docx-plus 0.0.2 → 0.0.4

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.
@@ -1,4 +1,4 @@
1
- var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, fflate, undio, xml) {
1
+ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate, xml) {
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  //#region \0rolldown/runtime.js
4
4
  var __create = Object.create;
@@ -22,9 +22,9 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
22
22
  enumerable: true
23
23
  }) : target, mod));
24
24
  //#endregion
25
- hash_js = __toESM(hash_js);
26
- xml = __toESM(xml);
27
- //#region \0@oxc-project+runtime@0.123.0/helpers/typeof.js
25
+ hash_js = __toESM(hash_js, 1);
26
+ xml = __toESM(xml, 1);
27
+ //#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
28
28
  function _typeof(o) {
29
29
  "@babel/helpers - typeof";
30
30
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -34,7 +34,7 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
34
34
  }, _typeof(o);
35
35
  }
36
36
  //#endregion
37
- //#region \0@oxc-project+runtime@0.123.0/helpers/toPrimitive.js
37
+ //#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
38
38
  function toPrimitive(t, r) {
39
39
  if ("object" != _typeof(t) || !t) return t;
40
40
  var e = t[Symbol.toPrimitive];
@@ -46,13 +46,13 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
46
46
  return ("string" === r ? String : Number)(t);
47
47
  }
48
48
  //#endregion
49
- //#region \0@oxc-project+runtime@0.123.0/helpers/toPropertyKey.js
49
+ //#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
50
50
  function toPropertyKey(t) {
51
51
  var i = toPrimitive(t, "string");
52
52
  return "symbol" == _typeof(i) ? i : i + "";
53
53
  }
54
54
  //#endregion
55
- //#region \0@oxc-project+runtime@0.123.0/helpers/defineProperty.js
55
+ //#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
56
56
  function _defineProperty(e, r, t) {
57
57
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
58
58
  value: t,
@@ -237,29 +237,6 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
237
237
  }
238
238
  };
239
239
  //#endregion
240
- //#region \0@oxc-project+runtime@0.123.0/helpers/objectSpread2.js
241
- function ownKeys(e, r) {
242
- var t = Object.keys(e);
243
- if (Object.getOwnPropertySymbols) {
244
- var o = Object.getOwnPropertySymbols(e);
245
- r && (o = o.filter(function(r) {
246
- return Object.getOwnPropertyDescriptor(e, r).enumerable;
247
- })), t.push.apply(t, o);
248
- }
249
- return t;
250
- }
251
- function _objectSpread2(e) {
252
- for (var r = 1; r < arguments.length; r++) {
253
- var t = null != arguments[r] ? arguments[r] : {};
254
- r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
255
- _defineProperty(e, r, t[r]);
256
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
257
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
258
- });
259
- }
260
- return e;
261
- }
262
- //#endregion
263
240
  //#region src/file/xml-components/default-attributes.ts
264
241
  /**
265
242
  * XML attribute components for the docx library.
@@ -353,7 +330,10 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
353
330
  * @returns Object with _attr key containing the attributes
354
331
  */
355
332
  prepForXml(_) {
356
- return { _attr: Object.values(this.root).filter(({ value }) => value !== void 0).reduce((acc, { key, value }) => _objectSpread2(_objectSpread2({}, acc), {}, { [key]: value }), {}) };
333
+ return { _attr: Object.values(this.root).filter(({ value }) => value !== void 0).reduce((acc, { key, value }) => ({
334
+ ...acc,
335
+ [key]: value
336
+ }), {}) };
357
337
  }
358
338
  };
359
339
  //#endregion
@@ -4727,13 +4707,16 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
4727
4707
  * @returns An XML component representing the click hyperlink
4728
4708
  */
4729
4709
  const createHyperlinkClick = (linkId, hasXmlNs) => new BuilderElement({
4730
- attributes: _objectSpread2(_objectSpread2({}, hasXmlNs ? { xmlns: {
4731
- key: "xmlns:a",
4732
- value: "http://schemas.openxmlformats.org/drawingml/2006/main"
4733
- } } : {}), {}, { id: {
4734
- key: "r:id",
4735
- value: `rId${linkId}`
4736
- } }),
4710
+ attributes: {
4711
+ ...hasXmlNs ? { xmlns: {
4712
+ key: "xmlns:a",
4713
+ value: "http://schemas.openxmlformats.org/drawingml/2006/main"
4714
+ } } : {},
4715
+ id: {
4716
+ key: "r:id",
4717
+ value: `rId${linkId}`
4718
+ }
4719
+ },
4737
4720
  name: "a:hlinkClick"
4738
4721
  });
4739
4722
  //#endregion
@@ -4981,21 +4964,23 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
4981
4964
  super("a:graphicData");
