@zinejs/core 0.8.0 → 0.9.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 (41) hide show
  1. package/README.md +27 -49
  2. package/dist/{bundled-Cp43MIt0.js → bundled-ESapkNsS.js} +34 -34
  3. package/dist/bundled-ESapkNsS.js.map +1 -0
  4. package/dist/controls/contextMenu.d.ts +16 -0
  5. package/dist/controls/controls.d.ts +10 -3
  6. package/dist/controls/icons.d.ts +2 -2
  7. package/dist/controls/menu.d.ts +68 -0
  8. package/dist/controls/search.d.ts +15 -2
  9. package/dist/controls/styles.d.ts +1 -1
  10. package/dist/controls/toolbar.d.ts +1 -1
  11. package/dist/controls/types.d.ts +13 -2
  12. package/dist/{controls-Djjk8Yac.js → controls-CcOu_19g.js} +355 -199
  13. package/dist/controls-CcOu_19g.js.map +1 -0
  14. package/dist/curls.js +1 -1
  15. package/dist/geometry/curls/cone.d.ts +4 -3
  16. package/dist/index.js +644 -450
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.umd.js +61 -13
  19. package/dist/index.umd.js.map +1 -1
  20. package/dist/loading/loading.d.ts +1 -1
  21. package/dist/{loading-C0qbANt2.js → loading-DF88K9yJ.js} +2 -2
  22. package/dist/loading-DF88K9yJ.js.map +1 -0
  23. package/dist/renderer/gl/texture.d.ts +13 -2
  24. package/dist/renderer/types.d.ts +6 -0
  25. package/dist/renderer/webglRenderer.d.ts +1 -0
  26. package/dist/{share-DXAfK9rJ.js → share-BrQa6aYm.js} +2 -2
  27. package/dist/{share-DXAfK9rJ.js.map → share-BrQa6aYm.js.map} +1 -1
  28. package/dist/source/types.d.ts +5 -0
  29. package/dist/styles-D_zOGk2q.js +40 -0
  30. package/dist/styles-D_zOGk2q.js.map +1 -0
  31. package/dist/{webglRenderer-nGRruZk2.js → webglRenderer-CmQ_mUrX.js} +113 -101
  32. package/dist/webglRenderer-CmQ_mUrX.js.map +1 -0
  33. package/dist/zine.d.ts +52 -1
  34. package/options.schema.json +49 -0
  35. package/package.json +2 -2
  36. package/dist/bundled-Cp43MIt0.js.map +0 -1
  37. package/dist/controls-Djjk8Yac.js.map +0 -1
  38. package/dist/loading-C0qbANt2.js.map +0 -1
  39. package/dist/styles-CgCzjFUk.js +0 -40
  40. package/dist/styles-CgCzjFUk.js.map +0 -1
  41. package/dist/webglRenderer-nGRruZk2.js.map +0 -1
package/dist/index.js CHANGED
@@ -245,32 +245,32 @@ var _ = class {
245
245
  };
246
246
  }
247
247
  }, v = "page", y = !1;
