react-semaphor 0.1.326 → 0.1.328

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 (82) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +1 -1
  3. package/dist/brand-studio/index.cjs +5 -5
  4. package/dist/brand-studio/index.js +23 -24
  5. package/dist/chunks/_commonjsHelpers-BVfed4GL.js +28 -0
  6. package/dist/chunks/_commonjsHelpers-DwTZ_eVU.js +1 -0
  7. package/dist/chunks/{braces-DVaMJoCd.js → braces-CG8viaD2.js} +1 -1
  8. package/dist/chunks/{braces-dHeaioTd.js → braces-DSaa_4Oc.js} +1 -1
  9. package/dist/chunks/{calendar-preferences-dialog-mqU_uOmY.js → calendar-preferences-dialog-DD_qAthL.js} +1 -1
  10. package/dist/chunks/{calendar-preferences-dialog--2jD-eKu.js → calendar-preferences-dialog-JRmNJptJ.js} +3 -3
  11. package/dist/chunks/{chevrons-up-down-DNQE-uEp.js → chevrons-up-down-CBa0uh0X.js} +1 -1
  12. package/dist/chunks/{chevrons-up-down-CLbzBHoI.js → chevrons-up-down-ChDNqVP7.js} +1 -1
  13. package/dist/chunks/dashboard-briefing-launcher-BKdJFwH5.js +106 -0
  14. package/dist/chunks/{dashboard-briefing-launcher-DsjXUPFq.js → dashboard-briefing-launcher-BfyNkd8i.js} +1106 -1108
  15. package/dist/chunks/{dashboard-controls-DgNkM1yT.js → dashboard-controls-0pZDLvFL.js} +218 -218
  16. package/dist/chunks/{dashboard-controls-XCa9PZuU.js → dashboard-controls-C0xm1QMR.js} +10 -10
  17. package/dist/chunks/dashboard-json-BW5OVZ6m.js +1 -0
  18. package/dist/chunks/{dashboard-json-DkA6Bf0Y.js → dashboard-json-DsruhRPD.js} +14 -13
  19. package/dist/chunks/date-formatter-B4EBSe9C.js +1 -0
  20. package/dist/chunks/date-formatter-CzcPZx39.js +416 -0
  21. package/dist/chunks/edit-dashboard-visual-DQyJ7SSv.js +178 -0
  22. package/dist/chunks/{edit-dashboard-visual-Q5hW5MXk.js → edit-dashboard-visual-g5SZZahJ.js} +8242 -7784
  23. package/dist/chunks/index-1JWDPCun.js +1935 -0
  24. package/dist/chunks/index-BdjXTQt4.js +1444 -0
  25. package/dist/chunks/{index-DwfDwtv2.js → index-BmKr-K7J.js} +117670 -113627
  26. package/dist/chunks/index-C1l78BIx.js +3247 -0
  27. package/dist/chunks/lib-Ce3zosXY.js +38 -0
  28. package/dist/chunks/lib-DFvr9fM4.js +5500 -0
  29. package/dist/chunks/{palette-DtmNws9a.js → palette-D0YmAqBS.js} +1 -1
  30. package/dist/chunks/{palette-DpcvHAiY.js → palette-DQgq3edH.js} +1 -1
  31. package/dist/chunks/{resource-management-panel-CGwWKZOP.js → resource-management-panel-CIfBh46E.js} +1 -1
  32. package/dist/chunks/{resource-management-panel-D2oAQkKi.js → resource-management-panel-Cj19pw9M.js} +145 -145
  33. package/dist/chunks/switch-BvTzw2AW.js +173 -0
  34. package/dist/chunks/{switch-j3AThLFk.js → switch-De31SR3q.js} +2752 -2717
  35. package/dist/chunks/typescript-Cmizj1hi.js +446 -0
  36. package/dist/chunks/typescript-H1EwZsOb.js +159820 -0
  37. package/dist/chunks/use-create-flow-overlay-state-BTQiKRD1.js +26 -0
  38. package/dist/chunks/{use-create-flow-overlay-state-CP6GDQAX.js → use-create-flow-overlay-state-IcHP0l39.js} +150 -151
  39. package/dist/chunks/{use-visual-utils-CSXU-96k.js → use-visual-utils-DQ5zGYD2.js} +13 -13
  40. package/dist/chunks/{use-visual-utils-NpOW5uZ1.js → use-visual-utils-XF-AqV8o.js} +1 -1
  41. package/dist/chunks/{validators-DvTxl9i0.js → validators-DDAweCzB.js} +67 -48
  42. package/dist/chunks/validators-odlRJblR.js +2 -0
  43. package/dist/dashboard/index.cjs +1 -1
  44. package/dist/dashboard/index.js +1 -1
  45. package/dist/dashboard-authoring/index.cjs +3 -3
  46. package/dist/dashboard-authoring/index.js +907 -527
  47. package/dist/data-app-builder/index.cjs +1 -0
  48. package/dist/data-app-builder/index.js +4 -0
  49. package/dist/data-app-builder-browser-runtime/index.cjs +1 -0
  50. package/dist/data-app-builder-browser-runtime/index.js +10 -0
  51. package/dist/data-app-sdk/index.cjs +1 -1
  52. package/dist/data-app-sdk/index.js +208 -196
  53. package/dist/format-utils/index.cjs +4 -4
  54. package/dist/format-utils/index.js +22 -21
  55. package/dist/index.cjs +1 -1
  56. package/dist/index.js +14 -14
  57. package/dist/style.css +1 -1
  58. package/dist/surfboard/index.cjs +1 -1
  59. package/dist/surfboard/index.js +2 -2
  60. package/dist/types/analytics-protocol.d.ts +1 -0
  61. package/dist/types/dashboard-authoring.d.ts +79 -2
  62. package/dist/types/dashboard.d.ts +17 -2
  63. package/dist/types/data-app-builder-browser-runtime.d.ts +185 -0
  64. package/dist/types/data-app-builder.d.ts +630 -0
  65. package/dist/types/data-app-sdk.d.ts +15 -1
  66. package/dist/types/format-utils.d.ts +25 -0
  67. package/dist/types/main.d.ts +67 -10
  68. package/dist/types/shared.d.ts +17 -2
  69. package/dist/types/surfboard.d.ts +17 -2
  70. package/dist/types/types.d.ts +32 -3
  71. package/package.json +11 -1
  72. package/dist/chunks/dashboard-briefing-launcher-DguNfFr8.js +0 -106
  73. package/dist/chunks/dashboard-json-DiBd65Xf.js +0 -1
  74. package/dist/chunks/date-formatter-D9Bvw5Qk.js +0 -1
  75. package/dist/chunks/date-formatter-DyIOb6uC.js +0 -333
  76. package/dist/chunks/edit-dashboard-visual-BC9eOc4U.js +0 -178
  77. package/dist/chunks/index-B1-46PoR.js +0 -1303
  78. package/dist/chunks/save-BY7WF62U.js +0 -21
  79. package/dist/chunks/save-Cv_XRb94.js +0 -6
  80. package/dist/chunks/switch-5aQ_jcLH.js +0 -168
  81. package/dist/chunks/use-create-flow-overlay-state-BQPXP0AM.js +0 -26
  82. package/dist/chunks/validators-DJUMR5An.js +0 -2
