@fileverse-dev/dsheet 2.1.5 → 3.0.1-formula-1

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 (132) hide show
  1. package/dist/{constants-yStXQJiK.js → constants-Cdz6oSCq.js} +5 -7
  2. package/dist/constants.js +1 -1
  3. package/dist/editor/components/api-key-modal/api-key-input.d.ts +5 -0
  4. package/dist/editor/components/api-key-modal/api-key-modal.d.ts +7 -0
  5. package/dist/editor/components/api-key-modal/rate-limit-info.d.ts +4 -0
  6. package/dist/editor/components/comments/comment-actions-dropdown.d.ts +19 -0
  7. package/dist/editor/components/comments/comment-cell-popup.d.ts +4 -0
  8. package/dist/editor/components/comments/comment-input.d.ts +4 -0
  9. package/dist/editor/components/comments/comment-item.d.ts +4 -0
  10. package/dist/editor/components/comments/comment-sidebar-empty.d.ts +4 -0
  11. package/dist/editor/components/comments/comment-sidebar.d.ts +4 -0
  12. package/dist/editor/components/comments/ens/ens-cache.d.ts +10 -0
  13. package/dist/editor/components/comments/ens/use-ens-status.d.ts +10 -0
  14. package/dist/editor/components/comments/use-comment-cell-popup.d.ts +12 -0
  15. package/dist/editor/components/comments/use-comment-permissions.d.ts +15 -0
  16. package/dist/editor/components/editor-workbook-sync.d.ts +1 -1
  17. package/dist/editor/components/editor-workbook.d.ts +11 -17
  18. package/dist/editor/components/sidebar/editor-right-sidebar.d.ts +20 -0
  19. package/dist/editor/components/sidebar/right-sidebar.d.ts +14 -0
  20. package/dist/editor/components/sidebar/sidebar-context.d.ts +17 -0
  21. package/dist/editor/components/sidebar/sidebar-portal-registry.d.ts +20 -0
  22. package/dist/editor/components/sidebar/use-right-panels.d.ts +12 -0
  23. package/dist/editor/components/sidebars/conditional-format.d.ts +2 -0
  24. package/dist/editor/components/sidebars/data-verification.d.ts +2 -0
  25. package/dist/editor/components/sidebars/function/function-categories-logic.d.ts +11 -0
  26. package/dist/editor/components/sidebars/function/function-categories.d.ts +6 -0
  27. package/dist/editor/components/sidebars/function/function-metadata.d.ts +7 -0
  28. package/dist/editor/components/sidebars/function/functionList.d.ts +8 -0
  29. package/dist/editor/components/sidebars/function/types.d.ts +24 -0
  30. package/dist/editor/components/sidebars/function/use-functions.d.ts +20 -0
  31. package/dist/editor/components/sidebars/function-content.d.ts +8 -0
  32. package/dist/editor/components/sidebars/named-ranges.d.ts +2 -0
  33. package/dist/editor/components/sidebars/template-ui.d.ts +22 -0
  34. package/dist/editor/components/sidebars/templates.d.ts +9 -0
  35. package/dist/editor/components/smart-contract/error-toast.d.ts +11 -0
  36. package/dist/editor/components/smart-contract/modal/abi-input-section.d.ts +11 -0
  37. package/dist/editor/components/smart-contract/modal/contract-name-section.d.ts +13 -0
  38. package/dist/editor/components/smart-contract/modal/file-upload-section.d.ts +12 -0
  39. package/dist/editor/components/smart-contract/modal/import-section.d.ts +8 -0
  40. package/dist/editor/components/smart-contract/modal/modal-header.d.ts +17 -0
  41. package/dist/editor/components/smart-contract/smart-contract-list-item.d.ts +8 -0
  42. package/dist/editor/components/smart-contract/smart-contract-modal-ui.d.ts +33 -0
  43. package/dist/editor/components/smart-contract/smart-contract-modal.d.ts +12 -0
  44. package/dist/editor/components/smart-contract/smart-contract-reading-intro.d.ts +4 -0
  45. package/dist/editor/components/smart-contract/smart-contract-view-list.d.ts +6 -0
  46. package/dist/editor/components/smart-contract/use-address-validation.d.ts +5 -0
  47. package/dist/editor/components/smart-contract/use-modal-outside-click.d.ts +18 -0
  48. package/dist/editor/components/smart-contract/use-smart-contract-modal.d.ts +38 -0
  49. package/dist/editor/constants/shared-constants.d.ts +0 -2
  50. package/dist/editor/contexts/editor-context.d.ts +20 -5
  51. package/dist/editor/dsheet-editor.d.ts +1 -1
  52. package/dist/editor/hooks/live-query/use-live-query.d.ts +4 -2
  53. package/dist/editor/hooks/use-celldata-compaction.d.ts +23 -0
  54. package/dist/editor/hooks/use-editor-data.d.ts +4 -2
  55. package/dist/editor/hooks/use-smart-contract.d.ts +26 -0
  56. package/dist/editor/hooks/use-xlsx-import-impl.d.ts +8 -1
  57. package/dist/editor/hooks/use-xlsx-import.d.ts +2 -1
  58. package/dist/editor/types/comments.d.ts +134 -0
  59. package/dist/editor/types/smart-contract.d.ts +88 -0
  60. package/dist/editor/types.d.ts +39 -32
  61. package/dist/editor/utils/after-update-cell.d.ts +13 -8
  62. package/dist/editor/utils/api-key-storage.d.ts +6 -0
  63. package/dist/editor/utils/api-keys-local-storage.d.ts +19 -0
  64. package/dist/editor/utils/cell-comment-marker.d.ts +30 -0
  65. package/dist/editor/utils/comment-key-utils.d.ts +7 -0
  66. package/dist/editor/utils/compact-committed-celldata.d.ts +28 -0
  67. package/dist/editor/utils/config-ydoc-update.d.ts +20 -0
  68. package/dist/editor/utils/csv-import.d.ts +3 -1
  69. package/dist/editor/utils/data-block-error-handler.d.ts +21 -0
  70. package/dist/editor/utils/datablock-error-utils.d.ts +1 -0
  71. package/dist/editor/utils/defined-names-ydoc.d.ts +31 -0
  72. package/dist/editor/utils/sheet-editor-safe.d.ts +26 -0
  73. package/dist/editor/utils/smart-contract/constants.d.ts +488 -0
  74. package/dist/editor/utils/smart-contract/error-helper.d.ts +20 -0
  75. package/dist/editor/utils/smart-contract/helpers.d.ts +4 -0
  76. package/dist/editor/utils/smart-contract/reading-utils.d.ts +34 -0
  77. package/dist/editor/utils/smart-contract/signature-utils.d.ts +9 -0
  78. package/dist/editor/utils/spreadsheet-import.d.ts +12 -0
  79. package/dist/editor/utils/update-ydoc.d.ts +2 -2
  80. package/dist/editor/utils/xlsx-defined-names.d.ts +41 -0
  81. package/dist/executeStringFunction-DMPoSj5F.js +32826 -0
  82. package/dist/formula.js +1 -1
  83. package/dist/index-DAVuAF9T.js +55303 -0
  84. package/dist/index.d.ts +11 -1
  85. package/dist/index.es.js +55 -49
  86. package/dist/jszip.min-CEyB-71x.js +2319 -0
  87. package/dist/sheet-engine/core/api/cell.d.ts +0 -20
  88. package/dist/sheet-engine/core/api/common.d.ts +2 -1
  89. package/dist/sheet-engine/core/api/index.d.ts +1 -0
  90. package/dist/sheet-engine/core/api/sheet-flowdata-lifecycle.d.ts +17 -0
  91. package/dist/sheet-engine/core/api/sheet.d.ts +5 -0
  92. package/dist/sheet-engine/core/context.d.ts +8 -1
  93. package/dist/sheet-engine/core/index.d.ts +2 -2
  94. package/dist/sheet-engine/core/modules/formula-async-eval.d.ts +53 -0
  95. package/dist/sheet-engine/core/modules/formula-eval.worker.d.ts +1 -0
  96. package/dist/sheet-engine/core/modules/formula-range-cache.d.ts +20 -0
  97. package/dist/sheet-engine/core/modules/formula-snapshot-eval.d.ts +51 -0
  98. package/dist/sheet-engine/core/modules/formula-transitive-deps.d.ts +7 -0
  99. package/dist/sheet-engine/core/modules/formula-worker-bridge.d.ts +17 -0
  100. package/dist/sheet-engine/core/modules/formula-worker-types.d.ts +24 -0
  101. package/dist/sheet-engine/core/modules/formula.d.ts +53 -1
  102. package/dist/sheet-engine/core/modules/index.d.ts +5 -2
  103. package/dist/sheet-engine/core/modules/namedRanges.d.ts +53 -0
  104. package/dist/sheet-engine/core/modules/sheet-metadata-hooks.d.ts +4 -0
  105. package/dist/sheet-engine/core/modules/sheet.d.ts +17 -1
  106. package/dist/sheet-engine/core/paste/paste-border-utils.d.ts +23 -0
  107. package/dist/sheet-engine/core/settings.d.ts +3 -1
  108. package/dist/sheet-engine/core/theme.d.ts +67 -0
  109. package/dist/sheet-engine/core/types.d.ts +20 -0
  110. package/dist/sheet-engine/core/utils/border-config-utils.d.ts +16 -0
  111. package/dist/sheet-engine/core/utils/cell-persist-utils.d.ts +10 -0
  112. package/dist/sheet-engine/core/utils/range-format.d.ts +71 -0
  113. package/dist/sheet-engine/core/utils/ydoc-celldata-changes.d.ts +40 -0
  114. package/dist/sheet-engine/react/components/NamedRanges/index.d.ts +4 -0
  115. package/dist/sheet-engine/react/components/SheetOverlay/Icon.d.ts +5 -4
  116. package/dist/sheet-engine/react/components/SheetOverlay/LucideIcon.d.ts +4 -4
  117. package/dist/sheet-engine/react/components/SidebarPanelPortals/index.d.ts +17 -0
  118. package/dist/sheet-engine/react/components/Workbook/api.d.ts +8 -1
  119. package/dist/sheet-engine/react/components/Workbook/index.d.ts +11 -1
  120. package/dist/sheet-engine/react/components/index.d.ts +1 -0
  121. package/dist/sheet-engine/react/utils/datepickerStyles.d.ts +1 -1
  122. package/dist/style.css +1 -1
  123. package/dist/use-xlsx-import-impl-DzthrhwA.js +1595 -0
  124. package/dist/xlsx-defined-names-D2KoICbm.js +117 -0
  125. package/dist/xlsx-export-impl-b2z4De4f.js +818 -0
  126. package/package.json +6 -4
  127. package/dist/executeStringFunction-BkmJj04p.js +0 -27295
  128. package/dist/index-Drl8OuI3.js +0 -52659
  129. package/dist/sheet-engine/react/components/Toolbar/conditionalFormatPortal.d.ts +0 -7
  130. package/dist/sheet-engine/react/components/Toolbar/dataVerificationPortal.d.ts +0 -6
  131. package/dist/use-xlsx-import-impl-DC_BfAcT.js +0 -1527
  132. package/dist/xlsx-export-impl-DP_eK3zS.js +0 -3126
