react-semaphor 0.1.179 → 0.1.180

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 (30) hide show
  1. package/dist/chunks/{dashboard-controls-CeT5saB7.js → dashboard-controls-Baw7eUyM.js} +3 -3
  2. package/dist/chunks/{dashboard-controls-O2Vl2SaH.js → dashboard-controls-CS3pAVZi.js} +339 -337
  3. package/dist/chunks/{dashboard-json--jGkpREU.js → dashboard-json-ClalWYi4.js} +1 -1
  4. package/dist/chunks/{dashboard-json-d1qZ8OYo.js → dashboard-json-Cz4bNnCC.js} +1 -1
  5. package/dist/chunks/{edit-dashboard-visual-ViDNkE8Q.js → edit-dashboard-visual-BMElXt-n.js} +30 -35
  6. package/dist/chunks/{edit-dashboard-visual-BsP87bZV.js → edit-dashboard-visual-DFJ5FJ7y.js} +11 -22
  7. package/dist/chunks/editor-action-buttons-DVWnnC_r.js +11 -0
  8. package/dist/chunks/{editor-action-buttons-F4_UU-Mk.js → editor-action-buttons-MtNYw1Bb.js} +57 -45
  9. package/dist/chunks/{index-v6ayK5K2.js → index-CAeKp6K8.js} +22589 -22037
  10. package/dist/chunks/{index-CFWw2cJ5.js → index-CfPKTeUk.js} +232 -227
  11. package/dist/chunks/notification-bell-2dZI5OV0.js +21 -0
  12. package/dist/chunks/notification-bell-YZ8VqdwA.js +870 -0
  13. package/dist/chunks/{resource-management-panel-Cn1aOr6L.js → resource-management-panel-Buhi-kvP.js} +1 -1
  14. package/dist/chunks/{resource-management-panel-CApVr9Vd.js → resource-management-panel-pxL28GXq.js} +133 -133
  15. package/dist/chunks/{use-role-aware-display-preferences-C-N0-Iik.js → use-role-aware-display-preferences-B_i2f9tn.js} +1 -1
  16. package/dist/chunks/{use-role-aware-display-preferences-Bxp6i8c7.js → use-role-aware-display-preferences-JljRcjrP.js} +1 -1
  17. package/dist/chunks/{use-visual-utils-D9lMGeVv.js → use-visual-utils-D3HjbsKO.js} +38 -38
  18. package/dist/chunks/{use-visual-utils-D19qzwzI.js → use-visual-utils-DPEHcmFT.js} +1 -1
  19. package/dist/dashboard/index.cjs +1 -1
  20. package/dist/dashboard/index.js +1 -1
  21. package/dist/index.cjs +1 -6
  22. package/dist/index.js +133 -126
  23. package/dist/style.css +1 -1
  24. package/dist/surfboard/index.cjs +1 -1
  25. package/dist/surfboard/index.js +1 -1
  26. package/dist/types/main.d.ts +262 -0
  27. package/package.json +1 -1
  28. package/dist/chunks/editor-action-buttons-DseT424l.js +0 -6
  29. package/dist/chunks/schedule-dashboard-B4KUKLfW.js +0 -416
  30. package/dist/chunks/schedule-dashboard-vvFw8B1E.js +0 -6
