react-semaphor 0.1.314 → 0.1.316

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.
Files changed (46) hide show
  1. package/dist/brand-studio/index.js +65 -65
  2. package/dist/briefings/index.cjs +1 -0
  3. package/dist/briefings/index.js +848 -0
  4. package/dist/chunks/{braces-CWi8x9ww.js → braces-CDPz6CF2.js} +1 -1
  5. package/dist/chunks/{calendar-preferences-dialog-D70CuT-1.js → calendar-preferences-dialog-9NlFzHX8.js} +3 -3
  6. package/dist/chunks/{calendar-preferences-dialog-BzpQ5u4h.js → calendar-preferences-dialog-BDdxi7Xm.js} +1 -1
  7. package/dist/chunks/{chevrons-up-down-B2viXO2I.js → chevrons-up-down-BsdQRmJL.js} +1 -1
  8. package/dist/chunks/dashboard-briefing-launcher-5fM_KJoT.js +7321 -0
  9. package/dist/chunks/dashboard-briefing-launcher-CVxLt10p.js +96 -0
  10. package/dist/chunks/dashboard-controls-9YV-D1tD.js +2009 -0
  11. package/dist/chunks/dashboard-controls-UR_m0wD1.js +57 -0
  12. package/dist/chunks/{dashboard-json-CJCAen1R.js → dashboard-json-CKPID8Am.js} +2 -2
  13. package/dist/chunks/{dashboard-json-v2C6Tmqf.js → dashboard-json-ws4tortP.js} +1 -1
  14. package/dist/chunks/edit-dashboard-visual-CmxnZI8I.js +178 -0
  15. package/dist/chunks/{edit-dashboard-visual-DljWvnMy.js → edit-dashboard-visual-ifKJLMTS.js} +807 -822
  16. package/dist/chunks/index-Xdag_85e.js +1298 -0
  17. package/dist/chunks/{index-P5hPTTzm.js → index-gcA9Rs35.js} +41178 -46390
  18. package/dist/chunks/{palette-CIuwlEiG.js → palette-BlxLchHy.js} +1 -1
  19. package/dist/chunks/{resource-management-panel-CAxXzMdi.js → resource-management-panel-BduJanWW.js} +1 -1
  20. package/dist/chunks/{resource-management-panel-Dk0DzgVm.js → resource-management-panel-paSAzVj2.js} +81 -81
  21. package/dist/chunks/{save-_ALpoMy6.js → save-DVRQBMeb.js} +1 -1
  22. package/dist/chunks/{switch-B6fh8nb-.js → switch-sauemjyY.js} +199 -199
  23. package/dist/chunks/{use-create-flow-overlay-state-Cqf7GaFm.js → use-create-flow-overlay-state-DKV6tIc5.js} +254 -225
  24. package/dist/chunks/use-create-flow-overlay-state-DWnzVVlP.js +26 -0
  25. package/dist/chunks/{use-visual-utils-CQQ3jvDn.js → use-visual-utils-C8PDxg2w.js} +1 -1
  26. package/dist/chunks/{use-visual-utils-CPMQLBYR.js → use-visual-utils-Cs0-baCK.js} +48 -48
  27. package/dist/dashboard/index.cjs +1 -1
  28. package/dist/dashboard/index.js +1 -1
  29. package/dist/index.cjs +1 -1
  30. package/dist/index.js +232 -485
  31. package/dist/style.css +1 -1
  32. package/dist/surfboard/index.cjs +1 -1
  33. package/dist/surfboard/index.js +2 -2
  34. package/dist/types/briefings.d.ts +240 -0
  35. package/dist/types/dashboard.d.ts +1 -0
  36. package/dist/types/main.d.ts +619 -1017
  37. package/dist/types/surfboard.d.ts +1 -0
  38. package/dist/types/types.d.ts +411 -261
  39. package/package.json +7 -2
  40. package/dist/chunks/dashboard-controls-BS_aZcxs.js +0 -57
  41. package/dist/chunks/dashboard-controls-DbKtbw1V.js +0 -2021
  42. package/dist/chunks/dashboard-filter-controls-launcher-C8Wm2Smj.js +0 -1540
  43. package/dist/chunks/dashboard-filter-controls-launcher-CMXpudFJ.js +0 -11
  44. package/dist/chunks/edit-dashboard-visual-lRn3FeaP.js +0 -183
  45. package/dist/chunks/index-XYIIY48z.js +0 -1330
  46. package/dist/chunks/use-create-flow-overlay-state-DMZTflFt.js +0 -16
