react-semaphor 0.1.604 → 0.1.606
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/dist/analytics-protocol/index.js +1 -1
- package/dist/appearance/index.js +1 -1
- package/dist/appearance-runtime/index.js +1 -1
- package/dist/assistant-context/index.js +1 -1
- package/dist/assistant-protocol/index.js +1 -1
- package/dist/brand-studio/index.js +3 -8
- package/dist/briefings/index.js +1 -1
- package/dist/chunks/{add-to-dashboard-DeHEBEqG.js → add-to-dashboard-CEmZUf9o.js} +1 -1
- package/dist/chunks/{analytics-base-schemas-BREc5WGv.js → analytics-base-schemas-DMFrDqn_.js} +1 -1
- package/dist/chunks/appearance-provider-fIhJSX6y.js +613 -0
- package/dist/chunks/appearance-runtime-provider-Bx8H-moR.js +1 -0
- package/dist/chunks/{assistant-chat-CjYrwVDa.js → assistant-chat-SBKSrrEA.js} +19 -24
- package/dist/chunks/attachment-filter-line-C_zHMhGh.js +1 -0
- package/dist/chunks/{bookmark-impact-C89zBLq3.js → bookmark-impact-BW30cm5E.js} +1 -1
- package/dist/chunks/bookmark-state-DScd31KT.js +1 -0
- package/dist/chunks/brand-CL5xDiFH.js +1 -0
- package/dist/chunks/card-filter-builder-CzScSOQY.js +11 -0
- package/dist/chunks/comparison-window-caption-tguyN24S.js +1 -0
- package/dist/chunks/{context-ALdccLHw.js → context-CntvtZwC.js} +1 -1
- package/dist/chunks/dashboard-Cyhj9EOl.js +1 -0
- package/dist/chunks/dashboard-briefing-launcher-CyOFddmD.js +42 -0
- package/dist/chunks/dashboard-controls-DpADfhr0.js +42 -0
- package/dist/chunks/dashboard-json-4xMChR2q.js +1 -0
- package/dist/chunks/dashboard-temporal-snapshot-w3SMiPKj.js +1 -0
- package/dist/chunks/edit-dashboard-visual-DlvY7au4.js +73 -0
- package/dist/chunks/filter-line-WwUV5JzN.js +1 -0
- package/dist/chunks/filter-reach-preview-DAEIyrEG.js +1 -0
- package/dist/chunks/filter-value-text-DqTHe_vu.js +1 -0
- package/dist/chunks/{index-BE1DfxNs.js → index-bkP6SnYu.js} +1 -1
- package/dist/chunks/kpi-trend-rule-N1Xkwe_u.js +1 -0
- package/dist/chunks/{layout-grid-BWtlgw0T.js → layout-grid-Dtsioq4h.js} +1 -1
- package/dist/chunks/matrix-analytical-definition-5T-2euHZ.js +1 -0
- package/dist/chunks/matrix-member-presentation-vVAv-aqg.js +1 -0
- package/dist/chunks/matrix-operation-contract-CWvcEsQ0.js +1 -0
- package/dist/chunks/numeric-range-options-C8tr-Bls.js +1 -0
- package/dist/chunks/{palette-BzC-CGOc.js → palette-565cA0nh.js} +1 -1
- package/dist/chunks/pivot-result-contract-expectations-BNWhS8mv.js +1 -0
- package/dist/chunks/pivot-result-identity-B0eWVMXg.js +1 -0
- package/dist/chunks/{raw-temporal-value-DeyEhL0S.js → raw-temporal-value-BHQ-ldpW.js} +1 -1
- package/dist/chunks/report-preferences-dialog-B2ZGPS9t.js +1 -0
- package/dist/chunks/{report-runtime-context-BWzIHCKK.js → report-runtime-context-Cd1b5pku.js} +1 -1
- package/dist/chunks/resolve-dashboard-input-context-SlAAe4GF.js +8 -0
- package/dist/chunks/resolver-CjsW8Rz0.js +1 -0
- package/dist/chunks/saved-dashboard-context-Bc2SVDr-.js +1 -0
- package/dist/chunks/schema-O1Y3WTGF.js +4 -0
- package/dist/chunks/{selection-filter-compiler-CCoCD25M.js → selection-filter-compiler-kYsRugss.js} +1 -1
- package/dist/chunks/semaphor-ready-indicator-Bj-cjkz-.js +612 -0
- package/dist/chunks/set-CACXVM2A.js +1 -0
- package/dist/chunks/slider-CWze9OEM.js +4 -0
- package/dist/chunks/stored-dashboard-CcNdU-mG.js +1 -0
- package/dist/chunks/{table-export-sheet-rC5pKmXg.js → table-export-sheet-xaczzWZF.js} +1 -1
- package/dist/chunks/{token-types-Bj9iMy0w.js → token-types-1vzMWjI-.js} +1 -1
- package/dist/chunks/{validators-CqV3Yka1.js → validators-Dg2kyF4_.js} +1 -1
- package/dist/chunks/{variable-draft-DJrfUyhv.js → variable-draft-CRbSYdB6.js} +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/dashboard-authoring/index.js +1 -1
- package/dist/format-utils/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/report-runtime-context/index.js +1 -1
- package/dist/style.css +1 -1
- package/dist/surfboard/index.js +1 -1
- package/dist/types/brand-studio/brand-studio-draft.d.ts +45 -13
- package/dist/types/brand-studio/brand-studio-editor.d.ts +13 -2
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/components/visual/data-table/hooks/use-data-table-logic.d.ts +17 -6
- package/dist/types/components/visual/data-table/types/data-table.d.ts +52 -42
- package/dist/types/index.js +1 -1
- package/dist/types/lib/appearance/aliases.d.ts +3 -0
- package/dist/types/lib/appearance/index.d.ts +1 -0
- package/dist/types/lib/appearance/table-density.d.ts +18 -0
- package/dist/types/lib/appearance/types.d.ts +39 -1
- package/dist/types/lib/dashboard-viewer/column-header-actions.d.ts +100 -0
- package/dist/types/lib/dashboard-viewer/table-view-edit.d.ts +0 -27
- package/dist/types/lib/dashboard-viewer/table-view.d.ts +26 -2
- package/dist/types/lib/dashboard-viewer/use-table-view.d.ts +2 -0
- package/dist/types/lib/hooks/use-add-new-frame.d.ts +7 -0
- package/dist/types/lib/hooks/use-dashboard-card.d.ts +4 -0
- package/dist/types/lib/interactions/get-click-context-from-chartjs.d.ts +8 -0
- package/dist/types/lib/stores/dashboard-store.d.ts +14 -2
- package/dist/types/lib/stores/explorer-actions.d.ts +0 -4
- package/dist/types/lib/types/common-types.d.ts +1 -2
- package/dist/types/lib/utils/card-config-utils.d.ts +13 -0
- package/dist/types/lib/utils/field-placement.d.ts +17 -0
- package/dist/types/shared/analytics-protocol/analytics-refusal.d.ts +21 -1
- package/dist/types/shared/analytics-protocol/field-provenance.d.ts +7 -4
- package/dist/types/shared/dashboard-authoring/card-data-source/filter-field-folders.d.ts +48 -0
- package/dist/types/shared/dashboard-authoring/card-settings/card-display-write.d.ts +2 -8
- package/dist/types/shared/dashboard-authoring/card-settings/card-kinds.d.ts +1 -1
- package/dist/types/shared/dashboard-authoring/card-settings/column-display-values.d.ts +5 -0
- package/dist/types/shared/dashboard-authoring/card-settings/column-display.d.ts +52 -0
- package/dist/types/shared/dashboard-authoring/card-settings/index.d.ts +1 -0
- package/dist/types/shared/dashboard-authoring/card-settings/inputs.d.ts +9 -0
- package/dist/types/shared/dashboard-authoring/card-settings/resolved.d.ts +4 -0
- package/dist/types/shared/dashboard-authoring/card-settings/table-viewer-switches.d.ts +15 -0
- package/dist/types/shared/dashboard-authoring/card-settings/views.d.ts +5 -0
- package/dist/types/shared/dashboard-authoring/changes/card-query-part.d.ts +6 -0
- package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +132 -3
- package/dist/types/shared/dashboard-authoring/changes/diagnostics.d.ts +3 -1
- package/dist/types/shared/dashboard-authoring/conditional-formatting/schema.d.ts +10 -10
- package/dist/types/shared/dashboard-authoring/conditional-formatting/store.d.ts +10 -1
- package/dist/types/shared/dashboard-authoring/field-aggregations.d.ts +9 -2
- package/dist/types/shared/dashboard-authoring/field-folders/field-folders.d.ts +8 -7
- package/dist/types/shared/dashboard-authoring/index.d.ts +1 -0
- package/dist/types/shared/dashboard-authoring/measure-calculations/index.d.ts +1 -1
- package/dist/types/shared/dashboard-authoring/measure-calculations/window-transforms.d.ts +2 -0
- package/dist/types/shared/dashboard-authoring/operations/card-operations.d.ts +2 -0
- package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +7 -2
- package/dist/types/shared/dashboard-authoring/outline/outline-dashboard.d.ts +6 -2
- package/dist/types/shared/dashboard-authoring/sheet-kinds.d.ts +36 -0
- package/dist/types/shared/dashboard-authoring/table-sheet-shape.d.ts +140 -0
- package/dist/types/shared/dashboard-viewer/table-column-move.d.ts +15 -0
- package/dist/types/shared/dashboard-viewer/table-settings.d.ts +8 -2
- package/dist/types/shared/format-utils/types/format-types.d.ts +1 -1
- package/dist/usage-events/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunks/appearance-context-BqBZrijL.js +0 -1
- package/dist/chunks/appearance-runtime-provider-DmbCrOOG.js +0 -1
- package/dist/chunks/bookmark-state-69YYnRql.js +0 -1
- package/dist/chunks/brand-DCaZyRt6.js +0 -1
- package/dist/chunks/card-filter-builder-CTp6RAz1.js +0 -17
- package/dist/chunks/comparison-window-caption-C312mn3s.js +0 -1
- package/dist/chunks/dashboard-BX28ld6s.js +0 -1
- package/dist/chunks/dashboard-briefing-launcher-qo7GH4EO.js +0 -37
- package/dist/chunks/dashboard-controls-DhRjB7MA.js +0 -42
- package/dist/chunks/dashboard-json-9cHzhSjC.js +0 -1
- package/dist/chunks/dates-D-KP8G-z.js +0 -1
- package/dist/chunks/edit-DEAK0UZo.js +0 -1
- package/dist/chunks/edit-dashboard-visual-Duq_QkB_.js +0 -93
- package/dist/chunks/filter-line-CwQrqORc.js +0 -1
- package/dist/chunks/filter-reach-preview-gixPFlZj.js +0 -1
- package/dist/chunks/filter-value-text-B3tXakhd.js +0 -1
- package/dist/chunks/index-B-VF1ogs.js +0 -1
- package/dist/chunks/matrix-analytical-definition-CtFqWyCK.js +0 -1
- package/dist/chunks/matrix-member-presentation-Q0MCJ-YK.js +0 -1
- package/dist/chunks/matrix-operation-contract-D1RC1bfi.js +0 -1
- package/dist/chunks/metric-comparison-DEZYXROZ.js +0 -1
- package/dist/chunks/paintbrush-BjS3SbrH.js +0 -6
- package/dist/chunks/pickers-DuBrUht0.js +0 -1
- package/dist/chunks/pivot-result-contract-expectations-DTQAgr4n.js +0 -1
- package/dist/chunks/pivot-result-identity-DTNCB--h.js +0 -1
- package/dist/chunks/report-preferences-dialog-B_gUmCzG.js +0 -1
- package/dist/chunks/resolve-dashboard-input-context-B-TtRqxu.js +0 -8
- package/dist/chunks/resolver-AN9ChBfZ.js +0 -1
- package/dist/chunks/save-DdFUZcbi.js +0 -6
- package/dist/chunks/saved-dashboard-context-BAJ5tWiq.js +0 -1
- package/dist/chunks/schema-MC0cQSAb.js +0 -4
- package/dist/chunks/semaphor-ready-indicator-DzjorP3t.js +0 -999
- package/dist/chunks/set-DuJfGkbY.js +0 -1
- package/dist/chunks/shelf-drop-preview-context-BlLJ5RsT.js +0 -6
- package/dist/chunks/stored-dashboard-Ctcpkllg.js +0 -1
- package/dist/chunks/style-sheet-parts-BRGt9O05.js +0 -178
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
var gr=Object.defineProperty;var fr=(e,n,o)=>n in e?gr(e,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[n]=o;var De=(e,n,o)=>fr(e,typeof n!="symbol"?n+"":n,o);import{jsxs as i,jsx as r,Fragment as T}from"react/jsx-runtime";import k from"react";import{c as Ie,U as mr,V as R,W as We,Y as je,Z as Ye,_ as Je,$ as vr,a0 as yr,a1 as Ue,P as xr,b as kr,e as Sr,a2 as Cr,a3 as Se,a4 as wr,a5 as Nr,a6 as Tr,a7 as Fr,a8 as Er,a9 as Or,aa as He,ab as Pr,B,ac as Ve,ad as Ar,X as Ge,C as Rr,ae as Dr,af as Br,ag as Be,ah as zr,ai as _r,aj as $r,ak as Lr,al as Mr,am as Ir,g as Wr}from"../chunks/appearance-provider-fIhJSX6y.js";import{k as N,a6 as ze,a7 as jr}from"../chunks/resolve-dashboard-input-context-SlAAe4GF.js";import"../chunks/validators-Dg2kyF4_.js";import"../chunks/matrix-operation-contract-CWvcEsQ0.js";import"../chunks/analytics-base-schemas-DMFrDqn_.js";import"../value-format-preferences/index.js";import{A as ce,v as Yr,p as be,S as Jr,d as ie}from"../chunks/schema-O1Y3WTGF.js";import{e as Ur}from"../chunks/brand-CL5xDiFH.js";import{n as Xe}from"../chunks/index-bkP6SnYu.js";import{b as Ke}from"../chunks/resolver-CjsW8Rz0.js";import{c as Hr,u as Vr}from"../chunks/appearance-runtime-provider-Bx8H-moR.js";import{e as Ce,D as _e}from"../chunks/filter-reach-preview-DAEIyrEG.js";import{P as Gr}from"../chunks/palette-565cA0nh.js";import{L as Xr}from"../chunks/layout-grid-Dtsioq4h.js";/**
|
|
2
2
|
* @license lucide-react v0.453.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const
|
|
6
|
+
*/const Kr=Ie("Clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]);/**
|
|
7
7
|
* @license lucide-react v0.453.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const xr=de("Clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]);/**
|
|
12
|
-
* @license lucide-react v0.453.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const vr=de("Pipette",[["path",{d:"m2 22 1-1h3l9-9",key:"1sre89"}],["path",{d:"M3 21v-3l9-9",key:"hpe2y6"}],["path",{d:"m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z",key:"196du1"}]]),kr=[{value:"none",label:"None"},{value:"compact",label:"Compact"},{value:"default",label:"Default"},{value:"roomy",label:"Roomy"}],he=[{value:"outlined",label:"Outlined",note:"A border on a muted canvas"},{value:"raised",label:"Raised",note:"A shadow and no border on a muted canvas"},{value:"open",label:"Open",note:"No border or shadow on a plain canvas"}],Cr=[{value:"square",label:"Square"},{value:"subtle",label:"Subtle"},{value:"rounded",label:"Rounded"},{value:"round",label:"Round"}];function yr({spec:e,mode:a,onEdit:n}){var F;const c=pr({organizationAppearance:e},a),s=c.authored,[f,h]=pe(null),[x,v]=pe(!1),b=l=>h(n(l)),i=l=>br[l],p=s.canvas==="muted"?"muted":s.canvas==="background"?"background":"color",y=l=>({[a]:l});return/* @__PURE__ */d("div",{className:"-mx-4",children:[/* @__PURE__ */r(be,{label:"Spacing",options:kr.map(l=>({...l,title:`${j[l.value]} px between cards and around them`,preview:{...s,spacing:j[l.value],canvasPadding:j[l.value]}})),lit:c.pickers.spacing,note:"Card sizes never change with spacing.",changed:c.source.spacing==="organization"||c.source.canvasPadding==="organization",resetTitle:`Back to the default: ${j.default} px`,onPick:l=>b({spacing:l}),onReset:()=>b({reset:["spacing","canvasPadding"]}),children:/* @__PURE__ */d("div",{className:"mt-2 flex items-center gap-1.5",children:[/* @__PURE__ */r("span",{className:"text-[11px] text-muted-foreground",children:"Gap"}),/* @__PURE__ */r(B,{value:s.spacing,...i("spacing"),onChange:l=>b({spacing:l})}),/* @__PURE__ */r("span",{className:"ml-2 text-[11px] text-muted-foreground",children:"Canvas padding"}),/* @__PURE__ */r(B,{value:s.canvasPadding,...i("canvasPadding"),onChange:l=>b({canvasPadding:l})})]})}),/* @__PURE__ */r(be,{label:"Cards",options:he.map(l=>({value:l.value,label:l.label,title:l.note,preview:{...s,...ir[l.value]}})),lit:c.pickers.cards,note:((F=he.find(l=>l.value===c.pickers.cards))==null?void 0:F.note)??"Your own mix of border, shadow and canvas",changed:["cardBorder","cardShadow","canvas"].some(l=>c.source[l]==="organization"),resetTitle:"Back to the default cards",onPick:l=>b({cards:l}),onReset:()=>b({reset:["cards"]})}),/* @__PURE__ */d("div",{className:"grid gap-2 px-4 pb-3",children:[/* @__PURE__ */d("div",{className:"flex flex-wrap items-center gap-2",children:[/* @__PURE__ */d("span",{className:"w-24 text-[12px] text-muted-foreground",children:["Canvas (",a,")"]}),/* @__PURE__ */r(M,{label:"Canvas background",value:p,onChange:l=>b({canvas:y(l==="color"?a==="dark"?"#111318":"#f4f6f8":l)}),options:[{value:"muted",label:"Muted"},{value:"background",label:"Plain"},{value:"color",label:"Custom"}]}),p==="color"?/* @__PURE__ */r(Ye,{color:We(s.canvas),label:"Canvas color",onChange:l=>b({canvas:y(l)})}):null]}),/* @__PURE__ */d("div",{className:"flex flex-wrap items-center gap-2",children:[/* @__PURE__ */r("span",{className:"w-24 text-[12px] text-muted-foreground",children:"Corners"}),/* @__PURE__ */r(M,{label:"Corners",value:c.pickers.corners,onChange:l=>b({corners:l}),options:Cr.map(l=>({...l,title:`Cards ${me[l.value].cardCorners} px, controls ${me[l.value].controlCorners} px`}))}),/* @__PURE__ */r("button",{type:"button",className:"text-[11px] text-foreground underline-offset-2 hover:underline",onClick:()=>v(!x),children:x||!c.pickers.corners?"Hide":"Set separately"})]}),x||!c.pickers.corners?/* @__PURE__ */d("div",{className:"flex items-center gap-1.5 pl-[104px]",children:[/* @__PURE__ */r("span",{className:"text-[11px] text-muted-foreground",children:"Cards"}),/* @__PURE__ */r(B,{value:s.cardCorners,...i("cardCorners"),onChange:l=>b({corners:{cards:l}})}),/* @__PURE__ */r("span",{className:"ml-1 text-[11px] text-muted-foreground",children:"Controls"}),/* @__PURE__ */r(B,{value:s.controlCorners,...i("controlCorners"),onChange:l=>b({corners:{controls:l}})})]}):null,/* @__PURE__ */d("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */r("span",{className:"w-24 text-[12px] text-muted-foreground",children:"Card border"}),/* @__PURE__ */r(Ce,{checked:s.cardBorder==="on",onCheckedChange:l=>b({border:l?"on":"off"}),"aria-label":"Card border"}),/* @__PURE__ */r("span",{className:"ml-4 w-20 text-[12px] text-muted-foreground",children:"Shadow"}),/* @__PURE__ */r(M,{label:"Card shadow",value:s.cardShadow==="custom"?null:s.cardShadow,onChange:l=>b({shadow:l}),options:[{value:"none",label:"None"},{value:"subtle",label:"Subtle"},{value:"raised",label:"Raised"}]})]}),/* @__PURE__ */d("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */r("span",{className:"w-24 text-[12px] text-muted-foreground",children:"Bar corners"}),/* @__PURE__ */r(B,{value:s.barCorners,...i("barCorners"),onChange:l=>b({barCorners:l})})]}),f?/* @__PURE__ */d("p",{role:"alert",className:"text-[12px] text-destructive",children:[f.message," ",f.fix]}):null]})]});}const Ae=[{id:"semaphor",name:"Semaphor",description:"Dense neutral system defaults for embedded analytics.",primary:"#18181b",accent:"#f4f4f5",light:{background:"#ffffff",foreground:"#18181b",muted:"#fafafa",mutedForeground:"#71717a",border:"#e4e4e7",primary:"#18181b",primaryForeground:"#ffffff",accent:"#f4f4f5",accentForeground:"#18181b",selection:"#2563eb",card:"#ffffff",cardForeground:"#18181b",chartPalette:["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#06b6d4"]},dark:{background:"#09090b",foreground:"#fafafa",muted:"#18181b",mutedForeground:"#a1a1aa",border:"#27272a",primary:"#fafafa",primaryForeground:"#09090b",accent:"#27272a",accentForeground:"#fafafa",selection:"#5090f7",card:"#09090b",cardForeground:"#fafafa",chartPalette:["#60a5fa","#34d399","#fbbf24","#f87171","#a78bfa","#22d3ee"]}},{id:"atlas-blue",name:"Atlas Blue",description:"Crisp enterprise blue with restrained neutral surfaces.",primary:"#2563eb",accent:"#dbeafe",light:{background:"#f8fafc",foreground:"#0f172a",muted:"#f1f5f9",mutedForeground:"#64748b",border:"#cbd5e1",primary:"#2563eb",primaryForeground:"#ffffff",accent:"#dbeafe",accentForeground:"#1e3a8a",selection:"#2563eb",card:"#ffffff",cardForeground:"#0f172a",chartPalette:["#2563eb","#0f766e","#ca8a04","#dc2626","#7c3aed","#0891b2"]},dark:{background:"#020617",foreground:"#e2e8f0",muted:"#0f172a",mutedForeground:"#94a3b8",border:"#1e293b",primary:"#60a5fa",primaryForeground:"#020617",accent:"#1e3a8a",accentForeground:"#dbeafe",selection:"#60a5fa",card:"#0f172a",cardForeground:"#e2e8f0",chartPalette:["#60a5fa","#2dd4bf","#facc15","#f87171","#a78bfa","#22d3ee"]}},{id:"field-green",name:"Field Green",description:"Operational green accents with quiet, readable canvases.",primary:"#047857",accent:"#d1fae5",light:{background:"#fbfdfb",foreground:"#10231d",muted:"#f1f5f3",mutedForeground:"#64746d",border:"#d7ded9",primary:"#047857",primaryForeground:"#ffffff",accent:"#d1fae5",accentForeground:"#064e3b",selection:"#047857",card:"#ffffff",cardForeground:"#10231d",chartPalette:["#047857","#2563eb","#d97706","#dc2626","#7c3aed","#0891b2"]},dark:{background:"#071511",foreground:"#e7f4ef",muted:"#10231d",mutedForeground:"#92aaa1",border:"#244139",primary:"#34d399",primaryForeground:"#071511",accent:"#064e3b",accentForeground:"#d1fae5",selection:"#34d399",card:"#0b1d17",cardForeground:"#e7f4ef",chartPalette:["#34d399","#60a5fa","#fbbf24","#f87171","#a78bfa","#22d3ee"]}}];function R(e){const a=fr({organizationAppearance:e?Ee(e).spec:void 0});return Nr(ze(J(a)));}function Nr(e){var a;for(const n of Object.values(e.schemes)){const c=(a=n.components.table)==null?void 0:a.row;c!=null&&c.selectedBackground&&c.selectedBackground===c.hoverBackground&&delete c.selectedBackground;}return e;}function $(e){const a=J({version:ne,mode:e.mode,schemes:e.schemes}),n=cr(a);if(!n.success){const c=n.issues[0];throw new Error(`Invalid Brand Studio appearance at ${c.path}: ${c.message}`);}return n.value;}function xe(e){var n,c;const a=$(e);for(const s of["light","dark"]){const f=(n=a.schemes)==null?void 0:n[s];if(!(f!=null&&f.components))continue;const h=ze(J({version:ne,mode:e.mode,schemes:{light:{tokens:f.tokens,components:{}},dark:{tokens:f.tokens,components:{}}}})).schemes[s].components;for(const x of Sr){const v=f.components[x];if(v)for(const b of wr[x])v[b]!==void 0&&v[b]===((c=h[x])==null?void 0:c[b])&&delete v[b];}}return Ee(a).spec??{version:ne,mode:e.mode};}const Sr=["dashboard","card"],wr={dashboard:["foreground","borderColor"],card:["background","foreground","borderColor"]};function Fr(e,a){const n=Ae.find(s=>s.id===a);if(!n)return e;const c=J(e);return ve(c.schemes.light,n.light),ve(c.schemes.dark,n.dark),c;}function ve(e,a){e.tokens.color.background=a.background,e.tokens.color.foreground=a.foreground,e.tokens.color.muted=a.muted,e.tokens.color.mutedForeground=a.mutedForeground,e.tokens.color.border=a.border,e.tokens.color.input=a.border,e.tokens.color.primary=a.primary,e.tokens.color.primaryForeground=a.primaryForeground,e.tokens.color.accent=a.accent,e.tokens.color.accentForeground=a.accentForeground,e.tokens.color.selection=a.selection,e.tokens.color.card=a.card,e.tokens.color.cardForeground=a.cardForeground,e.components.dashboard.background=a.background,e.components.dashboard.foreground=a.foreground,e.components.dashboard.borderColor=a.border,e.components.card.background=a.card,e.components.card.foreground=a.cardForeground,e.components.card.borderColor=a.border,e.components.interactive.toolbarBackground=a.background,e.components.interactive.background=a.card,e.components.interactive.foreground=a.foreground,e.components.interactive.borderColor=a.border,e.components.chart.palette=[...a.chartPalette],e.components.chart.background=a.card,e.components.chart.foreground=a.foreground,e.components.chart.gridColor=a.border,e.components.chart.axisColor=a.mutedForeground,e.components.table.container.background=a.card,e.components.table.container.borderColor=a.border,e.components.table.header.background=a.muted,e.components.table.header.foreground=a.mutedForeground,e.components.table.header.dividerColor=a.border,e.components.table.row.dividerColor=a.border,e.components.table.row.zebraBackground=a.muted,e.components.table.pagination.background=a.card,e.components.table.pagination.foreground=a.foreground,e.components.table.pagination.borderColor=a.border;}function Y(e,a,n){switch(e.tokens.color[a]=n,a){case"background":e.components.dashboard.background=n,e.components.interactive.toolbarBackground=n;break;case"foreground":e.components.dashboard.foreground=n,e.components.interactive.foreground=n,e.components.pagination.foreground=n,e.components.chart.foreground=n,e.components.table.pagination.foreground=n,e.components.table.subtotal.foreground=n,e.components.table.grandTotal.foreground=n;break;case"card":e.components.card.background=n,e.components.interactive.background=n,e.components.pagination.background=n,e.components.chart.background=n,e.components.table.container.background=n,e.components.table.pagination.background=n;break;case"cardForeground":e.components.card.foreground=n;break;case"muted":e.components.table.header.background=n,e.components.table.row.zebraBackground=n,e.components.table.subtotal.background=n,e.components.table.grandTotal.background=n;break;case"mutedForeground":e.components.table.header.foreground=n,e.components.chart.axisColor=n;break;case"border":e.tokens.color.input=n,e.components.dashboard.borderColor=n,e.components.card.borderColor=n,e.components.interactive.borderColor=n,e.components.pagination.borderColor=n,e.components.chart.gridColor=n,e.components.table.container.borderColor=n,e.components.table.header.dividerColor=n,e.components.table.row.dividerColor=n,e.components.table.grandTotal.borderColor=n,e.components.table.pagination.borderColor=n;break;case"accent":e.components.table.row.hoverBackground=n;break;}}function Pr(e,a,n){switch(e.tokens.radius[a]=n,a){case"table":e.components.table.container.borderRadius=n;break;}}function ze(e){for(const a of["light","dark"]){const n=e.schemes[a],c=n.tokens,s=c.color,f={fontFamily:"",headingFontFamily:"",monoFontFamily:"",baseFontSize:14,density:"comfortable"};c.typography={...f,...c.typography};const h={control:5,card:5,table:5,badge:999};c.radius={...h,...c.radius};const x={dashboardPadding:16,gridGap:12,cardPadding:16,controlGap:8,tableCellX:12,tableCellY:8};c.spacing={...x,...c.spacing};const v={card:"none",popover:"0 12px 32px rgba(15, 23, 42, 0.14)",focusRing:"0 0 0 2px rgba(37, 99, 235, 0.35)"};c.shadow={...v,...c.shadow};const b={dashboard:{background:s.background,foreground:s.foreground,borderColor:s.border},card:{background:s.card,foreground:s.cardForeground,borderColor:s.border},interactive:{toolbarBackground:s.background,background:s.card,foreground:s.foreground,borderColor:s.border},chart:{palette:[],background:s.card,foreground:s.foreground,gridColor:s.border,axisColor:s.mutedForeground,barRadius:0},table:ke(s,c),pagination:{background:s.card,foreground:s.foreground,borderColor:s.border}};n.components=Object.fromEntries(Object.entries({...b,...n.components}).map(([p,y])=>[p,{...b[p],...y}]));const i={palette:[],background:s.card,foreground:s.foreground,gridColor:s.border,axisColor:s.mutedForeground,barRadius:2};n.components.chart={...i,...n.components.chart},n.components.table={...ke(s,c),...n.components.table};}return e;}function ke(e,a){return{density:a.typography.density,container:{background:e.card,borderColor:e.border,borderRadius:a.radius.table,shadow:a.shadow.card},header:{background:e.muted,foreground:e.mutedForeground,dividerColor:e.border,fontWeight:600,uppercase:!0,sticky:!0},row:{height:32,dividerColor:e.border,zebra:!1,zebraBackground:e.muted,hoverBackground:e.accent},cell:{paddingX:a.spacing.tableCellX,paddingY:a.spacing.tableCellY,verticalAlign:"middle",wrap:"nowrap"},subtotal:{background:e.muted,foreground:e.foreground,fontWeight:600},grandTotal:{background:e.muted,foreground:e.foreground,fontWeight:700,borderColor:e.border},pagination:{background:e.card,foreground:e.foreground,borderColor:e.border}};}function J(e){return JSON.parse(JSON.stringify(e));}const Or=[["background","Canvas"],["foreground","Text"],["card","Card"],["cardForeground","Card text"],["primary","Primary"],["primaryForeground","Primary text"],["accent","Accent"],["accentForeground","Accent text"],["muted","Muted"],["mutedForeground","Muted text"],["border","Border"],["positive","Positive"],["negative","Negative"],["warning","Warning"],["info","Info"]],W=sr,Tr=["#ffffff","#f8fafc","#f4f4f5","#e4e4e7","#18181b","#09090b","#2563eb","#0f766e","#047857","#d97706","#dc2626","#7c3aed"];function Xr({appearance:e,previewTitle:a,isLoading:n=!1,isSaving:c=!1,error:s=null,className:f,onDraftChange:h,onSave:x,onClearConfig:v,onCancel:b}){const[i,p]=m.useState(null),[y,F]=m.useState("light"),[l,A]=m.useState(!1),[De,O]=m.useState("idle"),[ce,Ie]=m.useState(!1),[z,U]=m.useState(""),[D,C]=m.useState(null),se=m.useRef(null),I=m.useRef(h),T=m.useRef(!1);m.useEffect(()=>{I.current=h;},[h]),m.useEffect(()=>{if(e===void 0){T.current=!0,p(null);return;}const o=R(e);T.current=!0,p(o),F("light"),C(null);},[e]),m.useEffect(()=>{var o;if(i){if(T.current){T.current=!1;return;}try{const t=$(i);(o=I.current)==null||o.call(I,t),C(null);}catch(t){C(t instanceof Error?t.message:"Appearance is invalid");}}},[i]);const u=i==null?void 0:i.schemes[y],L=c||l,_e=m.useMemo(()=>u?Er(u.tokens.radius.control):void 0,[u]),je=o=>{p(t=>{if(!t)return t;const k=Ar(t);return o(k),k;});},g=o=>{je(t=>{o(t.schemes[y]);});},_=m.useMemo(()=>{if(!i)return null;try{return xe(i);}catch{return null;}},[i]),$e=o=>{if(!_)return null;const t=ur({spec:_,edit:o,mode:y});return t.ok?(p(R(t.spec)),null):t.refusal;},Je=async()=>{if(!i||!x)return;let o;try{o=xe(i);}catch(t){C(t instanceof Error?t.message:"Appearance is invalid");return;}A(!0);try{await x(o);}finally{A(!1);}},Ue=()=>{const o=R(null);O("idle"),p(o);},Le=async()=>{if(v){A(!0),C(null),O("idle");try{await v(),T.current=!0,p(R(null)),F("light");}catch(o){C(o instanceof Error?o.message:"Unable to clear organization appearance");}finally{A(!1);}}},le=m.useCallback(()=>i?JSON.stringify($(i),null,2):"",[i]),Me=o=>{if(Ie(o),o)try{U(le()),C(null);}catch(t){C(t instanceof Error?t.message:"Appearance is invalid");}},Ve=async()=>{if(i)try{const o=ce&&z?z:le();await navigator.clipboard.writeText(o),C(null),O("copied");}catch(o){C(o instanceof Error?o.message:"Unable to copy brand spec");}},ie=o=>{const t=JSON.parse(o),k=R(t),w=$(k);O("idle"),F("light"),p(k),U(JSON.stringify(w,null,2));},Ge=()=>{try{ie(z);}catch(o){C(o instanceof Error?o.message:"Brand spec must be valid JSON");}},He=async o=>{var k;const t=(k=o.target.files)==null?void 0:k[0];if(o.target.value="",!!t)try{ie(await zr(t));}catch(w){C(w instanceof Error?w.message:"Uploaded file must be a valid brand spec");}};return/* @__PURE__ */d("div",{className:te("flex min-h-0 flex-1 flex-col bg-background text-foreground",f),style:_e,children:[/* @__PURE__ */d("header",{className:"flex h-11 shrink-0 items-start gap-3 border-b border-border/60 px-4 pt-2",children:[/* @__PURE__ */r("div",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-control border border-border/70",children:/* @__PURE__ */r(H,{className:"h-3.5 w-3.5"})}),/* @__PURE__ */d("div",{className:"min-w-0 flex-1",children:[/* @__PURE__ */r("h2",{className:"truncate text-[13px] font-semibold leading-tight",children:"Brand Studio"}),/* @__PURE__ */d("p",{className:"truncate text-[11px] leading-tight text-muted-foreground",children:["Previewing ",a||"current dashboard"]})]}),/* @__PURE__ */d(ye,{open:ce,onOpenChange:Me,children:[/* @__PURE__ */r(Ne,{asChild:!0,children:/* @__PURE__ */d(S,{type:"button",size:"xs",variant:"ghost",disabled:!i,children:[/* @__PURE__ */r(qe,{className:"h-3.5 w-3.5"}),"Brand Spec"]})}),/* @__PURE__ */d(Se,{align:"end",sideOffset:6,className:"z-[60] w-[min(520px,calc(100vw-24px))] rounded-control p-2",children:[/* @__PURE__ */d("div",{className:"mb-2 flex items-center justify-between gap-2",children:[/* @__PURE__ */d("div",{className:"min-w-0",children:[/* @__PURE__ */r("div",{className:"text-[12px] font-medium",children:"Brand spec"}),/* @__PURE__ */r("div",{className:"text-[11px] text-muted-foreground",children:"Edit, apply, copy, or upload your brand spec."})]}),/* @__PURE__ */d("div",{className:"flex shrink-0 items-center gap-1",children:[/* @__PURE__ */d(S,{type:"button",size:"xs",variant:"ghost",onClick:Ve,children:[/* @__PURE__ */r(xr,{className:"h-3.5 w-3.5"}),De==="copied"?"Copied":"Copy"]}),/* @__PURE__ */d(S,{type:"button",size:"xs",variant:"ghost",onClick:()=>{var o;return(o=se.current)==null?void 0:o.click();},children:[/* @__PURE__ */r(Ke,{className:"h-3.5 w-3.5"}),"Upload"]}),/* @__PURE__ */r(S,{type:"button",size:"xs",onClick:Ge,children:"Apply"})]})]}),/* @__PURE__ */r("div",{className:"h-[320px] overflow-hidden rounded-control border border-input",children:/* @__PURE__ */r(Xe,{ariaLabel:"Brand spec",value:z,onValueChange:o=>{U(o),O("idle");},language:"json",embedded:!0,hideLineNumbers:!0,dense:!0})})]})]}),/* @__PURE__ */r("input",{ref:se,"aria-label":"Upload brand spec",type:"file",accept:"application/json,.json",className:"sr-only",onChange:He}),/* @__PURE__ */d(S,{type:"button",size:"xs",variant:"ghost",onClick:Ue,disabled:!i,children:[/* @__PURE__ */r(we,{className:"h-3.5 w-3.5"}),"Reset"]}),v&&/* @__PURE__ */d(S,{type:"button",size:"xs",variant:"ghost",onClick:Le,disabled:L,children:[/* @__PURE__ */r(hr,{className:"h-3.5 w-3.5"}),"No config"]}),/* @__PURE__ */d(S,{type:"button",size:"xs",onClick:Je,disabled:!i||L||!!D||!x,children:[L?/* @__PURE__ */r(fe,{className:"h-3.5 w-3.5 animate-spin"}):/* @__PURE__ */r(gr,{className:"h-3.5 w-3.5"}),"Save"]}),b&&/* @__PURE__ */r("button",{type:"button","aria-label":"Close Brand Studio",className:"flex h-7 w-7 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",onClick:b,children:/* @__PURE__ */r(Ze,{className:"h-3.5 w-3.5"})})]}),/* @__PURE__ */d("div",{className:"flex shrink-0 items-center justify-between border-b border-border/60 px-4 py-2",children:[/* @__PURE__ */r("div",{className:"flex items-center gap-2 text-[12px] text-muted-foreground",children:D?/* @__PURE__ */d(ue,{children:[/* @__PURE__ */r(ge,{className:"h-3.5 w-3.5 text-destructive"}),"Preview keeps the last valid draft"]}):/* @__PURE__ */d(ue,{children:[/* @__PURE__ */r(Qe,{className:"h-3.5 w-3.5 text-emerald-500"}),"Draft is applied to the live dashboard preview"]})}),/* @__PURE__ */r("div",{className:"inline-flex h-7 items-center overflow-hidden rounded-control border border-border/70",children:["light","dark"].map(o=>/* @__PURE__ */r("button",{type:"button",className:te("h-full px-2.5 text-[12px] capitalize transition-colors",y===o?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>F(o),children:o},o))})]}),D&&/* @__PURE__ */r("div",{className:"border-b border-destructive/20 bg-destructive/5 px-4 py-2 text-[12px] text-destructive",children:D}),n?/* @__PURE__ */r("div",{className:"flex flex-1 items-center justify-center",children:/* @__PURE__ */r(fe,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):s?/* @__PURE__ */r("div",{className:"p-4 text-[13px] text-muted-foreground",children:s}):i&&u?/* @__PURE__ */d(er,{defaultValue:"style",className:"flex min-h-0 flex-1 flex-col",children:[/* @__PURE__ */r("div",{className:"shrink-0 px-4 pt-3",children:/* @__PURE__ */d(rr,{variant:"underline",className:"w-full gap-5",children:[/* @__PURE__ */r(V,{value:"style",children:"Style"}),/* @__PURE__ */r(V,{value:"surfaces",children:"Surfaces"}),/* @__PURE__ */r(V,{value:"data",children:"Data"})]})}),/* @__PURE__ */d(or,{className:"min-h-0 flex-1",children:[/* @__PURE__ */d(G,{value:"style",className:"m-0 p-4",children:[/* @__PURE__ */r(P,{icon:H,title:"Presets",description:"Start from a full light and dark appearance.",children:/* @__PURE__ */r("div",{className:"grid grid-cols-1 gap-2",children:Ae.map(o=>/* @__PURE__ */d("button",{type:"button",className:"flex items-center gap-3 rounded-control border border-border/70 px-3 py-2 text-left hover:bg-muted/60",onClick:()=>{const t=Fr(i,o.id);p(t);},children:[/* @__PURE__ */d("div",{className:"flex h-7 w-10 overflow-hidden rounded-control border border-border/70",children:[/* @__PURE__ */r("span",{className:"h-full flex-1",style:{backgroundColor:o.primary}}),/* @__PURE__ */r("span",{className:"h-full flex-1",style:{backgroundColor:o.accent}})]}),/* @__PURE__ */d("span",{className:"min-w-0 flex-1",children:[/* @__PURE__ */r("span",{className:"block text-[13px] font-medium",children:o.name}),/* @__PURE__ */r("span",{className:"block truncate text-[12px] text-muted-foreground",children:o.description})]})]},o.id))})}),/* @__PURE__ */r(P,{icon:H,title:"Color",description:`Editing the ${y} scheme.`,children:/* @__PURE__ */r("div",{className:"grid grid-cols-2 gap-2",children:Or.map(([o,t])=>/* @__PURE__ */r(N,{label:t,value:u.tokens.color[o],onChange:k=>g(w=>{Y(w,o,k);})},o))})}),/* @__PURE__ */d(P,{icon:ar,title:"Typography",description:"Fonts and density used by dashboard and workflow chrome.",children:[/* @__PURE__ */r(Br,{value:u.tokens.typography.fontFamily,onChange:o=>g(t=>{t.tokens.typography.fontFamily=o,t.tokens.typography.headingFontFamily=o;})}),/* @__PURE__ */d("div",{className:"grid grid-cols-2 gap-2",children:[/* @__PURE__ */r(K,{label:"Base size",value:u.tokens.typography.baseFontSize,min:11,max:18,onChange:o=>g(t=>{t.tokens.typography.baseFontSize=o;})}),/* @__PURE__ */r(X,{label:"Density",value:u.tokens.typography.density,options:[["compact","Compact"],["comfortable","Comfortable"],["spacious","Spacious"]],onChange:o=>g(t=>{t.tokens.typography.density=o,t.components.table.density=t.tokens.typography.density;})})]})]})]}),/* @__PURE__ */d(G,{value:"surfaces",className:"m-0 p-4",children:[/* @__PURE__ */d(P,{icon:mr,title:"Layout",description:"Canvas, grid, and card rhythm for embedded dashboards.",children:[_?/* @__PURE__ */r(yr,{spec:_,mode:y,onEdit:$e}):null,/* @__PURE__ */d("div",{className:"grid grid-cols-3 gap-2",children:[/* @__PURE__ */r(K,{label:"Card pad",tooltip:"Inner padding inside card/widget frames around titles, controls, and visual content.",value:u.tokens.spacing.cardPadding,min:0,max:32,onChange:o=>g(t=>{t.tokens.spacing.cardPadding=o;})}),/* @__PURE__ */r(K,{label:"Table radius",tooltip:"Corner radius for table containers, table chrome, and table pagination surfaces.",value:u.tokens.radius.table,min:0,max:12,onChange:o=>g(t=>{Pr(t,"table",o);})})]})]}),/* @__PURE__ */r(P,{icon:ge,title:"Filters and Controls",description:"Dashboard filter/control toolbar, chip states, menus, and settings panels.",children:/* @__PURE__ */d("div",{className:"grid grid-cols-2 gap-2",children:[/* @__PURE__ */r(N,{label:"Toolbar background",tooltip:"Background color for the dashboard filter/control toolbar strip. This is separate from chip state colors.",value:u.components.interactive.toolbarBackground||u.tokens.color.background,onChange:o=>g(t=>{t.components.interactive.toolbarBackground=o;})}),/* @__PURE__ */r(N,{label:"Default state",tooltip:"Unselected filter/control chips plus the base surface for their menus, dialogs, and pagination fallback.",value:u.components.interactive.background||u.tokens.color.card,onChange:o=>g(t=>{t.components.interactive.background=o,t.components.pagination.background=o;})}),/* @__PURE__ */r(N,{label:"Border",tooltip:"Border color for filter/control chips, runtime inputs, settings panels, and related popover chrome.",value:u.components.interactive.borderColor||u.tokens.color.border,onChange:o=>g(t=>{t.components.interactive.borderColor=o,t.components.pagination.borderColor=o;})}),/* @__PURE__ */r(N,{label:"Selected state",tooltip:"Selected filter/control chips and hover feedback. This keeps a lighter default state and a stronger selected state.",value:u.tokens.color.accent,onChange:o=>g(t=>{Y(t,"accent",o);})})]})})]}),/* @__PURE__ */d(G,{value:"data",className:"m-0 p-4",children:[/* @__PURE__ */d(P,{icon:nr,title:"Charts",description:"Palette and semantic chart text/grid colors.",children:[/* @__PURE__ */r("div",{className:"grid grid-cols-3 gap-2",children:u.components.chart.palette.map((o,t)=>/* @__PURE__ */d("div",{className:"flex items-end gap-1",children:[/* @__PURE__ */r("div",{className:"min-w-0 flex-1",children:/* @__PURE__ */r(N,{label:`Series ${t+1}`,value:o||"#000000",onChange:k=>g(w=>{w.components.chart.palette[t]=k;})})}),u.components.chart.palette.length>1?/* @__PURE__ */r(S,{size:"xs",variant:"ghost","aria-label":`Remove series ${t+1} color`,className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground",onClick:()=>g(k=>{k.components.chart.palette.splice(t,1);}),children:"×"}):null]},t))}),u.components.chart.palette.length<12?/* @__PURE__ */r(S,{size:"xs",variant:"outline",className:"w-fit",onClick:()=>g(o=>{o.components.chart.palette.push("#64748b");}),children:"Add a color"}):null,/* @__PURE__ */d("div",{className:"grid grid-cols-2 gap-2",children:[/* @__PURE__ */r(N,{label:"Grid",value:u.components.chart.gridColor,onChange:o=>g(t=>{t.components.chart.gridColor=o;})}),/* @__PURE__ */r(N,{label:"Axis",value:u.components.chart.axisColor,onChange:o=>g(t=>{t.components.chart.axisColor=o;})})]})]}),/* @__PURE__ */d(P,{icon:tr,title:"Tables",description:"All tables share this appearance.",children:[/* @__PURE__ */d("div",{className:"grid grid-cols-2 gap-2",children:[/* @__PURE__ */r(X,{label:"Density",value:u.components.table.density,options:[["compact","Compact"],["comfortable","Comfortable"],["spacious","Spacious"]],onChange:o=>g(t=>{t.components.table.density=o;})}),/* @__PURE__ */r(X,{label:"Cell wrap",value:u.components.table.cell.wrap,options:[["nowrap","No wrap"],["wrap","Wrap"]],onChange:o=>g(t=>{t.components.table.cell.wrap=o;})})]}),/* @__PURE__ */d("div",{className:"grid grid-cols-2 gap-2",children:[/* @__PURE__ */r(N,{label:"Header",value:u.components.table.header.background,onChange:o=>g(t=>{t.components.table.header.background=o;})}),/* @__PURE__ */r(N,{label:"Divider",value:u.components.table.row.dividerColor,onChange:o=>g(t=>{t.components.table.row.dividerColor=o,t.components.table.header.dividerColor=o;})}),/* @__PURE__ */r(N,{label:"Selection",value:u.tokens.color.selection,onChange:o=>g(t=>{Y(t,"selection",o);})})]}),/* @__PURE__ */r(Z,{label:"Zebra rows",checked:u.components.table.row.zebra,onCheckedChange:o=>g(t=>{t.components.table.row.zebra=o;})}),/* @__PURE__ */r(Z,{label:"Sticky headers",checked:u.components.table.header.sticky,onCheckedChange:o=>g(t=>{t.components.table.header.sticky=o;})}),/* @__PURE__ */r(Z,{label:"Uppercase headers",checked:u.components.table.header.uppercase,onCheckedChange:o=>g(t=>{t.components.table.header.uppercase=o;})})]})]})]})]}):null]});}function P({icon:e,title:a,description:n,children:c}){return/* @__PURE__ */d("section",{className:"mb-6 last:mb-0",children:[/* @__PURE__ */d("div",{className:"mb-3 flex items-start gap-2",children:[/* @__PURE__ */r("div",{className:"mt-0.5 flex h-5 w-5 items-center justify-center rounded-control border border-border/70",children:/* @__PURE__ */r(e,{className:"h-3 w-3 text-muted-foreground"})}),/* @__PURE__ */d("div",{className:"min-w-0",children:[/* @__PURE__ */r("h3",{className:"text-[13px] font-semibold",children:a}),/* @__PURE__ */r("p",{className:"mt-0.5 text-[12px] leading-4 text-muted-foreground",children:n})]})]}),/* @__PURE__ */r("div",{className:"space-y-2",children:c}),/* @__PURE__ */r(dr,{className:"mt-5 bg-border/60"})]});}function Br({value:e,onChange:a}){var c;const n=(c=W.find(s=>s.value===e))==null?void 0:c.id;return/* @__PURE__ */d("div",{children:[/* @__PURE__ */r(E,{className:"mb-1 block text-[11px] font-normal text-muted-foreground",children:"Font family"}),/* @__PURE__ */d("div",{className:"grid grid-cols-[minmax(0,1fr)_150px] gap-2",children:[/* @__PURE__ */d(Pe,{value:n,onValueChange:s=>{const f=W.find(h=>h.id===s);f&&a(f.value);},children:[/* @__PURE__ */r(Oe,{size:"xs","aria-label":"Font family preset",children:/* @__PURE__ */r(Te,{placeholder:"Select font"})}),/* @__PURE__ */r(Be,{children:W.map(s=>/* @__PURE__ */r(Re,{value:s.id,children:s.label},s.id))})]}),/* @__PURE__ */r("div",{className:"flex h-7 items-center rounded-control border border-border/60 bg-muted/30 px-2 text-[12px]",style:{fontFamily:e},children:"Aa 123"})]})]});}function N({label:e,tooltip:a,value:n,onChange:c}){const[s,f]=m.useState(!1),[h,x]=m.useState(n),v=Rr(n),b=n!==h,i=p=>{f(p),p&&x(n);};return/* @__PURE__ */d("div",{className:"block",children:[/* @__PURE__ */d("div",{className:"mb-1 flex items-center gap-1",children:[/* @__PURE__ */r(E,{className:"text-[11px] font-normal text-muted-foreground",children:e}),a?/* @__PURE__ */r(Q,{children:/* @__PURE__ */d(ee,{children:[/* @__PURE__ */r(re,{asChild:!0,children:/* @__PURE__ */r("button",{type:"button","aria-label":`${e} details`,className:"inline-flex h-3.5 w-3.5 items-center justify-center rounded-control text-muted-foreground/70 transition-colors hover:bg-muted hover:text-foreground",children:/* @__PURE__ */r(Fe,{className:"h-3 w-3"})})}),/* @__PURE__ */r(oe,{side:"top",className:"max-w-64",children:a})]})}):null]}),/* @__PURE__ */d("div",{className:"flex h-7 items-center overflow-hidden rounded-control border border-input bg-background",children:[/* @__PURE__ */d(ye,{open:s,onOpenChange:i,children:[/* @__PURE__ */r(Ne,{asChild:!0,children:/* @__PURE__ */r("button",{type:"button","aria-label":`Open ${e} color picker`,className:"ml-1 flex h-5 w-5 shrink-0 items-center justify-center rounded-control border border-border/70",style:{backgroundColor:n},children:/* @__PURE__ */r("span",{className:"sr-only",children:e})})}),/* @__PURE__ */d(Se,{align:"start",sideOffset:6,className:"z-[60] w-64 rounded-control p-2",children:[/* @__PURE__ */d("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */d("label",{className:"relative flex h-16 w-16 shrink-0 cursor-pointer items-center justify-center overflow-hidden rounded-control border border-border/70",style:{backgroundColor:n},children:[/* @__PURE__ */r("input",{"aria-label":`${e} native color picker`,type:"color",value:v,onChange:p=>c(p.target.value),className:"absolute inset-0 h-full w-full cursor-pointer opacity-0"}),/* @__PURE__ */r("span",{className:"rounded-control bg-black/45 p-1 text-white shadow-sm",children:/* @__PURE__ */r(vr,{className:"h-3.5 w-3.5"})})]}),/* @__PURE__ */d("div",{className:"min-w-0 flex-1",children:[/* @__PURE__ */d("div",{className:"mb-1 flex items-center justify-between gap-2",children:[/* @__PURE__ */r(E,{className:"block text-[11px] font-normal text-muted-foreground",children:"Color value"}),/* @__PURE__ */r(Q,{children:/* @__PURE__ */d(ee,{children:[/* @__PURE__ */r(re,{asChild:!0,children:/* @__PURE__ */r("button",{type:"button","aria-label":`Reset ${e} color to previous value`,disabled:!b,className:"inline-flex h-5 w-5 items-center justify-center rounded-control text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-35",onClick:()=>c(h),children:/* @__PURE__ */r(we,{className:"h-3 w-3"})})}),/* @__PURE__ */r(oe,{side:"top",children:"Reset to previous value"})]})})]}),/* @__PURE__ */r(ae,{size:"xs","aria-label":`${e} popover color value`,value:n,onChange:p=>c(p.target.value),className:"font-mono"})]})]}),/* @__PURE__ */r("div",{className:"mt-2 grid grid-cols-6 gap-1",children:Tr.map(p=>/* @__PURE__ */r("button",{type:"button","aria-label":`Set ${e} to ${p}`,className:te("h-6 rounded-control border border-border/70 shadow-sm",n.toLowerCase()===p&&"ring-2 ring-ring"),style:{backgroundColor:p},onClick:()=>c(p)},p))})]})]}),/* @__PURE__ */r(ae,{size:"xs","aria-label":`${e} color value`,value:n,onChange:p=>c(p.target.value),className:"h-full border-0 px-2 font-mono shadow-none focus-visible:border-0"})]})]});}function Rr(e){const a=lr(e);return a?`#${q(a.r)}${q(a.g)}${q(a.b)}`:"#000000";}function q(e){return Math.round(e).toString(16).padStart(2,"0");}function K({label:e,tooltip:a,value:n,min:c,max:s,onChange:f}){const h=m.useId();return/* @__PURE__ */d("div",{className:"block",children:[/* @__PURE__ */d("div",{className:"mb-1 flex items-center gap-1",children:[/* @__PURE__ */r(E,{htmlFor:h,className:"text-[11px] font-normal text-muted-foreground",children:e}),a?/* @__PURE__ */r(Q,{children:/* @__PURE__ */d(ee,{children:[/* @__PURE__ */r(re,{asChild:!0,children:/* @__PURE__ */r("button",{type:"button","aria-label":`${e} details`,className:"inline-flex h-3.5 w-3.5 items-center justify-center rounded-control text-muted-foreground/70 transition-colors hover:bg-muted hover:text-foreground",children:/* @__PURE__ */r(Fe,{className:"h-3 w-3"})})}),/* @__PURE__ */r(oe,{side:"top",className:"max-w-56",children:a})]})}):null]}),/* @__PURE__ */r(ae,{id:h,size:"xs",type:"number",min:c,max:s,value:n,onChange:x=>{const v=Number(x.target.value);Number.isNaN(v)||f(v);}})]});}function X({label:e,value:a,options:n,onChange:c}){return/* @__PURE__ */d("div",{children:[/* @__PURE__ */r(E,{className:"mb-1 block text-[11px] font-normal text-muted-foreground",children:e}),/* @__PURE__ */d(Pe,{value:a,onValueChange:c,children:[/* @__PURE__ */r(Oe,{size:"xs",children:/* @__PURE__ */r(Te,{})}),/* @__PURE__ */r(Be,{children:n.map(([s,f])=>/* @__PURE__ */r(Re,{value:s,children:f},s))})]})]});}function Z({label:e,checked:a,onCheckedChange:n}){return/* @__PURE__ */d("div",{className:"flex h-8 items-center justify-between rounded-control border border-border/60 px-2",children:[/* @__PURE__ */r("span",{className:"text-[12px]",children:e}),/* @__PURE__ */r(Ce,{size:"xs",checked:a,onCheckedChange:n})]});}function Er(e){const a=`${Number((e/16).toFixed(4))}rem`;return{"--semaphor-radius":a,"--semaphor-control-radius":a};}function Ar(e){return JSON.parse(JSON.stringify(e));}function zr(e){return typeof e.text=="function"?e.text():new Promise((a,n)=>{const c=new FileReader();c.onload=()=>a(String(c.result??"")),c.onerror=()=>n(c.error??new Error("Unable to read file")),c.readAsText(e);});}export{Ae as BRAND_STUDIO_PRESETS,Xr as BrandStudioEditor,Fr as applyBrandStudioPreset,xe as brandStudioSaveSpec,$ as buildAppearanceSpecFromDraft,R as createBrandStudioDraft};
|
|
11
|
+
*/const qr=Ie("Pipette",[["path",{d:"m2 22 1-1h3l9-9",key:"1sre89"}],["path",{d:"M3 21v-3l9-9",key:"hpe2y6"}],["path",{d:"m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z",key:"196du1"}]]),V={modern:{label:"Modern",values:{borders:"horizontal",cell:{paddingX:16,paddingY:8,fontSize:13},header:{paddingY:8,fontSize:10,fontWeight:500,uppercase:!0,wrap:!1,filled:!1}}},report:{label:"Report",values:{borders:"horizontal",cell:{paddingX:10,paddingY:5,fontSize:12},header:{paddingY:6,fontSize:12,fontWeight:600,uppercase:!1,wrap:!0,filled:!0}}},compact:{label:"Compact",values:{borders:"horizontal",cell:{paddingX:6,paddingY:3,fontSize:12},header:{paddingY:4,fontSize:11,fontWeight:600,uppercase:!1,wrap:!1,filled:!1}}}},qe=Object.keys(V);function $e(e,n){const{borders:o,cell:a,header:t}=V[e].values,{filled:l,...s}=t;return{borders:o,cell:{...a},header:{...s,background:l?n.accent??"#f4f4f5":"transparent",foreground:l?n.foreground:void 0}};}const ge=[{id:"semaphor",name:"Semaphor",description:"Dense neutral system defaults for embedded analytics.",primary:"#18181b",accent:"#f4f4f5",light:{background:"#ffffff",foreground:"#18181b",muted:"#fafafa",mutedForeground:"#71717a",border:"#e4e4e7",primary:"#18181b",primaryForeground:"#ffffff",accent:"#f4f4f5",accentForeground:"#18181b",selection:"#2563eb",card:"#ffffff",cardForeground:"#18181b",chartPalette:["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#06b6d4"]},dark:{background:"#09090b",foreground:"#fafafa",muted:"#18181b",mutedForeground:"#a1a1aa",border:"#27272a",primary:"#fafafa",primaryForeground:"#09090b",accent:"#27272a",accentForeground:"#fafafa",selection:"#5090f7",card:"#09090b",cardForeground:"#fafafa",chartPalette:["#60a5fa","#34d399","#fbbf24","#f87171","#a78bfa","#22d3ee"]}},{id:"atlas-blue",name:"Atlas Blue",description:"Crisp enterprise blue with restrained neutral surfaces.",primary:"#2563eb",accent:"#dbeafe",light:{background:"#f8fafc",foreground:"#0f172a",muted:"#f1f5f9",mutedForeground:"#64748b",border:"#cbd5e1",primary:"#2563eb",primaryForeground:"#ffffff",accent:"#dbeafe",accentForeground:"#1e3a8a",selection:"#2563eb",card:"#ffffff",cardForeground:"#0f172a",chartPalette:["#2563eb","#0f766e","#ca8a04","#dc2626","#7c3aed","#0891b2"]},dark:{background:"#020617",foreground:"#e2e8f0",muted:"#0f172a",mutedForeground:"#94a3b8",border:"#1e293b",primary:"#60a5fa",primaryForeground:"#020617",accent:"#1e3a8a",accentForeground:"#dbeafe",selection:"#60a5fa",card:"#0f172a",cardForeground:"#e2e8f0",chartPalette:["#60a5fa","#2dd4bf","#facc15","#f87171","#a78bfa","#22d3ee"]}},{id:"field-green",name:"Field Green",description:"Operational green accents with quiet, readable canvases.",primary:"#047857",accent:"#d1fae5",light:{background:"#fbfdfb",foreground:"#10231d",muted:"#f1f5f3",mutedForeground:"#64746d",border:"#d7ded9",primary:"#047857",primaryForeground:"#ffffff",accent:"#d1fae5",accentForeground:"#064e3b",selection:"#047857",card:"#ffffff",cardForeground:"#10231d",chartPalette:["#047857","#2563eb","#d97706","#dc2626","#7c3aed","#0891b2"]},dark:{background:"#071511",foreground:"#e7f4ef",muted:"#10231d",mutedForeground:"#92aaa1",border:"#244139",primary:"#34d399",primaryForeground:"#071511",accent:"#064e3b",accentForeground:"#d1fae5",selection:"#34d399",card:"#0b1d17",cardForeground:"#e7f4ef",chartPalette:["#34d399","#60a5fa","#fbbf24","#f87171","#a78bfa","#22d3ee"]}}];function j(e){const n=Ke({organizationAppearance:e?Xe(e).spec:void 0});return Qr(Ze(re(n)));}function Qr(e){var n;for(const o of Object.values(e.schemes)){const a=(n=o.components.table)==null?void 0:n.row;a!=null&&a.selectedBackground&&a.selectedBackground===a.hoverBackground&&delete a.selectedBackground;}return e;}function fe(e){const n=re({version:ce,mode:e.mode,schemes:e.schemes}),o=Yr(n);if(!o.success)throw new Qe(o.issues[0]);return o.value;}class Qe extends Error{constructor(o){super(`Invalid Brand Studio appearance at ${o.path}: ${o.message}`);De(this,"issue");this.name="BrandStudioDraftError",this.issue=o;}}function Zr(e){return Ke({organizationAppearance:ee(e)});}function ee(e){var o,a;const n=fe(e);for(const t of["light","dark"]){const l=(o=n.schemes)==null?void 0:o[t];if(!(l!=null&&l.components))continue;const s=Ze(re({version:ce,mode:e.mode,schemes:{light:{tokens:l.tokens,components:{}},dark:{tokens:l.tokens,components:{}}}})).schemes[t].components;for(const m of en){const u=l.components[m];if(u)for(const d of rn[m])u[d]!==void 0&&u[d]===((a=s[m])==null?void 0:a[d])&&delete u[d];}}return Xe(n).spec??{version:ce,mode:e.mode};}const en=["dashboard","card"],rn={dashboard:["foreground","borderColor"],card:["background","foreground","borderColor"]};function nn(e,n){const o=ge.find(t=>t.id===n);if(!o)return e;const a=re(e);return Le(a.schemes.light,o.light),Le(a.schemes.dark,o.dark),a;}function Le(e,n){e.tokens.color.background=n.background,e.tokens.color.foreground=n.foreground,e.tokens.color.muted=n.muted,e.tokens.color.mutedForeground=n.mutedForeground,e.tokens.color.border=n.border,e.tokens.color.input=n.border,e.tokens.color.primary=n.primary,e.tokens.color.primaryForeground=n.primaryForeground,e.tokens.color.accent=n.accent,e.tokens.color.accentForeground=n.accentForeground,e.tokens.color.selection=n.selection,e.tokens.color.card=n.card,e.tokens.color.cardForeground=n.cardForeground,e.components.dashboard.background=n.background,e.components.dashboard.foreground=n.foreground,e.components.dashboard.borderColor=n.border,e.components.card.background=n.card,e.components.card.foreground=n.cardForeground,e.components.card.borderColor=n.border,e.components.interactive.toolbarBackground=n.background,e.components.interactive.background=n.card,e.components.interactive.foreground=n.foreground,e.components.interactive.borderColor=n.border,e.components.chart.palette=[...n.chartPalette],e.components.chart.background=n.card,e.components.chart.foreground=n.foreground,e.components.chart.gridColor=n.border,e.components.chart.axisColor=n.mutedForeground;}function ue(e,n,o){switch(e.tokens.color[n]=o,n){case"background":e.components.dashboard.background=o,e.components.interactive.toolbarBackground=o;break;case"foreground":e.components.dashboard.foreground=o,e.components.interactive.foreground=o,e.components.pagination.foreground=o,e.components.chart.foreground=o;break;case"card":e.components.card.background=o,e.components.interactive.background=o,e.components.pagination.background=o,e.components.chart.background=o;break;case"cardForeground":e.components.card.foreground=o;break;case"mutedForeground":e.components.chart.axisColor=o;break;case"border":e.tokens.color.input=o,e.components.dashboard.borderColor=o,e.components.card.borderColor=o,e.components.interactive.borderColor=o,e.components.pagination.borderColor=o,e.components.chart.gridColor=o;break;}}function on(e,n,o){e.tokens.radius[n]=o;}function Ze(e){for(const n of["light","dark"]){const o=e.schemes[n],a=o.tokens,t=a.color,l={fontFamily:"",headingFontFamily:"",monoFontFamily:"",baseFontSize:14,density:"comfortable"};a.typography={...l,...a.typography};const s={control:5,card:5,table:5,badge:999};a.radius={...s,...a.radius};const m={dashboardPadding:16,gridGap:12,cardPadding:16,controlGap:8,tableCellX:16,tableCellY:8};a.spacing={...m,...a.spacing};const u={card:"none",popover:"0 12px 32px rgba(15, 23, 42, 0.14)",focusRing:"0 0 0 2px rgba(37, 99, 235, 0.35)"};a.shadow={...u,...a.shadow};const d={dashboard:{background:t.background,foreground:t.foreground,borderColor:t.border},card:{background:t.card,foreground:t.cardForeground,borderColor:t.border},interactive:{toolbarBackground:t.background,background:t.card,foreground:t.foreground,borderColor:t.border},chart:{palette:[],background:t.card,foreground:t.foreground,gridColor:t.border,axisColor:t.mutedForeground,barRadius:0},table:{},documentTable:{},pagination:{background:t.card,foreground:t.foreground,borderColor:t.border}};o.components=Object.fromEntries(Object.entries({...d,...o.components}).map(([f,b])=>[f,{...d[f],...b}]));const c={palette:[],background:t.card,foreground:t.foreground,gridColor:t.border,axisColor:t.mutedForeground,barRadius:2};o.components.chart={...c,...o.components.chart};}return e;}function re(e){return JSON.parse(JSON.stringify(e));}function we(e,n){if(e===void 0||n===void 0)return e===n;if(e.trim().toLowerCase()===n.trim().toLowerCase())return!0;const o=be(e),a=be(n);return!o||!a?!1:Math.round(o.r)===Math.round(a.r)&&Math.round(o.g)===Math.round(a.g)&&Math.round(o.b)===Math.round(a.b);}function an(e,n){var o,a;return(a=(o=Jr.schemes[e].tokens)==null?void 0:o.color)==null?void 0:a[n];}function tn(e,n){let o;try{o=ee(e);}catch{return;}let a;try{a=ee(j(n??null));}catch{a={version:ce};}const t=me(o),l=me(a),s=/* @__PURE__ */new Map();for(const d of/* @__PURE__ */new Set([...t.keys(),...l.keys()]))t.get(d)!==l.get(d)&&s.set(d,t.get(d));const m={light:/* @__PURE__ */new Map(),dark:/* @__PURE__ */new Map()};for(const[d,c]of s){const f=/^schemes\.(light|dark)\.tokens\.color\./.exec(d),b=f?m[f[1]]:void 0;b&&c!==void 0&&!b.has(c)&&b.set(c,d);}const u=/* @__PURE__ */new Set();for(const[d,c]of s){const f=/^schemes\.(light|dark)\.(tokens\.color|components)\./.exec(d),b=f&&c!==void 0?m[f[1]].get(c):void 0;if(b!==void 0&&b!==d)continue;const g=/^schemes\.(light|dark)\.(.*)$/.exec(d);if(g){const y=`schemes.${g[1]==="light"?"dark":"light"}.${g[2]}`;if(s.has(y)&&s.get(y)===c){u.add(`schemes.*.${g[2]}`);continue;}}u.add(d);}return u.size;}function me(e,n="",o=/* @__PURE__ */new Map()){if(e&&typeof e=="object"&&!Array.isArray(e))for(const[a,t]of Object.entries(e))me(t,n?`${n}.${a}`:a,o);else n&&o.set(n,JSON.stringify(e));return o;}const ln=[["container","background"],["container","borderColor"],["row","zebraBackground"],["row","hoverBackground"],["subtotal","background"],["subtotal","foreground"],["grandTotal","borderColor"],["pagination","background"],["pagination","foreground"],["pagination","borderColor"]];function Ne(e){var o;const n=[];for(const a of["light","dark"]){const t=new Set(Object.values(e.schemes[a].tokens.color).map(s=>String(s).toLowerCase())),l=e.schemes[a].components.table;for(const[s,m]of ln){const u=(o=l[s])==null?void 0:o[m];typeof u=="string"&&t.has(u.toLowerCase())&&n.push({scheme:a,part:s,key:m});}}return n;}function sn(e){const n=re(e);for(const{scheme:o,part:a,key:t}of Ne(e)){const l=n.schemes[o].components.table,s={...l[a]};delete s[t],Object.keys(s).length?l[a]=s:delete l[a];}return n;}const er={background:"Page",card:"Cards",muted:"Tinted surface",border:"Lines",foreground:"Text",mutedForeground:"Secondary text",primary:"Primary",accent:"Accent",selection:"Selection",link:"Links",positive:"Positive",negative:"Negative",warning:"Warning",info:"Info",primaryForeground:"Text on primary",accentForeground:"Text on accent",cardForeground:"Text on cards",input:"Input borders",destructive:"Destructive",destructiveForeground:"Text on destructive"},dn={dashboard:"Dashboards",card:"Dashboards",interactive:"Filters and controls",pagination:"Filters and controls",chart:"Charts",table:"Tables",matrixTable:"Tables",documentTable:"Tables"};function de(e){return e instanceof Qe?cn(e.issue):e instanceof Error?e.message:"This brand can't be saved yet.";}function cn(e){const n=e.path.replace(/^\$\./,"").split("."),o=n[0]==="schemes"&&(n[1]==="light"||n[1]==="dark")?n[1]:null,a=o?` (${o==="light"?"Light":"Dark"})`:"",t=e.code==="invalid_color";if(o&&n[2]==="tokens"&&n[3]==="color"&&n[4]){const s=er[n[4]]??n[4];return t?`${s}${a} isn't a color yet. Enter one like #1A73E8.`:`${s}${a} can't be saved as it is.`;}const l=o&&n[2]==="components"?dn[n[3]??""]:void 0;return l?t?`A color in ${l}${a} isn't a color yet. Enter one like #1A73E8.`:`A value in ${l}${a} is out of range. Set it again to save.`:t?`A color${a} isn't a color yet. Enter one like #1A73E8.`:"A setting can't be saved as it is. Check Advanced.";}const rr={dashboards:"table",documents:"documentTable"};function Te(e,n,o){const a=Hr({spec:Zr(e),mode:o==="documents"?"light":n});return mr(a,{surface:o==="documents"?"document":"dashboard",kind:"table"});}function un(e,n,o){return e.schemes[o==="documents"?"light":n].components[rr[o]]??{};}function hn(e){var n;return((n=e.schemes.light.components.documentTable)==null?void 0:n.sameAsDashboards)===!0;}function G(e,n,o,a){const t=nr(e),l=rr[n],s=a&&n==="dashboards"?[a]:["light","dark"];for(const m of s){const u=t.schemes[m].components;u[l]=mn(u[l]??{},o);}return t;}function pn(e,n,o,a){if(n==="documents"){const l=e.schemes.light.tokens.color.accent;return G(e,n,{header:{background:a?l:"transparent"}},o);}let t=e;for(const l of[o,o==="light"?"dark":"light"]){const s=e.schemes[l].tokens.color.accent;t=G(t,n,{header:{background:a?s:"transparent"}},l);}return t;}function bn(e,n){const o=nr(e);for(const a of["light","dark"]){const t={...o.schemes[a].components.documentTable};t.sameAsDashboards=n,o.schemes[a].components.documentTable=t;}return o;}function gn(e,n,o){var t,l,s,m;if(n==="documents"){const u=e.schemes.light.tokens.color,d=$e(o,u),c=V[o].values.header.filled?d.header:{...d.header,background:"transparent",foreground:u.mutedForeground};return G(e,n,{...d,header:c});}let a=e;for(const u of["light","dark"]){const d=$e(o,e.schemes[u].tokens.color),c=e.schemes[u].tokens.spacing,f={...d.cell,paddingX:((t=d.cell)==null?void 0:t.paddingX)===c.tableCellX||(l=d.cell)==null?void 0:l.paddingX,paddingY:((s=d.cell)==null?void 0:s.paddingY)===c.tableCellY||(m=d.cell)==null?void 0:m.paddingY};a=G(a,n,{...d,cell:f},u);}return a;}function fn(e,n){return qe.find(o=>{const{borders:a,cell:t,header:l}=V[o].values;return e.rows.borders===a&&e.cell.paddingX===t.paddingX&&e.cell.paddingY===t.paddingY&&e.cell.fontSize===t.fontSize&&e.header.paddingY===l.paddingY&&e.header.fontSize===l.fontSize&&e.header.fontWeight===l.fontWeight&&e.header.uppercase===l.uppercase&&e.header.wrap===l.wrap&&(l.filled?e.header.background!=="transparent":e.header.background==="transparent"&&(e.header.foreground.startsWith("hsl(var(")||we(e.header.foreground,n)));})??null;}function mn(e,n){const o={...e};for(const[a,t]of Object.entries(n)){if(t===void 0)continue;const l=o[a];if(t&&typeof t=="object"){const s={...(l&&typeof l=="object"?l:{})};for(const[m,u]of Object.entries(t))u===void 0?delete s[m]:s[m]=u;o[a]=s;}else o[a]=t;}return o;}function nr(e){return JSON.parse(JSON.stringify(e));}function vn({draft:e,appearance:n,scheme:o,view:a,onSchemeChange:t,onViewChange:l}){const s=k.useMemo(()=>({...(n??{version:1}),mode:a==="document"?"light":o}),[n,o,a]);return/* @__PURE__ */i("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-muted/30",children:[/* @__PURE__ */i("div",{className:"flex shrink-0 items-center justify-between gap-3 border-b border-border/60 px-4 py-2",children:[/* @__PURE__ */r(R,{label:"Preview",value:a,onChange:l,options:[{value:"dashboard",label:"Dashboard"},{value:"table",label:"Table"},{value:"document",label:"Document"}]}),/* @__PURE__ */r(R,{label:"Scheme",value:o,onChange:t,options:[{value:"light",label:"Light"},{value:"dark",label:"Dark"}]})]}),/* @__PURE__ */r("div",{className:"min-h-0 flex-1 overflow-auto p-5",children:/* @__PURE__ */r(We,{organizationAppearance:s,children:a==="document"?/* @__PURE__ */r(wn,{draft:e}):/* @__PURE__ */r(Cn,{view:a})})})]});}const yn=[{region:"North",status:"Succeeded",orders:1284,revenue:98765.43},{region:"South",status:"Failed",orders:342,revenue:12034.5},{region:"East",status:"Running",orders:905,revenue:45210.2},{region:"West",status:"Succeeded",orders:1110,revenue:76402.1}],xn={region:"Total",orders:3641,revenue:232412.23},kn={id:"brand-studio-preview-table",type:"table",title:"Runs by region",config:{},preferences:{tablePrefs:{tableStyle:{totals:{enabled:!0}}}}},Sn={status:{type:"badge",badge:{style:"pill",tones:{Succeeded:"green",Failed:"red"}}}};function ve(){return/* @__PURE__ */r(Ue,{card:kn,data:yn,totalsByColumnId:xn,columnSettings:Sn,suppressSortControls:!0});}function Cn({view:e}){const{compiledAppearance:n}=Vr(),o=vr(),a=yr("interactive"),t=n.chartTheme.palette,l=n.chartTheme.barRadius,s=e==="table"?"Runs by region":"Revenue overview",m=[["Last 90 days",!0],["All regions",!1]];return/* @__PURE__ */i("div",{className:"mx-auto max-w-[820px] overflow-hidden rounded-[8px] border border-border/60 shadow-sm",style:{...o.dashboardContainerStyle,fontFamily:"var(--semaphor-font-family)"},children:[/* @__PURE__ */i("div",{className:"flex items-center gap-2 border-b border-border px-3 py-2",style:a.containerStyle,children:[/* @__PURE__ */r("span",{className:"text-[13px] font-semibold",children:s}),/* @__PURE__ */r("span",{className:"ml-auto flex gap-1.5",children:m.map(([u,d])=>/* @__PURE__ */r("span",{className:N("inline-flex h-7 items-center rounded-control border border-border px-2 text-[12px]",d?a.hasAppearance?"bg-accent/80":"bg-muted/80":"bg-muted/40"),style:a.chipStyle,children:u},u))})]}),/* @__PURE__ */r("div",{style:{...o.dashboardCanvasStyle,padding:o.canvasPadding},children:e==="table"?/* @__PURE__ */r(Q,{frame:o.cardFrameStyle,gutter:o.cardGutterStyle,children:/* @__PURE__ */r(ve,{})}):/* @__PURE__ */i("div",{className:"grid grid-cols-3",style:{gap:o.spacing},children:[[["Revenue","$1.24M","+8.2%",!0],["Orders","12,480","+3.1%",!0],["Refunds","2.4%","+0.4 pts",!1]].map(([u,d,c,f])=>/* @__PURE__ */i(Q,{frame:o.cardFrameStyle,gutter:o.cardGutterStyle,children:[/* @__PURE__ */r("p",{className:"text-[11px] text-muted-foreground",children:u}),/* @__PURE__ */r("p",{className:"mt-1 text-[22px] font-semibold tracking-tight",children:d}),/* @__PURE__ */i("p",{className:"text-[11px]",style:{color:`hsl(var(${f?"--semaphor-positive":"--semaphor-negative"}))`},children:[c," vs last period"]})]},String(u))),/* @__PURE__ */i(Q,{className:"col-span-2",frame:o.cardFrameStyle,gutter:o.cardGutterStyle,children:[/* @__PURE__ */r("p",{className:"mb-3 text-[13px] font-semibold",children:"Revenue by month"}),/* @__PURE__ */r("div",{className:"flex h-[110px] items-end gap-2 border-b border-border",children:[48,62,55,70,66,82,78,90].map((u,d)=>/* @__PURE__ */r("span",{className:"flex-1",style:{height:`${u}%`,background:t[0],borderRadius:`${l}px ${l}px 0 0`}},d))})]}),/* @__PURE__ */i(Q,{frame:o.cardFrameStyle,gutter:o.cardGutterStyle,children:[/* @__PURE__ */r("p",{className:"mb-2 text-[13px] font-semibold",children:"By channel"}),["Direct","Partners","Online"].map((u,d)=>/* @__PURE__ */i("div",{className:"flex items-center gap-2 py-1 text-[12px]",children:[/* @__PURE__ */r("span",{className:"h-2 w-2 rounded-full",style:{background:t[(d+1)%t.length]}}),u,/* @__PURE__ */i("span",{className:"ml-auto tabular-nums text-muted-foreground",children:[[46,31,23][d],"%"]})]},u))]}),/* @__PURE__ */i(Q,{className:"col-span-3",frame:o.cardFrameStyle,gutter:o.cardGutterStyle,children:[/* @__PURE__ */r("p",{className:"mb-2 text-[13px] font-semibold",children:"Recent runs"}),/* @__PURE__ */r(ve,{})]})]})})]});}function Q({frame:e,gutter:n,className:o,children:a}){return/* @__PURE__ */r("div",{className:N("relative min-w-0 overflow-clip rounded-card border bg-card text-card-foreground shadow-sm",o),style:e,children:/* @__PURE__ */r("div",{className:"py-3",style:n,children:a})});}function wn({draft:e}){const n=Te(e,"light","documents");return/* @__PURE__ */i("div",{className:"mx-auto w-[600px] rounded-[2px] bg-white p-10 text-zinc-900 shadow-[0_1px_3px_rgba(0,0,0,.12),0_8px_24px_rgba(0,0,0,.08)]",children:[/* @__PURE__ */r("p",{className:"text-[11px] text-zinc-500",children:"Weekly operations report · Page 1 of 4"}),/* @__PURE__ */r("h3",{className:"mt-3 text-[18px] font-semibold tracking-tight",children:"Runs by region"}),/* @__PURE__ */r("p",{className:"mt-1 text-[12px] text-zinc-500",children:"Week of Nov 10"}),/* @__PURE__ */r("div",{className:`mt-4 ${Ye(n)}`,style:je({style:n,isSliced:!0}),children:/* @__PURE__ */r(Je,{value:"document",children:/* @__PURE__ */r(ve,{})})})]});}const Nn=["#ffffff","#f8fafc","#f4f4f5","#e4e4e7","#18181b","#09090b","#2563eb","#0f766e","#047857","#d97706","#dc2626","#7c3aed"];function or(e){const n=be(e);return n?`#${pe(n.r)}${pe(n.g)}${pe(n.b)}`:"#000000";}function pe(e){return Math.round(e).toString(16).padStart(2,"0");}function _({title:e,children:n}){return/* @__PURE__ */i("div",{className:"px-5 pb-2 pt-5",children:[/* @__PURE__ */r("h2",{className:"text-[14px] font-semibold tracking-tight",children:e}),n?/* @__PURE__ */r("p",{className:"mt-0.5 text-[12px] leading-[1.45] text-muted-foreground",children:n}):null]});}function C({label:e,aside:n,children:o}){return/* @__PURE__ */i("div",{className:"px-5 py-3",children:[/* @__PURE__ */i("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[/* @__PURE__ */r("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:e}),n]}),/* @__PURE__ */r("div",{className:"divide-y divide-border/50",children:o})]});}function v({label:e,hint:n,error:o,children:a}){return/* @__PURE__ */i("div",{className:"py-2",children:[/* @__PURE__ */i("div",{className:"flex min-h-7 items-center justify-between gap-3",children:[/* @__PURE__ */i("div",{className:"min-w-0",children:[/* @__PURE__ */r("p",{className:"truncate text-[13px]",children:e}),n?/* @__PURE__ */r("p",{className:"truncate text-[11px] text-muted-foreground",children:n}):null]}),/* @__PURE__ */r("div",{className:"flex shrink-0 items-center gap-1.5",children:a})]}),o?/* @__PURE__ */r("p",{role:"alert",className:"mt-1 text-[11px] text-destructive",children:o}):null]});}function w({label:e,value:n,min:o,max:a,unit:t="px",onChange:l}){const s=c=>l(Math.min(a,Math.max(o,Math.round(c)))),[m,u]=k.useState(null),d=()=>{if(m===null)return;const c=Number(m);m.trim()!==""&&Number.isFinite(c)&&s(c),u(null);};return/* @__PURE__ */i("span",{className:"inline-flex h-7 items-center rounded-control border border-border",children:[/* @__PURE__ */r("button",{type:"button","aria-label":`Less ${e}`,disabled:n<=o,onClick:()=>s(n-1),className:"grid h-full w-6 place-items-center text-muted-foreground hover:text-foreground disabled:opacity-35",children:/* @__PURE__ */r(Or,{className:"h-3 w-3"})}),/* @__PURE__ */i("span",{className:"flex w-12 items-baseline justify-center gap-0.5",children:[/* @__PURE__ */r("input",{"aria-label":e,inputMode:"numeric",value:m??String(n),onChange:c=>u(c.target.value),onBlur:d,onKeyDown:c=>{c.key==="Enter"&&d(),c.key==="Escape"&&u(null);},className:"w-6 bg-transparent text-right text-[12px] tabular-nums outline-none"}),/* @__PURE__ */r("span",{className:"text-[11px] text-muted-foreground",children:t})]}),/* @__PURE__ */r("button",{type:"button","aria-label":`More ${e}`,disabled:n>=a,onClick:()=>s(n+1),className:"grid h-full w-6 place-items-center text-muted-foreground hover:text-foreground disabled:opacity-35",children:/* @__PURE__ */r(He,{className:"h-3 w-3"})})]});}function E({label:e,hint:n,value:o,onChange:a,onReset:t}){return/* @__PURE__ */i(v,{label:e,hint:n,children:[/* @__PURE__ */r("span",{className:"w-[66px] truncate text-right font-mono text-[11px] uppercase text-muted-foreground",children:or(o)}),/* @__PURE__ */r(ne,{label:e,value:o,onChange:a}),t?/* @__PURE__ */r("button",{type:"button","aria-label":`Reset ${e}`,onClick:t,className:"rounded-control p-1 text-muted-foreground hover:bg-muted hover:text-foreground",children:/* @__PURE__ */r(Se,{className:"h-3 w-3"})}):/* @__PURE__ */r("span",{className:"w-5"})]});}function ne({label:e,value:n,onChange:o}){const[a,t]=k.useState(!1),[l,s]=k.useState(n),[m,u]=k.useState(null);return/* @__PURE__ */i(xr,{open:a,onOpenChange:d=>{d&&s(n),u(null),t(d);},children:[/* @__PURE__ */r(kr,{asChild:!0,children:/* @__PURE__ */r("button",{type:"button","aria-label":`Open ${e} color picker`,className:"h-6 w-6 rounded-[4px] border border-black/10 dark:border-white/15",style:{backgroundColor:n}})}),/* @__PURE__ */i(Sr,{align:"end",sideOffset:6,className:"z-[60] w-64 rounded-control p-2",children:[/* @__PURE__ */i("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */i("label",{className:"relative flex h-14 w-14 shrink-0 cursor-pointer items-center justify-center overflow-hidden rounded-control border border-border/70",style:{backgroundColor:n},children:[/* @__PURE__ */r("input",{"aria-label":`${e} native color picker`,type:"color",value:or(n),onChange:d=>{u(null),o(d.target.value);},className:"absolute inset-0 h-full w-full cursor-pointer opacity-0"}),/* @__PURE__ */r("span",{className:"rounded-control bg-black/45 p-1 text-white shadow-sm",children:/* @__PURE__ */r(qr,{className:"h-3.5 w-3.5"})})]}),/* @__PURE__ */r(Cr,{size:"xs","aria-label":`${e} color value`,value:m??n,onChange:d=>{u(d.target.value),o(d.target.value);},onBlur:()=>u(null),className:"font-mono"}),n!==l?/* @__PURE__ */r("button",{type:"button","aria-label":`Reset ${e} color to previous value`,title:"Back to the color it had",onClick:()=>{u(null),o(l);},className:"shrink-0 rounded-control p-1 text-muted-foreground hover:bg-muted hover:text-foreground",children:/* @__PURE__ */r(Se,{className:"h-3.5 w-3.5"})}):null]}),/* @__PURE__ */r("div",{className:"mt-2 grid grid-cols-6 gap-1",children:Nn.map(d=>/* @__PURE__ */r("button",{type:"button","aria-label":`Set ${e} to ${d}`,className:N("h-6 rounded-control border border-border/70",n.toLowerCase()===d&&"ring-2 ring-ring"),style:{backgroundColor:d},onClick:()=>{u(null),o(d);}},d))})]})]});}function z({label:e,value:n,options:o,width:a=140,onChange:t}){return/* @__PURE__ */i(wr,{value:n,onValueChange:t,children:[/* @__PURE__ */r(Nr,{size:"xs","aria-label":e,style:{width:a},children:/* @__PURE__ */r(Tr,{})}),/* @__PURE__ */r(Fr,{children:o.map(([l,s])=>/* @__PURE__ */r(Er,{value:l,children:s},l))})]});}function W({label:e,checked:n,onCheckedChange:o}){return/* @__PURE__ */r(Pr,{size:"xs","aria-label":e,checked:n,onCheckedChange:o});}const Tn={semaphor:"Neutral"},Fn={"open-sans":"Open Sans"},ye=ie.map(e=>[e.id,Fn[e.id]??e.label]),xe=e=>{var n;return((n=ie.find(o=>o.value===e))==null?void 0:n.id)??ie[0].id;},ke=e=>{var n;return(n=ie.find(o=>o.id===e))==null?void 0:n.value;};function En({context:e}){var f;const{draft:n,scheme:o,setDraft:a,updateScheme:t,updateBoth:l,dashboardStyleSpec:s,editDashboardFields:m}=e,u=n.schemes[o].tokens.color,d=s?Ce({organizationAppearance:s},o):null,c=(f=ge.find(b=>we(b.light.primary,n.schemes.light.tokens.color.primary)))==null?void 0:f.id;return/* @__PURE__ */i(T,{children:[/* @__PURE__ */r(_,{title:"Brand",children:"Four choices set the look. Every other section fine-tunes it."}),/* @__PURE__ */r(C,{label:"Start from",children:/* @__PURE__ */r("div",{className:"grid grid-cols-3 gap-2 py-2",children:ge.map(b=>/* @__PURE__ */i("button",{type:"button","aria-pressed":c===b.id,onClick:()=>a(nn(n,b.id)),className:N("rounded-[6px] border p-2 text-left",c===b.id?"border-foreground ring-1 ring-foreground":"border-border hover:border-foreground/40"),children:[/* @__PURE__ */i("span",{className:"flex gap-1",children:[/* @__PURE__ */r("span",{className:"h-4 w-4 rounded-[3px]",style:{background:b.light.primary}}),/* @__PURE__ */r("span",{className:"h-4 w-4 rounded-[3px] border border-border/60",style:{background:b.light.accent}}),/* @__PURE__ */r("span",{className:"h-4 w-4 rounded-[3px]",style:{background:b.dark.background}})]}),/* @__PURE__ */r("span",{className:"mt-1.5 block truncate text-[12px] font-medium",children:Tn[b.id]??b.name})]},b.id))})}),/* @__PURE__ */i(C,{label:"Your brand",children:[/* @__PURE__ */r(v,{label:"Primary color",hint:"Buttons, selection and links",children:/* @__PURE__ */r(ne,{label:"Primary color",value:u.primary,onChange:b=>t(g=>ue(g,"primary",b))})}),/* @__PURE__ */r(v,{label:"Font",children:/* @__PURE__ */r(z,{label:"Font",value:xe(n.schemes.light.tokens.typography.fontFamily),options:ye,onChange:b=>l(g=>{const y=ke(b);y&&(g.tokens.typography.fontFamily=y,g.tokens.typography.headingFontFamily=y);})})}),d?/* @__PURE__ */i(T,{children:[/* @__PURE__ */r(v,{label:"Corners",children:/* @__PURE__ */r(R,{label:"Corners",value:d.pickers.corners,onChange:b=>m({corners:b}),options:["square","subtle","rounded"].map(b=>({value:b,label:b[0].toUpperCase()+b.slice(1),title:`Cards ${ze[b].cardCorners} px, controls ${ze[b].controlCorners} px`}))})}),/* @__PURE__ */r(v,{label:"Spacing",children:/* @__PURE__ */r(R,{label:"Spacing",value:d.pickers.spacing,onChange:b=>m({spacing:b}),options:["compact","default","roomy"].map(b=>({value:b,label:b[0].toUpperCase()+b.slice(1),title:`${jr[b]} px between cards`}))})})]}):null]})]});}const On=[{label:"Surfaces",rows:[["background"],["card"],["muted"],["border"]]},{label:"Text",rows:[["foreground"],["mutedForeground"]]},{label:"Brand",rows:[["primary"],["accent","Hover and highlights"],["selection","What a viewer filtered by"],["link"]]},{label:"Status",rows:[["positive"],["negative"],["warning"],["info"]]}],Pn=["primaryForeground","accentForeground","cardForeground","input","destructive","destructiveForeground"];function An({context:e}){const{draft:n,scheme:o,setDraft:a,updateScheme:t}=e,[l,s]=k.useState(!1),m=n.schemes[o].tokens.color,u=Ne(n),d=([c,f])=>{const b=er[c],g=an(o,c),y=g!==void 0&&!we(m[c],g);return/* @__PURE__ */r(E,{label:b,hint:f??(y?"Your color":"Default"),value:m[c]??g??"#000000",onChange:D=>t(S=>ue(S,c,D)),onReset:y&&g?()=>t(D=>ue(D,c,g)):void 0},c);};return/* @__PURE__ */i(T,{children:[/* @__PURE__ */i(_,{title:"Colors",children:[o==="light"?"Light":"Dark"," colors. Switch to ",o==="light"?"Dark":"Light"," to edit the other set; every other setting applies to both."]}),u.length?/* @__PURE__ */i("div",{className:"mx-5 mb-1 rounded-[6px] border border-amber-500/40 bg-amber-500/10 p-3",children:[/* @__PURE__ */i("p",{className:"text-[12px] font-medium",children:[u.length," table color",u.length===1?" was":"s were"," copied from your colors"]}),/* @__PURE__ */r("p",{className:"mt-0.5 text-[12px] leading-[1.45] text-muted-foreground",children:"An earlier version of this editor saved them, so they don't change when you change your colors."}),/* @__PURE__ */r(B,{size:"xs",className:"mt-2",onClick:()=>a(sn(n)),children:"Follow my colors"})]}):null,On.map(c=>/* @__PURE__ */r(C,{label:c.label,children:c.rows.map(d)},c.label)),/* @__PURE__ */i("button",{type:"button",onClick:()=>s(!l),className:"flex w-full items-center gap-1 px-5 py-2 text-[12px] text-muted-foreground hover:text-foreground",children:[/* @__PURE__ */r(Ve,{className:N("h-3 w-3 transition-transform",l&&"rotate-90")}),"Text on colors, inputs and destructive"]}),l?/* @__PURE__ */r(C,{label:"More colors",children:Pn.map(c=>d([c]))}):null]});}function Rn({context:e}){const{draft:n,updateBoth:o}=e,a=n.schemes.light.tokens.typography;return/* @__PURE__ */i(T,{children:[/* @__PURE__ */r(_,{title:"Typography",children:"Your app loads the font; a missing one falls back to the system font."}),/* @__PURE__ */i(C,{label:"Fonts",children:[/* @__PURE__ */r(v,{label:"Text",children:/* @__PURE__ */r(z,{label:"Text font",value:xe(a.fontFamily),options:ye,onChange:t=>o(l=>{const s=ke(t);s&&(l.tokens.typography.fontFamily=s);})})}),/* @__PURE__ */r(v,{label:"Headings",children:/* @__PURE__ */r(z,{label:"Heading font",value:xe(a.headingFontFamily),options:ye,onChange:t=>o(l=>{const s=ke(t);s&&(l.tokens.typography.headingFontFamily=s);})})})]}),/* @__PURE__ */i(C,{label:"Size",children:[/* @__PURE__ */r(v,{label:"Base size",hint:"Charts and controls scale from it",children:/* @__PURE__ */r(w,{label:"Base size",value:a.baseFontSize,min:11,max:18,onChange:t=>o(l=>l.tokens.typography.baseFontSize=t)})}),/* @__PURE__ */r(v,{label:"Density",hint:"Space in menus and panels",children:/* @__PURE__ */r(z,{label:"Density",value:a.density,width:130,options:[["compact","Compact"],["comfortable","Comfortable"],["spacious","Spacious"]],onChange:t=>o(l=>l.tokens.typography.density=t)})})]})]});}const Z=e=>({min:_e[e].min,max:_e[e].max});function Dn({context:e}){const{draft:n,scheme:o,updateBoth:a,dashboardStyleSpec:t,editDashboardFields:l}=e,[s,m]=k.useState(null);if(!t)return null;const u=Ce({organizationAppearance:t},o),d=u.authored,c=g=>m(l(g)),f=d.canvas==="muted"?"muted":d.canvas==="background"?"background":"color",b=g=>({[o]:g});return/* @__PURE__ */i(T,{children:[/* @__PURE__ */r(_,{title:"Dashboards",children:"How cards sit on the canvas. A dashboard can set its own in its Style panel."}),/* @__PURE__ */i(C,{label:"Layout",children:[/* @__PURE__ */r(v,{label:"Space between cards",children:/* @__PURE__ */r(w,{label:"Space between cards",value:d.spacing,...Z("spacing"),onChange:g=>c({spacing:g})})}),/* @__PURE__ */r(v,{label:"Canvas edge",children:/* @__PURE__ */r(w,{label:"Canvas edge",value:d.canvasPadding,...Z("canvasPadding"),onChange:g=>c({canvasPadding:g})})}),/* @__PURE__ */i(v,{label:`Canvas (${o})`,children:[/* @__PURE__ */r(R,{label:"Canvas",value:f,onChange:g=>c({canvas:b(g==="color"?o==="dark"?"#111318":"#f4f6f8":g)}),options:[{value:"muted",label:"Tinted"},{value:"background",label:"Plain"},{value:"color",label:"Custom"}]}),f==="color"?/* @__PURE__ */r(ne,{label:"Canvas color",value:Ar(d.canvas),onChange:g=>c({canvas:b(g)})}):null]})]}),/* @__PURE__ */i(C,{label:"Cards",children:[/* @__PURE__ */r(v,{label:"Style",children:/* @__PURE__ */r(R,{label:"Card style",value:u.pickers.cards,onChange:g=>c({cards:g}),options:[{value:"outlined",label:"Outlined",title:"A border on a tinted canvas"},{value:"raised",label:"Raised",title:"A shadow, no border"},{value:"open",label:"Open",title:"No border or shadow on a plain canvas"}]})}),/* @__PURE__ */r(v,{label:"Card corners",children:/* @__PURE__ */r(w,{label:"Card corners",value:d.cardCorners,...Z("cardCorners"),onChange:g=>c({corners:{cards:g}})})}),/* @__PURE__ */r(v,{label:"Control corners",children:/* @__PURE__ */r(w,{label:"Control corners",value:d.controlCorners,...Z("controlCorners"),onChange:g=>c({corners:{controls:g}})})}),/* @__PURE__ */r(v,{label:"Padding inside",children:/* @__PURE__ */r(w,{label:"Padding inside cards",value:n.schemes.light.tokens.spacing.cardPadding,min:0,max:32,onChange:g=>a(y=>y.tokens.spacing.cardPadding=g)})}),/* @__PURE__ */r(v,{label:"Table corners",children:/* @__PURE__ */r(w,{label:"Table corners",value:n.schemes.light.tokens.radius.table,min:0,max:12,onChange:g=>a(y=>on(y,"table",g))})})]}),s?/* @__PURE__ */i("p",{role:"alert",className:"px-5 text-[12px] text-destructive",children:[s.message," ",s.fix]}):null]});}function Bn({context:e}){const{draft:n,scheme:o,updateScheme:a,dashboardStyleSpec:t,editDashboardFields:l}=e,s=n.schemes[o].components.chart,m=t?Ce({organizationAppearance:t},o):null;return/* @__PURE__ */i(T,{children:[/* @__PURE__ */r(_,{title:"Charts",children:"Series take colors in order."}),/* @__PURE__ */r(C,{label:`Series colors (${o})`,children:/* @__PURE__ */i("div",{className:"flex flex-wrap items-center gap-1.5 py-2",children:[s.palette.map((u,d)=>/* @__PURE__ */i("span",{className:"group/series relative",children:[/* @__PURE__ */r(ne,{label:`Series ${d+1}`,value:u||"#000000",onChange:c=>a(f=>f.components.chart.palette[d]=c)}),s.palette.length>1?/* @__PURE__ */r("button",{type:"button","aria-label":`Remove series ${d+1} color`,onClick:()=>a(c=>c.components.chart.palette.splice(d,1)),className:"absolute -right-1.5 -top-1.5 hidden h-3.5 w-3.5 place-items-center rounded-full bg-foreground text-background group-hover/series:grid group-focus-within/series:grid",children:/* @__PURE__ */r(Ge,{className:"h-2.5 w-2.5"})}):null]},d)),s.palette.length<12?/* @__PURE__ */r("button",{type:"button","aria-label":"Add a color",onClick:()=>a(u=>u.components.chart.palette.push("#64748b")),className:"grid h-6 w-6 place-items-center rounded-[4px] border border-dashed border-border text-muted-foreground hover:text-foreground",children:/* @__PURE__ */r(He,{className:"h-3 w-3"})}):null]})}),/* @__PURE__ */i(C,{label:"Bars and lines",children:[m?/* @__PURE__ */r(v,{label:"Bar corners",children:/* @__PURE__ */r(w,{label:"Bar corners",value:m.authored.barCorners,...Z("barCorners"),onChange:u=>l({barCorners:u})})}):null,/* @__PURE__ */r(E,{label:"Grid lines",value:s.gridColor,onChange:u=>a(d=>d.components.chart.gridColor=u)}),/* @__PURE__ */r(E,{label:"Axis labels",value:s.axisColor,onChange:u=>a(d=>d.components.chart.axisColor=u)})]})]});}function zn({context:e}){const{draft:n,scheme:o,updateScheme:a}=e,t=n.schemes[o];return/* @__PURE__ */i(T,{children:[/* @__PURE__ */r(_,{title:"Filters and controls",children:"The bar above the cards, its chips, menus and panels."}),/* @__PURE__ */r(C,{label:"Toolbar",children:/* @__PURE__ */r(E,{label:"Background",value:t.components.interactive.toolbarBackground||t.tokens.color.background,onChange:l=>a(s=>s.components.interactive.toolbarBackground=l)})}),/* @__PURE__ */i(C,{label:"Chips",children:[/* @__PURE__ */r(E,{label:"Resting",hint:"Menus and panels too",value:t.components.interactive.background||t.tokens.color.card,onChange:l=>a(s=>{s.components.interactive.background=l,s.components.pagination.background=l;})}),/* @__PURE__ */r(E,{label:"Borders",value:t.components.interactive.borderColor||t.tokens.color.border,onChange:l=>a(s=>{s.components.interactive.borderColor=l,s.components.pagination.borderColor=l;})}),/* @__PURE__ */r(E,{label:"Selected",hint:"The Accent color",value:t.tokens.color.accent,onChange:l=>a(s=>ue(s,"accent",l))})]})]});}function _n({json:e,onJsonChange:n,onApplyJson:o,onCopyJson:a,copied:t,onUpload:l,onReset:s,onRemove:m,removing:u}){return/* @__PURE__ */i(T,{children:[/* @__PURE__ */r(_,{title:"Advanced",children:"Your brand as JSON, for version control or another organization."}),/* @__PURE__ */i(C,{label:"Brand spec",children:[/* @__PURE__ */r("div",{className:"my-2 h-[260px] overflow-hidden rounded-control border border-input",children:/* @__PURE__ */r(Rr,{ariaLabel:"Brand spec",value:e,onValueChange:n,language:"json",embedded:!0,hideLineNumbers:!0,dense:!0})}),/* @__PURE__ */i("div",{className:"flex flex-wrap gap-2 py-2",children:[/* @__PURE__ */r(B,{type:"button",size:"xs",onClick:o,children:"Apply"}),/* @__PURE__ */i(B,{type:"button",size:"xs",variant:"outline",onClick:a,children:[/* @__PURE__ */r(Kr,{className:"h-3.5 w-3.5"}),t?"Copied":"Copy"]}),/* @__PURE__ */i(B,{type:"button",size:"xs",variant:"outline",onClick:l,children:[/* @__PURE__ */r(Dr,{className:"h-3.5 w-3.5"}),"Upload a spec"]})]})]}),/* @__PURE__ */i(C,{label:"Start over",children:[/* @__PURE__ */r(v,{label:"Reset to the default look",hint:"Your saved brand stays until you save",children:/* @__PURE__ */i(B,{type:"button",size:"xs",variant:"outline",onClick:s,children:[/* @__PURE__ */r(Se,{className:"h-3.5 w-3.5"}),"Reset"]})}),m?/* @__PURE__ */r(v,{label:"Remove the brand",hint:"Dashboards use the default look",children:/* @__PURE__ */i(B,{type:"button",size:"xs",variant:"outline",className:"text-destructive",onClick:m,disabled:u,children:[/* @__PURE__ */r(Br,{className:"h-3.5 w-3.5"}),"Remove"]})}):null]})]});}const $n=[["horizontal","Rows"],["full","Grid"],["inner","Inner grid"],["vertical","Columns"],["outer","Frame only"],["none","None"]],Me=[["400","Regular"],["500","Medium"],["600","Semibold"],["700","Bold"]],Ln=[["solid","Solid"],["dashed","Dashed"],["dotted","Dotted"],["double","Double"],["none","None"]];function Mn({draft:e,shown:n=e,scheme:o,onDraftChange:a,onTargetChange:t,showPreview:l=!1}){var $,ae,L,Y,J,te;const[s,m]=k.useState("dashboards"),u=h=>{m(h),t==null||t(h);},[d,c]=k.useState(!1),f=Te(n,o,s),b=un(e,o,s),g=e.schemes[s==="documents"?"light":o].tokens.color,y=s==="documents"&&hn(e),D=fn(f,g.mutedForeground),S=h=>a(G(e,s,h)),O=h=>a(G(e,s,h,o)),oe=f.header.background!=="transparent";return/* @__PURE__ */i(T,{children:[/* @__PURE__ */r(_,{title:"Tables",children:"Every table and Matrix shares this style; a card keeps only Wrap text and its totals row."}),/* @__PURE__ */r("div",{className:"px-5",children:/* @__PURE__ */r(R,{label:"Table style target",fill:!0,value:s,onChange:u,options:[{value:"dashboards",label:"Dashboards"},{value:"documents",label:"Documents"}]})}),s==="documents"?/* @__PURE__ */r(C,{label:"Documents",children:/* @__PURE__ */r(v,{label:"Same as dashboards",hint:"Off: reports print in their own style",children:/* @__PURE__ */r(W,{label:"Same as dashboards",checked:y,onCheckedChange:h=>a(bn(e,h))})})}):null,y?null:/* @__PURE__ */i(T,{children:[/* @__PURE__ */r(C,{label:"Start from",children:/* @__PURE__ */r("div",{className:"grid grid-cols-3 gap-2 py-2",children:qe.map(h=>{const X=V[h].values;return/* @__PURE__ */i("button",{type:"button","aria-pressed":D===h,onClick:()=>a(gn(e,s,h)),className:N("rounded-[6px] border p-2 text-left",D===h?"border-foreground ring-1 ring-foreground":"border-border hover:border-foreground/40"),children:[/* @__PURE__ */i("span",{"aria-hidden":!0,className:"block overflow-hidden rounded-[3px] border border-border/60 bg-background",children:[/* @__PURE__ */r("span",{className:N("block h-2",X.header.filled&&"bg-muted")}),[0,1,2].map(U=>/* @__PURE__ */r("span",{className:"block border-t border-border/50",style:{height:2+X.cell.paddingY}},U))]}),/* @__PURE__ */r("span",{className:"mt-1.5 block text-[12px] font-medium",children:V[h].label})]},h);})})}),/* @__PURE__ */i(C,{label:"Rows",children:[/* @__PURE__ */r(v,{label:"Row padding",children:/* @__PURE__ */r(w,{label:"Row padding",value:f.cell.paddingY,min:0,max:16,onChange:h=>S({cell:{paddingY:h}})})}),/* @__PURE__ */r(v,{label:"Column padding",children:/* @__PURE__ */r(w,{label:"Column padding",value:f.cell.paddingX,min:0,max:24,onChange:h=>S({cell:{paddingX:h}})})}),/* @__PURE__ */r(v,{label:"Text size",children:/* @__PURE__ */r(w,{label:"Text size",value:f.cell.fontSize,min:9,max:18,onChange:h=>S({cell:{fontSize:h}})})}),/* @__PURE__ */r(v,{label:"Values in tall rows",children:/* @__PURE__ */r(R,{label:"Values in tall rows",value:f.cell.verticalAlign,onChange:h=>S({cell:{verticalAlign:h}}),options:[{value:"top",label:"Top"},{value:"middle",label:"Middle"},{value:"bottom",label:"Bottom"}]})}),/* @__PURE__ */r(v,{label:"Lines",children:/* @__PURE__ */r(z,{label:"Lines",value:f.rows.borders,options:$n,width:120,onChange:h=>S({borders:h})})}),/* @__PURE__ */r(v,{label:"Striped rows",children:/* @__PURE__ */r(W,{label:"Striped rows",checked:f.rows.zebra,onCheckedChange:h=>S({row:{zebra:h}})})})]}),/* @__PURE__ */i(C,{label:"Header",children:[/* @__PURE__ */r(v,{label:"Text size",children:/* @__PURE__ */r(w,{label:"Header text size",value:f.header.fontSize,min:9,max:18,onChange:h=>S({header:{fontSize:h}})})}),/* @__PURE__ */r(v,{label:"Padding",children:/* @__PURE__ */r(w,{label:"Header padding",value:f.header.paddingY,min:0,max:16,onChange:h=>S({header:{paddingY:h}})})}),/* @__PURE__ */r(v,{label:"Weight",children:/* @__PURE__ */r(z,{label:"Header weight",value:String(f.header.fontWeight),options:Me,width:110,onChange:h=>S({header:{fontWeight:Number(h)}})})}),/* @__PURE__ */r(v,{label:"Capitals",children:/* @__PURE__ */r(W,{label:"Header capitals",checked:f.header.uppercase,onCheckedChange:h=>S({header:{uppercase:h}})})}),/* @__PURE__ */i(v,{label:"Band",children:[oe?/* @__PURE__ */r(ne,{label:"Band",value:(($=b.header)==null?void 0:$.background)??g.accent,onChange:h=>O({header:{background:h}})}):null,/* @__PURE__ */r(W,{label:"Header band",checked:oe,onCheckedChange:h=>a(pn(e,s,o,h))})]}),/* @__PURE__ */r(E,{label:"Header text",value:((ae=b.header)==null?void 0:ae.foreground)??g.mutedForeground,onChange:h=>O({header:{foreground:h}})})]}),/* @__PURE__ */i("button",{type:"button",onClick:()=>c(!d),className:"flex w-full items-center gap-1 px-5 py-2 text-[12px] text-muted-foreground hover:text-foreground",children:[/* @__PURE__ */r(Ve,{className:N("h-3 w-3 transition-transform",d&&"rotate-90")}),"Totals row, wrapping and lines"]}),d?/* @__PURE__ */i(T,{children:[/* @__PURE__ */i(C,{label:"Totals row",children:[/* @__PURE__ */r(E,{label:"Background",value:((L=b.grandTotal)==null?void 0:L.background)??g.card,onChange:h=>O({grandTotal:{background:h}})}),/* @__PURE__ */r(E,{label:"Text",value:((Y=b.grandTotal)==null?void 0:Y.foreground)??g.foreground,onChange:h=>O({grandTotal:{foreground:h}})}),/* @__PURE__ */r(v,{label:"Weight",children:/* @__PURE__ */r(z,{label:"Totals weight",value:String(f.totals.fontWeight),options:Me,width:110,onChange:h=>S({grandTotal:{fontWeight:Number(h)}})})}),/* @__PURE__ */r(v,{label:"Rule above",children:/* @__PURE__ */r(z,{label:"Totals rule",value:((J=b.grandTotal)==null?void 0:J.borderTop)??"solid",options:Ln,width:110,onChange:h=>S({grandTotal:{borderTop:h}})})})]}),/* @__PURE__ */i(C,{label:"More",children:[/* @__PURE__ */r(v,{label:"Wrap long text",hint:"A card can turn it on for itself",children:/* @__PURE__ */r(W,{label:"Cell wrap",checked:f.cell.wrap,onCheckedChange:h=>S({cell:{wrap:h?"wrap":"nowrap"}})})}),/* @__PURE__ */r(v,{label:"Wrap header",hint:"Tables; Matrix keeps one line",children:/* @__PURE__ */r(W,{label:"Wrap header",checked:f.header.wrap,onCheckedChange:h=>S({header:{wrap:h}})})}),s==="dashboards"?/* @__PURE__ */r(v,{label:"Sticky header",children:/* @__PURE__ */r(W,{label:"Sticky header",checked:f.header.sticky,onCheckedChange:h=>S({header:{sticky:h}})})}):null,s==="dashboards"?/* @__PURE__ */r(E,{label:"Divider",value:((te=b.row)==null?void 0:te.dividerColor)??g.border,onChange:h=>O({row:{dividerColor:h},header:{dividerColor:h}})}):null]})]}):null]}),l?/* @__PURE__ */r("div",{className:"px-5 pb-5",children:/* @__PURE__ */r(Yn,{draft:n,scheme:o,target:s})}):null]});}const In=[{region:"North",status:"Succeeded",orders:1284,revenue:98765.43,note:"Quarter closed early"},{region:"South",status:"Failed",orders:342,revenue:12034.5,note:"Retry scheduled after the warehouse sync finished late"},{region:"East",status:"Running",orders:905,revenue:45210.2,note:""}],Wn={id:"brand-studio-table-preview",type:"table",title:"Preview",config:{},preferences:{tablePrefs:{tableStyle:{totals:{enabled:!0}}}}},jn={region:"Total",orders:2531,revenue:155010.13};function Yn({draft:e,scheme:n,target:o}){const a=k.useMemo(()=>({...e,mode:o==="documents"?"light":n}),[e,n,o]),t=/* @__PURE__ */r(Ue,{card:Wn,data:In,totalsByColumnId:jn,suppressSortControls:!0}),l=o==="documents"?Te(e,"light","documents"):void 0;return/* @__PURE__ */r("div",{"aria-label":"Table preview",className:"overflow-hidden rounded-control border border-border/60",children:/* @__PURE__ */r(We,{organizationAppearance:a,children:l?/* @__PURE__ */r("div",{className:"bg-white p-3",children:/* @__PURE__ */r("div",{className:Ye(l),style:je({style:l,isSliced:!0}),children:/* @__PURE__ */r(Je,{value:"document",children:t})})}):t})});}const Jn=[{id:"brand",label:"Brand",icon:zr},{id:"colors",label:"Colors",icon:Gr},{id:"type",label:"Typography",icon:_r},{id:"dashboards",label:"Dashboards",icon:Xr},{id:"charts",label:"Charts",icon:$r},{id:"tables",label:"Tables",icon:Lr},{id:"filters",label:"Filters and controls",icon:Mr},{id:"advanced",label:"Advanced",icon:Ir}],Un={tables:"table"};function ho({appearance:e,layout:n="panel",isLoading:o=!1,isSaving:a=!1,error:t=null,className:l,onDraftChange:s,onSave:m,onClearConfig:u,onCancel:d}){const[c,f]=k.useState(null),[b,g]=k.useState("light"),[y,D]=k.useState("brand"),[S,O]=k.useState("dashboard"),[oe,$]=k.useState(!1),[ae,L]=k.useState("idle"),[Y,J]=k.useState(""),[te,h]=k.useState(null),X=k.useRef(null),U=k.useRef(s),K=k.useRef(!1);k.useEffect(()=>{U.current=s;},[s]),k.useEffect(()=>{if(e===void 0){K.current=!0,f(null);return;}K.current=!0,f(j(e)),g("light"),h(null);},[e]);const P=k.useMemo(()=>{if(!c)return{spec:null,error:null};try{return{spec:ee(c),error:null};}catch(p){return{spec:null,error:de(p)};}},[c]),[A,ar]=k.useState(null);c&&P.spec&&c!==(A==null?void 0:A.draft)&&ar({draft:c,spec:P.spec});const Fe=P.spec?c:(A==null?void 0:A.draft)??c,Ee=P.spec??(A==null?void 0:A.spec)??null;k.useEffect(()=>{var p;if(c){if(K.current){K.current=!1;return;}P.spec&&((p=U.current)==null||p.call(U,P.spec)),h(null);}},[c,P]);const le=a||oe,H=k.useMemo(()=>c?tn(c,e):0,[c,e]),Oe=p=>{f(x=>{if(!x)return x;const I=Hn(x);return p(I),I;});},he=Ee,tr=p=>{if(!he)return null;const x=Ur({spec:he,edit:p,mode:b});return x.ok?(f(j(x.spec)),null):x.refusal;},lr=async()=>{if(!c||!m)return;let p;try{p=ee(c);}catch(x){h(de(x));return;}$(!0);try{await m(p);}finally{$(!1);}},se=p=>{L("idle");try{J(JSON.stringify(fe(p),null,2));}catch{}},sr=()=>{const p=j(e??null);f(p),se(p),h(null);},dr=()=>{const p=j(null);f(p),se(p);},cr=async()=>{if(u){$(!0),h(null);try{await u(),K.current=!0;const p=j(null);f(p),se(p),g("light");}catch(p){h(p instanceof Error?p.message:"Unable to remove the brand");}finally{$(!1);}}},Pe=p=>{const x=j(JSON.parse(p));L("idle"),g("light"),f(x),J(JSON.stringify(fe(x),null,2));},ir=()=>{try{Pe(Y);}catch(p){h(p instanceof SyntaxError?"The brand spec isn't valid JSON.":de(p));}},ur=async()=>{try{await navigator.clipboard.writeText(Y),L("copied");}catch(p){h(p instanceof Error?p.message:"Unable to copy brand spec");}},hr=async p=>{var I;const x=(I=p.target.files)==null?void 0:I[0];if(p.target.value="",!!x)try{Pe(await Vn(x));}catch(Re){h(Re instanceof SyntaxError?"The uploaded file isn't valid JSON.":de(Re));}},pr=p=>{p==="advanced"&&y!=="advanced"&&c&&se(c),D(p);const x=Un[p];x&&S==="dashboard"&&O(x);},M=c?{draft:c,scheme:b,setDraft:p=>f(p),updateScheme:p=>Oe(x=>p(x.schemes[b])),updateBoth:p=>Oe(x=>{p(x.schemes.light),p(x.schemes.dark);}),dashboardStyleSpec:he,editDashboardFields:tr}:null,F=n==="page",Ae=c?Ne(c).length>0:!1,q=te??P.error,br=q?/* @__PURE__ */r("span",{className:"truncate text-[12px] text-destructive",title:q,children:"Fix the brand to save"}):le?/* @__PURE__ */i("span",{className:"inline-flex items-center gap-1 text-[12px] text-muted-foreground",children:[/* @__PURE__ */r(Be,{className:"h-3.5 w-3.5 animate-spin"})," Saving"]}):H?/* @__PURE__ */r("span",{className:"text-[12px] text-muted-foreground",children:"Unsaved changes"}):/* @__PURE__ */i("span",{className:"inline-flex items-center gap-1 text-[12px] text-muted-foreground",children:[/* @__PURE__ */r(Wr,{className:"h-3.5 w-3.5 text-emerald-600"})," Up to date"]});return/* @__PURE__ */i("div",{className:N("flex min-h-0 flex-1 flex-col bg-background text-foreground",l),children:[/* @__PURE__ */i("header",{className:"flex h-11 shrink-0 items-center gap-3 border-b border-border/60 px-4",children:[/* @__PURE__ */r("h2",{className:"text-[13px] font-semibold",children:"Brand Studio"}),/* @__PURE__ */i("div",{className:"ml-auto flex min-w-0 items-center gap-2",children:[br,F?null:/* @__PURE__ */r(R,{label:"Scheme",value:b,onChange:g,options:[{value:"light",label:"Light"},{value:"dark",label:"Dark"}]}),/* @__PURE__ */r(B,{type:"button",size:"xs",variant:"ghost",onClick:sr,disabled:!c||!H&&!P.error||le,children:"Discard"}),/* @__PURE__ */r(B,{type:"button",size:"xs",onClick:lr,disabled:!c||le||!!q||!m||!H,children:H?`Save ${H} change${H===1?"":"s"}`:"Save"}),d?/* @__PURE__ */r("button",{type:"button","aria-label":"Close Brand Studio",className:"flex h-7 w-7 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",onClick:d,children:/* @__PURE__ */r(Ge,{className:"h-3.5 w-3.5"})}):null]})]}),q?/* @__PURE__ */r("div",{className:"shrink-0 border-b border-destructive/20 bg-destructive/5 px-4 py-2 text-[12px] text-destructive",children:q}):null,/* @__PURE__ */r("input",{ref:X,"aria-label":"Upload brand spec",type:"file",accept:"application/json,.json",className:"sr-only",onChange:hr}),o?/* @__PURE__ */r("div",{className:"flex flex-1 items-center justify-center",children:/* @__PURE__ */r(Be,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):t?/* @__PURE__ */r("div",{className:"p-4 text-[13px] text-muted-foreground",children:t}):c&&M?/* @__PURE__ */i("div",{className:"flex min-h-0 flex-1",children:[/* @__PURE__ */r("nav",{"aria-label":"Brand Studio sections",className:N("shrink-0 overflow-y-auto border-r border-border/60 p-2",F?"w-[188px]":"w-[52px]"),children:Jn.map(({id:p,label:x,icon:I})=>/* @__PURE__ */i("button",{type:"button","aria-current":y===p?"page":void 0,title:F?void 0:x,"aria-label":F?void 0:p==="colors"&&Ae?`${x}, needs attention`:x,onClick:()=>pr(p),className:N("relative flex w-full items-center gap-2 rounded-control px-2 py-1.5 text-left text-[13px]",y===p?"bg-muted font-medium text-foreground":"text-muted-foreground hover:bg-muted/50 hover:text-foreground",!F&&"justify-center"),children:[/* @__PURE__ */r(I,{className:"h-3.5 w-3.5 shrink-0"}),F?/* @__PURE__ */r("span",{className:"truncate",children:x}):null,p==="colors"&&Ae?/* @__PURE__ */i(T,{children:[/* @__PURE__ */r("span",{"aria-hidden":!0,className:N("h-1.5 w-1.5 rounded-full bg-amber-500",F?"ml-auto":"absolute right-1.5 top-1.5")}),F?/* @__PURE__ */r("span",{className:"sr-only",children:", needs attention"}):null]}):null]},p))}),/* @__PURE__ */i("div",{className:N("min-w-0 overflow-y-auto pb-6",F?"w-[360px] shrink-0 border-r border-border/60":"flex-1"),children:[y==="brand"?/* @__PURE__ */r(En,{context:M}):null,y==="colors"?/* @__PURE__ */r(An,{context:M}):null,y==="type"?/* @__PURE__ */r(Rn,{context:M}):null,y==="dashboards"?/* @__PURE__ */r(Dn,{context:M}):null,y==="charts"?/* @__PURE__ */r(Bn,{context:M}):null,y==="tables"?/* @__PURE__ */r(Mn,{draft:c,shown:Fe??c,scheme:b,onDraftChange:f,onTargetChange:p=>O(p==="documents"?"document":"table"),showPreview:!F}):null,y==="filters"?/* @__PURE__ */r(zn,{context:M}):null,y==="advanced"?/* @__PURE__ */r(_n,{json:Y,onJsonChange:p=>{J(p),L("idle");},onApplyJson:ir,onCopyJson:ur,copied:ae==="copied",onUpload:()=>{var p;return(p=X.current)==null?void 0:p.click();},onReset:dr,onRemove:u?cr:void 0,removing:le}):null]}),F?/* @__PURE__ */r(vn,{draft:Fe??c,appearance:Ee,scheme:b,view:S,onSchemeChange:g,onViewChange:O}):null]}):null]});}function Hn(e){return JSON.parse(JSON.stringify(e));}function Vn(e){return typeof e.text=="function"?e.text():new Promise((n,o)=>{const a=new FileReader();a.onload=()=>n(String(a.result??"")),a.onerror=()=>o(a.error??new Error("Unable to read file")),a.readAsText(e);});}export{ge as BRAND_STUDIO_PRESETS,ho as BrandStudioEditor,nn as applyBrandStudioPreset,ee as brandStudioSaveSpec,fe as buildAppearanceSpecFromDraft,j as createBrandStudioDraft};
|
package/dist/briefings/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunks/pivot-result-contract-expectations-DTQAgr4n.js";import"../chunks/validators-CqV3Yka1.js";import"../chunks/export-file-format-B-wQNHIn.js";import"zod";import"../chunks/matrix-operation-contract-D1RC1bfi.js";import"../chunks/analytics-base-schemas-BREc5WGv.js";import"../value-format-preferences/index.js";import{E as g,L as l,a5 as B,H as m,a7 as c,C as E,B as d,G as I,N as T,F as C,D as A,M as h,$ as u,k as p,a0 as D,a1 as F,a8 as S,q as _,n as b,o as R,R as N,m as y,T as M,h as O,f as v,U as x,x as G,t as L,e as U,a2 as V,j as H,d as J,K as z,J as P,i as q,c as X,b as K,a9 as Q,a as Y,a3 as j,X as k,a6 as w,Y as W,I as Z,a4 as $,u as ee,l as ae,Z as ie,_ as re,s as te,O as se,S as ne,Q as oe,p as fe,r as ge,v as le,w as Be,P as me,V as ce,W as Ee}from"../chunks/index-B-VF1ogs.js";export{g as BRIEFING_ARTIFACT_FORMATS,l as BRIEFING_ATTACHMENT_FORMATS,B as BRIEFING_ATTACHMENT_OMISSION_CODES,m as BRIEFING_CONTENT_LIMITS,c as BRIEFING_DELIVERY_OUTCOME_STATUSES,E as BRIEFING_KIND,d as BRIEFING_RUN_CANCELLED_ERROR,I as BRIEFING_TEXT_LIMITS,T as BriefingContractError,C as DEFAULT_BRIEFING_ARTIFACT_FORMATS,A as DEFAULT_BRIEFING_SCHEDULE,h as MAX_BRIEFING_ATTACHMENTS,u as briefingAttachmentFileTraits,p as briefingAttachmentFormatLabel,D as briefingAttachmentNeedsExportJob,F as briefingAttachmentProduction,S as briefingDeliveryChannelOutcome,_ as briefingScheduleDayOccurs,b as briefingScheduleMonths,R as briefingScheduleShortMonths,N as buildBriefingJobConfig,y as buildBriefingScheduleExpr,M as buildCreateBriefingRequest,O as buildDashboardTemporalSnapshotEntries,v as buildMatrixDeliveryEnvelope,x as buildUpdateBriefingRequest,G as canCreateBriefingForUser,L as canonicalBriefingMonthDays,U as captureMatrixExport,V as completeBriefingCardAttachment,H as completeBriefingCardAttachmentSettings,J as describeBriefingSchedule,z as formatBriefingComparisonValues,P as formatBriefingDisplayValue,q as getBriefingCardAttachmentCapability,X as getBriefingCardAttachmentFormats,K as getBriefingCreationIntents,Q as getBriefingDisplayTypeLabel,Y as getBriefingPresentation,j as getDefaultBriefingCardAttachmentFormat,k as isBriefingArtifactFormat,w as isBriefingAttachmentOmissionCode,W as isBriefingDeliveryChannel,Z as isBriefingNumericValue,$ as isBriefingTableExportCardType,ee as isEmailOnlyBriefingDelivery,ae as isValidBriefingTimezone,ie as matrixDeliveryPayloadSchema,re as matrixDeliveryQuerySchema,te as nextBriefingScheduleDates,se as normalizeBriefingContentDocument,ne as normalizeBriefingDraft,oe as normalizeBriefingJobConfig,fe as parseBriefingScheduleExpr,ge as readBriefingCardFacts,le as readBriefingDeliveryOutcome,Be as readBriefingOmittedAttachments,me as validateBriefingContentDocument,ce as validateBriefingDraft,Ee as validateBriefingJobConfig};
|
|
1
|
+
var Ce=Object.defineProperty;var Te=(e,n,t)=>n in e?Ce(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var J=(e,n,t)=>Te(e,typeof n!="symbol"?n+"":n,t);import{V as ne,k as xe,a1 as Ae,Z as N}from"../chunks/pivot-result-contract-expectations-BNWhS8mv.js";import{T as Se}from"../chunks/validators-Dg2kyF4_.js";import{C as ke}from"../chunks/export-file-format-B-wQNHIn.js";import"zod";import"../chunks/matrix-operation-contract-CWvcEsQ0.js";import"../chunks/analytics-base-schemas-DMFrDqn_.js";import"../value-format-preferences/index.js";import{i as _e}from"../chunks/dashboard-temporal-snapshot-w3SMiPKj.js";import{d as Tn,e as xn,f as An,g as Sn,o as kn,b as _n,c as Dn,h as On,j as Nn,k as wn,l as Ln,n as Fn,m as Rn,a as Mn,r as Bn}from"../chunks/dashboard-temporal-snapshot-w3SMiPKj.js";function De(e){return!!e&&typeof e=="object"&&!Array.isArray(e);}function T(e,n,t){return De(e)?e:(t.push({field:n,message:"Expected an object."}),{});}function x(e,n,t,r){const o=new Set(t);Object.keys(e).forEach(i=>{o.has(i)||r.push({field:`${n}.${i}`,message:"Unexpected property."});});}function k(e,n,t,r,o={}){if(e==null)return;if(typeof e!="string"){r.push({field:n,message:"Expected a string."});return;}const i=o.trim===!1?e:e.trim();if(!o.allowEmpty&&i.length===0){r.push({field:n,message:"Expected a non-empty string."});return;}if(i.length>t){r.push({field:n,message:`Expected ${t} characters or fewer.`});return;}return i;}function q(e,n,t){const r=k(e,n,2e3,t);if(r)try{return new URL(r),r;}catch{t.push({field:n,message:"Expected an absolute URL."});return;}}function Q(e,n,t){const r=T(e,n,t);x(r,n,["tokens","components"],t);const o={};if(r.tokens!==void 0){const i=T(r.tokens,`${n}.tokens`,t);x(i,`${n}.tokens`,["color","typography"],t);const a={};if(i.color!==void 0){const c=T(i.color,`${n}.tokens.color`,t),d=["background","foreground","muted","mutedForeground","border","primary","primaryForeground","positive","negative","warning","info"];x(c,`${n}.tokens.color`,d,t);const m={};d.forEach(s=>{const u=k(c[s],`${n}.tokens.color.${s}`,120,t);u!==void 0&&(m[s]=u);}),a.color=m;}if(i.typography!==void 0){const c=T(i.typography,`${n}.tokens.typography`,t);x(c,`${n}.tokens.typography`,["fontFamily","monoFontFamily"],t);const d=k(c.fontFamily,`${n}.tokens.typography.fontFamily`,500,t,{allowEmpty:!0}),m=k(c.monoFontFamily,`${n}.tokens.typography.monoFontFamily`,500,t,{allowEmpty:!0});a.typography={...(d!==void 0?{fontFamily:d}:{}),...(m!==void 0?{monoFontFamily:m}:{})};}o.tokens=a;}if(r.components!==void 0){const i=T(r.components,`${n}.components`,t);if(x(i,`${n}.components`,["chart"],t),i.chart!==void 0){const a=T(i.chart,`${n}.components.chart`,t);x(a,`${n}.components.chart`,["palette"],t);let c;a.palette!==void 0&&(Array.isArray(a.palette)?a.palette.length>20?t.push({field:`${n}.components.chart.palette`,message:"Expected 20 colors or fewer."}):c=a.palette.map((d,m)=>k(d,`${n}.components.chart.palette.${m}`,120,t)).filter(d=>d!==void 0):t.push({field:`${n}.components.chart.palette`,message:"Expected an array."})),o.components={chart:c?{palette:c}:{}};}}return o;}function Oe(e,n){const t="presentation.appearance",r=T(e,t,n);x(r,t,["version","schemes"],n);const o={};if(r.version!==void 0&&(typeof r.version!="number"||!Number.isFinite(r.version)?n.push({field:`${t}.version`,message:"Expected a number."}):o.version=r.version),r.schemes!==void 0){const i=T(r.schemes,`${t}.schemes`,n);x(i,`${t}.schemes`,["light","dark"],n),o.schemes={...(i.light!==void 0?{light:Q(i.light,`${t}.schemes.light`,n)}:{}),...(i.dark!==void 0?{dark:Q(i.dark,`${t}.schemes.dark`,n)}:{})};}return o;}function Ne(e,n){const t="presentation.brandOverrides",r=T(e,t,n);x(r,t,["brandName","logoUrl","link"],n);const o=k(r.brandName,`${t}.brandName`,200,n),i=q(r.logoUrl,`${t}.logoUrl`,n),a=k(r.link,`${t}.link`,120,n);return{...(o!==void 0?{brandName:o}:{}),...(i!==void 0?{logoUrl:i}:{}),...(a!==void 0?{link:a}:{})};}function we(e,n){const t="presentation.fragments",r=T(e,t,n),o=["preHeaderText","headerBannerHtml","signatureHtml","footerHtml","disclaimerHtml","unsubscribeUrl"];x(r,t,o,n);const i={};return o.forEach(a=>{const c=a==="unsubscribeUrl"?q(r[a],`${t}.${a}`,n):k(r[a],`${t}.${a}`,a==="preHeaderText"?200:5e3,n,{trim:a==="preHeaderText"});c!==void 0&&(i[a]=c);}),i;}function Le(e){const n=[],t={};if(e.appearance!==void 0&&(t.appearance=Oe(e.appearance,n)),e.brandOverrides!==void 0&&(t.brandOverrides=Ne(e.brandOverrides,n)),e.fragments!==void 0&&(t.fragments=we(e.fragments,n)),e.viewUrl!==void 0){const r=q(e.viewUrl,"presentation.viewUrl",n);r!==void 0&&(t.viewUrl=r);}return{value:t,issues:n};}const L=["SUN","MON","TUE","WED","THU","FRI","SAT"],re=new Map(L.map((e,n)=>[e,n])),R=[1,2,3,4,5],oe=[1,2,3,6,12],ie={1:"first",2:"second",3:"third",4:"fourth",[-1]:"last"},nn={frequency:"weekly",hour:9,minute:0,weekdays:[1]},$={ok:!1,issue:"Choose a supported schedule."};function Fe(e){if(typeof e!="string"||e.length===0||e!==e.trim()||/^(?:(?:UTC|GMT)[+-]|[+-]\d{2}:\d{2}$)/.test(e))return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:e}).format(),!0;}catch{return!1;}}function Re(e){return Number.isInteger(e.minute)&&e.minute>=0&&e.minute<=59&&Number.isInteger(e.hour)&&e.hour>=0&&e.hour<=23;}function ae(e){if(e.length===0)return null;const n=[...e].sort((t,r)=>t-r);return n.some((t,r)=>!Number.isInteger(t)||t<0||t>6||r>0&&t===n[r-1])?null:n;}function ce(e){const t=[...e.filter(o=>o!=="last")].sort((o,i)=>o-i);if(t.some((o,i)=>!Number.isInteger(o)||o<1||o>31||i>0&&o===t[i-1])||e.filter(o=>o==="last").length>1)return null;const r=e.includes("last")?[...t,"last"]:t;return r.length>0?r:null;}function D(e,n){const t=[];for(let r=0;r<12/e;r+=1)t.push((n+r*e)%12);return t.sort((r,o)=>r-o);}function Me(e,n){return e===1?"*":D(e,n).map(t=>t+1).join(",");}function le(e,n){return e.every(t=>Ke(t,n));}function rn(e){if(!Re(e))throw new Error("Choose a valid schedule time.");const n=`${e.minute} ${e.hour}`;switch(e.frequency){case"daily":return e.weekdaysOnly?`${n} * * ${R.map(t=>L[t]).join(",")}`:`${n} * * *`;case"weekly":{const t=ae(e.weekdays);if(!t)throw new Error("Choose at least one weekday.");return`${n} * * ${t.map(r=>L[r]).join(",")}`;}case"monthly":{if(!oe.includes(e.interval)||!Number.isInteger(e.startMonth)||e.startMonth<0||e.startMonth>=e.interval)throw new Error("Choose a valid month cycle.");const t=Me(e.interval,e.startMonth);if(e.on.type==="days"){const a=ce(e.on.days);if(!a)throw new Error("Choose at least one day of the month.");const c=D(e.interval,e.startMonth);if(!le(a,c))throw new Error("Choose a day that occurs in the chosen months.");const d=a.map(m=>m==="last"?"L":String(m)).join(",");return`${n} ${d} ${t} *`;}const{ordinal:r,weekday:o}=e.on;if(!Number.isInteger(o)||o<0||o>6||!(r in ie))throw new Error("Choose a valid weekday.");const i=L[o];return`${n} * ${t} ${r===-1?`${i}L`:`${i}#${r}`}`;}}}function Be(e){if(e==="*")return{interval:1,startMonth:0};const n=e.split(",");if(n.some(a=>!/^([1-9]|1[0-2])$/.test(a)))return null;const t=n.map(a=>Number(a)-1),r=12/t.length;if(!oe.includes(r))return null;const o=t[0],i=D(r,o);return o>=r||i.length!==t.length||i.some((a,c)=>a!==t[c])?null:{interval:r,startMonth:o};}function Ue(e){const n=e.split(",");if(n.some(o=>!/^(L|[1-9]|[12]\d|3[01])$/.test(o)))return null;const t=n.map(o=>o==="L"?"last":Number(o)),r=ce(t);return!r||r.some((o,i)=>o!==t[i])?null:r;}function Ve(e){const n=/^([A-Z]{3})(?:#([1-4])|(L))$/.exec(e);if(!n)return null;const t=re.get(n[1]);return t===void 0?null:{weekday:t,ordinal:n[3]?-1:Number(n[2])};}function de(e){if(typeof e!="string"||e.length===0||e!==e.trim()||e.includes(" "))return $;const n=e.split(" ");if(n.length!==5)return $;const[t,r,o,i,a]=n;if(!/^(0|[1-9]\d?)$/.test(t)||!/^(0|[1-9]\d?)$/.test(r))return $;const c=Number(t),d=Number(r);if(c>59||d>23)return $;if(i==="*"&&o==="*"&&a==="*")return{ok:!0,value:{frequency:"daily",hour:d,minute:c,weekdaysOnly:!1}};if(i==="*"&&o==="*"&&!a.includes("#")&&!a.endsWith("L")){const u=a.split(",").map(C=>re.get(C));if(u.some(C=>C===void 0))return $;const b=u,g=ae(b);return!g||g.some((C,O)=>C!==b[O])?$:g.length===R.length&&g.every((C,O)=>C===R[O])?{ok:!0,value:{frequency:"daily",hour:d,minute:c,weekdaysOnly:!0}}:{ok:!0,value:{frequency:"weekly",hour:d,minute:c,weekdays:g}};}const m=Be(i);if(!m)return $;if(o!=="*"&&a==="*"){const s=Ue(o),u=D(m.interval,m.startMonth);return!s||!le(s,u)?$:{ok:!0,value:{frequency:"monthly",hour:d,minute:c,...m,on:{type:"days",days:s}}};}if(o==="*"&&a!=="*"){const s=Ve(a);return s?{ok:!0,value:{frequency:"monthly",hour:d,minute:c,...m,on:{type:"weekday",...s}}}:$;}return $;}function Pe(e,n,t){return new Intl.DateTimeFormat(t,{hour:"numeric",minute:"2-digit",timeZone:"UTC"}).format(new Date(Date.UTC(2020,0,1,e,n)));}function ze(e,n){var t;if(e==="UTC")return"UTC";try{return((t=new Intl.DateTimeFormat(n,{timeZone:e,timeZoneName:"longGeneric"}).formatToParts(new Date(Date.UTC(2020,0,1))).find(o=>o.type==="timeZoneName"))==null?void 0:t.value)??e;}catch{return null;}}function ee(e){return e.length<=1?e.join(""):e.length===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`;}function je(e){const n=e%100;return n>=11&&n<=13?`${e}th`:`${e}${["th","st","nd","rd"][e%10]??"th"}`;}function qe(e,n,t){const r=(i,a)=>new Intl.DateTimeFormat(t,{month:a,timeZone:"UTC"}).format(new Date(Date.UTC(2020,i,1)));if(e===1)return"every month";if(e===12)return`${r(n,"long")} each year`;const o=D(e,n).map(i=>r(i,"short")).join(", ");return e===3?`each quarter (${o})`:`every ${e} months (${o})`;}function on(e,n,t="en-US"){const r=de(e);if(!r.ok)return null;try{const o=r.value,i=ze(n,t);if(!i)return null;const a=`at ${Pe(o.hour,o.minute,t)} ${i}`,c=d=>new Intl.DateTimeFormat(t,{weekday:"long",timeZone:"UTC"}).format(new Date(Date.UTC(2023,0,1+d)));switch(o.frequency){case"daily":return o.weekdaysOnly?`Every weekday, Monday to Friday, ${a}`:`Every day ${a}`;case"weekly":return`Every ${ee(o.weekdays.map(c))} ${a}`;case"monthly":{const d=qe(o.interval,o.startMonth,t);if(o.on.type==="weekday")return`On the ${ie[o.on.ordinal]} ${c(o.on.weekday)} of ${d} ${a}`;const m=o.on.days.map(s=>s==="last"?"last day":je(s));return`On the ${ee(m)} of ${d} ${a}`;}}}catch{return null;}}const se=[31,29,31,30,31,30,31,31,30,31,30,31];function Ke(e,n){return e==="last"||n.some(t=>e<=se[t]);}function an(e){if(e.frequency!=="monthly"||e.on.type!=="days")return null;const n=e.on.days.filter(o=>o!=="last");if(n.length===0)return null;const t=Math.max(...n),r=D(e.interval,e.startMonth).filter(o=>t>(o===1?28:se[o]));return r.length>0?{day:t,months:r}:null;}function Ge(e,n){return new Date(Date.UTC(e,n+1,0)).getUTCDate();}function He(e,n,t,r){const o=new Date(Date.UTC(n,t,r)).getUTCDay();switch(e.frequency){case"daily":return!e.weekdaysOnly||R.includes(o);case"weekly":return e.weekdays.includes(o);case"monthly":{if(!D(e.interval,e.startMonth).includes(t))return!1;const i=Ge(n,t);return e.on.type==="days"?e.on.days.some(a=>a==="last"?r===i:a===r):o!==e.on.weekday?!1:e.on.ordinal===-1?r+7>i:Math.ceil(r/7)===e.on.ordinal;}}}function cn(e,n,t,r){const o=de(e);if(!o.ok||!Fe(n))return[];const i=o.value,a=new Intl.DateTimeFormat("en-US",{timeZone:n,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric"}).formatToParts(t),c=s=>{var u;return Number((u=a.find(b=>b.type===s))==null?void 0:u.value);},d=new Date(Date.UTC(c("year"),c("month")-1,c("day")));c("hour")*60+c("minute")>=i.hour*60+i.minute&&d.setUTCDate(d.getUTCDate()+1);const m=[];for(let s=0;s<366*4*(r+1)&&m.length<r;s+=1)He(i,d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate())&&m.push(d.toISOString().slice(0,10)),d.setUTCDate(d.getUTCDate()+1);return m;}const We=Object.freeze(["PDF_ROW_LIMIT_EXCEEDED","PDF_SIZE_LIMIT_EXCEEDED","PDF_PAGE_LIMIT_EXCEEDED","TABLE_COMPLETENESS_UNVERIFIED","CARD_QUERY_FAILED","RENDER_NOT_READY","RENDER_TIMED_OUT","EXPORT_JOB_FAILED","ATTACHMENT_UNAVAILABLE","EXCEL_LIMIT_EXCEEDED","EXPORT_ROW_LIMIT_EXCEEDED","EXPORT_COUNT_UNAVAILABLE","EXPORT_NO_ROWS","CARD_FILE_LIMIT_EXCEEDED","IMAGE_TOO_LARGE","DOCUMENT_PAGE_OVERFLOW","DOCUMENT_ROW_LIMIT_EXCEEDED","DOCUMENT_SECTION_SETUP","REPORT_INPUTS_MISSING","REPORT_NEEDS_RESAVE"]),Xe=new Set(We);function Ze(e){return typeof e=="string"&&Xe.has(e);}function Ye(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const n=e;return typeof n.index!="number"||!Number.isInteger(n.index)||n.index<0||typeof n.title!="string"||!me.includes(n.format)||!Ze(n.code)||typeof n.reason!="string"||typeof n.diagnostic!="string"?null:{index:n.index,title:n.title,format:n.format,code:n.code,reason:n.reason,diagnostic:n.diagnostic};}function ln(e){if(!e||typeof e!="object"||Array.isArray(e))return[];const n=e.omittedAttachments;return Array.isArray(n)?n.flatMap(t=>{const r=Ye(t);return r?[r]:[];}):[];}const dn="Briefing run cancelled by user",Je=["sent","partly_sent","failed","not_set_up"];function Qe(e,n){var a;const t=n.sentCount??0,r=n.failedCount??0,o=e==="SLACK"&&n.channelName||null,i=((a=n.message)==null?void 0:a.trim())||null;switch(n.status){case"SENT":return{channel:e,status:"sent",sent:t,failed:0,destination:o,reason:null};case"FAILED":return{channel:e,status:t>0?"partly_sent":"failed",sent:t,failed:t>0?r:Math.max(r,1),destination:o,reason:i};case"NOT_CONFIGURED":return{channel:e,status:"not_set_up",sent:0,failed:0,destination:o,reason:i};default:return null;}}function w(e){return!!e&&typeof e=="object"&&!Array.isArray(e);}function et(e){if(!w(e))return null;const{channel:n,status:t,sent:r,failed:o,destination:i,reason:a}=e;return n!=="EMAIL"&&n!=="SLACK"||!Je.includes(t)?null:{channel:n,status:t,sent:typeof r=="number"?r:0,failed:typeof o=="number"?o:0,destination:typeof i=="string"&&i?i:null,reason:typeof a=="string"&&a?a:null};}function tt(e){return!w(e)||typeof e.status!="string"?null:{status:e.status,sentCount:typeof e.sentCount=="number"?e.sentCount:0,failedCount:typeof e.failedCount=="number"?e.failedCount:0,message:typeof e.message=="string"?e.message:"",channelName:typeof e.channelName=="string"?e.channelName:null};}function nt(e){return w(e)?{channels:("email"in e||"slack"in e?[["EMAIL",e.email],["SLACK",e.slack]]:[[e.channel==="SLACK"?"SLACK":"EMAIL",e]]).flatMap(([t,r])=>{const o=tt(r),i=o?Qe(t,o):null;return i?[i]:[];})}:null;}function sn(e){return w(e)?w(e.deliveryOutcome)&&Array.isArray(e.deliveryOutcome.channels)?{channels:e.deliveryOutcome.channels.flatMap(n=>{const t=et(n);return t?[t]:[];})}:nt(e.deliveryResult):null;}function mn(e){return e!=null&&e.role?e.type==="tenant"?e.role==="POWER_USER":["AUTHOR","ADMIN","SUPER_ADMIN"].includes(e.role):!1;}function fn(e){return e.canCreate?[...(e.scheduledReportAvailable?["scheduled_report"]:[]),...(e.analyticalBriefingsEnabled?["analytical_briefing"]:[])]:[];}function rt(e){const n=(e==null?void 0:e.channels)??[];return n.length===1&&n[0]==="EMAIL";}function ot(e){return e.body.type==="generated_analysis"?"Analytical briefing":e.body.type==="custom_message"&&e.attachments.length>0&&rt(e.deliveryConfig)?e.scheduleExpr?"Scheduled report":"On-demand report":"Plain briefing";}function un(e){const n=ot(e),t=n==="Scheduled report"||n==="On-demand report"?"report":"briefing";return{typeLabel:n,noun:t,pluralNoun:t==="report"?"reports":"briefings"};}const z="BRIEFING",it=["markdown","html"],j=["markdown"],B=20,f={name:500,description:2e3,instruction:5e4,customMessage:5e4,contentTitle:500,contentSummary:2e4,contentText:5e3,contentSql:5e4,contentItem:2e3,contentCell:500,attachmentTitle:500,presentationAudience:1e3,presentationTone:500,presentationFormat:2e3,id:500},I={maxBlocks:50,maxTableRows:100,maxTableColumns:20,maxTableCellCharacters:f.contentCell,maxParagraphCharacters:f.contentText,maxFindingCharacters:f.contentText,maxListItems:100,maxKpiTiles:8};function at(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;const n=e;if(typeof n.value!="number"||!Number.isFinite(n.value))return!1;const t=n.target;if(t===null||typeof t!="object"||Array.isArray(t))return!1;const r=t;return(r.kind==="metric"&&typeof r.metricId=="string"&&!!r.metricId.trim()||r.kind==="column"&&typeof r.columnKey=="string"&&!!r.columnKey.trim()||r.kind==="matrix_measure"&&typeof r.measureId=="string"&&!!r.measureId.trim())&&ne(n.format).ok;}function ct(e){return e==null?"":at(e)?xe(e.value,e.format):String(e);}function pn(e){return[e.delta,e.percentChange].filter(n=>n!=null).map(ct).filter(Boolean).join(" / ");}const me=["pdf","png","csv","xlsx"],fe=new Set(it),lt=/* @__PURE__ */new Set(["EMAIL","WEBHOOK","SLACK","IN_APP","TELEGRAM"]),U={maxToolCalls:{min:1,max:100},maxPlanningIterations:{min:1,max:10},maxRows:{min:1,max:1e5},timeoutMs:{min:1e3,max:30*6e4}},dt=/* @__PURE__ */new Set(["letter","legal","a4","a3","tabloid"]),st=/* @__PURE__ */new Set(["portrait","landscape"]),mt=/* @__PURE__ */new Set([",",";"," "]),ft=new Set(ke),ut=/* @__PURE__ */new Set(["current","all"]),pt=/* @__PURE__ */new Set(["concise","balanced","detailed"]),ht=/* @__PURE__ */new Set(["info","positive","warning","critical"]),yt=/* @__PURE__ */new Set(["text","number","currency","percent","date","boolean"]),gt=/* @__PURE__ */new Set(["left","center","right"]),Et=["matrix","pageSize","orientation","includeFilters","includeTimestamp","delimiter","csvEncoding","includeHeaders","useFormattedValues","sheetSelection","currentSheetId","currentSheetName","filterValues","inlineFilterValues","sheetFilterValues","filterLine","controlValues","controlDefinitions","cardControlDefinitions","controlBindings","tablePreferences","dashboardInputExecutionSnapshot","printInputCapture","selectedSheetId","cardType","allowDownload","theme"];class M extends Error{constructor(t){super(t.map(r=>`${r.field}: ${r.message}`).join("; "));J(this,"issues");this.name="BriefingContractError",this.issues=t;}}function ue(e){return typeof e=="object"&&e!==null&&!Array.isArray(e);}function l(e,n,t){e.push({field:n,message:t});}function E(e,n,t){return ue(e)?e:(l(t,n,"Expected an object."),{});}function p(e,n,t,r){const o=new Set(t);Object.keys(e).forEach(i=>{o.has(i)||l(r,n?`${n}.${i}`:i,`Unexpected field "${i}".`);});}function h(e,n,t,r){if(typeof e!="string")return l(r,n,"Expected a string."),"";const o=e.trim();return o?(o.length>t&&l(r,n,`Must be ${t} characters or fewer.`),o):(l(r,n,"Required value cannot be empty."),"");}function y(e,n,t,r){if(e==null)return;if(typeof e!="string"){l(r,n,"Expected a string.");return;}const o=e.trim();if(o)return o.length>t&&l(r,n,`Must be ${t} characters or fewer.`),o;}function bt(e,n,t,r){if(typeof e!="string")return l(r,n,"Expected a string."),"";const o=e.trim();return o.length>t&&l(r,n,`Must be ${t} characters or fewer.`),o;}function It(e,n,t){if(e!=null){if(!Number.isInteger(e)||Number(e)<0){l(t,n,"Expected a non-negative integer.");return;}return Number(e);}}function v(e,n,t,r={}){if(e==null)return r.required?(l(t,n,"Expected at least one evidence id."),[]):void 0;if(!Array.isArray(e))return l(t,n,"Expected an array."),r.required?[]:void 0;const o=[];return e.forEach((i,a)=>{const c=h(i,`${n}.${a}`,f.id,t);c&&!o.includes(c)&&o.push(c);}),r.required&&o.length===0&&l(t,n,"Expected at least one evidence id."),o.length>0||r.required?o:void 0;}function _(e,n,t,r){return e==null?n:typeof e!="boolean"?(l(r,t,"Expected a boolean."),n):e;}function $t(e,n){return e==null?"ACTIVE":e==="ACTIVE"||e==="PAUSED"||e==="DISABLED"?e:(l(n,"status","Expected ACTIVE, PAUSED, or DISABLED."),"ACTIVE");}function vt(e){return e.includes("@")&&e.includes(".")&&!e.includes(" ");}function pe(e,n){if(e==null)return{type:"project"};const t=E(e,"source",n),r=t.type;return r==="project"?(p(t,"source",["type"],n),{type:"project"}):r==="dashboard"?(p(t,"source",["type","dashboardId"],n),{type:"dashboard",dashboardId:h(t.dashboardId,"source.dashboardId",f.id,n)}):(l(n,"source.type","Expected project or dashboard."),{type:"project"});}function he(e,n){const t=E(e,"body",n),r=t.type;return r==="generated_analysis"?(p(t,"body",["type","instruction"],n),{type:"generated_analysis",instruction:h(t.instruction,"body.instruction",f.instruction,n)}):r==="custom_message"?(p(t,"body",["type","message"],n),{type:"custom_message",message:bt(t.message,"body.message",f.customMessage,n)}):r==="none"?(p(t,"body",["type"],n),{type:"none"}):(l(n,"body.type","Expected generated_analysis, custom_message, or none."),{type:"none"});}function Ct(e,n){if(e==null)return[...j];if(!Array.isArray(e))return l(n,"presentation.artifactFormats","Expected an array."),[...j];if(e.length===0)return l(n,"presentation.artifactFormats","Choose at least one artifact format."),[];const t=[];return e.forEach((r,o)=>{if(typeof r!="string"||!fe.has(r)){l(n,`presentation.artifactFormats.${o}`,"Expected markdown or html.");return;}t.includes(r)||t.push(r);}),t;}function ye(e,n){if(e==null)return{artifactFormats:[...j],includeEvidence:!0,includeSql:!0};const t=E(e,"presentation",n);p(t,"presentation",["artifactFormats","includeEvidence","includeSql","audience","tone","format","appearance","brandOverrides","fragments","viewUrl"],n);const r={artifactFormats:Ct(t.artifactFormats,n),includeEvidence:_(t.includeEvidence,!0,"presentation.includeEvidence",n),includeSql:_(t.includeSql,!0,"presentation.includeSql",n)},o=y(t.audience,"presentation.audience",f.presentationAudience,n),i=y(t.tone,"presentation.tone",f.presentationTone,n),a=y(t.format,"presentation.format",f.presentationFormat,n);o&&(r.audience=o),i&&(r.tone=i),a&&(r.format=a);const c=Le(t);return c.issues.forEach(d=>l(n,d.field,d.message)),Object.assign(r,c.value),r;}function Tt(e,n,t){return Array.isArray(e)?(e.length===0&&l(t,n,"Expected at least one item."),e.length>I.maxListItems&&l(t,n,`Must have ${I.maxListItems} items or fewer.`),e.slice(0,I.maxListItems).map((r,o)=>h(r,`${n}.${o}`,f.contentItem,t)).filter(Boolean)):(l(t,n,"Expected an array."),[]);}function xt(e,n,t){const r=E(e,n,t);if(r.kind==="metric")return p(r,n,["kind","metricId"],t),{kind:"metric",metricId:h(r.metricId,`${n}.metricId`,f.id,t)};if(r.kind==="column")return p(r,n,["kind","columnKey"],t),{kind:"column",columnKey:h(r.columnKey,`${n}.columnKey`,f.id,t)};if(r.kind==="matrix_measure")return p(r,n,["kind","measureId"],t),{kind:"matrix_measure",measureId:h(r.measureId,`${n}.measureId`,f.id,t)};l(t,`${n}.kind`,"Expected metric, column, or matrix_measure.");}function ge(e,n,t){if(e===null||typeof e!="object"||Array.isArray(e))return;const r=E(e,n,t);if(!Object.prototype.hasOwnProperty.call(r,"target")&&!Object.prototype.hasOwnProperty.call(r,"format"))return;p(r,n,["value","target","format"],t),(typeof r.value!="number"||!Number.isFinite(r.value))&&l(t,`${n}.value`,"Expected a finite number.");const o=xt(r.target,`${n}.target`,t),i=ne(r.format);if(i.ok||i.issues.forEach(a=>l(t,a.path==="$"?`${n}.format`:`${n}.format.${a.path}`,a.message)),!(typeof r.value!="number"||!Number.isFinite(r.value)||!o||!i.ok))return{value:r.value,target:o,format:i.value};}function S(e,n,t){if(typeof e=="string")return e;if(typeof e=="number"){if(!Number.isFinite(e)){l(t,n,"Expected a finite number.");return;}return e;}const r=ge(e,n,t);if(r)return r;l(t,n,"Expected a string, number, or structured numeric value.");}function At(e,n,t){if(e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean")return typeof e=="string"&&e.length>f.contentCell?(l(t,n,`Must be ${f.contentCell} characters or fewer.`),e.slice(0,f.contentCell)):typeof e=="number"&&!Number.isFinite(e)?(l(t,n,"Expected a finite number."),null):e;const r=ge(e,n,t);return r||(l(t,n,"Expected a string, number, boolean, structured numeric value, or null."),null);}function St(e,n,t){if(!Array.isArray(e))return l(t,n,"Expected an array."),[];e.length===0&&l(t,n,"Expected at least one column."),e.length>I.maxTableColumns&&l(t,n,`Must have ${I.maxTableColumns} columns or fewer.`);const r=/* @__PURE__ */new Set();return e.slice(0,I.maxTableColumns).map((o,i)=>{const a=`${n}.${i}`,c=E(o,a,t);p(c,a,["key","label","kind","align"],t);const d=h(c.key,`${a}.key`,f.id,t);d&&(r.has(d)&&l(t,`${a}.key`,"Column key must be unique."),r.add(d));const m=h(c.label,`${a}.label`,f.contentTitle,t),s=A(c.kind,`${a}.kind`,yt,"text, number, currency, percent, date, or boolean",t),u=A(c.align,`${a}.align`,gt,"left, center, or right",t);return{key:d,label:m,...(s?{kind:s}:{}),...(u?{align:u}:{})};});}function kt(e,n,t,r){if(!Array.isArray(e))return l(r,n,"Expected an array."),[];e.length>I.maxTableRows&&l(r,n,`Must have ${I.maxTableRows} rows or fewer.`);const o=new Set(t.map(i=>i.key).filter(Boolean));return e.slice(0,I.maxTableRows).map((i,a)=>{const c=`${n}.${a}`,d=E(i,c,r);return Object.keys(d).forEach(m=>{o.has(m)||l(r,`${c}.${m}`,`Unexpected table cell "${m}".`);}),Object.fromEntries(t.map(m=>[m.key,At(d[m.key]??null,`${c}.${m.key}`,r)]));});}function _t(e,n,t){const r=`content.blocks.${n}`,o=E(e,r,t),i=o.type;if(i==="heading"){p(o,r,["type","text","level","evidenceIds"],t);const a=o.level===void 0||o.level===null?void 0:o.level===2||o.level===3?o.level:void 0;o.level!==void 0&&o.level!==null&&a===void 0&&l(t,`${r}.level`,"Expected 2 or 3.");const c=v(o.evidenceIds,`${r}.evidenceIds`,t);return{type:"heading",text:h(o.text,`${r}.text`,f.contentTitle,t),...(a?{level:a}:{}),...(c?{evidenceIds:c}:{})};}if(i==="paragraph"){p(o,r,["type","text","evidenceIds"],t);const a=v(o.evidenceIds,`${r}.evidenceIds`,t);return{type:"paragraph",text:h(o.text,`${r}.text`,f.contentText,t),...(a?{evidenceIds:a}:{})};}if(i==="finding"){p(o,r,["type","title","text","severity","evidenceIds"],t);const a=y(o.title,`${r}.title`,f.contentTitle,t),c=A(o.severity,`${r}.severity`,ht,"info, positive, warning, or critical",t);return{type:"finding",...(a?{title:a}:{}),text:h(o.text,`${r}.text`,f.contentText,t),...(c?{severity:c}:{}),evidenceIds:v(o.evidenceIds,`${r}.evidenceIds`,t,{required:!0})??[]};}if(i==="bullets"||i==="actions"||i==="limitations"){p(o,r,["type","title","items","evidenceIds"],t);const a=y(o.title,`${r}.title`,f.contentTitle,t),c=v(o.evidenceIds,`${r}.evidenceIds`,t);return{type:i,...(a?{title:a}:{}),items:Tt(o.items,`${r}.items`,t),...(c?{evidenceIds:c}:{})};}if(i==="metric"){p(o,r,["type","label","value","previousValue","delta","percentChange","unit","evidenceIds"],t);const a=S(o.value,`${r}.value`,t)??"";a===""&&l(t,`${r}.value`,"Expected a non-empty string, number, or structured numeric value.");const c=o.previousValue===void 0||o.previousValue===null?o.previousValue:S(o.previousValue,`${r}.previousValue`,t),d=o.delta===void 0||o.delta===null?o.delta:S(o.delta,`${r}.delta`,t),m=o.percentChange===void 0||o.percentChange===null?o.percentChange:S(o.percentChange,`${r}.percentChange`,t),s=y(o.unit,`${r}.unit`,f.contentTitle,t),u=v(o.evidenceIds,`${r}.evidenceIds`,t);return{type:"metric",label:h(o.label,`${r}.label`,f.contentTitle,t),value:a,...(c!==void 0?{previousValue:c}:{}),...(d!==void 0?{delta:d}:{}),...(m!==void 0?{percentChange:m}:{}),...(s?{unit:s}:{}),...(u?{evidenceIds:u}:{})};}if(i==="kpi_grid"){p(o,r,["type","title","tiles","evidenceIds"],t);const a=y(o.title,`${r}.title`,f.contentTitle,t),c=Array.isArray(o.tiles)?o.tiles:[];Array.isArray(o.tiles)||l(t,`${r}.tiles`,"Expected an array."),c.length===0&&l(t,`${r}.tiles`,"Expected at least one tile."),c.length>I.maxKpiTiles&&l(t,`${r}.tiles`,`Must have ${I.maxKpiTiles} tiles or fewer.`);const d=c.slice(0,I.maxKpiTiles).map((s,u)=>{const b=`${r}.tiles.${u}`,g=E(s,b,t);p(g,b,["label","value","previousValue","delta","percentChange","unit","evidenceIds"],t);const C=S(g.value,`${b}.value`,t)??"";C===""&&l(t,`${b}.value`,"Expected a non-empty string, number, or structured numeric value.");const O=g.previousValue===void 0||g.previousValue===null?g.previousValue:S(g.previousValue,`${b}.previousValue`,t),W=g.delta===void 0||g.delta===null?g.delta:S(g.delta,`${b}.delta`,t),X=g.percentChange===void 0||g.percentChange===null?g.percentChange:S(g.percentChange,`${b}.percentChange`,t),Z=y(g.unit,`${b}.unit`,f.contentTitle,t),Y=v(g.evidenceIds,`${b}.evidenceIds`,t);return{label:h(g.label,`${b}.label`,f.contentTitle,t),value:C,...(O!==void 0?{previousValue:O}:{}),...(W!==void 0?{delta:W}:{}),...(X!==void 0?{percentChange:X}:{}),...(Z?{unit:Z}:{}),...(Y?{evidenceIds:Y}:{})};}),m=v(o.evidenceIds,`${r}.evidenceIds`,t);return{type:"kpi_grid",...(a?{title:a}:{}),tiles:d,...(m?{evidenceIds:m}:{})};}if(i==="progress"){p(o,r,["type","label","value","detail","evidenceIds"],t);const a=typeof o.value=="number"&&Number.isFinite(o.value)?o.value:0;(typeof o.value!="number"||!Number.isFinite(o.value))&&l(t,`${r}.value`,"Expected a finite number.");const c=y(o.detail,`${r}.detail`,f.contentText,t),d=v(o.evidenceIds,`${r}.evidenceIds`,t);return{type:"progress",label:h(o.label,`${r}.label`,f.contentTitle,t),value:a,...(c?{detail:c}:{}),...(d?{evidenceIds:d}:{})};}if(i==="table"){p(o,r,["type","id","title","columns","rows","caption","totalRows","evidenceIds"],t);const a=St(o.columns,`${r}.columns`,t),c=y(o.title,`${r}.title`,f.contentTitle,t),d=y(o.id,`${r}.id`,f.id,t),m=y(o.caption,`${r}.caption`,f.contentItem,t),s=It(o.totalRows,`${r}.totalRows`,t),u=v(o.evidenceIds,`${r}.evidenceIds`,t);return{type:"table",...(d?{id:d}:{}),...(c?{title:c}:{}),columns:a,rows:kt(o.rows,`${r}.rows`,a,t),...(m?{caption:m}:{}),...(s!==void 0?{totalRows:s}:{}),...(u?{evidenceIds:u}:{})};}if(i==="evidence_appendix"){p(o,r,["type","title","evidenceIds"],t);const a=y(o.title,`${r}.title`,f.contentTitle,t);return{type:"evidence_appendix",...(a?{title:a}:{}),evidenceIds:v(o.evidenceIds,`${r}.evidenceIds`,t,{required:!0})??[]};}if(i==="sql"){p(o,r,["type","title","sql","evidenceIds"],t);const a=y(o.title,`${r}.title`,f.contentTitle,t),c=h(o.sql,`${r}.sql`,f.contentSql,t),d=v(o.evidenceIds,`${r}.evidenceIds`,t);return{type:"sql",...(a?{title:a}:{}),sql:c,...(d?{evidenceIds:d}:{})};}return l(t,`${r}.type`,"Expected heading, paragraph, finding, bullets, metric, kpi_grid, progress, table, actions, limitations, sql, or evidence_appendix."),{type:"paragraph",text:""};}function Dt(e){const n=[],t=E(e,"content",n);p(t,"content",["version","title","summary","blocks"],n),t.version!==1&&l(n,"content.version","Expected version 1.");const r=y(t.title,"content.title",f.contentTitle,n),o=y(t.summary,"content.summary",f.contentSummary,n);Array.isArray(t.blocks)||l(n,"content.blocks","Expected an array.");const i=Array.isArray(t.blocks)?t.blocks:[];i.length===0&&l(n,"content.blocks","Expected at least one block."),i.length>I.maxBlocks&&l(n,"content.blocks",`Must have ${I.maxBlocks} blocks or fewer.`);const a=i.slice(0,I.maxBlocks).map((c,d)=>_t(c,d,n));return K(n),{version:1,...(r?{title:r}:{}),...(o?{summary:o}:{}),blocks:a};}function hn(e){try{return{valid:!0,value:Dt(e),issues:[]};}catch(n){if(n instanceof M)return{valid:!1,issues:n.issues};throw n;}}function F(e,n,t,r){return typeof e=="string"&&t.includes(e)?e:(l(r,n,`Expected ${t.join(" or ")}.`),t[0]);}function A(e,n,t,r,o){if(e!=null){if(typeof e=="string"&&t.has(e))return e;l(o,n,`Expected ${r}.`);}}function Ot(e,n,t){if(e!=null){if(!Array.isArray(e)){l(t,n,"Expected an array.");return;}return e;}}function Nt(e,n,t){if(e!=null){if(!ue(e)){l(t,n,"Expected an object.");return;}return e;}}function wt(e,n,t){if(e==null)return;const r=E(e,n,t);p(r,n,Et,t);const o={};if(r.matrix!==void 0){const s=E(r.matrix,`${n}.matrix`,t);p(s,`${n}.matrix`,["config","content"],t);const u=Se.safeParse(s.config);u.success||l(t,`${n}.matrix.config`,"Expected a valid Matrix definition.");const b=A(s.content,`${n}.matrix.content`,/* @__PURE__ */new Set(["current","all","flat"]),"current, all, or flat",t);b||l(t,`${n}.matrix.content`,"Choose Matrix export content."),u.success&&b&&(o.matrix={config:u.data,content:b});}const i=A(r.pageSize,`${n}.pageSize`,dt,"letter, legal, a4, a3, or tabloid",t),a=A(r.orientation,`${n}.orientation`,st,"portrait or landscape",t),c=A(r.delimiter,`${n}.delimiter`,mt,"comma, semicolon, or tab",t),d=A(r.csvEncoding,`${n}.csvEncoding`,ft,"utf-8-bom or utf-8",t),m=A(r.sheetSelection,`${n}.sheetSelection`,ut,"current or all",t);i&&(o.pageSize=i),a&&(o.orientation=a),c&&(o.delimiter=c),d&&(o.csvEncoding=d),m&&(o.sheetSelection=m);for(const s of["includeFilters","includeTimestamp","includeHeaders","useFormattedValues","allowDownload"])if(!(r[s]===void 0||r[s]===null)){if(typeof r[s]!="boolean"){l(t,`${n}.${s}`,"Expected a boolean.");continue;}o[s]=r[s];}for(const s of["currentSheetId","currentSheetName","selectedSheetId","cardType","theme"]){const u=y(r[s],`${n}.${s}`,f.id,t);u&&(o[s]=u);}for(const s of["filterValues","inlineFilterValues","sheetFilterValues","controlDefinitions","cardControlDefinitions","controlBindings"]){const u=Ot(r[s],`${n}.${s}`,t);u&&(o[s]=u);}for(const s of["controlValues","tablePreferences","dashboardInputExecutionSnapshot","printInputCapture"]){const u=Nt(r[s],`${n}.${s}`,t);u&&(o[s]=u);}return Object.keys(o).length>0?o:void 0;}function V(e,n,t,r){const o=y(n,t,f.attachmentTitle,r);return o&&(e.title=o),e;}function P(e,n,t,r){const o=wt(n,t,r);return o!=null&&o.printInputCapture&&e.type!=="dashboard"&&l(r,`${t}.printInputCapture`,"Only a full dashboard attachment can carry printInputCapture."),o&&(e.settings=o),e;}function Lt(e,n,t){const r=`attachments.${n}`,o=E(e,r,t),i=o.type;if(i==="dashboard"){p(o,r,["type","dashboardId","format","title","settings"],t);const a=V({type:"dashboard",dashboardId:h(o.dashboardId,`${r}.dashboardId`,f.id,t),format:F(o.format,`${r}.format`,["pdf"],t)},o.title,`${r}.title`,t);return P(a,o.settings,`${r}.settings`,t);}if(i==="dashboard_sheet"||i==="document_sheet"){p(o,r,["type","dashboardId","sheetId","format","title","settings"],t);const a=V({type:i,dashboardId:h(o.dashboardId,`${r}.dashboardId`,f.id,t),sheetId:h(o.sheetId,`${r}.sheetId`,f.id,t),format:F(o.format,`${r}.format`,i==="dashboard_sheet"?["pdf","png"]:["pdf"],t)},o.title,`${r}.title`,t);return te(P(a,o.settings,`${r}.settings`,t));}if(i==="card"){p(o,r,["type","dashboardId","cardId","format","title","settings"],t);const a=V({type:"card",dashboardId:h(o.dashboardId,`${r}.dashboardId`,f.id,t),cardId:h(o.cardId,`${r}.cardId`,f.id,t),format:F(o.format,`${r}.format`,me,t)},o.title,`${r}.title`,t);return te(P(a,o.settings,`${r}.settings`,t));}return l(t,`${r}.type`,"Expected dashboard, dashboard_sheet, document_sheet, or card."),{type:"dashboard",dashboardId:"",format:"pdf"};}function te(e){if(e.format!=="png"||!e.settings)return e;const{pageSize:n,orientation:t,includeFilters:r,...o}=e.settings,{settings:i,...a}=e;return Object.keys(o).length>0?{...a,settings:o}:a;}function Ft(e){switch(e.type){case"dashboard":return`${e.type}:${e.dashboardId}:${e.format}`;case"dashboard_sheet":case"document_sheet":return`${e.type}:${e.dashboardId}:${e.sheetId}:${e.format}`;case"card":return`${e.type}:${e.dashboardId}:${e.cardId}:${e.format}`;}}function Ee(e,n){if(e==null)return[];if(!Array.isArray(e))return l(n,"attachments","Expected an array."),[];e.length>B&&l(n,"attachments",`Choose ${B} attachments or fewer.`);const t=e.slice(0,B).map((o,i)=>Lt(o,i,n)),r=/* @__PURE__ */new Set();return t.forEach((o,i)=>{var d,m,s,u;const a=o.type==="card"?(d=o.settings)==null?void 0:d.cardType:void 0;(m=o.settings)!=null&&m.matrix&&(o.type!=="card"||a!==void 0&&a!=="matrixTable"||o.settings.matrix.content==="flat"&&o.format==="pdf")&&l(n,`attachments.${i}.settings.matrix`,"Matrix settings require a matrixTable card attachment; flat content requires CSV or Excel."),o.format==="png"&&(s=o.settings)!=null&&s.matrix&&o.settings.matrix.content!=="current"&&l(n,`attachments.${i}.settings.matrix.content`,"A Matrix PNG image shows the current layout."),o.format==="xlsx"&&a!==void 0&&!((u=o.settings)!=null&&u.matrix)&&!_e(a)&&l(n,`attachments.${i}.format`,"Excel attachments require a Table, Detail Table or Matrix card.");const c=Ft(o);r.has(c)&&l(n,`attachments.${i}`,"Duplicate attachment."),r.add(c);}),t;}function be(e,n){if(e==null)return;const t=E(e,"limits",n);p(t,"limits",Object.keys(U),n);const r={};return Object.keys(U).forEach(o=>{const i=t[o];if(i==null)return;const a=U[o];if(typeof i!="number"||!Number.isInteger(i)||i<a.min||i>a.max){l(n,`limits.${o}`,`Expected an integer between ${a.min} and ${a.max}.`);return;}r[o]=i;}),Object.keys(r).length>0?r:void 0;}function K(e){if(e.length>0)throw new M(e);}function Ie(e,n,t){!(e.type==="generated_analysis"||e.type==="custom_message"&&!!e.message.trim())&&n.length===0&&l(t,"body","Add briefing instructions, a custom message, or at least one attachment.");}function Rt(e,n,t){e==null||e.forEach((r,o)=>{const i=`${t}.${o}.scope`,a=r.scope.attachmentIndex;if(a===void 0)throw new N(`${i}.attachmentIndex must identify the attachment that owns this presentation entry.`);const c=n[a];if(!c)throw new N(`${i}.attachmentIndex must identify an existing attachment.`);if(r.scope.dashboardId!==c.dashboardId)throw new N(`${i}.dashboardId must match the dashboard selected by the referenced attachment.`);if(c.type==="card"&&r.scope.cardId!==c.cardId)throw new N(`${i}.cardId must match the card selected by the referenced attachment.`);});}function $e(e){const n=[],t=E(e,"jobConfig",n);p(t,"jobConfig",["kind","presentationExecutionSnapshot","source","body","attachments","presentation","limits"],n),t.kind!==z&&l(n,"kind","Expected BRIEFING.");let r;try{r=Ae(t.presentationExecutionSnapshot);}catch(m){if(m instanceof N)throw m;l(n,"jobConfig.presentationExecutionSnapshot",m instanceof Error?m.message:"Invalid presentation snapshot.");}const o=pe(t.source,n),i=he(t.body,n),a=Ee(t.attachments,n),c=ye(t.presentation,n),d=be(t.limits,n);return Ie(i,a,n),Rt(r==null?void 0:r.resolvedFormats,a,"jobConfig.presentationExecutionSnapshot.resolvedFormats"),K(n),{kind:z,presentationExecutionSnapshot:r,source:o,body:i,attachments:a,presentation:c,...(d?{limits:d}:{})};}function yn(e){return $e({...e,kind:z});}function G(e,n,t,r="deliveryConfig.recipients"){const o=`${r}.${n}`,i=E(e,o,t),a=i.type;if(a==="email"){p(i,o,["type","address","name"],t);const c=h(i.address,`${o}.address`,f.id,t),d=y(i.name,`${o}.name`,f.attachmentTitle,t);return c&&!vt(c)&&l(t,`${o}.address`,"Email address is invalid."),{type:"email",address:c,...(d?{name:d}:{})};}return a==="user"?(p(i,o,["type","userId"],t),{type:"user",userId:h(i.userId,`${o}.userId`,f.id,t)}):a==="tenant_user"?(p(i,o,["type","tenantUserId"],t),{type:"tenant_user",tenantUserId:h(i.tenantUserId,`${o}.tenantUserId`,f.id,t)}):a==="group"?(p(i,o,["type","groupId"],t),{type:"group",groupId:h(i.groupId,`${o}.groupId`,f.id,t)}):(l(t,`${o}.type`,"Expected email, user, tenant_user, or group."),{type:"email",address:""});}function Mt(e,n){return e==null?[]:Array.isArray(e)?e.map((t,r)=>G(t,r,n)):(l(n,"deliveryConfig.recipients","Expected an array."),[]);}function Bt(e,n){if(!Array.isArray(e))return l(n,"deliveryConfig.channels","Expected an array."),[];const t=[];return e.forEach((r,o)=>{if(!ve(r)){l(n,`deliveryConfig.channels.${o}`,"Expected EMAIL, WEBHOOK, SLACK, IN_APP, or TELEGRAM.");return;}t.includes(r)||t.push(r);}),t;}function Ut(e,n,t){if(e==null)return;const r=E(e,n,t),o={};return Object.entries(r).forEach(([i,a])=>{if(typeof a!="string"){l(t,`${n}.${i}`,"Expected a string.");return;}o[i]=a.trim();}),Object.keys(o).length>0?o:void 0;}function Vt(e,n,t){if(e==null)return;const r=E(e,n,t);p(r,n,["url","method","headers","secretEncrypted"],t);const o=r.method===void 0||r.method===null?void 0:F(r.method,`${n}.method`,["POST","PUT"],t),i=Ut(r.headers,`${n}.headers`,t),a=y(r.secretEncrypted,`${n}.secretEncrypted`,2e3,t);return{url:h(r.url,`${n}.url`,2e3,t),...(o?{method:o}:{}),...(i?{headers:i}:{}),...(a?{secretEncrypted:a}:{})};}function Pt(e,n,t){const r=E(e,n,t),o=r.type;if(o==="channel"){p(r,n,["type","channelId","channelName","isPrivate"],t);const i=y(r.channelName,`${n}.channelName`,f.attachmentTitle,t),a=r.isPrivate===void 0||r.isPrivate===null?void 0:_(r.isPrivate,!1,`${n}.isPrivate`,t);return{type:"channel",channelId:h(r.channelId,`${n}.channelId`,f.id,t),...(i?{channelName:i}:{}),...(a!==void 0?{isPrivate:a}:{})};}return o==="dm"?(p(r,n,["type","recipient"],t),l(t,`${n}.type`,"Slack DM delivery is not supported in V1."),{type:"dm",recipient:G(r.recipient,0,t,`${n}.recipient`)}):(l(t,`${n}.type`,"Expected channel."),{type:"channel",channelId:""});}function zt(e,n,t){if(e==null)return;if(!Array.isArray(e)){l(t,n,"Expected an array.");return;}const r=e.map((o,i)=>G(o,i,t,n));return r.length>0?r:void 0;}function jt(e,n,t){if(e==null)return;const r=E(e,n,t);p(r,n,["destination","threadMentions","postThreadDetail","includeDashboardLink","includeBriefingLink"],t);const o=zt(r.threadMentions,`${n}.threadMentions`,t),i=_(r.postThreadDetail,!0,`${n}.postThreadDetail`,t),a=_(r.includeDashboardLink,!0,`${n}.includeDashboardLink`,t),c=_(r.includeBriefingLink,!0,`${n}.includeBriefingLink`,t);return{destination:Pt(r.destination,`${n}.destination`,t),...(o?{threadMentions:o}:{}),...(r.postThreadDetail!==void 0?{postThreadDetail:i}:{}),...(r.includeDashboardLink!==void 0?{includeDashboardLink:a}:{}),...(r.includeBriefingLink!==void 0?{includeBriefingLink:c}:{})};}function qt(e,n,t){const r=E(e,n,t);p(r,n,["subjectOverride","titleOverride","summaryOverride","actionBlockVisible","formatProfile","slackConfig","webhookConfig"],t);const o=A(r.formatProfile,`${n}.formatProfile`,pt,"concise, balanced, or detailed",t),i=y(r.subjectOverride,`${n}.subjectOverride`,500,t),a=y(r.titleOverride,`${n}.titleOverride`,500,t),c=y(r.summaryOverride,`${n}.summaryOverride`,2e3,t),d=_(r.actionBlockVisible,!0,`${n}.actionBlockVisible`,t),m=Vt(r.webhookConfig,`${n}.webhookConfig`,t),s=jt(r.slackConfig,`${n}.slackConfig`,t);return{...(o?{formatProfile:o}:{}),...(i?{subjectOverride:i}:{}),...(a?{titleOverride:a}:{}),...(c?{summaryOverride:c}:{}),...(r.actionBlockVisible!==void 0?{actionBlockVisible:d}:{}),...(s?{slackConfig:s}:{}),...(m?{webhookConfig:m}:{})};}function Kt(e,n){if(e==null)return;const t=E(e,"deliveryConfig.channelConfigs",n),r={};return Object.entries(t).forEach(([o,i])=>{if(!ve(o)){l(n,`deliveryConfig.channelConfigs.${o}`,"Expected a supported delivery channel.");return;}r[o]=qt(i,`deliveryConfig.channelConfigs.${o}`,n);}),Object.keys(r).length>0?r:void 0;}function Gt(e,n){var d,m,s;if(e==null)return null;const t=E(e,"deliveryConfig",n);p(t,"deliveryConfig",["recipients","channels","channelConfigs"],n);const r=Kt(t.channelConfigs,n),o=Mt(t.recipients,n),i=Bt(t.channels,n),a=((m=(d=r==null?void 0:r.SLACK)==null?void 0:d.slackConfig)==null?void 0:m.destination.type)==="channel"&&!!r.SLACK.slackConfig.destination.channelId.trim();return i.some(u=>u!=="SLACK")&&o.length===0&&l(n,"deliveryConfig.recipients","Add at least one recipient or remove delivery config."),i.length===0&&l(n,"deliveryConfig.channels","Choose at least one delivery channel or remove delivery config."),i.includes("SLACK")&&!a&&l(n,"deliveryConfig.channelConfigs.SLACK.slackConfig.destination.channelId","Choose a Slack channel destination."),!i.includes("SLACK")&&(s=r==null?void 0:r.SLACK)!=null&&s.slackConfig&&l(n,"deliveryConfig.channelConfigs.SLACK","Slack config requires SLACK in deliveryConfig.channels."),{recipients:o,channels:i,...(r?{channelConfigs:r}:{})};}function H(e){const n=[],t=E(e,"draft",n);p(t,"draft",["name","description","status","scheduleExpr","timezone","source","body","attachments","presentation","limits","deliveryConfig"],n);const r=h(t.name,"name",f.name,n),o=y(t.description,"description",f.description,n)??null,i=y(t.scheduleExpr,"scheduleExpr",500,n)??null,a=y(t.timezone,"timezone",200,n)??"UTC",c=$t(t.status,n),d=pe(t.source,n),m=he(t.body,n),s=Ee(t.attachments,n),u=ye(t.presentation,n),b=be(t.limits,n),g=Gt(t.deliveryConfig,n);return Ie(m,s,n),K(n),{name:r,description:o,status:c,scheduleExpr:i,timezone:a,source:d,body:m,attachments:s,presentation:u,...(b?{limits:b}:{}),deliveryConfig:g};}function gn(e){return H(e);}function En(e){return H(e);}function bn(e){try{return{valid:!0,value:H(e),issues:[]};}catch(n){if(n instanceof M)return{valid:!1,issues:n.issues};throw n;}}function In(e){try{return{valid:!0,value:$e(e),issues:[]};}catch(n){if(n instanceof M)return{valid:!1,issues:n.issues};throw n;}}function $n(e){return typeof e=="string"&&fe.has(e);}function ve(e){return typeof e=="string"&<.has(e);}export{it as BRIEFING_ARTIFACT_FORMATS,me as BRIEFING_ATTACHMENT_FORMATS,We as BRIEFING_ATTACHMENT_OMISSION_CODES,I as BRIEFING_CONTENT_LIMITS,Je as BRIEFING_DELIVERY_OUTCOME_STATUSES,z as BRIEFING_KIND,dn as BRIEFING_RUN_CANCELLED_ERROR,f as BRIEFING_TEXT_LIMITS,M as BriefingContractError,j as DEFAULT_BRIEFING_ARTIFACT_FORMATS,nn as DEFAULT_BRIEFING_SCHEDULE,B as MAX_BRIEFING_ATTACHMENTS,Tn as briefingAttachmentFileTraits,xn as briefingAttachmentFormatLabel,An as briefingAttachmentNeedsExportJob,Sn as briefingAttachmentProduction,Qe as briefingDeliveryChannelOutcome,Ke as briefingScheduleDayOccurs,D as briefingScheduleMonths,an as briefingScheduleShortMonths,yn as buildBriefingJobConfig,rn as buildBriefingScheduleExpr,gn as buildCreateBriefingRequest,kn as buildDashboardTemporalSnapshotEntries,_n as buildMatrixDeliveryEnvelope,En as buildUpdateBriefingRequest,mn as canCreateBriefingForUser,ce as canonicalBriefingMonthDays,Dn as captureMatrixExport,On as completeBriefingCardAttachment,Nn as completeBriefingCardAttachmentSettings,on as describeBriefingSchedule,pn as formatBriefingComparisonValues,ct as formatBriefingDisplayValue,wn as getBriefingCardAttachmentCapability,Ln as getBriefingCardAttachmentFormats,fn as getBriefingCreationIntents,ot as getBriefingDisplayTypeLabel,un as getBriefingPresentation,Fn as getDefaultBriefingCardAttachmentFormat,$n as isBriefingArtifactFormat,Ze as isBriefingAttachmentOmissionCode,ve as isBriefingDeliveryChannel,at as isBriefingNumericValue,_e as isBriefingTableExportCardType,rt as isEmailOnlyBriefingDelivery,Fe as isValidBriefingTimezone,Rn as matrixDeliveryPayloadSchema,Mn as matrixDeliveryQuerySchema,cn as nextBriefingScheduleDates,Dt as normalizeBriefingContentDocument,H as normalizeBriefingDraft,$e as normalizeBriefingJobConfig,de as parseBriefingScheduleExpr,Bn as readBriefingCardFacts,sn as readBriefingDeliveryOutcome,ln as readBriefingOmittedAttachments,hn as validateBriefingContentDocument,bn as validateBriefingDraft,In as validateBriefingJobConfig};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as c,i as y,o as h}from"./context-
|
|
1
|
+
import{A as c,i as y,o as h}from"./context-CntvtZwC.js";function f(e,t){return e.role===t.role&&e.name===t.name&&e.aggregate===t.aggregate&&e.granularity===t.granularity;}function S(e){var n,s;const t=(n=e.selectedCard)==null?void 0:n.description;return(t==null?void 0:t.status)!=="described"||t.sql||((s=e.editing)==null?void 0:s.mode)==="sql"?[]:t.fields;}function M(e,t){if(t.length===0)return[];if(t.length>c.taggedFields)return[`taggedFields: at most ${c.taggedFields}`];const n=S(e);return t.flatMap((s,a)=>n.some(o=>f(o,s))?t.slice(0,a).some(o=>f(o,s))?[`taggedFields.${a}: tagged twice`]:[]:[`taggedFields.${a}: not a field of the card the context asks about`]);}function q(e,t){return t!=null&&t.length?`Fields of the asked-about card the user tagged in this question: ${t.map(y).join("; ")}.
|
|
2
2
|
|
|
3
3
|
${e}`:e;}function C(e){if(e.kind==="text")return{type:"text",text:e.text};const{kind:t,...n}=e;return{type:`data-${t}`,...(e.kind==="stage"?{id:e.stageId}:{}),data:n};}function U(e,t){return e.kind!=="text"?[C(e)]:[{type:"text-start",id:t},{type:"text-delta",id:t,delta:e.text},{type:"text-end",id:t}];}function T(e){if(e==="failed"||e==="interrupted")return{kind:"refusal",code:"model_unavailable",message:h.model_unavailable};if(e==="running")return{kind:"refusal",code:"turn_in_progress",message:h.turn_in_progress};}function $(e,t){let n=-1;e.forEach((a,o)=>{t(a)==="text"&&(n=o);});let s=-1;return e.forEach((a,o)=>{o<n&&t(a)==="step"&&(s=o);}),new Set(e.filter((a,o)=>o<s&&t(a)==="text"));}const p={conversation:"nowhere",text:"body",stage:"details",using:"details",clarify:"body",artifact:"body",refusal:"body",trace:"details",proposal:"body",proposal_operations:"nowhere",proposal_refused:"body",model_change:"body"};function P(e){return Object.hasOwn(p,e)&&p[e]==="body";}function b(e){return e.kind==="text"?v(e.text):e.kind==="stage"&&!e.change?"step":"other";}function v(e){return e.trim().length>0?"text":"other";}function V(e){const t=$(e,b);return e.flatMap(n=>n.kind==="text"&&!t.has(n)?[n.text]:[]).filter(n=>n.trim().length>0).join(`
|
|
4
4
|
|
package/dist/chunks/{analytics-base-schemas-BREc5WGv.js → analytics-base-schemas-DMFrDqn_.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as e}from"zod";const Z=["missing_dependency","missing_relationship","population_required","ambiguous_relationship"];function Re(t){return Z.includes(t);}const Ie=200,D=["second","minute","hour","day","week","month","quarter","year"];function xe(t){return typeof t=="string"&&D.includes(t);}const B=["week_of_short","week_of_long","quarter_short","quarter_long","fiscal_quarter_short","fiscal_year","short","long","numeric","iso"],G=["hour","day","week","month","quarter","year"],De={invalidMetadata:"invalid_raw_temporal_metadata"};function z(t){return t==="second"||t==="minute"||t==="hour"?"datetime":"date";}const we={missingMetadata:"missing_temporal_bucket_metadata",invalidMetadata:"invalid_temporal_bucket_metadata",invalidValue:"invalid_temporal_bucket_value"},je="__auto_count__";function w(t){try{return new Intl.DateTimeFormat("en-US",{timeZone:t}).format(),!0;}catch{return!1;}}const L=20;function d(t){if(!(typeof t!="number"||!Number.isFinite(t)))return Math.max(0,Math.min(L,Math.trunc(t)));}function s(t){return typeof t=="string"?t:void 0;}function S(t){return typeof t=="string"&&t.trim()?t:void 0;}function _(t){return typeof t=="boolean"?t:void 0;}function $(t){if(typeof t!="string")return;const a=t.trim().toUpperCase();return /^[A-Z]{3}$/.test(a)?a:void 0;}function H(t){return typeof t=="number"&&Number.isFinite(t)?t:void 0;}function c(t){return Object.fromEntries(Object.entries(t).filter(([,a])=>a!==void 0));}const K=/* @__PURE__ */new Set(["number","currency","percent","percentage","scientific"]),W=/* @__PURE__ */new Set(["millisecond","second","minute","hour","day"]);function v(t){return typeof t=="string"&&W.has(t)?t:void 0;}function X(t){const a=t.percentValueMode??"fraction";if(t.scale===1&&a==="whole"){const{scale:i,...f}=t;return{...f,percentValueMode:"whole"};}const o=t.minimumFractionDigits??(t.maximumFractionDigits===void 0?1:0),n=t.maximumFractionDigits??Math.max(o,1);return c({type:"number",scale:a==="whole"?t.scale:t.scale*100,minimumFractionDigits:o,maximumFractionDigits:n,useGrouping:t.useGrouping,prefix:t.prefix,suffix:`%${t.suffix??""}`,negativeStyle:t.negativeStyle,signDisplay:t.signDisplay});}function Y(t){const a=t.type==="percentage"?"percent":t.type;let o=d(t.minimumFractionDigits),n=d(t.maximumFractionDigits);const i=d(t.decimals);o===void 0&&n===void 0&&i!==void 0&&(o=i,n=i),o!==void 0&&n!==void 0&&o>n&&([o,n]=[n,o]);const f=t.negativeStyle==="parentheses"||t.negativeStyle==="minus"?t.negativeStyle:void 0,P=t.signDisplay==="auto"||t.signDisplay==="always"||t.signDisplay==="exceptZero"||t.signDisplay==="never"?t.signDisplay:void 0,m=c({type:a,currency:a==="currency"?$(t.currency):void 0,minimumFractionDigits:o,maximumFractionDigits:n,useGrouping:_(t.useGrouping)??_(t.thousandsSeparator),prefix:s(t.prefix),suffix:a==="percent"&&t.suffix==="%"?void 0:s(t.suffix),negativeStyle:f,compact:_(t.compact),scale:H(t.scale),percentValueMode:a==="percent"?t.percentValueMode==="whole"?"whole":"fraction":void 0,signDisplay:P});return m.type==="percent"&&m.scale!==void 0?X(m):m;}function J(t){if(!t||typeof t!="object"||Array.isArray(t))return;const a=t;if(a.type==="temporal_bucket"){const o=a.presentation;return o&&typeof o=="object"&&!Array.isArray(o)?{type:"temporal_bucket",presentation:o}:void 0;}if(typeof a.type=="string"&&K.has(a.type))return Y(a);if(a.type==="date"||a.type==="datetime"){const o=S(a.pattern),n=a.preset==="short"||a.preset==="long"||a.preset==="numeric"||a.preset==="iso"?a.preset:void 0,i=o&&(a.dialect==="date_fns"||a.dialect==="semaphor_tokens")?a.dialect:void 0;return c({type:"date",pattern:o,dialect:i,preset:o?void 0:n,relative:a.relative===!0?!0:void 0,timezone:S(a.timezone),sourceTimezone:S(a.sourceTimezone),prefix:s(a.prefix),suffix:s(a.suffix)});}if(a.type==="duration"){const o=d(a.maxUnits);return c({type:"duration",inputUnit:v(a.inputUnit),outputStyle:a.outputStyle==="compact"||a.outputStyle==="digital"||a.outputStyle==="long"?a.outputStyle:void 0,largestUnit:v(a.largestUnit),smallestUnit:v(a.smallestUnit),maxUnits:o===void 0?void 0:Math.min(o,10),prefix:s(a.prefix),suffix:s(a.suffix),negativeStyle:a.negativeStyle==="parentheses"||a.negativeStyle==="minus"?a.negativeStyle:void 0});}if(a.type==="string")return c({type:"string",prefix:s(a.prefix),suffix:s(a.suffix)});}const Q=e.record(e.string(),e.unknown()),p=e.array(Q),u=e.enum(["SUM","COUNT","AVG","MIN","MAX","MEDIAN","DISTINCT"]),g=e.enum(["postgres","mysql","mssql","snowflake","clickhouse","bigquery","redshift","duckdb","sqlite","unknown"]),ee=e.enum(D),h=e.enum(["dimension","measure","date","id","unknown"]),y=e.enum(["string","number","boolean","date","datetime","unknown"]),T=e.union([e.number(),e.string(),e.null()]),k=e.enum(["millisecond","second","minute","hour","day"]),te=e.enum(B),ae=e.discriminatedUnion("mode",[e.object({mode:e.literal("auto")}).strict(),e.object({mode:e.literal("preset"),preset:te}).strict(),e.object({mode:e.literal("pattern"),pattern:e.string().min(1)}).strict()]),j=e.object({type:e.literal("temporal_bucket"),presentation:ae}).strict(),oe=e.object({tz:e.string().min(1).refine(w,{message:"tz must be a valid IANA timezone"}),weekStart:e.number().int().min(0).max(6),fiscalCalendar:e.object({kind:e.literal("month_aligned"),yearStartMonth:e.number().int().min(1).max(12)}).strict().optional()}).strict(),R=e.object({kind:e.literal("temporal_bucket"),granularity:ee,calendar:oe}).strict(),ne=e.object({grainSource:e.enum(["automatic","card"]),window:e.object({startInclusive:e.string(),endExclusive:e.string()}).strict().optional(),automaticGrain:e.enum(G),holdsTime:e.boolean()}).strict(),ie=e.object({kind:e.literal("raw_temporal"),valueKind:e.enum(["date","wall_datetime","instant"])}).strict(),Ae=e.object({kind:e.literal("raw_temporal"),valueKind:e.enum(["date","wall_datetime","instant"]),tz:e.string().min(1).refine(w,"tz must be an IANA timezone.")}).strict(),r=e.string(),I=e.number().int().min(0).max(20),A=e.object({type:e.enum(["number","currency","percent","scientific"]),currency:e.string().regex(/^[A-Z]{3}$/,"Expected an ISO 4217 currency code.").optional(),minimumFractionDigits:I.optional(),maximumFractionDigits:I.optional(),useGrouping:e.boolean().optional(),prefix:r.optional(),suffix:r.optional(),negativeStyle:e.enum(["minus","parentheses"]).optional(),compact:e.boolean().optional(),scale:e.number().finite().optional(),percentValueMode:e.enum(["fraction","whole"]).optional(),signDisplay:e.enum(["auto","always","exceptZero","never"]).optional()}).strict().superRefine((t,a)=>{const{minimumFractionDigits:o,maximumFractionDigits:n}=t;o!==void 0&&n!==void 0&&o>n&&a.addIssue({code:e.ZodIssueCode.custom,path:["minimumFractionDigits"],message:"minimumFractionDigits must not exceed maximumFractionDigits."}),t.currency!==void 0&&t.type!=="currency"&&a.addIssue({code:e.ZodIssueCode.custom,path:["currency"],message:"Only a currency format names a currency."}),t.type==="percent"?(t.percentValueMode===void 0&&a.addIssue({code:e.ZodIssueCode.custom,path:["percentValueMode"],message:"A percent format states percentValueMode: fraction (0.25 is 25%) or whole (25 is 25%)."}),t.scale!==void 0&&a.addIssue({code:e.ZodIssueCode.custom,path:["scale"],message:"A percent format has no scale; percentValueMode says how the value is read."})):t.percentValueMode!==void 0&&a.addIssue({code:e.ZodIssueCode.custom,path:["percentValueMode"],message:"Only a percent format has percentValueMode."});}),se=["short","long","numeric","iso"],F=e.object({type:e.literal("date"),pattern:e.string().min(1).optional(),dialect:e.enum(["semaphor_tokens","date_fns"]).optional(),preset:e.enum(se).optional(),relative:e.boolean().optional(),timezone:e.string().min(1).optional(),sourceTimezone:e.string().min(1).optional(),prefix:r.optional(),suffix:r.optional()}).strict().superRefine((t,a)=>{t.pattern!==void 0&&t.preset!==void 0&&a.addIssue({code:e.ZodIssueCode.custom,path:["preset"],message:"A date format has a pattern or a preset, not both."}),t.dialect!==void 0&&t.pattern===void 0&&a.addIssue({code:e.ZodIssueCode.custom,path:["dialect"],message:"dialect names the token set of a pattern."});}),C=e.object({type:e.literal("duration"),inputUnit:k.optional(),outputStyle:e.enum(["compact","digital","long"]).optional(),largestUnit:k.optional(),smallestUnit:k.optional(),maxUnits:e.number().int().min(0).max(10).optional(),prefix:r.optional(),suffix:r.optional(),negativeStyle:e.enum(["minus","parentheses"]).optional()}).strict(),M=e.object({type:e.literal("string"),prefix:r.optional(),suffix:r.optional()}).strict(),O=e.union([A,F,C,M]),re=e.unknown().superRefine((t,a)=>{t&&typeof t=="object"&&"locale"in t&&["number","currency","percent","percentage","scientific"].includes(String(t.type))&&a.addIssue({code:e.ZodIssueCode.custom,path:["locale"],message:"Numeric semantic formats inherit locale from viewer preferences."});}).transform(t=>J(t)??t).pipe(O),Fe=e.union([O,j]),Ce=["number","currency","percent","scientific","duration","date","string","temporal_bucket"];function ce(t){switch(t){case"number":case"currency":case"percent":case"scientific":return A;case"date":return F;case"duration":return C;case"string":return M;case"temporal_bucket":return j;default:return;}}function Me(t){let a=ce(t);for(;a&&!(a instanceof e.ZodObject);)a=a instanceof e.ZodEffects?a.innerType():void 0;return a?Object.keys(a.shape):void 0;}function le(t,a){return e.object(t).passthrough().superRefine((o,n)=>{for(const i of a)Object.prototype.hasOwnProperty.call(o,i)||n.addIssue({code:"custom",path:[i],message:`Required field "${i}" is missing.`});});}const E=e.object({kind:e.literal("semantic"),domainId:e.string(),datasetName:e.string(),datasetId:e.string().optional(),label:e.string().optional(),connectionId:e.string().optional()}).passthrough(),pe=e.object({kind:e.literal("physical"),connectionId:e.string(),connectionType:e.string().optional(),tableName:e.string(),databaseName:e.string().optional(),schemaName:e.string().optional(),label:e.string().optional(),dialect:g.optional()}).passthrough(),ue=e.object({kind:e.literal("sql"),connectionId:e.string(),dialect:g.optional(),label:e.string().optional()}).passthrough(),N=e.union([E,pe,ue]),me=e.object({name:e.string(),label:e.string().optional(),role:h.optional(),dataType:y.optional(),source:N.optional(),aggregate:u.optional()}).passthrough(),V=me,de=e.object({kind:e.literal("field"),field:V,aggregate:u.optional()}).passthrough(),ge=e.object({kind:e.literal("derived_field"),name:e.string(),label:e.string(),description:e.string().optional(),resultRole:h,dataType:y,computeStage:e.enum(["row","aggregate"]),expression:e.string(),expressionLanguage:e.literal("semaphor_sql_template").optional(),inputs:e.record(de),defaultAggregate:u.optional(),aggregationBehavior:e.enum(["additive","non_additive","ratio_of_sums","weighted","pre_aggregated","snapshot"]).optional(),aggregationStrategy:e.enum(["default","symmetric_aggregate","aggregate_then_join","weighted"]).optional(),format:re.optional(),tags:e.array(e.string()).optional()}).passthrough(),U=ge,Oe=V.and(e.object({derivedField:U.optional()}).passthrough()),he=E,ye=e.object({kind:e.literal("physical"),connectionId:e.string().optional(),connectionType:e.string().optional(),tableName:e.string(),databaseName:e.string().optional(),schemaName:e.string().optional(),label:e.string().optional(),dialect:g.optional()}).passthrough(),be=e.object({kind:e.literal("sql"),connectionId:e.string().optional(),dialect:g.optional(),label:e.string().optional()}).passthrough(),fe=e.union([he,ye,be]),Ee=e.object({key:e.string().optional(),name:e.string(),label:e.string().optional(),role:h.optional(),dataType:y.optional(),source:fe.optional(),aggregate:u.optional(),derivedField:e.never().optional()}).passthrough(),l=e.object({key:e.string(),name:e.string(),label:e.string(),role:h.optional(),dataType:y.optional(),aggregate:u.optional(),source:N.optional(),derivedField:U.optional(),temporalBucket:R.optional(),rawTemporal:ie.optional(),dateGrain:ne.optional(),pivotIdentity:e.object({metricId:e.string().min(1),metricAlias:e.string().min(1),members:e.array(e.object({fieldId:e.string().min(1),value:e.string().nullable(),temporalBucket:R.optional()}).strict())}).strict().optional()}).passthrough().superRefine((t,a)=>{if(t.temporalBucket&&t.rawTemporal&&a.addIssue({code:e.ZodIssueCode.custom,path:["rawTemporal"],message:"A result column cannot carry both temporalBucket and rawTemporal metadata."}),t.temporalBucket){const o=z(t.temporalBucket.granularity);t.dataType!==o&&a.addIssue({code:e.ZodIssueCode.custom,path:["dataType"],message:`${t.temporalBucket.granularity} temporal buckets require dataType ${o}.`});}if(t.rawTemporal){const o=t.rawTemporal.valueKind==="date"?"date":"datetime";t.dataType!==o&&a.addIssue({code:e.ZodIssueCode.custom,path:["dataType"],message:`${t.rawTemporal.valueKind} raw temporal values require dataType ${o}.`});}}),Ne=e.object({records:p,columns:e.array(l).optional()}).passthrough(),Ve=e.object({records:p,columns:e.array(l)}).passthrough(),q=e.object({code:e.string(),message:e.string().optional(),invalidField:e.string().optional(),fieldRole:e.enum(["measure","date","dimension","input","source","sql"]).optional(),validMeasureCandidates:e.array(e.string()).optional(),validDateCandidates:e.array(e.string()).optional(),validDimensionCandidates:e.array(e.string()).optional(),recommendedNextStep:e.string()}).passthrough(),x=e.object({code:e.string(),message:e.string(),path:e.string().optional(),fieldRole:e.enum(["measure","date","dimension","input","source","sql"]).optional(),repairHint:q.optional()}).passthrough(),Ue=e.object({ok:e.boolean(),errors:e.array(x),warnings:e.array(x),repairHints:e.array(q)}).passthrough(),Se=e.object({page:e.number(),pageSize:e.number(),pageCount:e.number(),totalCount:e.number(),hasNextPage:e.boolean(),hasPrevPage:e.boolean()}).passthrough(),b={intentId:e.string().optional(),queryPath:e.enum(["query_spec","sql","sql_python"]),warnings:e.array(e.string()).optional(),rowCount:e.number().optional(),rowLimitExceeded:e.boolean().optional(),limit:e.number().optional(),pagination:Se.optional()},qe=e.object({...b,kind:e.literal("metric"),primaryValue:T,measures:e.record(T).optional(),missingMeasures:e.array(e.string()).optional(),comparison:e.object({kind:e.enum(["previous_period","previous_year","target"]),words:e.string().optional(),value:T.optional(),delta:e.union([e.number(),e.null()]).optional(),deltaPercent:e.union([e.number(),e.null()]).optional()}).passthrough().optional(),records:p.optional()}).passthrough(),Pe=e.object({...b,kind:e.literal("records"),columns:e.array(l),records:p,totals:e.object({mode:e.literal("server"),scope:e.literal("filtered_result"),row:e.record(e.string(),e.unknown()),columns:e.array(l).optional()}).passthrough().optional()}).passthrough(),_e=e.object({inputId:e.string().min(1),status:e.enum(["applied","inactive","skipped","overridden","error"]),reason:e.enum(["unrelated","population_required","missing_dependency","missing_relationship","ambiguous_relationship","invalid_metadata","unsupported_dependency","override_not_eligible"]).optional()}),ve=e.object({complete:e.boolean(),reason:e.enum(["unsupported","truncated"]).optional()}),Te=e.object({kind:e.literal("standardCursor"),pageSize:e.number().int().positive(),hasMore:e.boolean(),nextCursor:e.string().min(1).optional()}),Ze=e.object({...b,kind:e.literal("inputOptions"),dependencyOutcomes:e.array(_e).optional(),match:ve.optional(),page:Te.optional(),options:e.array(le({label:e.string(),value:e.unknown(),count:e.number().optional(),disambiguation:e.array(e.string()).optional()},["value"]))}).passthrough(),Be=e.object({...b,kind:e.literal("sql"),columns:e.array(l),records:p,sqlShape:e.object({statementType:e.string().optional(),explicitLimit:e.number().optional(),hasPythonCode:e.boolean().optional()}).passthrough().optional()}).passthrough();export{Te as $,G as A,Ce as B,ce as C,Me as D,E,pe as F,ue as G,me as H,V as I,ge as J,U as K,Oe as L,Ie as M,Ee as N,Z as O,l as P,Ne as Q,De as R,je as S,we as T,Ve as U,x as V,Ue as W,qe as X,Pe as Y,_e as Z,ve as _,z as a,Ze as a0,Be as a1,R as b,Re as c,D as d,xe as e,B as f,p as g,u as h,w as i,ee as j,j as k,ne as l,ie as m,T as n,Ae as o,A as p,se as q,Q as r,N as s,J as t,F as u,C as v,M as w,O as x,re as y,Fe as z};
|
|
1
|
+
import{z as e}from"zod";const Z=["missing_dependency","missing_relationship","population_required","ambiguous_relationship"];function Re(t){return Z.includes(t);}const Ie=200,D=["second","minute","hour","day","week","month","quarter","year"];function xe(t){return typeof t=="string"&&D.includes(t);}const B=["week_of_short","week_of_long","quarter_short","quarter_long","fiscal_quarter_short","fiscal_year","short","long","numeric","iso"],G=["hour","day","week","month","quarter","year"],De={invalidMetadata:"invalid_raw_temporal_metadata"};function z(t){return t==="second"||t==="minute"||t==="hour"?"datetime":"date";}const we={missingMetadata:"missing_temporal_bucket_metadata",invalidMetadata:"invalid_temporal_bucket_metadata",invalidValue:"invalid_temporal_bucket_value"},je="__auto_count__";function w(t){try{return new Intl.DateTimeFormat("en-US",{timeZone:t}).format(),!0;}catch{return!1;}}const L=20;function d(t){if(!(typeof t!="number"||!Number.isFinite(t)))return Math.max(0,Math.min(L,Math.trunc(t)));}function s(t){return typeof t=="string"?t:void 0;}function S(t){return typeof t=="string"&&t.trim()?t:void 0;}function _(t){return typeof t=="boolean"?t:void 0;}function $(t){if(typeof t!="string")return;const a=t.trim().toUpperCase();return /^[A-Z]{3}$/.test(a)?a:void 0;}function H(t){return typeof t=="number"&&Number.isFinite(t)?t:void 0;}function c(t){return Object.fromEntries(Object.entries(t).filter(([,a])=>a!==void 0));}const K=/* @__PURE__ */new Set(["number","currency","percent","percentage","scientific"]),W=/* @__PURE__ */new Set(["millisecond","second","minute","hour","day"]);function v(t){return typeof t=="string"&&W.has(t)?t:void 0;}function X(t){const a=t.percentValueMode??"fraction";if(t.scale===1&&a==="whole"){const{scale:i,...f}=t;return{...f,percentValueMode:"whole"};}const o=t.minimumFractionDigits??(t.maximumFractionDigits===void 0?1:0),n=t.maximumFractionDigits??Math.max(o,1);return c({type:"number",scale:a==="whole"?t.scale:t.scale*100,minimumFractionDigits:o,maximumFractionDigits:n,useGrouping:t.useGrouping,prefix:t.prefix,suffix:`%${t.suffix??""}`,negativeStyle:t.negativeStyle,signDisplay:t.signDisplay});}function Y(t){const a=t.type==="percentage"?"percent":t.type;let o=d(t.minimumFractionDigits),n=d(t.maximumFractionDigits);const i=d(t.decimals);o===void 0&&n===void 0&&i!==void 0&&(o=i,n=i),o!==void 0&&n!==void 0&&o>n&&([o,n]=[n,o]);const f=t.negativeStyle==="parentheses"||t.negativeStyle==="minus"?t.negativeStyle:void 0,P=t.signDisplay==="auto"||t.signDisplay==="always"||t.signDisplay==="exceptZero"||t.signDisplay==="never"?t.signDisplay:void 0,m=c({type:a,currency:a==="currency"?$(t.currency):void 0,minimumFractionDigits:o,maximumFractionDigits:n,useGrouping:_(t.useGrouping)??_(t.thousandsSeparator),prefix:s(t.prefix),suffix:a==="percent"&&t.suffix==="%"?void 0:s(t.suffix),negativeStyle:f,compact:_(t.compact),scale:H(t.scale),percentValueMode:a==="percent"?t.percentValueMode==="whole"?"whole":"fraction":void 0,signDisplay:P});return m.type==="percent"&&m.scale!==void 0?X(m):m;}function J(t){if(!t||typeof t!="object"||Array.isArray(t))return;const a=t;if(a.type==="temporal_bucket"){const o=a.presentation;return o&&typeof o=="object"&&!Array.isArray(o)?{type:"temporal_bucket",presentation:o}:void 0;}if(typeof a.type=="string"&&K.has(a.type))return Y(a);if(a.type==="date"||a.type==="datetime"){const o=S(a.pattern),n=a.preset==="short"||a.preset==="long"||a.preset==="numeric"||a.preset==="iso"?a.preset:void 0,i=o&&(a.dialect==="date_fns"||a.dialect==="semaphor_tokens")?a.dialect:void 0;return c({type:"date",pattern:o,dialect:i,preset:o?void 0:n,relative:a.relative===!0?!0:void 0,timezone:S(a.timezone),sourceTimezone:S(a.sourceTimezone),prefix:s(a.prefix),suffix:s(a.suffix)});}if(a.type==="duration"){const o=d(a.maxUnits);return c({type:"duration",inputUnit:v(a.inputUnit),outputStyle:a.outputStyle==="compact"||a.outputStyle==="digital"||a.outputStyle==="long"?a.outputStyle:void 0,largestUnit:v(a.largestUnit),smallestUnit:v(a.smallestUnit),maxUnits:o===void 0?void 0:Math.min(o,10),prefix:s(a.prefix),suffix:s(a.suffix),negativeStyle:a.negativeStyle==="parentheses"||a.negativeStyle==="minus"?a.negativeStyle:void 0});}if(a.type==="string")return c({type:"string",prefix:s(a.prefix),suffix:s(a.suffix)});}const Q=e.record(e.string(),e.unknown()),p=e.array(Q),u=e.enum(["SUM","COUNT","AVG","MIN","MAX","MEDIAN","DISTINCT"]),g=e.enum(["postgres","mysql","mssql","snowflake","clickhouse","bigquery","redshift","duckdb","sqlite","unknown"]),ee=e.enum(D),h=e.enum(["dimension","measure","date","id","unknown"]),y=e.enum(["string","number","boolean","date","datetime","unknown"]),T=e.union([e.number(),e.string(),e.null()]),k=e.enum(["millisecond","second","minute","hour","day"]),te=e.enum(B),ae=e.discriminatedUnion("mode",[e.object({mode:e.literal("auto")}).strict(),e.object({mode:e.literal("preset"),preset:te}).strict(),e.object({mode:e.literal("pattern"),pattern:e.string().min(1)}).strict()]),j=e.object({type:e.literal("temporal_bucket"),presentation:ae}).strict(),oe=e.object({tz:e.string().min(1).refine(w,{message:"tz must be a valid IANA timezone"}),weekStart:e.number().int().min(0).max(6),fiscalCalendar:e.object({kind:e.literal("month_aligned"),yearStartMonth:e.number().int().min(1).max(12)}).strict().optional()}).strict(),R=e.object({kind:e.literal("temporal_bucket"),granularity:ee,calendar:oe}).strict(),ne=e.object({grainSource:e.enum(["automatic","card"]),window:e.object({startInclusive:e.string(),endExclusive:e.string()}).strict().optional(),automaticGrain:e.enum(G),holdsTime:e.boolean()}).strict(),ie=e.object({kind:e.literal("raw_temporal"),valueKind:e.enum(["date","wall_datetime","instant"])}).strict(),Ae=e.object({kind:e.literal("raw_temporal"),valueKind:e.enum(["date","wall_datetime","instant"]),tz:e.string().min(1).refine(w,"tz must be an IANA timezone.")}).strict(),r=e.string(),I=e.number().int().min(0).max(20),A=e.object({type:e.enum(["number","currency","percent","scientific"]),currency:e.string().regex(/^[A-Z]{3}$/,"Expected an ISO 4217 currency code.").optional(),minimumFractionDigits:I.optional(),maximumFractionDigits:I.optional(),useGrouping:e.boolean().optional(),prefix:r.optional(),suffix:r.optional(),negativeStyle:e.enum(["minus","parentheses"]).optional(),compact:e.boolean().optional(),scale:e.number().finite().optional(),percentValueMode:e.enum(["fraction","whole"]).optional(),signDisplay:e.enum(["auto","always","exceptZero","never"]).optional()}).strict().superRefine((t,a)=>{const{minimumFractionDigits:o,maximumFractionDigits:n}=t;o!==void 0&&n!==void 0&&o>n&&a.addIssue({code:e.ZodIssueCode.custom,path:["minimumFractionDigits"],message:"minimumFractionDigits must not exceed maximumFractionDigits."}),t.currency!==void 0&&t.type!=="currency"&&a.addIssue({code:e.ZodIssueCode.custom,path:["currency"],message:"Only a currency format names a currency."}),t.type==="percent"?(t.percentValueMode===void 0&&a.addIssue({code:e.ZodIssueCode.custom,path:["percentValueMode"],message:"A percent format states percentValueMode: fraction (0.25 is 25%) or whole (25 is 25%)."}),t.scale!==void 0&&a.addIssue({code:e.ZodIssueCode.custom,path:["scale"],message:"A percent format has no scale; percentValueMode says how the value is read."})):t.percentValueMode!==void 0&&a.addIssue({code:e.ZodIssueCode.custom,path:["percentValueMode"],message:"Only a percent format has percentValueMode."});}),se=["short","long","numeric","iso"],F=e.object({type:e.literal("date"),pattern:e.string().min(1).optional(),dialect:e.enum(["semaphor_tokens","date_fns"]).optional(),preset:e.enum(se).optional(),relative:e.boolean().optional(),timezone:e.string().min(1).optional(),sourceTimezone:e.string().min(1).optional(),prefix:r.optional(),suffix:r.optional()}).strict().superRefine((t,a)=>{t.pattern!==void 0&&t.preset!==void 0&&a.addIssue({code:e.ZodIssueCode.custom,path:["preset"],message:"A date format has a pattern or a preset, not both."}),t.dialect!==void 0&&t.pattern===void 0&&a.addIssue({code:e.ZodIssueCode.custom,path:["dialect"],message:"dialect names the token set of a pattern."});}),C=e.object({type:e.literal("duration"),inputUnit:k.optional(),outputStyle:e.enum(["compact","digital","long"]).optional(),largestUnit:k.optional(),smallestUnit:k.optional(),maxUnits:e.number().int().min(0).max(10).optional(),prefix:r.optional(),suffix:r.optional(),negativeStyle:e.enum(["minus","parentheses"]).optional()}).strict(),M=e.object({type:e.literal("string"),prefix:r.optional(),suffix:r.optional()}).strict(),O=e.union([A,F,C,M]),re=e.unknown().superRefine((t,a)=>{t&&typeof t=="object"&&"locale"in t&&["number","currency","percent","percentage","scientific"].includes(String(t.type))&&a.addIssue({code:e.ZodIssueCode.custom,path:["locale"],message:"Numeric semantic formats inherit locale from viewer preferences."});}).transform(t=>J(t)??t).pipe(O),Fe=e.union([O,j]),Ce=["number","currency","percent","scientific","duration","date","string","temporal_bucket"];function ce(t){switch(t){case"number":case"currency":case"percent":case"scientific":return A;case"date":return F;case"duration":return C;case"string":return M;case"temporal_bucket":return j;default:return;}}function Me(t){let a=ce(t);for(;a&&!(a instanceof e.ZodObject);)a=a instanceof e.ZodEffects?a.innerType():void 0;return a?Object.keys(a.shape):void 0;}function le(t,a){return e.object(t).passthrough().superRefine((o,n)=>{for(const i of a)Object.prototype.hasOwnProperty.call(o,i)||n.addIssue({code:"custom",path:[i],message:`Required field "${i}" is missing.`});});}const E=e.object({kind:e.literal("semantic"),domainId:e.string(),datasetName:e.string(),datasetId:e.string().optional(),label:e.string().optional(),connectionId:e.string().optional()}).passthrough(),pe=e.object({kind:e.literal("physical"),connectionId:e.string(),connectionType:e.string().optional(),tableName:e.string(),databaseName:e.string().optional(),schemaName:e.string().optional(),label:e.string().optional(),dialect:g.optional()}).passthrough(),ue=e.object({kind:e.literal("sql"),connectionId:e.string(),dialect:g.optional(),label:e.string().optional()}).passthrough(),N=e.union([E,pe,ue]),me=e.object({name:e.string(),label:e.string().optional(),role:h.optional(),dataType:y.optional(),source:N.optional(),aggregate:u.optional()}).passthrough(),V=me,de=e.object({kind:e.literal("field"),field:V,aggregate:u.optional()}).passthrough(),ge=e.object({kind:e.literal("derived_field"),name:e.string(),label:e.string(),description:e.string().optional(),resultRole:h,dataType:y,computeStage:e.enum(["row","aggregate"]),expression:e.string(),expressionLanguage:e.literal("semaphor_sql_template").optional(),inputs:e.record(de),defaultAggregate:u.optional(),aggregationBehavior:e.enum(["additive","non_additive","ratio_of_sums","weighted","pre_aggregated","snapshot"]).optional(),aggregationStrategy:e.enum(["default","symmetric_aggregate","aggregate_then_join","weighted"]).optional(),format:re.optional(),tags:e.array(e.string()).optional()}).passthrough(),U=ge,Oe=V.and(e.object({derivedField:U.optional()}).passthrough()),he=E,ye=e.object({kind:e.literal("physical"),connectionId:e.string().optional(),connectionType:e.string().optional(),tableName:e.string(),databaseName:e.string().optional(),schemaName:e.string().optional(),label:e.string().optional(),dialect:g.optional()}).passthrough(),be=e.object({kind:e.literal("sql"),connectionId:e.string().optional(),dialect:g.optional(),label:e.string().optional()}).passthrough(),fe=e.union([he,ye,be]),Ee=e.object({key:e.string().optional(),name:e.string(),label:e.string().optional(),role:h.optional(),dataType:y.optional(),source:fe.optional(),aggregate:u.optional(),derivedField:e.never().optional()}).passthrough(),l=e.object({key:e.string(),name:e.string(),label:e.string(),role:h.optional(),dataType:y.optional(),aggregate:u.optional(),source:N.optional(),derivedField:U.optional(),temporalBucket:R.optional(),rawTemporal:ie.optional(),dateGrain:ne.optional(),pivotIdentity:e.object({metricId:e.string().min(1),metricAlias:e.string().min(1),members:e.array(e.object({fieldId:e.string().min(1),value:e.string().nullable(),temporalBucket:R.optional()}).strict())}).strict().optional()}).passthrough().superRefine((t,a)=>{if(t.temporalBucket&&t.rawTemporal&&a.addIssue({code:e.ZodIssueCode.custom,path:["rawTemporal"],message:"A result column cannot carry both temporalBucket and rawTemporal metadata."}),t.temporalBucket){const o=z(t.temporalBucket.granularity);t.dataType!==o&&a.addIssue({code:e.ZodIssueCode.custom,path:["dataType"],message:`${t.temporalBucket.granularity} temporal buckets require dataType ${o}.`});}if(t.rawTemporal){const o=t.rawTemporal.valueKind==="date"?"date":"datetime";t.dataType!==o&&a.addIssue({code:e.ZodIssueCode.custom,path:["dataType"],message:`${t.rawTemporal.valueKind} raw temporal values require dataType ${o}.`});}}),Ne=e.object({records:p,columns:e.array(l).optional()}).passthrough(),Ve=e.object({records:p,columns:e.array(l)}).passthrough(),q=e.object({code:e.string(),message:e.string().optional(),invalidField:e.string().optional(),fieldRole:e.enum(["measure","date","dimension","input","source","sql"]).optional(),validMeasureCandidates:e.array(e.string()).optional(),validDateCandidates:e.array(e.string()).optional(),validDimensionCandidates:e.array(e.string()).optional(),recommendedNextStep:e.string()}).passthrough(),x=e.object({code:e.string(),message:e.string(),path:e.string().optional(),fieldRole:e.enum(["measure","date","dimension","input","source","sql"]).optional(),repairHint:q.optional()}).passthrough(),Ue=e.object({ok:e.boolean(),errors:e.array(x),warnings:e.array(x),repairHints:e.array(q)}).passthrough(),Se=e.object({page:e.number(),pageSize:e.number(),pageCount:e.number(),totalCount:e.number(),hasNextPage:e.boolean(),hasPrevPage:e.boolean()}).passthrough(),b={intentId:e.string().optional(),queryPath:e.enum(["query_spec","sql","sql_python"]),warnings:e.array(e.string()).optional(),rowCount:e.number().optional(),rowLimitExceeded:e.boolean().optional(),limit:e.number().optional(),pagination:Se.optional()},qe=e.object({...b,kind:e.literal("metric"),primaryValue:T,measures:e.record(T).optional(),missingMeasures:e.array(e.string()).optional(),comparison:e.object({kind:e.enum(["previous_period","previous_year","target"]),words:e.string().optional(),value:T.optional(),delta:e.union([e.number(),e.null()]).optional(),deltaPercent:e.union([e.number(),e.null()]).optional()}).passthrough().optional(),records:p.optional()}).passthrough(),Pe=e.object({...b,kind:e.literal("records"),columns:e.array(l),records:p,totals:e.object({mode:e.literal("server"),scope:e.literal("filtered_result"),row:e.record(e.string(),e.unknown()),columns:e.array(l).optional()}).passthrough().optional()}).passthrough(),_e=e.object({inputId:e.string().min(1),status:e.enum(["applied","inactive","skipped","overridden","error"]),reason:e.enum(["unrelated","population_required","missing_dependency","missing_relationship","ambiguous_relationship","invalid_metadata","unsupported_dependency","override_not_eligible"]).optional()}),ve=e.object({complete:e.boolean(),reason:e.enum(["unsupported","truncated"]).optional()}),Te=e.object({kind:e.literal("standardCursor"),pageSize:e.number().int().positive(),hasMore:e.boolean(),nextCursor:e.string().min(1).optional()}),Ze=e.object({...b,kind:e.literal("inputOptions"),dependencyOutcomes:e.array(_e).optional(),match:ve.optional(),page:Te.optional(),options:e.array(le({label:e.string(),value:e.unknown(),count:e.number().optional(),disambiguation:e.array(e.string()).optional()},["value"]))}).passthrough(),Be=e.object({...b,kind:e.literal("sql"),columns:e.array(l),records:p,sqlShape:e.object({statementType:e.string().optional(),explicitLimit:e.number().optional(),hasPythonCode:e.boolean().optional()}).passthrough().optional()}).passthrough();export{Te as $,G as A,Ce as B,ce as C,Me as D,E,pe as F,ue as G,me as H,V as I,ge as J,U as K,Oe as L,Ie as M,Ee as N,Z as O,l as P,Ne as Q,De as R,je as S,B as T,Ve as U,x as V,Ue as W,qe as X,Pe as Y,_e as Z,ve as _,Re as a,Ze as a0,Be as a1,D as b,xe as c,z as d,we as e,p as f,u as g,ee as h,w as i,j,R as k,ne as l,ie as m,T as n,Ae as o,A as p,se as q,Q as r,N as s,J as t,F as u,C as v,M as w,O as x,re as y,Fe as z};
|