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