react-semaphor 0.1.267 → 0.1.268

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 (35) hide show
  1. package/dist/chunks/{dashboard-controls-d8j31cnQ.js → dashboard-controls-D9FGH-ux.js} +108 -108
  2. package/dist/chunks/{dashboard-controls-BRv37g5w.js → dashboard-controls-DVZnpRK5.js} +1 -1
  3. package/dist/chunks/dashboard-filter-controls-button-CcrX4Kjv.js +11 -0
  4. package/dist/chunks/{dashboard-filter-controls-button-BOs9T2hG.js → dashboard-filter-controls-button-DdI-qlYl.js} +209 -199
  5. package/dist/chunks/{dashboard-json-DjNS3G-C.js → dashboard-json-1s8UpQRT.js} +1 -1
  6. package/dist/chunks/{dashboard-json-CnEYIbNI.js → dashboard-json-B9t11hsc.js} +1 -1
  7. package/dist/chunks/{dashboard-summary-settings-dialog-DOVwh8Cc.js → dashboard-summary-settings-dialog-BXJnm_OC.js} +1 -1
  8. package/dist/chunks/{dashboard-summary-settings-dialog-CrBOuggE.js → dashboard-summary-settings-dialog-BruCXCaN.js} +1 -1
  9. package/dist/chunks/{edit-dashboard-visual-D4UMcS6R.js → edit-dashboard-visual-C4HfjuuW.js} +7447 -6972
  10. package/dist/chunks/edit-dashboard-visual-DrdskRgR.js +193 -0
  11. package/dist/chunks/{index-D5jdzvu3.js → index-BrLm4rYX.js} +35935 -34785
  12. package/dist/chunks/{index-C2i6CRUk.js → index-DTw8TJ-8.js} +523 -326
  13. package/dist/chunks/{resource-management-panel-3XD0FrTD.js → resource-management-panel-C7hHyHwo.js} +16 -16
  14. package/dist/chunks/{resource-management-panel-ZK4SWoad.js → resource-management-panel-CLZBF-Dw.js} +1 -1
  15. package/dist/chunks/{use-create-flow-overlay-state-Bb83NOgW.js → use-create-flow-overlay-state-BrRL7vBF.js} +589 -591
  16. package/dist/chunks/use-create-flow-overlay-state-C6B_dReH.js +21 -0
  17. package/dist/chunks/{use-visual-utils-Bj7eAUMG.js → use-visual-utils-1cXtOxvS.js} +111 -123
  18. package/dist/chunks/use-visual-utils-CLCzIgCj.js +1 -0
  19. package/dist/dashboard/index.cjs +1 -1
  20. package/dist/dashboard/index.js +1 -1
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.js +5 -5
  23. package/dist/style.css +1 -1
  24. package/dist/surfboard/index.cjs +1 -1
  25. package/dist/surfboard/index.js +2 -2
  26. package/dist/types/dashboard.d.ts +38 -0
  27. package/dist/types/main.d.ts +40 -0
  28. package/dist/types/shared.d.ts +38 -0
  29. package/dist/types/surfboard.d.ts +38 -0
  30. package/dist/types/types.d.ts +38 -0
  31. package/package.json +1 -1
  32. package/dist/chunks/dashboard-filter-controls-button-DKRyKRsP.js +0 -11
  33. package/dist/chunks/edit-dashboard-visual-D6RokBEF.js +0 -188
  34. package/dist/chunks/use-create-flow-overlay-state-Cmt64wFE.js +0 -21
  35. package/dist/chunks/use-visual-utils-Bdwejpa1.js +0 -1
