ooxml-core 1.16.1 → 1.17.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.
Files changed (76) hide show
  1. package/dist/{PptxHandler-ZF4G56V3.mjs → PptxHandler-K7GMS2ST.mjs} +2 -2
  2. package/dist/PptxHandler-L3JPWOBN.mjs +4 -0
  3. package/dist/{PptxHandler-MK665E6Z.cjs → PptxHandler-U6EFO73T.cjs} +3 -3
  4. package/dist/{PresentationBuilder-JGYSF25G.cjs → PresentationBuilder-LUR6LGHU.cjs} +5 -5
  5. package/dist/{PresentationBuilder-J7HAJGMB.mjs → PresentationBuilder-OK526SZ4.mjs} +2 -2
  6. package/dist/{PresentationBuilder-HPHJTMIB.mjs → PresentationBuilder-XC3F3OPY.mjs} +2 -2
  7. package/dist/automation/index.cjs +13 -7
  8. package/dist/automation/index.mjs +13 -7
  9. package/dist/chart/index.cjs +1 -1
  10. package/dist/chart/index.mjs +1 -1
  11. package/dist/{chunk-MVS2PT2Q.mjs → chunk-A7S2NYAU.mjs} +1 -1
  12. package/dist/{chunk-5ROLXCIY.mjs → chunk-HLZIALC5.mjs} +2 -2
  13. package/dist/{chunk-IBFHMYJD.mjs → chunk-IM5LFEA2.mjs} +1 -1
  14. package/dist/{chunk-YQ7HJOEZ.mjs → chunk-KU3SMBFU.mjs} +1 -1
  15. package/dist/{chunk-K7Z2EDI5.cjs → chunk-NYTR4UZ5.cjs} +1 -1
  16. package/dist/{chunk-HMZFUT65.mjs → chunk-UFGJNXRG.mjs} +1 -1
  17. package/dist/{chunk-THEWZNWS.cjs → chunk-UWWS6VVJ.cjs} +1007 -1007
  18. package/dist/{chunk-TWXBU7RE.mjs → chunk-XTSHZGSM.mjs} +1 -1
  19. package/dist/{chunk-ZBCNC5RI.mjs → chunk-YS43OMM3.mjs} +4 -4
  20. package/dist/crypto/index.cjs +1 -1
  21. package/dist/crypto/index.mjs +1 -1
  22. package/dist/diagram/index.cjs +1 -1
  23. package/dist/diagram/index.mjs +1 -1
  24. package/dist/docx/embedded.cjs +1 -1
  25. package/dist/docx/embedded.mjs +1 -1
  26. package/dist/docx/index.cjs +1 -1
  27. package/dist/docx/index.mjs +1 -1
  28. package/dist/docx/layout/index.cjs +1 -1
  29. package/dist/docx/layout/index.mjs +1 -1
  30. package/dist/docx/load/index.cjs +1 -1
  31. package/dist/docx/load/index.mjs +1 -1
  32. package/dist/docx/ui/index.cjs +1 -1
  33. package/dist/docx/ui/index.mjs +1 -1
  34. package/dist/drawingml/index.cjs +1 -1
  35. package/dist/drawingml/index.mjs +1 -1
  36. package/dist/index.cjs +1 -1
  37. package/dist/index.mjs +1 -1
  38. package/dist/math/index.cjs +1 -1
  39. package/dist/math/index.mjs +1 -1
  40. package/dist/opc/index.cjs +1 -1
  41. package/dist/opc/index.mjs +1 -1
  42. package/dist/pptx/automation/index.cjs +1 -1
  43. package/dist/pptx/automation/index.mjs +5 -5
  44. package/dist/pptx/cli/index.cjs +1 -1
  45. package/dist/pptx/cli/index.mjs +4 -4
  46. package/dist/pptx/converter/index.mjs +2 -2
  47. package/dist/pptx/editor/render/find-replace.cjs +14 -14
  48. package/dist/pptx/editor/render/find-replace.mjs +1 -1
  49. package/dist/pptx/editor/render/slide-operations.cjs +8 -8
  50. package/dist/pptx/editor/render/slide-operations.mjs +2 -2
  51. package/dist/pptx/index.cjs +1 -1
  52. package/dist/pptx/index.mjs +5 -5
  53. package/dist/teams/index.cjs +10 -4
  54. package/dist/teams/index.mjs +10 -4
  55. package/dist/visio/index.cjs +1 -1
  56. package/dist/visio/index.mjs +1 -1
  57. package/dist/visio/ui/document-history.d.ts +6 -1
  58. package/dist/visio/ui/document-history.d.ts.map +1 -1
  59. package/dist/visio/ui/index.cjs +27 -3
  60. package/dist/visio/ui/index.mjs +27 -4
  61. package/dist/xlsx/edit/context.d.ts.map +1 -1
  62. package/dist/xlsx/index.cjs +13 -7
  63. package/dist/xlsx/index.mjs +13 -7
  64. package/dist/xlsx/load/index.cjs +10 -4
  65. package/dist/xlsx/load/index.mjs +10 -4
  66. package/dist/xlsx/ui/dialogs/grid-chart.d.ts +25 -0
  67. package/dist/xlsx/ui/dialogs/grid-chart.d.ts.map +1 -0
  68. package/dist/xlsx/ui/index.cjs +4689 -1056
  69. package/dist/xlsx/ui/index.d.ts +1 -0
  70. package/dist/xlsx/ui/index.d.ts.map +1 -1
  71. package/dist/xlsx/ui/index.mjs +4682 -1056
  72. package/dist/xml/index.cjs +1 -1
  73. package/dist/xml/index.mjs +1 -1
  74. package/dist/xml/xml.d.ts.map +1 -1
  75. package/package.json +1 -1
  76. package/dist/PptxHandler-7RNEJ2IO.mjs +0 -4