@@ -1,26 +0,0 @@
1
- "use strict";const s=require("./switch-5aQ_jcLH.js"),v=require("react"),p=require("./index-B1-46PoR.js"),e=require("react/jsx-runtime");require("./index-BxM99sFL.js");const re=require("./use-visual-utils-NpOW5uZ1.js"),he=require("./save-Cv_XRb94.js");/**
2
- * @license lucide-react v0.453.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const Ne=s.createLucideIcon("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
7
- * @license lucide-react v0.453.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const ge=s.createLucideIcon("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);/**
12
- * @license lucide-react v0.453.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const be=s.createLucideIcon("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/**
17
- * @license lucide-react v0.453.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const De=s.createLucideIcon("Rows3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]);/**
22
- * @license lucide-react v0.453.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const Ee=s.createLucideIcon("SendHorizontal",[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]]);function we(){const l=s.useEditorStore(h=>h.card.dataSource),{setSelectedConnectionId:a,setSelectedDatabaseName:i,setSelectedSchemaName:d,setSelectedTableName:x,setSelectedDatamodelId:u}=s.useEditorActions();v.useEffect(()=>{var D;if(!l)return;const{tableName:h,schemaName:y,databaseName:g,connectionId:j}=p.extractTableMetadata(l),b=(D=l.selectedEntities)==null?void 0:D[0],C=(b==null?void 0:b.type)==="model"&&"id"in b?b.id:"";a(j||""),i(g||""),d(y||""),x(h||""),u(C)},[l,a,i,d,x,u])}function ae(){var g,j;const l=s.useEditorStore(b=>b.card),a=s.useEditorStore(b=>b.frame),i=v.useMemo(()=>p.findCustomVisualConfigCard(a,l),[a,l]),{manifest:d}=p.useCustomVisual(((g=i==null?void 0:i.customCardPreferences)==null?void 0:g.url)||""),x=v.useMemo(()=>{var b;return(b=d==null?void 0:d.visuals)==null?void 0:b.find(m=>{var C;return m.name===((C=i==null?void 0:i.customCardPreferences)==null?void 0:C.componentName)})},[d,(j=i==null?void 0:i.customCardPreferences)==null?void 0:j.componentName]),u=p.resolveMultiInputType(i,x),h=v.useMemo(()=>p.getCustomVisualInputCards({frame:a,configCard:i,isMultiInputVisual:u==="multiple"}),[a,i,u]),y=v.useMemo(()=>{const b=h.findIndex(m=>(m==null?void 0:m.id)===l.id);return b<0?-1:p.getSlotIndexForCard(l,b)},[h,l]);return v.useMemo(()=>!i||u!=="multiple"||y<0?l.type:p.getEffectiveCardTypeForSlot(l,y,x==null?void 0:x.slots)??l.type,[i,u,y,l,x==null?void 0:x.slots])}function Ve({type:l,isLinked:a,className:i,showLabel:d=!1,showLocal:x=!1}){const u=s.useDashboardStore(E=>E.selectedFrameId),h=p.useManagementStore(E=>E.selectedVisual),y=s.useEditorStore(E=>E.frame);let g;if(l)g=l;else if(a!==void 0)g=a?"linked":"library";else if(!!!(y!=null&&y.visualId||h!=null&&h.id)&&u)g="local";else if(h&&!u)g="library";else if(y!=null&&y.visualId&&u)g="linked";else if(h!=null&&h.id&&u)g="library";else return null;if(g==="local"&&!x)return null;const j={local:"border-slate-200/70 bg-slate-50/80 text-slate-700 shadow-sm hover:bg-slate-100/80 dark:border-slate-700 dark:bg-slate-900/70 dark:text-slate-200 dark:hover:bg-slate-800/80",linked:"border-purple-200/70 bg-gradient-to-r from-purple-50/50 to-purple-100/30 text-purple-900 shadow-sm hover:from-purple-100/60 hover:to-purple-100/50 hover:shadow-md dark:border-purple-800/50 dark:from-purple-950/40 dark:to-purple-900/30 dark:text-purple-100 dark:hover:from-purple-950/60 dark:hover:to-purple-900/50",library:"border-blue-200/70 bg-gradient-to-r from-blue-50/50 to-blue-100/30 text-blue-900 shadow-sm hover:from-blue-100/60 hover:to-blue-100/50 hover:shadow-md dark:border-blue-800/50 dark:from-blue-950/40 dark:to-blue-900/30 dark:text-blue-100 dark:hover:from-blue-950/60 dark:hover:to-blue-900/50"},b={local:"Local to this dashboard: Changes made here only affect this dashboard copy.",linked:"Linked to library: Changes made here update the library visual and all linked instances.",library:"Library visual: Share and reuse this visual across multiple dashboards."},m={local:"border-slate-200 bg-slate-50 text-slate-900 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100",linked:"border-purple-200 bg-purple-50 text-purple-900 dark:border-purple-800 dark:bg-purple-950 dark:text-purple-100",library:"border-blue-200 bg-blue-50 text-blue-900 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-100"},C={local:"fill-slate-50 dark:fill-slate-900",linked:"fill-purple-50 dark:fill-purple-950",library:"fill-blue-50 dark:fill-blue-950"},D={local:e.jsx("span",{className:"h-2 w-2 rounded-full bg-current/70"}),linked:e.jsx(be,{className:"h-3.5 w-3.5"}),library:e.jsx(ge,{className:"h-3.5 w-3.5"})},N={local:"Local",linked:"Linked",library:"Library"};return e.jsx(s.TooltipProvider,{children:e.jsxs(s.Tooltip,{delayDuration:300,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsxs(p.Badge,{variant:"outline",className:s.cn("cursor-help select-none transition-all",j[g],i),children:[D[g],d&&e.jsx("span",{className:"ml-1 text-xs font-medium leading-none",children:N[g]})]})}),e.jsxs(s.TooltipContent,{side:"bottom",className:s.cn("max-w-xs",m[g]),children:[e.jsx(s.TooltipArrow,{className:C[g]}),e.jsx("p",{children:b[g]})]})]})})}function Te(l,a){return{...l,sql:"",python:"",config:void 0,customCfg:"",preferences:{},interactionConfig:void 0,linkedInteractionTargetOverrides:void 0,dynamicCardPreferences:void 0,customCardPreferences:a?l.customCardPreferences:void 0,visualizationMode:"builtin",type:a?l.type:"bar"}}function le(l){const a=s.getDynamicFrameSaveIssue(l);return a?(p.ue.error(a),!1):!0}function Ie({className:l,variant:a="outline"}){const i=s.useEditorStore(u=>u.onSave),{getUpdatedFrame:d}=re.useVisualUtils();function x(){const u=d();le(u)&&(i==null||i(u))}return e.jsxs(s.Button,{onClick:x,className:l,size:"xs",variant:a,children:[e.jsx(s.Check,{className:"h-3.5 w-3.5"}),"Accept"]})}function Le({className:l,variant:a="default"}){const i=p.useQueryClient(),[d,x]=v.useState(!1),u=s.useDashboardStore(C=>C.actions.setIsDashboardPanelOpen),{setIsVisualEditing:h}=s.useDashboardActions(),{getUpdatedFrame:y}=re.useVisualUtils(),g=p.useSelectedVisual(),j=s.useEditorStore(C=>C.frame),b=p.useUpdateVisualMutation(),m=()=>{const C=y();if(!le(C))return;const D=(j==null?void 0:j.visualId)||(g==null?void 0:g.id);if(!D){p.ue.error("No visual to save");return}x(!0),b.mutate({visualId:D,data:{frameObject:C}},{onSuccess:()=>{x(!1),u(!0),p.ue.success("Visual updated successfully"),i.invalidateQueries({queryKey:["resource-by-id","visual",D],exact:!0})},onError:()=>{x(!1),p.ue.error("Failed to update visual")}})};return e.jsx(s.Button,{onClick:m,className:l,size:"xs",variant:a,children:d?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving"]}):e.jsxs(e.Fragment,{children:[e.jsx(he.Save,{className:"h-3.5 w-3.5"}),"Save to Library"]})})}function Fe({className:l}){const a=p.useQueryClient(),[i,d]=v.useState(!1),x=p.useSelectedVisual(),u=s.useEditorStore(N=>N.frame),h=s.useDashboardStore(N=>N.selectedSheetId),y=s.useDashboardStore(N=>N.dashboard),{updateFrame:g,setIsVisualEditing:j}=s.useDashboardActions(),{getUpdatedFrame:b}=re.useVisualUtils(),m=p.useUpdateVisualMutation(),C=p.useResolveExistingFrameSemanticExecutionPayload(),D=async()=>{if(!h){p.ue.error("No sheet selected");return}const N=(u==null?void 0:u.visualId)||(x==null?void 0:x.id);if(!N){p.ue.error("No visual to update");return}d(!0);try{const E=b();if(!le(E)){d(!1);return}const F={...E,visualId:N},Q=p.findDashboardFrameById(y,F.id),U=await C(F,{previousFrame:Q});await m.mutateAsync({visualId:N,data:{frameObject:E}}),g(h,F,{semanticExecutionPayload:U}),a.invalidateQueries({queryKey:["visuals"]}),a.invalidateQueries({queryKey:["visual",N]}),p.ue.success("Saved to library and applied locally"),setTimeout(()=>{j(!1)},300)}catch(E){console.error("Failed to save and apply:",E),p.ue.error(E instanceof Error?E.message:"Failed to save and apply changes")}finally{d(!1)}};return e.jsx(s.Button,{onClick:D,className:l,size:"xs",variant:"default",disabled:i,children:i?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(he.Save,{className:"h-3.5 w-3.5"}),"Save & Apply"]})})}function _e({className:l}){const{setTempQueryData:a,setSqlGen:i}=s.useEditorActions(),d=p.useQueryClient(),x=s.useEditorStore(m=>m.tempQueryData),u=s.useEditorStore(m=>m.onClose),h=s.useEditorStore(m=>m.card),y=ae(),g=v.useMemo(()=>y!==h.type?{...h,type:y}:h,[h,y]),{queryKey:j}=p.useEditorCardQuery(g);function b(){if(x){const{queryKey:m,queryData:C}=x;m&&C&&d.setQueryData(m,C)}i({}),u==null||u()}return e.jsxs(s.Button,{onClick:b,className:l,size:"xs",variant:"outline",children:[e.jsx(s.X,{className:"h-3.5 w-3.5"}),"Close"]})}function Be({label:l="Clear",variant:a="secondary",className:i}={}){const{setTempQueryData:d}=s.useEditorActions(),x=p.useQueryClient(),u=s.useEditorStore(q=>q.tempQueryData),h=s.useEditorStore(q=>q.card),y=ae(),g=v.useMemo(()=>y!==h.type?{...h,type:y}:h,[h,y]),{queryKey:j}=p.useEditorCardQuery(g),{setCardSql:b,setSqlGen:m,setCardPython:C,setCardCustomCfg:D,setCardPreferences:N,clearQueryConfig:E,setCardConfig:F,setCardType:Q,setFrame:U,setCard:X,setActiveTabCardId:P}=s.useEditorActions();function W(){var Y,G,L,H;const q=x.getQueryData(j);u!=null&&u.queryData||d({queryKey:j,queryData:q}),x.setQueryData(j,null),x.removeQueries({queryKey:j,exact:!0}),b(""),m({}),E(),F(void 0),C(""),D(""),N({});const r=s.useEditorStore.getState().frame,T=s.useEditorStore.getState().card,I=p.findCustomVisualConfigCard(r,T),A=((Y=I==null?void 0:I.customCardPreferences)==null?void 0:Y.visualType)==="multiple"||!!((G=I==null?void 0:I.customCardPreferences)!=null&&G.dataInputCardIds)||(((L=I==null?void 0:I.customCardPreferences)==null?void 0:L.minInputs)||0)>1||(((H=I==null?void 0:I.customCardPreferences)==null?void 0:H.maxInputs)||0)>1,M=Te(T,A);U({...r,cards:r.cards.map(O=>O.id===M.id?M:O)}),P(M.id),X(M),A||Q("bar")}return e.jsxs(s.Button,{onClick:W,className:i,size:"xs",variant:a,children:[e.jsx(s.X,{className:"h-3.5 w-3.5"}),l]})}function ye(l){const{control:a,onChange:i}=l;return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Label"}),e.jsx(s.Input,{size:"xs",value:a.label,placeholder:"Control label",onChange:d=>i(d.target.value)})]})}function qe(l){const{currentStep:a,labels:i}=l;return e.jsx("div",{className:"sticky top-0 z-10 -mx-1 border-b border-border/60 bg-background/95 px-1 pb-2.5 pt-1 backdrop-blur supports-[backdrop-filter]:bg-background/85",children:e.jsx("div",{className:"flex flex-wrap items-center gap-2 sm:gap-2.5",children:i.map((d,x)=>{const u=x+1,h=u===a,y=u<a;return e.jsxs(v.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:s.cn("flex h-5 w-5 items-center justify-center rounded-full border text-[10px] font-medium tabular-nums",h?"border-foreground bg-foreground text-background":y?"border-foreground/30 bg-foreground/10 text-foreground":"border-border/60 bg-background text-muted-foreground"),children:u}),e.jsx("span",{className:s.cn("text-[12px]",h?"font-medium text-foreground":"text-muted-foreground"),children:d})]}),x<i.length-1?e.jsx("span",{className:"h-px w-4 bg-border/60 sm:w-6","aria-hidden":"true"}):null]},d)})})})}function J(l){const{secondary:a,tertiary:i,primary:d}=l;return e.jsxs("div",{className:"sticky bottom-0 z-10 -mx-1 flex justify-end gap-2 border-t bg-background/95 px-1 pb-1 pt-3 backdrop-blur supports-[backdrop-filter]:bg-background/85",children:[a,i,d]})}function Ae(l){const{control:a,scope:i,detail:d}=l;return e.jsxs("div",{className:"flex items-start gap-2.5 rounded-control border border-border/60 bg-muted/30 px-3 py-2.5",children:[e.jsx(p.CircleCheck,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-foreground"}),e.jsxs("div",{className:"min-w-0 space-y-0.5",children:[e.jsx("div",{className:"text-[13px] font-medium text-foreground",children:a.label}),e.jsxs("div",{className:"text-[12px] text-muted-foreground",children:[s.getFriendlyTypeOption(a.type).label," ·"," ",s.getControlOptionPreview(a)," ·"," ",s.getPlacementLabel(i,a.placement)]}),d?e.jsx("div",{className:"text-[12px] text-muted-foreground",children:d}):null]})]})}function me(l){const{control:a,defaultValue:i,availableFieldChoices:d,availableMetricChoices:x,previewControlDefinitions:u,previewControlValues:h,onControlChange:y,onLabelChange:g,onDefaultValueChange:j,onBack:b,onNext:m,nextDisabled:C}=l;return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ye,{control:a,onChange:g}),e.jsx(p.ControlDefinitionOptionsEditor,{control:a,availableFieldChoices:d,availableMetricChoices:x,previewControlDefinitions:u,previewControlValues:h,controlLifecycle:"create",onChange:y}),e.jsx(p.ControlDefaultValueEditor,{control:a,value:i,onChange:j,allowNoDefault:!0,allowCardDefault:!0,hint:"This is the value viewers will see first.",previewControlDefinitions:u,previewControlValues:h}),e.jsx(J,{secondary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:b,children:"Back"}),primary:e.jsx(s.Button,{type:"button",size:"xs",onClick:m,disabled:C,children:"Next"})})]})}const Me=new Set(["grain_selector","aggregation_selector","field_selector","metric_selector"]);function xe(l){const{text:a,ariaLabel:i}=l,[d,x]=v.useState(!1);return e.jsxs("button",{type:"button","aria-label":i,onClick:async()=>{try{await navigator.clipboard.writeText(a),x(!0),setTimeout(()=>x(!1),1200)}catch(u){console.error("Failed to copy",u)}},className:"group flex w-full items-center justify-between gap-2 rounded-control bg-muted/40 px-2 py-1 text-left transition-colors hover:bg-muted/60 focus-visible:bg-muted/60 focus-visible:outline-none",children:[e.jsx("code",{className:"min-w-0 truncate font-mono text-[12px] text-foreground",children:a}),e.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100",children:d?"Copied":"Click to copy"})]})}function fe(l){const{control:a,scope:i,createdReference:d,explorerContent:x,sqlDescription:u,summaryDetail:h,onBack:y,onCancel:g,onDone:j}=l,b=Me.has(a.type),m=d.match(/\[\[param\.(.+?)\]\]/),C=m?`{{ param('${m[1]}') }}`:"";return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ae,{control:a,scope:i,detail:h}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[13px] font-medium text-foreground",children:"How cards use this control"}),e.jsxs("div",{className:"divide-y divide-border/60 overflow-hidden rounded-control border border-border/60",children:[b?e.jsxs("div",{className:"space-y-1 px-3 py-2.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Explorer cards"}),e.jsx("div",{className:"text-[12px] text-muted-foreground",children:x})]}):null,e.jsxs("div",{className:"space-y-1.5 px-3 py-2.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"SQL cards"}),e.jsx(xe,{text:d,ariaLabel:"Copy SQL control reference"}),C?e.jsx(xe,{text:C,ariaLabel:"Copy Jinja control reference"}):null,e.jsxs("p",{className:"text-[12px] text-muted-foreground",children:[u," ",e.jsx("a",{href:"https://docs.semaphor.cloud/docs/concepts/template-expressions",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Template expressions docs"}),"."]})]})]})]}),e.jsx(J,{secondary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:y,children:"Back"}),tertiary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:g,children:"Cancel"}),primary:e.jsx(s.Button,{type:"button",size:"xs",onClick:j,children:"Done"})})]})}function Oe(l){const a=s.createBlankControl(l.scope,l.existingControls,l.reservedIds),i=l.type===a.type?{...a,label:s.DEFAULT_LABEL_BY_TYPE[l.type]}:{...s.applyControlTypeChange({controls:[{...a,label:s.DEFAULT_LABEL_BY_TYPE[l.type]}],controlId:a.id,nextType:l.type}).controls[0],label:s.DEFAULT_LABEL_BY_TYPE[l.type]};return{step:2,control:i,defaultValue:s.getDefaultValueForType(i,void 0)}}function ze({scope:l,controls:a,reservedControlIds:i,defaultValues:d,onChange:x,emptyMessage:u,initialCreateFlow:h=!1,usageByControlId:y,availableFieldChoices:g,availableMetricChoices:j,structuralParticipants:b,structuralParticipantIdsByControlId:m,card:C,allowedControlTypes:D,onCreateFlowActiveChange:N,onCreateFlowComplete:E}){const F=v.useMemo(()=>new Set(i||[]),[i]),Q=s.getPlacementOptionsForScope(l),U=s.getDefaultPlacement(l),[X,P]=v.useState(null),[W,q]=v.useState(null),[r,T]=v.useState(()=>h?{step:1,control:s.createBlankControl(l,a,Array.from(F))}:null),I=v.useRef({}),A=v.useRef(void 0),M=v.useRef(h),Y=v.useMemo(()=>{const t=s.getFriendlyControlTypeOptions({scope:l,card:C});if(!D)return t;const o=new Set(D);return t.filter(n=>o.has(n.value))},[D,C,l]),G=v.useCallback(t=>{const o=s.getFriendlyControlTypeOptions({scope:l,card:C,includeType:D?void 0:t});if(!D)return o;const n=new Set(D);return o.filter(c=>n.has(c.value))},[D,C,l]),L=v.useCallback(t=>l==="dashboard"&&(t==="field_selector"||t==="metric_selector"),[l]),H=v.useMemo(()=>r?s.getEligibleParticipantsForStructuralControl(b||[],r.control.type):[],[r,b]),O=v.useMemo(()=>{if(!r)return{fields:g||[],metrics:j||[]};if(!L(r.control.type))return{fields:g||[],metrics:j||[]};const t=r.selectedCardIds||[],o=s.getCompatibleStructuralChoiceCatalog({controlType:r.control.type,participants:b||[],selectedCardIds:t});return{fields:r.control.type==="field_selector"?o.choices.map(n=>({option:n,target:o.fieldTargetMap[n.value]})):[],metrics:r.control.type==="metric_selector"?o.choices.map(n=>({option:n,target:o.metricTargetMap[n.value]})):[]}},[g,j,r,L,b]);v.useEffect(()=>{N==null||N(!!r)},[r,N]),v.useEffect(()=>{const t=h&&!M.current;M.current=h,t&&(T({step:1,control:s.createBlankControl(l,a,Array.from(F))}),q(null),P(null))},[a,h,F,l]);const ve=t=>{if(!L(t.type))return{fields:g||[],metrics:j||[]};const o=(m==null?void 0:m[t.id])||[];if(o.length===0)return{fields:g||[],metrics:j||[]};const n=s.getCompatibleStructuralChoiceCatalog({controlType:t.type,participants:b||[],selectedCardIds:o});return{fields:t.type==="field_selector"?n.choices.map(c=>({option:c,target:n.fieldTargetMap[c.value]})):[],metrics:t.type==="metric_selector"?n.choices.map(c=>({option:c,target:n.metricTargetMap[c.value]})):[]}},ne=t=>{if(!L(t.control.type))return{nextControl:t.control,cardBindingsById:void 0};const o=(m==null?void 0:m[t.control.id])||[],n=s.getCompatibleStructuralChoiceCatalog({controlType:t.control.type,participants:b||[],selectedCardIds:t.nextSelectedCardIds}),c=s.reconcileStructuralControlChoices({control:t.control,choices:n.choices}),S=Object.fromEntries(o.filter(k=>!t.nextSelectedCardIds.includes(k)).map(k=>[k,void 0]));return t.nextSelectedCardIds.length>0&&c.source.kind==="manual"&&c.source.options.length>0&&Object.assign(S,s.buildStructuralControlBindingsForParticipants({control:c,participants:b||[],selectedCardIds:t.nextSelectedCardIds})),{nextControl:c,cardBindingsById:S}},B=v.useCallback((t,o=d,n={type:"update"})=>{const c=t.map(S=>(s.resolveAuthoringControlDefaultValue({control:S,defaultValues:o}),s.syncSqlQueryControlExecutionRequirement(S)));x(c,o,n)},[d,x]),K=(t,o)=>{const n=a.find(V=>V.id===t);let c=a.map(V=>V.id!==t?V:o(V));const S=c.find(V=>V.id===t);let k,f;if(S&&l==="dashboard"&&(S.type==="field_selector"||S.type==="metric_selector")){const V=(m==null?void 0:m[S.id])||[],R=ne({control:S,nextSelectedCardIds:V});c=c.map(z=>z.id===t?R.nextControl:z),k=R.cardBindingsById,f=[S.id]}else if(n&&l==="dashboard"&&(n.type==="field_selector"||n.type==="metric_selector")){const V=(m==null?void 0:m[n.id])||[];k=Object.fromEntries(V.map(R=>[R,void 0])),f=[n.id]}const w=c.find(V=>V.id===t);let _=d;if(n&&w){const V=s.resolveAuthoringControlDefaultValue({control:n,defaultValues:d});n.source.kind==="manual"&&w.source.kind==="sql_query"&&(I.current[t]=V);const R=V===void 0&&n.source.kind==="sql_query"&&w.source.kind==="manual"?I.current[t]:V,z=s.getNextEditedControlDefaultValue({previousControl:n,nextControl:w,currentDefaultValue:R});w.source.kind==="manual"&&(I.current[t]=z),d&&(_={...d},z===void 0?delete _[t]:_[t]=z),c=c.map(pe=>pe.id===t?{...w,defaultValue:z}:pe)}B(c,_,{type:"update",cardBindingsById:k,affectedBindingControlIds:f})},Ce=(t,o)=>{if(!o.trim())return;const n=p.normalizeDashboardInputVariableName(o);if(n===t||F.has(n)||a.some(k=>k.id===n&&k.id!==t))return;const c=a.map(k=>k.id===t?{...k,id:n}:k);if(!d){B(c,void 0,{type:"rename",oldId:t,newId:n});return}const S={...d};Object.prototype.hasOwnProperty.call(S,t)&&(S[n]=S[t],delete S[t]),B(c,S,{type:"rename",oldId:t,newId:n})},je=t=>{const o=a.filter(c=>c.id!==t);if(!d){B(o,void 0,{type:"remove",controlId:t});return}const n={...d};delete n[t],B(o,n,{type:"remove",controlId:t})},Se=v.useCallback(()=>{A.current=void 0,T({step:1,control:s.createBlankControl(l,a,Array.from(F))}),q(null),P(null)},[a,F,l]),$=t=>{T(o=>o&&(()=>{const n=t(o.control);o.control.source.kind==="manual"&&n.source.kind==="sql_query"&&(A.current=o.defaultValue);const c=o.defaultValue===void 0&&o.control.source.kind==="sql_query"&&n.source.kind==="manual"?A.current:o.defaultValue,S=s.getNextEditedControlDefaultValue({previousControl:o.control,nextControl:n,currentDefaultValue:c});return n.source.kind==="manual"&&(A.current=S),{...o,control:n,defaultValue:S}})())},oe=t=>{T(o=>o&&(o.control.source.kind==="manual"&&(A.current=t),{...o,defaultValue:t}))},Z=(()=>{if(!r)return!1;if(r.step===2&&L(r.control.type))return(r.selectedCardIds||[]).length>0;if(r.step!==2&&r.step!==3||!r.control.label.trim())return!1;const o=r.control.source.kind==="sql_query"?r.control:s.ensureManualSource(r.control);if(o.source.kind==="manual"&&(s.needsManualOptions(o)&&o.source.options.length===0||o.source.options.some(c=>c.label.trim().length===0||c.value.trim().length===0)))return!1;if(o.source.kind==="sql_query"){const{connectionId:n,sql:c,valueColumn:S}=o.source;return n.trim().length>0&&c.trim().length>0&&S.trim().length>0}return s.hasConcreteDefaultValue(s.getDefaultValueForType(o,r.defaultValue))})(),ie=()=>{var k;if(!r)return;const t=s.ensureManualSource(r.control),o=s.deriveUniqueControlId({label:t.label,fallbackId:t.id,existingControls:a,reservedIds:Array.from(F)}),n={...t,id:o},c=l==="dashboard"&&(n.type==="field_selector"||n.type==="metric_selector")&&((k=r.selectedCardIds)!=null&&k.length)?s.buildStructuralControlBindingsForParticipants({control:n,participants:b||[],selectedCardIds:r.selectedCardIds}):void 0,S=s.getDefaultValueForType(n,r.defaultValue);T({step:l==="dashboard"&&(n.type==="field_selector"||n.type==="metric_selector")?4:3,control:n,defaultValue:S,createdControlId:o,selectedCardIds:r.selectedCardIds,cardBindingsById:c})},ee=v.useCallback(()=>{T(null)},[]),de=v.useCallback(()=>{if(!(r!=null&&r.createdControlId)){T(null);return}const t=r.control,o=r.createdControlId,n=s.getDefaultValueForType(t,r.defaultValue);if(d){const c={...d};n===void 0?delete c[o]:c[o]=n,B([...a,{...t,defaultValue:n}],c,{type:"add",cardBindingsById:r.cardBindingsById})}else B([...a,{...t,defaultValue:n}],void 0,{type:"add",cardBindingsById:r.cardBindingsById});q(o),T(null),E==null||E()},[a,r,d,B,E]),ke=r?L(r.control.type)?["Choose type","Select cards","Configure","Finish"]:["Choose type","Configure","Finish"]:[],ce=r!=null&&r.createdControlId?`[[param.${r.createdControlId}]]`:r?`[[param.${s.slugifyControlValue(r.control.label)||r.control.id}]]`:"",te=s.buildAuthoringPreviewControlValues({controls:a,defaultValues:d}),se=r?[...a,r.control]:a,ue=r?s.buildAuthoringPreviewControlValues({controls:se,defaultValues:d,overrides:[{controlId:r.control.id,value:r.defaultValue}]}):te;return e.jsxs("div",{className:"space-y-4",children:[r?e.jsxs("div",{className:"space-y-4 pb-1",children:[e.jsx(qe,{currentStep:r.step,labels:ke}),r.step===1&&(()=>{const t=new Set(["grain_selector","aggregation_selector","field_selector","metric_selector"]),o=new Set(["date","text"]),n=Y.filter(k=>!t.has(k.value)&&!o.has(k.value)),c=Y.filter(k=>t.has(k.value)),S=k=>e.jsxs("button",{type:"button",className:"rounded-control border border-border/60 bg-background px-3 py-2.5 text-left transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:outline-none",onClick:()=>T(Oe({scope:l,existingControls:a,reservedIds:Array.from(F),type:k.value})),children:[e.jsx("div",{className:"text-[13px] font-medium text-foreground",children:k.label}),e.jsx("p",{className:"mt-0.5 text-[12px] text-muted-foreground",children:k.description})]},k.value);return e.jsxs("div",{className:"space-y-4",children:[l==="card"&&(C==null?void 0:C.sql)==null?e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Explorer cards support displayed metric, group by field, aggregation, and time grain controls here."}):null,n.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Input controls"}),e.jsx("div",{className:"grid gap-1.5 sm:grid-cols-2",children:n.map(S)})]}),c.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Data-driven controls"}),e.jsx("div",{className:"grid gap-1.5 sm:grid-cols-2",children:c.map(S)})]}),e.jsx(J,{secondary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:ee,children:"Back to controls"})})]})})(),r.step===2&&L(r.control.type)&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(ye,{control:r.control,onChange:t=>$(o=>({...o,label:t}))}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Choose which cards should respond to this shared control."})]}),H.length===0?e.jsx("div",{className:"rounded-control border border-border/60 bg-muted/30 px-3 py-2.5 text-[12px] text-muted-foreground",children:"No eligible cards are available yet. Add compatible metrics or group-by fields to cards first."}):e.jsx("div",{className:"space-y-1 rounded-control border border-border/60 bg-background p-2",children:H.map(t=>{const o=(r.selectedCardIds||[]).includes(t.cardId);return e.jsxs("label",{className:"flex items-start gap-2 rounded-control px-1.5 py-1 text-[13px] hover:bg-muted/40",children:[e.jsx(p.Checkbox,{checked:o,onCheckedChange:n=>T(c=>c&&{...c,selectedCardIds:n===!0?[...c.selectedCardIds||[],t.cardId]:(c.selectedCardIds||[]).filter(S=>S!==t.cardId)})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-foreground",children:t.title}),e.jsx("div",{className:"text-[12px] text-muted-foreground",children:r.control.type==="field_selector"?`${t.fieldChoices.length} compatible group-by fields`:`${t.metricChoices.length} compatible metrics`})]})]},t.cardId)})}),e.jsx(J,{secondary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:()=>T(t=>t&&{...t,step:1,selectedCardIds:[]}),children:"Back"}),primary:e.jsx(s.Button,{type:"button",size:"xs",onClick:()=>T(t=>t&&{...t,step:3}),disabled:!Z,children:"Next"})})]}),r.step===2&&!L(r.control.type)&&e.jsx(me,{control:r.control,defaultValue:r.defaultValue,availableFieldChoices:O.fields,availableMetricChoices:O.metrics,previewControlDefinitions:se,previewControlValues:ue,onControlChange:t=>$(()=>t),onLabelChange:t=>$(o=>({...o,label:t})),onDefaultValueChange:oe,onBack:()=>T(t=>t&&{...t,step:1}),onNext:ie,nextDisabled:!Z}),r.step===3&&L(r.control.type)&&e.jsx(me,{control:r.control,defaultValue:r.defaultValue,availableFieldChoices:O.fields,availableMetricChoices:O.metrics,previewControlDefinitions:se,previewControlValues:ue,onControlChange:t=>$(()=>t),onLabelChange:t=>$(o=>({...o,label:t})),onDefaultValueChange:oe,onBack:()=>T(t=>t&&{...t,step:2}),onNext:ie,nextDisabled:!Z}),r.step===3&&!L(r.control.type)&&e.jsx(fe,{control:r.control,scope:l,createdReference:ce,explorerContent:e.jsxs(e.Fragment,{children:["Open the card and use"," ",e.jsx("span",{className:"font-medium text-foreground",children:"Settings → Controls"})," ","to choose what this control changes."]}),sqlDescription:"Reference this control directly in the SQL editor.",onBack:()=>T(t=>t&&{...t,step:2}),onCancel:ee,onDone:de}),r.step===4&&L(r.control.type)&&e.jsx(fe,{control:r.control,scope:l,createdReference:ce,summaryDetail:e.jsxs(e.Fragment,{children:["Used by ",(r.selectedCardIds||[]).length," selected card",(r.selectedCardIds||[]).length===1?"":"s"]}),explorerContent:e.jsx(e.Fragment,{children:"Selected cards have been set up to respond to this control automatically."}),sqlDescription:"SQL cards can still reference this control directly in the SQL editor.",onBack:()=>T(t=>t&&{...t,step:3}),onCancel:ee,onDone:de})]}):null,!r&&a.length===0?e.jsx("div",{className:"rounded-md border border-dashed p-3 text-sm text-muted-foreground",children:u}):null,!r&&a.map(t=>{const o=ve(t),n=y==null?void 0:y[t.id],c=s.resolveAuthoringControlDefaultValue({control:t,defaultValues:d}),S=W===t.id,k="inline-flex shrink-0 items-center rounded-[4px] border border-border/60 bg-muted/40 px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground";return e.jsxs("div",{className:"rounded-control border border-border/60",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[e.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-start gap-2 rounded-control text-left focus:outline-none focus-visible:bg-muted/40",onClick:()=>q(f=>f===t.id?null:t.id),children:[S?e.jsx(s.ChevronDown,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(p.ChevronRight,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",children:t.label||"Untitled control"}),e.jsx("span",{className:k,children:s.getFriendlyTypeOption(t.type).label}),e.jsx("span",{className:k,children:s.getPlacementLabel(l,t.placement)})]}),e.jsxs("div",{className:"mt-0.5 text-[12px] text-muted-foreground",children:[s.getControlOptionPreview(t),n!=null&&n.status?` · ${n.status}`:""]})]})]}),e.jsx(s.Button,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 shrink-0 p-0 text-muted-foreground",onClick:()=>je(t.id),"aria-label":`Remove ${t.label}`,children:e.jsx(p.Trash2,{className:"h-3.5 w-3.5"})})]}),S&&e.jsxs("div",{className:"space-y-4 border-t border-border/60 px-3 py-3",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Label"}),e.jsx(s.Input,{size:"xs",value:t.label,placeholder:"Control label",onChange:f=>K(t.id,w=>({...w,label:f.target.value}))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Type"}),e.jsxs(s.Select,{value:t.type,onValueChange:f=>{const w=s.applyControlTypeChange({controls:a,controlId:t.id,nextType:f,defaultValues:d});B(w.controls,w.defaultValues)},children:[e.jsx(s.SelectTrigger,{size:"xs",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:G(t.type).map(f=>e.jsx(s.SelectItem,{value:f.value,children:f.label},f.value))})]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Show in"}),e.jsxs(s.Select,{value:t.placement||U,onValueChange:f=>K(t.id,w=>({...w,placement:f})),children:[e.jsx(s.SelectTrigger,{size:"xs",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:Q.map(f=>e.jsx(s.SelectItem,{value:f.value,children:f.label},f.value))})]})]})]}),L(t.type)?e.jsx(p.StructuralParticipantSelector,{type:t.type,participants:s.getEligibleParticipantsForStructuralControl(b||[],t.type).map(f=>({cardId:f.cardId,title:f.title,choiceCount:t.type==="field_selector"?f.fieldChoices.length:f.metricChoices.length})),selectedCardIds:(m==null?void 0:m[t.id])||[],onChange:f=>{const w=ne({control:t,nextSelectedCardIds:f}),_=a.map(V=>V.id===t.id?w.nextControl:V);B(_,d,{type:"update",cardBindingsById:w.cardBindingsById})}}):null,e.jsx(p.ControlDefinitionOptionsEditor,{control:t,availableFieldChoices:o.fields,availableMetricChoices:o.metrics,previewControlDefinitions:a,previewControlValues:te,controlLifecycle:"edit",onChange:f=>K(t.id,()=>f)}),t.initialValueStrategy==="saved_default"&&e.jsx(p.ControlDefaultValueEditor,{control:t,value:c,allowNoDefault:!0,allowCardDefault:!0,previewControlDefinitions:a,previewControlValues:te,onChange:f=>{const w=a.map(_=>_.id===t.id?{..._,defaultValue:f}:_);if(t.source.kind==="manual"&&(I.current[t.id]=f),d){const _={...d};f===void 0?delete _[t.id]:_[t.id]=f,B(w,_);return}B(w,void 0)}}),e.jsxs(p.Collapsible,{open:X===t.id,onOpenChange:f=>P(f?t.id:null),children:[e.jsx(p.CollapsibleTrigger,{asChild:!0,children:e.jsxs(s.Button,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 gap-1 text-muted-foreground hover:text-foreground",children:[X===t.id?e.jsx(s.ChevronDown,{className:"h-3.5 w-3.5"}):e.jsx(p.ChevronRight,{className:"h-3.5 w-3.5"}),"Advanced"]})}),e.jsxs(p.CollapsibleContent,{className:"space-y-3 pt-2",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Variable name"}),e.jsx(p.ControlIdInput,{controlId:t.id,onCommit:f=>Ce(t.id,f)},t.id)]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Initial value"}),e.jsxs(s.Select,{value:t.initialValueStrategy,onValueChange:f=>K(t.id,w=>({...w,initialValueStrategy:f})),children:[e.jsx(s.SelectTrigger,{size:"xs",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:s.INITIAL_VALUE_STRATEGY_OPTIONS.map(f=>e.jsx(s.SelectItem,{value:f.value,children:f.label},f.value))})]})]})]}),e.jsx(p.ControlVisibilitySettings,{control:t,onChange:f=>K(t.id,()=>f)})]})]})]})]},t.id)}),!r&&e.jsxs(s.Button,{type:"button",variant:"outline",size:"xs",onClick:Se,children:[e.jsx(p.Plus,{className:"h-3.5 w-3.5"}),"Add control"]})]})}function Re(l){const{open:a,onOpenChange:i,initialCreateFlowActive:d=!1,dismissMode:x="passive"}=l,u=a!==void 0,[h,y]=v.useState(!1),[g,j]=v.useState(d),b=u?a:h,m=v.useCallback(N=>{!N&&g&&x==="passive"||(u||y(N),N||j(!1),i==null||i(N))},[u,g,x,i]),C=v.useCallback(()=>{u||y(!1),j(!1),i==null||i(!1)},[u,i]);v.useEffect(()=>{b||j(!1)},[b]);const D=v.useCallback(N=>{g&&N.preventDefault()},[g]);return{forceClose:C,handleOpenChange:m,isCreateFlowActive:g,preventPassiveDismissDuringCreate:D,resolvedOpen:b,setIsCreateFlowActive:j}}exports.CircleX=Ne;exports.ControlDefinitionListEditor=ze;exports.EditorAcceptButton=Ie;exports.EditorCancelButton=_e;exports.EditorClearButton=Be;exports.Library=ge;exports.Link2=be;exports.Rows3=De;exports.SendHorizontal=Ee;exports.VisualBadge=Ve;exports.VisualSaveAndApplyButton=Fe;exports.VisualSaveButton=Le;exports.useCreateFlowOverlayState=Re;exports.useEffectiveEditorCardType=ae;exports.useSyncLegacyEditorState=we;
@@ -1,2 +0,0 @@
1
- "use strict";function s(e,i,n){return n?{code:e,message:i,path:n}:{code:e,message:i}}function p(e){const i=new Set;for(const n of e){if(i.has(n))return n;i.add(n)}return null}function t(e){return typeof e=="string"&&e.trim().length>0}function f(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function h(e,i,n,r={}){if(!e||typeof e!="object"){n.push(s("missing_source","Analytics intent needs a source.",i));return}if(e.kind==="semantic"){t(e.domainId)||n.push(s("missing_semantic_domain","Semantic source needs a domainId.",`${i}.domainId`)),t(e.datasetName)||n.push(s("missing_dataset_name","Semantic source needs a datasetName.",`${i}.datasetName`));return}if(e.kind==="physical"){t(e.connectionId)||n.push(s("missing_connection_id","Physical source needs a connectionId.",`${i}.connectionId`)),t(e.tableName)||n.push(s("missing_table_name","Physical source needs a tableName.",`${i}.tableName`));return}if(e.kind==="sql"){t(e.connectionId)||n.push(s("missing_connection_id","SQL source needs a connectionId.",`${i}.connectionId`)),r.requireSqlText!==!1&&!t(e.sql)&&n.push(s("missing_sql","SQL source needs SQL text.",`${i}.sql`));return}n.push(s("invalid_source_kind","Source kind is not supported.",i))}function y(e){var r,u,o,m;const i=[],n=[];return!e||typeof e!="object"?{ok:!1,errors:[s("invalid_analytics_intent","Analytics intent must be a structured object.")],warnings:n,repairHints:[{code:"invalid_analytics_intent",recommendedNextStep:"Send one structured analytics intent object with kind, source, and required fields."}]}:(e.version!==void 0&&e.version!==1&&i.push(s("invalid_version","Analytics intent version must be 1.","version")),h(e.source,"source",i,{requireSqlText:e.kind!=="sql"||!t(e.sql)}),e.kind==="metric"?(t(e.metric)||i.push(s("missing_metric","Metric intent needs a metric.","metric")),e.metrics!==void 0&&!Array.isArray(e.metrics)?i.push(s("invalid_metric_list","Metric intent metrics must be an array of metric names.","metrics")):Array.isArray(e.metrics)&&e.metrics.some(c=>!t(c))&&i.push(s("invalid_metric_list","Metric intent metrics must be an array of non-empty metric names.","metrics")),e.dimensions!==void 0&&!Array.isArray(e.dimensions)?i.push(s("invalid_metric_dimensions","Metric intent dimensions must be an array of field references.","dimensions")):Array.isArray(e.dimensions)&&e.dimensions.some(c=>!f(c)||!t(c.name))&&i.push(s("invalid_metric_dimensions","Metric intent dimensions must be an array of field references with names.","dimensions"))):e.kind==="records"?!Array.isArray(e.fields)||e.fields.length===0?i.push(s("missing_record_fields","Records intent needs at least one field.","fields")):e.fields.some(c=>!f(c)||!t(c.name))&&i.push(s("invalid_record_fields","Records intent fields must be field references with names.","fields")):e.kind==="inputOptions"?(!e.field||!t(e.field.name))&&i.push(s("missing_input_options_field","Input options intent needs a field.","field")):e.kind==="sql"?(((r=e.source)==null?void 0:r.kind)!=="sql"&&((u=e.source)==null?void 0:u.kind)!=="physical"&&i.push(s("invalid_sql_source","SQL analytics intent must use a SQL or physical source.","source")),t(e.sql)&&((o=e.source)==null?void 0:o.kind)==="sql"&&t(e.source.sql)&&_(e.sql)!==_(e.source.sql)&&i.push(s("conflicting_sql","SQL analytics intent cannot define different SQL text in source.sql and sql.","sql")),!t(e.sql)&&!(((m=e.source)==null?void 0:m.kind)==="sql"&&t(e.source.sql))&&i.push(s("missing_sql","SQL analytics intent needs SQL text.","sql"))):i.push(s("invalid_analytics_kind","Analytics kind is not supported.","kind")),{ok:i.length===0,errors:i,warnings:n,repairHints:g(i)})}function _(e){return e.replace(/\r\n/g,`
2
- `).trim()}function g(e){return e.map(i=>{switch(i.code){case"missing_source":return{code:i.code,fieldRole:"source",recommendedNextStep:"Provide a semantic, physical, or SQL source before executing analytics."};case"missing_metric":return{code:i.code,fieldRole:"metric",recommendedNextStep:"Choose one exact metric from the grounded schema candidates."};case"missing_record_fields":return{code:i.code,fieldRole:"dimension",recommendedNextStep:"Provide at least one field for the records intent."};case"missing_input_options_field":return{code:i.code,fieldRole:"input",recommendedNextStep:"Provide the exact field whose option values should be listed."};case"missing_sql":return{code:i.code,fieldRole:"sql",recommendedNextStep:"Provide bounded read-only SQL with an explicit outer LIMIT."};case"conflicting_sql":return{code:i.code,fieldRole:"sql",recommendedNextStep:"Use one canonical SQL text location for the intent; prefer top-level sql."};case"missing_semantic_domain":case"missing_dataset_name":case"missing_connection_id":case"missing_table_name":return{code:i.code,fieldRole:"source",recommendedNextStep:"Use grounded catalog metadata to fill the missing source reference."};default:return}}).filter(i=>!!i)}function q(e,i,n,r){if(!e||typeof e!="object"){n.push(s("invalid_view","Dashboard view must be an object.",i));return}if(t(e.title)||n.push(s("missing_view_title","Dashboard view needs a title.",i)),!e.presentation||typeof e.presentation!="object"){n.push(s("missing_presentation","Dashboard view needs a presentation.",`${i}.presentation`));return}if(e.presentation.kind==="text"){t(e.text)||r.push(s("missing_text_content","Text views should include text content.",`${i}.text`));return}if(!e.analytics){n.push(s("missing_view_analytics","Non-text dashboard views need analytics intent.",`${i}.analytics`));return}const u=y(e.analytics);for(const o of u.errors)n.push(s(o.code,o.message,`${i}.analytics${o.path?`.${o.path}`:""}`));for(const o of u.warnings)r.push(s(o.code,o.message,`${i}.analytics${o.path?`.${o.path}`:""}`))}function S(e){const i=[],n=[];if(!e||typeof e!="object")return{ok:!1,errors:[s("invalid_dashboard_intent","Dashboard intent must be a structured object.")],warnings:n};e.version!==1&&i.push(s("invalid_version","Dashboard intent version must be 1.")),e.kind!=="dashboard"&&i.push(s("invalid_kind","Experience intent kind must be dashboard.")),t(e.title)||i.push(s("missing_title","Dashboard intent needs a title.","title"));const r=Array.isArray(e.inputs)?e.inputs:[],u=p(r.filter(f).map(d=>d.id).filter(d=>typeof d=="string"));u&&i.push(s("duplicate_input_id",`Duplicate input id: ${u}.`,"inputs"));for(const[d,a]of r.entries()){const l=`inputs.${d}`;if(!f(a)){i.push(s("invalid_input","Dashboard input must be an object.",l));continue}t(a.id)||i.push(s("missing_input_id","Input needs an id.",`${l}.id`)),t(a.label)||i.push(s("missing_input_label","Input needs a label.",`${l}.label`)),(!a.field||!t(a.field.name))&&i.push(s("missing_input_field","Input needs a field.",`${l}.field`)),a.source&&h(a.source,`${l}.source`,i)}const o=Array.isArray(e.sections)?e.sections:[];o.length===0&&i.push(s("missing_sections","Dashboard intent needs at least one section.","sections"));const m=o.flatMap(d=>d&&typeof d=="object"&&Array.isArray(d.views)?d.views.filter(f).map(a=>a.id).filter(a=>!!a):[]),c=p(m);c&&i.push(s("duplicate_view_id",`Duplicate dashboard view id: ${c}.`,"sections"));for(const[d,a]of o.entries()){const l=`sections.${d}`;if(!a||typeof a!="object"){i.push(s("invalid_section","Dashboard section must be an object.",l));continue}if(t(a.title)||i.push(s("missing_section_title","Dashboard section needs a title.",l)),!Array.isArray(a.views)||a.views.length===0){i.push(s("missing_section_views","Dashboard section needs at least one view.",`${l}.views`));continue}for(const[b,v]of a.views.entries())q(v,`${l}.views.${b}`,i,n)}return{ok:i.length===0,errors:i,warnings:n}}exports.validateSemaphorAnalyticsIntent=y;exports.validateSemaphorDashboardIntent=S;