248
- function b() {
248
+ function ee() {
249
249
  return y ? !1 : (y = !0, !0);
250
250
  }
251
- function x() {
251
+ function b() {
252
252
  y = !1;
253
253
  }
254
- function S(e) {
254
+ function x(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 C(e, t) {
260
+ function S(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 w(e, t) {
264
+ function C(e, t) {
265
265
  let n = null, r = () => {
266
- let r = S(e.location.hash);
266
+ let r = x(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 = C(e.location.hash, t);
273
+ let r = S(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 w(e, t) {
280
280
  }
281
281
  //#endregion
282
282
  //#region src/renderer/select.ts
283
- var T = {
283
+ var w = {
284
284
  css: async () => new (await (import("./cssRenderer-Deskm2ND.js"))).CssRenderer(),
285
- webgl2: async () => new (await (import("./webglRenderer-nGRruZk2.js"))).WebglRenderer()
286
- }, E = !0;
287
- function D(e) {
285
+ webgl2: async () => new (await (import("./webglRenderer-CmQ_mUrX.js"))).WebglRenderer()
286
+ }, T = !0;
287
+ function te(e) {
288
288
  return typeof e == "object" && !!e && !Array.isArray(e) && typeof e.mount == "function";
289
289
  }
290
- function O(e) {
291
- return e.gpu && E ? ["webgl2", "css"] : ["css"];
290
+ function ne(e) {
291
+ return e.gpu && T ? ["webgl2", "css"] : ["css"];
292
292
  }
293
- function ee() {
294
- return { gpu: te() };
293
+ function re() {
294
+ return { gpu: ie() };
295
295
  }
296
- function te() {
296
+ function ie() {
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 k(e = "auto", t = ee()) {
304
- if (D(e)) return e;
305
- let n = Array.isArray(e) ? e : e === "auto" ? O(t) : [e];
303
+ async function E(e = "auto", t = re()) {
304
+ if (te(e)) return e;
305
+ let n = Array.isArray(e) ? e : e === "auto" ? ne(t) : [e];
306
306
  for (let e of n) {
307
307
  if (e === "webgl2" && !t.gpu) continue;
308
- let n = T[e];
308
+ let n = w[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 A(e, t) {
315
+ function ae(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 M(e, t);
317
+ return !n && !r && !i ? e : new O(e, t);
318
318
  }
319
- function j(e) {
319
+ function D(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 M = class {
325
+ var O = class {
326
326
  #e;
327
327
  #t;
328
328
  #n;
@@ -391,16 +391,16 @@ var M = class {
391
391
  }
392
392
  #s(e) {
393
393
  let t = this.#a.get(e);
394
- return t === void 0 && (t = j(e).catch((t) => {
394
+ return t === void 0 && (t = D(e).catch((t) => {
395
395
  throw this.#a.delete(e), t;
396
396
  }), this.#a.set(e, t)), t;
397
397
  }
398
- }, 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;
399
- function q(e, t, n) {
400
- let r = Math.max(0, t - B), i = Math.min(e.length, t + n + B), a = e.slice(r, i).replace(/\s+/g, " ").trim();
398
+ }, k = .25, A = .0015, j = 6, M = 250, N = 24, P = 2 * M, F = 1.2, I = 32, L = 60, R = 2.5, z = 1.5, B = 120, V = .85, H = .82, oe = .12, U = 360, W = 28, G = 260, K = 7e3, q = 2200, J = "zine:hints-learned";
399
+ function se(e, t, n) {
400
+ let r = Math.max(0, t - I), i = Math.min(e.length, t + n + I), a = e.slice(r, i).replace(/\s+/g, " ").trim();
401
401
  return `${r > 0 ? "…" : ""}${a}${i < e.length ? "…" : ""}`;
402
402
  }
403
- var J = class {
403
+ var ce = class {
404
404
  #e;
405
405
  #t;
406
406
  #n = new l();
@@ -414,110 +414,133 @@ var J = class {
414
414
  #u;
415
415
  #d;
416
416
  #f;
417
- #p;
418
- #m;
419
- #h = !1;
420
- #g = null;
421
- #_ = !1;
422
- #v;
423
- #y = "";
424
- #b;
425
- #x;
426
- #S;
417
+ #p = null;
418
+ #m = null;
419
+ #h;
420
+ #g;
421
+ #_ = {
422
+ turn: !1,
423
+ zoom: !1,
424
+ pan: !1
425
+ };
426
+ #v = null;
427
+ #y = null;
428
+ #b = null;
429
+ #x = null;
430
+ #S = null;
427
431
  #C = null;
428
- #w = null;
429
- #T = [];
430
- #E = 0;
431
- #D = 0;
432
- #O = {
432
+ #w = !1;
433
+ #T = "";
434
+ #E;
435
+ #D;
436
+ #O;
437
+ #k = !1;
438
+ #A = null;
439
+ #j = !1;
440
+ #M;
441
+ #N = "";
442
+ #P;
443
+ #F;
444
+ #I;
445
+ #L = null;
446
+ #R = null;
447
+ #z = [];
448
+ #B = 0;
449
+ #V = 0;
450
+ #H = {
433
451
  left: null,
434
452
  right: null
435
453
  };
436
- #k;
437
- #A;
438
- #j;
439
- #M;
440
- #N;
441
- #P = null;
442
- #F = !1;
443
- #I = 1;
444
- #L = 0;
445
- #R = 0;
446
- #z = null;
447
- #B = !1;
448
- #V = !1;
449
- #H = null;
450
- #U = null;
451
- #W = null;
452
- #G = null;
453
- #K = null;
454
- #q = null;
454
+ #U;
455
+ #W;
456
+ #G;
457
+ #K;
458
+ #q;
455
459
  #J = null;
456
- #Y = 0;
457
- #X = null;
458
- #Z = !1;
459
- #Q = 1;
460
- #$ = !1;
461
- #ee = null;
462
- #te = null;
460
+ #Y = !1;
461
+ #X = 1;
462
+ #Z = 0;
463
+ #Q = 0;
464
+ #$ = null;
465
+ #ee = !1;
466
+ #te = !1;
463
467
  #ne = null;
464
468
  #re = null;
465
469
  #ie = null;
466
470
  #ae = null;
467
- #oe = -Infinity;
471
+ #oe = null;
468
472
  #se = null;
469
473
  #ce = null;
470
- #le = /* @__PURE__ */ new Set();
471
- #ue;
472
- #de = null;
473
- #fe;
474
- #pe = null;
474
+ #le = 0;
475
+ #ue = null;
476
+ #de = !1;
477
+ #fe = 1;
478
+ #pe = !1;
475
479
  #me = null;
476
- #he = "download";
477
- #ge = 1;
478
- #_e = 0;
480
+ #he = null;
481
+ #ge = null;
482
+ #_e = null;
479
483
  #ve = null;
480
- #ye;
484
+ #ye = null;
485
+ #be = -Infinity;
486
+ #xe = null;
487
+ #Se = null;
488
+ #Ce = /* @__PURE__ */ new Set();
489
+ #we;
490
+ #Te = null;
491
+ #Ee;
492
+ #De = null;
493
+ #Oe;
494
+ #ke;
495
+ #Ae = null;
496
+ #je = null;
497
+ #Me = "download";
498
+ #Ne = 1;
499
+ #Pe = 0;
500
+ #Fe = null;
501
+ #Ie;
481
502
  debug = { setFlipProgress: (e, t) => {
482
- this.#z?.setFlipProgress(e, t);
503
+ this.#$?.setFlipProgress(e, t);
483
504
  } };
484
505
  constructor(e, t) {
485
- 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, {
506
+ le(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 = ae(t.source, {
486
507
  frontCover: t.frontCover,
487
508
  backCover: t.backCover,
488
509
  pages: t.pages
489
510
  });
490
511
  let n = t.direction ?? "ltr";
491
- 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.#fe = t.loading ?? !0, this.#b = t.startPage, typeof this.#t.open != "function" && this.#Mt(), this.#k = t.flipDuration ?? 800, this.#A = t.zoom?.enabled ?? !0, this.#j = t.zoom?.wheel ?? !0;
492
- let r = t.zoom?.doubleClick, i = r === !1 ? [] : [...r ?? [
512
+ this.#a = n, this.#F = (t.deepLink ?? !0) && ee(), this.#I = 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.#f = t.cursorHints ?? !0;
513
+ let r = t.hints ?? !0;
514
+ this.#h = r === !0 || r !== !1 && (r.enabled ?? !0), this.#g = r !== !0 && r !== !1 && (r.persist ?? !1), this.#g && this.#dt(), this.#O = t.singlePageThreshold ?? 640, this.#M = t.responsiveSpread ?? !0, this.#we = t.controls ?? !0, this.#Ee = t.contextMenu ?? !t.disableContextMenu, this.#Oe = new Set(t.hideControls ?? []), this.#ke = t.loading ?? !0, this.#P = t.startPage, typeof this.#t.open != "function" && this.#mn(), this.#U = t.flipDuration ?? 800, this.#W = t.zoom?.enabled ?? !0, this.#G = t.zoom?.wheel ?? !0;
515
+ let i = t.zoom?.doubleClick, a = i === !1 ? [] : [...i ?? [
493
516
  1,
494
517
  2,
495
518
  4
496
519
  ]].sort((e, t) => e - t);
497
- this.#M = i.length > 0 ? i : null, this.#N = t.zoom?.max ?? 4;
498
- let a = this.#A && this.#M !== null, o = t.zoom?.doubleClickInFlipZone ?? this.#u === "half";
499
- this.#f = this.#u !== "off" && a && o && t.clickFlipDelay !== 0, this.#p = this.#f ? t.clickFlipDelay ?? I : 0, this.#ye = this.#$e(t.renderer ?? "auto");
520
+ this.#K = a.length > 0 ? a : null, this.#q = t.zoom?.max ?? 4;
521
+ let o = this.#W && this.#K !== null, s = t.zoom?.doubleClickInFlipZone ?? this.#u === "half";
522
+ this.#E = this.#u !== "off" && o && s && t.clickFlipDelay !== 0, this.#D = this.#E ? t.clickFlipDelay ?? M : 0, this.#Ie = this.#Ft(t.renderer ?? "auto");
500
523
  }
501
524
  get ready() {
502
- return this.#ye;
525
+ return this.#Ie;
503
526
  }
504
527
  getPageCount() {
505
528
  return this.#t.pageCount;
506
529
  }
507
530
  getPage() {
508
- return this.#D;
531
+ return this.#V;
509
532
  }
510
533
  get container() {
511
534
  return this.#e;
512
535
  }
513
536
  getPageBox() {
514
- return this.#z?.measure().book ?? null;
537
+ return this.#$?.measure().book ?? null;
515
538
  }
516
539
  getSpreads() {
517
- return this.#T;
540
+ return this.#z;
518
541
  }
519
542
  getSpreadIndex() {
520
- return this.#E;
543
+ return this.#B;
521
544
  }
522
545
  getDirection() {
523
546
  return this.#a;
@@ -526,44 +549,44 @@ var J = class {
526
549
  return this.#o;
527
550
  }
528
551
  isSinglePage() {
529
- return this.#h;
552
+ return this.#k;
530
553
  }
531
554
  setSpreadMode(e) {
532
- e !== this.#o && (this.#o = e, this.#_ = !1, this.#gt(), this.#_t());
555
+ e !== this.#o && (this.#o = e, this.#j = !1, this.#Qt(), this.#$t());
533
556
  }
534
557
  toggleSpreadMode() {
535
558
  this.setSpreadMode(this.#o === "single" ? this.#s === "single" ? "double" : this.#s : "single");
536
559
  }
537
560
  getResponsiveSpread() {
538
- return this.#v;
561
+ return this.#M;
539
562
  }
540
563
  isResponsiveSingle() {
541
- return this.#_ && this.#o !== "single";
564
+ return this.#j && this.#o !== "single";
542
565
  }
543
566
  setResponsiveSpread(e) {
544
- if (e !== this.#v) {
545
- if (this.#v = e, e) {
546
- let e = this.#z?.measure().containerWidth;
567
+ if (e !== this.#M) {
568
+ if (this.#M = e, e) {
569
+ let e = this.#$?.measure().containerWidth;
547
570
  if (e === void 0) return;
548
- this.#_ = !1, this.#ht(e);
571
+ this.#j = !1, this.#Zt(e);
549
572
  } else {
550
- if (!this.#_) return;
551
- this.#_ = !1, this.#gt();
573
+ if (!this.#j) return;
574
+ this.#j = !1, this.#Qt();
552
575
  }
553
- this.#_t();
576
+ this.#$t();
554
577
  }
555
578
  }
556
579
  getPageImage(e) {
557
- return this.#kt(e);
580
+ return this.#dn(e);
558
581
  }
559
582
  canFlipNext() {
560
- return this.#E + 1 < this.#T.length;
583
+ return this.#B + 1 < this.#z.length;
561
584
  }
562
585
  canFlipPrev() {
563
- return this.#E > 0;
586
+ return this.#B > 0;
564
587
  }
565
588
  getMaxZoom() {
566
- return this.#N;
589
+ return this.#q;
567
590
  }
568
591
  canSearch() {
569
592
  return typeof this.#t.getText == "function";
@@ -580,33 +603,33 @@ var J = class {
580
603
  async print() {
581
604
  let e = await this.getSourceFile(), t = this.#e.ownerDocument;
582
605
  if (!e || !t) return !1;
583
- let n = t.createElement("iframe");
584
- return n.style.cssText = "position:fixed;right:0;bottom:0;width:1px;height:1px;opacity:0;border:0;", n.setAttribute("aria-hidden", "true"), n.src = e.url, new Promise((r) => {
585
- let i = !1, a = (t) => {
586
- i || (i = !0, setTimeout(() => {
587
- n.remove(), e.revoke && URL.revokeObjectURL(e.url);
588
- }, 6e4), r(t));
606
+ let { url: n, revoke: r } = await this.#Le(e, t), i = t.createElement("iframe");
607
+ return i.style.cssText = "position:fixed;right:0;bottom:0;width:1px;height:1px;opacity:0;border:0;", i.setAttribute("aria-hidden", "true"), i.src = n, new Promise((e) => {
608
+ let a = !1, o = (t) => {
609
+ a || (a = !0, setTimeout(() => {
610
+ i.remove(), r && URL.revokeObjectURL(n);
611
+ }, 6e4), e(t));
589
612
  };
590
- n.addEventListener("load", () => {
613
+ i.addEventListener("load", () => {
591
614
  try {
592
- let e = n.contentWindow;
593
- if (!e) return a(!1);
594
- e.focus(), e.print(), a(!0);
615
+ let e = i.contentWindow;
616
+ if (!e) return o(!1);
617
+ e.focus(), e.print(), o(!0);
595
618
  } catch {
596
- a(!1);
619
+ o(!1);
597
620
  }
598
- }), n.addEventListener("error", () => a(!1)), t.body.appendChild(n);
621
+ }), i.addEventListener("error", () => o(!1)), t.body.appendChild(i);
599
622
  });
600
623
  }
601
624
  canOutline() {
602
625
  return typeof this.#t.getOutline == "function";
603
626
  }
604
627
  getOutline() {
605
- if (!this.#ce) {
628
+ if (!this.#Se) {
606
629
  let e = this.#t.getOutline;
607
- this.#ce = typeof e == "function" ? Promise.resolve(e.call(this.#t)).catch(() => []) : Promise.resolve([]);
630
+ this.#Se = typeof e == "function" ? Promise.resolve(e.call(this.#t)).catch(() => []) : Promise.resolve([]);
608
631
  }
609
- return this.#ce;
632
+ return this.#Se;
610
633
  }
611
634
  async getSourceFile() {
612
635
  let e = this.#t.getDownload;
@@ -617,15 +640,28 @@ var J = class {
617
640
  if (!e) return !1;
618
641
  let t = this.#e.ownerDocument;
619
642
  if (!t) return !1;
620
- let n = e.url, r = e.revoke ?? !1;
621
- if (!r && this.#be(n, t)) try {
622
- let e = await (await fetch(n)).blob();
623
- n = URL.createObjectURL(e), r = !0;
624
- } catch {}
625
- let i = t.createElement("a");
643
+ let { url: n, revoke: r } = await this.#Le(e, t), i = t.createElement("a");
626
644
  return i.href = n, i.download = e.filename, i.rel = "noopener", t.body.appendChild(i), i.click(), i.remove(), r && setTimeout(() => URL.revokeObjectURL(n), 1e4), !0;
627
645
  }
628
- #be(e, t) {
646
+ async #Le(e, t) {
647
+ if (e.revoke || !this.#Re(e.url, t)) return {
648
+ url: e.url,
649
+ revoke: e.revoke ?? !1
650
+ };
651
+ try {
652
+ let t = await (await fetch(e.url)).blob();
653
+ return {
654
+ url: URL.createObjectURL(t),
655
+ revoke: !0
656
+ };
657
+ } catch {
658
+ return {
659
+ url: e.url,
660
+ revoke: !1
661
+ };
662
+ }
663
+ }
664
+ #Re(e, t) {
629
665
  let n = t.defaultView?.location?.href;
630
666
  if (!n) return !1;
631
667
  try {
@@ -652,61 +688,62 @@ var J = class {
652
688
  let i = t.toLowerCase().indexOf(r);
653
689
  i < 0 || a.push({
654
690
  page: e,
655
- excerpt: q(t, i, r.length)
691
+ excerpt: se(t, i, r.length)
656
692
  });
657
693
  }
658
694
  return a;
659
695
  }
660
696
  flipNext() {
661
- this.#xe(1);
697
+ this.#ze(1);
662
698
  }
663
699
  flipPrev() {
664
- this.#xe(-1);
700
+ this.#ze(-1);
665
701
  }
666
- #xe(e) {
667
- this.#Se(() => this.#De(this.#E + e));
702
+ #ze(e) {
703
+ this.#Be(() => this.#Ge(this.#B + e));
668
704
  }
669
705
  flipTo(e) {
670
706
  let t = Y(e, 0, Math.max(0, this.#t.pageCount - 1));
671
- this.#Se(() => this.#De(this.#jt(t)));
707
+ this.#Be(() => this.#Ge(this.#pn(t)));
672
708
  }
673
- #Se(e) {
674
- this.#i.state === "idle" ? e() : this.#J ? (this.#q = null, this.#Ce(), e()) : this.#q = e;
709
+ #Be(e) {
710
+ this.#i.state === "idle" ? e() : this.#ce ? (this.#se = null, this.#Ve(), e()) : this.#se = e;
675
711
  }
676
- #Ce() {
677
- let e = this.#J;
678
- e && (this.#J = null, this.#H !== null && (cancelAnimationFrame(this.#H), this.#H = null), this.#z?.setFlipProgress(e.toT, e.direction), e.onDone());
712
+ #Ve() {
713
+ let e = this.#ce;
714
+ e && (this.#ce = null, this.#ne !== null && (cancelAnimationFrame(this.#ne), this.#ne = null), this.#$?.setFlipProgress(e.toT, e.direction), e.onDone());
679
715
  }
680
- #we() {
681
- let e = this.#q;
716
+ #He() {
717
+ let e = this.#se;
682
718
  if (!e) {
683
- this.#Tt();
719
+ this.#sn();
684
720
  return;
685
721
  }
686
- this.#q = null, e();
722
+ this.#se = null, e();
687
723
  }
688
724
  getZoom() {
689
- return this.#I;
725
+ return this.#X;
690
726
  }
691
727
  setZoom(e, t) {
692
- if (!this.#z || !this.#A) return;
693
- let n = Y(e, 1, this.#N), r = this.#z.measure(), i = r.screenAt?.(this.#I), a = t ?? (i ? {
694
- x: i.x + this.#L + i.width / 2,
695
- y: i.y + this.#R + i.height / 2
728
+ if (!this.#$ || !this.#W) return;
729
+ this.#gt(), this.#yt();
730
+ let n = Y(e, 1, this.#q), r = this.#$.measure(), i = r.screenAt?.(this.#X), a = t ?? (i ? {
731
+ x: i.x + this.#Z + i.width / 2,
732
+ y: i.y + this.#Q + i.height / 2
696
733
  } : null) ?? {
697
734
  x: r.containerWidth / 2,
698
735
  y: r.containerHeight / 2
699
- }, 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);
700
- [s, c] = this.#Ee(s, c, n, r.containerWidth, r.containerHeight), this.#I = n, this.#L = s, this.#R = c, this.#z.setViewTransform(n, s, c), o > 1 != n > 1 && this.#Te(), this.#xt(), this.#n.emit("zoomChanged", { scale: n });
736
+ }, o = this.#X, s = n === 1 ? 0 : a.x - n / o * (a.x - this.#Z), c = n === 1 ? 0 : a.y - n / o * (a.y - this.#Q);
737
+ [s, c] = this.#We(s, c, n, r.containerWidth, r.containerHeight), this.#X = n, this.#Z = s, this.#Q = c, this.#$.setViewTransform(n, s, c), o > 1 != n > 1 && this.#Ue(), this.#rn(), this.#lt(), o <= 1 && n > 1 && (this.#ft("zoom"), this.#bt()), this.#n.emit("zoomChanged", { scale: n });
701
738
  }
702
739
  resetZoom() {
703
740
  this.setZoom(1);
704
741
  }
705
- #Te() {
706
- this.#e.style.touchAction = this.#I > 1 ? "none" : "pan-y";
742
+ #Ue() {
743
+ this.#e.style.touchAction = this.#X > 1 ? "none" : "pan-y";
707
744
  }
708
- #Ee(e, t, n, r, i) {
709
- let a = typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, o = (e) => Math.round(e * a) / a || 0, s = this.#z?.measure().screenAt?.(n) ?? {
745
+ #We(e, t, n, r, i) {
746
+ let a = typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, o = (e) => Math.round(e * a) / a || 0, s = this.#$?.measure().screenAt?.(n) ?? {
710
747
  x: 0,
711
748
  y: 0,
712
749
  width: r * n,
@@ -718,31 +755,31 @@ var J = class {
718
755
  return this.#n.on(e, t);
719
756
  }
720
757
  destroy() {
721
- this.#V = !0, this.#H !== null && cancelAnimationFrame(this.#H), this.#J = null, this.#q = null, this.#We(), this.#P?.disconnect(), this.#C?.stop(), this.#C = null, this.#w?.(), this.#x && x(), this.#de?.(), this.#rt(), this.#se?.(), this.#ne?.(), this.#ie?.(), this.#re?.(), this.#te?.(), this.#ve !== null && clearTimeout(this.#ve), this.#_e++, this.#z?.destroy(), this.#z = null, this.#t.destroy(), this.#n.clear();
758
+ this.#te = !0, this.#ne !== null && cancelAnimationFrame(this.#ne), this.#ce = null, this.#se = null, this.#Et(), this.#mt(), this.#gt(), this.#yt(), this.#Tt(), this.#St(), this.#J?.disconnect(), this.#L?.stop(), this.#L = null, this.#R?.(), this.#F && b(), this.#Te?.(), this.#De?.(), this.#zt(), this.#xe?.(), this.#ge?.(), this.#ve?.(), this.#_e?.(), this.#m?.(), this.#he?.(), this.#Fe !== null && clearTimeout(this.#Fe), this.#Pe++, this.#$?.destroy(), this.#$ = null, this.#t.destroy(), this.#n.clear();
722
759
  }
723
- #De(e) {
724
- if (e < 0 || e >= this.#T.length || e === this.#E || this.#i.send("flip") === null) return;
725
- let t = e > this.#E ? "forward" : "backward", n = this.#Me(e);
760
+ #Ge(e) {
761
+ if (e < 0 || e >= this.#z.length || e === this.#B || (this.#gt(), this.#yt(), this.#i.send("flip") === null)) return;
762
+ let t = e > this.#B ? "forward" : "backward", n = this.#Xe(e);
726
763
  this.#n.emit("flipStart", {
727
- from: this.#D,
764
+ from: this.#V,
728
765
  to: n
729
- }), this.#Oe(e, t, n, ++this.#Y);
766
+ }), this.#Ke(e, t, n, ++this.#le);
730
767
  }
731
- async #Oe(e, t, n, r) {
732
- let i = this.#T[e], a = i ? await this.#Ot(i) : {
768
+ async #Ke(e, t, n, r) {
769
+ let i = this.#z[e], a = i ? await this.#un(i) : {
733
770
  left: null,
734
771
  right: null
735
772
  };
736
- r === this.#Y && (this.#z?.beginFlip(this.#O, a, t, {
737
- fill: this.#h,
738
- curl: this.#pt(),
773
+ r === this.#le && (this.#$?.beginFlip(this.#H, a, t, {
774
+ fill: this.#k,
775
+ curl: this.#Yt(),
739
776
  anchor: { y: this.#l }
740
- }), this.#ke(0, 1, t, () => this.#je(e, n, a), () => this.#Ae(n)));
777
+ }), this.#qe(0, 1, t, () => this.#Ye(e, n, a), () => this.#Je(n)));
741
778
  }
742
- #ke(e, t, n, r, i) {
743
- let a = this.#ft() * Math.abs(t - e);
779
+ #qe(e, t, n, r, i) {
780
+ let a = this.#Jt() * Math.abs(t - e);
744
781
  if (a <= 0) {
745
- this.#z?.setFlipProgress(t, n), r();
782
+ this.#$?.setFlipProgress(t, n), r();
746
783
  return;
747
784
  }
748
785
  let o = {
@@ -750,60 +787,60 @@ var J = class {
750
787
  direction: n,
751
788
  onDone: r
752
789
  };
753
- this.#J = o;
790
+ this.#ce = o;
754
791
  let s = performance.now(), c = !1, l = (u) => {
755
- if (this.#J !== o) return;
756
- let d = Math.min(1, (u - s) / a), f = this.#h ? ne(d) : Z(d);
757
- 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());
792
+ if (this.#ce !== o) return;
793
+ let d = Math.min(1, (u - s) / a), f = Z(d);
794
+ i && !c && f >= (this.#k ? H : V) && (c = !0, i()), d < 1 ? (this.#$?.setFlipProgress(e + (t - e) * f, n), this.#ne = requestAnimationFrame(l)) : (this.#$?.setFlipProgress(t, n), this.#ne = null, this.#ce = null, r());
758
795
  };
759
- this.#H = requestAnimationFrame(l);
796
+ this.#ne = requestAnimationFrame(l);
760
797
  }
761
- #Ae(e) {
762
- this.#D !== e && (this.#D = e, this.#dt(), this.#n.emit("pageChanged", { page: e }));
798
+ #Je(e) {
799
+ this.#V !== e && (this.#V = e, this.#qt(), this.#n.emit("pageChanged", { page: e }));
763
800
  }
764
- #je(e, t, n) {
765
- let r = this.#T[e];
766
- this.#E = e, this.#O = n, r && this.#vt(r, n), this.#At(), this.#i.send("settle"), this.#oe = performance.now(), this.#Ae(t), this.#n.emit("flipEnd", { page: t }), this.#we();
801
+ #Ye(e, t, n) {
802
+ let r = this.#z[e];
803
+ this.#B = e, this.#H = n, r && this.#en(r, n), this.#fn(), this.#i.send("settle"), this.#be = performance.now(), this.#Je(t), this.#ft("turn"), this.#lt(), this.#n.emit("flipEnd", { page: t }), this.#He();
767
804
  }
768
- #Me(e) {
769
- let t = this.#T[e];
770
- if (!t) return this.#D;
805
+ #Xe(e) {
806
+ let t = this.#z[e];
807
+ if (!t) return this.#V;
771
808
  let n = [t.left, t.right].filter((e) => e !== null);
772
- return n.length > 0 ? Math.min(...n) : this.#D;
809
+ return n.length > 0 ? Math.min(...n) : this.#V;
773
810
  }
774
- #Ne(e, t) {
775
- if (this.#Z || !this.#z) return;
776
- if (this.#We(), this.#I > 1) {
811
+ #Ze(e, t) {
812
+ if (this.#de || !this.#$) return;
813
+ if (this.#yt(), this.#Et(), this.#X > 1) {
777
814
  if (this.#i.send("panStart") === null) return;
778
- this.#X = {
779
- baseTx: this.#L,
780
- baseTy: this.#R
815
+ this.#ue = {
816
+ baseTx: this.#Z,
817
+ baseTy: this.#Q
781
818
  };
782
819
  return;
783
820
  }
784
- let n = this.#Be(), r = this.#Ve(e, t);
785
- this.#G = r;
786
- 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;
821
+ let n = this.#it(), r = this.#at(e, t);
822
+ this.#ae = r;
823
+ let i = Math.min(n.width, n.height) * k, 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;
787
824
  if (this.#i.state !== "idle") {
788
- if (!this.#J || !s) {
789
- this.#W = null;
825
+ if (!this.#ce || !s) {
826
+ this.#ie = null;
790
827
  return;
791
828
  }
792
- this.#Ce();
829
+ this.#Ve();
793
830
  }
794
831
  if (!s) return;
795
832
  this.#l = Y(r.y / n.height, 0, 1);
796
- let c = r.x > n.width / 2, l = this.#a === "rtl" ? !c : c, u = this.#E + (l ? 1 : -1);
797
- u < 0 || u >= this.#T.length || (this.#W = {
833
+ let c = r.x > n.width / 2, l = this.#a === "rtl" ? !c : c, u = this.#B + (l ? 1 : -1);
834
+ u < 0 || u >= this.#z.length || (this.#ie = {
798
835
  direction: l ? "forward" : "backward",
799
836
  targetIndex: u,
800
- toPage: this.#Me(u),
837
+ toPage: this.#Xe(u),
801
838
  width: n.width
802
839
  });
803
840
  }
804
- #Pe() {
805
- let e = this.#W;
806
- e && (this.#W = null, this.#i.send("grab") !== null && (this.#U = {
841
+ #Qe() {
842
+ let e = this.#ie;
843
+ e && (this.#ie = null, this.#i.send("grab") !== null && (this.#re = {
807
844
  direction: e.direction,
808
845
  targetIndex: e.targetIndex,
809
846
  toPage: e.toPage,
@@ -814,71 +851,75 @@ var J = class {
814
851
  width: e.width,
815
852
  t: 0
816
853
  }, this.#n.emit("flipStart", {
817
- from: this.#D,
854
+ from: this.#V,
818
855
  to: e.toPage
819
- }), this.#Fe(e.targetIndex, e.direction)));
856
+ }), this.#$e(e.targetIndex, e.direction)));
820
857
  }
821
- async #Fe(e, t) {
822
- let n = this.#T[e], r = n ? await this.#Ot(n) : {
858
+ async #$e(e, t) {
859
+ let n = this.#z[e], r = n ? await this.#un(n) : {
823
860
  left: null,
824
861
  right: null
825
862
  };
826
- this.#U?.targetIndex === e && (this.#U.toContent = r, this.#z?.beginFlip(this.#O, r, t, {
827
- fill: this.#h,
828
- curl: this.#pt(),
863
+ this.#re?.targetIndex === e && (this.#re.toContent = r, this.#$?.beginFlip(this.#H, r, t, {
864
+ fill: this.#k,
865
+ curl: this.#Yt(),
829
866
  anchor: { y: this.#l }
830
- }), this.#z?.setFlipProgress(this.#U.t, t));
831
- }
832
- #Ie(e, t) {
833
- if (this.#Z) return;
834
- if (this.#X) {
835
- if (!this.#z) return;
836
- let n = this.#z.measure(), [r, i] = this.#Ee(this.#X.baseTx + e, this.#X.baseTy + t, this.#I, n.containerWidth, n.containerHeight);
837
- this.#L = r, this.#R = i, this.#z.setViewTransform(this.#I, r, i), this.#xt();
867
+ }), this.#$?.setFlipProgress(this.#re.t, t));
868
+ }
869
+ #et(e, t) {
870
+ if (this.#de) return;
871
+ if (this.#ue) {
872
+ if (!this.#$) return;
873
+ let n = this.#$.measure(), [r, i] = this.#We(this.#ue.baseTx + e, this.#ue.baseTy + t, this.#X, n.containerWidth, n.containerHeight);
874
+ this.#Z = r, this.#Q = i, this.#$.setViewTransform(this.#X, r, i), this.#rn(), this.#ft("pan"), this.#St();
838
875
  return;
839
876
  }
840
- this.#W && Math.hypot(e, t) > F && this.#Pe();
841
- let n = this.#U;
842
- n && (n.t = Y((n.direction === "forward" ? -e : e) / n.width, 0, 1), this.#z?.setFlipProgress(n.t, n.direction));
843
- }
844
- #Le(e) {
845
- if (this.#Z) return;
846
- if (this.#X) {
847
- this.#X = null, this.#i.send("panEnd");
877
+ this.#ie && Math.hypot(e, t) > j && this.#Qe();
878
+ let n = this.#re;
879
+ n && (n.t = Y((n.direction === "forward" ? -e : e) / n.width, 0, 1), this.#$?.setFlipProgress(n.t, n.direction));
880
+ }
881
+ #tt(e) {
882
+ if (this.#de) return;
883
+ if (this.#ue) {
884
+ this.#ue = null, this.#i.send("panEnd"), this.#lt();
848
885
  return;
849
886
  }
850
- let t = this.#U;
887
+ let t = this.#re;
851
888
  if (!t) {
852
- this.#W = null, this.#Re(e) || this.#ze(e);
889
+ this.#ie = null, this.#nt(e) || this.#rt(e);
853
890
  return;
854
891
  }
855
- this.#U = null, this.#i.send("release");
892
+ this.#re = null, this.#i.send("release");
856
893
  let n = e.swipe && Math.abs(e.vx) > Math.abs(e.vy), r = t.direction === "forward" ? e.vx < 0 : e.vx > 0, i = n && r, a = n && !r;
857
- i || t.t >= .5 && !a ? this.#ke(t.t, 1, t.direction, () => this.#je(t.targetIndex, t.toPage, t.toContent), () => this.#Ae(t.toPage)) : this.#ke(t.t, 0, t.direction, () => this.#Ge());
894
+ i || t.t >= .5 && !a ? this.#qe(t.t, 1, t.direction, () => this.#Ye(t.targetIndex, t.toPage, t.toContent), () => this.#Je(t.toPage)) : this.#qe(t.t, 0, t.direction, () => this.#Dt());
858
895
  }
859
- #Re(e) {
860
- if (this.#I > 1 || !e.swipe || Math.abs(e.dx) <= Math.abs(e.dy)) return !1;
896
+ #nt(e) {
897
+ if (this.#X > 1 || !e.swipe || Math.abs(e.dx) <= Math.abs(e.dy)) return !1;
861
898
  let t = this.#a === "rtl" ? e.dx > 0 : e.dx < 0, n = t ? "forward" : "backward";
862
- if (!this.#Ue(n)) return !1;
899
+ if (!this.#st(n)) return this.#vt(n), !1;
863
900
  let r = t ? 1 : -1;
864
- return this.#Se(() => this.#De(this.#E + r)), !0;
865
- }
866
- #ze(e) {
867
- if (this.#u === "off" || this.#I > 1 || !this.#G || Math.abs(e.dx) > F || Math.abs(e.dy) > F) return;
868
- let t = this.#He(this.#G);
869
- if (!t || !this.#Ue(t)) return;
870
- this.#l = Y(this.#G.y / this.#Be().height, 0, 1);
871
- let n = t === "forward" ? 1 : -1, r = () => this.#De(this.#E + n);
872
- if (this.#We(), this.#p <= 0) {
873
- this.#Se(r);
901
+ return this.#Be(() => this.#Ge(this.#B + r)), !0;
902
+ }
903
+ #rt(e) {
904
+ if (this.#u === "off" || this.#X > 1 || !this.#ae || Math.abs(e.dx) > j || Math.abs(e.dy) > j) return;
905
+ let t = this.#ot(this.#ae);
906
+ if (!t) return;
907
+ if (!this.#st(t)) {
908
+ this.#vt(t);
909
+ return;
910
+ }
911
+ this.#l = Y(this.#ae.y / this.#it().height, 0, 1);
912
+ let n = t === "forward" ? 1 : -1, r = () => this.#Ge(this.#B + n);
913
+ if (this.#Et(), this.#D <= 0) {
914
+ this.#Be(r);
874
915
  return;
875
916
  }
876
- this.#K = setTimeout(() => {
877
- this.#K = null, this.#Se(r);
878
- }, this.#p);
917
+ this.#oe = setTimeout(() => {
918
+ this.#oe = null, this.#Be(r);
919
+ }, this.#D);
879
920
  }
880
- #Be() {
881
- let e = this.#z.measure();
921
+ #it() {
922
+ let e = this.#$.measure();
882
923
  return e.content ?? e.book ?? {
883
924
  x: 0,
884
925
  y: 0,
@@ -886,213 +927,351 @@ var J = class {
886
927
  height: e.containerHeight
887
928
  };
888
929
  }
889
- #Ve(e, t) {
890
- let n = this.#e.getBoundingClientRect(), r = this.#Be();
930
+ #at(e, t) {
931
+ let n = this.#e.getBoundingClientRect(), r = this.#it();
891
932
  return {
892
933
  x: e - n.left - r.x,
893
934
  y: t - n.top - r.y
894
935
  };
895
936
  }
896
- #He(e) {
897
- if (!this.#z) return null;
898
- let t = this.#Be().width, n;
937
+ #ot(e) {
938
+ if (!this.#$) return null;
939
+ let t = this.#it().width, n;
899
940
  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;
900
941
  let r = this.#a === "rtl" ? "left" : "right";
901
942
  return n === r ? "forward" : "backward";
902
943
  }
903
- #Ue(e) {
904
- let t = this.#E + (e === "forward" ? 1 : -1);
905
- return t >= 0 && t < this.#T.length;
944
+ #st(e) {
945
+ let t = this.#B + (e === "forward" ? 1 : -1);
946
+ return t >= 0 && t < this.#z.length;
947
+ }
948
+ #ct() {
949
+ let e = (e) => {
950
+ let t = e;
951
+ this.#p = {
952
+ x: t.clientX,
953
+ y: t.clientY
954
+ }, this.#lt();
955
+ }, t = () => {
956
+ this.#p = null, this.#lt();
957
+ };
958
+ this.#e.addEventListener("pointermove", e), this.#e.addEventListener("pointerleave", t), this.#m = () => {
959
+ this.#e.removeEventListener("pointermove", e), this.#e.removeEventListener("pointerleave", t);
960
+ };
961
+ }
962
+ #lt() {
963
+ if (!this.#f || !this.#$) return;
964
+ let e = "";
965
+ this.#re || this.#ue ? e = "grabbing" : this.#p && (e = this.#ut(this.#p.x, this.#p.y)), this.#e.style.cursor = e;
966
+ }
967
+ #ut(e, t) {
968
+ if (!this.#$) return "";
969
+ let n = this.#it(), r = this.#at(e, t);
970
+ if (r.x < 0 || r.y < 0 || r.x > n.width || r.y > n.height) return "";
971
+ if (this.#X > 1) return "grab";
972
+ let i = this.#ot(r);
973
+ return i && this.#st(i) ? "pointer" : this.#W && this.#K !== null ? "zoom-in" : "";
974
+ }
975
+ #dt() {
976
+ try {
977
+ let e = localStorage.getItem(J);
978
+ if (!e) return;
979
+ let t = JSON.parse(e);
980
+ this.#_ = {
981
+ turn: t.turn === !0,
982
+ zoom: t.zoom === !0,
983
+ pan: t.pan === !0
984
+ };
985
+ } catch {}
906
986
  }
907
- #We() {
908
- this.#K !== null && (clearTimeout(this.#K), this.#K = null);
987
+ #ft(e) {
988
+ if (!this.#_[e] && (this.#_[e] = !0, e === "turn" && this.#mt(), e === "zoom" && this.#Tt(), this.#g)) try {
989
+ localStorage.setItem(J, JSON.stringify(this.#_));
990
+ } catch {}
909
991
  }
910
- #Ge() {
911
- let e = this.#T[this.#E];
912
- e && this.#vt(e, this.#O), this.#i.send("settle"), this.#n.emit("flipEnd", { page: this.#D }), this.#we();
992
+ #pt() {
993
+ !this.#h || this.#pe || this.#_.turn || (this.#mt(), this.#v = setTimeout(() => {
994
+ this.#v = null, this.#ht();
995
+ }, K));
913
996
  }
914
- #Ke() {
915
- if (this.#W = null, this.#We(), this.#U) {
916
- this.#U = null, this.#i.send("release"), this.#i.send("settle");
917
- let e = this.#T[this.#E];
918
- e && this.#vt(e, this.#O);
919
- } else this.#X && (this.#X = null, this.#i.send("panEnd"));
920
- this.#Z = !0, this.#Q = this.#I;
997
+ #mt() {
998
+ this.#v !== null && (clearTimeout(this.#v), this.#v = null);
999
+ }
1000
+ async #ht() {
1001
+ if (!this.#h || this.#pe || this.#_.turn || !this.#$ || typeof requestAnimationFrame != "function" || this.#i.state !== "idle") return;
1002
+ let e = this.#B + 1, t = this.#z[e];
1003
+ if (!t) return;
1004
+ let n = await this.#un(t);
1005
+ if (this.#te || this.#_.turn || this.#i.state !== "idle" || this.#y) return;
1006
+ this.#l = 1, this.#$.beginFlip(this.#H, n, "forward", {
1007
+ fill: this.#k,
1008
+ curl: this.#Yt(),
1009
+ anchor: { y: this.#l }
1010
+ });
1011
+ let r = {};
1012
+ this.#y = r;
1013
+ let i = performance.now(), a = U * 2, o = () => {
1014
+ if (this.#y !== r) return;
1015
+ let e = Math.min(1, (performance.now() - i) / a), t = oe * Math.sin(e * Math.PI);
1016
+ this.#$?.setFlipProgress(Math.max(0, t), "forward"), e < 1 ? this.#ne = requestAnimationFrame(o) : (this.#ne = null, this.#y = null, this.#_t());
1017
+ };
1018
+ this.#ne = requestAnimationFrame(o);
921
1019
  }
922
- #qe(e, t, n) {
923
- if (!this.#Z) return;
1020
+ #gt() {
1021
+ this.#y && (this.#y = null, this.#ne !== null && (cancelAnimationFrame(this.#ne), this.#ne = null), this.#_t());
1022
+ }
1023
+ #_t() {
1024
+ let e = this.#z[this.#B];
1025
+ e && this.#i.state === "idle" && this.#en(e, this.#H);
1026
+ }
1027
+ #vt(e) {
1028
+ if (!this.#$ || typeof requestAnimationFrame != "function" || this.#pe || this.#i.state !== "idle" || this.#X > 1 || this.#b) return;
1029
+ let t = e === "forward", n = (this.#a === "rtl" ? !t : t) ? -1 : 1, r = {};
1030
+ this.#b = r;
1031
+ let i = performance.now(), a = () => {
1032
+ if (this.#b !== r) return;
1033
+ let e = Math.min(1, (performance.now() - i) / G), t = W * Math.sin(e * Math.PI);
1034
+ this.#$?.setViewTransform(1, n * t, 0), e < 1 ? this.#ne = requestAnimationFrame(a) : (this.#ne = null, this.#b = null, this.#$?.setViewTransform(1, 0, 0));
1035
+ };
1036
+ this.#ne = requestAnimationFrame(a);
1037
+ }
1038
+ #yt() {
1039
+ this.#b && (this.#b = null, this.#ne !== null && (cancelAnimationFrame(this.#ne), this.#ne = null), this.#$?.setViewTransform(1, 0, 0));
1040
+ }
1041
+ #bt() {
1042
+ this.#_.pan || this.#xt("Drag to move");
1043
+ }
1044
+ #xt(e) {
1045
+ if (!this.#h) return;
1046
+ let t = this.#e.ownerDocument;
1047
+ if (!t || typeof this.#e.appendChild != "function") return;
1048
+ this.#St();
1049
+ let n = t.createElement("div");
1050
+ n.className = "zine-hint-caption", n.setAttribute("aria-hidden", "true"), n.textContent = e, n.style.cssText = "position:absolute;left:50%;bottom:16px;transform:translateX(-50%);z-index:3;pointer-events:none;padding:6px 12px;border-radius:999px;font:500 13px/1.2 system-ui,sans-serif;color:#fff;background:rgba(24,24,27,0.82);box-shadow:0 1px 4px rgba(0,0,0,0.35);white-space:nowrap;opacity:0;";
1051
+ let r = !this.#pe && typeof requestAnimationFrame == "function";
1052
+ r && (n.style.transition = "opacity 200ms ease"), this.#e.appendChild(n), this.#x = n, r ? requestAnimationFrame(() => {
1053
+ this.#x === n && (n.style.opacity = "1");
1054
+ }) : n.style.opacity = "1", this.#S = setTimeout(() => this.#St(), q);
1055
+ }
1056
+ #St() {
1057
+ this.#S !== null && (clearTimeout(this.#S), this.#S = null), this.#x?.remove(), this.#x = null;
1058
+ }
1059
+ #Ct(e, t) {
1060
+ !this.#h || this.#_.zoom || this.#w || this.#T === "mouse" && this.#ut(e, t) === "zoom-in" && (this.#i.state === "animating" || performance.now() - this.#be <= P || (this.#Tt(), this.#C = setTimeout(() => {
1061
+ this.#C = null, !(this.#_.zoom || this.#w) && (this.#w = !0, this.#xt(this.#wt()));
1062
+ }, M)));
1063
+ }
1064
+ #wt() {
1065
+ let e = [];
1066
+ if (this.#K !== null && e.push("Double-click"), this.#G) {
1067
+ let t = this.#e.ownerDocument?.defaultView?.navigator, n = /Mac|iPhone|iPad/.test(t?.platform ?? "");
1068
+ e.push(`${n ? "⌘" : "Ctrl"}-scroll`);
1069
+ }
1070
+ return `${e.join(" or ")} to zoom`;
1071
+ }
1072
+ #Tt() {
1073
+ this.#C !== null && (clearTimeout(this.#C), this.#C = null);
1074
+ }
1075
+ #Et() {
1076
+ this.#oe !== null && (clearTimeout(this.#oe), this.#oe = null);
1077
+ }
1078
+ #Dt() {
1079
+ let e = this.#z[this.#B];
1080
+ e && this.#en(e, this.#H), this.#i.send("settle"), this.#lt(), this.#n.emit("flipEnd", { page: this.#V }), this.#He();
1081
+ }
1082
+ #Ot() {
1083
+ if (this.#ie = null, this.#Et(), this.#re) {
1084
+ this.#re = null, this.#i.send("release"), this.#i.send("settle");
1085
+ let e = this.#z[this.#B];
1086
+ e && this.#en(e, this.#H);
1087
+ } else this.#ue && (this.#ue = null, this.#i.send("panEnd"));
1088
+ this.#de = !0, this.#fe = this.#X;
1089
+ }
1090
+ #kt(e, t, n) {
1091
+ if (!this.#de) return;
924
1092
  let r = this.#e.getBoundingClientRect();
925
- this.setZoom(this.#Q * n, {
1093
+ this.setZoom(this.#fe * n, {
926
1094
  x: e - r.left,
927
1095
  y: t - r.top
928
1096
  });
929
1097
  }
930
- #Je() {
931
- this.#Z = !1;
1098
+ #At() {
1099
+ this.#de = !1;
932
1100
  }
933
- #Ye() {
934
- if (!this.#S) return;
1101
+ #jt() {
1102
+ if (!this.#I) return;
935
1103
  let e = (e) => e.preventDefault();
936
- this.#e.addEventListener("contextmenu", e), this.#re = () => this.#e.removeEventListener("contextmenu", e);
1104
+ this.#e.addEventListener("contextmenu", e), this.#_e = () => this.#e.removeEventListener("contextmenu", e);
937
1105
  }
938
- #Xe() {
1106
+ #Mt() {
939
1107
  let e = (e) => {
940
- if (!this.#j || !this.#A || !(e.ctrlKey || e.metaKey)) return;
1108
+ if (!this.#G || !this.#W || !(e.ctrlKey || e.metaKey)) return;
941
1109
  e.preventDefault();
942
- let t = this.#e.getBoundingClientRect(), n = Math.exp(-e.deltaY * P);
943
- this.setZoom(this.#I * n, {
1110
+ let t = this.#e.getBoundingClientRect(), n = Math.exp(-e.deltaY * A);
1111
+ this.setZoom(this.#X * n, {
944
1112
  x: e.clientX - t.left,
945
1113
  y: e.clientY - t.top
946
1114
  });
947
1115
  };
948
- this.#e.addEventListener("wheel", e, { passive: !1 }), this.#ne = () => this.#e.removeEventListener("wheel", e);
1116
+ this.#e.addEventListener("wheel", e, { passive: !1 }), this.#ge = () => this.#e.removeEventListener("wheel", e);
949
1117
  }
950
- #Ze() {
1118
+ #Nt() {
951
1119
  let e = (e) => {
952
- let t = this.#M;
953
- if (!this.#A || t === null || !this.#z) return;
954
- let n = performance.now(), r = this.#ae;
955
- if (!(r !== null && n - r.t <= I && Math.hypot(e.clientX - r.x, e.clientY - r.y) <= L)) {
956
- this.#ae = {
1120
+ this.#T = e.pointerType;
1121
+ }, t = (e) => {
1122
+ let t = this.#K;
1123
+ if (!this.#W || t === null || !this.#$) return;
1124
+ let n = performance.now(), r = this.#ye;
1125
+ if (!(r !== null && n - r.t <= M && Math.hypot(e.clientX - r.x, e.clientY - r.y) <= N)) {
1126
+ this.#ye = {
957
1127
  t: n,
958
1128
  x: e.clientX,
959
1129
  y: e.clientY
960
- };
1130
+ }, this.#Ct(e.clientX, e.clientY);
961
1131
  return;
962
1132
  }
963
- this.#ae = null, this.#Qe(e.clientX, e.clientY, t);
1133
+ this.#ye = null, this.#Tt(), this.#Pt(e.clientX, e.clientY, t);
1134
+ };
1135
+ this.#e.addEventListener("pointerdown", e), this.#e.addEventListener("click", t), this.#ve = () => {
1136
+ this.#e.removeEventListener("pointerdown", e), this.#e.removeEventListener("click", t);
964
1137
  };
965
- this.#e.addEventListener("click", e), this.#ie = () => this.#e.removeEventListener("click", e);
966
1138
  }
967
- #Qe(e, t, n) {
968
- if (this.#I <= 1 && this.#u !== "off" && !this.#f) {
969
- let n = this.#Ve(e, t), r = this.#He(n);
970
- if (r !== null && this.#Ue(r) || this.#i.state === "animating" || performance.now() - this.#oe <= R) return;
1139
+ #Pt(e, t, n) {
1140
+ if (this.#X <= 1 && this.#u !== "off" && !this.#E) {
1141
+ let n = this.#at(e, t), r = this.#ot(n);
1142
+ if (r !== null && this.#st(r) || this.#i.state === "animating" || performance.now() - this.#be <= P) return;
971
1143
  }
972
- this.#We();
973
- let r = n.find((e) => e > this.#I + 1e-6) ?? n[0] ?? this.#I, i = this.#e.getBoundingClientRect();
1144
+ this.#Et();
1145
+ let r = n.find((e) => e > this.#X + 1e-6) ?? n[0] ?? this.#X, i = this.#e.getBoundingClientRect();
974
1146
  this.setZoom(r, {
975
1147
  x: e - i.left,
976
1148
  y: t - i.top
977
1149
  });
978
1150
  }
979
- async #$e(e) {
980
- let t = k(e);
981
- if (this.#t.onProgress?.((e) => this.#et(e)), typeof this.#t.open == "function") {
982
- this.#tt();
1151
+ async #Ft(e) {
1152
+ let t = E(e);
1153
+ if (this.#t.onProgress?.((e) => this.#It(e)), typeof this.#t.open == "function") {
1154
+ this.#Lt();
983
1155
  try {
984
- await this.#t.open(), this.#Mt();
1156
+ await this.#t.open(), this.#mn();
985
1157
  } catch (e) {
986
- throw this.#rt(), e;
1158
+ throw this.#zt(), e;
987
1159
  }
988
- this.#nt("preparing");
1160
+ this.#Rt("preparing");
989
1161
  }
990
- this.#t.prefetch([this.#D]);
991
- let n = await t, r = await this.#it(n);
992
- this.#z = r, this.#t.onPageUpdate?.((e) => this.#bt(e)), this.#ht(r.measure().containerWidth);
1162
+ this.#t.prefetch([this.#V]);
1163
+ let n = await t, r = await this.#Bt(n);
1164
+ this.#$ = r, this.#t.onPageUpdate?.((e) => this.#nn(e)), this.#Zt(r.measure().containerWidth);
993
1165
  let i = new m({
994
- onStart: (e) => this.#Ne(e.x, e.y),
995
- onMove: (e) => this.#Ie(e.dx, e.dy),
996
- onEnd: (e) => this.#Le(e)
1166
+ onStart: (e) => this.#Ze(e.x, e.y),
1167
+ onMove: (e) => this.#et(e.dx, e.dy),
1168
+ onEnd: (e) => this.#tt(e)
997
1169
  }), a = new _({
998
- onPinchStart: () => this.#Ke(),
999
- onPinchMove: (e) => this.#qe(e.centerX, e.centerY, e.scale),
1000
- onPinchEnd: () => this.#Je()
1170
+ onPinchStart: () => this.#Ot(),
1171
+ onPinchMove: (e) => this.#kt(e.centerX, e.centerY, e.scale),
1172
+ onPinchEnd: () => this.#At()
1001
1173
  });
1002
- this.#te = h(this.#e, {
1174
+ this.#he = h(this.#e, {
1003
1175
  pointer: i,
1004
1176
  pinch: a
1005
- }), this.#Te(), this.#Xe(), this.#Ze(), this.#Ye(), this.#ot(), this.#se = this.#lt(), await this.#_t(), this.#rt(), this.#Et(), this.#At(), this.#dt(), this.#ct(), await this.#st(), this.#n.emit("ready");
1177
+ }), this.#Ue(), this.#Mt(), this.#Nt(), this.#jt(), this.#ct(), this.#Ht(), this.#xe = this.#Gt(), await this.#$t(), this.#zt(), this.#cn(), this.#fn(), this.#qt(), this.#Wt(), await this.#Ut(), this.#n.emit("ready"), this.#ht(), this.#pt();
1006
1178
  }
1007
- #et(e) {
1008
- this.#me = e, this.#n.emit("progress", e), this.#pe?.update(e);
1179
+ #It(e) {
1180
+ this.#je = e, this.#n.emit("progress", e), this.#Ae?.update(e);
1009
1181
  }
1010
- async #tt() {
1011
- if (this.#fe === !1 || this.#V) return;
1182
+ async #Lt() {
1183
+ if (this.#ke === !1 || this.#te) return;
1012
1184
  let e = this.#e;
1013
1185
  if (!(!e.ownerDocument || typeof e.appendChild != "function")) try {
1014
- let { mountLoading: t } = await import("./loading-C0qbANt2.js");
1015
- if (this.#he === "done" || this.#V) return;
1016
- this.#pe = t(e), this.#me && this.#pe.update(this.#me), this.#he === "preparing" && this.#pe.preparing();
1186
+ let { mountLoading: t } = await import("./loading-DF88K9yJ.js");
1187
+ if (this.#Me === "done" || this.#te) return;
1188
+ this.#Ae = t(e), this.#je && this.#Ae.update(this.#je), this.#Me === "preparing" && this.#Ae.preparing();
1017
1189
  } catch {}
1018
1190
  }
1019
- #nt(e) {
1020
- this.#he !== "done" && (this.#he = e, this.#pe?.preparing());
1191
+ #Rt(e) {
1192
+ this.#Me !== "done" && (this.#Me = e, this.#Ae?.preparing());
1021
1193
  }
1022
- #rt() {
1023
- this.#he = "done", this.#pe?.destroy(), this.#pe = null;
1194
+ #zt() {
1195
+ this.#Me = "done", this.#Ae?.destroy(), this.#Ae = null;
1024
1196
  }
1025
- async #it(e) {
1197
+ async #Bt(e) {
1026
1198
  try {
1027
1199
  return await e.mount(this.#e), e.onFatal?.(() => {
1028
- this.#at();
1200
+ this.#Vt();
1029
1201
  }), e;
1030
1202
  } catch {
1031
1203
  e.destroy();
1032
- let t = await k("css");
1033
- return await t.mount(this.#e), this.#B = !0, this.#n.emit("rendererFallback", {
1204
+ let t = await E("css");
1205
+ return await t.mount(this.#e), this.#ee = !0, this.#n.emit("rendererFallback", {
1034
1206
  from: "webgl2",
1035
1207
  to: "css"
1036
1208
  }), t;
1037
1209
  }
1038
1210
  }
1039
- async #at() {
1040
- if (this.#B || this.#V) return;
1041
- this.#B = !0, this.#z?.destroy(), this.#z = null;
1042
- let e = await k("css");
1043
- if (this.#V) {
1211
+ async #Vt() {
1212
+ if (this.#ee || this.#te) return;
1213
+ this.#ee = !0, this.#$?.destroy(), this.#$ = null;
1214
+ let e = await E("css");
1215
+ if (this.#te) {
1044
1216
  e.destroy();
1045
1217
  return;
1046
1218
  }
1047
- await e.mount(this.#e), this.#z = e, this.#ht(e.measure().containerWidth), await this.#_t(), this.#n.emit("rendererFallback", {
1219
+ await e.mount(this.#e), this.#$ = e, this.#Zt(e.measure().containerWidth), await this.#$t(), this.#n.emit("rendererFallback", {
1048
1220
  from: "webgl2",
1049
1221
  to: "css"
1050
1222
  });
1051
1223
  }
1052
- #ot() {
1224
+ #Ht() {
1053
1225
  if (typeof matchMedia != "function") return;
1054
1226
  let e = matchMedia("(prefers-reduced-motion: reduce)");
1055
- this.#$ = e.matches, e.addEventListener?.("change", (e) => {
1056
- this.#$ = e.matches;
1227
+ this.#pe = e.matches, e.addEventListener?.("change", (e) => {
1228
+ this.#pe = e.matches;
1057
1229
  });
1058
1230
  }
1059
- async #st() {
1060
- if (this.#ue === !1 || this.#V) return;
1061
- let e = this.#e;
1062
- if (!(!e.ownerDocument || typeof e.appendChild != "function")) try {
1063
- let { mountControls: t } = await import("./controls-Djjk8Yac.js");
1064
- if (this.#V) return;
1065
- let n = this.#ue === !0 ? {} : this.#ue;
1066
- this.#de = t(this, e, n);
1231
+ async #Ut() {
1232
+ let e = this.#we !== !1, t = this.#Ee !== !1;
1233
+ if (!e && !t || this.#te) return;
1234
+ let n = this.#e;
1235
+ if (!(!n.ownerDocument || typeof n.appendChild != "function")) try {
1236
+ let { mountControls: e, mountContextMenu: t } = await import("./controls-CcOu_19g.js");
1237
+ if (this.#te) return;
1238
+ if (this.#we !== !1) {
1239
+ let t = this.#we === !0 ? {} : this.#we;
1240
+ this.#Te = e(this, n, t, this.#Oe);
1241
+ }
1242
+ if (this.#Ee !== !1) {
1243
+ let e = this.#Ee === !0 ? {} : this.#Ee;
1244
+ this.#De = t(this, n, e, this.#Oe);
1245
+ }
1067
1246
  } catch {}
1068
1247
  }
1069
- #ct() {
1070
- if (!this.#x || globalThis.location === void 0) return;
1248
+ #Wt() {
1249
+ if (!this.#F || globalThis.location === void 0) return;
1071
1250
  let e = globalThis;
1072
- this.#C = w(e, (e) => {
1073
- e !== this.#D && this.flipTo(e);
1074
- }), this.#C.push(this.#D), this.#w = this.#n.on("pageChanged", ({ page: e }) => {
1075
- this.#C?.push(e);
1251
+ this.#L = C(e, (e) => {
1252
+ e !== this.#V && this.flipTo(e);
1253
+ }), this.#L.push(this.#V), this.#R = this.#n.on("pageChanged", ({ page: e }) => {
1254
+ this.#L?.push(e);
1076
1255
  });
1077
1256
  }
1078
- pageLink(e = this.#D) {
1257
+ pageLink(e = this.#V) {
1079
1258
  let t = globalThis.location?.href ?? "";
1080
1259
  if (!t) return "";
1081
1260
  let n = new URL(t);
1082
- return n.hash = C(n.hash, Y(e, 0, Math.max(0, this.#t.pageCount - 1))), n.toString();
1261
+ return n.hash = S(n.hash, Y(e, 0, Math.max(0, this.#t.pageCount - 1))), n.toString();
1083
1262
  }
1084
- #lt() {
1263
+ #Gt() {
1085
1264
  let e = this.#e, t = e.ownerDocument;
1086
1265
  if (!t || typeof e.setAttribute != "function") return null;
1087
1266
  e.hasAttribute("tabindex") || (e.tabIndex = 0), e.setAttribute("aria-roledescription", "flipbook");
1088
- let n = (e) => this.#ut(e);
1267
+ let n = (e) => this.#Kt(e);
1089
1268
  e.addEventListener("keydown", n);
1090
1269
  let r = t.createElement("div");
1091
- 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, () => {
1092
- e.removeEventListener("keydown", n), r.remove(), this.#ee = null;
1270
+ 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.#me = r, () => {
1271
+ e.removeEventListener("keydown", n), r.remove(), this.#me = null;
1093
1272
  };
1094
1273
  }
1095
- #ut(e) {
1274
+ #Kt(e) {
1096
1275
  let t = this.#a === "rtl" ? "ArrowLeft" : "ArrowRight";
1097
1276
  switch (e.key) {
1098
1277
  case "ArrowRight":
@@ -1108,92 +1287,98 @@ var J = class {
1108
1287
  default: break;
1109
1288
  }
1110
1289
  }
1111
- #dt() {
1112
- this.#ee && (this.#ee.textContent = `Page ${this.#D + 1} of ${this.#t.pageCount}`);
1290
+ #qt() {
1291
+ this.#me && (this.#me.textContent = `Page ${this.#V + 1} of ${this.#t.pageCount}`);
1113
1292
  }
1114
- #ft() {
1115
- return this.#$ ? W : this.#k * (this.#h ? z : 1);
1293
+ #Jt() {
1294
+ return this.#pe ? B : this.#U * (this.#k ? F : 1);
1116
1295
  }
1117
- #pt() {
1118
- return this.#$ ? "simple" : this.#c;
1296
+ #Yt() {
1297
+ return this.#pe ? "simple" : this.#c;
1119
1298
  }
1120
1299
  update() {
1121
- !this.#z || this.#i.state !== "idle" || (this.#ht(this.#z.measure().containerWidth), this.#_t());
1300
+ !this.#$ || this.#i.state !== "idle" || (this.#Zt(this.#$.measure().containerWidth), this.#$t(), this.#lt());
1122
1301
  }
1123
- #mt() {
1124
- return this.#_ || this.#o === "single" ? "single" : this.#o;
1302
+ #Xt() {
1303
+ return this.#j || this.#o === "single" ? "single" : this.#o;
1125
1304
  }
1126
- #ht(e) {
1127
- let t = this.#v && o(e, this.#m);
1128
- t !== this.#_ && (this.#_ = t, this.#gt());
1305
+ #Zt(e) {
1306
+ let t = this.#M && o(e, this.#O);
1307
+ t !== this.#j && (this.#j = t, this.#Qt());
1129
1308
  }
1130
- #gt() {
1131
- let e = this.#mt(), t = e !== this.#g;
1132
- this.#g = e, this.#h = e === "single", this.#T = a(this.#t.pageCount, {
1309
+ #Qt() {
1310
+ let e = this.#Xt(), t = e !== this.#A;
1311
+ this.#A = e, this.#k = e === "single", this.#z = a(this.#t.pageCount, {
1133
1312
  direction: this.#a,
1134
1313
  mode: e
1135
- }), this.#E = this.#jt(this.#D), t && this.#n.emit("spreadChanged", {
1314
+ }), this.#B = this.#pn(this.#V), t && this.#n.emit("spreadChanged", {
1136
1315
  mode: e,
1137
- singlePage: this.#h
1316
+ singlePage: this.#k
1138
1317
  });
1139
1318
  }
1140
- async #_t() {
1141
- let e = this.#T[this.#E];
1142
- !e || !this.#z || (this.#O = await this.#Ot(e), this.#vt(e, this.#O));
1319
+ async #$t() {
1320
+ let e = this.#z[this.#B];
1321
+ !e || !this.#$ || (this.#H = await this.#un(e), this.#en(e, this.#H));
1143
1322
  }
1144
- #vt(e, t) {
1145
- this.#z?.renderSpread(e, t, { fill: this.#h }), this.#yt(), this.#ge = 1, this.#xt();
1323
+ #en(e, t) {
1324
+ this.#$?.renderSpread(e, t, { fill: this.#k }), this.#tn(), this.#Ne = 1, this.#rn();
1146
1325
  }
1147
- #yt() {
1148
- let e = this.#z?.measure().book;
1326
+ #tn() {
1327
+ let e = this.#$?.measure().book;
1149
1328
  if (!e || e.width <= 0 || e.height <= 0) return;
1150
1329
  let t = (e.width / e.height).toFixed(4);
1151
- t !== this.#y && (this.#y = t, this.#e.style.aspectRatio = t);
1330
+ t !== this.#N && (this.#N = t, this.#e.style.aspectRatio = t);
1152
1331
  }
1153
- #bt(e) {
1332
+ #nn(e) {
1154
1333
  if (this.#i.state !== "idle") {
1155
- this.#le.add(e);
1334
+ this.#Ce.add(e);
1156
1335
  return;
1157
1336
  }
1158
- let t = this.#T[this.#E];
1159
- t && (t.left === e || t.right === e) && this.#_t();
1337
+ let t = this.#z[this.#B];
1338
+ if (!(!t || !(t.left === e || t.right === e))) {
1339
+ if (this.#X > 1) {
1340
+ this.#rn();
1341
+ return;
1342
+ }
1343
+ this.#$t();
1344
+ }
1160
1345
  }
1161
- #xt() {
1162
- this.#ve !== null && clearTimeout(this.#ve);
1163
- let e = this.#Ct();
1164
- if (e !== this.#ge) {
1346
+ #rn() {
1347
+ this.#Fe !== null && clearTimeout(this.#Fe);
1348
+ let e = this.#an();
1349
+ if (e !== this.#Ne) {
1165
1350
  if (e === 1) {
1166
- this.#_e++, this.#ge = 1, this.#_t();
1351
+ this.#Pe++, this.#Ne = 1, this.#$t();
1167
1352
  return;
1168
1353
  }
1169
- this.#ve = setTimeout(() => {
1170
- this.#ve = null, this.#wt();
1171
- }, V);
1354
+ this.#Fe = setTimeout(() => {
1355
+ this.#Fe = null, this.#on();
1356
+ }, L);
1172
1357
  }