@@ -0,0 +1,26 @@
1
+ "use strict";const s=require("./switch-DPaKnsb8.js"),v=require("react"),p=require("./index-Xdag_85e.js"),e=require("react/jsx-runtime"),re=require("./use-visual-utils-C8PDxg2w.js"),he=require("./save-B8x5Vi0W.js");/**
2
+ * @license lucide-react v0.453.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const Ne=s.createLucideIcon("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
7
+ * @license lucide-react v0.453.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const ge=s.createLucideIcon("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);/**
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 be=s.createLucideIcon("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/**
17
+ * @license lucide-react v0.453.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const De=s.createLucideIcon("Rows3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]);/**
22
+ * @license lucide-react v0.453.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const Ee=s.createLucideIcon("SendHorizontal",[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]]);function we(){const l=s.useEditorStore(h=>h.card.dataSource),{setSelectedConnectionId:a,setSelectedDatabaseName:i,setSelectedSchemaName:d,setSelectedTableName:x,setSelectedDatamodelId:u}=s.useEditorActions();v.useEffect(()=>{var D;if(!l)return;const{tableName:h,schemaName:y,databaseName:g,connectionId:j}=p.extractTableMetadata(l),b=(D=l.selectedEntities)==null?void 0:D[0],C=(b==null?void 0:b.type)==="model"&&"id"in b?b.id:"";a(j||""),i(g||""),d(y||""),x(h||""),u(C)},[l,a,i,d,x,u])}function ae(){var g,j;const l=s.useEditorStore(b=>b.card),a=s.useEditorStore(b=>b.frame),i=v.useMemo(()=>p.findCustomVisualConfigCard(a,l),[a,l]),{manifest:d}=p.useCustomVisual(((g=i==null?void 0:i.customCardPreferences)==null?void 0:g.url)||""),x=v.useMemo(()=>{var b;return(b=d==null?void 0:d.visuals)==null?void 0:b.find(m=>{var C;return m.name===((C=i==null?void 0:i.customCardPreferences)==null?void 0:C.componentName)})},[d,(j=i==null?void 0:i.customCardPreferences)==null?void 0:j.componentName]),u=p.resolveMultiInputType(i,x),h=v.useMemo(()=>p.getCustomVisualInputCards({frame:a,configCard:i,isMultiInputVisual:u==="multiple"}),[a,i,u]),y=v.useMemo(()=>{const b=h.findIndex(m=>(m==null?void 0:m.id)===l.id);return b<0?-1:p.getSlotIndexForCard(l,b)},[h,l]);return v.useMemo(()=>!i||u!=="multiple"||y<0?l.type:p.getEffectiveCardTypeForSlot(l,y,x==null?void 0:x.slots)??l.type,[i,u,y,l,x==null?void 0:x.slots])}function Ve({type:l,isLinked:a,className:i,showLabel:d=!1,showLocal:x=!1}){const u=s.useDashboardStore(E=>E.selectedFrameId),h=p.useManagementStore(E=>E.selectedVisual),y=s.useEditorStore(E=>E.frame);let g;if(l)g=l;else if(a!==void 0)g=a?"linked":"library";else if(!!!(y!=null&&y.visualId||h!=null&&h.id)&&u)g="local";else if(h&&!u)g="library";else if(y!=null&&y.visualId&&u)g="linked";else if(h!=null&&h.id&&u)g="library";else return null;if(g==="local"&&!x)return null;const j={local:"border-slate-200/70 bg-slate-50/80 text-slate-700 shadow-sm hover:bg-slate-100/80 dark:border-slate-700 dark:bg-slate-900/70 dark:text-slate-200 dark:hover:bg-slate-800/80",linked:"border-purple-200/70 bg-gradient-to-r from-purple-50/50 to-purple-100/30 text-purple-900 shadow-sm hover:from-purple-100/60 hover:to-purple-100/50 hover:shadow-md dark:border-purple-800/50 dark:from-purple-950/40 dark:to-purple-900/30 dark:text-purple-100 dark:hover:from-purple-950/60 dark:hover:to-purple-900/50",library:"border-blue-200/70 bg-gradient-to-r from-blue-50/50 to-blue-100/30 text-blue-900 shadow-sm hover:from-blue-100/60 hover:to-blue-100/50 hover:shadow-md dark:border-blue-800/50 dark:from-blue-950/40 dark:to-blue-900/30 dark:text-blue-100 dark:hover:from-blue-950/60 dark:hover:to-blue-900/50"},b={local:"Local to this dashboard: Changes made here only affect this dashboard copy.",linked:"Linked to library: Changes made here update the library visual and all linked instances.",library:"Library visual: Share and reuse this visual across multiple dashboards."},m={local:"border-slate-200 bg-slate-50 text-slate-900 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100",linked:"border-purple-200 bg-purple-50 text-purple-900 dark:border-purple-800 dark:bg-purple-950 dark:text-purple-100",library:"border-blue-200 bg-blue-50 text-blue-900 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-100"},C={local:"fill-slate-50 dark:fill-slate-900",linked:"fill-purple-50 dark:fill-purple-950",library:"fill-blue-50 dark:fill-blue-950"},D={local:e.jsx("span",{className:"h-2 w-2 rounded-full bg-current/70"}),linked:e.jsx(be,{className:"h-3.5 w-3.5"}),library:e.jsx(ge,{className:"h-3.5 w-3.5"})},N={local:"Local",linked:"Linked",library:"Library"};return e.jsx(s.TooltipProvider,{children:e.jsxs(s.Tooltip,{delayDuration:300,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsxs(p.Badge,{variant:"outline",className:s.cn("cursor-help select-none transition-all",j[g],i),children:[D[g],d&&e.jsx("span",{className:"ml-1 text-xs font-medium leading-none",children:N[g]})]})}),e.jsxs(s.TooltipContent,{side:"bottom",className:s.cn("max-w-xs",m[g]),children:[e.jsx(s.TooltipArrow,{className:C[g]}),e.jsx("p",{children:b[g]})]})]})})}function Te(l,a){return{...l,sql:"",python:"",config:void 0,customCfg:"",preferences:{},interactionConfig:void 0,linkedInteractionTargetOverrides:void 0,dynamicCardPreferences:void 0,customCardPreferences:a?l.customCardPreferences:void 0,visualizationMode:"builtin",type:a?l.type:"bar"}}function le(l){const a=s.getDynamicFrameSaveIssue(l);return a?(p.ue.error(a),!1):!0}function Ie({className:l,variant:a="outline"}){const i=s.useEditorStore(u=>u.onSave),{getUpdatedFrame:d}=re.useVisualUtils();function x(){const u=d();le(u)&&(i==null||i(u))}return e.jsxs(s.Button,{onClick:x,className:l,size:"xs",variant:a,children:[e.jsx(s.Check,{className:"h-3.5 w-3.5"}),"Accept"]})}function Le({className:l,variant:a="default"}){const i=p.useQueryClient(),[d,x]=v.useState(!1),u=s.useDashboardStore(C=>C.actions.setIsDashboardPanelOpen),{setIsVisualEditing:h}=s.useDashboardActions(),{getUpdatedFrame:y}=re.useVisualUtils(),g=p.useSelectedVisual(),j=s.useEditorStore(C=>C.frame),b=p.useUpdateVisualMutation(),m=()=>{const C=y();if(!le(C))return;const D=(j==null?void 0:j.visualId)||(g==null?void 0:g.id);if(!D){p.ue.error("No visual to save");return}x(!0),b.mutate({visualId:D,data:{frameObject:C}},{onSuccess:()=>{x(!1),u(!0),p.ue.success("Visual updated successfully"),i.invalidateQueries({queryKey:["resource-by-id","visual",D],exact:!0})},onError:()=>{x(!1),p.ue.error("Failed to update visual")}})};return e.jsx(s.Button,{onClick:m,className:l,size:"xs",variant:a,children:d?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving"]}):e.jsxs(e.Fragment,{children:[e.jsx(he.Save,{className:"h-3.5 w-3.5"}),"Save to Library"]})})}function Fe({className:l}){const a=p.useQueryClient(),[i,d]=v.useState(!1),x=p.useSelectedVisual(),u=s.useEditorStore(N=>N.frame),h=s.useDashboardStore(N=>N.selectedSheetId),y=s.useDashboardStore(N=>N.dashboard),{updateFrame:g,setIsVisualEditing:j}=s.useDashboardActions(),{getUpdatedFrame:b}=re.useVisualUtils(),m=p.useUpdateVisualMutation(),C=p.useResolveExistingFrameSemanticExecutionPayload(),D=async()=>{if(!h){p.ue.error("No sheet selected");return}const N=(u==null?void 0:u.visualId)||(x==null?void 0:x.id);if(!N){p.ue.error("No visual to update");return}d(!0);try{const E=b();if(!le(E)){d(!1);return}const F={...E,visualId:N},Q=p.findDashboardFrameById(y,F.id),U=await C(F,{previousFrame:Q});await m.mutateAsync({visualId:N,data:{frameObject:E}}),g(h,F,{semanticExecutionPayload:U}),a.invalidateQueries({queryKey:["visuals"]}),a.invalidateQueries({queryKey:["visual",N]}),p.ue.success("Saved to library and applied locally"),setTimeout(()=>{j(!1)},300)}catch(E){console.error("Failed to save and apply:",E),p.ue.error(E instanceof Error?E.message:"Failed to save and apply changes")}finally{d(!1)}};return e.jsx(s.Button,{onClick:D,className:l,size:"xs",variant:"default",disabled:i,children:i?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(he.Save,{className:"h-3.5 w-3.5"}),"Save & Apply"]})})}function _e({className:l}){const{setTempQueryData:a,setSqlGen:i}=s.useEditorActions(),d=p.useQueryClient(),x=s.useEditorStore(m=>m.tempQueryData),u=s.useEditorStore(m=>m.onClose),h=s.useEditorStore(m=>m.card),y=ae(),g=v.useMemo(()=>y!==h.type?{...h,type:y}:h,[h,y]),{queryKey:j}=p.useEditorCardQuery(g);function b(){if(x){const{queryKey:m,queryData:C}=x;m&&C&&d.setQueryData(m,C)}i({}),u==null||u()}return e.jsxs(s.Button,{onClick:b,className:l,size:"xs",variant:"outline",children:[e.jsx(s.X,{className:"h-3.5 w-3.5"}),"Close"]})}function Be({label:l="Clear",variant:a="secondary",className:i}={}){const{setTempQueryData:d}=s.useEditorActions(),x=p.useQueryClient(),u=s.useEditorStore(q=>q.tempQueryData),h=s.useEditorStore(q=>q.card),y=ae(),g=v.useMemo(()=>y!==h.type?{...h,type:y}:h,[h,y]),{queryKey:j}=p.useEditorCardQuery(g),{setCardSql:b,setSqlGen:m,setCardPython:C,setCardCustomCfg:D,setCardPreferences:N,clearQueryConfig:E,setCardConfig:F,setCardType:Q,setFrame:U,setCard:X,setActiveTabCardId:P}=s.useEditorActions();function W(){var Y,G,L,H;const q=x.getQueryData(j);u!=null&&u.queryData||d({queryKey:j,queryData:q}),x.setQueryData(j,null),x.removeQueries({queryKey:j,exact:!0}),b(""),m({}),E(),F(void 0),C(""),D(""),N({});const r=s.useEditorStore.getState().frame,T=s.useEditorStore.getState().card,I=p.findCustomVisualConfigCard(r,T),A=((Y=I==null?void 0:I.customCardPreferences)==null?void 0:Y.visualType)==="multiple"||!!((G=I==null?void 0:I.customCardPreferences)!=null&&G.dataInputCardIds)||(((L=I==null?void 0:I.customCardPreferences)==null?void 0:L.minInputs)||0)>1||(((H=I==null?void 0:I.customCardPreferences)==null?void 0:H.maxInputs)||0)>1,M=Te(T,A);U({...r,cards:r.cards.map(O=>O.id===M.id?M:O)}),P(M.id),X(M),A||Q("bar")}return e.jsxs(s.Button,{onClick:W,className:i,size:"xs",variant:a,children:[e.jsx(s.X,{className:"h-3.5 w-3.5"}),l]})}function ye(l){const{control:a,onChange:i}=l;return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Label"}),e.jsx(s.Input,{size:"xs",value:a.label,placeholder:"Control label",onChange:d=>i(d.target.value)})]})}function qe(l){const{currentStep:a,labels:i}=l;return e.jsx("div",{className:"sticky top-0 z-10 -mx-1 border-b border-border/60 bg-background/95 px-1 pb-2.5 pt-1 backdrop-blur supports-[backdrop-filter]:bg-background/85",children:e.jsx("div",{className:"flex flex-wrap items-center gap-2 sm:gap-2.5",children:i.map((d,x)=>{const u=x+1,h=u===a,y=u<a;return e.jsxs(v.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:s.cn("flex h-5 w-5 items-center justify-center rounded-full border text-[10px] font-medium tabular-nums",h?"border-foreground bg-foreground text-background":y?"border-foreground/30 bg-foreground/10 text-foreground":"border-border/60 bg-background text-muted-foreground"),children:u}),e.jsx("span",{className:s.cn("text-[12px]",h?"font-medium text-foreground":"text-muted-foreground"),children:d})]}),x<i.length-1?e.jsx("span",{className:"h-px w-4 bg-border/60 sm:w-6","aria-hidden":"true"}):null]},d)})})})}function J(l){const{secondary:a,tertiary:i,primary:d}=l;return e.jsxs("div",{className:"sticky bottom-0 z-10 -mx-1 flex justify-end gap-2 border-t bg-background/95 px-1 pb-1 pt-3 backdrop-blur supports-[backdrop-filter]:bg-background/85",children:[a,i,d]})}function Ae(l){const{control:a,scope:i,detail:d}=l;return e.jsxs("div",{className:"flex items-start gap-2.5 rounded-control border border-border/60 bg-muted/30 px-3 py-2.5",children:[e.jsx(p.CircleCheck,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-foreground"}),e.jsxs("div",{className:"min-w-0 space-y-0.5",children:[e.jsx("div",{className:"text-[13px] font-medium text-foreground",children:a.label}),e.jsxs("div",{className:"text-[12px] text-muted-foreground",children:[s.getFriendlyTypeOption(a.type).label," ·"," ",s.getControlOptionPreview(a)," ·"," ",s.getPlacementLabel(i,a.placement)]}),d?e.jsx("div",{className:"text-[12px] text-muted-foreground",children:d}):null]})]})}function me(l){const{control:a,defaultValue:i,availableFieldChoices:d,availableMetricChoices:x,previewControlDefinitions:u,previewControlValues:h,onControlChange:y,onLabelChange:g,onDefaultValueChange:j,onBack:b,onNext:m,nextDisabled:C}=l;return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ye,{control:a,onChange:g}),e.jsx(p.ControlDefinitionOptionsEditor,{control:a,availableFieldChoices:d,availableMetricChoices:x,previewControlDefinitions:u,previewControlValues:h,controlLifecycle:"create",onChange:y}),e.jsx(p.ControlDefaultValueEditor,{control:a,value:i,onChange:j,allowNoDefault:!0,allowCardDefault:!0,hint:"This is the value viewers will see first.",previewControlDefinitions:u,previewControlValues:h}),e.jsx(J,{secondary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:b,children:"Back"}),primary:e.jsx(s.Button,{type:"button",size:"xs",onClick:m,disabled:C,children:"Next"})})]})}const Me=new Set(["grain_selector","aggregation_selector","field_selector","metric_selector"]);function xe(l){const{text:a,ariaLabel:i}=l,[d,x]=v.useState(!1);return e.jsxs("button",{type:"button","aria-label":i,onClick:async()=>{try{await navigator.clipboard.writeText(a),x(!0),setTimeout(()=>x(!1),1200)}catch(u){console.error("Failed to copy",u)}},className:"group flex w-full items-center justify-between gap-2 rounded-control bg-muted/40 px-2 py-1 text-left transition-colors hover:bg-muted/60 focus-visible:bg-muted/60 focus-visible:outline-none",children:[e.jsx("code",{className:"min-w-0 truncate font-mono text-[12px] text-foreground",children:a}),e.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100",children:d?"Copied":"Click to copy"})]})}function fe(l){const{control:a,scope:i,createdReference:d,explorerContent:x,sqlDescription:u,summaryDetail:h,onBack:y,onCancel:g,onDone:j}=l,b=Me.has(a.type),m=d.match(/\[\[param\.(.+?)\]\]/),C=m?`{{ param('${m[1]}') }}`:"";return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ae,{control:a,scope:i,detail:h}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[13px] font-medium text-foreground",children:"How cards use this control"}),e.jsxs("div",{className:"divide-y divide-border/60 overflow-hidden rounded-control border border-border/60",children:[b?e.jsxs("div",{className:"space-y-1 px-3 py-2.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Explorer cards"}),e.jsx("div",{className:"text-[12px] text-muted-foreground",children:x})]}):null,e.jsxs("div",{className:"space-y-1.5 px-3 py-2.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"SQL cards"}),e.jsx(xe,{text:d,ariaLabel:"Copy SQL control reference"}),C?e.jsx(xe,{text:C,ariaLabel:"Copy Jinja control reference"}):null,e.jsxs("p",{className:"text-[12px] text-muted-foreground",children:[u," ",e.jsx("a",{href:"https://docs.semaphor.cloud/docs/concepts/template-expressions",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Template expressions docs"}),"."]})]})]})]}),e.jsx(J,{secondary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:y,children:"Back"}),tertiary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:g,children:"Cancel"}),primary:e.jsx(s.Button,{type:"button",size:"xs",onClick:j,children:"Done"})})]})}function Oe(l){const a=s.createBlankControl(l.scope,l.existingControls,l.reservedIds),i=l.type===a.type?{...a,label:s.DEFAULT_LABEL_BY_TYPE[l.type]}:{...s.applyControlTypeChange({controls:[{...a,label:s.DEFAULT_LABEL_BY_TYPE[l.type]}],controlId:a.id,nextType:l.type}).controls[0],label:s.DEFAULT_LABEL_BY_TYPE[l.type]};return{step:2,control:i,defaultValue:s.getDefaultValueForType(i,void 0)}}function ze({scope:l,controls:a,reservedControlIds:i,defaultValues:d,onChange:x,emptyMessage:u,initialCreateFlow:h=!1,usageByControlId:y,availableFieldChoices:g,availableMetricChoices:j,structuralParticipants:b,structuralParticipantIdsByControlId:m,card:C,allowedControlTypes:D,onCreateFlowActiveChange:N,onCreateFlowComplete:E}){const F=v.useMemo(()=>new Set(i||[]),[i]),Q=s.getPlacementOptionsForScope(l),U=s.getDefaultPlacement(l),[X,P]=v.useState(null),[W,q]=v.useState(null),[r,T]=v.useState(()=>h?{step:1,control:s.createBlankControl(l,a,Array.from(F))}:null),I=v.useRef({}),A=v.useRef(void 0),M=v.useRef(h),Y=v.useMemo(()=>{const t=s.getFriendlyControlTypeOptions({scope:l,card:C});if(!D)return t;const o=new Set(D);return t.filter(n=>o.has(n.value))},[D,C,l]),G=v.useCallback(t=>{const o=s.getFriendlyControlTypeOptions({scope:l,card:C,includeType:D?void 0:t});if(!D)return o;const n=new Set(D);return o.filter(c=>n.has(c.value))},[D,C,l]),L=v.useCallback(t=>l==="dashboard"&&(t==="field_selector"||t==="metric_selector"),[l]),H=v.useMemo(()=>r?s.getEligibleParticipantsForStructuralControl(b||[],r.control.type):[],[r,b]),O=v.useMemo(()=>{if(!r)return{fields:g||[],metrics:j||[]};if(!L(r.control.type))return{fields:g||[],metrics:j||[]};const t=r.selectedCardIds||[],o=s.getCompatibleStructuralChoiceCatalog({controlType:r.control.type,participants:b||[],selectedCardIds:t});return{fields:r.control.type==="field_selector"?o.choices.map(n=>({option:n,target:o.fieldTargetMap[n.value]})):[],metrics:r.control.type==="metric_selector"?o.choices.map(n=>({option:n,target:o.metricTargetMap[n.value]})):[]}},[g,j,r,L,b]);v.useEffect(()=>{N==null||N(!!r)},[r,N]),v.useEffect(()=>{const t=h&&!M.current;M.current=h,t&&(T({step:1,control:s.createBlankControl(l,a,Array.from(F))}),q(null),P(null))},[a,h,F,l]);const ve=t=>{if(!L(t.type))return{fields:g||[],metrics:j||[]};const o=(m==null?void 0:m[t.id])||[];if(o.length===0)return{fields:g||[],metrics:j||[]};const n=s.getCompatibleStructuralChoiceCatalog({controlType:t.type,participants:b||[],selectedCardIds:o});return{fields:t.type==="field_selector"?n.choices.map(c=>({option:c,target:n.fieldTargetMap[c.value]})):[],metrics:t.type==="metric_selector"?n.choices.map(c=>({option:c,target:n.metricTargetMap[c.value]})):[]}},ne=t=>{if(!L(t.control.type))return{nextControl:t.control,cardBindingsById:void 0};const o=(m==null?void 0:m[t.control.id])||[],n=s.getCompatibleStructuralChoiceCatalog({controlType:t.control.type,participants:b||[],selectedCardIds:t.nextSelectedCardIds}),c=s.reconcileStructuralControlChoices({control:t.control,choices:n.choices}),S=Object.fromEntries(o.filter(k=>!t.nextSelectedCardIds.includes(k)).map(k=>[k,void 0]));return t.nextSelectedCardIds.length>0&&c.source.kind==="manual"&&c.source.options.length>0&&Object.assign(S,s.buildStructuralControlBindingsForParticipants({control:c,participants:b||[],selectedCardIds:t.nextSelectedCardIds})),{nextControl:c,cardBindingsById:S}},B=v.useCallback((t,o=d,n={type:"update"})=>{const c=t.map(S=>(s.resolveAuthoringControlDefaultValue({control:S,defaultValues:o}),s.syncSqlQueryControlExecutionRequirement(S)));x(c,o,n)},[d,x]),K=(t,o)=>{const n=a.find(V=>V.id===t);let c=a.map(V=>V.id!==t?V:o(V));const S=c.find(V=>V.id===t);let k,f;if(S&&l==="dashboard"&&(S.type==="field_selector"||S.type==="metric_selector")){const V=(m==null?void 0:m[S.id])||[],R=ne({control:S,nextSelectedCardIds:V});c=c.map(z=>z.id===t?R.nextControl:z),k=R.cardBindingsById,f=[S.id]}else if(n&&l==="dashboard"&&(n.type==="field_selector"||n.type==="metric_selector")){const V=(m==null?void 0:m[n.id])||[];k=Object.fromEntries(V.map(R=>[R,void 0])),f=[n.id]}const w=c.find(V=>V.id===t);let _=d;if(n&&w){const V=s.resolveAuthoringControlDefaultValue({control:n,defaultValues:d});n.source.kind==="manual"&&w.source.kind==="sql_query"&&(I.current[t]=V);const R=V===void 0&&n.source.kind==="sql_query"&&w.source.kind==="manual"?I.current[t]:V,z=s.getNextEditedControlDefaultValue({previousControl:n,nextControl:w,currentDefaultValue:R});w.source.kind==="manual"&&(I.current[t]=z),d&&(_={...d},z===void 0?delete _[t]:_[t]=z),c=c.map(pe=>pe.id===t?{...w,defaultValue:z}:pe)}B(c,_,{type:"update",cardBindingsById:k,affectedBindingControlIds:f})},Ce=(t,o)=>{if(!o.trim())return;const n=p.normalizeDashboardInputVariableName(o);if(n===t||F.has(n)||a.some(k=>k.id===n&&k.id!==t))return;const c=a.map(k=>k.id===t?{...k,id:n}:k);if(!d){B(c,void 0,{type:"rename",oldId:t,newId:n});return}const S={...d};Object.prototype.hasOwnProperty.call(S,t)&&(S[n]=S[t],delete S[t]),B(c,S,{type:"rename",oldId:t,newId:n})},je=t=>{const o=a.filter(c=>c.id!==t);if(!d){B(o,void 0,{type:"remove",controlId:t});return}const n={...d};delete n[t],B(o,n,{type:"remove",controlId:t})},Se=v.useCallback(()=>{A.current=void 0,T({step:1,control:s.createBlankControl(l,a,Array.from(F))}),q(null),P(null)},[a,F,l]),$=t=>{T(o=>o&&(()=>{const n=t(o.control);o.control.source.kind==="manual"&&n.source.kind==="sql_query"&&(A.current=o.defaultValue);const c=o.defaultValue===void 0&&o.control.source.kind==="sql_query"&&n.source.kind==="manual"?A.current:o.defaultValue,S=s.getNextEditedControlDefaultValue({previousControl:o.control,nextControl:n,currentDefaultValue:c});return n.source.kind==="manual"&&(A.current=S),{...o,control:n,defaultValue:S}})())},oe=t=>{T(o=>o&&(o.control.source.kind==="manual"&&(A.current=t),{...o,defaultValue:t}))},Z=(()=>{if(!r)return!1;if(r.step===2&&L(r.control.type))return(r.selectedCardIds||[]).length>0;if(r.step!==2&&r.step!==3||!r.control.label.trim())return!1;const o=r.control.source.kind==="sql_query"?r.control:s.ensureManualSource(r.control);if(o.source.kind==="manual"&&(s.needsManualOptions(o)&&o.source.options.length===0||o.source.options.some(c=>c.label.trim().length===0||c.value.trim().length===0)))return!1;if(o.source.kind==="sql_query"){const{connectionId:n,sql:c,valueColumn:S}=o.source;return n.trim().length>0&&c.trim().length>0&&S.trim().length>0}return s.hasConcreteDefaultValue(s.getDefaultValueForType(o,r.defaultValue))})(),ie=()=>{var k;if(!r)return;const t=s.ensureManualSource(r.control),o=s.deriveUniqueControlId({label:t.label,fallbackId:t.id,existingControls:a,reservedIds:Array.from(F)}),n={...t,id:o},c=l==="dashboard"&&(n.type==="field_selector"||n.type==="metric_selector")&&((k=r.selectedCardIds)!=null&&k.length)?s.buildStructuralControlBindingsForParticipants({control:n,participants:b||[],selectedCardIds:r.selectedCardIds}):void 0,S=s.getDefaultValueForType(n,r.defaultValue);T({step:l==="dashboard"&&(n.type==="field_selector"||n.type==="metric_selector")?4:3,control:n,defaultValue:S,createdControlId:o,selectedCardIds:r.selectedCardIds,cardBindingsById:c})},ee=v.useCallback(()=>{T(null)},[]),de=v.useCallback(()=>{if(!(r!=null&&r.createdControlId)){T(null);return}const t=r.control,o=r.createdControlId,n=s.getDefaultValueForType(t,r.defaultValue);if(d){const c={...d};n===void 0?delete c[o]:c[o]=n,B([...a,{...t,defaultValue:n}],c,{type:"add",cardBindingsById:r.cardBindingsById})}else B([...a,{...t,defaultValue:n}],void 0,{type:"add",cardBindingsById:r.cardBindingsById});q(o),T(null),E==null||E()},[a,r,d,B,E]),ke=r?L(r.control.type)?["Choose type","Select cards","Configure","Finish"]:["Choose type","Configure","Finish"]:[],ce=r!=null&&r.createdControlId?`[[param.${r.createdControlId}]]`:r?`[[param.${s.slugifyControlValue(r.control.label)||r.control.id}]]`:"",te=s.buildAuthoringPreviewControlValues({controls:a,defaultValues:d}),se=r?[...a,r.control]:a,ue=r?s.buildAuthoringPreviewControlValues({controls:se,defaultValues:d,overrides:[{controlId:r.control.id,value:r.defaultValue}]}):te;return e.jsxs("div",{className:"space-y-4",children:[r?e.jsxs("div",{className:"space-y-4 pb-1",children:[e.jsx(qe,{currentStep:r.step,labels:ke}),r.step===1&&(()=>{const t=new Set(["grain_selector","aggregation_selector","field_selector","metric_selector"]),o=new Set(["date","text"]),n=Y.filter(k=>!t.has(k.value)&&!o.has(k.value)),c=Y.filter(k=>t.has(k.value)),S=k=>e.jsxs("button",{type:"button",className:"rounded-control border border-border/60 bg-background px-3 py-2.5 text-left transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:outline-none",onClick:()=>T(Oe({scope:l,existingControls:a,reservedIds:Array.from(F),type:k.value})),children:[e.jsx("div",{className:"text-[13px] font-medium text-foreground",children:k.label}),e.jsx("p",{className:"mt-0.5 text-[12px] text-muted-foreground",children:k.description})]},k.value);return e.jsxs("div",{className:"space-y-4",children:[l==="card"&&(C==null?void 0:C.sql)==null?e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Explorer cards support displayed metric, group by field, aggregation, and time grain controls here."}):null,n.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Input controls"}),e.jsx("div",{className:"grid gap-1.5 sm:grid-cols-2",children:n.map(S)})]}),c.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Data-driven controls"}),e.jsx("div",{className:"grid gap-1.5 sm:grid-cols-2",children:c.map(S)})]}),e.jsx(J,{secondary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:ee,children:"Back to controls"})})]})})(),r.step===2&&L(r.control.type)&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(ye,{control:r.control,onChange:t=>$(o=>({...o,label:t}))}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Choose which cards should respond to this shared control."})]}),H.length===0?e.jsx("div",{className:"rounded-control border border-border/60 bg-muted/30 px-3 py-2.5 text-[12px] text-muted-foreground",children:"No eligible cards are available yet. Add compatible metrics or group-by fields to cards first."}):e.jsx("div",{className:"space-y-1 rounded-control border border-border/60 bg-background p-2",children:H.map(t=>{const o=(r.selectedCardIds||[]).includes(t.cardId);return e.jsxs("label",{className:"flex items-start gap-2 rounded-control px-1.5 py-1 text-[13px] hover:bg-muted/40",children:[e.jsx(p.Checkbox,{checked:o,onCheckedChange:n=>T(c=>c&&{...c,selectedCardIds:n===!0?[...c.selectedCardIds||[],t.cardId]:(c.selectedCardIds||[]).filter(S=>S!==t.cardId)})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-foreground",children:t.title}),e.jsx("div",{className:"text-[12px] text-muted-foreground",children:r.control.type==="field_selector"?`${t.fieldChoices.length} compatible group-by fields`:`${t.metricChoices.length} compatible metrics`})]})]},t.cardId)})}),e.jsx(J,{secondary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:()=>T(t=>t&&{...t,step:1,selectedCardIds:[]}),children:"Back"}),primary:e.jsx(s.Button,{type:"button",size:"xs",onClick:()=>T(t=>t&&{...t,step:3}),disabled:!Z,children:"Next"})})]}),r.step===2&&!L(r.control.type)&&e.jsx(me,{control:r.control,defaultValue:r.defaultValue,availableFieldChoices:O.fields,availableMetricChoices:O.metrics,previewControlDefinitions:se,previewControlValues:ue,onControlChange:t=>$(()=>t),onLabelChange:t=>$(o=>({...o,label:t})),onDefaultValueChange:oe,onBack:()=>T(t=>t&&{...t,step:1}),onNext:ie,nextDisabled:!Z}),r.step===3&&L(r.control.type)&&e.jsx(me,{control:r.control,defaultValue:r.defaultValue,availableFieldChoices:O.fields,availableMetricChoices:O.metrics,previewControlDefinitions:se,previewControlValues:ue,onControlChange:t=>$(()=>t),onLabelChange:t=>$(o=>({...o,label:t})),onDefaultValueChange:oe,onBack:()=>T(t=>t&&{...t,step:2}),onNext:ie,nextDisabled:!Z}),r.step===3&&!L(r.control.type)&&e.jsx(fe,{control:r.control,scope:l,createdReference:ce,explorerContent:e.jsxs(e.Fragment,{children:["Open the card and use"," ",e.jsx("span",{className:"font-medium text-foreground",children:"Settings → Controls"})," ","to choose what this control changes."]}),sqlDescription:"Reference this control directly in the SQL editor.",onBack:()=>T(t=>t&&{...t,step:2}),onCancel:ee,onDone:de}),r.step===4&&L(r.control.type)&&e.jsx(fe,{control:r.control,scope:l,createdReference:ce,summaryDetail:e.jsxs(e.Fragment,{children:["Used by ",(r.selectedCardIds||[]).length," selected card",(r.selectedCardIds||[]).length===1?"":"s"]}),explorerContent:e.jsx(e.Fragment,{children:"Selected cards have been set up to respond to this control automatically."}),sqlDescription:"SQL cards can still reference this control directly in the SQL editor.",onBack:()=>T(t=>t&&{...t,step:3}),onCancel:ee,onDone:de})]}):null,!r&&a.length===0?e.jsx("div",{className:"rounded-md border border-dashed p-3 text-sm text-muted-foreground",children:u}):null,!r&&a.map(t=>{const o=ve(t),n=y==null?void 0:y[t.id],c=s.resolveAuthoringControlDefaultValue({control:t,defaultValues:d}),S=W===t.id,k="inline-flex shrink-0 items-center rounded-[4px] border border-border/60 bg-muted/40 px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground";return e.jsxs("div",{className:"rounded-control border border-border/60",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[e.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-start gap-2 rounded-control text-left focus:outline-none focus-visible:bg-muted/40",onClick:()=>q(f=>f===t.id?null:t.id),children:[S?e.jsx(s.ChevronDown,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(p.ChevronRight,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",children:t.label||"Untitled control"}),e.jsx("span",{className:k,children:s.getFriendlyTypeOption(t.type).label}),e.jsx("span",{className:k,children:s.getPlacementLabel(l,t.placement)})]}),e.jsxs("div",{className:"mt-0.5 text-[12px] text-muted-foreground",children:[s.getControlOptionPreview(t),n!=null&&n.status?` · ${n.status}`:""]})]})]}),e.jsx(s.Button,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 shrink-0 p-0 text-muted-foreground",onClick:()=>je(t.id),"aria-label":`Remove ${t.label}`,children:e.jsx(p.Trash2,{className:"h-3.5 w-3.5"})})]}),S&&e.jsxs("div",{className:"space-y-4 border-t border-border/60 px-3 py-3",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Label"}),e.jsx(s.Input,{size:"xs",value:t.label,placeholder:"Control label",onChange:f=>K(t.id,w=>({...w,label:f.target.value}))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Type"}),e.jsxs(s.Select,{value:t.type,onValueChange:f=>{const w=s.applyControlTypeChange({controls:a,controlId:t.id,nextType:f,defaultValues:d});B(w.controls,w.defaultValues)},children:[e.jsx(s.SelectTrigger,{size:"xs",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:G(t.type).map(f=>e.jsx(s.SelectItem,{value:f.value,children:f.label},f.value))})]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Show in"}),e.jsxs(s.Select,{value:t.placement||U,onValueChange:f=>K(t.id,w=>({...w,placement:f})),children:[e.jsx(s.SelectTrigger,{size:"xs",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:Q.map(f=>e.jsx(s.SelectItem,{value:f.value,children:f.label},f.value))})]})]})]}),L(t.type)?e.jsx(p.StructuralParticipantSelector,{type:t.type,participants:s.getEligibleParticipantsForStructuralControl(b||[],t.type).map(f=>({cardId:f.cardId,title:f.title,choiceCount:t.type==="field_selector"?f.fieldChoices.length:f.metricChoices.length})),selectedCardIds:(m==null?void 0:m[t.id])||[],onChange:f=>{const w=ne({control:t,nextSelectedCardIds:f}),_=a.map(V=>V.id===t.id?w.nextControl:V);B(_,d,{type:"update",cardBindingsById:w.cardBindingsById})}}):null,e.jsx(p.ControlDefinitionOptionsEditor,{control:t,availableFieldChoices:o.fields,availableMetricChoices:o.metrics,previewControlDefinitions:a,previewControlValues:te,controlLifecycle:"edit",onChange:f=>K(t.id,()=>f)}),t.initialValueStrategy==="saved_default"&&e.jsx(p.ControlDefaultValueEditor,{control:t,value:c,allowNoDefault:!0,allowCardDefault:!0,previewControlDefinitions:a,previewControlValues:te,onChange:f=>{const w=a.map(_=>_.id===t.id?{..._,defaultValue:f}:_);if(t.source.kind==="manual"&&(I.current[t.id]=f),d){const _={...d};f===void 0?delete _[t.id]:_[t.id]=f,B(w,_);return}B(w,void 0)}}),e.jsxs(p.Collapsible,{open:X===t.id,onOpenChange:f=>P(f?t.id:null),children:[e.jsx(p.CollapsibleTrigger,{asChild:!0,children:e.jsxs(s.Button,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 gap-1 text-muted-foreground hover:text-foreground",children:[X===t.id?e.jsx(s.ChevronDown,{className:"h-3.5 w-3.5"}):e.jsx(p.ChevronRight,{className:"h-3.5 w-3.5"}),"Advanced"]})}),e.jsxs(p.CollapsibleContent,{className:"space-y-3 pt-2",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Variable name"}),e.jsx(p.ControlIdInput,{controlId:t.id,onCommit:f=>Ce(t.id,f)},t.id)]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Initial value"}),e.jsxs(s.Select,{value:t.initialValueStrategy,onValueChange:f=>K(t.id,w=>({...w,initialValueStrategy:f})),children:[e.jsx(s.SelectTrigger,{size:"xs",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:s.INITIAL_VALUE_STRATEGY_OPTIONS.map(f=>e.jsx(s.SelectItem,{value:f.value,children:f.label},f.value))})]})]})]}),e.jsx(p.ControlVisibilitySettings,{control:t,onChange:f=>K(t.id,()=>f)})]})]})]})]},t.id)}),!r&&e.jsxs(s.Button,{type:"button",variant:"outline",size:"xs",onClick:Se,children:[e.jsx(p.Plus,{className:"h-3.5 w-3.5"}),"Add control"]})]})}function Re(l){const{open:a,onOpenChange:i,initialCreateFlowActive:d=!1,dismissMode:x="passive"}=l,u=a!==void 0,[h,y]=v.useState(!1),[g,j]=v.useState(d),b=u?a:h,m=v.useCallback(N=>{!N&&g&&x==="passive"||(u||y(N),N||j(!1),i==null||i(N))},[u,g,x,i]),C=v.useCallback(()=>{u||y(!1),j(!1),i==null||i(!1)},[u,i]);v.useEffect(()=>{b||j(!1)},[b]);const D=v.useCallback(N=>{g&&N.preventDefault()},[g]);return{forceClose:C,handleOpenChange:m,isCreateFlowActive:g,preventPassiveDismissDuringCreate:D,resolvedOpen:b,setIsCreateFlowActive:j}}exports.CircleX=Ne;exports.ControlDefinitionListEditor=ze;exports.EditorAcceptButton=Ie;exports.EditorCancelButton=_e;exports.EditorClearButton=Be;exports.Library=ge;exports.Link2=be;exports.Rows3=De;exports.SendHorizontal=Ee;exports.VisualBadge=Ve;exports.VisualSaveAndApplyButton=Fe;exports.VisualSaveButton=Le;exports.useCreateFlowOverlayState=Re;exports.useEffectiveEditorCardType=ae;exports.useSyncLegacyEditorState=we;
@@ -1 +1 @@
1
- "use strict";const u=require("./index-XYIIY48z.js"),f=require("./switch-DPaKnsb8.js"),S=require("react");function K(e){const[a,s]=S.useState(null),[r,t]=S.useState(null),o=u.useEnsureReactGlobals();return S.useEffect(()=>{if(!e||e.trim()===""){s(null),t(null);return}if(!o)return;(async()=>{try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error(`Invalid URL format: ${e}`);try{new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}const i=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(i,{method:"HEAD"})).ok)throw new Error(`Module not found at ${i}`)}catch{}const m=await import(i);if(typeof m.useChartStore!="function")throw new Error("useChartStore is not a function");s(()=>m.useChartStore),t(null)}catch(n){const i=n instanceof Error?n.message:"Unknown error";console.error("Failed to load remote chart store:",i),t(i),s(null)}})()},[e,o]),a}function X(e,a){if(e.length===0)return"";const s=e.find(r=>{var t,o;return((t=r.customCardPreferences)==null?void 0:t.visualType)==="multiple"||!!((o=r.customCardPreferences)!=null&&o.dataInputCardIds)});if(s)return s.id;if(a){const r=e.find(t=>t.id===a);if(r){const t=r.tabTitle;if(t=="All__Header")return e[0].id;if(t&&t.endsWith("__Header")){const l=t.split("__")[0],n=e.find(i=>i.tabTitle===l);return n?n.id:e[0].id}return a}}return e[0].id}const A=new Set;function Y(e){return A.add(e),()=>{A.delete(e)}}function z(){A.forEach(e=>{e()})}const Z=e=>{if(!e||!("detailTableBackup"in e))return e;const{detailTableBackup:a,...s}=e;return s};async function B(e,a,s,r){if(!a||!s)throw new Error("Missing auth token or visual ID");const t=["resource-by-id","visual",s],o=r.getQueryData(t);if(o)return console.log("Using cached visual data for:",s),{data:o,fromCache:!0};console.log("Fetching visual data from network for:",s);const l=u.ue.loading("Loading visual...",{position:"top-center"});try{const n=await fetch(`${e}/management/v1/visuals/${s}`,{headers:{Authorization:`Bearer ${a}`}});if(!n.ok)throw new Error("Failed to load visual");const i=await n.json();return r.setQueryData(t,i),u.ue.dismiss(l),{data:i,fromCache:!1}}catch(n){throw u.ue.dismiss(l),n}}function H(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function ee(e,a){var o,l;const s=(e==null?void 0:e.frameObject)??((o=e==null?void 0:e.visual)==null?void 0:o.frameObject);if(!s)return!1;const r=H(s);if(!(r!=null&&r.cards)||r.cards.length===0)return!1;const t=(l=r.cards)==null?void 0:l.find(n=>n.id===r.activeCardId);return t?(u.setupEditorWithCard({...a,frame:r,card:t,visualId:(e==null?void 0:e.id)||r.visualId}),!0):!1}function te(){const e=f.useEditorStore(r=>{var t;return((t=r.card.customCardPreferences)==null?void 0:t.url)||""}),a=K(e);return{getUpdatedFrame:S.useCallback(()=>{var b;z();const{frame:r,card:t,isDevMode:o,isShowingVisual:l,selectedSchemaName:n,selectedDatamodelId:i,selectedDatabaseName:m,selectedTableName:p,selectedConnectionId:y}=f.useEditorStore.getState(),I=t.sql,U=(b=a==null?void 0:a.getState())==null?void 0:b.settings,V=f.buildSavedEditorCard(t,{isDevMode:o,cardSql:I,isShowingVisual:l,selectedSchemaName:n,selectedDatamodelId:i,selectedDatabaseName:m,selectedTableName:p,selectedConnectionId:y,remoteChartSettings:U,stripConfig:Z}),g=r.cards.map(E=>E.id===t.id?V:E);return{...r,cards:g,activeCardId:X(g,r.activeCardId)}},[a])}}function re(){const{authToken:e,tokenProps:a}=u.useSemaphorContext(),s=u.useQueryClient(),r=u.useAddFrameWithFreshSemanticExecutionPayload(),t=u.useSelectedVisual(),{selectVisual:o}=u.useManagementActions(),{setFrame:l,setCard:n,setIsDevMode:i,initializeModeDrafts:m,setActiveTabCardId:p,updateDataSource:y,setQueryResultColumns:I,setSelectedConnectionId:U,setSelectedDatabaseName:V,setSelectedSchemaName:g,setSelectedTableName:b,setSelectedDatamodelId:E,setFilterValues:P,setInlineFilterValuesMap:M,setApplyFilters:k,clearEditorContext:L}=f.useEditorActions(),{setIsDashboardEditing:v,setIsVisualEditing:T,setSelectedFrameId:j,clearSelectedFrameId:N,setIsDashboardPanelOpen:R}=f.useDashboardActions(),w=f.useDashboardStore(c=>c.selectedSheetId),W=f.useDashboardStore(c=>c.selectedFrameId),$=f.useDashboardStore(c=>c.dashboard),_=f.useDashboardStore(c=>c.filterValues),x=f.useDashboardStore(c=>c.inlineFilterValuesMap),F=u.useVisualById((t==null?void 0:t.id)||"",{enabled:!!(t!=null&&t.id)&&!!(e!=null&&e.accessToken)}),Q=S.useCallback(async c=>{try{o(c),N(),L();const{data:h,fromCache:D}=await B(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",c.id,s);if(!ee(h,{setFrame:l,setCard:n,setIsDevMode:i,initializeModeDrafts:m,setActiveTabCardId:p,updateDataSource:y,setQueryResultColumns:I,setSelectedConnectionId:U,setSelectedDatabaseName:V,setSelectedSchemaName:g,setSelectedTableName:b,setSelectedDatamodelId:E,setFilterValues:P,setInlineFilterValuesMap:M,setApplyFilters:k,setIsDashboardEditing:v,setIsVisualEditing:T,dashboard:$,selectedSheetId:w,selectedFrameId:W,filterValues:_,inlineFilterValuesMap:x}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:D}}catch(h){return console.error("Error editing visual:",h),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,a.apiServiceUrl,s,o,l,n,v,T,i,m,p,y,I,U,V,g,b,E,P,M,k,L,N,$,w,W,_,x]),G=S.useCallback(async c=>{var D;const h=d=>(u.ue.error(d),{success:!1,error:d});try{if(o(c),!w)return h("No sheet selected. Please select a sheet first.");const{data:d,fromCache:J}=await B(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",c.id,s),O=(d==null?void 0:d.frameObject)??((D=d==null?void 0:d.visual)==null?void 0:D.frameObject);if(!O)return h("Visual has no frame data");const C=H(O);if(!(C!=null&&C.cards)||C.cards.length===0)return h("Visual frame is malformed");const q={...u.cloneLinkedFrameWithSourceMapping(C),visualId:c.id};return await r(w,q,"end"),v(!0),j(q.id),R(!1),{success:!0,fromCache:J}}catch(d){return console.error("Error adding visual:",d),h(d instanceof Error?d.message:"Failed to add visual to dashboard")}},[e==null?void 0:e.accessToken,a.apiServiceUrl,s,o,w,v,j,R,r]);return{visual:F.data,isLoading:F.isLoading,isError:F.isError,error:F.error,handleEditLibraryVisual:Q,handleAddLibraryVisual:G,getUpdatedFrame:te().getUpdatedFrame,refetch:F.refetch}}exports.flushPendingEditorDrafts=z;exports.registerPendingEditorDraftFlusher=Y;exports.useVisualUtils=re;
1
+ "use strict";const u=require("./index-Xdag_85e.js"),f=require("./switch-DPaKnsb8.js"),S=require("react");function K(e){const[a,s]=S.useState(null),[r,t]=S.useState(null),o=u.useEnsureReactGlobals();return S.useEffect(()=>{if(!e||e.trim()===""){s(null),t(null);return}if(!o)return;(async()=>{try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error(`Invalid URL format: ${e}`);try{new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}const i=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(i,{method:"HEAD"})).ok)throw new Error(`Module not found at ${i}`)}catch{}const m=await import(i);if(typeof m.useChartStore!="function")throw new Error("useChartStore is not a function");s(()=>m.useChartStore),t(null)}catch(n){const i=n instanceof Error?n.message:"Unknown error";console.error("Failed to load remote chart store:",i),t(i),s(null)}})()},[e,o]),a}function X(e,a){if(e.length===0)return"";const s=e.find(r=>{var t,o;return((t=r.customCardPreferences)==null?void 0:t.visualType)==="multiple"||!!((o=r.customCardPreferences)!=null&&o.dataInputCardIds)});if(s)return s.id;if(a){const r=e.find(t=>t.id===a);if(r){const t=r.tabTitle;if(t=="All__Header")return e[0].id;if(t&&t.endsWith("__Header")){const l=t.split("__")[0],n=e.find(i=>i.tabTitle===l);return n?n.id:e[0].id}return a}}return e[0].id}const A=new Set;function Y(e){return A.add(e),()=>{A.delete(e)}}function z(){A.forEach(e=>{e()})}const Z=e=>{if(!e||!("detailTableBackup"in e))return e;const{detailTableBackup:a,...s}=e;return s};async function B(e,a,s,r){if(!a||!s)throw new Error("Missing auth token or visual ID");const t=["resource-by-id","visual",s],o=r.getQueryData(t);if(o)return console.log("Using cached visual data for:",s),{data:o,fromCache:!0};console.log("Fetching visual data from network for:",s);const l=u.ue.loading("Loading visual...",{position:"top-center"});try{const n=await fetch(`${e}/management/v1/visuals/${s}`,{headers:{Authorization:`Bearer ${a}`}});if(!n.ok)throw new Error("Failed to load visual");const i=await n.json();return r.setQueryData(t,i),u.ue.dismiss(l),{data:i,fromCache:!1}}catch(n){throw u.ue.dismiss(l),n}}function H(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function ee(e,a){var o,l;const s=(e==null?void 0:e.frameObject)??((o=e==null?void 0:e.visual)==null?void 0:o.frameObject);if(!s)return!1;const r=H(s);if(!(r!=null&&r.cards)||r.cards.length===0)return!1;const t=(l=r.cards)==null?void 0:l.find(n=>n.id===r.activeCardId);return t?(u.setupEditorWithCard({...a,frame:r,card:t,visualId:(e==null?void 0:e.id)||r.visualId}),!0):!1}function te(){const e=f.useEditorStore(r=>{var t;return((t=r.card.customCardPreferences)==null?void 0:t.url)||""}),a=K(e);return{getUpdatedFrame:S.useCallback(()=>{var b;z();const{frame:r,card:t,isDevMode:o,isShowingVisual:l,selectedSchemaName:n,selectedDatamodelId:i,selectedDatabaseName:m,selectedTableName:p,selectedConnectionId:y}=f.useEditorStore.getState(),I=t.sql,U=(b=a==null?void 0:a.getState())==null?void 0:b.settings,V=f.buildSavedEditorCard(t,{isDevMode:o,cardSql:I,isShowingVisual:l,selectedSchemaName:n,selectedDatamodelId:i,selectedDatabaseName:m,selectedTableName:p,selectedConnectionId:y,remoteChartSettings:U,stripConfig:Z}),g=r.cards.map(E=>E.id===t.id?V:E);return{...r,cards:g,activeCardId:X(g,r.activeCardId)}},[a])}}function re(){const{authToken:e,tokenProps:a}=u.useSemaphorContext(),s=u.useQueryClient(),r=u.useAddFrameWithFreshSemanticExecutionPayload(),t=u.useSelectedVisual(),{selectVisual:o}=u.useManagementActions(),{setFrame:l,setCard:n,setIsDevMode:i,initializeModeDrafts:m,setActiveTabCardId:p,updateDataSource:y,setQueryResultColumns:I,setSelectedConnectionId:U,setSelectedDatabaseName:V,setSelectedSchemaName:g,setSelectedTableName:b,setSelectedDatamodelId:E,setFilterValues:P,setInlineFilterValuesMap:M,setApplyFilters:k,clearEditorContext:L}=f.useEditorActions(),{setIsDashboardEditing:v,setIsVisualEditing:T,setSelectedFrameId:j,clearSelectedFrameId:N,setIsDashboardPanelOpen:R}=f.useDashboardActions(),w=f.useDashboardStore(c=>c.selectedSheetId),W=f.useDashboardStore(c=>c.selectedFrameId),$=f.useDashboardStore(c=>c.dashboard),_=f.useDashboardStore(c=>c.filterValues),x=f.useDashboardStore(c=>c.inlineFilterValuesMap),F=u.useVisualById((t==null?void 0:t.id)||"",{enabled:!!(t!=null&&t.id)&&!!(e!=null&&e.accessToken)}),Q=S.useCallback(async c=>{try{o(c),N(),L();const{data:h,fromCache:D}=await B(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",c.id,s);if(!ee(h,{setFrame:l,setCard:n,setIsDevMode:i,initializeModeDrafts:m,setActiveTabCardId:p,updateDataSource:y,setQueryResultColumns:I,setSelectedConnectionId:U,setSelectedDatabaseName:V,setSelectedSchemaName:g,setSelectedTableName:b,setSelectedDatamodelId:E,setFilterValues:P,setInlineFilterValuesMap:M,setApplyFilters:k,setIsDashboardEditing:v,setIsVisualEditing:T,dashboard:$,selectedSheetId:w,selectedFrameId:W,filterValues:_,inlineFilterValuesMap:x}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:D}}catch(h){return console.error("Error editing visual:",h),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,a.apiServiceUrl,s,o,l,n,v,T,i,m,p,y,I,U,V,g,b,E,P,M,k,L,N,$,w,W,_,x]),G=S.useCallback(async c=>{var D;const h=d=>(u.ue.error(d),{success:!1,error:d});try{if(o(c),!w)return h("No sheet selected. Please select a sheet first.");const{data:d,fromCache:J}=await B(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",c.id,s),O=(d==null?void 0:d.frameObject)??((D=d==null?void 0:d.visual)==null?void 0:D.frameObject);if(!O)return h("Visual has no frame data");const C=H(O);if(!(C!=null&&C.cards)||C.cards.length===0)return h("Visual frame is malformed");const q={...u.cloneLinkedFrameWithSourceMapping(C),visualId:c.id};return await r(w,q,"end"),v(!0),j(q.id),R(!1),{success:!0,fromCache:J}}catch(d){return console.error("Error adding visual:",d),h(d instanceof Error?d.message:"Failed to add visual to dashboard")}},[e==null?void 0:e.accessToken,a.apiServiceUrl,s,o,w,v,j,R,r]);return{visual:F.data,isLoading:F.isLoading,isError:F.isError,error:F.error,handleEditLibraryVisual:Q,handleAddLibraryVisual:G,getUpdatedFrame:te().getUpdatedFrame,refetch:F.refetch}}exports.flushPendingEditorDrafts=z;exports.registerPendingEditorDraftFlusher=Y;exports.useVisualUtils=re;
@@ -1,8 +1,8 @@
1
- import { p as X, u as Y, q as Z, r as ee, s as te, t as re, v as se, w as ae, o as V, x as oe } from "./index-P5hPTTzm.js";
2
- import { g as ne, h as ie, u as b, i as z, j as ce } from "./switch-B6fh8nb-.js";
3
- import { useState as H, useEffect as de, useCallback as A } from "react";
1
+ import { ab as X, u as Y, ac as Z, ad as ee, ae as te, af as re, ag as se, ah as ae, o as V, ai as oe } from "./index-gcA9Rs35.js";
2
+ import { H as ne, E as ie, u as w, G as H, I as ce } from "./switch-sauemjyY.js";
3
+ import { useState as z, useEffect as de, useCallback as A } from "react";
4
4
  function le(e) {
5
- const [a, s] = H(null), [r, t] = H(null), o = X();
5
+ const [a, s] = z(null), [r, t] = z(null), o = X();
6
6
  return de(() => {
7
7
  if (!e || e.trim() === "") {
8
8
  s(null), t(null);
@@ -69,7 +69,7 @@ function ue(e, a) {
69
69
  return e[0].id;
70
70
  }
71
71
  const M = /* @__PURE__ */ new Set();
