react-semaphor 0.1.547 → 0.1.549

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 (40) hide show
  1. package/dist/analytics-protocol/index.js +1 -1
  2. package/dist/assistant-context/index.js +1 -1
  3. package/dist/briefings/index.js +1 -1
  4. package/dist/chunks/{assistant-chat-CK84cPAB.js → assistant-chat-CUSvuESS.js} +1831 -1846
  5. package/dist/chunks/{custom-visual-inputs-ChL54gGm.js → custom-visual-inputs-CwAcigQS.js} +1 -1
  6. package/dist/chunks/{dashboard-DCk26-6i.js → dashboard-Cm7WkARH.js} +1 -1
  7. package/dist/chunks/{dashboard-briefing-launcher-CQ1eYsGy.js → dashboard-briefing-launcher-X0HzNpS8.js} +627 -629
  8. package/dist/chunks/{dashboard-controls-BMeZjF7r.js → dashboard-controls-BuX6TMNK.js} +219 -219
  9. package/dist/chunks/{dashboard-json-BZqCoanC.js → dashboard-json-Cc4u2xvy.js} +1 -1
  10. package/dist/chunks/{document-dashboard-inputs-tYd7ao0o.js → document-dashboard-inputs-DPQ_wUGD.js} +2 -2
  11. package/dist/chunks/{edit-dashboard-visual-Bv3MHM_G.js → edit-dashboard-visual-DX2CzibK.js} +606 -606
  12. package/dist/chunks/{filter-reach-copy-CGWsL_ez.js → filter-reach-copy-Bc-Gei83.js} +4 -4
  13. package/dist/chunks/{global-date-filter-utils-BhAu8zIM.js → global-date-filter-utils-CnumW4j2.js} +1657 -1652
  14. package/dist/chunks/{index-DmrLP5Ro.js → index-DzsdV1o4.js} +3 -3
  15. package/dist/chunks/{raw-temporal-presentation-DypB7sMX.js → raw-temporal-presentation-CBKeEPYA.js} +1 -1
  16. package/dist/chunks/report-preferences-dialog-B9oYQ6OJ.js +2180 -0
  17. package/dist/chunks/{resolve-dashboard-input-context-D0JDUa4h.js → resolve-dashboard-input-context-DVWF7p5C.js} +2 -2
  18. package/dist/chunks/{saved-dashboard-context-BfAH5j4L.js → saved-dashboard-context-BMqMzNAo.js} +4 -4
  19. package/dist/chunks/{semaphor-ready-indicator-CRm17oIP.js → semaphor-ready-indicator-wWkPH4ue.js} +23405 -23367
  20. package/dist/chunks/{shelf-drop-preview-context-vy6P9THz.js → shelf-drop-preview-context-B86d8IZO.js} +3 -3
  21. package/dist/chunks/{source-entity-resolution-BIGRvtbG.js → source-entity-resolution-D195CrYS.js} +221 -192
  22. package/dist/chunks/{use-create-flow-overlay-state-Csx_Xjsh.js → use-create-flow-overlay-state-DPNjYyi3.js} +2 -2
  23. package/dist/dashboard/index.js +1 -1
  24. package/dist/dashboard-authoring/index.js +7 -7
  25. package/dist/data-app-sdk-validation/index.js +1 -1
  26. package/dist/index.js +12 -12
  27. package/dist/live-channel/index.js +124 -0
  28. package/dist/style.css +1 -1
  29. package/dist/surfboard/index.js +1 -1
  30. package/dist/types/components/surfboard/dashboard-plus.d.ts +1 -1
  31. package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-authoring.d.ts +42 -6
  32. package/dist/types/lib/stores/dashboard-store.d.ts +9 -0
  33. package/dist/types/lib/types/common-types.d.ts +26 -1
  34. package/dist/types/live-channel.d.ts +2 -0
  35. package/dist/types/shared/assistant-protocol/parts.d.ts +11 -0
  36. package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +14 -44
  37. package/dist/types/shared/live-channel/index.d.ts +1 -0
  38. package/dist/types/shared/live-channel/live-channel-contract.d.ts +126 -0
  39. package/package.json +5 -1
  40. package/dist/chunks/report-preferences-dialog-DoVyriYC.js +0 -1977
