react-semaphor 0.1.374 → 0.1.376

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 (49) hide show
  1. package/dist/brand-studio/index.cjs +2 -7
  2. package/dist/brand-studio/index.js +94 -106
  3. package/dist/chunks/{calendar-preferences-dialog-DmBRXOH6.js → calendar-preferences-dialog-B6fsethx.js} +3 -3
  4. package/dist/chunks/{calendar-preferences-dialog-94DoRSW_.js → calendar-preferences-dialog-Dh1b0ytN.js} +1 -1
  5. package/dist/chunks/{chevrons-up-down-CnCSGY02.js → chevrons-up-down-D2fZD4N_.js} +1 -1
  6. package/dist/chunks/{chevrons-up-down-DSvLu4Ye.js → chevrons-up-down-lahj6tQy.js} +1 -1
  7. package/dist/chunks/{dashboard-briefing-launcher-l0ylhcAv.js → dashboard-briefing-launcher-BKCRO7Qw.js} +597 -589
  8. package/dist/chunks/{dashboard-briefing-launcher-CAFCkwG3.js → dashboard-briefing-launcher-Gv1cwT0I.js} +13 -8
  9. package/dist/chunks/dashboard-controls-BDJZarV7.js +52 -0
  10. package/dist/chunks/dashboard-controls-CchLBVDv.js +3037 -0
  11. package/dist/chunks/{dashboard-json-B8kke4ES.js → dashboard-json-QT0T2ad_.js} +2 -2
  12. package/dist/chunks/{dashboard-json-BlPA6wRT.js → dashboard-json-ZhIEMXN0.js} +1 -1
  13. package/dist/chunks/edit-dashboard-visual-DNzPgXMh.js +178 -0
  14. package/dist/chunks/{edit-dashboard-visual-CgJxTZLJ.js → edit-dashboard-visual-kNoMQRmH.js} +4413 -4330
  15. package/dist/chunks/{index-BJ971AL_.js → index-CPpqPJba.js} +185 -180
  16. package/dist/chunks/{index-BiDFY4Gr.js → index-DX_0OcRv.js} +24419 -24257
  17. package/dist/chunks/layout-grid-BOTLt36V.js +36 -0
  18. package/dist/chunks/layout-grid-CS6BSCJF.js +11 -0
  19. package/dist/chunks/{palette-D-f4-82S.js → palette-2HWSR5wb.js} +1 -1
  20. package/dist/chunks/{palette-DUGktM-M.js → palette-BcHHAmOU.js} +1 -1
  21. package/dist/chunks/{save-kkBEBeLg.js → save-B-YfAPhu.js} +1 -1
  22. package/dist/chunks/{save-D3YYinDz.js → save-MoF1T13_.js} +1 -1
  23. package/dist/chunks/switch-CmHP5dT7.js +168 -0
  24. package/dist/chunks/{switch-Dkx2qEOr.js → switch-DmE_MY3L.js} +2001 -1982
  25. package/dist/chunks/use-create-flow-overlay-state-BLPQgGuz.js +21 -0
  26. package/dist/chunks/use-create-flow-overlay-state-D_Ntx-_C.js +1967 -0
  27. package/dist/dashboard/index.cjs +1 -1
  28. package/dist/dashboard/index.js +1 -1
  29. package/dist/data-app-builder/index.cjs +18 -13
  30. package/dist/data-app-builder/index.js +141 -131
  31. package/dist/index.cjs +1 -1
  32. package/dist/index.js +61 -63
  33. package/dist/style.css +1 -1
  34. package/dist/surfboard/index.cjs +1 -1
  35. package/dist/surfboard/index.js +2 -2
  36. package/dist/types/main.d.ts +1 -12
  37. package/package.json +1 -1
  38. package/dist/chunks/braces-C3-w6xDL.js +0 -6
  39. package/dist/chunks/braces-C8QqW4wu.js +0 -23
  40. package/dist/chunks/dashboard-controls-BX47yuCH.js +0 -57
  41. package/dist/chunks/dashboard-controls-DyzG0r5f.js +0 -2269
  42. package/dist/chunks/edit-dashboard-visual-DA8SaE4h.js +0 -178
  43. package/dist/chunks/resource-management-panel-Bssc5uaX.js +0 -1018
  44. package/dist/chunks/resource-management-panel-C14F7VSc.js +0 -6
  45. package/dist/chunks/switch-fIkmwzUt.js +0 -168
  46. package/dist/chunks/use-create-flow-overlay-state-BGhwg121.js +0 -1647
  47. package/dist/chunks/use-create-flow-overlay-state-DAVI3fO1.js +0 -26
  48. package/dist/chunks/use-visual-utils-47dkDwLK.js +0 -340
  49. package/dist/chunks/use-visual-utils-K0yQRSI7.js +0 -1
