react-semaphor 0.1.603 → 0.1.605

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 (208) hide show
  1. package/dist/activity/index.js +1 -73
  2. package/dist/analytics-protocol/index.js +1 -1491
  3. package/dist/appearance/index.js +1 -12
  4. package/dist/appearance-runtime/index.js +1 -5
  5. package/dist/assistant-context/index.js +1 -11
  6. package/dist/assistant-protocol/index.js +1 -152
  7. package/dist/brand-studio/index.js +3 -1598
  8. package/dist/briefings/index.js +1 -70
  9. package/dist/chunks/add-to-dashboard-CEmZUf9o.js +12 -0
  10. package/dist/chunks/analytics-base-schemas-DMFrDqn_.js +1 -0
  11. package/dist/chunks/appearance-provider-CfoAVQuG.js +608 -0
  12. package/dist/chunks/appearance-runtime-provider-Bx8H-moR.js +1 -0
  13. package/dist/chunks/applied-constraints-CinevlKD.js +1 -0
  14. package/dist/chunks/assistant-chat-DgUaCE9k.js +51 -0
  15. package/dist/chunks/attachment-filter-line-C_zHMhGh.js +1 -0
  16. package/dist/chunks/attribution-BEFSsbNn.js +1 -0
  17. package/dist/chunks/availability-3AIOf6Z-.js +1 -0
  18. package/dist/chunks/bookmark-impact-BAtemeyK.js +1 -0
  19. package/dist/chunks/bookmark-state-DScd31KT.js +1 -0
  20. package/dist/chunks/brand-C9APUFaP.js +1 -0
  21. package/dist/chunks/card-filter-builder-ClWrXB7P.js +11 -0
  22. package/dist/chunks/column-bands-DwxbZ6UI.js +1 -0
  23. package/dist/chunks/comparison-window-caption-tguyN24S.js +1 -0
  24. package/dist/chunks/context-CntvtZwC.js +2 -0
  25. package/dist/chunks/conversation-JMK2kyTK.js +1 -0
  26. package/dist/chunks/dashboard-ChIcbVTx.js +1 -0
  27. package/dist/chunks/dashboard-briefing-launcher-CwMlhkxV.js +42 -0
  28. package/dist/chunks/dashboard-controls-UCSAFCGA.js +42 -0
  29. package/dist/chunks/dashboard-json-B120hYDa.js +1 -0
  30. package/dist/chunks/dashboard-temporal-snapshot-BFJKbp_6.js +1 -0
  31. package/dist/chunks/edit-dashboard-visual-DvHp03h_.js +73 -0
  32. package/dist/chunks/export-file-format-B-wQNHIn.js +4 -0
  33. package/dist/chunks/filter-line-WwUV5JzN.js +1 -0
  34. package/dist/chunks/filter-reach-preview-C5M5_hf_.js +1 -0
  35. package/dist/chunks/filter-value-text-DqTHe_vu.js +1 -0
  36. package/dist/chunks/index-DViPGDFj.js +1 -0
  37. package/dist/chunks/index-bkP6SnYu.js +1 -0
  38. package/dist/chunks/kpi-trend-rule-B87LNzcz.js +1 -0
  39. package/dist/chunks/layout-grid-CFzqJ7GC.js +6 -0
  40. package/dist/chunks/matrix-analytical-definition-5T-2euHZ.js +1 -0
  41. package/dist/chunks/matrix-member-presentation-vVAv-aqg.js +1 -0
  42. package/dist/chunks/matrix-operation-contract-CWvcEsQ0.js +1 -0
  43. package/dist/chunks/normalize-dashboard-for-dirty-check-ILKfqgL3.js +1 -0
  44. package/dist/chunks/numeric-range-options-C8tr-Bls.js +1 -0
  45. package/dist/chunks/palette-NvEIuXHN.js +6 -0
  46. package/dist/chunks/pivot-result-contract-expectations-BNWhS8mv.js +1 -0
  47. package/dist/chunks/pivot-result-identity-B0eWVMXg.js +1 -0
  48. package/dist/chunks/raw-temporal-value-BHQ-ldpW.js +1 -0
  49. package/dist/chunks/rendered-file-BbvwaU6z.js +1 -0
  50. package/dist/chunks/report-preferences-dialog-Bseb2Rlg.js +1 -0
  51. package/dist/chunks/report-runtime-context-Cd1b5pku.js +1 -0
  52. package/dist/chunks/resolve-dashboard-input-context-BDY7KwRe.js +8 -0
  53. package/dist/chunks/resolver-CjsW8Rz0.js +1 -0
  54. package/dist/chunks/saved-dashboard-context-C3lWc4Dx.js +1 -0
  55. package/dist/chunks/schema-O1Y3WTGF.js +4 -0
  56. package/dist/chunks/selection-filter-compiler-kYsRugss.js +1 -0
  57. package/dist/chunks/semaphor-ready-indicator-BQarSo6S.js +612 -0
  58. package/dist/chunks/set-6mOnfQeH.js +1 -0
  59. package/dist/chunks/slider-BPnHdMGq.js +4 -0
  60. package/dist/chunks/stored-dashboard-DfrxDLhR.js +1 -0
  61. package/dist/chunks/table-export-sheet-xaczzWZF.js +2 -0
  62. package/dist/chunks/token-types-1vzMWjI-.js +1 -0
  63. package/dist/chunks/validators-Dg2kyF4_.js +1 -0
  64. package/dist/chunks/variable-draft-B4_xqr4Y.js +1 -0
  65. package/dist/chunks/visual-choice-DgEFfkE-.js +1 -0
  66. package/dist/dashboard/index.js +1 -7
  67. package/dist/dashboard-authoring/index.js +1 -4614
  68. package/dist/format-utils/index.js +1 -425
  69. package/dist/index.js +1 -554
  70. package/dist/layouts/index.js +1 -7
  71. package/dist/live-channel/index.js +1 -124
  72. package/dist/pdf-export-policy/index.js +1 -92
  73. package/dist/pdf-table-layout/index.js +1 -993
  74. package/dist/report-runtime-context/index.js +1 -9
  75. package/dist/shared/index.js +1 -6
  76. package/dist/style.css +1 -1
  77. package/dist/surfboard/index.js +1 -9
  78. package/dist/types/brand-studio/brand-studio-draft.d.ts +45 -13
  79. package/dist/types/brand-studio/brand-studio-editor.d.ts +13 -2
  80. package/dist/types/components/index.d.ts +1 -0
  81. package/dist/types/components/visual/data-table/hooks/use-data-table-logic.d.ts +17 -6
  82. package/dist/types/components/visual/data-table/types/data-table.d.ts +52 -42
  83. package/dist/types/index.js +1 -88
  84. package/dist/types/lib/appearance/aliases.d.ts +3 -0
  85. package/dist/types/lib/appearance/index.d.ts +1 -0
  86. package/dist/types/lib/appearance/table-density.d.ts +18 -0
  87. package/dist/types/lib/appearance/types.d.ts +39 -1
  88. package/dist/types/lib/dashboard-viewer/column-header-actions.d.ts +100 -0
  89. package/dist/types/lib/dashboard-viewer/table-view-edit.d.ts +0 -27
  90. package/dist/types/lib/dashboard-viewer/table-view.d.ts +26 -2
  91. package/dist/types/lib/dashboard-viewer/use-table-view.d.ts +2 -0
  92. package/dist/types/lib/filter-values/build-card-filter-definition.d.ts +32 -0
  93. package/dist/types/lib/hooks/use-add-new-frame.d.ts +7 -0
  94. package/dist/types/lib/hooks/use-dashboard-card.d.ts +4 -0
  95. package/dist/types/lib/interactions/get-click-context-from-chartjs.d.ts +8 -0
  96. package/dist/types/lib/query-context/dashboard-filter-mapping-resolution.d.ts +9 -0
  97. package/dist/types/lib/stores/dashboard-store.d.ts +14 -2
  98. package/dist/types/lib/stores/explorer-actions.d.ts +7 -10
  99. package/dist/types/lib/types/common-types.d.ts +1 -2
  100. package/dist/types/lib/types/semantic-types.d.ts +6 -10
  101. package/dist/types/lib/utils/card-config-utils.d.ts +13 -0
  102. package/dist/types/lib/utils/field-placement.d.ts +17 -0
  103. package/dist/types/lib/utils/field-state-calculator.d.ts +7 -19
  104. package/dist/types/shared/analytics-protocol/analytics-refusal.d.ts +21 -1
  105. package/dist/types/shared/analytics-protocol/field-provenance.d.ts +7 -4
  106. package/dist/types/shared/dashboard-authoring/calculations/definition.d.ts +13 -0
  107. package/dist/types/shared/dashboard-authoring/card-data-source/card-base.d.ts +125 -0
  108. package/dist/types/shared/dashboard-authoring/card-data-source/card-field-folders.d.ts +55 -0
  109. package/dist/types/shared/dashboard-authoring/card-data-source/card-joins.d.ts +114 -0
  110. package/dist/types/shared/dashboard-authoring/card-data-source/card-prune.d.ts +12 -0
  111. package/dist/types/shared/dashboard-authoring/card-data-source/filter-field-catalog.d.ts +60 -0
  112. package/dist/types/shared/dashboard-authoring/card-data-source/filter-field-folders.d.ts +180 -0
  113. package/dist/types/shared/dashboard-authoring/card-data-source/index.d.ts +7 -0
  114. package/dist/types/shared/dashboard-authoring/card-data-source/join-reach.d.ts +42 -0
  115. package/dist/types/shared/dashboard-authoring/card-field-places.d.ts +28 -0
  116. package/dist/types/shared/dashboard-authoring/card-settings/card-display-write.d.ts +2 -8
  117. package/dist/types/shared/dashboard-authoring/card-settings/card-kinds.d.ts +1 -1
  118. package/dist/types/shared/dashboard-authoring/card-settings/column-display-values.d.ts +5 -0
  119. package/dist/types/shared/dashboard-authoring/card-settings/column-display.d.ts +52 -0
  120. package/dist/types/shared/dashboard-authoring/card-settings/index.d.ts +1 -0
  121. package/dist/types/shared/dashboard-authoring/card-settings/inputs.d.ts +9 -0
  122. package/dist/types/shared/dashboard-authoring/card-settings/resolved.d.ts +4 -0
  123. package/dist/types/shared/dashboard-authoring/card-settings/table-viewer-switches.d.ts +15 -0
  124. package/dist/types/shared/dashboard-authoring/card-settings/views.d.ts +5 -0
  125. package/dist/types/shared/dashboard-authoring/changes/card-query-part.d.ts +6 -0
  126. package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +132 -3
  127. package/dist/types/shared/dashboard-authoring/changes/diagnostics.d.ts +3 -1
  128. package/dist/types/shared/dashboard-authoring/conditional-formatting/schema.d.ts +10 -10
  129. package/dist/types/shared/dashboard-authoring/conditional-formatting/store.d.ts +10 -1
  130. package/dist/types/shared/dashboard-authoring/field-aggregations.d.ts +9 -2
  131. package/dist/types/shared/dashboard-authoring/field-folders/field-folders.d.ts +116 -0
  132. package/dist/types/shared/dashboard-authoring/field-folders/index.d.ts +1 -0
  133. package/dist/types/shared/dashboard-authoring/filter-reach-decision.d.ts +11 -0
  134. package/dist/types/shared/dashboard-authoring/index.d.ts +7 -1
  135. package/dist/types/shared/dashboard-authoring/operations/card-operations.d.ts +2 -0
  136. package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +7 -2
  137. package/dist/types/shared/dashboard-authoring/outline/outline-dashboard.d.ts +6 -2
  138. package/dist/types/shared/dashboard-authoring/outline/outline-filters.d.ts +2 -0
  139. package/dist/types/shared/dashboard-authoring/see-records/result.d.ts +7 -22
  140. package/dist/types/shared/dashboard-authoring/sheet-kinds.d.ts +36 -0
  141. package/dist/types/shared/dashboard-authoring/table-sheet-shape.d.ts +140 -0
  142. package/dist/types/shared/dashboard-viewer/table-column-move.d.ts +15 -0
  143. package/dist/types/shared/dashboard-viewer/table-settings.d.ts +8 -2
  144. package/dist/types/shared/format-utils/types/format-types.d.ts +1 -1
  145. package/dist/usage-events/index.js +1 -285
  146. package/dist/value-format-preferences/index.js +1 -635
  147. package/package.json +5 -2
  148. package/dist/chunks/add-to-dashboard-CFF-wFU-.js +0 -291
  149. package/dist/chunks/analytics-base-schemas-DsUh5Q3C.js +0 -680
  150. package/dist/chunks/appearance-context-BwBp25ZG.js +0 -162
  151. package/dist/chunks/appearance-runtime-provider-BRHYELkC.js +0 -80
  152. package/dist/chunks/applied-constraints-DU-wndZ7.js +0 -47
  153. package/dist/chunks/assistant-chat-B6hNQI1t.js +0 -6115
  154. package/dist/chunks/attribution-BvoKvhcj.js +0 -32
  155. package/dist/chunks/availability-Bp5Gfu1I.js +0 -44
  156. package/dist/chunks/bookmark-impact-Ba2PLcGp.js +0 -76
  157. package/dist/chunks/bookmark-state-n7AaNzR_.js +0 -1667
  158. package/dist/chunks/brand-BoUV0iHF.js +0 -54
  159. package/dist/chunks/card-filter-builder-Y22HizVx.js +0 -4069
  160. package/dist/chunks/column-bands-RdM-kjDe.js +0 -47
  161. package/dist/chunks/comparison-window-caption-Ck2TIbnR.js +0 -741
  162. package/dist/chunks/context-UCQ7sere.js +0 -369
  163. package/dist/chunks/conversation-sQiWYUOb.js +0 -16
  164. package/dist/chunks/dashboard-BghI99oY.js +0 -14
  165. package/dist/chunks/dashboard-briefing-launcher-DtBAnGiH.js +0 -4875
  166. package/dist/chunks/dashboard-controls-CtFXlyjV.js +0 -2290
  167. package/dist/chunks/dashboard-json-DfGBUtCd.js +0 -66
  168. package/dist/chunks/dates-BnrXF4bb.js +0 -185
  169. package/dist/chunks/edit-9df1zOWe.js +0 -226
  170. package/dist/chunks/edit-dashboard-visual-oxt3x1wb.js +0 -18397
  171. package/dist/chunks/export-file-format-C-tJsxsf.js +0 -111
  172. package/dist/chunks/filter-line-Cy5YYqRL.js +0 -703
  173. package/dist/chunks/filter-reach-copy-CE_ZX147.js +0 -5111
  174. package/dist/chunks/filter-value-text-fWvSDwkl.js +0 -153
  175. package/dist/chunks/index-BVKzKl5d.js +0 -90
  176. package/dist/chunks/index-CV_Kzou0.js +0 -595
  177. package/dist/chunks/index-D5rxbtS4.js +0 -2795
  178. package/dist/chunks/layout-grid-9LndRoLa.js +0 -16
  179. package/dist/chunks/matrix-analytical-definition-CCp48UCw.js +0 -1233
  180. package/dist/chunks/matrix-member-presentation-zNehruXR.js +0 -391
  181. package/dist/chunks/matrix-operation-contract-DPBj69D8.js +0 -1413
  182. package/dist/chunks/metric-comparison-B0FR-Q8I.js +0 -600
  183. package/dist/chunks/normalize-dashboard-for-dirty-check-XKgH3GFX.js +0 -119
  184. package/dist/chunks/paintbrush-58FQYY-y.js +0 -27
  185. package/dist/chunks/palette-Be62Tkoa.js +0 -23
  186. package/dist/chunks/pickers-DkqmtnTL.js +0 -2403
  187. package/dist/chunks/pivot-result-contract-expectations-BYqAmG9n.js +0 -5092
  188. package/dist/chunks/pivot-result-identity-CAP4--iq.js +0 -77
  189. package/dist/chunks/raw-temporal-value-Dg_MTFF7.js +0 -3778
  190. package/dist/chunks/rendered-file-D8xEuVVx.js +0 -108
  191. package/dist/chunks/report-preferences-dialog-uJp9GBTM.js +0 -1651
  192. package/dist/chunks/report-runtime-context-c77_KF9v.js +0 -388
  193. package/dist/chunks/resolve-dashboard-input-context-Rtl1ffmE.js +0 -25324
  194. package/dist/chunks/resolver-DG_tfEpt.js +0 -156
  195. package/dist/chunks/save-C5A0JnEV.js +0 -21
  196. package/dist/chunks/saved-dashboard-context-tcyTU8jm.js +0 -618
  197. package/dist/chunks/schema-C9NPiIru.js +0 -2568
  198. package/dist/chunks/selection-filter-compiler-DNijjI5y.js +0 -150
  199. package/dist/chunks/semaphor-ready-indicator-FBvunj6S.js +0 -145603
  200. package/dist/chunks/shelf-drop-preview-context-QKStrcK9.js +0 -2466
  201. package/dist/chunks/stored-dashboard-CHozcAY9.js +0 -4075
  202. package/dist/chunks/style-sheet-parts-CDCG-8Ej.js +0 -8681
  203. package/dist/chunks/table-export-sheet-ZFIvs6Sj.js +0 -949
  204. package/dist/chunks/token-types-XbM6QByy.js +0 -8
  205. package/dist/chunks/upload-H15d7uHK.js +0 -15
  206. package/dist/chunks/validators-Baf3VIf5.js +0 -3686
  207. package/dist/chunks/variable-draft-C2y8Jp6Z.js +0 -242
  208. package/dist/chunks/visual-choice-DDfHfHvY.js +0 -172