1173
1358
  }
1174
- #St() {
1175
- let e = this.#z?.measure(), t = e?.content ?? e?.book;
1359
+ #in() {
1360
+ let e = this.#$?.measure(), t = e?.content ?? e?.book;
1176
1361
  if (!t || t.width <= 0) return 1;
1177
- let n = this.#O, r = +!!n.left + +!!n.right;
1362
+ let n = this.#H, r = +!!n.left + +!!n.right;
1178
1363
  if (r === 0) return 1;
1179
1364
  let i = t.width / r, a = typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, o = 0;
1180
1365
  for (let e of [n.left, n.right]) {
1181
1366
  if (!e || e.width <= 0) continue;
1182
- let t = e.width / this.#ge;
1367
+ let t = e.width / this.#Ne;
1183
1368
  o = Math.max(o, i * a / t);
1184
1369
  }
1185
1370
  return o === 0 ? 1 : o;
1186
1371
  }
1187
- #Ct() {
1188
- let e = Math.max(1, U / (typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1)), t = this.#I <= 1 ? 1 : this.#I, n = this.#St() * Math.max(t, e);
1189
- return n <= 1.001 ? 1 : Math.min(Math.ceil(n * 2) / 2, H);
1372
+ #an() {
1373
+ let e = Math.max(1, z / (typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1)), t = this.#X <= 1 ? 1 : this.#X, n = this.#in() * Math.max(t, e);
1374
+ return n <= 1.001 ? 1 : Math.min(Math.ceil(n * 2) / 2, R);
1190
1375
  }
