@silurus/ooxml 0.75.5 → 0.76.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +66 -28
  2. package/dist/bounded-raw-part-cache-C6ro6Ezf.js +254 -0
  3. package/dist/{find-cursor-Dc5iM6s7.js → canvas-viewer-mechanics-CwVSOYke.js} +192 -64
  4. package/dist/{document-pull-client-BcNYhoAG.js → document-pull-client-AAnwzlig.js} +3625 -3601
  5. package/dist/docx-CCksIXd5.js +1301 -0
  6. package/dist/docx.mjs +4 -6
  7. package/dist/docx_parser_bg.wasm +0 -0
  8. package/dist/index.mjs +3 -3
  9. package/dist/{line-distribute-B8sqT8kC.js → line-distribute-C1r2zvji.js} +141 -141
  10. package/dist/{line-metrics-D9gqQWHl.js → line-metrics-BdCACYlq.js} +4026 -1170
  11. package/dist/math.mjs +1 -1
  12. package/dist/node.mjs +779 -465
  13. package/dist/pptx-CKAk5e-J.js +1735 -0
  14. package/dist/pptx.mjs +5 -7
  15. package/dist/pptx_parser_bg.wasm +0 -0
  16. package/dist/{render-CalC7GX4.js → render-CLcpSi0m.js} +11 -18
  17. package/dist/render-worker-host-B8HAb_sK.js +27 -0
  18. package/dist/render-worker-host-Bkf1jUcW.js +27 -0
  19. package/dist/render-worker-host-CKOmXdyr.js +27 -0
  20. package/dist/resource-measurement-E_S_iau4.js +119 -0
  21. package/dist/session-B4Y54cbT.js +730 -0
  22. package/dist/{renderer-B9R6F_QY.js → slide-pull-client-WCuYCjio.js} +973 -820
  23. package/dist/types/docx.d.ts +1181 -3994
  24. package/dist/types/index.d.ts +2733 -8171
  25. package/dist/types/math.d.ts +8 -33
  26. package/dist/types/node.d.ts +1852 -4433
  27. package/dist/types/pptx.d.ts +1030 -3678
  28. package/dist/types/xlsx.d.ts +1291 -3262
  29. package/dist/worksheet-pull-client-YzjJMOns.js +455 -0
  30. package/dist/xlsx-BBmmZNQn.js +6362 -0
  31. package/dist/xlsx.mjs +5 -7
  32. package/dist/xlsx_parser_bg.wasm +0 -0
  33. package/package.json +14 -7
  34. package/dist/bounded-raw-part-cache-BTfZD_Sz.js +0 -1248
  35. package/dist/docx-DjF8FgoP.js +0 -1274
  36. package/dist/duotone-bitmap-by-path-CWsSJkJu.js +0 -28
  37. package/dist/hyperlink-D85FexTa.js +0 -27
  38. package/dist/pptx-C17xP8AV.js +0 -1705
  39. package/dist/pptx-Dl8tOSmP.js +0 -822
  40. package/dist/preload-BEouWnlI.js +0 -132
  41. package/dist/render-worker-host-BG3a7brz.js +0 -27
  42. package/dist/render-worker-host-CsB-dPJv.js +0 -27
  43. package/dist/render-worker-host-Cyv5Hkbh.js +0 -27
  44. package/dist/resource-measurement-6aReN3K0.js +0 -93
  45. package/dist/slide-pull-client-D_T0AIoX.js +0 -175
  46. package/dist/svg-image-by-path-C1M3N2pT.js +0 -1623
  47. package/dist/worksheet-pull-worker-DCei8u-4.js +0 -347
  48. package/dist/xlsx-BaH9irS0.js +0 -5515
  49. /package/dist/{highlight-rect-cCvVU-MW.js → highlight-rect-CAkCWJ37.js} +0 -0
  50. /package/dist/{mathjax-Dqo857oC.js → mathjax-CMjda8Ip.js} +0 -0
  51. /package/dist/{transfer-3QEJrsJa.js → transfer-DCu4c2BL.js} +0 -0
  52. /package/dist/{visible-index-CKvgpUrf.js → visible-index-CgyJLAS_.js} +0 -0
