docx-plus 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1,15 +1,14 @@
1
1
  (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("xml-js"), require("hash.js"), require("nanoid/non-secure"), require("undio"), require("stream"), require("fflate"), require("xml")) : typeof define === "function" && define.amd ? define([
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("xml-js"), require("hash.js"), require("nanoid/non-secure"), require("undio"), require("fflate"), require("xml")) : typeof define === "function" && define.amd ? define([
3
3
  "exports",
4
4
  "xml-js",
5
5
  "hash.js",
6
6
  "nanoid/non-secure",
7
7
  "undio",
8
- "stream",
9
8
  "fflate",
10
9
  "xml"
11
- ], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.docxPlus = {}, global.xml_js, global.hash_js, global.nanoid_non_secure, global.undio, global.stream, global.fflate, global.xml));
12
- })(this, function(exports, xml_js, hash_js, nanoid_non_secure, undio, stream, fflate, xml) {
10
+ ], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.docx = {}, global.xml_js, global.hash_js, global.nanoid_non_secure, global.undio, global.fflate, global.xml));
11
+ })(this, function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate, xml) {
13
12
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
14
13
  //#region \0rolldown/runtime.js
15
14
  var __create = Object.create;
@@ -33,9 +32,9 @@
33
32
  enumerable: true
34
33
  }) : target, mod));
35
34
  //#endregion
36
- hash_js = __toESM(hash_js);
37
- xml = __toESM(xml);
38
- //#region \0@oxc-project+runtime@0.123.0/helpers/typeof.js
35
+ hash_js = __toESM(hash_js, 1);
36
+ xml = __toESM(xml, 1);
37
+ //#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
39
38
  function _typeof(o) {
40
39
  "@babel/helpers - typeof";
41
40
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -45,7 +44,7 @@
45
44
  }, _typeof(o);
46
45
  }
47
46
  //#endregion
48
- //#region \0@oxc-project+runtime@0.123.0/helpers/toPrimitive.js
47
+ //#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
49
48
  function toPrimitive(t, r) {
50
49
  if ("object" != _typeof(t) || !t) return t;
51
50
  var e = t[Symbol.toPrimitive];
@@ -57,13 +56,13 @@
57
56
  return ("string" === r ? String : Number)(t);
58
57
  }
59
58
  //#endregion
60
- //#region \0@oxc-project+runtime@0.123.0/helpers/toPropertyKey.js
59
+ //#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
61
60
  function toPropertyKey(t) {
62
61
  var i = toPrimitive(t, "string");
63
62
  return "symbol" == _typeof(i) ? i : i + "";
64
63
  }
65
64
  //#endregion
66
- //#region \0@oxc-project+runtime@0.123.0/helpers/defineProperty.js
65
+ //#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
67
66
  function _defineProperty(e, r, t) {
68
67
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
69
68
  value: t,
@@ -248,29 +247,6 @@
248
247
  }
249
248
  };
250
249
  //#endregion
251
- //#region \0@oxc-project+runtime@0.123.0/helpers/objectSpread2.js
252
- function ownKeys(e, r) {
253
- var t = Object.keys(e);
254
- if (Object.getOwnPropertySymbols) {
255
- var o = Object.getOwnPropertySymbols(e);
256
- r && (o = o.filter(function(r) {
257
- return Object.getOwnPropertyDescriptor(e, r).enumerable;
258
- })), t.push.apply(t, o);
259
- }
260
- return t;
261
- }
262
- function _objectSpread2(e) {
263
- for (var r = 1; r < arguments.length; r++) {
264
- var t = null != arguments[r] ? arguments[r] : {};
265
- r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
266
- _defineProperty(e, r, t[r]);
267
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
268
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
269
- });
270
- }
271
- return e;
272
- }
273
- //#endregion
274
250
  //#region src/file/xml-components/default-attributes.ts
275
251
  /**
276
252
  * XML attribute components for the docx library.
@@ -364,7 +340,10 @@
364
340
  * @returns Object with _attr key containing the attributes
365
341
  */
366
342
  prepForXml(_) {
367
- return { _attr: Object.values(this.root).filter(({ value }) => value !== void 0).reduce((acc, { key, value }) => _objectSpread2(_objectSpread2({}, acc), {}, { [key]: value }), {}) };
343
+ return { _attr: Object.values(this.root).filter(({ value }) => value !== void 0).reduce((acc, { key, value }) => ({
344
+ ...acc,
345
+ [key]: value
346
+ }), {}) };
368
347
  }
369
348
  };
370
349
  //#endregion
@@ -415,6 +394,9 @@
415
394
  rsidSect: "w:rsidSect",
416
395
  space: "w:space",
417
396
  sz: "w:sz",
397
+ themeColor: "w:themeColor",
398
+ themeShade: "w:themeShade",
399
+ themeTint: "w:themeTint",
418
400
  top: "w:top",
419
401
  type: "w:type",
420
402
  val: "w:val",
@@ -941,6 +923,49 @@
941
923
  * ```
942
924
  */
943
925
  const dateTimeValue = (val) => val.toISOString();
926
+ /**
927
+ * Theme color values used throughout OOXML for referencing document theme colors.
928
+ *
929
+ * Reference: ST_ThemeColor in OOXML specification
930
+ *
931
+ * @publicApi
932
+ */
933
+ const ThemeColor = {
934
+ DARK1: "dark1",
935
+ LIGHT1: "light1",
936
+ DARK2: "dark2",
937
+ LIGHT2: "light2",
938
+ ACCENT1: "accent1",
939
+ ACCENT2: "accent2",
940
+ ACCENT3: "accent3",
941
+ ACCENT4: "accent4",
942
+ ACCENT5: "accent5",
943
+ ACCENT6: "accent6",
944
+ HYPERLINK: "hyperlink",
945
+ FOLLOWED_HYPERLINK: "followedHyperlink",
946
+ NONE: "none",
947
+ BACKGROUND1: "background1",
948
+ TEXT1: "text1",
949
+ BACKGROUND2: "background2",
950
+ TEXT2: "text2"
951
+ };
952
+ /**
953
+ * Theme font values used for referencing document theme fonts.
954
+ *
955
+ * Reference: ST_Theme in OOXML specification
956
+ *
957
+ * @publicApi
958
+ */
959
+ const ThemeFont = {
960
+ MAJOR_EAST_ASIA: "majorEastAsia",
961
+ MAJOR_BIDI: "majorBidi",
962
+ MAJOR_ASCII: "majorAscii",
963
+ MAJOR_H_ANSI: "majorHAnsi",
964
+ MINOR_EAST_ASIA: "minorEastAsia",
965
+ MINOR_BIDI: "minorBidi",
966
+ MINOR_ASCII: "minorAscii",
967
+ MINOR_H_ANSI: "minorHAnsi"
968
+ };
944
969
  //#endregion
945
970
  //#region src/file/xml-components/simple-elements.ts
946
971
  /**
@@ -1353,12 +1378,20 @@
1353
1378
  * });
1354
1379
  * ```
1355
1380
  */
