react-semaphor 0.1.563 → 0.1.565

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 (139) hide show
  1. package/DATA_APP_SDK.md +3 -3
  2. package/README.md +2 -2
  3. package/dist/analytics-protocol/index.js +8 -8
  4. package/dist/assistant-context/index.js +3 -2
  5. package/dist/brand-studio/index.js +28 -29
  6. package/dist/briefings/index.js +4 -4
  7. package/dist/chunks/{assistant-chat-iIp02_77.js → assistant-chat-DNfb5fbF.js} +294 -294
  8. package/dist/chunks/{bookmark-impact-D4Kl4amw.js → bookmark-impact-CHr7b1J2.js} +2 -2
  9. package/dist/chunks/bookmark-state-ByODVqee.js +1613 -0
  10. package/dist/chunks/card-filter-builder-CcEcfaYz.js +4100 -0
  11. package/dist/chunks/{switch-BW4yXSYs.js → code-editor-DJNOsgJH.js} +463 -442
  12. package/dist/chunks/{comparison-window-caption-D1EUXzaR.js → comparison-window-caption-CMLb3mut.js} +451 -419
  13. package/dist/chunks/{dashboard-CmqeP3QZ.js → dashboard-CtIfxycc.js} +1 -1
  14. package/dist/chunks/dashboard-briefing-launcher-D3mc6peE.js +4910 -0
  15. package/dist/chunks/{dashboard-controls-B253nJS-.js → dashboard-controls-BFv0zdws.js} +684 -674
  16. package/dist/chunks/{dashboard-json-osQuinUZ.js → dashboard-json-CXn_3OYb.js} +4 -4
  17. package/dist/chunks/{dates-DFY7Gfss.js → dates-DcRxw17S.js} +13 -13
  18. package/dist/chunks/{edit-dashboard-visual-CMar-NhA.js → edit-dashboard-visual-Y6HatqBd.js} +7704 -10337
  19. package/dist/chunks/filter-reach-copy-DbggA5B7.js +4673 -0
  20. package/dist/chunks/{filter-value-text-CPwFkrMz.js → filter-value-text-7zhmth1S.js} +2 -2
  21. package/dist/chunks/{index-CNGkfUp4.js → index-DDa_rklN.js} +69 -64
  22. package/dist/chunks/index-RNaTnE3m.js +585 -0
  23. package/dist/chunks/{layout-grid-BM65viQh.js → layout-grid-0hIlqEtk.js} +1 -1
  24. package/dist/chunks/{list-filter-BoeLBfL3.js → list-filter-DkgoCeBm.js} +1 -1
  25. package/dist/chunks/{matrix-analytical-definition-hEucouWM.js → matrix-analytical-definition-C9xB_T84.js} +18 -18
  26. package/dist/chunks/{matrix-card-CCh9JjP1.js → matrix-card-BSUeSXpD.js} +2 -2
  27. package/dist/chunks/{matrix-member-presentation-DsAUbuoL.js → matrix-member-presentation-DZNgQpUq.js} +1 -1
  28. package/dist/chunks/{matrix-operation-contract-DsLdFdSa.js → matrix-operation-contract-Eb6elidS.js} +1 -1
  29. package/dist/chunks/{metric-comparison-Bnso1cm1.js → metric-comparison-ChXUFaZu.js} +1 -1
  30. package/dist/chunks/{palette-p1XSJFgB.js → palette-4vf2BEEg.js} +1 -1
  31. package/dist/chunks/{pivot-result-contract-expectations-B53jqszr.js → pivot-result-contract-expectations-Ddh1rNz5.js} +4 -4
  32. package/dist/chunks/{pivot-result-identity-Dq5jm-EC.js → pivot-result-identity-BlbLrqaC.js} +1 -1
  33. package/dist/chunks/{report-preferences-dialog-l54wJyYE.js → report-preferences-dialog-Db-b04B4.js} +122 -131
  34. package/dist/chunks/{report-runtime-context-BITkNSDa.js → report-runtime-context-DnA_PiKo.js} +1 -1
  35. package/dist/chunks/resolve-dashboard-input-context-C18J-YZC.js +21394 -0
  36. package/dist/chunks/{save-CHV1B1fL.js → save-D6pHmSSP.js} +1 -1
  37. package/dist/chunks/saved-dashboard-context-DhC_EVus.js +629 -0
  38. package/dist/chunks/{selection-reducer-Bz5aywT4.js → selection-reducer-OaJ-N5uN.js} +1 -1
  39. package/dist/chunks/{semaphor-ready-indicator-C3EQEiD9.js → semaphor-ready-indicator-T6TsiBMT.js} +80879 -80744
  40. package/dist/chunks/{shelf-drop-preview-context-BODiBlqT.js → shelf-drop-preview-context-CNWL_b0S.js} +407 -407
  41. package/dist/chunks/{source-entity-resolution-DdDVXFB8.js → source-entity-resolution-DF6GulDn.js} +1 -1
  42. package/dist/chunks/stored-dashboard-IdmtrNkA.js +5026 -0
  43. package/dist/chunks/{table-export-sheet-bSXxGn-v.js → table-export-sheet--DUKWk6o.js} +1 -1
  44. package/dist/chunks/{temporal-input-presentation-sk9gqLi6.js → temporal-input-presentation--2r9BLr0.js} +392 -377
  45. package/dist/chunks/{token-types-BUK06hU2.js → token-types-C8JymO8s.js} +1 -1
  46. package/dist/chunks/{upload-BnmuyPqW.js → upload-Cf3wXZT8.js} +1 -1
  47. package/dist/chunks/{validators-BIM0FE31.js → validators-wtjw0aw6.js} +7 -7
  48. package/dist/chunks/variable-draft-3xseULxR.js +241 -0
  49. package/dist/dashboard/index.js +2 -2
  50. package/dist/dashboard-authoring/index.js +2226 -1704
  51. package/dist/data-app-sdk/index.js +4 -4
  52. package/dist/data-app-sdk-adapters/index.js +2 -2
  53. package/dist/data-app-sdk-validation/index.js +5 -5
  54. package/dist/format-utils/index.js +174 -167
  55. package/dist/index.js +190 -188
  56. package/dist/layouts/index.js +1 -1
  57. package/dist/pdf-export-policy/index.js +80 -28
  58. package/dist/pdf-table-layout/index.js +65 -65
  59. package/dist/report-runtime-context/index.js +1 -1
  60. package/dist/style.css +1 -1
  61. package/dist/surfboard/index.js +2 -2
  62. package/dist/types/briefings/attachment-outcomes.d.ts +1 -1
  63. package/dist/types/components/activity/activity-bell.d.ts +5 -1
  64. package/dist/types/components/activity/activity-types.d.ts +12 -4
  65. package/dist/types/components/dashboard-variables/data-variables-menu.d.ts +8 -0
  66. package/dist/types/components/dashboard-variables/variable-editor-host.d.ts +1 -0
  67. package/dist/types/components/index.d.ts +2 -0
  68. package/dist/types/index.js +5 -5
  69. package/dist/types/lib/dashboard-inputs/build-normalized-dashboard-inputs.d.ts +62 -0
  70. package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-authoring.d.ts +33 -2
  71. package/dist/types/lib/dashboard-inputs/filter-settings.d.ts +7 -2
  72. package/dist/types/lib/dashboard-inputs/prepare-loaded-dashboard.d.ts +4 -2
  73. package/dist/types/lib/dashboard-variables/data-text.d.ts +33 -0
  74. package/dist/types/lib/dashboard-variables/types.d.ts +207 -0
  75. package/dist/types/lib/document/document-edits.d.ts +16 -1
  76. package/dist/types/lib/document/document-panel-target.d.ts +1 -1
  77. package/dist/types/lib/document/document-section-query-options.d.ts +29 -0
  78. package/dist/types/lib/document/document-table-data-policy.d.ts +0 -1
  79. package/dist/types/lib/hooks/use-dashboard-frame-query.d.ts +92 -0
  80. package/dist/types/lib/query-context/build-card-query-context.d.ts +6 -0
  81. package/dist/types/lib/query-context/describe-card-execution-snapshot.d.ts +1 -0
  82. package/dist/types/lib/query-context/use-semantic-execution-payload-for-cards.d.ts +24 -0
  83. package/dist/types/lib/stores/dashboard-store.d.ts +36 -0
  84. package/dist/types/lib/text-variables/temporal-input-text.d.ts +28 -0
  85. package/dist/types/lib/text-variables/text-variable-types.d.ts +72 -0
  86. package/dist/types/lib/types/common-types.d.ts +155 -51
  87. package/dist/types/lib/utils/card-definition.d.ts +2 -2
  88. package/dist/types/shared/assistant-context/index.d.ts +1 -1
  89. package/dist/types/shared/assistant-context/saved-dashboard-context.d.ts +51 -1
  90. package/dist/types/shared/dashboard-authoring/card-query-request.d.ts +7 -1
  91. package/dist/types/shared/dashboard-authoring/card-settings/resolve-card-highlights.d.ts +10 -0
  92. package/dist/types/shared/dashboard-authoring/changes/card-query-part.d.ts +7 -1
  93. package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +1088 -431
  94. package/dist/types/shared/dashboard-authoring/changes/diagnostics.d.ts +18 -1
  95. package/dist/types/shared/dashboard-authoring/changes/read-card-query.d.ts +8 -1
  96. package/dist/types/shared/dashboard-authoring/changes/resolve-dashboard-changes.d.ts +1 -1
  97. package/dist/types/shared/dashboard-authoring/conditional-formatting/kpi.d.ts +10 -0
  98. package/dist/types/shared/dashboard-authoring/conditional-formatting/schema.d.ts +40 -40
  99. package/dist/types/shared/dashboard-authoring/control-execution-contract.d.ts +16 -16
  100. package/dist/types/shared/dashboard-authoring/dashboard-card-source-index.d.ts +1 -0
  101. package/dist/types/shared/dashboard-authoring/dashboard-filter-targets.d.ts +29 -0
  102. package/dist/types/shared/dashboard-authoring/dashboard-input-scope.d.ts +7 -4
  103. package/dist/types/shared/dashboard-authoring/dashboard-variable-card.d.ts +159 -0
  104. package/dist/types/shared/dashboard-authoring/dashboard-variable-changes.d.ts +61 -0
  105. package/dist/types/shared/dashboard-authoring/document-section-cards.d.ts +7 -0
  106. package/dist/types/shared/dashboard-authoring/filter-model/index.d.ts +2 -0
  107. package/dist/types/shared/dashboard-authoring/filter-model/read-dashboard-filter-model.d.ts +10 -0
  108. package/dist/types/shared/dashboard-authoring/index.d.ts +6 -0
  109. package/dist/types/shared/dashboard-authoring/measure-calculations/comparison.d.ts +2 -0
  110. package/dist/types/shared/dashboard-authoring/measure-calculations/schemas.d.ts +1 -1
  111. package/dist/types/shared/dashboard-authoring/operations/operation-sentences.d.ts +1 -1
  112. package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +50 -3
  113. package/dist/types/shared/dashboard-authoring/outline/outline-dashboard.d.ts +48 -1
  114. package/dist/types/shared/dashboard-authoring/outline/outline-filters.d.ts +2 -2
  115. package/dist/types/shared/dashboard-authoring/text-card-words/blocks.d.ts +87 -13
  116. package/dist/types/shared/dashboard-authoring/text-card-words/chip-colors.d.ts +23 -0
  117. package/dist/types/shared/dashboard-authoring/text-card-words/index.d.ts +90 -8
  118. package/dist/types/shared/dashboard-authoring/text-card-words/rich-content.d.ts +31 -3
  119. package/dist/types/shared/dashboard-authoring/text-card-words/variable-words.d.ts +8 -0
  120. package/dist/types/shared/dashboard-authoring/variable-draft.d.ts +125 -0
  121. package/dist/types/shared/dashboard-authoring/variable-editability.d.ts +24 -0
  122. package/dist/types/shared/dashboard-authoring/variable-references.d.ts +39 -0
  123. package/dist/types/shared/format-utils/document-print.d.ts +4 -2
  124. package/dist/types/shared/format-utils/index.d.ts +1 -0
  125. package/dist/types/shared/format-utils/pdf-capacity-lines.d.ts +17 -0
  126. package/dist/types/shared/format-utils/pdf-delivery.d.ts +8 -1
  127. package/dist/types/shared/format-utils/pdf-export-policy.d.ts +74 -6
  128. package/dist/types/shared/format-utils/presentation-execution.d.ts +9 -0
  129. package/package.json +2 -2
  130. package/src/data-app-sdk/README.md +3 -3
  131. package/dist/chunks/bookmark-state-CWeoGbrx.js +0 -743
  132. package/dist/chunks/braces-DzgoQC64.js +0 -23
  133. package/dist/chunks/dashboard-briefing-launcher-TYlSW77S.js +0 -3828
  134. package/dist/chunks/filter-reach-copy-CvV7W5dd.js +0 -3965
  135. package/dist/chunks/global-date-filter-utils-N1kcsOFE.js +0 -16722
  136. package/dist/chunks/index-CJW5BdWT.js +0 -583
  137. package/dist/chunks/resolve-dashboard-input-context-DaDrZGuA.js +0 -8214
  138. package/dist/chunks/saved-dashboard-context-DFYBrE6O.js +0 -564
  139. package/dist/chunks/use-create-flow-overlay-state-BXY8-Cyz.js +0 -1436
