@zinejs/core 0.7.2 → 0.7.3

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.js CHANGED
@@ -245,32 +245,32 @@ var _ = class {
245
245
  };
246
246
  }
247
247
  }, v = "page", y = !1;
248
- function ee() {
248
+ function b() {
249
249
  return y ? !1 : (y = !0, !0);
250
250
  }
251
- function b() {
251
+ function x() {
252
252
  y = !1;
253
253
  }
254
- function x(e) {
254
+ function S(e) {
255
255
  let t = new URLSearchParams(e.replace(/^#/, "")).get(v);
256
256
  if (t === null) return null;
257
257
  let n = Number(t);
258
258
  return Number.isInteger(n) && n >= 1 ? n - 1 : null;
259
259
  }
260
- function S(e, t) {
260
+ function C(e, t) {
261
261
  let n = new URLSearchParams(e.replace(/^#/, ""));
262
262
  return n.set(v, String(t + 1)), `#${n.toString()}`;
263
263
  }
264
- function C(e, t) {
264
+ function w(e, t) {
265
265
  let n = null, r = () => {
266
- let r = x(e.location.hash);
266
+ let r = S(e.location.hash);
267
267
  r === null || r === n || (n = r, t(r));
268
268
  };
269
269
  return e.addEventListener("hashchange", r), {
270
270
  push(t) {
271
271
  if (t === n) return;
272
272
  n = t;
273
- let r = S(e.location.hash, t);
273
+ let r = C(e.location.hash, t);
274
274
  r !== e.location.hash && e.history?.replaceState?.(e.history.state, "", r);
275
275
  },
276
276
  stop() {
@@ -280,49 +280,49 @@ function C(e, t) {
280
280
  }
281
281
  //#endregion
282
282
  //#region src/renderer/select.ts
283
- var w = {
283
+ var T = {
284
284
  css: async () => new (await (import("./cssRenderer-Deskm2ND.js"))).CssRenderer(),
285
285
  webgl2: async () => new (await (import("./webglRenderer-D_XGumQT.js"))).WebglRenderer()
286
- }, T = !0;
287
- function E(e) {
286
+ }, E = !0;
287
+ function ee(e) {
288
288
  return typeof e == "object" && !!e && !Array.isArray(e) && typeof e.mount == "function";
289
289
  }
290
- function D(e) {
291
- return e.gpu && T ? ["webgl2", "css"] : ["css"];
290
+ function te(e) {
291
+ return e.gpu && E ? ["webgl2", "css"] : ["css"];
292
292
  }
293
- function O() {
294
- return { gpu: k() };
293
+ function D() {
294
+ return { gpu: O() };
295
295
  }
296
- function k() {
296
+ function O() {
297
297
  try {
298
298
  return !!document.createElement("canvas").getContext("webgl2");
299
299
  } catch {
300
300
  return !1;
301
301
  }
302
302
  }
303
- async function A(e = "auto", t = O()) {
304
- if (E(e)) return e;
305
- let n = Array.isArray(e) ? e : e === "auto" ? D(t) : [e];
303
+ async function k(e = "auto", t = D()) {
304
+ if (ee(e)) return e;
305
+ let n = Array.isArray(e) ? e : e === "auto" ? te(t) : [e];
306
306
  for (let e of n) {
307
307
  if (e === "webgl2" && !t.gpu) continue;
308
- let n = w[e];
308
+ let n = T[e];
309
309
  if (n) return n();
310
310
  }
311
311
  throw n.length === 1 && n[0] === "webgl2" && !t.gpu ? Error("renderer: 'webgl2' was forced but this device has no WebGL2. Use 'css' or 'auto'.") : Error(`renderer: none of [${n.join(", ")}] could be loaded — use 'css' or 'auto'.`);
312
312
  }
313
313
  //#endregion
314
314
  //#region src/source/compose.ts
315
- function j(e, t) {
315
+ function A(e, t) {
316
316
  let n = typeof t.frontCover == "string", r = typeof t.backCover == "string", i = t.pages != null && Object.keys(t.pages).length > 0;
317
- return !n && !r && !i ? e : new N(e, t);
317
+ return !n && !r && !i ? e : new M(e, t);
318
318
  }
319
- function M(e) {
319
+ function j(e) {
320
320
  return fetch(e).then((t) => {
321
321
  if (!t.ok) throw Error(`zine: could not load image "${e}" (HTTP ${t.status}).`);
322
322
  return t.blob();
323
323
  }).then((e) => createImageBitmap(e));
324
324
  }
325
- var N = class {
325
+ var M = class {
326
326
  #e;
327
327
  #t;
328
328
  #n;
@@ -390,16 +390,16 @@ var N = class {
390
390
  }
391
391
  #s(e) {
392
392
  let t = this.#a.get(e);
393
- return t === void 0 && (t = M(e).catch((t) => {
393
+ return t === void 0 && (t = j(e).catch((t) => {
394
394
  throw this.#a.delete(e), t;
395
395
  }), this.#a.set(e, t)), t;
396
396
  }
397
- }, P = .25, F = .0015, I = 6, L = 250, R = 24, z = 1.55, B = 32, V = 60, H = 2.5, U = 1.5, W = 120;
398
- function G(e, t, n) {
397
+ }, N = .25, P = .0015, F = 6, I = 250, L = 24, R = 2 * I, z = 1.55, B = 32, V = 60, H = 2.5, U = 1.5, W = 120, G = .85, K = .72;
398
+ function q(e, t, n) {
399
399
  let r = Math.max(0, t - B), i = Math.min(e.length, t + n + B), a = e.slice(r, i).replace(/\s+/g, " ").trim();
400
400
  return `${r > 0 ? "…" : ""}${a}${i < e.length ? "…" : ""}`;
401
401
  }
402
- var K = class {
402
+ var J = class {
403
403
  #e;
404
404
  #t;
405
405
  #n = new l();
@@ -463,26 +463,27 @@ var K = class {
463
463
  #re = null;
464
464
  #ie = null;
465
465
  #ae = null;
466
- #oe = null;
466
+ #oe = -Infinity;
467
467
  #se = null;
468
- #ce = /* @__PURE__ */ new Set();
469
- #le;
470
- #ue = null;
471
- #de = 1;
472
- #fe = 0;
473
- #pe = null;
474
- #me;
468
+ #ce = null;
469
+ #le = /* @__PURE__ */ new Set();
470
+ #ue;
471
+ #de = null;
472
+ #fe = 1;
473
+ #pe = 0;
474
+ #me = null;
475
+ #he;
475
476
  debug = { setFlipProgress: (e, t) => {
476
477
  this.#z?.setFlipProgress(e, t);
477
478
  } };
478
479
  constructor(e, t) {
479
- Q(e, t), this.#e = e, t.width !== void 0 && (e.style.width = `${t.width}px`), t.height !== void 0 && (e.style.height = `${t.height}px`), this.#t = j(t.source, {
480
+ re(e, t), this.#e = e, t.width !== void 0 && (e.style.width = `${t.width}px`), t.height !== void 0 && (e.style.height = `${t.height}px`), this.#t = A(t.source, {
480
481
  frontCover: t.frontCover,
481
482
  backCover: t.backCover,
482
483
  pages: t.pages
483
484
  });
484
485
  let n = t.direction ?? "ltr";
485
- this.#a = n, this.#x = (t.deepLink ?? !0) && ee(), this.#S = t.disableContextMenu ?? !1, this.#o = t.spreadMode ?? "cover", this.#s = this.#o, this.#c = t.curl ?? "cone", this.#u = t.clickToFlip ?? "edge", this.#d = t.clickZoneSize ?? 64, this.#m = t.singlePageThreshold ?? 640, this.#v = t.responsiveSpread ?? !0, this.#le = t.controls ?? !0, this.#b = t.startPage, typeof this.#t.open != "function" && this.#yt(), this.#k = t.flipDuration ?? 800, this.#A = t.zoom?.enabled ?? !0, this.#j = t.zoom?.wheel ?? !0;
486
+ this.#a = n, this.#x = (t.deepLink ?? !0) && b(), this.#S = t.disableContextMenu ?? !1, this.#o = t.spreadMode ?? "cover", this.#s = this.#o, this.#c = t.curl ?? "cone", this.#u = t.clickToFlip ?? "edge", this.#d = t.clickZoneSize ?? 64, this.#m = t.singlePageThreshold ?? 640, this.#v = t.responsiveSpread ?? !0, this.#ue = t.controls ?? !0, this.#b = t.startPage, typeof this.#t.open != "function" && this.#xt(), this.#k = t.flipDuration ?? 800, this.#A = t.zoom?.enabled ?? !0, this.#j = t.zoom?.wheel ?? !0;
486
487
  let r = t.zoom?.doubleClick, i = r === !1 ? [] : [...r ?? [
487
488
  1,
488
489
  2,
@@ -490,10 +491,10 @@ var K = class {
490
491
  ]].sort((e, t) => e - t);
491
492
  this.#M = i.length > 0 ? i : null, this.#N = t.zoom?.max ?? 4;
492
493
  let a = this.#A && this.#M !== null, o = t.zoom?.doubleClickInFlipZone ?? this.#u === "half";
493
- this.#f = this.#u !== "off" && a && o && t.clickFlipDelay !== 0, this.#p = this.#f ? t.clickFlipDelay ?? L : 0, this.#me = this.#We(t.renderer ?? "auto");
494
+ this.#f = this.#u !== "off" && a && o && t.clickFlipDelay !== 0, this.#p = this.#f ? t.clickFlipDelay ?? I : 0, this.#he = this.#Ke(t.renderer ?? "auto");
494
495
  }
495
496
  get ready() {
496
- return this.#me;
497
+ return this.#he;
497
498
  }
498
499
  getPageCount() {
499
500
  return this.#t.pageCount;
@@ -520,7 +521,7 @@ var K = class {
520
521
  return this.#h;
521
522
  }
522
523
  setSpreadMode(e) {
523
- e !== this.#o && (this.#o = e, this.#_ = !1, this.#rt(), this.#it());
524
+ e !== this.#o && (this.#o = e, this.#_ = !1, this.#at(), this.#ot());
524
525
  }
525
526
  toggleSpreadMode() {
526
527
  this.setSpreadMode(this.#o === "single" ? this.#s === "single" ? "double" : this.#s : "single");
@@ -536,16 +537,16 @@ var K = class {
536
537
  if (this.#v = e, e) {
537
538
  let e = this.#z?.measure().containerWidth;
538
539
  if (e === void 0) return;
539
- this.#_ = !1, this.#nt(e);
540
+ this.#_ = !1, this.#it(e);
540
541
  } else {
541
542
  if (!this.#_) return;
542
- this.#_ = !1, this.#rt();
543
+ this.#_ = !1, this.#at();
543
544
  }
544
- this.#it();
545
+ this.#ot();
545
546
  }
546
547
  }
547
548
  getPageImage(e) {
548
- return this.#gt(e);
549
+ return this.#vt(e);
549
550
  }
550
551
  canFlipNext() {
551
552
  return this.#E + 1 < this.#T.length;
@@ -593,11 +594,11 @@ var K = class {
593
594
  return typeof this.#t.getOutline == "function";
594
595
  }
595
596
  getOutline() {
596
- if (!this.#se) {
597
+ if (!this.#ce) {
597
598
  let e = this.#t.getOutline;
598
- this.#se = typeof e == "function" ? Promise.resolve(e.call(this.#t)).catch(() => []) : Promise.resolve([]);
599
+ this.#ce = typeof e == "function" ? Promise.resolve(e.call(this.#t)).catch(() => []) : Promise.resolve([]);
599
600
  }
600
- return this.#se;
601
+ return this.#ce;
601
602
  }
602
603
  async getSourceFile() {
603
604
  let e = this.#t.getDownload;
@@ -629,35 +630,35 @@ var K = class {
629
630
  let i = t.toLowerCase().indexOf(r);
630
631
  i < 0 || a.push({
631
632
  page: e,
632
- excerpt: G(t, i, r.length)
633
+ excerpt: q(t, i, r.length)
633
634
  });
634
635
  }
635
636
  return a;
636
637
  }
637
638
  flipNext() {
638
- this.#he(1);
639
+ this.#ge(1);
639
640
  }
640
641
  flipPrev() {
641
- this.#he(-1);
642
+ this.#ge(-1);
642
643
  }
643
- #he(e) {
644
- this.#ge(() => this.#be(this.#E + e));
644
+ #ge(e) {
645
+ this.#_e(() => this.#xe(this.#E + e));
645
646
  }
646
647
  flipTo(e) {
647
- let t = q(e, 0, Math.max(0, this.#t.pageCount - 1));
648
- this.#ge(() => this.#be(this.#vt(t)));
648
+ let t = Y(e, 0, Math.max(0, this.#t.pageCount - 1));
649
+ this.#_e(() => this.#xe(this.#bt(t)));
649
650
  }
650
- #ge(e) {
651
- this.#i.state === "idle" ? e() : this.#J ? (this.#q = null, this.#_e(), e()) : this.#q = e;
651
+ #_e(e) {
652
+ this.#i.state === "idle" ? e() : this.#J ? (this.#q = null, this.#ve(), e()) : this.#q = e;
652
653
  }
653
- #_e() {
654
+ #ve() {
654
655
  let e = this.#J;
655
656
  e && (this.#J = null, this.#H !== null && (cancelAnimationFrame(this.#H), this.#H = null), this.#z?.setFlipProgress(e.toT, e.direction), e.onDone());
656
657
  }
657
- #ve() {
658
+ #ye() {
658
659
  let e = this.#q;
659
660
  if (!e) {
660
- this.#ft();
661
+ this.#mt();
661
662
  return;
662
663
  }
663
664
  this.#q = null, e();
@@ -667,84 +668,87 @@ var K = class {
667
668
  }
668
669
  setZoom(e, t) {
669
670
  if (!this.#z || !this.#A) return;
670
- let n = q(e, 1, this.#N), r = this.#z.measure(), i = r.screenAt?.(this.#I), a = t ?? (i ? {
671
+ let n = Y(e, 1, this.#N), r = this.#z.measure(), i = r.screenAt?.(this.#I), a = t ?? (i ? {
671
672
  x: i.x + this.#L + i.width / 2,
672
673
  y: i.y + this.#R + i.height / 2
673
674
  } : null) ?? {
674
675
  x: r.containerWidth / 2,
675
676
  y: r.containerHeight / 2
676
677
  }, o = this.#I, s = n === 1 ? 0 : a.x - n / o * (a.x - this.#L), c = n === 1 ? 0 : a.y - n / o * (a.y - this.#R);
677
- [s, c] = this.#ye(s, c, n, r.containerWidth, r.containerHeight), this.#I = n, this.#L = s, this.#R = c, this.#z.setViewTransform(n, s, c), this.#ct(), this.#n.emit("zoomChanged", { scale: n });
678
+ [s, c] = this.#be(s, c, n, r.containerWidth, r.containerHeight), this.#I = n, this.#L = s, this.#R = c, this.#z.setViewTransform(n, s, c), this.#ut(), this.#n.emit("zoomChanged", { scale: n });
678
679
  }
679
680
  resetZoom() {
680
681
  this.setZoom(1);
681
682
  }
682
- #ye(e, t, n, r, i) {
683
+ #be(e, t, n, r, i) {
683
684
  let a = typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, o = (e) => Math.round(e * a) / a || 0, s = this.#z?.measure().screenAt?.(n) ?? {
684
685
  x: 0,
685
686
  y: 0,
686
687
  width: r * n,
687
688
  height: i * n
688
- }, [c, l] = J(s.x, s.width, r), [u, d] = J(s.y, s.height, i);
689
- return [o(q(e, c, l)), o(q(t, u, d))];
689
+ }, [c, l] = X(s.x, s.width, r), [u, d] = X(s.y, s.height, i);
690
+ return [o(Y(e, c, l)), o(Y(t, u, d))];
690
691
  }
691
692
  on(e, t) {
692
693
  return this.#n.on(e, t);
693
694
  }
694
695
  destroy() {
695
- this.#V = !0, this.#H !== null && cancelAnimationFrame(this.#H), this.#J = null, this.#q = null, this.#Fe(), this.#P?.disconnect(), this.#C?.stop(), this.#C = null, this.#w?.(), this.#x && b(), this.#ue?.(), this.#oe?.(), this.#ne?.(), this.#ie?.(), this.#re?.(), this.#te?.(), this.#pe !== null && clearTimeout(this.#pe), this.#fe++, this.#z?.destroy(), this.#z = null, this.#t.destroy(), this.#n.clear();
696
+ this.#V = !0, this.#H !== null && cancelAnimationFrame(this.#H), this.#J = null, this.#q = null, this.#Le(), this.#P?.disconnect(), this.#C?.stop(), this.#C = null, this.#w?.(), this.#x && x(), this.#de?.(), this.#se?.(), this.#ne?.(), this.#ie?.(), this.#re?.(), this.#te?.(), this.#me !== null && clearTimeout(this.#me), this.#pe++, this.#z?.destroy(), this.#z = null, this.#t.destroy(), this.#n.clear();
696
697
  }
697
- #be(e) {
698
+ #xe(e) {
698
699
  if (e < 0 || e >= this.#T.length || e === this.#E || this.#i.send("flip") === null) return;
699
- let t = e > this.#E ? "forward" : "backward", n = this.#we(e);
700
+ let t = e > this.#E ? "forward" : "backward", n = this.#Ee(e);
700
701
  this.#n.emit("flipStart", {
701
702
  from: this.#D,
702
703
  to: n
703
- }), this.#xe(e, t, n, ++this.#Y);
704
+ }), this.#Se(e, t, n, ++this.#Y);
704
705
  }
705
- async #xe(e, t, n, r) {
706
- let i = this.#T[e], a = i ? await this.#ht(i) : {
706
+ async #Se(e, t, n, r) {
707
+ let i = this.#T[e], a = i ? await this.#_t(i) : {
707
708
  left: null,
708
709
  right: null
709
710
  };
710
711
  r === this.#Y && (this.#z?.beginFlip(this.#O, a, t, {
711
712
  fill: this.#h,
712
- curl: this.#et(),
713
+ curl: this.#nt(),
713
714
  anchor: { y: this.#l }
714
- }), this.#Se(0, 1, t, () => this.#Ce(e, n, a)));
715
+ }), this.#Ce(0, 1, t, () => this.#Te(e, n, a), () => this.#we(n)));
715
716
  }
716
- #Se(e, t, n, r) {
717
- let i = this.#$e() * Math.abs(t - e);
718
- if (i <= 0) {
717
+ #Ce(e, t, n, r, i) {
718
+ let a = this.#tt() * Math.abs(t - e);
719
+ if (a <= 0) {
719
720
  this.#z?.setFlipProgress(t, n), r();
720
721
  return;
721
722
  }
722
- let a = {
723
+ let o = {
723
724
  toT: t,
724
725
  direction: n,
725
726
  onDone: r
726
727
  };
727
- this.#J = a;
728
- let o = performance.now(), s = (c) => {
729
- if (this.#J !== a) return;
730
- let l = Math.min(1, (c - o) / i), u = this.#h ? X(l) : Y(l);
731
- this.#z?.setFlipProgress(e + (t - e) * u, n), l < 1 ? this.#H = requestAnimationFrame(s) : (this.#H = null, this.#J = null, r());
728
+ this.#J = o;
729
+ let s = performance.now(), c = !1, l = (u) => {
730
+ if (this.#J !== o) return;
731
+ let d = Math.min(1, (u - s) / a), f = this.#h ? ne(d) : Z(d);
732
+ i && !c && f >= (this.#h ? K : G) && (c = !0, i()), d < 1 ? (this.#z?.setFlipProgress(e + (t - e) * f, n), this.#H = requestAnimationFrame(l)) : (this.#z?.setFlipProgress(t, n), this.#H = null, this.#J = null, r());
732
733
  };
733
- this.#H = requestAnimationFrame(s);
734
+ this.#H = requestAnimationFrame(l);
735
+ }
736
+ #we(e) {
737
+ this.#D !== e && (this.#D = e, this.#et(), this.#n.emit("pageChanged", { page: e }));
734
738
  }
735
- #Ce(e, t, n) {
739
+ #Te(e, t, n) {
736
740
  let r = this.#T[e];
737
- this.#E = e, this.#D = t, this.#O = n, r && this.#at(r, n), this.#_t(), this.#i.send("settle"), this.#Qe(), this.#n.emit("pageChanged", { page: t }), this.#n.emit("flipEnd", { page: t }), this.#ve();
741
+ this.#E = e, this.#O = n, r && this.#st(r, n), this.#yt(), this.#i.send("settle"), this.#oe = performance.now(), this.#we(t), this.#n.emit("flipEnd", { page: t }), this.#ye();
738
742
  }
739
- #we(e) {
743
+ #Ee(e) {
740
744
  let t = this.#T[e];
741
745
  if (!t) return this.#D;
742
746
  let n = [t.left, t.right].filter((e) => e !== null);
743
747
  return n.length > 0 ? Math.min(...n) : this.#D;
744
748
  }
745
- #Te(e, t) {
749
+ #De(e, t) {
746
750
  if (this.#Z || !this.#z) return;
747
- if (this.#Fe(), this.#I > 1) {
751
+ if (this.#Le(), this.#I > 1) {
748
752
  if (this.#i.send("panStart") === null) return;
749
753
  this.#X = {
750
754
  baseTx: this.#L,
@@ -752,27 +756,27 @@ var K = class {
752
756
  };
753
757
  return;
754
758
  }
755
- let n = this.#je(), r = this.#Me(e, t);
759
+ let n = this.#Ne(), r = this.#Pe(e, t);
756
760
  this.#G = r;
757
- let i = Math.min(n.width, n.height) * P, a = r.x >= 0 && r.x <= n.width && r.y >= 0 && r.y <= n.height, o = r.x <= i || r.x >= n.width - i, s = a && o;
761
+ let i = Math.min(n.width, n.height) * N, a = r.x >= 0 && r.x <= n.width && r.y >= 0 && r.y <= n.height, o = r.x <= i || r.x >= n.width - i, s = a && o;
758
762
  if (this.#i.state !== "idle") {
759
763
  if (!this.#J || !s) {
760
764
  this.#W = null;
761
765
  return;
762
766
  }
763
- this.#_e();
767
+ this.#ve();
764
768
  }
765
769
  if (!s) return;
766
- this.#l = q(r.y / n.height, 0, 1);
770
+ this.#l = Y(r.y / n.height, 0, 1);
767
771
  let c = r.x > n.width / 2, l = this.#a === "rtl" ? !c : c, u = this.#E + (l ? 1 : -1);
768
772
  u < 0 || u >= this.#T.length || (this.#W = {
769
773
  direction: l ? "forward" : "backward",
770
774
  targetIndex: u,
771
- toPage: this.#we(u),
775
+ toPage: this.#Ee(u),
772
776
  width: n.width
773
777
  });
774
778
  }
775
- #Ee() {
779
+ #Oe() {
776
780
  let e = this.#W;
777
781
  e && (this.#W = null, this.#i.send("grab") !== null && (this.#U = {
778
782
  direction: e.direction,
@@ -787,32 +791,32 @@ var K = class {
787
791
  }, this.#n.emit("flipStart", {
788
792
  from: this.#D,
789
793
  to: e.toPage
790
- }), this.#De(e.targetIndex, e.direction)));
794
+ }), this.#ke(e.targetIndex, e.direction)));
791
795
  }
792
- async #De(e, t) {
793
- let n = this.#T[e], r = n ? await this.#ht(n) : {
796
+ async #ke(e, t) {
797
+ let n = this.#T[e], r = n ? await this.#_t(n) : {
794
798
  left: null,
795
799
  right: null
796
800
  };
797
801
  this.#U?.targetIndex === e && (this.#U.toContent = r, this.#z?.beginFlip(this.#O, r, t, {
798
802
  fill: this.#h,
799
- curl: this.#et(),
803
+ curl: this.#nt(),
800
804
  anchor: { y: this.#l }
801
805
  }), this.#z?.setFlipProgress(this.#U.t, t));
802
806
  }
803
- #Oe(e, t) {
807
+ #Ae(e, t) {
804
808
  if (this.#Z) return;
805
809
  if (this.#X) {
806
810
  if (!this.#z) return;
807
- let n = this.#z.measure(), [r, i] = this.#ye(this.#X.baseTx + e, this.#X.baseTy + t, this.#I, n.containerWidth, n.containerHeight);
808
- this.#L = r, this.#R = i, this.#z.setViewTransform(this.#I, r, i), this.#ct();
811
+ let n = this.#z.measure(), [r, i] = this.#be(this.#X.baseTx + e, this.#X.baseTy + t, this.#I, n.containerWidth, n.containerHeight);
812
+ this.#L = r, this.#R = i, this.#z.setViewTransform(this.#I, r, i), this.#ut();
809
813
  return;
810
814
  }
811
- this.#W && Math.hypot(e, t) > I && this.#Ee();
815
+ this.#W && Math.hypot(e, t) > F && this.#Oe();
812
816
  let n = this.#U;
813
- n && (n.t = q((n.direction === "forward" ? -e : e) / n.width, 0, 1), this.#z?.setFlipProgress(n.t, n.direction));
817
+ n && (n.t = Y((n.direction === "forward" ? -e : e) / n.width, 0, 1), this.#z?.setFlipProgress(n.t, n.direction));
814
818
  }
815
- #ke(e) {
819
+ #je(e) {
816
820
  if (this.#Z) return;
817
821
  if (this.#X) {
818
822
  this.#X = null, this.#i.send("panEnd");
@@ -820,28 +824,28 @@ var K = class {
820
824
  }
821
825
  let t = this.#U;
822
826
  if (!t) {
823
- this.#W = null, this.#Ae(e);
827
+ this.#W = null, this.#Me(e);
824
828
  return;
825
829
  }
826
830
  this.#U = null, this.#i.send("release");
827
831
  let n = e.swipe && (t.direction === "forward" ? e.dx < 0 : e.dx > 0);
828
- t.t >= .5 || n ? this.#Se(t.t, 1, t.direction, () => this.#Ce(t.targetIndex, t.toPage, t.toContent)) : this.#Se(t.t, 0, t.direction, () => this.#Ie());
829
- }
830
- #Ae(e) {
831
- if (this.#u === "off" || this.#I > 1 || !this.#G || Math.abs(e.dx) > I || Math.abs(e.dy) > I) return;
832
- let t = this.#Ne(this.#G);
833
- if (!t || !this.#Pe(t)) return;
834
- this.#l = q(this.#G.y / this.#je().height, 0, 1);
835
- let n = t === "forward" ? 1 : -1, r = () => this.#be(this.#E + n);
836
- if (this.#Fe(), this.#p <= 0) {
837
- this.#ge(r);
832
+ t.t >= .5 || n ? this.#Ce(t.t, 1, t.direction, () => this.#Te(t.targetIndex, t.toPage, t.toContent), () => this.#we(t.toPage)) : this.#Ce(t.t, 0, t.direction, () => this.#Re());
833
+ }
834
+ #Me(e) {
835
+ if (this.#u === "off" || this.#I > 1 || !this.#G || Math.abs(e.dx) > F || Math.abs(e.dy) > F) return;
836
+ let t = this.#Fe(this.#G);
837
+ if (!t || !this.#Ie(t)) return;
838
+ this.#l = Y(this.#G.y / this.#Ne().height, 0, 1);
839
+ let n = t === "forward" ? 1 : -1, r = () => this.#xe(this.#E + n);
840
+ if (this.#Le(), this.#p <= 0) {
841
+ this.#_e(r);
838
842
  return;
839
843
  }
840
844
  this.#K = setTimeout(() => {
841
- this.#K = null, this.#ge(r);
845
+ this.#K = null, this.#_e(r);
842
846
  }, this.#p);
843
847
  }
844
- #je() {
848
+ #Ne() {
845
849
  let e = this.#z.measure();
846
850
  return e.content ?? e.book ?? {
847
851
  x: 0,
@@ -850,40 +854,40 @@ var K = class {
850
854
  height: e.containerHeight
851
855
  };
852
856
  }
853
- #Me(e, t) {
854
- let n = this.#e.getBoundingClientRect(), r = this.#je();
857
+ #Pe(e, t) {
858
+ let n = this.#e.getBoundingClientRect(), r = this.#Ne();
855
859
  return {
856
860
  x: e - n.left - r.x,
857
861
  y: t - n.top - r.y
858
862
  };
859
863
  }
860
- #Ne(e) {
864
+ #Fe(e) {
861
865
  if (!this.#z) return null;
862
- let t = this.#je().width, n;
866
+ let t = this.#Ne().width, n;
863
867
  if (n = this.#u === "half" ? e.x > t / 2 ? "right" : "left" : e.x <= this.#d ? "left" : e.x >= t - this.#d ? "right" : null, !n) return null;
864
868
  let r = this.#a === "rtl" ? "left" : "right";
865
869
  return n === r ? "forward" : "backward";
866
870
  }
867
- #Pe(e) {
871
+ #Ie(e) {
868
872
  let t = this.#E + (e === "forward" ? 1 : -1);
869
873
  return t >= 0 && t < this.#T.length;
870
874
  }
871
- #Fe() {
875
+ #Le() {
872
876
  this.#K !== null && (clearTimeout(this.#K), this.#K = null);
873
877
  }
874
- #Ie() {
878
+ #Re() {
875
879
  let e = this.#T[this.#E];
876
- e && this.#at(e, this.#O), this.#i.send("settle"), this.#n.emit("flipEnd", { page: this.#D }), this.#ve();
880
+ e && this.#st(e, this.#O), this.#i.send("settle"), this.#n.emit("flipEnd", { page: this.#D }), this.#ye();
877
881
  }
878
- #Le() {
879
- if (this.#W = null, this.#Fe(), this.#U) {
882
+ #ze() {
883
+ if (this.#W = null, this.#Le(), this.#U) {
880
884
  this.#U = null, this.#i.send("release"), this.#i.send("settle");
881
885
  let e = this.#T[this.#E];
882
- e && this.#at(e, this.#O);
886
+ e && this.#st(e, this.#O);
883
887
  } else this.#X && (this.#X = null, this.#i.send("panEnd"));
884
888
  this.#Z = !0, this.#Q = this.#I;
885
889
  }
886
- #Re(e, t, n) {
890
+ #Be(e, t, n) {
887
891
  if (!this.#Z) return;
888
892
  let r = this.#e.getBoundingClientRect();
889
893
  this.setZoom(this.#Q * n, {
@@ -891,19 +895,19 @@ var K = class {
891
895
  y: t - r.top
892
896
  });
893
897
  }
894
- #ze() {
898
+ #Ve() {
895
899
  this.#Z = !1;
896
900
  }
897
- #Be() {
901
+ #He() {
898
902
  if (!this.#S) return;
899
903
  let e = (e) => e.preventDefault();
900
904
  this.#e.addEventListener("contextmenu", e), this.#re = () => this.#e.removeEventListener("contextmenu", e);
901
905
  }
902
- #Ve() {
906
+ #Ue() {
903
907
  let e = (e) => {
904
908
  if (!this.#j || !this.#A || !(e.ctrlKey || e.metaKey)) return;
905
909
  e.preventDefault();
906
- let t = this.#e.getBoundingClientRect(), n = Math.exp(-e.deltaY * F);
910
+ let t = this.#e.getBoundingClientRect(), n = Math.exp(-e.deltaY * P);
907
911
  this.setZoom(this.#I * n, {
908
912
  x: e.clientX - t.left,
909
913
  y: e.clientY - t.top
@@ -911,12 +915,12 @@ var K = class {
911
915
  };
912
916
  this.#e.addEventListener("wheel", e, { passive: !1 }), this.#ne = () => this.#e.removeEventListener("wheel", e);
913
917
  }
914
- #He() {
918
+ #We() {
915
919
  let e = (e) => {
916
920
  let t = this.#M;
917
921
  if (!this.#A || t === null || !this.#z) return;
918
922
  let n = performance.now(), r = this.#ae;
919
- if (!(r !== null && n - r.t <= L && Math.hypot(e.clientX - r.x, e.clientY - r.y) <= R)) {
923
+ if (!(r !== null && n - r.t <= I && Math.hypot(e.clientX - r.x, e.clientY - r.y) <= L)) {
920
924
  this.#ae = {
921
925
  t: n,
922
926
  x: e.clientX,
@@ -924,89 +928,89 @@ var K = class {
924
928
  };
925
929
  return;
926
930
  }
927
- this.#ae = null, this.#Ue(e.clientX, e.clientY, t);
931
+ this.#ae = null, this.#Ge(e.clientX, e.clientY, t);
928
932
  };
929
933
  this.#e.addEventListener("click", e), this.#ie = () => this.#e.removeEventListener("click", e);
930
934
  }
931
- #Ue(e, t, n) {
935
+ #Ge(e, t, n) {
932
936
  if (this.#I <= 1 && this.#u !== "off" && !this.#f) {
933
- let n = this.#Me(e, t), r = this.#Ne(n);
934
- if (r !== null && this.#Pe(r)) return;
937
+ let n = this.#Pe(e, t), r = this.#Fe(n);
938
+ if (r !== null && (this.#Ie(r) || performance.now() - this.#oe <= R)) return;
935
939
  }
936
- this.#Fe();
940
+ this.#Le();
937
941
  let r = n.find((e) => e > this.#I + 1e-6) ?? n[0] ?? this.#I, i = this.#e.getBoundingClientRect();
938
942
  this.setZoom(r, {
939
943
  x: e - i.left,
940
944
  y: t - i.top
941
945
  });
942
946
  }
943
- async #We(e) {
944
- let t = A(e);
945
- typeof this.#t.open == "function" && (await this.#t.open(), this.#yt()), this.#t.prefetch([this.#D]);
946
- let n = await t, r = await this.#Ge(n);
947
- this.#z = r, this.#t.onPageUpdate?.((e) => this.#st(e)), this.#nt(r.measure().containerWidth);
947
+ async #Ke(e) {
948
+ let t = k(e);
949
+ typeof this.#t.open == "function" && (await this.#t.open(), this.#xt()), this.#t.prefetch([this.#D]);
950
+ let n = await t, r = await this.#qe(n);
951
+ this.#z = r, this.#t.onPageUpdate?.((e) => this.#lt(e)), this.#it(r.measure().containerWidth);
948
952
  let i = new m({
949
- onStart: (e) => this.#Te(e.x, e.y),
950
- onMove: (e) => this.#Oe(e.dx, e.dy),
951
- onEnd: (e) => this.#ke(e)
953
+ onStart: (e) => this.#De(e.x, e.y),
954
+ onMove: (e) => this.#Ae(e.dx, e.dy),
955
+ onEnd: (e) => this.#je(e)
952
956
  }), a = new _({
953
- onPinchStart: () => this.#Le(),
954
- onPinchMove: (e) => this.#Re(e.centerX, e.centerY, e.scale),
955
- onPinchEnd: () => this.#ze()
957
+ onPinchStart: () => this.#ze(),
958
+ onPinchMove: (e) => this.#Be(e.centerX, e.centerY, e.scale),
959
+ onPinchEnd: () => this.#Ve()
956
960
  });
957
961
  this.#te = h(this.#e, {
958
962
  pointer: i,
959
963
  pinch: a
960
- }), this.#Ve(), this.#He(), this.#Be(), this.#qe(), this.#oe = this.#Xe(), await this.#it(), this.#pt(), this.#_t(), this.#Qe(), this.#Ye(), await this.#Je(), this.#n.emit("ready");
964
+ }), this.#Ue(), this.#We(), this.#He(), this.#Ye(), this.#se = this.#Qe(), await this.#ot(), this.#ht(), this.#yt(), this.#et(), this.#Ze(), await this.#Xe(), this.#n.emit("ready");
961
965
  }
962
- async #Ge(e) {
966
+ async #qe(e) {
963
967
  try {
964
968
  return await e.mount(this.#e), e.onFatal?.(() => {
965
- this.#Ke();
969
+ this.#Je();
966
970
  }), e;
967
971
  } catch {
968
972
  e.destroy();
969
- let t = await A("css");
973
+ let t = await k("css");
970
974
  return await t.mount(this.#e), this.#B = !0, this.#n.emit("rendererFallback", {
971
975
  from: "webgl2",
972
976
  to: "css"
973
977
  }), t;
974
978
  }
975
979
  }
976
- async #Ke() {
980
+ async #Je() {
977
981
  if (this.#B || this.#V) return;
978
982
  this.#B = !0, this.#z?.destroy(), this.#z = null;
979
- let e = await A("css");
983
+ let e = await k("css");
980
984
  if (this.#V) {
981
985
  e.destroy();
982
986
  return;
983
987
  }
984
- await e.mount(this.#e), this.#z = e, this.#nt(e.measure().containerWidth), await this.#it(), this.#n.emit("rendererFallback", {
988
+ await e.mount(this.#e), this.#z = e, this.#it(e.measure().containerWidth), await this.#ot(), this.#n.emit("rendererFallback", {
985
989
  from: "webgl2",
986
990
  to: "css"
987
991
  });
988
992
  }
989
- #qe() {
993
+ #Ye() {
990
994
  if (typeof matchMedia != "function") return;
991
995
  let e = matchMedia("(prefers-reduced-motion: reduce)");
992
996
  this.#$ = e.matches, e.addEventListener?.("change", (e) => {
993
997
  this.#$ = e.matches;
994
998
  });
995
999
  }
996
- async #Je() {
997
- if (this.#le === !1 || this.#V) return;
1000
+ async #Xe() {
1001
+ if (this.#ue === !1 || this.#V) return;
998
1002
  let e = this.#e;
999
1003
  if (!(!e.ownerDocument || typeof e.appendChild != "function")) try {
1000
- let { mountControls: t } = await import("./controls-BrPo8pKL.js");
1004
+ let { mountControls: t } = await import("./controls-Bj72hxVJ.js");
1001
1005
  if (this.#V) return;
1002
- let n = this.#le === !0 ? {} : this.#le;
1003
- this.#ue = t(this, e, n);
1006
+ let n = this.#ue === !0 ? {} : this.#ue;
1007
+ this.#de = t(this, e, n);
1004
1008
  } catch {}
1005
1009
  }
1006
- #Ye() {
1010
+ #Ze() {
1007
1011
  if (!this.#x || globalThis.location === void 0) return;
1008
1012
  let e = globalThis;
1009
- this.#C = C(e, (e) => {
1013
+ this.#C = w(e, (e) => {
1010
1014
  e !== this.#D && this.flipTo(e);
1011
1015
  }), this.#C.push(this.#D), this.#w = this.#n.on("pageChanged", ({ page: e }) => {
1012
1016
  this.#C?.push(e);
@@ -1016,20 +1020,20 @@ var K = class {
1016
1020
  let t = globalThis.location?.href ?? "";
1017
1021
  if (!t) return "";
1018
1022
  let n = new URL(t);
1019
- return n.hash = S(n.hash, q(e, 0, Math.max(0, this.#t.pageCount - 1))), n.toString();
1023
+ return n.hash = C(n.hash, Y(e, 0, Math.max(0, this.#t.pageCount - 1))), n.toString();
1020
1024
  }
1021
- #Xe() {
1025
+ #Qe() {
1022
1026
  let e = this.#e, t = e.ownerDocument;
1023
1027
  if (!t || typeof e.setAttribute != "function") return null;
1024
1028
  e.hasAttribute("tabindex") || (e.tabIndex = 0), e.setAttribute("aria-roledescription", "flipbook");
1025
- let n = (e) => this.#Ze(e);
1029
+ let n = (e) => this.#$e(e);
1026
1030
  e.addEventListener("keydown", n);
1027
1031
  let r = t.createElement("div");
1028
1032
  return r.setAttribute("aria-live", "polite"), r.setAttribute("aria-atomic", "true"), r.style.cssText = "position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;", e.appendChild(r), this.#ee = r, () => {
1029
1033
  e.removeEventListener("keydown", n), r.remove(), this.#ee = null;
1030
1034
  };
1031
1035
  }
1032
- #Ze(e) {
1036
+ #$e(e) {
1033
1037
  let t = this.#a === "rtl" ? "ArrowLeft" : "ArrowRight";
1034
1038
  switch (e.key) {
1035
1039
  case "ArrowRight":
@@ -1045,70 +1049,70 @@ var K = class {
1045
1049
  default: break;
1046
1050
  }
1047
1051
  }
1048
- #Qe() {
1052
+ #et() {
1049
1053
  this.#ee && (this.#ee.textContent = `Page ${this.#D + 1} of ${this.#t.pageCount}`);
1050
1054
  }
1051
- #$e() {
1055
+ #tt() {
1052
1056
  return this.#$ ? W : this.#k * (this.#h ? z : 1);
1053
1057
  }
1054
- #et() {
1058
+ #nt() {
1055
1059
  return this.#$ ? "simple" : this.#c;
1056
1060
  }
1057
1061
  update() {
1058
- !this.#z || this.#i.state !== "idle" || (this.#nt(this.#z.measure().containerWidth), this.#it());
1062
+ !this.#z || this.#i.state !== "idle" || (this.#it(this.#z.measure().containerWidth), this.#ot());
1059
1063
  }
1060
- #tt() {
1064
+ #rt() {
1061
1065
  return this.#_ || this.#o === "single" ? "single" : this.#o;
1062
1066
  }
1063
- #nt(e) {
1067
+ #it(e) {
1064
1068
  let t = this.#v && o(e, this.#m);
1065
- t !== this.#_ && (this.#_ = t, this.#rt());
1069
+ t !== this.#_ && (this.#_ = t, this.#at());
1066
1070
  }
1067
- #rt() {
1068
- let e = this.#tt(), t = e !== this.#g;
1071
+ #at() {
1072
+ let e = this.#rt(), t = e !== this.#g;
1069
1073
  this.#g = e, this.#h = e === "single", this.#T = a(this.#t.pageCount, {
1070
1074
  direction: this.#a,
1071
1075
  mode: e
1072
- }), this.#E = this.#vt(this.#D), t && this.#n.emit("spreadChanged", {
1076
+ }), this.#E = this.#bt(this.#D), t && this.#n.emit("spreadChanged", {
1073
1077
  mode: e,
1074
1078
  singlePage: this.#h
1075
1079
  });
1076
1080
  }
1077
- async #it() {
1081
+ async #ot() {
1078
1082
  let e = this.#T[this.#E];
1079
- !e || !this.#z || (this.#O = await this.#ht(e), this.#at(e, this.#O));
1083
+ !e || !this.#z || (this.#O = await this.#_t(e), this.#st(e, this.#O));
1080
1084
  }
1081
- #at(e, t) {
1082
- this.#z?.renderSpread(e, t, { fill: this.#h }), this.#ot(), this.#de = 1, this.#ct();
1085
+ #st(e, t) {
1086
+ this.#z?.renderSpread(e, t, { fill: this.#h }), this.#ct(), this.#fe = 1, this.#ut();
1083
1087
  }
1084
- #ot() {
1088
+ #ct() {
1085
1089
  let e = this.#z?.measure().book;
1086
1090
  if (!e || e.width <= 0 || e.height <= 0) return;
1087
1091
  let t = (e.width / e.height).toFixed(4);
1088
1092
  t !== this.#y && (this.#y = t, this.#e.style.aspectRatio = t);
1089
1093
  }
1090
- #st(e) {
1094
+ #lt(e) {
1091
1095
  if (this.#i.state !== "idle") {
1092
- this.#ce.add(e);
1096
+ this.#le.add(e);
1093
1097
  return;
1094
1098
  }
1095
1099
  let t = this.#T[this.#E];
1096
- t && (t.left === e || t.right === e) && this.#it();
1100
+ t && (t.left === e || t.right === e) && this.#ot();
1097
1101
  }
1098
- #ct() {
1099
- this.#pe !== null && clearTimeout(this.#pe);
1100
- let e = this.#ut();
1101
- if (e !== this.#de) {
1102
+ #ut() {
1103
+ this.#me !== null && clearTimeout(this.#me);
1104
+ let e = this.#ft();
1105
+ if (e !== this.#fe) {
1102
1106
  if (e === 1) {
1103
- this.#fe++, this.#de = 1, this.#it();
1107
+ this.#pe++, this.#fe = 1, this.#ot();
1104
1108
  return;
1105
1109
  }
1106
- this.#pe = setTimeout(() => {
1107
- this.#pe = null, this.#dt();
1110
+ this.#me = setTimeout(() => {
1111
+ this.#me = null, this.#pt();
1108
1112
  }, V);
1109
1113
  }
1110
1114
  }