1356
- const createBorderElement = (elementName, { color, size, space, style }) => new BuilderElement({
1381
+ const createBorderElement = (elementName, { color, size, space, style, themeColor, themeTint, themeShade, shadow, frame }) => new BuilderElement({
1357
1382
  attributes: {
1358
1383
  color: {
1359
1384
  key: "w:color",
1360
1385
  value: color === void 0 ? void 0 : hexColorValue(color)
1361
1386
  },
1387
+ frame: {
1388
+ key: "w:frame",
1389
+ value: frame
1390
+ },
1391
+ shadow: {
1392
+ key: "w:shadow",
1393
+ value: shadow
1394
+ },
1362
1395
  size: {
1363
1396
  key: "w:sz",
1364
1397
  value: size === void 0 ? void 0 : eighthPointMeasureValue(size)
@@ -1370,6 +1403,18 @@
1370
1403
  style: {
1371
1404
  key: "w:val",
1372
1405
  value: style
1406
+ },
1407
+ themeColor: {
1408
+ key: "w:themeColor",
1409
+ value: themeColor
1410
+ },
1411
+ themeShade: {
1412
+ key: "w:themeShade",
1413
+ value: themeShade === void 0 ? void 0 : uCharHexNumber(themeShade)
1414
+ },
1415
+ themeTint: {
1416
+ key: "w:themeTint",
1417
+ value: themeTint === void 0 ? void 0 : uCharHexNumber(themeTint)
1373
1418
  }
1374
1419
  },
1375
1420
  name: elementName
@@ -1573,20 +1618,32 @@
1573
1618
  * </xsd:complexType>
1574
1619
  * ```
1575
1620
  */
1576
- const createIndent = ({ start, end, left, right, hanging, firstLine }) => new BuilderElement({
1621
+ const createIndent = ({ start, startChars, end, endChars, left, right, hanging, hangingChars, firstLine, firstLineChars }) => new BuilderElement({
1577
1622
  attributes: {
1578
1623
  end: {
1579
1624
  key: "w:end",
1580
1625
  value: end === void 0 ? void 0 : signedTwipsMeasureValue(end)
1581
1626
  },
1627
+ endChars: {
1628
+ key: "w:endChars",
1629
+ value: endChars === void 0 ? void 0 : decimalNumber(endChars)
1630
+ },
1582
1631
  firstLine: {
1583
1632
  key: "w:firstLine",
1584
1633
  value: firstLine === void 0 ? void 0 : twipsMeasureValue(firstLine)
1585
1634
  },
1635
+ firstLineChars: {
1636
+ key: "w:firstLineChars",
1637
+ value: firstLineChars === void 0 ? void 0 : decimalNumber(firstLineChars)
1638
+ },
1586
1639
  hanging: {
1587
1640
  key: "w:hanging",
1588
1641
  value: hanging === void 0 ? void 0 : twipsMeasureValue(hanging)
1589
1642
  },
1643
+ hangingChars: {
1644
+ key: "w:hangingChars",
1645
+ value: hangingChars === void 0 ? void 0 : decimalNumber(hangingChars)
1646
+ },
1590
1647
  left: {
1591
1648
  key: "w:left",
1592
1649
  value: left === void 0 ? void 0 : signedTwipsMeasureValue(left)
@@ -1598,6 +1655,10 @@
1598
1655
  start: {
1599
1656
  key: "w:start",
1600
1657
  value: start === void 0 ? void 0 : signedTwipsMeasureValue(start)
1658
+ },
1659
+ startChars: {
1660
+ key: "w:startChars",
1661
+ value: startChars === void 0 ? void 0 : decimalNumber(startChars)
1601
1662
  }
1602
1663
  },
1603
1664
  name: "w:ind"
@@ -2048,7 +2109,7 @@
2048
2109
  *
2049
2110
  * Reference: http://officeopenxml.com/WPshading.php
2050
2111
  */
2051
- const createShading = ({ fill, color, type }) => new BuilderElement({
2112
+ const createShading = ({ fill, color, type, themeColor, themeTint, themeShade, themeFill, themeFillTint, themeFillShade }) => new BuilderElement({
2052
2113
  attributes: {
2053
2114
  color: {
2054
2115
  key: "w:color",
@@ -2058,6 +2119,30 @@
2058
2119
  key: "w:fill",
2059
2120
  value: fill === void 0 ? void 0 : hexColorValue(fill)
2060
2121
  },
2122
+ themeColor: {
2123
+ key: "w:themeColor",
2124
+ value: themeColor
2125
+ },
2126
+ themeFill: {
2127
+ key: "w:themeFill",
2128
+ value: themeFill
2129
+ },
2130
+ themeFillShade: {
2131
+ key: "w:themeFillShade",
2132
+ value: themeFillShade === void 0 ? void 0 : uCharHexNumber(themeFillShade)
2133
+ },
2134
+ themeFillTint: {
2135
+ key: "w:themeFillTint",
2136
+ value: themeFillTint === void 0 ? void 0 : uCharHexNumber(themeFillTint)
2137
+ },
2138
+ themeShade: {
2139
+ key: "w:themeShade",
2140
+ value: themeShade === void 0 ? void 0 : uCharHexNumber(themeShade)
2141
+ },
2142
+ themeTint: {
2143
+ key: "w:themeTint",
2144
+ value: themeTint === void 0 ? void 0 : uCharHexNumber(themeTint)
2145
+ },
2061
2146
  type: {
2062
2147
  key: "w:val",
2063
2148
  value: type
@@ -2236,7 +2321,13 @@
2236
2321
  *
2237
2322
  * @publicApi
2238
2323
  */
2239
- const EmphasisMarkType = { DOT: "dot" };
2324
+ const EmphasisMarkType = {
2325
+ NONE: "none",
2326
+ COMMA: "comma",
2327
+ CIRCLE: "circle",
2328
+ DOT: "dot",
2329
+ UNDER_DOT: "underDot"
2330
+ };
2240
2331
  /**
2241
2332
  * Creates an emphasis mark element for a WordprocessingML document.
2242
2333
  *
@@ -2327,16 +2418,27 @@
2327
2418
  *
2328
2419
  * @example
2329
2420
  * ```typescript
2330
- * new Color("FF0000"); // Red text
2421
+ * new Color("FF0000"); // Red text (backward compatible)
2331
2422
  * new Color("auto"); // Automatic color
2423
+ * new Color({ themeColor: ThemeColor.ACCENT1, themeTint: "99" }); // Theme color with tint
2332
2424
  * ```
2333
2425
  *
2334
2426
  * @internal
2335
2427
  */
2336
2428
  var Color = class extends XmlComponent {
2337
- constructor(color) {
2429
+ constructor(colorOrOptions) {
2338
2430
  super("w:color");
2339
- this.root.push(new Attributes({ val: hexColorValue(color) }));
2431
+ if (typeof colorOrOptions === "string") {
2432
+ this.root.push(new Attributes({ val: hexColorValue(colorOrOptions) }));
2433
+ return;
2434
+ }
2435
+ const opts = colorOrOptions;
2436
+ this.root.push(new Attributes({
2437
+ val: opts.val === void 0 ? void 0 : hexColorValue(opts.val),
2438
+ themeColor: opts.themeColor,
2439
+ themeTint: opts.themeTint === void 0 ? void 0 : uCharHexNumber(opts.themeTint),
2440
+ themeShade: opts.themeShade === void 0 ? void 0 : uCharHexNumber(opts.themeShade)
2441
+ }));
2340
2442
  }
2341
2443
  };
2342
2444
  /**
@@ -2535,18 +2637,34 @@
2535
2637
  key: "w:ascii",
2536
2638
  value: attrs.ascii
2537
2639
  },
2640
+ asciiTheme: {
2641
+ key: "w:asciiTheme",
2642
+ value: attrs.asciiTheme
2643
+ },
2538
2644
  cs: {
2539
2645
  key: "w:cs",
2540
2646
  value: attrs.cs
2541
2647
  },
2648
+ cstheme: {
2649
+ key: "w:cstheme",
2650
+ value: attrs.cstheme
2651
+ },
2542
2652
  eastAsia: {
2543
2653
  key: "w:eastAsia",
2544
2654
  value: attrs.eastAsia
2545
2655
  },
2656
+ eastAsiaTheme: {
2657
+ key: "w:eastAsiaTheme",
2658
+ value: attrs.eastAsiaTheme
2659
+ },
2546
2660
  hAnsi: {
2547
2661
  key: "w:hAnsi",
2548
2662
  value: attrs.hAnsi
2549
2663
  },
2664
+ hAnsiTheme: {
2665
+ key: "w:hAnsiTheme",
2666
+ value: attrs.hAnsiTheme
2667
+ },
2550
2668
  hint: {
2551
2669
  key: "w:hint",
2552
2670
  value: attrs.hint
@@ -2703,12 +2821,24 @@
2703
2821
  * createUnderline(UnderlineType.WAVE, "FF0000");
2704
2822
  * ```
2705
2823
  */
2706
- const createUnderline = (underlineType = UnderlineType.SINGLE, color) => new BuilderElement({
2824
+ const createUnderline = (underlineType = UnderlineType.SINGLE, color, themeColor, themeTint, themeShade) => new BuilderElement({
2707
2825
  attributes: {
2708
2826
  color: {
2709
2827
  key: "w:color",
2710
2828
  value: color === void 0 ? void 0 : hexColorValue(color)
2711
2829
  },
2830
+ themeColor: {
2831
+ key: "w:themeColor",
2832
+ value: themeColor
2833
+ },
2834
+ themeShade: {
2835
+ key: "w:themeShade",
2836
+ value: themeShade === void 0 ? void 0 : uCharHexNumber(themeShade)
2837
+ },
2838
+ themeTint: {
2839
+ key: "w:themeTint",
2840
+ value: themeTint === void 0 ? void 0 : uCharHexNumber(themeTint)
2841
+ },
2712
2842
  val: {
2713
2843
  key: "w:val",
2714
2844
  value: underlineType
@@ -2860,6 +2990,9 @@
2860
2990
  if (options.doubleStrike !== void 0) this.push(new OnOffElement("w:dstrike", options.doubleStrike));
2861
2991
  if (options.emboss !== void 0) this.push(new OnOffElement("w:emboss", options.emboss));
2862
2992
  if (options.imprint !== void 0) this.push(new OnOffElement("w:imprint", options.imprint));
2993
+ if (options.outline !== void 0) this.push(new OnOffElement("w:outline", options.outline));
2994
+ if (options.shadow !== void 0) this.push(new OnOffElement("w:shadow", options.shadow));
2995
+ if (options.webHidden !== void 0) this.push(new OnOffElement("w:webHidden", options.webHidden));
2863
2996
  if (options.noProof !== void 0) this.push(new OnOffElement("w:noProof", options.noProof));
2864
2997
  if (options.snapToGrid !== void 0) this.push(new OnOffElement("w:snapToGrid", options.snapToGrid));
2865
2998
  if (options.vanish) this.push(new OnOffElement("w:vanish", options.vanish));
@@ -2885,6 +3018,8 @@
2885
3018
  if (options.language) this.push(createLanguageComponent(options.language));
2886
3019
  if (options.specVanish) this.push(new OnOffElement("w:specVanish", options.vanish));
2887
3020
  if (options.math) this.push(new OnOffElement("w:oMath", options.math));
3021
+ if (options.fitText !== void 0) this.push(new NumberValueElement("w:fitText", options.fitText));
3022
+ if (options.complexScript !== void 0) this.push(new OnOffElement("w:cs", options.complexScript));
2888
3023
  if (options.revision) this.push(new RunPropertiesChange(options.revision));
2889
3024
  }
2890
3025
  push(item) {
@@ -3320,18 +3455,6 @@
3320
3455
  * ```
3321
3456
  */
3322
3457
  const uniqueUuid = () => `${generateUuidPart(8)}-${generateUuidPart(4)}-${generateUuidPart(4)}-${generateUuidPart(4)}-${generateUuidPart(12)}`;
3323
- /**
3324
- * Encode a string to UTF-8 bytes.
3325
- *
3326
- * This is used to pre-encode XML content before passing to fflate's zipSync,
3327
- * which expects Uint8Array input for text content.
3328
- *
3329
- * The copy via `new Uint8Array()` ensures the returned array uses the
3330
- * current module's Uint8Array constructor, avoiding cross-realm issues
3331
- * in test environments (happy-dom) where TextEncoder returns a different
3332
- * realm's Uint8Array.
3333
- */
3334
- const encodeUtf8 = (str) => new Uint8Array(new TextEncoder().encode(str));
3335
3458
  //#endregion
3336
3459
  //#region src/file/drawing/floating/floating-position.ts
3337
3460
  /**
@@ -4738,13 +4861,16 @@
4738
4861
  * @returns An XML component representing the click hyperlink
4739
4862
  */
4740
4863
  const createHyperlinkClick = (linkId, hasXmlNs) => new BuilderElement({
4741
- attributes: _objectSpread2(_objectSpread2({}, hasXmlNs ? { xmlns: {
4742
- key: "xmlns:a",
4743
- value: "http://schemas.openxmlformats.org/drawingml/2006/main"
4744
- } } : {}), {}, { id: {
4745
- key: "r:id",
4746
- value: `rId${linkId}`
4747
- } }),
4864
+ attributes: {
4865
+ ...hasXmlNs ? { xmlns: {
4866
+ key: "xmlns:a",
4867
+ value: "http://schemas.openxmlformats.org/drawingml/2006/main"
4868
+ } } : {},
4869
+ id: {
4870
+ key: "r:id",
4871
+ value: `rId${linkId}`
4872
+ }
4873
+ },
4748
4874
  name: "a:hlinkClick"
4749
4875
  });
4750
4876
  //#endregion
@@ -4992,21 +5118,23 @@
4992
5118
  super("a:graphicData");
4993
5119
  if (mediaData.type === "wps") {
4994
5120
  this.root.push(new GraphicDataAttributes({ uri: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape" }));
4995
- const wps = createWpsShape(_objectSpread2(_objectSpread2({}, mediaData.data), {}, {
5121
+ const wps = createWpsShape({
5122
+ ...mediaData.data,
4996
5123
  outline,
4997
5124
  solidFill,
4998
5125
  transformation: transform
4999
- }));
5126
+ });
5000
5127
  this.root.push(wps);
5001
5128
  } else if (mediaData.type === "wpg") {
5002
5129
  this.root.push(new GraphicDataAttributes({ uri: "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" }));
5003
5130
  const wpg = createWpgGroup({
5004
5131
  children: mediaData.children.map((child) => {
5005
- if (child.type === "wps") return createWpsShape(_objectSpread2(_objectSpread2({}, child.data), {}, {
5132
+ if (child.type === "wps") return createWpsShape({
5133
+ ...child.data,
5006
5134
  outline: child.outline,
5007
5135
  solidFill: child.solidFill,
5008
5136
  transformation: child.transformation
5009
- }));
5137
+ });
5010
5138
  else return new Pic({
5011
5139
  mediaData: child,
5012
5140
  outline: child.outline,
@@ -5635,14 +5763,15 @@
5635
5763
  var Anchor = class extends XmlComponent {
5636
5764
  constructor({ mediaData, transform, drawingOptions }) {
5637
5765
  super("wp:anchor");
5638
- const floating = _objectSpread2({
5766
+ const floating = {
5639
5767
  allowOverlap: true,
5640
5768
  behindDocument: false,
5641
5769
  horizontalPosition: {},
5642
5770
  layoutInCell: true,
5643
5771
  lockAnchor: false,
5644
- verticalPosition: {}
5645
- }, drawingOptions.floating);
5772
+ verticalPosition: {},
5773
+ ...drawingOptions.floating
5774
+ };
5646
5775
  this.root.push(new AnchorAttributes({
5647
5776
  distT: floating.margins ? floating.margins.top || 0 : 0,
5648
5777
  distB: floating.margins ? floating.margins.bottom || 0 : 0,
@@ -5828,8 +5957,18 @@
5828
5957
  const key = `${hashedId(rawData)}.${options.type}`;
5829
5958
  if (options.type === "svg") {
5830
5959
  const fallbackData = (0, undio.toUint8Array)(options.fallback.data);
5831
- this.imageData = _objectSpread2(_objectSpread2({ type: options.type }, createImageData(rawData, options.transformation, key)), {}, { fallback: _objectSpread2({ type: options.fallback.type }, createImageData(fallbackData, options.transformation, `${hashedId(fallbackData)}.${options.fallback.type}`)) });
5832
- } else this.imageData = _objectSpread2({ type: options.type }, createImageData(rawData, options.transformation, key));
5960
+ this.imageData = {
5961
+ type: options.type,
5962
+ ...createImageData(rawData, options.transformation, key),
5963
+ fallback: {
5964
+ type: options.fallback.type,
5965
+ ...createImageData(fallbackData, options.transformation, `${hashedId(fallbackData)}.${options.fallback.type}`)
5966
+ }
5967
+ };
5968
+ } else this.imageData = {
5969
+ type: options.type,
5970
+ ...createImageData(rawData, options.transformation, key)
5971
+ };
5833
5972
  const drawing = new Drawing(this.imageData, {
5834
5973
  docProperties: options.altText,
5835
5974
  floating: options.floating,
@@ -5878,7 +6017,7 @@
5878
6017
  super({});
5879
6018
  _defineProperty(this, "wpsShapeData", void 0);
5880
6019
  this.wpsShapeData = {
5881
- data: _objectSpread2({}, options),
6020
+ data: { ...options },
5882
6021
  transformation: createTransformation(options.transformation),
5883
6022
  type: options.type
5884
6023
  };
@@ -6978,7 +7117,7 @@
6978
7117
  * });
6979
7118
  * ```
6980
7119
  */
6981
- const createSpacing = ({ after, before, line, lineRule, beforeAutoSpacing, afterAutoSpacing }) => new BuilderElement({
7120
+ const createSpacing = ({ after, before, line, lineRule, beforeAutoSpacing, afterAutoSpacing, beforeLines, afterLines }) => new BuilderElement({
6982
7121
  attributes: {
6983
7122
  after: {
6984
7123
  key: "w:after",
@@ -6988,6 +7127,10 @@
6988
7127
  key: "w:afterAutospacing",
6989
7128
  value: afterAutoSpacing
6990
7129
  },
7130
+ afterLines: {
7131
+ key: "w:afterLines",
7132
+ value: afterLines === void 0 ? void 0 : decimalNumber(afterLines)
7133
+ },
6991
7134
  before: {
6992
7135
  key: "w:before",
6993
7136
  value: before
@@ -6996,6 +7139,10 @@
6996
7139
  key: "w:beforeAutospacing",
6997
7140
  value: beforeAutoSpacing
6998
7141
  },
7142
+ beforeLines: {
7143
+ key: "w:beforeLines",
7144
+ value: beforeLines === void 0 ? void 0 : decimalNumber(beforeLines)
7145
+ },
6999
7146
  line: {
7000
7147
  key: "w:line",
7001
7148
  value: line
@@ -7106,6 +7253,7 @@
7106
7253
  */
7107
7254
  const LeaderType = {
7108
7255
  DOT: "dot",
7256
+ HEAVY: "heavy",
7109
7257
  HYPHEN: "hyphen",
7110
7258
  MIDDLE_DOT: "middleDot",
7111
7259
  NONE: "none",
@@ -7905,13 +8053,16 @@
7905
8053
  * Creates a font relationship element for embedding fonts.
7906
8054
  */
7907
8055
  const createFontRelationship = ({ id, fontKey, subsetted }, name) => new BuilderElement({
7908
- attributes: _objectSpread2({ id: {
7909
- key: "r:id",
7910
- value: id
7911
- } }, fontKey ? { fontKey: {
7912
- key: "w:fontKey",
7913
- value: `{${fontKey}}`
7914
- } } : {}),
8056
+ attributes: {
8057
+ id: {
8058
+ key: "r:id",
8059
+ value: id
8060
+ },
8061
+ ...fontKey ? { fontKey: {
8062
+ key: "w:fontKey",
8063
+ value: `{${fontKey}}`
8064
+ } } : {}
8065
+ },
7915
8066
  children: subsetted ? [new OnOffElement("w:subsetted", subsetted)] : [],
7916
8067
  name
7917
8068
  });
@@ -8149,7 +8300,10 @@
8149
8300
  _defineProperty(this, "fontTable", void 0);
8150
8301
  _defineProperty(this, "relationships", void 0);
8151
8302
  _defineProperty(this, "fontOptionsWithKey", []);
8152
- this.fontOptionsWithKey = options.map((o) => _objectSpread2(_objectSpread2({}, o), {}, { fontKey: uniqueUuid() }));
8303
+ this.fontOptionsWithKey = options.map((o) => ({
8304
+ ...o,
8305
+ fontKey: uniqueUuid()
8306
+ }));
8153
8307
  this.fontTable = createFontTable(this.fontOptionsWithKey);
8154
8308
  this.relationships = new Relationships();
8155
8309
  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`);
@@ -8567,7 +8721,10 @@
8567
8721
  date: options.date,
8568
8722
  id: options.id
8569
8723
  }));
8570
- this.root.push(new ParagraphProperties(_objectSpread2(_objectSpread2({}, options), {}, { includeIfEmpty: true })));
8724
+ this.root.push(new ParagraphProperties({
8725
+ ...options,
8726
+ includeIfEmpty: true
8727
+ }));
8571
8728
  }
8572
8729
  };
8573
8730
  //#endregion
@@ -10782,7 +10939,10 @@
10782
10939
  *
10783
10940
  * @publicApi
10784
10941
  */
10785
- const VerticalAlignSection = _objectSpread2(_objectSpread2({}, VerticalAlignTable), {}, { BOTH: "both" });
10942
+ const VerticalAlignSection = {
10943
+ ...VerticalAlignTable,
10944
+ BOTH: "both"
10945
+ };
10786
10946
  /**
10787
10947
  * @deprecated Use {@link VerticalAlignTable} for table cells or
10788
10948
  * {@link VerticalAlignSection} for section properties. This alias remains for
@@ -11299,7 +11459,10 @@
11299
11459
  date: options.date,
11300
11460
  id: options.id
11301
11461
  }));
11302
- this.root.push(new TableCellProperties(_objectSpread2(_objectSpread2({}, options), {}, { includeIfEmpty: true })));
11462
+ this.root.push(new TableCellProperties({
11463
+ ...options,
11464
+ includeIfEmpty: true
11465
+ }));
11303
11466
  }
11304
11467
  };
11305
11468
  //#endregion
@@ -11843,7 +12006,10 @@
11843
12006
  date: options.date,
11844
12007
  id: options.id
11845
12008
  }));
11846
- this.root.push(new TableProperties(_objectSpread2(_objectSpread2({}, options), {}, { includeIfEmpty: true })));
12009
+ this.root.push(new TableProperties({
12010
+ ...options,
12011
+ includeIfEmpty: true
12012
+ }));
11847
12013
  }
11848
12014
  };
11849
12015
  //#endregion
@@ -12088,7 +12254,10 @@
12088
12254
  date: options.date,
12089
12255
  id: options.id
12090
12256
  }));
12091
- this.root.push(new TableRowProperties(_objectSpread2(_objectSpread2({}, options), {}, { includeIfEmpty: true })));
12257
+ this.root.push(new TableRowProperties({
12258
+ ...options,
12259
+ includeIfEmpty: true
12260
+ }));
12092
12261
  }
12093
12262
  };
12094
12263
  //#endregion
@@ -12487,8 +12656,14 @@
12487
12656
  */
12488
12657
  var DocumentAttributes = class extends XmlAttributeComponent {
12489
12658
  constructor(ns, Ignorable) {
12490
- super(_objectSpread2({ Ignorable }, Object.fromEntries(ns.map((n) => [n, DocumentAttributeNamespaces[n]]))));
12491
- _defineProperty(this, "xmlKeys", _objectSpread2({ Ignorable: "mc:Ignorable" }, Object.fromEntries(Object.keys(DocumentAttributeNamespaces).map((key) => [key, `xmlns:${key}`]))));
12659
+ super({
12660
+ Ignorable,
12661
+ ...Object.fromEntries(ns.map((n) => [n, DocumentAttributeNamespaces[n]]))
12662
+ });
12663
+ _defineProperty(this, "xmlKeys", {
12664
+ Ignorable: "mc:Ignorable",
12665
+ ...Object.fromEntries(Object.keys(DocumentAttributeNamespaces).map((key) => [key, `xmlns:${key}`]))
12666
+ });
12492
12667
  }
12493
12668
  };
12494
12669
  //#endregion
@@ -16168,7 +16343,10 @@
16168
16343
  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));
16169
16344
  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));
16170
16345
  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));
16171
- 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 })));
16346
+ this.root.push(new Compatibility({
16347
+ ...options.compatibility,
16348
+ 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
16349
+ }));
16172
16350
  }
16173
16351
  };
16174
16352
  //#endregion
@@ -16437,10 +16615,11 @@
16437
16615
  super({
16438
16616
  styleId: options.id,
16439
16617
  type: "character"
16440
- }, _objectSpread2({
16618
+ }, {
16441
16619
  uiPriority: 99,
16442
- unhideWhenUsed: true
16443
- }, options));
16620
+ unhideWhenUsed: true,
16621
+ ...options
16622
+ });
16444
16623
  _defineProperty(this, "runProperties", void 0);
16445
16624
  this.runProperties = new RunProperties(options.run);
16446
16625
  this.root.push(this.runProperties);
@@ -16476,11 +16655,12 @@
16476
16655
  */
16477
16656
  var HeadingStyle = class extends StyleForParagraph {
16478
16657
  constructor(options) {
16479
- super(_objectSpread2({
16658
+ super({
16480
16659
  basedOn: "Normal",
16481
16660
  next: "Normal",
16482
- quickFormat: true
16483
- }, options));
16661
+ quickFormat: true,
16662
+ ...options
16663
+ });
16484
16664
  }
16485
16665
  };
16486
16666
  /**
@@ -16497,10 +16677,11 @@
16497
16677
  */
16498
16678
  var TitleStyle = class extends HeadingStyle {
16499
16679
  constructor(options) {
16500
- super(_objectSpread2({
16680
+ super({
16501
16681
  id: "Title",
16502
- name: "Title"
16503
- }, options));
16682
+ name: "Title",
16683
+ ...options
16684
+ });
16504
16685
  }
16505
16686
  };
16506
16687
  /**
@@ -16517,10 +16698,11 @@
16517
16698
  */
16518
16699
  var Heading1Style = class extends HeadingStyle {
16519
16700
  constructor(options) {
16520
- super(_objectSpread2({
16701
+ super({
16521
16702
  id: "Heading1",
16522
- name: "Heading 1"
16523
- }, options));
16703
+ name: "Heading 1",
16704
+ ...options
16705
+ });
16524
16706
  }
16525
16707
  };
16526
16708
  /**
@@ -16530,10 +16712,11 @@
16530
16712
  */
16531
16713
  var Heading2Style = class extends HeadingStyle {
16532
16714
  constructor(options) {
16533
- super(_objectSpread2({
16715
+ super({
16534
16716
  id: "Heading2",
16535
- name: "Heading 2"
16536
- }, options));
16717
+ name: "Heading 2",
16718
+ ...options
16719
+ });
16537
16720
  }
16538
16721
  };
16539
16722
  /**
@@ -16543,10 +16726,11 @@
16543
16726
  */
16544
16727
  var Heading3Style = class extends HeadingStyle {
16545
16728
  constructor(options) {
16546
- super(_objectSpread2({
16729
+ super({
16547
16730
  id: "Heading3",
16548
- name: "Heading 3"
16549
- }, options));
16731
+ name: "Heading 3",
16732
+ ...options
16733
+ });
16550
16734
  }
16551
16735
  };
16552
16736
  /**
@@ -16556,10 +16740,11 @@
16556
16740
  */
16557
16741
  var Heading4Style = class extends HeadingStyle {
16558
16742
  constructor(options) {
16559
- super(_objectSpread2({
16743
+ super({
16560
16744
  id: "Heading4",
16561
- name: "Heading 4"
16562
- }, options));
16745
+ name: "Heading 4",
16746
+ ...options
16747
+ });
16563
16748
  }
16564
16749
  };
16565
16750
  /**
@@ -16569,10 +16754,11 @@
16569
16754
  */
16570
16755
  var Heading5Style = class extends HeadingStyle {
16571
16756
  constructor(options) {
16572
- super(_objectSpread2({
16757
+ super({
16573
16758
  id: "Heading5",
16574
- name: "Heading 5"
16575
- }, options));
16759
+ name: "Heading 5",
16760
+ ...options
16761
+ });
16576
16762
  }
16577
16763
  };
16578
16764
  /**
@@ -16582,10 +16768,11 @@
16582
16768
  */
16583
16769
  var Heading6Style = class extends HeadingStyle {
16584
16770
  constructor(options) {
16585
- super(_objectSpread2({
16771
+ super({
16586
16772
  id: "Heading6",
16587
- name: "Heading 6"
16588
- }, options));
16773
+ name: "Heading 6",
16774
+ ...options
16775
+ });
16589
16776
  }
16590
16777
  };
16591
16778
  /**
@@ -16595,10 +16782,11 @@
16595
16782
  */
16596
16783
  var StrongStyle = class extends HeadingStyle {
16597
16784
  constructor(options) {
16598
- super(_objectSpread2({
16785
+ super({
16599
16786
  id: "Strong",
16600
- name: "Strong"
16601
- }, options));
16787
+ name: "Strong",
16788
+ ...options
16789
+ });
16602
16790
  }
16603
16791
  };
16604
16792
  /**
@@ -16608,12 +16796,13 @@
16608
16796
  */
16609
16797
  var ListParagraph = class extends StyleForParagraph {
16610
16798
  constructor(options) {
16611
- super(_objectSpread2({
16799
+ super({
16612
16800
  basedOn: "Normal",
16613
16801
  id: "ListParagraph",
16614
16802
  name: "List Paragraph",
16615
- quickFormat: true
16616
- }, options));
16803
+ quickFormat: true,
16804
+ ...options
16805
+ });
16617
16806
  }
16618
16807
  };
16619
16808
  /**
@@ -16623,7 +16812,7 @@
16623
16812
  */
16624
16813
  var FootnoteText = class extends StyleForParagraph {
16625
16814
  constructor(options) {
16626
- super(_objectSpread2({
16815
+ super({
16627
16816
  basedOn: "Normal",
16628
16817
  id: "FootnoteText",
16629
16818
  link: "FootnoteTextChar",
@@ -16636,8 +16825,9 @@
16636
16825
  run: { size: 20 },
16637
16826
  semiHidden: true,
16638
16827
  uiPriority: 99,
16639
- unhideWhenUsed: true
16640
- }, options));
16828
+ unhideWhenUsed: true,
16829
+ ...options
16830
+ });
16641
16831
  }
16642
16832
  };
16643
16833
  /**
@@ -16647,13 +16837,14 @@
16647
16837
  */
16648
16838
  var FootnoteReferenceStyle = class extends StyleForCharacter {
16649
16839
  constructor(options) {
16650
- super(_objectSpread2({
16840
+ super({
16651
16841
  basedOn: "DefaultParagraphFont",
16652
16842
  id: "FootnoteReference",
16653
16843
  name: "footnote reference",
16654
16844
  run: { superScript: true },
16655
- semiHidden: true
16656
- }, options));
16845
+ semiHidden: true,
16846
+ ...options
16847
+ });
16657
16848
  }
16658
16849
  };
16659
16850
  /**
@@ -16663,14 +16854,15 @@
16663
16854
  */
16664
16855
  var FootnoteTextChar = class extends StyleForCharacter {
16665
16856
  constructor(options) {
16666
- super(_objectSpread2({
16857
+ super({
16667
16858
  basedOn: "DefaultParagraphFont",
16668
16859
  id: "FootnoteTextChar",
16669
16860
  link: "FootnoteText",
16670
16861
  name: "Footnote Text Char",
16671
16862
  run: { size: 20 },
16672
- semiHidden: true
16673
- }, options));
16863
+ semiHidden: true,
16864
+ ...options
16865
+ });
16674
16866
  }
16675
16867
  };
16676
16868
  /**
@@ -16680,7 +16872,7 @@
16680
16872
  */
16681
16873
  var EndnoteText = class extends StyleForParagraph {
16682
16874
  constructor(options) {
16683
- super(_objectSpread2({
16875
+ super({
16684
16876
  basedOn: "Normal",
16685
16877
  id: "EndnoteText",
16686
16878
  link: "EndnoteTextChar",
@@ -16693,8 +16885,9 @@
16693
16885
  run: { size: 20 },
16694
16886
  semiHidden: true,
16695
16887
  uiPriority: 99,
16696
- unhideWhenUsed: true
16697
- }, options));
16888
+ unhideWhenUsed: true,
16889
+ ...options
16890
+ });
16698
16891
  }
16699
16892
  };
16700
16893
  /**
@@ -16704,13 +16897,14 @@
16704
16897
  */
16705
16898
  var EndnoteReferenceStyle = class extends StyleForCharacter {
16706
16899
  constructor(options) {
16707
- super(_objectSpread2({
16900
+ super({
16708
16901
  basedOn: "DefaultParagraphFont",
16709
16902
  id: "EndnoteReference",
16710
16903
  name: "endnote reference",
16711
16904
  run: { superScript: true },
16712
- semiHidden: true
16713
- }, options));
16905
+ semiHidden: true,
16906
+ ...options
16907
+ });
16714
16908
  }
16715
16909
  };
16716
16910
  /**
@@ -16720,14 +16914,15 @@
16720
16914
  */
16721
16915
  var EndnoteTextChar = class extends StyleForCharacter {
16722
16916
  constructor(options) {
16723
- super(_objectSpread2({
16917
+ super({
16724
16918
  basedOn: "DefaultParagraphFont",
16725
16919
  id: "EndnoteTextChar",
16726
16920
  link: "EndnoteText",
16727
16921
  name: "Endnote Text Char",
16728
16922
  run: { size: 20 },
16729
- semiHidden: true
16730
- }, options));
16923
+ semiHidden: true,
16924
+ ...options
16925
+ });
16731
16926
  }
16732
16927
  };
16733
16928
  /**
@@ -16737,15 +16932,16 @@
16737
16932
  */
16738
16933
  var HyperlinkStyle = class extends StyleForCharacter {
16739
16934
  constructor(options) {
16740
- super(_objectSpread2({
16935
+ super({
16741
16936
  basedOn: "DefaultParagraphFont",
16742
16937
  id: "Hyperlink",
16743
16938
  name: "Hyperlink",
16744
16939
  run: {
16745
16940
  color: "0563C1",
16746
16941
  underline: { type: UnderlineType.SINGLE }
16747
- }
16748
- }, options));
16942
+ },
16943
+ ...options
16944
+ });
16749
16945
  }
16750
16946
  };
16751
16947
  //#endregion
@@ -17015,26 +17211,50 @@
17015
17211
  return {
17016
17212
  importedStyles: [
17017
17213
  new DocumentDefaults((_options$document = options.document) !== null && _options$document !== void 0 ? _options$document : {}),
17018
- new TitleStyle(_objectSpread2({ run: { size: 56 } }, options.title)),
17019
- new Heading1Style(_objectSpread2({ run: {
17020
- color: "2E74B5",
17021
- size: 32
17022
- } }, options.heading1)),
17023
- new Heading2Style(_objectSpread2({ run: {
17024
- color: "2E74B5",
17025
- size: 26
17026
- } }, options.heading2)),
17027
- new Heading3Style(_objectSpread2({ run: {
17028
- color: "1F4D78",
17029
- size: 24
17030
- } }, options.heading3)),
17031
- new Heading4Style(_objectSpread2({ run: {
17032
- color: "2E74B5",
17033
- italics: true
17034
- } }, options.heading4)),
17035
- new Heading5Style(_objectSpread2({ run: { color: "2E74B5" } }, options.heading5)),
17036
- new Heading6Style(_objectSpread2({ run: { color: "1F4D78" } }, options.heading6)),
17037
- new StrongStyle(_objectSpread2({ run: { bold: true } }, options.strong)),
17214
+ new TitleStyle({
17215
+ run: { size: 56 },
17216
+ ...options.title
17217
+ }),
17218
+ new Heading1Style({
17219
+ run: {
17220
+ color: "2E74B5",
17221
+ size: 32
17222
+ },
17223
+ ...options.heading1
17224
+ }),
17225
+ new Heading2Style({
17226
+ run: {
17227
+ color: "2E74B5",
17228
+ size: 26
17229
+ },
17230
+ ...options.heading2
17231
+ }),
17232
+ new Heading3Style({
17233
+ run: {
17234
+ color: "1F4D78",
17235
+ size: 24
17236
+ },
17237
+ ...options.heading3
17238
+ }),
17239
+ new Heading4Style({
17240
+ run: {
17241
+ color: "2E74B5",
17242
+ italics: true
17243
+ },
17244
+ ...options.heading4
17245
+ }),
17246
+ new Heading5Style({
17247
+ run: { color: "2E74B5" },
17248
+ ...options.heading5
17249
+ }),
17250
+ new Heading6Style({
17251
+ run: { color: "1F4D78" },
17252
+ ...options.heading6
17253
+ }),
17254
+ new StrongStyle({
17255
+ run: { bold: true },
17256
+ ...options.strong
17257
+ }),
17038
17258
  new ListParagraph(options.listParagraph || {}),
17039
17259
  new HyperlinkStyle(options.hyperlink || {}),
17040
17260
  new FootnoteReferenceStyle(options.footnoteReference || {}),
@@ -17152,11 +17372,12 @@
17152
17372
  _defineProperty(this, "styles", void 0);
17153
17373
  _defineProperty(this, "comments", void 0);
17154
17374
  _defineProperty(this, "fontWrapper", void 0);
17155
- this.coreProperties = new CoreProperties(_objectSpread2(_objectSpread2({}, options), {}, {
17375
+ this.coreProperties = new CoreProperties({
17376
+ ...options,
17156
17377
  creator: (_options$creator = options.creator) !== null && _options$creator !== void 0 ? _options$creator : "Un-named",
17157
17378
  lastModifiedBy: (_options$lastModified = options.lastModifiedBy) !== null && _options$lastModified !== void 0 ? _options$lastModified : "Un-named",
17158
17379
  revision: (_options$revision = options.revision) !== null && _options$revision !== void 0 ? _options$revision : 1
17159
- }));
17380
+ });
17160
17381
  this.numbering = new Numbering(options.numbering ? options.numbering : { config: [] });
17161
17382
  this.comments = new Comments((_options$comments = options.comments) !== null && _options$comments !== void 0 ? _options$comments : { children: [] });
17162
17383
  this.fileRelationships = new Relationships();
@@ -17185,8 +17406,14 @@
17185
17406
  var _options$styles;
17186
17407
  const defaultStyles = new DefaultStylesFactory().newInstance((_options$styles = options.styles) === null || _options$styles === void 0 ? void 0 : _options$styles.default);
17187
17408
  const externalStyles = new ExternalStylesFactory().newInstance(options.externalStyles);
17188
- this.styles = new Styles(_objectSpread2(_objectSpread2({}, externalStyles), {}, { importedStyles: [...defaultStyles.importedStyles, ...externalStyles.importedStyles] }));
17189
- } else if (options.styles) this.styles = new Styles(_objectSpread2(_objectSpread2({}, new DefaultStylesFactory().newInstance(options.styles.default)), options.styles));
17409
+ this.styles = new Styles({
17410
+ ...externalStyles,
17411
+ importedStyles: [...defaultStyles.importedStyles, ...externalStyles.importedStyles]
17412
+ });
17413
+ } else if (options.styles) this.styles = new Styles({
17414
+ ...new DefaultStylesFactory().newInstance(options.styles.default),
17415
+ ...options.styles
17416
+ });
17190
17417
  else this.styles = new Styles(new DefaultStylesFactory().newInstance());
17191
17418
  this.addDefaultRelationships();
17192
17419
  for (const section of options.sections) this.addSection(section);
@@ -17195,7 +17422,8 @@
17195
17422
  this.fontWrapper = new FontWrapper((_options$fonts = options.fonts) !== null && _options$fonts !== void 0 ? _options$fonts : []);
17196
17423
  }
17197
17424
  addSection({ headers = {}, footers = {}, children, properties }) {
17198
- this.documentWrapper.View.Body.addSection(_objectSpread2(_objectSpread2({}, properties), {}, {
17425
+ this.documentWrapper.View.Body.addSection({
17426
+ ...properties,
17199
17427
  footerWrapperGroup: {
17200
17428
  default: footers.default ? this.createFooter(footers.default) : void 0,
17201
17429
  even: footers.even ? this.createFooter(footers.even) : void 0,
@@ -17206,7 +17434,7 @@
17206
17434
  even: headers.even ? this.createHeader(headers.even) : void 0,
17207
17435
  first: headers.first ? this.createHeader(headers.first) : void 0
17208
17436
  }
17209
- }));
17437
+ });
17210
17438
  for (const child of children) this.documentWrapper.View.add(child);
17211
17439
  }
17212
17440
  createHeader(header) {
@@ -17463,28 +17691,6 @@
17463
17691
  }
17464
17692
  };
17465
17693
  //#endregion
17466
- //#region \0@oxc-project+runtime@0.123.0/helpers/objectWithoutPropertiesLoose.js
17467
- function _objectWithoutPropertiesLoose(r, e) {
17468
- if (null == r) return {};
17469
- var t = {};
17470
- for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
17471
- if (e.includes(n)) continue;
17472
- t[n] = r[n];
17473
- }
17474
- return t;
17475
- }
17476
- //#endregion
17477
- //#region \0@oxc-project+runtime@0.123.0/helpers/objectWithoutProperties.js
17478
- function _objectWithoutProperties(e, t) {
17479
- if (null == e) return {};
17480
- var o, r, i = _objectWithoutPropertiesLoose(e, t);
17481
- if (Object.getOwnPropertySymbols) {
17482
- var s = Object.getOwnPropertySymbols(e);
17483
- for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
17484
- }
17485
- return i;
17486
- }
17487
- //#endregion
17488
17694
  //#region src/file/table-of-contents/table-of-contents.ts
17489
17695
  /**
17490
17696
  * Table of Contents module for WordprocessingML documents.
@@ -17496,11 +17702,6 @@
17496
17702
  *
17497
17703
  * @module
17498
17704
  */
17499
- const _excluded$1 = [
17500
- "contentChildren",
17501
- "cachedEntries",
17502
- "beginDirty"
17503
- ];
17504
17705
  /**
17505
17706
  * Represents a Table of Contents in a WordprocessingML document.
17506
17707
  *
@@ -17531,8 +17732,7 @@
17531
17732
  * ```
17532
17733
  */
17533
17734
  var TableOfContents = class extends FileChild {
17534
- constructor(alias = "Table of Contents", _ref = {}) {
17535
- let { contentChildren = [], cachedEntries = [], beginDirty = true } = _ref, properties = _objectWithoutProperties(_ref, _excluded$1);
17735
+ constructor(alias = "Table of Contents", { contentChildren = [], cachedEntries = [], beginDirty = true, ...properties } = {}) {
17536
17736
  super("w:sdt");
17537
17737
  this.root.push(new StructuredDocumentTagProperties(alias));
17538
17738
  const content = new StructuredDocumentTagContent();
@@ -18228,7 +18428,6 @@
18228
18428
  *
18229
18429
  * @module
18230
18430
  */
18231
- const _excluded = ["style", "children"];
18232
18431
  /**
18233
18432
  * Represents a textbox in a WordprocessingML document.
18234
18433
  *
@@ -18278,8 +18477,7 @@
18278
18477
  * ```
18279
18478
  */
18280
18479
  var Textbox = class extends FileChild {
18281
- constructor(_ref) {
18282
- let { style, children } = _ref, rest = _objectWithoutProperties(_ref, _excluded);
18480
+ constructor({ style, children, ...rest }) {
18283
18481
  super("w:p");
18284
18482
  this.root.push(new ParagraphProperties(rest));
18285
18483
  this.root.push(createPictElement({ shape: createShape({
@@ -18290,49 +18488,3185 @@
18290
18488
  }
18291
18489
  };
18292
18490
  //#endregion
18293
- //#region src/util/output-type.ts
18491
+ //#region \0polyfill-node.events.js
18492
+ var domain;
18493
+ function EventHandlers() {}
18494
+ EventHandlers.prototype = Object.create(null);
18495
+ function EventEmitter() {
18496
+ EventEmitter.init.call(this);
18497
+ }
18498
+ EventEmitter.EventEmitter = EventEmitter;
18499
+ EventEmitter.usingDomains = false;
18500
+ EventEmitter.prototype.domain = void 0;
18501
+ EventEmitter.prototype._events = void 0;
18502
+ EventEmitter.prototype._maxListeners = void 0;
18503
+ EventEmitter.defaultMaxListeners = 10;
18504
+ EventEmitter.init = function() {
18505
+ this.domain = null;
18506
+ if (EventEmitter.usingDomains) {
18507
+ if (domain.active && !(this instanceof domain.Domain)) this.domain = domain.active;
18508
+ }
18509
+ if (!this._events || this._events === Object.getPrototypeOf(this)._events) {
18510
+ this._events = new EventHandlers();
18511
+ this._eventsCount = 0;
18512
+ }
18513
+ this._maxListeners = this._maxListeners || void 0;
18514
+ };
18515
+ EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
18516
+ if (typeof n !== "number" || n < 0 || isNaN(n)) throw new TypeError("\"n\" argument must be a positive number");
18517
+ this._maxListeners = n;
18518
+ return this;
18519
+ };
18520
+ function $getMaxListeners(that) {
18521
+ if (that._maxListeners === void 0) return EventEmitter.defaultMaxListeners;
18522
+ return that._maxListeners;
18523
+ }
18524
+ EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
18525
+ return $getMaxListeners(this);
18526
+ };
18527
+ function emitNone(handler, isFn, self) {
18528
+ if (isFn) handler.call(self);
18529
+ else {
18530
+ var len = handler.length;
18531
+ var listeners = arrayClone(handler, len);
18532
+ for (var i = 0; i < len; ++i) listeners[i].call(self);
18533
+ }
18534
+ }
18535
+ function emitOne(handler, isFn, self, arg1) {
18536
+ if (isFn) handler.call(self, arg1);
18537
+ else {
18538
+ var len = handler.length;
18539
+ var listeners = arrayClone(handler, len);
18540
+ for (var i = 0; i < len; ++i) listeners[i].call(self, arg1);
18541
+ }
18542
+ }
18543
+ function emitTwo(handler, isFn, self, arg1, arg2) {
18544
+ if (isFn) handler.call(self, arg1, arg2);
18545
+ else {
18546
+ var len = handler.length;
18547
+ var listeners = arrayClone(handler, len);
18548
+ for (var i = 0; i < len; ++i) listeners[i].call(self, arg1, arg2);
18549
+ }
18550
+ }
18551
+ function emitThree(handler, isFn, self, arg1, arg2, arg3) {
18552
+ if (isFn) handler.call(self, arg1, arg2, arg3);
18553
+ else {
18554
+ var len = handler.length;
18555
+ var listeners = arrayClone(handler, len);
18556
+ for (var i = 0; i < len; ++i) listeners[i].call(self, arg1, arg2, arg3);
18557
+ }
18558
+ }
18559
+ function emitMany(handler, isFn, self, args) {
18560
+ if (isFn) handler.apply(self, args);
18561
+ else {
18562
+ var len = handler.length;
18563
+ var listeners = arrayClone(handler, len);
18564
+ for (var i = 0; i < len; ++i) listeners[i].apply(self, args);
18565
+ }
18566
+ }
18567
+ EventEmitter.prototype.emit = function emit(type) {
18568
+ var er, handler, len, args, i, events, domain;
18569
+ var needDomainExit = false;
18570
+ var doError = type === "error";
18571
+ events = this._events;
18572
+ if (events) doError = doError && events.error == null;
18573
+ else if (!doError) return false;
18574
+ domain = this.domain;
18575
+ if (doError) {
18576
+ er = arguments[1];
18577
+ if (domain) {
18578
+ if (!er) er = /* @__PURE__ */ new Error("Uncaught, unspecified \"error\" event");
18579
+ er.domainEmitter = this;
18580
+ er.domain = domain;
18581
+ er.domainThrown = false;
18582
+ domain.emit("error", er);
18583
+ } else if (er instanceof Error) throw er;
18584
+ else {
18585
+ var err = /* @__PURE__ */ new Error("Uncaught, unspecified \"error\" event. (" + er + ")");
18586
+ err.context = er;
18587
+ throw err;
18588
+ }
18589
+ return false;
18590
+ }
18591
+ handler = events[type];
18592
+ if (!handler) return false;
18593
+ var isFn = typeof handler === "function";
18594
+ len = arguments.length;
18595
+ switch (len) {
18596
+ case 1:
18597
+ emitNone(handler, isFn, this);
18598
+ break;
18599
+ case 2:
18600
+ emitOne(handler, isFn, this, arguments[1]);
18601
+ break;
18602
+ case 3:
18603
+ emitTwo(handler, isFn, this, arguments[1], arguments[2]);
18604
+ break;
18605
+ case 4:
18606
+ emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
18607
+ break;
18608
+ default:
18609
+ args = new Array(len - 1);
18610
+ for (i = 1; i < len; i++) args[i - 1] = arguments[i];
18611
+ emitMany(handler, isFn, this, args);
18612
+ }
18613
+ if (needDomainExit) domain.exit();
18614
+ return true;
18615
+ };
18616
+ function _addListener(target, type, listener, prepend) {
18617
+ var m;
18618
+ var events;
18619
+ var existing;
18620
+ if (typeof listener !== "function") throw new TypeError("\"listener\" argument must be a function");
18621
+ events = target._events;
18622
+ if (!events) {
18623
+ events = target._events = new EventHandlers();
18624
+ target._eventsCount = 0;
18625
+ } else {
18626
+ if (events.newListener) {
18627
+ target.emit("newListener", type, listener.listener ? listener.listener : listener);
18628
+ events = target._events;
18629
+ }
18630
+ existing = events[type];
18631
+ }
18632
+ if (!existing) {
18633
+ existing = events[type] = listener;
18634
+ ++target._eventsCount;
18635
+ } else {
18636
+ if (typeof existing === "function") existing = events[type] = prepend ? [listener, existing] : [existing, listener];
18637
+ else if (prepend) existing.unshift(listener);
18638
+ else existing.push(listener);
18639
+ if (!existing.warned) {
18640
+ m = $getMaxListeners(target);
18641
+ if (m && m > 0 && existing.length > m) {
18642
+ existing.warned = true;
18643
+ var w = /* @__PURE__ */ new Error("Possible EventEmitter memory leak detected. " + existing.length + " " + type + " listeners added. Use emitter.setMaxListeners() to increase limit");
18644
+ w.name = "MaxListenersExceededWarning";
18645
+ w.emitter = target;
18646
+ w.type = type;
18647
+ w.count = existing.length;
18648
+ emitWarning(w);
18649
+ }
18650
+ }
18651
+ }
18652
+ return target;
18653
+ }
18654
+ function emitWarning(e) {
18655
+ typeof console.warn === "function" ? console.warn(e) : console.log(e);
18656
+ }
18657
+ EventEmitter.prototype.addListener = function addListener(type, listener) {
18658
+ return _addListener(this, type, listener, false);
18659
+ };
18660
+ EventEmitter.prototype.on = EventEmitter.prototype.addListener;
18661
+ EventEmitter.prototype.prependListener = function prependListener(type, listener) {
18662
+ return _addListener(this, type, listener, true);
18663
+ };
18664
+ function _onceWrap(target, type, listener) {
18665
+ var fired = false;
18666
+ function g() {
18667
+ target.removeListener(type, g);
18668
+ if (!fired) {
18669
+ fired = true;
18670
+ listener.apply(target, arguments);
18671
+ }
18672
+ }
18673
+ g.listener = listener;
18674
+ return g;
18675
+ }
18676
+ EventEmitter.prototype.once = function once(type, listener) {
18677
+ if (typeof listener !== "function") throw new TypeError("\"listener\" argument must be a function");
18678
+ this.on(type, _onceWrap(this, type, listener));
18679
+ return this;
18680
+ };
18681
+ EventEmitter.prototype.prependOnceListener = function prependOnceListener(type, listener) {
18682
+ if (typeof listener !== "function") throw new TypeError("\"listener\" argument must be a function");
18683
+ this.prependListener(type, _onceWrap(this, type, listener));
18684
+ return this;
18685
+ };
18686
+ EventEmitter.prototype.removeListener = function removeListener(type, listener) {
18687
+ var list, events, position, i, originalListener;
18688
+ if (typeof listener !== "function") throw new TypeError("\"listener\" argument must be a function");
18689
+ events = this._events;
18690
+ if (!events) return this;
18691
+ list = events[type];
18692
+ if (!list) return this;
18693
+ if (list === listener || list.listener && list.listener === listener) if (--this._eventsCount === 0) this._events = new EventHandlers();
18694
+ else {
18695
+ delete events[type];
18696
+ if (events.removeListener) this.emit("removeListener", type, list.listener || listener);
18697
+ }
18698
+ else if (typeof list !== "function") {
18699
+ position = -1;
18700
+ for (i = list.length; i-- > 0;) if (list[i] === listener || list[i].listener && list[i].listener === listener) {
18701
+ originalListener = list[i].listener;
18702
+ position = i;
18703
+ break;
18704
+ }
18705
+ if (position < 0) return this;
18706
+ if (list.length === 1) {
18707
+ list[0] = void 0;
18708
+ if (--this._eventsCount === 0) {
18709
+ this._events = new EventHandlers();
18710
+ return this;
18711
+ } else delete events[type];
18712
+ } else spliceOne(list, position);
18713
+ if (events.removeListener) this.emit("removeListener", type, originalListener || listener);
18714
+ }
18715
+ return this;
18716
+ };
18717
+ EventEmitter.prototype.off = function(type, listener) {
18718
+ return this.removeListener(type, listener);
18719
+ };
18720
+ EventEmitter.prototype.removeAllListeners = function removeAllListeners(type) {
18721
+ var listeners, events = this._events;
18722
+ if (!events) return this;
18723
+ if (!events.removeListener) {
18724
+ if (arguments.length === 0) {
18725
+ this._events = new EventHandlers();
18726
+ this._eventsCount = 0;
18727
+ } else if (events[type]) if (--this._eventsCount === 0) this._events = new EventHandlers();
18728
+ else delete events[type];
18729
+ return this;
18730
+ }
18731
+ if (arguments.length === 0) {
18732
+ var keys = Object.keys(events);
18733
+ for (var i = 0, key; i < keys.length; ++i) {
18734
+ key = keys[i];
18735
+ if (key === "removeListener") continue;
18736
+ this.removeAllListeners(key);
18737
+ }
18738
+ this.removeAllListeners("removeListener");
18739
+ this._events = new EventHandlers();
18740
+ this._eventsCount = 0;
18741
+ return this;
18742
+ }
18743
+ listeners = events[type];
18744
+ if (typeof listeners === "function") this.removeListener(type, listeners);
18745
+ else if (listeners) do
18746
+ this.removeListener(type, listeners[listeners.length - 1]);
18747
+ while (listeners[0]);
18748
+ return this;
18749
+ };
18750
+ EventEmitter.prototype.listeners = function listeners(type) {
18751
+ var evlistener;
18752
+ var ret;
18753
+ var events = this._events;
18754
+ if (!events) ret = [];
18755
+ else {
18756
+ evlistener = events[type];
18757
+ if (!evlistener) ret = [];
18758
+ else if (typeof evlistener === "function") ret = [evlistener.listener || evlistener];
18759
+ else ret = unwrapListeners(evlistener);
18760
+ }
18761
+ return ret;
18762
+ };
18763
+ EventEmitter.listenerCount = function(emitter, type) {
18764
+ if (typeof emitter.listenerCount === "function") return emitter.listenerCount(type);
18765
+ else return listenerCount$1.call(emitter, type);
18766
+ };
18767
+ EventEmitter.prototype.listenerCount = listenerCount$1;
18768
+ function listenerCount$1(type) {
18769
+ var events = this._events;
18770
+ if (events) {
18771
+ var evlistener = events[type];
18772
+ if (typeof evlistener === "function") return 1;
18773
+ else if (evlistener) return evlistener.length;
18774
+ }
18775
+ return 0;
18776
+ }
18777
+ EventEmitter.prototype.eventNames = function eventNames() {
18778
+ return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
18779
+ };
18780
+ function spliceOne(list, index) {
18781
+ for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) list[i] = list[k];
18782
+ list.pop();
18783
+ }
18784
+ function arrayClone(arr, i) {
18785
+ var copy = new Array(i);
18786
+ while (i--) copy[i] = arr[i];
18787
+ return copy;
18788
+ }
18789
+ function unwrapListeners(arr) {
18790
+ var ret = new Array(arr.length);
18791
+ for (var i = 0; i < ret.length; ++i) ret[i] = arr[i].listener || arr[i];
18792
+ return ret;
18793
+ }
18794
+ //#endregion
18795
+ //#region \0polyfill-node.global.js
18796
+ var _polyfill_node_global_default = typeof _polyfill_node_global_default !== "undefined" ? _polyfill_node_global_default : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
18797
+ //#endregion
18798
+ //#region \0polyfill-node.buffer.js
18799
+ var lookup = [];
18800
+ var revLookup = [];
18801
+ var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
18802
+ var inited = false;
18803
+ function init() {
18804
+ inited = true;
18805
+ var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
18806
+ for (var i = 0, len = code.length; i < len; ++i) {
18807
+ lookup[i] = code[i];
18808
+ revLookup[code.charCodeAt(i)] = i;
18809
+ }
18810
+ revLookup["-".charCodeAt(0)] = 62;
18811
+ revLookup["_".charCodeAt(0)] = 63;
18812
+ }
18813
+ function toByteArray(b64) {
18814
+ if (!inited) init();
18815
+ var i, j, l, tmp, placeHolders, arr;
18816
+ var len = b64.length;
18817
+ if (len % 4 > 0) throw new Error("Invalid string. Length must be a multiple of 4");
18818
+ placeHolders = b64[len - 2] === "=" ? 2 : b64[len - 1] === "=" ? 1 : 0;
18819
+ arr = new Arr(len * 3 / 4 - placeHolders);
18820
+ l = placeHolders > 0 ? len - 4 : len;
18821
+ var L = 0;
18822
+ for (i = 0, j = 0; i < l; i += 4, j += 3) {
18823
+ tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)];
18824
+ arr[L++] = tmp >> 16 & 255;
18825
+ arr[L++] = tmp >> 8 & 255;
18826
+ arr[L++] = tmp & 255;
18827
+ }
18828
+ if (placeHolders === 2) {
18829
+ tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4;
18830
+ arr[L++] = tmp & 255;
18831
+ } else if (placeHolders === 1) {
18832
+ tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2;
18833
+ arr[L++] = tmp >> 8 & 255;
18834
+ arr[L++] = tmp & 255;
18835
+ }
18836
+ return arr;
18837
+ }
18838
+ function tripletToBase64(num) {
18839
+ return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
18840
+ }
18841
+ function encodeChunk(uint8, start, end) {
18842
+ var tmp;
18843
+ var output = [];
18844
+ for (var i = start; i < end; i += 3) {
18845
+ tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + uint8[i + 2];
18846
+ output.push(tripletToBase64(tmp));
18847
+ }
18848
+ return output.join("");
18849
+ }
18850
+ function fromByteArray(uint8) {
18851
+ if (!inited) init();
18852
+ var tmp;
18853
+ var len = uint8.length;
18854
+ var extraBytes = len % 3;
18855
+ var output = "";
18856
+ var parts = [];
18857
+ var maxChunkLength = 16383;
18858
+ for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength));
18859
+ if (extraBytes === 1) {
18860
+ tmp = uint8[len - 1];
18861
+ output += lookup[tmp >> 2];
18862
+ output += lookup[tmp << 4 & 63];
18863
+ output += "==";
18864
+ } else if (extraBytes === 2) {
18865
+ tmp = (uint8[len - 2] << 8) + uint8[len - 1];
18866
+ output += lookup[tmp >> 10];
18867
+ output += lookup[tmp >> 4 & 63];
18868
+ output += lookup[tmp << 2 & 63];
18869
+ output += "=";
18870
+ }
18871
+ parts.push(output);
18872
+ return parts.join("");
18873
+ }
18874
+ function read(buffer, offset, isLE, mLen, nBytes) {
18875
+ var e, m;
18876
+ var eLen = nBytes * 8 - mLen - 1;
18877
+ var eMax = (1 << eLen) - 1;
18878
+ var eBias = eMax >> 1;
18879
+ var nBits = -7;
18880
+ var i = isLE ? nBytes - 1 : 0;
18881
+ var d = isLE ? -1 : 1;
18882
+ var s = buffer[offset + i];
18883
+ i += d;
18884
+ e = s & (1 << -nBits) - 1;
18885
+ s >>= -nBits;
18886
+ nBits += eLen;
18887
+ for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8);
18888
+ m = e & (1 << -nBits) - 1;
18889
+ e >>= -nBits;
18890
+ nBits += mLen;
18891
+ for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8);
18892
+ if (e === 0) e = 1 - eBias;
18893
+ else if (e === eMax) return m ? NaN : (s ? -1 : 1) * Infinity;
18894
+ else {
18895
+ m = m + Math.pow(2, mLen);
18896
+ e = e - eBias;
18897
+ }
18898
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
18899
+ }
18900
+ function write(buffer, value, offset, isLE, mLen, nBytes) {
18901
+ var e, m, c;
18902
+ var eLen = nBytes * 8 - mLen - 1;
18903
+ var eMax = (1 << eLen) - 1;
18904
+ var eBias = eMax >> 1;
18905
+ var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
18906
+ var i = isLE ? 0 : nBytes - 1;
18907
+ var d = isLE ? 1 : -1;
18908
+ var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
18909
+ value = Math.abs(value);
18910
+ if (isNaN(value) || value === Infinity) {
18911
+ m = isNaN(value) ? 1 : 0;
18912
+ e = eMax;
18913
+ } else {
18914
+ e = Math.floor(Math.log(value) / Math.LN2);
18915
+ if (value * (c = Math.pow(2, -e)) < 1) {
18916
+ e--;
18917
+ c *= 2;
18918
+ }
18919
+ if (e + eBias >= 1) value += rt / c;
18920
+ else value += rt * Math.pow(2, 1 - eBias);
18921
+ if (value * c >= 2) {
18922
+ e++;
18923
+ c /= 2;
18924
+ }
18925
+ if (e + eBias >= eMax) {
18926
+ m = 0;
18927
+ e = eMax;
18928
+ } else if (e + eBias >= 1) {
18929
+ m = (value * c - 1) * Math.pow(2, mLen);
18930
+ e = e + eBias;
18931
+ } else {
18932
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
18933
+ e = 0;
18934
+ }
18935
+ }
18936
+ for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8);
18937
+ e = e << mLen | m;
18938
+ eLen += mLen;
18939
+ for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8);
18940
+ buffer[offset + i - d] |= s * 128;
18941
+ }
18942
+ var toString = {}.toString;
18943
+ var isArray$1 = Array.isArray || function(arr) {
18944
+ return toString.call(arr) == "[object Array]";
18945
+ };
18294
18946
  /**
18295
- * Output type definitions for document generation.
18947
+ * If `Buffer.TYPED_ARRAY_SUPPORT`:
18948
+ * === true Use Uint8Array implementation (fastest)
18949
+ * === false Use Object implementation (most compatible, even IE6)
18296
18950
  *
18297
- * This module defines the various output formats supported when generating
18298
- * .docx files. These types correspond to fflate's output formats.
18951
+ * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
18952
+ * Opera 11.6+, iOS 4.2+.
18299
18953
  *
18300
- * @module
18954
+ * Due to various browser bugs, sometimes the Object implementation will be used even
18955
+ * when the browser supports typed arrays.
18956
+ *
18957
+ * Note:
18958
+ *
18959
+ * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
18960
+ * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
18961
+ *
18962
+ * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
18963
+ *
18964
+ * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
18965
+ * incorrect length in some situations.
18966
+
18967
+ * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
18968
+ * get the Object implementation, which is slower but behaves correctly.
18301
18969
  */
18970
+ Buffer$1.TYPED_ARRAY_SUPPORT = _polyfill_node_global_default.TYPED_ARRAY_SUPPORT !== void 0 ? _polyfill_node_global_default.TYPED_ARRAY_SUPPORT : true;
18971
+ kMaxLength();
18972
+ function kMaxLength() {
18973
+ return Buffer$1.TYPED_ARRAY_SUPPORT ? 2147483647 : 1073741823;
18974
+ }
18975
+ function createBuffer(that, length) {
18976
+ if (kMaxLength() < length) throw new RangeError("Invalid typed array length");
18977
+ if (Buffer$1.TYPED_ARRAY_SUPPORT) {
18978
+ that = new Uint8Array(length);
18979
+ that.__proto__ = Buffer$1.prototype;
18980
+ } else {
18981
+ if (that === null) that = new Buffer$1(length);
18982
+ that.length = length;
18983
+ }
18984
+ return that;
18985
+ }
18302
18986
  /**
18303
- * Converts a Uint8Array to the specified output type.
18987
+ * The Buffer constructor returns instances of `Uint8Array` that have their
18988
+ * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
18989
+ * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
18990
+ * and the `Uint8Array` methods. Square bracket notation works as expected -- it
18991
+ * returns a single octet.
18304
18992
  *
18305
- * This is used by both the Packer and patchDocument to convert fflate's
18306
- * raw Uint8Array output into the user's requested format.
18993
+ * The `Uint8Array` prototype remains unmodified.
18307
18994
  */
18308
- const convertOutput = (data, type) => {
18309
- switch (type) {
18310
- case "nodebuffer": return Buffer.from(data);
18311
- case "blob": return new Blob([data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength)], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" });
18312
- case "arraybuffer": return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
18313
- case "uint8array": return data;
18314
- case "base64": return btoa((0, fflate.strFromU8)(data, true));
18315
- case "string":
18316
- case "text":
18317
- case "binarystring": return (0, fflate.strFromU8)(data, true);
18318
- case "array": return [...data];
18319
- default: return data;
18995
+ function Buffer$1(arg, encodingOrOffset, length) {
18996
+ if (!Buffer$1.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer$1)) return new Buffer$1(arg, encodingOrOffset, length);
18997
+ if (typeof arg === "number") {
18998
+ if (typeof encodingOrOffset === "string") throw new Error("If encoding is specified then the first argument must be a string");
18999
+ return allocUnsafe(this, arg);
18320
19000
  }
19001
+ return from(this, arg, encodingOrOffset, length);
19002
+ }
19003
+ Buffer$1.poolSize = 8192;
19004
+ Buffer$1._augment = function(arr) {
19005
+ arr.__proto__ = Buffer$1.prototype;
19006
+ return arr;
19007
+ };
19008
+ function from(that, value, encodingOrOffset, length) {
19009
+ if (typeof value === "number") throw new TypeError("\"value\" argument must not be a number");
19010
+ if (typeof ArrayBuffer !== "undefined" && value instanceof ArrayBuffer) return fromArrayBuffer(that, value, encodingOrOffset, length);
19011
+ if (typeof value === "string") return fromString(that, value, encodingOrOffset);
19012
+ return fromObject(that, value);
19013
+ }
19014
+ /**
19015
+ * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
19016
+ * if value is a number.
19017
+ * Buffer.from(str[, encoding])
19018
+ * Buffer.from(array)
19019
+ * Buffer.from(buffer)
19020
+ * Buffer.from(arrayBuffer[, byteOffset[, length]])
19021
+ **/
19022
+ Buffer$1.from = function(value, encodingOrOffset, length) {
19023
+ return from(null, value, encodingOrOffset, length);
19024
+ };
19025
+ if (Buffer$1.TYPED_ARRAY_SUPPORT) {
19026
+ Buffer$1.prototype.__proto__ = Uint8Array.prototype;
19027
+ Buffer$1.__proto__ = Uint8Array;
19028
+ if (typeof Symbol !== "undefined" && Symbol.species && Buffer$1[Symbol.species] === Buffer$1);
19029
+ }
19030
+ function assertSize(size) {
19031
+ if (typeof size !== "number") throw new TypeError("\"size\" argument must be a number");
19032
+ else if (size < 0) throw new RangeError("\"size\" argument must not be negative");
19033
+ }
19034
+ function alloc(that, size, fill, encoding) {
19035
+ assertSize(size);
19036
+ if (size <= 0) return createBuffer(that, size);
19037
+ if (fill !== void 0) return typeof encoding === "string" ? createBuffer(that, size).fill(fill, encoding) : createBuffer(that, size).fill(fill);
19038
+ return createBuffer(that, size);
19039
+ }
19040
+ /**
19041
+ * Creates a new filled Buffer instance.
19042
+ * alloc(size[, fill[, encoding]])
19043
+ **/
19044
+ Buffer$1.alloc = function(size, fill, encoding) {
19045
+ return alloc(null, size, fill, encoding);
19046
+ };
19047
+ function allocUnsafe(that, size) {
19048
+ assertSize(size);
19049
+ that = createBuffer(that, size < 0 ? 0 : checked(size) | 0);
19050
+ if (!Buffer$1.TYPED_ARRAY_SUPPORT) for (var i = 0; i < size; ++i) that[i] = 0;
19051
+ return that;
19052
+ }
19053
+ /**
19054
+ * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
19055
+ * */
19056
+ Buffer$1.allocUnsafe = function(size) {
19057
+ return allocUnsafe(null, size);
18321
19058
  };
18322
- //#endregion
18323
- //#region src/file/fonts/obfuscate-ttf-to-odttf.ts
18324
19059
  /**
18325
- * Font obfuscation module for embedding fonts in WordprocessingML documents.
18326
- *
18327
- * This module implements the OOXML font obfuscation algorithm used to embed
18328
- * fonts in DOCX documents. Obfuscation is required by the OOXML specification
18329
- * to prevent simple extraction of embedded font files.
18330
- *
18331
- * Reference: ECMA-376 Part 2, Section 11.1 (Font Embedding)
18332
- *
18333
- * @module
19060
+ * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
18334
19061
  */
18335
- /** Start offset for obfuscation in the font file */
19062
+ Buffer$1.allocUnsafeSlow = function(size) {
19063
+ return allocUnsafe(null, size);
19064
+ };
19065
+ function fromString(that, string, encoding) {
19066
+ if (typeof encoding !== "string" || encoding === "") encoding = "utf8";
19067
+ if (!Buffer$1.isEncoding(encoding)) throw new TypeError("\"encoding\" must be a valid string encoding");
19068
+ var length = byteLength(string, encoding) | 0;
19069
+ that = createBuffer(that, length);
19070
+ var actual = that.write(string, encoding);
19071
+ if (actual !== length) that = that.slice(0, actual);
19072
+ return that;
19073
+ }
19074
+ function fromArrayLike(that, array) {
19075
+ var length = array.length < 0 ? 0 : checked(array.length) | 0;
19076
+ that = createBuffer(that, length);
19077
+ for (var i = 0; i < length; i += 1) that[i] = array[i] & 255;
19078
+ return that;
19079
+ }
19080
+ function fromArrayBuffer(that, array, byteOffset, length) {
19081
+ array.byteLength;
19082
+ if (byteOffset < 0 || array.byteLength < byteOffset) throw new RangeError("'offset' is out of bounds");
19083
+ if (array.byteLength < byteOffset + (length || 0)) throw new RangeError("'length' is out of bounds");
19084
+ if (byteOffset === void 0 && length === void 0) array = new Uint8Array(array);
19085
+ else if (length === void 0) array = new Uint8Array(array, byteOffset);
19086
+ else array = new Uint8Array(array, byteOffset, length);
19087
+ if (Buffer$1.TYPED_ARRAY_SUPPORT) {
19088
+ that = array;
19089
+ that.__proto__ = Buffer$1.prototype;
19090
+ } else that = fromArrayLike(that, array);
19091
+ return that;
19092
+ }
19093
+ function fromObject(that, obj) {
19094
+ if (internalIsBuffer(obj)) {
19095
+ var len = checked(obj.length) | 0;
19096
+ that = createBuffer(that, len);
19097
+ if (that.length === 0) return that;
19098
+ obj.copy(that, 0, 0, len);
19099
+ return that;
19100
+ }
19101
+ if (obj) {
19102
+ if (typeof ArrayBuffer !== "undefined" && obj.buffer instanceof ArrayBuffer || "length" in obj) {
19103
+ if (typeof obj.length !== "number" || isnan(obj.length)) return createBuffer(that, 0);
19104
+ return fromArrayLike(that, obj);
19105
+ }
19106
+ if (obj.type === "Buffer" && isArray$1(obj.data)) return fromArrayLike(that, obj.data);
19107
+ }
19108
+ throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.");
19109
+ }
19110
+ function checked(length) {
19111
+ if (length >= kMaxLength()) throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + kMaxLength().toString(16) + " bytes");
19112
+ return length | 0;
19113
+ }
19114
+ Buffer$1.isBuffer = isBuffer;
19115
+ function internalIsBuffer(b) {
19116
+ return !!(b != null && b._isBuffer);
19117
+ }
19118
+ Buffer$1.compare = function compare(a, b) {
19119
+ if (!internalIsBuffer(a) || !internalIsBuffer(b)) throw new TypeError("Arguments must be Buffers");
19120
+ if (a === b) return 0;
19121
+ var x = a.length;
19122
+ var y = b.length;
19123
+ for (var i = 0, len = Math.min(x, y); i < len; ++i) if (a[i] !== b[i]) {
19124
+ x = a[i];
19125
+ y = b[i];
19126
+ break;
19127
+ }
19128
+ if (x < y) return -1;
19129
+ if (y < x) return 1;
19130
+ return 0;
19131
+ };
19132
+ Buffer$1.isEncoding = function isEncoding(encoding) {
19133
+ switch (String(encoding).toLowerCase()) {
19134
+ case "hex":
19135
+ case "utf8":
19136
+ case "utf-8":
19137
+ case "ascii":
19138
+ case "latin1":
19139
+ case "binary":
19140
+ case "base64":
19141
+ case "ucs2":
19142
+ case "ucs-2":
19143
+ case "utf16le":
19144
+ case "utf-16le": return true;
19145
+ default: return false;
19146
+ }
19147
+ };
19148
+ Buffer$1.concat = function concat(list, length) {
19149
+ if (!isArray$1(list)) throw new TypeError("\"list\" argument must be an Array of Buffers");
19150
+ if (list.length === 0) return Buffer$1.alloc(0);
19151
+ var i;
19152
+ if (length === void 0) {
19153
+ length = 0;
19154
+ for (i = 0; i < list.length; ++i) length += list[i].length;
19155
+ }
19156
+ var buffer = Buffer$1.allocUnsafe(length);
19157
+ var pos = 0;
19158
+ for (i = 0; i < list.length; ++i) {
19159
+ var buf = list[i];
19160
+ if (!internalIsBuffer(buf)) throw new TypeError("\"list\" argument must be an Array of Buffers");
19161
+ buf.copy(buffer, pos);
19162
+ pos += buf.length;
19163
+ }
19164
+ return buffer;
19165
+ };
19166
+ function byteLength(string, encoding) {
19167
+ if (internalIsBuffer(string)) return string.length;
19168
+ if (typeof ArrayBuffer !== "undefined" && typeof ArrayBuffer.isView === "function" && (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) return string.byteLength;
19169
+ if (typeof string !== "string") string = "" + string;
19170
+ var len = string.length;
19171
+ if (len === 0) return 0;
19172
+ var loweredCase = false;
19173
+ for (;;) switch (encoding) {
19174
+ case "ascii":
19175
+ case "latin1":
19176
+ case "binary": return len;
19177
+ case "utf8":
19178
+ case "utf-8":
19179
+ case void 0: return utf8ToBytes(string).length;
19180
+ case "ucs2":
19181
+ case "ucs-2":
19182
+ case "utf16le":
19183
+ case "utf-16le": return len * 2;
19184
+ case "hex": return len >>> 1;
19185
+ case "base64": return base64ToBytes(string).length;
19186
+ default:
19187
+ if (loweredCase) return utf8ToBytes(string).length;
19188
+ encoding = ("" + encoding).toLowerCase();
19189
+ loweredCase = true;
19190
+ }
19191
+ }
19192
+ Buffer$1.byteLength = byteLength;
19193
+ function slowToString(encoding, start, end) {
19194
+ var loweredCase = false;
19195
+ if (start === void 0 || start < 0) start = 0;
19196
+ if (start > this.length) return "";
19197
+ if (end === void 0 || end > this.length) end = this.length;
19198
+ if (end <= 0) return "";
19199
+ end >>>= 0;
19200
+ start >>>= 0;
19201
+ if (end <= start) return "";
19202
+ if (!encoding) encoding = "utf8";
19203
+ while (true) switch (encoding) {
19204
+ case "hex": return hexSlice(this, start, end);
19205
+ case "utf8":
19206
+ case "utf-8": return utf8Slice(this, start, end);
19207
+ case "ascii": return asciiSlice(this, start, end);
19208
+ case "latin1":
19209
+ case "binary": return latin1Slice(this, start, end);
19210
+ case "base64": return base64Slice(this, start, end);
19211
+ case "ucs2":
19212
+ case "ucs-2":
19213
+ case "utf16le":
19214
+ case "utf-16le": return utf16leSlice(this, start, end);
19215
+ default:
19216
+ if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
19217
+ encoding = (encoding + "").toLowerCase();
19218
+ loweredCase = true;
19219
+ }
19220
+ }
19221
+ Buffer$1.prototype._isBuffer = true;
19222
+ function swap(b, n, m) {
19223
+ var i = b[n];
19224
+ b[n] = b[m];
19225
+ b[m] = i;
19226
+ }
19227
+ Buffer$1.prototype.swap16 = function swap16() {
19228
+ var len = this.length;
19229
+ if (len % 2 !== 0) throw new RangeError("Buffer size must be a multiple of 16-bits");
19230
+ for (var i = 0; i < len; i += 2) swap(this, i, i + 1);
19231
+ return this;
19232
+ };
19233
+ Buffer$1.prototype.swap32 = function swap32() {
19234
+ var len = this.length;
19235
+ if (len % 4 !== 0) throw new RangeError("Buffer size must be a multiple of 32-bits");
19236
+ for (var i = 0; i < len; i += 4) {
19237
+ swap(this, i, i + 3);
19238
+ swap(this, i + 1, i + 2);
19239
+ }
19240
+ return this;
19241
+ };
19242
+ Buffer$1.prototype.swap64 = function swap64() {
19243
+ var len = this.length;
19244
+ if (len % 8 !== 0) throw new RangeError("Buffer size must be a multiple of 64-bits");
19245
+ for (var i = 0; i < len; i += 8) {
19246
+ swap(this, i, i + 7);
19247
+ swap(this, i + 1, i + 6);
19248
+ swap(this, i + 2, i + 5);
19249
+ swap(this, i + 3, i + 4);
19250
+ }
19251
+ return this;
19252
+ };
19253
+ Buffer$1.prototype.toString = function toString() {
19254
+ var length = this.length | 0;
19255
+ if (length === 0) return "";
19256
+ if (arguments.length === 0) return utf8Slice(this, 0, length);
19257
+ return slowToString.apply(this, arguments);
19258
+ };
19259
+ Buffer$1.prototype.equals = function equals(b) {
19260
+ if (!internalIsBuffer(b)) throw new TypeError("Argument must be a Buffer");
19261
+ if (this === b) return true;
19262
+ return Buffer$1.compare(this, b) === 0;
19263
+ };
19264
+ Buffer$1.prototype.inspect = function inspect() {
19265
+ var str = "";
19266
+ var max = 50;
19267
+ if (this.length > 0) {
19268
+ str = this.toString("hex", 0, max).match(/.{2}/g).join(" ");
19269
+ if (this.length > max) str += " ... ";
19270
+ }
19271
+ return "<Buffer " + str + ">";
19272
+ };
19273
+ Buffer$1.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
19274
+ if (!internalIsBuffer(target)) throw new TypeError("Argument must be a Buffer");
19275
+ if (start === void 0) start = 0;
19276
+ if (end === void 0) end = target ? target.length : 0;
19277
+ if (thisStart === void 0) thisStart = 0;
19278
+ if (thisEnd === void 0) thisEnd = this.length;
19279
+ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) throw new RangeError("out of range index");
19280
+ if (thisStart >= thisEnd && start >= end) return 0;
19281
+ if (thisStart >= thisEnd) return -1;
19282
+ if (start >= end) return 1;
19283
+ start >>>= 0;
19284
+ end >>>= 0;
19285
+ thisStart >>>= 0;
19286
+ thisEnd >>>= 0;
19287
+ if (this === target) return 0;
19288
+ var x = thisEnd - thisStart;
19289
+ var y = end - start;
19290
+ var len = Math.min(x, y);
19291
+ var thisCopy = this.slice(thisStart, thisEnd);
19292
+ var targetCopy = target.slice(start, end);
19293
+ for (var i = 0; i < len; ++i) if (thisCopy[i] !== targetCopy[i]) {
19294
+ x = thisCopy[i];
19295
+ y = targetCopy[i];
19296
+ break;
19297
+ }
19298
+ if (x < y) return -1;
19299
+ if (y < x) return 1;
19300
+ return 0;
19301
+ };
19302
+ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
19303
+ if (buffer.length === 0) return -1;
19304
+ if (typeof byteOffset === "string") {
19305
+ encoding = byteOffset;
19306
+ byteOffset = 0;
19307
+ } else if (byteOffset > 2147483647) byteOffset = 2147483647;
19308
+ else if (byteOffset < -2147483648) byteOffset = -2147483648;
19309
+ byteOffset = +byteOffset;
19310
+ if (isNaN(byteOffset)) byteOffset = dir ? 0 : buffer.length - 1;
19311
+ if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
19312
+ if (byteOffset >= buffer.length) if (dir) return -1;
19313
+ else byteOffset = buffer.length - 1;
19314
+ else if (byteOffset < 0) if (dir) byteOffset = 0;
19315
+ else return -1;
19316
+ if (typeof val === "string") val = Buffer$1.from(val, encoding);
19317
+ if (internalIsBuffer(val)) {
19318
+ if (val.length === 0) return -1;
19319
+ return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
19320
+ } else if (typeof val === "number") {
19321
+ val = val & 255;
19322
+ if (Buffer$1.TYPED_ARRAY_SUPPORT && typeof Uint8Array.prototype.indexOf === "function") if (dir) return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
19323
+ else return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
19324
+ return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
19325
+ }
19326
+ throw new TypeError("val must be string, number or Buffer");
19327
+ }
19328
+ function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
19329
+ var indexSize = 1;
19330
+ var arrLength = arr.length;
19331
+ var valLength = val.length;
19332
+ if (encoding !== void 0) {
19333
+ encoding = String(encoding).toLowerCase();
19334
+ if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
19335
+ if (arr.length < 2 || val.length < 2) return -1;
19336
+ indexSize = 2;
19337
+ arrLength /= 2;
19338
+ valLength /= 2;
19339
+ byteOffset /= 2;
19340
+ }
19341
+ }
19342
+ function read(buf, i) {
19343
+ if (indexSize === 1) return buf[i];
19344
+ else return buf.readUInt16BE(i * indexSize);
19345
+ }
19346
+ var i;
19347
+ if (dir) {
19348
+ var foundIndex = -1;
19349
+ for (i = byteOffset; i < arrLength; i++) if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
19350
+ if (foundIndex === -1) foundIndex = i;
19351
+ if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;
19352
+ } else {
19353
+ if (foundIndex !== -1) i -= i - foundIndex;
19354
+ foundIndex = -1;
19355
+ }
19356
+ } else {
19357
+ if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
19358
+ for (i = byteOffset; i >= 0; i--) {
19359
+ var found = true;
19360
+ for (var j = 0; j < valLength; j++) if (read(arr, i + j) !== read(val, j)) {
19361
+ found = false;
19362
+ break;
19363
+ }
19364
+ if (found) return i;
19365
+ }
19366
+ }
19367
+ return -1;
19368
+ }
19369
+ Buffer$1.prototype.includes = function includes(val, byteOffset, encoding) {
19370
+ return this.indexOf(val, byteOffset, encoding) !== -1;
19371
+ };
19372
+ Buffer$1.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
19373
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
19374
+ };
19375
+ Buffer$1.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
19376
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
19377
+ };
19378
+ function hexWrite(buf, string, offset, length) {
19379
+ offset = Number(offset) || 0;
19380
+ var remaining = buf.length - offset;
19381
+ if (!length) length = remaining;
19382
+ else {
19383
+ length = Number(length);
19384
+ if (length > remaining) length = remaining;
19385
+ }
19386
+ var strLen = string.length;
19387
+ if (strLen % 2 !== 0) throw new TypeError("Invalid hex string");
19388
+ if (length > strLen / 2) length = strLen / 2;
19389
+ for (var i = 0; i < length; ++i) {
19390
+ var parsed = parseInt(string.substr(i * 2, 2), 16);
19391
+ if (isNaN(parsed)) return i;
19392
+ buf[offset + i] = parsed;
19393
+ }
19394
+ return i;
19395
+ }
19396
+ function utf8Write(buf, string, offset, length) {
19397
+ return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
19398
+ }
19399
+ function asciiWrite(buf, string, offset, length) {
19400
+ return blitBuffer(asciiToBytes(string), buf, offset, length);
19401
+ }
19402
+ function latin1Write(buf, string, offset, length) {
19403
+ return asciiWrite(buf, string, offset, length);
19404
+ }
19405
+ function base64Write(buf, string, offset, length) {
19406
+ return blitBuffer(base64ToBytes(string), buf, offset, length);
19407
+ }
19408
+ function ucs2Write(buf, string, offset, length) {
19409
+ return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
19410
+ }
19411
+ Buffer$1.prototype.write = function write(string, offset, length, encoding) {
19412
+ if (offset === void 0) {
19413
+ encoding = "utf8";
19414
+ length = this.length;
19415
+ offset = 0;
19416
+ } else if (length === void 0 && typeof offset === "string") {
19417
+ encoding = offset;
19418
+ length = this.length;
19419
+ offset = 0;
19420
+ } else if (isFinite(offset)) {
19421
+ offset = offset | 0;
19422
+ if (isFinite(length)) {
19423
+ length = length | 0;
19424
+ if (encoding === void 0) encoding = "utf8";
19425
+ } else {
19426
+ encoding = length;
19427
+ length = void 0;
19428
+ }
19429
+ } else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");
19430
+ var remaining = this.length - offset;
19431
+ if (length === void 0 || length > remaining) length = remaining;
19432
+ if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) throw new RangeError("Attempt to write outside buffer bounds");
19433
+ if (!encoding) encoding = "utf8";
19434
+ var loweredCase = false;
19435
+ for (;;) switch (encoding) {
19436
+ case "hex": return hexWrite(this, string, offset, length);
19437
+ case "utf8":
19438
+ case "utf-8": return utf8Write(this, string, offset, length);
19439
+ case "ascii": return asciiWrite(this, string, offset, length);
19440
+ case "latin1":
19441
+ case "binary": return latin1Write(this, string, offset, length);
19442
+ case "base64": return base64Write(this, string, offset, length);
19443
+ case "ucs2":
19444
+ case "ucs-2":
19445
+ case "utf16le":
19446
+ case "utf-16le": return ucs2Write(this, string, offset, length);
19447
+ default:
19448
+ if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
19449
+ encoding = ("" + encoding).toLowerCase();
19450
+ loweredCase = true;
19451
+ }
19452
+ };
19453
+ Buffer$1.prototype.toJSON = function toJSON() {
19454
+ return {
19455
+ type: "Buffer",
19456
+ data: Array.prototype.slice.call(this._arr || this, 0)
19457
+ };
19458
+ };
19459
+ function base64Slice(buf, start, end) {
19460
+ if (start === 0 && end === buf.length) return fromByteArray(buf);
19461
+ else return fromByteArray(buf.slice(start, end));
19462
+ }
19463
+ function utf8Slice(buf, start, end) {
19464
+ end = Math.min(buf.length, end);
19465
+ var res = [];
19466
+ var i = start;
19467
+ while (i < end) {
19468
+ var firstByte = buf[i];
19469
+ var codePoint = null;
19470
+ var bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
19471
+ if (i + bytesPerSequence <= end) {
19472
+ var secondByte, thirdByte, fourthByte, tempCodePoint;
19473
+ switch (bytesPerSequence) {
19474
+ case 1:
19475
+ if (firstByte < 128) codePoint = firstByte;
19476
+ break;
19477
+ case 2:
19478
+ secondByte = buf[i + 1];
19479
+ if ((secondByte & 192) === 128) {
19480
+ tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
19481
+ if (tempCodePoint > 127) codePoint = tempCodePoint;
19482
+ }
19483
+ break;
19484
+ case 3:
19485
+ secondByte = buf[i + 1];
19486
+ thirdByte = buf[i + 2];
19487
+ if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
19488
+ tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
19489
+ if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) codePoint = tempCodePoint;
19490
+ }
19491
+ break;
19492
+ case 4:
19493
+ secondByte = buf[i + 1];
19494
+ thirdByte = buf[i + 2];
19495
+ fourthByte = buf[i + 3];
19496
+ if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
19497
+ tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
19498
+ if (tempCodePoint > 65535 && tempCodePoint < 1114112) codePoint = tempCodePoint;
19499
+ }
19500
+ }
19501
+ }
19502
+ if (codePoint === null) {
19503
+ codePoint = 65533;
19504
+ bytesPerSequence = 1;
19505
+ } else if (codePoint > 65535) {
19506
+ codePoint -= 65536;
19507
+ res.push(codePoint >>> 10 & 1023 | 55296);
19508
+ codePoint = 56320 | codePoint & 1023;
19509
+ }
19510
+ res.push(codePoint);
19511
+ i += bytesPerSequence;
19512
+ }
19513
+ return decodeCodePointsArray(res);
19514
+ }
19515
+ var MAX_ARGUMENTS_LENGTH = 4096;
19516
+ function decodeCodePointsArray(codePoints) {
19517
+ var len = codePoints.length;
19518
+ if (len <= MAX_ARGUMENTS_LENGTH) return String.fromCharCode.apply(String, codePoints);
19519
+ var res = "";
19520
+ var i = 0;
19521
+ while (i < len) res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH));
19522
+ return res;
19523
+ }
19524
+ function asciiSlice(buf, start, end) {
19525
+ var ret = "";
19526
+ end = Math.min(buf.length, end);
19527
+ for (var i = start; i < end; ++i) ret += String.fromCharCode(buf[i] & 127);
19528
+ return ret;
19529
+ }
19530
+ function latin1Slice(buf, start, end) {
19531
+ var ret = "";
19532
+ end = Math.min(buf.length, end);
19533
+ for (var i = start; i < end; ++i) ret += String.fromCharCode(buf[i]);
19534
+ return ret;
19535
+ }
19536
+ function hexSlice(buf, start, end) {
19537
+ var len = buf.length;
19538
+ if (!start || start < 0) start = 0;
19539
+ if (!end || end < 0 || end > len) end = len;
19540
+ var out = "";
19541
+ for (var i = start; i < end; ++i) out += toHex(buf[i]);
19542
+ return out;
19543
+ }
19544
+ function utf16leSlice(buf, start, end) {
19545
+ var bytes = buf.slice(start, end);
19546
+ var res = "";
19547
+ for (var i = 0; i < bytes.length; i += 2) res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
19548
+ return res;
19549
+ }
19550
+ Buffer$1.prototype.slice = function slice(start, end) {
19551
+ var len = this.length;
19552
+ start = ~~start;
19553
+ end = end === void 0 ? len : ~~end;
19554
+ if (start < 0) {
19555
+ start += len;
19556
+ if (start < 0) start = 0;
19557
+ } else if (start > len) start = len;
19558
+ if (end < 0) {
19559
+ end += len;
19560
+ if (end < 0) end = 0;
19561
+ } else if (end > len) end = len;
19562
+ if (end < start) end = start;
19563
+ var newBuf;
19564
+ if (Buffer$1.TYPED_ARRAY_SUPPORT) {
19565
+ newBuf = this.subarray(start, end);
19566
+ newBuf.__proto__ = Buffer$1.prototype;
19567
+ } else {
19568
+ var sliceLen = end - start;
19569
+ newBuf = new Buffer$1(sliceLen, void 0);
19570
+ for (var i = 0; i < sliceLen; ++i) newBuf[i] = this[i + start];
19571
+ }
19572
+ return newBuf;
19573
+ };
19574
+ function checkOffset(offset, ext, length) {
19575
+ if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint");
19576
+ if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length");
19577
+ }
19578
+ Buffer$1.prototype.readUIntLE = function readUIntLE(offset, byteLength, noAssert) {
19579
+ offset = offset | 0;
19580
+ byteLength = byteLength | 0;
19581
+ if (!noAssert) checkOffset(offset, byteLength, this.length);
19582
+ var val = this[offset];
19583
+ var mul = 1;
19584
+ var i = 0;
19585
+ while (++i < byteLength && (mul *= 256)) val += this[offset + i] * mul;
19586
+ return val;
19587
+ };
19588
+ Buffer$1.prototype.readUIntBE = function readUIntBE(offset, byteLength, noAssert) {
19589
+ offset = offset | 0;
19590
+ byteLength = byteLength | 0;
19591
+ if (!noAssert) checkOffset(offset, byteLength, this.length);
19592
+ var val = this[offset + --byteLength];
19593
+ var mul = 1;
19594
+ while (byteLength > 0 && (mul *= 256)) val += this[offset + --byteLength] * mul;
19595
+ return val;
19596
+ };
19597
+ Buffer$1.prototype.readUInt8 = function readUInt8(offset, noAssert) {
19598
+ if (!noAssert) checkOffset(offset, 1, this.length);
19599
+ return this[offset];
19600
+ };
19601
+ Buffer$1.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
19602
+ if (!noAssert) checkOffset(offset, 2, this.length);
19603
+ return this[offset] | this[offset + 1] << 8;
19604
+ };
19605
+ Buffer$1.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
19606
+ if (!noAssert) checkOffset(offset, 2, this.length);
19607
+ return this[offset] << 8 | this[offset + 1];
19608
+ };
19609
+ Buffer$1.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
19610
+ if (!noAssert) checkOffset(offset, 4, this.length);
19611
+ return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
19612
+ };
19613
+ Buffer$1.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
19614
+ if (!noAssert) checkOffset(offset, 4, this.length);
19615
+ return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
19616
+ };
19617
+ Buffer$1.prototype.readIntLE = function readIntLE(offset, byteLength, noAssert) {
19618
+ offset = offset | 0;
19619
+ byteLength = byteLength | 0;
19620
+ if (!noAssert) checkOffset(offset, byteLength, this.length);
19621
+ var val = this[offset];
19622
+ var mul = 1;
19623
+ var i = 0;
19624
+ while (++i < byteLength && (mul *= 256)) val += this[offset + i] * mul;
19625
+ mul *= 128;
19626
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength);
19627
+ return val;
19628
+ };
19629
+ Buffer$1.prototype.readIntBE = function readIntBE(offset, byteLength, noAssert) {
19630
+ offset = offset | 0;
19631
+ byteLength = byteLength | 0;
19632
+ if (!noAssert) checkOffset(offset, byteLength, this.length);
19633
+ var i = byteLength;
19634
+ var mul = 1;
19635
+ var val = this[offset + --i];
19636
+ while (i > 0 && (mul *= 256)) val += this[offset + --i] * mul;
19637
+ mul *= 128;
19638
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength);
19639
+ return val;
19640
+ };
19641
+ Buffer$1.prototype.readInt8 = function readInt8(offset, noAssert) {
19642
+ if (!noAssert) checkOffset(offset, 1, this.length);
19643
+ if (!(this[offset] & 128)) return this[offset];
19644
+ return (255 - this[offset] + 1) * -1;
19645
+ };
19646
+ Buffer$1.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
19647
+ if (!noAssert) checkOffset(offset, 2, this.length);
19648
+ var val = this[offset] | this[offset + 1] << 8;
19649
+ return val & 32768 ? val | 4294901760 : val;
19650
+ };
19651
+ Buffer$1.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
19652
+ if (!noAssert) checkOffset(offset, 2, this.length);
19653
+ var val = this[offset + 1] | this[offset] << 8;
19654
+ return val & 32768 ? val | 4294901760 : val;
19655
+ };
19656
+ Buffer$1.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
19657
+ if (!noAssert) checkOffset(offset, 4, this.length);
19658
+ return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
19659
+ };
19660
+ Buffer$1.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
19661
+ if (!noAssert) checkOffset(offset, 4, this.length);
19662
+ return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
19663
+ };
19664
+ Buffer$1.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
19665
+ if (!noAssert) checkOffset(offset, 4, this.length);
19666
+ return read(this, offset, true, 23, 4);
19667
+ };
19668
+ Buffer$1.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
19669
+ if (!noAssert) checkOffset(offset, 4, this.length);
19670
+ return read(this, offset, false, 23, 4);
19671
+ };
19672
+ Buffer$1.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
19673
+ if (!noAssert) checkOffset(offset, 8, this.length);
19674
+ return read(this, offset, true, 52, 8);
19675
+ };
19676
+ Buffer$1.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
19677
+ if (!noAssert) checkOffset(offset, 8, this.length);
19678
+ return read(this, offset, false, 52, 8);
19679
+ };
19680
+ function checkInt(buf, value, offset, ext, max, min) {
19681
+ if (!internalIsBuffer(buf)) throw new TypeError("\"buffer\" argument must be a Buffer instance");
19682
+ if (value > max || value < min) throw new RangeError("\"value\" argument is out of bounds");
19683
+ if (offset + ext > buf.length) throw new RangeError("Index out of range");
19684
+ }
19685
+ Buffer$1.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength, noAssert) {
19686
+ value = +value;
19687
+ offset = offset | 0;
19688
+ byteLength = byteLength | 0;
19689
+ if (!noAssert) {
19690
+ var maxBytes = Math.pow(2, 8 * byteLength) - 1;
19691
+ checkInt(this, value, offset, byteLength, maxBytes, 0);
19692
+ }
19693
+ var mul = 1;
19694
+ var i = 0;
19695
+ this[offset] = value & 255;
19696
+ while (++i < byteLength && (mul *= 256)) this[offset + i] = value / mul & 255;
19697
+ return offset + byteLength;
19698
+ };
19699
+ Buffer$1.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength, noAssert) {
19700
+ value = +value;
19701
+ offset = offset | 0;
19702
+ byteLength = byteLength | 0;
19703
+ if (!noAssert) {
19704
+ var maxBytes = Math.pow(2, 8 * byteLength) - 1;
19705
+ checkInt(this, value, offset, byteLength, maxBytes, 0);
19706
+ }
19707
+ var i = byteLength - 1;
19708
+ var mul = 1;
19709
+ this[offset + i] = value & 255;
19710
+ while (--i >= 0 && (mul *= 256)) this[offset + i] = value / mul & 255;
19711
+ return offset + byteLength;
19712
+ };
19713
+ Buffer$1.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
19714
+ value = +value;
19715
+ offset = offset | 0;
19716
+ if (!noAssert) checkInt(this, value, offset, 1, 255, 0);
19717
+ if (!Buffer$1.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
19718
+ this[offset] = value & 255;
19719
+ return offset + 1;
19720
+ };
19721
+ function objectWriteUInt16(buf, value, offset, littleEndian) {
19722
+ if (value < 0) value = 65535 + value + 1;
19723
+ 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;
19724
+ }
19725
+ Buffer$1.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
19726
+ value = +value;
19727
+ offset = offset | 0;
19728
+ if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
19729
+ if (Buffer$1.TYPED_ARRAY_SUPPORT) {
19730
+ this[offset] = value & 255;
19731
+ this[offset + 1] = value >>> 8;
19732
+ } else objectWriteUInt16(this, value, offset, true);
19733
+ return offset + 2;
19734
+ };
19735
+ Buffer$1.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
19736
+ value = +value;
19737
+ offset = offset | 0;
19738
+ if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
19739
+ if (Buffer$1.TYPED_ARRAY_SUPPORT) {
19740
+ this[offset] = value >>> 8;
19741
+ this[offset + 1] = value & 255;
19742
+ } else objectWriteUInt16(this, value, offset, false);
19743
+ return offset + 2;
19744
+ };
19745
+ function objectWriteUInt32(buf, value, offset, littleEndian) {
19746
+ if (value < 0) value = 4294967295 + value + 1;
19747
+ for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) buf[offset + i] = value >>> (littleEndian ? i : 3 - i) * 8 & 255;
19748
+ }
19749
+ Buffer$1.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
19750
+ value = +value;
19751
+ offset = offset | 0;
19752
+ if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
19753
+ if (Buffer$1.TYPED_ARRAY_SUPPORT) {
19754
+ this[offset + 3] = value >>> 24;
19755
+ this[offset + 2] = value >>> 16;
19756
+ this[offset + 1] = value >>> 8;
19757
+ this[offset] = value & 255;
19758
+ } else objectWriteUInt32(this, value, offset, true);
19759
+ return offset + 4;
19760
+ };
19761
+ Buffer$1.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
19762
+ value = +value;
19763
+ offset = offset | 0;
19764
+ if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
19765
+ if (Buffer$1.TYPED_ARRAY_SUPPORT) {
19766
+ this[offset] = value >>> 24;
19767
+ this[offset + 1] = value >>> 16;
19768
+ this[offset + 2] = value >>> 8;
19769
+ this[offset + 3] = value & 255;
19770
+ } else objectWriteUInt32(this, value, offset, false);
19771
+ return offset + 4;
19772
+ };
19773
+ Buffer$1.prototype.writeIntLE = function writeIntLE(value, offset, byteLength, noAssert) {
19774
+ value = +value;
19775
+ offset = offset | 0;
19776
+ if (!noAssert) {
19777
+ var limit = Math.pow(2, 8 * byteLength - 1);
19778
+ checkInt(this, value, offset, byteLength, limit - 1, -limit);
19779
+ }
19780
+ var i = 0;
19781
+ var mul = 1;
19782
+ var sub = 0;
19783
+ this[offset] = value & 255;
19784
+ while (++i < byteLength && (mul *= 256)) {
19785
+ if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) sub = 1;
19786
+ this[offset + i] = (value / mul >> 0) - sub & 255;
19787
+ }
19788
+ return offset + byteLength;
19789
+ };
19790
+ Buffer$1.prototype.writeIntBE = function writeIntBE(value, offset, byteLength, noAssert) {
19791
+ value = +value;
19792
+ offset = offset | 0;
19793
+ if (!noAssert) {
19794
+ var limit = Math.pow(2, 8 * byteLength - 1);
19795
+ checkInt(this, value, offset, byteLength, limit - 1, -limit);
19796
+ }
19797
+ var i = byteLength - 1;
19798
+ var mul = 1;
19799
+ var sub = 0;
19800
+ this[offset + i] = value & 255;
19801
+ while (--i >= 0 && (mul *= 256)) {
19802
+ if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) sub = 1;
19803
+ this[offset + i] = (value / mul >> 0) - sub & 255;
19804
+ }
19805
+ return offset + byteLength;
19806
+ };
19807
+ Buffer$1.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
19808
+ value = +value;
19809
+ offset = offset | 0;
19810
+ if (!noAssert) checkInt(this, value, offset, 1, 127, -128);
19811
+ if (!Buffer$1.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
19812
+ if (value < 0) value = 255 + value + 1;
19813
+ this[offset] = value & 255;
19814
+ return offset + 1;
19815
+ };
19816
+ Buffer$1.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
19817
+ value = +value;
19818
+ offset = offset | 0;
19819
+ if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
19820
+ if (Buffer$1.TYPED_ARRAY_SUPPORT) {
19821
+ this[offset] = value & 255;
19822
+ this[offset + 1] = value >>> 8;
19823
+ } else objectWriteUInt16(this, value, offset, true);
19824
+ return offset + 2;
19825
+ };
19826
+ Buffer$1.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
19827
+ value = +value;
19828
+ offset = offset | 0;
19829
+ if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
19830
+ if (Buffer$1.TYPED_ARRAY_SUPPORT) {
19831
+ this[offset] = value >>> 8;
19832
+ this[offset + 1] = value & 255;
19833
+ } else objectWriteUInt16(this, value, offset, false);
19834
+ return offset + 2;
19835
+ };
19836
+ Buffer$1.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
19837
+ value = +value;
19838
+ offset = offset | 0;
19839
+ if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
19840
+ if (Buffer$1.TYPED_ARRAY_SUPPORT) {
19841
+ this[offset] = value & 255;
19842
+ this[offset + 1] = value >>> 8;
19843
+ this[offset + 2] = value >>> 16;
19844
+ this[offset + 3] = value >>> 24;
19845
+ } else objectWriteUInt32(this, value, offset, true);
19846
+ return offset + 4;
19847
+ };
19848
+ Buffer$1.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
19849
+ value = +value;
19850
+ offset = offset | 0;
19851
+ if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
19852
+ if (value < 0) value = 4294967295 + value + 1;
19853
+ if (Buffer$1.TYPED_ARRAY_SUPPORT) {
19854
+ this[offset] = value >>> 24;
19855
+ this[offset + 1] = value >>> 16;
19856
+ this[offset + 2] = value >>> 8;
19857
+ this[offset + 3] = value & 255;
19858
+ } else objectWriteUInt32(this, value, offset, false);
19859
+ return offset + 4;
19860
+ };
19861
+ function checkIEEE754(buf, value, offset, ext, max, min) {
19862
+ if (offset + ext > buf.length) throw new RangeError("Index out of range");
19863
+ if (offset < 0) throw new RangeError("Index out of range");
19864
+ }
19865
+ function writeFloat(buf, value, offset, littleEndian, noAssert) {
19866
+ if (!noAssert) checkIEEE754(buf, value, offset, 4);
19867
+ write(buf, value, offset, littleEndian, 23, 4);
19868
+ return offset + 4;
19869
+ }
19870
+ Buffer$1.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
19871
+ return writeFloat(this, value, offset, true, noAssert);
19872
+ };
19873
+ Buffer$1.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
19874
+ return writeFloat(this, value, offset, false, noAssert);
19875
+ };
19876
+ function writeDouble(buf, value, offset, littleEndian, noAssert) {
19877
+ if (!noAssert) checkIEEE754(buf, value, offset, 8);
19878
+ write(buf, value, offset, littleEndian, 52, 8);
19879
+ return offset + 8;
19880
+ }
19881
+ Buffer$1.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
19882
+ return writeDouble(this, value, offset, true, noAssert);
19883
+ };
19884
+ Buffer$1.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
19885
+ return writeDouble(this, value, offset, false, noAssert);
19886
+ };
19887
+ Buffer$1.prototype.copy = function copy(target, targetStart, start, end) {
19888
+ if (!start) start = 0;
19889
+ if (!end && end !== 0) end = this.length;
19890
+ if (targetStart >= target.length) targetStart = target.length;
19891
+ if (!targetStart) targetStart = 0;
19892
+ if (end > 0 && end < start) end = start;
19893
+ if (end === start) return 0;
19894
+ if (target.length === 0 || this.length === 0) return 0;
19895
+ if (targetStart < 0) throw new RangeError("targetStart out of bounds");
19896
+ if (start < 0 || start >= this.length) throw new RangeError("sourceStart out of bounds");
19897
+ if (end < 0) throw new RangeError("sourceEnd out of bounds");
19898
+ if (end > this.length) end = this.length;
19899
+ if (target.length - targetStart < end - start) end = target.length - targetStart + start;
19900
+ var len = end - start;
19901
+ var i;
19902
+ if (this === target && start < targetStart && targetStart < end) for (i = len - 1; i >= 0; --i) target[i + targetStart] = this[i + start];
19903
+ else if (len < 1e3 || !Buffer$1.TYPED_ARRAY_SUPPORT) for (i = 0; i < len; ++i) target[i + targetStart] = this[i + start];
19904
+ else Uint8Array.prototype.set.call(target, this.subarray(start, start + len), targetStart);
19905
+ return len;
19906
+ };
19907
+ Buffer$1.prototype.fill = function fill(val, start, end, encoding) {
19908
+ if (typeof val === "string") {
19909
+ if (typeof start === "string") {
19910
+ encoding = start;
19911
+ start = 0;
19912
+ end = this.length;
19913
+ } else if (typeof end === "string") {
19914
+ encoding = end;
19915
+ end = this.length;
19916
+ }
19917
+ if (val.length === 1) {
19918
+ var code = val.charCodeAt(0);
19919
+ if (code < 256) val = code;
19920
+ }
19921
+ if (encoding !== void 0 && typeof encoding !== "string") throw new TypeError("encoding must be a string");
19922
+ if (typeof encoding === "string" && !Buffer$1.isEncoding(encoding)) throw new TypeError("Unknown encoding: " + encoding);
19923
+ } else if (typeof val === "number") val = val & 255;
19924
+ if (start < 0 || this.length < start || this.length < end) throw new RangeError("Out of range index");
19925
+ if (end <= start) return this;
19926
+ start = start >>> 0;
19927
+ end = end === void 0 ? this.length : end >>> 0;
19928
+ if (!val) val = 0;
19929
+ var i;
19930
+ if (typeof val === "number") for (i = start; i < end; ++i) this[i] = val;
19931
+ else {
19932
+ var bytes = internalIsBuffer(val) ? val : utf8ToBytes(new Buffer$1(val, encoding).toString());
19933
+ var len = bytes.length;
19934
+ for (i = 0; i < end - start; ++i) this[i + start] = bytes[i % len];
19935
+ }
19936
+ return this;
19937
+ };
19938
+ var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g;
19939
+ function base64clean(str) {
19940
+ str = stringtrim(str).replace(INVALID_BASE64_RE, "");
19941
+ if (str.length < 2) return "";
19942
+ while (str.length % 4 !== 0) str = str + "=";
19943
+ return str;
19944
+ }
19945
+ function stringtrim(str) {
19946
+ if (str.trim) return str.trim();
19947
+ return str.replace(/^\s+|\s+$/g, "");
19948
+ }
19949
+ function toHex(n) {
19950
+ if (n < 16) return "0" + n.toString(16);
19951
+ return n.toString(16);
19952
+ }
19953
+ function utf8ToBytes(string, units) {
19954
+ units = units || Infinity;
19955
+ var codePoint;
19956
+ var length = string.length;
19957
+ var leadSurrogate = null;
19958
+ var bytes = [];
19959
+ for (var i = 0; i < length; ++i) {
19960
+ codePoint = string.charCodeAt(i);
19961
+ if (codePoint > 55295 && codePoint < 57344) {
19962
+ if (!leadSurrogate) {
19963
+ if (codePoint > 56319) {
19964
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
19965
+ continue;
19966
+ } else if (i + 1 === length) {
19967
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
19968
+ continue;
19969
+ }
19970
+ leadSurrogate = codePoint;
19971
+ continue;
19972
+ }
19973
+ if (codePoint < 56320) {
19974
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
19975
+ leadSurrogate = codePoint;
19976
+ continue;
19977
+ }
19978
+ codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
19979
+ } else if (leadSurrogate) {
19980
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
19981
+ }
19982
+ leadSurrogate = null;
19983
+ if (codePoint < 128) {
19984
+ if ((units -= 1) < 0) break;
19985
+ bytes.push(codePoint);
19986
+ } else if (codePoint < 2048) {
19987
+ if ((units -= 2) < 0) break;
19988
+ bytes.push(codePoint >> 6 | 192, codePoint & 63 | 128);
19989
+ } else if (codePoint < 65536) {
19990
+ if ((units -= 3) < 0) break;
19991
+ bytes.push(codePoint >> 12 | 224, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
19992
+ } else if (codePoint < 1114112) {
19993
+ if ((units -= 4) < 0) break;
19994
+ bytes.push(codePoint >> 18 | 240, codePoint >> 12 & 63 | 128, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
19995
+ } else throw new Error("Invalid code point");
19996
+ }
19997
+ return bytes;
19998
+ }
19999
+ function asciiToBytes(str) {
20000
+ var byteArray = [];
20001
+ for (var i = 0; i < str.length; ++i) byteArray.push(str.charCodeAt(i) & 255);
20002
+ return byteArray;
20003
+ }
20004
+ function utf16leToBytes(str, units) {
20005
+ var c, hi, lo;
20006
+ var byteArray = [];
20007
+ for (var i = 0; i < str.length; ++i) {
20008
+ if ((units -= 2) < 0) break;
20009
+ c = str.charCodeAt(i);
20010
+ hi = c >> 8;
20011
+ lo = c % 256;
20012
+ byteArray.push(lo);
20013
+ byteArray.push(hi);
20014
+ }
20015
+ return byteArray;
20016
+ }
20017
+ function base64ToBytes(str) {
20018
+ return toByteArray(base64clean(str));
20019
+ }
20020
+ function blitBuffer(src, dst, offset, length) {
20021
+ for (var i = 0; i < length; ++i) {
20022
+ if (i + offset >= dst.length || i >= src.length) break;
20023
+ dst[i + offset] = src[i];
20024
+ }
20025
+ return i;
20026
+ }
20027
+ function isnan(val) {
20028
+ return val !== val;
20029
+ }
20030
+ function isBuffer(obj) {
20031
+ return obj != null && (!!obj._isBuffer || isFastBuffer(obj) || isSlowBuffer(obj));
20032
+ }
20033
+ function isFastBuffer(obj) {
20034
+ return !!obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
20035
+ }
20036
+ function isSlowBuffer(obj) {
20037
+ return typeof obj.readFloatLE === "function" && typeof obj.slice === "function" && isFastBuffer(obj.slice(0, 0));
20038
+ }
20039
+ //#endregion
20040
+ //#region \0polyfill-node.process.js
20041
+ function defaultSetTimout() {
20042
+ throw new Error("setTimeout has not been defined");
20043
+ }
20044
+ function defaultClearTimeout() {
20045
+ throw new Error("clearTimeout has not been defined");
20046
+ }
20047
+ var cachedSetTimeout = defaultSetTimout;
20048
+ var cachedClearTimeout = defaultClearTimeout;
20049
+ if (typeof _polyfill_node_global_default.setTimeout === "function") cachedSetTimeout = setTimeout;
20050
+ if (typeof _polyfill_node_global_default.clearTimeout === "function") cachedClearTimeout = clearTimeout;
20051
+ function runTimeout(fun) {
20052
+ if (cachedSetTimeout === setTimeout) return setTimeout(fun, 0);
20053
+ if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
20054
+ cachedSetTimeout = setTimeout;
20055
+ return setTimeout(fun, 0);
20056
+ }
20057
+ try {
20058
+ return cachedSetTimeout(fun, 0);
20059
+ } catch (e) {
20060
+ try {
20061
+ return cachedSetTimeout.call(null, fun, 0);
20062
+ } catch (e) {
20063
+ return cachedSetTimeout.call(this, fun, 0);
20064
+ }
20065
+ }
20066
+ }
20067
+ function runClearTimeout(marker) {
20068
+ if (cachedClearTimeout === clearTimeout) return clearTimeout(marker);
20069
+ if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
20070
+ cachedClearTimeout = clearTimeout;
20071
+ return clearTimeout(marker);
20072
+ }
20073
+ try {
20074
+ return cachedClearTimeout(marker);
20075
+ } catch (e) {
20076
+ try {
20077
+ return cachedClearTimeout.call(null, marker);
20078
+ } catch (e) {
20079
+ return cachedClearTimeout.call(this, marker);
20080
+ }
20081
+ }
20082
+ }
20083
+ var queue = [];
20084
+ var draining = false;
20085
+ var currentQueue;
20086
+ var queueIndex = -1;
20087
+ function cleanUpNextTick() {
20088
+ if (!draining || !currentQueue) return;
20089
+ draining = false;
20090
+ if (currentQueue.length) queue = currentQueue.concat(queue);
20091
+ else queueIndex = -1;
20092
+ if (queue.length) drainQueue();
20093
+ }
20094
+ function drainQueue() {
20095
+ if (draining) return;
20096
+ var timeout = runTimeout(cleanUpNextTick);
20097
+ draining = true;
20098
+ var len = queue.length;
20099
+ while (len) {
20100
+ currentQueue = queue;
20101
+ queue = [];
20102
+ while (++queueIndex < len) if (currentQueue) currentQueue[queueIndex].run();
20103
+ queueIndex = -1;
20104
+ len = queue.length;
20105
+ }
20106
+ currentQueue = null;
20107
+ draining = false;
20108
+ runClearTimeout(timeout);
20109
+ }
20110
+ function nextTick(fun) {
20111
+ var args = new Array(arguments.length - 1);
20112
+ if (arguments.length > 1) for (var i = 1; i < arguments.length; i++) args[i - 1] = arguments[i];
20113
+ queue.push(new Item(fun, args));
20114
+ if (queue.length === 1 && !draining) runTimeout(drainQueue);
20115
+ }
20116
+ function Item(fun, array) {
20117
+ this.fun = fun;
20118
+ this.array = array;
20119
+ }
20120
+ Item.prototype.run = function() {
20121
+ this.fun.apply(null, this.array);
20122
+ };
20123
+ var title = "browser";
20124
+ var platform = "browser";
20125
+ var env = {};
20126
+ var argv = [];
20127
+ var versions = {};
20128
+ var release = {};
20129
+ var config = {};
20130
+ function noop() {}
20131
+ var on = noop;
20132
+ var addListener = noop;
20133
+ var once = noop;
20134
+ var off = noop;
20135
+ var removeListener = noop;
20136
+ var removeAllListeners = noop;
20137
+ var emit = noop;
20138
+ function binding(name) {
20139
+ throw new Error("process.binding is not supported");
20140
+ }
20141
+ function cwd() {
20142
+ return "/";
20143
+ }
20144
+ function chdir(dir) {
20145
+ throw new Error("process.chdir is not supported");
20146
+ }
20147
+ function umask() {
20148
+ return 0;
20149
+ }
20150
+ var performance = _polyfill_node_global_default.performance || {};
20151
+ var performanceNow = performance.now || performance.mozNow || performance.msNow || performance.oNow || performance.webkitNow || function() {
20152
+ return (/* @__PURE__ */ new Date()).getTime();
20153
+ };
20154
+ function hrtime(previousTimestamp) {
20155
+ var clocktime = performanceNow.call(performance) * .001;
20156
+ var seconds = Math.floor(clocktime);
20157
+ var nanoseconds = Math.floor(clocktime % 1 * 1e9);
20158
+ if (previousTimestamp) {
20159
+ seconds = seconds - previousTimestamp[0];
20160
+ nanoseconds = nanoseconds - previousTimestamp[1];
20161
+ if (nanoseconds < 0) {
20162
+ seconds--;
20163
+ nanoseconds += 1e9;
20164
+ }
20165
+ }
20166
+ return [seconds, nanoseconds];
20167
+ }
20168
+ var startTime = /* @__PURE__ */ new Date();
20169
+ function uptime() {
20170
+ return (/* @__PURE__ */ new Date() - startTime) / 1e3;
20171
+ }
20172
+ var browser$1 = {
20173
+ nextTick,
20174
+ title,
20175
+ browser: true,
20176
+ env,
20177
+ argv,
20178
+ version: "",
20179
+ versions,
20180
+ on,
20181
+ addListener,
20182
+ once,
20183
+ off,
20184
+ removeListener,
20185
+ removeAllListeners,
20186
+ emit,
20187
+ binding,
20188
+ cwd,
20189
+ chdir,
20190
+ umask,
20191
+ hrtime,
20192
+ platform,
20193
+ release,
20194
+ config,
20195
+ uptime
20196
+ };
20197
+ //#endregion
20198
+ //#region \0polyfill-node._inherits.js
20199
+ var inherits;
20200
+ if (typeof Object.create === "function") inherits = function inherits(ctor, superCtor) {
20201
+ ctor.super_ = superCtor;
20202
+ ctor.prototype = Object.create(superCtor.prototype, { constructor: {
20203
+ value: ctor,
20204
+ enumerable: false,
20205
+ writable: true,
20206
+ configurable: true
20207
+ } });
20208
+ };
20209
+ else inherits = function inherits(ctor, superCtor) {
20210
+ ctor.super_ = superCtor;
20211
+ var TempCtor = function() {};
20212
+ TempCtor.prototype = superCtor.prototype;
20213
+ ctor.prototype = new TempCtor();
20214
+ ctor.prototype.constructor = ctor;
20215
+ };
20216
+ var _polyfill_node__inherits_default = inherits;
20217
+ //#endregion
20218
+ //#region \0polyfill-node.util.js
20219
+ /**
20220
+ * Inherit the prototype methods from one constructor into another.
20221
+ *
20222
+ * The Function.prototype.inherits from lang.js rewritten as a standalone
20223
+ * function (not on Function.prototype). NOTE: If this file is to be loaded
20224
+ * during bootstrapping this function needs to be rewritten using some native
20225
+ * functions as prototype setup using normal JavaScript does not work as
20226
+ * expected during bootstrapping (see mirror.js in r114903).
20227
+ *
20228
+ * @param {function} ctor Constructor function which needs to inherit the
20229
+ * prototype.
20230
+ * @param {function} superCtor Constructor function to inherit prototype from.
20231
+ */
20232
+ var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors || function getOwnPropertyDescriptors(obj) {
20233
+ var keys = Object.keys(obj);
20234
+ var descriptors = {};
20235
+ for (var i = 0; i < keys.length; i++) descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]);
20236
+ return descriptors;
20237
+ };
20238
+ var formatRegExp = /%[sdj%]/g;
20239
+ function format(f) {
20240
+ if (!isString(f)) {
20241
+ var objects = [];
20242
+ for (var i = 0; i < arguments.length; i++) objects.push(inspect(arguments[i]));
20243
+ return objects.join(" ");
20244
+ }
20245
+ var i = 1;
20246
+ var args = arguments;
20247
+ var len = args.length;
20248
+ var str = String(f).replace(formatRegExp, function(x) {
20249
+ if (x === "%%") return "%";
20250
+ if (i >= len) return x;
20251
+ switch (x) {
20252
+ case "%s": return String(args[i++]);
20253
+ case "%d": return Number(args[i++]);
20254
+ case "%j": try {
20255
+ return JSON.stringify(args[i++]);
20256
+ } catch (_) {
20257
+ return "[Circular]";
20258
+ }
20259
+ default: return x;
20260
+ }
20261
+ });
20262
+ for (var x = args[i]; i < len; x = args[++i]) if (isNull(x) || !isObject(x)) str += " " + x;
20263
+ else str += " " + inspect(x);
20264
+ return str;
20265
+ }
20266
+ function deprecate(fn, msg) {
20267
+ if (isUndefined(_polyfill_node_global_default.process)) return function() {
20268
+ return deprecate(fn, msg).apply(this, arguments);
20269
+ };
20270
+ if (browser$1.noDeprecation === true) return fn;
20271
+ var warned = false;
20272
+ function deprecated() {
20273
+ if (!warned) {
20274
+ if (browser$1.throwDeprecation) throw new Error(msg);
20275
+ else if (browser$1.traceDeprecation) console.trace(msg);
20276
+ else console.error(msg);
20277
+ warned = true;
20278
+ }
20279
+ return fn.apply(this, arguments);
20280
+ }
20281
+ return deprecated;
20282
+ }
20283
+ var debugs = {};
20284
+ var debugEnviron;
20285
+ function debuglog(set) {
20286
+ if (isUndefined(debugEnviron)) debugEnviron = browser$1.env.NODE_DEBUG || "";
20287
+ set = set.toUpperCase();
20288
+ if (!debugs[set]) if (new RegExp("\\b" + set + "\\b", "i").test(debugEnviron)) {
20289
+ var pid = 0;
20290
+ debugs[set] = function() {
20291
+ var msg = format.apply(null, arguments);
20292
+ console.error("%s %d: %s", set, pid, msg);
20293
+ };
20294
+ } else debugs[set] = function() {};
20295
+ return debugs[set];
20296
+ }
20297
+ /**
20298
+ * Echos the value of a value. Trys to print the value out
20299
+ * in the best way possible given the different types.
20300
+ *
20301
+ * @param {Object} obj The object to print out.
20302
+ * @param {Object} opts Optional options object that alters the output.
20303
+ */
20304
+ function inspect(obj, opts) {
20305
+ var ctx = {
20306
+ seen: [],
20307
+ stylize: stylizeNoColor
20308
+ };
20309
+ if (arguments.length >= 3) ctx.depth = arguments[2];
20310
+ if (arguments.length >= 4) ctx.colors = arguments[3];
20311
+ if (isBoolean(opts)) ctx.showHidden = opts;
20312
+ else if (opts) _extend(ctx, opts);
20313
+ if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
20314
+ if (isUndefined(ctx.depth)) ctx.depth = 2;
20315
+ if (isUndefined(ctx.colors)) ctx.colors = false;
20316
+ if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
20317
+ if (ctx.colors) ctx.stylize = stylizeWithColor;
20318
+ return formatValue(ctx, obj, ctx.depth);
20319
+ }
20320
+ inspect.colors = {
20321
+ "bold": [1, 22],
20322
+ "italic": [3, 23],
20323
+ "underline": [4, 24],
20324
+ "inverse": [7, 27],
20325
+ "white": [37, 39],
20326
+ "grey": [90, 39],
20327
+ "black": [30, 39],
20328
+ "blue": [34, 39],
20329
+ "cyan": [36, 39],
20330
+ "green": [32, 39],
20331
+ "magenta": [35, 39],
20332
+ "red": [31, 39],
20333
+ "yellow": [33, 39]
20334
+ };
20335
+ inspect.styles = {
20336
+ "special": "cyan",
20337
+ "number": "yellow",
20338
+ "boolean": "yellow",
20339
+ "undefined": "grey",
20340
+ "null": "bold",
20341
+ "string": "green",
20342
+ "date": "magenta",
20343
+ "regexp": "red"
20344
+ };
20345
+ function stylizeWithColor(str, styleType) {
20346
+ var style = inspect.styles[styleType];
20347
+ if (style) return "\x1B[" + inspect.colors[style][0] + "m" + str + "\x1B[" + inspect.colors[style][1] + "m";
20348
+ else return str;
20349
+ }
20350
+ function stylizeNoColor(str, styleType) {
20351
+ return str;
20352
+ }
20353
+ function arrayToHash(array) {
20354
+ var hash = {};
20355
+ array.forEach(function(val, idx) {
20356
+ hash[val] = true;
20357
+ });
20358
+ return hash;
20359
+ }
20360
+ function formatValue(ctx, value, recurseTimes) {
20361
+ if (ctx.customInspect && value && isFunction(value.inspect) && value.inspect !== inspect && !(value.constructor && value.constructor.prototype === value)) {
20362
+ var ret = value.inspect(recurseTimes, ctx);
20363
+ if (!isString(ret)) ret = formatValue(ctx, ret, recurseTimes);
20364
+ return ret;
20365
+ }
20366
+ var primitive = formatPrimitive(ctx, value);
20367
+ if (primitive) return primitive;
20368
+ var keys = Object.keys(value);
20369
+ var visibleKeys = arrayToHash(keys);
20370
+ if (ctx.showHidden) keys = Object.getOwnPropertyNames(value);
20371
+ if (isError(value) && (keys.indexOf("message") >= 0 || keys.indexOf("description") >= 0)) return formatError(value);
20372
+ if (keys.length === 0) {
20373
+ if (isFunction(value)) {
20374
+ var name = value.name ? ": " + value.name : "";
20375
+ return ctx.stylize("[Function" + name + "]", "special");
20376
+ }
20377
+ if (isRegExp(value)) return ctx.stylize(RegExp.prototype.toString.call(value), "regexp");
20378
+ if (isDate(value)) return ctx.stylize(Date.prototype.toString.call(value), "date");
20379
+ if (isError(value)) return formatError(value);
20380
+ }
20381
+ var base = "", array = false, braces = ["{", "}"];
20382
+ if (isArray(value)) {
20383
+ array = true;
20384
+ braces = ["[", "]"];
20385
+ }
20386
+ if (isFunction(value)) base = " [Function" + (value.name ? ": " + value.name : "") + "]";
20387
+ if (isRegExp(value)) base = " " + RegExp.prototype.toString.call(value);
20388
+ if (isDate(value)) base = " " + Date.prototype.toUTCString.call(value);
20389
+ if (isError(value)) base = " " + formatError(value);
20390
+ if (keys.length === 0 && (!array || value.length == 0)) return braces[0] + base + braces[1];
20391
+ if (recurseTimes < 0) if (isRegExp(value)) return ctx.stylize(RegExp.prototype.toString.call(value), "regexp");
20392
+ else return ctx.stylize("[Object]", "special");
20393
+ ctx.seen.push(value);
20394
+ var output;
20395
+ if (array) output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
20396
+ else output = keys.map(function(key) {
20397
+ return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
20398
+ });
20399
+ ctx.seen.pop();
20400
+ return reduceToSingleString(output, base, braces);
20401
+ }
20402
+ function formatPrimitive(ctx, value) {
20403
+ if (isUndefined(value)) return ctx.stylize("undefined", "undefined");
20404
+ if (isString(value)) {
20405
+ var simple = "'" + JSON.stringify(value).replace(/^"|"$/g, "").replace(/'/g, "\\'").replace(/\\"/g, "\"") + "'";
20406
+ return ctx.stylize(simple, "string");
20407
+ }
20408
+ if (isNumber(value)) return ctx.stylize("" + value, "number");
20409
+ if (isBoolean(value)) return ctx.stylize("" + value, "boolean");
20410
+ if (isNull(value)) return ctx.stylize("null", "null");
20411
+ }
20412
+ function formatError(value) {
20413
+ return "[" + Error.prototype.toString.call(value) + "]";
20414
+ }
20415
+ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
20416
+ var output = [];
20417
+ 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));
20418
+ else output.push("");
20419
+ keys.forEach(function(key) {
20420
+ if (!key.match(/^\d+$/)) output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, key, true));
20421
+ });
20422
+ return output;
20423
+ }
20424
+ function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
20425
+ var name, str, desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
20426
+ if (desc.get) if (desc.set) str = ctx.stylize("[Getter/Setter]", "special");
20427
+ else str = ctx.stylize("[Getter]", "special");
20428
+ else if (desc.set) str = ctx.stylize("[Setter]", "special");
20429
+ if (!hasOwnProperty(visibleKeys, key)) name = "[" + key + "]";
20430
+ if (!str) if (ctx.seen.indexOf(desc.value) < 0) {
20431
+ if (isNull(recurseTimes)) str = formatValue(ctx, desc.value, null);
20432
+ else str = formatValue(ctx, desc.value, recurseTimes - 1);
20433
+ if (str.indexOf("\n") > -1) if (array) str = str.split("\n").map(function(line) {
20434
+ return " " + line;
20435
+ }).join("\n").substr(2);
20436
+ else str = "\n" + str.split("\n").map(function(line) {
20437
+ return " " + line;
20438
+ }).join("\n");
20439
+ } else str = ctx.stylize("[Circular]", "special");
20440
+ if (isUndefined(name)) {
20441
+ if (array && key.match(/^\d+$/)) return str;
20442
+ name = JSON.stringify("" + key);
20443
+ if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
20444
+ name = name.substr(1, name.length - 2);
20445
+ name = ctx.stylize(name, "name");
20446
+ } else {
20447
+ name = name.replace(/'/g, "\\'").replace(/\\"/g, "\"").replace(/(^"|"$)/g, "'");
20448
+ name = ctx.stylize(name, "string");
20449
+ }
20450
+ }
20451
+ return name + ": " + str;
20452
+ }
20453
+ function reduceToSingleString(output, base, braces) {
20454
+ var numLinesEst = 0;
20455
+ if (output.reduce(function(prev, cur) {
20456
+ numLinesEst++;
20457
+ if (cur.indexOf("\n") >= 0) numLinesEst++;
20458
+ return prev + cur.replace(/\u001b\[\d\d?m/g, "").length + 1;
20459
+ }, 0) > 60) return braces[0] + (base === "" ? "" : base + "\n ") + " " + output.join(",\n ") + " " + braces[1];
20460
+ return braces[0] + base + " " + output.join(", ") + " " + braces[1];
20461
+ }
20462
+ function isArray(ar) {
20463
+ return Array.isArray(ar);
20464
+ }
20465
+ function isBoolean(arg) {
20466
+ return typeof arg === "boolean";
20467
+ }
20468
+ function isNull(arg) {
20469
+ return arg === null;
20470
+ }
20471
+ function isNumber(arg) {
20472
+ return typeof arg === "number";
20473
+ }
20474
+ function isString(arg) {
20475
+ return typeof arg === "string";
20476
+ }
20477
+ function isUndefined(arg) {
20478
+ return arg === void 0;
20479
+ }
20480
+ function isRegExp(re) {
20481
+ return isObject(re) && objectToString(re) === "[object RegExp]";
20482
+ }
20483
+ function isObject(arg) {
20484
+ return typeof arg === "object" && arg !== null;
20485
+ }
20486
+ function isDate(d) {
20487
+ return isObject(d) && objectToString(d) === "[object Date]";
20488
+ }
20489
+ function isError(e) {
20490
+ return isObject(e) && (objectToString(e) === "[object Error]" || e instanceof Error);
20491
+ }
20492
+ function isFunction(arg) {
20493
+ return typeof arg === "function";
20494
+ }
20495
+ function objectToString(o) {
20496
+ return Object.prototype.toString.call(o);
20497
+ }
20498
+ function _extend(origin, add) {
20499
+ if (!add || !isObject(add)) return origin;
20500
+ var keys = Object.keys(add);
20501
+ var i = keys.length;
20502
+ while (i--) origin[keys[i]] = add[keys[i]];
20503
+ return origin;
20504
+ }
20505
+ function hasOwnProperty(obj, prop) {
20506
+ return Object.prototype.hasOwnProperty.call(obj, prop);
20507
+ }
20508
+ var kCustomPromisifiedSymbol = typeof Symbol !== "undefined" ? Symbol("util.promisify.custom") : void 0;
20509
+ function promisify(original) {
20510
+ if (typeof original !== "function") throw new TypeError("The \"original\" argument must be of type Function");
20511
+ if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {
20512
+ var fn = original[kCustomPromisifiedSymbol];
20513
+ if (typeof fn !== "function") throw new TypeError("The \"util.promisify.custom\" argument must be of type Function");
20514
+ Object.defineProperty(fn, kCustomPromisifiedSymbol, {
20515
+ value: fn,
20516
+ enumerable: false,
20517
+ writable: false,
20518
+ configurable: true
20519
+ });
20520
+ return fn;
20521
+ }
20522
+ function fn() {
20523
+ var promiseResolve, promiseReject;
20524
+ var promise = new Promise(function(resolve, reject) {
20525
+ promiseResolve = resolve;
20526
+ promiseReject = reject;
20527
+ });
20528
+ var args = [];
20529
+ for (var i = 0; i < arguments.length; i++) args.push(arguments[i]);
20530
+ args.push(function(err, value) {
20531
+ if (err) promiseReject(err);
20532
+ else promiseResolve(value);
20533
+ });
20534
+ try {
20535
+ original.apply(this, args);
20536
+ } catch (err) {
20537
+ promiseReject(err);
20538
+ }
20539
+ return promise;
20540
+ }
20541
+ Object.setPrototypeOf(fn, Object.getPrototypeOf(original));
20542
+ if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, {
20543
+ value: fn,
20544
+ enumerable: false,
20545
+ writable: false,
20546
+ configurable: true
20547
+ });
20548
+ return Object.defineProperties(fn, getOwnPropertyDescriptors(original));
20549
+ }
20550
+ promisify.custom = kCustomPromisifiedSymbol;
20551
+ //#endregion
20552
+ //#region \0polyfill-node._buffer_list.js
20553
+ var _polyfill_node__buffer_list_default = BufferList;
20554
+ function BufferList() {
20555
+ this.head = null;
20556
+ this.tail = null;
20557
+ this.length = 0;
20558
+ }
20559
+ BufferList.prototype.push = function(v) {
20560
+ var entry = {
20561
+ data: v,
20562
+ next: null
20563
+ };
20564
+ if (this.length > 0) this.tail.next = entry;
20565
+ else this.head = entry;
20566
+ this.tail = entry;
20567
+ ++this.length;
20568
+ };
20569
+ BufferList.prototype.unshift = function(v) {
20570
+ var entry = {
20571
+ data: v,
20572
+ next: this.head
20573
+ };
20574
+ if (this.length === 0) this.tail = entry;
20575
+ this.head = entry;
20576
+ ++this.length;
20577
+ };
20578
+ BufferList.prototype.shift = function() {
20579
+ if (this.length === 0) return;
20580
+ var ret = this.head.data;
20581
+ if (this.length === 1) this.head = this.tail = null;
20582
+ else this.head = this.head.next;
20583
+ --this.length;
20584
+ return ret;
20585
+ };
20586
+ BufferList.prototype.clear = function() {
20587
+ this.head = this.tail = null;
20588
+ this.length = 0;
20589
+ };
20590
+ BufferList.prototype.join = function(s) {
20591
+ if (this.length === 0) return "";
20592
+ var p = this.head;
20593
+ var ret = "" + p.data;
20594
+ while (p = p.next) ret += s + p.data;
20595
+ return ret;
20596
+ };
20597
+ BufferList.prototype.concat = function(n) {
20598
+ if (this.length === 0) return Buffer$1.alloc(0);
20599
+ if (this.length === 1) return this.head.data;
20600
+ var ret = Buffer$1.allocUnsafe(n >>> 0);
20601
+ var p = this.head;
20602
+ var i = 0;
20603
+ while (p) {
20604
+ p.data.copy(ret, i);
20605
+ i += p.data.length;
20606
+ p = p.next;
20607
+ }
20608
+ return ret;
20609
+ };
20610
+ //#endregion
20611
+ //#region \0polyfill-node.string_decoder.js
20612
+ var isBufferEncoding = Buffer$1.isEncoding || function(encoding) {
20613
+ switch (encoding && encoding.toLowerCase()) {
20614
+ case "hex":
20615
+ case "utf8":
20616
+ case "utf-8":
20617
+ case "ascii":
20618
+ case "binary":
20619
+ case "base64":
20620
+ case "ucs2":
20621
+ case "ucs-2":
20622
+ case "utf16le":
20623
+ case "utf-16le":
20624
+ case "raw": return true;
20625
+ default: return false;
20626
+ }
20627
+ };
20628
+ function assertEncoding(encoding) {
20629
+ if (encoding && !isBufferEncoding(encoding)) throw new Error("Unknown encoding: " + encoding);
20630
+ }
20631
+ function StringDecoder(encoding) {
20632
+ this.encoding = (encoding || "utf8").toLowerCase().replace(/[-_]/, "");
20633
+ assertEncoding(encoding);
20634
+ switch (this.encoding) {
20635
+ case "utf8":
20636
+ this.surrogateSize = 3;
20637
+ break;
20638
+ case "ucs2":
20639
+ case "utf16le":
20640
+ this.surrogateSize = 2;
20641
+ this.detectIncompleteChar = utf16DetectIncompleteChar;
20642
+ break;
20643
+ case "base64":
20644
+ this.surrogateSize = 3;
20645
+ this.detectIncompleteChar = base64DetectIncompleteChar;
20646
+ break;
20647
+ default:
20648
+ this.write = passThroughWrite;
20649
+ return;
20650
+ }
20651
+ this.charBuffer = new Buffer$1(6);
20652
+ this.charReceived = 0;
20653
+ this.charLength = 0;
20654
+ }
20655
+ StringDecoder.prototype.write = function(buffer) {
20656
+ var charStr = "";
20657
+ while (this.charLength) {
20658
+ var available = buffer.length >= this.charLength - this.charReceived ? this.charLength - this.charReceived : buffer.length;
20659
+ buffer.copy(this.charBuffer, this.charReceived, 0, available);
20660
+ this.charReceived += available;
20661
+ if (this.charReceived < this.charLength) return "";
20662
+ buffer = buffer.slice(available, buffer.length);
20663
+ charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
20664
+ var charCode = charStr.charCodeAt(charStr.length - 1);
20665
+ if (charCode >= 55296 && charCode <= 56319) {
20666
+ this.charLength += this.surrogateSize;
20667
+ charStr = "";
20668
+ continue;
20669
+ }
20670
+ this.charReceived = this.charLength = 0;
20671
+ if (buffer.length === 0) return charStr;
20672
+ break;
20673
+ }
20674
+ this.detectIncompleteChar(buffer);
20675
+ var end = buffer.length;
20676
+ if (this.charLength) {
20677
+ buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
20678
+ end -= this.charReceived;
20679
+ }
20680
+ charStr += buffer.toString(this.encoding, 0, end);
20681
+ var end = charStr.length - 1;
20682
+ var charCode = charStr.charCodeAt(end);
20683
+ if (charCode >= 55296 && charCode <= 56319) {
20684
+ var size = this.surrogateSize;
20685
+ this.charLength += size;
20686
+ this.charReceived += size;
20687
+ this.charBuffer.copy(this.charBuffer, size, 0, size);
20688
+ buffer.copy(this.charBuffer, 0, 0, size);
20689
+ return charStr.substring(0, end);
20690
+ }
20691
+ return charStr;
20692
+ };
20693
+ StringDecoder.prototype.detectIncompleteChar = function(buffer) {
20694
+ var i = buffer.length >= 3 ? 3 : buffer.length;
20695
+ for (; i > 0; i--) {
20696
+ var c = buffer[buffer.length - i];
20697
+ if (i == 1 && c >> 5 == 6) {
20698
+ this.charLength = 2;
20699
+ break;
20700
+ }
20701
+ if (i <= 2 && c >> 4 == 14) {
20702
+ this.charLength = 3;
20703
+ break;
20704
+ }
20705
+ if (i <= 3 && c >> 3 == 30) {
20706
+ this.charLength = 4;
20707
+ break;
20708
+ }
20709
+ }
20710
+ this.charReceived = i;
20711
+ };
20712
+ StringDecoder.prototype.end = function(buffer) {
20713
+ var res = "";
20714
+ if (buffer && buffer.length) res = this.write(buffer);
20715
+ if (this.charReceived) {
20716
+ var cr = this.charReceived;
20717
+ var buf = this.charBuffer;
20718
+ var enc = this.encoding;
20719
+ res += buf.slice(0, cr).toString(enc);
20720
+ }
20721
+ return res;
20722
+ };
20723
+ function passThroughWrite(buffer) {
20724
+ return buffer.toString(this.encoding);
20725
+ }
20726
+ function utf16DetectIncompleteChar(buffer) {
20727
+ this.charReceived = buffer.length % 2;
20728
+ this.charLength = this.charReceived ? 2 : 0;
20729
+ }
20730
+ function base64DetectIncompleteChar(buffer) {
20731
+ this.charReceived = buffer.length % 3;
20732
+ this.charLength = this.charReceived ? 3 : 0;
20733
+ }
20734
+ //#endregion
20735
+ //#region \0polyfill-node._stream_readable.js
20736
+ Readable.ReadableState = ReadableState;
20737
+ var debug = debuglog("stream");
20738
+ _polyfill_node__inherits_default(Readable, EventEmitter);
20739
+ function prependListener(emitter, event, fn) {
20740
+ if (typeof emitter.prependListener === "function") return emitter.prependListener(event, fn);
20741
+ else if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);
20742
+ else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);
20743
+ else emitter._events[event] = [fn, emitter._events[event]];
20744
+ }
20745
+ function listenerCount(emitter, type) {
20746
+ return emitter.listeners(type).length;
20747
+ }
20748
+ function ReadableState(options, stream) {
20749
+ options = options || {};
20750
+ this.objectMode = !!options.objectMode;
20751
+ if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
20752
+ var hwm = options.highWaterMark;
20753
+ var defaultHwm = this.objectMode ? 16 : 16 * 1024;
20754
+ this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
20755
+ this.highWaterMark = ~~this.highWaterMark;
20756
+ this.buffer = new _polyfill_node__buffer_list_default();
20757
+ this.length = 0;
20758
+ this.pipes = null;
20759
+ this.pipesCount = 0;
20760
+ this.flowing = null;
20761
+ this.ended = false;
20762
+ this.endEmitted = false;
20763
+ this.reading = false;
20764
+ this.sync = true;
20765
+ this.needReadable = false;
20766
+ this.emittedReadable = false;
20767
+ this.readableListening = false;
20768
+ this.resumeScheduled = false;
20769
+ this.defaultEncoding = options.defaultEncoding || "utf8";
20770
+ this.ranOut = false;
20771
+ this.awaitDrain = 0;
20772
+ this.readingMore = false;
20773
+ this.decoder = null;
20774
+ this.encoding = null;
20775
+ if (options.encoding) {
20776
+ this.decoder = new StringDecoder(options.encoding);
20777
+ this.encoding = options.encoding;
20778
+ }
20779
+ }
20780
+ function Readable(options) {
20781
+ if (!(this instanceof Readable)) return new Readable(options);
20782
+ this._readableState = new ReadableState(options, this);
20783
+ this.readable = true;
20784
+ if (options && typeof options.read === "function") this._read = options.read;
20785
+ EventEmitter.call(this);
20786
+ }
20787
+ Readable.prototype.push = function(chunk, encoding) {
20788
+ var state = this._readableState;
20789
+ if (!state.objectMode && typeof chunk === "string") {
20790
+ encoding = encoding || state.defaultEncoding;
20791
+ if (encoding !== state.encoding) {
20792
+ chunk = Buffer$1.from(chunk, encoding);
20793
+ encoding = "";
20794
+ }
20795
+ }
20796
+ return readableAddChunk(this, state, chunk, encoding, false);
20797
+ };
20798
+ Readable.prototype.unshift = function(chunk) {
20799
+ var state = this._readableState;
20800
+ return readableAddChunk(this, state, chunk, "", true);
20801
+ };
20802
+ Readable.prototype.isPaused = function() {
20803
+ return this._readableState.flowing === false;
20804
+ };
20805
+ function readableAddChunk(stream, state, chunk, encoding, addToFront) {
20806
+ var er = chunkInvalid(state, chunk);
20807
+ if (er) stream.emit("error", er);
20808
+ else if (chunk === null) {
20809
+ state.reading = false;
20810
+ onEofChunk(stream, state);
20811
+ } else if (state.objectMode || chunk && chunk.length > 0) if (state.ended && !addToFront) {
20812
+ var e = /* @__PURE__ */ new Error("stream.push() after EOF");
20813
+ stream.emit("error", e);
20814
+ } else if (state.endEmitted && addToFront) {
20815
+ var _e = /* @__PURE__ */ new Error("stream.unshift() after end event");
20816
+ stream.emit("error", _e);
20817
+ } else {
20818
+ var skipAdd;
20819
+ if (state.decoder && !addToFront && !encoding) {
20820
+ chunk = state.decoder.write(chunk);
20821
+ skipAdd = !state.objectMode && chunk.length === 0;
20822
+ }
20823
+ if (!addToFront) state.reading = false;
20824
+ if (!skipAdd) if (state.flowing && state.length === 0 && !state.sync) {
20825
+ stream.emit("data", chunk);
20826
+ stream.read(0);
20827
+ } else {
20828
+ state.length += state.objectMode ? 1 : chunk.length;
20829
+ if (addToFront) state.buffer.unshift(chunk);
20830
+ else state.buffer.push(chunk);
20831
+ if (state.needReadable) emitReadable(stream);
20832
+ }
20833
+ maybeReadMore(stream, state);
20834
+ }
20835
+ else if (!addToFront) state.reading = false;
20836
+ return needMoreData(state);
20837
+ }
20838
+ function needMoreData(state) {
20839
+ return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
20840
+ }
20841
+ Readable.prototype.setEncoding = function(enc) {
20842
+ this._readableState.decoder = new StringDecoder(enc);
20843
+ this._readableState.encoding = enc;
20844
+ return this;
20845
+ };
20846
+ var MAX_HWM = 8388608;
20847
+ function computeNewHighWaterMark(n) {
20848
+ if (n >= MAX_HWM) n = MAX_HWM;
20849
+ else {
20850
+ n--;
20851
+ n |= n >>> 1;
20852
+ n |= n >>> 2;
20853
+ n |= n >>> 4;
20854
+ n |= n >>> 8;
20855
+ n |= n >>> 16;
20856
+ n++;
20857
+ }
20858
+ return n;
20859
+ }
20860
+ function howMuchToRead(n, state) {
20861
+ if (n <= 0 || state.length === 0 && state.ended) return 0;
20862
+ if (state.objectMode) return 1;
20863
+ if (n !== n) if (state.flowing && state.length) return state.buffer.head.data.length;
20864
+ else return state.length;
20865
+ if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
20866
+ if (n <= state.length) return n;
20867
+ if (!state.ended) {
20868
+ state.needReadable = true;
20869
+ return 0;
20870
+ }
20871
+ return state.length;
20872
+ }
20873
+ Readable.prototype.read = function(n) {
20874
+ debug("read", n);
20875
+ n = parseInt(n, 10);
20876
+ var state = this._readableState;
20877
+ var nOrig = n;
20878
+ if (n !== 0) state.emittedReadable = false;
20879
+ if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
20880
+ debug("read: emitReadable", state.length, state.ended);
20881
+ if (state.length === 0 && state.ended) endReadable(this);
20882
+ else emitReadable(this);
20883
+ return null;
20884
+ }
20885
+ n = howMuchToRead(n, state);
20886
+ if (n === 0 && state.ended) {
20887
+ if (state.length === 0) endReadable(this);
20888
+ return null;
20889
+ }
20890
+ var doRead = state.needReadable;
20891
+ debug("need readable", doRead);
20892
+ if (state.length === 0 || state.length - n < state.highWaterMark) {
20893
+ doRead = true;
20894
+ debug("length less than watermark", doRead);
20895
+ }
20896
+ if (state.ended || state.reading) {
20897
+ doRead = false;
20898
+ debug("reading or ended", doRead);
20899
+ } else if (doRead) {
20900
+ debug("do read");
20901
+ state.reading = true;
20902
+ state.sync = true;
20903
+ if (state.length === 0) state.needReadable = true;
20904
+ this._read(state.highWaterMark);
20905
+ state.sync = false;
20906
+ if (!state.reading) n = howMuchToRead(nOrig, state);
20907
+ }
20908
+ var ret;
20909
+ if (n > 0) ret = fromList(n, state);
20910
+ else ret = null;
20911
+ if (ret === null) {
20912
+ state.needReadable = true;
20913
+ n = 0;
20914
+ } else state.length -= n;
20915
+ if (state.length === 0) {
20916
+ if (!state.ended) state.needReadable = true;
20917
+ if (nOrig !== n && state.ended) endReadable(this);
20918
+ }
20919
+ if (ret !== null) this.emit("data", ret);
20920
+ return ret;
20921
+ };
20922
+ function chunkInvalid(state, chunk) {
20923
+ var er = null;
20924
+ if (!Buffer$1.isBuffer(chunk) && typeof chunk !== "string" && chunk !== null && chunk !== void 0 && !state.objectMode) er = /* @__PURE__ */ new TypeError("Invalid non-string/buffer chunk");
20925
+ return er;
20926
+ }
20927
+ function onEofChunk(stream, state) {
20928
+ if (state.ended) return;
20929
+ if (state.decoder) {
20930
+ var chunk = state.decoder.end();
20931
+ if (chunk && chunk.length) {
20932
+ state.buffer.push(chunk);
20933
+ state.length += state.objectMode ? 1 : chunk.length;
20934
+ }
20935
+ }
20936
+ state.ended = true;
20937
+ emitReadable(stream);
20938
+ }
20939
+ function emitReadable(stream) {
20940
+ var state = stream._readableState;
20941
+ state.needReadable = false;
20942
+ if (!state.emittedReadable) {
20943
+ debug("emitReadable", state.flowing);
20944
+ state.emittedReadable = true;
20945
+ if (state.sync) nextTick(emitReadable_, stream);
20946
+ else emitReadable_(stream);
20947
+ }
20948
+ }
20949
+ function emitReadable_(stream) {
20950
+ debug("emit readable");
20951
+ stream.emit("readable");
20952
+ flow(stream);
20953
+ }
20954
+ function maybeReadMore(stream, state) {
20955
+ if (!state.readingMore) {
20956
+ state.readingMore = true;
20957
+ nextTick(maybeReadMore_, stream, state);
20958
+ }
20959
+ }
20960
+ function maybeReadMore_(stream, state) {
20961
+ var len = state.length;
20962
+ while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
20963
+ debug("maybeReadMore read 0");
20964
+ stream.read(0);
20965
+ if (len === state.length) break;
20966
+ else len = state.length;
20967
+ }
20968
+ state.readingMore = false;
20969
+ }
20970
+ Readable.prototype._read = function(n) {
20971
+ this.emit("error", /* @__PURE__ */ new Error("not implemented"));
20972
+ };
20973
+ Readable.prototype.pipe = function(dest, pipeOpts) {
20974
+ var src = this;
20975
+ var state = this._readableState;
20976
+ switch (state.pipesCount) {
20977
+ case 0:
20978
+ state.pipes = dest;
20979
+ break;
20980
+ case 1:
20981
+ state.pipes = [state.pipes, dest];
20982
+ break;
20983
+ default:
20984
+ state.pipes.push(dest);
20985
+ break;
20986
+ }
20987
+ state.pipesCount += 1;
20988
+ debug("pipe count=%d opts=%j", state.pipesCount, pipeOpts);
20989
+ var endFn = !pipeOpts || pipeOpts.end !== false ? onend : cleanup;
20990
+ if (state.endEmitted) nextTick(endFn);
20991
+ else src.once("end", endFn);
20992
+ dest.on("unpipe", onunpipe);
20993
+ function onunpipe(readable) {
20994
+ debug("onunpipe");
20995
+ if (readable === src) cleanup();
20996
+ }
20997
+ function onend() {
20998
+ debug("onend");
20999
+ dest.end();
21000
+ }
21001
+ var ondrain = pipeOnDrain(src);
21002
+ dest.on("drain", ondrain);
21003
+ var cleanedUp = false;
21004
+ function cleanup() {
21005
+ debug("cleanup");
21006
+ dest.removeListener("close", onclose);
21007
+ dest.removeListener("finish", onfinish);
21008
+ dest.removeListener("drain", ondrain);
21009
+ dest.removeListener("error", onerror);
21010
+ dest.removeListener("unpipe", onunpipe);
21011
+ src.removeListener("end", onend);
21012
+ src.removeListener("end", cleanup);
21013
+ src.removeListener("data", ondata);
21014
+ cleanedUp = true;
21015
+ if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
21016
+ }
21017
+ var increasedAwaitDrain = false;
21018
+ src.on("data", ondata);
21019
+ function ondata(chunk) {
21020
+ debug("ondata");
21021
+ increasedAwaitDrain = false;
21022
+ if (false === dest.write(chunk) && !increasedAwaitDrain) {
21023
+ if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
21024
+ debug("false write response, pause", src._readableState.awaitDrain);
21025
+ src._readableState.awaitDrain++;
21026
+ increasedAwaitDrain = true;
21027
+ }
21028
+ src.pause();
21029
+ }
21030
+ }
21031
+ function onerror(er) {
21032
+ debug("onerror", er);
21033
+ unpipe();
21034
+ dest.removeListener("error", onerror);
21035
+ if (listenerCount(dest, "error") === 0) dest.emit("error", er);
21036
+ }
21037
+ prependListener(dest, "error", onerror);
21038
+ function onclose() {
21039
+ dest.removeListener("finish", onfinish);
21040
+ unpipe();
21041
+ }
21042
+ dest.once("close", onclose);
21043
+ function onfinish() {
21044
+ debug("onfinish");
21045
+ dest.removeListener("close", onclose);
21046
+ unpipe();
21047
+ }
21048
+ dest.once("finish", onfinish);
21049
+ function unpipe() {
21050
+ debug("unpipe");
21051
+ src.unpipe(dest);
21052
+ }
21053
+ dest.emit("pipe", src);
21054
+ if (!state.flowing) {
21055
+ debug("pipe resume");
21056
+ src.resume();
21057
+ }
21058
+ return dest;
21059
+ };
21060
+ function pipeOnDrain(src) {
21061
+ return function() {
21062
+ var state = src._readableState;
21063
+ debug("pipeOnDrain", state.awaitDrain);
21064
+ if (state.awaitDrain) state.awaitDrain--;
21065
+ if (state.awaitDrain === 0 && src.listeners("data").length) {
21066
+ state.flowing = true;
21067
+ flow(src);
21068
+ }
21069
+ };
21070
+ }
21071
+ Readable.prototype.unpipe = function(dest) {
21072
+ var state = this._readableState;
21073
+ if (state.pipesCount === 0) return this;
21074
+ if (state.pipesCount === 1) {
21075
+ if (dest && dest !== state.pipes) return this;
21076
+ if (!dest) dest = state.pipes;
21077
+ state.pipes = null;
21078
+ state.pipesCount = 0;
21079
+ state.flowing = false;
21080
+ if (dest) dest.emit("unpipe", this);
21081
+ return this;
21082
+ }
21083
+ if (!dest) {
21084
+ var dests = state.pipes;
21085
+ var len = state.pipesCount;
21086
+ state.pipes = null;
21087
+ state.pipesCount = 0;
21088
+ state.flowing = false;
21089
+ for (var _i = 0; _i < len; _i++) dests[_i].emit("unpipe", this);
21090
+ return this;
21091
+ }
21092
+ var i = indexOf(state.pipes, dest);
21093
+ if (i === -1) return this;
21094
+ state.pipes.splice(i, 1);
21095
+ state.pipesCount -= 1;
21096
+ if (state.pipesCount === 1) state.pipes = state.pipes[0];
21097
+ dest.emit("unpipe", this);
21098
+ return this;
21099
+ };
21100
+ Readable.prototype.on = function(ev, fn) {
21101
+ var res = EventEmitter.prototype.on.call(this, ev, fn);
21102
+ if (ev === "data") {
21103
+ if (this._readableState.flowing !== false) this.resume();
21104
+ } else if (ev === "readable") {
21105
+ var state = this._readableState;
21106
+ if (!state.endEmitted && !state.readableListening) {
21107
+ state.readableListening = state.needReadable = true;
21108
+ state.emittedReadable = false;
21109
+ if (!state.reading) nextTick(nReadingNextTick, this);
21110
+ else if (state.length) emitReadable(this, state);
21111
+ }
21112
+ }
21113
+ return res;
21114
+ };
21115
+ Readable.prototype.addListener = Readable.prototype.on;
21116
+ function nReadingNextTick(self) {
21117
+ debug("readable nexttick read 0");
21118
+ self.read(0);
21119
+ }
21120
+ Readable.prototype.resume = function() {
21121
+ var state = this._readableState;
21122
+ if (!state.flowing) {
21123
+ debug("resume");
21124
+ state.flowing = true;
21125
+ resume(this, state);
21126
+ }
21127
+ return this;
21128
+ };
21129
+ function resume(stream, state) {
21130
+ if (!state.resumeScheduled) {
21131
+ state.resumeScheduled = true;
21132
+ nextTick(resume_, stream, state);
21133
+ }
21134
+ }
21135
+ function resume_(stream, state) {
21136
+ if (!state.reading) {
21137
+ debug("resume read 0");
21138
+ stream.read(0);
21139
+ }
21140
+ state.resumeScheduled = false;
21141
+ state.awaitDrain = 0;
21142
+ stream.emit("resume");
21143
+ flow(stream);
21144
+ if (state.flowing && !state.reading) stream.read(0);
21145
+ }
21146
+ Readable.prototype.pause = function() {
21147
+ debug("call pause flowing=%j", this._readableState.flowing);
21148
+ if (false !== this._readableState.flowing) {
21149
+ debug("pause");
21150
+ this._readableState.flowing = false;
21151
+ this.emit("pause");
21152
+ }
21153
+ return this;
21154
+ };
21155
+ function flow(stream) {
21156
+ var state = stream._readableState;
21157
+ debug("flow", state.flowing);
21158
+ while (state.flowing && stream.read() !== null);
21159
+ }
21160
+ Readable.prototype.wrap = function(stream) {
21161
+ var state = this._readableState;
21162
+ var paused = false;
21163
+ var self = this;
21164
+ stream.on("end", function() {
21165
+ debug("wrapped end");
21166
+ if (state.decoder && !state.ended) {
21167
+ var chunk = state.decoder.end();
21168
+ if (chunk && chunk.length) self.push(chunk);
21169
+ }
21170
+ self.push(null);
21171
+ });
21172
+ stream.on("data", function(chunk) {
21173
+ debug("wrapped data");
21174
+ if (state.decoder) chunk = state.decoder.write(chunk);
21175
+ if (state.objectMode && (chunk === null || chunk === void 0)) return;
21176
+ else if (!state.objectMode && (!chunk || !chunk.length)) return;
21177
+ if (!self.push(chunk)) {
21178
+ paused = true;
21179
+ stream.pause();
21180
+ }
21181
+ });
21182
+ for (var i in stream) if (this[i] === void 0 && typeof stream[i] === "function") this[i] = function(method) {
21183
+ return function() {
21184
+ return stream[method].apply(stream, arguments);
21185
+ };
21186
+ }(i);
21187
+ forEach([
21188
+ "error",
21189
+ "close",
21190
+ "destroy",
21191
+ "pause",
21192
+ "resume"
21193
+ ], function(ev) {
21194
+ stream.on(ev, self.emit.bind(self, ev));
21195
+ });
21196
+ self._read = function(n) {
21197
+ debug("wrapped _read", n);
21198
+ if (paused) {
21199
+ paused = false;
21200
+ stream.resume();
21201
+ }
21202
+ };
21203
+ return self;
21204
+ };
21205
+ Readable._fromList = fromList;
21206
+ function fromList(n, state) {
21207
+ if (state.length === 0) return null;
21208
+ var ret;
21209
+ if (state.objectMode) ret = state.buffer.shift();
21210
+ else if (!n || n >= state.length) {
21211
+ if (state.decoder) ret = state.buffer.join("");
21212
+ else if (state.buffer.length === 1) ret = state.buffer.head.data;
21213
+ else ret = state.buffer.concat(state.length);
21214
+ state.buffer.clear();
21215
+ } else ret = fromListPartial(n, state.buffer, state.decoder);
21216
+ return ret;
21217
+ }
21218
+ function fromListPartial(n, list, hasStrings) {
21219
+ var ret;
21220
+ if (n < list.head.data.length) {
21221
+ ret = list.head.data.slice(0, n);
21222
+ list.head.data = list.head.data.slice(n);
21223
+ } else if (n === list.head.data.length) ret = list.shift();
21224
+ else ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
21225
+ return ret;
21226
+ }
21227
+ function copyFromBufferString(n, list) {
21228
+ var p = list.head;
21229
+ var c = 1;
21230
+ var ret = p.data;
21231
+ n -= ret.length;
21232
+ while (p = p.next) {
21233
+ var str = p.data;
21234
+ var nb = n > str.length ? str.length : n;
21235
+ if (nb === str.length) ret += str;
21236
+ else ret += str.slice(0, n);
21237
+ n -= nb;
21238
+ if (n === 0) {
21239
+ if (nb === str.length) {
21240
+ ++c;
21241
+ if (p.next) list.head = p.next;
21242
+ else list.head = list.tail = null;
21243
+ } else {
21244
+ list.head = p;
21245
+ p.data = str.slice(nb);
21246
+ }
21247
+ break;
21248
+ }
21249
+ ++c;
21250
+ }
21251
+ list.length -= c;
21252
+ return ret;
21253
+ }
21254
+ function copyFromBuffer(n, list) {
21255
+ var ret = Buffer$1.allocUnsafe(n);
21256
+ var p = list.head;
21257
+ var c = 1;
21258
+ p.data.copy(ret);
21259
+ n -= p.data.length;
21260
+ while (p = p.next) {
21261
+ var buf = p.data;
21262
+ var nb = n > buf.length ? buf.length : n;
21263
+ buf.copy(ret, ret.length - n, 0, nb);
21264
+ n -= nb;
21265
+ if (n === 0) {
21266
+ if (nb === buf.length) {
21267
+ ++c;
21268
+ if (p.next) list.head = p.next;
21269
+ else list.head = list.tail = null;
21270
+ } else {
21271
+ list.head = p;
21272
+ p.data = buf.slice(nb);
21273
+ }
21274
+ break;
21275
+ }
21276
+ ++c;
21277
+ }
21278
+ list.length -= c;
21279
+ return ret;
21280
+ }
21281
+ function endReadable(stream) {
21282
+ var state = stream._readableState;
21283
+ if (state.length > 0) throw new Error("\"endReadable()\" called on non-empty stream");
21284
+ if (!state.endEmitted) {
21285
+ state.ended = true;
21286
+ nextTick(endReadableNT, state, stream);
21287
+ }
21288
+ }
21289
+ function endReadableNT(state, stream) {
21290
+ if (!state.endEmitted && state.length === 0) {
21291
+ state.endEmitted = true;
21292
+ stream.readable = false;
21293
+ stream.emit("end");
21294
+ }
21295
+ }
21296
+ function forEach(xs, f) {
21297
+ for (var i = 0, l = xs.length; i < l; i++) f(xs[i], i);
21298
+ }
21299
+ function indexOf(xs, x) {
21300
+ for (var i = 0, l = xs.length; i < l; i++) if (xs[i] === x) return i;
21301
+ return -1;
21302
+ }
21303
+ //#endregion
21304
+ //#region \0polyfill-node._stream_writable.js
21305
+ Writable.WritableState = WritableState;
21306
+ _polyfill_node__inherits_default(Writable, EventEmitter);
21307
+ function nop() {}
21308
+ function WriteReq(chunk, encoding, cb) {
21309
+ this.chunk = chunk;
21310
+ this.encoding = encoding;
21311
+ this.callback = cb;
21312
+ this.next = null;
21313
+ }
21314
+ function WritableState(options, stream) {
21315
+ Object.defineProperty(this, "buffer", { get: deprecate(function() {
21316
+ return this.getBuffer();
21317
+ }, "_writableState.buffer is deprecated. Use _writableState.getBuffer instead.") });
21318
+ options = options || {};
21319
+ this.objectMode = !!options.objectMode;
21320
+ if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
21321
+ var hwm = options.highWaterMark;
21322
+ var defaultHwm = this.objectMode ? 16 : 16 * 1024;
21323
+ this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
21324
+ this.highWaterMark = ~~this.highWaterMark;
21325
+ this.needDrain = false;
21326
+ this.ending = false;
21327
+ this.ended = false;
21328
+ this.finished = false;
21329
+ this.decodeStrings = !(options.decodeStrings === false);
21330
+ this.defaultEncoding = options.defaultEncoding || "utf8";
21331
+ this.length = 0;
21332
+ this.writing = false;
21333
+ this.corked = 0;
21334
+ this.sync = true;
21335
+ this.bufferProcessing = false;
21336
+ this.onwrite = function(er) {
21337
+ onwrite(stream, er);
21338
+ };
21339
+ this.writecb = null;
21340
+ this.writelen = 0;
21341
+ this.bufferedRequest = null;
21342
+ this.lastBufferedRequest = null;
21343
+ this.pendingcb = 0;
21344
+ this.prefinished = false;
21345
+ this.errorEmitted = false;
21346
+ this.bufferedRequestCount = 0;
21347
+ this.corkedRequestsFree = new CorkedRequest(this);
21348
+ }
21349
+ WritableState.prototype.getBuffer = function writableStateGetBuffer() {
21350
+ var current = this.bufferedRequest;
21351
+ var out = [];
21352
+ while (current) {
21353
+ out.push(current);
21354
+ current = current.next;
21355
+ }
21356
+ return out;
21357
+ };
21358
+ function Writable(options) {
21359
+ if (!(this instanceof Writable) && !(this instanceof Duplex)) return new Writable(options);
21360
+ this._writableState = new WritableState(options, this);
21361
+ this.writable = true;
21362
+ if (options) {
21363
+ if (typeof options.write === "function") this._write = options.write;
21364
+ if (typeof options.writev === "function") this._writev = options.writev;
21365
+ }
21366
+ EventEmitter.call(this);
21367
+ }
21368
+ Writable.prototype.pipe = function() {
21369
+ this.emit("error", /* @__PURE__ */ new Error("Cannot pipe, not readable"));
21370
+ };
21371
+ function writeAfterEnd(stream, cb) {
21372
+ var er = /* @__PURE__ */ new Error("write after end");
21373
+ stream.emit("error", er);
21374
+ nextTick(cb, er);
21375
+ }
21376
+ function validChunk(stream, state, chunk, cb) {
21377
+ var valid = true;
21378
+ var er = false;
21379
+ if (chunk === null) er = /* @__PURE__ */ new TypeError("May not write null values to stream");
21380
+ else if (!Buffer$1.isBuffer(chunk) && typeof chunk !== "string" && chunk !== void 0 && !state.objectMode) er = /* @__PURE__ */ new TypeError("Invalid non-string/buffer chunk");
21381
+ if (er) {
21382
+ stream.emit("error", er);
21383
+ nextTick(cb, er);
21384
+ valid = false;
21385
+ }
21386
+ return valid;
21387
+ }
21388
+ Writable.prototype.write = function(chunk, encoding, cb) {
21389
+ var state = this._writableState;
21390
+ var ret = false;
21391
+ if (typeof encoding === "function") {
21392
+ cb = encoding;
21393
+ encoding = null;
21394
+ }
21395
+ if (Buffer$1.isBuffer(chunk)) encoding = "buffer";
21396
+ else if (!encoding) encoding = state.defaultEncoding;
21397
+ if (typeof cb !== "function") cb = nop;
21398
+ if (state.ended) writeAfterEnd(this, cb);
21399
+ else if (validChunk(this, state, chunk, cb)) {
21400
+ state.pendingcb++;
21401
+ ret = writeOrBuffer(this, state, chunk, encoding, cb);
21402
+ }
21403
+ return ret;
21404
+ };
21405
+ Writable.prototype.cork = function() {
21406
+ var state = this._writableState;
21407
+ state.corked++;
21408
+ };
21409
+ Writable.prototype.uncork = function() {
21410
+ var state = this._writableState;
21411
+ if (state.corked) {
21412
+ state.corked--;
21413
+ if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
21414
+ }
21415
+ };
21416
+ Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
21417
+ if (typeof encoding === "string") encoding = encoding.toLowerCase();
21418
+ if (!([
21419
+ "hex",
21420
+ "utf8",
21421
+ "utf-8",
21422
+ "ascii",
21423
+ "binary",
21424
+ "base64",
21425
+ "ucs2",
21426
+ "ucs-2",
21427
+ "utf16le",
21428
+ "utf-16le",
21429
+ "raw"
21430
+ ].indexOf((encoding + "").toLowerCase()) > -1)) throw new TypeError("Unknown encoding: " + encoding);
21431
+ this._writableState.defaultEncoding = encoding;
21432
+ return this;
21433
+ };
21434
+ function decodeChunk(state, chunk, encoding) {
21435
+ if (!state.objectMode && state.decodeStrings !== false && typeof chunk === "string") chunk = Buffer$1.from(chunk, encoding);
21436
+ return chunk;
21437
+ }
21438
+ function writeOrBuffer(stream, state, chunk, encoding, cb) {
21439
+ chunk = decodeChunk(state, chunk, encoding);
21440
+ if (Buffer$1.isBuffer(chunk)) encoding = "buffer";
21441
+ var len = state.objectMode ? 1 : chunk.length;
21442
+ state.length += len;
21443
+ var ret = state.length < state.highWaterMark;
21444
+ if (!ret) state.needDrain = true;
21445
+ if (state.writing || state.corked) {
21446
+ var last = state.lastBufferedRequest;
21447
+ state.lastBufferedRequest = new WriteReq(chunk, encoding, cb);
21448
+ if (last) last.next = state.lastBufferedRequest;
21449
+ else state.bufferedRequest = state.lastBufferedRequest;
21450
+ state.bufferedRequestCount += 1;
21451
+ } else doWrite(stream, state, false, len, chunk, encoding, cb);
21452
+ return ret;
21453
+ }
21454
+ function doWrite(stream, state, writev, len, chunk, encoding, cb) {
21455
+ state.writelen = len;
21456
+ state.writecb = cb;
21457
+ state.writing = true;
21458
+ state.sync = true;
21459
+ if (writev) stream._writev(chunk, state.onwrite);
21460
+ else stream._write(chunk, encoding, state.onwrite);
21461
+ state.sync = false;
21462
+ }
21463
+ function onwriteError(stream, state, sync, er, cb) {
21464
+ --state.pendingcb;
21465
+ if (sync) nextTick(cb, er);
21466
+ else cb(er);
21467
+ stream._writableState.errorEmitted = true;
21468
+ stream.emit("error", er);
21469
+ }
21470
+ function onwriteStateUpdate(state) {
21471
+ state.writing = false;
21472
+ state.writecb = null;
21473
+ state.length -= state.writelen;
21474
+ state.writelen = 0;
21475
+ }
21476
+ function onwrite(stream, er) {
21477
+ var state = stream._writableState;
21478
+ var sync = state.sync;
21479
+ var cb = state.writecb;
21480
+ onwriteStateUpdate(state);
21481
+ if (er) onwriteError(stream, state, sync, er, cb);
21482
+ else {
21483
+ var finished = needFinish(state);
21484
+ if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(stream, state);
21485
+ if (sync) nextTick(afterWrite, stream, state, finished, cb);
21486
+ else afterWrite(stream, state, finished, cb);
21487
+ }
21488
+ }
21489
+ function afterWrite(stream, state, finished, cb) {
21490
+ if (!finished) onwriteDrain(stream, state);
21491
+ state.pendingcb--;
21492
+ cb();
21493
+ finishMaybe(stream, state);
21494
+ }
21495
+ function onwriteDrain(stream, state) {
21496
+ if (state.length === 0 && state.needDrain) {
21497
+ state.needDrain = false;
21498
+ stream.emit("drain");
21499
+ }
21500
+ }
21501
+ function clearBuffer(stream, state) {
21502
+ state.bufferProcessing = true;
21503
+ var entry = state.bufferedRequest;
21504
+ if (stream._writev && entry && entry.next) {
21505
+ var l = state.bufferedRequestCount;
21506
+ var buffer = new Array(l);
21507
+ var holder = state.corkedRequestsFree;
21508
+ holder.entry = entry;
21509
+ var count = 0;
21510
+ while (entry) {
21511
+ buffer[count] = entry;
21512
+ entry = entry.next;
21513
+ count += 1;
21514
+ }
21515
+ doWrite(stream, state, true, state.length, buffer, "", holder.finish);
21516
+ state.pendingcb++;
21517
+ state.lastBufferedRequest = null;
21518
+ if (holder.next) {
21519
+ state.corkedRequestsFree = holder.next;
21520
+ holder.next = null;
21521
+ } else state.corkedRequestsFree = new CorkedRequest(state);
21522
+ } else {
21523
+ while (entry) {
21524
+ var chunk = entry.chunk;
21525
+ var encoding = entry.encoding;
21526
+ var cb = entry.callback;
21527
+ doWrite(stream, state, false, state.objectMode ? 1 : chunk.length, chunk, encoding, cb);
21528
+ entry = entry.next;
21529
+ if (state.writing) break;
21530
+ }
21531
+ if (entry === null) state.lastBufferedRequest = null;
21532
+ }
21533
+ state.bufferedRequestCount = 0;
21534
+ state.bufferedRequest = entry;
21535
+ state.bufferProcessing = false;
21536
+ }
21537
+ Writable.prototype._write = function(chunk, encoding, cb) {
21538
+ cb(/* @__PURE__ */ new Error("not implemented"));
21539
+ };
21540
+ Writable.prototype._writev = null;
21541
+ Writable.prototype.end = function(chunk, encoding, cb) {
21542
+ var state = this._writableState;
21543
+ if (typeof chunk === "function") {
21544
+ cb = chunk;
21545
+ chunk = null;
21546
+ encoding = null;
21547
+ } else if (typeof encoding === "function") {
21548
+ cb = encoding;
21549
+ encoding = null;
21550
+ }
21551
+ if (chunk !== null && chunk !== void 0) this.write(chunk, encoding);
21552
+ if (state.corked) {
21553
+ state.corked = 1;
21554
+ this.uncork();
21555
+ }
21556
+ if (!state.ending && !state.finished) endWritable(this, state, cb);
21557
+ };
21558
+ function needFinish(state) {
21559
+ return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
21560
+ }
21561
+ function prefinish(stream, state) {
21562
+ if (!state.prefinished) {
21563
+ state.prefinished = true;
21564
+ stream.emit("prefinish");
21565
+ }
21566
+ }
21567
+ function finishMaybe(stream, state) {
21568
+ var need = needFinish(state);
21569
+ if (need) if (state.pendingcb === 0) {
21570
+ prefinish(stream, state);
21571
+ state.finished = true;
21572
+ stream.emit("finish");
21573
+ } else prefinish(stream, state);
21574
+ return need;
21575
+ }
21576
+ function endWritable(stream, state, cb) {
21577
+ state.ending = true;
21578
+ finishMaybe(stream, state);
21579
+ if (cb) if (state.finished) nextTick(cb);
21580
+ else stream.once("finish", cb);
21581
+ state.ended = true;
21582
+ stream.writable = false;
21583
+ }
21584
+ function CorkedRequest(state) {
21585
+ var _this = this;
21586
+ this.next = null;
21587
+ this.entry = null;
21588
+ this.finish = function(err) {
21589
+ var entry = _this.entry;
21590
+ _this.entry = null;
21591
+ while (entry) {
21592
+ var cb = entry.callback;
21593
+ state.pendingcb--;
21594
+ cb(err);
21595
+ entry = entry.next;
21596
+ }
21597
+ if (state.corkedRequestsFree) state.corkedRequestsFree.next = _this;
21598
+ else state.corkedRequestsFree = _this;
21599
+ };
21600
+ }
21601
+ //#endregion
21602
+ //#region \0polyfill-node._stream_duplex.js
21603
+ _polyfill_node__inherits_default(Duplex, Readable);
21604
+ var keys = Object.keys(Writable.prototype);
21605
+ for (var v = 0; v < keys.length; v++) {
21606
+ var method = keys[v];
21607
+ if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
21608
+ }
21609
+ function Duplex(options) {
21610
+ if (!(this instanceof Duplex)) return new Duplex(options);
21611
+ Readable.call(this, options);
21612
+ Writable.call(this, options);
21613
+ if (options && options.readable === false) this.readable = false;
21614
+ if (options && options.writable === false) this.writable = false;
21615
+ this.allowHalfOpen = true;
21616
+ if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
21617
+ this.once("end", onend);
21618
+ }
21619
+ function onend() {
21620
+ if (this.allowHalfOpen || this._writableState.ended) return;
21621
+ nextTick(onEndNT, this);
21622
+ }
21623
+ function onEndNT(self) {
21624
+ self.end();
21625
+ }
21626
+ //#endregion
21627
+ //#region src/util/output-type.ts
21628
+ /**
21629
+ * Output type definitions for document generation.
21630
+ *
21631
+ * This module defines the various output formats supported when generating
21632
+ * .docx files. These types correspond to fflate's output formats.
21633
+ *
21634
+ * @module
21635
+ */
21636
+ /**
21637
+ * Converts a Uint8Array to the specified output type.
21638
+ *
21639
+ * This is used by both the Packer and patchDocument to convert fflate's
21640
+ * raw Uint8Array output into the user's requested format.
21641
+ */
21642
+ const convertOutput = (data, type) => {
21643
+ switch (type) {
21644
+ case "nodebuffer": return Buffer$1.from(data);
21645
+ case "blob": return new Blob([data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength)], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" });
21646
+ case "arraybuffer": return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
21647
+ case "uint8array": return data;
21648
+ case "base64": return btoa((0, fflate.strFromU8)(data, true));
21649
+ case "string":
21650
+ case "text":
21651
+ case "binarystring": return (0, fflate.strFromU8)(data, true);
21652
+ case "array": return [...data];
21653
+ default: return data;
21654
+ }
21655
+ };
21656
+ //#endregion
21657
+ //#region src/file/fonts/obfuscate-ttf-to-odttf.ts
21658
+ /**
21659
+ * Font obfuscation module for embedding fonts in WordprocessingML documents.
21660
+ *
21661
+ * This module implements the OOXML font obfuscation algorithm used to embed
21662
+ * fonts in DOCX documents. Obfuscation is required by the OOXML specification
21663
+ * to prevent simple extraction of embedded font files.
21664
+ *
21665
+ * Reference: ECMA-376 Part 2, Section 11.1 (Font Embedding)
21666
+ *
21667
+ * @module
21668
+ */
21669
+ /** Start offset for obfuscation in the font file */
18336
21670
  const obfuscatedStartOffset = 0;