72
- function we(e) {
72
+ function be(e) {
73
73
  return M.add(e), () => {
74
74
  M.delete(e);
75
75
  };
@@ -138,7 +138,7 @@ function me(e, a) {
138
138
  }), !0) : !1;
139
139
  }
140
140
  function pe() {
141
- const e = z(
141
+ const e = H(
142
142
  (r) => {
143
143
  var t;
144
144
  return ((t = r.card.customCardPreferences) == null ? void 0 : t.url) || "";
@@ -157,7 +157,7 @@ function pe() {
157
157
  selectedDatabaseName: f,
158
158
  selectedTableName: h,
159
159
  selectedConnectionId: F
160
- } = z.getState(), C = t.sql, y = (p = a == null ? void 0 : a.getState()) == null ? void 0 : p.settings, I = ce(t, {
160
+ } = H.getState(), C = t.sql, y = (p = a == null ? void 0 : a.getState()) == null ? void 0 : p.settings, I = ce(t, {
161
161
  isDevMode: o,
162
162
  cardSql: C,
163
163
  isShowingVisual: l,
@@ -178,7 +178,7 @@ function pe() {
178
178
  };
179
179
  }, [a]) };
180
180
  }
181
- function be() {
181
+ function we() {
182
182
  const { authToken: e, tokenProps: a } = Y(), s = Z(), r = ee(), t = te(), { selectVisual: o } = re(), {
183
183
  setFrame: l,
184
184
  setCard: n,
@@ -193,24 +193,24 @@ function be() {
193
193
  setSelectedTableName: p,
194
194
  setSelectedDatamodelId: g,
195
195
  setFilterValues: P,
196
- setInlineFilterValuesMap: j,
197
- setApplyFilters: D,
198
- clearEditorContext: L
196
+ setInlineFilterValuesMap: D,
197
+ setApplyFilters: L,
198
+ clearEditorContext: T
199
199
  } = ne(), {
200
- setIsDashboardEditing: v,
201
- setIsVisualEditing: T,
200
+ setIsDashboardEditing: U,
201
+ setIsVisualEditing: j,
202
202
  setSelectedFrameId: k,
203
203
  clearSelectedFrameId: N,
204
204
  setIsDashboardPanelOpen: W
205
- } = ie(), S = b((c) => c.selectedSheetId), $ = b((c) => c.selectedFrameId), x = b((c) => c.dashboard), R = b((c) => c.filterValues), O = b(
205
+ } = ie(), E = w((c) => c.selectedSheetId), $ = w((c) => c.selectedFrameId), R = w((c) => c.dashboard), x = w((c) => c.filterValues), O = w(
206
206
  (c) => c.inlineFilterValuesMap
207
- ), E = se((t == null ? void 0 : t.id) || "", {
207
+ ), S = se((t == null ? void 0 : t.id) || "", {
208
208
  enabled: !!(t != null && t.id) && !!(e != null && e.accessToken)
209
209
  }), G = A(
210
210
  async (c) => {
211
211
  try {
212
- o(c), N(), L();
213
- const { data: u, fromCache: U } = await Q(
212
+ o(c), N(), T();
213
+ const { data: u, fromCache: v } = await Q(
214
214
  a.apiServiceUrl,
215
215
  (e == null ? void 0 : e.accessToken) || "",
216
216
  c.id,
@@ -230,18 +230,18 @@ function be() {
230
230
  setSelectedTableName: p,
231
231
  setSelectedDatamodelId: g,
232
232
  setFilterValues: P,
233
- setInlineFilterValuesMap: j,
234
- setApplyFilters: D,
235
- setIsDashboardEditing: v,
236
- setIsVisualEditing: T,
237
- dashboard: x,
238
- selectedSheetId: S,
233
+ setInlineFilterValuesMap: D,
234
+ setApplyFilters: L,
235
+ setIsDashboardEditing: U,
236
+ setIsVisualEditing: j,
237
+ dashboard: R,
238
+ selectedSheetId: E,
239
239
  selectedFrameId: $,
240
- filterValues: R,
240
+ filterValues: x,
241
241
  inlineFilterValuesMap: O
242
242
  }))
243
243
  throw new Error("Failed to setup editor with visual data");
244
- return { success: !0, fromCache: U };
244
+ return { success: !0, fromCache: v };
245
245
  } catch (u) {
246
246
  return console.error("Error editing visual:", u), { success: !1, error: "Failed to load visual for editing" };
247
247
  }
@@ -253,8 +253,8 @@ function be() {
253
253
  o,
254
254
  l,
255
255
  n,
256
- v,
257
- T,
256
+ U,
257
+ j,
258
258
  i,
259
259
  f,
260
260
  h,
@@ -266,44 +266,44 @@ function be() {
266
266
  p,
267
267
  g,
268
268
  P,
269
- j,
270
269
  D,
271
270
  L,
271
+ T,
272
272
  N,
273
- x,
274
- S,
275
- $,
276
273
  R,
274
+ E,
275
+ $,
276
+ x,
277
277
  O
278
278
  ]
279
279
  ), J = A(
280
280
  async (c) => {
281
- var U;
281
+ var v;
282
282
  const u = (d) => (V.error(d), { success: !1, error: d });
283
283
  try {
284
- if (o(c), !S)
284
+ if (o(c), !E)
285
285
  return u("No sheet selected. Please select a sheet first.");
286
286
  const { data: d, fromCache: K } = await Q(
287
287
  a.apiServiceUrl,
288
288
  (e == null ? void 0 : e.accessToken) || "",
289
289
  c.id,
290
290
  s
291
- ), _ = (d == null ? void 0 : d.frameObject) ?? ((U = d == null ? void 0 : d.visual) == null ? void 0 : U.frameObject);
291
+ ), _ = (d == null ? void 0 : d.frameObject) ?? ((v = d == null ? void 0 : d.visual) == null ? void 0 : v.frameObject);
292
292
  if (!_)
293
293
  return u("Visual has no frame data");
294
- const w = q(_);
295
- if (!(w != null && w.cards) || w.cards.length === 0)
294
+ const b = q(_);
295
+ if (!(b != null && b.cards) || b.cards.length === 0)
296
296
  return u("Visual frame is malformed");
297
297
  const B = {
298
- ...ae(w),
298
+ ...ae(b),
299
299
  visualId: c.id
300
300
  // Link this frame to the library visual
301
301
  };
302
302
  return await r(
303
- S,
303
+ E,
304
304
  B,
305
305
  "end"
306
- ), v(!0), k(B.id), W(!1), { success: !0, fromCache: K };
306
+ ), U(!0), k(B.id), W(!1), { success: !0, fromCache: K };
307
307
  } catch (d) {
308
308
  return console.error("Error adding visual:", d), u(
309
309
  d instanceof Error ? d.message : "Failed to add visual to dashboard"
@@ -315,26 +315,26 @@ function be() {
315
315
  a.apiServiceUrl,
316
316
  s,
317
317
  o,
318
- S,
319
- v,
318
+ E,
319
+ U,
320
320
  k,
321
321
  W,
322
322
  r
323
323
  ]
324
324
  );
325
325
  return {
326
- visual: E.data,
327
- isLoading: E.isLoading,
328
- isError: E.isError,
329
- error: E.error,
326
+ visual: S.data,
327
+ isLoading: S.isLoading,
328
+ isError: S.isError,
329
+ error: S.error,
330
330
  handleEditLibraryVisual: G,
331
331
  handleAddLibraryVisual: J,
332
332
  getUpdatedFrame: pe().getUpdatedFrame,
333
- refetch: E.refetch
333
+ refetch: S.refetch
334
334
  };
335
335
  }
336
336
  export {
337
337
  fe as f,
338
- we as r,
339
- be as u
338
+ be as r,
339
+ we as u
340
340
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../chunks/index-XYIIY48z.js"),e=require("../chunks/common-types-C73-Ud1-.js");exports.Dashboard=o.Dashboard;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../chunks/index-Xdag_85e.js"),e=require("../chunks/common-types-C73-Ud1-.js");exports.Dashboard=o.Dashboard;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;
@@ -1,4 +1,4 @@
1
- import { D as o } from "../chunks/index-P5hPTTzm.js";
1
+ import { D as o } from "../chunks/index-gcA9Rs35.js";
2
2
  import { C as s, E as C } from "../chunks/common-types-4bjoIgvm.js";
3
3
  export {
4
4
  s as CONTROL_CARD_DEFAULT_VALUE,
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-XYIIY48z.js"),y=require("./chunks/common-types-C73-Ud1-.js"),U=require("./chunks/calendar-preferences-dialog-BzpQ5u4h.js"),t=require("react/jsx-runtime"),r=require("./chunks/switch-DPaKnsb8.js"),m=require("react"),z=require("./chunks/resource-management-panel-CAxXzMdi.js"),L=require("./types/index.cjs"),q=require("./chunks/use-debounced-dirty-check-XHSwAefL.js");require("react-dom");require("./chunks/index-DRlMUglg.js");const A=require("./chunks/dashboard-filter-controls-launcher-CMXpudFJ.js"),B=require("./chunks/normalize-dashboard-for-dirty-check-BXRUMVb2.js");function Q(s){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const o in s)if(o!=="default"){const l=Object.getOwnPropertyDescriptor(s,o);Object.defineProperty(a,o,l.get?l:{enumerable:!0,get:()=>s[o]})}}return a.default=s,Object.freeze(a)}const P=Q(m);function V(s){const{displayPreferences:a,cardId:o,...l}=s,i={...l,id:s.dashboardId};return t.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:t.jsxs(e.SemaphorContextProvider,{dashboardProps:i,children:[t.jsx(e.SemaphorReadyIndicator,{componentType:"visual",componentId:s.cardId}),t.jsx(e.UXProvider,{appearance:s.appearance,children:t.jsx(e.DisplayPreferencesProvider,{displayPreferences:a,children:t.jsx(e.Container,{type:"visual",cardId:o,...i,children:t.jsx(W,{cardId:o})})})})]})})}function W({cardId:s}){const a=r.useDashboardStore(i=>{var u;return(u=i.dashboard)==null?void 0:u.sheets}),{card:o,frame:l}=m.useMemo(()=>{const i=a==null?void 0:a.flatMap(d=>d.frames),u=i==null?void 0:i.flatMap(d=>d==null?void 0:d.cards),h=u==null?void 0:u.find(d=>(d==null?void 0:d.id)===s),n=i==null?void 0:i.find(d=>{var x;return(x=d==null?void 0:d.cards)==null?void 0:x.find(C=>(C==null?void 0:C.id)===s)});return{card:h,frame:n}},[a,s]);return!o||!l?t.jsx(e.FallbackVisual,{error:new Error("Card not found"),resetErrorBoundary:()=>{},customerFacingMessage:`Card not found with ID: ${s}`}):t.jsx("main",{className:"flex h-full grow flex-col",children:t.jsx(e.ErrorBoundary,{FallbackComponent:({error:i,resetErrorBoundary:u})=>t.jsx(e.FallbackVisual,{error:i,resetErrorBoundary:u,customerFacingMessage:"Error creating visual. Please try again."}),children:t.jsx(e.DashboardCard,{card:o,frame:l})})})}function H(s,a,o,l){m.useEffect(()=>{s&&!o&&a&&l(e.cloneDeep(a))},[s,o,a,l])}function $({name:s,items:a,value:o,onChange:l,isLoading:i,isError:u,refetch:h,className:n,icon:d,showNone:x=!1}){const C=P.useRef(null),[b,D]=P.useState(!1),[N,v]=P.useState("100%"),S=x?[...a||[],{id:"none",name:"None"}]:a;P.useLayoutEffect(()=>{C.current&&v(C.current.offsetWidth)},[]);function _(){var p;return i?"Loading...":u?"Error":o?(p=a==null?void 0:a.find(j=>j.id===o))==null?void 0:p.name:`Select ${s}`}function R(p,j){l(j),D(!1)}return t.jsxs(r.Popover,{open:b,onOpenChange:D,children:[t.jsx(r.PopoverTrigger,{asChild:!0,children:t.jsxs(r.Button,{ref:C,variant:"outline",role:"combobox","aria-expanded":b,className:r.cn("flex h-9 w-full justify-between",n),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[d&&t.jsx("div",{className:"mr-2",children:d}),t.jsx("span",{className:"max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:_()})]}),t.jsx(r.ChevronDown,{className:"size-4 opacity-50"})]})}),t.jsx(r.PopoverContent,{className:"w-full p-0",style:{minWidth:N},children:t.jsxs(e.Command,{children:[t.jsxs("div",{className:"flex h-9 items-center justify-between border-b pr-1",children:[t.jsx(e.CommandInput,{className:"h-9",placeholder:"Search..."}),t.jsx(e.IconButton,{className:"h-7",onClick:h,children:t.jsx(e.RefreshCw,{className:r.cn("size-3.5 opacity-50",i&&"animate-spin")})})]}),t.jsxs(e.CommandList,{children:[t.jsxs(e.CommandEmpty,{children:["No ",s==null?void 0:s.toLowerCase()," found."]}),t.jsx(e.CommandGroup,{children:S==null?void 0:S.map(p=>t.jsx(e.CommandItem,{className:"overflow-x-auto",value:p.name,onSelect:j=>R(j,p.id),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(r.Check,{className:r.cn("size-4",o===p.id?"opacity-100":"opacity-0")}),t.jsx("div",{title:p.name,children:p.name})]})},p.id))})]})]})})]})}function G({triggerButtonClassName:s,variant:a="ghost"}){const[o,l]=m.useState(!1),i=r.useDashboardStore(h=>{var n;return(n=h.dashboard)==null?void 0:n.id}),u=r.useDashboardStore(h=>{var n;return(n=h.dashboard)==null?void 0:n.title});return i?t.jsxs(t.Fragment,{children:[t.jsx(e.IconButton,{tooltip:"Schedule Dashboard",className:r.cn("h-7 p-2",s),buttonProps:{variant:a},onClick:()=>l(!0),children:t.jsx(e.Clock,{className:"size-4"})}),t.jsx(e.EmailScheduleDialog,{open:o,onOpenChange:l,dashboardId:i,dashboardName:u})]}):null}function K(s){const{authToken:a,tokenProps:o}=e.useSemaphorContext();return e.useMutation({mutationFn:async l=>e.backtestAlert(o.apiServiceUrl,a.accessToken,s,l)})}function Y(s,a){m.useEffect(()=>(s&&a&&(window.__SEMAPHOR_PRINT_STATE__={...a}),()=>{s&&window.__SEMAPHOR_PRINT_STATE__&&delete window.__SEMAPHOR_PRINT_STATE__}),[s,a])}function I(s){if(!s)return"--";const a=new Date(s);return Number.isNaN(a.getTime())?"--":a.toLocaleString()}function X(s){var a;return((a=s.alertState)==null?void 0:a.currentState)==="FIRING"?"Signal surfaced":s.status==="ACTIVE"?"Watching":s.status==="PAUSED"?"Paused":s.status}function J({alertId:s,onBack:a}){var p,j,w,k;const{authToken:o,tokenProps:l}=e.useSemaphorContext(),{data:i,isLoading:u,refetch:h}=e.useAlertDetail(s),n=(i==null?void 0:i.alert)??null,[d,x]=m.useState([]),[C,b]=m.useState([]),[D,N]=m.useState(null),v=m.useCallback(async()=>{var g;const c=l==null?void 0:l.apiServiceUrl,f=o==null?void 0:o.accessToken;if(!c||!f||!s)return null;try{const T=await fetch(`${c}/v1/alerts/${s}/runs?limit=20`,{headers:{Authorization:`Bearer ${f}`}});if(T.ok){const F=await T.json(),E=Array.isArray(F.runs)?F.runs:[],M=D&&E.some(O=>O.id===D)?D:((g=E[0])==null?void 0:g.id)??null;return b(E),N(M),M}b([]),N(null)}catch{return b([]),N(null),null}return null},[s,o,D,l]),S=m.useCallback(async c=>{const f=l==null?void 0:l.apiServiceUrl,g=o==null?void 0:o.accessToken,T=c??D;if(!f||!g||!s||!T){x([]);return}try{const F=await fetch(`${f}/v1/alerts/${s}/runs/${T}/deliveries`,{headers:{Authorization:`Bearer ${g}`}});if(F.ok){const E=await F.json();x(Array.isArray(E.attempts)?E.attempts:[])}else x([])}catch{x([])}},[s,o,D,l]),_=m.useCallback(async()=>{await h();const c=await v();await S(c)},[S,v,h]);m.useEffect(()=>{v().catch(()=>{})},[v]),m.useEffect(()=>{S().catch(()=>{})},[S]);const R=m.useMemo(()=>{const c={};for(const f of d)c[f.channel]||(c[f.channel]=[]),c[f.channel].push(f);return c},[d]);return u?t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading signal detail..."}):n?t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[a&&t.jsx(r.Button,{variant:"outline",size:"sm",onClick:a,children:"Back"}),t.jsx("h2",{className:"text-lg font-semibold",children:n.name}),t.jsx(e.Badge,{variant:n.status==="ACTIVE"?"default":"secondary",children:X(n)}),((p=n.alertState)==null?void 0:p.currentState)&&t.jsx(e.Badge,{variant:n.alertState.currentState==="FIRING"?"destructive":"outline",children:n.alertState.currentState==="FIRING"?"Signal surfaced":"Stable"})]}),t.jsx(r.Button,{variant:"outline",size:"sm",onClick:()=>void _(),children:"Refresh"})]}),n.description&&t.jsx("p",{className:"text-sm text-muted-foreground",children:n.description}),t.jsxs("div",{className:"rounded-md border bg-muted/30 p-4 text-sm",children:[t.jsx("p",{className:"font-medium",children:"What changed"}),t.jsx("p",{className:"mt-1 text-muted-foreground",children:"Review the latest signal activity, then investigate the underlying dashboard context if you need more detail."})]}),t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-2",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Signal Watch"}),t.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Watching for:"})," ",e.formatSignalCondition(n.jobConfig.operator,n.jobConfig.threshold)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Severity:"})," ",n.jobConfig.severity]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Evaluated:"})," ",I((j=n.alertState)==null?void 0:j.lastEvaluatedAt)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Surfaced:"})," ",I((w=n.alertState)==null?void 0:w.lastTriggeredAt)]})]})]}),((k=n.deliveryConfig)==null?void 0:k.channels)&&n.deliveryConfig.channels.length>0&&t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-2",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Where It Surfaces"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:n.deliveryConfig.channels.map(c=>t.jsx(e.Badge,{variant:"outline",children:c},c))})]}),C.length>0&&t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-3",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Recent Delivery Activity"}),C.length>1&&t.jsx("div",{className:"flex flex-wrap gap-2",children:C.map(c=>t.jsx(r.Button,{variant:c.id===D?"default":"outline",size:"sm",onClick:()=>N(c.id),children:I(c.scheduledFor)},c.id))}),Object.keys(R).length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:"No delivery attempts were recorded for this run."}):Object.entries(R).map(([c,f])=>t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"flex items-center gap-2",children:t.jsx(e.Badge,{variant:"secondary",className:"text-xs",children:c})}),t.jsx("div",{className:"overflow-hidden rounded border",children:t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{className:"bg-muted/40",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Recipient"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Status"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Time"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Error"})]})}),t.jsx("tbody",{children:f.map(g=>t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-2 py-1",children:g.recipient}),t.jsx("td",{className:"px-2 py-1",children:t.jsx(e.Badge,{variant:g.status==="SENT"?"default":"destructive",className:"text-[10px]",children:g.status})}),t.jsx("td",{className:"px-2 py-1",children:I(g.createdAt)}),t.jsx("td",{className:"px-2 py-1 text-muted-foreground",children:g.error||"--"})]},g.id))})]})})]},c))]})]}):t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Signal not found."})}function Z(){var u,h;const{quotasQuery:s,usageQuery:a}=e.useAlertQuotas(),o=((u=s.data)==null?void 0:u.quotas)||[],l=((h=a.data)==null?void 0:h.usage)||[],i=new Map(l.map(n=>[n.tenantId||"org",n]));return t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h2",{className:"text-xl font-semibold",children:"Alert Quotas"}),t.jsx(r.Button,{variant:"outline",size:"sm",onClick:()=>{s.refetch(),a.refetch()},children:"Refresh"})]}),s.isLoading||a.isLoading?t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading quota usage..."}):null,t.jsx("div",{className:"overflow-hidden rounded-lg border",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"bg-muted/40",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Tenant"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Active Alerts"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Max Active"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Min Cadence"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Max Context Sources"})]})}),t.jsx("tbody",{children:o.map(n=>{const d=n.tenantId||"org",x=i.get(d);return t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-3 py-2",children:d}),t.jsx("td",{className:"px-3 py-2",children:(x==null?void 0:x.activeAlerts)??0}),t.jsx("td",{className:"px-3 py-2",children:n.policy.maxActiveAlerts}),t.jsxs("td",{className:"px-3 py-2",children:[n.policy.minCadenceMinutes," min"]}),t.jsx("td",{className:"px-3 py-2",children:n.policy.maxContextSources})]},d)})})]})})]})}exports.AlertManagementPage=e.AlertManagementPage;exports.AlertWizardDialog=e.AlertWizardDialog;exports.AlertsApiError=e.AlertsApiError;exports.CardAlertIndicator=e.CardAlertIndicator;exports.CardSummary=e.CardSummary;exports.Dashboard=e.Dashboard;exports.DashboardExportDialog=e.DashboardExportDialog;exports.DashboardWC=e.DashboardWC;exports.EmailScheduleDialog=e.EmailScheduleDialog;exports.ExportError=e.ExportError;exports.ResourceType=e.ResourceType;exports.SemaphorContextProvider=e.SemaphorContextProvider;exports.SemaphorDataProvider=e.SemaphorQueryClient;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.ShareDialog=e.ShareDialog;exports.SummaryCard=e.SummaryCard;exports.Surfboard=e.DashboardPlus;exports.backtestAlert=e.backtestAlert;exports.cancelExport=e.cancelExport;exports.cloneDeep=e.cloneDeep;exports.createAlert=e.createAlert;exports.createExport=e.createExport;exports.deleteAlert=e.deleteAlert;exports.downloadDocumentPdf=e.downloadDocumentPdf;exports.downloadPdf=e.downloadPdf;exports.formatFileSize=e.formatFileSize;exports.getAlert=e.getAlert;exports.getAlertContextSources=e.getAlertContextSources;exports.getAlertHistory=e.getAlertHistory;exports.getAlertQuotaUsage=e.getAlertQuotaUsage;exports.getAlertRunDeliveries=e.getAlertRunDeliveries;exports.getAlertRunSteps=e.getAlertRunSteps;exports.getAlertRuns=e.getAlertRuns;exports.getAlertState=e.getAlertState;exports.getDownloadUrl=e.getDownloadUrl;exports.getExportStatus=e.getExportStatus;exports.getExports=e.getExports;exports.isExportComplete=e.isExportComplete;exports.isExportInProgress=e.isExportInProgress;exports.listAlertQuotas=e.listAlertQuotas;exports.listAlerts=e.listAlerts;exports.previewAlertDeliverable=e.previewAlertDeliverable;exports.triggerAlertNow=e.triggerAlertNow;exports.updateAlert=e.updateAlert;exports.updateAlertContextSources=e.updateAlertContextSources;exports.updateAlertQuota=e.updateAlertQuota;exports.useActiveExports=e.useActiveExports;exports.useAddNewFrame=e.useAddNewFrame;exports.useAlertActions=e.useAlertActions;exports.useAlertDeliveries=e.useAlertDeliveries;exports.useAlertDetail=e.useAlertDetail;exports.useAlertDraft=e.useAlertDraft;exports.useAlertFilters=e.useAlertFilters;exports.useAlertHistory=e.useAlertHistory;exports.useAlertQuotas=e.useAlertQuotas;exports.useAlertRuns=e.useAlertRuns;exports.useAlertState=e.useAlertState;exports.useAlertStore=e.useAlertStore;exports.useAlertWizard=e.useAlertWizard;exports.useAlerts=e.useAlerts;exports.useAlertsBootstrap=e.useAlertsBootstrap;exports.useAlertsById=e.useAlertsById;exports.useAlertsForCard=e.useAlertsForCard;exports.useCard=e.useCard;exports.useCardAlertMap=e.useCardAlertMap;exports.useCardSummary=e.useCardSummary;exports.useDashboardById=e.useDashboardById;exports.useDashboardQuery=e.useDashboardQuery;exports.useDashboardSummary=e.useDashboardSummary;exports.useDataColumns=e.useDataColumns;exports.useDateFilterHook=e.useDateFilterHook;exports.useEditorAside=e.useEditorAside;exports.useExportActions=e.useExportActions;exports.useExportStore=e.useExportStore;exports.useInProgressExportsCount=e.useInProgressExportsCount;exports.useManagementStore=e.useManagementStore;exports.useResourceManagement=e.useResourceManagement;exports.useSelectedAlertId=e.useSelectedAlertId;exports.useTextFilterHook=e.useTextFilterHook;exports.CALCULATED_FIELD_ENTITY_MARKER=y.CALCULATED_FIELD_ENTITY_MARKER;exports.CONTROL_CARD_DEFAULT_VALUE=y.CONTROL_CARD_DEFAULT_VALUE;exports.DATE_FORMAT_VALUES=y.DATE_FORMAT_VALUES;exports.EMPTY_SELECTION=y.EMPTY_SELECTION;exports.PivotMarkerEnum=y.PivotMarkerEnum;exports.getFieldRuntimeColumnName=y.getFieldRuntimeColumnName;exports.hasCalculatedFieldMarker=y.hasCalculatedFieldMarker;exports.hasCalculatedFormulaInputs=y.hasCalculatedFormulaInputs;exports.isCalculatedDimension=y.isCalculatedDimension;exports.isCalculatedField=y.isCalculatedField;exports.isCalculatedMetric=y.isCalculatedMetric;exports.CalendarPreferencesDialog=U.CalendarPreferencesDialog;exports.createEmptyKpiConfig=r.createEmptyKpiConfig;exports.createSqlGenConfig=r.createSqlGenConfig;exports.emitDashboardLoad=r.emitDashboardLoad;exports.emitDashboardUnload=r.emitDashboardUnload;exports.fmt=r.fmt;exports.getColumnDataType=r.getColumnDataType;exports.getFilterValueType=r.getFilterValueType;exports.getFormattedTableNameForQuery=r.getFormattedTableNameForQuery;exports.getQualifiedTableName=r.getQualifiedTableName;exports.getSql=r.getSql;exports.invalidateToken=r.invalidateToken;exports.isBooleanDataType=r.isBooleanDataType;exports.isColumnInSqlGen=r.isColumnInSqlGen;exports.isDateDataType=r.isDateDataType;exports.isNumberDataType=r.isNumberDataType;exports.isTextDataType=r.isTextDataType;exports.resolveDataType=r.resolveDataType;exports.resolveDatamodelName=r.resolveDatamodelName;exports.useCurrentActiveCard=r.useCurrentActiveCard;exports.useCurrentCardConfig=r.useCurrentCardConfig;exports.useCurrentSheetActiveCards=r.useCurrentSheetActiveCards;exports.useDashboardActions=r.useDashboardActions;exports.useDashboardStore=r.useDashboardStore;exports.useEditorActions=r.useEditorActions;exports.useEditorStore=r.useEditorStore;exports.ResourceManagementPanel=z.ResourceManagementPanel;exports.DEFAULT_CALENDAR_CONTEXT=L.DEFAULT_CALENDAR_CONTEXT;exports.DEFAULT_SEMANTIC_DOMAIN_ACCESS=L.DEFAULT_SEMANTIC_DOMAIN_ACCESS;exports.useDebouncedDirtyCheck=q.useDebouncedDirtyCheck;exports.AdvancedModeToggle=A.AdvancedModeToggle;exports.DashboardControlsSettings=A.DashboardControlsSettings;exports.DashboardFilterControlsButton=A.DashboardFilterControlsButton;exports.DashboardFilterControlsLauncher=A.DashboardFilterControlsLauncher;exports.DocumentControlsSettings=A.DocumentControlsSettings;exports.ExportNotificationItem=A.ExportNotificationItem;exports.ExportNotificationList=A.ExportNotificationList;exports.NotificationBell=A.NotificationBell;exports.UnsavedChangesAlert=A.UnsavedChangesAlert;exports.VisualEditingControls=A.VisualEditingControls;exports.useExportPolling=A.useExportPolling;exports.useExportRecovery=A.useExportRecovery;exports.normalizeDashboardForDirtyCheck=B.normalizeDashboardForDirtyCheck;exports.serializeDashboardForDirtyCheck=B.serializeDashboardForDirtyCheck;exports.AlertDetailPageEmbedded=J;exports.Combobox=$;exports.ScheduleDashboard=G;exports.TenantQuotaPage=Z;exports.Visual=V;exports.useAlertBacktest=K;exports.useExposePrintState=Y;exports.usePristineSnapshotInitializer=H;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-Xdag_85e.js"),d=require("./chunks/common-types-C73-Ud1-.js"),P=require("./chunks/calendar-preferences-dialog-BDdxi7Xm.js"),t=require("react/jsx-runtime"),a=require("./chunks/switch-DPaKnsb8.js"),h=require("react"),N=require("./chunks/resource-management-panel-BduJanWW.js"),y=require("./types/index.cjs"),_=require("./chunks/use-debounced-dirty-check-XHSwAefL.js");require("react-dom");require("./chunks/index-DRlMUglg.js");const r=require("./chunks/dashboard-briefing-launcher-CVxLt10p.js"),S=require("./chunks/normalize-dashboard-for-dirty-check-BXRUMVb2.js");function R(o){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const n in o)if(n!=="default"){const l=Object.getOwnPropertyDescriptor(o,n);Object.defineProperty(i,n,l.get?l:{enumerable:!0,get:()=>o[n]})}}return i.default=o,Object.freeze(i)}const C=R(h);function j(o){const{displayPreferences:i,cardId:n,...l}=o,s={...l,id:o.dashboardId};return t.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:t.jsxs(e.SemaphorContextProvider,{dashboardProps:s,children:[t.jsx(e.SemaphorReadyIndicator,{componentType:"visual",componentId:o.cardId}),t.jsx(e.UXProvider,{appearance:o.appearance,children:t.jsx(e.DisplayPreferencesProvider,{displayPreferences:i,children:t.jsx(e.Container,{type:"visual",cardId:n,...s,children:t.jsx(w,{cardId:n})})})})]})})}function w({cardId:o}){const i=a.useDashboardStore(s=>{var c;return(c=s.dashboard)==null?void 0:c.sheets}),{card:n,frame:l}=h.useMemo(()=>{const s=i==null?void 0:i.flatMap(u=>u.frames),c=s==null?void 0:s.flatMap(u=>u==null?void 0:u.cards),D=c==null?void 0:c.find(u=>(u==null?void 0:u.id)===o),E=s==null?void 0:s.find(u=>{var p;return(p=u==null?void 0:u.cards)==null?void 0:p.find(g=>(g==null?void 0:g.id)===o)});return{card:D,frame:E}},[i,o]);return!n||!l?t.jsx(e.FallbackVisual,{error:new Error("Card not found"),resetErrorBoundary:()=>{},customerFacingMessage:`Card not found with ID: ${o}`}):t.jsx("main",{className:"flex h-full grow flex-col",children:t.jsx(e.ErrorBoundary,{FallbackComponent:({error:s,resetErrorBoundary:c})=>t.jsx(e.FallbackVisual,{error:s,resetErrorBoundary:c,customerFacingMessage:"Error creating visual. Please try again."}),children:t.jsx(e.DashboardCard,{card:n,frame:l})})})}function M(o,i,n,l){h.useEffect(()=>{o&&!n&&i&&l(e.cloneDeep(i))},[o,n,i,l])}function L({name:o,items:i,value:n,onChange:l,isLoading:s,isError:c,refetch:D,className:E,icon:u,showNone:p=!1}){const g=C.useRef(null),[b,T]=C.useState(!1),[A,B]=C.useState("100%"),x=p?[...i||[],{id:"none",name:"None"}]:i;C.useLayoutEffect(()=>{g.current&&B(g.current.offsetWidth)},[]);function F(){var f;return s?"Loading...":c?"Error":n?(f=i==null?void 0:i.find(m=>m.id===n))==null?void 0:f.name:`Select ${o}`}function v(f,m){l(m),T(!1)}return t.jsxs(a.Popover,{open:b,onOpenChange:T,children:[t.jsx(a.PopoverTrigger,{asChild:!0,children:t.jsxs(a.Button,{ref:g,variant:"outline",role:"combobox","aria-expanded":b,className:a.cn("flex h-9 w-full justify-between",E),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[u&&t.jsx("div",{className:"mr-2",children:u}),t.jsx("span",{className:"max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:F()})]}),t.jsx(a.ChevronDown,{className:"size-4 opacity-50"})]})}),t.jsx(a.PopoverContent,{className:"w-full p-0",style:{minWidth:A},children:t.jsxs(e.Command,{children:[t.jsxs("div",{className:"flex h-9 items-center justify-between border-b pr-1",children:[t.jsx(e.CommandInput,{className:"h-9",placeholder:"Search..."}),t.jsx(e.IconButton,{className:"h-7",onClick:D,children:t.jsx(e.RefreshCw,{className:a.cn("size-3.5 opacity-50",s&&"animate-spin")})})]}),t.jsxs(e.CommandList,{children:[t.jsxs(e.CommandEmpty,{children:["No ",o==null?void 0:o.toLowerCase()," found."]}),t.jsx(e.CommandGroup,{children:x==null?void 0:x.map(f=>t.jsx(e.CommandItem,{className:"overflow-x-auto",value:f.name,onSelect:m=>v(m,f.id),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(a.Check,{className:a.cn("size-4",n===f.id?"opacity-100":"opacity-0")}),t.jsx("div",{title:f.name,children:f.name})]})},f.id))})]})]})})]})}function I(o,i){h.useEffect(()=>(o&&i&&(window.__SEMAPHOR_PRINT_STATE__={...i}),()=>{o&&window.__SEMAPHOR_PRINT_STATE__&&delete window.__SEMAPHOR_PRINT_STATE__}),[o,i])}exports.CardSummary=e.CardSummary;exports.Dashboard=e.Dashboard;exports.DashboardExportDialog=e.DashboardExportDialog;exports.DashboardWC=e.DashboardWC;exports.ExportError=e.ExportError;exports.ResourceType=e.ResourceType;exports.SemaphorContextProvider=e.SemaphorContextProvider;exports.SemaphorDataProvider=e.SemaphorQueryClient;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.ShareDialog=e.ShareDialog;exports.SummaryCard=e.SummaryCard;exports.Surfboard=e.DashboardPlus;exports.cancelExport=e.cancelExport;exports.cloneDeep=e.cloneDeep;exports.createExport=e.createExport;exports.downloadDocumentPdf=e.downloadDocumentPdf;exports.downloadPdf=e.downloadPdf;exports.formatFileSize=e.formatFileSize;exports.getDownloadUrl=e.getDownloadUrl;exports.getExportStatus=e.getExportStatus;exports.getExports=e.getExports;exports.isExportComplete=e.isExportComplete;exports.isExportInProgress=e.isExportInProgress;exports.useActiveExports=e.useActiveExports;exports.useAddNewFrame=e.useAddNewFrame;exports.useCard=e.useCard;exports.useCardSummary=e.useCardSummary;exports.useDashboardById=e.useDashboardById;exports.useDashboardQuery=e.useDashboardQuery;exports.useDashboardSummary=e.useDashboardSummary;exports.useDataColumns=e.useDataColumns;exports.useDateFilterHook=e.useDateFilterHook;exports.useEditorAside=e.useEditorAside;exports.useExportActions=e.useExportActions;exports.useExportStore=e.useExportStore;exports.useInProgressExportsCount=e.useInProgressExportsCount;exports.useManagementStore=e.useManagementStore;exports.useResourceManagement=e.useResourceManagement;exports.useTextFilterHook=e.useTextFilterHook;exports.CALCULATED_FIELD_ENTITY_MARKER=d.CALCULATED_FIELD_ENTITY_MARKER;exports.CONTROL_CARD_DEFAULT_VALUE=d.CONTROL_CARD_DEFAULT_VALUE;exports.DATE_FORMAT_VALUES=d.DATE_FORMAT_VALUES;exports.EMPTY_SELECTION=d.EMPTY_SELECTION;exports.PivotMarkerEnum=d.PivotMarkerEnum;exports.getFieldRuntimeColumnName=d.getFieldRuntimeColumnName;exports.hasCalculatedFieldMarker=d.hasCalculatedFieldMarker;exports.hasCalculatedFormulaInputs=d.hasCalculatedFormulaInputs;exports.isCalculatedDimension=d.isCalculatedDimension;exports.isCalculatedField=d.isCalculatedField;exports.isCalculatedMetric=d.isCalculatedMetric;exports.CalendarPreferencesDialog=P.CalendarPreferencesDialog;exports.createEmptyKpiConfig=a.createEmptyKpiConfig;exports.createSqlGenConfig=a.createSqlGenConfig;exports.emitDashboardLoad=a.emitDashboardLoad;exports.emitDashboardUnload=a.emitDashboardUnload;exports.fmt=a.fmt;exports.getColumnDataType=a.getColumnDataType;exports.getFilterValueType=a.getFilterValueType;exports.getFormattedTableNameForQuery=a.getFormattedTableNameForQuery;exports.getQualifiedTableName=a.getQualifiedTableName;exports.getSql=a.getSql;exports.invalidateToken=a.invalidateToken;exports.isBooleanDataType=a.isBooleanDataType;exports.isColumnInSqlGen=a.isColumnInSqlGen;exports.isDateDataType=a.isDateDataType;exports.isNumberDataType=a.isNumberDataType;exports.isTextDataType=a.isTextDataType;exports.resolveDataType=a.resolveDataType;exports.resolveDatamodelName=a.resolveDatamodelName;exports.useCurrentActiveCard=a.useCurrentActiveCard;exports.useCurrentCardConfig=a.useCurrentCardConfig;exports.useCurrentSheetActiveCards=a.useCurrentSheetActiveCards;exports.useDashboardActions=a.useDashboardActions;exports.useDashboardStore=a.useDashboardStore;exports.useEditorActions=a.useEditorActions;exports.useEditorStore=a.useEditorStore;exports.ResourceManagementPanel=N.ResourceManagementPanel;exports.DEFAULT_CALENDAR_CONTEXT=y.DEFAULT_CALENDAR_CONTEXT;exports.DEFAULT_SEMANTIC_DOMAIN_ACCESS=y.DEFAULT_SEMANTIC_DOMAIN_ACCESS;exports.useDebouncedDirtyCheck=_.useDebouncedDirtyCheck;exports.AdvancedModeToggle=r.AdvancedModeToggle;exports.BriefingAuthor=r.BriefingAuthor;exports.BriefingsApiError=r.BriefingsApiError;exports.DashboardBriefingLauncher=r.DashboardBriefingLauncher;exports.DashboardControlsSettings=r.DashboardControlsSettings;exports.DashboardFilterControlsButton=r.DashboardFilterControlsButton;exports.DashboardFilterControlsLauncher=r.DashboardFilterControlsLauncher;exports.DocumentControlsSettings=r.DocumentControlsSettings;exports.ExportNotificationItem=r.ExportNotificationItem;exports.ExportNotificationList=r.ExportNotificationList;exports.NotificationBell=r.NotificationBell;exports.UnsavedChangesAlert=r.UnsavedChangesAlert;exports.VisualEditingControls=r.VisualEditingControls;exports.WatchDashboardButton=r.WatchDashboardButton;exports.applyBriefingFormPatch=r.applyBriefingFormPatch;exports.briefingFormDraftToCreateRequest=r.briefingFormDraftToCreateRequest;exports.briefingFormDraftToUpdateRequest=r.briefingFormDraftToUpdateRequest;exports.briefingToFormDraft=r.briefingToFormDraft;exports.cancelBriefingRun=r.cancelBriefingRun;exports.createBriefing=r.createBriefing;exports.createBriefingFormDraft=r.createBriefingFormDraft;exports.deleteBriefing=r.deleteBriefing;exports.deleteBriefingRun=r.deleteBriefingRun;exports.getBriefing=r.getBriefing;exports.getBriefingArtifact=r.getBriefingArtifact;exports.getBriefingEvidence=r.getBriefingEvidence;exports.getBriefingPreviewRun=r.getBriefingPreviewRun;exports.getBriefingRun=r.getBriefingRun;exports.listBriefingRuns=r.listBriefingRuns;exports.listBriefingTenantSummaries=r.listBriefingTenantSummaries;exports.listBriefings=r.listBriefings;exports.pauseBriefing=r.pauseBriefing;exports.previewBriefingPlan=r.previewBriefingPlan;exports.resumeBriefing=r.resumeBriefing;exports.runBriefingNow=r.runBriefingNow;exports.runBriefingPreview=r.runBriefingPreview;exports.updateBriefing=r.updateBriefing;exports.useExportPolling=r.useExportPolling;exports.useExportRecovery=r.useExportRecovery;exports.validateBriefingFormDraft=r.validateBriefingFormDraft;exports.normalizeDashboardForDirtyCheck=S.normalizeDashboardForDirtyCheck;exports.serializeDashboardForDirtyCheck=S.serializeDashboardForDirtyCheck;exports.Combobox=L;exports.Visual=j;exports.useExposePrintState=I;exports.usePristineSnapshotInitializer=M;