@@ -1,1977 +0,0 @@
1
- import { jsxs as h, jsx as l, Fragment as ie } from "react/jsx-runtime";
2
- import * as p from "react";
3
- import Lt, { useRef as Y, useState as L, useCallback as $, useEffect as ee, useMemo as q, lazy as Se, Suspense as ye, useLayoutEffect as Xe, Activity as _t, useId as ce } from "react";
4
- import { u as M, be as Mt, bf as Ut, bg as mt, a1 as Ot, bh as jt, bi as Bt, bj as Wt, b as $t, b2 as We, bk as Vt, bl as Kt, bm as ft, t as Ht, bn as qt, bo as Gt, bp as Xt, bq as Jt, br as be, bs as ht, bt as Je, E as Yt, F as Zt, S as Qt, B as ea, a as ta, U as aa, bu as ra, D as na, A as la, C as sa, bv as ia, bw as oa, bx as da, by as ca, bz as Ye, bA as Ne, bB as ua, bC as $e, bD as H, bE as ma, bF as fa, bG as ha, bH as pa, bI as va } from "./semaphor-ready-indicator-CRm17oIP.js";
5
- import "./validators-C-aOQlTB.js";
6
- import "./matrix-operation-contract-D6vYkZK4.js";
7
- import "./analytics-base-schemas-BKs3flFS.js";
8
- import "zod";
9
- import { Y as ba, cU as ga, bq as ya, br as wa, as as Sa, s as xa } from "./global-date-filter-utils-BhAu8zIM.js";
10
- import { j as Ca } from "./index-CuHybtft.js";
11
- import { parseValueFormatPreferencesResponse as Na, canonicalizeSupportedLocale as pt, getSupportedCurrencyCodes as Ea, canonicalizeSupportedCurrencyCode as Ta } from "../value-format-preferences/index.js";
12
- import { c as U } from "./_commonjsHelpers-DimLPMtv.js";
13
- import "./index-CtoK1Lgu.js";
14
- import "./pivot-result-lifecycle-pwq3b7LC.js";
15
- import { H as Ia } from "./table-settings-WysCBj62.js";
16
- import { l as oe, B as V, N as ka, O as Aa, Q as Da, U as Ra, V as Pa, W as za, X as se, z as Q, Y as he, P as Fa, a as La, b as _a, c as Ze, L as vt, r as Pe, s as ze, t as Fe, u as Le, v as J, T as Ma, d as Ua, e as Qe, g as et } from "./switch-CEBOR4n7.js";
17
- import { X as Oa } from "./x-4f5U2XwU.js";
18
- import { r as ja, a as bt } from "./availability-Bp5Gfu1I.js";
19
- import { S as Ba } from "./selection-reducer-CJzkTZio.js";
20
- import { a as Wa } from "./report-runtime-context-hWiTCzFV.js";
21
- import { r as ge, M as ue } from "./temporal-bucket-CQOSbv9-.js";
22
- function $a(e = []) {
23
- const a = Y(null), t = Y(null), n = Y(null), [r, i] = L(), s = $(() => {
24
- var m, x, I;
25
- const o = ((m = a.current) == null ? void 0 : m.clientWidth) ?? 0, f = ((x = n.current) == null ? void 0 : x.offsetWidth) ?? 0, u = ((I = t.current) == null ? void 0 : I.offsetWidth) ?? 0, c = o - f - u - 8, v = Math.max(c, 0);
26
- i((w) => w === v ? w : v);
27
- }, []);
28
- return ee(() => {
29
- const o = a.current;
30
- if (!o || typeof ResizeObserver > "u") return;
31
- const f = new ResizeObserver(() => s());
32
- return f.observe(o), s(), () => f.disconnect();
33
- }, [s, ...e]), {
34
- headerRef: a,
35
- leftActionsRef: t,
36
- rightActionsRef: n,
37
- titleMaxWidth: r,
38
- updateAvailableWidth: s
39
- };
40
- }
41
- function Va({ filter: e }) {
42
- var w;
43
- const a = M(
44
- (y) => y.isDashboardEditing
45
- ), { preferences: t } = Mt(), n = Ut((w = t == null ? void 0 : t.cardDisplay) == null ? void 0 : w.mode), r = M((y) => y.dashboard), i = M(
46
- (y) => y.dashboardInputValues
47
- ), s = M((y) => y.selectedSheetId), o = mt(), f = q(() => {
48
- var F;
49
- const y = (F = ba(r).findFilterInput({
50
- filterId: e.id
51
- })) == null ? void 0 : F.input;
52
- if (!y) return !1;
53
- const P = ga({
54
- dashboard: r,
55
- input: y,
56
- runtimeValues: i,
57
- target: { sheetId: s },
58
- calendar: o
59
- });
60
- return (P == null ? void 0 : P.status) === "set";
61
- }, [o, r, i, e.id, s]), { removeFilterInput: u, saveFilterSettings: g } = Ot(), {
62
- headerRef: c,
63
- leftActionsRef: v,
64
- rightActionsRef: m,
65
- titleMaxWidth: x,
66
- updateAvailableWidth: I
67
- } = $a([
68
- a,
69
- f,
70
- n
71
- ]);
72
- return ee(() => {
73
- I();
74
- }, [e.title, I]), /* @__PURE__ */ h(
75
- "div",
76
- {
77
- ref: c,
78
- className: "group mb-1 flex h-5 items-center justify-between",
79
- children: [
80
- /* @__PURE__ */ h("div", { className: "flex grow items-center gap-2 min-w-0", children: [
81
- /* @__PURE__ */ l(
82
- "div",
83
- {
84
- className: "min-w-0 flex-1",
85
- style: x !== void 0 ? { maxWidth: x } : void 0,
86
- children: /* @__PURE__ */ l(oe, { className: "my-1 block w-full text-sm", children: /* @__PURE__ */ l(
87
- jt,
88
- {
89
- value: e.title || e.column,
90
- onSave: (y) => g(
91
- { filterId: e.id },
92
- { definition: { ...e, title: y } }
93
- ),
94
- isEditable: a,
95
- placeholder: "Filter",
96
- displayClassName: "text-sm truncate",
97
- inputClassName: "text-sm"
98
- }
99
- ) })
100
- }
101
- ),
102
- /* @__PURE__ */ h(
103
- "div",
104
- {
105
- className: "flex shrink-0 items-center gap-1.5",
106
- ref: v,
107
- children: [
108
- a && /* @__PURE__ */ l(
109
- Bt,
110
- {
111
- filter: e,
112
- isEditing: a,
113
- filterRef: { filterId: e.id }
114
- }
115
- ),
116
- a && /* @__PURE__ */ l(
117
- "button",
118
- {
119
- onClick: () => {
120
- u({ filterId: e.id });
121
- },
122
- className: "text-muted-foreground hover:text-foreground",
123
- children: /* @__PURE__ */ l(Oa, { className: "size-3.5" })
124
- }
125
- )
126
- ]
127
- }
128
- )
129
- ] }),
130
- /* @__PURE__ */ l("div", { className: "hidden", ref: m })
131
- ]
132
- }
133
- );
134
- }
135
- function Ka() {
136
- const e = M((r) => r.dashboard), a = M((r) => r.selectedSheetId), t = M((r) => r.theme), n = q(
137
- () => ya(e, a, "dashboard").filter(({ input: r }) => wa(r)).map(({ input: r }) => r.filter),
138
- [e, a]
139
- );
140
- return n.length ? /* @__PURE__ */ l(
141
- "div",
142
- {
143
- className: U("mb-1 flex items-center gap-2 border-y px-0.5 pb-0.5", {
144
- "bg-[repeating-linear-gradient(45deg,_#ffffff_0_3px,_#f3f3f3_3px_6px)]": t === "light",
145
- "bg-[repeating-linear-gradient(45deg,_#18171d_0_3px,_#272729_3px_6px)]": t === "dark"
146
- }),
147
- children: n.map((r) => /* @__PURE__ */ h(
148
- "div",
149
- {
150
- className: "flex min-w-[250px] max-w-fit flex-col gap-1 p-2",
151
- children: [
152
- /* @__PURE__ */ l(Va, { filter: r }),
153
- /* @__PURE__ */ l(Wt, { filter: r })
154
- ]
155
- },
156
- r.id
157
- ))
158
- }
159
- ) : null;
160
- }
161
- function Ha() {
162
- var i;
163
- const e = M((s) => s.dashboard), a = M((s) => s.selectedSheetId), t = M(
164
- (s) => s.isDashboardEditing
165
- ), n = (i = e.sheets) == null ? void 0 : i.find(
166
- (s) => s.id === a
167
- ), r = Sa(n);
168
- return /* @__PURE__ */ l(
169
- "div",
170
- {
171
- role: "dashboard-plus-main",
172
- className: "flex min-h-0 grow basis-0 overflow-hidden",
173
- children: /* @__PURE__ */ h("section", { className: "flex min-h-0 grow basis-0 flex-col overflow-hidden", children: [
174
- t && !r && /* @__PURE__ */ l(Ka, {}),
175
- /* @__PURE__ */ l($t, {})
176
- ] })
177
- }
178
- );
179
- }
180
- const qa = /* @__PURE__ */ new Set(["iat", "exp", "nbf", "jti"]);
181
- function Ga(e) {
182
- return xa(
183
- Object.fromEntries(
184
- Object.entries(e ?? {}).filter(([a]) => !qa.has(a))
185
- )
186
- );
187
- }
188
- function Xa(e) {
189
- var t;
190
- const a = e == null ? void 0 : e.config;
191
- return ja({
192
- features: ((t = a == null ? void 0 : a.projectFeatures) == null ? void 0 : t.features) ?? {},
193
- config: { enabled: bt(a).enabled },
194
- identity: {
195
- orgUserId: e == null ? void 0 : e.orgUserId,
196
- tenantId: e == null ? void 0 : e.tenantId,
197
- endUserId: e == null ? void 0 : e.endUserId
198
- },
199
- modelConfigured: !0
200
- });
201
- }
202
- let tt = 0;
203
- function at(e, a) {
204
- tt += 1;
205
- const { name: t, layout: n } = bt(a == null ? void 0 : a.config);
206
- return { ...Kt(n), id: tt, callerKey: e, assistantName: t };
207
- }
208
- function Ja({
209
- children: e,
210
- authToken: a
211
- }) {
212
- const t = We(), n = q(
213
- () => a === void 0 ? t.tokenProps : Za(a),
214
- [a, t.tokenProps]
215
- ), r = q(() => Ga(n), [n]), i = q(
216
- () => Xa(n).available,
217
- [n]
218
- ), [s, o] = L(() => at(r, n));
219
- s.callerKey !== r && o(at(r, n)), Qa(s);
220
- const f = q(() => ({ instance: s, available: i }), [s, i]);
221
- return /* @__PURE__ */ l(Vt.Provider, { value: f, children: e });
222
- }
223
- function Ya({ children: e }) {
224
- return ft() ? /* @__PURE__ */ l(ie, { children: e }) : /* @__PURE__ */ l(Ja, { children: e });
225
- }
226
- function Za(e) {
227
- if (!(e != null && e.accessToken)) return {};
228
- try {
229
- return Ca(e.accessToken);
230
- } catch {
231
- return {};
232
- }
233
- }
234
- function Qa(e) {
235
- ee(() => {
236
- const a = (n, r) => {
237
- const i = e.store.getState().focus;
238
- i && !er(i, n, r) && e.clearFocus();
239
- }, t = M.getState();
240
- return a(t.selectedSheetId, t.dashboard), M.subscribe((n, r) => {
241
- (n.selectedSheetId !== r.selectedSheetId || n.dashboard !== r.dashboard) && a(n.selectedSheetId, n.dashboard), n.isVisualEditing && !r.isVisualEditing && e.leaveBeside();
242
- });
243
- }, [e]);
244
- }
245
- function er(e, a, t) {
246
- if ((a ?? null) !== e.sheetId) return !1;
247
- const n = t ? Ia(t, e.cardId) : void 0;
248
- return !!n && n.sheet.id === e.sheetId;
249
- }
250
- const tr = Se(() => import("./assistant-chat-CK84cPAB.js"));
251
- function gn() {
252
- const e = Ht();
253
- return e.available ? /* @__PURE__ */ h(
254
- V,
255
- {
256
- variant: e.isOpen ? "secondary" : "outline",
257
- size: "xs",
258
- "aria-pressed": e.isOpen,
259
- onClick: e.toggle,
260
- children: [
261
- /* @__PURE__ */ l(qt, { className: "h-3.5 w-3.5" }),
262
- e.assistantName
263
- ]
264
- }
265
- ) : null;
266
- }
267
- const ar = {
268
- // Docked widths are the viewer's (the resize handle), applied as a style.
269
- "docked-right": "relative shrink-0 border-l border-border",
270
- "docked-left": "relative order-first shrink-0 border-r border-border",
271
- centered: "absolute left-1/2 top-1/2 z-30 h-[min(80%,760px)] w-[min(640px,calc(100%-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-card border border-border shadow-lg",
272
- "full-page": "absolute inset-0 z-30"
273
- }, rr = "absolute left-0 top-0 z-30 max-h-[var(--assistant-beside-max-h)] max-w-[var(--assistant-beside-max-w)] rounded-card border border-border shadow-lg", nr = 640, fe = 8;
274
- function lr({ surface: e = "dashboard" } = {}) {
275
- const a = ft(), { isOpen: t, mounted: n, storedLayout: r, width: i, beside: s, besideSize: o, focusCardId: f, askCount: u } = Gt(
276
- (a == null ? void 0 : a.instance.store) ?? Jt,
277
- Xt((w) => {
278
- var y;
279
- return {
280
- isOpen: w.isOpen,
281
- mounted: w.mounted,
282
- storedLayout: w.layout,
283
- width: w.width,
284
- beside: w.beside,
285
- besideSize: w.besideSize,
286
- focusCardId: (y = w.focus) == null ? void 0 : y.cardId,
287
- askCount: w.askCount
288
- };
289
- })
290
- ), g = e === "none", c = M(
291
- (w) => s && t && f && !g ? sr(w.dashboard, w.selectedSheetId, f) : void 0
292
- ), v = ir(c, u);
293
- if (!(a != null && a.available) || !n && !g) return null;
294
- const m = g ? "full-page" : v.shown ? "beside-card" : r, x = g || t, I = m === "docked-right" || m === "docked-left";
295
- return /* @__PURE__ */ h(
296
- "aside",
297
- {
298
- ref: v.setFloating,
299
- "aria-label": a.instance.assistantName,
300
- "data-testid": "assistant-panel",
301
- "data-layout": m,
302
- "data-beside-frame": m === "beside-card" ? c : void 0,
303
- "data-beside-side": m === "beside-card" ? v.side : void 0,
304
- className: U(
305
- "flex-col bg-background",
306
- m === "beside-card" ? rr : ar[m],
307
- x ? "flex" : "hidden"
308
- ),
309
- style: m === "beside-card" ? { ...v.style, width: o.width, height: o.height } : (
310
- // The saved width, never more than the share of the dashboard's area the
311
- // handle allows, however the area is sized now or later (P4-10).
312
- I ? { width: i, maxWidth: `${gt * 100}%` } : void 0
313
- ),
314
- onKeyDown: m === "beside-card" ? (w) => {
315
- if (w.key !== "Escape" || w.defaultPrevented || !(w.target instanceof Node) || !w.currentTarget.contains(w.target)) return;
316
- w.preventDefault();
317
- const y = v.cardActions();
318
- a.instance.close(), y == null || y.focus();
319
- } : void 0,
320
- children: [
321
- I ? /* @__PURE__ */ l(cr, { instance: a.instance, side: m === "docked-left" ? "right" : "left", width: i }) : null,
322
- m === "beside-card" ? /* @__PURE__ */ l(dr, { instance: a.instance, size: o, side: v.handleSide }) : null,
323
- /* @__PURE__ */ l(ye, { fallback: null, children: /* @__PURE__ */ l(tr, { instance: a.instance, surface: e, placement: m }, a.instance.id) })
324
- ]
325
- }
326
- );
327
- }
328
- function sr(e, a, t) {
329
- var r, i, s;
330
- const n = (r = e.sheets) == null ? void 0 : r.find((o) => o.id === a);
331
- return (s = (i = n == null ? void 0 : n.frames) == null ? void 0 : i.find((o) => {
332
- var f;
333
- return (f = o.cards) == null ? void 0 : f.some((u) => u.id === t);
334
- })) == null ? void 0 : s.id;
335
- }
336
- function ir(e, a) {
337
- var x;
338
- const [t, n] = L(void 0), [r, i] = L(void 0), s = Y(a);
339
- Xe(() => {
340
- s.current = a;
341
- });
342
- const o = r === a ? null : t, { refs: f, elements: u, floatingStyles: g, middlewareData: c, isPositioned: v } = ka({
343
- strategy: "absolute",
344
- placement: o ?? "right-start",
345
- middleware: [
346
- Aa(fe),
347
- Da({ padding: fe }),
348
- Ra({
349
- padding: fe,
350
- apply: ({ availableWidth: I, availableHeight: w, elements: y }) => {
351
- y.floating.style.setProperty("--assistant-beside-max-w", `${Math.max(0, I)}px`), y.floating.style.setProperty("--assistant-beside-max-h", `${Math.max(0, w)}px`);
352
- }
353
- }),
354
- Pa()
355
- ],
356
- whileElementsMounted: (I, w, y) => za(I, w, () => {
357
- const P = or(I, w);
358
- n(P), P === null && i(s.current), y();
359
- })
360
- }), m = u.floating;
361
- return Xe(() => {
362
- f.setReference(e ? rt(m == null ? void 0 : m.parentElement, e) : null);
363
- }, [e, m, f]), {
364
- shown: e !== void 0 && o !== null && u.reference !== null,
365
- setFloating: f.setFloating,
366
- style: {
367
- ...g,
368
- // Not before it is placed (its side is chosen first): never a flash at
369
- // the row's corner. With the card wholly out of view, it goes with the card.
370
- ...!v || (x = c.hide) != null && x.referenceHidden ? { visibility: "hidden" } : {}
371
- },
372
- /** The side the conversation took; the size handle sits on the corner away from the card. */
373
- side: o ?? void 0,
374
- handleSide: o === "left-start" ? "left" : "right",
375
- /** The card's ··· menu, where Ask lives and focus returns on Escape. */
376
- cardActions: () => {
377
- var I;
378
- return e ? (I = rt(m == null ? void 0 : m.parentElement, e)) == null ? void 0 : I.querySelector("[data-card-actions]") : null;
379
- }
380
- };
381
- }
382
- function rt(e, a) {
383
- return e ? Array.from(e.querySelectorAll("[data-frame-id]")).find((t) => t.dataset.frameId === a) ?? null : null;
384
- }
385
- function or(e, a) {
386
- const t = a.parentElement;
387
- if (!t || !e.isConnected) return null;
388
- const n = t.getBoundingClientRect();
389
- if (n.width < nr) return null;
390
- const r = e.getBoundingClientRect(), { min: i } = ht, s = (o, f) => o >= i.width + 2 * fe && f >= i.height + 2 * fe;
391
- return s(n.right - r.right, n.height) ? "right-start" : s(r.left - n.left, n.height) ? "left-start" : s(n.width, n.bottom - r.bottom) ? "bottom-start" : null;
392
- }
393
- function dr({
394
- instance: e,
395
- size: a,
396
- side: t
397
- }) {
398
- const n = Y(void 0), r = t === "left" ? -1 : 1, i = (s) => {
399
- const o = n.current;
400
- return {
401
- width: o.start.width + r * (s.clientX - o.x),
402
- height: o.start.height + (s.clientY - o.y)
403
- };
404
- };
405
- return /* @__PURE__ */ l(
406
- "div",
407
- {
408
- role: "separator",
409
- "aria-label": "Resize assistant",
410
- tabIndex: 0,
411
- title: "Drag to resize. Double-click to reset.",
412
- onPointerDown: (s) => {
413
- var o, f;
414
- s.preventDefault(), (f = (o = s.currentTarget).setPointerCapture) == null || f.call(o, s.pointerId), n.current = { x: s.clientX, y: s.clientY, start: a };
415
- },
416
- onPointerMove: (s) => {
417
- n.current && e.setBesideSize(i(s));
418
- },
419
- onPointerUp: (s) => {
420
- n.current && (e.setBesideSize(i(s), { save: !0 }), n.current = void 0);
421
- },
422
- onPointerCancel: () => {
423
- n.current = void 0;
424
- },
425
- onKeyDown: (s) => {
426
- const o = {
427
- ArrowLeft: { width: -r * le, height: 0 },
428
- ArrowRight: { width: r * le, height: 0 },
429
- ArrowUp: { width: 0, height: -le },
430
- ArrowDown: { width: 0, height: le }
431
- }[s.key];
432
- o && (s.preventDefault(), e.setBesideSize({ width: a.width + o.width, height: a.height + o.height }, { save: !0 }));
433
- },
434
- onDoubleClick: () => e.setBesideSize(ht.default, { save: !0 }),
435
- className: U(
436
- "absolute bottom-0 z-10 h-3 w-3 touch-none outline-none hover:bg-primary/30 focus-visible:bg-primary/40",
437
- t === "left" ? "left-0 cursor-nesw-resize rounded-bl-card" : "right-0 cursor-nwse-resize rounded-br-card"
438
- )
439
- }
440
- );
441
- }
442
- const le = 16, gt = 0.6;
443
- function cr({ instance: e, side: a, width: t }) {
444
- const n = Y(void 0), r = (c) => {
445
- var m, x;
446
- const v = (x = (m = c.closest("aside")) == null ? void 0 : m.parentElement) == null ? void 0 : x.clientWidth;
447
- return v ? v * gt : be.max;
448
- }, i = (c) => {
449
- var v;
450
- return ((v = c.closest("aside")) == null ? void 0 : v.getBoundingClientRect().width) || t;
451
- }, s = (c) => {
452
- const v = n.current;
453
- if (!v) return t;
454
- const m = c - v.startX;
455
- return Je(v.startWidth + (a === "left" ? -m : m), v.maxForArea);
456
- }, o = (c) => {
457
- var v, m;
458
- c.preventDefault(), (m = (v = c.currentTarget).setPointerCapture) == null || m.call(v, c.pointerId), n.current = { startX: c.clientX, startWidth: i(c.currentTarget), maxForArea: r(c.currentTarget) };
459
- }, f = (c) => {
460
- n.current && e.setWidth(s(c.clientX));
461
- }, u = (c) => {
462
- n.current && (e.setWidth(s(c.clientX), { save: !0 }), n.current = void 0);
463
- }, g = (c) => {
464
- if (c.key !== "ArrowLeft" && c.key !== "ArrowRight") return;
465
- c.preventDefault();
466
- const v = c.key === "ArrowLeft" == (a === "left");
467
- e.setWidth(Je(i(c.currentTarget) + (v ? le : -le), r(c.currentTarget)), { save: !0 });
468
- };
469
- return /* @__PURE__ */ l(
470
- "div",
471
- {
472
- role: "separator",
473
- "aria-orientation": "vertical",
474
- "aria-label": "Resize assistant",
475
- "aria-valuenow": t,
476
- "aria-valuemin": be.min,
477
- "aria-valuemax": be.max,
478
- tabIndex: 0,
479
- title: "Drag to resize. Double-click to reset.",
480
- onPointerDown: o,
481
- onPointerMove: f,
482
- onPointerUp: u,
483
- onPointerCancel: u,
484
- onKeyDown: g,
485
- onDoubleClick: () => e.setWidth(be.default, { save: !0 }),
486
- className: U(
487
- "absolute inset-y-0 z-10 w-1.5 cursor-col-resize touch-none outline-none hover:bg-primary/30 focus-visible:bg-primary/40",
488
- a === "left" ? "-left-[3px]" : "-right-[3px]"
489
- )
490
- }
491
- );
492
- }
493
- const ur = Se(() => import("./dashboard-controls-BMeZjF7r.js")), mr = Se(
494
- () => import("./edit-dashboard-visual-Bv3MHM_G.js")
495
- ), fr = Se(() => import("./dashboard-json-BZqCoanC.js"));
496
- function yn({
497
- showControls: e = !1,
498
- showFooter: a = !0,
499
- ...t
500
- }) {
501
- const n = M((o) => o.isVisualEditing), r = M(
502
- (o) => o.showDashboardJSON
503
- ), { appearance: i, preferences: s } = t;
504
- return /* @__PURE__ */ l(Yt, { FallbackComponent: Zt, children: /* @__PURE__ */ l(Qt, { dashboardProps: t, children: /* @__PURE__ */ h(ea, { children: [
505
- /* @__PURE__ */ l(ta, { componentType: "surfboard", componentId: t.id }),
506
- /* @__PURE__ */ h(aa, { appearance: i, children: [
507
- /* @__PURE__ */ l(
508
- ra,
509
- {
510
- toastOptions: {
511
- classNames: {
512
- toast: "max-w-[calc(100vw-2rem)] overflow-x-hidden !items-start [--toast-close-button-end:0.5rem] [--toast-close-button-start:auto] [--toast-close-button-transform:translate(0,0)] sm:max-w-[44rem]",
513
- content: "min-w-0 flex-1",
514
- icon: "mt-0.5 shrink-0",
515
- title: "max-w-full break-words pr-8",
516
- description: "max-w-full break-words",
517
- closeButton: "!top-2 h-6 w-6 rounded-md border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground"
518
- }
519
- }
520
- }
521
- ),
522
- /* @__PURE__ */ h(na, { preferences: s, children: [
523
- r && /* @__PURE__ */ l(ye, { fallback: null, children: /* @__PURE__ */ l(fr, {}) }),
524
- /* @__PURE__ */ l(la, { children: /* @__PURE__ */ l(Ya, { children: /* @__PURE__ */ h("main", { className: "relative flex h-full w-full flex-col overflow-hidden", children: [
525
- e && /* @__PURE__ */ l(ye, { fallback: null, children: /* @__PURE__ */ l(ur, {}) }),
526
- /* @__PURE__ */ h("div", { className: "relative flex grow overflow-hidden", children: [
527
- /* @__PURE__ */ l("div", { className: "flex min-w-0 flex-1", children: /* @__PURE__ */ h(sa, { ...t, type: "dashboard", children: [
528
- n && /* @__PURE__ */ l(ye, { fallback: null, children: /* @__PURE__ */ l(mr, {}) }),
529
- /* @__PURE__ */ l(_t, { mode: n ? "hidden" : "visible", children: /* @__PURE__ */ l(Ha, {}) })
530
- ] }) }),
531
- /* @__PURE__ */ l(lr, {})
532
- ] })
533
- ] }) }) })
534
- ] })
535
- ] })
536
- ] }) }) });
537
- }
538
- var nt = 1, hr = 0.9, pr = 0.8, vr = 0.17, Ee = 0.1, Te = 0.999, br = 0.9999, gr = 0.99, yr = /[\\\/_+.#"@\[\(\{&]/, wr = /[\\\/_+.#"@\[\(\{&]/g, Sr = /[\s-]/, yt = /[\s-]/g;
539
- function _e(e, a, t, n, r, i, s) {
540
- if (i === a.length) return r === e.length ? nt : gr;
541
- var o = `${r},${i}`;
542
- if (s[o] !== void 0) return s[o];
543
- for (var f = n.charAt(i), u = t.indexOf(f, r), g = 0, c, v, m, x; u >= 0; ) c = _e(e, a, t, n, u + 1, i + 1, s), c > g && (u === r ? c *= nt : yr.test(e.charAt(u - 1)) ? (c *= pr, m = e.slice(r, u - 1).match(wr), m && r > 0 && (c *= Math.pow(Te, m.length))) : Sr.test(e.charAt(u - 1)) ? (c *= hr, x = e.slice(r, u - 1).match(yt), x && r > 0 && (c *= Math.pow(Te, x.length))) : (c *= vr, r > 0 && (c *= Math.pow(Te, u - r))), e.charAt(u) !== a.charAt(i) && (c *= br)), (c < Ee && t.charAt(u - 1) === n.charAt(i + 1) || n.charAt(i + 1) === n.charAt(i) && t.charAt(u - 1) !== n.charAt(i)) && (v = _e(e, a, t, n, u + 1, i + 2, s), v * Ee > c && (c = v * Ee)), c > g && (g = c), u = t.indexOf(f, u + 1);
544
- return s[o] = g, g;
545
- }
546
- function lt(e) {
547
- return e.toLowerCase().replace(yt, " ");
548
- }
549
- function xr(e, a, t) {
550
- return e = t && t.length > 0 ? `${e + " " + t.join(" ")}` : e, _e(e, a, lt(e), lt(a), 0, 0, {});
551
- }
552
- var me = '[cmdk-group=""]', Ie = '[cmdk-group-items=""]', Cr = '[cmdk-group-heading=""]', wt = '[cmdk-item=""]', st = `${wt}:not([aria-disabled="true"])`, Me = "cmdk-item-select", re = "data-value", Nr = (e, a, t) => xr(e, a, t), St = p.createContext(void 0), pe = () => p.useContext(St), xt = p.createContext(void 0), Ve = () => p.useContext(xt), Ct = p.createContext(void 0), Nt = p.forwardRef((e, a) => {
553
- let t = ne(() => {
554
- var d, T;
555
- return { search: "", value: (T = (d = e.value) != null ? d : e.defaultValue) != null ? T : "", selectedItemId: void 0, filtered: { count: 0, items: /* @__PURE__ */ new Map(), groups: /* @__PURE__ */ new Set() } };
556
- }), n = ne(() => /* @__PURE__ */ new Set()), r = ne(() => /* @__PURE__ */ new Map()), i = ne(() => /* @__PURE__ */ new Map()), s = ne(() => /* @__PURE__ */ new Set()), o = Et(e), { label: f, children: u, value: g, onValueChange: c, filter: v, shouldFilter: m, loop: x, disablePointerSelection: I = !1, vimBindings: w = !0, ...y } = e, P = se(), F = se(), O = se(), _ = p.useRef(null), E = Lr();
557
- te(() => {
558
- if (g !== void 0) {
559
- let d = g.trim();
560
- t.current.value = d, b.emit();
561
- }
562
- }, [g]), te(() => {
563
- E(6, ae);
564
- }, []);
565
- let b = p.useMemo(() => ({ subscribe: (d) => (s.current.add(d), () => s.current.delete(d)), snapshot: () => t.current, setState: (d, T, A) => {
566
- var S, D, z, W;
567
- if (!Object.is(t.current[d], T)) {
568
- if (t.current[d] = T, d === "search") K(), C(), E(1, G);
569
- else if (d === "value") {
570
- if (document.activeElement.hasAttribute("cmdk-input") || document.activeElement.hasAttribute("cmdk-root")) {
571
- let j = document.getElementById(O);
572
- j ? j.focus() : (S = document.getElementById(P)) == null || S.focus();
573
- }
574
- if (E(7, () => {
575
- var j;
576
- t.current.selectedItemId = (j = X()) == null ? void 0 : j.id, b.emit();
577
- }), A || E(5, ae), ((D = o.current) == null ? void 0 : D.value) !== void 0) {
578
- let j = T ?? "";
579
- (W = (z = o.current).onValueChange) == null || W.call(z, j);
580
- return;
581
- }
582
- }
583
- b.emit();
584
- }
585
- }, emit: () => {
586
- s.current.forEach((d) => d());
587
- } }), []), N = p.useMemo(() => ({ value: (d, T, A) => {
588
- var S;
589
- T !== ((S = i.current.get(d)) == null ? void 0 : S.value) && (i.current.set(d, { value: T, keywords: A }), t.current.filtered.items.set(d, R(T, A)), E(2, () => {
590
- C(), b.emit();
591
- }));
592
- }, item: (d, T) => (n.current.add(d), T && (r.current.has(T) ? r.current.get(T).add(d) : r.current.set(T, /* @__PURE__ */ new Set([d]))), E(3, () => {
593
- K(), C(), t.current.value || G(), b.emit();
594
- }), () => {
595
- i.current.delete(d), n.current.delete(d), t.current.filtered.items.delete(d);
596
- let A = X();
597
- E(4, () => {
598
- K(), (A == null ? void 0 : A.getAttribute("id")) === d && G(), b.emit();
599
- });
600
- }), group: (d) => (r.current.has(d) || r.current.set(d, /* @__PURE__ */ new Set()), () => {
601
- i.current.delete(d), r.current.delete(d);
602
- }), filter: () => o.current.shouldFilter, label: f || e["aria-label"], getDisablePointerSelection: () => o.current.disablePointerSelection, listId: P, inputId: O, labelId: F, listInnerRef: _ }), []);
603
- function R(d, T) {
604
- var A, S;
605
- let D = (S = (A = o.current) == null ? void 0 : A.filter) != null ? S : Nr;
606
- return d ? D(d, t.current.search, T) : 0;
607
- }
608
- function C() {
609
- if (!t.current.search || o.current.shouldFilter === !1) return;
610
- let d = t.current.filtered.items, T = [];
611
- t.current.filtered.groups.forEach((S) => {
612
- let D = r.current.get(S), z = 0;
613
- D.forEach((W) => {
614
- let j = d.get(W);
615
- z = Math.max(j, z);
616
- }), T.push([S, z]);
617
- });
618
- let A = _.current;
619
- k().sort((S, D) => {
620
- var z, W;
621
- let j = S.getAttribute("id"), ve = D.getAttribute("id");
622
- return ((z = d.get(ve)) != null ? z : 0) - ((W = d.get(j)) != null ? W : 0);
623
- }).forEach((S) => {
624
- let D = S.closest(Ie);
625
- D ? D.appendChild(S.parentElement === D ? S : S.closest(`${Ie} > *`)) : A.appendChild(S.parentElement === A ? S : S.closest(`${Ie} > *`));
626
- }), T.sort((S, D) => D[1] - S[1]).forEach((S) => {
627
- var D;
628
- let z = (D = _.current) == null ? void 0 : D.querySelector(`${me}[${re}="${encodeURIComponent(S[0])}"]`);
629
- z == null || z.parentElement.appendChild(z);
630
- });
631
- }
632
- function G() {
633
- let d = k().find((A) => A.getAttribute("aria-disabled") !== "true"), T = d == null ? void 0 : d.getAttribute(re);
634
- b.setState("value", T || void 0);
635
- }
636
- function K() {
637
- var d, T, A, S;
638
- if (!t.current.search || o.current.shouldFilter === !1) {
639
- t.current.filtered.count = n.current.size;
640
- return;
641
- }
642
- t.current.filtered.groups = /* @__PURE__ */ new Set();
643
- let D = 0;
644
- for (let z of n.current) {
645
- let W = (T = (d = i.current.get(z)) == null ? void 0 : d.value) != null ? T : "", j = (S = (A = i.current.get(z)) == null ? void 0 : A.keywords) != null ? S : [], ve = R(W, j);
646
- t.current.filtered.items.set(z, ve), ve > 0 && D++;
647
- }
648
- for (let [z, W] of r.current) for (let j of W) if (t.current.filtered.items.get(j) > 0) {
649
- t.current.filtered.groups.add(z);
650
- break;
651
- }
652
- t.current.filtered.count = D;
653
- }
654
- function ae() {
655
- var d, T, A;
656
- let S = X();
657
- S && (((d = S.parentElement) == null ? void 0 : d.firstChild) === S && ((A = (T = S.closest(me)) == null ? void 0 : T.querySelector(Cr)) == null || A.scrollIntoView({ block: "nearest" })), S.scrollIntoView({ block: "nearest" }));
658
- }
659
- function X() {
660
- var d;
661
- return (d = _.current) == null ? void 0 : d.querySelector(`${wt}[aria-selected="true"]`);
662
- }
663
- function k() {
664
- var d;
665
- return Array.from(((d = _.current) == null ? void 0 : d.querySelectorAll(st)) || []);
666
- }
667
- function de(d) {
668
- let T = k()[d];
669
- T && b.setState("value", T.getAttribute(re));
670
- }
671
- function Ce(d) {
672
- var T;
673
- let A = X(), S = k(), D = S.findIndex((W) => W === A), z = S[D + d];
674
- (T = o.current) != null && T.loop && (z = D + d < 0 ? S[S.length - 1] : D + d === S.length ? S[0] : S[D + d]), z && b.setState("value", z.getAttribute(re));
675
- }
676
- function Ke(d) {
677
- let T = X(), A = T == null ? void 0 : T.closest(me), S;
678
- for (; A && !S; ) A = d > 0 ? zr(A, me) : Fr(A, me), S = A == null ? void 0 : A.querySelector(st);
679
- S ? b.setState("value", S.getAttribute(re)) : Ce(d);
680
- }
681
- let He = () => de(k().length - 1), qe = (d) => {
682
- d.preventDefault(), d.metaKey ? He() : d.altKey ? Ke(1) : Ce(1);
683
- }, Ge = (d) => {
684
- d.preventDefault(), d.metaKey ? de(0) : d.altKey ? Ke(-1) : Ce(-1);
685
- };
686
- return p.createElement(Q.div, { ref: a, tabIndex: -1, ...y, "cmdk-root": "", onKeyDown: (d) => {
687
- var T;
688
- (T = y.onKeyDown) == null || T.call(y, d);
689
- let A = d.nativeEvent.isComposing || d.keyCode === 229;
690
- if (!(d.defaultPrevented || A)) switch (d.key) {
691
- case "n":
692
- case "j": {
693
- w && d.ctrlKey && qe(d);
694
- break;
695
- }
696
- case "ArrowDown": {
697
- qe(d);
698
- break;
699
- }
700
- case "p":
701
- case "k": {
702
- w && d.ctrlKey && Ge(d);
703
- break;
704
- }
705
- case "ArrowUp": {
706
- Ge(d);
707
- break;
708
- }
709
- case "Home": {
710
- d.preventDefault(), de(0);
711
- break;
712
- }
713
- case "End": {
714
- d.preventDefault(), He();
715
- break;
716
- }
717
- case "Enter": {
718
- d.preventDefault();
719
- let S = X();
720
- if (S) {
721
- let D = new Event(Me);
722
- S.dispatchEvent(D);
723
- }
724
- }
725
- }
726
- } }, p.createElement("label", { "cmdk-label": "", htmlFor: N.inputId, id: N.labelId, style: Mr }, f), xe(e, (d) => p.createElement(xt.Provider, { value: b }, p.createElement(St.Provider, { value: N }, d))));
727
- }), Er = p.forwardRef((e, a) => {
728
- var t, n;
729
- let r = se(), i = p.useRef(null), s = p.useContext(Ct), o = pe(), f = Et(e), u = (n = (t = f.current) == null ? void 0 : t.forceMount) != null ? n : s == null ? void 0 : s.forceMount;
730
- te(() => {
731
- if (!u) return o.item(r, s == null ? void 0 : s.id);
732
- }, [u]);
733
- let g = Tt(r, i, [e.value, e.children, i], e.keywords), c = Ve(), v = Z((E) => E.value && E.value === g.current), m = Z((E) => u || o.filter() === !1 ? !0 : E.search ? E.filtered.items.get(r) > 0 : !0);
734
- p.useEffect(() => {
735
- let E = i.current;
736
- if (!(!E || e.disabled)) return E.addEventListener(Me, x), () => E.removeEventListener(Me, x);
737
- }, [m, e.onSelect, e.disabled]);
738
- function x() {
739
- var E, b;
740
- I(), (b = (E = f.current).onSelect) == null || b.call(E, g.current);
741
- }
742
- function I() {
743
- c.setState("value", g.current, !0);
744
- }
745
- if (!m) return null;
746
- let { disabled: w, value: y, onSelect: P, forceMount: F, keywords: O, ..._ } = e;
747
- return p.createElement(Q.div, { ref: he(i, a), ..._, id: r, "cmdk-item": "", role: "option", "aria-disabled": !!w, "aria-selected": !!v, "data-disabled": !!w, "data-selected": !!v, onPointerMove: w || o.getDisablePointerSelection() ? void 0 : I, onClick: w ? void 0 : x }, e.children);
748
- }), Tr = p.forwardRef((e, a) => {
749
- let { heading: t, children: n, forceMount: r, ...i } = e, s = se(), o = p.useRef(null), f = p.useRef(null), u = se(), g = pe(), c = Z((m) => r || g.filter() === !1 ? !0 : m.search ? m.filtered.groups.has(s) : !0);
750
- te(() => g.group(s), []), Tt(s, o, [e.value, e.heading, f]);
751
- let v = p.useMemo(() => ({ id: s, forceMount: r }), [r]);
752
- return p.createElement(Q.div, { ref: he(o, a), ...i, "cmdk-group": "", role: "presentation", hidden: c ? void 0 : !0 }, t && p.createElement("div", { ref: f, "cmdk-group-heading": "", "aria-hidden": !0, id: u }, t), xe(e, (m) => p.createElement("div", { "cmdk-group-items": "", role: "group", "aria-labelledby": t ? u : void 0 }, p.createElement(Ct.Provider, { value: v }, m))));
753
- }), Ir = p.forwardRef((e, a) => {
754
- let { alwaysRender: t, ...n } = e, r = p.useRef(null), i = Z((s) => !s.search);
755
- return !t && !i ? null : p.createElement(Q.div, { ref: he(r, a), ...n, "cmdk-separator": "", role: "separator" });
756
- }), kr = p.forwardRef((e, a) => {
757
- let { onValueChange: t, ...n } = e, r = e.value != null, i = Ve(), s = Z((u) => u.search), o = Z((u) => u.selectedItemId), f = pe();
758
- return p.useEffect(() => {
759
- e.value != null && i.setState("search", e.value);
760
- }, [e.value]), p.createElement(Q.input, { ref: a, ...n, "cmdk-input": "", autoComplete: "off", autoCorrect: "off", spellCheck: !1, "aria-autocomplete": "list", role: "combobox", "aria-expanded": !0, "aria-controls": f.listId, "aria-labelledby": f.labelId, "aria-activedescendant": o, id: f.inputId, type: "text", value: r ? e.value : s, onChange: (u) => {
761
- r || i.setState("search", u.target.value), t == null || t(u.target.value);
762
- } });
763
- }), Ar = p.forwardRef((e, a) => {
764
- let { children: t, label: n = "Suggestions", ...r } = e, i = p.useRef(null), s = p.useRef(null), o = Z((u) => u.selectedItemId), f = pe();
765
- return p.useEffect(() => {
766
- if (s.current && i.current) {
767
- let u = s.current, g = i.current, c, v = new ResizeObserver(() => {
768
- c = requestAnimationFrame(() => {
769
- let m = u.offsetHeight;
770
- g.style.setProperty("--cmdk-list-height", m.toFixed(1) + "px");
771
- });
772
- });
773
- return v.observe(u), () => {
774
- cancelAnimationFrame(c), v.unobserve(u);
775
- };
776
- }
777
- }, []), p.createElement(Q.div, { ref: he(i, a), ...r, "cmdk-list": "", role: "listbox", tabIndex: -1, "aria-activedescendant": o, "aria-label": n, id: f.listId }, xe(e, (u) => p.createElement("div", { ref: he(s, f.listInnerRef), "cmdk-list-sizer": "" }, u)));
778
- }), Dr = p.forwardRef((e, a) => {
779
- let { open: t, onOpenChange: n, overlayClassName: r, contentClassName: i, container: s, ...o } = e;
780
- return p.createElement(ia, { open: t, onOpenChange: n }, p.createElement(oa, { container: s }, p.createElement(da, { "cmdk-overlay": "", className: r }), p.createElement(ca, { "aria-label": e.label, "cmdk-dialog": "", className: i }, p.createElement(Nt, { ref: a, ...o }))));
781
- }), Rr = p.forwardRef((e, a) => Z((t) => t.filtered.count === 0) ? p.createElement(Q.div, { ref: a, ...e, "cmdk-empty": "", role: "presentation" }) : null), Pr = p.forwardRef((e, a) => {
782
- let { progress: t, children: n, label: r = "Loading...", ...i } = e;
783
- return p.createElement(Q.div, { ref: a, ...i, "cmdk-loading": "", role: "progressbar", "aria-valuenow": t, "aria-valuemin": 0, "aria-valuemax": 100, "aria-label": r }, xe(e, (s) => p.createElement("div", { "aria-hidden": !0 }, s)));
784
- }), B = Object.assign(Nt, { List: Ar, Item: Er, Input: kr, Group: Tr, Separator: Ir, Dialog: Dr, Empty: Rr, Loading: Pr });
785
- function zr(e, a) {
786
- let t = e.nextElementSibling;
787
- for (; t; ) {
788
- if (t.matches(a)) return t;
789
- t = t.nextElementSibling;
790
- }
791
- }
792
- function Fr(e, a) {
793
- let t = e.previousElementSibling;
794
- for (; t; ) {
795
- if (t.matches(a)) return t;
796
- t = t.previousElementSibling;
797
- }
798
- }
799
- function Et(e) {
800
- let a = p.useRef(e);
801
- return te(() => {
802
- a.current = e;
803
- }), a;
804
- }
805
- var te = typeof window > "u" ? p.useEffect : p.useLayoutEffect;
806
- function ne(e) {
807
- let a = p.useRef();
808
- return a.current === void 0 && (a.current = e()), a;
809
- }
810
- function Z(e) {
811
- let a = Ve(), t = () => e(a.snapshot());
812
- return p.useSyncExternalStore(a.subscribe, t, t);
813
- }
814
- function Tt(e, a, t, n = []) {
815
- let r = p.useRef(), i = pe();
816
- return te(() => {
817
- var s;
818
- let o = (() => {
819
- var u;
820
- for (let g of t) {
821
- if (typeof g == "string") return g.trim();
822
- if (typeof g == "object" && "current" in g) return g.current ? (u = g.current.textContent) == null ? void 0 : u.trim() : r.current;
823
- }
824
- })(), f = n.map((u) => u.trim());
825
- i.value(e, o, f), (s = a.current) == null || s.setAttribute(re, o), r.current = o;
826
- }), r;
827
- }
828
- var Lr = () => {
829
- let [e, a] = p.useState(), t = ne(() => /* @__PURE__ */ new Map());
830
- return te(() => {
831
- t.current.forEach((n) => n()), t.current = /* @__PURE__ */ new Map();
832
- }, [e]), (n, r) => {
833
- t.current.set(n, r), a({});
834
- };
835
- };
836
- function _r(e) {
837
- let a = e.type;
838
- return typeof a == "function" ? a(e.props) : "render" in a ? a.render(e.props) : e;
839
- }
840
- function xe({ asChild: e, children: a }, t) {
841
- return e && p.isValidElement(a) ? p.cloneElement(_r(a), { ref: a.ref }, t(a.props.children)) : t(a);
842
- }
843
- var Mr = { position: "absolute", width: "1px", height: "1px", padding: "0", margin: "-1px", overflow: "hidden", clip: "rect(0, 0, 0, 0)", whiteSpace: "nowrap", borderWidth: "0" };
844
- const It = p.forwardRef(({ className: e, ...a }, t) => /* @__PURE__ */ l(
845
- B,
846
- {
847
- ref: t,
848
- className: U(
849
- "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
850
- e
851
- ),
852
- ...a
853
- }
854
- ));
855
- It.displayName = B.displayName;
856
- const kt = p.forwardRef(({ className: e, ...a }, t) => /* @__PURE__ */ h("div", { className: "flex items-center border-b px-3", "cmdk-input-wrapper": "", children: [
857
- /* @__PURE__ */ l(Ba, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
858
- /* @__PURE__ */ l(
859
- B.Input,
860
- {
861
- ref: t,
862
- className: U(
863
- "flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-[hsl(var(--semaphor-placeholder-foreground))] disabled:cursor-not-allowed disabled:opacity-50",
864
- e
865
- ),
866
- ...a
867
- }
868
- )
869
- ] }));
870
- kt.displayName = B.Input.displayName;
871
- const At = p.forwardRef(({ className: e, ...a }, t) => /* @__PURE__ */ l(
872
- B.List,
873
- {
874
- ref: t,
875
- className: U("max-h-[300px] overflow-y-auto overflow-x-hidden", e),
876
- ...a
877
- }
878
- ));
879
- At.displayName = B.List.displayName;
880
- const Dt = p.forwardRef((e, a) => /* @__PURE__ */ l(
881
- B.Empty,
882
- {
883
- ref: a,
884
- className: "py-6 text-center text-sm",
885
- ...e
886
- }
887
- ));
888
- Dt.displayName = B.Empty.displayName;
889
- const Ue = p.forwardRef(({ className: e, ...a }, t) => /* @__PURE__ */ l(
890
- B.Group,
891
- {
892
- ref: t,
893
- className: U(
894
- "overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
895
- e
896
- ),
897
- ...a
898
- }
899
- ));
900
- Ue.displayName = B.Group.displayName;
901
- const Rt = p.forwardRef(({ className: e, ...a }, t) => /* @__PURE__ */ l(
902
- B.Separator,
903
- {
904
- ref: t,
905
- className: U("-mx-1 h-px bg-border", e),
906
- ...a
907
- }
908
- ));
909
- Rt.displayName = B.Separator.displayName;
910
- const Oe = p.forwardRef(({ className: e, ...a }, t) => /* @__PURE__ */ l(
911
- B.Item,
912
- {
913
- ref: t,
914
- className: U(
915
- "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50",
916
- e
917
- ),
918
- ...a
919
- }
920
- ));
921
- Oe.displayName = B.Item.displayName;
922
- function Ur(e = {}) {
923
- const { authToken: a, tokenProps: t } = We(), n = M(
924
- (E) => E.actions.applyResolvedCalendarPreferences
925
- ), r = e.enabled ?? !0, i = (a == null ? void 0 : a.accessToken) ?? null, s = (t == null ? void 0 : t.apiServiceUrl) ?? null, [o, f] = L(!1), [u, g] = L(!1), [c, v] = L(!1), [m, x] = L(null), [I, w] = L(null), y = Y(i);
926
- y.current = i, ee(() => {
927
- w(null), x(null), f(!1), g(!1), v(!1);
928
- }, [i]);
929
- const P = $(async (E) => {
930
- const b = Wa(await E.json());
931
- if (!b.ok)
932
- throw new Error("Calendar preferences response is invalid");
933
- return b.value;
934
- }, []), F = $(async () => {
935
- if (!r || !i || !s) return;
936
- const E = i;
937
- f(!0), x(null);
938
- try {
939
- const b = await fetch(
940
- `${s}/v1/user-preferences/calendar`,
941
- {
942
- method: "GET",
943
- headers: { Authorization: `Bearer ${i}` }
944
- }
945
- );
946
- if (!b.ok) {
947
- const R = await b.json().catch(() => ({}));
948
- throw new Error(R.error || "Failed to fetch preferences");
949
- }
950
- const N = await P(b);
951
- y.current === E && w(N);
952
- } catch (b) {
953
- y.current === E && x(b instanceof Error ? b.message : "Unknown error");
954
- } finally {
955
- y.current === E && f(!1);
956
- }
957
- }, [i, s, r, P]);
958
- ee(() => {
959
- r && F();
960
- }, [r, F]);
961
- const O = $(
962
- async (E) => {
963
- if (!i || !s)
964
- return x("Not authenticated"), !1;
965
- const b = i;
966
- g(!0), x(null);
967
- try {
968
- const N = await fetch(
969
- `${s}/v1/user-preferences/calendar`,
970
- {
971
- method: "PATCH",
972
- headers: {
973
- "Content-Type": "application/json",
974
- Authorization: `Bearer ${i}`
975
- },
976
- body: JSON.stringify(E)
977
- }
978
- );
979
- if (!N.ok) {
980
- const C = await N.json().catch(() => ({}));
981
- throw new Error(C.error || "Failed to update preferences");
982
- }
983
- const R = await P(N);
984
- return y.current !== b ? !1 : (w(R), n(R.resolved, R.sources), !0);
985
- } catch (N) {
986
- return y.current === b && x(N instanceof Error ? N.message : "Unknown error"), !1;
987
- } finally {
988
- y.current === b && g(!1);
989
- }
990
- },
991
- [
992
- i,
993
- s,
994
- n,
995
- P
996
- ]
997
- ), _ = $(async () => {
998
- if (!i || !s)
999
- return x("Not authenticated"), !1;
1000
- const E = i;
1001
- v(!0), x(null);
1002
- try {
1003
- const b = await fetch(
1004
- `${s}/v1/user-preferences/calendar`,
1005
- {
1006
- method: "DELETE",
1007
- headers: { Authorization: `Bearer ${i}` }
1008
- }
1009
- );
1010
- if (!b.ok) {
1011
- const R = await b.json().catch(() => ({}));
1012
- throw new Error(R.error || "Failed to clear preferences");
1013
- }
1014
- const N = await P(b);
1015
- return y.current !== E ? !1 : (w(N), n(N.resolved, N.sources), !0);
1016
- } catch (b) {
1017
- return y.current === E && x(b instanceof Error ? b.message : "Unknown error"), !1;
1018
- } finally {
1019
- y.current === E && v(!1);
1020
- }
1021
- }, [
1022
- i,
1023
- s,
1024
- n,
1025
- P
1026
- ]);
1027
- return {
1028
- preferences: I,
1029
- isLoading: o,
1030
- isSaving: u,
1031
- isClearing: c,
1032
- error: m,
1033
- updatePreferences: O,
1034
- clearPreferences: _,
1035
- refetch: F
1036
- };
1037
- }
1038
- const we = [
1039
- { value: "America/New_York", label: "Eastern Time (US & Canada)" },
1040
- { value: "America/Chicago", label: "Central Time (US & Canada)" },
1041
- { value: "America/Denver", label: "Mountain Time (US & Canada)" },
1042
- { value: "America/Los_Angeles", label: "Pacific Time (US & Canada)" },
1043
- { value: "America/Phoenix", label: "Arizona" },
1044
- { value: "America/Anchorage", label: "Alaska" },
1045
- { value: "Pacific/Honolulu", label: "Hawaii" },
1046
- { value: "Europe/London", label: "London" },
1047
- { value: "Europe/Paris", label: "Paris, Berlin, Rome" },
1048
- { value: "Asia/Tokyo", label: "Tokyo" },
1049
- { value: "Asia/Shanghai", label: "Beijing, Shanghai" },
1050
- { value: "Asia/Kolkata", label: "Mumbai, New Delhi" },
1051
- { value: "Australia/Sydney", label: "Sydney" },
1052
- { value: "UTC", label: "UTC" }
1053
- ], Pt = [
1054
- { value: 0, label: "Sunday" },
1055
- { value: 1, label: "Monday" },
1056
- { value: 6, label: "Saturday" }
1057
- ], it = "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";
1058
- function Or() {
1059
- try {
1060
- const e = Intl;
1061
- if (e.supportedValuesOf)
1062
- return e.supportedValuesOf("timeZone");
1063
- } catch {
1064
- }
1065
- return we.map((e) => e.value);
1066
- }
1067
- function jr(e) {
1068
- if (!e) return "default";
1069
- if (e.tz !== e.weekStart) return "inherited";
1070
- switch (e.tz) {
1071
- case "viewer_tenant":
1072
- return "tenant";
1073
- case "viewer_organization":
1074
- return "organization";
1075
- case "system_default":
1076
- return "system";
1077
- case "session_initial":
1078
- return "embedded";
1079
- default:
1080
- return "default";
1081
- }
1082
- }
1083
- function ot(e) {
1084
- const a = we.find((t) => t.value === e);
1085
- return a ? a.label : e;
1086
- }
1087
- function Br(e) {
1088
- const a = Pt.find((t) => t.value === e);
1089
- return a ? a.label : String(e);
1090
- }
1091
- function Wr({
1092
- active: e,
1093
- onClose: a
1094
- }) {
1095
- const {
1096
- preferences: t,
1097
- isLoading: n,
1098
- isSaving: r,
1099
- isClearing: i,
1100
- updatePreferences: s,
1101
- clearPreferences: o
1102
- } = Ur({ enabled: e }), f = mt(), u = (t == null ? void 0 : t.resolved.tz) || (f == null ? void 0 : f.tz) || "UTC", g = (t == null ? void 0 : t.resolved.weekStart) ?? (f == null ? void 0 : f.weekStart) ?? 1, [c, v] = L((t == null ? void 0 : t.stored) === null), [m, x] = L(!1), [I, w] = L(
1103
- u
1104
- ), [y, P] = L(
1105
- g
1106
- ), [F, O] = L(!1), _ = q(() => Or(), []), E = q(
1107
- () => _.filter(
1108
- (k) => !we.some((de) => de.value === k)
1109
- ),
1110
- [_]
1111
- ), b = q(() => ot(I), [I]), N = t != null && t.inherited ? ot(t.inherited.tz) : "UTC", R = t != null && t.inherited ? Br(t.inherited.weekStart) : "Monday", C = jr(
1112
- t == null ? void 0 : t.inheritedSources
1113
- );
1114
- Lt.useEffect(() => {
1115
- if (!e) {
1116
- x(!1);
1117
- return;
1118
- }
1119
- m || (t && v(t.stored === null), w(u), P(g));
1120
- }, [
1121
- e,
1122
- m,
1123
- t,
1124
- u,
1125
- g
1126
- ]);
1127
- const G = async () => {
1128
- if (n) {
1129
- H.error("Preferences are still loading. Please try again.");
1130
- return;
1131
- }
1132
- c ? await o() ? (H.success("Now using default settings."), a()) : H.error("Failed to save preferences. Please try again.") : await s({
1133
- tz: I,
1134
- weekStart: y
1135
- }) ? (H.success("Preferences saved."), a()) : H.error("Failed to save preferences. Please try again.");
1136
- }, K = () => {
1137
- a();
1138
- }, ae = r || i, X = ae || n;
1139
- return /* @__PURE__ */ h(ie, { children: [
1140
- /* @__PURE__ */ h("div", { className: "space-y-4 py-1", children: [
1141
- /* @__PURE__ */ h(
1142
- Ye,
1143
- {
1144
- value: c ? "defaults" : "custom",
1145
- onValueChange: (k) => {
1146
- x(!0), v(k === "defaults");
1147
- },
1148
- className: "space-y-0.5",
1149
- children: [
1150
- /* @__PURE__ */ h(
1151
- "label",
1152
- {
1153
- htmlFor: "mode-defaults",
1154
- className: U(
1155
- "flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",
1156
- c && "bg-muted/50"
1157
- ),
1158
- onClick: () => {
1159
- x(!0), v(!0);
1160
- },
1161
- children: [
1162
- /* @__PURE__ */ l(
1163
- Ne,
1164
- {
1165
- value: "defaults",
1166
- id: "mode-defaults",
1167
- className: "mt-0.5"
1168
- }
1169
- ),
1170
- /* @__PURE__ */ h("div", { className: "flex-1 min-w-0", children: [
1171
- /* @__PURE__ */ h("p", { className: "text-[13px] font-medium text-foreground", children: [
1172
- "Use ",
1173
- C,
1174
- " defaults"
1175
- ] }),
1176
- /* @__PURE__ */ h("p", { className: "text-[12px] text-muted-foreground", children: [
1177
- N,
1178
- ", week starts ",
1179
- R
1180
- ] })
1181
- ] })
1182
- ]
1183
- }
1184
- ),
1185
- /* @__PURE__ */ h(
1186
- "label",
1187
- {
1188
- htmlFor: "mode-custom",
1189
- className: U(
1190
- "flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",
1191
- !c && "bg-muted/50"
1192
- ),
1193
- onClick: () => {
1194
- x(!0), v(!1);
1195
- },
1196
- children: [
1197
- /* @__PURE__ */ l(
1198
- Ne,
1199
- {
1200
- value: "custom",
1201
- id: "mode-custom",
1202
- className: "mt-0.5"
1203
- }
1204
- ),
1205
- /* @__PURE__ */ l("p", { className: "flex-1 text-[13px] font-medium text-foreground", children: "Use custom settings" })
1206
- ]
1207
- }
1208
- )
1209
- ]
1210
- }
1211
- ),
1212
- /* @__PURE__ */ h(
1213
- "div",
1214
- {
1215
- className: U(
1216
- "space-y-4 border-t border-border/60 pt-4 transition-opacity",
1217
- c && "pointer-events-none opacity-50"
1218
- ),
1219
- children: [
1220
- /* @__PURE__ */ h("div", { className: "space-y-1.5", children: [
1221
- /* @__PURE__ */ l(oe, { className: it, children: "Timezone" }),
1222
- /* @__PURE__ */ h(
1223
- Fa,
1224
- {
1225
- open: F,
1226
- onOpenChange: O,
1227
- modal: !0,
1228
- children: [
1229
- /* @__PURE__ */ l(La, { asChild: !0, children: /* @__PURE__ */ h(
1230
- V,
1231
- {
1232
- variant: "outline",
1233
- size: "xs",
1234
- role: "combobox",
1235
- "aria-expanded": F,
1236
- className: "w-full justify-between text-[12px] font-normal",
1237
- disabled: c,
1238
- children: [
1239
- /* @__PURE__ */ l("span", { className: "truncate", children: b }),
1240
- /* @__PURE__ */ l(ua, { className: "ml-2 h-3.5 w-3.5 shrink-0 opacity-50" })
1241
- ]
1242
- }
1243
- ) }),
1244
- /* @__PURE__ */ l(
1245
- _a,
1246
- {
1247
- className: "z-50 w-[--radix-popover-trigger-width] p-0",
1248
- align: "start",
1249
- children: /* @__PURE__ */ h(It, { className: "overflow-visible", children: [
1250
- /* @__PURE__ */ l(kt, { placeholder: "Search timezones…" }),
1251
- /* @__PURE__ */ h(At, { children: [
1252
- /* @__PURE__ */ l(Dt, { children: "No timezone found." }),
1253
- /* @__PURE__ */ l(Ue, { heading: "Common", children: we.map((k) => /* @__PURE__ */ h(
1254
- Oe,
1255
- {
1256
- value: `${k.value} ${k.label}`,
1257
- onSelect: () => {
1258
- x(!0), w(k.value), O(!1);
1259
- },
1260
- children: [
1261
- /* @__PURE__ */ l(
1262
- Ze,
1263
- {
1264
- className: U(
1265
- "h-3.5 w-3.5",
1266
- I === k.value ? "opacity-100" : "opacity-0"
1267
- )
1268
- }
1269
- ),
1270
- /* @__PURE__ */ l("span", { className: "flex-1", children: k.label }),
1271
- /* @__PURE__ */ l("span", { className: "text-[11px] text-muted-foreground", children: k.value })
1272
- ]
1273
- },
1274
- k.value
1275
- )) }),
1276
- /* @__PURE__ */ l(Rt, {}),
1277
- /* @__PURE__ */ l(Ue, { heading: "All timezones", children: E.map((k) => /* @__PURE__ */ h(
1278
- Oe,
1279
- {
1280
- value: k,
1281
- onSelect: () => {
1282
- x(!0), w(k), O(!1);
1283
- },
1284
- children: [
1285
- /* @__PURE__ */ l(
1286
- Ze,
1287
- {
1288
- className: U(
1289
- "h-3.5 w-3.5",
1290
- I === k ? "opacity-100" : "opacity-0"
1291
- )
1292
- }
1293
- ),
1294
- k
1295
- ]
1296
- },
1297
- k
1298
- )) })
1299
- ] })
1300
- ] })
1301
- }
1302
- )
1303
- ]
1304
- }
1305
- )
1306
- ] }),
1307
- /* @__PURE__ */ h("div", { className: "space-y-1.5", children: [
1308
- /* @__PURE__ */ l(oe, { className: it, children: "Week starts on" }),
1309
- /* @__PURE__ */ l(
1310
- Ye,
1311
- {
1312
- value: String(y),
1313
- onValueChange: (k) => {
1314
- x(!0), P(Number(k));
1315
- },
1316
- className: "flex gap-4",
1317
- disabled: c,
1318
- children: Pt.map((k) => /* @__PURE__ */ h(
1319
- "label",
1320
- {
1321
- htmlFor: `week-start-${k.value}`,
1322
- className: U(
1323
- "flex cursor-pointer items-center gap-2 text-[13px]",
1324
- c && "cursor-not-allowed"
1325
- ),
1326
- children: [
1327
- /* @__PURE__ */ l(
1328
- Ne,
1329
- {
1330
- value: String(k.value),
1331
- id: `week-start-${k.value}`,
1332
- disabled: c
1333
- }
1334
- ),
1335
- k.label
1336
- ]
1337
- },
1338
- k.value
1339
- ))
1340
- }
1341
- )
1342
- ] })
1343
- ]
1344
- }
1345
- )
1346
- ] }),
1347
- /* @__PURE__ */ h($e, { children: [
1348
- /* @__PURE__ */ l(
1349
- V,
1350
- {
1351
- variant: "outline",
1352
- size: "xs",
1353
- onClick: K,
1354
- disabled: ae,
1355
- children: "Cancel"
1356
- }
1357
- ),
1358
- /* @__PURE__ */ l(V, { size: "xs", onClick: G, disabled: X, children: ae ? /* @__PURE__ */ h(ie, { children: [
1359
- /* @__PURE__ */ l(vt, { className: "h-3.5 w-3.5 animate-spin" }),
1360
- "Saving…"
1361
- ] }) : "Save" })
1362
- ] })
1363
- ] });
1364
- }
1365
- function $r(e = {}) {
1366
- const { authToken: a, tokenProps: t } = We(), n = M(
1367
- (b) => b.actions.applyResolvedValueFormatPreferences
1368
- ), r = e.enabled ?? !0, i = (a == null ? void 0 : a.accessToken) ?? null, s = (t == null ? void 0 : t.apiServiceUrl) ?? null, o = Y(i);
1369
- o.current = i;
1370
- const [f, u] = L(null), [g, c] = L(!1), [v, m] = L(!1), [x, I] = L(!1), [w, y] = L(null);
1371
- ee(() => {
1372
- u(null), y(null), c(!1), m(!1), I(!1);
1373
- }, [i]);
1374
- const P = $(async (b) => {
1375
- const N = Na(await b.json());
1376
- if (!N.ok)
1377
- throw new Error("Value format preferences response is invalid");
1378
- return N.value;
1379
- }, []), F = $(
1380
- async (b, N) => {
1381
- if (!i || !s)
1382
- throw new Error("Not authenticated");
1383
- const R = await fetch(
1384
- `${s}/v1/user-preferences/value-format`,
1385
- {
1386
- method: b,
1387
- headers: {
1388
- Authorization: `Bearer ${i}`,
1389
- ...N ? { "Content-Type": "application/json" } : {}
1390
- },
1391
- body: N ? JSON.stringify(N) : void 0
1392
- }
1393
- );
1394
- if (!R.ok) {
1395
- const C = await R.json().catch(() => ({}));
1396
- throw new Error(C.error || "Failed to update preferences");
1397
- }
1398
- return P(R);
1399
- },
1400
- [i, s, P]
1401
- ), O = $(async () => {
1402
- if (!r || !i || !s) return;
1403
- const b = i;
1404
- c(!0), y(null);
1405
- try {
1406
- const N = await F("GET");
1407
- o.current === b && u(N);
1408
- } catch (N) {
1409
- o.current === b && y(N instanceof Error ? N.message : "Unknown error");
1410
- } finally {
1411
- o.current === b && c(!1);
1412
- }
1413
- }, [i, s, r, F]);
1414
- ee(() => {
1415
- r && O();
1416
- }, [r, O]);
1417
- const _ = $(
1418
- async (b) => {
1419
- const N = i;
1420
- m(!0), y(null);
1421
- try {
1422
- const R = await F("PATCH", b);
1423
- return o.current !== N ? !1 : (u(R), n(R.resolved, R.sources), !0);
1424
- } catch (R) {
1425
- return o.current === N && y(R instanceof Error ? R.message : "Unknown error"), !1;
1426
- } finally {
1427
- o.current === N && m(!1);
1428
- }
1429
- },
1430
- [i, n, F]
1431
- ), E = $(async () => {
1432
- const b = i;
1433
- I(!0), y(null);
1434
- try {
1435
- const N = await F("DELETE");
1436
- return o.current !== b ? !1 : (u(N), n(N.resolved, N.sources), !0);
1437
- } catch (N) {
1438
- return o.current === b && y(N instanceof Error ? N.message : "Unknown error"), !1;
1439
- } finally {
1440
- o.current === b && I(!1);
1441
- }
1442
- }, [i, n, F]);
1443
- return {
1444
- preferences: f,
1445
- isLoading: g,
1446
- isSaving: v,
1447
- isClearing: x,
1448
- error: w,
1449
- updatePreferences: _,
1450
- clearPreferences: E,
1451
- refetch: O
1452
- };
1453
- }
1454
- const je = [
1455
- { value: "en-US", label: "English (United States)" },
1456
- { value: "en-GB", label: "English (United Kingdom)" },
1457
- { value: "de-DE", label: "German (Germany)" },
1458
- { value: "fr-FR", label: "French (France)" },
1459
- { value: "es-ES", label: "Spanish (Spain)" },
1460
- { value: "it-IT", label: "Italian (Italy)" },
1461
- { value: "nl-NL", label: "Dutch (Netherlands)" },
1462
- { value: "pt-BR", label: "Portuguese (Brazil)" },
1463
- { value: "ja-JP", label: "Japanese (Japan)" },
1464
- { value: "en-IN", label: "English (India)" },
1465
- { value: "en-NZ", label: "English (New Zealand)" },
1466
- { value: "mi-NZ", label: "Māori (New Zealand)" }
1467
- ], zt = /* @__PURE__ */ new Set([
1468
- "USD",
1469
- "EUR",
1470
- "GBP",
1471
- "CAD",
1472
- "AUD",
1473
- "JPY",
1474
- "CHF",
1475
- "INR",
1476
- "BRL",
1477
- "KWD"
1478
- ]), Vr = Ea(), Kr = Vr.filter(
1479
- (e) => !zt.has(e)
1480
- ), Ft = [
1481
- { value: "short", label: "Short" },
1482
- { value: "medium", label: "Medium" },
1483
- { value: "long", label: "Long" }
1484
- ], dt = "2026-07-31", ke = "2026-07-31T14:30:45";
1485
- function Be(e) {
1486
- switch (e) {
1487
- case "viewer_user":
1488
- return "user";
1489
- case "viewer_tenant_user":
1490
- return "tenant user";
1491
- case "viewer_tenant":
1492
- return "tenant";
1493
- case "viewer_organization":
1494
- return "organization";
1495
- case "session_initial":
1496
- return "embedded session";
1497
- case "system_default":
1498
- return "system";
1499
- default:
1500
- return "another preference level";
1501
- }
1502
- }
1503
- function Ae(e) {
1504
- var a;
1505
- return ((a = Ft.find((t) => t.value === e)) == null ? void 0 : a.label) ?? e;
1506
- }
1507
- function Hr(e) {
1508
- const a = je.find((t) => t.value === e);
1509
- return a ? `${a.label} — ${a.value}` : e;
1510
- }
1511
- function De(e) {
1512
- return {
1513
- short: e("short"),
1514
- medium: e("medium"),
1515
- long: e("long")
1516
- };
1517
- }
1518
- function Re({
1519
- id: e,
1520
- label: a,
1521
- value: t,
1522
- inherited: n,
1523
- inheritedSource: r,
1524
- examples: i,
1525
- disabled: s,
1526
- onValueChange: o
1527
- }) {
1528
- const f = t === void 0 ? `Inherited · ${Ae(n)}` : Ae(t);
1529
- return /* @__PURE__ */ h("div", { className: "space-y-1.5", children: [
1530
- /* @__PURE__ */ l(oe, { htmlFor: e, className: "text-[11px] text-muted-foreground", children: a }),
1531
- /* @__PURE__ */ h(
1532
- Pe,
1533
- {
1534
- value: t ?? "inherit",
1535
- disabled: s,
1536
- onValueChange: o,
1537
- children: [
1538
- /* @__PURE__ */ l(ze, { id: e, size: "xs", children: /* @__PURE__ */ l(Fe, { children: f }) }),
1539
- /* @__PURE__ */ h(Le, { children: [
1540
- /* @__PURE__ */ l(J, { value: "inherit", className: "[&>span:last-child]:w-full", children: /* @__PURE__ */ h("span", { className: "flex w-full min-w-0 items-center justify-between gap-4", children: [
1541
- /* @__PURE__ */ h("span", { children: [
1542
- "Inherited from ",
1543
- Be(r),
1544
- " ·",
1545
- " ",
1546
- Ae(n)
1547
- ] }),
1548
- /* @__PURE__ */ l("span", { className: "shrink-0 tabular-nums text-muted-foreground", children: i[n] })
1549
- ] }) }),
1550
- Ft.map((u) => /* @__PURE__ */ l(
1551
- J,
1552
- {
1553
- value: u.value,
1554
- className: "[&>span:last-child]:w-full",
1555
- children: /* @__PURE__ */ h("span", { className: "flex w-full min-w-0 items-center justify-between gap-4", children: [
1556
- /* @__PURE__ */ l("span", { children: u.label }),
1557
- /* @__PURE__ */ l("span", { className: "shrink-0 tabular-nums text-muted-foreground", children: i[u.value] })
1558
- ] })
1559
- },
1560
- u.value
1561
- ))
1562
- ] })
1563
- ]
1564
- }
1565
- )
1566
- ] });
1567
- }
1568
- function qr({
1569
- value: e,
1570
- inherited: a,
1571
- inheritedSources: t,
1572
- onChange: n,
1573
- disabled: r
1574
- }) {
1575
- var E, b, N, R;
1576
- const i = ce(), s = ce(), o = ce(), f = ce(), u = ce(), c = (e.locale === void 0 ? void 0 : pt(e.locale)) ?? a.locale, v = e.defaultCurrency ?? a.defaultCurrency, m = {
1577
- locale: c,
1578
- dateStyle: e.dateStyle ?? a.dateStyle,
1579
- dateTime: {
1580
- dateStyle: ((E = e.dateTime) == null ? void 0 : E.dateStyle) ?? a.dateTime.dateStyle,
1581
- timeStyle: ((b = e.dateTime) == null ? void 0 : b.timeStyle) ?? a.dateTime.timeStyle
1582
- },
1583
- defaultCurrency: v
1584
- }, x = new Intl.NumberFormat(c, {
1585
- style: "currency",
1586
- currency: v
1587
- }).format(1e3), I = ge({
1588
- preferences: m,
1589
- calendar: { tz: "UTC" }
1590
- }), w = ue({
1591
- value: dt,
1592
- metadata: { kind: "raw_temporal", valueKind: "date" },
1593
- format: I
1594
- }).text, y = ue({
1595
- value: ke,
1596
- metadata: { kind: "raw_temporal", valueKind: "wall_datetime" },
1597
- format: I
1598
- }).text, P = De(
1599
- (C) => ue({
1600
- value: dt,
1601
- metadata: { kind: "raw_temporal", valueKind: "date" },
1602
- format: ge({
1603
- preferences: { ...m, dateStyle: C },
1604
- calendar: { tz: "UTC" }
1605
- })
1606
- }).text
1607
- ), F = De(
1608
- (C) => ue({
1609
- value: ke,
1610
- metadata: { kind: "raw_temporal", valueKind: "wall_datetime" },
1611
- format: ge({
1612
- preferences: {
1613
- ...m,
1614
- dateTime: { ...m.dateTime, dateStyle: C }
1615
- },
1616
- calendar: { tz: "UTC" }
1617
- })
1618
- }).text
1619
- ), O = De(
1620
- (C) => ue({
1621
- value: ke,
1622
- metadata: { kind: "raw_temporal", valueKind: "wall_datetime" },
1623
- format: ge({
1624
- preferences: {
1625
- ...m,
1626
- dateTime: { ...m.dateTime, timeStyle: C }
1627
- },
1628
- calendar: { tz: "UTC" }
1629
- })
1630
- }).text
1631
- ), _ = (C, G) => {
1632
- const K = {
1633
- ...e.dateTime,
1634
- [C]: G === "inherit" ? void 0 : G
1635
- };
1636
- n({
1637
- ...e,
1638
- dateTime: K.dateStyle === void 0 && K.timeStyle === void 0 ? void 0 : K
1639
- });
1640
- };
1641
- return /* @__PURE__ */ h("div", { className: "space-y-4", children: [
1642
- /* @__PURE__ */ h("div", { className: "space-y-1.5", children: [
1643
- /* @__PURE__ */ l(
1644
- oe,
1645
- {
1646
- htmlFor: i,
1647
- className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",
1648
- children: "Locale"
1649
- }
1650
- ),
1651
- /* @__PURE__ */ h(
1652
- Pe,
1653
- {
1654
- value: e.locale ?? "inherit",
1655
- disabled: r,
1656
- onValueChange: (C) => n({
1657
- ...e,
1658
- locale: C === "inherit" ? void 0 : C
1659
- }),
1660
- children: [
1661
- /* @__PURE__ */ l(ze, { id: i, size: "xs", children: /* @__PURE__ */ l(Fe, { children: e.locale === void 0 ? `Inherited · ${a.locale}` : Hr(e.locale) }) }),
1662
- /* @__PURE__ */ h(Le, { children: [
1663
- /* @__PURE__ */ h(J, { value: "inherit", children: [
1664
- "Inherited from ",
1665
- Be(t.locale),
1666
- " ·",
1667
- " ",
1668
- a.locale
1669
- ] }),
1670
- e.locale && !je.some(
1671
- (C) => C.value === e.locale
1672
- ) && /* @__PURE__ */ l(J, { value: e.locale, children: e.locale }),
1673
- je.map((C) => /* @__PURE__ */ h(J, { value: C.value, children: [
1674
- C.label,
1675
- " — ",
1676
- C.value
1677
- ] }, C.value))
1678
- ] })
1679
- ]
1680
- }
1681
- )
1682
- ] }),
1683
- /* @__PURE__ */ h("fieldset", { className: "space-y-2", children: [
1684
- /* @__PURE__ */ l("legend", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Date values" }),
1685
- /* @__PURE__ */ l(
1686
- Re,
1687
- {
1688
- id: o,
1689
- label: "Format",
1690
- value: e.dateStyle,
1691
- inherited: a.dateStyle,
1692
- inheritedSource: t.dateStyle,
1693
- examples: P,
1694
- disabled: r,
1695
- onValueChange: (C) => n({
1696
- ...e,
1697
- dateStyle: C === "inherit" ? void 0 : C
1698
- })
1699
- }
1700
- )
1701
- ] }),
1702
- /* @__PURE__ */ h("fieldset", { className: "space-y-2", children: [
1703
- /* @__PURE__ */ l("legend", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Date & time values" }),
1704
- /* @__PURE__ */ l(
1705
- Re,
1706
- {
1707
- id: f,
1708
- label: "Date",
1709
- value: (N = e.dateTime) == null ? void 0 : N.dateStyle,
1710
- inherited: a.dateTime.dateStyle,
1711
- inheritedSource: t.dateTime.dateStyle,
1712
- examples: F,
1713
- disabled: r,
1714
- onValueChange: (C) => _("dateStyle", C)
1715
- }
1716
- ),
1717
- /* @__PURE__ */ l(
1718
- Re,
1719
- {
1720
- id: u,
1721
- label: "Time",
1722
- value: (R = e.dateTime) == null ? void 0 : R.timeStyle,
1723
- inherited: a.dateTime.timeStyle,
1724
- inheritedSource: t.dateTime.timeStyle,
1725
- examples: O,
1726
- disabled: r,
1727
- onValueChange: (C) => _("timeStyle", C)
1728
- }
1729
- )
1730
- ] }),
1731
- /* @__PURE__ */ h("div", { className: "space-y-1.5", children: [
1732
- /* @__PURE__ */ l(
1733
- oe,
1734
- {
1735
- htmlFor: s,
1736
- className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",
1737
- children: "Default currency"
1738
- }
1739
- ),
1740
- /* @__PURE__ */ h(
1741
- Pe,
1742
- {
1743
- value: e.defaultCurrency ?? "inherit",
1744
- disabled: r,
1745
- onValueChange: (C) => n({
1746
- ...e,
1747
- defaultCurrency: C === "inherit" ? void 0 : C
1748
- }),
1749
- children: [
1750
- /* @__PURE__ */ l(ze, { id: s, size: "xs", children: /* @__PURE__ */ l(Fe, { children: e.defaultCurrency === void 0 ? `Inherited · ${a.defaultCurrency}` : e.defaultCurrency }) }),
1751
- /* @__PURE__ */ h(Le, { children: [
1752
- /* @__PURE__ */ h(J, { value: "inherit", children: [
1753
- "Inherited from ",
1754
- Be(t.defaultCurrency),
1755
- " ·",
1756
- " ",
1757
- a.defaultCurrency
1758
- ] }),
1759
- [...zt].map((C) => /* @__PURE__ */ l(J, { value: C, children: C }, C)),
1760
- Kr.map((C) => /* @__PURE__ */ l(J, { value: C, children: C }, C))
1761
- ] })
1762
- ]
1763
- }
1764
- )
1765
- ] }),
1766
- /* @__PURE__ */ h("div", { className: "rounded-control border border-border/60 bg-muted/30 px-3 py-2", children: [
1767
- /* @__PURE__ */ l("p", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Preview" }),
1768
- /* @__PURE__ */ h("dl", { className: "mt-1.5 space-y-1 text-[12px]", children: [
1769
- /* @__PURE__ */ h("div", { className: "flex items-baseline justify-between gap-4", children: [
1770
- /* @__PURE__ */ l("dt", { className: "text-muted-foreground", children: "Date" }),
1771
- /* @__PURE__ */ l("dd", { className: "text-right font-medium text-foreground", children: w })
1772
- ] }),
1773
- /* @__PURE__ */ h("div", { className: "flex items-baseline justify-between gap-4", children: [
1774
- /* @__PURE__ */ l("dt", { className: "text-muted-foreground", children: "Date & time" }),
1775
- /* @__PURE__ */ l("dd", { className: "text-right font-medium text-foreground", children: y })
1776
- ] }),
1777
- /* @__PURE__ */ h("div", { className: "flex items-baseline justify-between gap-4", children: [
1778
- /* @__PURE__ */ l("dt", { className: "text-muted-foreground", children: "Currency" }),
1779
- /* @__PURE__ */ l("dd", { className: "text-right font-medium text-foreground", children: x })
1780
- ] })
1781
- ] })
1782
- ] }),
1783
- /* @__PURE__ */ l("p", { className: "text-[11px] text-muted-foreground", children: "Currency values are not converted. Date examples use a fixed reference value and the Gregorian calendar." })
1784
- ] });
1785
- }
1786
- const ct = [
1787
- "locale",
1788
- "dateStyle",
1789
- "dateTime.dateStyle",
1790
- "dateTime.timeStyle",
1791
- "defaultCurrency"
1792
- ];
1793
- function ut(e, a) {
1794
- var t, n;
1795
- switch (a) {
1796
- case "locale":
1797
- return e == null ? void 0 : e.locale;
1798
- case "dateStyle":
1799
- return e == null ? void 0 : e.dateStyle;
1800
- case "dateTime.dateStyle":
1801
- return (t = e == null ? void 0 : e.dateTime) == null ? void 0 : t.dateStyle;
1802
- case "dateTime.timeStyle":
1803
- return (n = e == null ? void 0 : e.dateTime) == null ? void 0 : n.timeStyle;
1804
- case "defaultCurrency":
1805
- return e == null ? void 0 : e.defaultCurrency;
1806
- }
1807
- }
1808
- function Gr(e) {
1809
- var n, r;
1810
- const a = (n = e == null ? void 0 : e.dateTime) == null ? void 0 : n.dateStyle, t = (r = e == null ? void 0 : e.dateTime) == null ? void 0 : r.timeStyle;
1811
- return {
1812
- locale: e == null ? void 0 : e.locale,
1813
- dateStyle: e == null ? void 0 : e.dateStyle,
1814
- dateTime: a === void 0 && t === void 0 ? void 0 : { dateStyle: a, timeStyle: t },
1815
- defaultCurrency: e == null ? void 0 : e.defaultCurrency
1816
- };
1817
- }
1818
- function Xr({
1819
- active: e,
1820
- onClose: a
1821
- }) {
1822
- var o, f, u, g, c, v, m;
1823
- const { preferences: t, isLoading: n, isSaving: r, updatePreferences: i } = $r({ enabled: e });
1824
- if (!e) return null;
1825
- if (!t)
1826
- return /* @__PURE__ */ h(ie, { children: [
1827
- /* @__PURE__ */ l("div", { className: "py-2", children: /* @__PURE__ */ l("div", { className: "flex min-h-36 items-center justify-center text-[12px] text-muted-foreground", children: n ? "Loading preferences…" : "Preferences unavailable." }) }),
1828
- /* @__PURE__ */ h($e, { className: "justify-between sm:justify-between", children: [
1829
- /* @__PURE__ */ l(V, { variant: "ghost", size: "xs", disabled: !0, children: "Reset display formats" }),
1830
- /* @__PURE__ */ h("div", { className: "flex gap-2", children: [
1831
- /* @__PURE__ */ l(V, { variant: "outline", size: "xs", onClick: a, children: "Cancel" }),
1832
- /* @__PURE__ */ l(V, { size: "xs", disabled: !0, children: "Save" })
1833
- ] })
1834
- ] })
1835
- ] });
1836
- const s = [
1837
- ((o = t.stored) == null ? void 0 : o.locale) ?? "",
1838
- ((f = t.stored) == null ? void 0 : f.dateStyle) ?? "",
1839
- ((g = (u = t.stored) == null ? void 0 : u.dateTime) == null ? void 0 : g.dateStyle) ?? "",
1840
- ((v = (c = t.stored) == null ? void 0 : c.dateTime) == null ? void 0 : v.timeStyle) ?? "",
1841
- ((m = t.stored) == null ? void 0 : m.defaultCurrency) ?? ""
1842
- ].join(":");
1843
- return /* @__PURE__ */ l(
1844
- Jr,
1845
- {
1846
- preferences: t,
1847
- isSaving: r,
1848
- updatePreferences: i,
1849
- onClose: a
1850
- },
1851
- s
1852
- );
1853
- }
1854
- function Jr({
1855
- preferences: e,
1856
- isSaving: a,
1857
- updatePreferences: t,
1858
- onClose: n
1859
- }) {
1860
- var u, g;
1861
- const [r, i] = L(
1862
- () => Gr(e.stored)
1863
- ), s = (r.locale === void 0 || pt(r.locale) !== void 0) && (r.defaultCurrency === void 0 || Ta(r.defaultCurrency) !== void 0) && (r.dateStyle === void 0 || ["short", "medium", "long"].includes(r.dateStyle)) && (((u = r.dateTime) == null ? void 0 : u.dateStyle) === void 0 || ["short", "medium", "long"].includes(r.dateTime.dateStyle)) && (((g = r.dateTime) == null ? void 0 : g.timeStyle) === void 0 || ["short", "medium", "long"].includes(r.dateTime.timeStyle)), o = async () => {
1864
- const c = {
1865
- ...r.locale !== void 0 ? { locale: r.locale } : {},
1866
- ...r.dateStyle !== void 0 ? { dateStyle: r.dateStyle } : {},
1867
- ...r.dateTime ? { dateTime: { ...r.dateTime } } : {},
1868
- ...r.defaultCurrency !== void 0 ? { defaultCurrency: r.defaultCurrency } : {}
1869
- }, v = ct.filter(
1870
- (I) => ut(r, I) === void 0 && ut(e.stored, I) !== void 0
1871
- ), m = {
1872
- ...Object.keys(c).length > 0 ? { set: c } : {},
1873
- ...v.length > 0 ? { clear: v } : {}
1874
- };
1875
- (Object.keys(m).length === 0 ? !0 : await t(m)) ? (H.success("Display format preferences saved."), n()) : H.error("Failed to save preferences. Please try again.");
1876
- }, f = async () => {
1877
- await t({
1878
- clear: [...ct]
1879
- }) ? (H.success("Display format preferences reset."), n()) : H.error(
1880
- "Failed to reset display format preferences. Please try again."
1881
- );
1882
- };
1883
- return /* @__PURE__ */ h(ie, { children: [
1884
- /* @__PURE__ */ l("div", { className: "py-2", children: /* @__PURE__ */ l(
1885
- qr,
1886
- {
1887
- value: r,
1888
- inherited: e.inherited,
1889
- inheritedSources: e.inheritedSources,
1890
- onChange: i,
1891
- disabled: a
1892
- }
1893
- ) }),
1894
- /* @__PURE__ */ h($e, { className: "justify-between sm:justify-between", children: [
1895
- /* @__PURE__ */ l(
1896
- V,
1897
- {
1898
- variant: "ghost",
1899
- size: "xs",
1900
- onClick: f,
1901
- disabled: a || e.stored === null,
1902
- children: "Reset display formats"
1903
- }
1904
- ),
1905
- /* @__PURE__ */ h("div", { className: "flex gap-2", children: [
1906
- /* @__PURE__ */ l(
1907
- V,
1908
- {
1909
- variant: "outline",
1910
- size: "xs",
1911
- onClick: n,
1912
- disabled: a,
1913
- children: "Cancel"
1914
- }
1915
- ),
1916
- /* @__PURE__ */ l(
1917
- V,
1918
- {
1919
- size: "xs",
1920
- onClick: o,
1921
- disabled: a || !s,
1922
- children: a ? /* @__PURE__ */ h(ie, { children: [
1923
- /* @__PURE__ */ l(vt, { className: "h-3.5 w-3.5 animate-spin" }),
1924
- "Saving…"
1925
- ] }) : "Save"
1926
- }
1927
- )
1928
- ] })
1929
- ] })
1930
- ] });
1931
- }
1932
- function wn({
1933
- open: e,
1934
- onOpenChange: a
1935
- }) {
1936
- const [t, n] = L("display"), r = () => a(!1);
1937
- return /* @__PURE__ */ l(ma, { open: e, onOpenChange: a, children: /* @__PURE__ */ h(fa, { className: "rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control", children: [
1938
- /* @__PURE__ */ h(ha, { children: [
1939
- /* @__PURE__ */ l(pa, { className: "text-[15px]", children: "Report preferences" }),
1940
- /* @__PURE__ */ l(va, { className: "text-[13px] leading-5", children: "Set how values and Calendar periods appear for you." })
1941
- ] }),
1942
- /* @__PURE__ */ h(Ma, { value: t, onValueChange: n, children: [
1943
- /* @__PURE__ */ h(Ua, { variant: "underline", className: "w-full justify-start", children: [
1944
- /* @__PURE__ */ l(Qe, { value: "display", children: "Display formats" }),
1945
- /* @__PURE__ */ l(Qe, { value: "calendar", children: "Calendar" })
1946
- ] }),
1947
- /* @__PURE__ */ l(et, { value: "display", children: /* @__PURE__ */ l(
1948
- Xr,
1949
- {
1950
- active: e && t === "display",
1951
- onClose: r
1952
- }
1953
- ) }),
1954
- /* @__PURE__ */ l(et, { value: "calendar", children: /* @__PURE__ */ l(
1955
- Wr,
1956
- {
1957
- active: e && t === "calendar",
1958
- onClose: r
1959
- }
1960
- ) })
1961
- ] })
1962
- ] }) });
1963
- }
1964
- export {
1965
- Ja as A,
1966
- It as C,
1967
- yn as D,
1968
- wn as R,
1969
- qr as a,
1970
- kt as b,
1971
- At as c,
1972
- Dt as d,
1973
- Ue as e,
1974
- Oe as f,
1975
- lr as g,
1976
- gn as h
1977
- };