1111
- #lt() {
1115
+ #dt() {
1112
1116
  let e = this.#z?.measure(), t = e?.content ?? e?.book;
1113
1117
  if (!t || t.width <= 0) return 1;
1114
1118
  let n = this.#O, r = +!!n.left + +!!n.right;
@@ -1116,21 +1120,21 @@ var K = class {
1116
1120
  let i = t.width / r, a = typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, o = 0;
1117
1121
  for (let e of [n.left, n.right]) {
1118
1122
  if (!e || e.width <= 0) continue;
1119
- let t = e.width / this.#de;
1123
+ let t = e.width / this.#fe;
1120
1124
  o = Math.max(o, i * a / t);
1121
1125
  }
1122
1126
  return o === 0 ? 1 : o;
1123
1127
  }
1124
- #ut() {
1125
- let e = Math.max(1, U / (typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1)), t = this.#I <= 1 ? 1 : this.#I, n = this.#lt() * Math.max(t, e);
1128
+ #ft() {
1129
+ let e = Math.max(1, U / (typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1)), t = this.#I <= 1 ? 1 : this.#I, n = this.#dt() * Math.max(t, e);
1126
1130
  return n <= 1.001 ? 1 : Math.min(Math.ceil(n * 2) / 2, H);
1127
1131
  }
