@component-hook/pdf-canvas 1.5.0 → 1.5.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.
@@ -227,16 +227,20 @@ var se = Math.PI / 2, ce = Math.PI / 4, le = 2 * Math.PI, ue = Math.PI / 180, de
227
227
  return () => !1;
228
228
  }
229
229
  _removeEventListener(e, t) {
230
- if (this.__eventListeners[e]) if (t) {
231
- let n = this.__eventListeners[e], r = n.indexOf(t);
232
- r > -1 && n.splice(r, 1);
233
- } else this.__eventListeners[e] = [];
230
+ if (this.__eventListeners[e]) {
231
+ if (t) {
232
+ let n = this.__eventListeners[e], r = n.indexOf(t);
233
+ r > -1 && n.splice(r, 1);
234
+ } else this.__eventListeners[e] = [];
235
+ }
234
236
  }
235
237
  off(e, t) {
236
- if (this.__eventListeners) if (e === void 0) for (let e in this.__eventListeners) this._removeEventListener(e);
237
- else typeof e == "object" ? Object.entries(e).forEach(([e, t]) => {
238
- this._removeEventListener(e, t);
239
- }) : this._removeEventListener(e, t);
238
+ if (this.__eventListeners) {
239
+ if (e === void 0) for (let e in this.__eventListeners) this._removeEventListener(e);
240
+ else typeof e == "object" ? Object.entries(e).forEach(([e, t]) => {
241
+ this._removeEventListener(e, t);
242
+ }) : this._removeEventListener(e, t);
243
+ }
240
244
  }
