react-semaphor 0.1.115 → 0.1.116

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 (26) hide show
  1. package/dist/chunks/{dashboard-controls-YDGnMyyK.js → dashboard-controls-CRc6gw-F.js} +4 -4
  2. package/dist/chunks/{dashboard-controls-BQDmKxxN.js → dashboard-controls-CqcS1J54.js} +264 -251
  3. package/dist/chunks/{dashboard-json-BHAPV0Eh.js → dashboard-json-BOlcQgKG.js} +1 -1
  4. package/dist/chunks/{dashboard-json-D-gw81va.js → dashboard-json-D-75FAgQ.js} +1 -1
  5. package/dist/chunks/{edit-dashboard-visual-D8DmYTKj.js → edit-dashboard-visual-COf6UbOg.js} +165 -165
  6. package/dist/chunks/{edit-dashboard-visual-CadUC2o0.js → edit-dashboard-visual-tRQ806YP.js} +1 -1
  7. package/dist/chunks/{editor-action-buttons-CJ1R-8qC.js → editor-action-buttons-2B96j5tL.js} +1 -1
  8. package/dist/chunks/{editor-action-buttons-Cz-qv-g3.js → editor-action-buttons-Bh-TPwiy.js} +2 -2
  9. package/dist/chunks/{index-Bf4pgVkQ.js → index-CRDKevb0.js} +2892 -2880
  10. package/dist/chunks/{index-WFJ2bdm0.js → index-F4v-XjnM.js} +67 -67
  11. package/dist/chunks/resource-management-panel-CwGyO8S9.js +6 -0
  12. package/dist/chunks/resource-management-panel-DtwM8NVN.js +895 -0
  13. package/dist/chunks/{schedule-dashboard-BJ0PeQTb.js → schedule-dashboard-CtXspopT.js} +3 -3
  14. package/dist/chunks/{schedule-dashboard-DlYi6cPQ.js → schedule-dashboard-DWh6NWL5.js} +1 -1
  15. package/dist/chunks/{use-visual-utils-DlzVpKYl.js → use-visual-utils-Ce0Sq8Hn.js} +1 -1
  16. package/dist/chunks/{use-visual-utils-DlurLDVv.js → use-visual-utils-DyKq-_On.js} +1 -1
  17. package/dist/dashboard/index.cjs +1 -1
  18. package/dist/dashboard/index.js +1 -1
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.js +4 -4
  21. package/dist/style.css +1 -1
  22. package/dist/surfboard/index.cjs +1 -1
  23. package/dist/surfboard/index.js +1 -1
  24. package/package.json +1 -1
  25. package/dist/chunks/resource-management-panel-BXzn0kHW.js +0 -6
  26. package/dist/chunks/resource-management-panel-ByY6ZxCb.js +0 -878
