@zinejs/core 0.9.0 → 0.9.1

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