react-semaphor 0.1.290 → 0.1.292

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 (32) hide show
  1. package/dist/chunks/braces-0bzwctGp.js +23 -0
  2. package/dist/chunks/braces-hczcJsV8.js +6 -0
  3. package/dist/chunks/dashboard-controls-Db0F38eK.js +47 -0
  4. package/dist/chunks/dashboard-controls-DeUHM4uL.js +1970 -0
  5. package/dist/chunks/{dashboard-filter-controls-button-C4AMu723.js → dashboard-filter-controls-button-DDqEus_E.js} +54 -52
  6. package/dist/chunks/dashboard-filter-controls-button-DSQHVjjX.js +11 -0
  7. package/dist/chunks/{dashboard-json-C13EJaTK.js → dashboard-json-BDyKcoGT.js} +1 -1
  8. package/dist/chunks/{dashboard-json-BKs1UTLL.js → dashboard-json-COXiPm3N.js} +6 -6
  9. package/dist/chunks/{dashboard-summary-settings-dialog-fL9l0wUO.js → dashboard-summary-settings-dialog-CryMC_4x.js} +1 -1
  10. package/dist/chunks/{dashboard-summary-settings-dialog-T6aUgPAf.js → dashboard-summary-settings-dialog-DbcWMZsr.js} +1 -1
  11. package/dist/chunks/{edit-dashboard-visual-CKB34ird.js → edit-dashboard-visual-BqfzqW4i.js} +4 -9
  12. package/dist/chunks/{edit-dashboard-visual-CnVx0Xi7.js → edit-dashboard-visual-DLyimx6x.js} +11 -29
  13. package/dist/chunks/{index-Cr9Smn6Q.js → index-72yod5pb.js} +523 -516
  14. package/dist/chunks/{index-Cwg2SRSi.js → index-BQ6qu8FI.js} +93 -93
  15. package/dist/chunks/resource-management-panel-CSLGSJjC.js +6 -0
  16. package/dist/chunks/{resource-management-panel-DJgYduN9.js → resource-management-panel-DwPION_M.js} +22 -22
  17. package/dist/chunks/{use-create-flow-overlay-state-NGb4c5Ye.js → use-create-flow-overlay-state-UruHbtfS.js} +53 -53
  18. package/dist/chunks/{use-create-flow-overlay-state-DnI1SSKD.js → use-create-flow-overlay-state-zz9TYhdC.js} +1 -1
  19. package/dist/chunks/{use-visual-utils-ivCDI1cO.js → use-visual-utils-Bm-ZnkON.js} +1 -1
  20. package/dist/chunks/{use-visual-utils-BbxYtbzK.js → use-visual-utils-DPBqTRUC.js} +11 -11
  21. package/dist/dashboard/index.cjs +1 -1
  22. package/dist/dashboard/index.js +1 -1
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +21 -21
  25. package/dist/style.css +1 -1
  26. package/dist/surfboard/index.cjs +1 -1
  27. package/dist/surfboard/index.js +2 -2
  28. package/package.json +1 -1
  29. package/dist/chunks/dashboard-controls-BSbG43wo.js +0 -42
  30. package/dist/chunks/dashboard-controls-LtQ98rvL.js +0 -1938
  31. package/dist/chunks/dashboard-filter-controls-button-CgoIPOZZ.js +0 -11
  32. package/dist/chunks/resource-management-panel-Dv18tosO.js +0 -6