4982
4965
  if (mediaData.type === "wps") {
4983
4966
  this.root.push(new GraphicDataAttributes({ uri: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape" }));
4984
- const wps = createWpsShape(_objectSpread2(_objectSpread2({}, mediaData.data), {}, {
4967
+ const wps = createWpsShape({
4968
+ ...mediaData.data,
4985
4969
  outline,
4986
4970
  solidFill,
4987
4971
  transformation: transform
4988
- }));
4972
+ });
4989
4973
  this.root.push(wps);
4990
4974
  } else if (mediaData.type === "wpg") {
4991
4975
  this.root.push(new GraphicDataAttributes({ uri: "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" }));
4992
4976
  const wpg = createWpgGroup({
4993
4977
  children: mediaData.children.map((child) => {
4994
- if (child.type === "wps") return createWpsShape(_objectSpread2(_objectSpread2({}, child.data), {}, {
4978
+ if (child.type === "wps") return createWpsShape({
4979
+ ...child.data,
4995
4980
  outline: child.outline,
4996
4981
  solidFill: child.solidFill,
4997
4982
  transformation: child.transformation
4998
- }));
4983
+ });
4999
4984
  else return new Pic({
5000
4985
  mediaData: child,
5001
4986
  outline: child.outline,
@@ -5624,14 +5609,15 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
5624
5609
  var Anchor = class extends XmlComponent {
5625
5610
  constructor({ mediaData, transform, drawingOptions }) {
5626
5611
  super("wp:anchor");
5627
- const floating = _objectSpread2({
5612
+ const floating = {
5628
5613
  allowOverlap: true,
5629
5614
  behindDocument: false,
5630
5615
  horizontalPosition: {},
5631
5616
  layoutInCell: true,
5632
5617
  lockAnchor: false,
5633
- verticalPosition: {}
5634
- }, drawingOptions.floating);
5618
+ verticalPosition: {},
5619
+ ...drawingOptions.floating
5620
+ };
5635
5621
  this.root.push(new AnchorAttributes({
5636
5622
  distT: floating.margins ? floating.margins.top || 0 : 0,
5637
5623
  distB: floating.margins ? floating.margins.bottom || 0 : 0,
@@ -5771,29 +5757,20 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
5771
5757
  };
5772
5758
  //#endregion
5773
5759
  //#region src/file/paragraph/run/image-run.ts
5774
- const convertDataURIToBinary = (dataURI) => {
5775
- const base64Index = dataURI.indexOf(";base64,");
5776
- const base64IndexWithOffset = base64Index === -1 ? 0 : base64Index + 8;
5777
- const binaryString = atob(dataURI.substring(base64IndexWithOffset));
5778
- const bytes = new Uint8Array(binaryString.length);
5779
- for (let i = 0; i < binaryString.length; i++) bytes[i] = binaryString.charCodeAt(i);
5780
- return bytes;
5781
- };
5782
- const standardizeData = (data) => typeof data === "string" ? convertDataURIToBinary(data) : data;
5783
- const createImageData = (options, key) => ({
5784
- data: standardizeData(options.data),
5760
+ const createImageData = (data, transformation, key) => ({
5761
+ data,
5785
5762
  fileName: key,
5786
5763
  transformation: {
5787
5764
  emus: {
5788
- x: Math.round(options.transformation.width * 9525),
5789
- y: Math.round(options.transformation.height * 9525)
5765
+ x: Math.round(transformation.width * 9525),
5766
+ y: Math.round(transformation.height * 9525)
5790
5767
  },
5791
- flip: options.transformation.flip,
5768
+ flip: transformation.flip,
5792
5769
  pixels: {
5793
- x: Math.round(options.transformation.width),
5794
- y: Math.round(options.transformation.height)
5770
+ x: Math.round(transformation.width),
5771
+ y: Math.round(transformation.height)
5795
5772
  },
5796
- rotation: options.transformation.rotation ? options.transformation.rotation * 6e4 : void 0
5773
+ rotation: transformation.rotation ? transformation.rotation * 6e4 : void 0
5797
5774
  }
5798
5775
  });
5799
5776
  /**
@@ -5822,8 +5799,22 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
5822
5799
  constructor(options) {
5823
5800
  super({});
5824
5801
  _defineProperty(this, "imageData", void 0);
5825
- const key = `${hashedId(options.data)}.${options.type}`;
5826
- this.imageData = options.type === "svg" ? _objectSpread2(_objectSpread2({ type: options.type }, createImageData(options, key)), {}, { fallback: _objectSpread2({ type: options.fallback.type }, createImageData(_objectSpread2(_objectSpread2({}, options.fallback), {}, { transformation: options.transformation }), `${hashedId(options.fallback.data)}.${options.fallback.type}`)) }) : _objectSpread2({ type: options.type }, createImageData(options, key));
5802
+ const rawData = (0, undio.toUint8Array)(options.data);
5803
+ const key = `${hashedId(rawData)}.${options.type}`;
5804
+ if (options.type === "svg") {
5805
+ const fallbackData = (0, undio.toUint8Array)(options.fallback.data);
5806
+ this.imageData = {
5807
+ type: options.type,
5808
+ ...createImageData(rawData, options.transformation, key),
5809
+ fallback: {
5810
+ type: options.fallback.type,
5811
+ ...createImageData(fallbackData, options.transformation, `${hashedId(fallbackData)}.${options.fallback.type}`)
5812
+ }
5813
+ };
5814
+ } else this.imageData = {
5815
+ type: options.type,
5816
+ ...createImageData(rawData, options.transformation, key)
5817
+ };
5827
5818
  const drawing = new Drawing(this.imageData, {
5828
5819
  docProperties: options.altText,
5829
5820
  floating: options.floating,
@@ -5872,7 +5863,7 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
5872
5863
  super({});
5873
5864
  _defineProperty(this, "wpsShapeData", void 0);
5874
5865
  this.wpsShapeData = {
5875
- data: _objectSpread2({}, options),
5866
+ data: { ...options },
5876
5867
  transformation: createTransformation(options.transformation),
5877
5868
  type: options.type
5878
5869
  };
@@ -7899,13 +7890,16 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
7899
7890
  * Creates a font relationship element for embedding fonts.
7900
7891
  */
7901
7892
  const createFontRelationship = ({ id, fontKey, subsetted }, name) => new BuilderElement({
7902
- attributes: _objectSpread2({ id: {
7903
- key: "r:id",
7904
- value: id
7905
- } }, fontKey ? { fontKey: {
7906
- key: "w:fontKey",
7907
- value: `{${fontKey}}`
7908
- } } : {}),
7893
+ attributes: {
7894
+ id: {
7895
+ key: "r:id",
7896
+ value: id
7897
+ },
7898
+ ...fontKey ? { fontKey: {
7899
+ key: "w:fontKey",
7900
+ value: `{${fontKey}}`
7901
+ } } : {}
7902
+ },
7909
7903
  children: subsetted ? [new OnOffElement("w:subsetted", subsetted)] : [],
7910
7904
  name
7911
7905
  });
@@ -8143,7 +8137,10 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
8143
8137
  _defineProperty(this, "fontTable", void 0);
8144
8138
  _defineProperty(this, "relationships", void 0);
8145
8139
  _defineProperty(this, "fontOptionsWithKey", []);
8146
- this.fontOptionsWithKey = options.map((o) => _objectSpread2(_objectSpread2({}, o), {}, { fontKey: uniqueUuid() }));
8140
+ this.fontOptionsWithKey = options.map((o) => ({
8141
+ ...o,
8142
+ fontKey: uniqueUuid()
8143
+ }));
8147
8144
  this.fontTable = createFontTable(this.fontOptionsWithKey);
8148
8145
  this.relationships = new Relationships();
8149
8146
  for (let i = 0; i < options.length; i++) this.relationships.addRelationship(i + 1, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/font", `fonts/${options[i].name}.odttf`);
@@ -8561,7 +8558,10 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
8561
8558
  date: options.date,
8562
8559
  id: options.id
8563
8560
  }));
8564
- this.root.push(new ParagraphProperties(_objectSpread2(_objectSpread2({}, options), {}, { includeIfEmpty: true })));
8561
+ this.root.push(new ParagraphProperties({
8562
+ ...options,
8563
+ includeIfEmpty: true
8564
+ }));
8565
8565
  }
8566
8566
  };
8567
8567
  //#endregion
@@ -10776,7 +10776,10 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
10776
10776
  *
10777
10777
  * @publicApi
10778
10778
  */
10779
- const VerticalAlignSection = _objectSpread2(_objectSpread2({}, VerticalAlignTable), {}, { BOTH: "both" });
10779
+ const VerticalAlignSection = {
10780
+ ...VerticalAlignTable,
10781
+ BOTH: "both"
10782
+ };
10780
10783
  /**
10781
10784
  * @deprecated Use {@link VerticalAlignTable} for table cells or
10782
10785
  * {@link VerticalAlignSection} for section properties. This alias remains for
@@ -11293,7 +11296,10 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
11293
11296
  date: options.date,
11294
11297
  id: options.id
11295
11298
  }));
11296
- this.root.push(new TableCellProperties(_objectSpread2(_objectSpread2({}, options), {}, { includeIfEmpty: true })));
11299
+ this.root.push(new TableCellProperties({
11300
+ ...options,
11301
+ includeIfEmpty: true
11302
+ }));
11297
11303
  }
11298
11304
  };
11299
11305
  //#endregion
@@ -11837,7 +11843,10 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
11837
11843
  date: options.date,
11838
11844
  id: options.id
11839
11845
  }));
11840
- this.root.push(new TableProperties(_objectSpread2(_objectSpread2({}, options), {}, { includeIfEmpty: true })));
11846
+ this.root.push(new TableProperties({
11847
+ ...options,
11848
+ includeIfEmpty: true
11849
+ }));
11841
11850
  }
11842
11851
  };
11843
11852
  //#endregion
@@ -12082,7 +12091,10 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
12082
12091
  date: options.date,
12083
12092
  id: options.id
12084
12093
  }));
12085
- this.root.push(new TableRowProperties(_objectSpread2(_objectSpread2({}, options), {}, { includeIfEmpty: true })));
12094
+ this.root.push(new TableRowProperties({
12095
+ ...options,
12096
+ includeIfEmpty: true
12097
+ }));
12086
12098
  }
12087
12099
  };
12088
12100
  //#endregion
@@ -12481,8 +12493,14 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
12481
12493
  */
12482
12494
  var DocumentAttributes = class extends XmlAttributeComponent {
12483
12495
  constructor(ns, Ignorable) {
12484
- super(_objectSpread2({ Ignorable }, Object.fromEntries(ns.map((n) => [n, DocumentAttributeNamespaces[n]]))));
12485
- _defineProperty(this, "xmlKeys", _objectSpread2({ Ignorable: "mc:Ignorable" }, Object.fromEntries(Object.keys(DocumentAttributeNamespaces).map((key) => [key, `xmlns:${key}`]))));
12496
+ super({
12497
+ Ignorable,
12498
+ ...Object.fromEntries(ns.map((n) => [n, DocumentAttributeNamespaces[n]]))
12499
+ });
12500
+ _defineProperty(this, "xmlKeys", {
12501
+ Ignorable: "mc:Ignorable",
12502
+ ...Object.fromEntries(Object.keys(DocumentAttributeNamespaces).map((key) => [key, `xmlns:${key}`]))
12503
+ });
12486
12504
  }
12487
12505
  };
12488
12506
  //#endregion
@@ -16162,7 +16180,10 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
16162
16180
  if (((_options$hyphenation2 = options.hyphenation) === null || _options$hyphenation2 === void 0 ? void 0 : _options$hyphenation2.hyphenationZone) !== void 0) this.root.push(new NumberValueElement("w:hyphenationZone", options.hyphenation.hyphenationZone));
16163
16181
  if (((_options$hyphenation3 = options.hyphenation) === null || _options$hyphenation3 === void 0 ? void 0 : _options$hyphenation3.consecutiveHyphenLimit) !== void 0) this.root.push(new NumberValueElement("w:consecutiveHyphenLimit", options.hyphenation.consecutiveHyphenLimit));
16164
16182
  if (((_options$hyphenation4 = options.hyphenation) === null || _options$hyphenation4 === void 0 ? void 0 : _options$hyphenation4.doNotHyphenateCaps) !== void 0) this.root.push(new OnOffElement("w:doNotHyphenateCaps", options.hyphenation.doNotHyphenateCaps));
16165
- this.root.push(new Compatibility(_objectSpread2(_objectSpread2({}, options.compatibility), {}, { version: (_ref = (_options$compatibilit = (_options$compatibilit2 = options.compatibility) === null || _options$compatibilit2 === void 0 ? void 0 : _options$compatibilit2.version) !== null && _options$compatibilit !== void 0 ? _options$compatibilit : options.compatibilityModeVersion) !== null && _ref !== void 0 ? _ref : 15 })));
16183
+ this.root.push(new Compatibility({
16184
+ ...options.compatibility,
16185
+ version: (_ref = (_options$compatibilit = (_options$compatibilit2 = options.compatibility) === null || _options$compatibilit2 === void 0 ? void 0 : _options$compatibilit2.version) !== null && _options$compatibilit !== void 0 ? _options$compatibilit : options.compatibilityModeVersion) !== null && _ref !== void 0 ? _ref : 15
16186
+ }));
16166
16187
  }
16167
16188
  };
16168
16189
  //#endregion
@@ -16431,10 +16452,11 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
16431
16452
  super({
16432
16453
  styleId: options.id,
16433
16454
  type: "character"
16434
- }, _objectSpread2({
16455
+ }, {
16435
16456
  uiPriority: 99,
16436
- unhideWhenUsed: true
16437
- }, options));
16457
+ unhideWhenUsed: true,
16458
+ ...options
16459
+ });
16438
16460
  _defineProperty(this, "runProperties", void 0);
16439
16461
  this.runProperties = new RunProperties(options.run);
16440
16462
  this.root.push(this.runProperties);
@@ -16470,11 +16492,12 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
16470
16492
  */
16471
16493
  var HeadingStyle = class extends StyleForParagraph {
16472
16494
  constructor(options) {
16473
- super(_objectSpread2({
16495
+ super({
16474
16496
  basedOn: "Normal",
16475
16497
  next: "Normal",
16476
- quickFormat: true
16477
- }, options));
16498
+ quickFormat: true,
16499
+ ...options
16500
+ });
16478
16501
  }
16479
16502
  };
16480
16503
  /**
@@ -16491,10 +16514,11 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
16491
16514
  */
16492
16515
  var TitleStyle = class extends HeadingStyle {
16493
16516
  constructor(options) {
16494
- super(_objectSpread2({
16517
+ super({
16495
16518
  id: "Title",
16496
- name: "Title"
16497
- }, options));
16519
+ name: "Title",
16520
+ ...options
16521
+ });
16498
16522
  }
16499
16523
  };
16500
16524
  /**
@@ -16511,10 +16535,11 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
16511
16535
  */
16512
16536
  var Heading1Style = class extends HeadingStyle {
16513
16537
  constructor(options) {
16514
- super(_objectSpread2({
16538
+ super({
16515
16539
  id: "Heading1",
16516
- name: "Heading 1"
16517
- }, options));
16540
+ name: "Heading 1",
16541
+ ...options
16542
+ });
16518
16543
  }
16519
16544
  };
16520
16545
  /**
@@ -16524,10 +16549,11 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
16524
16549
  */
16525
16550
  var Heading2Style = class extends HeadingStyle {
16526
16551
  constructor(options) {
16527
- super(_objectSpread2({
16552
+ super({
16528
16553
  id: "Heading2",
16529
- name: "Heading 2"
16530
- }, options));
16554
+ name: "Heading 2",
16555
+ ...options
16556
+ });
16531
16557
  }
16532
16558
  };
16533
16559
  /**
@@ -16537,10 +16563,11 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
16537
16563
  */
16538
16564
  var Heading3Style = class extends HeadingStyle {
16539
16565
  constructor(options) {
16540
- super(_objectSpread2({
16566
+ super({
16541
16567
  id: "Heading3",
16542
- name: "Heading 3"
16543
- }, options));
16568
+ name: "Heading 3",
16569
+ ...options
16570
+ });
16544
16571
  }
16545
16572
  };
16546
16573
  /**
@@ -16550,10 +16577,11 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
16550
16577
  */
16551
16578
  var Heading4Style = class extends HeadingStyle {
16552
16579
  constructor(options) {
16553
- super(_objectSpread2({
16580
+ super({
16554
16581
  id: "Heading4",
16555
- name: "Heading 4"
16556
- }, options));
16582
+ name: "Heading 4",
16583
+ ...options
16584
+ });
16557
16585
  }
16558
16586
  };
16559
16587
  /**
@@ -16563,10 +16591,11 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
16563
16591
  */
16564
16592
  var Heading5Style = class extends HeadingStyle {
16565
16593
  constructor(options) {
16566
- super(_objectSpread2({
16594
+ super({
16567
16595
  id: "Heading5",
16568
- name: "Heading 5"
16569
- }, options));
16596
+ name: "Heading 5",
16597
+ ...options
16598
+ });
16570
16599
  }
16571
16600
  };
16572
16601
  /**
@@ -16576,10 +16605,11 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
16576
16605
  */
16577
16606
  var Heading6Style = class extends HeadingStyle {
16578
16607
  constructor(options) {
16579
- super(_objectSpread2({
16608
+ super({
16580
16609
  id: "Heading6",
16581
- name: "Heading 6"
16582
- }, options));
16610
+ name: "Heading 6",
16611
+ ...options
16612
+ });
16583
16613
  }
16584
16614
  };
16585
16615
  /**
@@ -16589,10 +16619,11 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
16589
16619
  */
16590
16620
  var StrongStyle = class extends HeadingStyle {
16591
16621
  constructor(options) {
16592
- super(_objectSpread2({
16622
+ super({
16593
16623
  id: "Strong",
16594
- name: "Strong"
16595
- }, options));
16624
+ name: "Strong",
16625
+ ...options
16626
+ });
16596
16627
  }
16597
16628
  };
16598
16629
  /**
@@ -16602,12 +16633,13 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
16602
16633
  */
16603
16634
  var ListParagraph = class extends StyleForParagraph {
16604
16635
  constructor(options) {
16605
- super(_objectSpread2({
16636
+ super({
16606
16637
  basedOn: "Normal",
16607
16638
  id: "ListParagraph",
16608
16639
  name: "List Paragraph",
16609
- quickFormat: true
16610
- }, options));
16640
+ quickFormat: true,
16641
+ ...options
16642
+ });
16611
16643
  }
16612
16644
  };
16613
16645
  /**
@@ -16617,7 +16649,7 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
16617
16649
  */
16618
16650
  var FootnoteText = class extends StyleForParagraph {
16619
16651
  constructor(options) {
16620
- super(_objectSpread2({
16652
+ super({
16621
16653
  basedOn: "Normal",
16622
16654
  id: "FootnoteText",
16623
16655
  link: "FootnoteTextChar",
@@ -16630,8 +16662,9 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
16630
16662
  run: { size: 20 },
16631
16663
  semiHidden: true,
16632
16664
  uiPriority: 99,
16633
- unhideWhenUsed: true
16634
- }, options));
16665
+ unhideWhenUsed: true,
16666
+ ...options
16667
+ });
16635
16668
  }
16636
16669
  };
16637
16670
  /**
@@ -16641,13 +16674,14 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
16641
16674
  */
16642
16675
  var FootnoteReferenceStyle = class extends StyleForCharacter {
16643
16676
  constructor(options) {
16644
- super(_objectSpread2({
16677
+ super({
16645
16678
  basedOn: "DefaultParagraphFont",
16646
16679
  id: "FootnoteReference",
16647
16680
  name: "footnote reference",
16648
16681
  run: { superScript: true },
16649
- semiHidden: true
16650
- }, options));
16682
+ semiHidden: true,
16683
+ ...options
16684
+ });
16651
16685
  }
16652
16686
  };
16653
16687
  /**
@@ -16657,14 +16691,15 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
16657
16691
  */
16658
16692
  var FootnoteTextChar = class extends StyleForCharacter {
16659
16693
  constructor(options) {
16660
- super(_objectSpread2({
16694
+ super({
16661
16695
  basedOn: "DefaultParagraphFont",
16662
16696
  id: "FootnoteTextChar",
16663
16697
  link: "FootnoteText",
16664
16698
  name: "Footnote Text Char",
16665
16699
  run: { size: 20 },
16666
- semiHidden: true
16667
- }, options));
16700
+ semiHidden: true,
16701
+ ...options
16702
+ });
16668
16703
  }
16669
16704
  };
16670
16705
  /**
@@ -16674,7 +16709,7 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
16674
16709
  */
16675
16710
  var EndnoteText = class extends StyleForParagraph {
16676
16711
  constructor(options) {
16677
- super(_objectSpread2({
16712
+ super({
16678
16713
  basedOn: "Normal",
16679
16714
  id: "EndnoteText",
16680
16715
  link: "EndnoteTextChar",
@@ -16687,8 +16722,9 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
16687
16722
  run: { size: 20 },
16688
16723
  semiHidden: true,
16689
16724
  uiPriority: 99,
16690
- unhideWhenUsed: true
16691
- }, options));
16725
+ unhideWhenUsed: true,
16726
+ ...options
16727
+ });
16692
16728
  }
16693
16729
  };
16694
16730
  /**
@@ -16698,13 +16734,14 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
16698
16734
  */
16699
16735
  var EndnoteReferenceStyle = class extends StyleForCharacter {
16700
16736
  constructor(options) {
16701
- super(_objectSpread2({
16737
+ super({
16702
16738
  basedOn: "DefaultParagraphFont",
16703
16739
  id: "EndnoteReference",
16704
16740
  name: "endnote reference",
16705
16741
  run: { superScript: true },
16706
- semiHidden: true
16707
- }, options));
16742
+ semiHidden: true,
16743
+ ...options
16744
+ });
16708
16745
  }
16709
16746
  };
16710
16747
  /**
@@ -16714,14 +16751,15 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
16714
16751
  */
16715
16752
  var EndnoteTextChar = class extends StyleForCharacter {
16716
16753
  constructor(options) {
16717
- super(_objectSpread2({
16754
+ super({
16718
16755
  basedOn: "DefaultParagraphFont",
16719
16756
  id: "EndnoteTextChar",
16720
16757
  link: "EndnoteText",
16721
16758
  name: "Endnote Text Char",
16722
16759
  run: { size: 20 },
16723
- semiHidden: true
16724
- }, options));
16760
+ semiHidden: true,
16761
+ ...options
16762
+ });
16725
16763
  }
16726
16764
  };
16727
16765
  /**
@@ -16731,15 +16769,16 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
16731
16769
  */
16732
16770
  var HyperlinkStyle = class extends StyleForCharacter {
16733
16771
  constructor(options) {
16734
- super(_objectSpread2({
16772
+ super({
16735
16773
  basedOn: "DefaultParagraphFont",
16736
16774
  id: "Hyperlink",
16737
16775
  name: "Hyperlink",
16738
16776
  run: {
16739
16777
  color: "0563C1",
16740
16778
  underline: { type: UnderlineType.SINGLE }
16741
- }
16742
- }, options));
16779
+ },
16780
+ ...options
16781
+ });
16743
16782
  }
16744
16783
  };
16745
16784
  //#endregion
@@ -17009,26 +17048,50 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
17009
17048
  return {
17010
17049
  importedStyles: [
17011
17050
  new DocumentDefaults((_options$document = options.document) !== null && _options$document !== void 0 ? _options$document : {}),
17012
- new TitleStyle(_objectSpread2({ run: { size: 56 } }, options.title)),
17013
- new Heading1Style(_objectSpread2({ run: {
17014
- color: "2E74B5",
17015
- size: 32
17016
- } }, options.heading1)),
17017
- new Heading2Style(_objectSpread2({ run: {
17018
- color: "2E74B5",
17019
- size: 26
17020
- } }, options.heading2)),
17021
- new Heading3Style(_objectSpread2({ run: {
17022
- color: "1F4D78",
17023
- size: 24
17024
- } }, options.heading3)),
17025
- new Heading4Style(_objectSpread2({ run: {
17026
- color: "2E74B5",
17027
- italics: true
17028
- } }, options.heading4)),
17029
- new Heading5Style(_objectSpread2({ run: { color: "2E74B5" } }, options.heading5)),
17030
- new Heading6Style(_objectSpread2({ run: { color: "1F4D78" } }, options.heading6)),
17031
- new StrongStyle(_objectSpread2({ run: { bold: true } }, options.strong)),
17051
+ new TitleStyle({
17052
+ run: { size: 56 },
17053
+ ...options.title
17054
+ }),
17055
+ new Heading1Style({
17056
+ run: {
17057
+ color: "2E74B5",
17058
+ size: 32
17059
+ },
17060
+ ...options.heading1
17061
+ }),
17062
+ new Heading2Style({
17063
+ run: {
17064
+ color: "2E74B5",
17065
+ size: 26
17066
+ },
17067
+ ...options.heading2
17068
+ }),
17069
+ new Heading3Style({
17070
+ run: {
17071
+ color: "1F4D78",
17072
+ size: 24
17073
+ },
17074
+ ...options.heading3
17075
+ }),
17076
+ new Heading4Style({
17077
+ run: {
17078
+ color: "2E74B5",
17079
+ italics: true
17080
+ },
17081
+ ...options.heading4
17082
+ }),
17083
+ new Heading5Style({
17084
+ run: { color: "2E74B5" },
17085
+ ...options.heading5
17086
+ }),
17087
+ new Heading6Style({
17088
+ run: { color: "1F4D78" },
17089
+ ...options.heading6
17090
+ }),
17091
+ new StrongStyle({
17092
+ run: { bold: true },
17093
+ ...options.strong
17094
+ }),
17032
17095
  new ListParagraph(options.listParagraph || {}),
17033
17096
  new HyperlinkStyle(options.hyperlink || {}),
17034
17097
  new FootnoteReferenceStyle(options.footnoteReference || {}),
@@ -17146,11 +17209,12 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
17146
17209
  _defineProperty(this, "styles", void 0);
17147
17210
  _defineProperty(this, "comments", void 0);
17148
17211
  _defineProperty(this, "fontWrapper", void 0);
17149
- this.coreProperties = new CoreProperties(_objectSpread2(_objectSpread2({}, options), {}, {
17212
+ this.coreProperties = new CoreProperties({
17213
+ ...options,
17150
17214
  creator: (_options$creator = options.creator) !== null && _options$creator !== void 0 ? _options$creator : "Un-named",
17151
17215
  lastModifiedBy: (_options$lastModified = options.lastModifiedBy) !== null && _options$lastModified !== void 0 ? _options$lastModified : "Un-named",
17152
17216
  revision: (_options$revision = options.revision) !== null && _options$revision !== void 0 ? _options$revision : 1
17153
- }));
17217
+ });
17154
17218
  this.numbering = new Numbering(options.numbering ? options.numbering : { config: [] });
17155
17219
  this.comments = new Comments((_options$comments = options.comments) !== null && _options$comments !== void 0 ? _options$comments : { children: [] });
17156
17220
  this.fileRelationships = new Relationships();
@@ -17179,8 +17243,14 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
17179
17243
  var _options$styles;
17180
17244
  const defaultStyles = new DefaultStylesFactory().newInstance((_options$styles = options.styles) === null || _options$styles === void 0 ? void 0 : _options$styles.default);
17181
17245
  const externalStyles = new ExternalStylesFactory().newInstance(options.externalStyles);
17182
- this.styles = new Styles(_objectSpread2(_objectSpread2({}, externalStyles), {}, { importedStyles: [...defaultStyles.importedStyles, ...externalStyles.importedStyles] }));
17183
- } else if (options.styles) this.styles = new Styles(_objectSpread2(_objectSpread2({}, new DefaultStylesFactory().newInstance(options.styles.default)), options.styles));
17246
+ this.styles = new Styles({
17247
+ ...externalStyles,
17248
+ importedStyles: [...defaultStyles.importedStyles, ...externalStyles.importedStyles]
17249
+ });
17250
+ } else if (options.styles) this.styles = new Styles({
17251
+ ...new DefaultStylesFactory().newInstance(options.styles.default),
17252
+ ...options.styles
17253
+ });
17184
17254
  else this.styles = new Styles(new DefaultStylesFactory().newInstance());
17185
17255
  this.addDefaultRelationships();
17186
17256
  for (const section of options.sections) this.addSection(section);
@@ -17189,7 +17259,8 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
17189
17259
  this.fontWrapper = new FontWrapper((_options$fonts = options.fonts) !== null && _options$fonts !== void 0 ? _options$fonts : []);
17190
17260
  }
17191
17261
  addSection({ headers = {}, footers = {}, children, properties }) {
17192
- this.documentWrapper.View.Body.addSection(_objectSpread2(_objectSpread2({}, properties), {}, {
17262
+ this.documentWrapper.View.Body.addSection({
17263
+ ...properties,
17193
17264
  footerWrapperGroup: {
17194
17265
  default: footers.default ? this.createFooter(footers.default) : void 0,
17195
17266
  even: footers.even ? this.createFooter(footers.even) : void 0,
@@ -17200,7 +17271,7 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
17200
17271
  even: headers.even ? this.createHeader(headers.even) : void 0,
17201
17272
  first: headers.first ? this.createHeader(headers.first) : void 0
17202
17273
  }
17203
- }));
17274
+ });
17204
17275
  for (const child of children) this.documentWrapper.View.add(child);
17205
17276
  }
17206
17277
  createHeader(header) {
@@ -17457,28 +17528,6 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
17457
17528
  }
17458
17529
  };
17459
17530
  //#endregion
17460
- //#region \0@oxc-project+runtime@0.123.0/helpers/objectWithoutPropertiesLoose.js
17461
- function _objectWithoutPropertiesLoose(r, e) {
17462
- if (null == r) return {};
17463
- var t = {};
17464
- for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
17465
- if (e.includes(n)) continue;
17466
- t[n] = r[n];
17467
- }
17468
- return t;
17469
- }
17470
- //#endregion
17471
- //#region \0@oxc-project+runtime@0.123.0/helpers/objectWithoutProperties.js
17472
- function _objectWithoutProperties(e, t) {
17473
- if (null == e) return {};
17474
- var o, r, i = _objectWithoutPropertiesLoose(e, t);
17475
- if (Object.getOwnPropertySymbols) {
17476
- var s = Object.getOwnPropertySymbols(e);
17477
- for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
17478
- }
17479
- return i;
17480
- }
17481
- //#endregion
17482
17531
  //#region src/file/table-of-contents/table-of-contents.ts
17483
17532
  /**
17484
17533
  * Table of Contents module for WordprocessingML documents.
@@ -17490,11 +17539,6 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
17490
17539
  *
17491
17540
  * @module
17492
17541
  */
17493
- const _excluded$1 = [
17494
- "contentChildren",
17495
- "cachedEntries",
17496
- "beginDirty"
17497
- ];
17498
17542
  /**
17499
17543
  * Represents a Table of Contents in a WordprocessingML document.
17500
17544
  *
@@ -17525,8 +17569,7 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
17525
17569
  * ```
17526
17570
  */
17527
17571
  var TableOfContents = class extends FileChild {
17528
- constructor(alias = "Table of Contents", _ref = {}) {
17529
- let { contentChildren = [], cachedEntries = [], beginDirty = true } = _ref, properties = _objectWithoutProperties(_ref, _excluded$1);
17572
+ constructor(alias = "Table of Contents", { contentChildren = [], cachedEntries = [], beginDirty = true, ...properties } = {}) {
17530
17573
  super("w:sdt");
17531
17574
  this.root.push(new StructuredDocumentTagProperties(alias));
17532
17575
  const content = new StructuredDocumentTagContent();
@@ -18222,7 +18265,6 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
18222
18265
  *
18223
18266
  * @module
18224
18267
  */
18225
- const _excluded = ["style", "children"];
18226
18268
  /**
18227
18269
  * Represents a textbox in a WordprocessingML document.
18228
18270
  *
@@ -18272,8 +18314,7 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
18272
18314
  * ```
18273
18315
  */
18274
18316
  var Textbox = class extends FileChild {
18275
- constructor(_ref) {
18276
- let { style, children } = _ref, rest = _objectWithoutProperties(_ref, _excluded);
18317
+ constructor({ style, children, ...rest }) {
18277
18318
  super("w:p");
18278
18319
  this.root.push(new ParagraphProperties(rest));
18279
18320
  this.root.push(createPictElement({ shape: createShape({
@@ -18284,118 +18325,3262 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
18284
18325
  }
18285
18326
  };
18286
18327
  //#endregion
18287
- //#region src/util/output-type.ts
18288
- /**
18289
- * Converts a Uint8Array to the specified output type.
18290
- *
18291
- * This is used by both the Packer and patchDocument to convert fflate's
18292
- * raw Uint8Array output into the user's requested format.
18293
- */
18294
- const convertOutput = (data, type) => {
18295
- switch (type) {
18296
- case "nodebuffer": return Buffer.from(data);
18297
- case "blob": return new Blob([data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength)], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" });
18298
- case "arraybuffer": return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
18299
- case "uint8array": return data;
18300
- case "base64": return Buffer.from(data).toString("base64");
18301
- case "string":
18302
- case "text": return Buffer.from(data).toString("binary");
18303
- case "binarystring": return Buffer.from(data).toString("binary");
18304
- case "array": return [...data];
18305
- default: return data;
18328
+ //#region \0polyfill-node.events.js
18329
+ var domain;
18330
+ function EventHandlers() {}
18331
+ EventHandlers.prototype = Object.create(null);
18332
+ function EventEmitter() {
18333
+ EventEmitter.init.call(this);
18334
+ }
18335
+ EventEmitter.EventEmitter = EventEmitter;
18336
+ EventEmitter.usingDomains = false;
18337
+ EventEmitter.prototype.domain = void 0;
18338
+ EventEmitter.prototype._events = void 0;
18339
+ EventEmitter.prototype._maxListeners = void 0;
18340
+ EventEmitter.defaultMaxListeners = 10;
18341
+ EventEmitter.init = function() {
18342
+ this.domain = null;
18343
+ if (EventEmitter.usingDomains) {
18344
+ if (domain.active && !(this instanceof domain.Domain)) this.domain = domain.active;
18345
+ }
18346
+ if (!this._events || this._events === Object.getPrototypeOf(this)._events) {
18347
+ this._events = new EventHandlers();
18348
+ this._eventsCount = 0;
18349
+ }
18350
+ this._maxListeners = this._maxListeners || void 0;
18351
+ };
18352
+ EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
18353
+ if (typeof n !== "number" || n < 0 || isNaN(n)) throw new TypeError("\"n\" argument must be a positive number");
18354
+ this._maxListeners = n;
18355
+ return this;
18356
+ };
18357
+ function $getMaxListeners(that) {
18358
+ if (that._maxListeners === void 0) return EventEmitter.defaultMaxListeners;
18359
+ return that._maxListeners;
18360
+ }
18361
+ EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
18362
+ return $getMaxListeners(this);
18363
+ };
18364
+ function emitNone(handler, isFn, self) {
18365
+ if (isFn) handler.call(self);
18366
+ else {
18367
+ var len = handler.length;
18368
+ var listeners = arrayClone(handler, len);
18369
+ for (var i = 0; i < len; ++i) listeners[i].call(self);
18370
+ }
18371
+ }
18372
+ function emitOne(handler, isFn, self, arg1) {
18373
+ if (isFn) handler.call(self, arg1);
18374
+ else {
18375
+ var len = handler.length;
18376
+ var listeners = arrayClone(handler, len);
18377
+ for (var i = 0; i < len; ++i) listeners[i].call(self, arg1);
18378
+ }
18379
+ }
18380
+ function emitTwo(handler, isFn, self, arg1, arg2) {
18381
+ if (isFn) handler.call(self, arg1, arg2);
18382
+ else {
18383
+ var len = handler.length;
18384
+ var listeners = arrayClone(handler, len);
18385
+ for (var i = 0; i < len; ++i) listeners[i].call(self, arg1, arg2);
18386
+ }
18387
+ }
18388
+ function emitThree(handler, isFn, self, arg1, arg2, arg3) {
18389
+ if (isFn) handler.call(self, arg1, arg2, arg3);
18390
+ else {
18391
+ var len = handler.length;
18392
+ var listeners = arrayClone(handler, len);
18393
+ for (var i = 0; i < len; ++i) listeners[i].call(self, arg1, arg2, arg3);
18394
+ }
18395
+ }
18396
+ function emitMany(handler, isFn, self, args) {
18397
+ if (isFn) handler.apply(self, args);
18398
+ else {
18399
+ var len = handler.length;
18400
+ var listeners = arrayClone(handler, len);
18401
+ for (var i = 0; i < len; ++i) listeners[i].apply(self, args);
18402
+ }
18403
+ }
18404
+ EventEmitter.prototype.emit = function emit(type) {
18405
+ var er, handler, len, args, i, events, domain;
18406
+ var needDomainExit = false;
18407
+ var doError = type === "error";
18408
+ events = this._events;
18409
+ if (events) doError = doError && events.error == null;
18410
+ else if (!doError) return false;
18411
+ domain = this.domain;
18412
+ if (doError) {
18413
+ er = arguments[1];
18414
+ if (domain) {
18415
+ if (!er) er = /* @__PURE__ */ new Error("Uncaught, unspecified \"error\" event");
18416
+ er.domainEmitter = this;
18417
+ er.domain = domain;
18418
+ er.domainThrown = false;
18419
+ domain.emit("error", er);
18420
+ } else if (er instanceof Error) throw er;
18421
+ else {
18422
+ var err = /* @__PURE__ */ new Error("Uncaught, unspecified \"error\" event. (" + er + ")");
18423
+ err.context = er;
18424
+ throw err;
18425
+ }
18426
+ return false;
18427
+ }
18428
+ handler = events[type];
18429
+ if (!handler) return false;
18430
+ var isFn = typeof handler === "function";
18431
+ len = arguments.length;
18432
+ switch (len) {
18433
+ case 1:
18434
+ emitNone(handler, isFn, this);
18435
+ break;
18436
+ case 2:
18437
+ emitOne(handler, isFn, this, arguments[1]);
18438
+ break;
18439
+ case 3:
18440
+ emitTwo(handler, isFn, this, arguments[1], arguments[2]);
18441
+ break;
18442
+ case 4:
18443
+ emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
18444
+ break;
18445
+ default:
18446
+ args = new Array(len - 1);
18447
+ for (i = 1; i < len; i++) args[i - 1] = arguments[i];
18448
+ emitMany(handler, isFn, this, args);
18449
+ }
18450
+ if (needDomainExit) domain.exit();
18451
+ return true;
18452
+ };
18453
+ function _addListener(target, type, listener, prepend) {
18454
+ var m;
18455
+ var events;
18456
+ var existing;
18457
+ if (typeof listener !== "function") throw new TypeError("\"listener\" argument must be a function");
18458
+ events = target._events;
18459
+ if (!events) {
18460
+ events = target._events = new EventHandlers();
18461
+ target._eventsCount = 0;
18462
+ } else {
18463
+ if (events.newListener) {
18464
+ target.emit("newListener", type, listener.listener ? listener.listener : listener);
18465
+ events = target._events;
18466
+ }
18467
+ existing = events[type];
18468
+ }
18469
+ if (!existing) {
18470
+ existing = events[type] = listener;
18471
+ ++target._eventsCount;
18472
+ } else {
18473
+ if (typeof existing === "function") existing = events[type] = prepend ? [listener, existing] : [existing, listener];
18474
+ else if (prepend) existing.unshift(listener);
18475
+ else existing.push(listener);
18476
+ if (!existing.warned) {
18477
+ m = $getMaxListeners(target);
18478
+ if (m && m > 0 && existing.length > m) {
18479
+ existing.warned = true;
18480
+ var w = /* @__PURE__ */ new Error("Possible EventEmitter memory leak detected. " + existing.length + " " + type + " listeners added. Use emitter.setMaxListeners() to increase limit");
18481
+ w.name = "MaxListenersExceededWarning";
18482
+ w.emitter = target;
18483
+ w.type = type;
18484
+ w.count = existing.length;
18485
+ emitWarning(w);
18486
+ }
18487
+ }
18488
+ }
18489
+ return target;
18490
+ }
18491
+ function emitWarning(e) {
18492
+ typeof console.warn === "function" ? console.warn(e) : console.log(e);
18493
+ }
18494
+ EventEmitter.prototype.addListener = function addListener(type, listener) {
18495
+ return _addListener(this, type, listener, false);
18496
+ };
18497
+ EventEmitter.prototype.on = EventEmitter.prototype.addListener;
18498
+ EventEmitter.prototype.prependListener = function prependListener(type, listener) {
18499
+ return _addListener(this, type, listener, true);
18500
+ };
18501
+ function _onceWrap(target, type, listener) {
18502
+ var fired = false;
18503
+ function g() {
18504
+ target.removeListener(type, g);
18505
+ if (!fired) {
18506
+ fired = true;
18507
+ listener.apply(target, arguments);
18508
+ }
18509
+ }
18510
+ g.listener = listener;
18511
+ return g;
18512
+ }
18513
+ EventEmitter.prototype.once = function once(type, listener) {
18514
+ if (typeof listener !== "function") throw new TypeError("\"listener\" argument must be a function");
18515
+ this.on(type, _onceWrap(this, type, listener));
18516
+ return this;
18517
+ };
18518
+ EventEmitter.prototype.prependOnceListener = function prependOnceListener(type, listener) {
18519
+ if (typeof listener !== "function") throw new TypeError("\"listener\" argument must be a function");
18520
+ this.prependListener(type, _onceWrap(this, type, listener));
18521
+ return this;
18522
+ };
18523
+ EventEmitter.prototype.removeListener = function removeListener(type, listener) {
18524
+ var list, events, position, i, originalListener;
18525
+ if (typeof listener !== "function") throw new TypeError("\"listener\" argument must be a function");
18526
+ events = this._events;
18527
+ if (!events) return this;
18528
+ list = events[type];
18529
+ if (!list) return this;
18530
+ if (list === listener || list.listener && list.listener === listener) if (--this._eventsCount === 0) this._events = new EventHandlers();
18531
+ else {
18532
+ delete events[type];
18533
+ if (events.removeListener) this.emit("removeListener", type, list.listener || listener);
18534
+ }
18535
+ else if (typeof list !== "function") {
18536
+ position = -1;
18537
+ for (i = list.length; i-- > 0;) if (list[i] === listener || list[i].listener && list[i].listener === listener) {
18538
+ originalListener = list[i].listener;
18539
+ position = i;
18540
+ break;
18541
+ }
18542
+ if (position < 0) return this;
18543
+ if (list.length === 1) {
18544
+ list[0] = void 0;
18545
+ if (--this._eventsCount === 0) {
18546
+ this._events = new EventHandlers();
18547
+ return this;
18548
+ } else delete events[type];
18549
+ } else spliceOne(list, position);
18550
+ if (events.removeListener) this.emit("removeListener", type, originalListener || listener);
18551
+ }
18552
+ return this;
18553
+ };
18554
+ EventEmitter.prototype.off = function(type, listener) {
18555
+ return this.removeListener(type, listener);
18556
+ };
18557
+ EventEmitter.prototype.removeAllListeners = function removeAllListeners(type) {
18558
+ var listeners, events = this._events;
18559
+ if (!events) return this;
18560
+ if (!events.removeListener) {
18561
+ if (arguments.length === 0) {
18562
+ this._events = new EventHandlers();
18563
+ this._eventsCount = 0;
18564
+ } else if (events[type]) if (--this._eventsCount === 0) this._events = new EventHandlers();
18565
+ else delete events[type];
18566
+ return this;
18567
+ }
18568
+ if (arguments.length === 0) {
18569
+ var keys = Object.keys(events);
18570
+ for (var i = 0, key; i < keys.length; ++i) {
18571
+ key = keys[i];
18572
+ if (key === "removeListener") continue;
18573
+ this.removeAllListeners(key);
18574
+ }
18575
+ this.removeAllListeners("removeListener");
18576
+ this._events = new EventHandlers();
18577
+ this._eventsCount = 0;
18578
+ return this;
18306
18579
  }
18580
+ listeners = events[type];
18581
+ if (typeof listeners === "function") this.removeListener(type, listeners);
18582
+ else if (listeners) do
18583
+ this.removeListener(type, listeners[listeners.length - 1]);
18584
+ while (listeners[0]);
18585
+ return this;
18586
+ };
18587
+ EventEmitter.prototype.listeners = function listeners(type) {
18588
+ var evlistener;
18589
+ var ret;
18590
+ var events = this._events;
18591
+ if (!events) ret = [];
18592
+ else {
18593
+ evlistener = events[type];
18594
+ if (!evlistener) ret = [];
18595
+ else if (typeof evlistener === "function") ret = [evlistener.listener || evlistener];
18596
+ else ret = unwrapListeners(evlistener);
18597
+ }
18598
+ return ret;
18599
+ };
18600
+ EventEmitter.listenerCount = function(emitter, type) {
18601
+ if (typeof emitter.listenerCount === "function") return emitter.listenerCount(type);
18602
+ else return listenerCount$1.call(emitter, type);
18603
+ };
18604
+ EventEmitter.prototype.listenerCount = listenerCount$1;
18605
+ function listenerCount$1(type) {
18606
+ var events = this._events;
18607
+ if (events) {
18608
+ var evlistener = events[type];
18609
+ if (typeof evlistener === "function") return 1;
18610
+ else if (evlistener) return evlistener.length;
18611
+ }
18612
+ return 0;
18613
+ }
18614
+ EventEmitter.prototype.eventNames = function eventNames() {
18615
+ return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
18307
18616
  };
18617
+ function spliceOne(list, index) {
18618
+ for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) list[i] = list[k];
18619
+ list.pop();
18620
+ }
18621
+ function arrayClone(arr, i) {
18622
+ var copy = new Array(i);
18623
+ while (i--) copy[i] = arr[i];
18624
+ return copy;
18625
+ }
18626
+ function unwrapListeners(arr) {
18627
+ var ret = new Array(arr.length);
18628
+ for (var i = 0; i < ret.length; ++i) ret[i] = arr[i].listener || arr[i];
18629
+ return ret;
18630
+ }
18308
18631
  //#endregion
18309
- //#region src/file/fonts/obfuscate-ttf-to-odttf.ts
18632
+ //#region \0polyfill-node.global.js
18633
+ var _polyfill_node_global_default = typeof _polyfill_node_global_default !== "undefined" ? _polyfill_node_global_default : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
18634
+ //#endregion
18635
+ //#region \0polyfill-node.buffer.js
18636
+ var lookup = [];
18637
+ var revLookup = [];
18638
+ var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
18639
+ var inited = false;
18640
+ function init() {
18641
+ inited = true;
18642
+ var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
18643
+ for (var i = 0, len = code.length; i < len; ++i) {
18644
+ lookup[i] = code[i];
18645
+ revLookup[code.charCodeAt(i)] = i;
18646
+ }
18647
+ revLookup["-".charCodeAt(0)] = 62;
18648
+ revLookup["_".charCodeAt(0)] = 63;
18649
+ }
18650
+ function toByteArray(b64) {
18651
+ if (!inited) init();
18652
+ var i, j, l, tmp, placeHolders, arr;
18653
+ var len = b64.length;
18654
+ if (len % 4 > 0) throw new Error("Invalid string. Length must be a multiple of 4");
18655
+ placeHolders = b64[len - 2] === "=" ? 2 : b64[len - 1] === "=" ? 1 : 0;
18656
+ arr = new Arr(len * 3 / 4 - placeHolders);
18657
+ l = placeHolders > 0 ? len - 4 : len;
18658
+ var L = 0;
18659
+ for (i = 0, j = 0; i < l; i += 4, j += 3) {
18660
+ tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)];
18661
+ arr[L++] = tmp >> 16 & 255;
18662
+ arr[L++] = tmp >> 8 & 255;
18663
+ arr[L++] = tmp & 255;
18664
+ }
18665
+ if (placeHolders === 2) {
18666
+ tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4;
18667
+ arr[L++] = tmp & 255;
18668
+ } else if (placeHolders === 1) {
18669
+ tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2;
18670
+ arr[L++] = tmp >> 8 & 255;
18671
+ arr[L++] = tmp & 255;
18672
+ }
18673
+ return arr;
18674
+ }
18675
+ function tripletToBase64(num) {
18676
+ return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
18677
+ }
18678
+ function encodeChunk(uint8, start, end) {
18679
+ var tmp;
18680
+ var output = [];
18681
+ for (var i = start; i < end; i += 3) {
18682
+ tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + uint8[i + 2];
18683
+ output.push(tripletToBase64(tmp));
18684
+ }
18685
+ return output.join("");
18686
+ }
18687
+ function fromByteArray(uint8) {
18688
+ if (!inited) init();
18689
+ var tmp;
18690
+ var len = uint8.length;
18691
+ var extraBytes = len % 3;
18692
+ var output = "";
18693
+ var parts = [];
18694
+ var maxChunkLength = 16383;
18695
+ for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength));
18696
+ if (extraBytes === 1) {
18697
+ tmp = uint8[len - 1];
18698
+ output += lookup[tmp >> 2];
18699
+ output += lookup[tmp << 4 & 63];
18700
+ output += "==";
18701
+ } else if (extraBytes === 2) {
18702
+ tmp = (uint8[len - 2] << 8) + uint8[len - 1];
18703
+ output += lookup[tmp >> 10];
18704
+ output += lookup[tmp >> 4 & 63];
18705
+ output += lookup[tmp << 2 & 63];
18706
+ output += "=";
18707
+ }
18708
+ parts.push(output);
18709
+ return parts.join("");
18710
+ }
18711
+ function read(buffer, offset, isLE, mLen, nBytes) {
18712
+ var e, m;
18713
+ var eLen = nBytes * 8 - mLen - 1;
18714
+ var eMax = (1 << eLen) - 1;
18715
+ var eBias = eMax >> 1;
18716
+ var nBits = -7;
18717
+ var i = isLE ? nBytes - 1 : 0;
18718
+ var d = isLE ? -1 : 1;
18719
+ var s = buffer[offset + i];
18720
+ i += d;
18721
+ e = s & (1 << -nBits) - 1;
18722
+ s >>= -nBits;
18723
+ nBits += eLen;
18724
+ for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8);
18725
+ m = e & (1 << -nBits) - 1;
18726
+ e >>= -nBits;
18727
+ nBits += mLen;
18728
+ for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8);
18729
+ if (e === 0) e = 1 - eBias;
18730
+ else if (e === eMax) return m ? NaN : (s ? -1 : 1) * Infinity;
18731
+ else {
18732
+ m = m + Math.pow(2, mLen);
18733
+ e = e - eBias;
18734
+ }
18735
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
18736
+ }
18737
+ function write(buffer, value, offset, isLE, mLen, nBytes) {
18738
+ var e, m, c;
18739
+ var eLen = nBytes * 8 - mLen - 1;
18740
+ var eMax = (1 << eLen) - 1;
18741
+ var eBias = eMax >> 1;
18742
+ var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
18743
+ var i = isLE ? 0 : nBytes - 1;
18744
+ var d = isLE ? 1 : -1;
18745
+ var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
18746
+ value = Math.abs(value);
18747
+ if (isNaN(value) || value === Infinity) {
18748
+ m = isNaN(value) ? 1 : 0;
18749
+ e = eMax;
18750
+ } else {
18751
+ e = Math.floor(Math.log(value) / Math.LN2);
18752
+ if (value * (c = Math.pow(2, -e)) < 1) {
18753
+ e--;
18754
+ c *= 2;
18755
+ }
18756
+ if (e + eBias >= 1) value += rt / c;
18757
+ else value += rt * Math.pow(2, 1 - eBias);
18758
+ if (value * c >= 2) {
18759
+ e++;
18760
+ c /= 2;
18761
+ }
18762
+ if (e + eBias >= eMax) {
18763
+ m = 0;
18764
+ e = eMax;
18765
+ } else if (e + eBias >= 1) {
18766
+ m = (value * c - 1) * Math.pow(2, mLen);
18767
+ e = e + eBias;
18768
+ } else {
18769
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
18770
+ e = 0;
18771
+ }
18772
+ }
18773
+ for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8);
18774
+ e = e << mLen | m;
18775
+ eLen += mLen;
18776
+ for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8);
18777
+ buffer[offset + i - d] |= s * 128;
18778
+ }
18779
+ var toString = {}.toString;
18780
+ var isArray$1 = Array.isArray || function(arr) {
18781
+ return toString.call(arr) == "[object Array]";
18782
+ };
18310
18783
  /**
18311
- * Font obfuscation module for embedding fonts in WordprocessingML documents.
18312
- *
18313
- * This module implements the OOXML font obfuscation algorithm used to embed
18314
- * fonts in DOCX documents. Obfuscation is required by the OOXML specification
18315
- * to prevent simple extraction of embedded font files.
18784
+ * If `Buffer.TYPED_ARRAY_SUPPORT`:
18785
+ * === true Use Uint8Array implementation (fastest)
18786
+ * === false Use Object implementation (most compatible, even IE6)
18316
18787
  *
18317
- * Reference: ECMA-376 Part 2, Section 11.1 (Font Embedding)
18788
+ * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
18789
+ * Opera 11.6+, iOS 4.2+.
18318
18790
  *
18319
- * @module
18320
- */
18321
- /** Start offset for obfuscation in the font file */
18322
- const obfuscatedStartOffset = 0;
18323
- /** End offset for obfuscation (first 32 bytes are obfuscated) */
18324
- const obfuscatedEndOffset = 32;
18325
- /** Expected GUID size (32 hex characters without dashes) */
18326
- const guidSize = 32;
18327
- /**
18328
- * Obfuscates a TrueType font file for embedding in OOXML documents.
18791
+ * Due to various browser bugs, sometimes the Object implementation will be used even
18792
+ * when the browser supports typed arrays.
18329
18793
  *
18330
- * The obfuscation algorithm XORs the first 32 bytes of the font file
18331
- * with a reversed byte sequence derived from the font's GUID key.
18332
- * This prevents simple extraction while maintaining font functionality.
18794
+ * Note:
18333
18795
  *
18334
- * @param buf - The original font file as a byte array
18335
- * @param fontKey - The GUID key for the font (with or without dashes)
18336
- * @returns The obfuscated font data
18337
- * @throws Error if the fontKey is not a valid 32-character GUID
18796
+ * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
18797
+ * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
18338
18798
  *
18339
- * @example
18340
- * ```typescript
18341
- * const fontData = readFileSync("font.ttf");
18342
- * const fontKey = "00000000-0000-0000-0000-000000000000";
18343
- * const obfuscatedData = obfuscate(fontData, fontKey);
18344
- * ```
18799
+ * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
18345
18800
  *
18346
- * @internal
18801
+ * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
18802
+ * incorrect length in some situations.
18803
+
18804
+ * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
18805
+ * get the Object implementation, which is slower but behaves correctly.
18347
18806
  */
18348
- const obfuscate = (buf, fontKey) => {
18349
- const guid = fontKey.replace(/-/g, "");
18350
- if (guid.length !== guidSize) throw new Error(`Error: Cannot extract GUID from font filename: ${fontKey}`);
18351
- const hexNumbers = guid.replace(/(..)/g, "$1 ").trim().split(" ").map((hexString) => parseInt(hexString, 16));
18352
- hexNumbers.reverse();
18353
- const obfuscatedBytes = buf.slice(obfuscatedStartOffset, obfuscatedEndOffset).map((byte, i) => byte ^ hexNumbers[i % hexNumbers.length]);
18354
- const out = new Uint8Array(obfuscatedStartOffset + obfuscatedBytes.length + Math.max(0, buf.length - obfuscatedEndOffset));
18355
- out.set(buf.slice(0, obfuscatedStartOffset));
18356
- out.set(obfuscatedBytes, obfuscatedStartOffset);
18357
- out.set(buf.slice(obfuscatedEndOffset), obfuscatedStartOffset + obfuscatedBytes.length);
18358
- return out;
18359
- };
18360
- //#endregion
18361
- //#region src/export/formatter.ts
18807
+ Buffer$1.TYPED_ARRAY_SUPPORT = _polyfill_node_global_default.TYPED_ARRAY_SUPPORT !== void 0 ? _polyfill_node_global_default.TYPED_ARRAY_SUPPORT : true;
18808
+ kMaxLength();
18809
+ function kMaxLength() {
18810
+ return Buffer$1.TYPED_ARRAY_SUPPORT ? 2147483647 : 1073741823;
18811
+ }
18812
+ function createBuffer(that, length) {
18813
+ if (kMaxLength() < length) throw new RangeError("Invalid typed array length");
18814
+ if (Buffer$1.TYPED_ARRAY_SUPPORT) {
18815
+ that = new Uint8Array(length);
18816
+ that.__proto__ = Buffer$1.prototype;
18817
+ } else {
18818
+ if (that === null) that = new Buffer$1(length);
18819
+ that.length = length;
18820
+ }
18821
+ return that;
18822
+ }
18362
18823
  /**
18363
- * Converts XML components into serializable objects ready for XML generation.
18364
- *
18365
- * The Formatter is responsible for preparing XML components for serialization by calling
18366
- * their prepForXml method with the appropriate context. This is a critical step in the
18367
- * export pipeline that transforms the declarative API objects into XML-compatible structures.
18824
+ * The Buffer constructor returns instances of `Uint8Array` that have their
18825
+ * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
18826
+ * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
18827
+ * and the `Uint8Array` methods. Square bracket notation works as expected -- it
18828
+ * returns a single octet.
18368
18829
  *
18369
- * @example
18370
- * ```typescript
18371
- * const formatter = new Formatter();
18372
- * const paragraph = new Paragraph("Hello World");
18373
- * const xmlObject = formatter.format(paragraph, context);
18374
- * ```
18830
+ * The `Uint8Array` prototype remains unmodified.
18375
18831
  */
18376
- var Formatter = class {
18377
- /**
18378
- * Formats an XML component into a serializable object.
18379
- *
18380
- * @param input - The XML component to format
18381
- * @param context - The context containing file state and relationships
18382
- * @returns A serializable XML object structure
18383
- * @throws Error if the component cannot be formatted correctly
18384
- */
18385
- format(input, context = { stack: [] }) {
18386
- const output = input.prepForXml(context);
18387
- if (output) return output;
18388
- else throw new Error("XMLComponent did not format correctly");
18832
+ function Buffer$1(arg, encodingOrOffset, length) {
18833
+ if (!Buffer$1.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer$1)) return new Buffer$1(arg, encodingOrOffset, length);
18834
+ if (typeof arg === "number") {
18835
+ if (typeof encodingOrOffset === "string") throw new Error("If encoding is specified then the first argument must be a string");
18836
+ return allocUnsafe(this, arg);
18389
18837
  }
18390
- };
18391
- //#endregion
18392
- //#region src/export/packer/image-replacer.ts
18838
+ return from(this, arg, encodingOrOffset, length);
18839
+ }
18840
+ Buffer$1.poolSize = 8192;
18841
+ Buffer$1._augment = function(arr) {
18842
+ arr.__proto__ = Buffer$1.prototype;
18843
+ return arr;
18844
+ };
18845
+ function from(that, value, encodingOrOffset, length) {
18846
+ if (typeof value === "number") throw new TypeError("\"value\" argument must not be a number");
18847
+ if (typeof ArrayBuffer !== "undefined" && value instanceof ArrayBuffer) return fromArrayBuffer(that, value, encodingOrOffset, length);
18848
+ if (typeof value === "string") return fromString(that, value, encodingOrOffset);
18849
+ return fromObject(that, value);
18850
+ }
18393
18851
  /**
18394
- * Replaces image placeholders with relationship IDs in XML content.
18395
- *
18396
- * During document compilation, images are referenced using placeholder tokens
18397
- * like {image1.png}. This class replaces those placeholders with the actual
18398
- * relationship IDs used in the OOXML structure.
18852
+ * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
18853
+ * if value is a number.
18854
+ * Buffer.from(str[, encoding])
18855
+ * Buffer.from(array)
18856
+ * Buffer.from(buffer)
18857
+ * Buffer.from(arrayBuffer[, byteOffset[, length]])
18858
+ **/
18859
+ Buffer$1.from = function(value, encodingOrOffset, length) {
18860
+ return from(null, value, encodingOrOffset, length);
18861
+ };
18862
+ if (Buffer$1.TYPED_ARRAY_SUPPORT) {
18863
+ Buffer$1.prototype.__proto__ = Uint8Array.prototype;
18864
+ Buffer$1.__proto__ = Uint8Array;
18865
+ if (typeof Symbol !== "undefined" && Symbol.species && Buffer$1[Symbol.species] === Buffer$1);
18866
+ }
18867
+ function assertSize(size) {
18868
+ if (typeof size !== "number") throw new TypeError("\"size\" argument must be a number");
18869
+ else if (size < 0) throw new RangeError("\"size\" argument must not be negative");
18870
+ }
18871
+ function alloc(that, size, fill, encoding) {
18872
+ assertSize(size);
18873
+ if (size <= 0) return createBuffer(that, size);
18874
+ if (fill !== void 0) return typeof encoding === "string" ? createBuffer(that, size).fill(fill, encoding) : createBuffer(that, size).fill(fill);
18875
+ return createBuffer(that, size);
18876
+ }
18877
+ /**
18878
+ * Creates a new filled Buffer instance.
18879
+ * alloc(size[, fill[, encoding]])
18880
+ **/
18881
+ Buffer$1.alloc = function(size, fill, encoding) {
18882
+ return alloc(null, size, fill, encoding);
18883
+ };
18884
+ function allocUnsafe(that, size) {
18885
+ assertSize(size);
18886
+ that = createBuffer(that, size < 0 ? 0 : checked(size) | 0);
18887
+ if (!Buffer$1.TYPED_ARRAY_SUPPORT) for (var i = 0; i < size; ++i) that[i] = 0;
18888
+ return that;
18889
+ }
18890
+ /**
18891
+ * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
18892
+ * */
18893
+ Buffer$1.allocUnsafe = function(size) {
18894
+ return allocUnsafe(null, size);
18895
+ };
18896
+ /**
18897
+ * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
18898
+ */
18899
+ Buffer$1.allocUnsafeSlow = function(size) {
18900
+ return allocUnsafe(null, size);
18901
+ };
18902
+ function fromString(that, string, encoding) {
18903
+ if (typeof encoding !== "string" || encoding === "") encoding = "utf8";
18904
+ if (!Buffer$1.isEncoding(encoding)) throw new TypeError("\"encoding\" must be a valid string encoding");
18905
+ var length = byteLength(string, encoding) | 0;
18906
+ that = createBuffer(that, length);
18907
+ var actual = that.write(string, encoding);
18908
+ if (actual !== length) that = that.slice(0, actual);
18909
+ return that;
18910
+ }
18911
+ function fromArrayLike(that, array) {
18912
+ var length = array.length < 0 ? 0 : checked(array.length) | 0;
18913
+ that = createBuffer(that, length);
18914
+ for (var i = 0; i < length; i += 1) that[i] = array[i] & 255;
18915
+ return that;
18916
+ }
18917
+ function fromArrayBuffer(that, array, byteOffset, length) {
18918
+ array.byteLength;
18919
+ if (byteOffset < 0 || array.byteLength < byteOffset) throw new RangeError("'offset' is out of bounds");
18920
+ if (array.byteLength < byteOffset + (length || 0)) throw new RangeError("'length' is out of bounds");
18921
+ if (byteOffset === void 0 && length === void 0) array = new Uint8Array(array);
18922
+ else if (length === void 0) array = new Uint8Array(array, byteOffset);
18923
+ else array = new Uint8Array(array, byteOffset, length);
18924
+ if (Buffer$1.TYPED_ARRAY_SUPPORT) {
18925
+ that = array;
18926
+ that.__proto__ = Buffer$1.prototype;
18927
+ } else that = fromArrayLike(that, array);
18928
+ return that;
18929
+ }
18930
+ function fromObject(that, obj) {
18931
+ if (internalIsBuffer(obj)) {
18932
+ var len = checked(obj.length) | 0;
18933
+ that = createBuffer(that, len);
18934
+ if (that.length === 0) return that;
18935
+ obj.copy(that, 0, 0, len);
18936
+ return that;
18937
+ }
18938
+ if (obj) {
18939
+ if (typeof ArrayBuffer !== "undefined" && obj.buffer instanceof ArrayBuffer || "length" in obj) {
18940
+ if (typeof obj.length !== "number" || isnan(obj.length)) return createBuffer(that, 0);
18941
+ return fromArrayLike(that, obj);
18942
+ }
18943
+ if (obj.type === "Buffer" && isArray$1(obj.data)) return fromArrayLike(that, obj.data);
18944
+ }
18945
+ throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.");
18946
+ }
18947
+ function checked(length) {
18948
+ if (length >= kMaxLength()) throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + kMaxLength().toString(16) + " bytes");
18949
+ return length | 0;
18950
+ }
18951
+ Buffer$1.isBuffer = isBuffer;
18952
+ function internalIsBuffer(b) {
18953
+ return !!(b != null && b._isBuffer);
18954
+ }
18955
+ Buffer$1.compare = function compare(a, b) {
18956
+ if (!internalIsBuffer(a) || !internalIsBuffer(b)) throw new TypeError("Arguments must be Buffers");
18957
+ if (a === b) return 0;
18958
+ var x = a.length;
18959
+ var y = b.length;
18960
+ for (var i = 0, len = Math.min(x, y); i < len; ++i) if (a[i] !== b[i]) {
18961
+ x = a[i];
18962
+ y = b[i];
18963
+ break;
18964
+ }
18965
+ if (x < y) return -1;
18966
+ if (y < x) return 1;
18967
+ return 0;
18968
+ };
18969
+ Buffer$1.isEncoding = function isEncoding(encoding) {
18970
+ switch (String(encoding).toLowerCase()) {
18971
+ case "hex":
18972
+ case "utf8":
18973
+ case "utf-8":
18974
+ case "ascii":
18975
+ case "latin1":
18976
+ case "binary":
18977
+ case "base64":
18978
+ case "ucs2":
18979
+ case "ucs-2":
18980
+ case "utf16le":
18981
+ case "utf-16le": return true;
18982
+ default: return false;
18983
+ }
18984
+ };
18985
+ Buffer$1.concat = function concat(list, length) {
18986
+ if (!isArray$1(list)) throw new TypeError("\"list\" argument must be an Array of Buffers");
18987
+ if (list.length === 0) return Buffer$1.alloc(0);
18988
+ var i;
18989
+ if (length === void 0) {
18990
+ length = 0;
18991
+ for (i = 0; i < list.length; ++i) length += list[i].length;
18992
+ }
18993
+ var buffer = Buffer$1.allocUnsafe(length);
18994
+ var pos = 0;
18995
+ for (i = 0; i < list.length; ++i) {
18996
+ var buf = list[i];
18997
+ if (!internalIsBuffer(buf)) throw new TypeError("\"list\" argument must be an Array of Buffers");
18998
+ buf.copy(buffer, pos);
18999
+ pos += buf.length;
19000
+ }
19001
+ return buffer;
19002
+ };
19003
+ function byteLength(string, encoding) {
19004
+ if (internalIsBuffer(string)) return string.length;
19005
+ if (typeof ArrayBuffer !== "undefined" && typeof ArrayBuffer.isView === "function" && (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) return string.byteLength;
19006
+ if (typeof string !== "string") string = "" + string;
19007
+ var len = string.length;
19008
+ if (len === 0) return 0;
19009
+ var loweredCase = false;
19010
+ for (;;) switch (encoding) {
19011
+ case "ascii":
19012
+ case "latin1":
19013
+ case "binary": return len;
19014
+ case "utf8":
19015
+ case "utf-8":
19016
+ case void 0: return utf8ToBytes(string).length;
19017
+ case "ucs2":
19018
+ case "ucs-2":
19019
+ case "utf16le":
19020
+ case "utf-16le": return len * 2;
19021
+ case "hex": return len >>> 1;
19022
+ case "base64": return base64ToBytes(string).length;
19023
+ default:
19024
+ if (loweredCase) return utf8ToBytes(string).length;
19025
+ encoding = ("" + encoding).toLowerCase();
19026
+ loweredCase = true;
19027
+ }
19028
+ }
19029
+ Buffer$1.byteLength = byteLength;
19030
+ function slowToString(encoding, start, end) {
19031
+ var loweredCase = false;
19032
+ if (start === void 0 || start < 0) start = 0;
19033
+ if (start > this.length) return "";
19034
+ if (end === void 0 || end > this.length) end = this.length;
19035
+ if (end <= 0) return "";
19036
+ end >>>= 0;
19037
+ start >>>= 0;
19038
+ if (end <= start) return "";
19039
+ if (!encoding) encoding = "utf8";
19040
+ while (true) switch (encoding) {
19041
+ case "hex": return hexSlice(this, start, end);
19042
+ case "utf8":
19043
+ case "utf-8": return utf8Slice(this, start, end);
19044
+ case "ascii": return asciiSlice(this, start, end);
19045
+ case "latin1":
19046
+ case "binary": return latin1Slice(this, start, end);
19047
+ case "base64": return base64Slice(this, start, end);
19048
+ case "ucs2":
19049
+ case "ucs-2":
19050
+ case "utf16le":
19051
+ case "utf-16le": return utf16leSlice(this, start, end);
19052
+ default:
19053
+ if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
19054
+ encoding = (encoding + "").toLowerCase();
19055
+ loweredCase = true;
19056
+ }
19057
+ }
19058
+ Buffer$1.prototype._isBuffer = true;
19059
+ function swap(b, n, m) {
19060
+ var i = b[n];
19061
+ b[n] = b[m];
19062
+ b[m] = i;
19063
+ }
19064
+ Buffer$1.prototype.swap16 = function swap16() {
19065
+ var len = this.length;
19066
+ if (len % 2 !== 0) throw new RangeError("Buffer size must be a multiple of 16-bits");
19067
+ for (var i = 0; i < len; i += 2) swap(this, i, i + 1);
19068
+ return this;
19069
+ };
19070
+ Buffer$1.prototype.swap32 = function swap32() {
19071
+ var len = this.length;
19072
+ if (len % 4 !== 0) throw new RangeError("Buffer size must be a multiple of 32-bits");
19073
+ for (var i = 0; i < len; i += 4) {
19074
+ swap(this, i, i + 3);
19075
+ swap(this, i + 1, i + 2);
19076
+ }
19077
+ return this;
19078
+ };
19079
+ Buffer$1.prototype.swap64 = function swap64() {
19080
+ var len = this.length;
19081
+ if (len % 8 !== 0) throw new RangeError("Buffer size must be a multiple of 64-bits");
19082
+ for (var i = 0; i < len; i += 8) {
19083
+ swap(this, i, i + 7);
19084
+ swap(this, i + 1, i + 6);
19085
+ swap(this, i + 2, i + 5);
19086
+ swap(this, i + 3, i + 4);
19087
+ }
19088
+ return this;
19089
+ };
19090
+ Buffer$1.prototype.toString = function toString() {
19091
+ var length = this.length | 0;
19092
+ if (length === 0) return "";
19093
+ if (arguments.length === 0) return utf8Slice(this, 0, length);
19094
+ return slowToString.apply(this, arguments);
19095
+ };
19096
+ Buffer$1.prototype.equals = function equals(b) {
19097
+ if (!internalIsBuffer(b)) throw new TypeError("Argument must be a Buffer");
19098
+ if (this === b) return true;
19099
+ return Buffer$1.compare(this, b) === 0;
19100
+ };
19101
+ Buffer$1.prototype.inspect = function inspect() {
19102
+ var str = "";
19103
+ var max = 50;
19104
+ if (this.length > 0) {
19105
+ str = this.toString("hex", 0, max).match(/.{2}/g).join(" ");
19106
+ if (this.length > max) str += " ... ";
19107
+ }
19108
+ return "<Buffer " + str + ">";
19109
+ };
19110
+ Buffer$1.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
19111
+ if (!internalIsBuffer(target)) throw new TypeError("Argument must be a Buffer");
19112
+ if (start === void 0) start = 0;
19113
+ if (end === void 0) end = target ? target.length : 0;
19114
+ if (thisStart === void 0) thisStart = 0;
19115
+ if (thisEnd === void 0) thisEnd = this.length;
19116
+ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) throw new RangeError("out of range index");
19117
+ if (thisStart >= thisEnd && start >= end) return 0;
19118
+ if (thisStart >= thisEnd) return -1;
19119
+ if (start >= end) return 1;
19120
+ start >>>= 0;
19121
+ end >>>= 0;
19122
+ thisStart >>>= 0;
19123
+ thisEnd >>>= 0;
19124
+ if (this === target) return 0;
19125
+ var x = thisEnd - thisStart;
19126
+ var y = end - start;
19127
+ var len = Math.min(x, y);
19128
+ var thisCopy = this.slice(thisStart, thisEnd);
19129
+ var targetCopy = target.slice(start, end);
19130
+ for (var i = 0; i < len; ++i) if (thisCopy[i] !== targetCopy[i]) {
19131
+ x = thisCopy[i];
19132
+ y = targetCopy[i];
19133
+ break;
19134
+ }
19135
+ if (x < y) return -1;
19136
+ if (y < x) return 1;
19137
+ return 0;
19138
+ };
19139
+ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
19140
+ if (buffer.length === 0) return -1;
19141
+ if (typeof byteOffset === "string") {
19142
+ encoding = byteOffset;
19143
+ byteOffset = 0;
19144
+ } else if (byteOffset > 2147483647) byteOffset = 2147483647;
19145
+ else if (byteOffset < -2147483648) byteOffset = -2147483648;
19146
+ byteOffset = +byteOffset;
19147
+ if (isNaN(byteOffset)) byteOffset = dir ? 0 : buffer.length - 1;
19148
+ if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
19149
+ if (byteOffset >= buffer.length) if (dir) return -1;
19150
+ else byteOffset = buffer.length - 1;
19151
+ else if (byteOffset < 0) if (dir) byteOffset = 0;
19152
+ else return -1;
19153
+ if (typeof val === "string") val = Buffer$1.from(val, encoding);
19154
+ if (internalIsBuffer(val)) {
19155
+ if (val.length === 0) return -1;
19156
+ return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
19157
+ } else if (typeof val === "number") {
19158
+ val = val & 255;
19159
+ if (Buffer$1.TYPED_ARRAY_SUPPORT && typeof Uint8Array.prototype.indexOf === "function") if (dir) return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
19160
+ else return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
19161
+ return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
19162
+ }
19163
+ throw new TypeError("val must be string, number or Buffer");
19164
+ }
19165
+ function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
19166
+ var indexSize = 1;
19167
+ var arrLength = arr.length;
19168
+ var valLength = val.length;
19169
+ if (encoding !== void 0) {
19170
+ encoding = String(encoding).toLowerCase();
19171
+ if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
19172
+ if (arr.length < 2 || val.length < 2) return -1;
19173
+ indexSize = 2;
19174
+ arrLength /= 2;
19175
+ valLength /= 2;
19176
+ byteOffset /= 2;
19177
+ }
19178
+ }
19179
+ function read(buf, i) {
19180
+ if (indexSize === 1) return buf[i];
19181
+ else return buf.readUInt16BE(i * indexSize);
19182
+ }
19183
+ var i;
19184
+ if (dir) {
19185
+ var foundIndex = -1;
19186
+ for (i = byteOffset; i < arrLength; i++) if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
19187
+ if (foundIndex === -1) foundIndex = i;
19188
+ if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;
19189
+ } else {
19190
+ if (foundIndex !== -1) i -= i - foundIndex;
19191
+ foundIndex = -1;
19192
+ }
19193
+ } else {
19194
+ if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
19195
+ for (i = byteOffset; i >= 0; i--) {
19196
+ var found = true;
19197
+ for (var j = 0; j < valLength; j++) if (read(arr, i + j) !== read(val, j)) {
19198
+ found = false;
19199
+ break;
19200
+ }
19201
+ if (found) return i;
19202
+ }
19203
+ }
19204
+ return -1;
19205
+ }
19206
+ Buffer$1.prototype.includes = function includes(val, byteOffset, encoding) {
19207
+ return this.indexOf(val, byteOffset, encoding) !== -1;
19208
+ };
19209
+ Buffer$1.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
19210
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
19211
+ };
19212
+ Buffer$1.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
19213
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
19214
+ };
19215
+ function hexWrite(buf, string, offset, length) {
19216
+ offset = Number(offset) || 0;
19217
+ var remaining = buf.length - offset;
19218
+ if (!length) length = remaining;
19219
+ else {
19220
+ length = Number(length);
19221
+ if (length > remaining) length = remaining;
19222
+ }
19223
+ var strLen = string.length;
19224
+ if (strLen % 2 !== 0) throw new TypeError("Invalid hex string");
19225
+ if (length > strLen / 2) length = strLen / 2;
19226
+ for (var i = 0; i < length; ++i) {
19227
+ var parsed = parseInt(string.substr(i * 2, 2), 16);
19228
+ if (isNaN(parsed)) return i;
19229
+ buf[offset + i] = parsed;
19230
+ }
19231
+ return i;
19232
+ }
19233
+ function utf8Write(buf, string, offset, length) {
19234
+ return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
19235
+ }
19236
+ function asciiWrite(buf, string, offset, length) {
19237
+ return blitBuffer(asciiToBytes(string), buf, offset, length);
19238
+ }
19239
+ function latin1Write(buf, string, offset, length) {
19240
+ return asciiWrite(buf, string, offset, length);
19241
+ }
19242
+ function base64Write(buf, string, offset, length) {
19243
+ return blitBuffer(base64ToBytes(string), buf, offset, length);
19244
+ }
19245
+ function ucs2Write(buf, string, offset, length) {
19246
+ return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
19247
+ }
19248
+ Buffer$1.prototype.write = function write(string, offset, length, encoding) {
19249
+ if (offset === void 0) {
19250
+ encoding = "utf8";
19251
+ length = this.length;
19252
+ offset = 0;
19253
+ } else if (length === void 0 && typeof offset === "string") {
19254
+ encoding = offset;
19255
+ length = this.length;
19256
+ offset = 0;
19257
+ } else if (isFinite(offset)) {
19258
+ offset = offset | 0;
19259
+ if (isFinite(length)) {
19260
+ length = length | 0;
19261
+ if (encoding === void 0) encoding = "utf8";
19262
+ } else {
19263
+ encoding = length;
19264
+ length = void 0;
19265
+ }
19266
+ } else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");
19267
+ var remaining = this.length - offset;
19268
+ if (length === void 0 || length > remaining) length = remaining;
19269
+ if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) throw new RangeError("Attempt to write outside buffer bounds");
19270
+ if (!encoding) encoding = "utf8";
19271
+ var loweredCase = false;
19272
+ for (;;) switch (encoding) {
19273
+ case "hex": return hexWrite(this, string, offset, length);
19274
+ case "utf8":
19275
+ case "utf-8": return utf8Write(this, string, offset, length);
19276
+ case "ascii": return asciiWrite(this, string, offset, length);
19277
+ case "latin1":
19278
+ case "binary": return latin1Write(this, string, offset, length);
19279
+ case "base64": return base64Write(this, string, offset, length);
19280
+ case "ucs2":
19281
+ case "ucs-2":
19282
+ case "utf16le":
19283
+ case "utf-16le": return ucs2Write(this, string, offset, length);
19284
+ default:
19285
+ if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
19286
+ encoding = ("" + encoding).toLowerCase();
19287
+ loweredCase = true;
19288
+ }
19289
+ };
19290
+ Buffer$1.prototype.toJSON = function toJSON() {
19291
+ return {
19292
+ type: "Buffer",
19293
+ data: Array.prototype.slice.call(this._arr || this, 0)
19294
+ };
19295
+ };
19296
+ function base64Slice(buf, start, end) {
19297
+ if (start === 0 && end === buf.length) return fromByteArray(buf);
19298
+ else return fromByteArray(buf.slice(start, end));
19299
+ }
19300
+ function utf8Slice(buf, start, end) {
19301
+ end = Math.min(buf.length, end);
19302
+ var res = [];
19303
+ var i = start;
19304
+ while (i < end) {
19305
+ var firstByte = buf[i];
19306
+ var codePoint = null;
19307
+ var bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
19308
+ if (i + bytesPerSequence <= end) {
19309
+ var secondByte, thirdByte, fourthByte, tempCodePoint;
19310
+ switch (bytesPerSequence) {
19311
+ case 1:
19312
+ if (firstByte < 128) codePoint = firstByte;
19313
+ break;
19314
+ case 2:
19315
+ secondByte = buf[i + 1];
19316
+ if ((secondByte & 192) === 128) {
19317
+ tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
19318
+ if (tempCodePoint > 127) codePoint = tempCodePoint;
19319
+ }
19320
+ break;
19321
+ case 3:
19322
+ secondByte = buf[i + 1];
19323
+ thirdByte = buf[i + 2];
19324
+ if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
19325
+ tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
19326
+ if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) codePoint = tempCodePoint;
19327
+ }
19328
+ break;
19329
+ case 4:
19330
+ secondByte = buf[i + 1];
19331
+ thirdByte = buf[i + 2];
19332
+ fourthByte = buf[i + 3];
19333
+ if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
19334
+ tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
19335
+ if (tempCodePoint > 65535 && tempCodePoint < 1114112) codePoint = tempCodePoint;
19336
+ }
19337
+ }
19338
+ }
19339
+ if (codePoint === null) {
19340
+ codePoint = 65533;
19341
+ bytesPerSequence = 1;
19342
+ } else if (codePoint > 65535) {
19343
+ codePoint -= 65536;
19344
+ res.push(codePoint >>> 10 & 1023 | 55296);
19345
+ codePoint = 56320 | codePoint & 1023;
19346
+ }
19347
+ res.push(codePoint);
19348
+ i += bytesPerSequence;
19349
+ }
19350
+ return decodeCodePointsArray(res);
19351
+ }
19352
+ var MAX_ARGUMENTS_LENGTH = 4096;
19353
+ function decodeCodePointsArray(codePoints) {
19354
+ var len = codePoints.length;
19355
+ if (len <= MAX_ARGUMENTS_LENGTH) return String.fromCharCode.apply(String, codePoints);
19356
+ var res = "";
19357
+ var i = 0;
19358
+ while (i < len) res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH));
19359
+ return res;
19360
+ }
19361
+ function asciiSlice(buf, start, end) {
19362
+ var ret = "";
19363
+ end = Math.min(buf.length, end);
19364
+ for (var i = start; i < end; ++i) ret += String.fromCharCode(buf[i] & 127);
19365
+ return ret;
19366
+ }
19367
+ function latin1Slice(buf, start, end) {
19368
+ var ret = "";
19369
+ end = Math.min(buf.length, end);
19370
+ for (var i = start; i < end; ++i) ret += String.fromCharCode(buf[i]);
19371
+ return ret;
19372
+ }
19373
+ function hexSlice(buf, start, end) {
19374
+ var len = buf.length;
19375
+ if (!start || start < 0) start = 0;
19376
+ if (!end || end < 0 || end > len) end = len;
19377
+ var out = "";
19378
+ for (var i = start; i < end; ++i) out += toHex(buf[i]);
19379
+ return out;
19380
+ }
19381
+ function utf16leSlice(buf, start, end) {
19382
+ var bytes = buf.slice(start, end);
19383
+ var res = "";
19384
+ for (var i = 0; i < bytes.length; i += 2) res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
19385
+ return res;
19386
+ }
19387
+ Buffer$1.prototype.slice = function slice(start, end) {
19388
+ var len = this.length;
19389
+ start = ~~start;
19390
+ end = end === void 0 ? len : ~~end;
19391
+ if (start < 0) {
19392
+ start += len;
19393
+ if (start < 0) start = 0;
19394
+ } else if (start > len) start = len;
19395
+ if (end < 0) {
19396
+ end += len;
19397
+ if (end < 0) end = 0;
19398
+ } else if (end > len) end = len;
19399
+ if (end < start) end = start;
19400
+ var newBuf;
19401
+ if (Buffer$1.TYPED_ARRAY_SUPPORT) {
19402
+ newBuf = this.subarray(start, end);
19403
+ newBuf.__proto__ = Buffer$1.prototype;
19404
+ } else {
19405
+ var sliceLen = end - start;
19406
+ newBuf = new Buffer$1(sliceLen, void 0);
19407
+ for (var i = 0; i < sliceLen; ++i) newBuf[i] = this[i + start];
19408
+ }
19409
+ return newBuf;
19410
+ };
19411
+ function checkOffset(offset, ext, length) {
19412
+ if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint");
19413
+ if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length");
19414
+ }
19415
+ Buffer$1.prototype.readUIntLE = function readUIntLE(offset, byteLength, noAssert) {
19416
+ offset = offset | 0;
19417
+ byteLength = byteLength | 0;
19418
+ if (!noAssert) checkOffset(offset, byteLength, this.length);
19419
+ var val = this[offset];
19420
+ var mul = 1;
19421
+ var i = 0;
19422
+ while (++i < byteLength && (mul *= 256)) val += this[offset + i] * mul;
19423
+ return val;
19424
+ };
19425
+ Buffer$1.prototype.readUIntBE = function readUIntBE(offset, byteLength, noAssert) {
19426
+ offset = offset | 0;
19427
+ byteLength = byteLength | 0;
19428
+ if (!noAssert) checkOffset(offset, byteLength, this.length);
19429
+ var val = this[offset + --byteLength];
19430
+ var mul = 1;
19431
+ while (byteLength > 0 && (mul *= 256)) val += this[offset + --byteLength] * mul;
19432
+ return val;
19433
+ };
19434
+ Buffer$1.prototype.readUInt8 = function readUInt8(offset, noAssert) {
19435
+ if (!noAssert) checkOffset(offset, 1, this.length);
19436
+ return this[offset];
19437
+ };
19438
+ Buffer$1.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
19439
+ if (!noAssert) checkOffset(offset, 2, this.length);
19440
+ return this[offset] | this[offset + 1] << 8;
19441
+ };
19442
+ Buffer$1.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
19443
+ if (!noAssert) checkOffset(offset, 2, this.length);
19444
+ return this[offset] << 8 | this[offset + 1];
19445
+ };
19446
+ Buffer$1.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
19447
+ if (!noAssert) checkOffset(offset, 4, this.length);
19448
+ return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
19449
+ };
19450
+ Buffer$1.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
19451
+ if (!noAssert) checkOffset(offset, 4, this.length);
19452
+ return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
19453
+ };
19454
+ Buffer$1.prototype.readIntLE = function readIntLE(offset, byteLength, noAssert) {
19455
+ offset = offset | 0;
19456
+ byteLength = byteLength | 0;
19457
+ if (!noAssert) checkOffset(offset, byteLength, this.length);
19458
+ var val = this[offset];
19459
+ var mul = 1;
19460
+ var i = 0;
19461
+ while (++i < byteLength && (mul *= 256)) val += this[offset + i] * mul;
19462
+ mul *= 128;
19463
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength);
19464
+ return val;
19465
+ };
19466
+ Buffer$1.prototype.readIntBE = function readIntBE(offset, byteLength, noAssert) {
19467
+ offset = offset | 0;
19468
+ byteLength = byteLength | 0;
19469
+ if (!noAssert) checkOffset(offset, byteLength, this.length);
19470
+ var i = byteLength;
19471
+ var mul = 1;
19472
+ var val = this[offset + --i];
19473
+ while (i > 0 && (mul *= 256)) val += this[offset + --i] * mul;
19474
+ mul *= 128;
19475
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength);
19476
+ return val;
19477
+ };
19478
+ Buffer$1.prototype.readInt8 = function readInt8(offset, noAssert) {
19479
+ if (!noAssert) checkOffset(offset, 1, this.length);
19480
+ if (!(this[offset] & 128)) return this[offset];
19481
+ return (255 - this[offset] + 1) * -1;
19482
+ };
19483
+ Buffer$1.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
19484
+ if (!noAssert) checkOffset(offset, 2, this.length);
19485
+ var val = this[offset] | this[offset + 1] << 8;
19486
+ return val & 32768 ? val | 4294901760 : val;
19487
+ };
19488
+ Buffer$1.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
19489
+ if (!noAssert) checkOffset(offset, 2, this.length);
19490
+ var val = this[offset + 1] | this[offset] << 8;
19491
+ return val & 32768 ? val | 4294901760 : val;
19492
+ };
19493
+ Buffer$1.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
19494
+ if (!noAssert) checkOffset(offset, 4, this.length);
19495
+ return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
19496
+ };
19497
+ Buffer$1.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
19498
+ if (!noAssert) checkOffset(offset, 4, this.length);
19499
+ return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
19500
+ };
19501
+ Buffer$1.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
19502
+ if (!noAssert) checkOffset(offset, 4, this.length);
19503
+ return read(this, offset, true, 23, 4);
19504
+ };
19505
+ Buffer$1.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
19506
+ if (!noAssert) checkOffset(offset, 4, this.length);
19507
+ return read(this, offset, false, 23, 4);
19508
+ };
19509
+ Buffer$1.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
19510
+ if (!noAssert) checkOffset(offset, 8, this.length);
19511
+ return read(this, offset, true, 52, 8);
19512
+ };
19513
+ Buffer$1.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
19514
+ if (!noAssert) checkOffset(offset, 8, this.length);
19515
+ return read(this, offset, false, 52, 8);
19516
+ };
19517
+ function checkInt(buf, value, offset, ext, max, min) {
19518
+ if (!internalIsBuffer(buf)) throw new TypeError("\"buffer\" argument must be a Buffer instance");
19519
+ if (value > max || value < min) throw new RangeError("\"value\" argument is out of bounds");
19520
+ if (offset + ext > buf.length) throw new RangeError("Index out of range");
19521
+ }
19522
+ Buffer$1.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength, noAssert) {
19523
+ value = +value;
19524
+ offset = offset | 0;
19525
+ byteLength = byteLength | 0;
19526
+ if (!noAssert) {
19527
+ var maxBytes = Math.pow(2, 8 * byteLength) - 1;
19528
+ checkInt(this, value, offset, byteLength, maxBytes, 0);
19529
+ }
19530
+ var mul = 1;
19531
+ var i = 0;
19532
+ this[offset] = value & 255;
19533
+ while (++i < byteLength && (mul *= 256)) this[offset + i] = value / mul & 255;
19534
+ return offset + byteLength;
19535
+ };
19536
+ Buffer$1.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength, noAssert) {
19537
+ value = +value;
19538
+ offset = offset | 0;
19539
+ byteLength = byteLength | 0;
19540
+ if (!noAssert) {
19541
+ var maxBytes = Math.pow(2, 8 * byteLength) - 1;
19542
+ checkInt(this, value, offset, byteLength, maxBytes, 0);
19543
+ }
19544
+ var i = byteLength - 1;
19545
+ var mul = 1;
19546
+ this[offset + i] = value & 255;
19547
+ while (--i >= 0 && (mul *= 256)) this[offset + i] = value / mul & 255;
19548
+ return offset + byteLength;
19549
+ };
19550
+ Buffer$1.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
19551
+ value = +value;
19552
+ offset = offset | 0;
19553
+ if (!noAssert) checkInt(this, value, offset, 1, 255, 0);
19554
+ if (!Buffer$1.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
19555
+ this[offset] = value & 255;
19556
+ return offset + 1;
19557
+ };
19558
+ function objectWriteUInt16(buf, value, offset, littleEndian) {
19559
+ if (value < 0) value = 65535 + value + 1;
19560
+ for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) buf[offset + i] = (value & 255 << 8 * (littleEndian ? i : 1 - i)) >>> (littleEndian ? i : 1 - i) * 8;
19561
+ }
19562
+ Buffer$1.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
19563
+ value = +value;
19564
+ offset = offset | 0;
19565
+ if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
19566
+ if (Buffer$1.TYPED_ARRAY_SUPPORT) {
19567
+ this[offset] = value & 255;
19568
+ this[offset + 1] = value >>> 8;
19569
+ } else objectWriteUInt16(this, value, offset, true);
19570
+ return offset + 2;
19571
+ };
19572
+ Buffer$1.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
19573
+ value = +value;
19574
+ offset = offset | 0;
19575
+ if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
19576
+ if (Buffer$1.TYPED_ARRAY_SUPPORT) {
19577
+ this[offset] = value >>> 8;
19578
+ this[offset + 1] = value & 255;
19579
+ } else objectWriteUInt16(this, value, offset, false);
19580
+ return offset + 2;
19581
+ };
19582
+ function objectWriteUInt32(buf, value, offset, littleEndian) {
19583
+ if (value < 0) value = 4294967295 + value + 1;
19584
+ for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) buf[offset + i] = value >>> (littleEndian ? i : 3 - i) * 8 & 255;
19585
+ }
19586
+ Buffer$1.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
19587
+ value = +value;
19588
+ offset = offset | 0;
19589
+ if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
19590
+ if (Buffer$1.TYPED_ARRAY_SUPPORT) {
19591
+ this[offset + 3] = value >>> 24;
19592
+ this[offset + 2] = value >>> 16;
19593
+ this[offset + 1] = value >>> 8;
19594
+ this[offset] = value & 255;
19595
+ } else objectWriteUInt32(this, value, offset, true);
19596
+ return offset + 4;
19597
+ };
19598
+ Buffer$1.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
19599
+ value = +value;
19600
+ offset = offset | 0;
19601
+ if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
19602
+ if (Buffer$1.TYPED_ARRAY_SUPPORT) {
19603
+ this[offset] = value >>> 24;
19604
+ this[offset + 1] = value >>> 16;
19605
+ this[offset + 2] = value >>> 8;
19606
+ this[offset + 3] = value & 255;
19607
+ } else objectWriteUInt32(this, value, offset, false);
19608
+ return offset + 4;
19609
+ };
19610
+ Buffer$1.prototype.writeIntLE = function writeIntLE(value, offset, byteLength, noAssert) {
19611
+ value = +value;
19612
+ offset = offset | 0;
19613
+ if (!noAssert) {
19614
+ var limit = Math.pow(2, 8 * byteLength - 1);
19615
+ checkInt(this, value, offset, byteLength, limit - 1, -limit);
19616
+ }
19617
+ var i = 0;
19618
+ var mul = 1;
19619
+ var sub = 0;
19620
+ this[offset] = value & 255;
19621
+ while (++i < byteLength && (mul *= 256)) {
19622
+ if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) sub = 1;
19623
+ this[offset + i] = (value / mul >> 0) - sub & 255;
19624
+ }
19625
+ return offset + byteLength;
19626
+ };
19627
+ Buffer$1.prototype.writeIntBE = function writeIntBE(value, offset, byteLength, noAssert) {
19628
+ value = +value;
19629
+ offset = offset | 0;
19630
+ if (!noAssert) {
19631
+ var limit = Math.pow(2, 8 * byteLength - 1);
19632
+ checkInt(this, value, offset, byteLength, limit - 1, -limit);
19633
+ }
19634
+ var i = byteLength - 1;
19635
+ var mul = 1;
19636
+ var sub = 0;
19637
+ this[offset + i] = value & 255;
19638
+ while (--i >= 0 && (mul *= 256)) {
19639
+ if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) sub = 1;
19640
+ this[offset + i] = (value / mul >> 0) - sub & 255;
19641
+ }
19642
+ return offset + byteLength;
19643
+ };
19644
+ Buffer$1.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
19645
+ value = +value;
19646
+ offset = offset | 0;
19647
+ if (!noAssert) checkInt(this, value, offset, 1, 127, -128);
19648
+ if (!Buffer$1.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
19649
+ if (value < 0) value = 255 + value + 1;
19650
+ this[offset] = value & 255;
19651
+ return offset + 1;
19652
+ };
19653
+ Buffer$1.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
19654
+ value = +value;
19655
+ offset = offset | 0;
19656
+ if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
19657
+ if (Buffer$1.TYPED_ARRAY_SUPPORT) {
19658
+ this[offset] = value & 255;
19659
+ this[offset + 1] = value >>> 8;
19660
+ } else objectWriteUInt16(this, value, offset, true);
19661
+ return offset + 2;
19662
+ };
19663
+ Buffer$1.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
19664
+ value = +value;
19665
+ offset = offset | 0;
19666
+ if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
19667
+ if (Buffer$1.TYPED_ARRAY_SUPPORT) {
19668
+ this[offset] = value >>> 8;
19669
+ this[offset + 1] = value & 255;
19670
+ } else objectWriteUInt16(this, value, offset, false);
19671
+ return offset + 2;
19672
+ };
19673
+ Buffer$1.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
19674
+ value = +value;
19675
+ offset = offset | 0;
19676
+ if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
19677
+ if (Buffer$1.TYPED_ARRAY_SUPPORT) {
19678
+ this[offset] = value & 255;
19679
+ this[offset + 1] = value >>> 8;
19680
+ this[offset + 2] = value >>> 16;
19681
+ this[offset + 3] = value >>> 24;
19682
+ } else objectWriteUInt32(this, value, offset, true);
19683
+ return offset + 4;
19684
+ };
19685
+ Buffer$1.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
19686
+ value = +value;
19687
+ offset = offset | 0;
19688
+ if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
19689
+ if (value < 0) value = 4294967295 + value + 1;
19690
+ if (Buffer$1.TYPED_ARRAY_SUPPORT) {
19691
+ this[offset] = value >>> 24;
19692
+ this[offset + 1] = value >>> 16;
19693
+ this[offset + 2] = value >>> 8;
19694
+ this[offset + 3] = value & 255;
19695
+ } else objectWriteUInt32(this, value, offset, false);
19696
+ return offset + 4;
19697
+ };
19698
+ function checkIEEE754(buf, value, offset, ext, max, min) {
19699
+ if (offset + ext > buf.length) throw new RangeError("Index out of range");
19700
+ if (offset < 0) throw new RangeError("Index out of range");
19701
+ }
19702
+ function writeFloat(buf, value, offset, littleEndian, noAssert) {
19703
+ if (!noAssert) checkIEEE754(buf, value, offset, 4);
19704
+ write(buf, value, offset, littleEndian, 23, 4);
19705
+ return offset + 4;
19706
+ }
19707
+ Buffer$1.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
19708
+ return writeFloat(this, value, offset, true, noAssert);
19709
+ };
19710
+ Buffer$1.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
19711
+ return writeFloat(this, value, offset, false, noAssert);
19712
+ };
19713
+ function writeDouble(buf, value, offset, littleEndian, noAssert) {
19714
+ if (!noAssert) checkIEEE754(buf, value, offset, 8);
19715
+ write(buf, value, offset, littleEndian, 52, 8);
19716
+ return offset + 8;
19717
+ }
19718
+ Buffer$1.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
19719
+ return writeDouble(this, value, offset, true, noAssert);
19720
+ };
19721
+ Buffer$1.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
19722
+ return writeDouble(this, value, offset, false, noAssert);
19723
+ };
19724
+ Buffer$1.prototype.copy = function copy(target, targetStart, start, end) {
19725
+ if (!start) start = 0;
19726
+ if (!end && end !== 0) end = this.length;
19727
+ if (targetStart >= target.length) targetStart = target.length;
19728
+ if (!targetStart) targetStart = 0;
19729
+ if (end > 0 && end < start) end = start;
19730
+ if (end === start) return 0;
19731
+ if (target.length === 0 || this.length === 0) return 0;
19732
+ if (targetStart < 0) throw new RangeError("targetStart out of bounds");
19733
+ if (start < 0 || start >= this.length) throw new RangeError("sourceStart out of bounds");
19734
+ if (end < 0) throw new RangeError("sourceEnd out of bounds");
19735
+ if (end > this.length) end = this.length;
19736
+ if (target.length - targetStart < end - start) end = target.length - targetStart + start;
19737
+ var len = end - start;
19738
+ var i;
19739
+ if (this === target && start < targetStart && targetStart < end) for (i = len - 1; i >= 0; --i) target[i + targetStart] = this[i + start];
19740
+ else if (len < 1e3 || !Buffer$1.TYPED_ARRAY_SUPPORT) for (i = 0; i < len; ++i) target[i + targetStart] = this[i + start];
19741
+ else Uint8Array.prototype.set.call(target, this.subarray(start, start + len), targetStart);
19742
+ return len;
19743
+ };
19744
+ Buffer$1.prototype.fill = function fill(val, start, end, encoding) {
19745
+ if (typeof val === "string") {
19746
+ if (typeof start === "string") {
19747
+ encoding = start;
19748
+ start = 0;
19749
+ end = this.length;
19750
+ } else if (typeof end === "string") {
19751
+ encoding = end;
19752
+ end = this.length;
19753
+ }
19754
+ if (val.length === 1) {
19755
+ var code = val.charCodeAt(0);
19756
+ if (code < 256) val = code;
19757
+ }
19758
+ if (encoding !== void 0 && typeof encoding !== "string") throw new TypeError("encoding must be a string");
19759
+ if (typeof encoding === "string" && !Buffer$1.isEncoding(encoding)) throw new TypeError("Unknown encoding: " + encoding);
19760
+ } else if (typeof val === "number") val = val & 255;
19761
+ if (start < 0 || this.length < start || this.length < end) throw new RangeError("Out of range index");
19762
+ if (end <= start) return this;
19763
+ start = start >>> 0;
19764
+ end = end === void 0 ? this.length : end >>> 0;
19765
+ if (!val) val = 0;
19766
+ var i;
19767
+ if (typeof val === "number") for (i = start; i < end; ++i) this[i] = val;
19768
+ else {
19769
+ var bytes = internalIsBuffer(val) ? val : utf8ToBytes(new Buffer$1(val, encoding).toString());
19770
+ var len = bytes.length;
19771
+ for (i = 0; i < end - start; ++i) this[i + start] = bytes[i % len];
19772
+ }
19773
+ return this;
19774
+ };
19775
+ var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g;
19776
+ function base64clean(str) {
19777
+ str = stringtrim(str).replace(INVALID_BASE64_RE, "");
19778
+ if (str.length < 2) return "";
19779
+ while (str.length % 4 !== 0) str = str + "=";
19780
+ return str;
19781
+ }
19782
+ function stringtrim(str) {
19783
+ if (str.trim) return str.trim();
19784
+ return str.replace(/^\s+|\s+$/g, "");
19785
+ }
19786
+ function toHex(n) {
19787
+ if (n < 16) return "0" + n.toString(16);
19788
+ return n.toString(16);
19789
+ }
19790
+ function utf8ToBytes(string, units) {
19791
+ units = units || Infinity;
19792
+ var codePoint;
19793
+ var length = string.length;
19794
+ var leadSurrogate = null;
19795
+ var bytes = [];
19796
+ for (var i = 0; i < length; ++i) {
19797
+ codePoint = string.charCodeAt(i);
19798
+ if (codePoint > 55295 && codePoint < 57344) {
19799
+ if (!leadSurrogate) {
19800
+ if (codePoint > 56319) {
19801
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
19802
+ continue;
19803
+ } else if (i + 1 === length) {
19804
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
19805
+ continue;
19806
+ }
19807
+ leadSurrogate = codePoint;
19808
+ continue;
19809
+ }
19810
+ if (codePoint < 56320) {
19811
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
19812
+ leadSurrogate = codePoint;
19813
+ continue;
19814
+ }
19815
+ codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
19816
+ } else if (leadSurrogate) {
19817
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
19818
+ }
19819
+ leadSurrogate = null;
19820
+ if (codePoint < 128) {
19821
+ if ((units -= 1) < 0) break;
19822
+ bytes.push(codePoint);
19823
+ } else if (codePoint < 2048) {
19824
+ if ((units -= 2) < 0) break;
19825
+ bytes.push(codePoint >> 6 | 192, codePoint & 63 | 128);
19826
+ } else if (codePoint < 65536) {
19827
+ if ((units -= 3) < 0) break;
19828
+ bytes.push(codePoint >> 12 | 224, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
19829
+ } else if (codePoint < 1114112) {
19830
+ if ((units -= 4) < 0) break;
19831
+ bytes.push(codePoint >> 18 | 240, codePoint >> 12 & 63 | 128, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
19832
+ } else throw new Error("Invalid code point");
19833
+ }
19834
+ return bytes;
19835
+ }
19836
+ function asciiToBytes(str) {
19837
+ var byteArray = [];
19838
+ for (var i = 0; i < str.length; ++i) byteArray.push(str.charCodeAt(i) & 255);
19839
+ return byteArray;
19840
+ }
19841
+ function utf16leToBytes(str, units) {
19842
+ var c, hi, lo;
19843
+ var byteArray = [];
19844
+ for (var i = 0; i < str.length; ++i) {
19845
+ if ((units -= 2) < 0) break;
19846
+ c = str.charCodeAt(i);
19847
+ hi = c >> 8;
19848
+ lo = c % 256;
19849
+ byteArray.push(lo);
19850
+ byteArray.push(hi);
19851
+ }
19852
+ return byteArray;
19853
+ }
19854
+ function base64ToBytes(str) {
19855
+ return toByteArray(base64clean(str));
19856
+ }
19857
+ function blitBuffer(src, dst, offset, length) {
19858
+ for (var i = 0; i < length; ++i) {
19859
+ if (i + offset >= dst.length || i >= src.length) break;
19860
+ dst[i + offset] = src[i];
19861
+ }
19862
+ return i;
19863
+ }
19864
+ function isnan(val) {
19865
+ return val !== val;
19866
+ }
19867
+ function isBuffer(obj) {
19868
+ return obj != null && (!!obj._isBuffer || isFastBuffer(obj) || isSlowBuffer(obj));
19869
+ }
19870
+ function isFastBuffer(obj) {
19871
+ return !!obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
19872
+ }
19873
+ function isSlowBuffer(obj) {
19874
+ return typeof obj.readFloatLE === "function" && typeof obj.slice === "function" && isFastBuffer(obj.slice(0, 0));
19875
+ }
19876
+ //#endregion
19877
+ //#region \0polyfill-node.process.js
19878
+ function defaultSetTimout() {
19879
+ throw new Error("setTimeout has not been defined");
19880
+ }
19881
+ function defaultClearTimeout() {
19882
+ throw new Error("clearTimeout has not been defined");
19883
+ }
19884
+ var cachedSetTimeout = defaultSetTimout;
19885
+ var cachedClearTimeout = defaultClearTimeout;
19886
+ if (typeof _polyfill_node_global_default.setTimeout === "function") cachedSetTimeout = setTimeout;
19887
+ if (typeof _polyfill_node_global_default.clearTimeout === "function") cachedClearTimeout = clearTimeout;
19888
+ function runTimeout(fun) {
19889
+ if (cachedSetTimeout === setTimeout) return setTimeout(fun, 0);
19890
+ if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
19891
+ cachedSetTimeout = setTimeout;
19892
+ return setTimeout(fun, 0);
19893
+ }
19894
+ try {
19895
+ return cachedSetTimeout(fun, 0);
19896
+ } catch (e) {
19897
+ try {
19898
+ return cachedSetTimeout.call(null, fun, 0);
19899
+ } catch (e) {
19900
+ return cachedSetTimeout.call(this, fun, 0);
19901
+ }
19902
+ }
19903
+ }
19904
+ function runClearTimeout(marker) {
19905
+ if (cachedClearTimeout === clearTimeout) return clearTimeout(marker);
19906
+ if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
19907
+ cachedClearTimeout = clearTimeout;
19908
+ return clearTimeout(marker);
19909
+ }
19910
+ try {
19911
+ return cachedClearTimeout(marker);
19912
+ } catch (e) {
19913
+ try {
19914
+ return cachedClearTimeout.call(null, marker);
19915
+ } catch (e) {
19916
+ return cachedClearTimeout.call(this, marker);
19917
+ }
19918
+ }
19919
+ }
19920
+ var queue = [];
19921
+ var draining = false;
19922
+ var currentQueue;
19923
+ var queueIndex = -1;
19924
+ function cleanUpNextTick() {
19925
+ if (!draining || !currentQueue) return;
19926
+ draining = false;
19927
+ if (currentQueue.length) queue = currentQueue.concat(queue);
19928
+ else queueIndex = -1;
19929
+ if (queue.length) drainQueue();
19930
+ }
19931
+ function drainQueue() {
19932
+ if (draining) return;
19933
+ var timeout = runTimeout(cleanUpNextTick);
19934
+ draining = true;
19935
+ var len = queue.length;
19936
+ while (len) {
19937
+ currentQueue = queue;
19938
+ queue = [];
19939
+ while (++queueIndex < len) if (currentQueue) currentQueue[queueIndex].run();
19940
+ queueIndex = -1;
19941
+ len = queue.length;
19942
+ }
19943
+ currentQueue = null;
19944
+ draining = false;
19945
+ runClearTimeout(timeout);
19946
+ }
19947
+ function nextTick(fun) {
19948
+ var args = new Array(arguments.length - 1);
19949
+ if (arguments.length > 1) for (var i = 1; i < arguments.length; i++) args[i - 1] = arguments[i];
19950
+ queue.push(new Item(fun, args));
19951
+ if (queue.length === 1 && !draining) runTimeout(drainQueue);
19952
+ }
19953
+ function Item(fun, array) {
19954
+ this.fun = fun;
19955
+ this.array = array;
19956
+ }
19957
+ Item.prototype.run = function() {
19958
+ this.fun.apply(null, this.array);
19959
+ };
19960
+ var title = "browser";
19961
+ var platform = "browser";
19962
+ var env = {};
19963
+ var argv = [];
19964
+ var versions = {};
19965
+ var release = {};
19966
+ var config = {};
19967
+ function noop() {}
19968
+ var on = noop;
19969
+ var addListener = noop;
19970
+ var once = noop;
19971
+ var off = noop;
19972
+ var removeListener = noop;
19973
+ var removeAllListeners = noop;
19974
+ var emit = noop;
19975
+ function binding(name) {
19976
+ throw new Error("process.binding is not supported");
19977
+ }
19978
+ function cwd() {
19979
+ return "/";
19980
+ }
19981
+ function chdir(dir) {
19982
+ throw new Error("process.chdir is not supported");
19983
+ }
19984
+ function umask() {
19985
+ return 0;
19986
+ }
19987
+ var performance = _polyfill_node_global_default.performance || {};
19988
+ var performanceNow = performance.now || performance.mozNow || performance.msNow || performance.oNow || performance.webkitNow || function() {
19989
+ return (/* @__PURE__ */ new Date()).getTime();
19990
+ };
19991
+ function hrtime(previousTimestamp) {
19992
+ var clocktime = performanceNow.call(performance) * .001;
19993
+ var seconds = Math.floor(clocktime);
19994
+ var nanoseconds = Math.floor(clocktime % 1 * 1e9);
19995
+ if (previousTimestamp) {
19996
+ seconds = seconds - previousTimestamp[0];
19997
+ nanoseconds = nanoseconds - previousTimestamp[1];
19998
+ if (nanoseconds < 0) {
19999
+ seconds--;
20000
+ nanoseconds += 1e9;
20001
+ }
20002
+ }
20003
+ return [seconds, nanoseconds];
20004
+ }
20005
+ var startTime = /* @__PURE__ */ new Date();
20006
+ function uptime() {
20007
+ return (/* @__PURE__ */ new Date() - startTime) / 1e3;
20008
+ }
20009
+ var browser$1 = {
20010
+ nextTick,
20011
+ title,
20012
+ browser: true,
20013
+ env,
20014
+ argv,
20015
+ version: "",
20016
+ versions,
20017
+ on,
20018
+ addListener,
20019
+ once,
20020
+ off,
20021
+ removeListener,
20022
+ removeAllListeners,
20023
+ emit,
20024
+ binding,
20025
+ cwd,
20026
+ chdir,
20027
+ umask,
20028
+ hrtime,
20029
+ platform,
20030
+ release,
20031
+ config,
20032
+ uptime
20033
+ };
20034
+ //#endregion
20035
+ //#region \0polyfill-node._inherits.js
20036
+ var inherits;
20037
+ if (typeof Object.create === "function") inherits = function inherits(ctor, superCtor) {
20038
+ ctor.super_ = superCtor;
20039
+ ctor.prototype = Object.create(superCtor.prototype, { constructor: {
20040
+ value: ctor,
20041
+ enumerable: false,
20042
+ writable: true,
20043
+ configurable: true
20044
+ } });
20045
+ };
20046
+ else inherits = function inherits(ctor, superCtor) {
20047
+ ctor.super_ = superCtor;
20048
+ var TempCtor = function() {};
20049
+ TempCtor.prototype = superCtor.prototype;
20050
+ ctor.prototype = new TempCtor();
20051
+ ctor.prototype.constructor = ctor;
20052
+ };
20053
+ var _polyfill_node__inherits_default = inherits;
20054
+ //#endregion
20055
+ //#region \0polyfill-node.util.js
20056
+ /**
20057
+ * Inherit the prototype methods from one constructor into another.
20058
+ *
20059
+ * The Function.prototype.inherits from lang.js rewritten as a standalone
20060
+ * function (not on Function.prototype). NOTE: If this file is to be loaded
20061
+ * during bootstrapping this function needs to be rewritten using some native
20062
+ * functions as prototype setup using normal JavaScript does not work as
20063
+ * expected during bootstrapping (see mirror.js in r114903).
20064
+ *
20065
+ * @param {function} ctor Constructor function which needs to inherit the
20066
+ * prototype.
20067
+ * @param {function} superCtor Constructor function to inherit prototype from.
20068
+ */
20069
+ var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors || function getOwnPropertyDescriptors(obj) {
20070
+ var keys = Object.keys(obj);
20071
+ var descriptors = {};
20072
+ for (var i = 0; i < keys.length; i++) descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]);
20073
+ return descriptors;
20074
+ };
20075
+ var formatRegExp = /%[sdj%]/g;
20076
+ function format(f) {
20077
+ if (!isString(f)) {
20078
+ var objects = [];
20079
+ for (var i = 0; i < arguments.length; i++) objects.push(inspect(arguments[i]));
20080
+ return objects.join(" ");
20081
+ }
20082
+ var i = 1;
20083
+ var args = arguments;
20084
+ var len = args.length;
20085
+ var str = String(f).replace(formatRegExp, function(x) {
20086
+ if (x === "%%") return "%";
20087
+ if (i >= len) return x;
20088
+ switch (x) {
20089
+ case "%s": return String(args[i++]);
20090
+ case "%d": return Number(args[i++]);
20091
+ case "%j": try {
20092
+ return JSON.stringify(args[i++]);
20093
+ } catch (_) {
20094
+ return "[Circular]";
20095
+ }
20096
+ default: return x;
20097
+ }
20098
+ });
20099
+ for (var x = args[i]; i < len; x = args[++i]) if (isNull(x) || !isObject(x)) str += " " + x;
20100
+ else str += " " + inspect(x);
20101
+ return str;
20102
+ }
20103
+ function deprecate(fn, msg) {
20104
+ if (isUndefined(_polyfill_node_global_default.process)) return function() {
20105
+ return deprecate(fn, msg).apply(this, arguments);
20106
+ };
20107
+ if (browser$1.noDeprecation === true) return fn;
20108
+ var warned = false;
20109
+ function deprecated() {
20110
+ if (!warned) {
20111
+ if (browser$1.throwDeprecation) throw new Error(msg);
20112
+ else if (browser$1.traceDeprecation) console.trace(msg);
20113
+ else console.error(msg);
20114
+ warned = true;
20115
+ }
20116
+ return fn.apply(this, arguments);
20117
+ }
20118
+ return deprecated;
20119
+ }
20120
+ var debugs = {};
20121
+ var debugEnviron;
20122
+ function debuglog(set) {
20123
+ if (isUndefined(debugEnviron)) debugEnviron = browser$1.env.NODE_DEBUG || "";
20124
+ set = set.toUpperCase();
20125
+ if (!debugs[set]) if (new RegExp("\\b" + set + "\\b", "i").test(debugEnviron)) {
20126
+ var pid = 0;
20127
+ debugs[set] = function() {
20128
+ var msg = format.apply(null, arguments);
20129
+ console.error("%s %d: %s", set, pid, msg);
20130
+ };
20131
+ } else debugs[set] = function() {};
20132
+ return debugs[set];
20133
+ }
20134
+ /**
20135
+ * Echos the value of a value. Trys to print the value out
20136
+ * in the best way possible given the different types.
20137
+ *
20138
+ * @param {Object} obj The object to print out.
20139
+ * @param {Object} opts Optional options object that alters the output.
20140
+ */
20141
+ function inspect(obj, opts) {
20142
+ var ctx = {
20143
+ seen: [],
20144
+ stylize: stylizeNoColor
20145
+ };
20146
+ if (arguments.length >= 3) ctx.depth = arguments[2];
20147
+ if (arguments.length >= 4) ctx.colors = arguments[3];
20148
+ if (isBoolean(opts)) ctx.showHidden = opts;
20149
+ else if (opts) _extend(ctx, opts);
20150
+ if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
20151
+ if (isUndefined(ctx.depth)) ctx.depth = 2;
20152
+ if (isUndefined(ctx.colors)) ctx.colors = false;
20153
+ if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
20154
+ if (ctx.colors) ctx.stylize = stylizeWithColor;
20155
+ return formatValue(ctx, obj, ctx.depth);
20156
+ }
20157
+ inspect.colors = {
20158
+ "bold": [1, 22],
20159
+ "italic": [3, 23],
20160
+ "underline": [4, 24],
20161
+ "inverse": [7, 27],
20162
+ "white": [37, 39],
20163
+ "grey": [90, 39],
20164
+ "black": [30, 39],
20165
+ "blue": [34, 39],
20166
+ "cyan": [36, 39],
20167
+ "green": [32, 39],
20168
+ "magenta": [35, 39],
20169
+ "red": [31, 39],
20170
+ "yellow": [33, 39]
20171
+ };
20172
+ inspect.styles = {
20173
+ "special": "cyan",
20174
+ "number": "yellow",
20175
+ "boolean": "yellow",
20176
+ "undefined": "grey",
20177
+ "null": "bold",
20178
+ "string": "green",
20179
+ "date": "magenta",
20180
+ "regexp": "red"
20181
+ };
20182
+ function stylizeWithColor(str, styleType) {
20183
+ var style = inspect.styles[styleType];
20184
+ if (style) return "\x1B[" + inspect.colors[style][0] + "m" + str + "\x1B[" + inspect.colors[style][1] + "m";
20185
+ else return str;
20186
+ }
20187
+ function stylizeNoColor(str, styleType) {
20188
+ return str;
20189
+ }
20190
+ function arrayToHash(array) {
20191
+ var hash = {};
20192
+ array.forEach(function(val, idx) {
20193
+ hash[val] = true;
20194
+ });
20195
+ return hash;
20196
+ }
20197
+ function formatValue(ctx, value, recurseTimes) {
20198
+ if (ctx.customInspect && value && isFunction(value.inspect) && value.inspect !== inspect && !(value.constructor && value.constructor.prototype === value)) {
20199
+ var ret = value.inspect(recurseTimes, ctx);
20200
+ if (!isString(ret)) ret = formatValue(ctx, ret, recurseTimes);
20201
+ return ret;
20202
+ }
20203
+ var primitive = formatPrimitive(ctx, value);
20204
+ if (primitive) return primitive;
20205
+ var keys = Object.keys(value);
20206
+ var visibleKeys = arrayToHash(keys);
20207
+ if (ctx.showHidden) keys = Object.getOwnPropertyNames(value);
20208
+ if (isError(value) && (keys.indexOf("message") >= 0 || keys.indexOf("description") >= 0)) return formatError(value);
20209
+ if (keys.length === 0) {
20210
+ if (isFunction(value)) {
20211
+ var name = value.name ? ": " + value.name : "";
20212
+ return ctx.stylize("[Function" + name + "]", "special");
20213
+ }
20214
+ if (isRegExp(value)) return ctx.stylize(RegExp.prototype.toString.call(value), "regexp");
20215
+ if (isDate(value)) return ctx.stylize(Date.prototype.toString.call(value), "date");
20216
+ if (isError(value)) return formatError(value);
20217
+ }
20218
+ var base = "", array = false, braces = ["{", "}"];
20219
+ if (isArray(value)) {
20220
+ array = true;
20221
+ braces = ["[", "]"];
20222
+ }
20223
+ if (isFunction(value)) base = " [Function" + (value.name ? ": " + value.name : "") + "]";
20224
+ if (isRegExp(value)) base = " " + RegExp.prototype.toString.call(value);
20225
+ if (isDate(value)) base = " " + Date.prototype.toUTCString.call(value);
20226
+ if (isError(value)) base = " " + formatError(value);
20227
+ if (keys.length === 0 && (!array || value.length == 0)) return braces[0] + base + braces[1];
20228
+ if (recurseTimes < 0) if (isRegExp(value)) return ctx.stylize(RegExp.prototype.toString.call(value), "regexp");
20229
+ else return ctx.stylize("[Object]", "special");
20230
+ ctx.seen.push(value);
20231
+ var output;
20232
+ if (array) output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
20233
+ else output = keys.map(function(key) {
20234
+ return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
20235
+ });
20236
+ ctx.seen.pop();
20237
+ return reduceToSingleString(output, base, braces);
20238
+ }
20239
+ function formatPrimitive(ctx, value) {
20240
+ if (isUndefined(value)) return ctx.stylize("undefined", "undefined");
20241
+ if (isString(value)) {
20242
+ var simple = "'" + JSON.stringify(value).replace(/^"|"$/g, "").replace(/'/g, "\\'").replace(/\\"/g, "\"") + "'";
20243
+ return ctx.stylize(simple, "string");
20244
+ }
20245
+ if (isNumber(value)) return ctx.stylize("" + value, "number");
20246
+ if (isBoolean(value)) return ctx.stylize("" + value, "boolean");
20247
+ if (isNull(value)) return ctx.stylize("null", "null");
20248
+ }
20249
+ function formatError(value) {
20250
+ return "[" + Error.prototype.toString.call(value) + "]";
20251
+ }
20252
+ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
20253
+ var output = [];
20254
+ for (var i = 0, l = value.length; i < l; ++i) if (hasOwnProperty(value, String(i))) output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, String(i), true));
20255
+ else output.push("");
20256
+ keys.forEach(function(key) {
20257
+ if (!key.match(/^\d+$/)) output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, key, true));
20258
+ });
20259
+ return output;
20260
+ }
20261
+ function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
20262
+ var name, str, desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
20263
+ if (desc.get) if (desc.set) str = ctx.stylize("[Getter/Setter]", "special");
20264
+ else str = ctx.stylize("[Getter]", "special");
20265
+ else if (desc.set) str = ctx.stylize("[Setter]", "special");
20266
+ if (!hasOwnProperty(visibleKeys, key)) name = "[" + key + "]";
20267
+ if (!str) if (ctx.seen.indexOf(desc.value) < 0) {
20268
+ if (isNull(recurseTimes)) str = formatValue(ctx, desc.value, null);
20269
+ else str = formatValue(ctx, desc.value, recurseTimes - 1);
20270
+ if (str.indexOf("\n") > -1) if (array) str = str.split("\n").map(function(line) {
20271
+ return " " + line;
20272
+ }).join("\n").substr(2);
20273
+ else str = "\n" + str.split("\n").map(function(line) {
20274
+ return " " + line;
20275
+ }).join("\n");
20276
+ } else str = ctx.stylize("[Circular]", "special");
20277
+ if (isUndefined(name)) {
20278
+ if (array && key.match(/^\d+$/)) return str;
20279
+ name = JSON.stringify("" + key);
20280
+ if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
20281
+ name = name.substr(1, name.length - 2);
20282
+ name = ctx.stylize(name, "name");
20283
+ } else {
20284
+ name = name.replace(/'/g, "\\'").replace(/\\"/g, "\"").replace(/(^"|"$)/g, "'");
20285
+ name = ctx.stylize(name, "string");
20286
+ }
20287
+ }
20288
+ return name + ": " + str;
20289
+ }
20290
+ function reduceToSingleString(output, base, braces) {
20291
+ var numLinesEst = 0;
20292
+ if (output.reduce(function(prev, cur) {
20293
+ numLinesEst++;
20294
+ if (cur.indexOf("\n") >= 0) numLinesEst++;
20295
+ return prev + cur.replace(/\u001b\[\d\d?m/g, "").length + 1;
20296
+ }, 0) > 60) return braces[0] + (base === "" ? "" : base + "\n ") + " " + output.join(",\n ") + " " + braces[1];
20297
+ return braces[0] + base + " " + output.join(", ") + " " + braces[1];
20298
+ }
20299
+ function isArray(ar) {
20300
+ return Array.isArray(ar);
20301
+ }
20302
+ function isBoolean(arg) {
20303
+ return typeof arg === "boolean";
20304
+ }
20305
+ function isNull(arg) {
20306
+ return arg === null;
20307
+ }
20308
+ function isNumber(arg) {
20309
+ return typeof arg === "number";
20310
+ }
20311
+ function isString(arg) {
20312
+ return typeof arg === "string";
20313
+ }
20314
+ function isUndefined(arg) {
20315
+ return arg === void 0;
20316
+ }
20317
+ function isRegExp(re) {
20318
+ return isObject(re) && objectToString(re) === "[object RegExp]";
20319
+ }
20320
+ function isObject(arg) {
20321
+ return typeof arg === "object" && arg !== null;
20322
+ }
20323
+ function isDate(d) {
20324
+ return isObject(d) && objectToString(d) === "[object Date]";
20325
+ }
20326
+ function isError(e) {
20327
+ return isObject(e) && (objectToString(e) === "[object Error]" || e instanceof Error);
20328
+ }
20329
+ function isFunction(arg) {
20330
+ return typeof arg === "function";
20331
+ }
20332
+ function objectToString(o) {
20333
+ return Object.prototype.toString.call(o);
20334
+ }
20335
+ function _extend(origin, add) {
20336
+ if (!add || !isObject(add)) return origin;
20337
+ var keys = Object.keys(add);
20338
+ var i = keys.length;
20339
+ while (i--) origin[keys[i]] = add[keys[i]];
20340
+ return origin;
20341
+ }
20342
+ function hasOwnProperty(obj, prop) {
20343
+ return Object.prototype.hasOwnProperty.call(obj, prop);
20344
+ }
20345
+ var kCustomPromisifiedSymbol = typeof Symbol !== "undefined" ? Symbol("util.promisify.custom") : void 0;
20346
+ function promisify(original) {
20347
+ if (typeof original !== "function") throw new TypeError("The \"original\" argument must be of type Function");
20348
+ if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {
20349
+ var fn = original[kCustomPromisifiedSymbol];
20350
+ if (typeof fn !== "function") throw new TypeError("The \"util.promisify.custom\" argument must be of type Function");
20351
+ Object.defineProperty(fn, kCustomPromisifiedSymbol, {
20352
+ value: fn,
20353
+ enumerable: false,
20354
+ writable: false,
20355
+ configurable: true
20356
+ });
20357
+ return fn;
20358
+ }
20359
+ function fn() {
20360
+ var promiseResolve, promiseReject;
20361
+ var promise = new Promise(function(resolve, reject) {
20362
+ promiseResolve = resolve;
20363
+ promiseReject = reject;
20364
+ });
20365
+ var args = [];
20366
+ for (var i = 0; i < arguments.length; i++) args.push(arguments[i]);
20367
+ args.push(function(err, value) {
20368
+ if (err) promiseReject(err);
20369
+ else promiseResolve(value);
20370
+ });
20371
+ try {
20372
+ original.apply(this, args);
20373
+ } catch (err) {
20374
+ promiseReject(err);
20375
+ }
20376
+ return promise;
20377
+ }
20378
+ Object.setPrototypeOf(fn, Object.getPrototypeOf(original));
20379
+ if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, {
20380
+ value: fn,
20381
+ enumerable: false,
20382
+ writable: false,
20383
+ configurable: true
20384
+ });
20385
+ return Object.defineProperties(fn, getOwnPropertyDescriptors(original));
20386
+ }
20387
+ promisify.custom = kCustomPromisifiedSymbol;
20388
+ //#endregion
20389
+ //#region \0polyfill-node._buffer_list.js
20390
+ var _polyfill_node__buffer_list_default = BufferList;
20391
+ function BufferList() {
20392
+ this.head = null;
20393
+ this.tail = null;
20394
+ this.length = 0;
20395
+ }
20396
+ BufferList.prototype.push = function(v) {
20397
+ var entry = {
20398
+ data: v,
20399
+ next: null
20400
+ };
20401
+ if (this.length > 0) this.tail.next = entry;
20402
+ else this.head = entry;
20403
+ this.tail = entry;
20404
+ ++this.length;
20405
+ };
20406
+ BufferList.prototype.unshift = function(v) {
20407
+ var entry = {
20408
+ data: v,
20409
+ next: this.head
20410
+ };
20411
+ if (this.length === 0) this.tail = entry;
20412
+ this.head = entry;
20413
+ ++this.length;
20414
+ };
20415
+ BufferList.prototype.shift = function() {
20416
+ if (this.length === 0) return;
20417
+ var ret = this.head.data;
20418
+ if (this.length === 1) this.head = this.tail = null;
20419
+ else this.head = this.head.next;
20420
+ --this.length;
20421
+ return ret;
20422
+ };
20423
+ BufferList.prototype.clear = function() {
20424
+ this.head = this.tail = null;
20425
+ this.length = 0;
20426
+ };
20427
+ BufferList.prototype.join = function(s) {
20428
+ if (this.length === 0) return "";
20429
+ var p = this.head;
20430
+ var ret = "" + p.data;
20431
+ while (p = p.next) ret += s + p.data;
20432
+ return ret;
20433
+ };
20434
+ BufferList.prototype.concat = function(n) {
20435
+ if (this.length === 0) return Buffer$1.alloc(0);
20436
+ if (this.length === 1) return this.head.data;
20437
+ var ret = Buffer$1.allocUnsafe(n >>> 0);
20438
+ var p = this.head;
20439
+ var i = 0;
20440
+ while (p) {
20441
+ p.data.copy(ret, i);
20442
+ i += p.data.length;
20443
+ p = p.next;
20444
+ }
20445
+ return ret;
20446
+ };
20447
+ //#endregion
20448
+ //#region \0polyfill-node.string_decoder.js
20449
+ var isBufferEncoding = Buffer$1.isEncoding || function(encoding) {
20450
+ switch (encoding && encoding.toLowerCase()) {
20451
+ case "hex":
20452
+ case "utf8":
20453
+ case "utf-8":
20454
+ case "ascii":
20455
+ case "binary":
20456
+ case "base64":
20457
+ case "ucs2":
20458
+ case "ucs-2":
20459
+ case "utf16le":
20460
+ case "utf-16le":
20461
+ case "raw": return true;
20462
+ default: return false;
20463
+ }
20464
+ };
20465
+ function assertEncoding(encoding) {
20466
+ if (encoding && !isBufferEncoding(encoding)) throw new Error("Unknown encoding: " + encoding);
20467
+ }
20468
+ function StringDecoder(encoding) {
20469
+ this.encoding = (encoding || "utf8").toLowerCase().replace(/[-_]/, "");
20470
+ assertEncoding(encoding);
20471
+ switch (this.encoding) {
20472
+ case "utf8":
20473
+ this.surrogateSize = 3;
20474
+ break;
20475
+ case "ucs2":
20476
+ case "utf16le":
20477
+ this.surrogateSize = 2;
20478
+ this.detectIncompleteChar = utf16DetectIncompleteChar;
20479
+ break;
20480
+ case "base64":
20481
+ this.surrogateSize = 3;
20482
+ this.detectIncompleteChar = base64DetectIncompleteChar;
20483
+ break;
20484
+ default:
20485
+ this.write = passThroughWrite;
20486
+ return;
20487
+ }
20488
+ this.charBuffer = new Buffer$1(6);
20489
+ this.charReceived = 0;
20490
+ this.charLength = 0;
20491
+ }
20492
+ StringDecoder.prototype.write = function(buffer) {
20493
+ var charStr = "";
20494
+ while (this.charLength) {
20495
+ var available = buffer.length >= this.charLength - this.charReceived ? this.charLength - this.charReceived : buffer.length;
20496
+ buffer.copy(this.charBuffer, this.charReceived, 0, available);
20497
+ this.charReceived += available;
20498
+ if (this.charReceived < this.charLength) return "";
20499
+ buffer = buffer.slice(available, buffer.length);
20500
+ charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
20501
+ var charCode = charStr.charCodeAt(charStr.length - 1);
20502
+ if (charCode >= 55296 && charCode <= 56319) {
20503
+ this.charLength += this.surrogateSize;
20504
+ charStr = "";
20505
+ continue;
20506
+ }
20507
+ this.charReceived = this.charLength = 0;
20508
+ if (buffer.length === 0) return charStr;
20509
+ break;
20510
+ }
20511
+ this.detectIncompleteChar(buffer);
20512
+ var end = buffer.length;
20513
+ if (this.charLength) {
20514
+ buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
20515
+ end -= this.charReceived;
20516
+ }
20517
+ charStr += buffer.toString(this.encoding, 0, end);
20518
+ var end = charStr.length - 1;
20519
+ var charCode = charStr.charCodeAt(end);
20520
+ if (charCode >= 55296 && charCode <= 56319) {
20521
+ var size = this.surrogateSize;
20522
+ this.charLength += size;
20523
+ this.charReceived += size;
20524
+ this.charBuffer.copy(this.charBuffer, size, 0, size);
20525
+ buffer.copy(this.charBuffer, 0, 0, size);
20526
+ return charStr.substring(0, end);
20527
+ }
20528
+ return charStr;
20529
+ };
20530
+ StringDecoder.prototype.detectIncompleteChar = function(buffer) {
20531
+ var i = buffer.length >= 3 ? 3 : buffer.length;
20532
+ for (; i > 0; i--) {
20533
+ var c = buffer[buffer.length - i];
20534
+ if (i == 1 && c >> 5 == 6) {
20535
+ this.charLength = 2;
20536
+ break;
20537
+ }
20538
+ if (i <= 2 && c >> 4 == 14) {
20539
+ this.charLength = 3;
20540
+ break;
20541
+ }
20542
+ if (i <= 3 && c >> 3 == 30) {
20543
+ this.charLength = 4;
20544
+ break;
20545
+ }
20546
+ }
20547
+ this.charReceived = i;
20548
+ };
20549
+ StringDecoder.prototype.end = function(buffer) {
20550
+ var res = "";
20551
+ if (buffer && buffer.length) res = this.write(buffer);
20552
+ if (this.charReceived) {
20553
+ var cr = this.charReceived;
20554
+ var buf = this.charBuffer;
20555
+ var enc = this.encoding;
20556
+ res += buf.slice(0, cr).toString(enc);
20557
+ }
20558
+ return res;
20559
+ };
20560
+ function passThroughWrite(buffer) {
20561
+ return buffer.toString(this.encoding);
20562
+ }
20563
+ function utf16DetectIncompleteChar(buffer) {
20564
+ this.charReceived = buffer.length % 2;
20565
+ this.charLength = this.charReceived ? 2 : 0;
20566
+ }
20567
+ function base64DetectIncompleteChar(buffer) {
20568
+ this.charReceived = buffer.length % 3;
20569
+ this.charLength = this.charReceived ? 3 : 0;
20570
+ }
20571
+ //#endregion
20572
+ //#region \0polyfill-node._stream_readable.js
20573
+ Readable.ReadableState = ReadableState;
20574
+ var debug = debuglog("stream");
20575
+ _polyfill_node__inherits_default(Readable, EventEmitter);
20576
+ function prependListener(emitter, event, fn) {
20577
+ if (typeof emitter.prependListener === "function") return emitter.prependListener(event, fn);
20578
+ else if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);
20579
+ else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);
20580
+ else emitter._events[event] = [fn, emitter._events[event]];
20581
+ }
20582
+ function listenerCount(emitter, type) {
20583
+ return emitter.listeners(type).length;
20584
+ }
20585
+ function ReadableState(options, stream) {
20586
+ options = options || {};
20587
+ this.objectMode = !!options.objectMode;
20588
+ if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
20589
+ var hwm = options.highWaterMark;
20590
+ var defaultHwm = this.objectMode ? 16 : 16 * 1024;
20591
+ this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
20592
+ this.highWaterMark = ~~this.highWaterMark;
20593
+ this.buffer = new _polyfill_node__buffer_list_default();
20594
+ this.length = 0;
20595
+ this.pipes = null;
20596
+ this.pipesCount = 0;
20597
+ this.flowing = null;
20598
+ this.ended = false;
20599
+ this.endEmitted = false;
20600
+ this.reading = false;
20601
+ this.sync = true;
20602
+ this.needReadable = false;
20603
+ this.emittedReadable = false;
20604
+ this.readableListening = false;
20605
+ this.resumeScheduled = false;
20606
+ this.defaultEncoding = options.defaultEncoding || "utf8";
20607
+ this.ranOut = false;
20608
+ this.awaitDrain = 0;
20609
+ this.readingMore = false;
20610
+ this.decoder = null;
20611
+ this.encoding = null;
20612
+ if (options.encoding) {
20613
+ this.decoder = new StringDecoder(options.encoding);
20614
+ this.encoding = options.encoding;
20615
+ }
20616
+ }
20617
+ function Readable(options) {
20618
+ if (!(this instanceof Readable)) return new Readable(options);
20619
+ this._readableState = new ReadableState(options, this);
20620
+ this.readable = true;
20621
+ if (options && typeof options.read === "function") this._read = options.read;
20622
+ EventEmitter.call(this);
20623
+ }
20624
+ Readable.prototype.push = function(chunk, encoding) {
20625
+ var state = this._readableState;
20626
+ if (!state.objectMode && typeof chunk === "string") {
20627
+ encoding = encoding || state.defaultEncoding;
20628
+ if (encoding !== state.encoding) {
20629
+ chunk = Buffer$1.from(chunk, encoding);
20630
+ encoding = "";
20631
+ }
20632
+ }
20633
+ return readableAddChunk(this, state, chunk, encoding, false);
20634
+ };
20635
+ Readable.prototype.unshift = function(chunk) {
20636
+ var state = this._readableState;
20637
+ return readableAddChunk(this, state, chunk, "", true);
20638
+ };
20639
+ Readable.prototype.isPaused = function() {
20640
+ return this._readableState.flowing === false;
20641
+ };
20642
+ function readableAddChunk(stream, state, chunk, encoding, addToFront) {
20643
+ var er = chunkInvalid(state, chunk);
20644
+ if (er) stream.emit("error", er);
20645
+ else if (chunk === null) {
20646
+ state.reading = false;
20647
+ onEofChunk(stream, state);
20648
+ } else if (state.objectMode || chunk && chunk.length > 0) if (state.ended && !addToFront) {
20649
+ var e = /* @__PURE__ */ new Error("stream.push() after EOF");
20650
+ stream.emit("error", e);
20651
+ } else if (state.endEmitted && addToFront) {
20652
+ var _e = /* @__PURE__ */ new Error("stream.unshift() after end event");
20653
+ stream.emit("error", _e);
20654
+ } else {
20655
+ var skipAdd;
20656
+ if (state.decoder && !addToFront && !encoding) {
20657
+ chunk = state.decoder.write(chunk);
20658
+ skipAdd = !state.objectMode && chunk.length === 0;
20659
+ }
20660
+ if (!addToFront) state.reading = false;
20661
+ if (!skipAdd) if (state.flowing && state.length === 0 && !state.sync) {
20662
+ stream.emit("data", chunk);
20663
+ stream.read(0);
20664
+ } else {
20665
+ state.length += state.objectMode ? 1 : chunk.length;
20666
+ if (addToFront) state.buffer.unshift(chunk);
20667
+ else state.buffer.push(chunk);
20668
+ if (state.needReadable) emitReadable(stream);
20669
+ }
20670
+ maybeReadMore(stream, state);
20671
+ }
20672
+ else if (!addToFront) state.reading = false;
20673
+ return needMoreData(state);
20674
+ }
20675
+ function needMoreData(state) {
20676
+ return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
20677
+ }
20678
+ Readable.prototype.setEncoding = function(enc) {
20679
+ this._readableState.decoder = new StringDecoder(enc);
20680
+ this._readableState.encoding = enc;
20681
+ return this;
20682
+ };
20683
+ var MAX_HWM = 8388608;
20684
+ function computeNewHighWaterMark(n) {
20685
+ if (n >= MAX_HWM) n = MAX_HWM;
20686
+ else {
20687
+ n--;
20688
+ n |= n >>> 1;
20689
+ n |= n >>> 2;
20690
+ n |= n >>> 4;
20691
+ n |= n >>> 8;
20692
+ n |= n >>> 16;
20693
+ n++;
20694
+ }
20695
+ return n;
20696
+ }
20697
+ function howMuchToRead(n, state) {
20698
+ if (n <= 0 || state.length === 0 && state.ended) return 0;
20699
+ if (state.objectMode) return 1;
20700
+ if (n !== n) if (state.flowing && state.length) return state.buffer.head.data.length;
20701
+ else return state.length;
20702
+ if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
20703
+ if (n <= state.length) return n;
20704
+ if (!state.ended) {
20705
+ state.needReadable = true;
20706
+ return 0;
20707
+ }
20708
+ return state.length;
20709
+ }
20710
+ Readable.prototype.read = function(n) {
20711
+ debug("read", n);
20712
+ n = parseInt(n, 10);
20713
+ var state = this._readableState;
20714
+ var nOrig = n;
20715
+ if (n !== 0) state.emittedReadable = false;
20716
+ if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
20717
+ debug("read: emitReadable", state.length, state.ended);
20718
+ if (state.length === 0 && state.ended) endReadable(this);
20719
+ else emitReadable(this);
20720
+ return null;
20721
+ }
20722
+ n = howMuchToRead(n, state);
20723
+ if (n === 0 && state.ended) {
20724
+ if (state.length === 0) endReadable(this);
20725
+ return null;
20726
+ }
20727
+ var doRead = state.needReadable;
20728
+ debug("need readable", doRead);
20729
+ if (state.length === 0 || state.length - n < state.highWaterMark) {
20730
+ doRead = true;
20731
+ debug("length less than watermark", doRead);
20732
+ }
20733
+ if (state.ended || state.reading) {
20734
+ doRead = false;
20735
+ debug("reading or ended", doRead);
20736
+ } else if (doRead) {
20737
+ debug("do read");
20738
+ state.reading = true;
20739
+ state.sync = true;
20740
+ if (state.length === 0) state.needReadable = true;
20741
+ this._read(state.highWaterMark);
20742
+ state.sync = false;
20743
+ if (!state.reading) n = howMuchToRead(nOrig, state);
20744
+ }
20745
+ var ret;
20746
+ if (n > 0) ret = fromList(n, state);
20747
+ else ret = null;
20748
+ if (ret === null) {
20749
+ state.needReadable = true;
20750
+ n = 0;
20751
+ } else state.length -= n;
20752
+ if (state.length === 0) {
20753
+ if (!state.ended) state.needReadable = true;
20754
+ if (nOrig !== n && state.ended) endReadable(this);
20755
+ }
20756
+ if (ret !== null) this.emit("data", ret);
20757
+ return ret;
20758
+ };
20759
+ function chunkInvalid(state, chunk) {
20760
+ var er = null;
20761
+ if (!Buffer$1.isBuffer(chunk) && typeof chunk !== "string" && chunk !== null && chunk !== void 0 && !state.objectMode) er = /* @__PURE__ */ new TypeError("Invalid non-string/buffer chunk");
20762
+ return er;
20763
+ }
20764
+ function onEofChunk(stream, state) {
20765
+ if (state.ended) return;
20766
+ if (state.decoder) {
20767
+ var chunk = state.decoder.end();
20768
+ if (chunk && chunk.length) {
20769
+ state.buffer.push(chunk);
20770
+ state.length += state.objectMode ? 1 : chunk.length;
20771
+ }
20772
+ }
20773
+ state.ended = true;
20774
+ emitReadable(stream);
20775
+ }
20776
+ function emitReadable(stream) {
20777
+ var state = stream._readableState;
20778
+ state.needReadable = false;
20779
+ if (!state.emittedReadable) {
20780
+ debug("emitReadable", state.flowing);
20781
+ state.emittedReadable = true;
20782
+ if (state.sync) nextTick(emitReadable_, stream);
20783
+ else emitReadable_(stream);
20784
+ }
20785
+ }
20786
+ function emitReadable_(stream) {
20787
+ debug("emit readable");
20788
+ stream.emit("readable");
20789
+ flow(stream);
20790
+ }
20791
+ function maybeReadMore(stream, state) {
20792
+ if (!state.readingMore) {
20793
+ state.readingMore = true;
20794
+ nextTick(maybeReadMore_, stream, state);
20795
+ }
20796
+ }
20797
+ function maybeReadMore_(stream, state) {
20798
+ var len = state.length;
20799
+ while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
20800
+ debug("maybeReadMore read 0");
20801
+ stream.read(0);
20802
+ if (len === state.length) break;
20803
+ else len = state.length;
20804
+ }
20805
+ state.readingMore = false;
20806
+ }
20807
+ Readable.prototype._read = function(n) {
20808
+ this.emit("error", /* @__PURE__ */ new Error("not implemented"));
20809
+ };
20810
+ Readable.prototype.pipe = function(dest, pipeOpts) {
20811
+ var src = this;
20812
+ var state = this._readableState;
20813
+ switch (state.pipesCount) {
20814
+ case 0:
20815
+ state.pipes = dest;
20816
+ break;
20817
+ case 1:
20818
+ state.pipes = [state.pipes, dest];
20819
+ break;
20820
+ default:
20821
+ state.pipes.push(dest);
20822
+ break;
20823
+ }
20824
+ state.pipesCount += 1;
20825
+ debug("pipe count=%d opts=%j", state.pipesCount, pipeOpts);
20826
+ var endFn = !pipeOpts || pipeOpts.end !== false ? onend : cleanup;
20827
+ if (state.endEmitted) nextTick(endFn);
20828
+ else src.once("end", endFn);
20829
+ dest.on("unpipe", onunpipe);
20830
+ function onunpipe(readable) {
20831
+ debug("onunpipe");
20832
+ if (readable === src) cleanup();
20833
+ }
20834
+ function onend() {
20835
+ debug("onend");
20836
+ dest.end();
20837
+ }
20838
+ var ondrain = pipeOnDrain(src);
20839
+ dest.on("drain", ondrain);
20840
+ var cleanedUp = false;
20841
+ function cleanup() {
20842
+ debug("cleanup");
20843
+ dest.removeListener("close", onclose);
20844
+ dest.removeListener("finish", onfinish);
20845
+ dest.removeListener("drain", ondrain);
20846
+ dest.removeListener("error", onerror);
20847
+ dest.removeListener("unpipe", onunpipe);
20848
+ src.removeListener("end", onend);
20849
+ src.removeListener("end", cleanup);
20850
+ src.removeListener("data", ondata);
20851
+ cleanedUp = true;
20852
+ if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
20853
+ }
20854
+ var increasedAwaitDrain = false;
20855
+ src.on("data", ondata);
20856
+ function ondata(chunk) {
20857
+ debug("ondata");
20858
+ increasedAwaitDrain = false;
20859
+ if (false === dest.write(chunk) && !increasedAwaitDrain) {
20860
+ if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
20861
+ debug("false write response, pause", src._readableState.awaitDrain);
20862
+ src._readableState.awaitDrain++;
20863
+ increasedAwaitDrain = true;
20864
+ }
20865
+ src.pause();
20866
+ }
20867
+ }
20868
+ function onerror(er) {
20869
+ debug("onerror", er);
20870
+ unpipe();
20871
+ dest.removeListener("error", onerror);
20872
+ if (listenerCount(dest, "error") === 0) dest.emit("error", er);
20873
+ }
20874
+ prependListener(dest, "error", onerror);
20875
+ function onclose() {
20876
+ dest.removeListener("finish", onfinish);
20877
+ unpipe();
20878
+ }
20879
+ dest.once("close", onclose);
20880
+ function onfinish() {
20881
+ debug("onfinish");
20882
+ dest.removeListener("close", onclose);
20883
+ unpipe();
20884
+ }
20885
+ dest.once("finish", onfinish);
20886
+ function unpipe() {
20887
+ debug("unpipe");
20888
+ src.unpipe(dest);
20889
+ }
20890
+ dest.emit("pipe", src);
20891
+ if (!state.flowing) {
20892
+ debug("pipe resume");
20893
+ src.resume();
20894
+ }
20895
+ return dest;
20896
+ };
20897
+ function pipeOnDrain(src) {
20898
+ return function() {
20899
+ var state = src._readableState;
20900
+ debug("pipeOnDrain", state.awaitDrain);
20901
+ if (state.awaitDrain) state.awaitDrain--;
20902
+ if (state.awaitDrain === 0 && src.listeners("data").length) {
20903
+ state.flowing = true;
20904
+ flow(src);
20905
+ }
20906
+ };
20907
+ }
20908
+ Readable.prototype.unpipe = function(dest) {
20909
+ var state = this._readableState;
20910
+ if (state.pipesCount === 0) return this;
20911
+ if (state.pipesCount === 1) {
20912
+ if (dest && dest !== state.pipes) return this;
20913
+ if (!dest) dest = state.pipes;
20914
+ state.pipes = null;
20915
+ state.pipesCount = 0;
20916
+ state.flowing = false;
20917
+ if (dest) dest.emit("unpipe", this);
20918
+ return this;
20919
+ }
20920
+ if (!dest) {
20921
+ var dests = state.pipes;
20922
+ var len = state.pipesCount;
20923
+ state.pipes = null;
20924
+ state.pipesCount = 0;
20925
+ state.flowing = false;
20926
+ for (var _i = 0; _i < len; _i++) dests[_i].emit("unpipe", this);
20927
+ return this;
20928
+ }
20929
+ var i = indexOf(state.pipes, dest);
20930
+ if (i === -1) return this;
20931
+ state.pipes.splice(i, 1);
20932
+ state.pipesCount -= 1;
20933
+ if (state.pipesCount === 1) state.pipes = state.pipes[0];
20934
+ dest.emit("unpipe", this);
20935
+ return this;
20936
+ };
20937
+ Readable.prototype.on = function(ev, fn) {
20938
+ var res = EventEmitter.prototype.on.call(this, ev, fn);
20939
+ if (ev === "data") {
20940
+ if (this._readableState.flowing !== false) this.resume();
20941
+ } else if (ev === "readable") {
20942
+ var state = this._readableState;
20943
+ if (!state.endEmitted && !state.readableListening) {
20944
+ state.readableListening = state.needReadable = true;
20945
+ state.emittedReadable = false;
20946
+ if (!state.reading) nextTick(nReadingNextTick, this);
20947
+ else if (state.length) emitReadable(this, state);
20948
+ }
20949
+ }
20950
+ return res;
20951
+ };
20952
+ Readable.prototype.addListener = Readable.prototype.on;
20953
+ function nReadingNextTick(self) {
20954
+ debug("readable nexttick read 0");
20955
+ self.read(0);
20956
+ }
20957
+ Readable.prototype.resume = function() {
20958
+ var state = this._readableState;
20959
+ if (!state.flowing) {
20960
+ debug("resume");
20961
+ state.flowing = true;
20962
+ resume(this, state);
20963
+ }
20964
+ return this;
20965
+ };
20966
+ function resume(stream, state) {
20967
+ if (!state.resumeScheduled) {
20968
+ state.resumeScheduled = true;
20969
+ nextTick(resume_, stream, state);
20970
+ }
20971
+ }
20972
+ function resume_(stream, state) {
20973
+ if (!state.reading) {
20974
+ debug("resume read 0");
20975
+ stream.read(0);
20976
+ }
20977
+ state.resumeScheduled = false;
20978
+ state.awaitDrain = 0;
20979
+ stream.emit("resume");
20980
+ flow(stream);
20981
+ if (state.flowing && !state.reading) stream.read(0);
20982
+ }
20983
+ Readable.prototype.pause = function() {
20984
+ debug("call pause flowing=%j", this._readableState.flowing);
20985
+ if (false !== this._readableState.flowing) {
20986
+ debug("pause");
20987
+ this._readableState.flowing = false;
20988
+ this.emit("pause");
20989
+ }
20990
+ return this;
20991
+ };
20992
+ function flow(stream) {
20993
+ var state = stream._readableState;
20994
+ debug("flow", state.flowing);
20995
+ while (state.flowing && stream.read() !== null);
20996
+ }
20997
+ Readable.prototype.wrap = function(stream) {
20998
+ var state = this._readableState;
20999
+ var paused = false;
21000
+ var self = this;
21001
+ stream.on("end", function() {
21002
+ debug("wrapped end");
21003
+ if (state.decoder && !state.ended) {
21004
+ var chunk = state.decoder.end();
21005
+ if (chunk && chunk.length) self.push(chunk);
21006
+ }
21007
+ self.push(null);
21008
+ });
21009
+ stream.on("data", function(chunk) {
21010
+ debug("wrapped data");
21011
+ if (state.decoder) chunk = state.decoder.write(chunk);
21012
+ if (state.objectMode && (chunk === null || chunk === void 0)) return;
21013
+ else if (!state.objectMode && (!chunk || !chunk.length)) return;
21014
+ if (!self.push(chunk)) {
21015
+ paused = true;
21016
+ stream.pause();
21017
+ }
21018
+ });
21019
+ for (var i in stream) if (this[i] === void 0 && typeof stream[i] === "function") this[i] = function(method) {
21020
+ return function() {
21021
+ return stream[method].apply(stream, arguments);
21022
+ };
21023
+ }(i);
21024
+ forEach([
21025
+ "error",
21026
+ "close",
21027
+ "destroy",
21028
+ "pause",
21029
+ "resume"
21030
+ ], function(ev) {
21031
+ stream.on(ev, self.emit.bind(self, ev));
21032
+ });
21033
+ self._read = function(n) {
21034
+ debug("wrapped _read", n);
21035
+ if (paused) {
21036
+ paused = false;
21037
+ stream.resume();
21038
+ }
21039
+ };
21040
+ return self;
21041
+ };
21042
+ Readable._fromList = fromList;
21043
+ function fromList(n, state) {
21044
+ if (state.length === 0) return null;
21045
+ var ret;
21046
+ if (state.objectMode) ret = state.buffer.shift();
21047
+ else if (!n || n >= state.length) {
21048
+ if (state.decoder) ret = state.buffer.join("");
21049
+ else if (state.buffer.length === 1) ret = state.buffer.head.data;
21050
+ else ret = state.buffer.concat(state.length);
21051
+ state.buffer.clear();
21052
+ } else ret = fromListPartial(n, state.buffer, state.decoder);
21053
+ return ret;
21054
+ }
21055
+ function fromListPartial(n, list, hasStrings) {
21056
+ var ret;
21057
+ if (n < list.head.data.length) {
21058
+ ret = list.head.data.slice(0, n);
21059
+ list.head.data = list.head.data.slice(n);
21060
+ } else if (n === list.head.data.length) ret = list.shift();
21061
+ else ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
21062
+ return ret;
21063
+ }
21064
+ function copyFromBufferString(n, list) {
21065
+ var p = list.head;
21066
+ var c = 1;
21067
+ var ret = p.data;
21068
+ n -= ret.length;
21069
+ while (p = p.next) {
21070
+ var str = p.data;
21071
+ var nb = n > str.length ? str.length : n;
21072
+ if (nb === str.length) ret += str;
21073
+ else ret += str.slice(0, n);
21074
+ n -= nb;
21075
+ if (n === 0) {
21076
+ if (nb === str.length) {
21077
+ ++c;
21078
+ if (p.next) list.head = p.next;
21079
+ else list.head = list.tail = null;
21080
+ } else {
21081
+ list.head = p;
21082
+ p.data = str.slice(nb);
21083
+ }
21084
+ break;
21085
+ }
21086
+ ++c;
21087
+ }
21088
+ list.length -= c;
21089
+ return ret;
21090
+ }
21091
+ function copyFromBuffer(n, list) {
21092
+ var ret = Buffer$1.allocUnsafe(n);
21093
+ var p = list.head;
21094
+ var c = 1;
21095
+ p.data.copy(ret);
21096
+ n -= p.data.length;
21097
+ while (p = p.next) {
21098
+ var buf = p.data;
21099
+ var nb = n > buf.length ? buf.length : n;
21100
+ buf.copy(ret, ret.length - n, 0, nb);
21101
+ n -= nb;
21102
+ if (n === 0) {
21103
+ if (nb === buf.length) {
21104
+ ++c;
21105
+ if (p.next) list.head = p.next;
21106
+ else list.head = list.tail = null;
21107
+ } else {
21108
+ list.head = p;
21109
+ p.data = buf.slice(nb);
21110
+ }
21111
+ break;
21112
+ }
21113
+ ++c;
21114
+ }
21115
+ list.length -= c;
21116
+ return ret;
21117
+ }
21118
+ function endReadable(stream) {
21119
+ var state = stream._readableState;
21120
+ if (state.length > 0) throw new Error("\"endReadable()\" called on non-empty stream");
21121
+ if (!state.endEmitted) {
21122
+ state.ended = true;
21123
+ nextTick(endReadableNT, state, stream);
21124
+ }
21125
+ }
21126
+ function endReadableNT(state, stream) {
21127
+ if (!state.endEmitted && state.length === 0) {
21128
+ state.endEmitted = true;
21129
+ stream.readable = false;
21130
+ stream.emit("end");
21131
+ }
21132
+ }
21133
+ function forEach(xs, f) {
21134
+ for (var i = 0, l = xs.length; i < l; i++) f(xs[i], i);
21135
+ }
21136
+ function indexOf(xs, x) {
21137
+ for (var i = 0, l = xs.length; i < l; i++) if (xs[i] === x) return i;
21138
+ return -1;
21139
+ }
21140
+ //#endregion
21141
+ //#region \0polyfill-node._stream_writable.js
21142
+ Writable.WritableState = WritableState;
21143
+ _polyfill_node__inherits_default(Writable, EventEmitter);
21144
+ function nop() {}
21145
+ function WriteReq(chunk, encoding, cb) {
21146
+ this.chunk = chunk;
21147
+ this.encoding = encoding;
21148
+ this.callback = cb;
21149
+ this.next = null;
21150
+ }
21151
+ function WritableState(options, stream) {
21152
+ Object.defineProperty(this, "buffer", { get: deprecate(function() {
21153
+ return this.getBuffer();
21154
+ }, "_writableState.buffer is deprecated. Use _writableState.getBuffer instead.") });
21155
+ options = options || {};
21156
+ this.objectMode = !!options.objectMode;
21157
+ if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
21158
+ var hwm = options.highWaterMark;
21159
+ var defaultHwm = this.objectMode ? 16 : 16 * 1024;
21160
+ this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
21161
+ this.highWaterMark = ~~this.highWaterMark;
21162
+ this.needDrain = false;
21163
+ this.ending = false;
21164
+ this.ended = false;
21165
+ this.finished = false;
21166
+ this.decodeStrings = !(options.decodeStrings === false);
21167
+ this.defaultEncoding = options.defaultEncoding || "utf8";
21168
+ this.length = 0;
21169
+ this.writing = false;
21170
+ this.corked = 0;
21171
+ this.sync = true;
21172
+ this.bufferProcessing = false;
21173
+ this.onwrite = function(er) {
21174
+ onwrite(stream, er);
21175
+ };
21176
+ this.writecb = null;
21177
+ this.writelen = 0;
21178
+ this.bufferedRequest = null;
21179
+ this.lastBufferedRequest = null;
21180
+ this.pendingcb = 0;
21181
+ this.prefinished = false;
21182
+ this.errorEmitted = false;
21183
+ this.bufferedRequestCount = 0;
21184
+ this.corkedRequestsFree = new CorkedRequest(this);
21185
+ }
21186
+ WritableState.prototype.getBuffer = function writableStateGetBuffer() {
21187
+ var current = this.bufferedRequest;
21188
+ var out = [];
21189
+ while (current) {
21190
+ out.push(current);
21191
+ current = current.next;
21192
+ }
21193
+ return out;
21194
+ };
21195
+ function Writable(options) {
21196
+ if (!(this instanceof Writable) && !(this instanceof Duplex)) return new Writable(options);
21197
+ this._writableState = new WritableState(options, this);
21198
+ this.writable = true;
21199
+ if (options) {
21200
+ if (typeof options.write === "function") this._write = options.write;
21201
+ if (typeof options.writev === "function") this._writev = options.writev;
21202
+ }
21203
+ EventEmitter.call(this);
21204
+ }
21205
+ Writable.prototype.pipe = function() {
21206
+ this.emit("error", /* @__PURE__ */ new Error("Cannot pipe, not readable"));
21207
+ };
21208
+ function writeAfterEnd(stream, cb) {
21209
+ var er = /* @__PURE__ */ new Error("write after end");
21210
+ stream.emit("error", er);
21211
+ nextTick(cb, er);
21212
+ }
21213
+ function validChunk(stream, state, chunk, cb) {
21214
+ var valid = true;
21215
+ var er = false;
21216
+ if (chunk === null) er = /* @__PURE__ */ new TypeError("May not write null values to stream");
21217
+ else if (!Buffer$1.isBuffer(chunk) && typeof chunk !== "string" && chunk !== void 0 && !state.objectMode) er = /* @__PURE__ */ new TypeError("Invalid non-string/buffer chunk");
21218
+ if (er) {
21219
+ stream.emit("error", er);
21220
+ nextTick(cb, er);
21221
+ valid = false;
21222
+ }
21223
+ return valid;
21224
+ }
21225
+ Writable.prototype.write = function(chunk, encoding, cb) {
21226
+ var state = this._writableState;
21227
+ var ret = false;
21228
+ if (typeof encoding === "function") {
21229
+ cb = encoding;
21230
+ encoding = null;
21231
+ }
21232
+ if (Buffer$1.isBuffer(chunk)) encoding = "buffer";
21233
+ else if (!encoding) encoding = state.defaultEncoding;
21234
+ if (typeof cb !== "function") cb = nop;
21235
+ if (state.ended) writeAfterEnd(this, cb);
21236
+ else if (validChunk(this, state, chunk, cb)) {
21237
+ state.pendingcb++;
21238
+ ret = writeOrBuffer(this, state, chunk, encoding, cb);
21239
+ }
21240
+ return ret;
21241
+ };
21242
+ Writable.prototype.cork = function() {
21243
+ var state = this._writableState;
21244
+ state.corked++;
21245
+ };
21246
+ Writable.prototype.uncork = function() {
21247
+ var state = this._writableState;
21248
+ if (state.corked) {
21249
+ state.corked--;
21250
+ if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
21251
+ }
21252
+ };
21253
+ Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
21254
+ if (typeof encoding === "string") encoding = encoding.toLowerCase();
21255
+ if (!([
21256
+ "hex",
21257
+ "utf8",
21258
+ "utf-8",
21259
+ "ascii",
21260
+ "binary",
21261
+ "base64",
21262
+ "ucs2",
21263
+ "ucs-2",
21264
+ "utf16le",
21265
+ "utf-16le",
21266
+ "raw"
21267
+ ].indexOf((encoding + "").toLowerCase()) > -1)) throw new TypeError("Unknown encoding: " + encoding);
21268
+ this._writableState.defaultEncoding = encoding;
21269
+ return this;
21270
+ };
21271
+ function decodeChunk(state, chunk, encoding) {
21272
+ if (!state.objectMode && state.decodeStrings !== false && typeof chunk === "string") chunk = Buffer$1.from(chunk, encoding);
21273
+ return chunk;
21274
+ }
21275
+ function writeOrBuffer(stream, state, chunk, encoding, cb) {
21276
+ chunk = decodeChunk(state, chunk, encoding);
21277
+ if (Buffer$1.isBuffer(chunk)) encoding = "buffer";
21278
+ var len = state.objectMode ? 1 : chunk.length;
21279
+ state.length += len;
21280
+ var ret = state.length < state.highWaterMark;
21281
+ if (!ret) state.needDrain = true;
21282
+ if (state.writing || state.corked) {
21283
+ var last = state.lastBufferedRequest;
21284
+ state.lastBufferedRequest = new WriteReq(chunk, encoding, cb);
21285
+ if (last) last.next = state.lastBufferedRequest;
21286
+ else state.bufferedRequest = state.lastBufferedRequest;
21287
+ state.bufferedRequestCount += 1;
21288
+ } else doWrite(stream, state, false, len, chunk, encoding, cb);
21289
+ return ret;
21290
+ }
21291
+ function doWrite(stream, state, writev, len, chunk, encoding, cb) {
21292
+ state.writelen = len;
21293
+ state.writecb = cb;
21294
+ state.writing = true;
21295
+ state.sync = true;
21296
+ if (writev) stream._writev(chunk, state.onwrite);
21297
+ else stream._write(chunk, encoding, state.onwrite);
21298
+ state.sync = false;
21299
+ }
21300
+ function onwriteError(stream, state, sync, er, cb) {
21301
+ --state.pendingcb;
21302
+ if (sync) nextTick(cb, er);
21303
+ else cb(er);
21304
+ stream._writableState.errorEmitted = true;
21305
+ stream.emit("error", er);
21306
+ }
21307
+ function onwriteStateUpdate(state) {
21308
+ state.writing = false;
21309
+ state.writecb = null;
21310
+ state.length -= state.writelen;
21311
+ state.writelen = 0;
21312
+ }
21313
+ function onwrite(stream, er) {
21314
+ var state = stream._writableState;
21315
+ var sync = state.sync;
21316
+ var cb = state.writecb;
21317
+ onwriteStateUpdate(state);
21318
+ if (er) onwriteError(stream, state, sync, er, cb);
21319
+ else {
21320
+ var finished = needFinish(state);
21321
+ if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(stream, state);
21322
+ if (sync) nextTick(afterWrite, stream, state, finished, cb);
21323
+ else afterWrite(stream, state, finished, cb);
21324
+ }
21325
+ }
21326
+ function afterWrite(stream, state, finished, cb) {
21327
+ if (!finished) onwriteDrain(stream, state);
21328
+ state.pendingcb--;
21329
+ cb();
21330
+ finishMaybe(stream, state);
21331
+ }
21332
+ function onwriteDrain(stream, state) {
21333
+ if (state.length === 0 && state.needDrain) {
21334
+ state.needDrain = false;
21335
+ stream.emit("drain");
21336
+ }
21337
+ }
21338
+ function clearBuffer(stream, state) {
21339
+ state.bufferProcessing = true;
21340
+ var entry = state.bufferedRequest;
21341
+ if (stream._writev && entry && entry.next) {
21342
+ var l = state.bufferedRequestCount;
21343
+ var buffer = new Array(l);
21344
+ var holder = state.corkedRequestsFree;
21345
+ holder.entry = entry;
21346
+ var count = 0;
21347
+ while (entry) {
21348
+ buffer[count] = entry;
21349
+ entry = entry.next;
21350
+ count += 1;
21351
+ }
21352
+ doWrite(stream, state, true, state.length, buffer, "", holder.finish);
21353
+ state.pendingcb++;
21354
+ state.lastBufferedRequest = null;
21355
+ if (holder.next) {
21356
+ state.corkedRequestsFree = holder.next;
21357
+ holder.next = null;
21358
+ } else state.corkedRequestsFree = new CorkedRequest(state);
21359
+ } else {
21360
+ while (entry) {
21361
+ var chunk = entry.chunk;
21362
+ var encoding = entry.encoding;
21363
+ var cb = entry.callback;
21364
+ doWrite(stream, state, false, state.objectMode ? 1 : chunk.length, chunk, encoding, cb);
21365
+ entry = entry.next;
21366
+ if (state.writing) break;
21367
+ }
21368
+ if (entry === null) state.lastBufferedRequest = null;
21369
+ }
21370
+ state.bufferedRequestCount = 0;
21371
+ state.bufferedRequest = entry;
21372
+ state.bufferProcessing = false;
21373
+ }
21374
+ Writable.prototype._write = function(chunk, encoding, cb) {
21375
+ cb(/* @__PURE__ */ new Error("not implemented"));
21376
+ };
21377
+ Writable.prototype._writev = null;
21378
+ Writable.prototype.end = function(chunk, encoding, cb) {
21379
+ var state = this._writableState;
21380
+ if (typeof chunk === "function") {
21381
+ cb = chunk;
21382
+ chunk = null;
21383
+ encoding = null;
21384
+ } else if (typeof encoding === "function") {
21385
+ cb = encoding;
21386
+ encoding = null;
21387
+ }
21388
+ if (chunk !== null && chunk !== void 0) this.write(chunk, encoding);
21389
+ if (state.corked) {
21390
+ state.corked = 1;
21391
+ this.uncork();
21392
+ }
21393
+ if (!state.ending && !state.finished) endWritable(this, state, cb);
21394
+ };
21395
+ function needFinish(state) {
21396
+ return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
21397
+ }
21398
+ function prefinish(stream, state) {
21399
+ if (!state.prefinished) {
21400
+ state.prefinished = true;
21401
+ stream.emit("prefinish");
21402
+ }
21403
+ }
21404
+ function finishMaybe(stream, state) {
21405
+ var need = needFinish(state);
21406
+ if (need) if (state.pendingcb === 0) {
21407
+ prefinish(stream, state);
21408
+ state.finished = true;
21409
+ stream.emit("finish");
21410
+ } else prefinish(stream, state);
21411
+ return need;
21412
+ }
21413
+ function endWritable(stream, state, cb) {
21414
+ state.ending = true;
21415
+ finishMaybe(stream, state);
21416
+ if (cb) if (state.finished) nextTick(cb);
21417
+ else stream.once("finish", cb);
21418
+ state.ended = true;
21419
+ stream.writable = false;
21420
+ }
21421
+ function CorkedRequest(state) {
21422
+ var _this = this;
21423
+ this.next = null;
21424
+ this.entry = null;
21425
+ this.finish = function(err) {
21426
+ var entry = _this.entry;
21427
+ _this.entry = null;
21428
+ while (entry) {
21429
+ var cb = entry.callback;
21430
+ state.pendingcb--;
21431
+ cb(err);
21432
+ entry = entry.next;
21433
+ }
21434
+ if (state.corkedRequestsFree) state.corkedRequestsFree.next = _this;
21435
+ else state.corkedRequestsFree = _this;
21436
+ };
21437
+ }
21438
+ //#endregion
21439
+ //#region \0polyfill-node._stream_duplex.js
21440
+ _polyfill_node__inherits_default(Duplex, Readable);
21441
+ var keys = Object.keys(Writable.prototype);
21442
+ for (var v = 0; v < keys.length; v++) {
21443
+ var method = keys[v];
21444
+ if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
21445
+ }
21446
+ function Duplex(options) {
21447
+ if (!(this instanceof Duplex)) return new Duplex(options);
21448
+ Readable.call(this, options);
21449
+ Writable.call(this, options);
21450
+ if (options && options.readable === false) this.readable = false;
21451
+ if (options && options.writable === false) this.writable = false;
21452
+ this.allowHalfOpen = true;
21453
+ if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
21454
+ this.once("end", onend);
21455
+ }
21456
+ function onend() {
21457
+ if (this.allowHalfOpen || this._writableState.ended) return;
21458
+ nextTick(onEndNT, this);
21459
+ }
21460
+ function onEndNT(self) {
21461
+ self.end();
21462
+ }
21463
+ //#endregion
21464
+ //#region src/util/output-type.ts
21465
+ /**
21466
+ * Output type definitions for document generation.
21467
+ *
21468
+ * This module defines the various output formats supported when generating
21469
+ * .docx files. These types correspond to fflate's output formats.
21470
+ *
21471
+ * @module
21472
+ */
21473
+ /**
21474
+ * Converts a Uint8Array to the specified output type.
21475
+ *
21476
+ * This is used by both the Packer and patchDocument to convert fflate's
21477
+ * raw Uint8Array output into the user's requested format.
21478
+ */
21479
+ const convertOutput = (data, type) => {
21480
+ switch (type) {
21481
+ case "nodebuffer": return Buffer$1.from(data);
21482
+ case "blob": return new Blob([data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength)], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" });
21483
+ case "arraybuffer": return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
21484
+ case "uint8array": return data;
21485
+ case "base64": return btoa((0, fflate.strFromU8)(data, true));
21486
+ case "string":
21487
+ case "text":
21488
+ case "binarystring": return (0, fflate.strFromU8)(data, true);
21489
+ case "array": return [...data];
21490
+ default: return data;
21491
+ }
21492
+ };
21493
+ //#endregion
21494
+ //#region src/file/fonts/obfuscate-ttf-to-odttf.ts
21495
+ /**
21496
+ * Font obfuscation module for embedding fonts in WordprocessingML documents.
21497
+ *
21498
+ * This module implements the OOXML font obfuscation algorithm used to embed
21499
+ * fonts in DOCX documents. Obfuscation is required by the OOXML specification
21500
+ * to prevent simple extraction of embedded font files.
21501
+ *
21502
+ * Reference: ECMA-376 Part 2, Section 11.1 (Font Embedding)
21503
+ *
21504
+ * @module
21505
+ */
21506
+ /** Start offset for obfuscation in the font file */
21507
+ const obfuscatedStartOffset = 0;
21508
+ /** End offset for obfuscation (first 32 bytes are obfuscated) */
21509
+ const obfuscatedEndOffset = 32;
21510
+ /** Expected GUID size (32 hex characters without dashes) */
21511
+ const guidSize = 32;
21512
+ /**
21513
+ * Obfuscates a TrueType font file for embedding in OOXML documents.
21514
+ *
21515
+ * The obfuscation algorithm XORs the first 32 bytes of the font file
21516
+ * with a reversed byte sequence derived from the font's GUID key.
21517
+ * This prevents simple extraction while maintaining font functionality.
21518
+ *
21519
+ * @param buf - The original font file as a byte array
21520
+ * @param fontKey - The GUID key for the font (with or without dashes)
21521
+ * @returns The obfuscated font data
21522
+ * @throws Error if the fontKey is not a valid 32-character GUID
21523
+ *
21524
+ * @example
21525
+ * ```typescript
21526
+ * const fontData = readFileSync("font.ttf");
21527
+ * const fontKey = "00000000-0000-0000-0000-000000000000";
21528
+ * const obfuscatedData = obfuscate(fontData, fontKey);
21529
+ * ```
21530
+ *
21531
+ * @internal
21532
+ */
21533
+ const obfuscate = (buf, fontKey) => {
21534
+ const guid = fontKey.replace(/-/g, "");
21535
+ if (guid.length !== guidSize) throw new Error(`Error: Cannot extract GUID from font filename: ${fontKey}`);
21536
+ const hexNumbers = guid.replace(/(..)/g, "$1 ").trim().split(" ").map((hexString) => parseInt(hexString, 16));
21537
+ hexNumbers.reverse();
21538
+ const obfuscatedBytes = buf.slice(obfuscatedStartOffset, obfuscatedEndOffset).map((byte, i) => byte ^ hexNumbers[i % hexNumbers.length]);
21539
+ const out = new Uint8Array(obfuscatedStartOffset + obfuscatedBytes.length + Math.max(0, buf.length - obfuscatedEndOffset));
21540
+ out.set(buf.slice(0, obfuscatedStartOffset));
21541
+ out.set(obfuscatedBytes, obfuscatedStartOffset);
21542
+ out.set(buf.slice(obfuscatedEndOffset), obfuscatedStartOffset + obfuscatedBytes.length);
21543
+ return out;
21544
+ };
21545
+ //#endregion
21546
+ //#region src/export/formatter.ts
21547
+ /**
21548
+ * Converts XML components into serializable objects ready for XML generation.
21549
+ *
21550
+ * The Formatter is responsible for preparing XML components for serialization by calling
21551
+ * their prepForXml method with the appropriate context. This is a critical step in the
21552
+ * export pipeline that transforms the declarative API objects into XML-compatible structures.
21553
+ *
21554
+ * @example
21555
+ * ```typescript
21556
+ * const formatter = new Formatter();
21557
+ * const paragraph = new Paragraph("Hello World");
21558
+ * const xmlObject = formatter.format(paragraph, context);
21559
+ * ```
21560
+ */
21561
+ var Formatter = class {
21562
+ /**
21563
+ * Formats an XML component into a serializable object.
21564
+ *
21565
+ * @param input - The XML component to format
21566
+ * @param context - The context containing file state and relationships
21567
+ * @returns A serializable XML object structure
21568
+ * @throws Error if the component cannot be formatted correctly
21569
+ */
21570
+ format(input, context = { stack: [] }) {
21571
+ const output = input.prepForXml(context);
21572
+ if (output) return output;
21573
+ else throw new Error("XMLComponent did not format correctly");
21574
+ }
21575
+ };
21576
+ //#endregion
21577
+ //#region src/export/packer/image-replacer.ts
21578
+ /**
21579
+ * Replaces image placeholders with relationship IDs in XML content.
21580
+ *
21581
+ * During document compilation, images are referenced using placeholder tokens
21582
+ * like {image1.png}. This class replaces those placeholders with the actual
21583
+ * relationship IDs used in the OOXML structure.
18399
21584
  *
18400
21585
  * @example
18401
21586
  * ```typescript
@@ -18875,32 +22060,6 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
18875
22060
  }
18876
22061
  };
18877
22062
  //#endregion
18878
- //#region \0@oxc-project+runtime@0.123.0/helpers/asyncToGenerator.js
18879
- function asyncGeneratorStep(n, t, e, r, o, a, c) {
18880
- try {
18881
- var i = n[a](c), u = i.value;
18882
- } catch (n) {
18883
- e(n);
18884
- return;
18885
- }
18886
- i.done ? t(u) : Promise.resolve(u).then(r, o);
18887
- }
18888
- function _asyncToGenerator(n) {
18889
- return function() {
18890
- var t = this, e = arguments;
18891
- return new Promise(function(r, o) {
18892
- var a = n.apply(t, e);
18893
- function _next(n) {
18894
- asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
18895
- }
18896
- function _throw(n) {
18897
- asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
18898
- }
18899
- _next(void 0);
18900
- });
18901
- };
18902
- }
18903
- //#endregion
18904
22063
  //#region src/export/packer/packer.ts
18905
22064
  /**
18906
22065
  * Packer module for exporting documents to various output formats.
@@ -18953,11 +22112,8 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
18953
22112
  * @param overrides - Optional array of file overrides for custom XML content
18954
22113
  * @returns A promise resolving to the exported document in the specified format
18955
22114
  */