@@ -1,1527 +0,0 @@
1
- import { g as Ue } from "./executeStringFunction-BkmJj04p.js";
2
- import * as qe from "yjs";
3
- import { m as Xe, y as Ze } from "./index-Drl8OuI3.js";
4
- import { n as Je } from "./xlsx-hyperlink-inline-DzewAypN.js";
5
- import { toast as Be } from "@fileverse/ui";
6
- var We = { exports: {} };
7
- (function(_) {
8
- var u = {}, d = function(w) {
9
- w.version = "0.11.2";
10
- function C(r) {
11
- for (var t = "", e = r.length - 1; e >= 0; ) t += r.charAt(e--);
12
- return t;
13
- }
14
- function $(r, t) {
15
- for (var e = ""; e.length < t; ) e += r;
16
- return e;
17
- }
18
- function T(r, t) {
19
- var e = "" + r;
20
- return e.length >= t ? e : $("0", t - e.length) + e;
21
- }
22
- function V(r, t) {
23
- var e = "" + r;
24
- return e.length >= t ? e : $(" ", t - e.length) + e;
25
- }
26
- function B(r, t) {
27
- var e = "" + r;
28
- return e.length >= t ? e : e + $(" ", t - e.length);
29
- }
30
- function q(r, t) {
31
- var e = "" + Math.round(r);
32
- return e.length >= t ? e : $("0", t - e.length) + e;
33
- }
34
- function oe(r, t) {
35
- var e = "" + r;
36
- return e.length >= t ? e : $("0", t - e.length) + e;
37
- }
38
- var fe = Math.pow(2, 32);
39
- function ie(r, t) {
40
- if (r > fe || r < -fe) return q(r, t);
41
- var e = Math.round(r);
42
- return oe(e, t);
43
- }
44
- function se(r, t) {
45
- return t = t || 0, r.length >= 7 + t && (r.charCodeAt(t) | 32) === 103 && (r.charCodeAt(t + 1) | 32) === 101 && (r.charCodeAt(t + 2) | 32) === 110 && (r.charCodeAt(t + 3) | 32) === 101 && (r.charCodeAt(t + 4) | 32) === 114 && (r.charCodeAt(t + 5) | 32) === 97 && (r.charCodeAt(t + 6) | 32) === 108;
46
- }
47
- var ve = [
48
- ["Sun", "Sunday"],
49
- ["Mon", "Monday"],
50
- ["Tue", "Tuesday"],
51
- ["Wed", "Wednesday"],
52
- ["Thu", "Thursday"],
53
- ["Fri", "Friday"],
54
- ["Sat", "Saturday"]
55
- ], we = [
56
- ["J", "Jan", "January"],
57
- ["F", "Feb", "February"],
58
- ["M", "Mar", "March"],
59
- ["A", "Apr", "April"],
60
- ["M", "May", "May"],
61
- ["J", "Jun", "June"],
62
- ["J", "Jul", "July"],
63
- ["A", "Aug", "August"],
64
- ["S", "Sep", "September"],
65
- ["O", "Oct", "October"],
66
- ["N", "Nov", "November"],
67
- ["D", "Dec", "December"]
68
- ];
69
- function Oe(r) {
70
- r[0] = "General", r[1] = "0", r[2] = "0.00", r[3] = "#,##0", r[4] = "#,##0.00", r[9] = "0%", r[10] = "0.00%", r[11] = "0.00E+00", r[12] = "# ?/?", r[13] = "# ??/??", r[14] = "m/d/yy", r[15] = "d-mmm-yy", r[16] = "d-mmm", r[17] = "mmm-yy", r[18] = "h:mm AM/PM", r[19] = "h:mm:ss AM/PM", r[20] = "h:mm", r[21] = "h:mm:ss", r[22] = "m/d/yy h:mm", r[37] = "#,##0 ;(#,##0)", r[38] = "#,##0 ;[Red](#,##0)", r[39] = "#,##0.00;(#,##0.00)", r[40] = "#,##0.00;[Red](#,##0.00)", r[45] = "mm:ss", r[46] = "[h]:mm:ss", r[47] = "mmss.0", r[48] = "##0.0E+0", r[49] = "@", r[56] = '"上午/下午 "hh"時"mm"分"ss"秒 "';
71
- }
72
- var te = {};
73
- Oe(te);
74
- var G = [], M = 0;
75
- for (M = 5; M <= 8; ++M) G[M] = 32 + M;
76
- for (M = 23; M <= 26; ++M) G[M] = 0;
77
- for (M = 27; M <= 31; ++M) G[M] = 14;
78
- for (M = 50; M <= 58; ++M) G[M] = 14;
79
- for (M = 59; M <= 62; ++M) G[M] = M - 58;
80
- for (M = 67; M <= 68; ++M) G[M] = M - 58;
81
- for (M = 72; M <= 75; ++M) G[M] = M - 58;
82
- for (M = 67; M <= 68; ++M) G[M] = M - 57;
83
- for (M = 76; M <= 78; ++M) G[M] = M - 56;
84
- for (M = 79; M <= 81; ++M) G[M] = M - 34;
85
- var I = [];
86
- I[5] = I[63] = '"$"#,##0_);\\("$"#,##0\\)', I[6] = I[64] = '"$"#,##0_);[Red]\\("$"#,##0\\)', I[7] = I[65] = '"$"#,##0.00_);\\("$"#,##0.00\\)', I[8] = I[66] = '"$"#,##0.00_);[Red]\\("$"#,##0.00\\)', I[41] = '_(* #,##0_);_(* \\(#,##0\\);_(* "-"_);_(@_)', I[42] = '_("$"* #,##0_);_("$"* \\(#,##0\\);_("$"* "-"_);_(@_)', I[43] = '_(* #,##0.00_);_(* \\(#,##0.00\\);_(* "-"??_);_(@_)', I[44] = '_("$"* #,##0.00_);_("$"* \\(#,##0.00\\);_("$"* "-"??_);_(@_)';
87
- function ke(r, t, e) {
88
- for (var b = r < 0 ? -1 : 1, n = r * b, p = 0, a = 1, l = 0, y = 1, h = 0, m = 0, A = Math.floor(n); h < t && (A = Math.floor(n), l = A * a + p, m = A * h + y, !(n - A < 5e-8)); )
89
- n = 1 / (n - A), p = a, a = l, y = h, h = m;
90
- if (m > t && (h > t ? (m = y, l = p) : (m = h, l = a)), !e) return [0, b * l, m];
91
- var R = Math.floor(b * l / m);
92
- return [R, b * l - R * m, m];
93
- }
94
- function pe(r, t, e) {
95
- if (r > 2958465 || r < 0) return null;
96
- var b = r | 0, n = Math.floor(86400 * (r - b)), p = 0, a = [], l = { D: b, T: n, u: 86400 * (r - b) - n, y: 0, m: 0, d: 0, H: 0, M: 0, S: 0, q: 0 };
97
- if (Math.abs(l.u) < 1e-6 && (l.u = 0), t && t.date1904 && (b += 1462), l.u > 0.9999 && (l.u = 0, ++n == 86400 && (l.T = n = 0, ++b, ++l.D)), b === 60)
98
- a = e ? [1317, 10, 29] : [1900, 2, 29], p = 3;
99
- else if (b === 0)
100
- a = e ? [1317, 8, 29] : [1900, 1, 0], p = 6;
101
- else {
102
- b > 60 && --b;
103
- var y = new Date(1900, 0, 1);
104
- y.setDate(y.getDate() + b - 1), a = [y.getFullYear(), y.getMonth() + 1, y.getDate()], p = y.getDay(), b < 60 && (p = (p + 6) % 7), e && (p = Te(y, a));
105
- }
106
- return l.y = a[0], l.m = a[1], l.d = a[2], l.S = n % 60, n = Math.floor(n / 60), l.M = n % 60, n = Math.floor(n / 60), l.H = n, l.q = p, l;
107
- }
108
- w.parse_date_code = pe;
109
- var Se = new Date(1899, 11, 31, 0, 0, 0), De = Se.getTime(), Re = new Date(1900, 2, 1, 0, 0, 0);
110
- function Ne(r, t) {
111
- var e = r.getTime();
112
- return t ? e -= 1262304e5 : r >= Re && (e += 864e5), (e - (De + (r.getTimezoneOffset() - Se.getTimezoneOffset()) * 6e4)) / 864e5;
113
- }
114
- function _e(r) {
115
- return r.toString(10);
116
- }
117
- w._general_int = _e;
118
- var Ce = /* @__PURE__ */ function() {
119
- var t = /(?:\.0*|(\.\d*[1-9])0+)$/;
120
- function e(h) {
121
- return h.indexOf(".") == -1 ? h : h.replace(t, "$1");
122
- }
123
- var b = /(?:\.0*|(\.\d*[1-9])0+)[Ee]/, n = /(E[+-])(\d)$/;
124
- function p(h) {
125
- return h.indexOf("E") == -1 ? h : h.replace(b, "$1E").replace(n, "$10$2");
126
- }
127
- function a(h) {
128
- var m = h < 0 ? 12 : 11, A = e(h.toFixed(12));
129
- return A.length <= m || (A = h.toPrecision(10), A.length <= m) ? A : h.toExponential(5);
130
- }
131
- function l(h) {
132
- var m = e(h.toFixed(11));
133
- return m.length > (h < 0 ? 12 : 11) || m === "0" || m === "-0" ? h.toPrecision(6) : m;
134
- }
135
- function y(h) {
136
- var m = Math.floor(Math.log(Math.abs(h)) * Math.LOG10E), A;
137
- return m >= -4 && m <= -1 ? A = h.toPrecision(10 + m) : Math.abs(m) <= 9 ? A = a(h) : m === 10 ? A = h.toFixed(10).substr(0, 12) : A = l(h), e(p(A.toUpperCase()));
138
- }
139
- return y;
140
- }();
141
- w._general_num = Ce;
142
- function me(r, t) {
143
- switch (typeof r) {
144
- case "string":
145
- return r;
146
- case "boolean":
147
- return r ? "TRUE" : "FALSE";
148
- case "number":
149
- return (r | 0) === r ? r.toString(10) : Ce(r);
150
- case "undefined":
151
- return "";
152
- case "object":
153
- if (r == null) return "";
154
- if (r instanceof Date) return ne(14, Ne(r, t && t.date1904), t);
155
- }
156
- throw new Error("unsupported value in General format: " + r);
157
- }
158
- w._general = me;
159
- function Te(r, t) {
160
- t[0] -= 581;
161
- var e = r.getDay();
162
- return r < 60 && (e = (e + 6) % 7), e;
163
- }
164
- function Fe(r, t, e, b) {
165
- var n = "", p = 0, a = 0, l = e.y, y, h = 0;
166
- switch (r) {
167
- case 98:
168
- l = e.y + 543;
169
- case 121:
170
- switch (t.length) {
171
- case 1:
172
- case 2:
173
- y = l % 100, h = 2;
174
- break;
175
- default:
176
- y = l % 1e4, h = 4;
177
- break;
178
- }
179
- break;
180
- case 109:
181
- switch (t.length) {
182
- case 1:
183
- case 2:
184
- y = e.m, h = t.length;
185
- break;
186
- case 3:
187
- return we[e.m - 1][1];
188
- case 5:
189
- return we[e.m - 1][0];
190
- default:
191
- return we[e.m - 1][2];
192
- }
193
- break;
194
- case 100:
195
- switch (t.length) {
196
- case 1:
197
- case 2:
198
- y = e.d, h = t.length;
199
- break;
200
- case 3:
201
- return ve[e.q][0];
202
- default:
203
- return ve[e.q][1];
204
- }
205
- break;
206
- case 104:
207
- switch (t.length) {
208
- case 1:
209
- case 2:
210
- y = 1 + (e.H + 11) % 12, h = t.length;
211
- break;
212
- default:
213
- throw "bad hour format: " + t;
214
- }
215
- break;
216
- case 72:
217
- switch (t.length) {
218
- case 1:
219
- case 2:
220
- y = e.H, h = t.length;
221
- break;
222
- default:
223
- throw "bad hour format: " + t;
224
- }
225
- break;
226
- case 77:
227
- switch (t.length) {
228
- case 1:
229
- case 2:
230
- y = e.M, h = t.length;
231
- break;
232
- default:
233
- throw "bad minute format: " + t;
234
- }
235
- break;
236
- case 115:
237
- if (t != "s" && t != "ss" && t != ".0" && t != ".00" && t != ".000") throw "bad second format: " + t;
238
- return e.u === 0 && (t == "s" || t == "ss") ? T(e.S, t.length) : (b >= 2 ? a = b === 3 ? 1e3 : 100 : a = b === 1 ? 10 : 1, p = Math.round(a * (e.S + e.u)), p >= 60 * a && (p = 0), t === "s" ? p === 0 ? "0" : "" + p / a : (n = T(p, 2 + b), t === "ss" ? n.substr(0, 2) : "." + n.substr(2, t.length - 1)));
239
- case 90:
240
- switch (t) {
241
- case "[h]":
242
- case "[hh]":
243
- y = e.D * 24 + e.H;
244
- break;
245
- case "[m]":
246
- case "[mm]":
247
- y = (e.D * 24 + e.H) * 60 + e.M;
248
- break;
249
- case "[s]":
250
- case "[ss]":
251
- y = ((e.D * 24 + e.H) * 60 + e.M) * 60 + Math.round(e.S + e.u);
252
- break;
253
- default:
254
- throw "bad abstime format: " + t;
255
- }
256
- h = t.length === 3 ? 1 : 2;
257
- break;
258
- case 101:
259
- y = l, h = 1;
260
- break;
261
- }
262
- var m = h > 0 ? T(y, h) : "";
263
- return m;
264
- }
265
- function Q(r) {
266
- var t = 3;
267
- if (r.length <= t) return r;
268
- for (var e = r.length % t, b = r.substr(0, e); e != r.length; e += t) b += (b.length > 0 ? "," : "") + r.substr(e, t);
269
- return b;
270
- }
271
- var X = /* @__PURE__ */ function() {
272
- var t = /%/g;
273
- function e(f, i, o) {
274
- var x = i.replace(t, ""), c = i.length - x.length;
275
- return X(f, x, o * Math.pow(10, 2 * c)) + $("%", c);
276
- }
277
- function b(f, i, o) {
278
- for (var x = i.length - 1; i.charCodeAt(x - 1) === 44; ) --x;
279
- return X(f, i.substr(0, x), o / Math.pow(10, 3 * (i.length - x)));
280
- }
281
- function n(f, i) {
282
- var o, x = f.indexOf("E") - f.indexOf(".") - 1;
283
- if (f.match(/^#+0.0E\+0$/)) {
284
- if (i == 0) return "0.0E+0";
285
- if (i < 0) return "-" + n(f, -i);
286
- var c = f.indexOf(".");
287
- c === -1 && (c = f.indexOf("E"));
288
- var s = Math.floor(Math.log(i) * Math.LOG10E) % c;
289
- if (s < 0 && (s += c), o = (i / Math.pow(10, s)).toPrecision(x + 1 + (c + s) % c), o.indexOf("e") === -1) {
290
- var E = Math.floor(Math.log(i) * Math.LOG10E);
291
- for (o.indexOf(".") === -1 ? o = o.charAt(0) + "." + o.substr(1) + "E+" + (E - o.length + s) : o += "E+" + (E - s); o.substr(0, 2) === "0."; )
292
- o = o.charAt(0) + o.substr(2, c) + "." + o.substr(2 + c), o = o.replace(/^0+([1-9])/, "$1").replace(/^0+\./, "0.");
293
- o = o.replace(/\+-/, "-");
294
- }
295
- o = o.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/, function(P, L, H, O) {
296
- return L + H + O.substr(0, (c + s) % c) + "." + O.substr(s) + "E";
297
- });
298
- } else o = i.toExponential(x);
299
- return f.match(/E\+00$/) && o.match(/e[+-]\d$/) && (o = o.substr(0, o.length - 1) + "0" + o.charAt(o.length - 1)), f.match(/E\-/) && o.match(/e\+/) && (o = o.replace(/e\+/, "e")), o.replace("e", "E");
300
- }
301
- var p = /# (\?+)( ?)\/( ?)(\d+)/;
302
- function a(f, i, o) {
303
- var x = parseInt(f[4], 10), c = Math.round(i * x), s = Math.floor(c / x), E = c - s * x, P = x;
304
- return o + (s === 0 ? "" : "" + s) + " " + (E === 0 ? $(" ", f[1].length + 1 + f[4].length) : V(E, f[1].length) + f[2] + "/" + f[3] + T(P, f[4].length));
305
- }
306
- function l(f, i, o) {
307
- return o + (i === 0 ? "" : "" + i) + $(" ", f[1].length + 2 + f[4].length);
308
- }
309
- var y = /^#*0*\.([0#]+)/, h = /\).*[0#]/, m = /\(###\) ###\\?-####/;
310
- function A(f) {
311
- for (var i = "", o, x = 0; x != f.length; ++x) switch (o = f.charCodeAt(x)) {
312
- case 35:
313
- break;
314
- case 63:
315
- i += " ";
316
- break;
317
- case 48:
318
- i += "0";
319
- break;
320
- default:
321
- i += String.fromCharCode(o);
322
- }
323
- return i;
324
- }
325
- function R(f, i) {
326
- var o = Math.pow(10, i);
327
- return "" + Math.round(f * o) / o;
328
- }
329
- function K(f, i) {
330
- var o = f - Math.floor(f), x = Math.pow(10, i);
331
- return i < ("" + Math.round(o * x)).length ? 0 : Math.round(o * x);
332
- }
333
- function ue(f, i) {
334
- return i < ("" + Math.round((f - Math.floor(f)) * Math.pow(10, i))).length ? 1 : 0;
335
- }
336
- function Y(f) {
337
- return f < 2147483647 && f > -2147483648 ? "" + (f >= 0 ? f | 0 : f - 1 | 0) : "" + Math.floor(f);
338
- }
339
- function S(f, i, o) {
340
- if (f.charCodeAt(0) === 40 && !i.match(h)) {
341
- var x = i.replace(/\( */, "").replace(/ \)/, "").replace(/\)/, "");
342
- return o >= 0 ? S("n", x, o) : "(" + S("n", x, -o) + ")";
343
- }
344
- if (i.charCodeAt(i.length - 1) === 44) return b(f, i, o);
345
- if (i.indexOf("%") !== -1) return e(f, i, o);
346
- if (i.indexOf("E") !== -1) return n(i, o);
347
- if (i.charCodeAt(0) === 36) return "$" + S(f, i.substr(i.charAt(1) == " " ? 2 : 1), o);
348
- var c, s, E, P, L = Math.abs(o), H = o < 0 ? "-" : "";
349
- if (i.match(/^00+$/)) return H + ie(L, i.length);
350
- if (i.match(/^[#?]+$/))
351
- return c = ie(o, 0), c === "0" && (c = ""), c.length > i.length ? c : A(i.substr(0, i.length - c.length)) + c;
352
- if (s = i.match(p)) return a(s, L, H);
353
- if (i.match(/^#+0+$/)) return H + ie(L, i.length - i.indexOf("0"));
354
- if (s = i.match(y))
355
- return c = R(o, s[1].length).replace(/^([^\.]+)$/, "$1." + A(s[1])).replace(/\.$/, "." + A(s[1])).replace(/\.(\d*)$/, function(g, N) {
356
- return "." + N + $("0", A(s[1]).length - N.length);
357
- }), i.indexOf("0.") !== -1 ? c : c.replace(/^0\./, ".");
358
- if (i = i.replace(/^#+([0.])/, "$1"), s = i.match(/^(0*)\.(#*)$/))
359
- return H + R(L, s[2].length).replace(/\.(\d*[1-9])0*$/, ".$1").replace(/^(-?\d*)$/, "$1.").replace(/^0\./, s[1].length ? "0." : ".");
360
- if (s = i.match(/^#{1,3},##0(\.?)$/)) return H + Q(ie(L, 0));
361
- if (s = i.match(/^#,##0\.([#0]*0)$/))
362
- return o < 0 ? "-" + S(f, i, -o) : Q("" + (Math.floor(o) + ue(o, s[1].length))) + "." + T(K(o, s[1].length), s[1].length);
363
- if (s = i.match(/^#,#*,#0/)) return S(f, i.replace(/^#,#*,/, ""), o);
364
- if (s = i.match(/^([0#]+)(\\?-([0#]+))+$/))
365
- return c = C(S(f, i.replace(/[\\-]/g, ""), o)), E = 0, C(C(i.replace(/\\/g, "")).replace(/[0#]/g, function(g) {
366
- return E < c.length ? c.charAt(E++) : g === "0" ? "0" : "";
367
- }));
368
- if (i.match(m))
369
- return c = S(f, "##########", o), "(" + c.substr(0, 3) + ") " + c.substr(3, 3) + "-" + c.substr(6);
370
- var O = "";
371
- if (s = i.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/))
372
- return E = Math.min(s[4].length, 7), P = ke(L, Math.pow(10, E) - 1, !1), c = "" + H, O = X("n", s[1], P[1]), O.charAt(O.length - 1) == " " && (O = O.substr(0, O.length - 1) + "0"), c += O + s[2] + "/" + s[3], O = B(P[2], E), O.length < s[4].length && (O = A(s[4].substr(s[4].length - O.length)) + O), c += O, c;
373
- if (s = i.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/))
374
- return E = Math.min(Math.max(s[1].length, s[4].length), 7), P = ke(L, Math.pow(10, E) - 1, !0), H + (P[0] || (P[1] ? "" : "0")) + " " + (P[1] ? V(P[1], E) + s[2] + "/" + s[3] + B(P[2], E) : $(" ", 2 * E + 1 + s[2].length + s[3].length));
375
- if (s = i.match(/^[#0?]+$/))
376
- return c = ie(o, 0), i.length <= c.length ? c : A(i.substr(0, i.length - c.length)) + c;
377
- if (s = i.match(/^([#0?]+)\.([#0]+)$/)) {
378
- c = "" + o.toFixed(Math.min(s[2].length, 10)).replace(/([^0])0+$/, "$1"), E = c.indexOf(".");
379
- var de = i.indexOf(".") - E, Me = i.length - c.length - de;
380
- return A(i.substr(0, de) + c + i.substr(i.length - Me));
381
- }
382
- if (s = i.match(/^00,000\.([#0]*0)$/))
383
- return E = K(o, s[1].length), o < 0 ? "-" + S(f, i, -o) : Q(Y(o)).replace(/^\d,\d{3}$/, "0$&").replace(/^\d*$/, function(g) {
384
- return "00," + (g.length < 3 ? T(0, 3 - g.length) : "") + g;
385
- }) + "." + T(E, s[1].length);
386
- switch (i) {
387
- case "###,##0.00":
388
- return S(f, "#,##0.00", o);
389
- case "###,###":
390
- case "##,###":
391
- case "#,###":
392
- var be = Q(ie(L, 0));
393
- return be !== "0" ? H + be : "";
394
- case "###,###.00":
395
- return S(f, "###,##0.00", o).replace(/^0\./, ".");
396
- case "#,###.00":
397
- return S(f, "#,##0.00", o).replace(/^0\./, ".");
398
- }
399
- throw new Error("unsupported format |" + i + "|");
400
- }
401
- function U(f, i, o) {
402
- for (var x = i.length - 1; i.charCodeAt(x - 1) === 44; ) --x;
403
- return X(f, i.substr(0, x), o / Math.pow(10, 3 * (i.length - x)));
404
- }
405
- function he(f, i, o) {
406
- var x = i.replace(t, ""), c = i.length - x.length;
407
- return X(f, x, o * Math.pow(10, 2 * c)) + $("%", c);
408
- }
409
- function ae(f, i) {
410
- var o, x = f.indexOf("E") - f.indexOf(".") - 1;
411
- if (f.match(/^#+0.0E\+0$/)) {
412
- if (i == 0) return "0.0E+0";
413
- if (i < 0) return "-" + ae(f, -i);
414
- var c = f.indexOf(".");
415
- c === -1 && (c = f.indexOf("E"));
416
- var s = Math.floor(Math.log(i) * Math.LOG10E) % c;
417
- if (s < 0 && (s += c), o = (i / Math.pow(10, s)).toPrecision(x + 1 + (c + s) % c), !o.match(/[Ee]/)) {
418
- var E = Math.floor(Math.log(i) * Math.LOG10E);
419
- o.indexOf(".") === -1 ? o = o.charAt(0) + "." + o.substr(1) + "E+" + (E - o.length + s) : o += "E+" + (E - s), o = o.replace(/\+-/, "-");
420
- }
421
- o = o.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/, function(P, L, H, O) {
422
- return L + H + O.substr(0, (c + s) % c) + "." + O.substr(s) + "E";
423
- });
424
- } else o = i.toExponential(x);
425
- return f.match(/E\+00$/) && o.match(/e[+-]\d$/) && (o = o.substr(0, o.length - 1) + "0" + o.charAt(o.length - 1)), f.match(/E\-/) && o.match(/e\+/) && (o = o.replace(/e\+/, "e")), o.replace("e", "E");
426
- }
427
- function v(f, i, o) {
428
- if (f.charCodeAt(0) === 40 && !i.match(h)) {
429
- var x = i.replace(/\( */, "").replace(/ \)/, "").replace(/\)/, "");
430
- return o >= 0 ? v("n", x, o) : "(" + v("n", x, -o) + ")";
431
- }
432
- if (i.charCodeAt(i.length - 1) === 44) return U(f, i, o);
433
- if (i.indexOf("%") !== -1) return he(f, i, o);
434
- if (i.indexOf("E") !== -1) return ae(i, o);
435
- if (i.charCodeAt(0) === 36) return "$" + v(f, i.substr(i.charAt(1) == " " ? 2 : 1), o);
436
- var c, s, E, P, L = Math.abs(o), H = o < 0 ? "-" : "";
437
- if (i.match(/^00+$/)) return H + T(L, i.length);
438
- if (i.match(/^[#?]+$/))
439
- return c = "" + o, o === 0 && (c = ""), c.length > i.length ? c : A(i.substr(0, i.length - c.length)) + c;
440
- if (s = i.match(p)) return l(s, L, H);
441
- if (i.match(/^#+0+$/)) return H + T(L, i.length - i.indexOf("0"));
442
- if (s = i.match(y))
443
- return c = ("" + o).replace(/^([^\.]+)$/, "$1." + A(s[1])).replace(/\.$/, "." + A(s[1])), c = c.replace(/\.(\d*)$/, function(g, N) {
444
- return "." + N + $("0", A(s[1]).length - N.length);
445
- }), i.indexOf("0.") !== -1 ? c : c.replace(/^0\./, ".");
446
- if (i = i.replace(/^#+([0.])/, "$1"), s = i.match(/^(0*)\.(#*)$/))
447
- return H + ("" + L).replace(/\.(\d*[1-9])0*$/, ".$1").replace(/^(-?\d*)$/, "$1.").replace(/^0\./, s[1].length ? "0." : ".");
448
- if (s = i.match(/^#{1,3},##0(\.?)$/)) return H + Q("" + L);
449
- if (s = i.match(/^#,##0\.([#0]*0)$/))
450
- return o < 0 ? "-" + v(f, i, -o) : Q("" + o) + "." + $("0", s[1].length);
451
- if (s = i.match(/^#,#*,#0/)) return v(f, i.replace(/^#,#*,/, ""), o);
452
- if (s = i.match(/^([0#]+)(\\?-([0#]+))+$/))
453
- return c = C(v(f, i.replace(/[\\-]/g, ""), o)), E = 0, C(C(i.replace(/\\/g, "")).replace(/[0#]/g, function(g) {
454
- return E < c.length ? c.charAt(E++) : g === "0" ? "0" : "";
455
- }));
456
- if (i.match(m))
457
- return c = v(f, "##########", o), "(" + c.substr(0, 3) + ") " + c.substr(3, 3) + "-" + c.substr(6);
458
- var O = "";
459
- if (s = i.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/))
460
- return E = Math.min(s[4].length, 7), P = ke(L, Math.pow(10, E) - 1, !1), c = "" + H, O = X("n", s[1], P[1]), O.charAt(O.length - 1) == " " && (O = O.substr(0, O.length - 1) + "0"), c += O + s[2] + "/" + s[3], O = B(P[2], E), O.length < s[4].length && (O = A(s[4].substr(s[4].length - O.length)) + O), c += O, c;
461
- if (s = i.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/))
462
- return E = Math.min(Math.max(s[1].length, s[4].length), 7), P = ke(L, Math.pow(10, E) - 1, !0), H + (P[0] || (P[1] ? "" : "0")) + " " + (P[1] ? V(P[1], E) + s[2] + "/" + s[3] + B(P[2], E) : $(" ", 2 * E + 1 + s[2].length + s[3].length));
463
- if (s = i.match(/^[#0?]+$/))
464
- return c = "" + o, i.length <= c.length ? c : A(i.substr(0, i.length - c.length)) + c;
465
- if (s = i.match(/^([#0]+)\.([#0]+)$/)) {
466
- c = "" + o.toFixed(Math.min(s[2].length, 10)).replace(/([^0])0+$/, "$1"), E = c.indexOf(".");
467
- var de = i.indexOf(".") - E, Me = i.length - c.length - de;
468
- return A(i.substr(0, de) + c + i.substr(i.length - Me));
469
- }
470
- if (s = i.match(/^00,000\.([#0]*0)$/))
471
- return o < 0 ? "-" + v(f, i, -o) : Q("" + o).replace(/^\d,\d{3}$/, "0$&").replace(/^\d*$/, function(g) {
472
- return "00," + (g.length < 3 ? T(0, 3 - g.length) : "") + g;
473
- }) + "." + T(0, s[1].length);
474
- switch (i) {
475
- case "###,###":
476
- case "##,###":
477
- case "#,###":
478
- var be = Q("" + L);
479
- return be !== "0" ? H + be : "";
480
- default:
481
- if (i.match(/\.[0#?]*$/)) return v(f, i.slice(0, i.lastIndexOf(".")), o) + A(i.slice(i.lastIndexOf(".")));
482
- }
483
- throw new Error("unsupported format |" + i + "|");
484
- }
485
- return function(i, o, x) {
486
- return (x | 0) === x ? v(i, o, x) : S(i, o, x);
487
- };
488
- }();
489
- function ye(r) {
490
- for (var t = [], e = !1, b = 0, n = 0; b < r.length; ++b) switch (
491
- /*cc=*/
492
- r.charCodeAt(b)
493
- ) {
494
- case 34:
495
- e = !e;
496
- break;
497
- case 95:
498
- case 42:
499
- case 92:
500
- ++b;
501
- break;
502
- case 59:
503
- t[t.length] = r.substr(n, b - n), n = b + 1;
504
- }
505
- if (t[t.length] = r.substr(n), e === !0) throw new Error("Format |" + r + "| unterminated string ");
506
- return t;
507
- }
508
- w._split = ye;
509
- var Ee = /\[[HhMmSs\u0E0A\u0E19\u0E17]*\]/;
510
- function Ae(r) {
511
- for (var t = 0, e = "", b = ""; t < r.length; )
512
- switch (e = r.charAt(t)) {
513
- case "G":
514
- se(r, t) && (t += 6), t++;
515
- break;
516
- case '"':
517
- for (
518
- ;
519
- /*cc=*/
520
- r.charCodeAt(++t) !== 34 && t < r.length;
521
- )
522
- ;
523
- ++t;
524
- break;
525
- case "\\":
526
- t += 2;
527
- break;
528
- case "_":
529
- t += 2;
530
- break;
531
- case "@":
532
- ++t;
533
- break;
534
- case "B":
535
- case "b":
536
- if (r.charAt(t + 1) === "1" || r.charAt(t + 1) === "2") return !0;
537
- case "M":
538
- case "D":
539
- case "Y":
540
- case "H":
541
- case "S":
542
- case "E":
543
- case "m":
544
- case "d":
545
- case "y":
546
- case "h":
547
- case "s":
548
- case "e":
549
- case "g":
550
- return !0;
551
- case "A":
552
- case "a":
553
- case "上":
554
- if (r.substr(t, 3).toUpperCase() === "A/P" || r.substr(t, 5).toUpperCase() === "AM/PM" || r.substr(t, 5).toUpperCase() === "上午/下午") return !0;
555
- ++t;
556
- break;
557
- case "[":
558
- for (b = e; r.charAt(t++) !== "]" && t < r.length; ) b += r.charAt(t);
559
- if (b.match(Ee)) return !0;
560
- break;
561
- case ".":
562
- case "0":
563
- case "#":
564
- for (; t < r.length && ("0#?.,E+-%".indexOf(e = r.charAt(++t)) > -1 || e == "\\" && r.charAt(t + 1) == "-" && "0#".indexOf(r.charAt(t + 2)) > -1); )
565
- ;
566
- break;
567
- case "?":
568
- for (; r.charAt(++t) === e; )
569
- ;
570
- break;
571
- case "*":
572
- ++t, (r.charAt(t) == " " || r.charAt(t) == "*") && ++t;
573
- break;
574
- case "(":
575
- case ")":
576
- ++t;
577
- break;
578
- case "1":
579
- case "2":
580
- case "3":
581
- case "4":
582
- case "5":
583
- case "6":
584
- case "7":
585
- case "8":
586
- case "9":
587
- for (; t < r.length && "0123456789".indexOf(r.charAt(++t)) > -1; )
588
- ;
589
- break;
590
- case " ":
591
- ++t;
592
- break;
593
- default:
594
- ++t;
595
- break;
596
- }
597
- return !1;
598
- }
599
- w.is_date = Ae;
600
- function z(r, t, e, b) {
601
- for (var n = [], p = "", a = 0, l = "", y = "t", h, m, A, R = "H"; a < r.length; )
602
- switch (l = r.charAt(a)) {
603
- case "G":
604
- if (!se(r, a)) throw new Error("unrecognized character " + l + " in " + r);
605
- n[n.length] = { t: "G", v: "General" }, a += 7;
606
- break;
607
- case '"':
608
- for (p = ""; (A = r.charCodeAt(++a)) !== 34 && a < r.length; ) p += String.fromCharCode(A);
609
- n[n.length] = { t: "t", v: p }, ++a;
610
- break;
611
- case "\\":
612
- var K = r.charAt(++a), ue = K === "(" || K === ")" ? K : "t";
613
- n[n.length] = { t: ue, v: K }, ++a;
614
- break;
615
- case "_":
616
- n[n.length] = { t: "t", v: " " }, a += 2;
617
- break;
618
- case "@":
619
- n[n.length] = { t: "T", v: t }, ++a;
620
- break;
621
- case "B":
622
- case "b":
623
- if (r.charAt(a + 1) === "1" || r.charAt(a + 1) === "2") {
624
- if (h == null && (h = pe(t, e, r.charAt(a + 1) === "2"), h == null))
625
- return "";
626
- n[n.length] = { t: "X", v: r.substr(a, 2) }, y = l, a += 2;
627
- break;
628
- }
629
- case "M":
630
- case "D":
631
- case "Y":
632
- case "H":
633
- case "S":
634
- case "E":
635
- l = l.toLowerCase();
636
- case "m":
637
- case "d":
638
- case "y":
639
- case "h":
640
- case "s":
641
- case "e":
642
- case "g":
643
- if (t < 0 || h == null && (h = pe(t, e), h == null))
644
- return "";
645
- for (p = l; ++a < r.length && r.charAt(a).toLowerCase() === l; ) p += l;
646
- l === "m" && y.toLowerCase() === "h" && (l = "M"), l === "h" && (l = R), n[n.length] = { t: l, v: p }, y = l;
647
- break;
648
- case "A":
649
- case "a":
650
- case "上":
651
- var Y = { t: l, v: l };
652
- if (h == null && (h = pe(t, e)), r.substr(a, 3).toUpperCase() === "A/P" ? (h != null && (Y.v = h.H >= 12 ? "P" : "A"), Y.t = "T", R = "h", a += 3) : r.substr(a, 5).toUpperCase() === "AM/PM" ? (h != null && (Y.v = h.H >= 12 ? "PM" : "AM"), Y.t = "T", a += 5, R = "h") : r.substr(a, 5).toUpperCase() === "上午/下午" ? (h != null && (Y.v = h.H >= 12 ? "下午" : "上午"), Y.t = "T", a += 5, R = "h") : (Y.t = "t", ++a), h == null && Y.t === "T") return "";
653
- n[n.length] = Y, y = l;
654
- break;
655
- case "[":
656
- for (p = l; r.charAt(a++) !== "]" && a < r.length; ) p += r.charAt(a);
657
- if (p.slice(-1) !== "]") throw 'unterminated "[" block: |' + p + "|";
658
- if (p.match(Ee)) {
659
- if (h == null && (h = pe(t, e), h == null))
660
- return "";
661
- n[n.length] = { t: "Z", v: p.toLowerCase() }, y = p.charAt(1);
662
- } else p.indexOf("$") > -1 && (p = (p.match(/\$([^-\[\]]*)/) || [])[1] || "$", Ae(r) || (n[n.length] = { t: "t", v: p }));
663
- break;
664
- case ".":
665
- if (h != null) {
666
- for (p = l; ++a < r.length && (l = r.charAt(a)) === "0"; ) p += l;
667
- n[n.length] = { t: "s", v: p };
668
- break;
669
- }
670
- case "0":
671
- case "#":
672
- for (p = l; ++a < r.length && "0#?.,E+-%".indexOf(l = r.charAt(a)) > -1; ) p += l;
673
- n[n.length] = { t: "n", v: p };
674
- break;
675
- case "?":
676
- for (p = l; r.charAt(++a) === l; ) p += l;
677
- n[n.length] = { t: l, v: p }, y = l;
678
- break;
679
- case "*":
680
- ++a, (r.charAt(a) == " " || r.charAt(a) == "*") && ++a;
681
- break;
682
- case "(":
683
- case ")":
684
- n[n.length] = { t: b === 1 ? "t" : l, v: l }, ++a;
685
- break;
686
- case "1":
687
- case "2":
688
- case "3":
689
- case "4":
690
- case "5":
691
- case "6":
692
- case "7":
693
- case "8":
694
- case "9":
695
- for (p = l; a < r.length && "0123456789".indexOf(r.charAt(++a)) > -1; ) p += r.charAt(a);
696
- n[n.length] = { t: "D", v: p };
697
- break;
698
- case " ":
699
- n[n.length] = { t: l, v: l }, ++a;
700
- break;
701
- case "$":
702
- n[n.length] = { t: "t", v: "$" }, ++a;
703
- break;
704
- default:
705
- if (",$-+/():!^&'~{}<>=€acfijklopqrtuvwxzP".indexOf(l) === -1) throw new Error("unrecognized character " + l + " in " + r);
706
- n[n.length] = { t: "t", v: l }, ++a;
707
- break;
708
- }
709
- var S = 0, U = 0, he;
710
- for (a = n.length - 1, y = "t"; a >= 0; --a)
711
- switch (n[a].t) {
712
- case "h":
713
- case "H":
714
- n[a].t = R, y = "h", S < 1 && (S = 1);
715
- break;
716
- case "s":
717
- (he = n[a].v.match(/\.0+$/)) && (U = Math.max(U, he[0].length - 1)), S < 3 && (S = 3);
718
- case "d":
719
- case "y":
720
- case "M":
721
- case "e":
722
- y = n[a].t;
723
- break;
724
- case "m":
725
- y === "s" && (n[a].t = "M", S < 2 && (S = 2));
726
- break;
727
- case "X":
728
- break;
729
- case "Z":
730
- S < 1 && n[a].v.match(/[Hh]/) && (S = 1), S < 2 && n[a].v.match(/[Mm]/) && (S = 2), S < 3 && n[a].v.match(/[Ss]/) && (S = 3);
731
- }
732
- switch (S) {
733
- case 0:
734
- break;
735
- case 1:
736
- h.u >= 0.5 && (h.u = 0, ++h.S), h.S >= 60 && (h.S = 0, ++h.M), h.M >= 60 && (h.M = 0, ++h.H);
737
- break;
738
- case 2:
739
- h.u >= 0.5 && (h.u = 0, ++h.S), h.S >= 60 && (h.S = 0, ++h.M);
740
- break;
741
- }
742
- var ae = "", v;
743
- for (a = 0; a < n.length; ++a)
744
- switch (n[a].t) {
745
- case "t":
746
- case "T":
747
- case " ":
748
- case "D":
749
- break;
750
- case "X":
751
- n[a].v = "", n[a].t = ";";
752
- break;
753
- case "d":
754
- case "m":
755
- case "y":
756
- case "h":
757
- case "H":
758
- case "M":
759
- case "s":
760
- case "e":
761
- case "b":
762
- case "Z":
763
- n[a].v = Fe(n[a].t.charCodeAt(0), n[a].v, h, U), n[a].t = "t";
764
- break;
765
- case "n":
766
- case "?":
767
- for (v = a + 1; n[v] != null && ((l = n[v].t) === "?" || l === "D" || (l === " " || l === "t") && n[v + 1] != null && (n[v + 1].t === "?" || n[v + 1].t === "t" && n[v + 1].v === "/") || n[a].t === "(" && (l === " " || l === "n" || l === ")") || l === "t" && (n[v].v === "/" || n[v].v === " " && n[v + 1] != null && n[v + 1].t == "?")); )
768
- n[a].v += n[v].v, n[v] = { v: "", t: ";" }, ++v;
769
- ae += n[a].v, a = v - 1;
770
- break;
771
- case "G":
772
- n[a].t = "t", n[a].v = me(t, e);
773
- break;
774
- }
775
- var f = "", i, o;
776
- if (ae.length > 0) {
777
- ae.charCodeAt(0) == 40 ? (i = t < 0 && ae.charCodeAt(0) === 45 ? -t : t, o = X("n", ae, i)) : (i = t < 0 && b > 1 ? -t : t, o = X("n", ae, i), i < 0 && n[0] && n[0].t == "t" && (o = o.substr(1), n[0].v = "-" + n[0].v)), v = o.length - 1;
778
- var x = n.length;
779
- for (a = 0; a < n.length; ++a) if (n[a] != null && n[a].t != "t" && n[a].v.indexOf(".") > -1) {
780
- x = a;
781
- break;
782
- }
783
- var c = n.length;
784
- if (x === n.length && o.indexOf("E") === -1) {
785
- for (a = n.length - 1; a >= 0; --a)
786
- n[a] == null || "n?".indexOf(n[a].t) === -1 || (v >= n[a].v.length - 1 ? (v -= n[a].v.length, n[a].v = o.substr(v + 1, n[a].v.length)) : v < 0 ? n[a].v = "" : (n[a].v = o.substr(0, v + 1), v = -1), n[a].t = "t", c = a);
787
- v >= 0 && c < n.length && (n[c].v = o.substr(0, v + 1) + n[c].v);
788
- } else if (x !== n.length && o.indexOf("E") === -1) {
789
- for (v = o.indexOf(".") - 1, a = x; a >= 0; --a)
790
- if (!(n[a] == null || "n?".indexOf(n[a].t) === -1)) {
791
- for (m = n[a].v.indexOf(".") > -1 && a === x ? n[a].v.indexOf(".") - 1 : n[a].v.length - 1, f = n[a].v.substr(m + 1); m >= 0; --m)
792
- v >= 0 && (n[a].v.charAt(m) === "0" || n[a].v.charAt(m) === "#") && (f = o.charAt(v--) + f);
793
- n[a].v = f, n[a].t = "t", c = a;
794
- }
795
- for (v >= 0 && c < n.length && (n[c].v = o.substr(0, v + 1) + n[c].v), v = o.indexOf(".") + 1, a = x; a < n.length; ++a)
796
- if (!(n[a] == null || "n?(".indexOf(n[a].t) === -1 && a !== x)) {
797
- for (m = n[a].v.indexOf(".") > -1 && a === x ? n[a].v.indexOf(".") + 1 : 0, f = n[a].v.substr(0, m); m < n[a].v.length; ++m)
798
- v < o.length && (f += o.charAt(v++));
799
- n[a].v = f, n[a].t = "t", c = a;
800
- }
801
- }
802
- }
803
- for (a = 0; a < n.length; ++a) n[a] != null && "n?".indexOf(n[a].t) > -1 && (i = b > 1 && t < 0 && a > 0 && n[a - 1].v === "-" ? -t : t, n[a].v = X(n[a].t, n[a].v, i), n[a].t = "t");
804
- var s = "";
805
- for (a = 0; a !== n.length; ++a) n[a] != null && (s += n[a].v);
806
- return s;
807
- }
808
- w._eval = z;
809
- var re = /\[[=<>]/, Z = /\[(=|>[=]?|<[>=]?)(-?\d+(?:\.\d*)?)\]/;
810
- function ge(r, t) {
811
- if (t == null) return !1;
812
- var e = parseFloat(t[2]);
813
- switch (t[1]) {
814
- case "=":
815
- if (r == e) return !0;
816
- break;
817
- case ">":
818
- if (r > e) return !0;
819
- break;
820
- case "<":
821
- if (r < e) return !0;
822
- break;
823
- case "<>":
824
- if (r != e) return !0;
825
- break;
826
- case ">=":
827
- if (r >= e) return !0;
828
- break;
829
- case "<=":
830
- if (r <= e) return !0;
831
- break;
832
- }
833
- return !1;
834
- }
835
- function ce(r, t) {
836
- var e = ye(r), b = e.length, n = e[b - 1].indexOf("@");
837
- if (b < 4 && n > -1 && --b, e.length > 4) throw new Error("cannot find right format for |" + e.join("|") + "|");
838
- if (typeof t != "number") return [4, e.length === 4 || n > -1 ? e[e.length - 1] : "@"];
839
- switch (e.length) {
840
- case 1:
841
- e = n > -1 ? ["General", "General", "General", e[0]] : [e[0], e[0], e[0], "@"];
842
- break;
843
- case 2:
844
- e = n > -1 ? [e[0], e[0], e[0], e[1]] : [e[0], e[1], e[0], "@"];
845
- break;
846
- case 3:
847
- e = n > -1 ? [e[0], e[1], e[0], e[2]] : [e[0], e[1], e[2], "@"];
848
- break;
849
- }
850
- var p = t > 0 ? e[0] : t < 0 ? e[1] : e[2];
851
- if (e[0].indexOf("[") === -1 && e[1].indexOf("[") === -1) return [b, p];
852
- if (e[0].match(re) != null || e[1].match(re) != null) {
853
- var a = e[0].match(Z), l = e[1].match(Z);
854
- return ge(t, a) ? [b, e[0]] : ge(t, l) ? [b, e[1]] : [b, e[a != null && l != null ? 2 : 1]];
855
- }
856
- return [b, p];
857
- }
858
- function ne(r, t, e) {
859
- e == null && (e = {});
860
- var b = "";
861
- switch (typeof r) {
862
- case "string":
863
- r == "m/d/yy" && e.dateNF ? b = e.dateNF : b = r;
864
- break;
865
- case "number":
866
- r == 14 && e.dateNF ? b = e.dateNF : b = (e.table != null ? e.table : te)[r], b == null && (b = e.table && e.table[G[r]] || te[G[r]]), b == null && (b = I[r] || "General");
867
- break;
868
- }
869
- if (se(b, 0)) return me(t, e);
870
- t instanceof Date && (t = Ne(t, e.date1904));
871
- var n = ce(b, t);
872
- if (se(n[1])) return me(t, e);
873
- if (t === !0) t = "TRUE";
874
- else if (t === !1) t = "FALSE";
875
- else if (t === "" || t == null) return "";
876
- return z(n[1], t, e, n[0]);
877
- }
878
- function xe(r, t) {
879
- if (typeof t != "number") {
880
- t = +t || -1;
881
- for (var e = 0; e < 392; ++e) {
882
- if (te[e] == null) {
883
- t < 0 && (t = e);
884
- continue;
885
- }
886
- if (te[e] == r) {
887
- t = e;
888
- break;
889
- }
890
- }
891
- t < 0 && (t = 391);
892
- }
893
- return te[t] = r, t;
894
- }
895
- w.load = xe, w._table = te, w.get_table = function() {
896
- return te;
897
- }, w.load_table = function(t) {
898
- for (var e = 0; e != 392; ++e)
899
- t[e] !== void 0 && xe(t[e], e);
900
- }, w.init_table = Oe, w.format = ne;
901
- };
902
- d(u), typeof DO_NOT_EXPORT_SSF > "u" && (_.exports = u);
903
- })(We);
904
- var Qe = We.exports;
905
- const Ve = /* @__PURE__ */ Ue(Qe), Ke = (_) => _.replace(/\.[^.]+$/, ""), Le = [
906
- "228, 232, 237",
907
- // Light Gray
908
- "219, 233, 236",
909
- // White
910
- "244, 217, 227",
911
- // Pink
912
- "247, 229, 207",
913
- // Peach
914
- "217, 234, 244",
915
- // Blue
916
- "222, 239, 222",
917
- // Green
918
- "239, 239, 239",
919
- // Light Green
920
- "244, 230, 230",
921
- // Rose
922
- "247, 239, 217",
923
- // Yellow
924
- "230, 230, 244",
925
- // Purple
926
- "217, 244, 244",
927
- // Cyan
928
- "244, 239, 234"
929
- // Cream
930
- ], je = Le[0], et = [
931
- ["true", "false"],
932
- ["yes", "no"],
933
- ["1", "0"]
934
- ];
935
- function tt(_, u) {
936
- const d = _.toLowerCase(), k = u.toLowerCase();
937
- return et.some(([w, C]) => d === w && k === C);
938
- }
939
- const rt = 200;
940
- function nt(_) {
941
- if (!Array.isArray(_) || _.length === 0) return null;
942
- const u = _.map((k) => String((k == null ? void 0 : k.v) ?? "")).join("");
943
- return u.trim() ? u : null;
944
- }
945
- function at(_) {
946
- return _ ? "TRUE" : "FALSE";
947
- }
948
- function it(_) {
949
- let u = !1, d = 0;
950
- const k = () => {
951
- if (u) return !0;
952
- const C = _.current;
953
- if (!(C != null && C.getWorkbookContext) || !C.recalculateAllFormulas) return !1;
954
- const $ = C.getWorkbookContext(), T = $ == null ? void 0 : $.luckysheetfile;
955
- return !(T != null && T.length) || !T.some(
956
- (B) => Array.isArray(B.data) && B.data.length > 0
957
- ) ? !1 : (C.recalculateAllFormulas(), u = !0, !0);
958
- }, w = () => {
959
- var C, $;
960
- k() || (d += 1, d < rt ? requestAnimationFrame(w) : (($ = (C = _.current) == null ? void 0 : C.recalculateAllFormulas) == null || $.call(C), u = !0));
961
- };
962
- requestAnimationFrame(() => requestAnimationFrame(w));
963
- for (const C of [120, 400, 1200])
964
- window.setTimeout(() => {
965
- u || k();
966
- }, C);
967
- }
968
- function ot(_) {
969
- return _ <= 0 ? je : _ > Le.length ? Array(_).fill(je).join(", ") : Le.slice(0, _).join(", ");
970
- }
971
- function He(_) {
972
- const u = _.match(/^([A-Z]+)(\d+)$/i);
973
- if (!u) return null;
974
- const d = u[1].toUpperCase(), k = u[2];
975
- let w = 0;
976
- for (let T = 0; T < d.length; T++)
977
- w = w * 26 + (d.charCodeAt(T) - 64);
978
- const C = parseInt(k, 10) - 1, $ = w - 1;
979
- return { row: C, col: $ };
980
- }
981
- function ct(_, u) {
982
- const d = He(_);
983
- if (!d) return null;
984
- const { row: k, col: w } = d, C = `${k}_${w}`, $ = Array.isArray(u.formulae) && u.formulae.length > 0 ? String(u.formulae[0]).replace(/^["']|["']$/g, "").replace(/["']/g, "") : "", T = $.split(",").map((se) => se.trim()).filter(Boolean);
985
- let V = u.type === "list" ? "dropdown" : u.type || "dropdown", B = $, q = "";
986
- u.type === "list" && T.length === 2 && tt(T[0], T[1]) && (V = "checkbox", B = T[0], q = T[1]);
987
- const oe = V === "checkbox" ? 1 : B ? B.split(",").length : 0, fe = ot(oe || 1), ie = {
988
- type: V,
989
- type2: "",
990
- rangeTxt: _,
991
- value1: B,
992
- value2: q,
993
- validity: "",
994
- remote: !1,
995
- prohibitInput: u.type === "list",
996
- hintShow: !!u.showInputMessage,
997
- hintValue: u.prompt ?? "",
998
- color: fe,
999
- checked: !1
1000
- };
1001
- return { rowColKey: C, entry: ie };
1002
- }
1003
- function lt(_) {
1004
- const u = _.split(":"), d = He(u[0].trim());
1005
- if (!d) return null;
1006
- const k = u.length > 1 ? He(u[1].trim()) : d;
1007
- return k ? {
1008
- row: [Math.min(d.row, k.row), Math.max(d.row, k.row)],
1009
- column: [Math.min(d.col, k.col), Math.max(d.col, k.col)]
1010
- } : null;
1011
- }
1012
- function st(_) {
1013
- return String(_ || "").split(/[,\s]+/).map((u) => u.trim()).filter(Boolean).map((u) => lt(u)).filter(
1014
- (u) => !!u
1015
- );
1016
- }
1017
- function Ye(_) {
1018
- const u = st(_);
1019
- return u.length ? u.map((d) => {
1020
- const [k, w] = d.row, [C, $] = d.column;
1021
- return {
1022
- left: 0,
1023
- width: 104,
1024
- top: 0,
1025
- height: 23,
1026
- left_move: 0,
1027
- width_move: 104,
1028
- top_move: 0,
1029
- height_move: 11999,
1030
- row: [k, w],
1031
- column: [C, $],
1032
- row_focus: k,
1033
- column_focus: C,
1034
- column_select: !0
1035
- };
1036
- }) : null;
1037
- }
1038
- function Ge(_) {
1039
- var $, T;
1040
- const u = {
1041
- textColor: "#000000",
1042
- cellColor: "#ffffff",
1043
- bold: !1,
1044
- italic: !1,
1045
- underline: !1,
1046
- strikethrough: !1
1047
- };
1048
- if (!_) return u;
1049
- const d = _.font, k = _.fill;
1050
- let w = u.textColor, C = u.cellColor;
1051
- if (($ = d == null ? void 0 : d.color) != null && $.argb) {
1052
- const V = d.color.argb;
1053
- w = "#" + (V.length >= 6 ? V.slice(-6) : V);
1054
- }
1055
- if ((k == null ? void 0 : k.type) === "pattern" && k.pattern === "solid" && ((T = k.fgColor) != null && T.argb)) {
1056
- const V = k.fgColor.argb;
1057
- C = "#" + (V.length >= 6 ? V.slice(-6) : V);
1058
- }
1059
- return {
1060
- textColor: w,
1061
- cellColor: C,
1062
- bold: !!(d != null && d.bold),
1063
- italic: !!(d != null && d.italic),
1064
- underline: !!(d != null && d.underline),
1065
- strikethrough: !1
1066
- };
1067
- }
1068
- function Ie(_) {
1069
- if (!_ || typeof _ != "string") return "";
1070
- const u = _.trim().replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&").replace(/^=/, ""), d = u.match(/(?:^|[^A-Z])SEARCH\s*\([\s(]*"((?:[^"]|"")*)"/i);
1071
- if (d) return (d[1] ?? "").replace(/""/g, '"');
1072
- const k = u.match(/(?:^|[^A-Z])SEARCH\s*\([\s(]*'([^']*)'/i);
1073
- return k ? k[1] ?? "" : "";
1074
- }
1075
- function Pe(_) {
1076
- if (!_ || typeof _ != "string") return "";
1077
- const u = _.trim().replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/^=/, ""), d = u.match(/"((?:[^"]|"")*)"/);
1078
- if (d) return (d[1] ?? "").replace(/""/g, '"');
1079
- const k = u.match(/'([^']*)'/);
1080
- return k ? k[1] ?? "" : "";
1081
- }
1082
- function ut(_) {
1083
- if (!_ || typeof _ != "string") return null;
1084
- const u = _.trim().toUpperCase(), d = Ie(_) || Pe(_);
1085
- return d ? u.includes("SEARCH(") ? u.includes("ISERROR(SEARCH(") || u.includes("NOTNUMBER(SEARCH(") ? { conditionName: "textDoesNotContain", conditionValue: [d] } : { conditionName: "textContains", conditionValue: [d] } : u.includes("LEFT(") ? { conditionName: "textStartsWith", conditionValue: [d] } : u.includes("RIGHT(") ? { conditionName: "textEndsWith", conditionValue: [d] } : u.includes("EXACT(") || u.includes('="') ? { conditionName: "textExactly", conditionValue: [d] } : null : null;
1086
- }
1087
- function ht(_, u, d) {
1088
- const k = (_ || "").toLowerCase();
1089
- if (k === "cellis") {
1090
- const w = (u || "").toLowerCase();
1091
- return w === "greaterthan" ? { conditionName: "greaterThan", conditionValue: [] } : w === "greaterthanorequal" ? { conditionName: "greaterThanOrEqual", conditionValue: [] } : w === "lessthan" ? { conditionName: "lessThan", conditionValue: [] } : w === "lessthanorequal" ? { conditionName: "lessThanOrEqual", conditionValue: [] } : w === "equal" ? { conditionName: "equal", conditionValue: [] } : w === "notequal" ? { conditionName: "notEqual", conditionValue: [] } : w === "between" ? { conditionName: "between", conditionValue: [] } : w === "notbetween" ? { conditionName: "notBetween", conditionValue: [] } : null;
1092
- }
1093
- if (k === "containstext" || k === "notcontainstext" || k === "beginswith" || k === "endswith" || k === "containsblanks" || k === "notcontainsblanks") {
1094
- const w = (u ?? "").toLowerCase();
1095
- if (k === "containsblanks" || w === "containsblanks")
1096
- return { conditionName: "empty", conditionValue: [""] };
1097
- if (k === "notcontainsblanks" || w === "notcontainsblanks")
1098
- return { conditionName: "notEmpty", conditionValue: [""] };
1099
- if (k === "notcontainstext" || w === "notcontainstext" || w === "notcontains")
1100
- return { conditionName: "textDoesNotContain", conditionValue: [] };
1101
- if (k === "beginswith" || w === "beginswith")
1102
- return { conditionName: "textStartsWith", conditionValue: [] };
1103
- if (k === "endswith" || w === "endswith")
1104
- return { conditionName: "textEndsWith", conditionValue: [] };
1105
- if (w === "equal")
1106
- return { conditionName: "textExactly", conditionValue: [] };
1107
- const C = (d == null ? void 0 : d.text) ?? "";
1108
- return {
1109
- conditionName: "textContains",
1110
- conditionValue: C ? [C] : []
1111
- };
1112
- }
1113
- if (k === "duplicatevalues")
1114
- return { conditionName: "duplicateValue", conditionValue: ["0"] };
1115
- if (k === "uniquevalues")
1116
- return { conditionName: "duplicateValue", conditionValue: ["1"] };
1117
- if (k === "top10") {
1118
- const w = (d == null ? void 0 : d.rank) ?? 10;
1119
- return d != null && d.percent && (d != null && d.bottom) ? {
1120
- conditionName: "last10_percent",
1121
- conditionValue: [String(w)]
1122
- } : d != null && d.percent ? { conditionName: "top10_percent", conditionValue: [String(w)] } : d != null && d.bottom ? { conditionName: "last10", conditionValue: [String(w)] } : { conditionName: "top10", conditionValue: [String(w)] };
1123
- }
1124
- if (k === "aboveaverage")
1125
- return (d == null ? void 0 : d.aboveAverage) === !1 ? { conditionName: "belowAverage", conditionValue: [] } : { conditionName: "aboveAverage", conditionValue: [] };
1126
- if (k === "timeperiod") {
1127
- const w = ((d == null ? void 0 : d.timePeriod) ?? "").toLowerCase();
1128
- return w === "today" || w === "tomorrow" || w === "yesterday" ? {
1129
- conditionName: "dateIs",
1130
- conditionValue: [`preset:${w}`, "", "DD/MM/YYYY"]
1131
- } : w === "last7days" ? {
1132
- conditionName: "dateIs",
1133
- conditionValue: ["preset:pastWeek", "", "DD/MM/YYYY"]
1134
- } : w === "lastmonth" ? {
1135
- conditionName: "dateIs",
1136
- conditionValue: ["preset:pastMonth", "", "DD/MM/YYYY"]
1137
- } : w === "lastyear" ? {
1138
- conditionName: "dateIs",
1139
- conditionValue: ["preset:pastYear", "", "DD/MM/YYYY"]
1140
- } : null;
1141
- }
1142
- return null;
1143
- }
1144
- function ft(_, u) {
1145
- if (!u.type) return null;
1146
- let d = (u.text ?? "").trim();
1147
- const k = Array.isArray(u.formulae) && u.formulae[0] ? String(u.formulae[0]) : void 0, w = (u.type.toLowerCase() === "expression" || u.type.toLowerCase() === "customformula") && ut(k);
1148
- if (w) {
1149
- const B = Ye(_);
1150
- if (!B) return null;
1151
- const q = Ge(u.style);
1152
- return {
1153
- type: "default",
1154
- cellrange: B,
1155
- format: {
1156
- textColor: q.textColor,
1157
- cellColor: q.cellColor,
1158
- bold: q.bold,
1159
- italic: q.italic,
1160
- underline: q.underline,
1161
- strikethrough: q.strikethrough
1162
- },
1163
- conditionName: w.conditionName,
1164
- conditionRange: [],
1165
- conditionValue: w.conditionValue
1166
- };
1167
- }
1168
- (u.type === "containsText" || u.type === "notContainsText" || u.type === "beginsWith" || u.type === "endsWith") && !d && (d = Ie(k), d || (d = Pe(k)));
1169
- const C = ht(u.type, u.operator, {
1170
- percent: u.percent,
1171
- bottom: u.bottom,
1172
- rank: u.rank,
1173
- aboveAverage: u.aboveAverage,
1174
- text: d || u.text,
1175
- timePeriod: u.timePeriod
1176
- });
1177
- if (!C) return null;
1178
- let $;
1179
- u.type === "cellIs" && Array.isArray(u.formulae) && u.formulae.length > 0 ? $ = u.formulae.map((B) => String(B ?? "")) : C.conditionName === "empty" || C.conditionName === "notEmpty" ? $ = [""] : u.type === "containsText" || u.type === "notContainsText" || u.type === "beginsWith" || u.type === "endsWith" ? $ = d ? [d] : Pe(k) ? [Pe(k)] : [] : $ = C.conditionValue.map(
1180
- (B) => B == null ? "" : String(B)
1181
- );
1182
- const T = Ye(_);
1183
- if (!T) return null;
1184
- const V = Ge(u.style);
1185
- return {
1186
- type: "default",
1187
- cellrange: T,
1188
- format: {
1189
- textColor: V.textColor,
1190
- cellColor: V.cellColor,
1191
- bold: V.bold,
1192
- italic: V.italic,
1193
- underline: V.underline,
1194
- strikethrough: V.strikethrough
1195
- },
1196
- conditionName: C.conditionName,
1197
- conditionRange: [],
1198
- conditionValue: $
1199
- };
1200
- }
1201
- async function mt({
1202
- sheetEditorRef: _,
1203
- ydocRef: u,
1204
- setForceSheetRender: d,
1205
- dsheetId: k,
1206
- currentDataRef: w,
1207
- updateDocumentTitle: C,
1208
- filterToastShown: $,
1209
- setFilterToastShown: T
1210
- }, V, B, q) {
1211
- var ve, we;
1212
- const oe = V == null ? void 0 : V.target;
1213
- if (!((ve = oe == null ? void 0 : oe.files) != null && ve.length) && !B)
1214
- return Promise.resolve();
1215
- const fe = ((we = oe == null ? void 0 : oe.files) == null ? void 0 : we[0]) || B, ie = {}, se = {};
1216
- return new Promise((Oe, te) => {
1217
- const G = new FileReader();
1218
- G.onerror = () => te(new Error("Failed to read file")), G.onload = async (M) => {
1219
- var Ce, me, Te, Fe;
1220
- if (!M.target) {
1221
- console.error("FileReader event target is null"), te(new Error("FileReader event target is null"));
1222
- return;
1223
- }
1224
- const I = M.target.result, [{ Workbook: ke }, pe, Se] = await Promise.all([
1225
- import("exceljs"),
1226
- // @ts-expect-error — luckyexcel ships without TypeScript types
1227
- import("luckyexcel"),
1228
- import("./xlsx-image-utils-Cvg0qxRA.js")
1229
- ]), De = pe.default.transformExcelToLucky, { extractImagesFromWorksheet: Re, convertRawImagesToFortuneSheet: Ne } = Se, _e = new ke();
1230
- try {
1231
- await _e.xlsx.load(I);
1232
- const Q = (Fe = (Te = (me = (Ce = _e.model) == null ? void 0 : Ce.styles) == null ? void 0 : me.fonts) == null ? void 0 : Te[0]) == null ? void 0 : Fe.size, X = {}, ye = {}, Ee = {}, Ae = {};
1233
- _e.eachSheet((z, re) => {
1234
- var n;
1235
- const Z = re - 1, ge = {}, ce = z.views;
1236
- if (ce && ce.length > 0) {
1237
- const p = ce[0];
1238
- if (p.state === "frozen") {
1239
- const a = p.xSplit || 0, l = p.ySplit || 0;
1240
- let y = null;
1241
- a > 0 && l > 0 ? y = "rangeBoth" : l > 0 ? y = "rangeRow" : a > 0 && (y = "rangeColumn"), y && (ye[Z] = {
1242
- type: y,
1243
- range: {
1244
- row_focus: l - 1,
1245
- column_focus: a - 1
1246
- }
1247
- });
1248
- }
1249
- }
1250
- const ne = {};
1251
- z.eachRow({ includeEmpty: !1 }, (p, a) => {
1252
- p.eachCell({ includeEmpty: !1 }, (l, y) => {
1253
- var K, ue, Y;
1254
- const h = `${a - 1}_${y - 1}`;
1255
- l.hyperlink && (ge[h] = [
1256
- {
1257
- linkType: "webpage",
1258
- linkAddress: l.hyperlink
1259
- }
1260
- ]);
1261
- const m = (K = l.style) == null ? void 0 : K.font, A = (ue = l.style) == null ? void 0 : ue.fill, R = {};
1262
- if (m) {
1263
- m.bold && (R.bl = 1), m.italic && (R.it = 1), m.underline && (R.un = 1);
1264
- const S = m.size ?? Q;
1265
- if (S && (R.fs = S), m.name && (R.ff = m.name), (Y = m.color) != null && Y.argb) {
1266
- const U = m.color.argb, he = "#" + U.substring(U.length - 6);
1267
- R.fc = he;
1268
- }
1269
- }
1270
- if ((A == null ? void 0 : A.type) === "pattern" && A.pattern === "solid" && A.fgColor && A.fgColor.argb) {
1271
- const S = A.fgColor.argb, U = "#" + S.substring(S.length - 6);
1272
- R.bg = U;
1273
- }
1274
- Object.keys(R).length > 0 && (ne[h] = R);
1275
- });
1276
- }), Object.keys(ge).length > 0 && (X[Z] = ge), Object.keys(ne).length > 0 && (Ee[Z] = ne);
1277
- const xe = Re(z, _e);
1278
- xe.length > 0 && (Ae[Z] = xe);
1279
- const r = z.tables;
1280
- r && Object.keys(r).length > 0 && Be({
1281
- title: "Tables are not fully supported",
1282
- description: "Table styles will not be applied",
1283
- variant: "warning",
1284
- showCloseButton: !0,
1285
- duration: 40 * 1e3
1286
- });
1287
- const t = (n = z.dataValidations) == null ? void 0 : n.model;
1288
- if (t && typeof t == "object") {
1289
- const p = {};
1290
- for (const [a, l] of Object.entries(t)) {
1291
- const h = ct(a, l);
1292
- h && (p[h.rowColKey] = h.entry);
1293
- }
1294
- Object.keys(p).length > 0 && (ie[Z] = p);
1295
- }
1296
- const e = z.conditionalFormattings;
1297
- if (Array.isArray(e) && e.length > 0) {
1298
- const p = [];
1299
- for (const a of e) {
1300
- const l = a.ref, y = a.rules || [];
1301
- for (const h of y) {
1302
- const m = h;
1303
- console.log("[XLSX CF RAW]", {
1304
- ref: l,
1305
- type: m.type,
1306
- operator: m.operator,
1307
- formulae: m.formulae,
1308
- text: m.text,
1309
- timePeriod: m.timePeriod,
1310
- percent: m.percent,
1311
- bottom: m.bottom,
1312
- rank: m.rank,
1313
- aboveAverage: m.aboveAverage
1314
- });
1315
- const A = m.type ? ft(l, m) : null;
1316
- A ? console.log("[XLSX CF MAPPED] accepted", A) : console.log("[XLSX CF MAPPED] skipped", {
1317
- ref: l,
1318
- type: m.type,
1319
- operator: m.operator,
1320
- formulae: m.formulae,
1321
- text: m.text
1322
- }), A && p.push(A);
1323
- }
1324
- }
1325
- p.length > 0 && (se[Z] = p);
1326
- }
1327
- z.autoFilter && ($ || (T(!0), Be({
1328
- title: "Filters are not supported in imported files",
1329
- variant: "warning",
1330
- showCloseButton: !0,
1331
- duration: 30 * 1e3
1332
- })));
1333
- }), De(
1334
- fe,
1335
- function(z) {
1336
- var t;
1337
- let re = z.sheets;
1338
- if (re.forEach((e, b) => {
1339
- const n = ie[b];
1340
- n && Object.keys(n).length > 0 && (e.dataVerification = n);
1341
- const p = se[b];
1342
- e.luckysheet_conditionformat_save = Array.isArray(p) && p.length > 0 ? p : [];
1343
- }), !u.current) {
1344
- console.error("ydocRef.current is null");
1345
- return;
1346
- }
1347
- const Z = u.current.getArray(k), ge = Array.from(Z), ce = /* @__PURE__ */ new Map();
1348
- re = re.map((e, b) => {
1349
- var R, K, ue, Y, S, U, he, ae, v, f, i, o, x, c, s, E, P, L, H, O, de, Me, be;
1350
- const n = (R = e == null ? void 0 : e.celldata) == null ? void 0 : R[e.celldata.length - 1], p = (n == null ? void 0 : n.r) ?? 0, a = (n == null ? void 0 : n.c) ?? 0;
1351
- if (e.row = Math.max(p, 500), e.column = Math.max(a, 36), e.id || (e.id = (K = _.current) == null ? void 0 : K.getSettings().generateSheetId()), ye[b] && (e.frozen = ye[b]), X[b] && (e.hyperlink = {
1352
- ...e.hyperlink || {},
1353
- ...X[b]
1354
- }), (ue = e.config) != null && ue.columnlen) {
1355
- const g = {};
1356
- Object.entries(e.config.columnlen).forEach(
1357
- ([N, F]) => {
1358
- const j = (Number(F) - 5) / 8 + 0.83;
1359
- g[N] = Math.round(j * 7 + 5);
1360
- }
1361
- ), e.config.columnlen = g;
1362
- }
1363
- if ((Y = e.config) != null && Y.rowlen) {
1364
- const g = Math.round(
1365
- Number(e.defaultRowHeight) || 21
1366
- ), N = {};
1367
- Object.entries(e.config.rowlen).forEach(([F, j]) => {
1368
- Math.abs(Math.round(Number(j)) - g) > 1 && (N[F] = Number(j));
1369
- }), e.config.rowlen = N;
1370
- }
1371
- if ((S = e.config) != null && S.customHeight) {
1372
- const g = new Set(
1373
- Object.keys(e.config.rowlen || {})
1374
- ), N = {};
1375
- Object.entries(e.config.customHeight).forEach(
1376
- ([F, j]) => {
1377
- g.has(F) && Number(j) === 1 && (N[F] = 1);
1378
- }
1379
- ), e.config.customHeight = N;
1380
- }
1381
- if (Ae[b]) {
1382
- const g = Number(e.defaultColWidth) || Number(
1383
- (ae = (he = (U = _.current) == null ? void 0 : U.getSettings) == null ? void 0 : he.call(U)) == null ? void 0 : ae.defaultColWidth
1384
- ) || 99, N = Number(e.defaultRowHeight) || Number(
1385
- (i = (f = (v = _.current) == null ? void 0 : v.getSettings) == null ? void 0 : f.call(v)) == null ? void 0 : i.defaultRowHeight
1386
- ) || 21;
1387
- e.images = Ne(
1388
- Ae[b],
1389
- e,
1390
- g,
1391
- N
1392
- );
1393
- }
1394
- const l = X[b], y = Ee[b], h = [], m = (g, N) => {
1395
- const F = `${g}_${N}`;
1396
- m._seen == null && (m._seen = /* @__PURE__ */ new Set());
1397
- const j = m._seen;
1398
- j.has(F) || (j.add(F), h.push({ r: g, c: N, id: e.id }));
1399
- }, A = (o = e.config) != null && o.merge ? /* @__PURE__ */ new Map() : null;
1400
- if (e.celldata)
1401
- for (const g of e.celldata) {
1402
- const N = `${g.r}_${g.c}`;
1403
- if (A == null || A.set(
1404
- N,
1405
- g
1406
- ), g.v) {
1407
- if (g.v.f) {
1408
- const D = String(g.v.f);
1409
- D.startsWith("=") || (g.v.f = `=${D}`);
1410
- }
1411
- if (g.v.f && ((x = g.v.ct) == null ? void 0 : x.t) !== "d" && (g.v.ct = { ...g.v.ct ?? {}, t: "str" }, m(g.r, g.c)), y != null && y[N]) {
1412
- const D = y[N];
1413
- if (!!(l != null && l[N])) {
1414
- const { fc: J, un: $e, ...ze } = D;
1415
- Object.assign(g.v, ze);
1416
- } else
1417
- Object.assign(g.v, D);
1418
- }
1419
- if (l != null && l[N] && !g.v.f) {
1420
- const D = l[N][0];
1421
- D && Je(
1422
- g.v,
1423
- D
1424
- );
1425
- }
1426
- const F = (c = g.v.ct) == null ? void 0 : c.fa, j = typeof F == "string" ? F.trim().toLowerCase() : "", ee = j === "general" || ((s = g.v.ct) == null ? void 0 : s.t) === "g", le = j === "@" || ((E = g.v.ct) == null ? void 0 : E.t) === "s";
1427
- if (F && !ce.has(F) && ce.set(F, Ve.is_date(F)), !g.v.f && F && ce.get(F)) {
1428
- const D = typeof g.v.v == "string" ? parseFloat(g.v.v) : g.v.v;
1429
- if (typeof D == "number" && !isNaN(D))
1430
- try {
1431
- g.v.v = D, g.v.m = Ve.format(F, D), g.v.ct = { ...g.v.ct, t: "d" };
1432
- } catch {
1433
- }
1434
- } else if (!g.v.f && typeof g.v.v == "string" && !le && !ee) {
1435
- const D = g.v.v.trim();
1436
- if (/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?$/.test(
1437
- D
1438
- )) {
1439
- const J = Number(D);
1440
- if (!isFinite(J))
1441
- continue;
1442
- if (g.v.v = J, g.v.ht == null && (g.v.ht = 2), !F)
1443
- g.v.m = String(J);
1444
- else
1445
- try {
1446
- g.v.m = Ve.format(F, J);
1447
- } catch {
1448
- }
1449
- }
1450
- } else !g.v.f && typeof g.v.v == "number" && isFinite(g.v.v) && ((P = g.v.ct) == null ? void 0 : P.t) !== "s" && ((L = g.v.ct) == null ? void 0 : L.t) !== "d" && g.v.ht == null && (g.v.ht = 2);
1451
- if (!g.v.f && (g.v.m === void 0 || g.v.m === null) && ((H = g.v.ct) == null ? void 0 : H.t) !== "d") {
1452
- const D = nt((O = g.v.ct) == null ? void 0 : O.s), W = g.v.v;
1453
- if (!(W == null || String(W).trim() === ""))
1454
- if (D != null)
1455
- g.v.m = D;
1456
- else if (typeof W == "boolean")
1457
- g.v.m = at(W);
1458
- else if (typeof W == "number" && isFinite(W)) {
1459
- const $e = (de = g.v.ct) == null ? void 0 : de.fa;
1460
- if (typeof $e == "string" && $e && ce.get($e) === !1)
1461
- try {
1462
- g.v.m = Ve.format($e, W);
1463
- } catch {
1464
- g.v.m = String(W);
1465
- }
1466
- else
1467
- g.v.m = String(W);
1468
- } else typeof W == "object" || (g.v.m = String(W));
1469
- }
1470
- }
1471
- }
1472
- if (Array.isArray(e.data)) {
1473
- const g = e.data;
1474
- for (let N = 0; N < g.length; N++) {
1475
- const F = g[N];
1476
- if (Array.isArray(F))
1477
- for (let j = 0; j < F.length; j++) {
1478
- const ee = F[j];
1479
- if (!ee || typeof ee != "object" || !ee.f) continue;
1480
- const le = String(ee.f);
1481
- le.startsWith("=") || (ee.f = `=${le}`), ((Me = ee.ct) == null ? void 0 : Me.t) !== "d" && (ee.ct = { ...ee.ct ?? {}, t: "str" }, m(N, j));
1482
- }
1483
- }
1484
- }
1485
- if (e.calcChain = h, A && ((be = e.config) != null && be.merge) && e.celldata)
1486
- for (const g of Object.values(e.config.merge)) {
1487
- const { r: N, c: F, rs: j, cs: ee } = g;
1488
- for (let le = 0; le < j; le++)
1489
- for (let D = 0; D < ee; D++) {
1490
- const W = `${N + le}_${F + D}`;
1491
- let J = A.get(W);
1492
- J || (J = { r: N + le, c: F + D, v: {} }, e.celldata.push(J), A.set(W, J)), J.v || (J.v = {}), J.v.mc = le === 0 && D === 0 ? { r: N, c: F, rs: j, cs: ee } : { r: N, c: F };
1493
- }
1494
- }
1495
- return e;
1496
- }), console.log("[xlsx-import] parsed sheets data", {
1497
- fileName: fe.name,
1498
- sheetCount: re.length,
1499
- sheets: re
1500
- });
1501
- let ne;
1502
- if (q === "merge-current-dsheet" ? ne = [...ge, ...re] : ne = [...re], ne = ne.map((e, b) => (e.order = b, e)), u.current.transact(() => {
1503
- q !== "merge-current-dsheet" && Z.delete(0, Z.length), ne.forEach((e) => {
1504
- if (e instanceof qe.Map) return;
1505
- const b = Xe(e);
1506
- Z.push([b()]);
1507
- });
1508
- }), u != null && u.current) {
1509
- const e = u.current.getArray(k), b = Ze(e);
1510
- w.current = b, d((n) => n + 1);
1511
- }
1512
- it(_);
1513
- const r = Ke((t = z == null ? void 0 : z.info) == null ? void 0 : t.name);
1514
- C == null || C(r), Oe();
1515
- }
1516
- );
1517
- } catch (Q) {
1518
- console.error("Error loading the workbook", Q), alert(
1519
- "Error loading the workbook. Please ensure it is a valid .xlsx file."
1520
- ), te(Q);
1521
- }
1522
- }, G.readAsArrayBuffer(fe);
1523
- });
1524
- }
1525
- export {
1526
- mt as runXlsxFileUpload
1527
- };