react-semaphor 0.1.459 → 0.1.461

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 (114) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +32 -32
  3. package/dist/brand-studio/index.cjs +1 -1
  4. package/dist/brand-studio/index.js +4 -4
  5. package/dist/briefings/index.cjs +1 -1
  6. package/dist/briefings/index.js +4 -4
  7. package/dist/chunks/{analyze-result-contract-BbRJ-C06.js → analyze-result-contract-DROq4vgY.js} +1 -1
  8. package/dist/chunks/{analyze-result-contract-LPDNldic.cjs → analyze-result-contract-DSGoFuXQ.cjs} +1 -1
  9. package/dist/chunks/canonical-result-keys-CEQefvdO.js +33 -0
  10. package/dist/chunks/canonical-result-keys-Cb96edol.cjs +1 -0
  11. package/dist/chunks/{common-types-H51FLKB7.js → common-types-BHVKgxRR.js} +1 -1
  12. package/dist/chunks/{common-types-C57kJ59w.cjs → common-types-BcV9PD9D.cjs} +1 -1
  13. package/dist/chunks/{dashboard-briefing-launcher-ClCj98sq.js → dashboard-briefing-launcher-3owMxX5K.js} +60 -61
  14. package/dist/chunks/{dashboard-briefing-launcher-DHtEouuH.cjs → dashboard-briefing-launcher-xuGrw8H3.cjs} +2 -2
  15. package/dist/chunks/{dashboard-controls-B8gsKlxc.js → dashboard-controls-B4GvjGr1.js} +44 -45
  16. package/dist/chunks/{dashboard-controls-VRShl9J0.cjs → dashboard-controls-Bpm_xOXQ.cjs} +1 -1
  17. package/dist/chunks/dashboard-filter-value-compatibility-KXIyvbhc.js +677 -0
  18. package/dist/chunks/dashboard-filter-value-compatibility-UapptYnn.cjs +1 -0
  19. package/dist/chunks/dashboard-input-contract-BkRFQ7Tq.cjs +1 -0
  20. package/dist/chunks/{dashboard-date-comparison-definition-DC3ekV2S.js → dashboard-input-contract-D5dxTWJ5.js} +41 -25
  21. package/dist/chunks/{dashboard-json-i_Auue_K.js → dashboard-json-DzyxoBp-.js} +13 -14
  22. package/dist/chunks/dashboard-json-yLM01xK4.cjs +1 -0
  23. package/dist/chunks/{edit-dashboard-visual-DWWyT55u.cjs → edit-dashboard-visual-1T278Nr_.cjs} +28 -28
  24. package/dist/chunks/{edit-dashboard-visual-B3JF0fe4.js → edit-dashboard-visual-nwSasO_j.js} +880 -894
  25. package/dist/chunks/{editor-action-buttons-BTlCsP63.cjs → editor-action-buttons-CX1Pken3.cjs} +2 -2
  26. package/dist/chunks/{editor-action-buttons-C9x3nGnb.js → editor-action-buttons-Dqw0asfA.js} +28 -28
  27. package/dist/chunks/index-B1qplNxl.cjs +1392 -0
  28. package/dist/chunks/{index-BS2-ZZGf.js → index-DazD5k0F.js} +45362 -42931
  29. package/dist/chunks/{index-BIFLI8ul.js → index-De_7nrwb.js} +10 -10
  30. package/dist/chunks/index-DjjKJPDy.cjs +4 -0
  31. package/dist/chunks/{matrix-result-contract-CofATICL.js → matrix-result-contract-BTpPuHOc.js} +88 -104
  32. package/dist/chunks/matrix-result-contract-ZRNfeIbI.cjs +1 -0
  33. package/dist/chunks/{pivot-header-presentation-B9nXXKlW.cjs → pivot-header-presentation-BijPbP33.cjs} +1 -1
  34. package/dist/chunks/{pivot-header-presentation-D-0jvUwn.js → pivot-header-presentation-DW0gKG8g.js} +2 -2
  35. package/dist/chunks/{pivot-result-identity-Bb4EixVN.cjs → pivot-result-identity-DxHtiKVj.cjs} +1 -1
  36. package/dist/chunks/{pivot-result-identity-DU1v-5Xk.js → pivot-result-identity-Z9tN2tEV.js} +1 -1
  37. package/dist/chunks/{pivot-result-lifecycle-DTLRuDEW.cjs → pivot-result-lifecycle-BXzIlQVu.cjs} +1 -1
  38. package/dist/chunks/{pivot-result-lifecycle-CHWEGU2o.js → pivot-result-lifecycle-g2U-vzQb.js} +7 -7
  39. package/dist/chunks/{raw-temporal-contract-BtjH_G-d.cjs → raw-temporal-contract-DfAvqNMo.cjs} +1 -1
  40. package/dist/chunks/{raw-temporal-contract-CxncLze5.js → raw-temporal-contract-UtAqoOZO.js} +1 -1
  41. package/dist/chunks/{report-preferences-dialog-BK0yAJnQ.cjs → report-preferences-dialog-DKPyjiCt.cjs} +1 -1
  42. package/dist/chunks/{report-preferences-dialog-BDpkcUtz.js → report-preferences-dialog-Dv3vCCFt.js} +6 -6
  43. package/dist/chunks/{report-runtime-context-DqxS4wbi.cjs → report-runtime-context-C0NfLPfc.cjs} +1 -1
  44. package/dist/chunks/{report-runtime-context-SM6YO61_.js → report-runtime-context-CNncA3VD.js} +11 -11
  45. package/dist/chunks/{saved-temporal-bucket-format-CFfWXRl9.cjs → saved-temporal-bucket-format-3QKveR3v.cjs} +1 -1
  46. package/dist/chunks/{saved-temporal-bucket-format-SGAV0ivR.js → saved-temporal-bucket-format-Dd2eixTH.js} +11 -11
  47. package/dist/chunks/switch-DBZsEV0U.cjs +138 -0
  48. package/dist/chunks/{switch-DQR-Va05.js → switch-kPUJEC1A.js} +6615 -5219
  49. package/dist/chunks/{temporal-bucket-5UYEotyQ.js → temporal-bucket-C85rmFmC.js} +4 -4
  50. package/dist/chunks/temporal-bucket-authoring-1fZuPAVb.js +653 -0
  51. package/dist/chunks/temporal-bucket-authoring-BK1UhYpD.cjs +1 -0
  52. package/dist/chunks/{temporal-bucket-contract-D5d-xEl3.js → temporal-bucket-contract-DXXNZssK.js} +1 -1
  53. package/dist/chunks/{temporal-bucket-contract-D2-93DGr.cjs → temporal-bucket-contract-xFkvboaw.cjs} +1 -1
  54. package/dist/chunks/{temporal-bucket-DHY1y9lq.cjs → temporal-bucket-pMfghsLX.cjs} +1 -1
  55. package/dist/chunks/{token-types-GbxRUozo.js → token-types-BLxc7UwR.js} +1 -1
  56. package/dist/chunks/{token-types-D7CaaI80.cjs → token-types-BYYO109W.cjs} +1 -1
  57. package/dist/chunks/{update-policy-hednMF-0.js → update-policy-CB8XJIoY.js} +1 -1
  58. package/dist/chunks/{update-policy-BmiOd0PB.cjs → update-policy-DMjjGjQY.cjs} +1 -1
  59. package/dist/chunks/{validators-DEmd8Sin.js → validators-DVd8s3qY.js} +416 -350
  60. package/dist/chunks/validators-dJlwubP4.cjs +1 -0
  61. package/dist/dashboard/index.cjs +1 -1
  62. package/dist/dashboard/index.js +2 -2
  63. package/dist/dashboard-authoring/index.cjs +3 -3
  64. package/dist/dashboard-authoring/index.js +328 -311
  65. package/dist/data-app-builder/index.cjs +1 -1
  66. package/dist/data-app-builder/index.js +2 -2
  67. package/dist/data-app-codegen/index.cjs +1 -1
  68. package/dist/data-app-codegen/index.js +2 -2
  69. package/dist/data-app-codegen-node/index.cjs +1 -1
  70. package/dist/data-app-codegen-node/index.js +3 -3
  71. package/dist/data-app-sdk/index.cjs +1 -1
  72. package/dist/data-app-sdk/index.js +55 -55
  73. package/dist/data-app-sdk-adapters/index.cjs +1 -1
  74. package/dist/data-app-sdk-adapters/index.js +61 -56
  75. package/dist/data-app-sdk-validation/index.cjs +1 -1
  76. package/dist/data-app-sdk-validation/index.js +9 -9
  77. package/dist/format-utils/index.cjs +1 -1
  78. package/dist/format-utils/index.js +15 -15
  79. package/dist/index.cjs +1 -1
  80. package/dist/index.js +154 -155
  81. package/dist/report-runtime-context/index.cjs +1 -1
  82. package/dist/report-runtime-context/index.js +2 -2
  83. package/dist/style.css +1 -1
  84. package/dist/surfboard/index.cjs +1 -1
  85. package/dist/surfboard/index.js +3 -3
  86. package/dist/types/analytics-protocol.d.ts +16 -8
  87. package/dist/types/briefings.d.ts +95 -13
  88. package/dist/types/dashboard-assistant.d.ts +11 -6
  89. package/dist/types/dashboard-authoring.d.ts +257 -19
  90. package/dist/types/dashboard.d.ts +109 -14
  91. package/dist/types/data-app-builder.d.ts +11 -6
  92. package/dist/types/data-app-codegen-node.d.ts +16 -8
  93. package/dist/types/data-app-codegen.d.ts +16 -8
  94. package/dist/types/data-app-sdk-adapters.d.ts +17 -11
  95. package/dist/types/data-app-sdk-validation.d.ts +17 -11
  96. package/dist/types/data-app-sdk.d.ts +17 -11
  97. package/dist/types/index.cjs +1 -1
  98. package/dist/types/index.js +4 -4
  99. package/dist/types/main.d.ts +225 -20
  100. package/dist/types/shared.d.ts +95 -13
  101. package/dist/types/surfboard.d.ts +109 -14
  102. package/dist/types/types.d.ts +109 -14
  103. package/package.json +1 -1
  104. package/dist/chunks/canonical-result-keys-BA0HCP4e.cjs +0 -1
  105. package/dist/chunks/canonical-result-keys-D6avdjpA.js +0 -467
  106. package/dist/chunks/dashboard-date-comparison-definition-Ces4alFm.cjs +0 -1
  107. package/dist/chunks/dashboard-json-BhvPMpZA.cjs +0 -1
  108. package/dist/chunks/index-DHF-2AqS.cjs +0 -1392
  109. package/dist/chunks/index-k8tEp0ys.cjs +0 -4
  110. package/dist/chunks/matrix-result-contract-zamd9euI.cjs +0 -1
  111. package/dist/chunks/switch-f3TuZNLr.cjs +0 -138
  112. package/dist/chunks/temporal-bucket-authoring-K1kE6R_z.js +0 -222
  113. package/dist/chunks/temporal-bucket-authoring-o3Emn05L.cjs +0 -1
  114. package/dist/chunks/validators-BDYprKI9.cjs +0 -1
