@file-viewer/vue3 3.1.1 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.en.md +3 -425
  2. package/README.md +3 -428
  3. package/dist/components/export.js +78 -78
  4. package/dist/components/export2.js +377 -357
  5. package/dist/components/fit.js +153 -93
  6. package/dist/components/image.js +49 -53
  7. package/dist/components/objectSpread2.js +6 -6
  8. package/dist/components/print-mask.js +4 -12
  9. package/dist/components/printMask.js +2 -5
  10. package/dist/index.mjs +1838 -1602
  11. package/dist/src/package/browser/printLayout.d.ts +0 -4
  12. package/dist/src/package/common/type.d.ts +6 -172
  13. package/dist/src/package/components/FileViewer/FileViewer.vue.d.ts +7 -5
  14. package/dist/src/package/components/FileViewer/ShadowFileViewer.vue.d.ts +7 -5
  15. package/dist/src/package/components/FileViewer/exportDocumentTemplate.d.ts +0 -8
  16. package/dist/src/package/components/FileViewer/hooks/useLoading.d.ts +2 -8
  17. package/dist/src/package/components/FileViewer/hooks/useViewerDocumentFeatures.d.ts +0 -6
  18. package/dist/src/package/components/FileViewer/hooks/useViewerLifecycle.d.ts +0 -6
  19. package/dist/src/package/components/FileViewer/hooks/useViewerPresentation.d.ts +0 -6
  20. package/dist/src/package/components/FileViewer/hooks/useViewerPreviewLifecycle.d.ts +0 -6
  21. package/dist/src/package/components/FileViewer/hooks/useViewerPublicApi.d.ts +0 -6
  22. package/dist/src/package/components/FileViewer/hooks/useViewerRenderSurface.d.ts +2 -8
  23. package/dist/src/package/components/FileViewer/hooks/useViewerSourceLoading.d.ts +1 -7
  24. package/dist/src/package/components/FileViewer/hooks/useViewerToolbar.d.ts +0 -6
  25. package/dist/src/package/components/FileViewer/hooks/useViewerViewState.d.ts +0 -6
  26. package/dist/src/package/components/FileViewer/hooks/useViewerZoom.d.ts +3 -8
  27. package/dist/src/package/components/FileViewer/index.d.ts +1 -1
  28. package/dist/src/package/components/FileViewer/rendererBridge.d.ts +0 -8
  29. package/dist/src/package/index.d.ts +6 -10
  30. package/dist/src/package/native.d.ts +1 -8
  31. package/dist/src/package/vendors/nestedRender.d.ts +0 -7
  32. package/dist/vue3.css +1 -1
  33. package/package.json +53 -25
@@ -108,24 +108,14 @@ var n = (e = {}) => {
108
108
  }
109
109
  if (!n) return null;
110
110
  let i = n.getBoundingClientRect(), a = e.getBoundingClientRect().top - i.top + n.scrollTop, o = null;
111
- for (let e of t) {
112
- if (e.top <= a + 1) {
113
- o = e;
114
- continue;
115
- }
116
- break;
117
- }
111
+ for (let e of t) if (e.top <= a + 1) o = e;
112
+ else break;
118
113
  return o;