18337
21671
  /** End offset for obfuscation (first 32 bytes are obfuscated) */
18338
21672
  const obfuscatedEndOffset = 32;
@@ -18530,13 +21864,12 @@
18530
21864
  const footerFormattedViews = /* @__PURE__ */ new Map();
18531
21865
  const xmlifiedFileMapping = this.xmlifyFile(file, headerFormattedViews, footerFormattedViews, prettifyXml);
18532
21866
  const map = new Map(Object.entries(xmlifiedFileMapping));
18533
- for (const [, obj] of map) if (Array.isArray(obj)) for (const subFile of obj) files[subFile.path] = encodeUtf8(subFile.data);
18534
- else files[obj.path] = encodeUtf8(obj.data);
18535
- for (const subFile of overrides) files[subFile.path] = encodeUtf8(subFile.data);
18536
- for (const mediaData of file.Media.Array) if (mediaData.type !== "svg") files[`word/media/${mediaData.fileName}`] = [(0, undio.toUint8Array)(mediaData.data), { level: 0 }];
18537
- else {
21867
+ for (const [, obj] of map) if (Array.isArray(obj)) for (const subFile of obj) files[subFile.path] = (0, undio.textToUint8Array)(subFile.data);
21868
+ else files[obj.path] = (0, undio.textToUint8Array)(obj.data);
21869
+ for (const subFile of overrides) files[subFile.path] = (0, undio.textToUint8Array)(subFile.data);
21870
+ for (const mediaData of file.Media.Array) {
18538
21871
  files[`word/media/${mediaData.fileName}`] = [(0, undio.toUint8Array)(mediaData.data), { level: 0 }];
18539
- files[`word/media/${mediaData.fallback.fileName}`] = [(0, undio.toUint8Array)(mediaData.fallback.data), { level: 0 }];
21872
+ if (mediaData.type === "svg") files[`word/media/${mediaData.fallback.fileName}`] = [(0, undio.toUint8Array)(mediaData.fallback.data), { level: 0 }];
18540
21873
  }
18541
21874
  for (const { data: buffer, name, fontKey } of file.FontTable.fontOptionsWithKey) {
18542
21875
  const [nameWithoutExtension] = name.split(".");
@@ -18889,32 +22222,6 @@
18889
22222
  }
18890
22223
  };