@@ -0,0 +1,870 @@
1
+ import oe, { useState as A, useRef as V, useCallback as M, useEffect as D, useContext as ie } from "react";
2
+ import { aF as z, aN as B, a0 as I, aC as $, ay as ae, az as _, a1 as se, ax as le, bu as ce, bv as de, bw as ue, bx as me, by as he, bz as O, bA as pe, bG as fe, bH as j, bB as ge, B as S, aG as H, au as P, aI as ve, u as E, aO as xe, as as re, bI as be, bJ as G, aL as T, A as we, bK as Ce, c as U, aV as X, aW as q, aX as W, aY as Q, aZ as Y, av as Ne, bL as ye, bM as Ae, bN as Se, bb as Ee, bc as De, bd as Ie, bO as ke, be as Te, bf as Ue, bg as Fe, bh as Me, bi as Pe, W as Le, I as Ve, bP as ze, bQ as Re, aE as Oe, X as Be, bR as $e, bS as _e, aA as Z, a3 as He, P as je, p as Ge, bT as Xe, r as qe } from "./index-CAeKp6K8.js";
3
+ import { jsx as t, jsxs as r, Fragment as L } from "react/jsx-runtime";
4
+ import { E as We, V as Qe, a as Ye, b as Ze, S as J, c as Je, C as Ke } from "./editor-action-buttons-MtNYw1Bb.js";
5
+ import { a as ne } from "./use-visual-utils-D3HjbsKO.js";
6
+ import { a as K } from "./index-B4EhQdS9.js";
7
+ /**
8
+ * @license lucide-react v0.453.0 - ISC
9
+ *
10
+ * This source code is licensed under the ISC license.
11
+ * See the LICENSE file in the root directory of this source tree.
12
+ */
13
+ const et = z("CircleCheck", [
14
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
15
+ ["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
16
+ ]);
17
+ /**
18
+ * @license lucide-react v0.453.0 - ISC
19
+ *
20
+ * This source code is licensed under the ISC license.
21
+ * See the LICENSE file in the root directory of this source tree.
22
+ */
23
+ const tt = z("CirclePlus", [
24
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
25
+ ["path", { d: "M8 12h8", key: "1wcyev" }],
26
+ ["path", { d: "M12 8v8", key: "napkw2" }]
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 ee = z("FileDown", [
35
+ ["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z", key: "1rqfz7" }],
36
+ ["path", { d: "M14 2v4a2 2 0 0 0 2 2h4", key: "tnqrlb" }],
37
+ ["path", { d: "M12 18v-6", key: "17g6i2" }],
38
+ ["path", { d: "m9 15 3 3 3-3", key: "1npd3o" }]
39
+ ]);
40
+ /**
41
+ * @license lucide-react v0.453.0 - ISC
42
+ *
43
+ * This source code is licensed under the ISC license.
44
+ * See the LICENSE file in the root directory of this source tree.
45
+ */
46
+ const at = z("RefreshCw", [
47
+ ["path", { d: "M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8", key: "v9h5vc" }],
48
+ ["path", { d: "M21 3v5h-5", key: "1q7to0" }],
49
+ ["path", { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16", key: "3uifl3" }],
50
+ ["path", { d: "M8 16H3v5", key: "1cv678" }]
51
+ ]), st = 1e4, rt = 15e3, nt = 3e4, ot = 3e4, it = 12e4, te = 2 * 60 * 60 * 1e3;
52
+ function lt(e) {
53
+ const a = Date.now() - e.getTime();
54
+ return a < ot ? st : a < it ? rt : nt;
55
+ }
56
+ function wt() {
57
+ const { authToken: e, tokenProps: a } = B(), c = I((v) => v.activeExports), [n, m] = A(
58
+ typeof document < "u" ? !document.hidden : !0
59
+ ), l = V(null), o = V(!1), s = V(void 0), h = a == null ? void 0 : a.apiServiceUrl, d = e == null ? void 0 : e.accessToken, g = M(() => {
60
+ const v = I.getState().activeExports;
61
+ return Array.from(v.values()).filter(
62
+ (b) => $(b.status)
63
+ );
64
+ }, []);
65
+ D(() => {
66
+ if (typeof document > "u") return;
67
+ const v = () => {
68
+ m(!document.hidden);
69
+ };
70
+ return document.addEventListener("visibilitychange", v), () => {
71
+ document.removeEventListener("visibilitychange", v);
72
+ };
73
+ }, []);
74
+ const C = M(async () => {
75
+ if (!h || !d) {
76
+ o.current = !1;
77
+ return;
78
+ }
79
+ const v = g();
80
+ if (v.length === 0) {
81
+ o.current = !1;
82
+ return;
83
+ }
84
+ const b = Date.now(), y = v.filter(
85
+ (p) => b - p.startedAt.getTime() > te
86
+ );
87
+ if (y.length > 0) {
88
+ const { updateExport: p } = I.getState().actions;
89
+ for (const i of y)
90
+ p(i.id, {
91
+ status: "failed",
92
+ error: "Export timed out. Please try again or contact support.",
93
+ lastUpdatedAt: /* @__PURE__ */ new Date()
94
+ });
95
+ }
96
+ const f = v.filter(
97
+ (p) => b - p.startedAt.getTime() <= te
98
+ );
99
+ if (f.length === 0) {
100
+ o.current = !1;
101
+ return;
102
+ }
103
+ const x = await Promise.allSettled(
104
+ f.map(async (p) => {
105
+ try {
106
+ const i = await ae(h, d, p.id);
107
+ let w;
108
+ if (i.status === "completed")
109
+ try {
110
+ w = await _(h, d, p.id);
111
+ } catch (F) {
112
+ console.error(
113
+ `[useExportPolling] Failed to get download URL for ${p.id}:`,
114
+ F
115
+ );
116
+ }
117
+ return {
118
+ id: p.id,
119
+ status: i.status,
120
+ progress: i.progress,
121
+ completedChunks: i.completedChunks,
122
+ completedAt: i.completedAt ? new Date(i.completedAt) : void 0,
123
+ lastUpdatedAt: /* @__PURE__ */ new Date(),
124
+ fileSize: i.fileSize,
125
+ error: i.error,
126
+ downloadUrl: w
127
+ };
128
+ } catch (i) {
129
+ return console.error(
130
+ `[useExportPolling] Failed to poll export ${p.id}:`,
131
+ i
132
+ ), null;
133
+ }
134
+ })
135
+ ), { updateExport: N } = I.getState().actions;
136
+ for (const p of x)
137
+ p.status === "fulfilled" && p.value && N(p.value.id, p.value);
138
+ const u = g();
139
+ if (u.length > 0 && !document.hidden) {
140
+ const p = u.reduce(
141
+ (w, F) => F.startedAt < w ? F.startedAt : w,
142
+ u[0].startedAt
143
+ ), i = lt(p);
144
+ l.current && clearTimeout(l.current), l.current = setTimeout(() => {
145
+ var w;
146
+ (w = s.current) == null || w.call(s);
147
+ }, i);
148
+ } else
149
+ o.current = !1;
150
+ }, [h, d, g]);
151
+ return D(() => {
152
+ s.current = C;
153
+ }, [C]), D(() => {
154
+ var b;
155
+ g().length > 0 && n && !o.current && (o.current = !0, (b = s.current) == null || b.call(s));
156
+ }, [c, n, g]), D(() => {
157
+ var b;
158
+ const v = g();
159
+ n && v.length > 0 && !o.current && (o.current = !0, (b = s.current) == null || b.call(s));
160
+ }, [n, g]), D(() => {
161
+ !n && l.current && (clearTimeout(l.current), l.current = null, o.current = !1);
162
+ }, [n]), D(() => () => {
163
+ l.current && (clearTimeout(l.current), l.current = null);
164
+ }, []), {
165
+ isPolling: o.current,
166
+ isTabVisible: n,
167
+ inProgressCount: g().length
168
+ };
169
+ }
170
+ function Ct() {
171
+ const { authToken: e, tokenProps: a } = B(), c = I((s) => s.activeExports), { addExport: n } = se(), m = V(!1), l = a == null ? void 0 : a.apiServiceUrl, o = e == null ? void 0 : e.accessToken;
172
+ D(() => {
173
+ if (m.current || !l || !o) return;
174
+ (async () => {
175
+ try {
176
+ const { exports: h } = await le(l, o, {
177
+ status: ["pending", "processing", "chunking", "compacting", "completed", "failed"],
178
+ limit: 20
179
+ // Limit to recent exports
180
+ });
181
+ for (const d of h) {
182
+ if (c.has(d.id)) continue;
183
+ const g = d.totalChunks ? Math.round(d.completedChunks / d.totalChunks * 100) : 0;
184
+ let C;
185
+ if (d.status === "completed")
186
+ try {
187
+ C = await _(l, o, d.id);
188
+ } catch (b) {
189
+ console.error(
190
+ `[useExportRecovery] Failed to get download URL for ${d.id}:`,
191
+ b
192
+ );
193
+ }
194
+ const v = {
195
+ id: d.id,
196
+ status: d.status,
197
+ progress: g,
198
+ title: ct(d),
199
+ totalRows: d.totalRows,
200
+ totalChunks: d.totalChunks,
201
+ completedChunks: d.completedChunks,
202
+ startedAt: new Date(d.createdAt),
203
+ lastUpdatedAt: /* @__PURE__ */ new Date(),
204
+ completedAt: d.completedAt ? new Date(d.completedAt) : void 0,
205
+ fileSize: d.fileSize,
206
+ error: d.error,
207
+ expiresAt: new Date(d.expiresAt),
208
+ downloadUrl: C
209
+ };
210
+ n(v);
211
+ }
212
+ m.current = !0;
213
+ } catch (h) {
214
+ console.error("[useExportRecovery] Failed to recover exports:", h), m.current = !0;
215
+ }
216
+ })();
217
+ }, [l, o, n, c]);
218
+ }
219
+ function ct(e) {
220
+ return e.title ? e.title : $(
221
+ e.status
222
+ ) ? "Export in progress..." : e.status === "completed" ? "Export completed" : e.status === "failed" ? "Export failed" : "Export";
223
+ }
224
+ function dt({
225
+ open: e,
226
+ onOpenChange: a,
227
+ isLibraryVisual: c,
228
+ currentVisualName: n,
229
+ isSaving: m = !1,
230
+ onConfirm: l
231
+ }) {
232
+ const [o, s] = A(
233
+ c && n ? `Copy of ${n}` : n || ""
234
+ ), [h, d] = A(""), [g, C] = A(!c), [v, b] = A(!0);
235
+ oe.useEffect(() => {
236
+ e && (s(
237
+ c && n ? `Copy of ${n}` : n || ""
238
+ ), d(""), C(!c), b(!0));
239
+ }, [e, c, n]);
240
+ const y = () => {
241
+ o.trim() && (!g && !v || l({
242
+ name: o.trim(),
243
+ description: h.trim() || void 0,
244
+ saveToLibrary: g,
245
+ saveToCurrentDashboard: v
246
+ }));
247
+ }, f = o.trim() && (g || v);
248
+ return /* @__PURE__ */ t(ce, { open: e, onOpenChange: a, children: /* @__PURE__ */ r(de, { className: "sm:max-w-[425px]", children: [
249
+ /* @__PURE__ */ r(ue, { children: [
250
+ /* @__PURE__ */ t(me, { children: "Save Visual As" }),
251
+ /* @__PURE__ */ t(he, { children: c ? "Create a copy of this visual with a new name" : "Save this visual to make it reusable" })
252
+ ] }),
253
+ /* @__PURE__ */ r("div", { className: "grid gap-4 py-4", children: [
254
+ /* @__PURE__ */ r("div", { className: "grid gap-2", children: [
255
+ /* @__PURE__ */ t(O, { htmlFor: "name", children: "Name" }),
256
+ /* @__PURE__ */ t(
257
+ pe,
258
+ {
259
+ id: "name",
260
+ value: o,
261
+ onChange: (x) => s(x.target.value),
262
+ placeholder: "Enter visual name",
263
+ disabled: m
264
+ }
265
+ )
266
+ ] }),
267
+ /* @__PURE__ */ r("div", { className: "grid gap-2", children: [
268
+ /* @__PURE__ */ t(O, { htmlFor: "description", children: "Description (optional)" }),
269
+ /* @__PURE__ */ t(
270
+ fe,
271
+ {
272
+ id: "description",
273
+ value: h,
274
+ onChange: (x) => d(x.target.value),
275
+ placeholder: "Enter visual description",
276
+ rows: 3,
277
+ disabled: m
278
+ }
279
+ )
280
+ ] }),
281
+ /* @__PURE__ */ r("div", { className: "space-y-4", children: [
282
+ /* @__PURE__ */ t(O, { children: "Save to:" }),
283
+ /* @__PURE__ */ r("div", { className: "space-y-2", children: [
284
+ /* @__PURE__ */ r("div", { className: "flex items-center space-x-2", children: [
285
+ /* @__PURE__ */ t(
286
+ j,
287
+ {
288
+ id: "save-to-dashboard",
289
+ checked: v,
290
+ onCheckedChange: (x) => b(!!x),
291
+ disabled: m
292
+ }
293
+ ),
294
+ /* @__PURE__ */ r(
295
+ "label",
296
+ {
297
+ htmlFor: "save-to-dashboard",
298
+ className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
299
+ children: [
300
+ "Current Dashboard",
301
+ /* @__PURE__ */ t("span", { className: "ml-2 text-xs text-muted-foreground", children: c ? "(add copy to this dashboard)" : "(keep as local visual)" })
302
+ ]
303
+ }
304
+ )
305
+ ] }),
306
+ /* @__PURE__ */ r("div", { className: "flex items-center space-x-2", children: [
307
+ /* @__PURE__ */ t(
308
+ j,
309
+ {
310
+ id: "save-to-library",
311
+ checked: g,
312
+ onCheckedChange: (x) => C(!!x),
313
+ disabled: m
314
+ }
315
+ ),
316
+ /* @__PURE__ */ r(
317
+ "label",
318
+ {
319
+ htmlFor: "save-to-library",
320
+ className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
321
+ children: [
322
+ "Visual Library",
323
+ /* @__PURE__ */ t("span", { className: "ml-2 text-xs text-muted-foreground", children: c ? "(save as new reusable visual)" : "(make available to all dashboards)" })
324
+ ]
325
+ }
326
+ )
327
+ ] })
328
+ ] }),
329
+ !g && !v && /* @__PURE__ */ t("p", { className: "text-sm text-destructive", children: "Please select at least one destination" })
330
+ ] })
331
+ ] }),
332
+ /* @__PURE__ */ r(ge, { children: [
333
+ /* @__PURE__ */ t(
334
+ S,
335
+ {
336
+ variant: "outline",
337
+ onClick: () => a(!1),
338
+ disabled: m,
339
+ children: "Cancel"
340
+ }
341
+ ),
342
+ /* @__PURE__ */ r(S, { onClick: y, disabled: !f || m, children: [
343
+ m && /* @__PURE__ */ t(H, { className: "mr-2 h-4 w-4 animate-spin" }),
344
+ m ? "Saving..." : "Save"
345
+ ] })
346
+ ] })
347
+ ] }) });
348
+ }
349
+ function ut() {
350
+ const [e, a] = A(!1), [c, n] = A(!1), [m, l] = A(null), o = P((i) => i.frame), s = P((i) => i.card), h = ve(), d = E((i) => i.selectedSheetId), g = E(
351
+ (i) => i.actions.setIsDashboardPanelOpen
352
+ ), { getUpdatedFrame: C } = ne(), { selectVisual: v } = xe(), { addFrame: b, setSelectedFrameId: y, setIsVisualEditing: f } = re(), x = !!(o != null && o.visualId), N = (() => {
353
+ var i, w;
354
+ return ((i = o == null ? void 0 : o.cards) == null ? void 0 : i.length) === 1 && ((w = o.cards[0]) != null && w.title) ? o.cards[0].title : h != null && h.title ? h.title : (s == null ? void 0 : s.title) || "Untitled Visual";
355
+ })(), u = be((i) => {
356
+ if (i != null && i.id) {
357
+ if (v(i), c && m && d) {
358
+ const w = {
359
+ ...m,
360
+ id: G(),
361
+ visualId: i.id
362
+ // Link to the newly created library visual
363
+ };
364
+ b(d, w, "end"), y(w.id), n(!1), l(null), f(!1);
365
+ }
366
+ g(!0), a(!1);
367
+ }
368
+ });
369
+ return {
370
+ saveAsDialogOpen: e,
371
+ setSaveAsDialogOpen: a,
372
+ handleSaveAs: async (i) => {
373
+ if (!d) {
374
+ T.error("No sheet selected");
375
+ return;
376
+ }
377
+ const w = C(), R = w.cards.length === 1 ? {
378
+ ...w,
379
+ cards: w.cards.map((k) => ({
380
+ ...k,
381
+ title: i.name
382
+ // Use visual name as card title
383
+ }))
384
+ } : w;
385
+ if (i.saveToLibrary) {
386
+ n(i.saveToCurrentDashboard), l(R);
387
+ const k = {
388
+ title: i.name,
389
+ description: i.description,
390
+ frameObject: R,
391
+ // Card title synced for single-card frames
392
+ isPrivate: !1
393
+ };
394
+ u.mutate(k);
395
+ } else if (i.saveToCurrentDashboard) {
396
+ const k = {
397
+ ...R,
398
+ // Card title already synced
399
+ id: G(),
400
+ visualId: void 0
401
+ // Explicitly no visualId for local visuals
402
+ };
403
+ b(d, k, "end"), y(k.id), T.success("Visual saved to dashboard"), a(!1), f(!1);
404
+ }
405
+ },
406
+ isLibraryVisual: x,
407
+ currentVisualName: N,
408
+ isSaving: u.isPending
409
+ };
410
+ }
411
+ function Nt({
412
+ className: e
413
+ }) {
414
+ const a = P((u) => u.frame), c = P((u) => u.card), n = we((u) => u.selectedVisual), m = E((u) => u.selectedFrameId), l = E((u) => u.selectedSheetId), { setIsVisualEditing: o } = re(), s = !!(a != null && a.visualId || n != null && n.id), h = !!(a != null && a.visualId && m), d = s && !h, {
415
+ saveAsDialogOpen: g,
416
+ setSaveAsDialogOpen: C,
417
+ handleSaveAs: v,
418
+ isLibraryVisual: b,
419
+ currentVisualName: y,
420
+ isSaving: f
421
+ } = ut(), { handleAddLibraryVisual: x } = ne(), N = async () => {
422
+ if (!l) {
423
+ T.error("No dashboard sheet selected");
424
+ return;
425
+ }
426
+ if (!n) {
427
+ T.error("No visual selected");
428
+ return;
429
+ }
430
+ const u = await x(n);
431
+ u.success ? (T.success("Visual added to dashboard"), o(!1)) : T.error(u.error || "Failed to add visual to dashboard");
432
+ };
433
+ return /* @__PURE__ */ r(L, { children: [
434
+ !s && /* @__PURE__ */ t(We, { className: e, variant: "default" }),
435
+ s && /* @__PURE__ */ r(L, { children: [
436
+ h && /* @__PURE__ */ t(Qe, { className: e }),
437
+ d && l && c && (c.sql || Ce(c.config)) && /* @__PURE__ */ r(
438
+ S,
439
+ {
440
+ onClick: N,
441
+ className: U(e),
442
+ size: "sm",
443
+ variant: "outline",
444
+ children: [
445
+ /* @__PURE__ */ t(tt, { className: "mr-2 size-4 font-bold" }),
446
+ "Add to Dashboard"
447
+ ]
448
+ }
449
+ ),
450
+ d && /* @__PURE__ */ t(Ye, { className: e, variant: "default" }),
451
+ h && /* @__PURE__ */ t(Ze, { className: e }),
452
+ /* @__PURE__ */ r(X, { modal: !1, children: [
453
+ /* @__PURE__ */ t(q, { asChild: !0, children: /* @__PURE__ */ t(
454
+ S,
455
+ {
456
+ variant: "outline",
457
+ size: "sm",
458
+ className: U(e, "w-8 p-0"),
459
+ children: /* @__PURE__ */ t(W, { className: "h-4 w-4" })
460
+ }
461
+ ) }),
462
+ /* @__PURE__ */ t(Q, { align: "end", children: /* @__PURE__ */ r(
463
+ Y,
464
+ {
465
+ onClick: (u) => {
466
+ u.stopPropagation(), C(!0);
467
+ },
468
+ children: [
469
+ /* @__PURE__ */ t(J, { className: "mr-2 h-4 w-4" }),
470
+ "Save As..."
471
+ ]
472
+ }
473
+ ) })
474
+ ] })
475
+ ] }),
476
+ !s && /* @__PURE__ */ r(X, { modal: !1, children: [
477
+ /* @__PURE__ */ t(q, { asChild: !0, children: /* @__PURE__ */ t(
478
+ S,
479
+ {
480
+ variant: "outline",
481
+ size: "sm",
482
+ className: U(e, "w-8 p-0"),
483
+ children: /* @__PURE__ */ t(W, { className: "h-4 w-4" })
484
+ }
485
+ ) }),
486
+ /* @__PURE__ */ t(Q, { align: "end", children: /* @__PURE__ */ r(Y, { onClick: () => C(!0), children: [
487
+ /* @__PURE__ */ t(J, { className: "mr-2 h-4 w-4" }),
488
+ "Save As..."
489
+ ] }) })
490
+ ] }),
491
+ /* @__PURE__ */ t(Je, { className: e }),
492
+ /* @__PURE__ */ t(
493
+ dt,
494
+ {
495
+ open: g,
496
+ onOpenChange: (u) => {
497
+ f || C(u);
498
+ },
499
+ isLibraryVisual: b,
500
+ currentVisualName: y,
501
+ isSaving: f,
502
+ onConfirm: v
503
+ }
504
+ )
505
+ ] });
506
+ }
507
+ function yt({
508
+ className: e,
509
+ //labelClassName,
510
+ switchClassName: a
511
+ }) {
512
+ const c = P((s) => s.isDevMode), n = E((s) => s.isVisualEditing), { setIsDevMode: m } = Ne(), { config: l } = ie(ye).tokenProps, o = (l == null ? void 0 : l.showAdvancedMode) !== !1;
513
+ return !n || !o ? null : /* @__PURE__ */ r("div", { className: U("flex items-center space-x-2", e), children: [
514
+ /* @__PURE__ */ t(
515
+ Ae,
516
+ {
517
+ className: U("", a),
518
+ checked: c,
519
+ onCheckedChange: () => m(!c),
520
+ id: "advanced-mode",
521
+ icon: /* @__PURE__ */ t(Se, { className: "h-4 w-4" }),
522
+ tooltip: "Advanced Mode"
523
+ }
524
+ ),
525
+ /* @__PURE__ */ t("label", { htmlFor: "advanced-mode", className: "sr-only", children: "Advanced Mode" })
526
+ ] });
527
+ }
528
+ function At({
529
+ open: e,
530
+ onOpenChange: a,
531
+ onSave: c,
532
+ onDiscard: n,
533
+ isSaving: m
534
+ }) {
535
+ return /* @__PURE__ */ t(Ee, { open: e, onOpenChange: (o) => {
536
+ !o && m || a(o);
537
+ }, children: /* @__PURE__ */ r(De, { className: "max-w-md", children: [
538
+ /* @__PURE__ */ r(Ie, { children: [
539
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
540
+ /* @__PURE__ */ t("div", { className: "flex h-10 w-10 items-center justify-center rounded-full bg-amber-100", children: /* @__PURE__ */ t(ke, { className: "h-5 w-5 text-amber-600" }) }),
541
+ /* @__PURE__ */ t(Te, { className: "text-xl", children: "Unsaved Changes" })
542
+ ] }),
543
+ /* @__PURE__ */ t(Ue, { className: "pt-2 text-base leading-relaxed", children: "You have unsaved changes to this dashboard. What would you like to do?" })
544
+ ] }),
545
+ /* @__PURE__ */ r(Fe, { className: "flex-col gap-2 sm:flex-row sm:gap-2", children: [
546
+ /* @__PURE__ */ t(
547
+ Me,
548
+ {
549
+ disabled: m,
550
+ className: "order-1 m-0 border-border/50 sm:order-1",
551
+ children: "Cancel"
552
+ }
553
+ ),
554
+ /* @__PURE__ */ t(
555
+ "button",
556
+ {
557
+ onClick: n,
558
+ disabled: m,
559
+ 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",
560
+ children: "Discard"
561
+ }
562
+ ),
563
+ /* @__PURE__ */ t(
564
+ Pe,
565
+ {
566
+ onClick: c,
567
+ disabled: m,
568
+ className: "order-3 m-0 bg-primary text-primary-foreground hover:bg-primary/90 sm:order-3",
569
+ children: m ? /* @__PURE__ */ r(L, { children: [
570
+ /* @__PURE__ */ t(H, { className: "mr-2 h-4 w-4 animate-spin" }),
571
+ "Saving..."
572
+ ] }) : "Save & Close"
573
+ }
574
+ )
575
+ ] })
576
+ ] }) });
577
+ }
578
+ function St(e, a, c, n) {
579
+ D(() => {
580
+ e && !c && a && n(Le(a));
581
+ }, [e, c, a, n]);
582
+ }
583
+ function Et({
584
+ triggerButtonClassName: e
585
+ }) {
586
+ const [a, c] = A(!1), n = E((s) => {
587
+ var h;
588
+ return (h = s.dashboard) == null ? void 0 : h.id;
589
+ }), m = E((s) => {
590
+ var h;
591
+ return (h = s.dashboard) == null ? void 0 : h.title;
592
+ }), l = E((s) => {
593
+ var h;
594
+ return (h = s.dashboard) == null ? void 0 : h.sheets;
595
+ }), o = E((s) => s.selectedSheetId);
596
+ return l == null || l.find((s) => s.id === o), n ? /* @__PURE__ */ r(L, { children: [
597
+ /* @__PURE__ */ t(
598
+ Ve,
599
+ {
600
+ tooltip: "Schedule Dashboard",
601
+ className: U("h-7 p-2", e),
602
+ onClick: () => c(!0),
603
+ children: /* @__PURE__ */ t(ze, { className: "size-4" })
604
+ }
605
+ ),
606
+ /* @__PURE__ */ t(
607
+ Re,
608
+ {
609
+ open: a,
610
+ onOpenChange: c,
611
+ dashboardId: n,
612
+ dashboardName: m
613
+ }
614
+ )
615
+ ] }) : null;
616
+ }
617
+ function mt({
618
+ export: e,
619
+ onRemove: a
620
+ }) {
621
+ const c = () => {
622
+ e.downloadUrl && window.open(e.downloadUrl, "_blank");
623
+ }, n = (s) => {
624
+ s.stopPropagation(), a == null || a(e.id);
625
+ }, m = () => {
626
+ switch (e.status) {
627
+ case "completed":
628
+ return /* @__PURE__ */ t(et, { className: "mt-0.5 h-5 w-5 shrink-0 text-green-600" });
629
+ case "failed":
630
+ return /* @__PURE__ */ t(Ke, { className: "mt-0.5 h-5 w-5 shrink-0 text-destructive" });
631
+ default:
632
+ return /* @__PURE__ */ t(H, { className: "text-foreground-muted mt-0.5 h-5 w-5 shrink-0 animate-spin" });
633
+ }
634
+ }, l = $(e.status), o = (() => {
635
+ switch (e.status) {
636
+ case "pending":
637
+ return "Queued...";
638
+ case "processing":
639
+ return "Processing...";
640
+ case "chunking":
641
+ return "Processing...";
642
+ case "compacting":
643
+ return "Finalizing...";
644
+ default:
645
+ return "Processing...";
646
+ }
647
+ })();
648
+ return /* @__PURE__ */ r("div", { className: "group p-4 transition-colors hover:bg-muted/50", children: [
649
+ /* @__PURE__ */ r("div", { className: "mb-2 flex items-start justify-between gap-3", children: [
650
+ /* @__PURE__ */ r("div", { className: "flex min-w-0 flex-1 items-start gap-3", children: [
651
+ m(),
652
+ /* @__PURE__ */ r("div", { className: "min-w-0 flex-1", children: [
653
+ /* @__PURE__ */ t("h4", { className: "mb-1 truncate text-sm font-medium", children: e.title }),
654
+ e.status === "completed" && /* @__PURE__ */ r("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
655
+ /* @__PURE__ */ r("span", { children: [
656
+ e.totalRows.toLocaleString(),
657
+ " rows"
658
+ ] }),
659
+ e.fileSize && /* @__PURE__ */ r(L, { children: [
660
+ /* @__PURE__ */ t("span", { children: "•" }),
661
+ /* @__PURE__ */ t("span", { children: Oe(e.fileSize) })
662
+ ] })
663
+ ] }),
664
+ l && /* @__PURE__ */ t("div", { className: "text-xs text-muted-foreground", children: o }),
665
+ e.status === "failed" && /* @__PURE__ */ t("div", { className: "line-clamp-2 text-xs text-destructive", children: e.error || "Export failed" })
666
+ ] })
667
+ ] }),
668
+ /* @__PURE__ */ t(
669
+ S,
670
+ {
671
+ variant: "ghost",
672
+ size: "icon",
673
+ className: "h-6 w-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",
674
+ onClick: n,
675
+ "aria-label": "Remove notification",
676
+ children: /* @__PURE__ */ t(Be, { className: "h-4 w-4" })
677
+ }
678
+ )
679
+ ] }),
680
+ /* @__PURE__ */ r("div", { className: "ml-8", children: [
681
+ e.status === "completed" && /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
682
+ /* @__PURE__ */ t("span", { className: "text-xs text-muted-foreground", children: K(e.startedAt, { addSuffix: !0 }) }),
683
+ e.downloadUrl && /* @__PURE__ */ r(
684
+ S,
685
+ {
686
+ size: "sm",
687
+ variant: "outline",
688
+ className: "h-8 bg-transparent",
689
+ onClick: c,
690
+ children: [
691
+ /* @__PURE__ */ t($e, { className: "mr-1.5 h-3.5 w-3.5" }),
692
+ "Download"
693
+ ]
694
+ }
695
+ )
696
+ ] }),
697
+ l && /* @__PURE__ */ r("div", { children: [
698
+ /* @__PURE__ */ t(_e, { value: e.progress, className: "h-1.5" }),
699
+ /* @__PURE__ */ r("span", { className: "mt-1 block text-xs text-muted-foreground", children: [
700
+ e.progress,
701
+ "% complete"
702
+ ] })
703
+ ] }),
704
+ e.status === "failed" && /* @__PURE__ */ t("span", { className: "text-xs text-muted-foreground", children: K(e.startedAt, { addSuffix: !0 }) })
705
+ ] })
706
+ ] });
707
+ }
708
+ function ht() {
709
+ const { authToken: e, tokenProps: a } = B(), c = I((f) => f.activeExports), { clearCompleted: n, removeExport: m, updateExport: l } = se(), [o, s] = A(!1), [h, d] = A(!1), g = Array.from(c.values()).sort(
710
+ (f, x) => x.startedAt.getTime() - f.startedAt.getTime()
711
+ ), C = g.some(
712
+ (f) => f.status === "completed" || f.status === "failed"
713
+ ), v = M(async () => {
714
+ const f = a == null ? void 0 : a.apiServiceUrl, x = e == null ? void 0 : e.accessToken;
715
+ if (!(!f || !x)) {
716
+ s(!0);
717
+ try {
718
+ const N = Array.from(c.values());
719
+ await Promise.all(
720
+ N.map(async (u) => {
721
+ try {
722
+ const p = await ae(f, x, u.id);
723
+ let i;
724
+ if (p.status === "completed")
725
+ try {
726
+ i = await _(f, x, u.id);
727
+ } catch (w) {
728
+ console.error(`Failed to get download URL for ${u.id}:`, w);
729
+ }
730
+ l(u.id, {
731
+ status: p.status,
732
+ progress: p.progress,
733
+ completedChunks: p.completedChunks,
734
+ completedAt: p.completedAt ? new Date(p.completedAt) : void 0,
735
+ lastUpdatedAt: /* @__PURE__ */ new Date(),
736
+ fileSize: p.fileSize,
737
+ error: p.error,
738
+ downloadUrl: i
739
+ });
740
+ } catch (p) {
741
+ console.error(`Failed to refresh export ${u.id}:`, p);
742
+ }
743
+ })
744
+ );
745
+ } finally {
746
+ s(!1);
747
+ }
748
+ }
749
+ }, [c, e == null ? void 0 : e.accessToken, a == null ? void 0 : a.apiServiceUrl, l]), b = M(async () => {
750
+ const f = a == null ? void 0 : a.apiServiceUrl, x = e == null ? void 0 : e.accessToken;
751
+ if (!f || !x) {
752
+ n();
753
+ return;
754
+ }
755
+ d(!0);
756
+ try {
757
+ const N = g.filter(
758
+ (u) => u.status === "completed" || u.status === "failed"
759
+ );
760
+ await Promise.all(
761
+ N.map(
762
+ (u) => Z(f, x, u.id).catch(
763
+ (p) => console.error(`Failed to delete export ${u.id}:`, p)
764
+ )
765
+ )
766
+ ), n();
767
+ } finally {
768
+ d(!1);
769
+ }
770
+ }, [g, a == null ? void 0 : a.apiServiceUrl, e == null ? void 0 : e.accessToken, n]), y = M(async (f) => {
771
+ const x = a == null ? void 0 : a.apiServiceUrl, N = e == null ? void 0 : e.accessToken;
772
+ if (x && N)
773
+ try {
774
+ await Z(x, N, f);
775
+ } catch (u) {
776
+ console.error(`Failed to cancel export ${f}:`, u);
777
+ }
778
+ m(f);
779
+ }, [a == null ? void 0 : a.apiServiceUrl, e == null ? void 0 : e.accessToken, m]);
780
+ return g.length === 0 ? /* @__PURE__ */ r("div", { className: "p-6 text-center", children: [
781
+ /* @__PURE__ */ t(ee, { className: "h-8 w-8 text-muted-foreground mx-auto mb-2" }),
782
+ /* @__PURE__ */ t("p", { className: "text-sm text-muted-foreground", children: "No active exports" }),
783
+ /* @__PURE__ */ t("p", { className: "text-xs text-muted-foreground mt-1", children: "Large exports will appear here" })
784
+ ] }) : /* @__PURE__ */ r("div", { className: "flex flex-col", children: [
785
+ /* @__PURE__ */ r("div", { className: "px-4 py-3 border-b flex items-center justify-between", children: [
786
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
787
+ /* @__PURE__ */ t(ee, { className: "h-5 w-5 text-muted-foreground" }),
788
+ /* @__PURE__ */ t("h4", { className: "font-semibold", children: "Exports" })
789
+ ] }),
790
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-1", children: [
791
+ /* @__PURE__ */ t(
792
+ S,
793
+ {
794
+ variant: "ghost",
795
+ size: "sm",
796
+ className: "h-7 w-7 p-0",
797
+ onClick: v,
798
+ disabled: o,
799
+ title: "Refresh status",
800
+ children: /* @__PURE__ */ t(at, { className: `h-4 w-4 ${o ? "animate-spin" : ""}` })
801
+ }
802
+ ),
803
+ C && /* @__PURE__ */ t(
804
+ S,
805
+ {
806
+ variant: "ghost",
807
+ size: "sm",
808
+ className: "h-7 text-sm px-2",
809
+ onClick: b,
810
+ disabled: h,
811
+ children: h ? "Clearing..." : "Clear all"
812
+ }
813
+ )
814
+ ] })
815
+ ] }),
816
+ /* @__PURE__ */ t("div", { className: "max-h-[350px] overflow-y-auto", children: /* @__PURE__ */ t("div", { className: "divide-y", children: g.map((f) => /* @__PURE__ */ t(
817
+ mt,
818
+ {
819
+ export: f,
820
+ onRemove: y
821
+ },
822
+ f.id
823
+ )) }) }),
824
+ /* @__PURE__ */ r("div", { className: "px-4 py-2 border-t text-sm text-muted-foreground text-center", children: [
825
+ g.length,
826
+ " total export",
827
+ g.length !== 1 ? "s" : ""
828
+ ] })
829
+ ] });
830
+ }
831
+ function Dt() {
832
+ const e = I((s) => s.activeExports), a = He(), c = e.size > 0, n = Array.from(e.values()).some(
833
+ (s) => s.status === "completed" || s.status === "failed"
834
+ ), l = a > 0 ? a > 9 ? "9+" : String(a) : null;
835
+ return /* @__PURE__ */ r(je, { children: [
836
+ /* @__PURE__ */ t(Ge, { asChild: !0, children: /* @__PURE__ */ r(
837
+ S,
838
+ {
839
+ variant: "ghost",
840
+ size: "icon",
841
+ className: "relative h-8 w-8",
842
+ "aria-label": "Export notifications",
843
+ children: [
844
+ /* @__PURE__ */ t(Xe, { className: "h-4 w-4" }),
845
+ c && /* @__PURE__ */ t(
846
+ "span",
847
+ {
848
+ className: `absolute flex items-center justify-center rounded-full bg-primary text-primary-foreground ${l ? "-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"}`,
849
+ children: l
850
+ }
851
+ )
852
+ ]
853
+ }
854
+ ) }),
855
+ /* @__PURE__ */ t(qe, { className: "w-80 p-0", align: "end", sideOffset: 8, children: /* @__PURE__ */ t(ht, {}) })
856
+ ] });
857
+ }
858
+ export {
859
+ yt as A,
860
+ ht as E,
861
+ Dt as N,
862
+ at as R,
863
+ Et as S,
864
+ At as U,
865
+ Nt as V,
866
+ mt as a,
867
+ Ct as b,
868
+ St as c,
869
+ wt as u
870
+ };