react-semaphor 0.1.301 → 0.1.303

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 (66) hide show
  1. package/dist/appearance/index.cjs +1 -0
  2. package/dist/appearance/index.js +9 -0
  3. package/dist/brand-studio/index.cjs +21 -0
  4. package/dist/brand-studio/index.js +1461 -0
  5. package/dist/chunks/dashboard-controls-BCJZOzrL.js +2226 -0
  6. package/dist/chunks/dashboard-controls-CVFoOPti.js +47 -0
  7. package/dist/chunks/dashboard-filter-controls-button-C-e7230k.js +11 -0
  8. package/dist/chunks/{dashboard-filter-controls-button-DjALRkvg.js → dashboard-filter-controls-button-Cfbac4Jw.js} +205 -216
  9. package/dist/chunks/dashboard-json-BM5ywMgp.js +1 -0
  10. package/dist/chunks/{dashboard-json-D-zIG46N.js → dashboard-json-BzvLPhGM.js} +14 -12
  11. package/dist/chunks/dashboard-summary-settings-dialog-BdxKl1UF.js +1 -0
  12. package/dist/chunks/{dashboard-summary-settings-dialog-D-F1eEJI.js → dashboard-summary-settings-dialog-ChK3344r.js} +64 -63
  13. package/dist/chunks/date-formatter-D9Bvw5Qk.js +1 -0
  14. package/dist/chunks/date-formatter-DyIOb6uC.js +333 -0
  15. package/dist/chunks/{edit-dashboard-visual-BjflrL8w.js → edit-dashboard-visual-D725CWD5.js} +6690 -6679
  16. package/dist/chunks/edit-dashboard-visual-nNaZ2IK1.js +183 -0
  17. package/dist/chunks/index-BWjB_9uz.js +1356 -0
  18. package/dist/chunks/index-CJdxSyQq.js +2578 -0
  19. package/dist/chunks/{index-DDA12yqV.js → index-CYWgnME0.js} +48994 -66425
  20. package/dist/chunks/index-D7KJindZ.js +1 -0
  21. package/dist/chunks/index-DFOb_6HB.js +1657 -0
  22. package/dist/chunks/index-DRlMUglg.js +4 -0
  23. package/dist/chunks/palette-B9DJXMGo.js +11 -0
  24. package/dist/chunks/palette-DGOzbtsn.js +43 -0
  25. package/dist/chunks/{resource-management-panel-B2558XA1.js → resource-management-panel-CE0-NcLL.js} +116 -115
  26. package/dist/chunks/resource-management-panel-mJmc5dMT.js +6 -0
  27. package/dist/chunks/rotate-ccw-Bs7YJn10.js +6 -0
  28. package/dist/chunks/rotate-ccw-YsjQwpKm.js +14 -0
  29. package/dist/chunks/save-Bj1y1rug.js +6 -0
  30. package/dist/chunks/save-CUrexoNl.js +21 -0
  31. package/dist/chunks/switch-CiEX68py.js +163 -0
  32. package/dist/chunks/switch-oojO-gal.js +19730 -0
  33. package/dist/chunks/{use-create-flow-overlay-state-BUw_JtLs.js → use-create-flow-overlay-state-BHDKxe7I.js} +396 -412
  34. package/dist/chunks/use-create-flow-overlay-state-D2I2wNey.js +16 -0
  35. package/dist/chunks/{use-visual-utils-C45OxsOf.js → use-visual-utils-CjFzlR0P.js} +54 -53
  36. package/dist/chunks/use-visual-utils-DYDXMl5v.js +1 -0
  37. package/dist/dashboard/index.cjs +1 -1
  38. package/dist/dashboard/index.js +1 -1
  39. package/dist/format-utils/index.cjs +1 -1
  40. package/dist/format-utils/index.js +2 -2
  41. package/dist/index.cjs +1 -1
  42. package/dist/index.js +210 -207
  43. package/dist/style.css +1 -1
  44. package/dist/surfboard/index.cjs +1 -1
  45. package/dist/surfboard/index.js +2 -2
  46. package/dist/types/appearance.d.ts +176 -0
  47. package/dist/types/brand-studio.d.ts +245 -0
  48. package/dist/types/dashboard.d.ts +134 -0
  49. package/dist/types/main.d.ts +142 -1
  50. package/dist/types/surfboard.d.ts +134 -0
  51. package/dist/types/types.d.ts +139 -0
  52. package/package.json +13 -1
  53. package/dist/chunks/braces-Bhqo4iW1.js +0 -23
  54. package/dist/chunks/braces-BwK7fWd_.js +0 -6
  55. package/dist/chunks/dashboard-controls-BIRiWCUK.js +0 -47
  56. package/dist/chunks/dashboard-controls-DIlnYo96.js +0 -2219
  57. package/dist/chunks/dashboard-filter-controls-button-CK1-mKQh.js +0 -11
  58. package/dist/chunks/dashboard-json-DK4mQ1gS.js +0 -1
  59. package/dist/chunks/dashboard-summary-settings-dialog-DSxNqxFI.js +0 -1
  60. package/dist/chunks/date-formatter-CqXdM6JO.js +0 -1
  61. package/dist/chunks/date-formatter-vkCj9Ct-.js +0 -1982
  62. package/dist/chunks/edit-dashboard-visual-DCsrtJr_.js +0 -193
  63. package/dist/chunks/index-8GnvL1_L.js +0 -1523
  64. package/dist/chunks/resource-management-panel-CKp4_aem.js +0 -6
  65. package/dist/chunks/use-create-flow-overlay-state-CWcCdPbC.js +0 -21
  66. package/dist/chunks/use-visual-utils-DyaThRzf.js +0 -1
