react-semaphor 0.1.209 → 0.1.210
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.
- package/dist/chunks/dashboard-controls-BAOrAMV9.js +42 -0
- package/dist/chunks/{dashboard-controls-BNTI4r0_.js → dashboard-controls-C08300Wi.js} +504 -456
- package/dist/chunks/{dashboard-json-kIoBtmBF.js → dashboard-json-DlEE5-WA.js} +1 -1
- package/dist/chunks/{dashboard-json-BjOqpGbW.js → dashboard-json-GjDBGO26.js} +1 -1
- package/dist/chunks/{dashboard-summary-settings-dialog-BoX18wiA.js → dashboard-summary-settings-dialog-QUuhhXU9.js} +1 -1
- package/dist/chunks/{dashboard-summary-settings-dialog-CO1SwHHD.js → dashboard-summary-settings-dialog-THx-gjnG.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-DG4VLoJF.js → edit-dashboard-visual-Bsmow1Pa.js} +3422 -3536
- package/dist/chunks/edit-dashboard-visual-PfWJXb2-.js +164 -0
- package/dist/chunks/editor-action-buttons-DNbp_ZWy.js +404 -0
- package/dist/chunks/editor-action-buttons-FPyaC09X.js +21 -0
- package/dist/chunks/{index-D0TdW88i.js → index-CAVrkf9d.js} +2196 -2180
- package/dist/chunks/{index-DSA80lEg.js → index-CXKjmjfB.js} +67 -67
- package/dist/chunks/normalize-dashboard-for-dirty-check-D9x96J2F.js +1 -0
- package/dist/chunks/normalize-dashboard-for-dirty-check-XKgH3GFX.js +119 -0
- package/dist/chunks/notification-bell-BqvKQSw9.js +6 -0
- package/dist/chunks/notification-bell-C3a7wC1u.js +871 -0
- package/dist/chunks/{resource-management-panel-DS_WEv1x.js → resource-management-panel-BVTgbma8.js} +343 -332
- package/dist/chunks/resource-management-panel-C5NjrVsA.js +6 -0
- package/dist/chunks/{use-role-aware-display-preferences-DfihB5pN.js → use-role-aware-display-preferences-DxCPoCgr.js} +1 -1
- package/dist/chunks/{use-role-aware-display-preferences-D8j5_cnK.js → use-role-aware-display-preferences-l7NFLYnn.js} +1 -1
- package/dist/chunks/{use-visual-utils-CzcVz3zB.js → use-visual-utils-B82Q-Ytl.js} +1 -1
- package/dist/chunks/{use-visual-utils-BfLXO_vi.js → use-visual-utils-D9IJz9R0.js} +1 -1
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +44 -40
- package/dist/shared/index.cjs +1 -0
- package/dist/shared/index.js +6 -0
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/main.d.ts +39 -1
- package/dist/types/shared.d.ts +1762 -0
- package/package.json +6 -1
- package/dist/chunks/dashboard-controls-Dcpx9_an.js +0 -42
- package/dist/chunks/edit-dashboard-visual-B9HuGExj.js +0 -179
- package/dist/chunks/editor-action-buttons-CDTIx_Jc.js +0 -11
- package/dist/chunks/editor-action-buttons-CszdZ4Fw.js +0 -345
- package/dist/chunks/notification-bell-D2V1-ARa.js +0 -11
- package/dist/chunks/notification-bell-DFiRaeJQ.js +0 -862
- package/dist/chunks/resource-management-panel-BhiWNPcw.js +0 -6
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("./index-DSA80lEg.js"),r=require("react/jsx-runtime"),h=require("./use-visual-utils-CzcVz3zB.js"),v=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 k=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 x=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 g(){var t,y;const o=e.useEditorStore(p=>p.card),u=e.useEditorStore(p=>p.frame),s=v.useMemo(()=>e.findCustomVisualConfigCard(u,o),[u,o]),{manifest:n}=e.useCustomVisual(((t=s==null?void 0:s.customCardPreferences)==null?void 0:t.url)||""),a=v.useMemo(()=>{var p;return(p=n==null?void 0:n.visuals)==null?void 0:p.find(l=>{var d;return l.name===((d=s==null?void 0:s.customCardPreferences)==null?void 0:d.componentName)})},[n,(y=s==null?void 0:s.customCardPreferences)==null?void 0:y.componentName]),i=e.resolveMultiInputType(s,a),c=v.useMemo(()=>e.getCustomVisualInputCards({frame:u,configCard:s,isMultiInputVisual:i==="multiple"}),[u,s,i]),m=v.useMemo(()=>{const p=c.findIndex(l=>(l==null?void 0:l.id)===o.id);return p<0?-1:e.getSlotIndexForCard(o,p)},[c,o]);return v.useMemo(()=>!s||i!=="multiple"||m<0?o.type:e.getEffectiveCardTypeForSlot(o,m,a==null?void 0:a.slots)??o.type,[s,i,m,o,a==null?void 0:a.slots])}function P(o,u){return{...o,sql:"",python:"",config:void 0,customCfg:"",preferences:{},interactionConfig:void 0,linkedInteractionTargetOverrides:void 0,customCardPreferences:u?o.customCardPreferences:void 0,type:u?o.type:"bar"}}function U({className:o,variant:u="outline"}){var m;const{setCardSql:s}=e.useEditorActions();e.useEditorStore(t=>t.frame);const n=e.useEditorStore(t=>t.card);h.useRemoteChartStore(((m=n.customCardPreferences)==null?void 0:m.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),n.sql;const a=e.useEditorStore(t=>t.onSave),{getUpdatedFrame:i}=h.useVisualUtils();function c(){const t=i();a==null||a(t)}return r.jsxs(e.Button,{onClick:c,className:e.cn("h-8",o),size:"sm",variant:u,children:[r.jsx(e.Check,{className:"mr-2 size-4 font-bold"}),"Accept"]})}function L({className:o,variant:u="default"}){const s=e.useQueryClient(),[n,a]=v.useState(!1),i=e.useDashboardStore(d=>d.actions.setIsDashboardPanelOpen),{setIsVisualEditing:c}=e.useDashboardActions(),{getUpdatedFrame:m}=h.useVisualUtils(),t=e.useSelectedVisual(),y=e.useEditorStore(d=>d.frame),p=e.useUpdateVisualMutation(),l=()=>{const d=m(),S=(y==null?void 0:y.visualId)||(t==null?void 0:t.id);if(!S){e.ue.error("No visual to save");return}a(!0),p.mutate({visualId:S,data:{frameObject:d}},{onSuccess:()=>{a(!1),i(!0),e.ue.success("Visual updated successfully"),s.invalidateQueries({queryKey:["resource-by-id","visual",S],exact:!0})},onError:()=>{a(!1),e.ue.error("Failed to update visual")}})};return r.jsxs(e.Button,{onClick:l,className:e.cn("h-8",o),size:"sm",variant:u,children:[n&&r.jsxs(r.Fragment,{children:[r.jsx(e.LoaderCircle,{className:"mr-2 size-4 animate-spin font-bold"})," Saving"]}),!n&&r.jsxs(r.Fragment,{children:[r.jsx(x,{className:"mr-2 size-4 font-bold"}),"Save to Library"]})]})}function K({className:o}){const u=e.useQueryClient(),[s,n]=v.useState(!1),a=e.useSelectedVisual(),i=e.useEditorStore(d=>d.frame),c=e.useDashboardStore(d=>d.selectedSheetId),{updateFrame:m,setIsVisualEditing:t}=e.useDashboardActions(),{getUpdatedFrame:y}=h.useVisualUtils(),p=e.useUpdateVisualMutation(),l=async()=>{if(!c){e.ue.error("No sheet selected");return}const d=(i==null?void 0:i.visualId)||(a==null?void 0:a.id);if(!d){e.ue.error("No visual to update");return}n(!0);try{const S=y();await p.mutateAsync({visualId:d,data:{frameObject:S}});const I={...S,visualId:d};m(c,I),u.invalidateQueries({queryKey:["visuals"]}),u.invalidateQueries({queryKey:["visual",d]}),e.ue.success("Saved to library and applied locally"),setTimeout(()=>{t(!1)},300)}catch(S){console.error("Failed to save and apply:",S),e.ue.error("Failed to save and apply changes")}finally{n(!1)}};return r.jsx(e.Button,{onClick:l,className:e.cn("h-8",o),size:"sm",variant:"default",disabled:s,children:s?r.jsxs(r.Fragment,{children:[r.jsx(e.LoaderCircle,{className:"mr-2 size-4 animate-spin font-bold"})," Saving..."]}):r.jsxs(r.Fragment,{children:[r.jsx(x,{className:"mr-2 size-4 font-bold"}),"Save & Apply"]})})}function O({className:o}){const{getUpdatedFrame:u}=h.useVisualUtils();e.useEditorStore(t=>t.frame);const s=e.useDashboardStore(t=>t.selectedSheetId),{updateFrame:n,setIsVisualEditing:a}=e.useDashboardActions(),[i,c]=v.useState(!1),m=()=>{if(!s){e.ue.error("No sheet selected");return}c(!0);const y={...u(),visualId:void 0};n(s,y),setTimeout(()=>{c(!1),e.ue.success("Changes applied. Visual is now local to this dashboard"),a(!1)},300)};return r.jsxs(e.Button,{onClick:m,className:e.cn("h-8",o),size:"sm",variant:"outline",children:[i&&r.jsxs(r.Fragment,{children:[r.jsx(e.LoaderCircle,{className:"mr-2 size-4 animate-spin font-bold"})," Applying"]}),!i&&r.jsxs(r.Fragment,{children:[r.jsx(e.Check,{className:"mr-2 size-4 font-bold"}),"Apply Locally"]})]})}function X({className:o}){const{setTempQueryData:u,setSqlGen:s}=e.useEditorActions(),n=e.useQueryClient(),a=e.useEditorStore(l=>l.tempQueryData),i=e.useEditorStore(l=>l.onClose),c=e.useEditorStore(l=>l.card),m=g(),t=v.useMemo(()=>m!==c.type?{...c,type:m}:c,[c,m]),{queryKey:y}=e.useDashboardCardQuery(t);function p(){if(a){const{queryKey:l,queryData:d}=a;l&&d&&n.setQueryData(l,d)}s({}),i==null||i()}return r.jsxs(e.Button,{onClick:p,className:e.cn("h-8",o),size:"sm",variant:"outline",children:[r.jsx(e.X,{className:"mr-2 size-4"}),"Close"]})}function w(){const{setTempQueryData:o}=e.useEditorActions(),u=e.useQueryClient();e.useEditorStore(C=>C.isDevMode);const s=e.useEditorStore(C=>C.tempQueryData),n=e.useEditorStore(C=>C.card),a=g(),i=v.useMemo(()=>a!==n.type?{...n,type:a}:n,[n,a]),{queryKey:c}=e.useDashboardCardQuery(i),{setCardSql:m,setSqlGen:t,setCardPython:y,setCardCustomCfg:p,setCardPreferences:l,updateDataSource:d,clearQueryConfig:S,setCardConfig:I,setCardType:z,setFrame:B,setCard:Q,setActiveTabCardId:M}=e.useEditorActions();function T(){var A,F,j,D;const C=u.getQueryData(c);s!=null&&s.queryData||o({queryKey:c,queryData:C}),u.setQueryData(c,null),u.removeQueries({queryKey:c,exact:!0}),m(""),t({}),S(),I(void 0),y(""),p(""),l({});const b=e.useEditorStore.getState().frame,V=e.useEditorStore.getState().card,f=e.findCustomVisualConfigCard(b,V),q=((A=f==null?void 0:f.customCardPreferences)==null?void 0:A.visualType)==="multiple"||!!((F=f==null?void 0:f.customCardPreferences)!=null&&F.dataInputCardIds)||(((j=f==null?void 0:f.customCardPreferences)==null?void 0:j.minInputs)||0)>1||(((D=f==null?void 0:f.customCardPreferences)==null?void 0:D.maxInputs)||0)>1,E=P(V,q);B({...b,cards:b.cards.map(N=>N.id===E.id?E:N)}),M(E.id),Q(E),q||z("bar")}return r.jsxs(e.Button,{onClick:T,className:"h-8",size:"sm",variant:"secondary",children:[r.jsx(e.X,{className:"mr-2 size-3.5"}),"Clear"]})}exports.CircleX=k;exports.EditorAcceptButton=U;exports.EditorCancelButton=X;exports.EditorClearButton=w;exports.Save=x;exports.VisualApplyLocalButton=O;exports.VisualSaveAndApplyButton=K;exports.VisualSaveButton=L;exports.useEffectiveEditorCardType=g;
|
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
import { bP as O, bA as n, bQ as j, bR as ae, bS as te, bT as se, bU as re, bV as ne, by as A, B as N, E as X, c as g, u as T, bs as k, H as E, bJ as F, bK as w, bW as H, bX as G, X as R, I as C } from "./index-D0TdW88i.js";
|
|
2
|
-
import { jsxs as f, jsx as h, Fragment as I } from "react/jsx-runtime";
|
|
3
|
-
import { u as oe, a as V } from "./use-visual-utils-BfLXO_vi.js";
|
|
4
|
-
import { useMemo as S, useState as P } 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 me = O("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 J = O("Save", [
|
|
23
|
-
[
|
|
24
|
-
"path",
|
|
25
|
-
{
|
|
26
|
-
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",
|
|
27
|
-
key: "1c8476"
|
|
28
|
-
}
|
|
29
|
-
],
|
|
30
|
-
["path", { d: "M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7", key: "1ydtos" }],
|
|
31
|
-
["path", { d: "M7 3v4a1 1 0 0 0 1 1h7", key: "t51u73" }]
|
|
32
|
-
]);
|
|
33
|
-
function W() {
|
|
34
|
-
var e, p;
|
|
35
|
-
const s = n((m) => m.card), o = n((m) => m.frame), a = S(
|
|
36
|
-
() => j(o, s),
|
|
37
|
-
[o, s]
|
|
38
|
-
), { manifest: r } = ae(
|
|
39
|
-
((e = a == null ? void 0 : a.customCardPreferences) == null ? void 0 : e.url) || ""
|
|
40
|
-
), t = S(
|
|
41
|
-
() => {
|
|
42
|
-
var m;
|
|
43
|
-
return (m = r == null ? void 0 : r.visuals) == null ? void 0 : m.find(
|
|
44
|
-
(d) => {
|
|
45
|
-
var i;
|
|
46
|
-
return d.name === ((i = a == null ? void 0 : a.customCardPreferences) == null ? void 0 : i.componentName);
|
|
47
|
-
}
|
|
48
|
-
);
|
|
49
|
-
},
|
|
50
|
-
[r, (p = a == null ? void 0 : a.customCardPreferences) == null ? void 0 : p.componentName]
|
|
51
|
-
), c = te(a, t), l = S(
|
|
52
|
-
() => se({
|
|
53
|
-
frame: o,
|
|
54
|
-
configCard: a,
|
|
55
|
-
isMultiInputVisual: c === "multiple"
|
|
56
|
-
}),
|
|
57
|
-
[o, a, c]
|
|
58
|
-
), u = S(() => {
|
|
59
|
-
const m = l.findIndex(
|
|
60
|
-
(d) => (d == null ? void 0 : d.id) === s.id
|
|
61
|
-
);
|
|
62
|
-
return m < 0 ? -1 : re(s, m);
|
|
63
|
-
}, [l, s]);
|
|
64
|
-
return S(() => !a || c !== "multiple" || u < 0 ? s.type : ne(
|
|
65
|
-
s,
|
|
66
|
-
u,
|
|
67
|
-
t == null ? void 0 : t.slots
|
|
68
|
-
) ?? s.type, [a, c, u, s, t == null ? void 0 : t.slots]);
|
|
69
|
-
}
|
|
70
|
-
function ce(s, o) {
|
|
71
|
-
return {
|
|
72
|
-
...s,
|
|
73
|
-
sql: "",
|
|
74
|
-
python: "",
|
|
75
|
-
config: void 0,
|
|
76
|
-
customCfg: "",
|
|
77
|
-
preferences: {},
|
|
78
|
-
interactionConfig: void 0,
|
|
79
|
-
linkedInteractionTargetOverrides: void 0,
|
|
80
|
-
customCardPreferences: o ? s.customCardPreferences : void 0,
|
|
81
|
-
type: o ? s.type : "bar"
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
function pe({
|
|
85
|
-
className: s,
|
|
86
|
-
variant: o = "outline"
|
|
87
|
-
}) {
|
|
88
|
-
var u;
|
|
89
|
-
const { setCardSql: a } = A();
|
|
90
|
-
n((e) => e.frame);
|
|
91
|
-
const r = n((e) => e.card);
|
|
92
|
-
oe(
|
|
93
|
-
((u = r.customCardPreferences) == null ? void 0 : u.url) || ""
|
|
94
|
-
), n(
|
|
95
|
-
(e) => e.selectedSchemaName
|
|
96
|
-
), n(
|
|
97
|
-
(e) => e.selectedDatamodelId
|
|
98
|
-
), n(
|
|
99
|
-
(e) => e.selectedDatabaseName
|
|
100
|
-
), n((e) => e.selectedTableName), n(
|
|
101
|
-
(e) => e.selectedConnectionId
|
|
102
|
-
), n((e) => e.isShowingVisual), r.sql;
|
|
103
|
-
const t = n((e) => e.onSave), { getUpdatedFrame: c } = V();
|
|
104
|
-
function l() {
|
|
105
|
-
const e = c();
|
|
106
|
-
t == null || t(e);
|
|
107
|
-
}
|
|
108
|
-
return /* @__PURE__ */ f(
|
|
109
|
-
N,
|
|
110
|
-
{
|
|
111
|
-
onClick: l,
|
|
112
|
-
className: g("h-8", s),
|
|
113
|
-
size: "sm",
|
|
114
|
-
variant: o,
|
|
115
|
-
children: [
|
|
116
|
-
/* @__PURE__ */ h(X, { className: "mr-2 size-4 font-bold" }),
|
|
117
|
-
"Accept"
|
|
118
|
-
]
|
|
119
|
-
}
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
function ye({
|
|
123
|
-
className: s,
|
|
124
|
-
variant: o = "default"
|
|
125
|
-
}) {
|
|
126
|
-
const a = F(), [r, t] = P(!1), c = T(
|
|
127
|
-
(i) => i.actions.setIsDashboardPanelOpen
|
|
128
|
-
), { setIsVisualEditing: l } = k(), { getUpdatedFrame: u } = V(), e = w(), p = n((i) => i.frame), m = H();
|
|
129
|
-
return /* @__PURE__ */ f(
|
|
130
|
-
N,
|
|
131
|
-
{
|
|
132
|
-
onClick: () => {
|
|
133
|
-
const i = u(), v = (p == null ? void 0 : p.visualId) || (e == null ? void 0 : e.id);
|
|
134
|
-
if (!v) {
|
|
135
|
-
C.error("No visual to save");
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
t(!0), m.mutate(
|
|
139
|
-
{
|
|
140
|
-
visualId: v,
|
|
141
|
-
data: {
|
|
142
|
-
frameObject: i
|
|
143
|
-
}
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
onSuccess: () => {
|
|
147
|
-
t(!1), c(!0), C.success("Visual updated successfully"), a.invalidateQueries({
|
|
148
|
-
queryKey: ["resource-by-id", "visual", v],
|
|
149
|
-
exact: !0
|
|
150
|
-
});
|
|
151
|
-
},
|
|
152
|
-
onError: () => {
|
|
153
|
-
t(!1), C.error("Failed to update visual");
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
);
|
|
157
|
-
},
|
|
158
|
-
className: g("h-8", s),
|
|
159
|
-
size: "sm",
|
|
160
|
-
variant: o,
|
|
161
|
-
children: [
|
|
162
|
-
r && /* @__PURE__ */ f(I, { children: [
|
|
163
|
-
/* @__PURE__ */ h(E, { className: "mr-2 size-4 animate-spin font-bold" }),
|
|
164
|
-
" Saving"
|
|
165
|
-
] }),
|
|
166
|
-
!r && /* @__PURE__ */ f(I, { children: [
|
|
167
|
-
/* @__PURE__ */ h(J, { className: "mr-2 size-4 font-bold" }),
|
|
168
|
-
"Save to Library"
|
|
169
|
-
] })
|
|
170
|
-
]
|
|
171
|
-
}
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
function fe({
|
|
175
|
-
className: s
|
|
176
|
-
}) {
|
|
177
|
-
const o = F(), [a, r] = P(!1), t = w(), c = n((i) => i.frame), l = T((i) => i.selectedSheetId), { updateFrame: u, setIsVisualEditing: e } = k(), { getUpdatedFrame: p } = V(), m = H();
|
|
178
|
-
return /* @__PURE__ */ h(
|
|
179
|
-
N,
|
|
180
|
-
{
|
|
181
|
-
onClick: async () => {
|
|
182
|
-
if (!l) {
|
|
183
|
-
C.error("No sheet selected");
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
const i = (c == null ? void 0 : c.visualId) || (t == null ? void 0 : t.id);
|
|
187
|
-
if (!i) {
|
|
188
|
-
C.error("No visual to update");
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
r(!0);
|
|
192
|
-
try {
|
|
193
|
-
const v = p();
|
|
194
|
-
await m.mutateAsync({
|
|
195
|
-
visualId: i,
|
|
196
|
-
data: {
|
|
197
|
-
frameObject: v
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
const D = {
|
|
201
|
-
...v,
|
|
202
|
-
visualId: i
|
|
203
|
-
// Keep the link to library visual
|
|
204
|
-
};
|
|
205
|
-
u(l, D), o.invalidateQueries({ queryKey: ["visuals"] }), o.invalidateQueries({ queryKey: ["visual", i] }), C.success("Saved to library and applied locally"), setTimeout(() => {
|
|
206
|
-
e(!1);
|
|
207
|
-
}, 300);
|
|
208
|
-
} catch (v) {
|
|
209
|
-
console.error("Failed to save and apply:", v), C.error("Failed to save and apply changes");
|
|
210
|
-
} finally {
|
|
211
|
-
r(!1);
|
|
212
|
-
}
|
|
213
|
-
},
|
|
214
|
-
className: g("h-8", s),
|
|
215
|
-
size: "sm",
|
|
216
|
-
variant: "default",
|
|
217
|
-
disabled: a,
|
|
218
|
-
children: a ? /* @__PURE__ */ f(I, { children: [
|
|
219
|
-
/* @__PURE__ */ h(E, { className: "mr-2 size-4 animate-spin font-bold" }),
|
|
220
|
-
" Saving..."
|
|
221
|
-
] }) : /* @__PURE__ */ f(I, { children: [
|
|
222
|
-
/* @__PURE__ */ h(J, { className: "mr-2 size-4 font-bold" }),
|
|
223
|
-
"Save & Apply"
|
|
224
|
-
] })
|
|
225
|
-
}
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
function ve({ className: s }) {
|
|
229
|
-
const { getUpdatedFrame: o } = V();
|
|
230
|
-
n((e) => e.frame);
|
|
231
|
-
const a = T((e) => e.selectedSheetId), { updateFrame: r, setIsVisualEditing: t } = k(), [c, l] = P(!1);
|
|
232
|
-
return /* @__PURE__ */ f(
|
|
233
|
-
N,
|
|
234
|
-
{
|
|
235
|
-
onClick: () => {
|
|
236
|
-
if (!a) {
|
|
237
|
-
C.error("No sheet selected");
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
l(!0);
|
|
241
|
-
const p = {
|
|
242
|
-
...o(),
|
|
243
|
-
visualId: void 0
|
|
244
|
-
// Remove the link to library visual
|
|
245
|
-
};
|
|
246
|
-
r(a, p), setTimeout(() => {
|
|
247
|
-
l(!1), C.success("Changes applied. Visual is now local to this dashboard"), t(!1);
|
|
248
|
-
}, 300);
|
|
249
|
-
},
|
|
250
|
-
className: g("h-8", s),
|
|
251
|
-
size: "sm",
|
|
252
|
-
variant: "outline",
|
|
253
|
-
children: [
|
|
254
|
-
c && /* @__PURE__ */ f(I, { children: [
|
|
255
|
-
/* @__PURE__ */ h(E, { className: "mr-2 size-4 animate-spin font-bold" }),
|
|
256
|
-
" Applying"
|
|
257
|
-
] }),
|
|
258
|
-
!c && /* @__PURE__ */ f(I, { children: [
|
|
259
|
-
/* @__PURE__ */ h(X, { className: "mr-2 size-4 font-bold" }),
|
|
260
|
-
"Apply Locally"
|
|
261
|
-
] })
|
|
262
|
-
]
|
|
263
|
-
}
|
|
264
|
-
);
|
|
265
|
-
}
|
|
266
|
-
function he({ className: s }) {
|
|
267
|
-
const { setTempQueryData: o, setSqlGen: a } = A(), r = F(), t = n((d) => d.tempQueryData), c = n((d) => d.onClose), l = n((d) => d.card), u = W(), e = S(() => u !== l.type ? { ...l, type: u } : l, [l, u]), { queryKey: p } = G(e);
|
|
268
|
-
function m() {
|
|
269
|
-
if (t) {
|
|
270
|
-
const { queryKey: d, queryData: i } = t;
|
|
271
|
-
d && i && r.setQueryData(d, i);
|
|
272
|
-
}
|
|
273
|
-
a({}), c == null || c();
|
|
274
|
-
}
|
|
275
|
-
return /* @__PURE__ */ f(
|
|
276
|
-
N,
|
|
277
|
-
{
|
|
278
|
-
onClick: m,
|
|
279
|
-
className: g("h-8", s),
|
|
280
|
-
size: "sm",
|
|
281
|
-
variant: "outline",
|
|
282
|
-
children: [
|
|
283
|
-
/* @__PURE__ */ h(R, { className: "mr-2 size-4" }),
|
|
284
|
-
"Close"
|
|
285
|
-
]
|
|
286
|
-
}
|
|
287
|
-
);
|
|
288
|
-
}
|
|
289
|
-
function Ce() {
|
|
290
|
-
const { setTempQueryData: s } = A(), o = F();
|
|
291
|
-
n((b) => b.isDevMode);
|
|
292
|
-
const a = n((b) => b.tempQueryData), r = n((b) => b.card), t = W(), c = S(() => t !== r.type ? { ...r, type: t } : r, [r, t]), { queryKey: l } = G(c), {
|
|
293
|
-
setCardSql: u,
|
|
294
|
-
setSqlGen: e,
|
|
295
|
-
setCardPython: p,
|
|
296
|
-
setCardCustomCfg: m,
|
|
297
|
-
setCardPreferences: d,
|
|
298
|
-
updateDataSource: i,
|
|
299
|
-
clearQueryConfig: v,
|
|
300
|
-
setCardConfig: D,
|
|
301
|
-
setCardType: Y,
|
|
302
|
-
setFrame: Z,
|
|
303
|
-
setCard: _,
|
|
304
|
-
setActiveTabCardId: $
|
|
305
|
-
} = A();
|
|
306
|
-
function ee() {
|
|
307
|
-
var M, U, B, K;
|
|
308
|
-
const b = o.getQueryData(l);
|
|
309
|
-
a != null && a.queryData || s({
|
|
310
|
-
queryKey: l,
|
|
311
|
-
queryData: b
|
|
312
|
-
}), o.setQueryData(l, null), o.removeQueries({ queryKey: l, exact: !0 }), u(""), e({}), v(), D(void 0), p(""), m(""), d({});
|
|
313
|
-
const z = n.getState().frame, Q = n.getState().card, y = j(z, Q), x = ((M = y == null ? void 0 : y.customCardPreferences) == null ? void 0 : M.visualType) === "multiple" || !!((U = y == null ? void 0 : y.customCardPreferences) != null && U.dataInputCardIds) || (((B = y == null ? void 0 : y.customCardPreferences) == null ? void 0 : B.minInputs) || 0) > 1 || (((K = y == null ? void 0 : y.customCardPreferences) == null ? void 0 : K.maxInputs) || 0) > 1, q = ce(Q, x);
|
|
314
|
-
Z({
|
|
315
|
-
...z,
|
|
316
|
-
cards: z.cards.map(
|
|
317
|
-
(L) => L.id === q.id ? q : L
|
|
318
|
-
)
|
|
319
|
-
}), $(q.id), _(q), x || Y("bar");
|
|
320
|
-
}
|
|
321
|
-
return /* @__PURE__ */ f(
|
|
322
|
-
N,
|
|
323
|
-
{
|
|
324
|
-
onClick: ee,
|
|
325
|
-
className: "h-8",
|
|
326
|
-
size: "sm",
|
|
327
|
-
variant: "secondary",
|
|
328
|
-
children: [
|
|
329
|
-
/* @__PURE__ */ h(R, { className: "mr-2 size-3.5" }),
|
|
330
|
-
"Clear"
|
|
331
|
-
]
|
|
332
|
-
}
|
|
333
|
-
);
|
|
334
|
-
}
|
|
335
|
-
export {
|
|
336
|
-
me as C,
|
|
337
|
-
pe as E,
|
|
338
|
-
J as S,
|
|
339
|
-
ve as V,
|
|
340
|
-
ye as a,
|
|
341
|
-
fe as b,
|
|
342
|
-
he as c,
|
|
343
|
-
Ce as d,
|
|
344
|
-
W as u
|
|
345
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";const p=require("react"),t=require("./index-DSA80lEg.js"),e=require("react/jsx-runtime"),N=require("./editor-action-buttons-CDTIx_Jc.js"),T=require("./use-visual-utils-CzcVz3zB.js"),I=require("./date-formatter-Sz6QDaM8.js");/**
|
|
2
|
-
* @license lucide-react v0.453.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const P=t.createLucideIcon("CirclePlus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/**
|
|
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 k=t.createLucideIcon("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]),L=1e4,V=15e3,B=3e4,R=3e4,z=12e4,U=2*60*60*1e3;function O(s){const r=Date.now()-s.getTime();return r<R?L:r<z?V:B}function $(){const{authToken:s,tokenProps:r}=t.useSemaphorContext(),m=t.useExportStore(f=>f.activeExports),[n,c]=p.useState(typeof document<"u"?!document.hidden:!0),d=p.useRef(null),a=p.useRef(!1),o=p.useRef(void 0),j=r==null?void 0:r.apiServiceUrl,u=s==null?void 0:s.accessToken,g=p.useCallback(()=>{const f=t.useExportStore.getState().activeExports;return Array.from(f.values()).filter(b=>t.isExportInProgress(b.status))},[]);p.useEffect(()=>{if(typeof document>"u")return;const f=()=>{c(!document.hidden)};return document.addEventListener("visibilitychange",f),()=>{document.removeEventListener("visibilitychange",f)}},[]);const C=p.useCallback(async()=>{if(!j||!u){a.current=!1;return}const f=g();if(f.length===0){a.current=!1;return}const b=Date.now(),E=f.filter(l=>b-l.startedAt.getTime()>U);if(E.length>0){const{updateExport:l}=t.useExportStore.getState().actions;for(const i of E)l(i.id,{status:"failed",error:"Export timed out. Please try again or contact support.",lastUpdatedAt:new Date})}const x=f.filter(l=>b-l.startedAt.getTime()<=U);if(x.length===0){a.current=!1;return}const v=await Promise.allSettled(x.map(async l=>{try{const i=await t.getExportStatus(j,u,l.id);let w;if(i.status==="completed")try{w=await t.getDownloadUrl(j,u,l.id)}catch(y){console.error(`[useExportPolling] Failed to get download URL for ${l.id}:`,y)}return{id:l.id,status:i.status,progress:i.progress,completedChunks:i.completedChunks,completedAt:i.completedAt?new Date(i.completedAt):void 0,lastUpdatedAt:new Date,fileSize:i.fileSize,error:i.error,downloadUrl:w}}catch(i){return console.error(`[useExportPolling] Failed to poll export ${l.id}:`,i),null}})),{updateExport:S}=t.useExportStore.getState().actions;for(const l of v)l.status==="fulfilled"&&l.value&&S(l.value.id,l.value);const h=g();if(h.length>0&&!document.hidden){const l=h.reduce((w,y)=>y.startedAt<w?y.startedAt:w,h[0].startedAt),i=O(l);d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{var w;(w=o.current)==null||w.call(o)},i)}else a.current=!1},[j,u,g]);return p.useEffect(()=>{o.current=C},[C]),p.useEffect(()=>{var b;g().length>0&&n&&!a.current&&(a.current=!0,(b=o.current)==null||b.call(o))},[m,n,g]),p.useEffect(()=>{var b;const f=g();n&&f.length>0&&!a.current&&(a.current=!0,(b=o.current)==null||b.call(o))},[n,g]),p.useEffect(()=>{!n&&d.current&&(clearTimeout(d.current),d.current=null,a.current=!1)},[n]),p.useEffect(()=>()=>{d.current&&(clearTimeout(d.current),d.current=null)},[]),{isPolling:a.current,isTabVisible:n,inProgressCount:g().length}}function q(){const{authToken:s,tokenProps:r}=t.useSemaphorContext(),m=t.useExportStore(o=>o.activeExports),{addExport:n}=t.useExportActions(),c=p.useRef(!1),d=r==null?void 0:r.apiServiceUrl,a=s==null?void 0:s.accessToken;p.useEffect(()=>{if(c.current||!d||!a)return;(async()=>{try{const{exports:j}=await t.getExports(d,a,{status:["pending","processing","chunking","compacting","completed","failed"],limit:20});for(const u of j){if(m.has(u.id))continue;const g=u.totalChunks?Math.round(u.completedChunks/u.totalChunks*100):0;let C;if(u.status==="completed")try{C=await t.getDownloadUrl(d,a,u.id)}catch(b){console.error(`[useExportRecovery] Failed to get download URL for ${u.id}:`,b)}const f={id:u.id,status:u.status,progress:g,title:_(u),totalRows:u.totalRows,totalChunks:u.totalChunks,completedChunks:u.completedChunks,startedAt:new Date(u.createdAt),lastUpdatedAt:new Date,completedAt:u.completedAt?new Date(u.completedAt):void 0,fileSize:u.fileSize,error:u.error,expiresAt:new Date(u.expiresAt),downloadUrl:C};n(f)}c.current=!0}catch(j){console.error("[useExportRecovery] Failed to recover exports:",j),c.current=!0}})()},[d,a,n,m])}function _(s){return s.title?s.title:t.isExportInProgress(s.status)?"Export in progress...":s.status==="completed"?"Export completed":s.status==="failed"?"Export failed":"Export"}function H({open:s,onOpenChange:r,isLibraryVisual:m,currentVisualName:n,isSaving:c=!1,onConfirm:d}){const[a,o]=p.useState(m&&n?`Copy of ${n}`:n||""),[j,u]=p.useState(""),[g,C]=p.useState(!m),[f,b]=p.useState(!0);p.useEffect(()=>{s&&(o(m&&n?`Copy of ${n}`:n||""),u(""),C(!m),b(!0))},[s,m,n]);const E=()=>{a.trim()&&(!g&&!f||d({name:a.trim(),description:j.trim()||void 0,saveToLibrary:g,saveToCurrentDashboard:f}))},x=a.trim()&&(g||f);return e.jsx(t.Dialog,{open:s,onOpenChange:r,children:e.jsxs(t.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:"Save Visual As"}),e.jsx(t.DialogDescription,{children:m?"Create a copy of this visual with a new name":"Save this visual to make it reusable"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(t.Label,{htmlFor:"name",children:"Name"}),e.jsx(t.Input$1,{id:"name",value:a,onChange:v=>o(v.target.value),placeholder:"Enter visual name",disabled:c})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(t.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(t.Textarea,{id:"description",value:j,onChange:v=>u(v.target.value),placeholder:"Enter visual description",rows:3,disabled:c})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(t.Label,{children:"Save to:"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.Checkbox,{id:"save-to-dashboard",checked:f,onCheckedChange:v=>b(!!v),disabled:c}),e.jsxs("label",{htmlFor:"save-to-dashboard",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:["Current Dashboard",e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:m?"(add copy to this dashboard)":"(keep as local visual)"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.Checkbox,{id:"save-to-library",checked:g,onCheckedChange:v=>C(!!v),disabled:c}),e.jsxs("label",{htmlFor:"save-to-library",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:["Visual Library",e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:m?"(save as new reusable visual)":"(make available to all dashboards)"})]})]})]}),!g&&!f&&e.jsx("p",{className:"text-sm text-destructive",children:"Please select at least one destination"})]})]}),e.jsxs(t.DialogFooter,{children:[e.jsx(t.Button,{variant:"outline",onClick:()=>r(!1),disabled:c,children:"Cancel"}),e.jsxs(t.Button,{onClick:E,disabled:!x||c,children:[c&&e.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),c?"Saving...":"Save"]})]})]})})}function X(){const[s,r]=p.useState(!1),[m,n]=p.useState(!1),[c,d]=p.useState(null),a=t.useEditorStore(i=>i.frame),o=t.useEditorStore(i=>i.card),j=t.useSelectedVisual(),u=t.useDashboardStore(i=>i.selectedSheetId),g=t.useDashboardStore(i=>i.actions.setIsDashboardPanelOpen),{getUpdatedFrame:C}=T.useVisualUtils(),{selectVisual:f}=t.useManagementActions(),{addFrame:b,setSelectedFrameId:E,setIsVisualEditing:x}=t.useDashboardActions(),v=!!(a!=null&&a.visualId),S=(()=>{var i,w;return((i=a==null?void 0:a.cards)==null?void 0:i.length)===1&&((w=a.cards[0])!=null&&w.title)?a.cards[0].title:j!=null&&j.title?j.title:(o==null?void 0:o.title)||"Untitled Visual"})(),h=t.useCreateVisualWithFrame(i=>{if(i!=null&&i.id){if(f(i),m&&c&&u){const w={...c,id:t.v4(),visualId:i.id};b(u,w,"end"),E(w.id),n(!1),d(null),x(!1)}g(!0),r(!1)}});return{saveAsDialogOpen:s,setSaveAsDialogOpen:r,handleSaveAs:async i=>{if(!u){t.ue.error("No sheet selected");return}const w=C(),A=w.cards.length===1?{...w,cards:w.cards.map(D=>({...D,title:i.name}))}:w;if(i.saveToLibrary){n(i.saveToCurrentDashboard),d(A);const D={title:i.name,description:i.description,frameObject:A,isPrivate:!1};h.mutate(D)}else if(i.saveToCurrentDashboard){const D={...A,id:t.v4(),visualId:void 0};b(u,D,"end"),E(D.id),t.ue.success("Visual saved to dashboard"),r(!1),x(!1)}},isLibraryVisual:v,currentVisualName:S,isSaving:h.isPending}}function G({className:s}){const r=t.useEditorStore(h=>h.frame),m=t.useEditorStore(h=>h.card),n=t.useManagementStore(h=>h.selectedVisual),c=t.useDashboardStore(h=>h.selectedFrameId),d=t.useDashboardStore(h=>h.selectedSheetId),{setIsVisualEditing:a}=t.useDashboardActions(),o=!!(r!=null&&r.visualId||n!=null&&n.id),j=!!(r!=null&&r.visualId&&c),u=o&&!j,{saveAsDialogOpen:g,setSaveAsDialogOpen:C,handleSaveAs:f,isLibraryVisual:b,currentVisualName:E,isSaving:x}=X(),{handleAddLibraryVisual:v}=T.useVisualUtils(),S=async()=>{if(!d){t.ue.error("No dashboard sheet selected");return}if(!n){t.ue.error("No visual selected");return}const h=await v(n);h.success?(t.ue.success("Visual added to dashboard"),a(!1)):t.ue.error(h.error||"Failed to add visual to dashboard")};return e.jsxs(e.Fragment,{children:[!o&&e.jsx(N.EditorAcceptButton,{className:s,variant:"default"}),o&&e.jsxs(e.Fragment,{children:[j&&e.jsx(N.VisualApplyLocalButton,{className:s}),u&&d&&m&&(m.sql||t.hasValidCardConfig(m.config))&&e.jsxs(t.Button,{onClick:S,className:t.cn(s),size:"sm",variant:"outline",children:[e.jsx(P,{className:"mr-2 size-4 font-bold"}),"Add to Dashboard"]}),u&&e.jsx(N.VisualSaveButton,{className:s,variant:"default"}),j&&e.jsx(N.VisualSaveAndApplyButton,{className:s}),e.jsxs(t.DropdownMenu,{modal:!1,children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",size:"sm",className:t.cn(s,"w-8 p-0"),children:e.jsx(t.EllipsisVertical,{className:"h-4 w-4"})})}),e.jsx(t.DropdownMenuContent,{align:"end",children:e.jsxs(t.DropdownMenuItem,{onClick:h=>{h.stopPropagation(),C(!0)},children:[e.jsx(N.Save,{className:"mr-2 h-4 w-4"}),"Save As..."]})})]})]}),!o&&e.jsxs(t.DropdownMenu,{modal:!1,children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",size:"sm",className:t.cn(s,"w-8 p-0"),children:e.jsx(t.EllipsisVertical,{className:"h-4 w-4"})})}),e.jsx(t.DropdownMenuContent,{align:"end",children:e.jsxs(t.DropdownMenuItem,{onClick:()=>C(!0),children:[e.jsx(N.Save,{className:"mr-2 h-4 w-4"}),"Save As..."]})})]}),e.jsx(N.EditorCancelButton,{className:s}),e.jsx(H,{open:g,onOpenChange:h=>{x||C(h)},isLibraryVisual:b,currentVisualName:E,isSaving:x,onConfirm:f})]})}function W({className:s,switchClassName:r}){const m=t.useEditorStore(o=>o.isDevMode),n=t.useDashboardStore(o=>o.isVisualEditing),{setIsDevMode:c}=t.useEditorActions(),{config:d}=p.useContext(t.SemaphorContext).tokenProps,a=(d==null?void 0:d.showAdvancedMode)!==!1;return!n||!a?null:e.jsxs("div",{className:t.cn("flex items-center space-x-2",s),children:[e.jsx(t.DevModeSwitch,{className:t.cn("",r),checked:m,onCheckedChange:()=>c(!m),id:"advanced-mode",icon:e.jsx(t.CodeXml,{className:"h-4 w-4"}),tooltip:"Advanced Mode"}),e.jsx("label",{htmlFor:"advanced-mode",className:"sr-only",children:"Advanced Mode"})]})}function Q({open:s,onOpenChange:r,onSave:m,onDiscard:n,isSaving:c}){const d=a=>{!a&&c||r(a)};return e.jsx(t.AlertDialog,{open:s,onOpenChange:d,children:e.jsxs(t.AlertDialogContent,{className:"max-w-md",children:[e.jsxs(t.AlertDialogHeader,{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-amber-100",children:e.jsx(t.TriangleAlert,{className:"h-5 w-5 text-amber-600"})}),e.jsx(t.AlertDialogTitle,{className:"text-xl",children:"Unsaved Changes"})]}),e.jsx(t.AlertDialogDescription,{className:"pt-2 text-base leading-relaxed",children:"You have unsaved changes to this dashboard. What would you like to do?"})]}),e.jsxs(t.AlertDialogFooter,{className:"flex-col gap-2 sm:flex-row sm:gap-2",children:[e.jsx(t.AlertDialogCancel,{disabled:c,className:"order-1 m-0 border-border/50 sm:order-1",children:"Cancel"}),e.jsx("button",{onClick:n,disabled:c,className:"order-2 rounded-md border border-destructive/20 bg-destructive/10 px-4 py-2 text-sm font-medium text-destructive transition-colors hover:bg-destructive/20 disabled:pointer-events-none disabled:opacity-50 sm:order-2",children:"Discard"}),e.jsx(t.AlertDialogAction,{onClick:m,disabled:c,className:"order-3 m-0 bg-primary text-primary-foreground hover:bg-primary/90 sm:order-3",children:c?e.jsxs(e.Fragment,{children:[e.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save & Close"})]})]})})}function Y(s,r,m,n){p.useEffect(()=>{s&&!m&&r&&n(t.cloneDeep(r))},[s,m,r,n])}function Z({triggerButtonClassName:s,variant:r="ghost"}){const[m,n]=p.useState(!1),c=t.useDashboardStore(a=>{var o;return(o=a.dashboard)==null?void 0:o.id}),d=t.useDashboardStore(a=>{var o;return(o=a.dashboard)==null?void 0:o.title});return c?e.jsxs(e.Fragment,{children:[e.jsx(t.IconButton,{tooltip:"Schedule Dashboard",className:t.cn("h-7 p-2",s),buttonProps:{variant:r},onClick:()=>n(!0),children:e.jsx(t.Clock,{className:"size-4"})}),e.jsx(t.EmailScheduleDialog,{open:m,onOpenChange:n,dashboardId:c,dashboardName:d})]}):null}function F({export:s,onRemove:r}){const m=()=>{s.downloadUrl&&window.open(s.downloadUrl,"_blank")},n=o=>{o.stopPropagation(),r==null||r(s.id)},c=()=>{switch(s.status){case"completed":return e.jsx(t.CircleCheck,{className:"mt-0.5 h-5 w-5 shrink-0 text-green-600"});case"failed":return e.jsx(N.CircleX,{className:"mt-0.5 h-5 w-5 shrink-0 text-destructive"});default:return e.jsx(t.LoaderCircle,{className:"text-foreground-muted mt-0.5 h-5 w-5 shrink-0 animate-spin"})}},d=t.isExportInProgress(s.status),a=(()=>{switch(s.status){case"pending":return"Queued...";case"processing":return"Processing...";case"chunking":return"Processing...";case"compacting":return"Finalizing...";default:return"Processing..."}})();return e.jsxs("div",{className:"group p-4 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"mb-2 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:[c(),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"mb-1 truncate text-sm font-medium",children:s.title}),s.status==="completed"&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:[s.totalRows.toLocaleString()," rows"]}),s.fileSize&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{children:t.formatFileSize(s.fileSize)})]})]}),d&&e.jsx("div",{className:"text-xs text-muted-foreground",children:a}),s.status==="failed"&&e.jsx("div",{className:"line-clamp-2 text-xs text-destructive",children:s.error||"Export failed"})]})]}),e.jsx(t.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:n,"aria-label":"Remove notification",children:e.jsx(t.X,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"ml-8",children:[s.status==="completed"&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:I.formatDistanceToNow(s.startedAt,{addSuffix:!0})}),s.downloadUrl&&e.jsxs(t.Button,{size:"sm",variant:"outline",className:"h-8 bg-transparent",onClick:m,children:[e.jsx(t.Download,{className:"mr-1.5 h-3.5 w-3.5"}),"Download"]})]}),d&&e.jsxs("div",{children:[e.jsx(t.Progress,{value:s.progress,className:"h-1.5"}),e.jsxs("span",{className:"mt-1 block text-xs text-muted-foreground",children:[s.progress,"% complete"]})]}),s.status==="failed"&&e.jsx("span",{className:"text-xs text-muted-foreground",children:I.formatDistanceToNow(s.startedAt,{addSuffix:!0})})]})]})}function M(){const{authToken:s,tokenProps:r}=t.useSemaphorContext(),m=t.useExportStore(x=>x.activeExports),{clearCompleted:n,removeExport:c,updateExport:d}=t.useExportActions(),[a,o]=p.useState(!1),[j,u]=p.useState(!1),g=Array.from(m.values()).sort((x,v)=>v.startedAt.getTime()-x.startedAt.getTime()),C=g.some(x=>x.status==="completed"||x.status==="failed"),f=p.useCallback(async()=>{const x=r==null?void 0:r.apiServiceUrl,v=s==null?void 0:s.accessToken;if(!(!x||!v)){o(!0);try{const S=Array.from(m.values());await Promise.all(S.map(async h=>{try{const l=await t.getExportStatus(x,v,h.id);let i;if(l.status==="completed")try{i=await t.getDownloadUrl(x,v,h.id)}catch(w){console.error(`Failed to get download URL for ${h.id}:`,w)}d(h.id,{status:l.status,progress:l.progress,completedChunks:l.completedChunks,completedAt:l.completedAt?new Date(l.completedAt):void 0,lastUpdatedAt:new Date,fileSize:l.fileSize,error:l.error,downloadUrl:i})}catch(l){console.error(`Failed to refresh export ${h.id}:`,l)}}))}finally{o(!1)}}},[m,s==null?void 0:s.accessToken,r==null?void 0:r.apiServiceUrl,d]),b=p.useCallback(async()=>{const x=r==null?void 0:r.apiServiceUrl,v=s==null?void 0:s.accessToken;if(!x||!v){n();return}u(!0);try{const S=g.filter(l=>l.status==="completed"||l.status==="failed"),h=await Promise.allSettled(S.map(async l=>(await t.cancelExport(x,v,l.id),l.id)));for(const l of h)l.status==="fulfilled"?c(l.value):console.error("Failed to delete export:",l.reason)}finally{u(!1)}},[g,r==null?void 0:r.apiServiceUrl,s==null?void 0:s.accessToken,n,c]),E=p.useCallback(async x=>{const v=r==null?void 0:r.apiServiceUrl,S=s==null?void 0:s.accessToken;if(v&&S)try{await t.cancelExport(v,S,x),c(x);return}catch(h){console.error(`Failed to cancel export ${x}:`,h)}c(x)},[r==null?void 0:r.apiServiceUrl,s==null?void 0:s.accessToken,c]);return g.length===0?e.jsxs("div",{className:"p-6 text-center",children:[e.jsx(k,{className:"mx-auto mb-2 h-8 w-8 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No active exports"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Large exports will appear here"})]}):e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h4",{className:"font-semibold",children:"Exports"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:f,disabled:a,title:"Refresh status",children:e.jsx(t.RefreshCw,{className:`h-4 w-4 ${a?"animate-spin":""}`})}),C&&e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-7 px-2 text-sm",onClick:b,disabled:j,children:j?"Clearing...":"Clear all"})]})]}),e.jsx("div",{className:"max-h-[350px] overflow-y-auto",children:e.jsx("div",{className:"divide-y",children:g.map(x=>e.jsx(F,{export:x,onRemove:E},x.id))})})]})}function J(){const s=t.useExportStore(o=>o.activeExports),r=t.useInProgressExportsCount(),m=s.size>0,n=Array.from(s.values()).some(o=>o.status==="completed"||o.status==="failed"),d=r>0?r>9?"9+":String(r):null,a=m;return e.jsxs(t.Popover,{children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsxs(t.Button,{variant:"ghost",size:"icon",className:"relative h-8 w-8","aria-label":"Export notifications",children:[e.jsx(t.Bell,{className:"h-4 w-4"}),a&&e.jsx("span",{className:`absolute flex items-center justify-center rounded-full bg-primary text-primary-foreground ${d?"-right-0.5 -top-0.5 h-4 min-w-4 px-0.5 text-[10px] font-semibold":"right-0.5 top-0.5 h-2 w-2"}`,children:d})]})}),e.jsx(t.PopoverContent,{className:"w-80 p-0",align:"end",sideOffset:8,children:e.jsx(M,{})})]})}exports.AdvancedModeToggle=W;exports.ExportNotificationItem=F;exports.ExportNotificationList=M;exports.NotificationBell=J;exports.ScheduleDashboard=Z;exports.UnsavedChangesAlert=Q;exports.VisualEditingControls=G;exports.useExportPolling=$;exports.useExportRecovery=q;exports.usePristineSnapshotInitializer=Y;
|