ooxml-core 1.36.0 → 1.37.0
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/dist/PptxHandler-2JSQ22VD.cjs +14 -0
- package/dist/{PptxHandler-XCYX5DVX.mjs → PptxHandler-3T5DTNKA.mjs} +2 -2
- package/dist/PptxHandler-7T7ZS7IK.mjs +5 -0
- package/dist/{PresentationBuilder-JBTNOIL7.mjs → PresentationBuilder-D6ZICJWN.mjs} +3 -3
- package/dist/{PresentationBuilder-HA56ZY23.cjs → PresentationBuilder-HCMXZQDK.cjs} +6 -6
- package/dist/{PresentationBuilder-IVLUEB4K.mjs → PresentationBuilder-XHKNDJMD.mjs} +2 -2
- package/dist/automation/index.cjs +21750 -19661
- package/dist/automation/index.mjs +21731 -19661
- package/dist/chart/index.cjs +1 -1
- package/dist/chart/index.mjs +1 -1
- package/dist/chart/region-map/index.cjs +1 -1
- package/dist/chart/region-map/index.mjs +1 -1
- package/dist/{chunk-UQMAPY6D.mjs → chunk-2TQJHNVU.mjs} +1 -1
- package/dist/{chunk-RI56PFGL.mjs → chunk-4YBSHQ76.mjs} +5 -5
- package/dist/{chunk-XF6ZRA2D.cjs → chunk-AFALJ5TA.cjs} +3 -3
- package/dist/{chunk-MK2IBZU6.mjs → chunk-CNIKTXAV.mjs} +1 -1
- package/dist/{chunk-PA5ADSTX.cjs → chunk-GZOYXHDF.cjs} +1269 -1269
- package/dist/{chunk-LSO5SSFX.mjs → chunk-H2Q42P6P.mjs} +1 -1
- package/dist/{chunk-EGBNPVBA.mjs → chunk-J43V3QOA.mjs} +2 -2
- package/dist/{chunk-TJXK4D4U.mjs → chunk-M2DFN3SP.mjs} +4 -4
- package/dist/{chunk-RPJHMPEL.mjs → chunk-OEM2ECAJ.mjs} +1 -1
- package/dist/{chunk-GNGL4BO7.mjs → chunk-RHQQS6LJ.mjs} +4 -4
- package/dist/{chunk-A27O7M5X.cjs → chunk-SNID2FDY.cjs} +1 -1
- package/dist/{chunk-EDRS3OSM.mjs → chunk-WNAPUUAT.mjs} +1 -0
- package/dist/color/theme-palette.d.ts +1 -1
- package/dist/color/theme-palette.d.ts.map +1 -1
- package/dist/crypto/index.cjs +1 -1
- package/dist/crypto/index.mjs +1 -1
- package/dist/diagram/index.cjs +1 -1
- package/dist/diagram/index.mjs +1 -1
- package/dist/docx/block-parser.d.ts.map +1 -1
- package/dist/docx/comment-parts.d.ts +33 -0
- package/dist/docx/comment-parts.d.ts.map +1 -0
- package/dist/docx/comments.d.ts +5 -2
- package/dist/docx/comments.d.ts.map +1 -1
- package/dist/docx/embedded.cjs +15231 -14731
- package/dist/docx/embedded.mjs +15231 -14731
- package/dist/docx/glossary.d.ts.map +1 -1
- package/dist/docx/index.cjs +10771 -10329
- package/dist/docx/index.mjs +10771 -10329
- package/dist/docx/layout/index.cjs +81 -73
- package/dist/docx/layout/index.mjs +81 -73
- package/dist/docx/load/index.cjs +16891 -16391
- package/dist/docx/load/index.mjs +16891 -16391
- package/dist/docx/page-background.d.ts +4 -3
- package/dist/docx/page-background.d.ts.map +1 -1
- package/dist/docx/paragraph-text.d.ts +5 -0
- package/dist/docx/paragraph-text.d.ts.map +1 -0
- package/dist/docx/parse.d.ts.map +1 -1
- package/dist/docx/save.d.ts.map +1 -1
- package/dist/docx/special-characters.d.ts +2 -0
- package/dist/docx/special-characters.d.ts.map +1 -1
- package/dist/docx/theme-color.d.ts.map +1 -1
- package/dist/docx/ui/index.cjs +135 -135
- package/dist/docx/ui/index.mjs +135 -135
- package/dist/docx/write-comment-identities.d.ts +8 -0
- package/dist/docx/write-comment-identities.d.ts.map +1 -0
- package/dist/docx/write-comment-metadata.d.ts +12 -0
- package/dist/docx/write-comment-metadata.d.ts.map +1 -0
- package/dist/docx/write-comment-text.d.ts +3 -0
- package/dist/docx/write-comment-text.d.ts.map +1 -0
- package/dist/docx/write-comments.d.ts +1 -4
- package/dist/docx/write-comments.d.ts.map +1 -1
- package/dist/drawingml/index.cjs +1 -1
- package/dist/drawingml/index.mjs +1 -1
- package/dist/index.cjs +110 -6
- package/dist/index.mjs +91 -6
- package/dist/math/index.cjs +1 -1
- package/dist/math/index.mjs +1 -1
- package/dist/opc/index.cjs +78 -3
- package/dist/opc/index.mjs +78 -3
- package/dist/opc/signature/index.d.ts +1 -0
- package/dist/opc/signature/index.d.ts.map +1 -1
- package/dist/opc/signature/package.d.ts +12 -0
- package/dist/opc/signature/package.d.ts.map +1 -0
- package/dist/pptx/automation/index.cjs +21 -4
- package/dist/pptx/automation/index.d.ts +1 -0
- package/dist/pptx/automation/index.d.ts.map +1 -1
- package/dist/pptx/automation/index.mjs +16 -6
- package/dist/pptx/automation/schemas/index.cjs +1 -0
- package/dist/pptx/automation/schemas/index.mjs +1 -1
- package/dist/pptx/automation/schemas/presentation-schemas.cjs +1 -0
- package/dist/pptx/automation/schemas/presentation-schemas.d.ts +1 -0
- package/dist/pptx/automation/schemas/presentation-schemas.d.ts.map +1 -1
- package/dist/pptx/automation/schemas/presentation-schemas.mjs +1 -1
- package/dist/pptx/cli/index.cjs +10 -4
- package/dist/pptx/cli/index.mjs +4 -4
- package/dist/pptx/converter/index.cjs +7 -1
- package/dist/pptx/converter/index.mjs +2 -2
- package/dist/pptx/editor/render/custom-show-operations.cjs +2 -2
- package/dist/pptx/editor/render/custom-show-operations.mjs +1 -1
- package/dist/pptx/editor/render/find-replace.cjs +15 -15
- package/dist/pptx/editor/render/find-replace.mjs +2 -2
- package/dist/pptx/editor/render/slide-operations.cjs +9 -9
- package/dist/pptx/editor/render/slide-operations.mjs +3 -3
- package/dist/pptx/index.cjs +10 -4
- package/dist/pptx/index.mjs +5 -5
- package/dist/pptx/ui/index.d.ts +1 -1
- package/dist/teams/index.cjs +812 -95
- package/dist/teams/index.mjs +811 -95
- package/dist/visio/bevel-3d.d.ts +6 -10
- package/dist/visio/bevel-3d.d.ts.map +1 -1
- package/dist/visio/bevel-shading.d.ts +72 -0
- package/dist/visio/bevel-shading.d.ts.map +1 -0
- package/dist/visio/cff-recalc.d.ts.map +1 -1
- package/dist/visio/collab/index.cjs +1 -1
- package/dist/visio/collab/index.mjs +1 -1
- package/dist/visio/data-graphic-instance.d.ts +44 -0
- package/dist/visio/data-graphic-instance.d.ts.map +1 -0
- package/dist/visio/data-graphic-masters.d.ts +38 -0
- package/dist/visio/data-graphic-masters.d.ts.map +1 -0
- package/dist/visio/data-graphic-place.d.ts +34 -0
- package/dist/visio/data-graphic-place.d.ts.map +1 -0
- package/dist/visio/edit-commands.d.ts +3 -1
- package/dist/visio/edit-commands.d.ts.map +1 -1
- package/dist/visio/edit-data-graphic-guard.d.ts +13 -0
- package/dist/visio/edit-data-graphic-guard.d.ts.map +1 -0
- package/dist/visio/edit-data-graphic-owner.d.ts +9 -0
- package/dist/visio/edit-data-graphic-owner.d.ts.map +1 -0
- package/dist/visio/edit-data-graphic-refresh.d.ts +14 -0
- package/dist/visio/edit-data-graphic-refresh.d.ts.map +1 -0
- package/dist/visio/edit-data-graphic.d.ts +33 -0
- package/dist/visio/edit-data-graphic.d.ts.map +1 -0
- package/dist/visio/edit-formatting-text-commands.d.ts +8 -0
- package/dist/visio/edit-formatting-text-commands.d.ts.map +1 -1
- package/dist/visio/edit-formatting-text-extra.d.ts +14 -0
- package/dist/visio/edit-formatting-text-extra.d.ts.map +1 -1
- package/dist/visio/edit-formatting-text.d.ts.map +1 -1
- package/dist/visio/edit-formatting.d.ts.map +1 -1
- package/dist/visio/edit-shape-data.d.ts.map +1 -1
- package/dist/visio/edit-swimlane-cff.d.ts +28 -0
- package/dist/visio/edit-swimlane-cff.d.ts.map +1 -0
- package/dist/visio/edit-swimlane-clone.d.ts +8 -4
- package/dist/visio/edit-swimlane-clone.d.ts.map +1 -1
- package/dist/visio/edit-swimlane-layout.d.ts +6 -1
- package/dist/visio/edit-swimlane-layout.d.ts.map +1 -1
- package/dist/visio/edit-swimlane-ops.d.ts.map +1 -1
- package/dist/visio/edit.d.ts.map +1 -1
- package/dist/visio/formula-analyze.d.ts.map +1 -1
- package/dist/visio/formula-evaluate.d.ts.map +1 -1
- package/dist/visio/formula.d.ts.map +1 -1
- package/dist/visio/index.cjs +2980 -1707
- package/dist/visio/index.d.ts +2 -1
- package/dist/visio/index.d.ts.map +1 -1
- package/dist/visio/index.mjs +2971 -1708
- package/dist/visio/master-list.d.ts +3 -3
- package/dist/visio/master-list.d.ts.map +1 -1
- package/dist/visio/model.d.ts +6 -1
- package/dist/visio/model.d.ts.map +1 -1
- package/dist/visio/rotation-presets.d.ts +25 -0
- package/dist/visio/rotation-presets.d.ts.map +1 -0
- package/dist/visio/shape-structure.d.ts.map +1 -1
- package/dist/visio/shapes.d.ts +2 -0
- package/dist/visio/shapes.d.ts.map +1 -1
- package/dist/visio/solid-3d.d.ts +9 -0
- package/dist/visio/solid-3d.d.ts.map +1 -1
- package/dist/visio/style.d.ts.map +1 -1
- package/dist/visio/ui/data-graphic-config.d.ts +4 -19
- package/dist/visio/ui/data-graphic-config.d.ts.map +1 -1
- package/dist/visio/ui/data-graphic-items.d.ts.map +1 -1
- package/dist/visio/ui/data-graphic-native.d.ts +20 -0
- package/dist/visio/ui/data-graphic-native.d.ts.map +1 -0
- package/dist/visio/ui/data-graphics.d.ts.map +1 -1
- package/dist/visio/ui/edit-commands.d.ts.map +1 -1
- package/dist/visio/ui/index.cjs +3130 -1821
- package/dist/visio/ui/index.mjs +3128 -1822
- package/dist/visio/ui/org-chart-belt.d.ts.map +1 -1
- package/dist/visio/ui/scene-validation.d.ts.map +1 -1
- package/dist/visio/ui/snapshot-scene.d.ts.map +1 -1
- package/dist/visio/ui/swimlane.d.ts.map +1 -1
- package/dist/visio/ui/text-dialog.d.ts +12 -0
- package/dist/visio/ui/text-dialog.d.ts.map +1 -1
- package/dist/xlsx/collab/index.cjs +45 -2
- package/dist/xlsx/collab/index.mjs +45 -2
- package/dist/xlsx/collab/part-specs.d.ts.map +1 -1
- package/dist/xlsx/collab/sheets.d.ts +1 -0
- package/dist/xlsx/collab/sheets.d.ts.map +1 -1
- package/dist/xlsx/edit/annotations.d.ts +4 -0
- package/dist/xlsx/edit/annotations.d.ts.map +1 -1
- package/dist/xlsx/edit/clipboard-annotations.d.ts.map +1 -1
- package/dist/xlsx/edit/comment-identities.d.ts +4 -0
- package/dist/xlsx/edit/comment-identities.d.ts.map +1 -0
- package/dist/xlsx/edit/session.d.ts.map +1 -1
- package/dist/xlsx/edit/sheets.d.ts.map +1 -1
- package/dist/xlsx/edit/types.d.ts +3 -0
- package/dist/xlsx/edit/types.d.ts.map +1 -1
- package/dist/xlsx/formula/functions/filterxml.d.ts +2 -0
- package/dist/xlsx/formula/functions/filterxml.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/registry.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +1007 -285
- package/dist/xlsx/index.mjs +988 -285
- package/dist/xlsx/layout/split.d.ts +3 -1
- package/dist/xlsx/layout/split.d.ts.map +1 -1
- package/dist/xlsx/load/index.cjs +809 -126
- package/dist/xlsx/load/index.mjs +790 -126
- package/dist/xlsx/model.d.ts +19 -7
- package/dist/xlsx/model.d.ts.map +1 -1
- package/dist/xlsx/read/comments.d.ts +3 -1
- package/dist/xlsx/read/comments.d.ts.map +1 -1
- package/dist/xlsx/read/conditional.d.ts +2 -2
- package/dist/xlsx/read/conditional.d.ts.map +1 -1
- package/dist/xlsx/read/data-validations.d.ts +7 -0
- package/dist/xlsx/read/data-validations.d.ts.map +1 -0
- package/dist/xlsx/read/sheet-props.d.ts.map +1 -1
- package/dist/xlsx/read/worksheet.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/messages.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/navigation.d.ts.map +1 -1
- package/dist/xlsx/ui/grid/geometry.d.ts +3 -0
- package/dist/xlsx/ui/grid/geometry.d.ts.map +1 -1
- package/dist/xlsx/ui/index.cjs +952 -168
- package/dist/xlsx/ui/index.mjs +933 -169
- package/dist/xlsx/ui/selection.d.ts +3 -0
- package/dist/xlsx/ui/selection.d.ts.map +1 -1
- package/dist/xlsx/validation-extensions.d.ts +6 -0
- package/dist/xlsx/validation-extensions.d.ts.map +1 -0
- package/dist/xlsx/write/comment-ids.d.ts +14 -0
- package/dist/xlsx/write/comment-ids.d.ts.map +1 -0
- package/dist/xlsx/write/comment-mentions.d.ts +6 -0
- package/dist/xlsx/write/comment-mentions.d.ts.map +1 -0
- package/dist/xlsx/write/comment-persons.d.ts +16 -0
- package/dist/xlsx/write/comment-persons.d.ts.map +1 -0
- package/dist/xlsx/write/comments.d.ts +5 -11
- package/dist/xlsx/write/comments.d.ts.map +1 -1
- package/dist/xlsx/write/conditional.d.ts +2 -2
- package/dist/xlsx/write/conditional.d.ts.map +1 -1
- package/dist/xlsx/write/data-validations.d.ts +6 -0
- package/dist/xlsx/write/data-validations.d.ts.map +1 -0
- package/dist/xlsx/write/save.d.ts.map +1 -1
- package/dist/xlsx/write/sheet-parts.d.ts +4 -0
- package/dist/xlsx/write/sheet-parts.d.ts.map +1 -1
- package/dist/xlsx/write/sheet-props.d.ts.map +1 -1
- package/dist/xlsx/write/threaded-comments.d.ts +19 -0
- package/dist/xlsx/write/threaded-comments.d.ts.map +1 -0
- package/dist/xlsx/write/worksheet.d.ts.map +1 -1
- package/dist/xml/index.cjs +31 -1
- package/dist/xml/index.d.ts +1 -0
- package/dist/xml/index.d.ts.map +1 -1
- package/dist/xml/index.mjs +11 -2
- package/dist/xml/xml.d.ts +2 -0
- package/dist/xml/xml.d.ts.map +1 -1
- package/dist/xml/xpath.d.ts +9 -0
- package/dist/xml/xpath.d.ts.map +1 -0
- package/package.json +2 -1
- package/dist/PptxHandler-5UDSMCBG.cjs +0 -14
- package/dist/PptxHandler-TTRTAQAR.mjs +0 -5
package/dist/xlsx/load/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { XMLSerializer, DOMParser } from '@xmldom/xmldom';
|
|
2
|
+
import * as xpath from 'xpath';
|
|
2
3
|
import JSZip2 from 'jszip';
|
|
3
4
|
|
|
4
5
|
// crypto/errors.ts
|
|
@@ -3345,7 +3346,7 @@ function parseXml(xml, options = {}) {
|
|
|
3345
3346
|
try {
|
|
3346
3347
|
parsed = new DOMParser({
|
|
3347
3348
|
onError: (level4, message) => {
|
|
3348
|
-
if (level4 !== "warning") parseError = message;
|
|
3349
|
+
if (level4 !== "warning" || options.warningsAsErrors) parseError = message;
|
|
3349
3350
|
}
|
|
3350
3351
|
}).parseFromString(xml, "application/xml");
|
|
3351
3352
|
} catch (error) {
|
|
@@ -3810,6 +3811,14 @@ function startTag(source3, from, namespaces) {
|
|
|
3810
3811
|
if (i2 < n && !isSpace(after) && after !== 62 && after !== 47) return void 0;
|
|
3811
3812
|
}
|
|
3812
3813
|
}
|
|
3814
|
+
var compiler = xpath;
|
|
3815
|
+
function selectXmlNodes(expression, node2, options = {}) {
|
|
3816
|
+
return compiler.parse(expression).select({
|
|
3817
|
+
node: node2,
|
|
3818
|
+
...options.namespaces ? { namespaces: options.namespaces } : {},
|
|
3819
|
+
allowAnyNamespaceForNoPrefix: options.matchDefaultNamespace ?? false
|
|
3820
|
+
});
|
|
3821
|
+
}
|
|
3813
3822
|
|
|
3814
3823
|
// opc/relationships.ts
|
|
3815
3824
|
function parseRelationships(xml) {
|
|
@@ -9904,31 +9913,90 @@ function parsePersons(xml) {
|
|
|
9904
9913
|
}
|
|
9905
9914
|
return persons;
|
|
9906
9915
|
}
|
|
9907
|
-
function parseThreadedComments(xml, persons) {
|
|
9916
|
+
function parseThreadedComments(xml, persons, personsXml) {
|
|
9908
9917
|
if (!xml) return [];
|
|
9909
9918
|
const root = parseXml(xml, { label: "XLSX threaded comments" }).documentElement;
|
|
9910
9919
|
const roots = /* @__PURE__ */ new Map();
|
|
9920
|
+
const personNames = new Map([...persons].map(([id, name]) => [id.toUpperCase(), name]));
|
|
9911
9921
|
const order = [];
|
|
9912
|
-
|
|
9913
|
-
|
|
9922
|
+
const nodes = children(root, "threadedComment", NS.tc);
|
|
9923
|
+
const byId = new Map(nodes.map((node2) => [(att(node2, "id") ?? "").toUpperCase(), node2]));
|
|
9924
|
+
const parentRoot = (parent) => {
|
|
9925
|
+
const seen = /* @__PURE__ */ new Set();
|
|
9926
|
+
while (parent) {
|
|
9927
|
+
parent = parent.toUpperCase();
|
|
9928
|
+
if (seen.has(parent)) break;
|
|
9929
|
+
if (roots.has(parent)) return roots.get(parent);
|
|
9930
|
+
seen.add(parent);
|
|
9931
|
+
parent = att(byId.get(parent), "parentId");
|
|
9932
|
+
}
|
|
9933
|
+
return void 0;
|
|
9934
|
+
};
|
|
9935
|
+
for (const node2 of [
|
|
9936
|
+
...nodes.filter((n) => !att(n, "parentId")),
|
|
9937
|
+
...nodes.filter((n) => att(n, "parentId"))
|
|
9938
|
+
]) {
|
|
9939
|
+
const parentComment = parentRoot(att(node2, "parentId"));
|
|
9940
|
+
const address2 = parseAddress(att(node2, "ref") ?? "") ?? parentComment?.address;
|
|
9914
9941
|
if (!address2) continue;
|
|
9915
|
-
const author =
|
|
9942
|
+
const author = personNames.get((att(node2, "personId") ?? "").toUpperCase()) ?? "";
|
|
9916
9943
|
const text = xText(children(node2, "text", NS.tc)[0]);
|
|
9917
9944
|
const date = att(node2, "dT");
|
|
9918
|
-
const parent = att(node2, "parentId");
|
|
9919
|
-
const parentComment = parent ? roots.get(parent) : void 0;
|
|
9920
9945
|
if (parentComment) {
|
|
9921
|
-
const reply = { author, text };
|
|
9946
|
+
const reply = { author, text, threadedXml: selfContainedXml(node2) };
|
|
9922
9947
|
if (date) reply.date = date;
|
|
9923
9948
|
(parentComment.replies ??= []).push(reply);
|
|
9924
9949
|
continue;
|
|
9925
9950
|
}
|
|
9926
|
-
const comment = {
|
|
9927
|
-
|
|
9951
|
+
const comment = {
|
|
9952
|
+
address: address2,
|
|
9953
|
+
author,
|
|
9954
|
+
text,
|
|
9955
|
+
replies: [],
|
|
9956
|
+
threadedXml: selfContainedXml(node2)
|
|
9957
|
+
};
|
|
9958
|
+
if (date) comment.date = date;
|
|
9959
|
+
const resolved = boolAttr(node2, "done");
|
|
9960
|
+
if (resolved !== void 0) comment.resolved = resolved;
|
|
9961
|
+
roots.set((att(node2, "id") ?? `${order.length}`).toUpperCase(), comment);
|
|
9928
9962
|
order.push(comment);
|
|
9929
9963
|
}
|
|
9964
|
+
for (const comment of order)
|
|
9965
|
+
comment.replies?.sort((a2, b) => {
|
|
9966
|
+
const aDate = a2.date ? Date.parse(a2.date) : NaN;
|
|
9967
|
+
const bDate = b.date ? Date.parse(b.date) : NaN;
|
|
9968
|
+
return Number.isFinite(aDate) && Number.isFinite(bDate) ? aDate - bDate : 0;
|
|
9969
|
+
});
|
|
9970
|
+
if (personsXml) {
|
|
9971
|
+
const records = /* @__PURE__ */ new Map();
|
|
9972
|
+
for (const person of children(parseXml(personsXml).documentElement, "person", NS.tc)) {
|
|
9973
|
+
const id = att(person, "id") ?? "";
|
|
9974
|
+
records.set(id.toUpperCase(), [id, selfContainedXml(person)]);
|
|
9975
|
+
}
|
|
9976
|
+
for (const comment of order) {
|
|
9977
|
+
const ids = /* @__PURE__ */ new Set();
|
|
9978
|
+
for (const message of [comment, ...comment.replies ?? []]) {
|
|
9979
|
+
const node2 = parseXml(message.threadedXml).documentElement;
|
|
9980
|
+
ids.add((att(node2, "personId") ?? "").toUpperCase());
|
|
9981
|
+
const mentions = first(node2, "mentions", NS.tc);
|
|
9982
|
+
if (mentions)
|
|
9983
|
+
for (const mention of children(mentions, "mention", NS.tc))
|
|
9984
|
+
ids.add((att(mention, "mentionpersonId") ?? "").toUpperCase());
|
|
9985
|
+
}
|
|
9986
|
+
const kept = [...ids].flatMap((id) => records.has(id) ? [records.get(id)] : []);
|
|
9987
|
+
if (kept.length) comment.threadedPersons = Object.fromEntries(kept);
|
|
9988
|
+
}
|
|
9989
|
+
}
|
|
9930
9990
|
return order;
|
|
9931
9991
|
}
|
|
9992
|
+
function threadedCommentEnvelope(xml) {
|
|
9993
|
+
if (!xml) return void 0;
|
|
9994
|
+
const doc = parseXml(xml);
|
|
9995
|
+
for (const node2 of children(doc.documentElement, "threadedComment", NS.tc)) {
|
|
9996
|
+
doc.documentElement.removeChild(node2);
|
|
9997
|
+
}
|
|
9998
|
+
return buildXml(doc);
|
|
9999
|
+
}
|
|
9932
10000
|
function mergeComments(legacy, threaded) {
|
|
9933
10001
|
if (!threaded.length) return legacy;
|
|
9934
10002
|
const key = (c2) => `${c2.address.row}:${c2.address.col}`;
|
|
@@ -12429,7 +12497,7 @@ function readSheetView(sheetViews) {
|
|
|
12429
12497
|
const cols = Math.max(0, Math.round(numAttr(pane, "xSplit") ?? 0));
|
|
12430
12498
|
if (rows || cols) view.freeze = { rows, cols };
|
|
12431
12499
|
}
|
|
12432
|
-
const split2 = pane && state === "split";
|
|
12500
|
+
const split2 = pane && (state === void 0 || state === "split");
|
|
12433
12501
|
if (split2) {
|
|
12434
12502
|
const x = Math.max(0, Math.round(numAttr(pane, "xSplit") ?? 0));
|
|
12435
12503
|
const y = Math.max(0, Math.round(numAttr(pane, "ySplit") ?? 0));
|
|
@@ -12437,9 +12505,8 @@ function readSheetView(sheetViews) {
|
|
|
12437
12505
|
view.split = { x, y };
|
|
12438
12506
|
const first2 = parseAddress(att(node2, "topLeftCell") ?? "");
|
|
12439
12507
|
if (first2) view.split.topLeft = first2;
|
|
12440
|
-
const active = att(pane, "activePane");
|
|
12441
|
-
if (
|
|
12442
|
-
view.split.activePane = active;
|
|
12508
|
+
const active = att(pane, "activePane") ?? "topLeft";
|
|
12509
|
+
if (PANES.has(active)) view.split.activePane = active;
|
|
12443
12510
|
}
|
|
12444
12511
|
}
|
|
12445
12512
|
const topLeft = parseAddress(
|
|
@@ -31721,6 +31788,49 @@ var WORKSHEET_CHILD_ORDER = [
|
|
|
31721
31788
|
"extLst"
|
|
31722
31789
|
];
|
|
31723
31790
|
|
|
31791
|
+
// xlsx/read/data-validations.ts
|
|
31792
|
+
var VALIDATION_XM = "http://schemas.microsoft.com/office/excel/2006/main";
|
|
31793
|
+
var TYPES = /* @__PURE__ */ new Set(["none", "whole", "decimal", "list", "date", "time", "textLength", "custom"]);
|
|
31794
|
+
var ERROR_STYLES = /* @__PURE__ */ new Set(["stop", "warning", "information"]);
|
|
31795
|
+
function readDataValidation(dv) {
|
|
31796
|
+
const extended = dv.namespaceURI === NS.x14;
|
|
31797
|
+
const ns = extended ? NS.x14 : NS.x;
|
|
31798
|
+
const ranges = parseSqref(
|
|
31799
|
+
extended ? first(dv, "sqref", VALIDATION_XM)?.textContent ?? "" : att(dv, "sqref")
|
|
31800
|
+
);
|
|
31801
|
+
if (!ranges.length) return void 0;
|
|
31802
|
+
const type = att(dv, "type") ?? "none";
|
|
31803
|
+
const validation = {
|
|
31804
|
+
ranges,
|
|
31805
|
+
type: TYPES.has(type) ? type : "none"
|
|
31806
|
+
};
|
|
31807
|
+
const operator = att(dv, "operator");
|
|
31808
|
+
if (operator) validation.operator = operator;
|
|
31809
|
+
for (const key of ["formula1", "formula2"]) {
|
|
31810
|
+
const container2 = first(dv, key, ns);
|
|
31811
|
+
const formula2 = extended ? first(container2, "f", VALIDATION_XM) : container2;
|
|
31812
|
+
if (formula2) validation[key] = stripFuturePrefixes(formula2.textContent ?? "");
|
|
31813
|
+
}
|
|
31814
|
+
if (boolAttr(dv, "allowBlank")) validation.allowBlank = true;
|
|
31815
|
+
const hideDropDown = boolAttr(dv, "showDropDown");
|
|
31816
|
+
if (validation.type === "list") validation.showDropDown = !hideDropDown;
|
|
31817
|
+
else if (hideDropDown) validation.showDropDown = false;
|
|
31818
|
+
if (boolAttr(dv, "showErrorMessage")) validation.showErrorMessage = true;
|
|
31819
|
+
if (boolAttr(dv, "showInputMessage")) validation.showInputMessage = true;
|
|
31820
|
+
const errorStyle = att(dv, "errorStyle");
|
|
31821
|
+
if (errorStyle && ERROR_STYLES.has(errorStyle))
|
|
31822
|
+
validation.errorStyle = errorStyle;
|
|
31823
|
+
for (const key of ["errorTitle", "error", "promptTitle", "prompt"]) {
|
|
31824
|
+
const value2 = att(dv, key);
|
|
31825
|
+
if (value2 !== void 0) validation[key] = value2;
|
|
31826
|
+
}
|
|
31827
|
+
if (extended) validation.extensionXml = selfContainedXml(dv);
|
|
31828
|
+
return validation;
|
|
31829
|
+
}
|
|
31830
|
+
function readDataValidations(node2) {
|
|
31831
|
+
return node2 ? children(node2, "dataValidation", NS.x).flatMap((dv) => readDataValidation(dv) ?? []) : [];
|
|
31832
|
+
}
|
|
31833
|
+
|
|
31724
31834
|
// xlsx/read/conditional.ts
|
|
31725
31835
|
var CFVO_TYPES = /* @__PURE__ */ new Set(["min", "max", "num", "percent", "percentile", "formula"]);
|
|
31726
31836
|
function cfvo(node2) {
|
|
@@ -31847,55 +31957,151 @@ function readConditionalFormats(blocks, dxfs, palette, warn) {
|
|
|
31847
31957
|
}
|
|
31848
31958
|
return out;
|
|
31849
31959
|
}
|
|
31850
|
-
|
|
31851
|
-
|
|
31852
|
-
|
|
31853
|
-
|
|
31854
|
-
|
|
31855
|
-
|
|
31856
|
-
|
|
31857
|
-
|
|
31858
|
-
|
|
31859
|
-
|
|
31860
|
-
|
|
31861
|
-
|
|
31862
|
-
|
|
31863
|
-
|
|
31864
|
-
|
|
31865
|
-
|
|
31866
|
-
|
|
31867
|
-
|
|
31868
|
-
|
|
31869
|
-
|
|
31870
|
-
|
|
31871
|
-
|
|
31872
|
-
|
|
31873
|
-
|
|
31874
|
-
|
|
31875
|
-
|
|
31876
|
-
|
|
31877
|
-
|
|
31878
|
-
|
|
31879
|
-
|
|
31880
|
-
|
|
31881
|
-
|
|
31882
|
-
|
|
31883
|
-
|
|
31884
|
-
const
|
|
31885
|
-
|
|
31886
|
-
validation.errorStyle = errorStyle;
|
|
31887
|
-
for (const key of ["errorTitle", "error", "promptTitle", "prompt"]) {
|
|
31888
|
-
const value2 = att(dv, key);
|
|
31889
|
-
if (value2 !== void 0) validation[key] = value2;
|
|
31890
|
-
}
|
|
31891
|
-
out.push(validation);
|
|
31960
|
+
|
|
31961
|
+
// xlsx/write/data-validations.ts
|
|
31962
|
+
function usesValidationExtension(dv) {
|
|
31963
|
+
if (dv.extensionXml) return true;
|
|
31964
|
+
return [dv.formula1, dv.formula2].some((formula2) => {
|
|
31965
|
+
if (!formula2) return false;
|
|
31966
|
+
try {
|
|
31967
|
+
return tokenize(formula2).some((token2) => token2.prefix !== void 0);
|
|
31968
|
+
} catch {
|
|
31969
|
+
return false;
|
|
31970
|
+
}
|
|
31971
|
+
});
|
|
31972
|
+
}
|
|
31973
|
+
function validationAttributes(dv) {
|
|
31974
|
+
return {
|
|
31975
|
+
type: dv.type === "none" ? void 0 : dv.type,
|
|
31976
|
+
errorStyle: dv.errorStyle,
|
|
31977
|
+
operator: dv.operator,
|
|
31978
|
+
allowBlank: dv.allowBlank || void 0,
|
|
31979
|
+
showDropDown: dv.showDropDown === false ? true : void 0,
|
|
31980
|
+
showInputMessage: dv.showInputMessage || void 0,
|
|
31981
|
+
showErrorMessage: dv.showErrorMessage || void 0,
|
|
31982
|
+
errorTitle: dv.errorTitle,
|
|
31983
|
+
error: dv.error,
|
|
31984
|
+
promptTitle: dv.promptTitle,
|
|
31985
|
+
prompt: dv.prompt
|
|
31986
|
+
};
|
|
31987
|
+
}
|
|
31988
|
+
function dataValidationXml(dv, extended) {
|
|
31989
|
+
const sqref2 = dv.ranges.map(formatRange).join(" ");
|
|
31990
|
+
if (!extended) {
|
|
31991
|
+
const formulas = ["formula1", "formula2"].map(
|
|
31992
|
+
(key) => dv[key] === void 0 ? "" : `<${key}>${escapeText2(addFuturePrefixes(dv[key]))}</${key}>`
|
|
31993
|
+
).join("");
|
|
31994
|
+
const values2 = attrs({ ...validationAttributes(dv), sqref: sqref2 });
|
|
31995
|
+
return formulas ? `<dataValidation${values2}>${formulas}</dataValidation>` : `<dataValidation${values2}/>`;
|
|
31892
31996
|
}
|
|
31893
|
-
|
|
31997
|
+
const doc = parseXml(
|
|
31998
|
+
dv.extensionXml || `<x14:dataValidation xmlns:x14="${NS.x14}" xmlns:xm="${VALIDATION_XM}"/>`
|
|
31999
|
+
);
|
|
32000
|
+
const node2 = doc.documentElement;
|
|
32001
|
+
for (const [key, value2] of Object.entries(validationAttributes(dv))) {
|
|
32002
|
+
if (value2 === void 0) node2.removeAttribute(key);
|
|
32003
|
+
else node2.setAttribute(key, typeof value2 === "boolean" ? "1" : value2);
|
|
32004
|
+
}
|
|
32005
|
+
for (const key of ["formula1", "formula2"]) {
|
|
32006
|
+
let container2 = first(node2, key, NS.x14);
|
|
32007
|
+
if (dv[key] === void 0) {
|
|
32008
|
+
if (container2) node2.removeChild(container2);
|
|
32009
|
+
continue;
|
|
32010
|
+
}
|
|
32011
|
+
if (!container2) {
|
|
32012
|
+
container2 = doc.createElementNS(NS.x14, `x14:${key}`);
|
|
32013
|
+
const next = key === "formula1" ? first(node2, "formula2", NS.x14) : void 0;
|
|
32014
|
+
node2.insertBefore(container2, next ?? first(node2, "sqref", VALIDATION_XM) ?? null);
|
|
32015
|
+
}
|
|
32016
|
+
let formula2 = first(container2, "f", VALIDATION_XM);
|
|
32017
|
+
if (!formula2) {
|
|
32018
|
+
formula2 = doc.createElementNS(VALIDATION_XM, "xm:f");
|
|
32019
|
+
container2.appendChild(formula2);
|
|
32020
|
+
}
|
|
32021
|
+
formula2.textContent = addFuturePrefixes(dv[key]);
|
|
32022
|
+
}
|
|
32023
|
+
let ranges = first(node2, "sqref", VALIDATION_XM);
|
|
32024
|
+
if (!ranges) {
|
|
32025
|
+
ranges = doc.createElementNS(VALIDATION_XM, "xm:sqref");
|
|
32026
|
+
node2.appendChild(ranges);
|
|
32027
|
+
}
|
|
32028
|
+
ranges.textContent = sqref2;
|
|
32029
|
+
return buildXml(doc);
|
|
32030
|
+
}
|
|
32031
|
+
function dataValidationsXml(validations) {
|
|
32032
|
+
const items = validations.filter((dv) => dv.ranges.length && !usesValidationExtension(dv)).map((dv) => dataValidationXml(dv, false));
|
|
32033
|
+
return items.length ? `<dataValidations count="${items.length}">${items.join("")}</dataValidations>` : "";
|
|
32034
|
+
}
|
|
32035
|
+
|
|
32036
|
+
// xlsx/validation-extensions.ts
|
|
32037
|
+
var URI = "{CCE6A557-97BC-4b89-ADB6-D9C93CAAB3DF}";
|
|
32038
|
+
function readValidationExtensions(sheet) {
|
|
32039
|
+
const kept = [];
|
|
32040
|
+
for (const xml of sheet.preserved.get("extLst") ?? []) {
|
|
32041
|
+
const doc = parseXml(xml);
|
|
32042
|
+
let changed = false;
|
|
32043
|
+
for (const ext of children(doc.documentElement, "ext", NS.x)) {
|
|
32044
|
+
if (ext.getAttribute("uri")?.toUpperCase() !== URI.toUpperCase()) continue;
|
|
32045
|
+
const collection = first(ext, "dataValidations", NS.x14);
|
|
32046
|
+
if (!collection) continue;
|
|
32047
|
+
for (const node2 of children(collection, "dataValidation", NS.x14)) {
|
|
32048
|
+
const rule = readDataValidation(node2);
|
|
32049
|
+
if (!rule) continue;
|
|
32050
|
+
sheet.dataValidations.push(rule);
|
|
32051
|
+
collection.removeChild(node2);
|
|
32052
|
+
changed = true;
|
|
32053
|
+
}
|
|
32054
|
+
collection.setAttribute(
|
|
32055
|
+
"count",
|
|
32056
|
+
String(children(collection, "dataValidation", NS.x14).length)
|
|
32057
|
+
);
|
|
32058
|
+
}
|
|
32059
|
+
if (!changed) kept.push(xml);
|
|
32060
|
+
else if (elements(doc.documentElement).length) kept.push(buildXml(doc));
|
|
32061
|
+
}
|
|
32062
|
+
if (kept.length) sheet.preserved.set("extLst", kept);
|
|
32063
|
+
else sheet.preserved.delete("extLst");
|
|
32064
|
+
}
|
|
32065
|
+
function validationExtensionsXml(sheet, extensions, ids = /* @__PURE__ */ new Set()) {
|
|
32066
|
+
const rules = sheet.dataValidations.filter(
|
|
32067
|
+
(dv) => dv.ranges.length && usesValidationExtension(dv)
|
|
32068
|
+
);
|
|
32069
|
+
const doc = parseXml(extensions || `<extLst xmlns="${NS.x}"/>`);
|
|
32070
|
+
let ext = elements(doc.documentElement).find(
|
|
32071
|
+
(node2) => node2.getAttribute("uri")?.toUpperCase() === URI.toUpperCase()
|
|
32072
|
+
);
|
|
32073
|
+
if (!rules.length) {
|
|
32074
|
+
const collection2 = first(ext, "dataValidations", NS.x14);
|
|
32075
|
+
if (ext && collection2 && !elements(collection2).length) {
|
|
32076
|
+
ext.removeChild(collection2);
|
|
32077
|
+
if (!elements(ext).length) doc.documentElement.removeChild(ext);
|
|
32078
|
+
}
|
|
32079
|
+
return elements(doc.documentElement).length ? inlineFragment(buildXml(doc)) : "";
|
|
32080
|
+
}
|
|
32081
|
+
if (!ext) {
|
|
32082
|
+
ext = doc.createElementNS(NS.x, "ext");
|
|
32083
|
+
ext.setAttribute("uri", URI);
|
|
32084
|
+
doc.documentElement.appendChild(ext);
|
|
32085
|
+
}
|
|
32086
|
+
let collection = first(ext, "dataValidations", NS.x14);
|
|
32087
|
+
if (!collection) {
|
|
32088
|
+
collection = doc.createElementNS(NS.x14, "x14:dataValidations");
|
|
32089
|
+
ext.appendChild(collection);
|
|
32090
|
+
}
|
|
32091
|
+
for (const rule of rules) {
|
|
32092
|
+
const node2 = doc.importNode(parseXml(dataValidationXml(rule, true)).documentElement, true);
|
|
32093
|
+
const id = node2.getAttributeNS(NS.xr, "uid");
|
|
32094
|
+
if (id && ids.has(id)) node2.removeAttributeNS(NS.xr, "uid");
|
|
32095
|
+
else if (id) ids.add(id);
|
|
32096
|
+
collection.appendChild(node2);
|
|
32097
|
+
}
|
|
32098
|
+
collection.setAttribute("count", String(children(collection, "dataValidation", NS.x14).length));
|
|
32099
|
+
return inlineFragment(buildXml(doc));
|
|
31894
32100
|
}
|
|
31895
32101
|
|
|
31896
32102
|
// xlsx/conditional-extensions.ts
|
|
31897
32103
|
var XM = "http://schemas.microsoft.com/office/excel/2006/main";
|
|
31898
|
-
var
|
|
32104
|
+
var URI2 = "{78C0D931-6437-407d-A8EE-F0AAD7539E65}";
|
|
31899
32105
|
function writeSettings(node2, rule) {
|
|
31900
32106
|
const bar = first(node2, "dataBar", NS.x14);
|
|
31901
32107
|
if (!bar) return;
|
|
@@ -31975,14 +32181,14 @@ function conditionalExtensionsXml(sheet) {
|
|
|
31975
32181
|
for (const xml of preserved.slice(1))
|
|
31976
32182
|
for (const node2 of elements(parseXml(xml).documentElement))
|
|
31977
32183
|
doc.documentElement.appendChild(doc.importNode(node2, true));
|
|
31978
|
-
let ext = elements(doc.documentElement).find((e) => e.getAttribute("uri") ===
|
|
32184
|
+
let ext = elements(doc.documentElement).find((e) => e.getAttribute("uri") === URI2);
|
|
31979
32185
|
let collection = first(ext, "conditionalFormattings", NS.x14);
|
|
31980
32186
|
for (const format of sheet.conditionalFormats)
|
|
31981
32187
|
for (const rule of format.rules) {
|
|
31982
32188
|
if (rule.type !== "dataBar" || !rule.extensionXml || !rule.extensionId) continue;
|
|
31983
32189
|
if (!ext) {
|
|
31984
32190
|
ext = doc.createElementNS(NS.x, "ext");
|
|
31985
|
-
ext.setAttribute("uri",
|
|
32191
|
+
ext.setAttribute("uri", URI2);
|
|
31986
32192
|
doc.documentElement.appendChild(ext);
|
|
31987
32193
|
}
|
|
31988
32194
|
if (!collection) {
|
|
@@ -35192,7 +35398,7 @@ function readSlicerFrame(content2, anchor, sourceXml) {
|
|
|
35192
35398
|
}
|
|
35193
35399
|
|
|
35194
35400
|
// xlsx/read/form-control.ts
|
|
35195
|
-
var
|
|
35401
|
+
var TYPES2 = {
|
|
35196
35402
|
checkbox: "checkbox",
|
|
35197
35403
|
radio: "radio",
|
|
35198
35404
|
drop: "dropdown",
|
|
@@ -35234,7 +35440,7 @@ var num3 = (value2) => {
|
|
|
35234
35440
|
};
|
|
35235
35441
|
function readProps(control, xml) {
|
|
35236
35442
|
const props = parseXml(xml, { label: "XLSX form control" }).documentElement;
|
|
35237
|
-
control.controlType =
|
|
35443
|
+
control.controlType = TYPES2[(att(props, "objectType") ?? "").toLowerCase()] ?? "other";
|
|
35238
35444
|
const link = att(props, "fmlaLink");
|
|
35239
35445
|
if (link) control.linkedCell = link;
|
|
35240
35446
|
const range = att(props, "fmlaRange");
|
|
@@ -36009,12 +36215,21 @@ function readTables(ctx, partName, node2, sheet) {
|
|
|
36009
36215
|
function readComments(ctx, partName, sheet) {
|
|
36010
36216
|
const legacyPart = ctx.source.targetOfType(partName, RELATIONSHIP_TYPES.comments);
|
|
36011
36217
|
const threadedPart = ctx.source.targetOfType(partName, RELATIONSHIP_TYPES.threadedComment);
|
|
36218
|
+
const personsPart = ctx.source.targetOfType(
|
|
36219
|
+
ctx.source.workbookPart() ?? "",
|
|
36220
|
+
RELATIONSHIP_TYPES.person
|
|
36221
|
+
);
|
|
36012
36222
|
const legacy = parseLegacyComments(legacyPart ? ctx.source.text(legacyPart) : void 0);
|
|
36013
36223
|
const threaded = parseThreadedComments(
|
|
36014
36224
|
threadedPart ? ctx.source.text(threadedPart) : void 0,
|
|
36015
|
-
ctx.persons
|
|
36225
|
+
ctx.persons,
|
|
36226
|
+
personsPart ? ctx.source.text(personsPart) : void 0
|
|
36016
36227
|
);
|
|
36017
36228
|
sheet.comments = mergeComments(legacy, threaded);
|
|
36229
|
+
const envelope = threadedCommentEnvelope(
|
|
36230
|
+
threadedPart ? ctx.source.text(threadedPart) : void 0
|
|
36231
|
+
);
|
|
36232
|
+
if (envelope) sheet.threadedCommentsXml = envelope;
|
|
36018
36233
|
}
|
|
36019
36234
|
function parseWorksheet(ctx, partName, name, sheetId) {
|
|
36020
36235
|
const xml = ctx.source.text(partName);
|
|
@@ -36085,6 +36300,7 @@ function readWorksheet(ctx, partName, name, sheetId, xml, rows) {
|
|
|
36085
36300
|
const scenarios = readScenarios(byName.get("scenarios"));
|
|
36086
36301
|
if (scenarios) sheet.scenarios = scenarios;
|
|
36087
36302
|
sheet.dataValidations = readDataValidations(byName.get("dataValidations"));
|
|
36303
|
+
readValidationExtensions(sheet);
|
|
36088
36304
|
readConditionalExtensions(sheet);
|
|
36089
36305
|
sheet.hyperlinks = readHyperlinks(ctx, partName, byName.get("hyperlinks"));
|
|
36090
36306
|
const page = readPageSetup(
|
|
@@ -36244,7 +36460,7 @@ function readProperties(core, app, custom, warn) {
|
|
|
36244
36460
|
};
|
|
36245
36461
|
}
|
|
36246
36462
|
|
|
36247
|
-
// xlsx/write/
|
|
36463
|
+
// xlsx/write/comment-ids.ts
|
|
36248
36464
|
function guidFrom(seed) {
|
|
36249
36465
|
let h1 = 2166136261;
|
|
36250
36466
|
let h2 = 16777619;
|
|
@@ -36260,32 +36476,406 @@ function guidFrom(seed) {
|
|
|
36260
36476
|
const s = hex.join("");
|
|
36261
36477
|
return `{${s.slice(0, 8)}-${s.slice(8, 12)}-4${s.slice(13, 16)}-8${s.slice(17, 20)}-${s.slice(20, 32)}}`;
|
|
36262
36478
|
}
|
|
36263
|
-
var
|
|
36479
|
+
var validGuid = (id) => /^\{[\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12}\}$/i.test(id);
|
|
36480
|
+
var CommentIds = class {
|
|
36481
|
+
reserved = /* @__PURE__ */ new Map();
|
|
36482
|
+
used = /* @__PURE__ */ new Set();
|
|
36483
|
+
mentions = /* @__PURE__ */ new WeakMap();
|
|
36484
|
+
constructor(workbook) {
|
|
36485
|
+
for (const matching2 of [true, false])
|
|
36486
|
+
for (const sheet of workbook?.sheets ?? []) {
|
|
36487
|
+
for (const comment of sheet.comments)
|
|
36488
|
+
for (const message of [comment, ...comment.replies ?? []]) {
|
|
36489
|
+
if (comment.regenerateThreadIds) continue;
|
|
36490
|
+
if (!message.threadedXml) continue;
|
|
36491
|
+
const node2 = parseXml(message.threadedXml).documentElement;
|
|
36492
|
+
if (node2.getAttribute("ref") === formatAddress(comment.address) !== matching2)
|
|
36493
|
+
continue;
|
|
36494
|
+
this.reserve(node2.getAttribute("id") ?? "", message);
|
|
36495
|
+
const mentions = first(node2, "mentions", NS.tc);
|
|
36496
|
+
if (mentions)
|
|
36497
|
+
children(mentions, "mention", NS.tc).forEach((mention, index3) => {
|
|
36498
|
+
this.reserve(
|
|
36499
|
+
mention.getAttribute("mentionId") ?? "",
|
|
36500
|
+
this.mentionOwner(message, index3)
|
|
36501
|
+
);
|
|
36502
|
+
});
|
|
36503
|
+
}
|
|
36504
|
+
}
|
|
36505
|
+
}
|
|
36506
|
+
reserve(id, owner) {
|
|
36507
|
+
const key = id.toUpperCase();
|
|
36508
|
+
if (validGuid(id) && !this.reserved.has(key)) this.reserved.set(key, owner);
|
|
36509
|
+
}
|
|
36510
|
+
mentionOwner(message, index3) {
|
|
36511
|
+
let owners = this.mentions.get(message);
|
|
36512
|
+
if (!owners) this.mentions.set(message, owners = []);
|
|
36513
|
+
return owners[index3] ??= {};
|
|
36514
|
+
}
|
|
36515
|
+
claim(source3, seed, owner, preserve = true) {
|
|
36516
|
+
const key = source3.toUpperCase();
|
|
36517
|
+
if (preserve && validGuid(source3) && !this.used.has(key) && (!this.reserved.has(key) || this.reserved.get(key) === owner)) {
|
|
36518
|
+
this.used.add(key);
|
|
36519
|
+
return source3;
|
|
36520
|
+
}
|
|
36521
|
+
let index3 = 0;
|
|
36522
|
+
let id = guidFrom(seed);
|
|
36523
|
+
while (this.used.has(id) || this.reserved.has(id)) id = guidFrom(`${seed}:${++index3}`);
|
|
36524
|
+
this.used.add(id);
|
|
36525
|
+
return id;
|
|
36526
|
+
}
|
|
36527
|
+
};
|
|
36528
|
+
|
|
36529
|
+
// text/text-diff.ts
|
|
36530
|
+
var isLowSurrogate = (text, at) => {
|
|
36531
|
+
const code = text.charCodeAt(at);
|
|
36532
|
+
return code >= 56320 && code <= 57343;
|
|
36533
|
+
};
|
|
36534
|
+
function shortestEdit(n, m, same8, maxEdits) {
|
|
36535
|
+
const max = Math.min(n + m, maxEdits);
|
|
36536
|
+
const offset2 = max + 1;
|
|
36537
|
+
const v = new Int32Array(2 * max + 3);
|
|
36538
|
+
const trace = [];
|
|
36539
|
+
for (let d = 0; d <= max; d++) {
|
|
36540
|
+
for (let k = -d; k <= d; k += 2) {
|
|
36541
|
+
const down = k === -d || k !== d && v[offset2 + k - 1] < v[offset2 + k + 1];
|
|
36542
|
+
let x = down ? v[offset2 + k + 1] : v[offset2 + k - 1] + 1;
|
|
36543
|
+
let y = x - k;
|
|
36544
|
+
while (x < n && y < m && same8(x, y)) {
|
|
36545
|
+
x++;
|
|
36546
|
+
y++;
|
|
36547
|
+
}
|
|
36548
|
+
v[offset2 + k] = x;
|
|
36549
|
+
if (x >= n && y >= m) return backtrack(trace, n, m, d);
|
|
36550
|
+
}
|
|
36551
|
+
trace.push(v.slice(offset2 - d, offset2 + d + 1));
|
|
36552
|
+
}
|
|
36553
|
+
return void 0;
|
|
36554
|
+
}
|
|
36555
|
+
function backtrack(trace, n, m, d) {
|
|
36556
|
+
const edits = [];
|
|
36557
|
+
let x = n;
|
|
36558
|
+
let y = m;
|
|
36559
|
+
for (let step = d; step > 0; step--) {
|
|
36560
|
+
const previous = trace[step - 1];
|
|
36561
|
+
const at = (k2) => previous[k2 + step - 1];
|
|
36562
|
+
const k = x - y;
|
|
36563
|
+
const down = k === -step || k !== step && at(k - 1) < at(k + 1);
|
|
36564
|
+
const before = down ? k + 1 : k - 1;
|
|
36565
|
+
const startX = at(before);
|
|
36566
|
+
const startY = startX - before;
|
|
36567
|
+
edits.push(down ? [startX, startY, true] : [startX, startY, false]);
|
|
36568
|
+
x = startX;
|
|
36569
|
+
y = startY;
|
|
36570
|
+
}
|
|
36571
|
+
return edits.reverse();
|
|
36572
|
+
}
|
|
36573
|
+
function changesOf(edits) {
|
|
36574
|
+
const changes = [];
|
|
36575
|
+
for (const [x, y, inserts] of edits) {
|
|
36576
|
+
const last = changes.at(-1);
|
|
36577
|
+
if (last && last.fromEnd === x && last.toEnd === y) {
|
|
36578
|
+
if (inserts) last.toEnd++;
|
|
36579
|
+
else last.fromEnd++;
|
|
36580
|
+
} else
|
|
36581
|
+
changes.push({
|
|
36582
|
+
fromStart: x,
|
|
36583
|
+
fromEnd: inserts ? x : x + 1,
|
|
36584
|
+
toStart: y,
|
|
36585
|
+
toEnd: inserts ? y + 1 : y
|
|
36586
|
+
});
|
|
36587
|
+
}
|
|
36588
|
+
return changes;
|
|
36589
|
+
}
|
|
36590
|
+
function characterChanges(a2, b, maxEdits) {
|
|
36591
|
+
const edits = shortestEdit(
|
|
36592
|
+
a2.length,
|
|
36593
|
+
b.length,
|
|
36594
|
+
(x, y) => a2.charCodeAt(x) === b.charCodeAt(y),
|
|
36595
|
+
maxEdits
|
|
36596
|
+
);
|
|
36597
|
+
return edits && changesOf(edits);
|
|
36598
|
+
}
|
|
36599
|
+
var TOKEN = /[\p{L}\p{N}\p{M}]+|\s+|[\s\S]/gu;
|
|
36600
|
+
function tokensOf(text, ids) {
|
|
36601
|
+
const tokens2 = [];
|
|
36602
|
+
const starts = [];
|
|
36603
|
+
for (const match2 of text.matchAll(TOKEN)) {
|
|
36604
|
+
let id = ids.get(match2[0]);
|
|
36605
|
+
if (id === void 0) ids.set(match2[0], id = ids.size);
|
|
36606
|
+
tokens2.push(id);
|
|
36607
|
+
starts.push(match2.index);
|
|
36608
|
+
}
|
|
36609
|
+
starts.push(text.length);
|
|
36610
|
+
return { tokens: tokens2, starts };
|
|
36611
|
+
}
|
|
36612
|
+
function tokenChanges(a2, b, maxEdits) {
|
|
36613
|
+
const ids = /* @__PURE__ */ new Map();
|
|
36614
|
+
const from = tokensOf(a2, ids);
|
|
36615
|
+
const to = tokensOf(b, ids);
|
|
36616
|
+
const edits = shortestEdit(
|
|
36617
|
+
from.tokens.length,
|
|
36618
|
+
to.tokens.length,
|
|
36619
|
+
(x, y) => from.tokens[x] === to.tokens[y],
|
|
36620
|
+
maxEdits
|
|
36621
|
+
);
|
|
36622
|
+
if (!edits) return void 0;
|
|
36623
|
+
let budget = maxEdits;
|
|
36624
|
+
return changesOf(edits).flatMap((stretch) => {
|
|
36625
|
+
const change = {
|
|
36626
|
+
fromStart: from.starts[stretch.fromStart],
|
|
36627
|
+
fromEnd: from.starts[stretch.fromEnd],
|
|
36628
|
+
toStart: to.starts[stretch.toStart],
|
|
36629
|
+
toEnd: to.starts[stretch.toEnd]
|
|
36630
|
+
};
|
|
36631
|
+
const inner = change.fromEnd > change.fromStart && change.toEnd > change.toStart ? characterChanges(
|
|
36632
|
+
a2.slice(change.fromStart, change.fromEnd),
|
|
36633
|
+
b.slice(change.toStart, change.toEnd),
|
|
36634
|
+
budget
|
|
36635
|
+
) : void 0;
|
|
36636
|
+
if (!inner) return [change];
|
|
36637
|
+
for (const found of inner)
|
|
36638
|
+
budget -= found.fromEnd - found.fromStart + found.toEnd - found.toStart;
|
|
36639
|
+
return inner.map((found) => ({
|
|
36640
|
+
fromStart: found.fromStart + change.fromStart,
|
|
36641
|
+
fromEnd: found.fromEnd + change.fromStart,
|
|
36642
|
+
toStart: found.toStart + change.toStart,
|
|
36643
|
+
toEnd: found.toEnd + change.toStart
|
|
36644
|
+
}));
|
|
36645
|
+
});
|
|
36646
|
+
}
|
|
36647
|
+
function diffText(from, to, maxEdits = 500) {
|
|
36648
|
+
let start = 0;
|
|
36649
|
+
while (start < from.length && start < to.length && from.charCodeAt(start) === to.charCodeAt(start))
|
|
36650
|
+
start++;
|
|
36651
|
+
let end = 0;
|
|
36652
|
+
while (end < from.length - start && end < to.length - start && from.charCodeAt(from.length - 1 - end) === to.charCodeAt(to.length - 1 - end))
|
|
36653
|
+
end++;
|
|
36654
|
+
const a2 = from.slice(start, from.length - end);
|
|
36655
|
+
const b = to.slice(start, to.length - end);
|
|
36656
|
+
if (!a2.length && !b.length) return [];
|
|
36657
|
+
const found = a2.length && b.length ? characterChanges(a2, b, maxEdits) ?? tokenChanges(a2, b, maxEdits) : void 0;
|
|
36658
|
+
const changes = found ?? [{ fromStart: 0, fromEnd: a2.length, toStart: 0, toEnd: b.length }];
|
|
36659
|
+
const result2 = [];
|
|
36660
|
+
for (const change of changes) {
|
|
36661
|
+
const placed = {
|
|
36662
|
+
fromStart: change.fromStart + start,
|
|
36663
|
+
fromEnd: change.fromEnd + start,
|
|
36664
|
+
toStart: change.toStart + start,
|
|
36665
|
+
toEnd: change.toEnd + start
|
|
36666
|
+
};
|
|
36667
|
+
if (placed.fromStart > 0 && placed.toStart > 0 && (isLowSurrogate(from, placed.fromStart) || isLowSurrogate(to, placed.toStart))) {
|
|
36668
|
+
placed.fromStart--;
|
|
36669
|
+
placed.toStart--;
|
|
36670
|
+
}
|
|
36671
|
+
if (isLowSurrogate(from, placed.fromEnd) || isLowSurrogate(to, placed.toEnd)) {
|
|
36672
|
+
placed.fromEnd++;
|
|
36673
|
+
placed.toEnd++;
|
|
36674
|
+
}
|
|
36675
|
+
const last = result2.at(-1);
|
|
36676
|
+
if (last && placed.fromStart <= last.fromEnd) {
|
|
36677
|
+
last.fromEnd = Math.max(last.fromEnd, placed.fromEnd);
|
|
36678
|
+
last.toEnd = Math.max(last.toEnd, placed.toEnd);
|
|
36679
|
+
} else result2.push(placed);
|
|
36680
|
+
}
|
|
36681
|
+
return result2;
|
|
36682
|
+
}
|
|
36683
|
+
|
|
36684
|
+
// xlsx/write/comment-mentions.ts
|
|
36685
|
+
function patchCommentMentions(node2, before, message, ids, commentId, preserveIds) {
|
|
36686
|
+
const container2 = first(node2, "mentions", NS.tc);
|
|
36687
|
+
if (!container2) return;
|
|
36688
|
+
const changes = diffText(before, message.text);
|
|
36689
|
+
children(container2, "mention", NS.tc).forEach((mention, index3) => {
|
|
36690
|
+
const start = Number(mention.getAttribute("startIndex"));
|
|
36691
|
+
const length = Number(mention.getAttribute("length"));
|
|
36692
|
+
const end = start + length;
|
|
36693
|
+
let shift3 = 0;
|
|
36694
|
+
let intact = Number.isInteger(start) && start >= 0 && Number.isInteger(length) && length > 0 && end <= before.length;
|
|
36695
|
+
for (const change of changes) {
|
|
36696
|
+
if (change.fromEnd <= start)
|
|
36697
|
+
shift3 += change.toEnd - change.toStart - (change.fromEnd - change.fromStart);
|
|
36698
|
+
else if (change.fromStart < end) intact = false;
|
|
36699
|
+
}
|
|
36700
|
+
if (!intact) {
|
|
36701
|
+
container2.removeChild(mention);
|
|
36702
|
+
return;
|
|
36703
|
+
}
|
|
36704
|
+
mention.setAttribute("startIndex", String(start + shift3));
|
|
36705
|
+
mention.setAttribute(
|
|
36706
|
+
"mentionId",
|
|
36707
|
+
ids.claim(
|
|
36708
|
+
mention.getAttribute("mentionId") ?? "",
|
|
36709
|
+
`${commentId}:mention:${index3}`,
|
|
36710
|
+
ids.mentionOwner(message, index3),
|
|
36711
|
+
preserveIds
|
|
36712
|
+
)
|
|
36713
|
+
);
|
|
36714
|
+
});
|
|
36715
|
+
if (!children(container2, "mention", NS.tc).length) node2.removeChild(container2);
|
|
36716
|
+
}
|
|
36717
|
+
|
|
36718
|
+
// xlsx/write/threaded-comments.ts
|
|
36719
|
+
var ThreadedCommentsWriter = class {
|
|
36720
|
+
constructor(persons, options = {}) {
|
|
36721
|
+
this.persons = persons;
|
|
36722
|
+
this.doc = parseXml(
|
|
36723
|
+
options.envelope ?? `${XML_HEADER}<ThreadedComments xmlns="${NS.tc}" xmlns:x="${NS.x}"/>`
|
|
36724
|
+
);
|
|
36725
|
+
for (const node2 of children(this.doc.documentElement, "threadedComment", NS.tc))
|
|
36726
|
+
this.doc.documentElement.removeChild(node2);
|
|
36727
|
+
this.ids = options.ids ?? new CommentIds();
|
|
36728
|
+
}
|
|
36729
|
+
persons;
|
|
36730
|
+
doc;
|
|
36731
|
+
ids;
|
|
36732
|
+
count = 0;
|
|
36733
|
+
add(comment, ref, sheetName) {
|
|
36734
|
+
this.persons.retain(comment.threadedPersons);
|
|
36735
|
+
const preserve = !comment.regenerateThreadIds;
|
|
36736
|
+
const prepare2 = (message, seed) => {
|
|
36737
|
+
const source3 = parseXml(message.threadedXml ?? `<threadedComment xmlns="${NS.tc}"/>`);
|
|
36738
|
+
const priorId = source3.documentElement.getAttribute("id") ?? "";
|
|
36739
|
+
const id = this.ids.claim(priorId, seed, message, preserve);
|
|
36740
|
+
return { message, source: source3, priorId, id };
|
|
36741
|
+
};
|
|
36742
|
+
const root = prepare2(comment, `${sheetName}!${ref}:${comment.text}`);
|
|
36743
|
+
const replies = (comment.replies ?? []).map(
|
|
36744
|
+
(reply, index3) => prepare2(reply, `${root.id}:reply:${index3}:${reply.text}`)
|
|
36745
|
+
);
|
|
36746
|
+
const identities = new Map(
|
|
36747
|
+
[root, ...replies].filter((item2) => item2.priorId).map((item2) => [item2.priorId.toUpperCase(), item2.id])
|
|
36748
|
+
);
|
|
36749
|
+
this.message(comment, ref, root.source, root.id, preserve, void 0, comment.resolved);
|
|
36750
|
+
for (const reply of replies)
|
|
36751
|
+
this.message(
|
|
36752
|
+
reply.message,
|
|
36753
|
+
ref,
|
|
36754
|
+
reply.source,
|
|
36755
|
+
reply.id,
|
|
36756
|
+
preserve,
|
|
36757
|
+
identities.get(
|
|
36758
|
+
(reply.source.documentElement.getAttribute("parentId") ?? "").toUpperCase()
|
|
36759
|
+
) ?? root.id
|
|
36760
|
+
);
|
|
36761
|
+
return root.id;
|
|
36762
|
+
}
|
|
36763
|
+
message(message, ref, source3, id, preserve, parent, resolved) {
|
|
36764
|
+
const node2 = source3.documentElement;
|
|
36765
|
+
const personId = this.persons.id(message.author, node2.getAttribute("personId") ?? void 0);
|
|
36766
|
+
for (const [key, value2] of Object.entries({
|
|
36767
|
+
id,
|
|
36768
|
+
ref,
|
|
36769
|
+
personId,
|
|
36770
|
+
dT: message.date,
|
|
36771
|
+
parentId: parent
|
|
36772
|
+
})) {
|
|
36773
|
+
if (value2 === void 0) node2.removeAttribute(key);
|
|
36774
|
+
else node2.setAttribute(key, value2);
|
|
36775
|
+
}
|
|
36776
|
+
if (!parent) {
|
|
36777
|
+
if (resolved === void 0) node2.removeAttribute("done");
|
|
36778
|
+
else node2.setAttribute("done", resolved ? "1" : "0");
|
|
36779
|
+
}
|
|
36780
|
+
let text = first(node2, "text", NS.tc);
|
|
36781
|
+
patchCommentMentions(node2, text?.textContent ?? "", message, this.ids, id, preserve);
|
|
36782
|
+
if (!text) {
|
|
36783
|
+
text = source3.createElementNS(NS.tc, node2.prefix ? `${node2.prefix}:text` : "text");
|
|
36784
|
+
node2.insertBefore(text, node2.firstChild);
|
|
36785
|
+
}
|
|
36786
|
+
text.textContent = message.text;
|
|
36787
|
+
const root = this.doc.documentElement;
|
|
36788
|
+
root.insertBefore(this.doc.importNode(node2, true), first(root, "extLst", NS.tc) ?? null);
|
|
36789
|
+
this.count++;
|
|
36790
|
+
}
|
|
36791
|
+
xml() {
|
|
36792
|
+
return this.count ? buildXml(this.doc) : void 0;
|
|
36793
|
+
}
|
|
36794
|
+
};
|
|
36795
|
+
|
|
36796
|
+
// xlsx/write/comment-persons.ts
|
|
36264
36797
|
var PersonRegistry = class {
|
|
36798
|
+
constructor(existing, source3) {
|
|
36799
|
+
this.source = source3;
|
|
36800
|
+
for (const [id, name] of existing ?? []) {
|
|
36801
|
+
this.names.set(id, name);
|
|
36802
|
+
this.identities.set(id.toUpperCase(), id);
|
|
36803
|
+
if (!this.byName.has(name)) this.byName.set(name, id);
|
|
36804
|
+
}
|
|
36805
|
+
}
|
|
36806
|
+
source;
|
|
36265
36807
|
names = /* @__PURE__ */ new Map();
|
|
36266
36808
|
byName = /* @__PURE__ */ new Map();
|
|
36267
|
-
|
|
36268
|
-
|
|
36809
|
+
identities = /* @__PURE__ */ new Map();
|
|
36810
|
+
added = /* @__PURE__ */ new Map();
|
|
36811
|
+
retained = /* @__PURE__ */ new Map();
|
|
36812
|
+
get changed() {
|
|
36813
|
+
return this.added.size > 0;
|
|
36814
|
+
}
|
|
36815
|
+
/** Bring referenced account records along with a thread copied from another workbook. */
|
|
36816
|
+
retain(records) {
|
|
36817
|
+
for (const [sourceId, xml] of Object.entries(records ?? {})) {
|
|
36818
|
+
const known = this.identities.get(sourceId.toUpperCase());
|
|
36819
|
+
if (known && (this.source || this.retained.has(known))) continue;
|
|
36820
|
+
const node2 = parseXml(xml).documentElement;
|
|
36821
|
+
if (node2.localName !== "person" || node2.namespaceURI !== NS.tc || node2.getAttribute("id")?.toUpperCase() !== sourceId.toUpperCase())
|
|
36822
|
+
continue;
|
|
36823
|
+
const name = node2.getAttribute("displayName") ?? "";
|
|
36824
|
+
const id = known ?? node2.getAttribute("id");
|
|
36825
|
+
this.retained.set(id, xml);
|
|
36269
36826
|
this.names.set(id, name);
|
|
36827
|
+
this.identities.set(id.toUpperCase(), id);
|
|
36828
|
+
this.added.set(id, name);
|
|
36270
36829
|
if (!this.byName.has(name)) this.byName.set(name, id);
|
|
36271
36830
|
}
|
|
36272
36831
|
}
|
|
36273
|
-
id(name) {
|
|
36832
|
+
id(name, preferred) {
|
|
36833
|
+
const preferredId = preferred ? this.identities.get(preferred.toUpperCase()) : void 0;
|
|
36834
|
+
if (preferredId && this.names.get(preferredId) === name) return preferredId;
|
|
36274
36835
|
let id = this.byName.get(name);
|
|
36275
36836
|
if (!id) {
|
|
36837
|
+
let index3 = 0;
|
|
36276
36838
|
id = guidFrom(`person:${name}`);
|
|
36839
|
+
while (this.identities.has(id.toUpperCase())) id = guidFrom(`person:${name}:${++index3}`);
|
|
36277
36840
|
this.byName.set(name, id);
|
|
36278
36841
|
this.names.set(id, name);
|
|
36842
|
+
this.identities.set(id.toUpperCase(), id);
|
|
36843
|
+
this.added.set(id, name);
|
|
36279
36844
|
}
|
|
36280
36845
|
return id;
|
|
36281
36846
|
}
|
|
36282
36847
|
xml() {
|
|
36283
|
-
|
|
36284
|
-
|
|
36285
|
-
|
|
36286
|
-
|
|
36848
|
+
if (this.source && !this.changed) return this.source;
|
|
36849
|
+
const doc = parseXml(
|
|
36850
|
+
this.source ?? `${XML_HEADER}<personList xmlns="${NS.tc}" xmlns:x="${NS.x}"/>`
|
|
36851
|
+
);
|
|
36852
|
+
const root = doc.documentElement;
|
|
36853
|
+
for (const [id, name] of this.source ? this.added : this.names) {
|
|
36854
|
+
const retained = this.retained.get(id);
|
|
36855
|
+
if (retained) {
|
|
36856
|
+
root.insertBefore(
|
|
36857
|
+
doc.importNode(parseXml(retained).documentElement, true),
|
|
36858
|
+
first(root, "extLst", NS.tc) ?? null
|
|
36859
|
+
);
|
|
36860
|
+
continue;
|
|
36861
|
+
}
|
|
36862
|
+
const person = doc.createElementNS(NS.tc, root.prefix ? `${root.prefix}:person` : "person");
|
|
36863
|
+
for (const [key, value2] of Object.entries({
|
|
36864
|
+
id,
|
|
36865
|
+
displayName: name,
|
|
36866
|
+
userId: name,
|
|
36867
|
+
providerId: "None"
|
|
36868
|
+
})) {
|
|
36869
|
+
person.setAttribute(key, value2);
|
|
36870
|
+
}
|
|
36871
|
+
root.insertBefore(person, first(root, "extLst", NS.tc) ?? null);
|
|
36872
|
+
}
|
|
36873
|
+
return buildXml(doc);
|
|
36287
36874
|
}
|
|
36288
36875
|
};
|
|
36876
|
+
|
|
36877
|
+
// xlsx/write/comments.ts
|
|
36878
|
+
var THREADED_NOTE = "[Threaded comment]\n\nYour version of Excel allows you to read this threaded comment; however, any edits to it will get removed if the file is opened in a newer version of Excel. Learn more: https://go.microsoft.com/fwlink/?linkid=870924\n\nComment:\n ";
|
|
36289
36879
|
function vmlShape(comment, index3, id) {
|
|
36290
36880
|
const { row: row2, col } = comment.address;
|
|
36291
36881
|
const anchor = `${col + 1}, 15, ${Math.max(0, row2 - 1)}, 10, ${col + 3}, 15, ${row2 + 3}, 4`;
|
|
@@ -36307,7 +36897,7 @@ function vmlXml(comments, layout3) {
|
|
|
36307
36897
|
}
|
|
36308
36898
|
return `<xml xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel"><o:shapelayout v:ext="edit"><o:idmap v:ext="edit" data="${data}"/></o:shapelayout>` + NOTE_SHAPETYPE + shapes + "</xml>";
|
|
36309
36899
|
}
|
|
36310
|
-
function commentParts(comments, sheetNumber, persons, sheetName, layout3) {
|
|
36900
|
+
function commentParts(comments, sheetNumber, persons, sheetName, layout3, threadOptions) {
|
|
36311
36901
|
const authors = [];
|
|
36312
36902
|
const authorId = (name) => {
|
|
36313
36903
|
let id = authors.indexOf(name);
|
|
@@ -36317,18 +36907,11 @@ function commentParts(comments, sheetNumber, persons, sheetName, layout3) {
|
|
|
36317
36907
|
const sorted2 = [...comments].sort(
|
|
36318
36908
|
(a2, b) => a2.address.row - b.address.row || a2.address.col - b.address.col
|
|
36319
36909
|
);
|
|
36320
|
-
|
|
36910
|
+
const threads = new ThreadedCommentsWriter(persons, threadOptions);
|
|
36321
36911
|
const list2 = sorted2.map((comment) => {
|
|
36322
36912
|
const ref = formatAddress(comment.address);
|
|
36323
36913
|
if (comment.replies) {
|
|
36324
|
-
const id =
|
|
36325
|
-
const personId = persons.id(comment.author);
|
|
36326
|
-
threaded += `<threadedComment ref="${ref}" personId="${personId}" id="${id}"><text>${escapeText2(comment.text)}</text></threadedComment>`;
|
|
36327
|
-
comment.replies.forEach((reply, index3) => {
|
|
36328
|
-
const replyId = guidFrom(`${id}:reply:${index3}:${reply.text}`);
|
|
36329
|
-
const dT = reply.date ? ` dT="${escapeAttr3(reply.date)}"` : "";
|
|
36330
|
-
threaded += `<threadedComment ref="${ref}"${dT} personId="${persons.id(reply.author)}" id="${replyId}" parentId="${id}"><text>${escapeText2(reply.text)}</text></threadedComment>`;
|
|
36331
|
-
});
|
|
36914
|
+
const id = threads.add(comment, ref, sheetName);
|
|
36332
36915
|
const fallback = `${THREADED_NOTE}${comment.text}${comment.replies.map((r) => `
|
|
36333
36916
|
Reply:
|
|
36334
36917
|
${r.text}`).join("")}`;
|
|
@@ -36346,8 +36929,8 @@ Reply:
|
|
|
36346
36929
|
}
|
|
36347
36930
|
);
|
|
36348
36931
|
const parts = { comments: commentsXml, vml };
|
|
36349
|
-
|
|
36350
|
-
|
|
36932
|
+
const threaded = threads.xml();
|
|
36933
|
+
if (threaded) parts.threaded = threaded;
|
|
36351
36934
|
return parts;
|
|
36352
36935
|
}
|
|
36353
36936
|
|
|
@@ -48001,6 +48584,83 @@ var TEXT_EXTRA_FUNCTIONS = [
|
|
|
48001
48584
|
)
|
|
48002
48585
|
];
|
|
48003
48586
|
|
|
48587
|
+
// xlsx/formula/functions/filterxml.ts
|
|
48588
|
+
var XML = "http://www.w3.org/XML/1998/namespace";
|
|
48589
|
+
var XMLNS2 = "http://www.w3.org/2000/xmlns/";
|
|
48590
|
+
function preservesSpace(node2) {
|
|
48591
|
+
for (let current = node2; current; current = current.parentNode) {
|
|
48592
|
+
if (current.nodeType !== 1) continue;
|
|
48593
|
+
const value2 = current.getAttributeNS(XML, "space");
|
|
48594
|
+
if (value2) return value2 === "preserve";
|
|
48595
|
+
}
|
|
48596
|
+
return false;
|
|
48597
|
+
}
|
|
48598
|
+
function prepare(root) {
|
|
48599
|
+
const namespaces = /* @__PURE__ */ Object.create(null);
|
|
48600
|
+
const visit = (element3) => {
|
|
48601
|
+
for (const attr3 of Array.from(element3.attributes)) {
|
|
48602
|
+
if (attr3.namespaceURI !== XMLNS2 || attr3.localName === "xmlns") continue;
|
|
48603
|
+
const prior = namespaces[attr3.localName];
|
|
48604
|
+
if (prior !== void 0 && prior !== attr3.value) throw new Error("Conflicting namespaces");
|
|
48605
|
+
namespaces[attr3.localName] = attr3.value;
|
|
48606
|
+
}
|
|
48607
|
+
for (const child6 of Array.from(element3.childNodes)) {
|
|
48608
|
+
if (child6.nodeType === 1) visit(child6);
|
|
48609
|
+
else if (child6.nodeType === 3 && !child6.nodeValue?.trim() && !preservesSpace(element3))
|
|
48610
|
+
element3.removeChild(child6);
|
|
48611
|
+
}
|
|
48612
|
+
};
|
|
48613
|
+
visit(root);
|
|
48614
|
+
return namespaces;
|
|
48615
|
+
}
|
|
48616
|
+
function nodeValue(node2) {
|
|
48617
|
+
let text;
|
|
48618
|
+
if (node2.nodeType === 2) text = (node2.nodeValue ?? "").trim();
|
|
48619
|
+
else if (node2.nodeType === 1) {
|
|
48620
|
+
const preserve = preservesSpace(node2);
|
|
48621
|
+
text = Array.from(node2.childNodes).filter((child6) => child6.nodeType === 3 || child6.nodeType === 4).map((child6) => {
|
|
48622
|
+
const value2 = child6.nodeValue ?? "";
|
|
48623
|
+
return preserve || child6.nodeType === 4 ? value2 : value2.trim();
|
|
48624
|
+
}).join("");
|
|
48625
|
+
} else return ERR.VALUE;
|
|
48626
|
+
if (!text) return ERR.VALUE;
|
|
48627
|
+
if (/^(true|false)$/i.test(text)) return text.toLowerCase() === "true";
|
|
48628
|
+
const date = /^(\d{1,4})[-/](\d{1,2})[-/](\d{1,4})(.*)$/.exec(text.trim());
|
|
48629
|
+
let numberText = text;
|
|
48630
|
+
if (date) {
|
|
48631
|
+
let year = Number(date[1]);
|
|
48632
|
+
if (year < 100) year += year < 30 ? 2e3 : 1900;
|
|
48633
|
+
numberText = `${year}-${date[2]}-${date[3]}${date[4]?.replace(/^T/, " ") ?? ""}`;
|
|
48634
|
+
}
|
|
48635
|
+
return parseNumberText(numberText) ?? text;
|
|
48636
|
+
}
|
|
48637
|
+
var FILTERXML = spec(
|
|
48638
|
+
"FILTERXML",
|
|
48639
|
+
"Web",
|
|
48640
|
+
"FILTERXML(xml, xpath)",
|
|
48641
|
+
"Returns XML element or attribute values selected by XPath, as a column.",
|
|
48642
|
+
2,
|
|
48643
|
+
2,
|
|
48644
|
+
(args) => {
|
|
48645
|
+
const xml = str(args[0]);
|
|
48646
|
+
const expression = str(args[1]);
|
|
48647
|
+
if (xml.length > 32767 || expression.length > 32767) return ERR.VALUE;
|
|
48648
|
+
let nodes;
|
|
48649
|
+
try {
|
|
48650
|
+
const doc = parseXml(xml, { warningsAsErrors: true, label: "FILTERXML" });
|
|
48651
|
+
nodes = selectXmlNodes(expression, doc, {
|
|
48652
|
+
namespaces: prepare(doc.documentElement),
|
|
48653
|
+
matchDefaultNamespace: true
|
|
48654
|
+
});
|
|
48655
|
+
} catch {
|
|
48656
|
+
return ERR.VALUE;
|
|
48657
|
+
}
|
|
48658
|
+
if (!nodes.length) return ERR.VALUE;
|
|
48659
|
+
chargeArrayCells(nodes.length);
|
|
48660
|
+
return new Matrix(nodes.map((node2) => [nodeValue(node2)]));
|
|
48661
|
+
}
|
|
48662
|
+
);
|
|
48663
|
+
|
|
48004
48664
|
// xlsx/formula/functions/registry.ts
|
|
48005
48665
|
var ALL = [
|
|
48006
48666
|
...MATH_FUNCTIONS,
|
|
@@ -48010,6 +48670,7 @@ var ALL = [
|
|
|
48010
48670
|
...LOGICAL_FUNCTIONS,
|
|
48011
48671
|
...TEXT_FUNCTIONS,
|
|
48012
48672
|
...TEXT_EXTRA_FUNCTIONS,
|
|
48673
|
+
FILTERXML,
|
|
48013
48674
|
BAHTTEXT,
|
|
48014
48675
|
GETPIVOTDATA,
|
|
48015
48676
|
...GROUPBY_FUNCTIONS,
|
|
@@ -49016,6 +49677,12 @@ function pageXml(sheet) {
|
|
|
49016
49677
|
return result2;
|
|
49017
49678
|
}
|
|
49018
49679
|
|
|
49680
|
+
// xlsx/layout/split.ts
|
|
49681
|
+
function splitActivePane(split2) {
|
|
49682
|
+
const valid = split2.x > 0 && split2.y > 0 ? ["topLeft", "topRight", "bottomLeft", "bottomRight"] : split2.y > 0 ? ["topLeft", "bottomLeft"] : ["topLeft", "topRight"];
|
|
49683
|
+
return split2.activePane && valid.includes(split2.activePane) ? split2.activePane : valid[valid.length - 1];
|
|
49684
|
+
}
|
|
49685
|
+
|
|
49019
49686
|
// xlsx/write/filter-columns.ts
|
|
49020
49687
|
function criteriaOf(column2) {
|
|
49021
49688
|
const { values: values2, blank, dateGroups, custom, top10, dynamic, color, icon, hiddenButton } = column2;
|
|
@@ -49177,16 +49844,14 @@ function dimensionXml(sheet) {
|
|
|
49177
49844
|
const used = usedRange(sheet);
|
|
49178
49845
|
return `<dimension ref="${used ? formatRange(used) : "A1"}"/>`;
|
|
49179
49846
|
}
|
|
49180
|
-
function splitActivePane(split2) {
|
|
49181
|
-
const both = split2.x > 0 && split2.y > 0;
|
|
49182
|
-
const valid = both ? ["topLeft", "topRight", "bottomLeft", "bottomRight"] : split2.y > 0 ? ["topLeft", "bottomLeft"] : ["topLeft", "topRight"];
|
|
49183
|
-
if (split2.activePane && valid.includes(split2.activePane)) return split2.activePane;
|
|
49184
|
-
return both ? "bottomRight" : split2.y > 0 ? "bottomLeft" : "topRight";
|
|
49185
|
-
}
|
|
49186
49847
|
function selectionXml(selection, pane) {
|
|
49848
|
+
const activeCellId = selection.ranges.findIndex(
|
|
49849
|
+
(range) => rangeContains(range, selection.active)
|
|
49850
|
+
);
|
|
49187
49851
|
return el("selection", {
|
|
49188
49852
|
pane,
|
|
49189
49853
|
activeCell: formatAddress(selection.active),
|
|
49854
|
+
activeCellId: activeCellId > 0 ? activeCellId : void 0,
|
|
49190
49855
|
sqref: sqref(selection.ranges) || formatAddress(selection.active)
|
|
49191
49856
|
});
|
|
49192
49857
|
}
|
|
@@ -49772,28 +50437,6 @@ function conditionalFormatsXml(formats, styles) {
|
|
|
49772
50437
|
return `<conditionalFormatting sqref="${format.ranges.map((r) => formatRange(r)).join(" ")}">${rules}</conditionalFormatting>`;
|
|
49773
50438
|
}).join("");
|
|
49774
50439
|
}
|
|
49775
|
-
function dataValidationsXml(validations) {
|
|
49776
|
-
const items = validations.filter((dv) => dv.ranges.length).map((dv) => {
|
|
49777
|
-
const hideDropDown = dv.showDropDown === false ? true : void 0;
|
|
49778
|
-
const values2 = attrs({
|
|
49779
|
-
type: dv.type === "none" ? void 0 : dv.type,
|
|
49780
|
-
errorStyle: dv.errorStyle,
|
|
49781
|
-
operator: dv.operator,
|
|
49782
|
-
allowBlank: dv.allowBlank || void 0,
|
|
49783
|
-
showDropDown: hideDropDown,
|
|
49784
|
-
showInputMessage: dv.showInputMessage || void 0,
|
|
49785
|
-
showErrorMessage: dv.showErrorMessage || void 0,
|
|
49786
|
-
errorTitle: dv.errorTitle,
|
|
49787
|
-
error: dv.error,
|
|
49788
|
-
promptTitle: dv.promptTitle,
|
|
49789
|
-
prompt: dv.prompt,
|
|
49790
|
-
sqref: dv.ranges.map((r) => formatRange(r)).join(" ")
|
|
49791
|
-
});
|
|
49792
|
-
const formulas = (dv.formula1 !== void 0 ? formulaXml2(dv.formula1, "formula1") : "") + (dv.formula2 !== void 0 ? formulaXml2(dv.formula2, "formula2") : "");
|
|
49793
|
-
return formulas ? `<dataValidation${values2}>${formulas}</dataValidation>` : `<dataValidation${values2}/>`;
|
|
49794
|
-
});
|
|
49795
|
-
return items.length ? `<dataValidations count="${items.length}">${items.join("")}</dataValidations>` : "";
|
|
49796
|
-
}
|
|
49797
50440
|
|
|
49798
50441
|
// xlsx/write/sheet-data.ts
|
|
49799
50442
|
var MAX_CELL_TEXT = 32767;
|
|
@@ -50646,6 +51289,8 @@ function writeComments(ctx, sheet, index3, partName, rels) {
|
|
|
50646
51289
|
const { writer, source: source3 } = ctx;
|
|
50647
51290
|
const name = (pattern) => writer.uniqueName(pattern, ctx.reserved);
|
|
50648
51291
|
const fromSource = source3 && sheet.partName && source3.has(sheet.partName);
|
|
51292
|
+
const sourceThreaded = fromSource ? source3.targetOfType(sheet.partName ?? "", RELATIONSHIP_TYPES.threadedComment) : void 0;
|
|
51293
|
+
const threadEnvelope = sheet.threadedCommentsXml ?? threadedCommentEnvelope(sourceThreaded ? source3?.text(sourceThreaded) : void 0);
|
|
50649
51294
|
const sourceVml = fromSource ? sourceVmlPart(source3, sheet.partName ?? "") : void 0;
|
|
50650
51295
|
const kept = source3 && sourceVml && !writer.has(sourceVml) ? stripNoteShapes(source3.text(sourceVml) ?? "") : void 0;
|
|
50651
51296
|
const base = kept && kept.kept > 0 ? kept.xml : void 0;
|
|
@@ -50670,11 +51315,13 @@ function writeComments(ctx, sheet, index3, partName, rels) {
|
|
|
50670
51315
|
parseLegacyComments(legacyPart ? source3.text(legacyPart) : void 0),
|
|
50671
51316
|
parseThreadedComments(
|
|
50672
51317
|
threadedPart ? source3.text(threadedPart) : void 0,
|
|
50673
|
-
parsePersons(personsPart ? source3.text(personsPart) : void 0)
|
|
51318
|
+
parsePersons(personsPart ? source3.text(personsPart) : void 0),
|
|
51319
|
+
personsPart ? source3.text(personsPart) : void 0
|
|
50674
51320
|
)
|
|
50675
51321
|
);
|
|
50676
51322
|
const free = [legacyPart, threadedPart, vmlPart].every((p) => !p || !writer.has(p));
|
|
50677
|
-
|
|
51323
|
+
const envelope = threadedCommentEnvelope(threadedPart ? source3.text(threadedPart) : void 0);
|
|
51324
|
+
if (legacyPart && vmlPart && free && sameModel(before, sheet.comments) && (sheet.threadedCommentsXml === void 0 || sheet.threadedCommentsXml === envelope)) {
|
|
50678
51325
|
writer.carry(legacyPart);
|
|
50679
51326
|
writer.carry(vmlPart);
|
|
50680
51327
|
rels.add(RELATIONSHIP_TYPES.comments, relativeTarget(partName, legacyPart));
|
|
@@ -50688,10 +51335,20 @@ function writeComments(ctx, sheet, index3, partName, rels) {
|
|
|
50688
51335
|
}
|
|
50689
51336
|
const own = base ? vmlIdmapBlocks(base) : [];
|
|
50690
51337
|
const layout3 = vmlAllocatorFor(ctx, source3).allocate(sheet.comments.length, index3 + 1, own);
|
|
50691
|
-
const parts = commentParts(
|
|
50692
|
-
|
|
50693
|
-
|
|
50694
|
-
|
|
51338
|
+
const parts = commentParts(
|
|
51339
|
+
sheet.comments,
|
|
51340
|
+
index3 + 1,
|
|
51341
|
+
ctx.persons,
|
|
51342
|
+
sheet.name,
|
|
51343
|
+
{
|
|
51344
|
+
...layout3,
|
|
51345
|
+
...base ? { base } : {}
|
|
51346
|
+
},
|
|
51347
|
+
{
|
|
51348
|
+
...threadEnvelope ? { envelope: threadEnvelope } : {},
|
|
51349
|
+
ids: ctx.commentIds ??= new CommentIds(ctx.workbook)
|
|
51350
|
+
}
|
|
51351
|
+
);
|
|
50695
51352
|
const commentsPart = name((n) => `xl/comments${n}.xml`);
|
|
50696
51353
|
writer.add(commentsPart, parts.comments, CONTENT_TYPES.comments);
|
|
50697
51354
|
rels.add(RELATIONSHIP_TYPES.comments, relativeTarget(partName, commentsPart));
|
|
@@ -50882,13 +51539,17 @@ function writeWorksheet(ctx, sheet, index3, partName) {
|
|
|
50882
51539
|
blocks.set("legacyDrawing", writeComments(ctx, sheet, index3, partName, rels));
|
|
50883
51540
|
blocks.set("tableParts", tableParts);
|
|
50884
51541
|
ctx.pivots?.writeSheet(writer, sheet, partName, rels);
|
|
50885
|
-
const extensions =
|
|
51542
|
+
const extensions = validationExtensionsXml(
|
|
51543
|
+
sheet,
|
|
51544
|
+
conditionalExtensionsXml(sheet),
|
|
51545
|
+
ctx.validationIds ??= /* @__PURE__ */ new Set()
|
|
51546
|
+
);
|
|
50886
51547
|
blocks.set(
|
|
50887
51548
|
"extLst",
|
|
50888
51549
|
ctx.slicers?.active ? ctx.slicers.writeSheet(sheet, partName, rels, extensions) : extensions
|
|
50889
51550
|
);
|
|
50890
51551
|
for (const [key, list2] of sheet.preserved) {
|
|
50891
|
-
if (key.startsWith("source:") || !WORKSHEET_CHILD_ORDER.includes(key) || (blocks.get(key) ?? "") !== "" || key === "extLst"
|
|
51552
|
+
if (key.startsWith("source:") || !WORKSHEET_CHILD_ORDER.includes(key) || (blocks.get(key) ?? "") !== "" || key === "extLst")
|
|
50892
51553
|
continue;
|
|
50893
51554
|
const valid = list2.filter(
|
|
50894
51555
|
(xml) => [...xml.matchAll(/\br:(?:id|embed|link|pict)="([^"]*)"/g)].every(
|
|
@@ -51164,7 +51825,7 @@ function dateFilterXml(pivot, filter2) {
|
|
|
51164
51825
|
}
|
|
51165
51826
|
|
|
51166
51827
|
// xlsx/pivot/write.ts
|
|
51167
|
-
var
|
|
51828
|
+
var TYPES3 = {
|
|
51168
51829
|
table: "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml",
|
|
51169
51830
|
definition: "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml",
|
|
51170
51831
|
records: "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml"
|
|
@@ -51230,14 +51891,14 @@ var PivotWritePlan = class {
|
|
|
51230
51891
|
`${NS.r}/pivotCacheRecords`,
|
|
51231
51892
|
relativeTarget(definition, records)
|
|
51232
51893
|
);
|
|
51233
|
-
writer.add(records, pivotCacheRecordsXml(pivot, cache2),
|
|
51894
|
+
writer.add(records, pivotCacheRecordsXml(pivot, cache2), TYPES3.records);
|
|
51234
51895
|
writer.add(
|
|
51235
51896
|
definition,
|
|
51236
51897
|
pivotCacheDefinitionXml(pivot, workbook, cache2, recordRel),
|
|
51237
|
-
|
|
51898
|
+
TYPES3.definition
|
|
51238
51899
|
);
|
|
51239
51900
|
writer.rels(definition, cacheRels);
|
|
51240
|
-
writer.add(table2, pivotTableXml(pivot, cacheId, cache2),
|
|
51901
|
+
writer.add(table2, pivotTableXml(pivot, cacheId, cache2), TYPES3.table);
|
|
51241
51902
|
const tableRels = new RelationshipSet();
|
|
51242
51903
|
tableRels.add(RELATIONSHIP_TYPES.pivotCacheDefinition, relativeTarget(table2, definition));
|
|
51243
51904
|
writer.rels(table2, tableRels);
|
|
@@ -51689,7 +52350,8 @@ async function saveXlsx(workbook) {
|
|
|
51689
52350
|
styles: new StyleWriter(workbook, stylesPart ? source3?.text(stylesPart) : void 0),
|
|
51690
52351
|
strings: new SharedStringTable(),
|
|
51691
52352
|
persons: new PersonRegistry(
|
|
51692
|
-
parsePersons(personsSource ? source3?.text(personsSource) : void 0)
|
|
52353
|
+
parsePersons(personsSource ? source3?.text(personsSource) : void 0),
|
|
52354
|
+
personsSource ? source3?.text(personsSource) : void 0
|
|
51693
52355
|
),
|
|
51694
52356
|
reserved,
|
|
51695
52357
|
tableIds: /* @__PURE__ */ new Set(),
|
|
@@ -51764,7 +52426,9 @@ async function saveXlsx(workbook) {
|
|
|
51764
52426
|
rels.add(RELATIONSHIP_TYPES.theme, relativeTarget(bookPart, outTheme));
|
|
51765
52427
|
if (ctx.threaded.used) {
|
|
51766
52428
|
const personsPart = personsSource ?? "xl/persons/person.xml";
|
|
51767
|
-
|
|
52429
|
+
if (personsSource) writer.carry(personsSource);
|
|
52430
|
+
if (!personsSource || ctx.persons.changed)
|
|
52431
|
+
writer.add(personsPart, ctx.persons.xml(), CONTENT_TYPES.persons);
|
|
51768
52432
|
rels.add(RELATIONSHIP_TYPES.person, relativeTarget(bookPart, personsPart));
|
|
51769
52433
|
}
|
|
51770
52434
|
writeMetadataPart(
|