@object-ui/plugin-dashboard 17.7.0 → 18.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +525 -0
- package/README.md +56 -17
- package/dist/DashboardGridLayout.d.ts +7 -6
- package/dist/DashboardGridLayout.d.ts.map +1 -1
- package/dist/DashboardRenderer.d.ts +30 -2
- package/dist/DashboardRenderer.d.ts.map +1 -1
- package/dist/DashboardWithConfig.d.ts.map +1 -1
- package/dist/DatasetWidget.d.ts +22 -23
- package/dist/DatasetWidget.d.ts.map +1 -1
- package/dist/MetricCard.d.ts +6 -0
- package/dist/MetricCard.d.ts.map +1 -1
- package/dist/MetricWidget.d.ts +21 -4
- package/dist/MetricWidget.d.ts.map +1 -1
- package/dist/ObjectMetricWidget.d.ts.map +1 -1
- package/dist/ObjectPivotTable.d.ts +7 -6
- package/dist/ObjectPivotTable.d.ts.map +1 -1
- package/dist/RecordDetailDrawer.d.ts +13 -2
- package/dist/RecordDetailDrawer.d.ts.map +1 -1
- package/dist/chartRenderHandoff.d.ts +9 -0
- package/dist/chartRenderHandoff.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1136 -1037
- package/dist/index.umd.cjs +3 -2
- package/dist/legacyRetiredWidget.d.ts +24 -1
- package/dist/legacyRetiredWidget.d.ts.map +1 -1
- package/dist/metricTile.d.ts +87 -0
- package/dist/metricTile.d.ts.map +1 -0
- package/dist/schemaHostProps.d.ts +55 -11
- package/dist/schemaHostProps.d.ts.map +1 -1
- package/dist/utils.d.ts +24 -6
- package/dist/utils.d.ts.map +1 -1
- package/dist/widgetDispatch.d.ts +36 -6
- package/dist/widgetDispatch.d.ts.map +1 -1
- package/package.json +11 -11
- package/dist/widgetSubCaption.d.ts +0 -40
- package/dist/widgetSubCaption.d.ts.map +0 -1
package/dist/index.umd.cjs
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("react"),require("@object-ui/core"),require("@object-ui/react"),require("@object-ui/i18n"),require("@object-ui/components"),require("lucide-react"),require("@dnd-kit/core"),require("@dnd-kit/sortable"),require("@dnd-kit/utilities"),require("@object-ui/types"),require("@objectstack/spec/ui"),require("react/jsx-runtime"),require("@object-ui/fields"),require("@object-ui/permissions"),require("react-grid-layout"),require("react-grid-layout/css/styles.css"),require("@objectstack/spec/data"),require("@object-ui/types/zod")):typeof define==`function`&&define.amd?define([`exports`,`react`,`@object-ui/core`,`@object-ui/react`,`@object-ui/i18n`,`@object-ui/components`,`lucide-react`,`@dnd-kit/core`,`@dnd-kit/sortable`,`@dnd-kit/utilities`,`@object-ui/types`,`@objectstack/spec/ui`,`react/jsx-runtime`,`@object-ui/fields`,`@object-ui/permissions`,`react-grid-layout`,`react-grid-layout/css/styles.css`,`@objectstack/spec/data`,`@object-ui/types/zod`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginDashboard={},e.React,e.ObjectUICore,e.ObjectUIReact,e.ObjectUII18n,e.ObjectUIComponents,e.lucide_react,e._dnd_kit_core,e._dnd_kit_sortable,e._dnd_kit_utilities,e.ObjectUITypes,e._objectstack_spec_ui,e.react_jsx_runtime,e.ObjectUIFields,e._object_ui_permissions,e.ReactGridLayout,e.react_grid_layout_css_styles_css,e._objectstack_spec_data,e._object_ui_types_zod))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var y=Object.create,b=Object.defineProperty,x=Object.getOwnPropertyDescriptor,S=Object.getOwnPropertyNames,C=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty,T=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=S(t),a=0,o=i.length,s;a<o;a++)s=i[a],!w.call(e,s)&&s!==n&&b(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=x(t,s))||r.enumerable});return e};t=((e,t,n)=>(n=e==null?{}:y(C(e)),T(t||!e||!e.__esModule||!w.call(e,`default`)?b(n,`default`,{value:e,enumerable:!0}):n,e)))(t,1);function E(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&e.provider===`object`}function D(e){return e.replace(/_/g,` `).replace(/([A-Z])/g,` $1`).trim().replace(/\b\w/g,e=>e.toUpperCase())}function O(e,t,n,r,i){if(i&&(!r||r===`value`||r===`count`||i===`count`))return e(`report.aggregate.${i}`,{defaultValue:i});let a=D(r);return n?t(n,r,a):a}function k(e){if(!Array.isArray(e)||e.length===0)return[];let t=e[0];return typeof t!=`object`||!t||Array.isArray(t)?[]:Object.keys(t).filter(e=>!e.startsWith(`_`)).map(e=>({header:D(e),accessorKey:e}))}function A(e,t){if(t==null||e==null||typeof e!=`number`||!Number.isFinite(e)||typeof t!=`number`||!Number.isFinite(t))return null;if(t===0)return e===0?{value:0,direction:`neutral`}:{value:100,direction:e>0?`up`:`down`};let n=e-t;if(n===0)return{value:0,direction:`neutral`};let r=Math.round(n/Math.abs(t)*100);return{value:Math.abs(r),direction:r>0?`up`:`down`}}var j;function M(){return j===void 0&&(j=d.DashboardWidgetSchema.shape.type.parse(void 0)),j}function N(e){return e.type===void 0?P(e)?void 0:M():e.type}function P(e){return e.component}function F(e){return u.DASHBOARD_COMPONENT_WIDGET_TYPES.includes(e.type)}function ee(e){return{type:`text`,content:`「${e}」chart type is not supported yet`,variant:`caption`,align:`center`,className:`flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-muted-foreground`}}var I={column:`bar`,"stacked-bar":`bar`,"grouped-bar":`bar`,"bi-polar-bar":`bar`,spline:`line`,"step-line":`line`,"stacked-area":`area`,pyramid:`funnel`,bubble:`scatter`},L=new Set([`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`scatter`,`funnel`,`radar`,`treemap`,`sankey`,`combo`]);function R(e){return L.has(e)}var te=new Set([`metric`,`gauge`,`solid-gauge`,`kpi`,`bullet`]),z=new Set([`table`,`list`]),B=new Set([`sunburst`,`word-cloud`,`choropleth`,`bubble-map`,`gl-map`,`heatmap`,`waterfall`,`box-plot`,`violin`,`candlestick`,`stock`]);function V(e){if(!e)return{family:`passthrough`};let t=I[e]??e;return R(t)?{family:`series`,chartType:t}:te.has(e)?{family:`metric`}:z.has(e)?{family:`table`}:e===`pivot`?{family:`pivot`}:e===`custom`?{family:`custom`}:B.has(e)?{family:`unsupported`}:{family:`passthrough`}}var H={metric:`plugin-dashboard:metric`,"metric-card":`plugin-dashboard:metric-card`},U=H;function W(e){if(!e||typeof e!=`object`)return e;let t=e.type,n=typeof t==`string`?U[t]:void 0;return n?{...e,type:n}:e}var G={type:`text`,content:`This widget uses a retired data format. Edit it to bind a dataset.`,variant:`caption`,align:`center`,className:`flex h-full w-full items-center justify-center rounded border border-dashed border-destructive/40 bg-destructive/5 p-4 text-center text-destructive`};function ne(e){if(!e)return!1;let t=e;return!t.dataset&&!(t.data||t.options?.data)&&!!t.object}var re=new Set([`object-metric`,`plugin-dashboard:object-metric`]);function ie(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`&&re.has(e.type)}function ae({source:e,className:t,testId:n}){let r=(0,i.useSafeTranslate)();return(0,f.jsx)(a.DataEmptyState,{role:`status`,"data-testid":n??`widget-empty-state`,className:(0,a.cn)(`h-full w-full gap-2 p-4 [&>h3]:text-sm [&>h3]:font-medium [&>p]:text-xs`,t),icon:(0,f.jsx)(o.Inbox,{className:`h-5 w-5 text-muted-foreground/70`}),iconWrapperClassName:`flex size-9 items-center justify-center rounded-lg bg-muted`,title:r(`dashboard.empty.title`,`No data yet`),description:r(`dashboard.empty.message`,`This widget loaded successfully and its query returned no records yet.`),children:e?(0,f.jsxs)(`p`,{className:`text-xs text-muted-foreground/80`,"data-testid":`widget-empty-source`,children:[(0,f.jsx)(`span`,{children:r(`dashboard.empty.sourceLabel`,`Source:`)}),` `,(0,f.jsx)(`span`,{className:`font-mono`,children:e})]}):null})}var K={default:`bg-muted text-muted-foreground`,blue:`bg-blue-500/10 text-blue-600 dark:text-blue-400`,teal:`bg-teal-500/10 text-teal-600 dark:text-teal-400`,orange:`bg-orange-500/10 text-orange-600 dark:text-orange-400`,purple:`bg-purple-500/10 text-purple-600 dark:text-purple-400`,success:`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`,warning:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,danger:`bg-rose-500/10 text-rose-600 dark:text-rose-400`},oe={default:`text-foreground`,blue:`text-blue-600 dark:text-blue-400`,teal:`text-teal-600 dark:text-teal-400`,orange:`text-orange-600 dark:text-orange-400`,purple:`text-purple-600 dark:text-purple-400`,success:`text-emerald-600 dark:text-emerald-400`,warning:`text-amber-600 dark:text-amber-400`,danger:`text-rose-600 dark:text-rose-400`};function se(e){if(typeof e==`string`&&e!=="default")return oe[e]}var ce=new Set([`id`,`organization_id`,`tenant_id`,`created_at`,`updated_at`,`created_by`,`updated_by`,`deleted_at`,`deleted_by`,`version`,`_id`,`__typename`]);function le(e,t){return t&&(t.isSystem===!0||t.system===!0)?!0:ce.has(e)}var ue=new Set([`select`,`picklist`,`dropdown`,`status`]),q=new Set([`currency`,`money`,`number`,`integer`,`decimal`,`float`,`percent`,`percentage`]),de=new Set([`date`,`datetime`]),J=[`reference`,`displayField`];function fe(e){let t={};if(!e)return t;for(let n of J)e[n]!==void 0&&(t[n]=e[n]);return t}function Y(e){let t={},n=e?.fields;if(!n)return t;if(Array.isArray(n))for(let e of n)e?.name&&(t[e.name]=e);else for(let[e,r]of Object.entries(n))t[e]={name:e,...r};return t}function pe(e){let{accessorKey:t,label:n,def:r,objectName:a,fieldOptionLabel:o,overrides:s={}}=e,c=s.options??r?.options;return a&&c&&o&&ue.has(r?.type)&&(c=c.map(e=>{if(e==null)return e;let n=typeof e==`object`?e.value:e,r=typeof e==`object`&&e.label||String(n);return{value:n,label:o(a,t,String(n),r),color:typeof e==`object`?e.color:void 0}})),{name:t,label:n,type:s.type??r?.type,options:c,format:s.format??r?.format,currency:s.currency??(0,i.resolveFieldCurrency)(r),...typeof r?.max==`number`&&{max:r.max},...fe(r)}}function X(e){return q.has(e.type)||typeof e.format==`string`&&/^[$¥€£]|%$|0/.test(e.format)}function Z(e,t,n,r){if(e==null||e===``)return``;let i=t.format;if(typeof i==`string`&&/^\$|¥|€|£/.test(i)&&typeof e==`number`){let a={$:`USD`,"¥":`JPY`,"€":`EUR`,"£":`GBP`}[i[0]];return(0,p.formatCurrency)(e,t.currency||a||n,r)}if(typeof i==`string`&&/%/.test(i)&&typeof e==`number`){let n=(i.match(/0\.(0+)%/)||[void 0,``])[1].length,a=t.type===`percent`||t.type===`progress`?(0,p.percentCellScale)(t):`fraction`;return(0,p.formatPercent)(e,a,n,r)}if(typeof i==`string`&&de.has(t.type)&&/[YMDHms]/.test(i))return(0,p.formatDate)(e,i,{locale:r});let a=(0,p.getCellRenderer)((0,p.resolveCellRendererType)(t));return(0,f.jsx)(a,{value:e,field:t})}function me(e){return typeof e==`string`&&(0,p.isRetiredFieldType)(e)?((0,p.reportRetiredFieldType)(e),!1):n.EXPANDABLE_FIELD_TYPES.has(e)}var he=[`name`,`title`,`label`,`subject`,`display_name`,`full_name`];function ge(e,t){if(t&&t.trim())return t;for(let t of he){let n=e[t];if(typeof n==`string`&&n.trim())return n}let n=e.id??e._id;return n==null?`Record`:String(n)}var _e=({record:e,objectName:n,objectSchema:r,fields:o,title:s,target:c=`drawer`,onClose:l,objectTypesPending:u=!1})=>{let{fieldLabel:d,fieldOptionLabel:m}=(0,i.useSafeFieldLabel)(),{currency:h}=(0,i.useLocalization)(),g=(0,i.useDisplayLocale)(),_=(0,t.useMemo)(()=>{if(!e)return[];let t=Y(r),i;return i=o&&o.length>0?o:Object.keys(t).length>0?Object.keys(t).filter(e=>!le(e,t[e])):Object.keys(e).filter(e=>!e.startsWith(`_`)&&!le(e)),i.map(r=>{let i=t[r],a=D(r),o=n?d(n,r,a):a,s=pe({accessorKey:r,label:o,def:i,objectName:n,fieldOptionLabel:m});return{key:r,label:o,node:u?(0,f.jsx)(p.MaskedCellRenderer,{value:e[r]}):Z(e[r],s,h,g),numeric:!u&&X(s)}})},[e,r,n,o,d,m,h,g,u]);if(!e)return null;let v=ge(e,s),y=(0,f.jsx)(`dl`,{className:`divide-y divide-border/60`,"data-testid":`record-detail-body`,children:_.map(e=>(0,f.jsxs)(`div`,{className:`grid grid-cols-3 gap-3 py-2.5`,children:[(0,f.jsx)(`dt`,{className:`text-xs font-medium text-muted-foreground self-center`,children:e.label}),(0,f.jsx)(`dd`,{className:`col-span-2 text-sm break-words ${e.numeric?`tabular-nums`:``}`,children:e.node===``||e.node==null?(0,f.jsx)(a.EmptyValue,{}):e.node})]},e.key))});return c===`dialog`?(0,f.jsx)(a.Dialog,{open:!0,onOpenChange:e=>!e&&l(),children:(0,f.jsxs)(a.DialogContent,{className:`max-w-2xl`,children:[(0,f.jsx)(a.DialogHeader,{children:(0,f.jsx)(a.DialogTitle,{children:v})}),(0,f.jsx)(`div`,{className:`max-h-[70vh] overflow-auto`,children:y})]})}):(0,f.jsx)(a.Sheet,{open:!0,onOpenChange:e=>!e&&l(),children:(0,f.jsxs)(a.SheetContent,{side:`right`,className:`w-full sm:max-w-md md:max-w-lg flex flex-col`,children:[(0,f.jsx)(a.SheetHeader,{children:(0,f.jsx)(a.SheetTitle,{children:v})}),(0,f.jsx)(`div`,{className:`flex-1 overflow-auto mt-2 pr-1`,children:y})]})})},ve=Object.freeze([]);function ye(e){return t.default.createElement(p.MaskedCellRenderer,{value:e})}function be(e){return e.map(e=>{if(typeof e==`string`)return{header:D(e),accessorKey:e};if(!e)return e;let t={};if(!e.accessorKey){let r=(0,n.columnIdentity)(e);r&&(t.accessorKey=r)}if(!e.header){let r=(0,n.columnHeader)(e);r&&(t.header=r)}return Object.keys(t).length===0?e:{...e,...t}})}function xe(e,t){if(!t?.fields)return[];let r={};if(Array.isArray(t.fields))for(let e of t.fields)e?.name&&(r[e.name]=e);else for(let[e,n]of Object.entries(t.fields))r[e]={name:e,...n};let i=Array.isArray(e.columns)?e.columns:[],a=new Set;if(i.length>0){let e=i.map(e=>typeof e==`string`?e:e?.accessorKey||(0,n.columnIdentity)(e)).filter(Boolean);for(let t of e){let e=r[t];e&&me(e.type)&&a.add(t)}}else for(let[e,t]of Object.entries(r))me(t?.type)&&a.add(e);return Array.from(a)}var Q=({schema:e,dataSource:o,className:s})=>{let{currency:c}=(0,i.useLocalization)(),l=(0,i.useDisplayLocale)(),d=(0,t.useContext)(r.SchemaRendererContext),h=o||d?.dataSource,g=(0,r.useDataScope)(e.bind),{fieldLabel:_,fieldOptionLabel:v}=(0,i.useSafeFieldLabel)(),y=`No data source available for`,{t:b}=(0,i.useObjectTranslation)(),x=b(`dashboard.noDataSourceFor`);x&&x!==`dashboard.noDataSourceFor`&&(y=x);let[S,C]=(0,t.useState)([]),[w,T]=(0,t.useState)(()=>!(Array.isArray(e.data)&&e.data.length>0)&&!!e.objectName),[E,O]=(0,t.useState)(null),k=e.drillDown,A=(0,n.isDrillEnabled)(k)&&(k?.mode??`record`)===`record`,[j,M]=(0,t.useState)(null),N=(0,t.useCallback)(e=>{M(e??null)},[]),P=(0,r.useFilterScope)(),F=(0,m.usePermissions)(),{ready:ee,def:I}=(0,r.useSettledSchema)(e.objectName??``,h),L=xe(e,I).join(`,`),R=!!h&&!!e.objectName&&!g&&(!e.data||e.data.length===0),te=(0,r.useDataInvalidation)(R?e.objectName:void 0);(0,t.useEffect)(()=>{let t=!0;return e.objectName&&!g&&(!e.data||e.data.length===0)?ee?(async()=>{if(!h||!e.objectName){t&&T(!1);return}t&&(T(!0),O(null));try{let r;if(typeof h.find==`function`){let t=xe(e,I),i=F?.isLoaded?t.filter(t=>F.checkField(e.objectName,t,`read`)):t,a={$filter:(0,n.resolveFilterPlaceholders)(e.filter,P)};i.length&&(a.$expand=i);let o=await h.find(e.objectName,a);r=(0,n.extractRecords)(o)}else return;t&&C(r)}catch(e){console.error(`[ObjectDataTable] Fetch error:`,e),t&&O(e instanceof Error?e.message:`Failed to load data`)}finally{t&&T(!1)}})():t&&T(!0):t&&T(!1),()=>{t=!1}},[e.objectName,h,g,e.data,e.filter,ee,I,L,P,F,te]);let z=g||e.data||S,B=Array.isArray(z)?z:ve,V=!!e.objectName&&typeof h?.getObjectSchema==`function`&&!I?.fields,H=(0,t.useMemo)(()=>{let t=e.objectName,n={};if(I?.fields){let e=I.fields;if(Array.isArray(e))for(let t of e)t?.name&&(n[t.name]=t);else for(let[t,r]of Object.entries(e))n[t]={name:t,...r}}let r=e=>{let n=D(e);return t?_(t,e,n):n},i=e=>{let r=e,i=pe({accessorKey:e.accessorKey,label:e.header,def:n[e.accessorKey],objectName:t,fieldOptionLabel:v,overrides:{type:r.type,format:r.format,options:r.options,currency:r.currency}}),a=e.align??(X(i)?`right`:void 0),o=(0,u.normalizeTableColumnType)(i.type),s=V||(0,p.isMaskedFieldType)(r.type)||(0,p.isMaskedFieldType)(n[e.accessorKey]?.type)?{masked:!0}:{};if(typeof e.cell==`function`)return{...e,name:i.name,type:o,align:a,...s};if(V&&!r.type)return{...e,name:i.name,type:o,align:a,cell:ye,...s};let d=e=>Z(e,i,c,l);return{...e,name:i.name,type:o,align:a,cell:d,...s}};return e.columns&&e.columns.length>0?be(e.columns).map(e=>{if(!e?.accessorKey)return e;let n=(e.header&&e.header!==e.accessorKey?e.header:void 0)??D(e.accessorKey),r=t?_(t,e.accessorKey,n):n;return r===e.header?e:{...e,header:r}}).map(i):B.length===0?[]:(Object.keys(n).length>0?Object.keys(n).filter(e=>!le(e,n[e])):Object.keys(B[0]).filter(e=>!e.startsWith(`_`)&&!le(e))).map(e=>i({header:r(e),accessorKey:e}))},[e.columns,e.objectName,B,I,V,_,v,c,l]);if(w&&B.length===0)return(0,f.jsx)(`div`,{className:(0,a.cn)(`overflow-auto`,s),"data-testid":`table-loading`,children:(0,f.jsxs)(`div`,{className:`space-y-2 p-2`,children:[(0,f.jsxs)(`div`,{className:`flex gap-2`,children:[(0,f.jsx)(a.Skeleton,{className:`h-6 w-1/4`}),(0,f.jsx)(a.Skeleton,{className:`h-6 w-1/4`}),(0,f.jsx)(a.Skeleton,{className:`h-6 w-1/4`}),(0,f.jsx)(a.Skeleton,{className:`h-6 w-1/4`})]}),[1,2,3,4].map(e=>(0,f.jsxs)(`div`,{className:`flex gap-2`,children:[(0,f.jsx)(a.Skeleton,{className:`h-5 w-1/4`}),(0,f.jsx)(a.Skeleton,{className:`h-5 w-1/4`}),(0,f.jsx)(a.Skeleton,{className:`h-5 w-1/4`}),(0,f.jsx)(a.Skeleton,{className:`h-5 w-1/4`})]},e))]})});if(E)return(0,f.jsx)(`div`,{className:(0,a.cn)(`overflow-auto`,s),"data-testid":`table-error`,children:(0,f.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-destructive`,"data-testid":`table-error-message`,children:[(0,f.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 mb-2 opacity-60`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,f.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,f.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,f.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),(0,f.jsx)(`p`,{className:`text-xs`,children:E})]})});if(!h&&e.objectName&&B.length===0)return(0,f.jsx)(`div`,{className:(0,a.cn)(`overflow-auto`,s),children:(0,f.jsx)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:(0,f.jsxs)(`p`,{className:`text-xs`,children:[y,` “`,e.objectName,`”`]})})});if(B.length===0)return(0,f.jsx)(`div`,{className:(0,a.cn)(`overflow-auto`,s),"data-testid":`table-empty-state`,children:(0,f.jsx)(ae,{source:e.objectName||void 0,className:`py-8`})});let{bind:U,...W}=e,G={...W,type:`data-table`,data:B,columns:H,onRowClick:e.onRowClick??(A?N:void 0)},ne=k?.title&&!k.title.includes("${")?k.title:void 0;return(0,f.jsxs)(`div`,{className:(0,a.cn)(`relative`,s),children:[(0,f.jsx)(a.RefreshIndicator,{active:w&&B.length>0,ariaLabel:b(`dashboard.refreshing`)}),(0,f.jsx)(r.SchemaRenderer,{schema:G,className:s}),A&&(0,f.jsx)(_e,{record:j,objectName:e.objectName,objectSchema:I,fields:k?.columns,title:ne,target:k?.target===`dialog`?`dialog`:`drawer`,onClose:()=>M(null),objectTypesPending:V})]})},Se=({objectName:e,filter:t,onNavigate:n,className:s})=>{let{openRecordList:c}=(0,r.useDrillNavigation)(),l=(0,i.useSafeTranslate)();return!c||!e?null:(0,f.jsxs)(a.Button,{type:`button`,variant:`ghost`,size:`sm`,className:s,"data-testid":`drill-open-in-list`,onClick:()=>{c(e,t),n?.()},children:[l(`dashboard.openInList`,`Open in list`),(0,f.jsx)(o.ArrowUpRight,{className:`ml-1 h-3.5 w-3.5`})]})};function $(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.dataset==`string`&&t.dataset.length>0||t.type===`joined`&&Array.isArray(t.blocks)&&t.blocks.some(e=>typeof e?.dataset==`string`)}var Ce=({open:e,onClose:n,title:i,target:o=`drawer`,objectName:s,filter:c,dataSource:l,columns:u,maxRows:d,className:p,report:m})=>{let{openRecordList:h}=(0,r.useDrillNavigation)(),g=$(m),_=o===`navigate`&&!!h&&!g&&!!s;if(t.default.useEffect(()=>{e&&_&&(h(s,c),n())},[e,_]),_)return null;let v=g?null:(0,f.jsx)(Se,{objectName:s,filter:c,onNavigate:n}),y=(0,f.jsx)(`div`,{className:(0,a.cn)(`overflow-auto`,p),"data-testid":`drill-down-body`,children:g?(()=>{let e=m.runtimeFilter,t=e?c?{$and:[e,c]}:e:c,n={type:`report`,report:t?{...m,runtimeFilter:t}:m};return(0,f.jsx)(r.SchemaRenderer,{schema:n})})():(0,f.jsx)(Q,{schema:{type:`object-data-table`,objectName:s,filter:c,columns:u?.map(e=>({accessorKey:e,header:e})),pagination:!0,searchable:!1,pageSize:d,drillDown:{enabled:!0,mode:`record`,target:`dialog`}},dataSource:l})});return o===`dialog`?(0,f.jsx)(a.Dialog,{open:e,onOpenChange:e=>!e&&n(),children:(0,f.jsxs)(a.DialogContent,{className:`max-w-5xl`,children:[(0,f.jsxs)(a.DialogHeader,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,f.jsx)(a.DialogTitle,{children:i}),v]}),y]})}):(0,f.jsx)(a.Sheet,{open:e,onOpenChange:e=>!e&&n(),children:(0,f.jsxs)(a.SheetContent,{side:`right`,className:`w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col`,children:[(0,f.jsxs)(a.SheetHeader,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,f.jsx)(a.SheetTitle,{children:i}),v]}),(0,f.jsx)(`div`,{className:`flex-1 overflow-hidden mt-2`,children:y})]})})},we=n.buildDatasetDrillFilter;function Te(e,t,r,i){let a=[],o=[],s=new Set,c=new Set,l=new Map;return e.forEach((e,u)=>{let d=(0,n.pivotBucketId)(t.map(t=>(0,n.pivotDimensionValue)(e[t]))),f=(0,n.pivotBucketId)([(0,n.pivotDimensionValue)(e[r])]);s.has(d)||(s.add(d),a.push({id:d,labels:t.map(t=>(0,n.formatDimensionValue)(e[t],i))})),c.has(f)||(c.add(f),o.push({id:f,label:(0,n.formatDimensionValue)(e[r],i)})),l.set((0,n.pivotCellKey)(d,f),u)}),{rowHeaders:a,colHeaders:o,cellIndex:l}}function Ee(e){if(e==null)return``;let t=String(e);return/[",\n\r]/.test(t)?`"${t.replace(/"/g,`""`)}"`:t}function De(e){return e.map(e=>e.map(Ee).join(`,`)).join(`\r
|
|
2
|
-
`)}function Oe(e,t){if(typeof document>`u`)return;let n=e&&e.trim()?e.trim():`export`,r=new Blob([`\uFEFF${De(t)}`],{type:`text/csv;charset=utf-8;`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=n.endsWith(`.csv`)?n:`${n}.csv`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)}var ke=`__compare`,Ae=e=>`${e}${ke}`,je={vsLastQuarter:`vs last quarter`,vsLastMonth:`vs last month`,vsLastWeek:`vs last week`,vsLastYear:`vs last year`,vsYesterday:`vs yesterday`,vsPreviousPeriod:`vs previous period`},Me=/^\d{4}-\d{2}-\d{2}(?:[T ][\d:.]+(?:Z|[+-]\d{2}:?\d{2})?)?$/;function Ne(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=Object.keys(e);if(t.length!==2||!t.includes(`$gte`)||!t.includes(`$lte`))return null;let{$gte:n,$lte:r}=e;return typeof n!=`string`||typeof r!=`string`||!Me.test(n)||!Me.test(r)?null:[n,r]}function Pe(e){let t=new Map,n=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return e;let r={},i=null;for(let[a,o]of Object.entries(e)){if(a===`$and`&&Array.isArray(o)){i=o.map(n).filter(e=>!!e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length>0);continue}if(a.startsWith(`$`)){r[a]=o;continue}let e=Ne(o);if(!e){r[a]=o;continue}let s=t.get(a);t.set(a,s?[s[0]>e[0]?s[0]:e[0],s[1]<e[1]?s[1]:e[1]]:e)}return i&&i.length>0&&(r.$and=i),r},r=n(e),i=r&&Object.keys(r).length>0?r:void 0,a=i&&Object.keys(i).length===1&&Array.isArray(i.$and)&&i.$and.length===1?i.$and[0]:void 0;return a&&(i=a),{windows:Array.from(t,([e,t])=>({dimension:e,dateRange:t})),rest:i}}var Fe=new Set([`metric`,`kpi`,`gauge`,`solid-gauge`,`bullet`]),Ie=new Set([`bar`,`column`,`horizontal-bar`,`line`,`area`,`combo`]),Le=new Set([`pie`,`donut`,`funnel`,`treemap`,`sankey`]),Re=`__measure`,ze=`__value`,Be={bar:`bar`,column:`column`,"horizontal-bar":`horizontal-bar`,"grouped-bar":`bar`,"stacked-bar":`bar`,"bi-polar-bar":`bar`,line:`line`,spline:`line`,"step-line":`line`,area:`area`,"stacked-area":`area`,pie:`pie`,donut:`donut`,funnel:`funnel`,pyramid:`funnel`,scatter:`scatter`,bubble:`scatter`,radar:`radar`,treemap:`treemap`,sankey:`sankey`,combo:`combo`};function Ve({widget:e,dataSource:s,subCaption:c}){let l=String(e?.dataset??``),u=(0,t.useMemo)(()=>Array.isArray(e?.dimensions)?e.dimensions.filter(Boolean):[],[e]),d=(0,t.useMemo)(()=>Array.isArray(e?.values)?e.values.filter(Boolean):[],[e]),p=String(e?.type??M()),m=p===`table`||p===`pivot`,h=d.length>1&&(m||Ie.has(Be[p]??``)),g=Fe.has(p)||u.length===0&&!h,_=Be[p]??`bar`,v=!g&&!m&&Le.has(_),y=g||v?d.slice(0,1):d,b=d.filter(e=>!y.includes(e)),x=!g&&!m&&(0,n.chartTypeIgnoresCompareTo)(_)?void 0:e?.compareTo,S=p===`pivot`&&u.length>=2,C=S?u.slice(0,-1):[],w=S?u[u.length-1]:``,T=e?.options&&typeof e.options==`object`&&!Array.isArray(e.options)?e.options:{},E=typeof T.dateGranularity==`string`?T.dateGranularity:void 0,D=typeof T.sortBy==`string`&&T.sortBy?T.sortBy:void 0,O=D&&(u.includes(D)||d.includes(D))?D:void 0,k=O?{[O]:T.sortOrder===`desc`?`desc`:`asc`}:void 0,j=typeof T.limit==`number`&&Number.isFinite(T.limit)&&T.limit>0?Math.floor(T.limit):void 0,N=m&&!S&&u.length>0&&j==null,P=S?[C,[w],[]]:N?[[]]:void 0,F=(0,i.useSafeTranslate)(),{fieldLabel:ee,fieldOptionLabel:I}=(0,i.useSafeFieldLabel)(),L=(0,i.useDisplayLocale)(),{language:R}=(0,i.useObjectTranslation)(),te=(0,r.useFilterScope)(),z=e?.filter,B=(0,t.useMemo)(()=>z&&typeof z==`object`&&Object.keys(z).length>0?(0,n.resolveFilterPlaceholders)(z,te):void 0,[z,te]),{windows:V,rest:H}=(0,t.useMemo)(()=>x?Pe(B):{windows:[],rest:B},[x,B]),[U,W]=(0,t.useState)({status:`idle`,rows:[]}),[G,ne]=(0,t.useState)(null),[re,ie]=(0,t.useState)(null),K=`${p}|${l}|${u.join(`,`)}|${d.join(`,`)}|${JSON.stringify(z??null)}|${JSON.stringify(x??null)}|${E??``}|${JSON.stringify(k??null)}|${j??``}`,[oe,ce]=(0,t.useState)(void 0),le=(0,r.useDataInvalidation)(d.length>0?oe:void 0);(0,t.useEffect)(()=>{let e=s;if(!e||typeof e.queryDataset!=`function`){W({status:`error`,rows:[],error:F(`dashboard.datasetUnsupported`,`This data source does not support dataset queries.`)});return}if(d.length===0){W({status:`idle`,rows:[]});return}let t=!1;return W(e=>e.status===`ok`&&e.signature===K?{...e,refreshing:!0}:{status:`loading`,rows:[]}),e.queryDataset(l,{dimensions:u,measures:d,...H?{runtimeFilter:H}:{},...V.length>0?{timeDimensions:V}:{},...x?{compareTo:x}:{},...P?{totals:{groupings:P}}:{},...E?{dateGranularity:E}:{},...k?{order:k}:{},...j==null?{}:{limit:j}}).then(e=>{t||(W({status:`ok`,rows:Array.isArray(e?.rows)?e.rows:[],fields:Array.isArray(e?.fields)?e.fields:[],object:e?.object,dimensionFields:e?.dimensionFields,drillRawRows:Array.isArray(e?.drillRawRows)?e.drillRawRows:void 0,drillRanges:Array.isArray(e?.drillRanges)?e.drillRanges:void 0,totals:Array.isArray(e?.totals)?e.totals:void 0,signature:K}),typeof e?.object==`string`&&e.object&&ce(e.object))}).catch(e=>{if(!t){if((0,r.classifyLoadError)(e)===`forbidden`){W({status:`error`,rows:[],forbidden:!0});return}W({status:`error`,rows:[],error:String(e?.message??e)})}}),()=>{t=!0}},[K,le]);let ue=e=>e.map(e=>`"${e}"`).join(`, `),q=b.length>0?`[DatasetWidget] Widget "${String(e?.id??``)}" (type "${p}", dataset "${l}") renders ${y.length} of its ${d.length} declared measures: ${ue(y)}. Queried and then never displayed: ${ue(b)}. `+(v?`Its chart family "${_}" draws a single series: the first declared measure.`:`The spec states what to author instead of a one-number tile with several measures in the replacement of its ADR-0087 entry "dashboard-widget-metric-family-multi-measure-refused".`):``;(0,t.useEffect)(()=>{q&&console.warn(q)},[q]);let de=(0,r.useDatasetDimensionMeta)(U.object,U.dimensionFields,u,{enabled:!g}),{categoryColors:J,dimensionLabels:fe,categoryOrder:Y}=(0,t.useMemo)(()=>{if(!de)return{categoryColors:null,dimensionLabels:null,categoryOrder:null};let{metaByPath:e,relabel:t}=de,r=m?void 0:t[0]?.path,i=r?e[r]:void 0,a=r?(0,n.localizeFieldOptions)(i?.options,(0,n.dimensionOptionTranslator)(i,I)):void 0;return{categoryColors:(0,n.buildOptionColorMap)(a),dimensionLabels:(0,n.deriveDimensionLabelMaps)(e,t,I),categoryOrder:(0,n.buildCategoryOrder)(a)}},[de,I,m]);if(d.length===0)return(0,f.jsx)(`div`,{className:`flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-xs text-muted-foreground`,children:F(`dashboard.pickMeasures`,`Pick measures (values) for this dataset widget.`)});if(U.status===`loading`||U.status===`idle`)return(0,f.jsxs)(`div`,{className:`h-full w-full p-2`,"data-testid":`dataset-loading`,role:`status`,"aria-busy":`true`,"aria-live":`polite`,children:[(0,f.jsx)(`span`,{className:`sr-only`,children:F(`dashboard.loading`,`Loading…`)}),g?(0,f.jsxs)(`div`,{className:`flex h-full w-full flex-col items-start justify-center gap-2 p-2`,children:[(0,f.jsx)(a.Skeleton,{className:`h-8 w-32 rounded`}),(0,f.jsx)(a.Skeleton,{className:`h-3 w-20 rounded`})]}):m?(0,f.jsx)(a.GridSkeleton,{className:`h-full`,rows:5,columns:Math.max(2,u.length+d.length)}):(0,f.jsx)(a.ChartSkeleton,{className:`h-full`})]});if(U.status===`error`&&U.forbidden)return(0,f.jsxs)(`div`,{role:`alert`,"data-testid":`dataset-widget-forbidden`,className:`flex h-full w-full flex-col items-center justify-center gap-1 p-3 text-center text-xs text-muted-foreground`,children:[(0,f.jsx)(o.ShieldAlert,{className:`h-5 w-5 text-muted-foreground/70`,"aria-hidden":`true`}),(0,f.jsx)(`span`,{className:`font-medium text-foreground/80`,children:F(`dashboard.widgetForbiddenTitle`,`You don’t have access`)}),(0,f.jsx)(`span`,{children:F(`dashboard.widgetForbiddenMessage`,`You don’t have permission to view the data behind this widget.`)})]});if(U.status===`error`)return(0,f.jsxs)(`div`,{role:`alert`,className:`flex h-full w-full items-start gap-2 rounded border border-destructive/40 bg-destructive/5 p-3 text-xs text-destructive`,children:[(0,f.jsx)(o.AlertTriangle,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),(0,f.jsx)(`span`,{className:`break-words`,children:U.error})]});let pe=(0,f.jsx)(a.RefreshIndicator,{active:!!U.refreshing,ariaLabel:F(`dashboard.refreshing`,`Refreshing…`)});if(U.rows.length===0&&!g)return(0,f.jsx)(ae,{className:`rounded border border-dashed bg-muted/20`,source:l||void 0});let{measureField:X,headerLabel:Z}=(0,n.buildDatasetFieldHelpers)(U.fields,U.object,ee,(0,i.builtinAggregateLabels)(F)),me=x?d.filter(e=>U.rows.some(t=>t[Ae(e)]!=null)):[],he=x?(0,n.compareToTrendLabelKey)(x,z):``,ge=x?F(`dashboard.trend.${he}`,je[he]??`vs previous period`):``,{object:_e,dimensionFields:ve,drillRawRows:ye,drillRanges:be}=U,xe=ve?u.filter(e=>e in ve):[],Q=!!_e&&(xe.length>0||!!be?.length),Se=(t,r)=>{if(!_e)return;let i;try{i=we(ye?.[t],xe,ve??{},B,be?.[t])}catch(e){if(!(e instanceof n.FilterOperatorError))throw e;console.warn(`[DatasetWidget] drill-down refused — the drilled list cannot be scoped: ${e.message}`);return}ne({filter:i,title:r||String(e?.title??``)})},$=G&&_e?(0,f.jsx)(Ce,{open:!0,onClose:()=>ne(null),title:G.title||String(e?.title??F(`dashboard.details`,`Details`)),objectName:_e,filter:G.filter,dataSource:s}):null;if(g){let t=y[0],r=X(t),s=U.rows[0]?.[t]??0,l=U.rows[0]?.[Ae(t)],u=me.includes(t)?A(typeof s==`number`?s:null,typeof l==`number`?l:null):null,d=se(e?.colorVariant),p=c===void 0?(0,i.pickLocalized)(T.description,R)||void 0:c||void 0;return(0,f.jsxs)(`div`,{className:(0,a.cn)(`flex h-full w-full flex-col items-start justify-center gap-1 p-2`,U.refreshing&&`relative`),children:[pe,(0,f.jsx)(`span`,{className:(0,a.cn)(`text-2xl font-semibold tabular-nums`,d),children:(0,n.formatMeasure)(s,r?.format,r?.currency,r?.percentScale,L)}),u&&(0,f.jsxs)(`div`,{className:`mt-0.5 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground`,"data-testid":`dataset-compare-trend`,children:[(0,f.jsxs)(`span`,{className:(0,a.cn)(`flex shrink-0 items-center font-medium`,u.direction===`up`&&`text-emerald-600 dark:text-emerald-400`,u.direction===`down`&&`text-rose-600 dark:text-rose-400`,u.direction===`neutral`&&`text-muted-foreground`),children:[u.direction===`up`&&(0,f.jsx)(o.ArrowUpIcon,{className:`mr-1 h-3 w-3`}),u.direction===`down`&&(0,f.jsx)(o.ArrowDownIcon,{className:`mr-1 h-3 w-3`}),u.direction===`neutral`&&(0,f.jsx)(o.MinusIcon,{className:`mr-1 h-3 w-3`}),u.value,`%`]}),(0,f.jsx)(`span`,{className:`min-w-0 truncate`,children:ge})]}),(0,f.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Z(t)}),p&&(0,f.jsx)(`span`,{className:`text-xs text-muted-foreground`,"data-testid":`dataset-metric-subcaption`,children:p})]})}if(m){let t=(0,n.relabelDimensions)(U.rows,fe),r=e=>{if(d.includes(e)||!e.endsWith(ke))return;let t=e.slice(0,-9);return d.includes(t)?t:void 0},i=e=>{let t=r(e);return t?`${Z(t)} · ${ge}`:Z(e)},s=d.flatMap(e=>me.includes(e)?[e,Ae(e)]:[e]),c=[...u,...s],p=t=>Oe(String(e?.title??l??`export`),[c.map(e=>i(e)),...t.map(e=>c.map(t=>{let n=e[t];return n==null?``:typeof n==`number`?n:String(n)}))]),m=e=>(0,f.jsx)(`button`,{type:`button`,onClick:()=>p(e),"data-testid":`dataset-export`,title:F(`dashboard.exportCsv`,`Export CSV`),"aria-label":F(`dashboard.exportCsv`,`Export CSV`),className:`absolute right-1 top-1 z-10 rounded p-1 text-muted-foreground opacity-70 hover:bg-accent/50 hover:text-foreground hover:opacity-100`,children:(0,f.jsx)(o.Download,{className:`h-3.5 w-3.5`})}),h=m(t);if(S){let e=Te(t,C,w,L),r=e.colHeaders.flatMap(e=>d.map(t=>({col:e,measure:t,header:d.length===1?e.label:`${e.label} · ${Z(t)}`}))),i=(e,t)=>(0,n.formatMeasure)(e,X(t)?.format,X(t)?.currency,X(t)?.percentScale,L),s=(e,t)=>{if(!me.includes(t))return null;let n=e?.[Ae(t)];if(n==null)return null;let r=e?.[t],s=A(typeof r==`number`?r:null,typeof n==`number`?n:null);return(0,f.jsxs)(`div`,{className:`flex items-center justify-end gap-1 text-[10px] font-normal leading-tight text-muted-foreground`,"data-testid":`matrix-cell-compare`,"data-direction":s?.direction,title:ge,children:[(0,f.jsx)(`span`,{className:`tabular-nums`,children:i(n,t)}),s&&(0,f.jsxs)(`span`,{className:(0,a.cn)(`flex shrink-0 items-center tabular-nums font-medium`,s.direction===`up`&&`text-emerald-600 dark:text-emerald-400`,s.direction===`down`&&`text-rose-600 dark:text-rose-400`),children:[s.direction===`up`&&(0,f.jsx)(o.ArrowUpIcon,{className:`h-2.5 w-2.5`}),s.direction===`down`&&(0,f.jsx)(o.ArrowDownIcon,{className:`h-2.5 w-2.5`}),s.direction===`neutral`&&(0,f.jsx)(o.MinusIcon,{className:`h-2.5 w-2.5`}),s.value,`%`]})]})},c=me.length>0?(0,f.jsx)(`caption`,{className:`px-2 pb-1 text-left text-[10px] font-normal text-muted-foreground`,"data-testid":`matrix-compare-caption`,children:ge}):null,l=e=>{let t=U.totals?.find(t=>Array.isArray(t.dimensions)&&t.dimensions.join(`,`)===e.join(`,`))?.rows;return t&&(0,n.relabelDimensions)(t,fe)},u=new Map;for(let e of l(C)??[])u.set((0,n.pivotBucketId)(C.map(t=>(0,n.pivotDimensionValue)(e[t]))),e);let p=new Map;for(let e of l([w])??[])p.set((0,n.pivotBucketId)([(0,n.pivotDimensionValue)(e[w])]),e);let m=l([])?.[0],g=u.size>0,_=p.size>0,v=F(`dashboard.total`,`Total`);return(0,f.jsxs)(`div`,{className:`relative h-full w-full overflow-auto p-1`,"data-testid":`dataset-matrix`,children:[pe,h,(0,f.jsxs)(`table`,{className:`w-full text-xs`,children:[c,(0,f.jsx)(`thead`,{className:`bg-muted/40`,children:(0,f.jsxs)(`tr`,{children:[C.map(e=>(0,f.jsx)(`th`,{className:`px-2 py-1.5 text-left font-medium whitespace-nowrap`,children:Z(e)},e)),r.map(e=>(0,f.jsx)(`th`,{className:`px-2 py-1.5 text-right font-medium whitespace-nowrap`,children:e.header},`${e.col.id}-${e.measure}`)),g&&d.map(e=>(0,f.jsx)(`th`,{className:`px-2 py-1.5 text-right font-medium whitespace-nowrap`,"data-testid":`matrix-total-col-header`,children:d.length===1?v:`${v} · ${Z(e)}`},`total-${e}`))]})}),(0,f.jsxs)(`tbody`,{children:[e.rowHeaders.map(t=>(0,f.jsxs)(`tr`,{className:`border-t`,children:[t.labels.map((e,t)=>(0,f.jsx)(`td`,{className:`px-2 py-1 whitespace-nowrap font-medium`,children:e},t)),r.map(r=>{let o=e.cellIndex.get((0,n.pivotCellKey)(t.id,r.col.id)),c=o==null?void 0:U.rows[o],l=Q&&o!=null,u=[...t.labels,r.col.label].filter(Boolean).join(` / `);return(0,f.jsxs)(`td`,{className:(0,a.cn)(`px-2 py-1 text-right tabular-nums whitespace-nowrap`,l&&`cursor-pointer hover:bg-accent/40`),"data-testid":l?`dataset-drill-cell`:void 0,onClick:l?()=>Se(o,u):void 0,children:[c?i(c[r.measure],r.measure):`—`,s(c,r.measure)]},`${r.col.id}-${r.measure}`)}),g&&d.map(e=>{let n=u.get(t.id);return(0,f.jsxs)(`td`,{className:`px-2 py-1 text-right tabular-nums whitespace-nowrap font-medium`,"data-testid":`matrix-row-total`,children:[i(n?.[e],e),s(n,e)]},`total-${e}`)})]},t.id)),_&&(0,f.jsxs)(`tr`,{className:`border-t bg-muted/30 font-medium`,"data-testid":`matrix-total-row`,children:[C.length>0&&(0,f.jsx)(`td`,{colSpan:C.length,className:`px-2 py-1 whitespace-nowrap`,children:v}),r.map(e=>{let t=p.get(e.col.id);return(0,f.jsxs)(`td`,{className:`px-2 py-1 text-right tabular-nums whitespace-nowrap`,children:[i(t?.[e.measure],e.measure),s(t,e.measure)]},`${e.col.id}-${e.measure}`)}),g&&d.map(e=>(0,f.jsxs)(`td`,{className:`px-2 py-1 text-right tabular-nums whitespace-nowrap`,"data-testid":`matrix-grand-total`,children:[i(m?.[e],e),s(m,e)]},`grand-${e}`))]})]})]}),$]})}let g=[...u,...s],_=new Set(g.filter(e=>(d.includes(e)||r(e)!==void 0)&&t.every(t=>t[e]==null||typeof t[e]==`number`))),v=t.map((e,t)=>({row:e,index:t})),y=re&&g.includes(re.column)?re:null,b=y?v.map(e=>({...e,key:(0,n.getSortValue)(e.row[y.column])})).sort((e,t)=>{if(e.key===null&&t.key===null)return 0;if(e.key===null)return 1;if(t.key===null)return-1;let r=(0,n.compareSortValues)(e.key,t.key);return y.dir===`asc`?r:-r}):[...v].sort((e,t)=>{for(let r of u){let i=+((0,n.getSortValue)(e.row[r])===null),a=+((0,n.getSortValue)(t.row[r])===null);if(i!==a)return i-a}return 0}),x=e=>_.has(e)?`desc`:`asc`,T=e=>ie(t=>{let n=x(e);return t?.column===e?t.dir===n?{column:e,dir:n===`asc`?`desc`:`asc`}:null:{column:e,dir:n}}),E=N?U.totals?.find(e=>Array.isArray(e.dimensions)&&e.dimensions.length===0)?.rows?.[0]:void 0,D=F(`dashboard.total`,`Total`),O=e=>{if(y?.column!==e)return(0,f.jsx)(o.ChevronsUpDown,{className:`ml-0.5 h-3 w-3 shrink-0 opacity-0 transition-opacity group-hover:opacity-50`,"aria-hidden":`true`});let t=y.dir===`asc`?o.ChevronUp:o.ChevronDown;return(0,f.jsx)(t,{className:`ml-0.5 h-3 w-3 shrink-0 text-primary`,"aria-hidden":`true`})};return(0,f.jsxs)(`div`,{className:`relative h-full w-full overflow-auto p-1`,children:[pe,m(b.map(e=>e.row)),(0,f.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,f.jsx)(`thead`,{className:`bg-muted/40`,children:(0,f.jsx)(`tr`,{children:g.map(e=>{let t=_.has(e);return(0,f.jsx)(`th`,{scope:`col`,"aria-sort":y?.column===e?y.dir===`asc`?`ascending`:`descending`:`none`,className:(0,a.cn)(`group px-2 py-1.5 font-medium whitespace-nowrap`,t?`text-right`:`text-left`),"data-testid":r(e)?`dataset-compare-column`:void 0,children:(0,f.jsxs)(`button`,{type:`button`,onClick:()=>T(e),"data-testid":`dataset-table-sort`,className:(0,a.cn)(`inline-flex w-full select-none items-center font-medium transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,t?`justify-end`:`justify-between`),children:[(0,f.jsx)(`span`,{className:`truncate`,children:i(e)}),O(e)]})},e)})})}),(0,f.jsx)(`tbody`,{children:b.map(({row:e,index:t})=>(0,f.jsx)(`tr`,{className:(0,a.cn)(`border-t transition-colors hover:bg-muted/40`,Q&&`cursor-pointer hover:bg-accent/40`),"data-testid":Q?`dataset-drill-row`:void 0,onClick:Q?()=>Se(t,xe.map(t=>(0,n.formatDimensionValue)(e[t],L)).filter(Boolean).join(` / `)):void 0,children:g.map(t=>{let i=r(t)??(d.includes(t)?t:void 0);return(0,f.jsx)(`td`,{className:(0,a.cn)(`px-2 py-1 whitespace-nowrap tabular-nums`,_.has(t)&&`text-right`),children:i?(0,n.formatMeasure)(e[t],X(i)?.format,X(i)?.currency,X(i)?.percentScale,L):(0,n.formatDimensionValue)(e[t],L)},t)})},t))}),E&&(0,f.jsx)(`tfoot`,{className:`bg-muted/30`,children:(0,f.jsxs)(`tr`,{className:`border-t font-medium`,"data-testid":`dataset-table-total-row`,children:[(0,f.jsx)(`td`,{colSpan:u.length,className:`px-2 py-1 whitespace-nowrap`,children:D}),s.map(e=>{let t=r(e)??e;return(0,f.jsx)(`td`,{className:(0,a.cn)(`px-2 py-1 whitespace-nowrap tabular-nums`,_.has(e)&&`text-right`),children:(0,n.formatMeasure)(E[e],X(t)?.format,X(t)?.currency,X(t)?.percentScale,L)},e)})]})})]}),$]})}let Ee=(0,n.relabelDimensions)(U.rows,fe),De=F(`chart.nullCategory`,`(None)`),Me=u.length===0,Ne=F(`dashboard.total`,`Total`),{data:Ve,xAxisKey:He,series:Ue}=Me?{data:d.map(e=>({[Re]:Z(e),[ze]:U.rows[0]?.[e],...me.includes(e)?{[Ae(ze)]:U.rows[0]?.[Ae(e)]}:{}})),xAxisKey:Re,series:[{dataKey:ze,label:Ne}]}:(0,n.buildChartSeries)(Ee,u,d,U.fields,{nullCategoryLabel:De,builtinAggregateLabels:(0,i.builtinAggregateLabels)(F)}),We=u.length>=2&&d.length===1,Ge=Me?me.length>0?[{dataKey:ze,label:Ne}]:[]:me.map(e=>({dataKey:e,label:Z(e)})),Ke=We?[]:Ge.map(({dataKey:e,label:t})=>({dataKey:Ae(e),label:`${t} · ${ge}`,variant:`comparison`})),qe=Ke.length>0?[...Ue.map(e=>({...e,variant:`current`})),...Ke]:Ue,Je=(Array.isArray(T.stageOrder)?T.stageOrder:void 0)?.flatMap(e=>{let t=String(e),n=fe?.[u[0]]?.[t];return n&&n!==t?[t,n]:[t]}),Ye=Je?.length?Je:Y,Xe=(0,n.chartConfigPresentation)(e?.chartConfig,J),Ze=Q?e=>{let t=(0,n.findChartSeriesRow)(Ee,u,d,e?.category,e?.series,{nullCategoryLabel:De,bucketId:e?.categoryId});if(t<0)return;let r=u.length>=2&&d.length===1,i=e?.seriesLabel??e?.series,a=[e?.category,r?i:void 0].filter(Boolean).map(String).join(` / `);Se(t,a)}:void 0;return(0,f.jsxs)(`div`,{className:(0,a.cn)(`relative h-full w-full min-h-[220px]`),children:[pe,(0,f.jsx)(r.SchemaRenderer,{schema:{type:`chart`,chartType:_,data:Ve,xAxisKey:He,series:qe,isAnimationActive:!1,...Xe,...Ye?{categoryOrder:Ye}:{}},onChartClick:Ze,onSegmentClick:Ze}),$]})}function He(e,n=!1){let{widgetSubCaption:r}=(0,i.useObjectLabel)(),{language:a}=(0,i.useObjectTranslation)();return(0,t.useCallback)(t=>{let o=t.options?.description,s=(0,i.pickLocalized)(o,a)||void 0;return n||!e||!t.id?s:r(e,t.id,s)},[n,e,r,a])}function Ue(e,t){e&&(t(!0),e(),setTimeout(()=>t(!1),600))}function We(e,n){let[r,i]=t.useState(!1),a=t.useRef(n);t.useEffect(()=>{a.current=n});let o=t.useCallback(()=>{Ue(a.current,i)},[]),s=e.refreshIntervalSeconds,c=!!n;return t.useEffect(()=>{if(!s||s<=0||!c)return;let e=setInterval(()=>Ue(a.current,i),s*1e3);return()=>clearInterval(e)},[s,c]),{refreshing:r,handleRefresh:o}}function Ge(e){let{language:t}=(0,i.useObjectTranslation)(),{fieldLabel:n}=(0,i.useSafeFieldLabel)(),r=(0,i.pickLocalized)(e.label,t);return e.object?n(e.object,e.field,r):r}var Ke=`__all__`,qe=`__custom__`;function Je(e,t){if(e){if(e.preset)return t(e.preset);if(e.from||e.to)return`${e.from??`…`} – ${e.to??`…`}`}}function Ye(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function Xe(){let[e,n]=(0,t.useState)(!1),[r,i]=(0,t.useState)(!1),a=(0,t.useRef)(null),o=(0,t.useRef)(!1),s=(0,t.useRef)(!1),c=(0,t.useRef)(!1),l=()=>{o.current=!0,queueMicrotask(()=>{o.current=!1})};return{select:{open:r,onOpenChange:e=>{!e&&o.current&&(s.current=!0),i(e)}},selectTrigger:{ref:a},selectContent:{onCloseAutoFocus:e=>{s.current&&(s.current=!1,e.preventDefault(),n(!0))}},customItem:{onPointerUp:l,onClick:l,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&l()}},onCustomValue:()=>{r||n(!0)},popover:{open:e,onOpenChange:n},popoverContent:{onInteractOutside:()=>{c.current=!0},onCloseAutoFocus:e=>{e.preventDefault(),c.current||a.current?.focus(),c.current=!1}}}}function Ze({def:e,value:t,onChange:r}){let s=(0,i.useSafeTranslate)(),c=Ge(e),l=Xe(),u=e.allowCustomRange!==!1,d=e=>s(`dashboard.filters.range.${e}`,e.replace(/_/g,` `)),p=t?.preset??(t?.from||t?.to?qe:Ke),m=t?.from&&!t.from.startsWith(`{`)?(0,n.toDisplayDate)(t.from):void 0,h=t?.to&&!t.to.startsWith(`{`)?(0,n.toDisplayDate)(t.to):void 0,g=m&&!Number.isNaN(m.getTime())?m:void 0;return(0,f.jsxs)(`div`,{className:`flex items-center gap-1`,"data-testid":`dashboard-filter-${e.name}`,children:[(0,f.jsxs)(a.Select,{value:p,...l.select,onValueChange:e=>{e===Ke?r(void 0):e===qe?l.onCustomValue():r({preset:e})},children:[(0,f.jsxs)(a.SelectTrigger,{...l.selectTrigger,className:`h-8 w-auto min-w-36 gap-1`,"aria-label":c||s(`dashboard.filters.dateRange`,`Date range`),children:[(0,f.jsx)(o.CalendarIcon,{className:`size-3.5 opacity-60`}),(0,f.jsx)(a.SelectValue,{placeholder:s(`dashboard.filters.dateRange`,`Date range`),children:Je(t,d)??s(`dashboard.filters.allTime`,`All time`)})]}),(0,f.jsxs)(a.SelectContent,{...l.selectContent,children:[(0,f.jsx)(a.SelectItem,{value:Ke,children:s(`dashboard.filters.allTime`,`All time`)}),n.DATE_RANGE_PRESETS.map(e=>(0,f.jsx)(a.SelectItem,{value:e,children:d(e)},e)),u&&(0,f.jsx)(a.SelectItem,{value:qe,...l.customItem,children:s(`dashboard.filters.custom`,`Custom…`)})]})]}),u&&(0,f.jsxs)(a.Popover,{...l.popover,children:[(0,f.jsx)(a.PopoverTrigger,{asChild:!0,children:(0,f.jsx)(`span`,{"aria-hidden":!0,className:`size-0`})}),(0,f.jsx)(a.PopoverContent,{...l.popoverContent,className:`w-auto p-0`,align:`start`,children:(0,f.jsx)(a.Calendar,{mode:`range`,numberOfMonths:2,defaultMonth:g,selected:{from:m,to:h},onSelect:e=>{if(!e?.from&&!e?.to){r(void 0);return}r({...e?.from?{from:Ye(e.from)}:{},...e?.to?{to:Ye(e.to)}:{}})}})})]})]})}function Qe(e,t,n){let r=Array.isArray(t)&&t.length===e.length&&t.some(e=>e?.[n.valueField]!==void 0)?t:void 0,i=new Map;for(let t=0;t<e.length;t++){let a=e[t],o=r?r[t]?.[n.valueField]:a?.[n.valueField];if(o==null||o===``)continue;let s=String(o);if(i.has(s))continue;let c=n.labelField?a?.[n.labelField]:a?.[n.valueField];i.set(s,String(c??s))}return Array.from(i,([e,t])=>({value:e,label:t}))}function $e({def:e,value:n,onChange:o,dataSource:s}){let c=(0,i.useSafeTranslate)(),{language:l}=(0,i.useObjectTranslation)(),{translateOptions:u}=(0,i.useSafeFieldLabel)(),d=Ge(e),[p,m]=(0,t.useState)(null),h=e.optionsFrom,g=JSON.stringify(h?.filter??null),_=(0,r.useDataInvalidation)(h&&s&&(typeof s.queryDataset==`function`||typeof s.find==`function`)&&h.object||void 0);(0,t.useEffect)(()=>{if(!h||!s)return;let e=!1,t=()=>{if(typeof s.find!=`function`){e||m([]);return}s.find(h.object,{$select:[...new Set([h.valueField,...h.labelField?[h.labelField]:[]])],...h.filter?{$filter:h.filter}:{},$top:200}).then(t=>{if(e)return;let n=Array.isArray(t)?t:t?.data??[];m(Qe(n,void 0,h))}).catch(()=>{e||m([])})};if(typeof s.queryDataset==`function`){let n=[{name:h.valueField,field:h.valueField}];h.labelField&&h.labelField!==h.valueField&&n.push({name:h.labelField,field:h.labelField}),s.queryDataset({name:`dashboard_filter_options`,label:`Dashboard filter options`,object:h.object,dimensions:n,measures:[{name:`option_count`,aggregate:`count`}]},{dimensions:n.map(e=>e.name),measures:[`option_count`],...h.filter?{runtimeFilter:h.filter}:{},order:{[h.valueField]:`asc`},limit:1e3}).then(t=>{if(e)return;let n=Array.isArray(t?.rows)?t.rows:[],r=Array.isArray(t?.drillRawRows)?t.drillRawRows:void 0;m(Qe(n,r,h))}).catch(()=>{e||t()})}else t();return()=>{e=!0}},[h?.object,h?.valueField,h?.labelField,g,s,_]);let v=(0,t.useMemo)(()=>(e.options?.length?e.options:p??[]).map(e=>({value:e.value,label:(0,i.pickLocalized)(e.label,l)||e.value})),[e.options,p,l]),y=e.object?u(e.object,e.field,v):v,b=d||e.name,x=n?y.find(e=>e.value===String(n))?.label??String(n):void 0;return(0,f.jsxs)(a.Select,{value:n?String(n):Ke,onValueChange:e=>o(e===Ke?void 0:e),children:[(0,f.jsx)(a.SelectTrigger,{className:`h-8 w-auto min-w-32`,"aria-label":b,"data-testid":`dashboard-filter-${e.name}`,children:(0,f.jsx)(a.SelectValue,{children:x??`${b}: ${c(`dashboard.filters.all`,`All`)}`})}),(0,f.jsxs)(a.SelectContent,{children:[(0,f.jsx)(a.SelectItem,{value:Ke,children:c(`dashboard.filters.all`,`All`)}),y.map(e=>(0,f.jsx)(a.SelectItem,{value:e.value,children:e.label},e.value))]})]})}function et({def:e,value:n,onChange:r}){let i=Ge(e)||e.name,[o,s]=(0,t.useState)(n==null?``:String(n));(0,t.useEffect)(()=>{s(n==null?``:String(n))},[n]);let c=()=>{let t=o.trim();if(t===``){r(void 0);return}r(e.type===`number`?Number(t):t)};return(0,f.jsx)(a.Input,{className:`h-8 w-36`,type:e.type===`number`?`number`:`text`,placeholder:i,value:o,onChange:e=>s(e.target.value),onBlur:c,onKeyDown:e=>{e.key===`Enter`&&c()},"aria-label":i,"data-testid":`dashboard-filter-${e.name}`})}function tt({defs:e,values:t,onChange:n,onReset:r,dataSource:s,className:c}){let l=(0,i.useSafeTranslate)();if(e.length===0)return null;let u=e=>e==null||e===``||typeof e==`object`&&Object.keys(e).length===0,d=e.some(e=>{let n=t[e.name],r=e.defaultValue;return u(n)&&u(r)?!1:JSON.stringify(n??null)!==JSON.stringify(r??null)});return(0,f.jsxs)(`div`,{className:(0,a.cn)(`col-span-full flex flex-wrap items-center gap-2`,c),"data-testid":`dashboard-filter-bar`,role:`group`,"aria-label":l(`dashboard.filters.label`,`Dashboard filters`),children:[e.map(e=>{let r=t[e.name],i=t=>n(e.name,t);return e.type===`dateRange`||e.type===`date`?(0,f.jsx)(Ze,{def:e,value:r,onChange:i},e.name):e.type===`select`||e.type===`lookup`?(0,f.jsx)($e,{def:e,value:r,onChange:i,dataSource:s},e.name):(0,f.jsx)(et,{def:e,value:r,onChange:i},e.name)}),r&&d&&(0,f.jsxs)(a.Button,{variant:`ghost`,size:`sm`,onClick:r,className:`text-muted-foreground`,children:[(0,f.jsx)(o.RotateCcw,{className:`size-3.5`}),l(`dashboard.filters.reset`,`Reset`)]})]})}function nt({id:e,disabled:t,gridSpan:n,className:r,children:i}){let{attributes:o,listeners:s,setNodeRef:u,transform:d,transition:p,isDragging:m,isOver:h}=(0,c.useSortable)({id:e,disabled:t}),g={transform:l.CSS.Transform.toString(d),transition:p,opacity:m?.4:1,...n?{gridColumn:`span ${n.w}`,gridRow:`span ${n.h}`}:{}};return(0,f.jsx)(`div`,{ref:u,style:g,className:(0,a.cn)(`h-full w-full`,r,!t&&`cursor-grab active:cursor-grabbing`,h&&!m&&`ring-2 ring-primary ring-offset-2 rounded-lg`),"data-sortable-widget-id":e,...o,...s,children:i})}function rt(e){return e?(0,a.getLazyIcon)(e):null}var it=[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`],at=new Set([`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`funnel`,`scatter`,`treemap`,`sankey`]);function ot(e){return at.has(e)?{enabled:!0}:void 0}var st=new Set([`object-chart`,`object-data-table`]);function ct(e){return st.has(e.type)}var lt=(0,t.forwardRef)(({schema:e,className:l,dataSource:u,onRefresh:d,recordCount:p,userActions:m,designMode:h,selectedWidgetId:g,onWidgetClick:_,onWidgetsReorder:v,modalHandler:y,scriptHandlers:b,hideHeaderText:x,localized:S,...C},w)=>{let T=(0,r.useResolvedDataSource)(u),D=(()=>{if(e.columns!=null)return e.columns;let t=e.widgets??[],n=0;for(let e of t){let t=(e.layout?.x??0)+(e.layout?.w??0);t>n&&(n=t),(e.layout?.w??0)>n&&(n=e.layout.w)}return n>4?12:4})(),A=D,j=e.gap||4,M=e.columns!=null||D!==4,[I,L]=(0,t.useState)(!1),R=(0,t.useMemo)(()=>(0,n.resolveDashboardFilterDefs)(e),[e.globalFilters,e.dateRange]),{variables:z,setVariable:B,resetVariables:U}=(0,r.usePageVariables)(),{dashboardLabel:re,dashboardDescription:ae,dashboardActionLabel:K,widgetTitle:oe,widgetDescription:se,fieldLabel:ce}=(0,r.useObjectLabel)(),{t:le,language:ue}=(0,i.useObjectTranslation)(),q=(0,i.useSafeTranslate)(),de=(0,i.useDisplayLocale)(),J=(0,t.useCallback)(e=>{if(e!=null)return(0,i.pickLocalized)(e,ue)||void 0},[ue]),fe=(0,t.useCallback)((e,t,n)=>O(le,ce,e,t,n),[le,ce]),Y=e.name,pe=(0,t.useCallback)(e=>{let t=(0,i.pickLocalized)(e.label,ue)||``;if(!Y)return t;let n=e.actionUrl||t;return K(Y,n,t)},[Y,K,ue]),X=(0,t.useMemo)(()=>(e.header?.actions??[]).map(e=>{let t=(0,i.pickLocalized)(e.label,ue)||void 0;return{name:e.actionUrl||t,type:e.actionType||`url`,target:e.actionUrl,label:t}}),[e.header?.actions,ue]),{executeAction:Z,engine:me}=(0,r.useActionEngine)({actions:X}),he=(0,t.useCallback)(e=>{let t=J(e.title);return S||!Y||!e.id||t===void 0?t:oe(Y,e.id,t)},[S,Y,oe,J]),ge=(0,t.useCallback)(e=>{let t=J(e.description);return S||!Y||!e.id?t:se(Y,e.id,t)},[S,Y,se,J]),_e=He(Y,S);(0,t.useEffect)(()=>{let e=me.getRunner();if(y&&e.setModalHandler(y),b)for(let[t,n]of Object.entries(b))e.registerScript(t,n)},[me,y,b]),(0,t.useEffect)(()=>{let e=()=>L(window.innerWidth<768);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let{refreshing:ve,handleRefresh:ye}=We(e,d),be=(0,t.useCallback)((e,t)=>{h&&_&&t&&(e.stopPropagation(),_(t))},[h,_]),xe=(0,t.useCallback)((t,n,r)=>{if(!h||!_)return;let i=e.widgets||[];if(t.key===`Enter`||t.key===` `)t.preventDefault(),_(n??null);else if(t.key===`ArrowRight`||t.key===`ArrowDown`){t.preventDefault();let e=r+1<i.length?i[r+1]:null;e?.id&&_(e.id)}else if(t.key===`ArrowLeft`||t.key===`ArrowUp`){t.preventDefault();let e=r-1>=0?i[r-1]:null;e?.id&&_(e.id)}else t.key===`Escape`&&(t.preventDefault(),_(null))},[h,_,e.widgets]),Q=(0,t.useCallback)(e=>{h&&_&&e.target===e.currentTarget&&_(null)},[h,_]),Se=e=>{Q(e),typeof C.onClick==`function`&&C.onClick(e)},$=!!(h&&v),Ce=(0,s.useSensors)((0,s.useSensor)(s.PointerSensor,{activationConstraint:{distance:5}})),we=(0,t.useCallback)(t=>{if(!$)return;let{active:n,over:r}=t;if(!r||n.id===r.id)return;let i=e.widgets??[],a=i.findIndex(e=>e.id===n.id),o=i.findIndex(e=>e.id===r.id);a<0||o<0||v?.((0,c.arrayMove)(i,a,o))},[$,e.widgets,v]),Te=(e,i,o)=>{let s=N(e),c=s===`metric`||te.has(s||``),l=M?{w:Math.min(c?3:6,A),h:c?2:4}:void 0,u=e.layout??l,d=u?{...u,w:Math.min(u.w,A)}:void 0,p=!!e.dataset,m=()=>{let t=P(e);if(ie(t))return G;if(t)return(0,r.toRenderableSchema)(W(t));let i=s,a=e.options||{},o=e.data||a.data;if(ne(e))return G;let c=V(i);if(c.family===`series`&&c.chartType){let t=a.xField||`name`,r=a.yField||`value`,i=(0,n.chartConfigPresentation)(e.chartConfig);if(E(o)){let s=o.aggregate,l=s?{field:s.field,function:s.function,groupBy:s.groupBy}:void 0,u=(0,n.chartMeasureKey)(l,r),d=(0,n.chartCategoryKey)(l,t);return{type:`object-chart`,chartType:c.chartType,objectName:o.object,aggregate:l,filter:o.filter||e.filter,xAxisKey:d,series:[{dataKey:u,label:fe(o.object,u,l?.function)}],colors:it,isAnimationActive:!1,drillDown:a.drillDown??ot(c.chartType),compareTo:e.compareTo,className:`h-[200px] sm:h-[250px] md:h-[300px]`,...i}}let s=Array.isArray(o)?o:o?.items||[];return{type:`chart`,chartType:c.chartType,data:s,xAxisKey:t,series:[{dataKey:r,label:fe(void 0,r,void 0)}],colors:it,isAnimationActive:!1,className:`h-[200px] sm:h-[250px] md:h-[300px]`,...i}}if(c.family===`metric`&&i!==void 0){if(E(o))return G;let t=he(e)||i,n=_e(e),r=Array.isArray(o)?o:o?.items||[],s=a.yField||`value`;return{type:H.metric,...a,label:t,description:n,value:a.value??r[0]?.[s]??`—`}}if(c.family===`table`){let t=i===`list`;if(E(o)){let{data:n,...r}=a;return{type:`object-data-table`,...r,objectName:o.object,filter:o.filter||e.filter,searchable:t?!1:e.searchable??!1,pagination:t?!1:e.pagination??!1,drillDown:a.drillDown??{enabled:!0,mode:`record`},className:`border-0`}}let n=Array.isArray(o)?o:o?.items||[];return{type:`data-table`,...a,data:n,columns:Array.isArray(a.columns)&&a.columns.length>0?a.columns:k(n),searchable:!1,pagination:!1,className:`border-0`}}return c.family===`pivot`?G:c.family===`custom`?{type:`text`,content:"Custom widget — set `component` to a UIComponent schema.",variant:`caption`,align:`center`,className:`flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-muted-foreground`}:c.family===`unsupported`?ee(i):F(e)?W({...e,...a}):ee(i)},_=R.length>0?(0,n.buildWidgetScopedFilter)(e,R,z):void 0,v=(()=>{let e=m();return _&&e&&typeof e==`object`&&ct(e)?{...e,filter:(0,n.mergeFilters)(e.filter,_)}:e})(),y=_&&p?{...e,filter:(0,n.mergeFilters)(e.filter,_)}:e,b=s===`metric`&&!p,x=he(e),S=ge(e),C=e.id||x||`widget-${i}`,w=h&&g===e.id,D=h?{"data-testid":`dashboard-preview-widget-${e.id}`,"data-widget-id":e.id,role:`button`,tabIndex:0,"aria-selected":w,"aria-label":`Widget: ${x||`Widget ${i+1}`}`,onClick:t=>be(t,e.id),onKeyDown:t=>xe(t,e.id,i)}:{},O=h?(0,a.cn)(`cursor-pointer rounded-lg transition-all outline-none`,`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,w?`ring-2 ring-primary shadow-md bg-primary/5 dark:bg-primary/10`:`hover:ring-2 hover:ring-primary/40 hover:shadow-sm`):void 0,j=!I&&d&&!$?{gridColumn:`span ${d.w}`,gridRow:`span ${d.h}`}:void 0,L=b?(0,f.jsxs)(`div`,{className:(0,a.cn)(`h-full w-full`,h&&`relative`,O),style:j,...D,children:[(0,f.jsx)(r.SchemaRenderer,{schema:v,className:(0,a.cn)(`h-full w-full`,h&&`pointer-events-none`),dataSource:T}),h&&(0,f.jsx)(`div`,{className:`absolute inset-0 z-10`,"aria-hidden":`true`,"data-testid":`widget-click-overlay`})]}):(0,f.jsxs)(a.Card,{className:(0,a.cn)(`overflow-hidden border-border/50 shadow-sm transition-all hover:shadow-md`,`bg-card/50 backdrop-blur-sm`,o&&`w-full`,h&&`relative`,O),style:j,...D,children:[x&&(0,f.jsxs)(a.CardHeader,{className:`pb-2 border-b border-border/40 bg-muted/20 px-3 sm:px-6`,children:[(0,f.jsx)(a.CardTitle,{className:`text-sm sm:text-base font-medium tracking-tight truncate`,title:x,children:x}),S&&(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 line-clamp-2`,children:S})]}),(0,f.jsx)(a.CardContent,{className:`p-0`,children:(0,f.jsx)(`div`,{className:(0,a.cn)(`h-full w-full`,`p-3 sm:p-4 md:p-6`,h&&`pointer-events-none`),children:p?(0,f.jsx)(Ve,{widget:y,dataSource:T,subCaption:_e(e)??null}):(0,f.jsx)(r.SchemaRenderer,{schema:v,dataSource:T})})}),h&&(0,f.jsx)(`div`,{className:`absolute inset-0 z-10`,"aria-hidden":`true`,"data-testid":`widget-click-overlay`})]});return $&&e.id?(0,f.jsx)(nt,{id:e.id,gridSpan:!I&&d?{w:d.w,h:d.h}:void 0,children:L},C):(0,f.jsx)(t.Fragment,{children:L},C)},Ee=e.label,De=e.header,Oe=!x&&De?.showTitle!==!1&&!!Ee,ke=!x&&De?.showDescription!==!1&&!!e.description,Ae=De?.actions??[],je=De&&(Oe||ke||Ae.length>0)&&(0,f.jsxs)(`div`,{className:`col-span-full mb-4`,children:[Oe&&(0,f.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:Y&&!S?re({name:Y,label:J(Ee)}):J(Ee)}),ke&&(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:Y&&!S?ae({name:Y,description:J(e.description)}):J(e.description)}),Ae.length>0&&(0,f.jsx)(`div`,{className:`flex gap-2 mt-3`,children:Ae.map((e,t)=>{let n=rt(e.icon);return(0,f.jsxs)(a.Button,{variant:`outline`,size:`sm`,onClick:async()=>{let{actionType:t,actionUrl:n}=e;if(!t||!n){console.warn(`[DashboardRenderer] Header action missing actionType/actionUrl:`,e);return}if(t===`url`){/^https?:\/\//.test(n)||n.startsWith(`//`)?window.location.assign(n):(window.history.pushState({},``,n),window.dispatchEvent(new PopStateEvent(`popstate`)));return}let r=await Z(n);r?.success||console.warn(`[DashboardRenderer] action failed`,r?.error)},children:[n&&(0,f.jsx)(n,{className:`w-4 h-4 mr-1.5`}),pe(e)]},t)})})]}),Me=R.length>0&&(0,f.jsx)(tt,{defs:R,values:z,onChange:B,onReset:U,dataSource:T,className:`mb-2`}),Ne=p!==void 0&&(0,f.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[p.toLocaleString(de),` records`]}),Pe=m?JSON.stringify(m):void 0,Fe=(0,n.toDomProps)(C),Ie=d&&(0,f.jsxs)(`div`,{className:(0,a.cn)(`flex items-center justify-end gap-3 mb-2`,!I&&`col-span-full`),children:[Ne,(0,f.jsxs)(a.Button,{variant:`outline`,size:`sm`,onClick:ye,disabled:ve,"aria-label":q(`dashboard.refreshDashboard`,`Refresh dashboard`),children:[(0,f.jsx)(o.RefreshCw,{className:(0,a.cn)(`h-4 w-4 mr-2`,ve&&`animate-spin`)}),ve?q(`dashboard.refreshing`,`Refreshing…`):q(`dashboard.refreshAll`,`Refresh All`)]})]}),Le=(0,t.useMemo)(()=>(e.widgets??[]).map(e=>e.id).filter(e=>!!e),[e.widgets]),Re=(0,t.useMemo)(()=>(e.widgets??[]).filter(e=>N(e)===`metric`).map(e=>e.id).filter(e=>!!e),[e.widgets]),ze=(0,t.useMemo)(()=>(e.widgets??[]).filter(e=>N(e)!==`metric`).map(e=>e.id).filter(e=>!!e),[e.widgets]);if(I){let t=e.widgets?.filter(e=>N(e)===`metric`)||[],n=e.widgets?.filter(e=>N(e)!==`metric`)||[],r=(0,f.jsxs)(`div`,{ref:w,...Fe,className:(0,a.cn)(`flex flex-col gap-4 px-4`,l),"data-user-actions":Pe,onClick:Se,children:[je,Me,Ie,t.length>0&&(0,f.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,onClick:Q,children:(0,f.jsx)(c.SortableContext,{items:Re,strategy:c.rectSortingStrategy,disabled:!$,children:t.map((e,t)=>Te(e,t))})}),n.length>0&&(0,f.jsx)(`div`,{className:`flex flex-col gap-4`,onClick:Q,children:(0,f.jsx)(c.SortableContext,{items:ze,strategy:c.verticalListSortingStrategy,disabled:!$,children:n.map((e,t)=>Te(e,t,!0))})})]});return $?(0,f.jsx)(s.DndContext,{sensors:Ce,collisionDetection:s.closestCenter,onDragEnd:we,children:r}):r}let Be=(0,f.jsxs)(`div`,{ref:w,...Fe,className:(0,a.cn)(`grid`,!M&&`auto-rows-min grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4`,l),style:{...M&&{gridTemplateColumns:`repeat(${A}, minmax(0, 1fr))`,gridAutoRows:`minmax(5rem, auto)`},gap:`${j*.25}rem`},"data-user-actions":Pe,onClick:Se,children:[je,Me,Ie,(0,f.jsx)(c.SortableContext,{items:Le,strategy:c.rectSortingStrategy,disabled:!$,children:e.widgets?.map((e,t)=>Te(e,t))})]});return $?(0,f.jsx)(s.DndContext,{sensors:Ce,collisionDetection:s.closestCenter,onDragEnd:we,children:Be}):Be});lt.displayName=`DashboardRendererInner`;var ut=(0,t.forwardRef)((e,i)=>{let{schema:a}=e,o=(0,t.useMemo)(()=>(0,n.resolveDashboardFilterDefs)(a),[a.globalFilters,a.dateRange]);return o.length===0?(0,f.jsx)(lt,{ref:i,...e}):(0,f.jsx)(r.PageVariablesProvider,{definitions:(0,n.dashboardFilterVariableDefs)(o),children:(0,f.jsx)(lt,{ref:i,...e})})});ut.displayName=`DashboardRenderer`;function dt({editMode:e}){let n=(0,r.useDnd)();return t.useEffect(()=>{if(e)return n.startDrag({id:`dashboard-layout`,type:`dashboard-widget`,data:{}}),()=>{n.endDrag()};n.endDrag(`dashboard`)},[e,n]),null}var ft=[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`];function pt(e,t){if(!e.widgets?.length)return e;let n=new Map(t.map(e=>[e.i,e])),r=e.widgets.map((e,t)=>{let r=e.id||`widget-${t}`,i=n.get(r);return i?{...e,layout:{x:i.x,y:i.y,w:i.w,h:i.h}}:e});return{...e,widgets:r}}function mt(e){return{lg:e.widgets?.map((e,t)=>({i:e.id||`widget-${t}`,...(0,u.completeWidgetLayout)(e.layout,{},(0,u.defaultWidgetPlacement)(t))}))||[]}}var ht=({schema:e,className:s,dataSource:c,onLayoutChange:l,onSchemaChange:u,onRefresh:d})=>{let{width:p,containerRef:m,mounted:g}=(0,h.useContainerWidth)(),[_,v]=t.useState(!1),y=(0,r.useHasDndProvider)(),{t:b,language:x}=(0,i.useObjectTranslation)(),S=(0,i.useSafeTranslate)(),{fieldLabel:C}=(0,i.useObjectLabel)(),w=t.useCallback((e,t,n)=>O(b,C,e,t,n),[b,C]),T=He(e.name),{refreshing:D,handleRefresh:A}=We(e,d),[j,M]=t.useState(()=>mt(e)),I=t.useMemo(()=>JSON.stringify(e.widgets?.map((e,t)=>({i:e.id||`widget-${t}`,x:e.layout?.x,y:e.layout?.y,w:e.layout?.w,h:e.layout?.h}))??[]),[e.widgets]);t.useEffect(()=>{M(mt(e))},[I]);let L=t.useCallback((e,t)=>{M(t),l?.(e)},[l]),R=t.useCallback(()=>{u?u(pt(e,j.lg)):globalThis.process?.env?.NODE_ENV!==`production`&&console.warn("[DashboardGridLayout] Layout edits are in-memory only. Wire `onSchemaChange` to persist via your data adapter."),v(!1)},[u,e,j]),te=t.useCallback(()=>{M(mt(e))},[e]),z=t.useCallback(e=>{let t=P(e);if(ie(t))return G;if(t)return(0,r.toRenderableSchema)(W(t));if(ne(e))return G;let i=N(e),a=e.options||{},o=V(i);if(o.family===`series`&&o.chartType){let t=e.data||a.data,r=a.xField||`name`,i=a.yField||`value`,s=(0,n.chartConfigPresentation)(e.chartConfig);if(E(t)){let e=t.aggregate,a=e?{field:e.field,function:e.function,groupBy:e.groupBy}:void 0,c=(0,n.chartMeasureKey)(a,i),l=(0,n.chartCategoryKey)(a,r);return{type:`object-chart`,chartType:o.chartType,objectName:t.object,aggregate:a,xAxisKey:l,series:[{dataKey:c,label:w(t.object,c,a?.function)}],colors:ft,isAnimationActive:!1,className:`h-full`,...s}}let c=Array.isArray(t)?t:t?.items||[];return{type:`chart`,chartType:o.chartType,data:c,xAxisKey:r,series:[{dataKey:i,label:w(void 0,i,void 0)}],colors:ft,isAnimationActive:!1,className:`h-full`,...s}}if(o.family===`metric`&&i!==void 0){let t=e.data||a.data;if(E(t))return G;let n=e.title||i,r=Array.isArray(t)?t:t?.items||[],o=a.yField||`value`;return{type:H.metric,...a,label:n,value:a.value??r[0]?.[o]??`—`}}if(o.family===`table`){let t=e.data||a.data;if(E(t)){let n=i===`list`,{data:r,...o}=a;return{type:`object-data-table`,...o,objectName:t.object,filter:t.filter||e.filter,searchable:n?!1:e.searchable??!1,pagination:n?!1:e.pagination??!1,drillDown:a.drillDown??{enabled:!0,mode:`record`},className:`border-0`}}let n=Array.isArray(t)?t:t?.items||[];return{type:`data-table`,...a,data:n,columns:Array.isArray(a.columns)&&a.columns.length>0?a.columns:k(n),searchable:!1,pagination:!1,className:`border-0`}}if(o.family===`pivot`){let t=e.data||a.data;return E(t)?G:{type:`pivot`,title:a.title,rowField:a.rowField,columnField:a.columnField,valueField:a.valueField,aggregation:a.aggregation,showRowTotals:a.showRowTotals,showColumnTotals:a.showColumnTotals,format:a.format,columnColors:a.columnColors,className:a.className,data:Array.isArray(t)?t:t?.items||[]}}return o.family===`unsupported`?ee(i):F(e)?W({...e,...a}):ee(i)},[w]);return(0,f.jsxs)(`div`,{ref:m,className:(0,a.cn)(`w-full`,s),"data-testid":`grid-layout`,children:[y&&(0,f.jsx)(dt,{editMode:_}),(0,f.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,f.jsx)(`h2`,{className:`text-2xl font-bold`,children:(0,i.pickLocalized)(e.label,x)||`Dashboard`}),(0,f.jsx)(`div`,{className:`flex gap-2`,children:_?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(a.Button,{onClick:R,size:`sm`,variant:`default`,children:[(0,f.jsx)(o.Save,{className:`h-4 w-4 mr-2`}),`Save Layout`]}),(0,f.jsxs)(a.Button,{onClick:te,size:`sm`,variant:`outline`,children:[(0,f.jsx)(o.X,{className:`h-4 w-4 mr-2`}),`Reset`]}),(0,f.jsx)(a.Button,{onClick:()=>v(!1),size:`sm`,variant:`ghost`,children:`Cancel`})]}):(0,f.jsxs)(f.Fragment,{children:[d&&(0,f.jsxs)(a.Button,{onClick:A,size:`sm`,variant:`outline`,disabled:D,"aria-label":S(`dashboard.refreshDashboard`,`Refresh dashboard`),children:[(0,f.jsx)(o.RefreshCw,{className:(0,a.cn)(`h-4 w-4 mr-2`,D&&`animate-spin`)}),D?S(`dashboard.refreshing`,`Refreshing…`):S(`dashboard.refreshAll`,`Refresh All`)]}),(0,f.jsxs)(a.Button,{onClick:()=>v(!0),size:`sm`,variant:`outline`,children:[(0,f.jsx)(o.Edit,{className:`h-4 w-4 mr-2`}),`Edit Layout`]})]})})]}),g&&(0,f.jsx)(h.ResponsiveGridLayout,{className:`layout`,width:p,layouts:j,breakpoints:{lg:1200,md:996,sm:768,xs:480,xxs:0},cols:{lg:12,md:10,sm:6,xs:4,xxs:2},rowHeight:60,dragConfig:{enabled:_,handle:`.drag-handle`},resizeConfig:{enabled:_},onLayoutChange:L,children:e.widgets?.map((e,t)=>{let n=e.id||`widget-${t}`,s=z(e),l=!!e.dataset,u=N(e)===`metric`&&!l,d=(0,i.pickLocalized)(e.title,x);return(0,f.jsx)(`div`,{className:`h-full`,children:u?(0,f.jsxs)(`div`,{className:`h-full w-full relative`,children:[_&&(0,f.jsx)(`div`,{className:`drag-handle absolute top-2 right-2 z-10 cursor-move p-1 bg-background/80 rounded border border-border`,children:(0,f.jsx)(o.GripVertical,{className:`h-4 w-4`})}),(0,f.jsx)(r.SchemaRenderer,{schema:s,className:`h-full w-full`})]}):(0,f.jsxs)(a.Card,{className:(0,a.cn)(`h-full overflow-hidden border-border/50 shadow-sm transition-all`,`bg-card/50 backdrop-blur-sm`,_&&`ring-2 ring-primary/20`),children:[d&&(0,f.jsxs)(a.CardHeader,{className:`pb-2 border-b border-border/40 bg-muted/20 flex flex-row items-center justify-between`,children:[(0,f.jsx)(a.CardTitle,{className:`text-base font-medium tracking-tight truncate`,title:d,children:d}),_&&(0,f.jsx)(`div`,{className:`drag-handle cursor-move p-1 hover:bg-muted/40 rounded`,children:(0,f.jsx)(o.GripVertical,{className:`h-4 w-4`})})]}),(0,f.jsx)(a.CardContent,{className:`p-0 h-full`,children:(0,f.jsx)(`div`,{className:(0,a.cn)(`h-full w-full overflow-auto p-4`),children:l?(0,f.jsx)(Ve,{widget:e,dataSource:c,subCaption:T(e)??null}):(0,f.jsx)(r.SchemaRenderer,{schema:s})})})]})},n)})})]})},gt=(0,i.createSafeTranslation)({"dashboard.trend.vsLastQuarter":`vs last quarter`,"dashboard.trend.vsLastMonth":`vs last month`,"dashboard.trend.vsLastWeek":`vs last week`,"dashboard.trend.vsLastYear":`vs last year`,"dashboard.trend.vsYesterday":`vs yesterday`,"dashboard.trend.vsPreviousPeriod":`vs previous period`},`dashboard.trend.vsLastQuarter`);function _t(e){switch(e.trim().toLowerCase().replace(/\s+/g,` `)){case`vs last quarter`:case`vs previous quarter`:return`dashboard.trend.vsLastQuarter`;case`vs last month`:case`vs previous month`:return`dashboard.trend.vsLastMonth`;case`vs last week`:case`vs previous week`:return`dashboard.trend.vsLastWeek`;case`vs last year`:case`vs previous year`:return`dashboard.trend.vsLastYear`;case`vs yesterday`:return`dashboard.trend.vsYesterday`;case`vs previous period`:case`vs prior period`:return`dashboard.trend.vsPreviousPeriod`;default:return}}function vt(e){let t=(e||``).trim().match(/0\.(0+)/);return t?t[1].length:0}function yt(e,t,n,r){if(e==null)return``;if(typeof e==`string`){let i=Number(e);return!isFinite(i)||e.trim()===``?e:yt(i,t,n,r)}if(!isFinite(e))return String(e);let a={$:`USD`,"¥":`JPY`,"€":`EUR`,"£":`GBP`},o=(t||``).trim(),s=!!n||o.length>0&&a[o[0]]!==void 0,c=o.endsWith(`%`),l=vt(o);if(/a/i.test(o)){let t={locale:r,notation:`compact`,maximumFractionDigits:l||1};s&&(t.currency=n||a[o[0]]||`USD`);try{return(0,i.formatDisplayNumber)(e,t)}catch{}}if(s){let t=n||a[o[0]]||`USD`;try{return(0,i.formatDisplayNumber)(e,{locale:r,currency:t,minimumFractionDigits:l,maximumFractionDigits:l})}catch{return`${t} ${e.toFixed(l)}`}}return c?(0,p.formatPercent)(e,`fraction`,l,r):(0,i.formatDisplayNumber)(e,{locale:r,minimumFractionDigits:l,maximumFractionDigits:l})}var bt=({label:e,value:n,trend:r,icon:s,className:c,description:l,loading:u,error:d,colorVariant:p=`default`,format:m,currency:h,prefix:g,suffix:_,onClick:v,variant:y=`card`,schema:b,bind:x,events:S,props:C,ariaLabel:w,ariaDescribedBy:T,dataSource:E,...D})=>{let O=K[p]||K.default,{t:k}=gt(),A=(0,i.useDisplayLocale)(),{language:j}=(0,i.useObjectTranslation)(),M=(0,t.useMemo)(()=>(0,i.pickLocalized)(e,j)||void 0,[e,j]),N=(0,t.useMemo)(()=>{let e=(0,i.pickLocalized)(l,j)||(0,i.pickLocalized)(r?.label,j)||void 0;if(!e)return e;let t=_t(e);return t?k(t):e},[l,r?.label,k,j]),P=(0,t.useMemo)(()=>{let e=typeof n==`number`||typeof n==`string`&&n.trim()!==``&&isFinite(Number(n))?yt(n,m,h,A):n??``,t=String(e);return`${g&&t.startsWith(g)?``:g??``}${t}${_&&t.endsWith(_)?``:_??``}`},[n,m,h,g,_,A]),F=(0,t.useMemo)(()=>{if(typeof s==`string`){let e=(0,a.getLazyIcon)(s);return e?(0,f.jsx)(e,{className:`h-4 w-4`}):null}return s},[s]);if(y===`bare`){let e=oe[p]||oe.default;return(0,f.jsx)(`div`,{className:(0,a.cn)(`flex flex-col gap-1 min-w-0`,v&&`cursor-pointer`,c),onClick:v,role:v?`button`:void 0,tabIndex:v?0:void 0,onKeyDown:v?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),v())}:void 0,children:u?(0,f.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,"data-testid":`metric-loading`,children:[(0,f.jsx)(o.Loader2,{className:`h-4 w-4 animate-spin`}),(0,f.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]}):d?(0,f.jsxs)(`div`,{className:`flex items-center gap-2`,"data-testid":`metric-error`,role:`alert`,children:[(0,f.jsx)(o.AlertCircle,{className:`h-4 w-4 text-destructive shrink-0`}),(0,f.jsx)(`span`,{className:`text-xs text-destructive truncate`,children:d})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`div`,{className:(0,a.cn)(`text-[2rem] leading-none font-extrabold tabular-nums tracking-tight truncate`,e),children:P}),(0,f.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground truncate`,children:M})]})})}return(0,f.jsxs)(a.Card,{className:(0,a.cn)(`h-full overflow-hidden`,v&&`cursor-pointer transition-colors hover:bg-accent/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`,c),onClick:v,role:v?`button`:void 0,tabIndex:v?0:void 0,onKeyDown:v?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),v())}:void 0,...D,children:[(0,f.jsxs)(a.CardHeader,{className:`flex flex-row items-center justify-between space-y-0 pb-2`,children:[(0,f.jsx)(a.CardTitle,{className:`text-sm font-medium truncate`,children:M}),F&&(0,f.jsx)(`div`,{className:(0,a.cn)(`flex h-8 w-8 items-center justify-center rounded-md shrink-0`,O),children:F})]}),(0,f.jsx)(a.CardContent,{children:u?(0,f.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,"data-testid":`metric-loading`,children:[(0,f.jsx)(o.Loader2,{className:`h-4 w-4 animate-spin`}),(0,f.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]}):d?(0,f.jsxs)(`div`,{className:`flex items-center gap-2`,"data-testid":`metric-error`,role:`alert`,children:[(0,f.jsx)(o.AlertCircle,{className:`h-4 w-4 text-destructive shrink-0`}),(0,f.jsx)(`span`,{className:`text-xs text-destructive truncate`,children:d})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`div`,{className:`text-2xl font-bold tabular-nums tracking-tight truncate`,children:P}),(r||l)&&(0,f.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 min-w-0`,children:[r&&(0,f.jsxs)(`span`,{className:(0,a.cn)(`flex items-center shrink-0 font-medium`,r.direction===`up`&&`text-emerald-600 dark:text-emerald-400`,r.direction===`down`&&`text-rose-600 dark:text-rose-400`,r.direction===`neutral`&&`text-muted-foreground`),children:[r.direction===`up`&&(0,f.jsx)(o.ArrowUpIcon,{className:`h-3 w-3 mr-1`}),r.direction===`down`&&(0,f.jsx)(o.ArrowDownIcon,{className:`h-3 w-3 mr-1`}),r.direction===`neutral`&&(0,f.jsx)(o.MinusIcon,{className:`h-3 w-3 mr-1`}),r.value,`%`]}),(0,f.jsx)(`span`,{className:`truncate min-w-0`,children:N})]})]})})]})},xt=({title:e,value:t,icon:n,trend:r,trendValue:s,description:c,className:l,loading:u,error:d,schema:p,bind:m,events:h,props:g,ariaLabel:_,ariaDescribedBy:v,dataSource:y,...b})=>{let x=n?(0,a.getLazyIcon)(n):null,{language:S}=(0,i.useObjectTranslation)();return(0,f.jsxs)(a.Card,{className:(0,a.cn)(`h-full`,l),...b,children:[(0,f.jsxs)(a.CardHeader,{className:`flex flex-row items-center justify-between space-y-0 pb-2`,children:[(0,f.jsx)(a.CardTitle,{className:`text-sm font-medium`,children:(0,i.pickLocalized)(e,S)}),x&&(0,f.jsx)(x,{className:`h-4 w-4 text-muted-foreground`})]}),(0,f.jsx)(a.CardContent,{children:u?(0,f.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,"data-testid":`metric-card-loading`,children:[(0,f.jsx)(o.Loader2,{className:`h-4 w-4 animate-spin`}),(0,f.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]}):d?(0,f.jsxs)(`div`,{className:`flex items-center gap-2`,"data-testid":`metric-card-error`,role:`alert`,children:[(0,f.jsx)(o.AlertCircle,{className:`h-4 w-4 text-destructive shrink-0`}),(0,f.jsx)(`span`,{className:`text-xs text-destructive truncate`,children:d})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`div`,{className:`text-2xl font-bold`,children:t}),(r||s||c)&&(0,f.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center mt-1`,children:[r&&s&&(0,f.jsxs)(`span`,{className:(0,a.cn)(`flex items-center mr-2`,r===`up`&&`text-green-500`,r===`down`&&`text-red-500`,r===`neutral`&&`text-yellow-500`),children:[r===`up`&&(0,f.jsx)(o.ArrowUpIcon,{className:`h-3 w-3 mr-1`}),r===`down`&&(0,f.jsx)(o.ArrowDownIcon,{className:`h-3 w-3 mr-1`}),r===`neutral`&&(0,f.jsx)(o.MinusIcon,{className:`h-3 w-3 mr-1`}),s]}),(0,i.pickLocalized)(c,S)]})]})})]})},St=25,Ct={sum:!0,avg:!0,min:!0,max:!0,count:!1};function wt(e){return typeof e==`string`&&Object.prototype.hasOwnProperty.call(Ct,e)&&Ct[e]}function Tt(e,t){return`0,0${e>0?`.${`0`.repeat(e)}`:``}${t?`%`:``}`}function Et(e){let[t,n]=String(e).split(`e`),r=t.indexOf(`.`),i=r===-1?0:t.length-r-1;return Math.min(Math.max(i-(n?Number(n):0),0),20)}function Dt(e){if(!Array.isArray(e))return e;let t=(0,n.toFilterNode)(e);return t!==void 0&&(0,_.isFilterAST)(t)?(0,_.parseFilterAST)(t):t}var Ot=({objectName:e,aggregate:a,filter:o,label:s,fallbackValue:c,trend:l,icon:u,className:d,description:m,dataSource:h,colorVariant:g,format:v,currency:y,prefix:b,suffix:x,invert:S,drillDown:C,title:w,compareTo:T,t:E,variant:D})=>{let O=(0,t.useContext)(r.SchemaRendererContext),k=h||O?.dataSource,[j,M]=(0,t.useState)(!1),[N,P]=(0,t.useState)(null),[F,ee]=(0,t.useState)(null),[I,L]=(0,t.useState)(!1),[R,te]=(0,t.useState)(null),[z,B]=(0,t.useState)(null);(0,t.useEffect)(()=>{let t=!0;if(k&&e&&typeof k.getObjectSchema==`function`)return k.getObjectSchema(e).then(e=>{t&&B(e)}).catch(()=>{}),()=>{t=!1}},[k,e]);let V=(0,t.useMemo)(()=>{let e=a?.field;if(!e||!z?.fields)return null;let t=z.fields;return Array.isArray(t)?t.find(t=>t?.name===e)||null:t[e]||null},[z,a?.field]),H=wt(a?.function),U=(0,t.useMemo)(()=>{if(v)return v;if(!V||!H)return;let e=V.type,t=e===`percent`;if(!t&&e!==`number`&&e!==`integer`)return;let n=(0,_.resolveFieldScale)({type:e,scale:V.scale});if(n!==void 0)return Tt(n,t);let r=a?.function;if(r===`min`||r===`max`){let e=typeof N==`number`?N:typeof N==`string`&&N.trim()!==``?Number(N):NaN;if(Number.isFinite(e))return Tt(Et(e),!1)}return`0,0`},[v,V,H,a?.function,N]),{currency:W}=(0,i.useLocalization)(),{language:G}=(0,i.useObjectTranslation)(),ne=(0,i.useDisplayLocale)(),re=(0,t.useMemo)(()=>{if(y)return y;if(H&&V?.type===`currency`)return(0,i.resolveFieldCurrency)(V,W)},[y,V,W,H]),ie=(0,t.useMemo)(()=>a?JSON.stringify(a):``,[a]),ae=(0,r.useFilterScope)(),K=(0,t.useMemo)(()=>(0,n.resolveFilterPlaceholders)(o,ae),[o,ae]),oe=(0,t.useMemo)(()=>K?JSON.stringify(K):``,[K]),se=(0,t.useMemo)(()=>T?JSON.stringify(T):``,[T]),ce=(0,t.useCallback)(async(t,r)=>{if(a&&typeof t.aggregate==`function`){let i=a.groupBy,o=(0,n.isStructuredGroupBy)(i)?await t.aggregate(e,(0,n.objectAggregateSpecQuery)(a,i,Dt(r))):await t.aggregate(e,{field:a.field,function:a.function,groupBy:i||`_all`,filter:r}),s=Array.isArray(o)?o:[];if(s.length===0)return 0;if(a.function===`count`){let e=`${a.field}_count`;return s.reduce((t,n)=>t+(Number(n[e])||Number(n[a.field])||Number(n.count)||0),0)}let c=s[0];return c[`${a.field}_${a.function}`]??c[a.field]??c.value??0}if(typeof t.find==`function`){let n=await t.find(e,{$filter:r});return(Array.isArray(n)?n:n?.data||n?.records||[]).length}return null},[e,ie]),le=(0,t.useCallback)(async(t,r)=>{if(t&&e){r.current&&(L(!0),te(null));try{let e=T?(0,n.shiftFilterByCompareTo)(o,T):null,[i,a]=await Promise.all([ce(t,K),e?ce(t,e):Promise.resolve(null)]);if(i===null)return;r.current&&(P(i),ee(typeof a==`number`&&Number.isFinite(a)?a:null))}catch(e){console.error(`[ObjectMetricWidget] Fetch error:`,e),r.current&&te(e instanceof Error?e.message:`Failed to load metric`)}finally{r.current&&L(!1)}}},[e,ie,oe,se,ce]),ue=(0,r.useDataInvalidation)(k&&e||void 0);(0,t.useEffect)(()=>{let t={current:!0};return k&&e?le(k,t):(P(null),te(null)),()=>{t.current=!1}},[k,e,le,ue]);let q=N===null?k?`—`:c??`—`:N;S&&typeof q==`number`&&isFinite(q)&&q>=0&&q<=1&&(q=1-q);let de=q,J=U;if(!v&&H&&V?.type===`currency`){let e=typeof q==`number`?q:q.trim()===``?NaN:Number(q);Number.isFinite(e)&&(re?de=(0,p.formatCurrency)(e,re,ne):J=`0,0.00`)}if(H&&V?.type===`percent`&&(!v||v.trim().endsWith(`%`))){let e=typeof q==`number`?q:q.trim()===``?NaN:Number(q);if(Number.isFinite(e)){let t=v?vt(v):(0,_.resolveFieldScale)({type:`percent`,scale:V.scale});de=(0,p.formatPercent)(e,(0,p.percentCellScale)(V),t,ne)}}let fe=(0,t.useMemo)(()=>{if(!T||typeof N!=`number`||!Number.isFinite(N)||F===null)return;let e=A(N,F);if(!e)return;let t=(0,n.compareToTrendLabelKey)(T,o),r=`dashboard.trend.${t}`,i={vsPreviousPeriod:`vs previous period`,vsLastWeek:`vs last week`,vsLastMonth:`vs last month`,vsLastQuarter:`vs last quarter`,vsLastYear:`vs last year`,vsYesterday:`vs yesterday`},a=E?E(r,i[t]||t):i[t]||t;return{value:e.value,direction:e.direction,label:a}},[T,N,F,o,E])??l,Y=(0,n.isDrillEnabled)(C)&&!!e&&!!k,pe=(0,t.useMemo)(()=>{let e=(0,i.pickLocalized)(s,G),t=(0,i.pickLocalized)(w,G);return(0,n.resolveDrillTitle)(C,{},t||e||`Details`)},[C,s,w,G]),X=Y?(0,f.jsx)(Ce,{open:!0,onClose:()=>M(!1),title:pe,target:C?.target,objectName:e,filter:K,dataSource:k,columns:C?.columns,maxRows:C?.maxRows??St,report:C?.report,className:`h-full`}):null;return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(bt,{label:s,value:de,trend:fe,icon:u,className:d,description:m,loading:I,error:R,colorVariant:g,format:J,currency:re,prefix:b,suffix:x,variant:D,onClick:Y?()=>M(!0):void 0}),j&&X]})};function kt(){return(0,i.useSafeTranslate)()(`dashboard.total`,`Total`)}function At(e,t){if(!t)return String(e);let n=``,r=!1,i,a=t,o=a.match(/^([^0-9.,#]*)/);if(o&&o[1]){let e=o[1];n=e.replace(`,`,``),e.includes(`,`)&&(r=!0),a=a.slice(o[1].length)}a.includes(`,`)&&(r=!0,a=a.replace(/,/g,``));let s=a.match(/\.(\d+)f?/);s&&(i=Number(s[1]),a=a.slice(s[0].length));let c=a.replace(/[0-9#.f]/g,``),l=i===void 0?String(e):e.toFixed(i);if(r){let[e,t]=l.split(`.`),r=e.replace(/\B(?=(\d{3})+(?!\d))/g,`,`);return n+(t===void 0?r:`${r}.${t}`)+c}return n+l+c}var jt=`—`;function Mt(e,t){return e===``?jt:t?.[e]??e}var Nt=Object.freeze([]),Pt=new Set([`sum`,`count`,`avg`,`min`,`max`]);function Ft(e,t){if(e.length===0)return 0;switch(t){case`sum`:return e.reduce((e,t)=>e+t,0);case`count`:return e.length;case`avg`:return e.reduce((e,t)=>e+t,0)/e.length;case`min`:return Math.min(...e);case`max`:return Math.max(...e);default:return NaN}}var It=({schema:e,className:n,rowLabels:r,columnLabels:i,rowFieldLabel:o,sourceLabel:s,onDrillDown:c})=>{let{title:l,rowField:u,columnField:d,valueField:p,aggregation:m=`sum`,data:h=Nt,showRowTotals:g=!1,showColumnTotals:_=!1,format:v,columnColors:y}=e,b=kt(),x=typeof c==`function`,S=e=>{x&&c({...e,rowLabel:e.rowKey===void 0?e.rowLabel:r?.[e.rowKey]??e.rowKey,colLabel:e.colKey===void 0?e.colLabel:i?.[e.colKey]??e.colKey})},C=e=>t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e())},w=x?`cursor-pointer hover:bg-accent/40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-[-2px]`:``,T=Array.isArray(h)?h:Nt,{rowKeys:E,colKeys:D,matrix:O,rowTotals:k,colTotals:A,grandTotal:j}=(0,t.useMemo)(()=>{let e=new Map,t=new Map,n={};for(let r of T){let i=String(r[u]??``),a=String(r[d]??``),o=Number(r[p])||0;e.set(i,!0),t.set(a,!0),n[i]||(n[i]={}),n[i][a]||(n[i][a]=[]),n[i][a].push(o)}let r=Array.from(e.keys()),i=Array.from(t.keys()),a={},o={},s={};for(let e of r){a[e]={};let t=[];for(let r of i){let i=n[e]?.[r]??[],o=Ft(i,m);a[e][r]=o,t.push(...i),!s[r]&&s[r]}o[e]=Ft(t,m)}for(let e of i){let t=[];for(let i of r){let r=n[i]?.[e]??[];t.push(...r)}s[e]=Ft(t,m)}let c=[];for(let e of T)c.push(Number(e[p])||0);return{rowKeys:r,colKeys:i,matrix:a,rowTotals:o,colTotals:s,grandTotal:Ft(c,m)}},[T,u,d,p,m]),M=e=>At(e,v);return Pt.has(m)?T.length===0?(0,f.jsxs)(`div`,{className:(0,a.cn)(`overflow-auto`,n),children:[l&&(0,f.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:l}),(0,f.jsx)(ae,{testId:`pivot-empty-state`,source:s,className:`py-8`})]}):(0,f.jsxs)(`div`,{className:(0,a.cn)(`overflow-auto`,n),children:[l&&(0,f.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:l}),(0,f.jsxs)(`table`,{className:`w-full text-sm border-collapse table-auto`,role:`table`,children:[(0,f.jsx)(`thead`,{children:(0,f.jsxs)(`tr`,{className:`border-b border-border`,children:[(0,f.jsx)(`th`,{className:`text-left p-2 font-medium text-muted-foreground whitespace-nowrap`,children:o||u}),D.map(e=>{let t=()=>S({scope:`column`,colKey:e});return(0,f.jsx)(`th`,{className:(0,a.cn)(`text-right p-2 font-medium whitespace-nowrap`,e===``&&`italic text-muted-foreground/70`,y?.[e]??`text-muted-foreground`,w),title:e===``?`${d}: (empty)`:`${d}: ${e}`,role:x?`button`:void 0,tabIndex:x?0:void 0,onClick:x?t:void 0,onKeyDown:x?C(t):void 0,"aria-label":x?`Drill into ${d}: ${e||`(empty)`}`:void 0,children:Mt(e,i)},e)}),g&&(0,f.jsx)(`th`,{className:`text-right p-2 font-semibold text-muted-foreground bg-muted/20 whitespace-nowrap`,children:b})]})}),(0,f.jsx)(`tbody`,{children:E.map(e=>(0,f.jsxs)(`tr`,{className:`border-b border-border/50 hover:bg-muted/30`,children:[(0,f.jsx)(`td`,{className:(0,a.cn)(`p-2 font-medium whitespace-nowrap`,e===``&&`italic text-muted-foreground/70`,w),role:x?`button`:void 0,tabIndex:x?0:void 0,onClick:x?()=>S({scope:`row`,rowKey:e}):void 0,onKeyDown:x?C(()=>S({scope:`row`,rowKey:e})):void 0,"aria-label":x?`Drill into ${u}: ${e||`(empty)`}`:void 0,children:Mt(e,r)}),D.map(t=>{let n=O[e]?.[t]??0,r=()=>S({scope:`cell`,rowKey:e,colKey:t,value:n});return(0,f.jsx)(`td`,{className:(0,a.cn)(`text-right p-2 tabular-nums`,y?.[t],w),role:x?`button`:void 0,tabIndex:x?0:void 0,onClick:x?r:void 0,onKeyDown:x?C(r):void 0,"aria-label":x?`Drill into ${u}=${e||`(empty)`}, ${d}=${t||`(empty)`}`:void 0,children:M(n)},t)}),g&&(0,f.jsx)(`td`,{className:(0,a.cn)(`text-right p-2 font-semibold tabular-nums bg-muted/20`,w),role:x?`button`:void 0,tabIndex:x?0:void 0,onClick:x?()=>S({scope:`row`,rowKey:e,value:k[e]??0}):void 0,onKeyDown:x?C(()=>S({scope:`row`,rowKey:e,value:k[e]??0})):void 0,children:M(k[e]??0)})]},e))}),_&&(0,f.jsx)(`tfoot`,{children:(0,f.jsxs)(`tr`,{className:`border-t-2 border-border font-semibold bg-muted/40`,children:[(0,f.jsx)(`td`,{className:`p-2`,children:b}),D.map(e=>(0,f.jsx)(`td`,{className:(0,a.cn)(`text-right p-2 tabular-nums`,w),role:x?`button`:void 0,tabIndex:x?0:void 0,onClick:x?()=>S({scope:`column`,colKey:e,value:A[e]??0}):void 0,onKeyDown:x?C(()=>S({scope:`column`,colKey:e,value:A[e]??0})):void 0,children:M(A[e]??0)},e)),g&&(0,f.jsx)(`td`,{className:(0,a.cn)(`text-right p-2 tabular-nums font-bold`,w),role:x?`button`:void 0,tabIndex:x?0:void 0,onClick:x?()=>S({scope:`total`,value:j}):void 0,onKeyDown:x?C(()=>S({scope:`total`,value:j})):void 0,children:M(j)})]})})]})]}):(0,f.jsxs)(`div`,{className:(0,a.cn)(`overflow-auto`,n),"data-testid":`pivot-unsupported-aggregation`,children:[l&&(0,f.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:l}),(0,f.jsx)(`div`,{role:`alert`,className:`flex flex-col items-center justify-center py-8 text-destructive`,children:(0,f.jsxs)(`p`,{className:`text-xs`,children:[`Unsupported aggregation “`,String(m),`” — this pivot table renders`,` `,[...Pt].join(`, `),`.`]})})]})},Lt=Object.freeze([]),Rt=({schema:e,dataSource:o,className:s})=>{let c=(0,t.useContext)(r.SchemaRendererContext),l=o||c?.dataSource,u=(0,r.useDataScope)(e.bind),[d,p]=(0,t.useState)([]),[m,h]=(0,t.useState)(!1),[g,_]=(0,t.useState)(null),[v,y]=(0,t.useState)({}),[b,x]=(0,t.useState)({}),[S,C]=(0,t.useState)(null),{fieldLabel:w,fieldOptionLabel:T}=(0,i.useSafeFieldLabel)();(0,t.useEffect)(()=>{if(!l||!e.objectName)return;let t=l.getObjectSchema;if(typeof t!=`function`)return;let n=!0;return Promise.resolve(t.call(l,e.objectName)).then(t=>{if(!n||!t?.fields)return;let r=e.objectName,i={},a={};for(let[e,n]of Object.entries(t.fields)){let t=n?.label?String(n.label):e;a[e]=w(r,e,t);let o=n?.options;if(Array.isArray(o)&&o.length>0){let t={};for(let n of o)if(n&&n.value!==void 0&&n.label!==void 0){let i=String(n.value),a=String(n.label);t[i]=T(r,e,i,a)}Object.keys(t).length>0&&(i[e]=t)}}y(i),x(a)}).catch(()=>{}),()=>{n=!1}},[l,e.objectName,w,T]);let E=(0,r.useFilterScope)(),D=!!l&&!!e.objectName&&!u&&(!e.data||e.data.length===0),O=(0,r.useDataInvalidation)(D?e.objectName:void 0);(0,t.useEffect)(()=>{let t=!0;return e.objectName&&!u&&(!e.data||e.data.length===0)&&(async()=>{if(l&&e.objectName){t&&(h(!0),_(null));try{let r;if(typeof l.find==`function`){let t=await l.find(e.objectName,{$filter:(0,n.resolveFilterPlaceholders)(e.filter,E)});r=(0,n.extractRecords)(t)}else return;t&&p(r)}catch(e){console.error(`[ObjectPivotTable] Fetch error:`,e),t&&_(e instanceof Error?e.message:`Failed to load data`)}finally{t&&h(!1)}}})(),()=>{t=!1}},[e.objectName,l,u,e.data,e.filter,E,O]);let k=(0,t.useMemo)(()=>{if(S)try{let t=(0,n.computeDrillFilter)(e.drillDown,S,{rowField:e.rowField,columnField:e.columnField});return{ok:!0,filter:(0,n.composeDrillFilter)(e.filter,t)}}catch(e){if(!(e instanceof n.FilterOperatorError))throw e;return{ok:!1,refusal:e}}},[S,e.drillDown,e.rowField,e.columnField,e.filter]),A=k?.ok===!1?k.refusal.message:void 0;(0,t.useEffect)(()=>{A&&console.warn(`[ObjectPivotTable] drill-down refused — the drilled list cannot be scoped: ${A}`)},[A]);let j=u||e.data||d,M=Array.isArray(j)?j:Lt;if(m&&M.length===0)return(0,f.jsxs)(`div`,{className:(0,a.cn)(`overflow-auto`,s),"data-testid":`pivot-loading`,children:[e.title&&(0,f.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:e.title}),(0,f.jsxs)(`div`,{className:`space-y-2 p-2`,children:[(0,f.jsxs)(`div`,{className:`flex gap-2`,children:[(0,f.jsx)(a.Skeleton,{className:`h-6 w-24`}),(0,f.jsx)(a.Skeleton,{className:`h-6 w-20`}),(0,f.jsx)(a.Skeleton,{className:`h-6 w-20`}),(0,f.jsx)(a.Skeleton,{className:`h-6 w-20`})]}),[1,2,3].map(e=>(0,f.jsxs)(`div`,{className:`flex gap-2`,children:[(0,f.jsx)(a.Skeleton,{className:`h-5 w-24`}),(0,f.jsx)(a.Skeleton,{className:`h-5 w-20`}),(0,f.jsx)(a.Skeleton,{className:`h-5 w-20`}),(0,f.jsx)(a.Skeleton,{className:`h-5 w-20`})]},e))]})]});if(g)return(0,f.jsxs)(`div`,{className:(0,a.cn)(`overflow-auto`,s),"data-testid":`pivot-error`,children:[e.title&&(0,f.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:e.title}),(0,f.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-destructive`,"data-testid":`pivot-error-message`,children:[(0,f.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 mb-2 opacity-60`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,f.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,f.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,f.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),(0,f.jsx)(`p`,{className:`text-xs`,children:g})]})]});if(!l&&e.objectName&&M.length===0)return(0,f.jsxs)(`div`,{className:(0,a.cn)(`overflow-auto`,s),children:[e.title&&(0,f.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:e.title}),(0,f.jsx)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:(0,f.jsxs)(`p`,{className:`text-xs`,children:[`No data source available for “`,e.objectName,`”`]})})]});let{drillDown:N,...P}=e,F={...P,data:M},ee=e.rowField?v[e.rowField]:void 0,I=e.columnField?v[e.columnField]:void 0,L=e.rowField?b[e.rowField]:void 0,R=e.drillDown,te=(0,n.isDrillEnabled)(R)?e=>C(e):void 0;return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(It,{schema:F,className:s,rowLabels:ee,columnLabels:I,rowFieldLabel:L,sourceLabel:e.objectName,onDrillDown:te}),(()=>{if(!S||!e.objectName||!k?.ok)return null;let t=k.filter,r=(0,n.resolveDrillTitle)(R,S,e.title||`Details`);return(0,f.jsx)(Ce,{open:!0,onClose:()=>C(null),title:r,target:R?.target??`drawer`,objectName:e.objectName,filter:t,dataSource:l,columns:R?.columns,maxRows:R?.maxRows,report:R?.report})})()]})},zt={"dashboard.config.breadcrumb.dashboard":`Dashboard`,"dashboard.config.breadcrumb.configuration":`Configuration`,"dashboard.config.breadcrumb.widget":`Widget`,"dashboard.config.breadcrumb.chart":`Chart`,"dashboard.config.breadcrumb.table":`Table`,"dashboard.config.breadcrumb.pivotTable":`Pivot table`,"dashboard.config.section.general":`General`,"dashboard.config.section.layout":`Layout`,"dashboard.config.section.data":`Data`,"dashboard.config.section.dataBinding":`Data Binding`,"dashboard.config.section.appearance":`Appearance`,"dashboard.config.field.title":`Title`,"dashboard.config.field.description":`Description`,"dashboard.config.field.columns":`Columns`,"dashboard.config.field.gap":`Gap`,"dashboard.config.field.rowHeight":`Row height (px)`,"dashboard.config.field.autoRefresh":`Auto refresh`,"dashboard.config.field.showDescription":`Show description`,"dashboard.config.field.theme":`Theme`,"dashboard.config.field.widgetType":`Widget type`,"dashboard.config.field.colorVariant":`Color variant`,"dashboard.config.field.dataset":`Dataset`,"dashboard.config.field.dimensions":`Dimensions`,"dashboard.config.field.values":`Values`,"dashboard.config.field.width":`Width (columns)`,"dashboard.config.field.height":`Height (rows)`,"dashboard.config.placeholder.dashboardTitle":`Dashboard title`,"dashboard.config.placeholder.dashboardDescription":`Short summary shown under the title`,"dashboard.config.placeholder.widgetTitle":`Widget title`,"dashboard.config.placeholder.widgetDescription":`Widget description`,"dashboard.config.placeholder.datasetName":`Dataset name`,"dashboard.config.placeholder.selectDataset":`Select dataset…`,"dashboard.config.placeholder.searchDatasets":`Search datasets…`,"dashboard.config.placeholder.addDimension":`Add dimension…`,"dashboard.config.placeholder.addMeasure":`Add measure…`,"dashboard.config.placeholder.searchMembers":`Search…`,"dashboard.config.empty.datasets":`No datasets found.`,"dashboard.config.empty.dimensions":`No dimensions selected.`,"dashboard.config.empty.measures":`No measures selected.`,"dashboard.config.empty.nothingToAdd":`Nothing left to add.`,"dashboard.config.help.dataset":`The semantic-layer dataset this widget binds to (ADR-0021).`,"dashboard.config.help.dimensions":`Group/split the values by these dataset dimensions.`,"dashboard.config.help.dimensionsPivot":`Group/split fields. The last dimension spreads across as columns.`,"dashboard.config.help.values":`Measure(s) from the dataset to display (at least one).`,"dashboard.config.action.add":`Add`,"dashboard.config.action.remove":`Remove {{name}}`,"dashboard.config.refresh.off":`Off`,"dashboard.config.refresh.every30s":`Every 30s`,"dashboard.config.refresh.every1m":`Every 1 min`,"dashboard.config.refresh.every5m":`Every 5 min`,"dashboard.config.refresh.every15m":`Every 15 min`,"dashboard.config.refresh.every30m":`Every 30 min`,"dashboard.config.refresh.every1h":`Every 1 hour`,"dashboard.config.themeOption.light":`Light`,"dashboard.config.themeOption.dark":`Dark`,"dashboard.config.themeOption.auto":`Auto`,"dashboard.config.widgetType.metric":`Metric`,"dashboard.config.widgetType.bar":`Bar Chart`,"dashboard.config.widgetType.horizontalBar":`Horizontal Bar`,"dashboard.config.widgetType.line":`Line Chart`,"dashboard.config.widgetType.pie":`Pie Chart`,"dashboard.config.widgetType.donut":`Donut Chart`,"dashboard.config.widgetType.area":`Area Chart`,"dashboard.config.widgetType.scatter":`Scatter Plot`,"dashboard.config.widgetType.funnel":`Funnel`,"dashboard.config.widgetType.table":`Table`,"dashboard.config.widgetType.pivot":`Pivot Table`,"dashboard.config.color.default":`Default`,"dashboard.config.color.blue":`Blue`,"dashboard.config.color.teal":`Teal`,"dashboard.config.color.orange":`Orange`,"dashboard.config.color.purple":`Purple`,"dashboard.config.color.success":`Success`,"dashboard.config.color.warning":`Warning`,"dashboard.config.color.danger":`Danger`},Bt=(0,i.createSafeTranslation)(zt,`dashboard.config.section.general`);function Vt(e){return[{value:`0`,label:e(`dashboard.config.refresh.off`)},{value:`30`,label:e(`dashboard.config.refresh.every30s`)},{value:`60`,label:e(`dashboard.config.refresh.every1m`)},{value:`300`,label:e(`dashboard.config.refresh.every5m`)},{value:`900`,label:e(`dashboard.config.refresh.every15m`)},{value:`1800`,label:e(`dashboard.config.refresh.every30m`)},{value:`3600`,label:e(`dashboard.config.refresh.every1h`)}]}function Ht(e){return[{value:`light`,label:e(`dashboard.config.themeOption.light`)},{value:`dark`,label:e(`dashboard.config.themeOption.dark`)},{value:`auto`,label:e(`dashboard.config.themeOption.auto`)}]}function Ut(e){return{breadcrumb:[e(`dashboard.config.breadcrumb.dashboard`),e(`dashboard.config.breadcrumb.configuration`)],sections:[{key:`layout`,title:e(`dashboard.config.section.layout`),collapsible:!0,fields:[{key:`columns`,label:e(`dashboard.config.field.columns`),type:`slider`,defaultValue:3,min:1,max:12,step:1},{key:`gap`,label:e(`dashboard.config.field.gap`),type:`slider`,defaultValue:4,min:0,max:16,step:1},{key:`rowHeight`,label:e(`dashboard.config.field.rowHeight`),type:`slider`,defaultValue:120,min:40,max:320,step:10}]},{key:`data`,title:e(`dashboard.config.section.data`),collapsible:!0,fields:[{key:`refreshIntervalSeconds`,label:e(`dashboard.config.field.autoRefresh`),type:`select`,defaultValue:`0`,options:Vt(e)}]},{key:`appearance`,title:e(`dashboard.config.section.appearance`),collapsible:!0,defaultCollapsed:!0,fields:[{key:`title`,label:e(`dashboard.config.field.title`),type:`input`,placeholder:e(`dashboard.config.placeholder.dashboardTitle`)},{key:`description`,label:e(`dashboard.config.field.description`),type:`textarea`,placeholder:e(`dashboard.config.placeholder.dashboardDescription`)},{key:`showDescription`,label:e(`dashboard.config.field.showDescription`),type:`switch`,defaultValue:!0},{key:`theme`,label:e(`dashboard.config.field.theme`),type:`select`,defaultValue:`auto`,options:Ht(e)}]}]}}function Wt({open:e,onClose:n,config:r,onSave:i,onFieldChange:o}){let{t:s}=Bt(),{draft:c,isDirty:l,updateField:u,discard:d}=(0,a.useConfigDraft)(r,{onUpdate:o}),p=t.useMemo(()=>Ut(s),[s]);return(0,f.jsx)(a.ConfigPanelRenderer,{open:e,onClose:n,schema:p,draft:c,isDirty:l,onFieldChange:u,onSave:()=>i(c),onDiscard:d})}function Gt(e){let t=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],n={...typeof e.id==`string`?{id:e.id}:{},...typeof e.type==`string`&&e.type?{type:e.type}:{},values:t(e.values),...Array.isArray(e.dimensions)?{dimensions:t(e.dimensions)}:{}},r=v.DashboardWidgetSchema.safeParse(n);if(!r.success)return r.error.issues.find(e=>e.code===`custom`&&e.path.length===1&&e.path[0]===`values`)?.message}var Kt=`__next_measure__`;function qt(e){return[{value:`metric`,label:e(`dashboard.config.widgetType.metric`)},{value:`bar`,label:e(`dashboard.config.widgetType.bar`)},{value:`horizontal-bar`,label:e(`dashboard.config.widgetType.horizontalBar`)},{value:`line`,label:e(`dashboard.config.widgetType.line`)},{value:`pie`,label:e(`dashboard.config.widgetType.pie`)},{value:`donut`,label:e(`dashboard.config.widgetType.donut`)},{value:`area`,label:e(`dashboard.config.widgetType.area`)},{value:`scatter`,label:e(`dashboard.config.widgetType.scatter`)},{value:`funnel`,label:e(`dashboard.config.widgetType.funnel`)},{value:`table`,label:e(`dashboard.config.widgetType.table`)},{value:`pivot`,label:e(`dashboard.config.widgetType.pivot`)}]}function Jt(e){return[{value:`default`,label:e(`dashboard.config.color.default`)},{value:`blue`,label:e(`dashboard.config.color.blue`)},{value:`teal`,label:e(`dashboard.config.color.teal`)},{value:`orange`,label:e(`dashboard.config.color.orange`)},{value:`purple`,label:e(`dashboard.config.color.purple`)},{value:`success`,label:e(`dashboard.config.color.success`)},{value:`warning`,label:e(`dashboard.config.color.warning`)},{value:`danger`,label:e(`dashboard.config.color.danger`)}]}var Yt=[`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`scatter`,`funnel`],Xt=[`metric`,`gauge`,`solid-gauge`,`kpi`,`bullet`];function Zt(e){return!!e&&Yt.includes(e)}function Qt(e){return!!e&&!Xt.includes(e)}function $t(e,t){return t===`pivot`?e(`dashboard.config.breadcrumb.pivotTable`):t===`table`?e(`dashboard.config.breadcrumb.table`):Zt(t)?e(`dashboard.config.breadcrumb.chart`):e(`dashboard.config.breadcrumb.widget`)}function en({names:e,options:n,placeholder:r,emptyText:i,onChange:s,canAdd:c=!0,refusal:l}){let{t:u}=Bt(),[d,p]=t.useState(``),m=t.useMemo(()=>new Set(e),[e]),h=t.useMemo(()=>n.filter(e=>!m.has(e.value)),[n,m]),g=t=>{let n=t.trim();c&&n&&!m.has(n)&&(s([...e,n]),p(``))},_=t=>s(e.filter(e=>e!==t));return(0,f.jsxs)(`div`,{className:`space-y-1.5`,children:[e.length===0?(0,f.jsx)(`p`,{className:`rounded border border-dashed px-2 py-1.5 text-center text-[11px] text-muted-foreground`,children:i}):(0,f.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.map(e=>(0,f.jsxs)(`span`,{"data-testid":`dataset-name-chip-${e}`,className:(0,a.cn)(`inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5`,`font-mono text-[11px] text-foreground`),children:[e,(0,f.jsx)(`button`,{type:`button`,"aria-label":u(`dashboard.config.action.remove`,{name:e}),className:`text-muted-foreground hover:text-foreground`,onClick:()=>_(e),children:(0,f.jsx)(o.X,{className:`h-3 w-3`})})]},e))}),l&&(0,f.jsx)(`p`,{role:`alert`,"data-testid":`dataset-names-refusal`,className:`break-words text-[11px] leading-snug text-destructive`,children:l}),c?h.length>0?(0,f.jsx)(a.Combobox,{options:h,value:``,onValueChange:g,placeholder:r,searchPlaceholder:u(`dashboard.config.placeholder.searchMembers`),emptyText:u(`dashboard.config.empty.nothingToAdd`),className:`h-7 w-full text-xs`}):(0,f.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,f.jsx)(a.Input,{value:d,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),g(d))},placeholder:r,className:`h-7 flex-1 text-xs`}),(0,f.jsx)(a.Button,{type:`button`,size:`sm`,variant:`outline`,className:`h-7 px-2 text-xs`,onClick:()=>g(d),disabled:!d.trim(),children:u(`dashboard.config.action.add`)})]}):null]})}function tn(e,t,n){let r=t??[],i=r.length>0,o=r.map(e=>({value:e.name,label:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name})),s=e=>typeof e==`string`?r.find(t=>t.name===e):void 0,c=e(`dashboard.config.field.dataset`),l=e(`dashboard.config.help.dataset`),u=i?{key:`dataset`,label:c,type:`custom`,helpText:l,render:(t,n)=>(0,f.jsx)(a.ConfigRow,{label:c,children:(0,f.jsx)(`div`,{"data-testid":`config-field-dataset`,children:(0,f.jsx)(a.Combobox,{options:o,value:t??``,onValueChange:n,placeholder:e(`dashboard.config.placeholder.selectDataset`),searchPlaceholder:e(`dashboard.config.placeholder.searchDatasets`),emptyText:e(`dashboard.config.empty.datasets`),className:`h-7 w-40 text-xs`})})})}:{key:`dataset`,label:c,type:`input`,placeholder:e(`dashboard.config.placeholder.datasetName`),helpText:l},d=e(`dashboard.config.field.dimensions`),p={key:`dimensions`,label:d,type:`custom`,visibleWhen:e=>Qt(e.type),helpText:e(n===`pivot`?`dashboard.config.help.dimensionsPivot`:`dashboard.config.help.dimensions`),render:(t,n,r)=>{let i=(s(r.dataset)?.dimensions??[]).map(e=>({value:e.name,label:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name}));return(0,f.jsx)(a.ConfigRow,{label:d,children:(0,f.jsx)(`div`,{"data-testid":`config-field-dimensions`,className:`w-40`,children:(0,f.jsx)(en,{names:Array.isArray(t)?t:[],options:i,placeholder:e(`dashboard.config.placeholder.addDimension`),emptyText:e(`dashboard.config.empty.dimensions`),onChange:n})})})}},m=e(`dashboard.config.field.values`),h={key:`values`,label:m,type:`custom`,helpText:e(`dashboard.config.help.values`),render:(t,n,r)=>{let i=(s(r.dataset)?.measures??[]).map(e=>({value:e.name,label:e.aggregate?`${e.label??e.name} · ${e.aggregate}`:e.label??e.name})),o=Array.isArray(t)?t:[],c=cn(r),l={id:c.id,type:c.type,dimensions:c.dimensions},u=o.length>0?Gt({...l,values:o}):void 0,d=!Gt({...l,values:[...o,Kt]});return(0,f.jsx)(a.ConfigRow,{label:m,children:(0,f.jsx)(`div`,{"data-testid":`config-field-values`,className:`w-40`,children:(0,f.jsx)(en,{names:o,options:i,placeholder:e(`dashboard.config.placeholder.addMeasure`),emptyText:e(`dashboard.config.empty.measures`),onChange:n,canAdd:d,refusal:u})})})}};return{breadcrumb:[e(`dashboard.config.breadcrumb.dashboard`),$t(e,n)],sections:[{key:`general`,title:e(`dashboard.config.section.general`),fields:[{key:`title`,label:e(`dashboard.config.field.title`),type:`input`,placeholder:e(`dashboard.config.placeholder.widgetTitle`)},{key:`description`,label:e(`dashboard.config.field.description`),type:`input`,placeholder:e(`dashboard.config.placeholder.widgetDescription`)},{key:`type`,label:e(`dashboard.config.field.widgetType`),type:`select`,options:qt(e),defaultValue:`metric`}]},{key:`data`,title:e(`dashboard.config.section.dataBinding`),collapsible:!0,fields:[u,p,h]},{key:`layout`,title:e(`dashboard.config.section.layout`),collapsible:!0,fields:[{key:`layoutW`,label:e(`dashboard.config.field.width`),type:`slider`,min:1,max:12,step:1,defaultValue:1},{key:`layoutH`,label:e(`dashboard.config.field.height`),type:`slider`,min:1,max:6,step:1,defaultValue:1}]},{key:`appearance`,title:e(`dashboard.config.section.appearance`),collapsible:!0,defaultCollapsed:!0,fields:[{key:`colorVariant`,label:e(`dashboard.config.field.colorVariant`),type:`select`,options:Jt(e),defaultValue:`default`}]}]}}var nn=[`title`,`description`];function rn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function an(e,t,n){let r=e;for(let a of nn){let o=t?.[a];if(!rn(o))continue;let s=e[a];typeof s==`string`&&(r===e&&(r={...e}),r[a]=s===(0,i.pickLocalized)(o,n)?o:(0,i.setLocalized)(o,n,s))}return r}var on=[`actionUrl`,`actionType`,`actionIcon`],sn=[`object`,`categoryField`,`categoryGranularity`,`valueField`,`aggregate`,`aggregation`,`rowField`,`columnField`,`xAxisField`,`yAxisFields`,`xAxisLabel`,`yAxisLabel`,`measures`,`rowSortBy`,`rowSortOrder`,`columnSortBy`,`columnSortOrder`,`showRowLabels`,`showRowTotals`,`showColumnLabels`,`showColumnTotals`,`format`,`showLegend`,`searchable`,`pagination`];function cn(e){let t=e.type,n={...e};for(let e of sn)delete n[e];for(let e of on)delete n[e];return Qt(t)||delete n.dimensions,n}function ln({open:e,onClose:n,config:r,onSave:o,onFieldChange:s,headerExtra:c,datasets:l,datasetsLoading:u}){let{t:d,language:p}=Bt(),m=t.useMemo(()=>({...r,title:typeof r.title==`object`?(0,i.pickLocalized)(r.title,p):r.title,description:typeof r.description==`object`?(0,i.pickLocalized)(r.description,p):r.description}),[r,p]),h=t.useCallback((e,t)=>{if(!s)return;let n=r?.[e];s(e,nn.includes(e)&&rn(n)&&typeof t==`string`?(0,i.setLocalized)(n,p,t):t)},[s,r,p]),{draft:g,isDirty:_,updateField:v,discard:y}=(0,a.useConfigDraft)(m,{onUpdate:h}),b=t.useMemo(()=>tn(d,l,g.type),[d,l,g.type]);return(0,f.jsx)(a.ConfigPanelRenderer,{open:e,onClose:n,schema:b,draft:g,isDirty:_,onFieldChange:v,onSave:()=>o(cn(an(g,r,p))),onDiscard:y,headerExtra:c})}function un({schema:e,config:n,onConfigSave:r,onWidgetSave:i,onRefresh:s,recordCount:c,defaultConfigOpen:l=!1,className:d,datasets:p,datasetsLoading:m}){let[h,g]=(0,t.useState)(l),[_,v]=(0,t.useState)(null),[y,b]=(0,t.useState)(e),[x,S]=(0,t.useState)(0);(0,t.useEffect)(()=>{b(e),S(e=>e+1)},[e]);let C=t.useMemo(()=>{if(!_||!y.widgets)return null;let e=y.widgets,t=e.findIndex(e=>(e.id||e.title)===_);if(t<0)return null;let n=e[t],r=(0,u.completeWidgetLayout)(n.layout,{},(0,u.defaultWidgetPlacement)(t)),i=n;return{id:n.id??``,title:n.title??``,description:n.description??``,type:n.type??``,dataset:typeof i.dataset==`string`?i.dataset:``,dimensions:Array.isArray(i.dimensions)?i.dimensions:[],values:Array.isArray(i.values)?i.values:[],colorVariant:n.colorVariant??`default`,layoutW:r.w,layoutH:r.h}},[_,x]),w=(0,t.useCallback)(e=>{v(e),g(!0)},[]),T=(0,t.useCallback)(()=>{v(null)},[]),E=(0,t.useCallback)((e,t)=>{_&&b(n=>n.widgets?{...n,widgets:n.widgets.map((n,r)=>{if((n.id||n.title)!==_)return n;if(e===`layoutW`||e===`layoutH`){let i=e===`layoutW`?{w:t}:{h:t};return{...n,layout:(0,u.completeWidgetLayout)(n.layout,i,(0,u.defaultWidgetPlacement)(r))}}return{...n,[e]:t}})}:n)},[_]),D=(0,t.useCallback)(e=>{_&&i&&i(_,e),v(null),S(e=>e+1)},[_,i]),O=(0,t.useCallback)(()=>{g(e=>!e),v(null)},[]);return(0,f.jsxs)(`div`,{className:(0,a.cn)(`flex h-full w-full`,d),"data-testid":`dashboard-with-config`,children:[(0,f.jsxs)(`div`,{className:`flex-1 min-w-0 overflow-auto relative`,children:[(0,f.jsx)(`div`,{className:`absolute top-2 right-2 z-10`,children:(0,f.jsxs)(a.Button,{size:`sm`,variant:h?`default`:`outline`,onClick:O,"data-testid":`dashboard-config-toggle`,children:[(0,f.jsx)(o.Settings,{className:`h-3.5 w-3.5 mr-1`}),`Settings`]})}),(0,f.jsx)(ut,{schema:y,onRefresh:s,recordCount:c,designMode:h,selectedWidgetId:_,onWidgetClick:w})]}),h&&(0,f.jsx)(`div`,{className:`relative shrink-0`,children:_&&C?(0,f.jsx)(ln,{open:!0,onClose:T,config:C,onSave:D,onFieldChange:E,datasets:p,datasetsLoading:m}):(0,f.jsx)(Wt,{open:!0,onClose:()=>g(!1),config:n,onSave:r})})]})}var dn=Object.freeze({dashboard:'[object-ui] Node type `view:dashboard` was RETIRED (objectui#9533). This package registers the dashboard renderer as `plugin-dashboard:dashboard`, the namespace the console\'s lazy stubs and the CLI\'s known-type whitelist already declare. Write `{ "type": "plugin-dashboard:dashboard" }`, or the bare `{ "type": "dashboard" }`, which resolves to the same renderer.'}),fn=new Set;function pn(e){fn.has(e)||(fn.add(e),console.error(dn[e]??`[object-ui] Node type \`${e}\` was retired by @object-ui/plugin-dashboard.`))}function mn(){fn.clear()}var hn=e=>{let n=e?.schema,r=typeof n?.type==`string`?n.type:void 0,i=typeof e?.type==`string`?e.type:void 0,a=r??i??`view:dashboard`,o=a.includes(`:`)?a.slice(a.indexOf(`:`)+1):a,s=dn[o]??`[object-ui] Node type \`${a}\` was retired by @object-ui/plugin-dashboard.`;return t.default.useEffect(()=>{pn(o)},[o]),(0,f.jsx)(`div`,{role:`alert`,"data-testid":`dashboard-retired-node-tombstone`,"data-retired-node-type":a,className:`rounded-md border border-destructive/50 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:s})};n.ComponentRegistry.register(`dashboard`,ut,{namespace:`plugin-dashboard`,label:`Dashboard`,category:`Complex`,icon:`layout-dashboard`,inputs:[{name:`widgets`,type:`array`,description:`The widget tree — the spec’s DashboardWidget[]. Each widget binds a dataset (ADR-0021) and may carry a layout ({ x, y, w, h }) and filterBindings. When omitted the dashboard renders an empty grid.`},{name:`label`,type:[`string`,`object`],description:'Display name, shown as the header title when `header` is declared — a string or an inline per-locale map such as { en, "zh-CN" }. Spec-canonical spelling; the legacy `title` spelling is not authoring surface.'},{name:`description`,type:[`string`,`object`],description:"Header description shown under the title — a string or an inline per-locale map. Rendered only when `header` is declared and `header.showDescription` is not false."},{name:`header`,type:`object`,description:`Header block: { showTitle?, showDescription?, actions? }. Strict — the contract rejects any other key. Renders nothing (zero pixels) when everything it would show is suppressed.`},{name:`globalFilters`,type:`array`,description:`Dashboard-level filter bar — the spec’s GlobalFilter[]. Filter values live as dashboard variables (readable in widget expressions as page.<name>) and are AND-merged into each bound widget’s query per its filterBindings.`},{name:`dateRange`,type:`object`,description:'Built-in date-range filter: { field?, defaultRange?, allowCustomRange? }. `defaultRange` takes the spec’s date presets plus "custom"; the bound field defaults to created_at.'},{name:`refreshIntervalSeconds`,type:`number`,description:`Auto-refresh period in seconds. Zero or a negative value disables the timer, and it only runs when the host wires an onRefresh handler.`},{name:`columns`,type:`number`},{name:`gap`,type:`number`},{name:`className`,type:`string`}],defaultProps:{columns:3,widgets:[]}}),n.ComponentRegistry.register(`metric`,bt,{namespace:`plugin-dashboard`,skipFallback:!0,label:`Metric Widget`,category:`Dashboard`,inputs:[{name:`label`,type:`string`},{name:`value`,type:`string`}]}),n.ComponentRegistry.register(`metric-card`,xt,{namespace:`plugin-dashboard`,skipFallback:!0,label:`Metric Card`,category:`Dashboard`,inputs:[{name:`title`,type:`string`},{name:`value`,type:`string`,required:!0},{name:`icon`,type:`string`},{name:`trend`,type:`enum`,enum:[{label:`Up`,value:`up`},{label:`Down`,value:`down`},{label:`Neutral`,value:`neutral`}]},{name:`trendValue`,type:`string`},{name:`description`,type:`string`}],defaultProps:{title:`Metric`,value:`0`}});var gn={filter:!0},_n=(0,n.elementDataSourceBlock)(({schema:e,...t})=>(0,f.jsx)(r.ElementDataSourceGate,{schema:e,mapping:gn,dataSource:t.dataSource,testId:`object-metric`,errorTitle:`This metric’s data source could not be resolved`,children:e=>(0,f.jsx)(Ot,{...t,objectName:e?.objectName??t.objectName,filter:e?.filter??t.filter})}));n.ComponentRegistry.register(`object-metric`,_n,{namespace:`plugin-dashboard`,label:`Object Metric`,category:`Dashboard`,inputs:[{name:`objectName`,type:`string`,required:!0},{name:`label`,type:[`string`,`object`],description:'Heading of the tile, and of the drill-down panel when `title` is not set. Accepts either a plain string or an inline per-locale map (`{ en: "Pipeline", "zh-CN": "销售管道" }`) — the `I18nLabel` union the contract admits on this key — and the tile resolves the map against the active UI language, falling back through base language, a region-qualified sibling, `default`, then `en`, and finally to any remaining entry.'},{name:`aggregate`,type:`object`,description:`Aggregation config: { field, function, groupBy }`},{name:`icon`,type:`string`},{name:`description`,type:[`string`,`object`],description:'Helper text rendered under the value. Accepts either a plain string or an inline per-locale map (`{ en: "This quarter", "zh-CN": "本季度" }`), resolved against the active UI language with the same fallback chain as `label`.'},{name:`title`,type:[`string`,`object`],description:'Heading of the drill-down panel. Defaults to `label` — set it only when the records list wants a different name from the tile. Accepts either a plain string or an inline per-locale map (`{ en: "Open deals", "zh-CN": "进行中的商机" }`), resolved against the active UI language with the same fallback chain as `label`.'},{name:`filter`,type:`array`,description:`Criteria the aggregation is scoped by. The same filter narrows the drill-down list, so the number and the records behind it always agree.`},{name:`colorVariant`,type:`enum`,enum:[`default`,`blue`,`teal`,`orange`,`purple`,`success`,`warning`,`danger`],description:"Colour of the icon container. Semantic, not decorative: `success` / `warning` / `danger` should track what the number means."},{name:`variant`,type:`enum`,enum:[`card`,`bare`],description:"`card` draws the tile’s own surface; `bare` drops it, for a metric already sitting inside a card."},{name:`format`,type:`string`,description:"Numeral-style format pattern, e.g. `0,0`, `$0,0`, `0%`. Use `currency` instead of hard-coding a currency symbol here."},{name:`currency`,type:`string`,description:"ISO 4217 code, e.g. `USD`. Enables locale-aware currency formatting of the value."},{name:`prefix`,type:`string`,description:`Static text placed before the formatted value.`},{name:`suffix`,type:`string`,description:`Static text placed after the formatted value.`},{name:`invert`,type:`boolean`,description:"Display `1 - value` — for gauges whose good direction is down, such as error rate shown as uptime."},{name:`fallbackValue`,type:`string`,description:`Value shown when no data source resolves. For static/demo tiles; a bound metric should not need it.`},{name:`trend`,type:`object`,description:"Static trend badge: `{ value, label, direction }`. Use `compareTo` instead when the trend should be computed from data."},{name:`compareTo`,type:`object`,description:'Period-over-period comparison, `{ kind: "previousPeriod" }` or `{ kind: "previousYear" }` — the computed alternative to a static `trend`.'},{name:`drillDown`,type:`object`,description:"Click-through config that opens the records behind the number. `drillDown.filter` and `drillDown.mode` do not apply to a metric, which has no clicked point to filter by and no row to open, so the list is always scoped by this block’s own `filter`; a drill `filter` belongs on `object-chart` or `object-pivot`, and `mode` on `object-data-table`."}],defaultProps:{label:`Metric`}}),n.ComponentRegistry.register(`pivot`,It,{namespace:`plugin-dashboard`,label:`Pivot Table`,category:`Dashboard`,icon:`table-2`,inputs:[{name:`title`,type:`string`},{name:`rowField`,type:`string`,required:!0},{name:`columnField`,type:`string`,required:!0},{name:`valueField`,type:`string`,required:!0},{name:`aggregation`,type:`enum`,enum:[{label:`Sum`,value:`sum`},{label:`Count`,value:`count`},{label:`Average`,value:`avg`},{label:`Min`,value:`min`},{label:`Max`,value:`max`}]},{name:`showRowTotals`,type:`boolean`},{name:`showColumnTotals`,type:`boolean`},{name:`format`,type:`string`}],defaultProps:{rowField:``,columnField:``,valueField:``,aggregation:`sum`,data:[]}});var vn={filter:!0},yn=(0,n.elementDataSourceBlock)(({schema:e,...t})=>(0,f.jsx)(r.ElementDataSourceGate,{schema:e,mapping:vn,dataSource:t.dataSource,testId:`object-pivot`,errorTitle:`This pivot table’s data source could not be resolved`,children:e=>(0,f.jsx)(Rt,{...t,schema:e})}));n.ComponentRegistry.register(`object-pivot`,yn,{namespace:`plugin-dashboard`,label:`Object Pivot Table`,category:`Dashboard`,icon:`table-2`,inputs:[{name:`objectName`,type:`string`,required:!0},{name:`title`,type:`string`},{name:`rowField`,type:`string`,required:!0},{name:`columnField`,type:`string`,required:!0},{name:`valueField`,type:`string`,required:!0},{name:`aggregation`,type:`enum`,enum:[{label:`Sum`,value:`sum`},{label:`Count`,value:`count`},{label:`Average`,value:`avg`},{label:`Min`,value:`min`},{label:`Max`,value:`max`}]},{name:`showRowTotals`,type:`boolean`},{name:`showColumnTotals`,type:`boolean`},{name:`filter`,type:`array`},{name:`format`,type:`string`},{name:`drillDown`,type:`object`,description:'Click-through config that opens the records behind a clicked cell, header or total — in a drawer, a dialog, the object’s list page (`target: "navigate"`), or an analytical report (`report`). The drilled list is this block’s `filter` narrowed by the clicked value. `drillDown.mode` does not apply: every click point on a pivot is an aggregated bucket, so it always drills through; `mode` belongs on `object-data-table`.'}],defaultProps:{rowField:``,columnField:``,valueField:``,aggregation:`sum`}}),n.ComponentRegistry.register(`object-data-table`,Q,{namespace:`plugin-dashboard`,label:`Object Data Table`,category:`Dashboard`,icon:`table`,inputs:[{name:`objectName`,type:`string`,required:!0},{name:`columns`,type:`array`},{name:`filter`,type:`array`},{name:`searchable`,type:`boolean`},{name:`pagination`,type:`boolean`}],defaultProps:{searchable:!1,pagination:!1}});for(let e of Object.keys(dn))n.ComponentRegistry.register(e,hn,{namespace:`view`,skipFallback:!0});var bn={dashboard:ut,"plugin-dashboard:metric":bt,"plugin-dashboard:metric-card":xt,"object-metric":_n,pivot:It,"object-pivot":yn,"object-data-table":Q};e.CONFIG_PANEL_DEFAULT_TRANSLATIONS=zt,e.DashboardConfigPanel=Wt,e.DashboardGridLayout=ht,e.DashboardRenderer=ut,e.DashboardWithConfig=un,e.DrillDownDrawer=Ce,e.MetricCard=xt,e.MetricWidget=bt,e.ObjectDataTable=Q,e.ObjectMetricWidget=Ot,e.ObjectPivotTable=Rt,e.PivotTable=It,e.RETIRED_DASHBOARD_NODE_TYPES=dn,e.RetiredDashboardNodeTombstone=hn,e.WidgetConfigPanel=ln,e.dashboardComponents=bn,e.reportRetiredDashboardNodeType=pn,e.resetRetiredDashboardNodeTypeReports=mn,e.useConfigPanelTranslation=Bt});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("react"),require("@object-ui/core"),require("@object-ui/react"),require("@object-ui/i18n"),require("@object-ui/components"),require("lucide-react"),require("@dnd-kit/core"),require("@dnd-kit/sortable"),require("@dnd-kit/utilities"),require("@object-ui/types"),require("@objectstack/spec/ui"),require("react/jsx-runtime"),require("@object-ui/fields"),require("@object-ui/permissions"),require("react-grid-layout"),require("react-grid-layout/css/styles.css"),require("@objectstack/spec/data"),require("@object-ui/types/zod")):typeof define==`function`&&define.amd?define([`exports`,`react`,`@object-ui/core`,`@object-ui/react`,`@object-ui/i18n`,`@object-ui/components`,`lucide-react`,`@dnd-kit/core`,`@dnd-kit/sortable`,`@dnd-kit/utilities`,`@object-ui/types`,`@objectstack/spec/ui`,`react/jsx-runtime`,`@object-ui/fields`,`@object-ui/permissions`,`react-grid-layout`,`react-grid-layout/css/styles.css`,`@objectstack/spec/data`,`@object-ui/types/zod`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginDashboard={},e.React,e.ObjectUICore,e.ObjectUIReact,e.ObjectUII18n,e.ObjectUIComponents,e.lucide_react,e._dnd_kit_core,e._dnd_kit_sortable,e._dnd_kit_utilities,e.ObjectUITypes,e._objectstack_spec_ui,e.react_jsx_runtime,e.ObjectUIFields,e._object_ui_permissions,e.ReactGridLayout,e.react_grid_layout_css_styles_css,e._objectstack_spec_data,e._object_ui_types_zod))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var y=Object.create,b=Object.defineProperty,x=Object.getOwnPropertyDescriptor,S=Object.getOwnPropertyNames,C=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty,T=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=S(t),a=0,o=i.length,s;a<o;a++)s=i[a],!w.call(e,s)&&s!==n&&b(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=x(t,s))||r.enumerable});return e};t=((e,t,n)=>(n=e==null?{}:y(C(e)),T(t||!e||!e.__esModule||!w.call(e,`default`)?b(n,`default`,{value:e,enumerable:!0}):n,e)))(t,1);function E(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&e.provider===`object`}function D(e){return e.replace(/_/g,` `).replace(/([A-Z])/g,` $1`).trim().replace(/\b\w/g,e=>e.toUpperCase())}function O(e,t,n,r,i){if(i&&(!r||r===`value`||r===`count`||i===`count`))return e(`report.aggregate.${i}`,{defaultValue:i});let a=D(r);return n?t(n,r,a):a}function k(e){if(!Array.isArray(e)||e.length===0)return[];let t=e[0];return typeof t!=`object`||!t||Array.isArray(t)?[]:Object.keys(t).filter(e=>!e.startsWith(`_`)).map(e=>({header:D(e),accessorKey:e}))}function A(e,t){if(t==null||e==null||typeof e!=`number`||!Number.isFinite(e)||typeof t!=`number`||!Number.isFinite(t))return null;if(t===0)return e===0?{value:0,direction:`neutral`}:{value:null,direction:e>0?`up`:`down`};let n=e-t;if(n===0)return{value:0,direction:`neutral`};let r=Math.round(n/Math.abs(t)*100);return{value:Math.abs(r),direction:r>0?`up`:`down`}}function j(e){return e===null?`—`:`${e}%`}var M;function N(){return M===void 0&&(M=d.DashboardWidgetSchema.shape.type.parse(void 0)),M}function P(e){return e.type===void 0?F(e)?void 0:N():e.type}function F(e){return I(e)?void 0:e.component}function I(e){return u.DASHBOARD_COMPONENT_WIDGET_TYPES.includes(e.type)}function L(e){return{type:`text`,content:`「${e}」chart type is not supported yet`,variant:`caption`,align:`center`,className:`flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-muted-foreground`}}var R={column:`bar`,"stacked-bar":`bar`,"grouped-bar":`bar`,"bi-polar-bar":`bar`,spline:`line`,"step-line":`line`,"stacked-area":`area`,pyramid:`funnel`,bubble:`scatter`},z=new Set([`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`scatter`,`funnel`,`radar`,`treemap`,`sankey`,`combo`]);function B(e){return z.has(e)}var V=new Set([`metric`,`gauge`,`solid-gauge`,`kpi`,`bullet`]),H=new Set([`table`,`list`]),U=new Set([`sunburst`,`word-cloud`,`choropleth`,`bubble-map`,`gl-map`,`heatmap`,`waterfall`,`box-plot`,`violin`,`candlestick`,`stock`]);function W(e){if(!e)return{family:`passthrough`};let t=R[e]??e;return B(t)?{family:`series`,chartType:t}:V.has(e)?{family:`metric`}:H.has(e)?{family:`table`}:e===`pivot`?{family:`pivot`}:e===`custom`?{family:`custom`}:U.has(e)?{family:`unsupported`}:{family:`passthrough`}}var G={metric:`plugin-dashboard:metric`,"metric-card":`plugin-dashboard:metric-card`},K=G;function ee(e){let{description:t,...n}=e;return n}function te(e){if(!e||typeof e!=`object`)return e;let t=e.type,n=typeof t==`string`?K[t]:void 0;return n?{...e,type:n}:e}var q={type:`text`,content:`This widget uses a retired data format. Edit it to bind a dataset.`,variant:`caption`,align:`center`,className:`flex h-full w-full items-center justify-center rounded border border-dashed border-destructive/40 bg-destructive/5 p-4 text-center text-destructive`};function ne(e){if(!e)return!1;let t=e;return!t.dataset&&!(t.data||t.options?.data)&&!!t.object}function re(e){if(!e)return!1;let t=typeof e==`object`?e.type:void 0;return!u.DASHBOARD_COMPONENT_WIDGET_TYPES.includes(t)}function ie({source:e,className:t,testId:n}){let r=(0,i.useSafeTranslate)();return(0,f.jsx)(a.DataEmptyState,{role:`status`,"data-testid":n??`widget-empty-state`,className:(0,a.cn)(`h-full w-full gap-2 p-4 [&>h3]:text-sm [&>h3]:font-medium [&>p]:text-xs`,t),icon:(0,f.jsx)(o.Inbox,{className:`h-5 w-5 text-muted-foreground/70`}),iconWrapperClassName:`flex size-9 items-center justify-center rounded-lg bg-muted`,title:r(`dashboard.empty.title`,`No data yet`),description:r(`dashboard.empty.message`,`This widget loaded successfully and its query returned no records yet.`),children:e?(0,f.jsxs)(`p`,{className:`text-xs text-muted-foreground/80`,"data-testid":`widget-empty-source`,children:[(0,f.jsx)(`span`,{children:r(`dashboard.empty.sourceLabel`,`Source:`)}),` `,(0,f.jsx)(`span`,{className:`font-mono`,children:e})]}):null})}var ae={default:`bg-muted text-muted-foreground`,blue:`bg-blue-500/10 text-blue-600 dark:text-blue-400`,teal:`bg-teal-500/10 text-teal-600 dark:text-teal-400`,orange:`bg-orange-500/10 text-orange-600 dark:text-orange-400`,purple:`bg-purple-500/10 text-purple-600 dark:text-purple-400`,success:`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`,warning:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,danger:`bg-rose-500/10 text-rose-600 dark:text-rose-400`},oe={default:`text-foreground`,blue:`text-blue-600 dark:text-blue-400`,teal:`text-teal-600 dark:text-teal-400`,orange:`text-orange-600 dark:text-orange-400`,purple:`text-purple-600 dark:text-purple-400`,success:`text-emerald-600 dark:text-emerald-400`,warning:`text-amber-600 dark:text-amber-400`,danger:`text-rose-600 dark:text-rose-400`};function se(e){if(typeof e==`string`&&e!=="default")return oe[e]}var ce=`@container`,le=`min-w-0 line-clamp-2 break-words text-[13px] font-medium leading-snug text-foreground`,J=`max-w-full overflow-hidden text-ellipsis whitespace-nowrap tabular-nums text-xl @[160px]:text-2xl`,Y=[{maxEm:4.5,sizes:`text-xl @[160px]:text-2xl`},{maxEm:5.5,sizes:`text-sm @[136px]:text-base @[147px]:text-lg @[158px]:text-xl @[180px]:text-2xl`},{maxEm:6.75,sizes:`text-sm @[156px]:text-base @[170px]:text-lg @[183px]:text-xl @[210px]:text-2xl`},{maxEm:8,sizes:`text-sm @[176px]:text-base @[192px]:text-lg @[208px]:text-xl @[240px]:text-2xl`},{maxEm:10,sizes:`text-sm @[208px]:text-base @[228px]:text-lg @[248px]:text-xl @[288px]:text-2xl`},{maxEm:12.5,sizes:`text-sm @[248px]:text-base @[273px]:text-lg @[298px]:text-xl @[348px]:text-2xl`}],ue=`text-sm`,de=`max-w-full overflow-hidden text-ellipsis whitespace-nowrap tabular-nums`;function X(e){let t=0;for(let n of e)n>=`0`&&n<=`9`?t+=.65:/[.,'\s]/u.test(n)?t+=.27:/[\p{Sc}%+\-\u2212]/u.test(n)?t+=.7:t+=1;return t}function fe(e){let t=X(String(e)),n=Y.find(e=>t<=e.maxEm);return`${de} ${n?n.sizes:ue}`}function Z(e,t,n){return[t||e,n].filter(Boolean).join(`
|
|
2
|
+
`)||void 0}function pe(e){let t=String(e);return X(t)>Y[0].maxEm?t:void 0}var me=new Set([`id`,`organization_id`,`tenant_id`,`created_at`,`updated_at`,`created_by`,`updated_by`,`deleted_at`,`deleted_by`,`version`,`_id`,`__typename`]);function he(e,t){return t&&(t.isSystem===!0||t.system===!0)?!0:me.has(e)}var Q=new Set([`select`,`picklist`,`dropdown`,`status`]),ge=new Set([`currency`,`money`,`number`,`integer`,`decimal`,`float`,`percent`,`percentage`]),_e=new Set([`date`,`datetime`]),ve=[`reference`,`displayField`];function ye(e){let t={};if(!e)return t;for(let n of ve)e[n]!==void 0&&(t[n]=e[n]);return t}function be(e){let t={},n=e?.fields;if(!n)return t;if(Array.isArray(n))for(let e of n)e?.name&&(t[e.name]=e);else for(let[e,r]of Object.entries(n))t[e]={name:e,...r};return t}function xe(e){let{accessorKey:t,label:n,def:r,objectName:a,fieldOptionLabel:o,overrides:s={}}=e,c=s.options??r?.options;return a&&c&&o&&Q.has(r?.type)&&(c=c.map(e=>{if(e==null)return e;let n=typeof e==`object`?e.value:e,r=typeof e==`object`&&e.label||String(n);return{value:n,label:o(a,t,String(n),r),color:typeof e==`object`?e.color:void 0}})),{name:t,label:n,type:s.type??r?.type,options:c,format:s.format??r?.format,currency:s.currency??(0,i.resolveFieldCurrency)(r),...typeof r?.max==`number`&&{max:r.max},...ye(r)}}function Se(e){return ge.has(e.type)||typeof e.format==`string`&&/^[$¥€£]|%$|0/.test(e.format)}function Ce(e,t,n,r){if(e==null||e===``)return``;let i=t.format;if(typeof i==`string`&&/^\$|¥|€|£/.test(i)&&typeof e==`number`){let a={$:`USD`,"¥":`JPY`,"€":`EUR`,"£":`GBP`}[i[0]];return(0,p.formatCurrency)(e,t.currency||a||n,r)}if(typeof i==`string`&&/%/.test(i)&&typeof e==`number`){let n=(i.match(/0\.(0+)%/)||[void 0,``])[1].length,a=t.type===`percent`||t.type===`progress`?(0,p.percentCellScale)(t):`fraction`;return(0,p.formatPercent)(e,a,n,r)}if(typeof i==`string`&&_e.has(t.type)&&/[YMDHms]/.test(i))return(0,p.formatDate)(e,i,{locale:r});let a=(0,p.getCellRenderer)((0,p.resolveCellRendererType)(t));return(0,f.jsx)(a,{value:e,field:t})}function we(e){return typeof e==`string`&&(0,p.isRetiredFieldType)(e)?((0,p.reportRetiredFieldType)(e),!1):n.EXPANDABLE_FIELD_TYPES.has(e)}var Te=[`name`,`title`,`label`,`subject`,`display_name`,`full_name`];function Ee(e,t){if(t&&t.trim())return t;for(let t of Te){let n=e[t];if(typeof n==`string`&&n.trim())return n}let n=e.id??e._id;return n==null?`Record`:String(n)}var De=({record:e,objectName:n,objectSchema:r,fields:o,title:s,target:c=`drawer`,onClose:l,objectTypesPending:u=!1})=>{let{fieldLabel:d,fieldOptionLabel:m}=(0,i.useSafeFieldLabel)(),{currency:h}=(0,i.useLocalization)(),g=(0,i.useDisplayLocale)(),_=(0,t.useMemo)(()=>{if(!e)return[];let t=be(r),i;return i=o&&o.length>0?o:Object.keys(t).length>0?Object.keys(t).filter(e=>!he(e,t[e])):Object.keys(e).filter(e=>!e.startsWith(`_`)&&!he(e)),i.map(r=>{let i=t[r],a=D(r),o=n?d(n,r,a):a,s=xe({accessorKey:r,label:o,def:i,objectName:n,fieldOptionLabel:m});return{key:r,label:o,node:u?(0,f.jsx)(p.MaskedCellRenderer,{value:e[r]}):Ce(e[r],s,h,g),numeric:!u&&Se(s)}})},[e,r,n,o,d,m,h,g,u]);if(!e)return null;let v=Ee(e,s),y=(0,f.jsx)(`dl`,{className:`divide-y divide-border/60`,"data-testid":`record-detail-body`,children:_.map(e=>(0,f.jsxs)(`div`,{className:`grid grid-cols-3 gap-3 py-2.5`,children:[(0,f.jsx)(`dt`,{className:`text-xs font-medium text-muted-foreground self-center`,children:e.label}),(0,f.jsx)(`dd`,{className:`col-span-2 text-sm break-words ${e.numeric?`tabular-nums`:``}`,children:e.node===``||e.node==null?(0,f.jsx)(a.EmptyValue,{}):e.node})]},e.key))});return c===`dialog`?(0,f.jsx)(a.Dialog,{open:!0,onOpenChange:e=>!e&&l(),children:(0,f.jsxs)(a.DialogContent,{className:`max-w-2xl`,children:[(0,f.jsx)(a.DialogHeader,{children:(0,f.jsx)(a.DialogTitle,{children:v})}),(0,f.jsx)(`div`,{className:`max-h-[70vh] overflow-auto`,children:y})]})}):(0,f.jsx)(a.Sheet,{open:!0,onOpenChange:e=>!e&&l(),children:(0,f.jsxs)(a.SheetContent,{side:`right`,className:`w-full sm:max-w-md md:max-w-lg flex flex-col`,children:[(0,f.jsx)(a.SheetHeader,{children:(0,f.jsx)(a.SheetTitle,{children:v})}),(0,f.jsx)(`div`,{className:`flex-1 overflow-auto mt-2 pr-1`,children:y})]})})},$=Object.freeze([]);function Oe(e){return t.default.createElement(p.MaskedCellRenderer,{value:e})}function ke(e){return e.map(e=>{if(typeof e==`string`)return{header:D(e),accessorKey:e};if(!e)return e;let t={};if(!e.accessorKey){let r=(0,n.columnIdentity)(e);r&&(t.accessorKey=r)}if(!e.header){let r=(0,n.columnHeader)(e);r&&(t.header=r)}return Object.keys(t).length===0?e:{...e,...t}})}function Ae(e,t){if(!t?.fields)return[];let r={};if(Array.isArray(t.fields))for(let e of t.fields)e?.name&&(r[e.name]=e);else for(let[e,n]of Object.entries(t.fields))r[e]={name:e,...n};let i=Array.isArray(e.columns)?e.columns:[],a=new Set;if(i.length>0){let e=i.map(e=>typeof e==`string`?e:e?.accessorKey||(0,n.columnIdentity)(e)).filter(Boolean);for(let t of e){let e=r[t];e&&we(e.type)&&a.add(t)}}else for(let[e,t]of Object.entries(r))we(t?.type)&&a.add(e);return Array.from(a)}var je=({schema:e,dataSource:o,className:s})=>{let{currency:c}=(0,i.useLocalization)(),l=(0,i.useDisplayLocale)(),d=(0,t.useContext)(r.SchemaRendererContext),h=o||d?.dataSource,g=(0,r.useDataScope)(e.bind),{fieldLabel:_,fieldOptionLabel:v}=(0,i.useSafeFieldLabel)(),y=`No data source available for`,{t:b}=(0,i.useObjectTranslation)(),x=b(`dashboard.noDataSourceFor`);x&&x!==`dashboard.noDataSourceFor`&&(y=x);let[S,C]=(0,t.useState)([]),[w,T]=(0,t.useState)(()=>!(Array.isArray(e.data)&&e.data.length>0)&&!!e.objectName),[E,O]=(0,t.useState)(null),k=e.drillDown,A=(0,n.isDrillEnabled)(k)&&(k?.mode??`record`)===`record`,[j,M]=(0,t.useState)(null),N=(0,t.useCallback)(e=>{M(e??null)},[]),P=(0,r.useFilterScope)(),F=(0,m.usePermissions)(),{ready:I,def:L}=(0,r.useSettledSchema)(e.objectName??``,h),R=Ae(e,L).join(`,`),z=!!h&&!!e.objectName&&!g&&(!e.data||e.data.length===0),B=(0,r.useDataInvalidation)(z?e.objectName:void 0);(0,t.useEffect)(()=>{let t=!0;return e.objectName&&!g&&(!e.data||e.data.length===0)?I?(async()=>{if(!h||!e.objectName){t&&T(!1);return}t&&(T(!0),O(null));try{let r;if(typeof h.find==`function`){let t=Ae(e,L),i=F?.isLoaded?t.filter(t=>F.checkField(e.objectName,t,`read`)):t,a={$filter:(0,n.resolveFilterPlaceholders)(e.filter,P)};i.length&&(a.$expand=i);let o=await h.find(e.objectName,a);r=(0,n.extractRecords)(o)}else return;t&&C(r)}catch(e){console.error(`[ObjectDataTable] Fetch error:`,e),t&&O(e instanceof Error?e.message:`Failed to load data`)}finally{t&&T(!1)}})():t&&T(!0):t&&T(!1),()=>{t=!1}},[e.objectName,h,g,e.data,e.filter,I,L,R,P,F,B]);let V=g||e.data||S,H=Array.isArray(V)?V:$,U=!!e.objectName&&typeof h?.getObjectSchema==`function`&&!L?.fields,W=(0,t.useMemo)(()=>{let t=e.objectName,n={};if(L?.fields){let e=L.fields;if(Array.isArray(e))for(let t of e)t?.name&&(n[t.name]=t);else for(let[t,r]of Object.entries(e))n[t]={name:t,...r}}let r=e=>{let n=D(e);return t?_(t,e,n):n},i=e=>{let r=e,i=xe({accessorKey:e.accessorKey,label:e.header,def:n[e.accessorKey],objectName:t,fieldOptionLabel:v,overrides:{type:r.type,format:r.format,options:r.options,currency:r.currency}}),a=e.align??(Se(i)?`right`:void 0),o=(0,u.normalizeTableColumnType)(i.type),s=U||(0,p.isMaskedFieldType)(r.type)||(0,p.isMaskedFieldType)(n[e.accessorKey]?.type)?{masked:!0}:{};if(typeof e.cell==`function`)return{...e,name:i.name,type:o,align:a,...s};if(U&&!r.type)return{...e,name:i.name,type:o,align:a,cell:Oe,...s};let d=e=>Ce(e,i,c,l);return{...e,name:i.name,type:o,align:a,cell:d,...s}};return e.columns&&e.columns.length>0?ke(e.columns).map(e=>{if(!e?.accessorKey)return e;let n=(e.header&&e.header!==e.accessorKey?e.header:void 0)??D(e.accessorKey),r=t?_(t,e.accessorKey,n):n;return r===e.header?e:{...e,header:r}}).map(i):H.length===0?[]:(Object.keys(n).length>0?Object.keys(n).filter(e=>!he(e,n[e])):Object.keys(H[0]).filter(e=>!e.startsWith(`_`)&&!he(e))).map(e=>i({header:r(e),accessorKey:e}))},[e.columns,e.objectName,H,L,U,_,v,c,l]);if(w&&H.length===0)return(0,f.jsx)(`div`,{className:(0,a.cn)(`overflow-auto`,s),"data-testid":`table-loading`,children:(0,f.jsxs)(`div`,{className:`space-y-2 p-2`,children:[(0,f.jsxs)(`div`,{className:`flex gap-2`,children:[(0,f.jsx)(a.Skeleton,{className:`h-6 w-1/4`}),(0,f.jsx)(a.Skeleton,{className:`h-6 w-1/4`}),(0,f.jsx)(a.Skeleton,{className:`h-6 w-1/4`}),(0,f.jsx)(a.Skeleton,{className:`h-6 w-1/4`})]}),[1,2,3,4].map(e=>(0,f.jsxs)(`div`,{className:`flex gap-2`,children:[(0,f.jsx)(a.Skeleton,{className:`h-5 w-1/4`}),(0,f.jsx)(a.Skeleton,{className:`h-5 w-1/4`}),(0,f.jsx)(a.Skeleton,{className:`h-5 w-1/4`}),(0,f.jsx)(a.Skeleton,{className:`h-5 w-1/4`})]},e))]})});if(E)return(0,f.jsx)(`div`,{className:(0,a.cn)(`overflow-auto`,s),"data-testid":`table-error`,children:(0,f.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-destructive`,"data-testid":`table-error-message`,children:[(0,f.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 mb-2 opacity-60`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,f.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,f.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,f.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),(0,f.jsx)(`p`,{className:`text-xs`,children:E})]})});if(!h&&e.objectName&&H.length===0)return(0,f.jsx)(`div`,{className:(0,a.cn)(`overflow-auto`,s),children:(0,f.jsx)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:(0,f.jsxs)(`p`,{className:`text-xs`,children:[y,` “`,e.objectName,`”`]})})});if(H.length===0)return(0,f.jsx)(`div`,{className:(0,a.cn)(`overflow-auto`,s),"data-testid":`table-empty-state`,children:(0,f.jsx)(ie,{source:e.objectName||void 0,className:`py-8`})});let{bind:G,...K}=e,ee={...K,type:`data-table`,data:H,columns:W,onRowClick:e.onRowClick??(A?N:void 0)},te=k?.title&&!k.title.includes("${")?k.title:void 0;return(0,f.jsxs)(`div`,{className:(0,a.cn)(`relative`,s),children:[(0,f.jsx)(a.RefreshIndicator,{active:w&&H.length>0,ariaLabel:b(`dashboard.refreshing`)}),(0,f.jsx)(r.SchemaRenderer,{schema:ee,className:s}),A&&(0,f.jsx)(De,{record:j,objectName:e.objectName,objectSchema:L,fields:k?.columns,title:te,target:k?.target===`dialog`?`dialog`:`drawer`,onClose:()=>M(null),objectTypesPending:U})]})},Me=({objectName:e,filter:t,onNavigate:n,className:s})=>{let{openRecordList:c}=(0,r.useDrillNavigation)(),l=(0,i.useSafeTranslate)();return!c||!e?null:(0,f.jsxs)(a.Button,{type:`button`,variant:`ghost`,size:`sm`,className:s,"data-testid":`drill-open-in-list`,onClick:()=>{c(e,t),n?.()},children:[l(`dashboard.openInList`,`Open in list`),(0,f.jsx)(o.ArrowUpRight,{className:`ml-1 h-3.5 w-3.5`})]})};function Ne(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.dataset==`string`&&t.dataset.length>0||t.type===`joined`&&Array.isArray(t.blocks)&&t.blocks.some(e=>typeof e?.dataset==`string`)}var Pe=({open:e,onClose:n,title:i,target:o=`drawer`,objectName:s,filter:c,dataSource:l,columns:u,maxRows:d,className:p,report:m})=>{let{openRecordList:h}=(0,r.useDrillNavigation)(),g=Ne(m),_=o===`navigate`&&!!h&&!g&&!!s;if(t.default.useEffect(()=>{e&&_&&(h(s,c),n())},[e,_]),_)return null;let v=g?null:(0,f.jsx)(Me,{objectName:s,filter:c,onNavigate:n}),y=(0,f.jsx)(`div`,{className:(0,a.cn)(`overflow-auto`,p),"data-testid":`drill-down-body`,children:g?(()=>{let e=m.runtimeFilter,t=e?c?{$and:[e,c]}:e:c,n={type:`report`,report:t?{...m,runtimeFilter:t}:m};return(0,f.jsx)(r.SchemaRenderer,{schema:n})})():(0,f.jsx)(je,{schema:{type:`object-data-table`,objectName:s,filter:c,columns:u?.map(e=>({accessorKey:e,header:e})),pagination:!0,searchable:!1,pageSize:d,drillDown:{enabled:!0,mode:`record`,target:`dialog`}},dataSource:l})});return o===`dialog`?(0,f.jsx)(a.Dialog,{open:e,onOpenChange:e=>!e&&n(),children:(0,f.jsxs)(a.DialogContent,{className:`max-w-5xl`,children:[(0,f.jsxs)(a.DialogHeader,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,f.jsx)(a.DialogTitle,{children:i}),v]}),y]})}):(0,f.jsx)(a.Sheet,{open:e,onOpenChange:e=>!e&&n(),children:(0,f.jsxs)(a.SheetContent,{side:`right`,className:`w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col`,children:[(0,f.jsxs)(a.SheetHeader,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,f.jsx)(a.SheetTitle,{children:i}),v]}),(0,f.jsx)(`div`,{className:`flex-1 overflow-hidden mt-2`,children:y})]})})},Fe=n.buildDatasetDrillFilter;function Ie(e,t,r,i){let a=[],o=[],s=new Set,c=new Set,l=new Map;return e.forEach((e,u)=>{let d=(0,n.pivotBucketId)(t.map(t=>(0,n.pivotDimensionValue)(e[t]))),f=(0,n.pivotBucketId)([(0,n.pivotDimensionValue)(e[r])]);s.has(d)||(s.add(d),a.push({id:d,labels:t.map(t=>(0,n.formatDimensionValue)(e[t],i))})),c.has(f)||(c.add(f),o.push({id:f,label:(0,n.formatDimensionValue)(e[r],i)})),l.set((0,n.pivotCellKey)(d,f),u)}),{rowHeaders:a,colHeaders:o,cellIndex:l}}function Le(e){if(e==null)return``;let t=String(e);return/[",\n\r]/.test(t)?`"${t.replace(/"/g,`""`)}"`:t}function Re(e){return e.map(e=>e.map(Le).join(`,`)).join(`\r
|
|
3
|
+
`)}function ze(e,t){if(typeof document>`u`)return;let n=e&&e.trim()?e.trim():`export`,r=new Blob([`\uFEFF${Re(t)}`],{type:`text/csv;charset=utf-8;`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=n.endsWith(`.csv`)?n:`${n}.csv`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)}var Be=`__compare`,Ve=e=>`${e}${Be}`,He={vsLastQuarter:`vs last quarter`,vsLastMonth:`vs last month`,vsLastWeek:`vs last week`,vsLastYear:`vs last year`,vsYesterday:`vs yesterday`,vsPreviousPeriod:`vs previous period`},Ue={previousPeriod:`vsPreviousPeriod`,previousYear:`vsLastYear`},We=/^\d{4}-\d{2}-\d{2}(?:[T ][\d:.]+(?:Z|[+-]\d{2}:?\d{2})?)?$/;function Ge(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=Object.keys(e);if(t.length!==2||!t.includes(`$gte`)||!t.includes(`$lte`))return null;let{$gte:n,$lte:r}=e;return typeof n!=`string`||typeof r!=`string`||!We.test(n)||!We.test(r)?null:[n,r]}function Ke(e){let t=new Map,n=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return e;let r={},i=null;for(let[a,o]of Object.entries(e)){if(a===`$and`&&Array.isArray(o)){i=o.map(n).filter(e=>!!e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length>0);continue}if(a.startsWith(`$`)){r[a]=o;continue}let e=Ge(o);if(!e){r[a]=o;continue}let s=t.get(a);t.set(a,s?[s[0]>e[0]?s[0]:e[0],s[1]<e[1]?s[1]:e[1]]:e)}return i&&i.length>0&&(r.$and=i),r},r=n(e),i=r&&Object.keys(r).length>0?r:void 0,a=i&&Object.keys(i).length===1&&Array.isArray(i.$and)&&i.$and.length===1?i.$and[0]:void 0;return a&&(i=a),{windows:Array.from(t,([e,t])=>({dimension:e,dateRange:t})),rest:i}}var qe=new Set([`metric`,`kpi`,`gauge`,`solid-gauge`,`bullet`]),Je=new Set(d.DASHBOARD_WIDGET_MULTI_MEASURE_TYPES),Ye=new Set([`pie`,`donut`,`funnel`,`treemap`,`sankey`]),Xe=`__measure`,Ze=`__value`;function Qe(e,t,n){let r=e==null?void 0:t.get(String(e));return r===void 0?e==null||e===``||n!==void 0&&e===n?2**53-1:2**53-1-1:r}var $e={bar:`bar`,column:`column`,"horizontal-bar":`horizontal-bar`,"grouped-bar":`bar`,"stacked-bar":`bar`,"bi-polar-bar":`bar`,line:`line`,spline:`line`,"step-line":`line`,area:`area`,"stacked-area":`area`,pie:`pie`,donut:`donut`,funnel:`funnel`,pyramid:`funnel`,scatter:`scatter`,bubble:`scatter`,radar:`radar`,treemap:`treemap`,sankey:`sankey`,combo:`combo`};function et({heading:e,label:t}){return(0,f.jsx)(`div`,{className:`flex w-full min-w-0`,"data-testid":`dataset-metric-heading`,children:e.title&&(0,f.jsx)(`span`,{className:`min-w-0 line-clamp-2 break-words text-[13px] font-medium leading-snug text-foreground`,title:Z(e.title,e.description,t),"data-testid":`dataset-metric-title`,children:e.title})})}function tt({widget:e,dataSource:s,heading:c}){let l=String(e?.dataset??``),u=(0,t.useMemo)(()=>Array.isArray(e?.dimensions)?e.dimensions.filter(Boolean):[],[e]),d=(0,t.useMemo)(()=>Array.isArray(e?.values)?e.values.filter(Boolean):[],[e]),p=String(e?.type??N()),m=p===`table`||p===`pivot`,h=d.length>1&&(m||Je.has($e[p]??``)),g=qe.has(p)||u.length===0&&!h,_=$e[p]??`bar`,v=!g&&!m&&Ye.has(_),y=g||v?d.slice(0,1):d,b=d.filter(e=>!y.includes(e)),x=!g&&!m&&(0,n.chartTypeIgnoresCompareTo)(_)?void 0:e?.compareTo,S=p===`pivot`&&u.length>=2,C=S?u.slice(0,-1):[],w=S?u[u.length-1]:``,T=e?.options&&typeof e.options==`object`&&!Array.isArray(e.options)?e.options:{},E=typeof T.dateGranularity==`string`?T.dateGranularity:void 0,D=typeof T.sortBy==`string`&&T.sortBy?T.sortBy:void 0,O=D&&(u.includes(D)||d.includes(D))?D:void 0,k=O?{[O]:T.sortOrder===`desc`?`desc`:`asc`}:void 0,M=typeof T.limit==`number`&&Number.isFinite(T.limit)&&T.limit>0?Math.floor(T.limit):void 0,P=m&&!S&&u.length>0&&M==null,F=S?[C,[w],[]]:P?[[]]:void 0,I=(0,i.useSafeTranslate)(),{fieldLabel:L,fieldOptionLabel:R}=(0,i.useSafeFieldLabel)(),z=(0,i.useDisplayLocale)(),B=(0,r.useFilterScope)(),V=e?.filter,H=(0,t.useMemo)(()=>V&&typeof V==`object`&&Object.keys(V).length>0?(0,n.resolveFilterPlaceholders)(V,B):void 0,[V,B]),{windows:U,rest:W}=(0,t.useMemo)(()=>x?Ke(H):{windows:[],rest:H},[x,H]),[G,K]=(0,t.useState)({status:`idle`,rows:[]}),[ee,te]=(0,t.useState)(null),[q,ne]=(0,t.useState)(null),re=`${p}|${l}|${u.join(`,`)}|${d.join(`,`)}|${JSON.stringify(V??null)}|${JSON.stringify(x??null)}|${E??``}|${JSON.stringify(k??null)}|${M??``}`,[ae,oe]=(0,t.useState)(void 0),le=(0,r.useDataInvalidation)(d.length>0?ae:void 0);(0,t.useEffect)(()=>{let e=s;if(!e||typeof e.queryDataset!=`function`){K({status:`error`,rows:[],error:I(`dashboard.datasetUnsupported`,`This data source does not support dataset queries.`)});return}if(d.length===0){K({status:`idle`,rows:[]});return}let t=!1;return K(e=>e.status===`ok`&&e.signature===re?{...e,refreshing:!0}:{status:`loading`,rows:[]}),e.queryDataset(l,{dimensions:u,measures:d,...W?{runtimeFilter:W}:{},...U.length>0?{timeDimensions:U}:{},...x?{compareTo:x}:{},...F?{totals:{groupings:F}}:{},...E?{dateGranularity:E}:{},...k?{order:k}:{},...M==null?{}:{limit:M}}).then(e=>{t||(K({status:`ok`,rows:Array.isArray(e?.rows)?e.rows:[],fields:Array.isArray(e?.fields)?e.fields:[],object:e?.object,dimensionFields:e?.dimensionFields,drillRawRows:Array.isArray(e?.drillRawRows)?e.drillRawRows:void 0,drillRanges:Array.isArray(e?.drillRanges)?e.drillRanges:void 0,totals:Array.isArray(e?.totals)?e.totals:void 0,signature:re}),typeof e?.object==`string`&&e.object&&oe(e.object))}).catch(e=>{if(!t){if((0,r.classifyLoadError)(e)===`forbidden`){K({status:`error`,rows:[],forbidden:!0});return}K({status:`error`,rows:[],error:String(e?.message??e)})}}),()=>{t=!0}},[re,le]);let Y=e=>e.map(e=>`"${e}"`).join(`, `),ue=b.length>0?`[DatasetWidget] Widget "${String(e?.id??``)}" (type "${p}", dataset "${l}") renders ${y.length} of its ${d.length} declared measures: ${Y(y)}. Queried and then never displayed: ${Y(b)}. `+(v?`Its chart family "${_}" draws a single series: the first declared measure.`:`The spec states what to author instead of a one-number tile with several measures in the replacement of its ADR-0087 entry "dashboard-widget-metric-family-multi-measure-refused".`):``;(0,t.useEffect)(()=>{ue&&console.warn(ue)},[ue]);let de=(0,r.useDatasetDimensionMeta)(G.object,G.dimensionFields,u,{enabled:!g}),{categoryColors:X,dimensionLabels:fe,categoryOrder:Z,seriesOrder:pe}=(0,t.useMemo)(()=>{if(!de)return{categoryColors:null,dimensionLabels:null,categoryOrder:null,seriesOrder:null};let{metaByPath:e,relabel:t}=de,r=m?void 0:t[0]?.path,i=r?e[r]:void 0,a=r?(0,n.localizeFieldOptions)(i?.options,(0,n.dimensionOptionTranslator)(i,R)):void 0,o=m?void 0:t[1]?.path,s=o?e[o]:void 0,c=o?(0,n.localizeFieldOptions)(s?.options,(0,n.dimensionOptionTranslator)(s,R)):void 0;return{categoryColors:(0,n.buildOptionColorMap)(a),dimensionLabels:(0,n.deriveDimensionLabelMaps)(e,t,R),categoryOrder:(0,n.buildCategoryOrder)(a),seriesOrder:(0,n.buildCategoryOrder)(c)}},[de,R,m]),me=e=>c?(0,f.jsxs)(`div`,{className:(0,a.cn)(`flex h-full w-full min-w-0 flex-col gap-1`,ce),children:[(0,f.jsx)(et,{heading:c}),e]}):e;if(d.length===0)return me((0,f.jsx)(`div`,{className:`flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-xs text-muted-foreground`,children:I(`dashboard.pickMeasures`,`Pick measures (values) for this dataset widget.`)}));if(G.status===`loading`||G.status===`idle`)return me((0,f.jsxs)(`div`,{className:`h-full w-full p-2`,"data-testid":`dataset-loading`,role:`status`,"aria-busy":`true`,"aria-live":`polite`,children:[(0,f.jsx)(`span`,{className:`sr-only`,children:I(`dashboard.loading`,`Loading…`)}),g?(0,f.jsxs)(`div`,{className:`flex h-full w-full flex-col items-start justify-center gap-2 p-2`,children:[(0,f.jsx)(a.Skeleton,{className:`h-8 w-32 rounded`}),(0,f.jsx)(a.Skeleton,{className:`h-3 w-20 rounded`})]}):m?(0,f.jsx)(a.GridSkeleton,{className:`h-full`,rows:5,columns:Math.max(2,u.length+d.length)}):(0,f.jsx)(a.ChartSkeleton,{className:`h-full`})]}));if(G.status===`error`&&G.forbidden)return me((0,f.jsxs)(`div`,{role:`alert`,"data-testid":`dataset-widget-forbidden`,className:`flex h-full w-full flex-col items-center justify-center gap-1 p-3 text-center text-xs text-muted-foreground`,children:[(0,f.jsx)(o.ShieldAlert,{className:`h-5 w-5 text-muted-foreground/70`,"aria-hidden":`true`}),(0,f.jsx)(`span`,{className:`font-medium text-foreground/80`,children:I(`dashboard.widgetForbiddenTitle`,`You don’t have access`)}),(0,f.jsx)(`span`,{children:I(`dashboard.widgetForbiddenMessage`,`You don’t have permission to view the data behind this widget.`)})]}));if(G.status===`error`)return me((0,f.jsxs)(`div`,{role:`alert`,className:`flex h-full w-full items-start gap-2 rounded border border-destructive/40 bg-destructive/5 p-3 text-xs text-destructive`,children:[(0,f.jsx)(o.AlertTriangle,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),(0,f.jsx)(`span`,{className:`break-words`,children:G.error})]}));let he=(0,f.jsx)(a.RefreshIndicator,{active:!!G.refreshing,ariaLabel:I(`dashboard.refreshing`,`Refreshing…`)});if(G.rows.length===0&&!g)return(0,f.jsx)(ie,{className:`rounded border border-dashed bg-muted/20`,source:l||void 0});let{measureField:Q,headerLabel:ge}=(0,n.buildDatasetFieldHelpers)(G.fields,G.object,L,(0,i.builtinAggregateLabels)(I)),_e=x?d.filter(e=>G.rows.some(t=>t[Ve(e)]!=null)):[],ve=x?Ue[x.kind]:``,ye=x?I(`dashboard.trend.${ve}`,He[ve]??`vs previous period`):``,{object:be,dimensionFields:xe,drillRawRows:Se,drillRanges:Ce}=G,we=xe?u.filter(e=>e in xe):[],Te=!!be&&(we.length>0||!!Ce?.length),Ee=(t,r)=>{if(!be)return;let i;try{i=Fe(Se?.[t],we,xe??{},H,Ce?.[t])}catch(e){if(!(e instanceof n.FilterOperatorError))throw e;console.warn(`[DatasetWidget] drill-down refused — the drilled list cannot be scoped: ${e.message}`);return}te({filter:i,title:r||String(e?.title??``)})},De=ee&&be?(0,f.jsx)(Pe,{open:!0,onClose:()=>te(null),title:ee.title||String(e?.title??I(`dashboard.details`,`Details`)),objectName:be,filter:ee.filter,dataSource:s}):null;if(g){let t=y[0],r=Q(t),i=G.rows[0]?.[t]??0,s=G.rows[0]?.[Ve(t)],l=_e.includes(t)?A(typeof i==`number`?i:null,typeof s==`number`?s:null):null,u=se(e?.colorVariant),d=ge(t);return(0,f.jsxs)(`div`,{className:(0,a.cn)(`flex h-full w-full flex-col items-start justify-center gap-1 p-2`,c&&(0,a.cn)(`min-w-0`,`@container`),G.refreshing&&`relative`),children:[he,c&&(0,f.jsx)(et,{heading:c,label:d}),(0,f.jsx)(`span`,{className:(0,a.cn)(c?(0,a.cn)(`font-semibold`,J):`text-2xl font-semibold tabular-nums`,u),children:(0,n.formatMeasure)(i,r?.format,r?.currency,r?.percentScale,z)}),c&&d&&(0,f.jsx)(`span`,{className:`hidden max-w-full truncate text-[11px] text-muted-foreground @[160px]:block`,"data-testid":`dataset-metric-label`,children:d}),l&&(0,f.jsxs)(`div`,{className:`mt-0.5 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground`,"data-testid":`dataset-compare-trend`,children:[(0,f.jsxs)(`span`,{className:(0,a.cn)(`flex shrink-0 items-center font-medium`,l.direction===`up`&&`text-emerald-600 dark:text-emerald-400`,l.direction===`down`&&`text-rose-600 dark:text-rose-400`,l.direction===`neutral`&&`text-muted-foreground`),children:[l.direction===`up`&&(0,f.jsx)(o.ArrowUpIcon,{className:`mr-1 h-3 w-3`}),l.direction===`down`&&(0,f.jsx)(o.ArrowDownIcon,{className:`mr-1 h-3 w-3`}),l.direction===`neutral`&&(0,f.jsx)(o.MinusIcon,{className:`mr-1 h-3 w-3`}),j(l.value)]}),(0,f.jsx)(`span`,{className:`min-w-0 truncate`,children:ye})]}),!c&&(0,f.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:d})]})}if(m){let t=(0,n.relabelDimensions)(G.rows,fe),r=e=>{if(d.includes(e)||!e.endsWith(Be))return;let t=e.slice(0,-9);return d.includes(t)?t:void 0},i=e=>{let t=r(e);return t?`${ge(t)} · ${ye}`:ge(e)},s=d.flatMap(e=>_e.includes(e)?[e,Ve(e)]:[e]),c=[...u,...s],p=t=>ze(String(e?.title??l??`export`),[c.map(e=>i(e)),...t.map(e=>c.map(t=>{let n=e[t];return n==null?``:typeof n==`number`?n:String(n)}))]),m=e=>(0,f.jsx)(`button`,{type:`button`,onClick:()=>p(e),"data-testid":`dataset-export`,title:I(`dashboard.exportCsv`,`Export CSV`),"aria-label":I(`dashboard.exportCsv`,`Export CSV`),className:`absolute right-1 top-1 z-10 rounded p-1 text-muted-foreground opacity-70 hover:bg-accent/50 hover:text-foreground hover:opacity-100`,children:(0,f.jsx)(o.Download,{className:`h-3.5 w-3.5`})}),h=m(t);if(S){let e=Ie(t,C,w,z),r=e.colHeaders.flatMap(e=>d.map(t=>({col:e,measure:t,header:d.length===1?e.label:`${e.label} · ${ge(t)}`}))),i=(e,t)=>(0,n.formatMeasure)(e,Q(t)?.format,Q(t)?.currency,Q(t)?.percentScale,z),s=(e,t)=>{if(!_e.includes(t))return null;let n=e?.[Ve(t)];if(n==null)return null;let r=e?.[t],s=A(typeof r==`number`?r:null,typeof n==`number`?n:null);return(0,f.jsxs)(`div`,{className:`flex items-center justify-end gap-1 text-[10px] font-normal leading-tight text-muted-foreground`,"data-testid":`matrix-cell-compare`,"data-direction":s?.direction,title:ye,children:[(0,f.jsx)(`span`,{className:`tabular-nums`,children:i(n,t)}),s&&(0,f.jsxs)(`span`,{className:(0,a.cn)(`flex shrink-0 items-center tabular-nums font-medium`,s.direction===`up`&&`text-emerald-600 dark:text-emerald-400`,s.direction===`down`&&`text-rose-600 dark:text-rose-400`),children:[s.direction===`up`&&(0,f.jsx)(o.ArrowUpIcon,{className:`h-2.5 w-2.5`}),s.direction===`down`&&(0,f.jsx)(o.ArrowDownIcon,{className:`h-2.5 w-2.5`}),s.direction===`neutral`&&(0,f.jsx)(o.MinusIcon,{className:`h-2.5 w-2.5`}),j(s.value)]})]})},c=_e.length>0?(0,f.jsx)(`caption`,{className:`px-2 pb-1 text-left text-[10px] font-normal text-muted-foreground`,"data-testid":`matrix-compare-caption`,children:ye}):null,l=e=>{let t=G.totals?.find(t=>Array.isArray(t.dimensions)&&t.dimensions.join(`,`)===e.join(`,`))?.rows;return t&&(0,n.relabelDimensions)(t,fe)},u=new Map;for(let e of l(C)??[])u.set((0,n.pivotBucketId)(C.map(t=>(0,n.pivotDimensionValue)(e[t]))),e);let p=new Map;for(let e of l([w])??[])p.set((0,n.pivotBucketId)([(0,n.pivotDimensionValue)(e[w])]),e);let m=l([])?.[0],g=u.size>0,_=p.size>0,v=I(`dashboard.total`,`Total`);return(0,f.jsxs)(`div`,{className:`relative h-full w-full overflow-auto p-1`,"data-testid":`dataset-matrix`,children:[he,h,(0,f.jsxs)(`table`,{className:`w-full text-xs`,children:[c,(0,f.jsx)(`thead`,{className:`bg-muted/40`,children:(0,f.jsxs)(`tr`,{children:[C.map(e=>(0,f.jsx)(`th`,{className:`px-2 py-1.5 text-left font-medium whitespace-nowrap`,children:ge(e)},e)),r.map(e=>(0,f.jsx)(`th`,{className:`px-2 py-1.5 text-right font-medium whitespace-nowrap`,children:e.header},`${e.col.id}-${e.measure}`)),g&&d.map(e=>(0,f.jsx)(`th`,{className:`px-2 py-1.5 text-right font-medium whitespace-nowrap`,"data-testid":`matrix-total-col-header`,children:d.length===1?v:`${v} · ${ge(e)}`},`total-${e}`))]})}),(0,f.jsxs)(`tbody`,{children:[e.rowHeaders.map(t=>(0,f.jsxs)(`tr`,{className:`border-t`,children:[t.labels.map((e,t)=>(0,f.jsx)(`td`,{className:`px-2 py-1 whitespace-nowrap font-medium`,children:e},t)),r.map(r=>{let o=e.cellIndex.get((0,n.pivotCellKey)(t.id,r.col.id)),c=o==null?void 0:G.rows[o],l=Te&&o!=null,u=[...t.labels,r.col.label].filter(Boolean).join(` / `);return(0,f.jsxs)(`td`,{className:(0,a.cn)(`px-2 py-1 text-right tabular-nums whitespace-nowrap`,l&&`cursor-pointer hover:bg-accent/40`),"data-testid":l?`dataset-drill-cell`:void 0,onClick:l?()=>Ee(o,u):void 0,children:[c?i(c[r.measure],r.measure):`—`,s(c,r.measure)]},`${r.col.id}-${r.measure}`)}),g&&d.map(e=>{let n=u.get(t.id);return(0,f.jsxs)(`td`,{className:`px-2 py-1 text-right tabular-nums whitespace-nowrap font-medium`,"data-testid":`matrix-row-total`,children:[i(n?.[e],e),s(n,e)]},`total-${e}`)})]},t.id)),_&&(0,f.jsxs)(`tr`,{className:`border-t bg-muted/30 font-medium`,"data-testid":`matrix-total-row`,children:[C.length>0&&(0,f.jsx)(`td`,{colSpan:C.length,className:`px-2 py-1 whitespace-nowrap`,children:v}),r.map(e=>{let t=p.get(e.col.id);return(0,f.jsxs)(`td`,{className:`px-2 py-1 text-right tabular-nums whitespace-nowrap`,children:[i(t?.[e.measure],e.measure),s(t,e.measure)]},`${e.col.id}-${e.measure}`)}),g&&d.map(e=>(0,f.jsxs)(`td`,{className:`px-2 py-1 text-right tabular-nums whitespace-nowrap`,"data-testid":`matrix-grand-total`,children:[i(m?.[e],e),s(m,e)]},`grand-${e}`))]})]})]}),De]})}let g=[...u,...s],_=new Set(g.filter(e=>(d.includes(e)||r(e)!==void 0)&&t.every(t=>t[e]==null||typeof t[e]==`number`))),v=t.map((e,t)=>({row:e,index:t})),y=q&&g.includes(q.column)?q:null,b=y?v.map(e=>({...e,key:(0,n.getSortValue)(e.row[y.column])})).sort((e,t)=>{if(e.key===null&&t.key===null)return 0;if(e.key===null)return 1;if(t.key===null)return-1;let r=(0,n.compareSortValues)(e.key,t.key);return y.dir===`asc`?r:-r}):[...v].sort((e,t)=>{for(let r of u){let i=+((0,n.getSortValue)(e.row[r])===null),a=+((0,n.getSortValue)(t.row[r])===null);if(i!==a)return i-a}return 0}),x=e=>_.has(e)?`desc`:`asc`,T=e=>ne(t=>{let n=x(e);return t?.column===e?t.dir===n?{column:e,dir:n===`asc`?`desc`:`asc`}:null:{column:e,dir:n}}),E=P?G.totals?.find(e=>Array.isArray(e.dimensions)&&e.dimensions.length===0)?.rows?.[0]:void 0,D=I(`dashboard.total`,`Total`),O=e=>{if(y?.column!==e)return(0,f.jsx)(o.ChevronsUpDown,{className:`ml-0.5 h-3 w-3 shrink-0 opacity-0 transition-opacity group-hover:opacity-50`,"aria-hidden":`true`});let t=y.dir===`asc`?o.ChevronUp:o.ChevronDown;return(0,f.jsx)(t,{className:`ml-0.5 h-3 w-3 shrink-0 text-primary`,"aria-hidden":`true`})};return(0,f.jsxs)(`div`,{className:`relative h-full w-full overflow-auto p-1`,children:[he,m(b.map(e=>e.row)),(0,f.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,f.jsx)(`thead`,{className:`bg-muted/40`,children:(0,f.jsx)(`tr`,{children:g.map(e=>{let t=_.has(e);return(0,f.jsx)(`th`,{scope:`col`,"aria-sort":y?.column===e?y.dir===`asc`?`ascending`:`descending`:`none`,className:(0,a.cn)(`group px-2 py-1.5 font-medium whitespace-nowrap`,t?`text-right`:`text-left`),"data-testid":r(e)?`dataset-compare-column`:void 0,children:(0,f.jsxs)(`button`,{type:`button`,onClick:()=>T(e),"data-testid":`dataset-table-sort`,className:(0,a.cn)(`inline-flex w-full select-none items-center font-medium transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,t?`justify-end`:`justify-between`),children:[(0,f.jsx)(`span`,{className:`truncate`,children:i(e)}),O(e)]})},e)})})}),(0,f.jsx)(`tbody`,{children:b.map(({row:e,index:t})=>(0,f.jsx)(`tr`,{className:(0,a.cn)(`border-t transition-colors hover:bg-muted/40`,Te&&`cursor-pointer hover:bg-accent/40`),"data-testid":Te?`dataset-drill-row`:void 0,onClick:Te?()=>Ee(t,we.map(t=>(0,n.formatDimensionValue)(e[t],z)).filter(Boolean).join(` / `)):void 0,children:g.map(t=>{let i=r(t)??(d.includes(t)?t:void 0);return(0,f.jsx)(`td`,{className:(0,a.cn)(`px-2 py-1 whitespace-nowrap tabular-nums`,_.has(t)&&`text-right`),children:i?(0,n.formatMeasure)(e[t],Q(i)?.format,Q(i)?.currency,Q(i)?.percentScale,z):(0,n.formatDimensionValue)(e[t],z)},t)})},t))}),E&&(0,f.jsx)(`tfoot`,{className:`bg-muted/30`,children:(0,f.jsxs)(`tr`,{className:`border-t font-medium`,"data-testid":`dataset-table-total-row`,children:[(0,f.jsx)(`td`,{colSpan:u.length,className:`px-2 py-1 whitespace-nowrap`,children:D}),s.map(e=>{let t=r(e)??e;return(0,f.jsx)(`td`,{className:(0,a.cn)(`px-2 py-1 whitespace-nowrap tabular-nums`,_.has(e)&&`text-right`),children:(0,n.formatMeasure)(E[e],Q(t)?.format,Q(t)?.currency,Q(t)?.percentScale,z)},e)})]})})]}),De]})}let $=(0,n.relabelDimensions)(G.rows,fe),Oe=I(`chart.nullCategory`,`(None)`),ke=u.length===0,Ae=I(`dashboard.total`,`Total`),je=new Set(d.map(e=>Q(e)?.aggregate)),[Me]=je,Ne={dataKey:Ze,label:Ae,...je.size===1&&typeof Me==`string`?{aggregate:Me}:{}},Le=ke||O?null:(0,n.buildCategoryRank)(Z),Re=Le?[...$].sort((e,t)=>Qe(e[u[0]],Le)-Qe(t[u[0]],Le)):$,{data:We,xAxisKey:Ge,series:tt}=ke?{data:d.map(e=>({[Xe]:ge(e),[Ze]:G.rows[0]?.[e],..._e.includes(e)?{[Ve(Ze)]:G.rows[0]?.[Ve(e)]}:{}})),xAxisKey:Xe,series:[Ne]}:(0,n.buildChartSeries)(Re,u,d,G.fields,{nullCategoryLabel:Oe,builtinAggregateLabels:(0,i.builtinAggregateLabels)(I)}),nt=u.length>=2&&d.length===1&&!O?(0,n.buildCategoryRank)(pe):null,rt=nt?[...tt].sort((e,t)=>Qe(e.label,nt,Oe)-Qe(t.label,nt,Oe)):tt,it=u.length>=2&&d.length===1,at=ke?_e.length>0?[Ne]:[]:_e.map(e=>{let t=Q(e)?.aggregate;return{dataKey:e,label:ge(e),...typeof t==`string`?{aggregate:t}:{}}}),ot=it?[]:at.map(({dataKey:e,label:t,aggregate:n})=>({dataKey:Ve(e),label:`${t} · ${ye}`,variant:`comparison`,...n===void 0?{}:{aggregate:n}})),st=ot.length>0?[...rt.map(e=>({...e,variant:`current`})),...ot]:rt,ct=(Array.isArray(T.stageOrder)?T.stageOrder:void 0)?.flatMap(e=>{let t=String(e),n=fe?.[u[0]]?.[t];return n&&n!==t?[t,n]:[t]}),lt=ct?.length?ct:Z,ut=(0,n.chartConfigPresentation)(e?.chartConfig,X),dt=Te?e=>{let t=(0,n.findChartSeriesRow)($,u,d,e?.category,e?.series,{nullCategoryLabel:Oe,bucketId:e?.categoryId});if(t<0)return;let r=u.length>=2&&d.length===1,i=e?.seriesLabel??e?.series,a=[e?.category,r?i:void 0].filter(Boolean).map(String).join(` / `);Ee(t,a)}:void 0;return(0,f.jsxs)(`div`,{className:(0,a.cn)(`relative h-full w-full min-h-[220px]`),children:[he,(0,f.jsx)(r.SchemaRenderer,{schema:{type:`chart`,chartType:_,data:We,xAxisKey:Ge,series:st,isAnimationActive:!1,...ut,...lt?{categoryOrder:lt}:{}},onChartClick:dt,onSegmentClick:dt}),De]})}function nt(e,t){e&&(t(!0),e(),setTimeout(()=>t(!1),600))}function rt(e,n){let[r,i]=t.useState(!1),a=t.useRef(n);t.useEffect(()=>{a.current=n});let o=t.useCallback(()=>{nt(a.current,i)},[]),s=e.refreshIntervalSeconds,c=!!n;return t.useEffect(()=>{if(!s||s<=0||!c)return;let e=setInterval(()=>nt(a.current,i),s*1e3);return()=>clearInterval(e)},[s,c]),{refreshing:r,handleRefresh:o}}function it(e){let{language:t}=(0,i.useObjectTranslation)(),{fieldLabel:n}=(0,i.useSafeFieldLabel)(),r=(0,i.pickLocalized)(e.label,t);return e.object?n(e.object,e.field,r):r}var at=`__all__`,ot=`__custom__`;function st(e,t){if(e){if(e.preset)return t(e.preset);if(e.from||e.to)return`${e.from??`…`} – ${e.to??`…`}`}}function ct(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function lt(){let[e,n]=(0,t.useState)(!1),[r,i]=(0,t.useState)(!1),a=(0,t.useRef)(null),o=(0,t.useRef)(!1),s=(0,t.useRef)(!1),c=(0,t.useRef)(!1),l=()=>{o.current=!0,queueMicrotask(()=>{o.current=!1})};return{select:{open:r,onOpenChange:e=>{!e&&o.current&&(s.current=!0),i(e)}},selectTrigger:{ref:a},selectContent:{onCloseAutoFocus:e=>{s.current&&(s.current=!1,e.preventDefault(),n(!0))}},customItem:{onPointerUp:l,onClick:l,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&l()}},onCustomValue:()=>{r||n(!0)},popover:{open:e,onOpenChange:n},popoverContent:{onInteractOutside:()=>{c.current=!0},onCloseAutoFocus:e=>{e.preventDefault(),c.current||a.current?.focus(),c.current=!1}}}}function ut({def:e,value:t,onChange:r}){let s=(0,i.useSafeTranslate)(),c=it(e),l=lt(),u=e.allowCustomRange!==!1,d=e=>s(`dashboard.filters.range.${e}`,e.replace(/_/g,` `)),p=t?.preset??(t?.from||t?.to?ot:at),m=t?.from&&!t.from.startsWith(`{`)?(0,n.toDisplayDate)(t.from):void 0,h=t?.to&&!t.to.startsWith(`{`)?(0,n.toDisplayDate)(t.to):void 0,g=m&&!Number.isNaN(m.getTime())?m:void 0;return(0,f.jsxs)(`div`,{className:`flex items-center gap-1`,"data-testid":`dashboard-filter-${e.name}`,children:[(0,f.jsxs)(a.Select,{value:p,...l.select,onValueChange:e=>{e===at?r(void 0):e===ot?l.onCustomValue():r({preset:e})},children:[(0,f.jsxs)(a.SelectTrigger,{...l.selectTrigger,className:`h-8 w-auto min-w-36 gap-1`,"aria-label":c||s(`dashboard.filters.dateRange`,`Date range`),children:[(0,f.jsx)(o.CalendarIcon,{className:`size-3.5 opacity-60`}),(0,f.jsx)(a.SelectValue,{placeholder:s(`dashboard.filters.dateRange`,`Date range`),children:st(t,d)??s(`dashboard.filters.allTime`,`All time`)})]}),(0,f.jsxs)(a.SelectContent,{...l.selectContent,children:[(0,f.jsx)(a.SelectItem,{value:at,children:s(`dashboard.filters.allTime`,`All time`)}),n.DATE_RANGE_PRESETS.map(e=>(0,f.jsx)(a.SelectItem,{value:e,children:d(e)},e)),u&&(0,f.jsx)(a.SelectItem,{value:ot,...l.customItem,children:s(`dashboard.filters.custom`,`Custom…`)})]})]}),u&&(0,f.jsxs)(a.Popover,{...l.popover,children:[(0,f.jsx)(a.PopoverTrigger,{asChild:!0,children:(0,f.jsx)(`span`,{"aria-hidden":!0,className:`size-0`})}),(0,f.jsx)(a.PopoverContent,{...l.popoverContent,className:`w-auto p-0`,align:`start`,children:(0,f.jsx)(a.Calendar,{mode:`range`,numberOfMonths:2,defaultMonth:g,selected:{from:m,to:h},onSelect:e=>{if(!e?.from&&!e?.to){r(void 0);return}r({...e?.from?{from:ct(e.from)}:{},...e?.to?{to:ct(e.to)}:{}})}})})]})]})}function dt(e,t,n){let r=Array.isArray(t)&&t.length===e.length&&t.some(e=>e?.[n.valueField]!==void 0)?t:void 0,i=new Map;for(let t=0;t<e.length;t++){let a=e[t],o=r?r[t]?.[n.valueField]:a?.[n.valueField];if(o==null||o===``)continue;let s=String(o);if(i.has(s))continue;let c=n.labelField?a?.[n.labelField]:a?.[n.valueField];i.set(s,String(c??s))}return Array.from(i,([e,t])=>({value:e,label:t}))}function ft({def:e,value:n,onChange:o,dataSource:s}){let c=(0,i.useSafeTranslate)(),{language:l}=(0,i.useObjectTranslation)(),{translateOptions:u}=(0,i.useSafeFieldLabel)(),d=it(e),[p,m]=(0,t.useState)(null),h=e.optionsFrom,g=JSON.stringify(h?.filter??null),_=(0,r.useDataInvalidation)(h&&s&&(typeof s.queryDataset==`function`||typeof s.find==`function`)&&h.object||void 0);(0,t.useEffect)(()=>{if(!h||!s)return;let e=!1,t=()=>{if(typeof s.find!=`function`){e||m([]);return}s.find(h.object,{$select:[...new Set([h.valueField,...h.labelField?[h.labelField]:[]])],...h.filter?{$filter:h.filter}:{},$top:200}).then(t=>{if(e)return;let n=Array.isArray(t)?t:t?.data??[];m(dt(n,void 0,h))}).catch(()=>{e||m([])})};if(typeof s.queryDataset==`function`){let n=[{name:h.valueField,field:h.valueField}];h.labelField&&h.labelField!==h.valueField&&n.push({name:h.labelField,field:h.labelField}),s.queryDataset({name:`dashboard_filter_options`,label:`Dashboard filter options`,object:h.object,dimensions:n,measures:[{name:`option_count`,aggregate:`count`}]},{dimensions:n.map(e=>e.name),measures:[`option_count`],...h.filter?{runtimeFilter:h.filter}:{},order:{[h.valueField]:`asc`},limit:1e3}).then(t=>{if(e)return;let n=Array.isArray(t?.rows)?t.rows:[],r=Array.isArray(t?.drillRawRows)?t.drillRawRows:void 0;m(dt(n,r,h))}).catch(()=>{e||t()})}else t();return()=>{e=!0}},[h?.object,h?.valueField,h?.labelField,g,s,_]);let v=(0,t.useMemo)(()=>(e.options?.length?e.options:p??[]).map(e=>({value:e.value,label:(0,i.pickLocalized)(e.label,l)||e.value})),[e.options,p,l]),y=e.object?u(e.object,e.field,v):v,b=d||e.name,x=n?y.find(e=>e.value===String(n))?.label??String(n):void 0;return(0,f.jsxs)(a.Select,{value:n?String(n):at,onValueChange:e=>o(e===at?void 0:e),children:[(0,f.jsx)(a.SelectTrigger,{className:`h-8 w-auto min-w-32`,"aria-label":b,"data-testid":`dashboard-filter-${e.name}`,children:(0,f.jsx)(a.SelectValue,{children:x??`${b}: ${c(`dashboard.filters.all`,`All`)}`})}),(0,f.jsxs)(a.SelectContent,{children:[(0,f.jsx)(a.SelectItem,{value:at,children:c(`dashboard.filters.all`,`All`)}),y.map(e=>(0,f.jsx)(a.SelectItem,{value:e.value,children:e.label},e.value))]})]})}function pt({def:e,value:n,onChange:r}){let i=it(e)||e.name,[o,s]=(0,t.useState)(n==null?``:String(n));(0,t.useEffect)(()=>{s(n==null?``:String(n))},[n]);let c=()=>{let t=o.trim();if(t===``){r(void 0);return}r(e.type===`number`?Number(t):t)};return(0,f.jsx)(a.Input,{className:`h-8 w-36`,type:e.type===`number`?`number`:`text`,placeholder:i,value:o,onChange:e=>s(e.target.value),onBlur:c,onKeyDown:e=>{e.key===`Enter`&&c()},"aria-label":i,"data-testid":`dashboard-filter-${e.name}`})}function mt({defs:e,values:t,onChange:n,onReset:r,dataSource:s,className:c}){let l=(0,i.useSafeTranslate)();if(e.length===0)return null;let u=e=>e==null||e===``||typeof e==`object`&&Object.keys(e).length===0,d=e.some(e=>{let n=t[e.name],r=e.defaultValue;return u(n)&&u(r)?!1:JSON.stringify(n??null)!==JSON.stringify(r??null)});return(0,f.jsxs)(`div`,{className:(0,a.cn)(`col-span-full flex flex-wrap items-center gap-2`,c),"data-testid":`dashboard-filter-bar`,role:`group`,"aria-label":l(`dashboard.filters.label`,`Dashboard filters`),children:[e.map(e=>{let r=t[e.name],i=t=>n(e.name,t);return e.type===`dateRange`||e.type===`date`?(0,f.jsx)(ut,{def:e,value:r,onChange:i},e.name):e.type===`select`||e.type===`lookup`?(0,f.jsx)(ft,{def:e,value:r,onChange:i,dataSource:s},e.name):(0,f.jsx)(pt,{def:e,value:r,onChange:i},e.name)}),r&&d&&(0,f.jsxs)(a.Button,{variant:`ghost`,size:`sm`,onClick:r,className:`text-muted-foreground`,children:[(0,f.jsx)(o.RotateCcw,{className:`size-3.5`}),l(`dashboard.filters.reset`,`Reset`)]})]})}function ht({id:e,disabled:t,gridSpan:n,className:r,children:i}){let{attributes:o,listeners:s,setNodeRef:u,transform:d,transition:p,isDragging:m,isOver:h}=(0,c.useSortable)({id:e,disabled:t}),g={transform:l.CSS.Transform.toString(d),transition:p,opacity:m?.4:1,...n?{gridColumn:`span ${n.w}`,gridRow:`span ${n.h}`}:{}};return(0,f.jsx)(`div`,{ref:u,style:g,className:(0,a.cn)(`h-full w-full`,r,!t&&`cursor-grab active:cursor-grabbing`,h&&!m&&`ring-2 ring-primary ring-offset-2 rounded-lg`),"data-sortable-widget-id":e,...o,...s,children:i})}function gt(e){return e?(0,a.getLazyIcon)(e):null}var _t=[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`],vt=new Set([`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`funnel`,`scatter`,`treemap`,`sankey`]);function yt(e){return vt.has(e)?{enabled:!0}:void 0}var bt=new Set([`object-chart`,`object-data-table`]);function xt(e){return bt.has(e.type)}var St=(0,t.forwardRef)(({schema:e,className:l,dataSource:u,onRefresh:d,recordCount:p,userActions:m,designMode:h,selectedWidgetId:g,onWidgetClick:_,onWidgetsReorder:v,modalHandler:y,scriptHandlers:b,hideHeaderText:x,onRefreshStateChange:S,localized:C,...w},T)=>{let D=(0,r.useResolvedDataSource)(u),A=(()=>{if(e.columns!=null)return e.columns;let t=e.widgets??[],n=0;for(let e of t){let t=(e.layout?.x??0)+(e.layout?.w??0);t>n&&(n=t),(e.layout?.w??0)>n&&(n=e.layout.w)}return n>4?12:4})(),j=A,M=e.gap||4,N=e.columns!=null||A!==4,[R,z]=(0,t.useState)(!1),B=(0,t.useMemo)(()=>(0,n.resolveDashboardFilterDefs)(e),[e.globalFilters,e.dateRange]),{variables:H,setVariable:U,resetVariables:K}=(0,r.usePageVariables)(),{dashboardLabel:ie,dashboardDescription:ae,dashboardActionLabel:oe,widgetTitle:se,widgetDescription:ce,fieldLabel:le}=(0,r.useObjectLabel)(),{t:J,language:Y}=(0,i.useObjectTranslation)(),ue=(0,i.useSafeTranslate)(),de=(0,i.useDisplayLocale)(),X=(0,t.useCallback)(e=>{if(e!=null)return(0,i.pickLocalized)(e,Y)||void 0},[Y]),fe=(0,t.useCallback)((e,t,n)=>O(J,le,e,t,n),[J,le]),Z=e.name,pe=(0,t.useCallback)(e=>{let t=(0,i.pickLocalized)(e.label,Y)||``;if(!Z)return t;let n=e.actionUrl||t;return oe(Z,n,t)},[Z,oe,Y]),me=(0,t.useMemo)(()=>(e.header?.actions??[]).map(e=>{let t=(0,i.pickLocalized)(e.label,Y)||void 0,n=e.actionType||`url`;return{name:e.actionUrl||t,type:n,target:e.actionUrl,label:t,...n===`url`?{toast:{showOnSuccess:!1}}:{}}}),[e.header?.actions,Y]),{executeAction:he,engine:Q}=(0,r.useActionEngine)({actions:me}),ge=(0,t.useCallback)(e=>{let t=X(e.title);return C||!Z||!e.id||t===void 0?t:se(Z,e.id,t)},[C,Z,se,X]),_e=(0,t.useCallback)(e=>{let t=X(e.description);return C||!Z||!e.id?t:ce(Z,e.id,t)},[C,Z,ce,X]);(0,t.useEffect)(()=>{let e=Q.getRunner();if(y&&e.setModalHandler(y),b)for(let[t,n]of Object.entries(b))e.registerScript(t,n)},[Q,y,b]),(0,t.useEffect)(()=>{let e=()=>z(window.innerWidth<768);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let{refreshing:ve,handleRefresh:ye}=rt(e,d),be=!!S,xe=!!d,Se=(0,t.useRef)(S),Ce=(0,t.useRef)(ye);(0,t.useLayoutEffect)(()=>{Se.current=S,Ce.current=ye}),(0,t.useLayoutEffect)(()=>{be&&Se.current?.(xe?{refreshing:ve,handleRefresh:()=>Ce.current()}:null)},[be,xe,ve]),(0,t.useLayoutEffect)(()=>()=>Se.current?.(null),[]);let we=(0,t.useCallback)((e,t)=>{h&&_&&t&&(e.stopPropagation(),_(t))},[h,_]),Te=(0,t.useCallback)((t,n,r)=>{if(!h||!_)return;let i=e.widgets||[];if(t.key===`Enter`||t.key===` `)t.preventDefault(),_(n??null);else if(t.key===`ArrowRight`||t.key===`ArrowDown`){t.preventDefault();let e=r+1<i.length?i[r+1]:null;e?.id&&_(e.id)}else if(t.key===`ArrowLeft`||t.key===`ArrowUp`){t.preventDefault();let e=r-1>=0?i[r-1]:null;e?.id&&_(e.id)}else t.key===`Escape`&&(t.preventDefault(),_(null))},[h,_,e.widgets]),Ee=(0,t.useCallback)(e=>{h&&_&&e.target===e.currentTarget&&_(null)},[h,_]),De=e=>{Ee(e),typeof w.onClick==`function`&&w.onClick(e)},$=!!(h&&v),Oe=(0,s.useSensors)((0,s.useSensor)(s.PointerSensor,{activationConstraint:{distance:5}})),ke=(0,t.useCallback)(t=>{if(!$)return;let{active:n,over:r}=t;if(!r||n.id===r.id)return;let i=e.widgets??[],a=i.findIndex(e=>e.id===n.id),o=i.findIndex(e=>e.id===r.id);a<0||o<0||v?.((0,c.arrayMove)(i,a,o))},[$,e.widgets,v]),Ae=(e,i,o)=>{let s=P(e),c=s===`metric`||V.has(s||``),l=N?{w:Math.min(c?3:6,j),h:c?1:4}:void 0,u=e.layout??l,d=u?{...u,w:Math.min(u.w,j)}:void 0,p=I(e)?void 0:e,m=!!p?.dataset,_=()=>{if(I(e))return te({...e});let t=F(e);if(re(t))return q;if(t)return te(t);let r=s,i=e.options||{},a=e.data||i.data;if(ne(e))return q;let o=W(r);if(o.family===`series`&&o.chartType){let t=i.xField||`name`,r=i.yField||`value`,s=(0,n.chartConfigPresentation)(e.chartConfig);if(E(a)){let c=a.aggregate,l=c?{field:c.field,function:c.function,groupBy:c.groupBy}:void 0,u=(0,n.chartMeasureKey)(l,r),d=(0,n.chartCategoryKey)(l,t);return{type:`object-chart`,chartType:o.chartType,objectName:a.object,aggregate:l,filter:a.filter||e.filter,xAxisKey:d,series:[{dataKey:u,label:fe(a.object,u,l?.function)}],colors:_t,isAnimationActive:!1,drillDown:i.drillDown??yt(o.chartType),compareTo:e.compareTo,className:`h-[200px] sm:h-[250px] md:h-[300px]`,...s}}let c=Array.isArray(a)?a:a?.items||[];return{type:`chart`,chartType:o.chartType,data:c,xAxisKey:t,series:[{dataKey:r,label:fe(void 0,r,void 0)}],colors:_t,isAnimationActive:!1,className:`h-[200px] sm:h-[250px] md:h-[300px]`,...s}}if(o.family===`metric`&&r!==void 0){if(E(a))return q;let t=ge(e)||r,n=Array.isArray(a)?a:a?.items||[],o=i.yField||`value`;return{type:G.metric,...ee(i),label:t,value:i.value??n[0]?.[o]??`—`}}if(o.family===`table`){let t=r===`list`;if(E(a)){let{data:n,...r}=i;return{type:`object-data-table`,...r,objectName:a.object,filter:a.filter||e.filter,searchable:t?!1:e.searchable??!1,pagination:t?!1:e.pagination??!1,drillDown:i.drillDown??{enabled:!0,mode:`record`},className:`border-0`}}let n=Array.isArray(a)?a:a?.items||[];return{type:`data-table`,...i,data:n,columns:Array.isArray(i.columns)&&i.columns.length>0?i.columns:k(n),searchable:!1,pagination:!1,className:`border-0`}}return o.family===`pivot`?q:(o.family,L(r))},v=p&&B.length>0?(0,n.buildWidgetScopedFilter)(p,B,H):void 0,y=(()=>{let e=_();return v&&e&&typeof e==`object`&&xt(e)?{...e,filter:(0,n.mergeFilters)(e.filter,v)}:e})(),b=p&&m?v?{...p,filter:(0,n.mergeFilters)(p.filter,v)}:p:void 0,x=s===`metric`&&!m,S=m&&s===`metric`,C=ge(e),w=_e(e),T=e.id||C||`widget-${i}`,O=h&&g===e.id,A=h?{"data-testid":`dashboard-preview-widget-${e.id}`,"data-widget-id":e.id,role:`button`,tabIndex:0,"aria-selected":O,"aria-label":`Widget: ${C||`Widget ${i+1}`}`,onClick:t=>we(t,e.id),onKeyDown:t=>Te(t,e.id,i)}:{},M=h?(0,a.cn)(`cursor-pointer rounded-lg transition-all outline-none`,`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,O?`ring-2 ring-primary shadow-md bg-primary/5 dark:bg-primary/10`:`hover:ring-2 hover:ring-primary/40 hover:shadow-sm`):void 0,z=!R&&d&&!$?{gridColumn:`span ${d.w}`,gridRow:`span ${d.h}`}:void 0,U=x?(0,f.jsxs)(`div`,{className:(0,a.cn)(`h-full w-full`,h&&`relative`,M),style:z,...A,children:[(0,f.jsx)(r.SchemaRenderer,{schema:y,className:(0,a.cn)(`h-full w-full`,h&&`pointer-events-none`),dataSource:D}),h&&(0,f.jsx)(`div`,{className:`absolute inset-0 z-10`,"aria-hidden":`true`,"data-testid":`widget-click-overlay`})]}):(0,f.jsxs)(a.Card,{className:(0,a.cn)(`overflow-hidden border-border/50 shadow-sm transition-all hover:shadow-md`,`bg-card/50 backdrop-blur-sm`,o&&`w-full`,h&&`relative`,M),style:z,...A,children:[C&&!S&&(0,f.jsxs)(a.CardHeader,{className:`pb-2 border-b border-border/40 bg-muted/20 px-3 sm:px-6`,children:[(0,f.jsx)(a.CardTitle,{className:`text-sm sm:text-base font-medium tracking-tight truncate`,title:C,children:C}),w&&(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 line-clamp-2`,children:w})]}),(0,f.jsx)(a.CardContent,{className:`p-0`,children:(0,f.jsx)(`div`,{className:(0,a.cn)(`h-full w-full`,S?`p-3 sm:p-4`:`p-3 sm:p-4 md:p-6`,h&&`pointer-events-none`),children:b?(0,f.jsx)(tt,{widget:b,dataSource:D,heading:S?{title:C||``,description:w||void 0}:void 0}):(0,f.jsx)(r.SchemaRenderer,{schema:y,dataSource:D})})}),h&&(0,f.jsx)(`div`,{className:`absolute inset-0 z-10`,"aria-hidden":`true`,"data-testid":`widget-click-overlay`})]});return $&&e.id?(0,f.jsx)(ht,{id:e.id,gridSpan:!R&&d?{w:d.w,h:d.h}:void 0,children:U},T):(0,f.jsx)(t.Fragment,{children:U},T)},je=e.label,Me=p!==void 0&&(0,f.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[p.toLocaleString(de),` records`]}),Ne=d&&!be&&(0,f.jsxs)(a.Button,{variant:`outline`,size:`sm`,onClick:ye,disabled:ve,"aria-label":ue(`dashboard.refreshDashboard`,`Refresh dashboard`),children:[(0,f.jsx)(o.RefreshCw,{className:(0,a.cn)(`h-4 w-4 mr-2`,ve&&`animate-spin`)}),ve?ue(`dashboard.refreshing`,`Refreshing…`):ue(`dashboard.refreshAll`,`Refresh All`)]}),Pe=d&&(Ne||Me)&&(0,f.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-3`,children:[Me,Ne]}),Fe=!!Pe&&B.length===0,Ie=e.header,Le=!x&&Ie?.showTitle!==!1&&!!je,Re=!x&&Ie?.showDescription!==!1&&!!e.description,ze=Ie?.actions??[],Be=Ie&&(Le||Re||ze.length>0)&&(0,f.jsxs)(`div`,{className:(0,a.cn)(`col-span-full mb-4`,Fe&&`flex items-start justify-between gap-3`),children:[(0,f.jsxs)(`div`,{className:`min-w-0`,children:[Le&&(0,f.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:Z&&!C?ie({name:Z,label:X(je)}):X(je)}),Re&&(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:Z&&!C?ae({name:Z,description:X(e.description)}):X(e.description)}),ze.length>0&&(0,f.jsx)(`div`,{className:`flex gap-2 mt-3`,children:ze.map((e,t)=>{let n=gt(e.icon);return(0,f.jsxs)(a.Button,{variant:`outline`,size:`sm`,onClick:async()=>{let n=await he(e.actionUrl);if(!n?.success){console.warn(`[DashboardRenderer] action failed`,n?.error);return}n.redirect&&me[t]?.type===`url`&&(window.history.pushState({},``,n.redirect),window.dispatchEvent(new PopStateEvent(`popstate`)))},children:[n&&(0,f.jsx)(n,{className:`w-4 h-4 mr-1.5`}),pe(e)]},t)})})]}),Fe&&Pe]}),Ve=B.length>0&&(0,f.jsx)(mt,{defs:B,values:H,onChange:U,onReset:K,dataSource:D,className:Pe?`min-w-0 grow`:void 0}),He=Ve?Pe?(0,f.jsxs)(`div`,{className:`col-span-full flex flex-wrap items-center gap-2`,children:[Ve,Pe]}):Ve:Pe&&!Be&&(0,f.jsx)(`div`,{className:`col-span-full flex`,children:Pe}),Ue=+!!Be+ +!!He,We=m?JSON.stringify(m):void 0,Ge=(0,n.toDomProps)(w),Ke=(0,t.useMemo)(()=>(e.widgets??[]).map(e=>e.id).filter(e=>!!e),[e.widgets]),qe=(0,t.useMemo)(()=>(e.widgets??[]).filter(e=>P(e)===`metric`).map(e=>e.id).filter(e=>!!e),[e.widgets]),Je=(0,t.useMemo)(()=>(e.widgets??[]).filter(e=>P(e)!==`metric`).map(e=>e.id).filter(e=>!!e),[e.widgets]);if(R){let t=e.widgets?.filter(e=>P(e)===`metric`)||[],n=e.widgets?.filter(e=>P(e)!==`metric`)||[],r=(0,f.jsxs)(`div`,{ref:T,...Ge,className:(0,a.cn)(`flex flex-col gap-4 px-4`,l),"data-user-actions":We,onClick:De,children:[Be,He,t.length>0&&(0,f.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,onClick:Ee,children:(0,f.jsx)(c.SortableContext,{items:qe,strategy:c.rectSortingStrategy,disabled:!$,children:t.map((e,t)=>Ae(e,t))})}),n.length>0&&(0,f.jsx)(`div`,{className:`flex flex-col gap-4`,onClick:Ee,children:(0,f.jsx)(c.SortableContext,{items:Je,strategy:c.verticalListSortingStrategy,disabled:!$,children:n.map((e,t)=>Ae(e,t,!0))})})]});return $?(0,f.jsx)(s.DndContext,{sensors:Oe,collisionDetection:s.closestCenter,onDragEnd:ke,children:r}):r}let Ye=(0,f.jsxs)(`div`,{ref:T,...Ge,className:(0,a.cn)(`grid`,!N&&`auto-rows-min grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4`,N&&Ue===1&&`grid-rows-[auto]`,N&&Ue===2&&`grid-rows-[auto_auto]`,l),style:{...N&&{gridTemplateColumns:`repeat(${j}, minmax(0, 1fr))`,gridAutoRows:`minmax(5rem, auto)`},gap:`${M*.25}rem`},"data-user-actions":We,onClick:De,children:[Be,He,(0,f.jsx)(c.SortableContext,{items:Ke,strategy:c.rectSortingStrategy,disabled:!$,children:e.widgets?.map((e,t)=>Ae(e,t))})]});return $?(0,f.jsx)(s.DndContext,{sensors:Oe,collisionDetection:s.closestCenter,onDragEnd:ke,children:Ye}):Ye});St.displayName=`DashboardRendererInner`;var Ct=(0,t.forwardRef)((e,i)=>{let{schema:a}=e,o=(0,t.useMemo)(()=>(0,n.resolveDashboardFilterDefs)(a),[a.globalFilters,a.dateRange]);return o.length===0?(0,f.jsx)(St,{ref:i,...e}):(0,f.jsx)(r.PageVariablesProvider,{definitions:(0,n.dashboardFilterVariableDefs)(o),children:(0,f.jsx)(St,{ref:i,...e})})});Ct.displayName=`DashboardRenderer`;function wt({editMode:e}){let n=(0,r.useDnd)();return t.useEffect(()=>{if(e)return n.startDrag({id:`dashboard-layout`,type:`dashboard-widget`,data:{}}),()=>{n.endDrag()};n.endDrag(`dashboard`)},[e,n]),null}var Tt=[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`];function Et(e,t){if(!e.widgets?.length)return e;let n=new Map(t.map(e=>[e.i,e])),r=e.widgets.map((e,t)=>{let r=e.id||`widget-${t}`,i=n.get(r);return i?{...e,layout:{x:i.x,y:i.y,w:i.w,h:i.h}}:e});return{...e,widgets:r}}function Dt(e){return{lg:e.widgets?.map((e,t)=>({i:e.id||`widget-${t}`,...(0,u.completeWidgetLayout)(e.layout,{},(0,u.defaultWidgetPlacement)(t))}))||[]}}var Ot=({schema:e,className:s,dataSource:c,onLayoutChange:l,onSchemaChange:u,onRefresh:d})=>{let{width:p,containerRef:m,mounted:g}=(0,h.useContainerWidth)(),[_,v]=t.useState(!1),y=(0,r.useHasDndProvider)(),{t:b,language:x}=(0,i.useObjectTranslation)(),S=(0,i.useSafeTranslate)(),{fieldLabel:C}=(0,i.useObjectLabel)(),w=t.useCallback((e,t,n)=>O(b,C,e,t,n),[b,C]),{refreshing:T,handleRefresh:D}=rt(e,d),[A,j]=t.useState(()=>Dt(e)),M=t.useMemo(()=>JSON.stringify(e.widgets?.map((e,t)=>({i:e.id||`widget-${t}`,x:e.layout?.x,y:e.layout?.y,w:e.layout?.w,h:e.layout?.h}))??[]),[e.widgets]);t.useEffect(()=>{j(Dt(e))},[M]);let N=t.useCallback((e,t)=>{j(t),l?.(e)},[l]),R=t.useCallback(()=>{u?u(Et(e,A.lg)):globalThis.process?.env?.NODE_ENV!==`production`&&console.warn("[DashboardGridLayout] Layout edits are in-memory only. Wire `onSchemaChange` to persist via your data adapter."),v(!1)},[u,e,A]),z=t.useCallback(()=>{j(Dt(e))},[e]),B=t.useCallback(e=>{if(I(e))return te({...e});let t=F(e);if(re(t))return q;if(t)return te(t);if(ne(e))return q;let r=P(e),i=e.options||{},a=W(r);if(a.family===`series`&&a.chartType){let t=e.data||i.data,r=i.xField||`name`,o=i.yField||`value`,s=(0,n.chartConfigPresentation)(e.chartConfig);if(E(t)){let e=t.aggregate,i=e?{field:e.field,function:e.function,groupBy:e.groupBy}:void 0,c=(0,n.chartMeasureKey)(i,o),l=(0,n.chartCategoryKey)(i,r);return{type:`object-chart`,chartType:a.chartType,objectName:t.object,aggregate:i,xAxisKey:l,series:[{dataKey:c,label:w(t.object,c,i?.function)}],colors:Tt,isAnimationActive:!1,className:`h-full`,...s}}let c=Array.isArray(t)?t:t?.items||[];return{type:`chart`,chartType:a.chartType,data:c,xAxisKey:r,series:[{dataKey:o,label:w(void 0,o,void 0)}],colors:Tt,isAnimationActive:!1,className:`h-full`,...s}}if(a.family===`metric`&&r!==void 0){let t=e.data||i.data;if(E(t))return q;let n=e.title||r,a=Array.isArray(t)?t:t?.items||[],o=i.yField||`value`;return{type:G.metric,...ee(i),label:n,value:i.value??a[0]?.[o]??`—`}}if(a.family===`table`){let t=e.data||i.data;if(E(t)){let n=r===`list`,{data:a,...o}=i;return{type:`object-data-table`,...o,objectName:t.object,filter:t.filter||e.filter,searchable:n?!1:e.searchable??!1,pagination:n?!1:e.pagination??!1,drillDown:i.drillDown??{enabled:!0,mode:`record`},className:`border-0`}}let n=Array.isArray(t)?t:t?.items||[];return{type:`data-table`,...i,data:n,columns:Array.isArray(i.columns)&&i.columns.length>0?i.columns:k(n),searchable:!1,pagination:!1,className:`border-0`}}if(a.family===`pivot`){let t=e.data||i.data;return E(t)?q:{type:`pivot`,title:i.title,rowField:i.rowField,columnField:i.columnField,valueField:i.valueField,aggregation:i.aggregation,showRowTotals:i.showRowTotals,showColumnTotals:i.showColumnTotals,format:i.format,columnColors:i.columnColors,className:i.className,data:Array.isArray(t)?t:t?.items||[]}}return a.family,L(r)},[w]);return(0,f.jsxs)(`div`,{ref:m,className:(0,a.cn)(`w-full`,s),"data-testid":`grid-layout`,children:[y&&(0,f.jsx)(wt,{editMode:_}),(0,f.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,f.jsx)(`h2`,{className:`text-2xl font-bold`,children:(0,i.pickLocalized)(e.label,x)||`Dashboard`}),(0,f.jsx)(`div`,{className:`flex gap-2`,children:_?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(a.Button,{onClick:R,size:`sm`,variant:`default`,children:[(0,f.jsx)(o.Save,{className:`h-4 w-4 mr-2`}),`Save Layout`]}),(0,f.jsxs)(a.Button,{onClick:z,size:`sm`,variant:`outline`,children:[(0,f.jsx)(o.X,{className:`h-4 w-4 mr-2`}),`Reset`]}),(0,f.jsx)(a.Button,{onClick:()=>v(!1),size:`sm`,variant:`ghost`,children:`Cancel`})]}):(0,f.jsxs)(f.Fragment,{children:[d&&(0,f.jsxs)(a.Button,{onClick:D,size:`sm`,variant:`outline`,disabled:T,"aria-label":S(`dashboard.refreshDashboard`,`Refresh dashboard`),children:[(0,f.jsx)(o.RefreshCw,{className:(0,a.cn)(`h-4 w-4 mr-2`,T&&`animate-spin`)}),T?S(`dashboard.refreshing`,`Refreshing…`):S(`dashboard.refreshAll`,`Refresh All`)]}),(0,f.jsxs)(a.Button,{onClick:()=>v(!0),size:`sm`,variant:`outline`,children:[(0,f.jsx)(o.Edit,{className:`h-4 w-4 mr-2`}),`Edit Layout`]})]})})]}),g&&(0,f.jsx)(h.ResponsiveGridLayout,{className:`layout`,width:p,layouts:A,breakpoints:{lg:1200,md:996,sm:768,xs:480,xxs:0},cols:{lg:12,md:10,sm:6,xs:4,xxs:2},rowHeight:60,dragConfig:{enabled:_,handle:`.drag-handle`},resizeConfig:{enabled:_},onLayoutChange:N,children:e.widgets?.map((e,t)=>{let n=e.id||`widget-${t}`,s=B(e),l=!I(e)&&e.dataset?e:void 0,u=l!==void 0,d=P(e)===`metric`&&!u,p=u&&P(e)===`metric`,m=(0,i.pickLocalized)(e.title,x);return(0,f.jsx)(`div`,{className:`h-full`,children:d?(0,f.jsxs)(`div`,{className:`h-full w-full relative`,children:[_&&(0,f.jsx)(`div`,{className:`drag-handle absolute top-2 right-2 z-10 cursor-move p-1 bg-background/80 rounded border border-border`,children:(0,f.jsx)(o.GripVertical,{className:`h-4 w-4`})}),(0,f.jsx)(r.SchemaRenderer,{schema:s,className:`h-full w-full`})]}):(0,f.jsxs)(a.Card,{className:(0,a.cn)(`h-full overflow-hidden border-border/50 shadow-sm transition-all`,`bg-card/50 backdrop-blur-sm`,_&&`ring-2 ring-primary/20`,p&&`relative`),children:[p&&_&&(0,f.jsx)(`div`,{className:`drag-handle absolute top-2 right-2 z-10 cursor-move p-1 bg-background/80 rounded border border-border`,children:(0,f.jsx)(o.GripVertical,{className:`h-4 w-4`})}),m&&!p&&(0,f.jsxs)(a.CardHeader,{className:`pb-2 border-b border-border/40 bg-muted/20 flex flex-row items-center justify-between`,children:[(0,f.jsx)(a.CardTitle,{className:`text-base font-medium tracking-tight truncate`,title:m,children:m}),_&&(0,f.jsx)(`div`,{className:`drag-handle cursor-move p-1 hover:bg-muted/40 rounded`,children:(0,f.jsx)(o.GripVertical,{className:`h-4 w-4`})})]}),(0,f.jsx)(a.CardContent,{className:`p-0 h-full`,children:(0,f.jsx)(`div`,{className:(0,a.cn)(`h-full w-full overflow-auto p-4`,p&&_&&`pr-10`),children:l?(0,f.jsx)(tt,{widget:l,dataSource:c,heading:p?{title:m,description:(0,i.pickLocalized)(l.description,x)||void 0}:void 0}):(0,f.jsx)(r.SchemaRenderer,{schema:s})})})]})},n)})})]})};function kt(e,t){return e===void 0?t:(0,n.toDomProps)(t)}var At=(0,i.createSafeTranslation)({"dashboard.trend.vsLastQuarter":`vs last quarter`,"dashboard.trend.vsLastMonth":`vs last month`,"dashboard.trend.vsLastWeek":`vs last week`,"dashboard.trend.vsLastYear":`vs last year`,"dashboard.trend.vsYesterday":`vs yesterday`,"dashboard.trend.vsPreviousPeriod":`vs previous period`},`dashboard.trend.vsLastQuarter`);function jt(e){switch(e.trim().toLowerCase().replace(/\s+/g,` `)){case`vs last quarter`:case`vs previous quarter`:return`dashboard.trend.vsLastQuarter`;case`vs last month`:case`vs previous month`:return`dashboard.trend.vsLastMonth`;case`vs last week`:case`vs previous week`:return`dashboard.trend.vsLastWeek`;case`vs last year`:case`vs previous year`:return`dashboard.trend.vsLastYear`;case`vs yesterday`:return`dashboard.trend.vsYesterday`;case`vs previous period`:case`vs prior period`:return`dashboard.trend.vsPreviousPeriod`;default:return}}function Mt(e){let t=(e||``).trim().match(/0\.(0+)/);return t?t[1].length:0}function Nt(e,t,n,r){if(e==null)return``;if(typeof e==`string`){let i=Number(e);return!isFinite(i)||e.trim()===``?e:Nt(i,t,n,r)}if(!isFinite(e))return String(e);let a={$:`USD`,"¥":`JPY`,"€":`EUR`,"£":`GBP`},o=(t||``).trim(),s=!!n||o.length>0&&a[o[0]]!==void 0,c=o.endsWith(`%`),l=Mt(o);if(/a/i.test(o)){let t={locale:r,notation:`compact`,maximumFractionDigits:l||1};s&&(t.currency=n||a[o[0]]||`USD`);try{return(0,i.formatDisplayNumber)(e,t)}catch{}}if(s){let t=n||a[o[0]]||`USD`;try{return(0,i.formatDisplayNumber)(e,{locale:r,currency:t,minimumFractionDigits:l,maximumFractionDigits:l})}catch{return`${t} ${e.toFixed(l)}`}}return c?(0,p.formatPercent)(e,`fraction`,l,r):(0,i.formatDisplayNumber)(e,{locale:r,minimumFractionDigits:l,maximumFractionDigits:l})}var Pt=({label:e,value:n,trend:r,derivedTrend:s,icon:c,className:l,description:u,loading:d,error:p,colorVariant:m=`default`,format:h,currency:g,prefix:_,suffix:v,onClick:y,variant:b=`card`,schema:x,bind:S,events:C,props:w,ariaLabel:T,ariaDescribedBy:E,dataSource:D,...O})=>{let k=kt(x,O),A=s??r,M=ae[m]||ae.default,{t:N}=At(),P=(0,i.useDisplayLocale)(),{language:F}=(0,i.useObjectTranslation)(),I=(0,t.useMemo)(()=>(0,i.pickLocalized)(e,F)||void 0,[e,F]),L=(0,t.useMemo)(()=>{let e=(0,i.pickLocalized)(u,F)||(0,i.pickLocalized)(A?.label,F)||void 0;if(!e)return e;let t=jt(e);return t?N(t):e},[u,A?.label,N,F]),R=(0,t.useMemo)(()=>{let e=typeof n==`number`||typeof n==`string`&&n.trim()!==``&&isFinite(Number(n))?Nt(n,h,g,P):n??``,t=String(e);return`${_&&t.startsWith(_)?``:_??``}${t}${v&&t.endsWith(v)?``:v??``}`},[n,h,g,_,v,P]),z=(0,t.useMemo)(()=>{if(typeof c==`string`){let e=(0,a.getLazyIcon)(c);return e?(0,f.jsx)(e,{className:`h-4 w-4`}):null}return c},[c]);if(b===`bare`){let e=oe[m]||oe.default;return(0,f.jsx)(`div`,{className:(0,a.cn)(`flex flex-col gap-1 min-w-0`,y&&`cursor-pointer`,l),onClick:y,role:y?`button`:void 0,tabIndex:y?0:void 0,onKeyDown:y?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),y())}:void 0,children:d?(0,f.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,"data-testid":`metric-loading`,children:[(0,f.jsx)(o.Loader2,{className:`h-4 w-4 animate-spin`}),(0,f.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]}):p?(0,f.jsxs)(`div`,{className:`flex items-center gap-2`,"data-testid":`metric-error`,role:`alert`,children:[(0,f.jsx)(o.AlertCircle,{className:`h-4 w-4 text-destructive shrink-0`}),(0,f.jsx)(`span`,{className:`text-xs text-destructive truncate`,children:p})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`div`,{className:(0,a.cn)(`text-[2rem] leading-none font-extrabold tabular-nums tracking-tight truncate`,e),children:R}),(0,f.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground truncate`,children:I})]})})}return(0,f.jsxs)(a.Card,{className:(0,a.cn)(`h-full overflow-hidden`,ce,y&&`cursor-pointer transition-colors hover:bg-accent/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`,l),onClick:y,role:y?`button`:void 0,tabIndex:y?0:void 0,onKeyDown:y?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),y())}:void 0,...k,children:[(0,f.jsxs)(a.CardHeader,{className:`flex flex-row items-center justify-between gap-2 space-y-0 pb-2`,children:[(0,f.jsx)(a.CardTitle,{className:le,title:I,children:I}),z&&(0,f.jsx)(`div`,{className:(0,a.cn)(`flex h-8 w-8 items-center justify-center rounded-md shrink-0`,M),children:z})]}),(0,f.jsx)(a.CardContent,{children:d?(0,f.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,"data-testid":`metric-loading`,children:[(0,f.jsx)(o.Loader2,{className:`h-4 w-4 animate-spin`}),(0,f.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]}):p?(0,f.jsxs)(`div`,{className:`flex items-center gap-2`,"data-testid":`metric-error`,role:`alert`,children:[(0,f.jsx)(o.AlertCircle,{className:`h-4 w-4 text-destructive shrink-0`}),(0,f.jsx)(`span`,{className:`text-xs text-destructive truncate`,children:p})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`div`,{className:(0,a.cn)(`font-bold tracking-tight`,fe(R)),title:pe(R),children:R}),(A||u)&&(0,f.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 min-w-0`,children:[A&&(0,f.jsxs)(`span`,{className:(0,a.cn)(`flex items-center shrink-0 font-medium`,A.direction===`up`&&`text-emerald-600 dark:text-emerald-400`,A.direction===`down`&&`text-rose-600 dark:text-rose-400`,A.direction===`neutral`&&`text-muted-foreground`),children:[A.direction===`up`&&(0,f.jsx)(o.ArrowUpIcon,{className:`h-3 w-3 mr-1`}),A.direction===`down`&&(0,f.jsx)(o.ArrowDownIcon,{className:`h-3 w-3 mr-1`}),A.direction===`neutral`&&(0,f.jsx)(o.MinusIcon,{className:`h-3 w-3 mr-1`}),j(A.value)]}),(0,f.jsx)(`span`,{className:`truncate min-w-0`,children:L})]})]})})]})},Ft=({title:e,value:t,icon:n,trend:r,trendValue:s,description:c,className:l,loading:u,error:d,schema:p,bind:m,events:h,props:g,ariaLabel:_,ariaDescribedBy:v,dataSource:y,...b})=>{let x=kt(p,b),S=n?(0,a.getLazyIcon)(n):null,{language:C}=(0,i.useObjectTranslation)();return(0,f.jsxs)(a.Card,{className:(0,a.cn)(`h-full`,ce,l),...x,children:[(0,f.jsxs)(a.CardHeader,{className:`flex flex-row items-center justify-between gap-2 space-y-0 pb-2`,children:[(0,f.jsx)(a.CardTitle,{className:le,title:(0,i.pickLocalized)(e,C)||void 0,children:(0,i.pickLocalized)(e,C)}),S&&(0,f.jsx)(S,{className:`h-4 w-4 shrink-0 text-muted-foreground`})]}),(0,f.jsx)(a.CardContent,{children:u?(0,f.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,"data-testid":`metric-card-loading`,children:[(0,f.jsx)(o.Loader2,{className:`h-4 w-4 animate-spin`}),(0,f.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]}):d?(0,f.jsxs)(`div`,{className:`flex items-center gap-2`,"data-testid":`metric-card-error`,role:`alert`,children:[(0,f.jsx)(o.AlertCircle,{className:`h-4 w-4 text-destructive shrink-0`}),(0,f.jsx)(`span`,{className:`text-xs text-destructive truncate`,children:d})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`div`,{className:(0,a.cn)(`font-bold`,fe(t)),title:pe(t),children:t}),(r||s||c)&&(0,f.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center mt-1`,children:[r&&s&&(0,f.jsxs)(`span`,{className:(0,a.cn)(`flex items-center mr-2`,r===`up`&&`text-green-500`,r===`down`&&`text-red-500`,r===`neutral`&&`text-yellow-500`),children:[r===`up`&&(0,f.jsx)(o.ArrowUpIcon,{className:`h-3 w-3 mr-1`}),r===`down`&&(0,f.jsx)(o.ArrowDownIcon,{className:`h-3 w-3 mr-1`}),r===`neutral`&&(0,f.jsx)(o.MinusIcon,{className:`h-3 w-3 mr-1`}),s]}),(0,i.pickLocalized)(c,C)]})]})})]})},It=25,Lt={sum:!0,avg:!0,min:!0,max:!0,count:!1};function Rt(e){return typeof e==`string`&&Object.prototype.hasOwnProperty.call(Lt,e)&&Lt[e]}function zt(e,t){return`0,0${e>0?`.${`0`.repeat(e)}`:``}${t?`%`:``}`}function Bt(e){let[t,n]=String(e).split(`e`),r=t.indexOf(`.`),i=r===-1?0:t.length-r-1;return Math.min(Math.max(i-(n?Number(n):0),0),20)}function Vt(e){if(!Array.isArray(e))return e;let t=(0,n.toFilterNode)(e);return t!==void 0&&(0,_.isFilterAST)(t)?(0,_.parseFilterAST)(t):t}var Ht=({objectName:e,aggregate:a,filter:o,label:s,fallbackValue:c,trend:l,icon:u,className:d,description:m,dataSource:h,colorVariant:g,format:v,currency:y,prefix:b,suffix:x,invert:S,drillDown:C,title:w,compareTo:T,t:E,variant:D})=>{let O=(0,t.useContext)(r.SchemaRendererContext),k=h||O?.dataSource,[j,M]=(0,t.useState)(!1),[N,P]=(0,t.useState)(null),[F,I]=(0,t.useState)(null),[L,R]=(0,t.useState)(!1),[z,B]=(0,t.useState)(null),[V,H]=(0,t.useState)(null);(0,t.useEffect)(()=>{let t=!0;if(k&&e&&typeof k.getObjectSchema==`function`)return k.getObjectSchema(e).then(e=>{t&&H(e)}).catch(()=>{}),()=>{t=!1}},[k,e]);let U=(0,t.useMemo)(()=>{let e=a?.field;if(!e||!V?.fields)return null;let t=V.fields;return Array.isArray(t)?t.find(t=>t?.name===e)||null:t[e]||null},[V,a?.field]),W=Rt(a?.function),G=(0,t.useMemo)(()=>{if(v)return v;if(!U||!W)return;let e=U.type,t=e===`percent`;if(!t&&e!==`number`&&e!==`integer`)return;let n=(0,_.resolveFieldScale)({type:e,scale:U.scale});if(n!==void 0)return zt(n,t);let r=a?.function;if(r===`min`||r===`max`){let e=typeof N==`number`?N:typeof N==`string`&&N.trim()!==``?Number(N):NaN;if(Number.isFinite(e))return zt(Bt(e),!1)}return`0,0`},[v,U,W,a?.function,N]),{currency:K}=(0,i.useLocalization)(),{language:ee}=(0,i.useObjectTranslation)(),te=(0,i.useDisplayLocale)(),q=(0,t.useMemo)(()=>{if(y)return y;if(W&&U?.type===`currency`)return(0,i.resolveFieldCurrency)(U,K)},[y,U,K,W]),ne=(0,t.useMemo)(()=>a?JSON.stringify(a):``,[a]),re=(0,r.useFilterScope)(),ie=(0,t.useMemo)(()=>(0,n.resolveFilterPlaceholders)(o,re),[o,re]),ae=(0,t.useMemo)(()=>ie?JSON.stringify(ie):``,[ie]),oe=(0,t.useMemo)(()=>T?JSON.stringify(T):``,[T]),se=(0,t.useCallback)(async(t,r)=>{if(a&&typeof t.aggregate==`function`){let i=a.groupBy,o=(0,n.isStructuredGroupBy)(i)?await t.aggregate(e,(0,n.objectAggregateSpecQuery)(a,i,Vt(r))):await t.aggregate(e,{field:a.field,function:a.function,groupBy:i||`_all`,filter:r}),s=Array.isArray(o)?o:[];if(s.length===0)return 0;if(a.function===`count`){let e=`${a.field}_count`;return s.reduce((t,n)=>t+(Number(n[e])||Number(n[a.field])||Number(n.count)||0),0)}let c=s[0];return c[`${a.field}_${a.function}`]??c[a.field]??c.value??0}if(typeof t.find==`function`){let n=await t.find(e,{$filter:r});return(Array.isArray(n)?n:n?.data||n?.records||[]).length}return null},[e,ne]),ce=(0,t.useCallback)(async(t,r)=>{if(t&&e){r.current&&(R(!0),B(null));try{let e=T?(0,n.shiftFilterByCompareTo)(o,T):null,[i,a]=await Promise.all([se(t,ie),e?se(t,e):Promise.resolve(null)]);if(i===null)return;r.current&&(P(i),I(typeof a==`number`&&Number.isFinite(a)?a:null))}catch(e){console.error(`[ObjectMetricWidget] Fetch error:`,e),r.current&&B(e instanceof Error?e.message:`Failed to load metric`)}finally{r.current&&R(!1)}}},[e,ne,ae,oe,se]),le=(0,r.useDataInvalidation)(k&&e||void 0);(0,t.useEffect)(()=>{let t={current:!0};return k&&e?ce(k,t):(P(null),B(null)),()=>{t.current=!1}},[k,e,ce,le]);let J=N===null?k?`—`:c??`—`:N;S&&typeof J==`number`&&isFinite(J)&&J>=0&&J<=1&&(J=1-J);let Y=J,ue=G;if(!v&&W&&U?.type===`currency`){let e=typeof J==`number`?J:J.trim()===``?NaN:Number(J);Number.isFinite(e)&&(q?Y=(0,p.formatCurrency)(e,q,te):ue=`0,0.00`)}if(W&&U?.type===`percent`&&(!v||v.trim().endsWith(`%`))){let e=typeof J==`number`?J:J.trim()===``?NaN:Number(J);if(Number.isFinite(e)){let t=v?Mt(v):(0,_.resolveFieldScale)({type:`percent`,scale:U.scale});Y=(0,p.formatPercent)(e,(0,p.percentCellScale)(U),t,te)}}let de=(0,t.useMemo)(()=>{if(!T||typeof N!=`number`||!Number.isFinite(N)||F===null)return;let e=A(N,F);if(!e)return;let t=(0,n.compareToTrendLabelKey)(T,o),r=`dashboard.trend.${t}`,i={vsPreviousPeriod:`vs previous period`,vsLastWeek:`vs last week`,vsLastMonth:`vs last month`,vsLastQuarter:`vs last quarter`,vsLastYear:`vs last year`,vsYesterday:`vs yesterday`},a=E?E(r,i[t]||t):i[t]||t;return{value:e.value,direction:e.direction,label:a}},[T,N,F,o,E]),X=(0,n.isDrillEnabled)(C)&&!!e&&!!k,fe=(0,t.useMemo)(()=>{let e=(0,i.pickLocalized)(s,ee),t=(0,i.pickLocalized)(w,ee);return(0,n.resolveDrillTitle)(C,{},t||e||`Details`)},[C,s,w,ee]),Z=X?(0,f.jsx)(Pe,{open:!0,onClose:()=>M(!1),title:fe,target:C?.target,objectName:e,filter:ie,dataSource:k,columns:C?.columns,maxRows:C?.maxRows??It,report:C?.report,className:`h-full`}):null;return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(Pt,{label:s,value:Y,trend:l,derivedTrend:de,icon:u,className:d,description:m,loading:L,error:z,colorVariant:g,format:ue,currency:q,prefix:b,suffix:x,variant:D,onClick:X?()=>M(!0):void 0}),j&&Z]})};function Ut(){return(0,i.useSafeTranslate)()(`dashboard.total`,`Total`)}function Wt(e,t){if(!t)return String(e);let n=``,r=!1,i,a=t,o=a.match(/^([^0-9.,#]*)/);if(o&&o[1]){let e=o[1];n=e.replace(`,`,``),e.includes(`,`)&&(r=!0),a=a.slice(o[1].length)}a.includes(`,`)&&(r=!0,a=a.replace(/,/g,``));let s=a.match(/\.(\d+)f?/);s&&(i=Number(s[1]),a=a.slice(s[0].length));let c=a.replace(/[0-9#.f]/g,``),l=i===void 0?String(e):e.toFixed(i);if(r){let[e,t]=l.split(`.`),r=e.replace(/\B(?=(\d{3})+(?!\d))/g,`,`);return n+(t===void 0?r:`${r}.${t}`)+c}return n+l+c}var Gt=`—`;function Kt(e,t){return e===``?Gt:t?.[e]??e}var qt=Object.freeze([]),Jt=new Set([`sum`,`count`,`avg`,`min`,`max`]);function Yt(e,t){if(e.length===0)return 0;switch(t){case`sum`:return e.reduce((e,t)=>e+t,0);case`count`:return e.length;case`avg`:return e.reduce((e,t)=>e+t,0)/e.length;case`min`:return Math.min(...e);case`max`:return Math.max(...e);default:return NaN}}var Xt=({schema:e,className:n,rowLabels:r,columnLabels:i,rowFieldLabel:o,sourceLabel:s,onDrillDown:c})=>{let{title:l,rowField:u,columnField:d,valueField:p,aggregation:m=`sum`,data:h=qt,showRowTotals:g=!1,showColumnTotals:_=!1,format:v,columnColors:y}=e,b=Ut(),x=typeof c==`function`,S=e=>{x&&c({...e,rowLabel:e.rowKey===void 0?e.rowLabel:r?.[e.rowKey]??e.rowKey,colLabel:e.colKey===void 0?e.colLabel:i?.[e.colKey]??e.colKey})},C=e=>t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e())},w=x?`cursor-pointer hover:bg-accent/40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-[-2px]`:``,T=Array.isArray(h)?h:qt,{rowKeys:E,colKeys:D,matrix:O,rowTotals:k,colTotals:A,grandTotal:j}=(0,t.useMemo)(()=>{let e=new Map,t=new Map,n={};for(let r of T){let i=String(r[u]??``),a=String(r[d]??``),o=Number(r[p])||0;e.set(i,!0),t.set(a,!0),n[i]||(n[i]={}),n[i][a]||(n[i][a]=[]),n[i][a].push(o)}let r=Array.from(e.keys()),i=Array.from(t.keys()),a={},o={},s={};for(let e of r){a[e]={};let t=[];for(let r of i){let i=n[e]?.[r]??[],o=Yt(i,m);a[e][r]=o,t.push(...i),!s[r]&&s[r]}o[e]=Yt(t,m)}for(let e of i){let t=[];for(let i of r){let r=n[i]?.[e]??[];t.push(...r)}s[e]=Yt(t,m)}let c=[];for(let e of T)c.push(Number(e[p])||0);return{rowKeys:r,colKeys:i,matrix:a,rowTotals:o,colTotals:s,grandTotal:Yt(c,m)}},[T,u,d,p,m]),M=e=>Wt(e,v);return Jt.has(m)?T.length===0?(0,f.jsxs)(`div`,{className:(0,a.cn)(`overflow-auto`,n),children:[l&&(0,f.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:l}),(0,f.jsx)(ie,{testId:`pivot-empty-state`,source:s,className:`py-8`})]}):(0,f.jsxs)(`div`,{className:(0,a.cn)(`overflow-auto`,n),children:[l&&(0,f.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:l}),(0,f.jsxs)(`table`,{className:`w-full text-sm border-collapse table-auto`,role:`table`,children:[(0,f.jsx)(`thead`,{children:(0,f.jsxs)(`tr`,{className:`border-b border-border`,children:[(0,f.jsx)(`th`,{className:`text-left p-2 font-medium text-muted-foreground whitespace-nowrap`,children:o||u}),D.map(e=>{let t=()=>S({scope:`column`,colKey:e});return(0,f.jsx)(`th`,{className:(0,a.cn)(`text-right p-2 font-medium whitespace-nowrap`,e===``&&`italic text-muted-foreground/70`,y?.[e]??`text-muted-foreground`,w),title:e===``?`${d}: (empty)`:`${d}: ${e}`,role:x?`button`:void 0,tabIndex:x?0:void 0,onClick:x?t:void 0,onKeyDown:x?C(t):void 0,"aria-label":x?`Drill into ${d}: ${e||`(empty)`}`:void 0,children:Kt(e,i)},e)}),g&&(0,f.jsx)(`th`,{className:`text-right p-2 font-semibold text-muted-foreground bg-muted/20 whitespace-nowrap`,children:b})]})}),(0,f.jsx)(`tbody`,{children:E.map(e=>(0,f.jsxs)(`tr`,{className:`border-b border-border/50 hover:bg-muted/30`,children:[(0,f.jsx)(`td`,{className:(0,a.cn)(`p-2 font-medium whitespace-nowrap`,e===``&&`italic text-muted-foreground/70`,w),role:x?`button`:void 0,tabIndex:x?0:void 0,onClick:x?()=>S({scope:`row`,rowKey:e}):void 0,onKeyDown:x?C(()=>S({scope:`row`,rowKey:e})):void 0,"aria-label":x?`Drill into ${u}: ${e||`(empty)`}`:void 0,children:Kt(e,r)}),D.map(t=>{let n=O[e]?.[t]??0,r=()=>S({scope:`cell`,rowKey:e,colKey:t,value:n});return(0,f.jsx)(`td`,{className:(0,a.cn)(`text-right p-2 tabular-nums`,y?.[t],w),role:x?`button`:void 0,tabIndex:x?0:void 0,onClick:x?r:void 0,onKeyDown:x?C(r):void 0,"aria-label":x?`Drill into ${u}=${e||`(empty)`}, ${d}=${t||`(empty)`}`:void 0,children:M(n)},t)}),g&&(0,f.jsx)(`td`,{className:(0,a.cn)(`text-right p-2 font-semibold tabular-nums bg-muted/20`,w),role:x?`button`:void 0,tabIndex:x?0:void 0,onClick:x?()=>S({scope:`row`,rowKey:e,value:k[e]??0}):void 0,onKeyDown:x?C(()=>S({scope:`row`,rowKey:e,value:k[e]??0})):void 0,children:M(k[e]??0)})]},e))}),_&&(0,f.jsx)(`tfoot`,{children:(0,f.jsxs)(`tr`,{className:`border-t-2 border-border font-semibold bg-muted/40`,children:[(0,f.jsx)(`td`,{className:`p-2`,children:b}),D.map(e=>(0,f.jsx)(`td`,{className:(0,a.cn)(`text-right p-2 tabular-nums`,w),role:x?`button`:void 0,tabIndex:x?0:void 0,onClick:x?()=>S({scope:`column`,colKey:e,value:A[e]??0}):void 0,onKeyDown:x?C(()=>S({scope:`column`,colKey:e,value:A[e]??0})):void 0,children:M(A[e]??0)},e)),g&&(0,f.jsx)(`td`,{className:(0,a.cn)(`text-right p-2 tabular-nums font-bold`,w),role:x?`button`:void 0,tabIndex:x?0:void 0,onClick:x?()=>S({scope:`total`,value:j}):void 0,onKeyDown:x?C(()=>S({scope:`total`,value:j})):void 0,children:M(j)})]})})]})]}):(0,f.jsxs)(`div`,{className:(0,a.cn)(`overflow-auto`,n),"data-testid":`pivot-unsupported-aggregation`,children:[l&&(0,f.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:l}),(0,f.jsx)(`div`,{role:`alert`,className:`flex flex-col items-center justify-center py-8 text-destructive`,children:(0,f.jsxs)(`p`,{className:`text-xs`,children:[`Unsupported aggregation “`,String(m),`” — this pivot table renders`,` `,[...Jt].join(`, `),`.`]})})]})},Zt=Object.freeze([]),Qt=({schema:e,dataSource:o,className:s})=>{let c=(0,t.useContext)(r.SchemaRendererContext),l=o||c?.dataSource,u=(0,r.useDataScope)(e.bind),[d,p]=(0,t.useState)([]),[m,h]=(0,t.useState)(!1),[g,_]=(0,t.useState)(null),[v,y]=(0,t.useState)({}),[b,x]=(0,t.useState)({}),[S,C]=(0,t.useState)(null),{fieldLabel:w,fieldOptionLabel:T}=(0,i.useSafeFieldLabel)();(0,t.useEffect)(()=>{if(!l||!e.objectName)return;let t=l.getObjectSchema;if(typeof t!=`function`)return;let n=!0;return Promise.resolve(t.call(l,e.objectName)).then(t=>{if(!n||!t?.fields)return;let r=e.objectName,i={},a={};for(let[e,n]of Object.entries(t.fields)){let t=n?.label?String(n.label):e;a[e]=w(r,e,t);let o=n?.options;if(Array.isArray(o)&&o.length>0){let t={};for(let n of o)if(n&&n.value!==void 0&&n.label!==void 0){let i=String(n.value),a=String(n.label);t[i]=T(r,e,i,a)}Object.keys(t).length>0&&(i[e]=t)}}y(i),x(a)}).catch(()=>{}),()=>{n=!1}},[l,e.objectName,w,T]);let E=(0,r.useFilterScope)(),D=!!l&&!!e.objectName&&!u&&(!e.data||e.data.length===0),O=(0,r.useDataInvalidation)(D?e.objectName:void 0);(0,t.useEffect)(()=>{let t=!0;return e.objectName&&!u&&(!e.data||e.data.length===0)&&(async()=>{if(l&&e.objectName){t&&(h(!0),_(null));try{let r;if(typeof l.find==`function`){let t=await l.find(e.objectName,{$filter:(0,n.resolveFilterPlaceholders)(e.filter,E)});r=(0,n.extractRecords)(t)}else return;t&&p(r)}catch(e){console.error(`[ObjectPivotTable] Fetch error:`,e),t&&_(e instanceof Error?e.message:`Failed to load data`)}finally{t&&h(!1)}}})(),()=>{t=!1}},[e.objectName,l,u,e.data,e.filter,E,O]);let k=(0,t.useMemo)(()=>{if(S)try{let t=(0,n.computeDrillFilter)(e.drillDown,S,{rowField:e.rowField,columnField:e.columnField});return{ok:!0,filter:(0,n.composeDrillFilter)(e.filter,t)}}catch(e){if(!(e instanceof n.FilterOperatorError))throw e;return{ok:!1,refusal:e}}},[S,e.drillDown,e.rowField,e.columnField,e.filter]),A=k?.ok===!1?k.refusal.message:void 0;(0,t.useEffect)(()=>{A&&console.warn(`[ObjectPivotTable] drill-down refused — the drilled list cannot be scoped: ${A}`)},[A]);let j=u||e.data||d,M=Array.isArray(j)?j:Zt;if(m&&M.length===0)return(0,f.jsxs)(`div`,{className:(0,a.cn)(`overflow-auto`,s),"data-testid":`pivot-loading`,children:[e.title&&(0,f.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:e.title}),(0,f.jsxs)(`div`,{className:`space-y-2 p-2`,children:[(0,f.jsxs)(`div`,{className:`flex gap-2`,children:[(0,f.jsx)(a.Skeleton,{className:`h-6 w-24`}),(0,f.jsx)(a.Skeleton,{className:`h-6 w-20`}),(0,f.jsx)(a.Skeleton,{className:`h-6 w-20`}),(0,f.jsx)(a.Skeleton,{className:`h-6 w-20`})]}),[1,2,3].map(e=>(0,f.jsxs)(`div`,{className:`flex gap-2`,children:[(0,f.jsx)(a.Skeleton,{className:`h-5 w-24`}),(0,f.jsx)(a.Skeleton,{className:`h-5 w-20`}),(0,f.jsx)(a.Skeleton,{className:`h-5 w-20`}),(0,f.jsx)(a.Skeleton,{className:`h-5 w-20`})]},e))]})]});if(g)return(0,f.jsxs)(`div`,{className:(0,a.cn)(`overflow-auto`,s),"data-testid":`pivot-error`,children:[e.title&&(0,f.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:e.title}),(0,f.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-destructive`,"data-testid":`pivot-error-message`,children:[(0,f.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 mb-2 opacity-60`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,f.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,f.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,f.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),(0,f.jsx)(`p`,{className:`text-xs`,children:g})]})]});if(!l&&e.objectName&&M.length===0)return(0,f.jsxs)(`div`,{className:(0,a.cn)(`overflow-auto`,s),children:[e.title&&(0,f.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:e.title}),(0,f.jsx)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:(0,f.jsxs)(`p`,{className:`text-xs`,children:[`No data source available for “`,e.objectName,`”`]})})]});let{drillDown:N,...P}=e,F={...P,data:M},I=e.rowField?v[e.rowField]:void 0,L=e.columnField?v[e.columnField]:void 0,R=e.rowField?b[e.rowField]:void 0,z=e.drillDown,B=(0,n.isDrillEnabled)(z)?e=>C(e):void 0;return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(Xt,{schema:F,className:s,rowLabels:I,columnLabels:L,rowFieldLabel:R,sourceLabel:e.objectName,onDrillDown:B}),(()=>{if(!S||!e.objectName||!k?.ok)return null;let t=k.filter,r=(0,n.resolveDrillTitle)(z,S,e.title||`Details`);return(0,f.jsx)(Pe,{open:!0,onClose:()=>C(null),title:r,target:z?.target??`drawer`,objectName:e.objectName,filter:t,dataSource:l,columns:z?.columns,maxRows:z?.maxRows,report:z?.report})})()]})},$t={"dashboard.config.breadcrumb.dashboard":`Dashboard`,"dashboard.config.breadcrumb.configuration":`Configuration`,"dashboard.config.breadcrumb.widget":`Widget`,"dashboard.config.breadcrumb.chart":`Chart`,"dashboard.config.breadcrumb.table":`Table`,"dashboard.config.breadcrumb.pivotTable":`Pivot table`,"dashboard.config.section.general":`General`,"dashboard.config.section.layout":`Layout`,"dashboard.config.section.data":`Data`,"dashboard.config.section.dataBinding":`Data Binding`,"dashboard.config.section.appearance":`Appearance`,"dashboard.config.field.title":`Title`,"dashboard.config.field.description":`Description`,"dashboard.config.field.columns":`Columns`,"dashboard.config.field.gap":`Gap`,"dashboard.config.field.rowHeight":`Row height (px)`,"dashboard.config.field.autoRefresh":`Auto refresh`,"dashboard.config.field.showDescription":`Show description`,"dashboard.config.field.theme":`Theme`,"dashboard.config.field.widgetType":`Widget type`,"dashboard.config.field.colorVariant":`Color variant`,"dashboard.config.field.dataset":`Dataset`,"dashboard.config.field.dimensions":`Dimensions`,"dashboard.config.field.values":`Values`,"dashboard.config.field.width":`Width (columns)`,"dashboard.config.field.height":`Height (rows)`,"dashboard.config.placeholder.dashboardTitle":`Dashboard title`,"dashboard.config.placeholder.dashboardDescription":`Short summary shown under the title`,"dashboard.config.placeholder.widgetTitle":`Widget title`,"dashboard.config.placeholder.widgetDescription":`Widget description`,"dashboard.config.placeholder.datasetName":`Dataset name`,"dashboard.config.placeholder.selectDataset":`Select dataset…`,"dashboard.config.placeholder.searchDatasets":`Search datasets…`,"dashboard.config.placeholder.addDimension":`Add dimension…`,"dashboard.config.placeholder.addMeasure":`Add measure…`,"dashboard.config.placeholder.searchMembers":`Search…`,"dashboard.config.empty.datasets":`No datasets found.`,"dashboard.config.empty.dimensions":`No dimensions selected.`,"dashboard.config.empty.measures":`No measures selected.`,"dashboard.config.empty.nothingToAdd":`Nothing left to add.`,"dashboard.config.help.dataset":`The semantic-layer dataset this widget binds to (ADR-0021).`,"dashboard.config.help.dimensions":`Group/split the values by these dataset dimensions.`,"dashboard.config.help.dimensionsPivot":`Group/split fields. The last dimension spreads across as columns.`,"dashboard.config.help.values":`Measure(s) from the dataset to display (at least one).`,"dashboard.config.action.add":`Add`,"dashboard.config.action.remove":`Remove {{name}}`,"dashboard.config.refresh.off":`Off`,"dashboard.config.refresh.every30s":`Every 30s`,"dashboard.config.refresh.every1m":`Every 1 min`,"dashboard.config.refresh.every5m":`Every 5 min`,"dashboard.config.refresh.every15m":`Every 15 min`,"dashboard.config.refresh.every30m":`Every 30 min`,"dashboard.config.refresh.every1h":`Every 1 hour`,"dashboard.config.themeOption.light":`Light`,"dashboard.config.themeOption.dark":`Dark`,"dashboard.config.themeOption.auto":`Auto`,"dashboard.config.widgetType.metric":`Metric`,"dashboard.config.widgetType.bar":`Bar Chart`,"dashboard.config.widgetType.horizontalBar":`Horizontal Bar`,"dashboard.config.widgetType.line":`Line Chart`,"dashboard.config.widgetType.pie":`Pie Chart`,"dashboard.config.widgetType.donut":`Donut Chart`,"dashboard.config.widgetType.area":`Area Chart`,"dashboard.config.widgetType.scatter":`Scatter Plot`,"dashboard.config.widgetType.funnel":`Funnel`,"dashboard.config.widgetType.table":`Table`,"dashboard.config.widgetType.pivot":`Pivot Table`,"dashboard.config.color.default":`Default`,"dashboard.config.color.blue":`Blue`,"dashboard.config.color.teal":`Teal`,"dashboard.config.color.orange":`Orange`,"dashboard.config.color.purple":`Purple`,"dashboard.config.color.success":`Success`,"dashboard.config.color.warning":`Warning`,"dashboard.config.color.danger":`Danger`},en=(0,i.createSafeTranslation)($t,`dashboard.config.section.general`);function tn(e){return[{value:`0`,label:e(`dashboard.config.refresh.off`)},{value:`30`,label:e(`dashboard.config.refresh.every30s`)},{value:`60`,label:e(`dashboard.config.refresh.every1m`)},{value:`300`,label:e(`dashboard.config.refresh.every5m`)},{value:`900`,label:e(`dashboard.config.refresh.every15m`)},{value:`1800`,label:e(`dashboard.config.refresh.every30m`)},{value:`3600`,label:e(`dashboard.config.refresh.every1h`)}]}function nn(e){return[{value:`light`,label:e(`dashboard.config.themeOption.light`)},{value:`dark`,label:e(`dashboard.config.themeOption.dark`)},{value:`auto`,label:e(`dashboard.config.themeOption.auto`)}]}function rn(e){return{breadcrumb:[e(`dashboard.config.breadcrumb.dashboard`),e(`dashboard.config.breadcrumb.configuration`)],sections:[{key:`layout`,title:e(`dashboard.config.section.layout`),collapsible:!0,fields:[{key:`columns`,label:e(`dashboard.config.field.columns`),type:`slider`,defaultValue:3,min:1,max:12,step:1},{key:`gap`,label:e(`dashboard.config.field.gap`),type:`slider`,defaultValue:4,min:0,max:16,step:1},{key:`rowHeight`,label:e(`dashboard.config.field.rowHeight`),type:`slider`,defaultValue:120,min:40,max:320,step:10}]},{key:`data`,title:e(`dashboard.config.section.data`),collapsible:!0,fields:[{key:`refreshIntervalSeconds`,label:e(`dashboard.config.field.autoRefresh`),type:`select`,defaultValue:`0`,options:tn(e)}]},{key:`appearance`,title:e(`dashboard.config.section.appearance`),collapsible:!0,defaultCollapsed:!0,fields:[{key:`title`,label:e(`dashboard.config.field.title`),type:`input`,placeholder:e(`dashboard.config.placeholder.dashboardTitle`)},{key:`description`,label:e(`dashboard.config.field.description`),type:`textarea`,placeholder:e(`dashboard.config.placeholder.dashboardDescription`)},{key:`showDescription`,label:e(`dashboard.config.field.showDescription`),type:`switch`,defaultValue:!0},{key:`theme`,label:e(`dashboard.config.field.theme`),type:`select`,defaultValue:`auto`,options:nn(e)}]}]}}function an({open:e,onClose:n,config:r,onSave:i,onFieldChange:o}){let{t:s}=en(),{draft:c,isDirty:l,updateField:u,discard:d}=(0,a.useConfigDraft)(r,{onUpdate:o}),p=t.useMemo(()=>rn(s),[s]);return(0,f.jsx)(a.ConfigPanelRenderer,{open:e,onClose:n,schema:p,draft:c,isDirty:l,onFieldChange:u,onSave:()=>i(c),onDiscard:d})}function on(e){let t=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],n={...typeof e.id==`string`?{id:e.id}:{},...typeof e.type==`string`&&e.type?{type:e.type}:{},values:t(e.values),...Array.isArray(e.dimensions)?{dimensions:t(e.dimensions)}:{}},r=v.DashboardWidgetSchema.safeParse(n);if(!r.success)return r.error.issues.find(e=>e.code===`custom`&&e.path.length===1&&e.path[0]===`values`)?.message}var sn=`__next_measure__`;function cn(e){return[{value:`metric`,label:e(`dashboard.config.widgetType.metric`)},{value:`bar`,label:e(`dashboard.config.widgetType.bar`)},{value:`horizontal-bar`,label:e(`dashboard.config.widgetType.horizontalBar`)},{value:`line`,label:e(`dashboard.config.widgetType.line`)},{value:`pie`,label:e(`dashboard.config.widgetType.pie`)},{value:`donut`,label:e(`dashboard.config.widgetType.donut`)},{value:`area`,label:e(`dashboard.config.widgetType.area`)},{value:`scatter`,label:e(`dashboard.config.widgetType.scatter`)},{value:`funnel`,label:e(`dashboard.config.widgetType.funnel`)},{value:`table`,label:e(`dashboard.config.widgetType.table`)},{value:`pivot`,label:e(`dashboard.config.widgetType.pivot`)}]}function ln(e){return[{value:`default`,label:e(`dashboard.config.color.default`)},{value:`blue`,label:e(`dashboard.config.color.blue`)},{value:`teal`,label:e(`dashboard.config.color.teal`)},{value:`orange`,label:e(`dashboard.config.color.orange`)},{value:`purple`,label:e(`dashboard.config.color.purple`)},{value:`success`,label:e(`dashboard.config.color.success`)},{value:`warning`,label:e(`dashboard.config.color.warning`)},{value:`danger`,label:e(`dashboard.config.color.danger`)}]}var un=[`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`scatter`,`funnel`],dn=[`metric`,`gauge`,`solid-gauge`,`kpi`,`bullet`];function fn(e){return!!e&&un.includes(e)}function pn(e){return!!e&&!dn.includes(e)}function mn(e,t){return t===`pivot`?e(`dashboard.config.breadcrumb.pivotTable`):t===`table`?e(`dashboard.config.breadcrumb.table`):fn(t)?e(`dashboard.config.breadcrumb.chart`):e(`dashboard.config.breadcrumb.widget`)}function hn({names:e,options:n,placeholder:r,emptyText:i,onChange:s,canAdd:c=!0,refusal:l}){let{t:u}=en(),[d,p]=t.useState(``),m=t.useMemo(()=>new Set(e),[e]),h=t.useMemo(()=>n.filter(e=>!m.has(e.value)),[n,m]),g=t=>{let n=t.trim();c&&n&&!m.has(n)&&(s([...e,n]),p(``))},_=t=>s(e.filter(e=>e!==t));return(0,f.jsxs)(`div`,{className:`space-y-1.5`,children:[e.length===0?(0,f.jsx)(`p`,{className:`rounded border border-dashed px-2 py-1.5 text-center text-[11px] text-muted-foreground`,children:i}):(0,f.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.map(e=>(0,f.jsxs)(`span`,{"data-testid":`dataset-name-chip-${e}`,className:(0,a.cn)(`inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5`,`font-mono text-[11px] text-foreground`),children:[e,(0,f.jsx)(`button`,{type:`button`,"aria-label":u(`dashboard.config.action.remove`,{name:e}),className:`text-muted-foreground hover:text-foreground`,onClick:()=>_(e),children:(0,f.jsx)(o.X,{className:`h-3 w-3`})})]},e))}),l&&(0,f.jsx)(`p`,{role:`alert`,"data-testid":`dataset-names-refusal`,className:`break-words text-[11px] leading-snug text-destructive`,children:l}),c?h.length>0?(0,f.jsx)(a.Combobox,{options:h,value:``,onValueChange:g,placeholder:r,searchPlaceholder:u(`dashboard.config.placeholder.searchMembers`),emptyText:u(`dashboard.config.empty.nothingToAdd`),className:`h-7 w-full text-xs`}):(0,f.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,f.jsx)(a.Input,{value:d,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),g(d))},placeholder:r,className:`h-7 flex-1 text-xs`}),(0,f.jsx)(a.Button,{type:`button`,size:`sm`,variant:`outline`,className:`h-7 px-2 text-xs`,onClick:()=>g(d),disabled:!d.trim(),children:u(`dashboard.config.action.add`)})]}):null]})}function gn(e,t,n){let r=t??[],i=r.length>0,o=r.map(e=>({value:e.name,label:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name})),s=e=>typeof e==`string`?r.find(t=>t.name===e):void 0,c=e(`dashboard.config.field.dataset`),l=e(`dashboard.config.help.dataset`),u=i?{key:`dataset`,label:c,type:`custom`,helpText:l,render:(t,n)=>(0,f.jsx)(a.ConfigRow,{label:c,children:(0,f.jsx)(`div`,{"data-testid":`config-field-dataset`,children:(0,f.jsx)(a.Combobox,{options:o,value:t??``,onValueChange:n,placeholder:e(`dashboard.config.placeholder.selectDataset`),searchPlaceholder:e(`dashboard.config.placeholder.searchDatasets`),emptyText:e(`dashboard.config.empty.datasets`),className:`h-7 w-40 text-xs`})})})}:{key:`dataset`,label:c,type:`input`,placeholder:e(`dashboard.config.placeholder.datasetName`),helpText:l},d=e(`dashboard.config.field.dimensions`),p={key:`dimensions`,label:d,type:`custom`,visibleWhen:e=>pn(e.type),helpText:e(n===`pivot`?`dashboard.config.help.dimensionsPivot`:`dashboard.config.help.dimensions`),render:(t,n,r)=>{let i=(s(r.dataset)?.dimensions??[]).map(e=>({value:e.name,label:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name}));return(0,f.jsx)(a.ConfigRow,{label:d,children:(0,f.jsx)(`div`,{"data-testid":`config-field-dimensions`,className:`w-40`,children:(0,f.jsx)(hn,{names:Array.isArray(t)?t:[],options:i,placeholder:e(`dashboard.config.placeholder.addDimension`),emptyText:e(`dashboard.config.empty.dimensions`),onChange:n})})})}},m=e(`dashboard.config.field.values`),h={key:`values`,label:m,type:`custom`,helpText:e(`dashboard.config.help.values`),render:(t,n,r)=>{let i=(s(r.dataset)?.measures??[]).map(e=>({value:e.name,label:e.aggregate?`${e.label??e.name} · ${e.aggregate}`:e.label??e.name})),o=Array.isArray(t)?t:[],c=Sn(r),l={id:c.id,type:c.type,dimensions:c.dimensions},u=o.length>0?on({...l,values:o}):void 0,d=!on({...l,values:[...o,sn]});return(0,f.jsx)(a.ConfigRow,{label:m,children:(0,f.jsx)(`div`,{"data-testid":`config-field-values`,className:`w-40`,children:(0,f.jsx)(hn,{names:o,options:i,placeholder:e(`dashboard.config.placeholder.addMeasure`),emptyText:e(`dashboard.config.empty.measures`),onChange:n,canAdd:d,refusal:u})})})}};return{breadcrumb:[e(`dashboard.config.breadcrumb.dashboard`),mn(e,n)],sections:[{key:`general`,title:e(`dashboard.config.section.general`),fields:[{key:`title`,label:e(`dashboard.config.field.title`),type:`input`,placeholder:e(`dashboard.config.placeholder.widgetTitle`)},{key:`description`,label:e(`dashboard.config.field.description`),type:`input`,placeholder:e(`dashboard.config.placeholder.widgetDescription`)},{key:`type`,label:e(`dashboard.config.field.widgetType`),type:`select`,options:cn(e),defaultValue:`metric`}]},{key:`data`,title:e(`dashboard.config.section.dataBinding`),collapsible:!0,fields:[u,p,h]},{key:`layout`,title:e(`dashboard.config.section.layout`),collapsible:!0,fields:[{key:`layoutW`,label:e(`dashboard.config.field.width`),type:`slider`,min:1,max:12,step:1,defaultValue:1},{key:`layoutH`,label:e(`dashboard.config.field.height`),type:`slider`,min:1,max:6,step:1,defaultValue:1}]},{key:`appearance`,title:e(`dashboard.config.section.appearance`),collapsible:!0,defaultCollapsed:!0,fields:[{key:`colorVariant`,label:e(`dashboard.config.field.colorVariant`),type:`select`,options:ln(e),defaultValue:`default`}]}]}}var _n=[`title`,`description`];function vn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function yn(e,t,n){let r=e;for(let a of _n){let o=t?.[a];if(!vn(o))continue;let s=e[a];typeof s==`string`&&(r===e&&(r={...e}),r[a]=s===(0,i.pickLocalized)(o,n)?o:(0,i.setLocalized)(o,n,s))}return r}var bn=[`actionUrl`,`actionType`,`actionIcon`],xn=[`object`,`categoryField`,`categoryGranularity`,`valueField`,`aggregate`,`aggregation`,`rowField`,`columnField`,`xAxisField`,`yAxisFields`,`xAxisLabel`,`yAxisLabel`,`measures`,`rowSortBy`,`rowSortOrder`,`columnSortBy`,`columnSortOrder`,`showRowLabels`,`showRowTotals`,`showColumnLabels`,`showColumnTotals`,`format`,`showLegend`,`searchable`,`pagination`];function Sn(e){let t=e.type,n={...e};for(let e of xn)delete n[e];for(let e of bn)delete n[e];return pn(t)||delete n.dimensions,n}function Cn({open:e,onClose:n,config:r,onSave:o,onFieldChange:s,headerExtra:c,datasets:l,datasetsLoading:u}){let{t:d,language:p}=en(),m=t.useMemo(()=>({...r,title:typeof r.title==`object`?(0,i.pickLocalized)(r.title,p):r.title,description:typeof r.description==`object`?(0,i.pickLocalized)(r.description,p):r.description}),[r,p]),h=t.useCallback((e,t)=>{if(!s)return;let n=r?.[e];s(e,_n.includes(e)&&vn(n)&&typeof t==`string`?(0,i.setLocalized)(n,p,t):t)},[s,r,p]),{draft:g,isDirty:_,updateField:v,discard:y}=(0,a.useConfigDraft)(m,{onUpdate:h}),b=t.useMemo(()=>gn(d,l,g.type),[d,l,g.type]);return(0,f.jsx)(a.ConfigPanelRenderer,{open:e,onClose:n,schema:b,draft:g,isDirty:_,onFieldChange:v,onSave:()=>o(Sn(yn(g,r,p))),onDiscard:y,headerExtra:c})}function wn({schema:e,config:n,onConfigSave:r,onWidgetSave:i,onRefresh:s,recordCount:c,defaultConfigOpen:l=!1,className:d,datasets:p,datasetsLoading:m}){let[h,g]=(0,t.useState)(l),[_,v]=(0,t.useState)(null),[y,b]=(0,t.useState)(e),[x,S]=(0,t.useState)(0);(0,t.useEffect)(()=>{b(e),S(e=>e+1)},[e]);let C=t.useMemo(()=>{if(!_||!y.widgets)return null;let e=y.widgets,t=e.findIndex(e=>(e.id||e.title)===_);if(t<0)return null;let n=e[t],r=(0,u.completeWidgetLayout)(n.layout,{},(0,u.defaultWidgetPlacement)(t)),i=I(n)?void 0:n,a=i?.dataset,o=i?.dimensions,s=i?.values;return{id:n.id??``,title:n.title??``,description:n.description??``,type:n.type??``,dataset:typeof a==`string`?a:``,dimensions:Array.isArray(o)?o:[],values:Array.isArray(s)?s:[],colorVariant:i?.colorVariant??`default`,layoutW:r.w,layoutH:r.h}},[_,x]),w=(0,t.useCallback)(e=>{v(e),g(!0)},[]),T=(0,t.useCallback)(()=>{v(null)},[]),E=(0,t.useCallback)((e,t)=>{_&&b(n=>n.widgets?{...n,widgets:n.widgets.map((n,r)=>{if((n.id||n.title)!==_)return n;if(e===`layoutW`||e===`layoutH`){let i=e===`layoutW`?{w:t}:{h:t};return{...n,layout:(0,u.completeWidgetLayout)(n.layout,i,(0,u.defaultWidgetPlacement)(r))}}return{...n,[e]:t}})}:n)},[_]),D=(0,t.useCallback)(e=>{_&&i&&i(_,e),v(null),S(e=>e+1)},[_,i]),O=(0,t.useCallback)(()=>{g(e=>!e),v(null)},[]);return(0,f.jsxs)(`div`,{className:(0,a.cn)(`flex h-full w-full`,d),"data-testid":`dashboard-with-config`,children:[(0,f.jsxs)(`div`,{className:`flex-1 min-w-0 overflow-auto relative`,children:[(0,f.jsx)(`div`,{className:`absolute top-2 right-2 z-10`,children:(0,f.jsxs)(a.Button,{size:`sm`,variant:h?`default`:`outline`,onClick:O,"data-testid":`dashboard-config-toggle`,children:[(0,f.jsx)(o.Settings,{className:`h-3.5 w-3.5 mr-1`}),`Settings`]})}),(0,f.jsx)(Ct,{schema:y,onRefresh:s,recordCount:c,designMode:h,selectedWidgetId:_,onWidgetClick:w})]}),h&&(0,f.jsx)(`div`,{className:`relative shrink-0`,children:_&&C?(0,f.jsx)(Cn,{open:!0,onClose:T,config:C,onSave:D,onFieldChange:E,datasets:p,datasetsLoading:m}):(0,f.jsx)(an,{open:!0,onClose:()=>g(!1),config:n,onSave:r})})]})}var Tn=Object.freeze({dashboard:'[object-ui] Node type `view:dashboard` was RETIRED (objectui#9533). This package registers the dashboard renderer as `plugin-dashboard:dashboard`, the namespace the console\'s lazy stubs and the CLI\'s known-type whitelist already declare. Write `{ "type": "plugin-dashboard:dashboard" }`, or the bare `{ "type": "dashboard" }`, which resolves to the same renderer.'}),En=new Set;function Dn(e){En.has(e)||(En.add(e),console.error(Tn[e]??`[object-ui] Node type \`${e}\` was retired by @object-ui/plugin-dashboard.`))}function On(){En.clear()}var kn=e=>{let n=e?.schema,r=typeof n?.type==`string`?n.type:void 0,i=typeof e?.type==`string`?e.type:void 0,a=r??i??`view:dashboard`,o=a.includes(`:`)?a.slice(a.indexOf(`:`)+1):a,s=Tn[o]??`[object-ui] Node type \`${a}\` was retired by @object-ui/plugin-dashboard.`;return t.default.useEffect(()=>{Dn(o)},[o]),(0,f.jsx)(`div`,{role:`alert`,"data-testid":`dashboard-retired-node-tombstone`,"data-retired-node-type":a,className:`rounded-md border border-destructive/50 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:s})};n.ComponentRegistry.register(`dashboard`,Ct,{namespace:`plugin-dashboard`,label:`Dashboard`,category:`Complex`,icon:`layout-dashboard`,inputs:[{name:`widgets`,type:`array`,description:`The widget tree — the spec’s DashboardWidget[]. Each widget binds a dataset (ADR-0021) and may carry a layout ({ x, y, w, h }) and filterBindings. When omitted the dashboard renders an empty grid.`},{name:`label`,type:[`string`,`object`],description:'Display name, shown as the header title when `header` is declared — a string or an inline per-locale map such as { en, "zh-CN" }. Spec-canonical spelling; the legacy `title` spelling is not authoring surface.'},{name:`description`,type:[`string`,`object`],description:"Header description shown under the title — a string or an inline per-locale map. Rendered only when `header` is declared and `header.showDescription` is not false."},{name:`header`,type:`object`,description:`Header block: { showTitle?, showDescription?, actions? }. Strict — the contract rejects any other key. Renders nothing (zero pixels) when everything it would show is suppressed.`},{name:`globalFilters`,type:`array`,description:`Dashboard-level filter bar — the spec’s GlobalFilter[]. Filter values live as dashboard variables (readable in widget expressions as page.<name>) and are AND-merged into each bound widget’s query per its filterBindings.`},{name:`dateRange`,type:`object`,description:'Built-in date-range filter: { field?, defaultRange?, allowCustomRange? }. `defaultRange` takes the spec’s date presets plus "custom"; the bound field defaults to created_at.'},{name:`refreshIntervalSeconds`,type:`number`,description:`Auto-refresh period in seconds. Zero or a negative value disables the timer, and it only runs when the host wires an onRefresh handler.`},{name:`columns`,type:`number`},{name:`gap`,type:`number`},{name:`className`,type:`string`}],defaultProps:{columns:3,widgets:[]}}),n.ComponentRegistry.register(`metric`,Pt,{namespace:`plugin-dashboard`,skipFallback:!0,label:`Metric Widget`,category:`Dashboard`,inputs:[{name:`label`,type:`string`},{name:`value`,type:`string`}]}),n.ComponentRegistry.register(`metric-card`,Ft,{namespace:`plugin-dashboard`,skipFallback:!0,label:`Metric Card`,category:`Dashboard`,inputs:[{name:`title`,type:`string`},{name:`value`,type:`string`,required:!0},{name:`icon`,type:`string`},{name:`trend`,type:`enum`,enum:[{label:`Up`,value:`up`},{label:`Down`,value:`down`},{label:`Neutral`,value:`neutral`}]},{name:`trendValue`,type:`string`},{name:`description`,type:`string`}],defaultProps:{title:`Metric`,value:`0`}});var An={filter:!0},jn=(0,n.elementDataSourceBlock)(({schema:e,...t})=>{let{t:n}=(0,i.useObjectTranslation)();return(0,f.jsx)(r.ElementDataSourceGate,{schema:e,mapping:An,dataSource:t.dataSource,testId:`object-metric`,errorTitle:n(`element.number.sourceUnresolved`,{defaultValue:`This metric’s data source could not be resolved`}),requiresObject:e!=null&&e.fallbackValue===void 0,children:e=>(0,f.jsx)(Ht,{...t,objectName:e?.objectName??t.objectName,filter:e?.filter??t.filter})})});n.ComponentRegistry.register(`object-metric`,jn,{namespace:`plugin-dashboard`,label:`Object Metric`,category:`Dashboard`,inputs:[{name:`objectName`,type:`string`,description:"Object this metric aggregates. Not required: the node's `dataSource` binding can name the object instead, and `dataSource.object` lands on this key, outranking an authored value. With neither, and no `fallbackValue`, the tile shows a hint naming this key instead of a value."},{name:`label`,type:[`string`,`object`],description:'Heading of the tile, and of the drill-down panel when `title` is not set. Accepts either a plain string or an inline per-locale map (`{ en: "Pipeline", "zh-CN": "销售管道" }`) — the `I18nLabel` union the contract admits on this key — and the tile resolves the map against the active UI language, falling back through base language, a region-qualified sibling, `default`, then `en`, and finally to any remaining entry.'},{name:`aggregate`,type:`object`,description:`Aggregation config: { field, function, groupBy }`},{name:`icon`,type:`string`},{name:`description`,type:[`string`,`object`],description:'Helper text rendered under the value. Accepts either a plain string or an inline per-locale map (`{ en: "This quarter", "zh-CN": "本季度" }`), resolved against the active UI language with the same fallback chain as `label`.'},{name:`title`,type:[`string`,`object`],description:'Heading of the drill-down panel. Defaults to `label` — set it only when the records list wants a different name from the tile. Accepts either a plain string or an inline per-locale map (`{ en: "Open deals", "zh-CN": "进行中的商机" }`), resolved against the active UI language with the same fallback chain as `label`.'},{name:`filter`,type:`array`,description:`Criteria the aggregation is scoped by. The same filter narrows the drill-down list, so the number and the records behind it always agree.`},{name:`colorVariant`,type:`enum`,enum:[`default`,`blue`,`teal`,`orange`,`purple`,`success`,`warning`,`danger`],description:"Colour of the icon container. Semantic, not decorative: `success` / `warning` / `danger` should track what the number means."},{name:`variant`,type:`enum`,enum:[`card`,`bare`],description:"`card` draws the tile’s own surface; `bare` drops it, for a metric already sitting inside a card."},{name:`format`,type:`string`,description:"Numeral-style format pattern, e.g. `0,0`, `$0,0`, `0%`. Use `currency` instead of hard-coding a currency symbol here."},{name:`currency`,type:`string`,description:"ISO 4217 code, e.g. `USD`. Enables locale-aware currency formatting of the value."},{name:`prefix`,type:`string`,description:`Static text placed before the formatted value.`},{name:`suffix`,type:`string`,description:`Static text placed after the formatted value.`},{name:`invert`,type:`boolean`,description:"Display `1 - value` — for gauges whose good direction is down, such as error rate shown as uptime."},{name:`fallbackValue`,type:`string`,description:`Value shown when no data source resolves. For static/demo tiles; a bound metric should not need it.`},{name:`trend`,type:`object`,description:"Static trend badge: `{ value, label, direction }`. Use `compareTo` instead when the trend should be computed from data."},{name:`compareTo`,type:`object`,description:'Period-over-period comparison, `{ kind: "previousPeriod" }` or `{ kind: "previousYear" }` — the computed alternative to a static `trend`.'},{name:`drillDown`,type:`object`,description:"Click-through config that opens the records behind the number. `drillDown.filter` and `drillDown.mode` do not apply to a metric, which has no clicked point to filter by and no row to open, so the list is always scoped by this block’s own `filter`; a drill `filter` belongs on `object-chart` or `object-pivot`, and `mode` on `object-data-table`."}],defaultProps:{label:`Metric`}}),n.ComponentRegistry.register(`pivot`,Xt,{namespace:`plugin-dashboard`,label:`Pivot Table`,category:`Dashboard`,icon:`table-2`,inputs:[{name:`title`,type:`string`},{name:`rowField`,type:`string`,required:!0},{name:`columnField`,type:`string`,required:!0},{name:`valueField`,type:`string`,required:!0},{name:`aggregation`,type:`enum`,enum:[{label:`Sum`,value:`sum`},{label:`Count`,value:`count`},{label:`Average`,value:`avg`},{label:`Min`,value:`min`},{label:`Max`,value:`max`}]},{name:`showRowTotals`,type:`boolean`},{name:`showColumnTotals`,type:`boolean`},{name:`format`,type:`string`}],defaultProps:{rowField:``,columnField:``,valueField:``,aggregation:`sum`,data:[]}});var Mn={filter:!0},Nn=(0,n.elementDataSourceBlock)(({schema:e,...t})=>{let{t:n}=(0,i.useObjectTranslation)();return(0,f.jsx)(r.ElementDataSourceGate,{schema:e,mapping:Mn,dataSource:t.dataSource,testId:`object-pivot`,errorTitle:n(`element.pivotTable.sourceUnresolved`,{defaultValue:`This pivot table’s data source could not be resolved`}),requiresObject:e!=null&&e.data==null&&e.bind==null,children:e=>(0,f.jsx)(Qt,{...t,schema:e})})});n.ComponentRegistry.register(`object-pivot`,Nn,{namespace:`plugin-dashboard`,label:`Object Pivot Table`,category:`Dashboard`,icon:`table-2`,inputs:[{name:`objectName`,type:`string`,description:"Object this pivot table cross-tabulates. Not required: the node's `dataSource` binding can name the object instead, and `dataSource.object` lands on this key, outranking an authored value. With neither, the table shows a hint naming this key and fetches nothing."},{name:`title`,type:`string`},{name:`rowField`,type:`string`,required:!0},{name:`columnField`,type:`string`,required:!0},{name:`valueField`,type:`string`,required:!0},{name:`aggregation`,type:`enum`,enum:[{label:`Sum`,value:`sum`},{label:`Count`,value:`count`},{label:`Average`,value:`avg`},{label:`Min`,value:`min`},{label:`Max`,value:`max`}]},{name:`showRowTotals`,type:`boolean`},{name:`showColumnTotals`,type:`boolean`},{name:`filter`,type:`array`},{name:`format`,type:`string`},{name:`drillDown`,type:`object`,description:'Click-through config that opens the records behind a clicked cell, header or total — in a drawer, a dialog, the object’s list page (`target: "navigate"`), or an analytical report (`report`). The drilled list is this block’s `filter` narrowed by the clicked value. `drillDown.mode` does not apply: every click point on a pivot is an aggregated bucket, so it always drills through; `mode` belongs on `object-data-table`.'}],defaultProps:{rowField:``,columnField:``,valueField:``,aggregation:`sum`}}),n.ComponentRegistry.register(`object-data-table`,je,{namespace:`plugin-dashboard`,label:`Object Data Table`,category:`Dashboard`,icon:`table`,inputs:[{name:`objectName`,type:`string`,required:!0},{name:`columns`,type:`array`},{name:`filter`,type:`array`},{name:`searchable`,type:`boolean`},{name:`pagination`,type:`boolean`}],defaultProps:{searchable:!1,pagination:!1}});for(let e of Object.keys(Tn))n.ComponentRegistry.register(e,kn,{namespace:`view`,skipFallback:!0});var Pn={dashboard:Ct,"plugin-dashboard:metric":Pt,"plugin-dashboard:metric-card":Ft,"object-metric":jn,pivot:Xt,"object-pivot":Nn,"object-data-table":je};e.CONFIG_PANEL_DEFAULT_TRANSLATIONS=$t,e.DashboardConfigPanel=an,e.DashboardGridLayout=Ot,e.DashboardRenderer=Ct,e.DashboardWithConfig=wn,e.DrillDownDrawer=Pe,e.MetricCard=Ft,e.MetricWidget=Pt,e.ObjectDataTable=je,e.ObjectMetricWidget=Ht,e.ObjectPivotTable=Qt,e.PivotTable=Xt,e.RETIRED_DASHBOARD_NODE_TYPES=Tn,e.RetiredDashboardNodeTombstone=kn,e.WidgetConfigPanel=Cn,e.dashboardComponents=Pn,e.reportRetiredDashboardNodeType=Dn,e.resetRetiredDashboardNodeTypeReports=On,e.useConfigPanelTranslation=en});
|