1128
- async #dt() {
1132
+ async #pt() {
1129
1133
  let e = this.#T[this.#E];
1130
1134
  if (!this.#z || !e) return;
1131
- let t = this.#ut();
1132
- if (t === 1 || t === this.#de) return;
1133
- let n = ++this.#fe, r = {
1135
+ let t = this.#ft();
1136
+ if (t === 1 || t === this.#fe || this.#i.state !== "idle") return;
1137
+ let n = ++this.#pe, r = {
1134
1138
  x: 0,
1135
1139
  y: 0,
1136
1140
  width: 1,
@@ -1149,34 +1153,34 @@ var K = class {
1149
1153
  }), null;
1150
1154
  }
1151
1155
  }));
1152
- if (n !== this.#fe || this.#ut() !== t) return;
1156
+ if (n !== this.#pe || this.#ft() !== t || this.#i.state !== "idle") return;
1153
1157
  let a = i[0] ?? null, o = i[1] ?? null;
1154
- a === this.#O.left && o === this.#O.right || (this.#de = t, this.#O = {
1158
+ a === this.#O.left && o === this.#O.right || (this.#fe = t, this.#O = {
1155
1159
  left: a,
1156
1160
  right: o
1157
1161
  }, this.#z.renderSpread(e, this.#O, { fill: this.#h }));
1158
1162
  }