1191
- async #wt() {
1192
- let e = this.#T[this.#E];
1193
- if (!this.#z || !e) return;
1194
- let t = this.#Ct();
1195
- if (t === 1 || t === this.#ge || this.#i.state !== "idle") return;
1196
- let n = ++this.#_e, r = {
1376
+ async #on() {
1377
+ let e = this.#z[this.#B];
1378
+ if (!this.#$ || !e) return;
1379
+ let t = this.#an();
1380
+ if (t === 1 || t === this.#Ne || this.#i.state !== "idle") return;
1381
+ let n = ++this.#Pe, r = {
1197
1382
  x: 0,
1198
1383
  y: 0,
1199
1384
  width: 1,
@@ -1203,7 +1388,8 @@ var J = class {
1203
1388
  try {
1204
1389
  return await this.#t.get(e, {
1205
1390
  scale: t,
1206
- region: r
1391
+ region: r,
1392
+ maxSize: this.#$?.maxTextureSize
1207
1393
  });
1208
1394
  } catch (t) {
1209
1395
  return this.#n.emit("sourceError", {
@@ -1212,34 +1398,34 @@ var J = class {
1212
1398
  }), null;
1213
1399
  }
1214
1400
  }));
1215
- if (n !== this.#_e || this.#Ct() !== t || this.#i.state !== "idle") return;
1216
- let a = i[0] ?? null, o = i[1] ?? null;
1217
- a === this.#O.left && o === this.#O.right || (this.#ge = t, this.#O = {
1401
+ if (n !== this.#Pe || this.#an() !== t || this.#i.state !== "idle") return;
1402
+ let a = i[0] ?? this.#H.left, o = i[1] ?? this.#H.right;
1403
+ a === this.#H.left && o === this.#H.right || (this.#Ne = t, this.#H = {
1218
1404
  left: a,
1219
1405
  right: o
1220
- }, this.#z.renderSpread(e, this.#O, { fill: this.#h }));
1406
+ }, this.#$.renderSpread(e, this.#H, { fill: this.#k }));
1221
1407
  }