18891
22224
  //#endregion
18892
- //#region \0@oxc-project+runtime@0.123.0/helpers/asyncToGenerator.js
18893
- function asyncGeneratorStep(n, t, e, r, o, a, c) {
18894
- try {
18895
- var i = n[a](c), u = i.value;
18896
- } catch (n) {
18897
- e(n);
18898
- return;
18899
- }
18900
- i.done ? t(u) : Promise.resolve(u).then(r, o);
18901
- }
18902
- function _asyncToGenerator(n) {
18903
- return function() {
18904
- var t = this, e = arguments;
18905
- return new Promise(function(r, o) {
18906
- var a = n.apply(t, e);
18907
- function _next(n) {
18908
- asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
18909
- }
18910
- function _throw(n) {
18911
- asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
18912
- }
18913
- _next(void 0);
18914
- });
18915
- };
18916
- }
18917
- //#endregion
18918
22225
  //#region src/export/packer/packer.ts
18919
22226
  /**
18920
22227
  * Packer module for exporting documents to various output formats.
@@ -18967,11 +22274,8 @@
18967
22274
  * @param overrides - Optional array of file overrides for custom XML content
18968
22275
  * @returns A promise resolving to the exported document in the specified format
18969
22276
  */
18970
- static pack(_x, _x2, _x3) {
18971
- var _this = this;
18972
- return _asyncToGenerator(function* (file, type, prettify, overrides = []) {
18973
- return convertOutput((0, fflate.zipSync)(_this.compiler.compile(file, convertPrettifyType(prettify), overrides), { level: 6 }), type);
18974
- }).apply(this, arguments);
22277
+ static async pack(file, type, prettify, overrides = []) {
22278
+ return convertOutput((0, fflate.zipSync)(this.compiler.compile(file, convertPrettifyType(prettify), overrides), { level: 6 }), type);
18975
22279
  }
18976
22280
  /**
18977
22281
  * Exports a document to a string representation.
@@ -19047,16 +22351,20 @@
19047
22351
  * ```
19048
22352
  */
19049
22353
  static toStream(file, prettify, overrides = []) {
19050
- const stream$1 = new stream.Readable({ read() {} });
22354
+ /* v8 ignore start */
22355
+ const stream = new Readable({ read() {} });
22356
+ /* v8 ignore stop */
19051
22357
  try {
19052
22358
  const files = this.compiler.compile(file, convertPrettifyType(prettify), overrides);
19053
22359
  const zip = new fflate.Zip((err, chunk, final) => {
22360
+ /* v8 ignore start */
19054
22361
  if (err) {
19055
- stream$1.destroy(err);
22362
+ stream.destroy(err);
19056
22363
  return;
19057
22364
  }
19058
- if (!stream$1.destroyed) stream$1.push(chunk);
19059
- if (final) stream$1.push(null);
22365
+ /* v8 ignore stop */
22366
+ if (!stream.destroyed) stream.push(chunk);
22367
+ if (final) stream.push(null);
19060
22368
  });
19061
22369
  for (const [name, data] of Object.entries(files)) {
19062
22370
  var _level;
@@ -19068,9 +22376,9 @@
19068
22376
  }
19069
22377
  zip.end();
19070
22378
  } catch (err) {
19071
- stream$1.destroy(err instanceof Error ? err : new Error(String(err)));
22379
+ stream.destroy(err instanceof Error ? err : new Error(String(err)));
19072
22380
  }
19073
- return stream$1;
22381
+ return stream;
19074
22382
  }
19075
22383
  };
