react-semaphor 0.1.524 → 0.1.526

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 (82) hide show
  1. package/dist/brand-studio/index.js +37 -37
  2. package/dist/briefings/index.js +38 -33
  3. package/dist/chunks/{calculated-field-identity-Dy_WpDdo.js → calculated-field-identity-D1ofR4KJ.js} +28 -28
  4. package/dist/chunks/{card-config-utils-CAyjC5Tp.js → card-config-utils-9sv4e-Vb.js} +15 -15
  5. package/dist/chunks/{switch-CWPcwAZ4.js → code-highlight-994tgM9v.js} +6309 -8642
  6. package/dist/chunks/dashboard-CsHvEtjN.js +15 -0
  7. package/dist/chunks/{dashboard-briefing-launcher-CTEyh3FQ.js → dashboard-briefing-launcher-DXz1GhFZ.js} +364 -370
  8. package/dist/chunks/{dashboard-controls-C3KbYzz-.js → dashboard-controls-Df8qOSrs.js} +163 -168
  9. package/dist/chunks/dashboard-json-Xldp0qww.js +65 -0
  10. package/dist/chunks/{edit-dashboard-visual-DqRmfRqN.js → edit-dashboard-visual-COHBqyic.js} +2836 -2829
  11. package/dist/chunks/editor-action-buttons-DahlP57T.js +2071 -0
  12. package/dist/chunks/{index-D9HDUSye.js → index-CbjuruKe.js} +1187 -1018
  13. package/dist/chunks/{matrix-control-sources-B1K7x0SL.js → matrix-control-sources-2VAzGlt8.js} +29 -29
  14. package/dist/chunks/pre-block-Cq1RqhZX.js +3987 -0
  15. package/dist/chunks/report-preferences-dialog-BcH-0lR-.js +1232 -0
  16. package/dist/chunks/search-CJz-QQ0Q.js +24 -0
  17. package/dist/chunks/{selection-reducer-CvCBQbl2.js → selection-reducer-NF5C07yM.js} +25 -46
  18. package/dist/chunks/{index-D7GVxl4a.js → semaphor-ready-indicator-BLRDuLr4.js} +55200 -59783
  19. package/dist/chunks/slider-BYIH4icg.js +877 -0
  20. package/dist/chunks/switch-XaAACBrJ.js +2234 -0
  21. package/dist/dashboard/index.js +1 -1
  22. package/dist/dashboard-authoring/index.js +4 -4
  23. package/dist/data-app-builder/index.js +67 -67
  24. package/dist/data-app-sdk/index.js +33 -32
  25. package/dist/index.js +435 -243
  26. package/dist/style.css +1 -1
  27. package/dist/surfboard/index.js +4 -5
  28. package/dist/types/briefings/index.d.ts +1 -1
  29. package/dist/types/briefings/schedule.d.ts +49 -2
  30. package/dist/types/components/briefings/briefing-author/form-primitives.d.ts +1 -1
  31. package/dist/types/components/briefings/briefing-author/schedule-model.d.ts +12 -2
  32. package/dist/types/components/dashboard/dashboard-container.d.ts +1 -1
  33. package/dist/types/components/dashboard/sheet/layout-change-guard.d.ts +1 -1
  34. package/dist/types/components/dashboard/sheet/sheet-layout.d.ts +1 -1
  35. package/dist/types/components/editor/editor-main/text-card.d.ts +1 -1
  36. package/dist/types/components/editor/editor.d.ts +1 -1
  37. package/dist/types/components/providers/semaphor-context-provider.d.ts +1 -1
  38. package/dist/types/components/providers/theme-provider-context.d.ts +1 -1
  39. package/dist/types/components/providers/theme-provider.d.ts +1 -1
  40. package/dist/types/components/shared/unsaved-changes/use-pristine-snapshot-initializer.d.ts +1 -1
  41. package/dist/types/components/sharing-and-management/hooks/use-groups.d.ts +5 -1
  42. package/dist/types/components/sharing-and-management/hooks/use-unified-users.d.ts +9 -1
  43. package/dist/types/components/sharing-and-management/resource-share-dialog/index.d.ts +1 -1
  44. package/dist/types/components/sharing-and-management/resource-share-dialog/unified/adapter.d.ts +21 -1
  45. package/dist/types/components/sharing-and-management/resource-share-dialog/unified/configs.d.ts +12 -0
  46. package/dist/types/components/sharing-and-management/resource-share-dialog/unified/invite-combobox.d.ts +5 -0
  47. package/dist/types/components/sharing-and-management/resource-share-dialog/unified/share-shape.d.ts +7 -0
  48. package/dist/types/components/sharing-and-management/resource-share-dialog/unified/types.d.ts +2 -0
  49. package/dist/types/components/sharing-and-management/utils/shares-types.d.ts +8 -0
  50. package/dist/types/components/sharing-and-management/utils/types.d.ts +2 -0
  51. package/dist/types/components/surfboard/dashboard-plus.d.ts +1 -1
  52. package/dist/types/components/ui/resizable.d.ts +1 -1
  53. package/dist/types/components/visual/column-display-utils.d.ts +1 -1
  54. package/dist/types/components/visual/kpi-visual/kpi-utils.d.ts +1 -1
  55. package/dist/types/components/visual/settings/color-format.d.ts +1 -1
  56. package/dist/types/components/visual/visual-utils.d.ts +1 -1
  57. package/dist/types/lib/actions/data-point-click-action.d.ts +2 -1
  58. package/dist/types/lib/charts/area-chart.d.ts +1 -1
  59. package/dist/types/lib/charts/bar-chart.d.ts +1 -1
  60. package/dist/types/lib/charts/cartesian-data.d.ts +72 -0
  61. package/dist/types/lib/charts/cartesian-fields.d.ts +60 -0
  62. package/dist/types/lib/charts/chart-utils.d.ts +3 -0
  63. package/dist/types/lib/charts/combo-chart.d.ts +1 -1
  64. package/dist/types/lib/charts/create-chart.d.ts +1 -1
  65. package/dist/types/lib/charts/line-chart.d.ts +1 -1
  66. package/dist/types/lib/charts/shared/category-group-axis-plugin.d.ts +23 -0
  67. package/dist/types/lib/charts/stacked-line-chart.d.ts +2 -0
  68. package/dist/types/lib/charts/types.d.ts +1 -7
  69. package/dist/types/lib/dashboard/normalize-dashboard-for-dirty-check.d.ts +1 -1
  70. package/dist/types/lib/formatters/cartesian-temporal-presentation.d.ts +6 -1
  71. package/dist/types/lib/hooks/explorer/use-schemas.d.ts +1 -1
  72. package/dist/types/lib/hooks/use-dashboard.d.ts +2 -2
  73. package/dist/types/lib/interactions/get-click-context-from-chartjs.d.ts +1 -2
  74. package/dist/types/lib/stores/editor-store.d.ts +1 -2
  75. package/dist/types/lib/stores/table-actions.d.ts +2 -1
  76. package/dist/types/lib/types/token-types.d.ts +0 -12
  77. package/dist/types/lib/utils.d.ts +0 -2
  78. package/package.json +2 -1
  79. package/dist/chunks/dashboard-json-Kc_M7nLP.js +0 -75
  80. package/dist/chunks/editor-action-buttons-s-ByVR9x.js +0 -2019
  81. package/dist/chunks/report-preferences-dialog-RAp0DAuw.js +0 -723
  82. package/dist/types/lib/encrypt-utils.d.ts +0 -9
