@likecoin/epub-ts 0.4.8 → 0.5.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.node.js CHANGED
@@ -1,7 +1,7 @@
1
- import { DOMParser as qt, parseHTML as Ut } from "linkedom";
2
- import jt from "jszip";
3
- function A(l) {
4
- const t = typeof l == "function" ? l.prototype : l;
1
+ import { DOMParser as Ut, parseHTML as jt } from "linkedom";
2
+ import Ft from "jszip";
3
+ function A(a) {
4
+ const t = typeof a == "function" ? a.prototype : a;
5
5
  return t.on = function(e, i) {
6
6
  return this.__listeners || (this.__listeners = {}), this.__listeners[e] || (this.__listeners[e] = []), this.__listeners[e].push(i), this;
7
7
  }, t.off = function(e, i) {
@@ -13,70 +13,61 @@ function A(l) {
13
13
  const s = this.__listeners[e].slice();
14
14
  for (let n = 0; n < s.length; n++)
15
15
  s[n](...i);
16
- }, l;
16
+ }, a;
17
17
  }
18
- const Tt = typeof window < "u" ? window.requestAnimationFrame.bind(window) : !1, Ft = 1, Lt = typeof URL < "u" ? URL : typeof window < "u" ? window.URL : void 0;
19
- function gt() {
20
- let l = (/* @__PURE__ */ new Date()).getTime();
18
+ const _t = (a) => (Promise.resolve().then(() => a(performance.now())), 0), Vt = typeof window < "u" ? window.requestAnimationFrame.bind(window) : _t, Ht = 1, Tt = typeof URL < "u" ? URL : typeof window < "u" ? window.URL : void 0;
19
+ function kt() {
20
+ let a = (/* @__PURE__ */ new Date()).getTime();
21
21
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
22
- const i = (l + Math.random() * 16) % 16 | 0;
23
- return l = Math.floor(l / 16), (e == "x" ? i : i & 7 | 8).toString(16);
22
+ const i = (a + Math.random() * 16) % 16 | 0;
23
+ return a = Math.floor(a / 16), (e === "x" ? i : i & 7 | 8).toString(16);
24
24
  });
25
25
  }
