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,72 +0,0 @@
1
- import { z as e } from "zod";
2
- const p = 5 * 1024 * 1024, s = e.number().int().positive().max(Number.MAX_SAFE_INTEGER), r = e.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER), c = r.refine((t) => t > 0), l = (t) => !!t && t !== "." && t !== ".." && !t.includes("/") && !t.includes("\\");
3
- function a(t, i) {
4
- const n = i.split("/");
5
- if (n.length !== 5 || n[0] !== "exports" || n[1] !== t || n[2] !== "attempts" || !n.every(l))
6
- throw new Error("Invalid Matrix export artifact namespace.");
7
- return { attemptId: n[3], filename: n[4] };
8
- }
9
- function y(t, i, n) {
10
- const o = `exports/${t}/attempts/${i}/${n}`;
11
- return a(t, o), o;
12
- }
13
- const E = e.object({
14
- acquisition: e.literal("continuation"),
15
- jobId: e.string().min(1),
16
- sequence: c,
17
- deadlineAt: s
18
- }), f = e.object({
19
- key: e.string(),
20
- content: e.string(),
21
- contentType: e.enum(["text/csv", "application/json"]),
22
- encoding: e.literal("gzip-base64").optional()
23
- }).refine((t) => !t.encoding || t.contentType === "application/json", "Unsupported Matrix artifact encoding."), h = e.discriminatedUnion("kind", [
24
- e.object({ kind: e.literal("work"), sequence: c, checkpointKey: e.string(), objects: e.array(f).min(2).max(3), deadlineAt: s }),
25
- e.object({ kind: e.literal("committed"), sequence: c, done: e.boolean(), deadlineAt: s })
26
- ]);
27
- function x(t) {
28
- const i = JSON.stringify(t);
29
- if (i === void 0 || new TextEncoder().encode(i).byteLength > p)
30
- throw new RangeError("Matrix export batch exceeds its transport byte limit.");
31
- }
32
- function M(t, i) {
33
- const n = h.parse(t);
34
- if (x(t), n.deadlineAt !== i.deadlineAt) throw new Error("Matrix deadline does not match the job.");
35
- if (n.sequence !== i.sequence + (n.kind === "committed" ? 1 : 0))
36
- throw new Error("Invalid Matrix batch sequence.");
37
- if (n.kind === "work") {
38
- a(i.jobId, n.checkpointKey);
39
- for (const o of n.objects)
40
- a(i.jobId, o.key);
41
- }
42
- return n;
43
- }
44
- const b = e.object({
45
- acquisition: e.literal("continuation"),
46
- deadlineAt: s,
47
- chunks: e.array(e.object({ chunkNumber: c, dataKey: e.string() })).min(1),
48
- totalRows: r,
49
- totalBytes: r,
50
- fileKey: e.string().min(1).optional(),
51
- fileSize: r.optional()
52
- }).refine((t) => t.fileKey === void 0 == (t.fileSize === void 0), "Incomplete published Matrix artifact.");
53
- function g(t, i, n) {
54
- const o = b.parse(t);
55
- if (o.deadlineAt !== n) throw new Error("Matrix deadline does not match the job.");
56
- return o.chunks.forEach((d, m) => {
57
- if (d.chunkNumber !== m + 1) throw new Error("Invalid committed Matrix chunk order.");
58
- a(i, d.dataKey);
59
- }), o.fileKey !== void 0 && a(i, o.fileKey), o;
60
- }
61
- export {
62
- p as M,
63
- y as a,
64
- E as b,
65
- h as c,
66
- x as d,
67
- M as e,
68
- b as f,
69
- g,
70
- s as m,
71
- a as p
72
- };
@@ -1,636 +0,0 @@
1
- var te = Object.defineProperty;
2
- var re = (e, t, o) => t in e ? te(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
3
- var x = (e, t, o) => re(e, typeof t != "symbol" ? t + "" : t, o);
4
- import { h as oe, f as ne, aa as ie, a0 as ae, G, a1 as se, az as P, B as ce, u as j, ai as le } from "./validators-DMSH81OM.js";
5
- import { C as A } from "./common-types-g7yS12Cg.js";
6
- import "./matrix-operation-contract-BKupLHXL.js";
7
- import { ZodError as de } from "zod";
8
- import { q as ue, v as ge } from "./calculated-field-identity-BptYhyOP.js";
9
- import { v as fe } from "./field-aggregations-CoLzYHeL.js";
10
- import { a as H } from "./matrix-card-CAdizkUl.js";
11
- import { m as Y, a as Z } from "./constants-DNWVy8Y3.js";
12
- function me(e, t) {
13
- const r = Ne(e);
14
- let i;
15
- if (r.date) {
16
- const g = Oe(r.date, 2);
17
- i = Te(g.restDateString, g.year);
18
- }
19
- if (!i || isNaN(i.getTime()))
20
- return /* @__PURE__ */ new Date(NaN);
21
- const a = i.getTime();
22
- let d = 0, u;
23
- if (r.time && (d = De(r.time), isNaN(d)))
24
- return /* @__PURE__ */ new Date(NaN);
25
- if (r.timezone) {
26
- if (u = he(r.timezone), isNaN(u))
27
- return /* @__PURE__ */ new Date(NaN);
28
- } else {
29
- const g = new Date(a + d), O = /* @__PURE__ */ new Date(0);
30
- return O.setFullYear(
31
- g.getUTCFullYear(),
32
- g.getUTCMonth(),
33
- g.getUTCDate()
34
- ), O.setHours(
35
- g.getUTCHours(),
36
- g.getUTCMinutes(),
37
- g.getUTCSeconds(),
38
- g.getUTCMilliseconds()
39
- ), O;
40
- }
41
- return new Date(a + d + u);
42
- }
43
- const b = {
44
- dateTimeDelimiter: /[T ]/,
45
- timeZoneDelimiter: /[Z ]/i,
46
- timezone: /([Z+-].*)$/
47
- }, pe = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/, Ie = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/, _e = /^([+-])(\d{2})(?::?(\d{2}))?$/;
48
- function Ne(e) {
49
- const t = {}, o = e.split(b.dateTimeDelimiter);
50
- let r;
51
- if (o.length > 2)
52
- return t;
53
- if (/:/.test(o[0]) ? r = o[0] : (t.date = o[0], r = o[1], b.timeZoneDelimiter.test(t.date) && (t.date = e.split(b.timeZoneDelimiter)[0], r = e.substr(
54
- t.date.length,
55
- e.length
56
- ))), r) {
57
- const i = b.timezone.exec(r);
58
- i ? (t.time = r.replace(i[1], ""), t.timezone = i[1]) : t.time = r;
59
- }
60
- return t;
61
- }
62
- function Oe(e, t) {
63
- const o = new RegExp(
64
- "^(?:(\\d{4}|[+-]\\d{" + (4 + t) + "})|(\\d{2}|[+-]\\d{" + (2 + t) + "})$)"
65
- ), r = e.match(o);
66
- if (!r) return { year: NaN, restDateString: "" };
67
- const i = r[1] ? parseInt(r[1]) : null, a = r[2] ? parseInt(r[2]) : null;
68
- return {
69
- year: a === null ? i : a * 100,
70
- restDateString: e.slice((r[1] || r[2]).length)
71
- };
72
- }
73
- function Te(e, t) {
74
- if (t === null) return /* @__PURE__ */ new Date(NaN);
75
- const o = e.match(pe);
76
- if (!o) return /* @__PURE__ */ new Date(NaN);
77
- const r = !!o[4], i = R(o[1]), a = R(o[2]) - 1, d = R(o[3]), u = R(o[4]), g = R(o[5]) - 1;
78
- if (r)
79
- return Re(t, u, g) ? Ce(t, u, g) : /* @__PURE__ */ new Date(NaN);
80
- {
81
- const O = /* @__PURE__ */ new Date(0);
82
- return !we(t, a, d) || !Ee(t, i) ? /* @__PURE__ */ new Date(NaN) : (O.setUTCFullYear(t, a, Math.max(i, d)), O);
83
- }
84
- }
85
- function R(e) {
86
- return e ? parseInt(e) : 1;
87
- }
88
- function De(e) {
89
- const t = e.match(Ie);
90
- if (!t) return NaN;
91
- const o = v(t[1]), r = v(t[2]), i = v(t[3]);
92
- return be(o, r, i) ? o * Y + r * Z + i * 1e3 : NaN;
93
- }
94
- function v(e) {
95
- return e && parseFloat(e.replace(",", ".")) || 0;
96
- }
97
- function he(e) {
98
- if (e === "Z") return 0;
99
- const t = e.match(_e);
100
- if (!t) return 0;
101
- const o = t[1] === "+" ? -1 : 1, r = parseInt(t[2]), i = t[3] && parseInt(t[3]) || 0;
102
- return Ae(r, i) ? o * (r * Y + i * Z) : NaN;
103
- }
104
- function Ce(e, t, o) {
105
- const r = /* @__PURE__ */ new Date(0);
106
- r.setUTCFullYear(e, 0, 4);
107
- const i = r.getUTCDay() || 7, a = (t - 1) * 7 + o + 1 - i;
108
- return r.setUTCDate(r.getUTCDate() + a), r;
109
- }
110
- const ye = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
111
- function W(e) {
112
- return e % 400 === 0 || e % 4 === 0 && e % 100 !== 0;
113
- }
114
- function we(e, t, o) {
115
- return t >= 0 && t <= 11 && o >= 1 && o <= (ye[t] || (W(e) ? 29 : 28));
116
- }
117
- function Ee(e, t) {
118
- return t >= 1 && t <= (W(e) ? 366 : 365);
119
- }
120
- function Re(e, t, o) {
121
- return t >= 1 && t <= 53 && o >= 0 && o <= 6;
122
- }
123
- function be(e, t, o) {
124
- return e === 24 ? t === 0 && o === 0 : o >= 0 && o < 60 && t >= 0 && t < 60 && e >= 0 && e < 25;
125
- }
126
- function Ae(e, t) {
127
- return t >= 0 && t <= 59;
128
- }
129
- const tt = [
130
- "lg",
131
- "md",
132
- "sm",
133
- "xs",
134
- "xxs"
135
- ], rt = 15;
136
- function Se(e, t) {
137
- return e.name === t.name && e.qualifiedEntityName === t.qualifiedEntityName;
138
- }
139
- function ot(e, t, o) {
140
- var i, a;
141
- if (o.sortPolicy === "dropUnrelatedSorts") {
142
- const d = new Set(
143
- (e.metricColumns || []).map((u) => u.id)
144
- );
145
- return {
146
- ...e,
147
- groupByColumns: [t],
148
- sortByColumns: (e.sortByColumns || []).filter(
149
- (u) => u.id === t.id || d.has(u.id)
150
- )
151
- };
152
- }
153
- const r = (i = e.groupByColumns) == null ? void 0 : i[0];
154
- return {
155
- ...e,
156
- groupByColumns: [t],
157
- sortByColumns: (a = e.sortByColumns) == null ? void 0 : a.map(
158
- (d) => r && Se(d, r) ? {
159
- ...t,
160
- role: "sortby",
161
- direction: d.direction
162
- } : d
163
- )
164
- };
165
- }
166
- function nt(e, t) {
167
- return `${e}-${t}`;
168
- }
169
- const it = "CONTROL_PLACEHOLDER_QUOTED", xe = "CONTROL_REFERENCE_MISSING", ve = "CONTROL_VALUE_MISSING", at = "CONTROL_VALUE_INVALID", st = "CONTROL_CONTEXT_UNSUPPORTED", Le = "CONTROL_DEFINITION_DUPLICATE", Ve = "CONTROL_DEFINITION_INVALID", L = "CONTROL_BINDING_MAPPING_MISSING", Me = "CONTROL_BINDING_TARGET_INVALID", q = "CONTROL_BINDING_VALUE_INVALID";
170
- class I extends Error {
171
- constructor(o, r) {
172
- super(o);
173
- x(this, "status", 400);
174
- x(this, "details");
175
- Object.setPrototypeOf(this, I.prototype), this.name = "ControlResolutionError", this.details = r;
176
- }
177
- }
178
- function X(e, t) {
179
- const o = /* @__PURE__ */ new Map();
180
- for (const r of [...e, ...t]) {
181
- if (!r || typeof r != "object" || typeof r.id != "string" || r.id.trim().length === 0)
182
- throw new I(
183
- "Malformed control definition was provided for query execution.",
184
- {
185
- code: Ve
186
- }
187
- );
188
- if (o.get(r.id))
189
- throw new I(
190
- `Duplicate control definition '${r.id}' was provided for query execution.`,
191
- {
192
- code: Le,
193
- controlId: r.id
194
- }
195
- );
196
- o.set(r.id, r);
197
- }
198
- return o;
199
- }
200
- const Fe = /^-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/;
201
- function Ue(e) {
202
- switch (e.source.kind) {
203
- case "manual":
204
- return e.source.options.map((t) => t.value);
205
- case "field_allowlist":
206
- return e.source.fieldIds;
207
- case "metric_allowlist":
208
- return e.source.metricIds;
209
- case "dataset_values":
210
- return null;
211
- default:
212
- return null;
213
- }
214
- }
215
- function T(e) {
216
- return `${e.label || e.id} (${e.id})`;
217
- }
218
- function $e(e) {
219
- return e.type === "field_selector" || e.type === "metric_selector" || e.type === "aggregation_selector" || e.type === "grain_selector";
220
- }
221
- function k(e, t) {
222
- const o = Ue(e);
223
- if (!(!o || o.length === 0) && !o.includes(t))
224
- throw new Error(
225
- `Control ${T(e)} received unsupported value '${t}'.`
226
- );
227
- }
228
- function Be(e, t) {
229
- switch (e.type) {
230
- case "enum":
231
- case "field_selector":
232
- case "metric_selector":
233
- case "aggregation_selector":
234
- case "grain_selector": {
235
- if (typeof t != "string" || t.trim().length === 0)
236
- throw new Error(
237
- `Control ${T(e)} requires a non-empty string value.`
238
- );
239
- return $e(e) && t === A || k(e, t), t;
240
- }
241
- case "multi_enum": {
242
- if (!Array.isArray(t))
243
- throw new Error(
244
- `Control ${T(e)} requires a non-empty array value.`
245
- );
246
- if (t.length === 0) {
247
- if (!e.requiredAtExecution)
248
- return;
249
- throw new Error(
250
- `Control ${T(e)} requires a non-empty array value.`
251
- );
252
- }
253
- for (const o of t) {
254
- if (typeof o != "string" || o.trim().length === 0)
255
- throw new Error(
256
- `Control ${T(e)} requires string array values.`
257
- );
258
- k(e, o);
259
- }
260
- return t;
261
- }
262
- case "text": {
263
- if (typeof t != "string")
264
- throw new Error(
265
- `Control ${T(e)} requires a string value.`
266
- );
267
- return t;
268
- }
269
- case "number": {
270
- if (typeof t == "number" && Number.isFinite(t))
271
- return t;
272
- if (typeof t == "string" && Fe.test(t.trim()))
273
- return Number(t);
274
- throw new Error(
275
- `Control ${T(e)} requires a numeric value.`
276
- );
277
- }
278
- case "boolean": {
279
- if (typeof t != "boolean")
280
- throw new Error(
281
- `Control ${T(e)} requires a boolean value.`
282
- );
283
- return t;
284
- }
285
- case "date": {
286
- if (t instanceof Date && !Number.isNaN(t.getTime()))
287
- return t;
288
- if (typeof t == "string" && t.trim().length > 0) {
289
- const o = t.trim(), r = me(o);
290
- if (!Number.isNaN(r.getTime()))
291
- return o;
292
- }
293
- throw new Error(
294
- `Control ${T(e)} requires a date-compatible value.`
295
- );
296
- }
297
- default:
298
- return t;
299
- }
300
- }
301
- function Q(e) {
302
- var i;
303
- const t = e.definitions.get(e.binding.controlId);
304
- if (!t)
305
- throw new I(
306
- `Binding references unknown control '${e.binding.controlId}'.`,
307
- {
308
- code: xe,
309
- controlId: e.binding.controlId
310
- }
311
- );
312
- if (!Object.prototype.hasOwnProperty.call(
313
- e.controlValues || {},
314
- e.binding.controlId
315
- )) {
316
- if (!t.requiredAtExecution)
317
- return;
318
- throw new I(
319
- `Control '${e.binding.controlId}' must resolve to a concrete value before query execution.`,
320
- {
321
- code: ve,
322
- controlId: e.binding.controlId
323
- }
324
- );
325
- }
326
- let r;
327
- try {
328
- r = Be(
329
- t,
330
- (i = e.controlValues) == null ? void 0 : i[e.binding.controlId]
331
- );
332
- } catch (a) {
333
- const d = a instanceof Error ? a.message : String(a);
334
- throw new I(d, {
335
- code: q,
336
- controlId: e.binding.controlId
337
- });
338
- }
339
- if (typeof r == "string" && r.trim().length > 0)
340
- return r;
341
- if (typeof r == "number" || typeof r == "boolean")
342
- return String(r);
343
- if (r instanceof Date && !Number.isNaN(r.getTime()))
344
- return r.toISOString();
345
- throw new I(
346
- `Binding control '${e.binding.controlId}' must resolve to a single scalar value.`,
347
- {
348
- code: q,
349
- controlId: e.binding.controlId
350
- }
351
- );
352
- }
353
- function z(e) {
354
- const t = e.binding.mapping[e.selectedValue];
355
- if (typeof t == "string" && t.trim().length > 0)
356
- return t;
357
- throw new I(
358
- `Binding for control '${e.binding.controlId}' does not map value '${e.selectedValue}'.`,
359
- {
360
- code: L,
361
- controlId: e.binding.controlId
362
- }
363
- );
364
- }
365
- function Ge(e) {
366
- const t = e.binding.mapping[e.selectedValue];
367
- if (t && typeof t == "object" && "role" in t && t.role === "groupby")
368
- return t;
369
- throw new I(
370
- `Binding for control '${e.binding.controlId}' does not map value '${e.selectedValue}' to a valid group-by field.`,
371
- {
372
- code: L,
373
- controlId: e.binding.controlId
374
- }
375
- );
376
- }
377
- function Pe(e) {
378
- const t = e.binding.mapping[e.selectedValue];
379
- if (t && typeof t == "object" && "role" in t && t.role === "metric")
380
- return t;
381
- throw new I(
382
- `Binding for control '${e.binding.controlId}' does not map value '${e.selectedValue}' to a valid metric field.`,
383
- {
384
- code: L,
385
- controlId: e.binding.controlId
386
- }
387
- );
388
- }
389
- function qe(e, t, o) {
390
- if (oe(
391
- ne(t),
392
- e.aggregateOrigin
393
- ))
394
- return { aggregate: void 0, aggregateOrigin: void 0 };
395
- const r = o === "selection" && e.role === "metric" ? t.aggregate : void 0;
396
- return {
397
- aggregate: e.aggregate ?? r,
398
- aggregateOrigin: e.aggregate ? e.aggregateOrigin : r ? t.aggregateOrigin : void 0
399
- };
400
- }
401
- function ke(e, t, o) {
402
- var r, i, a, d, u, g;
403
- if (o === "domain")
404
- return {
405
- filters: (r = t.parameters) == null ? void 0 : r.filters,
406
- windowTransform: (i = e.parameters) == null ? void 0 : i.windowTransform
407
- };
408
- if (!(!e.parameters && !t.parameters))
409
- return {
410
- filters: ((a = e.parameters) == null ? void 0 : a.filters) ?? ((d = t.parameters) == null ? void 0 : d.filters),
411
- windowTransform: ((u = e.parameters) == null ? void 0 : u.windowTransform) ?? ((g = t.parameters) == null ? void 0 : g.windowTransform)
412
- };
413
- }
414
- function ct(e, t, o) {
415
- const r = e;
416
- return {
417
- id: e.id,
418
- role: e.role,
419
- // Result-column names belong to the selection's consumer (for example,
420
- // range bounds). They do not identify or redefine the catalog calculation.
421
- ...o === "selection" && e.alias ? { alias: e.alias } : {},
422
- granularity: e.granularity ?? t.granularity,
423
- dateFormat: e.dateFormat,
424
- customFormat: e.customFormat,
425
- semanticTemporalPresentation: t.semanticTemporalPresentation || e.semanticTemporalPresentation,
426
- ...qe(e, t, o),
427
- ...e.role === "metric" ? {
428
- aliasTemplate: r.aliasTemplate,
429
- valueAliases: r.valueAliases,
430
- comparison: r.comparison,
431
- comparisonPolarity: r.comparisonPolarity,
432
- parameters: ke(
433
- r,
434
- t,
435
- "domain"
436
- )
437
- } : {},
438
- ...ze(e)
439
- };
440
- }
441
- function ze(e) {
442
- const t = {
443
- ...e.labelOrigin === "override" ? { label: e.label, labelOrigin: e.labelOrigin } : {},
444
- ...e.formatOrigin === "override" ? { format: e.format, formatOrigin: e.formatOrigin } : {}
445
- };
446
- switch (e.role) {
447
- case "pivotby":
448
- return {
449
- ...t,
450
- memberOrder: e.memberOrder
451
- };
452
- case "sortby":
453
- return {
454
- ...t,
455
- direction: e.direction
456
- };
457
- case "detail":
458
- return {
459
- ...t,
460
- ...e.dateFormat !== void 0 ? { dateFormat: e.dateFormat } : {},
461
- ...e.customFormat !== void 0 ? { customFormat: e.customFormat } : {}
462
- };
463
- default:
464
- return t;
465
- }
466
- }
467
- const je = /* @__PURE__ */ new Set([
468
- "day",
469
- "week",
470
- "month",
471
- "quarter",
472
- "year",
473
- "hour",
474
- "minute",
475
- "second"
476
- ]);
477
- function lt(e) {
478
- let t = e.spec;
479
- const o = X(
480
- e.controlDefinitions || [],
481
- e.cardControlDefinitions || []
482
- ), r = (e.controlBindings || []).filter(
483
- (n) => n.target !== "sql_param"
484
- ), i = r.filter(
485
- (n) => n.target === "config_metric_selector" || n.target === "config_field_selector"
486
- ), a = r.filter(
487
- (n) => n.target === "config_grain" || n.target === "config_aggregation"
488
- ), d = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Map();
489
- let g;
490
- const O = () => {
491
- if (g) return g;
492
- const n = e.catalog, c = /* @__PURE__ */ new Map();
493
- for (const l of n) {
494
- const f = c.get(l.id) ?? [];
495
- c.set(l.id, [...f, l]);
496
- }
497
- return g = { refs: n, byId: c }, g;
498
- }, y = (n, c) => {
499
- throw new I(n, {
500
- code: Me,
501
- ...c ? { controlId: c } : {}
502
- });
503
- }, S = (n, c) => {
504
- var f;
505
- if (n.derivedField) return n.derivedField.dataType;
506
- const l = O().refs.filter((h) => h.field.name === n.name && G(h.field.source ?? e.spec.source, n.source ?? e.spec.source));
507
- return l.length > 1 ? y("The selected field is ambiguous in the authorized Matrix field catalog.", c) : ce(((f = l[0]) == null ? void 0 : f.field.dataType) ?? n.dataType);
508
- }, V = (n, c) => ue(n, c.target, (l) => S(l, c.controlId)), D = ie.safeParse(t);
509
- if (!D.success) return y(D.error.message);
510
- t = D.data;
511
- const K = [...i, ...a].map((n) => {
512
- const c = Q({ binding: n, definitions: o, controlValues: e.controlValues }), l = !n.matrixTargetId && c !== void 0 && c !== A ? V(D.data, n) : [];
513
- return {
514
- binding: n,
515
- selectedValue: c,
516
- targetId: n.matrixTargetId ?? (l.length === 1 ? l[0].id : void 0)
517
- };
518
- });
519
- for (const { binding: n, targetId: c, selectedValue: l } of K) {
520
- if (l === void 0 || l === A)
521
- continue;
522
- const f = (s) => y(s, n.controlId), h = n.target === "config_metric_selector" || n.target === "config_aggregation", ee = V(t, n);
523
- (!c || !ee.some((s) => s.id === c)) && f("Choose a valid Matrix level or measure target for this control.");
524
- const M = `${n.target}:${c}`;
525
- d.has(M) && f("Multiple controls cannot replace the same Matrix target."), d.add(M);
526
- const F = (s) => {
527
- const m = (O().byId.get(s.id) ?? []).filter((_) => !s.source || G(s.source, _.field.source ?? e.spec.source));
528
- if (m.length !== 1) return f(m.length ? "The selected field is ambiguous in the authorized Matrix field catalog." : "The selected field is not in the authorized Matrix field catalog.");
529
- const N = se.safeParse(m[0].field);
530
- return N.success ? N.data : f(N.error.message);
531
- }, w = n.target === "config_metric_selector" || n.target === "config_field_selector" ? n.mapping[l] : void 0, C = w && typeof w == "object" && "kind" in w && w.kind === "matrix_instance" ? w.id : void 0;
532
- if (h) {
533
- u.set(c, n.controlId);
534
- const s = C === void 0 ? void 0 : D.data.measures.find(
535
- (p) => p.id === C && p.kind === "aggregate"
536
- );
537
- C !== void 0 && !s && f("The selected Matrix aggregate measure is no longer available.");
538
- const m = n.target === "config_metric_selector" && !s ? Pe({ binding: n, selectedValue: l }) : void 0, N = ((s == null ? void 0 : s.kind) === "aggregate" ? s.aggregate : m == null ? void 0 : m.aggregate) ?? (n.target === "config_aggregation" ? z({ binding: n, selectedValue: l }) : void 0), _ = N === void 0 ? void 0 : ae.safeParse(N);
539
- _ && !_.success && f("This aggregation is not supported by Matrix."), t = {
540
- ...t,
541
- measures: t.measures.map(
542
- (p) => p.id !== c || p.kind !== "aggregate" ? p : {
543
- ...p,
544
- ...m ? { field: F(m) } : {},
545
- ...(s == null ? void 0 : s.kind) === "aggregate" ? { field: s.field } : {},
546
- aggregate: _ != null && _.success ? _.data : p.aggregate
547
- }
548
- )
549
- };
550
- } else {
551
- const s = C === void 0 ? void 0 : [...D.data.rows, ...D.data.columns].find(
552
- (p) => p.id === C
553
- );
554
- C !== void 0 && !s && f("The selected Matrix level is no longer available.");
555
- const m = n.target === "config_field_selector" && !s ? Ge({ binding: n, selectedValue: l }) : void 0, N = n.target === "config_grain" ? z({ binding: n, selectedValue: l }) : s ? s.grain : m == null ? void 0 : m.granularity;
556
- N !== void 0 && !je.has(N) && f("This time grain is not supported by Matrix.");
557
- const _ = (p) => p.map((E) => {
558
- if (E.id !== c) return E;
559
- const U = (s == null ? void 0 : s.field) ?? (m ? F(m) : E.field), $ = S(U, n.controlId), B = N ?? (m && P($) ? E.grain : void 0);
560
- return B && !P($) && f("A time grain requires a temporal Matrix level."), { ...E, field: U, grain: B };
561
- });
562
- t = {
563
- ...t,
564
- rows: _(t.rows),
565
- columns: _(t.columns)
566
- };
567
- }
568
- }
569
- for (const [n, c] of Array.from(u)) {
570
- const l = t.measures.find((h) => h.id === n);
571
- if (!l || l.kind !== "aggregate") continue;
572
- const f = S(l.field, c);
573
- fe(f).some((h) => h.value === l.aggregate) || y(`Aggregation '${l.aggregate}' is not eligible for this Matrix field datatype.`, c);
574
- }
575
- try {
576
- return ge(D.data, t);
577
- } catch (n) {
578
- if (n instanceof de) return y(n.message);
579
- throw n;
580
- }
581
- }
582
- function J(e, t) {
583
- const o = [], r = (i) => {
584
- if (i.source) {
585
- const a = le.safeParse(i.source);
586
- if (a.success) o.push(a.data);
587
- else if (t) throw a.error;
588
- }
589
- i.derivedField && Object.values(i.derivedField.inputs).forEach((a) => r(a.field));
590
- };
591
- for (const i of e) {
592
- if (i.target !== "config_field_selector" && i.target !== "config_metric_selector") continue;
593
- const a = t == null ? void 0 : t.get(i), d = t ? a && a !== A ? [i.mapping[a]] : [] : Object.values(i.mapping);
594
- for (const u of d)
595
- u && "role" in u && r(u);
596
- }
597
- return o;
598
- }
599
- function dt(e, t = [], o = []) {
600
- return j([...H(e), ...J(t), ...o]);
601
- }
602
- function ut(e, t = {}) {
603
- const o = t.controlBindings ?? [], r = X(t.controlDefinitions ?? [], t.cardControlDefinitions ?? []), i = new Map(o.filter((a) => a.target === "config_field_selector" || a.target === "config_metric_selector").map((a) => [a, Q({ binding: a, definitions: r, controlValues: t.controlValues })]));
604
- return j([...H(e), ...J(o, i)]);
605
- }
606
- export {
607
- me as A,
608
- it as C,
609
- rt as D,
610
- tt as a,
611
- ut as b,
612
- ot as c,
613
- xe as d,
614
- ve as e,
615
- at as f,
616
- nt as g,
617
- st as h,
618
- Le as i,
619
- Ve as j,
620
- L as k,
621
- Me as l,
622
- dt as m,
623
- q as n,
624
- I as o,
625
- X as p,
626
- z as q,
627
- Q as r,
628
- Ge as s,
629
- Pe as t,
630
- qe as u,
631
- Be as v,
632
- ke as w,
633
- ct as x,
634
- ze as y,
635
- lt as z
636
- };