@xlcalc/vue 0.0.0-stage → 0.21.2
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.
- package/CHANGELOG.md +42 -0
- package/LICENSE +21 -0
- package/README.md +75 -2
- package/dist/abort.d.ts +6 -0
- package/dist/components/CellDraft.vue.d.ts +7 -0
- package/dist/components/CellEditor.vue.d.ts +3 -0
- package/dist/components/ColourSwatches.vue.d.ts +13 -0
- package/dist/components/DialogShell.vue.d.ts +37 -0
- package/dist/components/ExplainPanel.vue.d.ts +3 -0
- package/dist/components/FilterPopover.vue.d.ts +3 -0
- package/dist/components/FindBar.vue.d.ts +3 -0
- package/dist/components/FormatBorders.vue.d.ts +14 -0
- package/dist/components/FormatColour.vue.d.ts +19 -0
- package/dist/components/FormatDialog.vue.d.ts +24 -0
- package/dist/components/FormulaBar.vue.d.ts +3 -0
- package/dist/components/FunctionList.vue.d.ts +28 -0
- package/dist/components/FunctionTip.vue.d.ts +14 -0
- package/dist/components/InsertFunction.vue.d.ts +9 -0
- package/dist/components/OutlineCell.vue.d.ts +8 -0
- package/dist/components/OutlineLevels.vue.d.ts +7 -0
- package/dist/components/SheetGrid.vue.d.ts +3 -0
- package/dist/components/SheetMarks.vue.d.ts +3 -0
- package/dist/components/SheetMenu.vue.d.ts +3 -0
- package/dist/components/SheetRow.vue.d.ts +18 -0
- package/dist/components/SheetTabs.vue.d.ts +3 -0
- package/dist/components/SheetToolbar.vue.d.ts +43 -0
- package/dist/components/SheetView.vue.d.ts +56 -0
- package/dist/components/ValidationAlert.vue.d.ts +16 -0
- package/dist/components/ValidationDropdown.vue.d.ts +33 -0
- package/dist/components/ValidationPrompt.vue.d.ts +16 -0
- package/dist/components/cf-icons.d.ts +6 -0
- package/dist/components/context.d.ts +4 -0
- package/dist/components/dom.d.ts +7 -0
- package/dist/components/icons.d.ts +33 -0
- package/dist/components/popup.d.ts +29 -0
- package/dist/components/toolbar-icons.d.ts +24 -0
- package/dist/contract/memory.d.ts +108 -0
- package/dist/contract/messages.d.ts +260 -0
- package/dist/contract/source.d.ts +433 -0
- package/dist/contract/view.d.ts +108 -0
- package/dist/contract.d.ts +9 -0
- package/dist/core/ask.d.ts +2 -0
- package/dist/core/autocomplete.d.ts +28 -0
- package/dist/core/cell-style.d.ts +33 -0
- package/dist/core/cell-view.d.ts +104 -0
- package/dist/core/clip.d.ts +43 -0
- package/dist/core/commands.d.ts +47 -0
- package/dist/core/conditional.d.ts +16 -0
- package/dist/core/editing.d.ts +85 -0
- package/dist/core/explain.d.ts +36 -0
- package/dist/core/fill.d.ts +42 -0
- package/dist/core/filter.d.ts +72 -0
- package/dist/core/find.d.ts +53 -0
- package/dist/core/formula.d.ts +41 -0
- package/dist/core/function-tip.d.ts +34 -0
- package/dist/core/geometry.d.ts +55 -0
- package/dist/core/keys.d.ts +8 -0
- package/dist/core/list-keys.d.ts +4 -0
- package/dist/core/list.d.ts +17 -0
- package/dist/core/menu.d.ts +155 -0
- package/dist/core/merge.d.ts +19 -0
- package/dist/core/navigation.d.ts +72 -0
- package/dist/core/outline.d.ts +34 -0
- package/dist/core/point.d.ts +34 -0
- package/dist/core/ref-paint.d.ts +21 -0
- package/dist/core/selection.d.ts +45 -0
- package/dist/core/sheet.d.ts +774 -0
- package/dist/core/state.d.ts +107 -0
- package/dist/core/storage.d.ts +6 -0
- package/dist/core/totals.d.ts +16 -0
- package/dist/core/validation.d.ts +95 -0
- package/dist/core/viewport.d.ts +83 -0
- package/dist/core/windows.d.ts +102 -0
- package/dist/entry.d.ts +3 -0
- package/dist/failure.d.ts +5 -0
- package/dist/filter-key.d.ts +3 -0
- package/dist/find-match.d.ts +24 -0
- package/dist/format-cells.d.ts +85 -0
- package/dist/frame.d.ts +5 -0
- package/dist/grid-ref.d.ts +3 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +12767 -0
- package/dist/lines.d.ts +16 -0
- package/dist/local/find.d.ts +15 -0
- package/dist/local/index.d.ts +3 -0
- package/dist/local/locale.d.ts +5 -0
- package/dist/local/outcome.d.ts +21 -0
- package/dist/local/query.d.ts +23 -0
- package/dist/local/source.d.ts +4 -0
- package/dist/local/types.d.ts +37 -0
- package/dist/local/validation.d.ts +8 -0
- package/dist/local/window.d.ts +16 -0
- package/dist/local/xlsx.d.ts +23 -0
- package/dist/local.js +1025 -0
- package/dist/locale-ref.d.ts +7 -0
- package/dist/locales.d.ts +3 -0
- package/dist/memory-outline.d.ts +31 -0
- package/dist/memory-query.d.ts +26 -0
- package/dist/memory-source.d.ts +3 -0
- package/dist/memory-validation.d.ts +17 -0
- package/dist/messages.d.ts +6 -0
- package/dist/number-formats.d.ts +13 -0
- package/dist/rect.d.ts +9 -0
- package/dist/ru-RU-BVeg6JGM.js +931 -0
- package/dist/sheet-query.d.ts +22 -0
- package/dist/stats.d.ts +8 -0
- package/dist/style.css +2 -0
- package/dist/toolbar.d.ts +39 -0
- package/dist/typed-entry-2l9Ay-hV.js +4559 -0
- package/dist/window-size.d.ts +4 -0
- package/docs/api.md +520 -0
- package/docs/autocomplete.md +60 -0
- package/docs/checks.md +40 -0
- package/docs/clipboard.md +48 -0
- package/docs/editing.md +97 -0
- package/docs/example-app.md +26 -0
- package/docs/find-replace.md +26 -0
- package/docs/list-mode.md +86 -0
- package/docs/local.md +94 -0
- package/docs/quick-start.md +221 -0
- package/docs/sheets.md +61 -0
- package/docs/toolbar.md +72 -0
- package/docs/validation.md +41 -0
- package/docs/view.md +50 -0
- package/package.json +92 -4
package/dist/local.js
ADDED
|
@@ -0,0 +1,1025 @@
|
|
|
1
|
+
import { FUNCTION_NAMES as e, LOCALES as t, createInlineCalc as n, functionSignature as r, registerLocale as i } from "xlcalc";
|
|
2
|
+
import { cellAddress as a, colLetters as o, linesKey as s, nameKey as c, outlineGroups as l, parseCell as u, parseLines as d, parseRange as f, rangeAddress as p, sameName as ee } from "xlcalc/a1";
|
|
3
|
+
import { DEFAULT_ROW_HEIGHT as m, valueComparator as h } from "xlcalc/text";
|
|
4
|
+
//#region src/rect.ts
|
|
5
|
+
var g = (e, t) => ({
|
|
6
|
+
top: e,
|
|
7
|
+
left: t,
|
|
8
|
+
bottom: e,
|
|
9
|
+
right: t
|
|
10
|
+
}), _ = (e, t) => ({
|
|
11
|
+
top: Math.min(e.top, t.top),
|
|
12
|
+
left: Math.min(e.left, t.left),
|
|
13
|
+
bottom: Math.max(e.bottom, t.bottom),
|
|
14
|
+
right: Math.max(e.right, t.right)
|
|
15
|
+
}), v = 500, y = "A1:XFD1048576", b = (e) => [{
|
|
16
|
+
sheet: e.sheet,
|
|
17
|
+
range: e.range ?? y
|
|
18
|
+
}];
|
|
19
|
+
function x(e, t) {
|
|
20
|
+
return {
|
|
21
|
+
wildcards: !0,
|
|
22
|
+
skipHidden: !0,
|
|
23
|
+
...e.matchCase ? { caseSensitive: !0 } : {},
|
|
24
|
+
...e.wholeCell ? { wholeCell: !0 } : {},
|
|
25
|
+
...t ? { rows: t } : {}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function S(e, t) {
|
|
29
|
+
let n = e.after ? u(e.after) : null;
|
|
30
|
+
if (!n) return;
|
|
31
|
+
let r = e.range ? f(e.range) : null;
|
|
32
|
+
if (!(r && (n.row < r.top || n.row > r.bottom || n.col < r.left || n.col > r.right)) && (!t || t.includes(n.row))) return {
|
|
33
|
+
sheet: e.sheet,
|
|
34
|
+
cell: a(n.row, n.col)
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
async function te(e, t, n, r) {
|
|
38
|
+
let i = t.lookIn === "values", a = S(t, n), o = await e.findCells(b(t), t.query, {
|
|
39
|
+
...x(t, n),
|
|
40
|
+
in: i ? "text" : "edit",
|
|
41
|
+
...t.byColumns ? { byColumns: !0 } : {},
|
|
42
|
+
...a ? { after: a } : {},
|
|
43
|
+
fields: [],
|
|
44
|
+
maxCells: v,
|
|
45
|
+
count: !0,
|
|
46
|
+
...r ? { signal: r } : {}
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
hits: o.cells.map((e) => {
|
|
50
|
+
let t = u(e.cell);
|
|
51
|
+
return {
|
|
52
|
+
row: t.row,
|
|
53
|
+
col: t.col
|
|
54
|
+
};
|
|
55
|
+
}),
|
|
56
|
+
total: o.total ?? o.cells.length
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function ne(e, t, n, r) {
|
|
60
|
+
return e.replaceInCells(b(t), t.query, n, x(t, r));
|
|
61
|
+
}
|
|
62
|
+
function re(e, t, n) {
|
|
63
|
+
let r = [], i = null;
|
|
64
|
+
for (let o of t) {
|
|
65
|
+
let t = a(o.row, o.col), s = i?.rect, c = s ? _(s, g(o.row, o.col)) : null;
|
|
66
|
+
i && c && (c.bottom - c.top + 1) * (c.right - c.left + 1) <= n ? (i.rect = c, i.only.add(t)) : r.push(i = {
|
|
67
|
+
sheet: e,
|
|
68
|
+
rect: g(o.row, o.col),
|
|
69
|
+
only: /* @__PURE__ */ new Set([t])
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return r;
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/locales.ts
|
|
76
|
+
var C = { "ru-RU": () => import("xlcalc/locales/ru-RU").then((e) => e.ruRU) };
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/local/locale.ts
|
|
79
|
+
async function w(e) {
|
|
80
|
+
if (t.has(e)) return;
|
|
81
|
+
let n = C[e];
|
|
82
|
+
n && i(await n());
|
|
83
|
+
}
|
|
84
|
+
var T = { "ru-RU": () => import("xlcalc/function-text/ru-RU").then((e) => e.ruRUFunctionText) }, E = /* @__PURE__ */ new Map();
|
|
85
|
+
function ie(e) {
|
|
86
|
+
let n = E.get(e);
|
|
87
|
+
if (!n) {
|
|
88
|
+
let r = T[e], i = t.get(e);
|
|
89
|
+
n = r && i ? r().then((e) => ({
|
|
90
|
+
...i,
|
|
91
|
+
...e
|
|
92
|
+
}), () => e) : Promise.resolve(e), E.set(e, n);
|
|
93
|
+
}
|
|
94
|
+
return n;
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/local/validation.ts
|
|
98
|
+
function ae(e) {
|
|
99
|
+
if (!e) return null;
|
|
100
|
+
let { rule: t } = e, n = {};
|
|
101
|
+
return t.type === "list" && t.dropdown !== !1 && (n.list = Array.isArray(e.list) ? e.list.map((e) => e.text) : []), t.showPrompt !== !1 && (t.prompt || t.promptTitle) && (n.prompt = {
|
|
102
|
+
...t.promptTitle ? { title: t.promptTitle } : {},
|
|
103
|
+
text: t.prompt ?? ""
|
|
104
|
+
}), n;
|
|
105
|
+
}
|
|
106
|
+
function D(e) {
|
|
107
|
+
let t = e.rule.errorTitle;
|
|
108
|
+
return {
|
|
109
|
+
ok: !1,
|
|
110
|
+
reason: "refused",
|
|
111
|
+
message: e.message,
|
|
112
|
+
alert: {
|
|
113
|
+
severity: e.severity,
|
|
114
|
+
...t ? { title: t } : {},
|
|
115
|
+
message: e.message,
|
|
116
|
+
sheet: e.sheet,
|
|
117
|
+
cell: e.cell
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region src/local/outcome.ts
|
|
123
|
+
var O = (e) => ({
|
|
124
|
+
ok: !1,
|
|
125
|
+
reason: "failed",
|
|
126
|
+
message: e
|
|
127
|
+
});
|
|
128
|
+
function k(e, t) {
|
|
129
|
+
let n = e, r = n?.message ?? String(e);
|
|
130
|
+
return n?.name === "InputError" ? {
|
|
131
|
+
ok: !1,
|
|
132
|
+
reason: t,
|
|
133
|
+
message: r
|
|
134
|
+
} : O(r);
|
|
135
|
+
}
|
|
136
|
+
var A = /* @__PURE__ */ new Set([
|
|
137
|
+
"syntax",
|
|
138
|
+
"empty",
|
|
139
|
+
"too_long",
|
|
140
|
+
"too_deep"
|
|
141
|
+
]);
|
|
142
|
+
function j(e) {
|
|
143
|
+
if (e.code === "validation") return D(e);
|
|
144
|
+
if (!A.has(e.code)) return {
|
|
145
|
+
ok: !1,
|
|
146
|
+
reason: "refused",
|
|
147
|
+
message: e.message
|
|
148
|
+
};
|
|
149
|
+
let { at: t, correction: n } = e;
|
|
150
|
+
return {
|
|
151
|
+
ok: !1,
|
|
152
|
+
reason: "invalid",
|
|
153
|
+
message: e.message,
|
|
154
|
+
...t === void 0 ? {} : { at: t },
|
|
155
|
+
...n === void 0 ? {} : { correction: n }
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function oe(e, t, n) {
|
|
159
|
+
return {
|
|
160
|
+
sheet: e,
|
|
161
|
+
cell: t,
|
|
162
|
+
text: n?.text ?? "",
|
|
163
|
+
value: n ? n.value : null,
|
|
164
|
+
...n?.color ? { color: n.color } : {},
|
|
165
|
+
formula: n?.formulaLocal ?? null,
|
|
166
|
+
editText: n?.editText ?? "",
|
|
167
|
+
numberFormat: n?.numberFormat ?? null
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
var se = (e) => !!(e.layout?.length || e.styles || e.moved?.length || e.changes.some((e) => e.style !== void 0 || e.note !== void 0 || e.link !== void 0)), M = (e, t) => `${c(e)}!${t}`;
|
|
171
|
+
function N(e) {
|
|
172
|
+
let t = /* @__PURE__ */ new Map();
|
|
173
|
+
for (let n of e) {
|
|
174
|
+
let e = u(n.cell);
|
|
175
|
+
if (!e) continue;
|
|
176
|
+
let r = c(n.sheet), i = t.get(r);
|
|
177
|
+
i ? (i.rect = _(i.rect, g(e.row, e.col)), i.only.add(a(e.row, e.col))) : t.set(r, {
|
|
178
|
+
sheet: n.sheet,
|
|
179
|
+
rect: g(e.row, e.col),
|
|
180
|
+
only: /* @__PURE__ */ new Set([a(e.row, e.col)])
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
return [...t.values()];
|
|
184
|
+
}
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region src/abort.ts
|
|
187
|
+
var P = () => new DOMException("The request was aborted", "AbortError");
|
|
188
|
+
function F(e) {
|
|
189
|
+
if (e?.aborted) throw P();
|
|
190
|
+
}
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region src/filter-key.ts
|
|
193
|
+
var ce = (e) => JSON.stringify([
|
|
194
|
+
e.head,
|
|
195
|
+
Object.entries(e.cols ?? {}).sort(([e], [t]) => Number(e) - Number(t)),
|
|
196
|
+
e.sort ?? null
|
|
197
|
+
]);
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region src/lines.ts
|
|
200
|
+
function I(e, t) {
|
|
201
|
+
let n = d(e, t);
|
|
202
|
+
if (n) return n;
|
|
203
|
+
let r = f(e.includes(":") ? e : `${e}:${e}`);
|
|
204
|
+
return r?.kind === t ? t === "rows" ? {
|
|
205
|
+
first: r.top,
|
|
206
|
+
last: r.bottom
|
|
207
|
+
} : {
|
|
208
|
+
first: r.left,
|
|
209
|
+
last: r.right
|
|
210
|
+
} : null;
|
|
211
|
+
}
|
|
212
|
+
var L = (e) => e.op === "showLevel" ? e.axis : "rows" in e ? "rows" : "columns";
|
|
213
|
+
//#endregion
|
|
214
|
+
//#region src/memory-outline.ts
|
|
215
|
+
function R(e, t) {
|
|
216
|
+
if (!e.rows.length && !e.columns.length) return;
|
|
217
|
+
let n = (t) => e[t].map((e) => ({
|
|
218
|
+
from: e.first,
|
|
219
|
+
to: e.last,
|
|
220
|
+
level: e.level,
|
|
221
|
+
collapsed: e.collapsed
|
|
222
|
+
}));
|
|
223
|
+
return {
|
|
224
|
+
rows: n("rows"),
|
|
225
|
+
columns: n("columns"),
|
|
226
|
+
summaryBelow: t?.summaryBelow ?? !0,
|
|
227
|
+
summaryRight: t?.summaryRight ?? !0
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
function z(e, t) {
|
|
231
|
+
if (e.op === "showLevel") return e.axis === "rows" ? {
|
|
232
|
+
op: "showLevels",
|
|
233
|
+
rows: e.level
|
|
234
|
+
} : {
|
|
235
|
+
op: "showLevels",
|
|
236
|
+
columns: e.level
|
|
237
|
+
};
|
|
238
|
+
let n = L(e), r = "rows" in e ? e.rows : e.columns, i = I(r, n);
|
|
239
|
+
if (!i) return { refused: `Not ${n}: ${r}` };
|
|
240
|
+
if (!("level" in e)) {
|
|
241
|
+
let t = s(i.first, i.last, n);
|
|
242
|
+
return n === "rows" ? {
|
|
243
|
+
op: e.op,
|
|
244
|
+
rows: t
|
|
245
|
+
} : {
|
|
246
|
+
op: e.op,
|
|
247
|
+
columns: t
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
let a = t(n).find((t) => t.first === i.first && t.last === i.last && t.level === e.level);
|
|
251
|
+
if (!a) return { refused: `No group of level ${e.level} over the ${n} ${r}` };
|
|
252
|
+
if (a.summary === null) return { refused: `The group of ${n} ${r} has no summary ${n === "rows" ? "row" : "column"} within the sheet: Excel draws no button for it` };
|
|
253
|
+
let c = e.op === "collapse" ? "hideDetail" : "showDetail";
|
|
254
|
+
return n === "rows" ? {
|
|
255
|
+
op: c,
|
|
256
|
+
row: a.summary
|
|
257
|
+
} : {
|
|
258
|
+
op: c,
|
|
259
|
+
column: o(a.summary)
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
var le = (e, t, n) => Math.max(0, Math.min(t, Math.floor(e / Math.max(1, n)))), B = 1e3;
|
|
263
|
+
function V(e) {
|
|
264
|
+
return !!e && (!!e.sort || Object.values(e.cols ?? {}).some((e) => !!e.values || !!e.text?.trim()));
|
|
265
|
+
}
|
|
266
|
+
function ue(e) {
|
|
267
|
+
let t = new Set(Object.keys(e.cols ?? {}).map(Number));
|
|
268
|
+
return e.sort && t.add(e.sort.col), [...t];
|
|
269
|
+
}
|
|
270
|
+
var H = (e, t) => Math.min(Math.max(0, Math.trunc(e.head)), t);
|
|
271
|
+
function U(e, t, n) {
|
|
272
|
+
let r = Object.entries(t.cols ?? {}).filter(([e]) => Number(e) !== n).map(([e, t]) => ({
|
|
273
|
+
col: Number(e),
|
|
274
|
+
values: t.values ? new Set(t.values) : null,
|
|
275
|
+
text: t.text?.trim() ? t.text.trim().toLocaleLowerCase() : null
|
|
276
|
+
}));
|
|
277
|
+
return (t) => r.every((n) => {
|
|
278
|
+
let r = e.textAt(t, n.col);
|
|
279
|
+
return (!n.values || n.values.has(r)) && (!n.text || r.toLocaleLowerCase().includes(n.text));
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
var W = (e) => e === void 0 || e === "" ? null : e, G = (e, t = !1) => h({
|
|
283
|
+
descending: t,
|
|
284
|
+
...e ? { locale: e } : {}
|
|
285
|
+
});
|
|
286
|
+
function de(e, t, n) {
|
|
287
|
+
let r = H(t, e.maxRow), i = U(e, t), a = [];
|
|
288
|
+
for (let t = r + 1; t <= e.maxRow; t++) i(t) && a.push(t);
|
|
289
|
+
let o = t.sort, s = a;
|
|
290
|
+
if (o) {
|
|
291
|
+
let t = G(n, o.dir === "desc"), r = a.map((t) => W(e.valueAt(t, o.col))), i = a.map((e, t) => t);
|
|
292
|
+
i.sort((e, n) => t(r[e], r[n])), s = i.map((e) => a[e]);
|
|
293
|
+
}
|
|
294
|
+
let c = [];
|
|
295
|
+
for (let e = 1; e <= r; e++) c.push(e);
|
|
296
|
+
return c.concat(s);
|
|
297
|
+
}
|
|
298
|
+
function fe(e, t, n, r) {
|
|
299
|
+
let i = U(e, n, t), a = /* @__PURE__ */ new Map();
|
|
300
|
+
for (let r = H(n, e.maxRow) + 1; r <= e.maxRow; r++) {
|
|
301
|
+
if (!i(r)) continue;
|
|
302
|
+
let n = e.textAt(r, t), o = a.get(n);
|
|
303
|
+
o ? o.count++ : a.set(n, {
|
|
304
|
+
count: 1,
|
|
305
|
+
value: W(e.valueAt(r, t))
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
let o = G(r), s = [...a.entries()].sort(([e, t], [n, r]) => o(t.value, r.value) || o(e, n));
|
|
309
|
+
return {
|
|
310
|
+
values: s.slice(0, B).map(([e, { count: t }]) => ({
|
|
311
|
+
text: e,
|
|
312
|
+
count: t
|
|
313
|
+
})),
|
|
314
|
+
more: Math.max(0, s.length - B)
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
//#endregion
|
|
318
|
+
//#region src/local/query.ts
|
|
319
|
+
var K = 0, q = 1, J = 2, Y = 3, X = 4, Z = (e) => e == null || e === "", pe = class {
|
|
320
|
+
texts;
|
|
321
|
+
kinds;
|
|
322
|
+
nums;
|
|
323
|
+
other = /* @__PURE__ */ new Map();
|
|
324
|
+
constructor(e) {
|
|
325
|
+
this.texts = Array(e).fill(""), this.kinds = new Uint8Array(e), this.nums = new Float64Array(e);
|
|
326
|
+
}
|
|
327
|
+
set(e, t, n) {
|
|
328
|
+
e >= this.kinds.length && this.grow(e + 1), this.texts[e] = t, this.other.delete(e), Z(n) ? this.kinds[e] = K : typeof n == "number" ? (this.kinds[e] = q, this.nums[e] = n) : typeof n == "boolean" ? (this.kinds[e] = Y, this.nums[e] = +!!n) : typeof n == "string" ? (this.kinds[e] = J, n !== t && this.other.set(e, n)) : (this.kinds[e] = X, this.other.set(e, n.error));
|
|
329
|
+
}
|
|
330
|
+
valueAt(e) {
|
|
331
|
+
switch (this.kinds[e]) {
|
|
332
|
+
case q: return this.nums[e];
|
|
333
|
+
case Y: return this.nums[e] === 1;
|
|
334
|
+
case J: return this.other.get(e) ?? this.texts[e];
|
|
335
|
+
case X: return { error: this.other.get(e) };
|
|
336
|
+
default: return null;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
grow(e) {
|
|
340
|
+
let t = Math.max(e, this.kinds.length * 2), n = new Uint8Array(t);
|
|
341
|
+
n.set(this.kinds);
|
|
342
|
+
let r = new Float64Array(t);
|
|
343
|
+
r.set(this.nums);
|
|
344
|
+
for (let e = this.texts.length; e < t; e++) this.texts.push("");
|
|
345
|
+
this.kinds = n, this.nums = r;
|
|
346
|
+
}
|
|
347
|
+
}, me = class {
|
|
348
|
+
maxRow;
|
|
349
|
+
read;
|
|
350
|
+
cols = /* @__PURE__ */ new Map();
|
|
351
|
+
reading = /* @__PURE__ */ new Map();
|
|
352
|
+
constructor(e, t) {
|
|
353
|
+
this.maxRow = e, this.read = t;
|
|
354
|
+
}
|
|
355
|
+
async load(e, t) {
|
|
356
|
+
for (;;) {
|
|
357
|
+
let n = e.filter((e) => !this.cols.has(e) && !this.reading.has(e));
|
|
358
|
+
n.length && this.start(n, t);
|
|
359
|
+
let r = e.flatMap((e) => this.reading.get(e) ?? []);
|
|
360
|
+
try {
|
|
361
|
+
await Promise.all(r.map((e) => e.done));
|
|
362
|
+
return;
|
|
363
|
+
} catch (e) {
|
|
364
|
+
if (F(t), !r.some((e) => e.signal?.aborted)) throw e;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
start(e, t) {
|
|
369
|
+
let n = this.maxRow, r = (n ? this.read(e.map((e) => `${o(e)}1:${o(e)}${n}`), t) : Promise.resolve({})).then((t) => {
|
|
370
|
+
let r = new Map(e.map((e) => [e, new pe(n + 1)]));
|
|
371
|
+
for (let [e, n] of Object.entries(t)) {
|
|
372
|
+
let t = u(e);
|
|
373
|
+
t && r.get(t.col)?.set(t.row, n.text ?? "", n.value);
|
|
374
|
+
}
|
|
375
|
+
for (let [e, t] of r) {
|
|
376
|
+
for (let [n, r, i] of this.reading.get(e).missed) t.set(n, r, i);
|
|
377
|
+
this.cols.set(e, t), this.reading.delete(e);
|
|
378
|
+
}
|
|
379
|
+
}, (t) => {
|
|
380
|
+
for (let t of e) this.reading.delete(t);
|
|
381
|
+
throw t;
|
|
382
|
+
});
|
|
383
|
+
for (let n of e) this.reading.set(n, {
|
|
384
|
+
done: r,
|
|
385
|
+
signal: t,
|
|
386
|
+
missed: []
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
set(e, t, n, r) {
|
|
390
|
+
e > this.maxRow && (n !== "" || !Z(r)) && (this.maxRow = e);
|
|
391
|
+
let i = this.cols.get(t);
|
|
392
|
+
i ? i.set(e, n, r) : this.reading.get(t)?.missed.push([
|
|
393
|
+
e,
|
|
394
|
+
n,
|
|
395
|
+
r
|
|
396
|
+
]);
|
|
397
|
+
}
|
|
398
|
+
textAt(e, t) {
|
|
399
|
+
return this.cols.get(t)?.texts[e] ?? "";
|
|
400
|
+
}
|
|
401
|
+
valueAt(e, t) {
|
|
402
|
+
return this.cols.get(t)?.valueAt(e) ?? null;
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
//#endregion
|
|
406
|
+
//#region src/local/window.ts
|
|
407
|
+
function he(e, t) {
|
|
408
|
+
let n = [];
|
|
409
|
+
for (let [t, r] of Object.entries(e.styles)) n[Number(t)] = r;
|
|
410
|
+
let r = {
|
|
411
|
+
row: t.row,
|
|
412
|
+
col: t.col,
|
|
413
|
+
text: [],
|
|
414
|
+
values: [],
|
|
415
|
+
formulas: {},
|
|
416
|
+
editText: {},
|
|
417
|
+
colors: {},
|
|
418
|
+
styleIds: {},
|
|
419
|
+
styles: n,
|
|
420
|
+
numberFormats: {},
|
|
421
|
+
widths: e.columns.slice(0, t.cols).map((e) => e.hidden ? 0 : e.width),
|
|
422
|
+
rowHeights: {},
|
|
423
|
+
merges: [],
|
|
424
|
+
tables: e.tables.map((e) => ({
|
|
425
|
+
name: e.name,
|
|
426
|
+
range: e.range,
|
|
427
|
+
headerRow: e.headers ? f(e.range)?.top ?? 0 : 0
|
|
428
|
+
})),
|
|
429
|
+
appearance: {},
|
|
430
|
+
links: {},
|
|
431
|
+
notes: {},
|
|
432
|
+
...t.notice ? { notice: t.notice } : {}
|
|
433
|
+
};
|
|
434
|
+
for (let t of e.rows) (t.hidden || t.height !== m) && (r.rowHeights[t.row] = t.hidden ? 0 : t.height);
|
|
435
|
+
let i = t.col + t.cols - 1;
|
|
436
|
+
for (let n of t.rows) {
|
|
437
|
+
let o = [], s = [];
|
|
438
|
+
for (let c = t.col; c <= i; c++) {
|
|
439
|
+
let t = a(n, c), i = e.cells[t];
|
|
440
|
+
if (o.push(i?.text ?? ""), s.push(i ? i.value : null), i && (i.effectiveStyle !== void 0 && (r.styleIds[t] = i.effectiveStyle), i.numberFormat !== void 0 && (r.numberFormats[t] = i.numberFormat), i.formulaLocal !== void 0 && (r.formulas[t] = i.formulaLocal), i.editText && (r.editText[t] = i.editText), i.color && (r.colors[t] = i.color), i.note && (r.notes[t] = i.note), i.appearance && (r.appearance[t] = i.appearance), i.link)) {
|
|
441
|
+
let { url: e, location: n, tooltip: a } = i.link, o = e ? { href: n ? `${e}#${n}` : e } : n ? { location: n } : {};
|
|
442
|
+
r.links[t] = {
|
|
443
|
+
...o,
|
|
444
|
+
...a ? { tooltip: a } : {}
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
r.text.push(o), r.values.push(s);
|
|
449
|
+
}
|
|
450
|
+
if (!t.filtered) r.merges = e.merges;
|
|
451
|
+
else {
|
|
452
|
+
let n = new Set(t.rows);
|
|
453
|
+
r.merges = e.merges.filter((e) => {
|
|
454
|
+
let t = f(e);
|
|
455
|
+
return !!t && t.top === t.bottom && n.has(t.top);
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
return r;
|
|
459
|
+
}
|
|
460
|
+
//#endregion
|
|
461
|
+
//#region src/local/source.ts
|
|
462
|
+
async function ge(e) {
|
|
463
|
+
if ((typeof e.calc == "string" ? e.calc : typeof Worker == "function" ? "pool" : "inline") === "inline") return n();
|
|
464
|
+
let { createCalcPool: t } = await import("xlcalc/worker");
|
|
465
|
+
return t({
|
|
466
|
+
threads: 1,
|
|
467
|
+
...e.pool
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
function _e(e, t) {
|
|
471
|
+
let n = e.frozen, r = R(l(e), e.outline);
|
|
472
|
+
return {
|
|
473
|
+
name: e.name,
|
|
474
|
+
maxRow: t.rows,
|
|
475
|
+
maxCol: t.columns,
|
|
476
|
+
...n ? { freeze: {
|
|
477
|
+
rows: n.rows ?? 0,
|
|
478
|
+
cols: n.columns ?? 0
|
|
479
|
+
} } : {},
|
|
480
|
+
...e.hidden ? { hidden: e.hidden } : {},
|
|
481
|
+
...r ? { outline: r } : {}
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
function Q(e, t) {
|
|
485
|
+
let n = I(e, t);
|
|
486
|
+
return n && s(n.first, n.last, t);
|
|
487
|
+
}
|
|
488
|
+
async function ve(e, t) {
|
|
489
|
+
let n;
|
|
490
|
+
if ("level" in t && t.op !== "showLevel" && (n = (await e.getLayout()).sheets.find((e) => ee(e.name, t.sheet)), !n)) return O(`No sheet ${t.sheet}`);
|
|
491
|
+
let r = z(t, (e) => n ? l(n)[e] : []);
|
|
492
|
+
return "refused" in r ? {
|
|
493
|
+
ok: !1,
|
|
494
|
+
reason: "refused",
|
|
495
|
+
message: r.refused
|
|
496
|
+
} : {
|
|
497
|
+
...r,
|
|
498
|
+
sheet: t.sheet
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
function ye(n, i = {}) {
|
|
502
|
+
let o = n.locale ?? "en-US", s, l = i.maxCells ?? 2e4, d = /* @__PURE__ */ new Set(), m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), g = null, _ = null, v = Promise.resolve();
|
|
503
|
+
function y(e) {
|
|
504
|
+
return (...t) => {
|
|
505
|
+
let n = v.then(() => e(...t));
|
|
506
|
+
return v = n.catch(() => {}), n;
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
let b = (async () => {
|
|
510
|
+
await w(o), g = typeof i.calc == "object" ? i.calc : await ge(i), _ = await g.createSession(n, i.session);
|
|
511
|
+
})();
|
|
512
|
+
b.catch(() => {});
|
|
513
|
+
let x = async () => (await b, _);
|
|
514
|
+
function S(e) {
|
|
515
|
+
for (let t of d) t(e);
|
|
516
|
+
}
|
|
517
|
+
function C() {
|
|
518
|
+
m.clear(), h.clear(), S({ kind: "reload" });
|
|
519
|
+
}
|
|
520
|
+
let T = n.sheets.some((e) => e.conditionalFormats?.some((e) => "style" in e && e.style?.numberFormat !== void 0));
|
|
521
|
+
function E(e) {
|
|
522
|
+
T && m.clear(), S({
|
|
523
|
+
kind: "repaint",
|
|
524
|
+
ranges: e.map((e) => ({
|
|
525
|
+
sheet: e.sheet,
|
|
526
|
+
range: e.range
|
|
527
|
+
}))
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
function D(e, t = /* @__PURE__ */ new Map()) {
|
|
531
|
+
let n = new Map(t);
|
|
532
|
+
for (let t of e) {
|
|
533
|
+
let e = M(t.sheet, t.cell);
|
|
534
|
+
n.has(e) || n.set(e, {
|
|
535
|
+
sheet: t.sheet,
|
|
536
|
+
cell: t.cell,
|
|
537
|
+
text: t.text ?? "",
|
|
538
|
+
value: t.value,
|
|
539
|
+
...t.color ? { color: t.color } : {}
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
let r = [...n.values()], i = /* @__PURE__ */ new Map();
|
|
543
|
+
for (let e of r) {
|
|
544
|
+
let t = m.get(c(e.sheet));
|
|
545
|
+
if (!t) continue;
|
|
546
|
+
let n = i.get(t);
|
|
547
|
+
n ? n.push(e) : i.set(t, [e]);
|
|
548
|
+
}
|
|
549
|
+
for (let [e, t] of i) e.then((e) => {
|
|
550
|
+
for (let n of t) {
|
|
551
|
+
let t = u(n.cell);
|
|
552
|
+
t && e.set(t.row, t.col, n.text, n.value);
|
|
553
|
+
}
|
|
554
|
+
});
|
|
555
|
+
return r;
|
|
556
|
+
}
|
|
557
|
+
function A(e, t) {
|
|
558
|
+
let n = c(t), r = m.get(n);
|
|
559
|
+
return r || (r = e.getUsedRange(t).then((n) => new me(n.rows, (n, r) => e.getCells(t, n, r ? { signal: r } : {}))), m.set(n, r), r.catch(() => m.delete(n))), r;
|
|
560
|
+
}
|
|
561
|
+
async function P(e, t, n, r) {
|
|
562
|
+
let i = await A(e, t);
|
|
563
|
+
return await i.load(n, r), i;
|
|
564
|
+
}
|
|
565
|
+
async function I(e, t, n, r, i) {
|
|
566
|
+
let a = ce(n), s = h.get(c(t));
|
|
567
|
+
if (!r && s?.key === a) return s;
|
|
568
|
+
let l = await P(e, t, ue(n), i), u = {
|
|
569
|
+
key: a,
|
|
570
|
+
rows: de(l, n, o),
|
|
571
|
+
max: l.maxRow
|
|
572
|
+
};
|
|
573
|
+
return h.set(c(t), u), u;
|
|
574
|
+
}
|
|
575
|
+
async function L(e, t, n, r) {
|
|
576
|
+
if (!V(n)) return null;
|
|
577
|
+
let i = await I(e, t, n, !1, r);
|
|
578
|
+
return i.rows.length < i.max ? i.asc ??= [...i.rows].sort((e, t) => e - t) : null;
|
|
579
|
+
}
|
|
580
|
+
async function R(e, t) {
|
|
581
|
+
let n = /* @__PURE__ */ new Map(), r = !1;
|
|
582
|
+
return await Promise.all(t.map(async (t) => {
|
|
583
|
+
let i = await e.getViewport(t.sheet, p(t.rect), {
|
|
584
|
+
formulaLocal: !0,
|
|
585
|
+
editText: !0,
|
|
586
|
+
maxCells: l
|
|
587
|
+
});
|
|
588
|
+
r ||= i.truncated;
|
|
589
|
+
let o = f(i.range);
|
|
590
|
+
for (let e = o.top; e <= o.bottom; e++) for (let r = o.left; r <= o.right; r++) {
|
|
591
|
+
let o = a(e, r);
|
|
592
|
+
(!t.only || t.only.has(o)) && n.set(M(t.sheet, o), oe(t.sheet, o, i.cells[o]));
|
|
593
|
+
}
|
|
594
|
+
})), {
|
|
595
|
+
updates: n,
|
|
596
|
+
truncated: r
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
async function z(e, t, n) {
|
|
600
|
+
let { updates: r, truncated: i } = await R(e, n), a = D(t.changes, r);
|
|
601
|
+
return i || se(t) ? C() : (a.length && S({
|
|
602
|
+
kind: "changed",
|
|
603
|
+
changes: a
|
|
604
|
+
}), t.repaint?.length && E(t.repaint)), {
|
|
605
|
+
ok: !0,
|
|
606
|
+
changes: a
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
function B(e, t) {
|
|
610
|
+
return y(async (...n) => {
|
|
611
|
+
let r = await x();
|
|
612
|
+
try {
|
|
613
|
+
return await e(r, ...n);
|
|
614
|
+
} catch (e) {
|
|
615
|
+
return t(e);
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
let H = (e) => k(e, "refused"), U = (e) => k(e, "failed");
|
|
620
|
+
function W(e) {
|
|
621
|
+
let t = D(e);
|
|
622
|
+
return C(), {
|
|
623
|
+
ok: !0,
|
|
624
|
+
changes: t
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
async function G(e, t, n) {
|
|
628
|
+
let r = [];
|
|
629
|
+
for (let e of t) {
|
|
630
|
+
let t = u(e.cell);
|
|
631
|
+
if (!t) return O(`No cell ${e.sheet}!${e.cell}`);
|
|
632
|
+
r.push({
|
|
633
|
+
sheet: e.sheet,
|
|
634
|
+
cell: a(t.row, t.col),
|
|
635
|
+
text: e.text
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
if (!r.length) return {
|
|
639
|
+
ok: !0,
|
|
640
|
+
changes: []
|
|
641
|
+
};
|
|
642
|
+
let i = N(r);
|
|
643
|
+
if (r.every((e) => e.text === null)) return z(e, await e.clearCells(r.map((e) => ({
|
|
644
|
+
sheet: e.sheet,
|
|
645
|
+
range: e.cell
|
|
646
|
+
})), "contents"), i);
|
|
647
|
+
let o = r.map((e) => ({
|
|
648
|
+
sheet: e.sheet,
|
|
649
|
+
cell: e.cell,
|
|
650
|
+
text: e.text ?? ""
|
|
651
|
+
})), s = await e.setCellTexts(o, {
|
|
652
|
+
refuseInvalid: !n?.accept,
|
|
653
|
+
...n?.inPlace ? { inPlace: !0 } : {}
|
|
654
|
+
});
|
|
655
|
+
return s.ok ? z(e, s, i) : j(s);
|
|
656
|
+
}
|
|
657
|
+
async function K(e, t, n, r) {
|
|
658
|
+
let i = await e.pasteText(t, n, r);
|
|
659
|
+
return i.ok ? {
|
|
660
|
+
...await z(e, i, [{
|
|
661
|
+
sheet: t,
|
|
662
|
+
rect: f(i.range)
|
|
663
|
+
}]),
|
|
664
|
+
select: {
|
|
665
|
+
sheet: t,
|
|
666
|
+
range: i.range
|
|
667
|
+
}
|
|
668
|
+
} : j(i);
|
|
669
|
+
}
|
|
670
|
+
async function q(e, t, n, r, i) {
|
|
671
|
+
let o = u(n);
|
|
672
|
+
if (!o) return O(`No cell ${t}!${n}`);
|
|
673
|
+
let s = (await e.getValidation(t, n))?.list, c = Array.isArray(s) ? s[r] : void 0;
|
|
674
|
+
if (!c || c.text !== i) return {
|
|
675
|
+
ok: !1,
|
|
676
|
+
reason: "conflict",
|
|
677
|
+
message: `The list of ${t}!${n} changed: open it again`
|
|
678
|
+
};
|
|
679
|
+
let l = a(o.row, o.col);
|
|
680
|
+
return z(e, await e.setCells([{
|
|
681
|
+
sheet: t,
|
|
682
|
+
cell: l,
|
|
683
|
+
input: c.input
|
|
684
|
+
}]), N([{
|
|
685
|
+
sheet: t,
|
|
686
|
+
cell: l
|
|
687
|
+
}]));
|
|
688
|
+
}
|
|
689
|
+
async function J(e, t, n, r, i, a) {
|
|
690
|
+
let o = f(n);
|
|
691
|
+
if (!o) return O(`Not a range: ${n}`);
|
|
692
|
+
let s = await e.fillCellText(t, n, r, {
|
|
693
|
+
active: i,
|
|
694
|
+
refuseInvalid: !a?.accept,
|
|
695
|
+
...a?.inPlace ? { inPlace: !0 } : {}
|
|
696
|
+
});
|
|
697
|
+
return s.ok ? {
|
|
698
|
+
...await z(e, s, [{
|
|
699
|
+
sheet: t,
|
|
700
|
+
rect: o
|
|
701
|
+
}]),
|
|
702
|
+
select: {
|
|
703
|
+
sheet: t,
|
|
704
|
+
range: p(o)
|
|
705
|
+
}
|
|
706
|
+
} : j(s);
|
|
707
|
+
}
|
|
708
|
+
async function Y(e, t) {
|
|
709
|
+
let n = await e[t]();
|
|
710
|
+
if (!n) return {
|
|
711
|
+
ok: !0,
|
|
712
|
+
changes: []
|
|
713
|
+
};
|
|
714
|
+
if (n.call === "editStructure") return W(n.changes);
|
|
715
|
+
let r = N(n.cells ?? []), i = await z(e, n, r), a = r[0];
|
|
716
|
+
return a ? {
|
|
717
|
+
...i,
|
|
718
|
+
select: {
|
|
719
|
+
sheet: a.sheet,
|
|
720
|
+
range: p(a.rect)
|
|
721
|
+
}
|
|
722
|
+
} : i;
|
|
723
|
+
}
|
|
724
|
+
async function X(e, t) {
|
|
725
|
+
let n = await e.editStructure(t);
|
|
726
|
+
return n.ok ? W(n.changes) : {
|
|
727
|
+
ok: !1,
|
|
728
|
+
reason: "refused",
|
|
729
|
+
code: n.code,
|
|
730
|
+
message: n.message
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
async function Z(e, t) {
|
|
734
|
+
let n = (e) => t.hidden === void 0 ? e !== void 0 && e > 0 ? { hidden: null } : {} : { hidden: t.hidden ? !0 : null }, r;
|
|
735
|
+
if ("columns" in t) {
|
|
736
|
+
let e = Q(t.columns, "columns");
|
|
737
|
+
if (!e) return O(`Not columns: ${t.columns}`);
|
|
738
|
+
r = t.fit ? {
|
|
739
|
+
sheet: t.sheet,
|
|
740
|
+
columns: e,
|
|
741
|
+
fit: !0
|
|
742
|
+
} : {
|
|
743
|
+
sheet: t.sheet,
|
|
744
|
+
columns: e,
|
|
745
|
+
set: {
|
|
746
|
+
...t.width === void 0 ? {} : {
|
|
747
|
+
width: t.width,
|
|
748
|
+
bestFit: null
|
|
749
|
+
},
|
|
750
|
+
...n(t.width)
|
|
751
|
+
}
|
|
752
|
+
};
|
|
753
|
+
} else {
|
|
754
|
+
let e = Q(t.rows, "rows");
|
|
755
|
+
if (!e) return O(`Not rows: ${t.rows}`);
|
|
756
|
+
r = t.fit ? {
|
|
757
|
+
sheet: t.sheet,
|
|
758
|
+
rows: e,
|
|
759
|
+
fit: !0
|
|
760
|
+
} : {
|
|
761
|
+
sheet: t.sheet,
|
|
762
|
+
rows: e,
|
|
763
|
+
set: {
|
|
764
|
+
...t.height === void 0 ? {} : {
|
|
765
|
+
height: t.height,
|
|
766
|
+
bestFit: null
|
|
767
|
+
},
|
|
768
|
+
...n(t.height)
|
|
769
|
+
}
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
let i = await e.setLayout([r]);
|
|
773
|
+
if (t.hidden !== void 0 || "fit" in t && t.fit) return W(i.changes);
|
|
774
|
+
let a = D(i.changes);
|
|
775
|
+
return a.length && S({
|
|
776
|
+
kind: "changed",
|
|
777
|
+
changes: a
|
|
778
|
+
}), {
|
|
779
|
+
ok: !0,
|
|
780
|
+
changes: a
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
async function pe(e, t, n) {
|
|
784
|
+
let r = [];
|
|
785
|
+
for (let e of n) {
|
|
786
|
+
let n = {};
|
|
787
|
+
e.style !== void 0 && (n.style = e.style), e.numberFormat !== void 0 && (n.numberFormat = e.numberFormat), Object.keys(n).length && r.push({
|
|
788
|
+
sheet: t,
|
|
789
|
+
range: e.range,
|
|
790
|
+
set: n
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
if (!r.length) return {
|
|
794
|
+
ok: !0,
|
|
795
|
+
changes: []
|
|
796
|
+
};
|
|
797
|
+
let i = await e.patchCells(r);
|
|
798
|
+
if (r.some((e) => e.set.numberFormat !== void 0)) return W(i.changes);
|
|
799
|
+
let a = D(i.changes);
|
|
800
|
+
return S({
|
|
801
|
+
kind: "repaint",
|
|
802
|
+
ranges: [...n.filter((e) => e.style !== void 0).map((e) => ({
|
|
803
|
+
sheet: t,
|
|
804
|
+
range: e.range
|
|
805
|
+
})), ...(i.repaint ?? []).map((e) => ({
|
|
806
|
+
sheet: e.sheet,
|
|
807
|
+
range: e.range
|
|
808
|
+
}))]
|
|
809
|
+
}), {
|
|
810
|
+
ok: !0,
|
|
811
|
+
changes: a
|
|
812
|
+
};
|
|
813
|
+
}
|
|
814
|
+
async function ye(e, t, n) {
|
|
815
|
+
let r = await ne(e, t, n, await L(e, t.sheet, t.filter)), i = r.refused?.length ? { refused: r.refused.map((e) => ({
|
|
816
|
+
sheet: e.sheet,
|
|
817
|
+
cell: e.cell,
|
|
818
|
+
message: e.message
|
|
819
|
+
})) } : {};
|
|
820
|
+
if (!r.replaced) return {
|
|
821
|
+
ok: !0,
|
|
822
|
+
changes: [],
|
|
823
|
+
replaced: 0,
|
|
824
|
+
...i
|
|
825
|
+
};
|
|
826
|
+
let a = r.changes.filter((e) => ee(e.sheet, t.sheet)).map((e) => u(e.cell));
|
|
827
|
+
return {
|
|
828
|
+
...await z(e, r, re(t.sheet, a, l)),
|
|
829
|
+
replaced: r.replaced,
|
|
830
|
+
...i
|
|
831
|
+
};
|
|
832
|
+
}
|
|
833
|
+
async function $(e, t) {
|
|
834
|
+
let n = await ve(e, t);
|
|
835
|
+
return "ok" in n ? n : X(e, n);
|
|
836
|
+
}
|
|
837
|
+
async function be(e, t, n) {
|
|
838
|
+
let r = n && (n.rows > 0 || n.cols > 0) ? {
|
|
839
|
+
...n.rows > 0 ? { rows: n.rows } : {},
|
|
840
|
+
...n.cols > 0 ? { columns: n.cols } : {}
|
|
841
|
+
} : null, i = D((await e.setLayout([{
|
|
842
|
+
sheet: t,
|
|
843
|
+
frozen: r
|
|
844
|
+
}])).changes);
|
|
845
|
+
return S({ kind: "reload" }), {
|
|
846
|
+
ok: !0,
|
|
847
|
+
changes: i
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
return {
|
|
851
|
+
maxCells: l,
|
|
852
|
+
locale: o,
|
|
853
|
+
ready: b,
|
|
854
|
+
async sheets(e) {
|
|
855
|
+
let t = await x(), { sheets: n } = await t.getLayout(), r = await Promise.all(n.map((e) => t.getUsedRange(e.name)));
|
|
856
|
+
return F(e), n.map((e, t) => _e(e, r[t]));
|
|
857
|
+
},
|
|
858
|
+
async window(e, t) {
|
|
859
|
+
let n = await x();
|
|
860
|
+
F(t);
|
|
861
|
+
let r = Math.max(0, e.cols), o = le(l, e.rows, r), s = V(e.filter), c;
|
|
862
|
+
c = s ? (await I(n, e.sheet, e.filter, !1, t)).rows.slice(e.row - 1, e.row - 1 + o) : Array.from({ length: o }, (t, n) => e.row + n);
|
|
863
|
+
let u = [...c].sort((e, t) => e - t), d = u[0] ?? 1, f = `${a(d, e.col)}:${a(u[u.length - 1] ?? d, e.col + Math.max(1, r) - 1)}`, p = await n.getViewport(e.sheet, f, {
|
|
864
|
+
formulaLocal: !0,
|
|
865
|
+
editText: !0,
|
|
866
|
+
maxCells: l,
|
|
867
|
+
...s || !c.length ? { rows: u } : {}
|
|
868
|
+
});
|
|
869
|
+
return F(t), he(p, {
|
|
870
|
+
row: e.row,
|
|
871
|
+
rows: c,
|
|
872
|
+
col: e.col,
|
|
873
|
+
cols: r,
|
|
874
|
+
filtered: s,
|
|
875
|
+
notice: i.notice
|
|
876
|
+
});
|
|
877
|
+
},
|
|
878
|
+
edit: B(G, H),
|
|
879
|
+
paste: B(K, H),
|
|
880
|
+
fill: B(J, H),
|
|
881
|
+
pick: B(q, H),
|
|
882
|
+
undo: B((e) => Y(e, "undo"), U),
|
|
883
|
+
redo: B((e) => Y(e, "redo"), U),
|
|
884
|
+
structure: B(X, U),
|
|
885
|
+
layout: B(Z, U),
|
|
886
|
+
format: B(pe, H),
|
|
887
|
+
replace: B(ye, (e) => ({
|
|
888
|
+
...H(e),
|
|
889
|
+
replaced: 0
|
|
890
|
+
})),
|
|
891
|
+
outline: B($, U),
|
|
892
|
+
freeze: B(be, U),
|
|
893
|
+
get history() {
|
|
894
|
+
return _?.history ?? {
|
|
895
|
+
undo: 0,
|
|
896
|
+
redo: 0
|
|
897
|
+
};
|
|
898
|
+
},
|
|
899
|
+
subscribe(e) {
|
|
900
|
+
return d.add(e), () => d.delete(e);
|
|
901
|
+
},
|
|
902
|
+
async copyText(e, t, n) {
|
|
903
|
+
let r = await x();
|
|
904
|
+
return F(n?.signal), r.copyText(e, t, {
|
|
905
|
+
...n?.trailingNewline === !1 ? { trailingNewline: !1 } : {},
|
|
906
|
+
...n?.signal ? { signal: n.signal } : {}
|
|
907
|
+
});
|
|
908
|
+
},
|
|
909
|
+
async validation(e, t, n) {
|
|
910
|
+
let r = await x();
|
|
911
|
+
F(n);
|
|
912
|
+
let i = ae(await r.getValidation(e, t));
|
|
913
|
+
return F(n), i;
|
|
914
|
+
},
|
|
915
|
+
async functionNames(n) {
|
|
916
|
+
await b, F(n);
|
|
917
|
+
let r = t.get(o)?.functions ?? {};
|
|
918
|
+
return e.map((e) => r[e] ?? e).sort(new Intl.Collator(o).compare);
|
|
919
|
+
},
|
|
920
|
+
async functionSignature(e, t) {
|
|
921
|
+
await b, F(t);
|
|
922
|
+
let n = await ie(o);
|
|
923
|
+
F(t);
|
|
924
|
+
let i = r(e, n);
|
|
925
|
+
s ??= import("xlcalc/function-text").then((e) => e.functionDescription, () => null);
|
|
926
|
+
let a = i && (await s)?.(i.fn, n);
|
|
927
|
+
return i && a ? {
|
|
928
|
+
...i,
|
|
929
|
+
description: a
|
|
930
|
+
} : i;
|
|
931
|
+
},
|
|
932
|
+
async explain(e, t) {
|
|
933
|
+
return (await (await x()).explain(e, t)).text;
|
|
934
|
+
},
|
|
935
|
+
async end(e, t, n, r) {
|
|
936
|
+
let i = await x();
|
|
937
|
+
return F(r), i.getEnd(e, t, n);
|
|
938
|
+
},
|
|
939
|
+
async stats(e, t, n, r) {
|
|
940
|
+
let i = await x();
|
|
941
|
+
F(r);
|
|
942
|
+
let a = await L(i, e, n, r);
|
|
943
|
+
try {
|
|
944
|
+
let n = await i.summarizeRanges([{
|
|
945
|
+
sheet: e,
|
|
946
|
+
range: t
|
|
947
|
+
}], {
|
|
948
|
+
...a ? { rows: a } : {},
|
|
949
|
+
...r ? { signal: r } : {}
|
|
950
|
+
});
|
|
951
|
+
return {
|
|
952
|
+
cells: n.cells,
|
|
953
|
+
numbers: n.numbers,
|
|
954
|
+
sum: typeof n.sum == "number" ? n.sum : NaN,
|
|
955
|
+
min: n.min,
|
|
956
|
+
max: n.max
|
|
957
|
+
};
|
|
958
|
+
} catch (e) {
|
|
959
|
+
throw F(r), e;
|
|
960
|
+
}
|
|
961
|
+
},
|
|
962
|
+
async find(e, t) {
|
|
963
|
+
let n = await x();
|
|
964
|
+
F(t);
|
|
965
|
+
let r = await L(n, e.sheet, e.filter, t);
|
|
966
|
+
try {
|
|
967
|
+
return await te(n, e, r, t);
|
|
968
|
+
} catch (e) {
|
|
969
|
+
throw F(t), e;
|
|
970
|
+
}
|
|
971
|
+
},
|
|
972
|
+
async visibleRows(e, t, n) {
|
|
973
|
+
let r = await x();
|
|
974
|
+
return V(t) ? (F(n), { rows: (await I(r, e, t, !0, n)).rows }) : (h.delete(c(e)), { rows: null });
|
|
975
|
+
},
|
|
976
|
+
async columnValues(e, t, n, r) {
|
|
977
|
+
let i = await x();
|
|
978
|
+
return F(r), fe(await P(i, e, [t, ...Object.keys(n.cols ?? {}).map(Number)], r), t, n, o);
|
|
979
|
+
},
|
|
980
|
+
async book() {
|
|
981
|
+
return (await x()).getBook();
|
|
982
|
+
},
|
|
983
|
+
async snapshot() {
|
|
984
|
+
return (await x()).getSnapshot();
|
|
985
|
+
},
|
|
986
|
+
async close() {
|
|
987
|
+
await b.catch(() => {}), await _?.close(), g && typeof i.calc != "object" && await g.close();
|
|
988
|
+
}
|
|
989
|
+
};
|
|
990
|
+
}
|
|
991
|
+
//#endregion
|
|
992
|
+
//#region src/local/xlsx.ts
|
|
993
|
+
async function $(e) {
|
|
994
|
+
return e.locale === void 0 ? {} : (typeof e.locale == "string" && await w(e.locale), { locale: e.locale });
|
|
995
|
+
}
|
|
996
|
+
async function be(e, t = {}) {
|
|
997
|
+
let n = e instanceof Blob ? new Uint8Array(await e.arrayBuffer()) : e, [{ readXlsx: r }, i] = await Promise.all([import("xlcalc/xlsx"), $(t)]);
|
|
998
|
+
return r(n, i);
|
|
999
|
+
}
|
|
1000
|
+
async function xe(e, t = {}) {
|
|
1001
|
+
let [{ writeXlsx: n }, r, i] = await Promise.all([
|
|
1002
|
+
import("xlcalc/xlsx"),
|
|
1003
|
+
e.snapshot(),
|
|
1004
|
+
$(t)
|
|
1005
|
+
]);
|
|
1006
|
+
return n(r, {
|
|
1007
|
+
...t.mode ? { mode: t.mode } : {},
|
|
1008
|
+
...i
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
function Se(e) {
|
|
1012
|
+
let t = /* @__PURE__ */ new Map();
|
|
1013
|
+
for (let n of e) {
|
|
1014
|
+
let e = t.get(n.code);
|
|
1015
|
+
e || t.set(n.code, e = {
|
|
1016
|
+
code: n.code,
|
|
1017
|
+
count: 0,
|
|
1018
|
+
sheets: [],
|
|
1019
|
+
message: n.message
|
|
1020
|
+
}), e.count++, n.sheet && !e.sheets.includes(n.sheet) && e.sheets.push(n.sheet);
|
|
1021
|
+
}
|
|
1022
|
+
return [...t.values()];
|
|
1023
|
+
}
|
|
1024
|
+
//#endregion
|
|
1025
|
+
export { Se as groupIssues, ye as localSource, be as openXlsx, xe as saveXlsx };
|