26
- function Vt(l) {
27
- return !!(l && l.nodeType == 1);
26
+ function Xt(a) {
27
+ return !!(a && a.nodeType === 1);
28
28
  }
29
- function S(l) {
30
- return !isNaN(parseFloat(l)) && isFinite(l);
29
+ function E(a) {
30
+ return !isNaN(parseFloat(a)) && isFinite(a);
31
31
  }
32
- function Ht(l) {
33
- const t = parseFloat(l);
34
- return S(l) === !1 ? !1 : typeof l == "string" && l.indexOf(".") > -1 ? !0 : Math.floor(t) !== t;
32
+ function Yt(a) {
33
+ const t = parseFloat(a);
34
+ return E(a) === !1 ? !1 : typeof a == "string" && a.indexOf(".") > -1 ? !0 : Math.floor(t) !== t;
35
35
  }
36
- function j(l) {
37
- const t = ["Webkit", "webkit", "Moz", "O", "ms"], e = ["-webkit-", "-webkit-", "-moz-", "-o-", "-ms-"], i = l.toLowerCase(), s = t.length;
38
- if (typeof document > "u" || i in document.body.style)
39
- return l;
40
- for (let n = 0; n < s; n++)
41
- if (e[n] + i in document.body.style)
42
- return e[n] + i;
43
- return l;
44
- }
45
- function Xt(l, ...t) {
36
+ function Gt(a, ...t) {
46
37
  for (let e = 0; e < t.length; e++) {
47
38
  const i = t[e];
48
39
  for (const s in i)
49
- l[s] === void 0 && (l[s] = i[s]);
40
+ a[s] === void 0 && (a[s] = i[s]);
50
41
  }
51
- return l;
42
+ return a;
52
43
  }
53
- function _(l, ...t) {
44
+ function _(a, ...t) {
54
45
  return t.forEach(function(e) {
55
46
  e && Object.getOwnPropertyNames(e).forEach(function(i) {
56
- Object.defineProperty(l, i, Object.getOwnPropertyDescriptor(e, i));
47
+ Object.defineProperty(a, i, Object.getOwnPropertyDescriptor(e, i));
57
48
  });
58
- }), l;
49
+ }), a;
59
50
  }
60
- function $(l, t, e, i, s) {
51
+ function $(a, t, e, i, s) {
61
52
  const n = i || 0, r = s || t.length, o = Math.floor(n + (r - n) / 2);
62
- if (e || (e = function(a, c) {
63
- return a > c ? 1 : a < c ? -1 : 0;
53
+ if (e || (e = function(l, c) {
54
+ return l > c ? 1 : l < c ? -1 : 0;
64
55
  }), r - n <= 0)
65
56
  return o;
66
- const h = e(t[o], l);
67
- return r - n === 1 ? h >= 0 ? o : o + 1 : h === 0 ? o : h === -1 ? $(l, t, e, o, r) : $(l, t, e, n, o);
57
+ const h = e(t[o], a);
58
+ return r - n === 1 ? h >= 0 ? o : o + 1 : h === 0 ? o : h === -1 ? $(a, t, e, o, r) : $(a, t, e, n, o);
68
59
  }
69
- function ot(l, t, e, i, s) {
60
+ function ot(a, t, e, i, s) {
70
61
  const n = i || 0, r = s || t.length, o = Math.floor(n + (r - n) / 2);
71
- if (e || (e = function(a, c) {
72
- return a > c ? 1 : a < c ? -1 : 0;
62
+ if (e || (e = function(l, c) {
63
+ return l > c ? 1 : l < c ? -1 : 0;
73
64
  }), r - n <= 0)
74
65
  return -1;
75
- const h = e(t[o], l);
76
- return r - n === 1 ? h === 0 ? o : -1 : h === 0 ? o : h === -1 ? ot(l, t, e, o, r) : ot(l, t, e, n, o);
66
+ const h = e(t[o], a);
67
+ return r - n === 1 ? h === 0 ? o : -1 : h === 0 ? o : h === -1 ? ot(a, t, e, o, r) : ot(a, t, e, n, o);
77
68
  }
78
- function tt(l) {
79
- const t = window.getComputedStyle(l), 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"];
69
+ function J(a) {
70
+ 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"];
80
71
  let s = 0, n = 0;
81
72
  return e.forEach(function(r) {
82
73
  s += parseFloat(t.getPropertyValue(r)) || 0;
@@ -87,8 +78,8 @@ function tt(l) {
87
78
  width: s
88
79
  };
89
80
  }
90
- function ht(l) {
91
- const t = window.getComputedStyle(l), 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"];
81
+ function ht(a) {
82
+ 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"];
92
83
  let s = 0, n = 0;
93
84
  return e.forEach(function(r) {
94
85
  s += parseFloat(t.getPropertyValue(r)) || 0;
@@ -99,136 +90,144 @@ function ht(l) {
99
90
  width: s
100
91
  };
101
92
  }
102
- function vt(l) {
93
+ function gt(a) {
103
94
  let t;
104
- const e = l.ownerDocument;
105
- if (l.nodeType == Node.TEXT_NODE) {
95
+ const e = a.ownerDocument;
96
+ if (a.nodeType === Node.TEXT_NODE) {
106
97
  const i = e.createRange();
107
- i.selectNodeContents(l), t = i.getBoundingClientRect();
98
+ i.selectNodeContents(a), t = i.getBoundingClientRect();
108
99
  } else
109
- t = l.getBoundingClientRect();
100
+ t = a.getBoundingClientRect();
110
101
  return t;
111
102
  }
112
- function lt() {
113
- const l = window.innerWidth, t = window.innerHeight;
103
+ function mt() {
104
+ const a = window.innerWidth, t = window.innerHeight;
114
105
  return {
115
106
  top: 0,
116
107
  left: 0,
117
- right: l,
108
+ right: a,
118
109
  bottom: t,
119
- width: l,
110
+ width: a,
120
111
  height: t
121
112
  };
122
113
  }
123
- function Yt(l, t) {
124
- const i = l.parentNode.childNodes;
114
+ function $t(a, t) {
115
+ const i = a.parentNode.childNodes;
125
116
  let s, n = -1;
126
- for (let r = 0; r < i.length && (s = i[r], s.nodeType === t && n++, s != l); r++)
117
+ for (let r = 0; r < i.length && (s = i[r], s.nodeType === t && n++, s !== a); r++)
127
118
  ;
128
119
  return n;
129
120
  }
130
- function Gt(l) {
131
- return Yt(l, Ft);
121
+ function Kt(a) {
122
+ return $t(a, Ht);
123
+ }
124
+ function Lt(a) {
125
+ return ["xml", "opf", "ncx"].indexOf(a) > -1;
132
126
  }
133
- function K(l) {
134
- return ["xml", "opf", "ncx"].indexOf(l) > -1;
127
+ function Nt(a, t) {
128
+ return t === "json" ? JSON.parse(a) : t && Lt(t) ? W(a, "text/xml") : t === "xhtml" ? W(a, "application/xhtml+xml") : t === "html" || t === "htm" ? W(a, "text/html") : a;
135
129
  }
136
- function $t(l, t) {
137
- return new Blob([l], { type: t });
130
+ class q extends Error {
131
+ constructor(t, e) {
132
+ super(t), this.name = "EpubError", this.status = e;
133
+ }
138
134
  }
139
- function at(l, t) {
140
- const e = $t(l, t);
141
- return Lt.createObjectURL(e);
135
+ function Zt(a, t) {
136
+ return new Blob([a], { type: t });
142
137
  }
143
- function kt(l) {
144
- return Lt.revokeObjectURL(l);
138
+ function at(a, t) {
139
+ const e = Zt(a, t);
140
+ return Tt.createObjectURL(e);
145
141
  }
146
- function yt(l, t) {
147
- if (typeof l != "string")
142
+ function Rt(a) {
143
+ return Tt.revokeObjectURL(a);
144
+ }
145
+ function vt(a, t) {
146
+ if (typeof a != "string")
148
147
  return;
149
- const e = btoa(l);
148
+ const e = btoa(a);
150
149
  return "data:" + t + ";base64," + e;
151
150
  }
152
- function Kt(l) {
153
- return Object.prototype.toString.call(l).slice(8, -1);
151
+ function Qt(a) {
152
+ return Object.prototype.toString.call(a).slice(8, -1);
154
153
  }
155
- function O(l, t) {
156
- return l.charCodeAt(0) === 65279 && (l = l.slice(1)), new DOMParser().parseFromString(l, t);
154
+ function W(a, t) {
155
+ return a.charCodeAt(0) === 65279 && (a = a.slice(1)), new DOMParser().parseFromString(a, t);
157
156
  }
158
- function b(l, t) {
159
- if (!l)
157
+ function w(a, t) {
158
+ if (!a)
160
159
  throw new Error("No Element Provided");
161
- return l.querySelector(t);
160
+ return a.querySelector(t);
162
161
  }
163
- function M(l, t) {
164
- return l.querySelectorAll(t);
162
+ function B(a, t) {
163
+ return a.querySelectorAll(t);
165
164
  }
166
- function F(l, t, e) {
165
+ function j(a, t, e) {
167
166
  t += "[";
168
167
  for (const i in e)
169
168
  t += i + "~='" + e[i] + "'";
170
- return t += "]", l.querySelector(t) ?? void 0;
169
+ return t += "]", a.querySelector(t) ?? void 0;
171
170
  }
172
- function ct(l, t) {
173
- Zt(l, t, NodeFilter.SHOW_TEXT);
171
+ function lt(a, t) {
172
+ Jt(a, t, NodeFilter.SHOW_TEXT);
174
173
  }
175
- function Zt(l, t, e) {
176
- const i = document.createTreeWalker(l, e, null);
174
+ function Jt(a, t, e) {
175
+ const i = document.createTreeWalker(a, e, null);
177
176
  let s;
178
177
  for (; s = i.nextNode(); )
179
178
  t(s);
180
179
  }
181
- function Qt(l) {
180
+ function te(a) {
182
181
  return new Promise(function(t, e) {
183
182
  const i = new FileReader();
184
- i.readAsDataURL(l), i.onloadend = function() {
183
+ i.readAsDataURL(a), i.onloadend = function() {
185
184
  t(i.result);
186
185
  };
187
186
  });
188
187
  }
189
- class v {
188
+ class S {
190
189
  constructor() {
191
- this.id = gt(), this.promise = new Promise((t, e) => {
190
+ this.promise = new Promise((t, e) => {
192
191
  this.resolve = t, this.reject = e;
193
- }), Object.freeze(this);
192
+ });
194
193
  }
195
194
  }
196
- function dt(l, t, e) {
195
+ function ct(a, t, e) {
197
196
  let i = null;
198
197
  try {
199
- i = l.querySelector(`${t}[*|type="${e}"]`);
198
+ i = a.querySelector(`${t}[*|type="${e}"]`);
200
199
  } catch {
201
200
  }
202
201
  if (i)
203
202
  return i;
204
- const s = l.querySelectorAll(t);
203
+ const s = a.querySelectorAll(t);
205
204
  for (let n = 0; n < s.length; n++)
206
205
  if (s[n].getAttributeNS("http://www.idpf.org/2007/ops", "type") === e || s[n].getAttribute("epub:type") === e)
207
206
  return s[n];
208
207
  }
209
- function wt(l) {
210
- const t = [], e = l.childNodes;
208
+ function yt(a) {
209
+ const t = [], e = a.childNodes;
211
210
  for (let i = 0; i < e.length; i++) {
212
211
  const s = e[i];
213
212
  s.nodeType === 1 && t.push(s);
214
213
  }
215
214
  return t;
216
215
  }
217
- function bt(l) {
216
+ function wt(a) {
218
217
  const t = [];
219
- for (let e = l ?? null; e; e = e.parentNode)
218
+ for (let e = a ?? null; e; e = e.parentNode)
220
219
  t.unshift(e);
221
220
  return t;
222
221
  }
223
- function V(l, t, e) {
224
- const i = l.childNodes;
222
+ function F(a, t, e) {
223
+ const i = a.childNodes;
225
224
  for (let s = 0; s < i.length; s++) {
226
225
  const n = i[s];
227
226
  if (n.nodeType === 1 && n.nodeName.toLowerCase() === t)
228
227
  return n;
229
228
  }
230
229
  }
231
- class Jt {
230
+ class ee {
232
231
  constructor() {
233
232
  this.collapsed = !1, this.commonAncestorContainer = void 0, this.endContainer = void 0, this.endOffset = void 0, this.startContainer = void 0, this.startOffset = void 0;
234
233
  }
@@ -250,10 +249,10 @@ class Jt {
250
249
  this.setStart(t, 0), this.setEnd(t, e);
251
250
  }
252
251
  _commonAncestorContainer(t, e) {
253
- const i = bt(t ?? this.startContainer), s = bt(e ?? this.endContainer);
254
- if (i[0] == s[0]) {
252
+ const i = wt(t ?? this.startContainer), s = wt(e ?? this.endContainer);
253
+ if (i[0] === s[0]) {
255
254
  for (let n = 0; n < i.length; n++)
256
- if (i[n] != s[n])
255
+ if (i[n] !== s[n])
257
256
  return i[n - 1];
258
257
  }
259
258
  }
@@ -264,15 +263,15 @@ class Jt {
264
263
  return "";
265
264
  }
266
265
  }
267
- function U(l) {
268
- if (typeof l != "string")
269
- throw new TypeError("Path must be a string. Received " + l);
266
+ function U(a) {
267
+ if (typeof a != "string")
268
+ throw new TypeError("Path must be a string. Received " + a);
270
269
  }
271
- function te(l, t) {
270
+ function ie(a, t) {
272
271
  let e = "", i = -1, s = 0, n;
273
- for (let r = 0; r <= l.length; ++r) {
274
- if (r < l.length)
275
- n = l.charCodeAt(r);
272
+ for (let r = 0; r <= a.length; ++r) {
273
+ if (r < a.length)
274
+ n = a.charCodeAt(r);
276
275
  else {
277
276
  if (n === 47)
278
277
  break;
@@ -297,32 +296,32 @@ function te(l, t) {
297
296
  }
298
297
  t && (e.length > 0 ? e += "/.." : e = "..");
299
298
  } else
300
- e.length > 0 ? e += "/" + l.slice(i + 1, r) : e = l.slice(i + 1, r);
299
+ e.length > 0 ? e += "/" + a.slice(i + 1, r) : e = a.slice(i + 1, r);
301
300
  i = r, s = 0;
302
301
  } else n === 46 && s !== -1 ? ++s : s = -1;
303
302
  }
304
303
  return e;
305
304
  }
306
- function ut(...l) {
305
+ function dt(...a) {
307
306
  let t = "", e = !1;
308
- for (let i = l.length - 1; i >= -1 && !e; i--) {
309
- const s = i >= 0 ? l[i] : "/";
307
+ for (let i = a.length - 1; i >= -1 && !e; i--) {
308
+ const s = i >= 0 ? a[i] : "/";
310
309
  U(s), s.length !== 0 && (t = s + "/" + t, e = s.charCodeAt(0) === 47);
311
310
  }
312
- return t = te(t, !e), e ? t.length > 0 ? "/" + t : "/" : t.length > 0 ? t : ".";
311
+ return t = ie(t, !e), e ? t.length > 0 ? "/" + t : "/" : t.length > 0 ? t : ".";
313
312
  }
314
- function ee(l, t) {
315
- if (U(l), U(t), l === t || (l = ut(l), t = ut(t), l === t))
313
+ function se(a, t) {
314
+ if (U(a), U(t), a === t || (a = dt(a), t = dt(t), a === t))
316
315
  return "";
317
316
  let e = 1;
318
- for (; e < l.length && l.charCodeAt(e) === 47; ++e)
317
+ for (; e < a.length && a.charCodeAt(e) === 47; ++e)
319
318
  ;
320
- const i = l.length, s = i - e;
319
+ const i = a.length, s = i - e;
321
320
  let n = 1;
322
321
  for (; n < t.length && t.charCodeAt(n) === 47; ++n)
323
322
  ;
324
323
  const o = t.length - n, h = s < o ? s : o;
325
- let a = -1, c = 0;
324
+ let l = -1, c = 0;
326
325
  for (; c <= h; ++c) {
327
326
  if (c === h) {
328
327
  if (o > h) {
@@ -330,61 +329,61 @@ function ee(l, t) {
330
329
  return t.slice(n + c + 1);
331
330
  if (c === 0)
332
331
  return t.slice(n + c);
333
- } else s > h && (l.charCodeAt(e + c) === 47 ? a = c : c === 0 && (a = 0));
332
+ } else s > h && (a.charCodeAt(e + c) === 47 ? l = c : c === 0 && (l = 0));
334
333
  break;
335
334
  }
336
- const f = l.charCodeAt(e + c), p = t.charCodeAt(n + c);
335
+ const f = a.charCodeAt(e + c), p = t.charCodeAt(n + c);
337
336
  if (f !== p)
338
337
  break;
339
- f === 47 && (a = c);
338
+ f === 47 && (l = c);
340
339
  }
341
340
  let d = "";
342
- for (c = e + a + 1; c <= i; ++c)
343
- (c === i || l.charCodeAt(c) === 47) && (d.length === 0 ? d += ".." : d += "/..");
344
- return d.length > 0 ? d + t.slice(n + a) : (n += a, t.charCodeAt(n) === 47 && ++n, t.slice(n));
341
+ for (c = e + l + 1; c <= i; ++c)
342
+ (c === i || a.charCodeAt(c) === 47) && (d.length === 0 ? d += ".." : d += "/..");
343
+ return d.length > 0 ? d + t.slice(n + l) : (n += l, t.charCodeAt(n) === 47 && ++n, t.slice(n));
345
344
  }
346
- function ie(l) {
347
- if (U(l), l.length === 0)
345
+ function ne(a) {
346
+ if (U(a), a.length === 0)
348
347
  return ".";
349
- let t = l.charCodeAt(0);
348
+ let t = a.charCodeAt(0);
350
349
  const e = t === 47;
351
350
  let i = -1, s = !0;
352
- for (let n = l.length - 1; n >= 1; --n)
353
- if (t = l.charCodeAt(n), t === 47) {
351
+ for (let n = a.length - 1; n >= 1; --n)
352
+ if (t = a.charCodeAt(n), t === 47) {
354
353
  if (!s) {
355
354
  i = n;
356
355
  break;
357
356
  }
358
357
  } else
359
358
  s = !1;
360
- return i === -1 ? e ? "/" : "." : e && i === 1 ? "//" : l.slice(0, i);
359
+ return i === -1 ? e ? "/" : "." : e && i === 1 ? "//" : a.slice(0, i);
361
360
  }
362
- function se(l) {
363
- return U(l), l.length > 0 && l.charCodeAt(0) === 47;
361
+ function re(a) {
362
+ return U(a), a.length > 0 && a.charCodeAt(0) === 47;
364
363
  }
365
- function ne(l) {
366
- U(l);
364
+ function oe(a) {
365
+ U(a);
367
366
  const t = { root: "", dir: "", base: "", ext: "", name: "" };
368
- if (l.length === 0)
367
+ if (a.length === 0)
369
368
  return t;
370
- let e = l.charCodeAt(0);
369
+ let e = a.charCodeAt(0);
371
370
  const i = e === 47;
372
371
  let s;
373
372
  i ? (t.root = "/", s = 1) : s = 0;
374
- let n = -1, r = 0, o = -1, h = !0, a = l.length - 1, c = 0;
375
- for (; a >= s; --a) {
376
- if (e = l.charCodeAt(a), e === 47) {
373
+ let n = -1, r = 0, o = -1, h = !0, l = a.length - 1, c = 0;
374
+ for (; l >= s; --l) {
375
+ if (e = a.charCodeAt(l), e === 47) {
377
376
  if (!h) {
378
- r = a + 1;
377
+ r = l + 1;
379
378
  break;
380
379
  }
381
380
  continue;
382
381
  }
383
- o === -1 && (h = !1, o = a + 1), e === 46 ? n === -1 ? n = a : c !== 1 && (c = 1) : n !== -1 && (c = -1);
382
+ o === -1 && (h = !1, o = l + 1), e === 46 ? n === -1 ? n = l : c !== 1 && (c = 1) : n !== -1 && (c = -1);
384
383
  }
385
- return n === -1 || o === -1 || c === 0 || c === 1 && n === o - 1 && n === r + 1 ? o !== -1 && (r === 0 && i ? t.base = t.name = l.slice(1, o) : t.base = t.name = l.slice(r, o)) : (r === 0 && i ? (t.name = l.slice(1, n), t.base = l.slice(1, o)) : (t.name = l.slice(r, n), t.base = l.slice(r, o)), t.ext = l.slice(n, o)), r > 0 ? t.dir = l.slice(0, r - 1) : i && (t.dir = "/"), t;
384
+ 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;
386
385
  }
387
- const D = { resolve: ut, relative: ee, dirname: ie, isAbsolute: se, parse: ne };
386
+ const z = { resolve: dt, relative: se, dirname: ne, isAbsolute: re, parse: oe };
388
387
  class P {
389
388
  constructor(t) {
390
389
  t.indexOf("://") > -1 && (t = new URL(t).pathname);
@@ -397,14 +396,14 @@ class P {
397
396
  * @returns {object}
398
397
  */
399
398
  parse(t) {
400
- return D.parse(t);
399
+ return z.parse(t);
401
400
  }
402
401
  /**
403
402
  * @param {string} what
404
403
  * @returns {boolean}
405
404
  */
406
405
  isAbsolute(t) {
407
- return D.isAbsolute(t || this.path);
406
+ return z.isAbsolute(t || this.path);
408
407
  }
409
408
  /**
410
409
  * Check if path ends with a directory
@@ -422,7 +421,7 @@ class P {
422
421
  * @returns {string} resolved
423
422
  */
424
423
  resolve(t) {
425
- return D.resolve(this.directory, t);
424
+ return z.resolve(this.directory, t);
426
425
  }
427
426
  /**
428
427
  * Resolve a path relative to the directory of the Path
@@ -432,7 +431,7 @@ class P {
432
431
  * @returns {string} relative
433
432
  */
434
433
  relative(t) {
435
- return t && t.indexOf("://") > -1 ? t : D.relative(this.directory, t);
434
+ return t && t.indexOf("://") > -1 ? t : z.relative(this.directory, t);
436
435
  }
437
436
  /**
438
437
  * Return the path string
@@ -442,7 +441,7 @@ class P {
442
441
  return this.path;
443
442
  }
444
443
  }
445
- class R {
444
+ class N {
446
445
  constructor(t, e) {
447
446
  const i = t.indexOf("://") > -1;
448
447
  let s = t, n;
@@ -468,7 +467,7 @@ class R {
468
467
  resolve(t) {
469
468
  if (t.indexOf("://") > -1)
470
469
  return t;
471
- const i = D.resolve(this.directory, t);
470
+ const i = z.resolve(this.directory, t);
472
471
  return this.origin + i;
473
472
  }
474
473
  /**
@@ -477,7 +476,7 @@ class R {
477
476
  * @returns {string} path
478
477
  */
479
478
  relative(t) {
480
- return D.relative(t, this.directory);
479
+ return z.relative(t, this.directory);
481
480
  }
482
481
  /**
483
482
  * @returns {string}
@@ -486,7 +485,7 @@ class R {
486
485
  return this.href;
487
486
  }
488
487
  }
489
- const W = 1, L = 3, re = 9;
488
+ const M = 1, k = 3, he = 9;
490
489
  class m {
491
490
  constructor(t, e, i) {
492
491
  if (this.str = "", this.base = {}, this.spinePos = 0, this.range = !1, this.path = {}, this.start = null, this.end = null, !(this instanceof m))
@@ -510,7 +509,7 @@ class m {
510
509
  * @private
511
510
  */
512
511
  checkType(t) {
513
- return this.isCfiString(t) ? "string" : t && typeof t == "object" && (Kt(t) === "Range" || typeof t.startContainer < "u") ? "range" : t && typeof t == "object" && typeof t.nodeType < "u" ? "node" : t && typeof t == "object" && t instanceof m ? "EpubCFI" : !1;
512
+ return this.isCfiString(t) ? "string" : t && typeof t == "object" && (Qt(t) === "Range" || typeof t.startContainer < "u") ? "range" : t && typeof t == "object" && typeof t.nodeType < "u" ? "node" : t && typeof t == "object" && t instanceof m ? "EpubCFI" : !1;
514
513
  }
515
514
  /**
516
515
  * Parse a cfi string to a CFI object representation
@@ -565,7 +564,7 @@ class m {
565
564
  parseTerminal(t) {
566
565
  let e, i = null;
567
566
  const s = t.match(/\[(.*)\]/);
568
- return s && s[1] ? (e = parseInt(t.split("[")[0]), i = s[1]) : e = parseInt(t), S(e) || (e = null), {
567
+ return s && s[1] ? (e = parseInt(t.split("[")[0]), i = s[1]) : e = parseInt(t), E(e) || (e = null), {
569
568
  offset: e,
570
569
  assertion: i
571
570
  };
@@ -617,12 +616,12 @@ class m {
617
616
  if (t.spinePos < e.spinePos)
618
617
  return -1;
619
618
  t.range ? (i = t.path.steps.concat(t.start.steps), n = t.start.terminal) : (i = t.path.steps, n = t.path.terminal), e.range ? (s = e.path.steps.concat(e.start.steps), r = e.start.terminal) : (s = e.path.steps, r = e.path.terminal);
620
- for (let a = 0; a < i.length; a++) {
621
- if (!i[a])
619
+ for (let l = 0; l < i.length; l++) {
620
+ if (!i[l])
622
621
  return -1;
623
- if (!s[a] || i[a].index > s[a].index)
622
+ if (!s[l] || i[l].index > s[l].index)
624
623
  return 1;
625
- if (i[a].index < s[a].index)
624
+ if (i[l].index < s[l].index)
626
625
  return -1;
627
626
  }
628
627
  if (i.length < s.length)
@@ -631,7 +630,7 @@ class m {
631
630
  return o > h ? 1 : o < h ? -1 : 0;
632
631
  }
633
632
  step(t) {
634
- const e = t.nodeType === L ? "text" : "element";
633
+ const e = t.nodeType === k ? "text" : "element";
635
634
  return {
636
635
  id: t.id,
637
636
  tagName: t.tagName,
@@ -643,7 +642,7 @@ class m {
643
642
  const i = this.filter(t, e);
644
643
  if (!i)
645
644
  return;
646
- const s = i.nodeType === L ? "text" : "element";
645
+ const s = i.nodeType === k ? "text" : "element";
647
646
  return {
648
647
  id: i.id,
649
648
  tagName: i.tagName,
@@ -660,9 +659,9 @@ class m {
660
659
  }
661
660
  };
662
661
  let n = t, r;
663
- for (; n && n.parentNode && n.parentNode.nodeType != re; )
662
+ for (; n && n.parentNode && n.parentNode.nodeType !== he; )
664
663
  i ? r = this.filteredStep(n, i) : r = this.step(n), r && s.steps.unshift(r), n = n.parentNode;
665
- return e != null && e >= 0 && (s.terminal.offset = e, s.steps.length > 0 && s.steps[s.steps.length - 1].type != "text" && s.steps.push({
664
+ return e != null && e >= 0 && (s.terminal.offset = e, s.steps.length > 0 && s.steps[s.steps.length - 1].type !== "text" && s.steps.push({
666
665
  type: "text",
667
666
  index: 0,
668
667
  id: null,
@@ -688,11 +687,11 @@ class m {
688
687
  end: null,
689
688
  spinePos: 0
690
689
  }, n = t.startContainer, r = t.endContainer;
691
- let o = t.startOffset, h = t.endOffset, a = !1;
692
- if (i && (a = n.ownerDocument.querySelector("." + i) != null), typeof e == "string" ? (s.base = this.parseComponent(e), s.spinePos = s.base.steps[1].index) : typeof e == "object" && (s.base = e), t.collapsed)
693
- a && (o = this.patchOffset(n, o, i)), s.path = this.pathTo(n, o, i);
690
+ let o = t.startOffset, h = t.endOffset, l = !1;
691
+ if (i && (l = n.ownerDocument.querySelector("." + i) != null), typeof e == "string" ? (s.base = this.parseComponent(e), s.spinePos = s.base.steps[1].index) : typeof e == "object" && (s.base = e), t.collapsed)
692
+ l && (o = this.patchOffset(n, o, i)), s.path = this.pathTo(n, o, i);
694
693
  else {
695
- s.range = !0, a && (o = this.patchOffset(n, o, i)), s.start = this.pathTo(n, o, i), a && (h = this.patchOffset(r, h, i)), s.end = this.pathTo(r, h, i), s.path = {
694
+ s.range = !0, l && (o = this.patchOffset(n, o, i)), s.start = this.pathTo(n, o, i), l && (h = this.patchOffset(r, h, i)), s.end = this.pathTo(r, h, i), s.path = {
696
695
  steps: [],
697
696
  terminal: { offset: null, assertion: null }
698
697
  };
@@ -724,14 +723,14 @@ class m {
724
723
  }
725
724
  filter(t, e) {
726
725
  let i, s, n, r, o, h = !1;
727
- return t.nodeType === L ? (h = !0, n = t.parentNode, i = t.parentNode.classList.contains(e)) : (h = !1, i = t.classList.contains(e)), i && h ? (r = n.previousSibling, o = n.nextSibling, r && r.nodeType === L ? s = r : o && o.nodeType === L && (s = o), s || t) : i && !h ? !1 : t;
726
+ return t.nodeType === k ? (h = !0, n = t.parentNode, i = t.parentNode.classList.contains(e)) : (h = !1, i = t.classList.contains(e)), i && h ? (r = n.previousSibling, o = n.nextSibling, r && r.nodeType === k ? s = r : o && o.nodeType === k && (s = o), s || t) : i && !h ? !1 : t;
728
727
  }
729
728
  patchOffset(t, e, i) {
730
- if (t.nodeType != L)
729
+ if (t.nodeType !== k)
731
730
  throw new Error("Anchor must be a text node");
732
731
  let s = t, n = e;
733
732
  for (t.parentNode.classList.contains(i) && (s = t.parentNode); s.previousSibling; ) {
734
- if (s.previousSibling.nodeType === W)
733
+ if (s.previousSibling.nodeType === M)
735
734
  if (s.previousSibling.classList.contains(i))
736
735
  n += (s.previousSibling.textContent ?? "").length;
737
736
  else
@@ -746,18 +745,18 @@ class m {
746
745
  const s = {};
747
746
  let n = -1, r;
748
747
  const o = t.length;
749
- let h, a;
748
+ let h, l;
750
749
  for (r = 0; r < o; r++)
751
- h = t[r].nodeType, h === W && t[r].classList.contains(i) && (h = L), r > 0 && h === L && a === L ? s[r] = n : e === h && (n = n + 1, s[r] = n), a = h;
750
+ h = t[r].nodeType, h === M && t[r].classList.contains(i) && (h = k), r > 0 && h === k && l === k ? s[r] = n : e === h && (n = n + 1, s[r] = n), l = h;
752
751
  return s;
753
752
  }
754
753
  position(t) {
755
754
  let e, i;
756
- return t.nodeType === W ? (e = t.parentNode.children, e || (e = wt(t.parentNode)), i = Array.from(e).indexOf(t)) : (e = this.textNodes(t.parentNode), i = e.indexOf(t)), i;
755
+ return t.nodeType === M ? (e = t.parentNode.children, e || (e = yt(t.parentNode)), i = Array.from(e).indexOf(t)) : (e = this.textNodes(t.parentNode), i = e.indexOf(t)), i;
757
756
  }
758
757
  filteredPosition(t, e) {
759
758
  let i, s;
760
- t.nodeType === W ? (i = t.parentNode.children, s = this.normalizedMap(i, W, e)) : (i = t.parentNode.childNodes, t.parentNode.classList.contains(e) && (t = t.parentNode, i = t.parentNode.childNodes), s = this.normalizedMap(i, L, e));
759
+ t.nodeType === M ? (i = t.parentNode.children, s = this.normalizedMap(i, M, e)) : (i = t.parentNode.childNodes, t.parentNode.classList.contains(e) && (t = t.parentNode, i = t.parentNode.childNodes), s = this.normalizedMap(i, k, e));
761
760
  const n = Array.from(i).indexOf(t);
762
761
  return s[n];
763
762
  }
@@ -779,7 +778,7 @@ class m {
779
778
  // Find the containing element
780
779
  startContainerParent = doc.querySelector(query);
781
780
  // Find the text node within that element
782
- if(startContainerParent && lastStep.type == "text") {
781
+ if(startContainerParent && lastStep.type === "text") {
783
782
  container = startContainerParent.childNodes[lastStep.index];
784
783
  }
785
784
  */
@@ -792,15 +791,15 @@ class m {
792
791
  }
793
792
  textNodes(t, e) {
794
793
  return Array.from(t.childNodes).filter(function(i) {
795
- return i.nodeType === L ? !0 : !!(e && i.classList.contains(e));
794
+ return i.nodeType === k ? !0 : !!(e && i.classList.contains(e));
796
795
  });
797
796
  }
798
797
  walkToNode(t, e, i) {
799
798
  const s = e || document;
800
799
  let n = s.documentElement, r, o;
801
800
  const h = t.length;
802
- let a;
803
- for (a = 0; a < h && (o = t[a], o.type === "element" ? o.id ? n = s.getElementById(o.id) : (r = n.children || wt(n), n = r[o.index]) : o.type === "text" && (n = this.textNodes(n, i)[o.index]), !!n); a++)
801
+ let l;
802
+ for (l = 0; l < h && (o = t[l], o.type === "element" ? o.id ? n = s.getElementById(o.id) : (r = n.children || yt(n), n = r[o.index]) : o.type === "text" && (n = this.textNodes(n, i)[o.index]), !!n); l++)
804
803
  ;
805
804
  return n;
806
805
  }
@@ -813,15 +812,15 @@ class m {
813
812
  let n = this.findNode(t.slice(0, -1), i, s);
814
813
  if (!n)
815
814
  return { container: (i ?? document).documentElement, offset: 0 };
816
- const r = n.childNodes, o = this.normalizedMap(r, L, s);
817
- let h, a;
815
+ const r = n.childNodes, o = this.normalizedMap(r, k, s);
816
+ let h, l;
818
817
  const c = t[t.length - 1].index;
819
818
  for (const d in o)
820
819
  if (o.hasOwnProperty(d) && o[d] === c)
821
- if (h = r[d], a = (h.textContent ?? "").length, e > a)
822
- e = e - a;
820
+ if (h = r[d], l = (h.textContent ?? "").length, e > l)
821
+ e = e - l;
823
822
  else {
824
- h.nodeType === W ? n = h.childNodes[0] ?? h : n = h;
823
+ h.nodeType === M ? n = h.childNodes[0] ?? h : n = h;
825
824
  break;
826
825
  }
827
826
  return {
@@ -838,11 +837,11 @@ class m {
838
837
  toRange(t, e) {
839
838
  const i = t || document;
840
839
  let s, n, r, o, h;
841
- const a = this;
840
+ const l = this;
842
841
  let c, d;
843
842
  const f = e ? i.querySelector("." + e) != null : !1;
844
843
  let p;
845
- if (typeof i.createRange < "u" ? s = i.createRange() : s = new Jt(), a.range ? (n = a.start, c = a.path.steps.concat(n.steps), o = this.findNode(c, i, f ? e : void 0), r = a.end, d = a.path.steps.concat(r.steps), h = this.findNode(d, i, f ? e : void 0)) : (n = a.path, c = a.path.steps, o = this.findNode(a.path.steps, i, f ? e : void 0)), o)
844
+ if (typeof i.createRange < "u" ? s = i.createRange() : s = new ee(), l.range ? (n = l.start, c = l.path.steps.concat(n.steps), o = this.findNode(c, i, f ? e : void 0), r = l.end, d = l.path.steps.concat(r.steps), h = this.findNode(d, i, f ? e : void 0)) : (n = l.path, c = l.path.steps, o = this.findNode(l.path.steps, i, f ? e : void 0)), o)
846
845
  try {
847
846
  n.terminal.offset != null ? s.setStart(o, n.terminal.offset) : s.setStart(o, 0);
848
847
  } catch {
@@ -854,7 +853,7 @@ class m {
854
853
  try {
855
854
  r.terminal.offset != null ? s.setEnd(h, r.terminal.offset) : s.setEnd(h, 0);
856
855
  } catch {
857
- p = this.fixMiss(d, a.end.terminal.offset, i, f ? e : void 0), s.setEnd(p.container, p.offset);
856
+ p = this.fixMiss(d, l.end.terminal.offset, i, f ? e : void 0), s.setEnd(p.container, p.offset);
858
857
  }
859
858
  return s;
860
859
  }
@@ -879,7 +878,7 @@ class m {
879
878
  this.range && (this.range = !1, t ? (this.path.steps = this.path.steps.concat(this.start.steps), this.path.terminal = this.start.terminal) : (this.path.steps = this.path.steps.concat(this.end.steps), this.path.terminal = this.end.terminal));
880
879
  }
881
880
  }
882
- class N {
881
+ class R {
883
882
  constructor(t) {
884
883
  this.context = t || this, this.hooks = [];
885
884
  }
@@ -933,35 +932,35 @@ class N {
933
932
  return this.hooks = [];
934
933
  }
935
934
  }
936
- function Rt(l, t) {
935
+ function At(a, t) {
937
936
  let e, i = t.url;
938
937
  const s = i.indexOf("://") > -1;
939
- if (!l)
938
+ if (!a)
940
939
  return;
941
- const n = b(l, "head");
942
- e = b(n, "base"), e || (e = l.createElement("base"), n.insertBefore(e, n.firstChild)), !s && typeof window < "u" && window.location && (i = window.location.origin + i), e.setAttribute("href", i);
940
+ const n = w(a, "head");
941
+ 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);
943
942
  }
944
- function oe(l, t) {
943
+ function ae(a, t) {
945
944
  let e;
946
945
  const i = t.canonical;
947
- if (!l)
946
+ if (!a)
948
947
  return;
949
- const s = b(l, "head");
950
- e = b(s, "link[rel='canonical']"), e ? e.setAttribute("href", i) : (e = l.createElement("link"), e.setAttribute("rel", "canonical"), e.setAttribute("href", i), s.appendChild(e));
948
+ const s = w(a, "head");
949
+ 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));
951
950
  }
952
- function he(l, t) {
951
+ function le(a, t) {
953
952
  let e;
954
953
  const i = t.idref;
955
- if (!l)
954
+ if (!a)
956
955
  return;
957
- const s = b(l, "head");
958
- e = b(s, "link[property='dc.identifier']"), e ? e.setAttribute("content", i) : (e = l.createElement("meta"), e.setAttribute("name", "dc.identifier"), e.setAttribute("content", i), s.appendChild(e));
956
+ const s = w(a, "head");
957
+ 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));
959
958
  }
960
- function le(l, t) {
961
- const e = l.querySelectorAll("a[href]");
959
+ function ce(a, t) {
960
+ const e = a.querySelectorAll("a[href]");
962
961
  if (!e.length)
963
962
  return;
964
- const i = b(l.ownerDocument, "base"), s = i ? i.getAttribute("href") ?? void 0 : void 0, n = function(r) {
963
+ const i = w(a.ownerDocument, "base"), s = i ? i.getAttribute("href") ?? void 0 : void 0, n = function(r) {
965
964
  const o = r.getAttribute("href") ?? "";
966
965
  if (o.indexOf("mailto:") === 0)
967
966
  return;
@@ -975,7 +974,7 @@ function le(l, t) {
975
974
  else {
976
975
  let c;
977
976
  try {
978
- c = new R(o, s);
977
+ c = new N(o, s);
979
978
  } catch {
980
979
  }
981
980
  r.onclick = function() {
@@ -986,99 +985,86 @@ function le(l, t) {
986
985
  for (let r = 0; r < e.length; r++)
987
986
  n(e[r]);
988
987
  }
989
- function xt(l, t, e) {
990
- return t.forEach(function(i, s) {
991
- if (i && e[s]) {
992
- try {
993
- const n = decodeURIComponent(i);
994
- if (n !== i) {
995
- const r = n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
996
- l = l.replace(new RegExp(r, "g"), e[s]);
997
- }
998
- } catch {
988
+ function bt(a, t, e) {
989
+ const i = /* @__PURE__ */ new Map(), s = [], n = /[-[\]{}()*+?.,\\^$|#\s]/g;
990
+ for (let o = 0; o < t.length; o++) {
991
+ const h = t[o], l = e[o];
992
+ if (!h || !l) continue;
993
+ const c = h.replace(n, "\\$&");
994
+ i.set(h, l), s.push(c);
995
+ try {
996
+ const d = decodeURIComponent(h);
997
+ if (d !== h) {
998
+ const f = d.replace(n, "\\$&");
999
+ i.set(d, l), s.push(f);
999
1000
  }
1000
- i = i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), l = l.replace(new RegExp(i, "g"), e[s]);
1001
+ } catch {
1001
1002
  }
1002
- }), l;
1003
+ }
1004
+ if (s.length === 0) return a;
1005
+ s.sort((o, h) => h.length - o.length);
1006
+ const r = new RegExp(s.join("|"), "g");
1007
+ return a.replace(r, (o) => i.get(o) ?? o);
1003
1008
  }
1004
- function H(l, t, e, i) {
1005
- const s = typeof window < "u" ? window.URL : !1, n = s ? "blob" : "arraybuffer", r = new v(), o = new XMLHttpRequest();
1006
- let h;
1007
- e && (o.withCredentials = !0), o.onreadystatechange = c, o.onerror = a, o.open("GET", l, !0);
1008
- for (h in i)
1009
- o.setRequestHeader(h, i[h]);
1010
- t == "json" && o.setRequestHeader("Accept", "application/json"), t || (t = new P(l).extension), t == "blob" && (o.responseType = n), K(t) && o.overrideMimeType("text/xml"), t == "binary" && (o.responseType = "arraybuffer"), o.send();
1011
- function a(d) {
1012
- r.reject(d);
1013
- }
1014
- function c() {
1015
- if (o.readyState === XMLHttpRequest.DONE) {
1016
- let d = !1;
1017
- if ((o.responseType === "" || o.responseType === "document") && (d = o.responseXML), o.status === 200 || o.status === 0 || d) {
1018
- let f;
1019
- if (!o.response && !d)
1020
- return r.reject({
1021
- status: o.status,
1022
- message: "Empty Response",
1023
- stack: new Error().stack
1024
- }), r.promise;
1025
- if (o.status === 403)
1026
- return r.reject({
1027
- status: o.status,
1028
- response: o.response,
1029
- message: "Forbidden",
1030
- stack: new Error().stack
1031
- }), r.promise;
1032
- d ? f = o.responseXML : K(t) ? f = O(o.response, "text/xml") : t == "xhtml" ? f = O(o.response, "application/xhtml+xml") : t == "html" || t == "htm" ? f = O(o.response, "text/html") : t == "json" ? f = JSON.parse(o.response) : t == "blob" ? s ? f = o.response : f = new Blob([o.response]) : f = o.response, r.resolve(f);
1033
- } else
1034
- r.reject({
1035
- status: o.status,
1036
- message: o.response,
1037
- stack: new Error().stack
1038
- });
1039
- }
1009
+ async function V(a, t, e, i) {
1010
+ t || (t = new P(a).extension);
1011
+ const s = {};
1012
+ if (e && (s.credentials = "include"), i || t === "json") {
1013
+ const o = new Headers(i);
1014
+ t === "json" && o.set("Accept", "application/json"), s.headers = o;
1040
1015
  }
1041
- return r.promise;
1016
+ let n;
1017
+ try {
1018
+ n = await fetch(a, s);
1019
+ } catch (o) {
1020
+ throw new q(o.message || "Network Error", 0);
1021
+ }
1022
+ if (!n.ok) {
1023
+ const o = await n.text().catch(() => "");
1024
+ throw new q(o || n.statusText, n.status);
1025
+ }
1026
+ if (t === "blob") {
1027
+ const o = await n.blob();
1028
+ return o instanceof Blob ? o : new Blob([o], { type: o.type });
1029
+ }
1030
+ if (t === "binary")
1031
+ return n.arrayBuffer();
1032
+ if (t === "json")
1033
+ return n.json();
1034
+ const r = await n.text();
1035
+ return Lt(t) ? W(r, "text/xml") : t === "xhtml" ? W(r, "application/xhtml+xml") : t === "html" || t === "htm" ? W(r, "text/html") : r;
1042
1036
  }
1043
- class ae {
1037
+ class de {
1044
1038
  constructor(t, e) {
1045
- 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 N(this), this.hooks.content = new N(this)), this.document = void 0, this.contents = void 0, this.output = void 0;
1039
+ 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 R(this), this.hooks.content = new R(this)), this.document = void 0, this.contents = void 0, this.output = void 0;
1046
1040
  }
1047
1041
  /**
1048
1042
  * Load the section from its url
1049
1043
  * @param {method} [_request] a request method to use for loading
1050
1044
  * @return {document} a promise with the xml document
1051
1045
  */
1052
- load(t) {
1053
- const e = t || this.request || H, i = new v(), s = i.promise;
1054
- return this.contents ? i.resolve(this.contents) : e(this.url).then((n) => (this.document = n, this.contents = n.documentElement, this.hooks.content.trigger(this.document, this))).then(() => {
1055
- i.resolve(this.contents);
1056
- }).catch(function(n) {
1057
- i.reject(n);
1058
- }), s;
1046
+ async load(t) {
1047
+ const e = t || this.request || V;
1048
+ if (this.contents)
1049
+ return this.contents;
1050
+ const i = await e(this.url);
1051
+ return this.document = i, this.contents = i.documentElement, await this.hooks.content.trigger(this.document, this), this.contents;
1059
1052
  }
1060
1053
  /**
1061
1054
  * Adds a base tag for resolving urls in the section
1062
1055
  * @private
1063
1056
  */
1064
1057
  base() {
1065
- return Rt(this.document, this);
1058
+ return At(this.document, this);
1066
1059
  }
1067
1060
  /**
1068
1061
  * Render the contents of a section
1069
1062
  * @param {method} [_request] a request method to use for loading
1070
1063
  * @return {string} output a serialized XML Document
1071
1064
  */
1072
- render(t) {
1073
- const e = new v(), i = e.promise;
1074
- return this.load(t).then((s) => {
1075
- const n = new XMLSerializer();
1076
- return this.output = n.serializeToString(s), this.output;
1077
- }).then(() => this.hooks.serialize.trigger(this.output, this)).then(() => {
1078
- e.resolve(this.output);
1079
- }).catch(function(s) {
1080
- e.reject(s);
1081
- }), i;
1065
+ async render(t) {
1066
+ const e = await this.load(t), i = new XMLSerializer();
1067
+ return this.output = i.serializeToString(e), await this.hooks.serialize.trigger(this.output, this), this.output;
1082
1068
  }
1083
1069
  /**
1084
1070
  * Find a string in a section
@@ -1088,15 +1074,15 @@ class ae {
1088
1074
  find(t) {
1089
1075
  const e = this, i = [], s = t.toLowerCase(), n = function(r) {
1090
1076
  const o = r.textContent.toLowerCase();
1091
- let h, a, c, d = -1, f;
1077
+ let h, l, c, d = -1, f;
1092
1078
  const p = 150;
1093
- for (; c != -1; )
1094
- c = o.indexOf(s, d + 1), c != -1 && (h = e.document.createRange(), h.setStart(r, c), h.setEnd(r, c + s.length), a = e.cfiFromRange(h), r.textContent.length < p ? f = r.textContent : (f = r.textContent.substring(c - p / 2, c + p / 2), f = "..." + f + "..."), i.push({
1095
- cfi: a,
1079
+ for (; c !== -1; )
1080
+ 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 ? f = r.textContent : (f = r.textContent.substring(c - p / 2, c + p / 2), f = "..." + f + "..."), i.push({
1081
+ cfi: l,
1096
1082
  excerpt: f
1097
1083
  })), d = c;
1098
1084
  };
1099
- return ct(e.document, function(r) {
1085
+ return lt(e.document, function(r) {
1100
1086
  n(r);
1101
1087
  }), i;
1102
1088
  }
@@ -1108,29 +1094,29 @@ class ae {
1108
1094
  */
1109
1095
  search(t, e = 5) {
1110
1096
  const i = [], n = this, r = t.toLowerCase(), o = function(d) {
1111
- const g = d.reduce((y, w) => y + (w.textContent ?? ""), "").toLowerCase().indexOf(r);
1112
- if (g != -1) {
1113
- const w = g + r.length;
1114
- let x = 0, T = 0;
1097
+ const g = d.reduce((v, y) => v + (y.textContent ?? ""), "").toLowerCase().indexOf(r);
1098
+ if (g !== -1) {
1099
+ const y = g + r.length;
1100
+ let b = 0, T = 0;
1115
1101
  if (g < d[0].length) {
1116
- for (; x < d.length - 1 && (T += d[x].length, !(w <= T)); )
1117
- x += 1;
1118
- const E = d[0], C = d[x], I = n.document.createRange();
1119
- I.setStart(E, g);
1120
- const Y = d.slice(0, x).reduce((Q, J) => Q + (J.textContent ?? "").length, 0);
1121
- I.setEnd(C, Y > w ? w : w - Y);
1122
- const B = n.cfiFromRange(I);
1123
- let z = d.slice(0, x + 1).reduce((Q, J) => Q + (J.textContent ?? ""), "");
1124
- z.length > 150 && (z = z.substring(g - 150 / 2, g + 150 / 2), z = "..." + z + "..."), i.push({
1125
- cfi: B,
1126
- excerpt: z
1102
+ for (; b < d.length - 1 && (T += d[b].length, !(y <= T)); )
1103
+ b += 1;
1104
+ const x = d[0], C = d[b], I = n.document.createRange();
1105
+ I.setStart(x, g);
1106
+ const Y = d.slice(0, b).reduce((Z, Q) => Z + (Q.textContent ?? "").length, 0);
1107
+ I.setEnd(C, Y > y ? y : y - Y);
1108
+ const D = n.cfiFromRange(I);
1109
+ let O = d.slice(0, b + 1).reduce((Z, Q) => Z + (Q.textContent ?? ""), "");
1110
+ O.length > 150 && (O = O.substring(g - 150 / 2, g + 150 / 2), O = "..." + O + "..."), i.push({
1111
+ cfi: D,
1112
+ excerpt: O
1127
1113
  });
1128
1114
  }
1129
1115
  }
1130
1116
  }, h = document.createTreeWalker(n.document, NodeFilter.SHOW_TEXT, null);
1131
- let a, c = [];
1132
- for (; a = h.nextNode(); )
1133
- c.push(a), c.length == e && (o(c.slice(0, e)), c = c.slice(1, e));
1117
+ let l, c = [];
1118
+ for (; l = h.nextNode(); )
1119
+ c.push(l), c.length === e && (o(c.slice(0, e)), c = c.slice(1, e));
1134
1120
  return c.length > 0 && o(c), i;
1135
1121
  }
1136
1122
  /**
@@ -1148,7 +1134,7 @@ class ae {
1148
1134
  return this.properties.forEach(function(i) {
1149
1135
  const s = i.replace("rendition:", ""), n = s.indexOf("-");
1150
1136
  let r, o;
1151
- n != -1 && (r = s.slice(0, n), o = s.slice(n + 1), e[r] = o);
1137
+ n !== -1 && (r = s.slice(0, n), o = s.slice(n + 1), e[r] = o);
1152
1138
  }), e;
1153
1139
  }
1154
1140
  /**
@@ -1177,9 +1163,9 @@ class ae {
1177
1163
  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;
1178
1164
  }
1179
1165
  }
1180
- class ce {
1166
+ class ue {
1181
1167
  constructor() {
1182
- this.spineItems = [], this.spineByHref = {}, this.spineById = {}, this.hooks = {}, this.hooks.serialize = new N(), this.hooks.content = new N(), this.hooks.content.register(Rt), this.hooks.content.register(oe), this.hooks.content.register(he), this.epubcfi = new m(), this.loaded = !1, this.items = [], this.manifest = {}, this.spineNodeIndex = 0, this.baseUrl = "", this.length = 0;
1168
+ this.spineItems = [], this.spineByHref = {}, this.spineById = {}, this.hooks = {}, this.hooks.serialize = new R(), this.hooks.content = new R(), this.hooks.content.register(At), this.hooks.content.register(ae), this.hooks.content.register(le), this.epubcfi = new m(), this.loaded = !1, this.items = [], this.manifest = {}, this.spineNodeIndex = 0, this.baseUrl = "", this.length = 0;
1183
1169
  }
1184
1170
  /**
1185
1171
  * Unpack items from a opf into spine items
@@ -1193,23 +1179,23 @@ class ce {
1193
1179
  s.index = n, s.cfiBase = this.epubcfi.generateChapterComponent(this.spineNodeIndex, s.index, s.id), s.href && (s.url = e(s.href, !0), s.canonical = i(s.href)), r && (s.href = r.href, s.url = e(s.href, !0), s.canonical = i(s.href), r.properties.length && s.properties.push(...r.properties)), s.linear === "yes" ? (s.prev = () => {
1194
1180
  let h = s.index;
1195
1181
  for (; h > 0; ) {
1196
- const a = this.get(h - 1);
1197
- if (a && a.linear)
1198
- return a;
1182
+ const l = this.get(h - 1);
1183
+ if (l && l.linear)
1184
+ return l;
1199
1185
  h -= 1;
1200
1186
  }
1201
1187
  }, s.next = () => {
1202
1188
  let h = s.index;
1203
1189
  for (; h < this.spineItems.length - 1; ) {
1204
- const a = this.get(h + 1);
1205
- if (a && a.linear)
1206
- return a;
1190
+ const l = this.get(h + 1);
1191
+ if (l && l.linear)
1192
+ return l;
1207
1193
  h += 1;
1208
1194
  }
1209
1195
  }) : (s.prev = function() {
1210
1196
  }, s.next = function() {
1211
1197
  });
1212
- const o = new ae(s, this.hooks);
1198
+ const o = new de(s, this.hooks);
1213
1199
  this.append(o);
1214
1200
  }), this.loaded = !0;
1215
1201
  }
@@ -1303,16 +1289,16 @@ class ce {
1303
1289
  this.each((t) => t.destroy()), this.spineItems = void 0, this.spineByHref = void 0, this.spineById = void 0, this.hooks.serialize.clear(), this.hooks.content.clear(), this.hooks = void 0, this.epubcfi = void 0, this.loaded = !1, this.items = void 0, this.manifest = void 0, this.spineNodeIndex = void 0, this.baseUrl = void 0, this.length = void 0;
1304
1290
  }
1305
1291
  }
1306
- class mt {
1292
+ class pt {
1307
1293
  constructor(t) {
1308
- this._q = [], this.context = t, this.tick = Tt, this.running = !1, this.paused = !1;
1294
+ this._q = [], this.context = t, this.tick = Vt, this.running = !1, this.paused = !1;
1309
1295
  }
1310
1296
  enqueue(...t) {
1311
1297
  let e, i, s;
1312
1298
  const [n, ...r] = t;
1313
1299
  if (!n)
1314
1300
  throw new Error("No Task Provided");
1315
- return typeof n == "function" ? (e = new v(), i = e.promise, s = {
1301
+ return typeof n == "function" ? (e = new S(), i = e.promise, s = {
1316
1302
  task: n,
1317
1303
  args: r,
1318
1304
  //"context" : context,
@@ -1321,7 +1307,7 @@ class mt {
1321
1307
  }) : s = {
1322
1308
  args: [],
1323
1309
  promise: n
1324
- }, this._q.push(s), this.paused == !1 && !this.running && this.run(), s.promise;
1310
+ }, this._q.push(s), !this.paused && !this.running && this.run(), s.promise;
1325
1311
  }
1326
1312
  /**
1327
1313
  * Run one item
@@ -1345,11 +1331,13 @@ class mt {
1345
1331
  * @return {Promise}
1346
1332
  */
1347
1333
  run() {
1348
- return this.running || (this.running = !0, this.defered = new v()), this.tick && this.tick(() => {
1334
+ this.running || (this.running = !0, this.defered = new S());
1335
+ const t = () => {
1349
1336
  this._q.length ? this.dequeue()?.then(() => {
1350
1337
  this.run();
1351
1338
  }) : (this.defered.resolve(), this.running = void 0);
1352
- }), this.paused == !0 && (this.paused = !1), this.defered.promise;
1339
+ };
1340
+ return this.tick(t), this.paused && (this.paused = !1), this.defered.promise;
1353
1341
  }
1354
1342
  /**
1355
1343
  * Flush all, as quickly as possible
@@ -1387,7 +1375,7 @@ class mt {
1387
1375
  this._q = [], this.running = !1, this.paused = !0;
1388
1376
  }
1389
1377
  }
1390
- const Nt = "0.3", G = ["keydown", "keyup", "keypress", "mouseup", "mousedown", "mousemove", "click", "dblclick", "touchend", "touchstart", "touchmove"], u = {
1378
+ const It = "0.3", G = ["keydown", "keyup", "keypress", "mouseup", "mousedown", "mousemove", "click", "dblclick", "touchend", "touchstart", "touchmove"], u = {
1391
1379
  BOOK: {
1392
1380
  OPEN_FAILED: "openFailed"
1393
1381
  },
@@ -1444,9 +1432,9 @@ const Nt = "0.3", G = ["keydown", "keyup", "keypress", "mouseup", "mousedown", "
1444
1432
  DETACH: "detach"
1445
1433
  }
1446
1434
  };
1447
- class At {
1435
+ class Pt {
1448
1436
  constructor(t, e, i) {
1449
- this.spine = t, this.request = e, this.pause = i || 100, this.q = new mt(this), this.epubcfi = new m(), this._locations = [], this._locationsWords = [], this.total = 0, this.break = 150, this._current = 0, this._wordCounter = 0, this._currentCfi = "", this.processingTimeout = void 0;
1437
+ this.spine = t, this.request = e, this.pause = i || 0, this.q = new pt(this), this.q.tick = _t, this.epubcfi = new m(), this._locations = [], this._locationsWords = [], this.total = 0, this.break = 150, this._current = 0, this._wordCounter = 0, this._currentCfi = "", this.processingTimeout = void 0;
1450
1438
  }
1451
1439
  /**
1452
1440
  * Load all of sections in the book to generate locations
@@ -1466,34 +1454,34 @@ class At {
1466
1454
  endOffset: void 0
1467
1455
  };
1468
1456
  }
1469
- process(t) {
1470
- return t.load(this.request).then((e) => {
1471
- const i = new v(), s = this.parse(e, t.cfiBase);
1472
- return this._locations = this._locations.concat(s), t.unload(), this.processingTimeout = setTimeout(() => i.resolve(s), this.pause), i.promise;
1457
+ async process(t) {
1458
+ const e = await t.load(this.request), i = this.parse(e, t.cfiBase);
1459
+ return this._locations = this._locations.concat(i), t.unload(), new Promise((s) => {
1460
+ this.processingTimeout = setTimeout(() => s(i), this.pause);
1473
1461
  });
1474
1462
  }
1475
1463
  parse(t, e, i) {
1476
1464
  const s = [];
1477
1465
  let n;
1478
- const r = t.ownerDocument, o = b(r, "body");
1479
- let h = 0, a;
1466
+ const r = t.ownerDocument, o = w(r, "body");
1467
+ let h = 0, l;
1480
1468
  const c = i || this.break;
1481
- if (ct(o, (f) => {
1469
+ if (lt(o, (f) => {
1482
1470
  const p = f.length;
1483
- let g, y = 0;
1471
+ let g, v = 0;
1484
1472
  if ((f.textContent ?? "").trim().length === 0)
1485
- return a = f, !1;
1486
- for (h === 0 && (n = this.createRange(), n.startContainer = f, n.startOffset = 0), g = c - h, g > p && (h += p, y = p); y < p; )
1487
- if (g = c - h, h === 0 && (y += 1, n = this.createRange(), n.startContainer = f, n.startOffset = y), y + g >= p)
1488
- h += p - y, y = p;
1473
+ return l = f, !1;
1474
+ for (h === 0 && (n = this.createRange(), n.startContainer = f, n.startOffset = 0), g = c - h, g > p && (h += p, v = p); v < p; )
1475
+ if (g = c - h, h === 0 && (v += 1, n = this.createRange(), n.startContainer = f, n.startOffset = v), v + g >= p)
1476
+ h += p - v, v = p;
1489
1477
  else {
1490
- y += g, n.endContainer = f, n.endOffset = y;
1491
- const w = new m(n, e).toString();
1492
- s.push(w), h = 0;
1478
+ v += g, n.endContainer = f, n.endOffset = v;
1479
+ const y = new m(n, e).toString();
1480
+ s.push(y), h = 0;
1493
1481
  }
1494
- return a = f, !1;
1495
- }), n && n.startContainer && a) {
1496
- n.endContainer = a, n.endOffset = a.length;
1482
+ return l = f, !1;
1483
+ }), n && n.startContainer && l) {
1484
+ n.endContainer = l, n.endOffset = l.length;
1497
1485
  const f = new m(n, e).toString();
1498
1486
  s.push(f), h = 0;
1499
1487
  }
@@ -1509,13 +1497,15 @@ class At {
1509
1497
  generateFromWords(t, e, i) {
1510
1498
  const s = t ? new m(t) : void 0;
1511
1499
  return this.q.pause(), this._locationsWords = [], this._wordCounter = 0, this.spine.each((n) => {
1512
- n.linear && (s ? n.index >= s.spinePos && this.q.enqueue((r, o, h, a) => this.processWords(r, o, h, a), n, e, s, i) : this.q.enqueue((r, o, h, a) => this.processWords(r, o, h, a), n, e, s, i));
1500
+ n.linear && (s ? n.index >= s.spinePos && this.q.enqueue((r, o, h, l) => this.processWords(r, o, h, l), n, e, s, i) : this.q.enqueue((r, o, h, l) => this.processWords(r, o, h, l), n, e, s, i));
1513
1501
  }), this.q.run().then(() => (this._currentCfi && (this.currentLocation = this._currentCfi), this._locationsWords));
1514
1502
  }
1515
- processWords(t, e, i, s) {
1516
- return s && this._locationsWords.length >= s ? Promise.resolve([]) : t.load(this.request).then((n) => {
1517
- const r = new v(), o = this.parseWords(n, t, e, i), h = s - this._locationsWords.length;
1518
- return this._locationsWords = this._locationsWords.concat(o.length >= s ? o.slice(0, h) : o), t.unload(), this.processingTimeout = setTimeout(() => r.resolve(o), this.pause), r.promise;
1503
+ async processWords(t, e, i, s) {
1504
+ if (s && this._locationsWords.length >= s)
1505
+ return [];
1506
+ const n = await t.load(this.request), r = this.parseWords(n, t, e, i), o = s - this._locationsWords.length;
1507
+ return this._locationsWords = this._locationsWords.concat(r.length >= s ? r.slice(0, o) : r), t.unload(), new Promise((h) => {
1508
+ this.processingTimeout = setTimeout(() => h(r), this.pause);
1519
1509
  });
1520
1510
  }
1521
1511
  //http://stackoverflow.com/questions/18679576/counting-words-in-string
@@ -1524,9 +1514,9 @@ class At {
1524
1514
  `), t.split(" ").length;
1525
1515
  }
1526
1516
  parseWords(t, e, i, s) {
1527
- const n = e.cfiBase, r = [], o = t.ownerDocument, h = b(o, "body"), a = i;
1517
+ const n = e.cfiBase, r = [], o = t.ownerDocument, h = w(o, "body"), l = i;
1528
1518
  let c = s ? s.spinePos !== e.index : !0, d;
1529
- return s && e.index === s.spinePos && (d = s.findNode(s.range ? s.path.steps.concat(s.start.steps) : s.path.steps, t.ownerDocument)), ct(h, (p) => {
1519
+ return s && e.index === s.spinePos && (d = s.findNode(s.range ? s.path.steps.concat(s.start.steps) : s.path.steps, t.ownerDocument)), lt(h, (p) => {
1530
1520
  if (!c)
1531
1521
  if (p === d)
1532
1522
  c = !0;
@@ -1535,16 +1525,16 @@ class At {
1535
1525
  if ((p.textContent ?? "").length < 10 && (p.textContent ?? "").trim().length === 0)
1536
1526
  return !1;
1537
1527
  const g = this.countWords(p.textContent ?? "");
1538
- let y, w = 0;
1528
+ let v, y = 0;
1539
1529
  if (g === 0)
1540
1530
  return !1;
1541
- for (y = a - this._wordCounter, y > g && (this._wordCounter += g, w = g); w < g; )
1542
- if (y = a - this._wordCounter, w + y >= g)
1543
- this._wordCounter += g - w, w = g;
1531
+ for (v = l - this._wordCounter, v > g && (this._wordCounter += g, y = g); y < g; )
1532
+ if (v = l - this._wordCounter, y + v >= g)
1533
+ this._wordCounter += g - y, y = g;
1544
1534
  else {
1545
- w += y;
1546
- const x = new m(p, n);
1547
- r.push({ cfi: x.toString(), wordCount: this._wordCounter }), this._wordCounter = 0;
1535
+ y += v;
1536
+ const b = new m(p, n);
1537
+ r.push({ cfi: b.toString(), wordCount: this._wordCounter }), this._wordCounter = 0;
1548
1538
  }
1549
1539
  return !1;
1550
1540
  }), r;
@@ -1652,8 +1642,8 @@ class At {
1652
1642
  this.spine = void 0, this.request = void 0, this.pause = void 0, this.q?.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);
1653
1643
  }
1654
1644
  }
1655
- A(At.prototype);
1656
- class de {
1645
+ A(Pt.prototype);
1646
+ class fe {
1657
1647
  constructor(t) {
1658
1648
  this.packagePath = "", this.directory = "", this.encoding = "", t && this.parse(t);
1659
1649
  }
@@ -1664,16 +1654,16 @@ class de {
1664
1654
  parse(t) {
1665
1655
  if (!t)
1666
1656
  throw new Error("Container File Not Found");
1667
- const e = b(t, "rootfile");
1657
+ const e = w(t, "rootfile");
1668
1658
  if (!e)
1669
1659
  throw new Error("No RootFile Found");
1670
- this.packagePath = e.getAttribute("full-path") ?? "", this.directory = D.dirname(this.packagePath), this.encoding = t.xmlEncoding;
1660
+ this.packagePath = e.getAttribute("full-path") ?? "", this.directory = z.dirname(this.packagePath), this.encoding = t.xmlEncoding;
1671
1661
  }
1672
1662
  destroy() {
1673
1663
  this.packagePath = void 0, this.directory = void 0, this.encoding = void 0;
1674
1664
  }
1675
1665
  }
1676
- class Et {
1666
+ class xt {
1677
1667
  constructor(t) {
1678
1668
  this.manifest = {}, this.navPath = "", this.ncxPath = "", this.coverPath = "", this.spineNodeIndex = 0, this.spine = [], this.metadata = {}, t && this.parse(t);
1679
1669
  }
@@ -1685,16 +1675,16 @@ class Et {
1685
1675
  parse(t) {
1686
1676
  if (!t)
1687
1677
  throw new Error("Package File Not Found");
1688
- const e = b(t, "metadata");
1678
+ const e = w(t, "metadata");
1689
1679
  if (!e)
1690
1680
  throw new Error("No Metadata Found");
1691
- const i = b(t, "manifest");
1681
+ const i = w(t, "manifest");
1692
1682
  if (!i)
1693
1683
  throw new Error("No Manifest Found");
1694
- const s = b(t, "spine");
1684
+ const s = w(t, "spine");
1695
1685
  if (!s)
1696
1686
  throw new Error("No Spine Found");
1697
- return this.manifest = this.parseManifest(i), this.navPath = this.findNavPath(i), this.ncxPath = this.findNcxPath(i, s), this.coverPath = this.findCoverPath(t), this.spineNodeIndex = Gt(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") ?? "", {
1687
+ return this.manifest = this.parseManifest(i), this.navPath = this.findNavPath(i), this.ncxPath = this.findNcxPath(i, s), this.coverPath = this.findCoverPath(t), this.spineNodeIndex = Kt(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") ?? "", {
1698
1688
  metadata: this.metadata,
1699
1689
  spine: this.spine,
1700
1690
  manifest: this.manifest,
@@ -1721,14 +1711,14 @@ class Et {
1721
1711
  * @return {object} manifest
1722
1712
  */
1723
1713
  parseManifest(t) {
1724
- const e = {}, i = M(t, "item");
1714
+ const e = {}, i = B(t, "item");
1725
1715
  return Array.from(i).forEach(function(n) {
1726
- const r = n.getAttribute("id") ?? "", o = n.getAttribute("href") || "", h = n.getAttribute("media-type") || "", a = n.getAttribute("media-overlay") || "", c = n.getAttribute("properties") || "", d = n.getAttribute("fallback") || "";
1716
+ const r = n.getAttribute("id") ?? "", o = n.getAttribute("href") || "", h = n.getAttribute("media-type") || "", l = n.getAttribute("media-overlay") || "", c = n.getAttribute("properties") || "", d = n.getAttribute("fallback") || "";
1727
1717
  e[r] = {
1728
1718
  href: o,
1729
1719
  // "url" : href,
1730
1720
  type: h,
1731
- overlay: a,
1721
+ overlay: l,
1732
1722
  properties: c.length ? c.split(" ") : [],
1733
1723
  fallback: d
1734
1724
  };
@@ -1742,9 +1732,9 @@ class Et {
1742
1732
  * @return {object} spine
1743
1733
  */
1744
1734
  parseSpine(t, e) {
1745
- const i = [], s = M(t, "itemref");
1735
+ const i = [], s = B(t, "itemref");
1746
1736
  return Array.from(s).forEach(function(r, o) {
1747
- const h = r.getAttribute("idref"), a = r.getAttribute("properties") || "", c = a.length ? a.split(" ") : [], d = {
1737
+ const h = r.getAttribute("idref"), l = r.getAttribute("properties") || "", c = l.length ? l.split(" ") : [], d = {
1748
1738
  id: r.getAttribute("id") ?? void 0,
1749
1739
  idref: h,
1750
1740
  linear: r.getAttribute("linear") || "yes",
@@ -1777,7 +1767,7 @@ class Et {
1777
1767
  * @return {string}
1778
1768
  */
1779
1769
  findNavPath(t) {
1780
- const e = F(t, "item", { properties: "nav" });
1770
+ const e = j(t, "item", { properties: "nav" });
1781
1771
  return e && e.getAttribute("href") || "";
1782
1772
  }
1783
1773
  /**
@@ -1789,7 +1779,7 @@ class Et {
1789
1779
  * @return {string}
1790
1780
  */
1791
1781
  findNcxPath(t, e) {
1792
- let i = F(t, "item", { "media-type": "application/x-dtbncx+xml" }), s;
1782
+ let i = j(t, "item", { "media-type": "application/x-dtbncx+xml" }), s;
1793
1783
  return i || (s = e.getAttribute("toc"), s && (i = t.querySelector(`#${s}`) ?? void 0)), i && i.getAttribute("href") || "";
1794
1784
  }
1795
1785
  /**
@@ -1801,10 +1791,10 @@ class Et {
1801
1791
  * @return {string} href
1802
1792
  */
1803
1793
  findCoverPath(t) {
1804
- b(t, "package")?.getAttribute("version");
1805
- const i = F(t, "item", { properties: "cover-image" });
1794
+ w(t, "package")?.getAttribute("version");
1795
+ const i = j(t, "item", { properties: "cover-image" });
1806
1796
  if (i) return i.getAttribute("href") ?? "";
1807
- const s = F(t, "meta", { name: "cover" });
1797
+ const s = j(t, "meta", { name: "cover" });
1808
1798
  if (s) {
1809
1799
  const n = s.getAttribute("content"), r = t.getElementById(n);
1810
1800
  return r ? r.getAttribute("href") ?? "" : "";
@@ -1832,7 +1822,7 @@ class Et {
1832
1822
  * @return {string} text
1833
1823
  */
1834
1824
  getPropertyText(t, e) {
1835
- const i = F(t, "meta", { property: e });
1825
+ const i = j(t, "meta", { property: e });
1836
1826
  return i && i.childNodes.length ? i.childNodes[0].nodeValue ?? "" : "";
1837
1827
  }
1838
1828
  /**
@@ -1860,7 +1850,7 @@ class Et {
1860
1850
  this.manifest = void 0, this.navPath = void 0, this.ncxPath = void 0, this.coverPath = void 0, this.spineNodeIndex = void 0, this.spine = void 0, this.metadata = void 0;
1861
1851
  }
1862
1852
  }
1863
- class et {
1853
+ class tt {
1864
1854
  constructor(t) {
1865
1855
  this.toc = [], this.tocByHref = {}, this.tocById = {}, this.landmarks = [], this.landmarksByType = {}, this.length = 0, t && this.parse(t);
1866
1856
  }
@@ -1871,7 +1861,7 @@ class et {
1871
1861
  parse(t) {
1872
1862
  const e = t.nodeType;
1873
1863
  let i, s;
1874
- e && (i = b(t, "html"), s = b(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);
1864
+ 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);
1875
1865
  }
1876
1866
  /**
1877
1867
  * Unpack navigation items
@@ -1931,10 +1921,10 @@ class et {
1931
1921
  * @return {array} navigation list
1932
1922
  */
1933
1923
  parseNav(t) {
1934
- const e = dt(t, "nav", "toc");
1924
+ const e = ct(t, "nav", "toc");
1935
1925
  let i = [];
1936
1926
  if (!e) return i;
1937
- const s = V(e, "ol");
1927
+ const s = F(e, "ol");
1938
1928
  return s && (i = this.parseNavList(s)), i;
1939
1929
  }
1940
1930
  /**
@@ -1960,14 +1950,14 @@ class et {
1960
1950
  */
1961
1951
  navItem(t, e) {
1962
1952
  let i = t.getAttribute("id") || void 0;
1963
- const s = V(t, "a") || V(t, "span");
1953
+ const s = F(t, "a") || F(t, "span");
1964
1954
  if (!s)
1965
1955
  return;
1966
1956
  const n = s.getAttribute("href") || "";
1967
1957
  i || (i = n);
1968
1958
  const r = s.textContent || "";
1969
1959
  let o = [];
1970
- const h = V(t, "ol");
1960
+ const h = F(t, "ol");
1971
1961
  return h && (o = this.parseNavList(h, i)), {
1972
1962
  id: i,
1973
1963
  href: n,
@@ -1983,7 +1973,7 @@ class et {
1983
1973
  * @return {array} landmarks list
1984
1974
  */
1985
1975
  parseLandmarks(t) {
1986
- const e = dt(t, "nav", "landmarks"), i = e ? Array.from(M(e, "li")) : [], s = i.length;
1976
+ const e = ct(t, "nav", "landmarks"), i = e ? Array.from(B(e, "li")) : [], s = i.length;
1987
1977
  let n;
1988
1978
  const r = [];
1989
1979
  let o;
@@ -1999,7 +1989,7 @@ class et {
1999
1989
  * @return {object} landmarkItem
2000
1990
  */
2001
1991
  landmarkItem(t) {
2002
- const e = V(t, "a");
1992
+ const e = F(t, "a");
2003
1993
  if (!e)
2004
1994
  return;
2005
1995
  const i = e.getAttributeNS("http://www.idpf.org/2007/ops", "type") || void 0, s = e.getAttribute("href") || "", n = e.textContent || "";
@@ -2016,7 +2006,7 @@ class et {
2016
2006
  * @return {array} navigation list
2017
2007
  */
2018
2008
  parseNcx(t) {
2019
- const e = M(t, "navPoint"), i = e.length;
2009
+ const e = B(t, "navPoint"), i = e.length;
2020
2010
  let s;
2021
2011
  const n = {}, r = [];
2022
2012
  let o, h;
@@ -2032,14 +2022,14 @@ class et {
2032
2022
  * @return {object} ncxItem
2033
2023
  */
2034
2024
  ncxItem(t) {
2035
- const e = t.getAttribute("id") || "", i = b(t, "content"), s = i ? i.getAttribute("src") ?? "" : "", n = b(t, "navLabel"), r = n?.textContent ? n.textContent : "", o = [], h = t.parentNode;
2036
- let a;
2037
- return h && (h.nodeName === "navPoint" || h.nodeName.split(":").slice(-1)[0] === "navPoint") && (a = h.getAttribute("id") ?? void 0), {
2025
+ const e = t.getAttribute("id") || "", i = w(t, "content"), s = i ? i.getAttribute("src") ?? "" : "", n = w(t, "navLabel"), r = n?.textContent ? n.textContent : "", o = [], h = t.parentNode;
2026
+ let l;
2027
+ return h && (h.nodeName === "navPoint" || h.nodeName.split(":").slice(-1)[0] === "navPoint") && (l = h.getAttribute("id") ?? void 0), {
2038
2028
  id: e,
2039
2029
  href: s,
2040
2030
  label: r,
2041
2031
  subitems: o,
2042
- parent: a
2032
+ parent: l
2043
2033
  };
2044
2034
  }
2045
2035
  /**
@@ -2062,7 +2052,7 @@ class et {
2062
2052
  return this.toc.forEach(t);
2063
2053
  }
2064
2054
  }
2065
- const it = {
2055
+ const et = {
2066
2056
  application: {
2067
2057
  ecmascript: ["es", "ecma"],
2068
2058
  javascript: "js",
@@ -2196,27 +2186,27 @@ const it = {
2196
2186
  "x-ms-vob": "vob",
2197
2187
  "x-smv": "smv"
2198
2188
  }
2199
- }, ue = (function() {
2200
- let l, t, e, i;
2189
+ }, pe = (function() {
2190
+ let a, t, e, i;
2201
2191
  const s = {};
2202
- for (l in it)
2203
- if (it.hasOwnProperty(l)) {
2204
- const n = it[l];
2192
+ for (a in et)
2193
+ if (et.hasOwnProperty(a)) {
2194
+ const n = et[a];
2205
2195
  for (t in n)
2206
2196
  if (n.hasOwnProperty(t))
2207
2197
  if (e = n[t], typeof e == "string")
2208
- s[e] = l + "/" + t;
2198
+ s[e] = a + "/" + t;
2209
2199
  else
2210
2200
  for (i = 0; i < e.length; i++)
2211
- s[e[i]] = l + "/" + t;
2201
+ s[e[i]] = a + "/" + t;
2212
2202
  }
2213
2203
  return s;
2214
- })(), fe = "text/plain";
2215
- function pe(l) {
2216
- return l && ue[l.split(".").pop().toLowerCase()] || fe;
2204
+ })(), ge = "text/plain";
2205
+ function me(a) {
2206
+ return a && pe[a.split(".").pop().toLowerCase()] || ge;
2217
2207
  }
2218
- const q = { lookup: pe };
2219
- class ge {
2208
+ const H = { lookup: me };
2209
+ class ve {
2220
2210
  constructor(t, e) {
2221
2211
  this.settings = {
2222
2212
  replacements: e && e.replacements || "base64",
@@ -2262,8 +2252,8 @@ class ge {
2262
2252
  * @return {Promise<string>} Promise resolves with url string
2263
2253
  */
2264
2254
  createUrl(t) {
2265
- const e = new R(t), i = q.lookup(e.filename);
2266
- 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) => Qt(s)).then((s) => yt(s, i)) : this.settings.request(t, "blob").then((s) => at(s, i));
2255
+ const e = new N(t), i = H.lookup(e.filename);
2256
+ 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) => te(s)).then((s) => vt(s, i)) : this.settings.request(t, "blob").then((s) => at(s, i));
2267
2257
  }
2268
2258
  /**
2269
2259
  * Create blob urls for all the assets
@@ -2288,6 +2278,8 @@ class ge {
2288
2278
  * @return {Promise}
2289
2279
  */
2290
2280
  replaceCss(t, e) {
2281
+ if (this.settings.replacements === "none")
2282
+ return Promise.resolve([]);
2291
2283
  const i = [];
2292
2284
  return this.cssUrls.forEach((s) => {
2293
2285
  const n = this.createCssFile(s).then((r) => {
@@ -2305,7 +2297,7 @@ class ge {
2305
2297
  */
2306
2298
  createCssFile(t) {
2307
2299
  let e;
2308
- if (D.isAbsolute(t))
2300
+ if (z.isAbsolute(t))
2309
2301
  return new Promise(function(r) {
2310
2302
  r();
2311
2303
  });
@@ -2317,8 +2309,8 @@ class ge {
2317
2309
  return new P(i).relative(o);
2318
2310
  });
2319
2311
  return s ? s.then((r) => {
2320
- const o = xt(r, n, this.replacementUrls);
2321
- return this.settings.replacements === "base64" ? e = yt(o, "text/css") : e = at(o, "text/css"), e;
2312
+ const o = bt(r, n, this.replacementUrls);
2313
+ return this.settings.replacements === "base64" ? e = vt(o, "text/css") : e = at(o, "text/css"), e;
2322
2314
  }, (r) => new Promise(function(o) {
2323
2315
  o();
2324
2316
  })) : new Promise(function(r) {
@@ -2358,15 +2350,15 @@ class ge {
2358
2350
  */
2359
2351
  substitute(t, e) {
2360
2352
  let i;
2361
- return e ? i = this.relativeTo(e) : i = this.urls, xt(t, i, this.replacementUrls);
2353
+ return e ? i = this.relativeTo(e) : i = this.urls, bt(t, i, this.replacementUrls);
2362
2354
  }
2363
2355
  destroy() {
2364
2356
  this.replacementUrls && this.replacementUrls.forEach((t) => {
2365
- t && kt(t);
2357
+ t && Rt(t);
2366
2358
  }), this.settings = void 0, this.manifest = void 0, this.resources = void 0, this.replacementUrls = void 0, this.html = void 0, this.assets = void 0, this.css = void 0, this.urls = void 0, this.cssUrls = void 0;
2367
2359
  }
2368
2360
  }
2369
- class st {
2361
+ class it {
2370
2362
  constructor(t) {
2371
2363
  this.pages = [], this.locations = [], this.epubcfi = new m(), this.firstPage = 0, this.lastPage = 0, this.totalPages = 0, this.toc = void 0, this.ncx = void 0, t && (this.pageList = this.parse(t)), this.pageList && this.pageList.length && this.process(this.pageList);
2372
2364
  }
@@ -2375,7 +2367,7 @@ class st {
2375
2367
  * @param {document} xml
2376
2368
  */
2377
2369
  parse(t) {
2378
- const e = b(t, "html"), i = b(t, "ncx");
2370
+ const e = w(t, "html"), i = w(t, "ncx");
2379
2371
  return e ? this.parseNav(t) : i ? this.parseNcx(t) : [];
2380
2372
  }
2381
2373
  /**
@@ -2385,7 +2377,7 @@ class st {
2385
2377
  * @return {PageList.item[]} list
2386
2378
  */
2387
2379
  parseNav(t) {
2388
- const e = dt(t, "nav", "page-list"), i = e ? Array.from(M(e, "li")) : [], s = i.length;
2380
+ const e = ct(t, "nav", "page-list"), i = e ? Array.from(B(e, "li")) : [], s = i.length;
2389
2381
  let n;
2390
2382
  const r = [];
2391
2383
  let o;
@@ -2397,9 +2389,9 @@ class st {
2397
2389
  parseNcx(t) {
2398
2390
  const e = [];
2399
2391
  let i = 0, s, n = 0;
2400
- const r = b(t, "pageList");
2392
+ const r = w(t, "pageList");
2401
2393
  if (!r) return e;
2402
- const o = M(r, "pageTarget");
2394
+ const o = B(r, "pageTarget");
2403
2395
  if (n = o.length, !o || o.length === 0)
2404
2396
  return e;
2405
2397
  for (i = 0; i < n; ++i)
@@ -2407,7 +2399,7 @@ class st {
2407
2399
  return e;
2408
2400
  }
2409
2401
  ncxItem(t) {
2410
- const e = b(t, "navLabel"), s = b(e, "text").textContent ?? "", r = b(t, "content").getAttribute("src") ?? "", o = parseInt(s, 10);
2402
+ const e = w(t, "navLabel"), s = w(e, "text").textContent ?? "", r = w(t, "content").getAttribute("src") ?? "", o = parseInt(s, 10);
2411
2403
  return {
2412
2404
  href: r,
2413
2405
  page: o
@@ -2420,10 +2412,10 @@ class st {
2420
2412
  * @return {object} pageListItem
2421
2413
  */
2422
2414
  item(t) {
2423
- const e = b(t, "a"), i = e.getAttribute("href") || "", s = e.textContent || "", n = parseInt(s), r = i.indexOf("epubcfi");
2424
- let o, h, a;
2425
- return r != -1 ? (o = i.split("#"), h = o[0], a = o.length > 1 ? o[1] : void 0, {
2426
- cfi: a,
2415
+ const e = w(t, "a"), i = e.getAttribute("href") || "", s = e.textContent || "", n = parseInt(s), r = i.indexOf("epubcfi");
2416
+ let o, h, l;
2417
+ return r !== -1 ? (o = i.split("#"), h = o[0], l = o.length > 1 ? o[1] : void 0, {
2418
+ cfi: l,
2427
2419
  href: i,
2428
2420
  packageUrl: h,
2429
2421
  page: n
@@ -2452,7 +2444,7 @@ class st {
2452
2444
  if (this.locations.length === 0)
2453
2445
  return -1;
2454
2446
  let i = ot(t, this.locations, this.epubcfi.compare);
2455
- return i != -1 ? e = this.pages[i] : (i = $(t, this.locations, this.epubcfi.compare), e = i - 1 >= 0 ? this.pages[i - 1] : this.pages[0], e !== void 0 || (e = -1)), e;
2447
+ return i !== -1 ? e = this.pages[i] : (i = $(t, this.locations, this.epubcfi.compare), e = i - 1 >= 0 ? this.pages[i - 1] : this.pages[0], e !== void 0 || (e = -1)), e;
2456
2448
  }
2457
2449
  /**
2458
2450
  * Get an EpubCFI from a Page List Item
@@ -2463,7 +2455,7 @@ class st {
2463
2455
  let e = -1;
2464
2456
  typeof t != "number" && (t = parseInt(t));
2465
2457
  const i = this.pages.indexOf(t);
2466
- return i != -1 && i < this.locations.length && (e = this.locations[i]), e;
2458
+ return i !== -1 && i < this.locations.length && (e = this.locations[i]), e;
2467
2459
  }
2468
2460
  /**
2469
2461
  * Get a Page from Book percentage
@@ -2498,7 +2490,7 @@ class st {
2498
2490
  this.pages = void 0, this.locations = void 0, this.epubcfi = void 0, this.pageList = void 0, this.toc = void 0, this.ncx = void 0;
2499
2491
  }
2500
2492
  }
2501
- class It {
2493
+ class Ot {
2502
2494
  constructor(t) {
2503
2495
  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 = {
2504
2496
  name: this.name,
@@ -2540,16 +2532,16 @@ class It {
2540
2532
  calculate(t, e, i) {
2541
2533
  let s = 1, n = i || 0, r = t;
2542
2534
  const o = e, h = Math.floor(r / 12);
2543
- let a, c;
2544
- this._spread && r >= this._minSpreadWidth ? s = 2 : s = 1, this.name === "reflowable" && this._flow === "paginated" && !(i !== void 0 && i >= 0) && (n = h % 2 === 0 ? h : h - 1), this.name === "pre-paginated" && (n = 0), s > 1 ? (a = r / s - n, c = a + n) : (a = r, c = r), this.name === "pre-paginated" && s > 1 && (r = a);
2545
- const d = a * s + n, f = r;
2546
- this.width = r, this.height = o, this.spreadWidth = d, this.pageWidth = c, this.delta = f, this.columnWidth = a, this.gap = n, this.divisor = s, this.update({
2535
+ let l, c;
2536
+ this._spread && r >= this._minSpreadWidth ? s = 2 : s = 1, this.name === "reflowable" && this._flow === "paginated" && !(i !== void 0 && i >= 0) && (n = h % 2 === 0 ? h : h - 1), this.name === "pre-paginated" && (n = 0), s > 1 ? (l = r / s - n, c = l + n) : (l = r, c = r), this.name === "pre-paginated" && s > 1 && (r = l);
2537
+ const d = l * s + n, f = r;
2538
+ this.width = r, this.height = o, this.spreadWidth = d, this.pageWidth = c, this.delta = f, this.columnWidth = l, this.gap = n, this.divisor = s, this.update({
2547
2539
  width: r,
2548
2540
  height: o,
2549
2541
  spreadWidth: d,
2550
2542
  pageWidth: c,
2551
2543
  delta: f,
2552
- columnWidth: a,
2544
+ columnWidth: l,
2553
2545
  gap: n,
2554
2546
  divisor: s
2555
2547
  });
@@ -2591,8 +2583,8 @@ class It {
2591
2583
  }
2592
2584
  }
2593
2585
  }
2594
- A(It.prototype);
2595
- class me {
2586
+ A(Ot.prototype);
2587
+ class ye {
2596
2588
  constructor(t) {
2597
2589
  this.rendition = t, this._themes = {
2598
2590
  default: {
@@ -2651,7 +2643,7 @@ class me {
2651
2643
  * @param {string} css
2652
2644
  */
2653
2645
  registerCss(t, e) {
2654
- this._themes[t] = { serialized: e }, (this._injected[t] || t == "default") && this.update(t);
2646
+ this._themes[t] = { serialized: e }, (this._injected[t] || t === "default") && this.update(t);
2655
2647
  }
2656
2648
  /**
2657
2649
  * Register a url
@@ -2659,8 +2651,8 @@ class me {
2659
2651
  * @param {string} input
2660
2652
  */
2661
2653
  registerUrl(t, e) {
2662
- const i = new R(e);
2663
- this._themes[t] = { url: i.toString() }, (this._injected[t] || t == "default") && this.update(t);
2654
+ const i = new N(e);
2655
+ this._themes[t] = { url: i.toString() }, (this._injected[t] || t === "default") && this.update(t);
2664
2656
  }
2665
2657
  /**
2666
2658
  * Register rule
@@ -2668,7 +2660,7 @@ class me {
2668
2660
  * @param {object} rules
2669
2661
  */
2670
2662
  registerRules(t, e) {
2671
- this._themes[t] = { rules: e }, (this._injected[t] || t == "default") && this.update(t);
2663
+ this._themes[t] = { rules: e }, (this._injected[t] || t === "default") && this.update(t);
2672
2664
  }
2673
2665
  /**
2674
2666
  * Select a theme
@@ -2698,7 +2690,7 @@ class me {
2698
2690
  let s;
2699
2691
  for (const n in i)
2700
2692
  i.hasOwnProperty(n) && (n === this._current || n === "default") && (s = i[n], (s.rules && Object.keys(s.rules).length > 0 || s.url && e.indexOf(s.url) === -1 || s.serialized) && this.add(n, t), this._injected.push(n));
2701
- this._current != "default" && t.addClass(this._current);
2693
+ this._current !== "default" && t.addClass(this._current);
2702
2694
  }
2703
2695
  /**
2704
2696
  * Add Theme to contents
@@ -2757,7 +2749,7 @@ class me {
2757
2749
  this.rendition = void 0, this._themes = void 0, this._overrides = void 0, this._current = void 0, this._injected = void 0;
2758
2750
  }
2759
2751
  }
2760
- class ve {
2752
+ class we {
2761
2753
  constructor(t) {
2762
2754
  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));
2763
2755
  }
@@ -2772,16 +2764,16 @@ class ve {
2772
2764
  * @returns {Annotation} annotation
2773
2765
  */
2774
2766
  add(t, e, i, s, n, r) {
2775
- const o = encodeURI(e + t), a = new m(e).spinePos, c = new Ot({
2767
+ const o = encodeURI(e + t), l = new m(e).spinePos, c = new zt({
2776
2768
  type: t,
2777
2769
  cfiRange: e,
2778
2770
  data: i,
2779
- sectionIndex: a,
2771
+ sectionIndex: l,
2780
2772
  cb: s,
2781
2773
  className: n,
2782
2774
  styles: r
2783
2775
  });
2784
- return this._annotations[o] = c, a in this._annotationsBySectionIndex ? this._annotationsBySectionIndex[a].push(o) : this._annotationsBySectionIndex[a] = [o], this.rendition.views().forEach((f) => {
2776
+ return this._annotations[o] = c, l in this._annotationsBySectionIndex ? this._annotationsBySectionIndex[l].push(o) : this._annotationsBySectionIndex[l] = [o], this.rendition.views().forEach((f) => {
2785
2777
  c.sectionIndex === f.index && c.attach(f);
2786
2778
  }), c;
2787
2779
  }
@@ -2891,7 +2883,7 @@ class ve {
2891
2883
  hide() {
2892
2884
  }
2893
2885
  }
2894
- class Ot {
2886
+ class zt {
2895
2887
  constructor({
2896
2888
  type: t,
2897
2889
  cfiRange: e,
@@ -2916,8 +2908,8 @@ class Ot {
2916
2908
  */
2917
2909
  attach(t) {
2918
2910
  const { cfiRange: e, data: i, type: s, mark: n, cb: r, className: o, styles: h } = this;
2919
- let a;
2920
- return s === "highlight" ? a = t.highlight(e, i, r, o, h) : s === "underline" ? a = t.underline(e, i, r, o, h) : s === "mark" && (a = t.mark(e, i, r)), this.mark = a, this.emit(u.ANNOTATION.ATTACH, a), a;
2911
+ let l;
2912
+ 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(u.ANNOTATION.ATTACH, l), l;
2921
2913
  }
2922
2914
  /**
2923
2915
  * Remove from a view
@@ -2934,8 +2926,8 @@ class Ot {
2934
2926
  text() {
2935
2927
  }
2936
2928
  }
2937
- A(Ot.prototype);
2938
- class ft {
2929
+ A(zt.prototype);
2930
+ class ut {
2939
2931
  constructor(t, e, i, s = !1) {
2940
2932
  this.layout = t, this.horizontal = i === "horizontal", this.direction = e || "ltr", this._dev = s;
2941
2933
  }
@@ -2962,8 +2954,8 @@ class ft {
2962
2954
  end: this.findEnd(n, i, s)
2963
2955
  });
2964
2956
  if (this._dev === !0) {
2965
- const o = t.document, h = new m(r.start).toRange(o), a = new m(r.end).toRange(o), c = o.defaultView.getSelection(), d = o.createRange();
2966
- c.removeAllRanges(), d.setStart(h.startContainer, h.startOffset), d.setEnd(a.endContainer, a.endOffset), c.addRange(d);
2957
+ const o = t.document, h = new m(r.start).toRange(o), l = new m(r.end).toRange(o), c = o.defaultView.getSelection(), d = o.createRange();
2958
+ c.removeAllRanges(), d.setStart(h.startContainer, h.startOffset), d.setEnd(l.endContainer, l.endOffset), c.addRange(d);
2967
2959
  }
2968
2960
  return r;
2969
2961
  }
@@ -2987,11 +2979,11 @@ class ft {
2987
2979
  }
2988
2980
  findRanges(t) {
2989
2981
  const e = [], i = t.contents.scrollWidth(), n = Math.ceil(i / this.layout.spreadWidth) * this.layout.divisor, r = this.layout.columnWidth, o = this.layout.gap;
2990
- let h, a;
2982
+ let h, l;
2991
2983
  for (let c = 0; c < n; c++)
2992
- h = (r + o) * c, a = r * (c + 1) + o * c, e.push({
2993
- start: this.findStart(t.document.body, h, a),
2994
- end: this.findEnd(t.document.body, h, a)
2984
+ h = (r + o) * c, l = r * (c + 1) + o * c, e.push({
2985
+ start: this.findStart(t.document.body, h, l),
2986
+ end: this.findEnd(t.document.body, h, l)
2995
2987
  });
2996
2988
  return e;
2997
2989
  }
@@ -3008,18 +3000,18 @@ class ft {
3008
3000
  let n, r, o = t;
3009
3001
  for (; s.length; )
3010
3002
  if (n = s.shift(), r = this.walk(n, (h) => {
3011
- let a, c, d, f;
3012
- const p = vt(h);
3003
+ let l, c, d, f;
3004
+ const p = gt(h);
3013
3005
  if (this.horizontal && this.direction === "ltr") {
3014
- if (a = this.horizontal ? p.left : p.top, c = this.horizontal ? p.right : p.bottom, a >= e && a <= i)
3006
+ if (l = this.horizontal ? p.left : p.top, c = this.horizontal ? p.right : p.bottom, l >= e && l <= i)
3015
3007
  return h;
3016
3008
  if (c > e)
3017
3009
  return h;
3018
3010
  o = h, s.push(h);
3019
3011
  } else if (this.horizontal && this.direction === "rtl") {
3020
- if (a = p.left, c = p.right, c <= i && c >= e)
3012
+ if (l = p.left, c = p.right, c <= i && c >= e)
3021
3013
  return h;
3022
- if (a < i)
3014
+ if (l < i)
3023
3015
  return h;
3024
3016
  o = h, s.push(h);
3025
3017
  } else {
@@ -3046,18 +3038,18 @@ class ft {
3046
3038
  let n, r = t, o;
3047
3039
  for (; s.length; )
3048
3040
  if (n = s.shift(), o = this.walk(n, (h) => {
3049
- let a, c, d, f;
3050
- const p = vt(h);
3041
+ let l, c, d, f;
3042
+ const p = gt(h);
3051
3043
  if (this.horizontal && this.direction === "ltr") {
3052
- if (a = Math.round(p.left), c = Math.round(p.right), a > i && r)
3044
+ if (l = Math.round(p.left), c = Math.round(p.right), l > i && r)
3053
3045
  return r;
3054
3046
  if (c > i)
3055
3047
  return h;
3056
3048
  r = h, s.push(h);
3057
3049
  } else if (this.horizontal && this.direction === "rtl") {
3058
- if (a = Math.round(this.horizontal ? p.left : p.top), c = Math.round(this.horizontal ? p.right : p.bottom), c < e && r)
3050
+ if (l = Math.round(this.horizontal ? p.left : p.top), c = Math.round(this.horizontal ? p.right : p.bottom), c < e && r)
3059
3051
  return r;
3060
- if (a < e)
3052
+ if (l < e)
3061
3053
  return h;
3062
3054
  r = h, s.push(h);
3063
3055
  } else {
@@ -3081,13 +3073,13 @@ class ft {
3081
3073
  */
3082
3074
  findTextStartRange(t, e, i) {
3083
3075
  const s = this.splitTextNodeIntoRanges(t);
3084
- let n, r, o, h, a;
3076
+ let n, r, o, h, l;
3085
3077
  for (let c = 0; c < s.length; c++)
3086
3078
  if (n = s[c], r = n.getBoundingClientRect(), this.horizontal && this.direction === "ltr") {
3087
3079
  if (o = r.left, o >= e)
3088
3080
  return n;
3089
3081
  } else if (this.horizontal && this.direction === "rtl") {
3090
- if (a = r.right, a <= i)
3082
+ if (l = r.right, l <= i)
3091
3083
  return n;
3092
3084
  } else if (h = r.top, h >= e)
3093
3085
  return n;
@@ -3103,15 +3095,15 @@ class ft {
3103
3095
  */
3104
3096
  findTextEndRange(t, e, i) {
3105
3097
  const s = this.splitTextNodeIntoRanges(t);
3106
- let n, r, o, h, a, c, d;
3098
+ let n, r, o, h, l, c, d;
3107
3099
  for (let f = 0; f < s.length; f++) {
3108
3100
  if (r = s[f], o = r.getBoundingClientRect(), this.horizontal && this.direction === "ltr") {
3109
- if (h = o.left, a = o.right, h > i && n)
3101
+ if (h = o.left, l = o.right, h > i && n)
3110
3102
  return n;
3111
- if (a > i)
3103
+ if (l > i)
3112
3104
  return r;
3113
3105
  } else if (this.horizontal && this.direction === "rtl") {
3114
- if (h = o.left, a = o.right, a < e && n)
3106
+ if (h = o.left, l = o.right, l < e && n)
3115
3107
  return n;
3116
3108
  if (h < e)
3117
3109
  return r;
@@ -3136,11 +3128,11 @@ class ft {
3136
3128
  const i = [], n = (t.textContent || "").trim();
3137
3129
  let r;
3138
3130
  const o = t.ownerDocument, h = e || " ";
3139
- let a = n.indexOf(h);
3140
- if (a === -1 || t.nodeType != Node.TEXT_NODE)
3131
+ let l = n.indexOf(h);
3132
+ if (l === -1 || t.nodeType !== Node.TEXT_NODE)
3141
3133
  return r = o.createRange(), r.selectNodeContents(t), [r];
3142
- for (r = o.createRange(), r.setStart(t, 0), r.setEnd(t, a), i.push(r), r = null; a != -1; )
3143
- a = n.indexOf(h, a + 1), a > 0 && (r && (r.setEnd(t, a), i.push(r)), r = o.createRange(), r.setStart(t, a + 1));
3134
+ for (r = o.createRange(), r.setStart(t, 0), r.setEnd(t, l), i.push(r), r = null; l !== -1; )
3135
+ l = n.indexOf(h, l + 1), l > 0 && (r && (r.setEnd(t, l), i.push(r)), r = o.createRange(), r.setStart(t, l + 1));
3144
3136
  return r && (r.setEnd(t, n.length), i.push(r)), i;
3145
3137
  }
3146
3138
  /**
@@ -3175,13 +3167,13 @@ class ft {
3175
3167
  return t && (this.horizontal = t === "horizontal"), this.horizontal;
3176
3168
  }
3177
3169
  }
3178
- const Pt = typeof navigator < "u", ye = Pt && /Chrome/.test(navigator.userAgent), St = Pt && !ye && /AppleWebKit/.test(navigator.userAgent), we = 1;
3179
- class zt {
3170
+ const be = typeof navigator < "u", Et = be && !/Chrome/.test(navigator.userAgent) && /AppleWebKit/.test(navigator.userAgent), xe = 1;
3171
+ class Dt {
3180
3172
  constructor(t, e, i, s) {
3181
3173
  this.epubcfi = new m(), this.document = t, this.documentElement = this.document.documentElement, this.content = e || this.document.body, this.window = this.document.defaultView, this._size = {
3182
3174
  width: 0,
3183
3175
  height: 0
3184
- }, this.sectionIndex = s || 0, this.cfiBase = i || "", this._mediaQueryHandlers = [], this.epubReadingSystem("epub.js", Nt), this.called = 0, this.active = !0, this.listeners();
3176
+ }, this.sectionIndex = s || 0, this.cfiBase = i || "", this._mediaQueryHandlers = [], this.epubReadingSystem("epub.js", It), this.called = 0, this.active = !0, this.listeners();
3185
3177
  }
3186
3178
  /**
3187
3179
  * Get DOM events that are listened for and passed along
@@ -3196,7 +3188,7 @@ class zt {
3196
3188
  */
3197
3189
  width(t) {
3198
3190
  const e = this.content;
3199
- return t && S(t) && (t = t + "px"), t && (e.style.width = t), parseInt(this.window.getComputedStyle(e).width);
3191
+ return t && E(t) && (t = t + "px"), t && (e.style.width = t), parseInt(this.window.getComputedStyle(e).width);
3200
3192
  }
3201
3193
  /**
3202
3194
  * Get or Set height
@@ -3205,7 +3197,7 @@ class zt {
3205
3197
  */
3206
3198
  height(t) {
3207
3199
  const e = this.content;
3208
- return t && S(t) && (t = t + "px"), t && (e.style.height = t), parseInt(this.window.getComputedStyle(e).height);
3200
+ return t && E(t) && (t = t + "px"), t && (e.style.height = t), parseInt(this.window.getComputedStyle(e).height);
3209
3201
  }
3210
3202
  /**
3211
3203
  * Get or Set width of the contents
@@ -3214,7 +3206,7 @@ class zt {
3214
3206
  */
3215
3207
  contentWidth(t) {
3216
3208
  const e = this.content || this.document.body;
3217
- return t && S(t) && (t = t + "px"), t && (e.style.width = t), parseInt(this.window.getComputedStyle(e).width);
3209
+ return t && E(t) && (t = t + "px"), t && (e.style.width = t), parseInt(this.window.getComputedStyle(e).width);
3218
3210
  }
3219
3211
  /**
3220
3212
  * Get or Set height of the contents
@@ -3223,7 +3215,7 @@ class zt {
3223
3215
  */
3224
3216
  contentHeight(t) {
3225
3217
  const e = this.content || this.document.body;
3226
- return t && S(t) && (t = t + "px"), t && (e.style.height = t), parseInt(this.window.getComputedStyle(e).height);
3218
+ return t && E(t) && (t = t + "px"), t && (e.style.height = t), parseInt(this.window.getComputedStyle(e).height);
3227
3219
  }
3228
3220
  /**
3229
3221
  * Get the width of the text using Range
@@ -3289,6 +3281,17 @@ class zt {
3289
3281
  const s = this.content || this.document.body;
3290
3282
  return e ? s.style.setProperty(t, e, i ? "important" : "") : s.style.removeProperty(t), this.window.getComputedStyle(s)[t] ?? "";
3291
3283
  }
3284
+ /**
3285
+ * Set multiple Css properties at once without triggering
3286
+ * intermediate getComputedStyle reads.
3287
+ * @param {Array<[string, string?, boolean?]>} properties
3288
+ * @private
3289
+ */
3290
+ cssBatch(t) {
3291
+ const e = this.content || this.document.body;
3292
+ for (const [i, s, n] of t)
3293
+ s ? e.style.setProperty(i, s, n ? "important" : "") : e.style.removeProperty(i);
3294
+ }
3292
3295
  /**
3293
3296
  * Get or Set the viewport element
3294
3297
  * @param {object} [options]
@@ -3311,10 +3314,10 @@ class zt {
3311
3314
  }, s = [];
3312
3315
  let n = {};
3313
3316
  if (e && e.hasAttribute("content")) {
3314
- const r = e.getAttribute("content") ?? "", o = r.match(/width\s*=\s*([^,]*)/), h = r.match(/height\s*=\s*([^,]*)/), a = r.match(/initial-scale\s*=\s*([^,]*)/), c = r.match(/minimum-scale\s*=\s*([^,]*)/), d = r.match(/maximum-scale\s*=\s*([^,]*)/), f = r.match(/user-scalable\s*=\s*([^,]*)/);
3315
- o && o.length && typeof o[1] < "u" && (i.width = o[1]), h && h.length && typeof h[1] < "u" && (i.height = h[1]), a && a.length && typeof a[1] < "u" && (i.scale = a[1]), c && c.length && typeof c[1] < "u" && (i.minimum = c[1]), d && d.length && typeof d[1] < "u" && (i.maximum = d[1]), f && f.length && typeof f[1] < "u" && (i.scalable = f[1]);
3317
+ 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*([^,]*)/), f = r.match(/user-scalable\s*=\s*([^,]*)/);
3318
+ 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]), f && f.length && typeof f[1] < "u" && (i.scalable = f[1]);
3316
3319
  }
3317
- return n = Xt(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;
3320
+ return n = Gt(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;
3318
3321
  }
3319
3322
  /**
3320
3323
  * Event emitter for when the contents has expanded
@@ -3328,17 +3331,17 @@ class zt {
3328
3331
  * @private
3329
3332
  */
3330
3333
  listeners() {
3331
- this.imageLoadListeners(), this.mediaQueryListeners(), this.fontLoadListeners(), this.addEventListeners(), this.addSelectionListeners(), typeof ResizeObserver > "u" ? (this.resizeListeners(), this.visibilityListeners()) : this.resizeObservers(), this.linksHandler();
3334
+ this.imageLoadListeners(), this.mediaQueryListeners(), this.fontLoadListeners(), this.addEventListeners(), this.addSelectionListeners(), this.resizeObservers(), this.linksHandler();
3332
3335
  }
3333
3336
  /**
3334
3337
  * Remove DOM listeners
3335
3338
  * @private
3336
3339
  */
3337
3340
  removeListeners() {
3338
- this.removeEventListeners(), this.removeSelectionListeners(), this._onVisibilityChange && (document.removeEventListener("visibilitychange", this._onVisibilityChange), this._onVisibilityChange = void 0), this._resizeCheck && (this.document.removeEventListener("transitionend", this._resizeCheck), this._resizeCheck = void 0);
3341
+ this.removeEventListeners(), this.removeSelectionListeners(), this._resizeCheck && (this.document.removeEventListener("transitionend", this._resizeCheck), this._resizeCheck = void 0);
3339
3342
  for (const { mql: e, handler: i } of this._mediaQueryHandlers)
3340
3343
  e.removeEventListener("change", i);
3341
- this._mediaQueryHandlers = [], this.observer && this.observer.disconnect(), clearTimeout(this.expanding);
3344
+ this._mediaQueryHandlers = [], this.observer && this.observer.disconnect();
3342
3345
  const t = this.document.querySelectorAll("img");
3343
3346
  for (let e = 0; e < t.length; e++)
3344
3347
  t[e].onload = null;
@@ -3350,27 +3353,11 @@ class zt {
3350
3353
  */
3351
3354
  resizeCheck() {
3352
3355
  const t = this.textWidth(), e = this.textHeight();
3353
- (t != this._size.width || e != this._size.height) && (this._size = {
3356
+ (t !== this._size.width || e !== this._size.height) && (this._size = {
3354
3357
  width: t,
3355
3358
  height: e
3356
3359
  }, this.onResize && this.onResize(this._size), this.emit(u.CONTENTS.RESIZE, this._size));
3357
3360
  }
3358
- /**
3359
- * Poll for resize detection
3360
- * @private
3361
- */
3362
- resizeListeners() {
3363
- clearTimeout(this.expanding), requestAnimationFrame(this.resizeCheck.bind(this)), this.expanding = setTimeout(this.resizeListeners.bind(this), 350);
3364
- }
3365
- /**
3366
- * Listen for visibility of tab to change
3367
- * @private
3368
- */
3369
- visibilityListeners() {
3370
- this._onVisibilityChange = () => {
3371
- document.visibilityState === "visible" && this.active === !1 ? (this.active = !0, this.resizeListeners()) : (this.active = !1, clearTimeout(this.expanding));
3372
- }, document.addEventListener("visibilitychange", this._onVisibilityChange);
3373
- }
3374
3361
  /**
3375
3362
  * Use css transitions to detect resize
3376
3363
  * @private
@@ -3386,7 +3373,7 @@ class zt {
3386
3373
  */
3387
3374
  mediaQueryListeners() {
3388
3375
  const t = this.document.styleSheets, e = (i) => {
3389
- i.matches && !this._expanding && setTimeout(this.expand.bind(this), 1);
3376
+ i.matches && !this._expanding && setTimeout(() => this.expand(), 0);
3390
3377
  };
3391
3378
  for (let i = 0; i < t.length; i += 1) {
3392
3379
  let s;
@@ -3463,19 +3450,19 @@ class zt {
3463
3450
  const n = new m(t).toRange(this.document, e);
3464
3451
  if (n) {
3465
3452
  try {
3466
- if (!n.endContainer || n.startContainer == n.endContainer && n.startOffset == n.endOffset) {
3453
+ if (!n.endContainer || n.startContainer === n.endContainer && n.startOffset === n.endOffset) {
3467
3454
  let r = (n.startContainer.textContent ?? "").indexOf(" ", n.startOffset);
3468
- r == -1 && (r = (n.startContainer.textContent ?? "").length), n.setEnd(n.startContainer, r);
3455
+ r === -1 && (r = (n.startContainer.textContent ?? "").length), n.setEnd(n.startContainer, r);
3469
3456
  }
3470
3457
  } catch (r) {
3471
3458
  console.error("setting end offset to start container length failed", r);
3472
3459
  }
3473
3460
  if (n.startContainer.nodeType === Node.ELEMENT_NODE)
3474
3461
  i = n.startContainer.getBoundingClientRect(), s.left = i.left, s.top = i.top;
3475
- else if (St) {
3462
+ else if (Et) {
3476
3463
  const r = n.startContainer, o = new Range();
3477
3464
  try {
3478
- r.nodeType === we ? 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();
3465
+ r.nodeType === xe ? 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();
3479
3466
  } catch (h) {
3480
3467
  console.error(h, h instanceof Error ? h.stack : void 0);
3481
3468
  }
@@ -3485,7 +3472,7 @@ class zt {
3485
3472
  } else if (typeof t == "string" && t.indexOf("#") > -1) {
3486
3473
  const n = t.substring(t.indexOf("#") + 1), r = this.document.getElementById(n);
3487
3474
  if (r)
3488
- if (St) {
3475
+ if (Et) {
3489
3476
  const o = new Range();
3490
3477
  o.selectNode(r), i = o.getBoundingClientRect();
3491
3478
  } else
@@ -3511,7 +3498,7 @@ class zt {
3511
3498
  s = this.document.createElement("link"), s.type = "text/css", s.rel = "stylesheet", s.href = t, s.onload = () => {
3512
3499
  n || (n = !0, setTimeout(() => {
3513
3500
  e(!0);
3514
- }, 1));
3501
+ }, 0));
3515
3502
  }, this.document.head.appendChild(s);
3516
3503
  });
3517
3504
  }
@@ -3542,25 +3529,25 @@ class zt {
3542
3529
  if (Array.isArray(t))
3543
3530
  for (let s = 0, n = t.length; s < n; s++) {
3544
3531
  let r = 1, o = t[s], h = "";
3545
- const a = t[s][0];
3532
+ const l = t[s][0];
3546
3533
  Array.isArray(o[1]?.[0]) && (o = o[1], r = 0);
3547
3534
  for (let c = o.length; r < c; r++) {
3548
3535
  const d = o[r];
3549
3536
  h += d[0] + ":" + d[1] + (d[2] ? " !important" : "") + `;
3550
3537
  `;
3551
3538
  }
3552
- i.insertRule(a + "{" + h + "}", i.cssRules.length);
3539
+ i.insertRule(l + "{" + h + "}", i.cssRules.length);
3553
3540
  }
3554
3541
  else
3555
3542
  Object.keys(t).forEach((n) => {
3556
3543
  const r = t[n];
3557
3544
  if (Array.isArray(r))
3558
3545
  r.forEach((o) => {
3559
- const a = Object.keys(o).map((c) => `${c}:${o[c]}`).join(";");
3560
- i.insertRule(`${n}{${a}}`, i.cssRules.length);
3546
+ const l = Object.keys(o).map((c) => `${c}:${o[c]}`).join(";");
3547
+ i.insertRule(`${n}{${l}}`, i.cssRules.length);
3561
3548
  });
3562
3549
  else {
3563
- const h = Object.keys(r).map((a) => `${a}:${r[a]}`).join(";");
3550
+ const h = Object.keys(r).map((l) => `${l}:${r[l]}`).join(";");
3564
3551
  i.insertRule(`${n}{${h}}`, i.cssRules.length);
3565
3552
  }
3566
3553
  });
@@ -3581,7 +3568,7 @@ class zt {
3581
3568
  n.type = "text/javascript", n.async = !0, n.src = t, n.onload = () => {
3582
3569
  s || (s = !0, setTimeout(() => {
3583
3570
  e(!0);
3584
- }, 1));
3571
+ }, 0));
3585
3572
  }, this.document.head.appendChild(n);
3586
3573
  });
3587
3574
  }
@@ -3694,7 +3681,12 @@ class zt {
3694
3681
  */
3695
3682
  size(t, e) {
3696
3683
  const i = { scale: 1, scalable: "no" };
3697
- this.layoutStyle("scrolling"), t !== void 0 && t >= 0 && (this.width(t), i.width = t, this.css("padding", "0 " + t / 12 + "px")), e !== void 0 && e >= 0 && (this.height(e), i.height = e), this.css("margin", "0"), this.css("box-sizing", "border-box"), this.viewport(i);
3684
+ this.layoutStyle("scrolling");
3685
+ const s = [];
3686
+ t !== void 0 && t >= 0 && (this.width(t), i.width = t, s.push(["padding", "0 " + t / 12 + "px"])), e !== void 0 && e >= 0 && (this.height(e), i.height = e), s.push(
3687
+ ["margin", "0"],
3688
+ ["box-sizing", "border-box"]
3689
+ ), this.cssBatch(s), this.viewport(i);
3698
3690
  }
3699
3691
  /**
3700
3692
  * Apply columns to the contents for pagination
@@ -3704,8 +3696,37 @@ class zt {
3704
3696
  * @param {number} gap
3705
3697
  */
3706
3698
  columns(t, e, i, s, n) {
3707
- const r = j("column-axis"), o = j("column-gap"), h = j("column-width"), a = j("column-fill"), d = this.writingMode().indexOf("vertical") === 0 ? "vertical" : "horizontal";
3708
- this.layoutStyle("paginated"), n === "rtl" && d === "horizontal" && this.direction(n), this.width(t), this.height(e), this.viewport({ width: t, height: e, scale: 1, scalable: "no" }), this.css("display", "inline-block"), this.css("overflow-y", "hidden"), this.css("margin", "0", !0), d === "vertical" ? (this.css("padding-top", s / 2 + "px", !0), this.css("padding-bottom", s / 2 + "px", !0), this.css("padding-left", "20px"), this.css("padding-right", "20px"), this.css(r, "vertical")) : (this.css("padding-top", "20px"), this.css("padding-bottom", "20px"), this.css("padding-left", s / 2 + "px", !0), this.css("padding-right", s / 2 + "px", !0), this.css(r, "horizontal")), this.css("box-sizing", "border-box"), this.css("max-width", "inherit"), this.css(a, "auto"), this.css(o, s + "px"), this.css(h, i + "px");
3699
+ const r = "-webkit-column-axis", o = "column-gap", h = "column-width", l = "column-fill", d = this.writingMode().indexOf("vertical") === 0 ? "vertical" : "horizontal";
3700
+ this.layoutStyle("paginated"), n === "rtl" && d === "horizontal" && this.direction(n), this.width(t), this.height(e), this.viewport({ width: t, height: e, scale: 1, scalable: "no" });
3701
+ const f = [
3702
+ // Fixes Safari column cut offs, but causes RTL issues.
3703
+ // Required on iOS: block-level body in CSS columns triggers a
3704
+ // WKWebView content-size expansion feedback loop where scrollWidth
3705
+ // grows toward infinity. inline-block shrink-wraps the body to
3706
+ // its explicit width, breaking the cycle.
3707
+ ["display", "inline-block"],
3708
+ ["overflow-y", "hidden"],
3709
+ ["margin", "0", !0]
3710
+ ];
3711
+ d === "vertical" ? f.push(
3712
+ ["padding-top", s / 2 + "px", !0],
3713
+ ["padding-bottom", s / 2 + "px", !0],
3714
+ ["padding-left", "20px"],
3715
+ ["padding-right", "20px"],
3716
+ [r, "vertical"]
3717
+ ) : f.push(
3718
+ ["padding-top", "20px"],
3719
+ ["padding-bottom", "20px"],
3720
+ ["padding-left", s / 2 + "px", !0],
3721
+ ["padding-right", s / 2 + "px", !0],
3722
+ [r, "horizontal"]
3723
+ ), f.push(
3724
+ ["box-sizing", "border-box"],
3725
+ ["max-width", "inherit"],
3726
+ [l, "auto"],
3727
+ [o, s + "px"],
3728
+ [h, i + "px"]
3729
+ ), this.cssBatch(f);
3709
3730
  }
3710
3731
  /**
3711
3732
  * Scale contents from center
@@ -3724,11 +3745,18 @@ class zt {
3724
3745
  * @param {number} height
3725
3746
  */
3726
3747
  fit(t, e, i) {
3727
- const s = this.viewport(), n = parseInt(s.width), r = parseInt(s.height), o = t / n, h = e / r, a = o < h ? o : h;
3728
- if (this.layoutStyle("paginated"), this.width(n), this.height(r), this.overflow("hidden"), this.scaler(a, 0, 0), this.css("background-size", n * a + "px " + r * a + "px"), this.css("background-color", "transparent"), i && i.properties.includes("page-spread-left")) {
3729
- const c = t - n * a;
3730
- this.css("margin-left", c + "px");
3748
+ const s = this.viewport(), n = parseInt(s.width), r = parseInt(s.height), o = t / n, h = e / r, l = o < h ? o : h;
3749
+ this.layoutStyle("paginated"), this.width(n), this.height(r), this.overflow("hidden"), this.scaler(l, 0, 0);
3750
+ const c = [
3751
+ // background images are not scaled by transform
3752
+ ["background-size", n * l + "px " + r * l + "px"],
3753
+ ["background-color", "transparent"]
3754
+ ];
3755
+ if (i && i.properties.includes("page-spread-left")) {
3756
+ const d = t - n * l;
3757
+ c.push(["margin-left", d + "px"]);
3731
3758
  }
3759
+ this.cssBatch(c);
3732
3760
  }
3733
3761
  /**
3734
3762
  * Set the direction of the text
@@ -3738,14 +3766,14 @@ class zt {
3738
3766
  this.documentElement && (this.documentElement.style.direction = t);
3739
3767
  }
3740
3768
  mapPage(t, e, i, s, n) {
3741
- return new ft(e, void 0, void 0, n).page(this, t, i, s);
3769
+ return new ut(e, void 0, void 0, n).page(this, t, i, s);
3742
3770
  }
3743
3771
  /**
3744
3772
  * Emit event when link in content is clicked
3745
3773
  * @private
3746
3774
  */
3747
3775
  linksHandler() {
3748
- le(this.content, (t) => {
3776
+ ce(this.content, (t) => {
3749
3777
  this.emit(u.CONTENTS.LINK_CLICKED, t);
3750
3778
  });
3751
3779
  }
@@ -3754,8 +3782,7 @@ class zt {
3754
3782
  * @param {string} [mode="horizontal-tb"] "horizontal-tb" | "vertical-rl" | "vertical-lr"
3755
3783
  */
3756
3784
  writingMode(t) {
3757
- const e = j("writing-mode");
3758
- return t && this.documentElement && (this.documentElement.style[e] = t), this.window.getComputedStyle(this.documentElement)[e] || "";
3785
+ return t && this.documentElement && (this.documentElement.style.writingMode = t), this.window.getComputedStyle(this.documentElement).writingMode || "";
3759
3786
  }
3760
3787
  /**
3761
3788
  * Set the layoutStyle of the content
@@ -3800,41 +3827,41 @@ class zt {
3800
3827
  this.removeListeners(), this.__listeners = {};
3801
3828
  }
3802
3829
  }
3803
- A(zt.prototype);
3804
- function X(l) {
3805
- return document.createElementNS("http://www.w3.org/2000/svg", l);
3830
+ A(Dt.prototype);
3831
+ function X(a) {
3832
+ return document.createElementNS("http://www.w3.org/2000/svg", a);
3806
3833
  }
3807
- function be(l, t) {
3834
+ function Ee(a, t) {
3808
3835
  function e(s) {
3809
3836
  for (let n = t.length - 1; n >= 0; n--) {
3810
3837
  const r = t[n];
3811
3838
  let o, h;
3812
- if ("touches" in s && s.touches.length ? (o = s.touches[0].clientX, h = s.touches[0].clientY) : (o = s.clientX, h = s.clientY), !!Ee(r, l, o, h)) {
3813
- r.dispatchEvent(xe(s));
3839
+ if ("touches" in s && s.touches.length ? (o = s.touches[0].clientX, h = s.touches[0].clientY) : (o = s.clientX, h = s.clientY), !!Ce(r, a, o, h)) {
3840
+ r.dispatchEvent(Se(s));
3814
3841
  break;
3815
3842
  }
3816
3843
  }
3817
3844
  }
3818
3845
  let i;
3819
- if (l.nodeName === "iframe" || l.nodeName === "IFRAME")
3846
+ if (a.nodeName === "iframe" || a.nodeName === "IFRAME")
3820
3847
  try {
3821
- i = l.contentDocument;
3848
+ i = a.contentDocument;
3822
3849
  } catch {
3823
- i = l;
3850
+ i = a;
3824
3851
  }
3825
3852
  else
3826
- i = l;
3853
+ i = a;
3827
3854
  for (const s of ["mouseup", "mousedown", "click", "touchstart"])
3828
3855
  i.addEventListener(s, (n) => e(n), !1);
3829
3856
  }
3830
- function xe(l) {
3831
- const t = Object.assign({}, l, { bubbles: !1 });
3857
+ function Se(a) {
3858
+ const t = Object.assign({}, a, { bubbles: !1 });
3832
3859
  try {
3833
- return new MouseEvent(l.type, t);
3860
+ return new MouseEvent(a.type, t);
3834
3861
  } catch {
3835
- const i = l, s = document.createEvent("MouseEvents");
3862
+ const i = a, s = document.createEvent("MouseEvents");
3836
3863
  return s.initMouseEvent(
3837
- l.type,
3864
+ a.type,
3838
3865
  !1,
3839
3866
  i.cancelable,
3840
3867
  i.view,
@@ -3852,39 +3879,39 @@ function xe(l) {
3852
3879
  ), s;
3853
3880
  }
3854
3881
  }
3855
- function Ee(l, t, e, i) {
3882
+ function Ce(a, t, e, i) {
3856
3883
  const s = t.getBoundingClientRect();
3857
- function n(h, a, c) {
3884
+ function n(h, l, c) {
3858
3885
  const d = h.top - s.top, f = h.left - s.left, p = d + h.height, g = f + h.width;
3859
- return d <= c && f <= a && p > c && g > a;
3886
+ return d <= c && f <= l && p > c && g > l;
3860
3887
  }
3861
- const r = l.getBoundingClientRect();
3888
+ const r = a.getBoundingClientRect();
3862
3889
  if (!n(r, e, i))
3863
3890
  return !1;
3864
- const o = l.getClientRects();
3865
- for (let h = 0, a = o.length; h < a; h++)
3891
+ const o = a.getClientRects();
3892
+ for (let h = 0, l = o.length; h < l; h++)
3866
3893
  if (n(o[h], e, i))
3867
3894
  return !0;
3868
3895
  return !1;
3869
3896
  }
3870
- function Se(l, t) {
3871
- const e = t.getBoundingClientRect(), i = l.getBoundingClientRect();
3897
+ function _e(a, t) {
3898
+ const e = t.getBoundingClientRect(), i = a.getBoundingClientRect();
3872
3899
  return {
3873
3900
  top: i.top - e.top,
3874
3901
  left: i.left - e.left,
3875
- height: l.scrollHeight,
3876
- width: l.scrollWidth
3902
+ height: a.scrollHeight,
3903
+ width: a.scrollWidth
3877
3904
  };
3878
3905
  }
3879
- function Ce(l, t) {
3880
- l.style.setProperty("top", `${t.top}px`, "important"), l.style.setProperty("left", `${t.left}px`, "important"), l.style.setProperty("height", `${t.height}px`, "important"), l.style.setProperty("width", `${t.width}px`, "important");
3906
+ function Te(a, t) {
3907
+ 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");
3881
3908
  }
3882
- function _e(l, t) {
3883
- return t.right <= l.right && t.left >= l.left && t.top >= l.top && t.bottom <= l.bottom;
3909
+ function ke(a, t) {
3910
+ return t.right <= a.right && t.left >= a.left && t.top >= a.top && t.bottom <= a.bottom;
3884
3911
  }
3885
- class Ct {
3912
+ class St {
3886
3913
  constructor(t, e = document.body) {
3887
- this.target = t, this.element = X("svg"), this.marks = [], this.element.style.position = "absolute", this.element.setAttribute("pointer-events", "none"), be(this.target, this.marks), this.container = e, this.container.appendChild(this.element), this.render();
3914
+ this.target = t, this.element = X("svg"), this.marks = [], this.element.style.position = "absolute", this.element.setAttribute("pointer-events", "none"), Ee(this.target, this.marks), this.container = e, this.container.appendChild(this.element), this.render();
3888
3915
  }
3889
3916
  addMark(t) {
3890
3917
  const e = X("g");
@@ -3898,12 +3925,12 @@ class Ct {
3898
3925
  this.element.removeChild(i), this.marks.splice(e, 1);
3899
3926
  }
3900
3927
  render() {
3901
- Ce(this.element, Se(this.target, this.container));
3928
+ Te(this.element, _e(this.target, this.container));
3902
3929
  for (const t of this.marks)
3903
3930
  t.render();
3904
3931
  }
3905
3932
  }
3906
- class Te {
3933
+ class Le {
3907
3934
  constructor() {
3908
3935
  this.element = null;
3909
3936
  }
@@ -3935,14 +3962,14 @@ class Te {
3935
3962
  for (let i = 0; i < t.length; i++) {
3936
3963
  if (t[i] === e)
3937
3964
  return !0;
3938
- if (_e(t[i], e))
3965
+ if (ke(t[i], e))
3939
3966
  return !1;
3940
3967
  }
3941
3968
  return !0;
3942
3969
  });
3943
3970
  }
3944
3971
  }
3945
- class Dt extends Te {
3972
+ class Bt extends Le {
3946
3973
  constructor(t, e, i, s) {
3947
3974
  super(), this.range = t, this.className = e, this.data = i || {}, this.attributes = s || {};
3948
3975
  }
@@ -3965,7 +3992,7 @@ class Dt extends Te {
3965
3992
  this.element.appendChild(t);
3966
3993
  }
3967
3994
  }
3968
- class Le extends Dt {
3995
+ class Ne extends Bt {
3969
3996
  constructor(t, e, i, s) {
3970
3997
  super(t, e, i, s);
3971
3998
  }
@@ -3976,13 +4003,13 @@ class Le extends Dt {
3976
4003
  for (let n = 0, r = e.length; n < r; n++) {
3977
4004
  const o = e[n], h = X("rect");
3978
4005
  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");
3979
- const a = X("line");
3980
- a.setAttribute("x1", String(o.left - i.left + s.left)), a.setAttribute("x2", String(o.left - i.left + s.left + o.width)), a.setAttribute("y1", String(o.top - i.top + s.top + o.height - 1)), a.setAttribute("y2", String(o.top - i.top + s.top + o.height - 1)), a.setAttribute("stroke-width", "1"), a.setAttribute("stroke", "black"), a.setAttribute("stroke-linecap", "square"), t.appendChild(h), t.appendChild(a);
4006
+ const l = X("line");
4007
+ 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);
3981
4008
  }
3982
4009
  this.element.appendChild(t);
3983
4010
  }
3984
4011
  }
3985
- class Bt {
4012
+ class Mt {
3986
4013
  constructor(t, e) {
3987
4014
  this.settings = _({
3988
4015
  ignoreClass: "",
@@ -3997,14 +4024,14 @@ class Bt {
3997
4024
  forceRight: !1,
3998
4025
  allowScriptedContent: !1,
3999
4026
  allowPopups: !1
4000
- }, e || {}), this.id = "epubjs-view-" + gt(), this.section = t, this.index = t.index, this.element = this.container(this.settings.axis), this.added = !1, this.displayed = !1, this.rendered = !1, this.fixedWidth = 0, this.fixedHeight = 0, this.epubcfi = new m(), this.layout = this.settings.layout, this.pane = void 0, this.highlights = {}, this.underlines = {}, this.marks = {};
4027
+ }, e || {}), this.id = "epubjs-view-" + kt(), this.section = t, this.index = t.index, this.element = this.container(this.settings.axis), this.added = !1, this.displayed = !1, this.rendered = !1, this.fixedWidth = 0, this.fixedHeight = 0, this.epubcfi = new m(), this.layout = this.settings.layout, this.pane = void 0, this.highlights = {}, this.underlines = {}, this.marks = {};
4001
4028
  }
4002
4029
  container(t) {
4003
4030
  const e = document.createElement("div");
4004
- return e.classList.add("epub-view"), e.style.height = "0px", e.style.width = "0px", e.style.overflow = "hidden", e.style.position = "relative", e.style.display = "block", t && t == "horizontal" ? e.style.flex = "none" : e.style.flex = "initial", e;
4031
+ return e.classList.add("epub-view"), e.style.height = "0px", e.style.width = "0px", e.style.overflow = "hidden", e.style.position = "relative", e.style.display = "block", t && t === "horizontal" ? e.style.flex = "none" : e.style.flex = "initial", e;
4005
4032
  }
4006
4033
  create() {
4007
- return this.iframe ? this.iframe : (this.element || (this.element = this.container()), this.iframe = document.createElement("iframe"), this.iframe.id = this.id, this.iframe.scrolling = "no", this.iframe.style.overflow = "hidden", this.iframe.setAttribute("seamless", "seamless"), this.iframe.style.border = "none", this.iframe.sandbox = "allow-same-origin", this.settings.allowScriptedContent && (this.iframe.sandbox += " allow-scripts"), this.settings.allowPopups && (this.iframe.sandbox += " allow-popups"), this.iframe.setAttribute("enable-annotation", "true"), this.resizing = !0, this.element.style.visibility = "hidden", this.iframe.style.visibility = "hidden", this.iframe.style.width = "0", this.iframe.style.height = "0", this._width = 0, this._height = 0, this.element.setAttribute("ref", String(this.index)), this.added = !0, this.elementBounds = tt(this.element), "srcdoc" in this.iframe ? this.supportsSrcdoc = !0 : this.supportsSrcdoc = !1, this.settings.method || (this.settings.method = this.supportsSrcdoc ? "srcdoc" : "write"), this.iframe);
4034
+ return this.iframe ? this.iframe : (this.element || (this.element = this.container()), this.iframe = document.createElement("iframe"), this.iframe.id = this.id, this.iframe.scrolling = "no", this.iframe.style.overflow = "hidden", this.iframe.setAttribute("seamless", "seamless"), this.iframe.style.border = "none", this.iframe.sandbox = "allow-same-origin", this.settings.allowScriptedContent && (this.iframe.sandbox += " allow-scripts"), this.settings.allowPopups && (this.iframe.sandbox += " allow-popups"), this.iframe.setAttribute("enable-annotation", "true"), this.resizing = !0, this.element.style.visibility = "hidden", this.iframe.style.visibility = "hidden", this.iframe.style.width = "0", this.iframe.style.height = "0", this._width = 0, this._height = 0, this.element.setAttribute("ref", String(this.index)), this.added = !0, this.elementBounds = J(this.element), "srcdoc" in this.iframe ? this.supportsSrcdoc = !0 : this.supportsSrcdoc = !1, this.settings.method || (this.settings.method = this.supportsSrcdoc ? "srcdoc" : "write"), this.iframe);
4008
4035
  }
4009
4036
  render(t, e) {
4010
4037
  return this.create(), this.size(), this.sectionRender || (this.sectionRender = this.section.render(t)), this.sectionRender.then((i) => this.load(i)).then(() => {
@@ -4031,15 +4058,15 @@ class Bt {
4031
4058
  lock(t, e, i) {
4032
4059
  const s = ht(this.element);
4033
4060
  let n;
4034
- this.iframe ? n = ht(this.iframe) : n = { width: 0, height: 0 }, t == "width" && S(e) && (this.lockedWidth = e - s.width - n.width), t == "height" && S(i) && (this.lockedHeight = i - s.height - n.height), t === "both" && S(e) && S(i) && (this.lockedWidth = e - s.width - n.width, this.lockedHeight = i - s.height - n.height), this.displayed && this.iframe && this.expand();
4061
+ this.iframe ? n = ht(this.iframe) : n = { width: 0, height: 0 }, t === "width" && E(e) && (this.lockedWidth = e - s.width - n.width), t === "height" && E(i) && (this.lockedHeight = i - s.height - n.height), t === "both" && E(e) && E(i) && (this.lockedWidth = e - s.width - n.width, this.lockedHeight = i - s.height - n.height), this.displayed && this.iframe && this.expand();
4035
4062
  }
4036
4063
  // Resize a single axis based on content dimensions
4037
4064
  expand(t) {
4038
4065
  let e = this.lockedWidth, i = this.lockedHeight, s;
4039
- !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);
4066
+ !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);
4040
4067
  }
4041
4068
  reframe(t, e) {
4042
- S(t) && (this.element.style.width = t + "px", this.iframe.style.width = t + "px", this._width = t), S(e) && (this.element.style.height = e + "px", this.iframe.style.height = e + "px", this._height = e);
4069
+ E(t) && (this.element.style.width = t + "px", this.iframe.style.width = t + "px", this._width = t), E(e) && (this.element.style.height = e + "px", this.iframe.style.height = e + "px", this._height = e);
4043
4070
  const i = this.prevBounds ? t - this.prevBounds.width : t, s = this.prevBounds ? e - this.prevBounds.height : e, n = {
4044
4071
  width: t,
4045
4072
  height: e,
@@ -4050,10 +4077,10 @@ class Bt {
4050
4077
  let r;
4051
4078
  for (const o in this.marks)
4052
4079
  this.marks.hasOwnProperty(o) && (r = this.marks[o], this.placeMark(r.element, r.range));
4053
- }), this.onResize(this, n), this.emit(u.VIEWS.RESIZED, n), this.prevBounds = n, this.elementBounds = tt(this.element);
4080
+ }), this.onResize(this, n), this.emit(u.VIEWS.RESIZED, n), this.prevBounds = n, this.elementBounds = J(this.element);
4054
4081
  }
4055
4082
  load(t) {
4056
- const e = new v(), i = e.promise;
4083
+ const e = new S(), i = e.promise;
4057
4084
  if (!this.iframe)
4058
4085
  return e.reject(new Error("No Iframe Available")), i;
4059
4086
  if (this.iframe.onload = (s) => {
@@ -4070,7 +4097,7 @@ class Bt {
4070
4097
  return i;
4071
4098
  }
4072
4099
  onLoad(t, e) {
4073
- this.window = this.iframe.contentWindow, this.document = this.iframe.contentDocument, this.contents = new zt(this.document, this.document.body, this.section.cfiBase, this.section.index), this.rendering = !1;
4100
+ this.window = this.iframe.contentWindow, this.document = this.iframe.contentDocument, this.contents = new Dt(this.document, this.document.body, this.section.cfiBase, this.section.index), this.rendering = !1;
4074
4101
  let i = this.document.querySelector("link[rel='canonical']");
4075
4102
  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(u.CONTENTS.EXPAND, () => {
4076
4103
  this.displayed && this.iframe && (this.expand(), this.contents && this.layout.format(this.contents));
@@ -4082,7 +4109,7 @@ class Bt {
4082
4109
  this.layout = t, this.contents && (this.layout.format(this.contents), this.expand());
4083
4110
  }
4084
4111
  setAxis(t) {
4085
- this.settings.axis = t, t == "horizontal" ? this.element.style.flex = "none" : this.element.style.flex = "initial", this.size();
4112
+ this.settings.axis = t, t === "horizontal" ? this.element.style.flex = "none" : this.element.style.flex = "initial", this.size();
4086
4113
  }
4087
4114
  setWritingMode(t) {
4088
4115
  this.writingMode = t;
@@ -4093,7 +4120,7 @@ class Bt {
4093
4120
  this.contents && (this.contents.off(u.CONTENTS.EXPAND), this.contents.off(u.CONTENTS.RESIZE));
4094
4121
  }
4095
4122
  display(t) {
4096
- const e = new v();
4123
+ const e = new S();
4097
4124
  return this.displayed ? e.resolve(this) : this.render(t).then(() => {
4098
4125
  this.emit(u.VIEWS.DISPLAYED, this), this.onDisplayed(this), this.displayed = !0, e.resolve(this);
4099
4126
  }, (i) => {
@@ -4134,7 +4161,7 @@ class Bt {
4134
4161
  onResize(t, e) {
4135
4162
  }
4136
4163
  bounds(t) {
4137
- return (t || !this.elementBounds) && (this.elementBounds = tt(this.element)), this.elementBounds;
4164
+ return (t || !this.elementBounds) && (this.elementBounds = J(this.element)), this.elementBounds;
4138
4165
  }
4139
4166
  highlight(t, e = {}, i, s = "epubjs-hl", n = {}) {
4140
4167
  if (!this.contents)
@@ -4142,11 +4169,11 @@ class Bt {
4142
4169
  const r = Object.assign({ fill: "yellow", "fill-opacity": "0.3", "mix-blend-mode": "multiply" }, n), o = this.contents.range(t), h = (d) => {
4143
4170
  this.emit(u.VIEWS.MARK_CLICKED, t, e);
4144
4171
  };
4145
- e.epubcfi = t, this.pane || (this.pane = new Ct(this.iframe, this.element));
4146
- const a = new Dt(o, s, e, r);
4172
+ e.epubcfi = t, this.pane || (this.pane = new St(this.iframe, this.element));
4173
+ const l = new Bt(o, s, e, r);
4147
4174
  let c;
4148
4175
  try {
4149
- c = this.pane.addMark(a);
4176
+ c = this.pane.addMark(l);
4150
4177
  } catch (d) {
4151
4178
  console.error("Failed to add highlight for", t, d);
4152
4179
  return;
@@ -4159,11 +4186,11 @@ class Bt {
4159
4186
  const r = Object.assign({ stroke: "black", "stroke-opacity": "0.3", "mix-blend-mode": "multiply" }, n), o = this.contents.range(t), h = (d) => {
4160
4187
  this.emit(u.VIEWS.MARK_CLICKED, t, e);
4161
4188
  };
4162
- e.epubcfi = t, this.pane || (this.pane = new Ct(this.iframe, this.element));
4163
- const a = new Le(o, s, e, r);
4189
+ e.epubcfi = t, this.pane || (this.pane = new St(this.iframe, this.element));
4190
+ const l = new Ne(o, s, e, r);
4164
4191
  let c;
4165
4192
  try {
4166
- c = this.pane.addMark(a);
4193
+ c = this.pane.addMark(l);
4167
4194
  } catch (d) {
4168
4195
  console.error("Failed to add underline for", t, d);
4169
4196
  return;
@@ -4178,13 +4205,13 @@ class Bt {
4178
4205
  let s = this.contents.range(t);
4179
4206
  if (!s)
4180
4207
  return;
4181
- const n = s.commonAncestorContainer, r = n.nodeType === 1 ? n : n.parentNode, o = (a) => {
4208
+ const n = s.commonAncestorContainer, r = n.nodeType === 1 ? n : n.parentNode, o = (l) => {
4182
4209
  this.emit(u.VIEWS.MARK_CLICKED, t, e);
4183
4210
  };
4184
4211
  s.collapsed && n.nodeType === 1 ? (s = new Range(), s.selectNodeContents(n)) : s.collapsed && (s = new Range(), s.selectNodeContents(r));
4185
4212
  const h = this.document.createElement("a");
4186
- return h.setAttribute("ref", "epubjs-mk"), h.style.position = "absolute", h.dataset.epubcfi = t, e && Object.keys(e).forEach((a) => {
4187
- h.dataset[a] = e[a];
4213
+ return h.setAttribute("ref", "epubjs-mk"), h.style.position = "absolute", h.dataset.epubcfi = t, e && Object.keys(e).forEach((l) => {
4214
+ h.dataset[l] = e[l];
4188
4215
  }), i && (h.addEventListener("click", i), h.addEventListener("touchstart", i)), h.addEventListener("click", o), h.addEventListener("touchstart", o), this.placeMark(h, s), this.element.appendChild(h), this.marks[t] = { element: h, range: s, listeners: [o, i] }, r;
4189
4216
  }
4190
4217
  placeMark(t, e) {
@@ -4195,7 +4222,7 @@ class Bt {
4195
4222
  } else {
4196
4223
  const r = e.getClientRects();
4197
4224
  let o;
4198
- for (let h = 0; h != r.length; h++)
4225
+ for (let h = 0; h !== r.length; h++)
4199
4226
  o = r[h], (!n || o.left < n) && (n = o.left, s = Math.ceil(n / this.layout.props.pageWidth) * this.layout.props.pageWidth - this.layout.gap / 2, i = o.top);
4200
4227
  }
4201
4228
  t.style.top = `${i}px`, t.style.left = `${s}px`;
@@ -4231,37 +4258,37 @@ class Bt {
4231
4258
  this.ununderline(t);
4232
4259
  for (const t in this.marks)
4233
4260
  this.unmark(t);
4234
- this.blobUrl && kt(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 = {};
4261
+ this.blobUrl && Rt(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 = {};
4235
4262
  }
4236
4263
  }
4237
- A(Bt.prototype);
4238
- function ke() {
4239
- let l = "reverse";
4240
- const t = Re();
4241
- return document.body.appendChild(t), t.scrollLeft > 0 ? l = "default" : typeof Element < "u" && typeof Element.prototype.scrollIntoView == "function" ? (t.children[0].children[1].scrollIntoView(), t.scrollLeft < 0 && (l = "negative")) : (t.scrollLeft = 1, t.scrollLeft === 0 && (l = "negative")), document.body.removeChild(t), l;
4242
- }
4264
+ A(Mt.prototype);
4243
4265
  function Re() {
4244
- const l = document.createElement("div");
4245
- l.dir = "rtl", l.style.position = "fixed", l.style.width = "1px", l.style.height = "1px", l.style.top = "0px", l.style.left = "0px", l.style.overflow = "hidden";
4266
+ let a = "reverse";
4267
+ const t = Ae();
4268
+ 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;
4269
+ }
4270
+ function Ae() {
4271
+ const a = document.createElement("div");
4272
+ 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";
4246
4273
  const t = document.createElement("div");
4247
4274
  t.style.width = "2px";
4248
4275
  const e = document.createElement("span");
4249
4276
  e.style.width = "1px", e.style.display = "inline-block";
4250
4277
  const i = document.createElement("span");
4251
- return i.style.width = "1px", i.style.display = "inline-block", t.appendChild(e), t.appendChild(i), l.appendChild(t), l;
4278
+ return i.style.width = "1px", i.style.display = "inline-block", t.appendChild(e), t.appendChild(i), a.appendChild(t), a;
4252
4279
  }
4253
- function Ne(l, t) {
4280
+ function Ie(a, t) {
4254
4281
  let e = null, i = 0;
4255
4282
  return function(...s) {
4256
4283
  const n = Date.now(), r = t - (n - i);
4257
- r <= 0 || r > t ? (e && (clearTimeout(e), e = null), i = n, l.call(this, ...s)) : e || (e = setTimeout(() => {
4258
- i = Date.now(), e = null, l.call(this, ...s);
4284
+ r <= 0 || r > t ? (e && (clearTimeout(e), e = null), i = n, a.call(this, ...s)) : e || (e = setTimeout(() => {
4285
+ i = Date.now(), e = null, a.call(this, ...s);
4259
4286
  }, r));
4260
4287
  };
4261
4288
  }
4262
- class Ae {
4289
+ class Pe {
4263
4290
  constructor(t) {
4264
- this.settings = t || {}, this.id = "epubjs-container-" + gt(), this.container = this.create(this.settings), this.settings.hidden && (this.wrapper = this.wrap(this.container));
4291
+ this.settings = t || {}, this.id = "epubjs-container-" + kt(), this.container = this.create(this.settings), this.settings.hidden && (this.wrapper = this.wrap(this.container));
4265
4292
  }
4266
4293
  /*
4267
4294
  * Creates an element to render to.
@@ -4270,7 +4297,7 @@ class Ae {
4270
4297
  create(t) {
4271
4298
  let e = t.height, i = t.width;
4272
4299
  const s = t.overflow || !1, n = t.axis || "vertical", r = t.direction;
4273
- _(this.settings, t), t.height && S(t.height) && (e = t.height + "px"), t.width && S(t.width) && (i = t.width + "px");
4300
+ _(this.settings, t), t.height && E(t.height) && (e = t.height + "px"), t.width && E(t.width) && (i = t.width + "px");
4274
4301
  const o = document.createElement("div");
4275
4302
  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;
4276
4303
  }
@@ -4280,7 +4307,7 @@ class Ae {
4280
4307
  }
4281
4308
  getElement(t) {
4282
4309
  let e = null;
4283
- if (Vt(t) ? e = t : typeof t == "string" && (e = document.getElementById(t)), !e)
4310
+ if (Xt(t) ? e = t : typeof t == "string" && (e = document.getElementById(t)), !e)
4284
4311
  throw new Error("Not an Element");
4285
4312
  return e;
4286
4313
  }
@@ -4294,7 +4321,7 @@ class Ae {
4294
4321
  return this.container;
4295
4322
  }
4296
4323
  onResize(t) {
4297
- (!S(this.settings.width) || !S(this.settings.height)) && (this.resizeFunc = Ne(t, 50), window.addEventListener("resize", this.resizeFunc, !1));
4324
+ (!E(this.settings.width) || !E(this.settings.height)) && (this.resizeFunc = Ie(t, 50), window.addEventListener("resize", this.resizeFunc, !1));
4298
4325
  }
4299
4326
  onOrientationChange(t) {
4300
4327
  this.orientationChangeFunc = t, window.addEventListener("orientationchange", this.orientationChangeFunc, !1);
@@ -4302,13 +4329,13 @@ class Ae {
4302
4329
  size(t, e) {
4303
4330
  let i;
4304
4331
  const s = t || this.settings.width, n = e || this.settings.height;
4305
- t === null ? (i = this.element.getBoundingClientRect(), i.width && (t = Math.floor(i.width), this.container.style.width = t + "px")) : S(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")) : S(e) ? this.container.style.height = e + "px" : e && (this.container.style.height = e), S(t) || (t = this.container.clientWidth), S(e) || (e = this.container.clientHeight), this.containerStyles = window.getComputedStyle(this.container), this.containerPadding = {
4332
+ t === null ? (i = this.element.getBoundingClientRect(), i.width && (t = Math.floor(i.width), this.container.style.width = t + "px")) : E(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")) : E(e) ? this.container.style.height = e + "px" : e && (this.container.style.height = e), E(t) || (t = this.container.clientWidth), E(e) || (e = this.container.clientHeight), this.containerStyles = window.getComputedStyle(this.container), this.containerPadding = {
4306
4333
  left: parseFloat(this.containerStyles.paddingLeft) || 0,
4307
4334
  right: parseFloat(this.containerStyles.paddingRight) || 0,
4308
4335
  top: parseFloat(this.containerStyles.paddingTop) || 0,
4309
4336
  bottom: parseFloat(this.containerStyles.paddingBottom) || 0
4310
4337
  };
4311
- const r = lt(), o = window.getComputedStyle(document.body), h = {
4338
+ const r = mt(), o = window.getComputedStyle(document.body), h = {
4312
4339
  left: parseFloat(o.paddingLeft) || 0,
4313
4340
  right: parseFloat(o.paddingRight) || 0,
4314
4341
  top: parseFloat(o.paddingTop) || 0,
@@ -4321,7 +4348,7 @@ class Ae {
4321
4348
  }
4322
4349
  bounds() {
4323
4350
  let t;
4324
- return this.container.style.overflow !== "visible" && (t = this.container && this.container.getBoundingClientRect()), !t || !t.width || !t.height ? lt() : t;
4351
+ return this.container.style.overflow !== "visible" && (t = this.container && this.container.getBoundingClientRect()), !t || !t.width || !t.height ? mt() : t;
4325
4352
  }
4326
4353
  getSheet() {
4327
4354
  const t = document.createElement("style");
@@ -4357,7 +4384,7 @@ class Ae {
4357
4384
  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));
4358
4385
  }
4359
4386
  }
4360
- class Ie {
4387
+ class Oe {
4361
4388
  constructor(t) {
4362
4389
  this.container = t, this._views = [], this.length = 0, this.hidden = !1;
4363
4390
  }
@@ -4412,7 +4439,7 @@ class Ie {
4412
4439
  let e;
4413
4440
  const i = this.length;
4414
4441
  for (let s = 0; s < i; s++)
4415
- if (e = this._views[s], e.displayed && e.section.index == t.index)
4442
+ if (e = this._views[s], e.displayed && e.section.index === t.index)
4416
4443
  return e;
4417
4444
  }
4418
4445
  displayed() {
@@ -4438,9 +4465,9 @@ class Ie {
4438
4465
  this.hidden = !0;
4439
4466
  }
4440
4467
  }
4441
- class Z {
4468
+ class K {
4442
4469
  constructor(t) {
4443
- this.name = "default", this.optsSettings = t.settings, this.View = t.view, this.request = t.request, this.renditionQueue = t.queue, this.q = new mt(this), this.settings = _({}, {
4470
+ this.name = "default", this.optsSettings = t.settings, this.View = t.view, this.request = t.request, this.renditionQueue = t.queue, this.q = new pt(this), this.settings = _({}, {
4444
4471
  infinite: !0,
4445
4472
  hidden: !1,
4446
4473
  width: void 0,
@@ -4468,7 +4495,7 @@ class Z {
4468
4495
  }
4469
4496
  render(t, e) {
4470
4497
  const i = t.tagName;
4471
- 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 = ke(), this.stage = new Ae({
4498
+ 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 = Re(), this.stage = new Pe({
4472
4499
  width: e.width,
4473
4500
  height: e.height,
4474
4501
  overflow: this.overflow,
@@ -4476,7 +4503,7 @@ class Z {
4476
4503
  axis: this.settings.axis,
4477
4504
  fullsize: this.settings.fullsize,
4478
4505
  direction: this.settings.direction
4479
- }), this.stage.attachTo(t), this.container = this.stage.getContainer(), this.views = new Ie(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;
4506
+ }), this.stage.attachTo(t), this.container = this.stage.getContainer(), this.views = new Oe(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;
4480
4507
  }
4481
4508
  addEventListeners() {
4482
4509
  let t;
@@ -4489,23 +4516,17 @@ class Z {
4489
4516
  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;
4490
4517
  }
4491
4518
  destroy() {
4492
- clearTimeout(this.orientationTimeout), clearTimeout(this.resizeTimeout), clearTimeout(this.afterScrolled), this.clear(), this.removeEventListeners(), this.stage.destroy(), this.rendered = !1, this.__listeners = {};
4519
+ clearTimeout(this.resizeTimeout), clearTimeout(this.afterScrolled), this.clear(), this.removeEventListeners(), this.stage.destroy(), this.rendered = !1, this.__listeners = {};
4493
4520
  }
4494
4521
  onOrientationChange(t) {
4495
4522
  const { orientation: e } = window;
4496
- this.optsSettings?.resizeOnOrientationChange && this.resize(), clearTimeout(this.orientationTimeout), this.orientationTimeout = setTimeout(() => {
4497
- this.orientationTimeout = void 0, this.optsSettings?.resizeOnOrientationChange && this.resize(), this.emit(u.MANAGERS.ORIENTATION_CHANGE, e);
4498
- }, 500);
4523
+ this.optsSettings?.resizeOnOrientationChange && this.resize(), this.emit(u.MANAGERS.ORIENTATION_CHANGE, e);
4499
4524
  }
4500
4525
  onResized(t) {
4501
4526
  this.resize();
4502
4527
  }
4503
4528
  resize(t, e, i) {
4504
4529
  const s = this.stage.size(t, e);
4505
- if (this.winBounds = lt(), this.orientationTimeout && this.winBounds.width === this.winBounds.height) {
4506
- this._stageSize = void 0;
4507
- return;
4508
- }
4509
4530
  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(u.MANAGERS.RESIZED, {
4510
4531
  width: this._stageSize.width,
4511
4532
  height: this._stageSize.height
@@ -4524,8 +4545,8 @@ class Z {
4524
4545
  }
4525
4546
  }
4526
4547
  display(t, e) {
4527
- const i = new v(), s = i.promise;
4528
- (e === t.href || S(e)) && (e = void 0);
4548
+ const i = new S(), s = i.promise;
4549
+ (e === t.href || E(e)) && (e = void 0);
4529
4550
  const n = this.views.find(t);
4530
4551
  if (n && t && this.layout.name !== "pre-paginated") {
4531
4552
  const o = n.offset();
@@ -4536,8 +4557,8 @@ class Z {
4536
4557
  this.scrollTo(o.left + h, o.top, !0);
4537
4558
  }
4538
4559
  if (e) {
4539
- const h = n.locationOf(e), a = n.width();
4540
- this.moveTo(h, a);
4560
+ const h = n.locationOf(e), l = n.width();
4561
+ this.moveTo(h, l);
4541
4562
  }
4542
4563
  return i.resolve(), s;
4543
4564
  }
@@ -4545,8 +4566,8 @@ class Z {
4545
4566
  let r = !1;
4546
4567
  return this.layout.name === "pre-paginated" && this.layout.divisor === 2 && t.properties.includes("page-spread-right") && (r = !0), this.add(t, r).then((o) => {
4547
4568
  if (e) {
4548
- const h = o.locationOf(e), a = o.width();
4549
- this.moveTo(h, a);
4569
+ const h = o.locationOf(e), l = o.width();
4570
+ this.moveTo(h, l);
4550
4571
  }
4551
4572
  }, (o) => {
4552
4573
  i.reject(o);
@@ -4709,21 +4730,21 @@ class Z {
4709
4730
  this.settings.direction;
4710
4731
  let r = 0;
4711
4732
  const o = 0;
4712
- return this.settings.fullsize && (r = n ? window.scrollY : window.scrollX), t.map((a) => {
4713
- const c = a.section.index, d = a.section.href, f = a.position(), p = a.width(), g = a.height();
4714
- let y, w, x, T;
4715
- n ? (y = r + e.top - f.top + o, w = y + i - o, T = this.layout.count(g, i).pages, x = i) : (y = r + e.left - f.left + o, w = y + s - o, T = this.layout.count(p, s).pages, x = s);
4716
- let E = Math.ceil(y / x), C = [], I = Math.ceil(w / x);
4733
+ return this.settings.fullsize && (r = n ? window.scrollY : window.scrollX), t.map((l) => {
4734
+ const c = l.section.index, d = l.section.href, f = l.position(), p = l.width(), g = l.height();
4735
+ let v, y, b, T;
4736
+ n ? (v = r + e.top - f.top + o, y = v + i - o, T = this.layout.count(g, i).pages, b = i) : (v = r + e.left - f.left + o, y = v + s - o, T = this.layout.count(p, s).pages, b = s);
4737
+ let x = Math.ceil(v / b), C = [], I = Math.ceil(y / b);
4717
4738
  if (this.settings.direction === "rtl" && !n) {
4718
- const B = E;
4719
- E = T - I, I = T - B;
4739
+ const D = x;
4740
+ x = T - I, I = T - D;
4720
4741
  }
4721
4742
  C = [];
4722
- for (let B = E; B <= I; B++) {
4723
- const z = B + 1;
4724
- C.push(z);
4743
+ for (let D = x; D <= I; D++) {
4744
+ const O = D + 1;
4745
+ C.push(O);
4725
4746
  }
4726
- const Y = this.mapping.page(a.contents, a.section.cfiBase, y, w);
4747
+ const Y = this.mapping.page(l.contents, l.section.cfiBase, v, y);
4727
4748
  return {
4728
4749
  index: c,
4729
4750
  href: d,
@@ -4738,19 +4759,19 @@ class Z {
4738
4759
  let i = 0, s = 0;
4739
4760
  return this.settings.fullsize && (i = window.scrollX), t.map((r) => {
4740
4761
  const o = r.section.index, h = r.section.href;
4741
- let a;
4762
+ let l;
4742
4763
  const c = r.position(), d = r.width();
4743
4764
  let f, p, g;
4744
- this.settings.direction === "rtl" ? (a = e.right - i, g = Math.min(Math.abs(a - c.left), this.layout.width) - s, p = c.width - (c.right - a) - s, f = p - g) : (a = e.left + i, g = Math.min(c.right - a, this.layout.width) - s, f = a - c.left + s, p = f + g), s += g;
4745
- const y = this.mapping.page(r.contents, r.section.cfiBase, f, p), w = this.layout.count(d).pages;
4746
- let x = Math.floor(f / this.layout.pageWidth);
4765
+ 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, f = p - g) : (l = e.left + i, g = Math.min(c.right - l, this.layout.width) - s, f = l - c.left + s, p = f + g), s += g;
4766
+ const v = this.mapping.page(r.contents, r.section.cfiBase, f, p), y = this.layout.count(d).pages;
4767
+ let b = Math.floor(f / this.layout.pageWidth);
4747
4768
  const T = [];
4748
- let E = Math.floor(p / this.layout.pageWidth);
4749
- if (x < 0 && (x = 0, E = E + 1), this.settings.direction === "rtl") {
4750
- const C = x;
4751
- x = w - E, E = w - C;
4769
+ let x = Math.floor(p / this.layout.pageWidth);
4770
+ if (b < 0 && (b = 0, x = x + 1), this.settings.direction === "rtl") {
4771
+ const C = b;
4772
+ b = y - x, x = y - C;
4752
4773
  }
4753
- for (let C = x + 1; C <= E; C++) {
4774
+ for (let C = b + 1; C <= x; C++) {
4754
4775
  const I = C;
4755
4776
  T.push(I);
4756
4777
  }
@@ -4758,8 +4779,8 @@ class Z {
4758
4779
  index: o,
4759
4780
  href: h,
4760
4781
  pages: T,
4761
- totalPages: w,
4762
- mapping: y
4782
+ totalPages: y,
4783
+ mapping: v
4763
4784
  };
4764
4785
  });
4765
4786
  }
@@ -4807,7 +4828,7 @@ class Z {
4807
4828
  ), 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));
4808
4829
  }
4809
4830
  setLayout(t) {
4810
- this.viewSettings.layout = t, this.mapping = new ft(t.props, this.settings.direction, this.settings.axis), this.views && this.views.forEach((e) => {
4831
+ this.viewSettings.layout = t, this.mapping = new ut(t.props, this.settings.direction, this.settings.axis), this.views && this.views.forEach((e) => {
4811
4832
  e && e.setLayout(t);
4812
4833
  });
4813
4834
  }
@@ -4815,7 +4836,7 @@ class Z {
4815
4836
  this.writingMode = t;
4816
4837
  }
4817
4838
  updateAxis(t, e) {
4818
- !e && t === this.settings.axis || (this.settings.axis = t, this.stage && this.stage.axis(t), this.viewSettings.axis = t, this.mapping && (this.mapping = new ft(this.layout.props, this.settings.direction, this.settings.axis)), this.layout && (t === "vertical" ? this.layout.spread("none") : this.layout.spread(this.layout.settings.spread)));
4839
+ !e && t === this.settings.axis || (this.settings.axis = t, this.stage && this.stage.axis(t), this.viewSettings.axis = t, this.mapping && (this.mapping = new ut(this.layout.props, this.settings.direction, this.settings.axis)), this.layout && (t === "vertical" ? this.layout.spread("none") : this.layout.spread(this.layout.settings.spread)));
4819
4840
  }
4820
4841
  updateFlow(t, e = "auto") {
4821
4842
  const i = t === "paginated" || t === "auto";
@@ -4835,23 +4856,23 @@ class Z {
4835
4856
  return this.rendered;
4836
4857
  }
4837
4858
  }
4838
- A(Z.prototype);
4839
- const Oe = {
4840
- easeInCubic: function(l) {
4841
- return Math.pow(l, 3);
4859
+ A(K.prototype);
4860
+ const ze = {
4861
+ easeInCubic: function(a) {
4862
+ return Math.pow(a, 3);
4842
4863
  }
4843
4864
  };
4844
- class pt {
4865
+ class ft {
4845
4866
  constructor(t, e) {
4846
4867
  this.settings = _({
4847
4868
  duration: 80,
4848
4869
  minVelocity: 0.2,
4849
4870
  minDistance: 10,
4850
- easing: Oe.easeInCubic
4871
+ easing: ze.easeInCubic
4851
4872
  }, e || {}), this._supportsTouch = this.supportsTouch(), this._supportsTouch && this.setup(t);
4852
4873
  }
4853
4874
  setup(t) {
4854
- this.manager = t, this.layout = this.manager.layout, this.fullsize = this.manager.settings.fullsize ?? !1, this.fullsize ? (this.element = this.manager.stage.element, this.scroller = window, this.disableScroll()) : (this.element = this.manager.stage.container, this.scroller = this.element, this.element.style.setProperty("-webkit-overflow-scrolling", "touch")), this.manager.settings.offset = this.layout.width, this.manager.settings.afterScrolledTimeout = this.settings.duration * 2, this.isVertical = this.manager.settings.axis === "vertical", !(!this.manager.isPaginated || this.isVertical) && (this.touchCanceler = !1, this.resizeCanceler = !1, this.snapping = !1, this.scrollLeft, this.scrollTop, this.startTouchX = void 0, this.startTouchY = void 0, this.startTime = void 0, this.endTouchX = void 0, this.endTouchY = void 0, this.endTime = void 0, this.addListeners());
4875
+ this.manager = t, this.layout = this.manager.layout, this.fullsize = this.manager.settings.fullsize ?? !1, this.fullsize ? (this.element = this.manager.stage.element, this.scroller = window, this.disableScroll()) : (this.element = this.manager.stage.container, this.scroller = this.element), this.manager.settings.offset = this.layout.width, this.manager.settings.afterScrolledTimeout = this.settings.duration * 2, this.isVertical = this.manager.settings.axis === "vertical", !(!this.manager.isPaginated || this.isVertical) && (this.touchCanceler = !1, this.resizeCanceler = !1, this.snapping = !1, this.scrollLeft, this.scrollTop, this.startTouchX = void 0, this.startTouchY = void 0, this.startTime = void 0, this.endTouchX = void 0, this.endTouchY = void 0, this.endTime = void 0, this.addListeners());
4855
4876
  }
4856
4877
  supportsTouch() {
4857
4878
  return "ontouchstart" in window || "DocumentTouch" in window;
@@ -4912,38 +4933,39 @@ class pt {
4912
4933
  return t && (s += t * i), this.smoothScrollTo(s);
4913
4934
  }
4914
4935
  smoothScrollTo(t) {
4915
- const e = new v(), i = this.scrollLeft, s = this.now(), n = this.settings.duration, r = this.settings.easing;
4916
- this.snapping = !0;
4917
- const o = () => {
4918
- const h = this.now(), a = Math.min(1, (h - s) / n);
4919
- if (r(a), this.touchCanceler || this.resizeCanceler) {
4920
- this.resizeCanceler = !1, this.snapping = !1, e.resolve();
4921
- return;
4922
- }
4923
- a < 1 ? (window.requestAnimationFrame(o), this.scrollTo(i + (t - i) * a, 0)) : (this.scrollTo(t, 0), this.snapping = !1, e.resolve());
4924
- };
4925
- return o(), e.promise;
4936
+ const e = this.scrollLeft, i = this.now(), s = this.settings.duration, n = this.settings.easing;
4937
+ return this.snapping = !0, new Promise((r) => {
4938
+ const o = () => {
4939
+ const h = this.now(), l = Math.min(1, (h - i) / s), c = n(l);
4940
+ if (this.touchCanceler || this.resizeCanceler) {
4941
+ this.resizeCanceler = !1, this.snapping = !1, r();
4942
+ return;
4943
+ }
4944
+ l < 1 ? (window.requestAnimationFrame(o), this.scrollTo(e + (t - e) * c, 0)) : (this.scrollTo(t, 0), this.snapping = !1, r());
4945
+ };
4946
+ o();
4947
+ });
4926
4948
  }
4927
4949
  scrollTo(t = 0, e = 0) {
4928
4950
  this.fullsize ? window.scroll(t, e) : (this.scroller.scrollLeft = t, this.scroller.scrollTop = e);
4929
4951
  }
4930
4952
  now() {
4931
- return "now" in window.performance ? performance.now() : (/* @__PURE__ */ new Date()).getTime();
4953
+ return performance.now();
4932
4954
  }
4933
4955
  destroy() {
4934
4956
  this.scroller && (this.fullsize && this.enableScroll(), this.removeListeners(), this.scroller = void 0);
4935
4957
  }
4936
4958
  }
4937
- A(pt.prototype);
4938
- function Pe(l, t) {
4959
+ A(ft.prototype);
4960
+ function De(a, t) {
4939
4961
  let e;
4940
4962
  return function(...i) {
4941
4963
  clearTimeout(e), e = setTimeout(() => {
4942
- l.call(this, ...i);
4964
+ a.call(this, ...i);
4943
4965
  }, t);
4944
4966
  };
4945
4967
  }
4946
- class ze extends Z {
4968
+ class Be extends K {
4947
4969
  constructor(t) {
4948
4970
  super(t), this.name = "continuous", this.settings = _({}, {
4949
4971
  infinite: !0,
@@ -4974,13 +4996,12 @@ class ze extends Z {
4974
4996
  }, this.scrollTop = 0, this.scrollLeft = 0;
4975
4997
  }
4976
4998
  display(t, e) {
4977
- return Z.prototype.display.call(this, t, e).then(() => this.fill());
4999
+ return K.prototype.display.call(this, t, e).then(() => this.fill());
4978
5000
  }
4979
- fill(t) {
4980
- const e = t || new v();
4981
- return this.q.enqueue(() => this.check()).then((i) => {
4982
- i ? this.fill(e) : e.resolve();
4983
- }), e.promise;
5001
+ async fill() {
5002
+ let t = !0;
5003
+ for (; t; )
5004
+ t = await this.q.enqueue(() => this.check());
4984
5005
  }
4985
5006
  moveTo(t) {
4986
5007
  let e = 0, i = 0;
@@ -5032,7 +5053,7 @@ class ze extends Z {
5032
5053
  update(t) {
5033
5054
  const e = this.bounds(), i = this.views.all(), s = i.length, n = typeof t < "u" ? t : this.settings.offset || 0;
5034
5055
  let r, o;
5035
- const h = new v(), a = [];
5056
+ const h = new S(), l = [];
5036
5057
  for (let c = 0; c < s; c++)
5037
5058
  if (o = i[c], r = this.isVisible(o, n, n, e), r === !0)
5038
5059
  if (o.displayed)
@@ -5043,46 +5064,46 @@ class ze extends Z {
5043
5064
  }, (f) => {
5044
5065
  o.hide();
5045
5066
  });
5046
- a.push(d);
5067
+ l.push(d);
5047
5068
  }
5048
5069
  else
5049
5070
  this.q.enqueue(() => o.destroy()), clearTimeout(this.trimTimeout), this.trimTimeout = setTimeout(() => {
5050
5071
  this.q.enqueue(() => this.trim());
5051
5072
  }, 250);
5052
- return a.length ? Promise.all(a).catch((c) => {
5073
+ return l.length ? Promise.all(l).catch((c) => {
5053
5074
  h.reject(c);
5054
5075
  }) : (h.resolve(), h.promise);
5055
5076
  }
5056
5077
  check(t, e) {
5057
- const i = new v(), s = [], n = this.settings.axis === "horizontal";
5078
+ const i = new S(), s = [], n = this.settings.axis === "horizontal";
5058
5079
  let r = this.settings.offset || 0;
5059
5080
  t && n && (r = t), e && !n && (r = e);
5060
5081
  const o = this._bounds;
5061
5082
  let h = n ? this.scrollLeft : this.scrollTop;
5062
- const a = 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", f = this.settings.rtlScrollType, p = this.settings.direction === "rtl";
5063
- this.settings.fullsize ? (n && p && f === "negative" || !n && p && f === "default") && (h = h * -1) : (p && f === "default" && d === "horizontal" && (h = c - a - h), p && f === "negative" && d === "horizontal" && (h = h * -1));
5083
+ 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", f = this.settings.rtlScrollType, p = this.settings.direction === "rtl";
5084
+ this.settings.fullsize ? (n && p && f === "negative" || !n && p && f === "default") && (h = h * -1) : (p && f === "default" && d === "horizontal" && (h = c - l - h), p && f === "negative" && d === "horizontal" && (h = h * -1));
5064
5085
  const g = () => {
5065
- const E = this.views.first(), C = E && E.section.prev?.();
5086
+ const x = this.views.first(), C = x && x.section.prev?.();
5066
5087
  C && s.push(this.prepend(C));
5067
- }, y = () => {
5068
- const E = this.views.last(), C = E && E.section.next?.();
5088
+ }, v = () => {
5089
+ const x = this.views.last(), C = x && x.section.next?.();
5069
5090
  C && s.push(this.append(C));
5070
- }, w = h + a + r, x = h - r;
5071
- w >= c && y(), x < 0 && g();
5072
- const T = s.map((E) => E.display(this.request));
5073
- return s.length ? Promise.all(T).then(() => this.check()).then(() => this.update(r), (E) => E) : (this.q.enqueue(() => {
5091
+ }, y = h + l + r, b = h - r;
5092
+ y >= c && v(), b < 0 && g();
5093
+ const T = s.map((x) => x.display(this.request));
5094
+ return s.length ? Promise.all(T).then(() => this.check()).then(() => this.update(r), (x) => x) : (this.q.enqueue(() => {
5074
5095
  this.update();
5075
5096
  }), i.resolve(!1), i.promise);
5076
5097
  }
5077
5098
  trim() {
5078
- const t = new v(), e = this.views.displayed();
5099
+ const t = new S(), e = this.views.displayed();
5079
5100
  if (!e.length)
5080
5101
  return t.resolve(), t.promise;
5081
5102
  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);
5082
- for (let a = 0; a < o.length - 1; a++)
5083
- this.erase(o[a], o);
5084
- for (let a = 1; a < h.length; a++)
5085
- this.erase(h[a]);
5103
+ for (let l = 0; l < o.length - 1; l++)
5104
+ this.erase(o[l], o);
5105
+ for (let l = 1; l < h.length; l++)
5106
+ this.erase(h[l]);
5086
5107
  return t.resolve(), t.promise;
5087
5108
  }
5088
5109
  erase(t, e) {
@@ -5094,13 +5115,12 @@ class ze extends Z {
5094
5115
  addEventListeners(t) {
5095
5116
  this._onUnload = (e) => {
5096
5117
  this.ignore = !0, this.destroy();
5097
- }, window.addEventListener("unload", this._onUnload), this.addScrollListeners(), this.isPaginated && this.settings.snap && (this.snapper = new pt(this, typeof this.settings.snap == "object" ? this.settings.snap : void 0));
5118
+ }, window.addEventListener("unload", this._onUnload), this.addScrollListeners(), this.isPaginated && this.settings.snap && (this.snapper = new ft(this, typeof this.settings.snap == "object" ? this.settings.snap : void 0));
5098
5119
  }
5099
5120
  addScrollListeners() {
5100
5121
  let t;
5101
- this.tick = Tt;
5102
5122
  const e = this.settings.direction === "rtl" && this.settings.rtlScrollType === "default" ? -1 : 1;
5103
- 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 = Pe(() => this.scrolled(), 30), this.didScroll = !1;
5123
+ 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 = De(() => this.scrolled(), 30), this.didScroll = !1;
5104
5124
  }
5105
5125
  removeEventListeners() {
5106
5126
  let t;
@@ -5133,13 +5153,13 @@ class ze extends Z {
5133
5153
  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()));
5134
5154
  }
5135
5155
  updateFlow(t) {
5136
- 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 pt(this, typeof this.settings.snap == "object" ? this.settings.snap : void 0));
5156
+ 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 ft(this, typeof this.settings.snap == "object" ? this.settings.snap : void 0));
5137
5157
  }
5138
5158
  destroy() {
5139
5159
  clearTimeout(this.scrollTimeout), clearTimeout(this.trimTimeout), super.destroy(), this.snapper && this.snapper.destroy();
5140
5160
  }
5141
5161
  }
5142
- class Mt {
5162
+ class Wt {
5143
5163
  constructor(t, e) {
5144
5164
  this.settings = _({}, {
5145
5165
  width: null,
@@ -5158,7 +5178,7 @@ class Mt {
5158
5178
  defaultDirection: "ltr",
5159
5179
  allowScriptedContent: !1,
5160
5180
  allowPopups: !1
5161
- }), _(this.settings, e), typeof this.settings.manager == "object" && (this.manager = this.settings.manager), this.book = t, this.hooks = {}, this.hooks.display = new N(this), this.hooks.serialize = new N(this), this.hooks.content = new N(this), this.hooks.unloaded = new N(this), this.hooks.layout = new N(this), this.hooks.render = new N(this), this.hooks.show = new N(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 me(this), this.annotations = new ve(this), this.epubcfi = new m(), this.q = new mt(this), this.location = void 0, this.q.enqueue(this.book.opened), this.starting = new v(), this.started = this.starting.promise, this.q.enqueue(this.start);
5181
+ }), _(this.settings, e), typeof this.settings.manager == "object" && (this.manager = this.settings.manager), this.book = t, this.hooks = {}, this.hooks.display = new R(this), this.hooks.serialize = new R(this), this.hooks.content = new R(this), this.hooks.unloaded = new R(this), this.hooks.layout = new R(this), this.hooks.render = new R(this), this.hooks.show = new R(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 ye(this), this.annotations = new we(this), this.epubcfi = new m(), this.q = new pt(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);
5162
5182
  }
5163
5183
  /**
5164
5184
  * Set the manager function
@@ -5174,7 +5194,7 @@ class Mt {
5174
5194
  */
5175
5195
  requireManager(t) {
5176
5196
  let e;
5177
- return typeof t == "string" && t === "default" ? e = Z : typeof t == "string" && t === "continuous" ? e = ze : e = t, e;
5197
+ return typeof t == "string" && t === "default" ? e = K : typeof t == "string" && t === "continuous" ? e = Be : e = t, e;
5178
5198
  }
5179
5199
  /**
5180
5200
  * Require the view from passed string, or as a class function
@@ -5183,7 +5203,7 @@ class Mt {
5183
5203
  */
5184
5204
  requireView(t) {
5185
5205
  let e;
5186
- return typeof t == "string" && t === "iframe" ? e = Bt : e = t, e;
5206
+ return typeof t == "string" && t === "iframe" ? e = Mt : e = t, e;
5187
5207
  }
5188
5208
  /**
5189
5209
  * Start the rendering
@@ -5240,8 +5260,8 @@ class Mt {
5240
5260
  if (!this.book)
5241
5261
  return;
5242
5262
  this.epubcfi.isCfiString(t);
5243
- const e = new v(), i = e.promise;
5244
- this.displaying = e, this.book.locations.length() && Ht(t) && (t = this.book.locations.cfiFromPercentage(parseFloat(t)));
5263
+ const e = new S(), i = e.promise;
5264
+ this.displaying = e, this.book.locations.length() && Yt(t) && (t = this.book.locations.cfiFromPercentage(parseFloat(t)));
5245
5265
  const s = this.book.spine.get(t);
5246
5266
  return s ? (this.manager.display(s, t).then(() => {
5247
5267
  e.resolve(s), this.displaying = void 0, this.emit(u.RENDITION.DISPLAYED, s), this.reportLocation();
@@ -5404,7 +5424,7 @@ class Mt {
5404
5424
  * @param {object} settings
5405
5425
  */
5406
5426
  layout(t) {
5407
- return t && (this._layout = new It(t), this._layout.spread(t.spread, this.settings.minSpreadWidth), this._layout.on(u.LAYOUT.UPDATED, (e, i) => {
5427
+ return t && (this._layout = new Ot(t), this._layout.spread(t.spread, this.settings.minSpreadWidth), this._layout.on(u.LAYOUT.UPDATED, (e, i) => {
5408
5428
  this.emit(u.RENDITION.LAYOUT, e, i);
5409
5429
  })), this.manager && this._layout && this.manager.applyLayout(this._layout), this._layout;
5410
5430
  }
@@ -5499,7 +5519,7 @@ class Mt {
5499
5519
  }, n = this.book.locations.locationFromCfi(e.mapping.start), r = this.book.locations.locationFromCfi(i.mapping.end);
5500
5520
  n != null && (s.start.location = n, s.start.percentage = this.book.locations.percentageFromLocation(n)), r != null && (s.end.location = r, s.end.percentage = this.book.locations.percentageFromLocation(r));
5501
5521
  const o = this.book.pageList.pageFromCfi(e.mapping.start), h = this.book.pageList.pageFromCfi(i.mapping.end);
5502
- return o != -1 && (s.start.page = o), h != -1 && (s.end.page = h), i.index === this.book.spine.last().index && s.end.displayed.page >= s.end.displayed.total && (s.atEnd = !0), e.index === this.book.spine.first().index && s.start.displayed.page === 1 && (s.atStart = !0), s;
5522
+ return o !== -1 && (s.start.page = o), h !== -1 && (s.end.page = h), i.index === this.book.spine.last().index && s.end.displayed.page >= s.end.displayed.total && (s.atEnd = !0), e.index === this.book.spine.first().index && s.start.displayed.page === 1 && (s.atStart = !0), s;
5503
5523
  }
5504
5524
  /**
5505
5525
  * Remove and Clean Up the Rendition
@@ -5580,10 +5600,8 @@ class Mt {
5580
5600
  "page-break-inside": "avoid",
5581
5601
  "break-inside": "avoid"
5582
5602
  }
5583
- }), new Promise(function(n, r) {
5584
- setTimeout(function() {
5585
- n();
5586
- }, 1);
5603
+ }), new Promise(function(n) {
5604
+ setTimeout(n, 0);
5587
5605
  });
5588
5606
  }
5589
5607
  /**
@@ -5645,8 +5663,9 @@ class Mt {
5645
5663
  s.setAttribute("name", "dc.relation.ispartof"), i && s.setAttribute("content", i), t.getElementsByTagName("head")[0].appendChild(s);
5646
5664
  }
5647
5665
  }
5648
- A(Mt.prototype);
5649
- class De {
5666
+ A(Wt.prototype);
5667
+ const st = typeof window < "u" ? window.URL : URL;
5668
+ class Me {
5650
5669
  constructor() {
5651
5670
  this.zip = void 0, this.urlCache = {}, this.checkRequirements();
5652
5671
  }
@@ -5657,7 +5676,7 @@ class De {
5657
5676
  */
5658
5677
  checkRequirements() {
5659
5678
  try {
5660
- this.zip = new jt();
5679
+ this.zip = new Ft();
5661
5680
  } catch {
5662
5681
  throw new Error("JSZip lib not loaded");
5663
5682
  }
@@ -5678,7 +5697,7 @@ class De {
5678
5697
  * @return {Promise} zipfile
5679
5698
  */
5680
5699
  openUrl(t, e) {
5681
- return H(t, "binary").then((i) => this.zip.loadAsync(i, { base64: e }));
5700
+ return V(t, "binary").then((i) => this.zip.loadAsync(i, { base64: e }));
5682
5701
  }
5683
5702
  /**
5684
5703
  * Request a url from the archive
@@ -5686,17 +5705,14 @@ class De {
5686
5705
  * @param {string} [type] specify the type of the returned result
5687
5706
  * @return {Promise<Blob | string | JSON | Document | XMLDocument>}
5688
5707
  */
5689
- request(t, e) {
5690
- const i = new v();
5691
- let s;
5692
- const n = new P(t);
5693
- return e || (e = n.extension), e == "blob" ? s = this.getBlob(t) : s = this.getText(t), s ? s.then((r) => {
5694
- const o = this.handleResponse(r, e);
5695
- i.resolve(o);
5696
- }) : i.reject({
5697
- message: "File not found in the epub: " + t,
5698
- stack: new Error().stack
5699
- }), i.promise;
5708
+ async request(t, e) {
5709
+ const i = new P(t);
5710
+ e || (e = i.extension);
5711
+ const s = e === "blob" ? this.getBlob(t) : this.getText(t);
5712
+ if (!s)
5713
+ throw new q("File not found in the epub: " + t);
5714
+ const n = await s;
5715
+ return this.handleResponse(n, e);
5700
5716
  }
5701
5717
  /**
5702
5718
  * Handle the response from request
@@ -5706,8 +5722,7 @@ class De {
5706
5722
  * @return {any} the parsed result
5707
5723
  */
5708
5724
  handleResponse(t, e) {
5709
- let i;
5710
- return e == "json" ? i = JSON.parse(t) : K(e) ? i = O(t, "text/xml") : e == "xhtml" ? i = O(t, "application/xhtml+xml") : e == "html" || e == "htm" ? i = O(t, "text/html") : i = t, i;
5725
+ return Nt(t, e);
5711
5726
  }
5712
5727
  /**
5713
5728
  * Get a Blob from Archive by Url
@@ -5718,7 +5733,7 @@ class De {
5718
5733
  getBlob(t, e) {
5719
5734
  const i = decodeURIComponent(t.substr(1)), s = this.zip.file(i);
5720
5735
  if (s)
5721
- return e = e || q.lookup(s.name), s.async("uint8array").then(function(n) {
5736
+ return e = e || H.lookup(s.name), s.async("uint8array").then(function(n) {
5722
5737
  return new Blob([n], { type: e });
5723
5738
  });
5724
5739
  }
@@ -5744,7 +5759,7 @@ class De {
5744
5759
  getBase64(t, e) {
5745
5760
  const i = decodeURIComponent(t.substr(1)), s = this.zip.file(i);
5746
5761
  if (s)
5747
- return e = e || q.lookup(s.name), s.async("base64").then(function(n) {
5762
+ return e = e || H.lookup(s.name), s.async("base64").then(function(n) {
5748
5763
  return "data:" + e + ";base64," + n;
5749
5764
  });
5750
5765
  }
@@ -5754,46 +5769,50 @@ class De {
5754
5769
  * @param {object} [options.base64] use base64 encoding or blob url
5755
5770
  * @return {Promise} url promise with Url string
5756
5771
  */
5757
- createUrl(t, e) {
5758
- const i = new v(), s = typeof window < "u" ? window.URL || window.webkitURL || window.mozURL : URL;
5759
- let n, r;
5760
- const o = e && e.base64;
5761
- return t in this.urlCache ? (i.resolve(this.urlCache[t]), i.promise) : (o ? (r = this.getBase64(t), r && r.then((h) => {
5762
- this.urlCache[t] = h, i.resolve(h);
5763
- })) : (r = this.getBlob(t), r && r.then((h) => {
5764
- n = s.createObjectURL(h), this.urlCache[t] = n, i.resolve(n);
5765
- })), r || i.reject({
5766
- message: "File not found in the epub: " + t,
5767
- stack: new Error().stack
5768
- }), i.promise);
5772
+ async createUrl(t, e) {
5773
+ if (t in this.urlCache)
5774
+ return this.urlCache[t];
5775
+ if (e && e.base64) {
5776
+ const s = this.getBase64(t);
5777
+ if (s) {
5778
+ const n = await s;
5779
+ return this.urlCache[t] = n, n;
5780
+ }
5781
+ } else {
5782
+ const s = this.getBlob(t);
5783
+ if (s) {
5784
+ const n = await s, r = st.createObjectURL(n);
5785
+ return this.urlCache[t] = r, r;
5786
+ }
5787
+ }
5788
+ throw new q("File not found in the epub: " + t);
5769
5789
  }
5770
5790
  /**
5771
5791
  * Revoke Temp Url for a archive item
5772
5792
  * @param {string} url url of the item in the archive
5773
5793
  */
5774
5794
  revokeUrl(t) {
5775
- const e = typeof window < "u" ? window.URL || window.webkitURL || window.mozURL : URL, i = this.urlCache[t];
5776
- i && e.revokeObjectURL(i);
5795
+ const e = this.urlCache[t];
5796
+ e && st.revokeObjectURL(e);
5777
5797
  }
5778
5798
  destroy() {
5779
- const t = typeof window < "u" ? window.URL || window.webkitURL || window.mozURL : URL;
5780
- for (const e in this.urlCache) {
5781
- const i = this.urlCache[e];
5782
- i && t.revokeObjectURL(i);
5799
+ for (const t in this.urlCache) {
5800
+ const e = this.urlCache[t];
5801
+ e && st.revokeObjectURL(e);
5783
5802
  }
5784
5803
  this.zip = void 0, this.urlCache = {};
5785
5804
  }
5786
5805
  }
5787
- function Be(l) {
5806
+ function We(a) {
5788
5807
  return new Promise((t, e) => {
5789
- const i = indexedDB.open(l, 1);
5808
+ const i = indexedDB.open(a, 1);
5790
5809
  i.onupgradeneeded = () => {
5791
5810
  i.result.createObjectStore("data");
5792
5811
  }, i.onsuccess = () => t(i.result), i.onerror = () => e(i.error);
5793
5812
  });
5794
5813
  }
5795
- function Me(l) {
5796
- const t = Be(l);
5814
+ function qe(a) {
5815
+ const t = We(a);
5797
5816
  return {
5798
5817
  getItem(e) {
5799
5818
  return t.then((i) => new Promise((s, n) => {
@@ -5809,10 +5828,10 @@ function Me(l) {
5809
5828
  }
5810
5829
  };
5811
5830
  }
5812
- const nt = typeof window < "u" ? window.URL || window.webkitURL || window.mozURL : void 0;
5813
- class Wt {
5831
+ const nt = typeof window < "u" ? window.URL : void 0;
5832
+ class qt {
5814
5833
  constructor(t, e, i) {
5815
- this.urlCache = {}, this.name = t, this.requester = e || H, this.resolver = i, this.online = !0, this.checkRequirements(), this.addListeners();
5834
+ this.urlCache = {}, this.name = t, this.requester = e || V, this.resolver = i, this.online = !0, this.checkRequirements(), this.addListeners();
5816
5835
  }
5817
5836
  /**
5818
5837
  * Checks that IndexedDB is available and creates the storage instance
@@ -5822,7 +5841,7 @@ class Wt {
5822
5841
  try {
5823
5842
  if (typeof indexedDB > "u")
5824
5843
  throw new Error("IndexedDB not available");
5825
- this.storage = Me(this.name);
5844
+ this.storage = qe(this.name);
5826
5845
  } catch {
5827
5846
  throw new Error("IndexedDB not available");
5828
5847
  }
@@ -5858,7 +5877,7 @@ class Wt {
5858
5877
  add(t, e) {
5859
5878
  const i = t.resources.map((s) => {
5860
5879
  const { href: n } = s, r = this.resolver(n), o = encodeURIComponent(r);
5861
- return this.storage.getItem(o).then((h) => !h || e ? this.requester(r, "binary").then((a) => this.storage.setItem(o, a)) : h);
5880
+ return this.storage.getItem(o).then((h) => !h || e ? this.requester(r, "binary").then((l) => this.storage.setItem(o, l)) : h);
5862
5881
  });
5863
5882
  return Promise.all(i);
5864
5883
  }
@@ -5890,17 +5909,13 @@ class Wt {
5890
5909
  * @param {string} [type] specify the type of the returned result
5891
5910
  * @return {Promise<Blob | string | JSON | Document | XMLDocument>}
5892
5911
  */
5893
- retrieve(t, e) {
5894
- let i;
5895
- const s = new P(t);
5896
- return e || (e = s.extension), e == "blob" ? i = this.getBlob(t) : i = this.getText(t), i.then((n) => {
5897
- const r = new v();
5898
- let o;
5899
- return n ? (o = this.handleResponse(n, e), r.resolve(o)) : r.reject({
5900
- message: "File not found in storage: " + t,
5901
- stack: new Error().stack
5902
- }), r.promise;
5903
- });
5912
+ async retrieve(t, e) {
5913
+ const i = new P(t);
5914
+ e || (e = i.extension);
5915
+ const s = e === "blob" ? await this.getBlob(t) : await this.getText(t);
5916
+ if (s)
5917
+ return this.handleResponse(s, e);
5918
+ throw new q("File not found in storage: " + t);
5904
5919
  }
5905
5920
  /**
5906
5921
  * Handle the response from request
@@ -5910,8 +5925,7 @@ class Wt {
5910
5925
  * @return {string | Document | Blob | object} the parsed result
5911
5926
  */
5912
5927
  handleResponse(t, e) {
5913
- let i;
5914
- return e == "json" ? i = JSON.parse(t) : K(e) ? i = O(t, "text/xml") : e == "xhtml" ? i = O(t, "application/xhtml+xml") : e == "html" || e == "htm" ? i = O(t, "text/html") : i = t, i;
5928
+ return Nt(t, e);
5915
5929
  }
5916
5930
  /**
5917
5931
  * Get a Blob from Storage by Url
@@ -5923,24 +5937,19 @@ class Wt {
5923
5937
  const i = encodeURIComponent(t);
5924
5938
  return this.storage.getItem(i).then(function(s) {
5925
5939
  if (s)
5926
- return e = e || q.lookup(t), new Blob([s], { type: e });
5940
+ return e = e || H.lookup(t), new Blob([s], { type: e });
5927
5941
  });
5928
5942
  }
5929
5943
  /**
5930
5944
  * Get Text from Storage by Url
5931
5945
  * @param {string} url
5932
- * @param {string} [mimeType]
5933
5946
  * @return {string}
5934
5947
  */
5935
5948
  getText(t, e) {
5936
5949
  const i = encodeURIComponent(t);
5937
- return e = e || q.lookup(t), this.storage.getItem(i).then(function(s) {
5938
- const n = new v(), r = new FileReader();
5939
- if (!s) return;
5940
- const o = new Blob([s], { type: e });
5941
- return r.addEventListener("loadend", () => {
5942
- n.resolve(r.result);
5943
- }), r.readAsText(o, e), n.promise;
5950
+ return this.storage.getItem(i).then(function(s) {
5951
+ if (s)
5952
+ return new TextDecoder().decode(s);
5944
5953
  });
5945
5954
  }
5946
5955
  /**
@@ -5949,15 +5958,17 @@ class Wt {
5949
5958
  * @param {string} [mimeType]
5950
5959
  * @return {string} base64 encoded
5951
5960
  */
5952
- getBase64(t, e) {
5961
+ async getBase64(t, e) {
5953
5962
  const i = encodeURIComponent(t);
5954
- return e = e || q.lookup(t), this.storage.getItem(i).then((s) => {
5955
- const n = new v(), r = new FileReader();
5956
- if (!s) return;
5957
- const o = new Blob([s], { type: e });
5958
- return r.addEventListener("loadend", () => {
5959
- n.resolve(r.result);
5960
- }), r.readAsDataURL(o), n.promise;
5963
+ e = e || H.lookup(t);
5964
+ const s = await this.storage.getItem(i);
5965
+ if (!s) return;
5966
+ const n = new Blob([s], { type: e });
5967
+ return new Promise((r) => {
5968
+ const o = new FileReader();
5969
+ o.addEventListener("loadend", () => {
5970
+ r(o.result);
5971
+ }), o.readAsDataURL(n);
5961
5972
  });
5962
5973
  }
5963
5974
  /**
@@ -5966,18 +5977,21 @@ class Wt {
5966
5977
  * @param {object} [options.base64] use base64 encoding or blob url
5967
5978
  * @return {Promise} url promise with Url string
5968
5979
  */
5969
- createUrl(t, e) {
5970
- const i = new v();
5971
- let s, n;
5972
- const r = e && e.base64;
5973
- return t in this.urlCache ? (i.resolve(this.urlCache[t]), i.promise) : (r ? (n = this.getBase64(t), n && n.then((o) => {
5974
- this.urlCache[t] = o, i.resolve(o);
5975
- })) : (n = this.getBlob(t), n && n.then((o) => {
5976
- s = o ? nt.createObjectURL(o) : void 0, this.urlCache[t] = s, i.resolve(s);
5977
- })), n || i.reject({
5978
- message: "File not found in storage: " + t,
5979
- stack: new Error().stack
5980
- }), i.promise);
5980
+ async createUrl(t, e) {
5981
+ if (t in this.urlCache)
5982
+ return this.urlCache[t];
5983
+ if (e && e.base64) {
5984
+ const s = await this.getBase64(t);
5985
+ if (s)
5986
+ return this.urlCache[t] = s, s;
5987
+ } else {
5988
+ const s = await this.getBlob(t);
5989
+ if (s) {
5990
+ const n = nt.createObjectURL(s);
5991
+ return this.urlCache[t] = n, n;
5992
+ }
5993
+ }
5994
+ throw new q("File not found in storage: " + t);
5981
5995
  }
5982
5996
  /**
5983
5997
  * Revoke Temp Url for a archive item
@@ -5995,7 +6009,7 @@ class Wt {
5995
6009
  this.urlCache = {}, this.removeListeners();
5996
6010
  }
5997
6011
  }
5998
- A(Wt.prototype);
6012
+ A(qt.prototype);
5999
6013
  class rt {
6000
6014
  constructor(t) {
6001
6015
  this.interactive = "", this.fixedLayout = "", this.openToSpread = "", this.orientationLock = "", t && this.parse(t);
@@ -6008,8 +6022,8 @@ class rt {
6008
6022
  parse(t) {
6009
6023
  if (!t)
6010
6024
  return this;
6011
- const e = b(t, "display_options");
6012
- return e ? (M(e, "option").forEach((s) => {
6025
+ const e = w(t, "display_options");
6026
+ return e ? (B(e, "option").forEach((s) => {
6013
6027
  let n = "";
6014
6028
  switch (s.childNodes.length && (n = s.childNodes[0].nodeValue ?? ""), s.getAttribute("name") ?? "") {
6015
6029
  case "interactive":
@@ -6031,7 +6045,7 @@ class rt {
6031
6045
  this.interactive = void 0, this.fixedLayout = void 0, this.openToSpread = void 0, this.orientationLock = void 0;
6032
6046
  }
6033
6047
  }
6034
- const _t = "META-INF/container.xml", We = "META-INF/com.apple.ibooks.display-options.xml", k = {
6048
+ const Ct = "META-INF/container.xml", Ue = "META-INF/com.apple.ibooks.display-options.xml", L = {
6035
6049
  BINARY: "binary",
6036
6050
  BASE64: "base64",
6037
6051
  EPUB: "epub",
@@ -6039,7 +6053,7 @@ const _t = "META-INF/container.xml", We = "META-INF/com.apple.ibooks.display-opt
6039
6053
  MANIFEST: "json",
6040
6054
  DIRECTORY: "directory"
6041
6055
  };
6042
- class qe {
6056
+ class je {
6043
6057
  constructor(t, e) {
6044
6058
  typeof e > "u" && typeof t != "string" && !(t instanceof Blob) && !(t instanceof ArrayBuffer) && (e = t, t = void 0), this.settings = _({}, {
6045
6059
  requestMethod: void 0,
@@ -6050,15 +6064,15 @@ class qe {
6050
6064
  canonical: void 0,
6051
6065
  openAs: void 0,
6052
6066
  store: void 0
6053
- }), _(this.settings, e), this.opening = new v(), this.opened = this.opening.promise, this.isOpen = !1, this.loading = {
6054
- manifest: new v(),
6055
- spine: new v(),
6056
- metadata: new v(),
6057
- cover: new v(),
6058
- navigation: new v(),
6059
- pageList: new v(),
6060
- resources: new v(),
6061
- displayOptions: new v()
6067
+ }), _(this.settings, e), this.opening = new S(), this.opened = this.opening.promise, this.isOpen = !1, this.loading = {
6068
+ manifest: new S(),
6069
+ spine: new S(),
6070
+ metadata: new S(),
6071
+ cover: new S(),
6072
+ navigation: new S(),
6073
+ pageList: new S(),
6074
+ resources: new S(),
6075
+ displayOptions: new S()
6062
6076
  }, this.loaded = {
6063
6077
  manifest: this.loading.manifest.promise,
6064
6078
  spine: this.loading.spine.promise,
@@ -6076,7 +6090,7 @@ class qe {
6076
6090
  this.loaded.navigation,
6077
6091
  this.loaded.resources,
6078
6092
  this.loaded.displayOptions
6079
- ]), this.isRendered = !1, this.request = this.settings.requestMethod || H, this.spine = new ce(), this.locations = new At(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) => {
6093
+ ]), this.isRendered = !1, this.request = this.settings.requestMethod || V, this.spine = new ue(), this.locations = new Pt(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) => {
6080
6094
  const s = new Error("Cannot load book at " + t);
6081
6095
  this.emit(u.BOOK.OPEN_FAILED, s);
6082
6096
  });
@@ -6091,7 +6105,7 @@ class qe {
6091
6105
  open(t, e) {
6092
6106
  let i;
6093
6107
  const s = e || this.determineType(t);
6094
- return s === k.BINARY ? (this.archived = !0, this.url = new R("/", ""), i = this.openEpub(t)) : s === k.BASE64 ? (this.archived = !0, this.url = new R("/", ""), i = this.openEpub(t, s)) : s === k.EPUB ? (this.archived = !0, this.url = new R("/", ""), i = this.request(t, "binary", this.settings.requestCredentials, this.settings.requestHeaders).then((n) => this.openEpub(n))) : s == k.OPF ? (this.url = new R(t), i = this.openPackaging(this.url.Path.toString())) : s == k.MANIFEST ? (this.url = new R(t), i = this.openManifest(this.url.Path.toString())) : (this.url = new R(t), i = this.openContainer(_t).then((n) => this.openPackaging(n))), i;
6108
+ return s === L.BINARY ? (this.archived = !0, this.url = new N("/", ""), i = this.openEpub(t)) : s === L.BASE64 ? (this.archived = !0, this.url = new N("/", ""), i = this.openEpub(t, s)) : s === L.EPUB ? (this.archived = !0, this.url = new N("/", ""), i = this.request(t, "binary", this.settings.requestCredentials, this.settings.requestHeaders).then((n) => this.openEpub(n))) : s === L.OPF ? (this.url = new N(t), i = this.openPackaging(this.url.Path.toString())) : s === L.MANIFEST ? (this.url = new N(t), i = this.openManifest(this.url.Path.toString())) : (this.url = new N(t), i = this.openContainer(Ct).then((n) => this.openPackaging(n))), i;
6095
6109
  }
6096
6110
  /**
6097
6111
  * Open an archived epub
@@ -6101,7 +6115,7 @@ class qe {
6101
6115
  * @return {Promise}
6102
6116
  */
6103
6117
  openEpub(t, e) {
6104
- return this.unarchive(t, e || this.settings.encoding).then(() => this.openContainer(_t)).then((i) => this.openPackaging(i));
6118
+ return this.unarchive(t, e || this.settings.encoding).then(() => this.openContainer(Ct)).then((i) => this.openPackaging(i));
6105
6119
  }
6106
6120
  /**
6107
6121
  * Open the epub container
@@ -6110,7 +6124,7 @@ class qe {
6110
6124
  * @return {string} packagePath
6111
6125
  */
6112
6126
  openContainer(t) {
6113
- return this.load(t).then((e) => (this.container = new de(e), this.resolve(this.container.packagePath)));
6127
+ return this.load(t).then((e) => (this.container = new fe(e), this.resolve(this.container.packagePath)));
6114
6128
  }
6115
6129
  /**
6116
6130
  * Open the Open Packaging Format Xml
@@ -6119,7 +6133,7 @@ class qe {
6119
6133
  * @return {Promise}
6120
6134
  */
6121
6135
  openPackaging(t) {
6122
- return this.path = new P(t), this.load(t).then((e) => (this.packaging = new Et(e), this.unpack(this.packaging)));
6136
+ return this.path = new P(t), this.load(t).then((e) => (this.packaging = new xt(e), this.unpack(this.packaging)));
6123
6137
  }
6124
6138
  /**
6125
6139
  * Open the manifest JSON
@@ -6128,7 +6142,7 @@ class qe {
6128
6142
  * @return {Promise}
6129
6143
  */
6130
6144
  openManifest(t) {
6131
- return this.path = new P(t), this.load(t).then((e) => (this.packaging = new Et(), this.packaging.load(e), this.unpack(this.packaging)));
6145
+ return this.path = new P(t), this.load(t).then((e) => (this.packaging = new xt(), this.packaging.load(e), this.unpack(this.packaging)));
6132
6146
  }
6133
6147
  /**
6134
6148
  * Load a resource from the Book
@@ -6149,7 +6163,7 @@ class qe {
6149
6163
  if (!t)
6150
6164
  return "";
6151
6165
  let i = t;
6152
- return t.indexOf("://") > -1 ? t : (this.path && (i = this.path.resolve(t)), e != !1 && this.url && (i = this.url.resolve(i)), i);
6166
+ return t.indexOf("://") > -1 ? t : (this.path && (i = this.path.resolve(t)), e !== !1 && this.url && (i = this.url.resolve(i)), i);
6153
6167
  }
6154
6168
  /**
6155
6169
  * Get a canonical link to a path
@@ -6169,17 +6183,17 @@ class qe {
6169
6183
  determineType(t) {
6170
6184
  let e;
6171
6185
  if (this.settings.encoding === "base64")
6172
- return k.BASE64;
6186
+ return L.BASE64;
6173
6187
  if (typeof t != "string")
6174
- return k.BINARY;
6175
- if (e = new R(t).path().extension, e && (e = e.replace(/\?.*$/, "")), !e)
6176
- return k.DIRECTORY;
6188
+ return L.BINARY;
6189
+ if (e = new N(t).path().extension, e && (e = e.replace(/\?.*$/, "")), !e)
6190
+ return L.DIRECTORY;
6177
6191
  if (e === "epub")
6178
- return k.EPUB;
6192
+ return L.EPUB;
6179
6193
  if (e === "opf")
6180
- return k.OPF;
6194
+ return L.OPF;
6181
6195
  if (e === "json")
6182
- return k.MANIFEST;
6196
+ return L.MANIFEST;
6183
6197
  }
6184
6198
  /**
6185
6199
  * unpack the contents of the Books packaging
@@ -6187,26 +6201,20 @@ class qe {
6187
6201
  * @param {Packaging} packaging object
6188
6202
  */
6189
6203
  unpack(t) {
6190
- this.package = t, this.packaging.metadata.layout === "" ? this.load(this.url.resolve(We)).then((e) => {
6191
- this.displayOptions = new rt(e), this.loading.displayOptions.resolve(this.displayOptions);
6192
- }).catch((e) => {
6204
+ this.package = t, this.packaging.metadata.layout === "" ? this.load(this.url.resolve(Ue)).then((i) => {
6205
+ this.displayOptions = new rt(i), this.loading.displayOptions.resolve(this.displayOptions);
6206
+ }).catch((i) => {
6193
6207
  this.displayOptions = new rt(), this.loading.displayOptions.resolve(this.displayOptions);
6194
- }) : (this.displayOptions = new rt(), this.loading.displayOptions.resolve(this.displayOptions)), this.spine.unpack(this.packaging, (e, i) => this.resolve(e, i), (e) => this.canonical(e)), this.resources = new ge(this.packaging.manifest, {
6208
+ }) : (this.displayOptions = new rt(), this.loading.displayOptions.resolve(this.displayOptions)), this.spine.unpack(this.packaging, (i, s) => this.resolve(i, s), (i) => this.canonical(i)), this.resources = new ve(this.packaging.manifest, {
6195
6209
  archive: this.archive,
6196
- resolver: (e, i) => this.resolve(e, i),
6197
- request: (e, i) => this.request(e, i),
6210
+ resolver: (i, s) => this.resolve(i, s),
6211
+ request: (i, s) => this.request(i, s),
6198
6212
  replacements: this.settings.replacements || (this.archived ? "blobUrl" : "base64")
6199
6213
  }), this.loadNavigation(this.packaging).then(() => {
6200
6214
  this.loading.navigation.resolve(this.navigation);
6201
- }), this.packaging.coverPath && (this.cover = this.resolve(this.packaging.coverPath)), this.loading.manifest.resolve(this.packaging.manifest), this.loading.metadata.resolve(this.packaging.metadata), this.loading.spine.resolve(this.spine), this.loading.cover.resolve(this.cover), this.loading.resources.resolve(this.resources), this.loading.pageList.resolve(this.pageList), this.isOpen = !0, this.archived || this.settings.replacements && this.settings.replacements != "none" ? this.replacements().then(() => {
6202
- this.loaded.displayOptions.then(() => {
6203
- this.opening.resolve(this);
6204
- });
6205
- }).catch((e) => {
6206
- console.error(e), this.loaded.displayOptions.then(() => {
6207
- this.opening.resolve(this);
6208
- });
6209
- }) : this.loaded.displayOptions.then(() => {
6215
+ }), this.packaging.coverPath && (this.cover = this.resolve(this.packaging.coverPath)), this.loading.manifest.resolve(this.packaging.manifest), this.loading.metadata.resolve(this.packaging.metadata), this.loading.spine.resolve(this.spine), this.loading.cover.resolve(this.cover), this.loading.resources.resolve(this.resources), this.loading.pageList.resolve(this.pageList), this.isOpen = !0, (this.settings.replacements || (this.archived ? "blobUrl" : "none")) !== "none" && (this.replacementsReady = this.replacements().catch((i) => {
6216
+ console.error(i);
6217
+ })), Promise.all([this.loaded.displayOptions, this.loaded.navigation]).then(() => {
6210
6218
  this.opening.resolve(this);
6211
6219
  });
6212
6220
  }
@@ -6218,9 +6226,9 @@ class qe {
6218
6226
  loadNavigation(t) {
6219
6227
  const e = t.navPath || t.ncxPath, i = t.toc;
6220
6228
  return i ? new Promise((s, n) => {
6221
- this.navigation = new et(i), "pageList" in t && t.pageList && (this.pageList = new st(t.pageList)), s(this.navigation);
6222
- }) : e ? this.load(e, "xml").then((s) => (this.navigation = new et(s), this.pageList = new st(s), this.navigation)) : new Promise((s, n) => {
6223
- this.navigation = new et(), this.pageList = new st(), s(this.navigation);
6229
+ this.navigation = new tt(i), "pageList" in t && t.pageList && (this.pageList = new it(t.pageList)), s(this.navigation);
6230
+ }) : e ? this.load(e, "xml").then((s) => (this.navigation = new tt(s), this.pageList = new it(s), this.navigation)) : new Promise((s, n) => {
6231
+ this.navigation = new tt(), this.pageList = new it(), s(this.navigation);
6224
6232
  });
6225
6233
  }
6226
6234
  /**
@@ -6239,7 +6247,7 @@ class qe {
6239
6247
  * @return {Rendition}
6240
6248
  */
6241
6249
  renderTo(t, e) {
6242
- return this.rendition = new Mt(this, e), this.rendition.attachTo(t), this.rendition;
6250
+ return this.rendition = new Wt(this, e), this.rendition.attachTo(t), this.rendition;
6243
6251
  }
6244
6252
  /**
6245
6253
  * Set if request should use withCredentials
@@ -6263,7 +6271,7 @@ class qe {
6263
6271
  * @return {Archive}
6264
6272
  */
6265
6273
  unarchive(t, e) {
6266
- return this.archive = new De(), this.archive.open(t, e === "base64");
6274
+ return this.archive = new Me(), this.archive.open(t, e === "base64");
6267
6275
  }
6268
6276
  /**
6269
6277
  * Store the epubs contents
@@ -6273,14 +6281,14 @@ class qe {
6273
6281
  * @return {Store}
6274
6282
  */
6275
6283
  store(t) {
6276
- const e = this.settings.replacements && this.settings.replacements !== "none" ? this.settings.replacements : void 0, i = this.url, s = this.settings.requestMethod || ((n, r) => H(n, r));
6277
- return this.storage = new Wt(t, s, (n, r) => this.resolve(n, r)), this.request = (n, r) => this.storage.request(n, r), this.opened.then(() => {
6284
+ const e = this.settings.replacements && this.settings.replacements !== "none" ? this.settings.replacements : void 0, i = this.url, s = this.settings.requestMethod || ((n, r) => V(n, r));
6285
+ return this.storage = new qt(t, s, (n, r) => this.resolve(n, r)), this.request = (n, r) => this.storage.request(n, r), this.opened.then(() => {
6278
6286
  this.archived && (this.storage.requester = (r, o) => this.archive.request(r, o));
6279
6287
  const n = (r, o) => {
6280
6288
  o.output = this.resources.substitute(r, o.url);
6281
6289
  };
6282
6290
  this.resources.settings.replacements = e || "blobUrl", this.resources.replacements().then(() => this.resources.replaceCss()), this.storage.on("offline", () => {
6283
- this.url = new R("/", ""), this.spine.hooks.serialize.register(n);
6291
+ this.url = new N("/", ""), this.spine.hooks.serialize.register(n);
6284
6292
  }), this.storage.on("online", () => {
6285
6293
  this.url = i, this.spine.hooks.serialize.deregister(n);
6286
6294
  });
@@ -6299,10 +6307,11 @@ class qe {
6299
6307
  * @return {Promise} completed loading urls
6300
6308
  */
6301
6309
  replacements() {
6302
- return this.spine.hooks.serialize.register((t, e) => {
6303
- e.output = this.resources.substitute(t, e.url);
6304
- }), this.resources.replacements().then(() => this.resources.replaceCss()).then(() => {
6310
+ const t = this.resources.replacements().then(() => this.resources.replaceCss()).then(() => {
6305
6311
  });
6312
+ return this.spine.hooks.serialize.register((e, i) => t.then(() => {
6313
+ i.output = this.resources.substitute(e, i.url);
6314
+ })), t;
6306
6315
  }
6307
6316
  /**
6308
6317
  * Find a DOM Range for a given CFI Range
@@ -6324,39 +6333,39 @@ class qe {
6324
6333
  */
6325
6334
  key(t) {
6326
6335
  const e = t || this.packaging.metadata.identifier || this.url.filename;
6327
- return `epubjs:${Nt}:${e}`;
6336
+ return `epubjs:${It}:${e}`;
6328
6337
  }
6329
6338
  /**
6330
6339
  * Destroy the Book and all associated objects
6331
6340
  */
6332
6341
  destroy() {
6333
- this.opened = void 0, this.loading = void 0, this.loaded = void 0, this.ready = void 0, this.isOpen = !1, this.isRendered = !1, this.spine && this.spine.destroy(), this.locations && this.locations.destroy(), this.pageList && this.pageList.destroy(), this.archive && this.archive.destroy(), this.resources && this.resources.destroy(), this.container && this.container.destroy(), this.packaging && this.packaging.destroy(), this.rendition && this.rendition.destroy(), this.displayOptions && this.displayOptions.destroy(), this.storage && (this.storage.destroy(), this.storage = void 0), this.spine = void 0, this.locations = void 0, this.pageList = void 0, this.archive = void 0, this.resources = void 0, this.container = void 0, this.packaging = void 0, this.rendition = void 0, this.navigation = void 0, this.url = void 0, this.path = void 0, this.archived = !1;
6342
+ this.opened = void 0, this.loading = void 0, this.loaded = void 0, this.ready = void 0, this.replacementsReady = void 0, this.isOpen = !1, this.isRendered = !1, this.spine && this.spine.destroy(), this.locations && this.locations.destroy(), this.pageList && this.pageList.destroy(), this.archive && this.archive.destroy(), this.resources && this.resources.destroy(), this.container && this.container.destroy(), this.packaging && this.packaging.destroy(), this.rendition && this.rendition.destroy(), this.displayOptions && this.displayOptions.destroy(), this.storage && (this.storage.destroy(), this.storage = void 0), this.spine = void 0, this.locations = void 0, this.pageList = void 0, this.archive = void 0, this.resources = void 0, this.container = void 0, this.packaging = void 0, this.rendition = void 0, this.navigation = void 0, this.url = void 0, this.path = void 0, this.archived = !1;
6334
6343
  }
6335
6344
  }
6336
- A(qe.prototype);
6337
- typeof globalThis.DOMParser > "u" && (globalThis.DOMParser = qt);
6345
+ A(je.prototype);
6346
+ typeof globalThis.DOMParser > "u" && (globalThis.DOMParser = Ut);
6338
6347
  typeof globalThis.XMLSerializer > "u" && (globalThis.XMLSerializer = class {
6339
6348
  serializeToString(t) {
6340
6349
  return t.toString();
6341
6350
  }
6342
6351
  });
6343
6352
  if (typeof globalThis.document > "u") {
6344
- const { document: l } = Ut("<!DOCTYPE html><html><head></head><body></body></html>");
6345
- globalThis.document = l;
6353
+ const { document: a } = jt("<!DOCTYPE html><html><head></head><body></body></html>");
6354
+ globalThis.document = a;
6346
6355
  }
6347
6356
  export {
6348
- De as Archive,
6349
- qe as Book,
6350
- de as Container,
6357
+ Me as Archive,
6358
+ je as Book,
6359
+ fe as Container,
6351
6360
  rt as DisplayOptions,
6352
6361
  m as EpubCFI,
6353
- It as Layout,
6354
- At as Locations,
6355
- et as Navigation,
6356
- Et as Packaging,
6357
- st as PageList,
6358
- ge as Resources,
6359
- ae as Section,
6360
- ce as Spine
6362
+ Ot as Layout,
6363
+ Pt as Locations,
6364
+ tt as Navigation,
6365
+ xt as Packaging,
6366
+ it as PageList,
6367
+ ve as Resources,
6368
+ de as Section,
6369
+ ue as Spine
6361
6370
  };
6362
6371
  //# sourceMappingURL=epub.node.js.map