react-semaphor 0.1.291 → 0.1.293

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