1222
- #Tt() {
1223
- if (this.#le.size === 0) return;
1224
- let e = this.#T[this.#E], t = e !== void 0 && [e.left, e.right].some((e) => e !== null && this.#le.has(e));
1225
- this.#le.clear(), t && this.#_t();
1408
+ #sn() {
1409
+ if (this.#Ce.size === 0) return;
1410
+ let e = this.#z[this.#B], t = e !== void 0 && [e.left, e.right].some((e) => e !== null && this.#Ce.has(e));
1411
+ this.#Ce.clear(), t && (this.#X > 1 ? this.#rn() : this.#$t());
1226
1412
  }
1227
- #Et() {
1228
- typeof ResizeObserver > "u" || (this.#P = new ResizeObserver(() => this.#Dt()), this.#P.observe(this.#e));
1413
+ #cn() {
1414
+ typeof ResizeObserver > "u" || (this.#J = new ResizeObserver(() => this.#ln()), this.#J.observe(this.#e));
1229
1415
  }
1230
- #Dt() {
1231
- this.#F || (this.#F = !0, requestAnimationFrame(() => {
1232
- this.#F = !1, this.update();
1416
+ #ln() {
1417
+ this.#Y || (this.#Y = !0, requestAnimationFrame(() => {
1418
+ this.#Y = !1, this.update();
1233
1419
  }));