1159
- #ft() {
1160
- if (this.#ce.size === 0) return;
1161
- let e = this.#T[this.#E], t = e !== void 0 && [e.left, e.right].some((e) => e !== null && this.#ce.has(e));
1162
- this.#ce.clear(), t && this.#it();
1163
+ #mt() {
1164
+ if (this.#le.size === 0) return;
1165
+ let e = this.#T[this.#E], t = e !== void 0 && [e.left, e.right].some((e) => e !== null && this.#le.has(e));
1166
+ this.#le.clear(), t && this.#ot();
1163
1167
  }
1164
- #pt() {
1165
- typeof ResizeObserver > "u" || (this.#P = new ResizeObserver(() => this.#mt()), this.#P.observe(this.#e));
1168
+ #ht() {
1169
+ typeof ResizeObserver > "u" || (this.#P = new ResizeObserver(() => this.#gt()), this.#P.observe(this.#e));
1166
1170
  }
1167
- #mt() {
1171
+ #gt() {
1168
1172
  this.#F || (this.#F = !0, requestAnimationFrame(() => {
1169
1173
  this.#F = !1, this.update();
1170
1174
  }));
1171
1175
  }
1172
- async #ht(e) {
1173
- let [t, n] = await Promise.all([this.#gt(e.left), this.#gt(e.right)]);
1176
+ async #_t(e) {
1177
+ let [t, n] = await Promise.all([this.#vt(e.left), this.#vt(e.right)]);
1174
1178
  return {
1175
1179
  left: t,
1176
1180
  right: n
1177
1181
  };
1178
1182
  }
1179
- async #gt(e) {
1183
+ async #vt(e) {
1180
1184
  if (e === null) return null;
1181
1185
  try {
1182
1186
  return await this.#t.get(e);
@@ -1187,7 +1191,7 @@ var K = class {
1187
1191
  }), null;
1188
1192
  }
1189
1193
  }
1190
- #_t() {
1194
+ #yt() {
1191
1195
  let { toMount: e } = this.#r.update(this.#E, this.#T.length), t = [];
1192
1196
  for (let n of e) {
1193
1197
  let e = this.#T[n];
@@ -1195,45 +1199,45 @@ var K = class {
1195
1199
  }
1196
1200
  this.#t.prefetch(t);
1197
1201
  }
1198
- #vt(e) {
1202
+ #bt(e) {
1199
1203
  let t = this.#T.findIndex((t) => t.left === e || t.right === e);
1200
1204
  return t === -1 ? 0 : t;
1201
1205
  }