@@ -0,0 +1,16 @@
1
+ "use strict";const l=require("./switch-CiEX68py.js"),e=require("react/jsx-runtime"),s=require("./index-BWjB_9uz.js"),C=require("react"),re=require("./use-visual-utils-DYDXMl5v.js"),he=require("./save-Bj1y1rug.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=l.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=l.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=l.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"}]]);function le(){var h,k;const n=l.useEditorStore(y=>y.card),a=l.useEditorStore(y=>y.frame),d=C.useMemo(()=>s.findCustomVisualConfigCard(a,n),[a,n]),{manifest:c}=s.useCustomVisual(((h=d==null?void 0:d.customCardPreferences)==null?void 0:h.url)||""),f=C.useMemo(()=>{var y;return(y=c==null?void 0:c.visuals)==null?void 0:y.find(m=>{var j;return m.name===((j=d==null?void 0:d.customCardPreferences)==null?void 0:j.componentName)})},[c,(k=d==null?void 0:d.customCardPreferences)==null?void 0:k.componentName]),p=s.resolveMultiInputType(d,f),g=C.useMemo(()=>s.getCustomVisualInputCards({frame:a,configCard:d,isMultiInputVisual:p==="multiple"}),[a,d,p]),v=C.useMemo(()=>{const y=g.findIndex(m=>(m==null?void 0:m.id)===n.id);return y<0?-1:s.getSlotIndexForCard(n,y)},[g,n]);return C.useMemo(()=>!d||p!=="multiple"||v<0?n.type:s.getEffectiveCardTypeForSlot(n,v,f==null?void 0:f.slots)??n.type,[d,p,v,n,f==null?void 0:f.slots])}function De({type:n,isLinked:a,className:d,showLabel:c=!1,showLocal:f=!1}){const p=l.useDashboardStore(N=>N.selectedFrameId),g=s.useManagementStore(N=>N.selectedVisual),v=l.useEditorStore(N=>N.frame);let h;if(n)h=n;else if(a!==void 0)h=a?"linked":"library";else if(!!!(v!=null&&v.visualId||g!=null&&g.id)&&p)h="local";else if(g&&!p)h="library";else if(v!=null&&v.visualId&&p)h="linked";else if(g!=null&&g.id&&p)h="library";else return null;if(h==="local"&&!f)return null;const k={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"},y={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"},j={local:"fill-slate-50 dark:fill-slate-900",linked:"fill-purple-50 dark:fill-purple-950",library:"fill-blue-50 dark:fill-blue-950"},V={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"})},S={local:"Local",linked:"Linked",library:"Library"};return e.jsx(l.TooltipProvider,{children:e.jsxs(l.Tooltip,{delayDuration:300,children:[e.jsx(l.TooltipTrigger,{asChild:!0,children:e.jsxs(s.Badge,{variant:"outline",className:l.cn("cursor-help select-none transition-all",k[h],d),children:[V[h],c&&e.jsx("span",{className:"ml-1 text-xs font-medium leading-none",children:S[h]})]})}),e.jsxs(l.TooltipContent,{side:"bottom",className:l.cn("max-w-xs",m[h]),children:[e.jsx(l.TooltipArrow,{className:j[h]}),e.jsx("p",{children:y[h]})]})]})})}function Ee(n,a){return{...n,sql:"",python:"",config:void 0,customCfg:"",preferences:{},interactionConfig:void 0,linkedInteractionTargetOverrides:void 0,dynamicCardPreferences:void 0,customCardPreferences:a?n.customCardPreferences:void 0,visualizationMode:"builtin",type:a?n.type:"bar"}}function ae(n){const a=l.getDynamicFrameSaveIssue(n);return a?(s.ue.error(a),!1):!0}function we({className:n,variant:a="outline"}){const d=l.useEditorStore(p=>p.onSave),{getUpdatedFrame:c}=re.useVisualUtils();function f(){const p=c();ae(p)&&(d==null||d(p))}return e.jsxs(l.Button,{onClick:f,className:n,size:"xs",variant:a,children:[e.jsx(l.Check,{className:"h-3.5 w-3.5"}),"Accept"]})}function Ve({className:n,variant:a="default"}){const d=s.useQueryClient(),[c,f]=C.useState(!1),p=l.useDashboardStore(j=>j.actions.setIsDashboardPanelOpen),{setIsVisualEditing:g}=l.useDashboardActions(),{getUpdatedFrame:v}=re.useVisualUtils(),h=s.useSelectedVisual(),k=l.useEditorStore(j=>j.frame),y=s.useUpdateVisualMutation(),m=()=>{const j=v();if(!ae(j))return;const V=(k==null?void 0:k.visualId)||(h==null?void 0:h.id);if(!V){s.ue.error("No visual to save");return}f(!0),y.mutate({visualId:V,data:{frameObject:j}},{onSuccess:()=>{f(!1),p(!0),s.ue.success("Visual updated successfully"),d.invalidateQueries({queryKey:["resource-by-id","visual",V],exact:!0})},onError:()=>{f(!1),s.ue.error("Failed to update visual")}})};return e.jsx(l.Button,{onClick:m,className:n,size:"xs",variant:a,children:c?e.jsxs(e.Fragment,{children:[e.jsx(l.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 Te({className:n}){const a=s.useQueryClient(),[d,c]=C.useState(!1),f=s.useSelectedVisual(),p=l.useEditorStore(S=>S.frame),g=l.useDashboardStore(S=>S.selectedSheetId),v=l.useDashboardStore(S=>S.dashboard),{updateFrame:h,setIsVisualEditing:k}=l.useDashboardActions(),{getUpdatedFrame:y}=re.useVisualUtils(),m=s.useUpdateVisualMutation(),j=s.useResolveExistingFrameSemanticExecutionPayload(),V=async()=>{if(!g){s.ue.error("No sheet selected");return}const S=(p==null?void 0:p.visualId)||(f==null?void 0:f.id);if(!S){s.ue.error("No visual to update");return}c(!0);try{const N=y();if(!ae(N)){c(!1);return}const L={...N,visualId:S},R=s.findDashboardFrameById(v,L.id),U=await j(L,{previousFrame:R});await m.mutateAsync({visualId:S,data:{frameObject:N}}),h(g,L,{semanticExecutionPayload:U}),a.invalidateQueries({queryKey:["visuals"]}),a.invalidateQueries({queryKey:["visual",S]}),s.ue.success("Saved to library and applied locally"),setTimeout(()=>{k(!1)},300)}catch(N){console.error("Failed to save and apply:",N),s.ue.error(N instanceof Error?N.message:"Failed to save and apply changes")}finally{c(!1)}};return e.jsx(l.Button,{onClick:V,className:n,size:"xs",variant:"default",disabled:d,children:d?e.jsxs(e.Fragment,{children:[e.jsx(l.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 Fe({className:n}){const{setTempQueryData:a,setSqlGen:d}=l.useEditorActions(),c=s.useQueryClient(),f=l.useEditorStore(m=>m.tempQueryData),p=l.useEditorStore(m=>m.onClose),g=l.useEditorStore(m=>m.card),v=le(),h=C.useMemo(()=>v!==g.type?{...g,type:v}:g,[g,v]),{queryKey:k}=s.useEditorCardQuery(h);function y(){if(f){const{queryKey:m,queryData:j}=f;m&&j&&c.setQueryData(m,j)}d({}),p==null||p()}return e.jsxs(l.Button,{onClick:y,className:n,size:"xs",variant:"outline",children:[e.jsx(l.X,{className:"h-3.5 w-3.5"}),"Close"]})}function Ie({label:n="Clear",variant:a="secondary",className:d}={}){const{setTempQueryData:c}=l.useEditorActions(),f=s.useQueryClient(),p=l.useEditorStore(_=>_.tempQueryData),g=l.useEditorStore(_=>_.card),v=le(),h=C.useMemo(()=>v!==g.type?{...g,type:v}:g,[g,v]),{queryKey:k}=s.useEditorCardQuery(h),{setCardSql:y,setSqlGen:m,setCardPython:j,setCardCustomCfg:V,setCardPreferences:S,clearQueryConfig:N,setCardConfig:L,setCardType:R,setFrame:U,setCard:G,setActiveTabCardId:P}=l.useEditorActions();function W(){var Y,H,I,K;const _=f.getQueryData(k);p!=null&&p.queryData||c({queryKey:k,queryData:_}),f.setQueryData(k,null),f.removeQueries({queryKey:k,exact:!0}),y(""),m({}),N(),L(void 0),j(""),V(""),S({});const r=l.useEditorStore.getState().frame,T=l.useEditorStore.getState().card,F=s.findCustomVisualConfigCard(r,T),A=((Y=F==null?void 0:F.customCardPreferences)==null?void 0:Y.visualType)==="multiple"||!!((H=F==null?void 0:F.customCardPreferences)!=null&&H.dataInputCardIds)||(((I=F==null?void 0:F.customCardPreferences)==null?void 0:I.minInputs)||0)>1||(((K=F==null?void 0:F.customCardPreferences)==null?void 0:K.maxInputs)||0)>1,M=Ee(T,A);U({...r,cards:r.cards.map(O=>O.id===M.id?M:O)}),P(M.id),G(M),A||R("bar")}return e.jsxs(l.Button,{onClick:W,className:d,size:"xs",variant:a,children:[e.jsx(l.X,{className:"h-3.5 w-3.5"}),n]})}function ye(n){const{control:a,onChange:d}=n;return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(l.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Label"}),e.jsx(l.Input,{size:"xs",value:a.label,placeholder:"Control label",onChange:c=>d(c.target.value)})]})}function Le(n){const{currentStep:a,labels:d}=n;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:d.map((c,f)=>{const p=f+1,g=p===a,v=p<a;return e.jsxs(C.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:l.cn("flex h-5 w-5 items-center justify-center rounded-full border text-[10px] font-medium tabular-nums",g?"border-foreground bg-foreground text-background":v?"border-foreground/30 bg-foreground/10 text-foreground":"border-border/60 bg-background text-muted-foreground"),children:p}),e.jsx("span",{className:l.cn("text-[12px]",g?"font-medium text-foreground":"text-muted-foreground"),children:c})]}),f<d.length-1?e.jsx("span",{className:"h-px w-4 bg-border/60 sm:w-6","aria-hidden":"true"}):null]},c)})})})}function J(n){const{secondary:a,tertiary:d,primary:c}=n;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,d,c]})}function Be(n){const{control:a,scope:d,detail:c}=n;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(s.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(d,a.placement)]}),c?e.jsx("div",{className:"text-[12px] text-muted-foreground",children:c}):null]})]})}function me(n){const{control:a,defaultValue:d,availableFieldChoices:c,availableMetricChoices:f,previewControlDefinitions:p,previewControlValues:g,onControlChange:v,onLabelChange:h,onDefaultValueChange:k,onBack:y,onNext:m,nextDisabled:j}=n;return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ye,{control:a,onChange:h}),e.jsx(s.ControlDefinitionOptionsEditor,{control:a,availableFieldChoices:c,availableMetricChoices:f,previewControlDefinitions:p,previewControlValues:g,controlLifecycle:"create",onChange:v}),e.jsx(s.ControlDefaultValueEditor,{control:a,value:d,onChange:k,allowNoDefault:!0,allowCardDefault:!0,hint:"This is the value viewers will see first.",previewControlDefinitions:p,previewControlValues:g}),e.jsx(J,{secondary:e.jsx(l.Button,{type:"button",variant:"outline",size:"xs",onClick:y,children:"Back"}),primary:e.jsx(l.Button,{type:"button",size:"xs",onClick:m,disabled:j,children:"Next"})})]})}const qe=new Set(["grain_selector","aggregation_selector","field_selector","metric_selector"]);function xe(n){const{text:a,ariaLabel:d}=n,[c,f]=C.useState(!1);return e.jsxs("button",{type:"button","aria-label":d,onClick:async()=>{try{await navigator.clipboard.writeText(a),f(!0),setTimeout(()=>f(!1),1200)}catch(p){console.error("Failed to copy",p)}},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:c?"Copied":"Click to copy"})]})}function fe(n){const{control:a,scope:d,createdReference:c,explorerContent:f,sqlDescription:p,summaryDetail:g,onBack:v,onCancel:h,onDone:k}=n,y=qe.has(a.type),m=c.match(/\[\[param\.(.+?)\]\]/),j=m?`{{ param('${m[1]}') }}`:"";return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Be,{control:a,scope:d,detail:g}),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:[y?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:f})]}):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:c,ariaLabel:"Copy SQL control reference"}),j?e.jsx(xe,{text:j,ariaLabel:"Copy Jinja control reference"}):null,e.jsxs("p",{className:"text-[12px] text-muted-foreground",children:[p," ",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(l.Button,{type:"button",variant:"outline",size:"xs",onClick:v,children:"Back"}),tertiary:e.jsx(l.Button,{type:"button",variant:"outline",size:"xs",onClick:h,children:"Cancel"}),primary:e.jsx(l.Button,{type:"button",size:"xs",onClick:k,children:"Done"})})]})}function _e(n){const a=s.createBlankControl(n.scope,n.existingControls,n.reservedIds),d=n.type===a.type?{...a,label:s.DEFAULT_LABEL_BY_TYPE[n.type]}:{...s.applyControlTypeChange({controls:[{...a,label:s.DEFAULT_LABEL_BY_TYPE[n.type]}],controlId:a.id,nextType:n.type}).controls[0],label:s.DEFAULT_LABEL_BY_TYPE[n.type]};return{step:2,control:d,defaultValue:s.getDefaultValueForType(d,void 0)}}function Ae({scope:n,controls:a,reservedControlIds:d,defaultValues:c,onChange:f,emptyMessage:p,initialCreateFlow:g=!1,usageByControlId:v,availableFieldChoices:h,availableMetricChoices:k,structuralParticipants:y,structuralParticipantIdsByControlId:m,card:j,allowedControlTypes:V,onCreateFlowActiveChange:S,onCreateFlowComplete:N}){const L=C.useMemo(()=>new Set(d||[]),[d]),R=s.getPlacementOptionsForScope(n),U=s.getDefaultPlacement(n),[G,P]=C.useState(null),[W,_]=C.useState(null),[r,T]=C.useState(()=>g?{step:1,control:s.createBlankControl(n,a,Array.from(L))}:null),F=C.useRef({}),A=C.useRef(void 0),M=C.useRef(g),Y=C.useMemo(()=>{const t=s.getFriendlyControlTypeOptions({scope:n,card:j});if(!V)return t;const i=new Set(V);return t.filter(o=>i.has(o.value))},[V,j,n]),H=C.useCallback(t=>{const i=s.getFriendlyControlTypeOptions({scope:n,card:j,includeType:V?void 0:t});if(!V)return i;const o=new Set(V);return i.filter(u=>o.has(u.value))},[V,j,n]),I=C.useCallback(t=>n==="dashboard"&&(t==="field_selector"||t==="metric_selector"),[n]),K=C.useMemo(()=>r?s.getEligibleParticipantsForStructuralControl(y||[],r.control.type):[],[r,y]),O=C.useMemo(()=>{if(!r)return{fields:h||[],metrics:k||[]};if(!I(r.control.type))return{fields:h||[],metrics:k||[]};const t=r.selectedCardIds||[],i=s.getCompatibleStructuralChoiceCatalog({controlType:r.control.type,participants:y||[],selectedCardIds:t});return{fields:r.control.type==="field_selector"?i.choices.map(o=>({option:o,target:i.fieldTargetMap[o.value]})):[],metrics:r.control.type==="metric_selector"?i.choices.map(o=>({option:o,target:i.metricTargetMap[o.value]})):[]}},[h,k,r,I,y]);C.useEffect(()=>{S==null||S(!!r)},[r,S]),C.useEffect(()=>{const t=g&&!M.current;M.current=g,t&&(T({step:1,control:s.createBlankControl(n,a,Array.from(L))}),_(null),P(null))},[a,g,L,n]);const ve=t=>{if(!I(t.type))return{fields:h||[],metrics:k||[]};const i=(m==null?void 0:m[t.id])||[];if(i.length===0)return{fields:h||[],metrics:k||[]};const o=s.getCompatibleStructuralChoiceCatalog({controlType:t.type,participants:y||[],selectedCardIds:i});return{fields:t.type==="field_selector"?o.choices.map(u=>({option:u,target:o.fieldTargetMap[u.value]})):[],metrics:t.type==="metric_selector"?o.choices.map(u=>({option:u,target:o.metricTargetMap[u.value]})):[]}},ne=t=>{if(!I(t.control.type))return{nextControl:t.control,cardBindingsById:void 0};const i=(m==null?void 0:m[t.control.id])||[],o=s.getCompatibleStructuralChoiceCatalog({controlType:t.control.type,participants:y||[],selectedCardIds:t.nextSelectedCardIds}),u=s.reconcileStructuralControlChoices({control:t.control,choices:o.choices}),b=Object.fromEntries(i.filter(E=>!t.nextSelectedCardIds.includes(E)).map(E=>[E,void 0]));return t.nextSelectedCardIds.length>0&&u.source.kind==="manual"&&u.source.options.length>0&&Object.assign(b,s.buildStructuralControlBindingsForParticipants({control:u,participants:y||[],selectedCardIds:t.nextSelectedCardIds})),{nextControl:u,cardBindingsById:b}},q=C.useCallback((t,i=c,o={type:"update"})=>{const u=t.map(b=>(s.resolveAuthoringControlDefaultValue({control:b,defaultValues:i}),s.syncSqlQueryControlExecutionRequirement(b)));f(u,i,o)},[c,f]),$=(t,i)=>{const o=a.find(w=>w.id===t);let u=a.map(w=>w.id!==t?w:i(w));const b=u.find(w=>w.id===t);let E,x;if(b&&n==="dashboard"&&(b.type==="field_selector"||b.type==="metric_selector")){const w=(m==null?void 0:m[b.id])||[],Q=ne({control:b,nextSelectedCardIds:w});u=u.map(z=>z.id===t?Q.nextControl:z),E=Q.cardBindingsById,x=[b.id]}else if(o&&n==="dashboard"&&(o.type==="field_selector"||o.type==="metric_selector")){const w=(m==null?void 0:m[o.id])||[];E=Object.fromEntries(w.map(Q=>[Q,void 0])),x=[o.id]}const D=u.find(w=>w.id===t);let B=c;if(o&&D){const w=s.resolveAuthoringControlDefaultValue({control:o,defaultValues:c});o.source.kind==="manual"&&D.source.kind==="sql_query"&&(F.current[t]=w);const Q=w===void 0&&o.source.kind==="sql_query"&&D.source.kind==="manual"?F.current[t]:w,z=s.getNextEditedControlDefaultValue({previousControl:o,nextControl:D,currentDefaultValue:Q});D.source.kind==="manual"&&(F.current[t]=z),c&&(B={...c},z===void 0?delete B[t]:B[t]=z),u=u.map(pe=>pe.id===t?{...D,defaultValue:z}:pe)}q(u,B,{type:"update",cardBindingsById:E,affectedBindingControlIds:x})},Ce=(t,i)=>{const o=i.trim();if(o.length===0||o===t||L.has(o)||a.some(E=>E.id===o&&E.id!==t))return;const u=a.map(E=>E.id===t?{...E,id:o}:E);if(!c){q(u,void 0,{type:"rename",oldId:t,newId:o});return}const b={...c};Object.prototype.hasOwnProperty.call(b,t)&&(b[o]=b[t],delete b[t]),q(u,b,{type:"rename",oldId:t,newId:o})},je=t=>{const i=a.filter(u=>u.id!==t);if(!c){q(i,void 0,{type:"remove",controlId:t});return}const o={...c};delete o[t],q(i,o,{type:"remove",controlId:t})},ke=C.useCallback(()=>{A.current=void 0,T({step:1,control:s.createBlankControl(n,a,Array.from(L))}),_(null),P(null)},[a,L,n]),X=t=>{T(i=>i&&(()=>{const o=t(i.control);i.control.source.kind==="manual"&&o.source.kind==="sql_query"&&(A.current=i.defaultValue);const u=i.defaultValue===void 0&&i.control.source.kind==="sql_query"&&o.source.kind==="manual"?A.current:i.defaultValue,b=s.getNextEditedControlDefaultValue({previousControl:i.control,nextControl:o,currentDefaultValue:u});return o.source.kind==="manual"&&(A.current=b),{...i,control:o,defaultValue:b}})())},oe=t=>{T(i=>i&&(i.control.source.kind==="manual"&&(A.current=t),{...i,defaultValue:t}))},Z=(()=>{if(!r)return!1;if(r.step===2&&I(r.control.type))return(r.selectedCardIds||[]).length>0;if(r.step!==2&&r.step!==3||!r.control.label.trim())return!1;const i=r.control.source.kind==="sql_query"?r.control:s.ensureManualSource(r.control);if(i.source.kind==="manual"&&(s.needsManualOptions(i)&&i.source.options.length===0||i.source.options.some(u=>u.label.trim().length===0||u.value.trim().length===0)))return!1;if(i.source.kind==="sql_query"){const{connectionId:o,sql:u,valueColumn:b}=i.source;return o.trim().length>0&&u.trim().length>0&&b.trim().length>0}return s.hasConcreteDefaultValue(s.getDefaultValueForType(i,r.defaultValue))})(),ie=()=>{var E;if(!r)return;const t=s.ensureManualSource(r.control),i=s.deriveUniqueControlId({label:t.label,fallbackId:t.id,existingControls:a,reservedIds:Array.from(L)}),o={...t,id:i},u=n==="dashboard"&&(o.type==="field_selector"||o.type==="metric_selector")&&((E=r.selectedCardIds)!=null&&E.length)?s.buildStructuralControlBindingsForParticipants({control:o,participants:y||[],selectedCardIds:r.selectedCardIds}):void 0,b=s.getDefaultValueForType(o,r.defaultValue);T({step:n==="dashboard"&&(o.type==="field_selector"||o.type==="metric_selector")?4:3,control:o,defaultValue:b,createdControlId:i,selectedCardIds:r.selectedCardIds,cardBindingsById:u})},ee=C.useCallback(()=>{T(null)},[]),de=C.useCallback(()=>{if(!(r!=null&&r.createdControlId)){T(null);return}const t=r.control,i=r.createdControlId,o=s.getDefaultValueForType(t,r.defaultValue);if(c){const u={...c};o===void 0?delete u[i]:u[i]=o,q([...a,{...t,defaultValue:o}],u,{type:"add",cardBindingsById:r.cardBindingsById})}else q([...a,{...t,defaultValue:o}],void 0,{type:"add",cardBindingsById:r.cardBindingsById});_(i),T(null),N==null||N()},[a,r,c,q,N]),Se=r?I(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:c}),se=r?[...a,r.control]:a,ue=r?s.buildAuthoringPreviewControlValues({controls:se,defaultValues:c,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(Le,{currentStep:r.step,labels:Se}),r.step===1&&(()=>{const t=new Set(["grain_selector","aggregation_selector","field_selector","metric_selector"]),i=Y.filter(b=>!t.has(b.value)),o=Y.filter(b=>t.has(b.value)),u=b=>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(_e({scope:n,existingControls:a,reservedIds:Array.from(L),type:b.value})),children:[e.jsx("div",{className:"text-[13px] font-medium text-foreground",children:b.label}),e.jsx("p",{className:"mt-0.5 text-[12px] text-muted-foreground",children:b.description})]},b.value);return e.jsxs("div",{className:"space-y-4",children:[n==="card"&&(j==null?void 0:j.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,i.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:i.map(u)})]}),o.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:o.map(u)})]}),e.jsx(J,{secondary:e.jsx(l.Button,{type:"button",variant:"outline",size:"xs",onClick:ee,children:"Back to controls"})})]})})(),r.step===2&&I(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=>X(i=>({...i,label:t}))}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Choose which cards should respond to this shared control."})]}),K.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:K.map(t=>{const i=(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(s.Checkbox,{checked:i,onCheckedChange:o=>T(u=>u&&{...u,selectedCardIds:o===!0?[...u.selectedCardIds||[],t.cardId]:(u.selectedCardIds||[]).filter(b=>b!==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(l.Button,{type:"button",variant:"outline",size:"xs",onClick:()=>T(t=>t&&{...t,step:1,selectedCardIds:[]}),children:"Back"}),primary:e.jsx(l.Button,{type:"button",size:"xs",onClick:()=>T(t=>t&&{...t,step:3}),disabled:!Z,children:"Next"})})]}),r.step===2&&!I(r.control.type)&&e.jsx(me,{control:r.control,defaultValue:r.defaultValue,availableFieldChoices:O.fields,availableMetricChoices:O.metrics,previewControlDefinitions:se,previewControlValues:ue,onControlChange:t=>X(()=>t),onLabelChange:t=>X(i=>({...i,label:t})),onDefaultValueChange:oe,onBack:()=>T(t=>t&&{...t,step:1}),onNext:ie,nextDisabled:!Z}),r.step===3&&I(r.control.type)&&e.jsx(me,{control:r.control,defaultValue:r.defaultValue,availableFieldChoices:O.fields,availableMetricChoices:O.metrics,previewControlDefinitions:se,previewControlValues:ue,onControlChange:t=>X(()=>t),onLabelChange:t=>X(i=>({...i,label:t})),onDefaultValueChange:oe,onBack:()=>T(t=>t&&{...t,step:2}),onNext:ie,nextDisabled:!Z}),r.step===3&&!I(r.control.type)&&e.jsx(fe,{control:r.control,scope:n,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&&I(r.control.type)&&e.jsx(fe,{control:r.control,scope:n,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:p}):null,!r&&a.map(t=>{const i=ve(t),o=v==null?void 0:v[t.id],u=s.resolveAuthoringControlDefaultValue({control:t,defaultValues:c}),b=W===t.id,E="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:()=>_(x=>x===t.id?null:t.id),children:[b?e.jsx(l.ChevronDown,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(s.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:E,children:s.getFriendlyTypeOption(t.type).label}),e.jsx("span",{className:E,children:s.getPlacementLabel(n,t.placement)})]}),e.jsxs("div",{className:"mt-0.5 text-[12px] text-muted-foreground",children:[s.getControlOptionPreview(t),o!=null&&o.status?` · ${o.status}`:""]})]})]}),e.jsx(l.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(s.Trash2,{className:"h-3.5 w-3.5"})})]}),b&&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(l.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Label"}),e.jsx(l.Input,{size:"xs",value:t.label,placeholder:"Control label",onChange:x=>$(t.id,D=>({...D,label:x.target.value}))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(l.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Type"}),e.jsxs(l.Select,{value:t.type,onValueChange:x=>{const D=s.applyControlTypeChange({controls:a,controlId:t.id,nextType:x,defaultValues:c});q(D.controls,D.defaultValues)},children:[e.jsx(l.SelectTrigger,{size:"xs",children:e.jsx(l.SelectValue,{})}),e.jsx(l.SelectContent,{children:H(t.type).map(x=>e.jsx(l.SelectItem,{value:x.value,children:x.label},x.value))})]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(l.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Show in"}),e.jsxs(l.Select,{value:t.placement||U,onValueChange:x=>$(t.id,D=>({...D,placement:x})),children:[e.jsx(l.SelectTrigger,{size:"xs",children:e.jsx(l.SelectValue,{})}),e.jsx(l.SelectContent,{children:R.map(x=>e.jsx(l.SelectItem,{value:x.value,children:x.label},x.value))})]})]})]}),I(t.type)?e.jsx(s.StructuralParticipantSelector,{type:t.type,participants:s.getEligibleParticipantsForStructuralControl(y||[],t.type).map(x=>({cardId:x.cardId,title:x.title,choiceCount:t.type==="field_selector"?x.fieldChoices.length:x.metricChoices.length})),selectedCardIds:(m==null?void 0:m[t.id])||[],onChange:x=>{const D=ne({control:t,nextSelectedCardIds:x}),B=a.map(w=>w.id===t.id?D.nextControl:w);q(B,c,{type:"update",cardBindingsById:D.cardBindingsById})}}):null,e.jsx(s.ControlDefinitionOptionsEditor,{control:t,availableFieldChoices:i.fields,availableMetricChoices:i.metrics,previewControlDefinitions:a,previewControlValues:te,controlLifecycle:"edit",onChange:x=>$(t.id,()=>x)}),t.initialValueStrategy==="saved_default"&&e.jsx(s.ControlDefaultValueEditor,{control:t,value:u,allowNoDefault:!0,allowCardDefault:!0,previewControlDefinitions:a,previewControlValues:te,onChange:x=>{const D=a.map(B=>B.id===t.id?{...B,defaultValue:x}:B);if(t.source.kind==="manual"&&(F.current[t.id]=x),c){const B={...c};x===void 0?delete B[t.id]:B[t.id]=x,q(D,B);return}q(D,void 0)}}),e.jsxs(s.Collapsible,{open:G===t.id,onOpenChange:x=>P(x?t.id:null),children:[e.jsx(s.CollapsibleTrigger,{asChild:!0,children:e.jsxs(l.Button,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 gap-1 text-muted-foreground hover:text-foreground",children:[G===t.id?e.jsx(l.ChevronDown,{className:"h-3.5 w-3.5"}):e.jsx(s.ChevronRight,{className:"h-3.5 w-3.5"}),"Advanced"]})}),e.jsxs(s.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(l.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Control ID"}),e.jsx(s.ControlIdInput,{controlId:t.id,onCommit:x=>Ce(t.id,x)},t.id)]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(l.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Initial value"}),e.jsxs(l.Select,{value:t.initialValueStrategy,onValueChange:x=>$(t.id,D=>({...D,initialValueStrategy:x})),children:[e.jsx(l.SelectTrigger,{size:"xs",children:e.jsx(l.SelectValue,{})}),e.jsx(l.SelectContent,{children:s.INITIAL_VALUE_STRATEGY_OPTIONS.map(x=>e.jsx(l.SelectItem,{value:x.value,children:x.label},x.value))})]})]})]}),e.jsx(s.ControlVisibilitySettings,{control:t,onChange:x=>$(t.id,()=>x)})]})]})]})]},t.id)}),!r&&e.jsxs(l.Button,{type:"button",variant:"outline",size:"xs",onClick:ke,children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Add control"]})]})}function Me(n){const{open:a,onOpenChange:d,initialCreateFlowActive:c=!1,dismissMode:f="passive"}=n,p=a!==void 0,[g,v]=C.useState(!1),[h,k]=C.useState(c),y=p?a:g,m=C.useCallback(S=>{!S&&h&&f==="passive"||(p||v(S),S||k(!1),d==null||d(S))},[p,h,f,d]),j=C.useCallback(()=>{p||v(!1),k(!1),d==null||d(!1)},[p,d]);C.useEffect(()=>{y||k(!1)},[y]);const V=C.useCallback(S=>{h&&S.preventDefault()},[h]);return{forceClose:j,handleOpenChange:m,isCreateFlowActive:h,preventPassiveDismissDuringCreate:V,resolvedOpen:y,setIsCreateFlowActive:k}}exports.CircleX=Ne;exports.ControlDefinitionListEditor=Ae;exports.EditorAcceptButton=we;exports.EditorCancelButton=Fe;exports.EditorClearButton=Ie;exports.Library=ge;exports.Link2=be;exports.VisualBadge=De;exports.VisualSaveAndApplyButton=Te;exports.VisualSaveButton=Ve;exports.useCreateFlowOverlayState=Me;exports.useEffectiveEditorCardType=le;
@@ -1,7 +1,8 @@
1
- import { H as Y, d as X, J as Z, K as ee, M as te, N as re, O as se, Q as ae, u as b, T as oe, U as ne, y as v, V as ie, W as H, Y as ce } from "./index-DDA12yqV.js";
2
- import { useState as Q, useEffect as de, useCallback as A } from "react";
1
+ import { q as X, u as Y, r as Z, s as ee, t as te, v as re, w as se, x as ae, p as V, y as oe } from "./index-CYWgnME0.js";
2
+ import { l as ne, m as ie, u as b, n as z, o as ce } from "./switch-oojO-gal.js";
3
+ import { useState as H, useEffect as de, useCallback as A } from "react";
3
4
  function le(e) {
4
- const [a, s] = Q(null), [r, t] = Q(null), o = Y();
5
+ const [a, s] = H(null), [r, t] = H(null), o = X();
5
6
  return de(() => {
6
7
  if (!e || e.trim() === "") {
7
8
  s(null), t(null);
@@ -68,7 +69,7 @@ function ue(e, a) {
68
69
  return e[0].id;
69
70
  }
70
71
  const M = /* @__PURE__ */ new Set();
71
- function Ee(e) {
72
+ function we(e) {
72
73
  return M.add(e), () => {
73
74
  M.delete(e);
74
75
  };
@@ -84,14 +85,14 @@ const he = (e) => {
84
85
  const { detailTableBackup: a, ...s } = e;
85
86
  return s;
86
87
  };
87
- async function z(e, a, s, r) {
88
+ async function Q(e, a, s, r) {
88
89
  if (!a || !s)
89
90
  throw new Error("Missing auth token or visual ID");
90
91
  const t = ["resource-by-id", "visual", s], o = r.getQueryData(t);
91
92
  if (o)
92
93
  return console.log("Using cached visual data for:", s), { data: o, fromCache: !0 };
93
94
  console.log("Fetching visual data from network for:", s);
94
- const l = v.loading("Loading visual...", {
95
+ const l = V.loading("Loading visual...", {
95
96
  position: "top-center"
96
97
  });
97
98
  try {
@@ -106,9 +107,9 @@ async function z(e, a, s, r) {
106
107
  if (!n.ok)
107
108
  throw new Error("Failed to load visual");
108
109
  const i = await n.json();
109
- return r.setQueryData(t, i), v.dismiss(l), { data: i, fromCache: !1 };
110
+ return r.setQueryData(t, i), V.dismiss(l), { data: i, fromCache: !1 };
110
111
  } catch (n) {
111
- throw v.dismiss(l), n;
112
+ throw V.dismiss(l), n;
112
113
  }
113
114
  }
114
115
  function q(e) {
@@ -129,7 +130,7 @@ function me(e, a) {
129
130
  const t = (l = r.cards) == null ? void 0 : l.find(
130
131
  (n) => n.id === r.activeCardId
131
132
  );
132
- return t ? (ie({
133
+ return t ? (oe({
133
134
  ...a,
134
135
  frame: r,
135
136
  card: t,
@@ -137,7 +138,7 @@ function me(e, a) {
137
138
  }), !0) : !1;
138
139
  }
139
140
  function pe() {
140
- const e = H(
141
+ const e = z(
141
142
  (r) => {
142
143
  var t;
143
144
  return ((t = r.card.customCardPreferences) == null ? void 0 : t.url) || "";
@@ -156,7 +157,7 @@ function pe() {
156
157
  selectedDatabaseName: f,
157
158
  selectedTableName: h,
158
159
  selectedConnectionId: F
159
- } = H.getState(), C = t.sql, y = (p = a == null ? void 0 : a.getState()) == null ? void 0 : p.settings, I = ce(t, {
160
+ } = z.getState(), C = t.sql, y = (p = a == null ? void 0 : a.getState()) == null ? void 0 : p.settings, I = ce(t, {
160
161
  isDevMode: o,
161
162
  cardSql: C,
162
163
  isShowingVisual: l,
@@ -177,8 +178,8 @@ function pe() {
177
178
  };
178
179
  }, [a]) };
179
180
  }
180
- function we() {
181
- const { authToken: e, tokenProps: a } = X(), s = Z(), r = ee(), t = te(), { selectVisual: o } = re(), {
181
+ function be() {
182
+ const { authToken: e, tokenProps: a } = Y(), s = Z(), r = ee(), t = te(), { selectVisual: o } = re(), {
182
183
  setFrame: l,
183
184
  setCard: n,
184
185
  setIsDevMode: i,
@@ -192,24 +193,24 @@ function we() {
192
193
  setSelectedTableName: p,
193
194
  setSelectedDatamodelId: g,
194
195
  setFilterValues: P,
195
- setInlineFilterValuesMap: T,
196
- setApplyFilters: D,
197
- clearEditorContext: L
198
- } = se(), {
199
- setIsDashboardEditing: U,
200
- setIsVisualEditing: N,
201
- setSelectedFrameId: W,
202
- clearSelectedFrameId: j,
203
- setIsDashboardPanelOpen: k
204
- } = ae(), S = b((c) => c.selectedSheetId), $ = b((c) => c.selectedFrameId), O = b((c) => c.dashboard), R = b((c) => c.filterValues), x = b(
196
+ setInlineFilterValuesMap: D,
197
+ setApplyFilters: L,
198
+ clearEditorContext: T
199
+ } = ne(), {
200
+ setIsDashboardEditing: v,
201
+ setIsVisualEditing: j,
202
+ setSelectedFrameId: k,
203
+ clearSelectedFrameId: N,
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
206
  (c) => c.inlineFilterValuesMap
206
- ), E = oe((t == null ? void 0 : t.id) || "", {
207
+ ), E = se((t == null ? void 0 : t.id) || "", {
207
208
  enabled: !!(t != null && t.id) && !!(e != null && e.accessToken)
208
- }), J = A(
209
+ }), G = A(
209
210
  async (c) => {
210
211
  try {
211
- o(c), j(), L();
212
- const { data: u, fromCache: V } = await z(
212
+ o(c), N(), T();
213
+ const { data: u, fromCache: U } = await Q(
213
214
  a.apiServiceUrl,
214
215
  (e == null ? void 0 : e.accessToken) || "",
215
216
  c.id,
@@ -229,18 +230,18 @@ function we() {
229
230
  setSelectedTableName: p,
230
231
  setSelectedDatamodelId: g,
231
232
  setFilterValues: P,
232
- setInlineFilterValuesMap: T,
233
- setApplyFilters: D,
234
- setIsDashboardEditing: U,
235
- setIsVisualEditing: N,
236
- dashboard: O,
233
+ setInlineFilterValuesMap: D,
234
+ setApplyFilters: L,
235
+ setIsDashboardEditing: v,
236
+ setIsVisualEditing: j,
237
+ dashboard: x,
237
238
  selectedSheetId: S,
238
239
  selectedFrameId: $,
239
240
  filterValues: R,
240
- inlineFilterValuesMap: x
241
+ inlineFilterValuesMap: O
241
242
  }))
242
243
  throw new Error("Failed to setup editor with visual data");
243
- return { success: !0, fromCache: V };
244
+ return { success: !0, fromCache: U };
244
245
  } catch (u) {
245
246
  return console.error("Error editing visual:", u), { success: !1, error: "Failed to load visual for editing" };
246
247
  }
@@ -252,8 +253,8 @@ function we() {
252
253
  o,
253
254
  l,
254
255
  n,
255
- U,
256
- N,
256
+ v,
257
+ j,
257
258
  i,
258
259
  f,
259
260
  h,
@@ -265,36 +266,36 @@ function we() {
265
266
  p,
266
267
  g,
267
268
  P,
268
- T,
269
269
  D,
270
270
  L,
271
- j,
272
- O,
271
+ T,
272
+ N,
273
+ x,
273
274
  S,
274
275
  $,
275
276
  R,
276
- x
277
+ O
277
278
  ]
278
- ), K = A(
279
+ ), J = A(
279
280
  async (c) => {
280
- var V;
281
- const u = (d) => (v.error(d), { success: !1, error: d });
281
+ var U;
282
+ const u = (d) => (V.error(d), { success: !1, error: d });
282
283
  try {
283
284
  if (o(c), !S)
284
285
  return u("No sheet selected. Please select a sheet first.");
285
- const { data: d, fromCache: G } = await z(
286
+ const { data: d, fromCache: K } = await Q(
286
287
  a.apiServiceUrl,
287
288
  (e == null ? void 0 : e.accessToken) || "",
288
289
  c.id,
289
290
  s
290
- ), _ = (d == null ? void 0 : d.frameObject) ?? ((V = d == null ? void 0 : d.visual) == null ? void 0 : V.frameObject);
291
+ ), _ = (d == null ? void 0 : d.frameObject) ?? ((U = d == null ? void 0 : d.visual) == null ? void 0 : U.frameObject);
291
292
  if (!_)
292
293
  return u("Visual has no frame data");
293
294
  const w = q(_);
294
295
  if (!(w != null && w.cards) || w.cards.length === 0)
295
296
  return u("Visual frame is malformed");
296
297
  const B = {
297
- ...ne(w),
298
+ ...ae(w),
298
299
  visualId: c.id
299
300
  // Link this frame to the library visual
300
301
  };
@@ -302,7 +303,7 @@ function we() {
302
303
  S,
303
304
  B,
304
305
  "end"
305
- ), U(!0), W(B.id), k(!1), { success: !0, fromCache: G };
306
+ ), v(!0), k(B.id), W(!1), { success: !0, fromCache: K };
306
307
  } catch (d) {
307
308
  return console.error("Error adding visual:", d), u(
308
309
  d instanceof Error ? d.message : "Failed to add visual to dashboard"
@@ -315,9 +316,9 @@ function we() {
315
316
  s,
316
317
  o,
317
318
  S,
318
- U,
319
- W,
319
+ v,
320
320
  k,
321
+ W,
321
322
  r
322
323
  ]
323
324
  );
@@ -326,14 +327,14 @@ function we() {
326
327
  isLoading: E.isLoading,
327
328
  isError: E.isError,
328
329
  error: E.error,
329
- handleEditLibraryVisual: J,
330
- handleAddLibraryVisual: K,
330
+ handleEditLibraryVisual: G,
331
+ handleAddLibraryVisual: J,
331
332
  getUpdatedFrame: pe().getUpdatedFrame,
332
333
  refetch: E.refetch
333
334
  };
334
335
  }
335
336
  export {
336
337
  fe as f,
337
- Ee as r,
338
- we as u
338
+ we as r,
339
+ be as u
339
340
  };
@@ -0,0 +1 @@
1
+ "use strict";const u=require("./index-BWjB_9uz.js"),f=require("./switch-CiEX68py.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 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chunks/index-8GnvL1_L.js"),e=require("../types/index.cjs");exports.Dashboard=r.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 r=require("../chunks/index-BWjB_9uz.js"),e=require("../types/index.cjs");exports.Dashboard=r.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 E } from "../chunks/index-DDA12yqV.js";
1
+ import { D as E } from "../chunks/index-CYWgnME0.js";
2
2
  import { CONTROL_CARD_DEFAULT_VALUE as L, EMPTY_SELECTION as T } from "../types/index.js";
3
3
  export {
4
4
  L as CONTROL_CARD_DEFAULT_VALUE,
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../chunks/date-formatter-CqXdM6JO.js");function H(r,e,n,t){const s=r instanceof Date?r.toISOString():String(r),u=(t==null?void 0:t.browserTimezone)||n,o=(t==null?void 0:t.isSqlCard)??!1;if(e!=null&&e.useRelativeTime)return l.formatRelativeTime(s,(e==null?void 0:e.sourceTimezone)||"auto");const i=e!=null&&e.useCustomFormat&&(e!=null&&e.customFormat)?e.customFormat:(e==null?void 0:e.format)||"MM/dd/yyyy";return l.formatDate(s,i,e!=null&&e.timezone&&(e==null?void 0:e.timezone)!=="auto"?e.timezone:o?u:n,(e==null?void 0:e.sourceTimezone)||"auto")}function h(r,e,n){if(r==null)return"";if(!n.useFormattedValues||!e)return String(r);switch(e.type){case"number":return typeof r=="number"?l.formatNumberWithColumnSettings(r,e.numberFormat,n.locale):String(r);case"date":return H(r,e.dateFormat,n.timezone,{browserTimezone:n.browserTimezone,isSqlCard:n.isSqlCard});case"progress":return typeof r=="number"?`${r}%`:String(r);case"badge":case"link":case"text":case"none":default:return String(r)}}function T(r,e){return e.visibleColumns.map(n=>{const t=r[n],s=e.columnSettings[n];return h(t,s,{useFormattedValues:e.useFormattedValues,timezone:e.timezone,locale:e.locale})})}function m(r,e=","){if(r==null)return"";const n=String(r);return n.includes(e)||n.includes('"')||n.includes(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../chunks/date-formatter-D9Bvw5Qk.js");function H(r,e,n,t){const s=r instanceof Date?r.toISOString():String(r),u=(t==null?void 0:t.browserTimezone)||n,o=(t==null?void 0:t.isSqlCard)??!1;if(e!=null&&e.useRelativeTime)return l.formatRelativeTime(s,(e==null?void 0:e.sourceTimezone)||"auto");const i=e!=null&&e.useCustomFormat&&(e!=null&&e.customFormat)?e.customFormat:(e==null?void 0:e.format)||"MM/dd/yyyy";return l.formatDate(s,i,e!=null&&e.timezone&&(e==null?void 0:e.timezone)!=="auto"?e.timezone:o?u:n,(e==null?void 0:e.sourceTimezone)||"auto")}function h(r,e,n){if(r==null)return"";if(!n.useFormattedValues||!e)return String(r);switch(e.type){case"number":return typeof r=="number"?l.formatNumberWithColumnSettings(r,e.numberFormat,n.locale):String(r);case"date":return H(r,e.dateFormat,n.timezone,{browserTimezone:n.browserTimezone,isSqlCard:n.isSqlCard});case"progress":return typeof r=="number"?`${r}%`:String(r);case"badge":case"link":case"text":case"none":default:return String(r)}}function T(r,e){return e.visibleColumns.map(n=>{const t=r[n],s=e.columnSettings[n];return h(t,s,{useFormattedValues:e.useFormattedValues,timezone:e.timezone,locale:e.locale})})}function m(r,e=","){if(r==null)return"";const n=String(r);return n.includes(e)||n.includes('"')||n.includes(`
2
2
  `)||n.includes("\r")?`"${n.replace(/"/g,'""')}"`:n}function f(r,e=","){return r.map(n=>m(n,e)).join(e)}function d(r,e={}){const{delimiter:n=",",lineEnding:t=`
3
3
  `}=e;return r.map(s=>f(s,n)).join(t)}function N(r,e={}){if(r.length===0)return"";const{delimiter:n=",",lineEnding:t=`
4
4
  `,includeHeaders:s=!0,columns:u}=e,o=u||Object.keys(r[0]),i=[];s&&i.push(o);for(const c of r){const p=o.map(b=>{const a=c[b];return a==null?"":String(a)});i.push(p)}return d(i,{delimiter:n,lineEnding:t})}function y(r,e){const n=[];e.includeHeaders&&n.push(f(e.visibleColumns,e.delimiter));for(const t of r){const s=T(t,e);n.push(s.map(u=>m(u,e.delimiter)).join(e.delimiter))}return n}function v(r,e,n=`
@@ -1,5 +1,5 @@
1
- import { f as h, a as V, b as w } from "../chunks/date-formatter-vkCj9Ct-.js";
2
- import { d as O, c as W, h as k, e as I, g as J, i as K, j as Q, p as U, r as X } from "../chunks/date-formatter-vkCj9Ct-.js";
1
+ import { f as h, a as V, b as w } from "../chunks/date-formatter-DyIOb6uC.js";
2
+ import { d as O, c as W, h as k, e as I, g as J, i as K, j as Q, p as U, r as X } from "../chunks/date-formatter-DyIOb6uC.js";
3
3
  function z(r, e, n, s) {
4
4
  const u = r instanceof Date ? r.toISOString() : String(r), l = (s == null ? void 0 : s.browserTimezone) || n, t = (s == null ? void 0 : s.isSqlCard) ?? !1;
5
5
  if (e != null && e.useRelativeTime)
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-8GnvL1_L.js"),_=require("./types/index.cjs"),M=require("./chunks/dashboard-summary-settings-dialog-DSxNqxFI.js"),t=require("react/jsx-runtime"),u=require("react"),O=require("./chunks/resource-management-panel-CKp4_aem.js"),U=require("./chunks/use-debounced-dirty-check-XHSwAefL.js");require("react-dom");const C=require("./chunks/dashboard-filter-controls-button-CK1-mKQh.js"),L=require("./chunks/normalize-dashboard-for-dirty-check-BXRUMVb2.js");function z(s){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const n in s)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(s,n);Object.defineProperty(r,n,o.get?o:{enumerable:!0,get:()=>s[n]})}}return r.default=s,Object.freeze(r)}const R=z(u);function Q(s){const{authToken:r,tokenProps:n}=e.useSemaphorContext();return e.useMutation({mutationFn:async o=>e.backtestAlert(n.apiServiceUrl,r.accessToken,s,o)})}function q(s){const{displayPreferences:r,cardId:n,...o}=s,l={...o,id:s.dashboardId};return t.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:t.jsxs(e.SemaphorContextProvider,{dashboardProps:l,children:[t.jsx(e.SemaphorReadyIndicator,{componentType:"visual",componentId:s.cardId}),t.jsx(e.UXProvider,{children:t.jsx(e.DisplayPreferencesProvider,{displayPreferences:r,children:t.jsx(e.Container,{type:"visual",cardId:n,...l,children:t.jsx(V,{cardId:n})})})})]})})}function V({cardId:s}){const r=e.useDashboardStore(l=>{var c;return(c=l.dashboard)==null?void 0:c.sheets}),{card:n,frame:o}=u.useMemo(()=>{const l=r==null?void 0:r.flatMap(i=>i.frames),c=l==null?void 0:l.flatMap(i=>i==null?void 0:i.cards),m=c==null?void 0:c.find(i=>(i==null?void 0:i.id)===s),a=l==null?void 0:l.find(i=>{var h;return(h=i==null?void 0:i.cards)==null?void 0:h.find(f=>(f==null?void 0:f.id)===s)});return{card:m,frame:a}},[r,s]);return!n||!o?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:l,resetErrorBoundary:c})=>t.jsx(e.FallbackVisual,{error:l,resetErrorBoundary:c,customerFacingMessage:"Error creating visual. Please try again."}),children:t.jsx(e.DashboardCard,{card:n,frame:o})})})}function W(s,r,n,o){u.useEffect(()=>{s&&!n&&r&&o(e.cloneDeep(r))},[s,n,r,o])}function H({name:s,items:r,value:n,onChange:o,isLoading:l,isError:c,refetch:m,className:a,icon:i,showNone:h=!1}){const f=R.useRef(null),[S,A]=R.useState(!1),[b,j]=R.useState("100%"),y=h?[...r||[],{id:"none",name:"None"}]:r;R.useLayoutEffect(()=>{f.current&&j(f.current.offsetWidth)},[]);function w(){var x;return l?"Loading...":c?"Error":n?(x=r==null?void 0:r.find(D=>D.id===n))==null?void 0:x.name:`Select ${s}`}function T(x,D){o(D),A(!1)}return t.jsxs(e.Popover,{open:S,onOpenChange:A,children:[t.jsx(e.PopoverTrigger,{asChild:!0,children:t.jsxs(e.Button,{ref:f,variant:"outline",role:"combobox","aria-expanded":S,className:e.cn("flex h-9 w-full justify-between",a),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.jsx("div",{className:"mr-2",children:i}),t.jsx("span",{className:"max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:w()})]}),t.jsx(e.ChevronDown,{className:"size-4 opacity-50"})]})}),t.jsx(e.PopoverContent,{className:"w-full p-0",style:{minWidth:b},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:m,children:t.jsx(e.RefreshCw,{className:e.cn("size-3.5 opacity-50",l&&"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:y==null?void 0:y.map(x=>t.jsx(e.CommandItem,{className:"overflow-x-auto",value:x.name,onSelect:D=>T(D,x.id),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(e.Check,{className:e.cn("size-4",n===x.id?"opacity-100":"opacity-0")}),t.jsx("div",{title:x.name,children:x.name})]})},x.id))})]})]})})]})}function $({triggerButtonClassName:s,variant:r="ghost"}){const[n,o]=u.useState(!1),l=e.useDashboardStore(m=>{var a;return(a=m.dashboard)==null?void 0:a.id}),c=e.useDashboardStore(m=>{var a;return(a=m.dashboard)==null?void 0:a.title});return l?t.jsxs(t.Fragment,{children:[t.jsx(e.IconButton,{tooltip:"Schedule Dashboard",className:e.cn("h-7 p-2",s),buttonProps:{variant:r},onClick:()=>o(!0),children:t.jsx(e.Clock,{className:"size-4"})}),t.jsx(e.EmailScheduleDialog,{open:n,onOpenChange:o,dashboardId:l,dashboardName:c})]}):null}function G(s,r){u.useEffect(()=>(s&&r&&(window.__SEMAPHOR_PRINT_STATE__={...r}),()=>{s&&window.__SEMAPHOR_PRINT_STATE__&&delete window.__SEMAPHOR_PRINT_STATE__}),[s,r])}function P(s){if(!s)return"--";const r=new Date(s);return Number.isNaN(r.getTime())?"--":r.toLocaleString()}function K(s){var r;return((r=s.alertState)==null?void 0:r.currentState)==="FIRING"?"Signal surfaced":s.status==="ACTIVE"?"Watching":s.status==="PAUSED"?"Paused":s.status}function Y({alertId:s,onBack:r}){var x,D,I,F;const{authToken:n,tokenProps:o}=e.useSemaphorContext(),{data:l,isLoading:c,refetch:m}=e.useAlertDetail(s),a=(l==null?void 0:l.alert)??null,[i,h]=u.useState([]),[f,S]=u.useState([]),[A,b]=u.useState(null),j=u.useCallback(async()=>{var g;const d=o==null?void 0:o.apiServiceUrl,p=n==null?void 0:n.accessToken;if(!d||!p||!s)return null;try{const v=await fetch(`${d}/v1/alerts/${s}/runs?limit=20`,{headers:{Authorization:`Bearer ${p}`}});if(v.ok){const E=await v.json(),N=Array.isArray(E.runs)?E.runs:[],k=A&&N.some(B=>B.id===A)?A:((g=N[0])==null?void 0:g.id)??null;return S(N),b(k),k}S([]),b(null)}catch{return S([]),b(null),null}return null},[s,n,A,o]),y=u.useCallback(async d=>{const p=o==null?void 0:o.apiServiceUrl,g=n==null?void 0:n.accessToken,v=d??A;if(!p||!g||!s||!v){h([]);return}try{const E=await fetch(`${p}/v1/alerts/${s}/runs/${v}/deliveries`,{headers:{Authorization:`Bearer ${g}`}});if(E.ok){const N=await E.json();h(Array.isArray(N.attempts)?N.attempts:[])}else h([])}catch{h([])}},[s,n,A,o]),w=u.useCallback(async()=>{await m();const d=await j();await y(d)},[y,j,m]);u.useEffect(()=>{j().catch(()=>{})},[j]),u.useEffect(()=>{y().catch(()=>{})},[y]);const T=u.useMemo(()=>{const d={};for(const p of i)d[p.channel]||(d[p.channel]=[]),d[p.channel].push(p);return d},[i]);return c?t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading signal detail..."}):a?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:[r&&t.jsx(e.Button,{variant:"outline",size:"sm",onClick:r,children:"Back"}),t.jsx("h2",{className:"text-lg font-semibold",children:a.name}),t.jsx(e.Badge,{variant:a.status==="ACTIVE"?"default":"secondary",children:K(a)}),((x=a.alertState)==null?void 0:x.currentState)&&t.jsx(e.Badge,{variant:a.alertState.currentState==="FIRING"?"destructive":"outline",children:a.alertState.currentState==="FIRING"?"Signal surfaced":"Stable"})]}),t.jsx(e.Button,{variant:"outline",size:"sm",onClick:()=>void w(),children:"Refresh"})]}),a.description&&t.jsx("p",{className:"text-sm text-muted-foreground",children:a.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(a.jobConfig.operator,a.jobConfig.threshold)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Severity:"})," ",a.jobConfig.severity]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Evaluated:"})," ",P((D=a.alertState)==null?void 0:D.lastEvaluatedAt)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Surfaced:"})," ",P((I=a.alertState)==null?void 0:I.lastTriggeredAt)]})]})]}),((F=a.deliveryConfig)==null?void 0:F.channels)&&a.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:a.deliveryConfig.channels.map(d=>t.jsx(e.Badge,{variant:"outline",children:d},d))})]}),f.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"}),f.length>1&&t.jsx("div",{className:"flex flex-wrap gap-2",children:f.map(d=>t.jsx(e.Button,{variant:d.id===A?"default":"outline",size:"sm",onClick:()=>b(d.id),children:P(d.scheduledFor)},d.id))}),Object.keys(T).length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:"No delivery attempts were recorded for this run."}):Object.entries(T).map(([d,p])=>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:d})}),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:p.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:P(g.createdAt)}),t.jsx("td",{className:"px-2 py-1 text-muted-foreground",children:g.error||"--"})]},g.id))})]})})]},d))]})]}):t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Signal not found."})}function X(){var c,m;const{quotasQuery:s,usageQuery:r}=e.useAlertQuotas(),n=((c=s.data)==null?void 0:c.quotas)||[],o=((m=r.data)==null?void 0:m.usage)||[],l=new Map(o.map(a=>[a.tenantId||"org",a]));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(e.Button,{variant:"outline",size:"sm",onClick:()=>{s.refetch(),r.refetch()},children:"Refresh"})]}),s.isLoading||r.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:n.map(a=>{const i=a.tenantId||"org",h=l.get(i);return t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-3 py-2",children:i}),t.jsx("td",{className:"px-3 py-2",children:(h==null?void 0:h.activeAlerts)??0}),t.jsx("td",{className:"px-3 py-2",children:a.policy.maxActiveAlerts}),t.jsxs("td",{className:"px-3 py-2",children:[a.policy.minCadenceMinutes," min"]}),t.jsx("td",{className:"px-3 py-2",children:a.policy.maxContextSources})]},i)})})]})})]})}exports.AlertManagementPage=e.AlertManagementPage;exports.AlertWizardDialog=e.AlertWizardDialog;exports.AlertsApiError=e.AlertsApiError;exports.CALCULATED_FIELD_ENTITY_MARKER=e.CALCULATED_FIELD_ENTITY_MARKER;exports.CardAlertIndicator=e.CardAlertIndicator;exports.CardSummary=e.CardSummary;exports.DATE_FORMAT_VALUES=e.DATE_FORMAT_VALUES;exports.Dashboard=e.Dashboard;exports.DashboardExportDialog=e.DashboardExportDialog;exports.DashboardWC=e.DashboardWC;exports.EmailScheduleDialog=e.EmailScheduleDialog;exports.ExportError=e.ExportError;exports.PivotMarkerEnum=e.PivotMarkerEnum;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.createEmptyKpiConfig=e.createEmptyKpiConfig;exports.createExport=e.createExport;exports.createSqlGenConfig=e.createSqlGenConfig;exports.deleteAlert=e.deleteAlert;exports.downloadDocumentPdf=e.downloadDocumentPdf;exports.downloadPdf=e.downloadPdf;exports.emitDashboardLoad=e.emitDashboardLoad;exports.emitDashboardUnload=e.emitDashboardUnload;exports.fmt=e.fmt;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.getColumnDataType=e.getColumnDataType;exports.getDownloadUrl=e.getDownloadUrl;exports.getExportStatus=e.getExportStatus;exports.getExports=e.getExports;exports.getFilterValueType=e.getFilterValueType;exports.getFormattedTableNameForQuery=e.getFormattedTableNameForQuery;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.invalidateToken=e.invalidateToken;exports.isBooleanDataType=e.isBooleanDataType;exports.isCalculatedDimension=e.isCalculatedDimension;exports.isCalculatedField=e.isCalculatedField;exports.isCalculatedMetric=e.isCalculatedMetric;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.isDateDataType=e.isDateDataType;exports.isExportComplete=e.isExportComplete;exports.isExportInProgress=e.isExportInProgress;exports.isNumberDataType=e.isNumberDataType;exports.isTextDataType=e.isTextDataType;exports.listAlertQuotas=e.listAlertQuotas;exports.listAlerts=e.listAlerts;exports.previewAlertDeliverable=e.previewAlertDeliverable;exports.resolveDataType=e.resolveDataType;exports.resolveDatamodelName=e.resolveDatamodelName;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.useCurrentActiveCard=e.useCurrentActiveCard;exports.useCurrentCardConfig=e.useCurrentCardConfig;exports.useCurrentSheetActiveCards=e.useCurrentSheetActiveCards;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardById=e.useDashboardById;exports.useDashboardQuery=e.useDashboardQuery;exports.useDashboardStore=e.useDashboardStore;exports.useDashboardSummary=e.useDashboardSummary;exports.useDataColumns=e.useDataColumns;exports.useDateFilterHook=e.useDateFilterHook;exports.useEditorActions=e.useEditorActions;exports.useEditorAside=e.useEditorAside;exports.useEditorStore=e.useEditorStore;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.CONTROL_CARD_DEFAULT_VALUE=_.CONTROL_CARD_DEFAULT_VALUE;exports.DEFAULT_CALENDAR_CONTEXT=_.DEFAULT_CALENDAR_CONTEXT;exports.DEFAULT_SEMANTIC_DOMAIN_ACCESS=_.DEFAULT_SEMANTIC_DOMAIN_ACCESS;exports.EMPTY_SELECTION=_.EMPTY_SELECTION;exports.CalendarPreferencesDialog=M.CalendarPreferencesDialog;exports.DashboardSummarySettingsDialog=M.DashboardSummarySettingsDialog;exports.ResourceManagementPanel=O.ResourceManagementPanel;exports.useDebouncedDirtyCheck=U.useDebouncedDirtyCheck;exports.AdvancedModeToggle=C.AdvancedModeToggle;exports.DashboardControlsSettings=C.DashboardControlsSettings;exports.DashboardFilterControlsButton=C.DashboardFilterControlsButton;exports.ExportNotificationItem=C.ExportNotificationItem;exports.ExportNotificationList=C.ExportNotificationList;exports.NotificationBell=C.NotificationBell;exports.UnsavedChangesAlert=C.UnsavedChangesAlert;exports.VisualEditingControls=C.VisualEditingControls;exports.useExportPolling=C.useExportPolling;exports.useExportRecovery=C.useExportRecovery;exports.normalizeDashboardForDirtyCheck=L.normalizeDashboardForDirtyCheck;exports.serializeDashboardForDirtyCheck=L.serializeDashboardForDirtyCheck;exports.AlertDetailPageEmbedded=Y;exports.Combobox=H;exports.ScheduleDashboard=$;exports.TenantQuotaPage=X;exports.Visual=q;exports.useAlertBacktest=Q;exports.useExposePrintState=G;exports.usePristineSnapshotInitializer=W;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-BWjB_9uz.js"),w=require("./types/index.cjs"),L=require("./chunks/dashboard-summary-settings-dialog-BdxKl1UF.js"),t=require("react/jsx-runtime"),r=require("./chunks/switch-CiEX68py.js"),m=require("react"),U=require("./chunks/resource-management-panel-mJmc5dMT.js"),z=require("./chunks/use-debounced-dirty-check-XHSwAefL.js");require("react-dom");require("./chunks/index-DRlMUglg.js");const y=require("./chunks/dashboard-filter-controls-button-C-e7230k.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 q(s){const{authToken:a,tokenProps:o}=e.useSemaphorContext();return e.useMutation({mutationFn:async l=>e.backtestAlert(o.apiServiceUrl,a.accessToken,s,l)})}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(A=>(A==null?void 0:A.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 A=P.useRef(null),[b,C]=P.useState(!1),[j,N]=P.useState("100%"),D=x?[...a||[],{id:"none",name:"None"}]:a;P.useLayoutEffect(()=>{A.current&&N(A.current.offsetWidth)},[]);function I(){var p;return i?"Loading...":u?"Error":o?(p=a==null?void 0:a.find(S=>S.id===o))==null?void 0:p.name:`Select ${s}`}function R(p,S){l(S),C(!1)}return t.jsxs(r.Popover,{open:b,onOpenChange:C,children:[t.jsx(r.PopoverTrigger,{asChild:!0,children:t.jsxs(r.Button,{ref:A,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:I()})]}),t.jsx(r.ChevronDown,{className:"size-4 opacity-50"})]})}),t.jsx(r.PopoverContent,{className:"w-full p-0",style:{minWidth:j},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:D==null?void 0:D.map(p=>t.jsx(e.CommandItem,{className:"overflow-x-auto",value:p.name,onSelect:S=>R(S,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,a){m.useEffect(()=>(s&&a&&(window.__SEMAPHOR_PRINT_STATE__={...a}),()=>{s&&window.__SEMAPHOR_PRINT_STATE__&&delete window.__SEMAPHOR_PRINT_STATE__}),[s,a])}function _(s){if(!s)return"--";const a=new Date(s);return Number.isNaN(a.getTime())?"--":a.toLocaleString()}function Y(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 X({alertId:s,onBack:a}){var p,S,F,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([]),[A,b]=m.useState([]),[C,j]=m.useState(null),N=m.useCallback(async()=>{var f;const c=l==null?void 0:l.apiServiceUrl,g=o==null?void 0:o.accessToken;if(!c||!g||!s)return null;try{const E=await fetch(`${c}/v1/alerts/${s}/runs?limit=20`,{headers:{Authorization:`Bearer ${g}`}});if(E.ok){const T=await E.json(),v=Array.isArray(T.runs)?T.runs:[],M=C&&v.some(O=>O.id===C)?C:((f=v[0])==null?void 0:f.id)??null;return b(v),j(M),M}b([]),j(null)}catch{return b([]),j(null),null}return null},[s,o,C,l]),D=m.useCallback(async c=>{const g=l==null?void 0:l.apiServiceUrl,f=o==null?void 0:o.accessToken,E=c??C;if(!g||!f||!s||!E){x([]);return}try{const T=await fetch(`${g}/v1/alerts/${s}/runs/${E}/deliveries`,{headers:{Authorization:`Bearer ${f}`}});if(T.ok){const v=await T.json();x(Array.isArray(v.attempts)?v.attempts:[])}else x([])}catch{x([])}},[s,o,C,l]),I=m.useCallback(async()=>{await h();const c=await N();await D(c)},[D,N,h]);m.useEffect(()=>{N().catch(()=>{})},[N]),m.useEffect(()=>{D().catch(()=>{})},[D]);const R=m.useMemo(()=>{const c={};for(const g of d)c[g.channel]||(c[g.channel]=[]),c[g.channel].push(g);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:Y(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 I(),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:"})," ",_((S=n.alertState)==null?void 0:S.lastEvaluatedAt)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Surfaced:"})," ",_((F=n.alertState)==null?void 0:F.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))})]}),A.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"}),A.length>1&&t.jsx("div",{className:"flex flex-wrap gap-2",children:A.map(c=>t.jsx(r.Button,{variant:c.id===C?"default":"outline",size:"sm",onClick:()=>j(c.id),children:_(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,g])=>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:g.map(f=>t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-2 py-1",children:f.recipient}),t.jsx("td",{className:"px-2 py-1",children:t.jsx(e.Badge,{variant:f.status==="SENT"?"default":"destructive",className:"text-[10px]",children:f.status})}),t.jsx("td",{className:"px-2 py-1",children:_(f.createdAt)}),t.jsx("td",{className:"px-2 py-1 text-muted-foreground",children:f.error||"--"})]},f.id))})]})})]},c))]})]}):t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Signal not found."})}function J(){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.CONTROL_CARD_DEFAULT_VALUE=w.CONTROL_CARD_DEFAULT_VALUE;exports.DEFAULT_CALENDAR_CONTEXT=w.DEFAULT_CALENDAR_CONTEXT;exports.DEFAULT_SEMANTIC_DOMAIN_ACCESS=w.DEFAULT_SEMANTIC_DOMAIN_ACCESS;exports.EMPTY_SELECTION=w.EMPTY_SELECTION;exports.CalendarPreferencesDialog=L.CalendarPreferencesDialog;exports.DashboardSummarySettingsDialog=L.DashboardSummarySettingsDialog;exports.CALCULATED_FIELD_ENTITY_MARKER=r.CALCULATED_FIELD_ENTITY_MARKER;exports.DATE_FORMAT_VALUES=r.DATE_FORMAT_VALUES;exports.PivotMarkerEnum=r.PivotMarkerEnum;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.isCalculatedDimension=r.isCalculatedDimension;exports.isCalculatedField=r.isCalculatedField;exports.isCalculatedMetric=r.isCalculatedMetric;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=U.ResourceManagementPanel;exports.useDebouncedDirtyCheck=z.useDebouncedDirtyCheck;exports.AdvancedModeToggle=y.AdvancedModeToggle;exports.DashboardControlsSettings=y.DashboardControlsSettings;exports.DashboardFilterControlsButton=y.DashboardFilterControlsButton;exports.ExportNotificationItem=y.ExportNotificationItem;exports.ExportNotificationList=y.ExportNotificationList;exports.NotificationBell=y.NotificationBell;exports.UnsavedChangesAlert=y.UnsavedChangesAlert;exports.VisualEditingControls=y.VisualEditingControls;exports.useExportPolling=y.useExportPolling;exports.useExportRecovery=y.useExportRecovery;exports.normalizeDashboardForDirtyCheck=B.normalizeDashboardForDirtyCheck;exports.serializeDashboardForDirtyCheck=B.serializeDashboardForDirtyCheck;exports.AlertDetailPageEmbedded=X;exports.Combobox=$;exports.ScheduleDashboard=G;exports.TenantQuotaPage=J;exports.Visual=V;exports.useAlertBacktest=q;exports.useExposePrintState=K;exports.usePristineSnapshotInitializer=H;