react-semaphor 0.1.303 → 0.1.305

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 (49) hide show
  1. package/dist/brand-studio/index.cjs +1 -1
  2. package/dist/brand-studio/index.js +4 -4
  3. package/dist/chunks/common-types-C6cAQgyh.js +9 -0
  4. package/dist/chunks/common-types-nBuCd3u2.js +1 -0
  5. package/dist/chunks/dashboard-controls-BcwXajYv.js +47 -0
  6. package/dist/chunks/{dashboard-controls-BCJZOzrL.js → dashboard-controls-DjOO0fkG.js} +799 -774
  7. package/dist/chunks/{dashboard-filter-controls-button-C-e7230k.js → dashboard-filter-controls-button-CR0_duPw.js} +3 -3
  8. package/dist/chunks/{dashboard-filter-controls-button-Cfbac4Jw.js → dashboard-filter-controls-button-YvRfoUuN.js} +142 -142
  9. package/dist/chunks/{dashboard-json-BzvLPhGM.js → dashboard-json-BYLaWi0-.js} +2 -2
  10. package/dist/chunks/{dashboard-json-BM5ywMgp.js → dashboard-json-tOsNVccY.js} +1 -1
  11. package/dist/chunks/{dashboard-summary-settings-dialog-ChK3344r.js → dashboard-summary-settings-dialog-CMxi2arh.js} +2 -2
  12. package/dist/chunks/{dashboard-summary-settings-dialog-BdxKl1UF.js → dashboard-summary-settings-dialog-DioOegLQ.js} +1 -1
  13. package/dist/chunks/{edit-dashboard-visual-nNaZ2IK1.js → edit-dashboard-visual-331vOmKT.js} +2 -2
  14. package/dist/chunks/{edit-dashboard-visual-D725CWD5.js → edit-dashboard-visual-ClLcFLD_.js} +164 -164
  15. package/dist/chunks/index-BOGpMmRo.js +1360 -0
  16. package/dist/chunks/{index-CYWgnME0.js → index-DJFckbGE.js} +42308 -40062
  17. package/dist/chunks/{palette-B9DJXMGo.js → palette-BqJlrRto.js} +1 -1
  18. package/dist/chunks/{palette-DGOzbtsn.js → palette-DD-i7bNS.js} +1 -1
  19. package/dist/chunks/{resource-management-panel-CE0-NcLL.js → resource-management-panel-BS9nfJbb.js} +65 -65
  20. package/dist/chunks/{resource-management-panel-mJmc5dMT.js → resource-management-panel-CoHy6cOi.js} +1 -1
  21. package/dist/chunks/{rotate-ccw-Bs7YJn10.js → rotate-ccw-CdGW8Rxm.js} +1 -1
  22. package/dist/chunks/{rotate-ccw-YsjQwpKm.js → rotate-ccw-X8MbX_hF.js} +1 -1
  23. package/dist/chunks/{save-Bj1y1rug.js → save-CFBIhbHD.js} +1 -1
  24. package/dist/chunks/{save-CUrexoNl.js → save-j-clxFtx.js} +1 -1
  25. package/dist/chunks/{switch-oojO-gal.js → switch-BFhVVwh9.js} +4248 -3243
  26. package/dist/chunks/switch-BH17qlxH.js +163 -0
  27. package/dist/chunks/use-create-flow-overlay-state-BSUi4chy.js +16 -0
  28. package/dist/chunks/{use-create-flow-overlay-state-BHDKxe7I.js → use-create-flow-overlay-state-Lmk-mIkA.js} +318 -316
  29. package/dist/chunks/{use-visual-utils-DYDXMl5v.js → use-visual-utils-CR9nLyEz.js} +1 -1
  30. package/dist/chunks/{use-visual-utils-CjFzlR0P.js → use-visual-utils-CikIkKb2.js} +2 -2
  31. package/dist/dashboard/index.cjs +1 -1
  32. package/dist/dashboard/index.js +5 -5
  33. package/dist/index.cjs +1 -1
  34. package/dist/index.js +60 -59
  35. package/dist/style.css +1 -1
  36. package/dist/surfboard/index.cjs +1 -1
  37. package/dist/surfboard/index.js +6 -6
  38. package/dist/types/dashboard.d.ts +168 -0
  39. package/dist/types/index.cjs +1 -1
  40. package/dist/types/index.js +8 -11
  41. package/dist/types/main.d.ts +194 -2
  42. package/dist/types/shared.d.ts +120 -0
  43. package/dist/types/surfboard.d.ts +168 -0
  44. package/dist/types/types.d.ts +168 -0
  45. package/package.json +1 -1
  46. package/dist/chunks/dashboard-controls-CVFoOPti.js +0 -47
  47. package/dist/chunks/index-BWjB_9uz.js +0 -1356
  48. package/dist/chunks/switch-CiEX68py.js +0 -163
  49. package/dist/chunks/use-create-flow-overlay-state-D2I2wNey.js +0 -16