19076
22384
  _defineProperty(Packer, "compiler", new Compiler());
@@ -19139,7 +22447,10 @@
19139
22447
  * // Adds xml:space="preserve" to maintain whitespace
19140
22448
  * ```
19141
22449
  */
19142
- const patchSpaceAttribute = (element) => _objectSpread2(_objectSpread2({}, element), {}, { attributes: { "xml:space": "preserve" } });
22450
+ const patchSpaceAttribute = (element) => ({
22451
+ ...element,
22452
+ attributes: { "xml:space": "preserve" }
22453
+ });
19143
22454
  /**
19144
22455
  * Retrieves first-level child elements by parent element name.
19145
22456
  *
@@ -19331,14 +22642,24 @@
19331
22642
  if (e.type === "element" && e.name === "w:t") {
19332
22643
  var _ref, _e$elements;
19333
22644
  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);
19334
- const newElements = splitText.map((t) => _objectSpread2(_objectSpread2(_objectSpread2({}, e), patchSpaceAttribute(e)), {}, { elements: createTextElementContents(t) }));
22645
+ const newElements = splitText.map((t) => ({
22646
+ ...e,
22647
+ ...patchSpaceAttribute(e),
22648
+ elements: createTextElementContents(t)
22649
+ }));
19335
22650
  if (splitText.length > 1) splitIndex = i;
19336
22651
  return newElements;
19337
22652
  } else return e;
19338
22653
  }).flat()) !== null && _runElement$elements$ !== void 0 ? _runElement$elements$ : [];
19339
22654
  return {
19340
- left: _objectSpread2(_objectSpread2({}, JSON.parse(JSON.stringify(runElement))), {}, { elements: splitElements.slice(0, splitIndex + 1) }),
19341
- right: _objectSpread2(_objectSpread2({}, JSON.parse(JSON.stringify(runElement))), {}, { elements: splitElements.slice(splitIndex + 1) })
22655
+ left: {
22656
+ ...JSON.parse(JSON.stringify(runElement)),
22657
+ elements: splitElements.slice(0, splitIndex + 1)
22658
+ },
22659
+ right: {
22660
+ ...JSON.parse(JSON.stringify(runElement)),
22661
+ elements: splitElements.slice(splitIndex + 1)
22662
+ }
19342
22663
  };
19343
22664
  };
19344
22665
  //#endregion
@@ -19598,9 +22919,15 @@
19598
22919
  const runElementNonTextualElements = runElementToBeReplaced.elements.filter((e) => e.type === "element" && e.name === "w:rPr");
19599
22920
  newRunElements = textJson.map((e) => {
19600
22921
  var _e$elements;
19601
- return _objectSpread2(_objectSpread2({}, e), {}, { elements: [...runElementNonTextualElements, ...(_e$elements = e.elements) !== null && _e$elements !== void 0 ? _e$elements : []] });
22922
+ return {
22923
+ ...e,
22924
+ elements: [...runElementNonTextualElements, ...(_e$elements = e.elements) !== null && _e$elements !== void 0 ? _e$elements : []]
22925
+ };
19602
22926
  });
19603
- patchedRightElement = _objectSpread2(_objectSpread2({}, right), {}, { elements: [...runElementNonTextualElements, ...right.elements] });
22927
+ patchedRightElement = {
22928
+ ...right,
22929
+ elements: [...runElementNonTextualElements, ...right.elements]
22930
+ };
19604
22931
  }
19605
22932
  paragraphElement.elements.splice(index, 1, left, ...newRunElements, patchedRightElement);
19606
22933
  break;
@@ -19686,69 +23013,70 @@
19686
23013
  *
19687
23014
  * @publicApi
19688
23015
  */
19689
- const patchDocument = function() {
19690
- var _ref = _asyncToGenerator(function* ({ outputType, data, patches, keepOriginalStyles, placeholderDelimiters = {
19691
- end: "}}",
19692
- start: "{{"
19693
- }, recursive = true }) {
19694
- const zipContent = (0, fflate.unzipSync)((0, undio.toUint8Array)(data));
19695
- const contexts = /* @__PURE__ */ new Map();
19696
- const file = { Media: new Media() };
19697
- const map = /* @__PURE__ */ new Map();
19698
- const imageRelationshipAdditions = [];
19699
- const hyperlinkRelationshipAdditions = [];
19700
- let hasMedia = false;
19701
- const binaryContentMap = /* @__PURE__ */ new Map();
19702
- for (const [key, value] of Object.entries(zipContent)) {
19703
- const startBytes = value.slice(0, 2);
19704
- if (compareByteArrays(startBytes, UTF16LE) || compareByteArrays(startBytes, UTF16BE)) {
19705
- binaryContentMap.set(key, value);
19706
- continue;
19707
- }
19708
- if (!key.endsWith(".xml") && !key.endsWith(".rels")) {
19709
- binaryContentMap.set(key, value);
19710
- continue;
19711
- }
19712
- const json = toJson((0, fflate.strFromU8)(value));
19713
- if (key === "word/document.xml") {
19714
- var _json$elements;
19715
- const document = (_json$elements = json.elements) === null || _json$elements === void 0 ? void 0 : _json$elements.find((i) => i.name === "w:document");
19716
- if (document && document.attributes) {
19717
- for (const ns of [
19718
- "mc",
19719
- "wp",
19720
- "r",
19721
- "w15",
19722
- "m"
19723
- ]) document.attributes[`xmlns:${ns}`] = DocumentAttributeNamespaces[ns];
19724
- document.attributes["mc:Ignorable"] = `${document.attributes["mc:Ignorable"] || ""} w15`.trim();
19725
- }
23016
+ const patchDocument = async ({ outputType, data, patches, keepOriginalStyles, placeholderDelimiters = {
23017
+ end: "}}",
23018
+ start: "{{"
23019
+ }, recursive = true }) => {
23020
+ const zipContent = (0, fflate.unzipSync)((0, undio.toUint8Array)(data));
23021
+ const contexts = /* @__PURE__ */ new Map();
23022
+ const file = { Media: new Media() };
23023
+ const map = /* @__PURE__ */ new Map();
23024
+ const imageRelationshipAdditions = [];
23025
+ const hyperlinkRelationshipAdditions = [];
23026
+ let hasMedia = false;
23027
+ const binaryContentMap = /* @__PURE__ */ new Map();
23028
+ for (const [key, value] of Object.entries(zipContent)) {
23029
+ const startBytes = value.slice(0, 2);
23030
+ if (compareByteArrays(startBytes, UTF16LE) || compareByteArrays(startBytes, UTF16BE)) {
23031
+ binaryContentMap.set(key, value);
23032
+ continue;
23033
+ }
23034
+ if (!key.endsWith(".xml") && !key.endsWith(".rels")) {
23035
+ binaryContentMap.set(key, value);
23036
+ continue;
23037
+ }
23038
+ const json = toJson((0, fflate.strFromU8)(value));
23039
+ if (key === "word/document.xml") {
23040
+ var _json$elements;
23041
+ const document = (_json$elements = json.elements) === null || _json$elements === void 0 ? void 0 : _json$elements.find((i) => i.name === "w:document");
23042
+ if (document && document.attributes) {
23043
+ for (const ns of [
23044
+ "mc",
23045
+ "wp",
23046
+ "r",
23047
+ "w15",
23048
+ "m"
23049
+ ]) document.attributes[`xmlns:${ns}`] = DocumentAttributeNamespaces[ns];
23050
+ document.attributes["mc:Ignorable"] = `${document.attributes["mc:Ignorable"] || ""} w15`.trim();
19726
23051
  }
19727
- if (key.startsWith("word/") && !key.endsWith(".xml.rels")) {
19728
- const context = {
19729
- file,
19730
- stack: [],
19731
- viewWrapper: { Relationships: { addRelationship: (linkId, _, target, __) => {
19732
- hyperlinkRelationshipAdditions.push({
19733
- hyperlink: {
19734
- id: linkId,
19735
- link: target
19736
- },
19737
- key
19738
- });
19739
- } } }
19740
- };
19741
- contexts.set(key, context);
19742
- 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.");
19743
- const { start, end } = placeholderDelimiters;
19744
- for (const [patchKey, patchValue] of Object.entries(patches)) {
19745
- const patchText = `${start}${patchKey}${end}`;
19746
- while (true) {
19747
- const { didFindOccurrence } = replacer({
19748
- context,
19749
- json,
19750
- keepOriginalStyles,
19751
- patch: _objectSpread2(_objectSpread2({}, patchValue), {}, { children: patchValue.children.map((element) => {
23052
+ }
23053
+ if (key.startsWith("word/") && !key.endsWith(".xml.rels")) {
23054
+ const context = {
23055
+ file,
23056
+ stack: [],
23057
+ viewWrapper: { Relationships: { addRelationship: (linkId, _, target, __) => {
23058
+ hyperlinkRelationshipAdditions.push({
23059
+ hyperlink: {
23060
+ id: linkId,
23061
+ link: target
23062
+ },
23063
+ key
23064
+ });
23065
+ } } }
23066
+ };
23067
+ contexts.set(key, context);
23068
+ 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.");
23069
+ const { start, end } = placeholderDelimiters;
23070
+ for (const [patchKey, patchValue] of Object.entries(patches)) {
23071
+ const patchText = `${start}${patchKey}${end}`;
23072
+ while (true) {
23073
+ const { didFindOccurrence } = replacer({
23074
+ context,
23075
+ json,
23076
+ keepOriginalStyles,
23077
+ patch: {
23078
+ ...patchValue,
23079
+ children: patchValue.children.map((element) => {
19752
23080
  if (element instanceof ExternalHyperlink) {
19753
23081
  const concreteHyperlink = new ConcreteHyperlink(element.options.children, uniqueId());
19754
23082
  hyperlinkRelationshipAdditions.push({
@@ -19760,63 +23088,60 @@
19760
23088
  });
19761
23089
  return concreteHyperlink;
19762
23090
  } else return element;
19763
- }) }),
19764
- patchText
19765
- });
19766
- if (!recursive || !didFindOccurrence) break;
19767
- }
19768
- }
19769
- const mediaDatas = imageReplacer.getMediaData(JSON.stringify(json), context.file.Media);
19770
- if (mediaDatas.length > 0) {
19771
- hasMedia = true;
19772
- imageRelationshipAdditions.push({
19773
- key,
19774
- mediaDatas
23091
+ })
23092
+ },
23093
+ patchText
19775
23094
  });
23095
+ if (!recursive || !didFindOccurrence) break;
19776
23096
  }
19777
23097
  }
19778
- map.set(key, json);
19779
- }
19780
- for (const { key, mediaDatas } of imageRelationshipAdditions) {
19781
- var _map$get;
19782
- const relationshipKey = `word/_rels/${key.split("/").pop()}.rels`;
19783
- const relationshipsJson = (_map$get = map.get(relationshipKey)) !== null && _map$get !== void 0 ? _map$get : createRelationshipFile();
19784
- map.set(relationshipKey, relationshipsJson);
19785
- const index = getNextRelationshipIndex(relationshipsJson);
19786
- const newJson = imageReplacer.replace(JSON.stringify(map.get(key)), mediaDatas, index);
19787
- map.set(key, JSON.parse(newJson));
19788
- for (let i = 0; i < mediaDatas.length; i++) {
19789
- const { fileName } = mediaDatas[i];
19790
- appendRelationship(relationshipsJson, index + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `media/${fileName}`);
23098
+ const mediaDatas = imageReplacer.getMediaData(JSON.stringify(json), context.file.Media);
23099
+ if (mediaDatas.length > 0) {
23100
+ hasMedia = true;
23101
+ imageRelationshipAdditions.push({
23102
+ key,
23103
+ mediaDatas
23104
+ });
19791
23105
  }
19792
23106
  }
19793
- for (const { key, hyperlink } of hyperlinkRelationshipAdditions) {
19794
- var _map$get2;
19795
- const relationshipKey = `word/_rels/${key.split("/").pop()}.rels`;
19796
- const relationshipsJson = (_map$get2 = map.get(relationshipKey)) !== null && _map$get2 !== void 0 ? _map$get2 : createRelationshipFile();
19797
- map.set(relationshipKey, relationshipsJson);
19798
- appendRelationship(relationshipsJson, hyperlink.id, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", hyperlink.link, TargetModeType.EXTERNAL);
19799
- }
19800
- if (hasMedia) {
19801
- const contentTypesJson = map.get("[Content_Types].xml");
19802
- if (!contentTypesJson) throw new Error("Could not find content types file");
19803
- appendContentType(contentTypesJson, "image/png", "png");
19804
- appendContentType(contentTypesJson, "image/jpeg", "jpeg");
19805
- appendContentType(contentTypesJson, "image/jpeg", "jpg");
19806
- appendContentType(contentTypesJson, "image/bmp", "bmp");
19807
- appendContentType(contentTypesJson, "image/gif", "gif");
19808
- appendContentType(contentTypesJson, "image/svg+xml", "svg");
23107
+ map.set(key, json);
23108
+ }
23109
+ for (const { key, mediaDatas } of imageRelationshipAdditions) {
23110
+ var _map$get;
23111
+ const relationshipKey = `word/_rels/${key.split("/").pop()}.rels`;
23112
+ const relationshipsJson = (_map$get = map.get(relationshipKey)) !== null && _map$get !== void 0 ? _map$get : createRelationshipFile();
23113
+ map.set(relationshipKey, relationshipsJson);
23114
+ const index = getNextRelationshipIndex(relationshipsJson);
23115
+ const newJson = imageReplacer.replace(JSON.stringify(map.get(key)), mediaDatas, index);
23116
+ map.set(key, JSON.parse(newJson));
23117
+ for (let i = 0; i < mediaDatas.length; i++) {
23118
+ const { fileName } = mediaDatas[i];
23119
+ appendRelationship(relationshipsJson, index + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `media/${fileName}`);
19809
23120
  }
19810
- const files = {};
19811
- for (const [key, value] of map) files[key] = (0, undio.textToUint8Array)(toXml(value));
19812
- for (const [key, value] of binaryContentMap) files[key] = value;
19813
- for (const { data: mediaData, fileName } of file.Media.Array) files[`word/media/${fileName}`] = mediaData instanceof Uint8Array ? mediaData : new Uint8Array(mediaData);
19814
- return convertOutput((0, fflate.zipSync)(files, { level: 6 }), outputType);
19815
- });
19816
- return function patchDocument(_x) {
19817
- return _ref.apply(this, arguments);
19818
- };
19819
- }();
23121
+ }
23122
+ for (const { key, hyperlink } of hyperlinkRelationshipAdditions) {
23123
+ var _map$get2;
23124
+ const relationshipKey = `word/_rels/${key.split("/").pop()}.rels`;
23125
+ const relationshipsJson = (_map$get2 = map.get(relationshipKey)) !== null && _map$get2 !== void 0 ? _map$get2 : createRelationshipFile();
23126
+ map.set(relationshipKey, relationshipsJson);
23127
+ appendRelationship(relationshipsJson, hyperlink.id, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", hyperlink.link, TargetModeType.EXTERNAL);
23128
+ }
23129
+ if (hasMedia) {
23130
+ const contentTypesJson = map.get("[Content_Types].xml");
23131
+ if (!contentTypesJson) throw new Error("Could not find content types file");
23132
+ appendContentType(contentTypesJson, "image/png", "png");
23133
+ appendContentType(contentTypesJson, "image/jpeg", "jpeg");
23134
+ appendContentType(contentTypesJson, "image/jpeg", "jpg");
23135
+ appendContentType(contentTypesJson, "image/bmp", "bmp");
23136
+ appendContentType(contentTypesJson, "image/gif", "gif");
23137
+ appendContentType(contentTypesJson, "image/svg+xml", "svg");
23138
+ }
23139
+ const files = {};
23140
+ for (const [key, value] of map) files[key] = (0, undio.textToUint8Array)(toXml(value));
23141
+ for (const [key, value] of binaryContentMap) files[key] = value;
23142
+ for (const { data: mediaData, fileName } of file.Media.Array) files[`word/media/${fileName}`] = mediaData instanceof Uint8Array ? mediaData : new Uint8Array(mediaData);
23143
+ return convertOutput((0, fflate.zipSync)(files, { level: 6 }), outputType);
23144
+ };
19820
23145
  const toXml = (jsonObj) => {
19821
23146
  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;") });
19822
23147
  };
@@ -19865,20 +23190,15 @@
19865
23190
  * });
19866
23191
  * ```