@@ -1,4 +1,4 @@
1
- "use strict";const J=require("./x-B6ghREd2.cjs"),v=require("react"),s=require("./switch-f3TuZNLr.cjs"),f=require("./index-DHF-2AqS.cjs"),e=require("react/jsx-runtime");require("./saved-temporal-bucket-format-CFfWXRl9.cjs");require("./validators-BDYprKI9.cjs");require("./analyze-result-contract-LPDNldic.cjs");require("../value-format-preferences/index.cjs");const ge=require("./search-BqqhaMx9.cjs"),Fe=require("./index-k8tEp0ys.cjs"),Se=require("./save-3dYRmehL.cjs");/**
1
+ "use strict";const J=require("./x-B6ghREd2.cjs"),v=require("react"),s=require("./switch-DBZsEV0U.cjs"),f=require("./index-B1qplNxl.cjs"),e=require("react/jsx-runtime");require("./saved-temporal-bucket-format-3QKveR3v.cjs");require("./validators-dJlwubP4.cjs");require("./analyze-result-contract-DSGoFuXQ.cjs");require("../value-format-preferences/index.cjs");const ge=require("./search-BqqhaMx9.cjs"),Fe=require("./index-DjjKJPDy.cjs"),Se=require("./save-3dYRmehL.cjs");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -13,4 +13,4 @@
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const ke=J.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 Ie(r){const[a,l]=v.useState(null),[n,d]=v.useState(null),u=f.useEnsureReactGlobals();return v.useEffect(()=>{if(!r||r.trim()===""){l(null),d(null);return}if(!u)return;(async()=>{try{if(!r.startsWith("http://")&&!r.startsWith("https://"))throw new Error(`Invalid URL format: ${r}`);try{new URL(r)}catch{throw new Error(`Invalid URL: ${r}`)}const p=`${r.endsWith("/")?r:`${r}/`}index.js`;try{if(!(await fetch(p,{method:"HEAD"})).ok)throw new Error(`Module not found at ${p}`)}catch{}const C=await import(p);if(typeof C.useChartStore!="function")throw new Error("useChartStore is not a function");l(()=>C.useChartStore),d(null)}catch(x){const p=x instanceof Error?x.message:"Unknown error";console.error("Failed to load remote chart store:",p),d(p),l(null)}})()},[r,u]),a}function Te(r,a){if(r.length===0)return"";const l=r.find(n=>{var d,u;return((d=n.customCardPreferences)==null?void 0:d.visualType)==="multiple"||!!((u=n.customCardPreferences)!=null&&u.dataInputCardIds)});if(l)return l.id;if(a){const n=r.find(d=>d.id===a);if(n){const d=n.tabTitle;if(d=="All__Header")return r[0].id;if(d&&d.endsWith("__Header")){const m=d.split("__")[0],x=r.find(p=>p.tabTitle===m);return x?x.id:r[0].id}return a}}return r[0].id}const Le=r=>{if(!r||!("detailTableBackup"in r))return r;const{detailTableBackup:a,...l}=r;return l};async function be(r,a,l,n,d="Opening library visual..."){if(!a||!l)throw new Error("Missing auth token or visual ID");const u=["resource-by-id","visual",l],m=n.getQueryData(u);if(m)return console.log("Using cached visual data for:",l),{data:m,fromCache:!0};console.log("Fetching visual data from network for:",l);const x=f.ue.loading(d,{position:"top-center"});try{const p=await fetch(`${r}/management/v1/visuals/${l}`,{headers:{Authorization:`Bearer ${a}`}});if(!p.ok)throw new Error("Failed to load visual");const C=await p.json();return n.setQueryData(u,C),f.ue.dismiss(x),{data:C,fromCache:!1}}catch(p){throw f.ue.dismiss(x),p}}function Ne(r){if(typeof r=="string")return JSON.parse(r);if(typeof r=="object")return r;throw new Error("Invalid frame object format")}function Ae(r,a){var u,m;const l=(r==null?void 0:r.frameObject)??((u=r==null?void 0:r.visual)==null?void 0:u.frameObject);if(!l)return!1;const n=Ne(l);if(!(n!=null&&n.cards)||n.cards.length===0)return!1;const d=(m=n.cards)==null?void 0:m.find(x=>x.id===n.activeCardId);return d?(f.setupEditorWithCard({...a,frame:n,card:d,visualId:(r==null?void 0:r.id)||n.visualId}),!0):!1}function _e(){const r=s.useEditorStore(n=>{var d;return((d=n.card.customCardPreferences)==null?void 0:d.url)||""}),a=Ie(r);return{getUpdatedFrame:v.useCallback(()=>{var T;f.flushPendingEditorDrafts();const{frame:n,card:d,isDevMode:u,isShowingVisual:m,selectedSchemaName:x,selectedDatamodelId:p,selectedDatabaseName:C,selectedTableName:y,selectedConnectionId:g}=s.useEditorStore.getState(),S=d.sql,D=(T=a==null?void 0:a.getState())==null?void 0:T.settings,k=s.buildSavedEditorCard(d,{isDevMode:u,cardSql:S,isShowingVisual:m,selectedSchemaName:x,selectedDatamodelId:p,selectedDatabaseName:C,selectedTableName:y,selectedConnectionId:g,remoteChartSettings:D,stripConfig:Le}),E=n.cards.map(O=>O.id===d.id?k:O);return{...n,cards:E,activeCardId:Te(E,n.activeCardId)}},[a])}}function ae(){const{authToken:r,tokenProps:a}=f.useSemaphorContext(),l=f.useQueryClient(),n=f.useAddFrameWithFreshSemanticExecutionPayload(),d=f.useSelectedVisual(),{selectVisual:u}=f.useManagementActions(),{setFrame:m,setCard:x,setIsDevMode:p,initializeModeDrafts:C,setActiveTabCardId:y,updateDataSource:g,setQueryResultColumns:S,setSelectedConnectionId:D,setSelectedDatabaseName:k,setSelectedSchemaName:E,setSelectedTableName:T,setSelectedDatamodelId:O,setFilterValues:$,setInlineFilterValuesMap:U,setApplyFilters:R,clearEditorContext:W}=s.useEditorActions(),{setIsDashboardEditing:F,setIsVisualEditing:o,setSelectedFrameId:w,clearSelectedFrameId:Q}=s.useDashboardActions(),B=s.useDashboardStore(A=>A.selectedSheetId),Y=s.useDashboardStore(A=>A.selectedFrameId),H=s.useDashboardStore(A=>A.dashboard),X=s.useDashboardStore(A=>A.filterValues),q=s.useDashboardStore(A=>A.inlineFilterValuesMap),K=f.useVisualById((d==null?void 0:d.id)||"",{enabled:!!(d!=null&&d.id)&&!!(r!=null&&r.accessToken)}),Z=v.useCallback(async A=>{try{u(A),Q(),W();const{data:V,fromCache:P}=await be(a.apiServiceUrl,(r==null?void 0:r.accessToken)||"",A.id,l,"Opening library visual...");if(!Ae(V,{setFrame:m,setCard:x,setIsDevMode:p,initializeModeDrafts:C,setActiveTabCardId:y,updateDataSource:g,setQueryResultColumns:S,setSelectedConnectionId:D,setSelectedDatabaseName:k,setSelectedSchemaName:E,setSelectedTableName:T,setSelectedDatamodelId:O,setFilterValues:$,setInlineFilterValuesMap:U,setApplyFilters:R,setIsDashboardEditing:F,setIsVisualEditing:o,dashboard:H,selectedSheetId:B,selectedFrameId:Y,filterValues:X,inlineFilterValuesMap:q}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:P}}catch(V){return console.error("Error editing visual:",V),{success:!1,error:"Failed to load visual for editing"}}},[r==null?void 0:r.accessToken,a.apiServiceUrl,l,u,m,x,F,o,p,C,y,g,S,D,k,E,T,O,$,U,R,W,Q,H,B,Y,X,q]),ne=v.useCallback(async A=>{var P;const V=_=>(f.ue.error(_),{success:!1,error:_});try{if(u(A),!B)return V("No sheet selected. Please select a sheet first.");const{data:_,fromCache:oe}=await be(a.apiServiceUrl,(r==null?void 0:r.accessToken)||"",A.id,l,"Adding visual to dashboard..."),re=(_==null?void 0:_.frameObject)??((P=_==null?void 0:_.visual)==null?void 0:P.frameObject);if(!re)return V("Visual has no frame data");const z=Ne(re);if(!(z!=null&&z.cards)||z.cards.length===0)return V("Visual frame is malformed");const te={...f.cloneLinkedFrameWithSourceMapping(z),visualId:A.id};return await n(B,te,"end"),F(!0),w(te.id),{success:!0,fromCache:oe}}catch(_){return console.error("Error adding visual:",_),V(_ instanceof Error?_.message:"Failed to add visual to dashboard")}},[r==null?void 0:r.accessToken,a.apiServiceUrl,l,u,B,F,w,n]);return{visual:K.data,isLoading:K.isLoading,isError:K.isError,error:K.error,handleEditLibraryVisual:Z,handleAddLibraryVisual:ne,getUpdatedFrame:_e().getUpdatedFrame,refetch:K.refetch}}function qe(){const r=s.useEditorStore(m=>m.card.dataSource),{setSelectedConnectionId:a,setSelectedDatabaseName:l,setSelectedSchemaName:n,setSelectedTableName:d,setSelectedDatamodelId:u}=s.useEditorActions();v.useEffect(()=>{var D;if(!r)return;const{tableName:m,schemaName:x,databaseName:p,connectionId:C}=f.extractTableMetadata(r),y=(D=r.selectedEntities)==null?void 0:D[0],S=(y==null?void 0:y.type)==="model"&&"id"in y?y.id:"";a(C||""),l(p||""),n(x||""),d(m||""),u(S)},[r,a,l,n,d,u])}function Be(r,a){return{...r,sql:"",python:"",config:void 0,customCfg:"",preferences:{},interactionConfig:void 0,linkedInteractionTargetOverrides:void 0,dynamicCardPreferences:void 0,customCardPreferences:a?r.customCardPreferences:void 0,visualizationMode:"builtin",type:a?r.type:"bar"}}function Ee(){const{setTempQueryData:r}=s.useEditorActions(),a=f.useQueryClient(),l=s.useEditorStore(U=>U.tempQueryData),n=s.useEditorStore(U=>U.card),d=f.useEffectiveEditorCardType(),u=v.useMemo(()=>d!==n.type?{...n,type:d}:n,[n,d]),{queryKey:m}=f.useEditorCardQuery(u),{setCardSql:x,setSqlGen:p,setCardPython:C,setCardCustomCfg:y,setCardPreferences:g,clearQueryConfig:S,setCardConfig:D,setCardType:k,setFrame:E,setCard:T,setActiveTabCardId:O}=s.useEditorActions();function $(){var Q,B,Y,H;const U=a.getQueryData(m);l!=null&&l.queryData||r({queryKey:m,queryData:U}),a.setQueryData(m,null),a.removeQueries({queryKey:m,exact:!0}),x(""),p({}),S(),D(void 0),C(""),y(""),g({});const R=s.useEditorStore.getState().frame,W=s.useEditorStore.getState().card,F=Fe.findCustomVisualConfigCard(R,W),o=((Q=F==null?void 0:F.customCardPreferences)==null?void 0:Q.visualType)==="multiple"||!!((B=F==null?void 0:F.customCardPreferences)!=null&&B.dataInputCardIds)||(((Y=F==null?void 0:F.customCardPreferences)==null?void 0:Y.minInputs)||0)>1||(((H=F==null?void 0:F.customCardPreferences)==null?void 0:H.maxInputs)||0)>1,w=Be(W,o);E({...R,cards:R.cards.map(X=>X.id===w.id?w:X)}),O(w.id),T(w),o||k("bar")}return $}function Me({type:r,isLinked:a,className:l,showLabel:n=!1,showLocal:d=!1}){const u=s.useDashboardStore(E=>E.selectedFrameId),m=f.useManagementStore(E=>E.selectedVisual),x=s.useEditorStore(E=>E.frame);let p;if(r)p=r;else if(a!==void 0)p=a?"linked":"library";else if(!!!(x!=null&&x.visualId||m!=null&&m.id)&&u)p="local";else if(m&&!u)p="library";else if(x!=null&&x.visualId&&u)p="linked";else if(m!=null&&m.id&&u)p="library";else return null;if(p==="local"&&!d)return null;const C={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."},g={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"},S={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(ke,{className:"h-3.5 w-3.5"}),library:e.jsx(je,{className:"h-3.5 w-3.5"})},k={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(f.Badge,{variant:"outline",className:s.cn("cursor-help select-none transition-all",C[p],l),children:[D[p],n&&e.jsx("span",{className:"ml-1 text-xs font-medium leading-none",children:k[p]})]})}),e.jsxs(s.TooltipContent,{side:"bottom",className:s.cn("max-w-xs",g[p]),children:[e.jsx(s.TooltipArrow,{className:S[p]}),e.jsx("p",{children:y[p]})]})]})})}function we(r){const{control:a,onChange:l}=r;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:n=>l(n.target.value)})]})}function Oe(r){const{currentStep:a,labels:l}=r;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:l.map((n,d)=>{const u=d+1,m=u===a,x=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",m?"border-foreground bg-foreground text-background":x?"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]",m?"font-medium text-foreground":"text-muted-foreground"),children:n})]}),d<l.length-1?e.jsx("span",{className:"h-px w-4 bg-border/60 sm:w-6","aria-hidden":"true"}):null]},n)})})})}function se(r){const{secondary:a,tertiary:l,primary:n}=r;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,l,n]})}function Ue(r){const{control:a,scope:l,detail:n}=r;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(f.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(l,a.placement)]}),n?e.jsx("div",{className:"text-[12px] text-muted-foreground",children:n}):null]})]})}function ye(r){const{control:a,defaultValue:l,availableFieldChoices:n,availableMetricChoices:d,previewControlDefinitions:u,previewControlValues:m,onControlChange:x,onLabelChange:p,onDefaultValueChange:C,onBack:y,onNext:g,nextDisabled:S}=r;return e.jsxs("div",{className:"space-y-3",children:[e.jsx(we,{control:a,onChange:p}),e.jsx(f.ControlDefinitionOptionsEditor,{control:a,availableFieldChoices:n,availableMetricChoices:d,previewControlDefinitions:u,previewControlValues:m,controlLifecycle:"create",onChange:x}),e.jsx(f.ControlDefaultValueEditor,{control:a,value:l,onChange:C,allowNoDefault:!0,allowCardDefault:!0,hint:"This is the value viewers will see first.",previewControlDefinitions:u,previewControlValues:m}),e.jsx(se,{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:g,disabled:S,children:"Next"})})]})}const ze=new Set(["grain_selector","aggregation_selector","field_selector","metric_selector"]);function ve(r){const{text:a,ariaLabel:l}=r,[n,d]=v.useState(!1);return e.jsxs("button",{type:"button","aria-label":l,onClick:async()=>{try{await navigator.clipboard.writeText(a),d(!0),setTimeout(()=>d(!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:n?"Copied":"Click to copy"})]})}function Ce(r){const{control:a,scope:l,createdReference:n,explorerContent:d,sqlDescription:u,summaryDetail:m,onBack:x,onCancel:p,onDone:C}=r,y=ze.has(a.type),g=n.match(/\[\[param\.(.+?)\]\]/),S=g?`{{ param('${g[1]}') }}`:"";return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ue,{control:a,scope:l,detail:m}),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:d})]}):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(ve,{text:n,ariaLabel:"Copy SQL control reference"}),S?e.jsx(ve,{text:S,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(se,{secondary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:x,children:"Back"}),tertiary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:p,children:"Cancel"}),primary:e.jsx(s.Button,{type:"button",size:"xs",onClick:C,children:"Done"})})]})}function Re(r){const a=s.createBlankControl(r.scope,r.existingControls,r.reservedIds),l=r.type===a.type?{...a,label:s.DEFAULT_LABEL_BY_TYPE[r.type]}:{...s.applyControlTypeChange({controls:[{...a,label:s.DEFAULT_LABEL_BY_TYPE[r.type]}],controlId:a.id,nextType:r.type}).controls[0],label:s.DEFAULT_LABEL_BY_TYPE[r.type]};return{step:2,control:l,defaultValue:s.getDefaultValueForType(l,void 0)}}function Qe({scope:r,controls:a,reservedControlIds:l,defaultValues:n,onChange:d,emptyMessage:u,initialCreateFlow:m=!1,usageByControlId:x,availableFieldChoices:p,availableMetricChoices:C,structuralParticipants:y,structuralParticipantIdsByControlId:g,card:S,allowedControlTypes:D,onCreateFlowActiveChange:k,onCreateFlowComplete:E}){const T=v.useMemo(()=>new Set(l||[]),[l]),O=s.getPlacementOptionsForScope(r),$=s.getDefaultPlacement(r),[U,R]=v.useState(null),[W,F]=v.useState(null),[o,w]=v.useState(()=>m?{step:1,control:s.createBlankControl(r,a,Array.from(T))}:null),Q=v.useRef({}),B=v.useRef(void 0),Y=v.useRef(m),H=v.useMemo(()=>{const t=s.getFriendlyControlTypeOptions({scope:r,card:S});if(!D)return t;const c=new Set(D);return t.filter(i=>c.has(i.value))},[D,S,r]),X=v.useCallback(t=>{const c=s.getFriendlyControlTypeOptions({scope:r,card:S,includeType:D?void 0:t});if(!D)return c;const i=new Set(D);return c.filter(h=>i.has(h.value))},[D,S,r]),q=v.useCallback(t=>r==="dashboard"&&(t==="field_selector"||t==="metric_selector"),[r]),K=v.useMemo(()=>o?s.getEligibleParticipantsForStructuralControl(y||[],o.control.type):[],[o,y]),Z=v.useMemo(()=>{if(!o)return{fields:p||[],metrics:C||[]};if(!q(o.control.type))return{fields:p||[],metrics:C||[]};const t=o.selectedCardIds||[],c=s.getCompatibleStructuralChoiceCatalog({controlType:o.control.type,participants:y||[],selectedCardIds:t});return{fields:o.control.type==="field_selector"?c.choices.map(i=>({option:i,target:c.fieldTargetMap[i.value]})):[],metrics:o.control.type==="metric_selector"?c.choices.map(i=>({option:i,target:c.metricTargetMap[i.value]})):[]}},[p,C,o,q,y]);v.useEffect(()=>{k==null||k(!!o)},[o,k]),v.useEffect(()=>{const t=m&&!Y.current;Y.current=m,t&&(w({step:1,control:s.createBlankControl(r,a,Array.from(T))}),F(null),R(null))},[a,m,T,r]);const ne=t=>{if(!q(t.type))return{fields:p||[],metrics:C||[]};const c=(g==null?void 0:g[t.id])||[];if(c.length===0)return{fields:p||[],metrics:C||[]};const i=s.getCompatibleStructuralChoiceCatalog({controlType:t.type,participants:y||[],selectedCardIds:c});return{fields:t.type==="field_selector"?i.choices.map(h=>({option:h,target:i.fieldTargetMap[h.value]})):[],metrics:t.type==="metric_selector"?i.choices.map(h=>({option:h,target:i.metricTargetMap[h.value]})):[]}},A=t=>{if(!q(t.control.type))return{nextControl:t.control,cardBindingsById:void 0};const c=(g==null?void 0:g[t.control.id])||[],i=s.getCompatibleStructuralChoiceCatalog({controlType:t.control.type,participants:y||[],selectedCardIds:t.nextSelectedCardIds}),h=s.reconcileStructuralControlChoices({control:t.control,choices:i.choices}),j=Object.fromEntries(c.filter(N=>!t.nextSelectedCardIds.includes(N)).map(N=>[N,void 0]));return t.nextSelectedCardIds.length>0&&h.source.kind==="manual"&&h.source.options.length>0&&Object.assign(j,s.buildStructuralControlBindingsForParticipants({control:h,participants:y||[],selectedCardIds:t.nextSelectedCardIds})),{nextControl:h,cardBindingsById:j}},V=v.useCallback((t,c=n,i={type:"update"})=>{const h=t.map(j=>(s.resolveAuthoringControlDefaultValue({control:j,defaultValues:c}),s.syncSqlQueryControlExecutionRequirement(j)));d(h,c,i)},[n,d]),P=(t,c)=>{const i=a.find(L=>L.id===t);let h=a.map(L=>L.id!==t?L:c(L));const j=h.find(L=>L.id===t);let N,b;if(j&&r==="dashboard"&&(j.type==="field_selector"||j.type==="metric_selector")){const L=(g==null?void 0:g[j.id])||[],ee=A({control:j,nextSelectedCardIds:L});h=h.map(G=>G.id===t?ee.nextControl:G),N=ee.cardBindingsById,b=[j.id]}else if(i&&r==="dashboard"&&(i.type==="field_selector"||i.type==="metric_selector")){const L=(g==null?void 0:g[i.id])||[];N=Object.fromEntries(L.map(ee=>[ee,void 0])),b=[i.id]}const I=h.find(L=>L.id===t);let M=n;if(i&&I){const L=s.resolveAuthoringControlDefaultValue({control:i,defaultValues:n});i.source.kind==="manual"&&I.source.kind==="sql_query"&&(Q.current[t]=L);const ee=L===void 0&&i.source.kind==="sql_query"&&I.source.kind==="manual"?Q.current[t]:L,G=s.getNextEditedControlDefaultValue({previousControl:i,nextControl:I,currentDefaultValue:ee});I.source.kind==="manual"&&(Q.current[t]=G),n&&(M={...n},G===void 0?delete M[t]:M[t]=G),h=h.map(xe=>xe.id===t?{...I,defaultValue:G}:xe)}V(h,M,{type:"update",cardBindingsById:N,affectedBindingControlIds:b})},_=(t,c)=>{if(!c.trim())return;const i=f.normalizeDashboardInputVariableName(c);if(i===t||T.has(i)||a.some(N=>N.id===i&&N.id!==t))return;const h=a.map(N=>N.id===t?{...N,id:i}:N);if(!n){V(h,void 0,{type:"rename",oldId:t,newId:i});return}const j={...n};Object.prototype.hasOwnProperty.call(j,t)&&(j[i]=j[t],delete j[t]),V(h,j,{type:"rename",oldId:t,newId:i})},oe=t=>{const c=a.filter(h=>h.id!==t);if(!n){V(c,void 0,{type:"remove",controlId:t});return}const i={...n};delete i[t],V(c,i,{type:"remove",controlId:t})},re=v.useCallback(()=>{B.current=void 0,w({step:1,control:s.createBlankControl(r,a,Array.from(T))}),F(null),R(null)},[a,T,r]),z=t=>{w(c=>c&&(()=>{const i=t(c.control);c.control.source.kind==="manual"&&i.source.kind==="sql_query"&&(B.current=c.defaultValue);const h=c.defaultValue===void 0&&c.control.source.kind==="sql_query"&&i.source.kind==="manual"?B.current:c.defaultValue,j=s.getNextEditedControlDefaultValue({previousControl:c.control,nextControl:i,currentDefaultValue:h});return i.source.kind==="manual"&&(B.current=j),{...c,control:i,defaultValue:j}})())},te=t=>{w(c=>c&&(c.control.source.kind==="manual"&&(B.current=t),{...c,defaultValue:t}))},le=(()=>{if(!o)return!1;if(o.step===2&&q(o.control.type))return(o.selectedCardIds||[]).length>0;if(o.step!==2&&o.step!==3||!o.control.label.trim())return!1;const c=o.control.source.kind==="sql_query"?o.control:s.ensureManualSource(o.control);if(c.source.kind==="manual"&&(s.needsManualOptions(c)&&c.source.options.length===0||c.source.options.some(h=>h.label.trim().length===0||h.value.trim().length===0)))return!1;if(c.source.kind==="sql_query"){const{connectionId:i,sql:h,valueColumn:j}=c.source;return i.trim().length>0&&h.trim().length>0&&j.trim().length>0}return s.hasConcreteDefaultValue(s.getDefaultValueForType(c,o.defaultValue))})(),pe=()=>{var N;if(!o)return;const t=s.ensureManualSource(o.control),c=s.deriveUniqueControlId({label:t.label,fallbackId:t.id,existingControls:a,reservedIds:Array.from(T)}),i={...t,id:c},h=r==="dashboard"&&(i.type==="field_selector"||i.type==="metric_selector")&&((N=o.selectedCardIds)!=null&&N.length)?s.buildStructuralControlBindingsForParticipants({control:i,participants:y||[],selectedCardIds:o.selectedCardIds}):void 0,j=s.getDefaultValueForType(i,o.defaultValue);w({step:r==="dashboard"&&(i.type==="field_selector"||i.type==="metric_selector")?4:3,control:i,defaultValue:j,createdControlId:c,selectedCardIds:o.selectedCardIds,cardBindingsById:h})},ie=v.useCallback(()=>{w(null)},[]),me=v.useCallback(()=>{if(!(o!=null&&o.createdControlId)){w(null);return}const t=o.control,c=o.createdControlId,i=s.getDefaultValueForType(t,o.defaultValue);if(n){const h={...n};i===void 0?delete h[c]:h[c]=i,V([...a,{...t,defaultValue:i}],h,{type:"add",cardBindingsById:o.cardBindingsById})}else V([...a,{...t,defaultValue:i}],void 0,{type:"add",cardBindingsById:o.cardBindingsById});F(c),w(null),E==null||E()},[a,o,n,V,E]),De=o?q(o.control.type)?["Choose type","Select cards","Configure","Finish"]:["Choose type","Configure","Finish"]:[],fe=o!=null&&o.createdControlId?`[[param.${o.createdControlId}]]`:o?`[[param.${s.slugifyControlValue(o.control.label)||o.control.id}]]`:"",de=s.buildAuthoringPreviewControlValues({controls:a,defaultValues:n}),ce=o?[...a,o.control]:a,he=o?s.buildAuthoringPreviewControlValues({controls:ce,defaultValues:n,overrides:[{controlId:o.control.id,value:o.defaultValue}]}):de;return e.jsxs("div",{className:"space-y-4",children:[o?e.jsxs("div",{className:"space-y-4 pb-1",children:[e.jsx(Oe,{currentStep:o.step,labels:De}),o.step===1&&(()=>{const t=new Set(["grain_selector","aggregation_selector","field_selector","metric_selector"]),c=new Set(["date","text"]),i=H.filter(N=>!t.has(N.value)&&!c.has(N.value)),h=H.filter(N=>t.has(N.value)),j=N=>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:()=>w(Re({scope:r,existingControls:a,reservedIds:Array.from(T),type:N.value})),children:[e.jsx("div",{className:"text-[13px] font-medium text-foreground",children:N.label}),e.jsx("p",{className:"mt-0.5 text-[12px] text-muted-foreground",children:N.description})]},N.value);return e.jsxs("div",{className:"space-y-4",children:[r==="card"&&(S==null?void 0:S.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(j)})]}),h.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:h.map(j)})]}),e.jsx(se,{secondary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:ie,children:"Back to controls"})})]})})(),o.step===2&&q(o.control.type)&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(we,{control:o.control,onChange:t=>z(c=>({...c,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 c=(o.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(f.Checkbox,{checked:c,onCheckedChange:i=>w(h=>h&&{...h,selectedCardIds:i===!0?[...h.selectedCardIds||[],t.cardId]:(h.selectedCardIds||[]).filter(j=>j!==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:o.control.type==="field_selector"?`${t.fieldChoices.length} compatible group-by fields`:`${t.metricChoices.length} compatible metrics`})]})]},t.cardId)})}),e.jsx(se,{secondary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:()=>w(t=>t&&{...t,step:1,selectedCardIds:[]}),children:"Back"}),primary:e.jsx(s.Button,{type:"button",size:"xs",onClick:()=>w(t=>t&&{...t,step:3}),disabled:!le,children:"Next"})})]}),o.step===2&&!q(o.control.type)&&e.jsx(ye,{control:o.control,defaultValue:o.defaultValue,availableFieldChoices:Z.fields,availableMetricChoices:Z.metrics,previewControlDefinitions:ce,previewControlValues:he,onControlChange:t=>z(()=>t),onLabelChange:t=>z(c=>({...c,label:t})),onDefaultValueChange:te,onBack:()=>w(t=>t&&{...t,step:1}),onNext:pe,nextDisabled:!le}),o.step===3&&q(o.control.type)&&e.jsx(ye,{control:o.control,defaultValue:o.defaultValue,availableFieldChoices:Z.fields,availableMetricChoices:Z.metrics,previewControlDefinitions:ce,previewControlValues:he,onControlChange:t=>z(()=>t),onLabelChange:t=>z(c=>({...c,label:t})),onDefaultValueChange:te,onBack:()=>w(t=>t&&{...t,step:2}),onNext:pe,nextDisabled:!le}),o.step===3&&!q(o.control.type)&&e.jsx(Ce,{control:o.control,scope:r,createdReference:fe,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:()=>w(t=>t&&{...t,step:2}),onCancel:ie,onDone:me}),o.step===4&&q(o.control.type)&&e.jsx(Ce,{control:o.control,scope:r,createdReference:fe,summaryDetail:e.jsxs(e.Fragment,{children:["Used by ",(o.selectedCardIds||[]).length," selected card",(o.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:()=>w(t=>t&&{...t,step:3}),onCancel:ie,onDone:me})]}):null,!o&&a.length===0?e.jsx("div",{className:"rounded-md border border-dashed p-3 text-sm text-muted-foreground",children:u}):null,!o&&a.map(t=>{const c=ne(t),i=x==null?void 0:x[t.id],h=s.resolveAuthoringControlDefaultValue({control:t,defaultValues:n}),j=W===t.id,N="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:()=>F(b=>b===t.id?null:t.id),children:[j?e.jsx(J.ChevronDown,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(ge.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:N,children:s.getFriendlyTypeOption(t.type).label}),e.jsx("span",{className:N,children:s.getPlacementLabel(r,t.placement)})]}),e.jsxs("div",{className:"mt-0.5 text-[12px] text-muted-foreground",children:[s.getControlOptionPreview(t),i!=null&&i.status?` · ${i.status}`:""]})]})]}),e.jsx(s.Button,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 shrink-0 p-0 text-muted-foreground",onClick:()=>oe(t.id),"aria-label":`Remove ${t.label}`,children:e.jsx(f.Trash2,{className:"h-3.5 w-3.5"})})]}),j&&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:b=>P(t.id,I=>({...I,label:b.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:b=>{const I=s.applyControlTypeChange({controls:a,controlId:t.id,nextType:b,defaultValues:n});V(I.controls,I.defaultValues)},children:[e.jsx(s.SelectTrigger,{size:"xs",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:X(t.type).map(b=>e.jsx(s.SelectItem,{value:b.value,children:b.label},b.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||$,onValueChange:b=>P(t.id,I=>({...I,placement:b})),children:[e.jsx(s.SelectTrigger,{size:"xs",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:O.map(b=>e.jsx(s.SelectItem,{value:b.value,children:b.label},b.value))})]})]})]}),q(t.type)?e.jsx(f.StructuralParticipantSelector,{type:t.type,participants:s.getEligibleParticipantsForStructuralControl(y||[],t.type).map(b=>({cardId:b.cardId,title:b.title,choiceCount:t.type==="field_selector"?b.fieldChoices.length:b.metricChoices.length})),selectedCardIds:(g==null?void 0:g[t.id])||[],onChange:b=>{const I=A({control:t,nextSelectedCardIds:b}),M=a.map(L=>L.id===t.id?I.nextControl:L);V(M,n,{type:"update",cardBindingsById:I.cardBindingsById})}}):null,e.jsx(f.ControlDefinitionOptionsEditor,{control:t,availableFieldChoices:c.fields,availableMetricChoices:c.metrics,previewControlDefinitions:a,previewControlValues:de,controlLifecycle:"edit",onChange:b=>P(t.id,()=>b)}),t.initialValueStrategy==="saved_default"&&e.jsx(f.ControlDefaultValueEditor,{control:t,value:h,allowNoDefault:!0,allowCardDefault:!0,previewControlDefinitions:a,previewControlValues:de,onChange:b=>{const I=a.map(M=>M.id===t.id?{...M,defaultValue:b}:M);if(t.source.kind==="manual"&&(Q.current[t.id]=b),n){const M={...n};b===void 0?delete M[t.id]:M[t.id]=b,V(I,M);return}V(I,void 0)}}),e.jsxs(f.Collapsible,{open:U===t.id,onOpenChange:b=>R(b?t.id:null),children:[e.jsx(f.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:[U===t.id?e.jsx(J.ChevronDown,{className:"h-3.5 w-3.5"}):e.jsx(ge.ChevronRight,{className:"h-3.5 w-3.5"}),"Advanced"]})}),e.jsxs(f.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(f.ControlIdInput,{controlId:t.id,onCommit:b=>_(t.id,b)},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:b=>P(t.id,I=>({...I,initialValueStrategy:b})),children:[e.jsx(s.SelectTrigger,{size:"xs",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:s.INITIAL_VALUE_STRATEGY_OPTIONS.map(b=>e.jsx(s.SelectItem,{value:b.value,children:b.label},b.value))})]})]})]}),e.jsx(f.ControlVisibilitySettings,{control:t,onChange:b=>P(t.id,()=>b)})]})]})]})]},t.id)}),!o&&e.jsxs(s.Button,{type:"button",variant:"outline",size:"xs",onClick:re,children:[e.jsx(f.Plus,{className:"h-3.5 w-3.5"}),"Add control"]})]})}function Pe(r){const{open:a,onOpenChange:l,initialCreateFlowActive:n=!1,dismissMode:d="passive"}=r,u=a!==void 0,[m,x]=v.useState(!1),[p,C]=v.useState(n),y=u?a:m,g=v.useCallback(k=>{!k&&p&&d==="passive"||(u||x(k),k||C(!1),l==null||l(k))},[u,p,d,l]),S=v.useCallback(()=>{u||x(!1),C(!1),l==null||l(!1)},[u,l]);v.useEffect(()=>{y||C(!1)},[y]);const D=v.useCallback(k=>{p&&k.preventDefault()},[p]);return{forceClose:S,handleOpenChange:g,isCreateFlowActive:p,preventPassiveDismissDuringCreate:D,resolvedOpen:y,setIsCreateFlowActive:C}}function ue(r){const a=s.getDynamicFrameSaveIssue(r);return a?(f.ue.error(a),!1):!0}function $e({className:r,variant:a="outline"}){const l=s.useEditorStore(u=>u.onSave),{getUpdatedFrame:n}=ae();function d(){const u=n();ue(u)&&(l==null||l(u))}return e.jsxs(s.Button,{onClick:d,className:r,size:"xs",variant:a,children:[e.jsx(s.Check,{className:"h-3.5 w-3.5"}),"Accept"]})}function Ye({className:r,variant:a="default"}){const l=f.useQueryClient(),[n,d]=v.useState(!1),{setIsVisualEditing:u}=s.useDashboardActions(),{getUpdatedFrame:m}=ae(),x=f.useSelectedVisual(),p=s.useEditorStore(g=>g.frame),C=f.useUpdateVisualMutation(),y=()=>{const g=m();if(!ue(g))return;const S=(p==null?void 0:p.visualId)||(x==null?void 0:x.id);if(!S){f.ue.error("No visual to save");return}d(!0),C.mutate({visualId:S,data:{frameObject:g}},{onSuccess:()=>{d(!1),f.ue.success("Visual updated successfully"),l.invalidateQueries({queryKey:["resource-by-id","visual",S],exact:!0})},onError:()=>{d(!1),f.ue.error("Failed to update visual")}})};return e.jsx(s.Button,{onClick:y,className:r,size:"xs",variant:a,children:n?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(Se.Save,{className:"h-3.5 w-3.5"}),"Save to Library"]})})}function He({className:r}){const a=f.useQueryClient(),[l,n]=v.useState(!1),d=f.useSelectedVisual(),u=s.useEditorStore(k=>k.frame),m=s.useDashboardStore(k=>k.selectedSheetId),x=s.useDashboardStore(k=>k.dashboard),{updateFrame:p,setIsVisualEditing:C}=s.useDashboardActions(),{getUpdatedFrame:y}=ae(),g=f.useUpdateVisualMutation(),S=f.useResolveExistingFrameSemanticExecutionPayload(),D=async()=>{if(!m){f.ue.error("No sheet selected");return}const k=(u==null?void 0:u.visualId)||(d==null?void 0:d.id);if(!k){f.ue.error("No visual to update");return}n(!0);try{const E=y();if(!ue(E)){n(!1);return}const T={...E,visualId:k},O=s.findDashboardFrameById(x,T.id),$=await S(T,{previousFrame:O});await g.mutateAsync({visualId:k,data:{frameObject:E}}),p(m,T,{semanticExecutionPayload:$}),a.invalidateQueries({queryKey:["visuals"]}),a.invalidateQueries({queryKey:["visual",k]}),f.ue.success("Saved to library and applied locally"),setTimeout(()=>{C(!1)},300)}catch(E){console.error("Failed to save and apply:",E),f.ue.error(E instanceof Error?E.message:"Failed to save and apply changes")}finally{n(!1)}};return e.jsx(s.Button,{onClick:D,className:r,size:"xs",variant:"default",disabled:l,children:l?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(Se.Save,{className:"h-3.5 w-3.5"}),"Save & Apply"]})})}function Ke({className:r}){const{setTempQueryData:a,setSqlGen:l}=s.useEditorActions(),n=f.useQueryClient(),d=s.useEditorStore(g=>g.tempQueryData),u=s.useEditorStore(g=>g.onClose),m=s.useEditorStore(g=>g.card),x=f.useEffectiveEditorCardType(),p=v.useMemo(()=>x!==m.type?{...m,type:x}:m,[m,x]),{queryKey:C}=f.useEditorCardQuery(p);function y(){if(d){const{queryKey:g,queryData:S}=d;g&&S&&n.setQueryData(g,S)}l({}),u==null||u()}return e.jsxs(s.Button,{onClick:y,className:r,size:"xs",variant:"outline",children:[e.jsx(J.X,{className:"h-3.5 w-3.5"}),"Close"]})}function We({label:r="Clear",variant:a="secondary",className:l}={}){const n=Ee();return e.jsxs(s.Button,{onClick:n,className:l,size:"xs",variant:a,children:[e.jsx(J.X,{className:"h-3.5 w-3.5"}),r]})}exports.ControlDefinitionListEditor=Qe;exports.EditorAcceptButton=$e;exports.EditorCancelButton=Ke;exports.EditorClearButton=We;exports.FilterX=Ve;exports.Library=je;exports.Link2=ke;exports.VisualBadge=Me;exports.VisualSaveAndApplyButton=He;exports.VisualSaveButton=Ye;exports.useCreateFlowOverlayState=Pe;exports.useEditorClearAction=Ee;exports.useSyncLegacyEditorState=qe;exports.useVisualUtils=ae;
16
+ */const ke=J.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 Ie(r){const[a,l]=v.useState(null),[n,d]=v.useState(null),u=f.useEnsureReactGlobals();return v.useEffect(()=>{if(!r||r.trim()===""){l(null),d(null);return}if(!u)return;(async()=>{try{if(!r.startsWith("http://")&&!r.startsWith("https://"))throw new Error(`Invalid URL format: ${r}`);try{new URL(r)}catch{throw new Error(`Invalid URL: ${r}`)}const p=`${r.endsWith("/")?r:`${r}/`}index.js`;try{if(!(await fetch(p,{method:"HEAD"})).ok)throw new Error(`Module not found at ${p}`)}catch{}const C=await import(p);if(typeof C.useChartStore!="function")throw new Error("useChartStore is not a function");l(()=>C.useChartStore),d(null)}catch(x){const p=x instanceof Error?x.message:"Unknown error";console.error("Failed to load remote chart store:",p),d(p),l(null)}})()},[r,u]),a}function Te(r,a){if(r.length===0)return"";const l=r.find(n=>{var d,u;return((d=n.customCardPreferences)==null?void 0:d.visualType)==="multiple"||!!((u=n.customCardPreferences)!=null&&u.dataInputCardIds)});if(l)return l.id;if(a){const n=r.find(d=>d.id===a);if(n){const d=n.tabTitle;if(d=="All__Header")return r[0].id;if(d&&d.endsWith("__Header")){const m=d.split("__")[0],x=r.find(p=>p.tabTitle===m);return x?x.id:r[0].id}return a}}return r[0].id}const Le=r=>{if(!r||!("detailTableBackup"in r))return r;const{detailTableBackup:a,...l}=r;return l};async function be(r,a,l,n,d="Opening library visual..."){if(!a||!l)throw new Error("Missing auth token or visual ID");const u=["resource-by-id","visual",l],m=n.getQueryData(u);if(m)return console.log("Using cached visual data for:",l),{data:m,fromCache:!0};console.log("Fetching visual data from network for:",l);const x=f.ue.loading(d,{position:"top-center"});try{const p=await fetch(`${r}/management/v1/visuals/${l}`,{headers:{Authorization:`Bearer ${a}`}});if(!p.ok)throw new Error("Failed to load visual");const C=await p.json();return n.setQueryData(u,C),f.ue.dismiss(x),{data:C,fromCache:!1}}catch(p){throw f.ue.dismiss(x),p}}function Ne(r){if(typeof r=="string")return JSON.parse(r);if(typeof r=="object")return r;throw new Error("Invalid frame object format")}function Ae(r,a){var u,m;const l=(r==null?void 0:r.frameObject)??((u=r==null?void 0:r.visual)==null?void 0:u.frameObject);if(!l)return!1;const n=Ne(l);if(!(n!=null&&n.cards)||n.cards.length===0)return!1;const d=(m=n.cards)==null?void 0:m.find(x=>x.id===n.activeCardId);return d?(f.setupEditorWithCard({...a,frame:n,card:d,visualId:(r==null?void 0:r.id)||n.visualId}),!0):!1}function _e(){const r=s.useEditorStore(n=>{var d;return((d=n.card.customCardPreferences)==null?void 0:d.url)||""}),a=Ie(r);return{getUpdatedFrame:v.useCallback(()=>{var T;f.flushPendingEditorDrafts();const{frame:n,card:d,isDevMode:u,isShowingVisual:m,selectedSchemaName:x,selectedDatamodelId:p,selectedDatabaseName:C,selectedTableName:y,selectedConnectionId:g}=s.useEditorStore.getState(),S=d.sql,D=(T=a==null?void 0:a.getState())==null?void 0:T.settings,k=s.buildSavedEditorCard(d,{isDevMode:u,cardSql:S,isShowingVisual:m,selectedSchemaName:x,selectedDatamodelId:p,selectedDatabaseName:C,selectedTableName:y,selectedConnectionId:g,remoteChartSettings:D,stripConfig:Le}),E=n.cards.map(O=>O.id===d.id?k:O);return{...n,cards:E,activeCardId:Te(E,n.activeCardId)}},[a])}}function ae(){const{authToken:r,tokenProps:a}=f.useSemaphorContext(),l=f.useQueryClient(),n=f.useAddFrameWithFreshSemanticExecutionPayload(),d=f.useSelectedVisual(),{selectVisual:u}=f.useManagementActions(),{setFrame:m,setCard:x,setIsDevMode:p,initializeModeDrafts:C,setActiveTabCardId:y,updateDataSource:g,setQueryResultColumns:S,setSelectedConnectionId:D,setSelectedDatabaseName:k,setSelectedSchemaName:E,setSelectedTableName:T,setSelectedDatamodelId:O,setFilterValues:$,setInlineFilterValuesMap:U,setApplyFilters:R,clearEditorContext:W}=s.useEditorActions(),{setIsDashboardEditing:F,setIsVisualEditing:o,setSelectedFrameId:w,clearSelectedFrameId:Q}=s.useDashboardActions(),B=s.useDashboardStore(A=>A.selectedSheetId),Y=s.useDashboardStore(A=>A.selectedFrameId),H=s.useDashboardStore(A=>A.dashboard),X=s.useDashboardStore(A=>A.filterValues),q=s.useDashboardStore(A=>A.inlineFilterValuesMap),K=f.useVisualById((d==null?void 0:d.id)||"",{enabled:!!(d!=null&&d.id)&&!!(r!=null&&r.accessToken)}),Z=v.useCallback(async A=>{try{u(A),Q(),W();const{data:V,fromCache:P}=await be(a.apiServiceUrl,(r==null?void 0:r.accessToken)||"",A.id,l,"Opening library visual...");if(!Ae(V,{setFrame:m,setCard:x,setIsDevMode:p,initializeModeDrafts:C,setActiveTabCardId:y,updateDataSource:g,setQueryResultColumns:S,setSelectedConnectionId:D,setSelectedDatabaseName:k,setSelectedSchemaName:E,setSelectedTableName:T,setSelectedDatamodelId:O,setFilterValues:$,setInlineFilterValuesMap:U,setApplyFilters:R,setIsDashboardEditing:F,setIsVisualEditing:o,dashboard:H,selectedSheetId:B,selectedFrameId:Y,filterValues:X,inlineFilterValuesMap:q}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:P}}catch(V){return console.error("Error editing visual:",V),{success:!1,error:"Failed to load visual for editing"}}},[r==null?void 0:r.accessToken,a.apiServiceUrl,l,u,m,x,F,o,p,C,y,g,S,D,k,E,T,O,$,U,R,W,Q,H,B,Y,X,q]),ne=v.useCallback(async A=>{var P;const V=_=>(f.ue.error(_),{success:!1,error:_});try{if(u(A),!B)return V("No sheet selected. Please select a sheet first.");const{data:_,fromCache:oe}=await be(a.apiServiceUrl,(r==null?void 0:r.accessToken)||"",A.id,l,"Adding visual to dashboard..."),re=(_==null?void 0:_.frameObject)??((P=_==null?void 0:_.visual)==null?void 0:P.frameObject);if(!re)return V("Visual has no frame data");const z=Ne(re);if(!(z!=null&&z.cards)||z.cards.length===0)return V("Visual frame is malformed");const te={...f.cloneLinkedFrameWithSourceMapping(z),visualId:A.id};return await n(B,te,"end"),F(!0),w(te.id),{success:!0,fromCache:oe}}catch(_){return console.error("Error adding visual:",_),V(_ instanceof Error?_.message:"Failed to add visual to dashboard")}},[r==null?void 0:r.accessToken,a.apiServiceUrl,l,u,B,F,w,n]);return{visual:K.data,isLoading:K.isLoading,isError:K.isError,error:K.error,handleEditLibraryVisual:Z,handleAddLibraryVisual:ne,getUpdatedFrame:_e().getUpdatedFrame,refetch:K.refetch}}function qe(){const r=s.useEditorStore(m=>m.card.dataSource),{setSelectedConnectionId:a,setSelectedDatabaseName:l,setSelectedSchemaName:n,setSelectedTableName:d,setSelectedDatamodelId:u}=s.useEditorActions();v.useEffect(()=>{var D;if(!r)return;const{tableName:m,schemaName:x,databaseName:p,connectionId:C}=f.extractTableMetadata(r),y=(D=r.selectedEntities)==null?void 0:D[0],S=(y==null?void 0:y.type)==="model"&&"id"in y?y.id:"";a(C||""),l(p||""),n(x||""),d(m||""),u(S)},[r,a,l,n,d,u])}function Be(r,a){return{...r,sql:"",python:"",config:void 0,customCfg:"",preferences:{},interactionConfig:void 0,linkedInteractionTargetOverrides:void 0,dynamicCardPreferences:void 0,customCardPreferences:a?r.customCardPreferences:void 0,visualizationMode:"builtin",type:a?r.type:"bar"}}function Ee(){const{setTempQueryData:r}=s.useEditorActions(),a=f.useQueryClient(),l=s.useEditorStore(U=>U.tempQueryData),n=s.useEditorStore(U=>U.card),d=f.useEffectiveEditorCardType(),u=v.useMemo(()=>d!==n.type?{...n,type:d}:n,[n,d]),{queryKey:m}=f.useEditorCardQuery(u),{setCardSql:x,setSqlGen:p,setCardPython:C,setCardCustomCfg:y,setCardPreferences:g,clearQueryConfig:S,setCardConfig:D,setCardType:k,setFrame:E,setCard:T,setActiveTabCardId:O}=s.useEditorActions();function $(){var Q,B,Y,H;const U=a.getQueryData(m);l!=null&&l.queryData||r({queryKey:m,queryData:U}),a.setQueryData(m,null),a.removeQueries({queryKey:m,exact:!0}),x(""),p({}),S(),D(void 0),C(""),y(""),g({});const R=s.useEditorStore.getState().frame,W=s.useEditorStore.getState().card,F=Fe.findCustomVisualConfigCard(R,W),o=((Q=F==null?void 0:F.customCardPreferences)==null?void 0:Q.visualType)==="multiple"||!!((B=F==null?void 0:F.customCardPreferences)!=null&&B.dataInputCardIds)||(((Y=F==null?void 0:F.customCardPreferences)==null?void 0:Y.minInputs)||0)>1||(((H=F==null?void 0:F.customCardPreferences)==null?void 0:H.maxInputs)||0)>1,w=Be(W,o);E({...R,cards:R.cards.map(X=>X.id===w.id?w:X)}),O(w.id),T(w),o||k("bar")}return $}function Me({type:r,isLinked:a,className:l,showLabel:n=!1,showLocal:d=!1}){const u=s.useDashboardStore(E=>E.selectedFrameId),m=f.useManagementStore(E=>E.selectedVisual),x=s.useEditorStore(E=>E.frame);let p;if(r)p=r;else if(a!==void 0)p=a?"linked":"library";else if(!!!(x!=null&&x.visualId||m!=null&&m.id)&&u)p="local";else if(m&&!u)p="library";else if(x!=null&&x.visualId&&u)p="linked";else if(m!=null&&m.id&&u)p="library";else return null;if(p==="local"&&!d)return null;const C={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."},g={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"},S={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(ke,{className:"h-3.5 w-3.5"}),library:e.jsx(je,{className:"h-3.5 w-3.5"})},k={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(f.Badge,{variant:"outline",className:s.cn("cursor-help select-none transition-all",C[p],l),children:[D[p],n&&e.jsx("span",{className:"ml-1 text-xs font-medium leading-none",children:k[p]})]})}),e.jsxs(s.TooltipContent,{side:"bottom",className:s.cn("max-w-xs",g[p]),children:[e.jsx(s.TooltipArrow,{className:S[p]}),e.jsx("p",{children:y[p]})]})]})})}function we(r){const{control:a,onChange:l}=r;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:n=>l(n.target.value)})]})}function Oe(r){const{currentStep:a,labels:l}=r;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:l.map((n,d)=>{const u=d+1,m=u===a,x=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",m?"border-foreground bg-foreground text-background":x?"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]",m?"font-medium text-foreground":"text-muted-foreground"),children:n})]}),d<l.length-1?e.jsx("span",{className:"h-px w-4 bg-border/60 sm:w-6","aria-hidden":"true"}):null]},n)})})})}function se(r){const{secondary:a,tertiary:l,primary:n}=r;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,l,n]})}function Ue(r){const{control:a,scope:l,detail:n}=r;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(f.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(l,a.placement)]}),n?e.jsx("div",{className:"text-[12px] text-muted-foreground",children:n}):null]})]})}function ye(r){const{control:a,defaultValue:l,availableFieldChoices:n,availableMetricChoices:d,previewControlDefinitions:u,previewControlValues:m,onControlChange:x,onLabelChange:p,onDefaultValueChange:C,onBack:y,onNext:g,nextDisabled:S}=r;return e.jsxs("div",{className:"space-y-3",children:[e.jsx(we,{control:a,onChange:p}),e.jsx(f.ControlDefinitionOptionsEditor,{control:a,availableFieldChoices:n,availableMetricChoices:d,previewControlDefinitions:u,previewControlValues:m,controlLifecycle:"create",onChange:x}),e.jsx(f.ControlDefaultValueEditor,{control:a,value:l,onChange:C,allowNoDefault:!0,allowCardDefault:!0,hint:"This is the value viewers will see first.",previewControlDefinitions:u,previewControlValues:m}),e.jsx(se,{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:g,disabled:S,children:"Next"})})]})}const ze=new Set(["grain_selector","aggregation_selector","field_selector","metric_selector"]);function ve(r){const{text:a,ariaLabel:l}=r,[n,d]=v.useState(!1);return e.jsxs("button",{type:"button","aria-label":l,onClick:async()=>{try{await navigator.clipboard.writeText(a),d(!0),setTimeout(()=>d(!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:n?"Copied":"Click to copy"})]})}function Ce(r){const{control:a,scope:l,createdReference:n,explorerContent:d,sqlDescription:u,summaryDetail:m,onBack:x,onCancel:p,onDone:C}=r,y=ze.has(a.type),g=n.match(/\[\[param\.(.+?)\]\]/),S=g?`{{ param('${g[1]}') }}`:"";return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ue,{control:a,scope:l,detail:m}),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:d})]}):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(ve,{text:n,ariaLabel:"Copy SQL control reference"}),S?e.jsx(ve,{text:S,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(se,{secondary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:x,children:"Back"}),tertiary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:p,children:"Cancel"}),primary:e.jsx(s.Button,{type:"button",size:"xs",onClick:C,children:"Done"})})]})}function Re(r){const a=s.createBlankControl(r.scope,r.existingControls,r.reservedIds),l=r.type===a.type?{...a,label:s.DEFAULT_LABEL_BY_TYPE[r.type]}:{...s.applyControlTypeChange({controls:[{...a,label:s.DEFAULT_LABEL_BY_TYPE[r.type]}],controlId:a.id,nextType:r.type}).controls[0],label:s.DEFAULT_LABEL_BY_TYPE[r.type]};return{step:2,control:l,defaultValue:s.getDefaultValueForType(l,void 0)}}function Qe({scope:r,controls:a,reservedControlIds:l,defaultValues:n,onChange:d,emptyMessage:u,initialCreateFlow:m=!1,usageByControlId:x,availableFieldChoices:p,availableMetricChoices:C,structuralParticipants:y,structuralParticipantIdsByControlId:g,card:S,allowedControlTypes:D,onCreateFlowActiveChange:k,onCreateFlowComplete:E}){const T=v.useMemo(()=>new Set(l||[]),[l]),O=s.getPlacementOptionsForScope(r),$=s.getDefaultPlacement(r),[U,R]=v.useState(null),[W,F]=v.useState(null),[o,w]=v.useState(()=>m?{step:1,control:s.createBlankControl(r,a,Array.from(T))}:null),Q=v.useRef({}),B=v.useRef(void 0),Y=v.useRef(m),H=v.useMemo(()=>{const t=s.getFriendlyControlTypeOptions({scope:r,card:S});if(!D)return t;const c=new Set(D);return t.filter(i=>c.has(i.value))},[D,S,r]),X=v.useCallback(t=>{const c=s.getFriendlyControlTypeOptions({scope:r,card:S,includeType:D?void 0:t});if(!D)return c;const i=new Set(D);return c.filter(h=>i.has(h.value))},[D,S,r]),q=v.useCallback(t=>r==="dashboard"&&(t==="field_selector"||t==="metric_selector"),[r]),K=v.useMemo(()=>o?s.getEligibleParticipantsForStructuralControl(y||[],o.control.type):[],[o,y]),Z=v.useMemo(()=>{if(!o)return{fields:p||[],metrics:C||[]};if(!q(o.control.type))return{fields:p||[],metrics:C||[]};const t=o.selectedCardIds||[],c=s.getCompatibleStructuralChoiceCatalog({controlType:o.control.type,participants:y||[],selectedCardIds:t});return{fields:o.control.type==="field_selector"?c.choices.map(i=>({option:i,target:c.fieldTargetMap[i.value]})):[],metrics:o.control.type==="metric_selector"?c.choices.map(i=>({option:i,target:c.metricTargetMap[i.value]})):[]}},[p,C,o,q,y]);v.useEffect(()=>{k==null||k(!!o)},[o,k]),v.useEffect(()=>{const t=m&&!Y.current;Y.current=m,t&&(w({step:1,control:s.createBlankControl(r,a,Array.from(T))}),F(null),R(null))},[a,m,T,r]);const ne=t=>{if(!q(t.type))return{fields:p||[],metrics:C||[]};const c=(g==null?void 0:g[t.id])||[];if(c.length===0)return{fields:p||[],metrics:C||[]};const i=s.getCompatibleStructuralChoiceCatalog({controlType:t.type,participants:y||[],selectedCardIds:c});return{fields:t.type==="field_selector"?i.choices.map(h=>({option:h,target:i.fieldTargetMap[h.value]})):[],metrics:t.type==="metric_selector"?i.choices.map(h=>({option:h,target:i.metricTargetMap[h.value]})):[]}},A=t=>{if(!q(t.control.type))return{nextControl:t.control,cardBindingsById:void 0};const c=(g==null?void 0:g[t.control.id])||[],i=s.getCompatibleStructuralChoiceCatalog({controlType:t.control.type,participants:y||[],selectedCardIds:t.nextSelectedCardIds}),h=s.reconcileStructuralControlChoices({control:t.control,choices:i.choices}),j=Object.fromEntries(c.filter(N=>!t.nextSelectedCardIds.includes(N)).map(N=>[N,void 0]));return t.nextSelectedCardIds.length>0&&h.source.kind==="manual"&&h.source.options.length>0&&Object.assign(j,s.buildStructuralControlBindingsForParticipants({control:h,participants:y||[],selectedCardIds:t.nextSelectedCardIds})),{nextControl:h,cardBindingsById:j}},V=v.useCallback((t,c=n,i={type:"update"})=>{const h=t.map(j=>(s.resolveAuthoringControlDefaultValue({control:j,defaultValues:c}),s.syncSqlQueryControlExecutionRequirement(j)));d(h,c,i)},[n,d]),P=(t,c)=>{const i=a.find(L=>L.id===t);let h=a.map(L=>L.id!==t?L:c(L));const j=h.find(L=>L.id===t);let N,b;if(j&&r==="dashboard"&&(j.type==="field_selector"||j.type==="metric_selector")){const L=(g==null?void 0:g[j.id])||[],ee=A({control:j,nextSelectedCardIds:L});h=h.map(G=>G.id===t?ee.nextControl:G),N=ee.cardBindingsById,b=[j.id]}else if(i&&r==="dashboard"&&(i.type==="field_selector"||i.type==="metric_selector")){const L=(g==null?void 0:g[i.id])||[];N=Object.fromEntries(L.map(ee=>[ee,void 0])),b=[i.id]}const I=h.find(L=>L.id===t);let M=n;if(i&&I){const L=s.resolveAuthoringControlDefaultValue({control:i,defaultValues:n});i.source.kind==="manual"&&I.source.kind==="sql_query"&&(Q.current[t]=L);const ee=L===void 0&&i.source.kind==="sql_query"&&I.source.kind==="manual"?Q.current[t]:L,G=s.getNextEditedControlDefaultValue({previousControl:i,nextControl:I,currentDefaultValue:ee});I.source.kind==="manual"&&(Q.current[t]=G),n&&(M={...n},G===void 0?delete M[t]:M[t]=G),h=h.map(xe=>xe.id===t?{...I,defaultValue:G}:xe)}V(h,M,{type:"update",cardBindingsById:N,affectedBindingControlIds:b})},_=(t,c)=>{if(!c.trim())return;const i=s.normalizeDashboardInputVariableName(c);if(i===t||T.has(i)||a.some(N=>N.id===i&&N.id!==t))return;const h=a.map(N=>N.id===t?{...N,id:i}:N);if(!n){V(h,void 0,{type:"rename",oldId:t,newId:i});return}const j={...n};Object.prototype.hasOwnProperty.call(j,t)&&(j[i]=j[t],delete j[t]),V(h,j,{type:"rename",oldId:t,newId:i})},oe=t=>{const c=a.filter(h=>h.id!==t);if(!n){V(c,void 0,{type:"remove",controlId:t});return}const i={...n};delete i[t],V(c,i,{type:"remove",controlId:t})},re=v.useCallback(()=>{B.current=void 0,w({step:1,control:s.createBlankControl(r,a,Array.from(T))}),F(null),R(null)},[a,T,r]),z=t=>{w(c=>c&&(()=>{const i=t(c.control);c.control.source.kind==="manual"&&i.source.kind==="sql_query"&&(B.current=c.defaultValue);const h=c.defaultValue===void 0&&c.control.source.kind==="sql_query"&&i.source.kind==="manual"?B.current:c.defaultValue,j=s.getNextEditedControlDefaultValue({previousControl:c.control,nextControl:i,currentDefaultValue:h});return i.source.kind==="manual"&&(B.current=j),{...c,control:i,defaultValue:j}})())},te=t=>{w(c=>c&&(c.control.source.kind==="manual"&&(B.current=t),{...c,defaultValue:t}))},le=(()=>{if(!o)return!1;if(o.step===2&&q(o.control.type))return(o.selectedCardIds||[]).length>0;if(o.step!==2&&o.step!==3||!o.control.label.trim())return!1;const c=o.control.source.kind==="sql_query"?o.control:s.ensureManualSource(o.control);if(c.source.kind==="manual"&&(s.needsManualOptions(c)&&c.source.options.length===0||c.source.options.some(h=>h.label.trim().length===0||h.value.trim().length===0)))return!1;if(c.source.kind==="sql_query"){const{connectionId:i,sql:h,valueColumn:j}=c.source;return i.trim().length>0&&h.trim().length>0&&j.trim().length>0}return s.hasConcreteDefaultValue(s.getDefaultValueForType(c,o.defaultValue))})(),pe=()=>{var N;if(!o)return;const t=s.ensureManualSource(o.control),c=s.deriveUniqueControlId({label:t.label,fallbackId:t.id,existingControls:a,reservedIds:Array.from(T)}),i={...t,id:c},h=r==="dashboard"&&(i.type==="field_selector"||i.type==="metric_selector")&&((N=o.selectedCardIds)!=null&&N.length)?s.buildStructuralControlBindingsForParticipants({control:i,participants:y||[],selectedCardIds:o.selectedCardIds}):void 0,j=s.getDefaultValueForType(i,o.defaultValue);w({step:r==="dashboard"&&(i.type==="field_selector"||i.type==="metric_selector")?4:3,control:i,defaultValue:j,createdControlId:c,selectedCardIds:o.selectedCardIds,cardBindingsById:h})},ie=v.useCallback(()=>{w(null)},[]),me=v.useCallback(()=>{if(!(o!=null&&o.createdControlId)){w(null);return}const t=o.control,c=o.createdControlId,i=s.getDefaultValueForType(t,o.defaultValue);if(n){const h={...n};i===void 0?delete h[c]:h[c]=i,V([...a,{...t,defaultValue:i}],h,{type:"add",cardBindingsById:o.cardBindingsById})}else V([...a,{...t,defaultValue:i}],void 0,{type:"add",cardBindingsById:o.cardBindingsById});F(c),w(null),E==null||E()},[a,o,n,V,E]),De=o?q(o.control.type)?["Choose type","Select cards","Configure","Finish"]:["Choose type","Configure","Finish"]:[],fe=o!=null&&o.createdControlId?`[[param.${o.createdControlId}]]`:o?`[[param.${s.slugifyControlValue(o.control.label)||o.control.id}]]`:"",de=s.buildAuthoringPreviewControlValues({controls:a,defaultValues:n}),ce=o?[...a,o.control]:a,he=o?s.buildAuthoringPreviewControlValues({controls:ce,defaultValues:n,overrides:[{controlId:o.control.id,value:o.defaultValue}]}):de;return e.jsxs("div",{className:"space-y-4",children:[o?e.jsxs("div",{className:"space-y-4 pb-1",children:[e.jsx(Oe,{currentStep:o.step,labels:De}),o.step===1&&(()=>{const t=new Set(["grain_selector","aggregation_selector","field_selector","metric_selector"]),c=new Set(["date","text"]),i=H.filter(N=>!t.has(N.value)&&!c.has(N.value)),h=H.filter(N=>t.has(N.value)),j=N=>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:()=>w(Re({scope:r,existingControls:a,reservedIds:Array.from(T),type:N.value})),children:[e.jsx("div",{className:"text-[13px] font-medium text-foreground",children:N.label}),e.jsx("p",{className:"mt-0.5 text-[12px] text-muted-foreground",children:N.description})]},N.value);return e.jsxs("div",{className:"space-y-4",children:[r==="card"&&(S==null?void 0:S.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(j)})]}),h.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:h.map(j)})]}),e.jsx(se,{secondary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:ie,children:"Back to controls"})})]})})(),o.step===2&&q(o.control.type)&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(we,{control:o.control,onChange:t=>z(c=>({...c,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 c=(o.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(f.Checkbox,{checked:c,onCheckedChange:i=>w(h=>h&&{...h,selectedCardIds:i===!0?[...h.selectedCardIds||[],t.cardId]:(h.selectedCardIds||[]).filter(j=>j!==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:o.control.type==="field_selector"?`${t.fieldChoices.length} compatible group-by fields`:`${t.metricChoices.length} compatible metrics`})]})]},t.cardId)})}),e.jsx(se,{secondary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:()=>w(t=>t&&{...t,step:1,selectedCardIds:[]}),children:"Back"}),primary:e.jsx(s.Button,{type:"button",size:"xs",onClick:()=>w(t=>t&&{...t,step:3}),disabled:!le,children:"Next"})})]}),o.step===2&&!q(o.control.type)&&e.jsx(ye,{control:o.control,defaultValue:o.defaultValue,availableFieldChoices:Z.fields,availableMetricChoices:Z.metrics,previewControlDefinitions:ce,previewControlValues:he,onControlChange:t=>z(()=>t),onLabelChange:t=>z(c=>({...c,label:t})),onDefaultValueChange:te,onBack:()=>w(t=>t&&{...t,step:1}),onNext:pe,nextDisabled:!le}),o.step===3&&q(o.control.type)&&e.jsx(ye,{control:o.control,defaultValue:o.defaultValue,availableFieldChoices:Z.fields,availableMetricChoices:Z.metrics,previewControlDefinitions:ce,previewControlValues:he,onControlChange:t=>z(()=>t),onLabelChange:t=>z(c=>({...c,label:t})),onDefaultValueChange:te,onBack:()=>w(t=>t&&{...t,step:2}),onNext:pe,nextDisabled:!le}),o.step===3&&!q(o.control.type)&&e.jsx(Ce,{control:o.control,scope:r,createdReference:fe,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:()=>w(t=>t&&{...t,step:2}),onCancel:ie,onDone:me}),o.step===4&&q(o.control.type)&&e.jsx(Ce,{control:o.control,scope:r,createdReference:fe,summaryDetail:e.jsxs(e.Fragment,{children:["Used by ",(o.selectedCardIds||[]).length," selected card",(o.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:()=>w(t=>t&&{...t,step:3}),onCancel:ie,onDone:me})]}):null,!o&&a.length===0?e.jsx("div",{className:"rounded-md border border-dashed p-3 text-sm text-muted-foreground",children:u}):null,!o&&a.map(t=>{const c=ne(t),i=x==null?void 0:x[t.id],h=s.resolveAuthoringControlDefaultValue({control:t,defaultValues:n}),j=W===t.id,N="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:()=>F(b=>b===t.id?null:t.id),children:[j?e.jsx(J.ChevronDown,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(ge.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:N,children:s.getFriendlyTypeOption(t.type).label}),e.jsx("span",{className:N,children:s.getPlacementLabel(r,t.placement)})]}),e.jsxs("div",{className:"mt-0.5 text-[12px] text-muted-foreground",children:[s.getControlOptionPreview(t),i!=null&&i.status?` · ${i.status}`:""]})]})]}),e.jsx(s.Button,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 shrink-0 p-0 text-muted-foreground",onClick:()=>oe(t.id),"aria-label":`Remove ${t.label}`,children:e.jsx(f.Trash2,{className:"h-3.5 w-3.5"})})]}),j&&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:b=>P(t.id,I=>({...I,label:b.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:b=>{const I=s.applyControlTypeChange({controls:a,controlId:t.id,nextType:b,defaultValues:n});V(I.controls,I.defaultValues)},children:[e.jsx(s.SelectTrigger,{size:"xs",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:X(t.type).map(b=>e.jsx(s.SelectItem,{value:b.value,children:b.label},b.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||$,onValueChange:b=>P(t.id,I=>({...I,placement:b})),children:[e.jsx(s.SelectTrigger,{size:"xs",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:O.map(b=>e.jsx(s.SelectItem,{value:b.value,children:b.label},b.value))})]})]})]}),q(t.type)?e.jsx(f.StructuralParticipantSelector,{type:t.type,participants:s.getEligibleParticipantsForStructuralControl(y||[],t.type).map(b=>({cardId:b.cardId,title:b.title,choiceCount:t.type==="field_selector"?b.fieldChoices.length:b.metricChoices.length})),selectedCardIds:(g==null?void 0:g[t.id])||[],onChange:b=>{const I=A({control:t,nextSelectedCardIds:b}),M=a.map(L=>L.id===t.id?I.nextControl:L);V(M,n,{type:"update",cardBindingsById:I.cardBindingsById})}}):null,e.jsx(f.ControlDefinitionOptionsEditor,{control:t,availableFieldChoices:c.fields,availableMetricChoices:c.metrics,previewControlDefinitions:a,previewControlValues:de,controlLifecycle:"edit",onChange:b=>P(t.id,()=>b)}),t.initialValueStrategy==="saved_default"&&e.jsx(f.ControlDefaultValueEditor,{control:t,value:h,allowNoDefault:!0,allowCardDefault:!0,previewControlDefinitions:a,previewControlValues:de,onChange:b=>{const I=a.map(M=>M.id===t.id?{...M,defaultValue:b}:M);if(t.source.kind==="manual"&&(Q.current[t.id]=b),n){const M={...n};b===void 0?delete M[t.id]:M[t.id]=b,V(I,M);return}V(I,void 0)}}),e.jsxs(f.Collapsible,{open:U===t.id,onOpenChange:b=>R(b?t.id:null),children:[e.jsx(f.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:[U===t.id?e.jsx(J.ChevronDown,{className:"h-3.5 w-3.5"}):e.jsx(ge.ChevronRight,{className:"h-3.5 w-3.5"}),"Advanced"]})}),e.jsxs(f.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(f.ControlIdInput,{controlId:t.id,onCommit:b=>_(t.id,b)},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:b=>P(t.id,I=>({...I,initialValueStrategy:b})),children:[e.jsx(s.SelectTrigger,{size:"xs",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:s.INITIAL_VALUE_STRATEGY_OPTIONS.map(b=>e.jsx(s.SelectItem,{value:b.value,children:b.label},b.value))})]})]})]}),e.jsx(f.ControlVisibilitySettings,{control:t,onChange:b=>P(t.id,()=>b)})]})]})]})]},t.id)}),!o&&e.jsxs(s.Button,{type:"button",variant:"outline",size:"xs",onClick:re,children:[e.jsx(f.Plus,{className:"h-3.5 w-3.5"}),"Add control"]})]})}function Pe(r){const{open:a,onOpenChange:l,initialCreateFlowActive:n=!1,dismissMode:d="passive"}=r,u=a!==void 0,[m,x]=v.useState(!1),[p,C]=v.useState(n),y=u?a:m,g=v.useCallback(k=>{!k&&p&&d==="passive"||(u||x(k),k||C(!1),l==null||l(k))},[u,p,d,l]),S=v.useCallback(()=>{u||x(!1),C(!1),l==null||l(!1)},[u,l]);v.useEffect(()=>{y||C(!1)},[y]);const D=v.useCallback(k=>{p&&k.preventDefault()},[p]);return{forceClose:S,handleOpenChange:g,isCreateFlowActive:p,preventPassiveDismissDuringCreate:D,resolvedOpen:y,setIsCreateFlowActive:C}}function ue(r){const a=s.getDynamicFrameSaveIssue(r);return a?(f.ue.error(a),!1):!0}function $e({className:r,variant:a="outline"}){const l=s.useEditorStore(u=>u.onSave),{getUpdatedFrame:n}=ae();function d(){const u=n();ue(u)&&(l==null||l(u))}return e.jsxs(s.Button,{onClick:d,className:r,size:"xs",variant:a,children:[e.jsx(s.Check,{className:"h-3.5 w-3.5"}),"Accept"]})}function Ye({className:r,variant:a="default"}){const l=f.useQueryClient(),[n,d]=v.useState(!1),{setIsVisualEditing:u}=s.useDashboardActions(),{getUpdatedFrame:m}=ae(),x=f.useSelectedVisual(),p=s.useEditorStore(g=>g.frame),C=f.useUpdateVisualMutation(),y=()=>{const g=m();if(!ue(g))return;const S=(p==null?void 0:p.visualId)||(x==null?void 0:x.id);if(!S){f.ue.error("No visual to save");return}d(!0),C.mutate({visualId:S,data:{frameObject:g}},{onSuccess:()=>{d(!1),f.ue.success("Visual updated successfully"),l.invalidateQueries({queryKey:["resource-by-id","visual",S],exact:!0})},onError:()=>{d(!1),f.ue.error("Failed to update visual")}})};return e.jsx(s.Button,{onClick:y,className:r,size:"xs",variant:a,children:n?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(Se.Save,{className:"h-3.5 w-3.5"}),"Save to Library"]})})}function He({className:r}){const a=f.useQueryClient(),[l,n]=v.useState(!1),d=f.useSelectedVisual(),u=s.useEditorStore(k=>k.frame),m=s.useDashboardStore(k=>k.selectedSheetId),x=s.useDashboardStore(k=>k.dashboard),{updateFrame:p,setIsVisualEditing:C}=s.useDashboardActions(),{getUpdatedFrame:y}=ae(),g=f.useUpdateVisualMutation(),S=f.useResolveExistingFrameSemanticExecutionPayload(),D=async()=>{if(!m){f.ue.error("No sheet selected");return}const k=(u==null?void 0:u.visualId)||(d==null?void 0:d.id);if(!k){f.ue.error("No visual to update");return}n(!0);try{const E=y();if(!ue(E)){n(!1);return}const T={...E,visualId:k},O=s.findDashboardFrameById(x,T.id),$=await S(T,{previousFrame:O});await g.mutateAsync({visualId:k,data:{frameObject:E}}),p(m,T,{semanticExecutionPayload:$}),a.invalidateQueries({queryKey:["visuals"]}),a.invalidateQueries({queryKey:["visual",k]}),f.ue.success("Saved to library and applied locally"),setTimeout(()=>{C(!1)},300)}catch(E){console.error("Failed to save and apply:",E),f.ue.error(E instanceof Error?E.message:"Failed to save and apply changes")}finally{n(!1)}};return e.jsx(s.Button,{onClick:D,className:r,size:"xs",variant:"default",disabled:l,children:l?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(Se.Save,{className:"h-3.5 w-3.5"}),"Save & Apply"]})})}function Ke({className:r}){const{setTempQueryData:a,setSqlGen:l}=s.useEditorActions(),n=f.useQueryClient(),d=s.useEditorStore(g=>g.tempQueryData),u=s.useEditorStore(g=>g.onClose),m=s.useEditorStore(g=>g.card),x=f.useEffectiveEditorCardType(),p=v.useMemo(()=>x!==m.type?{...m,type:x}:m,[m,x]),{queryKey:C}=f.useEditorCardQuery(p);function y(){if(d){const{queryKey:g,queryData:S}=d;g&&S&&n.setQueryData(g,S)}l({}),u==null||u()}return e.jsxs(s.Button,{onClick:y,className:r,size:"xs",variant:"outline",children:[e.jsx(J.X,{className:"h-3.5 w-3.5"}),"Close"]})}function We({label:r="Clear",variant:a="secondary",className:l}={}){const n=Ee();return e.jsxs(s.Button,{onClick:n,className:l,size:"xs",variant:a,children:[e.jsx(J.X,{className:"h-3.5 w-3.5"}),r]})}exports.ControlDefinitionListEditor=Qe;exports.EditorAcceptButton=$e;exports.EditorCancelButton=Ke;exports.EditorClearButton=We;exports.FilterX=Ve;exports.Library=je;exports.Link2=ke;exports.VisualBadge=Me;exports.VisualSaveAndApplyButton=He;exports.VisualSaveButton=Ye;exports.useCreateFlowOverlayState=Pe;exports.useEditorClearAction=Ee;exports.useSyncLegacyEditorState=qe;exports.useVisualUtils=ae;
@@ -1,14 +1,14 @@
1
1
  import { c as Te, C as je, X as Ze } from "./x-CXDkqdur.js";
2
2
  import { useState as H, useEffect as ie, useCallback as U, useMemo as oe, useRef as ke, Fragment as ht } from "react";
3
- import { E as de, z as _e, u as J, D as z, a4 as bt, Q as gt, V as yt, W as vt, c as fe, Y as xt, a5 as Ct, a6 as kt, a7 as pe, a8 as Re, a9 as Qe, aa as Se, ab as Ne, ac as St, ad as $e, ae as Nt, af as wt, ag as me, ah as Dt, ai as Pe, B as L, aj as et, ak as tt, al as rt, O as ne, Z as at, _ as we, $ as De, a0 as Ee, a1 as Fe, a2 as Ie, am as st, an as Et, ao as Ft, ap as We, aq as It, ar as He, as as Vt, at as Ve, d as Tt, L as nt, au as _t, av as At } from "./switch-DQR-Va05.js";
4
- import { b7 as Lt, az as qt, b8 as ce, b9 as Mt, ba as Ae, bb as Ot, bc as zt, bd as Ut, aG as B, be as Bt, bf as jt, bg as Rt, bh as ot, bi as lt, u as Qt, bj as $t, bk as Pt, bl as Wt, bm as Ht, bn as it, bo as dt, bp as Kt, bq as Yt, br as Gt, bs as Xt, bt as Jt, aZ as Zt, bu as er, bv as tr, bw as ct, bx as rr } from "./index-BS2-ZZGf.js";
3
+ import { E as de, z as _e, u as J, D as z, a4 as bt, Q as gt, V as yt, W as vt, c as fe, Y as xt, a5 as Ct, a6 as kt, a7 as pe, a8 as Re, a9 as Qe, aa as Se, ab as Ne, ac as St, ad as $e, ae as Nt, af as wt, ag as me, ah as Dt, ai as Pe, B as L, aj as et, ak as tt, al as rt, O as ne, Z as at, _ as we, $ as De, a0 as Ee, a1 as Fe, a2 as Ie, am as st, an as Et, ao as Ft, ap as We, aq as It, ar as He, as as Vt, at as Tt, au as Ve, d as _t, L as nt, av as At, aw as Lt } from "./switch-kPUJEC1A.js";
4
+ import { b7 as qt, az as Mt, b8 as ce, b9 as Ot, ba as Ae, bb as zt, bc as Ut, bd as Bt, aG as B, be as jt, bf as Rt, bg as Qt, bh as ot, bi as lt, u as $t, bj as Pt, bk as Wt, bl as Ht, bm as Kt, bn as it, bo as dt, bp as Yt, bq as Gt, br as Xt, bs as Jt, bt as Zt, aZ as er, bu as tr, bv as ct, bw as rr } from "./index-DazD5k0F.js";
5
5
  import { jsx as r, jsxs as p, Fragment as re } from "react/jsx-runtime";
6
- import "./saved-temporal-bucket-format-SGAV0ivR.js";
7
- import "./validators-DEmd8Sin.js";
8
- import "./analyze-result-contract-BbRJ-C06.js";
6
+ import "./saved-temporal-bucket-format-Dd2eixTH.js";
7
+ import "./validators-DVd8s3qY.js";
8
+ import "./analyze-result-contract-DROq4vgY.js";
9
9
  import "../value-format-preferences/index.js";
10
10
  import { C as Ke } from "./search-BHsQIWBV.js";
11
- import { f as ar } from "./index-BIFLI8ul.js";
11
+ import { f as ar } from "./index-De_7nrwb.js";
12
12
  import { S as ut } from "./save-DgMfP0j8.js";
13
13
  /**
14
14
  * @license lucide-react v0.453.0 - ISC
@@ -45,7 +45,7 @@ const nr = Te("Link2", [
45
45
  ["line", { x1: "8", x2: "16", y1: "12", y2: "12", key: "1jonct" }]
46
46
  ]);
47
47
  function or(t) {
48
- const [a, o] = H(null), [s, i] = H(null), c = Lt();
48
+ const [a, o] = H(null), [s, i] = H(null), c = qt();
49
49
  return ie(() => {
50
50
  if (!t || t.trim() === "") {
51
51
  o(null), i(null);
@@ -162,7 +162,7 @@ function dr(t, a) {
162
162
  const i = (m = s.cards) == null ? void 0 : m.find(
163
163
  (h) => h.id === s.activeCardId
164
164
  );
165
- return i ? (Bt({
165
+ return i ? (jt({
166
166
  ...a,
167
167
  frame: s,
168
168
  card: i,
@@ -178,7 +178,7 @@ function cr() {
178
178
  ), a = or(t);
179
179
  return { getUpdatedFrame: U(() => {
180
180
  var V;
181
- jt();
181
+ Rt();
182
182
  const {
183
183
  frame: s,
184
184
  card: i,
@@ -211,7 +211,7 @@ function cr() {
211
211
  }, [a]) };
212
212
  }
213
213
  function Le() {
214
- const { authToken: t, tokenProps: a } = qt(), o = ce(), s = Mt(), i = Ae(), { selectVisual: c } = Ot(), {
214
+ const { authToken: t, tokenProps: a } = Mt(), o = ce(), s = Ot(), i = Ae(), { selectVisual: c } = zt(), {
215
215
  setFrame: m,
216
216
  setCard: h,
217
217
  setIsDevMode: u,
@@ -235,7 +235,7 @@ function Le() {
235
235
  clearSelectedFrameId: P
236
236
  } = _e(), M = J((_) => _.selectedSheetId), Y = J((_) => _.selectedFrameId), G = J((_) => _.dashboard), ee = J((_) => _.filterValues), q = J(
237
237
  (_) => _.inlineFilterValuesMap
238
- ), X = zt((i == null ? void 0 : i.id) || "", {
238
+ ), X = Ut((i == null ? void 0 : i.id) || "", {
239
239
  enabled: !!(i != null && i.id) && !!(t != null && t.accessToken)
240
240
  }), ae = U(
241
241
  async (_) => {
@@ -328,7 +328,7 @@ function Le() {
328
328
  if (!(Q != null && Q.cards) || Q.cards.length === 0)
329
329
  return F("Visual frame is malformed");
330
330
  const le = {
331
- ...Ut(Q),
331
+ ...Bt(Q),
332
332
  visualId: _.id
333
333
  // Link this frame to the library visual
334
334
  };
@@ -376,7 +376,7 @@ function Vr() {
376
376
  ie(() => {
377
377
  var D;
378
378
  if (!t) return;
379
- const { tableName: m, schemaName: h, databaseName: u, connectionId: v } = Rt(t), y = (D = t.selectedEntities) == null ? void 0 : D[0], x = (y == null ? void 0 : y.type) === "model" && "id" in y ? y.id : "";
379
+ const { tableName: m, schemaName: h, databaseName: u, connectionId: v } = Qt(t), y = (D = t.selectedEntities) == null ? void 0 : D[0], x = (y == null ? void 0 : y.type) === "model" && "id" in y ? y.id : "";
380
380
  a(v || ""), o(u || ""), s(h || ""), i(m || ""), c(x);
381
381
  }, [
382
382
  t,
@@ -441,7 +441,7 @@ function Tr({
441
441
  showLabel: s = !1,
442
442
  showLocal: i = !1
443
443
  }) {
444
- const c = J((N) => N.selectedFrameId), m = Qt((N) => N.selectedVisual), h = z((N) => N.frame);
444
+ const c = J((N) => N.selectedFrameId), m = $t((N) => N.selectedVisual), h = z((N) => N.frame);
445
445
  let u;
446
446
  if (t)
447
447
  u = t;
@@ -486,7 +486,7 @@ function Tr({
486
486
  };
487
487
  return /* @__PURE__ */ r(gt, { children: /* @__PURE__ */ p(yt, { delayDuration: 300, children: [
488
488
  /* @__PURE__ */ r(vt, { asChild: !0, children: /* @__PURE__ */ p(
489
- $t,
489
+ Pt,
490
490
  {
491
491
  variant: "outline",
492
492
  className: fe(
@@ -994,7 +994,7 @@ function _r({
994
994
  }, A = (e, d) => {
995
995
  if (!d.trim())
996
996
  return;
997
- const l = er(d);
997
+ const l = Tt(d);
998
998
  if (l === e || V.has(l) || a.some(
999
999
  (S) => S.id === l && S.id !== e
1000
1000
  ))
@@ -1249,7 +1249,7 @@ function _r({
1249
1249
  className: "flex items-start gap-2 rounded-control px-1.5 py-1 text-[13px] hover:bg-muted/40",
1250
1250
  children: [
1251
1251
  /* @__PURE__ */ r(
1252
- Pt,
1252
+ Wt,
1253
1253
  {
1254
1254
  checked: d,
1255
1255
  onCheckedChange: (l) => w(
@@ -1455,7 +1455,7 @@ function _r({
1455
1455
  className: "h-7 w-7 shrink-0 p-0 text-muted-foreground",
1456
1456
  onClick: () => ge(e.id),
1457
1457
  "aria-label": `Remove ${e.label}`,
1458
- children: /* @__PURE__ */ r(Wt, { className: "h-3.5 w-3.5" })
1458
+ children: /* @__PURE__ */ r(Ht, { className: "h-3.5 w-3.5" })
1459
1459
  }
1460
1460
  )
1461
1461
  ] }),
@@ -1526,7 +1526,7 @@ function _r({
1526
1526
  ] })
1527
1527
  ] }),
1528
1528
  q(e.type) ? /* @__PURE__ */ r(
1529
- Ht,
1529
+ Kt,
1530
1530
  {
1531
1531
  type: e.type,
1532
1532
  participants: Qe(
@@ -1587,12 +1587,12 @@ function _r({
1587
1587
  }
1588
1588
  ),
1589
1589
  /* @__PURE__ */ p(
1590
- Kt,
1590
+ Yt,
1591
1591
  {
1592
1592
  open: R === e.id,
1593
1593
  onOpenChange: (g) => $(g ? e.id : null),
1594
1594
  children: [
1595
- /* @__PURE__ */ r(Yt, { asChild: !0, children: /* @__PURE__ */ p(
1595
+ /* @__PURE__ */ r(Gt, { asChild: !0, children: /* @__PURE__ */ p(
1596
1596
  L,
1597
1597
  {
1598
1598
  type: "button",
@@ -1605,12 +1605,12 @@ function _r({
1605
1605
  ]
1606
1606
  }
1607
1607
  ) }),
1608
- /* @__PURE__ */ p(Gt, { className: "space-y-3 pt-2", children: [
1608
+ /* @__PURE__ */ p(Xt, { className: "space-y-3 pt-2", children: [
1609
1609
  /* @__PURE__ */ p("div", { className: "grid gap-3 md:grid-cols-2", children: [
1610
1610
  /* @__PURE__ */ p("div", { className: "flex flex-col gap-1.5", children: [
1611
1611
  /* @__PURE__ */ r(ne, { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Variable name" }),
1612
1612
  /* @__PURE__ */ r(
1613
- Xt,
1613
+ Jt,
1614
1614
  {
1615
1615
  controlId: e.id,
1616
1616
  onCommit: (g) => A(e.id, g)
@@ -1644,7 +1644,7 @@ function _r({
1644
1644
  ] })
1645
1645
  ] }),
1646
1646
  /* @__PURE__ */ r(
1647
- Jt,
1647
+ Zt,
1648
1648
  {
1649
1649
  control: e,
1650
1650
  onChange: (g) => W(e.id, () => g)
@@ -1668,7 +1668,7 @@ function _r({
1668
1668
  size: "xs",
1669
1669
  onClick: ue,
1670
1670
  children: [
1671
- /* @__PURE__ */ r(Zt, { className: "h-3.5 w-3.5" }),
1671
+ /* @__PURE__ */ r(er, { className: "h-3.5 w-3.5" }),
1672
1672
  "Add control"
1673
1673
  ]
1674
1674
  }
@@ -1710,7 +1710,7 @@ function Ar(t) {
1710
1710
  };
1711
1711
  }
1712
1712
  function qe(t) {
1713
- const a = At(t);
1713
+ const a = Lt(t);
1714
1714
  return a ? (B.error(a), !1) : !0;
1715
1715
  }
1716
1716
  function Lr({
@@ -1730,7 +1730,7 @@ function Lr({
1730
1730
  size: "xs",
1731
1731
  variant: a,
1732
1732
  children: [
1733
- /* @__PURE__ */ r(Tt, { className: "h-3.5 w-3.5" }),
1733
+ /* @__PURE__ */ r(_t, { className: "h-3.5 w-3.5" }),
1734
1734
  "Accept"
1735
1735
  ]
1736
1736
  }
@@ -1814,7 +1814,7 @@ function Mr({
1814
1814
  ...N,
1815
1815
  visualId: k
1816
1816
  // Keep the link to library visual
1817
- }, j = _t(h, V.id), K = await x(V, {
1817
+ }, j = At(h, V.id), K = await x(V, {
1818
1818
  previousFrame: j
1819
1819
  });
1820
1820
  await b.mutateAsync({