@@ -0,0 +1,16 @@
1
+ "use strict";const s=require("./switch-BH17qlxH.js"),e=require("react/jsx-runtime"),p=require("./index-BOGpMmRo.js"),C=require("react"),re=require("./use-visual-utils-CR9nLyEz.js"),he=require("./save-CFBIhbHD.js");/**
2
+ * @license lucide-react v0.453.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const Ne=s.createLucideIcon("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
7
+ * @license lucide-react v0.453.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const ge=s.createLucideIcon("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);/**
12
+ * @license lucide-react v0.453.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const be=s.createLucideIcon("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);function le(){var h,k;const a=s.useEditorStore(y=>y.card),l=s.useEditorStore(y=>y.frame),i=C.useMemo(()=>p.findCustomVisualConfigCard(l,a),[l,a]),{manifest:d}=p.useCustomVisual(((h=i==null?void 0:i.customCardPreferences)==null?void 0:h.url)||""),f=C.useMemo(()=>{var y;return(y=d==null?void 0:d.visuals)==null?void 0:y.find(m=>{var j;return m.name===((j=i==null?void 0:i.customCardPreferences)==null?void 0:j.componentName)})},[d,(k=i==null?void 0:i.customCardPreferences)==null?void 0:k.componentName]),u=p.resolveMultiInputType(i,f),g=C.useMemo(()=>p.getCustomVisualInputCards({frame:l,configCard:i,isMultiInputVisual:u==="multiple"}),[l,i,u]),v=C.useMemo(()=>{const y=g.findIndex(m=>(m==null?void 0:m.id)===a.id);return y<0?-1:p.getSlotIndexForCard(a,y)},[g,a]);return C.useMemo(()=>!i||u!=="multiple"||v<0?a.type:p.getEffectiveCardTypeForSlot(a,v,f==null?void 0:f.slots)??a.type,[i,u,v,a,f==null?void 0:f.slots])}function De({type:a,isLinked:l,className:i,showLabel:d=!1,showLocal:f=!1}){const u=s.useDashboardStore(N=>N.selectedFrameId),g=p.useManagementStore(N=>N.selectedVisual),v=s.useEditorStore(N=>N.frame);let h;if(a)h=a;else if(l!==void 0)h=l?"linked":"library";else if(!!!(v!=null&&v.visualId||g!=null&&g.id)&&u)h="local";else if(g&&!u)h="library";else if(v!=null&&v.visualId&&u)h="linked";else if(g!=null&&g.id&&u)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(s.TooltipProvider,{children:e.jsxs(s.Tooltip,{delayDuration:300,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsxs(p.Badge,{variant:"outline",className:s.cn("cursor-help select-none transition-all",k[h],i),children:[V[h],d&&e.jsx("span",{className:"ml-1 text-xs font-medium leading-none",children:S[h]})]})}),e.jsxs(s.TooltipContent,{side:"bottom",className:s.cn("max-w-xs",m[h]),children:[e.jsx(s.TooltipArrow,{className:j[h]}),e.jsx("p",{children:y[h]})]})]})})}function Ee(a,l){return{...a,sql:"",python:"",config:void 0,customCfg:"",preferences:{},interactionConfig:void 0,linkedInteractionTargetOverrides:void 0,dynamicCardPreferences:void 0,customCardPreferences:l?a.customCardPreferences:void 0,visualizationMode:"builtin",type:l?a.type:"bar"}}function ae(a){const l=s.getDynamicFrameSaveIssue(a);return l?(p.ue.error(l),!1):!0}function we({className:a,variant:l="outline"}){const i=s.useEditorStore(u=>u.onSave),{getUpdatedFrame:d}=re.useVisualUtils();function f(){const u=d();ae(u)&&(i==null||i(u))}return e.jsxs(s.Button,{onClick:f,className:a,size:"xs",variant:l,children:[e.jsx(s.Check,{className:"h-3.5 w-3.5"}),"Accept"]})}function Ve({className:a,variant:l="default"}){const i=p.useQueryClient(),[d,f]=C.useState(!1),u=s.useDashboardStore(j=>j.actions.setIsDashboardPanelOpen),{setIsVisualEditing:g}=s.useDashboardActions(),{getUpdatedFrame:v}=re.useVisualUtils(),h=p.useSelectedVisual(),k=s.useEditorStore(j=>j.frame),y=p.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){p.ue.error("No visual to save");return}f(!0),y.mutate({visualId:V,data:{frameObject:j}},{onSuccess:()=>{f(!1),u(!0),p.ue.success("Visual updated successfully"),i.invalidateQueries({queryKey:["resource-by-id","visual",V],exact:!0})},onError:()=>{f(!1),p.ue.error("Failed to update visual")}})};return e.jsx(s.Button,{onClick:m,className:a,size:"xs",variant:l,children:d?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving"]}):e.jsxs(e.Fragment,{children:[e.jsx(he.Save,{className:"h-3.5 w-3.5"}),"Save to Library"]})})}function Te({className:a}){const l=p.useQueryClient(),[i,d]=C.useState(!1),f=p.useSelectedVisual(),u=s.useEditorStore(S=>S.frame),g=s.useDashboardStore(S=>S.selectedSheetId),v=s.useDashboardStore(S=>S.dashboard),{updateFrame:h,setIsVisualEditing:k}=s.useDashboardActions(),{getUpdatedFrame:y}=re.useVisualUtils(),m=p.useUpdateVisualMutation(),j=p.useResolveExistingFrameSemanticExecutionPayload(),V=async()=>{if(!g){p.ue.error("No sheet selected");return}const S=(u==null?void 0:u.visualId)||(f==null?void 0:f.id);if(!S){p.ue.error("No visual to update");return}d(!0);try{const N=y();if(!ae(N)){d(!1);return}const L={...N,visualId:S},R=p.findDashboardFrameById(v,L.id),U=await j(L,{previousFrame:R});await m.mutateAsync({visualId:S,data:{frameObject:N}}),h(g,L,{semanticExecutionPayload:U}),l.invalidateQueries({queryKey:["visuals"]}),l.invalidateQueries({queryKey:["visual",S]}),p.ue.success("Saved to library and applied locally"),setTimeout(()=>{k(!1)},300)}catch(N){console.error("Failed to save and apply:",N),p.ue.error(N instanceof Error?N.message:"Failed to save and apply changes")}finally{d(!1)}};return e.jsx(s.Button,{onClick:V,className:a,size:"xs",variant:"default",disabled:i,children:i?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(he.Save,{className:"h-3.5 w-3.5"}),"Save & Apply"]})})}function Fe({className:a}){const{setTempQueryData:l,setSqlGen:i}=s.useEditorActions(),d=p.useQueryClient(),f=s.useEditorStore(m=>m.tempQueryData),u=s.useEditorStore(m=>m.onClose),g=s.useEditorStore(m=>m.card),v=le(),h=C.useMemo(()=>v!==g.type?{...g,type:v}:g,[g,v]),{queryKey:k}=p.useEditorCardQuery(h);function y(){if(f){const{queryKey:m,queryData:j}=f;m&&j&&d.setQueryData(m,j)}i({}),u==null||u()}return e.jsxs(s.Button,{onClick:y,className:a,size:"xs",variant:"outline",children:[e.jsx(s.X,{className:"h-3.5 w-3.5"}),"Close"]})}function Ie({label:a="Clear",variant:l="secondary",className:i}={}){const{setTempQueryData:d}=s.useEditorActions(),f=p.useQueryClient(),u=s.useEditorStore(_=>_.tempQueryData),g=s.useEditorStore(_=>_.card),v=le(),h=C.useMemo(()=>v!==g.type?{...g,type:v}:g,[g,v]),{queryKey:k}=p.useEditorCardQuery(h),{setCardSql:y,setSqlGen:m,setCardPython:j,setCardCustomCfg:V,setCardPreferences:S,clearQueryConfig:N,setCardConfig:L,setCardType:R,setFrame:U,setCard:G,setActiveTabCardId:P}=s.useEditorActions();function W(){var Y,H,I,K;const _=f.getQueryData(k);u!=null&&u.queryData||d({queryKey:k,queryData:_}),f.setQueryData(k,null),f.removeQueries({queryKey:k,exact:!0}),y(""),m({}),N(),L(void 0),j(""),V(""),S({});const r=s.useEditorStore.getState().frame,T=s.useEditorStore.getState().card,F=p.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(s.Button,{onClick:W,className:i,size:"xs",variant:l,children:[e.jsx(s.X,{className:"h-3.5 w-3.5"}),a]})}function ye(a){const{control:l,onChange:i}=a;return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Label"}),e.jsx(s.Input,{size:"xs",value:l.label,placeholder:"Control label",onChange:d=>i(d.target.value)})]})}function Le(a){const{currentStep:l,labels:i}=a;return e.jsx("div",{className:"sticky top-0 z-10 -mx-1 border-b border-border/60 bg-background/95 px-1 pb-2.5 pt-1 backdrop-blur supports-[backdrop-filter]:bg-background/85",children:e.jsx("div",{className:"flex flex-wrap items-center gap-2 sm:gap-2.5",children:i.map((d,f)=>{const u=f+1,g=u===l,v=u<l;return e.jsxs(C.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:s.cn("flex h-5 w-5 items-center justify-center rounded-full border text-[10px] font-medium tabular-nums",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:u}),e.jsx("span",{className:s.cn("text-[12px]",g?"font-medium text-foreground":"text-muted-foreground"),children:d})]}),f<i.length-1?e.jsx("span",{className:"h-px w-4 bg-border/60 sm:w-6","aria-hidden":"true"}):null]},d)})})})}function J(a){const{secondary:l,tertiary:i,primary:d}=a;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:[l,i,d]})}function Be(a){const{control:l,scope:i,detail:d}=a;return e.jsxs("div",{className:"flex items-start gap-2.5 rounded-control border border-border/60 bg-muted/30 px-3 py-2.5",children:[e.jsx(p.CircleCheck,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-foreground"}),e.jsxs("div",{className:"min-w-0 space-y-0.5",children:[e.jsx("div",{className:"text-[13px] font-medium text-foreground",children:l.label}),e.jsxs("div",{className:"text-[12px] text-muted-foreground",children:[s.getFriendlyTypeOption(l.type).label," ·"," ",s.getControlOptionPreview(l)," ·"," ",s.getPlacementLabel(i,l.placement)]}),d?e.jsx("div",{className:"text-[12px] text-muted-foreground",children:d}):null]})]})}function me(a){const{control:l,defaultValue:i,availableFieldChoices:d,availableMetricChoices:f,previewControlDefinitions:u,previewControlValues:g,onControlChange:v,onLabelChange:h,onDefaultValueChange:k,onBack:y,onNext:m,nextDisabled:j}=a;return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ye,{control:l,onChange:h}),e.jsx(p.ControlDefinitionOptionsEditor,{control:l,availableFieldChoices:d,availableMetricChoices:f,previewControlDefinitions:u,previewControlValues:g,controlLifecycle:"create",onChange:v}),e.jsx(p.ControlDefaultValueEditor,{control:l,value:i,onChange:k,allowNoDefault:!0,allowCardDefault:!0,hint:"This is the value viewers will see first.",previewControlDefinitions:u,previewControlValues:g}),e.jsx(J,{secondary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:y,children:"Back"}),primary:e.jsx(s.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(a){const{text:l,ariaLabel:i}=a,[d,f]=C.useState(!1);return e.jsxs("button",{type:"button","aria-label":i,onClick:async()=>{try{await navigator.clipboard.writeText(l),f(!0),setTimeout(()=>f(!1),1200)}catch(u){console.error("Failed to copy",u)}},className:"group flex w-full items-center justify-between gap-2 rounded-control bg-muted/40 px-2 py-1 text-left transition-colors hover:bg-muted/60 focus-visible:bg-muted/60 focus-visible:outline-none",children:[e.jsx("code",{className:"min-w-0 truncate font-mono text-[12px] text-foreground",children:l}),e.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100",children:d?"Copied":"Click to copy"})]})}function fe(a){const{control:l,scope:i,createdReference:d,explorerContent:f,sqlDescription:u,summaryDetail:g,onBack:v,onCancel:h,onDone:k}=a,y=qe.has(l.type),m=d.match(/\[\[param\.(.+?)\]\]/),j=m?`{{ param('${m[1]}') }}`:"";return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Be,{control:l,scope:i,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:d,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:[u," ",e.jsx("a",{href:"https://docs.semaphor.cloud/docs/concepts/template-expressions",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Template expressions docs"}),"."]})]})]})]}),e.jsx(J,{secondary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:v,children:"Back"}),tertiary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:h,children:"Cancel"}),primary:e.jsx(s.Button,{type:"button",size:"xs",onClick:k,children:"Done"})})]})}function _e(a){const l=s.createBlankControl(a.scope,a.existingControls,a.reservedIds),i=a.type===l.type?{...l,label:s.DEFAULT_LABEL_BY_TYPE[a.type]}:{...s.applyControlTypeChange({controls:[{...l,label:s.DEFAULT_LABEL_BY_TYPE[a.type]}],controlId:l.id,nextType:a.type}).controls[0],label:s.DEFAULT_LABEL_BY_TYPE[a.type]};return{step:2,control:i,defaultValue:s.getDefaultValueForType(i,void 0)}}function Ae({scope:a,controls:l,reservedControlIds:i,defaultValues:d,onChange:f,emptyMessage:u,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(i||[]),[i]),R=s.getPlacementOptionsForScope(a),U=s.getDefaultPlacement(a),[G,P]=C.useState(null),[W,_]=C.useState(null),[r,T]=C.useState(()=>g?{step:1,control:s.createBlankControl(a,l,Array.from(L))}:null),F=C.useRef({}),A=C.useRef(void 0),M=C.useRef(g),Y=C.useMemo(()=>{const t=s.getFriendlyControlTypeOptions({scope:a,card:j});if(!V)return t;const o=new Set(V);return t.filter(n=>o.has(n.value))},[V,j,a]),H=C.useCallback(t=>{const o=s.getFriendlyControlTypeOptions({scope:a,card:j,includeType:V?void 0:t});if(!V)return o;const n=new Set(V);return o.filter(c=>n.has(c.value))},[V,j,a]),I=C.useCallback(t=>a==="dashboard"&&(t==="field_selector"||t==="metric_selector"),[a]),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||[],o=s.getCompatibleStructuralChoiceCatalog({controlType:r.control.type,participants:y||[],selectedCardIds:t});return{fields:r.control.type==="field_selector"?o.choices.map(n=>({option:n,target:o.fieldTargetMap[n.value]})):[],metrics:r.control.type==="metric_selector"?o.choices.map(n=>({option:n,target:o.metricTargetMap[n.value]})):[]}},[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(a,l,Array.from(L))}),_(null),P(null))},[l,g,L,a]);const ve=t=>{if(!I(t.type))return{fields:h||[],metrics:k||[]};const o=(m==null?void 0:m[t.id])||[];if(o.length===0)return{fields:h||[],metrics:k||[]};const n=s.getCompatibleStructuralChoiceCatalog({controlType:t.type,participants:y||[],selectedCardIds:o});return{fields:t.type==="field_selector"?n.choices.map(c=>({option:c,target:n.fieldTargetMap[c.value]})):[],metrics:t.type==="metric_selector"?n.choices.map(c=>({option:c,target:n.metricTargetMap[c.value]})):[]}},ne=t=>{if(!I(t.control.type))return{nextControl:t.control,cardBindingsById:void 0};const o=(m==null?void 0:m[t.control.id])||[],n=s.getCompatibleStructuralChoiceCatalog({controlType:t.control.type,participants:y||[],selectedCardIds:t.nextSelectedCardIds}),c=s.reconcileStructuralControlChoices({control:t.control,choices:n.choices}),b=Object.fromEntries(o.filter(E=>!t.nextSelectedCardIds.includes(E)).map(E=>[E,void 0]));return t.nextSelectedCardIds.length>0&&c.source.kind==="manual"&&c.source.options.length>0&&Object.assign(b,s.buildStructuralControlBindingsForParticipants({control:c,participants:y||[],selectedCardIds:t.nextSelectedCardIds})),{nextControl:c,cardBindingsById:b}},q=C.useCallback((t,o=d,n={type:"update"})=>{const c=t.map(b=>(s.resolveAuthoringControlDefaultValue({control:b,defaultValues:o}),s.syncSqlQueryControlExecutionRequirement(b)));f(c,o,n)},[d,f]),$=(t,o)=>{const n=l.find(w=>w.id===t);let c=l.map(w=>w.id!==t?w:o(w));const b=c.find(w=>w.id===t);let E,x;if(b&&a==="dashboard"&&(b.type==="field_selector"||b.type==="metric_selector")){const w=(m==null?void 0:m[b.id])||[],Q=ne({control:b,nextSelectedCardIds:w});c=c.map(z=>z.id===t?Q.nextControl:z),E=Q.cardBindingsById,x=[b.id]}else if(n&&a==="dashboard"&&(n.type==="field_selector"||n.type==="metric_selector")){const w=(m==null?void 0:m[n.id])||[];E=Object.fromEntries(w.map(Q=>[Q,void 0])),x=[n.id]}const D=c.find(w=>w.id===t);let B=d;if(n&&D){const w=s.resolveAuthoringControlDefaultValue({control:n,defaultValues:d});n.source.kind==="manual"&&D.source.kind==="sql_query"&&(F.current[t]=w);const Q=w===void 0&&n.source.kind==="sql_query"&&D.source.kind==="manual"?F.current[t]:w,z=s.getNextEditedControlDefaultValue({previousControl:n,nextControl:D,currentDefaultValue:Q});D.source.kind==="manual"&&(F.current[t]=z),d&&(B={...d},z===void 0?delete B[t]:B[t]=z),c=c.map(pe=>pe.id===t?{...D,defaultValue:z}:pe)}q(c,B,{type:"update",cardBindingsById:E,affectedBindingControlIds:x})},Ce=(t,o)=>{if(!o.trim())return;const n=p.normalizeDashboardInputVariableName(o);if(n===t||L.has(n)||l.some(E=>E.id===n&&E.id!==t))return;const c=l.map(E=>E.id===t?{...E,id:n}:E);if(!d){q(c,void 0,{type:"rename",oldId:t,newId:n});return}const b={...d};Object.prototype.hasOwnProperty.call(b,t)&&(b[n]=b[t],delete b[t]),q(c,b,{type:"rename",oldId:t,newId:n})},je=t=>{const o=l.filter(c=>c.id!==t);if(!d){q(o,void 0,{type:"remove",controlId:t});return}const n={...d};delete n[t],q(o,n,{type:"remove",controlId:t})},ke=C.useCallback(()=>{A.current=void 0,T({step:1,control:s.createBlankControl(a,l,Array.from(L))}),_(null),P(null)},[l,L,a]),X=t=>{T(o=>o&&(()=>{const n=t(o.control);o.control.source.kind==="manual"&&n.source.kind==="sql_query"&&(A.current=o.defaultValue);const c=o.defaultValue===void 0&&o.control.source.kind==="sql_query"&&n.source.kind==="manual"?A.current:o.defaultValue,b=s.getNextEditedControlDefaultValue({previousControl:o.control,nextControl:n,currentDefaultValue:c});return n.source.kind==="manual"&&(A.current=b),{...o,control:n,defaultValue:b}})())},oe=t=>{T(o=>o&&(o.control.source.kind==="manual"&&(A.current=t),{...o,defaultValue:t}))},Z=(()=>{if(!r)return!1;if(r.step===2&&I(r.control.type))return(r.selectedCardIds||[]).length>0;if(r.step!==2&&r.step!==3||!r.control.label.trim())return!1;const o=r.control.source.kind==="sql_query"?r.control:s.ensureManualSource(r.control);if(o.source.kind==="manual"&&(s.needsManualOptions(o)&&o.source.options.length===0||o.source.options.some(c=>c.label.trim().length===0||c.value.trim().length===0)))return!1;if(o.source.kind==="sql_query"){const{connectionId:n,sql:c,valueColumn:b}=o.source;return n.trim().length>0&&c.trim().length>0&&b.trim().length>0}return s.hasConcreteDefaultValue(s.getDefaultValueForType(o,r.defaultValue))})(),ie=()=>{var E;if(!r)return;const t=s.ensureManualSource(r.control),o=s.deriveUniqueControlId({label:t.label,fallbackId:t.id,existingControls:l,reservedIds:Array.from(L)}),n={...t,id:o},c=a==="dashboard"&&(n.type==="field_selector"||n.type==="metric_selector")&&((E=r.selectedCardIds)!=null&&E.length)?s.buildStructuralControlBindingsForParticipants({control:n,participants:y||[],selectedCardIds:r.selectedCardIds}):void 0,b=s.getDefaultValueForType(n,r.defaultValue);T({step:a==="dashboard"&&(n.type==="field_selector"||n.type==="metric_selector")?4:3,control:n,defaultValue:b,createdControlId:o,selectedCardIds:r.selectedCardIds,cardBindingsById:c})},ee=C.useCallback(()=>{T(null)},[]),de=C.useCallback(()=>{if(!(r!=null&&r.createdControlId)){T(null);return}const t=r.control,o=r.createdControlId,n=s.getDefaultValueForType(t,r.defaultValue);if(d){const c={...d};n===void 0?delete c[o]:c[o]=n,q([...l,{...t,defaultValue:n}],c,{type:"add",cardBindingsById:r.cardBindingsById})}else q([...l,{...t,defaultValue:n}],void 0,{type:"add",cardBindingsById:r.cardBindingsById});_(o),T(null),N==null||N()},[l,r,d,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:l,defaultValues:d}),se=r?[...l,r.control]:l,ue=r?s.buildAuthoringPreviewControlValues({controls:se,defaultValues:d,overrides:[{controlId:r.control.id,value:r.defaultValue}]}):te;return e.jsxs("div",{className:"space-y-4",children:[r?e.jsxs("div",{className:"space-y-4 pb-1",children:[e.jsx(Le,{currentStep:r.step,labels:Se}),r.step===1&&(()=>{const t=new Set(["grain_selector","aggregation_selector","field_selector","metric_selector"]),o=Y.filter(b=>!t.has(b.value)),n=Y.filter(b=>t.has(b.value)),c=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:a,existingControls:l,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:[a==="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,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:"Input controls"}),e.jsx("div",{className:"grid gap-1.5 sm:grid-cols-2",children:o.map(c)})]}),n.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Data-driven controls"}),e.jsx("div",{className:"grid gap-1.5 sm:grid-cols-2",children:n.map(c)})]}),e.jsx(J,{secondary:e.jsx(s.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(o=>({...o,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 o=(r.selectedCardIds||[]).includes(t.cardId);return e.jsxs("label",{className:"flex items-start gap-2 rounded-control px-1.5 py-1 text-[13px] hover:bg-muted/40",children:[e.jsx(p.Checkbox,{checked:o,onCheckedChange:n=>T(c=>c&&{...c,selectedCardIds:n===!0?[...c.selectedCardIds||[],t.cardId]:(c.selectedCardIds||[]).filter(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(s.Button,{type:"button",variant:"outline",size:"xs",onClick:()=>T(t=>t&&{...t,step:1,selectedCardIds:[]}),children:"Back"}),primary:e.jsx(s.Button,{type:"button",size:"xs",onClick:()=>T(t=>t&&{...t,step:3}),disabled:!Z,children:"Next"})})]}),r.step===2&&!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(o=>({...o,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(o=>({...o,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:a,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:a,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&&l.length===0?e.jsx("div",{className:"rounded-md border border-dashed p-3 text-sm text-muted-foreground",children:u}):null,!r&&l.map(t=>{const o=ve(t),n=v==null?void 0:v[t.id],c=s.resolveAuthoringControlDefaultValue({control:t,defaultValues:d}),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(s.ChevronDown,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(p.ChevronRight,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",children:t.label||"Untitled control"}),e.jsx("span",{className:E,children:s.getFriendlyTypeOption(t.type).label}),e.jsx("span",{className:E,children:s.getPlacementLabel(a,t.placement)})]}),e.jsxs("div",{className:"mt-0.5 text-[12px] text-muted-foreground",children:[s.getControlOptionPreview(t),n!=null&&n.status?` · ${n.status}`:""]})]})]}),e.jsx(s.Button,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 shrink-0 p-0 text-muted-foreground",onClick:()=>je(t.id),"aria-label":`Remove ${t.label}`,children:e.jsx(p.Trash2,{className:"h-3.5 w-3.5"})})]}),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(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Label"}),e.jsx(s.Input,{size:"xs",value:t.label,placeholder:"Control label",onChange:x=>$(t.id,D=>({...D,label:x.target.value}))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Type"}),e.jsxs(s.Select,{value:t.type,onValueChange:x=>{const D=s.applyControlTypeChange({controls:l,controlId:t.id,nextType:x,defaultValues:d});q(D.controls,D.defaultValues)},children:[e.jsx(s.SelectTrigger,{size:"xs",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:H(t.type).map(x=>e.jsx(s.SelectItem,{value:x.value,children:x.label},x.value))})]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Show in"}),e.jsxs(s.Select,{value:t.placement||U,onValueChange:x=>$(t.id,D=>({...D,placement:x})),children:[e.jsx(s.SelectTrigger,{size:"xs",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:R.map(x=>e.jsx(s.SelectItem,{value:x.value,children:x.label},x.value))})]})]})]}),I(t.type)?e.jsx(p.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=l.map(w=>w.id===t.id?D.nextControl:w);q(B,d,{type:"update",cardBindingsById:D.cardBindingsById})}}):null,e.jsx(p.ControlDefinitionOptionsEditor,{control:t,availableFieldChoices:o.fields,availableMetricChoices:o.metrics,previewControlDefinitions:l,previewControlValues:te,controlLifecycle:"edit",onChange:x=>$(t.id,()=>x)}),t.initialValueStrategy==="saved_default"&&e.jsx(p.ControlDefaultValueEditor,{control:t,value:c,allowNoDefault:!0,allowCardDefault:!0,previewControlDefinitions:l,previewControlValues:te,onChange:x=>{const D=l.map(B=>B.id===t.id?{...B,defaultValue:x}:B);if(t.source.kind==="manual"&&(F.current[t.id]=x),d){const B={...d};x===void 0?delete B[t.id]:B[t.id]=x,q(D,B);return}q(D,void 0)}}),e.jsxs(p.Collapsible,{open:G===t.id,onOpenChange:x=>P(x?t.id:null),children:[e.jsx(p.CollapsibleTrigger,{asChild:!0,children:e.jsxs(s.Button,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 gap-1 text-muted-foreground hover:text-foreground",children:[G===t.id?e.jsx(s.ChevronDown,{className:"h-3.5 w-3.5"}):e.jsx(p.ChevronRight,{className:"h-3.5 w-3.5"}),"Advanced"]})}),e.jsxs(p.CollapsibleContent,{className:"space-y-3 pt-2",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Variable name"}),e.jsx(p.ControlIdInput,{controlId:t.id,onCommit:x=>Ce(t.id,x)},t.id)]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Initial value"}),e.jsxs(s.Select,{value:t.initialValueStrategy,onValueChange:x=>$(t.id,D=>({...D,initialValueStrategy:x})),children:[e.jsx(s.SelectTrigger,{size:"xs",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:s.INITIAL_VALUE_STRATEGY_OPTIONS.map(x=>e.jsx(s.SelectItem,{value:x.value,children:x.label},x.value))})]})]})]}),e.jsx(p.ControlVisibilitySettings,{control:t,onChange:x=>$(t.id,()=>x)})]})]})]})]},t.id)}),!r&&e.jsxs(s.Button,{type:"button",variant:"outline",size:"xs",onClick:ke,children:[e.jsx(p.Plus,{className:"h-3.5 w-3.5"}),"Add control"]})]})}function Me(a){const{open:l,onOpenChange:i,initialCreateFlowActive:d=!1,dismissMode:f="passive"}=a,u=l!==void 0,[g,v]=C.useState(!1),[h,k]=C.useState(d),y=u?l:g,m=C.useCallback(S=>{!S&&h&&f==="passive"||(u||v(S),S||k(!1),i==null||i(S))},[u,h,f,i]),j=C.useCallback(()=>{u||v(!1),k(!1),i==null||i(!1)},[u,i]);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;