1202
- #yt() {
1206
+ #xt() {
1203
1207
  let e = this.#t.pageCount;
1204
1208
  if (!Number.isInteger(e) || e < 1) throw Error(`Zine: source has ${e} pages; a Source must have at least 1 page.`);
1205
1209
  let t = this.#b;
1206
1210
  if (t !== void 0 && (!Number.isInteger(t) || t < 0 || t >= e)) throw Error(`Zine: startPage ${JSON.stringify(t)} is out of range for a ${e}-page book (valid 0..${e - 1}).`);
1207
- let n = this.#tt();
1211
+ let n = this.#rt();
1208
1212
  this.#h = n === "single", this.#T = a(e, {
1209
1213
  direction: this.#a,
1210
1214
  mode: n
1211
1215
  });
1212
- let r = this.#x ? x(globalThis.location?.hash ?? "") : null;
1213
- this.#D = q(r ?? t ?? 0, 0, e - 1), this.#E = this.#vt(this.#D);
1216
+ let r = this.#x ? S(globalThis.location?.hash ?? "") : null;
1217
+ this.#D = Y(r ?? t ?? 0, 0, e - 1), this.#E = this.#bt(this.#D);
1214
1218
  }
1215
1219
  };
1216
- function q(e, t, n) {
1220
+ function Y(e, t, n) {
1217
1221
  return e < t ? t : e > n ? n : e;
1218
1222
  }
1219
- function J(e, t, n) {
1223
+ function X(e, t, n) {
1220
1224
  if (t <= n) {
1221
1225
  let r = (n - t) / 2 - e;
1222
1226
  return [r, r];
1223
1227
  }
1224
1228
  return [n - (e + t), -e];
1225
1229
  }
1226
- function Y(e) {
1230
+ function Z(e) {
1227
1231
  return e < .5 ? 2 * e * e : 1 - (-2 * e + 2) ** 2 / 2;
1228
1232
  }
1229
- function X(e) {
1230
- return 1 - (1 - Y(e)) ** 1.3;
1233
+ function ne(e) {
1234
+ return 1 - (1 - Z(e)) ** 1.3;
1231
1235
  }
1232
- function Z(e) {
1236
+ function Q(e) {
1233
1237
  return e === null ? "null" : Array.isArray(e) ? "array" : typeof e;
1234
1238
  }
1235
- function Q(n, r) {
1236
- if (typeof n != "object" || !n || typeof n.appendChild != "function" || typeof n.addEventListener != "function") throw Error(`Zine: container must be a DOM element; received ${Z(n)}.`);
1239
+ function re(n, r) {
1240
+ if (typeof n != "object" || !n || typeof n.appendChild != "function" || typeof n.addEventListener != "function") throw Error(`Zine: container must be a DOM element; received ${Q(n)}.`);
1237
1241
  if (typeof r != "object" || !r) throw Error("Zine: an options object with a `source` is required.");
1238
1242
  let i = r, a = i.source;
1239
1243
  if (typeof a != "object" || !a || typeof a.get != "function" || typeof a.pageCount != "number") throw Error("Zine: `source` is required and must be a Source, e.g. new ImageSource(urls).");
@@ -1258,9 +1262,9 @@ function Q(n, r) {
1258
1262
  "deepLink",
1259
1263
  "disableContextMenu",
1260
1264
  "responsiveSpread"
1261
- ]) if (i[e] !== void 0 && typeof i[e] != "boolean") throw Error(`Zine: ${e} must be a boolean; got ${Z(i[e])}.`);
1265
+ ]) if (i[e] !== void 0 && typeof i[e] != "boolean") throw Error(`Zine: ${e} must be a boolean; got ${Q(i[e])}.`);
1262
1266
  let u = i.controls;
1263
- if (u !== void 0 && typeof u != "boolean" && (typeof u != "object" || !u)) throw Error(`Zine: controls must be a boolean or an options object; got ${Z(u)}.`);
1267
+ if (u !== void 0 && typeof u != "boolean" && (typeof u != "object" || !u)) throw Error(`Zine: controls must be a boolean or an options object; got ${Q(u)}.`);
1264
1268
  let d = u?.position;
1265
1269
  if (d !== void 0 && ![
1266
1270
  "top",
@@ -1281,12 +1285,12 @@ function Q(n, r) {
1281
1285
  }
1282
1286
  let p = i.pages;
1283
1287
  if (p !== void 0 && (typeof p != "object" || !p || Array.isArray(p))) throw Error("Zine: pages must be an object mapping page indices to image URLs.");
1284
- $(i.width, "width", 1), $(i.height, "height", 1), $(i.flipDuration, "flipDuration", 0), $(i.clickZoneSize, "clickZoneSize", 0), $(i.clickFlipDelay, "clickFlipDelay", 0), $(i.singlePageThreshold, "singlePageThreshold", 0), te(i.zoom), ne(i.renderer);
1288
+ $(i.width, "width", 1), $(i.height, "height", 1), $(i.flipDuration, "flipDuration", 0), $(i.clickZoneSize, "clickZoneSize", 0), $(i.clickFlipDelay, "clickFlipDelay", 0), $(i.singlePageThreshold, "singlePageThreshold", 0), ie(i.zoom), ae(i.renderer);
1285
1289
  }
1286
1290
  function $(e, t, n) {
1287
1291
  if (e !== void 0 && (typeof e != "number" || !Number.isFinite(e) || e < n)) throw Error(`Zine: ${t} must be a number >= ${n}; got ${JSON.stringify(e)}.`);
1288
1292
  }
1289
- function te(e) {
1293
+ function ie(e) {
1290
1294
  if (e === void 0) return;
1291
1295
  if (typeof e != "object" || !e || Array.isArray(e)) throw Error("Zine: zoom must be an object, e.g. { max: 4 }.");
1292
1296
  let t = e;
@@ -1299,7 +1303,7 @@ function te(e) {
1299
1303
  }
1300
1304
  $(t.max, "zoom.max", 1);
1301
1305
  }
1302
- function ne(e) {
1306
+ function ae(e) {
1303
1307
  if (e !== void 0) {
1304
1308
  if (typeof e == "string") {
1305
1309
  if (e !== "auto" && e !== "css" && e !== "webgl2") throw Error(`Zine: renderer '${e}' is not recognized; use 'auto', 'css', 'webgl2', an array of those, or a custom Renderer.`);
@@ -1314,7 +1318,7 @@ function ne(e) {
1314
1318
  }
1315
1319
  //#endregion
1316
1320
  //#region src/source/imageSource.ts
1317
- var re = class {
1321
+ var oe = class {
1318
1322
  pageCount;
1319
1323
  fit;
1320
1324
  #e;
@@ -1351,6 +1355,6 @@ var re = class {
1351
1355
  }
1352
1356
  };
1353
1357
  //#endregion
1354
- export { t as CURL_TYPES, i as DEFAULT_ITEMS, e as IMPORTABLE_CURLS, re as ImageSource, K as Zine, n as defineControl, r as getControl };
1358
+ export { t as CURL_TYPES, i as DEFAULT_ITEMS, e as IMPORTABLE_CURLS, oe as ImageSource, J as Zine, n as defineControl, r as getControl };
1355
1359
 
1356
1360
  //# sourceMappingURL=index.js.map