@@ -1,595 +0,0 @@
1
- const k = {
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
- }, b = k.columns.lg;
12
- function Q(n) {
13
- return n === "sm" || n === "xs";
14
- }
15
- function kt(n) {
16
- return n === "lg" || Q(n);
17
- }
18
- function vt(n) {
19
- return n === "md" || kt(n);
20
- }
21
- const Wt = [
22
- "table",
23
- "matrixTable",
24
- "detailTable"
25
- ], Ht = new Set(Wt);
26
- function _t(n) {
27
- return typeof n == "string" && Ht.has(n);
28
- }
29
- function zt(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 U(n) {
34
- var i;
35
- const t = (i = zt(n)) == null ? void 0 : i.type;
36
- return t === "kpi" ? "kpi" : t === "text" ? "text" : _t(t) ? "table" : "chart";
37
- }
38
- function it(n) {
39
- return n === "kpi" || n === "text" ? "short" : "tall";
40
- }
41
- const E = {
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
- // One line fits at every gap: 6 rows is 42 px of card at the widest gap (24), where the text
46
- // card's padding tightens to 8 px (dashboard-card.tsx); a heading line is about 23 px.
47
- text: { h: 10, minH: 6, minW: 12 }
48
- }, C = {
49
- kpi: 48,
50
- chart: 24,
51
- table: 48,
52
- text: 48
53
- };
54
- function q(n) {
55
- if (n <= 0) return [];
56
- const t = Math.ceil(n / 4), i = Math.floor(n / t), o = n % t;
57
- return Array.from({ length: t }, (e, r) => r < o ? i + 1 : i).flatMap(
58
- (e) => Array.from({ length: e }, () => 48 / e)
59
- );
60
- }
61
- const at = {
62
- full: 48,
63
- half: 24,
64
- third: 16,
65
- quarter: 12
66
- }, It = ["full", "half", "third", "quarter"];
67
- function Ot(n) {
68
- let t = "full", i = 1 / 0;
69
- for (const o of It) {
70
- const e = Math.abs(at[o] - n);
71
- e < i && (t = o, i = e);
72
- }
73
- return t;
74
- }
75
- function P(n, t) {
76
- 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);
77
- }
78
- function O(n) {
79
- let t = 0;
80
- for (const i of n) t = Math.max(t, i.y + i.h);
81
- return t;
82
- }
83
- function ot(n, t) {
84
- for (const i of n) if (P(i, t)) return i;
85
- }
86
- function At(n) {
87
- 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);
88
- }
89
- function ft(n, t, i) {
90
- t.y += 1;
91
- const o = n.findIndex((e) => e.i === t.i);
92
- for (let e = o + 1; e < n.length; e += 1) {
93
- const r = n[e];
94
- if (!r.static) {
95
- if (r.y > t.y + t.h) break;
96
- P(t, r) && ft(n, r, i + t.h);
97
- }
98
- }
99
- t.y = i;
100
- }
101
- function Et(n, t, i) {
102
- for (t.y = Math.min(O(n), t.y); t.y > 0 && !ot(n, t); ) t.y -= 1;
103
- let o;
104
- for (; o = ot(n, t); )
105
- ft(i, t, o.y + o.h);
106
- return t.y = Math.max(t.y, 0), t.x = Math.max(t.x, 0), t;
107
- }
108
- function g(n) {
109
- const t = n.map((r) => ({ ...r })), i = t.filter((r) => r.static), o = At(t), e = /* @__PURE__ */ new Map();
110
- for (const r of o) {
111
- let s = { ...r };
112
- s.static || (s = Et(i, s, o), i.push(s)), e.set(r, s);
113
- }
114
- return t.map((r) => e.get(r));
115
- }
116
- function St(n) {
117
- return g(n).every((i, o) => i.y === n[o].y && i.x === n[o].x);
118
- }
119
- function Bt(n) {
120
- for (let t = 0; t < n.length; t += 1)
121
- for (let i = t + 1; i < n.length; i += 1)
122
- if (P(n[t], n[i])) return !0;
123
- return !1;
124
- }
125
- function A(n, t) {
126
- const i = (o) => t.get(o.i) ?? Number.MAX_SAFE_INTEGER;
127
- return n.slice().sort((o, e) => o.y - e.y || o.x - e.x || i(o) - i(e));
128
- }
129
- function F(n) {
130
- const t = [];
131
- let i = [], o = 0;
132
- for (const e of n) {
133
- const r = i[i.length - 1];
134
- if (r && e.x >= r.x + r.w && o + e.w <= b) {
135
- i.push(e), o += e.w;
136
- continue;
137
- }
138
- i.length && t.push(i), i = [e], o = e.w;
139
- }
140
- return i.length && t.push(i), t;
141
- }
142
- function Lt(n) {
143
- return new Map(n.map((t, i) => [t, i]));
144
- }
145
- function Tt(n, t, i, o) {
146
- const e = (d) => t.get(d) ?? "chart", r = A(n, i).map((d) => d.i), s = r.find((d) => e(d) === "text"), a = o ? r : [
147
- ...s ? [s] : [],
148
- ...r.filter((d) => e(d) === "kpi"),
149
- ...r.filter((d) => e(d) === "chart"),
150
- ...r.filter((d) => e(d) === "table"),
151
- ...r.filter((d) => e(d) === "text" && d !== s)
152
- ], f = (d) => {
153
- const m = a[d];
154
- if (!o) return a.filter((M) => e(M) === e(m));
155
- let p = d;
156
- for (; p > 0 && e(a[p - 1]) === e(m); ) p -= 1;
157
- let l = d;
158
- for (; l < a.length - 1 && e(a[l + 1]) === e(m); ) l += 1;
159
- return a.slice(p, l + 1);
160
- }, y = (d) => {
161
- const m = a[d], p = e(m);
162
- if (p === "table") return b;
163
- if (p === "text") return m === s ? b : b / 2;
164
- const l = f(d);
165
- if (p === "kpi") return q(l.length)[l.indexOf(m)];
166
- const M = l.indexOf(m);
167
- return l.length === 1 || l.length % 2 === 1 && M === 0 ? b : b / 2;
168
- };
169
- let x = 0, c = 0, u = 0;
170
- const h = a.map((d, m) => {
171
- const p = E[e(d)], l = Math.min(y(m), b);
172
- x > 0 && x + l > b && (x = 0, c += u, u = 0);
173
- const M = { i: d, x, y: c, w: l, h: p.h, minW: Math.min(p.minW, b), minH: p.minH };
174
- return x += l, u = Math.max(u, p.h), M;
175
- });
176
- return { items: g(h), order: a };
177
- }
178
- function $(n) {
179
- return Math.floor(n + 0.5);
180
- }
181
- function ct(n, t, i, o, e, r) {
182
- const s = k.columns[t], a = { i: n.i, x: i, y: o, w: e, h: n.h }, f = r ?? n.minW;
183
- 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;
184
- }
185
- function dt(n) {
186
- return g(
187
- n.map((t) => {
188
- let i = $(t.x * 0.75), e = $((t.x + t.w) * 0.75) - i;
189
- e === 0 && (e = 1, i === 36 && (i = 35));
190
- const r = t.minW === void 0 ? void 0 : Math.min(Math.max(1, $(t.minW * 0.75)), e);
191
- return ct(t, "md", i, t.y, e, r);
192
- })
193
- );
194
- }
195
- function Ct(n, t) {
196
- const i = new Map(dt(n).map((r) => [r.i, r])), o = new Map(t.map((r) => [r.i, r])), e = k.columns.lg;
197
- return n.map((r) => {
198
- const s = o.get(r.i), a = i.get(r.i);
199
- if (!s || !a) return r;
200
- const f = { ...r };
201
- if (s.x !== a.x || s.w !== a.w) {
202
- const y = Math.min(e - 1, $(s.x * 1.3333333333333333)), x = Math.min(e, Math.max(y + 1, $((s.x + s.w) * (4 / 3))));
203
- f.x = y, f.w = x - y;
204
- }
205
- return (s.y !== a.y || s.h !== a.h) && (f.y = s.y, f.h = s.h), f;
206
- });
207
- }
208
- function K(n, t, i) {
209
- const o = /* @__PURE__ */ new Map();
210
- let e = 0;
211
- for (const r of n) {
212
- let s = 0;
213
- for (const a of r)
214
- o.set(a.source.i, ct(a.source, t, a.x, e, a.w)), s = Math.max(s, a.source.h);
215
- e += s;
216
- }
217
- return g(i.map((r) => o.get(r.i)));
218
- }
219
- function et(n, t, i) {
220
- const o = [];
221
- for (const e of n) {
222
- let r;
223
- const s = () => {
224
- r && o.push([{ source: r, x: 0, w: t }]), r = void 0;
225
- };
226
- for (const a of e)
227
- i(a) ? (s(), o.push([{ source: a, x: 0, w: t }])) : r ? (o.push([
228
- { source: r, x: 0, w: t / 2 },
229
- { source: a, x: t / 2, w: t / 2 }
230
- ]), r = void 0) : r = a;
231
- s();
232
- }
233
- return o;
234
- }
235
- function ut(n, t, i, o) {
236
- if (n === "md") return dt(t);
237
- const e = k.columns[n], r = F(A(t, o)), s = (a) => i.get(a.i) ?? "chart";
238
- return n === "sm" ? K(et(r, e, (a) => s(a) === "table" || s(a) === "text"), "sm", t) : n === "xs" ? K(et(r, e, (a) => s(a) !== "kpi"), "xs", t) : K(
239
- r.flatMap((a) => a.map((f) => [{ source: f, x: 0, w: e }])),
240
- "xxs",
241
- t
242
- );
243
- }
244
- function _(n, t, i) {
245
- const o = E[t];
246
- return { i: n, x: 0, y: 0, w: i, h: o.h, minW: Math.min(o.minW, i), minH: o.minH };
247
- }
248
- function Y(n, t) {
249
- return n.slice().sort((i, o) => (t.get(i.i) ?? 0) - (t.get(o.i) ?? 0));
250
- }
251
- function X(n, t, i) {
252
- return n.map((o) => o.y >= t ? { ...o, y: o.y + i } : o);
253
- }
254
- function $t(n, t, i) {
255
- const o = (f, y) => !t.some((x) => P({ ...n, i: "\0", x: f, y }, x)), e = n.x + n.w;
256
- if (e + n.w <= i && o(e, n.y)) return { x: e, y: n.y };
257
- 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, y) => f - y)];
258
- for (const f of a)
259
- for (let y = 0; y <= r; y += 1) if (o(y, f)) return { x: y, y: f };
260
- return { x: 0, y: s };
261
- }
262
- function mt(n, t) {
263
- const i = Math.max(1, Math.min(n.w, t));
264
- return {
265
- ...n,
266
- w: i,
267
- x: Math.max(0, Math.min(n.x, t - i)),
268
- ...n.minW !== void 0 ? { minW: Math.max(1, Math.min(n.minW, i)) } : {},
269
- ...n.maxW !== void 0 ? { maxW: Math.max(i, Math.min(n.maxW, t)) } : {}
270
- };
271
- }
272
- function lt(n, t, i, o) {
273
- const e = n.find((f) => f.i === t), r = mt(e, o), { x: s, y: a } = $t(r, n.filter((f) => f.i !== t), o);
274
- return [...n, { ...r, i, x: s, y: a }];
275
- }
276
- function Rt(n, t, i, o, e) {
277
- var h, d;
278
- const r = o == null ? void 0 : o.position;
279
- if (r && typeof r == "object" && "beside" in r)
280
- return g(Y(lt(n, r.beside, t, b), e.frameOrder));
281
- const s = o != null && o.width ? at[o.width] : void 0;
282
- let a = n.slice();
283
- const f = (m) => g(Y([...a, m], e.frameOrder));
284
- if (r === "top") {
285
- const m = _(t, i, s ?? C[i]);
286
- return a = X(a, 0, m.h), f(m);
287
- }
288
- if (r === "end")
289
- return f({ ..._(t, i, s ?? C[i]), y: O(a) });
290
- const y = r === void 0 && s !== void 0, x = r && typeof r == "object" && "after" in r ? r.after : y ? (h = A(a, e.frameOrder).at(-1)) == null ? void 0 : h.i : void 0;
291
- if (y && x === void 0) return f(_(t, i, s));
292
- if (x !== void 0) {
293
- const m = _(t, i, s ?? C[i]), l = F(A(a, e.frameOrder)).find((W) => W.some((v) => v.i === x)), M = l.find((W) => W.i === x), z = l[l.length - 1];
294
- if (b - (z.x + z.w) >= m.w) {
295
- const W = new Set(l.filter((v) => v.x > M.x).map((v) => v.i));
296
- return a = a.map((v) => W.has(v.i) ? { ...v, x: v.x + m.w } : v), f({ ...m, x: M.x + M.w, y: M.y });
297
- }
298
- const B = Math.max(...l.map((W) => W.y + W.h));
299
- return a = X(a, B, m.h), f({ ...m, x: 0, y: B });
300
- }
301
- const c = (m) => e.kinds.get(m.i) ?? "chart", u = F(A(a, e.frameOrder));
302
- if (i === "kpi") {
303
- const m = ((d = u[0]) == null ? void 0 : d.length) === 1 && c(u[0][0]) === "text" ? 1 : 0;
304
- let p = m;
305
- for (; p < u.length && u[p].every((w) => c(w) === "kpi"); ) p += 1;
306
- if (p === m) {
307
- const w = m === 1 ? u[0][0].y + u[0][0].h : 0, D = _(t, i, q(1)[0]);
308
- return a = X(a, w, D.h), f({ ...D, y: w });
309
- }
310
- const l = u.slice(m, p).flat(), M = new Set(l.map((w) => w.i)), z = Math.min(...l.map((w) => w.y)), S = Math.max(...l.map((w) => w.y + w.h)), B = [...l, _(t, i, 12)], W = q(B.length);
311
- let v = 0, G = z, L = 0;
312
- const bt = B.map((w, D) => {
313
- const N = W[D];
314
- v > 0 && v + N > b && (v = 0, G += L, L = 0);
315
- const Mt = { ...w, x: v, y: G, w: N, ...w.minW !== void 0 ? { minW: Math.min(w.minW, N) } : {} };
316
- return v += N, L = Math.max(L, w.h), Mt;
317
- }), nt = G + L, gt = a.filter((w) => !M.has(w.i)).map((w) => w.y >= z && nt > S ? { ...w, y: w.y + (nt - S) } : w);
318
- return g(Y([...gt, ...bt], e.frameOrder));
319
- }
320
- if (i === "chart") {
321
- const m = u[u.length - 1], p = (m == null ? void 0 : m.length) === 1 ? m[0] : void 0;
322
- return p && c(p) === "chart" && (p.x + p.w <= 24 || p.x >= 24) ? f({ ..._(t, i, 24), x: p.x + p.w <= 24 ? 24 : 0, y: p.y }) : f({ ..._(t, i, 24), y: O(a) });
323
- }
324
- return f({ ..._(t, i, b), y: O(a) });
325
- }
326
- function ht(n, t, i) {
327
- const o = Math.max(1, Math.min(i, Math.round(t.w * i / b)));
328
- return [...n, mt({ ...t, x: 0, y: O(n), w: o }, i)];
329
- }
330
- const tt = ["md", "sm", "xs", "xxs"], pt = [];
331
- function T(n) {
332
- const t = n.map((i) => i.id);
333
- return {
334
- frames: n,
335
- ids: t,
336
- kinds: new Map(n.map((i) => [i.id, U(i)])),
337
- frameOrder: Lt(t)
338
- };
339
- }
340
- function H(n) {
341
- return typeof n == "number" && Number.isFinite(n) ? Math.round(n) : void 0;
342
- }
343
- function R(n, t, i) {
344
- const o = new Set(i.ids), e = /* @__PURE__ */ new Map();
345
- if (!Array.isArray(n)) return e;
346
- for (const r of n) {
347
- if (!r || typeof r != "object") continue;
348
- const s = r, a = s.i;
349
- if (typeof a != "string" || !o.has(a) || e.has(a)) continue;
350
- const f = i.kinds.get(a) ?? "chart", y = H(s.minH), x = Math.max(1, Math.min(H(s.w) ?? Math.min(C[f], t), t)), c = Math.max(H(s.h) ?? E[f].h, y ?? 1, 1), u = {
351
- i: a,
352
- x: Math.max(0, Math.min(H(s.x) ?? 0, t - x)),
353
- y: Math.max(0, H(s.y) ?? Number.MAX_SAFE_INTEGER),
354
- w: x,
355
- h: c
356
- }, h = H(s.minW);
357
- h !== void 0 && (u.minW = Math.max(1, Math.min(h, x))), y !== void 0 && (u.minH = Math.max(1, Math.min(y, c)));
358
- const d = H(s.maxW);
359
- d !== void 0 && (u.maxW = Math.max(d, x));
360
- const m = H(s.maxH);
361
- m !== void 0 && (u.maxH = Math.max(m, c)), typeof s.static == "boolean" && (u.static = s.static), typeof s.isResizable == "boolean" && (u.isResizable = s.isResizable), typeof s.isDraggable == "boolean" && (u.isDraggable = s.isDraggable), e.set(a, V(u, i));
362
- }
363
- return e;
364
- }
365
- function V(n, t) {
366
- const i = E[t.kinds.get(n.i) ?? "chart"].minH;
367
- return n.minH !== void 0 && n.minH > i ? { ...n, minH: i } : n;
368
- }
369
- function Dt(n, t) {
370
- return t.ids.every((i) => n.has(i));
371
- }
372
- function j(n, t) {
373
- return t.ids.flatMap((i) => n.has(i) ? [n.get(i)] : []);
374
- }
375
- function Z(n, t) {
376
- const i = g(j(n, t)), o = new Map(i.map((r) => [r.i, r]));
377
- let e = O(i);
378
- for (const r of t.ids) {
379
- if (o.has(r)) continue;
380
- const s = t.kinds.get(r) ?? "chart", a = E[s], f = C[s];
381
- 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;
382
- }
383
- return g(t.ids.map((r) => o.get(r)));
384
- }
385
- function Nt(n, t) {
386
- const i = b / t;
387
- return n.map((o) => {
388
- if (!o || typeof o != "object") return o;
389
- const e = o, r = H(e.x), s = H(e.w);
390
- if (r === void 0 || s === void 0) return e;
391
- const a = Math.round(r * i), f = Math.round((r + s) * i);
392
- return { ...e, x: a, w: Math.max(1, f - a) };
393
- });
394
- }
395
- function Ft(n) {
396
- const t = n.layouts ?? {};
397
- if (Array.isArray(t.lg)) return t.lg;
398
- if (Array.isArray(n.layout)) return n.layout;
399
- for (const i of tt) {
400
- const o = t[i];
401
- if (Array.isArray(o)) return Nt(o, k.columns[i]);
402
- }
403
- return [];
404
- }
405
- function rt(n, t) {
406
- var i;
407
- return (i = n.layouts) == null ? void 0 : i[t];
408
- }
409
- function xt(n, t, i, o) {
410
- let e = g(j(n, o));
411
- for (const r of t)
412
- n.has(r.i) || (e = ht(e, r, k.columns[i]));
413
- return g(J(e, o));
414
- }
415
- function J(n, t) {
416
- return n.slice().sort((i, o) => (t.frameOrder.get(i.i) ?? 0) - (t.frameOrder.get(o.i) ?? 0));
417
- }
418
- const jt = ["i", "x", "y", "w", "h", "minW", "minH", "maxW", "maxH", "static", "isResizable", "isDraggable"];
419
- function yt(n, t) {
420
- return !Array.isArray(n) || n.length !== t.length ? !1 : t.every((i, o) => {
421
- const e = n[o];
422
- return !!e && jt.every((r) => e[r] === i[r]);
423
- });
424
- }
425
- function Pt(n, t) {
426
- const i = new Map(t.map((o) => [o.i, o]));
427
- return n.length === t.length && n.every((o) => {
428
- const e = i.get(o.i);
429
- return !!e && e.x === o.x && e.y === o.y && e.w === o.w && e.h === o.h;
430
- });
431
- }
432
- function Gt(n, t) {
433
- return k.breakpoints.every((i) => yt(n[i], t[i]));
434
- }
435
- function Kt(n) {
436
- return k.customizable.filter((t) => n.includes(t));
437
- }
438
- function wt(n, t, i) {
439
- const o = { lg: n };
440
- for (const e of tt)
441
- o[e] = i[e] ?? ut(e, n, t.kinds, t.frameOrder);
442
- return o;
443
- }
444
- function Yt(n, t) {
445
- return F(A(n, t.frameOrder)).map((i) => ({
446
- tiles: i.map((o) => ({ frameId: o.i, kind: t.kinds.get(o.i) ?? "chart", width: Ot(o.w) }))
447
- }));
448
- }
449
- function Xt(n) {
450
- const t = T(n.frames ?? pt), i = Z(R(Ft(n), b, t), t), o = Array.isArray(n.customizedBreakpoints), e = {}, r = [];
451
- for (const f of tt) {
452
- const y = k.columns[f], x = R(rt(n, f), y, t), c = Dt(x, t) && t.ids.length > 0;
453
- if (Q(f)) {
454
- if (o && n.customizedBreakpoints.includes(f)) {
455
- e[f] = xt(x, i, f, t), r.push(f);
456
- continue;
457
- }
458
- if (!o && c) {
459
- const h = g(j(x, t));
460
- Pt(h, ut(f, i, t.kinds, t.frameOrder)) || (e[f] = h, r.push(f));
461
- }
462
- continue;
463
- }
464
- !o && c && (e[f] = g(j(x, t)));
465
- }
466
- const s = wt(i, t, e), a = k.breakpoints.some((f) => !yt(rt(n, f), s[f]));
467
- return { layouts: s, customizedBreakpoints: r, rows: Yt(i, t), repaired: a };
468
- }
469
- function I(n) {
470
- return { ok: !1, failure: n };
471
- }
472
- function st(n, t, i) {
473
- const o = E[i];
474
- return n.map((e) => e.i === t ? { ...e, h: o.h, minH: o.minH, minW: Math.min(o.minW, e.w) } : e);
475
- }
476
- function Ut(n, t) {
477
- const i = Xt(n), o = n.frames ?? pt;
478
- let e = o, r = i.layouts.lg, s = i.customizedBreakpoints.slice();
479
- const a = {};
480
- for (const c of s) a[c] = i.layouts[c];
481
- switch (t.kind) {
482
- case "frame_added": {
483
- const { frame: c, placement: u } = t;
484
- if (o.some((l) => l.id === c.id))
485
- return I({ code: "frame_already_on_sheet", frameId: c.id, message: `A frame with id ${c.id} is already on this sheet.` });
486
- const h = u == null ? void 0 : u.position, d = typeof h == "object" ? "after" in h ? h.after : h.beside : void 0;
487
- if (d !== void 0 && !o.some((l) => l.id === d))
488
- return I({ code: "position_target_not_found", frameId: d, message: `No frame ${d} on this sheet to place the new frame next to.` });
489
- if (h === "top") e = [c, ...o];
490
- else if (d !== void 0) {
491
- const l = o.findIndex((M) => M.id === d);
492
- e = [...o.slice(0, l + 1), c, ...o.slice(l + 1)];
493
- } else e = [...o, c];
494
- const m = T(e);
495
- r = Rt(r, c.id, m.kinds.get(c.id), u, m);
496
- const p = r.find((l) => l.i === c.id);
497
- for (const l of s) {
498
- const M = k.columns[l], z = a[l], S = typeof h == "object" && "beside" in h ? lt(z, h.beside, c.id, M) : ht(z, p, M);
499
- a[l] = g(J(S, m));
500
- }
501
- break;
502
- }
503
- case "frame_removed": {
504
- if (!o.some((c) => c.id === t.frameId))
505
- return I({ code: "frame_not_on_sheet", frameId: t.frameId, message: `No frame ${t.frameId} on this sheet.` });
506
- e = o.filter((c) => c.id !== t.frameId), r = g(r.filter((c) => c.i !== t.frameId));
507
- for (const c of s)
508
- a[c] = g(a[c].filter((u) => u.i !== t.frameId));
509
- break;
510
- }
511
- case "frame_updated": {
512
- const c = o.findIndex((d) => d.id === t.frame.id);
513
- if (c < 0)
514
- return I({ code: "frame_not_on_sheet", frameId: t.frame.id, message: `No frame ${t.frame.id} on this sheet.` });
515
- e = o.map((d, m) => m === c ? t.frame : d);
516
- const u = U(o[c]), h = U(t.frame);
517
- if (u === h)
518
- return {
519
- ok: !0,
520
- frames: e,
521
- layouts: i.layouts,
522
- customizedBreakpoints: i.customizedBreakpoints,
523
- changed: !0,
524
- layoutsChanged: !1
525
- };
526
- if (t.resizeForNewKind && it(u) !== it(h)) {
527
- r = g(st(r, t.frame.id, h));
528
- for (const d of s)
529
- a[d] = g(st(a[d], t.frame.id, h));
530
- }
531
- break;
532
- }
533
- case "grid_edited": {
534
- if (!vt(t.breakpoint))
535
- return I({ code: "breakpoint_not_editable", breakpoint: String(t.breakpoint), message: `The ${String(t.breakpoint)} layout is derived; edit Desktop, Tablet or Phone.` });
536
- const c = T(o);
537
- if (t.breakpoint === "md") {
538
- const u = [...R(t.items, k.columns.md, c).values()];
539
- r = Z(new Map(Ct(r, u).map((h) => [h.i, h])), c);
540
- } else if (t.breakpoint === "lg")
541
- r = Z(R(t.items, b, c), c);
542
- else {
543
- const u = t.breakpoint;
544
- a[u] = xt(R(t.items, k.columns[u], c), r, u, c), s.includes(u) || (s = Kt([...s, u]));
545
- }
546
- break;
547
- }
548
- case "reset_to_automatic": {
549
- if (!Q(t.breakpoint))
550
- return I({ code: "breakpoint_not_editable", breakpoint: String(t.breakpoint), message: "Only Tablet and Phone can go back to automatic." });
551
- s = s.filter((c) => c !== t.breakpoint), delete a[t.breakpoint];
552
- break;
553
- }
554
- case "arrange": {
555
- const c = T(o), u = Tt(r, c.kinds, c.frameOrder, t.keepOrder === !0), h = new Map(o.map((d) => [d.id, d]));
556
- e = u.order.map((d) => h.get(d)), e.every((d, m) => d === o[m]) && (e = o), r = u.items, s = [];
557
- for (const d of k.customizable) delete a[d];
558
- break;
559
- }
560
- }
561
- const f = T(e);
562
- r = J(r, f).map((c) => V(c, f));
563
- for (const c of k.customizable) {
564
- const u = a[c];
565
- u && (a[c] = u.map((h) => V(h, f)));
566
- }
567
- const y = wt(r, f, a), x = !Gt(y, i.layouts) || s.join() !== i.customizedBreakpoints.join();
568
- return { ok: !0, frames: e, layouts: y, customizedBreakpoints: s, changed: e !== o || x, layoutsChanged: x };
569
- }
570
- function qt(n, t) {
571
- const i = [...t].sort().join("\0");
572
- for (const o of k.breakpoints) {
573
- const e = n[o], r = k.columns[o];
574
- if (!Array.isArray(e)) throw new Error(`Layout ${o} is missing.`);
575
- if (e.map((s) => s.i).sort().join("\0") !== i) throw new Error(`Layout ${o} doesn't hold exactly the sheet's frames.`);
576
- for (const s of e) {
577
- 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.`);
578
- if (s.x < 0 || s.y < 0 || s.w < 1 || s.w > r || s.x + s.w > r || s.h < 1)
579
- throw new Error(`Layout ${o}: ${s.i} is out of bounds.`);
580
- if (s.minW !== void 0 && (s.minW < 1 || s.minW > s.w)) throw new Error(`Layout ${o}: ${s.i} minW out of range.`);
581
- if (s.minH !== void 0 && (s.minH < 1 || s.minH > s.h)) throw new Error(`Layout ${o}: ${s.i} minH out of range.`);
582
- if (s.maxW !== void 0 && s.maxW < s.w) throw new Error(`Layout ${o}: ${s.i} maxW below w.`);
583
- if (s.maxH !== void 0 && s.maxH < s.h) throw new Error(`Layout ${o}: ${s.i} maxH below h.`);
584
- }
585
- if (Bt(e)) throw new Error(`Layout ${o} has overlapping items.`);
586
- if (!St(e)) throw new Error(`Layout ${o} isn't packed.`);
587
- }
588
- }
589
- export {
590
- k as D,
591
- Ut as a,
592
- qt as b,
593
- _t as i,
594
- Xt as r
595
- };