react-semaphor 0.1.588 → 0.1.589

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 (24) hide show
  1. package/dist/brand-studio/index.js +5 -5
  2. package/dist/chunks/{assistant-chat-BeM6joPc.js → assistant-chat-DBPa6sJU.js} +5 -5
  3. package/dist/chunks/{card-filter-builder-DmodrhyI.js → card-filter-builder-CGM7ROM0.js} +166 -166
  4. package/dist/chunks/{dashboard-Tu5wT0Cw.js → dashboard-UXH3E31V.js} +1 -1
  5. package/dist/chunks/{dashboard-briefing-launcher-D8jMxIJo.js → dashboard-briefing-launcher-CTFuSWH_.js} +154 -154
  6. package/dist/chunks/{dashboard-controls-uzeAIEkM.js → dashboard-controls-BcxWhOKw.js} +42 -42
  7. package/dist/chunks/{dashboard-json-i5rpFNCg.js → dashboard-json-C-oBcKKC.js} +2 -2
  8. package/dist/chunks/{edit-dashboard-visual-BpEK_Sls.js → edit-dashboard-visual-COjKc_Du.js} +718 -718
  9. package/dist/chunks/{layout-grid-XCYphks2.js → layout-grid-BG__sPkb.js} +1 -1
  10. package/dist/chunks/{list-filter-DGV3fqqv.js → list-filter-Cb8i7N8f.js} +1 -1
  11. package/dist/chunks/{paintbrush-DEEZXhDj.js → paintbrush-C310xSuR.js} +1 -1
  12. package/dist/chunks/{palette-Bgy0H-Nt.js → palette-Ci5P91Zb.js} +1 -1
  13. package/dist/chunks/report-preferences-dialog-DtuOcejh.js +1637 -0
  14. package/dist/chunks/{save-xnRCvMeA.js → save-BhhXfp4s.js} +1 -1
  15. package/dist/chunks/{semaphor-ready-indicator-zU9reNmX.js → semaphor-ready-indicator-HGEnCavj.js} +27084 -26516
  16. package/dist/chunks/{shelf-drop-preview-context-R9sf4oDX.js → shelf-drop-preview-context-DaCXCdMA.js} +108 -108
  17. package/dist/chunks/{style-sheet-parts-D7NbsFL0.js → style-sheet-parts-CmXmKqGw.js} +30 -30
  18. package/dist/chunks/{upload-BXGgYS4g.js → upload-DDYc1Qjj.js} +1 -1
  19. package/dist/dashboard/index.js +1 -1
  20. package/dist/index.js +208 -209
  21. package/dist/style.css +1 -1
  22. package/dist/surfboard/index.js +1 -1
  23. package/package.json +1 -1
  24. package/dist/chunks/report-preferences-dialog-CTM0xfd0.js +0 -2028
