react-semaphor 0.1.525 → 0.1.527

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 (196) hide show
  1. package/DATA_APP_SDK.md +5 -1
  2. package/dist/analytics-protocol/index.js +1179 -296
  3. package/dist/brand-studio/index.js +31 -31
  4. package/dist/briefings/index.js +50 -49
  5. package/dist/chunks/{calculated-field-identity-Dy_WpDdo.js → calculated-field-identity-DEhjPSr-.js} +77 -76
  6. package/dist/chunks/{card-config-utils-CAyjC5Tp.js → card-config-utils-BlIbwkuD.js} +62 -59
  7. package/dist/chunks/{constants-DeLIHVAW.js → constants-DNWVy8Y3.js} +4 -4
  8. package/dist/chunks/dashboard-JNHR0_cZ.js +14 -0
  9. package/dist/chunks/{dashboard-briefing-launcher-BilVIEyw.js → dashboard-briefing-launcher-D9pFByPh.js} +274 -267
  10. package/dist/chunks/{dashboard-controls-DyLPcvCK.js → dashboard-controls-CJI5ZWMq.js} +740 -692
  11. package/dist/chunks/dashboard-json-DLdrFry-.js +65 -0
  12. package/dist/chunks/{edit-dashboard-visual-DtmKNNdE.js → edit-dashboard-visual-D5LjWle1.js} +6760 -6728
  13. package/dist/chunks/editor-action-buttons-G91NQKxU.js +2070 -0
  14. package/dist/chunks/{field-aggregations-BQjogiI1.js → field-aggregations-DeVQLIsP.js} +19 -19
  15. package/dist/chunks/{field-dependencies-v-lJNzC7.js → field-dependencies-CGYic38w.js} +1 -1
  16. package/dist/chunks/{index-ON7Gpvcv.js → index-BvJOYbNv.js} +760 -750
  17. package/dist/chunks/{matrix-analytical-definition-BimC4XIV.js → matrix-analytical-definition-BJyH5-99.js} +1 -1
  18. package/dist/chunks/{matrix-card-CIlz0Dnp.js → matrix-card-DY45yiUM.js} +7 -6
  19. package/dist/chunks/{matrix-control-sources-B1K7x0SL.js → matrix-control-sources-BypfLZsK.js} +36 -36
  20. package/dist/chunks/{matrix-definition-E5gXXSTZ.js → matrix-definition-Cdn3LoxW.js} +3 -3
  21. package/dist/chunks/{semantic-format-Baqp8kD_.js → matrix-formatter-BoKU3MzZ.js} +655 -511
  22. package/dist/chunks/{matrix-member-presentation-Bw7-JCrr.js → matrix-member-presentation-BBW0n1iY.js} +1 -1
  23. package/dist/chunks/matrix-operation-contract-BV02rLhu.js +809 -0
  24. package/dist/chunks/{metric-comparison-BphoJ9bq.js → metric-comparison-Crljx_XY.js} +15 -10
  25. package/dist/chunks/{numeric-presentation-VhMUHfrJ.js → numeric-presentation-LvnNY5Ma.js} +68 -68
  26. package/dist/chunks/pivot-header-presentation-D5v8uyjj.js +618 -0
  27. package/dist/chunks/{pivot-result-identity-BzUQiCEV.js → pivot-result-identity-CY__BuwI.js} +1 -1
  28. package/dist/chunks/{pivot-result-lifecycle-BFO354lk.js → pivot-result-lifecycle-BWrPhlGT.js} +259 -204
  29. package/dist/chunks/{raw-temporal-7bFbXd2a.js → raw-temporal-CdnA_OXJ.js} +10 -10
  30. package/dist/chunks/{raw-temporal-contract-BQZIJ1fn.js → raw-temporal-contract-Bc9z83t-.js} +1 -1
  31. package/dist/chunks/relative-date-DAF9J7mt.js +456 -0
  32. package/dist/chunks/report-preferences-dialog-D3hxu4sE.js +1231 -0
  33. package/dist/chunks/{report-runtime-context-CxIoGyNM.js → report-runtime-context-CtaGGlit.js} +1 -1
  34. package/dist/chunks/{selection-reducer-CvCBQbl2.js → selection-reducer-C7Um5XN-.js} +3 -3
  35. package/dist/chunks/semantic-format-BjBMOSoo.js +192 -0
  36. package/dist/chunks/{index-DYOaHuLS.js → semaphor-ready-indicator-D46I_4g7.js} +145070 -146854
  37. package/dist/chunks/slider-B6LELqx6.js +876 -0
  38. package/dist/chunks/{source-entity-resolution-Bzefiive.js → source-entity-resolution-Bde29mqE.js} +25 -25
  39. package/dist/chunks/{switch-CWPcwAZ4.js → switch-_7uBAbYx.js} +7950 -8545
  40. package/dist/chunks/{temporal-bucket-PcLFSYWX.js → temporal-bucket-DlFuhCnT.js} +6 -6
  41. package/dist/chunks/{temporal-bucket-contract-DTLDRzgV.js → temporal-bucket-contract-C6lUGPS3.js} +1 -1
  42. package/dist/chunks/temporal-input-presentation-DyMWCZYh.js +195 -0
  43. package/dist/chunks/{token-types-BC6RcUY8.js → token-types-UjyNz95-.js} +1 -1
  44. package/dist/chunks/{validators-CsdOtZI6.js → validators-CQcG0EPN.js} +852 -731
  45. package/dist/chunks/zoned-wall-clock-BkxV9jS2.js +46 -0
  46. package/dist/dashboard/index.js +1 -1
  47. package/dist/dashboard-authoring/index.js +138 -137
  48. package/dist/data-app-sdk/index.js +30 -29
  49. package/dist/data-app-sdk-adapters/index.js +23 -22
  50. package/dist/data-app-sdk-validation/index.js +27 -26
  51. package/dist/format-utils/index.js +247 -329
  52. package/dist/index.js +435 -246
  53. package/dist/report-runtime-context/index.js +2 -2
  54. package/dist/style.css +1 -1
  55. package/dist/surfboard/index.js +4 -5
  56. package/dist/types/briefings/index.d.ts +3 -0
  57. package/dist/types/components/dashboard/dashboard-container.d.ts +1 -1
  58. package/dist/types/components/dashboard/sheet/layout-change-guard.d.ts +1 -1
  59. package/dist/types/components/dashboard/sheet/sheet-layout.d.ts +1 -1
  60. package/dist/types/components/editor/editor-main/text-card.d.ts +1 -1
  61. package/dist/types/components/editor/editor.d.ts +1 -1
  62. package/dist/types/components/explorer/filters/card-date-filter.d.ts +13 -5
  63. package/dist/types/components/explorer/filters/card-date-selection.d.ts +28 -0
  64. package/dist/types/components/providers/semaphor-context-provider.d.ts +1 -1
  65. package/dist/types/components/providers/theme-provider-context.d.ts +1 -1
  66. package/dist/types/components/providers/theme-provider.d.ts +1 -1
  67. package/dist/types/components/shared/unsaved-changes/use-pristine-snapshot-initializer.d.ts +1 -1
  68. package/dist/types/components/sharing-and-management/dashboard-actions-menu.d.ts +1 -1
  69. package/dist/types/components/sharing-and-management/hooks/use-resource-management.d.ts +0 -1
  70. package/dist/types/components/surfboard/dashboard-plus.d.ts +1 -1
  71. package/dist/types/components/surfboard/download-settings-dialog.d.ts +8 -0
  72. package/dist/types/components/surfboard/filter/types.d.ts +8 -29
  73. package/dist/types/components/surfboard/filter/use-dashboard-filter-mapping-popover.d.ts +5 -1
  74. package/dist/types/components/ui-custom/date-range-picker.d.ts +18 -2
  75. package/dist/types/components/ui-custom/date-range-presets.d.ts +8 -21
  76. package/dist/types/components/ui-custom/report-calendar.d.ts +18 -0
  77. package/dist/types/components/visual/aggregated-table/utils/export-utils.d.ts +3 -5
  78. package/dist/types/components/visual/column-display-utils.d.ts +1 -1
  79. package/dist/types/components/visual/data-table/data-table-toolbar.d.ts +1 -1
  80. package/dist/types/components/visual/kpi-visual/kpi-utils.d.ts +1 -1
  81. package/dist/types/components/visual/pivot-table/utils/pivot-table-export-utils.d.ts +3 -1
  82. package/dist/types/components/visual/settings/color-format.d.ts +1 -1
  83. package/dist/types/components/visual/visual-utils.d.ts +1 -1
  84. package/dist/types/index.js +5 -5
  85. package/dist/types/lib/actions/data-point-click-action.d.ts +2 -1
  86. package/dist/types/lib/api/exports-api.d.ts +3 -0
  87. package/dist/types/lib/csv-download.d.ts +9 -0
  88. package/dist/types/lib/csv-encoding-options.d.ts +6 -0
  89. package/dist/types/lib/dashboard/normalize-dashboard-for-dirty-check.d.ts +1 -1
  90. package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-storage-transition.d.ts +2 -1
  91. package/dist/types/lib/dashboard-navigation/build-carried-click-context.d.ts +0 -1
  92. package/dist/types/lib/document/document-input-runtime.d.ts +2 -1
  93. package/dist/types/lib/export-utils.d.ts +17 -15
  94. package/dist/types/lib/hooks/explorer/use-filter-builder.d.ts +2 -2
  95. package/dist/types/lib/hooks/explorer/use-schemas.d.ts +1 -1
  96. package/dist/types/lib/hooks/use-dashboard.d.ts +2 -2
  97. package/dist/types/lib/hooks/use-relative-date-summarizer.d.ts +7 -0
  98. package/dist/types/lib/interactions/get-click-context-from-chartjs.d.ts +1 -2
  99. package/dist/types/lib/matrix-table/matrix-application-adapter.d.ts +3 -2
  100. package/dist/types/lib/matrix-table/matrix-card-adapter.d.ts +1 -1
  101. package/dist/types/lib/matrix-table/matrix-card-draft.d.ts +1 -1
  102. package/dist/types/lib/matrix-table/matrix-dataset-history.d.ts +47 -0
  103. package/dist/types/lib/matrix-table/matrix-delivery.d.ts +7 -3
  104. package/dist/types/lib/matrix-table/matrix-execution-context.d.ts +2 -0
  105. package/dist/types/lib/matrix-table/matrix-query-transport.d.ts +4 -1
  106. package/dist/types/lib/matrix-table/matrix-runtime-types.d.ts +105 -4
  107. package/dist/types/lib/matrix-table/matrix-runtime.d.ts +43 -2
  108. package/dist/types/lib/matrix-table/use-matrix.d.ts +6 -0
  109. package/dist/types/lib/query-context/build-card-query-context.d.ts +5 -1
  110. package/dist/types/lib/query-context/build-dashboard-card-query-contract.d.ts +0 -1
  111. package/dist/types/lib/query-context/build-global-date-comparison-context.d.ts +1 -2
  112. package/dist/types/lib/query-context/compile-dashboard-card-filters.d.ts +1 -2
  113. package/dist/types/lib/query-context/dashboard-card-query-key.d.ts +10 -0
  114. package/dist/types/lib/query-context/query-auth-scope.d.ts +5 -0
  115. package/dist/types/lib/stores/dashboard-store.d.ts +9 -4
  116. package/dist/types/lib/stores/editor-store.d.ts +1 -2
  117. package/dist/types/lib/stores/table-actions.d.ts +2 -1
  118. package/dist/types/lib/temporal-filter/temporal-filter-utils.d.ts +9 -2
  119. package/dist/types/lib/types/common-types.d.ts +5 -0
  120. package/dist/types/lib/types/explorer-types.d.ts +14 -0
  121. package/dist/types/lib/types/token-types.d.ts +0 -13
  122. package/dist/types/lib/utils/card-definition.d.ts +1 -1
  123. package/dist/types/lib/utils/date-timezone-utils.d.ts +4 -46
  124. package/dist/types/lib/utils/filter-default-value-utils.d.ts +8 -2
  125. package/dist/types/lib/utils/inline-filter-utils.d.ts +3 -2
  126. package/dist/types/lib/utils/relative-date-description.d.ts +38 -0
  127. package/dist/types/lib/utils.d.ts +0 -2
  128. package/dist/types/shared/analytics-protocol/contracts.d.ts +10 -7
  129. package/dist/types/shared/analytics-protocol/index.d.ts +12 -1
  130. package/dist/types/shared/analytics-protocol/matrix-definition-contract.d.ts +20 -20
  131. package/dist/types/shared/analytics-protocol/matrix-operation-contract.d.ts +10 -10
  132. package/dist/types/shared/analytics-protocol/matrix-operation-request.d.ts +8 -8
  133. package/dist/types/shared/analytics-protocol/matrix-window-contract.d.ts +51 -5
  134. package/dist/types/shared/analytics-protocol/metric-comparison.d.ts +9 -3
  135. package/dist/types/shared/analytics-protocol/operation-temporal-state.d.ts +64 -0
  136. package/dist/types/shared/analytics-protocol/relative-date-filter.d.ts +61 -0
  137. package/dist/types/shared/analytics-protocol/relative-date-label.d.ts +20 -0
  138. package/dist/types/shared/analytics-protocol/runtime-schemas.d.ts +0 -2
  139. package/dist/types/shared/analytics-protocol/time-window-schema.d.ts +314 -0
  140. package/dist/types/shared/analytics-protocol/time-window.d.ts +13 -0
  141. package/dist/types/shared/dashboard-authoring/matrix-delivery.d.ts +8 -4
  142. package/dist/types/shared/format-utils/exporters/csv-utils.d.ts +46 -15
  143. package/dist/types/shared/format-utils/exporters/index.d.ts +2 -3
  144. package/dist/types/shared/format-utils/flat-table-export-totals.d.ts +2 -1
  145. package/dist/types/shared/format-utils/matrix-export-presentation.d.ts +2 -2
  146. package/dist/types/shared/format-utils/types/format-types.d.ts +0 -42
  147. package/dist/types/shared/temporal/calendar-periods.d.ts +56 -0
  148. package/dist/types/shared/temporal/index.d.ts +5 -0
  149. package/dist/types/shared/temporal/relative-date.d.ts +21 -0
  150. package/dist/types/shared/temporal/temporal-parity-fixtures.d.ts +73 -0
  151. package/dist/types/shared/temporal/time-window-periods.d.ts +21 -0
  152. package/dist/types/shared/temporal/zoned-wall-clock.d.ts +23 -0
  153. package/package.json +2 -17
  154. package/src/data-app-sdk/README.md +6 -3
  155. package/dist/chunks/dashboard-date-comparison-definition-BqNhECUr.js +0 -183
  156. package/dist/chunks/dashboard-json-QEoU-mx4.js +0 -75
  157. package/dist/chunks/editor-action-buttons-B9VRW3Bh.js +0 -2019
  158. package/dist/chunks/matrix-formatter-WBgtebUT.js +0 -341
  159. package/dist/chunks/matrix-operation-contract-D32U2CSw.js +0 -1802
  160. package/dist/chunks/mouse-pointer-2-BZvGk45-.js +0 -19
  161. package/dist/chunks/pivot-header-presentation-CGtudHo7.js +0 -661
  162. package/dist/chunks/report-preferences-dialog-BLaFmlE2.js +0 -723
  163. package/dist/chunks/temporal-input-presentation-2RJrvmYL.js +0 -222
  164. package/dist/chunks/update-policy-DhAUtiC8.js +0 -913
  165. package/dist/data-app-builder/index.js +0 -3666
  166. package/dist/data-app-builder-browser-runtime/index.js +0 -8
  167. package/dist/data-app-codegen/index.js +0 -22
  168. package/dist/data-app-codegen-node/index.js +0 -1807
  169. package/dist/types/components/data-app-runtime/published-data-app-runtime.d.ts +0 -7
  170. package/dist/types/components/surfboard/json-to-csv.d.ts +0 -7
  171. package/dist/types/components/visual/data-table/utils/export-utils.d.ts +0 -31
  172. package/dist/types/data-app-builder/browser-runtime.d.ts +0 -174
  173. package/dist/types/data-app-builder/constants.d.ts +0 -14
  174. package/dist/types/data-app-builder/data-app-builder.d.ts +0 -14
  175. package/dist/types/data-app-builder/index.d.ts +0 -1
  176. package/dist/types/data-app-builder/lib/api.d.ts +0 -36
  177. package/dist/types/data-app-builder/lib/context-select.d.ts +0 -3
  178. package/dist/types/data-app-builder/lib/diagnostics.d.ts +0 -12
  179. package/dist/types/data-app-builder/lib/file-tree.d.ts +0 -2
  180. package/dist/types/data-app-builder/types.d.ts +0 -558
  181. package/dist/types/data-app-builder-browser-runtime.d.ts +0 -2
  182. package/dist/types/data-app-builder.d.ts +0 -2
  183. package/dist/types/data-app-codegen/generate-contract.d.ts +0 -26
  184. package/dist/types/data-app-codegen/generated-contract-files.d.ts +0 -7
  185. package/dist/types/data-app-codegen/generated-contract-validation.d.ts +0 -13
  186. package/dist/types/data-app-codegen/index.d.ts +0 -6
  187. package/dist/types/data-app-codegen/live-execution.d.ts +0 -42
  188. package/dist/types/data-app-codegen/node.d.ts +0 -2
  189. package/dist/types/data-app-codegen/update-policy.d.ts +0 -25
  190. package/dist/types/data-app-codegen/validation.d.ts +0 -8
  191. package/dist/types/data-app-codegen-node.d.ts +0 -2
  192. package/dist/types/data-app-codegen.d.ts +0 -2
  193. package/dist/types/lib/encrypt-utils.d.ts +0 -9
  194. package/dist/types/shared/analytics-protocol/data-app-codegen-summary.d.ts +0 -418
  195. package/dist/types/shared/format-utils/exporters/pivot-exporter.d.ts +0 -13
  196. package/dist/types/shared/format-utils/exporters/table-exporter.d.ts +0 -10