@@ -1,878 +0,0 @@
1
- import { jsx as e, jsxs as s, Fragment as me } from "react/jsx-runtime";
2
- import { b as He, aM as pe, u as de, f as _e, ak as k, aN as Ge, aO as Ke, c as Y, aP as We, aC as Ye, aD as qe, B as z, aE as Je, aF as Qe, aG as H, aQ as ce, L as ee, aR as Xe, aS as Ze, aT as $e, aU as we, aV as fe, aW as ke, aX as et, I as tt, aY as Ce, aZ as te, a_ as ve, a$ as at, J as ye, R as Se, b0 as Ve, b1 as Ee, b2 as Le, b3 as Oe, b4 as Te, b5 as Ae, b6 as Pe, b7 as Re, b8 as Ue, b9 as st, ba as nt, bb as it, bc as ot, bd as rt, be as lt, bf as dt, bg as ct, aA as $, aj as ut, bh as ht, bi as Ie, bj as mt, bk as pt, ao as ft, ap as gt, aq as Dt, ar as Nt, as as xt, at as be, au as ue, ax as wt, bl as bt, bm as Ct, bn as vt } from "./index-Bf4pgVkQ.js";
3
- import yt, { useState as g, useEffect as he } from "react";
4
- import { a as Me } from "./use-visual-utils-DlzVpKYl.js";
5
- import { u as St } from "./use-click-outside-CMeO_QFI.js";
6
- /**
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
- */
12
- const Vt = He("FolderOpen", [
13
- [
14
- "path",
15
- {
16
- d: "m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",
17
- key: "usdka0"
18
- }
19
- ]
20
- ]);
21
- function je() {
22
- return /* @__PURE__ */ e(pe, { className: "w-full flex-1", children: /* @__PURE__ */ s("div", { className: "space-y-4 px-4 py-2", children: [
23
- /* @__PURE__ */ e("div", { className: "h-9 w-full rounded bg-muted animate-pulse" }),
24
- /* @__PURE__ */ e("div", { className: "h-9 w-full rounded bg-muted animate-pulse" }),
25
- /* @__PURE__ */ e("div", { className: "space-y-3 pt-2", children: [...Array(3)].map((t, f) => /* @__PURE__ */ s("div", { className: "flex gap-3 animate-pulse", children: [
26
- /* @__PURE__ */ e("div", { className: "h-8 w-8 rounded bg-muted flex-shrink-0" }),
27
- /* @__PURE__ */ s("div", { className: "flex-1 space-y-1.5", children: [
28
- /* @__PURE__ */ e("div", { className: "h-4 w-2/3 rounded bg-muted" }),
29
- /* @__PURE__ */ e("div", { className: "h-3 w-4/5 rounded bg-muted" })
30
- ] })
31
- ] }, f)) })
32
- ] }) });
33
- }
34
- const Et = (t) => {
35
- const f = de((o) => o.isVisualEditing), p = de((o) => o.selectedFrameId), i = _e((o) => o.frame);
36
- return !!(f && p && (i == null ? void 0 : i.visualId) === t);
37
- };
38
- function Lt({
39
- visual: t,
40
- isDeleting: f,
41
- isDuplicating: p,
42
- onAddVisual: i,
43
- onOpenVisual: o,
44
- onEditDetails: D,
45
- onDeleteClick: N,
46
- onDuplicateVisual: h,
47
- // onTogglePrivacy,
48
- onShareVisual: x,
49
- formatDate: S
50
- }) {
51
- var T, y, C, R;
52
- const { selectVisual: l } = k(), d = Ge(t.id), w = Et(t.id), { isConsoleMode: A } = Ke(), V = yt.useRef(null), [b, v] = g(!1), [E, L] = g(!1);
53
- he(() => {
54
- p ? (v(!0), L(!0)) : E && (v(!1), L(!1));
55
- }, [p, E]), he(() => {
56
- w && V.current && V.current.scrollIntoView({
57
- behavior: "smooth",
58
- block: "center"
59
- });
60
- }, [w]);
61
- const P = () => {
62
- l(t), o == null || o(t);
63
- };
64
- return /* @__PURE__ */ s(
65
- "div",
66
- {
67
- ref: V,
68
- className: Y(
69
- "group flex cursor-pointer items-start gap-3 rounded-md px-2 py-2 transition-colors hover:bg-muted",
70
- w ? "bg-purple-500/10" : d && "bg-muted/80"
71
- ),
72
- onClick: P,
73
- children: [
74
- /* @__PURE__ */ e(We, { className: "mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground/50" }),
75
- /* @__PURE__ */ e("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ s("div", { className: "flex items-start justify-between gap-2", children: [
76
- /* @__PURE__ */ s("div", { className: "min-w-0 flex-1", children: [
77
- /* @__PURE__ */ e(
78
- "p",
79
- {
80
- className: "truncate text-sm font-medium text-foreground",
81
- title: t.title || "Untitled Visual",
82
- children: t.title || "Untitled Visual"
83
- }
84
- ),
85
- /* @__PURE__ */ e(
86
- "p",
87
- {
88
- className: "truncate text-xs text-muted-foreground",
89
- title: t.description || "No description",
90
- children: (T = t.description) != null && T.trim() ? t.description : "No description"
91
- }
92
- )
93
- ] }),
94
- /* @__PURE__ */ s(
95
- "div",
96
- {
97
- className: "flex flex-shrink-0 items-center gap-1",
98
- onClick: (u) => u.stopPropagation(),
99
- children: [
100
- /* @__PURE__ */ e("div", { className: "opacity-0 transition-opacity group-hover:opacity-100", children: /* @__PURE__ */ s(
101
- Ye,
102
- {
103
- modal: !1,
104
- open: b,
105
- onOpenChange: v,
106
- children: [
107
- /* @__PURE__ */ e(qe, { asChild: !0, children: /* @__PURE__ */ e(z, { size: "sm", variant: "ghost", className: "h-6 w-6 p-0", children: /* @__PURE__ */ e(Je, { className: "h-3 w-3" }) }) }),
108
- /* @__PURE__ */ s(Qe, { align: "end", className: "z-[51] w-40", children: [
109
- /* @__PURE__ */ s(
110
- H,
111
- {
112
- onClick: (u) => {
113
- u.stopPropagation(), i(t);
114
- },
115
- children: [
116
- /* @__PURE__ */ e(ce, { className: "mr-2 h-3 w-3" }),
117
- "Add"
118
- ]
119
- }
120
- ),
121
- /* @__PURE__ */ s(
122
- H,
123
- {
124
- onClick: (u) => {
125
- u.stopPropagation(), o == null || o(t);
126
- },
127
- children: [
128
- /* @__PURE__ */ e(Vt, { className: "mr-2 h-3 w-3" }),
129
- "Open"
130
- ]
131
- }
132
- ),
133
- /* @__PURE__ */ s(
134
- H,
135
- {
136
- onClick: (u) => {
137
- u.preventDefault(), u.stopPropagation(), h(t.id);
138
- },
139
- disabled: p,
140
- children: [
141
- p ? /* @__PURE__ */ e(ee, { className: "mr-2 h-3 w-3 animate-spin" }) : /* @__PURE__ */ e(Xe, { className: "mr-2 h-3 w-3" }),
142
- p ? "Duplicating..." : "Duplicate"
143
- ]
144
- }
145
- ),
146
- t.ownership.isOwner && /* @__PURE__ */ s(me, { children: [
147
- /* @__PURE__ */ s(
148
- H,
149
- {
150
- onClick: (u) => {
151
- u.stopPropagation(), D == null || D(t);
152
- },
153
- children: [
154
- /* @__PURE__ */ e(Ze, { className: "mr-2 h-3 w-3" }),
155
- "Edit details"
156
- ]
157
- }
158
- ),
159
- /* @__PURE__ */ s(
160
- H,
161
- {
162
- onClick: (u) => {
163
- u.stopPropagation(), x(t);
164
- },
165
- children: [
166
- /* @__PURE__ */ e($e, { className: "mr-2 h-3 w-3" }),
167
- "Share"
168
- ]
169
- }
170
- ),
171
- /* @__PURE__ */ e(we, {}),
172
- /* @__PURE__ */ s(
173
- H,
174
- {
175
- onClick: (u) => {
176
- u.stopPropagation(), N(t);
177
- },
178
- className: "text-destructive",
179
- disabled: f,
180
- children: [
181
- /* @__PURE__ */ e(fe, { className: "mr-2 h-3 w-3" }),
182
- f ? "Deleting..." : "Delete"
183
- ]
184
- }
185
- )
186
- ] }),
187
- /* @__PURE__ */ e(we, {}),
188
- /* @__PURE__ */ s("div", { className: "space-y-1 px-2 py-2 text-xs text-slate-500 dark:text-slate-400", children: [
189
- (((y = t.ownership.createdBy) == null ? void 0 : y.type) === "tenant" || ((C = t.ownership.createdBy) == null ? void 0 : C.type) === "organization" && A) && /* @__PURE__ */ s("div", { className: "flex items-center gap-1", children: [
190
- /* @__PURE__ */ e(ke, { className: "h-3 w-3" }),
191
- /* @__PURE__ */ e("span", { children: ((R = t.ownership.createdBy) == null ? void 0 : R.name) || "Unknown" })
192
- ] }),
193
- /* @__PURE__ */ s("div", { className: "flex items-center gap-1", children: [
194
- /* @__PURE__ */ e(et, { className: "h-3 w-3" }),
195
- /* @__PURE__ */ e("span", { children: S(t.lastModified) })
196
- ] })
197
- ] })
198
- ] })
199
- ]
200
- }
201
- ) }),
202
- /* @__PURE__ */ e(
203
- tt,
204
- {
205
- tooltip: "Add to dashboard",
206
- buttonProps: {
207
- variant: "ghost",
208
- size: "sm",
209
- onClick: (u) => {
210
- u.stopPropagation(), i(t);
211
- }
212
- },
213
- className: "h-6 w-6 p-0",
214
- children: /* @__PURE__ */ e(ce, { className: "h-3.5 w-3.5" })
215
- }
216
- )
217
- ]
218
- }
219
- )
220
- ] }) })
221
- ]
222
- },
223
- t.id
224
- );
225
- }
226
- function Ot({ searchQuery: t }) {
227
- const [f, p] = g(!1), [i, o] = g(
228
- null
229
- ), [D, N] = g(!1), [h, x] = g(null), [S, l] = g(null), [d, w] = g(
230
- null
231
- ), { selectVisual: A } = k(), { handleEditLibraryVisual: V, handleAddLibraryVisual: b } = Me(), {
232
- resources: v,
233
- isLoading: E,
234
- isError: L,
235
- updateResource: P,
236
- deleteResource: T,
237
- duplicateResource: y,
238
- isDeleting: C
239
- } = Ce(() => {
240
- N(!1), x(null);
241
- });
242
- te();
243
- const R = v.filter(
244
- (n) => {
245
- var O, r;
246
- return ((O = n == null ? void 0 : n.title) == null ? void 0 : O.toLowerCase().includes(t.toLowerCase())) || ((r = n == null ? void 0 : n.description) == null ? void 0 : r.toLowerCase().includes(t.toLowerCase()));
247
- }
248
- ), u = (n) => new Date(n).toLocaleDateString("en-US", {
249
- month: "short",
250
- day: "numeric",
251
- year: "numeric"
252
- }), q = (n) => {
253
- x(n), N(!0);
254
- }, _ = () => {
255
- h && T(h.id);
256
- }, {
257
- startUpdating: J,
258
- stopUpdating: M,
259
- isUpdating: m
260
- } = ve(), j = (n, O, r) => {
261
- var Z;
262
- const B = Object.fromEntries(
263
- Object.entries(O).filter(([, I]) => I !== void 0)
264
- );
265
- if (Object.keys(B).length === 0) {
266
- (Z = r == null ? void 0 : r.onSuccess) == null || Z.call(r);
267
- return;
268
- }
269
- const X = Object.keys(B), W = X.length === 1 ? X[0] : void 0;
270
- J(n, W), P(
271
- {
272
- resourceId: n,
273
- data: B
274
- },
275
- {
276
- onSuccess: () => {
277
- var I;
278
- M(n, W), (I = r == null ? void 0 : r.onSuccess) == null || I.call(r);
279
- },
280
- onError: () => {
281
- var I;
282
- M(n, W), (I = r == null ? void 0 : r.onError) == null || I.call(r);
283
- }
284
- }
285
- );
286
- }, G = (n) => {
287
- l(n), y(n, {
288
- onSettled: () => l(null)
289
- });
290
- }, ae = (n) => {
291
- V(n);
292
- }, K = (n) => {
293
- b(n);
294
- }, se = (n) => {
295
- const O = v.find((r) => r.id === n);
296
- O && P({
297
- resourceId: n,
298
- data: {
299
- isPrivate: !O.isPrivate
300
- }
301
- });
302
- }, Q = (n) => {
303
- o(n), p(!0);
304
- }, ne = (n) => {
305
- w(n);
306
- }, ie = () => {
307
- w(null);
308
- }, oe = ({
309
- title: n,
310
- description: O
311
- }) => {
312
- if (!d)
313
- return;
314
- const r = {};
315
- n !== d.title && (r.title = n), (d.description || "") !== O && (r.description = O), j(d.id, r, {
316
- onSuccess: () => {
317
- w(null);
318
- }
319
- });
320
- };
321
- return E ? /* @__PURE__ */ e(je, {}) : L ? /* @__PURE__ */ e(pe, { className: "w-full flex-1 pr-2", children: /* @__PURE__ */ s("div", { className: "py-8 text-center text-muted-foreground", children: [
322
- /* @__PURE__ */ e("p", { className: "text-sm text-destructive", children: "Failed to load visuals" }),
323
- /* @__PURE__ */ e(
324
- z,
325
- {
326
- variant: "outline",
327
- size: "sm",
328
- className: "mt-2",
329
- onClick: () => window.location.reload(),
330
- children: "Retry"
331
- }
332
- )
333
- ] }) }) : /* @__PURE__ */ s("div", { className: "flex h-full flex-1 flex-col", children: [
334
- /* @__PURE__ */ e("div", { className: "flex flex-1 basis-0 flex-col gap-3 overflow-y-auto", children: R.length === 0 ? /* @__PURE__ */ s("div", { className: "py-8 text-center", children: [
335
- /* @__PURE__ */ e("div", { className: "mb-3", children: /* @__PURE__ */ e(at, { className: "mx-auto h-12 w-12 text-muted-foreground/50" }) }),
336
- /* @__PURE__ */ e("h3", { className: "mb-1 font-medium text-foreground", children: t ? "No visuals found" : "No visuals yet" }),
337
- /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t ? "Try adjusting your search" : 'Click "Create" above to add your first visual' })
338
- ] }) : R.map((n) => /* @__PURE__ */ e(
339
- Lt,
340
- {
341
- visual: n,
342
- onAddVisual: K,
343
- onOpenVisual: ae,
344
- onEditDetails: ne,
345
- onDeleteClick: q,
346
- onDuplicateVisual: G,
347
- onTogglePrivacy: se,
348
- onShareVisual: Q,
349
- isDeleting: C,
350
- isDuplicating: S === n.id,
351
- formatDate: u
352
- },
353
- n.id
354
- )) }),
355
- f && i && /* @__PURE__ */ e(
356
- ye,
357
- {
358
- resource: i,
359
- resourceType: Se.VISUAL,
360
- onClose: () => {
361
- p(!1), o(null);
362
- }
363
- }
364
- ),
365
- d && /* @__PURE__ */ e(
366
- Ve,
367
- {
368
- open: !!d,
369
- resourceLabel: "Visual",
370
- initialTitle: d.title || "",
371
- initialDescription: d.description || "",
372
- onClose: ie,
373
- onSave: oe,
374
- isSaving: m(d.id)
375
- }
376
- ),
377
- /* @__PURE__ */ e(
378
- Ee,
379
- {
380
- open: D,
381
- onOpenChange: (n) => {
382
- !n && C || (N(n), n || x(null));
383
- },
384
- children: /* @__PURE__ */ s(Le, { children: [
385
- /* @__PURE__ */ s(Oe, { children: [
386
- /* @__PURE__ */ e(Te, { children: "Delete Visual" }),
387
- /* @__PURE__ */ s(Ae, { children: [
388
- 'Are you sure you want to delete "',
389
- h == null ? void 0 : h.title,
390
- '"? This action cannot be undone.'
391
- ] })
392
- ] }),
393
- /* @__PURE__ */ s(Pe, { children: [
394
- /* @__PURE__ */ e(Re, { disabled: C, children: "Cancel" }),
395
- /* @__PURE__ */ s(
396
- Ue,
397
- {
398
- onClick: (n) => {
399
- n.preventDefault(), n.stopPropagation(), _();
400
- },
401
- className: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
402
- disabled: C,
403
- children: [
404
- C ? /* @__PURE__ */ e(ee, { className: "mr-2 h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(fe, { className: "mr-2 h-3.5 w-3.5" }),
405
- C ? "Deleting..." : "Delete"
406
- ]
407
- }
408
- )
409
- ] })
410
- ] })
411
- }
412
- )
413
- ] });
414
- }
415
- function Tt({
416
- dashboard: t,
417
- isDeleting: f,
418
- isDuplicating: p,
419
- isDefault: i,
420
- onLoadDashboard: o,
421
- onEditDetails: D,
422
- onDeleteClick: N,
423
- onDuplicateDashboard: h,
424
- onShareDashboard: x,
425
- formatDate: S,
426
- onDashboardItemClick: l
427
- }) {
428
- var T, y;
429
- const { selectDashboard: d } = k(), w = st(t.id), { userContext: A, isLoading: V } = te(), { mutate: b } = nt(), v = ((T = A == null ? void 0 : A.permissions) == null ? void 0 : T.canEdit) ?? !1, E = V || !v, L = () => {
430
- d(t), o(t.id), l == null || l(t.id);
431
- }, P = (C) => {
432
- C.stopPropagation(), b({ dashboardId: i ? null : t.id });
433
- };
434
- return /* @__PURE__ */ e(it, { children: /* @__PURE__ */ s(
435
- "div",
436
- {
437
- className: Y(
438
- "group flex cursor-pointer items-start gap-3 rounded-md px-2 py-2 transition-colors hover:bg-muted",
439
- w && "bg-muted/80"
440
- ),
441
- onClick: L,
442
- children: [
443
- /* @__PURE__ */ s(ot, { children: [
444
- /* @__PURE__ */ e(rt, { asChild: !0, children: /* @__PURE__ */ e(
445
- "button",
446
- {
447
- onClick: P,
448
- className: "mt-0.5 flex-shrink-0 rounded p-0.5 hover:bg-muted",
449
- children: /* @__PURE__ */ e(
450
- lt,
451
- {
452
- className: Y(
453
- "h-4 w-4 transition-colors",
454
- i ? "fill-yellow-400 text-yellow-400" : "text-muted-foreground/40 hover:text-yellow-400"
455
- )
456
- }
457
- )
458
- }
459
- ) }),
460
- /* @__PURE__ */ e(dt, { side: "right", className: "text-xs", children: i ? "Remove as default" : "Set as default" })
461
- ] }),
462
- /* @__PURE__ */ e("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ s("div", { className: "flex items-start justify-between gap-2", children: [
463
- /* @__PURE__ */ s("div", { className: "min-w-0 flex-1", children: [
464
- /* @__PURE__ */ e(
465
- "p",
466
- {
467
- className: "truncate text-sm font-medium text-foreground",
468
- title: t.title || "Untitled Dashboard",
469
- children: t.title || "Untitled Dashboard"
470
- }
471
- ),
472
- /* @__PURE__ */ e(
473
- "p",
474
- {
475
- className: "truncate text-xs text-muted-foreground",
476
- title: t.description || "No description",
477
- children: (y = t.description) != null && y.trim() ? t.description : "No description"
478
- }
479
- )
480
- ] }),
481
- /* @__PURE__ */ e("div", { className: "flex-shrink-0 opacity-0 transition-opacity group-hover:opacity-100", children: /* @__PURE__ */ e(
482
- ct,
483
- {
484
- dashboard: t,
485
- isDeleting: f,
486
- isDuplicating: p,
487
- shouldHideActions: E,
488
- onEditDetails: D,
489
- onDeleteClick: N,
490
- onDuplicateDashboard: h,
491
- onShareDashboard: x,
492
- formatDate: S
493
- }
494
- ) })
495
- ] }) })
496
- ]
497
- },
498
- t.id
499
- ) });
500
- }
501
- function At({ onRetry: t }) {
502
- return /* @__PURE__ */ e(pe, { className: "w-full flex-1 pr-2", children: /* @__PURE__ */ s("div", { className: "py-8 text-center text-muted-foreground", children: [
503
- /* @__PURE__ */ e("p", { className: "text-sm text-destructive", children: "Failed to load dashboards" }),
504
- /* @__PURE__ */ e(z, { variant: "outline", size: "sm", className: "mt-2", onClick: t, children: "Retry" })
505
- ] }) });
506
- }
507
- function Pt(t) {
508
- var ge, De;
509
- const { searchQuery: f, onLoadDashboard: p, onEditDashboard: i, onDashboardItemClick: o } = t, [D, N] = g(!1), [h, x] = g(
510
- null
511
- ), [S, l] = g(!1), [d, w] = g(null), [A, V] = g(null), [b, v] = g(null), E = $(
512
- (a) => a.lastSelectedDashboard
513
- ), L = $(
514
- (a) => a.selectedDashboard
515
- ), P = $(
516
- (a) => a.actions.selectDashboard
517
- ), T = $(
518
- (a) => a.actions.clearSelectedDashboard
519
- ), { tokenProps: y, id: C } = ut();
520
- ht();
521
- const {
522
- resources: R,
523
- isLoading: u,
524
- isError: q,
525
- updateResource: _,
526
- deleteResource: J,
527
- duplicateResource: M,
528
- isDeleting: m
529
- } = Ie(() => {
530
- l(!1);
531
- const a = d == null ? void 0 : d.id;
532
- w(null), (L == null ? void 0 : L.id) === a && (!(y != null && y.dashboard_id) && !C ? T() : E && E.id !== a && P(E));
533
- }), { currentUser: j, userContext: G } = te(), ae = ((ge = G == null ? void 0 : G.permissions) == null ? void 0 : ge.canCreateDashboard) ?? !1, { data: K } = mt(), se = ((De = K == null ? void 0 : K.preference) == null ? void 0 : De.defaultDashboardId) || null, Q = R.filter(
534
- (a) => {
535
- var U, c;
536
- return ((U = a == null ? void 0 : a.title) == null ? void 0 : U.toLowerCase().includes(f.toLowerCase())) || ((c = a == null ? void 0 : a.description) == null ? void 0 : c.toLowerCase().includes(f.toLowerCase()));
537
- }
538
- ), ne = (a) => new Date(a).toLocaleDateString("en-US", {
539
- month: "short",
540
- day: "numeric",
541
- year: "numeric"
542
- }), ie = (a) => {
543
- p == null || p(a);
544
- }, oe = (a) => {
545
- w(a), l(!0);
546
- }, n = () => {
547
- d && J(d.id);
548
- }, O = (a) => {
549
- V(a), M(a, {
550
- onSettled: () => V(null)
551
- });
552
- }, {
553
- startUpdating: r,
554
- stopUpdating: B,
555
- isUpdating: X
556
- } = ve(), W = (a, U, c) => {
557
- var xe;
558
- const re = Object.fromEntries(
559
- Object.entries(U).filter(([, F]) => F !== void 0)
560
- );
561
- if (Object.keys(re).length === 0) {
562
- (xe = c == null ? void 0 : c.onSuccess) == null || xe.call(c);
563
- return;
564
- }
565
- const Ne = Object.keys(re), le = Ne.length === 1 ? Ne[0] : void 0;
566
- r(a, le), _(
567
- {
568
- resourceId: a,
569
- data: re
570
- },
571
- {
572
- onSuccess: () => {
573
- var F;
574
- B(a, le), (F = c == null ? void 0 : c.onSuccess) == null || F.call(c);
575
- },
576
- onError: () => {
577
- var F;
578
- B(a, le), (F = c == null ? void 0 : c.onError) == null || F.call(c);
579
- }
580
- }
581
- );
582
- }, Z = (a) => {
583
- const U = R.find(
584
- (c) => c.id === a
585
- );
586
- U && _({
587
- resourceId: a,
588
- data: {
589
- isPrivate: !U.isPrivate
590
- }
591
- });
592
- }, I = (a) => {
593
- x(a), j == null || j.type, N(!0);
594
- }, Fe = (a) => {
595
- i == null || i(a.id), v(a);
596
- }, ze = () => {
597
- v(null);
598
- }, Be = ({
599
- title: a,
600
- description: U
601
- }) => {
602
- if (!b)
603
- return;
604
- const c = {};
605
- a !== b.title && (c.title = a), (b.description || "") !== U && (c.description = U), W(b.id, c, {
606
- onSuccess: () => {
607
- v(null);
608
- }
609
- });
610
- };
611
- return u ? /* @__PURE__ */ e(je, {}) : q ? /* @__PURE__ */ e(At, { onRetry: () => window.location.reload() }) : /* @__PURE__ */ s("div", { className: "flex h-full flex-1 flex-col", children: [
612
- /* @__PURE__ */ e("div", { className: "flex flex-1 basis-0 flex-col gap-3 overflow-y-auto", children: Q.length === 0 ? /* @__PURE__ */ s("div", { className: "py-8 text-center", children: [
613
- /* @__PURE__ */ e("div", { className: "mb-3", children: /* @__PURE__ */ e(pt, { className: "mx-auto h-12 w-12 text-muted-foreground/50" }) }),
614
- /* @__PURE__ */ e("h3", { className: "mb-1 font-medium text-foreground", children: f ? "No dashboards found" : "No dashboards yet" }),
615
- /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: f ? "Try adjusting your search" : ae ? 'Click "Create" above to add your first dashboard' : "No dashboards have been shared with you yet" })
616
- ] }) : Q.map((a) => /* @__PURE__ */ e(
617
- Tt,
618
- {
619
- dashboard: a,
620
- isDeleting: m,
621
- isDuplicating: A === a.id,
622
- isDefault: a.id === se,
623
- onLoadDashboard: ie,
624
- onEditDetails: Fe,
625
- onDeleteClick: oe,
626
- onDuplicateDashboard: O,
627
- onTogglePrivacy: Z,
628
- onShareDashboard: I,
629
- formatDate: ne,
630
- onDashboardItemClick: o
631
- },
632
- a.id
633
- )) }),
634
- D && h && /* @__PURE__ */ e(
635
- ye,
636
- {
637
- resource: h,
638
- resourceType: Se.DASHBOARD,
639
- onClose: () => {
640
- N(!1), x(null);
641
- }
642
- }
643
- ),
644
- /* @__PURE__ */ e(
645
- Ee,
646
- {
647
- open: S,
648
- onOpenChange: (a) => {
649
- !a && m || (l(a), a || w(null));
650
- },
651
- children: /* @__PURE__ */ s(Le, { children: [
652
- /* @__PURE__ */ s(Oe, { children: [
653
- /* @__PURE__ */ e(Te, { children: "Delete Dashboard" }),
654
- /* @__PURE__ */ s(Ae, { children: [
655
- 'Are you sure you want to delete "',
656
- d == null ? void 0 : d.title,
657
- '"? This action cannot be undone.'
658
- ] })
659
- ] }),
660
- /* @__PURE__ */ s(Pe, { children: [
661
- /* @__PURE__ */ e(Re, { disabled: m, children: "Cancel" }),
662
- /* @__PURE__ */ s(
663
- Ue,
664
- {
665
- onClick: (a) => {
666
- a.preventDefault(), a.stopPropagation(), n();
667
- },
668
- className: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
669
- disabled: m,
670
- children: [
671
- m ? /* @__PURE__ */ e(ee, { className: "mr-2 h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(fe, { className: "mr-2 h-3.5 w-3.5" }),
672
- m ? "Deleting..." : "Delete"
673
- ]
674
- }
675
- )
676
- ] })
677
- ] })
678
- }
679
- ),
680
- b && /* @__PURE__ */ e(
681
- Ve,
682
- {
683
- open: !!b,
684
- resourceLabel: "Dashboard",
685
- initialTitle: b.title || "",
686
- initialDescription: b.description || "",
687
- onClose: ze,
688
- onSave: Be,
689
- isSaving: X(b.id)
690
- }
691
- )
692
- ] });
693
- }
694
- function Rt({
695
- open: t,
696
- onOpenChange: f,
697
- onSubmit: p,
698
- isCreating: i
699
- }) {
700
- const [o, D] = g(""), [N, h] = g("");
701
- he(() => {
702
- t || (D(""), h(""));
703
- }, [t]);
704
- const x = () => {
705
- o.trim() && p({ title: o, description: N });
706
- }, S = (l) => {
707
- f(l);
708
- };
709
- return /* @__PURE__ */ e(ft, { open: t, onOpenChange: S, children: /* @__PURE__ */ s(gt, { children: [
710
- /* @__PURE__ */ s(Dt, { children: [
711
- /* @__PURE__ */ e(Nt, { children: "Create New Visual" }),
712
- /* @__PURE__ */ e(xt, { children: "Add a new visual to your library. You can configure it after creation." })
713
- ] }),
714
- /* @__PURE__ */ s("div", { className: "space-y-4 py-4", children: [
715
- /* @__PURE__ */ s("div", { className: "space-y-2", children: [
716
- /* @__PURE__ */ e(be, { htmlFor: "title", children: "Visual Title" }),
717
- /* @__PURE__ */ e(
718
- ue,
719
- {
720
- id: "title",
721
- placeholder: "Enter visual title...",
722
- value: o,
723
- onChange: (l) => D(l.target.value),
724
- disabled: i,
725
- onKeyDown: (l) => {
726
- l.key === "Enter" && !l.shiftKey && (l.preventDefault(), x());
727
- }
728
- }
729
- )
730
- ] }),
731
- /* @__PURE__ */ s("div", { className: "space-y-2", children: [
732
- /* @__PURE__ */ e(be, { htmlFor: "description", children: "Description (optional)" }),
733
- /* @__PURE__ */ e(
734
- ue,
735
- {
736
- id: "description",
737
- placeholder: "Enter visual description...",
738
- value: N,
739
- onChange: (l) => h(l.target.value),
740
- disabled: i
741
- }
742
- )
743
- ] })
744
- ] }),
745
- /* @__PURE__ */ s(wt, { children: [
746
- /* @__PURE__ */ e(
747
- z,
748
- {
749
- variant: "outline",
750
- onClick: () => S(!1),
751
- disabled: i,
752
- children: "Cancel"
753
- }
754
- ),
755
- /* @__PURE__ */ e(
756
- z,
757
- {
758
- onClick: x,
759
- disabled: !o.trim() || i,
760
- children: i ? /* @__PURE__ */ s(me, { children: [
761
- /* @__PURE__ */ e(ee, { className: "mr-2 h-4 w-4 animate-spin" }),
762
- "Creating..."
763
- ] }) : "Create Visual"
764
- }
765
- )
766
- ] })
767
- ] }) });
768
- }
769
- function zt({
770
- isOpen: t,
771
- onClose: f,
772
- className: p,
773
- onDashboardItemClick: i,
774
- variant: o = "inline"
775
- }) {
776
- var M;
777
- const D = de(
778
- (m) => m.isDashboardEditing
779
- ), [N, h] = g(!1), [x, S] = g(""), [l, d] = g(!1), { userContext: w } = te(), A = ((M = w == null ? void 0 : w.permissions) == null ? void 0 : M.canCreateDashboard) ?? !1, { onCreateSuccess: V } = bt({
780
- onDashboardSelect: i
781
- }), { selectVisual: b } = k(), { handleEditLibraryVisual: v } = Me(), {
782
- createResource: E,
783
- isCreating: L,
784
- refetch: P
785
- } = Ie(), { createResource: T, isCreating: y } = Ce(
786
- void 0,
787
- // onDeleteSuccess (not needed here)
788
- (m) => {
789
- h(!1), m && (b(m), v(m));
790
- }
791
- ), C = o === "overlay", R = St(f, {
792
- enabled: t && C
793
- }), u = Y(
794
- "flex h-full flex-col border-r bg-background",
795
- C ? Y(
796
- "absolute inset-y-0 left-0 z-[51] w-60 shadow-lg transition-transform duration-300 ease-in-out",
797
- t ? "translate-x-0" : "pointer-events-none -translate-x-full"
798
- ) : "w-full max-w-[17rem] min-w-[11rem] overflow-hidden shadow-sm",
799
- p
800
- );
801
- return /* @__PURE__ */ e(me, { children: (!C || t) && /* @__PURE__ */ s("div", { ref: R, className: u, children: [
802
- /* @__PURE__ */ s("div", { className: "border-b border-border", children: [
803
- /* @__PURE__ */ s("div", { className: "flex items-center justify-between px-4 py-1.5", children: [
804
- /* @__PURE__ */ e("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ e("h2", { className: "whitespace-nowrap text-sm font-semibold", children: D ? "Visuals" : "Dashboards" }) }),
805
- /* @__PURE__ */ s("div", { className: "flex items-center gap-0", children: [
806
- /* @__PURE__ */ e(
807
- z,
808
- {
809
- size: "sm",
810
- variant: "ghost",
811
- onClick: () => d(!l),
812
- className: "h-8 w-8 p-0",
813
- children: /* @__PURE__ */ e(Ct, { className: "h-3.5 w-3.5" })
814
- }
815
- ),
816
- (D || A) && /* @__PURE__ */ e(
817
- z,
818
- {
819
- size: "sm",
820
- variant: "ghost",
821
- className: "h-8 w-8 whitespace-nowrap p-0",
822
- onClick: () => h(!0),
823
- children: /* @__PURE__ */ e(ce, { className: "h-3.5 w-3.5" })
824
- }
825
- )
826
- ] })
827
- ] }),
828
- l && /* @__PURE__ */ e("div", { className: "bg-muted/30 px-4 pb-3", children: /* @__PURE__ */ e(
829
- ue,
830
- {
831
- placeholder: "Search...",
832
- value: x,
833
- onChange: (m) => S(m.target.value),
834
- className: "h-8 border-muted-foreground/20 bg-background text-sm focus-visible:border-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0",
835
- autoFocus: !0
836
- }
837
- ) })
838
- ] }),
839
- /* @__PURE__ */ e("div", { className: "flex flex-1 flex-col overflow-auto px-2 py-2", children: D ? /* @__PURE__ */ e(Ot, { searchQuery: x }) : /* @__PURE__ */ e(
840
- Pt,
841
- {
842
- searchQuery: x,
843
- onLoadDashboard: (m) => {
844
- },
845
- onEditDashboard: (m) => {
846
- console.log("Editing dashboard:", m);
847
- },
848
- onDashboardItemClick: i
849
- }
850
- ) }),
851
- D ? /* @__PURE__ */ e(
852
- Rt,
853
- {
854
- open: N,
855
- onOpenChange: h,
856
- onSubmit: T,
857
- isCreating: y
858
- }
859
- ) : /* @__PURE__ */ e(
860
- vt,
861
- {
862
- open: N,
863
- onOpenChange: h,
864
- onSubmit: (m) => {
865
- E(m, {
866
- onSuccess: (j) => {
867
- h(!1), V(j, P);
868
- }
869
- });
870
- },
871
- isCreating: L
872
- }
873
- )
874
- ] }) });
875
- }
876
- export {
877
- zt as ResourceManagementPanel
878
- };