18956
- static pack(_x, _x2, _x3) {
18957
- var _this = this;
18958
- return _asyncToGenerator(function* (file, type, prettify, overrides = []) {
18959
- return convertOutput((0, fflate.zipSync)(_this.compiler.compile(file, convertPrettifyType(prettify), overrides), { level: 6 }), type);
18960
- }).apply(this, arguments);
22115
+ static async pack(file, type, prettify, overrides = []) {
22116
+ return convertOutput((0, fflate.zipSync)(this.compiler.compile(file, convertPrettifyType(prettify), overrides), { level: 6 }), type);
18961
22117
  }
18962
22118
  /**
18963
22119
  * Exports a document to a string representation.
@@ -19033,16 +22189,20 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
19033
22189
  * ```
19034
22190
  */
19035
22191
  static toStream(file, prettify, overrides = []) {
19036
- const stream$1 = new stream.Readable({ read() {} });
22192
+ /* v8 ignore start */
22193
+ const stream = new Readable({ read() {} });
22194
+ /* v8 ignore stop */
19037
22195
  try {
19038
22196
  const files = this.compiler.compile(file, convertPrettifyType(prettify), overrides);
19039
22197
  const zip = new fflate.Zip((err, chunk, final) => {
22198
+ /* v8 ignore start */
19040
22199
  if (err) {
19041
- stream$1.destroy(err);
22200
+ stream.destroy(err);
19042
22201
  return;
19043
22202
  }
19044
- if (!stream$1.destroyed) stream$1.push(chunk);
19045
- if (final) stream$1.push(null);
22203
+ /* v8 ignore stop */
22204
+ if (!stream.destroyed) stream.push(chunk);
22205
+ if (final) stream.push(null);
19046
22206
  });
19047
22207
  for (const [name, data] of Object.entries(files)) {
19048
22208
  var _level;
@@ -19054,9 +22214,9 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
19054
22214
  }
19055
22215
  zip.end();
19056
22216
  } catch (err) {
19057
- stream$1.destroy(err instanceof Error ? err : new Error(String(err)));
22217
+ stream.destroy(err instanceof Error ? err : new Error(String(err)));
19058
22218
  }
19059
- return stream$1;
22219
+ return stream;
19060
22220
  }
19061
22221
  };