@@ -0,0 +1,1231 @@
1
+ import { jsxs as l, jsx as a, Fragment as B } from "react/jsx-runtime";
2
+ import Pe, { useRef as M, useState as C, useCallback as _, useEffect as U, lazy as ie, Suspense as J, Activity as De, useMemo as q, useId as V } from "react";
3
+ import { aN as Re, aO as _e, aP as Ae, aQ as Ie, aR as Fe, b as Le, E as ze, F as Ue, S as Oe, B as je, a as Ve, U as We, D as Me, C as Be, aB as Se, aS as $e, aT as ce, aU as Z, aV as He, f as Ge, g as Ke, h as Je, i as qe, j as de, k as ue, aW as Ze, aX as oe, aY as Ye, aZ as Xe, a_ as Qe, a$ as ea, b0 as aa } from "./semaphor-ready-indicator-D46I_4g7.js";
4
+ import { u as R, a0 as ta, m as O, c as z, ah as ra, ai as la, P as na, a as sa, B as F, b as ia, d as me, L as xe, aj as I, s as ae, t as te, v as re, w as le, x as L, T as oa, e as ca, f as fe, h as he } from "./switch-_7uBAbYx.js";
5
+ import { X as da } from "./x-CXDkqdur.js";
6
+ import "./validators-CQcG0EPN.js";
7
+ import "./matrix-operation-contract-BV02rLhu.js";
8
+ import "zod";
9
+ import { parseValueFormatPreferencesResponse as ua, canonicalizeSupportedLocale as we, getSupportedCurrencyCodes as ma, canonicalizeSupportedCurrencyCode as fa } from "../value-format-preferences/index.js";
10
+ import { a as ha } from "./report-runtime-context-CtaGGlit.js";
11
+ import { r as H, g as W } from "./raw-temporal-CdnA_OXJ.js";
12
+ function va(e = []) {
13
+ const r = M(null), t = M(null), s = M(null), [n, i] = C(), o = _(() => {
14
+ var b, v, p;
15
+ const m = ((b = r.current) == null ? void 0 : b.clientWidth) ?? 0, h = ((v = s.current) == null ? void 0 : v.offsetWidth) ?? 0, y = ((p = t.current) == null ? void 0 : p.offsetWidth) ?? 0, f = m - h - y - 8, S = Math.max(f, 0);
16
+ i((k) => k === S ? k : S);
17
+ }, []);
18
+ return U(() => {
19
+ const m = r.current;
20
+ if (!m || typeof ResizeObserver > "u") return;
21
+ const h = new ResizeObserver(() => o());
22
+ return h.observe(m), o(), () => h.disconnect();
23
+ }, [o, ...e]), {
24
+ headerRef: r,
25
+ leftActionsRef: t,
26
+ rightActionsRef: s,
27
+ titleMaxWidth: n,
28
+ updateAvailableWidth: o
29
+ };
30
+ }
31
+ function pa({ filter: e }) {
32
+ var v;
33
+ const r = R(
34
+ (p) => p.isDashboardEditing
35
+ ), { preferences: t } = Re(), s = _e((v = t == null ? void 0 : t.cardDisplay) == null ? void 0 : v.mode), n = R((p) => p.filterValues), i = n == null ? void 0 : n.some(
36
+ (p) => p.filterId === e.id
37
+ ), { removeFilterValues: o, removeFilter: m, updateFilter: h } = ta(), {
38
+ headerRef: y,
39
+ leftActionsRef: N,
40
+ rightActionsRef: f,
41
+ titleMaxWidth: S,
42
+ updateAvailableWidth: b
43
+ } = va([
44
+ r,
45
+ i,
46
+ s
47
+ ]);
48
+ return U(() => {
49
+ b();
50
+ }, [e.title, b]), /* @__PURE__ */ l(
51
+ "div",
52
+ {
53
+ ref: y,
54
+ className: "group mb-1 flex h-5 items-center justify-between",
55
+ children: [
56
+ /* @__PURE__ */ l("div", { className: "flex grow items-center gap-2 min-w-0", children: [
57
+ /* @__PURE__ */ a(
58
+ "div",
59
+ {
60
+ className: "min-w-0 flex-1",
61
+ style: S !== void 0 ? { maxWidth: S } : void 0,
62
+ children: /* @__PURE__ */ a(O, { className: "my-1 block w-full text-sm", children: /* @__PURE__ */ a(
63
+ Ae,
64
+ {
65
+ value: e.title || e.column,
66
+ onSave: (p) => h({ ...e, title: p }),
67
+ isEditable: r,
68
+ placeholder: "Filter",
69
+ displayClassName: "text-sm truncate",
70
+ inputClassName: "text-sm"
71
+ }
72
+ ) })
73
+ }
74
+ ),
75
+ /* @__PURE__ */ l(
76
+ "div",
77
+ {
78
+ className: "flex shrink-0 items-center gap-1.5",
79
+ ref: N,
80
+ children: [
81
+ r && /* @__PURE__ */ a(Ie, { filter: e, isEditing: r }),
82
+ r && /* @__PURE__ */ a(
83
+ "button",
84
+ {
85
+ onClick: () => {
86
+ o(e.id), m(e.id);
87
+ },
88
+ className: "text-muted-foreground hover:text-foreground",
89
+ children: /* @__PURE__ */ a(da, { className: "size-3.5" })
90
+ }
91
+ )
92
+ ]
93
+ }
94
+ )
95
+ ] }),
96
+ /* @__PURE__ */ a("div", { className: "hidden", ref: f })
97
+ ]
98
+ }
99
+ );
100
+ }
101
+ function ya() {
102
+ const e = R((s) => s.dashboard.filters), r = R((s) => s.theme), t = e == null ? void 0 : e.filter((s) => s.hide);
103
+ return t != null && t.length ? /* @__PURE__ */ a(
104
+ "div",
105
+ {
106
+ className: z("mb-1 flex items-center gap-2 border-y px-0.5 pb-0.5", {
107
+ "bg-[repeating-linear-gradient(45deg,_#ffffff_0_3px,_#f3f3f3_3px_6px)]": r === "light",
108
+ "bg-[repeating-linear-gradient(45deg,_#18171d_0_3px,_#272729_3px_6px)]": r === "dark"
109
+ }),
110
+ children: t == null ? void 0 : t.map((s) => /* @__PURE__ */ l(
111
+ "div",
112
+ {
113
+ className: "flex min-w-[250px] max-w-fit flex-col gap-1 p-2",
114
+ children: [
115
+ /* @__PURE__ */ a(pa, { filter: s }),
116
+ /* @__PURE__ */ a(Fe, { filter: s })
117
+ ]
118
+ },
119
+ s.id
120
+ ))
121
+ }
122
+ ) : null;
123
+ }
124
+ function ba() {
125
+ var i;
126
+ const e = R((o) => o.dashboard), r = R((o) => o.selectedSheetId), t = R(
127
+ (o) => o.isDashboardEditing
128
+ ), s = (i = e.sheets) == null ? void 0 : i.find(
129
+ (o) => o.id === r
130
+ ), n = ra(s);
131
+ return /* @__PURE__ */ a(
132
+ "div",
133
+ {
134
+ role: "dashboard-plus-main",
135
+ className: "flex min-h-0 grow basis-0 overflow-hidden",
136
+ children: /* @__PURE__ */ l("section", { className: "flex min-h-0 grow basis-0 flex-col overflow-hidden", children: [
137
+ t && !n && /* @__PURE__ */ a(ya, {}),
138
+ /* @__PURE__ */ a(Le, {})
139
+ ] })
140
+ }
141
+ );
142
+ }
143
+ const ga = ie(() => import("./dashboard-controls-CJI5ZWMq.js")), Sa = ie(
144
+ () => import("./edit-dashboard-visual-D5LjWle1.js")
145
+ ), xa = ie(() => import("./dashboard-json-DLdrFry-.js"));
146
+ function Ga({
147
+ showControls: e = !1,
148
+ showFooter: r = !0,
149
+ ...t
150
+ }) {
151
+ const s = R((m) => m.isVisualEditing), n = R(
152
+ (m) => m.showDashboardJSON
153
+ ), { appearance: i, preferences: o } = t;
154
+ return /* @__PURE__ */ a(ze, { FallbackComponent: Ue, children: /* @__PURE__ */ a(Oe, { dashboardProps: t, children: /* @__PURE__ */ l(je, { children: [
155
+ /* @__PURE__ */ a(Ve, { componentType: "surfboard", componentId: t.id }),
156
+ /* @__PURE__ */ l(We, { appearance: i, children: [
157
+ /* @__PURE__ */ a(
158
+ la,
159
+ {
160
+ toastOptions: {
161
+ classNames: {
162
+ 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]",
163
+ content: "min-w-0 flex-1",
164
+ icon: "mt-0.5 shrink-0",
165
+ title: "max-w-full break-words pr-8",
166
+ description: "max-w-full break-words",
167
+ closeButton: "!top-2 h-6 w-6 rounded-md border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground"
168
+ }
169
+ }
170
+ }
171
+ ),
172
+ /* @__PURE__ */ l(Me, { preferences: o, children: [
173
+ n && /* @__PURE__ */ a(J, { fallback: null, children: /* @__PURE__ */ a(xa, {}) }),
174
+ /* @__PURE__ */ l("main", { className: "relative flex h-full w-full flex-col overflow-hidden", children: [
175
+ e && /* @__PURE__ */ a(J, { fallback: null, children: /* @__PURE__ */ a(ga, {}) }),
176
+ /* @__PURE__ */ a("div", { className: "flex grow overflow-hidden", children: /* @__PURE__ */ a("div", { className: "flex min-w-0 flex-1", children: /* @__PURE__ */ l(Be, { ...t, type: "dashboard", children: [
177
+ s && /* @__PURE__ */ a(J, { fallback: null, children: /* @__PURE__ */ a(Sa, {}) }),
178
+ /* @__PURE__ */ a(De, { mode: s ? "hidden" : "visible", children: /* @__PURE__ */ a(ba, {}) })
179
+ ] }) }) })
180
+ ] })
181
+ ] })
182
+ ] })
183
+ ] }) }) });
184
+ }
185
+ function wa(e = {}) {
186
+ const { authToken: r, tokenProps: t } = Se(), s = R(
187
+ (T) => T.actions.applyResolvedCalendarPreferences
188
+ ), n = e.enabled ?? !0, i = (r == null ? void 0 : r.accessToken) ?? null, o = (t == null ? void 0 : t.apiServiceUrl) ?? null, [m, h] = C(!1), [y, N] = C(!1), [f, S] = C(!1), [b, v] = C(null), [p, k] = C(null), x = M(i);
189
+ x.current = i, U(() => {
190
+ k(null), v(null), h(!1), N(!1), S(!1);
191
+ }, [i]);
192
+ const P = _(async (T) => {
193
+ const c = ha(await T.json());
194
+ if (!c.ok)
195
+ throw new Error("Calendar preferences response is invalid");
196
+ return c.value;
197
+ }, []), E = _(async () => {
198
+ if (!n || !i || !o) return;
199
+ const T = i;
200
+ h(!0), v(null);
201
+ try {
202
+ const c = await fetch(
203
+ `${o}/v1/user-preferences/calendar`,
204
+ {
205
+ method: "GET",
206
+ headers: { Authorization: `Bearer ${i}` }
207
+ }
208
+ );
209
+ if (!c.ok) {
210
+ const w = await c.json().catch(() => ({}));
211
+ throw new Error(w.error || "Failed to fetch preferences");
212
+ }
213
+ const u = await P(c);
214
+ x.current === T && k(u);
215
+ } catch (c) {
216
+ x.current === T && v(c instanceof Error ? c.message : "Unknown error");
217
+ } finally {
218
+ x.current === T && h(!1);
219
+ }
220
+ }, [i, o, n, P]);
221
+ U(() => {
222
+ n && E();
223
+ }, [n, E]);
224
+ const D = _(
225
+ async (T) => {
226
+ if (!i || !o)
227
+ return v("Not authenticated"), !1;
228
+ const c = i;
229
+ N(!0), v(null);
230
+ try {
231
+ const u = await fetch(
232
+ `${o}/v1/user-preferences/calendar`,
233
+ {
234
+ method: "PATCH",
235
+ headers: {
236
+ "Content-Type": "application/json",
237
+ Authorization: `Bearer ${i}`
238
+ },
239
+ body: JSON.stringify(T)
240
+ }
241
+ );
242
+ if (!u.ok) {
243
+ const d = await u.json().catch(() => ({}));
244
+ throw new Error(d.error || "Failed to update preferences");
245
+ }
246
+ const w = await P(u);
247
+ return x.current !== c ? !1 : (k(w), s(w.resolved, w.sources), !0);
248
+ } catch (u) {
249
+ return x.current === c && v(u instanceof Error ? u.message : "Unknown error"), !1;
250
+ } finally {
251
+ x.current === c && N(!1);
252
+ }
253
+ },
254
+ [
255
+ i,
256
+ o,
257
+ s,
258
+ P
259
+ ]
260
+ ), A = _(async () => {
261
+ if (!i || !o)
262
+ return v("Not authenticated"), !1;
263
+ const T = i;
264
+ S(!0), v(null);
265
+ try {
266
+ const c = await fetch(
267
+ `${o}/v1/user-preferences/calendar`,
268
+ {
269
+ method: "DELETE",
270
+ headers: { Authorization: `Bearer ${i}` }
271
+ }
272
+ );
273
+ if (!c.ok) {
274
+ const w = await c.json().catch(() => ({}));
275
+ throw new Error(w.error || "Failed to clear preferences");
276
+ }
277
+ const u = await P(c);
278
+ return x.current !== T ? !1 : (k(u), s(u.resolved, u.sources), !0);
279
+ } catch (c) {
280
+ return x.current === T && v(c instanceof Error ? c.message : "Unknown error"), !1;
281
+ } finally {
282
+ x.current === T && S(!1);
283
+ }
284
+ }, [
285
+ i,
286
+ o,
287
+ s,
288
+ P
289
+ ]);
290
+ return {
291
+ preferences: p,
292
+ isLoading: m,
293
+ isSaving: y,
294
+ isClearing: f,
295
+ error: b,
296
+ updatePreferences: D,
297
+ clearPreferences: A,
298
+ refetch: E
299
+ };
300
+ }
301
+ const G = [
302
+ { value: "America/New_York", label: "Eastern Time (US & Canada)" },
303
+ { value: "America/Chicago", label: "Central Time (US & Canada)" },
304
+ { value: "America/Denver", label: "Mountain Time (US & Canada)" },
305
+ { value: "America/Los_Angeles", label: "Pacific Time (US & Canada)" },
306
+ { value: "America/Phoenix", label: "Arizona" },
307
+ { value: "America/Anchorage", label: "Alaska" },
308
+ { value: "Pacific/Honolulu", label: "Hawaii" },
309
+ { value: "Europe/London", label: "London" },
310
+ { value: "Europe/Paris", label: "Paris, Berlin, Rome" },
311
+ { value: "Asia/Tokyo", label: "Tokyo" },
312
+ { value: "Asia/Shanghai", label: "Beijing, Shanghai" },
313
+ { value: "Asia/Kolkata", label: "Mumbai, New Delhi" },
314
+ { value: "Australia/Sydney", label: "Sydney" },
315
+ { value: "UTC", label: "UTC" }
316
+ ], Te = [
317
+ { value: 0, label: "Sunday" },
318
+ { value: 1, label: "Monday" },
319
+ { value: 6, label: "Saturday" }
320
+ ], ve = "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";
321
+ function Ta() {
322
+ try {
323
+ const e = Intl;
324
+ if (e.supportedValuesOf)
325
+ return e.supportedValuesOf("timeZone");
326
+ } catch {
327
+ }
328
+ return G.map((e) => e.value);
329
+ }
330
+ function Na(e) {
331
+ if (!e) return "default";
332
+ if (e.tz !== e.weekStart) return "inherited";
333
+ switch (e.tz) {
334
+ case "viewer_tenant":
335
+ return "tenant";
336
+ case "viewer_organization":
337
+ return "organization";
338
+ case "system_default":
339
+ return "system";
340
+ case "session_initial":
341
+ return "embedded";
342
+ default:
343
+ return "default";
344
+ }
345
+ }
346
+ function pe(e) {
347
+ const r = G.find((t) => t.value === e);
348
+ return r ? r.label : e;
349
+ }
350
+ function Ca(e) {
351
+ const r = Te.find((t) => t.value === e);
352
+ return r ? r.label : String(e);
353
+ }
354
+ function ka({
355
+ active: e,
356
+ onClose: r
357
+ }) {
358
+ const {
359
+ preferences: t,
360
+ isLoading: s,
361
+ isSaving: n,
362
+ isClearing: i,
363
+ updatePreferences: o,
364
+ clearPreferences: m
365
+ } = wa({ enabled: e }), h = $e(), y = (t == null ? void 0 : t.resolved.tz) || (h == null ? void 0 : h.tz) || "UTC", N = (t == null ? void 0 : t.resolved.weekStart) ?? (h == null ? void 0 : h.weekStart) ?? 1, [f, S] = C((t == null ? void 0 : t.stored) === null), [b, v] = C(!1), [p, k] = C(
366
+ y
367
+ ), [x, P] = C(
368
+ N
369
+ ), [E, D] = C(!1), A = q(() => Ta(), []), T = q(
370
+ () => A.filter(
371
+ (g) => !G.some((Ee) => Ee.value === g)
372
+ ),
373
+ [A]
374
+ ), c = q(() => pe(p), [p]), u = t != null && t.inherited ? pe(t.inherited.tz) : "UTC", w = t != null && t.inherited ? Ca(t.inherited.weekStart) : "Monday", d = Na(
375
+ t == null ? void 0 : t.inheritedSources
376
+ );
377
+ Pe.useEffect(() => {
378
+ if (!e) {
379
+ v(!1);
380
+ return;
381
+ }
382
+ b || (t && S(t.stored === null), k(y), P(N));
383
+ }, [
384
+ e,
385
+ b,
386
+ t,
387
+ y,
388
+ N
389
+ ]);
390
+ const $ = async () => {
391
+ if (s) {
392
+ I.error("Preferences are still loading. Please try again.");
393
+ return;
394
+ }
395
+ f ? await m() ? (I.success("Now using default settings."), r()) : I.error("Failed to save preferences. Please try again.") : await o({
396
+ tz: p,
397
+ weekStart: x
398
+ }) ? (I.success("Preferences saved."), r()) : I.error("Failed to save preferences. Please try again.");
399
+ }, j = () => {
400
+ r();
401
+ }, K = n || i, ke = K || s;
402
+ return /* @__PURE__ */ l(B, { children: [
403
+ /* @__PURE__ */ l("div", { className: "space-y-4 py-1", children: [
404
+ /* @__PURE__ */ l(
405
+ ce,
406
+ {
407
+ value: f ? "defaults" : "custom",
408
+ onValueChange: (g) => {
409
+ v(!0), S(g === "defaults");
410
+ },
411
+ className: "space-y-0.5",
412
+ children: [
413
+ /* @__PURE__ */ l(
414
+ "label",
415
+ {
416
+ htmlFor: "mode-defaults",
417
+ className: z(
418
+ "flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",
419
+ f && "bg-muted/50"
420
+ ),
421
+ onClick: () => {
422
+ v(!0), S(!0);
423
+ },
424
+ children: [
425
+ /* @__PURE__ */ a(
426
+ Z,
427
+ {
428
+ value: "defaults",
429
+ id: "mode-defaults",
430
+ className: "mt-0.5"
431
+ }
432
+ ),
433
+ /* @__PURE__ */ l("div", { className: "flex-1 min-w-0", children: [
434
+ /* @__PURE__ */ l("p", { className: "text-[13px] font-medium text-foreground", children: [
435
+ "Use ",
436
+ d,
437
+ " defaults"
438
+ ] }),
439
+ /* @__PURE__ */ l("p", { className: "text-[12px] text-muted-foreground", children: [
440
+ u,
441
+ ", week starts ",
442
+ w
443
+ ] })
444
+ ] })
445
+ ]
446
+ }
447
+ ),
448
+ /* @__PURE__ */ l(
449
+ "label",
450
+ {
451
+ htmlFor: "mode-custom",
452
+ className: z(
453
+ "flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",
454
+ !f && "bg-muted/50"
455
+ ),
456
+ onClick: () => {
457
+ v(!0), S(!1);
458
+ },
459
+ children: [
460
+ /* @__PURE__ */ a(
461
+ Z,
462
+ {
463
+ value: "custom",
464
+ id: "mode-custom",
465
+ className: "mt-0.5"
466
+ }
467
+ ),
468
+ /* @__PURE__ */ a("p", { className: "flex-1 text-[13px] font-medium text-foreground", children: "Use custom settings" })
469
+ ]
470
+ }
471
+ )
472
+ ]
473
+ }
474
+ ),
475
+ /* @__PURE__ */ l(
476
+ "div",
477
+ {
478
+ className: z(
479
+ "space-y-4 border-t border-border/60 pt-4 transition-opacity",
480
+ f && "pointer-events-none opacity-50"
481
+ ),
482
+ children: [
483
+ /* @__PURE__ */ l("div", { className: "space-y-1.5", children: [
484
+ /* @__PURE__ */ a(O, { className: ve, children: "Timezone" }),
485
+ /* @__PURE__ */ l(
486
+ na,
487
+ {
488
+ open: E,
489
+ onOpenChange: D,
490
+ modal: !0,
491
+ children: [
492
+ /* @__PURE__ */ a(sa, { asChild: !0, children: /* @__PURE__ */ l(
493
+ F,
494
+ {
495
+ variant: "outline",
496
+ size: "xs",
497
+ role: "combobox",
498
+ "aria-expanded": E,
499
+ className: "w-full justify-between text-[12px] font-normal",
500
+ disabled: f,
501
+ children: [
502
+ /* @__PURE__ */ a("span", { className: "truncate", children: c }),
503
+ /* @__PURE__ */ a(He, { className: "ml-2 h-3.5 w-3.5 shrink-0 opacity-50" })
504
+ ]
505
+ }
506
+ ) }),
507
+ /* @__PURE__ */ a(
508
+ ia,
509
+ {
510
+ className: "z-50 w-[--radix-popover-trigger-width] p-0",
511
+ align: "start",
512
+ children: /* @__PURE__ */ l(Ge, { className: "overflow-visible", children: [
513
+ /* @__PURE__ */ a(Ke, { placeholder: "Search timezones…" }),
514
+ /* @__PURE__ */ l(Je, { children: [
515
+ /* @__PURE__ */ a(qe, { children: "No timezone found." }),
516
+ /* @__PURE__ */ a(de, { heading: "Common", children: G.map((g) => /* @__PURE__ */ l(
517
+ ue,
518
+ {
519
+ value: `${g.value} ${g.label}`,
520
+ onSelect: () => {
521
+ v(!0), k(g.value), D(!1);
522
+ },
523
+ children: [
524
+ /* @__PURE__ */ a(
525
+ me,
526
+ {
527
+ className: z(
528
+ "h-3.5 w-3.5",
529
+ p === g.value ? "opacity-100" : "opacity-0"
530
+ )
531
+ }
532
+ ),
533
+ /* @__PURE__ */ a("span", { className: "flex-1", children: g.label }),
534
+ /* @__PURE__ */ a("span", { className: "text-[11px] text-muted-foreground", children: g.value })
535
+ ]
536
+ },
537
+ g.value
538
+ )) }),
539
+ /* @__PURE__ */ a(Ze, {}),
540
+ /* @__PURE__ */ a(de, { heading: "All timezones", children: T.map((g) => /* @__PURE__ */ l(
541
+ ue,
542
+ {
543
+ value: g,
544
+ onSelect: () => {
545
+ v(!0), k(g), D(!1);
546
+ },
547
+ children: [
548
+ /* @__PURE__ */ a(
549
+ me,
550
+ {
551
+ className: z(
552
+ "h-3.5 w-3.5",
553
+ p === g ? "opacity-100" : "opacity-0"
554
+ )
555
+ }
556
+ ),
557
+ g
558
+ ]
559
+ },
560
+ g
561
+ )) })
562
+ ] })
563
+ ] })
564
+ }
565
+ )
566
+ ]
567
+ }
568
+ )
569
+ ] }),
570
+ /* @__PURE__ */ l("div", { className: "space-y-1.5", children: [
571
+ /* @__PURE__ */ a(O, { className: ve, children: "Week starts on" }),
572
+ /* @__PURE__ */ a(
573
+ ce,
574
+ {
575
+ value: String(x),
576
+ onValueChange: (g) => {
577
+ v(!0), P(Number(g));
578
+ },
579
+ className: "flex gap-4",
580
+ disabled: f,
581
+ children: Te.map((g) => /* @__PURE__ */ l(
582
+ "label",
583
+ {
584
+ htmlFor: `week-start-${g.value}`,
585
+ className: z(
586
+ "flex cursor-pointer items-center gap-2 text-[13px]",
587
+ f && "cursor-not-allowed"
588
+ ),
589
+ children: [
590
+ /* @__PURE__ */ a(
591
+ Z,
592
+ {
593
+ value: String(g.value),
594
+ id: `week-start-${g.value}`,
595
+ disabled: f
596
+ }
597
+ ),
598
+ g.label
599
+ ]
600
+ },
601
+ g.value
602
+ ))
603
+ }
604
+ )
605
+ ] })
606
+ ]
607
+ }
608
+ )
609
+ ] }),
610
+ /* @__PURE__ */ l(oe, { children: [
611
+ /* @__PURE__ */ a(
612
+ F,
613
+ {
614
+ variant: "outline",
615
+ size: "xs",
616
+ onClick: j,
617
+ disabled: K,
618
+ children: "Cancel"
619
+ }
620
+ ),
621
+ /* @__PURE__ */ a(F, { size: "xs", onClick: $, disabled: ke, children: K ? /* @__PURE__ */ l(B, { children: [
622
+ /* @__PURE__ */ a(xe, { className: "h-3.5 w-3.5 animate-spin" }),
623
+ "Saving…"
624
+ ] }) : "Save" })
625
+ ] })
626
+ ] });
627
+ }
628
+ function Ea(e = {}) {
629
+ const { authToken: r, tokenProps: t } = Se(), s = R(
630
+ (c) => c.actions.applyResolvedValueFormatPreferences
631
+ ), n = e.enabled ?? !0, i = (r == null ? void 0 : r.accessToken) ?? null, o = (t == null ? void 0 : t.apiServiceUrl) ?? null, m = M(i);
632
+ m.current = i;
633
+ const [h, y] = C(null), [N, f] = C(!1), [S, b] = C(!1), [v, p] = C(!1), [k, x] = C(null);
634
+ U(() => {
635
+ y(null), x(null), f(!1), b(!1), p(!1);
636
+ }, [i]);
637
+ const P = _(async (c) => {
638
+ const u = ua(await c.json());
639
+ if (!u.ok)
640
+ throw new Error("Value format preferences response is invalid");
641
+ return u.value;
642
+ }, []), E = _(
643
+ async (c, u) => {
644
+ if (!i || !o)
645
+ throw new Error("Not authenticated");
646
+ const w = await fetch(
647
+ `${o}/v1/user-preferences/value-format`,
648
+ {
649
+ method: c,
650
+ headers: {
651
+ Authorization: `Bearer ${i}`,
652
+ ...u ? { "Content-Type": "application/json" } : {}
653
+ },
654
+ body: u ? JSON.stringify(u) : void 0
655
+ }
656
+ );
657
+ if (!w.ok) {
658
+ const d = await w.json().catch(() => ({}));
659
+ throw new Error(d.error || "Failed to update preferences");
660
+ }
661
+ return P(w);
662
+ },
663
+ [i, o, P]
664
+ ), D = _(async () => {
665
+ if (!n || !i || !o) return;
666
+ const c = i;
667
+ f(!0), x(null);
668
+ try {
669
+ const u = await E("GET");
670
+ m.current === c && y(u);
671
+ } catch (u) {
672
+ m.current === c && x(u instanceof Error ? u.message : "Unknown error");
673
+ } finally {
674
+ m.current === c && f(!1);
675
+ }
676
+ }, [i, o, n, E]);
677
+ U(() => {
678
+ n && D();
679
+ }, [n, D]);
680
+ const A = _(
681
+ async (c) => {
682
+ const u = i;
683
+ b(!0), x(null);
684
+ try {
685
+ const w = await E("PATCH", c);
686
+ return m.current !== u ? !1 : (y(w), s(w.resolved, w.sources), !0);
687
+ } catch (w) {
688
+ return m.current === u && x(w instanceof Error ? w.message : "Unknown error"), !1;
689
+ } finally {
690
+ m.current === u && b(!1);
691
+ }
692
+ },
693
+ [i, s, E]
694
+ ), T = _(async () => {
695
+ const c = i;
696
+ p(!0), x(null);
697
+ try {
698
+ const u = await E("DELETE");
699
+ return m.current !== c ? !1 : (y(u), s(u.resolved, u.sources), !0);
700
+ } catch (u) {
701
+ return m.current === c && x(u instanceof Error ? u.message : "Unknown error"), !1;
702
+ } finally {
703
+ m.current === c && p(!1);
704
+ }
705
+ }, [i, s, E]);
706
+ return {
707
+ preferences: h,
708
+ isLoading: N,
709
+ isSaving: S,
710
+ isClearing: v,
711
+ error: k,
712
+ updatePreferences: A,
713
+ clearPreferences: T,
714
+ refetch: D
715
+ };
716
+ }
717
+ const ne = [
718
+ { value: "en-US", label: "English (United States)" },
719
+ { value: "en-GB", label: "English (United Kingdom)" },
720
+ { value: "de-DE", label: "German (Germany)" },
721
+ { value: "fr-FR", label: "French (France)" },
722
+ { value: "es-ES", label: "Spanish (Spain)" },
723
+ { value: "it-IT", label: "Italian (Italy)" },
724
+ { value: "nl-NL", label: "Dutch (Netherlands)" },
725
+ { value: "pt-BR", label: "Portuguese (Brazil)" },
726
+ { value: "ja-JP", label: "Japanese (Japan)" },
727
+ { value: "en-IN", label: "English (India)" },
728
+ { value: "en-NZ", label: "English (New Zealand)" },
729
+ { value: "mi-NZ", label: "Māori (New Zealand)" }
730
+ ], Ne = /* @__PURE__ */ new Set([
731
+ "USD",
732
+ "EUR",
733
+ "GBP",
734
+ "CAD",
735
+ "AUD",
736
+ "JPY",
737
+ "CHF",
738
+ "INR",
739
+ "BRL",
740
+ "KWD"
741
+ ]), Pa = ma(), Da = Pa.filter(
742
+ (e) => !Ne.has(e)
743
+ ), Ce = [
744
+ { value: "short", label: "Short" },
745
+ { value: "medium", label: "Medium" },
746
+ { value: "long", label: "Long" }
747
+ ], ye = "2026-07-31", Y = "2026-07-31T14:30:45";
748
+ function se(e) {
749
+ switch (e) {
750
+ case "viewer_user":
751
+ return "user";
752
+ case "viewer_tenant_user":
753
+ return "tenant user";
754
+ case "viewer_tenant":
755
+ return "tenant";
756
+ case "viewer_organization":
757
+ return "organization";
758
+ case "session_initial":
759
+ return "embedded session";
760
+ case "system_default":
761
+ return "system";
762
+ default:
763
+ return "another preference level";
764
+ }
765
+ }
766
+ function X(e) {
767
+ var r;
768
+ return ((r = Ce.find((t) => t.value === e)) == null ? void 0 : r.label) ?? e;
769
+ }
770
+ function Ra(e) {
771
+ const r = ne.find((t) => t.value === e);
772
+ return r ? `${r.label} — ${r.value}` : e;
773
+ }
774
+ function Q(e) {
775
+ return {
776
+ short: e("short"),
777
+ medium: e("medium"),
778
+ long: e("long")
779
+ };
780
+ }
781
+ function ee({
782
+ id: e,
783
+ label: r,
784
+ value: t,
785
+ inherited: s,
786
+ inheritedSource: n,
787
+ examples: i,
788
+ disabled: o,
789
+ onValueChange: m
790
+ }) {
791
+ const h = t === void 0 ? `Inherited · ${X(s)}` : X(t);
792
+ return /* @__PURE__ */ l("div", { className: "space-y-1.5", children: [
793
+ /* @__PURE__ */ a(O, { htmlFor: e, className: "text-[11px] text-muted-foreground", children: r }),
794
+ /* @__PURE__ */ l(
795
+ ae,
796
+ {
797
+ value: t ?? "inherit",
798
+ disabled: o,
799
+ onValueChange: m,
800
+ children: [
801
+ /* @__PURE__ */ a(te, { id: e, size: "xs", children: /* @__PURE__ */ a(re, { children: h }) }),
802
+ /* @__PURE__ */ l(le, { children: [
803
+ /* @__PURE__ */ a(L, { value: "inherit", className: "[&>span:last-child]:w-full", children: /* @__PURE__ */ l("span", { className: "flex w-full min-w-0 items-center justify-between gap-4", children: [
804
+ /* @__PURE__ */ l("span", { children: [
805
+ "Inherited from ",
806
+ se(n),
807
+ " ·",
808
+ " ",
809
+ X(s)
810
+ ] }),
811
+ /* @__PURE__ */ a("span", { className: "shrink-0 tabular-nums text-muted-foreground", children: i[s] })
812
+ ] }) }),
813
+ Ce.map((y) => /* @__PURE__ */ a(
814
+ L,
815
+ {
816
+ value: y.value,
817
+ className: "[&>span:last-child]:w-full",
818
+ children: /* @__PURE__ */ l("span", { className: "flex w-full min-w-0 items-center justify-between gap-4", children: [
819
+ /* @__PURE__ */ a("span", { children: y.label }),
820
+ /* @__PURE__ */ a("span", { className: "shrink-0 tabular-nums text-muted-foreground", children: i[y.value] })
821
+ ] })
822
+ },
823
+ y.value
824
+ ))
825
+ ] })
826
+ ]
827
+ }
828
+ )
829
+ ] });
830
+ }
831
+ function _a({
832
+ value: e,
833
+ inherited: r,
834
+ inheritedSources: t,
835
+ onChange: s,
836
+ disabled: n
837
+ }) {
838
+ var T, c, u, w;
839
+ const i = V(), o = V(), m = V(), h = V(), y = V(), f = (e.locale === void 0 ? void 0 : we(e.locale)) ?? r.locale, S = e.defaultCurrency ?? r.defaultCurrency, b = {
840
+ locale: f,
841
+ dateStyle: e.dateStyle ?? r.dateStyle,
842
+ dateTime: {
843
+ dateStyle: ((T = e.dateTime) == null ? void 0 : T.dateStyle) ?? r.dateTime.dateStyle,
844
+ timeStyle: ((c = e.dateTime) == null ? void 0 : c.timeStyle) ?? r.dateTime.timeStyle
845
+ },
846
+ defaultCurrency: S
847
+ }, v = new Intl.NumberFormat(f, {
848
+ style: "currency",
849
+ currency: S
850
+ }).format(1e3), p = H({
851
+ preferences: b,
852
+ calendar: { tz: "UTC" }
853
+ }), k = W({
854
+ value: ye,
855
+ metadata: { kind: "raw_temporal", valueKind: "date" },
856
+ format: p
857
+ }).text, x = W({
858
+ value: Y,
859
+ metadata: { kind: "raw_temporal", valueKind: "wall_datetime" },
860
+ format: p
861
+ }).text, P = Q(
862
+ (d) => W({
863
+ value: ye,
864
+ metadata: { kind: "raw_temporal", valueKind: "date" },
865
+ format: H({
866
+ preferences: { ...b, dateStyle: d },
867
+ calendar: { tz: "UTC" }
868
+ })
869
+ }).text
870
+ ), E = Q(
871
+ (d) => W({
872
+ value: Y,
873
+ metadata: { kind: "raw_temporal", valueKind: "wall_datetime" },
874
+ format: H({
875
+ preferences: {
876
+ ...b,
877
+ dateTime: { ...b.dateTime, dateStyle: d }
878
+ },
879
+ calendar: { tz: "UTC" }
880
+ })
881
+ }).text
882
+ ), D = Q(
883
+ (d) => W({
884
+ value: Y,
885
+ metadata: { kind: "raw_temporal", valueKind: "wall_datetime" },
886
+ format: H({
887
+ preferences: {
888
+ ...b,
889
+ dateTime: { ...b.dateTime, timeStyle: d }
890
+ },
891
+ calendar: { tz: "UTC" }
892
+ })
893
+ }).text
894
+ ), A = (d, $) => {
895
+ const j = {
896
+ ...e.dateTime,
897
+ [d]: $ === "inherit" ? void 0 : $
898
+ };
899
+ s({
900
+ ...e,
901
+ dateTime: j.dateStyle === void 0 && j.timeStyle === void 0 ? void 0 : j
902
+ });
903
+ };
904
+ return /* @__PURE__ */ l("div", { className: "space-y-4", children: [
905
+ /* @__PURE__ */ l("div", { className: "space-y-1.5", children: [
906
+ /* @__PURE__ */ a(
907
+ O,
908
+ {
909
+ htmlFor: i,
910
+ className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",
911
+ children: "Locale"
912
+ }
913
+ ),
914
+ /* @__PURE__ */ l(
915
+ ae,
916
+ {
917
+ value: e.locale ?? "inherit",
918
+ disabled: n,
919
+ onValueChange: (d) => s({
920
+ ...e,
921
+ locale: d === "inherit" ? void 0 : d
922
+ }),
923
+ children: [
924
+ /* @__PURE__ */ a(te, { id: i, size: "xs", children: /* @__PURE__ */ a(re, { children: e.locale === void 0 ? `Inherited · ${r.locale}` : Ra(e.locale) }) }),
925
+ /* @__PURE__ */ l(le, { children: [
926
+ /* @__PURE__ */ l(L, { value: "inherit", children: [
927
+ "Inherited from ",
928
+ se(t.locale),
929
+ " ·",
930
+ " ",
931
+ r.locale
932
+ ] }),
933
+ e.locale && !ne.some(
934
+ (d) => d.value === e.locale
935
+ ) && /* @__PURE__ */ a(L, { value: e.locale, children: e.locale }),
936
+ ne.map((d) => /* @__PURE__ */ l(L, { value: d.value, children: [
937
+ d.label,
938
+ " — ",
939
+ d.value
940
+ ] }, d.value))
941
+ ] })
942
+ ]
943
+ }
944
+ )
945
+ ] }),
946
+ /* @__PURE__ */ l("fieldset", { className: "space-y-2", children: [
947
+ /* @__PURE__ */ a("legend", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Date values" }),
948
+ /* @__PURE__ */ a(
949
+ ee,
950
+ {
951
+ id: m,
952
+ label: "Format",
953
+ value: e.dateStyle,
954
+ inherited: r.dateStyle,
955
+ inheritedSource: t.dateStyle,
956
+ examples: P,
957
+ disabled: n,
958
+ onValueChange: (d) => s({
959
+ ...e,
960
+ dateStyle: d === "inherit" ? void 0 : d
961
+ })
962
+ }
963
+ )
964
+ ] }),
965
+ /* @__PURE__ */ l("fieldset", { className: "space-y-2", children: [
966
+ /* @__PURE__ */ a("legend", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Date & time values" }),
967
+ /* @__PURE__ */ a(
968
+ ee,
969
+ {
970
+ id: h,
971
+ label: "Date",
972
+ value: (u = e.dateTime) == null ? void 0 : u.dateStyle,
973
+ inherited: r.dateTime.dateStyle,
974
+ inheritedSource: t.dateTime.dateStyle,
975
+ examples: E,
976
+ disabled: n,
977
+ onValueChange: (d) => A("dateStyle", d)
978
+ }
979
+ ),
980
+ /* @__PURE__ */ a(
981
+ ee,
982
+ {
983
+ id: y,
984
+ label: "Time",
985
+ value: (w = e.dateTime) == null ? void 0 : w.timeStyle,
986
+ inherited: r.dateTime.timeStyle,
987
+ inheritedSource: t.dateTime.timeStyle,
988
+ examples: D,
989
+ disabled: n,
990
+ onValueChange: (d) => A("timeStyle", d)
991
+ }
992
+ )
993
+ ] }),
994
+ /* @__PURE__ */ l("div", { className: "space-y-1.5", children: [
995
+ /* @__PURE__ */ a(
996
+ O,
997
+ {
998
+ htmlFor: o,
999
+ className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",
1000
+ children: "Default currency"
1001
+ }
1002
+ ),
1003
+ /* @__PURE__ */ l(
1004
+ ae,
1005
+ {
1006
+ value: e.defaultCurrency ?? "inherit",
1007
+ disabled: n,
1008
+ onValueChange: (d) => s({
1009
+ ...e,
1010
+ defaultCurrency: d === "inherit" ? void 0 : d
1011
+ }),
1012
+ children: [
1013
+ /* @__PURE__ */ a(te, { id: o, size: "xs", children: /* @__PURE__ */ a(re, { children: e.defaultCurrency === void 0 ? `Inherited · ${r.defaultCurrency}` : e.defaultCurrency }) }),
1014
+ /* @__PURE__ */ l(le, { children: [
1015
+ /* @__PURE__ */ l(L, { value: "inherit", children: [
1016
+ "Inherited from ",
1017
+ se(t.defaultCurrency),
1018
+ " ·",
1019
+ " ",
1020
+ r.defaultCurrency
1021
+ ] }),
1022
+ [...Ne].map((d) => /* @__PURE__ */ a(L, { value: d, children: d }, d)),
1023
+ Da.map((d) => /* @__PURE__ */ a(L, { value: d, children: d }, d))
1024
+ ] })
1025
+ ]
1026
+ }
1027
+ )
1028
+ ] }),
1029
+ /* @__PURE__ */ l("div", { className: "rounded-control border border-border/60 bg-muted/30 px-3 py-2", children: [
1030
+ /* @__PURE__ */ a("p", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Preview" }),
1031
+ /* @__PURE__ */ l("dl", { className: "mt-1.5 space-y-1 text-[12px]", children: [
1032
+ /* @__PURE__ */ l("div", { className: "flex items-baseline justify-between gap-4", children: [
1033
+ /* @__PURE__ */ a("dt", { className: "text-muted-foreground", children: "Date" }),
1034
+ /* @__PURE__ */ a("dd", { className: "text-right font-medium text-foreground", children: k })
1035
+ ] }),
1036
+ /* @__PURE__ */ l("div", { className: "flex items-baseline justify-between gap-4", children: [
1037
+ /* @__PURE__ */ a("dt", { className: "text-muted-foreground", children: "Date & time" }),
1038
+ /* @__PURE__ */ a("dd", { className: "text-right font-medium text-foreground", children: x })
1039
+ ] }),
1040
+ /* @__PURE__ */ l("div", { className: "flex items-baseline justify-between gap-4", children: [
1041
+ /* @__PURE__ */ a("dt", { className: "text-muted-foreground", children: "Currency" }),
1042
+ /* @__PURE__ */ a("dd", { className: "text-right font-medium text-foreground", children: v })
1043
+ ] })
1044
+ ] })
1045
+ ] }),
1046
+ /* @__PURE__ */ a("p", { className: "text-[11px] text-muted-foreground", children: "Currency values are not converted. Date examples use a fixed reference value and the Gregorian calendar." })
1047
+ ] });
1048
+ }
1049
+ const be = [
1050
+ "locale",
1051
+ "dateStyle",
1052
+ "dateTime.dateStyle",
1053
+ "dateTime.timeStyle",
1054
+ "defaultCurrency"
1055
+ ];
1056
+ function ge(e, r) {
1057
+ var t, s;
1058
+ switch (r) {
1059
+ case "locale":
1060
+ return e == null ? void 0 : e.locale;
1061
+ case "dateStyle":
1062
+ return e == null ? void 0 : e.dateStyle;
1063
+ case "dateTime.dateStyle":
1064
+ return (t = e == null ? void 0 : e.dateTime) == null ? void 0 : t.dateStyle;
1065
+ case "dateTime.timeStyle":
1066
+ return (s = e == null ? void 0 : e.dateTime) == null ? void 0 : s.timeStyle;
1067
+ case "defaultCurrency":
1068
+ return e == null ? void 0 : e.defaultCurrency;
1069
+ }
1070
+ }
1071
+ function Aa(e) {
1072
+ var s, n;
1073
+ const r = (s = e == null ? void 0 : e.dateTime) == null ? void 0 : s.dateStyle, t = (n = e == null ? void 0 : e.dateTime) == null ? void 0 : n.timeStyle;
1074
+ return {
1075
+ locale: e == null ? void 0 : e.locale,
1076
+ dateStyle: e == null ? void 0 : e.dateStyle,
1077
+ dateTime: r === void 0 && t === void 0 ? void 0 : { dateStyle: r, timeStyle: t },
1078
+ defaultCurrency: e == null ? void 0 : e.defaultCurrency
1079
+ };
1080
+ }
1081
+ function Ia({
1082
+ active: e,
1083
+ onClose: r
1084
+ }) {
1085
+ var m, h, y, N, f, S, b;
1086
+ const { preferences: t, isLoading: s, isSaving: n, updatePreferences: i } = Ea({ enabled: e });
1087
+ if (!e) return null;
1088
+ if (!t)
1089
+ return /* @__PURE__ */ l(B, { children: [
1090
+ /* @__PURE__ */ a("div", { className: "py-2", children: /* @__PURE__ */ a("div", { className: "flex min-h-36 items-center justify-center text-[12px] text-muted-foreground", children: s ? "Loading preferences…" : "Preferences unavailable." }) }),
1091
+ /* @__PURE__ */ l(oe, { className: "justify-between sm:justify-between", children: [
1092
+ /* @__PURE__ */ a(F, { variant: "ghost", size: "xs", disabled: !0, children: "Reset display formats" }),
1093
+ /* @__PURE__ */ l("div", { className: "flex gap-2", children: [
1094
+ /* @__PURE__ */ a(F, { variant: "outline", size: "xs", onClick: r, children: "Cancel" }),
1095
+ /* @__PURE__ */ a(F, { size: "xs", disabled: !0, children: "Save" })
1096
+ ] })
1097
+ ] })
1098
+ ] });
1099
+ const o = [
1100
+ ((m = t.stored) == null ? void 0 : m.locale) ?? "",
1101
+ ((h = t.stored) == null ? void 0 : h.dateStyle) ?? "",
1102
+ ((N = (y = t.stored) == null ? void 0 : y.dateTime) == null ? void 0 : N.dateStyle) ?? "",
1103
+ ((S = (f = t.stored) == null ? void 0 : f.dateTime) == null ? void 0 : S.timeStyle) ?? "",
1104
+ ((b = t.stored) == null ? void 0 : b.defaultCurrency) ?? ""
1105
+ ].join(":");
1106
+ return /* @__PURE__ */ a(
1107
+ Fa,
1108
+ {
1109
+ preferences: t,
1110
+ isSaving: n,
1111
+ updatePreferences: i,
1112
+ onClose: r
1113
+ },
1114
+ o
1115
+ );
1116
+ }
1117
+ function Fa({
1118
+ preferences: e,
1119
+ isSaving: r,
1120
+ updatePreferences: t,
1121
+ onClose: s
1122
+ }) {
1123
+ var y, N;
1124
+ const [n, i] = C(
1125
+ () => Aa(e.stored)
1126
+ ), o = (n.locale === void 0 || we(n.locale) !== void 0) && (n.defaultCurrency === void 0 || fa(n.defaultCurrency) !== void 0) && (n.dateStyle === void 0 || ["short", "medium", "long"].includes(n.dateStyle)) && (((y = n.dateTime) == null ? void 0 : y.dateStyle) === void 0 || ["short", "medium", "long"].includes(n.dateTime.dateStyle)) && (((N = n.dateTime) == null ? void 0 : N.timeStyle) === void 0 || ["short", "medium", "long"].includes(n.dateTime.timeStyle)), m = async () => {
1127
+ const f = {
1128
+ ...n.locale !== void 0 ? { locale: n.locale } : {},
1129
+ ...n.dateStyle !== void 0 ? { dateStyle: n.dateStyle } : {},
1130
+ ...n.dateTime ? { dateTime: { ...n.dateTime } } : {},
1131
+ ...n.defaultCurrency !== void 0 ? { defaultCurrency: n.defaultCurrency } : {}
1132
+ }, S = be.filter(
1133
+ (p) => ge(n, p) === void 0 && ge(e.stored, p) !== void 0
1134
+ ), b = {
1135
+ ...Object.keys(f).length > 0 ? { set: f } : {},
1136
+ ...S.length > 0 ? { clear: S } : {}
1137
+ };
1138
+ (Object.keys(b).length === 0 ? !0 : await t(b)) ? (I.success("Display format preferences saved."), s()) : I.error("Failed to save preferences. Please try again.");
1139
+ }, h = async () => {
1140
+ await t({
1141
+ clear: [...be]
1142
+ }) ? (I.success("Display format preferences reset."), s()) : I.error(
1143
+ "Failed to reset display format preferences. Please try again."
1144
+ );
1145
+ };
1146
+ return /* @__PURE__ */ l(B, { children: [
1147
+ /* @__PURE__ */ a("div", { className: "py-2", children: /* @__PURE__ */ a(
1148
+ _a,
1149
+ {
1150
+ value: n,
1151
+ inherited: e.inherited,
1152
+ inheritedSources: e.inheritedSources,
1153
+ onChange: i,
1154
+ disabled: r
1155
+ }
1156
+ ) }),
1157
+ /* @__PURE__ */ l(oe, { className: "justify-between sm:justify-between", children: [
1158
+ /* @__PURE__ */ a(
1159
+ F,
1160
+ {
1161
+ variant: "ghost",
1162
+ size: "xs",
1163
+ onClick: h,
1164
+ disabled: r || e.stored === null,
1165
+ children: "Reset display formats"
1166
+ }
1167
+ ),
1168
+ /* @__PURE__ */ l("div", { className: "flex gap-2", children: [
1169
+ /* @__PURE__ */ a(
1170
+ F,
1171
+ {
1172
+ variant: "outline",
1173
+ size: "xs",
1174
+ onClick: s,
1175
+ disabled: r,
1176
+ children: "Cancel"
1177
+ }
1178
+ ),
1179
+ /* @__PURE__ */ a(
1180
+ F,
1181
+ {
1182
+ size: "xs",
1183
+ onClick: m,
1184
+ disabled: r || !o,
1185
+ children: r ? /* @__PURE__ */ l(B, { children: [
1186
+ /* @__PURE__ */ a(xe, { className: "h-3.5 w-3.5 animate-spin" }),
1187
+ "Saving…"
1188
+ ] }) : "Save"
1189
+ }
1190
+ )
1191
+ ] })
1192
+ ] })
1193
+ ] });
1194
+ }
1195
+ function Ka({
1196
+ open: e,
1197
+ onOpenChange: r
1198
+ }) {
1199
+ const [t, s] = C("display"), n = () => r(!1);
1200
+ return /* @__PURE__ */ a(Ye, { open: e, onOpenChange: r, children: /* @__PURE__ */ l(Xe, { className: "rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control", children: [
1201
+ /* @__PURE__ */ l(Qe, { children: [
1202
+ /* @__PURE__ */ a(ea, { className: "text-[15px]", children: "Report preferences" }),
1203
+ /* @__PURE__ */ a(aa, { className: "text-[13px] leading-5", children: "Set how values and Calendar periods appear for you." })
1204
+ ] }),
1205
+ /* @__PURE__ */ l(oa, { value: t, onValueChange: s, children: [
1206
+ /* @__PURE__ */ l(ca, { variant: "underline", className: "w-full justify-start", children: [
1207
+ /* @__PURE__ */ a(fe, { value: "display", children: "Display formats" }),
1208
+ /* @__PURE__ */ a(fe, { value: "calendar", children: "Calendar" })
1209
+ ] }),
1210
+ /* @__PURE__ */ a(he, { value: "display", children: /* @__PURE__ */ a(
1211
+ Ia,
1212
+ {
1213
+ active: e && t === "display",
1214
+ onClose: n
1215
+ }
1216
+ ) }),
1217
+ /* @__PURE__ */ a(he, { value: "calendar", children: /* @__PURE__ */ a(
1218
+ ka,
1219
+ {
1220
+ active: e && t === "calendar",
1221
+ onClose: n
1222
+ }
1223
+ ) })
1224
+ ] })
1225
+ ] }) });
1226
+ }
1227
+ export {
1228
+ Ga as D,
1229
+ Ka as R,
1230
+ _a as a
1231
+ };