241
245
  fire(e, t) {
242
246
  if (!this.__eventListeners) return;
@@ -971,7 +975,7 @@ var Nt = class {
971
975
  toSVG(e = {}, t) {
972
976
  e.reviver = t;
973
977
  let n = [];
974
- return (this._setSVGPreamble(n, e), this._setSVGHeader(n, e), this.clipPath) && n.push(`<g clip-path="url(#${z(this.clipPath.clipPathId ?? "")})" >\n`), this._setSVGBgOverlayColor(n, "background"), this._setSVGBgOverlayImage(n, "backgroundImage", t), this._setSVGObjects(n, t), this.clipPath && n.push("</g>\n"), this._setSVGBgOverlayColor(n, "overlay"), this._setSVGBgOverlayImage(n, "overlayImage", t), n.push("</svg>"), n.join("");
978
+ return this._setSVGPreamble(n, e), this._setSVGHeader(n, e), this.clipPath && n.push(`<g clip-path="url(#${z(this.clipPath.clipPathId ?? "")})" >\n`), this._setSVGBgOverlayColor(n, "background"), this._setSVGBgOverlayImage(n, "backgroundImage", t), this._setSVGObjects(n, t), this.clipPath && n.push("</g>\n"), this._setSVGBgOverlayColor(n, "overlay"), this._setSVGBgOverlayImage(n, "overlayImage", t), n.push("</svg>"), n.join("");
975
979
  }
976
980
  _setSVGPreamble(e, t) {
977
981
  t.suppressPreamble || e.push("<?xml version=\"1.0\" encoding=\"", t.encoding || "UTF-8", "\" standalone=\"no\" ?>\n", "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" ", "\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");
@@ -1033,10 +1037,12 @@ var Nt = class {
1033
1037
  }
1034
1038
  _setSVGBgOverlayColor(e, t) {
1035
1039
  let n = this[`${t}Color`];
1036
- if (n) if (Ct(n)) {
1037
- let r = n.repeat || "", i = this.width, a = this.height, o = this[`${t}Vpt`] ? St(rt(this.viewportTransform)) : "";
1038
- e.push(`<rect transform="${o} translate(${i / 2},${a / 2})" x="${n.offsetX - i / 2}" y="${n.offsetY - a / 2}" width="${r !== "repeat-y" && r !== "no-repeat" || !Tt(n) ? i : n.source.width}" height="${r !== "repeat-x" && r !== "no-repeat" || !Tt(n) ? a : n.source.height}" fill="url(#SVGID_${n.id})"></rect>\n`);
1039
- } else e.push("<rect x=\"0\" y=\"0\" width=\"100%\" height=\"100%\" ", "fill=\"", n, "\"", "></rect>\n");
1040
+ if (n) {
1041
+ if (Ct(n)) {
1042
+ let r = n.repeat || "", i = this.width, a = this.height, o = this[`${t}Vpt`] ? St(rt(this.viewportTransform)) : "";
1043
+ e.push(`<rect transform="${o} translate(${i / 2},${a / 2})" x="${n.offsetX - i / 2}" y="${n.offsetY - a / 2}" width="${r !== "repeat-y" && r !== "no-repeat" || !Tt(n) ? i : n.source.width}" height="${r !== "repeat-x" && r !== "no-repeat" || !Tt(n) ? a : n.source.height}" fill="url(#SVGID_${n.id})"></rect>\n`);
1044
+ } else e.push("<rect x=\"0\" y=\"0\" width=\"100%\" height=\"100%\" ", "fill=\"", n, "\"", "></rect>\n");
1045
+ }
1040
1046
  }
1041
1047
  loadFromJSON(e, t, { signal: n } = {}) {
1042
1048
  if (!e) return Promise.reject(new D("`json` is undefined"));
@@ -1374,17 +1380,18 @@ var Tn = new RegExp(String.raw`[\0-\x1F\x7F;<>\\]|\/\*|\*\/|url\s*\(|expression\
1374
1380
  ];
1375
1381
  }, In = class e {
1376
1382
  constructor(t) {
1377
- if (C(this, "isUnrecognised", !1), t) if (t instanceof e) this.setSource([...t._source]);
1378
- else if (Array.isArray(t)) {
1379
- let [e, n, r, i = 1] = t;
1380
- this.setSource([
1381
- e,
1382
- n,
1383
- r,
1384
- i
1385
- ]);
1386
- } else this.setSource(this._tryParsingColor(t));
1387
- else this.setSource([
1383
+ if (C(this, "isUnrecognised", !1), t) {
1384
+ if (t instanceof e) this.setSource([...t._source]);
1385
+ else if (Array.isArray(t)) {
1386
+ let [e, n, r, i = 1] = t;
1387
+ this.setSource([
1388
+ e,
1389
+ n,
1390
+ r,
1391
+ i
1392
+ ]);
1393
+ } else this.setSource(this._tryParsingColor(t));
1394
+ } else this.setSource([
1388
1395
  0,
1389
1396
  0,
1390
1397
  0,
@@ -1577,15 +1584,16 @@ var Tn = new RegExp(String.raw`[\0-\x1F\x7F;<>\\]|\/\*|\*\/|url\s*\(|expression\
1577
1584
  };
1578
1585
  }, Bn = (e, t, n = !0) => {
1579
1586
  let r, i;
1580
- if (t) if (t.toLive) r = `url(#SVGID_${z(t.id)})`;
1581
- else {
1582
- let e = String(t);
1583
- if (En(e)) {
1584
- let t = new In(e), n = t.getAlpha();
1585
- r = t.toRgb(), n !== 1 && (i = n.toString());
1586
- } else r = new In("black").toRgb();
1587
- }
1588
- else r = "none";
1587
+ if (t) {
1588
+ if (t.toLive) r = `url(#SVGID_${z(t.id)})`;
1589
+ else {
1590
+ let e = String(t);
1591
+ if (En(e)) {
1592
+ let t = new In(e), n = t.getAlpha();
1593
+ r = t.toRgb(), n !== 1 && (i = n.toString());
1594
+ } else r = new In("black").toRgb();
1595
+ }
1596
+ } else r = "none";
1589
1597
  return n ? `${e}: ${r}; ${i ? `${e}-opacity: ${i}; ` : ""}` : `${e}="${r}" ${i ? `${e}-opacity="${i}" ` : ""}`;
1590
1598
  }, Vn = class {
1591
1599
  getSvgStyles(e) {
@@ -2478,7 +2486,7 @@ var ai = class e {
2478
2486
  return !!this.shadow && (this.shadow.offsetX !== 0 || this.shadow.offsetY !== 0);
2479
2487
  }
2480
2488
  drawClipPathOnCache(e, t, n) {
2481
- e.save(), t.inverted ? e.globalCompositeOperation = "destination-out" : e.globalCompositeOperation = "destination-in", e.setTransform(1, 0, 0, 1, 0, 0), e.drawImage(n, 0, 0), e.restore();
2489
+ e.save(), e.globalCompositeOperation = t.inverted ? "destination-out" : "destination-in", e.setTransform(1, 0, 0, 1, 0, 0), e.drawImage(n, 0, 0), e.restore();
2482
2490
  }
2483
2491
  drawObject(e, t, n) {
2484
2492
  let r = this.fill, i = this.stroke;
@@ -5412,10 +5420,10 @@ var Ro = class {
5412
5420
  }
5413
5421
  _onMouseUpInDrawingMode(e) {
5414
5422
  let t = this.getScenePoint(e);
5415
- this.freeDrawingBrush ? this._isCurrentlyDrawing = !!this.freeDrawingBrush.onMouseUp({
5423
+ this._isCurrentlyDrawing = this.freeDrawingBrush ? !!this.freeDrawingBrush.onMouseUp({
5416
5424
  e,
5417
5425
  pointer: t
5418
- }) : this._isCurrentlyDrawing = !1, this._handleEvent(e, "up");
5426
+ }) : !1, this._handleEvent(e, "up");
5419
5427
  }
5420
5428
  __onMouseDown(e) {
5421
5429
  this._isClick = !0, this._handleEvent(e, "down:before");
@@ -6080,7 +6088,7 @@ var ls = [
6080
6088
  let t = this.calcLinePoints();
6081
6089
  e.moveTo(t.x1, t.y1), e.lineTo(t.x2, t.y2), e.lineWidth = this.strokeWidth;
6082
6090
  let n = e.strokeStyle;
6083
- Ct(this.stroke) ? e.strokeStyle = this.stroke.toLive(e) : e.strokeStyle = this.stroke ?? e.fillStyle, this.stroke && this._renderStroke(e), e.strokeStyle = n;
6091
+ e.strokeStyle = Ct(this.stroke) ? this.stroke.toLive(e) : this.stroke ?? e.fillStyle, this.stroke && this._renderStroke(e), e.strokeStyle = n;
6084
6092
  }
6085
6093
  _findCenterFromElement() {
6086
6094
  return new F((this.x1 + this.x2) / 2, (this.y1 + this.y2) / 2);
@@ -7452,7 +7460,7 @@ var Cs = class {
7452
7460
  copy() {
7453
7461
  if (this.selectionStart === this.selectionEnd) return;
7454
7462
  let { copyPasteData: e } = M();
7455
- e.copiedText = this.getSelectedText(), T.disableStyleCopyPaste ? e.copiedTextStyle = void 0 : e.copiedTextStyle = this.getSelectionStyles(this.selectionStart, this.selectionEnd, !0), this._copyDone = !0;
7463
+ e.copiedText = this.getSelectedText(), e.copiedTextStyle = T.disableStyleCopyPaste ? void 0 : this.getSelectionStyles(this.selectionStart, this.selectionEnd, !0), this._copyDone = !0;
7456
7464
  }
7457
7465
  paste() {
7458
7466
  this.fromPaste = !0;
@@ -7789,10 +7797,12 @@ var Cs = class {
7789
7797
  for (let t = u; t <= d; t++) {
7790
7798
  let a = this._getLineLeftOffset(t) || 0, o = this.getHeightOfLine(t), c = 0, l = 0;
7791
7799
  if (t === u && (c = this.__charBounds[u][f].left), t >= u && t < d) l = s && !this.isEndOfWrapping(t) ? this.width : this.getLineWidth(t) || 5;
7792
- else if (t === d) if (p === 0) l = this.__charBounds[d][p].left;
7793
- else {
7794
- let e = this._getWidthOfCharSpacing();
7795
- l = this.__charBounds[d][p - 1].left + this.__charBounds[d][p - 1].width - e;
7800
+ else if (t === d) {
7801
+ if (p === 0) l = this.__charBounds[d][p].left;
7802
+ else {
7803
+ let e = this._getWidthOfCharSpacing();
7804
+ l = this.__charBounds[d][p - 1].left + this.__charBounds[d][p - 1].width - e;
7805
+ }
7796
7806
  }
7797
7807
  let m = o;
7798
7808
  (this.lineHeight < 1 || t === d && this.lineHeight > 1) && (o /= this.lineHeight);
@@ -8634,14 +8644,16 @@ async function oc(e, t, { crossOrigin: n, signal: r } = {}) {
8634
8644
  for (let e of t) {
8635
8645
  if (!e) continue;
8636
8646
  let { name: t, value: r } = e;
8637
- if (!n.includes(t)) if (t === "style") {
8638
- let e = {};
8639
- Sa(r, e), Object.entries(l).forEach(([t, n]) => {
8640
- e[t] = n;
8641
- }), Sa(l.style || "", e);
8642
- let n = Object.entries(e).map((e) => e.join(":")).join(";");
8643
- s.setAttribute(t, n);
8644
- } else !l[t] && s.setAttribute(t, r);
8647
+ if (!n.includes(t)) {
8648
+ if (t === "style") {
8649
+ let e = {};
8650
+ Sa(r, e), Object.entries(l).forEach(([t, n]) => {
8651
+ e[t] = n;
8652
+ }), Sa(l.style || "", e);
8653
+ let n = Object.entries(e).map((e) => e.join(":")).join(";");
8654
+ s.setAttribute(t, n);
8655
+ } else !l[t] && s.setAttribute(t, r);
8656
+ }
8645
8657
  }
8646
8658
  s.setAttribute("transform", p), s.setAttribute("instantiated_by_use", "1"), s.removeAttribute("id"), r.parentNode.replaceChild(s, r);
8647
8659
  }
@@ -11056,11 +11068,7 @@ var ou = class {
11056
11068
  });
11057
11069
  }
11058
11070
  onSetPreference({ name: e, value: t }) {
11059
- switch (e) {
11060
- case "enableNewAltTextWhenAddingImage":
11061
- this.#_ = t;
11062
- break;
11063
- }
11071
+ e === "enableNewAltTextWhenAddingImage" && (this.#_ = t);
11064
11072
  }
11065
11073
  onPageChanging({ pageNumber: e }) {
11066
11074
  this.#u = e - 1;
@@ -11149,11 +11157,11 @@ var ou = class {
11149
11157
  this.#N && (this.#C?.hide(), this.#N = null, this.#te({ hasSelectedText: !1 }));
11150
11158
  return;
11151
11159
  }
11152
- if (this.#C?.hide(), this.#N = t, this.#te({ hasSelectedText: !0 }), !(this.#j !== H.HIGHLIGHT && this.#j !== H.NONE) && (this.#j === H.HIGHLIGHT && this.showAllEditors("highlight", !0, !0), this.#S = this.isShiftKeyDown, !this.isShiftKeyDown)) {
11160
+ if (this.#C?.hide(), this.#N = t, this.#te({ hasSelectedText: !0 }), (this.#j === H.HIGHLIGHT || this.#j === H.NONE) && (this.#j === H.HIGHLIGHT && this.showAllEditors("highlight", !0, !0), this.#S = this.isShiftKeyDown, !this.isShiftKeyDown)) {
11153
11161
  let e = this.#j === H.HIGHLIGHT ? this.#U(n) : null;
11154
11162
  e?.toggleDrawing();
11155
11163
  let t = new AbortController(), r = this.combinedSignal(t), i = (n) => {
11156
- n.type === "pointerup" && n.button !== 0 || (t.abort(), e?.toggleDrawing(!0), n.type === "pointerup" && this.#K("main_toolbar"));
11164
+ (n.type !== "pointerup" || n.button === 0) && (t.abort(), e?.toggleDrawing(!0), n.type === "pointerup" && this.#K("main_toolbar"));
11157
11165
  };
11158
11166
  window.addEventListener("pointerup", i, { signal: r }), window.addEventListener("blur", i, { signal: r });
11159
11167
  }
@@ -11296,9 +11304,7 @@ var ou = class {
11296
11304
  case "selectAll":
11297
11305
  this[e]();
11298
11306
  break;
11299
- case "highlightSelection":
11300
- this.highlightSelection("context_menu");
11301
- break;
11307
+ case "highlightSelection": this.highlightSelection("context_menu");
11302
11308
  }
11303
11309
  }
11304
11310
  #te(e) {
@@ -11380,18 +11386,16 @@ var ou = class {
11380
11386
  case U.HIGHLIGHT_DEFAULT_COLOR:
11381
11387
  this.#k?.updateColor(t);
11382
11388
  break;
11383
- case U.HIGHLIGHT_SHOW_ALL:
11384
- this._eventBus.dispatch("reporttelemetry", {
11385
- source: this,
11386
- details: {
11387
- type: "editing",
11388
- data: {
11389
- type: "highlight",
11390
- action: "toggle_visibility"
11391
- }
11389
+ case U.HIGHLIGHT_SHOW_ALL: this._eventBus.dispatch("reporttelemetry", {
11390
+ source: this,
11391
+ details: {
11392
+ type: "editing",
11393
+ data: {
11394
+ type: "highlight",
11395
+ action: "toggle_visibility"
11392
11396
  }
11393
- }), (this.#F ||= /* @__PURE__ */ new Map()).set(e, t), this.showAllEditors("highlight", t);
11394
- break;
11397
+ }
11398
+ }), (this.#F ||= /* @__PURE__ */ new Map()).set(e, t), this.showAllEditors("highlight", t);
11395
11399
  }
11396
11400
  for (let n of this.#M) n.updateParams(e, t);
11397
11401
  for (let n of this.#p) n.updateDefaultParams(e, t);
@@ -11668,19 +11672,17 @@ var ou = class {
11668
11672
  height: o / i
11669
11673
  });
11670
11674
  break;
11671
- default:
11672
- o = (e, t, o, s) => ({
11673
- x: (e - n) / i,
11674
- y: (t - r) / a,
11675
- width: o / i,
11676
- height: s / a
11677
- });
11678
- break;
11675
+ default: o = (e, t, o, s) => ({
11676
+ x: (e - n) / i,
11677
+ y: (t - r) / a,
11678
+ width: o / i,
11679
+ height: s / a
11680
+ });
11679
11681
  }
11680
11682
  let s = [];
11681
11683
  for (let e = 0, n = t.rangeCount; e < n; e++) {
11682
11684
  let n = t.getRangeAt(e);
11683
- if (!n.collapsed) for (let { x: e, y: t, width: r, height: i } of n.getClientRects()) r === 0 || i === 0 || s.push(o(e, t, r, i));
11685
+ if (!n.collapsed) for (let { x: e, y: t, width: r, height: i } of n.getClientRects()) r !== 0 && i !== 0 && s.push(o(e, t, r, i));
11684
11686
  }
11685
11687
  return s.length === 0 ? null : s;
11686
11688
  }
@@ -11789,7 +11791,7 @@ var ou = class {
11789
11791
  };
11790
11792
  }
11791
11793
  set data({ altText: e, decorative: t, guessedText: n, textWithDisclaimer: r, cancel: i = !1 }) {
11792
- n && (this.#l = n, this.#u = r), !(this.#e === e && this.#t === t) && (i || (this.#e = e, this.#t = t), this.#m());
11794
+ n && (this.#l = n, this.#u = r), (this.#e !== e || this.#t !== t) && (i || (this.#e = e, this.#t = t), this.#m());
11793
11795
  }
11794
11796
  toggle(e = !1) {
11795
11797
  this.#n && (!e && this.#a && (clearTimeout(this.#a), this.#a = null), this.#n.disabled = !e);
@@ -12051,9 +12053,7 @@ var ou = class {
12051
12053
  case 270:
12052
12054
  this.x += this.height * t / (e * 2), this.y -= this.width * e / (t * 2);
12053
12055
  break;
12054
- default:
12055
- this.x -= this.width / 2, this.y -= this.height / 2;
12056
- break;
12056
+ default: this.x -= this.width / 2, this.y -= this.height / 2;
12057
12057
  }
12058
12058
  this.fixAndSetPosition();
12059
12059
  }
@@ -12154,9 +12154,7 @@ var ou = class {
12154
12154
  case 180:
12155
12155
  i = Math.min(n, Math.max(o, i)), a = Math.min(r, Math.max(s, a));
12156
12156
  break;
12157
- case 270:
12158
- i = Math.min(n, Math.max(s, i)), a = Math.max(0, Math.min(r - o, a));
12159
- break;
12157
+ case 270: i = Math.min(n, Math.max(s, i)), a = Math.max(0, Math.min(r - o, a));
12160
12158
  }
12161
12159
  this.x = i /= n, this.y = a /= r;
12162
12160
  let [c, l] = this.getBaseTranslation();
@@ -12296,7 +12294,7 @@ var ou = class {
12296
12294
  let { savedX: e, savedY: t, savedWidth: n, savedHeight: r } = this.#l;
12297
12295
  this.#l = null;
12298
12296
  let i = this.x, a = this.y, o = this.width, s = this.height;
12299
- i === e && a === t && o === n && s === r || this.addCommands({
12297
+ (i !== e || a !== t || o !== n || s !== r) && this.addCommands({
12300
12298
  cmd: this.#k.bind(this, i, a, o, s),
12301
12299
  undo: this.#k.bind(this, e, t, n, r),
12302
12300
  mustExec: !0
@@ -12329,9 +12327,7 @@ var ou = class {
12329
12327
  case "bottomLeft":
12330
12328
  _ = !0, h = (e, t) => [0, t], g = (e, t) => [e, 0];
12331
12329
  break;
12332
- case "middleLeft":
12333
- v = !0, h = (e, t) => [0, t / 2], g = (e, t) => [e, t / 2];
12334
- break;
12330
+ case "middleLeft": v = !0, h = (e, t) => [0, t / 2], g = (e, t) => [e, t / 2];
12335
12331
  }
12336
12332
  let y = h(s, c), b = g(s, c), x = f(...b), S = e._round(a + x[0]), C = e._round(o + x[1]), w = 1, T = 1, E, D;
12337
12333
  if (n.fromKeyboard) ({deltaX: E, deltaY: D} = n);
@@ -14330,9 +14326,7 @@ var hd = [
14330
14326
  case "SMask":
14331
14327
  this.current.activeSMask = n ? this.tempSMask : null, this.tempSMask = null, this.checkSMaskState();
14332
14328
  break;
14333
- case "TR":
14334
- this.ctx.filter = this.current.transferMaps = this.filterFactory.addFilter(n);
14335
- break;
14329
+ case "TR": this.ctx.filter = this.current.transferMaps = this.filterFactory.addFilter(n);
14336
14330
  }
14337
14331
  }
14338
14332
  get inSMaskMode() {
@@ -14370,7 +14364,7 @@ var hd = [
14370
14364
  }
14371
14365
  composeSMask(e, t, n, r) {
14372
14366
  let i = r[0], a = r[1], o = r[2] - i, s = r[3] - a;
14373
- o === 0 || s === 0 || (this.genericComposeSMask(t.context, n, o, s, t.subtype, t.backdrop, t.transferMap, i, a, t.offsetX, t.offsetY), e.save(), e.globalAlpha = 1, e.globalCompositeOperation = "source-over", e.setTransform(1, 0, 0, 1, 0, 0), e.drawImage(n.canvas, 0, 0), e.restore());
14367
+ o !== 0 && s !== 0 && (this.genericComposeSMask(t.context, n, o, s, t.subtype, t.backdrop, t.transferMap, i, a, t.offsetX, t.offsetY), e.save(), e.globalAlpha = 1, e.globalCompositeOperation = "source-over", e.setTransform(1, 0, 0, 1, 0, 0), e.drawImage(n.canvas, 0, 0), e.restore());
14374
14368
  }
14375
14369
  genericComposeSMask(e, t, n, r, i, a, o, s, c, l, u) {
14376
14370
  let d = e.canvas, f = s - l, p = c - u;
@@ -14428,9 +14422,7 @@ var hd = [
14428
14422
  case ol.curveTo3:
14429
14423
  s = a, c = o, a = t[f + 2], o = t[f + 3], r.bezierCurveTo(t[f], t[f + 1], a, o, a, o), i.updateCurvePathMinMax(l, s, c, t[f], t[f + 1], a, o, a, o, d), f += 4;
14430
14424
  break;
14431
- case ol.closePath:
14432
- r.closePath();
14433
- break;
14425
+ case ol.closePath: r.closePath();
14434
14426
  }
14435
14427
  u && i.updateScalingPathMinMax(l, d), i.setCurrentPoint(a, o);
14436
14428
  }
@@ -14540,14 +14532,18 @@ var hd = [
14540
14532
  paintChar(e, t, n, r, i) {
14541
14533
  let a = this.ctx, o = this.current, s = o.font, c = o.textRenderingMode, l = o.fontSize / o.fontSizeScale, u = c & nl.FILL_STROKE_MASK, d = !!(c & nl.ADD_TO_PATH_FLAG), f = o.patternFill && !s.missingFile, p = o.patternStroke && !s.missingFile, m;
14542
14534
  if ((s.disableFontFace || d || f || p) && (m = s.getPathGenerator(this.commonObjs, e)), s.disableFontFace || f || p) {
14543
- if (a.save(), a.translate(t, n), a.scale(l, -l), u === nl.FILL || u === nl.FILL_STROKE) if (r) {
14544
- let e = a.getTransform();
14545
- a.setTransform(...r), a.fill(this.#n(m, e, r));
14546
- } else a.fill(m);
14547
- if (u === nl.STROKE || u === nl.FILL_STROKE) if (i) {
14548
- let e = a.getTransform();
14549
- a.setTransform(...i), a.stroke(this.#n(m, e, i));
14550
- } else a.lineWidth /= l, a.stroke(m);
14535
+ if (a.save(), a.translate(t, n), a.scale(l, -l), u === nl.FILL || u === nl.FILL_STROKE) {
14536
+ if (r) {
14537
+ let e = a.getTransform();
14538
+ a.setTransform(...r), a.fill(this.#n(m, e, r));
14539
+ } else a.fill(m);
14540
+ }
14541
+ if (u === nl.STROKE || u === nl.FILL_STROKE) {
14542
+ if (i) {
14543
+ let e = a.getTransform();
14544
+ a.setTransform(...i), a.stroke(this.#n(m, e, i));
14545
+ } else a.lineWidth /= l, a.stroke(m);
14546
+ }
14551
14547
  a.restore();
14552
14548
  } else (u === nl.FILL || u === nl.FILL_STROKE) && a.fillText(e, t, n), (u === nl.STROKE || u === nl.FILL_STROKE) && a.strokeText(e, t, n);
14553
14549
  d && (this.pendingTextPaths ||= []).push({
@@ -14943,12 +14939,13 @@ var hd = [
14943
14939
  let { lineWidth: e } = this.current, { a: t, b: n, c: r, d: i } = this.ctx.getTransform(), a, o;
14944
14940
  if (n === 0 && r === 0) {
14945
14941
  let n = Math.abs(t), r = Math.abs(i);
14946
- if (n === r) if (e === 0) a = o = 1 / n;
14947
- else {
14948
- let t = n * e;
14949
- a = o = t < 1 ? 1 / t : 1;
14950
- }
14951
- else if (e === 0) a = 1 / n, o = 1 / r;
14942
+ if (n === r) {
14943
+ if (e === 0) a = o = 1 / n;
14944
+ else {
14945
+ let t = n * e;
14946
+ a = o = t < 1 ? 1 / t : 1;
14947
+ }
14948
+ } else if (e === 0) a = 1 / n, o = 1 / r;
14952
14949
  else {
14953
14950
  let t = n * e, i = r * e;
14954
14951
  a = t < 1 ? 1 / t : 1, o = i < 1 ? 1 / i : 1;
@@ -15085,19 +15082,22 @@ var bd = class {
15085
15082
  if (this.#t.get(t).visible) return !0;
15086
15083
  }
15087
15084
  return !1;
15088
- } else if (e.policy === "AllOn") {
15085
+ }
15086
+ if (e.policy === "AllOn") {
15089
15087
  for (let t of e.ids) {
15090
15088
  if (!this.#t.has(t)) return G(`Optional content group not found: ${t}`), !0;
15091
15089
  if (!this.#t.get(t).visible) return !1;
15092
15090
  }
15093
15091
  return !0;
15094
- } else if (e.policy === "AnyOff") {
15092
+ }
15093
+ if (e.policy === "AnyOff") {
15095
15094
  for (let t of e.ids) {
15096
15095
  if (!this.#t.has(t)) return G(`Optional content group not found: ${t}`), !0;
15097
15096
  if (!this.#t.get(t).visible) return !0;
15098
15097
  }
15099
15098
  return !1;
15100
- } else if (e.policy === "AllOff") {
15099
+ }
15100
+ if (e.policy === "AllOff") {
15101
15101
  for (let t of e.ids) {
15102
15102
  if (!this.#t.has(t)) return G(`Optional content group not found: ${t}`), !0;
15103
15103
  if (this.#t.get(t).visible) return !1;
@@ -15135,9 +15135,7 @@ var bd = class {
15135
15135
  case "OFF":
15136
15136
  this.setVisibility(r, !1, t);
15137
15137
  break;
15138
- case "Toggle":
15139
- this.setVisibility(r, !e.visible, t);
15140
- break;
15138
+ case "Toggle": this.setVisibility(r, !e.visible, t);
15141
15139
  }
15142
15140
  }
15143
15141
  this.#e = null;
@@ -15187,7 +15185,7 @@ var bd = class {
15187
15185
  _onReceiveData({ begin: e, chunk: t }) {
15188
15186
  let n = t instanceof Uint8Array && t.byteLength === t.buffer.byteLength ? t.buffer : new Uint8Array(t).buffer;
15189
15187
  e === void 0 ? this._fullRequestReader ? this._fullRequestReader._enqueue(n) : this._queuedChunks.push(n) : q(this._rangeReaders.some(function(t) {
15190
- return t._begin === e ? (t._enqueue(n), !0) : !1;
15188
+ return t._begin === e && (t._enqueue(n), !0);
15191
15189
  }), "_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.");
15192
15190
  }
15193
15191
  get _progressiveDataLength() {
@@ -15579,7 +15577,7 @@ var Ud = class {
15579
15577
  return;
15580
15578
  }
15581
15579
  let i = r.status || Bd;
15582
- if (!(i === Bd && n.expectedStatus === Vd) && i !== n.expectedStatus) {
15580
+ if ((i !== Bd || n.expectedStatus !== Vd) && i !== n.expectedStatus) {
15583
15581
  n.onError(r.status);
15584
15582
  return;
15585
15583
  }
@@ -16067,7 +16065,7 @@ var Yd = class {
16067
16065
  }
16068
16066
  static #D(e, t, n) {
16069
16067
  let r = this.#b.get(e);
16070
- t === r.size && n === r.family || (e.font = `${t}px ${n}`, r.size = t, r.family = n);
16068
+ (t !== r.size || n !== r.family) && (e.font = `${t}px ${n}`, r.size = t, r.family = n);
16071
16069
  }
16072
16070
  static #O() {
16073
16071
  if (this.#x !== null) return;
@@ -16117,7 +16115,7 @@ var Yd = class {
16117
16115
  return i(t), r;
16118
16116
  }
16119
16117
  static shouldBuildText(e) {
16120
- return !(e === "textarea" || e === "input" || e === "option" || e === "select");
16118
+ return e !== "textarea" && e !== "input" && e !== "option" && e !== "select";
16121
16119
  }
16122
16120
  }, rf = 65536, af = 100, of = 5e3, sf = qc ? Ru : ku, cf = qc ? zu : ju, lf = qc ? Lu : Nu, uf = qc ? Bu : Fu;
16123
16121
  function df(e = {}) {
@@ -16191,11 +16189,12 @@ function df(e = {}) {
16191
16189
  else if (!i) {
16192
16190
  if (!r) throw Error("getDocument - no `url` parameter provided.");
16193
16191
  let e;
16194
- if (qc) if (ql(r)) {
16195
- if (typeof fetch > "u" || typeof Response > "u" || !("body" in Response.prototype)) throw Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");
16196
- e = Ld;
16197
- } else e = Yd;
16198
- else e = ql(r) ? Ld : Wd;
16192
+ if (qc) {
16193
+ if (ql(r)) {
16194
+ if (typeof fetch > "u" || typeof Response > "u" || !("body" in Response.prototype)) throw Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");
16195
+ e = Ld;
16196
+ } else e = Yd;
16197
+ } else e = ql(r) ? Ld : Wd;
16199
16198
  s = new e({
16200
16199
  url: r,
16201
16200
  length: ne,
@@ -17365,7 +17364,6 @@ var Af = class {
17365
17364
  let n = e.target.options, i = n.selectedIndex === -1 ? "" : n[n.selectedIndex].value;
17366
17365
  r.setValue(t, { value: i });
17367
17366
  });
17368
- break;
17369
17367
  }
17370
17368
  }
17371
17369
  static setAttributes({ html: e, element: t, storage: n = null, intent: r, linkService: i }) {
@@ -17548,10 +17546,7 @@ var Rf = class {
17548
17546
  case il.INSET:
17549
17547
  G("Unimplemented border style: inset");
17550
17548
  break;
17551
- case il.UNDERLINE:
17552
- a.borderBottomStyle = "solid";
17553
- break;
17554
- default: break;
17549
+ case il.UNDERLINE: a.borderBottomStyle = "solid";
17555
17550
  }
17556
17551
  let r = t.borderColor || null;
17557
17552
  r ? (this.#t = !0, a.borderColor = Y.makeHexColor(r[0] | 0, r[1] | 0, r[2] | 0)) : a.borderWidth = 0;
@@ -18060,9 +18055,7 @@ var Rf = class {
18060
18055
  case "deleteContentBackward":
18061
18056
  a === o && --c;
18062
18057
  break;
18063
- case "deleteContentForward":
18064
- a === o && (l += 1);
18065
- break;
18058
+ case "deleteContentForward": a === o && (l += 1);
18066
18059
  }
18067
18060
  e.preventDefault(), this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
18068
18061
  source: this,
@@ -18908,9 +18901,7 @@ var Rf = class {
18908
18901
  case U.FREETEXT_SIZE:
18909
18902
  e._defaultFontSize = n;
18910
18903
  break;
18911
- case U.FREETEXT_COLOR:
18912
- e._defaultColor = n;
18913
- break;
18904
+ case U.FREETEXT_COLOR: e._defaultColor = n;
18914
18905
  }
18915
18906
  }
18916
18907
  updateParams(e, t) {
@@ -18918,9 +18909,7 @@ var Rf = class {
18918
18909
  case U.FREETEXT_SIZE:
18919
18910
  this.#a(t);
18920
18911
  break;
18921
- case U.FREETEXT_COLOR:
18922
- this.#o(t);
18923
- break;
18912
+ case U.FREETEXT_COLOR: this.#o(t);
18924
18913
  }
18925
18914
  }
18926
18915
  static get defaultPropertiesToUpdate() {
@@ -18992,7 +18981,7 @@ var Rf = class {
18992
18981
  let t = [];
18993
18982
  this.editorDiv.normalize();
18994
18983
  let n = null;
18995
- for (let r of this.editorDiv.childNodes) n?.nodeType === Node.TEXT_NODE && r.nodeName === "BR" || (t.push(e.#l(r)), n = r);
18984
+ for (let r of this.editorDiv.childNodes) (n?.nodeType !== Node.TEXT_NODE || r.nodeName !== "BR") && (t.push(e.#l(r)), n = r);
18996
18985
  return t.join("\n");
18997
18986
  }
18998
18987
  #c() {
@@ -19077,9 +19066,7 @@ var Rf = class {
19077
19066
  case 180:
19078
19067
  d = e - this.width + (i[0] - l) / s, f = t - (i[1] - u) / c, [a, o] = [-a, -o];
19079
19068
  break;
19080
- case 270:
19081
- d = e + (i[0] - l - this.height * c) / s, f = t + (i[1] - u - this.width * s) / c, [a, o] = [-o, a];
19082
- break;
19069
+ case 270: d = e + (i[0] - l - this.height * c) / s, f = t + (i[1] - u - this.width * s) / c, [a, o] = [-o, a];
19083
19070
  }
19084
19071
  this.setAt(d * n, f * r, a, o);
19085
19072
  } else this.setAt(e * n, t * r, this.width * n, this.height * r);
@@ -19491,9 +19478,7 @@ var Rf = class {
19491
19478
  case 180:
19492
19479
  s = $._rescale(this.#o, n, t, -a, o), c = $._rescale(this.#i, n, t, -a, o);
19493
19480
  break;
19494
- case 270:
19495
- s = $._rescaleAndSwap(this.#o, n, r, -a, -o), c = $._rescaleAndSwap(this.#i, n, r, -a, -o);
19496
- break;
19481
+ case 270: s = $._rescaleAndSwap(this.#o, n, r, -a, -o), c = $._rescaleAndSwap(this.#i, n, r, -a, -o);
19497
19482
  }
19498
19483
  return {
19499
19484
  outline: Array.from(s),
@@ -19999,9 +19984,7 @@ var Rf = class {
19999
19984
  case U.HIGHLIGHT_DEFAULT_COLOR:
20000
19985
  e._defaultColor = n;
20001
19986
  break;
20002
- case U.HIGHLIGHT_THICKNESS:
20003
- e._defaultThickness = n;
20004
- break;
19987
+ case U.HIGHLIGHT_THICKNESS: e._defaultThickness = n;
20005
19988
  }
20006
19989
  }
20007
19990
  translateInPage(e, t) {}
@@ -20013,9 +19996,7 @@ var Rf = class {
20013
19996
  case U.HIGHLIGHT_COLOR:
20014
19997
  this.#b(t);
20015
19998
  break;
20016
- case U.HIGHLIGHT_THICKNESS:
20017
- this.#x(t);
20018
- break;
19999
+ case U.HIGHLIGHT_THICKNESS: this.#x(t);
20019
20000
  }
20020
20001
  }
20021
20002
  static get defaultPropertiesToUpdate() {
@@ -20196,9 +20177,7 @@ var Rf = class {
20196
20177
  this.#D(!0);
20197
20178
  break;
20198
20179
  case 1:
20199
- case 3:
20200
- this.#D(!1);
20201
- break;
20180
+ case 3: this.#D(!1);
20202
20181
  }
20203
20182
  }
20204
20183
  #D(e) {
@@ -20541,7 +20520,7 @@ var Rf = class {
20541
20520
  this._drawId === null || !this.parent || (this.parent.drawLayer.remove(this._drawId), this._drawId = null, this._drawingOptions.reset());
20542
20521
  }
20543
20522
  #f(e = this.parent) {
20544
- if (!(this._drawId !== null && this.parent === e)) {
20523
+ if (this._drawId === null || this.parent !== e) {
20545
20524
  if (this._drawId !== null) {
20546
20525
  this.parent.drawLayer.updateParent(this._drawId, e.drawLayer);
20547
20526
  return;
@@ -21006,9 +20985,7 @@ var Rf = class {
21006
20985
  case 180:
21007
20986
  y = $._rescale, d = e + n, f = t, p = -n, m = r, h = e + (1 - s - l) * n, g = t + c * r, _ = e + (1 - s) * n, v = t + (c + u) * r;
21008
20987
  break;
21009
- case 270:
21010
- y = $._rescaleAndSwap, d = e + n, f = t + r, p = -n, m = -r, h = e + (1 - c - u) * n, g = t + (1 - s - l) * r, _ = e + (1 - c) * n, v = t + (1 - s) * r;
21011
- break;
20988
+ case 270: y = $._rescaleAndSwap, d = e + n, f = t + r, p = -n, m = -r, h = e + (1 - c - u) * n, g = t + (1 - s - l) * r, _ = e + (1 - c) * n, v = t + (1 - s) * r;
21012
20989
  }
21013
20990
  for (let { line: e, points: t } of this.#r) a.push(y(e, d, f, p, m, i ? Array(e.length) : null)), o.push(y(t, d, f, p, m, i ? Array(t.length) : null));
21014
20991
  return {
@@ -21034,9 +21011,7 @@ var Rf = class {
21034
21011
  case 180:
21035
21012
  h = $._rescale, d = t / r + 1, f = -n / i, p = -1 / r, m = 1 / i;
21036
21013
  break;
21037
- case 270:
21038
- h = $._rescaleAndSwap, d = n / i + 1, f = t / r + 1, p = -1 / i, m = -1 / r;
21039
- break;
21014
+ case 270: h = $._rescaleAndSwap, d = n / i + 1, f = t / r + 1, p = -1 / i, m = -1 / r;
21040
21015
  }
21041
21016
  if (!o) {
21042
21017
  o = [];
@@ -21821,8 +21796,8 @@ var Rf = class {
21821
21796
  if (e.serialize() !== null) {
21822
21797
  t.set(e.annotationElementId, e);
21823
21798
  continue;
21824
- } else n.set(e.annotationElementId, e);
21825
- this.getEditableAnnotation(e.annotationElementId)?.show(), e.remove();
21799
+ }
21800
+ n.set(e.annotationElementId, e), this.getEditableAnnotation(e.annotationElementId)?.show(), e.remove();
21826
21801
  }
21827
21802
  if (this.#n) {
21828
21803
  let e = this.#n.getEditableAnnotations();
@@ -22258,7 +22233,7 @@ function Vp(e, t) {
22258
22233
  async function Hp({ data: e, password: t, id: n, page: r, units: i, scale: a }) {
22259
22234
  let o = new Worker(new URL(
22260
22235
  /* @vite-ignore */
22261
- "" + new URL("assets/pdfjs.worker-635tbwI0.js", import.meta.url).href,
22236
+ "" + new URL("assets/pdfjs.worker-QHzJtIzr.js", import.meta.url).href,
22262
22237
  "" + import.meta.url
22263
22238
  ), { type: "module" });
22264
22239
  try {
@@ -22270,27 +22245,30 @@ async function Hp({ data: e, password: t, id: n, page: r, units: i, scale: a })
22270
22245
  units: i,
22271
22246
  scale: a
22272
22247
  }), await new Promise((e, t) => {
22273
- let r = (i) => {
22248
+ let r = () => {
22249
+ o.removeEventListener("message", i), o.removeEventListener("error", a);
22250
+ }, i = (i) => {
22274
22251
  if (i.data.status) {
22275
- if (i.data.status === "success") {
22252
+ if (r(), i.data.status === "success") {
22276
22253
  let { bitmap: t, width: r, height: a, pages: o } = i.data;
22277
22254
  if (t && n) {
22278
22255
  let n = document.createElement("canvas"), i = n.getContext("2d");
22279
- n.width = r, n.height = a, i?.drawImage(t, 0, 0), t.close(), e({
22256
+ return n.width = r, n.height = a, i?.drawImage(t, 0, 0), t.close(), e({
22280
22257
  pages: o,
22281
22258
  canvas: n
22282
22259
  });
22283
- } else e({
22260
+ }
22261
+ return e({
22284
22262
  pages: o,
22285
22263
  canvas: null
22286
22264
  });
22287
22265
  }
22288
- i.data.status === "error" && t(i.data.error), o.removeEventListener("message", r);
22266
+ if (i.data.status === "error") return t(i.data.error);
22289
22267
  }
22268
+ }, a = (e) => {
22269
+ r(), t(/* @__PURE__ */ Error(`Worker error: ${e.message}`));
22290
22270
  };
22291
- o.addEventListener("message", r), o.addEventListener("error", (e) => {
22292
- t(/* @__PURE__ */ Error(`Worker error: ${e.message}`));
22293
- }, { once: !0 });
22271
+ o.addEventListener("message", i), o.addEventListener("error", a, { once: !0 });
22294
22272
  });
22295
22273
  } finally {
22296
22274
  o.terminate();