react-semaphor 0.1.209 → 0.1.211

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 (42) hide show
  1. package/dist/chunks/{dashboard-controls-BNTI4r0_.js → dashboard-controls-7KpXzAWL.js} +662 -607
  2. package/dist/chunks/dashboard-controls-CnDq9Uh_.js +42 -0
  3. package/dist/chunks/{dashboard-json-BjOqpGbW.js → dashboard-json-dqey5VK0.js} +1 -1
  4. package/dist/chunks/{dashboard-json-kIoBtmBF.js → dashboard-json-stWvjp2O.js} +1 -1
  5. package/dist/chunks/{dashboard-summary-settings-dialog-CO1SwHHD.js → dashboard-summary-settings-dialog-DPEe6XBC.js} +1 -1
  6. package/dist/chunks/{dashboard-summary-settings-dialog-BoX18wiA.js → dashboard-summary-settings-dialog-DuxhidK1.js} +1 -1
  7. package/dist/chunks/{edit-dashboard-visual-DG4VLoJF.js → edit-dashboard-visual-CQAk_UsI.js} +3416 -3531
  8. package/dist/chunks/edit-dashboard-visual-D_XPr8f8.js +164 -0
  9. package/dist/chunks/editor-action-buttons-CH7W6KdH.js +21 -0
  10. package/dist/chunks/editor-action-buttons-D34_GSZu.js +404 -0
  11. package/dist/chunks/{index-D0TdW88i.js → index-BDS2sWhv.js} +26669 -26443
  12. package/dist/chunks/index-BfiIPyeS.js +1109 -0
  13. package/dist/chunks/normalize-dashboard-for-dirty-check-D9x96J2F.js +1 -0
  14. package/dist/chunks/normalize-dashboard-for-dirty-check-XKgH3GFX.js +119 -0
  15. package/dist/chunks/notification-bell-Cu3qDd9V.js +837 -0
  16. package/dist/chunks/notification-bell-hijGST9g.js +6 -0
  17. package/dist/chunks/{resource-management-panel-DS_WEv1x.js → resource-management-panel-BvHqslqC.js} +346 -335
  18. package/dist/chunks/resource-management-panel-gK3a6OEj.js +6 -0
  19. package/dist/chunks/{use-role-aware-display-preferences-D8j5_cnK.js → use-role-aware-display-preferences-BlR29aKQ.js} +1 -1
  20. package/dist/chunks/{use-role-aware-display-preferences-DfihB5pN.js → use-role-aware-display-preferences-a5FH9Y0k.js} +1 -1
  21. package/dist/chunks/{use-visual-utils-CzcVz3zB.js → use-visual-utils-B11AA2fd.js} +1 -1
  22. package/dist/chunks/{use-visual-utils-BfLXO_vi.js → use-visual-utils-ptPsQ3nC.js} +23 -23
  23. package/dist/dashboard/index.cjs +1 -1
  24. package/dist/dashboard/index.js +1 -1
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.js +253 -214
  27. package/dist/shared/index.cjs +1 -0
  28. package/dist/shared/index.js +6 -0
  29. package/dist/style.css +1 -1
  30. package/dist/surfboard/index.cjs +1 -1
  31. package/dist/surfboard/index.js +2 -2
  32. package/dist/types/main.d.ts +88 -1
  33. package/dist/types/shared.d.ts +1762 -0
  34. package/package.json +6 -1
  35. package/dist/chunks/dashboard-controls-Dcpx9_an.js +0 -42
  36. package/dist/chunks/edit-dashboard-visual-B9HuGExj.js +0 -179
  37. package/dist/chunks/editor-action-buttons-CDTIx_Jc.js +0 -11
  38. package/dist/chunks/editor-action-buttons-CszdZ4Fw.js +0 -345
  39. package/dist/chunks/index-DSA80lEg.js +0 -1104
  40. package/dist/chunks/notification-bell-D2V1-ARa.js +0 -11
  41. package/dist/chunks/notification-bell-DFiRaeJQ.js +0 -862
  42. package/dist/chunks/resource-management-panel-BhiWNPcw.js +0 -6