@@ -0,0 +1,1970 @@
1
+ import { jsx as e, jsxs as o, Fragment as A } from "react/jsx-runtime";
2
+ import { c as Z, dp as Ka, u as N, B as M, dq as ls, O as Qs, d as H, e as ds, dr as Qa, ct as Oe, f as us, g as ms, h as hs, i as Ws, L as es, I as le, w as Wa, ds as ce, cK as Ie, dt as Ja, du as $s, dv as Js, b as Y, dw as Ys, dx as Ya, c$ as ps, dy as Xa, dz as Za, dA as et, dB as st, dC as at, dD as tt, J as Pe, Y as _e, y as k, dE as Ue, dF as Xs, dG as Zs, d8 as nt, dH as rt, x as X, cJ as K, dI as ot, dJ as it, dK as ss, dL as ct, dM as lt, dN as ea, dO as sa, dP as ke, dQ as Te, d4 as as, cP as ts, dR as ns, ch as aa, dS as rs, cc as ta, dT as dt, cS as na, cT as ra, cU as oa, cV as ia, cW as ca, cX as la, cY as da, cZ as os, dU as ua, cB as ut, dV as mt, ah as ht, V as Vs, ag as Ae, dW as pt, an as ft, ai as We, dX as gt, dY as vt, dZ as bt, aC as yt, d_ as St, a8 as Je, d$ as Nt, bT as xt, bU as Dt, bV as wt, e0 as Ct, bW as Et, e1 as Mt, dn as At, e2 as Lt, cC as It, cD as Ot, cE as kt, cF as Tt, cG as q, de as Pt, aa as _t, cM as Ut, e3 as Rt, cH as Gt, au as Ft, e4 as $t, e5 as Vt, e6 as qt, am as Ht, ab as zt, e7 as jt, at as Bt, e8 as Kt } from "./index-72yod5pb.js";
3
+ import * as E from "react";
4
+ import ma, { useState as S, useMemo as B, useCallback as qs, useEffect as Hs } from "react";
5
+ import "react-dom";
6
+ import { b as Qt, u as Wt, d as Jt, A as Yt, V as Xt, c as Zt, D as en, N as sn, U as an } from "./dashboard-filter-controls-button-DDqEus_E.js";
7
+ import { l as tn } from "./date-formatter-vkCj9Ct-.js";
8
+ import { C as nn, D as rn } from "./dashboard-summary-settings-dialog-DbcWMZsr.js";
9
+ import { u as on } from "./use-debounced-dirty-check-BwAbnX_5.js";
10
+ import { s as Ye } from "./normalize-dashboard-for-dirty-check-5KpZN8xr.js";
11
+ import { S as zs } from "./use-create-flow-overlay-state-UruHbtfS.js";
12
+ import { B as cn } from "./braces-0bzwctGp.js";
13
+ /**
14
+ * @license lucide-react v0.453.0 - ISC
15
+ *
16
+ * This source code is licensed under the ISC license.
17
+ * See the LICENSE file in the root directory of this source tree.
18
+ */
19
+ const ln = Z("Glasses", [
20
+ ["circle", { cx: "6", cy: "15", r: "4", key: "vux9w4" }],
21
+ ["circle", { cx: "18", cy: "15", r: "4", key: "18o8ve" }],
22
+ ["path", { d: "M14 15a2 2 0 0 0-2-2 2 2 0 0 0-2 2", key: "1ag4bs" }],
23
+ ["path", { d: "M2.5 13 5 7c.7-1.3 1.4-2 3-2", key: "1hm1gs" }],
24
+ ["path", { d: "M21.5 13 19 7c-.7-1.3-1.5-2-3-2", key: "1r31ai" }]
25
+ ]);
26
+ /**
27
+ * @license lucide-react v0.453.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */
32
+ const dn = Z("Menu", [
33
+ ["line", { x1: "4", x2: "20", y1: "12", y2: "12", key: "1e0a9i" }],
34
+ ["line", { x1: "4", x2: "20", y1: "6", y2: "6", key: "1owob3" }],
35
+ ["line", { x1: "4", x2: "20", y1: "18", y2: "18", key: "yk5zj1" }]
36
+ ]);
37
+ /**
38
+ * @license lucide-react v0.453.0 - ISC
39
+ *
40
+ * This source code is licensed under the ISC license.
41
+ * See the LICENSE file in the root directory of this source tree.
42
+ */
43
+ const un = Z("Monitor", [
44
+ ["rect", { width: "20", height: "14", x: "2", y: "3", rx: "2", key: "48i651" }],
45
+ ["line", { x1: "8", x2: "16", y1: "21", y2: "21", key: "1svkeh" }],
46
+ ["line", { x1: "12", x2: "12", y1: "17", y2: "21", key: "vw1qmm" }]
47
+ ]);
48
+ /**
49
+ * @license lucide-react v0.453.0 - ISC
50
+ *
51
+ * This source code is licensed under the ISC license.
52
+ * See the LICENSE file in the root directory of this source tree.
53
+ */
54
+ const mn = Z("Moon", [
55
+ ["path", { d: "M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z", key: "a7tn18" }]
56
+ ]);
57
+ /**
58
+ * @license lucide-react v0.453.0 - ISC
59
+ *
60
+ * This source code is licensed under the ISC license.
61
+ * See the LICENSE file in the root directory of this source tree.
62
+ */
63
+ const hn = Z("ShieldX", [
64
+ [
65
+ "path",
66
+ {
67
+ d: "M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",
68
+ key: "oel41y"
69
+ }
70
+ ],
71
+ ["path", { d: "m14.5 9.5-5 5", key: "17q4r4" }],
72
+ ["path", { d: "m9.5 9.5 5 5", key: "18nt4w" }]
73
+ ]);
74
+ /**
75
+ * @license lucide-react v0.453.0 - ISC
76
+ *
77
+ * This source code is licensed under the ISC license.
78
+ * See the LICENSE file in the root directory of this source tree.
79
+ */
80
+ const pn = Z("Sun", [
81
+ ["circle", { cx: "12", cy: "12", r: "4", key: "4exip2" }],
82
+ ["path", { d: "M12 2v2", key: "tus03m" }],
83
+ ["path", { d: "M12 20v2", key: "1lh1kg" }],
84
+ ["path", { d: "m4.93 4.93 1.41 1.41", key: "149t6j" }],
85
+ ["path", { d: "m17.66 17.66 1.41 1.41", key: "ptbguv" }],
86
+ ["path", { d: "M2 12h2", key: "1t8f8n" }],
87
+ ["path", { d: "M20 12h2", key: "1q8mjw" }],
88
+ ["path", { d: "m6.34 17.66-1.41 1.41", key: "1m8zz5" }],
89
+ ["path", { d: "m19.07 4.93-1.41 1.41", key: "1shlcs" }]
90
+ ]);
91
+ var is = { exports: {} }, Xe = {};
92
+ /**
93
+ * @license React
94
+ * use-sync-external-store-shim.production.js
95
+ *
96
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
97
+ *
98
+ * This source code is licensed under the MIT license found in the
99
+ * LICENSE file in the root directory of this source tree.
100
+ */
101
+ var js;
102
+ function fn() {
103
+ if (js) return Xe;
104
+ js = 1;
105
+ var s = ma;
106
+ function n(u, r) {
107
+ return u === r && (u !== 0 || 1 / u === 1 / r) || u !== u && r !== r;
108
+ }
109
+ var t = typeof Object.is == "function" ? Object.is : n, a = s.useState, c = s.useEffect, l = s.useLayoutEffect, h = s.useDebugValue;
110
+ function m(u, r) {
111
+ var p = r(), g = a({ inst: { value: p, getSnapshot: r } }), y = g[0].inst, x = g[1];
112
+ return l(
113
+ function() {
114
+ y.value = p, y.getSnapshot = r, f(y) && x({ inst: y });
115
+ },
116
+ [u, p, r]
117
+ ), c(
118
+ function() {
119
+ return f(y) && x({ inst: y }), u(function() {
120
+ f(y) && x({ inst: y });
121
+ });
122
+ },
123
+ [u]
124
+ ), h(p), p;
125
+ }
126
+ function f(u) {
127
+ var r = u.getSnapshot;
128
+ u = u.value;
129
+ try {
130
+ var p = r();
131
+ return !t(u, p);
132
+ } catch {
133
+ return !0;
134
+ }
135
+ }
136
+ function v(u, r) {
137
+ return r();
138
+ }
139
+ var d = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? v : m;
140
+ return Xe.useSyncExternalStore = s.useSyncExternalStore !== void 0 ? s.useSyncExternalStore : d, Xe;
141
+ }
142
+ var Ze = {};
143
+ /**
144
+ * @license React
145
+ * use-sync-external-store-shim.development.js
146
+ *
147
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
148
+ *
149
+ * This source code is licensed under the MIT license found in the
150
+ * LICENSE file in the root directory of this source tree.
151
+ */
152
+ var Bs;
153
+ function gn() {
154
+ return Bs || (Bs = 1, process.env.NODE_ENV !== "production" && function() {
155
+ function s(p, g) {
156
+ return p === g && (p !== 0 || 1 / p === 1 / g) || p !== p && g !== g;
157
+ }
158
+ function n(p, g) {
159
+ d || c.startTransition === void 0 || (d = !0, console.error(
160
+ "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
161
+ ));
162
+ var y = g();
163
+ if (!u) {
164
+ var x = g();
165
+ l(y, x) || (console.error(
166
+ "The result of getSnapshot should be cached to avoid an infinite loop"
167
+ ), u = !0);
168
+ }
169
+ x = h({
170
+ inst: { value: y, getSnapshot: g }
171
+ });
172
+ var C = x[0].inst, L = x[1];
173
+ return f(
174
+ function() {
175
+ C.value = y, C.getSnapshot = g, t(C) && L({ inst: C });
176
+ },
177
+ [p, y, g]
178
+ ), m(
179
+ function() {
180
+ return t(C) && L({ inst: C }), p(function() {
181
+ t(C) && L({ inst: C });
182
+ });
183
+ },
184
+ [p]
185
+ ), v(y), y;
186
+ }
187
+ function t(p) {
188
+ var g = p.getSnapshot;
189
+ p = p.value;
190
+ try {
191
+ var y = g();
192
+ return !l(p, y);
193
+ } catch {
194
+ return !0;
195
+ }
196
+ }
197
+ function a(p, g) {
198
+ return g();
199
+ }
200
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
201
+ var c = ma, l = typeof Object.is == "function" ? Object.is : s, h = c.useState, m = c.useEffect, f = c.useLayoutEffect, v = c.useDebugValue, d = !1, u = !1, r = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? a : n;
202
+ Ze.useSyncExternalStore = c.useSyncExternalStore !== void 0 ? c.useSyncExternalStore : r, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
203
+ }()), Ze;
204
+ }
205
+ process.env.NODE_ENV === "production" ? is.exports = fn() : is.exports = gn();
206
+ var vn = is.exports;
207
+ const Le = ["light", "dark", "system"];
208
+ function bn() {
209
+ const { theme: s, setTheme: n } = Ka(), t = N(
210
+ (h) => h.actions.setDashboardTheme
211
+ );
212
+ function a() {
213
+ const h = Le.includes(s) ? s : "system", m = Le[(Le.indexOf(h) + 1) % Le.length];
214
+ n(m), t(m);
215
+ }
216
+ const c = s === "light" ? pn : s === "dark" ? mn : un, l = s === "light" ? "Theme: light (click for dark)" : s === "dark" ? "Theme: dark (click for system)" : "Theme: system (click for light)";
217
+ return /* @__PURE__ */ e(
218
+ M,
219
+ {
220
+ type: "button",
221
+ variant: "ghost",
222
+ size: "xs",
223
+ className: "h-7 w-7 p-0 text-muted-foreground hover:text-foreground",
224
+ onClick: a,
225
+ "aria-label": l,
226
+ title: l,
227
+ children: /* @__PURE__ */ e(c, { className: "h-3.5 w-3.5", strokeWidth: 1.5 })
228
+ }
229
+ );
230
+ }
231
+ async function yn(s, n, t, a, c) {
232
+ if (!c)
233
+ return null;
234
+ const l = JSON.stringify(t), h = `${s}/v1/lens`;
235
+ return await ls(h, c, {
236
+ name: n,
237
+ template: l,
238
+ filterValues: a,
239
+ operation: "create"
240
+ });
241
+ }
242
+ async function cs(s, n, t) {
243
+ if (!t)
244
+ return null;
245
+ const { id: a, template: c, filterValues: l, isDefault: h, shared: m } = n, f = `${s}/v1/lens`;
246
+ return await ls(f, t, {
247
+ lensId: a,
248
+ template: c,
249
+ filterValues: l,
250
+ isDefault: h,
251
+ shared: m,
252
+ operation: "update"
253
+ });
254
+ }
255
+ async function Sn(s, n, t) {
256
+ if (!t)
257
+ return null;
258
+ const a = `${s}/v1/lens`;
259
+ return await ls(a, t, {
260
+ operation: "delete",
261
+ lensId: n
262
+ });
263
+ }
264
+ function Nn({ open: s, onOpenChange: n } = {}) {
265
+ const [t, a] = S(""), [c, l] = S(!1), h = N((D) => D.lenses), { setLenses: m, setSelectedLensId: f } = Qs(), [v, d] = S(!1), [u, r] = S(!1), p = s !== void 0, g = p ? s : u, y = (D) => {
266
+ p || r(D), n == null || n(D);
267
+ }, x = N((D) => D.dashboard), C = N((D) => D.filterValues), { authToken: L, tokenProps: R } = H();
268
+ async function T() {
269
+ d(!0);
270
+ const D = await yn(
271
+ R.apiServiceUrl,
272
+ t,
273
+ x,
274
+ C,
275
+ L == null ? void 0 : L.accessToken
276
+ );
277
+ D && (m([...h || [], D]), f(D.id), y(!1)), d(!1);
278
+ }
279
+ return /* @__PURE__ */ o(ds, { open: g, onOpenChange: y, children: [
280
+ p ? null : /* @__PURE__ */ e(Qa, { asChild: !0, children: /* @__PURE__ */ o(
281
+ M,
282
+ {
283
+ variant: "secondary",
284
+ className: "h-7 p-2",
285
+ size: "sm",
286
+ children: [
287
+ /* @__PURE__ */ e(Oe, { className: "mr-2 h-4 w-4" }),
288
+ "Lens"
289
+ ]
290
+ }
291
+ ) }),
292
+ /* @__PURE__ */ o(us, { className: "sm:max-w-[425px]", children: [
293
+ /* @__PURE__ */ o(ms, { children: [
294
+ /* @__PURE__ */ e(hs, { children: "Create Lens" }),
295
+ /* @__PURE__ */ e(Ws, { children: "Lenses are private by default and are only visible to you." })
296
+ ] }),
297
+ /* @__PURE__ */ e("div", { className: "grid gap-4 py-4", children: /* @__PURE__ */ o("div", { className: "grid grid-cols-8 items-center gap-4", children: [
298
+ /* @__PURE__ */ e(es, { className: "text-right", children: "Name" }),
299
+ /* @__PURE__ */ e(
300
+ le,
301
+ {
302
+ value: t,
303
+ onChange: (D) => {
304
+ a(D.target.value);
305
+ },
306
+ id: "name",
307
+ className: "col-span-7 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"
308
+ }
309
+ )
310
+ ] }) }),
311
+ c && /* @__PURE__ */ e("p", { className: "text-sm", children: "The lens name already exists. Use a differnet name." }),
312
+ /* @__PURE__ */ e(Wa, { children: /* @__PURE__ */ e(
313
+ M,
314
+ {
315
+ size: "sm",
316
+ variant: "outline",
317
+ type: "submit",
318
+ onClick: T,
319
+ disabled: v,
320
+ children: v ? "Creating..." : "Add"
321
+ }
322
+ ) })
323
+ ] })
324
+ ] });
325
+ }
326
+ function xn({ includeLabel: s = !1 } = {}) {
327
+ const n = N((d) => d.lenses), t = N((d) => d.selectedLensId), { setLenses: a, setSelectedLensId: c } = Qs(), { authToken: l, tokenProps: h } = H();
328
+ async function m(d) {
329
+ c(d);
330
+ }
331
+ async function f(d) {
332
+ if (await Sn(h.apiServiceUrl, d, l == null ? void 0 : l.accessToken)) {
333
+ const r = n == null ? void 0 : n.filter((p) => p.id !== d);
334
+ a(r || []), c("original");
335
+ }
336
+ }
337
+ async function v(d) {
338
+ const u = n == null ? void 0 : n.map((g) => g.id === d.id ? {
339
+ ...g,
340
+ isDefault: !d.isDefault
341
+ } : {
342
+ ...g,
343
+ isDefault: !1
344
+ });
345
+ a(u || []);
346
+ const r = {
347
+ ...d,
348
+ isDefault: !d.isDefault
349
+ };
350
+ await cs(h.apiServiceUrl, r, l == null ? void 0 : l.accessToken);
351
+ const p = n == null ? void 0 : n.find((g) => g.isDefault);
352
+ if (p && p.id !== d.id) {
353
+ const g = {
354
+ ...p,
355
+ isDefault: !1
356
+ };
357
+ await cs(h.apiServiceUrl, g, l == null ? void 0 : l.accessToken);
358
+ }
359
+ }
360
+ return /* @__PURE__ */ o(A, { children: [
361
+ s ? /* @__PURE__ */ o(A, { children: [
362
+ /* @__PURE__ */ e(ce, { className: "px-3", children: "Lenses" }),
363
+ /* @__PURE__ */ e(Ie, {})
364
+ ] }) : null,
365
+ /* @__PURE__ */ o(
366
+ Ja,
367
+ {
368
+ value: t,
369
+ onValueChange: m,
370
+ children: [
371
+ /* @__PURE__ */ e($s, { value: "original", children: "Original" }),
372
+ n == null ? void 0 : n.map((d) => /* @__PURE__ */ o(
373
+ $s,
374
+ {
375
+ className: "group flex justify-between gap-2",
376
+ value: d.id,
377
+ children: [
378
+ /* @__PURE__ */ e("p", { children: d.name }),
379
+ /* @__PURE__ */ o("span", { className: "flex items-center gap-3", children: [
380
+ /* @__PURE__ */ e(
381
+ Js,
382
+ {
383
+ onClick: (u) => {
384
+ u.preventDefault(), v(d);
385
+ },
386
+ className: Y(
387
+ "size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",
388
+ {
389
+ invisible: !d.isDefault,
390
+ "text-green-500": d.isDefault
391
+ }
392
+ ),
393
+ strokeWidth: 1.5
394
+ }
395
+ ),
396
+ /* @__PURE__ */ e(
397
+ Ys,
398
+ {
399
+ onClick: (u) => {
400
+ u.preventDefault(), f(d.id);
401
+ },
402
+ className: "invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",
403
+ strokeWidth: 1.5
404
+ }
405
+ )
406
+ ] })
407
+ ]
408
+ },
409
+ d.id
410
+ ))
411
+ ]
412
+ }
413
+ )
414
+ ] });
415
+ }
416
+ function Dn() {
417
+ const { displayPreferences: s, shouldShowElement: n } = Ya(), { currentUser: t, userContext: a } = ps(), c = B(
418
+ () => Xa(t),
419
+ [t]
420
+ ), l = B(() => (m) => c && c[m] !== void 0 && c[m] === !1 ? !1 : n(m), [c, n, s]), h = B(
421
+ () => {
422
+ var m, f, v, d, u;
423
+ return {
424
+ canEdit: ((m = a == null ? void 0 : a.permissions) == null ? void 0 : m.canEdit) ?? tt(t),
425
+ canUseFilters: ((f = a == null ? void 0 : a.permissions) == null ? void 0 : f.canEdit) ?? at(t),
426
+ canManageDashboards: ((v = a == null ? void 0 : a.permissions) == null ? void 0 : v.canCreateDashboard) ?? st(t),
427
+ canCreateDashboards: ((d = a == null ? void 0 : a.permissions) == null ? void 0 : d.canCreateDashboard) ?? et(t),
428
+ canAccessVisuals: ((u = a == null ? void 0 : a.permissions) == null ? void 0 : u.canEdit) ?? Za(t)
429
+ };
430
+ },
431
+ [t, a]
432
+ );
433
+ return {
434
+ displayPreferences: s,
435
+ shouldShowElement: l,
436
+ permissions: h,
437
+ currentUser: t
438
+ };
439
+ }
440
+ const wn = async (s, n, t) => {
441
+ const a = `${s}/management/v1/groups`;
442
+ return await Zs(a, n, t);
443
+ }, Cn = async (s, n, t) => {
444
+ const a = `${s}/management/v1/groups/${t}`;
445
+ await Xs(a, n, "DELETE");
446
+ }, En = async (s, n, t, a) => {
447
+ const c = `${s}/management/v1/groups/${t}/members`;
448
+ return await Zs(c, n, a);
449
+ }, Mn = async (s, n, t, a) => {
450
+ const c = `${s}/management/v1/groups/${t}/members`;
451
+ await Xs(c, n, "DELETE", a);
452
+ };
453
+ function An() {
454
+ const { authToken: s, tokenProps: n } = H(), t = Pe();
455
+ return _e({
456
+ mutationFn: (a) => wn(n.apiServiceUrl, (s == null ? void 0 : s.accessToken) || "", a),
457
+ onSuccess: () => {
458
+ t.invalidateQueries({ queryKey: ["groups"] }), k.success("Group created successfully");
459
+ },
460
+ onError: (a) => {
461
+ console.error("Failed to create group:", a), k.error("Failed to create group", {
462
+ description: Ue(a, "Failed to create group")
463
+ });
464
+ }
465
+ });
466
+ }
467
+ function Ln() {
468
+ const { authToken: s, tokenProps: n } = H(), t = Pe();
469
+ return _e({
470
+ mutationFn: (a) => Cn(n.apiServiceUrl, (s == null ? void 0 : s.accessToken) || "", a),
471
+ onSuccess: (a, c) => {
472
+ t.invalidateQueries({ queryKey: ["groups"] }), t.removeQueries({ queryKey: ["group", c] }), k.success("Group deleted successfully");
473
+ },
474
+ onError: (a) => {
475
+ console.error("Failed to delete group:", a), k.error("Failed to delete group", {
476
+ description: Ue(a, "Failed to delete group")
477
+ });
478
+ }
479
+ });
480
+ }
481
+ function In() {
482
+ const { authToken: s, tokenProps: n } = H(), t = Pe();
483
+ return _e({
484
+ mutationFn: ({
485
+ groupId: a,
486
+ data: c
487
+ }) => En(n.apiServiceUrl, (s == null ? void 0 : s.accessToken) || "", a, c),
488
+ onSuccess: (a, c) => {
489
+ t.invalidateQueries({ queryKey: ["group", c.groupId] }), t.invalidateQueries({
490
+ queryKey: ["group-members", c.groupId]
491
+ }), t.invalidateQueries({ queryKey: ["groups"] }), k.success("Members added successfully");
492
+ },
493
+ onError: (a) => {
494
+ console.error("Failed to add group members:", a), k.error("Failed to add members", {
495
+ description: Ue(a, "Failed to add members")
496
+ });
497
+ }
498
+ });
499
+ }
500
+ function On() {
501
+ const { authToken: s, tokenProps: n } = H(), t = Pe();
502
+ return _e({
503
+ mutationFn: ({
504
+ groupId: a,
505
+ data: c
506
+ }) => Mn(n.apiServiceUrl, (s == null ? void 0 : s.accessToken) || "", a, c),
507
+ onSuccess: (a, c) => {
508
+ t.invalidateQueries({ queryKey: ["group", c.groupId] }), t.invalidateQueries({
509
+ queryKey: ["group-members", c.groupId]
510
+ }), t.invalidateQueries({ queryKey: ["groups"] }), k.success("Members removed successfully");
511
+ },
512
+ onError: (a) => {
513
+ console.error("Failed to remove group members:", a), k.error("Failed to remove members", {
514
+ description: Ue(a, "Failed to remove members")
515
+ });
516
+ }
517
+ });
518
+ }
519
+ function kn({
520
+ onSuccess: s,
521
+ tenantId: n,
522
+ isTenantUser: t
523
+ }) {
524
+ const [a, c] = S(""), [l, h] = S(""), [m, f] = S({}), v = An(), d = () => {
525
+ const r = {};
526
+ return a.trim() ? a.length < 3 ? r.name = "Group name must be at least 3 characters" : a.length > 50 && (r.name = "Group name must be less than 50 characters") : r.name = "Group name is required", l && l.length > 200 && (r.description = "Description must be less than 200 characters"), f(r), Object.keys(r).length === 0;
527
+ };
528
+ return /* @__PURE__ */ o("form", { onSubmit: async (r) => {
529
+ if (r.preventDefault(), !d()) return;
530
+ const p = {
531
+ name: a.trim(),
532
+ description: l.trim() || void 0,
533
+ type: t ? "TENANT_GROUP" : "ORG_GROUP",
534
+ ...t && n ? { tenantId: n } : {}
535
+ };
536
+ try {
537
+ await v.mutateAsync(p), c(""), h(""), f({}), s();
538
+ } catch (g) {
539
+ console.error("Failed to create group:", g);
540
+ }
541
+ }, className: "space-y-6", children: [
542
+ /* @__PURE__ */ o("div", { className: "space-y-4", children: [
543
+ /* @__PURE__ */ o("div", { className: "space-y-2", children: [
544
+ /* @__PURE__ */ o(es, { htmlFor: "group-name", children: [
545
+ "Group Name ",
546
+ /* @__PURE__ */ e("span", { className: "text-destructive", children: "*" })
547
+ ] }),
548
+ /* @__PURE__ */ e(
549
+ le,
550
+ {
551
+ id: "group-name",
552
+ placeholder: "e.g., Marketing Team, Engineering Squad",
553
+ value: a,
554
+ onChange: (r) => {
555
+ c(r.target.value), m.name && f((p) => ({ ...p, name: "" }));
556
+ },
557
+ className: m.name ? "border-destructive" : "",
558
+ disabled: v.isPending
559
+ }
560
+ ),
561
+ m.name && /* @__PURE__ */ e("p", { className: "text-sm text-destructive", children: m.name })
562
+ ] }),
563
+ /* @__PURE__ */ o("div", { className: "space-y-2", children: [
564
+ /* @__PURE__ */ o(es, { htmlFor: "group-description", children: [
565
+ "Description",
566
+ /* @__PURE__ */ e("span", { className: "ml-2 text-xs text-muted-foreground", children: "(optional)" })
567
+ ] }),
568
+ /* @__PURE__ */ e(
569
+ nt,
570
+ {
571
+ id: "group-description",
572
+ placeholder: "Describe the purpose of this group...",
573
+ value: l,
574
+ onChange: (r) => {
575
+ h(r.target.value), m.description && f((p) => ({ ...p, description: "" }));
576
+ },
577
+ className: m.description ? "border-destructive" : "",
578
+ disabled: v.isPending,
579
+ rows: 3
580
+ }
581
+ ),
582
+ m.description && /* @__PURE__ */ e("p", { className: "text-sm text-destructive", children: m.description }),
583
+ /* @__PURE__ */ o("p", { className: "text-xs text-muted-foreground", children: [
584
+ l.length,
585
+ "/200 characters"
586
+ ] })
587
+ ] }),
588
+ /* @__PURE__ */ e("div", { className: "rounded-lg border bg-muted/50 p-4", children: /* @__PURE__ */ o("div", { className: "flex gap-3", children: [
589
+ /* @__PURE__ */ e(rt, { className: "h-4 w-4 mt-0.5 text-muted-foreground" }),
590
+ /* @__PURE__ */ e("div", { className: "text-sm text-muted-foreground", children: "This group will be accessible to users in your workspace. You can add members after creating the group." })
591
+ ] }) })
592
+ ] }),
593
+ /* @__PURE__ */ o("div", { className: "flex justify-end gap-3", children: [
594
+ /* @__PURE__ */ e(
595
+ M,
596
+ {
597
+ type: "button",
598
+ variant: "outline",
599
+ onClick: () => {
600
+ c(""), h(""), f({});
601
+ },
602
+ disabled: v.isPending,
603
+ children: "Clear"
604
+ }
605
+ ),
606
+ /* @__PURE__ */ e(
607
+ M,
608
+ {
609
+ type: "submit",
610
+ disabled: v.isPending || !a.trim(),
611
+ children: v.isPending ? /* @__PURE__ */ o(A, { children: [
612
+ /* @__PURE__ */ e(X, { className: "mr-2 h-4 w-4 animate-spin" }),
613
+ "Creating..."
614
+ ] }) : /* @__PURE__ */ o(A, { children: [
615
+ /* @__PURE__ */ e(K, { className: "mr-2 h-4 w-4" }),
616
+ "Create Group"
617
+ ] })
618
+ }
619
+ )
620
+ ] })
621
+ ] });
622
+ }
623
+ function Tn(s, n = []) {
624
+ let t = [];
625
+ function a(l, h) {
626
+ const m = E.createContext(h);
627
+ m.displayName = l + "Context";
628
+ const f = t.length;
629
+ t = [...t, h];
630
+ const v = (u) => {
631
+ var C;
632
+ const { scope: r, children: p, ...g } = u, y = ((C = r == null ? void 0 : r[s]) == null ? void 0 : C[f]) || m, x = E.useMemo(() => g, Object.values(g));
633
+ return /* @__PURE__ */ e(y.Provider, { value: x, children: p });
634
+ };
635
+ v.displayName = l + "Provider";
636
+ function d(u, r) {
637
+ var y;
638
+ const p = ((y = r == null ? void 0 : r[s]) == null ? void 0 : y[f]) || m, g = E.useContext(p);
639
+ if (g) return g;
640
+ if (h !== void 0) return h;
641
+ throw new Error(`\`${u}\` must be used within \`${l}\``);
642
+ }
643
+ return [v, d];
644
+ }
645
+ const c = () => {
646
+ const l = t.map((h) => E.createContext(h));
647
+ return function(m) {
648
+ const f = (m == null ? void 0 : m[s]) || l;
649
+ return E.useMemo(
650
+ () => ({ [`__scope${s}`]: { ...m, [s]: f } }),
651
+ [m, f]
652
+ );
653
+ };
654
+ };
655
+ return c.scopeName = s, [a, Pn(c, ...n)];
656
+ }
657
+ function Pn(...s) {
658
+ const n = s[0];
659
+ if (s.length === 1) return n;
660
+ const t = () => {
661
+ const a = s.map((c) => ({
662
+ useScope: c(),
663
+ scopeName: c.scopeName
664
+ }));
665
+ return function(l) {
666
+ const h = a.reduce((m, { useScope: f, scopeName: v }) => {
667
+ const u = f(l)[`__scope${v}`];
668
+ return { ...m, ...u };
669
+ }, {});
670
+ return E.useMemo(() => ({ [`__scope${n.scopeName}`]: h }), [h]);
671
+ };
672
+ };
673
+ return t.scopeName = n.scopeName, t;
674
+ }
675
+ var _n = [
676
+ "a",
677
+ "button",
678
+ "div",
679
+ "form",
680
+ "h2",
681
+ "h3",
682
+ "img",
683
+ "input",
684
+ "label",
685
+ "li",
686
+ "nav",
687
+ "ol",
688
+ "p",
689
+ "select",
690
+ "span",
691
+ "svg",
692
+ "ul"
693
+ ], fs = _n.reduce((s, n) => {
694
+ const t = ot(`Primitive.${n}`), a = E.forwardRef((c, l) => {
695
+ const { asChild: h, ...m } = c, f = h ? t : n;
696
+ return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ e(f, { ...m, ref: l });
697
+ });
698
+ return a.displayName = `Primitive.${n}`, { ...s, [n]: a };
699
+ }, {});
700
+ function Un() {
701
+ return vn.useSyncExternalStore(
702
+ Rn,
703
+ () => !0,
704
+ () => !1
705
+ );
706
+ }
707
+ function Rn() {
708
+ return () => {
709
+ };
710
+ }
711
+ var gs = "Avatar", [Gn] = Tn(gs), [Fn, ha] = Gn(gs), pa = E.forwardRef(
712
+ (s, n) => {
713
+ const { __scopeAvatar: t, ...a } = s, [c, l] = E.useState("idle");
714
+ return /* @__PURE__ */ e(
715
+ Fn,
716
+ {
717
+ scope: t,
718
+ imageLoadingStatus: c,
719
+ onImageLoadingStatusChange: l,
720
+ children: /* @__PURE__ */ e(fs.span, { ...a, ref: n })
721
+ }
722
+ );
723
+ }
724
+ );
725
+ pa.displayName = gs;
726
+ var fa = "AvatarImage", ga = E.forwardRef(
727
+ (s, n) => {
728
+ const { __scopeAvatar: t, src: a, onLoadingStatusChange: c = () => {
729
+ }, ...l } = s, h = ha(fa, t), m = $n(a, l), f = it((v) => {
730
+ c(v), h.onImageLoadingStatusChange(v);
731
+ });
732
+ return ss(() => {
733
+ m !== "idle" && f(m);
734
+ }, [m, f]), m === "loaded" ? /* @__PURE__ */ e(fs.img, { ...l, ref: n, src: a }) : null;
735
+ }
736
+ );
737
+ ga.displayName = fa;
738
+ var va = "AvatarFallback", ba = E.forwardRef(
739
+ (s, n) => {
740
+ const { __scopeAvatar: t, delayMs: a, ...c } = s, l = ha(va, t), [h, m] = E.useState(a === void 0);
741
+ return E.useEffect(() => {
742
+ if (a !== void 0) {
743
+ const f = window.setTimeout(() => m(!0), a);
744
+ return () => window.clearTimeout(f);
745
+ }
746
+ }, [a]), h && l.imageLoadingStatus !== "loaded" ? /* @__PURE__ */ e(fs.span, { ...c, ref: n }) : null;
747
+ }
748
+ );
749
+ ba.displayName = va;
750
+ function Ks(s, n) {
751
+ return s ? n ? (s.src !== n && (s.src = n), s.complete && s.naturalWidth > 0 ? "loaded" : "loading") : "error" : "idle";
752
+ }
753
+ function $n(s, { referrerPolicy: n, crossOrigin: t }) {
754
+ const a = Un(), c = E.useRef(null), l = a ? (c.current || (c.current = new window.Image()), c.current) : null, [h, m] = E.useState(
755
+ () => Ks(l, s)
756
+ );
757
+ return ss(() => {
758
+ m(Ks(l, s));
759
+ }, [l, s]), ss(() => {
760
+ const f = (u) => () => {
761
+ m(u);
762
+ };
763
+ if (!l) return;
764
+ const v = f("loaded"), d = f("error");
765
+ return l.addEventListener("load", v), l.addEventListener("error", d), n && (l.referrerPolicy = n), typeof t == "string" && (l.crossOrigin = t), () => {
766
+ l.removeEventListener("load", v), l.removeEventListener("error", d);
767
+ };
768
+ }, [l, t, n]), h;
769
+ }
770
+ var ya = pa, Sa = ga, Na = ba;
771
+ const vs = E.forwardRef(({ className: s, ...n }, t) => /* @__PURE__ */ e(
772
+ ya,
773
+ {
774
+ ref: t,
775
+ className: Y(
776
+ "relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
777
+ s
778
+ ),
779
+ ...n
780
+ }
781
+ ));
782
+ vs.displayName = ya.displayName;
783
+ const Vn = E.forwardRef(({ className: s, ...n }, t) => /* @__PURE__ */ e(
784
+ Sa,
785
+ {
786
+ ref: t,
787
+ className: Y("aspect-square h-full w-full", s),
788
+ ...n
789
+ }
790
+ ));
791
+ Vn.displayName = Sa.displayName;
792
+ const bs = E.forwardRef(({ className: s, ...n }, t) => /* @__PURE__ */ e(
793
+ Na,
794
+ {
795
+ ref: t,
796
+ className: Y(
797
+ "flex h-full w-full items-center justify-center rounded-full bg-muted",
798
+ s
799
+ ),
800
+ ...n
801
+ }
802
+ ));
803
+ bs.displayName = Na.displayName;
804
+ function qn({
805
+ open: s,
806
+ onOpenChange: n,
807
+ group: t,
808
+ onUpdate: a
809
+ }) {
810
+ const [c, l] = S("members"), [h, m] = S(""), [f, v] = S([]), [d, u] = S([]), { data: r, isLoading: p, refetch: g } = ct(t.id), y = t.type === "TENANT_GROUP" ? "tenant" : "organization", { users: x, isLoading: C } = lt({
811
+ type: y,
812
+ tenantId: t.tenantId || void 0,
813
+ active: !0,
814
+ limit: 100
815
+ }), L = In(), R = On(), T = (r == null ? void 0 : r.members) || [], D = B(() => new Set(T.map((b) => b.userId)), [T]), G = B(() => x.filter((b) => !D.has(b.id)), [x, D]), Q = B(() => {
816
+ if (!h) return G;
817
+ const b = h.toLowerCase();
818
+ return G.filter(
819
+ (I) => {
820
+ var U, F;
821
+ return ((U = I.name) == null ? void 0 : U.toLowerCase().includes(b)) || ((F = I.email) == null ? void 0 : F.toLowerCase().includes(b));
822
+ }
823
+ );
824
+ }, [G, h]), w = B(() => {
825
+ if (!h) return T;
826
+ const b = h.toLowerCase();
827
+ return T.filter(
828
+ (I) => {
829
+ var U, F, me, z;
830
+ return ((F = (U = I.user) == null ? void 0 : U.name) == null ? void 0 : F.toLowerCase().includes(b)) || ((z = (me = I.user) == null ? void 0 : me.email) == null ? void 0 : z.toLowerCase().includes(b));
831
+ }
832
+ );
833
+ }, [T, h]), W = async () => {
834
+ if (f.length !== 0)
835
+ try {
836
+ await L.mutateAsync({
837
+ groupId: t.id,
838
+ data: {
839
+ userIds: f,
840
+ userType: y === "tenant" ? "tenant" : "org"
841
+ }
842
+ }), v([]), l("members"), g(), a == null || a();
843
+ } catch (b) {
844
+ console.error("Failed to add members:", b);
845
+ }
846
+ }, de = async () => {
847
+ if (d.length !== 0)
848
+ try {
849
+ await R.mutateAsync({
850
+ groupId: t.id,
851
+ data: {
852
+ userIds: d
853
+ }
854
+ }), u([]), g(), a == null || a();
855
+ } catch (b) {
856
+ console.error("Failed to remove members:", b);
857
+ }
858
+ }, Re = (b) => {
859
+ v(
860
+ (I) => I.includes(b) ? I.filter((U) => U !== b) : [...I, b]
861
+ );
862
+ }, ue = (b) => {
863
+ u(
864
+ (I) => I.includes(b) ? I.filter((U) => U !== b) : [...I, b]
865
+ );
866
+ };
867
+ return /* @__PURE__ */ e(A, { children: /* @__PURE__ */ e(ds, { open: s, onOpenChange: n, children: /* @__PURE__ */ o(us, { className: "max-w-3xl max-h-[80vh]", "aria-describedby": "group-members-description", children: [
868
+ /* @__PURE__ */ o(ms, { children: [
869
+ /* @__PURE__ */ e(hs, { children: t.name }),
870
+ /* @__PURE__ */ e("div", { className: "flex items-center gap-2 mt-1", children: /* @__PURE__ */ o("p", { className: "text-sm text-muted-foreground", children: [
871
+ T.length,
872
+ " ",
873
+ T.length === 1 ? "member" : "members"
874
+ ] }) }),
875
+ /* @__PURE__ */ o("p", { id: "group-members-description", className: "sr-only", children: [
876
+ "Add or remove members from the ",
877
+ t.name,
878
+ " group"
879
+ ] })
880
+ ] }),
881
+ /* @__PURE__ */ o(ea, { value: c, onValueChange: (b) => {
882
+ l(b), m(""), u([]);
883
+ }, className: "mt-4", children: [
884
+ /* @__PURE__ */ o(sa, { className: "grid w-full grid-cols-2", children: [
885
+ /* @__PURE__ */ e(ke, { value: "members", children: "Current Members" }),
886
+ /* @__PURE__ */ e(ke, { value: "add", children: "Add Members" })
887
+ ] }),
888
+ /* @__PURE__ */ o(Te, { value: "members", className: "mt-4 space-y-4", children: [
889
+ /* @__PURE__ */ o("div", { className: "relative", children: [
890
+ /* @__PURE__ */ e(as, { className: "absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }),
891
+ /* @__PURE__ */ e(
892
+ le,
893
+ {
894
+ placeholder: "Search members...",
895
+ value: h,
896
+ onChange: (b) => m(b.target.value),
897
+ className: "pl-10"
898
+ }
899
+ )
900
+ ] }),
901
+ /* @__PURE__ */ e(ts, { className: d.length > 0 ? "h-[300px]" : "h-[350px]", children: p ? /* @__PURE__ */ e("div", { className: "space-y-2", children: [1, 2, 3].map((b) => /* @__PURE__ */ e(ns, { className: "h-16 w-full" }, b)) }) : w.length === 0 ? /* @__PURE__ */ o("div", { className: "flex flex-col items-center justify-center py-12 text-muted-foreground", children: [
902
+ /* @__PURE__ */ e(K, { className: "h-12 w-12 mb-3 opacity-50" }),
903
+ /* @__PURE__ */ e("p", { className: "text-sm font-medium", children: h ? "No members found" : "No members yet" }),
904
+ /* @__PURE__ */ e("p", { className: "text-xs mt-1", children: h ? "Try a different search" : 'Switch to the "Add Members" tab to add people to this group' })
905
+ ] }) : /* @__PURE__ */ e("div", { className: "space-y-2", children: w.map((b) => /* @__PURE__ */ e(
906
+ Hn,
907
+ {
908
+ member: b,
909
+ selected: d.includes(b.userId),
910
+ onToggle: () => ue(b.userId)
911
+ },
912
+ b.id
913
+ )) }) }),
914
+ d.length > 0 && /* @__PURE__ */ o("div", { className: "flex items-center justify-between pt-4 border-t", children: [
915
+ /* @__PURE__ */ o("span", { className: "text-sm text-muted-foreground", children: [
916
+ d.length,
917
+ " member",
918
+ d.length !== 1 ? "s" : "",
919
+ " selected"
920
+ ] }),
921
+ /* @__PURE__ */ e(
922
+ M,
923
+ {
924
+ variant: "destructive",
925
+ size: "sm",
926
+ onClick: de,
927
+ disabled: R.isPending,
928
+ children: R.isPending ? /* @__PURE__ */ o(A, { children: [
929
+ /* @__PURE__ */ e(X, { className: "mr-2 h-4 w-4 animate-spin" }),
930
+ "Removing..."
931
+ ] }) : /* @__PURE__ */ o(A, { children: [
932
+ /* @__PURE__ */ e(aa, { className: "mr-2 h-4 w-4" }),
933
+ "Remove Selected"
934
+ ] })
935
+ }
936
+ )
937
+ ] })
938
+ ] }),
939
+ /* @__PURE__ */ o(Te, { value: "add", className: "mt-4 space-y-4", children: [
940
+ /* @__PURE__ */ o("div", { className: "relative", children: [
941
+ /* @__PURE__ */ e(as, { className: "absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }),
942
+ /* @__PURE__ */ e(
943
+ le,
944
+ {
945
+ placeholder: "Search users to add...",
946
+ value: h,
947
+ onChange: (b) => m(b.target.value),
948
+ className: "pl-10"
949
+ }
950
+ )
951
+ ] }),
952
+ /* @__PURE__ */ e(ts, { className: "h-[300px]", children: C ? /* @__PURE__ */ e("div", { className: "space-y-2", children: [1, 2, 3].map((b) => /* @__PURE__ */ e(ns, { className: "h-16 w-full" }, b)) }) : Q.length === 0 ? /* @__PURE__ */ o("div", { className: "flex flex-col items-center justify-center py-12 text-muted-foreground", children: [
953
+ /* @__PURE__ */ e(rs, { className: "h-12 w-12 mb-3 opacity-50" }),
954
+ /* @__PURE__ */ e("p", { className: "text-sm font-medium", children: "No available users" }),
955
+ /* @__PURE__ */ e("p", { className: "text-xs mt-1", children: h ? "Try a different search" : "All eligible users are already members" })
956
+ ] }) : /* @__PURE__ */ e("div", { className: "space-y-2", children: Q.map((b) => /* @__PURE__ */ e(
957
+ zn,
958
+ {
959
+ user: b,
960
+ selected: f.includes(b.id),
961
+ onToggle: () => Re(b.id)
962
+ },
963
+ b.id
964
+ )) }) }),
965
+ f.length > 0 && /* @__PURE__ */ o("div", { className: "flex items-center justify-between pt-4 border-t", children: [
966
+ /* @__PURE__ */ o("span", { className: "text-sm text-muted-foreground", children: [
967
+ f.length,
968
+ " user",
969
+ f.length !== 1 ? "s" : "",
970
+ " selected"
971
+ ] }),
972
+ /* @__PURE__ */ e(
973
+ M,
974
+ {
975
+ onClick: W,
976
+ disabled: L.isPending,
977
+ children: L.isPending ? /* @__PURE__ */ o(A, { children: [
978
+ /* @__PURE__ */ e(X, { className: "mr-2 h-4 w-4 animate-spin" }),
979
+ "Adding..."
980
+ ] }) : /* @__PURE__ */ o(A, { children: [
981
+ /* @__PURE__ */ e(rs, { className: "mr-2 h-4 w-4" }),
982
+ "Add Members"
983
+ ] })
984
+ }
985
+ )
986
+ ] })
987
+ ] })
988
+ ] })
989
+ ] }) }) });
990
+ }
991
+ function Hn({
992
+ member: s,
993
+ selected: n,
994
+ onToggle: t
995
+ }) {
996
+ var c, l, h, m;
997
+ const a = ((l = (c = s.user) == null ? void 0 : c.name) == null ? void 0 : l.split(" ").map((f) => f[0]).join("").toUpperCase()) || "?";
998
+ return /* @__PURE__ */ o(
999
+ "div",
1000
+ {
1001
+ className: "flex items-center gap-3 p-3 rounded-lg border bg-card hover:bg-muted/50 cursor-pointer",
1002
+ onClick: t,
1003
+ children: [
1004
+ /* @__PURE__ */ e(ta, { checked: n }),
1005
+ /* @__PURE__ */ e(vs, { className: "h-8 w-8", children: /* @__PURE__ */ e(bs, { className: "text-xs", children: a }) }),
1006
+ /* @__PURE__ */ o("div", { className: "flex-1", children: [
1007
+ /* @__PURE__ */ e("p", { className: "text-sm font-medium", children: ((h = s.user) == null ? void 0 : h.name) || "Unknown User" }),
1008
+ /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: (m = s.user) == null ? void 0 : m.email })
1009
+ ] })
1010
+ ]
1011
+ }
1012
+ );
1013
+ }
1014
+ function zn({
1015
+ user: s,
1016
+ selected: n,
1017
+ onToggle: t
1018
+ }) {
1019
+ var c;
1020
+ const a = ((c = s.name) == null ? void 0 : c.split(" ").map((l) => l[0]).join("").toUpperCase()) || "?";
1021
+ return /* @__PURE__ */ o(
1022
+ "div",
1023
+ {
1024
+ className: "flex items-center gap-3 p-3 rounded-lg border bg-card hover:bg-muted/50 cursor-pointer",
1025
+ onClick: t,
1026
+ children: [
1027
+ /* @__PURE__ */ e(ta, { checked: n }),
1028
+ /* @__PURE__ */ e(vs, { className: "h-8 w-8", children: /* @__PURE__ */ e(bs, { className: "text-xs", children: a }) }),
1029
+ /* @__PURE__ */ o("div", { className: "flex-1", children: [
1030
+ /* @__PURE__ */ e("p", { className: "text-sm font-medium", children: s.name }),
1031
+ /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: s.email })
1032
+ ] })
1033
+ ]
1034
+ }
1035
+ );
1036
+ }
1037
+ function jn({
1038
+ open: s,
1039
+ onOpenChange: n
1040
+ }) {
1041
+ const [t, a] = S("groups"), [c, l] = S(""), [h, m] = S(null), [f, v] = S(!1), [d, u] = S(null), { tokenProps: r } = H(), { currentUser: p } = ps(), g = Ln(), y = (p == null ? void 0 : p.type) === "tenant", x = r == null ? void 0 : r.tenantId, { groups: C, isLoading: L, refetch: R } = dt({
1042
+ type: y ? "TENANT_GROUP" : "all",
1043
+ tenantId: y ? x : void 0,
1044
+ includeMembers: !1
1045
+ }), T = C.filter(
1046
+ (w) => {
1047
+ var W;
1048
+ return w.name.toLowerCase().includes(c.toLowerCase()) || ((W = w.description) == null ? void 0 : W.toLowerCase().includes(c.toLowerCase()));
1049
+ }
1050
+ ), D = async () => {
1051
+ if (d)
1052
+ try {
1053
+ await g.mutateAsync(d.id), u(null), R();
1054
+ } catch (w) {
1055
+ console.error("Failed to delete group:", w);
1056
+ }
1057
+ }, G = (w) => {
1058
+ m(w), v(!0);
1059
+ }, Q = () => {
1060
+ a("groups"), R();
1061
+ };
1062
+ return /* @__PURE__ */ o(A, { children: [
1063
+ /* @__PURE__ */ e(ds, { open: s, onOpenChange: n, children: /* @__PURE__ */ o(us, { className: "max-w-4xl max-h-[80vh]", children: [
1064
+ /* @__PURE__ */ o(ms, { children: [
1065
+ /* @__PURE__ */ o(hs, { className: "flex items-center gap-2", children: [
1066
+ /* @__PURE__ */ e(K, { className: "h-5 w-5" }),
1067
+ "Group Management"
1068
+ ] }),
1069
+ /* @__PURE__ */ e(Ws, { children: "Manage your groups, create new groups, and control group membership" })
1070
+ ] }),
1071
+ /* @__PURE__ */ o(ea, { value: t, onValueChange: a, className: "mt-4", children: [
1072
+ /* @__PURE__ */ o(sa, { className: "grid w-full grid-cols-2", children: [
1073
+ /* @__PURE__ */ o(ke, { value: "groups", className: "flex items-center gap-2", children: [
1074
+ /* @__PURE__ */ e(K, { className: "h-4 w-4" }),
1075
+ "Groups"
1076
+ ] }),
1077
+ /* @__PURE__ */ o(ke, { value: "create", className: "flex items-center gap-2", children: [
1078
+ /* @__PURE__ */ e(Oe, { className: "h-4 w-4" }),
1079
+ "Create Group"
1080
+ ] })
1081
+ ] }),
1082
+ /* @__PURE__ */ e(Te, { value: "groups", className: "mt-4", children: /* @__PURE__ */ o("div", { className: "space-y-4", children: [
1083
+ /* @__PURE__ */ o("div", { className: "relative", children: [
1084
+ /* @__PURE__ */ e(as, { className: "absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }),
1085
+ /* @__PURE__ */ e(
1086
+ le,
1087
+ {
1088
+ placeholder: "Search groups...",
1089
+ value: c,
1090
+ onChange: (w) => l(w.target.value),
1091
+ className: "pl-10"
1092
+ }
1093
+ )
1094
+ ] }),
1095
+ /* @__PURE__ */ e(ts, { className: "h-[400px]", children: L ? /* @__PURE__ */ e("div", { className: "space-y-3", children: [1, 2, 3].map((w) => /* @__PURE__ */ e(ns, { className: "h-24 w-full" }, w)) }) : T.length === 0 ? /* @__PURE__ */ o("div", { className: "flex flex-col items-center justify-center py-12 text-muted-foreground", children: [
1096
+ /* @__PURE__ */ e(K, { className: "h-12 w-12 mb-3 opacity-50" }),
1097
+ /* @__PURE__ */ e("p", { className: "text-sm font-medium", children: "No groups found" }),
1098
+ /* @__PURE__ */ e("p", { className: "text-xs mt-1", children: c ? "Try a different search" : "Create your first group to get started" })
1099
+ ] }) : /* @__PURE__ */ e("div", { className: "space-y-3", children: T.map((w) => /* @__PURE__ */ e(
1100
+ Bn,
1101
+ {
1102
+ group: w,
1103
+ onManageMembers: () => G(w),
1104
+ onDelete: () => u(w),
1105
+ currentUserId: p == null ? void 0 : p.id
1106
+ },
1107
+ w.id
1108
+ )) }) })
1109
+ ] }) }),
1110
+ /* @__PURE__ */ e(Te, { value: "create", className: "mt-4", children: /* @__PURE__ */ e(
1111
+ kn,
1112
+ {
1113
+ onSuccess: Q,
1114
+ tenantId: x,
1115
+ isTenantUser: y
1116
+ }
1117
+ ) })
1118
+ ] })
1119
+ ] }) }),
1120
+ h && /* @__PURE__ */ e(
1121
+ qn,
1122
+ {
1123
+ open: f,
1124
+ onOpenChange: v,
1125
+ group: h,
1126
+ onUpdate: () => R()
1127
+ }
1128
+ ),
1129
+ /* @__PURE__ */ e(
1130
+ na,
1131
+ {
1132
+ open: !!d,
1133
+ onOpenChange: () => u(null),
1134
+ children: /* @__PURE__ */ o(ra, { children: [
1135
+ /* @__PURE__ */ o(oa, { children: [
1136
+ /* @__PURE__ */ e(ia, { children: "Delete Group" }),
1137
+ /* @__PURE__ */ o(ca, { children: [
1138
+ 'Are you sure you want to delete "',
1139
+ d == null ? void 0 : d.name,
1140
+ '"? This action cannot be undone and will remove all members from the group.'
1141
+ ] })
1142
+ ] }),
1143
+ /* @__PURE__ */ o(la, { children: [
1144
+ /* @__PURE__ */ e(da, { children: "Cancel" }),
1145
+ /* @__PURE__ */ e(
1146
+ os,
1147
+ {
1148
+ onClick: D,
1149
+ disabled: g.isPending,
1150
+ className: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
1151
+ children: g.isPending ? /* @__PURE__ */ o(A, { children: [
1152
+ /* @__PURE__ */ e(X, { className: "mr-2 h-4 w-4 animate-spin" }),
1153
+ "Deleting..."
1154
+ ] }) : "Delete Group"
1155
+ }
1156
+ )
1157
+ ] })
1158
+ ] })
1159
+ }
1160
+ )
1161
+ ] });
1162
+ }
1163
+ function Bn({
1164
+ group: s,
1165
+ onManageMembers: n,
1166
+ onDelete: t,
1167
+ currentUserId: a
1168
+ }) {
1169
+ const c = s.createdBy === a;
1170
+ return /* @__PURE__ */ e("div", { className: "rounded-lg border bg-card p-4 transition-colors hover:bg-muted/50", children: /* @__PURE__ */ o("div", { className: "flex items-start justify-between gap-3", children: [
1171
+ /* @__PURE__ */ o("div", { className: "flex-1 space-y-2", children: [
1172
+ /* @__PURE__ */ o("div", { children: [
1173
+ /* @__PURE__ */ e("h4", { className: "font-medium", children: s.name }),
1174
+ s.description && /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground mt-1", children: s.description })
1175
+ ] }),
1176
+ /* @__PURE__ */ o("div", { className: "flex flex-wrap items-center gap-3 text-xs text-muted-foreground", children: [
1177
+ /* @__PURE__ */ o("span", { className: "flex items-center gap-1", children: [
1178
+ /* @__PURE__ */ e(K, { className: "h-3 w-3" }),
1179
+ s.memberCount,
1180
+ " ",
1181
+ s.memberCount === 1 ? "member" : "members"
1182
+ ] }),
1183
+ /* @__PURE__ */ o("span", { children: [
1184
+ "Created ",
1185
+ tn(new Date(s.createdAt), "MMM d, yyyy")
1186
+ ] })
1187
+ ] })
1188
+ ] }),
1189
+ /* @__PURE__ */ o("div", { className: "flex items-center gap-1", children: [
1190
+ /* @__PURE__ */ e(
1191
+ M,
1192
+ {
1193
+ variant: "ghost",
1194
+ size: "sm",
1195
+ onClick: n,
1196
+ title: "Manage members",
1197
+ children: /* @__PURE__ */ e(rs, { className: "h-4 w-4" })
1198
+ }
1199
+ ),
1200
+ c && /* @__PURE__ */ e(
1201
+ M,
1202
+ {
1203
+ variant: "ghost",
1204
+ size: "sm",
1205
+ onClick: t,
1206
+ title: "Delete group",
1207
+ className: "text-destructive hover:text-destructive",
1208
+ children: /* @__PURE__ */ e(aa, { className: "h-4 w-4" })
1209
+ }
1210
+ )
1211
+ ] })
1212
+ ] }) });
1213
+ }
1214
+ function oe(s, n, t) {
1215
+ var l, h;
1216
+ const a = (s.controls || []).find(
1217
+ (m) => m.id === t
1218
+ );
1219
+ if (a)
1220
+ return a.label;
1221
+ const c = (h = (l = ua(s, n)) == null ? void 0 : l.controls) == null ? void 0 : h.find(
1222
+ (m) => m.id === t
1223
+ );
1224
+ return (c == null ? void 0 : c.label) || t;
1225
+ }
1226
+ function ie(s, n) {
1227
+ var t;
1228
+ return ((t = ua(s, n)) == null ? void 0 : t.title) || n;
1229
+ }
1230
+ function Kn(s) {
1231
+ const { errors: n, dashboard: t } = s;
1232
+ if (!t)
1233
+ return n;
1234
+ const a = /* @__PURE__ */ new Map();
1235
+ for (const c of n) {
1236
+ const l = c.match(
1237
+ /^Card '(.+)' binding for control '(.+)' maps to missing metric '(.+)'\.$/
1238
+ );
1239
+ if (l) {
1240
+ const [, d, u] = l, r = `${d}:${u}:missing-metric`;
1241
+ a.has(r) || a.set(
1242
+ r,
1243
+ `"${ie(t, d)}" has an outdated "${oe(
1244
+ t,
1245
+ d,
1246
+ u
1247
+ )}" mapping. Some choices still point to metrics that are no longer available on this card. Open the card controls and choose replacements.`
1248
+ );
1249
+ continue;
1250
+ }
1251
+ const h = c.match(
1252
+ /^Card '(.+)' binding for control '(.+)' maps to missing group-by field '(.+)'\.$/
1253
+ );
1254
+ if (h) {
1255
+ const [, d, u] = h, r = `${d}:${u}:missing-group-by`;
1256
+ a.has(r) || a.set(
1257
+ r,
1258
+ `"${ie(t, d)}" has an outdated "${oe(
1259
+ t,
1260
+ d,
1261
+ u
1262
+ )}" mapping. Some choices still point to fields that are no longer available on this card. Open the card controls and choose replacements.`
1263
+ );
1264
+ continue;
1265
+ }
1266
+ const m = c.match(
1267
+ /^Card '(.+)' binding for control '(.+)' maps to an invalid metric target\.$/
1268
+ );
1269
+ if (m) {
1270
+ const [, d, u] = m, r = `${d}:${u}:invalid-metric`;
1271
+ a.has(r) || a.set(
1272
+ r,
1273
+ `"${ie(t, d)}" has an invalid "${oe(
1274
+ t,
1275
+ d,
1276
+ u
1277
+ )}" metric mapping. Open the card controls and choose a valid metric for each option.`
1278
+ );
1279
+ continue;
1280
+ }
1281
+ const f = c.match(
1282
+ /^Card '(.+)' binding for control '(.+)' maps to an invalid group-by target\.$/
1283
+ );
1284
+ if (f) {
1285
+ const [, d, u] = f, r = `${d}:${u}:invalid-group-by`;
1286
+ a.has(r) || a.set(
1287
+ r,
1288
+ `"${ie(t, d)}" has an invalid "${oe(
1289
+ t,
1290
+ d,
1291
+ u
1292
+ )}" field mapping. Open the card controls and choose a valid field for each option.`
1293
+ );
1294
+ continue;
1295
+ }
1296
+ const v = c.match(
1297
+ /^Card '(.+)' binding for control '(.+)' requires at least one temporal group-by field\.$/
1298
+ );
1299
+ if (v) {
1300
+ const [, d, u] = v, r = `${d}:${u}:missing-temporal-group-by`;
1301
+ a.has(r) || a.set(
1302
+ r,
1303
+ `"${ie(t, d)}" can no longer use "${oe(
1304
+ t,
1305
+ d,
1306
+ u
1307
+ )}" for time grain because the card does not currently group by a date field.`
1308
+ );
1309
+ continue;
1310
+ }
1311
+ a.set(c, c);
1312
+ }
1313
+ return Array.from(a.values());
1314
+ }
1315
+ function rr() {
1316
+ var _s, Us, Rs, Gs;
1317
+ Qt(), Wt();
1318
+ const {
1319
+ authToken: s,
1320
+ tokenProps: n,
1321
+ id: t
1322
+ } = H(), { isLocalDev: a } = ut(), { permissions: c } = Dn(), l = mt(), { isLoading: h } = ht();
1323
+ N((i) => i.theme);
1324
+ const m = N((i) => i.isDownloadingPdf), f = N(
1325
+ (i) => i.dashboardAssistantDraftScopeKey
1326
+ ), v = N((i) => i.lenses), d = N((i) => i.selectedLensId), u = v == null ? void 0 : v.find((i) => i.id === d), r = N((i) => i.dashboard);
1327
+ N((i) => i.selectedSheetId);
1328
+ const p = N(
1329
+ (i) => i.isDashboardEditing
1330
+ ), { setDashboardTitle: g } = N((i) => i.actions), [y, x] = S(!1), [C, L] = S(!1), [R, T] = S(!1), [D, G] = S(!1), [Q, w] = S(!1), [W, de] = S(!1), [Re, ue] = S(!1), [b, I] = S(!1), [U, F] = S(null), [me, z] = S(!1), [he, pe] = S(null), [ys, fe] = S([]), [Ss, ge] = S(!1), xa = N((i) => i.isDashboardPanelOpen), Da = N(
1331
+ (i) => i.actions.setIsDashboardPanelOpen
1332
+ ), wa = N((i) => i.filterValues), P = N((i) => i.isVisualEditing);
1333
+ Vs((i) => i.card);
1334
+ const ee = Ae(
1335
+ (i) => i.selectedDashboard
1336
+ ), ve = Ae(
1337
+ (i) => i.initialDashboard
1338
+ );
1339
+ Ae((i) => i.selectedVisual), N((i) => i.selectedFrameId), Vs((i) => i.frame);
1340
+ const be = ee ? (Us = ee == null ? void 0 : ee.permissions) == null ? void 0 : Us.canEdit : (_s = ve == null ? void 0 : ve.permissions) == null ? void 0 : _s.canEdit, ye = N((i) => i.showFilters), Ns = pt((i) => i.setPanelOpen), xs = N(
1341
+ (i) => i.showDashboardJSON
1342
+ ), Ge = N((i) => i.onSaveFunction), Ds = N(
1343
+ (i) => i.actions.setShowFilters
1344
+ ), { setIsDashboardEditing: ws, setShowDashboardJSON: Cs } = N(
1345
+ (i) => i.actions
1346
+ ), { setInitialDashboard: Es, clearSelectedDashboard: Fe } = Ae(
1347
+ (i) => i.actions
1348
+ ), { resources: Se } = ft(We.DASHBOARD), { data: $e } = gt(), Ca = ((Rs = $e == null ? void 0 : $e.preference) == null ? void 0 : Rs.defaultDashboardId) || null, { mutate: Ea, isPending: Ma } = vt(), { currentUser: Aa } = ps(), La = bt(Aa), J = ee || ve, Ms = J ? {
1349
+ id: J.id,
1350
+ title: (r == null ? void 0 : r.title) || J.title || "Dashboard"
1351
+ } : null, { handleAddNewFrame: Ia } = yt(), [Ve, qe] = S(!1), [Oa, se] = S(!1), [He, Ne] = S("close"), ae = St(We.DASHBOARD), [$, ze] = S(
1352
+ null
1353
+ ), As = qs(
1354
+ (i) => {
1355
+ window.setTimeout(() => {
1356
+ F(i);
1357
+ }, 0);
1358
+ },
1359
+ []
1360
+ ), ka = async (i, O) => {
1361
+ if (!(r != null && r.id)) {
1362
+ console.log("No dashboard ID found");
1363
+ return;
1364
+ }
1365
+ console.log("Updating dashboard title:", {
1366
+ dashboardId: r.id,
1367
+ newTitle: i,
1368
+ previousTitle: O
1369
+ }), ae.mutate(
1370
+ {
1371
+ resourceId: r.id,
1372
+ data: { title: i }
1373
+ },
1374
+ {
1375
+ onSuccess: () => {
1376
+ console.log("Dashboard title updated successfully"), k.success("Dashboard title updated");
1377
+ },
1378
+ onError: (V) => {
1379
+ console.error("Failed to update dashboard title:", V), k.error("Failed to update dashboard title"), g(O);
1380
+ }
1381
+ }
1382
+ );
1383
+ };
1384
+ Hs(() => {
1385
+ if (Se && Se.length > 0) {
1386
+ const i = r == null ? void 0 : r.id;
1387
+ if (i) {
1388
+ const O = Se.find(
1389
+ (V) => V.id === i
1390
+ );
1391
+ O && Es(O);
1392
+ }
1393
+ }
1394
+ }, [Se, r == null ? void 0 : r.id, Es]);
1395
+ const te = n.orgUserId || n.tenantId, Ls = p && !P && te && be, { setDashboard: je } = N((i) => i.actions), Ta = () => {
1396
+ ws(!0);
1397
+ }, Be = () => {
1398
+ ws(!1), Cs(!1), ze(null), F(null);
1399
+ };
1400
+ Jt(
1401
+ p,
1402
+ r,
1403
+ $,
1404
+ (i) => ze(i)
1405
+ );
1406
+ const { isDirty: Is, isDirtyPending: Pa, resetDirty: xe } = on(
1407
+ r,
1408
+ $,
1409
+ 300,
1410
+ 1e3,
1411
+ Ye
1412
+ ), Os = qs(() => $ ? Ye(r) !== Ye($) : !1, [r, $]), ks = Is || Pa, De = Ve || ae.isPending, _a = () => {
1413
+ Os() ? (Ne("close"), se(!0)) : (Be(), xe());
1414
+ }, Ua = async () => {
1415
+ await Ke({
1416
+ closeAfterSave: !0,
1417
+ navigateHomeAfterSave: He === "home"
1418
+ });
1419
+ }, Ra = () => {
1420
+ $ && je($), Be(), He === "home" && Fe(), Ne("close"), se(!1), xe();
1421
+ }, Ga = () => {
1422
+ $ && (je($), xe());
1423
+ }, Fa = () => {
1424
+ if (p && Os()) {
1425
+ Ne("home"), se(!0);
1426
+ return;
1427
+ }
1428
+ Fe();
1429
+ };
1430
+ async function Ke(i) {
1431
+ const O = N.getState().dashboard;
1432
+ if (!O)
1433
+ return;
1434
+ const V = (i == null ? void 0 : i.closeAfterSave) ?? Ss, za = (i == null ? void 0 : i.navigateHomeAfterSave) ?? !1;
1435
+ ge(V), V && se(!1);
1436
+ const ja = Bt(O);
1437
+ z(!0), pe(null), fe([]), qe(!0);
1438
+ const Ba = {
1439
+ template: O
1440
+ };
1441
+ ae.mutate(
1442
+ {
1443
+ resourceId: O.id,
1444
+ data: Ba
1445
+ },
1446
+ {
1447
+ onSuccess: (_) => {
1448
+ var Ce, Ee, Fs;
1449
+ const j = (_ == null ? void 0 : _.id) || ((Ce = _ == null ? void 0 : _.dashboard) == null ? void 0 : Ce.id) || ((Ee = _ == null ? void 0 : _.resource) == null ? void 0 : Ee.id) || ((Fs = _ == null ? void 0 : _.template) == null ? void 0 : Fs.id) || null;
1450
+ if (!O.id && j) {
1451
+ const Qe = Kt.getState(), Me = Qe.pendingDashboardDraftMigration;
1452
+ (Me == null ? void 0 : Me.scopeKey) === f ? Qe.actions.setPendingDashboardDraftMigrationExpectedDashboardId(
1453
+ j
1454
+ ) : Me && Qe.actions.clearPendingDashboardDraftMigration();
1455
+ }
1456
+ qe(!1), k.success("Dashboard saved!"), ze(ja), z(!1), ge(!1), V && (Be(), xe(), za && Fe()), Ne("close");
1457
+ },
1458
+ onError: (_) => {
1459
+ qe(!1), pe("Failed to save dashboard. Please try again.");
1460
+ const j = _.details, Ce = Array.isArray(
1461
+ j == null ? void 0 : j.errors
1462
+ ) ? (j.errors || []).filter(
1463
+ (Ee) => typeof Ee == "string"
1464
+ ) : [];
1465
+ fe(
1466
+ Kn({
1467
+ errors: Ce,
1468
+ dashboard: O || void 0
1469
+ })
1470
+ ), k.error("Failed to save dashboard");
1471
+ }
1472
+ }
1473
+ );
1474
+ }
1475
+ async function $a() {
1476
+ if (x(!0), !d || !u) return;
1477
+ const i = N.getState().dashboard;
1478
+ if (!i) {
1479
+ x(!1);
1480
+ return;
1481
+ }
1482
+ const O = JSON.stringify(i), V = {
1483
+ ...u,
1484
+ template: O,
1485
+ filterValues: wa
1486
+ };
1487
+ await cs(
1488
+ n.apiServiceUrl,
1489
+ V,
1490
+ s == null ? void 0 : s.accessToken
1491
+ ), k.success("Lens saved"), Ge == null || Ge(i), x(!1);
1492
+ }
1493
+ const Ts = (u == null ? void 0 : u.name) || r.title, ne = !!(r != null && r.id);
1494
+ ae.isPending && console.log("Title during update:", {
1495
+ title: Ts,
1496
+ dashboardStateTitle: r.title,
1497
+ dashboardId: r == null ? void 0 : r.id,
1498
+ currentLensName: u == null ? void 0 : u.name
1499
+ });
1500
+ const Ps = n.orgUserId || n.tenantId && n.endUserId && n.endUserEmail, Va = !!Ps && !!(s != null && s.accessToken) && !!(n != null && n.apiServiceUrl);
1501
+ Hs(() => {
1502
+ !ne && D && G(!1);
1503
+ }, [ne, D]);
1504
+ const qa = l, re = (r == null ? void 0 : r.id) || null, we = !!re && Ca === re, Ha = () => {
1505
+ re && Ea({
1506
+ dashboardId: we ? null : re
1507
+ });
1508
+ };
1509
+ return /* @__PURE__ */ o(
1510
+ "div",
1511
+ {
1512
+ className: "flex h-11 shrink-0 items-center justify-between gap-2 overflow-x-auto border-b px-4 py-2",
1513
+ role: "dashboard-controls",
1514
+ children: [
1515
+ /* @__PURE__ */ o("div", { className: "flex items-center gap-2", children: [
1516
+ Ps && /* @__PURE__ */ o(A, { children: [
1517
+ /* @__PURE__ */ e(
1518
+ Je,
1519
+ {
1520
+ "aria-label": "Manage Dashboards",
1521
+ tooltip: "Manage Dashboards",
1522
+ onClick: () => {
1523
+ Da(!xa);
1524
+ },
1525
+ className: "h-7 w-7 px-0",
1526
+ buttonProps: { size: "xs" },
1527
+ children: /* @__PURE__ */ e(dn, { className: "h-3.5 w-3.5" })
1528
+ }
1529
+ ),
1530
+ qa && !P && /* @__PURE__ */ e(
1531
+ Je,
1532
+ {
1533
+ "aria-label": "Dashboard Hub",
1534
+ tooltip: "Dashboard Hub",
1535
+ onClick: Fa,
1536
+ className: "h-7 w-7 px-0",
1537
+ buttonProps: { size: "xs" },
1538
+ children: /* @__PURE__ */ e(Js, { className: "h-3.5 w-3.5" })
1539
+ }
1540
+ )
1541
+ ] }),
1542
+ !P && l && (h ? /* @__PURE__ */ e(
1543
+ "div",
1544
+ {
1545
+ className: "h-4 w-28 rounded-md bg-muted/70 animate-pulse",
1546
+ "aria-label": "Loading dashboard title",
1547
+ role: "status",
1548
+ children: /* @__PURE__ */ e("span", { className: "sr-only", children: "Loading dashboard title" })
1549
+ }
1550
+ ) : /* @__PURE__ */ o(A, { children: [
1551
+ /* @__PURE__ */ e(
1552
+ Nt,
1553
+ {
1554
+ value: Ts || "Untitled Dashboard",
1555
+ onSave: (i) => {
1556
+ console.log("EditableText onSave called:", {
1557
+ newTitle: i,
1558
+ canEditDashboard: be,
1559
+ dashboardId: r == null ? void 0 : r.id
1560
+ });
1561
+ const O = (r == null ? void 0 : r.title) || "";
1562
+ g(i), ka(i, O);
1563
+ },
1564
+ isEditable: be && !u,
1565
+ displayClassName: "text-[13px] font-medium",
1566
+ inputClassName: "text-[13px] font-medium",
1567
+ placeholder: "Dashboard Title",
1568
+ isPending: ae.isPending
1569
+ }
1570
+ ),
1571
+ Va && re && /* @__PURE__ */ e(xt, { children: /* @__PURE__ */ o(Dt, { children: [
1572
+ /* @__PURE__ */ e(wt, { asChild: !0, children: /* @__PURE__ */ e(
1573
+ M,
1574
+ {
1575
+ variant: "ghost",
1576
+ size: "xs",
1577
+ onClick: Ha,
1578
+ disabled: Ma || !(s != null && s.accessToken) || !(n != null && n.apiServiceUrl),
1579
+ className: "w-7 px-0",
1580
+ "aria-label": we ? "Remove as default dashboard" : "Make this a default dashboard",
1581
+ children: /* @__PURE__ */ e(
1582
+ Ct,
1583
+ {
1584
+ className: Y(
1585
+ "h-3.5 w-3.5 transition-colors",
1586
+ we ? "fill-foreground text-foreground" : "text-muted-foreground hover:text-foreground"
1587
+ )
1588
+ }
1589
+ )
1590
+ }
1591
+ ) }),
1592
+ /* @__PURE__ */ e(Et, { children: /* @__PURE__ */ e("p", { children: we ? "Remove as default dashboard" : "Make this a default dashboard" }) })
1593
+ ] }) })
1594
+ ] }))
1595
+ ] }),
1596
+ /* @__PURE__ */ o("div", { className: "flex items-center gap-2", children: [
1597
+ P && /* @__PURE__ */ o(A, { children: [
1598
+ /* @__PURE__ */ e(Yt, {}),
1599
+ /* @__PURE__ */ e(Xt, {})
1600
+ ] }),
1601
+ !P && l && ((Gs = J == null ? void 0 : J.permissions) == null ? void 0 : Gs.canShare) && /* @__PURE__ */ o(
1602
+ M,
1603
+ {
1604
+ variant: "outline",
1605
+ size: "xs",
1606
+ onClick: () => L(!0),
1607
+ children: [
1608
+ /* @__PURE__ */ e(Mt, { className: "h-3.5 w-3.5" }),
1609
+ "Share"
1610
+ ]
1611
+ }
1612
+ ),
1613
+ !P && p && c.canUseFilters && l && /* @__PURE__ */ e(
1614
+ Zt,
1615
+ {
1616
+ showFilters: ye,
1617
+ onToggleFilters: () => {
1618
+ ye || Ns("dashboard", !1), Ds(!ye);
1619
+ },
1620
+ onAddFilter: () => {
1621
+ ye || (Ns("dashboard", !1), Ds(!0));
1622
+ },
1623
+ onAddControl: () => {
1624
+ As("create");
1625
+ },
1626
+ onManageControls: () => As("manage")
1627
+ }
1628
+ ),
1629
+ p && !P && l && U ? /* @__PURE__ */ e(
1630
+ en,
1631
+ {
1632
+ open: !0,
1633
+ onOpenChange: (i) => {
1634
+ i || F(null);
1635
+ },
1636
+ showTrigger: !1,
1637
+ initialMode: U
1638
+ }
1639
+ ) : null,
1640
+ p && !P && te && u && a && l && /* @__PURE__ */ o(
1641
+ M,
1642
+ {
1643
+ variant: "secondary",
1644
+ size: "xs",
1645
+ disabled: y,
1646
+ onClick: $a,
1647
+ children: [
1648
+ /* @__PURE__ */ e(zs, { className: "h-3.5 w-3.5" }),
1649
+ "Save Lens"
1650
+ ]
1651
+ }
1652
+ ),
1653
+ p && !P && l && /* @__PURE__ */ o(
1654
+ M,
1655
+ {
1656
+ variant: "outline",
1657
+ size: "xs",
1658
+ disabled: !p,
1659
+ onClick: () => Ia(),
1660
+ children: [
1661
+ /* @__PURE__ */ e(Oe, { className: "h-3.5 w-3.5" }),
1662
+ "Visual"
1663
+ ]
1664
+ }
1665
+ ),
1666
+ !P && !p && be && l && /* @__PURE__ */ o(M, { size: "xs", onClick: Ta, children: [
1667
+ /* @__PURE__ */ e(At, { className: "h-3.5 w-3.5" }),
1668
+ "Edit"
1669
+ ] }),
1670
+ Ls && l && Is && /* @__PURE__ */ o(
1671
+ M,
1672
+ {
1673
+ variant: "outline",
1674
+ size: "xs",
1675
+ onClick: Ga,
1676
+ disabled: De,
1677
+ children: [
1678
+ /* @__PURE__ */ e(Lt, { className: "h-3.5 w-3.5" }),
1679
+ "Undo"
1680
+ ]
1681
+ }
1682
+ ),
1683
+ Ls && l && /* @__PURE__ */ o(
1684
+ M,
1685
+ {
1686
+ size: "xs",
1687
+ className: Y(!ks && "opacity-60"),
1688
+ disabled: De || !ks,
1689
+ onClick: () => Ke(),
1690
+ children: [
1691
+ De ? /* @__PURE__ */ e(X, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(zs, { className: "h-3.5 w-3.5" }),
1692
+ De ? "Saving..." : "Save"
1693
+ ]
1694
+ }
1695
+ ),
1696
+ p && !P && l && /* @__PURE__ */ o(
1697
+ M,
1698
+ {
1699
+ variant: "outline",
1700
+ size: "xs",
1701
+ onClick: _a,
1702
+ children: [
1703
+ /* @__PURE__ */ e(Ys, { className: "h-3.5 w-3.5" }),
1704
+ "Close"
1705
+ ]
1706
+ }
1707
+ ),
1708
+ !P && l && /* @__PURE__ */ e("div", { className: "ml-2", children: /* @__PURE__ */ e(sn, {}) }),
1709
+ !P && a && /* @__PURE__ */ e(bn, {}),
1710
+ !P && l && /* @__PURE__ */ o(It, { children: [
1711
+ /* @__PURE__ */ e(Ot, { asChild: !0, children: /* @__PURE__ */ e(
1712
+ Je,
1713
+ {
1714
+ tooltip: "More Options",
1715
+ className: "w-7 px-0 text-muted-foreground hover:text-foreground",
1716
+ buttonProps: {
1717
+ size: "xs",
1718
+ variant: "ghost",
1719
+ "aria-label": "More dashboard options"
1720
+ },
1721
+ children: /* @__PURE__ */ e(kt, { className: "h-3.5 w-3.5" })
1722
+ }
1723
+ ) }),
1724
+ /* @__PURE__ */ o(
1725
+ Tt,
1726
+ {
1727
+ align: "end",
1728
+ className: "w-56 rounded-[6px] border border-border/60 p-1 shadow-sm",
1729
+ children: [
1730
+ /* @__PURE__ */ e(ce, { children: "Reports" }),
1731
+ /* @__PURE__ */ o(
1732
+ q,
1733
+ {
1734
+ disabled: m,
1735
+ onSelect: () => I(!0),
1736
+ children: [
1737
+ /* @__PURE__ */ e(Pt, { className: "h-3.5 w-3.5" }),
1738
+ "Export"
1739
+ ]
1740
+ }
1741
+ ),
1742
+ /* @__PURE__ */ o(
1743
+ q,
1744
+ {
1745
+ disabled: !ne,
1746
+ onSelect: () => {
1747
+ ne && G(!0);
1748
+ },
1749
+ children: [
1750
+ /* @__PURE__ */ e(_t, { className: "h-3.5 w-3.5" }),
1751
+ "Schedule"
1752
+ ]
1753
+ }
1754
+ ),
1755
+ /* @__PURE__ */ e(Ie, {}),
1756
+ La && /* @__PURE__ */ o(A, { children: [
1757
+ /* @__PURE__ */ e(ce, { children: "Access" }),
1758
+ /* @__PURE__ */ o(
1759
+ q,
1760
+ {
1761
+ onClick: () => T(!0),
1762
+ children: [
1763
+ /* @__PURE__ */ e(K, { className: "h-3.5 w-3.5" }),
1764
+ "Manage Groups"
1765
+ ]
1766
+ }
1767
+ ),
1768
+ /* @__PURE__ */ e(Ie, {})
1769
+ ] }),
1770
+ /* @__PURE__ */ e(ce, { children: "Preferences" }),
1771
+ /* @__PURE__ */ o(q, { onClick: () => w(!0), children: [
1772
+ /* @__PURE__ */ e(Ut, { className: "h-3.5 w-3.5" }),
1773
+ "Calendar Preferences"
1774
+ ] }),
1775
+ /* @__PURE__ */ o(q, { onClick: () => de(!0), children: [
1776
+ /* @__PURE__ */ e(Rt, { className: "h-3.5 w-3.5" }),
1777
+ "Summary Settings"
1778
+ ] }),
1779
+ a && l && /* @__PURE__ */ o(A, { children: [
1780
+ /* @__PURE__ */ e(Ie, {}),
1781
+ /* @__PURE__ */ e(ce, { children: "Developer" }),
1782
+ /* @__PURE__ */ o(
1783
+ q,
1784
+ {
1785
+ onSelect: () => {
1786
+ var i;
1787
+ s != null && s.accessToken && ((i = navigator == null ? void 0 : navigator.clipboard) != null && i.writeText ? navigator.clipboard.writeText(s.accessToken).then(
1788
+ () => k.success("Token copied to clipboard")
1789
+ ).catch(() => k.error("Unable to copy token")) : k.error("Clipboard not available"));
1790
+ },
1791
+ children: [
1792
+ /* @__PURE__ */ e(Gt, { className: "h-3.5 w-3.5" }),
1793
+ "Copy token"
1794
+ ]
1795
+ }
1796
+ ),
1797
+ /* @__PURE__ */ o(
1798
+ q,
1799
+ {
1800
+ onSelect: () => Ft(n.apiServiceUrl),
1801
+ children: [
1802
+ /* @__PURE__ */ e(hn, { className: "h-3.5 w-3.5" }),
1803
+ "Invalidate token"
1804
+ ]
1805
+ }
1806
+ ),
1807
+ p && /* @__PURE__ */ o(
1808
+ q,
1809
+ {
1810
+ onSelect: () => Cs(!xs),
1811
+ children: [
1812
+ /* @__PURE__ */ e(cn, { className: "h-3.5 w-3.5" }),
1813
+ xs ? "Hide dashboard JSON" : "Show dashboard JSON"
1814
+ ]
1815
+ }
1816
+ ),
1817
+ te && p && /* @__PURE__ */ o(
1818
+ q,
1819
+ {
1820
+ onSelect: () => ue(!0),
1821
+ children: [
1822
+ /* @__PURE__ */ e(Oe, { className: "h-3.5 w-3.5" }),
1823
+ "Add lens"
1824
+ ]
1825
+ }
1826
+ ),
1827
+ te && /* @__PURE__ */ o($t, { children: [
1828
+ /* @__PURE__ */ o(Vt, { children: [
1829
+ /* @__PURE__ */ e(ln, { className: "h-3.5 w-3.5" }),
1830
+ "Lenses"
1831
+ ] }),
1832
+ /* @__PURE__ */ e(qt, { className: "w-60", children: /* @__PURE__ */ e(xn, {}) })
1833
+ ] })
1834
+ ] })
1835
+ ]
1836
+ }
1837
+ )
1838
+ ] }),
1839
+ C && Ms && /* @__PURE__ */ e(
1840
+ Ht,
1841
+ {
1842
+ resource: Ms,
1843
+ resourceType: We.DASHBOARD,
1844
+ onClose: () => L(!1)
1845
+ }
1846
+ ),
1847
+ /* @__PURE__ */ e(
1848
+ jn,
1849
+ {
1850
+ open: R,
1851
+ onOpenChange: T
1852
+ }
1853
+ ),
1854
+ ne && (r == null ? void 0 : r.id) && /* @__PURE__ */ e(
1855
+ zt,
1856
+ {
1857
+ open: D,
1858
+ onOpenChange: G,
1859
+ dashboardId: r.id,
1860
+ dashboardName: r == null ? void 0 : r.title
1861
+ }
1862
+ ),
1863
+ /* @__PURE__ */ e(
1864
+ nn,
1865
+ {
1866
+ open: Q,
1867
+ onOpenChange: w
1868
+ }
1869
+ ),
1870
+ /* @__PURE__ */ e(
1871
+ rn,
1872
+ {
1873
+ open: W,
1874
+ onOpenChange: de,
1875
+ dashboard: r,
1876
+ disabled: !p,
1877
+ onApply: (i) => je({
1878
+ ...r,
1879
+ summary: i
1880
+ })
1881
+ }
1882
+ ),
1883
+ a && te && l && /* @__PURE__ */ e(
1884
+ Nn,
1885
+ {
1886
+ open: Re,
1887
+ onOpenChange: ue
1888
+ }
1889
+ ),
1890
+ l && /* @__PURE__ */ e(
1891
+ jt,
1892
+ {
1893
+ open: b,
1894
+ onOpenChange: I
1895
+ }
1896
+ ),
1897
+ /* @__PURE__ */ e(
1898
+ na,
1899
+ {
1900
+ open: me,
1901
+ onOpenChange: (i) => {
1902
+ !i && Ve && !he || (z(i), i || (pe(null), fe([]), ge(!1)));
1903
+ },
1904
+ children: /* @__PURE__ */ o(ra, { className: "max-w-sm", children: [
1905
+ /* @__PURE__ */ o(oa, { children: [
1906
+ /* @__PURE__ */ e(ia, { children: he ? "Save failed" : "Saving dashboard" }),
1907
+ /* @__PURE__ */ e(ca, { className: "pt-2", children: he ? "We could not save the dashboard. Please try again." : "Please wait while we save your changes." }),
1908
+ ys.length > 0 && /* @__PURE__ */ o("div", { className: "space-y-1 rounded-md border border-destructive/20 bg-destructive/5 p-3 text-left", children: [
1909
+ /* @__PURE__ */ e("div", { className: "text-sm font-medium text-destructive", children: "What needs attention" }),
1910
+ /* @__PURE__ */ e("ul", { className: "list-disc space-y-1 pl-4 text-xs text-muted-foreground", children: ys.slice(0, 5).map((i) => /* @__PURE__ */ e("li", { children: i }, i)) })
1911
+ ] })
1912
+ ] }),
1913
+ /* @__PURE__ */ e(la, { className: "flex-col gap-2 sm:flex-row sm:justify-end", children: he ? /* @__PURE__ */ o(A, { children: [
1914
+ /* @__PURE__ */ e(
1915
+ da,
1916
+ {
1917
+ onClick: () => {
1918
+ z(!1), pe(null), fe([]), ge(!1);
1919
+ },
1920
+ className: "m-0",
1921
+ children: "Close"
1922
+ }
1923
+ ),
1924
+ /* @__PURE__ */ e(
1925
+ os,
1926
+ {
1927
+ onClick: () => Ke({
1928
+ closeAfterSave: Ss,
1929
+ navigateHomeAfterSave: He === "home"
1930
+ }),
1931
+ className: "m-0",
1932
+ children: "Retry"
1933
+ }
1934
+ )
1935
+ ] }) : /* @__PURE__ */ o(
1936
+ os,
1937
+ {
1938
+ disabled: !0,
1939
+ className: "m-0 cursor-default",
1940
+ children: [
1941
+ /* @__PURE__ */ e(X, { className: "mr-2 h-4 w-4 animate-spin" }),
1942
+ "Saving..."
1943
+ ]
1944
+ }
1945
+ ) })
1946
+ ] })
1947
+ }
1948
+ ),
1949
+ /* @__PURE__ */ e(
1950
+ an,
1951
+ {
1952
+ open: Oa,
1953
+ onOpenChange: (i) => {
1954
+ se(i);
1955
+ },
1956
+ onSave: Ua,
1957
+ onDiscard: Ra,
1958
+ isSaving: Ve,
1959
+ saveLabel: "Save",
1960
+ discardLabel: "Discard"
1961
+ }
1962
+ )
1963
+ ] })
1964
+ ]
1965
+ }
1966
+ );
1967
+ }
1968
+ export {
1969
+ rr as default
1970
+ };