@@ -1,723 +0,0 @@
1
- import { jsxs as o, Fragment as j, jsx as t } from "react/jsx-runtime";
2
- import oe, { useState as S, useRef as X, useEffect as U, useCallback as E, useMemo as _ } from "react";
3
- import { az as ee, aA as ce, aB as B, aC as $, aD as de, g as ue, h as me, i as fe, j as he, k as M, l as H, aE as ve, aF as V, b as ye, aG as pe, aH as ge, aI as Se, aJ as be, aK as Te } from "./index-D7GVxl4a.js";
4
- import { u as ae, c as F, O as W, P as we, a as Ce, B as D, b as ke, d as q, L as te, a4 as z, T as xe, F as Ne, G, I as K } from "./switch-CWPcwAZ4.js";
5
- import { a as Pe } from "./report-runtime-context-CxIoGyNM.js";
6
- import "./x-CXDkqdur.js";
7
- import "./card-config-utils-CAyjC5Tp.js";
8
- import "./validators-CsdOtZI6.js";
9
- import "./matrix-operation-contract-D32U2CSw.js";
10
- import { parseValueFormatPreferencesResponse as Ae, canonicalizeSupportedLocale as Ee, canonicalizeSupportedCurrencyCode as ze } from "../value-format-preferences/index.js";
11
- function De(e = {}) {
12
- const { authToken: i, tokenProps: a } = ee(), d = ae(
13
- (g) => g.actions.applyResolvedCalendarPreferences
14
- ), r = e.enabled ?? !0, l = (i == null ? void 0 : i.accessToken) ?? null, m = (a == null ? void 0 : a.apiServiceUrl) ?? null, [y, p] = S(!1), [b, w] = S(!1), [u, T] = S(!1), [C, h] = S(null), [k, P] = S(null), f = X(l);
15
- f.current = l, U(() => {
16
- P(null), h(null), p(!1), w(!1), T(!1);
17
- }, [l]);
18
- const N = E(async (g) => {
19
- const s = Pe(await g.json());
20
- if (!s.ok)
21
- throw new Error("Calendar preferences response is invalid");
22
- return s.value;
23
- }, []), x = E(async () => {
24
- if (!r || !l || !m) return;
25
- const g = l;
26
- p(!0), h(null);
27
- try {
28
- const s = await fetch(
29
- `${m}/v1/user-preferences/calendar`,
30
- {
31
- method: "GET",
32
- headers: { Authorization: `Bearer ${l}` }
33
- }
34
- );
35
- if (!s.ok) {
36
- const v = await s.json().catch(() => ({}));
37
- throw new Error(v.error || "Failed to fetch preferences");
38
- }
39
- const n = await N(s);
40
- f.current === g && P(n);
41
- } catch (s) {
42
- f.current === g && h(s instanceof Error ? s.message : "Unknown error");
43
- } finally {
44
- f.current === g && p(!1);
45
- }
46
- }, [l, m, r, N]);
47
- U(() => {
48
- r && x();
49
- }, [r, x]);
50
- const A = E(
51
- async (g) => {
52
- if (!l || !m)
53
- return h("Not authenticated"), !1;
54
- const s = l;
55
- w(!0), h(null);
56
- try {
57
- const n = await fetch(
58
- `${m}/v1/user-preferences/calendar`,
59
- {
60
- method: "PATCH",
61
- headers: {
62
- "Content-Type": "application/json",
63
- Authorization: `Bearer ${l}`
64
- },
65
- body: JSON.stringify(g)
66
- }
67
- );
68
- if (!n.ok) {
69
- const R = await n.json().catch(() => ({}));
70
- throw new Error(R.error || "Failed to update preferences");
71
- }
72
- const v = await N(n);
73
- return f.current !== s ? !1 : (P(v), d(v.resolved, v.sources), !0);
74
- } catch (n) {
75
- return f.current === s && h(n instanceof Error ? n.message : "Unknown error"), !1;
76
- } finally {
77
- f.current === s && w(!1);
78
- }
79
- },
80
- [
81
- l,
82
- m,
83
- d,
84
- N
85
- ]
86
- ), L = E(async () => {
87
- if (!l || !m)
88
- return h("Not authenticated"), !1;
89
- const g = l;
90
- T(!0), h(null);
91
- try {
92
- const s = await fetch(
93
- `${m}/v1/user-preferences/calendar`,
94
- {
95
- method: "DELETE",
96
- headers: { Authorization: `Bearer ${l}` }
97
- }
98
- );
99
- if (!s.ok) {
100
- const v = await s.json().catch(() => ({}));
101
- throw new Error(v.error || "Failed to clear preferences");
102
- }
103
- const n = await N(s);
104
- return f.current !== g ? !1 : (P(n), d(n.resolved, n.sources), !0);
105
- } catch (s) {
106
- return f.current === g && h(s instanceof Error ? s.message : "Unknown error"), !1;
107
- } finally {
108
- f.current === g && T(!1);
109
- }
110
- }, [
111
- l,
112
- m,
113
- d,
114
- N
115
- ]);
116
- return {
117
- preferences: k,
118
- isLoading: y,
119
- isSaving: b,
120
- isClearing: u,
121
- error: C,
122
- updatePreferences: A,
123
- clearPreferences: L,
124
- refetch: x
125
- };
126
- }
127
- const I = [
128
- { value: "America/New_York", label: "Eastern Time (US & Canada)" },
129
- { value: "America/Chicago", label: "Central Time (US & Canada)" },
130
- { value: "America/Denver", label: "Mountain Time (US & Canada)" },
131
- { value: "America/Los_Angeles", label: "Pacific Time (US & Canada)" },
132
- { value: "America/Phoenix", label: "Arizona" },
133
- { value: "America/Anchorage", label: "Alaska" },
134
- { value: "Pacific/Honolulu", label: "Hawaii" },
135
- { value: "Europe/London", label: "London" },
136
- { value: "Europe/Paris", label: "Paris, Berlin, Rome" },
137
- { value: "Asia/Tokyo", label: "Tokyo" },
138
- { value: "Asia/Shanghai", label: "Beijing, Shanghai" },
139
- { value: "Asia/Kolkata", label: "Mumbai, New Delhi" },
140
- { value: "Australia/Sydney", label: "Sydney" },
141
- { value: "UTC", label: "UTC" }
142
- ], re = [
143
- { value: 0, label: "Sunday" },
144
- { value: 1, label: "Monday" },
145
- { value: 6, label: "Saturday" }
146
- ], J = "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";
147
- function Le() {
148
- try {
149
- const e = Intl;
150
- if (e.supportedValuesOf)
151
- return e.supportedValuesOf("timeZone");
152
- } catch {
153
- }
154
- return I.map((e) => e.value);
155
- }
156
- function Fe(e) {
157
- if (!e) return "default";
158
- if (e.tz !== e.weekStart) return "inherited";
159
- switch (e.tz) {
160
- case "viewer_tenant":
161
- return "tenant";
162
- case "viewer_organization":
163
- return "organization";
164
- case "system_default":
165
- return "system";
166
- case "session_initial":
167
- return "embedded";
168
- default:
169
- return "default";
170
- }
171
- }
172
- function Y(e) {
173
- const i = I.find((a) => a.value === e);
174
- return i ? i.label : e;
175
- }
176
- function Re(e) {
177
- const i = re.find((a) => a.value === e);
178
- return i ? i.label : String(e);
179
- }
180
- function je({
181
- active: e,
182
- onClose: i
183
- }) {
184
- const {
185
- preferences: a,
186
- isLoading: d,
187
- isSaving: r,
188
- isClearing: l,
189
- updatePreferences: m,
190
- clearPreferences: y
191
- } = De({ enabled: e }), p = ce(), b = (a == null ? void 0 : a.resolved.tz) || (p == null ? void 0 : p.tz) || "UTC", w = (a == null ? void 0 : a.resolved.weekStart) ?? (p == null ? void 0 : p.weekStart) ?? 1, [u, T] = S((a == null ? void 0 : a.stored) === null), [C, h] = S(!1), [k, P] = S(
192
- b
193
- ), [f, N] = S(
194
- w
195
- ), [x, A] = S(!1), L = _(() => Le(), []), g = _(
196
- () => L.filter(
197
- (c) => !I.some((ie) => ie.value === c)
198
- ),
199
- [L]
200
- ), s = _(() => Y(k), [k]), n = a != null && a.inherited ? Y(a.inherited.tz) : "UTC", v = a != null && a.inherited ? Re(a.inherited.weekStart) : "Monday", R = Fe(
201
- a == null ? void 0 : a.inheritedSources
202
- );
203
- oe.useEffect(() => {
204
- if (!e) {
205
- h(!1);
206
- return;
207
- }
208
- C || (a && T(a.stored === null), P(b), N(w));
209
- }, [
210
- e,
211
- C,
212
- a,
213
- b,
214
- w
215
- ]);
216
- const se = async () => {
217
- if (d) {
218
- z.error("Preferences are still loading. Please try again.");
219
- return;
220
- }
221
- u ? await y() ? (z.success("Now using default settings."), i()) : z.error("Failed to save preferences. Please try again.") : await m({
222
- tz: k,
223
- weekStart: f
224
- }) ? (z.success("Preferences saved."), i()) : z.error("Failed to save preferences. Please try again.");
225
- }, ne = () => {
226
- i();
227
- }, O = r || l, le = O || d;
228
- return /* @__PURE__ */ o(j, { children: [
229
- /* @__PURE__ */ o("div", { className: "space-y-4 py-1", children: [
230
- /* @__PURE__ */ o(
231
- B,
232
- {
233
- value: u ? "defaults" : "custom",
234
- onValueChange: (c) => {
235
- h(!0), T(c === "defaults");
236
- },
237
- className: "space-y-0.5",
238
- children: [
239
- /* @__PURE__ */ o(
240
- "label",
241
- {
242
- htmlFor: "mode-defaults",
243
- className: F(
244
- "flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",
245
- u && "bg-muted/50"
246
- ),
247
- onClick: () => {
248
- h(!0), T(!0);
249
- },
250
- children: [
251
- /* @__PURE__ */ t(
252
- $,
253
- {
254
- value: "defaults",
255
- id: "mode-defaults",
256
- className: "mt-0.5"
257
- }
258
- ),
259
- /* @__PURE__ */ o("div", { className: "flex-1 min-w-0", children: [
260
- /* @__PURE__ */ o("p", { className: "text-[13px] font-medium text-foreground", children: [
261
- "Use ",
262
- R,
263
- " defaults"
264
- ] }),
265
- /* @__PURE__ */ o("p", { className: "text-[12px] text-muted-foreground", children: [
266
- n,
267
- ", week starts ",
268
- v
269
- ] })
270
- ] })
271
- ]
272
- }
273
- ),
274
- /* @__PURE__ */ o(
275
- "label",
276
- {
277
- htmlFor: "mode-custom",
278
- className: F(
279
- "flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",
280
- !u && "bg-muted/50"
281
- ),
282
- onClick: () => {
283
- h(!0), T(!1);
284
- },
285
- children: [
286
- /* @__PURE__ */ t(
287
- $,
288
- {
289
- value: "custom",
290
- id: "mode-custom",
291
- className: "mt-0.5"
292
- }
293
- ),
294
- /* @__PURE__ */ t("p", { className: "flex-1 text-[13px] font-medium text-foreground", children: "Use custom settings" })
295
- ]
296
- }
297
- )
298
- ]
299
- }
300
- ),
301
- /* @__PURE__ */ o(
302
- "div",
303
- {
304
- className: F(
305
- "space-y-4 border-t border-border/60 pt-4 transition-opacity",
306
- u && "pointer-events-none opacity-50"
307
- ),
308
- children: [
309
- /* @__PURE__ */ o("div", { className: "space-y-1.5", children: [
310
- /* @__PURE__ */ t(W, { className: J, children: "Timezone" }),
311
- /* @__PURE__ */ o(
312
- we,
313
- {
314
- open: x,
315
- onOpenChange: A,
316
- modal: !0,
317
- children: [
318
- /* @__PURE__ */ t(Ce, { asChild: !0, children: /* @__PURE__ */ o(
319
- D,
320
- {
321
- variant: "outline",
322
- size: "xs",
323
- role: "combobox",
324
- "aria-expanded": x,
325
- className: "w-full justify-between text-[12px] font-normal",
326
- disabled: u,
327
- children: [
328
- /* @__PURE__ */ t("span", { className: "truncate", children: s }),
329
- /* @__PURE__ */ t(de, { className: "ml-2 h-3.5 w-3.5 shrink-0 opacity-50" })
330
- ]
331
- }
332
- ) }),
333
- /* @__PURE__ */ t(
334
- ke,
335
- {
336
- className: "z-50 w-[--radix-popover-trigger-width] p-0",
337
- align: "start",
338
- children: /* @__PURE__ */ o(ue, { className: "overflow-visible", children: [
339
- /* @__PURE__ */ t(me, { placeholder: "Search timezones…" }),
340
- /* @__PURE__ */ o(fe, { children: [
341
- /* @__PURE__ */ t(he, { children: "No timezone found." }),
342
- /* @__PURE__ */ t(M, { heading: "Common", children: I.map((c) => /* @__PURE__ */ o(
343
- H,
344
- {
345
- value: `${c.value} ${c.label}`,
346
- onSelect: () => {
347
- h(!0), P(c.value), A(!1);
348
- },
349
- children: [
350
- /* @__PURE__ */ t(
351
- q,
352
- {
353
- className: F(
354
- "h-3.5 w-3.5",
355
- k === c.value ? "opacity-100" : "opacity-0"
356
- )
357
- }
358
- ),
359
- /* @__PURE__ */ t("span", { className: "flex-1", children: c.label }),
360
- /* @__PURE__ */ t("span", { className: "text-[11px] text-muted-foreground", children: c.value })
361
- ]
362
- },
363
- c.value
364
- )) }),
365
- /* @__PURE__ */ t(ve, {}),
366
- /* @__PURE__ */ t(M, { heading: "All timezones", children: g.map((c) => /* @__PURE__ */ o(
367
- H,
368
- {
369
- value: c,
370
- onSelect: () => {
371
- h(!0), P(c), A(!1);
372
- },
373
- children: [
374
- /* @__PURE__ */ t(
375
- q,
376
- {
377
- className: F(
378
- "h-3.5 w-3.5",
379
- k === c ? "opacity-100" : "opacity-0"
380
- )
381
- }
382
- ),
383
- c
384
- ]
385
- },
386
- c
387
- )) })
388
- ] })
389
- ] })
390
- }
391
- )
392
- ]
393
- }
394
- )
395
- ] }),
396
- /* @__PURE__ */ o("div", { className: "space-y-1.5", children: [
397
- /* @__PURE__ */ t(W, { className: J, children: "Week starts on" }),
398
- /* @__PURE__ */ t(
399
- B,
400
- {
401
- value: String(f),
402
- onValueChange: (c) => {
403
- h(!0), N(Number(c));
404
- },
405
- className: "flex gap-4",
406
- disabled: u,
407
- children: re.map((c) => /* @__PURE__ */ o(
408
- "label",
409
- {
410
- htmlFor: `week-start-${c.value}`,
411
- className: F(
412
- "flex cursor-pointer items-center gap-2 text-[13px]",
413
- u && "cursor-not-allowed"
414
- ),
415
- children: [
416
- /* @__PURE__ */ t(
417
- $,
418
- {
419
- value: String(c.value),
420
- id: `week-start-${c.value}`,
421
- disabled: u
422
- }
423
- ),
424
- c.label
425
- ]
426
- },
427
- c.value
428
- ))
429
- }
430
- )
431
- ] })
432
- ]
433
- }
434
- )
435
- ] }),
436
- /* @__PURE__ */ o(V, { children: [
437
- /* @__PURE__ */ t(
438
- D,
439
- {
440
- variant: "outline",
441
- size: "xs",
442
- onClick: ne,
443
- disabled: O,
444
- children: "Cancel"
445
- }
446
- ),
447
- /* @__PURE__ */ t(D, { size: "xs", onClick: se, disabled: le, children: O ? /* @__PURE__ */ o(j, { children: [
448
- /* @__PURE__ */ t(te, { className: "h-3.5 w-3.5 animate-spin" }),
449
- "Saving…"
450
- ] }) : "Save" })
451
- ] })
452
- ] });
453
- }
454
- function Ue(e = {}) {
455
- const { authToken: i, tokenProps: a } = ee(), d = ae(
456
- (s) => s.actions.applyResolvedValueFormatPreferences
457
- ), r = e.enabled ?? !0, l = (i == null ? void 0 : i.accessToken) ?? null, m = (a == null ? void 0 : a.apiServiceUrl) ?? null, y = X(l);
458
- y.current = l;
459
- const [p, b] = S(null), [w, u] = S(!1), [T, C] = S(!1), [h, k] = S(!1), [P, f] = S(null);
460
- U(() => {
461
- b(null), f(null), u(!1), C(!1), k(!1);
462
- }, [l]);
463
- const N = E(async (s) => {
464
- const n = Ae(await s.json());
465
- if (!n.ok)
466
- throw new Error("Value format preferences response is invalid");
467
- return n.value;
468
- }, []), x = E(
469
- async (s, n) => {
470
- if (!l || !m)
471
- throw new Error("Not authenticated");
472
- const v = await fetch(
473
- `${m}/v1/user-preferences/value-format`,
474
- {
475
- method: s,
476
- headers: {
477
- Authorization: `Bearer ${l}`,
478
- ...n ? { "Content-Type": "application/json" } : {}
479
- },
480
- body: n ? JSON.stringify(n) : void 0
481
- }
482
- );
483
- if (!v.ok) {
484
- const R = await v.json().catch(() => ({}));
485
- throw new Error(R.error || "Failed to update preferences");
486
- }
487
- return N(v);
488
- },
489
- [l, m, N]
490
- ), A = E(async () => {
491
- if (!r || !l || !m) return;
492
- const s = l;
493
- u(!0), f(null);
494
- try {
495
- const n = await x("GET");
496
- y.current === s && b(n);
497
- } catch (n) {
498
- y.current === s && f(n instanceof Error ? n.message : "Unknown error");
499
- } finally {
500
- y.current === s && u(!1);
501
- }
502
- }, [l, m, r, x]);
503
- U(() => {
504
- r && A();
505
- }, [r, A]);
506
- const L = E(
507
- async (s) => {
508
- const n = l;
509
- C(!0), f(null);
510
- try {
511
- const v = await x("PATCH", s);
512
- return y.current !== n ? !1 : (b(v), d(v.resolved, v.sources), !0);
513
- } catch (v) {
514
- return y.current === n && f(v instanceof Error ? v.message : "Unknown error"), !1;
515
- } finally {
516
- y.current === n && C(!1);
517
- }
518
- },
519
- [l, d, x]
520
- ), g = E(async () => {
521
- const s = l;
522
- k(!0), f(null);
523
- try {
524
- const n = await x("DELETE");
525
- return y.current !== s ? !1 : (b(n), d(n.resolved, n.sources), !0);
526
- } catch (n) {
527
- return y.current === s && f(n instanceof Error ? n.message : "Unknown error"), !1;
528
- } finally {
529
- y.current === s && k(!1);
530
- }
531
- }, [l, d, x]);
532
- return {
533
- preferences: p,
534
- isLoading: w,
535
- isSaving: T,
536
- isClearing: h,
537
- error: P,
538
- updatePreferences: L,
539
- clearPreferences: g,
540
- refetch: A
541
- };
542
- }
543
- const Z = [
544
- "locale",
545
- "dateStyle",
546
- "dateTime.dateStyle",
547
- "dateTime.timeStyle",
548
- "defaultCurrency"
549
- ];
550
- function Q(e, i) {
551
- var a, d;
552
- switch (i) {
553
- case "locale":
554
- return e == null ? void 0 : e.locale;
555
- case "dateStyle":
556
- return e == null ? void 0 : e.dateStyle;
557
- case "dateTime.dateStyle":
558
- return (a = e == null ? void 0 : e.dateTime) == null ? void 0 : a.dateStyle;
559
- case "dateTime.timeStyle":
560
- return (d = e == null ? void 0 : e.dateTime) == null ? void 0 : d.timeStyle;
561
- case "defaultCurrency":
562
- return e == null ? void 0 : e.defaultCurrency;
563
- }
564
- }
565
- function Ie(e) {
566
- var d, r;
567
- const i = (d = e == null ? void 0 : e.dateTime) == null ? void 0 : d.dateStyle, a = (r = e == null ? void 0 : e.dateTime) == null ? void 0 : r.timeStyle;
568
- return {
569
- locale: e == null ? void 0 : e.locale,
570
- dateStyle: e == null ? void 0 : e.dateStyle,
571
- dateTime: i === void 0 && a === void 0 ? void 0 : { dateStyle: i, timeStyle: a },
572
- defaultCurrency: e == null ? void 0 : e.defaultCurrency
573
- };
574
- }
575
- function Oe({
576
- active: e,
577
- onClose: i
578
- }) {
579
- var y, p, b, w, u, T, C;
580
- const { preferences: a, isLoading: d, isSaving: r, updatePreferences: l } = Ue({ enabled: e });
581
- if (!e) return null;
582
- if (!a)
583
- return /* @__PURE__ */ o(j, { children: [
584
- /* @__PURE__ */ t("div", { className: "py-2", children: /* @__PURE__ */ t("div", { className: "flex min-h-36 items-center justify-center text-[12px] text-muted-foreground", children: d ? "Loading preferences…" : "Preferences unavailable." }) }),
585
- /* @__PURE__ */ o(V, { className: "justify-between sm:justify-between", children: [
586
- /* @__PURE__ */ t(D, { variant: "ghost", size: "xs", disabled: !0, children: "Reset display formats" }),
587
- /* @__PURE__ */ o("div", { className: "flex gap-2", children: [
588
- /* @__PURE__ */ t(D, { variant: "outline", size: "xs", onClick: i, children: "Cancel" }),
589
- /* @__PURE__ */ t(D, { size: "xs", disabled: !0, children: "Save" })
590
- ] })
591
- ] })
592
- ] });
593
- const m = [
594
- ((y = a.stored) == null ? void 0 : y.locale) ?? "",
595
- ((p = a.stored) == null ? void 0 : p.dateStyle) ?? "",
596
- ((w = (b = a.stored) == null ? void 0 : b.dateTime) == null ? void 0 : w.dateStyle) ?? "",
597
- ((T = (u = a.stored) == null ? void 0 : u.dateTime) == null ? void 0 : T.timeStyle) ?? "",
598
- ((C = a.stored) == null ? void 0 : C.defaultCurrency) ?? ""
599
- ].join(":");
600
- return /* @__PURE__ */ t(
601
- _e,
602
- {
603
- preferences: a,
604
- isSaving: r,
605
- updatePreferences: l,
606
- onClose: i
607
- },
608
- m
609
- );
610
- }
611
- function _e({
612
- preferences: e,
613
- isSaving: i,
614
- updatePreferences: a,
615
- onClose: d
616
- }) {
617
- var b, w;
618
- const [r, l] = S(
619
- () => Ie(e.stored)
620
- ), m = (r.locale === void 0 || Ee(r.locale) !== void 0) && (r.defaultCurrency === void 0 || ze(r.defaultCurrency) !== void 0) && (r.dateStyle === void 0 || ["short", "medium", "long"].includes(r.dateStyle)) && (((b = r.dateTime) == null ? void 0 : b.dateStyle) === void 0 || ["short", "medium", "long"].includes(r.dateTime.dateStyle)) && (((w = r.dateTime) == null ? void 0 : w.timeStyle) === void 0 || ["short", "medium", "long"].includes(r.dateTime.timeStyle)), y = async () => {
621
- const u = {
622
- ...r.locale !== void 0 ? { locale: r.locale } : {},
623
- ...r.dateStyle !== void 0 ? { dateStyle: r.dateStyle } : {},
624
- ...r.dateTime ? { dateTime: { ...r.dateTime } } : {},
625
- ...r.defaultCurrency !== void 0 ? { defaultCurrency: r.defaultCurrency } : {}
626
- }, T = Z.filter(
627
- (k) => Q(r, k) === void 0 && Q(e.stored, k) !== void 0
628
- ), C = {
629
- ...Object.keys(u).length > 0 ? { set: u } : {},
630
- ...T.length > 0 ? { clear: T } : {}
631
- };
632
- (Object.keys(C).length === 0 ? !0 : await a(C)) ? (z.success("Display format preferences saved."), d()) : z.error("Failed to save preferences. Please try again.");
633
- }, p = async () => {
634
- await a({
635
- clear: [...Z]
636
- }) ? (z.success("Display format preferences reset."), d()) : z.error(
637
- "Failed to reset display format preferences. Please try again."
638
- );
639
- };
640
- return /* @__PURE__ */ o(j, { children: [
641
- /* @__PURE__ */ t("div", { className: "py-2", children: /* @__PURE__ */ t(
642
- ye,
643
- {
644
- value: r,
645
- inherited: e.inherited,
646
- inheritedSources: e.inheritedSources,
647
- onChange: l,
648
- disabled: i
649
- }
650
- ) }),
651
- /* @__PURE__ */ o(V, { className: "justify-between sm:justify-between", children: [
652
- /* @__PURE__ */ t(
653
- D,
654
- {
655
- variant: "ghost",
656
- size: "xs",
657
- onClick: p,
658
- disabled: i || e.stored === null,
659
- children: "Reset display formats"
660
- }
661
- ),
662
- /* @__PURE__ */ o("div", { className: "flex gap-2", children: [
663
- /* @__PURE__ */ t(
664
- D,
665
- {
666
- variant: "outline",
667
- size: "xs",
668
- onClick: d,
669
- disabled: i,
670
- children: "Cancel"
671
- }
672
- ),
673
- /* @__PURE__ */ t(
674
- D,
675
- {
676
- size: "xs",
677
- onClick: y,
678
- disabled: i || !m,
679
- children: i ? /* @__PURE__ */ o(j, { children: [
680
- /* @__PURE__ */ t(te, { className: "h-3.5 w-3.5 animate-spin" }),
681
- "Saving…"
682
- ] }) : "Save"
683
- }
684
- )
685
- ] })
686
- ] })
687
- ] });
688
- }
689
- function Ye({
690
- open: e,
691
- onOpenChange: i
692
- }) {
693
- const [a, d] = S("display"), r = () => i(!1);
694
- return /* @__PURE__ */ t(pe, { open: e, onOpenChange: i, children: /* @__PURE__ */ o(ge, { className: "rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control", children: [
695
- /* @__PURE__ */ o(Se, { children: [
696
- /* @__PURE__ */ t(be, { className: "text-[15px]", children: "Report preferences" }),
697
- /* @__PURE__ */ t(Te, { className: "text-[13px] leading-5", children: "Set how values and Calendar periods appear for you." })
698
- ] }),
699
- /* @__PURE__ */ o(xe, { value: a, onValueChange: d, children: [
700
- /* @__PURE__ */ o(Ne, { variant: "underline", className: "w-full justify-start", children: [
701
- /* @__PURE__ */ t(G, { value: "display", children: "Display formats" }),
702
- /* @__PURE__ */ t(G, { value: "calendar", children: "Calendar" })
703
- ] }),
704
- /* @__PURE__ */ t(K, { value: "display", children: /* @__PURE__ */ t(
705
- Oe,
706
- {
707
- active: e && a === "display",
708
- onClose: r
709
- }
710
- ) }),
711
- /* @__PURE__ */ t(K, { value: "calendar", children: /* @__PURE__ */ t(
712
- je,
713
- {
714
- active: e && a === "calendar",
715
- onClose: r
716
- }
717
- ) })
718
- ] })
719
- ] }) });
720
- }
721
- export {
722
- Ye as R
723
- };