19062
22222
  _defineProperty(Packer, "compiler", new Compiler());
@@ -19125,7 +22285,10 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
19125
22285
  * // Adds xml:space="preserve" to maintain whitespace
19126
22286
  * ```
19127
22287
  */
19128
- const patchSpaceAttribute = (element) => _objectSpread2(_objectSpread2({}, element), {}, { attributes: { "xml:space": "preserve" } });
22288
+ const patchSpaceAttribute = (element) => ({
22289
+ ...element,
22290
+ attributes: { "xml:space": "preserve" }
22291
+ });
19129
22292
  /**
19130
22293
  * Retrieves first-level child elements by parent element name.
19131
22294
  *
@@ -19317,14 +22480,24 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
19317
22480
  if (e.type === "element" && e.name === "w:t") {
19318
22481
  var _ref, _e$elements;
19319
22482
  const splitText = ((_ref = (_e$elements = e.elements) === null || _e$elements === void 0 || (_e$elements = _e$elements[0]) === null || _e$elements === void 0 ? void 0 : _e$elements.text) !== null && _ref !== void 0 ? _ref : "").split(token);
19320
- const newElements = splitText.map((t) => _objectSpread2(_objectSpread2(_objectSpread2({}, e), patchSpaceAttribute(e)), {}, { elements: createTextElementContents(t) }));
22483
+ const newElements = splitText.map((t) => ({
22484
+ ...e,
22485
+ ...patchSpaceAttribute(e),
22486
+ elements: createTextElementContents(t)
22487
+ }));
19321
22488
  if (splitText.length > 1) splitIndex = i;
19322
22489
  return newElements;
19323
22490
  } else return e;
19324
22491
  }).flat()) !== null && _runElement$elements$ !== void 0 ? _runElement$elements$ : [];
19325
22492
  return {
19326
- left: _objectSpread2(_objectSpread2({}, JSON.parse(JSON.stringify(runElement))), {}, { elements: splitElements.slice(0, splitIndex + 1) }),
19327
- right: _objectSpread2(_objectSpread2({}, JSON.parse(JSON.stringify(runElement))), {}, { elements: splitElements.slice(splitIndex + 1) })
22493
+ left: {
22494
+ ...JSON.parse(JSON.stringify(runElement)),
22495
+ elements: splitElements.slice(0, splitIndex + 1)
22496
+ },
22497
+ right: {
22498
+ ...JSON.parse(JSON.stringify(runElement)),
22499
+ elements: splitElements.slice(splitIndex + 1)
22500
+ }
19328
22501
  };
19329
22502
  };
19330
22503
  //#endregion
@@ -19584,9 +22757,15 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
19584
22757
  const runElementNonTextualElements = runElementToBeReplaced.elements.filter((e) => e.type === "element" && e.name === "w:rPr");
19585
22758
  newRunElements = textJson.map((e) => {
19586
22759
  var _e$elements;
19587
- return _objectSpread2(_objectSpread2({}, e), {}, { elements: [...runElementNonTextualElements, ...(_e$elements = e.elements) !== null && _e$elements !== void 0 ? _e$elements : []] });
22760
+ return {
22761
+ ...e,
22762
+ elements: [...runElementNonTextualElements, ...(_e$elements = e.elements) !== null && _e$elements !== void 0 ? _e$elements : []]
22763
+ };
19588
22764
  });
19589
- patchedRightElement = _objectSpread2(_objectSpread2({}, right), {}, { elements: [...runElementNonTextualElements, ...right.elements] });
22765
+ patchedRightElement = {
22766
+ ...right,
22767
+ elements: [...runElementNonTextualElements, ...right.elements]
22768
+ };
19590
22769
  }
19591
22770
  paragraphElement.elements.splice(index, 1, left, ...newRunElements, patchedRightElement);
19592
22771
  break;
@@ -19672,69 +22851,70 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
19672
22851
  *
19673
22852
  * @publicApi
19674
22853
  */
19675
- const patchDocument = function() {
19676
- var _ref = _asyncToGenerator(function* ({ outputType, data, patches, keepOriginalStyles, placeholderDelimiters = {
19677
- end: "}}",
19678
- start: "{{"
19679
- }, recursive = true }) {
19680
- const zipContent = (0, fflate.unzipSync)((0, undio.toUint8Array)(data));
19681
- const contexts = /* @__PURE__ */ new Map();
19682
- const file = { Media: new Media() };
19683
- const map = /* @__PURE__ */ new Map();
19684
- const imageRelationshipAdditions = [];
19685
- const hyperlinkRelationshipAdditions = [];
19686
- let hasMedia = false;
19687
- const binaryContentMap = /* @__PURE__ */ new Map();
19688
- for (const [key, value] of Object.entries(zipContent)) {
19689
- const startBytes = value.slice(0, 2);
19690
- if (compareByteArrays(startBytes, UTF16LE) || compareByteArrays(startBytes, UTF16BE)) {
19691
- binaryContentMap.set(key, value);
19692
- continue;
19693
- }
19694
- if (!key.endsWith(".xml") && !key.endsWith(".rels")) {
19695
- binaryContentMap.set(key, value);
19696
- continue;
19697
- }
19698
- const json = toJson((0, fflate.strFromU8)(value));
19699
- if (key === "word/document.xml") {
19700
- var _json$elements;
19701
- const document = (_json$elements = json.elements) === null || _json$elements === void 0 ? void 0 : _json$elements.find((i) => i.name === "w:document");
19702
- if (document && document.attributes) {
19703
- for (const ns of [
19704
- "mc",
19705
- "wp",
19706
- "r",
19707
- "w15",
19708
- "m"
19709
- ]) document.attributes[`xmlns:${ns}`] = DocumentAttributeNamespaces[ns];
19710
- document.attributes["mc:Ignorable"] = `${document.attributes["mc:Ignorable"] || ""} w15`.trim();
19711
- }
22854
+ const patchDocument = async ({ outputType, data, patches, keepOriginalStyles, placeholderDelimiters = {
22855
+ end: "}}",
22856
+ start: "{{"
22857
+ }, recursive = true }) => {
22858
+ const zipContent = (0, fflate.unzipSync)((0, undio.toUint8Array)(data));
22859
+ const contexts = /* @__PURE__ */ new Map();
22860
+ const file = { Media: new Media() };
22861
+ const map = /* @__PURE__ */ new Map();
22862
+ const imageRelationshipAdditions = [];
22863
+ const hyperlinkRelationshipAdditions = [];
22864
+ let hasMedia = false;
22865
+ const binaryContentMap = /* @__PURE__ */ new Map();
22866
+ for (const [key, value] of Object.entries(zipContent)) {
22867
+ const startBytes = value.slice(0, 2);
22868
+ if (compareByteArrays(startBytes, UTF16LE) || compareByteArrays(startBytes, UTF16BE)) {
22869
+ binaryContentMap.set(key, value);
22870
+ continue;
22871
+ }
22872
+ if (!key.endsWith(".xml") && !key.endsWith(".rels")) {
22873
+ binaryContentMap.set(key, value);
22874
+ continue;
22875
+ }
22876
+ const json = toJson((0, fflate.strFromU8)(value));
22877
+ if (key === "word/document.xml") {
22878
+ var _json$elements;
22879
+ const document = (_json$elements = json.elements) === null || _json$elements === void 0 ? void 0 : _json$elements.find((i) => i.name === "w:document");
22880
+ if (document && document.attributes) {
22881
+ for (const ns of [
22882
+ "mc",
22883
+ "wp",
22884
+ "r",
22885
+ "w15",
22886
+ "m"
22887
+ ]) document.attributes[`xmlns:${ns}`] = DocumentAttributeNamespaces[ns];
22888
+ document.attributes["mc:Ignorable"] = `${document.attributes["mc:Ignorable"] || ""} w15`.trim();
19712
22889
  }
19713
- if (key.startsWith("word/") && !key.endsWith(".xml.rels")) {
19714
- const context = {
19715
- file,
19716
- stack: [],
19717
- viewWrapper: { Relationships: { addRelationship: (linkId, _, target, __) => {
19718
- hyperlinkRelationshipAdditions.push({
19719
- hyperlink: {
19720
- id: linkId,
19721
- link: target
19722
- },
19723
- key
19724
- });
19725
- } } }
19726
- };
19727
- contexts.set(key, context);
19728
- if (!(placeholderDelimiters === null || placeholderDelimiters === void 0 ? void 0 : placeholderDelimiters.start.trim()) || !(placeholderDelimiters === null || placeholderDelimiters === void 0 ? void 0 : placeholderDelimiters.end.trim())) throw new Error("Both start and end delimiters must be non-empty strings.");
19729
- const { start, end } = placeholderDelimiters;
19730
- for (const [patchKey, patchValue] of Object.entries(patches)) {
19731
- const patchText = `${start}${patchKey}${end}`;
19732
- while (true) {
19733
- const { didFindOccurrence } = replacer({
19734
- context,
19735
- json,
19736
- keepOriginalStyles,
19737
- patch: _objectSpread2(_objectSpread2({}, patchValue), {}, { children: patchValue.children.map((element) => {
22890
+ }
22891
+ if (key.startsWith("word/") && !key.endsWith(".xml.rels")) {
22892
+ const context = {
22893
+ file,
22894
+ stack: [],
22895
+ viewWrapper: { Relationships: { addRelationship: (linkId, _, target, __) => {
22896
+ hyperlinkRelationshipAdditions.push({
22897
+ hyperlink: {
22898
+ id: linkId,
22899
+ link: target
22900
+ },
22901
+ key
22902
+ });
22903
+ } } }
22904
+ };
22905
+ contexts.set(key, context);
22906
+ if (!(placeholderDelimiters === null || placeholderDelimiters === void 0 ? void 0 : placeholderDelimiters.start.trim()) || !(placeholderDelimiters === null || placeholderDelimiters === void 0 ? void 0 : placeholderDelimiters.end.trim())) throw new Error("Both start and end delimiters must be non-empty strings.");
22907
+ const { start, end } = placeholderDelimiters;
22908
+ for (const [patchKey, patchValue] of Object.entries(patches)) {
22909
+ const patchText = `${start}${patchKey}${end}`;
22910
+ while (true) {
22911
+ const { didFindOccurrence } = replacer({
22912
+ context,
22913
+ json,
22914
+ keepOriginalStyles,
22915
+ patch: {
22916
+ ...patchValue,
22917
+ children: patchValue.children.map((element) => {
19738
22918
  if (element instanceof ExternalHyperlink) {
19739
22919
  const concreteHyperlink = new ConcreteHyperlink(element.options.children, uniqueId());
19740
22920
  hyperlinkRelationshipAdditions.push({
@@ -19746,63 +22926,60 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
19746
22926
  });
19747
22927
  return concreteHyperlink;
19748
22928
  } else return element;
19749
- }) }),
19750
- patchText
19751
- });
19752
- if (!recursive || !didFindOccurrence) break;
19753
- }
19754
- }
19755
- const mediaDatas = imageReplacer.getMediaData(JSON.stringify(json), context.file.Media);
19756
- if (mediaDatas.length > 0) {
19757
- hasMedia = true;
19758
- imageRelationshipAdditions.push({
19759
- key,
19760
- mediaDatas
22929
+ })
22930
+ },
22931
+ patchText
19761
22932
  });
22933
+ if (!recursive || !didFindOccurrence) break;
19762
22934
  }
19763
22935
  }
19764
- map.set(key, json);
19765
- }
19766
- for (const { key, mediaDatas } of imageRelationshipAdditions) {
19767
- var _map$get;
19768
- const relationshipKey = `word/_rels/${key.split("/").pop()}.rels`;
19769
- const relationshipsJson = (_map$get = map.get(relationshipKey)) !== null && _map$get !== void 0 ? _map$get : createRelationshipFile();
19770
- map.set(relationshipKey, relationshipsJson);
19771
- const index = getNextRelationshipIndex(relationshipsJson);
19772
- const newJson = imageReplacer.replace(JSON.stringify(map.get(key)), mediaDatas, index);
19773
- map.set(key, JSON.parse(newJson));
19774
- for (let i = 0; i < mediaDatas.length; i++) {
19775
- const { fileName } = mediaDatas[i];
19776
- appendRelationship(relationshipsJson, index + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `media/${fileName}`);
22936
+ const mediaDatas = imageReplacer.getMediaData(JSON.stringify(json), context.file.Media);
22937
+ if (mediaDatas.length > 0) {
22938
+ hasMedia = true;
22939
+ imageRelationshipAdditions.push({
22940
+ key,
22941
+ mediaDatas
22942
+ });
19777
22943
  }
19778
22944
  }
19779
- for (const { key, hyperlink } of hyperlinkRelationshipAdditions) {
19780
- var _map$get2;
19781
- const relationshipKey = `word/_rels/${key.split("/").pop()}.rels`;
19782
- const relationshipsJson = (_map$get2 = map.get(relationshipKey)) !== null && _map$get2 !== void 0 ? _map$get2 : createRelationshipFile();
19783
- map.set(relationshipKey, relationshipsJson);
19784
- appendRelationship(relationshipsJson, hyperlink.id, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", hyperlink.link, TargetModeType.EXTERNAL);
22945
+ map.set(key, json);
22946
+ }
22947
+ for (const { key, mediaDatas } of imageRelationshipAdditions) {
22948
+ var _map$get;
22949
+ const relationshipKey = `word/_rels/${key.split("/").pop()}.rels`;
22950
+ const relationshipsJson = (_map$get = map.get(relationshipKey)) !== null && _map$get !== void 0 ? _map$get : createRelationshipFile();
22951
+ map.set(relationshipKey, relationshipsJson);
22952
+ const index = getNextRelationshipIndex(relationshipsJson);
22953
+ const newJson = imageReplacer.replace(JSON.stringify(map.get(key)), mediaDatas, index);
22954
+ map.set(key, JSON.parse(newJson));
22955
+ for (let i = 0; i < mediaDatas.length; i++) {
22956
+ const { fileName } = mediaDatas[i];
22957
+ appendRelationship(relationshipsJson, index + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `media/${fileName}`);
19785
22958
  }
19786
- if (hasMedia) {
19787
- const contentTypesJson = map.get("[Content_Types].xml");
19788
- if (!contentTypesJson) throw new Error("Could not find content types file");
19789
- appendContentType(contentTypesJson, "image/png", "png");
19790
- appendContentType(contentTypesJson, "image/jpeg", "jpeg");
19791
- appendContentType(contentTypesJson, "image/jpeg", "jpg");
19792
- appendContentType(contentTypesJson, "image/bmp", "bmp");
19793
- appendContentType(contentTypesJson, "image/gif", "gif");
19794
- appendContentType(contentTypesJson, "image/svg+xml", "svg");
19795
- }
19796
- const files = {};
19797
- for (const [key, value] of map) files[key] = (0, undio.textToUint8Array)(toXml(value));
19798
- for (const [key, value] of binaryContentMap) files[key] = value;
19799
- for (const { data: mediaData, fileName } of file.Media.Array) files[`word/media/${fileName}`] = mediaData instanceof Uint8Array ? mediaData : new Uint8Array(mediaData);
19800
- return convertOutput((0, fflate.zipSync)(files, { level: 6 }), outputType);
19801
- });
19802
- return function patchDocument(_x) {
19803
- return _ref.apply(this, arguments);
19804
- };
19805
- }();
22959
+ }
22960
+ for (const { key, hyperlink } of hyperlinkRelationshipAdditions) {
22961
+ var _map$get2;
22962
+ const relationshipKey = `word/_rels/${key.split("/").pop()}.rels`;
22963
+ const relationshipsJson = (_map$get2 = map.get(relationshipKey)) !== null && _map$get2 !== void 0 ? _map$get2 : createRelationshipFile();
22964
+ map.set(relationshipKey, relationshipsJson);
22965
+ appendRelationship(relationshipsJson, hyperlink.id, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", hyperlink.link, TargetModeType.EXTERNAL);
22966
+ }
22967
+ if (hasMedia) {
22968
+ const contentTypesJson = map.get("[Content_Types].xml");
22969
+ if (!contentTypesJson) throw new Error("Could not find content types file");
22970
+ appendContentType(contentTypesJson, "image/png", "png");
22971
+ appendContentType(contentTypesJson, "image/jpeg", "jpeg");
22972
+ appendContentType(contentTypesJson, "image/jpeg", "jpg");
22973
+ appendContentType(contentTypesJson, "image/bmp", "bmp");
22974
+ appendContentType(contentTypesJson, "image/gif", "gif");
22975
+ appendContentType(contentTypesJson, "image/svg+xml", "svg");
22976
+ }
22977
+ const files = {};
22978
+ for (const [key, value] of map) files[key] = (0, undio.textToUint8Array)(toXml(value));
22979
+ for (const [key, value] of binaryContentMap) files[key] = value;
22980
+ for (const { data: mediaData, fileName } of file.Media.Array) files[`word/media/${fileName}`] = mediaData instanceof Uint8Array ? mediaData : new Uint8Array(mediaData);
22981
+ return convertOutput((0, fflate.zipSync)(files, { level: 6 }), outputType);
22982
+ };
19806
22983
  const toXml = (jsonObj) => {
19807
22984
  return (0, xml_js.js2xml)(jsonObj, { attributeValueFn: (str) => String(str).replace(/&(?!amp;|lt;|gt;|quot;|apos;)/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;") });
19808
22985
  };
@@ -19851,20 +23028,15 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
19851
23028
  * });
19852
23029
  * ```