@@ -359,7 +359,7 @@ var init_xml = __esm({
359
359
  maxDepth: 512,
360
360
  maxNodes: 5e6
361
361
  };
362
- TAG_RE = /<(\/?)([^\s\/>]+)(?:\s+[^\s=\/>]+\s*=\s*(?:"[^"]*"|'[^']*'))*\s*(\/?)>/y;
362
+ TAG_RE = /<(\/?)([^\s\/><]+)(?:\s+[^\s=\/><]+\s*=\s*(?:"[^"<]*"|'[^'<]*'))*\s*(\/?)>/y;
363
363
  MARKUP_SKIPS = [
364
364
  ["<!--", "-->"],
365
365
  ["<![CDATA[", "]]>"],
@@ -23019,11 +23019,17 @@ function pivotTableXml(source2, cacheId, cache3) {
23019
23019
  }
23020
23020
  return XML_HEADER + buildXml(root);
23021
23021
  }
23022
+ function firstFilterTag(xml) {
23023
+ for (let at = xml.indexOf("<filter"); at !== -1; at = xml.indexOf("<filter", at + 1)) {
23024
+ if (!/\s/.test(xml.charAt(at + 7))) continue;
23025
+ const end = xml.indexOf(">", at);
23026
+ return end === -1 ? "" : xml.slice(at, end + 1);
23027
+ }
23028
+ return "";
23029
+ }
23022
23030
  function dateFilterXml(pivot, filter2) {
23023
23031
  const x15 = "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main";
23024
- const id = Number(
23025
- /\bid="(\d+)"/.exec(/<filter\s[^>]*>/.exec(pivot.sourceXml ?? "")?.[0] ?? "")?.[1] ?? 1
23026
- );
23032
+ const id = Number(/\bid="(\d+)"/.exec(firstFilterTag(pivot.sourceXml ?? ""))?.[1] ?? 1);
23027
23033
  return `<filters count="1"><filter${attrs({ fld: pivot.fields.indexOf(filter2.field), type: "dateBetween", evalOrder: -1, id, name: filter2.field })}><autoFilter ref="A1"><filterColumn colId="0"><customFilters and="1"><customFilter operator="greaterThanOrEqual" val="${Math.floor(filter2.start)}"/><customFilter operator="lessThanOrEqual" val="${Math.floor(filter2.end)}"/></customFilters></filterColumn></autoFilter><extLst><ext uri="{0605FD5F-26C8-4aeb-8148-2DB25E43C511}" xmlns:x15="${x15}"><x15:pivotFilter useWholeDay="1"/></ext></extLst></filter></filters>`;
23028
23034
  }
23029
23035
  var X14;
@@ -332,7 +332,7 @@ var init_xml = __esm({
332
332
  maxDepth: 512,
333
333
  maxNodes: 5e6
334
334
  };
335
- TAG_RE = /<(\/?)([^\s\/>]+)(?:\s+[^\s=\/>]+\s*=\s*(?:"[^"]*"|'[^']*'))*\s*(\/?)>/y;
335
+ TAG_RE = /<(\/?)([^\s\/><]+)(?:\s+[^\s=\/><]+\s*=\s*(?:"[^"<]*"|'[^'<]*'))*\s*(\/?)>/y;
336
336
  MARKUP_SKIPS = [
337
337
  ["<!--", "-->"],
338
338
  ["<![CDATA[", "]]>"],
@@ -22992,11 +22992,17 @@ function pivotTableXml(source2, cacheId, cache3) {
22992
22992
  }
22993
22993
  return XML_HEADER + buildXml(root);
22994
22994
  }
22995
+ function firstFilterTag(xml) {
22996
+ for (let at = xml.indexOf("<filter"); at !== -1; at = xml.indexOf("<filter", at + 1)) {
22997
+ if (!/\s/.test(xml.charAt(at + 7))) continue;
22998
+ const end = xml.indexOf(">", at);
22999
+ return end === -1 ? "" : xml.slice(at, end + 1);
23000
+ }
23001
+ return "";
23002
+ }
22995
23003
  function dateFilterXml(pivot, filter2) {
22996
23004
  const x15 = "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main";
22997
- const id = Number(
22998
- /\bid="(\d+)"/.exec(/<filter\s[^>]*>/.exec(pivot.sourceXml ?? "")?.[0] ?? "")?.[1] ?? 1
22999
- );
23005
+ const id = Number(/\bid="(\d+)"/.exec(firstFilterTag(pivot.sourceXml ?? ""))?.[1] ?? 1);
23000
23006
  return `<filters count="1"><filter${attrs({ fld: pivot.fields.indexOf(filter2.field), type: "dateBetween", evalOrder: -1, id, name: filter2.field })}><autoFilter ref="A1"><filterColumn colId="0"><customFilters and="1"><customFilter operator="greaterThanOrEqual" val="${Math.floor(filter2.start)}"/><customFilter operator="lessThanOrEqual" val="${Math.floor(filter2.end)}"/></customFilters></filterColumn></autoFilter><extLst><ext uri="{0605FD5F-26C8-4aeb-8148-2DB25E43C511}" xmlns:x15="${x15}"><x15:pivotFilter useWholeDay="1"/></ext></extLst></filter></filters>`;
23001
23007
  }
23002
23008
  var X14;
@@ -80,7 +80,7 @@ var DEFAULT_XML_LIMITS = {
80
80
  maxDepth: 512,
81
81
  maxNodes: 5e6
82
82
  };
83
- var TAG_RE = /<(\/?)([^\s\/>]+)(?:\s+[^\s=\/>]+\s*=\s*(?:"[^"]*"|'[^']*'))*\s*(\/?)>/y;
83
+ var TAG_RE = /<(\/?)([^\s\/><]+)(?:\s+[^\s=\/><]+\s*=\s*(?:"[^"<]*"|'[^'<]*'))*\s*(\/?)>/y;
84
84
  var MARKUP_SKIPS = [
85
85
  ["<!--", "-->"],
86
86
  ["<![CDATA[", "]]>"],
@@ -74,7 +74,7 @@ var DEFAULT_XML_LIMITS = {
74
74
  maxDepth: 512,
75
75
  maxNodes: 5e6
76
76
  };
77
- var TAG_RE = /<(\/?)([^\s\/>]+)(?:\s+[^\s=\/>]+\s*=\s*(?:"[^"]*"|'[^']*'))*\s*(\/?)>/y;
77
+ var TAG_RE = /<(\/?)([^\s\/><]+)(?:\s+[^\s=\/><]+\s*=\s*(?:"[^"<]*"|'[^'<]*'))*\s*(\/?)>/y;
78
78
  var MARKUP_SKIPS = [
79
79
  ["<!--", "-->"],
80
80
  ["<![CDATA[", "]]>"],
@@ -23,6 +23,8 @@ export declare const EDIT_HISTORY_LIMITS: Readonly<{
23
23
  maxBytes: number;
24
24
  maxEntries: 20;
25
25
  }>;
26
+ /** A requested undo depth as a snapshot count: whole, at least 2 (one undo), at most the cap. */
27
+ export declare const clampHistoryEntries: (entries: number) => number;
26
28
  export interface SourceSnapshot {
27
29
  readonly bytes: Uint8Array;
28
30
  readonly diagnostics: readonly EditDiagnostic[];
@@ -31,12 +33,15 @@ export interface SourceSnapshot {
31
33
  export declare class DocumentHistory {
32
34
  #private;
33
35
  readonly original: SourceSnapshot;
34
- constructor(bytes: Uint8Array);
36
+ constructor(bytes: Uint8Array, maxEntries?: number);
35
37
  get current(): SourceSnapshot;
36
38
  get undoTarget(): SourceSnapshot | undefined;
37
39
  get redoTarget(): SourceSnapshot | undefined;
38
40
  get state(): ViewerEditState;
39
41
  append(bytes: Uint8Array, diagnostics: readonly EditDiagnostic[]): void;
42
+ /** Keep at most `entries` snapshots (the original plus its edits), dropping the oldest first. */
43
+ set maxEntries(entries: number);
44
+ get maxEntries(): number;
40
45
  move(target: SourceSnapshot): void;
41
46
  export(): VsdxExportResult;
42
47
  }
@@ -1 +1 @@
1
- {"version":3,"file":"document-history.d.ts","sourceRoot":"","sources":["../../../visio/ui/document-history.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CACzB;AACD,MAAM,WAAW,gBAAgB;IAChC,KAAK,EAAE,UAAU,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,EAAE,SAAS,cAAc,EAAE,CAAC;CACvC;AACD,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ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,MAAM,EAU7B;IACD,IAAI,UAAU,IAAI,MAAM,CAEvB;IAeD,IAAI,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAKjC;IACD,MAAM,IAAI,gBAAgB,CAMzB;CACD"}
@@ -170,12 +170,18 @@ var EMPTY_EDIT_STATE = Object.freeze({
170
170
  diagnostics: Object.freeze([])
171
171
  });
172
172
  var EDIT_HISTORY_LIMITS = Object.freeze({ maxBytes: 96 * 1024 * 1024, maxEntries: 20 });
173
+ var clampHistoryEntries = (entries) => Math.min(
174
+ EDIT_HISTORY_LIMITS.maxEntries,
175
+ Math.max(2, Number.isFinite(entries) ? Math.round(entries) : EDIT_HISTORY_LIMITS.maxEntries)
176
+ );
173
177
  var DocumentHistory = class {
174
178
  original;
175
179
  #entries;
176
180
  #index = 0;
177
181
  #truncated = false;
178
- constructor(bytes) {
182
+ #maxEntries = EDIT_HISTORY_LIMITS.maxEntries;
183
+ constructor(bytes, maxEntries) {
184
+ if (maxEntries !== void 0) this.#maxEntries = clampHistoryEntries(maxEntries);
179
185
  this.original = { bytes: Uint8Array.from(bytes), diagnostics: Object.freeze([]) };
180
186
  this.#entries = [this.original];
181
187
  }
@@ -209,8 +215,25 @@ var DocumentHistory = class {
209
215
  this.#entries = this.#entries.slice(0, this.#index + 1);
210
216
  this.#entries.push(snapshot);
211
217
  this.#index++;
218
+ this.#trim();
219
+ }
220
+ /** Keep at most `entries` snapshots (the original plus its edits), dropping the oldest first. */
221
+ set maxEntries(entries) {
222
+ this.#maxEntries = clampHistoryEntries(entries);
223
+ while (this.#entries.length > this.#maxEntries) {
224
+ if (this.#index > 0) {
225
+ this.#entries.shift();
226
+ this.#index--;
227
+ this.#truncated = true;
228
+ } else this.#entries.pop();
229
+ }
230
+ }
231
+ get maxEntries() {
232
+ return this.#maxEntries;
233
+ }
234
+ #trim() {
212
235
  const retained = () => /* @__PURE__ */ new Set([this.original, ...this.#entries]);
213
- while (this.#entries.length > EDIT_HISTORY_LIMITS.maxEntries || [...retained()].reduce((sum, entry) => sum + entry.bytes.byteLength, 0) > EDIT_HISTORY_LIMITS.maxBytes) {
236
+ while (this.#entries.length > this.#maxEntries || [...retained()].reduce((sum, entry) => sum + entry.bytes.byteLength, 0) > EDIT_HISTORY_LIMITS.maxBytes) {
214
237
  if (this.#index === 0) throw new Error("Source snapshots exceed the retained history limit.");
215
238
  this.#entries.shift();
216
239
  this.#index--;
@@ -1366,7 +1389,7 @@ var DEFAULT_XML_LIMITS = {
1366
1389
  maxDepth: 512,
1367
1390
  maxNodes: 5e6
1368
1391
  };
1369
- var TAG_RE = /<(\/?)([^\s\/>]+)(?:\s+[^\s=\/>]+\s*=\s*(?:"[^"]*"|'[^']*'))*\s*(\/?)>/y;
1392
+ var TAG_RE = /<(\/?)([^\s\/><]+)(?:\s+[^\s=\/><]+\s*=\s*(?:"[^"<]*"|'[^'<]*'))*\s*(\/?)>/y;
1370
1393
  var MARKUP_SKIPS = [
1371
1394
  ["<!--", "-->"],
1372
1395
  ["<![CDATA[", "]]>"],
@@ -34269,6 +34292,7 @@ exports.VisioTextDraftError = VisioTextDraftError;
34269
34292
  exports.assertShapeDetails = assertShapeDetails;
34270
34293
  exports.assertViewableDocument = assertViewableDocument;
34271
34294
  exports.checkVisioDiagram = checkVisioDiagram;
34295
+ exports.clampHistoryEntries = clampHistoryEntries;
34272
34296
  exports.compatibilityNotes = compatibilityNotes;
34273
34297
  exports.compatibilityText = compatibilityText;
34274
34298
  exports.composeVisioTransform = composeAffine;
@@ -164,12 +164,18 @@ var EMPTY_EDIT_STATE = Object.freeze({
164
164
  diagnostics: Object.freeze([])
165
165
  });
166
166
  var EDIT_HISTORY_LIMITS = Object.freeze({ maxBytes: 96 * 1024 * 1024, maxEntries: 20 });
167
+ var clampHistoryEntries = (entries) => Math.min(
168
+ EDIT_HISTORY_LIMITS.maxEntries,
169
+ Math.max(2, Number.isFinite(entries) ? Math.round(entries) : EDIT_HISTORY_LIMITS.maxEntries)
170
+ );
167
171
  var DocumentHistory = class {
168
172
  original;
169
173
  #entries;
170
174
  #index = 0;
171
175
  #truncated = false;
172
- constructor(bytes) {
176
+ #maxEntries = EDIT_HISTORY_LIMITS.maxEntries;
177
+ constructor(bytes, maxEntries) {
178
+ if (maxEntries !== void 0) this.#maxEntries = clampHistoryEntries(maxEntries);
173
179
  this.original = { bytes: Uint8Array.from(bytes), diagnostics: Object.freeze([]) };
174
180
  this.#entries = [this.original];
175
181
  }
@@ -203,8 +209,25 @@ var DocumentHistory = class {
203
209
  this.#entries = this.#entries.slice(0, this.#index + 1);
204
210
  this.#entries.push(snapshot);
205
211
  this.#index++;
212
+ this.#trim();
213
+ }
214
+ /** Keep at most `entries` snapshots (the original plus its edits), dropping the oldest first. */
215
+ set maxEntries(entries) {
216
+ this.#maxEntries = clampHistoryEntries(entries);
217
+ while (this.#entries.length > this.#maxEntries) {
218
+ if (this.#index > 0) {
219
+ this.#entries.shift();
220
+ this.#index--;
221
+ this.#truncated = true;
222
+ } else this.#entries.pop();
223
+ }
224
+ }
225
+ get maxEntries() {
226
+ return this.#maxEntries;
227
+ }
228
+ #trim() {
206
229
  const retained = () => /* @__PURE__ */ new Set([this.original, ...this.#entries]);
207
- while (this.#entries.length > EDIT_HISTORY_LIMITS.maxEntries || [...retained()].reduce((sum, entry) => sum + entry.bytes.byteLength, 0) > EDIT_HISTORY_LIMITS.maxBytes) {
230
+ while (this.#entries.length > this.#maxEntries || [...retained()].reduce((sum, entry) => sum + entry.bytes.byteLength, 0) > EDIT_HISTORY_LIMITS.maxBytes) {
208
231
  if (this.#index === 0) throw new Error("Source snapshots exceed the retained history limit.");
209
232
  this.#entries.shift();
210
233
  this.#index--;
@@ -1360,7 +1383,7 @@ var DEFAULT_XML_LIMITS = {
1360
1383
  maxDepth: 512,
1361
1384
  maxNodes: 5e6
1362
1385
  };
1363
- var TAG_RE = /<(\/?)([^\s\/>]+)(?:\s+[^\s=\/>]+\s*=\s*(?:"[^"]*"|'[^']*'))*\s*(\/?)>/y;
1386
+ var TAG_RE = /<(\/?)([^\s\/><]+)(?:\s+[^\s=\/><]+\s*=\s*(?:"[^"<]*"|'[^'<]*'))*\s*(\/?)>/y;
1364
1387
  var MARKUP_SKIPS = [
1365
1388
  ["<!--", "-->"],
1366
1389
  ["<![CDATA[", "]]>"],
@@ -34222,4 +34245,4 @@ async function createSampleVsdx() {
34222
34245
  return (await editVsdx(pages.bytes, PAGES.flatMap(shapeEdits))).bytes;
34223
34246
  }
34224
34247
 
34225
- export { DocumentHistory, EDIT_HISTORY_LIMITS, EMPTY_EDIT_STATE, EMPTY_SELECTION, EMPTY_TEXT_SEARCH, FOREIGN_VECTOR_SCENE_LIMITS, ForeignVectorBudget, MAX_INPUT_BYTES, TEXT_SEARCH_LIMITS, VISIO_AUTO_CONNECT_DIRECTIONS, VISIO_AUTO_CONNECT_GAP, VISIO_AUTO_CONNECT_REACH, VISIO_BULLET_STYLES, VISIO_DATA_GRAPHIC_FILL_ROW, VISIO_DATA_GRAPHIC_ICONS, VISIO_DATA_GRAPHIC_ROW, VISIO_DIAGRAM_RULE_SETS, VISIO_FIELD_CATEGORIES, VISIO_FORMAT_PAINTER_LIMITS, VISIO_GRID_DENSITY_CHOICES, IDENTITY_AFFINE as VISIO_IDENTITY_TRANSFORM, VISIO_LAYOUT_LABELS, VISIO_LAYOUT_STYLES, VISIO_PAGE_SIZE_PRESETS, VISIO_PAPER_SIZES, VISIO_PASTE_TEXT_LIMIT, VISIO_PATH_CLOSE_DISTANCE, VISIO_PATH_TOLERANCE, VISIO_PICTURE_DPI, VISIO_RESIZE_HANDLES, VISIO_RULER_DENSITY_CHOICES, VISIO_SELECT_TYPES, VISIO_SELECT_TYPE_LABELS, VISIO_SUBPROCESS_SHAPE, VISIO_TEXT_BLOCK_HANDLES, VISIO_TEXT_LANGUAGES, VISIO_TEXT_REPLACE_LIMITS, VisioTextDraftError, assertShapeDetails, assertViewableDocument, checkVisioDiagram, compatibilityNotes, compatibilityText, composeAffine as composeVisioTransform, copySnapshotScene, createSampleVsdx, demoDocument, editErrorMessage, eventKeys, excelSerialToIso, hasVisibleShapeContent, indexDocumentText, inspectForeignVectorResource, isEditCancellation, isVisioPathTool, normalizeVisioHyperlinkAddress, propertyKeys, sameSelection, searchDocumentText, selectionKey, snapshotEdits, snapshotSelection, textSearchStatus, validateSearchQuery, visioAddConnectionPointCommand, visioArrangeCommands, visioAutoAlignCommands, visioAutoConnectArrows, visioAutoConnectNeighbor, visioAutoConnectPlacement, visioAutoConnectPlan, visioAutoConnectShape, visioAutoConnectSidePoint, visioBoxCreationCommand, visioCalloutCommand, visioChangeCaseCommand, visioChangeCaseShape, visioChangeMasterCommand, visioChangeMasterTargets, visioChangeShapeCommand, visioChangeShapeRefusal, visioClipboardShape, visioColorRules, visioConnectableShape, visioConnectorCreationCommand, visioConnectorEdges, visioConnectorEndHandles, visioConnectorMovePreviews, visioConnectorPreviewPath, visioConnectorRouteOf, visioContainerCommand, visioCopyableShape, visioDataGraphicEdits, visioDataGraphicFields, visioDataGraphicMarker, visioDataGraphicParts, visioDataTable, visioDrawBounds, visioDrawIsLargeEnough, visioDrawPlan, visioDrawingPoint, visioDuplicateCommand, visioFileMasterDropCommand, visioFillPatternTransform, visioFitToDrawingEdits, visioFollowTarget, visioFontFamilies, visioFormatPainterEdits, visioFormatPainterSnapshot, visioFormatTargetShape, visioFormattingShape, visioGlowKey, visioGlueableShape, visioGradientInstances, visioGridSteps, visioGroupCommand, visioGuideCreateCommand, visioGuideMoveCommand, visioKeepAutoSize, visioLayerAssignCommand, visioLayerAssignCommands, visioLayerAssignState, visioLegendEdits, visioLineCreationCommand, visioLineDashLengths, visioLocalFormattingShape, visioLocalRotationShape, visioMarqueeBox, visioMarqueeSelection, visioMasterDropCommand, visioMasterDropRefusal, visioMasterDropSize, visioMasterPreviewBox, visioMatchingPaperSize, visioMovableGroup, visioMoveCommands, visioMovePreviewTransform, visioMoveTargets, visioMovementShape, visioNearestConnectionPoint, visioNewLayerNames, visioNewPageId, visioNextShapeId, visioNudgeCommands, visioOrderingShape, visioOrientationEdits, visioPageBreaks, visioPageConnectionPoints, visioPageDecorationState, visioPageDragDelta, visioPageEditToDrawing, visioPageGuides, visioPageInsertCommand, visioPageMasters, visioPageOrientationCommand, visioPageSizeCommand, visioPageSizePresetCommand, visioPageSizePresetEdits, visioPageSizeState, visioPaperSize, visioParseRange, visioPasteCommand, visioPasteTextCommand, visioPasteTextValue, visioPathDrawPlan, visioPathPreview, visioPictureInsertCommand, visioPrintTile, visioQuarterTurnCommand, visioReLayoutCommands, visioReflectionKey, visioRemoveDataGraphicEdits, visioRenderedGradientStopCount, visioRenderedGradientStops, visioResizeDrag, visioResizeFrame, visioResizeShape, visioRotationPreviewTransform, visioRotationShape, visioRulerDensityFactor, visioRulerGridEdits, visioRulerGridValues, visioSceneToLocal, visioSelectByType, visioSelectionIsOnPage, visioShadowPreset, visioShapeDataNumber, visioShapeDataRow, visioShapeDataText, visioShapeEffectValues, visioShapeFormattingState, visioShapeLocalPoint, visioShapePageBox, visioShapeReport, visioShapeReportCsv, visioShapeReportTable, visioShapeReportText, visioShapeSelectType, visioShapeSnapBox, visioSizePositionCommand, visioSizePositionState, visioSnapMoveDelta, visioStencilDropCommand, visioStencilInstanceShape, visioStencilShape, visioStencilSubShape, visioStraightLineHandles, visioStrokeGradient, visioStyleFormattingShape, visioSubprocessCommand, visioSvgStrokeStyle, visioTextAppendEdit, visioTextBlockDrag, visioTextBlockEdit, visioTextBlockFrame, visioTextBlockMatrix, visioTextBlockShape, visioTextDialogPatch, visioTextDialogValues, visioTextDraftEdit, visioTextFontStepCommand, visioTextFormattingState, visioTextIndentCommand, visioTextOccurrenceSelection, visioTextReplaceCommands, visioTextReplaceFindNext, visioTextReplaceOccurrences, visioTextReplacePlan, visioTextShape, visioTextSource, visioUngroupCommand, visioWithCalloutLeaders, visioWithContainerMembers, visioWithDataGraphics, visioWorkbookGrid };
34248
+ export { DocumentHistory, EDIT_HISTORY_LIMITS, EMPTY_EDIT_STATE, EMPTY_SELECTION, EMPTY_TEXT_SEARCH, FOREIGN_VECTOR_SCENE_LIMITS, ForeignVectorBudget, MAX_INPUT_BYTES, TEXT_SEARCH_LIMITS, VISIO_AUTO_CONNECT_DIRECTIONS, VISIO_AUTO_CONNECT_GAP, VISIO_AUTO_CONNECT_REACH, VISIO_BULLET_STYLES, VISIO_DATA_GRAPHIC_FILL_ROW, VISIO_DATA_GRAPHIC_ICONS, VISIO_DATA_GRAPHIC_ROW, VISIO_DIAGRAM_RULE_SETS, VISIO_FIELD_CATEGORIES, VISIO_FORMAT_PAINTER_LIMITS, VISIO_GRID_DENSITY_CHOICES, IDENTITY_AFFINE as VISIO_IDENTITY_TRANSFORM, VISIO_LAYOUT_LABELS, VISIO_LAYOUT_STYLES, VISIO_PAGE_SIZE_PRESETS, VISIO_PAPER_SIZES, VISIO_PASTE_TEXT_LIMIT, VISIO_PATH_CLOSE_DISTANCE, VISIO_PATH_TOLERANCE, VISIO_PICTURE_DPI, VISIO_RESIZE_HANDLES, VISIO_RULER_DENSITY_CHOICES, VISIO_SELECT_TYPES, VISIO_SELECT_TYPE_LABELS, VISIO_SUBPROCESS_SHAPE, VISIO_TEXT_BLOCK_HANDLES, VISIO_TEXT_LANGUAGES, VISIO_TEXT_REPLACE_LIMITS, VisioTextDraftError, assertShapeDetails, assertViewableDocument, checkVisioDiagram, clampHistoryEntries, compatibilityNotes, compatibilityText, composeAffine as composeVisioTransform, copySnapshotScene, createSampleVsdx, demoDocument, editErrorMessage, eventKeys, excelSerialToIso, hasVisibleShapeContent, indexDocumentText, inspectForeignVectorResource, isEditCancellation, isVisioPathTool, normalizeVisioHyperlinkAddress, propertyKeys, sameSelection, searchDocumentText, selectionKey, snapshotEdits, snapshotSelection, textSearchStatus, validateSearchQuery, visioAddConnectionPointCommand, visioArrangeCommands, visioAutoAlignCommands, visioAutoConnectArrows, visioAutoConnectNeighbor, visioAutoConnectPlacement, visioAutoConnectPlan, visioAutoConnectShape, visioAutoConnectSidePoint, visioBoxCreationCommand, visioCalloutCommand, visioChangeCaseCommand, visioChangeCaseShape, visioChangeMasterCommand, visioChangeMasterTargets, visioChangeShapeCommand, visioChangeShapeRefusal, visioClipboardShape, visioColorRules, visioConnectableShape, visioConnectorCreationCommand, visioConnectorEdges, visioConnectorEndHandles, visioConnectorMovePreviews, visioConnectorPreviewPath, visioConnectorRouteOf, visioContainerCommand, visioCopyableShape, visioDataGraphicEdits, visioDataGraphicFields, visioDataGraphicMarker, visioDataGraphicParts, visioDataTable, visioDrawBounds, visioDrawIsLargeEnough, visioDrawPlan, visioDrawingPoint, visioDuplicateCommand, visioFileMasterDropCommand, visioFillPatternTransform, visioFitToDrawingEdits, visioFollowTarget, visioFontFamilies, visioFormatPainterEdits, visioFormatPainterSnapshot, visioFormatTargetShape, visioFormattingShape, visioGlowKey, visioGlueableShape, visioGradientInstances, visioGridSteps, visioGroupCommand, visioGuideCreateCommand, visioGuideMoveCommand, visioKeepAutoSize, visioLayerAssignCommand, visioLayerAssignCommands, visioLayerAssignState, visioLegendEdits, visioLineCreationCommand, visioLineDashLengths, visioLocalFormattingShape, visioLocalRotationShape, visioMarqueeBox, visioMarqueeSelection, visioMasterDropCommand, visioMasterDropRefusal, visioMasterDropSize, visioMasterPreviewBox, visioMatchingPaperSize, visioMovableGroup, visioMoveCommands, visioMovePreviewTransform, visioMoveTargets, visioMovementShape, visioNearestConnectionPoint, visioNewLayerNames, visioNewPageId, visioNextShapeId, visioNudgeCommands, visioOrderingShape, visioOrientationEdits, visioPageBreaks, visioPageConnectionPoints, visioPageDecorationState, visioPageDragDelta, visioPageEditToDrawing, visioPageGuides, visioPageInsertCommand, visioPageMasters, visioPageOrientationCommand, visioPageSizeCommand, visioPageSizePresetCommand, visioPageSizePresetEdits, visioPageSizeState, visioPaperSize, visioParseRange, visioPasteCommand, visioPasteTextCommand, visioPasteTextValue, visioPathDrawPlan, visioPathPreview, visioPictureInsertCommand, visioPrintTile, visioQuarterTurnCommand, visioReLayoutCommands, visioReflectionKey, visioRemoveDataGraphicEdits, visioRenderedGradientStopCount, visioRenderedGradientStops, visioResizeDrag, visioResizeFrame, visioResizeShape, visioRotationPreviewTransform, visioRotationShape, visioRulerDensityFactor, visioRulerGridEdits, visioRulerGridValues, visioSceneToLocal, visioSelectByType, visioSelectionIsOnPage, visioShadowPreset, visioShapeDataNumber, visioShapeDataRow, visioShapeDataText, visioShapeEffectValues, visioShapeFormattingState, visioShapeLocalPoint, visioShapePageBox, visioShapeReport, visioShapeReportCsv, visioShapeReportTable, visioShapeReportText, visioShapeSelectType, visioShapeSnapBox, visioSizePositionCommand, visioSizePositionState, visioSnapMoveDelta, visioStencilDropCommand, visioStencilInstanceShape, visioStencilShape, visioStencilSubShape, visioStraightLineHandles, visioStrokeGradient, visioStyleFormattingShape, visioSubprocessCommand, visioSvgStrokeStyle, visioTextAppendEdit, visioTextBlockDrag, visioTextBlockEdit, visioTextBlockFrame, visioTextBlockMatrix, visioTextBlockShape, visioTextDialogPatch, visioTextDialogValues, visioTextDraftEdit, visioTextFontStepCommand, visioTextFormattingState, visioTextIndentCommand, visioTextOccurrenceSelection, visioTextReplaceCommands, visioTextReplaceFindNext, visioTextReplaceOccurrences, visioTextReplacePlan, visioTextShape, visioTextSource, visioUngroupCommand, visioWithCalloutLeaders, visioWithContainerMembers, visioWithDataGraphics, visioWorkbookGrid };
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../xlsx/edit/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,SAAS,EAAkB,MAAM,YAAY,CAAC;AAE9E,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErE,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,SAA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xD;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAKhD;AAED,0DAA0D;AAC1D,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAQ1E"}
@@ -11736,7 +11736,7 @@ var DEFAULT_XML_LIMITS = {
11736
11736
  maxDepth: 512,
11737
11737
  maxNodes: 5e6
11738
11738
  };
11739
- var TAG_RE = /<(\/?)([^\s\/>]+)(?:\s+[^\s=\/>]+\s*=\s*(?:"[^"]*"|'[^']*'))*\s*(\/?)>/y;
11739
+ var TAG_RE = /<(\/?)([^\s\/><]+)(?:\s+[^\s=\/><]+\s*=\s*(?:"[^"<]*"|'[^'<]*'))*\s*(\/?)>/y;
11740
11740
  var MARKUP_SKIPS = [
11741
11741
  ["<!--", "-->"],
11742
11742
  ["<![CDATA[", "]]>"],
@@ -29536,11 +29536,17 @@ function pivotTableXml(source2, cacheId, cache3) {
29536
29536
  }
29537
29537
  return XML_HEADER + buildXml(root);
29538
29538
  }
29539
+ function firstFilterTag(xml) {
29540
+ for (let at = xml.indexOf("<filter"); at !== -1; at = xml.indexOf("<filter", at + 1)) {
29541
+ if (!/\s/.test(xml.charAt(at + 7))) continue;
29542
+ const end = xml.indexOf(">", at);
29543
+ return end === -1 ? "" : xml.slice(at, end + 1);
29544
+ }
29545
+ return "";
29546
+ }
29539
29547
  function dateFilterXml(pivot, filter2) {
29540
29548
  const x15 = "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main";
29541
- const id = Number(
29542
- /\bid="(\d+)"/.exec(/<filter\s[^>]*>/.exec(pivot.sourceXml ?? "")?.[0] ?? "")?.[1] ?? 1
29543
- );
29549
+ const id = Number(/\bid="(\d+)"/.exec(firstFilterTag(pivot.sourceXml ?? ""))?.[1] ?? 1);
29544
29550
  return `<filters count="1"><filter${attrs({ fld: pivot.fields.indexOf(filter2.field), type: "dateBetween", evalOrder: -1, id, name: filter2.field })}><autoFilter ref="A1"><filterColumn colId="0"><customFilters and="1"><customFilter operator="greaterThanOrEqual" val="${Math.floor(filter2.start)}"/><customFilter operator="lessThanOrEqual" val="${Math.floor(filter2.end)}"/></customFilters></filterColumn></autoFilter><extLst><ext uri="{0605FD5F-26C8-4aeb-8148-2DB25E43C511}" xmlns:x15="${x15}"><x15:pivotFilter useWholeDay="1"/></ext></extLst></filter></filters>`;
29545
29551
  }
29546
29552
 
@@ -29642,7 +29648,7 @@ var PivotWritePlan = class {
29642
29648
 
29643
29649
  // xlsx/edit/context.ts
29644
29650
  function sheetAt(workbook, index3) {
29645
- const sheet = Number.isInteger(index3) ? workbook.sheets[index3] : void 0;
29651
+ const sheet = Number.isInteger(index3) && index3 >= 0 ? workbook.sheets.at(index3) : void 0;
29646
29652
  if (!sheet) throw new RangeError(`No sheet at index ${index3}`);
29647
29653
  return sheet;
29648
29654
  }
@@ -34405,7 +34411,7 @@ function editScenario(ctx, s, index3, draft) {
34405
34411
  const name = checkName(sheet, draft.name, index3);
34406
34412
  const scenario = build(ctx, sheet, draft, name);
34407
34413
  ctx.run("Edit scenario", "view", PARTS(s), () => {
34408
- sheet.scenarios.list[index3] = scenario;
34414
+ sheet.scenarios.list.splice(index3, 1, scenario);
34409
34415
  });
34410
34416
  }
34411
34417
  function deleteScenario(ctx, s, index3) {
@@ -34428,7 +34434,7 @@ function deleteScenario(ctx, s, index3) {
34428
34434
  }
34429
34435
  function showScenario(ctx, s, index3) {
34430
34436
  const sheet = sheetAt(ctx.workbook, s);
34431
- const scenario = scenariosOf(sheet)[index3];
34437
+ const scenario = Number.isInteger(index3) ? scenariosOf(sheet)[index3] : void 0;
34432
34438
  if (!scenario) throw new ScenarioError("missing");
34433
34439
  const addresses = scenarioAddresses(scenario);
34434
34440
  const ranges = addresses.map((a2) => ({ start: a2, end: a2 }));
@@ -11730,7 +11730,7 @@ var DEFAULT_XML_LIMITS = {
11730
11730
  maxDepth: 512,
11731
11731
  maxNodes: 5e6
11732
11732
  };
11733
- var TAG_RE = /<(\/?)([^\s\/>]+)(?:\s+[^\s=\/>]+\s*=\s*(?:"[^"]*"|'[^']*'))*\s*(\/?)>/y;
11733
+ var TAG_RE = /<(\/?)([^\s\/><]+)(?:\s+[^\s=\/><]+\s*=\s*(?:"[^"<]*"|'[^'<]*'))*\s*(\/?)>/y;
11734
11734
  var MARKUP_SKIPS = [
11735
11735
  ["<!--", "-->"],
11736
11736
  ["<![CDATA[", "]]>"],
@@ -29530,11 +29530,17 @@ function pivotTableXml(source2, cacheId, cache3) {
29530
29530
  }
29531
29531
  return XML_HEADER + buildXml(root);
29532
29532
  }
29533
+ function firstFilterTag(xml) {
29534
+ for (let at = xml.indexOf("<filter"); at !== -1; at = xml.indexOf("<filter", at + 1)) {
29535
+ if (!/\s/.test(xml.charAt(at + 7))) continue;
29536
+ const end = xml.indexOf(">", at);
29537
+ return end === -1 ? "" : xml.slice(at, end + 1);
29538
+ }
29539
+ return "";
29540
+ }
29533
29541
  function dateFilterXml(pivot, filter2) {
29534
29542
  const x15 = "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main";
29535
- const id = Number(
29536
- /\bid="(\d+)"/.exec(/<filter\s[^>]*>/.exec(pivot.sourceXml ?? "")?.[0] ?? "")?.[1] ?? 1
29537
- );
29543
+ const id = Number(/\bid="(\d+)"/.exec(firstFilterTag(pivot.sourceXml ?? ""))?.[1] ?? 1);
29538
29544
  return `<filters count="1"><filter${attrs({ fld: pivot.fields.indexOf(filter2.field), type: "dateBetween", evalOrder: -1, id, name: filter2.field })}><autoFilter ref="A1"><filterColumn colId="0"><customFilters and="1"><customFilter operator="greaterThanOrEqual" val="${Math.floor(filter2.start)}"/><customFilter operator="lessThanOrEqual" val="${Math.floor(filter2.end)}"/></customFilters></filterColumn></autoFilter><extLst><ext uri="{0605FD5F-26C8-4aeb-8148-2DB25E43C511}" xmlns:x15="${x15}"><x15:pivotFilter useWholeDay="1"/></ext></extLst></filter></filters>`;
29539
29545
  }
29540
29546
 
@@ -29636,7 +29642,7 @@ var PivotWritePlan = class {
29636
29642
 
29637
29643
  // xlsx/edit/context.ts
29638
29644
  function sheetAt(workbook, index3) {
29639
- const sheet = Number.isInteger(index3) ? workbook.sheets[index3] : void 0;
29645
+ const sheet = Number.isInteger(index3) && index3 >= 0 ? workbook.sheets.at(index3) : void 0;
29640
29646
  if (!sheet) throw new RangeError(`No sheet at index ${index3}`);
29641
29647
  return sheet;
29642
29648
  }
@@ -34399,7 +34405,7 @@ function editScenario(ctx, s, index3, draft) {
34399
34405
  const name = checkName(sheet, draft.name, index3);
34400
34406
  const scenario = build(ctx, sheet, draft, name);
34401
34407
  ctx.run("Edit scenario", "view", PARTS(s), () => {
34402
- sheet.scenarios.list[index3] = scenario;
34408
+ sheet.scenarios.list.splice(index3, 1, scenario);
34403
34409
  });
34404
34410
  }
34405
34411
  function deleteScenario(ctx, s, index3) {
@@ -34422,7 +34428,7 @@ function deleteScenario(ctx, s, index3) {
34422
34428
  }
34423
34429
  function showScenario(ctx, s, index3) {
34424
34430
  const sheet = sheetAt(ctx.workbook, s);
34425
- const scenario = scenariosOf(sheet)[index3];
34431
+ const scenario = Number.isInteger(index3) ? scenariosOf(sheet)[index3] : void 0;
34426
34432
  if (!scenario) throw new ScenarioError("missing");
34427
34433
  const addresses = scenarioAddresses(scenario);
34428
34434
  const ranges = addresses.map((a2) => ({ start: a2, end: a2 }));
@@ -3254,7 +3254,7 @@ var DEFAULT_XML_LIMITS = {
3254
3254
  maxDepth: 512,
3255
3255
  maxNodes: 5e6
3256
3256
  };
3257
- var TAG_RE = /<(\/?)([^\s\/>]+)(?:\s+[^\s=\/>]+\s*=\s*(?:"[^"]*"|'[^']*'))*\s*(\/?)>/y;
3257
+ var TAG_RE = /<(\/?)([^\s\/><]+)(?:\s+[^\s=\/><]+\s*=\s*(?:"[^"<]*"|'[^'<]*'))*\s*(\/?)>/y;
3258
3258
  var MARKUP_SKIPS = [
3259
3259
  ["<!--", "-->"],
3260
3260
  ["<![CDATA[", "]]>"],
@@ -27541,11 +27541,17 @@ function pivotTableXml(source2, cacheId, cache2) {
27541
27541
  }
27542
27542
  return XML_HEADER + buildXml(root);
27543
27543
  }
27544
+ function firstFilterTag(xml) {
27545
+ for (let at = xml.indexOf("<filter"); at !== -1; at = xml.indexOf("<filter", at + 1)) {
27546
+ if (!/\s/.test(xml.charAt(at + 7))) continue;
27547
+ const end = xml.indexOf(">", at);
27548
+ return end === -1 ? "" : xml.slice(at, end + 1);
27549
+ }
27550
+ return "";
27551
+ }
27544
27552
  function dateFilterXml(pivot, filter2) {
27545
27553
  const x15 = "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main";
27546
- const id = Number(
27547
- /\bid="(\d+)"/.exec(/<filter\s[^>]*>/.exec(pivot.sourceXml ?? "")?.[0] ?? "")?.[1] ?? 1
27548
- );
27554
+ const id = Number(/\bid="(\d+)"/.exec(firstFilterTag(pivot.sourceXml ?? ""))?.[1] ?? 1);
27549
27555
  return `<filters count="1"><filter${attrs({ fld: pivot.fields.indexOf(filter2.field), type: "dateBetween", evalOrder: -1, id, name: filter2.field })}><autoFilter ref="A1"><filterColumn colId="0"><customFilters and="1"><customFilter operator="greaterThanOrEqual" val="${Math.floor(filter2.start)}"/><customFilter operator="lessThanOrEqual" val="${Math.floor(filter2.end)}"/></customFilters></filterColumn></autoFilter><extLst><ext uri="{0605FD5F-26C8-4aeb-8148-2DB25E43C511}" xmlns:x15="${x15}"><x15:pivotFilter useWholeDay="1"/></ext></extLst></filter></filters>`;
27550
27556
  }
27551
27557
 
@@ -3248,7 +3248,7 @@ var DEFAULT_XML_LIMITS = {
3248
3248
  maxDepth: 512,
3249
3249
  maxNodes: 5e6
3250
3250
  };
3251
- var TAG_RE = /<(\/?)([^\s\/>]+)(?:\s+[^\s=\/>]+\s*=\s*(?:"[^"]*"|'[^']*'))*\s*(\/?)>/y;
3251
+ var TAG_RE = /<(\/?)([^\s\/><]+)(?:\s+[^\s=\/><]+\s*=\s*(?:"[^"<]*"|'[^'<]*'))*\s*(\/?)>/y;
3252
3252
  var MARKUP_SKIPS = [
3253
3253
  ["<!--", "-->"],
3254
3254
  ["<![CDATA[", "]]>"],
@@ -27535,11 +27535,17 @@ function pivotTableXml(source2, cacheId, cache2) {
27535
27535
  }
27536
27536
  return XML_HEADER + buildXml(root);
27537
27537
  }
27538
+ function firstFilterTag(xml) {
27539
+ for (let at = xml.indexOf("<filter"); at !== -1; at = xml.indexOf("<filter", at + 1)) {
27540
+ if (!/\s/.test(xml.charAt(at + 7))) continue;
27541
+ const end = xml.indexOf(">", at);
27542
+ return end === -1 ? "" : xml.slice(at, end + 1);
27543
+ }
27544
+ return "";
27545
+ }
27538
27546
  function dateFilterXml(pivot, filter2) {
27539
27547
  const x15 = "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main";
27540
- const id = Number(
27541
- /\bid="(\d+)"/.exec(/<filter\s[^>]*>/.exec(pivot.sourceXml ?? "")?.[0] ?? "")?.[1] ?? 1
27542
- );
27548
+ const id = Number(/\bid="(\d+)"/.exec(firstFilterTag(pivot.sourceXml ?? ""))?.[1] ?? 1);
27543
27549
  return `<filters count="1"><filter${attrs({ fld: pivot.fields.indexOf(filter2.field), type: "dateBetween", evalOrder: -1, id, name: filter2.field })}><autoFilter ref="A1"><filterColumn colId="0"><customFilters and="1"><customFilter operator="greaterThanOrEqual" val="${Math.floor(filter2.start)}"/><customFilter operator="lessThanOrEqual" val="${Math.floor(filter2.end)}"/></customFilters></filterColumn></autoFilter><extLst><ext uri="{0605FD5F-26C8-4aeb-8148-2DB25E43C511}" xmlns:x15="${x15}"><x15:pivotFilter useWholeDay="1"/></ext></extLst></filter></filters>`;
27544
27550
  }
27545
27551
 
@@ -0,0 +1,25 @@
1
+ import { type CellValue, type ChartObject, type ChartType, type Workbook } from '../../index.js';
2
+ /** The chart types Insert Chart offers, in Office's order, with their English names. */
3
+ export declare const INSERT_CHART_TYPES: ReadonlyArray<readonly [type: ChartType, label: string]>;
4
+ /** The types whose bars can be stacked (Insert Chart shows a Grouping choice for these). */
5
+ export declare const GROUPED_CHART_TYPES: readonly ChartType[];
6
+ /** Largest grid read from pasted text: far beyond a readable chart, small enough to stay cheap. */
7
+ export declare const MAX_GRID_ROWS = 100;
8
+ export declare const MAX_GRID_COLS = 26;
9
+ /**
10
+ * Rows of cells from text: one row per line, cells split on tabs (or commas when the line has no
11
+ * tab). Numbers become numbers, empty cells null, and short rows are padded to the widest.
12
+ */
13
+ export declare function parseChartGrid(text: string): CellValue[][];
14
+ export interface GridChart {
15
+ workbook: Workbook;
16
+ chart: ChartObject;
17
+ }
18
+ /** The chart for `rows` (text in the first row names the series, in the first column the categories). */
19
+ export declare function gridChart(rows: readonly (readonly CellValue[])[], type: ChartType, options?: {
20
+ grouping?: ChartObject['grouping'];
21
+ title?: string;
22
+ }): GridChart | undefined;
23
+ /** `grid` as a standalone SVG document `width` by `height`; `bare` leaves out the title and legend. */
24
+ export declare function gridChartSvg(grid: GridChart, width: number, height: number, bare?: boolean): string;
25
+ //# sourceMappingURL=grid-chart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid-chart.d.ts","sourceRoot":"","sources":["../../../../xlsx/ui/dialogs/grid-chart.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,QAAQ,EAKb,MAAM,aAAa,CAAC;AAGrB,wFAAwF;AACxF,eAAO,MAAM,kBAAkB,EAAE,aAAa,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,CASvF,CAAC;AAEF,4FAA4F;AAC5F,eAAO,MAAM,mBAAmB,EAAE,SAAS,SAAS,EAAsB,CAAC;AAE3E,mGAAmG;AACnG,eAAO,MAAM,aAAa,MAAM,CAAC;AACjC,eAAO,MAAM,aAAa,KAAK,CAAC;AAEhC;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,EAAE,CAiB1D;AAED,MAAM,WAAW,SAAS;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,WAAW,CAAC;CACnB;AAED,yGAAyG;AACzG,wBAAgB,SAAS,CACxB,IAAI,EAAE,SAAS,CAAC,SAAS,SAAS,EAAE,CAAC,EAAE,EACvC,IAAI,EAAE,SAAS,EACf,OAAO,GAAE;IAAE,QAAQ,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAClE,SAAS,GAAG,SAAS,CAWvB;AAED,uGAAuG;AACvG,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,UAAQ,GAAG,MAAM,CAIjG"}