@likecoin/epub-ts 0.5.0 → 0.6.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.
package/dist/epub.js CHANGED
@@ -1,4 +1,4 @@
1
- import ee from "jszip";
1
+ import ie from "jszip";
2
2
  function P(a) {
3
3
  const t = typeof a == "function" ? a.prototype : a;
4
4
  return t.on = function(e, i) {
@@ -14,7 +14,7 @@ function P(a) {
14
14
  s[n](...i);
15
15
  }, a;
16
16
  }
17
- const xt = (a) => (Promise.resolve().then(() => a(performance.now())), 0), Dt = typeof window < "u" ? window.requestAnimationFrame.bind(window) : xt, ie = 1, se = 3, Bt = typeof URL < "u" ? URL : typeof window < "u" ? window.URL : void 0;
17
+ const bt = (a) => (Promise.resolve().then(() => a(performance.now())), 0), Bt = typeof window < "u" ? window.requestAnimationFrame.bind(window) : bt, se = 1, ne = 3, Mt = typeof URL < "u" ? URL : typeof window < "u" ? window.URL : void 0;
18
18
  function Et() {
19
19
  let a = (/* @__PURE__ */ new Date()).getTime();
20
20
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
@@ -22,7 +22,7 @@ function Et() {
22
22
  return a = Math.floor(a / 16), (e === "x" ? i : i & 7 | 8).toString(16);
23
23
  });
24
24
  }