19853
23030
  */
19854
- const patchDetector = function() {
19855
- var _ref = _asyncToGenerator(function* ({ data }) {
19856
- const zipContent = (0, fflate.unzipSync)((0, undio.toUint8Array)(data));
19857
- const patches = /* @__PURE__ */ new Set();
19858
- for (const [key, value] of Object.entries(zipContent)) {
19859
- if (!key.endsWith(".xml") && !key.endsWith(".rels")) continue;
19860
- if (key.startsWith("word/") && !key.endsWith(".xml.rels")) traverse(toJson((0, fflate.strFromU8)(value))).forEach((p) => findPatchKeys(p.text).forEach((patch) => patches.add(patch)));
19861
- }
19862
- return [...patches];
19863
- });
19864
- return function patchDetector(_x) {
19865
- return _ref.apply(this, arguments);
19866
- };
19867
- }();
23031
+ const patchDetector = async ({ data }) => {
23032
+ const zipContent = (0, fflate.unzipSync)((0, undio.toUint8Array)(data));
23033
+ const patches = /* @__PURE__ */ new Set();
23034
+ for (const [key, value] of Object.entries(zipContent)) {
23035
+ if (!key.endsWith(".xml") && !key.endsWith(".rels")) continue;
23036
+ if (key.startsWith("word/") && !key.endsWith(".xml.rels")) traverse(toJson((0, fflate.strFromU8)(value))).forEach((p) => findPatchKeys(p.text).forEach((patch) => patches.add(patch)));
23037
+ }
23038
+ return [...patches];
23039
+ };
19868
23040
  /**
19869
23041
  * Extracts placeholder keys from text using regex pattern.
19870
23042
  *
@@ -19873,8 +23045,7 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
19873
23045
  */
