react-semaphor 0.1.537 → 0.1.539

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