1234
1420
  }
1235
- async #Ot(e) {
1236
- let [t, n] = await Promise.all([this.#kt(e.left), this.#kt(e.right)]);
1421
+ async #un(e) {
1422
+ let [t, n] = await Promise.all([this.#dn(e.left), this.#dn(e.right)]);
1237
1423
  return {
1238
1424
  left: t,
1239
1425
  right: n
1240
1426
  };
1241
1427
  }
1242
- async #kt(e) {
1428
+ async #dn(e) {
1243
1429
  if (e === null) return null;
1244
1430
  try {
1245
1431
  return await this.#t.get(e);
@@ -1250,30 +1436,30 @@ var J = class {
1250
1436
  }), null;
1251
1437
  }
1252
1438
  }
1253
- #At() {
1254
- let { toMount: e } = this.#r.update(this.#E, this.#T.length), t = [];
1439
+ #fn() {
1440
+ let { toMount: e } = this.#r.update(this.#B, this.#z.length), t = [];
1255
1441
  for (let n of e) {
1256
- let e = this.#T[n];
1442
+ let e = this.#z[n];
1257
1443
  e?.left != null && t.push(e.left), e?.right != null && t.push(e.right);
1258
1444
  }
1259
1445
  this.#t.prefetch(t);
1260
1446
  }