25
- function ne() {
25
+ function re() {
26
26
  return Math.max(
27
27
  document.documentElement.clientHeight,
28
28
  document.body.scrollHeight,
@@ -31,17 +31,17 @@ function ne() {
31
31
  document.documentElement.offsetHeight
32
32
  );
33
33
  }
34
- function Mt(a) {
34
+ function Wt(a) {
35
35
  return !!(a && a.nodeType === 1);
36
36
  }
37
- function x(a) {
37
+ function b(a) {
38
38
  return !isNaN(parseFloat(a)) && isFinite(a);
39
39
  }
40
- function Wt(a) {
40
+ function qt(a) {
41
41
  const t = parseFloat(a);
42
- return x(a) === !1 ? !1 : typeof a == "string" && a.indexOf(".") > -1 ? !0 : Math.floor(t) !== t;
42
+ return b(a) === !1 ? !1 : typeof a == "string" && a.indexOf(".") > -1 ? !0 : Math.floor(t) !== t;
43
43
  }
44
- function qt(a, ...t) {
44
+ function Ut(a, ...t) {
45
45
  for (let e = 0; e < t.length; e++) {
46
46
  const i = t[e];
47
47
  for (const s in i)
@@ -56,27 +56,27 @@ function C(a, ...t) {
56
56
  });
57
57
  }), a;
58
58
  }
59
- function re(a, t, e) {
60
- const i = V(a, t, e);
59
+ function oe(a, t, e) {
60
+ const i = H(a, t, e);
61
61
  return t.splice(i, 0, a), i;
62
62
  }
63
- function V(a, t, e, i, s) {
63
+ function H(a, t, e, i, s) {
64
64
  const n = i || 0, r = s || t.length, o = Math.floor(n + (r - n) / 2);
65
65
  if (e || (e = function(l, c) {
66
66
  return l > c ? 1 : l < c ? -1 : 0;
67
67
  }), r - n <= 0)
68
68
  return o;
69
69
  const h = e(t[o], a);
70
- return r - n === 1 ? h >= 0 ? o : o + 1 : h === 0 ? o : h === -1 ? V(a, t, e, o, r) : V(a, t, e, n, o);
70
+ return r - n === 1 ? h >= 0 ? o : o + 1 : h === 0 ? o : h === -1 ? H(a, t, e, o, r) : H(a, t, e, n, o);
71
71
  }
72
- function Q(a, t, e, i, s) {
72
+ function J(a, t, e, i, s) {
73
73
  const n = i || 0, r = s || t.length, o = Math.floor(n + (r - n) / 2);
74
74
  if (e || (e = function(l, c) {
75
75
  return l > c ? 1 : l < c ? -1 : 0;
76
76
  }), r - n <= 0)
77
77
  return -1;
78
78
  const h = e(t[o], a);
79
- return r - n === 1 ? h === 0 ? o : -1 : h === 0 ? o : h === -1 ? Q(a, t, e, o, r) : Q(a, t, e, n, o);
79
+ return r - n === 1 ? h === 0 ? o : -1 : h === 0 ? o : h === -1 ? J(a, t, e, o, r) : J(a, t, e, n, o);
80
80
  }
81
81
  function K(a) {
82
82
  const t = window.getComputedStyle(a), e = ["width", "padding-right", "padding-left", "margin-right", "margin-left", "border-right-width", "border-left-width"], i = ["height", "padding-top", "padding-bottom", "margin-top", "margin-bottom", "border-top-width", "border-bottom-width"];
@@ -90,7 +90,7 @@ function K(a) {
90
90
  width: s
91
91
  };
92
92
  }
93
- function J(a) {
93
+ function Q(a) {
94
94
  const t = window.getComputedStyle(a), e = ["padding-right", "padding-left", "margin-right", "margin-left", "border-right-width", "border-left-width"], i = ["padding-top", "padding-bottom", "margin-top", "margin-bottom", "border-top-width", "border-bottom-width"];
95
95
  let s = 0, n = 0;
96
96
  return e.forEach(function(r) {
@@ -123,39 +123,39 @@ function pt() {
123
123
  height: t
124
124
  };
125
125
  }
126
- function St(a, t) {
126
+ function _t(a, t) {
127
127
  const i = a.parentNode.childNodes;
128
128
  let s, n = -1;
129
129
  for (let r = 0; r < i.length && (s = i[r], s.nodeType === t && n++, s !== a); r++)
130
130
  ;
131
131
  return n;
132
132
  }
133
- function oe(a) {
134
- return St(a, se);
133
+ function he(a) {
134
+ return _t(a, ne);
135
135
  }
136
- function Ut(a) {
137
- return St(a, ie);
136
+ function jt(a) {
137
+ return _t(a, se);
138
138
  }
139
- function _t(a) {
139
+ function St(a) {
140
140
  return ["xml", "opf", "ncx"].indexOf(a) > -1;
141
141
  }
142
142
  function Ct(a, t) {
143
- return t === "json" ? JSON.parse(a) : t && _t(t) ? W(a, "text/xml") : t === "xhtml" ? W(a, "application/xhtml+xml") : t === "html" || t === "htm" ? W(a, "text/html") : a;
143
+ return t === "json" ? JSON.parse(a) : t && St(t) ? W(a, "text/xml") : t === "xhtml" ? W(a, "application/xhtml+xml") : t === "html" || t === "htm" ? W(a, "text/html") : a;
144
144
  }
145
145
  class q extends Error {
146
146
  constructor(t, e) {
147
147
  super(t), this.name = "EpubError", this.status = e;
148
148
  }
149
149
  }
150
- function jt(a, t) {
150
+ function Ft(a, t) {
151
151
  return new Blob([a], { type: t });
152
152
  }
153
153
  function tt(a, t) {
154
- const e = jt(a, t);
155
- return Bt.createObjectURL(e);
154
+ const e = Ft(a, t);
155
+ return Mt.createObjectURL(e);
156
156
  }
157
157
  function Tt(a) {
158
- return Bt.revokeObjectURL(a);
158
+ return Mt.revokeObjectURL(a);
159
159
  }
160
160
  function gt(a, t) {
161
161
  if (typeof a != "string")
@@ -163,13 +163,13 @@ function gt(a, t) {
163
163
  const e = btoa(a);
164
164
  return "data:" + t + ";base64," + e;
165
165
  }
166
- function Ft(a) {
166
+ function Ht(a) {
167
167
  return Object.prototype.toString.call(a).slice(8, -1);
168
168
  }
169
169
  function W(a, t) {
170
170
  return a.charCodeAt(0) === 65279 && (a = a.slice(1)), new DOMParser().parseFromString(a, t);
171
171
  }
172
- function w(a, t) {
172
+ function x(a, t) {
173
173
  if (!a)
174
174
  throw new Error("No Element Provided");
175
175
  return a.querySelector(t);
@@ -192,18 +192,18 @@ function Vt(a, t, e) {
192
192
  for (; s = i.nextNode(); )
193
193
  t(s);
194
194
  }
195
- function Ht(a, t, e) {
195
+ function Xt(a, t, e) {
196
196
  if (t(a))
197
197
  return !0;
198
198
  let i = a.firstChild;
199
199
  if (i)
200
200
  do {
201
- if (Ht(i, t))
201
+ if (Xt(i, t))
202
202
  return !0;
203
203
  i = i.nextSibling;
204
204
  } while (i);
205
205
  }
206
- function Xt(a) {
206
+ function Yt(a) {
207
207
  return new Promise(function(t, e) {
208
208
  const i = new FileReader();
209
209
  i.readAsDataURL(a), i.onloadend = function() {
@@ -211,7 +211,7 @@ function Xt(a) {
211
211
  };
212
212
  });
213
213
  }
214
- class S {
214
+ class _ {
215
215
  constructor() {
216
216
  this.promise = new Promise((t, e) => {
217
217
  this.resolve = t, this.reject = e;
@@ -258,7 +258,7 @@ function F(a, t, e) {
258
258
  if (!e)
259
259
  return i;
260
260
  }
261
- function he(a, t) {
261
+ function ae(a, t) {
262
262
  let e;
263
263
  if (!(a === null || t === ""))
264
264
  for (e = a.parentNode; e && e.nodeType === 1; ) {
@@ -267,7 +267,7 @@ function he(a, t) {
267
267
  e = e.parentNode;
268
268
  }
269
269
  }
270
- class Yt {
270
+ class Gt {
271
271
  constructor() {
272
272
  this.collapsed = !1, this.commonAncestorContainer = void 0, this.endContainer = void 0, this.endOffset = void 0, this.startContainer = void 0, this.startOffset = void 0;
273
273
  }
@@ -304,56 +304,56 @@ class Yt {
304
304
  return "";
305
305
  }
306
306
  }
307
- const ae = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
307
+ const le = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
308
308
  __proto__: null,
309
309
  EpubError: q,
310
- RangeObject: Yt,
311
- blob2base64: Xt,
312
- borders: J,
310
+ RangeObject: Gt,
311
+ blob2base64: Yt,
312
+ borders: Q,
313
313
  bounds: K,
314
314
  createBase64Url: gt,
315
- createBlob: jt,
315
+ createBlob: Ft,
316
316
  createBlobUrl: tt,
317
- defaults: qt,
318
- defer: S,
319
- documentHeight: ne,
317
+ defaults: Ut,
318
+ defer: _,
319
+ documentHeight: re,
320
320
  extend: C,
321
321
  filterChildren: F,
322
322
  findChildren: mt,
323
- getParentByTagName: he,
323
+ getParentByTagName: ae,
324
324
  handleResponse: Ct,
325
- indexOfElementNode: Ut,
326
- indexOfNode: St,
327
- indexOfSorted: Q,
328
- indexOfTextNode: oe,
329
- insert: re,
330
- isElement: Mt,
331
- isFloat: Wt,
332
- isNumber: x,
333
- isXml: _t,
334
- locationOf: V,
335
- microTick: xt,
325
+ indexOfElementNode: jt,
326
+ indexOfNode: _t,
327
+ indexOfSorted: J,
328
+ indexOfTextNode: he,
329
+ insert: oe,
330
+ isElement: Wt,
331
+ isFloat: qt,
332
+ isNumber: b,
333
+ isXml: St,
334
+ locationOf: H,
335
+ microTick: bt,
336
336
  nodeBounds: ft,
337
337
  parents: vt,
338
338
  parse: W,
339
- qs: w,
339
+ qs: x,
340
340
  qsa: B,
341
341
  qsp: j,
342
342
  querySelectorByType: it,
343
- requestAnimationFrame: Dt,
343
+ requestAnimationFrame: Bt,
344
344
  revokeBlobUrl: Tt,
345
345
  sprint: et,
346
346
  treeWalker: Vt,
347
- type: Ft,
347
+ type: Ht,
348
348
  uuid: Et,
349
- walk: Ht,
349
+ walk: Xt,
350
350
  windowBounds: pt
351
351
  }, Symbol.toStringTag, { value: "Module" }));
352
- function H(a) {
352
+ function V(a) {
353
353
  if (typeof a != "string")
354
354
  throw new TypeError("Path must be a string. Received " + a);
355
355
  }
356
- function le(a, t) {
356
+ function ce(a, t) {
357
357
  let e = "", i = -1, s = 0, n;
358
358
  for (let r = 0; r <= a.length; ++r) {
359
359
  if (r < a.length)
@@ -392,12 +392,12 @@ function yt(...a) {
392
392
  let t = "", e = !1;
393
393
  for (let i = a.length - 1; i >= -1 && !e; i--) {
394
394
  const s = i >= 0 ? a[i] : "/";
395
- H(s), s.length !== 0 && (t = s + "/" + t, e = s.charCodeAt(0) === 47);
395
+ V(s), s.length !== 0 && (t = s + "/" + t, e = s.charCodeAt(0) === 47);
396
396
  }
397
- return t = le(t, !e), e ? t.length > 0 ? "/" + t : "/" : t.length > 0 ? t : ".";
397
+ return t = ce(t, !e), e ? t.length > 0 ? "/" + t : "/" : t.length > 0 ? t : ".";
398
398
  }
399
- function ce(a, t) {
400
- if (H(a), H(t), a === t || (a = yt(a), t = yt(t), a === t))
399
+ function de(a, t) {
400
+ if (V(a), V(t), a === t || (a = yt(a), t = yt(t), a === t))
401
401
  return "";
402
402
  let e = 1;
403
403
  for (; e < a.length && a.charCodeAt(e) === 47; ++e)
@@ -418,8 +418,8 @@ function ce(a, t) {
418
418
  } else s > h && (a.charCodeAt(e + c) === 47 ? l = c : c === 0 && (l = 0));
419
419
  break;
420
420
  }
421
- const u = a.charCodeAt(e + c), p = t.charCodeAt(n + c);
422
- if (u !== p)
421
+ const u = a.charCodeAt(e + c), m = t.charCodeAt(n + c);
422
+ if (u !== m)
423
423
  break;
424
424
  u === 47 && (l = c);
425
425
  }
@@ -428,8 +428,8 @@ function ce(a, t) {
428
428
  (c === i || a.charCodeAt(c) === 47) && (d.length === 0 ? d += ".." : d += "/..");
429
429
  return d.length > 0 ? d + t.slice(n + l) : (n += l, t.charCodeAt(n) === 47 && ++n, t.slice(n));
430
430
  }
431
- function de(a) {
432
- if (H(a), a.length === 0)
431
+ function ue(a) {
432
+ if (V(a), a.length === 0)
433
433
  return ".";
434
434
  let t = a.charCodeAt(0);
435
435
  const e = t === 47;
@@ -444,11 +444,11 @@ function de(a) {
444
444
  s = !1;
445
445
  return i === -1 ? e ? "/" : "." : e && i === 1 ? "//" : a.slice(0, i);
446
446
  }
447
- function ue(a) {
448
- return H(a), a.length > 0 && a.charCodeAt(0) === 47;
449
- }
450
447
  function fe(a) {
451
- H(a);
448
+ return V(a), a.length > 0 && a.charCodeAt(0) === 47;
449
+ }
450
+ function pe(a) {
451
+ V(a);
452
452
  const t = { root: "", dir: "", base: "", ext: "", name: "" };
453
453
  if (a.length === 0)
454
454
  return t;
@@ -469,7 +469,7 @@ function fe(a) {
469
469
  }
470
470
  return n === -1 || o === -1 || c === 0 || c === 1 && n === o - 1 && n === r + 1 ? o !== -1 && (r === 0 && i ? t.base = t.name = a.slice(1, o) : t.base = t.name = a.slice(r, o)) : (r === 0 && i ? (t.name = a.slice(1, n), t.base = a.slice(1, o)) : (t.name = a.slice(r, n), t.base = a.slice(r, o)), t.ext = a.slice(n, o)), r > 0 ? t.dir = a.slice(0, r - 1) : i && (t.dir = "/"), t;
471
471
  }
472
- const D = { resolve: yt, relative: ce, dirname: de, isAbsolute: ue, parse: fe };
472
+ const z = { resolve: yt, relative: de, dirname: ue, isAbsolute: fe, parse: pe };
473
473
  class O {
474
474
  constructor(t) {
475
475
  t.indexOf("://") > -1 && (t = new URL(t).pathname);
@@ -482,14 +482,14 @@ class O {
482
482
  * @returns {object}
483
483
  */
484
484
  parse(t) {
485
- return D.parse(t);
485
+ return z.parse(t);
486
486
  }
487
487
  /**
488
488
  * @param {string} what
489
489
  * @returns {boolean}
490
490
  */
491
491
  isAbsolute(t) {
492
- return D.isAbsolute(t || this.path);
492
+ return z.isAbsolute(t || this.path);
493
493
  }
494
494
  /**
495
495
  * Check if path ends with a directory
@@ -507,7 +507,7 @@ class O {
507
507
  * @returns {string} resolved
508
508
  */
509
509
  resolve(t) {
510
- return D.resolve(this.directory, t);
510
+ return z.resolve(this.directory, t);
511
511
  }
512
512
  /**
513
513
  * Resolve a path relative to the directory of the Path
@@ -517,7 +517,7 @@ class O {
517
517
  * @returns {string} relative
518
518
  */
519
519
  relative(t) {
520
- return t && t.indexOf("://") > -1 ? t : D.relative(this.directory, t);
520
+ return t && t.indexOf("://") > -1 ? t : z.relative(this.directory, t);
521
521
  }
522
522
  /**
523
523
  * Return the path string
@@ -553,7 +553,7 @@ class R {
553
553
  resolve(t) {
554
554
  if (t.indexOf("://") > -1)
555
555
  return t;
556
- const i = D.resolve(this.directory, t);
556
+ const i = z.resolve(this.directory, t);
557
557
  return this.origin + i;
558
558
  }
559
559
  /**
@@ -562,7 +562,7 @@ class R {
562
562
  * @returns {string} path
563
563
  */
564
564
  relative(t) {
565
- return D.relative(t, this.directory);
565
+ return z.relative(t, this.directory);
566
566
  }
567
567
  /**
568
568
  * @returns {string}
@@ -571,7 +571,7 @@ class R {
571
571
  return this.href;
572
572
  }
573
573
  }
574
- const U = 1, N = 3, pe = 9;
574
+ const U = 1, N = 3, ge = 9;
575
575
  class y {
576
576
  constructor(t, e, i) {
577
577
  if (this.str = "", this.base = {}, this.spinePos = 0, this.range = !1, this.path = {}, this.start = null, this.end = null, !(this instanceof y))
@@ -595,7 +595,7 @@ class y {
595
595
  * @private
596
596
  */
597
597
  checkType(t) {
598
- return this.isCfiString(t) ? "string" : t && typeof t == "object" && (Ft(t) === "Range" || typeof t.startContainer < "u") ? "range" : t && typeof t == "object" && typeof t.nodeType < "u" ? "node" : t && typeof t == "object" && t instanceof y ? "EpubCFI" : !1;
598
+ return this.isCfiString(t) ? "string" : t && typeof t == "object" && (Ht(t) === "Range" || typeof t.startContainer < "u") ? "range" : t && typeof t == "object" && typeof t.nodeType < "u" ? "node" : t && typeof t == "object" && t instanceof y ? "EpubCFI" : !1;
599
599
  }
600
600
  /**
601
601
  * Parse a cfi string to a CFI object representation
@@ -650,7 +650,7 @@ class y {
650
650
  parseTerminal(t) {
651
651
  let e, i = null;
652
652
  const s = t.match(/\[(.*)\]/);
653
- return s && s[1] ? (e = parseInt(t.split("[")[0]), i = s[1]) : e = parseInt(t), x(e) || (e = null), {
653
+ return s && s[1] ? (e = parseInt(t.split("[")[0]), i = s[1]) : e = parseInt(t), b(e) || (e = null), {
654
654
  offset: e,
655
655
  assertion: i
656
656
  };
@@ -745,7 +745,7 @@ class y {
745
745
  }
746
746
  };
747
747
  let n = t, r;
748
- for (; n && n.parentNode && n.parentNode.nodeType !== pe; )
748
+ for (; n && n.parentNode && n.parentNode.nodeType !== ge; )
749
749
  i ? r = this.filteredStep(n, i) : r = this.step(n), r && s.steps.unshift(r), n = n.parentNode;
750
750
  return e != null && e >= 0 && (s.terminal.offset = e, s.steps.length > 0 && s.steps[s.steps.length - 1].type !== "text" && s.steps.push({
751
751
  type: "text",
@@ -926,12 +926,12 @@ class y {
926
926
  const l = this;
927
927
  let c, d;
928
928
  const u = e ? i.querySelector("." + e) != null : !1;
929
- let p;
930
- if (typeof i.createRange < "u" ? s = i.createRange() : s = new Yt(), l.range ? (n = l.start, c = l.path.steps.concat(n.steps), o = this.findNode(c, i, u ? e : void 0), r = l.end, d = l.path.steps.concat(r.steps), h = this.findNode(d, i, u ? e : void 0)) : (n = l.path, c = l.path.steps, o = this.findNode(l.path.steps, i, u ? e : void 0)), o)
929
+ let m;
930
+ if (typeof i.createRange < "u" ? s = i.createRange() : s = new Gt(), l.range ? (n = l.start, c = l.path.steps.concat(n.steps), o = this.findNode(c, i, u ? e : void 0), r = l.end, d = l.path.steps.concat(r.steps), h = this.findNode(d, i, u ? e : void 0)) : (n = l.path, c = l.path.steps, o = this.findNode(l.path.steps, i, u ? e : void 0)), o)
931
931
  try {
932
932
  n.terminal.offset != null ? s.setStart(o, n.terminal.offset) : s.setStart(o, 0);
933
933
  } catch {
934
- p = this.fixMiss(c, n.terminal.offset, i, u ? e : void 0), s.setStart(p.container, p.offset);
934
+ m = this.fixMiss(c, n.terminal.offset, i, u ? e : void 0), s.setStart(m.container, m.offset);
935
935
  }
936
936
  else
937
937
  return console.log("No startContainer found for", this.toString()), null;
@@ -939,7 +939,7 @@ class y {
939
939
  try {
940
940
  r.terminal.offset != null ? s.setEnd(h, r.terminal.offset) : s.setEnd(h, 0);
941
941
  } catch {
942
- p = this.fixMiss(d, l.end.terminal.offset, i, u ? e : void 0), s.setEnd(p.container, p.offset);
942
+ m = this.fixMiss(d, l.end.terminal.offset, i, u ? e : void 0), s.setEnd(m.container, m.offset);
943
943
  }
944
944
  return s;
945
945
  }
@@ -1018,35 +1018,35 @@ class A {
1018
1018
  return this.hooks = [];
1019
1019
  }
1020
1020
  }
1021
- function Gt(a, t) {
1021
+ function $t(a, t) {
1022
1022
  let e, i = t.url;
1023
1023
  const s = i.indexOf("://") > -1;
1024
1024
  if (!a)
1025
1025
  return;
1026
- const n = w(a, "head");
1027
- e = w(n, "base"), e || (e = a.createElement("base"), n.insertBefore(e, n.firstChild)), !s && typeof window < "u" && window.location && (i = window.location.origin + i), e.setAttribute("href", i);
1026
+ const n = x(a, "head");
1027
+ e = x(n, "base"), e || (e = a.createElement("base"), n.insertBefore(e, n.firstChild)), !s && typeof window < "u" && window.location && (i = window.location.origin + i), e.setAttribute("href", i);
1028
1028
  }
1029
- function ge(a, t) {
1029
+ function me(a, t) {
1030
1030
  let e;
1031
1031
  const i = t.canonical;
1032
1032
  if (!a)
1033
1033
  return;
1034
- const s = w(a, "head");
1035
- e = w(s, "link[rel='canonical']"), e ? e.setAttribute("href", i) : (e = a.createElement("link"), e.setAttribute("rel", "canonical"), e.setAttribute("href", i), s.appendChild(e));
1034
+ const s = x(a, "head");
1035
+ e = x(s, "link[rel='canonical']"), e ? e.setAttribute("href", i) : (e = a.createElement("link"), e.setAttribute("rel", "canonical"), e.setAttribute("href", i), s.appendChild(e));
1036
1036
  }
1037
- function me(a, t) {
1037
+ function ve(a, t) {
1038
1038
  let e;
1039
1039
  const i = t.idref;
1040
1040
  if (!a)
1041
1041
  return;
1042
- const s = w(a, "head");
1043
- e = w(s, "link[property='dc.identifier']"), e ? e.setAttribute("content", i) : (e = a.createElement("meta"), e.setAttribute("name", "dc.identifier"), e.setAttribute("content", i), s.appendChild(e));
1042
+ const s = x(a, "head");
1043
+ e = x(s, "link[property='dc.identifier']"), e ? e.setAttribute("content", i) : (e = a.createElement("meta"), e.setAttribute("name", "dc.identifier"), e.setAttribute("content", i), s.appendChild(e));
1044
1044
  }
1045
- function ve(a, t) {
1045
+ function ye(a, t) {
1046
1046
  const e = a.querySelectorAll("a[href]");
1047
1047
  if (!e.length)
1048
1048
  return;
1049
- const i = w(a.ownerDocument, "base"), s = i ? i.getAttribute("href") ?? void 0 : void 0, n = function(r) {
1049
+ const i = x(a.ownerDocument, "base"), s = i ? i.getAttribute("href") ?? void 0 : void 0, n = function(r) {
1050
1050
  const o = r.getAttribute("href") ?? "";
1051
1051
  if (o.indexOf("mailto:") === 0)
1052
1052
  return;
@@ -1118,9 +1118,9 @@ async function Y(a, t, e, i) {
1118
1118
  if (t === "json")
1119
1119
  return n.json();
1120
1120
  const r = await n.text();
1121
- return _t(t) ? W(r, "text/xml") : t === "xhtml" ? W(r, "application/xhtml+xml") : t === "html" || t === "htm" ? W(r, "text/html") : r;
1121
+ return St(t) ? W(r, "text/xml") : t === "xhtml" ? W(r, "application/xhtml+xml") : t === "html" || t === "htm" ? W(r, "text/html") : r;
1122
1122
  }
1123
- class ye {
1123
+ class we {
1124
1124
  constructor(t, e) {
1125
1125
  this.idref = t.idref, this.linear = t.linear === "yes", this.properties = t.properties, this.index = t.index, this.href = t.href, this.url = t.url, this.canonical = t.canonical, this.next = t.next, this.prev = t.prev, this.cfiBase = t.cfiBase, e ? this.hooks = e : (this.hooks = {}, this.hooks.serialize = new A(this), this.hooks.content = new A(this)), this.document = void 0, this.contents = void 0, this.output = void 0;
1126
1126
  }
@@ -1141,7 +1141,7 @@ class ye {
1141
1141
  * @private
1142
1142
  */
1143
1143
  base() {
1144
- return Gt(this.document, this);
1144
+ return $t(this.document, this);
1145
1145
  }
1146
1146
  /**
1147
1147
  * Render the contents of a section
@@ -1161,9 +1161,9 @@ class ye {
1161
1161
  const e = this, i = [], s = t.toLowerCase(), n = function(r) {
1162
1162
  const o = r.textContent.toLowerCase();
1163
1163
  let h, l, c, d = -1, u;
1164
- const p = 150;
1164
+ const m = 150;
1165
1165
  for (; c !== -1; )
1166
- c = o.indexOf(s, d + 1), c !== -1 && (h = e.document.createRange(), h.setStart(r, c), h.setEnd(r, c + s.length), l = e.cfiFromRange(h), r.textContent.length < p ? u = r.textContent : (u = r.textContent.substring(c - p / 2, c + p / 2), u = "..." + u + "..."), i.push({
1166
+ c = o.indexOf(s, d + 1), c !== -1 && (h = e.document.createRange(), h.setStart(r, c), h.setEnd(r, c + s.length), l = e.cfiFromRange(h), r.textContent.length < m ? u = r.textContent : (u = r.textContent.substring(c - m / 2, c + m / 2), u = "..." + u + "..."), i.push({
1167
1167
  cfi: l,
1168
1168
  excerpt: u
1169
1169
  })), d = c;
@@ -1180,22 +1180,22 @@ class ye {
1180
1180
  */
1181
1181
  search(t, e = 5) {
1182
1182
  const i = [], n = this, r = t.toLowerCase(), o = function(d) {
1183
- const g = d.reduce((m, v) => m + (v.textContent ?? ""), "").toLowerCase().indexOf(r);
1184
- if (g !== -1) {
1185
- const v = g + r.length;
1186
- let b = 0, k = 0;
1187
- if (g < d[0].length) {
1188
- for (; b < d.length - 1 && (k += d[b].length, !(v <= k)); )
1189
- b += 1;
1190
- const E = d[0], _ = d[b], T = n.document.createRange();
1191
- T.setStart(E, g);
1192
- const I = d.slice(0, b).reduce((rt, ot) => rt + (ot.textContent ?? "").length, 0);
1193
- T.setEnd(_, I > v ? v : v - I);
1183
+ const f = d.reduce((p, v) => p + (v.textContent ?? ""), "").toLowerCase().indexOf(r);
1184
+ if (f !== -1) {
1185
+ const v = f + r.length;
1186
+ let w = 0, k = 0;
1187
+ if (f < d[0].length) {
1188
+ for (; w < d.length - 1 && (k += d[w].length, !(v <= k)); )
1189
+ w += 1;
1190
+ const E = d[0], S = d[w], T = n.document.createRange();
1191
+ T.setStart(E, f);
1192
+ const I = d.slice(0, w).reduce((rt, ot) => rt + (ot.textContent ?? "").length, 0);
1193
+ T.setEnd(S, I > v ? v : v - I);
1194
1194
  const M = n.cfiFromRange(T);
1195
- let z = d.slice(0, b + 1).reduce((rt, ot) => rt + (ot.textContent ?? ""), "");
1196
- z.length > 150 && (z = z.substring(g - 150 / 2, g + 150 / 2), z = "..." + z + "..."), i.push({
1195
+ let D = d.slice(0, w + 1).reduce((rt, ot) => rt + (ot.textContent ?? ""), "");
1196
+ D.length > 150 && (D = D.substring(f - 150 / 2, f + 150 / 2), D = "..." + D + "..."), i.push({
1197
1197
  cfi: M,
1198
- excerpt: z
1198
+ excerpt: D
1199
1199
  });
1200
1200
  }
1201
1201
  }
@@ -1249,9 +1249,9 @@ class ye {
1249
1249
  this.unload(), this.hooks.serialize.clear(), this.hooks.content.clear(), this.hooks = void 0, this.idref = void 0, this.linear = void 0, this.properties = void 0, this.index = void 0, this.href = void 0, this.url = void 0, this.next = void 0, this.prev = void 0, this.cfiBase = void 0;
1250
1250
  }
1251
1251
  }
1252
- class we {
1252
+ class xe {
1253
1253
  constructor() {
1254
- this.spineItems = [], this.spineByHref = {}, this.spineById = {}, this.hooks = {}, this.hooks.serialize = new A(), this.hooks.content = new A(), this.hooks.content.register(Gt), this.hooks.content.register(ge), this.hooks.content.register(me), this.epubcfi = new y(), this.loaded = !1, this.items = [], this.manifest = {}, this.spineNodeIndex = 0, this.baseUrl = "", this.length = 0;
1254
+ this.spineItems = [], this.spineByHref = {}, this.spineById = {}, this.hooks = {}, this.hooks.serialize = new A(), this.hooks.content = new A(), this.hooks.content.register($t), this.hooks.content.register(me), this.hooks.content.register(ve), this.epubcfi = new y(), this.loaded = !1, this.items = [], this.manifest = {}, this.spineNodeIndex = 0, this.baseUrl = "", this.length = 0;
1255
1255
  }
1256
1256
  /**
1257
1257
  * Unpack items from a opf into spine items
@@ -1281,7 +1281,7 @@ class we {
1281
1281
  }) : (s.prev = function() {
1282
1282
  }, s.next = function() {
1283
1283
  });
1284
- const o = new ye(s, this.hooks);
1284
+ const o = new we(s, this.hooks);
1285
1285
  this.append(o);
1286
1286
  }), this.loaded = !0;
1287
1287
  }
@@ -1377,14 +1377,14 @@ class we {
1377
1377
  }
1378
1378
  class kt {
1379
1379
  constructor(t) {
1380
- this._q = [], this.context = t, this.tick = Dt, this.running = !1, this.paused = !1;
1380
+ this._q = [], this.context = t, this.tick = Bt, this.running = !1, this.paused = !1;
1381
1381
  }
1382
1382
  enqueue(...t) {
1383
1383
  let e, i, s;
1384
1384
  const [n, ...r] = t;
1385
1385
  if (!n)
1386
1386
  throw new Error("No Task Provided");
1387
- return typeof n == "function" ? (e = new S(), i = e.promise, s = {
1387
+ return typeof n == "function" ? (e = new _(), i = e.promise, s = {
1388
1388
  task: n,
1389
1389
  args: r,
1390
1390
  //"context" : context,
@@ -1417,7 +1417,7 @@ class kt {
1417
1417
  * @return {Promise}
1418
1418
  */
1419
1419
  run() {
1420
- this.running || (this.running = !0, this.defered = new S());
1420
+ this.running || (this.running = !0, this.defered = new _());
1421
1421
  const t = () => {
1422
1422
  var e;
1423
1423
  this._q.length ? (e = this.dequeue()) == null || e.then(() => {
@@ -1463,7 +1463,7 @@ class kt {
1463
1463
  this._q = [], this.running = !1, this.paused = !0;
1464
1464
  }
1465
1465
  }
1466
- const nt = "0.3", Z = ["keydown", "keyup", "keypress", "mouseup", "mousedown", "mousemove", "click", "dblclick", "touchend", "touchstart", "touchmove"], f = {
1466
+ const nt = "0.3", Z = ["keydown", "keyup", "keypress", "mouseup", "mousedown", "mousemove", "click", "dblclick", "touchend", "touchstart", "touchmove"], g = {
1467
1467
  BOOK: {
1468
1468
  OPEN_FAILED: "openFailed"
1469
1469
  },
@@ -1520,9 +1520,9 @@ const nt = "0.3", Z = ["keydown", "keyup", "keypress", "mouseup", "mousedown", "
1520
1520
  DETACH: "detach"
1521
1521
  }
1522
1522
  };
1523
- class $t {
1523
+ class Kt {
1524
1524
  constructor(t, e, i) {
1525
- this.spine = t, this.request = e, this.pause = i || 0, this.q = new kt(this), this.q.tick = xt, this.epubcfi = new y(), this._locations = [], this._locationsWords = [], this.total = 0, this.break = 150, this._current = 0, this._wordCounter = 0, this._currentCfi = "", this.processingTimeout = void 0;
1525
+ this.spine = t, this.request = e, this.pause = i || 0, this.q = new kt(this), this.q.tick = bt, this.epubcfi = new y(), this._locations = [], this._locationsWords = [], this.total = 0, this.break = 150, this._current = 0, this._wordCounter = 0, this._currentCfi = "", this.processingTimeout = void 0;
1526
1526
  }
1527
1527
  /**
1528
1528
  * Load all of sections in the book to generate locations
@@ -1551,19 +1551,19 @@ class $t {
1551
1551
  parse(t, e, i) {
1552
1552
  const s = [];
1553
1553
  let n;
1554
- const r = t.ownerDocument, o = w(r, "body");
1554
+ const r = t.ownerDocument, o = x(r, "body");
1555
1555
  let h = 0, l;
1556
1556
  const c = i || this.break;
1557
1557
  if (et(o, (u) => {
1558
- const p = u.length;
1559
- let g, m = 0;
1558
+ const m = u.length;
1559
+ let f, p = 0;
1560
1560
  if ((u.textContent ?? "").trim().length === 0)
1561
1561
  return l = u, !1;
1562
- for (h === 0 && (n = this.createRange(), n.startContainer = u, n.startOffset = 0), g = c - h, g > p && (h += p, m = p); m < p; )
1563
- if (g = c - h, h === 0 && (m += 1, n = this.createRange(), n.startContainer = u, n.startOffset = m), m + g >= p)
1564
- h += p - m, m = p;
1562
+ for (h === 0 && (n = this.createRange(), n.startContainer = u, n.startOffset = 0), f = c - h, f > m && (h += m, p = m); p < m; )
1563
+ if (f = c - h, h === 0 && (p += 1, n = this.createRange(), n.startContainer = u, n.startOffset = p), p + f >= m)
1564
+ h += m - p, p = m;
1565
1565
  else {
1566
- m += g, n.endContainer = u, n.endOffset = m;
1566
+ p += f, n.endContainer = u, n.endOffset = p;
1567
1567
  const v = new y(n, e).toString();
1568
1568
  s.push(v), h = 0;
1569
1569
  }
@@ -1602,27 +1602,27 @@ class $t {
1602
1602
  `), t.split(" ").length;
1603
1603
  }
1604
1604
  parseWords(t, e, i, s) {
1605
- const n = e.cfiBase, r = [], o = t.ownerDocument, h = w(o, "body"), l = i;
1605
+ const n = e.cfiBase, r = [], o = t.ownerDocument, h = x(o, "body"), l = i;
1606
1606
  let c = s ? s.spinePos !== e.index : !0, d;
1607
- return s && e.index === s.spinePos && (d = s.findNode(s.range ? s.path.steps.concat(s.start.steps) : s.path.steps, t.ownerDocument)), et(h, (p) => {
1607
+ return s && e.index === s.spinePos && (d = s.findNode(s.range ? s.path.steps.concat(s.start.steps) : s.path.steps, t.ownerDocument)), et(h, (m) => {
1608
1608
  if (!c)
1609
- if (p === d)
1609
+ if (m === d)
1610
1610
  c = !0;
1611
1611
  else
1612
1612
  return !1;
1613
- if ((p.textContent ?? "").length < 10 && (p.textContent ?? "").trim().length === 0)
1613
+ if ((m.textContent ?? "").length < 10 && (m.textContent ?? "").trim().length === 0)
1614
1614
  return !1;
1615
- const g = this.countWords(p.textContent ?? "");
1616
- let m, v = 0;
1617
- if (g === 0)
1615
+ const f = this.countWords(m.textContent ?? "");
1616
+ let p, v = 0;
1617
+ if (f === 0)
1618
1618
  return !1;
1619
- for (m = l - this._wordCounter, m > g && (this._wordCounter += g, v = g); v < g; )
1620
- if (m = l - this._wordCounter, v + m >= g)
1621
- this._wordCounter += g - v, v = g;
1619
+ for (p = l - this._wordCounter, p > f && (this._wordCounter += f, v = f); v < f; )
1620
+ if (p = l - this._wordCounter, v + p >= f)
1621
+ this._wordCounter += f - v, v = f;
1622
1622
  else {
1623
- v += m;
1624
- const b = new y(p, n);
1625
- r.push({ cfi: b.toString(), wordCount: this._wordCounter }), this._wordCounter = 0;
1623
+ v += p;
1624
+ const w = new y(m, n);
1625
+ r.push({ cfi: w.toString(), wordCount: this._wordCounter }), this._wordCounter = 0;
1626
1626
  }
1627
1627
  return !1;
1628
1628
  }), r;
@@ -1635,7 +1635,7 @@ class $t {
1635
1635
  locationFromCfi(t) {
1636
1636
  if (y.prototype.isCfiString(t) && (t = new y(t)), this._locations.length === 0)
1637
1637
  return -1;
1638
- const e = V(t, this._locations, this.epubcfi.compare);
1638
+ const e = H(t, this._locations, this.epubcfi.compare);
1639
1639
  return e > this.total ? this.total : e;
1640
1640
  }
1641
1641
  /**
@@ -1704,7 +1704,7 @@ class $t {
1704
1704
  this._current = t;
1705
1705
  else
1706
1706
  return;
1707
- this._locations.length !== 0 && (typeof t == "string" ? (e = this.locationFromCfi(t), this._current = e) : e = t, this.emit(f.LOCATIONS.CHANGED, {
1707
+ this._locations.length !== 0 && (typeof t == "string" ? (e = this.locationFromCfi(t), this._current = e) : e = t, this.emit(g.LOCATIONS.CHANGED, {
1708
1708
  percentage: this.percentageFromLocation(e)
1709
1709
  }));
1710
1710
  }
@@ -1731,7 +1731,7 @@ class $t {
1731
1731
  this.spine = void 0, this.request = void 0, this.pause = void 0, (t = this.q) == null || t.stop(), this.q = void 0, this.epubcfi = void 0, this._locations = void 0, this.total = void 0, this.break = void 0, this._current = void 0, this.currentLocation = void 0, this._currentCfi = void 0, clearTimeout(this.processingTimeout);
1732
1732
  }
1733
1733
  }
1734
- P($t.prototype);
1734
+ P(Kt.prototype);
1735
1735
  class be {
1736
1736
  constructor(t) {
1737
1737
  this.packagePath = "", this.directory = "", this.encoding = "", t && this.parse(t);
@@ -1743,10 +1743,10 @@ class be {
1743
1743
  parse(t) {
1744
1744
  if (!t)
1745
1745
  throw new Error("Container File Not Found");
1746
- const e = w(t, "rootfile");
1746
+ const e = x(t, "rootfile");
1747
1747
  if (!e)
1748
1748
  throw new Error("No RootFile Found");
1749
- this.packagePath = e.getAttribute("full-path") ?? "", this.directory = D.dirname(this.packagePath), this.encoding = t.xmlEncoding;
1749
+ this.packagePath = e.getAttribute("full-path") ?? "", this.directory = z.dirname(this.packagePath), this.encoding = t.xmlEncoding;
1750
1750
  }
1751
1751
  destroy() {
1752
1752
  this.packagePath = void 0, this.directory = void 0, this.encoding = void 0;
@@ -1764,16 +1764,16 @@ class It {
1764
1764
  parse(t) {
1765
1765
  if (!t)
1766
1766
  throw new Error("Package File Not Found");
1767
- const e = w(t, "metadata");
1767
+ const e = x(t, "metadata");
1768
1768
  if (!e)
1769
1769
  throw new Error("No Metadata Found");
1770
- const i = w(t, "manifest");
1770
+ const i = x(t, "manifest");
1771
1771
  if (!i)
1772
1772
  throw new Error("No Manifest Found");
1773
- const s = w(t, "spine");
1773
+ const s = x(t, "spine");
1774
1774
  if (!s)
1775
1775
  throw new Error("No Spine Found");
1776
- return this.manifest = this.parseManifest(i), this.navPath = this.findNavPath(i), this.ncxPath = this.findNcxPath(i, s), this.coverPath = this.findCoverPath(t), this.spineNodeIndex = Ut(s), this.spine = this.parseSpine(s, this.manifest), this.uniqueIdentifier = this.findUniqueIdentifier(t), this.metadata = this.parseMetadata(e), this.metadata.direction = s.getAttribute("page-progression-direction") ?? "", {
1776
+ return this.manifest = this.parseManifest(i), this.navPath = this.findNavPath(i), this.ncxPath = this.findNcxPath(i, s), this.coverPath = this.findCoverPath(t), this.spineNodeIndex = jt(s), this.spine = this.parseSpine(s, this.manifest), this.uniqueIdentifier = this.findUniqueIdentifier(t), this.metadata = this.parseMetadata(e), this.metadata.direction = s.getAttribute("page-progression-direction") ?? "", {
1777
1777
  metadata: this.metadata,
1778
1778
  spine: this.spine,
1779
1779
  manifest: this.manifest,
@@ -1880,7 +1880,7 @@ class It {
1880
1880
  * @return {string} href
1881
1881
  */
1882
1882
  findCoverPath(t) {
1883
- const e = w(t, "package");
1883
+ const e = x(t, "package");
1884
1884
  e == null || e.getAttribute("version");
1885
1885
  const i = j(t, "item", { properties: "cover-image" });
1886
1886
  if (i) return i.getAttribute("href") ?? "";
@@ -1951,7 +1951,7 @@ class ht {
1951
1951
  parse(t) {
1952
1952
  const e = t.nodeType;
1953
1953
  let i, s;
1954
- e && (i = w(t, "html"), s = w(t, "ncx")), e ? i ? (this.toc = this.parseNav(t), this.landmarks = this.parseLandmarks(t)) : s && (this.toc = this.parseNcx(t)) : this.toc = this.load(t), this.length = 0, this.unpack(this.toc);
1954
+ e && (i = x(t, "html"), s = x(t, "ncx")), e ? i ? (this.toc = this.parseNav(t), this.landmarks = this.parseLandmarks(t)) : s && (this.toc = this.parseNcx(t)) : this.toc = this.load(t), this.length = 0, this.unpack(this.toc);
1955
1955
  }
1956
1956
  /**
1957
1957
  * Unpack navigation items
@@ -2112,7 +2112,7 @@ class ht {
2112
2112
  * @return {object} ncxItem
2113
2113
  */
2114
2114
  ncxItem(t) {
2115
- const e = t.getAttribute("id") || "", i = w(t, "content"), s = i ? i.getAttribute("src") ?? "" : "", n = w(t, "navLabel"), r = n != null && n.textContent ? n.textContent : "", o = [], h = t.parentNode;
2115
+ const e = t.getAttribute("id") || "", i = x(t, "content"), s = i ? i.getAttribute("src") ?? "" : "", n = x(t, "navLabel"), r = n != null && n.textContent ? n.textContent : "", o = [], h = t.parentNode;
2116
2116
  let l;
2117
2117
  return h && (h.nodeName === "navPoint" || h.nodeName.split(":").slice(-1)[0] === "navPoint") && (l = h.getAttribute("id") ?? void 0), {
2118
2118
  id: e,
@@ -2276,7 +2276,7 @@ const at = {
2276
2276
  "x-ms-vob": "vob",
2277
2277
  "x-smv": "smv"
2278
2278
  }
2279
- }, xe = (function() {
2279
+ }, Ee = (function() {
2280
2280
  let a, t, e, i;
2281
2281
  const s = {};
2282
2282
  for (a in at)
@@ -2291,12 +2291,12 @@ const at = {
2291
2291
  s[e[i]] = a + "/" + t;
2292
2292
  }
2293
2293
  return s;
2294
- })(), Ee = "text/plain";
2294
+ })(), _e = "text/plain";
2295
2295
  function Se(a) {
2296
- return a && xe[a.split(".").pop().toLowerCase()] || Ee;
2296
+ return a && Ee[a.split(".").pop().toLowerCase()] || _e;
2297
2297
  }
2298
2298
  const G = { lookup: Se };
2299
- class _e {
2299
+ class Ce {
2300
2300
  constructor(t, e) {
2301
2301
  this.settings = {
2302
2302
  replacements: e && e.replacements || "base64",
@@ -2343,7 +2343,7 @@ class _e {
2343
2343
  */
2344
2344
  createUrl(t) {
2345
2345
  const e = new R(t), i = G.lookup(e.filename);
2346
- return this.settings.archive ? this.settings.archive.createUrl(t, { base64: this.settings.replacements === "base64" }) : this.settings.replacements === "base64" ? this.settings.request(t, "blob").then((s) => Xt(s)).then((s) => gt(s, i)) : this.settings.request(t, "blob").then((s) => tt(s, i));
2346
+ return this.settings.archive ? this.settings.archive.createUrl(t, { base64: this.settings.replacements === "base64" }) : this.settings.replacements === "base64" ? this.settings.request(t, "blob").then((s) => Yt(s)).then((s) => gt(s, i)) : this.settings.request(t, "blob").then((s) => tt(s, i));
2347
2347
  }
2348
2348
  /**
2349
2349
  * Create blob urls for all the assets
@@ -2387,7 +2387,7 @@ class _e {
2387
2387
  */
2388
2388
  createCssFile(t) {
2389
2389
  let e;
2390
- if (D.isAbsolute(t))
2390
+ if (z.isAbsolute(t))
2391
2391
  return new Promise(function(r) {
2392
2392
  r();
2393
2393
  });
@@ -2457,7 +2457,7 @@ class lt {
2457
2457
  * @param {document} xml
2458
2458
  */
2459
2459
  parse(t) {
2460
- const e = w(t, "html"), i = w(t, "ncx");
2460
+ const e = x(t, "html"), i = x(t, "ncx");
2461
2461
  return e ? this.parseNav(t) : i ? this.parseNcx(t) : [];
2462
2462
  }
2463
2463
  /**
@@ -2479,7 +2479,7 @@ class lt {
2479
2479
  parseNcx(t) {
2480
2480
  const e = [];
2481
2481
  let i = 0, s, n = 0;
2482
- const r = w(t, "pageList");
2482
+ const r = x(t, "pageList");
2483
2483
  if (!r) return e;
2484
2484
  const o = B(r, "pageTarget");
2485
2485
  if (n = o.length, !o || o.length === 0)
@@ -2489,7 +2489,7 @@ class lt {
2489
2489
  return e;
2490
2490
  }
2491
2491
  ncxItem(t) {
2492
- const e = w(t, "navLabel"), s = w(e, "text").textContent ?? "", r = w(t, "content").getAttribute("src") ?? "", o = parseInt(s, 10);
2492
+ const e = x(t, "navLabel"), s = x(e, "text").textContent ?? "", r = x(t, "content").getAttribute("src") ?? "", o = parseInt(s, 10);
2493
2493
  return {
2494
2494
  href: r,
2495
2495
  page: o
@@ -2502,7 +2502,7 @@ class lt {
2502
2502
  * @return {object} pageListItem
2503
2503
  */
2504
2504
  item(t) {
2505
- const e = w(t, "a"), i = e.getAttribute("href") || "", s = e.textContent || "", n = parseInt(s), r = i.indexOf("epubcfi");
2505
+ const e = x(t, "a"), i = e.getAttribute("href") || "", s = e.textContent || "", n = parseInt(s), r = i.indexOf("epubcfi");
2506
2506
  let o, h, l;
2507
2507
  return r !== -1 ? (o = i.split("#"), h = o[0], l = o.length > 1 ? o[1] : void 0, {
2508
2508
  cfi: l,
@@ -2533,8 +2533,8 @@ class lt {
2533
2533
  let e = -1;
2534
2534
  if (this.locations.length === 0)
2535
2535
  return -1;
2536
- let i = Q(t, this.locations, this.epubcfi.compare);
2537
- return i !== -1 ? e = this.pages[i] : (i = V(t, this.locations, this.epubcfi.compare), e = i - 1 >= 0 ? this.pages[i - 1] : this.pages[0], e !== void 0 || (e = -1)), e;
2536
+ let i = J(t, this.locations, this.epubcfi.compare);
2537
+ return i !== -1 ? e = this.pages[i] : (i = H(t, this.locations, this.epubcfi.compare), e = i - 1 >= 0 ? this.pages[i - 1] : this.pages[0], e !== void 0 || (e = -1)), e;
2538
2538
  }
2539
2539
  /**
2540
2540
  * Get an EpubCFI from a Page List Item
@@ -2580,7 +2580,7 @@ class lt {
2580
2580
  this.pages = void 0, this.locations = void 0, this.epubcfi = void 0, this.pageList = void 0, this.toc = void 0, this.ncx = void 0;
2581
2581
  }
2582
2582
  }
2583
- class Kt {
2583
+ class Zt {
2584
2584
  constructor(t) {
2585
2585
  this.settings = t, this.name = t.layout || "reflowable", this._spread = t.spread !== "none", this._minSpreadWidth = t.minSpreadWidth || 800, this._evenSpreads = t.evenSpreads || !1, t.flow === "scrolled" || t.flow === "scrolled-continuous" || t.flow === "scrolled-doc" ? this._flow = "scrolled" : this._flow = "paginated", this.width = 0, this.height = 0, this.spreadWidth = 0, this.delta = 0, this.columnWidth = 0, this.gap = 0, this.divisor = 1, this.props = {
2586
2586
  name: this.name,
@@ -2669,12 +2669,12 @@ class Kt {
2669
2669
  i[s] === e[s] && delete e[s];
2670
2670
  }), Object.keys(e).length > 0) {
2671
2671
  const s = C(this.props, t);
2672
- this.emit(f.LAYOUT.UPDATED, s, t);
2672
+ this.emit(g.LAYOUT.UPDATED, s, t);
2673
2673
  }
2674
2674
  }
2675
2675
  }
2676
- P(Kt.prototype);
2677
- class Ce {
2676
+ P(Zt.prototype);
2677
+ class Te {
2678
2678
  constructor(t) {
2679
2679
  this.rendition = t, this._themes = {
2680
2680
  default: {
@@ -2839,7 +2839,7 @@ class Ce {
2839
2839
  this.rendition = void 0, this._themes = void 0, this._overrides = void 0, this._current = void 0, this._injected = void 0;
2840
2840
  }
2841
2841
  }
2842
- class Te {
2842
+ class ke {
2843
2843
  constructor(t) {
2844
2844
  this.rendition = t, this.highlights = [], this.underlines = [], this.marks = [], this._annotations = {}, this._annotationsBySectionIndex = {}, this.rendition.hooks.render.register((e) => this.inject(e)), this.rendition.hooks.unloaded.register((e) => this.clear(e));
2845
2845
  }
@@ -2854,7 +2854,7 @@ class Te {
2854
2854
  * @returns {Annotation} annotation
2855
2855
  */
2856
2856
  add(t, e, i, s, n, r) {
2857
- const o = encodeURI(e + t), l = new y(e).spinePos, c = new Zt({
2857
+ const o = encodeURI(e + t), l = new y(e).spinePos, c = new Jt({
2858
2858
  type: t,
2859
2859
  cfiRange: e,
2860
2860
  data: i,
@@ -2962,18 +2962,16 @@ class Te {
2962
2962
  }
2963
2963
  /**
2964
2964
  * [Not Implemented] Show annotations
2965
- * @TODO: needs implementation in View
2966
2965
  */
2967
2966
  show() {
2968
2967
  }
2969
2968
  /**
2970
2969
  * [Not Implemented] Hide annotations
2971
- * @TODO: needs implementation in View
2972
2970
  */
2973
2971
  hide() {
2974
2972
  }
2975
2973
  }
2976
- class Zt {
2974
+ class Jt {
2977
2975
  constructor({
2978
2976
  type: t,
2979
2977
  cfiRange: e,
@@ -2999,7 +2997,7 @@ class Zt {
2999
2997
  attach(t) {
3000
2998
  const { cfiRange: e, data: i, type: s, mark: n, cb: r, className: o, styles: h } = this;
3001
2999
  let l;
3002
- return s === "highlight" ? l = t.highlight(e, i, r, o, h) : s === "underline" ? l = t.underline(e, i, r, o, h) : s === "mark" && (l = t.mark(e, i, r)), this.mark = l, this.emit(f.ANNOTATION.ATTACH, l), l;
3000
+ return s === "highlight" ? l = t.highlight(e, i, r, o, h) : s === "underline" ? l = t.underline(e, i, r, o, h) : s === "mark" && (l = t.mark(e, i, r)), this.mark = l, this.emit(g.ANNOTATION.ATTACH, l), l;
3003
3001
  }
3004
3002
  /**
3005
3003
  * Remove from a view
@@ -3007,19 +3005,18 @@ class Zt {
3007
3005
  */
3008
3006
  detach(t) {
3009
3007
  const { cfiRange: e, type: i } = this;
3010
- t && (i === "highlight" ? t.unhighlight(e) : i === "underline" ? t.ununderline(e) : i === "mark" && t.unmark(e)), this.mark = void 0, this.emit(f.ANNOTATION.DETACH);
3008
+ t && (i === "highlight" ? t.unhighlight(e) : i === "underline" ? t.ununderline(e) : i === "mark" && t.unmark(e)), this.mark = void 0, this.emit(g.ANNOTATION.DETACH);
3011
3009
  }
3012
3010
  /**
3013
3011
  * [Not Implemented] Get text of an annotation
3014
- * @TODO: needs implementation in contents
3015
3012
  */
3016
3013
  text() {
3017
3014
  }
3018
3015
  }
3019
- P(Zt.prototype);
3016
+ P(Jt.prototype);
3020
3017
  class wt {
3021
- constructor(t, e, i, s = !1) {
3022
- this.layout = t, this.horizontal = i === "horizontal", this.direction = e || "ltr", this._dev = s;
3018
+ constructor(t, e, i, s = !1, n) {
3019
+ this.layout = t, this.horizontal = i === "horizontal", this.direction = e || "ltr", this._dev = s, this._measurer = n || null;
3023
3020
  }
3024
3021
  /**
3025
3022
  * Find CFI pairs for entire section at once
@@ -3087,33 +3084,33 @@ class wt {
3087
3084
  */
3088
3085
  findStart(t, e, i) {
3089
3086
  const s = [t];
3090
- let n, r, o = t;
3087
+ let n, r, o = t, h;
3091
3088
  for (; s.length; )
3092
- if (n = s.shift(), r = this.walk(n, (h) => {
3093
- let l, c, d, u;
3094
- const p = ft(h);
3095
- if (this.horizontal && this.direction === "ltr") {
3096
- if (l = this.horizontal ? p.left : p.top, c = this.horizontal ? p.right : p.bottom, l >= e && l <= i)
3097
- return h;
3098
- if (c > e)
3099
- return h;
3100
- o = h, s.push(h);
3089
+ if (n = s.shift(), r = this.walk(n, (l) => {
3090
+ let c, d, u, m;
3091
+ const f = ft(l);
3092
+ if (h = f, this.horizontal && this.direction === "ltr") {
3093
+ if (c = f.left, d = f.right, c >= e && c <= i)
3094
+ return l;
3095
+ if (d > e)
3096
+ return l;
3097
+ o = l, s.push(l);
3101
3098
  } else if (this.horizontal && this.direction === "rtl") {
3102
- if (l = p.left, c = p.right, c <= i && c >= e)
3103
- return h;
3104
- if (l < i)
3105
- return h;
3106
- o = h, s.push(h);
3099
+ if (c = f.left, d = f.right, d <= i && d >= e)
3100
+ return l;
3101
+ if (c < i)
3102
+ return l;
3103
+ o = l, s.push(l);
3107
3104
  } else {
3108
- if (d = p.top, u = p.bottom, d >= e && d <= i)
3109
- return h;
3110
- if (u > e)
3111
- return h;
3112
- o = h, s.push(h);
3105
+ if (u = f.top, m = f.bottom, u >= e && u <= i)
3106
+ return l;
3107
+ if (m > e)
3108
+ return l;
3109
+ o = l, s.push(l);
3113
3110
  }
3114
3111
  }), r)
3115
- return this.findTextStartRange(r, e, i);
3116
- return this.findTextStartRange(o, e, i);
3112
+ return this.findTextStartRange(r, e, i, h);
3113
+ return this.findTextStartRange(o, e, i, h);
3117
3114
  }
3118
3115
  /**
3119
3116
  * Find End Range
@@ -3125,87 +3122,143 @@ class wt {
3125
3122
  */
3126
3123
  findEnd(t, e, i) {
3127
3124
  const s = [t];
3128
- let n, r = t, o;
3125
+ let n, r = t, o, h, l;
3129
3126
  for (; s.length; )
3130
- if (n = s.shift(), o = this.walk(n, (h) => {
3131
- let l, c, d, u;
3132
- const p = ft(h);
3133
- if (this.horizontal && this.direction === "ltr") {
3134
- if (l = Math.round(p.left), c = Math.round(p.right), l > i && r)
3127
+ if (n = s.shift(), o = this.walk(n, (c) => {
3128
+ let d, u, m, f;
3129
+ const p = ft(c);
3130
+ if (h = p, this.horizontal && this.direction === "ltr") {
3131
+ if (d = Math.round(p.left), u = Math.round(p.right), d > i && r)
3135
3132
  return r;
3136
- if (c > i)
3137
- return h;
3138
- r = h, s.push(h);
3133
+ if (u > i)
3134
+ return c;
3135
+ r = c, l = p, s.push(c);
3139
3136
  } else if (this.horizontal && this.direction === "rtl") {
3140
- if (l = Math.round(this.horizontal ? p.left : p.top), c = Math.round(this.horizontal ? p.right : p.bottom), c < e && r)
3137
+ if (d = Math.round(p.left), u = Math.round(p.right), u < e && r)
3141
3138
  return r;
3142
- if (l < e)
3143
- return h;
3144
- r = h, s.push(h);
3139
+ if (d < e)
3140
+ return c;
3141
+ r = c, l = p, s.push(c);
3145
3142
  } else {
3146
- if (d = Math.round(p.top), u = Math.round(p.bottom), d > i && r)
3143
+ if (m = Math.round(p.top), f = Math.round(p.bottom), m > i && r)
3147
3144
  return r;
3148
- if (u > i)
3149
- return h;
3150
- r = h, s.push(h);
3145
+ if (f > i)
3146
+ return c;
3147
+ r = c, l = p, s.push(c);
3151
3148
  }
3152
- }), o)
3153
- return this.findTextEndRange(o, e, i);
3154
- return this.findTextEndRange(r, e, i);
3149
+ }), o) {
3150
+ const c = o === r ? l : h;
3151
+ return this.findTextEndRange(o, e, i, c);
3152
+ }
3153
+ return this.findTextEndRange(r, e, i, l);
3154
+ }
3155
+ /**
3156
+ * Try to prepare a text node's root for canvas-based measurement.
3157
+ * Returns the PreparedNode for this text node, or null if not available.
3158
+ * @private
3159
+ */
3160
+ _canvasPrepare(t) {
3161
+ var o;
3162
+ if (!this._measurer || t.nodeType !== Node.TEXT_NODE) return null;
3163
+ const e = t, i = e.parentElement;
3164
+ if (!i) return null;
3165
+ const s = (o = i.ownerDocument) == null ? void 0 : o.defaultView;
3166
+ if (!s) return null;
3167
+ const n = this._measurer.getPreparedNode(e);
3168
+ if (n) {
3169
+ const h = s.getComputedStyle(i).font;
3170
+ if (!h || h === n.font) return n;
3171
+ const l = i.ownerDocument.body;
3172
+ l && this._measurer.invalidate(l);
3173
+ }
3174
+ if (this._measurer.hasExoticCSS(e, s)) return null;
3175
+ const r = i.ownerDocument.body;
3176
+ return r ? (this._measurer.prepare(r, s), this._measurer.getPreparedNode(e)) : null;
3177
+ }
3178
+ /**
3179
+ * Canvas fast path: use binary search on pre-measured cumulative widths
3180
+ * to find a Range at the target position, then verify with one getBoundingClientRect.
3181
+ * Returns the Range if verification passes, or null to fall through to DOM loop.
3182
+ * @private
3183
+ */
3184
+ _canvasFindRange(t, e, i, s) {
3185
+ const n = this._canvasPrepare(t);
3186
+ if (!n || n.segments.length === 0) return null;
3187
+ const r = t, o = this.horizontal ? this.direction === "rtl" ? e.right : e.left : e.top, h = this.horizontal && this.direction === "rtl" ? o - i : i - o;
3188
+ if (h < 0) return null;
3189
+ const l = this._measurer.findSegmentIndex(n.segments, h), c = n.segments, d = r.ownerDocument, u = r.data.length;
3190
+ for (let m = l; m < c.length && m <= l + 1; m++) {
3191
+ const f = c[m], p = c[m + 1], v = d.createRange();
3192
+ if (v.setStart(r, Math.min(f.charOffset, u)), v.setEnd(r, Math.min(p ? p.charOffset : u, u)), s(v.getBoundingClientRect())) return v;
3193
+ }
3194
+ return null;
3155
3195
  }
3156
3196
  /**
3157
3197
  * Find Text Start Range
3158
3198
  * @private
3159
- * @param {Node} root root node
3199
+ * @param {Node} node text node
3160
3200
  * @param {number} start position to start at
3161
3201
  * @param {number} end position to end at
3202
+ * @param {DOMRect} [nodePos] pre-computed node bounds from findStart (avoids redundant reflow)
3162
3203
  * @return {Range}
3163
3204
  */
3164
- findTextStartRange(t, e, i) {
3165
- const s = this.splitTextNodeIntoRanges(t);
3166
- let n, r, o, h, l;
3167
- for (let c = 0; c < s.length; c++)
3168
- if (n = s[c], r = n.getBoundingClientRect(), this.horizontal && this.direction === "ltr") {
3169
- if (o = r.left, o >= e)
3170
- return n;
3205
+ findTextStartRange(t, e, i, s) {
3206
+ if (s) {
3207
+ const d = this.horizontal && this.direction === "rtl" ? i : e, u = this._canvasFindRange(t, s, d, (m) => {
3208
+ const f = this.horizontal ? this.direction === "rtl" ? m.right : m.left : m.top;
3209
+ return this.horizontal && this.direction === "ltr" ? f >= e : this.horizontal && this.direction === "rtl" ? f <= i : f >= e;
3210
+ });
3211
+ if (u) return u;
3212
+ }
3213
+ const n = this.splitTextNodeIntoRanges(t);
3214
+ let r, o, h, l, c;
3215
+ for (let d = 0; d < n.length; d++)
3216
+ if (r = n[d], o = r.getBoundingClientRect(), this.horizontal && this.direction === "ltr") {
3217
+ if (h = o.left, h >= e)
3218
+ return r;
3171
3219
  } else if (this.horizontal && this.direction === "rtl") {
3172
- if (l = r.right, l <= i)
3173
- return n;
3174
- } else if (h = r.top, h >= e)
3175
- return n;
3176
- return s[0];
3220
+ if (c = o.right, c <= i)
3221
+ return r;
3222
+ } else if (l = o.top, l >= e)
3223
+ return r;
3224
+ return n[0];
3177
3225
  }
3178
3226
  /**
3179
3227
  * Find Text End Range
3180
3228
  * @private
3181
- * @param {Node} root root node
3229
+ * @param {Node} node text node
3182
3230
  * @param {number} start position to start at
3183
3231
  * @param {number} end position to end at
3232
+ * @param {DOMRect} [nodePos] pre-computed node bounds from findEnd (avoids redundant reflow)
3184
3233
  * @return {Range}
3185
3234
  */
3186
- findTextEndRange(t, e, i) {
3187
- const s = this.splitTextNodeIntoRanges(t);
3188
- let n, r, o, h, l, c, d;
3189
- for (let u = 0; u < s.length; u++) {
3190
- if (r = s[u], o = r.getBoundingClientRect(), this.horizontal && this.direction === "ltr") {
3191
- if (h = o.left, l = o.right, h > i && n)
3192
- return n;
3193
- if (l > i)
3235
+ findTextEndRange(t, e, i, s) {
3236
+ if (s) {
3237
+ const m = this.horizontal && this.direction === "rtl" ? e : i, f = this._canvasFindRange(t, s, m, (p) => this.horizontal && this.direction === "ltr" ? p.left <= i && p.right >= i : this.horizontal && this.direction === "rtl" ? p.right >= e && p.left <= e : p.top <= i && p.bottom >= i);
3238
+ if (f) return f;
3239
+ }
3240
+ const n = this.splitTextNodeIntoRanges(t);
3241
+ let r, o, h, l, c, d, u;
3242
+ for (let m = 0; m < n.length; m++) {
3243
+ if (o = n[m], h = o.getBoundingClientRect(), this.horizontal && this.direction === "ltr") {
3244
+ if (l = h.left, c = h.right, l > i && r)
3194
3245
  return r;
3246
+ if (c > i)
3247
+ return o;
3195
3248
  } else if (this.horizontal && this.direction === "rtl") {
3196
- if (h = o.left, l = o.right, l < e && n)
3197
- return n;
3198
- if (h < e)
3249
+ if (l = h.left, c = h.right, c < e && r)
3199
3250
  return r;
3251
+ if (l < e)
3252
+ return o;
3200
3253
  } else {
3201
- if (c = o.top, d = o.bottom, c > i && n)
3202
- return n;
3203
- if (d > i)
3254
+ if (d = h.top, u = h.bottom, d > i && r)
3204
3255
  return r;
3256
+ if (u > i)
3257
+ return o;
3205
3258
  }
3206
- n = r;
3259
+ r = o;
3207
3260
  }
3208
- return s[s.length - 1];
3261
+ return n[n.length - 1];
3209
3262
  }
3210
3263
  /**
3211
3264
  * Split up a text node into ranges for each word
@@ -3257,7 +3310,7 @@ class wt {
3257
3310
  return t && (this.horizontal = t === "horizontal"), this.horizontal;
3258
3311
  }
3259
3312
  }
3260
- const ke = typeof navigator < "u", Pt = ke && !/Chrome/.test(navigator.userAgent) && /AppleWebKit/.test(navigator.userAgent), Ne = 1;
3313
+ const Ne = typeof navigator < "u", Pt = Ne && !/Chrome/.test(navigator.userAgent) && /AppleWebKit/.test(navigator.userAgent), Le = 1;
3261
3314
  class Nt {
3262
3315
  constructor(t, e, i, s) {
3263
3316
  this.epubcfi = new y(), this.document = t, this.documentElement = this.document.documentElement, this.content = e || this.document.body, this.window = this.document.defaultView, this._size = {
@@ -3278,7 +3331,7 @@ class Nt {
3278
3331
  */
3279
3332
  width(t) {
3280
3333
  const e = this.content;
3281
- return t && x(t) && (t = t + "px"), t && (e.style.width = t), parseInt(this.window.getComputedStyle(e).width);
3334
+ return t && b(t) && (t = t + "px"), t && (e.style.width = t), parseInt(this.window.getComputedStyle(e).width);
3282
3335
  }
3283
3336
  /**
3284
3337
  * Get or Set height
@@ -3287,7 +3340,7 @@ class Nt {
3287
3340
  */
3288
3341
  height(t) {
3289
3342
  const e = this.content;
3290
- return t && x(t) && (t = t + "px"), t && (e.style.height = t), parseInt(this.window.getComputedStyle(e).height);
3343
+ return t && b(t) && (t = t + "px"), t && (e.style.height = t), parseInt(this.window.getComputedStyle(e).height);
3291
3344
  }
3292
3345
  /**
3293
3346
  * Get or Set width of the contents
@@ -3296,7 +3349,7 @@ class Nt {
3296
3349
  */
3297
3350
  contentWidth(t) {
3298
3351
  const e = this.content || this.document.body;
3299
- return t && x(t) && (t = t + "px"), t && (e.style.width = t), parseInt(this.window.getComputedStyle(e).width);
3352
+ return t && b(t) && (t = t + "px"), t && (e.style.width = t), parseInt(this.window.getComputedStyle(e).width);
3300
3353
  }
3301
3354
  /**
3302
3355
  * Get or Set height of the contents
@@ -3305,7 +3358,7 @@ class Nt {
3305
3358
  */
3306
3359
  contentHeight(t) {
3307
3360
  const e = this.content || this.document.body;
3308
- return t && x(t) && (t = t + "px"), t && (e.style.height = t), parseInt(this.window.getComputedStyle(e).height);
3361
+ return t && b(t) && (t = t + "px"), t && (e.style.height = t), parseInt(this.window.getComputedStyle(e).height);
3309
3362
  }
3310
3363
  /**
3311
3364
  * Get the width of the text using Range
@@ -3313,7 +3366,7 @@ class Nt {
3313
3366
  */
3314
3367
  textWidth() {
3315
3368
  let t;
3316
- const e = this.document.createRange(), i = this.content || this.document.body, s = J(i);
3369
+ const e = this.document.createRange(), i = this.content || this.document.body, s = Q(i);
3317
3370
  return e.selectNodeContents(i), t = e.getBoundingClientRect().width, s && s.width && (t += s.width), Math.round(t);
3318
3371
  }
3319
3372
  /**
@@ -3407,14 +3460,14 @@ class Nt {
3407
3460
  const r = e.getAttribute("content") ?? "", o = r.match(/width\s*=\s*([^,]*)/), h = r.match(/height\s*=\s*([^,]*)/), l = r.match(/initial-scale\s*=\s*([^,]*)/), c = r.match(/minimum-scale\s*=\s*([^,]*)/), d = r.match(/maximum-scale\s*=\s*([^,]*)/), u = r.match(/user-scalable\s*=\s*([^,]*)/);
3408
3461
  o && o.length && typeof o[1] < "u" && (i.width = o[1]), h && h.length && typeof h[1] < "u" && (i.height = h[1]), l && l.length && typeof l[1] < "u" && (i.scale = l[1]), c && c.length && typeof c[1] < "u" && (i.minimum = c[1]), d && d.length && typeof d[1] < "u" && (i.maximum = d[1]), u && u.length && typeof u[1] < "u" && (i.scalable = u[1]);
3409
3462
  }
3410
- return n = qt(t ?? {}, i), t && (n.width && s.push("width=" + n.width), n.height && s.push("height=" + n.height), n.scale && s.push("initial-scale=" + n.scale), n.scalable === "no" ? (s.push("minimum-scale=" + n.scale), s.push("maximum-scale=" + n.scale), s.push("user-scalable=" + n.scalable)) : (n.scalable && s.push("user-scalable=" + n.scalable), n.minimum && s.push("minimum-scale=" + n.minimum), n.maximum && s.push("minimum-scale=" + n.maximum)), e || (e = this.document.createElement("meta"), e.setAttribute("name", "viewport"), this.document.querySelector("head").appendChild(e)), e.setAttribute("content", s.join(", ")), this.window.scrollTo(0, 0)), n;
3463
+ return n = Ut(t ?? {}, i), t && (n.width && s.push("width=" + n.width), n.height && s.push("height=" + n.height), n.scale && s.push("initial-scale=" + n.scale), n.scalable === "no" ? (s.push("minimum-scale=" + n.scale), s.push("maximum-scale=" + n.scale), s.push("user-scalable=" + n.scalable)) : (n.scalable && s.push("user-scalable=" + n.scalable), n.minimum && s.push("minimum-scale=" + n.minimum), n.maximum && s.push("minimum-scale=" + n.maximum)), e || (e = this.document.createElement("meta"), e.setAttribute("name", "viewport"), this.document.querySelector("head").appendChild(e)), e.setAttribute("content", s.join(", ")), this.window.scrollTo(0, 0)), n;
3411
3464
  }
3412
3465
  /**
3413
3466
  * Event emitter for when the contents has expanded
3414
3467
  * @private
3415
3468
  */
3416
3469
  expand() {
3417
- this.emit(f.CONTENTS.EXPAND);
3470
+ this.emit(g.CONTENTS.EXPAND);
3418
3471
  }
3419
3472
  /**
3420
3473
  * Add DOM listeners
@@ -3446,7 +3499,7 @@ class Nt {
3446
3499
  (t !== this._size.width || e !== this._size.height) && (this._size = {
3447
3500
  width: t,
3448
3501
  height: e
3449
- }, this.onResize && this.onResize(this._size), this.emit(f.CONTENTS.RESIZE, this._size));
3502
+ }, this.onResize && this.onResize(this._size), this.emit(g.CONTENTS.RESIZE, this._size));
3450
3503
  }
3451
3504
  /**
3452
3505
  * Use css transitions to detect resize
@@ -3552,7 +3605,7 @@ class Nt {
3552
3605
  else if (Pt) {
3553
3606
  const r = n.startContainer, o = new Range();
3554
3607
  try {
3555
- r.nodeType === Ne ? i = r.getBoundingClientRect() : n.startOffset + 2 < r.length ? (o.setStart(r, n.startOffset), o.setEnd(r, n.startOffset + 2), i = o.getBoundingClientRect()) : n.startOffset - 2 > 0 ? (o.setStart(r, n.startOffset - 2), o.setEnd(r, n.startOffset), i = o.getBoundingClientRect()) : i = r.parentNode.getBoundingClientRect();
3608
+ r.nodeType === Le ? i = r.getBoundingClientRect() : n.startOffset + 2 < r.length ? (o.setStart(r, n.startOffset), o.setEnd(r, n.startOffset + 2), i = o.getBoundingClientRect()) : n.startOffset - 2 > 0 ? (o.setStart(r, n.startOffset - 2), o.setEnd(r, n.startOffset), i = o.getBoundingClientRect()) : i = r.parentNode.getBoundingClientRect();
3556
3609
  } catch (h) {
3557
3610
  console.error(h, h instanceof Error ? h.stack : void 0);
3558
3611
  }
@@ -3736,7 +3789,7 @@ class Nt {
3736
3789
  */
3737
3790
  triggerSelectedEvent(t) {
3738
3791
  let e, i;
3739
- t && t.rangeCount > 0 && (e = t.getRangeAt(0), e.collapsed || (i = new y(e, this.cfiBase).toString(), this.emit(f.CONTENTS.SELECTED, i), this.emit(f.CONTENTS.SELECTED_RANGE, e)));
3792
+ t && t.rangeCount > 0 && (e = t.getRangeAt(0), e.collapsed || (i = new y(e, this.cfiBase).toString(), this.emit(g.CONTENTS.SELECTED, i), this.emit(g.CONTENTS.SELECTED_RANGE, e)));
3740
3793
  }
3741
3794
  /**
3742
3795
  * Get a Dom Range from EpubCFI
@@ -3864,8 +3917,8 @@ class Nt {
3864
3917
  * @private
3865
3918
  */
3866
3919
  linksHandler() {
3867
- ve(this.content, (t) => {
3868
- this.emit(f.CONTENTS.LINK_CLICKED, t);
3920
+ ye(this.content, (t) => {
3921
+ this.emit(g.CONTENTS.LINK_CLICKED, t);
3869
3922
  });
3870
3923
  }
3871
3924
  /**
@@ -3922,13 +3975,13 @@ P(Nt.prototype);
3922
3975
  function $(a) {
3923
3976
  return document.createElementNS("http://www.w3.org/2000/svg", a);
3924
3977
  }
3925
- function Le(a, t) {
3978
+ function Re(a, t) {
3926
3979
  function e(s) {
3927
3980
  for (let n = t.length - 1; n >= 0; n--) {
3928
3981
  const r = t[n];
3929
3982
  let o, h;
3930
- if ("touches" in s && s.touches.length ? (o = s.touches[0].clientX, h = s.touches[0].clientY) : (o = s.clientX, h = s.clientY), !!Ae(r, a, o, h)) {
3931
- r.dispatchEvent(Re(s));
3983
+ if ("touches" in s && s.touches.length ? (o = s.touches[0].clientX, h = s.touches[0].clientY) : (o = s.clientX, h = s.clientY), !!Ie(r, a, o, h)) {
3984
+ r.dispatchEvent(Ae(s));
3932
3985
  break;
3933
3986
  }
3934
3987
  }
@@ -3945,7 +3998,7 @@ function Le(a, t) {
3945
3998
  for (const s of ["mouseup", "mousedown", "click", "touchstart"])
3946
3999
  i.addEventListener(s, (n) => e(n), !1);
3947
4000
  }
3948
- function Re(a) {
4001
+ function Ae(a) {
3949
4002
  const t = Object.assign({}, a, { bubbles: !1 });
3950
4003
  try {
3951
4004
  return new MouseEvent(a.type, t);
@@ -3970,11 +4023,11 @@ function Re(a) {
3970
4023
  ), s;
3971
4024
  }
3972
4025
  }
3973
- function Ae(a, t, e, i) {
4026
+ function Ie(a, t, e, i) {
3974
4027
  const s = t.getBoundingClientRect();
3975
4028
  function n(h, l, c) {
3976
- const d = h.top - s.top, u = h.left - s.left, p = d + h.height, g = u + h.width;
3977
- return d <= c && u <= l && p > c && g > l;
4029
+ const d = h.top - s.top, u = h.left - s.left, m = d + h.height, f = u + h.width;
4030
+ return d <= c && u <= l && m > c && f > l;
3978
4031
  }
3979
4032
  const r = a.getBoundingClientRect();
3980
4033
  if (!n(r, e, i))
@@ -3985,7 +4038,7 @@ function Ae(a, t, e, i) {
3985
4038
  return !0;
3986
4039
  return !1;
3987
4040
  }
3988
- function Ie(a, t) {
4041
+ function Pe(a, t) {
3989
4042
  const e = t.getBoundingClientRect(), i = a.getBoundingClientRect();
3990
4043
  return {
3991
4044
  top: i.top - e.top,
@@ -3994,15 +4047,15 @@ function Ie(a, t) {
3994
4047
  width: a.scrollWidth
3995
4048
  };
3996
4049
  }
3997
- function Pe(a, t) {
4050
+ function Oe(a, t) {
3998
4051
  a.style.setProperty("top", `${t.top}px`, "important"), a.style.setProperty("left", `${t.left}px`, "important"), a.style.setProperty("height", `${t.height}px`, "important"), a.style.setProperty("width", `${t.width}px`, "important");
3999
4052
  }
4000
- function Oe(a, t) {
4053
+ function De(a, t) {
4001
4054
  return t.right <= a.right && t.left >= a.left && t.top >= a.top && t.bottom <= a.bottom;
4002
4055
  }
4003
4056
  class Ot {
4004
4057
  constructor(t, e = document.body) {
4005
- this.target = t, this.element = $("svg"), this.marks = [], this.element.style.position = "absolute", this.element.setAttribute("pointer-events", "none"), Le(this.target, this.marks), this.container = e, this.container.appendChild(this.element), this.render();
4058
+ this.target = t, this.element = $("svg"), this.marks = [], this.element.style.position = "absolute", this.element.setAttribute("pointer-events", "none"), Re(this.target, this.marks), this.container = e, this.container.appendChild(this.element), this.render();
4006
4059
  }
4007
4060
  addMark(t) {
4008
4061
  const e = $("g");
@@ -4016,7 +4069,7 @@ class Ot {
4016
4069
  this.element.removeChild(i), this.marks.splice(e, 1);
4017
4070
  }
4018
4071
  render() {
4019
- Pe(this.element, Ie(this.target, this.container));
4072
+ Oe(this.element, Pe(this.target, this.container));
4020
4073
  for (const t of this.marks)
4021
4074
  t.render();
4022
4075
  }
@@ -4053,7 +4106,7 @@ class ze {
4053
4106
  for (let i = 0; i < t.length; i++) {
4054
4107
  if (t[i] === e)
4055
4108
  return !0;
4056
- if (Oe(t[i], e))
4109
+ if (De(t[i], e))
4057
4110
  return !1;
4058
4111
  }
4059
4112
  return !0;
@@ -4083,7 +4136,7 @@ class Qt extends ze {
4083
4136
  this.element.appendChild(t);
4084
4137
  }
4085
4138
  }
4086
- class De extends Qt {
4139
+ class Be extends Qt {
4087
4140
  constructor(t, e, i, s) {
4088
4141
  super(t, e, i, s);
4089
4142
  }
@@ -4093,16 +4146,16 @@ class De extends Qt {
4093
4146
  const t = this.element.ownerDocument.createDocumentFragment(), e = this.filteredRanges(), i = this.element.getBoundingClientRect(), s = this.container.getBoundingClientRect();
4094
4147
  for (let n = 0, r = e.length; n < r; n++) {
4095
4148
  const o = e[n], h = $("rect");
4096
- h.setAttribute("x", String(o.left - i.left + s.left)), h.setAttribute("y", String(o.top - i.top + s.top)), h.setAttribute("height", String(o.height)), h.setAttribute("width", String(o.width)), h.setAttribute("fill", "none");
4149
+ h.setAttribute("x", String(o.left - i.left + s.left)), h.setAttribute("y", String(o.top - i.top + s.top)), h.setAttribute("height", String(o.height)), h.setAttribute("width", String(o.width)), h.setAttribute("fill", this.attributes.fill || "none");
4097
4150
  const l = $("line");
4098
- l.setAttribute("x1", String(o.left - i.left + s.left)), l.setAttribute("x2", String(o.left - i.left + s.left + o.width)), l.setAttribute("y1", String(o.top - i.top + s.top + o.height - 1)), l.setAttribute("y2", String(o.top - i.top + s.top + o.height - 1)), l.setAttribute("stroke-width", "1"), l.setAttribute("stroke", "black"), l.setAttribute("stroke-linecap", "square"), t.appendChild(h), t.appendChild(l);
4151
+ l.setAttribute("x1", String(o.left - i.left + s.left)), l.setAttribute("x2", String(o.left - i.left + s.left + o.width)), l.setAttribute("y1", String(o.top - i.top + s.top + o.height - 1)), l.setAttribute("y2", String(o.top - i.top + s.top + o.height - 1)), l.setAttribute("stroke-width", this.attributes["stroke-width"] || "1"), l.setAttribute("stroke", this.attributes.stroke || "black"), l.setAttribute("stroke-linecap", this.attributes["stroke-linecap"] || "square"), t.appendChild(h), t.appendChild(l);
4099
4152
  }
4100
4153
  this.element.appendChild(t);
4101
4154
  }
4102
4155
  }
4103
- class Jt {
4156
+ class te {
4104
4157
  constructor(t, e) {
4105
- this.settings = C({
4158
+ this._contentDirty = !0, this._needsReframe = !1, this._expanding = !1, this.settings = C({
4106
4159
  ignoreClass: "",
4107
4160
  axis: void 0,
4108
4161
  //options.layout && options.layout.props.flow === "scrolled" ? "vertical" : "horizontal",
@@ -4128,17 +4181,17 @@ class Jt {
4128
4181
  return this.create(), this.size(), this.sectionRender || (this.sectionRender = this.section.render(t)), this.sectionRender.then((i) => this.load(i)).then(() => {
4129
4182
  const i = this.contents.writingMode();
4130
4183
  let s;
4131
- return this.settings.flow === "scrolled" ? s = i.indexOf("vertical") === 0 ? "horizontal" : "vertical" : s = i.indexOf("vertical") === 0 ? "vertical" : "horizontal", i.indexOf("vertical") === 0 && this.settings.flow === "paginated" && (this.layout.delta = this.layout.height), this.setAxis(s), this.emit(f.VIEWS.AXIS, s), this.setWritingMode(i), this.emit(f.VIEWS.WRITING_MODE, i), this.layout.format(this.contents, this.section, this.axis), this.addListeners(), new Promise((n, r) => {
4184
+ return this.settings.flow === "scrolled" ? s = i.indexOf("vertical") === 0 ? "horizontal" : "vertical" : s = i.indexOf("vertical") === 0 ? "vertical" : "horizontal", i.indexOf("vertical") === 0 && this.settings.flow === "paginated" && (this.layout.delta = this.layout.height), this.setAxis(s), this.emit(g.VIEWS.AXIS, s), this.setWritingMode(i), this.emit(g.VIEWS.WRITING_MODE, i), this.layout.format(this.contents, this.section, this.axis), this.addListeners(), new Promise((n, r) => {
4132
4185
  this.expand(), this.settings.forceRight && (this.element.style.marginLeft = this.width() + "px"), n();
4133
4186
  });
4134
- }, (i) => (this.emit(f.VIEWS.LOAD_ERROR, i), new Promise((s, n) => {
4187
+ }, (i) => (this.emit(g.VIEWS.LOAD_ERROR, i), new Promise((s, n) => {
4135
4188
  n(i);
4136
4189
  }))).then(() => {
4137
- this.emit(f.VIEWS.RENDERED, this.section);
4190
+ this.emit(g.VIEWS.RENDERED, this.section);
4138
4191
  });
4139
4192
  }
4140
4193
  reset() {
4141
- this.iframe && (this.iframe.style.width = "0", this.iframe.style.height = "0", this._width = 0, this._height = 0, this._textWidth = void 0, this._contentWidth = void 0, this._textHeight = void 0, this._contentHeight = void 0), this._needsReframe = !0;
4194
+ this.iframe && (this.iframe.style.width = "0", this.iframe.style.height = "0", this._width = 0, this._height = 0, this._textWidth = void 0, this._contentWidth = void 0, this._textHeight = void 0, this._contentHeight = void 0), this._contentDirty = !0, this._needsReframe = !0;
4142
4195
  }
4143
4196
  // Determine locks base on settings
4144
4197
  size(t, e) {
@@ -4147,17 +4200,17 @@ class Jt {
4147
4200
  }
4148
4201
  // Lock an axis to element dimensions, taking borders into account
4149
4202
  lock(t, e, i) {
4150
- const s = J(this.element);
4203
+ const s = Q(this.element);
4151
4204
  let n;
4152
- this.iframe ? n = J(this.iframe) : n = { width: 0, height: 0 }, t === "width" && x(e) && (this.lockedWidth = e - s.width - n.width), t === "height" && x(i) && (this.lockedHeight = i - s.height - n.height), t === "both" && x(e) && x(i) && (this.lockedWidth = e - s.width - n.width, this.lockedHeight = i - s.height - n.height), this.displayed && this.iframe && this.expand();
4205
+ this.iframe ? n = Q(this.iframe) : n = { width: 0, height: 0 }, t === "width" && b(e) && (this.lockedWidth = e - s.width - n.width), t === "height" && b(i) && (this.lockedHeight = i - s.height - n.height), t === "both" && b(e) && b(i) && (this.lockedWidth = e - s.width - n.width, this.lockedHeight = i - s.height - n.height), this.displayed && this.iframe && this.expand();
4153
4206
  }
4154
4207
  // Resize a single axis based on content dimensions
4155
4208
  expand(t) {
4156
4209
  let e = this.lockedWidth, i = this.lockedHeight, s;
4157
- !this.iframe || this._expanding || (this._expanding = !0, this.layout.name === "pre-paginated" ? (e = this.layout.columnWidth, i = this.layout.height) : this.settings.axis === "horizontal" ? (e = this.contents.textWidth(), e % this.layout.pageWidth > 0 && (e = Math.ceil(e / this.layout.pageWidth) * this.layout.pageWidth), this.settings.forceEvenPages && (s = e / this.layout.pageWidth, this.layout.divisor > 1 && this.layout.name === "reflowable" && s % 2 > 0 && (e += this.layout.pageWidth))) : this.settings.axis === "vertical" && (i = this.contents.textHeight(), this.settings.flow === "paginated" && i % this.layout.height > 0 && (i = Math.ceil(i / this.layout.height) * this.layout.height)), (this._needsReframe || e !== this._width || i !== this._height) && this.reframe(e, i), this._expanding = !1);
4210
+ !this.iframe || this._expanding || (this._expanding = !0, this.layout.name === "pre-paginated" ? (e = this.layout.columnWidth, i = this.layout.height) : this.settings.axis === "horizontal" ? (!this._contentDirty && this._textWidth !== void 0 ? e = this._textWidth : (e = this.contents.textWidth(), this._textWidth = e, this._contentDirty = !1), e % this.layout.pageWidth > 0 && (e = Math.ceil(e / this.layout.pageWidth) * this.layout.pageWidth), this.settings.forceEvenPages && (s = e / this.layout.pageWidth, this.layout.divisor > 1 && this.layout.name === "reflowable" && s % 2 > 0 && (e += this.layout.pageWidth))) : this.settings.axis === "vertical" && (!this._contentDirty && this._textHeight !== void 0 ? i = this._textHeight : (i = this.contents.textHeight(), this._textHeight = i, this._contentDirty = !1), this.settings.flow === "paginated" && i % this.layout.height > 0 && (i = Math.ceil(i / this.layout.height) * this.layout.height)), (this._needsReframe || e !== this._width || i !== this._height) && this.reframe(e, i), this._expanding = !1);
4158
4211
  }
4159
4212
  reframe(t, e) {
4160
- x(t) && (this.element.style.width = t + "px", this.iframe.style.width = t + "px", this._width = t), x(e) && (this.element.style.height = e + "px", this.iframe.style.height = e + "px", this._height = e);
4213
+ b(t) && (this.element.style.width = t + "px", this.iframe.style.width = t + "px", this._width = t), b(e) && (this.element.style.height = e + "px", this.iframe.style.height = e + "px", this._height = e);
4161
4214
  const i = this.prevBounds ? t - this.prevBounds.width : t, s = this.prevBounds ? e - this.prevBounds.height : e, n = {
4162
4215
  width: t,
4163
4216
  height: e,
@@ -4168,10 +4221,10 @@ class Jt {
4168
4221
  let r;
4169
4222
  for (const o in this.marks)
4170
4223
  this.marks.hasOwnProperty(o) && (r = this.marks[o], this.placeMark(r.element, r.range));
4171
- }), this.onResize(this, n), this.emit(f.VIEWS.RESIZED, n), this.prevBounds = n, this.elementBounds = K(this.element);
4224
+ }), this.onResize(this, n), this.emit(g.VIEWS.RESIZED, n), this.prevBounds = n, this.elementBounds = K(this.element);
4172
4225
  }
4173
4226
  load(t) {
4174
- const e = new S(), i = e.promise;
4227
+ const e = new _(), i = e.promise;
4175
4228
  if (!this.iframe)
4176
4229
  return e.reject(new Error("No Iframe Available")), i;
4177
4230
  if (this.iframe.onload = (s) => {
@@ -4190,14 +4243,14 @@ class Jt {
4190
4243
  onLoad(t, e) {
4191
4244
  this.window = this.iframe.contentWindow, this.document = this.iframe.contentDocument, this.contents = new Nt(this.document, this.document.body, this.section.cfiBase, this.section.index), this.rendering = !1;
4192
4245
  let i = this.document.querySelector("link[rel='canonical']");
4193
- i ? i.setAttribute("href", this.section.canonical) : (i = this.document.createElement("link"), i.setAttribute("rel", "canonical"), i.setAttribute("href", this.section.canonical), this.document.querySelector("head").appendChild(i)), this.contents.on(f.CONTENTS.EXPAND, () => {
4194
- this.displayed && this.iframe && (this.expand(), this.contents && this.layout.format(this.contents));
4195
- }), this.contents.on(f.CONTENTS.RESIZE, (s) => {
4196
- this.displayed && this.iframe && (this.expand(), this.contents && this.layout.format(this.contents));
4246
+ i ? i.setAttribute("href", this.section.canonical) : (i = this.document.createElement("link"), i.setAttribute("rel", "canonical"), i.setAttribute("href", this.section.canonical), this.document.querySelector("head").appendChild(i)), this.contents.on(g.CONTENTS.EXPAND, () => {
4247
+ this.displayed && this.iframe && (this._contentDirty = !0, this.expand(), this.contents && this.layout.format(this.contents));
4248
+ }), this.contents.on(g.CONTENTS.RESIZE, (s) => {
4249
+ this.displayed && this.iframe && (this._textWidth = s.width, this._textHeight = s.height, this._contentDirty = !1, this.expand(), this.contents && this.layout.format(this.contents));
4197
4250
  }), e.resolve(this.contents);
4198
4251
  }
4199
4252
  setLayout(t) {
4200
- this.layout = t, this.contents && (this.layout.format(this.contents), this.expand());
4253
+ this.layout = t, this.contents && (this.layout.format(this.contents), this._contentDirty = !0, this.expand());
4201
4254
  }
4202
4255
  setAxis(t) {
4203
4256
  this.settings.axis = t, t === "horizontal" ? this.element.style.flex = "none" : this.element.style.flex = "initial", this.size();
@@ -4208,21 +4261,21 @@ class Jt {
4208
4261
  addListeners() {
4209
4262
  }
4210
4263
  removeListeners() {
4211
- this.contents && (this.contents.off(f.CONTENTS.EXPAND), this.contents.off(f.CONTENTS.RESIZE));
4264
+ this.contents && (this.contents.off(g.CONTENTS.EXPAND), this.contents.off(g.CONTENTS.RESIZE));
4212
4265
  }
4213
4266
  display(t) {
4214
- const e = new S();
4267
+ const e = new _();
4215
4268
  return this.displayed ? e.resolve(this) : this.render(t).then(() => {
4216
- this.emit(f.VIEWS.DISPLAYED, this), this.onDisplayed(this), this.displayed = !0, e.resolve(this);
4269
+ this.emit(g.VIEWS.DISPLAYED, this), this.onDisplayed(this), this.displayed = !0, e.resolve(this);
4217
4270
  }, (i) => {
4218
4271
  e.reject(i);
4219
4272
  }), e.promise;
4220
4273
  }
4221
4274
  show() {
4222
- this.element.style.visibility = "visible", this.iframe && (this.iframe.style.visibility = "visible", this.iframe.style.transform = "translateZ(0)", this.iframe.offsetWidth, this.iframe.style.transform = ""), this.emit(f.VIEWS.SHOWN, this);
4275
+ this.element.style.visibility = "visible", this.iframe && (this.iframe.style.visibility = "visible", this.iframe.style.transform = "translateZ(0)", this.iframe.offsetWidth, this.iframe.style.transform = ""), this.emit(g.VIEWS.SHOWN, this);
4223
4276
  }
4224
4277
  hide() {
4225
- this.element.style.visibility = "hidden", this.iframe.style.visibility = "hidden", this.stopExpanding = !0, this.emit(f.VIEWS.HIDDEN, this);
4278
+ this.element.style.visibility = "hidden", this.iframe.style.visibility = "hidden", this.stopExpanding = !0, this.emit(g.VIEWS.HIDDEN, this);
4226
4279
  }
4227
4280
  offset() {
4228
4281
  return {
@@ -4258,7 +4311,7 @@ class Jt {
4258
4311
  if (!this.contents)
4259
4312
  return;
4260
4313
  const r = Object.assign({ fill: "yellow", "fill-opacity": "0.3", "mix-blend-mode": "multiply" }, n), o = this.contents.range(t), h = (d) => {
4261
- this.emit(f.VIEWS.MARK_CLICKED, t, e);
4314
+ this.emit(g.VIEWS.MARK_CLICKED, t, e);
4262
4315
  };
4263
4316
  e.epubcfi = t, this.pane || (this.pane = new Ot(this.iframe, this.element));
4264
4317
  const l = new Qt(o, s, e, r);
@@ -4275,10 +4328,10 @@ class Jt {
4275
4328
  if (!this.contents)
4276
4329
  return;
4277
4330
  const r = Object.assign({ stroke: "black", "stroke-opacity": "0.3", "mix-blend-mode": "multiply" }, n), o = this.contents.range(t), h = (d) => {
4278
- this.emit(f.VIEWS.MARK_CLICKED, t, e);
4331
+ this.emit(g.VIEWS.MARK_CLICKED, t, e);
4279
4332
  };
4280
4333
  e.epubcfi = t, this.pane || (this.pane = new Ot(this.iframe, this.element));
4281
- const l = new De(o, s, e, r);
4334
+ const l = new Be(o, s, e, r);
4282
4335
  let c;
4283
4336
  try {
4284
4337
  c = this.pane.addMark(l);
@@ -4297,7 +4350,7 @@ class Jt {
4297
4350
  if (!s)
4298
4351
  return;
4299
4352
  const n = s.commonAncestorContainer, r = n.nodeType === 1 ? n : n.parentNode, o = (l) => {
4300
- this.emit(f.VIEWS.MARK_CLICKED, t, e);
4353
+ this.emit(g.VIEWS.MARK_CLICKED, t, e);
4301
4354
  };
4302
4355
  s.collapsed && n.nodeType === 1 ? (s = new Range(), s.selectNodeContents(n)) : s.collapsed && (s = new Range(), s.selectNodeContents(r));
4303
4356
  const h = this.document.createElement("a");
@@ -4352,13 +4405,13 @@ class Jt {
4352
4405
  this.blobUrl && Tt(this.blobUrl), this.displayed && (this.displayed = !1, this.removeListeners(), this.contents.destroy(), this.stopExpanding = !0, this.iframe && (this.iframe.onload = null), this.element.removeChild(this.iframe), this.pane && (this.pane.element.remove(), this.pane = void 0), this.iframe = void 0, this.contents = void 0, this.section.unload(), this._textWidth = void 0, this._textHeight = void 0, this._width = void 0, this._height = void 0), this.__listeners = {};
4353
4406
  }
4354
4407
  }
4355
- P(Jt.prototype);
4356
- function Be() {
4408
+ P(te.prototype);
4409
+ function Me() {
4357
4410
  let a = "reverse";
4358
- const t = Me();
4411
+ const t = We();
4359
4412
  return document.body.appendChild(t), t.scrollLeft > 0 ? a = "default" : typeof Element < "u" && typeof Element.prototype.scrollIntoView == "function" ? (t.children[0].children[1].scrollIntoView(), t.scrollLeft < 0 && (a = "negative")) : (t.scrollLeft = 1, t.scrollLeft === 0 && (a = "negative")), document.body.removeChild(t), a;
4360
4413
  }
4361
- function Me() {
4414
+ function We() {
4362
4415
  const a = document.createElement("div");
4363
4416
  a.dir = "rtl", a.style.position = "fixed", a.style.width = "1px", a.style.height = "1px", a.style.top = "0px", a.style.left = "0px", a.style.overflow = "hidden";
4364
4417
  const t = document.createElement("div");
@@ -4368,7 +4421,7 @@ function Me() {
4368
4421
  const i = document.createElement("span");
4369
4422
  return i.style.width = "1px", i.style.display = "inline-block", t.appendChild(e), t.appendChild(i), a.appendChild(t), a;
4370
4423
  }
4371
- function We(a, t) {
4424
+ function qe(a, t) {
4372
4425
  let e = null, i = 0;
4373
4426
  return function(...s) {
4374
4427
  const n = Date.now(), r = t - (n - i);
@@ -4377,7 +4430,7 @@ function We(a, t) {
4377
4430
  }, r));
4378
4431
  };
4379
4432
  }
4380
- class qe {
4433
+ class Ue {
4381
4434
  constructor(t) {
4382
4435
  this.settings = t || {}, this.id = "epubjs-container-" + Et(), this.container = this.create(this.settings), this.settings.hidden && (this.wrapper = this.wrap(this.container));
4383
4436
  }
@@ -4388,7 +4441,7 @@ class qe {
4388
4441
  create(t) {
4389
4442
  let e = t.height, i = t.width;
4390
4443
  const s = t.overflow || !1, n = t.axis || "vertical", r = t.direction;
4391
- C(this.settings, t), t.height && x(t.height) && (e = t.height + "px"), t.width && x(t.width) && (i = t.width + "px");
4444
+ C(this.settings, t), t.height && b(t.height) && (e = t.height + "px"), t.width && b(t.width) && (i = t.width + "px");
4392
4445
  const o = document.createElement("div");
4393
4446
  return o.id = this.id, o.classList.add("epub-container"), o.style.wordSpacing = "0", o.style.lineHeight = "0", o.style.verticalAlign = "top", o.style.position = "relative", o.style.overflowAnchor = "none", n === "horizontal" && (o.style.display = "flex", o.style.flexDirection = "row", o.style.flexWrap = "nowrap"), i && (o.style.width = i), e && (o.style.height = e), s && (s === "scroll" && n === "vertical" ? (o.style.overflowY = s, o.style.overflowX = "hidden") : s === "scroll" && n === "horizontal" ? (o.style.overflowY = "hidden", o.style.overflowX = s) : o.style.overflow = s), r && (o.dir = r, o.style.direction = r), r && this.settings.fullsize && (document.body.style.direction = r), o;
4394
4447
  }
@@ -4398,7 +4451,7 @@ class qe {
4398
4451
  }
4399
4452
  getElement(t) {
4400
4453
  let e = null;
4401
- if (Mt(t) ? e = t : typeof t == "string" && (e = document.getElementById(t)), !e)
4454
+ if (Wt(t) ? e = t : typeof t == "string" && (e = document.getElementById(t)), !e)
4402
4455
  throw new Error("Not an Element");
4403
4456
  return e;
4404
4457
  }
@@ -4412,7 +4465,7 @@ class qe {
4412
4465
  return this.container;
4413
4466
  }
4414
4467
  onResize(t) {
4415
- (!x(this.settings.width) || !x(this.settings.height)) && (this.resizeFunc = We(t, 50), window.addEventListener("resize", this.resizeFunc, !1));
4468
+ (!b(this.settings.width) || !b(this.settings.height)) && (this.resizeFunc = qe(t, 50), window.addEventListener("resize", this.resizeFunc, !1));
4416
4469
  }
4417
4470
  onOrientationChange(t) {
4418
4471
  this.orientationChangeFunc = t, window.addEventListener("orientationchange", this.orientationChangeFunc, !1);
@@ -4420,7 +4473,7 @@ class qe {
4420
4473
  size(t, e) {
4421
4474
  let i;
4422
4475
  const s = t || this.settings.width, n = e || this.settings.height;
4423
- t === null ? (i = this.element.getBoundingClientRect(), i.width && (t = Math.floor(i.width), this.container.style.width = t + "px")) : x(t) ? this.container.style.width = t + "px" : t && (this.container.style.width = t), e === null ? (i = i || this.element.getBoundingClientRect(), i.height && (e = i.height, this.container.style.height = e + "px")) : x(e) ? this.container.style.height = e + "px" : e && (this.container.style.height = e), x(t) || (t = this.container.clientWidth), x(e) || (e = this.container.clientHeight), this.containerStyles = window.getComputedStyle(this.container), this.containerPadding = {
4476
+ t === null ? (i = this.element.getBoundingClientRect(), i.width && (t = Math.floor(i.width), this.container.style.width = t + "px")) : b(t) ? this.container.style.width = t + "px" : t && (this.container.style.width = t), e === null ? (i = i || this.element.getBoundingClientRect(), i.height && (e = i.height, this.container.style.height = e + "px")) : b(e) ? this.container.style.height = e + "px" : e && (this.container.style.height = e), b(t) || (t = this.container.clientWidth), b(e) || (e = this.container.clientHeight), this.containerStyles = window.getComputedStyle(this.container), this.containerPadding = {
4424
4477
  left: parseFloat(this.containerStyles.paddingLeft) || 0,
4425
4478
  right: parseFloat(this.containerStyles.paddingRight) || 0,
4426
4479
  top: parseFloat(this.containerStyles.paddingTop) || 0,
@@ -4475,7 +4528,7 @@ class qe {
4475
4528
  this.element && (this.settings.hidden ? this.wrapper : this.container, this.element.contains(this.container) && this.element.removeChild(this.container), window.removeEventListener("resize", this.resizeFunc), window.removeEventListener("orientationchange", this.orientationChangeFunc));
4476
4529
  }
4477
4530
  }
4478
- class Ue {
4531
+ class je {
4479
4532
  constructor(t) {
4480
4533
  this.container = t, this._views = [], this.length = 0, this.hidden = !1;
4481
4534
  }
@@ -4556,6 +4609,167 @@ class Ue {
4556
4609
  this.hidden = !0;
4557
4610
  }
4558
4611
  }
4612
+ const Fe = /[\u2E80-\u9FFF\uF900-\uFAFF\uFE30-\uFE4F\u{20000}-\u{2FA1F}]/u;
4613
+ function Dt(a) {
4614
+ const t = a.letterSpacing;
4615
+ if (t && t !== "normal" && t !== "0px") return !0;
4616
+ const e = a.wordSpacing;
4617
+ if (e && e !== "normal" && e !== "0px") return !0;
4618
+ const i = a.textIndent;
4619
+ return !!(i && i !== "0px");
4620
+ }
4621
+ const He = 32;
4622
+ class Ve {
4623
+ constructor() {
4624
+ this._canvas = null, this._ctx = null, this._widthCache = /* @__PURE__ */ new Map(), this._preparedCache = /* @__PURE__ */ new WeakMap(), this._nodeIndex = /* @__PURE__ */ new WeakMap(), this._segmenter = null;
4625
+ }
4626
+ getCanvas() {
4627
+ return this._ctx ? this._ctx : typeof OffscreenCanvas < "u" && (this._canvas = new OffscreenCanvas(1, 1), this._ctx = this._canvas.getContext("2d"), this._ctx) ? this._ctx : (this._canvas = document.createElement("canvas"), this._ctx = this._canvas.getContext("2d"), this._ctx);
4628
+ }
4629
+ getSegmenter() {
4630
+ return this._segmenter ? this._segmenter : typeof Intl < "u" && "Segmenter" in Intl ? (this._segmenter = new Intl.Segmenter(void 0, { granularity: "word" }), this._segmenter) : null;
4631
+ }
4632
+ /**
4633
+ * Measure a text string with a given CSS font, returning its width in pixels.
4634
+ * Results are cached per font+text pair.
4635
+ */
4636
+ measureText(t, e) {
4637
+ let i = this._widthCache.get(e);
4638
+ if (i) {
4639
+ const r = i.get(t);
4640
+ if (r !== void 0) return r;
4641
+ } else {
4642
+ if (this._widthCache.size >= He) {
4643
+ const r = this._widthCache.keys().next().value;
4644
+ r !== void 0 && this._widthCache.delete(r);
4645
+ }
4646
+ i = /* @__PURE__ */ new Map(), this._widthCache.set(e, i);
4647
+ }
4648
+ const s = this.getCanvas();
4649
+ if (!s) return 0;
4650
+ s.font = e;
4651
+ const n = s.measureText(t).width;
4652
+ return i.set(t, n), n;
4653
+ }
4654
+ /**
4655
+ * Segment text into word-level pieces suitable for measurement.
4656
+ * Uses Intl.Segmenter when available, falls back to space-splitting
4657
+ * (with per-character splitting for CJK).
4658
+ */
4659
+ segmentText(t) {
4660
+ const e = this.getSegmenter();
4661
+ if (e) {
4662
+ const o = [];
4663
+ for (const h of e.segment(t))
4664
+ o.push({ text: h.segment, index: h.index });
4665
+ return o;
4666
+ }
4667
+ const i = [];
4668
+ let s = "", n = 0, r = 0;
4669
+ for (const o of t)
4670
+ o === " " ? (s && i.push({ text: s, index: n }), i.push({ text: " ", index: r }), s = "", n = r + o.length) : Fe.test(o) ? (s && (i.push({ text: s, index: n }), s = ""), i.push({ text: o, index: r }), n = r + o.length) : (s || (n = r), s += o), r += o.length;
4671
+ return s && i.push({ text: s, index: n }), i;
4672
+ }
4673
+ /**
4674
+ * Prepare phase: measure all text nodes under a root element.
4675
+ * Returns PreparedNode[] with cumulative widths for binary search.
4676
+ *
4677
+ * Text nodes whose parent has exotic CSS (letter-spacing, word-spacing,
4678
+ * text-indent) are skipped — the caller should fall back to DOM Range
4679
+ * measurement for those.
4680
+ *
4681
+ * @param root The container element (usually document.body)
4682
+ * @param win The window object for getComputedStyle
4683
+ * @returns PreparedNode[] with entries for measurable text nodes (may be empty)
4684
+ */
4685
+ prepare(t, e) {
4686
+ const i = this._preparedCache.get(t);
4687
+ if (i) return i;
4688
+ const s = [], n = /* @__PURE__ */ new Map(), r = t.ownerDocument.createTreeWalker(t, NodeFilter.SHOW_TEXT, {
4689
+ acceptNode(h) {
4690
+ return h.data.trim().length > 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
4691
+ }
4692
+ });
4693
+ let o;
4694
+ for (; o = r.nextNode(); ) {
4695
+ const h = o.parentElement;
4696
+ if (!h) continue;
4697
+ let l = n.get(h);
4698
+ if (l || (l = e.getComputedStyle(h), n.set(h, l)), Dt(l)) continue;
4699
+ const c = l.font;
4700
+ if (!c) continue;
4701
+ const d = o.data, u = this.segmentText(d), m = [];
4702
+ let f = 0;
4703
+ for (const v of u) {
4704
+ const w = this.measureText(v.text, c);
4705
+ m.push({
4706
+ node: o,
4707
+ charOffset: v.index,
4708
+ text: v.text,
4709
+ width: w,
4710
+ cumWidth: f + w
4711
+ }), f += w;
4712
+ }
4713
+ const p = {
4714
+ node: o,
4715
+ segments: m,
4716
+ totalWidth: f,
4717
+ font: c
4718
+ };
4719
+ s.push(p), this._nodeIndex.set(o, p);
4720
+ }
4721
+ return this._preparedCache.set(t, s), s;
4722
+ }
4723
+ /**
4724
+ * Layout phase: find the segment index at a given pixel position
4725
+ * using binary search on cumulative widths.
4726
+ *
4727
+ * @param segments The TextSegment[] from a PreparedNode
4728
+ * @param position Target position in pixels (relative to text node start)
4729
+ * @returns Index into the segments array
4730
+ */
4731
+ findSegmentIndex(t, e) {
4732
+ if (t.length === 0) return 0;
4733
+ let i = 0, s = t.length - 1;
4734
+ for (; i < s; ) {
4735
+ const n = i + s >>> 1;
4736
+ t[n].cumWidth < e ? i = n + 1 : s = n;
4737
+ }
4738
+ return i;
4739
+ }
4740
+ /**
4741
+ * Look up a previously prepared text node in O(1).
4742
+ * Returns null if the node was not prepared (exotic CSS, not yet prepared, etc.).
4743
+ */
4744
+ getPreparedNode(t) {
4745
+ return this._nodeIndex.get(t) || null;
4746
+ }
4747
+ /**
4748
+ * Check if a text node's parent has exotic CSS that prevents canvas measurement.
4749
+ */
4750
+ hasExoticCSS(t, e) {
4751
+ const i = t.parentElement;
4752
+ return i ? Dt(e.getComputedStyle(i)) : !0;
4753
+ }
4754
+ /**
4755
+ * Invalidate cached preparation for a root element,
4756
+ * including all per-node index entries under it.
4757
+ */
4758
+ invalidate(t) {
4759
+ const e = this._preparedCache.get(t);
4760
+ if (e) {
4761
+ for (const i of e)
4762
+ this._nodeIndex.delete(i.node);
4763
+ this._preparedCache.delete(t);
4764
+ }
4765
+ }
4766
+ /**
4767
+ * Destroy the measurer, releasing the canvas and all caches.
4768
+ */
4769
+ destroy() {
4770
+ this._widthCache.clear(), this._preparedCache = /* @__PURE__ */ new WeakMap(), this._nodeIndex = /* @__PURE__ */ new WeakMap(), this._ctx = null, this._canvas = null, this._segmenter = null;
4771
+ }
4772
+ }
4559
4773
  class st {
4560
4774
  constructor(t) {
4561
4775
  this.name = "default", this.optsSettings = t.settings, this.View = t.view, this.request = t.request, this.renditionQueue = t.queue, this.q = new kt(this), this.settings = C({}, {
@@ -4582,11 +4796,11 @@ class st {
4582
4796
  forceEvenPages: !0,
4583
4797
  allowScriptedContent: this.settings.allowScriptedContent,
4584
4798
  allowPopups: this.settings.allowPopups
4585
- }, this.rendered = !1;
4799
+ }, this._measurer = new Ve(), this.rendered = !1;
4586
4800
  }
4587
4801
  render(t, e) {
4588
4802
  const i = t.tagName;
4589
- typeof this.settings.fullsize > "u" && i && (i.toLowerCase() === "body" || i.toLowerCase() === "html") && (this.settings.fullsize = !0), this.settings.fullsize && (this.settings.overflow = "visible", this.overflow = this.settings.overflow), this.settings.size = e, this.settings.rtlScrollType = Be(), this.stage = new qe({
4803
+ typeof this.settings.fullsize > "u" && i && (i.toLowerCase() === "body" || i.toLowerCase() === "html") && (this.settings.fullsize = !0), this.settings.fullsize && (this.settings.overflow = "visible", this.overflow = this.settings.overflow), this.settings.size = e, this.settings.rtlScrollType = Me(), this.stage = new Ue({
4590
4804
  width: e.width,
4591
4805
  height: e.height,
4592
4806
  overflow: this.overflow,
@@ -4594,7 +4808,7 @@ class st {
4594
4808
  axis: this.settings.axis,
4595
4809
  fullsize: this.settings.fullsize,
4596
4810
  direction: this.settings.direction
4597
- }), this.stage.attachTo(t), this.container = this.stage.getContainer(), this.views = new Ue(this.container), this._bounds = this.bounds(), this._stageSize = this.stage.size(), this.viewSettings.width = this._stageSize.width, this.viewSettings.height = this._stageSize.height, this.stage.onResize(() => this.onResized()), this.stage.onOrientationChange((s) => this.onOrientationChange(s)), this.addEventListeners(), this.layout && this.updateLayout(), this.rendered = !0;
4811
+ }), this.stage.attachTo(t), this.container = this.stage.getContainer(), this.views = new je(this.container), this._bounds = this.bounds(), this._stageSize = this.stage.size(), this.viewSettings.width = this._stageSize.width, this.viewSettings.height = this._stageSize.height, this.stage.onResize(() => this.onResized()), this.stage.onOrientationChange((s) => this.onOrientationChange(s)), this.addEventListeners(), this.layout && this.updateLayout(), this.rendered = !0;
4598
4812
  }
4599
4813
  addEventListeners() {
4600
4814
  let t;
@@ -4607,19 +4821,19 @@ class st {
4607
4821
  this.settings.fullsize ? t = window : t = this.container, t.removeEventListener("scroll", this._onScroll), this._onScroll = void 0, window.removeEventListener("unload", this._onUnload), this._onUnload = void 0;
4608
4822
  }
4609
4823
  destroy() {
4610
- clearTimeout(this.resizeTimeout), clearTimeout(this.afterScrolled), this.clear(), this.removeEventListeners(), this.stage.destroy(), this.rendered = !1, this.__listeners = {};
4824
+ clearTimeout(this.resizeTimeout), clearTimeout(this.afterScrolled), this.clear(), this.removeEventListeners(), this.stage.destroy(), this._measurer && this._measurer.destroy(), this.rendered = !1, this.__listeners = {};
4611
4825
  }
4612
4826
  onOrientationChange(t) {
4613
4827
  var i;
4614
4828
  const { orientation: e } = window;
4615
- (i = this.optsSettings) != null && i.resizeOnOrientationChange && this.resize(), this.emit(f.MANAGERS.ORIENTATION_CHANGE, e);
4829
+ (i = this.optsSettings) != null && i.resizeOnOrientationChange && this.resize(), this.emit(g.MANAGERS.ORIENTATION_CHANGE, e);
4616
4830
  }
4617
4831
  onResized(t) {
4618
4832
  this.resize();
4619
4833
  }
4620
4834
  resize(t, e, i) {
4621
4835
  const s = this.stage.size(t, e);
4622
- this._stageSize && this._stageSize.width === s.width && this._stageSize.height === s.height || (this._stageSize = s, this._bounds = this.bounds(), this.clear(), this.viewSettings.width = this._stageSize.width, this.viewSettings.height = this._stageSize.height, this.updateLayout(), this.emit(f.MANAGERS.RESIZED, {
4836
+ this._stageSize && this._stageSize.width === s.width && this._stageSize.height === s.height || (this._stageSize = s, this._bounds = this.bounds(), this.clear(), this.viewSettings.width = this._stageSize.width, this.viewSettings.height = this._stageSize.height, this.updateLayout(), this.emit(g.MANAGERS.RESIZED, {
4623
4837
  width: this._stageSize.width,
4624
4838
  height: this._stageSize.height
4625
4839
  }, i));
@@ -4638,8 +4852,8 @@ class st {
4638
4852
  }
4639
4853
  }
4640
4854
  display(t, e) {
4641
- const i = new S(), s = i.promise;
4642
- (e === t.href || x(e)) && (e = void 0);
4855
+ const i = new _(), s = i.promise;
4856
+ (e === t.href || b(e)) && (e = void 0);
4643
4857
  const n = this.views.find(t);
4644
4858
  if (n && t && this.layout.name !== "pre-paginated") {
4645
4859
  const o = n.offset();
@@ -4669,10 +4883,10 @@ class st {
4669
4883
  }), s;
4670
4884
  }
4671
4885
  afterDisplayed(t) {
4672
- this.emit(f.MANAGERS.ADDED, t);
4886
+ this.emit(g.MANAGERS.ADDED, t);
4673
4887
  }
4674
4888
  afterResized(t) {
4675
- this.emit(f.MANAGERS.RESIZE, t.section);
4889
+ this.emit(g.MANAGERS.RESIZE, t.section);
4676
4890
  }
4677
4891
  moveTo(t, e) {
4678
4892
  let i = 0, s = 0;
@@ -4680,27 +4894,27 @@ class st {
4680
4894
  }
4681
4895
  add(t, e) {
4682
4896
  const i = this.createView(t, e);
4683
- return this.views.append(i), i.onDisplayed = (s) => this.afterDisplayed(s), i.onResize = (s) => this.afterResized(s), i.on(f.VIEWS.AXIS, (s) => {
4897
+ return this.views.append(i), i.onDisplayed = (s) => this.afterDisplayed(s), i.onResize = (s) => this.afterResized(s), i.on(g.VIEWS.AXIS, (s) => {
4684
4898
  this.updateAxis(s);
4685
- }), i.on(f.VIEWS.WRITING_MODE, (s) => {
4899
+ }), i.on(g.VIEWS.WRITING_MODE, (s) => {
4686
4900
  this.updateWritingMode(s);
4687
4901
  }), i.display(this.request);
4688
4902
  }
4689
4903
  append(t, e) {
4690
4904
  const i = this.createView(t, e);
4691
- return this.views.append(i), i.onDisplayed = (s) => this.afterDisplayed(s), i.onResize = (s) => this.afterResized(s), i.on(f.VIEWS.AXIS, (s) => {
4905
+ return this.views.append(i), i.onDisplayed = (s) => this.afterDisplayed(s), i.onResize = (s) => this.afterResized(s), i.on(g.VIEWS.AXIS, (s) => {
4692
4906
  this.updateAxis(s);
4693
- }), i.on(f.VIEWS.WRITING_MODE, (s) => {
4907
+ }), i.on(g.VIEWS.WRITING_MODE, (s) => {
4694
4908
  this.updateWritingMode(s);
4695
4909
  }), i.display(this.request);
4696
4910
  }
4697
4911
  prepend(t, e) {
4698
4912
  const i = this.createView(t, e);
4699
- return i.on(f.VIEWS.RESIZED, (s) => {
4913
+ return i.on(g.VIEWS.RESIZED, (s) => {
4700
4914
  this.counter(s);
4701
- }), this.views.prepend(i), i.onDisplayed = (s) => this.afterDisplayed(s), i.onResize = (s) => this.afterResized(s), i.on(f.VIEWS.AXIS, (s) => {
4915
+ }), this.views.prepend(i), i.onDisplayed = (s) => this.afterDisplayed(s), i.onResize = (s) => this.afterResized(s), i.on(g.VIEWS.AXIS, (s) => {
4702
4916
  this.updateAxis(s);
4703
- }), i.on(f.VIEWS.WRITING_MODE, (s) => {
4917
+ }), i.on(g.VIEWS.WRITING_MODE, (s) => {
4704
4918
  this.updateWritingMode(s);
4705
4919
  }), i.display(this.request);
4706
4920
  }
@@ -4717,7 +4931,7 @@ class st {
4717
4931
  //
4718
4932
  // };
4719
4933
  next() {
4720
- var s, n, r, o, h, l, c, d, u, p;
4934
+ var s, n, r, o, h, l, c, d, u, m;
4721
4935
  let t, e;
4722
4936
  const i = this.settings.direction;
4723
4937
  if (this.views.length) {
@@ -4725,43 +4939,43 @@ class st {
4725
4939
  if (this.scrollLeft = this.container.scrollLeft, e = this.container.scrollLeft + this.container.offsetWidth + this.layout.delta, e <= this.container.scrollWidth)
4726
4940
  this.scrollBy(this.layout.delta, 0, !0);
4727
4941
  else {
4728
- const g = this.views.last();
4729
- g && g.expand(), e = this.container.scrollLeft + this.container.offsetWidth + this.layout.delta, e <= this.container.scrollWidth ? this.scrollBy(this.layout.delta, 0, !0) : t = (n = g == null ? void 0 : (s = g.section).next) == null ? void 0 : n.call(s);
4942
+ const f = this.views.last();
4943
+ f && f.expand(), e = this.container.scrollLeft + this.container.offsetWidth + this.layout.delta, e <= this.container.scrollWidth ? this.scrollBy(this.layout.delta, 0, !0) : t = (n = f == null ? void 0 : (s = f.section).next) == null ? void 0 : n.call(s);
4730
4944
  }
4731
4945
  else if (this.isPaginated && this.settings.axis === "horizontal" && i === "rtl")
4732
4946
  if (this.scrollLeft = this.container.scrollLeft, this.settings.rtlScrollType === "default")
4733
4947
  if (e = this.container.scrollLeft, e > 0)
4734
4948
  this.scrollBy(this.layout.delta, 0, !0);
4735
4949
  else {
4736
- const g = this.views.last();
4737
- g && g.expand(), e = this.container.scrollLeft, e > 0 ? this.scrollBy(this.layout.delta, 0, !0) : t = (o = g == null ? void 0 : (r = g.section).next) == null ? void 0 : o.call(r);
4950
+ const f = this.views.last();
4951
+ f && f.expand(), e = this.container.scrollLeft, e > 0 ? this.scrollBy(this.layout.delta, 0, !0) : t = (o = f == null ? void 0 : (r = f.section).next) == null ? void 0 : o.call(r);
4738
4952
  }
4739
4953
  else if (e = this.container.scrollLeft + this.layout.delta * -1, e > this.container.scrollWidth * -1)
4740
4954
  this.scrollBy(this.layout.delta, 0, !0);
4741
4955
  else {
4742
- const g = this.views.last();
4743
- g && g.expand(), e = this.container.scrollLeft + this.layout.delta * -1, e > this.container.scrollWidth * -1 ? this.scrollBy(this.layout.delta, 0, !0) : t = (l = g == null ? void 0 : (h = g.section).next) == null ? void 0 : l.call(h);
4956
+ const f = this.views.last();
4957
+ f && f.expand(), e = this.container.scrollLeft + this.layout.delta * -1, e > this.container.scrollWidth * -1 ? this.scrollBy(this.layout.delta, 0, !0) : t = (l = f == null ? void 0 : (h = f.section).next) == null ? void 0 : l.call(h);
4744
4958
  }
4745
4959
  else if (this.isPaginated && this.settings.axis === "vertical")
4746
4960
  if (this.scrollTop = this.container.scrollTop, !(Math.abs(this.container.scrollHeight - this.container.clientHeight - this.container.scrollTop) < 1))
4747
4961
  this.scrollBy(0, this.layout.height, !0);
4748
4962
  else {
4749
- const m = this.views.last();
4750
- m && m.expand(), Math.abs(this.container.scrollHeight - this.container.clientHeight - this.container.scrollTop) < 1 ? t = (d = m == null ? void 0 : (c = m.section).next) == null ? void 0 : d.call(c) : this.scrollBy(0, this.layout.height, !0);
4963
+ const p = this.views.last();
4964
+ p && p.expand(), Math.abs(this.container.scrollHeight - this.container.clientHeight - this.container.scrollTop) < 1 ? t = (d = p == null ? void 0 : (c = p.section).next) == null ? void 0 : d.call(c) : this.scrollBy(0, this.layout.height, !0);
4751
4965
  }
4752
4966
  else
4753
- t = (p = (u = this.views.last().section).next) == null ? void 0 : p.call(u);
4967
+ t = (m = (u = this.views.last().section).next) == null ? void 0 : m.call(u);
4754
4968
  if (t) {
4755
4969
  this.clear(), this.updateLayout();
4756
- let g = !1;
4757
- return this.layout.name === "pre-paginated" && this.layout.divisor === 2 && t.properties.includes("page-spread-right") && (g = !0), this.append(t, g).then(() => this.handleNextPrePaginated(g, t, this.append), (m) => m).then(() => {
4970
+ let f = !1;
4971
+ return this.layout.name === "pre-paginated" && this.layout.divisor === 2 && t.properties.includes("page-spread-right") && (f = !0), this.append(t, f).then(() => this.handleNextPrePaginated(f, t, this.append), (p) => p).then(() => {
4758
4972
  !this.isPaginated && this.settings.axis === "horizontal" && this.settings.direction === "rtl" && this.settings.rtlScrollType === "default" && this.scrollTo(this.container.scrollWidth, 0, !0), this.views.show();
4759
4973
  });
4760
4974
  }
4761
4975
  }
4762
4976
  }
4763
4977
  prev() {
4764
- var s, n, r, o, h, l, c, d, u, p, g;
4978
+ var s, n, r, o, h, l, c, d, u, m, f;
4765
4979
  let t, e;
4766
4980
  const i = this.settings.direction;
4767
4981
  if (this.views.length) {
@@ -4769,22 +4983,22 @@ class st {
4769
4983
  if (this.scrollLeft = this.container.scrollLeft, e = this.container.scrollLeft, e > 0)
4770
4984
  this.scrollBy(-this.layout.delta, 0, !0);
4771
4985
  else {
4772
- const m = this.views.first();
4773
- m && m.expand(), e = this.container.scrollLeft, e > 0 ? this.scrollBy(-this.layout.delta, 0, !0) : t = (n = m == null ? void 0 : (s = m.section).prev) == null ? void 0 : n.call(s);
4986
+ const p = this.views.first();
4987
+ p && p.expand(), e = this.container.scrollLeft, e > 0 ? this.scrollBy(-this.layout.delta, 0, !0) : t = (n = p == null ? void 0 : (s = p.section).prev) == null ? void 0 : n.call(s);
4774
4988
  }
4775
4989
  else if (this.isPaginated && this.settings.axis === "horizontal" && i === "rtl")
4776
4990
  if (this.scrollLeft = this.container.scrollLeft, this.settings.rtlScrollType === "default")
4777
4991
  if (e = this.container.scrollLeft + this.container.offsetWidth, e < this.container.scrollWidth)
4778
4992
  this.scrollBy(-this.layout.delta, 0, !0);
4779
4993
  else {
4780
- const m = this.views.first();
4781
- m && m.expand(), e = this.container.scrollLeft + this.container.offsetWidth, e < this.container.scrollWidth ? this.scrollBy(-this.layout.delta, 0, !0) : t = (o = m == null ? void 0 : (r = m.section).prev) == null ? void 0 : o.call(r);
4994
+ const p = this.views.first();
4995
+ p && p.expand(), e = this.container.scrollLeft + this.container.offsetWidth, e < this.container.scrollWidth ? this.scrollBy(-this.layout.delta, 0, !0) : t = (o = p == null ? void 0 : (r = p.section).prev) == null ? void 0 : o.call(r);
4782
4996
  }
4783
4997
  else if (e = this.container.scrollLeft, e < 0)
4784
4998
  this.scrollBy(-this.layout.delta, 0, !0);
4785
4999
  else {
4786
- const m = this.views.first();
4787
- m && m.expand(), e = this.container.scrollLeft, e < 0 ? this.scrollBy(-this.layout.delta, 0, !0) : t = (l = m == null ? void 0 : (h = m.section).prev) == null ? void 0 : l.call(h);
5000
+ const p = this.views.first();
5001
+ p && p.expand(), e = this.container.scrollLeft, e < 0 ? this.scrollBy(-this.layout.delta, 0, !0) : t = (l = p == null ? void 0 : (h = p.section).prev) == null ? void 0 : l.call(h);
4788
5002
  }
4789
5003
  else if (this.isPaginated && this.settings.axis === "vertical")
4790
5004
  if (this.scrollTop = this.container.scrollTop, this.container.scrollTop > 0)
@@ -4794,16 +5008,16 @@ class st {
4794
5008
  v && v.expand(), this.container.scrollTop > 0 ? this.scrollBy(0, -this.layout.height, !0) : t = (d = v == null ? void 0 : (c = v.section).prev) == null ? void 0 : d.call(c);
4795
5009
  }
4796
5010
  else
4797
- t = (p = (u = this.views.first().section).prev) == null ? void 0 : p.call(u);
5011
+ t = (m = (u = this.views.first().section).prev) == null ? void 0 : m.call(u);
4798
5012
  if (t) {
4799
5013
  this.clear(), this.updateLayout();
4800
- let m = !1;
4801
- return this.layout.name === "pre-paginated" && this.layout.divisor === 2 && typeof ((g = t.prev) == null ? void 0 : g.call(t)) != "object" && (m = !0), this.prepend(t, m).then(() => {
5014
+ let p = !1;
5015
+ return this.layout.name === "pre-paginated" && this.layout.divisor === 2 && typeof ((f = t.prev) == null ? void 0 : f.call(t)) != "object" && (p = !0), this.prepend(t, p).then(() => {
4802
5016
  var v;
4803
5017
  if (this.layout.name === "pre-paginated" && this.layout.divisor > 1) {
4804
- const b = (v = t.prev) == null ? void 0 : v.call(t);
4805
- if (b)
4806
- return this.prepend(b);
5018
+ const w = (v = t.prev) == null ? void 0 : v.call(t);
5019
+ if (w)
5020
+ return this.prepend(w);
4807
5021
  }
4808
5022
  }, (v) => v).then(() => {
4809
5023
  this.isPaginated && this.settings.axis === "horizontal" && (this.settings.direction === "rtl" ? this.settings.rtlScrollType === "default" ? this.scrollTo(0, 0, !0) : this.scrollTo(this.container.scrollWidth * -1 + this.layout.delta, 0, !0) : this.scrollTo(this.container.scrollWidth - this.layout.delta, 0, !0)), this.views.show();
@@ -4816,7 +5030,10 @@ class st {
4816
5030
  return t.length ? t[t.length - 1] : null;
4817
5031
  }
4818
5032
  clear() {
4819
- this.views && (this.views.hide(), this.scrollTo(0, 0, !0), this.views.clear());
5033
+ this.views && (this._measurer && this.views.forEach((t) => {
5034
+ var e;
5035
+ (e = t == null ? void 0 : t.document) != null && e.body && this._measurer.invalidate(t.document.body);
5036
+ }), this.views.hide(), this.scrollTo(0, 0, !0), this.views.clear());
4820
5037
  }
4821
5038
  currentLocation() {
4822
5039
  return this.updateLayout(), this.isPaginated && this.settings.axis === "horizontal" ? this.location = this.paginatedLocation() : this.location = this.scrolledLocation(), this.location;
@@ -4827,24 +5044,24 @@ class st {
4827
5044
  let r = 0;
4828
5045
  const o = 0;
4829
5046
  return this.settings.fullsize && (r = n ? window.scrollY : window.scrollX), t.map((l) => {
4830
- const c = l.section.index, d = l.section.href, u = l.position(), p = l.width(), g = l.height();
4831
- let m, v, b, k;
4832
- n ? (m = r + e.top - u.top + o, v = m + i - o, k = this.layout.count(g, i).pages, b = i) : (m = r + e.left - u.left + o, v = m + s - o, k = this.layout.count(p, s).pages, b = s);
4833
- let E = Math.ceil(m / b), _ = [], T = Math.ceil(v / b);
5047
+ const c = l.section.index, d = l.section.href, u = l.position(), m = l.width(), f = l.height();
5048
+ let p, v, w, k;
5049
+ n ? (p = r + e.top - u.top + o, v = p + i - o, k = this.layout.count(f, i).pages, w = i) : (p = r + e.left - u.left + o, v = p + s - o, k = this.layout.count(m, s).pages, w = s);
5050
+ let E = Math.ceil(p / w), S = [], T = Math.ceil(v / w);
4834
5051
  if (this.settings.direction === "rtl" && !n) {
4835
5052
  const M = E;
4836
5053
  E = k - T, T = k - M;
4837
5054
  }
4838
- _ = [];
5055
+ S = [];
4839
5056
  for (let M = E; M <= T; M++) {
4840
- const z = M + 1;
4841
- _.push(z);
5057
+ const D = M + 1;
5058
+ S.push(D);
4842
5059
  }
4843
- const I = this.mapping.page(l.contents, l.section.cfiBase, m, v);
5060
+ const I = this.mapping.page(l.contents, l.section.cfiBase, p, v);
4844
5061
  return {
4845
5062
  index: c,
4846
5063
  href: d,
4847
- pages: _,
5064
+ pages: S,
4848
5065
  totalPages: k,
4849
5066
  mapping: I
4850
5067
  };
@@ -4857,18 +5074,18 @@ class st {
4857
5074
  const o = r.section.index, h = r.section.href;
4858
5075
  let l;
4859
5076
  const c = r.position(), d = r.width();
4860
- let u, p, g;
4861
- this.settings.direction === "rtl" ? (l = e.right - i, g = Math.min(Math.abs(l - c.left), this.layout.width) - s, p = c.width - (c.right - l) - s, u = p - g) : (l = e.left + i, g = Math.min(c.right - l, this.layout.width) - s, u = l - c.left + s, p = u + g), s += g;
4862
- const m = this.mapping.page(r.contents, r.section.cfiBase, u, p), v = this.layout.count(d).pages;
4863
- let b = Math.floor(u / this.layout.pageWidth);
5077
+ let u, m, f;
5078
+ this.settings.direction === "rtl" ? (l = e.right - i, f = Math.min(Math.abs(l - c.left), this.layout.width) - s, m = c.width - (c.right - l) - s, u = m - f) : (l = e.left + i, f = Math.min(c.right - l, this.layout.width) - s, u = l - c.left + s, m = u + f), s += f;
5079
+ const p = this.mapping.page(r.contents, r.section.cfiBase, u, m), v = this.layout.count(d).pages;
5080
+ let w = Math.floor(u / this.layout.pageWidth);
4864
5081
  const k = [];
4865
- let E = Math.floor(p / this.layout.pageWidth);
4866
- if (b < 0 && (b = 0, E = E + 1), this.settings.direction === "rtl") {
4867
- const _ = b;
4868
- b = v - E, E = v - _;
5082
+ let E = Math.floor(m / this.layout.pageWidth);
5083
+ if (w < 0 && (w = 0, E = E + 1), this.settings.direction === "rtl") {
5084
+ const S = w;
5085
+ w = v - E, E = v - S;
4869
5086
  }
4870
- for (let _ = b + 1; _ <= E; _++) {
4871
- const T = _;
5087
+ for (let S = w + 1; S <= E; S++) {
5088
+ const T = S;
4872
5089
  k.push(T);
4873
5090
  }
4874
5091
  return {
@@ -4876,7 +5093,7 @@ class st {
4876
5093
  href: h,
4877
5094
  pages: k,
4878
5095
  totalPages: v,
4879
- mapping: m
5096
+ mapping: p
4880
5097
  };
4881
5098
  });
4882
5099
  }
@@ -4900,11 +5117,11 @@ class st {
4900
5117
  }
4901
5118
  onScroll() {
4902
5119
  let t, e;
4903
- this.settings.fullsize ? (t = window.scrollY, e = window.scrollX) : (t = this.container.scrollTop, e = this.container.scrollLeft), this.scrollTop = t, this.scrollLeft = e, this.ignore ? this.ignore = !1 : (this.emit(f.MANAGERS.SCROLL, {
5120
+ this.settings.fullsize ? (t = window.scrollY, e = window.scrollX) : (t = this.container.scrollTop, e = this.container.scrollLeft), this.scrollTop = t, this.scrollLeft = e, this.ignore ? this.ignore = !1 : (this.emit(g.MANAGERS.SCROLL, {
4904
5121
  top: t,
4905
5122
  left: e
4906
5123
  }), clearTimeout(this.afterScrolled), this.afterScrolled = setTimeout(() => {
4907
- this.emit(f.MANAGERS.SCROLLED, {
5124
+ this.emit(g.MANAGERS.SCROLLED, {
4908
5125
  top: this.scrollTop,
4909
5126
  left: this.scrollLeft
4910
5127
  });
@@ -4924,7 +5141,7 @@ class st {
4924
5141
  ), this.settings.offset = this.layout.delta / this.layout.divisor) : this.layout.calculate(this._stageSize.width, this._stageSize.height), this.viewSettings.width = this.layout.width, this.viewSettings.height = this.layout.height, this.setLayout(this.layout));
4925
5142
  }
4926
5143
  setLayout(t) {
4927
- this.viewSettings.layout = t, this.mapping = new wt(t.props, this.settings.direction, this.settings.axis), this.views && this.views.forEach((e) => {
5144
+ this.viewSettings.layout = t, this.mapping = new wt(t.props, this.settings.direction, this.settings.axis, !1, this._measurer), this.views && this.views.forEach((e) => {
4928
5145
  e && e.setLayout(t);
4929
5146
  });
4930
5147
  }
@@ -4932,7 +5149,7 @@ class st {
4932
5149
  this.writingMode = t;
4933
5150
  }
4934
5151
  updateAxis(t, e) {
4935
- !e && t === this.settings.axis || (this.settings.axis = t, this.stage && this.stage.axis(t), this.viewSettings.axis = t, this.mapping && (this.mapping = new wt(this.layout.props, this.settings.direction, this.settings.axis)), this.layout && (t === "vertical" ? this.layout.spread("none") : this.layout.spread(this.layout.settings.spread)));
5152
+ !e && t === this.settings.axis || (this.settings.axis = t, this.stage && this.stage.axis(t), this.viewSettings.axis = t, this.mapping && (this.mapping = new wt(this.layout.props, this.settings.direction, this.settings.axis, !1, this._measurer)), this.layout && (t === "vertical" ? this.layout.spread("none") : this.layout.spread(this.layout.settings.spread)));
4936
5153
  }
4937
5154
  updateFlow(t, e = "auto") {
4938
5155
  const i = t === "paginated" || t === "auto";
@@ -4953,18 +5170,18 @@ class st {
4953
5170
  }
4954
5171
  }
4955
5172
  P(st.prototype);
4956
- const je = {
5173
+ const Xe = {
4957
5174
  easeInCubic: function(a) {
4958
5175
  return Math.pow(a, 3);
4959
5176
  }
4960
5177
  };
4961
- class bt {
5178
+ class xt {
4962
5179
  constructor(t, e) {
4963
5180
  this.settings = C({
4964
5181
  duration: 80,
4965
5182
  minVelocity: 0.2,
4966
5183
  minDistance: 10,
4967
- easing: je.easeInCubic
5184
+ easing: Xe.easeInCubic
4968
5185
  }, e || {}), this._supportsTouch = this.supportsTouch(), this._supportsTouch && this.setup(t);
4969
5186
  }
4970
5187
  setup(t) {
@@ -4980,10 +5197,10 @@ class bt {
4980
5197
  this.element.style.overflow = "";
4981
5198
  }
4982
5199
  addListeners() {
4983
- this._onResize = this.onResize.bind(this), window.addEventListener("resize", this._onResize), this._onScroll = this.onScroll.bind(this), this.scroller.addEventListener("scroll", this._onScroll), this._onTouchStart = this.onTouchStart.bind(this), this.scroller.addEventListener("touchstart", this._onTouchStart, { passive: !0 }), this.on("touchstart", this._onTouchStart), this._onTouchMove = this.onTouchMove.bind(this), this.scroller.addEventListener("touchmove", this._onTouchMove, { passive: !0 }), this.on("touchmove", this._onTouchMove), this._onTouchEnd = this.onTouchEnd.bind(this), this.scroller.addEventListener("touchend", this._onTouchEnd, { passive: !0 }), this.on("touchend", this._onTouchEnd), this._afterDisplayed = this.afterDisplayed.bind(this), this.manager.on(f.MANAGERS.ADDED, this._afterDisplayed);
5200
+ this._onResize = this.onResize.bind(this), window.addEventListener("resize", this._onResize), this._onScroll = this.onScroll.bind(this), this.scroller.addEventListener("scroll", this._onScroll), this._onTouchStart = this.onTouchStart.bind(this), this.scroller.addEventListener("touchstart", this._onTouchStart, { passive: !0 }), this.on("touchstart", this._onTouchStart), this._onTouchMove = this.onTouchMove.bind(this), this.scroller.addEventListener("touchmove", this._onTouchMove, { passive: !0 }), this.on("touchmove", this._onTouchMove), this._onTouchEnd = this.onTouchEnd.bind(this), this.scroller.addEventListener("touchend", this._onTouchEnd, { passive: !0 }), this.on("touchend", this._onTouchEnd), this._afterDisplayed = this.afterDisplayed.bind(this), this.manager.on(g.MANAGERS.ADDED, this._afterDisplayed);
4984
5201
  }
4985
5202
  removeListeners() {
4986
- window.removeEventListener("resize", this._onResize), this._onResize = void 0, this.scroller.removeEventListener("scroll", this._onScroll), this._onScroll = void 0, this.scroller.removeEventListener("touchstart", this._onTouchStart, { passive: !0 }), this.off("touchstart", this._onTouchStart), this._onTouchStart = void 0, this.scroller.removeEventListener("touchmove", this._onTouchMove, { passive: !0 }), this.off("touchmove", this._onTouchMove), this._onTouchMove = void 0, this.scroller.removeEventListener("touchend", this._onTouchEnd, { passive: !0 }), this.off("touchend", this._onTouchEnd), this._onTouchEnd = void 0, this.manager.off(f.MANAGERS.ADDED, this._afterDisplayed), this._afterDisplayed = void 0;
5203
+ window.removeEventListener("resize", this._onResize), this._onResize = void 0, this.scroller.removeEventListener("scroll", this._onScroll), this._onScroll = void 0, this.scroller.removeEventListener("touchstart", this._onTouchStart, { passive: !0 }), this.off("touchstart", this._onTouchStart), this._onTouchStart = void 0, this.scroller.removeEventListener("touchmove", this._onTouchMove, { passive: !0 }), this.off("touchmove", this._onTouchMove), this._onTouchMove = void 0, this.scroller.removeEventListener("touchend", this._onTouchEnd, { passive: !0 }), this.off("touchend", this._onTouchEnd), this._onTouchEnd = void 0, this.manager.off(g.MANAGERS.ADDED, this._afterDisplayed), this._afterDisplayed = void 0;
4987
5204
  }
4988
5205
  afterDisplayed(t) {
4989
5206
  const e = t.contents;
@@ -5052,8 +5269,8 @@ class bt {
5052
5269
  this.scroller && (this.fullsize && this.enableScroll(), this.removeListeners(), this.scroller = void 0);
5053
5270
  }
5054
5271
  }
5055
- P(bt.prototype);
5056
- function Fe(a, t) {
5272
+ P(xt.prototype);
5273
+ function Ye(a, t) {
5057
5274
  let e;
5058
5275
  return function(...i) {
5059
5276
  clearTimeout(e), e = setTimeout(() => {
@@ -5061,7 +5278,7 @@ function Fe(a, t) {
5061
5278
  }, t);
5062
5279
  };
5063
5280
  }
5064
- class Ve extends st {
5281
+ class Ge extends st {
5065
5282
  constructor(t) {
5066
5283
  var i;
5067
5284
  super(t), this.name = "continuous", this.settings = C({}, {
@@ -5105,7 +5322,7 @@ class Ve extends st {
5105
5322
  this.isPaginated ? (e = Math.floor(t.left / this.layout.delta) * this.layout.delta, e + (this.settings.offsetDelta ?? 0)) : (i = t.top, t.top + (this.settings.offsetDelta ?? 0)), (e > 0 || i > 0) && this.scrollBy(e, i, !0);
5106
5323
  }
5107
5324
  afterResized(t) {
5108
- this.emit(f.MANAGERS.RESIZE, t.section);
5325
+ this.emit(g.MANAGERS.RESIZE, t.section);
5109
5326
  }
5110
5327
  // Remove Previous Listeners if present
5111
5328
  removeShownListeners(t) {
@@ -5114,35 +5331,33 @@ class Ve extends st {
5114
5331
  }
5115
5332
  add(t) {
5116
5333
  const e = this.createView(t);
5117
- return this.views.append(e), e.on(f.VIEWS.RESIZED, (i) => {
5334
+ return this.views.append(e), e.on(g.VIEWS.RESIZED, (i) => {
5118
5335
  e.expanded = !0;
5119
- }), e.on(f.VIEWS.AXIS, (i) => {
5336
+ }), e.on(g.VIEWS.AXIS, (i) => {
5120
5337
  this.updateAxis(i);
5121
- }), e.on(f.VIEWS.WRITING_MODE, (i) => {
5338
+ }), e.on(g.VIEWS.WRITING_MODE, (i) => {
5122
5339
  this.updateWritingMode(i);
5123
5340
  }), e.onDisplayed = (i) => this.afterDisplayed(i), e.onResize = (i) => this.afterResized(i), e.display(this.request);
5124
5341
  }
5125
- // @ts-expect-error - Returns IframeView synchronously unlike base class Promise<IframeView>
5126
5342
  append(t) {
5127
5343
  const e = this.createView(t);
5128
- return e.on(f.VIEWS.RESIZED, (i) => {
5344
+ return e.on(g.VIEWS.RESIZED, (i) => {
5129
5345
  e.expanded = !0;
5130
- }), e.on(f.VIEWS.AXIS, (i) => {
5346
+ }), e.on(g.VIEWS.AXIS, (i) => {
5131
5347
  this.updateAxis(i);
5132
- }), e.on(f.VIEWS.WRITING_MODE, (i) => {
5348
+ }), e.on(g.VIEWS.WRITING_MODE, (i) => {
5133
5349
  this.updateWritingMode(i);
5134
- }), this.views.append(e), e.onDisplayed = (i) => this.afterDisplayed(i), e;
5350
+ }), this.views.append(e), e.onDisplayed = (i) => this.afterDisplayed(i), Promise.resolve(e);
5135
5351
  }
5136
- // @ts-expect-error - Returns IframeView synchronously unlike base class Promise<IframeView>
5137
5352
  prepend(t) {
5138
5353
  const e = this.createView(t);
5139
- return e.on(f.VIEWS.RESIZED, (i) => {
5354
+ return e.on(g.VIEWS.RESIZED, (i) => {
5140
5355
  this.counter(i), e.expanded = !0;
5141
- }), e.on(f.VIEWS.AXIS, (i) => {
5356
+ }), e.on(g.VIEWS.AXIS, (i) => {
5142
5357
  this.updateAxis(i);
5143
- }), e.on(f.VIEWS.WRITING_MODE, (i) => {
5358
+ }), e.on(g.VIEWS.WRITING_MODE, (i) => {
5144
5359
  this.updateWritingMode(i);
5145
- }), this.views.prepend(e), e.onDisplayed = (i) => this.afterDisplayed(i), e;
5360
+ }), this.views.prepend(e), e.onDisplayed = (i) => this.afterDisplayed(i), Promise.resolve(e);
5146
5361
  }
5147
5362
  counter(t) {
5148
5363
  this.settings.axis === "vertical" ? this.scrollBy(0, t.heightDelta, !0) : this.scrollBy(t.widthDelta, 0, !0);
@@ -5150,7 +5365,7 @@ class Ve extends st {
5150
5365
  update(t) {
5151
5366
  const e = this.bounds(), i = this.views.all(), s = i.length, n = typeof t < "u" ? t : this.settings.offset || 0;
5152
5367
  let r, o;
5153
- const h = new S(), l = [];
5368
+ const h = new _(), l = [];
5154
5369
  for (let c = 0; c < s; c++)
5155
5370
  if (o = i[c], r = this.isVisible(o, n, n, e), r === !0)
5156
5371
  if (o.displayed)
@@ -5172,30 +5387,30 @@ class Ve extends st {
5172
5387
  }) : (h.resolve(), h.promise);
5173
5388
  }
5174
5389
  check(t, e) {
5175
- const i = new S(), s = [], n = this.settings.axis === "horizontal";
5390
+ const i = new _(), s = [], n = this.settings.axis === "horizontal";
5176
5391
  let r = this.settings.offset || 0;
5177
5392
  t && n && (r = t), e && !n && (r = e);
5178
5393
  const o = this._bounds;
5179
5394
  let h = n ? this.scrollLeft : this.scrollTop;
5180
- const l = n ? Math.floor(o.width) : o.height, c = n ? this.container.scrollWidth : this.container.scrollHeight, d = this.writingMode && this.writingMode.indexOf("vertical") === 0 ? "vertical" : "horizontal", u = this.settings.rtlScrollType, p = this.settings.direction === "rtl";
5181
- this.settings.fullsize ? (n && p && u === "negative" || !n && p && u === "default") && (h = h * -1) : (p && u === "default" && d === "horizontal" && (h = c - l - h), p && u === "negative" && d === "horizontal" && (h = h * -1));
5182
- const g = () => {
5395
+ const l = n ? Math.floor(o.width) : o.height, c = n ? this.container.scrollWidth : this.container.scrollHeight, d = this.writingMode && this.writingMode.indexOf("vertical") === 0 ? "vertical" : "horizontal", u = this.settings.rtlScrollType, m = this.settings.direction === "rtl";
5396
+ this.settings.fullsize ? (n && m && u === "negative" || !n && m && u === "default") && (h = h * -1) : (m && u === "default" && d === "horizontal" && (h = c - l - h), m && u === "negative" && d === "horizontal" && (h = h * -1));
5397
+ const f = () => {
5183
5398
  var T, I;
5184
- const E = this.views.first(), _ = E && ((I = (T = E.section).prev) == null ? void 0 : I.call(T));
5185
- _ && s.push(this.prepend(_));
5186
- }, m = () => {
5399
+ const E = this.views.first(), S = E && ((I = (T = E.section).prev) == null ? void 0 : I.call(T));
5400
+ S && s.push(this.prepend(S));
5401
+ }, p = () => {
5187
5402
  var T, I;
5188
- const E = this.views.last(), _ = E && ((I = (T = E.section).next) == null ? void 0 : I.call(T));
5189
- _ && s.push(this.append(_));
5190
- }, v = h + l + r, b = h - r;
5191
- v >= c && m(), b < 0 && g();
5192
- const k = s.map((E) => E.display(this.request));
5403
+ const E = this.views.last(), S = E && ((I = (T = E.section).next) == null ? void 0 : I.call(T));
5404
+ S && s.push(this.append(S));
5405
+ }, v = h + l + r, w = h - r;
5406
+ v >= c && p(), w < 0 && f();
5407
+ const k = s.map((E) => E.then((S) => S.display(this.request)));
5193
5408
  return s.length ? Promise.all(k).then(() => this.check()).then(() => this.update(r), (E) => E) : (this.q.enqueue(() => {
5194
5409
  this.update();
5195
5410
  }), i.resolve(!1), i.promise);
5196
5411
  }
5197
5412
  trim() {
5198
- const t = new S(), e = this.views.displayed();
5413
+ const t = new _(), e = this.views.displayed();
5199
5414
  if (!e.length)
5200
5415
  return t.resolve(), t.promise;
5201
5416
  const i = e[0], s = e[e.length - 1], n = this.views.indexOf(i), r = this.views.indexOf(s), o = this.views.slice(0, n), h = this.views.slice(r + 1);
@@ -5214,12 +5429,12 @@ class Ve extends st {
5214
5429
  addEventListeners(t) {
5215
5430
  this._onUnload = (e) => {
5216
5431
  this.ignore = !0, this.destroy();
5217
- }, window.addEventListener("unload", this._onUnload), this.addScrollListeners(), this.isPaginated && this.settings.snap && (this.snapper = new bt(this, typeof this.settings.snap == "object" ? this.settings.snap : void 0));
5432
+ }, window.addEventListener("unload", this._onUnload), this.addScrollListeners(), this.isPaginated && this.settings.snap && (this.snapper = new xt(this, typeof this.settings.snap == "object" ? this.settings.snap : void 0));
5218
5433
  }
5219
5434
  addScrollListeners() {
5220
5435
  let t;
5221
5436
  const e = this.settings.direction === "rtl" && this.settings.rtlScrollType === "default" ? -1 : 1;
5222
- this.scrollDeltaVert = 0, this.scrollDeltaHorz = 0, this.settings.fullsize ? (t = window, this.scrollTop = window.scrollY * e, this.scrollLeft = window.scrollX * e) : (t = this.container, this.scrollTop = this.container.scrollTop, this.scrollLeft = this.container.scrollLeft), this._onScroll = this.onScroll.bind(this), t.addEventListener("scroll", this._onScroll), this._scrolled = Fe(() => this.scrolled(), 30), this.didScroll = !1;
5437
+ this.scrollDeltaVert = 0, this.scrollDeltaHorz = 0, this.settings.fullsize ? (t = window, this.scrollTop = window.scrollY * e, this.scrollLeft = window.scrollX * e) : (t = this.container, this.scrollTop = this.container.scrollTop, this.scrollLeft = this.container.scrollLeft), this._onScroll = this.onScroll.bind(this), t.addEventListener("scroll", this._onScroll), this._scrolled = Ye(() => this.scrolled(), 30), this.didScroll = !1;
5223
5438
  }
5224
5439
  removeEventListeners() {
5225
5440
  let t;
@@ -5233,11 +5448,11 @@ class Ve extends st {
5233
5448
  }, 150), clearTimeout(this.afterScrolled), this.didScroll = !1;
5234
5449
  }
5235
5450
  scrolled() {
5236
- this.q.enqueue(() => this.check()), this.emit(f.MANAGERS.SCROLL, {
5451
+ this.q.enqueue(() => this.check()), this.emit(g.MANAGERS.SCROLL, {
5237
5452
  top: this.scrollTop,
5238
5453
  left: this.scrollLeft
5239
5454
  }), clearTimeout(this.afterScrolled), this.afterScrolled = setTimeout(() => {
5240
- this.snapper && this.snapper.supportsTouch() && this.snapper.needsSnap() || this.emit(f.MANAGERS.SCROLLED, {
5455
+ this.snapper && this.snapper.supportsTouch() && this.snapper.needsSnap() || this.emit(g.MANAGERS.SCROLLED, {
5241
5456
  top: this.scrollTop,
5242
5457
  left: this.scrollLeft
5243
5458
  });
@@ -5252,7 +5467,7 @@ class Ve extends st {
5252
5467
  this.views.length && (this.isPaginated && this.settings.axis === "horizontal" ? this.scrollBy(-t, 0, !0) : this.scrollBy(0, -this.layout.height, !0), this.q.enqueue(() => this.check()));
5253
5468
  }
5254
5469
  updateFlow(t) {
5255
- this.rendered && this.snapper && (this.snapper.destroy(), this.snapper = void 0), super.updateFlow(t, "scroll"), this.rendered && this.isPaginated && this.settings.snap && (this.snapper = new bt(this, typeof this.settings.snap == "object" ? this.settings.snap : void 0));
5470
+ this.rendered && this.snapper && (this.snapper.destroy(), this.snapper = void 0), super.updateFlow(t, "scroll"), this.rendered && this.isPaginated && this.settings.snap && (this.snapper = new xt(this, typeof this.settings.snap == "object" ? this.settings.snap : void 0));
5256
5471
  }
5257
5472
  destroy() {
5258
5473
  clearTimeout(this.scrollTimeout), clearTimeout(this.trimTimeout), super.destroy(), this.snapper && this.snapper.destroy();
@@ -5277,7 +5492,7 @@ class Lt {
5277
5492
  defaultDirection: "ltr",
5278
5493
  allowScriptedContent: !1,
5279
5494
  allowPopups: !1
5280
- }), C(this.settings, e), typeof this.settings.manager == "object" && (this.manager = this.settings.manager), this.book = t, this.hooks = {}, this.hooks.display = new A(this), this.hooks.serialize = new A(this), this.hooks.content = new A(this), this.hooks.unloaded = new A(this), this.hooks.layout = new A(this), this.hooks.render = new A(this), this.hooks.show = new A(this), this.hooks.content.register((i) => this.handleLinks(i)), this.hooks.content.register((i) => this.passEvents(i)), this.hooks.content.register((i) => this.adjustImages(i)), this.book.spine.hooks.content.register((i, s) => this.injectIdentifier(i, s)), this.settings.stylesheet && this.book.spine.hooks.content.register((i, s) => this.injectStylesheet(i, s)), this.settings.script && this.book.spine.hooks.content.register((i, s) => this.injectScript(i, s)), this.themes = new Ce(this), this.annotations = new Te(this), this.epubcfi = new y(), this.q = new kt(this), this.location = void 0, this.q.enqueue(this.book.opened), this.starting = new S(), this.started = this.starting.promise, this.q.enqueue(this.start);
5495
+ }), C(this.settings, e), typeof this.settings.manager == "object" && (this.manager = this.settings.manager), this.book = t, this.hooks = {}, this.hooks.display = new A(this), this.hooks.serialize = new A(this), this.hooks.content = new A(this), this.hooks.unloaded = new A(this), this.hooks.layout = new A(this), this.hooks.render = new A(this), this.hooks.show = new A(this), this.hooks.content.register((i) => this.handleLinks(i)), this.hooks.content.register((i) => this.passEvents(i)), this.hooks.content.register((i) => this.adjustImages(i)), this.book.spine.hooks.content.register((i, s) => this.injectIdentifier(i, s)), this.settings.stylesheet && this.book.spine.hooks.content.register((i, s) => this.injectStylesheet(i, s)), this.settings.script && this.book.spine.hooks.content.register((i, s) => this.injectScript(i, s)), this.themes = new Te(this), this.annotations = new ke(this), this.epubcfi = new y(), this.q = new kt(this), this.location = void 0, this.q.enqueue(this.book.opened), this.starting = new _(), this.started = this.starting.promise, this.q.enqueue(this.start);
5281
5496
  }
5282
5497
  /**
5283
5498
  * Set the manager function
@@ -5293,7 +5508,7 @@ class Lt {
5293
5508
  */
5294
5509
  requireManager(t) {
5295
5510
  let e;
5296
- return typeof t == "string" && t === "default" ? e = st : typeof t == "string" && t === "continuous" ? e = Ve : e = t, e;
5511
+ return typeof t == "string" && t === "default" ? e = st : typeof t == "string" && t === "continuous" ? e = Ge : e = t, e;
5297
5512
  }
5298
5513
  /**
5299
5514
  * Require the view from passed string, or as a class function
@@ -5302,7 +5517,7 @@ class Lt {
5302
5517
  */
5303
5518
  requireView(t) {
5304
5519
  let e;
5305
- return typeof t == "string" && t === "iframe" ? e = Jt : e = t, e;
5520
+ return typeof t == "string" && t === "iframe" ? e = te : e = t, e;
5306
5521
  }
5307
5522
  /**
5308
5523
  * Start the rendering
@@ -5322,7 +5537,7 @@ class Lt {
5322
5537
  queue: this.q,
5323
5538
  request: this.book.load.bind(this.book),
5324
5539
  settings: this.settings
5325
- })), this.direction(this.book.package.metadata.direction || this.settings.defaultDirection), this.settings.globalLayoutProperties = this.determineLayoutProperties(this.book.package.metadata), this.flow(this.settings.globalLayoutProperties.flow), this.layout(this.settings.globalLayoutProperties), this.manager.on(f.MANAGERS.ADDED, (t) => this.afterDisplayed(t)), this.manager.on(f.MANAGERS.REMOVED, (t) => this.afterRemoved(t)), this.manager.on(f.MANAGERS.RESIZED, (t, e) => this.onResized(t, e)), this.manager.on(f.MANAGERS.ORIENTATION_CHANGE, (t) => this.onOrientationChange(t)), this.manager.on(f.MANAGERS.SCROLLED, () => this.reportLocation()), this.emit(f.RENDITION.STARTED), this.starting.resolve();
5540
+ })), this.direction(this.book.package.metadata.direction || this.settings.defaultDirection), this.settings.globalLayoutProperties = this.determineLayoutProperties(this.book.package.metadata), this.flow(this.settings.globalLayoutProperties.flow), this.layout(this.settings.globalLayoutProperties), this.manager.on(g.MANAGERS.ADDED, (t) => this.afterDisplayed(t)), this.manager.on(g.MANAGERS.REMOVED, (t) => this.afterRemoved(t)), this.manager.on(g.MANAGERS.RESIZED, (t, e) => this.onResized(t, e)), this.manager.on(g.MANAGERS.ORIENTATION_CHANGE, (t) => this.onOrientationChange(t)), this.manager.on(g.MANAGERS.SCROLLED, () => this.reportLocation()), this.emit(g.RENDITION.STARTED), this.starting.resolve();
5326
5541
  }
5327
5542
  /**
5328
5543
  * Call to attach the container to an element in the dom
@@ -5335,7 +5550,7 @@ class Lt {
5335
5550
  this.manager.render(t, {
5336
5551
  width: this.settings.width,
5337
5552
  height: this.settings.height
5338
- }), this.emit(f.RENDITION.ATTACHED);
5553
+ }), this.emit(g.RENDITION.ATTACHED);
5339
5554
  });
5340
5555
  }
5341
5556
  /**
@@ -5359,13 +5574,13 @@ class Lt {
5359
5574
  if (!this.book)
5360
5575
  return;
5361
5576
  this.epubcfi.isCfiString(t);
5362
- const e = new S(), i = e.promise;
5363
- this.displaying = e, this.book.locations.length() && Wt(t) && (t = this.book.locations.cfiFromPercentage(parseFloat(t)));
5577
+ const e = new _(), i = e.promise;
5578
+ this.displaying = e, this.book.locations.length() && qt(t) && (t = this.book.locations.cfiFromPercentage(parseFloat(t)));
5364
5579
  const s = this.book.spine.get(t);
5365
5580
  return s ? (this.manager.display(s, t).then(() => {
5366
- e.resolve(s), this.displaying = void 0, this.emit(f.RENDITION.DISPLAYED, s), this.reportLocation();
5581
+ e.resolve(s), this.displaying = void 0, this.emit(g.RENDITION.DISPLAYED, s), this.reportLocation();
5367
5582
  }, (n) => {
5368
- this.emit(f.RENDITION.DISPLAY_ERROR, n);
5583
+ this.emit(g.RENDITION.DISPLAY_ERROR, n);
5369
5584
  }), i) : (e.reject(new Error("No Section Found")), i);
5370
5585
  }
5371
5586
  /*
@@ -5418,12 +5633,12 @@ class Lt {
5418
5633
  * @param {*} view
5419
5634
  */
5420
5635
  afterDisplayed(t) {
5421
- t.on(f.VIEWS.MARK_CLICKED, (e, i) => {
5636
+ t.on(g.VIEWS.MARK_CLICKED, (e, i) => {
5422
5637
  t.contents && this.triggerMarkEvent(e, i, t.contents);
5423
5638
  }), this.hooks.render.trigger(t, this).then(() => {
5424
5639
  t.contents ? this.hooks.content.trigger(t.contents, this).then(() => {
5425
- this.emit(f.RENDITION.RENDERED, t.section, t);
5426
- }) : this.emit(f.RENDITION.RENDERED, t.section, t);
5640
+ this.emit(g.RENDITION.RENDERED, t.section, t);
5641
+ }) : this.emit(g.RENDITION.RENDERED, t.section, t);
5427
5642
  });
5428
5643
  }
5429
5644
  /**
@@ -5433,7 +5648,7 @@ class Lt {
5433
5648
  */
5434
5649
  afterRemoved(t) {
5435
5650
  this.hooks.unloaded.trigger(t, this).then(() => {
5436
- this.emit(f.RENDITION.REMOVED, t.section, t);
5651
+ this.emit(g.RENDITION.REMOVED, t.section, t);
5437
5652
  });
5438
5653
  }
5439
5654
  /**
@@ -5441,7 +5656,7 @@ class Lt {
5441
5656
  * @private
5442
5657
  */
5443
5658
  onResized(t, e) {
5444
- this.emit(f.RENDITION.RESIZED, {
5659
+ this.emit(g.RENDITION.RESIZED, {
5445
5660
  width: t.width,
5446
5661
  height: t.height
5447
5662
  }, e), this.location && this.location.start && this.display(e || this.location.start.cfi);
@@ -5451,7 +5666,7 @@ class Lt {
5451
5666
  * @private
5452
5667
  */
5453
5668
  onOrientationChange(t) {
5454
- this.emit(f.RENDITION.ORIENTATION_CHANGE, t);
5669
+ this.emit(g.RENDITION.ORIENTATION_CHANGE, t);
5455
5670
  }
5456
5671
  /**
5457
5672
  * Move the Rendition to a specific offset
@@ -5523,13 +5738,13 @@ class Lt {
5523
5738
  * @param {object} settings
5524
5739
  */
5525
5740
  layout(t) {
5526
- return t && (this._layout = new Kt(t), this._layout.spread(t.spread, this.settings.minSpreadWidth), this._layout.on(f.LAYOUT.UPDATED, (e, i) => {
5527
- this.emit(f.RENDITION.LAYOUT, e, i);
5741
+ return t && (this._layout = new Zt(t), this._layout.spread(t.spread, this.settings.minSpreadWidth), this._layout.on(g.LAYOUT.UPDATED, (e, i) => {
5742
+ this.emit(g.RENDITION.LAYOUT, e, i);
5528
5743
  })), this.manager && this._layout && this.manager.applyLayout(this._layout), this._layout;
5529
5744
  }
5530
5745
  /**
5531
5746
  * Adjust if the rendition uses spreads
5532
- * @param {string} spread none | auto (TODO: implement landscape, portrait, both)
5747
+ * @param {string} spread none | auto
5533
5748
  * @param {int} [min] min width to use spreads at
5534
5749
  */
5535
5750
  spread(t, e) {
@@ -5553,25 +5768,25 @@ class Lt {
5553
5768
  if (t && "then" in t && typeof t.then == "function")
5554
5769
  t.then((e) => {
5555
5770
  const i = this.located(e);
5556
- !i || !i.start || !i.end || (this.location = i, this.emit(f.RENDITION.LOCATION_CHANGED, {
5771
+ !i || !i.start || !i.end || (this.location = i, this.emit(g.RENDITION.LOCATION_CHANGED, {
5557
5772
  index: this.location.start.index,
5558
5773
  href: this.location.start.href,
5559
5774
  start: this.location.start.cfi,
5560
5775
  end: this.location.end.cfi,
5561
5776
  percentage: this.location.start.percentage
5562
- }), this.emit(f.RENDITION.RELOCATED, this.location));
5777
+ }), this.emit(g.RENDITION.RELOCATED, this.location));
5563
5778
  });
5564
5779
  else if (t) {
5565
5780
  const e = this.located(t);
5566
5781
  if (!e || !e.start || !e.end)
5567
5782
  return;
5568
- this.location = e, this.emit(f.RENDITION.LOCATION_CHANGED, {
5783
+ this.location = e, this.emit(g.RENDITION.LOCATION_CHANGED, {
5569
5784
  index: this.location.start.index,
5570
5785
  href: this.location.start.href,
5571
5786
  start: this.location.start.cfi,
5572
5787
  end: this.location.end.cfi,
5573
5788
  percentage: this.location.start.percentage
5574
- }), this.emit(f.RENDITION.RELOCATED, this.location);
5789
+ }), this.emit(g.RENDITION.RELOCATED, this.location);
5575
5790
  }
5576
5791
  });
5577
5792
  });
@@ -5624,7 +5839,7 @@ class Lt {
5624
5839
  * Remove and Clean Up the Rendition
5625
5840
  */
5626
5841
  destroy() {
5627
- this.q.clear(), this.manager && (this.manager.off(f.MANAGERS.ADDED), this.manager.off(f.MANAGERS.REMOVED), this.manager.off(f.MANAGERS.RESIZED), this.manager.off(f.MANAGERS.ORIENTATION_CHANGE), this.manager.off(f.MANAGERS.SCROLLED), this.manager.destroy(), this.manager = void 0), this.book = void 0, this.hooks.display.clear(), this.hooks.serialize.clear(), this.hooks.content.clear(), this.hooks.unloaded.clear(), this.hooks.layout.clear(), this.hooks.render.clear(), this.hooks.show.clear(), this.themes.destroy(), this._layout && this._layout.off(f.LAYOUT.UPDATED), this._layout = void 0, this.location = void 0;
5842
+ this.q.clear(), this.manager && (this.manager.off(g.MANAGERS.ADDED), this.manager.off(g.MANAGERS.REMOVED), this.manager.off(g.MANAGERS.RESIZED), this.manager.off(g.MANAGERS.ORIENTATION_CHANGE), this.manager.off(g.MANAGERS.SCROLLED), this.manager.destroy(), this.manager = void 0), this.book = void 0, this.hooks.display.clear(), this.hooks.serialize.clear(), this.hooks.content.clear(), this.hooks.unloaded.clear(), this.hooks.layout.clear(), this.hooks.render.clear(), this.hooks.show.clear(), this.themes.destroy(), this._layout && this._layout.off(g.LAYOUT.UPDATED), this._layout = void 0, this.location = void 0;
5628
5843
  }
5629
5844
  /**
5630
5845
  * Pass the events from a view's Contents
@@ -5634,7 +5849,7 @@ class Lt {
5634
5849
  passEvents(t) {
5635
5850
  Z.forEach((e) => {
5636
5851
  t.on(e, (i) => this.triggerViewEvent(i, t));
5637
- }), t.on(f.CONTENTS.SELECTED, (e) => this.triggerSelectedEvent(e, t));
5852
+ }), t.on(g.CONTENTS.SELECTED, (e) => this.triggerSelectedEvent(e, t));
5638
5853
  }
5639
5854
  /**
5640
5855
  * Emit events passed by a view
@@ -5650,7 +5865,7 @@ class Lt {
5650
5865
  * @param {string} cfirange
5651
5866
  */
5652
5867
  triggerSelectedEvent(t, e) {
5653
- this.emit(f.RENDITION.SELECTED, t, e);
5868
+ this.emit(g.RENDITION.SELECTED, t, e);
5654
5869
  }
5655
5870
  /**
5656
5871
  * Emit a markClicked event with the cfiRange and data from a mark
@@ -5658,7 +5873,7 @@ class Lt {
5658
5873
  * @param {EpubCFI} cfirange
5659
5874
  */
5660
5875
  triggerMarkEvent(t, e, i) {
5661
- this.emit(f.RENDITION.MARK_CLICKED, t, e, i);
5876
+ this.emit(g.RENDITION.MARK_CLICKED, t, e, i);
5662
5877
  }
5663
5878
  /**
5664
5879
  * Get a Range from a Visible CFI
@@ -5723,7 +5938,7 @@ class Lt {
5723
5938
  * @private
5724
5939
  */
5725
5940
  handleLinks(t) {
5726
- t && t.on(f.CONTENTS.LINK_CLICKED, (e) => {
5941
+ t && t.on(g.CONTENTS.LINK_CLICKED, (e) => {
5727
5942
  const i = this.book.path.relative(e);
5728
5943
  this.display(i);
5729
5944
  });
@@ -5764,7 +5979,7 @@ class Lt {
5764
5979
  }
5765
5980
  P(Lt.prototype);
5766
5981
  const ct = typeof window < "u" ? window.URL : URL;
5767
- class He {
5982
+ class $e {
5768
5983
  constructor() {
5769
5984
  this.zip = void 0, this.urlCache = {}, this.checkRequirements();
5770
5985
  }
@@ -5775,7 +5990,7 @@ class He {
5775
5990
  */
5776
5991
  checkRequirements() {
5777
5992
  try {
5778
- this.zip = new ee();
5993
+ this.zip = new ie();
5779
5994
  } catch {
5780
5995
  throw new Error("JSZip lib not loaded");
5781
5996
  }
@@ -5902,7 +6117,7 @@ class He {
5902
6117
  this.zip = void 0, this.urlCache = {};
5903
6118
  }
5904
6119
  }
5905
- function Xe(a) {
6120
+ function Ke(a) {
5906
6121
  return new Promise((t, e) => {
5907
6122
  const i = indexedDB.open(a, 1);
5908
6123
  i.onupgradeneeded = () => {
@@ -5910,8 +6125,8 @@ function Xe(a) {
5910
6125
  }, i.onsuccess = () => t(i.result), i.onerror = () => e(i.error);
5911
6126
  });
5912
6127
  }
5913
- function Ye(a) {
5914
- const t = Xe(a);
6128
+ function Ze(a) {
6129
+ const t = Ke(a);
5915
6130
  return {
5916
6131
  getItem(e) {
5917
6132
  return t.then((i) => new Promise((s, n) => {
@@ -5928,7 +6143,7 @@ function Ye(a) {
5928
6143
  };
5929
6144
  }
5930
6145
  const dt = typeof window < "u" ? window.URL : void 0;
5931
- class te {
6146
+ class ee {
5932
6147
  constructor(t, e, i) {
5933
6148
  this.urlCache = {}, this.name = t, this.requester = e || Y, this.resolver = i, this.online = !0, this.checkRequirements(), this.addListeners();
5934
6149
  }
@@ -5940,7 +6155,7 @@ class te {
5940
6155
  try {
5941
6156
  if (typeof indexedDB > "u")
5942
6157
  throw new Error("IndexedDB not available");
5943
- this.storage = Ye(this.name);
6158
+ this.storage = Ze(this.name);
5944
6159
  } catch {
5945
6160
  throw new Error("IndexedDB not available");
5946
6161
  }
@@ -6108,7 +6323,7 @@ class te {
6108
6323
  this.urlCache = {}, this.removeListeners();
6109
6324
  }
6110
6325
  }
6111
- P(te.prototype);
6326
+ P(ee.prototype);
6112
6327
  class ut {
6113
6328
  constructor(t) {
6114
6329
  this.interactive = "", this.fixedLayout = "", this.openToSpread = "", this.orientationLock = "", t && this.parse(t);
@@ -6121,7 +6336,7 @@ class ut {
6121
6336
  parse(t) {
6122
6337
  if (!t)
6123
6338
  return this;
6124
- const e = w(t, "display_options");
6339
+ const e = x(t, "display_options");
6125
6340
  return e ? (B(e, "option").forEach((s) => {
6126
6341
  let n = "";
6127
6342
  switch (s.childNodes.length && (n = s.childNodes[0].nodeValue ?? ""), s.getAttribute("name") ?? "") {
@@ -6144,7 +6359,7 @@ class ut {
6144
6359
  this.interactive = void 0, this.fixedLayout = void 0, this.openToSpread = void 0, this.orientationLock = void 0;
6145
6360
  }
6146
6361
  }
6147
- const zt = "META-INF/container.xml", Ge = "META-INF/com.apple.ibooks.display-options.xml", L = {
6362
+ const zt = "META-INF/container.xml", Je = "META-INF/com.apple.ibooks.display-options.xml", L = {
6148
6363
  BINARY: "binary",
6149
6364
  BASE64: "base64",
6150
6365
  EPUB: "epub",
@@ -6163,15 +6378,15 @@ class Rt {
6163
6378
  canonical: void 0,
6164
6379
  openAs: void 0,
6165
6380
  store: void 0
6166
- }), C(this.settings, e), this.opening = new S(), this.opened = this.opening.promise, this.isOpen = !1, this.loading = {
6167
- manifest: new S(),
6168
- spine: new S(),
6169
- metadata: new S(),
6170
- cover: new S(),
6171
- navigation: new S(),
6172
- pageList: new S(),
6173
- resources: new S(),
6174
- displayOptions: new S()
6381
+ }), C(this.settings, e), this.opening = new _(), this.opened = this.opening.promise, this.isOpen = !1, this.loading = {
6382
+ manifest: new _(),
6383
+ spine: new _(),
6384
+ metadata: new _(),
6385
+ cover: new _(),
6386
+ navigation: new _(),
6387
+ pageList: new _(),
6388
+ resources: new _(),
6389
+ displayOptions: new _()
6175
6390
  }, this.loaded = {
6176
6391
  manifest: this.loading.manifest.promise,
6177
6392
  spine: this.loading.spine.promise,
@@ -6189,9 +6404,9 @@ class Rt {
6189
6404
  this.loaded.navigation,
6190
6405
  this.loaded.resources,
6191
6406
  this.loaded.displayOptions
6192
- ]), this.isRendered = !1, this.request = this.settings.requestMethod || Y, this.spine = new we(), this.locations = new $t(this.spine, (i) => this.load(i)), this.navigation = void 0, this.pageList = void 0, this.url = void 0, this.path = void 0, this.archived = !1, this.archive = void 0, this.storage = void 0, this.resources = void 0, this.rendition = void 0, this.container = void 0, this.packaging = void 0, this.displayOptions = void 0, this.settings.store && this.store(this.settings.store), t && this.open(t, this.settings.openAs).catch((i) => {
6407
+ ]), this.isRendered = !1, this.request = this.settings.requestMethod || Y, this.spine = new xe(), this.locations = new Kt(this.spine, (i) => this.load(i)), this.navigation = void 0, this.pageList = void 0, this.url = void 0, this.path = void 0, this.archived = !1, this.archive = void 0, this.storage = void 0, this.resources = void 0, this.rendition = void 0, this.container = void 0, this.packaging = void 0, this.displayOptions = void 0, this.settings.store && this.store(this.settings.store), t && this.open(t, this.settings.openAs).catch((i) => {
6193
6408
  const s = new Error("Cannot load book at " + t);
6194
- this.emit(f.BOOK.OPEN_FAILED, s);
6409
+ this.emit(g.BOOK.OPEN_FAILED, s);
6195
6410
  });
6196
6411
  }
6197
6412
  /**
@@ -6300,11 +6515,11 @@ class Rt {
6300
6515
  * @param {Packaging} packaging object
6301
6516
  */
6302
6517
  unpack(t) {
6303
- this.package = t, this.packaging.metadata.layout === "" ? this.load(this.url.resolve(Ge)).then((i) => {
6518
+ this.package = t, this.packaging.metadata.layout === "" ? this.load(this.url.resolve(Je)).then((i) => {
6304
6519
  this.displayOptions = new ut(i), this.loading.displayOptions.resolve(this.displayOptions);
6305
6520
  }).catch((i) => {
6306
6521
  this.displayOptions = new ut(), this.loading.displayOptions.resolve(this.displayOptions);
6307
- }) : (this.displayOptions = new ut(), this.loading.displayOptions.resolve(this.displayOptions)), this.spine.unpack(this.packaging, (i, s) => this.resolve(i, s), (i) => this.canonical(i)), this.resources = new _e(this.packaging.manifest, {
6522
+ }) : (this.displayOptions = new ut(), this.loading.displayOptions.resolve(this.displayOptions)), this.spine.unpack(this.packaging, (i, s) => this.resolve(i, s), (i) => this.canonical(i)), this.resources = new Ce(this.packaging.manifest, {
6308
6523
  archive: this.archive,
6309
6524
  resolver: (i, s) => this.resolve(i, s),
6310
6525
  request: (i, s) => this.request(i, s),
@@ -6370,7 +6585,7 @@ class Rt {
6370
6585
  * @return {Archive}
6371
6586
  */
6372
6587
  unarchive(t, e) {
6373
- return this.archive = new He(), this.archive.open(t, e === "base64");
6588
+ return this.archive = new $e(), this.archive.open(t, e === "base64");
6374
6589
  }
6375
6590
  /**
6376
6591
  * Store the epubs contents
@@ -6381,7 +6596,7 @@ class Rt {
6381
6596
  */
6382
6597
  store(t) {
6383
6598
  const e = this.settings.replacements && this.settings.replacements !== "none" ? this.settings.replacements : void 0, i = this.url, s = this.settings.requestMethod || ((n, r) => Y(n, r));
6384
- return this.storage = new te(t, s, (n, r) => this.resolve(n, r)), this.request = (n, r) => this.storage.request(n, r), this.opened.then(() => {
6599
+ return this.storage = new ee(t, s, (n, r) => this.resolve(n, r)), this.request = (n, r) => this.storage.request(n, r), this.opened.then(() => {
6385
6600
  this.archived && (this.storage.requester = (r, o) => this.archive.request(r, o));
6386
6601
  const n = (r, o) => {
6387
6602
  o.output = this.resources.substitute(r, o.url);
@@ -6451,27 +6666,28 @@ X.Book = Rt;
6451
6666
  X.Rendition = Lt;
6452
6667
  X.Contents = Nt;
6453
6668
  X.CFI = y;
6454
- X.utils = ae;
6669
+ X.utils = le;
6455
6670
  export {
6456
- Te as Annotations,
6457
- He as Archive,
6671
+ ke as Annotations,
6672
+ $e as Archive,
6458
6673
  Rt as Book,
6674
+ be as Container,
6459
6675
  Nt as Contents,
6460
6676
  ut as DisplayOptions,
6461
6677
  y as EpubCFI,
6462
6678
  q as EpubError,
6463
- Kt as Layout,
6464
- $t as Locations,
6679
+ Zt as Layout,
6680
+ Kt as Locations,
6465
6681
  wt as Mapping,
6466
6682
  ht as Navigation,
6467
6683
  It as Packaging,
6468
6684
  lt as PageList,
6469
6685
  Lt as Rendition,
6470
- _e as Resources,
6471
- ye as Section,
6472
- we as Spine,
6473
- te as Store,
6474
- Ce as Themes,
6686
+ Ce as Resources,
6687
+ we as Section,
6688
+ xe as Spine,
6689
+ ee as Store,
6690
+ Te as Themes,
6475
6691
  X as default
6476
6692
  };
6477
6693
  //# sourceMappingURL=epub.js.map