@@ -0,0 +1,21 @@
1
+ "use strict";const e=require("./index-BfiIPyeS.js"),a=require("react/jsx-runtime"),k=require("./use-visual-utils-B11AA2fd.js"),f=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 P=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 T=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 F=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 g=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 E(){var t,y;const u=e.useEditorStore(m=>m.card),d=e.useEditorStore(m=>m.frame),o=f.useMemo(()=>e.findCustomVisualConfigCard(d,u),[d,u]),{manifest:c}=e.useCustomVisual(((t=o==null?void 0:o.customCardPreferences)==null?void 0:t.url)||""),r=f.useMemo(()=>{var m;return(m=c==null?void 0:c.visuals)==null?void 0:m.find(p=>{var l;return p.name===((l=o==null?void 0:o.customCardPreferences)==null?void 0:l.componentName)})},[c,(y=o==null?void 0:o.customCardPreferences)==null?void 0:y.componentName]),i=e.resolveMultiInputType(o,r),n=f.useMemo(()=>e.getCustomVisualInputCards({frame:d,configCard:o,isMultiInputVisual:i==="multiple"}),[d,o,i]),s=f.useMemo(()=>{const m=n.findIndex(p=>(p==null?void 0:p.id)===u.id);return m<0?-1:e.getSlotIndexForCard(u,m)},[n,u]);return f.useMemo(()=>!o||i!=="multiple"||s<0?u.type:e.getEffectiveCardTypeForSlot(u,s,r==null?void 0:r.slots)??u.type,[o,i,s,u,r==null?void 0:r.slots])}function w({type:u,isLinked:d,className:o,showLabel:c=!1}){const r=e.useDashboardStore(b=>b.selectedFrameId),i=e.useManagementStore(b=>b.selectedVisual),n=e.useEditorStore(b=>b.frame);let s;if(u)s=u;else if(d!==void 0)s=d?"linked":"library";else if(!!!(n!=null&&n.visualId||i!=null&&i.id)&&r)s="local";else if(i&&!r)s="library";else if(n!=null&&n.visualId&&r)s="linked";else if(i!=null&&i.id&&r)s="library";else return null;if(s==="local")return null;const t={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={linked:"Linked to library: Changes made here update the library visual and all linked instances.",library:"Library visual: Share and reuse this visual across multiple dashboards."},m={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"},p={linked:"fill-purple-50 dark:fill-purple-950",library:"fill-blue-50 dark:fill-blue-950"},l={linked:a.jsx(F,{className:"h-3.5 w-3.5"}),library:a.jsx(T,{className:"h-3.5 w-3.5"})},h={linked:"Linked",library:"Library"};return a.jsx(e.TooltipProvider,{children:a.jsxs(e.Tooltip,{delayDuration:300,children:[a.jsx(e.TooltipTrigger,{asChild:!0,children:a.jsxs(e.Badge,{variant:"outline",className:e.cn("cursor-help select-none transition-all",t[s],o),children:[l[s],c&&a.jsx("span",{className:"ml-1 text-xs font-medium leading-none",children:h[s]})]})}),a.jsxs(e.TooltipContent,{side:"bottom",className:e.cn("max-w-xs",m[s]),children:[a.jsx(e.TooltipArrow,{className:p[s]}),a.jsx("p",{children:y[s]})]})]})})}function U(u,d){return{...u,sql:"",python:"",config:void 0,customCfg:"",preferences:{},interactionConfig:void 0,linkedInteractionTargetOverrides:void 0,customCardPreferences:d?u.customCardPreferences:void 0,type:d?u.type:"bar"}}function K({className:u,variant:d="outline"}){var s;const{setCardSql:o}=e.useEditorActions();e.useEditorStore(t=>t.frame);const c=e.useEditorStore(t=>t.card);k.useRemoteChartStore(((s=c.customCardPreferences)==null?void 0:s.url)||""),e.useEditorStore(t=>t.selectedSchemaName),e.useEditorStore(t=>t.selectedDatamodelId),e.useEditorStore(t=>t.selectedDatabaseName),e.useEditorStore(t=>t.selectedTableName),e.useEditorStore(t=>t.selectedConnectionId),e.useEditorStore(t=>t.isShowingVisual),c.sql;const r=e.useEditorStore(t=>t.onSave),{getUpdatedFrame:i}=k.useVisualUtils();function n(){const t=i();r==null||r(t)}return a.jsxs(e.Button,{onClick:n,className:e.cn("h-8",u),size:"sm",variant:d,children:[a.jsx(e.Check,{className:"mr-2 size-4 font-bold"}),"Accept"]})}function O({className:u,variant:d="default"}){const o=e.useQueryClient(),[c,r]=f.useState(!1),i=e.useDashboardStore(l=>l.actions.setIsDashboardPanelOpen),{setIsVisualEditing:n}=e.useDashboardActions(),{getUpdatedFrame:s}=k.useVisualUtils(),t=e.useSelectedVisual(),y=e.useEditorStore(l=>l.frame),m=e.useUpdateVisualMutation(),p=()=>{const l=s(),h=(y==null?void 0:y.visualId)||(t==null?void 0:t.id);if(!h){e.ue.error("No visual to save");return}r(!0),m.mutate({visualId:h,data:{frameObject:l}},{onSuccess:()=>{r(!1),i(!0),e.ue.success("Visual updated successfully"),o.invalidateQueries({queryKey:["resource-by-id","visual",h],exact:!0})},onError:()=>{r(!1),e.ue.error("Failed to update visual")}})};return a.jsxs(e.Button,{onClick:p,className:e.cn("h-8",u),size:"sm",variant:d,children:[c&&a.jsxs(a.Fragment,{children:[a.jsx(e.LoaderCircle,{className:"mr-2 size-4 animate-spin font-bold"})," Saving"]}),!c&&a.jsxs(a.Fragment,{children:[a.jsx(g,{className:"mr-2 size-4 font-bold"}),"Save to Library"]})]})}function X({className:u}){const d=e.useQueryClient(),[o,c]=f.useState(!1),r=e.useSelectedVisual(),i=e.useEditorStore(l=>l.frame),n=e.useDashboardStore(l=>l.selectedSheetId),{updateFrame:s,setIsVisualEditing:t}=e.useDashboardActions(),{getUpdatedFrame:y}=k.useVisualUtils(),m=e.useUpdateVisualMutation(),p=async()=>{if(!n){e.ue.error("No sheet selected");return}const l=(i==null?void 0:i.visualId)||(r==null?void 0:r.id);if(!l){e.ue.error("No visual to update");return}c(!0);try{const h=y();await m.mutateAsync({visualId:l,data:{frameObject:h}});const b={...h,visualId:l};s(n,b),d.invalidateQueries({queryKey:["visuals"]}),d.invalidateQueries({queryKey:["visual",l]}),e.ue.success("Saved to library and applied locally"),setTimeout(()=>{t(!1)},300)}catch(h){console.error("Failed to save and apply:",h),e.ue.error("Failed to save and apply changes")}finally{c(!1)}};return a.jsx(e.Button,{onClick:p,className:e.cn("h-8",u),size:"sm",variant:"default",disabled:o,children:o?a.jsxs(a.Fragment,{children:[a.jsx(e.LoaderCircle,{className:"mr-2 size-4 animate-spin font-bold"})," Saving..."]}):a.jsxs(a.Fragment,{children:[a.jsx(g,{className:"mr-2 size-4 font-bold"}),"Save & Apply"]})})}function H({className:u}){const{setTempQueryData:d,setSqlGen:o}=e.useEditorActions(),c=e.useQueryClient(),r=e.useEditorStore(p=>p.tempQueryData),i=e.useEditorStore(p=>p.onClose),n=e.useEditorStore(p=>p.card),s=E(),t=f.useMemo(()=>s!==n.type?{...n,type:s}:n,[n,s]),{queryKey:y}=e.useDashboardCardQuery(t);function m(){if(r){const{queryKey:p,queryData:l}=r;p&&l&&c.setQueryData(p,l)}o({}),i==null||i()}return a.jsxs(e.Button,{onClick:m,className:e.cn("h-8",u),size:"sm",variant:"outline",children:[a.jsx(e.X,{className:"mr-2 size-4"}),"Close"]})}function R(){const{setTempQueryData:u}=e.useEditorActions(),d=e.useQueryClient();e.useEditorStore(S=>S.isDevMode);const o=e.useEditorStore(S=>S.tempQueryData),c=e.useEditorStore(S=>S.card),r=E(),i=f.useMemo(()=>r!==c.type?{...c,type:r}:c,[c,r]),{queryKey:n}=e.useDashboardCardQuery(i),{setCardSql:s,setSqlGen:t,setCardPython:y,setCardCustomCfg:m,setCardPreferences:p,updateDataSource:l,clearQueryConfig:h,setCardConfig:b,setCardType:A,setFrame:B,setCard:Q,setActiveTabCardId:L}=e.useEditorActions();function z(){var q,N,V,D;const S=d.getQueryData(n);o!=null&&o.queryData||u({queryKey:n,queryData:S}),d.setQueryData(n,null),d.removeQueries({queryKey:n,exact:!0}),s(""),t({}),h(),b(void 0),y(""),m(""),p({});const x=e.useEditorStore.getState().frame,I=e.useEditorStore.getState().card,v=e.findCustomVisualConfigCard(x,I),j=((q=v==null?void 0:v.customCardPreferences)==null?void 0:q.visualType)==="multiple"||!!((N=v==null?void 0:v.customCardPreferences)!=null&&N.dataInputCardIds)||(((V=v==null?void 0:v.customCardPreferences)==null?void 0:V.minInputs)||0)>1||(((D=v==null?void 0:v.customCardPreferences)==null?void 0:D.maxInputs)||0)>1,C=U(I,j);B({...x,cards:x.cards.map(M=>M.id===C.id?C:M)}),L(C.id),Q(C),j||A("bar")}return a.jsxs(e.Button,{onClick:z,className:"h-8",size:"sm",variant:"secondary",children:[a.jsx(e.X,{className:"mr-2 size-3.5"}),"Clear"]})}exports.CircleX=P;exports.EditorAcceptButton=K;exports.EditorCancelButton=H;exports.EditorClearButton=R;exports.Library=T;exports.Link2=F;exports.Save=g;exports.VisualBadge=w;exports.VisualSaveAndApplyButton=X;exports.VisualSaveButton=O;exports.useEffectiveEditorCardType=E;
@@ -0,0 +1,404 @@
1
+ import { bS as T, a1 as u, bT as B, bU as ee, bV as ae, bW as te, bX as se, bY as re, u as F, bO as le, bZ as oe, b_ as ne, b$ as ie, c0 as de, c as g, c1 as ue, c2 as ce, Y as q, B as I, E as pe, U as D, Z as U, V as K, c3 as j, H as O, c4 as H, X, I as S } from "./index-BDS2sWhv.js";
2
+ import { jsx as m, jsxs as f, Fragment as x } from "react/jsx-runtime";
3
+ import { u as me, a as M } from "./use-visual-utils-ptPsQ3nC.js";
4
+ import { useMemo as C, useState as G } from "react";
5
+ /**
6
+ * @license lucide-react v0.453.0 - ISC
7
+ *
8
+ * This source code is licensed under the ISC license.
9
+ * See the LICENSE file in the root directory of this source tree.
10
+ */
11
+ const Se = T("CircleX", [
12
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
13
+ ["path", { d: "m15 9-6 6", key: "1uzhvr" }],
14
+ ["path", { d: "m9 9 6 6", key: "z0biqf" }]
15
+ ]);
16
+ /**
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
+ */
22
+ const ye = T("Library", [
23
+ ["path", { d: "m16 6 4 14", key: "ji33uf" }],
24
+ ["path", { d: "M12 6v14", key: "1n7gus" }],
25
+ ["path", { d: "M8 8v12", key: "1gg7y9" }],
26
+ ["path", { d: "M4 4v16", key: "6qkkli" }]
27
+ ]);
28
+ /**
29
+ * @license lucide-react v0.453.0 - ISC
30
+ *
31
+ * This source code is licensed under the ISC license.
32
+ * See the LICENSE file in the root directory of this source tree.
33
+ */
34
+ const be = T("Link2", [
35
+ ["path", { d: "M9 17H7A5 5 0 0 1 7 7h2", key: "8i5ue5" }],
36
+ ["path", { d: "M15 7h2a5 5 0 1 1 0 10h-2", key: "1b9ql8" }],
37
+ ["line", { x1: "8", x2: "16", y1: "12", y2: "12", key: "1jonct" }]
38
+ ]);
39
+ /**
40
+ * @license lucide-react v0.453.0 - ISC
41
+ *
42
+ * This source code is licensed under the ISC license.
43
+ * See the LICENSE file in the root directory of this source tree.
44
+ */
45
+ const Y = T("Save", [
46
+ [
47
+ "path",
48
+ {
49
+ 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",
50
+ key: "1c8476"
51
+ }
52
+ ],
53
+ ["path", { d: "M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7", key: "1ydtos" }],
54
+ ["path", { d: "M7 3v4a1 1 0 0 0 1 1h7", key: "t51u73" }]
55
+ ]);
56
+ function Z() {
57
+ var e, y;
58
+ const r = u((p) => p.card), i = u((p) => p.frame), s = C(
59
+ () => B(i, r),
60
+ [i, r]
61
+ ), { manifest: d } = ee(
62
+ ((e = s == null ? void 0 : s.customCardPreferences) == null ? void 0 : e.url) || ""
63
+ ), a = C(
64
+ () => {
65
+ var p;
66
+ return (p = d == null ? void 0 : d.visuals) == null ? void 0 : p.find(
67
+ (c) => {
68
+ var n;
69
+ return c.name === ((n = s == null ? void 0 : s.customCardPreferences) == null ? void 0 : n.componentName);
70
+ }
71
+ );
72
+ },
73
+ [d, (y = s == null ? void 0 : s.customCardPreferences) == null ? void 0 : y.componentName]
74
+ ), l = ae(s, a), o = C(
75
+ () => te({
76
+ frame: i,
77
+ configCard: s,
78
+ isMultiInputVisual: l === "multiple"
79
+ }),
80
+ [i, s, l]
81
+ ), t = C(() => {
82
+ const p = o.findIndex(
83
+ (c) => (c == null ? void 0 : c.id) === r.id
84
+ );
85
+ return p < 0 ? -1 : se(r, p);
86
+ }, [o, r]);
87
+ return C(() => !s || l !== "multiple" || t < 0 ? r.type : re(
88
+ r,
89
+ t,
90
+ a == null ? void 0 : a.slots
91
+ ) ?? r.type, [s, l, t, r, a == null ? void 0 : a.slots]);
92
+ }
93
+ function ge({
94
+ type: r,
95
+ isLinked: i,
96
+ className: s,
97
+ showLabel: d = !1
98
+ }) {
99
+ const a = F((v) => v.selectedFrameId), l = le((v) => v.selectedVisual), o = u((v) => v.frame);
100
+ let t;
101
+ if (r)
102
+ t = r;
103
+ else if (i !== void 0)
104
+ t = i ? "linked" : "library";
105
+ else if (!!!(o != null && o.visualId || l != null && l.id) && a)
106
+ t = "local";
107
+ else if (l && !a)
108
+ t = "library";
109
+ else if (o != null && o.visualId && a)
110
+ t = "linked";
111
+ else if (l != null && l.id && a)
112
+ t = "library";
113
+ else
114
+ return null;
115
+ if (t === "local")
116
+ return null;
117
+ const e = {
118
+ 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",
119
+ 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"
120
+ }, y = {
121
+ linked: "Linked to library: Changes made here update the library visual and all linked instances.",
122
+ library: "Library visual: Share and reuse this visual across multiple dashboards."
123
+ }, p = {
124
+ linked: "border-purple-200 bg-purple-50 text-purple-900 dark:border-purple-800 dark:bg-purple-950 dark:text-purple-100",
125
+ library: "border-blue-200 bg-blue-50 text-blue-900 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-100"
126
+ }, c = {
127
+ linked: "fill-purple-50 dark:fill-purple-950",
128
+ library: "fill-blue-50 dark:fill-blue-950"
129
+ }, n = {
130
+ linked: /* @__PURE__ */ m(be, { className: "h-3.5 w-3.5" }),
131
+ library: /* @__PURE__ */ m(ye, { className: "h-3.5 w-3.5" })
132
+ }, b = {
133
+ linked: "Linked",
134
+ library: "Library"
135
+ };
136
+ return /* @__PURE__ */ m(oe, { children: /* @__PURE__ */ f(ne, { delayDuration: 300, children: [
137
+ /* @__PURE__ */ m(ie, { asChild: !0, children: /* @__PURE__ */ f(
138
+ de,
139
+ {
140
+ variant: "outline",
141
+ className: g(
142
+ "cursor-help select-none transition-all",
143
+ e[t],
144
+ s
145
+ ),
146
+ children: [
147
+ n[t],
148
+ d && /* @__PURE__ */ m("span", { className: "ml-1 text-xs font-medium leading-none", children: b[t] })
149
+ ]
150
+ }
151
+ ) }),
152
+ /* @__PURE__ */ f(
153
+ ue,
154
+ {
155
+ side: "bottom",
156
+ className: g("max-w-xs", p[t]),
157
+ children: [
158
+ /* @__PURE__ */ m(ce, { className: c[t] }),
159
+ /* @__PURE__ */ m("p", { children: y[t] })
160
+ ]
161
+ }
162
+ )
163
+ ] }) });
164
+ }
165
+ function he(r, i) {
166
+ return {
167
+ ...r,
168
+ sql: "",
169
+ python: "",
170
+ config: void 0,
171
+ customCfg: "",
172
+ preferences: {},
173
+ interactionConfig: void 0,
174
+ linkedInteractionTargetOverrides: void 0,
175
+ customCardPreferences: i ? r.customCardPreferences : void 0,
176
+ type: i ? r.type : "bar"
177
+ };
178
+ }
179
+ function Ie({
180
+ className: r,
181
+ variant: i = "outline"
182
+ }) {
183
+ var t;
184
+ const { setCardSql: s } = q();
185
+ u((e) => e.frame);
186
+ const d = u((e) => e.card);
187
+ me(
188
+ ((t = d.customCardPreferences) == null ? void 0 : t.url) || ""
189
+ ), u(
190
+ (e) => e.selectedSchemaName
191
+ ), u(
192
+ (e) => e.selectedDatamodelId
193
+ ), u(
194
+ (e) => e.selectedDatabaseName
195
+ ), u((e) => e.selectedTableName), u(
196
+ (e) => e.selectedConnectionId
197
+ ), u((e) => e.isShowingVisual), d.sql;
198
+ const a = u((e) => e.onSave), { getUpdatedFrame: l } = M();
199
+ function o() {
200
+ const e = l();
201
+ a == null || a(e);
202
+ }
203
+ return /* @__PURE__ */ f(
204
+ I,
205
+ {
206
+ onClick: o,
207
+ className: g("h-8", r),
208
+ size: "sm",
209
+ variant: i,
210
+ children: [
211
+ /* @__PURE__ */ m(pe, { className: "mr-2 size-4 font-bold" }),
212
+ "Accept"
213
+ ]
214
+ }
215
+ );
216
+ }
217
+ function Ne({
218
+ className: r,
219
+ variant: i = "default"
220
+ }) {
221
+ const s = D(), [d, a] = G(!1), l = F(
222
+ (n) => n.actions.setIsDashboardPanelOpen
223
+ ), { setIsVisualEditing: o } = U(), { getUpdatedFrame: t } = M(), e = K(), y = u((n) => n.frame), p = j();
224
+ return /* @__PURE__ */ f(
225
+ I,
226
+ {
227
+ onClick: () => {
228
+ const n = t(), b = (y == null ? void 0 : y.visualId) || (e == null ? void 0 : e.id);
229
+ if (!b) {
230
+ S.error("No visual to save");
231
+ return;
232
+ }
233
+ a(!0), p.mutate(
234
+ {
235
+ visualId: b,
236
+ data: {
237
+ frameObject: n
238
+ }
239
+ },
240
+ {
241
+ onSuccess: () => {
242
+ a(!1), l(!0), S.success("Visual updated successfully"), s.invalidateQueries({
243
+ queryKey: ["resource-by-id", "visual", b],
244
+ exact: !0
245
+ });
246
+ },
247
+ onError: () => {
248
+ a(!1), S.error("Failed to update visual");
249
+ }
250
+ }
251
+ );
252
+ },
253
+ className: g("h-8", r),
254
+ size: "sm",
255
+ variant: i,
256
+ children: [
257
+ d && /* @__PURE__ */ f(x, { children: [
258
+ /* @__PURE__ */ m(O, { className: "mr-2 size-4 animate-spin font-bold" }),
259
+ " Saving"
260
+ ] }),
261
+ !d && /* @__PURE__ */ f(x, { children: [
262
+ /* @__PURE__ */ m(Y, { className: "mr-2 size-4 font-bold" }),
263
+ "Save to Library"
264
+ ] })
265
+ ]
266
+ }
267
+ );
268
+ }
269
+ function qe({
270
+ className: r
271
+ }) {
272
+ const i = D(), [s, d] = G(!1), a = K(), l = u((n) => n.frame), o = F((n) => n.selectedSheetId), { updateFrame: t, setIsVisualEditing: e } = U(), { getUpdatedFrame: y } = M(), p = j();
273
+ return /* @__PURE__ */ m(
274
+ I,
275
+ {
276
+ onClick: async () => {
277
+ if (!o) {
278
+ S.error("No sheet selected");
279
+ return;
280
+ }
281
+ const n = (l == null ? void 0 : l.visualId) || (a == null ? void 0 : a.id);
282
+ if (!n) {
283
+ S.error("No visual to update");
284
+ return;
285
+ }
286
+ d(!0);
287
+ try {
288
+ const b = y();
289
+ await p.mutateAsync({
290
+ visualId: n,
291
+ data: {
292
+ frameObject: b
293
+ }
294
+ });
295
+ const v = {
296
+ ...b,
297
+ visualId: n
298
+ // Keep the link to library visual
299
+ };
300
+ t(o, v), i.invalidateQueries({ queryKey: ["visuals"] }), i.invalidateQueries({ queryKey: ["visual", n] }), S.success("Saved to library and applied locally"), setTimeout(() => {
301
+ e(!1);
302
+ }, 300);
303
+ } catch (b) {
304
+ console.error("Failed to save and apply:", b), S.error("Failed to save and apply changes");
305
+ } finally {
306
+ d(!1);
307
+ }
308
+ },
309
+ className: g("h-8", r),
310
+ size: "sm",
311
+ variant: "default",
312
+ disabled: s,
313
+ children: s ? /* @__PURE__ */ f(x, { children: [
314
+ /* @__PURE__ */ m(O, { className: "mr-2 size-4 animate-spin font-bold" }),
315
+ " Saving..."
316
+ ] }) : /* @__PURE__ */ f(x, { children: [
317
+ /* @__PURE__ */ m(Y, { className: "mr-2 size-4 font-bold" }),
318
+ "Save & Apply"
319
+ ] })
320
+ }
321
+ );
322
+ }
323
+ function xe({ className: r }) {
324
+ const { setTempQueryData: i, setSqlGen: s } = q(), d = D(), a = u((c) => c.tempQueryData), l = u((c) => c.onClose), o = u((c) => c.card), t = Z(), e = C(() => t !== o.type ? { ...o, type: t } : o, [o, t]), { queryKey: y } = H(e);
325
+ function p() {
326
+ if (a) {
327
+ const { queryKey: c, queryData: n } = a;
328
+ c && n && d.setQueryData(c, n);
329
+ }
330
+ s({}), l == null || l();
331
+ }
332
+ return /* @__PURE__ */ f(
333
+ I,
334
+ {
335
+ onClick: p,
336
+ className: g("h-8", r),
337
+ size: "sm",
338
+ variant: "outline",
339
+ children: [
340
+ /* @__PURE__ */ m(X, { className: "mr-2 size-4" }),
341
+ "Close"
342
+ ]
343
+ }
344
+ );
345
+ }
346
+ function Te() {
347
+ const { setTempQueryData: r } = q(), i = D();
348
+ u((k) => k.isDevMode);
349
+ const s = u((k) => k.tempQueryData), d = u((k) => k.card), a = Z(), l = C(() => a !== d.type ? { ...d, type: a } : d, [d, a]), { queryKey: o } = H(l), {
350
+ setCardSql: t,
351
+ setSqlGen: e,
352
+ setCardPython: y,
353
+ setCardCustomCfg: p,
354
+ setCardPreferences: c,
355
+ updateDataSource: n,
356
+ clearQueryConfig: b,
357
+ setCardConfig: v,
358
+ setCardType: R,
359
+ setFrame: W,
360
+ setCard: _,
361
+ setActiveTabCardId: $
362
+ } = q();
363
+ function J() {
364
+ var P, E, Q, w;
365
+ const k = i.getQueryData(o);
366
+ s != null && s.queryData || r({
367
+ queryKey: o,
368
+ queryData: k
369
+ }), i.setQueryData(o, null), i.removeQueries({ queryKey: o, exact: !0 }), t(""), e({}), b(), v(void 0), y(""), p(""), c({});
370
+ const V = u.getState().frame, z = u.getState().card, h = B(V, z), A = ((P = h == null ? void 0 : h.customCardPreferences) == null ? void 0 : P.visualType) === "multiple" || !!((E = h == null ? void 0 : h.customCardPreferences) != null && E.dataInputCardIds) || (((Q = h == null ? void 0 : h.customCardPreferences) == null ? void 0 : Q.minInputs) || 0) > 1 || (((w = h == null ? void 0 : h.customCardPreferences) == null ? void 0 : w.maxInputs) || 0) > 1, N = he(z, A);
371
+ W({
372
+ ...V,
373
+ cards: V.cards.map(
374
+ (L) => L.id === N.id ? N : L
375
+ )
376
+ }), $(N.id), _(N), A || R("bar");
377
+ }
378
+ return /* @__PURE__ */ f(
379
+ I,
380
+ {
381
+ onClick: J,
382
+ className: "h-8",
383
+ size: "sm",
384
+ variant: "secondary",
385
+ children: [
386
+ /* @__PURE__ */ m(X, { className: "mr-2 size-3.5" }),
387
+ "Clear"
388
+ ]
389
+ }
390
+ );
391
+ }
392
+ export {
393
+ Se as C,
394
+ Ie as E,
395
+ ye as L,
396
+ Y as S,
397
+ ge as V,
398
+ Ne as a,
399
+ qe as b,
400
+ be as c,
401
+ xe as d,
402
+ Te as e,
403
+ Z as u
404
+ };