@@ -0,0 +1,3037 @@
1
+ import { jsx as e, jsxs as s, Fragment as T } from "react/jsx-runtime";
2
+ import { c as fe, u as k, B as I, ay as kt, E as lr, L as pt, a0 as ft, a as ke, az as hn, aA as pn, aB as gt, aC as Te, aD as Et, aE as dr, f as pe, X as Lt, aF as cr, Q as ur, e as fn, O as gn, aG as bn, G as Xt, W as xn, Y as vn, Z as yn, $ as wn, g as Nn, j as Sn, aH as Cn } from "./switch-DmE_MY3L.js";
3
+ import { b6 as Dn, u as X, b as tt, b7 as kn, aq as oe, c as rt, d as En, e as Ue, f as bt, n as Ln, b8 as _e, b9 as Ce, ba as An, bb as Zt, bc as mr, bd as hr, be as In, bf as At, bg as Mn, bh as On, bi as Pn, bj as _n, bk as Un, bl as Rn, aK as Ve, bm as ze, o as A, bn as Tn, bo as pr, aX as De, az as fr, bp as Vn, bq as zn, br as gr, bs as It, ax as Fn, aN as $n, bt as br, bu as Gn, bv as Bn, bw as Mt, H as xr, z as et, bx as jn, ag as vr, aj as yr, ak as wr, al as Nr, am as Sr, an as Cr, ao as Dr, ap as xt, aW as kr, by as Hn, bz as qn, bA as ct, bB as vt, bC as yt, bD as Kn, bE as wt, bF as R, au as Nt, bG as Qn, bH as Wn, bI as Jn, y as Yn, x as Xe, J as Xn, bJ as Zn, bK as ea, bL as ta, _ as ra, bM as na, I as er, bN as aa, bO as sa, bP as oa, bQ as ia, bR as la, bS as da, bT as ca, bU as ua, bV as ma, bW as ha, v as St } from "./index-DX_0OcRv.js";
4
+ import "./index-CuHybtft.js";
5
+ import * as _ from "react";
6
+ import Er, { useState as w, useMemo as Y, useEffect as Re, useRef as tr, useLayoutEffect as pa, useCallback as fa } from "react";
7
+ import "./index-CJdxSyQq.js";
8
+ import { createPortal as ga } from "react-dom";
9
+ import { L as ba, b as xa, u as va, A as ya, V as wa, K as Na, e as Sa, M as Ca, N as Da, U as ka } from "./dashboard-briefing-launcher-BKCRO7Qw.js";
10
+ import { d as Lr } from "./index-DFOb_6HB.js";
11
+ import { C as Ea } from "./calendar-preferences-dialog-B6fsethx.js";
12
+ import { u as La } from "./use-debounced-dirty-check-BwAbnX_5.js";
13
+ import { s as ut } from "./normalize-dashboard-for-dirty-check-5KpZN8xr.js";
14
+ import { L as Ot, B as Aa } from "./layout-grid-BOTLt36V.js";
15
+ import { u as Ia } from "./use-create-flow-overlay-state-D_Ntx-_C.js";
16
+ import { S as rr } from "./save-B-YfAPhu.js";
17
+ import { P as Ma } from "./palette-2HWSR5wb.js";
18
+ /**
19
+ * @license lucide-react v0.453.0 - ISC
20
+ *
21
+ * This source code is licensed under the ISC license.
22
+ * See the LICENSE file in the root directory of this source tree.
23
+ */
24
+ const Oa = fe("Glasses", [
25
+ ["circle", { cx: "6", cy: "15", r: "4", key: "vux9w4" }],
26
+ ["circle", { cx: "18", cy: "15", r: "4", key: "18o8ve" }],
27
+ ["path", { d: "M14 15a2 2 0 0 0-2-2 2 2 0 0 0-2 2", key: "1ag4bs" }],
28
+ ["path", { d: "M2.5 13 5 7c.7-1.3 1.4-2 3-2", key: "1hm1gs" }],
29
+ ["path", { d: "M21.5 13 19 7c-.7-1.3-1.5-2-3-2", key: "1r31ai" }]
30
+ ]);
31
+ /**
32
+ * @license lucide-react v0.453.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */
37
+ const Pa = fe("Monitor", [
38
+ ["rect", { width: "20", height: "14", x: "2", y: "3", rx: "2", key: "48i651" }],
39
+ ["line", { x1: "8", x2: "16", y1: "21", y2: "21", key: "1svkeh" }],
40
+ ["line", { x1: "12", x2: "12", y1: "17", y2: "21", key: "vw1qmm" }]
41
+ ]);
42
+ /**
43
+ * @license lucide-react v0.453.0 - ISC
44
+ *
45
+ * This source code is licensed under the ISC license.
46
+ * See the LICENSE file in the root directory of this source tree.
47
+ */
48
+ const _a = fe("Moon", [
49
+ ["path", { d: "M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z", key: "a7tn18" }]
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 Ua = fe("ShieldX", [
58
+ [
59
+ "path",
60
+ {
61
+ 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",
62
+ key: "oel41y"
63
+ }
64
+ ],
65
+ ["path", { d: "m14.5 9.5-5 5", key: "17q4r4" }],
66
+ ["path", { d: "m9.5 9.5 5 5", key: "18nt4w" }]
67
+ ]);
68
+ /**
69
+ * @license lucide-react v0.453.0 - ISC
70
+ *
71
+ * This source code is licensed under the ISC license.
72
+ * See the LICENSE file in the root directory of this source tree.
73
+ */
74
+ const Ra = fe("Sun", [
75
+ ["circle", { cx: "12", cy: "12", r: "4", key: "4exip2" }],
76
+ ["path", { d: "M12 2v2", key: "tus03m" }],
77
+ ["path", { d: "M12 20v2", key: "1lh1kg" }],
78
+ ["path", { d: "m4.93 4.93 1.41 1.41", key: "149t6j" }],
79
+ ["path", { d: "m17.66 17.66 1.41 1.41", key: "ptbguv" }],
80
+ ["path", { d: "M2 12h2", key: "1t8f8n" }],
81
+ ["path", { d: "M20 12h2", key: "1q8mjw" }],
82
+ ["path", { d: "m6.34 17.66-1.41 1.41", key: "1m8zz5" }],
83
+ ["path", { d: "m19.07 4.93-1.41 1.41", key: "1shlcs" }]
84
+ ]);
85
+ /**
86
+ * @license lucide-react v0.453.0 - ISC
87
+ *
88
+ * This source code is licensed under the ISC license.
89
+ * See the LICENSE file in the root directory of this source tree.
90
+ */
91
+ const Ta = fe("UserPlus", [
92
+ ["path", { d: "M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2", key: "1yyitq" }],
93
+ ["circle", { cx: "9", cy: "7", r: "4", key: "nufk8" }],
94
+ ["line", { x1: "19", x2: "19", y1: "8", y2: "14", key: "1bvyxn" }],
95
+ ["line", { x1: "22", x2: "16", y1: "11", y2: "11", key: "1shjgl" }]
96
+ ]);
97
+ /**
98
+ * @license lucide-react v0.453.0 - ISC
99
+ *
100
+ * This source code is licensed under the ISC license.
101
+ * See the LICENSE file in the root directory of this source tree.
102
+ */
103
+ const Ar = fe("UserRound", [
104
+ ["circle", { cx: "12", cy: "8", r: "5", key: "1hypcn" }],
105
+ ["path", { d: "M20 21a8 8 0 0 0-16 0", key: "rfgkzh" }]
106
+ ]);
107
+ var Ct = { exports: {} }, mt = {};
108
+ /**
109
+ * @license React
110
+ * use-sync-external-store-shim.production.js
111
+ *
112
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
113
+ *
114
+ * This source code is licensed under the MIT license found in the
115
+ * LICENSE file in the root directory of this source tree.
116
+ */
117
+ var nr;
118
+ function Va() {
119
+ if (nr) return mt;
120
+ nr = 1;
121
+ var t = Er;
122
+ function r(u, g) {
123
+ return u === g && (u !== 0 || 1 / u === 1 / g) || u !== u && g !== g;
124
+ }
125
+ var a = typeof Object.is == "function" ? Object.is : r, n = t.useState, o = t.useEffect, c = t.useLayoutEffect, p = t.useDebugValue;
126
+ function d(u, g) {
127
+ var m = g(), f = n({ inst: { value: m, getSnapshot: g } }), l = f[0].inst, N = f[1];
128
+ return c(
129
+ function() {
130
+ l.value = m, l.getSnapshot = g, b(l) && N({ inst: l });
131
+ },
132
+ [u, m, g]
133
+ ), o(
134
+ function() {
135
+ return b(l) && N({ inst: l }), u(function() {
136
+ b(l) && N({ inst: l });
137
+ });
138
+ },
139
+ [u]
140
+ ), p(m), m;
141
+ }
142
+ function b(u) {
143
+ var g = u.getSnapshot;
144
+ u = u.value;
145
+ try {
146
+ var m = g();
147
+ return !a(u, m);
148
+ } catch {
149
+ return !0;
150
+ }
151
+ }
152
+ function x(u, g) {
153
+ return g();
154
+ }
155
+ var i = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? x : d;
156
+ return mt.useSyncExternalStore = t.useSyncExternalStore !== void 0 ? t.useSyncExternalStore : i, mt;
157
+ }
158
+ var ht = {};
159
+ /**
160
+ * @license React
161
+ * use-sync-external-store-shim.development.js
162
+ *
163
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
164
+ *
165
+ * This source code is licensed under the MIT license found in the
166
+ * LICENSE file in the root directory of this source tree.
167
+ */
168
+ var ar;
169
+ function za() {
170
+ return ar || (ar = 1, process.env.NODE_ENV !== "production" && function() {
171
+ function t(m, f) {
172
+ return m === f && (m !== 0 || 1 / m === 1 / f) || m !== m && f !== f;
173
+ }
174
+ function r(m, f) {
175
+ i || o.startTransition === void 0 || (i = !0, console.error(
176
+ "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."
177
+ ));
178
+ var l = f();
179
+ if (!u) {
180
+ var N = f();
181
+ c(l, N) || (console.error(
182
+ "The result of getSnapshot should be cached to avoid an infinite loop"
183
+ ), u = !0);
184
+ }
185
+ N = p({
186
+ inst: { value: l, getSnapshot: f }
187
+ });
188
+ var S = N[0].inst, E = N[1];
189
+ return b(
190
+ function() {
191
+ S.value = l, S.getSnapshot = f, a(S) && E({ inst: S });
192
+ },
193
+ [m, l, f]
194
+ ), d(
195
+ function() {
196
+ return a(S) && E({ inst: S }), m(function() {
197
+ a(S) && E({ inst: S });
198
+ });
199
+ },
200
+ [m]
201
+ ), x(l), l;
202
+ }
203
+ function a(m) {
204
+ var f = m.getSnapshot;
205
+ m = m.value;
206
+ try {
207
+ var l = f();
208
+ return !c(m, l);
209
+ } catch {
210
+ return !0;
211
+ }
212
+ }
213
+ function n(m, f) {
214
+ return f();
215
+ }
216
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
217
+ var o = Er, c = typeof Object.is == "function" ? Object.is : t, p = o.useState, d = o.useEffect, b = o.useLayoutEffect, x = o.useDebugValue, i = !1, u = !1, g = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? n : r;
218
+ ht.useSyncExternalStore = o.useSyncExternalStore !== void 0 ? o.useSyncExternalStore : g, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
219
+ }()), ht;
220
+ }
221
+ process.env.NODE_ENV === "production" ? Ct.exports = Va() : Ct.exports = za();
222
+ var Fa = Ct.exports;
223
+ const Ze = ["light", "dark", "system"];
224
+ function $a() {
225
+ const { theme: t, setTheme: r } = Dn(), a = k(
226
+ (p) => p.actions.setDashboardTheme
227
+ );
228
+ function n() {
229
+ const p = Ze.includes(t) ? t : "system", d = Ze[(Ze.indexOf(p) + 1) % Ze.length];
230
+ r(d), a(d);
231
+ }
232
+ const o = t === "light" ? Ra : t === "dark" ? _a : Pa, c = t === "light" ? "Theme: light (click for dark)" : t === "dark" ? "Theme: dark (click for system)" : "Theme: system (click for light)";
233
+ return /* @__PURE__ */ e(
234
+ I,
235
+ {
236
+ type: "button",
237
+ variant: "ghost",
238
+ size: "xs",
239
+ className: "h-7 w-7 p-0 text-muted-foreground hover:text-foreground",
240
+ onClick: n,
241
+ "aria-label": c,
242
+ title: c,
243
+ children: /* @__PURE__ */ e(o, { className: "h-3.5 w-3.5", strokeWidth: 1.5 })
244
+ }
245
+ );
246
+ }
247
+ async function Ga(t, r, a, n, o) {
248
+ if (!o)
249
+ return null;
250
+ const c = JSON.stringify(a), p = `${t}/v1/lens`;
251
+ return await kt(p, o, {
252
+ name: r,
253
+ template: c,
254
+ filterValues: n,
255
+ operation: "create"
256
+ });
257
+ }
258
+ async function Dt(t, r, a) {
259
+ if (!a)
260
+ return null;
261
+ const { id: n, template: o, filterValues: c, isDefault: p, shared: d } = r, b = `${t}/v1/lens`;
262
+ return await kt(b, a, {
263
+ lensId: n,
264
+ template: o,
265
+ filterValues: c,
266
+ isDefault: p,
267
+ shared: d,
268
+ operation: "update"
269
+ });
270
+ }
271
+ async function Ba(t, r, a) {
272
+ if (!a)
273
+ return null;
274
+ const n = `${t}/v1/lens`;
275
+ return await kt(n, a, {
276
+ operation: "delete",
277
+ lensId: r
278
+ });
279
+ }
280
+ const ja = "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";
281
+ function Ha({
282
+ open: t,
283
+ onOpenChange: r
284
+ } = {}) {
285
+ const [a, n] = w(""), [o, c] = w(!1), p = k((C) => C.lenses), { setLenses: d, setSelectedLensId: b } = lr(), [x, i] = w(!1), [u, g] = w(!1), m = t !== void 0, f = m ? t : u, l = (C) => {
286
+ m || g(C), r == null || r(C);
287
+ }, N = k((C) => C.dashboard), S = k((C) => C.filterValues), { authToken: E, tokenProps: L } = X();
288
+ async function M() {
289
+ i(!0);
290
+ const C = await Ga(
291
+ L.apiServiceUrl,
292
+ a,
293
+ N,
294
+ S,
295
+ E == null ? void 0 : E.accessToken
296
+ );
297
+ C && (d([...p || [], C]), b(C.id), l(!1)), i(!1);
298
+ }
299
+ return /* @__PURE__ */ s(tt, { open: f, onOpenChange: l, children: [
300
+ m ? null : /* @__PURE__ */ e(kn, { asChild: !0, children: /* @__PURE__ */ s(I, { variant: "secondary", size: "xs", children: [
301
+ /* @__PURE__ */ e(oe, { className: "h-3.5 w-3.5" }),
302
+ "Lens"
303
+ ] }) }),
304
+ /* @__PURE__ */ s(rt, { className: "rounded-control border-border/60 sm:max-w-[420px] sm:rounded-control", children: [
305
+ /* @__PURE__ */ s(En, { children: [
306
+ /* @__PURE__ */ e(Ue, { className: "text-[15px]", children: "Create lens" }),
307
+ /* @__PURE__ */ e(bt, { className: "text-[13px] leading-5", children: "Lenses are private by default and are only visible to you." })
308
+ ] }),
309
+ /* @__PURE__ */ s("div", { className: "space-y-1.5 py-1", children: [
310
+ /* @__PURE__ */ e(pt, { htmlFor: "lens-name", className: ja, children: "Name" }),
311
+ /* @__PURE__ */ e(
312
+ ft,
313
+ {
314
+ id: "lens-name",
315
+ size: "xs",
316
+ value: a,
317
+ placeholder: "Monthly review, West region, …",
318
+ onChange: (C) => n(C.target.value)
319
+ }
320
+ ),
321
+ o && /* @__PURE__ */ e("p", { className: "text-[12px] text-destructive", children: "A lens with this name already exists. Pick a different one." })
322
+ ] }),
323
+ /* @__PURE__ */ s(Ln, { children: [
324
+ /* @__PURE__ */ e(I, { variant: "outline", size: "xs", onClick: () => l(!1), children: "Cancel" }),
325
+ /* @__PURE__ */ e(
326
+ I,
327
+ {
328
+ size: "xs",
329
+ type: "submit",
330
+ onClick: M,
331
+ disabled: x || !a.trim(),
332
+ children: x ? "Creating…" : "Create"
333
+ }
334
+ )
335
+ ] })
336
+ ] })
337
+ ] });
338
+ }
339
+ function qa({ includeLabel: t = !1 } = {}) {
340
+ const r = k((i) => i.lenses), a = k((i) => i.selectedLensId), { setLenses: n, setSelectedLensId: o } = lr(), { authToken: c, tokenProps: p } = X();
341
+ async function d(i) {
342
+ o(i);
343
+ }
344
+ async function b(i) {
345
+ if (await Ba(p.apiServiceUrl, i, c == null ? void 0 : c.accessToken)) {
346
+ const g = r == null ? void 0 : r.filter((m) => m.id !== i);
347
+ n(g || []), o("original");
348
+ }
349
+ }
350
+ async function x(i) {
351
+ const u = r == null ? void 0 : r.map((f) => f.id === i.id ? {
352
+ ...f,
353
+ isDefault: !i.isDefault
354
+ } : {
355
+ ...f,
356
+ isDefault: !1
357
+ });
358
+ n(u || []);
359
+ const g = {
360
+ ...i,
361
+ isDefault: !i.isDefault
362
+ };
363
+ await Dt(p.apiServiceUrl, g, c == null ? void 0 : c.accessToken);
364
+ const m = r == null ? void 0 : r.find((f) => f.isDefault);
365
+ if (m && m.id !== i.id) {
366
+ const f = {
367
+ ...m,
368
+ isDefault: !1
369
+ };
370
+ await Dt(p.apiServiceUrl, f, c == null ? void 0 : c.accessToken);
371
+ }
372
+ }
373
+ return /* @__PURE__ */ s(T, { children: [
374
+ t ? /* @__PURE__ */ s(T, { children: [
375
+ /* @__PURE__ */ e(_e, { className: "px-3", children: "Lenses" }),
376
+ /* @__PURE__ */ e(Ce, {})
377
+ ] }) : null,
378
+ /* @__PURE__ */ s(
379
+ An,
380
+ {
381
+ value: a,
382
+ onValueChange: d,
383
+ children: [
384
+ /* @__PURE__ */ e(Zt, { value: "original", children: "Original" }),
385
+ r == null ? void 0 : r.map((i) => /* @__PURE__ */ s(
386
+ Zt,
387
+ {
388
+ className: "group flex justify-between gap-2",
389
+ value: i.id,
390
+ children: [
391
+ /* @__PURE__ */ e("p", { children: i.name }),
392
+ /* @__PURE__ */ s("span", { className: "flex items-center gap-3", children: [
393
+ /* @__PURE__ */ e(
394
+ mr,
395
+ {
396
+ onClick: (u) => {
397
+ u.preventDefault(), x(i);
398
+ },
399
+ className: ke(
400
+ "size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",
401
+ {
402
+ invisible: !i.isDefault,
403
+ "text-green-500": i.isDefault
404
+ }
405
+ ),
406
+ strokeWidth: 1.5
407
+ }
408
+ ),
409
+ /* @__PURE__ */ e(
410
+ hr,
411
+ {
412
+ onClick: (u) => {
413
+ u.preventDefault(), b(i.id);
414
+ },
415
+ className: "invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",
416
+ strokeWidth: 1.5
417
+ }
418
+ )
419
+ ] })
420
+ ]
421
+ },
422
+ i.id
423
+ ))
424
+ ]
425
+ }
426
+ )
427
+ ] });
428
+ }
429
+ function Ka() {
430
+ const { displayPreferences: t, shouldShowElement: r } = In(), { currentUser: a, userContext: n } = At(), o = Y(
431
+ () => Mn(a),
432
+ [a]
433
+ ), c = Y(() => (d) => o && o[d] !== void 0 && o[d] === !1 ? !1 : r(d), [o, r, t]), p = Y(
434
+ () => {
435
+ var d, b, x, i, u;
436
+ return {
437
+ canEdit: ((d = n == null ? void 0 : n.permissions) == null ? void 0 : d.canEdit) ?? Rn(a),
438
+ canUseFilters: ((b = n == null ? void 0 : n.permissions) == null ? void 0 : b.canEdit) ?? Un(a),
439
+ canManageDashboards: ((x = n == null ? void 0 : n.permissions) == null ? void 0 : x.canCreateDashboard) ?? _n(a),
440
+ canCreateDashboards: ((i = n == null ? void 0 : n.permissions) == null ? void 0 : i.canCreateDashboard) ?? Pn(a),
441
+ canAccessVisuals: ((u = n == null ? void 0 : n.permissions) == null ? void 0 : u.canEdit) ?? On(a)
442
+ };
443
+ },
444
+ [a, n]
445
+ );
446
+ return {
447
+ displayPreferences: t,
448
+ shouldShowElement: c,
449
+ permissions: p,
450
+ currentUser: a
451
+ };
452
+ }
453
+ function Qa(t, r = []) {
454
+ let a = [];
455
+ function n(c, p) {
456
+ const d = _.createContext(p);
457
+ d.displayName = c + "Context";
458
+ const b = a.length;
459
+ a = [...a, p];
460
+ const x = (u) => {
461
+ var S;
462
+ const { scope: g, children: m, ...f } = u, l = ((S = g == null ? void 0 : g[t]) == null ? void 0 : S[b]) || d, N = _.useMemo(() => f, Object.values(f));
463
+ return /* @__PURE__ */ e(l.Provider, { value: N, children: m });
464
+ };
465
+ x.displayName = c + "Provider";
466
+ function i(u, g) {
467
+ var l;
468
+ const m = ((l = g == null ? void 0 : g[t]) == null ? void 0 : l[b]) || d, f = _.useContext(m);
469
+ if (f) return f;
470
+ if (p !== void 0) return p;
471
+ throw new Error(`\`${u}\` must be used within \`${c}\``);
472
+ }
473
+ return [x, i];
474
+ }
475
+ const o = () => {
476
+ const c = a.map((p) => _.createContext(p));
477
+ return function(d) {
478
+ const b = (d == null ? void 0 : d[t]) || c;
479
+ return _.useMemo(
480
+ () => ({ [`__scope${t}`]: { ...d, [t]: b } }),
481
+ [d, b]
482
+ );
483
+ };
484
+ };
485
+ return o.scopeName = t, [n, Wa(o, ...r)];
486
+ }
487
+ function Wa(...t) {
488
+ const r = t[0];
489
+ if (t.length === 1) return r;
490
+ const a = () => {
491
+ const n = t.map((o) => ({
492
+ useScope: o(),
493
+ scopeName: o.scopeName
494
+ }));
495
+ return function(c) {
496
+ const p = n.reduce((d, { useScope: b, scopeName: x }) => {
497
+ const u = b(c)[`__scope${x}`];
498
+ return { ...d, ...u };
499
+ }, {});
500
+ return _.useMemo(() => ({ [`__scope${r.scopeName}`]: p }), [p]);
501
+ };
502
+ };
503
+ return a.scopeName = r.scopeName, a;
504
+ }
505
+ var Ja = [
506
+ "a",
507
+ "button",
508
+ "div",
509
+ "form",
510
+ "h2",
511
+ "h3",
512
+ "img",
513
+ "input",
514
+ "label",
515
+ "li",
516
+ "nav",
517
+ "ol",
518
+ "p",
519
+ "select",
520
+ "span",
521
+ "svg",
522
+ "ul"
523
+ ], Pt = Ja.reduce((t, r) => {
524
+ const a = hn(`Primitive.${r}`), n = _.forwardRef((o, c) => {
525
+ const { asChild: p, ...d } = o, b = p ? a : r;
526
+ return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ e(b, { ...d, ref: c });
527
+ });
528
+ return n.displayName = `Primitive.${r}`, { ...t, [r]: n };
529
+ }, {});
530
+ function Ya() {
531
+ return Fa.useSyncExternalStore(
532
+ Xa,
533
+ () => !0,
534
+ () => !1
535
+ );
536
+ }
537
+ function Xa() {
538
+ return () => {
539
+ };
540
+ }
541
+ var _t = "Avatar", [Za] = Qa(_t), [es, Ir] = Za(_t), Mr = _.forwardRef(
542
+ (t, r) => {
543
+ const { __scopeAvatar: a, ...n } = t, [o, c] = _.useState("idle");
544
+ return /* @__PURE__ */ e(
545
+ es,
546
+ {
547
+ scope: a,
548
+ imageLoadingStatus: o,
549
+ onImageLoadingStatusChange: c,
550
+ children: /* @__PURE__ */ e(Pt.span, { ...n, ref: r })
551
+ }
552
+ );
553
+ }
554
+ );
555
+ Mr.displayName = _t;
556
+ var Or = "AvatarImage", Pr = _.forwardRef(
557
+ (t, r) => {
558
+ const { __scopeAvatar: a, src: n, onLoadingStatusChange: o = () => {
559
+ }, ...c } = t, p = Ir(Or, a), d = ts(n, c), b = pn((x) => {
560
+ o(x), p.onImageLoadingStatusChange(x);
561
+ });
562
+ return gt(() => {
563
+ d !== "idle" && b(d);
564
+ }, [d, b]), d === "loaded" ? /* @__PURE__ */ e(Pt.img, { ...c, ref: r, src: n }) : null;
565
+ }
566
+ );
567
+ Pr.displayName = Or;
568
+ var _r = "AvatarFallback", Ur = _.forwardRef(
569
+ (t, r) => {
570
+ const { __scopeAvatar: a, delayMs: n, ...o } = t, c = Ir(_r, a), [p, d] = _.useState(n === void 0);
571
+ return _.useEffect(() => {
572
+ if (n !== void 0) {
573
+ const b = window.setTimeout(() => d(!0), n);
574
+ return () => window.clearTimeout(b);
575
+ }
576
+ }, [n]), p && c.imageLoadingStatus !== "loaded" ? /* @__PURE__ */ e(Pt.span, { ...o, ref: r }) : null;
577
+ }
578
+ );
579
+ Ur.displayName = _r;
580
+ function sr(t, r) {
581
+ return t ? r ? (t.src !== r && (t.src = r), t.complete && t.naturalWidth > 0 ? "loaded" : "loading") : "error" : "idle";
582
+ }
583
+ function ts(t, { referrerPolicy: r, crossOrigin: a }) {
584
+ const n = Ya(), o = _.useRef(null), c = n ? (o.current || (o.current = new window.Image()), o.current) : null, [p, d] = _.useState(
585
+ () => sr(c, t)
586
+ );
587
+ return gt(() => {
588
+ d(sr(c, t));
589
+ }, [c, t]), gt(() => {
590
+ const b = (u) => () => {
591
+ d(u);
592
+ };
593
+ if (!c) return;
594
+ const x = b("loaded"), i = b("error");
595
+ return c.addEventListener("load", x), c.addEventListener("error", i), r && (c.referrerPolicy = r), typeof a == "string" && (c.crossOrigin = a), () => {
596
+ c.removeEventListener("load", x), c.removeEventListener("error", i);
597
+ };
598
+ }, [c, a, r]), p;
599
+ }
600
+ var Rr = Mr, Tr = Pr, Vr = Ur;
601
+ const zr = _.forwardRef(({ className: t, ...r }, a) => /* @__PURE__ */ e(
602
+ Rr,
603
+ {
604
+ ref: a,
605
+ className: ke(
606
+ "relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
607
+ t
608
+ ),
609
+ ...r
610
+ }
611
+ ));
612
+ zr.displayName = Rr.displayName;
613
+ const rs = _.forwardRef(({ className: t, ...r }, a) => /* @__PURE__ */ e(
614
+ Tr,
615
+ {
616
+ ref: a,
617
+ className: ke("aspect-square h-full w-full", t),
618
+ ...r
619
+ }
620
+ ));
621
+ rs.displayName = Tr.displayName;
622
+ const Fr = _.forwardRef(({ className: t, ...r }, a) => /* @__PURE__ */ e(
623
+ Vr,
624
+ {
625
+ ref: a,
626
+ className: ke(
627
+ "flex h-full w-full items-center justify-center rounded-full bg-muted",
628
+ t
629
+ ),
630
+ ...r
631
+ }
632
+ ));
633
+ Fr.displayName = Vr.displayName;
634
+ const ns = async (t, r, a) => {
635
+ const n = `${t}/management/v1/groups`;
636
+ return await dr(n, r, a);
637
+ }, as = async (t, r, a, n) => {
638
+ const o = `${t}/management/v1/groups/${a}`;
639
+ return Et(o, r, "PATCH", n);
640
+ }, ss = async (t, r, a) => {
641
+ const n = `${t}/management/v1/groups/${a}`;
642
+ await Et(n, r, "DELETE");
643
+ }, os = async (t, r, a, n) => {
644
+ const o = `${t}/management/v1/groups/${a}/members`;
645
+ return await dr(o, r, n);
646
+ }, is = async (t, r, a, n) => {
647
+ const o = `${t}/management/v1/groups/${a}/members`;
648
+ await Et(o, r, "DELETE", n);
649
+ };
650
+ function ls() {
651
+ const { authToken: t, tokenProps: r } = X(), a = Ve();
652
+ return ze({
653
+ mutationFn: (n) => ns(r.apiServiceUrl, (t == null ? void 0 : t.accessToken) || "", n),
654
+ onSuccess: () => {
655
+ a.invalidateQueries({ queryKey: ["groups"] }), A.success("Group created successfully");
656
+ },
657
+ onError: (n) => {
658
+ console.error("Failed to create group:", n), A.error("Failed to create group", {
659
+ description: Te(n, "Failed to create group")
660
+ });
661
+ }
662
+ });
663
+ }
664
+ function ds() {
665
+ const { authToken: t, tokenProps: r } = X(), a = Ve();
666
+ return ze({
667
+ mutationFn: ({
668
+ groupId: n,
669
+ data: o
670
+ }) => as(r.apiServiceUrl, (t == null ? void 0 : t.accessToken) || "", n, o),
671
+ onSuccess: (n, o) => {
672
+ a.invalidateQueries({ queryKey: ["group", o.groupId] }), a.invalidateQueries({ queryKey: ["groups"] }), A.success("Group updated successfully");
673
+ },
674
+ onError: (n) => {
675
+ console.error("Failed to update group:", n), A.error("Failed to update group", {
676
+ description: Te(n, "Failed to update group")
677
+ });
678
+ }
679
+ });
680
+ }
681
+ function cs() {
682
+ const { authToken: t, tokenProps: r } = X(), a = Ve();
683
+ return ze({
684
+ mutationFn: (n) => ss(r.apiServiceUrl, (t == null ? void 0 : t.accessToken) || "", n),
685
+ onSuccess: (n, o) => {
686
+ a.invalidateQueries({ queryKey: ["groups"] }), a.removeQueries({ queryKey: ["group", o] }), A.success("Group deleted successfully");
687
+ },
688
+ onError: (n) => {
689
+ console.error("Failed to delete group:", n), A.error("Failed to delete group", {
690
+ description: Te(n, "Failed to delete group")
691
+ });
692
+ }
693
+ });
694
+ }
695
+ function us() {
696
+ const { authToken: t, tokenProps: r } = X(), a = Ve();
697
+ return ze({
698
+ mutationFn: ({
699
+ groupId: n,
700
+ data: o
701
+ }) => os(r.apiServiceUrl, (t == null ? void 0 : t.accessToken) || "", n, o),
702
+ onSuccess: (n, o) => {
703
+ a.invalidateQueries({ queryKey: ["group", o.groupId] }), a.invalidateQueries({
704
+ queryKey: ["group-members", o.groupId]
705
+ }), a.invalidateQueries({ queryKey: ["groups"] }), A.success("Members added successfully");
706
+ },
707
+ onError: (n) => {
708
+ console.error("Failed to add group members:", n), A.error("Failed to add members", {
709
+ description: Te(n, "Failed to add members")
710
+ });
711
+ }
712
+ });
713
+ }
714
+ function ms() {
715
+ const { authToken: t, tokenProps: r } = X(), a = Ve();
716
+ return ze({
717
+ mutationFn: ({
718
+ groupId: n,
719
+ data: o
720
+ }) => is(r.apiServiceUrl, (t == null ? void 0 : t.accessToken) || "", n, o),
721
+ onSuccess: (n, o) => {
722
+ a.invalidateQueries({ queryKey: ["group", o.groupId] }), a.invalidateQueries({
723
+ queryKey: ["group-members", o.groupId]
724
+ }), a.invalidateQueries({ queryKey: ["groups"] }), A.success("Members removed successfully");
725
+ },
726
+ onError: (n) => {
727
+ console.error("Failed to remove group members:", n), A.error("Failed to remove members", {
728
+ description: Te(n, "Failed to remove members")
729
+ });
730
+ }
731
+ });
732
+ }
733
+ const hs = [];
734
+ function ps({
735
+ open: t,
736
+ onOpenChange: r
737
+ }) {
738
+ var E, L, M;
739
+ const { tokenProps: a } = X(), { currentUser: n } = At(), o = (n == null ? void 0 : n.type) === "tenant", c = a == null ? void 0 : a.tenantId, {
740
+ groups: p,
741
+ isLoading: d,
742
+ error: b,
743
+ refetch: x
744
+ } = Tn({
745
+ type: o ? "TENANT_GROUP" : "all",
746
+ tenantId: o ? c : void 0,
747
+ includeMembers: !1
748
+ }), i = b ? $r(b, "Unable to load groups.") : null, [u, g] = w({ kind: "list" }), [m, f] = w(null), l = cs();
749
+ Re(() => {
750
+ t || (g({ kind: "list" }), f(null));
751
+ }, [t]);
752
+ const N = u.kind === "members" && p.find((C) => C.id === u.groupId) || null, S = async () => {
753
+ if (m)
754
+ try {
755
+ await l.mutateAsync(m.id), f(null), g({ kind: "list" }), x();
756
+ } catch {
757
+ }
758
+ };
759
+ return /* @__PURE__ */ e(tt, { open: t, onOpenChange: r, children: /* @__PURE__ */ s(rt, { className: "flex max-h-[640px] w-[720px] max-w-[92vw] flex-col gap-0 overflow-hidden p-0", children: [
760
+ u.kind === "list" ? /* @__PURE__ */ s("div", { className: "shrink-0 border-b border-border px-5 pt-4 pb-3.5", children: [
761
+ /* @__PURE__ */ e(Ue, { className: "text-[15px] font-semibold tracking-tight", children: "Group management" }),
762
+ /* @__PURE__ */ e(bt, { className: "mt-1 text-[12px] leading-[1.5] text-muted-foreground", children: "Organize people into groups for shared access." })
763
+ ] }) : u.kind === "create" ? /* @__PURE__ */ s("div", { className: "flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-5", children: [
764
+ /* @__PURE__ */ e(
765
+ "button",
766
+ {
767
+ type: "button",
768
+ onClick: () => g({ kind: "list" }),
769
+ "aria-label": "Back",
770
+ className: "-ml-1 flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",
771
+ children: /* @__PURE__ */ e(pr, { className: "h-3.5 w-3.5" })
772
+ }
773
+ ),
774
+ /* @__PURE__ */ e(Ue, { className: "truncate text-[13px] font-medium", children: "New group" }),
775
+ /* @__PURE__ */ e(bt, { className: "sr-only", children: "Create a new group to organize members." })
776
+ ] }) : null,
777
+ u.kind === "list" && /* @__PURE__ */ e(
778
+ fs,
779
+ {
780
+ groups: p,
781
+ isLoading: d,
782
+ errorMessage: i,
783
+ onRetry: () => x(),
784
+ currentUserId: n == null ? void 0 : n.id,
785
+ onOpenGroup: (C) => g({ kind: "members", groupId: C }),
786
+ onCreate: () => g({ kind: "create" }),
787
+ onDeleteRequest: (C) => f(C)
788
+ }
789
+ ),
790
+ u.kind === "members" && N && /* @__PURE__ */ e(
791
+ xs,
792
+ {
793
+ group: N,
794
+ isTenantViewer: o,
795
+ canEdit: ((E = N.permissions) == null ? void 0 : E.canEdit) ?? N.createdBy === (n == null ? void 0 : n.id),
796
+ canDelete: ((L = N.permissions) == null ? void 0 : L.canDelete) ?? N.createdBy === (n == null ? void 0 : n.id),
797
+ canManageMembers: ((M = N.permissions) == null ? void 0 : M.canManageMembers) ?? N.createdBy === (n == null ? void 0 : n.id),
798
+ onBack: () => g({ kind: "list" }),
799
+ onMembersChanged: x,
800
+ onUpdated: x,
801
+ onRequestDelete: () => f(N)
802
+ },
803
+ N.id
804
+ ),
805
+ u.kind === "create" && /* @__PURE__ */ e(
806
+ vs,
807
+ {
808
+ isTenantUser: o,
809
+ tenantId: c,
810
+ onCancel: () => g({ kind: "list" }),
811
+ onCreated: (C) => {
812
+ x(), g({ kind: "members", groupId: C });
813
+ }
814
+ }
815
+ ),
816
+ m && /* @__PURE__ */ s("div", { className: "flex shrink-0 items-center justify-between gap-3 border-t border-border bg-muted/40 px-5 py-2.5", children: [
817
+ /* @__PURE__ */ s("div", { className: "min-w-0 text-[12px] text-foreground", children: [
818
+ "Delete ",
819
+ /* @__PURE__ */ e("span", { className: "font-medium", children: m.name }),
820
+ "?",
821
+ /* @__PURE__ */ e("span", { className: "ml-2 text-muted-foreground", children: "Members lose any access granted via this group." })
822
+ ] }),
823
+ /* @__PURE__ */ s("div", { className: "flex shrink-0 items-center gap-1.5", children: [
824
+ /* @__PURE__ */ e(
825
+ "button",
826
+ {
827
+ type: "button",
828
+ onClick: () => f(null),
829
+ disabled: l.isPending,
830
+ className: "h-7 rounded-[5px] px-2.5 text-[12px] font-medium text-foreground/80 hover:bg-background",
831
+ children: "Cancel"
832
+ }
833
+ ),
834
+ /* @__PURE__ */ s(
835
+ "button",
836
+ {
837
+ type: "button",
838
+ onClick: S,
839
+ disabled: l.isPending,
840
+ className: "inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-rose-600 px-2.5 text-[12px] font-medium text-white hover:bg-rose-700 disabled:opacity-60",
841
+ children: [
842
+ l.isPending ? /* @__PURE__ */ e(pe, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ e(De, { className: "h-3 w-3" }),
843
+ "Delete group"
844
+ ]
845
+ }
846
+ )
847
+ ] })
848
+ ] })
849
+ ] }) });
850
+ }
851
+ function fs({
852
+ groups: t,
853
+ isLoading: r,
854
+ errorMessage: a,
855
+ onRetry: n,
856
+ currentUserId: o,
857
+ onOpenGroup: c,
858
+ onCreate: p,
859
+ onDeleteRequest: d
860
+ }) {
861
+ const [b, x] = w(""), i = Y(
862
+ () => t.filter(
863
+ (u) => !b.trim() || u.name.toLowerCase().includes(b.toLowerCase()) || (u.description || "").toLowerCase().includes(b.toLowerCase())
864
+ ),
865
+ [t, b]
866
+ );
867
+ return /* @__PURE__ */ s("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
868
+ /* @__PURE__ */ s("div", { className: "flex shrink-0 items-center gap-2 border-b border-border px-5 py-2.5", children: [
869
+ /* @__PURE__ */ s("div", { className: "flex flex-1 items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40", children: [
870
+ /* @__PURE__ */ e(fr, { className: "h-3 w-3 text-muted-foreground" }),
871
+ /* @__PURE__ */ e(
872
+ "input",
873
+ {
874
+ value: b,
875
+ onChange: (u) => x(u.target.value),
876
+ placeholder: "Search groups…",
877
+ className: "h-7 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none"
878
+ }
879
+ ),
880
+ b && /* @__PURE__ */ e(
881
+ "button",
882
+ {
883
+ type: "button",
884
+ onClick: () => x(""),
885
+ className: "flex h-4 w-4 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",
886
+ children: /* @__PURE__ */ e(Lt, { className: "h-2.5 w-2.5" })
887
+ }
888
+ )
889
+ ] }),
890
+ /* @__PURE__ */ s(
891
+ "button",
892
+ {
893
+ type: "button",
894
+ onClick: p,
895
+ className: "inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90",
896
+ children: [
897
+ /* @__PURE__ */ e(oe, { className: "h-3 w-3" }),
898
+ "New group"
899
+ ]
900
+ }
901
+ )
902
+ ] }),
903
+ /* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto", children: r ? /* @__PURE__ */ e("div", { className: "space-y-px p-3", children: [1, 2, 3].map((u) => /* @__PURE__ */ e(
904
+ "div",
905
+ {
906
+ className: "h-12 animate-pulse rounded-[4px] bg-muted/60"
907
+ },
908
+ u
909
+ )) }) : a ? /* @__PURE__ */ e(
910
+ Gr,
911
+ {
912
+ title: "Can't load groups",
913
+ message: a,
914
+ onRetry: n
915
+ }
916
+ ) : i.length === 0 && t.length === 0 ? /* @__PURE__ */ e(bs, { onCreate: p }) : i.length === 0 ? /* @__PURE__ */ s("div", { className: "flex h-full flex-col items-center justify-center gap-1 py-10 text-center", children: [
917
+ /* @__PURE__ */ s("div", { className: "text-[12px] text-foreground", children: [
918
+ 'No groups match "',
919
+ b,
920
+ '"'
921
+ ] }),
922
+ /* @__PURE__ */ e("div", { className: "text-[11px] text-muted-foreground", children: "Try a different search." })
923
+ ] }) : i.map((u) => {
924
+ var g;
925
+ return /* @__PURE__ */ e(
926
+ gs,
927
+ {
928
+ group: u,
929
+ canDelete: ((g = u.permissions) == null ? void 0 : g.canDelete) ?? u.createdBy === o,
930
+ onClick: () => c(u.id),
931
+ onDelete: () => d(u)
932
+ },
933
+ u.id
934
+ );
935
+ }) })
936
+ ] });
937
+ }
938
+ function gs({
939
+ group: t,
940
+ canDelete: r,
941
+ onClick: a,
942
+ onDelete: n
943
+ }) {
944
+ let o = "";
945
+ try {
946
+ o = Lr(new Date(t.createdAt), "MMM d, yyyy");
947
+ } catch {
948
+ o = "";
949
+ }
950
+ return /* @__PURE__ */ s(
951
+ "button",
952
+ {
953
+ type: "button",
954
+ onClick: a,
955
+ className: "group flex w-full items-center gap-3 border-b border-border/60 px-5 py-2.5 text-left hover:bg-accent/40",
956
+ children: [
957
+ /* @__PURE__ */ e("div", { className: "flex h-7 w-7 shrink-0 items-center justify-center rounded-[4px] border border-border bg-background text-muted-foreground", children: /* @__PURE__ */ e(ba, { className: "h-3.5 w-3.5" }) }),
958
+ /* @__PURE__ */ s("div", { className: "min-w-0 flex-1", children: [
959
+ /* @__PURE__ */ e("div", { className: "truncate text-[13px] font-medium text-foreground", children: t.name }),
960
+ /* @__PURE__ */ s("div", { className: "mt-0.5 flex items-center gap-2 text-[11px] text-muted-foreground", children: [
961
+ /* @__PURE__ */ s("span", { className: "inline-flex items-center gap-1", children: [
962
+ /* @__PURE__ */ e(Ar, { className: "h-2.5 w-2.5" }),
963
+ t.memberCount,
964
+ " member",
965
+ t.memberCount === 1 ? "" : "s"
966
+ ] }),
967
+ o && /* @__PURE__ */ s(T, { children: [
968
+ /* @__PURE__ */ e("span", { className: "text-border", children: "·" }),
969
+ /* @__PURE__ */ s("span", { className: "inline-flex items-center gap-1", children: [
970
+ /* @__PURE__ */ e(It, { className: "h-2.5 w-2.5" }),
971
+ o
972
+ ] })
973
+ ] }),
974
+ t.description && /* @__PURE__ */ s(T, { children: [
975
+ /* @__PURE__ */ e("span", { className: "text-border", children: "·" }),
976
+ /* @__PURE__ */ e("span", { className: "truncate text-muted-foreground", children: t.description })
977
+ ] })
978
+ ] })
979
+ ] }),
980
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100", children: [
981
+ r && /* @__PURE__ */ e(
982
+ "span",
983
+ {
984
+ role: "button",
985
+ tabIndex: 0,
986
+ onClick: (c) => {
987
+ c.stopPropagation(), n();
988
+ },
989
+ onKeyDown: (c) => {
990
+ (c.key === "Enter" || c.key === " ") && (c.preventDefault(), c.stopPropagation(), n());
991
+ },
992
+ "aria-label": `Delete ${t.name}`,
993
+ className: "flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",
994
+ children: /* @__PURE__ */ e(De, { className: "h-3 w-3" })
995
+ }
996
+ ),
997
+ /* @__PURE__ */ e(Fn, { className: "h-3.5 w-3.5 text-muted-foreground" })
998
+ ] })
999
+ ]
1000
+ }
1001
+ );
1002
+ }
1003
+ function bs({ onCreate: t }) {
1004
+ return /* @__PURE__ */ s("div", { className: "flex h-full flex-col items-center justify-center gap-2 py-12 text-center", children: [
1005
+ /* @__PURE__ */ e("div", { className: "flex h-9 w-9 items-center justify-center rounded-full border border-border bg-muted/40 text-muted-foreground", children: /* @__PURE__ */ e(gr, { className: "h-4 w-4" }) }),
1006
+ /* @__PURE__ */ e("div", { className: "text-[13px] font-medium text-foreground", children: "No groups yet" }),
1007
+ /* @__PURE__ */ e("div", { className: "max-w-[320px] text-[11.5px] leading-[1.55] text-muted-foreground", children: "Groups let you grant shared access to dashboards. Create one and add members." }),
1008
+ /* @__PURE__ */ s(
1009
+ "button",
1010
+ {
1011
+ type: "button",
1012
+ onClick: t,
1013
+ className: "mt-1 inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90",
1014
+ children: [
1015
+ /* @__PURE__ */ e(oe, { className: "h-3 w-3" }),
1016
+ "New group"
1017
+ ]
1018
+ }
1019
+ )
1020
+ ] });
1021
+ }
1022
+ function xs({
1023
+ group: t,
1024
+ isTenantViewer: r,
1025
+ canEdit: a,
1026
+ canDelete: n,
1027
+ canManageMembers: o,
1028
+ onBack: c,
1029
+ onMembersChanged: p,
1030
+ onUpdated: d,
1031
+ onRequestDelete: b
1032
+ }) {
1033
+ const {
1034
+ data: x,
1035
+ isLoading: i,
1036
+ error: u,
1037
+ refetch: g
1038
+ } = Vn(t.id), m = (x == null ? void 0 : x.members) ?? hs, f = u ? $r(u, "Unable to load members for this group.") : null, l = t.type === "TENANT_GROUP" ? "tenant" : "organization", { users: N } = zn({
1039
+ type: l,
1040
+ tenantId: t.tenantId || void 0,
1041
+ active: !0,
1042
+ limit: 200
1043
+ }), S = Y(
1044
+ () => new Set(m.map((y) => y.userId)),
1045
+ [m]
1046
+ ), E = us(), L = ms(), M = ds(), [C, Z] = w(!1), [ee, ie] = w(t.name), [ge, te] = w(!1), [re, ne] = w(t.description || ""), [ae, be] = w(""), [xe, j] = w(!1), ve = Y(() => {
1047
+ const y = ae.trim().toLowerCase();
1048
+ return N.filter((G) => !S.has(G.id)).filter(
1049
+ (G) => !y || (G.name || "").toLowerCase().includes(y) || (G.email || "").toLowerCase().includes(y)
1050
+ ).slice(0, 50);
1051
+ }, [N, S, ae]), le = async () => {
1052
+ const y = ee.trim();
1053
+ if (Z(!1), y.length >= 3 && y !== t.name)
1054
+ try {
1055
+ await M.mutateAsync({
1056
+ groupId: t.id,
1057
+ data: { name: y }
1058
+ }), d();
1059
+ } catch {
1060
+ }
1061
+ }, K = async () => {
1062
+ const y = re.trim();
1063
+ if (te(!1), y !== (t.description || ""))
1064
+ try {
1065
+ await M.mutateAsync({
1066
+ groupId: t.id,
1067
+ data: { description: y }
1068
+ }), d();
1069
+ } catch {
1070
+ }
1071
+ }, $ = async (y) => {
1072
+ if (o) {
1073
+ be(""), j(!1);
1074
+ try {
1075
+ await E.mutateAsync({
1076
+ groupId: t.id,
1077
+ data: {
1078
+ userIds: [y.id],
1079
+ userType: l === "tenant" ? "tenant" : "org"
1080
+ }
1081
+ }), g(), p();
1082
+ } catch {
1083
+ }
1084
+ }
1085
+ }, V = async (y) => {
1086
+ if (o)
1087
+ try {
1088
+ await L.mutateAsync({
1089
+ groupId: t.id,
1090
+ data: { userIds: [y] }
1091
+ }), g(), p();
1092
+ } catch {
1093
+ }
1094
+ };
1095
+ let z = "";
1096
+ try {
1097
+ z = Lr(new Date(t.createdAt), "MMM d, yyyy");
1098
+ } catch {
1099
+ z = "";
1100
+ }
1101
+ return /* @__PURE__ */ s("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
1102
+ /* @__PURE__ */ s("div", { className: "flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-5", children: [
1103
+ /* @__PURE__ */ e(
1104
+ "button",
1105
+ {
1106
+ type: "button",
1107
+ onClick: c,
1108
+ "aria-label": "Back",
1109
+ className: "-ml-1 flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",
1110
+ children: /* @__PURE__ */ e(pr, { className: "h-3.5 w-3.5" })
1111
+ }
1112
+ ),
1113
+ C ? /* @__PURE__ */ e(
1114
+ "input",
1115
+ {
1116
+ autoFocus: !0,
1117
+ value: ee,
1118
+ onChange: (y) => ie(y.target.value),
1119
+ onBlur: le,
1120
+ onKeyDown: (y) => {
1121
+ y.key === "Enter" && le(), y.key === "Escape" && (ie(t.name), Z(!1));
1122
+ },
1123
+ className: "h-6 min-w-0 flex-1 rounded-[3px] border border-border bg-background px-1.5 text-[13px] font-medium text-foreground focus:border-foreground/40 focus:outline-none"
1124
+ }
1125
+ ) : /* @__PURE__ */ e(
1126
+ "button",
1127
+ {
1128
+ type: "button",
1129
+ onClick: () => {
1130
+ a && (ie(t.name), Z(!0));
1131
+ },
1132
+ title: a ? "Click to rename" : t.name,
1133
+ disabled: !a,
1134
+ className: "truncate rounded-[3px] px-1 text-[13px] font-medium text-foreground enabled:hover:bg-accent disabled:cursor-default",
1135
+ children: t.name
1136
+ }
1137
+ ),
1138
+ /* @__PURE__ */ s("span", { className: "ml-1 inline-flex shrink-0 items-center gap-1 text-[10.5px] text-muted-foreground", children: [
1139
+ /* @__PURE__ */ e(Ar, { className: "h-2.5 w-2.5" }),
1140
+ m.length,
1141
+ " member",
1142
+ m.length === 1 ? "" : "s"
1143
+ ] })
1144
+ ] }),
1145
+ /* @__PURE__ */ e("div", { className: "shrink-0 border-b border-border px-5 py-2.5", children: ge ? /* @__PURE__ */ s("div", { children: [
1146
+ /* @__PURE__ */ e(
1147
+ "textarea",
1148
+ {
1149
+ autoFocus: !0,
1150
+ rows: 2,
1151
+ value: re,
1152
+ onChange: (y) => ne(y.target.value),
1153
+ maxLength: 200,
1154
+ onKeyDown: (y) => {
1155
+ y.key === "Escape" && (ne(t.description || ""), te(!1)), y.key === "Enter" && (y.metaKey || y.ctrlKey) && K();
1156
+ },
1157
+ placeholder: "What is this group for?",
1158
+ className: "block w-full resize-none rounded-[5px] border border-border bg-background px-2 py-1.5 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"
1159
+ }
1160
+ ),
1161
+ /* @__PURE__ */ s("div", { className: "mt-1.5 flex items-center justify-between", children: [
1162
+ /* @__PURE__ */ s("span", { className: "text-[10.5px] text-muted-foreground", children: [
1163
+ re.length,
1164
+ "/200 · Esc to cancel · ⌘↩ to save"
1165
+ ] }),
1166
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-1.5", children: [
1167
+ /* @__PURE__ */ e(
1168
+ "button",
1169
+ {
1170
+ type: "button",
1171
+ onClick: () => {
1172
+ ne(t.description || ""), te(!1);
1173
+ },
1174
+ className: "h-6 rounded-[5px] px-2 text-[11px] font-medium text-foreground/80 hover:bg-accent",
1175
+ children: "Cancel"
1176
+ }
1177
+ ),
1178
+ /* @__PURE__ */ e(
1179
+ "button",
1180
+ {
1181
+ type: "button",
1182
+ onClick: K,
1183
+ className: "inline-flex h-6 items-center rounded-[5px] bg-foreground px-2 text-[11px] font-medium text-background hover:opacity-90",
1184
+ children: "Save"
1185
+ }
1186
+ )
1187
+ ] })
1188
+ ] })
1189
+ ] }) : /* @__PURE__ */ s(
1190
+ "button",
1191
+ {
1192
+ type: "button",
1193
+ onClick: () => {
1194
+ a && (ne(t.description || ""), te(!0));
1195
+ },
1196
+ disabled: !a,
1197
+ title: a ? "Click to edit description" : void 0,
1198
+ className: "block w-full rounded-[3px] px-1 py-0.5 text-left enabled:hover:bg-accent/40 disabled:cursor-default",
1199
+ children: [
1200
+ t.description ? /* @__PURE__ */ e("p", { className: "text-[12px] leading-[1.55] text-foreground/90", children: t.description }) : /* @__PURE__ */ e("p", { className: "text-[12px] leading-[1.55] text-muted-foreground", children: a ? "Add a description…" : "No description" }),
1201
+ /* @__PURE__ */ s("p", { className: "mt-1 text-[10.5px] text-muted-foreground", children: [
1202
+ z ? `Created ${z}` : "Recently created",
1203
+ a ? " · You can edit this group" : ""
1204
+ ] })
1205
+ ]
1206
+ }
1207
+ ) }),
1208
+ o && /* @__PURE__ */ e(
1209
+ ys,
1210
+ {
1211
+ query: ae,
1212
+ setQuery: be,
1213
+ open: xe,
1214
+ setOpen: j,
1215
+ candidates: ve,
1216
+ showKindChip: !r,
1217
+ onAdd: $,
1218
+ busy: E.isPending
1219
+ }
1220
+ ),
1221
+ /* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto", children: i ? /* @__PURE__ */ e("div", { className: "space-y-px p-3", children: [1, 2, 3].map((y) => /* @__PURE__ */ e(
1222
+ "div",
1223
+ {
1224
+ className: "h-10 animate-pulse rounded-[4px] bg-muted/60"
1225
+ },
1226
+ y
1227
+ )) }) : f ? /* @__PURE__ */ e(
1228
+ Gr,
1229
+ {
1230
+ title: "Can't load members",
1231
+ message: f,
1232
+ onRetry: () => g()
1233
+ }
1234
+ ) : m.length === 0 ? /* @__PURE__ */ s("div", { className: "flex h-full flex-col items-center justify-center gap-1 py-10 text-center", children: [
1235
+ /* @__PURE__ */ e("div", { className: "text-[12px] text-foreground", children: "No members yet" }),
1236
+ /* @__PURE__ */ e("div", { className: "text-[11px] text-muted-foreground", children: o ? "Search above to add people to this group." : "This group does not have any members." })
1237
+ ] }) : m.map((y) => {
1238
+ var G, H, ye, de, we, O;
1239
+ return /* @__PURE__ */ s(
1240
+ "div",
1241
+ {
1242
+ className: "group flex items-center gap-2 border-b border-border/60 px-5 py-2",
1243
+ children: [
1244
+ /* @__PURE__ */ e(Br, { name: ((G = y.user) == null ? void 0 : G.name) || ((H = y.user) == null ? void 0 : H.email) || "?" }),
1245
+ /* @__PURE__ */ s("div", { className: "min-w-0 flex-1", children: [
1246
+ /* @__PURE__ */ e("div", { className: "truncate text-[12.5px] font-medium text-foreground", children: ((ye = y.user) == null ? void 0 : ye.name) || ((de = y.user) == null ? void 0 : de.email) || "Unknown" }),
1247
+ ((we = y.user) == null ? void 0 : we.email) && y.user.name && /* @__PURE__ */ e("div", { className: "truncate text-[10.5px] text-muted-foreground", children: y.user.email })
1248
+ ] }),
1249
+ !r && /* @__PURE__ */ e("span", { className: "text-[10px] uppercase tracking-[0.06em] text-muted-foreground", children: y.userType }),
1250
+ /* @__PURE__ */ e(
1251
+ "button",
1252
+ {
1253
+ type: "button",
1254
+ onClick: () => V(y.userId),
1255
+ disabled: !o || L.isPending,
1256
+ "aria-label": `Remove ${((O = y.user) == null ? void 0 : O.name) || "member"}`,
1257
+ className: "flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground opacity-0 transition-opacity hover:bg-accent hover:text-foreground group-hover:opacity-100 disabled:opacity-30",
1258
+ children: /* @__PURE__ */ e(Lt, { className: "h-3 w-3" })
1259
+ }
1260
+ )
1261
+ ]
1262
+ },
1263
+ y.id
1264
+ );
1265
+ }) }),
1266
+ n && /* @__PURE__ */ e("div", { className: "flex shrink-0 items-center justify-end gap-1.5 border-t border-border bg-muted/30 px-5 py-2.5", children: /* @__PURE__ */ s(
1267
+ "button",
1268
+ {
1269
+ type: "button",
1270
+ onClick: b,
1271
+ className: "inline-flex h-7 items-center gap-1.5 rounded-[5px] border border-rose-200 bg-background px-2.5 text-[12px] font-medium text-rose-600 hover:bg-rose-50 dark:border-rose-900/60 dark:text-rose-400 dark:hover:bg-rose-950/30",
1272
+ children: [
1273
+ /* @__PURE__ */ e(De, { className: "h-3 w-3" }),
1274
+ "Delete group"
1275
+ ]
1276
+ }
1277
+ ) })
1278
+ ] });
1279
+ }
1280
+ function vs({
1281
+ isTenantUser: t,
1282
+ tenantId: r,
1283
+ onCancel: a,
1284
+ onCreated: n
1285
+ }) {
1286
+ const [o, c] = w(""), [p, d] = w(""), [b, x] = w(null), i = ls(), u = o.trim().length >= 3 && o.trim().length <= 50, g = async () => {
1287
+ if (!u) return;
1288
+ x(null);
1289
+ const m = {
1290
+ name: o.trim(),
1291
+ description: p.trim() || void 0,
1292
+ type: t ? "TENANT_GROUP" : "ORG_GROUP",
1293
+ ...t && r ? { tenantId: r } : {}
1294
+ };
1295
+ try {
1296
+ const f = await i.mutateAsync(m), l = f == null ? void 0 : f.id;
1297
+ l ? n(l) : a();
1298
+ } catch (f) {
1299
+ x(f instanceof Error ? f.message : "Failed to create group");
1300
+ }
1301
+ };
1302
+ return /* @__PURE__ */ s("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
1303
+ /* @__PURE__ */ s("div", { className: "flex-1 overflow-y-auto px-5 py-4", children: [
1304
+ /* @__PURE__ */ e(or, { children: "Name" }),
1305
+ /* @__PURE__ */ e(
1306
+ "input",
1307
+ {
1308
+ autoFocus: !0,
1309
+ value: o,
1310
+ onChange: (m) => c(m.target.value),
1311
+ placeholder: "Marketing leads, North America sales, …",
1312
+ maxLength: 50,
1313
+ className: "mt-1 block h-7 w-full rounded-[5px] border border-border bg-background px-2 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"
1314
+ }
1315
+ ),
1316
+ /* @__PURE__ */ e("div", { className: "mt-1 text-[10.5px] text-muted-foreground", children: "3–50 characters." }),
1317
+ /* @__PURE__ */ s("div", { className: "mt-4", children: [
1318
+ /* @__PURE__ */ e(or, { children: "Description (optional)" }),
1319
+ /* @__PURE__ */ e(
1320
+ "textarea",
1321
+ {
1322
+ rows: 2,
1323
+ value: p,
1324
+ onChange: (m) => d(m.target.value),
1325
+ maxLength: 200,
1326
+ placeholder: "What is this group for?",
1327
+ className: "mt-1 block w-full resize-none rounded-[5px] border border-border bg-background px-2 py-1.5 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"
1328
+ }
1329
+ ),
1330
+ /* @__PURE__ */ s("div", { className: "mt-1 flex justify-end text-[10.5px] text-muted-foreground", children: [
1331
+ p.length,
1332
+ "/200"
1333
+ ] })
1334
+ ] }),
1335
+ b && /* @__PURE__ */ e("div", { className: "mt-3 rounded-[5px] border border-rose-200 bg-rose-50 px-2 py-1.5 text-[11.5px] text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/30 dark:text-rose-300", children: b })
1336
+ ] }),
1337
+ /* @__PURE__ */ s("div", { className: "flex shrink-0 items-center justify-end gap-1.5 border-t border-border bg-muted/30 px-5 py-2.5", children: [
1338
+ /* @__PURE__ */ e(
1339
+ "button",
1340
+ {
1341
+ type: "button",
1342
+ onClick: a,
1343
+ disabled: i.isPending,
1344
+ className: "h-7 rounded-[5px] px-2.5 text-[12px] font-medium text-foreground/80 hover:bg-accent",
1345
+ children: "Cancel"
1346
+ }
1347
+ ),
1348
+ /* @__PURE__ */ e(
1349
+ "button",
1350
+ {
1351
+ type: "button",
1352
+ onClick: g,
1353
+ disabled: !u || i.isPending,
1354
+ className: "inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-60",
1355
+ children: i.isPending ? /* @__PURE__ */ s(T, { children: [
1356
+ /* @__PURE__ */ e(pe, { className: "h-3 w-3 animate-spin" }),
1357
+ "Creating…"
1358
+ ] }) : /* @__PURE__ */ s(T, { children: [
1359
+ /* @__PURE__ */ e(oe, { className: "h-3 w-3" }),
1360
+ "Create group"
1361
+ ] })
1362
+ }
1363
+ )
1364
+ ] })
1365
+ ] });
1366
+ }
1367
+ function ys({
1368
+ query: t,
1369
+ setQuery: r,
1370
+ open: a,
1371
+ setOpen: n,
1372
+ candidates: o,
1373
+ showKindChip: c,
1374
+ onAdd: p,
1375
+ busy: d
1376
+ }) {
1377
+ const b = tr(null), x = tr(null), [i, u] = w(null);
1378
+ pa(() => {
1379
+ if (!a) {
1380
+ u(null);
1381
+ return;
1382
+ }
1383
+ const m = () => {
1384
+ const f = b.current;
1385
+ if (!f) return;
1386
+ const l = f.getBoundingClientRect(), N = 240, E = window.innerHeight - l.bottom < N + 16 && l.top > N;
1387
+ u({
1388
+ left: l.left,
1389
+ top: E ? l.top - 6 : l.bottom + 6,
1390
+ width: l.width,
1391
+ above: E
1392
+ });
1393
+ };
1394
+ return m(), window.addEventListener("resize", m), window.addEventListener("scroll", m, !0), () => {
1395
+ window.removeEventListener("resize", m), window.removeEventListener("scroll", m, !0);
1396
+ };
1397
+ }, [a, o.length]), Re(() => {
1398
+ if (!a) return;
1399
+ const m = (f) => {
1400
+ var N, S;
1401
+ const l = f.target;
1402
+ (N = b.current) != null && N.contains(l) || (S = x.current) != null && S.contains(l) || n(!1);
1403
+ };
1404
+ return document.addEventListener("mousedown", m), () => document.removeEventListener("mousedown", m);
1405
+ }, [a, n]);
1406
+ const g = a && o.length > 0 && i;
1407
+ return /* @__PURE__ */ s("div", { className: "shrink-0 border-b border-border px-5 py-2.5", children: [
1408
+ /* @__PURE__ */ s(
1409
+ "div",
1410
+ {
1411
+ ref: b,
1412
+ className: "flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40",
1413
+ children: [
1414
+ /* @__PURE__ */ e(Ta, { className: "h-3 w-3 text-muted-foreground" }),
1415
+ /* @__PURE__ */ e(
1416
+ "input",
1417
+ {
1418
+ value: t,
1419
+ onChange: (m) => {
1420
+ r(m.target.value), n(!0);
1421
+ },
1422
+ onFocus: () => n(!0),
1423
+ placeholder: "Add a member by name or email…",
1424
+ disabled: d,
1425
+ className: "h-7 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none disabled:cursor-not-allowed"
1426
+ }
1427
+ )
1428
+ ]
1429
+ }
1430
+ ),
1431
+ g && typeof document < "u" && ga(
1432
+ /* @__PURE__ */ e(
1433
+ "div",
1434
+ {
1435
+ ref: x,
1436
+ style: {
1437
+ position: "fixed",
1438
+ left: i.left,
1439
+ top: i.top,
1440
+ width: i.width,
1441
+ transform: i.above ? "translateY(-100%)" : void 0
1442
+ },
1443
+ className: "z-[60] max-h-[240px] overflow-y-auto rounded-[5px] border border-border bg-background shadow-[0_8px_24px_-12px_rgba(0,0,0,0.18)]",
1444
+ children: o.map((m) => /* @__PURE__ */ s(
1445
+ "button",
1446
+ {
1447
+ type: "button",
1448
+ onClick: () => p(m),
1449
+ className: "flex w-full items-center gap-2 border-b border-border/60 px-2.5 py-2 text-left last:border-b-0 hover:bg-accent",
1450
+ children: [
1451
+ /* @__PURE__ */ e(Br, { name: m.name || m.email || "?" }),
1452
+ /* @__PURE__ */ s("div", { className: "min-w-0 flex-1", children: [
1453
+ /* @__PURE__ */ e("div", { className: "truncate text-[12px] font-medium text-foreground", children: m.name || m.email || "Unknown" }),
1454
+ m.email && m.name && /* @__PURE__ */ e("div", { className: "truncate text-[10.5px] text-muted-foreground", children: m.email })
1455
+ ] }),
1456
+ c && m.type && /* @__PURE__ */ e("span", { className: "text-[10px] uppercase tracking-[0.06em] text-muted-foreground", children: m.type === "tenant" ? "tenant" : "org" })
1457
+ ]
1458
+ },
1459
+ m.id
1460
+ ))
1461
+ }
1462
+ ),
1463
+ document.body
1464
+ )
1465
+ ] });
1466
+ }
1467
+ function $r(t, r) {
1468
+ if (!t) return r;
1469
+ if (t instanceof Error) {
1470
+ const a = t.message || "", n = a.match(/\{[\s\S]*"error"\s*:\s*"([^"]+)"[\s\S]*\}/);
1471
+ return n ? n[1] : a || r;
1472
+ }
1473
+ return typeof t == "string" ? t : r;
1474
+ }
1475
+ function Gr({
1476
+ title: t,
1477
+ message: r,
1478
+ onRetry: a
1479
+ }) {
1480
+ return /* @__PURE__ */ s("div", { className: "flex h-full flex-col items-center justify-center gap-2 px-6 py-10 text-center", children: [
1481
+ /* @__PURE__ */ e("div", { className: "text-[12.5px] font-medium text-foreground", children: t }),
1482
+ /* @__PURE__ */ e("div", { className: "max-w-[360px] text-[11.5px] leading-[1.55] text-muted-foreground", children: r }),
1483
+ a && /* @__PURE__ */ e(
1484
+ "button",
1485
+ {
1486
+ type: "button",
1487
+ onClick: a,
1488
+ className: "mt-1 inline-flex h-7 items-center rounded-[5px] border border-border bg-background px-2.5 text-[11.5px] font-medium text-foreground hover:bg-accent",
1489
+ children: "Try again"
1490
+ }
1491
+ )
1492
+ ] });
1493
+ }
1494
+ function or({ children: t }) {
1495
+ return /* @__PURE__ */ e("label", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: t });
1496
+ }
1497
+ function Br({ name: t }) {
1498
+ const r = t.split(" ").map((a) => a[0]).filter(Boolean).slice(0, 2).join("").toUpperCase();
1499
+ return /* @__PURE__ */ e(zr, { className: "h-6 w-6 shrink-0", children: /* @__PURE__ */ e(Fr, { className: "text-[9px] font-semibold", children: r || "?" }) });
1500
+ }
1501
+ function Oe(t, r, a) {
1502
+ var c, p;
1503
+ const n = (t.controls || []).find(
1504
+ (d) => d.id === a
1505
+ );
1506
+ if (n)
1507
+ return n.label;
1508
+ const o = (p = (c = cr(t, r)) == null ? void 0 : c.controls) == null ? void 0 : p.find(
1509
+ (d) => d.id === a
1510
+ );
1511
+ return (o == null ? void 0 : o.label) || a;
1512
+ }
1513
+ function Pe(t, r) {
1514
+ var a;
1515
+ return ((a = cr(t, r)) == null ? void 0 : a.title) || r;
1516
+ }
1517
+ function ws(t) {
1518
+ const { errors: r, dashboard: a } = t;
1519
+ if (!a)
1520
+ return r;
1521
+ const n = /* @__PURE__ */ new Map();
1522
+ for (const o of r) {
1523
+ const c = o.match(
1524
+ /^Card '(.+)' binding for control '(.+)' maps to missing metric '(.+)'\.$/
1525
+ );
1526
+ if (c) {
1527
+ const [, i, u] = c, g = `${i}:${u}:missing-metric`;
1528
+ n.has(g) || n.set(
1529
+ g,
1530
+ `"${Pe(a, i)}" has an outdated "${Oe(
1531
+ a,
1532
+ i,
1533
+ u
1534
+ )}" mapping. Some choices still point to metrics that are no longer available on this card. Open the card controls and choose replacements.`
1535
+ );
1536
+ continue;
1537
+ }
1538
+ const p = o.match(
1539
+ /^Card '(.+)' binding for control '(.+)' maps to missing group-by field '(.+)'\.$/
1540
+ );
1541
+ if (p) {
1542
+ const [, i, u] = p, g = `${i}:${u}:missing-group-by`;
1543
+ n.has(g) || n.set(
1544
+ g,
1545
+ `"${Pe(a, i)}" has an outdated "${Oe(
1546
+ a,
1547
+ i,
1548
+ u
1549
+ )}" mapping. Some choices still point to fields that are no longer available on this card. Open the card controls and choose replacements.`
1550
+ );
1551
+ continue;
1552
+ }
1553
+ const d = o.match(
1554
+ /^Card '(.+)' binding for control '(.+)' maps to an invalid metric target\.$/
1555
+ );
1556
+ if (d) {
1557
+ const [, i, u] = d, g = `${i}:${u}:invalid-metric`;
1558
+ n.has(g) || n.set(
1559
+ g,
1560
+ `"${Pe(a, i)}" has an invalid "${Oe(
1561
+ a,
1562
+ i,
1563
+ u
1564
+ )}" metric mapping. Open the card controls and choose a valid metric for each option.`
1565
+ );
1566
+ continue;
1567
+ }
1568
+ const b = o.match(
1569
+ /^Card '(.+)' binding for control '(.+)' maps to an invalid group-by target\.$/
1570
+ );
1571
+ if (b) {
1572
+ const [, i, u] = b, g = `${i}:${u}:invalid-group-by`;
1573
+ n.has(g) || n.set(
1574
+ g,
1575
+ `"${Pe(a, i)}" has an invalid "${Oe(
1576
+ a,
1577
+ i,
1578
+ u
1579
+ )}" field mapping. Open the card controls and choose a valid field for each option.`
1580
+ );
1581
+ continue;
1582
+ }
1583
+ const x = o.match(
1584
+ /^Card '(.+)' binding for control '(.+)' requires at least one temporal group-by field\.$/
1585
+ );
1586
+ if (x) {
1587
+ const [, i, u] = x, g = `${i}:${u}:missing-temporal-group-by`;
1588
+ n.has(g) || n.set(
1589
+ g,
1590
+ `"${Pe(a, i)}" can no longer use "${Oe(
1591
+ a,
1592
+ i,
1593
+ u
1594
+ )}" for time grain because the card does not currently group by a date field.`
1595
+ );
1596
+ continue;
1597
+ }
1598
+ n.set(o, o);
1599
+ }
1600
+ return Array.from(n.values());
1601
+ }
1602
+ function Ns(t, r) {
1603
+ return typeof t == "boolean" ? t : typeof r == "boolean" ? r : !0;
1604
+ }
1605
+ function Ss() {
1606
+ return /* @__PURE__ */ e("div", { className: "space-y-1.5 py-1", children: [...Array(5)].map((t, r) => /* @__PURE__ */ s(
1607
+ "div",
1608
+ {
1609
+ className: "flex animate-pulse items-start gap-3 rounded-xl border border-transparent px-2.5 py-2.5",
1610
+ children: [
1611
+ /* @__PURE__ */ e("div", { className: "mt-0.5 h-4 w-4 flex-shrink-0 rounded bg-muted/60" }),
1612
+ /* @__PURE__ */ s("div", { className: "flex-1 space-y-1.5", children: [
1613
+ /* @__PURE__ */ e("div", { className: "h-4 w-3/5 rounded bg-muted/60" }),
1614
+ /* @__PURE__ */ e("div", { className: "h-3 w-4/5 rounded bg-muted/40" })
1615
+ ] })
1616
+ ]
1617
+ },
1618
+ r
1619
+ )) });
1620
+ }
1621
+ function Cs({
1622
+ open: t,
1623
+ onOpenChange: r,
1624
+ onSubmit: a,
1625
+ isCreating: n
1626
+ }) {
1627
+ const [o, c] = w(""), [p, d] = w("");
1628
+ Re(() => {
1629
+ t || (c(""), d(""));
1630
+ }, [t]);
1631
+ const b = () => {
1632
+ o.trim() && a({ title: o, description: p });
1633
+ }, x = (i) => {
1634
+ r(i);
1635
+ };
1636
+ return /* @__PURE__ */ e(tt, { open: t, onOpenChange: x, children: /* @__PURE__ */ s(
1637
+ rt,
1638
+ {
1639
+ showCloseButton: !1,
1640
+ className: "flex max-w-lg grid-cols-none flex-col gap-0 overflow-hidden rounded-[6px] border-border/60 p-0 shadow-lg",
1641
+ children: [
1642
+ /* @__PURE__ */ s("div", { className: "flex h-10 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3", children: [
1643
+ /* @__PURE__ */ s("div", { className: "flex min-w-0 items-center gap-2", children: [
1644
+ /* @__PURE__ */ e(Ot, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
1645
+ /* @__PURE__ */ s("div", { className: "flex min-w-0 items-baseline gap-2", children: [
1646
+ /* @__PURE__ */ e(Ue, { className: "truncate text-[13px] font-medium leading-none tracking-normal", children: "New library visual" }),
1647
+ /* @__PURE__ */ e("span", { className: "shrink-0 text-[10px] font-medium uppercase leading-none tracking-[0.08em] text-muted-foreground", children: "Visual" })
1648
+ ] })
1649
+ ] }),
1650
+ /* @__PURE__ */ e(
1651
+ I,
1652
+ {
1653
+ size: "xs",
1654
+ variant: "ghost",
1655
+ className: "w-7 px-0 text-muted-foreground hover:text-foreground",
1656
+ onClick: () => x(!1),
1657
+ "aria-label": "Close",
1658
+ disabled: n,
1659
+ children: /* @__PURE__ */ e(Lt, { className: "h-3.5 w-3.5" })
1660
+ }
1661
+ )
1662
+ ] }),
1663
+ /* @__PURE__ */ s("div", { className: "space-y-3 px-4 py-3", children: [
1664
+ /* @__PURE__ */ e("p", { className: "text-[12px] text-muted-foreground", children: "Create a saved visual that can be reused across dashboards." }),
1665
+ /* @__PURE__ */ s("div", { className: "space-y-1.5", children: [
1666
+ /* @__PURE__ */ e(pt, { htmlFor: "visual-title", className: "text-[12px]", children: "Name" }),
1667
+ /* @__PURE__ */ e(
1668
+ ft,
1669
+ {
1670
+ id: "visual-title",
1671
+ size: "sm",
1672
+ placeholder: "Untitled visual",
1673
+ value: o,
1674
+ onChange: (i) => c(i.target.value),
1675
+ disabled: n,
1676
+ onKeyDown: (i) => {
1677
+ i.key === "Enter" && !i.shiftKey && (i.preventDefault(), b());
1678
+ }
1679
+ }
1680
+ )
1681
+ ] }),
1682
+ /* @__PURE__ */ s("div", { className: "space-y-1.5", children: [
1683
+ /* @__PURE__ */ e(pt, { htmlFor: "visual-description", className: "text-[12px]", children: "Description" }),
1684
+ /* @__PURE__ */ e(
1685
+ ft,
1686
+ {
1687
+ id: "visual-description",
1688
+ size: "sm",
1689
+ placeholder: "Optional",
1690
+ value: p,
1691
+ onChange: (i) => d(i.target.value),
1692
+ disabled: n
1693
+ }
1694
+ )
1695
+ ] })
1696
+ ] }),
1697
+ /* @__PURE__ */ s("div", { className: "flex shrink-0 justify-end gap-2 border-t border-border/60 px-4 py-2.5", children: [
1698
+ /* @__PURE__ */ e(
1699
+ I,
1700
+ {
1701
+ size: "xs",
1702
+ variant: "outline",
1703
+ onClick: () => x(!1),
1704
+ disabled: n,
1705
+ children: "Cancel"
1706
+ }
1707
+ ),
1708
+ /* @__PURE__ */ e(
1709
+ I,
1710
+ {
1711
+ size: "xs",
1712
+ onClick: b,
1713
+ disabled: !o.trim() || n,
1714
+ children: n ? /* @__PURE__ */ s(T, { children: [
1715
+ /* @__PURE__ */ e(pe, { className: "h-3.5 w-3.5 animate-spin" }),
1716
+ "Creating..."
1717
+ ] }) : "Create library visual"
1718
+ }
1719
+ )
1720
+ ] })
1721
+ ]
1722
+ }
1723
+ ) });
1724
+ }
1725
+ function jr(t) {
1726
+ return t ? new Date(t).toLocaleDateString("en-US", {
1727
+ month: "short",
1728
+ day: "numeric",
1729
+ year: "numeric"
1730
+ }) : "Unknown";
1731
+ }
1732
+ function Hr(t, r) {
1733
+ var n;
1734
+ const a = (n = t.ownership.createdBy) == null ? void 0 : n.type;
1735
+ return a === "tenant" || a === "organization" && r;
1736
+ }
1737
+ function Ut(t, r) {
1738
+ var a, n;
1739
+ return Hr(t, r) ? ((a = t.ownership.createdBy) == null ? void 0 : a.name) || ((n = t.createdByTenantUserRel) == null ? void 0 : n.name) || t.lastModifiedBy || "Unknown" : "Organization";
1740
+ }
1741
+ function Ds(t, r) {
1742
+ return Ut(t, r).split(/\s+/).filter(Boolean).slice(0, 2).map((n) => n.charAt(0).toUpperCase()).join("") || "?";
1743
+ }
1744
+ function ks(t) {
1745
+ const r = (t || "").toLowerCase();
1746
+ return r.includes("table") ? ur : r.includes("pie") || r.includes("donut") ? Hn : r.includes("line") ? qn : r.includes("bar") ? gn : Ot;
1747
+ }
1748
+ function Es({ visual: t }) {
1749
+ const r = t.ownership.status === "public" ? "Public" : t.ownership.status === "shared" || t.ownership.sharedCount > 0 ? "Shared" : "Private";
1750
+ return /* @__PURE__ */ e("span", { className: "inline-flex items-center rounded-[4px] border border-border/60 px-1.5 py-px text-[11px] text-muted-foreground", children: r });
1751
+ }
1752
+ function Ls({
1753
+ open: t,
1754
+ onOpenChange: r
1755
+ }) {
1756
+ const [a, n] = w(""), [o, c] = w(/* @__PURE__ */ new Set()), [p, d] = w(!1), [b, x] = w(
1757
+ null
1758
+ ), [i, u] = w(
1759
+ null
1760
+ ), [g, m] = w(!1), [f, l] = w(null), [N, S] = w(null), E = () => {
1761
+ c(/* @__PURE__ */ new Set()), x(null), u(null), m(!1), l(null);
1762
+ }, L = () => {
1763
+ r(!1), E();
1764
+ }, { selectVisual: M } = $n(), { handleAddLibraryVisual: C, handleEditLibraryVisual: Z } = Ia(), { isConsoleMode: ee } = br(), {
1765
+ resources: ie,
1766
+ isLoading: ge,
1767
+ isError: te,
1768
+ createResource: re,
1769
+ updateResource: ne,
1770
+ deleteResourceAsync: ae,
1771
+ duplicateResource: be,
1772
+ isCreating: xe,
1773
+ isDeleting: j
1774
+ } = Gn(
1775
+ void 0,
1776
+ (v) => {
1777
+ d(!1), v && (M(v), Z(v), L());
1778
+ }
1779
+ ), {
1780
+ startUpdating: ve,
1781
+ stopUpdating: le,
1782
+ isUpdating: K
1783
+ } = Bn(), $ = ie, V = Y(() => {
1784
+ const v = a.trim().toLowerCase();
1785
+ return v ? $.filter(
1786
+ (D) => {
1787
+ var P, q, se;
1788
+ return ((P = D.title) == null ? void 0 : P.toLowerCase().includes(v)) || ((q = D.description) == null ? void 0 : q.toLowerCase().includes(v)) || ((se = D.kind) == null ? void 0 : se.toLowerCase().includes(v));
1789
+ }
1790
+ ) : $;
1791
+ }, [a, $]), z = Y(
1792
+ () => $.filter(
1793
+ (v) => o.has(v.id)
1794
+ ),
1795
+ [o, $]
1796
+ ), y = z.filter(
1797
+ (v) => v.permissions.canDelete
1798
+ ), G = z.filter(
1799
+ (v) => v.permissions.canShare
1800
+ ), H = V.length > 0 && V.every(
1801
+ (v) => o.has(v.id)
1802
+ ), ye = V.some(
1803
+ (v) => o.has(v.id)
1804
+ ), de = (v) => {
1805
+ const D = new Set(o);
1806
+ v(D), c(D);
1807
+ }, we = (v) => {
1808
+ de((D) => {
1809
+ D.has(v) ? D.delete(v) : D.add(v);
1810
+ });
1811
+ }, O = () => {
1812
+ c((v) => {
1813
+ const D = new Set(v);
1814
+ return H ? V.forEach(
1815
+ (P) => D.delete(P.id)
1816
+ ) : V.forEach(
1817
+ (P) => D.add(P.id)
1818
+ ), D;
1819
+ });
1820
+ }, ce = async (v) => {
1821
+ (await C(v)).success && L();
1822
+ }, Ne = async () => {
1823
+ const v = z;
1824
+ if (v.length === 0) return;
1825
+ let D = !1;
1826
+ for (const P of v)
1827
+ if (!(await C(P)).success) {
1828
+ D = !0;
1829
+ break;
1830
+ }
1831
+ D || L();
1832
+ }, Se = (v) => {
1833
+ Z(v), L();
1834
+ }, Fe = (v) => {
1835
+ S(v), be(v, {
1836
+ onSettled: () => S(null)
1837
+ });
1838
+ }, Ee = () => {
1839
+ if (y.length === 0) {
1840
+ A.error("Select a visual you can delete");
1841
+ return;
1842
+ }
1843
+ l(null), m(!0);
1844
+ }, $e = async () => {
1845
+ const v = f ? [f] : y;
1846
+ try {
1847
+ for (const D of v)
1848
+ await ae(D.id);
1849
+ c((D) => {
1850
+ const P = new Set(D);
1851
+ return v.forEach(
1852
+ (q) => P.delete(q.id)
1853
+ ), P;
1854
+ }), m(!1), l(null);
1855
+ } catch {
1856
+ }
1857
+ }, Ge = () => {
1858
+ if (z.length !== 1) {
1859
+ A.error("Select one visual to share");
1860
+ return;
1861
+ }
1862
+ const [v] = z;
1863
+ if (!v.permissions.canShare) {
1864
+ A.error("You do not have permission to share this visual");
1865
+ return;
1866
+ }
1867
+ x(v);
1868
+ }, Be = ({
1869
+ title: v,
1870
+ description: D
1871
+ }) => {
1872
+ if (!i) return;
1873
+ const P = {};
1874
+ if (v !== i.title && (P.title = v), (i.description || "") !== D && (P.description = D), Object.keys(P).length === 0) {
1875
+ u(null);
1876
+ return;
1877
+ }
1878
+ const q = Object.keys(P), se = q.length === 1 ? q[0] : void 0;
1879
+ ve(i.id, se), ne(
1880
+ {
1881
+ resourceId: i.id,
1882
+ data: P
1883
+ },
1884
+ {
1885
+ onSuccess: () => {
1886
+ le(i.id, se), u(null);
1887
+ },
1888
+ onError: () => {
1889
+ le(i.id, se);
1890
+ }
1891
+ }
1892
+ );
1893
+ }, ue = (v) => {
1894
+ r(v), v || E();
1895
+ }, Q = f ? 1 : y.length;
1896
+ return /* @__PURE__ */ s(T, { children: [
1897
+ /* @__PURE__ */ e(tt, { open: t, onOpenChange: ue, children: /* @__PURE__ */ s(
1898
+ rt,
1899
+ {
1900
+ showCloseButton: !1,
1901
+ className: "flex max-h-[80vh] w-[min(72rem,calc(100vw-2rem))] max-w-none grid-cols-none flex-col gap-0 overflow-hidden rounded-[6px] border-border/60 p-0 shadow-lg",
1902
+ children: [
1903
+ /* @__PURE__ */ s("div", { className: "flex h-10 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3", children: [
1904
+ /* @__PURE__ */ s("div", { className: "flex min-w-0 items-center gap-2", children: [
1905
+ /* @__PURE__ */ e(ur, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
1906
+ /* @__PURE__ */ s("div", { className: "flex min-w-0 items-baseline gap-2", children: [
1907
+ /* @__PURE__ */ e(Ue, { className: "truncate text-[13px] font-medium leading-none tracking-normal", children: "Visuals library" }),
1908
+ /* @__PURE__ */ e("span", { className: "shrink-0 text-[10px] font-medium uppercase leading-none tracking-[0.08em] text-muted-foreground", children: "Add to dashboard" })
1909
+ ] })
1910
+ ] }),
1911
+ /* @__PURE__ */ e(
1912
+ I,
1913
+ {
1914
+ size: "xs",
1915
+ variant: "ghost",
1916
+ className: "w-7 px-0 text-muted-foreground hover:text-foreground",
1917
+ onClick: () => ue(!1),
1918
+ "aria-label": "Close visuals library",
1919
+ children: "×"
1920
+ }
1921
+ )
1922
+ ] }),
1923
+ /* @__PURE__ */ s("div", { className: "flex shrink-0 items-center gap-2 border-b border-border/60 px-3 py-2", children: [
1924
+ /* @__PURE__ */ s("div", { className: "relative min-w-[12rem] flex-1 md:max-w-md", children: [
1925
+ /* @__PURE__ */ e(fr, { className: "pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" }),
1926
+ /* @__PURE__ */ e(
1927
+ "input",
1928
+ {
1929
+ autoFocus: !0,
1930
+ value: a,
1931
+ onChange: (v) => n(v.target.value),
1932
+ placeholder: "Search visuals...",
1933
+ className: "h-7 w-full rounded-control border border-input bg-background pl-7 pr-2 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-ring focus:outline-none",
1934
+ "aria-label": "Search visuals"
1935
+ }
1936
+ )
1937
+ ] }),
1938
+ /* @__PURE__ */ s(
1939
+ I,
1940
+ {
1941
+ size: "xs",
1942
+ variant: "outline",
1943
+ className: "ml-auto",
1944
+ onClick: () => d(!0),
1945
+ children: [
1946
+ /* @__PURE__ */ e(oe, { className: "h-3.5 w-3.5" }),
1947
+ "New library visual"
1948
+ ]
1949
+ }
1950
+ )
1951
+ ] }),
1952
+ /* @__PURE__ */ e("div", { className: "min-h-0 flex-1 overflow-auto", children: ge ? /* @__PURE__ */ e("div", { className: "p-3", children: /* @__PURE__ */ e(Ss, {}) }) : te ? /* @__PURE__ */ e("div", { className: "flex flex-col items-center gap-2 px-4 py-12 text-center", children: /* @__PURE__ */ e("p", { className: "text-[13px] text-destructive", children: "Failed to load visuals" }) }) : V.length === 0 ? /* @__PURE__ */ s("div", { className: "flex flex-col items-center gap-2 px-4 py-12 text-center", children: [
1953
+ /* @__PURE__ */ e(Ot, { className: "h-5 w-5 text-muted-foreground/60" }),
1954
+ /* @__PURE__ */ e("p", { className: "text-[13px] font-medium", children: a ? "No visuals found" : "No visuals yet" }),
1955
+ /* @__PURE__ */ e("p", { className: "text-[12px] text-muted-foreground", children: a ? "Try a different search." : "Create a saved visual to add it here." })
1956
+ ] }) : /* @__PURE__ */ e(
1957
+ As,
1958
+ {
1959
+ visuals: V,
1960
+ selectedIds: o,
1961
+ allFilteredSelected: H,
1962
+ someFilteredSelected: ye,
1963
+ onSelectAll: O,
1964
+ onToggleSelection: we,
1965
+ onAddVisual: ce,
1966
+ onOpenVisual: Se,
1967
+ onEditDetails: u,
1968
+ onShareVisual: x,
1969
+ onDeleteVisual: (v) => {
1970
+ l(v), m(!0);
1971
+ },
1972
+ onDuplicateVisual: Fe,
1973
+ duplicatingId: N,
1974
+ isDeleting: j,
1975
+ isConsoleMode: ee
1976
+ }
1977
+ ) }),
1978
+ /* @__PURE__ */ s("div", { className: "flex shrink-0 items-center justify-between gap-2 border-t border-border/60 px-3 py-2", children: [
1979
+ /* @__PURE__ */ e("div", { className: "flex min-w-0 items-center gap-1.5", children: o.size > 0 && /* @__PURE__ */ s(T, { children: [
1980
+ /* @__PURE__ */ s("span", { className: "text-[12px] text-muted-foreground", children: [
1981
+ /* @__PURE__ */ e("span", { className: "font-medium tabular-nums text-foreground", children: o.size }),
1982
+ " ",
1983
+ "selected"
1984
+ ] }),
1985
+ /* @__PURE__ */ e(
1986
+ I,
1987
+ {
1988
+ size: "xs",
1989
+ variant: "ghost",
1990
+ onClick: () => c(/* @__PURE__ */ new Set()),
1991
+ children: "Clear"
1992
+ }
1993
+ ),
1994
+ /* @__PURE__ */ s(
1995
+ I,
1996
+ {
1997
+ size: "xs",
1998
+ variant: "outline",
1999
+ onClick: Ge,
2000
+ disabled: z.length !== 1 || G.length !== 1,
2001
+ children: [
2002
+ /* @__PURE__ */ e(Mt, { className: "h-3.5 w-3.5" }),
2003
+ "Share"
2004
+ ]
2005
+ }
2006
+ ),
2007
+ /* @__PURE__ */ s(
2008
+ I,
2009
+ {
2010
+ size: "xs",
2011
+ variant: "outline",
2012
+ className: "text-destructive hover:text-destructive",
2013
+ onClick: Ee,
2014
+ disabled: y.length === 0,
2015
+ children: [
2016
+ /* @__PURE__ */ e(De, { className: "h-3.5 w-3.5" }),
2017
+ "Delete ",
2018
+ y.length || o.size
2019
+ ]
2020
+ }
2021
+ )
2022
+ ] }) }),
2023
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
2024
+ /* @__PURE__ */ e(
2025
+ I,
2026
+ {
2027
+ size: "xs",
2028
+ variant: "outline",
2029
+ onClick: () => ue(!1),
2030
+ children: "Close"
2031
+ }
2032
+ ),
2033
+ /* @__PURE__ */ s(
2034
+ I,
2035
+ {
2036
+ size: "xs",
2037
+ onClick: Ne,
2038
+ disabled: o.size === 0,
2039
+ children: [
2040
+ /* @__PURE__ */ e(fn, { className: "h-3.5 w-3.5" }),
2041
+ o.size === 0 ? "Add to dashboard" : `Add ${o.size} visual${o.size === 1 ? "" : "s"}`
2042
+ ]
2043
+ }
2044
+ )
2045
+ ] })
2046
+ ] })
2047
+ ]
2048
+ }
2049
+ ) }),
2050
+ /* @__PURE__ */ e(
2051
+ Cs,
2052
+ {
2053
+ open: p,
2054
+ onOpenChange: d,
2055
+ onSubmit: re,
2056
+ isCreating: xe
2057
+ }
2058
+ ),
2059
+ b && /* @__PURE__ */ e(
2060
+ xr,
2061
+ {
2062
+ resource: b,
2063
+ resourceType: et.VISUAL,
2064
+ onClose: () => x(null)
2065
+ }
2066
+ ),
2067
+ i && /* @__PURE__ */ e(
2068
+ jn,
2069
+ {
2070
+ open: !!i,
2071
+ resourceLabel: "Visual",
2072
+ initialTitle: i.title || "",
2073
+ initialDescription: i.description || "",
2074
+ onClose: () => u(null),
2075
+ onSave: Be,
2076
+ isSaving: K(i.id)
2077
+ }
2078
+ ),
2079
+ /* @__PURE__ */ e(
2080
+ vr,
2081
+ {
2082
+ open: g,
2083
+ onOpenChange: (v) => {
2084
+ !v && j || (m(v), v || l(null));
2085
+ },
2086
+ children: /* @__PURE__ */ s(yr, { children: [
2087
+ /* @__PURE__ */ s(wr, { children: [
2088
+ /* @__PURE__ */ s(Nr, { children: [
2089
+ "Delete ",
2090
+ Q,
2091
+ " visual",
2092
+ Q === 1 ? "" : "s",
2093
+ "?"
2094
+ ] }),
2095
+ /* @__PURE__ */ e(Sr, { children: "This cannot be undone. Visuals already added to dashboards may need to be removed from those dashboards separately." })
2096
+ ] }),
2097
+ /* @__PURE__ */ s(Cr, { children: [
2098
+ /* @__PURE__ */ e(Dr, { disabled: j, children: "Cancel" }),
2099
+ /* @__PURE__ */ s(
2100
+ xt,
2101
+ {
2102
+ onClick: (v) => {
2103
+ v.preventDefault(), $e();
2104
+ },
2105
+ disabled: j || Q === 0,
2106
+ children: [
2107
+ j ? /* @__PURE__ */ e(pe, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(De, { className: "h-3.5 w-3.5" }),
2108
+ j ? "Deleting..." : "Delete"
2109
+ ]
2110
+ }
2111
+ )
2112
+ ] })
2113
+ ] })
2114
+ }
2115
+ )
2116
+ ] });
2117
+ }
2118
+ function As({
2119
+ visuals: t,
2120
+ selectedIds: r,
2121
+ allFilteredSelected: a,
2122
+ someFilteredSelected: n,
2123
+ onSelectAll: o,
2124
+ onToggleSelection: c,
2125
+ onAddVisual: p,
2126
+ onOpenVisual: d,
2127
+ onEditDetails: b,
2128
+ onShareVisual: x,
2129
+ onDeleteVisual: i,
2130
+ onDuplicateVisual: u,
2131
+ duplicatingId: g,
2132
+ isDeleting: m,
2133
+ isConsoleMode: f
2134
+ }) {
2135
+ return /* @__PURE__ */ s("div", { className: "min-w-[48rem]", children: [
2136
+ /* @__PURE__ */ s("div", { className: "grid h-9 grid-cols-[2.5rem_minmax(14rem,1.8fr)_minmax(10rem,1fr)_8rem_7rem_5rem_5.5rem] items-center border-b border-border/60 px-3 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: [
2137
+ /* @__PURE__ */ e(
2138
+ kr,
2139
+ {
2140
+ checked: a ? !0 : n ? "indeterminate" : !1,
2141
+ onCheckedChange: o,
2142
+ "aria-label": "Select all visuals"
2143
+ }
2144
+ ),
2145
+ /* @__PURE__ */ e("span", { children: "Name" }),
2146
+ /* @__PURE__ */ e("span", { children: "Created by" }),
2147
+ /* @__PURE__ */ e("span", { children: "Updated" }),
2148
+ /* @__PURE__ */ e("span", { children: "Visibility" }),
2149
+ /* @__PURE__ */ e("span", { className: "text-right", children: "Shared" }),
2150
+ /* @__PURE__ */ e("span", { className: "text-right", children: "Actions" })
2151
+ ] }),
2152
+ t.map((l) => /* @__PURE__ */ e(
2153
+ Is,
2154
+ {
2155
+ visual: l,
2156
+ selected: r.has(l.id),
2157
+ onToggleSelection: c,
2158
+ onAddVisual: p,
2159
+ onOpenVisual: d,
2160
+ onEditDetails: b,
2161
+ onShareVisual: x,
2162
+ onDeleteVisual: i,
2163
+ onDuplicateVisual: u,
2164
+ duplicatingId: g,
2165
+ isDeleting: m,
2166
+ isConsoleMode: f
2167
+ },
2168
+ l.id
2169
+ ))
2170
+ ] });
2171
+ }
2172
+ function Is({
2173
+ visual: t,
2174
+ selected: r,
2175
+ onToggleSelection: a,
2176
+ onAddVisual: n,
2177
+ onOpenVisual: o,
2178
+ onEditDetails: c,
2179
+ onShareVisual: p,
2180
+ onDeleteVisual: d,
2181
+ onDuplicateVisual: b,
2182
+ duplicatingId: x,
2183
+ isDeleting: i,
2184
+ isConsoleMode: u
2185
+ }) {
2186
+ var f;
2187
+ const g = ks(t.kind), m = () => {
2188
+ n(t);
2189
+ };
2190
+ return /* @__PURE__ */ s(
2191
+ "div",
2192
+ {
2193
+ className: ke(
2194
+ "group grid min-h-12 grid-cols-[2.5rem_minmax(14rem,1.8fr)_minmax(10rem,1fr)_8rem_7rem_5rem_5.5rem] items-center border-b border-border/50 px-3 text-[13px] hover:bg-muted/50",
2195
+ r && "bg-muted/70"
2196
+ ),
2197
+ children: [
2198
+ /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(
2199
+ kr,
2200
+ {
2201
+ checked: r,
2202
+ onCheckedChange: () => a(t.id),
2203
+ "aria-label": `Select ${t.title || "visual"}`
2204
+ }
2205
+ ) }),
2206
+ /* @__PURE__ */ s(
2207
+ "button",
2208
+ {
2209
+ type: "button",
2210
+ className: "flex min-w-0 items-center gap-2 rounded-[4px] text-left outline-none focus-visible:ring-1 focus-visible:ring-ring",
2211
+ onClick: m,
2212
+ "aria-label": `Add ${t.title || "visual"} to dashboard`,
2213
+ children: [
2214
+ /* @__PURE__ */ e(g, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
2215
+ /* @__PURE__ */ s("div", { className: "min-w-0", children: [
2216
+ /* @__PURE__ */ e(
2217
+ "div",
2218
+ {
2219
+ className: "truncate font-medium text-foreground",
2220
+ title: t.title || "Untitled Visual",
2221
+ children: t.title || "Untitled Visual"
2222
+ }
2223
+ ),
2224
+ ((f = t.description) == null ? void 0 : f.trim()) && /* @__PURE__ */ e(
2225
+ "div",
2226
+ {
2227
+ className: "truncate text-[11px] text-muted-foreground",
2228
+ title: t.description,
2229
+ children: t.description
2230
+ }
2231
+ )
2232
+ ] })
2233
+ ]
2234
+ }
2235
+ ),
2236
+ /* @__PURE__ */ s("div", { className: "flex min-w-0 items-center gap-2", children: [
2237
+ /* @__PURE__ */ e("div", { className: "flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-muted text-[9px] font-medium text-muted-foreground", children: Ds(t, u) }),
2238
+ /* @__PURE__ */ e("span", { className: "truncate text-muted-foreground", children: Ut(t, u) })
2239
+ ] }),
2240
+ /* @__PURE__ */ e("span", { className: "text-muted-foreground", children: jr(t.updatedAt) }),
2241
+ /* @__PURE__ */ e(Es, { visual: t }),
2242
+ /* @__PURE__ */ e("span", { className: "text-right tabular-nums text-muted-foreground", children: t.ownership.sharedCount > 0 ? t.ownership.sharedCount : "—" }),
2243
+ /* @__PURE__ */ e(
2244
+ Ms,
2245
+ {
2246
+ visual: t,
2247
+ onOpenVisual: o,
2248
+ onEditDetails: c,
2249
+ onShareVisual: p,
2250
+ onDeleteVisual: d,
2251
+ onDuplicateVisual: b,
2252
+ duplicatingId: x,
2253
+ isDeleting: i,
2254
+ isConsoleMode: u
2255
+ }
2256
+ )
2257
+ ]
2258
+ }
2259
+ );
2260
+ }
2261
+ function Ms({
2262
+ visual: t,
2263
+ onOpenVisual: r,
2264
+ onEditDetails: a,
2265
+ onShareVisual: n,
2266
+ onDeleteVisual: o,
2267
+ onDuplicateVisual: c,
2268
+ duplicatingId: p,
2269
+ isDeleting: d,
2270
+ isConsoleMode: b
2271
+ }) {
2272
+ return /* @__PURE__ */ s(
2273
+ "div",
2274
+ {
2275
+ className: "flex items-center justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",
2276
+ onClick: (x) => x.stopPropagation(),
2277
+ children: [
2278
+ /* @__PURE__ */ e(
2279
+ I,
2280
+ {
2281
+ size: "xs",
2282
+ variant: "ghost",
2283
+ className: "w-7 px-0",
2284
+ onClick: () => r(t),
2285
+ "aria-label": "Edit visual",
2286
+ children: /* @__PURE__ */ e(ct, { className: "h-3.5 w-3.5" })
2287
+ }
2288
+ ),
2289
+ /* @__PURE__ */ s(vt, { modal: !1, children: [
2290
+ /* @__PURE__ */ e(yt, { asChild: !0, children: /* @__PURE__ */ e(
2291
+ I,
2292
+ {
2293
+ size: "xs",
2294
+ variant: "ghost",
2295
+ className: "w-7 px-0",
2296
+ "aria-label": "More actions",
2297
+ children: /* @__PURE__ */ e(Kn, { className: "h-3.5 w-3.5" })
2298
+ }
2299
+ ) }),
2300
+ /* @__PURE__ */ s(
2301
+ wt,
2302
+ {
2303
+ align: "end",
2304
+ className: "z-[60] w-44 rounded-[6px] border-border/60 p-1 shadow-sm",
2305
+ children: [
2306
+ /* @__PURE__ */ s(R, { onClick: () => r(t), children: [
2307
+ /* @__PURE__ */ e(ct, { className: "h-3.5 w-3.5" }),
2308
+ "Edit visual"
2309
+ ] }),
2310
+ /* @__PURE__ */ s(
2311
+ R,
2312
+ {
2313
+ onClick: () => c(t.id),
2314
+ disabled: p === t.id,
2315
+ children: [
2316
+ p === t.id ? /* @__PURE__ */ e(pe, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(Nt, { className: "h-3.5 w-3.5" }),
2317
+ p === t.id ? "Duplicating..." : "Duplicate"
2318
+ ]
2319
+ }
2320
+ ),
2321
+ t.permissions.canEdit && /* @__PURE__ */ s(R, { onClick: () => a(t), children: [
2322
+ /* @__PURE__ */ e(ct, { className: "h-3.5 w-3.5" }),
2323
+ "Edit details"
2324
+ ] }),
2325
+ t.permissions.canShare && /* @__PURE__ */ s(R, { onClick: () => n(t), children: [
2326
+ /* @__PURE__ */ e(Mt, { className: "h-3.5 w-3.5" }),
2327
+ "Share"
2328
+ ] }),
2329
+ t.permissions.canDelete && /* @__PURE__ */ s(T, { children: [
2330
+ /* @__PURE__ */ e(Ce, {}),
2331
+ /* @__PURE__ */ s(
2332
+ R,
2333
+ {
2334
+ className: "text-destructive focus:bg-destructive/10 focus:text-destructive",
2335
+ onClick: () => o(t),
2336
+ disabled: d,
2337
+ children: [
2338
+ /* @__PURE__ */ e(De, { className: "h-3.5 w-3.5" }),
2339
+ d ? "Deleting..." : "Delete"
2340
+ ]
2341
+ }
2342
+ )
2343
+ ] }),
2344
+ /* @__PURE__ */ e(Ce, {}),
2345
+ /* @__PURE__ */ s("div", { className: "space-y-1 px-2 py-1.5 text-[11px] text-muted-foreground", children: [
2346
+ Hr(t, b) && /* @__PURE__ */ s("div", { className: "flex items-center gap-1.5", children: [
2347
+ /* @__PURE__ */ e(Qn, { className: "h-3 w-3" }),
2348
+ /* @__PURE__ */ e("span", { className: "truncate", children: Ut(t, b) })
2349
+ ] }),
2350
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-1.5", children: [
2351
+ /* @__PURE__ */ e(It, { className: "h-3 w-3" }),
2352
+ /* @__PURE__ */ e("span", { children: jr(t.updatedAt) })
2353
+ ] })
2354
+ ] })
2355
+ ]
2356
+ }
2357
+ )
2358
+ ] })
2359
+ ]
2360
+ }
2361
+ );
2362
+ }
2363
+ function ir(t, r) {
2364
+ return {
2365
+ dashboard: St(t),
2366
+ semanticExecutionPayload: St(r)
2367
+ };
2368
+ }
2369
+ function Ws() {
2370
+ var jt, Ht, qt, Kt, Qt, Wt, Jt;
2371
+ xa(), va();
2372
+ const {
2373
+ authToken: t,
2374
+ tokenProps: r,
2375
+ id: a,
2376
+ showBriefings: n
2377
+ } = X(), { isLocalDev: o } = br(), { openBrandStudioPreview: c } = Wn(), { permissions: p } = Ka(), d = Jn(), { isLoading: b } = Yn(), x = k((h) => h.theme), i = k((h) => h.isDownloadingPdf), u = k(
2378
+ (h) => h.dashboardAssistantDraftScopeKey
2379
+ ), g = k((h) => h.lenses), m = k((h) => h.selectedLensId), f = g == null ? void 0 : g.find((h) => h.id === m), l = k((h) => h.dashboard), N = k((h) => h.selectedSheetId), S = (jt = l == null ? void 0 : l.sheets) == null ? void 0 : jt.find(
2380
+ (h) => h.id === N
2381
+ ), E = bn(S), L = E ? (Ht = S == null ? void 0 : S.document) == null ? void 0 : Ht.page : void 0, M = k(
2382
+ (h) => h.isDashboardEditing
2383
+ ), { setDashboardTitle: C } = k((h) => h.actions), [Z, ee] = w(!1), [ie, ge] = w(!1), [te, re] = w(!1), [ne, ae] = w(!1), [be, xe] = w(!1), [j, ve] = w(!1), [le, K] = w(!1), [$, V] = w(null), [z, y] = w([]), [G, H] = w(!1), [ye, de] = w(!1), we = k((h) => h.filterValues), O = k((h) => h.isVisualEditing);
2384
+ Xt((h) => h.card);
2385
+ const ce = Xe(
2386
+ (h) => h.selectedDashboard
2387
+ ), Ne = Xe(
2388
+ (h) => h.initialDashboard
2389
+ );
2390
+ Xe((h) => h.selectedVisual), k((h) => h.selectedFrameId), Xt((h) => h.frame);
2391
+ const Se = ce ? (Kt = ce == null ? void 0 : ce.permissions) == null ? void 0 : Kt.canEdit : (qt = Ne == null ? void 0 : Ne.permissions) == null ? void 0 : qt.canEdit, Fe = k(
2392
+ (h) => h.showDashboardJSON
2393
+ ), Ee = k((h) => h.onSaveFunction), {
2394
+ setIsDashboardEditing: $e,
2395
+ setShowDashboardJSON: Ge
2396
+ } = k((h) => h.actions), { setInitialDashboard: Be, clearSelectedDashboard: ue } = Xe(
2397
+ (h) => h.actions
2398
+ ), Q = !!r.orgUserId || !!(r.tenantId && r.endUserId && r.endUserEmail), { resources: v } = Xn(et.DASHBOARD), { data: D } = Zn(), P = ((Qt = D == null ? void 0 : D.preference) == null ? void 0 : Qt.defaultDashboardId) || null, { mutate: q, isPending: se } = ea(), { currentUser: qr } = At(), Kr = ta(qr), W = ce || Ne, Rt = W ? {
2399
+ id: W.id,
2400
+ title: (l == null ? void 0 : l.title) || W.title || "Dashboard"
2401
+ } : null, { handleAddNewFrame: Qr } = ra(), [nt, at] = w(!1), [Wr, Le] = w(!1), [st, je] = w("close"), Ae = na(et.DASHBOARD), [B, He] = w(null), Jr = async (h, U) => {
2402
+ if (!(l != null && l.id)) {
2403
+ console.log("No dashboard ID found");
2404
+ return;
2405
+ }
2406
+ console.log("Updating dashboard title:", {
2407
+ dashboardId: l.id,
2408
+ newTitle: h,
2409
+ previousTitle: U
2410
+ }), Ae.mutate(
2411
+ {
2412
+ resourceId: l.id,
2413
+ data: { title: h }
2414
+ },
2415
+ {
2416
+ onSuccess: () => {
2417
+ console.log("Dashboard title updated successfully"), A.success("Dashboard title updated");
2418
+ },
2419
+ onError: (J) => {
2420
+ console.error("Failed to update dashboard title:", J), A.error("Failed to update dashboard title"), C(U);
2421
+ }
2422
+ }
2423
+ );
2424
+ };
2425
+ Re(() => {
2426
+ if (v && v.length > 0) {
2427
+ const h = l == null ? void 0 : l.id;
2428
+ if (h) {
2429
+ const U = v.find(
2430
+ (J) => J.id === h
2431
+ );
2432
+ U && Be(U);
2433
+ }
2434
+ }
2435
+ }, [v, l == null ? void 0 : l.id, Be]);
2436
+ const Ie = r.orgUserId || r.tenantId, ot = Y(
2437
+ () => Os({
2438
+ accessToken: t == null ? void 0 : t.accessToken,
2439
+ dashboardId: (l == null ? void 0 : l.id) || a || r.dashboard_id,
2440
+ selectedSheetId: E ? N : void 0,
2441
+ pageSize: L == null ? void 0 : L.size,
2442
+ orientation: L == null ? void 0 : L.orientation,
2443
+ theme: x
2444
+ }),
2445
+ [
2446
+ t == null ? void 0 : t.accessToken,
2447
+ a,
2448
+ l == null ? void 0 : l.id,
2449
+ E,
2450
+ L == null ? void 0 : L.orientation,
2451
+ L == null ? void 0 : L.size,
2452
+ N,
2453
+ x,
2454
+ r.dashboard_id
2455
+ ]
2456
+ ), Tt = M && !O && Ie && Se, { setDashboard: Vt } = k((h) => h.actions), zt = k(
2457
+ (h) => h.semanticExecutionPayload
2458
+ ), Yr = () => {
2459
+ $e(!0);
2460
+ }, it = () => {
2461
+ $e(!1), Ge(!1), He(null);
2462
+ };
2463
+ Re(() => {
2464
+ if (!M) {
2465
+ B && He(null);
2466
+ return;
2467
+ }
2468
+ B || !l || b || He(
2469
+ ir(
2470
+ l,
2471
+ zt
2472
+ )
2473
+ );
2474
+ }, [
2475
+ l,
2476
+ B,
2477
+ M,
2478
+ b,
2479
+ zt
2480
+ ]);
2481
+ const qe = (B == null ? void 0 : B.dashboard) ?? null, { isDirty: Ft, isDirtyPending: Xr, resetDirty: Ke } = La(
2482
+ l,
2483
+ qe,
2484
+ 300,
2485
+ 1e3,
2486
+ ut
2487
+ ), $t = fa(() => qe ? ut(l) !== ut(qe) : !1, [l, qe]), Gt = Ft || Xr, Qe = nt || Ae.isPending, Zr = () => {
2488
+ $t() ? (je("close"), Le(!0)) : (it(), Ke());
2489
+ }, en = async () => {
2490
+ await lt({
2491
+ closeAfterSave: !0,
2492
+ navigateHomeAfterSave: st === "home"
2493
+ });
2494
+ }, tn = () => {
2495
+ const h = st === "home" && !!Q;
2496
+ B && Vt(B.dashboard, {
2497
+ semanticExecutionPayload: B.semanticExecutionPayload
2498
+ }), it(), h && ue(), je("close"), Le(!1), Ke();
2499
+ }, rn = () => {
2500
+ B && (Vt(B.dashboard, {
2501
+ semanticExecutionPayload: B.semanticExecutionPayload
2502
+ }), Ke());
2503
+ }, nn = () => {
2504
+ if (Q) {
2505
+ if (M && $t()) {
2506
+ je("home"), Le(!0);
2507
+ return;
2508
+ }
2509
+ ue();
2510
+ }
2511
+ };
2512
+ async function lt(h) {
2513
+ const U = k.getState().dashboard;
2514
+ if (!U)
2515
+ return;
2516
+ const J = (h == null ? void 0 : h.closeAfterSave) ?? G, cn = (h == null ? void 0 : h.navigateHomeAfterSave) ?? !1;
2517
+ H(J), J && Le(!1);
2518
+ const un = St(U);
2519
+ K(!0), V(null), y([]), at(!0);
2520
+ const mn = {
2521
+ template: U
2522
+ };
2523
+ Ae.mutate(
2524
+ {
2525
+ resourceId: U.id,
2526
+ data: mn
2527
+ },
2528
+ {
2529
+ onSuccess: (F) => {
2530
+ var We, Je, Yt;
2531
+ const he = (F == null ? void 0 : F.id) || ((We = F == null ? void 0 : F.dashboard) == null ? void 0 : We.id) || ((Je = F == null ? void 0 : F.resource) == null ? void 0 : Je.id) || ((Yt = F == null ? void 0 : F.template) == null ? void 0 : Yt.id) || null;
2532
+ if (!U.id && he) {
2533
+ const dt = Cn.getState(), Ye = dt.pendingDashboardDraftMigration;
2534
+ (Ye == null ? void 0 : Ye.scopeKey) === u ? dt.actions.setPendingDashboardDraftMigrationExpectedDashboardId(
2535
+ he
2536
+ ) : Ye && dt.actions.clearPendingDashboardDraftMigration();
2537
+ }
2538
+ at(!1), A.success("Dashboard saved!"), He(
2539
+ ir(
2540
+ un,
2541
+ k.getState().semanticExecutionPayload
2542
+ )
2543
+ ), K(!1), H(!1), J && (it(), Ke(), cn && Q && ue()), je("close");
2544
+ },
2545
+ onError: (F) => {
2546
+ at(!1), V("Failed to save dashboard. Please try again.");
2547
+ const he = F.details, We = Array.isArray(
2548
+ he == null ? void 0 : he.errors
2549
+ ) ? (he.errors || []).filter(
2550
+ (Je) => typeof Je == "string"
2551
+ ) : [];
2552
+ y(
2553
+ ws({
2554
+ errors: We,
2555
+ dashboard: U || void 0
2556
+ })
2557
+ ), A.error("Failed to save dashboard");
2558
+ }
2559
+ }
2560
+ );
2561
+ }
2562
+ async function an() {
2563
+ if (ee(!0), !m || !f) return;
2564
+ const h = k.getState().dashboard;
2565
+ if (!h) {
2566
+ ee(!1);
2567
+ return;
2568
+ }
2569
+ const U = JSON.stringify(h), J = {
2570
+ ...f,
2571
+ template: U,
2572
+ filterValues: we
2573
+ };
2574
+ await Dt(
2575
+ r.apiServiceUrl,
2576
+ J,
2577
+ t == null ? void 0 : t.accessToken
2578
+ ), A.success("Lens saved"), Ee == null || Ee(h), ee(!1);
2579
+ }
2580
+ const Bt = (f == null ? void 0 : f.name) || l.title;
2581
+ Ae.isPending && console.log("Title during update:", {
2582
+ title: Bt,
2583
+ dashboardStateTitle: l.title,
2584
+ dashboardId: l == null ? void 0 : l.id,
2585
+ currentLensName: f == null ? void 0 : f.name
2586
+ });
2587
+ const sn = Q && !!(t != null && t.accessToken) && !!(r != null && r.apiServiceUrl), on = d && Q, me = (l == null ? void 0 : l.id) || null, ln = Ns(
2588
+ (Wt = r.config) == null ? void 0 : Wt.showBriefings,
2589
+ n
2590
+ ), Me = !!me && P === me, dn = () => {
2591
+ me && q({
2592
+ dashboardId: Me ? null : me
2593
+ });
2594
+ };
2595
+ return !d && !O ? null : /* @__PURE__ */ s(
2596
+ "div",
2597
+ {
2598
+ className: "flex h-11 shrink-0 items-center justify-between gap-2 overflow-x-auto border-b px-4 py-2",
2599
+ role: "dashboard-controls",
2600
+ children: [
2601
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
2602
+ on && !O && /* @__PURE__ */ e(
2603
+ er,
2604
+ {
2605
+ "aria-label": "Dashboard Hub",
2606
+ tooltip: "Dashboard Hub",
2607
+ onClick: nn,
2608
+ className: "h-7 w-7 px-0",
2609
+ buttonProps: { size: "xs" },
2610
+ children: /* @__PURE__ */ e(mr, { className: "h-3.5 w-3.5" })
2611
+ }
2612
+ ),
2613
+ !O && d && (b ? /* @__PURE__ */ e(
2614
+ "div",
2615
+ {
2616
+ className: "h-4 w-28 animate-pulse rounded-md bg-muted/70",
2617
+ "aria-label": "Loading dashboard title",
2618
+ role: "status",
2619
+ children: /* @__PURE__ */ e("span", { className: "sr-only", children: "Loading dashboard title" })
2620
+ }
2621
+ ) : /* @__PURE__ */ s(T, { children: [
2622
+ /* @__PURE__ */ e(
2623
+ aa,
2624
+ {
2625
+ value: Bt || "Untitled Dashboard",
2626
+ onSave: (h) => {
2627
+ console.log("EditableText onSave called:", {
2628
+ newTitle: h,
2629
+ canEditDashboard: Se,
2630
+ dashboardId: l == null ? void 0 : l.id
2631
+ });
2632
+ const U = (l == null ? void 0 : l.title) || "";
2633
+ C(h), Jr(h, U);
2634
+ },
2635
+ isEditable: Se && !f,
2636
+ displayClassName: "text-[13px] font-medium",
2637
+ inputClassName: "text-[13px] font-medium",
2638
+ placeholder: "Dashboard Title",
2639
+ isPending: Ae.isPending
2640
+ }
2641
+ ),
2642
+ Me && /* @__PURE__ */ e(
2643
+ "span",
2644
+ {
2645
+ className: "shrink-0 rounded-[4px] border border-border/60 px-1.5 py-px text-[10px] font-medium uppercase tracking-[0.06em] text-muted-foreground",
2646
+ title: "Default dashboard",
2647
+ children: "Default"
2648
+ }
2649
+ ),
2650
+ sn && me && /* @__PURE__ */ e(xn, { children: /* @__PURE__ */ s(vn, { children: [
2651
+ /* @__PURE__ */ e(yn, { asChild: !0, children: /* @__PURE__ */ e(
2652
+ I,
2653
+ {
2654
+ variant: "ghost",
2655
+ size: "xs",
2656
+ onClick: dn,
2657
+ disabled: se || !(t != null && t.accessToken) || !(r != null && r.apiServiceUrl),
2658
+ className: "w-7 px-0 text-muted-foreground hover:text-foreground",
2659
+ "aria-label": Me ? "Clear default dashboard" : "Set as default dashboard",
2660
+ children: Me ? /* @__PURE__ */ e(sa, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ e(oa, { className: "h-3.5 w-3.5" })
2661
+ }
2662
+ ) }),
2663
+ /* @__PURE__ */ e(wn, { children: /* @__PURE__ */ e("p", { children: Me ? "Clear default" : "Set as default" }) })
2664
+ ] }) })
2665
+ ] }))
2666
+ ] }),
2667
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
2668
+ O && /* @__PURE__ */ s(T, { children: [
2669
+ /* @__PURE__ */ e(ya, {}),
2670
+ /* @__PURE__ */ e(wa, {})
2671
+ ] }),
2672
+ !O && d && ((Jt = W == null ? void 0 : W.permissions) == null ? void 0 : Jt.canShare) && /* @__PURE__ */ s(
2673
+ I,
2674
+ {
2675
+ variant: "outline",
2676
+ size: "xs",
2677
+ onClick: () => ge(!0),
2678
+ children: [
2679
+ /* @__PURE__ */ e(Mt, { className: "h-3.5 w-3.5" }),
2680
+ "Share"
2681
+ ]
2682
+ }
2683
+ ),
2684
+ !O && !M && d && me && ln && /* @__PURE__ */ e(
2685
+ Na,
2686
+ {
2687
+ dashboardId: me,
2688
+ dashboardTitle: (l == null ? void 0 : l.title) || (W == null ? void 0 : W.title)
2689
+ }
2690
+ ),
2691
+ !O && M && p.canUseFilters && d && /* @__PURE__ */ e(Sa, {}),
2692
+ M && !O && Ie && f && o && d && /* @__PURE__ */ s(
2693
+ I,
2694
+ {
2695
+ variant: "secondary",
2696
+ size: "xs",
2697
+ disabled: Z,
2698
+ onClick: an,
2699
+ children: [
2700
+ /* @__PURE__ */ e(rr, { className: "h-3.5 w-3.5" }),
2701
+ "Save Lens"
2702
+ ]
2703
+ }
2704
+ ),
2705
+ M && !O && d && !E && /* @__PURE__ */ s("div", { className: "inline-flex h-7 items-stretch overflow-hidden rounded-control border border-input bg-background", children: [
2706
+ /* @__PURE__ */ s(
2707
+ I,
2708
+ {
2709
+ variant: "ghost",
2710
+ size: "xs",
2711
+ disabled: !M,
2712
+ onClick: () => void Qr(),
2713
+ className: "h-full rounded-none border-0 shadow-none hover:bg-accent",
2714
+ children: [
2715
+ /* @__PURE__ */ e(oe, { className: "h-3.5 w-3.5" }),
2716
+ "Visual"
2717
+ ]
2718
+ }
2719
+ ),
2720
+ /* @__PURE__ */ s(vt, { modal: !1, children: [
2721
+ /* @__PURE__ */ e(yt, { asChild: !0, children: /* @__PURE__ */ e(
2722
+ I,
2723
+ {
2724
+ variant: "ghost",
2725
+ size: "xs",
2726
+ className: "h-full w-7 rounded-none border-0 border-l border-border/60 px-0 shadow-none hover:bg-accent",
2727
+ "aria-label": "Open visual options",
2728
+ disabled: !M,
2729
+ children: /* @__PURE__ */ e(Nn, { className: "h-3.5 w-3.5" })
2730
+ }
2731
+ ) }),
2732
+ /* @__PURE__ */ e(
2733
+ wt,
2734
+ {
2735
+ align: "end",
2736
+ className: "z-[60] w-48 rounded-[6px] border-border/60 p-1 shadow-sm",
2737
+ children: /* @__PURE__ */ s(R, { onClick: () => de(!0), children: [
2738
+ /* @__PURE__ */ e(oe, { className: "h-3.5 w-3.5" }),
2739
+ "From library..."
2740
+ ] })
2741
+ }
2742
+ )
2743
+ ] }),
2744
+ /* @__PURE__ */ e(
2745
+ Ls,
2746
+ {
2747
+ open: ye,
2748
+ onOpenChange: de
2749
+ }
2750
+ )
2751
+ ] }),
2752
+ !O && !M && Se && d && /* @__PURE__ */ s(I, { size: "xs", onClick: Yr, children: [
2753
+ /* @__PURE__ */ e(ia, { className: "h-3.5 w-3.5" }),
2754
+ "Edit"
2755
+ ] }),
2756
+ Tt && d && Ft && /* @__PURE__ */ s(
2757
+ I,
2758
+ {
2759
+ variant: "outline",
2760
+ size: "xs",
2761
+ onClick: rn,
2762
+ disabled: Qe,
2763
+ children: [
2764
+ /* @__PURE__ */ e(Ca, { className: "h-3.5 w-3.5" }),
2765
+ "Undo"
2766
+ ]
2767
+ }
2768
+ ),
2769
+ Tt && d && /* @__PURE__ */ s(
2770
+ I,
2771
+ {
2772
+ size: "xs",
2773
+ className: ke(!Gt && "opacity-60"),
2774
+ disabled: Qe || !Gt,
2775
+ onClick: () => lt(),
2776
+ children: [
2777
+ Qe ? /* @__PURE__ */ e(pe, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(rr, { className: "h-3.5 w-3.5" }),
2778
+ Qe ? "Saving..." : "Save"
2779
+ ]
2780
+ }
2781
+ ),
2782
+ M && !O && d && /* @__PURE__ */ s(I, { variant: "outline", size: "xs", onClick: Zr, children: [
2783
+ /* @__PURE__ */ e(hr, { className: "h-3.5 w-3.5" }),
2784
+ "Close"
2785
+ ] }),
2786
+ !O && d && /* @__PURE__ */ e("div", { className: "ml-2", children: /* @__PURE__ */ e(Da, {}) }),
2787
+ !O && o && /* @__PURE__ */ e($a, {}),
2788
+ !O && d && /* @__PURE__ */ s(vt, { children: [
2789
+ /* @__PURE__ */ e(yt, { asChild: !0, children: /* @__PURE__ */ e(
2790
+ er,
2791
+ {
2792
+ tooltip: "More Options",
2793
+ className: "w-7 px-0 text-muted-foreground hover:text-foreground",
2794
+ buttonProps: {
2795
+ size: "xs",
2796
+ variant: "ghost",
2797
+ "aria-label": "More dashboard options"
2798
+ },
2799
+ children: /* @__PURE__ */ e(la, { className: "h-3.5 w-3.5" })
2800
+ }
2801
+ ) }),
2802
+ /* @__PURE__ */ s(
2803
+ wt,
2804
+ {
2805
+ align: "end",
2806
+ className: "w-56 rounded-control border border-border/60 p-1 shadow-sm",
2807
+ children: [
2808
+ /* @__PURE__ */ e(_e, { children: "Reports" }),
2809
+ /* @__PURE__ */ s(
2810
+ R,
2811
+ {
2812
+ disabled: i,
2813
+ onSelect: () => ve(!0),
2814
+ children: [
2815
+ /* @__PURE__ */ e(da, { className: "h-3.5 w-3.5" }),
2816
+ "Export"
2817
+ ]
2818
+ }
2819
+ ),
2820
+ /* @__PURE__ */ e(Ce, {}),
2821
+ Kr && /* @__PURE__ */ s(T, { children: [
2822
+ /* @__PURE__ */ e(_e, { children: "Access" }),
2823
+ /* @__PURE__ */ s(
2824
+ R,
2825
+ {
2826
+ onClick: () => re(!0),
2827
+ children: [
2828
+ /* @__PURE__ */ e(gr, { className: "h-3.5 w-3.5" }),
2829
+ "Manage Groups"
2830
+ ]
2831
+ }
2832
+ ),
2833
+ /* @__PURE__ */ e(Ce, {})
2834
+ ] }),
2835
+ /* @__PURE__ */ e(_e, { children: "Preferences" }),
2836
+ /* @__PURE__ */ s(R, { onClick: () => ae(!0), children: [
2837
+ /* @__PURE__ */ e(It, { className: "h-3.5 w-3.5" }),
2838
+ "Calendar Preferences"
2839
+ ] }),
2840
+ o && d && /* @__PURE__ */ s(T, { children: [
2841
+ /* @__PURE__ */ e(Ce, {}),
2842
+ /* @__PURE__ */ e(_e, { children: "Developer" }),
2843
+ /* @__PURE__ */ s(
2844
+ R,
2845
+ {
2846
+ onSelect: () => {
2847
+ var h;
2848
+ t != null && t.accessToken && ((h = navigator == null ? void 0 : navigator.clipboard) != null && h.writeText ? navigator.clipboard.writeText(t.accessToken).then(
2849
+ () => A.success("Token copied to clipboard")
2850
+ ).catch(() => A.error("Unable to copy token")) : A.error("Clipboard not available"));
2851
+ },
2852
+ children: [
2853
+ /* @__PURE__ */ e(Nt, { className: "h-3.5 w-3.5" }),
2854
+ "Copy token"
2855
+ ]
2856
+ }
2857
+ ),
2858
+ E && /* @__PURE__ */ s(
2859
+ R,
2860
+ {
2861
+ disabled: !ot,
2862
+ onSelect: () => {
2863
+ var h;
2864
+ if (!ot) {
2865
+ A.error(
2866
+ "Open a document sheet with a token to copy the local PDF URL"
2867
+ );
2868
+ return;
2869
+ }
2870
+ (h = navigator == null ? void 0 : navigator.clipboard) != null && h.writeText ? navigator.clipboard.writeText(ot).then(
2871
+ () => A.success(
2872
+ "Local document PDF URL copied to clipboard"
2873
+ )
2874
+ ).catch(
2875
+ () => A.error(
2876
+ "Unable to copy local document PDF URL"
2877
+ )
2878
+ ) : A.error("Clipboard not available");
2879
+ },
2880
+ children: [
2881
+ /* @__PURE__ */ e(Nt, { className: "h-3.5 w-3.5" }),
2882
+ "Copy local document PDF URL"
2883
+ ]
2884
+ }
2885
+ ),
2886
+ /* @__PURE__ */ s(
2887
+ R,
2888
+ {
2889
+ onSelect: () => Sn(r.apiServiceUrl),
2890
+ children: [
2891
+ /* @__PURE__ */ e(Ua, { className: "h-3.5 w-3.5" }),
2892
+ "Invalidate token"
2893
+ ]
2894
+ }
2895
+ ),
2896
+ /* @__PURE__ */ s(R, { onSelect: c, children: [
2897
+ /* @__PURE__ */ e(Ma, { className: "h-3.5 w-3.5" }),
2898
+ "Brand Studio"
2899
+ ] }),
2900
+ M && /* @__PURE__ */ s(
2901
+ R,
2902
+ {
2903
+ onSelect: () => Ge(!Fe),
2904
+ children: [
2905
+ /* @__PURE__ */ e(Aa, { className: "h-3.5 w-3.5" }),
2906
+ Fe ? "Hide dashboard JSON" : "Show dashboard JSON"
2907
+ ]
2908
+ }
2909
+ ),
2910
+ Ie && M && /* @__PURE__ */ s(R, { onSelect: () => xe(!0), children: [
2911
+ /* @__PURE__ */ e(oe, { className: "h-3.5 w-3.5" }),
2912
+ "Add lens"
2913
+ ] }),
2914
+ Ie && /* @__PURE__ */ s(ca, { children: [
2915
+ /* @__PURE__ */ s(ua, { children: [
2916
+ /* @__PURE__ */ e(Oa, { className: "h-3.5 w-3.5" }),
2917
+ "Lenses"
2918
+ ] }),
2919
+ /* @__PURE__ */ e(ma, { className: "w-60", children: /* @__PURE__ */ e(qa, {}) })
2920
+ ] })
2921
+ ] })
2922
+ ]
2923
+ }
2924
+ )
2925
+ ] }),
2926
+ ie && Rt && /* @__PURE__ */ e(
2927
+ xr,
2928
+ {
2929
+ resource: Rt,
2930
+ resourceType: et.DASHBOARD,
2931
+ onClose: () => ge(!1)
2932
+ }
2933
+ ),
2934
+ /* @__PURE__ */ e(
2935
+ ps,
2936
+ {
2937
+ open: te,
2938
+ onOpenChange: re
2939
+ }
2940
+ ),
2941
+ /* @__PURE__ */ e(
2942
+ Ea,
2943
+ {
2944
+ open: ne,
2945
+ onOpenChange: ae
2946
+ }
2947
+ ),
2948
+ o && Ie && d && /* @__PURE__ */ e(Ha, { open: be, onOpenChange: xe }),
2949
+ d && /* @__PURE__ */ e(
2950
+ ha,
2951
+ {
2952
+ open: j,
2953
+ onOpenChange: ve
2954
+ }
2955
+ ),
2956
+ /* @__PURE__ */ e(
2957
+ vr,
2958
+ {
2959
+ open: le,
2960
+ onOpenChange: (h) => {
2961
+ !h && nt && !$ || (K(h), h || (V(null), y([]), H(!1)));
2962
+ },
2963
+ children: /* @__PURE__ */ s(yr, { className: "max-w-sm", children: [
2964
+ /* @__PURE__ */ s(wr, { children: [
2965
+ /* @__PURE__ */ e(Nr, { children: $ ? "Save failed" : "Saving dashboard" }),
2966
+ /* @__PURE__ */ e(Sr, { className: "pt-2", children: $ ? "We could not save the dashboard. Please try again." : "Please wait while we save your changes." }),
2967
+ z.length > 0 && /* @__PURE__ */ s("div", { className: "space-y-1 rounded-md border border-destructive/20 bg-destructive/5 p-3 text-left", children: [
2968
+ /* @__PURE__ */ e("div", { className: "text-sm font-medium text-destructive", children: "What needs attention" }),
2969
+ /* @__PURE__ */ e("ul", { className: "list-disc space-y-1 pl-4 text-xs text-muted-foreground", children: z.slice(0, 5).map((h) => /* @__PURE__ */ e("li", { children: h }, h)) })
2970
+ ] })
2971
+ ] }),
2972
+ /* @__PURE__ */ e(Cr, { className: "flex-col gap-2 sm:flex-row sm:justify-end", children: $ ? /* @__PURE__ */ s(T, { children: [
2973
+ /* @__PURE__ */ e(
2974
+ Dr,
2975
+ {
2976
+ onClick: () => {
2977
+ K(!1), V(null), y([]), H(!1);
2978
+ },
2979
+ className: "m-0",
2980
+ children: "Close"
2981
+ }
2982
+ ),
2983
+ /* @__PURE__ */ e(
2984
+ xt,
2985
+ {
2986
+ onClick: () => lt({
2987
+ closeAfterSave: G,
2988
+ navigateHomeAfterSave: st === "home"
2989
+ }),
2990
+ className: "m-0",
2991
+ children: "Retry"
2992
+ }
2993
+ )
2994
+ ] }) : /* @__PURE__ */ s(xt, { disabled: !0, className: "m-0 cursor-default", children: [
2995
+ /* @__PURE__ */ e(pe, { className: "mr-2 h-4 w-4 animate-spin" }),
2996
+ "Saving..."
2997
+ ] }) })
2998
+ ] })
2999
+ }
3000
+ ),
3001
+ /* @__PURE__ */ e(
3002
+ ka,
3003
+ {
3004
+ open: Wr,
3005
+ onOpenChange: (h) => {
3006
+ Le(h);
3007
+ },
3008
+ onSave: en,
3009
+ onDiscard: tn,
3010
+ isSaving: nt,
3011
+ saveLabel: "Save",
3012
+ discardLabel: "Discard"
3013
+ }
3014
+ )
3015
+ ] })
3016
+ ]
3017
+ }
3018
+ );
3019
+ }
3020
+ function Os({
3021
+ accessToken: t,
3022
+ dashboardId: r,
3023
+ selectedSheetId: a,
3024
+ pageSize: n,
3025
+ orientation: o,
3026
+ theme: c
3027
+ }) {
3028
+ if (!t || !a)
3029
+ return null;
3030
+ const p = new URL("http://localhost:5173/print-document");
3031
+ p.searchParams.set("token", t), r && p.searchParams.set("dashboardId", r), p.searchParams.set("selectedSheetId", a), c && p.searchParams.set("theme", c);
3032
+ const d = new URL("http://127.0.0.1:3002/");
3033
+ return d.searchParams.set("pdfMode", "document"), d.searchParams.set("pageSize", n || "letter"), d.searchParams.set("orientation", o || "portrait"), d.searchParams.set("url", p.toString()), d.toString();
3034
+ }
3035
+ export {
3036
+ Ws as default
3037
+ };