119
114
  }, v = (e, t) => {
120
115
  if (!e || !t.length) return null;
121
116
  let n = e.scrollTop + e.clientHeight * .42, r = t[0];
122
- for (let e of t) {
123
- if (e.top <= n) {
124
- r = e;
125
- continue;
126
- }
127
- break;
128
- }
117
+ for (let e of t) if (e.top <= n) r = e;
118
+ else break;
129
119
  return r;
130
120
  }, y = (e, t) => {
131
121
  if (!e || t == null) return !1;
@@ -171,7 +161,72 @@ var n = (e = {}) => {
171
161
  if (t && (!C(e) || e.dataset.viewerViewStateProvider !== "generic")) return t;
172
162
  let n = w(e, "[data-viewer-view-state-provider]"), r = n.find((e) => e.dataset.viewerViewStateProvider !== "generic"), i = n.find((e) => e.dataset.viewerViewStateProvider === "generic"), a = r || i;
173
163
  return a ? S.get(a) || a.__flyfishViewerViewStateProvider || null : t || null;
174
- }, M = (e) => ({
164
+ };
165
+ //#endregion
166
+ //#region ../../core/dist/features/document/zoomGestures.js
167
+ function M(t, n) {
168
+ let r = t.ownerDocument.defaultView;
169
+ if (!r) return () => {};
170
+ let i = !1, a = 0, o = !1, s = null, c = null, l = null, u = (e) => {
171
+ let t = n.settings();
172
+ return t !== !1 && (typeof t != "object" || t[e] !== !1) && n.enabled();
173
+ }, d = (e) => e.composedPath().some((e) => e instanceof r.Element && e.matches("button,a[href],input,textarea,select,[contenteditable]:not([contenteditable=\"false\"])")), f = (e, t) => {
174
+ var n, r;
175
+ let i = t.getState();
176
+ return Math.min((n = i.maxScale) == null ? 4 : n, Math.max((r = i.minScale) == null ? .1 : r, e));
177
+ }, p = () => {
178
+ !i && !o && !a && s !== null && (a = r.requestAnimationFrame(() => {
179
+ a = 0, m();
180
+ }));
181
+ }, m = function() {
182
+ var t = e(function* () {
183
+ let e = s, t = c;
184
+ if (s = null, c = null, i || !n.enabled() || e === null || !(t != null && t.setZoom) || t !== n.provider()) return;
185
+ let r = e >= t.getState().scale ? "zoom-in" : "zoom-out";
186
+ o = !0;
187
+ try {
188
+ if (!(yield n.beforeZoom(r)) || i || !n.enabled() || t !== n.provider()) return;
189
+ yield t.setZoom(f(e, t)), !i && t === n.provider() && n.onZoom();
190
+ } catch (e) {} finally {
191
+ o = !1, p();
192
+ }
193
+ });
194
+ return function() {
195
+ return t.apply(this, arguments);
196
+ };
197
+ }(), h = (e, t) => {
198
+ s = f(e, t), c = t, p();
199
+ }, g = (e) => {
200
+ if (e.defaultPrevented || !u("wheel") || !(e.ctrlKey || e.metaKey) || d(e) || !Number.isFinite(e.deltaY) || e.deltaY === 0) return;
201
+ let r = n.provider();
202
+ if (!(r != null && r.setZoom)) return;
203
+ let i = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? Math.max(1, t.clientHeight) : 1, a = c === r && s !== null ? s : r.getState().scale;
204
+ h(a * Math.exp(-Math.max(-1e3, Math.min(1e3, e.deltaY * i)) * .002), r), e.preventDefault();
205
+ }, _ = (e) => Math.hypot(e[0].clientX - e[1].clientX, e[0].clientY - e[1].clientY), v = (e) => {
206
+ if (e.defaultPrevented || e.touches.length !== 2 || !u("pinch") || d(e)) return;
207
+ let t = n.provider(), r = _(e.touches);
208
+ !(t != null && t.setZoom) || !Number.isFinite(r) || r <= 0 || (l = {
209
+ distance: r,
210
+ scale: t.getState().scale,
211
+ provider: t
212
+ }, e.preventDefault());
213
+ }, y = (e) => {
214
+ if (!l || e.touches.length !== 2 || !u("pinch") || l.provider !== n.provider()) {
215
+ l = null;
216
+ return;
217
+ }
218
+ let t = _(e.touches);
219
+ !Number.isFinite(t) || t <= 0 || (h(l.scale * t / l.distance, l.provider), e.preventDefault());
220
+ }, b = (e) => {
221
+ e.touches.length !== 2 && (l = null);
222
+ };
223
+ return t.addEventListener("wheel", g, { passive: !1 }), t.addEventListener("touchstart", v, { passive: !1 }), t.addEventListener("touchmove", y, { passive: !1 }), t.addEventListener("touchend", b), t.addEventListener("touchcancel", b), () => {
224
+ i = !0, s = null, c = null, l = null, a && r.cancelAnimationFrame(a), t.removeEventListener("wheel", g), t.removeEventListener("touchstart", v), t.removeEventListener("touchmove", y), t.removeEventListener("touchend", b), t.removeEventListener("touchcancel", b);
225
+ };
226
+ }
227
+ //#endregion
228
+ //#region ../../core/dist/features/document/zoom.js
229
+ var N = (e) => ({
175
230
  scale: e.scale,
176
231
  label: e.label,
177
232
  canZoomIn: e.canZoomIn,
@@ -179,19 +234,19 @@ var n = (e = {}) => {
179
234
  canReset: e.canReset,
180
235
  minScale: e.minScale,
181
236
  maxScale: e.maxScale
182
- }), N = (e, t) => {
237
+ }), P = (e, t) => {
183
238
  let r = n(t || {});
184
239
  return e.scale = r.scale, e.label = r.label, e.canZoomIn = r.canZoomIn, e.canZoomOut = r.canZoomOut, e.canReset = r.canReset, e.minScale = r.minScale, e.maxScale = r.maxScale, e;
185
- }, P = (e) => M(e);
240
+ }, F = (e) => N(e);
186
241
  (function() {
187
242
  var t = e(function* (e, t) {
188
- return N(e, yield t()), P(e);
243
+ return P(e, yield t()), F(e);
189
244
  });
190
245
  return function(e, n) {
191
246
  return t.apply(this, arguments);
192
247
  };
193
248
  })();
194
- var F = () => {
249
+ var I = () => {
195
250
  let e = /* @__PURE__ */ new Set();
196
251
  return {
197
252
  emit() {
@@ -206,33 +261,33 @@ var F = () => {
206
261
  e.clear();
207
262
  }
208
263
  };
209
- }, I = (e) => {
264
+ }, L = (e) => {
210
265
  var t, n;
211
266
  return ((n = (t = e == null ? void 0 : e.ownerDocument) == null ? void 0 : t.defaultView) == null ? void 0 : n.MutationObserver) || (typeof MutationObserver < "u" ? MutationObserver : void 0);
212
- }, L = ({ root: t, enabled: r, beforeZoom: i, onChange: a }) => {
213
- let o = null, s = null, c = null, l = !1, u = n(), d = () => {
214
- a == null || a(M(u));
215
- }, f = () => {
216
- s == null || s(), s = null, o = null, N(u, null);
217
- }, p = () => {
267
+ }, R = ({ root: t, enabled: r, gestures: i, beforeZoom: a, onChange: o }) => {
268
+ let s = null, c = null, l = null, u = null, d = !1, f = n(), p = () => {
269
+ o == null || o(N(f));
270
+ }, m = () => {
271
+ c == null || c(), c = null, s = null, P(f, null);
272
+ }, h = () => {
218
273
  var e, n;
219
- if ((r == null ? void 0 : r()) === !1) return f(), null;
274
+ if ((r == null ? void 0 : r()) === !1) return m(), null;
220
275
  let i = O(t());
221
- return i !== o && (s == null || s(), o = i, s = ((e = i == null ? void 0 : i.subscribe) == null ? void 0 : e.call(i, () => {
222
- N(u, i.getState()), l || d();
223
- })) || null), N(u, ((n = i == null ? void 0 : i.getState) == null ? void 0 : n.call(i)) || null), i;
224
- }, m = () => {
225
- c == null || c.disconnect(), c = null;
226
- }, h = function() {
276
+ return i !== s && (c == null || c(), s = i, c = ((e = i == null ? void 0 : i.subscribe) == null ? void 0 : e.call(i, () => {
277
+ P(f, i.getState()), d || p();
278
+ })) || null), P(f, ((n = i == null ? void 0 : i.getState) == null ? void 0 : n.call(i)) || null), i;
279
+ }, g = () => {
280
+ l == null || l.disconnect(), l = null, u == null || u(), u = null;
281
+ }, _ = function() {
227
282
  var t = e(function* (e, t) {
228
- let n = p();
229
- if (!n || i && (yield i(e)) === !1) return M(u);
230
- l = !0;
283
+ let n = h();
284
+ if (!n || a && (yield a(e)) === !1) return N(f);
285
+ d = !0;
231
286
  try {
232
287
  let e = yield t(n);
233
- return N(u, e || n.getState()), M(u);
288
+ return P(f, e || n.getState()), N(f);
234
289
  } finally {
235
- l = !1;
290
+ d = !1;
236
291
  }
237
292
  });
238
293
  return function(e, n) {
@@ -241,39 +296,48 @@ var F = () => {
241
296
  }();
242
297
  return {
243
298
  get provider() {
244
- return o;
299
+ return s;
245
300
  },
246
- state: u,
301
+ state: f,
247
302
  hasProvider() {
248
- return !!p();
303
+ return !!h();
249
304
  },
250
- refreshProvider: p,
305
+ refreshProvider: h,
251
306
  observe() {
252
- m();
253
- let e = t(), n = I(e);
254
- if (!e || !n) {
255
- p();
256
- return;
257
- }
258
- c = new n(() => {
259
- p();
260
- }), c.observe(e, {
307
+ g();
308
+ let e = t();
309
+ e && (u = M(e, {
310
+ provider: h,
311
+ enabled: () => (r == null ? void 0 : r()) !== !1,
312
+ settings: () => i == null ? void 0 : i(),
313
+ beforeZoom: (e) => {
314
+ var t;
315
+ return (t = a == null ? void 0 : a(e)) == null || t;
316
+ },
317
+ onZoom: () => {
318
+ h(), p();
319
+ }
320
+ }));
321
+ let n = L(e);
322
+ !e || !n || (l = new n(() => {
323
+ h();
324
+ }), l.observe(e, {
261
325
  childList: !0,
262
326
  subtree: !0
263
- }), p();
327
+ })), h();
264
328
  },
265
- clearProvider: f,
329
+ clearProvider: m,
266
330
  getState() {
267
- return M(u);
331
+ return N(f);
268
332
  },
269
- zoomIn: () => h("zoom-in", (e) => e.zoomIn()),
270
- zoomOut: () => h("zoom-out", (e) => e.zoomOut()),
271
- resetZoom: () => h("zoom-reset", (e) => e.resetZoom()),
333
+ zoomIn: () => _("zoom-in", (e) => e.zoomIn()),
334
+ zoomOut: () => _("zoom-out", (e) => e.zoomOut()),
335
+ resetZoom: () => _("zoom-reset", (e) => e.resetZoom()),
272
336
  destroy() {
273
- m(), f();
337
+ g(), m();
274
338
  }
275
339
  };
276
- }, R = [
340
+ }, z = [
277
341
  "auto",
278
342
  "contain",
279
343
  "cover",
@@ -281,36 +345,36 @@ var F = () => {
281
345
  "height",
282
346
  "actual",
283
347
  "scale-down"
284
- ], z = [
348
+ ], B = [
285
349
  "until-interaction",
286
350
  "always",
287
351
  "initial"
288
- ], B = "until-interaction", V = 0, H = 8, U = (e) => !!e && typeof e == "object" && !Array.isArray(e), W = (e) => typeof e == "string" && R.includes(e), G = (e) => typeof e == "string" && z.includes(e), K = (e) => {
352
+ ], V = "until-interaction", H = 0, U = 8, W = (e) => !!e && typeof e == "object" && !Array.isArray(e), G = (e) => typeof e == "string" && z.includes(e), K = (e) => typeof e == "string" && B.includes(e), q = (e) => {
289
353
  let t = Number(e);
290
354
  return Number.isFinite(t) && t > 0 ? t : void 0;
291
- }, q = (e) => {
292
- let t = Number(e);
293
- return Number.isFinite(t) && t > 0 ? t : V;
294
355
  }, J = (e) => {
356
+ let t = Number(e);
357
+ return Number.isFinite(t) && t > 0 ? t : H;
358
+ }, Y = (e) => {
295
359
  if (e == null || e === !1) return null;
296
- if (W(e)) return {
360
+ if (G(e)) return {
297
361
  mode: e,
298
- resize: B,
299
- padding: V
362
+ resize: V,
363
+ padding: H
300
364
  };
301
- if (!U(e)) return null;
302
- let t = K(e.minScale), n = K(e.maxScale), r = t !== void 0 && n !== void 0 && n < t ? t : n;
365
+ if (!W(e)) return null;
366
+ let t = q(e.minScale), n = q(e.maxScale), r = t !== void 0 && n !== void 0 && n < t ? t : n;
303
367
  return {
304
- mode: W(e.mode) ? e.mode : "auto",
305
- resize: G(e.resize) ? e.resize : B,
306
- padding: q(e.padding),
368
+ mode: G(e.mode) ? e.mode : "auto",
369
+ resize: K(e.resize) ? e.resize : V,
370
+ padding: J(e.padding),
307
371
  minScale: t,
308
372
  maxScale: r
309
373
  };
310
- }, Y = (e, t, n) => {
374
+ }, X = (e, t, n) => {
311
375
  let r = e;
312
376
  return Number.isFinite(t) && (r = Math.max(Number(t), r)), Number.isFinite(n) && (r = Math.min(Number(n), r)), r;
313
- }, X = ({ mode: e, viewportWidth: t, viewportHeight: n, contentWidth: r, contentHeight: i, minScale: a, maxScale: o }) => {
377
+ }, Z = ({ mode: e, viewportWidth: t, viewportHeight: n, contentWidth: r, contentHeight: i, minScale: a, maxScale: o }) => {
314
378
  if (t <= 0 || n <= 0 || r <= 0 || i <= 0) return;
315
379
  let s = t / r, c = n / i, l = Math.min(s, c), u = Math.max(s, c), d = (() => {
316
380
  switch (e) {
@@ -322,8 +386,8 @@ var F = () => {
322
386
  default: return l;
323
387
  }
324
388
  })();
325
- if (!(!Number.isFinite(d) || d <= 0)) return Y(d, a, o);
326
- }, Z = (e) => {
389
+ if (!(!Number.isFinite(d) || d <= 0)) return X(d, a, o);
390
+ }, ee = (e) => {
327
391
  var t, n;
328
392
  if (!e) return !1;
329
393
  let r = Number((t = e.scale) == null ? (n = e.zoom) == null ? void 0 : n.scale : t);
@@ -354,14 +418,14 @@ var F = () => {
354
418
  reason: e == null ? void 0 : e.reason,
355
419
  provider: (e == null ? void 0 : e.provider) || n,
356
420
  state: e == null ? void 0 : e.state
357
- }), ee = (e) => e === "pending" || e === "retry" || e === "image-not-ready" || e === "unmeasurable", te = (e) => {
421
+ }), te = (e) => e === "pending" || e === "retry" || e === "image-not-ready" || e === "unmeasurable", ne = (e) => {
358
422
  var t;
359
423
  let n = (t = e.getBoundingClientRect) == null ? void 0 : t.call(e);
360
424
  return {
361
425
  width: Math.max(0, (n == null ? void 0 : n.width) || e.clientWidth || 0),
362
426
  height: Math.max(0, (n == null ? void 0 : n.height) || e.clientHeight || 0)
363
427
  };
364
- }, ne = ({ root: n, enabled: r, getFit: i = () => void 0, onFit: a }) => {
428
+ }, re = ({ root: n, enabled: r, getFit: i = () => void 0, onFit: a }) => {
365
429
  let o = null, s = null, c = null, l = !1, u = 0, d = () => {
366
430
  var e;
367
431
  let t = n();
@@ -374,9 +438,9 @@ var F = () => {
374
438
  c && clearTimeout(c), c = null;
375
439
  }, m = (e, t) => {
376
440
  let n = e === void 0 ? i() : e;
377
- return n == null ? t === "api" ? J("auto") : null : J(n);
441
+ return n == null ? t === "api" ? Y("auto") : null : Y(n);
378
442
  }, h = (e, t, n) => {
379
- u >= H || (p(), u += 1, c = setTimeout(() => {
443
+ u >= U || (p(), u += 1, c = setTimeout(() => {
380
444
  c = null, g(e, {
381
445
  source: t,
382
446
  reason: n === "api" ? "api" : "retry"
@@ -388,7 +452,7 @@ var F = () => {
388
452
  if (!c) return {
389
453
  applied: !1,
390
454
  mode: "auto",
391
- resize: B,
455
+ resize: V,
392
456
  source: o,
393
457
  reason: "not-configured",
394
458
  provider: "none"
@@ -396,7 +460,7 @@ var F = () => {
396
460
  if ((r == null ? void 0 : r()) === !1) return Q(c, "disabled", o);
397
461
  let l = n();
398
462
  if (!l) return h(e, o, s), Q(c, "no-root", o);
399
- let d = te(l);
463
+ let d = ne(l);
400
464
  if (d.width <= 0 || d.height <= 0) return h(e, o, s), Q(c, "zero-size", o);
401
465
  let f = t(t({}, c), {}, {
402
466
  source: o,
@@ -417,13 +481,13 @@ var F = () => {
417
481
  g = e;
418
482
  }
419
483
  let v = Q(c, p || _ ? "unsupported" : "no-provider", o);
420
- return (v.reason === "no-provider" || ee(g == null ? void 0 : g.reason)) && h(e, o, s), v;
484
+ return (v.reason === "no-provider" || te(g == null ? void 0 : g.reason)) && h(e, o, s), v;
421
485
  });
422
486
  return function(e) {
423
487
  return i.apply(this, arguments);
424
488
  };
425
489
  }(), _ = (e = "resize") => {
426
- let t = J(i());
490
+ let t = Y(i());
427
491
  if (!t || t.resize === "initial" || t.resize === "until-interaction" && l) return;
428
492
  f();
429
493
  let n = d(), r = () => {
@@ -432,16 +496,12 @@ var F = () => {
432
496
  reason: e
433
497
  });
434
498
  };
435
- if (n != null && n.requestAnimationFrame) {
436
- s = n.requestAnimationFrame(r);
437
- return;
438
- }
439
- s = setTimeout(r, 16);
499
+ s = n != null && n.requestAnimationFrame ? n.requestAnimationFrame(r) : setTimeout(r, 16);
440
500
  }, v = () => {
441
501
  f(), o == null || o.disconnect(), o = null;
442
502
  };
443
503
  return {
444
- normalize: J,
504
+ normalize: Y,
445
505
  fit: function() {
446
506
  var t = e(function* (e, t) {
447
507
  return p(), l = !1, g(e, {
@@ -455,7 +515,7 @@ var F = () => {
455
515
  }(),
456
516
  applyInitialFit: function() {
457
517
  var t = e(function* (e = {}) {
458
- return p(), u = 0, l = !1, e.skip ? Q(J(i()) || J("auto"), "initial-view-state", "initial") : g(void 0, {
518
+ return p(), u = 0, l = !1, e.skip ? Q(Y(i()) || Y("auto"), "initial-view-state", "initial") : g(void 0, {
459
519
  source: "initial",
460
520
  reason: "initial"
461
521
  });
@@ -469,7 +529,7 @@ var F = () => {
469
529
  var e, t;
470
530
  v();
471
531
  let r = n(), i = ((t = (e = r == null ? void 0 : r.ownerDocument) == null ? void 0 : e.defaultView) == null ? void 0 : t.ResizeObserver) || (typeof ResizeObserver < "u" ? ResizeObserver : void 0);
472
- !r || !i || (o = new i(() => _("resize")), o.observe(r));
532
+ r && i && (o = new i(() => _("resize")), o.observe(r));
473
533
  },
474
534
  markUserInteraction() {
475
535
  l = !0, p();
@@ -483,4 +543,4 @@ var F = () => {
483
543
  };
484
544
  };
485
545
  //#endregion
486
- export { o as _, L as a, O as c, A as d, D as f, y as g, v as h, F as i, k as l, _ as m, Z as n, T as o, g as p, X as r, j as s, ne as t, E as u, i as v, r as y };
546
+ export { o as _, R as a, O as c, A as d, D as f, y as g, v as h, I as i, k as l, _ as m, ee as n, T as o, g as p, Z as r, j as s, re as t, E as u, i as v, r as y };
@@ -27,11 +27,7 @@ var o = {
27
27
  r.onload = (e) => {
28
28
  var r;
29
29
  let i = (r = e.target) == null ? void 0 : r.result;
30
- if (typeof i == "string") {
31
- t(i);
32
- return;
33
- }
34
- n(/* @__PURE__ */ Error("Unable to read image data URL."));
30
+ typeof i == "string" ? t(i) : n(/* @__PURE__ */ Error("Unable to read image data URL."));
35
31
  }, r.onerror = () => n(r.error || /* @__PURE__ */ Error("Unable to read image data URL.")), r.readAsDataURL(e);
36
32
  });
37
33
  });
@@ -77,53 +73,53 @@ function m(e, t, n, r) {
77
73
  function h() {
78
74
  return h = e(function* (e, o, s, u) {
79
75
  var m, h;
80
- let g = a(u == null ? void 0 : u.options), _ = o.ownerDocument || document, v = yield d(e, s);
76
+ let g = a(u == null ? void 0 : u.options), _ = o.ownerDocument || document, v = _.defaultView, y = yield d(e, s);
81
77
  (m = u == null ? void 0 : u.registerThumbnailAdapter) == null || m.call(u, { capture: () => new Blob([e], { type: l(s) }) });
82
- let y = 1, b = 1, x = 1, S = 0, C = n(), w = _.createElement("div");
83
- w.className = "image-viewer", w.dataset.viewerZoomProvider = "image";
84
- let T = _.createElement("div");
85
- T.className = "image-stage";
86
- let E = _.createElement("img");
87
- E.alt = g("image.alt"), E.src = v, E.tabIndex = 0, E.setAttribute("role", "button"), E.setAttribute("aria-haspopup", "dialog"), T.append(E), w.append(T);
88
- let D = p(_, v, g), O = () => D.open(E), k = (e) => {
89
- (e.key === "Enter" || e.key === " ") && (e.preventDefault(), D.open(E));
78
+ let b = 1, x = 1, S = 1, C = 0, w = null, T = !1, E = n(), D = _.createElement("div");
79
+ D.className = "image-viewer", D.dataset.viewerZoomProvider = "image";
80
+ let O = _.createElement("div");
81
+ O.className = "image-stage";
82
+ let k = _.createElement("img");
83
+ k.alt = g("image.alt"), k.src = y, k.tabIndex = 0, k.setAttribute("role", "button"), k.setAttribute("aria-haspopup", "dialog"), O.append(k), D.append(O);
84
+ let A = p(_, y, g), j = () => A.open(k), M = (e) => {
85
+ (e.key === "Enter" || e.key === " ") && (e.preventDefault(), A.open(k));
90
86
  };
91
- E.addEventListener("click", O), E.addEventListener("keydown", k);
92
- let A = () => Math.min(.1, b || .1), j = (e) => {
93
- let t = A();
87
+ k.addEventListener("click", j), k.addEventListener("keydown", M);
88
+ let N = () => Math.min(.1, x || .1), P = (e) => {
89
+ let t = N();
94
90
  return Math.min(5, Math.max(t, f(e)));
95
- }, M = () => {
96
- let e = E.naturalWidth || 0, t = E.naturalHeight || 0;
91
+ }, F = () => {
92
+ let e = k.naturalWidth || 0, t = k.naturalHeight || 0;
97
93
  if (!e || !t) return 1;
98
- let n = Math.max((w.clientWidth || 0) - 48, 1), r = Math.max((w.clientHeight || S || 0) - 48, 1);
94
+ let n = Math.max((D.clientWidth || 0) - 48, 1), r = Math.max((D.clientHeight || C || 0) - 48, 1);
99
95
  return Math.min(1, n / e, r / t);
100
- }, N = () => {
101
- if (b = M(), x = j(b * y), E.naturalWidth && E.naturalHeight) {
102
- E.style.width = `${Math.max(1, Math.round(E.naturalWidth * x))}px`, E.style.height = `${Math.max(1, Math.round(E.naturalHeight * x))}px`;
103
- return;
104
- }
105
- E.style.width = "auto", E.style.height = S > 0 ? `${Math.max(1, Math.round(S * y))}px` : `${y * 100}%`;
106
- }, P = () => {
107
- S = w.clientHeight || 0, N(), C.emit();
108
- }, F = new ResizeObserver(P);
109
- F.observe(w), E.addEventListener("load", P);
110
- let I = () => ({
111
- scale: x,
112
- label: `${Math.round(x * 100)}%`,
113
- canZoomIn: x < 5,
114
- canZoomOut: x > A(),
115
- canReset: Math.abs(y - 1) > .001,
116
- minScale: A(),
96
+ }, I = () => {
97
+ x = F(), S = P(x * b), k.naturalWidth && k.naturalHeight ? (k.style.width = `${Math.max(1, Math.round(k.naturalWidth * S))}px`, k.style.height = `${Math.max(1, Math.round(k.naturalHeight * S))}px`) : (k.style.width = "auto", k.style.height = C > 0 ? `${Math.max(1, Math.round(C * b))}px` : `${b * 100}%`);
98
+ }, L = () => {
99
+ C = D.clientHeight || 0, I(), E.emit();
100
+ }, R = new ResizeObserver(() => {
101
+ T || w !== null || (v != null && v.requestAnimationFrame ? w = v.requestAnimationFrame(() => {
102
+ w = null, T || L();
103
+ }) : L());
104
+ });
105
+ R.observe(D), k.addEventListener("load", L);
106
+ let z = () => ({
107
+ scale: S,
108
+ label: `${Math.round(S * 100)}%`,
109
+ canZoomIn: S < 5,
110
+ canZoomOut: S > N(),
111
+ canReset: Math.abs(b - 1) > .001,
112
+ minScale: N(),
117
113
  maxScale: 5
118
- }), L = (e) => (y = j(e) / Math.max(b, .001), N(), C.emit(), I());
119
- return i(w, {
120
- zoomIn: () => L(x + .15),
121
- zoomOut: () => L(x - .15),
122
- resetZoom: () => (y = 1, N(), C.emit(), I()),
123
- setZoom: L,
114
+ }), B = (e) => (b = P(e) / Math.max(x, .001), I(), E.emit(), z());
115
+ return i(D, {
116
+ zoomIn: () => B(S + .15),
117
+ zoomOut: () => B(S - .15),
118
+ resetZoom: () => (b = 1, I(), E.emit(), z()),
119
+ setZoom: B,
124
120
  fit: (e) => {
125
121
  var t, n;
126
- let i = E.naturalWidth || 0, a = E.naturalHeight || 0;
122
+ let i = k.naturalWidth || 0, a = k.naturalHeight || 0;
127
123
  if (!i || !a) return {
128
124
  applied: !1,
129
125
  mode: e.mode,
@@ -134,12 +130,12 @@ function h() {
134
130
  };
135
131
  let o = e.mode === "auto" ? "scale-down" : e.mode, s = r({
136
132
  mode: o,
137
- viewportWidth: Math.max(1, e.viewportWidth || w.clientWidth || 0),
138
- viewportHeight: Math.max(1, e.viewportHeight || w.clientHeight || S || 0),
133
+ viewportWidth: Math.max(1, e.viewportWidth || D.clientWidth || 0),
134
+ viewportHeight: Math.max(1, e.viewportHeight || D.clientHeight || C || 0),
139
135
  contentWidth: i,
140
136
  contentHeight: a,
141
- currentScale: x,
142
- minScale: (t = e.minScale) == null ? A() : t,
137
+ currentScale: S,
138
+ minScale: (t = e.minScale) == null ? N() : t,
143
139
  maxScale: (n = e.maxScale) == null ? 5 : n
144
140
  });
145
141
  if (!s) return {
@@ -150,7 +146,7 @@ function h() {
150
146
  reason: "unmeasurable",
151
147
  provider: "zoom"
152
148
  };
153
- let c = L(s);
149
+ let c = B(s);
154
150
  return {
155
151
  applied: !0,
156
152
  mode: e.mode,
@@ -160,13 +156,13 @@ function h() {
160
156
  provider: "zoom"
161
157
  };
162
158
  },
163
- getState: I,
164
- subscribe: C.subscribe
165
- }), o.replaceChildren(c(_), w), (((h = u == null ? void 0 : u.surface) == null ? void 0 : h.shadowRoot) || o).append(D.element), P(), {
159
+ getState: z,
160
+ subscribe: E.subscribe
161
+ }), o.replaceChildren(c(_), D), (((h = u == null ? void 0 : u.surface) == null ? void 0 : h.shadowRoot) || o).append(A.element), L(), {
166
162
  $el: o,
167
163
  unmount() {
168
164
  var e;
169
- (e = u == null ? void 0 : u.registerThumbnailAdapter) == null || e.call(u, null), t(w), F.disconnect(), E.removeEventListener("load", P), E.removeEventListener("click", O), E.removeEventListener("keydown", k), D.destroy(), o.replaceChildren();
165
+ T = !0, w !== null && (v == null || v.cancelAnimationFrame(w), w = null), (e = u == null ? void 0 : u.registerThumbnailAdapter) == null || e.call(u, null), t(D), R.disconnect(), k.removeEventListener("load", L), k.removeEventListener("click", j), k.removeEventListener("keydown", M), A.destroy(), o.replaceChildren();
170
166
  }
171
167
  };
172
168
  }), h.apply(this, arguments);
@@ -1,4 +1,4 @@
1
- //#region \0@oxc-project+runtime@0.147.0/helpers/esm/asyncToGenerator.js
1
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/asyncToGenerator.js
2
2
  function e(e, t, n, r, i, a, o) {
3
3
  try {
4
4
  var s = e[a](o), c = s.value;
@@ -24,7 +24,7 @@ function t(t) {
24
24
  };
25
25
  }
26
26
  //#endregion
27
- //#region \0@oxc-project+runtime@0.147.0/helpers/esm/typeof.js
27
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
28
28
  function n(e) {
29
29
  "@babel/helpers - typeof";
30
30
  return n = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
@@ -34,7 +34,7 @@ function n(e) {
34
34
  }, n(e);
35
35
  }
36
36
  //#endregion
37
- //#region \0@oxc-project+runtime@0.147.0/helpers/esm/toPrimitive.js
37
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
38
38
  function r(e, t) {
39
39
  if (n(e) != "object" || !e) return e;
40
40
  var r = e[Symbol.toPrimitive];
@@ -46,13 +46,13 @@ function r(e, t) {
46
46
  return (t === "string" ? String : Number)(e);
47
47
  }
48
48
  //#endregion
49
- //#region \0@oxc-project+runtime@0.147.0/helpers/esm/toPropertyKey.js
49
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
50
50
  function i(e) {
51
51
  var t = r(e, "string");
52
52
  return n(t) == "symbol" ? t : t + "";
53
53
  }
54
54
  //#endregion
55
- //#region \0@oxc-project+runtime@0.147.0/helpers/esm/defineProperty.js
55
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
56
56
  function a(e, t, n) {
57
57
  return (t = i(t)) in e ? Object.defineProperty(e, t, {
58
58
  value: n,
@@ -62,7 +62,7 @@ function a(e, t, n) {
62
62
  }) : e[t] = n, e;
63
63
  }
64
64
  //#endregion
65
- //#region \0@oxc-project+runtime@0.147.0/helpers/esm/objectSpread2.js
65
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/objectSpread2.js
66
66
  function o(e, t) {
67
67
  var n = Object.keys(e);
68
68
  if (Object.getOwnPropertySymbols) {
@@ -27,11 +27,7 @@ var a = "\n.fv-print-mask-layer{position:absolute;inset:0;z-index:2147483000;poi
27
27
  }
28
28
  let i = new ((t == null ? void 0 : t.FileReader) || globalThis.FileReader)();
29
29
  i.addEventListener("load", () => {
30
- if (typeof i.result == "string" && i.result.startsWith("data:image/")) {
31
- n(i.result);
32
- return;
33
- }
34
- r(/* @__PURE__ */ Error("Invalid print stamp image"));
30
+ typeof i.result == "string" && i.result.startsWith("data:image/") ? n(i.result) : r(/* @__PURE__ */ Error("Invalid print stamp image"));
35
31
  }), i.addEventListener("error", () => r(i.error || /* @__PURE__ */ Error("Failed to read print stamp image"))), i.readAsDataURL(e);
36
32
  }), d = (a) => {
37
33
  let l = a.root, d = l.ownerDocument, f = n(a.i18n), p = a.color || "#000000", m = [...a.initialRegions || []].map((e) => r(e)).filter((e) => !!e), h = [...a.initialStamps || []].map((e) => i(e)).filter((e) => !!e), g = Array.from(new Set(a.pages || [])).filter((e) => e === l || l.contains(e)), _ = g.length > 0, v = _ ? g : [l];
@@ -125,7 +121,7 @@ var a = "\n.fv-print-mask-layer{position:absolute;inset:0;z-index:2147483000;poi
125
121
  });
126
122
  let l = (e) => {
127
123
  var t;
128
- if (!(!c || c.pointerId !== e.pointerId)) {
124
+ if (c && c.pointerId === e.pointerId) {
129
125
  try {
130
126
  (t = r.releasePointerCapture) == null || t.call(r, c.pointerId);
131
127
  } catch (e) {}
@@ -165,7 +161,7 @@ var a = "\n.fv-print-mask-layer{position:absolute;inset:0;z-index:2147483000;poi
165
161
  } catch (e) {}
166
162
  a = null, M(), r && m.push(r), F();
167
163
  }), e.canvas.addEventListener("pointercancel", () => {
168
- !a || a.surface !== e || (a.preview.remove(), a = null, M(), F());
164
+ a && a.surface === e && (a.preview.remove(), a = null, M(), F());
169
165
  });
170
166
  });
171
167
  let L = () => {
@@ -202,11 +198,7 @@ var a = "\n.fv-print-mask-layer{position:absolute;inset:0;z-index:2147483000;poi
202
198
  })), k.addEventListener("click", () => {
203
199
  m.splice(0, m.length), h.splice(0, h.length), M(), F();
204
200
  }), A.addEventListener("click", () => N(null)), j.addEventListener("click", () => {
205
- if (!m.length && !h.length) {
206
- N(null);
207
- return;
208
- }
209
- N({ mask: t(t(t({}, m.length ? { regions: m.map((e) => t({}, e)) } : {}), h.length ? { stamps: h.map((e) => t({}, e)) } : {}), {}, { color: p }) });
201
+ !m.length && !h.length ? N(null) : N({ mask: t(t(t({}, m.length ? { regions: m.map((e) => t({}, e)) } : {}), h.length ? { stamps: h.map((e) => t({}, e)) } : {}), {}, { color: p }) });
210
202
  }), F();
211
203
  });
212
204
  };