@@ -1,21 +0,0 @@
1
- "use strict";const e=require("./index-C2i6CRUk.js"),t=require("react/jsx-runtime"),R=require("./use-visual-utils-Bdwejpa1.js"),C=require("react");/**
2
- * @license lucide-react v0.453.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const pe=e.createLucideIcon("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
7
- * @license lucide-react v0.453.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const ne=e.createLucideIcon("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);/**
12
- * @license lucide-react v0.453.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const de=e.createLucideIcon("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/**
17
- * @license lucide-react v0.453.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const W=e.createLucideIcon("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);function J(){var n,v;const l=e.useEditorStore(b=>b.card),r=e.useEditorStore(b=>b.frame),d=C.useMemo(()=>e.findCustomVisualConfigCard(r,l),[r,l]),{manifest:i}=e.useCustomVisual(((n=d==null?void 0:d.customCardPreferences)==null?void 0:n.url)||""),m=C.useMemo(()=>{var b;return(b=i==null?void 0:i.visuals)==null?void 0:b.find(h=>{var y;return h.name===((y=d==null?void 0:d.customCardPreferences)==null?void 0:y.componentName)})},[i,(v=d==null?void 0:d.customCardPreferences)==null?void 0:v.componentName]),f=e.resolveMultiInputType(d,m),p=C.useMemo(()=>e.getCustomVisualInputCards({frame:r,configCard:d,isMultiInputVisual:f==="multiple"}),[r,d,f]),x=C.useMemo(()=>{const b=p.findIndex(h=>(h==null?void 0:h.id)===l.id);return b<0?-1:e.getSlotIndexForCard(l,b)},[p,l]);return C.useMemo(()=>!d||f!=="multiple"||x<0?l.type:e.getEffectiveCardTypeForSlot(l,x,m==null?void 0:m.slots)??l.type,[d,f,x,l,m==null?void 0:m.slots])}function xe({type:l,isLinked:r,className:d,showLabel:i=!1,showLocal:m=!1}){const f=e.useDashboardStore(E=>E.selectedFrameId),p=e.useManagementStore(E=>E.selectedVisual),x=e.useEditorStore(E=>E.frame);let n;if(l)n=l;else if(r!==void 0)n=r?"linked":"library";else if(!!!(x!=null&&x.visualId||p!=null&&p.id)&&f)n="local";else if(p&&!f)n="library";else if(x!=null&&x.visualId&&f)n="linked";else if(p!=null&&p.id&&f)n="library";else return null;if(n==="local"&&!m)return null;const v={local:"border-slate-200/70 bg-slate-50/80 text-slate-700 shadow-sm hover:bg-slate-100/80 dark:border-slate-700 dark:bg-slate-900/70 dark:text-slate-200 dark:hover:bg-slate-800/80",linked:"border-purple-200/70 bg-gradient-to-r from-purple-50/50 to-purple-100/30 text-purple-900 shadow-sm hover:from-purple-100/60 hover:to-purple-100/50 hover:shadow-md dark:border-purple-800/50 dark:from-purple-950/40 dark:to-purple-900/30 dark:text-purple-100 dark:hover:from-purple-950/60 dark:hover:to-purple-900/50",library:"border-blue-200/70 bg-gradient-to-r from-blue-50/50 to-blue-100/30 text-blue-900 shadow-sm hover:from-blue-100/60 hover:to-blue-100/50 hover:shadow-md dark:border-blue-800/50 dark:from-blue-950/40 dark:to-blue-900/30 dark:text-blue-100 dark:hover:from-blue-950/60 dark:hover:to-blue-900/50"},b={local:"Local to this dashboard: Changes made here only affect this dashboard copy.",linked:"Linked to library: Changes made here update the library visual and all linked instances.",library:"Library visual: Share and reuse this visual across multiple dashboards."},h={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"},y={local:"fill-slate-50 dark:fill-slate-900",linked:"fill-purple-50 dark:fill-purple-950",library:"fill-blue-50 dark:fill-blue-950"},j={local:t.jsx("span",{className:"h-2 w-2 rounded-full bg-current/70"}),linked:t.jsx(de,{className:"h-3.5 w-3.5"}),library:t.jsx(ne,{className:"h-3.5 w-3.5"})},L={local:"Local",linked:"Linked",library:"Library"};return t.jsx(e.TooltipProvider,{children:t.jsxs(e.Tooltip,{delayDuration:300,children:[t.jsx(e.TooltipTrigger,{asChild:!0,children:t.jsxs(e.Badge,{variant:"outline",className:e.cn("cursor-help select-none transition-all",v[n],d),children:[j[n],i&&t.jsx("span",{className:"ml-1 text-xs font-medium leading-none",children:L[n]})]})}),t.jsxs(e.TooltipContent,{side:"bottom",className:e.cn("max-w-xs",h[n]),children:[t.jsx(e.TooltipArrow,{className:y[n]}),t.jsx("p",{children:b[n]})]})]})})}function he(l,r){return{...l,sql:"",python:"",config:void 0,customCfg:"",preferences:{},interactionConfig:void 0,linkedInteractionTargetOverrides:void 0,customCardPreferences:r?l.customCardPreferences:void 0,type:r?l.type:"bar"}}function fe({className:l,variant:r="outline"}){var x;const{setCardSql:d}=e.useEditorActions();e.useEditorStore(n=>n.frame);const i=e.useEditorStore(n=>n.card);R.useRemoteChartStore(((x=i.customCardPreferences)==null?void 0:x.url)||""),e.useEditorStore(n=>n.selectedSchemaName),e.useEditorStore(n=>n.selectedDatamodelId),e.useEditorStore(n=>n.selectedDatabaseName),e.useEditorStore(n=>n.selectedTableName),e.useEditorStore(n=>n.selectedConnectionId),e.useEditorStore(n=>n.isShowingVisual),i.sql;const m=e.useEditorStore(n=>n.onSave),{getUpdatedFrame:f}=R.useVisualUtils();function p(){const n=f();m==null||m(n)}return t.jsxs(e.Button,{onClick:p,className:e.cn("h-8",l),size:"sm",variant:r,children:[t.jsx(e.Check,{className:"mr-2 size-4 font-bold"}),"Accept"]})}function be({className:l,variant:r="default"}){const d=e.useQueryClient(),[i,m]=C.useState(!1),f=e.useDashboardStore(y=>y.actions.setIsDashboardPanelOpen),{setIsVisualEditing:p}=e.useDashboardActions(),{getUpdatedFrame:x}=R.useVisualUtils(),n=e.useSelectedVisual(),v=e.useEditorStore(y=>y.frame),b=e.useUpdateVisualMutation(),h=()=>{const y=x(),j=(v==null?void 0:v.visualId)||(n==null?void 0:n.id);if(!j){e.ue.error("No visual to save");return}m(!0),b.mutate({visualId:j,data:{frameObject:y}},{onSuccess:()=>{m(!1),f(!0),e.ue.success("Visual updated successfully"),d.invalidateQueries({queryKey:["resource-by-id","visual",j],exact:!0})},onError:()=>{m(!1),e.ue.error("Failed to update visual")}})};return t.jsxs(e.Button,{onClick:h,className:e.cn("h-8",l),size:"sm",variant:r,children:[i&&t.jsxs(t.Fragment,{children:[t.jsx(e.LoaderCircle,{className:"mr-2 size-4 animate-spin font-bold"})," Saving"]}),!i&&t.jsxs(t.Fragment,{children:[t.jsx(W,{className:"mr-2 size-4 font-bold"}),"Save to Library"]})]})}function ye({className:l}){const r=e.useQueryClient(),[d,i]=C.useState(!1),m=e.useSelectedVisual(),f=e.useEditorStore(y=>y.frame),p=e.useDashboardStore(y=>y.selectedSheetId),{updateFrame:x,setIsVisualEditing:n}=e.useDashboardActions(),{getUpdatedFrame:v}=R.useVisualUtils(),b=e.useUpdateVisualMutation(),h=async()=>{if(!p){e.ue.error("No sheet selected");return}const y=(f==null?void 0:f.visualId)||(m==null?void 0:m.id);if(!y){e.ue.error("No visual to update");return}i(!0);try{const j=v();await b.mutateAsync({visualId:y,data:{frameObject:j}});const L={...j,visualId:y};x(p,L),r.invalidateQueries({queryKey:["visuals"]}),r.invalidateQueries({queryKey:["visual",y]}),e.ue.success("Saved to library and applied locally"),setTimeout(()=>{n(!1)},300)}catch(j){console.error("Failed to save and apply:",j),e.ue.error("Failed to save and apply changes")}finally{i(!1)}};return t.jsx(e.Button,{onClick:h,className:e.cn("h-8",l),size:"sm",variant:"default",disabled:d,children:d?t.jsxs(t.Fragment,{children:[t.jsx(e.LoaderCircle,{className:"mr-2 size-4 animate-spin font-bold"})," Saving..."]}):t.jsxs(t.Fragment,{children:[t.jsx(W,{className:"mr-2 size-4 font-bold"}),"Save & Apply"]})})}function ge({className:l}){const{setTempQueryData:r,setSqlGen:d}=e.useEditorActions(),i=e.useQueryClient(),m=e.useEditorStore(h=>h.tempQueryData),f=e.useEditorStore(h=>h.onClose),p=e.useEditorStore(h=>h.card),x=J(),n=C.useMemo(()=>x!==p.type?{...p,type:x}:p,[p,x]),{queryKey:v}=e.useDashboardCardQuery(n);function b(){if(m){const{queryKey:h,queryData:y}=m;h&&y&&i.setQueryData(h,y)}d({}),f==null||f()}return t.jsxs(e.Button,{onClick:b,className:e.cn("h-8",l),size:"sm",variant:"outline",children:[t.jsx(e.X,{className:"mr-2 size-4"}),"Close"]})}function Ce({label:l="Clear",variant:r="secondary",className:d}={}){const{setTempQueryData:i}=e.useEditorActions(),m=e.useQueryClient(),f=e.useEditorStore(a=>a.tempQueryData),p=e.useEditorStore(a=>a.card),x=J(),n=C.useMemo(()=>x!==p.type?{...p,type:x}:p,[p,x]),{queryKey:v}=e.useDashboardCardQuery(n),{setCardSql:b,setSqlGen:h,setCardPython:y,setCardCustomCfg:j,setCardPreferences:L,clearQueryConfig:E,setCardConfig:K,setCardType:P,setFrame:z,setCard:M,setActiveTabCardId:H}=e.useEditorActions();function q(){var F,U,_,I;const a=m.getQueryData(v);f!=null&&f.queryData||i({queryKey:v,queryData:a}),m.setQueryData(v,null),m.removeQueries({queryKey:v,exact:!0}),b(""),h({}),E(),K(void 0),y(""),j(""),L({});const k=e.useEditorStore.getState().frame,O=e.useEditorStore.getState().card,T=e.findCustomVisualConfigCard(k,O),D=((F=T==null?void 0:T.customCardPreferences)==null?void 0:F.visualType)==="multiple"||!!((U=T==null?void 0:T.customCardPreferences)!=null&&U.dataInputCardIds)||(((_=T==null?void 0:T.customCardPreferences)==null?void 0:_.minInputs)||0)>1||(((I=T==null?void 0:T.customCardPreferences)==null?void 0:I.maxInputs)||0)>1,V=he(O,D);z({...k,cards:k.cards.map(B=>B.id===V.id?V:B)}),H(V.id),M(V),D||P("bar")}return t.jsxs(e.Button,{onClick:q,className:e.cn("h-8",d),size:"sm",variant:r,children:[t.jsx(e.X,{className:"mr-2 size-3.5"}),l]})}function oe(l){const{control:r,onChange:d}=l;return t.jsxs("div",{className:"space-y-1",children:[t.jsx(e.Label,{className:"text-xs",children:"Label"}),t.jsxs("div",{className:"relative",children:[t.jsx(e.Input,{className:"pr-40",value:r.label,placeholder:"Control label",onChange:i=>d(i.target.value)}),t.jsx(e.Badge,{variant:"outline",className:"pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-xs",children:e.getFriendlyTypeOption(r.type).label})]})]})}function ve(l){const{currentStep:r,labels:d}=l;return t.jsx("div",{className:"sticky top-0 z-10 -mx-1 border-b bg-background/95 px-1 pb-2 pt-1 backdrop-blur supports-[backdrop-filter]:bg-background/85",children:t.jsx("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:d.map((i,m)=>{const f=m+1,p=f===r,x=f<r;return t.jsxs(C.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:e.cn("flex h-7 w-7 items-center justify-center rounded-full border text-[11px] font-semibold",p?"border-primary bg-primary text-primary-foreground":x?"border-primary/25 bg-primary/10 text-primary":"border-border bg-muted/30 text-muted-foreground"),children:f}),t.jsx("span",{className:e.cn("text-xs font-medium",p?"text-foreground":"text-muted-foreground"),children:i})]}),m<d.length-1?t.jsx("span",{className:"h-px w-5 bg-border/80 sm:w-8","aria-hidden":"true"}):null]},i)})})})}function Y(l){const{secondary:r,tertiary:d,primary:i}=l;return t.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:[r,d,i]})}function je(l){const{control:r,scope:d,detail:i}=l;return t.jsxs("div",{className:"flex items-start gap-3 rounded-xl border border-border/40 bg-muted/20 p-3",children:[t.jsx(e.CircleCheck,{className:"mt-0.5 h-4 w-4 text-emerald-600"}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"text-sm font-medium",children:r.label}),t.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.getFriendlyTypeOption(r.type).label," ·"," ",e.getControlOptionPreview(r)," ·"," ",e.getPlacementLabel(d,r.placement)]}),i?t.jsx("div",{className:"text-xs text-muted-foreground",children:i}):null]})]})}function G(l){const{title:r,children:d,className:i}=l;return t.jsxs("div",{className:e.cn("space-y-1 rounded-xl border border-border/40 bg-muted/20 p-3",i),children:[t.jsx("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:r}),d]})}function Se(l){const{createdReference:r,description:d}=l;return t.jsxs(G,{title:"SQL cards",className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-border/30 bg-muted/40 px-3 py-2",children:[t.jsx("code",{className:"min-w-0 truncate text-xs",children:r}),t.jsx(e.CopyButton,{text:r,ariaLabel:"Copy SQL control reference"})]}),t.jsx("p",{className:"text-[11px] text-muted-foreground",children:d})]})}function le(l){const{control:r,defaultValue:d,availableFieldChoices:i,availableMetricChoices:m,onControlChange:f,onLabelChange:p,onDefaultValueChange:x,onBack:n,onNext:v,nextDisabled:b}=l;return t.jsxs("div",{className:"space-y-3",children:[t.jsx(oe,{control:r,onChange:p}),t.jsx(e.ControlDefinitionOptionsEditor,{control:r,availableFieldChoices:i,availableMetricChoices:m,onChange:f}),t.jsx(e.ControlDefaultValueEditor,{control:r,value:d,onChange:x,allowCardDefault:!0,hint:"This is the value viewers will see first."}),t.jsx(Y,{secondary:t.jsx(e.Button,{type:"button",variant:"outline",onClick:n,children:"Back"}),primary:t.jsx(e.Button,{type:"button",onClick:v,disabled:b,children:"Next"})})]})}function re(l){const{control:r,scope:d,createdReference:i,explorerContent:m,sqlDescription:f,summaryDetail:p,onBack:x,onCancel:n,onDone:v}=l;return t.jsxs("div",{className:"space-y-4",children:[t.jsx(je,{control:r,scope:d,detail:p}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-sm font-medium",children:"How cards use this control"}),m,t.jsx(Se,{createdReference:i,description:f})]}),t.jsx(Y,{secondary:t.jsx(e.Button,{type:"button",variant:"outline",onClick:x,children:"Back"}),tertiary:t.jsx(e.Button,{type:"button",variant:"outline",onClick:n,children:"Cancel"}),primary:t.jsx(e.Button,{type:"button",onClick:v,children:"Done"})})]})}function Ne(l){const r=e.createBlankControl(l.scope,l.existingControls,l.reservedIds),d=l.type===r.type?{...r,label:e.DEFAULT_LABEL_BY_TYPE[l.type]}:{...e.applyControlTypeChange({controls:[{...r,label:e.DEFAULT_LABEL_BY_TYPE[l.type]}],controlId:r.id,nextType:l.type}).controls[0],label:e.DEFAULT_LABEL_BY_TYPE[l.type]};return{step:2,control:d,defaultValue:e.getDefaultValueForType(d,void 0)}}function ke({scope:l,controls:r,reservedControlIds:d,defaultValues:i,onChange:m,emptyMessage:f,initialCreateFlow:p=!1,usageByControlId:x,availableFieldChoices:n,availableMetricChoices:v,structuralParticipants:b,structuralParticipantIdsByControlId:h,card:y,onCreateFlowActiveChange:j,onCreateFlowComplete:L}){const E=C.useMemo(()=>new Set(d||[]),[d]),K=e.getPlacementOptionsForScope(l),P=e.getDefaultPlacement(l),[z,M]=C.useState(null),[H,q]=C.useState(null),[a,k]=C.useState(()=>p?{step:1,control:e.createBlankControl(l,r,Array.from(E))}:null),O=C.useRef(p),T=C.useMemo(()=>e.getFriendlyControlTypeOptions({scope:l,card:y}),[y,l]),D=C.useCallback(s=>l==="dashboard"&&(s==="field_selector"||s==="metric_selector"),[l]),V=C.useMemo(()=>a?e.getEligibleParticipantsForStructuralControl(b||[],a.control.type):[],[a,b]),F=C.useMemo(()=>{if(!a)return{fields:n||[],metrics:v||[]};if(!D(a.control.type))return{fields:n||[],metrics:v||[]};const s=a.selectedCardIds||[],u=e.getCompatibleStructuralChoiceCatalog({controlType:a.control.type,participants:b||[],selectedCardIds:s});return{fields:a.control.type==="field_selector"?u.choices.map(c=>({option:c,target:u.fieldTargetMap[c.value]})):[],metrics:a.control.type==="metric_selector"?u.choices.map(c=>({option:c,target:u.metricTargetMap[c.value]})):[]}},[n,v,a,D,b]);C.useEffect(()=>{j==null||j(!!a)},[a,j]),C.useEffect(()=>{const s=p&&!O.current;O.current=p,s&&(k({step:1,control:e.createBlankControl(l,r,Array.from(E))}),q(null),M(null))},[r,p,E,l]);const U=s=>{if(!D(s.type))return{fields:n||[],metrics:v||[]};const u=(h==null?void 0:h[s.id])||[];if(u.length===0)return{fields:n||[],metrics:v||[]};const c=e.getCompatibleStructuralChoiceCatalog({controlType:s.type,participants:b||[],selectedCardIds:u});return{fields:s.type==="field_selector"?c.choices.map(g=>({option:g,target:c.fieldTargetMap[g.value]})):[],metrics:s.type==="metric_selector"?c.choices.map(g=>({option:g,target:c.metricTargetMap[g.value]})):[]}},_=s=>{if(!D(s.control.type))return{nextControl:s.control,cardBindingsById:void 0};const u=(h==null?void 0:h[s.control.id])||[],c=e.getCompatibleStructuralChoiceCatalog({controlType:s.control.type,participants:b||[],selectedCardIds:s.nextSelectedCardIds}),g=e.reconcileStructuralControlChoices({control:s.control,choices:c.choices}),S=Object.fromEntries(u.filter(o=>!s.nextSelectedCardIds.includes(o)).map(o=>[o,void 0]));return s.nextSelectedCardIds.length>0&&g.source.kind==="manual"&&g.source.options.length>0&&Object.assign(S,e.buildStructuralControlBindingsForParticipants({control:g,participants:b||[],selectedCardIds:s.nextSelectedCardIds})),{nextControl:g,cardBindingsById:S}},I=C.useCallback((s,u=i,c={type:"update"})=>{m(s,u,c)},[i,m]),B=(s,u)=>{const c=r.find(w=>w.id===s);let g=r.map(w=>w.id!==s?w:u(w));const S=g.find(w=>w.id===s);let o,N;if(S&&l==="dashboard"&&(S.type==="field_selector"||S.type==="metric_selector")){const w=(h==null?void 0:h[S.id])||[],A=_({control:S,nextSelectedCardIds:w});g=g.map(ae=>ae.id===s?A.nextControl:ae),o=A.cardBindingsById,N=[S.id]}else if(c&&l==="dashboard"&&(c.type==="field_selector"||c.type==="metric_selector")){const w=(h==null?void 0:h[c.id])||[];o=Object.fromEntries(w.map(A=>[A,void 0])),N=[c.id]}I(g,i,{type:"update",cardBindingsById:o,affectedBindingControlIds:N})},ie=(s,u)=>{const c=u.trim();if(c.length===0||c===s||E.has(c)||r.some(o=>o.id===c&&o.id!==s))return;const g=r.map(o=>o.id===s?{...o,id:c}:o);if(!i){I(g,void 0,{type:"rename",oldId:s,newId:c});return}const S={...i};Object.prototype.hasOwnProperty.call(S,s)&&(S[c]=S[s],delete S[s]),I(g,S,{type:"rename",oldId:s,newId:c})},ce=s=>{const u=r.filter(g=>g.id!==s);if(!i){I(u,void 0,{type:"remove",controlId:s});return}const c={...i};delete c[s],I(u,c,{type:"remove",controlId:s})},ue=C.useCallback(()=>{k({step:1,control:e.createBlankControl(l,r,Array.from(E))}),q(null),M(null)},[r,E,l]),Q=s=>{k(u=>u&&{...u,control:s(u.control)})},Z=s=>{k(u=>u&&{...u,defaultValue:s})},X=(()=>{if(!a)return!1;if(a.step===2&&D(a.control.type))return(a.selectedCardIds||[]).length>0;if(a.step!==2&&a.step!==3||!a.control.label.trim())return!1;const u=e.ensureManualSource(a.control);return u.source.kind==="manual"&&(e.needsManualOptions(u)&&u.source.options.length===0||u.source.options.some(g=>g.label.trim().length===0||g.value.trim().length===0))?!1:e.hasConcreteDefaultValue(e.getDefaultValueForType(u,a.defaultValue))})(),ee=()=>{var o;if(!a)return;const s=e.ensureManualSource(a.control),u=e.deriveUniqueControlId({label:s.label,fallbackId:s.id,existingControls:r,reservedIds:Array.from(E)}),c={...s,id:u},g=l==="dashboard"&&(c.type==="field_selector"||c.type==="metric_selector")&&((o=a.selectedCardIds)!=null&&o.length)?e.buildStructuralControlBindingsForParticipants({control:c,participants:b||[],selectedCardIds:a.selectedCardIds}):void 0,S=e.getDefaultValueForType(c,a.defaultValue);k({step:l==="dashboard"&&(c.type==="field_selector"||c.type==="metric_selector")?4:3,control:c,defaultValue:S,createdControlId:u,selectedCardIds:a.selectedCardIds,cardBindingsById:g})},$=C.useCallback(()=>{k(null)},[]),te=C.useCallback(()=>{if(!(a!=null&&a.createdControlId)){k(null);return}const s=a.control,u=a.createdControlId,c=e.getDefaultValueForType(s,a.defaultValue);i?I([...r,s],{...i,[u]:c},{type:"add",cardBindingsById:a.cardBindingsById}):I([...r,{...s,defaultValue:c}],void 0,{type:"add",cardBindingsById:a.cardBindingsById}),q(u),k(null),L==null||L()},[r,a,i,I,L]),me=a?D(a.control.type)?["Choose type","Select cards","Configure","Finish"]:["Choose type","Configure","Finish"]:[],se=a!=null&&a.createdControlId?`[[param.${a.createdControlId}]]`:a?`[[param.${e.slugifyControlValue(a.control.label)||a.control.id}]]`:"";return t.jsxs("div",{className:"space-y-4",children:[a?t.jsxs("div",{className:"space-y-4 pb-1",children:[t.jsx(ve,{currentStep:a.step,labels:me}),a.step===1&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"What kind of input should viewers see?"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose the viewer experience first. You can fine-tune the details next."}),l==="card"&&(y==null?void 0:y.sql)==null?t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Explorer cards support displayed metric, group by field, aggregation, and time grain controls here."}):null]}),t.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:T.map(s=>t.jsxs("button",{type:"button",className:"rounded-xl border border-border/50 bg-muted/20 p-3 text-left transition-colors hover:border-border/70 hover:bg-muted/35",onClick:()=>k(Ne({scope:l,existingControls:r,reservedIds:Array.from(E),type:s.value})),children:[t.jsx("div",{className:"text-sm font-medium",children:s.label}),t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:s.description})]},s.value))}),t.jsx(Y,{secondary:t.jsx(e.Button,{type:"button",variant:"outline",onClick:$,children:"Back to controls"})})]}),a.step===2&&D(a.control.type)&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx(oe,{control:a.control,onChange:s=>Q(u=>({...u,label:s}))}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose which cards should respond to this shared control."})]}),V.length===0?t.jsx("div",{className:"rounded-xl bg-muted/20 p-3 text-xs text-muted-foreground",children:"No eligible cards are available yet. Add compatible metrics or group-by fields to cards first."}):t.jsx("div",{className:"space-y-2 rounded-xl bg-muted/20 p-3",children:V.map(s=>{const u=(a.selectedCardIds||[]).includes(s.cardId);return t.jsxs("label",{className:"flex items-start gap-2 text-sm",children:[t.jsx(e.Checkbox,{checked:u,onCheckedChange:c=>k(g=>g&&{...g,selectedCardIds:c===!0?[...g.selectedCardIds||[],s.cardId]:(g.selectedCardIds||[]).filter(S=>S!==s.cardId)})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"font-medium",children:s.title}),t.jsx("div",{className:"text-xs text-muted-foreground",children:a.control.type==="field_selector"?`${s.fieldChoices.length} compatible group-by fields`:`${s.metricChoices.length} compatible metrics`})]})]},s.cardId)})}),t.jsx(Y,{secondary:t.jsx(e.Button,{type:"button",variant:"outline",onClick:()=>k(s=>s&&{...s,step:1,selectedCardIds:[]}),children:"Back"}),primary:t.jsx(e.Button,{type:"button",onClick:()=>k(s=>s&&{...s,step:3}),disabled:!X,children:"Next"})})]}),a.step===2&&!D(a.control.type)&&t.jsx(le,{control:a.control,defaultValue:a.defaultValue,availableFieldChoices:F.fields,availableMetricChoices:F.metrics,onControlChange:s=>Q(()=>s),onLabelChange:s=>Q(u=>({...u,label:s})),onDefaultValueChange:Z,onBack:()=>k(s=>s&&{...s,step:1}),onNext:ee,nextDisabled:!X}),a.step===3&&D(a.control.type)&&t.jsx(le,{control:a.control,defaultValue:a.defaultValue,availableFieldChoices:F.fields,availableMetricChoices:F.metrics,onControlChange:s=>Q(()=>s),onLabelChange:s=>Q(u=>({...u,label:s})),onDefaultValueChange:Z,onBack:()=>k(s=>s&&{...s,step:2}),onNext:ee,nextDisabled:!X}),a.step===3&&!D(a.control.type)&&t.jsx(re,{control:a.control,scope:l,createdReference:se,explorerContent:t.jsx(G,{title:"Explorer cards",children:t.jsxs("p",{className:"text-sm",children:["Open the card and use"," ",t.jsx("span",{className:"font-medium",children:"Settings → Controls"})," ","to choose what this control changes."]})}),sqlDescription:"Reference this control directly in the SQL editor.",onBack:()=>k(s=>s&&{...s,step:2}),onCancel:$,onDone:te}),a.step===4&&D(a.control.type)&&t.jsx(re,{control:a.control,scope:l,createdReference:se,summaryDetail:t.jsxs(t.Fragment,{children:["Used by ",(a.selectedCardIds||[]).length," ","selected card",(a.selectedCardIds||[]).length===1?"":"s"]}),explorerContent:t.jsx(G,{title:"Explorer cards",children:t.jsx("p",{className:"text-sm",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:()=>k(s=>s&&{...s,step:3}),onCancel:$,onDone:te})]}):null,!a&&r.length===0?t.jsx("div",{className:"rounded-md border border-dashed p-3 text-sm text-muted-foreground",children:f}):null,!a&&r.map(s=>{const u=U(s),c=x==null?void 0:x[s.id],g=i&&Object.prototype.hasOwnProperty.call(i,s.id)?i[s.id]:s.defaultValue,S=H===s.id;return t.jsxs("div",{className:"rounded-md border",children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-3",children:[t.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-start gap-2 text-left",onClick:()=>q(o=>o===s.id?null:s.id),children:[S?t.jsx(e.ChevronDown,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}):t.jsx(e.ChevronRight,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"truncate text-sm font-medium",children:s.label||"Untitled control"}),t.jsx(e.Badge,{variant:"outline",className:"text-[11px]",children:e.getFriendlyTypeOption(s.type).label}),t.jsx(e.Badge,{variant:"secondary",className:"text-[11px]",children:e.getPlacementLabel(l,s.placement)})]}),t.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[e.getControlOptionPreview(s),c!=null&&c.status?` · ${c.status}`:""]})]})]}),t.jsx(e.Button,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8 shrink-0",onClick:()=>ce(s.id),"aria-label":`Remove ${s.label}`,children:t.jsx(e.Trash2,{className:"h-4 w-4"})})]}),S&&t.jsxs("div",{className:"space-y-4 border-t px-3 py-4",children:[c!=null&&c.helper?t.jsx("div",{className:"rounded-md bg-muted/30 px-3 py-2 text-xs text-muted-foreground",children:c.helper}):null,t.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(e.Label,{className:"text-xs",children:"Label"}),t.jsx(e.Input,{value:s.label,placeholder:"Control label",onChange:o=>B(s.id,N=>({...N,label:o.target.value}))})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(e.Label,{className:"text-xs",children:"Type"}),t.jsxs(e.Select,{value:s.type,onValueChange:o=>{const N=e.applyControlTypeChange({controls:r,controlId:s.id,nextType:o,defaultValues:i});I(N.controls,N.defaultValues)},children:[t.jsx(e.SelectTrigger,{children:t.jsx(e.SelectValue,{})}),t.jsx(e.SelectContent,{children:e.getFriendlyControlTypeOptions({scope:l,card:y,includeType:s.type}).map(o=>t.jsx(e.SelectItem,{value:o.value,children:o.label},o.value))})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(e.Label,{className:"text-xs",children:"Show in"}),t.jsxs(e.Select,{value:s.placement||P,onValueChange:o=>B(s.id,N=>({...N,placement:o})),children:[t.jsx(e.SelectTrigger,{children:t.jsx(e.SelectValue,{})}),t.jsx(e.SelectContent,{children:K.map(o=>t.jsx(e.SelectItem,{value:o.value,children:o.label},o.value))})]})]})]}),D(s.type)?t.jsx(e.StructuralParticipantSelector,{type:s.type,participants:e.getEligibleParticipantsForStructuralControl(b||[],s.type).map(o=>({cardId:o.cardId,title:o.title,choiceCount:s.type==="field_selector"?o.fieldChoices.length:o.metricChoices.length})),selectedCardIds:(h==null?void 0:h[s.id])||[],onChange:o=>{const N=_({control:s,nextSelectedCardIds:o}),w=r.map(A=>A.id===s.id?N.nextControl:A);I(w,i,{type:"update",cardBindingsById:N.cardBindingsById})}}):null,t.jsx(e.ControlDefinitionOptionsEditor,{control:s,availableFieldChoices:u.fields,availableMetricChoices:u.metrics,onChange:o=>B(s.id,()=>o)}),s.initialValueStrategy==="saved_default"&&t.jsx(e.ControlDefaultValueEditor,{control:s,value:g,allowNoDefault:!0,allowCardDefault:!0,onChange:o=>{if(i){const N={...i};o===void 0?delete N[s.id]:N[s.id]=o,I(r,N);return}B(s.id,N=>({...N,defaultValue:o}))}}),t.jsxs(e.Collapsible,{open:z===s.id,onOpenChange:o=>M(o?s.id:null),children:[t.jsx(e.CollapsibleTrigger,{asChild:!0,children:t.jsxs(e.Button,{type:"button",variant:"ghost",className:"h-auto px-0 text-xs text-muted-foreground hover:bg-transparent",children:[z===s.id?t.jsx(e.ChevronDown,{className:"mr-1 h-4 w-4"}):t.jsx(e.ChevronRight,{className:"mr-1 h-4 w-4"}),"Advanced"]})}),t.jsxs(e.CollapsibleContent,{className:"space-y-3 pt-2",children:[t.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(e.Label,{className:"text-xs",children:"Control ID"}),t.jsx(e.ControlIdInput,{controlId:s.id,onCommit:o=>ie(s.id,o)},s.id)]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(e.Label,{className:"text-xs",children:"Initial value"}),t.jsxs(e.Select,{value:s.initialValueStrategy,onValueChange:o=>B(s.id,N=>({...N,initialValueStrategy:o})),children:[t.jsx(e.SelectTrigger,{children:t.jsx(e.SelectValue,{})}),t.jsx(e.SelectContent,{children:e.INITIAL_VALUE_STRATEGY_OPTIONS.map(o=>t.jsx(e.SelectItem,{value:o.value,children:o.label},o.value))})]}),t.jsx("p",{className:"text-[11px] text-muted-foreground",children:e.getInitialValueStrategyHint(s.initialValueStrategy)})]})]}),t.jsx(e.ControlVisibilitySettings,{control:s,onChange:o=>B(s.id,()=>o)})]})]})]})]},s.id)}),!a&&t.jsxs(e.Button,{type:"button",variant:"outline",size:"sm",onClick:ue,children:[t.jsx(e.Plus,{className:"mr-2 h-4 w-4"}),"Add control"]})]})}function Ee(l){const{open:r,onOpenChange:d,initialCreateFlowActive:i=!1}=l,m=r!==void 0,[f,p]=C.useState(!1),[x,n]=C.useState(i),v=m?r:f,b=C.useCallback(j=>{!j&&x||(m||p(j),j||n(!1),d==null||d(j))},[m,x,d]),h=C.useCallback(()=>{m||p(!1),n(!1),d==null||d(!1)},[m,d]);C.useEffect(()=>{v||n(!1)},[v]);const y=C.useCallback(j=>{x&&j.preventDefault()},[x]);return{forceClose:h,handleOpenChange:b,isCreateFlowActive:x,preventPassiveDismissDuringCreate:y,resolvedOpen:v,setIsCreateFlowActive:n}}exports.CircleX=pe;exports.ControlDefinitionListEditor=ke;exports.EditorAcceptButton=fe;exports.EditorCancelButton=ge;exports.EditorClearButton=Ce;exports.Library=ne;exports.Link2=de;exports.Save=W;exports.VisualBadge=xe;exports.VisualSaveAndApplyButton=ye;exports.VisualSaveButton=be;exports.useCreateFlowOverlayState=Ee;exports.useEffectiveEditorCardType=J;
@@ -1 +0,0 @@
1
- "use strict";const o=require("./index-C2i6CRUk.js"),b=require("react");function z(e){const n=e.toUpperCase().indexOf("WHERE"),t=e.toUpperCase().indexOf("GROUP BY"),r=e.toUpperCase().indexOf("LIMIT"),s=e.toUpperCase().indexOf("ORDER BY");let c=e.length;if(s!==-1&&(c=s),r!==-1&&r<c&&(c=r),n!==-1){const d=e.substring(0,n),a=e.substring(n);return`${d} {{ filters | where }} AND ${a.substring(6)}`}else if(t!==-1){const d=e.substring(0,t),a=e.substring(t);return`${d} {{ filters | where }} ${a}`}else{const d=e.substring(0,c),a=e.substring(c);return console.log("beforeClause",d),console.log("afterClause",a),a?`${d} {{ filters | where }} ${a}`:`${d.replace(/;$/,"")} {{ filters | where }}`}}function j(e){const[n,t]=b.useState(null),[r,s]=b.useState(null),c=o.useEnsureReactGlobals();return b.useEffect(()=>{if(!e||e.trim()===""){t(null),s(null);return}if(!c)return;(async()=>{try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error(`Invalid URL format: ${e}`);try{new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}const l=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(l,{method:"HEAD"})).ok)throw new Error(`Module not found at ${l}`)}catch{}const h=await import(l);if(typeof h.useChartStore!="function")throw new Error("useChartStore is not a function");t(()=>h.useChartStore),s(null)}catch(a){const l=a instanceof Error?a.message:"Unknown error";console.error("Failed to load remote chart store:",l),s(l),t(null)}})()},[e,c]),n}function G(e,n){if(e.length===0)return"";const t=e.find(r=>{var s,c;return((s=r.customCardPreferences)==null?void 0:s.visualType)==="multiple"||!!((c=r.customCardPreferences)!=null&&c.dataInputCardIds)});if(t)return t.id;if(n){const r=e.find(s=>s.id===n);if(r){const s=r.tabTitle;if(s=="All__Header")return e[0].id;if(s&&s.endsWith("__Header")){const d=s.split("__")[0],a=e.find(l=>l.tabTitle===d);return a?a.id:e[0].id}return n}}return e[0].id}const Y=e=>{if(!e||!("detailTableBackup"in e))return e;const{detailTableBackup:n,...t}=e;return t};async function L(e,n,t,r){if(!n||!t)throw new Error("Missing auth token or visual ID");const s=["resource-by-id","visual",t],c=r.getQueryData(s);if(c)return console.log("Using cached visual data for:",t),{data:c,fromCache:!0};console.log("Fetching visual data from network for:",t);const d=o.ue.loading("Loading visual...",{position:"top-center"});try{const a=await fetch(`${e}/management/v1/visuals/${t}`,{headers:{Authorization:`Bearer ${n}`}});if(!a.ok)throw new Error("Failed to load visual");const l=await a.json();return r.setQueryData(s,l),o.ue.dismiss(d),{data:l,fromCache:!1}}catch(a){throw o.ue.dismiss(d),a}}function _(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function J(e,n){var c,d;const t=(e==null?void 0:e.frameObject)??((c=e==null?void 0:e.visual)==null?void 0:c.frameObject);if(!t)return!1;const r=_(t);if(!(r!=null&&r.cards)||r.cards.length===0)return!1;const s=(d=r.cards)==null?void 0:d.find(a=>a.id===r.activeCardId);return s?(o.setupEditorWithCard({...n,frame:r,card:s,visualId:(e==null?void 0:e.id)||r.visualId}),!0):!1}function K(){var g;const{setCardSql:e}=o.useEditorActions(),n=o.useEditorStore(i=>i.frame),t=o.useEditorStore(i=>i.card),r=o.useEditorStore(i=>i.isDevMode),s=j(((g=t.customCardPreferences)==null?void 0:g.url)||""),c=o.useEditorStore(i=>i.selectedSchemaName),d=o.useEditorStore(i=>i.selectedDatamodelId),a=o.useEditorStore(i=>i.selectedDatabaseName),l=o.useEditorStore(i=>i.selectedTableName),h=o.useEditorStore(i=>i.selectedConnectionId),m=o.useEditorStore(i=>i.isShowingVisual),p=t.sql;return{getUpdatedFrame:b.useCallback(()=>{var w;let i=p;p&&!p.includes("{{")&&(i=z(p),e(i));const C=(w=s==null?void 0:s.getState())==null?void 0:w.settings,v={...t,dataSource:t.dataSource||{mode:"directSource"},lastSelectedSchema:c,lastSelectedDatamodelId:d,lastSelectedDatabase:a,lastSelectedTable:l,connectionId:h,sql:r?i:void 0,python:r?t.python:void 0,config:r?void 0:Y(t.config),customCfg:m?t.customCfg:null,preferences:t.preferences,...C&&{customCardPreferences:{...t.customCardPreferences,settings:C}}},E=n.cards.map(I=>I.id===t.id?v:I);return{...n,cards:E,activeCardId:G(E,n.activeCardId)}},[t,n,r,m,c,d,a,l,h,e,s,p])}}function X(){const{authToken:e,tokenProps:n}=o.useSemaphorContext(),t=o.useQueryClient(),r=o.useSelectedVisual(),{selectVisual:s}=o.useManagementActions(),{setFrame:c,setCard:d,setIsDevMode:a,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:p,setSelectedConnectionId:D,setSelectedDatabaseName:g,setSelectedSchemaName:i,setSelectedTableName:C,setSelectedDatamodelId:v,setFilterValues:E,setInlineFilterValuesMap:w,setApplyFilters:I}=o.useEditorActions(),{setIsDashboardEditing:V,setIsVisualEditing:$,setSelectedFrameId:M,clearSelectedFrameId:A,addFrame:R,setIsDashboardPanelOpen:N}=o.useDashboardActions(),y=o.useDashboardStore(u=>u.selectedSheetId),O=o.useDashboardStore(u=>u.selectedFrameId),T=o.useDashboardStore(u=>u.dashboard),x=o.useDashboardStore(u=>u.filterValues),B=o.useDashboardStore(u=>u.inlineFilterValuesMap),F=o.useVisualById((r==null?void 0:r.id)||"",{enabled:!!(r!=null&&r.id)&&!!(e!=null&&e.accessToken)}),H=b.useCallback(async u=>{try{s(u),A();const{data:S,fromCache:f}=await L(n.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t);if(!J(S,{setFrame:c,setCard:d,setIsDevMode:a,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:p,setSelectedConnectionId:D,setSelectedDatabaseName:g,setSelectedSchemaName:i,setSelectedTableName:C,setSelectedDatamodelId:v,setFilterValues:E,setInlineFilterValuesMap:w,setApplyFilters:I,setIsDashboardEditing:V,setIsVisualEditing:$,dashboard:T,selectedSheetId:y,selectedFrameId:O,filterValues:x,inlineFilterValuesMap:B}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:f}}catch(S){return console.error("Error editing visual:",S),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,n.apiServiceUrl,t,s,c,d,V,$,a,l,h,m,p,D,g,i,C,v,E,w,I,A,T,y,O,x,B]),Q=b.useCallback(async u=>{var S;try{if(s(u),!y)return{success:!1,error:"No sheet selected. Please select a sheet first."};const{data:f,fromCache:P}=await L(n.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t),W=(f==null?void 0:f.frameObject)??((S=f==null?void 0:f.visual)==null?void 0:S.frameObject);if(!W)return{success:!1,error:"Visual has no frame data"};const U=_(W);if(!(U!=null&&U.cards)||U.cards.length===0)return{success:!1,error:"Visual frame is malformed"};const k={...o.cloneLinkedFrameWithSourceMapping(U),visualId:u.id};return R(y,k,"end"),V(!0),M(k.id),N(!1),{success:!0,fromCache:P}}catch(f){return console.error("Error adding visual:",f),{success:!1,error:"Failed to add visual to dashboard"}}},[e==null?void 0:e.accessToken,n.apiServiceUrl,t,s,y,R,V,M,N]);return{visual:F.data,isLoading:F.isLoading,isError:F.isError,error:F.error,handleEditLibraryVisual:H,handleAddLibraryVisual:Q,getUpdatedFrame:K().getUpdatedFrame,refetch:F.refetch}}exports.useRemoteChartStore=j;exports.useVisualUtils=X;