@@ -0,0 +1,1637 @@
1
+ import { jsx as r, Fragment as M, jsxs as d } from "react/jsx-runtime";
2
+ import He, { useMemo as j, useState as I, useEffect as B, lazy as ae, Suspense as Y, useRef as L, useLayoutEffect as ee, useCallback as P, Activity as Ke, useId as $ } from "react";
3
+ import { b as qe, b8 as be, bk as Ge, bl as Je, u as D, bm as ze, Y as Xe, W as Ze, bn as Ye, bo as Qe, bp as et, bq as tt, br as J, bs as Le, bt as ge, bu as at, ad as X, ac as rt, bv as nt, bw as st, ae as ye, af as lt, bx as it, E as ot, F as dt, S as ct, B as ut, a as mt, U as ht, by as ft, D as bt, A as pt, C as gt, bz as yt, bA as ve, bB as ne, bC as vt, i as St, j as wt, k as xt, l as Tt, m as Se, n as we, bD as Ct, bE as pe, bF as F, bG as Nt, bH as Et, bI as It, bJ as At, bK as Dt } from "./semaphor-ready-indicator-HGEnCavj.js";
4
+ import { j as kt, c as U } from "./pickers-DkqmtnTL.js";
5
+ import { J as _t } from "./bookmark-state-Bn7k3ttp.js";
6
+ import { r as Pt, a as Re } from "./availability-Bp5Gfu1I.js";
7
+ import { s as zt } from "./resolve-dashboard-input-context-DFBIngUZ.js";
8
+ import { B as z, Z as Lt, _ as Rt, $ as Ut, a0 as Ft, a1 as Ot, a2 as Bt, s as G, e as jt, f as Mt, h as Vt, j as xe, L as Ue, y as de, z as ce, A as ue, D as me, E as O, T as Wt, k as $t, l as Te, n as Ce } from "./style-sheet-parts-CmXmKqGw.js";
9
+ import "./validators-CrYXNnNE.js";
10
+ import "./matrix-operation-contract-JSmproo9.js";
11
+ import "./analytics-base-schemas-8wz9vqn_.js";
12
+ import { parseValueFormatPreferencesResponse as Ht, canonicalizeSupportedLocale as Fe, getSupportedCurrencyCodes as Kt, canonicalizeSupportedCurrencyCode as qt } from "../value-format-preferences/index.js";
13
+ import { f as Gt } from "./filter-reach-copy-D5AmDHda.js";
14
+ import { a as Jt } from "./report-runtime-context-CrOgmuxO.js";
15
+ import { ar as Z, ay as H } from "./pivot-result-contract-expectations-DbBahmgc.js";
16
+ function Xt() {
17
+ return /* @__PURE__ */ r(
18
+ "div",
19
+ {
20
+ role: "dashboard-plus-main",
21
+ className: "flex min-h-0 grow basis-0 overflow-hidden",
22
+ children: /* @__PURE__ */ r("section", { className: "flex min-h-0 grow basis-0 flex-col overflow-hidden", children: /* @__PURE__ */ r(qe, {}) })
23
+ }
24
+ );
25
+ }
26
+ const Zt = /* @__PURE__ */ new Set(["iat", "exp", "nbf", "jti"]);
27
+ function Yt(e) {
28
+ return zt(
29
+ Object.fromEntries(
30
+ Object.entries(e ?? {}).filter(([a]) => !Zt.has(a))
31
+ )
32
+ );
33
+ }
34
+ function Qt(e) {
35
+ var t;
36
+ const a = e == null ? void 0 : e.config;
37
+ return Pt({
38
+ features: ((t = a == null ? void 0 : a.projectFeatures) == null ? void 0 : t.features) ?? {},
39
+ config: { enabled: Re(a).enabled },
40
+ identity: {
41
+ orgUserId: e == null ? void 0 : e.orgUserId,
42
+ tenantId: e == null ? void 0 : e.tenantId,
43
+ endUserId: e == null ? void 0 : e.endUserId
44
+ },
45
+ modelConfigured: !0
46
+ });
47
+ }
48
+ let Ne = 0;
49
+ function Ee(e, a) {
50
+ Ne += 1;
51
+ const { name: t, layout: n } = Re(a == null ? void 0 : a.config);
52
+ return { ...Je(n), id: Ne, callerKey: e, assistantName: t };
53
+ }
54
+ function ea({
55
+ children: e,
56
+ authToken: a
57
+ }) {
58
+ const t = be(), n = j(
59
+ () => a === void 0 ? t.tokenProps : aa(a),
60
+ [a, t.tokenProps]
61
+ ), s = j(() => Yt(n), [n]), i = j(
62
+ () => Qt(n).available,
63
+ [n]
64
+ ), [l, o] = I(() => Ee(s, n));
65
+ l.callerKey !== s && o(Ee(s, n)), ra(l);
66
+ const h = j(() => ({ instance: l, available: i }), [l, i]);
67
+ return /* @__PURE__ */ r(Ge.Provider, { value: h, children: e });
68
+ }
69
+ function ta({ children: e }) {
70
+ return ze() ? /* @__PURE__ */ r(M, { children: e }) : /* @__PURE__ */ r(ea, { children: e });
71
+ }
72
+ function aa(e) {
73
+ if (!(e != null && e.accessToken)) return {};
74
+ try {
75
+ return kt(e.accessToken);
76
+ } catch {
77
+ return {};
78
+ }
79
+ }
80
+ function ra(e) {
81
+ B(() => {
82
+ const a = (n, s) => {
83
+ const i = e.store.getState().focus;
84
+ i && !na(i, n, s) && e.clearFocus();
85
+ }, t = D.getState();
86
+ return a(t.selectedSheetId, t.dashboard), D.subscribe((n, s) => {
87
+ (n.selectedSheetId !== s.selectedSheetId || n.dashboard !== s.dashboard) && a(n.selectedSheetId, n.dashboard), n.isVisualEditing && !s.isVisualEditing && e.leaveBeside();
88
+ });
89
+ }, [e]);
90
+ }
91
+ function na(e, a, t) {
92
+ if ((a ?? null) !== e.sheetId) return !1;
93
+ const n = t ? _t(t, e.cardId) : void 0;
94
+ return !!n && n.sheet.id === e.sheetId;
95
+ }
96
+ const sa = ae(() => import("./assistant-chat-DBPa6sJU.js"));
97
+ function Ya() {
98
+ const e = Xe(), a = Ze();
99
+ if (!e.available) return null;
100
+ const t = a !== "lg";
101
+ return /* @__PURE__ */ d(
102
+ z,
103
+ {
104
+ variant: e.isOpen ? "secondary" : "outline",
105
+ size: "xs",
106
+ "aria-pressed": e.isOpen,
107
+ "aria-label": e.assistantName,
108
+ title: t ? e.assistantName : void 0,
109
+ onClick: e.toggle,
110
+ className: t ? "w-7 px-0" : void 0,
111
+ children: [
112
+ /* @__PURE__ */ r(Ye, { className: "h-3.5 w-3.5" }),
113
+ !t && e.assistantName
114
+ ]
115
+ }
116
+ );
117
+ }
118
+ const la = {
119
+ // Docked widths are the viewer's (the resize handle), applied as a style.
120
+ "docked-right": "relative shrink-0 border-l border-border",
121
+ "docked-left": "relative order-first shrink-0 border-r border-border",
122
+ 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",
123
+ "full-page": "absolute inset-0 z-30"
124
+ }, ia = "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", oa = 640, q = 8;
125
+ function da({ surface: e = "dashboard" } = {}) {
126
+ const a = ze(), { isOpen: t, mounted: n, storedLayout: s, width: i, beside: l, besideSize: o, focusCardId: h, askCount: w } = Qe(
127
+ (a == null ? void 0 : a.instance.store) ?? tt,
128
+ et((f) => {
129
+ var y;
130
+ return {
131
+ isOpen: f.isOpen,
132
+ mounted: f.mounted,
133
+ storedLayout: f.layout,
134
+ width: f.width,
135
+ beside: f.beside,
136
+ besideSize: f.besideSize,
137
+ focusCardId: (y = f.focus) == null ? void 0 : y.cardId,
138
+ askCount: f.askCount
139
+ };
140
+ })
141
+ ), x = e === "none", u = D(
142
+ (f) => l && t && h && !x ? ca(f.dashboard, f.selectedSheetId, h) : void 0
143
+ ), b = ua(u, w);
144
+ if (!(a != null && a.available) || !n && !x) return null;
145
+ const c = x ? "full-page" : b.shown ? "beside-card" : s, S = x || t, m = c === "docked-right" || c === "docked-left";
146
+ return /* @__PURE__ */ d(
147
+ "aside",
148
+ {
149
+ ref: b.setFloating,
150
+ "aria-label": a.instance.assistantName,
151
+ "data-testid": "assistant-panel",
152
+ "data-layout": c,
153
+ "data-beside-frame": c === "beside-card" ? u : void 0,
154
+ "data-beside-side": c === "beside-card" ? b.side : void 0,
155
+ className: U(
156
+ "flex-col bg-background",
157
+ c === "beside-card" ? ia : la[c],
158
+ S ? "flex" : "hidden"
159
+ ),
160
+ style: c === "beside-card" ? { ...b.style, width: o.width, height: o.height } : (
161
+ // The saved width, never more than the share of the dashboard's area the
162
+ // handle allows, however the area is sized now or later (P4-10).
163
+ m ? { width: i, maxWidth: `${Oe * 100}%` } : void 0
164
+ ),
165
+ onKeyDown: c === "beside-card" ? (f) => {
166
+ if (f.key !== "Escape" || f.defaultPrevented || !(f.target instanceof Node) || !f.currentTarget.contains(f.target)) return;
167
+ f.preventDefault();
168
+ const y = b.cardActions();
169
+ a.instance.close(), y == null || y.focus();
170
+ } : void 0,
171
+ children: [
172
+ m ? /* @__PURE__ */ r(fa, { instance: a.instance, side: c === "docked-left" ? "right" : "left", width: i }) : null,
173
+ c === "beside-card" ? /* @__PURE__ */ r(ha, { instance: a.instance, size: o, side: b.handleSide }) : null,
174
+ /* @__PURE__ */ r(Y, { fallback: null, children: /* @__PURE__ */ r(sa, { instance: a.instance, surface: e, placement: c }, a.instance.id) })
175
+ ]
176
+ }
177
+ );
178
+ }
179
+ function ca(e, a, t) {
180
+ var s, i, l;
181
+ const n = (s = e.sheets) == null ? void 0 : s.find((o) => o.id === a);
182
+ return (l = (i = n == null ? void 0 : n.frames) == null ? void 0 : i.find((o) => {
183
+ var h;
184
+ return (h = o.cards) == null ? void 0 : h.some((w) => w.id === t);
185
+ })) == null ? void 0 : l.id;
186
+ }
187
+ function ua(e, a) {
188
+ var S;
189
+ const [t, n] = I(void 0), [s, i] = I(void 0), l = L(a);
190
+ ee(() => {
191
+ l.current = a;
192
+ });
193
+ const o = s === a ? null : t, { refs: h, elements: w, floatingStyles: x, middlewareData: u, isPositioned: b } = Lt({
194
+ strategy: "absolute",
195
+ placement: o ?? "right-start",
196
+ middleware: [
197
+ Rt(q),
198
+ Ut({ padding: q }),
199
+ Ft({
200
+ padding: q,
201
+ apply: ({ availableWidth: m, availableHeight: f, elements: y }) => {
202
+ y.floating.style.setProperty("--assistant-beside-max-w", `${Math.max(0, m)}px`), y.floating.style.setProperty("--assistant-beside-max-h", `${Math.max(0, f)}px`);
203
+ }
204
+ }),
205
+ Ot()
206
+ ],
207
+ whileElementsMounted: (m, f, y) => Bt(m, f, () => {
208
+ const E = ma(m, f);
209
+ n(E), E === null && i(l.current), y();
210
+ })
211
+ }), c = w.floating;
212
+ return ee(() => {
213
+ h.setReference(e ? Ie(c == null ? void 0 : c.parentElement, e) : null);
214
+ }, [e, c, h]), {
215
+ shown: e !== void 0 && o !== null && w.reference !== null,
216
+ setFloating: h.setFloating,
217
+ style: {
218
+ ...x,
219
+ // Not before it is placed (its side is chosen first): never a flash at
220
+ // the row's corner. With the card wholly out of view, it goes with the card.
221
+ ...!b || (S = u.hide) != null && S.referenceHidden ? { visibility: "hidden" } : {}
222
+ },
223
+ /** The side the conversation took; the size handle sits on the corner away from the card. */
224
+ side: o ?? void 0,
225
+ handleSide: o === "left-start" ? "left" : "right",
226
+ /** The card's ··· menu, where Ask lives and focus returns on Escape. */
227
+ cardActions: () => {
228
+ var m;
229
+ return e ? (m = Ie(c == null ? void 0 : c.parentElement, e)) == null ? void 0 : m.querySelector("[data-card-actions]") : null;
230
+ }
231
+ };
232
+ }
233
+ function Ie(e, a) {
234
+ return e ? Array.from(e.querySelectorAll("[data-frame-id]")).find((t) => t.dataset.frameId === a) ?? null : null;
235
+ }
236
+ function ma(e, a) {
237
+ const t = a.parentElement;
238
+ if (!t || !e.isConnected) return null;
239
+ const n = t.getBoundingClientRect();
240
+ if (n.width < oa) return null;
241
+ const s = e.getBoundingClientRect(), { min: i } = Le, l = (o, h) => o >= i.width + 2 * q && h >= i.height + 2 * q;
242
+ return l(n.right - s.right, n.height) ? "right-start" : l(s.left - n.left, n.height) ? "left-start" : l(n.width, n.bottom - s.bottom) ? "bottom-start" : null;
243
+ }
244
+ function ha({
245
+ instance: e,
246
+ size: a,
247
+ side: t
248
+ }) {
249
+ const n = L(void 0), s = t === "left" ? -1 : 1, i = (l) => {
250
+ const o = n.current;
251
+ return {
252
+ width: o.start.width + s * (l.clientX - o.x),
253
+ height: o.start.height + (l.clientY - o.y)
254
+ };
255
+ };
256
+ return /* @__PURE__ */ r(
257
+ "div",
258
+ {
259
+ role: "separator",
260
+ "aria-label": "Resize assistant",
261
+ tabIndex: 0,
262
+ title: "Drag to resize. Double-click to reset.",
263
+ onPointerDown: (l) => {
264
+ var o, h;
265
+ l.preventDefault(), (h = (o = l.currentTarget).setPointerCapture) == null || h.call(o, l.pointerId), n.current = { x: l.clientX, y: l.clientY, start: a };
266
+ },
267
+ onPointerMove: (l) => {
268
+ n.current && e.setBesideSize(i(l));
269
+ },
270
+ onPointerUp: (l) => {
271
+ n.current && (e.setBesideSize(i(l), { save: !0 }), n.current = void 0);
272
+ },
273
+ onPointerCancel: () => {
274
+ n.current = void 0;
275
+ },
276
+ onKeyDown: (l) => {
277
+ const o = {
278
+ ArrowLeft: { width: -s * W, height: 0 },
279
+ ArrowRight: { width: s * W, height: 0 },
280
+ ArrowUp: { width: 0, height: -W },
281
+ ArrowDown: { width: 0, height: W }
282
+ }[l.key];
283
+ o && (l.preventDefault(), e.setBesideSize({ width: a.width + o.width, height: a.height + o.height }, { save: !0 }));
284
+ },
285
+ onDoubleClick: () => e.setBesideSize(Le.default, { save: !0 }),
286
+ className: U(
287
+ "absolute bottom-0 z-10 h-3 w-3 touch-none outline-none hover:bg-primary/30 focus-visible:bg-primary/40",
288
+ t === "left" ? "left-0 cursor-nesw-resize rounded-bl-card" : "right-0 cursor-nwse-resize rounded-br-card"
289
+ )
290
+ }
291
+ );
292
+ }
293
+ const W = 16, Oe = 0.6;
294
+ function fa({ instance: e, side: a, width: t }) {
295
+ const n = L(void 0), s = (u) => {
296
+ var c, S;
297
+ const b = (S = (c = u.closest("aside")) == null ? void 0 : c.parentElement) == null ? void 0 : S.clientWidth;
298
+ return b ? b * Oe : J.max;
299
+ }, i = (u) => {
300
+ var b;
301
+ return ((b = u.closest("aside")) == null ? void 0 : b.getBoundingClientRect().width) || t;
302
+ }, l = (u) => {
303
+ const b = n.current;
304
+ if (!b) return t;
305
+ const c = u - b.startX;
306
+ return ge(b.startWidth + (a === "left" ? -c : c), b.maxForArea);
307
+ }, o = (u) => {
308
+ var b, c;
309
+ u.preventDefault(), (c = (b = u.currentTarget).setPointerCapture) == null || c.call(b, u.pointerId), n.current = { startX: u.clientX, startWidth: i(u.currentTarget), maxForArea: s(u.currentTarget) };
310
+ }, h = (u) => {
311
+ n.current && e.setWidth(l(u.clientX));
312
+ }, w = (u) => {
313
+ n.current && (e.setWidth(l(u.clientX), { save: !0 }), n.current = void 0);
314
+ }, x = (u) => {
315
+ if (u.key !== "ArrowLeft" && u.key !== "ArrowRight") return;
316
+ u.preventDefault();
317
+ const b = u.key === "ArrowLeft" == (a === "left");
318
+ e.setWidth(ge(i(u.currentTarget) + (b ? W : -W), s(u.currentTarget)), { save: !0 });
319
+ };
320
+ return /* @__PURE__ */ r(
321
+ "div",
322
+ {
323
+ role: "separator",
324
+ "aria-orientation": "vertical",
325
+ "aria-label": "Resize assistant",
326
+ "aria-valuenow": t,
327
+ "aria-valuemin": J.min,
328
+ "aria-valuemax": J.max,
329
+ tabIndex: 0,
330
+ title: "Drag to resize. Double-click to reset.",
331
+ onPointerDown: o,
332
+ onPointerMove: h,
333
+ onPointerUp: w,
334
+ onPointerCancel: w,
335
+ onKeyDown: x,
336
+ onDoubleClick: () => e.setWidth(J.default, { save: !0 }),
337
+ className: U(
338
+ "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",
339
+ a === "left" ? "-left-[3px]" : "-right-[3px]"
340
+ )
341
+ }
342
+ );
343
+ }
344
+ function ba(e) {
345
+ const a = at();
346
+ return P(
347
+ async (t, n) => {
348
+ const s = D.getState();
349
+ if (s.isVisualEditing)
350
+ return { ok: !1, reason: "not_editable", message: X.not_editable };
351
+ if (!e()) return { ok: !1, reason: "not_editable", message: X.no_save };
352
+ if (s.dashboard !== t.basedOn)
353
+ return { ok: !1, reason: "dashboard_changed", message: X.dashboard_changed };
354
+ const i = Gt(t.basedOn, t.operations, t.context);
355
+ if (!i.ok) return { ok: !1, reason: "refused", message: i.failedAt.message };
356
+ const l = { domainsById: {} };
357
+ for (const o of i.queryFrames) {
358
+ const h = await a(o, { reuseLoaded: !0 }).catch((w) => {
359
+ console.warn("Applying the change without refreshed semantic metadata:", w);
360
+ });
361
+ rt(l, h);
362
+ }
363
+ return n != null && n.stillWanted && !n.stillWanted() ? { ok: !1, reason: "dropped" } : e() ? D.getState().actions.applyProposal({ ...t, semanticExecutionPayload: l }) : { ok: !1, reason: "not_editable", message: X.no_save };
364
+ },
365
+ [e, a]
366
+ );
367
+ }
368
+ function pa(e) {
369
+ const { canEditDashboard: a, isInspectionMode: t } = nt(), n = st(), s = D(ye), i = e && n && a === !0 && !t, l = L(i);
370
+ ee(() => {
371
+ l.current = i;
372
+ });
373
+ const o = P(
374
+ () => l.current && ye(D.getState()),
375
+ []
376
+ );
377
+ return { canChange: i && s, canChangeNow: o };
378
+ }
379
+ const Be = {
380
+ dashboard_changed: "Not applied: the dashboard on screen changed after this change was prepared.",
381
+ not_editable: "Not applied: the dashboard can't be changed on screen right now (the editor is open, or Save isn't shown).",
382
+ expired: "Not applied: it arrived after the time it had to land.",
383
+ refused: "Not applied: the change no longer fits the dashboard."
384
+ }, K = {
385
+ changed: "Changed by your assistant",
386
+ undo: "Undo",
387
+ changedSince: "Changed since. Cancel discards every unsaved change.",
388
+ closeEditorToUndo: "Close the editor to undo."
389
+ };
390
+ function ga({
391
+ port: e,
392
+ onLifecycleEvent: a
393
+ }) {
394
+ const { canChange: t, canChangeNow: n } = pa(!0), s = D((c) => {
395
+ var S;
396
+ return (S = c.dashboard) == null ? void 0 : S.id;
397
+ }), i = ba(n), [l, o] = I(null), h = L(/* @__PURE__ */ new Map()), w = L(/* @__PURE__ */ new Map()), x = L(Promise.resolve()), u = L({ apply: i, onLifecycleEvent: a });
398
+ ee(() => {
399
+ u.current = { apply: i, onLifecycleEvent: a };
400
+ }), B(() => {
401
+ e.setScreenState({ eligible: t, ...s ? { dashboardId: s } : {} });
402
+ }, [e, t, s]), B(
403
+ () => D.subscribe((c, S) => {
404
+ if (c.editSessionEpoch !== S.editSessionEpoch) {
405
+ h.current.clear(), o(null);
406
+ return;
407
+ }
408
+ if (c.dashboard !== S.dashboard)
409
+ for (const [m, f] of h.current)
410
+ f !== c.dashboard && h.current.delete(m);
411
+ }),
412
+ []
413
+ ), B(() => {
414
+ const c = (m) => {
415
+ const f = D.getState().dashboard;
416
+ if (!f || f.id !== m.dashboardId) return;
417
+ const y = Sa();
418
+ h.current.set(y, f), e.answerCopyRequest({
419
+ kind: "uploaded",
420
+ screenId: e.screenId,
421
+ requestId: m.requestId,
422
+ revisionId: y,
423
+ dashboard: f
424
+ });
425
+ }, S = async (m, f) => {
426
+ var p, v, C;
427
+ const y = w.current.get(m.deliveryId);
428
+ if (y) {
429
+ e.reportOutcome({ screenId: e.screenId, deliveryId: m.deliveryId, outcome: y });
430
+ return;
431
+ }
432
+ const E = h.current.get(m.revisionId), A = () => !E || h.current.get(m.revisionId) !== E ? "dashboard_changed" : performance.now() < f + m.applyWithinMs ? null : "expired", _ = A();
433
+ let k;
434
+ if (_ || !E)
435
+ k = Q(_ ?? "dashboard_changed");
436
+ else {
437
+ let g = "expired";
438
+ const V = await u.current.apply(
439
+ { proposalId: m.proposalId, operations: m.operations, context: m.context, basedOn: E },
440
+ {
441
+ stillWanted: () => {
442
+ const R = A();
443
+ return R && (g = R), R === null;
444
+ }
445
+ }
446
+ );
447
+ k = va(V, g);
448
+ }
449
+ if (w.current.set(m.deliveryId, k), e.reportOutcome({ screenId: e.screenId, deliveryId: m.deliveryId, outcome: k }), k.status !== "applied") return;
450
+ const N = ((p = D.getState().dashboard) == null ? void 0 : p.id) ?? "";
451
+ o({ deliveryId: m.deliveryId, proposalId: m.proposalId, summary: m.summary, dashboardId: N, words: null }), (C = (v = u.current).onLifecycleEvent) == null || C.call(v, {
452
+ type: "dashboard:change-applied",
453
+ dashboardId: N,
454
+ payload: { deliveryId: m.deliveryId, summary: m.summary }
455
+ });
456
+ };
457
+ return e.subscribe((m) => {
458
+ if (m.type === "copy_request") {
459
+ c(m);
460
+ return;
461
+ }
462
+ const f = performance.now();
463
+ x.current = x.current.then(
464
+ () => S(m, f).catch((y) => console.error("[live-screen] a delivery failed", y))
465
+ );
466
+ });
467
+ }, [e]);
468
+ const b = P(() => {
469
+ var S, m;
470
+ if (!l) return;
471
+ const c = D.getState().actions.undoProposal(l.proposalId);
472
+ c.ok ? ((m = (S = u.current).onLifecycleEvent) == null || m.call(S, {
473
+ type: "dashboard:change-undone",
474
+ dashboardId: l.dashboardId,
475
+ payload: { deliveryId: l.deliveryId, summary: l.summary }
476
+ }), o(null)) : c.reason === "changed_since" ? o({ ...l, words: "changed_since" }) : c.reason === "not_editable" ? o({ ...l, words: "not_editable" }) : o(null);
477
+ }, [l]);
478
+ return l ? /* @__PURE__ */ r(ya, { note: l, onUndo: b }) : null;
479
+ }
480
+ function ya({ note: e, onUndo: a }) {
481
+ const t = D((l) => lt(l, e.proposalId)), n = D((l) => l.isVisualEditing);
482
+ if (t === "none" && e.words === null) return null;
483
+ const s = e.words === "changed_since" || t === "changed_since", i = s ? "changed_since" : e.words === "not_editable" ? "not_editable" : t;
484
+ return /* @__PURE__ */ d(
485
+ "div",
486
+ {
487
+ className: "flex min-h-8 items-center gap-2 border-b border-border bg-muted/40 px-3 py-1 text-xs text-muted-foreground",
488
+ "data-testid": "live-change-note",
489
+ "data-note-state": i,
490
+ role: "status",
491
+ children: [
492
+ /* @__PURE__ */ d("span", { className: "truncate", title: e.summary.join(" "), children: [
493
+ K.changed,
494
+ s ? `. ${K.changedSince}` : e.words === "not_editable" ? `. ${K.closeEditorToUndo}` : ""
495
+ ] }),
496
+ !s && t === "undoable" ? /* @__PURE__ */ d(M, { children: [
497
+ /* @__PURE__ */ r("span", { "aria-hidden": "true", children: "·" }),
498
+ /* @__PURE__ */ d(
499
+ z,
500
+ {
501
+ variant: "outline",
502
+ size: "xs",
503
+ className: "h-6 gap-1 px-2 text-[11.5px]",
504
+ disabled: n,
505
+ title: n ? K.closeEditorToUndo : void 0,
506
+ onClick: a,
507
+ children: [
508
+ /* @__PURE__ */ r(it, { className: "h-3 w-3" }),
509
+ K.undo
510
+ ]
511
+ }
512
+ )
513
+ ] }) : null
514
+ ]
515
+ }
516
+ );
517
+ }
518
+ function va(e, a) {
519
+ if (e.ok) return { status: "applied" };
520
+ switch (e.reason) {
521
+ case "dashboard_changed":
522
+ case "not_editable":
523
+ return Q(e.reason);
524
+ case "refused":
525
+ return { status: "not_applied", reason: "refused", message: (e.message || Be.refused).slice(0, 500) };
526
+ case "dropped":
527
+ return Q(a);
528
+ case "previous_not_applied":
529
+ return Q("refused");
530
+ }
531
+ }
532
+ function Q(e) {
533
+ return { status: "not_applied", reason: e, message: Be[e] };
534
+ }
535
+ function Sa() {
536
+ return globalThis.crypto.randomUUID();
537
+ }
538
+ const wa = ae(() => import("./dashboard-controls-BcxWhOKw.js")), xa = ae(
539
+ () => import("./edit-dashboard-visual-COjKc_Du.js")
540
+ ), Ta = ae(() => import("./dashboard-json-C-oBcKKC.js"));
541
+ function Qa({
542
+ showControls: e = !1,
543
+ showFooter: a = !0,
544
+ liveScreen: t,
545
+ ...n
546
+ }) {
547
+ const s = D((h) => h.isVisualEditing), i = D(
548
+ (h) => h.showDashboardJSON
549
+ ), { appearance: l, preferences: o } = n;
550
+ return /* @__PURE__ */ r(ot, { FallbackComponent: dt, children: /* @__PURE__ */ r(ct, { dashboardProps: n, children: /* @__PURE__ */ d(ut, { children: [
551
+ /* @__PURE__ */ r(mt, { componentType: "surfboard", componentId: n.id }),
552
+ /* @__PURE__ */ d(ht, { appearance: l, children: [
553
+ /* @__PURE__ */ r(
554
+ ft,
555
+ {
556
+ toastOptions: {
557
+ classNames: {
558
+ 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]",
559
+ content: "min-w-0 flex-1",
560
+ icon: "mt-0.5 shrink-0",
561
+ title: "max-w-full break-words pr-8",
562
+ description: "max-w-full break-words",
563
+ closeButton: "!top-2 h-6 w-6 rounded-md border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground"
564
+ }
565
+ }
566
+ }
567
+ ),
568
+ /* @__PURE__ */ d(bt, { preferences: o, children: [
569
+ i && /* @__PURE__ */ r(Y, { fallback: null, children: /* @__PURE__ */ r(Ta, {}) }),
570
+ /* @__PURE__ */ r(pt, { children: /* @__PURE__ */ r(ta, { children: /* @__PURE__ */ d("main", { className: "relative flex h-full w-full flex-col overflow-hidden", children: [
571
+ e && /* @__PURE__ */ r(Y, { fallback: null, children: /* @__PURE__ */ r(wa, {}) }),
572
+ t && /* @__PURE__ */ r(ga, { port: t, onLifecycleEvent: n.onDashboardLifecycleEvent }),
573
+ /* @__PURE__ */ d("div", { className: "relative flex grow overflow-hidden", children: [
574
+ /* @__PURE__ */ r("div", { className: "flex min-w-0 flex-1", children: /* @__PURE__ */ d(gt, { ...n, type: "dashboard", children: [
575
+ s && /* @__PURE__ */ r(Y, { fallback: null, children: /* @__PURE__ */ r(xa, {}) }),
576
+ /* @__PURE__ */ r(Ke, { mode: s ? "hidden" : "visible", children: /* @__PURE__ */ r(Xt, {}) })
577
+ ] }) }),
578
+ /* @__PURE__ */ r(da, {})
579
+ ] })
580
+ ] }) }) })
581
+ ] })
582
+ ] })
583
+ ] }) }) });
584
+ }
585
+ function Ca(e = {}) {
586
+ const { authToken: a, tokenProps: t } = be(), n = D(
587
+ (N) => N.actions.applyResolvedCalendarPreferences
588
+ ), s = e.enabled ?? !0, i = (a == null ? void 0 : a.accessToken) ?? null, l = (t == null ? void 0 : t.apiServiceUrl) ?? null, [o, h] = I(!1), [w, x] = I(!1), [u, b] = I(!1), [c, S] = I(null), [m, f] = I(null), y = L(i);
589
+ y.current = i, B(() => {
590
+ f(null), S(null), h(!1), x(!1), b(!1);
591
+ }, [i]);
592
+ const E = P(async (N) => {
593
+ const p = Jt(await N.json());
594
+ if (!p.ok)
595
+ throw new Error("Calendar preferences response is invalid");
596
+ return p.value;
597
+ }, []), A = P(async () => {
598
+ if (!s || !i || !l) return;
599
+ const N = i;
600
+ h(!0), S(null);
601
+ try {
602
+ const p = await fetch(
603
+ `${l}/v1/user-preferences/calendar`,
604
+ {
605
+ method: "GET",
606
+ headers: { Authorization: `Bearer ${i}` }
607
+ }
608
+ );
609
+ if (!p.ok) {
610
+ const C = await p.json().catch(() => ({}));
611
+ throw new Error(C.error || "Failed to fetch preferences");
612
+ }
613
+ const v = await E(p);
614
+ y.current === N && f(v);
615
+ } catch (p) {
616
+ y.current === N && S(p instanceof Error ? p.message : "Unknown error");
617
+ } finally {
618
+ y.current === N && h(!1);
619
+ }
620
+ }, [i, l, s, E]);
621
+ B(() => {
622
+ s && A();
623
+ }, [s, A]);
624
+ const _ = P(
625
+ async (N) => {
626
+ if (!i || !l)
627
+ return S("Not authenticated"), !1;
628
+ const p = i;
629
+ x(!0), S(null);
630
+ try {
631
+ const v = await fetch(
632
+ `${l}/v1/user-preferences/calendar`,
633
+ {
634
+ method: "PATCH",
635
+ headers: {
636
+ "Content-Type": "application/json",
637
+ Authorization: `Bearer ${i}`
638
+ },
639
+ body: JSON.stringify(N)
640
+ }
641
+ );
642
+ if (!v.ok) {
643
+ const g = await v.json().catch(() => ({}));
644
+ throw new Error(g.error || "Failed to update preferences");
645
+ }
646
+ const C = await E(v);
647
+ return y.current !== p ? !1 : (f(C), n(C.resolved, C.sources), !0);
648
+ } catch (v) {
649
+ return y.current === p && S(v instanceof Error ? v.message : "Unknown error"), !1;
650
+ } finally {
651
+ y.current === p && x(!1);
652
+ }
653
+ },
654
+ [
655
+ i,
656
+ l,
657
+ n,
658
+ E
659
+ ]
660
+ ), k = P(async () => {
661
+ if (!i || !l)
662
+ return S("Not authenticated"), !1;
663
+ const N = i;
664
+ b(!0), S(null);
665
+ try {
666
+ const p = await fetch(
667
+ `${l}/v1/user-preferences/calendar`,
668
+ {
669
+ method: "DELETE",
670
+ headers: { Authorization: `Bearer ${i}` }
671
+ }
672
+ );
673
+ if (!p.ok) {
674
+ const C = await p.json().catch(() => ({}));
675
+ throw new Error(C.error || "Failed to clear preferences");
676
+ }
677
+ const v = await E(p);
678
+ return y.current !== N ? !1 : (f(v), n(v.resolved, v.sources), !0);
679
+ } catch (p) {
680
+ return y.current === N && S(p instanceof Error ? p.message : "Unknown error"), !1;
681
+ } finally {
682
+ y.current === N && b(!1);
683
+ }
684
+ }, [
685
+ i,
686
+ l,
687
+ n,
688
+ E
689
+ ]);
690
+ return {
691
+ preferences: m,
692
+ isLoading: o,
693
+ isSaving: w,
694
+ isClearing: u,
695
+ error: c,
696
+ updatePreferences: _,
697
+ clearPreferences: k,
698
+ refetch: A
699
+ };
700
+ }
701
+ const te = [
702
+ { value: "America/New_York", label: "Eastern Time (US & Canada)" },
703
+ { value: "America/Chicago", label: "Central Time (US & Canada)" },
704
+ { value: "America/Denver", label: "Mountain Time (US & Canada)" },
705
+ { value: "America/Los_Angeles", label: "Pacific Time (US & Canada)" },
706
+ { value: "America/Phoenix", label: "Arizona" },
707
+ { value: "America/Anchorage", label: "Alaska" },
708
+ { value: "Pacific/Honolulu", label: "Hawaii" },
709
+ { value: "Europe/London", label: "London" },
710
+ { value: "Europe/Paris", label: "Paris, Berlin, Rome" },
711
+ { value: "Asia/Tokyo", label: "Tokyo" },
712
+ { value: "Asia/Shanghai", label: "Beijing, Shanghai" },
713
+ { value: "Asia/Kolkata", label: "Mumbai, New Delhi" },
714
+ { value: "Australia/Sydney", label: "Sydney" },
715
+ { value: "UTC", label: "UTC" }
716
+ ], je = [
717
+ { value: 0, label: "Sunday" },
718
+ { value: 1, label: "Monday" },
719
+ { value: 6, label: "Saturday" }
720
+ ], Ae = "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";
721
+ function Na() {
722
+ try {
723
+ const e = Intl;
724
+ if (e.supportedValuesOf)
725
+ return e.supportedValuesOf("timeZone");
726
+ } catch {
727
+ }
728
+ return te.map((e) => e.value);
729
+ }
730
+ function Ea(e) {
731
+ if (!e) return "default";
732
+ if (e.tz !== e.weekStart) return "inherited";
733
+ switch (e.tz) {
734
+ case "viewer_tenant":
735
+ return "tenant";
736
+ case "viewer_organization":
737
+ return "organization";
738
+ case "system_default":
739
+ return "system";
740
+ case "session_initial":
741
+ return "embedded";
742
+ default:
743
+ return "default";
744
+ }
745
+ }
746
+ function De(e) {
747
+ const a = te.find((t) => t.value === e);
748
+ return a ? a.label : e;
749
+ }
750
+ function Ia(e) {
751
+ const a = je.find((t) => t.value === e);
752
+ return a ? a.label : String(e);
753
+ }
754
+ function Aa({
755
+ active: e,
756
+ onClose: a
757
+ }) {
758
+ const {
759
+ preferences: t,
760
+ isLoading: n,
761
+ isSaving: s,
762
+ isClearing: i,
763
+ updatePreferences: l,
764
+ clearPreferences: o
765
+ } = Ca({ enabled: e }), h = yt(), w = (t == null ? void 0 : t.resolved.tz) || (h == null ? void 0 : h.tz) || "UTC", x = (t == null ? void 0 : t.resolved.weekStart) ?? (h == null ? void 0 : h.weekStart) ?? 1, [u, b] = I((t == null ? void 0 : t.stored) === null), [c, S] = I(!1), [m, f] = I(
766
+ w
767
+ ), [y, E] = I(
768
+ x
769
+ ), [A, _] = I(!1), k = j(() => Na(), []), N = j(
770
+ () => k.filter(
771
+ (T) => !te.some(($e) => $e.value === T)
772
+ ),
773
+ [k]
774
+ ), p = j(() => De(m), [m]), v = t != null && t.inherited ? De(t.inherited.tz) : "UTC", C = t != null && t.inherited ? Ia(t.inherited.weekStart) : "Monday", g = Ea(
775
+ t == null ? void 0 : t.inheritedSources
776
+ );
777
+ He.useEffect(() => {
778
+ if (!e) {
779
+ S(!1);
780
+ return;
781
+ }
782
+ c || (t && b(t.stored === null), f(w), E(x));
783
+ }, [
784
+ e,
785
+ c,
786
+ t,
787
+ w,
788
+ x
789
+ ]);
790
+ const V = async () => {
791
+ if (n) {
792
+ F.error("Preferences are still loading. Please try again.");
793
+ return;
794
+ }
795
+ u ? await o() ? (F.success("Now using default settings."), a()) : F.error("Failed to save preferences. Please try again.") : await l({
796
+ tz: m,
797
+ weekStart: y
798
+ }) ? (F.success("Preferences saved."), a()) : F.error("Failed to save preferences. Please try again.");
799
+ }, R = () => {
800
+ a();
801
+ }, re = s || i, We = re || n;
802
+ return /* @__PURE__ */ d(M, { children: [
803
+ /* @__PURE__ */ d("div", { className: "space-y-4 py-1", children: [
804
+ /* @__PURE__ */ d(
805
+ ve,
806
+ {
807
+ value: u ? "defaults" : "custom",
808
+ onValueChange: (T) => {
809
+ S(!0), b(T === "defaults");
810
+ },
811
+ className: "space-y-0.5",
812
+ children: [
813
+ /* @__PURE__ */ d(
814
+ "label",
815
+ {
816
+ htmlFor: "mode-defaults",
817
+ className: U(
818
+ "flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",
819
+ u && "bg-muted/50"
820
+ ),
821
+ onClick: () => {
822
+ S(!0), b(!0);
823
+ },
824
+ children: [
825
+ /* @__PURE__ */ r(
826
+ ne,
827
+ {
828
+ value: "defaults",
829
+ id: "mode-defaults",
830
+ className: "mt-0.5"
831
+ }
832
+ ),
833
+ /* @__PURE__ */ d("div", { className: "flex-1 min-w-0", children: [
834
+ /* @__PURE__ */ d("p", { className: "text-[13px] font-medium text-foreground", children: [
835
+ "Use ",
836
+ g,
837
+ " defaults"
838
+ ] }),
839
+ /* @__PURE__ */ d("p", { className: "text-[12px] text-muted-foreground", children: [
840
+ v,
841
+ ", week starts ",
842
+ C
843
+ ] })
844
+ ] })
845
+ ]
846
+ }
847
+ ),
848
+ /* @__PURE__ */ d(
849
+ "label",
850
+ {
851
+ htmlFor: "mode-custom",
852
+ className: U(
853
+ "flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",
854
+ !u && "bg-muted/50"
855
+ ),
856
+ onClick: () => {
857
+ S(!0), b(!1);
858
+ },
859
+ children: [
860
+ /* @__PURE__ */ r(
861
+ ne,
862
+ {
863
+ value: "custom",
864
+ id: "mode-custom",
865
+ className: "mt-0.5"
866
+ }
867
+ ),
868
+ /* @__PURE__ */ r("p", { className: "flex-1 text-[13px] font-medium text-foreground", children: "Use custom settings" })
869
+ ]
870
+ }
871
+ )
872
+ ]
873
+ }
874
+ ),
875
+ /* @__PURE__ */ d(
876
+ "div",
877
+ {
878
+ className: U(
879
+ "space-y-4 border-t border-border/60 pt-4 transition-opacity",
880
+ u && "pointer-events-none opacity-50"
881
+ ),
882
+ children: [
883
+ /* @__PURE__ */ d("div", { className: "space-y-1.5", children: [
884
+ /* @__PURE__ */ r(G, { className: Ae, children: "Timezone" }),
885
+ /* @__PURE__ */ d(
886
+ jt,
887
+ {
888
+ open: A,
889
+ onOpenChange: _,
890
+ modal: !0,
891
+ children: [
892
+ /* @__PURE__ */ r(Mt, { asChild: !0, children: /* @__PURE__ */ d(
893
+ z,
894
+ {
895
+ variant: "outline",
896
+ size: "xs",
897
+ role: "combobox",
898
+ "aria-expanded": A,
899
+ className: "w-full justify-between text-[12px] font-normal",
900
+ disabled: u,
901
+ children: [
902
+ /* @__PURE__ */ r("span", { className: "truncate", children: p }),
903
+ /* @__PURE__ */ r(vt, { className: "ml-2 h-3.5 w-3.5 shrink-0 opacity-50" })
904
+ ]
905
+ }
906
+ ) }),
907
+ /* @__PURE__ */ r(
908
+ Vt,
909
+ {
910
+ className: "z-50 w-[--radix-popover-trigger-width] p-0",
911
+ align: "start",
912
+ children: /* @__PURE__ */ d(St, { className: "overflow-visible", children: [
913
+ /* @__PURE__ */ r(wt, { placeholder: "Search timezones…" }),
914
+ /* @__PURE__ */ d(xt, { children: [
915
+ /* @__PURE__ */ r(Tt, { children: "No timezone found." }),
916
+ /* @__PURE__ */ r(Se, { heading: "Common", children: te.map((T) => /* @__PURE__ */ d(
917
+ we,
918
+ {
919
+ value: `${T.value} ${T.label}`,
920
+ onSelect: () => {
921
+ S(!0), f(T.value), _(!1);
922
+ },
923
+ children: [
924
+ /* @__PURE__ */ r(
925
+ xe,
926
+ {
927
+ className: U(
928
+ "h-3.5 w-3.5",
929
+ m === T.value ? "opacity-100" : "opacity-0"
930
+ )
931
+ }
932
+ ),
933
+ /* @__PURE__ */ r("span", { className: "flex-1", children: T.label }),
934
+ /* @__PURE__ */ r("span", { className: "text-[11px] text-muted-foreground", children: T.value })
935
+ ]
936
+ },
937
+ T.value
938
+ )) }),
939
+ /* @__PURE__ */ r(Ct, {}),
940
+ /* @__PURE__ */ r(Se, { heading: "All timezones", children: N.map((T) => /* @__PURE__ */ d(
941
+ we,
942
+ {
943
+ value: T,
944
+ onSelect: () => {
945
+ S(!0), f(T), _(!1);
946
+ },
947
+ children: [
948
+ /* @__PURE__ */ r(
949
+ xe,
950
+ {
951
+ className: U(
952
+ "h-3.5 w-3.5",
953
+ m === T ? "opacity-100" : "opacity-0"
954
+ )
955
+ }
956
+ ),
957
+ T
958
+ ]
959
+ },
960
+ T
961
+ )) })
962
+ ] })
963
+ ] })
964
+ }
965
+ )
966
+ ]
967
+ }
968
+ )
969
+ ] }),
970
+ /* @__PURE__ */ d("div", { className: "space-y-1.5", children: [
971
+ /* @__PURE__ */ r(G, { className: Ae, children: "Week starts on" }),
972
+ /* @__PURE__ */ r(
973
+ ve,
974
+ {
975
+ value: String(y),
976
+ onValueChange: (T) => {
977
+ S(!0), E(Number(T));
978
+ },
979
+ className: "flex gap-4",
980
+ disabled: u,
981
+ children: je.map((T) => /* @__PURE__ */ d(
982
+ "label",
983
+ {
984
+ htmlFor: `week-start-${T.value}`,
985
+ className: U(
986
+ "flex cursor-pointer items-center gap-2 text-[13px]",
987
+ u && "cursor-not-allowed"
988
+ ),
989
+ children: [
990
+ /* @__PURE__ */ r(
991
+ ne,
992
+ {
993
+ value: String(T.value),
994
+ id: `week-start-${T.value}`,
995
+ disabled: u
996
+ }
997
+ ),
998
+ T.label
999
+ ]
1000
+ },
1001
+ T.value
1002
+ ))
1003
+ }
1004
+ )
1005
+ ] })
1006
+ ]
1007
+ }
1008
+ )
1009
+ ] }),
1010
+ /* @__PURE__ */ d(pe, { children: [
1011
+ /* @__PURE__ */ r(
1012
+ z,
1013
+ {
1014
+ variant: "outline",
1015
+ size: "xs",
1016
+ onClick: R,
1017
+ disabled: re,
1018
+ children: "Cancel"
1019
+ }
1020
+ ),
1021
+ /* @__PURE__ */ r(z, { size: "xs", onClick: V, disabled: We, children: re ? /* @__PURE__ */ d(M, { children: [
1022
+ /* @__PURE__ */ r(Ue, { className: "h-3.5 w-3.5 animate-spin" }),
1023
+ "Saving…"
1024
+ ] }) : "Save" })
1025
+ ] })
1026
+ ] });
1027
+ }
1028
+ function Da(e = {}) {
1029
+ const { authToken: a, tokenProps: t } = be(), n = D(
1030
+ (p) => p.actions.applyResolvedValueFormatPreferences
1031
+ ), s = e.enabled ?? !0, i = (a == null ? void 0 : a.accessToken) ?? null, l = (t == null ? void 0 : t.apiServiceUrl) ?? null, o = L(i);
1032
+ o.current = i;
1033
+ const [h, w] = I(null), [x, u] = I(!1), [b, c] = I(!1), [S, m] = I(!1), [f, y] = I(null);
1034
+ B(() => {
1035
+ w(null), y(null), u(!1), c(!1), m(!1);
1036
+ }, [i]);
1037
+ const E = P(async (p) => {
1038
+ const v = Ht(await p.json());
1039
+ if (!v.ok)
1040
+ throw new Error("Value format preferences response is invalid");
1041
+ return v.value;
1042
+ }, []), A = P(
1043
+ async (p, v) => {
1044
+ if (!i || !l)
1045
+ throw new Error("Not authenticated");
1046
+ const C = await fetch(
1047
+ `${l}/v1/user-preferences/value-format`,
1048
+ {
1049
+ method: p,
1050
+ headers: {
1051
+ Authorization: `Bearer ${i}`,
1052
+ ...v ? { "Content-Type": "application/json" } : {}
1053
+ },
1054
+ body: v ? JSON.stringify(v) : void 0
1055
+ }
1056
+ );
1057
+ if (!C.ok) {
1058
+ const g = await C.json().catch(() => ({}));
1059
+ throw new Error(g.error || "Failed to update preferences");
1060
+ }
1061
+ return E(C);
1062
+ },
1063
+ [i, l, E]
1064
+ ), _ = P(async () => {
1065
+ if (!s || !i || !l) return;
1066
+ const p = i;
1067
+ u(!0), y(null);
1068
+ try {
1069
+ const v = await A("GET");
1070
+ o.current === p && w(v);
1071
+ } catch (v) {
1072
+ o.current === p && y(v instanceof Error ? v.message : "Unknown error");
1073
+ } finally {
1074
+ o.current === p && u(!1);
1075
+ }
1076
+ }, [i, l, s, A]);
1077
+ B(() => {
1078
+ s && _();
1079
+ }, [s, _]);
1080
+ const k = P(
1081
+ async (p) => {
1082
+ const v = i;
1083
+ c(!0), y(null);
1084
+ try {
1085
+ const C = await A("PATCH", p);
1086
+ return o.current !== v ? !1 : (w(C), n(C.resolved, C.sources), !0);
1087
+ } catch (C) {
1088
+ return o.current === v && y(C instanceof Error ? C.message : "Unknown error"), !1;
1089
+ } finally {
1090
+ o.current === v && c(!1);
1091
+ }
1092
+ },
1093
+ [i, n, A]
1094
+ ), N = P(async () => {
1095
+ const p = i;
1096
+ m(!0), y(null);
1097
+ try {
1098
+ const v = await A("DELETE");
1099
+ return o.current !== p ? !1 : (w(v), n(v.resolved, v.sources), !0);
1100
+ } catch (v) {
1101
+ return o.current === p && y(v instanceof Error ? v.message : "Unknown error"), !1;
1102
+ } finally {
1103
+ o.current === p && m(!1);
1104
+ }
1105
+ }, [i, n, A]);
1106
+ return {
1107
+ preferences: h,
1108
+ isLoading: x,
1109
+ isSaving: b,
1110
+ isClearing: S,
1111
+ error: f,
1112
+ updatePreferences: k,
1113
+ clearPreferences: N,
1114
+ refetch: _
1115
+ };
1116
+ }
1117
+ const he = [
1118
+ { value: "en-US", label: "English (United States)" },
1119
+ { value: "en-GB", label: "English (United Kingdom)" },
1120
+ { value: "de-DE", label: "German (Germany)" },
1121
+ { value: "fr-FR", label: "French (France)" },
1122
+ { value: "es-ES", label: "Spanish (Spain)" },
1123
+ { value: "it-IT", label: "Italian (Italy)" },
1124
+ { value: "nl-NL", label: "Dutch (Netherlands)" },
1125
+ { value: "pt-BR", label: "Portuguese (Brazil)" },
1126
+ { value: "ja-JP", label: "Japanese (Japan)" },
1127
+ { value: "en-IN", label: "English (India)" },
1128
+ { value: "en-AU", label: "English (Australia)" },
1129
+ { value: "en-NZ", label: "English (New Zealand)" },
1130
+ { value: "mi-NZ", label: "Māori (New Zealand)" }
1131
+ ], Me = /* @__PURE__ */ new Set([
1132
+ "USD",
1133
+ "EUR",
1134
+ "GBP",
1135
+ "CAD",
1136
+ "AUD",
1137
+ "JPY",
1138
+ "CHF",
1139
+ "INR",
1140
+ "BRL",
1141
+ "KWD"
1142
+ ]), ka = Kt(), _a = ka.filter(
1143
+ (e) => !Me.has(e)
1144
+ ), Ve = [
1145
+ { value: "short", label: "Short" },
1146
+ { value: "medium", label: "Medium" },
1147
+ { value: "long", label: "Long" }
1148
+ ], ke = "2026-07-31", se = "2026-07-31T14:30:45";
1149
+ function fe(e) {
1150
+ switch (e) {
1151
+ case "viewer_user":
1152
+ return "user";
1153
+ case "viewer_tenant_user":
1154
+ return "tenant user";
1155
+ case "viewer_tenant":
1156
+ return "tenant";
1157
+ case "viewer_organization":
1158
+ return "organization";
1159
+ case "session_initial":
1160
+ return "embedded session";
1161
+ case "system_default":
1162
+ return "system";
1163
+ default:
1164
+ return "another preference level";
1165
+ }
1166
+ }
1167
+ function le(e) {
1168
+ var a;
1169
+ return ((a = Ve.find((t) => t.value === e)) == null ? void 0 : a.label) ?? e;
1170
+ }
1171
+ function Pa(e) {
1172
+ const a = he.find((t) => t.value === e);
1173
+ return a ? `${a.label} — ${a.value}` : e;
1174
+ }
1175
+ function ie(e) {
1176
+ return {
1177
+ short: e("short"),
1178
+ medium: e("medium"),
1179
+ long: e("long")
1180
+ };
1181
+ }
1182
+ function oe({
1183
+ id: e,
1184
+ label: a,
1185
+ value: t,
1186
+ inherited: n,
1187
+ inheritedSource: s,
1188
+ examples: i,
1189
+ disabled: l,
1190
+ onValueChange: o
1191
+ }) {
1192
+ const h = t === void 0 ? `Inherited · ${le(n)}` : le(t);
1193
+ return /* @__PURE__ */ d("div", { className: "space-y-1.5", children: [
1194
+ /* @__PURE__ */ r(G, { htmlFor: e, className: "text-[11px] text-muted-foreground", children: a }),
1195
+ /* @__PURE__ */ d(
1196
+ de,
1197
+ {
1198
+ value: t ?? "inherit",
1199
+ disabled: l,
1200
+ onValueChange: o,
1201
+ children: [
1202
+ /* @__PURE__ */ r(ce, { id: e, size: "xs", children: /* @__PURE__ */ r(ue, { children: h }) }),
1203
+ /* @__PURE__ */ d(me, { children: [
1204
+ /* @__PURE__ */ r(O, { value: "inherit", className: "[&>span:last-child]:w-full", children: /* @__PURE__ */ d("span", { className: "flex w-full min-w-0 items-center justify-between gap-4", children: [
1205
+ /* @__PURE__ */ d("span", { children: [
1206
+ "Inherited from ",
1207
+ fe(s),
1208
+ " ·",
1209
+ " ",
1210
+ le(n)
1211
+ ] }),
1212
+ /* @__PURE__ */ r("span", { className: "shrink-0 tabular-nums text-muted-foreground", children: i[n] })
1213
+ ] }) }),
1214
+ Ve.map((w) => /* @__PURE__ */ r(
1215
+ O,
1216
+ {
1217
+ value: w.value,
1218
+ className: "[&>span:last-child]:w-full",
1219
+ children: /* @__PURE__ */ d("span", { className: "flex w-full min-w-0 items-center justify-between gap-4", children: [
1220
+ /* @__PURE__ */ r("span", { children: w.label }),
1221
+ /* @__PURE__ */ r("span", { className: "shrink-0 tabular-nums text-muted-foreground", children: i[w.value] })
1222
+ ] })
1223
+ },
1224
+ w.value
1225
+ ))
1226
+ ] })
1227
+ ]
1228
+ }
1229
+ )
1230
+ ] });
1231
+ }
1232
+ function za({
1233
+ value: e,
1234
+ inherited: a,
1235
+ inheritedSources: t,
1236
+ onChange: n,
1237
+ disabled: s
1238
+ }) {
1239
+ var N, p, v, C;
1240
+ const i = $(), l = $(), o = $(), h = $(), w = $(), u = (e.locale === void 0 ? void 0 : Fe(e.locale)) ?? a.locale, b = e.defaultCurrency ?? a.defaultCurrency, c = {
1241
+ locale: u,
1242
+ dateStyle: e.dateStyle ?? a.dateStyle,
1243
+ dateTime: {
1244
+ dateStyle: ((N = e.dateTime) == null ? void 0 : N.dateStyle) ?? a.dateTime.dateStyle,
1245
+ timeStyle: ((p = e.dateTime) == null ? void 0 : p.timeStyle) ?? a.dateTime.timeStyle
1246
+ },
1247
+ defaultCurrency: b
1248
+ }, S = new Intl.NumberFormat(u, {
1249
+ style: "currency",
1250
+ currency: b
1251
+ }).format(1e3), m = Z({
1252
+ preferences: c,
1253
+ calendar: { tz: "UTC" }
1254
+ }), f = H({
1255
+ value: ke,
1256
+ metadata: { kind: "raw_temporal", valueKind: "date" },
1257
+ format: m
1258
+ }).text, y = H({
1259
+ value: se,
1260
+ metadata: { kind: "raw_temporal", valueKind: "wall_datetime" },
1261
+ format: m
1262
+ }).text, E = ie(
1263
+ (g) => H({
1264
+ value: ke,
1265
+ metadata: { kind: "raw_temporal", valueKind: "date" },
1266
+ format: Z({
1267
+ preferences: { ...c, dateStyle: g },
1268
+ calendar: { tz: "UTC" }
1269
+ })
1270
+ }).text
1271
+ ), A = ie(
1272
+ (g) => H({
1273
+ value: se,
1274
+ metadata: { kind: "raw_temporal", valueKind: "wall_datetime" },
1275
+ format: Z({
1276
+ preferences: {
1277
+ ...c,
1278
+ dateTime: { ...c.dateTime, dateStyle: g }
1279
+ },
1280
+ calendar: { tz: "UTC" }
1281
+ })
1282
+ }).text
1283
+ ), _ = ie(
1284
+ (g) => H({
1285
+ value: se,
1286
+ metadata: { kind: "raw_temporal", valueKind: "wall_datetime" },
1287
+ format: Z({
1288
+ preferences: {
1289
+ ...c,
1290
+ dateTime: { ...c.dateTime, timeStyle: g }
1291
+ },
1292
+ calendar: { tz: "UTC" }
1293
+ })
1294
+ }).text
1295
+ ), k = (g, V) => {
1296
+ const R = {
1297
+ ...e.dateTime,
1298
+ [g]: V === "inherit" ? void 0 : V
1299
+ };
1300
+ n({
1301
+ ...e,
1302
+ dateTime: R.dateStyle === void 0 && R.timeStyle === void 0 ? void 0 : R
1303
+ });
1304
+ };
1305
+ return /* @__PURE__ */ d("div", { className: "space-y-4", children: [
1306
+ /* @__PURE__ */ d("div", { className: "space-y-1.5", children: [
1307
+ /* @__PURE__ */ r(
1308
+ G,
1309
+ {
1310
+ htmlFor: i,
1311
+ className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",
1312
+ children: "Locale"
1313
+ }
1314
+ ),
1315
+ /* @__PURE__ */ d(
1316
+ de,
1317
+ {
1318
+ value: e.locale ?? "inherit",
1319
+ disabled: s,
1320
+ onValueChange: (g) => n({
1321
+ ...e,
1322
+ locale: g === "inherit" ? void 0 : g
1323
+ }),
1324
+ children: [
1325
+ /* @__PURE__ */ r(ce, { id: i, size: "xs", children: /* @__PURE__ */ r(ue, { children: e.locale === void 0 ? `Inherited · ${a.locale}` : Pa(e.locale) }) }),
1326
+ /* @__PURE__ */ d(me, { children: [
1327
+ /* @__PURE__ */ d(O, { value: "inherit", children: [
1328
+ "Inherited from ",
1329
+ fe(t.locale),
1330
+ " ·",
1331
+ " ",
1332
+ a.locale
1333
+ ] }),
1334
+ e.locale && !he.some(
1335
+ (g) => g.value === e.locale
1336
+ ) && /* @__PURE__ */ r(O, { value: e.locale, children: e.locale }),
1337
+ he.map((g) => /* @__PURE__ */ d(O, { value: g.value, children: [
1338
+ g.label,
1339
+ " — ",
1340
+ g.value
1341
+ ] }, g.value))
1342
+ ] })
1343
+ ]
1344
+ }
1345
+ )
1346
+ ] }),
1347
+ /* @__PURE__ */ d("fieldset", { className: "space-y-2", children: [
1348
+ /* @__PURE__ */ r("legend", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Date values" }),
1349
+ /* @__PURE__ */ r(
1350
+ oe,
1351
+ {
1352
+ id: o,
1353
+ label: "Format",
1354
+ value: e.dateStyle,
1355
+ inherited: a.dateStyle,
1356
+ inheritedSource: t.dateStyle,
1357
+ examples: E,
1358
+ disabled: s,
1359
+ onValueChange: (g) => n({
1360
+ ...e,
1361
+ dateStyle: g === "inherit" ? void 0 : g
1362
+ })
1363
+ }
1364
+ )
1365
+ ] }),
1366
+ /* @__PURE__ */ d("fieldset", { className: "space-y-2", children: [
1367
+ /* @__PURE__ */ r("legend", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Date & time values" }),
1368
+ /* @__PURE__ */ r(
1369
+ oe,
1370
+ {
1371
+ id: h,
1372
+ label: "Date",
1373
+ value: (v = e.dateTime) == null ? void 0 : v.dateStyle,
1374
+ inherited: a.dateTime.dateStyle,
1375
+ inheritedSource: t.dateTime.dateStyle,
1376
+ examples: A,
1377
+ disabled: s,
1378
+ onValueChange: (g) => k("dateStyle", g)
1379
+ }
1380
+ ),
1381
+ /* @__PURE__ */ r(
1382
+ oe,
1383
+ {
1384
+ id: w,
1385
+ label: "Time",
1386
+ value: (C = e.dateTime) == null ? void 0 : C.timeStyle,
1387
+ inherited: a.dateTime.timeStyle,
1388
+ inheritedSource: t.dateTime.timeStyle,
1389
+ examples: _,
1390
+ disabled: s,
1391
+ onValueChange: (g) => k("timeStyle", g)
1392
+ }
1393
+ )
1394
+ ] }),
1395
+ /* @__PURE__ */ d("div", { className: "space-y-1.5", children: [
1396
+ /* @__PURE__ */ r(
1397
+ G,
1398
+ {
1399
+ htmlFor: l,
1400
+ className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",
1401
+ children: "Default currency"
1402
+ }
1403
+ ),
1404
+ /* @__PURE__ */ d(
1405
+ de,
1406
+ {
1407
+ value: e.defaultCurrency ?? "inherit",
1408
+ disabled: s,
1409
+ onValueChange: (g) => n({
1410
+ ...e,
1411
+ defaultCurrency: g === "inherit" ? void 0 : g
1412
+ }),
1413
+ children: [
1414
+ /* @__PURE__ */ r(ce, { id: l, size: "xs", children: /* @__PURE__ */ r(ue, { children: e.defaultCurrency === void 0 ? `Inherited · ${a.defaultCurrency}` : e.defaultCurrency }) }),
1415
+ /* @__PURE__ */ d(me, { children: [
1416
+ /* @__PURE__ */ d(O, { value: "inherit", children: [
1417
+ "Inherited from ",
1418
+ fe(t.defaultCurrency),
1419
+ " ·",
1420
+ " ",
1421
+ a.defaultCurrency
1422
+ ] }),
1423
+ [...Me].map((g) => /* @__PURE__ */ r(O, { value: g, children: g }, g)),
1424
+ _a.map((g) => /* @__PURE__ */ r(O, { value: g, children: g }, g))
1425
+ ] })
1426
+ ]
1427
+ }
1428
+ )
1429
+ ] }),
1430
+ /* @__PURE__ */ d("div", { className: "rounded-control border border-border/60 bg-muted/30 px-3 py-2", children: [
1431
+ /* @__PURE__ */ r("p", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Preview" }),
1432
+ /* @__PURE__ */ d("dl", { className: "mt-1.5 space-y-1 text-[12px]", children: [
1433
+ /* @__PURE__ */ d("div", { className: "flex items-baseline justify-between gap-4", children: [
1434
+ /* @__PURE__ */ r("dt", { className: "text-muted-foreground", children: "Date" }),
1435
+ /* @__PURE__ */ r("dd", { className: "text-right font-medium text-foreground", children: f })
1436
+ ] }),
1437
+ /* @__PURE__ */ d("div", { className: "flex items-baseline justify-between gap-4", children: [
1438
+ /* @__PURE__ */ r("dt", { className: "text-muted-foreground", children: "Date & time" }),
1439
+ /* @__PURE__ */ r("dd", { className: "text-right font-medium text-foreground", children: y })
1440
+ ] }),
1441
+ /* @__PURE__ */ d("div", { className: "flex items-baseline justify-between gap-4", children: [
1442
+ /* @__PURE__ */ r("dt", { className: "text-muted-foreground", children: "Currency" }),
1443
+ /* @__PURE__ */ r("dd", { className: "text-right font-medium text-foreground", children: S })
1444
+ ] })
1445
+ ] })
1446
+ ] }),
1447
+ /* @__PURE__ */ r("p", { className: "text-[11px] text-muted-foreground", children: "Currency values are not converted. Date examples use a fixed reference value and the Gregorian calendar." })
1448
+ ] });
1449
+ }
1450
+ const _e = [
1451
+ "locale",
1452
+ "dateStyle",
1453
+ "dateTime.dateStyle",
1454
+ "dateTime.timeStyle",
1455
+ "defaultCurrency"
1456
+ ];
1457
+ function Pe(e, a) {
1458
+ var t, n;
1459
+ switch (a) {
1460
+ case "locale":
1461
+ return e == null ? void 0 : e.locale;
1462
+ case "dateStyle":
1463
+ return e == null ? void 0 : e.dateStyle;
1464
+ case "dateTime.dateStyle":
1465
+ return (t = e == null ? void 0 : e.dateTime) == null ? void 0 : t.dateStyle;
1466
+ case "dateTime.timeStyle":
1467
+ return (n = e == null ? void 0 : e.dateTime) == null ? void 0 : n.timeStyle;
1468
+ case "defaultCurrency":
1469
+ return e == null ? void 0 : e.defaultCurrency;
1470
+ }
1471
+ }
1472
+ function La(e) {
1473
+ var n, s;
1474
+ const a = (n = e == null ? void 0 : e.dateTime) == null ? void 0 : n.dateStyle, t = (s = e == null ? void 0 : e.dateTime) == null ? void 0 : s.timeStyle;
1475
+ return {
1476
+ locale: e == null ? void 0 : e.locale,
1477
+ dateStyle: e == null ? void 0 : e.dateStyle,
1478
+ dateTime: a === void 0 && t === void 0 ? void 0 : { dateStyle: a, timeStyle: t },
1479
+ defaultCurrency: e == null ? void 0 : e.defaultCurrency
1480
+ };
1481
+ }
1482
+ function Ra({
1483
+ active: e,
1484
+ onClose: a
1485
+ }) {
1486
+ var o, h, w, x, u, b, c;
1487
+ const { preferences: t, isLoading: n, isSaving: s, updatePreferences: i } = Da({ enabled: e });
1488
+ if (!e) return null;
1489
+ if (!t)
1490
+ return /* @__PURE__ */ d(M, { children: [
1491
+ /* @__PURE__ */ r("div", { className: "py-2", children: /* @__PURE__ */ r("div", { className: "flex min-h-36 items-center justify-center text-[12px] text-muted-foreground", children: n ? "Loading preferences…" : "Preferences unavailable." }) }),
1492
+ /* @__PURE__ */ d(pe, { className: "justify-between sm:justify-between", children: [
1493
+ /* @__PURE__ */ r(z, { variant: "ghost", size: "xs", disabled: !0, children: "Reset display formats" }),
1494
+ /* @__PURE__ */ d("div", { className: "flex gap-2", children: [
1495
+ /* @__PURE__ */ r(z, { variant: "outline", size: "xs", onClick: a, children: "Cancel" }),
1496
+ /* @__PURE__ */ r(z, { size: "xs", disabled: !0, children: "Save" })
1497
+ ] })
1498
+ ] })
1499
+ ] });
1500
+ const l = [
1501
+ ((o = t.stored) == null ? void 0 : o.locale) ?? "",
1502
+ ((h = t.stored) == null ? void 0 : h.dateStyle) ?? "",
1503
+ ((x = (w = t.stored) == null ? void 0 : w.dateTime) == null ? void 0 : x.dateStyle) ?? "",
1504
+ ((b = (u = t.stored) == null ? void 0 : u.dateTime) == null ? void 0 : b.timeStyle) ?? "",
1505
+ ((c = t.stored) == null ? void 0 : c.defaultCurrency) ?? ""
1506
+ ].join(":");
1507
+ return /* @__PURE__ */ r(
1508
+ Ua,
1509
+ {
1510
+ preferences: t,
1511
+ isSaving: s,
1512
+ updatePreferences: i,
1513
+ onClose: a
1514
+ },
1515
+ l
1516
+ );
1517
+ }
1518
+ function Ua({
1519
+ preferences: e,
1520
+ isSaving: a,
1521
+ updatePreferences: t,
1522
+ onClose: n
1523
+ }) {
1524
+ var w, x;
1525
+ const [s, i] = I(
1526
+ () => La(e.stored)
1527
+ ), l = (s.locale === void 0 || Fe(s.locale) !== void 0) && (s.defaultCurrency === void 0 || qt(s.defaultCurrency) !== void 0) && (s.dateStyle === void 0 || ["short", "medium", "long"].includes(s.dateStyle)) && (((w = s.dateTime) == null ? void 0 : w.dateStyle) === void 0 || ["short", "medium", "long"].includes(s.dateTime.dateStyle)) && (((x = s.dateTime) == null ? void 0 : x.timeStyle) === void 0 || ["short", "medium", "long"].includes(s.dateTime.timeStyle)), o = async () => {
1528
+ const u = {
1529
+ ...s.locale !== void 0 ? { locale: s.locale } : {},
1530
+ ...s.dateStyle !== void 0 ? { dateStyle: s.dateStyle } : {},
1531
+ ...s.dateTime ? { dateTime: { ...s.dateTime } } : {},
1532
+ ...s.defaultCurrency !== void 0 ? { defaultCurrency: s.defaultCurrency } : {}
1533
+ }, b = _e.filter(
1534
+ (m) => Pe(s, m) === void 0 && Pe(e.stored, m) !== void 0
1535
+ ), c = {
1536
+ ...Object.keys(u).length > 0 ? { set: u } : {},
1537
+ ...b.length > 0 ? { clear: b } : {}
1538
+ };
1539
+ (Object.keys(c).length === 0 ? !0 : await t(c)) ? (F.success("Display format preferences saved."), n()) : F.error("Failed to save preferences. Please try again.");
1540
+ }, h = async () => {
1541
+ await t({
1542
+ clear: [..._e]
1543
+ }) ? (F.success("Display format preferences reset."), n()) : F.error(
1544
+ "Failed to reset display format preferences. Please try again."
1545
+ );
1546
+ };
1547
+ return /* @__PURE__ */ d(M, { children: [
1548
+ /* @__PURE__ */ r("div", { className: "py-2", children: /* @__PURE__ */ r(
1549
+ za,
1550
+ {
1551
+ value: s,
1552
+ inherited: e.inherited,
1553
+ inheritedSources: e.inheritedSources,
1554
+ onChange: i,
1555
+ disabled: a
1556
+ }
1557
+ ) }),
1558
+ /* @__PURE__ */ d(pe, { className: "justify-between sm:justify-between", children: [
1559
+ /* @__PURE__ */ r(
1560
+ z,
1561
+ {
1562
+ variant: "ghost",
1563
+ size: "xs",
1564
+ onClick: h,
1565
+ disabled: a || e.stored === null,
1566
+ children: "Reset display formats"
1567
+ }
1568
+ ),
1569
+ /* @__PURE__ */ d("div", { className: "flex gap-2", children: [
1570
+ /* @__PURE__ */ r(
1571
+ z,
1572
+ {
1573
+ variant: "outline",
1574
+ size: "xs",
1575
+ onClick: n,
1576
+ disabled: a,
1577
+ children: "Cancel"
1578
+ }
1579
+ ),
1580
+ /* @__PURE__ */ r(
1581
+ z,
1582
+ {
1583
+ size: "xs",
1584
+ onClick: o,
1585
+ disabled: a || !l,
1586
+ children: a ? /* @__PURE__ */ d(M, { children: [
1587
+ /* @__PURE__ */ r(Ue, { className: "h-3.5 w-3.5 animate-spin" }),
1588
+ "Saving…"
1589
+ ] }) : "Save"
1590
+ }
1591
+ )
1592
+ ] })
1593
+ ] })
1594
+ ] });
1595
+ }
1596
+ function er({
1597
+ open: e,
1598
+ onOpenChange: a
1599
+ }) {
1600
+ const [t, n] = I("display"), s = () => a(!1);
1601
+ return /* @__PURE__ */ r(Nt, { open: e, onOpenChange: a, children: /* @__PURE__ */ d(Et, { className: "rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control", children: [
1602
+ /* @__PURE__ */ d(It, { children: [
1603
+ /* @__PURE__ */ r(At, { className: "text-[15px]", children: "Report preferences" }),
1604
+ /* @__PURE__ */ r(Dt, { className: "text-[13px] leading-5", children: "Set how values and Calendar periods appear for you." })
1605
+ ] }),
1606
+ /* @__PURE__ */ d(Wt, { value: t, onValueChange: n, children: [
1607
+ /* @__PURE__ */ d($t, { variant: "underline", className: "w-full justify-start", children: [
1608
+ /* @__PURE__ */ r(Te, { value: "display", children: "Display formats" }),
1609
+ /* @__PURE__ */ r(Te, { value: "calendar", children: "Calendar" })
1610
+ ] }),
1611
+ /* @__PURE__ */ r(Ce, { value: "display", children: /* @__PURE__ */ r(
1612
+ Ra,
1613
+ {
1614
+ active: e && t === "display",
1615
+ onClose: s
1616
+ }
1617
+ ) }),
1618
+ /* @__PURE__ */ r(Ce, { value: "calendar", children: /* @__PURE__ */ r(
1619
+ Aa,
1620
+ {
1621
+ active: e && t === "calendar",
1622
+ onClose: s
1623
+ }
1624
+ ) })
1625
+ ] })
1626
+ ] }) });
1627
+ }
1628
+ export {
1629
+ ea as A,
1630
+ Qa as D,
1631
+ er as R,
1632
+ za as a,
1633
+ da as b,
1634
+ Ya as c,
1635
+ ba as d,
1636
+ pa as u
1637
+ };