@@ -1,583 +0,0 @@
1
- const v = {
2
- /** Widest first. */
3
- breakpoints: ["lg", "md", "sm", "xs", "xxs"],
4
- columns: { lg: 48, md: 36, sm: 24, xs: 12, xxs: 6 },
5
- /** react-grid-layout's default breakpoint widths, now stated. */
6
- minContainerWidthPx: { lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 },
7
- editable: ["lg", "sm", "xs"],
8
- customizable: ["sm", "xs"],
9
- /** The preview canvas widths: Laptop, Tablet, Phone, Small phone (Desktop is at least `minContainerWidthPx.lg`; RL-D19). */
10
- previewWidthPx: { md: 1024, sm: 820, xs: 390, xxs: 360 }
11
- }, g = v.columns.lg;
12
- function q(n) {
13
- return n === "sm" || n === "xs";
14
- }
15
- function wt(n) {
16
- return n === "lg" || q(n);
17
- }
18
- function bt(n) {
19
- return n === "md" || wt(n);
20
- }
21
- const gt = [
22
- "table",
23
- "matrixTable",
24
- "detailTable"
25
- ], Mt = new Set(gt);
26
- function kt(n) {
27
- return typeof n == "string" && Mt.has(n);
28
- }
29
- function vt(n) {
30
- var t, i;
31
- return ((t = n == null ? void 0 : n.cards) == null ? void 0 : t.find((o) => o.id === n.activeCardId)) ?? ((i = n == null ? void 0 : n.cards) == null ? void 0 : i[0]);
32
- }
33
- function K(n) {
34
- var i;
35
- const t = (i = vt(n)) == null ? void 0 : i.type;
36
- return t === "kpi" ? "kpi" : t === "text" ? "text" : kt(t) ? "table" : "chart";
37
- }
38
- function J(n) {
39
- return n === "kpi" || n === "text" ? "short" : "tall";
40
- }
41
- const T = {
42
- kpi: { h: 15, minH: 12, minW: 6 },
43
- chart: { h: 30, minH: 16, minW: 12 },
44
- table: { h: 38, minH: 18, minW: 12 },
45
- text: { h: 10, minH: 8, minW: 12 }
46
- }, E = {
47
- kpi: 48,
48
- chart: 24,
49
- table: 48,
50
- text: 48
51
- };
52
- function Y(n) {
53
- if (n <= 0) return [];
54
- const t = Math.ceil(n / 4), i = Math.floor(n / t), o = n % t;
55
- return Array.from({ length: t }, (e, r) => r < o ? i + 1 : i).flatMap(
56
- (e) => Array.from({ length: e }, () => 48 / e)
57
- );
58
- }
59
- const ot = {
60
- full: 48,
61
- half: 24,
62
- third: 16,
63
- quarter: 12
64
- }, Wt = ["full", "half", "third", "quarter"];
65
- function _t(n) {
66
- let t = "full", i = 1 / 0;
67
- for (const o of Wt) {
68
- const e = Math.abs(ot[o] - n);
69
- e < i && (t = o, i = e);
70
- }
71
- return t;
72
- }
73
- function N(n, t) {
74
- return !(n.i === t.i || n.x + n.w <= t.x || n.x >= t.x + t.w || n.y + n.h <= t.y || n.y >= t.y + t.h);
75
- }
76
- function I(n) {
77
- let t = 0;
78
- for (const i of n) t = Math.max(t, i.y + i.h);
79
- return t;
80
- }
81
- function Q(n, t) {
82
- for (const i of n) if (N(i, t)) return i;
83
- }
84
- function Ht(n) {
85
- return n.slice().sort((t, i) => t.y > i.y || t.y === i.y && t.x > i.x ? 1 : t.y === i.y && t.x === i.x ? 0 : -1);
86
- }
87
- function et(n, t, i) {
88
- t.y += 1;
89
- const o = n.findIndex((e) => e.i === t.i);
90
- for (let e = o + 1; e < n.length; e += 1) {
91
- const r = n[e];
92
- if (!r.static) {
93
- if (r.y > t.y + t.h) break;
94
- N(t, r) && et(n, r, i + t.h);
95
- }
96
- }
97
- t.y = i;
98
- }
99
- function zt(n, t, i) {
100
- for (t.y = Math.min(I(n), t.y); t.y > 0 && !Q(n, t); ) t.y -= 1;
101
- let o;
102
- for (; o = Q(n, t); )
103
- et(i, t, o.y + o.h);
104
- return t.y = Math.max(t.y, 0), t.x = Math.max(t.x, 0), t;
105
- }
106
- function M(n) {
107
- const t = n.map((r) => ({ ...r })), i = t.filter((r) => r.static), o = Ht(t), e = /* @__PURE__ */ new Map();
108
- for (const r of o) {
109
- let s = { ...r };
110
- s.static || (s = zt(i, s, o), i.push(s)), e.set(r, s);
111
- }
112
- return t.map((r) => e.get(r));
113
- }
114
- function It(n) {
115
- return M(n).every((i, o) => i.y === n[o].y && i.x === n[o].x);
116
- }
117
- function Ot(n) {
118
- for (let t = 0; t < n.length; t += 1)
119
- for (let i = t + 1; i < n.length; i += 1)
120
- if (N(n[t], n[i])) return !0;
121
- return !1;
122
- }
123
- function L(n, t) {
124
- const i = (o) => t.get(o.i) ?? Number.MAX_SAFE_INTEGER;
125
- return n.slice().sort((o, e) => o.y - e.y || o.x - e.x || i(o) - i(e));
126
- }
127
- function R(n) {
128
- const t = [];
129
- let i = [], o = 0;
130
- for (const e of n) {
131
- const r = i[i.length - 1];
132
- if (r && e.x >= r.x + r.w && o + e.w <= g) {
133
- i.push(e), o += e.w;
134
- continue;
135
- }
136
- i.length && t.push(i), i = [e], o = e.w;
137
- }
138
- return i.length && t.push(i), t;
139
- }
140
- function At(n) {
141
- return new Map(n.map((t, i) => [t, i]));
142
- }
143
- function Et(n, t, i, o) {
144
- const e = (c) => t.get(c) ?? "chart", r = L(n, i).map((c) => c.i), s = r.find((c) => e(c) === "text"), a = o ? r : [
145
- ...s ? [s] : [],
146
- ...r.filter((c) => e(c) === "kpi"),
147
- ...r.filter((c) => e(c) === "chart"),
148
- ...r.filter((c) => e(c) === "table"),
149
- ...r.filter((c) => e(c) === "text" && c !== s)
150
- ], f = (c) => {
151
- const p = a[c];
152
- if (!o) return a.filter((k) => e(k) === e(p));
153
- let w = c;
154
- for (; w > 0 && e(a[w - 1]) === e(p); ) w -= 1;
155
- let h = c;
156
- for (; h < a.length - 1 && e(a[h + 1]) === e(p); ) h += 1;
157
- return a.slice(w, h + 1);
158
- }, x = (c) => {
159
- const p = a[c], w = e(p);
160
- if (w === "table") return g;
161
- if (w === "text") return p === s ? g : g / 2;
162
- const h = f(c);
163
- if (w === "kpi") return Y(h.length)[h.indexOf(p)];
164
- const k = h.indexOf(p);
165
- return h.length === 1 || h.length % 2 === 1 && k === 0 ? g : g / 2;
166
- };
167
- let l = 0, u = 0, d = 0;
168
- const m = a.map((c, p) => {
169
- const w = T[e(c)], h = Math.min(x(p), g);
170
- l > 0 && l + h > g && (l = 0, u += d, d = 0);
171
- const k = { i: c, x: l, y: u, w: h, h: w.h, minW: Math.min(w.minW, g), minH: w.minH };
172
- return l += h, d = Math.max(d, w.h), k;
173
- });
174
- return { items: M(m), order: a };
175
- }
176
- function S(n) {
177
- return Math.floor(n + 0.5);
178
- }
179
- function rt(n, t, i, o, e, r) {
180
- const s = v.columns[t], a = { i: n.i, x: i, y: o, w: e, h: n.h }, f = r ?? n.minW;
181
- return f !== void 0 && (a.minW = Math.max(1, Math.min(f, e, s))), n.minH !== void 0 && (a.minH = n.minH), n.maxW !== void 0 && (a.maxW = Math.max(e, Math.min(n.maxW, s))), n.maxH !== void 0 && (a.maxH = n.maxH), n.static !== void 0 && (a.static = n.static), n.isResizable !== void 0 && (a.isResizable = n.isResizable), n.isDraggable !== void 0 && (a.isDraggable = n.isDraggable), a;
182
- }
183
- function st(n) {
184
- return M(
185
- n.map((t) => {
186
- let i = S(t.x * 0.75), e = S((t.x + t.w) * 0.75) - i;
187
- e === 0 && (e = 1, i === 36 && (i = 35));
188
- const r = t.minW === void 0 ? void 0 : Math.min(Math.max(1, S(t.minW * 0.75)), e);
189
- return rt(t, "md", i, t.y, e, r);
190
- })
191
- );
192
- }
193
- function St(n, t) {
194
- const i = new Map(st(n).map((r) => [r.i, r])), o = new Map(t.map((r) => [r.i, r])), e = v.columns.lg;
195
- return n.map((r) => {
196
- const s = o.get(r.i), a = i.get(r.i);
197
- if (!s || !a) return r;
198
- const f = { ...r };
199
- if (s.x !== a.x || s.w !== a.w) {
200
- const x = Math.min(e - 1, S(s.x * 1.3333333333333333)), l = Math.min(e, Math.max(x + 1, S((s.x + s.w) * (4 / 3))));
201
- f.x = x, f.w = l - x;
202
- }
203
- return (s.y !== a.y || s.h !== a.h) && (f.y = s.y, f.h = s.h), f;
204
- });
205
- }
206
- function j(n, t, i) {
207
- const o = /* @__PURE__ */ new Map();
208
- let e = 0;
209
- for (const r of n) {
210
- let s = 0;
211
- for (const a of r)
212
- o.set(a.source.i, rt(a.source, t, a.x, e, a.w)), s = Math.max(s, a.source.h);
213
- e += s;
214
- }
215
- return M(i.map((r) => o.get(r.i)));
216
- }
217
- function tt(n, t, i) {
218
- const o = [];
219
- for (const e of n) {
220
- let r;
221
- const s = () => {
222
- r && o.push([{ source: r, x: 0, w: t }]), r = void 0;
223
- };
224
- for (const a of e)
225
- i(a) ? (s(), o.push([{ source: a, x: 0, w: t }])) : r ? (o.push([
226
- { source: r, x: 0, w: t / 2 },
227
- { source: a, x: t / 2, w: t / 2 }
228
- ]), r = void 0) : r = a;
229
- s();
230
- }
231
- return o;
232
- }
233
- function at(n, t, i, o) {
234
- if (n === "md") return st(t);
235
- const e = v.columns[n], r = R(L(t, o)), s = (a) => i.get(a.i) ?? "chart";
236
- return n === "sm" ? j(tt(r, e, (a) => s(a) === "table" || s(a) === "text"), "sm", t) : n === "xs" ? j(tt(r, e, (a) => s(a) !== "kpi"), "xs", t) : j(
237
- r.flatMap((a) => a.map((f) => [{ source: f, x: 0, w: e }])),
238
- "xxs",
239
- t
240
- );
241
- }
242
- function H(n, t, i) {
243
- const o = T[t];
244
- return { i: n, x: 0, y: 0, w: i, h: o.h, minW: Math.min(o.minW, i), minH: o.minH };
245
- }
246
- function P(n, t) {
247
- return n.slice().sort((i, o) => (t.get(i.i) ?? 0) - (t.get(o.i) ?? 0));
248
- }
249
- function G(n, t, i) {
250
- return n.map((o) => o.y >= t ? { ...o, y: o.y + i } : o);
251
- }
252
- function Bt(n, t, i) {
253
- const o = (f, x) => !t.some((l) => N({ ...n, i: "\0", x: f, y: x }, l)), e = n.x + n.w;
254
- if (e + n.w <= i && o(e, n.y)) return { x: e, y: n.y };
255
- const r = Math.max(i - n.w, 0), s = n.y + n.h, a = [s, ...t.map((f) => f.y + f.h).filter((f) => f > s).sort((f, x) => f - x)];
256
- for (const f of a)
257
- for (let x = 0; x <= r; x += 1) if (o(x, f)) return { x, y: f };
258
- return { x: 0, y: s };
259
- }
260
- function ft(n, t) {
261
- const i = Math.max(1, Math.min(n.w, t));
262
- return {
263
- ...n,
264
- w: i,
265
- x: Math.max(0, Math.min(n.x, t - i)),
266
- ...n.minW !== void 0 ? { minW: Math.max(1, Math.min(n.minW, i)) } : {},
267
- ...n.maxW !== void 0 ? { maxW: Math.max(i, Math.min(n.maxW, t)) } : {}
268
- };
269
- }
270
- function ct(n, t, i, o) {
271
- const e = n.find((f) => f.i === t), r = ft(e, o), { x: s, y: a } = Bt(r, n.filter((f) => f.i !== t), o);
272
- return [...n, { ...r, i, x: s, y: a }];
273
- }
274
- function Lt(n, t, i, o, e) {
275
- var u;
276
- const r = o == null ? void 0 : o.position;
277
- if (r && typeof r == "object" && "beside" in r)
278
- return M(P(ct(n, r.beside, t, g), e.frameOrder));
279
- const s = o != null && o.width ? ot[o.width] : void 0;
280
- let a = n.slice();
281
- const f = (d) => M(P([...a, d], e.frameOrder));
282
- if (r === "top") {
283
- const d = H(t, i, s ?? E[i]);
284
- return a = G(a, 0, d.h), f(d);
285
- }
286
- if (r === "end" || r === void 0 && s !== void 0)
287
- return f({ ...H(t, i, s ?? E[i]), y: I(a) });
288
- if (r && typeof r == "object" && "after" in r) {
289
- const d = H(t, i, s ?? E[i]), c = R(L(a, e.frameOrder)).find((W) => W.some((b) => b.i === r.after)), p = c.find((W) => W.i === r.after), w = c[c.length - 1];
290
- if (g - (w.x + w.w) >= d.w) {
291
- const W = new Set(c.filter((b) => b.x > p.x).map((b) => b.i));
292
- return a = a.map((b) => W.has(b.i) ? { ...b, x: b.x + d.w } : b), f({ ...d, x: p.x + p.w, y: p.y });
293
- }
294
- const k = Math.max(...c.map((W) => W.y + W.h));
295
- return a = G(a, k, d.h), f({ ...d, x: 0, y: k });
296
- }
297
- const x = (d) => e.kinds.get(d.i) ?? "chart", l = R(L(a, e.frameOrder));
298
- if (i === "kpi") {
299
- const d = ((u = l[0]) == null ? void 0 : u.length) === 1 && x(l[0][0]) === "text" ? 1 : 0;
300
- let m = d;
301
- for (; m < l.length && l[m].every((y) => x(y) === "kpi"); ) m += 1;
302
- if (m === d) {
303
- const y = d === 1 ? l[0][0].y + l[0][0].h : 0, C = H(t, i, Y(1)[0]);
304
- return a = G(a, y, C.h), f({ ...C, y });
305
- }
306
- const c = l.slice(d, m).flat(), p = new Set(c.map((y) => y.i)), w = Math.min(...c.map((y) => y.y)), h = Math.max(...c.map((y) => y.y + y.h)), k = [...c, H(t, i, 12)], W = Y(k.length);
307
- let b = 0, F = w, O = 0;
308
- const pt = k.map((y, C) => {
309
- const $ = W[C];
310
- b > 0 && b + $ > g && (b = 0, F += O, O = 0);
311
- const yt = { ...y, x: b, y: F, w: $, ...y.minW !== void 0 ? { minW: Math.min(y.minW, $) } : {} };
312
- return b += $, O = Math.max(O, y.h), yt;
313
- }), Z = F + O, xt = a.filter((y) => !p.has(y.i)).map((y) => y.y >= w && Z > h ? { ...y, y: y.y + (Z - h) } : y);
314
- return M(P([...xt, ...pt], e.frameOrder));
315
- }
316
- if (i === "chart") {
317
- const d = l[l.length - 1], m = (d == null ? void 0 : d.length) === 1 ? d[0] : void 0;
318
- return m && x(m) === "chart" && (m.x + m.w <= 24 || m.x >= 24) ? f({ ...H(t, i, 24), x: m.x + m.w <= 24 ? 24 : 0, y: m.y }) : f({ ...H(t, i, 24), y: I(a) });
319
- }
320
- return f({ ...H(t, i, g), y: I(a) });
321
- }
322
- function dt(n, t, i) {
323
- const o = Math.max(1, Math.min(i, Math.round(t.w * i / g)));
324
- return [...n, ft({ ...t, x: 0, y: I(n), w: o }, i)];
325
- }
326
- const V = ["md", "sm", "xs", "xxs"], ut = [];
327
- function A(n) {
328
- const t = n.map((i) => i.id);
329
- return {
330
- frames: n,
331
- ids: t,
332
- kinds: new Map(n.map((i) => [i.id, K(i)])),
333
- frameOrder: At(t)
334
- };
335
- }
336
- function _(n) {
337
- return typeof n == "number" && Number.isFinite(n) ? Math.round(n) : void 0;
338
- }
339
- function B(n, t, i) {
340
- const o = new Set(i.ids), e = /* @__PURE__ */ new Map();
341
- if (!Array.isArray(n)) return e;
342
- for (const r of n) {
343
- if (!r || typeof r != "object") continue;
344
- const s = r, a = s.i;
345
- if (typeof a != "string" || !o.has(a) || e.has(a)) continue;
346
- const f = i.kinds.get(a) ?? "chart", x = _(s.minH), l = Math.max(1, Math.min(_(s.w) ?? Math.min(E[f], t), t)), u = Math.max(_(s.h) ?? T[f].h, x ?? 1, 1), d = {
347
- i: a,
348
- x: Math.max(0, Math.min(_(s.x) ?? 0, t - l)),
349
- y: Math.max(0, _(s.y) ?? Number.MAX_SAFE_INTEGER),
350
- w: l,
351
- h: u
352
- }, m = _(s.minW);
353
- m !== void 0 && (d.minW = Math.max(1, Math.min(m, l))), x !== void 0 && (d.minH = Math.max(1, Math.min(x, u)));
354
- const c = _(s.maxW);
355
- c !== void 0 && (d.maxW = Math.max(c, l));
356
- const p = _(s.maxH);
357
- p !== void 0 && (d.maxH = Math.max(p, u)), typeof s.static == "boolean" && (d.static = s.static), typeof s.isResizable == "boolean" && (d.isResizable = s.isResizable), typeof s.isDraggable == "boolean" && (d.isDraggable = s.isDraggable), e.set(a, d);
358
- }
359
- return e;
360
- }
361
- function Tt(n, t) {
362
- return t.ids.every((i) => n.has(i));
363
- }
364
- function D(n, t) {
365
- return t.ids.flatMap((i) => n.has(i) ? [n.get(i)] : []);
366
- }
367
- function X(n, t) {
368
- const i = M(D(n, t)), o = new Map(i.map((r) => [r.i, r]));
369
- let e = I(i);
370
- for (const r of t.ids) {
371
- if (o.has(r)) continue;
372
- const s = t.kinds.get(r) ?? "chart", a = T[s], f = E[s];
373
- o.set(r, { i: r, x: 0, y: e, w: f, h: a.h, minW: Math.min(a.minW, f), minH: a.minH }), e += a.h;
374
- }
375
- return M(t.ids.map((r) => o.get(r)));
376
- }
377
- function Ct(n, t) {
378
- const i = g / t;
379
- return n.map((o) => {
380
- if (!o || typeof o != "object") return o;
381
- const e = o, r = _(e.x), s = _(e.w);
382
- if (r === void 0 || s === void 0) return e;
383
- const a = Math.round(r * i), f = Math.round((r + s) * i);
384
- return { ...e, x: a, w: Math.max(1, f - a) };
385
- });
386
- }
387
- function $t(n) {
388
- const t = n.layouts ?? {};
389
- if (Array.isArray(t.lg)) return t.lg;
390
- if (Array.isArray(n.layout)) return n.layout;
391
- for (const i of V) {
392
- const o = t[i];
393
- if (Array.isArray(o)) return Ct(o, v.columns[i]);
394
- }
395
- return [];
396
- }
397
- function nt(n, t) {
398
- var i;
399
- return (i = n.layouts) == null ? void 0 : i[t];
400
- }
401
- function mt(n, t, i, o) {
402
- let e = M(D(n, o));
403
- for (const r of t)
404
- n.has(r.i) || (e = dt(e, r, v.columns[i]));
405
- return M(U(e, o));
406
- }
407
- function U(n, t) {
408
- return n.slice().sort((i, o) => (t.frameOrder.get(i.i) ?? 0) - (t.frameOrder.get(o.i) ?? 0));
409
- }
410
- const Rt = ["i", "x", "y", "w", "h", "minW", "minH", "maxW", "maxH", "static", "isResizable", "isDraggable"];
411
- function lt(n, t) {
412
- return !Array.isArray(n) || n.length !== t.length ? !1 : t.every((i, o) => {
413
- const e = n[o];
414
- return !!e && Rt.every((r) => e[r] === i[r]);
415
- });
416
- }
417
- function Dt(n, t) {
418
- const i = new Map(t.map((o) => [o.i, o]));
419
- return n.length === t.length && n.every((o) => {
420
- const e = i.get(o.i);
421
- return !!e && e.x === o.x && e.y === o.y && e.w === o.w && e.h === o.h;
422
- });
423
- }
424
- function Nt(n, t) {
425
- return v.breakpoints.every((i) => lt(n[i], t[i]));
426
- }
427
- function Ft(n) {
428
- return v.customizable.filter((t) => n.includes(t));
429
- }
430
- function ht(n, t, i) {
431
- const o = { lg: n };
432
- for (const e of V)
433
- o[e] = i[e] ?? at(e, n, t.kinds, t.frameOrder);
434
- return o;
435
- }
436
- function jt(n, t) {
437
- return R(L(n, t.frameOrder)).map((i) => ({
438
- tiles: i.map((o) => ({ frameId: o.i, kind: t.kinds.get(o.i) ?? "chart", width: _t(o.w) }))
439
- }));
440
- }
441
- function Pt(n) {
442
- const t = A(n.frames ?? ut), i = X(B($t(n), g, t), t), o = Array.isArray(n.customizedBreakpoints), e = {}, r = [];
443
- for (const f of V) {
444
- const x = v.columns[f], l = B(nt(n, f), x, t), u = Tt(l, t) && t.ids.length > 0;
445
- if (q(f)) {
446
- if (o && n.customizedBreakpoints.includes(f)) {
447
- e[f] = mt(l, i, f, t), r.push(f);
448
- continue;
449
- }
450
- if (!o && u) {
451
- const m = M(D(l, t));
452
- Dt(m, at(f, i, t.kinds, t.frameOrder)) || (e[f] = m, r.push(f));
453
- }
454
- continue;
455
- }
456
- !o && u && (e[f] = M(D(l, t)));
457
- }
458
- const s = ht(i, t, e), a = v.breakpoints.some((f) => !lt(nt(n, f), s[f]));
459
- return { layouts: s, customizedBreakpoints: r, rows: jt(i, t), repaired: a };
460
- }
461
- function z(n) {
462
- return { ok: !1, failure: n };
463
- }
464
- function it(n, t, i) {
465
- const o = T[i];
466
- return n.map((e) => e.i === t ? { ...e, h: o.h, minH: o.minH, minW: Math.min(o.minW, e.w) } : e);
467
- }
468
- function Gt(n, t) {
469
- const i = Pt(n), o = n.frames ?? ut;
470
- let e = o, r = i.layouts.lg, s = i.customizedBreakpoints.slice();
471
- const a = {};
472
- for (const u of s) a[u] = i.layouts[u];
473
- switch (t.kind) {
474
- case "frame_added": {
475
- const { frame: u, placement: d } = t;
476
- if (o.some((h) => h.id === u.id))
477
- return z({ code: "frame_already_on_sheet", frameId: u.id, message: `A frame with id ${u.id} is already on this sheet.` });
478
- const m = d == null ? void 0 : d.position, c = typeof m == "object" ? "after" in m ? m.after : m.beside : void 0;
479
- if (c !== void 0 && !o.some((h) => h.id === c))
480
- return z({ code: "position_target_not_found", frameId: c, message: `No frame ${c} on this sheet to place the new frame next to.` });
481
- if (m === "top") e = [u, ...o];
482
- else if (c !== void 0) {
483
- const h = o.findIndex((k) => k.id === c);
484
- e = [...o.slice(0, h + 1), u, ...o.slice(h + 1)];
485
- } else e = [...o, u];
486
- const p = A(e);
487
- r = Lt(r, u.id, p.kinds.get(u.id), d, p);
488
- const w = r.find((h) => h.i === u.id);
489
- for (const h of s) {
490
- const k = v.columns[h], W = a[h], b = typeof m == "object" && "beside" in m ? ct(W, m.beside, u.id, k) : dt(W, w, k);
491
- a[h] = M(U(b, p));
492
- }
493
- break;
494
- }
495
- case "frame_removed": {
496
- if (!o.some((u) => u.id === t.frameId))
497
- return z({ code: "frame_not_on_sheet", frameId: t.frameId, message: `No frame ${t.frameId} on this sheet.` });
498
- e = o.filter((u) => u.id !== t.frameId), r = M(r.filter((u) => u.i !== t.frameId));
499
- for (const u of s)
500
- a[u] = M(a[u].filter((d) => d.i !== t.frameId));
501
- break;
502
- }
503
- case "frame_updated": {
504
- const u = o.findIndex((c) => c.id === t.frame.id);
505
- if (u < 0)
506
- return z({ code: "frame_not_on_sheet", frameId: t.frame.id, message: `No frame ${t.frame.id} on this sheet.` });
507
- e = o.map((c, p) => p === u ? t.frame : c);
508
- const d = K(o[u]), m = K(t.frame);
509
- if (d === m)
510
- return {
511
- ok: !0,
512
- frames: e,
513
- layouts: i.layouts,
514
- customizedBreakpoints: i.customizedBreakpoints,
515
- changed: !0,
516
- layoutsChanged: !1
517
- };
518
- if (t.resizeForNewKind && J(d) !== J(m)) {
519
- r = M(it(r, t.frame.id, m));
520
- for (const c of s)
521
- a[c] = M(it(a[c], t.frame.id, m));
522
- }
523
- break;
524
- }
525
- case "grid_edited": {
526
- if (!bt(t.breakpoint))
527
- return z({ code: "breakpoint_not_editable", breakpoint: String(t.breakpoint), message: `The ${String(t.breakpoint)} layout is derived; edit Desktop, Tablet or Phone.` });
528
- const u = A(o);
529
- if (t.breakpoint === "md") {
530
- const d = [...B(t.items, v.columns.md, u).values()];
531
- r = X(new Map(St(r, d).map((m) => [m.i, m])), u);
532
- } else if (t.breakpoint === "lg")
533
- r = X(B(t.items, g, u), u);
534
- else {
535
- const d = t.breakpoint;
536
- a[d] = mt(B(t.items, v.columns[d], u), r, d, u), s.includes(d) || (s = Ft([...s, d]));
537
- }
538
- break;
539
- }
540
- case "reset_to_automatic": {
541
- if (!q(t.breakpoint))
542
- return z({ code: "breakpoint_not_editable", breakpoint: String(t.breakpoint), message: "Only Tablet and Phone can go back to automatic." });
543
- s = s.filter((u) => u !== t.breakpoint), delete a[t.breakpoint];
544
- break;
545
- }
546
- case "arrange": {
547
- const u = A(o), d = Et(r, u.kinds, u.frameOrder, t.keepOrder === !0), m = new Map(o.map((c) => [c.id, c]));
548
- e = d.order.map((c) => m.get(c)), e.every((c, p) => c === o[p]) && (e = o), r = d.items, s = [];
549
- for (const c of v.customizable) delete a[c];
550
- break;
551
- }
552
- }
553
- const f = A(e);
554
- r = U(r, f);
555
- const x = ht(r, f, a), l = !Nt(x, i.layouts) || s.join() !== i.customizedBreakpoints.join();
556
- return { ok: !0, frames: e, layouts: x, customizedBreakpoints: s, changed: e !== o || l, layoutsChanged: l };
557
- }
558
- function Kt(n, t) {
559
- const i = [...t].sort().join("\0");
560
- for (const o of v.breakpoints) {
561
- const e = n[o], r = v.columns[o];
562
- if (!Array.isArray(e)) throw new Error(`Layout ${o} is missing.`);
563
- if (e.map((s) => s.i).sort().join("\0") !== i) throw new Error(`Layout ${o} doesn't hold exactly the sheet's frames.`);
564
- for (const s of e) {
565
- if (![s.x, s.y, s.w, s.h].every(Number.isInteger)) throw new Error(`Layout ${o}: ${s.i} has a non-integer position or size.`);
566
- if (s.x < 0 || s.y < 0 || s.w < 1 || s.w > r || s.x + s.w > r || s.h < 1)
567
- throw new Error(`Layout ${o}: ${s.i} is out of bounds.`);
568
- if (s.minW !== void 0 && (s.minW < 1 || s.minW > s.w)) throw new Error(`Layout ${o}: ${s.i} minW out of range.`);
569
- if (s.minH !== void 0 && (s.minH < 1 || s.minH > s.h)) throw new Error(`Layout ${o}: ${s.i} minH out of range.`);
570
- if (s.maxW !== void 0 && s.maxW < s.w) throw new Error(`Layout ${o}: ${s.i} maxW below w.`);
571
- if (s.maxH !== void 0 && s.maxH < s.h) throw new Error(`Layout ${o}: ${s.i} maxH below h.`);
572
- }
573
- if (Ot(e)) throw new Error(`Layout ${o} has overlapping items.`);
574
- if (!It(e)) throw new Error(`Layout ${o} isn't packed.`);
575
- }
576
- }
577
- export {
578
- v as D,
579
- Gt as a,
580
- Kt as b,
581
- kt as i,
582
- Pt as r
583
- };