react-semaphor 0.1.321 → 0.1.322

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