19874
23046
  const findPatchKeys = (text) => {
19875
23047
  var _text$match;
19876
- const pattern = /* @__PURE__ */ new RegExp("(?<=\\{\\{).+?(?=\\}\\})", "gs");
19877
- return (_text$match = text.match(pattern)) !== null && _text$match !== void 0 ? _text$match : [];
23048
+ return (_text$match = text.match(/(?<=\{\{).+?(?=\}\})/gs)) !== null && _text$match !== void 0 ? _text$match : [];
19878
23049
  };
19879
23050
  //#endregion
19880
23051
  exports.AbstractNumbering = AbstractNumbering;
@@ -20173,7 +23344,6 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
20173
23344
  exports.shortHexNumber = shortHexNumber;
20174
23345
  exports.signedHpsMeasureValue = signedHpsMeasureValue;
20175
23346
  exports.signedTwipsMeasureValue = signedTwipsMeasureValue;
20176
- exports.standardizeData = standardizeData;
20177
23347
  exports.twipsMeasureValue = twipsMeasureValue;
20178
23348
  exports.uCharHexNumber = uCharHexNumber;
20179
23349
  exports.uniqueId = uniqueId;
@@ -20182,4 +23352,4 @@ var docxPlus = (function(exports, xml_js, hash_js, nanoid_non_secure, stream, ff
20182
23352
  exports.universalMeasureValue = universalMeasureValue;
20183
23353
  exports.unsignedDecimalNumber = unsignedDecimalNumber;
20184
23354
  return exports;
20185
- })({}, xml_js, hash_js, nanoid_non_secure, stream, fflate, undio, xml);
23355
+ })({}, xml_js, hash_js, nanoid_non_secure, undio, fflate, xml);