19867
23192
  */
19868
- const patchDetector = function() {
19869
- var _ref = _asyncToGenerator(function* ({ data }) {
19870
- const zipContent = (0, fflate.unzipSync)((0, undio.toUint8Array)(data));
19871
- const patches = /* @__PURE__ */ new Set();
19872
- for (const [key, value] of Object.entries(zipContent)) {
19873
- if (!key.endsWith(".xml") && !key.endsWith(".rels")) continue;
19874
- if (key.startsWith("word/") && !key.endsWith(".xml.rels")) traverse(toJson((0, fflate.strFromU8)(value))).forEach((p) => findPatchKeys(p.text).forEach((patch) => patches.add(patch)));
19875
- }
19876
- return [...patches];
19877
- });
19878
- return function patchDetector(_x) {
19879
- return _ref.apply(this, arguments);
19880
- };
19881
- }();
23193
+ const patchDetector = async ({ data }) => {
23194
+ const zipContent = (0, fflate.unzipSync)((0, undio.toUint8Array)(data));
23195
+ const patches = /* @__PURE__ */ new Set();
23196
+ for (const [key, value] of Object.entries(zipContent)) {
23197
+ if (!key.endsWith(".xml") && !key.endsWith(".rels")) continue;
23198
+ if (key.startsWith("word/") && !key.endsWith(".xml.rels")) traverse(toJson((0, fflate.strFromU8)(value))).forEach((p) => findPatchKeys(p.text).forEach((patch) => patches.add(patch)));
23199
+ }
23200
+ return [...patches];
23201
+ };
19882
23202
  /**
19883
23203
  * Extracts placeholder keys from text using regex pattern.
19884
23204
  *
@@ -19887,8 +23207,7 @@
19887
23207
  */