1261
- #jt(e) {
1262
- let t = this.#T.findIndex((t) => t.left === e || t.right === e);
1447
+ #pn(e) {
1448
+ let t = this.#z.findIndex((t) => t.left === e || t.right === e);
1263
1449
  return t === -1 ? 0 : t;
1264
1450
  }
1265
- #Mt() {
1451
+ #mn() {
1266
1452
  let e = this.#t.pageCount;
1267
1453
  if (!Number.isInteger(e) || e < 1) throw Error(`Zine: source has ${e} pages; a Source must have at least 1 page.`);
1268
- let t = this.#b;
1454
+ let t = this.#P;
1269
1455
  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}).`);
1270
- let n = this.#mt();
1271
- this.#h = n === "single", this.#T = a(e, {
1456
+ let n = this.#Xt();
1457
+ this.#k = n === "single", this.#z = a(e, {
1272
1458
  direction: this.#a,
1273
1459
  mode: n
1274
1460
  });
1275
- let r = this.#x ? S(globalThis.location?.hash ?? "") : null;
1276
- this.#D = Y(r ?? t ?? 0, 0, e - 1), this.#E = this.#jt(this.#D);
1461
+ let r = this.#F ? x(globalThis.location?.hash ?? "") : null;
1462
+ this.#V = Y(r ?? t ?? 0, 0, e - 1), this.#B = this.#pn(this.#V);
1277
1463
  }
1278
1464
  };
1279
1465
  function Y(e, t, n) {
@@ -1289,13 +1475,10 @@ function X(e, t, n) {
1289
1475
  function Z(e) {
1290
1476
  return e < .5 ? 2 * e * e : 1 - (-2 * e + 2) ** 2 / 2;
1291
1477
  }
1292
- function ne(e) {
1293
- return 1 - (1 - Z(e)) ** 1.3;
1294
- }
1295
1478
  function Q(e) {
1296
1479
  return e === null ? "null" : Array.isArray(e) ? "array" : typeof e;
1297
1480
  }
1298
- function re(n, r) {
1481
+ function le(n, r) {
1299
1482
  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)}.`);
