react-semaphor 0.1.537 → 0.1.538

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