{
  "version": 3,
  "sources": ["../../../src/components/widget-render/widget-render.tsx"],
  "sourcesContent": ["import { useCallback } from '@wordpress/element';\nimport { WidgetRender as WidgetRenderPrimitive } from '@wordpress/widget-primitives';\nimport type { WidgetType } from '@wordpress/widget-primitives';\nimport { useDashboardInternalContext } from '../../context/dashboard-context';\nimport type { DashboardWidget } from '../../types';\n\ninterface WidgetRenderProps {\n\twidget: DashboardWidget< unknown >;\n\twidgetType: WidgetType;\n}\n\n/**\n * Adapter around the host-agnostic `WidgetRender` primitive. Bridges the\n * dashboard context (`resolveWidgetModule`, layout state) and turns\n * layout-level attribute updates into the per-instance `setAttributes`\n * callback the render contract expects. When the policy denies `edit`,\n * the widget renders read-only: it receives no `setAttributes`.\n *\n * @param {WidgetRenderProps} props Component props.\n */\nexport function WidgetRender( { widget, widgetType }: WidgetRenderProps ) {\n\tconst { layout, onLayoutChange, resolveWidgetModule, canPerform } =\n\t\tuseDashboardInternalContext();\n\tconst canEdit = canPerform( { operation: 'edit', widget, widgetType } );\n\n\tconst setAttributes = useCallback(\n\t\t( next: Partial< unknown > ) => {\n\t\t\tonLayoutChange(\n\t\t\t\tlayout.map( ( w ) =>\n\t\t\t\t\tw.uuid === widget.uuid\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t...w,\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t...( w.attributes as object ),\n\t\t\t\t\t\t\t\t\t...( next as object ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t  }\n\t\t\t\t\t\t: w\n\t\t\t\t)\n\t\t\t);\n\t\t},\n\t\t[ widget.uuid, layout, onLayoutChange ]\n\t);\n\n\treturn (\n\t\t<WidgetRenderPrimitive\n\t\t\twidgetType={ widgetType }\n\t\t\tattributes={ widget.attributes }\n\t\t\tsetAttributes={ canEdit ? setAttributes : undefined }\n\t\t\tresolveWidgetModule={ resolveWidgetModule }\n\t\t/>\n\t);\n}\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA4B;AAC5B,+BAAsD;AAEtD,+BAA4C;AA0C1C;AAzBK,SAAS,aAAc,EAAE,QAAQ,WAAW,GAAuB;AACzE,QAAM,EAAE,QAAQ,gBAAgB,qBAAqB,WAAW,QAC/D,sDAA4B;AAC7B,QAAM,UAAU,WAAY,EAAE,WAAW,QAAQ,QAAQ,WAAW,CAAE;AAEtE,QAAM,oBAAgB;AAAA,IACrB,CAAE,SAA8B;AAC/B;AAAA,QACC,OAAO;AAAA,UAAK,CAAE,MACb,EAAE,SAAS,OAAO,OACf;AAAA,YACA,GAAG;AAAA,YACH,YAAY;AAAA,cACX,GAAK,EAAE;AAAA,cACP,GAAK;AAAA,YACN;AAAA,UACA,IACA;AAAA,QACJ;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAE,OAAO,MAAM,QAAQ,cAAe;AAAA,EACvC;AAEA,SACC;AAAA,IAAC,yBAAAA;AAAA,IAAA;AAAA,MACA;AAAA,MACA,YAAa,OAAO;AAAA,MACpB,eAAgB,UAAU,gBAAgB;AAAA,MAC1C;AAAA;AAAA,EACD;AAEF;",
  "names": ["WidgetRenderPrimitive"]
}