1300
1483
  if (typeof r != "object" || !r) throw Error("Zine: an options object with a `source` is required.");
1301
1484
  let i = r, a = i.source;
@@ -1340,25 +1523,36 @@ function re(n, r) {
1340
1523
  ].includes(f)) throw Error(`Zine: controls.colorScheme must be 'light', 'dark', or 'auto'; got ${JSON.stringify(f)}.`);
1341
1524
  let p = u?.arrows;
1342
1525
  if (p !== void 0 && typeof p != "boolean" && !["desktop", "mobile"].includes(p)) throw Error(`Zine: controls.arrows must be a boolean, 'desktop', or 'mobile'; got ${JSON.stringify(p)}.`);
1343
- let m = i.spreadMode;
1344
- if (m !== void 0 && ![
1526
+ let m = i.contextMenu;
1527
+ if (m !== void 0 && typeof m != "boolean" && (typeof m != "object" || !m)) throw Error(`Zine: contextMenu must be a boolean or an options object; got ${Q(m)}.`);
1528
+ let h = m?.colorScheme;
1529
+ if (h !== void 0 && ![
1530
+ "light",
1531
+ "dark",
1532
+ "auto"
1533
+ ].includes(h)) throw Error(`Zine: contextMenu.colorScheme must be 'light', 'dark', or 'auto'; got ${JSON.stringify(h)}.`);
1534
+ if (i.disableContextMenu === !0 && m !== void 0 && m !== !1) throw Error("Zine: disableContextMenu and contextMenu are mutually exclusive — one removes the browser's right-click menu, the other replaces it. Enable only one.");
1535
+ let g = i.hideControls;
1536
+ if (g !== void 0 && (!Array.isArray(g) || g.some((e) => typeof e != "string"))) throw Error(`Zine: hideControls must be an array of control-id strings; got ${Q(g)}.`);
1537
+ let _ = i.spreadMode;
1538
+ if (_ !== void 0 && ![
1345
1539
  "double",
1346
1540
  "single",
1347
1541
  "cover",
1348
1542
  "book"
1349
- ].includes(m)) throw Error(`Zine: spreadMode must be 'double', 'single', 'cover', or 'book'; got ${JSON.stringify(m)}.`);
1543
+ ].includes(_)) throw Error(`Zine: spreadMode must be 'double', 'single', 'cover', or 'book'; got ${JSON.stringify(_)}.`);
1350
1544
  for (let e of ["frontCover", "backCover"]) {
1351
1545
  let t = i[e];
1352
1546
  if (t !== void 0 && typeof t != "string") throw Error(`Zine: ${e} must be an image URL string; got ${JSON.stringify(t)}.`);
1353
1547
  }
1354
- let h = i.pages;
1355
- if (h !== void 0 && (typeof h != "object" || !h || Array.isArray(h))) throw Error("Zine: pages must be an object mapping page indices to image URLs.");
1356
- $(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);
1548
+ let v = i.pages;
1549
+ if (v !== void 0 && (typeof v != "object" || !v || Array.isArray(v))) throw Error("Zine: pages must be an object mapping page indices to image URLs.");
1550
+ $(i.width, "width", 1), $(i.height, "height", 1), $(i.flipDuration, "flipDuration", 0), $(i.clickZoneSize, "clickZoneSize", 0), $(i.clickFlipDelay, "clickFlipDelay", 0), $(i.singlePageThreshold, "singlePageThreshold", 0), ue(i.zoom), de(i.renderer);
1357
1551
  }
1358
1552
  function $(e, t, n) {
1359
1553
  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)}.`);
1360
1554
  }
1361
- function ie(e) {
1555
+ function ue(e) {
1362
1556
  if (e === void 0) return;
1363
1557
  if (typeof e != "object" || !e || Array.isArray(e)) throw Error("Zine: zoom must be an object, e.g. { max: 4 }.");
1364
1558
  let t = e;
@@ -1371,7 +1565,7 @@ function ie(e) {
1371
1565
  }
1372
1566
  $(t.max, "zoom.max", 1);
1373
1567
  }
1374
- function ae(e) {
1568
+ function de(e) {
1375
1569
  if (e !== void 0) {
1376
1570
  if (typeof e == "string") {
1377
1571
  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.`);
@@ -1386,7 +1580,7 @@ function ae(e) {
1386
1580
  }
1387
1581
  //#endregion
1388
1582
  //#region src/source/imageSource.ts
1389
- var oe = class {
1583
+ var fe = class {
1390
1584
  pageCount;
1391
1585
  fit;
1392
1586
  #e;
@@ -1423,6 +1617,6 @@ var oe = class {
1423
1617
  }
1424
1618
  };
1425
1619
  //#endregion
1426
- 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 };
1620
+ export { t as CURL_TYPES, i as DEFAULT_ITEMS, e as IMPORTABLE_CURLS, fe as ImageSource, ce as Zine, n as defineControl, r as getControl };
1427
1621
 
1428
1622
  //# sourceMappingURL=index.js.map