19888
23208
  const findPatchKeys = (text) => {
19889
23209
  var _text$match;
19890
- const pattern = /* @__PURE__ */ new RegExp("(?<=\\{\\{).+?(?=\\}\\})", "gs");
19891
- return (_text$match = text.match(pattern)) !== null && _text$match !== void 0 ? _text$match : [];
23210
+ return (_text$match = text.match(/(?<=\{\{).+?(?=\}\})/gs)) !== null && _text$match !== void 0 ? _text$match : [];
19892
23211
  };
19893
23212
  //#endregion
19894
23213
  exports.AbstractNumbering = AbstractNumbering;
@@ -20093,6 +23412,8 @@
20093
23412
  exports.TextWrappingType = TextWrappingType;
20094
23413
  exports.Textbox = Textbox;
20095
23414
  exports.ThematicBreak = ThematicBreak;
23415
+ exports.ThemeColor = ThemeColor;
23416
+ exports.ThemeFont = ThemeFont;
20096
23417
  exports.UnderlineType = UnderlineType;
20097
23418
  exports.VerticalAlign = VerticalAlign;
20098
23419
  exports.VerticalAlignSection = VerticalAlignSection;
@@ -20171,7 +23492,6 @@
20171
23492
  exports.decimalNumber = decimalNumber;
20172
23493
  exports.docPropertiesUniqueNumericIdGen = docPropertiesUniqueNumericIdGen;
20173
23494
  exports.eighthPointMeasureValue = eighthPointMeasureValue;
20174
- exports.encodeUtf8 = encodeUtf8;
20175
23495
  exports.hashedId = hashedId;
20176
23496
  exports.hexColorValue = hexColorValue;
20177
23497
  exports.hpsMeasureValue = hpsMeasureValue;