@@ -1,4 +1,4 @@
1
- import { M as e } from "./bounded-raw-part-cache-BTfZD_Sz.js";
1
+ import { mn as e } from "./line-metrics-BdCACYlq.js";
2
2
  //#region packages/core/src/errors/cfb-sniff.ts
3
3
  var t = [
4
4
  208,
@@ -86,20 +86,20 @@ var h = [
86
86
  177,
87
87
  26,
88
88
  225
89
- ], g = 4294967290, _ = 4294967294, v = 512, y = 128, b = 4e6, ee = 8e6, te = 65536, ne = 1e6;
90
- function x(e, t) {
91
- if (e.length < v) return null;
89
+ ], g = 4294967290, _ = 4294967294, ee = 512, v = 128, y = 4e6, te = 8e6, b = 65536, x = 1e6;
90
+ function S(e, t) {
91
+ if (e.length < ee) return null;
92
92
  for (let t = 0; t < h.length; t++) if (e[t] !== h[t]) return null;
93
- let n = new DataView(e.buffer, e.byteOffset, e.byteLength), r = S(n);
93
+ let n = new DataView(e.buffer, e.byteOffset, e.byteLength), r = ne(n);
94
94
  if (r === null) return null;
95
- let i = re(n, e.length, r);
95
+ let i = T(n, e.length, r);
96
96
  if (i === null) return null;
97
- let a = E(n, e.length, r, i, t);
97
+ let a = re(n, e.length, r, i, t);
98
98
  if (a === null || a.target === null) return null;
99
99
  let { target: o, root: s } = a;
100
- return o.size === 0 ? new Uint8Array() : o.size < r.miniStreamCutoff ? s === null ? null : ie(n, e.length, r, i, s, o) : O(n, e.length, r, i, o.startSector, o.size);
100
+ return o.size === 0 ? new Uint8Array() : o.size < r.miniStreamCutoff ? s === null ? null : O(n, e.length, r, i, s, o) : D(n, e.length, r, i, o.startSector, o.size);
101
101
  }
102
- function S(e) {
102
+ function ne(e) {
103
103
  let t = e.getUint16(30, !0);
104
104
  if (t !== 9 && t !== 12) return null;
105
105
  let n = e.getUint16(32, !0);
@@ -119,7 +119,7 @@ function C(e, t) {
119
119
  function w(e) {
120
120
  return e >= 0 && e <= g;
121
121
  }
122
- function re(e, t, n) {
122
+ function T(e, t, n) {
123
123
  let { sectorSize: r } = n, i = [];
124
124
  for (let t = 0; t < 109; t++) {
125
125
  let n = e.getUint32(76 + t * 4, !0);
@@ -127,7 +127,7 @@ function re(e, t, n) {
127
127
  }
128
128
  let a = r / 4 - 1, o = n.firstDifatSector, s = /* @__PURE__ */ new Set(), c = 0;
129
129
  for (; w(o);) {
130
- if (c++ > ne) return null;
130
+ if (c++ > x) return null;
131
131
  if (s.has(o)) break;
132
132
  s.add(o);
133
133
  let n = C(o, r);
@@ -140,7 +140,7 @@ function re(e, t, n) {
140
140
  }
141
141
  return i;
142
142
  }
143
- function T(e, t, n, r, i) {
143
+ function E(e, t, n, r, i) {
144
144
  let a = n / 4, o = Math.floor(i / a), s = i % a;
145
145
  if (o >= r.length) return null;
146
146
  let c = r[o];
@@ -148,22 +148,22 @@ function T(e, t, n, r, i) {
148
148
  let l = C(c, n) + s * 4;
149
149
  return l < 0 || l + 4 > t ? null : e.getUint32(l, !0);
150
150
  }
151
- function E(e, t, n, r, i) {
152
- let { sectorSize: a } = n, o = Math.floor(a / y);
151
+ function re(e, t, n, r, i) {
152
+ let { sectorSize: a } = n, o = Math.floor(a / v);
153
153
  if (o < 1) return null;
154
154
  let s = null, c = null, l = /* @__PURE__ */ new Set(), u = n.firstDirSector, d = 0, f = 0;
155
155
  for (; w(u);) {
156
- if (d++ > b) return null;
156
+ if (d++ > y) return null;
157
157
  if (l.has(u)) break;
158
158
  l.add(u);
159
159
  let n = C(u, a);
160
160
  if (n < 0 || n + a > t) return null;
161
161
  for (let t = 0; t < o; t++) {
162
- if (f++ > te) return {
162
+ if (f++ > b) return {
163
163
  target: s,
164
164
  root: c
165
165
  };
166
- let r = n + t * y, a = e.getUint8(r + 66);
166
+ let r = n + t * v, a = e.getUint8(r + 66);
167
167
  if (a === 0) continue;
168
168
  let o = e.getUint32(r + 116, !0), l = e.getUint32(r + 120, !0);
169
169
  if (a === 5) {
@@ -173,12 +173,12 @@ function E(e, t, n, r, i) {
173
173
  };
174
174
  continue;
175
175
  }
176
- D(e, r) === i && (s = {
176
+ ie(e, r) === i && (s = {
177
177
  startSector: o,
178
178
  size: l
179
179
  });
180
180
  }
181
- let p = T(e, t, a, r, u);
181
+ let p = E(e, t, a, r, u);
182
182
  if (p === null) break;
183
183
  u = p;
184
184
  }
@@ -187,7 +187,7 @@ function E(e, t, n, r, i) {
187
187
  root: c
188
188
  };
189
189
  }
190
- function D(e, t) {
190
+ function ie(e, t) {
191
191
  let n = e.getUint16(t + 64, !0);
192
192
  if (n < 2 || n > 64) return "";
193
193
  let r = n / 2 - 1, i = "";
@@ -198,27 +198,27 @@ function D(e, t) {
198
198
  }
199
199
  return i;
200
200
  }
201
- function O(e, t, n, r, i, a) {
201
+ function D(e, t, n, r, i, a) {
202
202
  let { sectorSize: o } = n, s = new Uint8Array(a), c = 0, l = i, u = /* @__PURE__ */ new Set(), d = 0;
203
203
  for (; w(l) && c < a;) {
204
- if (d++ > b || u.has(l)) return null;
204
+ if (d++ > y || u.has(l)) return null;
205
205
  u.add(l);
206
206
  let n = C(l, o);
207
207
  if (n < 0 || n + o > t) return null;
208
208
  let i = Math.min(o, a - c);
209
209
  s.set(new Uint8Array(e.buffer, e.byteOffset + n, i), c), c += i;
210
- let f = T(e, t, o, r, l);
210
+ let f = E(e, t, o, r, l);
211
211
  if (f === null) return null;
212
212
  l = f;
213
213
  }
214
214
  return c === a ? s : null;
215
215
  }
216
- function ie(e, t, n, r, i, a) {
217
- let { sectorSize: o, miniSectorSize: s } = n, c = O(e, t, n, r, i.startSector, i.size);
216
+ function O(e, t, n, r, i, a) {
217
+ let { sectorSize: o, miniSectorSize: s } = n, c = D(e, t, n, r, i.startSector, i.size);
218
218
  if (c === null) return null;
219
219
  let l = new Uint8Array(a.size), u = 0, d = a.startSector, f = /* @__PURE__ */ new Set(), p = 0, m = o / 4;
220
220
  for (; w(d) && u < a.size;) {
221
- if (p++ > ee || f.has(d)) return null;
221
+ if (p++ > te || f.has(d)) return null;
222
222
  f.add(d);
223
223
  let i = d * s;
224
224
  if (i < 0 || i + s > c.length) return null;
@@ -235,7 +235,7 @@ function ae(e, t, n, r, i, a) {
235
235
  for (let n = 0; n < s; n++) {
236
236
  if (!w(l) || u.has(l)) return null;
237
237
  u.add(l);
238
- let n = T(e, t, o, r, l);
238
+ let n = E(e, t, o, r, l);
239
239
  if (n === null) return null;
240
240
  l = n;
241
241
  }
@@ -473,9 +473,9 @@ async function fe(e, t, n) {
473
473
  }
474
474
  //#endregion
475
475
  //#region packages/core/src/crypto/decrypt-ooxml.ts
476
- var pe = "EncryptionInfo", me = "EncryptedPackage";
477
- async function he(e, t) {
478
- let n = x(e, pe), r = x(e, me);
476
+ var Y = "EncryptionInfo", pe = "EncryptedPackage";
477
+ async function me(e, t) {
478
+ let n = S(e, Y), r = S(e, pe);
479
479
  if (n === null || r === null) return {
480
480
  ok: !1,
481
481
  reason: "corrupt"
@@ -502,7 +502,7 @@ async function he(e, t) {
502
502
  }
503
503
  //#endregion
504
504
  //#region packages/core/src/errors/cfb-guard.ts
505
- function ge(t) {
505
+ function he(t) {
506
506
  let n = l(t instanceof Uint8Array ? t : new Uint8Array(t));
507
507
  if (n !== null) switch (n) {
508
508
  case "encrypted": throw new e("encrypted", "This file is password-protected (MS-OFFCRYPTO). Pass LoadOptions.password to decrypt it.");
@@ -511,12 +511,12 @@ function ge(t) {
511
511
  default: throw new e("not-ooxml", "This file is an OLE2/Compound File container of an unrecognised kind, not an OOXML (ZIP) document.");
512
512
  }
513
513
  }
514
- async function _e(t, n) {
514
+ async function ge(t, n) {
515
515
  let r = t instanceof Uint8Array ? t : new Uint8Array(t), i = l(r);
516
516
  if (i === null) return r;
517
517
  if (i === "encrypted") {
518
518
  if (n === void 0) throw new e("encrypted", "This file is password-protected (MS-OFFCRYPTO). Pass LoadOptions.password to decrypt it.");
519
- let t = await he(r, n);
519
+ let t = await me(r, n);
520
520
  if (t.ok) return t.data;
521
521
  switch (t.reason) {
522
522
  case "invalid-password": throw new e("invalid-password", "The supplied password is incorrect.");
@@ -525,14 +525,14 @@ async function _e(t, n) {
525
525
  default: throw t.reason, new e("not-ooxml", "This encrypted file could not be decrypted.");
526
526
  }
527
527
  }
528
- return ge(r), r;
528
+ return he(r), r;
529
529
  }
530
- function ve(e) {
530
+ function _e(e) {
531
531
  return e.byteOffset === 0 && e.byteLength === e.buffer.byteLength && e.buffer instanceof ArrayBuffer ? e.buffer : e.slice().buffer;
532
532
  }
533
533
  //#endregion
534
534
  //#region packages/core/src/autoResize.ts
535
- function ye(e, t, n = {}) {
535
+ function ve(e, t, n = {}) {
536
536
  let r = n.pauseWhenHidden ?? !0, i = null, a = 0, o = 0, s = null, c = !1, l = !1, u = () => {
537
537
  if (!l && !(r && typeof document < "u" && document.hidden)) {
538
538
  if (s) {
@@ -569,11 +569,11 @@ function ye(e, t, n = {}) {
569
569
  }
570
570
  //#endregion
571
571
  //#region packages/core/src/worker/bridge.ts
572
- function Y() {
572
+ function X() {
573
573
  let e = /* @__PURE__ */ Error("worker request aborted");
574
574
  return e.name = "AbortError", e;
575
575
  }
576
- var be = class {
576
+ var ye = class {
577
577
  _worker;
578
578
  _opts;
579
579
  _pending = /* @__PURE__ */ new Map();
@@ -630,7 +630,7 @@ var be = class {
630
630
  return;
631
631
  }
632
632
  if (a?.aborted) {
633
- o("abort"), c(Y());
633
+ o("abort"), c(X());
634
634
  return;
635
635
  }
636
636
  let l, u;
@@ -646,7 +646,7 @@ var be = class {
646
646
  e && (this._pending.delete(r), e.onOrphanedResponse && this._orphaned.set(r, e.onOrphanedResponse), e.cleanup(), o("timeout"), e.reject(/* @__PURE__ */ Error(`worker request timed out after ${i}ms`)));
647
647
  }, i)), a && (u = () => {
648
648
  let e = this._pending.get(r);
649
- e && (this._pending.delete(r), e.onOrphanedResponse && this._orphaned.set(r, e.onOrphanedResponse), e.cleanup(), o("abort"), e.reject(Y()));
649
+ e && (this._pending.delete(r), e.onOrphanedResponse && this._orphaned.set(r, e.onOrphanedResponse), e.cleanup(), o("abort"), e.reject(X()));
650
650
  }, a.addEventListener("abort", u));
651
651
  try {
652
652
  this._worker.postMessage(e(r), t);
@@ -687,7 +687,7 @@ var be = class {
687
687
  };
688
688
  //#endregion
689
689
  //#region packages/core/src/worker/rejected-load.ts
690
- function xe(e, t) {
690
+ function be(e, t) {
691
691
  if (t) try {
692
692
  t();
693
693
  return;
@@ -698,17 +698,17 @@ function xe(e, t) {
698
698
  }
699
699
  //#endregion
700
700
  //#region packages/core/src/interaction/zoom.ts
701
- var Se = .01;
702
- function Ce(e, t) {
703
- return e * Math.exp(-t * Se);
701
+ var xe = .01;
702
+ function Se(e, t) {
703
+ return e * Math.exp(-t * xe);
704
704
  }
705
- function we(e, t, n, r, i) {
705
+ function Ce(e, t, n, r, i) {
706
706
  let a = n > 0 ? r / n : 1, o = (e + t) * a - t, s = i.maxScroll > 0 ? i.maxScroll : 0;
707
707
  return o < 0 ? 0 : o > s ? s : o;
708
708
  }
709
709
  //#endregion
710
710
  //#region packages/core/src/interaction/zoomable.ts
711
- var X = Object.freeze([
711
+ var Z = Object.freeze([
712
712
  .25,
713
713
  .33,
714
714
  .5,
@@ -724,22 +724,22 @@ var X = Object.freeze([
724
724
  2.5,
725
725
  3,
726
726
  4
727
- ]), Z = .005;
728
- function Te(e) {
729
- for (let t of X) if (t > e + Z) return t;
730
- return X[X.length - 1];
727
+ ]), Q = .005;
728
+ function we(e) {
729
+ for (let t of Z) if (t > e + Q) return t;
730
+ return Z[Z.length - 1];
731
731
  }
732
- function Ee(e) {
733
- for (let t = X.length - 1; t >= 0; t--) {
734
- let n = X[t];
735
- if (n < e - Z) return n;
732
+ function Te(e) {
733
+ for (let t = Z.length - 1; t >= 0; t--) {
734
+ let n = Z[t];
735
+ if (n < e - Q) return n;
736
736
  }
737
- return X[0];
737
+ return Z[0];
738
738
  }
739
- function De(e, t, n) {
739
+ function Ee(e, t, n) {
740
740
  return e < t ? t : e > n ? n : e;
741
741
  }
742
- function Oe(e, t) {
742
+ function De(e, t) {
743
743
  let { contentWidth: n, contentHeight: r, containerWidth: i, containerHeight: a } = e;
744
744
  if (n <= 0 || i <= 0) return 0;
745
745
  let o = i / n;
@@ -750,7 +750,7 @@ function Oe(e, t) {
750
750
  }
751
751
  //#endregion
752
752
  //#region packages/core/src/search/text-index.ts
753
- function Q(e) {
753
+ function $(e) {
754
754
  let t = e.toLowerCase();
755
755
  if (t.length === e.length) return t;
756
756
  let n = "";
@@ -760,17 +760,17 @@ function Q(e) {
760
760
  }
761
761
  return n;
762
762
  }
763
- function ke(e) {
763
+ function Oe(e) {
764
764
  let t = Array(e.length), n = 0, r = "";
765
765
  for (let i = 0; i < e.length; i++) t[i] = n, r += e[i].text, n += e[i].text.length;
766
766
  return {
767
767
  text: r,
768
- folded: Q(r),
768
+ folded: $(r),
769
769
  runStart: t,
770
770
  runCount: e.length
771
771
  };
772
772
  }
773
- function $(e, t) {
773
+ function ke(e, t) {
774
774
  let { runStart: n } = e, r = 0, i = n.length - 1;
775
775
  for (; r < i;) {
776
776
  let e = r + i + 1 >> 1;
@@ -779,7 +779,7 @@ function $(e, t) {
779
779
  return r;
780
780
  }
781
781
  function Ae(e, t, n) {
782
- let { runStart: r, runCount: i, text: a } = e, o = [], s = $(e, t), c = t;
782
+ let { runStart: r, runCount: i, text: a } = e, o = [], s = ke(e, t), c = t;
783
783
  for (; c < n && s < i;) {
784
784
  let e = s + 1 < i ? r[s + 1] : a.length, t = Math.min(n, e), l = c - r[s], u = t - r[s];
785
785
  u > l && o.push({
@@ -792,7 +792,7 @@ function Ae(e, t, n) {
792
792
  }
793
793
  function je(e, t, n = {}) {
794
794
  if (t.length === 0) return [];
795
- let r = n.caseSensitive ?? !1, i = r ? e.text : e.folded, a = r ? t : Q(t), o = [], s = 0, c = 0;
795
+ let r = n.caseSensitive ?? !1, i = r ? e.text : e.folded, a = r ? t : $(t), o = [], s = 0, c = 0;
796
796
  for (;;) {
797
797
  let t = i.indexOf(a, s);
798
798
  if (t === -1) break;
@@ -812,4 +812,132 @@ function Ne(e, t) {
812
812
  return t <= 0 ? -1 : e < 0 ? t - 1 : (e - 1 + t) % t;
813
813
  }
814
814
  //#endregion
815
- export { De as a, Ee as c, xe as d, be as f, ve as h, je as i, we as l, _e as m, Ne as n, Oe as o, ye as p, ke as r, Te as s, Me as t, Ce as u };
815
+ //#region packages/core/src/internal/canvas-viewer-mechanics.ts
816
+ var Pe = class {
817
+ wrapper;
818
+ originalParent;
819
+ originalNextSibling;
820
+ originalDisplay;
821
+ originalStyle;
822
+ originalWidth;
823
+ originalHeight;
824
+ restored = !1;
825
+ constructor(e, t) {
826
+ this.canvas = e, this.options = t, this.originalParent = e.parentNode, this.originalNextSibling = e.nextSibling, this.originalDisplay = e.style.display, this.originalStyle = t.restoreMode === "style-and-bitmap" ? e.getAttribute("style") : null, this.originalWidth = e.width, this.originalHeight = e.height, this.wrapper = (e.ownerDocument ?? document).createElement("div"), this.wrapper.style.cssText = t.wrapperCssText, t.forceDisplayBlock && !e.style.display && (e.style.display = "block"), this.originalParent && this.originalParent.insertBefore(this.wrapper, e), this.wrapper.appendChild(e);
827
+ }
828
+ restore() {
829
+ if (!this.restored) {
830
+ if (this.restored = !0, this.originalParent) {
831
+ let e = this.originalNextSibling?.parentNode === this.originalParent ? this.originalNextSibling : null;
832
+ this.originalParent.insertBefore(this.canvas, e);
833
+ } else this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas);
834
+ (this.options.restoreMode ?? "display") === "style-and-bitmap" ? (this.originalStyle === null ? this.canvas.removeAttribute("style") : this.canvas.setAttribute("style", this.originalStyle), this.canvas.width = this.originalWidth, this.canvas.height = this.originalHeight) : this.canvas.style.display = this.originalDisplay, this.wrapper.remove();
835
+ }
836
+ }
837
+ }, Fe = "position:absolute;top:0;left:0;width:100%;height:100%;overflow:hidden;pointer-events:none;user-select:text;-webkit-user-select:text;", Ie = "position:absolute;top:0;left:0;width:100%;height:100%;overflow:hidden;pointer-events:none;", Le = class {
838
+ textLayer;
839
+ highlightLayer;
840
+ constructor(e, t) {
841
+ let n = e.ownerDocument ?? document;
842
+ this.textLayer = t ? n.createElement("div") : null, this.textLayer && (this.textLayer.style.cssText = Fe, e.appendChild(this.textLayer)), this.highlightLayer = n.createElement("div"), this.highlightLayer.style.cssText = Ie, e.appendChild(this.highlightLayer);
843
+ }
844
+ };
845
+ function Re(e, t, n) {
846
+ if (n && t !== void 0 && t !== n.mode) throw Error(`${e}: opts.mode='${t}' conflicts with the borrowed engine's mode='${n.mode}'. Omit opts.mode when borrowing an engine — the engine owns its render mode.`);
847
+ return n?.mode ?? t ?? "main";
848
+ }
849
+ var ze = class {
850
+ generation = 0;
851
+ resource;
852
+ ownsResource;
853
+ closed = !1;
854
+ constructor(e, t = null, n = !1) {
855
+ this.ownerName = e, this.resource = t, this.ownsResource = t !== null && n;
856
+ }
857
+ get current() {
858
+ return this.resource;
859
+ }
860
+ async replace(e, t) {
861
+ this.assertOpen();
862
+ let n = ++this.generation, r;
863
+ try {
864
+ r = await e();
865
+ } catch (e) {
866
+ if (this.closed) throw this.closedError();
867
+ if (n !== this.generation) return null;
868
+ throw e;
869
+ }
870
+ if (this.closed) throw this.dispose(r), this.closedError();
871
+ if (n !== this.generation) return this.dispose(r), null;
872
+ try {
873
+ t?.(this.resource);
874
+ } catch (e) {
875
+ throw this.dispose(r), e;
876
+ }
877
+ return this.install(r, !0), r;
878
+ }
879
+ install(e, t = !0) {
880
+ this.assertOpen(), this.generation++;
881
+ let n = this.resource, r = this.ownsResource;
882
+ this.resource = e, this.ownsResource = t, r && n && this.dispose(n);
883
+ }
884
+ close() {
885
+ if (this.closed) return;
886
+ this.closed = !0, this.generation++;
887
+ let e = this.resource, t = this.ownsResource;
888
+ this.resource = null, this.ownsResource = !1, t && e && this.dispose(e);
889
+ }
890
+ assertOpen() {
891
+ if (this.closed) throw this.closedError();
892
+ }
893
+ closedError() {
894
+ return /* @__PURE__ */ Error(`${this.ownerName} is closed`);
895
+ }
896
+ dispose(e) {
897
+ try {
898
+ e.destroy();
899
+ } catch {}
900
+ }
901
+ }, Be = class {
902
+ generation = 0;
903
+ destroyed = !1;
904
+ bitmapContext;
905
+ constructor(e, t) {
906
+ this.canvas = e, this.bitmapContext = t ? e.getContext("bitmaprenderer") : null;
907
+ }
908
+ begin() {
909
+ return ++this.generation;
910
+ }
911
+ isCurrent(e) {
912
+ return !this.destroyed && e === this.generation;
913
+ }
914
+ commitBitmap(e, t, n = {}) {
915
+ if (!this.isCurrent(e)) return t.close(), !1;
916
+ if (!this.bitmapContext) throw t.close(), Error("bitmaprenderer context not available");
917
+ this.canvas.width !== t.width && (this.canvas.width = t.width), this.canvas.height !== t.height && (this.canvas.height = t.height), n.cssWidth !== void 0 && (this.canvas.style.width = `${n.cssWidth}px`), n.cssHeight !== void 0 && (this.canvas.style.height = `${n.cssHeight}px`);
918
+ try {
919
+ this.bitmapContext.transferFromImageBitmap(t);
920
+ } catch (e) {
921
+ throw t.close(), e;
922
+ }
923
+ return !0;
924
+ }
925
+ destroy() {
926
+ this.destroyed || (this.destroyed = !0, this.generation++);
927
+ }
928
+ }, Ve = class {
929
+ closed = !1;
930
+ constructor(e, t) {
931
+ this.viewerName = e, this.onError = t;
932
+ }
933
+ report(e) {
934
+ if (this.closed) return;
935
+ let t = e instanceof Error ? e : Error(String(e));
936
+ this.onError ? this.onError(t) : console.error(`[ooxml] ${this.viewerName} render failed:`, t);
937
+ }
938
+ close() {
939
+ this.closed = !0;
940
+ }
941
+ };
942
+ //#endregion
943
+ export { be as _, ze as a, ge as b, Ne as c, Ee as d, De as f, Se as g, Ce as h, Be as i, Oe as l, Te as m, Le as n, Re as o, we as p, Ve as r, Me as s, Pe as t, je as u, ye as v, _e as x, ve as y };