@prose-reader/core 1.326.0 → 1.327.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/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { Report as e, arrayEqual as t, detectMimeTypeFromName as n, getItemSpreadPosition as r, getParentPath as i, isShallowEqual as a, isShallowEqual as o, parseContentType as s, shallowMergeIfDefined as c } from "@prose-reader/shared";
2
- import { BehaviorSubject as l, EMPTY as u, NEVER as d, Observable as f, ReplaySubject as p, Subject as m, animationFrameScheduler as h, auditTime as g, catchError as _, combineLatest as v, concatMap as ee, debounce as te, debounceTime as ne, defaultIfEmpty as re, defer as ie, delay as ae, distinctUntilChanged as y, endWith as oe, exhaustMap as se, filter as b, finalize as ce, first as x, from as S, fromEvent as C, identity as le, lastValueFrom as ue, map as w, merge as T, mergeMap as E, of as D, scheduled as de, share as O, shareReplay as k, skip as fe, startWith as A, switchMap as j, switchScan as pe, take as me, takeUntil as M, tap as N, throttleTime as he, timeout as ge, timer as _e, withLatestFrom as P } from "rxjs";
3
- import { debounceTime as ve, distinctUntilChanged as ye, filter as be, first as xe, map as Se, pairwise as Ce, share as we, shareReplay as Te, skip as Ee, startWith as De, switchMap as F, take as Oe, takeUntil as I, tap as L } from "rxjs/operators";
4
- import { generate as ke, isIndirectionOnly as Ae, isParsedCfiRange as je, parse as Me, resolve as Ne } from "@prose-reader/cfi";
5
- var R = e.namespace("@prose-reader/core", void 0, { color: "#98cde7" }), Pe = [
2
+ import { BehaviorSubject as l, EMPTY as u, NEVER as d, Observable as f, ReplaySubject as p, Subject as m, animationFrameScheduler as h, auditTime as g, catchError as _, combineLatest as v, concatMap as y, debounce as ee, debounceTime as te, defaultIfEmpty as ne, defer as re, delay as ie, distinctUntilChanged as b, endWith as ae, exhaustMap as oe, filter as x, finalize as se, first as S, from as C, fromEvent as w, identity as ce, lastValueFrom as le, map as T, merge as E, mergeMap as ue, of as D, scheduled as de, share as O, shareReplay as k, skip as fe, startWith as pe, switchMap as A, switchScan as me, take as he, takeUntil as j, tap as M, throttleTime as ge, timeout as _e, timer as ve, withLatestFrom as N } from "rxjs";
3
+ import { debounceTime as ye, distinctUntilChanged as be, filter as xe, first as Se, map as Ce, pairwise as we, share as Te, shareReplay as Ee, skip as De, startWith as Oe, switchMap as P, take as ke, takeUntil as F, tap as I } from "rxjs/operators";
4
+ import { generate as Ae, isIndirectionOnly as je, isParsedCfiRange as Me, parse as Ne, resolve as Pe } from "@prose-reader/cfi";
5
+ var L = e.namespace("@prose-reader/core", void 0, { color: "#98cde7" }), Fe = [
6
6
  "pointercancel",
7
7
  "pointerdown",
8
8
  "pointerenter",
@@ -12,38 +12,38 @@ var R = e.namespace("@prose-reader/core", void 0, { color: "#98cde7" }), Pe = [
12
12
  "pointerover",
13
13
  "pointerup"
14
14
  ];
15
- function z(e, t, n) {
15
+ function R(e, t, n) {
16
16
  let r = String(n);
17
17
  e.getAttribute(t) !== r && e.setAttribute(t, r);
18
18
  }
19
- function Fe(e, t) {
19
+ function Ie(e, t) {
20
20
  e.hasAttribute(t) && e.removeAttribute(t);
21
21
  }
22
- function Ie(e, t, n) {
22
+ function Le(e, t, n) {
23
23
  e[t] !== n && (e[t] = n);
24
24
  }
25
- function B(e, t, n) {
25
+ function z(e, t, n) {
26
26
  e.getPropertyValue(t) !== n && e.setProperty(t, n);
27
27
  }
28
- function V(e, t) {
28
+ function B(e, t) {
29
29
  e.getPropertyValue(t) !== "" && e.removeProperty(t);
30
30
  }
31
- function Le(e, t, n) {
31
+ function Re(e, t, n) {
32
32
  if ("caretPositionFromPoint" in e) return e.caretPositionFromPoint(t, n);
33
33
  if ("caretRangeFromPoint" in e && e.caretRangeFromPoint !== void 0) return e.caretRangeFromPoint(t, n);
34
34
  }
35
- var Re = (e, t) => {
35
+ var ze = (e, t) => {
36
36
  let n = "createRange" in e ? e : e.ownerDocument;
37
37
  if (!n) return;
38
- let r = "body" in e ? ze(e.body, t) : ze(e, t);
38
+ let r = "body" in e ? Be(e.body, t) : Be(e, t);
39
39
  if (r) {
40
40
  let e, i = 0, a = n.createRange();
41
41
  return Array.from(r.childNodes).some((r) => {
42
42
  a.selectNodeContents(r);
43
- let o = Ve(a.getClientRects(), t);
43
+ let o = He(a.getClientRects(), t);
44
44
  if (o) {
45
45
  e = a.cloneRange();
46
- let t = Le(n, Math.ceil(o.left), Math.ceil(o.top));
46
+ let t = Re(n, Math.ceil(o.left), Math.ceil(o.top));
47
47
  return t && "startContainer" in t && t.startContainer === e.startContainer && (i = t.startOffset), t && "offsetNode" in t && t.offsetNode === e.startContainer && (i = t.offset), !0;
48
48
  }
49
49
  return !1;
@@ -55,36 +55,36 @@ var Re = (e, t) => {
55
55
  offset: 0
56
56
  };
57
57
  }
58
- }, ze = (e, t) => {
59
- let n = Be(e.getBoundingClientRect(), t), r;
58
+ }, Be = (e, t) => {
59
+ let n = Ve(e.getBoundingClientRect(), t), r;
60
60
  n !== "before" && n !== "after" && (r = e);
61
61
  for (let n of e.children) {
62
- let e = ze(n, t);
62
+ let e = Be(n, t);
63
63
  if (e) return e;
64
64
  }
65
65
  return r;
66
66
  };
67
- function Be(e, { left: t, right: n }) {
67
+ function Ve(e, { left: t, right: n }) {
68
68
  return e.left <= t && e.right <= t ? "before" : e.left <= t && e.right > t && e.right <= n ? "partially-before" : e.left <= n && e.right > n ? "partially-after" : e.left > n ? "after" : "within";
69
69
  }
70
- function Ve(e, t) {
70
+ function He(e, t) {
71
71
  return Array.from(e).find((e) => {
72
- let n = Be(e, t);
72
+ let n = Ve(e, t);
73
73
  return n !== "before" && n !== "after";
74
74
  });
75
75
  }
76
- var He = (e, t) => {
76
+ var Ue = (e, t) => {
77
77
  if (e.nodeType !== Node.CDATA_SECTION_NODE && e.nodeType !== Node.DOCUMENT_TYPE_NODE) {
78
78
  let n = e.ownerDocument?.createRange();
79
79
  n?.selectNodeContents(e);
80
80
  try {
81
81
  t <= (n?.endOffset || 0) && n?.setStart(e, t || 0);
82
82
  } catch (e) {
83
- R.error(e);
83
+ L.error(e);
84
84
  }
85
85
  return n;
86
86
  }
87
- }, Ue = (e) => {
87
+ }, We = (e) => {
88
88
  if (e?.target && (e?.target)?.ownerDocument?.defaultView) {
89
89
  let t = (e?.target)?.ownerDocument?.defaultView;
90
90
  if (t.PointerEvent && e instanceof t.PointerEvent) return !0;
@@ -93,9 +93,9 @@ var He = (e, t) => {
93
93
  let t = e?.view;
94
94
  if (t.PointerEvent && e instanceof t.PointerEvent) return !0;
95
95
  }
96
- return !!Pe.includes(e.type);
97
- }, We = (e) => {
98
- if (Ue(e)) return !1;
96
+ return !!Fe.includes(e.type);
97
+ }, Ge = (e) => {
98
+ if (We(e)) return !1;
99
99
  if (e?.target && (e?.target)?.ownerDocument?.defaultView) {
100
100
  let t = (e?.target)?.ownerDocument?.defaultView;
101
101
  if (t.MouseEvent) return e instanceof t.MouseEvent;
@@ -105,7 +105,7 @@ var He = (e, t) => {
105
105
  if (t.MouseEvent) return e instanceof t.MouseEvent;
106
106
  }
107
107
  return !1;
108
- }, Ge = (e) => {
108
+ }, Ke = (e) => {
109
109
  if (e?.target && (e?.target)?.ownerDocument?.defaultView) {
110
110
  let t = (e?.target)?.ownerDocument?.defaultView;
111
111
  if (t.TouchEvent) return e instanceof t.TouchEvent;
@@ -115,7 +115,7 @@ var He = (e, t) => {
115
115
  if (t.TouchEvent) return e instanceof t.TouchEvent;
116
116
  }
117
117
  return !1;
118
- }, Ke = () => document.createElement("div"), qe = (e) => {
118
+ }, qe = () => document.createElement("div"), Je = (e) => {
119
119
  let t = [
120
120
  "img",
121
121
  "video",
@@ -125,8 +125,8 @@ var He = (e, t) => {
125
125
  "script"
126
126
  ].join(",");
127
127
  return Array.from(e?.querySelectorAll(t) || []);
128
- }, Je = (e) => {
129
- if (qe(e).forEach((t) => {
128
+ }, Ye = (e) => {
129
+ if (Je(e).forEach((t) => {
130
130
  let n = t.getAttribute("src") || t.getAttribute("href");
131
131
  n?.startsWith("blob:") && e?.defaultView?.URL.revokeObjectURL(n);
132
132
  }), e) {
@@ -136,7 +136,7 @@ var He = (e, t) => {
136
136
  try {
137
137
  return Array.from(n.cssRules || []);
138
138
  } catch (e) {
139
- return R.warn(`Error getting rules for sheet: ${n.href}`, e), [];
139
+ return L.warn(`Error getting rules for sheet: ${n.href}`, e), [];
140
140
  }
141
141
  })();
142
142
  for (let n of t) if (e.defaultView && n instanceof e.defaultView.CSSFontFaceRule) {
@@ -148,20 +148,20 @@ var He = (e, t) => {
148
148
  }
149
149
  }
150
150
  };
151
- function Ye(e, t, n = []) {
151
+ function Xe(e, t, n = []) {
152
152
  if (typeof e != "object" || !e) return !1;
153
153
  for (let n of t) if (!(n in e)) return !1;
154
154
  for (let t of n) if (t in e && typeof e[t] != "function") return !1;
155
155
  return !0;
156
156
  }
157
- function Xe(e) {
158
- return Ye(e, ["nodeType"], []) && e.nodeType === Node.ELEMENT_NODE;
157
+ function Ze(e) {
158
+ return Xe(e, ["nodeType"], []) && e.nodeType === Node.ELEMENT_NODE;
159
159
  }
160
- function Ze(e, t) {
161
- return Xe(e) && e.tagName.toLowerCase() === t.toLowerCase();
160
+ function V(e, t) {
161
+ return Ze(e) && e.tagName.toLowerCase() === t.toLowerCase();
162
162
  }
163
163
  function Qe(e) {
164
- return Ye(e, [
164
+ return Xe(e, [
165
165
  "startContainer",
166
166
  "endContainer",
167
167
  "startOffset",
@@ -226,13 +226,13 @@ var $e = (e, t, n, r) => {
226
226
  }
227
227
  }
228
228
  return { hasViewport: !1 };
229
- }, ot = (e) => e.pipe(j((e) => e.src === "about:blank" && e.contentDocument?.readyState === "complete" && e.contentDocument.body ? D(e) : C(e, "load").pipe(me(1), w(() => e)))), st = (e) => e.pipe(j((e) => {
229
+ }, ot = (e) => e.pipe(A((e) => e.src === "about:blank" && e.contentDocument?.readyState === "complete" && e.contentDocument.body ? D(e) : w(e, "load").pipe(he(1), T(() => e)))), st = (e) => e.pipe(A((e) => {
230
230
  let t = e?.contentDocument?.fonts.ready;
231
- return t ? S(t).pipe(w(() => e)) : D(e);
231
+ return t ? C(t).pipe(T(() => e)) : D(e);
232
232
  })), ct = (e) => (t) => {
233
- let n = e(t), r = new IntersectionObserver((e) => {
233
+ let n = e(t), r = new ((n.context.document.defaultView?.IntersectionObserver) ?? IntersectionObserver)((e) => {
234
234
  e.forEach((e) => {
235
- e.isIntersecting ? Fe(e.target, "tab-index") : z(e.target, "tab-index", "-1");
235
+ e.isIntersecting ? Ie(e.target, "tab-index") : R(e.target, "tab-index", "-1");
236
236
  });
237
237
  }, {}), i = /* @__PURE__ */ new Map();
238
238
  return n.hookManager.register("item.onDocumentLoad", async ({ itemId: e }) => {
@@ -255,13 +255,13 @@ var $e = (e, t, n, r) => {
255
255
  }), { ...n };
256
256
  }, lt = (e) => (t) => {
257
257
  let n = e(t);
258
- return n.context.watch("rootElement").pipe(M(n.context.destroy$)).subscribe((e) => {
258
+ return n.context.watch("rootElement").pipe(j(n.context.destroy$)).subscribe((e) => {
259
259
  e && e.addEventListener("scroll", () => {
260
260
  n.settings.values.computedPageTurnMode === "controlled" && e.scrollTo(0, 0);
261
261
  });
262
262
  }), n.hookManager.register("item.onDocumentLoad", async ({ itemId: e }) => {
263
263
  let t = n.spineItemsManager.get(e)?.renderer.getDocumentFrame();
264
- t && t.contentDocument?.body && z(t.contentDocument.body, "tabindex", "-1");
264
+ t && t.contentDocument?.body && R(t.contentDocument.body, "tabindex", "-1");
265
265
  }), n;
266
266
  }, ut = ({ position: e, frameElement: t }) => {
267
267
  let n = t.getBoundingClientRect(), r = n.width / t.offsetWidth, i = n.height / t.offsetHeight, { left: a = 0, top: o = 0 } = n;
@@ -273,8 +273,8 @@ var $e = (e, t, n, r) => {
273
273
  let i = t?.view?.frameElement;
274
274
  if (!t || !i) return e;
275
275
  let a = n.getSpineItemFromIframe(i), o = i, { height: s, width: c } = r.pageSize;
276
- if (!a || !(o instanceof HTMLIFrameElement)) return e;
277
- if (Ue(e)) {
276
+ if (!a || !V(o, "iframe")) return e;
277
+ if (We(e)) {
278
278
  let { clientX: n, clientY: r } = ut({
279
279
  position: e,
280
280
  frameElement: o,
@@ -291,7 +291,7 @@ var $e = (e, t, n, r) => {
291
291
  enumerable: !0
292
292
  }), i;
293
293
  }
294
- if (We(e)) {
294
+ if (Ge(e)) {
295
295
  let { clientX: n, clientY: r } = ut({
296
296
  position: e,
297
297
  frameElement: o,
@@ -307,7 +307,7 @@ var $e = (e, t, n, r) => {
307
307
  enumerable: !0
308
308
  }), i;
309
309
  }
310
- if (Ge(e)) {
310
+ if (Ke(e)) {
311
311
  let n = Array.from(e.touches).map((e) => {
312
312
  let { clientX: t, clientY: n } = ut({
313
313
  position: e,
@@ -350,7 +350,7 @@ var $e = (e, t, n, r) => {
350
350
  let a = ft.map((e) => {
351
351
  let t = (e) => {
352
352
  let t = e;
353
- if (Ue(e) && (t = new PointerEvent(e.type, e)), t !== e) {
353
+ if (We(e) && (t = new PointerEvent(e.type, e)), t !== e) {
354
354
  let r = dt(t, e, n.spine.locator, n.viewport);
355
355
  n.context.value.rootElement?.dispatchEvent(r);
356
356
  }
@@ -377,10 +377,10 @@ var $e = (e, t, n, r) => {
377
377
  }, ht = (e, t) => Object.entries(e).reduce((e, [n, r]) => t.includes(n) ? {
378
378
  ...e,
379
379
  [n]: r
380
- } : e, {}), gt = (e) => Se((t) => ht(t, e)), _t = (e) => (t) => t.pipe(gt(e), ye(o));
380
+ } : e, {}), gt = (e) => Ce((t) => ht(t, e)), _t = (e) => (t) => t.pipe(gt(e), be(o));
381
381
  function vt(e) {
382
382
  return new f((t) => {
383
- let n = new ResizeObserver((e) => {
383
+ let n = new ((e.ownerDocument.defaultView?.ResizeObserver) ?? ResizeObserver)((e) => {
384
384
  t.next(e);
385
385
  });
386
386
  return n.observe(e), () => {
@@ -388,7 +388,7 @@ function vt(e) {
388
388
  };
389
389
  });
390
390
  }
391
- var yt = (e) => (t) => t.pipe(F((t) => e.pipe(xe(), Se(() => t)))), bt = (e) => {
391
+ var yt = (e) => (t) => t.pipe(P((t) => e.pipe(Se(), Ce(() => t)))), bt = (e) => {
392
392
  let t, n = e.subscribe((e) => {
393
393
  t = { result: e };
394
394
  });
@@ -409,17 +409,17 @@ function xt() {
409
409
  });
410
410
  }
411
411
  function St(e) {
412
- return ie(() => xt().pipe(F(e)));
412
+ return re(() => xt().pipe(P(e)));
413
413
  }
414
414
  var Ct = (e, t) => new f((n) => {
415
- let r = new MutationObserver((e) => {
415
+ let r = new ((e.ownerDocument?.defaultView?.MutationObserver) ?? MutationObserver)((e) => {
416
416
  n.next(e);
417
417
  });
418
418
  return r.observe(e, t), () => r.disconnect();
419
419
  });
420
420
  function wt(e, t) {
421
421
  return new f((n) => {
422
- let r = new IntersectionObserver((e) => {
422
+ let r = new ((e.ownerDocument.defaultView?.IntersectionObserver) ?? IntersectionObserver)((e) => {
423
423
  n.next(e);
424
424
  }, t);
425
425
  return r.observe(e), () => {
@@ -433,10 +433,10 @@ var Tt = class {
433
433
  constructor(e, t) {
434
434
  this.settingsManager = t;
435
435
  let n = c(this.getDefaultSettings(), e);
436
- this.outputSettings = this.computeOutputSettings(n), this.inputSettings = c(this.getDefaultSettings(), e), this.outputSettingsUpdateSubject = new m(), this.values$ = v([this.settingsManager.values$, this.outputSettingsUpdateSubject.pipe(De(this.outputSettings))]).pipe(Se(([e, t]) => ({
436
+ this.outputSettings = this.computeOutputSettings(n), this.inputSettings = c(this.getDefaultSettings(), e), this.outputSettingsUpdateSubject = new m(), this.values$ = v([this.settingsManager.values$, this.outputSettingsUpdateSubject.pipe(Oe(this.outputSettings))]).pipe(Ce(([e, t]) => ({
437
437
  ...e,
438
438
  ...t
439
- })), Te(1)), this.values$.subscribe();
439
+ })), Ee(1)), this.values$.subscribe();
440
440
  }
441
441
  _prepareUpdate(e) {
442
442
  let t = this.getCleanedParentInputSettings(e), n = this.settingsManager._prepareUpdate(t), r = c(this.inputSettings, e), i = this.computeOutputSettings(r), a = this.hasSettingsChanged(i);
@@ -459,7 +459,7 @@ var Tt = class {
459
459
  };
460
460
  }
461
461
  watch(e) {
462
- return Array.isArray(e) ? this.values$.pipe(_t(e)) : this.values$.pipe(Se((t) => t[e]), ye(o));
462
+ return Array.isArray(e) ? this.values$.pipe(_t(e)) : this.values$.pipe(Ce((t) => t[e]), be(o));
463
463
  }
464
464
  destroy() {
465
465
  this.outputSettingsUpdateSubject.complete();
@@ -504,14 +504,14 @@ var Tt = class {
504
504
  let e = t?.renderer.getDocumentFrame();
505
505
  e && H(e, "prose-reader-fonts", l());
506
506
  }
507
- }), c.values$.pipe((e) => e.pipe(Ce(), w(([e, t]) => t.fontScale !== e.fontScale || t.lineHeight !== e.lineHeight)), L((e) => {
507
+ }), c.values$.pipe((e) => e.pipe(we(), T(([e, t]) => t.fontScale !== e.fontScale || t.lineHeight !== e.lineHeight)), I((e) => {
508
508
  s.spineItemsManager.items.forEach((e) => {
509
509
  if (e.renditionLayout !== "pre-paginated") {
510
510
  let t = e.renderer.getDocumentFrame();
511
511
  t && H(t, "prose-reader-fonts", l());
512
512
  }
513
513
  }), e && s.layout();
514
- }), M(s.$.destroy$)).subscribe(), {
514
+ }), j(s.$.destroy$)).subscribe(), {
515
515
  ...s,
516
516
  destroy: () => {
517
517
  o.complete(), c.destroy(), s.destroy();
@@ -519,7 +519,7 @@ var Tt = class {
519
519
  settings: c
520
520
  };
521
521
  }, Ot = (e) => (t) => {
522
- let n = e(t), r = (e) => C(e, "keyup").pipe(w((e) => {
522
+ let n = e(t), r = (e) => w(e, "keyup").pipe(T((e) => {
523
523
  let { pageTurnDirection: t, computedPageTurnMode: r } = n.settings.values;
524
524
  if (r === "scrollable") return e;
525
525
  if (t === "horizontal") {
@@ -532,18 +532,18 @@ var Tt = class {
532
532
  }
533
533
  return e;
534
534
  }));
535
- return r(document).pipe(M(n.$.destroy$)).subscribe(), T(...n.spineItemsManager.items.map((e) => e.watch("isLoaded").pipe(j(() => {
535
+ return r(n.context.document).pipe(j(n.$.destroy$)).subscribe(), E(...n.spineItemsManager.items.map((e) => e.watch("isLoaded").pipe(A(() => {
536
536
  let t = e.renderer.getDocumentFrame();
537
- return t instanceof HTMLIFrameElement && t?.contentDocument ? r(t.contentDocument) : u;
538
- })))).pipe(M(n.$.destroy$)).subscribe(), n;
539
- }, kt = (e) => T(...e.spine.spineItemsManager.items.map((e) => e.watch("isLoaded").pipe(j(() => {
537
+ return V(t, "iframe") && t.contentDocument ? r(t.contentDocument) : u;
538
+ })))).pipe(j(n.$.destroy$)).subscribe(), n;
539
+ }, kt = (e) => E(...e.spine.spineItemsManager.items.map((e) => e.watch("isLoaded").pipe(A(() => {
540
540
  let t = e.renderer.getDocumentFrame();
541
- return t?.contentDocument ? T(...Array.from(t.contentDocument.querySelectorAll("a")).map((e) => C(e, "click"))) : d;
542
- })))).pipe(N((e) => {
541
+ return t?.contentDocument ? E(...Array.from(t.contentDocument.querySelectorAll("a")).map((e) => w(e, "click"))) : d;
542
+ })))).pipe(M((e) => {
543
543
  e.preventDefault();
544
544
  }), O()), U = class extends f {
545
545
  constructor(e) {
546
- super((e) => this.stateSubject.pipe(M(this._destroy$)).subscribe(e)), this._destroy$ = new m(), this.isDestroyed = !1, this.destroy$ = this._destroy$.asObservable(), this.stateSubject = new l(e), this.state$ = this.stateSubject.asObservable();
546
+ super((e) => this.stateSubject.pipe(j(this._destroy$)).subscribe(e)), this._destroy$ = new m(), this.isDestroyed = !1, this.destroy$ = this._destroy$.asObservable(), this.stateSubject = new l(e), this.state$ = this.stateSubject.asObservable();
547
547
  }
548
548
  next(e) {
549
549
  this.stateSubject.next(e);
@@ -556,7 +556,7 @@ var Tt = class {
556
556
  o(this.value, t) || this.stateSubject.next(t);
557
557
  }
558
558
  watch(e) {
559
- return Array.isArray(e) ? this.stateSubject.pipe(_t(e)) : this.stateSubject.pipe(w((t) => t[e]), y(o));
559
+ return Array.isArray(e) ? this.stateSubject.pipe(_t(e)) : this.stateSubject.pipe(T((t) => t[e]), b(o));
560
560
  }
561
561
  get value() {
562
562
  return this.stateSubject.value;
@@ -574,25 +574,25 @@ var Tt = class {
574
574
  error: void 0,
575
575
  documentContainer: void 0
576
576
  }), this.triggerSubject = new m(), this.context = e.context, this.settings = e.settings, this.hookManager = e.hookManager, this.item = e.item, this.containerElement = e.containerElement, this.resourcesHandler = e.resourcesHandler, this.viewport = e.viewport;
577
- let t = this.triggerSubject.pipe(b((e) => e.type === "unload")), n = this.triggerSubject.pipe(b((e) => e.type === "load"));
578
- this.loaded$ = n.pipe(E(() => this.value.state === "loaded" || this.value.state === "loading" ? u : (this.mergeCompare({
577
+ let t = this.triggerSubject.pipe(x((e) => e.type === "unload")), n = this.triggerSubject.pipe(x((e) => e.type === "load"));
578
+ this.loaded$ = n.pipe(ue(() => this.value.state === "loaded" || this.value.state === "loading" ? u : (this.mergeCompare({
579
579
  state: "loading",
580
580
  error: void 0
581
- }), this.onCreateDocument().pipe(x()).pipe(E((e) => (this.hookManager.execute("item.onDocumentCreated", {
581
+ }), this.onCreateDocument().pipe(S()).pipe(ue((e) => (this.hookManager.execute("item.onDocumentCreated", {
582
582
  itemId: this.item.id,
583
583
  documentContainer: e
584
- }), this.onLoadDocument().pipe(oe(null), x()).pipe(yt(this.context.bridgeEvent.viewportFree$), j(() => this.hookManager.fromExecuteAsync("item.onDocumentLoad", this.item.id, {
584
+ }), this.onLoadDocument().pipe(ae(null), S()).pipe(yt(this.context.bridgeEvent.viewportFree$), A(() => this.hookManager.fromExecuteAsync("item.onDocumentLoad", this.item.id, {
585
585
  itemId: this.item.id,
586
586
  documentContainer: e
587
- }))))), w(() => {
587
+ }))))), T(() => {
588
588
  this.mergeCompare({
589
589
  state: "loaded",
590
590
  error: void 0
591
591
  });
592
- }), M(t)))), O()), this.unloaded$ = t.pipe(E(() => this.value.state === "unloading" || this.value.state === "idle" ? u : (this.mergeCompare({
592
+ }), j(t)))), O()), this.unloaded$ = t.pipe(ue(() => this.value.state === "unloading" || this.value.state === "idle" ? u : (this.mergeCompare({
593
593
  state: "unloading",
594
594
  error: void 0
595
- }), this.context.bridgeEvent.viewportFree$.pipe(x(), w(() => {
595
+ }), this.context.bridgeEvent.viewportFree$.pipe(S(), T(() => {
596
596
  let e = this.value.documentContainer;
597
597
  if (e) try {
598
598
  this.hookManager.execute("item.onDocumentUnload", {
@@ -600,21 +600,21 @@ var Tt = class {
600
600
  documentContainer: e
601
601
  });
602
602
  } catch (e) {
603
- R.error("Error unloading document", e);
603
+ L.error("Error unloading document", e);
604
604
  }
605
605
  try {
606
606
  this.onUnload();
607
607
  } catch (e) {
608
- R.error("Error unloading document", e);
608
+ L.error("Error unloading document", e);
609
609
  }
610
610
  this.mergeCompare({
611
611
  state: "idle",
612
612
  error: void 0
613
613
  });
614
- }), M(n)))), O()), T(this.loaded$, this.unloaded$).pipe(_((e) => (this.mergeCompare({
614
+ }), j(n)))), O()), E(this.loaded$, this.unloaded$).pipe(_((e) => (this.mergeCompare({
615
615
  state: "error",
616
616
  error: e
617
- }), u)), M(this.destroy$)).subscribe();
617
+ }), u)), j(this.destroy$)).subscribe();
618
618
  }
619
619
  setDocumentContainer(t) {
620
620
  t.classList.add(e.DOCUMENT_CONTAINER_CLASS_NAME), this.mergeCompare({ documentContainer: t });
@@ -626,7 +626,7 @@ var Tt = class {
626
626
  this.documentContainer?.remove(), this.mergeCompare({ documentContainer: void 0 });
627
627
  }
628
628
  get isLoaded$() {
629
- return this.state$.pipe(w((e) => e.state === "loaded"));
629
+ return this.state$.pipe(T((e) => e.state === "loaded"));
630
630
  }
631
631
  load() {
632
632
  this.triggerSubject.next({ type: "load" });
@@ -636,16 +636,16 @@ var Tt = class {
636
636
  }
637
637
  renderHeadless() {
638
638
  let e = new m();
639
- return ie(() => this.onRenderHeadless({ release: e })).pipe(oe(void 0), x(), w((t) => {
639
+ return re(() => this.onRenderHeadless({ release: e })).pipe(ae(void 0), S(), T((t) => {
640
640
  if (t) return {
641
641
  doc: t,
642
642
  release: () => {
643
643
  e.next(void 0);
644
644
  }
645
645
  };
646
- }), ce(() => {
646
+ }), se(() => {
647
647
  e.complete();
648
- }), _((e) => (R.error(e), D(void 0))));
648
+ }), _((e) => (L.error(e), D(void 0))));
649
649
  }
650
650
  layout(e) {
651
651
  return this.onLayout(e);
@@ -660,12 +660,12 @@ var Tt = class {
660
660
  documentContainer: e
661
661
  });
662
662
  } catch (e) {
663
- R.error("Error while executing unload hooks on destroy", e);
663
+ L.error("Error while executing unload hooks on destroy", e);
664
664
  }
665
665
  try {
666
666
  this.onUnload();
667
667
  } catch (e) {
668
- R.error("Error while unloading document on destroy", e);
668
+ L.error("Error while unloading document on destroy", e);
669
669
  }
670
670
  }
671
671
  super.destroy();
@@ -690,7 +690,7 @@ var Tt = class {
690
690
  this.item = e, this.settings = t;
691
691
  }
692
692
  async getResource() {
693
- return await ue(this.settings.values.getResource?.(this.item) ?? D(void 0)) ?? jt(this.item);
693
+ return await le(this.settings.values.getResource?.(this.item) ?? D(void 0)) ?? jt(this.item);
694
694
  }
695
695
  async fetchResource() {
696
696
  let e = await this.getResource();
@@ -739,7 +739,7 @@ var Tt = class {
739
739
  let a = t.getAttribute("src") || t.getAttribute("href");
740
740
  if (!a) return D(null);
741
741
  let o = r.manifest.items.find(({ href: e }) => `${Nt(n, a).toLowerCase()}`.endsWith(`${e.toLowerCase()}`));
742
- return o ? S(new Mt(o, i).getResource()).pipe(E((e) => e instanceof Response ? S(e.blob()) : D(void 0)), E((a) => {
742
+ return o ? C(new Mt(o, i).getResource()).pipe(ue((e) => e instanceof Response ? C(e.blob()) : D(void 0)), ue((a) => {
743
743
  if (!a) return D(null);
744
744
  let o = e?.defaultView?.URL.createObjectURL(a) ?? "";
745
745
  if (t.hasAttribute("src")) t.setAttribute("src", o);
@@ -754,11 +754,11 @@ var Tt = class {
754
754
  });
755
755
  return D(null);
756
756
  })) : D(null);
757
- }, It = ({ settings: e, item: t, context: n }) => (r) => r.pipe(j((r) => {
758
- let a = qe(r.contentDocument), o = i(t.href), s = a.map((t) => Ft(r.contentDocument, t, o, n, e));
759
- return s.length === 0 ? D(r) : v(s).pipe(w(() => r));
757
+ }, It = ({ settings: e, item: t, context: n }) => (r) => r.pipe(A((r) => {
758
+ let a = Je(r.contentDocument), o = i(t.href), s = a.map((t) => Ft(r.contentDocument, t, o, n, e));
759
+ return s.length === 0 ? D(r) : v(s).pipe(T(() => r));
760
760
  })), Lt = (e) => {
761
- Je(e?.contentDocument);
761
+ Ye(e?.contentDocument);
762
762
  }, Rt = async (e, t) => {
763
763
  if (typeof e == "string") return new Blob([e], { type: "text/html" });
764
764
  let r = s(e.headers.get("Content-Type") || "") || n(t.href);
@@ -828,18 +828,18 @@ var Tt = class {
828
828
  let n = URL.createObjectURL(t);
829
829
  e.setAttribute("src", n);
830
830
  };
831
- return (r) => r.pipe(j((r) => S(t.getResource()).pipe(j((i) => {
831
+ return (r) => r.pipe(A((r) => C(t.getResource()).pipe(A((i) => {
832
832
  let a = zt.some((t) => e.href.endsWith(t)) || e.mediaType && Bt.includes(e.mediaType);
833
- return i instanceof URL && e.href.startsWith(window.location.origin) && !a ? (Vt(r), r?.setAttribute("src", i.href), D(r)) : (i instanceof URL ? S(t.fetchResource()) : D(i)).pipe(j((t) => {
833
+ return i instanceof URL && e.href.startsWith(window.location.origin) && !a ? (Vt(r), r?.setAttribute("src", i.href), D(r)) : (i instanceof URL ? C(t.fetchResource()) : D(i)).pipe(A((t) => {
834
834
  if (!(t instanceof Response)) throw Error("Invalid resource");
835
835
  return Rt(t, e);
836
- }), N((e) => {
836
+ }), M((e) => {
837
837
  n(r, e);
838
- }), w(() => r), _((t) => (R.error(`Error while trying to fetch or load resource for item ${e.id}`, i), R.error(t), D(r))));
838
+ }), T(() => r), _((t) => (L.error(`Error while trying to fetch or load resource for item ${e.id}`, i), L.error(t), D(r))));
839
839
  }))));
840
- }, Ut = () => {
841
- let e = document.createElement("iframe");
842
- return e.frameBorder = "no", e.tabIndex = 0, e.setAttribute("sandbox", "\n allow-same-origin \n allow-scripts \n allow-top-navigation-to-custom-protocols\n"), e.style.cssText = "\n overflow: hidden;\n background-color: transparent;\n border: 0px none transparent;\n padding: 0px;\n", e.setAttribute("role", "main"), e;
840
+ }, Ut = (e) => {
841
+ let t = e.createElement("iframe");
842
+ return t.frameBorder = "no", t.tabIndex = 0, t.setAttribute("sandbox", "\n allow-same-origin \n allow-scripts \n allow-top-navigation-to-custom-protocols\n"), t.style.cssText = "\n overflow: hidden;\n background-color: transparent;\n border: 0px none transparent;\n padding: 0px;\n", t.setAttribute("role", "main"), t;
843
843
  }, Wt = "body{margin:0}html,body{width:100%;height:100%}html[data-prose-reader-html-renderer-has-viewport-dimensions=false] body{display:flex}html[data-prose-reader-html-renderer-has-viewport-dimensions=false][data-prose-reader-html-renderer-spread-position=left] body{justify-content:flex-end}html[data-prose-reader-html-renderer-has-viewport-dimensions=false][data-prose-reader-html-renderer-spread-position=right] body{justify-content:flex-start}html[data-prose-reader-html-renderer-has-viewport-dimensions=false][data-prose-reader-html-renderer-spread-position=none] body{justify-content:center}:not(html.prose-reader-html-renderer-touch-enabled),:not(html.prose-reader-html-renderer-touch-enabled) body{touch-action:none}img{-webkit-user-select:none;user-select:none;-webkit-user-drag:none;-khtml-user-drag:none;-moz-user-drag:none;-o-user-drag:none;display:flex}html[data-prose-reader-html-renderer-has-viewport-dimensions=false] img{object-fit:contain;max-width:100%;height:100%}", Gt = ({ pageHeight: e, pageWidth: t, frameElement: n }) => {
844
844
  let r = at(n), i = r.width, a = r.height;
845
845
  !i && r.widthToken === "device-width" && (i = t), !a && r.heightToken === "device-height" && (a = e), !a && (i || r.widthToken === "device-width") && (a = e), !i && (a || r.heightToken === "device-height") && (i = t);
@@ -1009,10 +1009,10 @@ var Tt = class {
1009
1009
  width: o
1010
1010
  };
1011
1011
  }, nn = (e, t) => {
1012
- B(e.style, "width", `${t.width}px`), B(e.style, "height", `${t.height}px`);
1012
+ z(e.style, "width", `${t.width}px`), z(e.style, "height", `${t.height}px`);
1013
1013
  }, rn = ({ pageHeight: e, pageWidth: t, frameElement: n, manifest: r, renditionFlow: i, minPageSpread: a, isRTL: o, blankPagePosition: s, isImageType: c, enableTouch: l, isUsingVerticalWriting: u }) => {
1014
1014
  let d = a * t, f = r.renditionLayout === "reflowable" && i === "scrolled-continuous", p = f ? Math.min(400, e) : e;
1015
- B(n.style, "width", `${t}px`), f ? V(n.style, "height") : B(n.style, "height", `${p}px`);
1015
+ z(n.style, "width", `${t}px`), f ? B(n.style, "height") : z(n.style, "height", `${p}px`);
1016
1016
  let { viewportDimensions: m, computedScale: h = 1 } = Gt({
1017
1017
  frameElement: n,
1018
1018
  pageHeight: p,
@@ -1023,7 +1023,7 @@ var Tt = class {
1023
1023
  if (m?.hasViewport) H(n, "prose-reader-html-renderer-framce-css", Qt()), nn(n, {
1024
1024
  width: m.width ?? 1,
1025
1025
  height: m.height ?? 1
1026
- }), B(n.style, "position", "absolute"), B(n.style, "top", "50%"), B(n.style, "left", s === "before" ? o ? "25%" : "75%" : s === "after" ? o ? "75%" : "25%" : "50%"), B(n.style, "transform", `translate(-50%, -50%) scale(${h})`), B(n.style, "transform-origin", "center center");
1026
+ }), z(n.style, "position", "absolute"), z(n.style, "top", "50%"), z(n.style, "left", s === "before" ? o ? "25%" : "75%" : s === "after" ? o ? "75%" : "25%" : "50%"), z(n.style, "transform", `translate(-50%, -50%) scale(${h})`), z(n.style, "transform-origin", "center center");
1027
1027
  else if (H(n, "prose-reader-css", c ? $t({
1028
1028
  isScrollable: i === "scrolled-continuous",
1029
1029
  enableTouch: l
@@ -1047,7 +1047,7 @@ var Tt = class {
1047
1047
  height: r
1048
1048
  });
1049
1049
  }
1050
- return e % d === 0 ? B(n.style, "margin-left", "0px") : (e += t, o && !u && B(n.style, "margin-left", `${t}px`)), {
1050
+ return e % d === 0 ? z(n.style, "margin-left", "0px") : (e += t, o && !u && z(n.style, "margin-left", `${t}px`)), {
1051
1051
  width: e,
1052
1052
  height: r
1053
1053
  };
@@ -1057,7 +1057,7 @@ var Tt = class {
1057
1057
  super(...e), this.isPrePaginated = () => this.item.renditionLayout === "pre-paginated" || !this.item.renditionLayout && this.context.manifest.renditionLayout === "pre-paginated", this.isImageType = () => !!(this.item.mediaType ?? n(this.item.href))?.startsWith("image/");
1058
1058
  }
1059
1059
  onCreateDocument() {
1060
- let e = Ut();
1060
+ let e = Ut(this.context.document);
1061
1061
  return this.setDocumentContainer(e), D(e);
1062
1062
  }
1063
1063
  onLoadDocument() {
@@ -1067,15 +1067,15 @@ var Tt = class {
1067
1067
  item: this.item,
1068
1068
  resourcesHandler: this.resourcesHandler,
1069
1069
  settings: this.settings
1070
- }), yt(this.context.bridgeEvent.viewportFree$), N((e) => {
1070
+ }), yt(this.context.bridgeEvent.viewportFree$), M((e) => {
1071
1071
  this.prepareFrameForAttach(e), this.attach();
1072
- }), ot, N((e) => {
1072
+ }), ot, M((e) => {
1073
1073
  this.isPrePaginated() ? H(e, "prose-reader-css", Wt) : this.isImageType();
1074
1074
  }), It({
1075
1075
  context: this.context,
1076
1076
  item: this.item,
1077
1077
  settings: this.settings
1078
- }), st, N((e) => {
1078
+ }), st, M((e) => {
1079
1079
  this.revealFrameAfterReady(e);
1080
1080
  }));
1081
1081
  }
@@ -1087,7 +1087,7 @@ var Tt = class {
1087
1087
  let { width: r, height: i } = this.viewport.pageSize, a = this.getFrameElement();
1088
1088
  if (!a) return D(void 0);
1089
1089
  let o = this.settings.values.computedPageTurnMode === "scrollable";
1090
- if (a.contentDocument?.documentElement && (z(a.contentDocument.documentElement, "data-prose-reader-html-renderer-spread-position", n), o ? a.contentDocument?.documentElement.classList.add("prose-reader-html-renderer-touch-enabled") : a.contentDocument?.documentElement.classList.remove("prose-reader-html-renderer-touch-enabled")), this.isPrePaginated()) return D(Zt({
1090
+ if (a.contentDocument?.documentElement && (R(a.contentDocument.documentElement, "data-prose-reader-html-renderer-spread-position", n), o ? a.contentDocument?.documentElement.classList.add("prose-reader-html-renderer-touch-enabled") : a.contentDocument?.documentElement.classList.remove("prose-reader-html-renderer-touch-enabled")), this.isPrePaginated()) return D(Zt({
1091
1091
  blankPagePosition: t,
1092
1092
  frameElement: a,
1093
1093
  isRTL: this.context.isRTL(),
@@ -1112,7 +1112,7 @@ var Tt = class {
1112
1112
  }));
1113
1113
  }
1114
1114
  onRenderHeadless() {
1115
- return S(this.resourcesHandler.fetchResource()).pipe(j((e) => {
1115
+ return C(this.resourcesHandler.fetchResource()).pipe(A((e) => {
1116
1116
  if (e instanceof Response) {
1117
1117
  let t = e.headers.get("content-type") ?? "";
1118
1118
  if ([
@@ -1120,14 +1120,14 @@ var Tt = class {
1120
1120
  "application/xml",
1121
1121
  "text/html",
1122
1122
  "text/xml"
1123
- ].includes(t)) return S(e.text()).pipe(w((e) => new DOMParser().parseFromString(e, t)));
1123
+ ].includes(t)) return C(e.text()).pipe(T((e) => new DOMParser().parseFromString(e, t)));
1124
1124
  }
1125
1125
  return D(void 0);
1126
1126
  }));
1127
1127
  }
1128
1128
  getFrameElement() {
1129
1129
  let e = this.documentContainer;
1130
- if (e instanceof HTMLIFrameElement) return e;
1130
+ if (V(e, "iframe")) return e;
1131
1131
  }
1132
1132
  prepareFrameForAttach(e) {
1133
1133
  e.style.setProperty("visibility", "hidden"), e.style.setProperty("pointer-events", "none"), e.style.setProperty("contain", "layout paint size"), e.style.setProperty("display", "block");
@@ -1162,7 +1162,7 @@ var Tt = class {
1162
1162
  return t.getRenderer?.(e) ?? ((e) => new an(e));
1163
1163
  }
1164
1164
  }), r = kt(n);
1165
- return r.pipe(M(n.$.destroy$)).subscribe(), {
1165
+ return r.pipe(j(n.$.destroy$)).subscribe(), {
1166
1166
  ...n,
1167
1167
  links$: r
1168
1168
  };
@@ -1223,14 +1223,14 @@ var sn = class {
1223
1223
  y: u / c
1224
1224
  };
1225
1225
  }, mn = (e, t) => new Y(pn(e, t)), hn = (e) => ({ getSpinePositionFromClientPosition: (t) => e.spine.element ? mn(t, e.spine.element) : void 0 }), gn = (e) => {
1226
- let t, n = e.context.watch("rootElement").pipe(F((e) => e ? new f(() => (t = e.ownerDocument.createElement("div"), t.style.cssText = "\n position: absolute;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n visibility: hidden;\n ", e.appendChild(t), () => {
1226
+ let t, n = e.context.watch("rootElement").pipe(P((e) => e ? new f(() => (t = e.ownerDocument.createElement("div"), t.style.cssText = "\n position: absolute;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n visibility: hidden;\n ", e.appendChild(t), () => {
1227
1227
  t?.remove(), t = void 0;
1228
- })) : d)), r = (e) => de(e, h).pipe(L(() => {
1229
- t && B(t.style, "visibility", "hidden");
1230
- })), i = e.context.bridgeEvent.viewportBusy$.pipe(L(() => {
1231
- t && B(t.style, "visibility", "visible");
1232
- })), a = r(e.viewportFree$).pipe(Oe(1));
1233
- return T(n, e.settings.values$.pipe(Se(() => e.settings.values.computedPageTurnMode), ye()).pipe(F((e) => e === "controlled" ? i.pipe(F(() => a)) : r(D(void 0))), I(e.$.destroy$)));
1228
+ })) : d)), r = (e) => de(e, h).pipe(I(() => {
1229
+ t && z(t.style, "visibility", "hidden");
1230
+ })), i = e.context.bridgeEvent.viewportBusy$.pipe(I(() => {
1231
+ t && z(t.style, "visibility", "visible");
1232
+ })), a = r(e.viewportFree$).pipe(ke(1));
1233
+ return E(n, e.settings.values$.pipe(Ce(() => e.settings.values.computedPageTurnMode), be()).pipe(P((e) => e === "controlled" ? i.pipe(P(() => a)) : r(D(void 0))), F(e.$.destroy$)));
1234
1234
  }, _n = "@prose-reader/core", vn = 0, yn = 200, X = "prose-reader", bn = `${X}-style`, xn = `data-${X}-id`, Sn = `${X}-viewport`, Cn = `${X}-scroll-navigator`, wn = `${X}-spine-item`, Tn = `--${X}-absolute-viewport-width`, En = `--${X}-absolute-viewport-height`, Dn = `${X}-enhancer-loading`, On = `${Dn}-container`, kn = `${Dn}-logo`, An = `${Dn}-details`, jn = ({ container: e, item: t }) => {
1235
1235
  let n = e.ownerDocument.createElement("div");
1236
1236
  n.classList.add(On);
@@ -1239,11 +1239,11 @@ var sn = class {
1239
1239
  let i = n.ownerDocument.createElement("div");
1240
1240
  return i.classList.add(An), i.setAttribute("data-details-element", "true"), i.innerText = `loading ${t.id}`, n.appendChild(r), n.appendChild(i), n;
1241
1241
  }, Mn = (e) => e === "sepia" ? "#939393" : "rgb(202, 202, 202)", Nn = ({ loadingElement: e, theme: t }) => {
1242
- B(e.style, "color", Mn(t));
1242
+ z(e.style, "color", Mn(t));
1243
1243
  }, Pn = (e) => {
1244
1244
  let t = /* @__PURE__ */ new WeakMap();
1245
1245
  return e.hookManager.register("item.onBeforeContainerAttach", ({ element: n, item: r }) => {
1246
- B(n.style, "z-index", "0");
1246
+ z(n.style, "z-index", "0");
1247
1247
  let i = jn({
1248
1248
  container: n,
1249
1249
  item: r
@@ -1252,13 +1252,13 @@ var sn = class {
1252
1252
  loadingElement: i,
1253
1253
  theme: e.theme.get()
1254
1254
  }), t.set(n, i), n.appendChild(i);
1255
- }), T(e.spineItemsObserver.itemStateChange$.pipe(L(({ item: e, isError: n, error: r }) => {
1255
+ }), E(e.spineItemsObserver.itemStateChange$.pipe(I(({ item: e, isError: n, error: r }) => {
1256
1256
  if (!n) return;
1257
1257
  let i = t.get(e.containerElement);
1258
1258
  if (!i) return;
1259
1259
  let a = i.querySelector("[data-details-element]");
1260
- a instanceof HTMLElement && Ie(a, "innerText", r?.toString() ?? "Unknown error");
1261
- })), e.theme.$.theme$.pipe(L((n) => {
1260
+ Ze(a) && Le(a, "innerText", r?.toString() ?? "Unknown error");
1261
+ })), e.theme.$.theme$.pipe(I((n) => {
1262
1262
  for (let r of e.spineItemsManager.items) {
1263
1263
  let e = t.get(r.containerElement);
1264
1264
  e && Nn({
@@ -1270,16 +1270,16 @@ var sn = class {
1270
1270
  }, Fn = (e) => {
1271
1271
  e.hookManager.register("item.onDocumentLoad", async ({ itemId: t }) => {
1272
1272
  let n = e.spineItemsManager.get(t)?.renderer.getDocumentFrame();
1273
- n && z(n, "scrolling", "no");
1273
+ n && R(n, "scrolling", "no");
1274
1274
  });
1275
1275
  }, In = (e) => {
1276
1276
  e.hookManager.register("item.onAfterLayout", ({ item: t, blankPagePosition: n, minimumWidth: r }) => {
1277
1277
  let i = e.spineItemsManager.get(t.id), a = i?.renderer.getDocumentFrame();
1278
- if (i?.renditionLayout !== "reflowable" || !(a instanceof HTMLIFrameElement)) return;
1278
+ if (i?.renditionLayout !== "reflowable" || !V(a, "iframe")) return;
1279
1279
  let { hasViewport: o } = at(a), { width: s } = e.viewport.pageSize, c = i?.renderer.getDocumentFrame();
1280
- o && n === "none" && s < r && c instanceof HTMLIFrameElement && B(c.style, "left", e.context.isRTL() ? "75%" : "25%");
1280
+ o && n === "none" && s < r && V(c, "iframe") && z(c.style, "left", e.context.isRTL() ? "75%" : "25%");
1281
1281
  });
1282
- }, Ln = (e) => e.spineItemsObserver.itemStateChange$.pipe(N(({ item: e, isReady: t, isDirty: n }) => {
1282
+ }, Ln = (e) => e.spineItemsObserver.itemStateChange$.pipe(M(({ item: e, isReady: t, isDirty: n }) => {
1283
1283
  e.containerElement.dataset.isDirty = n.toString(), e.containerElement.dataset.isReady = t.toString();
1284
1284
  })), Rn = class extends Tt {
1285
1285
  computeOutputSettings(e) {
@@ -1309,7 +1309,7 @@ var sn = class {
1309
1309
  manifest: e,
1310
1310
  viewport: t
1311
1311
  })
1312
- }), Un = (e) => v([e.viewport.watch(["width", "height"]), e.context.watch("manifest")]).pipe(N(([t, n]) => e.settings.update({ spreadMode: Vn({
1312
+ }), Un = (e) => v([e.viewport.watch(["width", "height"]), e.context.watch("manifest")]).pipe(M(([t, n]) => e.settings.update({ spreadMode: Vn({
1313
1313
  manifest: n,
1314
1314
  viewport: t
1315
1315
  }) }))), Wn = (e) => (t) => {
@@ -1354,25 +1354,25 @@ var sn = class {
1354
1354
  `);
1355
1355
  }
1356
1356
  }), In(s), Fn(s), s.hookManager.register("item.onDocumentCreated", ({ documentContainer: e }) => {
1357
- B(e.style, "opacity", "0"), c.values.layoutLayerTransition && B(e.style, "transition", "opacity 800ms");
1357
+ z(e.style, "opacity", "0"), c.values.layoutLayerTransition && z(e.style, "transition", "opacity 800ms");
1358
1358
  }), s.hookManager.register("item.onBeforeLayout", ({ item: e }) => {
1359
1359
  let t = s.spineItemsManager.get(e.id)?.renderer.documentContainer;
1360
- s.settings.values.computedPageTurnMode !== "scrollable" && t && z(t, "tab-index", "0");
1360
+ s.settings.values.computedPageTurnMode !== "scrollable" && t && R(t, "tab-index", "0");
1361
1361
  });
1362
- let l = s.spineItemsObserver.itemStateChange$.pipe(be(({ isReady: e }) => e), L(({ item: e }) => {
1362
+ let l = s.spineItemsObserver.itemStateChange$.pipe(xe(({ isReady: e }) => e), I(({ item: e }) => {
1363
1363
  let t = e.renderer.documentContainer;
1364
- t && B(t.style, "opacity", "1");
1365
- })), u = c.values$.pipe(be(({ layoutAutoResize: e }) => e === "container"), F(() => s.context.watch("rootElement")), be(K), F((e) => vt(e)), ve(100), be(K), L(() => {
1364
+ t && z(t.style, "opacity", "1");
1365
+ })), u = c.values$.pipe(xe(({ layoutAutoResize: e }) => e === "container"), P(() => s.context.watch("rootElement")), xe(K), P((e) => vt(e)), ye(100), xe(K), I(() => {
1366
1366
  s?.layout();
1367
1367
  })), d = gn(s);
1368
- c.watch(["pageHorizontalMargin", "pageVerticalMargin"]).pipe(Ee(1), L(() => {
1368
+ c.watch(["pageHorizontalMargin", "pageVerticalMargin"]).pipe(De(1), I(() => {
1369
1369
  s.layout();
1370
- }), I(s.$.destroy$)).subscribe();
1371
- let f = s.spine.pages.pipe(Te({
1370
+ }), F(s.$.destroy$)).subscribe();
1371
+ let f = s.spine.pages.pipe(Ee({
1372
1372
  refCount: !0,
1373
1373
  bufferSize: 1
1374
1374
  }));
1375
- return T(l, d, u, f, Ln(s), Un(s), Pn(s)).pipe(I(s.$.destroy$)).subscribe(), {
1375
+ return E(l, d, u, f, Ln(s), Un(s), Pn(s)).pipe(F(s.$.destroy$)).subscribe(), {
1376
1376
  ...s,
1377
1377
  destroy: () => {
1378
1378
  c.destroy(), s.destroy();
@@ -1383,7 +1383,7 @@ var sn = class {
1383
1383
  coordinates: hn(s)
1384
1384
  };
1385
1385
  }, Gn = (e) => (t) => {
1386
- let n = e(t), r = new IntersectionObserver((e) => {
1386
+ let n = e(t), r = n.context.document.defaultView?.IntersectionObserver ?? IntersectionObserver, i = new r((e) => {
1387
1387
  e.forEach((e) => {
1388
1388
  let t = e.target, n = Array.from(t.contentDocument?.body.getElementsByTagName("audio") || []);
1389
1389
  e.isIntersecting ? n.forEach((e) => {
@@ -1392,43 +1392,43 @@ var sn = class {
1392
1392
  e.pause(), e.currentTime = 0;
1393
1393
  });
1394
1394
  });
1395
- }, { threshold: .01 }), i = new IntersectionObserver((e) => {
1395
+ }, { threshold: .01 }), a = new r((e) => {
1396
1396
  e.forEach((e) => {
1397
1397
  if (e.target.tagName === "video") {
1398
1398
  let t = e.target;
1399
1399
  e.isIntersecting ? t.hasAttribute("autoplay") && t.paused && t.readyState >= 2 && t.play().catch(console.error) : (t.pause(), t.currentTime = 0);
1400
1400
  }
1401
1401
  });
1402
- }, { threshold: .5 }), a = /* @__PURE__ */ new Map();
1402
+ }, { threshold: .5 }), o = /* @__PURE__ */ new Map();
1403
1403
  n.hookManager.register("item.onDocumentLoad", async ({ itemId: e }) => {
1404
- a.get(e)?.(), a.delete(e);
1404
+ o.get(e)?.(), o.delete(e);
1405
1405
  let t = n.spineItemsManager.get(e)?.renderer.getDocumentFrame();
1406
1406
  if (!t) return;
1407
- r.observe(t);
1408
- let o = t.contentDocument?.body.getElementsByTagName("video"), s = Array.from(o || []).map((e) => (i.observe(e), () => i.unobserve(e)));
1409
- a.set(e, () => {
1410
- r.unobserve(t), s.forEach((e) => {
1407
+ i.observe(t);
1408
+ let r = t.contentDocument?.body.getElementsByTagName("video"), s = Array.from(r || []).map((e) => (a.observe(e), () => a.unobserve(e)));
1409
+ o.set(e, () => {
1410
+ i.unobserve(t), s.forEach((e) => {
1411
1411
  e();
1412
1412
  });
1413
1413
  });
1414
1414
  }), n.hookManager.register("item.onDocumentUnload", ({ itemId: e }) => {
1415
- a.get(e)?.(), a.delete(e);
1415
+ o.get(e)?.(), o.delete(e);
1416
1416
  });
1417
- let o = () => {
1418
- r.disconnect(), i.disconnect(), a.clear(), n.destroy();
1417
+ let s = () => {
1418
+ i.disconnect(), a.disconnect(), o.clear(), n.destroy();
1419
1419
  };
1420
1420
  return {
1421
1421
  ...n,
1422
- destroy: o
1422
+ destroy: s
1423
1423
  };
1424
- }, Kn = (e) => (t) => t.pipe(j((t) => e.pipe(b((e) => e === "free"), x(), w(() => t)))), qn = ({ navigation$: e, navigationState$: t }) => e.pipe(Kn(t)), Jn = (e) => qn(e).pipe(fe(1)), Yn = (e) => (t) => t.pipe(M(Jn(e))), Xn = (e) => e.navigation.navigation$.pipe(b((e) => e.triggeredBy === "user"), Kn(e.navigation.navigationState$), w((t) => {
1424
+ }, Kn = (e) => (t) => t.pipe(A((t) => e.pipe(x((e) => e === "free"), S(), T(() => t)))), qn = ({ navigation$: e, navigationState$: t }) => e.pipe(Kn(t)), Jn = (e) => qn(e).pipe(fe(1)), Yn = (e) => (t) => t.pipe(j(Jn(e))), Xn = (e) => e.navigation.navigation$.pipe(x((e) => e.triggeredBy === "user"), Kn(e.navigation.navigationState$), T((t) => {
1425
1425
  let n = t.requestedPosition, r = t.requestedVisibleArea;
1426
1426
  return n && r ? e.navigation.navigationResolver.getBoundaryForPosition(n, r) : void 0;
1427
- }), b((e) => e !== void 0), w((e) => ({ boundary: e })), O()), Zn = (e, t) => e.links$.pipe(N((n) => {
1428
- if (!Ze(n.target, "a") || n.type !== "click") return;
1427
+ }), x((e) => e !== void 0), T((e) => ({ boundary: e })), O()), Zn = (e, t) => e.links$.pipe(M((n) => {
1428
+ if (!V(n.target, "a") || n.type !== "click") return;
1429
1429
  let r = new URL(n.target.href), i = `${r.origin}${r.pathname}`;
1430
1430
  e.context.manifest.spineItems.some((e) => e.href === i) && t.goToUrl(r);
1431
- })), Z = R.namespace("navigation"), Qn = ({ position: e, spineItem: t, pageHeight: n, pageWidth: r, spineItemLocator: i }) => {
1431
+ })), Z = L.namespace("navigation"), Qn = ({ position: e, spineItem: t, pageHeight: n, pageWidth: r, spineItemLocator: i }) => {
1432
1432
  let a = new q({
1433
1433
  x: e.x - r,
1434
1434
  y: e.y
@@ -1576,37 +1576,27 @@ var sn = class {
1576
1576
  turnBottom() {
1577
1577
  return this.turnRightOrBottom();
1578
1578
  }
1579
- turnRightOrBottom() {
1580
- let e = this.reader.navigation.getNavigation(), t = this.reader.spineItemsManager.get(e.spineItem);
1581
- if (!t) return;
1582
- let n = rr({
1579
+ turnWith(e) {
1580
+ let t = this.reader.navigation.getNavigation(), n = this.reader.spineItemsManager.get(t.spineItem);
1581
+ if (!n) return;
1582
+ let r = e({
1583
1583
  context: this.reader.context,
1584
1584
  navigationResolver: this.reader.navigation.navigationResolver,
1585
- position: e.position,
1585
+ position: t.position,
1586
1586
  computedPageTurnDirection: this.reader.settings.values.computedPageTurnDirection,
1587
- spineItem: t,
1587
+ spineItem: n,
1588
1588
  spineItemsManager: this.reader.spineItemsManager,
1589
1589
  spineLocator: this.reader.spine.locator,
1590
1590
  viewport: this.reader.viewport,
1591
1591
  settings: this.reader.settings
1592
1592
  });
1593
- return this.reader.navigation.navigate({ position: n });
1593
+ return this.reader.navigation.navigate({ position: r });
1594
+ }
1595
+ turnRightOrBottom() {
1596
+ return this.turnWith(rr);
1594
1597
  }
1595
1598
  turnLeftOrTop() {
1596
- let e = this.reader.navigation.getNavigation(), t = this.reader.spineItemsManager.get(e.spineItem);
1597
- if (!t) return;
1598
- let n = er({
1599
- context: this.reader.context,
1600
- navigationResolver: this.reader.navigation.navigationResolver,
1601
- position: e.position,
1602
- computedPageTurnDirection: this.reader.settings.values.computedPageTurnDirection,
1603
- spineItem: t,
1604
- spineItemsManager: this.reader.spineItemsManager,
1605
- spineLocator: this.reader.spine.locator,
1606
- viewport: this.reader.viewport,
1607
- settings: this.reader.settings
1608
- });
1609
- return this.reader.navigation.navigate({ position: n });
1599
+ return this.turnWith(er);
1610
1600
  }
1611
1601
  goToCfi(e, t = { animate: !0 }) {
1612
1602
  return this.reader.navigation.navigate({
@@ -1777,21 +1767,21 @@ var sn = class {
1777
1767
  }
1778
1768
  }, or = 500, sr = class extends Q {
1779
1769
  constructor(e, t) {
1780
- super(), this.scrollNavigationController = e, this.lock = t, this.navigationSubject = new m(), this.navigation$ = this.navigationSubject.asObservable(), T(this.scrollNavigationController.userScroll$.pipe(se((e) => {
1770
+ super(), this.scrollNavigationController = e, this.lock = t, this.navigationSubject = new m(), this.navigation$ = this.navigationSubject.asObservable(), E(this.scrollNavigationController.userScroll$.pipe(oe((e) => {
1781
1771
  let t = this.lock();
1782
- return T(this.scrollNavigationController.userScroll$, D(e)).pipe(ne(or, h), x(), N(() => {
1772
+ return E(this.scrollNavigationController.userScroll$, D(e)).pipe(te(or, h), S(), M(() => {
1783
1773
  let e = this.scrollNavigationController.fromScrollPosition(this.scrollNavigationController.scrollPosition);
1784
1774
  this.navigationSubject.next({
1785
1775
  animation: !1,
1786
1776
  type: "scroll",
1787
1777
  position: e
1788
1778
  });
1789
- }), ce(() => {
1779
+ }), se(() => {
1790
1780
  t();
1791
1781
  }));
1792
- }))).pipe(M(this.destroy$)).subscribe();
1782
+ }))).pipe(j(this.destroy$)).subscribe();
1793
1783
  }
1794
- }, cr = (e) => e.pagination.state$.pipe(P(e.settings.values$), w(([t, { computedPageTurnDirection: n }]) => {
1784
+ }, cr = (e) => e.pagination.state$.pipe(N(e.settings.values$), T(([t, { computedPageTurnDirection: n }]) => {
1795
1785
  let { spineItems: r, readingDirection: i } = e.context.manifest, a = r.length ?? 0, o = t.beginSpineItemIndex === 0, s = t.endSpineItemIndex === Math.max(a - 1, 0), c = t.endSpineItemIndex === Math.max(a - 1, 0), l = t.beginSpineItemIndex === 0, u = t.beginPageIndexInSpineItem === 0, d = t.endPageIndexInSpineItem === t.endNumberOfPagesInSpineItem - 1;
1796
1786
  return {
1797
1787
  canTurnLeft: n !== "vertical" && !u,
@@ -1801,21 +1791,21 @@ var sn = class {
1801
1791
  canGoLeftSpineItem: n !== "vertical" && (i === "ltr" && !o || i === "rtl" && !c),
1802
1792
  canGoRightSpineItem: n !== "vertical" && (i === "ltr" && !s || i === "rtl" && !l)
1803
1793
  };
1804
- }), y(a)), lr = ({ reader: e, duration: t }) => (n) => {
1794
+ }), b(a)), lr = ({ reader: e, duration: t }) => (n) => {
1805
1795
  let r, i = () => {
1806
1796
  r?.(), r = void 0;
1807
1797
  };
1808
- return n.pipe(N(() => {
1798
+ return n.pipe(M(() => {
1809
1799
  r ||= e?.navigation.lock();
1810
- }), he(t, void 0, {
1800
+ }), ge(t, void 0, {
1811
1801
  trailing: !0,
1812
1802
  leading: !0
1813
- }), N(i), ce(i));
1803
+ }), M(i), se(i));
1814
1804
  }, ur = (e) => (t) => {
1815
1805
  let n = e(t), r = cr(n), i = Xn(n), a = new ir(n), o = new ar(n), s = new sr(n.navigation.scrollNavigationController, n.navigation.lock);
1816
- T(Zn(n, a), s.navigation$.pipe(N((e) => {
1806
+ E(Zn(n, a), s.navigation$.pipe(M((e) => {
1817
1807
  n.navigation.navigate(e);
1818
- }))).pipe(M(n.$.destroy$)).subscribe();
1808
+ }))).pipe(j(n.$.destroy$)).subscribe();
1819
1809
  let c = (e) => {
1820
1810
  n.mount(e), t.cfi && a.goToCfi(t.cfi, { animate: !1 });
1821
1811
  }, l = () => {
@@ -1876,7 +1866,7 @@ var sn = class {
1876
1866
  };
1877
1867
  }, fr = (e, t) => {
1878
1868
  let n = e?.itemPageIndex, { itemIndex: r, ...i } = t.cfi.parseCfi(e.cfi), a = t.spineItemsManager.get(r);
1879
- return a ? xt().pipe(P(a.isReady$), w(([, o]) => {
1869
+ return a ? xt().pipe(N(a.isReady$), T(([, o]) => {
1880
1870
  let { node: s = null, offset: c, range: l } = o ? t.cfi.resolveCfi({ cfi: e.cfi }) : {};
1881
1871
  a.renditionLayout !== "pre-paginated" && s && (n = t.spine.locator.spineItemLocator.getSpineItemPageIndexFromNode(s, c ?? 0, a) ?? n);
1882
1872
  let u = e?.absolutePageIndex;
@@ -1909,16 +1899,16 @@ var sn = class {
1909
1899
  meta: dr(this.reader, e)
1910
1900
  };
1911
1901
  return St(() => {
1912
- let r = this.reader.spineItemsManager.get(n.meta.itemIndex ?? 0), i = r?.renditionLayout === "reflowable", a = t.mode === "shallow" || !i || !r ? () => {} : this.reader.spine.spineItemsLoader.forceOpen([r.index]), o = "cfi" in e ? e.cfi : void 0, s = o ? this.locatorsByKey.get(o) : void 0, c = (e) => e.pipe(ce(() => {
1902
+ let r = this.reader.spineItemsManager.get(n.meta.itemIndex ?? 0), i = r?.renditionLayout === "reflowable", a = t.mode === "shallow" || !i || !r ? () => {} : this.reader.spine.spineItemsLoader.forceOpen([r.index]), o = "cfi" in e ? e.cfi : void 0, s = o ? this.locatorsByKey.get(o) : void 0, c = (e) => e.pipe(se(() => {
1913
1903
  o && this.deregisterMemoizedStream(o), setTimeout(() => {
1914
1904
  a();
1915
1905
  }, 1e3);
1916
1906
  }));
1917
- if (o && s) return s.observerCount++, c(s.consolidate$.pipe(w(({ resource: e, meta: t }) => ({
1907
+ if (o && s) return s.observerCount++, c(s.consolidate$.pipe(T(({ resource: e, meta: t }) => ({
1918
1908
  resource: e,
1919
1909
  meta: t
1920
1910
  }))));
1921
- let l = this.reader.spine.layout$.pipe(ne(10), A(n), pe((e) => fr(e.meta, this.reader).pipe(w((t) => ({
1911
+ let l = this.reader.spine.layout$.pipe(te(10), pe(n), me((e) => fr(e.meta, this.reader).pipe(T((t) => ({
1922
1912
  ...e,
1923
1913
  meta: t
1924
1914
  }))), n), k({
@@ -1933,9 +1923,9 @@ var sn = class {
1933
1923
  };
1934
1924
  }
1935
1925
  locateResource(e, t) {
1936
- return Array.isArray(e) ? St(() => v(e.map((e) => this.locate(e, t ?? {}))).pipe(re([]))) : this.locate(e, t ?? {});
1926
+ return Array.isArray(e) ? St(() => v(e.map((e) => this.locate(e, t ?? {}))).pipe(ne([]))) : this.locate(e, t ?? {});
1937
1927
  }
1938
- }, mr = R.namespace("spine"), hr = ({ position: e, pageSize: t }) => new dn({
1928
+ }, mr = L.namespace("spine"), hr = ({ position: e, pageSize: t }) => new dn({
1939
1929
  ...e,
1940
1930
  left: e.x,
1941
1931
  top: e.y,
@@ -1955,7 +1945,7 @@ var sn = class {
1955
1945
  firstVisibleNode: void 0
1956
1946
  } : {
1957
1947
  ...n,
1958
- firstVisibleNode: Re(r, e.layout)
1948
+ firstVisibleNode: ze(r, e.layout)
1959
1949
  };
1960
1950
  }, vr = (e) => new f((t) => {
1961
1951
  if (e.length === 0) {
@@ -1988,7 +1978,7 @@ var sn = class {
1988
1978
  };
1989
1979
  }), yr = class e extends U {
1990
1980
  constructor(t, n, r, i, a, o) {
1991
- super({ pages: [] }), this.spineLayout = t, this.spineItemsManager = n, this.spineItemLocator = r, this.context = i, this.locator = a, this.viewport = o, this.fromSpineItemPageIndex = (t, n) => e.fromSpineItemPageIndex(this.value, t, n), this.fromNextPageWithinSameSpineItem = (t) => e.fromNextPageWithinSameSpineItem(this.value, t), this.fromAbsolutePageIndex = (t) => e.fromAbsolutePageIndex(this.value, t), this.observeFromAbsolutePageIndex = (e) => this.pipe(w(() => this.fromAbsolutePageIndex(e))), this.layout$ = t.layout$.pipe(P(o), j(([, { pageSize: e }]) => vr(n.items.reduce((t, n, i) => {
1981
+ super({ pages: [] }), this.spineLayout = t, this.spineItemsManager = n, this.spineItemLocator = r, this.context = i, this.locator = a, this.viewport = o, this.fromSpineItemPageIndex = (t, n) => e.fromSpineItemPageIndex(this.value, t, n), this.fromNextPageWithinSameSpineItem = (t) => e.fromNextPageWithinSameSpineItem(this.value, t), this.fromAbsolutePageIndex = (t) => e.fromAbsolutePageIndex(this.value, t), this.observeFromAbsolutePageIndex = (e) => this.pipe(T(() => this.fromAbsolutePageIndex(e))), this.layout$ = t.layout$.pipe(N(o), A(([, { pageSize: e }]) => vr(n.items.reduce((t, n, i) => {
1992
1982
  for (let o = 0; o < n.numberOfPages; o += 1) {
1993
1983
  let s = r.getSpineItemPositionFromPageIndex({
1994
1984
  spineItem: n,
@@ -2019,7 +2009,7 @@ var sn = class {
2019
2009
  });
2020
2010
  }
2021
2011
  return t;
2022
- }, []))), w((e) => (mr.info("Pages layout", e), { pages: e })), O()), this.layout$.pipe(M(this.destroy$)).subscribe(this.next.bind(this));
2012
+ }, []))), T((e) => (mr.info("Pages layout", e), { pages: e })), O()), this.layout$.pipe(j(this.destroy$)).subscribe(this.next.bind(this));
2023
2013
  }
2024
2014
  static {
2025
2015
  this.fromSpineItemPageIndex = (e, t, n) => {
@@ -2174,7 +2164,7 @@ var sn = class {
2174
2164
  }, Rr = (e, t) => e ? e.spineItems.reduce((n, r) => (n[r.id] = Lr(e, t, r), n), {}) : {}, zr = (e, t, n) => e + t * n, Br = (e, t, n) => {
2175
2165
  let { height: r, width: i } = n.layoutInfo, { top: a, left: o } = e.spine.getSpineItemSpineLayoutInfo(n);
2176
2166
  return e.settings.values.computedPageTurnDirection === "vertical" ? Math.max(0, Math.min(1, (t.y - a + e.viewport.absoluteViewport.height) / r)) : Math.max(0, Math.min(1, (t.x - o + e.viewport.absoluteViewport.width) / i));
2177
- }, Vr = (e, t, n, r, i, a) => i.isReady$.pipe(x(), P(e.layoutInfo$), w(([o, s]) => {
2167
+ }, Vr = (e, t, n, r, i, a) => i.isReady$.pipe(S(), N(e.layoutInfo$), T(([o, s]) => {
2178
2168
  let c = a.renditionLayout === "pre-paginated", l = a.spineItems.length || 0, u = a.spineItems.slice(0, t).reduce((e, t) => e + (t.progressionWeight ?? 0), 0) || 0, d = e.spineItemsManager.getSpineItemIndex(i) ?? 0, f = a.spineItems.length ?? 0, p = s.pages.filter((e) => e.itemIndex === d).length ?? 0, m = a.spineItems[t]?.progressionWeight ?? (d + 1) / f, h = (n + 1) * (m / p);
2179
2169
  !c && i.renditionLayout === "reflowable" && !o && (h = 0);
2180
2170
  let g = u + h;
@@ -2211,7 +2201,7 @@ var sn = class {
2211
2201
  }, Wr = (e, t) => e.numberOfTotalPages !== t.numberOfTotalPages || e.numberOfPagesPerItems.length !== t.numberOfPagesPerItems.length ? !1 : e.numberOfPagesPerItems.every((e, n) => e === t.numberOfPagesPerItems[n]), Gr = ({ reader: e, paginationInfo: t, navigationPosition: n, manifest: r }) => {
2212
2202
  let i = e.spineItemsManager.get(t.endSpineItemIndex);
2213
2203
  return i ? Vr(e, t.endSpineItemIndex ?? 0, t.endPageIndexInSpineItem || 0, n, i, r) : D(0);
2214
- }, Kr = (e) => D(e.context.manifest).pipe(w((e) => {
2204
+ }, Kr = (e) => D(e.context.manifest).pipe(T((e) => {
2215
2205
  let t = Tr(e.nav?.toc ?? [], e);
2216
2206
  return {
2217
2207
  tocCandidatesBySpineHref: Er({
@@ -2230,10 +2220,10 @@ var sn = class {
2230
2220
  bufferSize: 1,
2231
2221
  refCount: !0
2232
2222
  })), i = v([
2233
- t.pipe(w(qr), y(o)),
2223
+ t.pipe(T(qr), b(o)),
2234
2224
  r,
2235
2225
  n
2236
- ]).pipe(w(([t, n, r]) => Hr({
2226
+ ]).pipe(T(([t, n, r]) => Hr({
2237
2227
  beginItem: e.spineItemsManager.get(t.beginSpineItemIndex),
2238
2228
  endItem: e.spineItemsManager.get(t.endSpineItemIndex),
2239
2229
  paginationInfo: t,
@@ -2244,31 +2234,31 @@ var sn = class {
2244
2234
  refCount: !0
2245
2235
  })), a = v([
2246
2236
  t,
2247
- e.settings.watch(["computedSpreadMode"]).pipe(w((e) => e.computedSpreadMode ?? !1), y()),
2237
+ e.settings.watch(["computedSpreadMode"]).pipe(T((e) => e.computedSpreadMode ?? !1), b()),
2248
2238
  i,
2249
- n.pipe(w((t) => Ur({
2239
+ n.pipe(T((t) => Ur({
2250
2240
  items: e.spineItemsManager.items,
2251
2241
  pagesState: t
2252
- })), y(Wr))
2253
- ]).pipe(w(([e, t, n, r]) => ({
2242
+ })), b(Wr))
2243
+ ]).pipe(T(([e, t, n, r]) => ({
2254
2244
  ...e,
2255
2245
  ...n,
2256
2246
  isUsingSpread: t,
2257
2247
  ...r
2258
- }))), s = qn(e.navigation).pipe(w(({ position: e }) => e), y(o));
2248
+ }))), s = qn(e.navigation).pipe(T(({ position: e }) => e), b(o));
2259
2249
  return v([a, v([
2260
2250
  t,
2261
2251
  e.layout$,
2262
2252
  s
2263
- ]).pipe(j(([t, n, r]) => Gr({
2253
+ ]).pipe(A(([t, n, r]) => Gr({
2264
2254
  reader: e,
2265
2255
  paginationInfo: t,
2266
2256
  navigationPosition: r,
2267
2257
  manifest: e.context.manifest
2268
- })), w((e) => ({ percentageEstimateOfBook: e })))]).pipe(w(([e, t]) => ({
2258
+ })), T((e) => ({ percentageEstimateOfBook: e })))]).pipe(T(([e, t]) => ({
2269
2259
  ...e,
2270
2260
  ...t
2271
- })), y(o), g(5));
2261
+ })), b(o), g(5));
2272
2262
  }, Yr = (e) => (t) => {
2273
2263
  let n = e(t), r = new l({
2274
2264
  ...n.pagination.state,
@@ -2285,7 +2275,7 @@ var sn = class {
2285
2275
  endChapterInfo: void 0,
2286
2276
  endSpineItemReadingDirection: void 0,
2287
2277
  percentageEstimateOfBook: 0
2288
- }), i = new pr(n), a = Jr(n).pipe(N((e) => R.log("Pagination", e))).subscribe(r);
2278
+ }), i = new pr(n), a = Jr(n).pipe(M((e) => L.log("Pagination", e))).subscribe(r);
2289
2279
  return {
2290
2280
  ...n,
2291
2281
  locateResource: i.locateResource.bind(i),
@@ -2313,7 +2303,7 @@ var sn = class {
2313
2303
  n.setStart(e.node, r), n.setEnd(e.node, i);
2314
2304
  }
2315
2305
  } catch (n) {
2316
- R.warn("Failed to create range from selection", n, {
2306
+ L.warn("Failed to create range from selection", n, {
2317
2307
  anchor: e,
2318
2308
  focus: t
2319
2309
  });
@@ -2331,7 +2321,7 @@ var sn = class {
2331
2321
  offset: a
2332
2322
  });
2333
2323
  } catch (n) {
2334
- R.warn("Failed to create range from selection", n, {
2324
+ L.warn("Failed to create range from selection", n, {
2335
2325
  selection: e,
2336
2326
  spineItem: t
2337
2327
  });
@@ -2346,48 +2336,48 @@ var sn = class {
2346
2336
  let n = Ct(t.body, {
2347
2337
  childList: !0,
2348
2338
  subtree: !0
2349
- }).pipe(b((e) => !!e.find((e) => e.type === "childList" && e.removedNodes.length))), r = e.parentElement ? Ct(e.parentElement, { childList: !0 }).pipe(b((t) => !!t.find((t) => Array.from(t.removedNodes).includes(e)))) : D(null);
2350
- this.selectionChange$ = T(C(t, "selectionchange"), n).pipe(w(() => t.getSelection()), M(T(r, this.destroy$)), oe(null)), this.selectionOver$ = C(t, "pointerdown").pipe(j(() => T(C(t, "pointerup"), C(t, "pointercancel"), C(t, "contextmenu")).pipe(x(), ae(0), w((e) => {
2339
+ }).pipe(x((e) => !!e.find((e) => e.type === "childList" && e.removedNodes.length))), r = e.parentElement ? Ct(e.parentElement, { childList: !0 }).pipe(x((t) => !!t.find((t) => Array.from(t.removedNodes).includes(e)))) : D(null);
2340
+ this.selectionChange$ = E(w(t, "selectionchange"), n).pipe(T(() => t.getSelection()), j(E(r, this.destroy$)), ae(null)), this.selectionOver$ = w(t, "pointerdown").pipe(A(() => E(w(t, "pointerup"), w(t, "pointercancel"), w(t, "contextmenu")).pipe(S(), ie(0), T((e) => {
2351
2341
  let n = t.getSelection();
2352
2342
  return n && !n.isCollapsed ? [e, n] : void 0;
2353
- }), b(K))), M(T(r, this.destroy$)));
2343
+ }), x(K))), j(E(r, this.destroy$)));
2354
2344
  }
2355
2345
  }
2356
- }, $r = (e) => e.watch("isLoaded").pipe(j(() => {
2346
+ }, $r = (e) => e.watch("isLoaded").pipe(A(() => {
2357
2347
  let t = e.renderer.getDocumentFrame(), n = t?.contentDocument || t?.contentWindow?.document;
2358
2348
  if (!t || !n) return d;
2359
2349
  let r = new Qr(t);
2360
- return T(r.selectionChange$.pipe(w((e) => {
2350
+ return E(r.selectionChange$.pipe(T((e) => {
2361
2351
  if (e?.toString()) return {
2362
2352
  type: "change",
2363
2353
  selection: e
2364
2354
  };
2365
- })), r.selectionOver$.pipe(w(([e, t]) => ({
2355
+ })), r.selectionOver$.pipe(T(([e, t]) => ({
2366
2356
  type: "over",
2367
2357
  event: e,
2368
2358
  selection: t
2369
- })))).pipe(M(e.unloaded$), oe(void 0), ce(() => {
2359
+ })))).pipe(j(e.unloaded$), ae(void 0), se(() => {
2370
2360
  r.destroy();
2371
2361
  }));
2372
- }), y()), ei = (e) => (t) => {
2373
- let n = e(t), r, i = T(...n.spineItemsManager.items.map((e) => {
2362
+ }), b()), ei = (e) => (t) => {
2363
+ let n = e(t), r, i = E(...n.spineItemsManager.items.map((e) => {
2374
2364
  let t = n.spineItemsManager.getSpineItemIndex(e) ?? 0;
2375
- return $r(e).pipe(w((e) => {
2365
+ return $r(e).pipe(T((e) => {
2376
2366
  if (e) return {
2377
2367
  ...e,
2378
2368
  itemIndex: t
2379
2369
  };
2380
2370
  }));
2381
- })).pipe(A(void 0), y(), N((e) => {
2371
+ })).pipe(pe(void 0), b(), M((e) => {
2382
2372
  r = e;
2383
2373
  }), k({
2384
2374
  refCount: !0,
2385
2375
  bufferSize: 1
2386
- })), a = i, o = i.pipe(w((e) => !!e), y(), b((e) => e), O()), s = o.pipe(j(() => a), y(), b((e) => !e), O()), c = i.pipe(b((e) => e?.type === "over"), O()), l = n.context.watch("rootElement").pipe(b(K), j((e) => C(e, "pointerdown")), P(a), w(([, e]) => e), A(void 0), k({
2376
+ })), a = i, o = i.pipe(T((e) => !!e), b(), x((e) => e), O()), s = o.pipe(A(() => a), b(), x((e) => !e), O()), c = i.pipe(x((e) => e?.type === "over"), O()), l = n.context.watch("rootElement").pipe(x(K), A((e) => w(e, "pointerdown")), N(a), T(([, e]) => e), pe(void 0), k({
2387
2377
  refCount: !0,
2388
2378
  bufferSize: 1
2389
2379
  }));
2390
- return T(a, l).pipe(M(n.$.destroy$)).subscribe(), {
2380
+ return E(a, l).pipe(j(n.$.destroy$)).subscribe(), {
2391
2381
  ...n,
2392
2382
  selection: {
2393
2383
  selection$: a,
@@ -2430,7 +2420,7 @@ var sn = class {
2430
2420
  `;
2431
2421
  }, a = ({ container: e }) => {
2432
2422
  let t = ti.find((e) => e.name === r.value);
2433
- return t && B(e.style, "background-color", t.backgroundColor), () => {};
2423
+ return t && z(e.style, "background-color", t.backgroundColor), () => {};
2434
2424
  }, o = () => {
2435
2425
  n.spineItemsManager.items.forEach((e) => {
2436
2426
  let t = e.renderer.getDocumentFrame();
@@ -2443,9 +2433,9 @@ var sn = class {
2443
2433
  let e = t?.renderer.getDocumentFrame();
2444
2434
  e && H(e, "prose-reader-theme", i());
2445
2435
  }
2446
- }), r.pipe(L(() => {
2436
+ }), r.pipe(I(() => {
2447
2437
  o();
2448
- }), I(n.$.destroy$)).subscribe(), {
2438
+ }), F(n.$.destroy$)).subscribe(), {
2449
2439
  ...n,
2450
2440
  theme: {
2451
2441
  set: (e) => {
@@ -2456,7 +2446,7 @@ var sn = class {
2456
2446
  }
2457
2447
  };
2458
2448
  }, ri = (e) => (t) => {
2459
- let n = e(t), r = (e) => !!(Xe(e) && (e.nodeName === "a" ? e : e.closest("a"))?.getAttribute("href")), i = (e, t, r) => {
2449
+ let n = e(t), r = (e) => !!(Ze(e) && (e.nodeName === "a" ? e : e.closest("a"))?.getAttribute("href")), i = (e, t, r) => {
2460
2450
  let i = r.replace("${id}", n.id);
2461
2451
  return $e(e, `${t}-${n.id}`, i);
2462
2452
  };
@@ -2481,9 +2471,9 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
2481
2471
  y: Math.min(Math.max(e.y, a.minY), a.maxY)
2482
2472
  };
2483
2473
  }, oi = (e, t, n) => {
2484
- B(n.style, "transform-origin", "0 0");
2474
+ z(n.style, "transform-origin", "0 0");
2485
2475
  let r = `translate3d(${t.x}px, ${t.y}px, 0px)`, i = `scale(${e})`;
2486
- B(n.style, "transform", `${r} ${i}`);
2476
+ z(n.style, "transform", `${r} ${i}`);
2487
2477
  }, si = (e, t, n, r) => {
2488
2478
  let i = t / e, a = n.clientWidth, o = n.clientHeight, s = a / 2 - r.x, c = o / 2 - r.y;
2489
2479
  return {
@@ -2508,20 +2498,20 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
2508
2498
  left: n.x,
2509
2499
  top: n.y,
2510
2500
  behavior: "instant"
2511
- }), _e(1).pipe(N(() => {
2501
+ }), ve(1).pipe(M(() => {
2512
2502
  this.scrollingSubject.next(!1);
2513
- }), M(T(this.scrollingSubject.pipe(fe(1)), this.destroy$))).subscribe(), this.hookManager.execute("onViewportOffsetAdjust", void 0));
2503
+ }), j(E(this.scrollingSubject.pipe(fe(1)), this.destroy$))).subscribe(), this.hookManager.execute("onViewportOffsetAdjust", void 0));
2514
2504
  }, this.isActive = () => this.settings.values.computedPageTurnMode === "scrollable", this.getNavigationVisibleArea = () => this.viewport.relativeViewport;
2515
- let a = this.context.pipe(_t(["rootElement"]), N(({ rootElement: e }) => {
2505
+ let a = this.context.pipe(_t(["rootElement"]), M(({ rootElement: e }) => {
2516
2506
  if (!e) return;
2517
- let t = document.createElement("div");
2507
+ let t = this.context.document.createElement("div");
2518
2508
  t.setAttribute(`data-${Cn}`, ""), t.appendChild(this.viewport.value.element), e.appendChild(t), this.update({ element: t });
2519
- })), o = v([t.watch(["computedPageTurnMode"]), this.watch("element")]).pipe(N(([{ computedPageTurnMode: e }, t]) => {
2520
- t && (e === "scrollable" ? B(t.style, "display", "block") : B(t.style, "display", "contents"));
2521
- })), s = this.navigateSubject.pipe(N(this.applyNavigationPosition));
2509
+ })), o = v([t.watch(["computedPageTurnMode"]), this.watch("element")]).pipe(M(([{ computedPageTurnMode: e }, t]) => {
2510
+ t && (e === "scrollable" ? z(t.style, "display", "block") : z(t.style, "display", "contents"));
2511
+ })), s = this.navigateSubject.pipe(M(this.applyNavigationPosition));
2522
2512
  this.isNavigating$ = this.scrollingSubject.asObservable();
2523
- let c = v([T(r.element$.pipe(b(K), j((e) => vt(e))), r.element$.pipe(b(K), j((e) => C(e, "scroll"))), r.spineItemsObserver.itemResize$).pipe(j(() => _e(10).pipe(w(() => !1), A(!0))), y(), A(!1)), this.isNavigating$]).pipe(w(([e, t]) => e || t), k(1));
2524
- this.userScroll$ = this.watch("element").pipe(b(K), j((e) => t.watch(["computedPageTurnMode"]).pipe(j(({ computedPageTurnMode: t }) => t === "controlled" ? d : C(e, "scroll").pipe(P(c), b(([, e]) => !e), w(([e]) => e))))), O()), T(a, o, s).pipe(M(this.destroy$)).subscribe();
2513
+ let c = v([E(r.element$.pipe(x(K), A((e) => vt(e))), r.element$.pipe(x(K), A((e) => w(e, "scroll"))), r.spineItemsObserver.itemResize$).pipe(A(() => ve(10).pipe(T(() => !1), pe(!0))), b(), pe(!1)), this.isNavigating$]).pipe(T(([e, t]) => e || t), k(1));
2514
+ this.userScroll$ = this.watch("element").pipe(x(K), A((e) => t.watch(["computedPageTurnMode"]).pipe(A(({ computedPageTurnMode: t }) => t === "controlled" ? d : w(e, "scroll").pipe(N(c), x(([, e]) => !e), T(([e]) => e))))), O()), E(a, o, s).pipe(j(this.destroy$)).subscribe();
2525
2515
  }
2526
2516
  update(e) {
2527
2517
  this.mergeCompare(e);
@@ -2560,8 +2550,8 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
2560
2550
  y: p - o / 2 + i
2561
2551
  });
2562
2552
  }, pi = (e, t) => {
2563
- let n = t.viewport, r = t.navigation.scrollNavigationController, i = n.value.element, a = r.value.element, o = r.value.element, s = Math.round(n.scaleFactor * 100) / 100, c = i.offsetLeft, l = i.offsetTop, u = fi(a ?? Ke(), s, e, c, l), d = e < 1 ? "down" : "up";
2564
- o && z(o, `data-${X}-zooming-direction`, d), e < 1 ? B(i.style, "transform-origin", "top") : e > 1 && B(i.style, "transform-origin", `${c}px ${l}px`), B(i.style, "transform", `scale(${e})`);
2553
+ let n = t.viewport, r = t.navigation.scrollNavigationController, i = n.value.element, a = r.value.element, o = r.value.element, s = Math.round(n.scaleFactor * 100) / 100, c = i.offsetLeft, l = i.offsetTop, u = fi(a ?? qe(), s, e, c, l), d = e < 1 ? "down" : "up";
2554
+ o && R(o, `data-${X}-zooming-direction`, d), e < 1 ? z(i.style, "transform-origin", "top") : e > 1 && z(i.style, "transform-origin", `${c}px ${l}px`), z(i.style, "transform", `scale(${e})`);
2565
2555
  let f = r.fromScrollPosition(u);
2566
2556
  t.navigation.navigate({ position: f });
2567
2557
  }, mi = 200, hi = class extends U {
@@ -2573,32 +2563,32 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
2573
2563
  x: 0,
2574
2564
  y: 0
2575
2565
  }
2576
- }), this.reader = e, this.enterSubject = new m(), this.exitSubject = new m(), T(this.enterSubject.pipe(j((e) => {
2566
+ }), this.reader = e, this.enterSubject = new m(), this.exitSubject = new m(), E(this.enterSubject.pipe(A((e) => {
2577
2567
  let { scale: t = 1, animate: n = !1 } = e ?? {}, r = this.reader.viewport.value.element;
2578
- z(this.viewport.element, `data-${X}-zooming`, "true");
2568
+ R(this.viewport.element, `data-${X}-zooming`, "true");
2579
2569
  let i = this.scrollNavigationController.value.element;
2580
- return i && z(i, `data-${X}-zooming`, this.isControlled ? "false" : "true"), n && this.isControlled && B(r.style, "transition", `transform ${mi}ms`), this.mergeCompare({
2570
+ return i && R(i, `data-${X}-zooming`, this.isControlled ? "false" : "true"), n && this.isControlled && z(r.style, "transition", `transform ${mi}ms`), this.mergeCompare({
2581
2571
  isZooming: !0,
2582
2572
  currentScale: 1,
2583
2573
  currentPosition: {
2584
2574
  x: 0,
2585
2575
  y: 0
2586
2576
  }
2587
- }), this.updateZoom(t), t !== 1 && this.isControlled ? _e(e?.animate ? mi : 0).pipe(N(() => {
2577
+ }), this.updateZoom(t), t !== 1 && this.isControlled ? ve(e?.animate ? mi : 0).pipe(M(() => {
2588
2578
  this.reader.layout();
2589
2579
  })) : u;
2590
- })), this.exitSubject.pipe(j((e) => {
2580
+ })), this.exitSubject.pipe(A((e) => {
2591
2581
  let t = this.reader.viewport.value.element;
2592
- z(this.viewport.element, `data-${X}-zooming`, "false");
2582
+ R(this.viewport.element, `data-${X}-zooming`, "false");
2593
2583
  let n = this.scrollNavigationController.value.element;
2594
- return n && (Fe(n, `data-${X}-zooming-direction`), z(n, `data-${X}-zooming`, "false")), e?.animate && this.isControlled && B(t.style, "transition", `transform ${mi}ms`), this.updateZoom(1, {
2584
+ return n && (Ie(n, `data-${X}-zooming-direction`), R(n, `data-${X}-zooming`, "false")), e?.animate && this.isControlled && z(t.style, "transition", `transform ${mi}ms`), this.updateZoom(1, {
2595
2585
  x: 0,
2596
2586
  y: 0
2597
- }), V(t.style, "transform"), this.mergeCompare({ isZooming: !1 }), _e(e?.animate ? mi : 0).pipe(N(() => {
2587
+ }), B(t.style, "transform"), this.mergeCompare({ isZooming: !1 }), ve(e?.animate ? mi : 0).pipe(M(() => {
2598
2588
  let e = this.reader.viewport.value.element;
2599
- V(e.style, "transform-origin"), V(e.style, "transition"), this.isControlled && this.reader.layout();
2600
- }), M(this.enterSubject));
2601
- }))).pipe(M(this.destroy$)).subscribe();
2589
+ B(e.style, "transform-origin"), B(e.style, "transition"), this.isControlled && this.reader.layout();
2590
+ }), j(this.enterSubject));
2591
+ }))).pipe(j(this.destroy$)).subscribe();
2602
2592
  }
2603
2593
  enter(e) {
2604
2594
  this.enterSubject.next(e);
@@ -2607,11 +2597,11 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
2607
2597
  this.exitSubject.next(e);
2608
2598
  }
2609
2599
  move(e, t) {
2610
- this.isControlled && (V(this.viewport.element.style, "transition"), this.updateZoom(this.value.currentScale, e, { constraints: t?.constrain === "within-viewport" ? (...e) => ai(...e, this.reader.viewport) : void 0 }));
2600
+ this.isControlled && (B(this.viewport.element.style, "transition"), this.updateZoom(this.value.currentScale, e, { constraints: t?.constrain === "within-viewport" ? (...e) => ai(...e, this.reader.viewport) : void 0 }));
2611
2601
  }
2612
2602
  scaleAt(e, t) {
2613
2603
  if (!this.value.isZooming) return;
2614
- V(this.viewport.element.style, "transition");
2604
+ B(this.viewport.element.style, "transition");
2615
2605
  let n = Math.ceil(e * 100) / 100;
2616
2606
  this.updateZoom(n, void 0, { constraints: t?.constrain === "within-viewport" ? (...e) => ai(...e, this.reader.viewport) : void 0 });
2617
2607
  }
@@ -2655,12 +2645,12 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
2655
2645
  }
2656
2646
  }
2657
2647
  };
2658
- }, _i = (e) => ke({
2648
+ }, _i = (e) => Ae({
2659
2649
  spineIndex: e.index,
2660
2650
  spineId: e.id
2661
2651
  }), vi = ({ nodeOrRange: e, offset: t, item: n }) => {
2662
2652
  let r = "ownerDocument" in e ? e.ownerDocument : e.startContainer.ownerDocument;
2663
- return !r?.documentElement || e === r ? _i(n) : Qe(e) ? ke({
2653
+ return !r?.documentElement || e === r ? _i(n) : Qe(e) ? Ae({
2664
2654
  start: {
2665
2655
  node: e.startContainer,
2666
2656
  offset: e.startOffset,
@@ -2673,7 +2663,7 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
2673
2663
  spineIndex: n.index,
2674
2664
  spineId: n.id
2675
2665
  }
2676
- }) : ke({
2666
+ }) : Ae({
2677
2667
  node: e,
2678
2668
  offset: t,
2679
2669
  spineIndex: n.index,
@@ -2686,8 +2676,8 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
2686
2676
  }).trim(), bi = (e, t) => vi({
2687
2677
  nodeOrRange: e,
2688
2678
  item: t
2689
- }), xi = (e) => e.index.toString(), Si = (e) => e[0]?.index === 6 && e.length > 1, Ci = (e) => Ae(Me(e)), wi = (e) => Array.isArray(e) ? e[0] && Si(e[0]) ? e[0] : void 0 : e.parent[0] && Si(e.parent[0]) ? e.parent[0] : void 0, Ti = (e) => {
2690
- let t = Me(e), n = ((wi(t) ?? [])[1]?.index ?? 2) / 2 - 1, r = je(t);
2679
+ }), xi = (e) => e.index.toString(), Si = (e) => e[0]?.index === 6 && e.length > 1, Ci = (e) => je(Ne(e)), wi = (e) => Array.isArray(e) ? e[0] && Si(e[0]) ? e[0] : void 0 : e.parent[0] && Si(e.parent[0]) ? e.parent[0] : void 0, Ti = (e) => {
2680
+ let t = Ne(e), n = ((wi(t) ?? [])[1]?.index ?? 2) / 2 - 1, r = Me(t);
2691
2681
  return {
2692
2682
  isCfiRange: r,
2693
2683
  itemIndex: n,
@@ -2701,10 +2691,10 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
2701
2691
  node: null
2702
2692
  };
2703
2693
  let a = i.renderer.getDocumentFrame();
2704
- if (a instanceof HTMLIFrameElement) {
2694
+ if (V(a, "iframe")) {
2705
2695
  let t = a.contentWindow?.document;
2706
2696
  if (t) try {
2707
- let a = Ne(e, t, { throwOnError: !0 });
2697
+ let a = Pe(e, t, { throwOnError: !0 });
2708
2698
  return {
2709
2699
  ...r,
2710
2700
  itemIndex: n,
@@ -2715,7 +2705,7 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
2715
2705
  spineItem: i
2716
2706
  };
2717
2707
  } catch (t) {
2718
- return R.warn(`Error resolving cfi: ${e}.`), R.warn(t), {
2708
+ return L.warn(`Error resolving cfi: ${e}.`), L.warn(t), {
2719
2709
  ...r,
2720
2710
  spineItem: i,
2721
2711
  itemIndex: n,
@@ -2764,15 +2754,15 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
2764
2754
  }
2765
2755
  }, Oi = (e) => e.spineItems.every((t) => (t.renditionLayout ?? e.renditionLayout) === "pre-paginated"), ki = class {
2766
2756
  constructor() {
2767
- this.navigationSubject = new p(1), this.positionSubject = new p(1), this.viewportStateSubject = new l("free"), this.paginationSubject = new p(1), this.pagination$ = this.paginationSubject.asObservable(), this.viewportState$ = this.viewportStateSubject.asObservable(), this.viewportFree$ = this.viewportState$.pipe(b((e) => e === "free")), this.viewportBusy$ = this.viewportState$.pipe(b((e) => e === "busy")), this.navigation$ = this.navigationSubject.asObservable(), this.position$ = this.positionSubject.asObservable();
2757
+ this.navigationSubject = new p(1), this.positionSubject = new p(1), this.viewportStateSubject = new l("free"), this.paginationSubject = new p(1), this.pagination$ = this.paginationSubject.asObservable(), this.viewportState$ = this.viewportStateSubject.asObservable(), this.viewportFree$ = this.viewportState$.pipe(x((e) => e === "free")), this.viewportBusy$ = this.viewportState$.pipe(x((e) => e === "busy")), this.navigation$ = this.navigationSubject.asObservable(), this.position$ = this.positionSubject.asObservable();
2768
2758
  }
2769
2759
  }, Ai = class extends U {
2770
- constructor(e) {
2760
+ constructor(e, t = globalThis.document) {
2771
2761
  super({
2772
2762
  manifest: e,
2773
2763
  assumedRenditionLayout: e.renditionLayout ?? "reflowable",
2774
2764
  isFullyPrePaginated: Oi(e)
2775
- }), this.bridgeEvent = new ki(), this.isRTL = () => this.value.manifest.readingDirection === "rtl";
2765
+ }), this.bridgeEvent = new ki(), this.isRTL = () => this.value.manifest.readingDirection === "rtl", this.document = t;
2776
2766
  }
2777
2767
  update(e) {
2778
2768
  this.mergeCompare(e);
@@ -2794,12 +2784,12 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
2794
2784
  supportedPageTurnMode: ["controlled", "scrollable"],
2795
2785
  supportedPageTurnDirection: ["horizontal", "vertical"],
2796
2786
  supportedComputedPageTurnDirection: ["horizontal", "vertical"]
2797
- }), v([e.watch(["hasVerticalWriting"]), t.watch(["computedPageTurnMode"])]).pipe(w(([{ hasVerticalWriting: t }, { computedPageTurnMode: n }]) => ({
2787
+ }), v([e.watch(["hasVerticalWriting"]), t.watch(["computedPageTurnMode"])]).pipe(T(([{ hasVerticalWriting: t }, { computedPageTurnMode: n }]) => ({
2798
2788
  hasVerticalWriting: t,
2799
2789
  renditionFlow: e.manifest.renditionFlow,
2800
2790
  renditionLayout: e.manifest.renditionLayout,
2801
2791
  computedPageTurnMode: n
2802
- })), y(o), w(({ hasVerticalWriting: e, renditionFlow: t, renditionLayout: n, computedPageTurnMode: r }) => ({
2792
+ })), b(o), T(({ hasVerticalWriting: e, renditionFlow: t, renditionLayout: n, computedPageTurnMode: r }) => ({
2803
2793
  ...this.value,
2804
2794
  supportedPageTurnMode: t === "scrolled-continuous" ? ["scrollable"] : ["controlled", "scrollable"],
2805
2795
  supportedPageTurnAnimation: t === "scrolled-continuous" || r === "scrollable" ? ["none"] : e ? ["fade", "none"] : [
@@ -2808,7 +2798,7 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
2808
2798
  "slide"
2809
2799
  ],
2810
2800
  supportedPageTurnDirection: r === "scrollable" ? ["vertical"] : n === "reflowable" ? ["horizontal"] : ["horizontal", "vertical"]
2811
- })), M(this.destroy$)).subscribe(this.next.bind(this));
2801
+ })), j(this.destroy$)).subscribe(this.next.bind(this));
2812
2802
  }
2813
2803
  }, Mi = class {
2814
2804
  constructor() {
@@ -2902,21 +2892,21 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
2902
2892
  }) : new J({
2903
2893
  x: -e.x,
2904
2894
  y: -e.y
2905
- }), Ii = R.namespace("navigation/ControlledNavigationController"), Li = class extends Q {
2895
+ }), Ii = L.namespace("navigation/ControlledNavigationController"), Li = class extends Q {
2906
2896
  constructor(e, t, n, r, i) {
2907
- super(), this.settings = e, this.hookManager = t, this.context = n, this.spine = r, this.viewport = i, this.navigateSubject = new m(), this.element$ = new l(document.createElement("div")), this.isActive = () => this.settings.values.computedPageTurnMode === "controlled", this.getNavigationVisibleArea = () => this.viewport.absoluteViewport;
2908
- let o = this.spine.element$.pipe(b(K), P(this.element$), N(([e, t]) => {
2897
+ super(), this.settings = e, this.hookManager = t, this.context = n, this.spine = r, this.viewport = i, this.navigateSubject = new m(), this.isActive = () => this.settings.values.computedPageTurnMode === "controlled", this.getNavigationVisibleArea = () => this.viewport.absoluteViewport, this.element$ = new l(n.document.createElement("div"));
2898
+ let o = this.spine.element$.pipe(x(K), N(this.element$), M(([e, t]) => {
2909
2899
  t.style.cssText = "\n height: 100%;\n width: 100%;\n position: relative;\n ", t.className = `${X}-controlled-navigator`, t.innerHTML = "", t.appendChild(e), this.viewport.value.element.appendChild(t), this.element$.next(t);
2910
2900
  })), s = v([e.watch([
2911
2901
  "computedPageTurnDirection",
2912
2902
  "computedPageTurnMode",
2913
2903
  "numberOfAdjacentSpineItemToPreLoad"
2914
- ]), this.element$]).pipe(N(([, t]) => {
2915
- e.values.computedPageTurnMode === "scrollable" ? B(t.style, "display", "contents") : B(t.style, "display", "block");
2904
+ ]), this.element$]).pipe(M(([, t]) => {
2905
+ e.values.computedPageTurnMode === "scrollable" ? z(t.style, "display", "contents") : z(t.style, "display", "block");
2916
2906
  }));
2917
- this.layout$ = s.pipe(N(() => {
2907
+ this.layout$ = s.pipe(M(() => {
2918
2908
  Ii.info("layout", e.values);
2919
- }), O()), this.isNavigating$ = this.navigateSubject.pipe(y((e, t) => a(e.position, t.position)), w(({ animation: t, position: n }) => (Ii.info("Navigation requested", {
2909
+ }), O()), this.isNavigating$ = this.navigateSubject.pipe(b((e, t) => a(e.position, t.position)), T(({ animation: t, position: n }) => (Ii.info("Navigation requested", {
2920
2910
  animation: t,
2921
2911
  position: n
2922
2912
  }), {
@@ -2924,28 +2914,28 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
2924
2914
  shouldAnimate: !(!t || t === "turn" && e.values.computedPageTurnAnimation === "none"),
2925
2915
  animation: t,
2926
2916
  position: n
2927
- })), j((t) => {
2917
+ })), A((t) => {
2928
2918
  let n = this.element$.getValue();
2929
- return B(n.style, "transition", "none"), B(n.style, "opacity", "1"), T(D(!0), D(null).pipe(E(() => {
2919
+ return z(n.style, "transition", "none"), z(n.style, "opacity", "1"), E(D(!0), D(null).pipe(ue(() => {
2930
2920
  if (t?.type !== "manualAdjust") return D(!1);
2931
2921
  let n = t.animation === "snap" ? e.values.snapAnimationDuration : e.values.computedPageTurnAnimationDuration, r = t.animation === "snap" ? "slide" : e.values.computedPageTurnAnimation;
2932
- return D(t).pipe(t.shouldAnimate ? ae(1, h) : le, N((e) => {
2922
+ return D(t).pipe(t.shouldAnimate ? ie(1, h) : ce, M((e) => {
2933
2923
  let i = this.element$.getValue();
2934
- e.shouldAnimate ? r === "fade" ? (B(i.style, "transition", `opacity ${n / 2}ms`), B(i.style, "opacity", "0")) : (t.animation === "snap" || r === "slide") && (B(i.style, "transition", `transform ${n}ms`), B(i.style, "opacity", "1")) : (B(i.style, "transition", "none"), B(i.style, "opacity", "1"));
2935
- }), N((e) => {
2924
+ e.shouldAnimate ? r === "fade" ? (z(i.style, "transition", `opacity ${n / 2}ms`), z(i.style, "opacity", "0")) : (t.animation === "snap" || r === "slide") && (z(i.style, "transition", `transform ${n}ms`), z(i.style, "opacity", "1")) : (z(i.style, "transition", "none"), z(i.style, "opacity", "1"));
2925
+ }), M((e) => {
2936
2926
  r !== "fade" && this.applyNavigationPosition(e.position);
2937
- }), t.shouldAnimate ? ae(n / 2, h) : le, N((e) => {
2927
+ }), t.shouldAnimate ? ie(n / 2, h) : ce, M((e) => {
2938
2928
  let t = this.element$.getValue();
2939
- r === "fade" && (this.applyNavigationPosition(e.position), B(t.style, "opacity", "1"));
2940
- }), t.shouldAnimate ? ae(n / 2, h) : le, N((e) => {
2929
+ r === "fade" && (this.applyNavigationPosition(e.position), z(t.style, "opacity", "1"));
2930
+ }), t.shouldAnimate ? ie(n / 2, h) : ce, M((e) => {
2941
2931
  r === "fade" && this.applyNavigationPosition(e.position);
2942
2932
  }));
2943
- }), w(() => !1)));
2944
- }), A(!1), k(1)), T(o, this.isNavigating$, this.layout$).pipe(M(this.destroy$)).subscribe();
2933
+ }), T(() => !1)));
2934
+ }), pe(!1), k(1)), E(o, this.isNavigating$, this.layout$).pipe(j(this.destroy$)).subscribe();
2945
2935
  }
2946
2936
  applyNavigationPosition(e) {
2947
2937
  let t = this.element$.getValue(), n = Pi(e);
2948
- B(t.style, "transform", `translate(${n.x}px, ${n.y}px)`), this.hookManager.execute("onViewportOffsetAdjust", void 0);
2938
+ z(t.style, "transform", `translate(${n.x}px, ${n.y}px)`), this.hookManager.execute("onViewportOffsetAdjust", void 0);
2949
2939
  }
2950
2940
  navigate(e) {
2951
2941
  this.navigateSubject.next(e);
@@ -2954,26 +2944,26 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
2954
2944
  super.destroy(), this.element$.getValue().remove(), this.element$.complete();
2955
2945
  }
2956
2946
  get viewportPosition() {
2957
- let e = this.element$.getValue(), t = window.getComputedStyle(e), n = t.transform || t.webkitTransform;
2947
+ let e = this.element$.getValue(), t = e.ownerDocument.defaultView?.getComputedStyle(e), n = t?.transform || t?.webkitTransform;
2958
2948
  return !n || n === "none" ? new J({
2959
2949
  x: 0,
2960
2950
  y: 0
2961
2951
  }) : Fi(new DOMMatrix(n));
2962
2952
  }
2963
- }, Ri = () => (e) => e.pipe(w(({ navigation: e, pagination: t, ...n }) => ({
2953
+ }, Ri = () => (e) => e.pipe(T(({ navigation: e, pagination: t, ...n }) => ({
2964
2954
  navigation: {
2965
2955
  ...e,
2966
2956
  paginationBeginCfi: t.beginCfi
2967
2957
  },
2968
2958
  ...n
2969
- }))), zi = (e, t, n) => e.bridgeEvent.pagination$.pipe(P(t), b(([e, t]) => e.navigationId === t.id), j(([e, t]) => (n.spineItemsManager.get(t.spineItem)?.isReady$.pipe(x()) ?? D(!1)).pipe(b((e) => e), w(() => ({
2959
+ }))), zi = (e, t, n) => e.bridgeEvent.pagination$.pipe(N(t), x(([e, t]) => e.navigationId === t.id), A(([e, t]) => (n.spineItemsManager.get(t.spineItem)?.isReady$.pipe(S()) ?? D(!1)).pipe(x((e) => e), T(() => ({
2970
2960
  pagination: e,
2971
2961
  navigation: t
2972
- })))), Ri(), y((e, t) => e.navigation.paginationBeginCfi === t.navigation.paginationBeginCfi), w(({ navigation: e }) => ({
2962
+ })))), Ri(), b((e, t) => e.navigation.paginationBeginCfi === t.navigation.paginationBeginCfi), T(({ navigation: e }) => ({
2973
2963
  ...e,
2974
2964
  meta: { triggeredBy: "pagination" },
2975
2965
  requestedPosition: e.position
2976
- }))), Bi = ({ navigationResolver: e, getNavigationVisibleArea: t }) => (n) => n.pipe(w(([n, r]) => {
2966
+ }))), Bi = ({ navigationResolver: e, getNavigationVisibleArea: t }) => (n) => n.pipe(T(([n, r]) => {
2977
2967
  let i = n.position, a = i ? t() : void 0, o = i && a ? e.clampPositionInSpine(i, a) : void 0;
2978
2968
  return {
2979
2969
  previousNavigation: r,
@@ -2988,7 +2978,7 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
2988
2978
  position: o
2989
2979
  }
2990
2980
  };
2991
- })), Vi = ({ navigationResolver: e }) => (t) => t.pipe(w((t) => {
2981
+ })), Vi = ({ navigationResolver: e }) => (t) => t.pipe(T((t) => {
2992
2982
  if (t.navigation.cfi) {
2993
2983
  let n = e.getNavigationForCfi(t.navigation.cfi);
2994
2984
  if (n) return {
@@ -3000,7 +2990,7 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
3000
2990
  };
3001
2991
  }
3002
2992
  return t;
3003
- })), Hi = ({ navigation: e, previousNavigation: t, settings: n }) => e.directionFromLastNavigation ? e.directionFromLastNavigation : e.url !== void 0 || e.cfi !== void 0 ? "anchor" : t.spineItem === void 0 || e.spineItem || !e.position ? "forward" : n.values.computedPageTurnDirection === "vertical" ? e.position.y > t.position.y || e.position.y === t.position.y && t.directionFromLastNavigation !== "backward" ? "forward" : "backward" : Math.abs(e.position.x) > Math.abs(t.position.x) || e.position.x === t.position.x && t.directionFromLastNavigation !== "backward" ? "forward" : "backward", Ui = ({ context: e, settings: t }) => (n) => n.pipe(w(({ navigation: n, previousNavigation: r }) => {
2993
+ })), Hi = ({ navigation: e, previousNavigation: t, settings: n }) => e.directionFromLastNavigation ? e.directionFromLastNavigation : e.url !== void 0 || e.cfi !== void 0 ? "anchor" : t.spineItem === void 0 || e.spineItem || !e.position ? "forward" : n.values.computedPageTurnDirection === "vertical" ? e.position.y > t.position.y || e.position.y === t.position.y && t.directionFromLastNavigation !== "backward" ? "forward" : "backward" : Math.abs(e.position.x) > Math.abs(t.position.x) || e.position.x === t.position.x && t.directionFromLastNavigation !== "backward" ? "forward" : "backward", Ui = ({ context: e, settings: t }) => (n) => n.pipe(T(({ navigation: n, previousNavigation: r }) => {
3004
2994
  let i = Hi({
3005
2995
  context: e,
3006
2996
  navigation: n,
@@ -3015,7 +3005,7 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
3015
3005
  },
3016
3006
  direction: i
3017
3007
  };
3018
- })), Wi = ({ spineItemsManager: e, navigationResolver: t, settings: n, viewport: r }) => (i) => i.pipe(w(({ navigation: i, ...a }) => {
3008
+ })), Wi = ({ spineItemsManager: e, navigationResolver: t, settings: n, viewport: r }) => (i) => i.pipe(T(({ navigation: i, ...a }) => {
3019
3009
  let o = e.get(i.spineItem);
3020
3010
  if (i.position) return n.values.computedPageTurnMode === "scrollable" ? {
3021
3011
  navigation: {
@@ -3084,7 +3074,7 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
3084
3074
  }
3085
3075
  return o && d === "scrollable" ? r.getSpineItemFromPosition(o) : t.get(0);
3086
3076
  };
3087
- return a.pipe(w(({ navigation: e, ...n }) => {
3077
+ return a.pipe(T(({ navigation: e, ...n }) => {
3088
3078
  let r = o(e);
3089
3079
  return {
3090
3080
  navigation: {
@@ -3094,9 +3084,9 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
3094
3084
  ...n
3095
3085
  };
3096
3086
  }));
3097
- }, Ki = ({ spine: e }) => (t) => t.pipe(j(({ navigation: t, ...n }) => {
3087
+ }, Ki = ({ spine: e }) => (t) => t.pipe(A(({ navigation: t, ...n }) => {
3098
3088
  let r = e.getSpineItemSpineLayoutInfo(t.spineItem), i = e.spineItemsManager.get(t.spineItem);
3099
- return (i?.isReady$ ?? D(!1)).pipe(x(), w((e) => ({
3089
+ return (i?.isReady$ ?? D(!1)).pipe(S(), T((e) => ({
3100
3090
  navigation: {
3101
3091
  ...t,
3102
3092
  spineItemHeight: r?.height,
@@ -3138,14 +3128,14 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
3138
3128
  return n.getSpineItemPositionFromSpinePosition(i.position, s);
3139
3129
  }
3140
3130
  };
3141
- return i.pipe(w(({ navigation: e, ...t }) => ({
3131
+ return i.pipe(T(({ navigation: e, ...t }) => ({
3142
3132
  navigation: {
3143
3133
  ...e,
3144
3134
  positionInSpineItem: a(e)
3145
3135
  },
3146
3136
  ...t
3147
3137
  })));
3148
- }, Ji = ({ navigationResolver: e }) => (t) => t.pipe(w((t) => {
3138
+ }, Ji = ({ navigationResolver: e }) => (t) => t.pipe(T((t) => {
3149
3139
  if (t.navigation.url) {
3150
3140
  let n = e.getNavigationForUrl(t.navigation.url);
3151
3141
  if (n) return {
@@ -3160,7 +3150,7 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
3160
3150
  return t;
3161
3151
  })), Yi = class {
3162
3152
  constructor() {
3163
- this.isLockedSubject = new l(0), this.isLocked$ = this.isLockedSubject.pipe(w((e) => !!e), y());
3153
+ this.isLockedSubject = new l(0), this.isLocked$ = this.isLockedSubject.pipe(T((e) => !!e), b());
3164
3154
  }
3165
3155
  lock() {
3166
3156
  let e = !1;
@@ -3170,7 +3160,7 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
3170
3160
  }
3171
3161
  }, Xi = ({ spineLocator: e, navigation: t, navigationResolver: n, spineItemsManager: r, spine: i, cfiManager: a }) => {
3172
3162
  let o = r.get(t.spineItem);
3173
- return o ? o.isReady$.pipe(x(), w((r) => {
3163
+ return o ? o.isReady$.pipe(S(), T((r) => {
3174
3164
  let s = i.getSpineItemSpineLayoutInfo(o), c = e.isPositionWithinSpineItem(t.position, o), l = s.width - (t.spineItemWidth ?? 0), u = s.height - (t.spineItemHeight ?? 0), d = l !== 0 || u !== 0;
3175
3165
  if (t.url !== void 0 && (l || u || r && !t.spineItemIsReady)) {
3176
3166
  let e = n.getNavigationForUrl(t.url);
@@ -3273,7 +3263,7 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
3273
3263
  spineItemsManager: t,
3274
3264
  spine: a,
3275
3265
  cfiManager: o
3276
- }), $i = ({ settings: e, navigationResolver: t, context: n, spine: r, cfiManager: i }) => (a) => a.pipe(j((a) => Qi({
3266
+ }), $i = ({ settings: e, navigationResolver: t, context: n, spine: r, cfiManager: i }) => (a) => a.pipe(A((a) => Qi({
3277
3267
  spineLocator: r.locator,
3278
3268
  navigation: a.navigation,
3279
3269
  navigationResolver: t,
@@ -3283,13 +3273,13 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
3283
3273
  context: n,
3284
3274
  spine: r,
3285
3275
  cfiManager: i
3286
- }).pipe(w((e) => ({
3276
+ }).pipe(T((e) => ({
3287
3277
  ...a,
3288
3278
  navigation: {
3289
3279
  ...a.navigation,
3290
3280
  position: e
3291
3281
  }
3292
- }))))), ea = R.namespace("navigation/InternalNavigator"), ta = (e, t) => e === t || !!e && !!t && e.x === t.x && e.y === t.y, na = (e, t) => e === t || !!e && !!t && e.width === t.width && e.height === t.height, ra = (e, t) => e.id === t.id && ta(e.position, t.position) && ta(e.requestedPosition, t.requestedPosition) && na(e.requestedVisibleArea, t.requestedVisibleArea), ia = class extends Q {
3282
+ }))))), ea = L.namespace("navigation/InternalNavigator"), ta = (e, t) => e === t || !!e && !!t && e.x === t.x && e.y === t.y, na = (e, t) => e === t || !!e && !!t && e.width === t.width && e.height === t.height, ra = (e, t) => e.id === t.id && ta(e.position, t.position) && ta(e.requestedPosition, t.requestedPosition) && na(e.requestedVisibleArea, t.requestedVisibleArea), ia = class extends Q {
3293
3283
  constructor(e, t, n, r, i, a, o, s, c, u) {
3294
3284
  super(), this.settings = e, this.context = t, this.userNavigation$ = n, this.getActiveNavigationModeController = r, this.navigationModeLayout$ = i, this.navigationResolver = a, this.spine = o, this.viewport = s, this.cfiManager = c, this.isUserInteractionLocked$ = u, this.navigationSubject = new l({
3295
3285
  animation: !1,
@@ -3305,14 +3295,14 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
3305
3295
  spineItemIsReady: !1,
3306
3296
  type: "api",
3307
3297
  id: Symbol("init")
3308
- }), this.navigation$ = this.navigationSubject.pipe(w(({ position: e, id: t, requestedPosition: n, requestedVisibleArea: r, meta: i }) => ({
3298
+ }), this.navigation$ = this.navigationSubject.pipe(T(({ position: e, id: t, requestedPosition: n, requestedVisibleArea: r, meta: i }) => ({
3309
3299
  position: e,
3310
3300
  id: t,
3311
3301
  requestedPosition: n,
3312
3302
  requestedVisibleArea: r,
3313
3303
  triggeredBy: i.triggeredBy
3314
- })), y(ra), k(1)), this.locker = new Yi();
3315
- let d = n.pipe(P(this.navigationSubject), Bi({
3304
+ })), b(ra), k(1)), this.locker = new Yi();
3305
+ let d = n.pipe(N(this.navigationSubject), Bi({
3316
3306
  navigationResolver: a,
3317
3307
  getNavigationVisibleArea: () => r().getNavigationVisibleArea()
3318
3308
  }), Ji({ navigationResolver: a }), Vi({ navigationResolver: a }), Ui({
@@ -3335,9 +3325,9 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
3335
3325
  spineItemsManager: o.spineItemsManager,
3336
3326
  settings: e,
3337
3327
  viewport: s
3338
- }), P(u), j(([n, r]) => {
3328
+ }), N(u), A(([n, r]) => {
3339
3329
  let i = n.navigation.cfi || n.navigation.url || e.values.computedPageTurnMode === "scrollable" || r;
3340
- return D(n).pipe(i ? le : $i({
3330
+ return D(n).pipe(i ? ce : $i({
3341
3331
  navigationResolver: a,
3342
3332
  settings: e,
3343
3333
  spine: o,
@@ -3349,25 +3339,25 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
3349
3339
  spineLocator: o.locator,
3350
3340
  settings: e,
3351
3341
  navigationResolver: a
3352
- }), w((e) => e.navigation), O()), f = d.pipe(P(u), b(([, e]) => e), j(([e]) => {
3342
+ }), T((e) => e.navigation), O()), f = d.pipe(N(u), x(([, e]) => e), A(([e]) => {
3353
3343
  let t = this.locker.lock();
3354
- return u.pipe(b((e) => !e), x(), w(() => ({ navigation: {
3344
+ return u.pipe(x((e) => !e), S(), T(() => ({ navigation: {
3355
3345
  ...e,
3356
3346
  animation: "snap"
3357
- } })), ce(() => {
3347
+ } })), se(() => {
3358
3348
  t();
3359
- }), M(d));
3349
+ }), j(d));
3360
3350
  }), O());
3361
- T(T(T(i, o.layout$).pipe(j(() => D(null).pipe(j(() => u.pipe(b((e) => !e), x())), w(() => ({ navigation: {
3351
+ E(E(E(i, o.layout$).pipe(A(() => D(null).pipe(A(() => u.pipe(x((e) => !e), S())), T(() => ({ navigation: {
3362
3352
  ...this.navigationSubject.getValue(),
3363
3353
  animation: !1
3364
- } })), M(T(f, d))))), f).pipe($i({
3354
+ } })), j(E(f, d))))), f).pipe($i({
3365
3355
  navigationResolver: a,
3366
3356
  settings: e,
3367
3357
  context: t,
3368
3358
  spine: o,
3369
3359
  cfiManager: c
3370
- }), w(({ navigation: e }) => ({ navigation: {
3360
+ }), T(({ navigation: e }) => ({ navigation: {
3371
3361
  ...e,
3372
3362
  meta: { triggeredBy: "restoration" },
3373
3363
  requestedPosition: e.position
@@ -3383,7 +3373,7 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
3383
3373
  spineLocator: o.locator,
3384
3374
  settings: e,
3385
3375
  navigationResolver: a
3386
- }), w(({ navigation: e }) => e), O()), d, zi(t, this.navigationSubject, o)).pipe(P(this.navigationSubject), (e) => e.pipe(N(([e]) => {
3376
+ }), T(({ navigation: e }) => e), O()), d, zi(t, this.navigationSubject, o)).pipe(N(this.navigationSubject), (e) => e.pipe(M(([e]) => {
3387
3377
  let t = e.type === "scroll", n = e.meta.triggeredBy === "pagination", r = e.meta.triggeredBy === "restoration";
3388
3378
  if (t && !r || n) return;
3389
3379
  let i = {
@@ -3391,12 +3381,12 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
3391
3381
  animation: e.animation
3392
3382
  };
3393
3383
  this.getActiveNavigationModeController().navigate(i);
3394
- })), (e) => e.pipe(N(([e, t]) => {
3384
+ })), (e) => e.pipe(M(([e, t]) => {
3395
3385
  ea.info(`navigation updated from ${e.meta.triggeredBy} of type ${e.type}`, {
3396
3386
  previousNavigation: t,
3397
3387
  currentNavigation: e
3398
3388
  }), this.navigationSubject.next(e);
3399
- })), M(this.destroy$)).subscribe();
3389
+ })), j(this.destroy$)).subscribe();
3400
3390
  }
3401
3391
  get navigation() {
3402
3392
  return this.navigationSubject.getValue();
@@ -3446,7 +3436,7 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
3446
3436
  }, pa = ({ context: e, settings: t, viewport: n }) => {
3447
3437
  let r = (e, t, r) => {
3448
3438
  let i;
3449
- e?.nodeName === "img" || e?.textContent === "" && e.nodeType === Node.ELEMENT_NODE ? i = e.getBoundingClientRect().x : e && (i = (e ? He(e, t) : void 0)?.getBoundingClientRect().x || i);
3439
+ e?.nodeName === "img" || e?.textContent === "" && e.nodeType === Node.ELEMENT_NODE ? i = e.getBoundingClientRect().x : e && (i = (e ? Ue(e, t) : void 0)?.getBoundingClientRect().x || i);
3450
3440
  let a = r.layoutInfo?.width || 0, o = n.pageSize.width;
3451
3441
  if (i !== void 0) return new q({
3452
3442
  x: sa(i, o, a),
@@ -3637,7 +3627,7 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
3637
3627
  visibleAreaRectWidth: a.absoluteViewport.width
3638
3628
  });
3639
3629
  }, ba = (e, t) => {
3640
- if (t && t instanceof HTMLIFrameElement) {
3630
+ if (V(t, "iframe")) {
3641
3631
  let n = t.contentDocument, r = e.trim();
3642
3632
  if (!n || r.length === 0) return;
3643
3633
  if (r.startsWith("#")) {
@@ -3743,7 +3733,7 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
3743
3733
  getNavigationForCfi: (e) => {
3744
3734
  let { node: t, offset: r = 0, spineItem: i } = o.resolveCfi({ cfi: e });
3745
3735
  if (!i) {
3746
- R.warn(Ea, `unable to detect item id from cfi ${e}`);
3736
+ L.warn(Ea, `unable to detect item id from cfi ${e}`);
3747
3737
  return;
3748
3738
  }
3749
3739
  let c = t ? s.getNavigationFromNode(i, t, r) : new q({
@@ -3837,11 +3827,11 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
3837
3827
  locator: r.locator,
3838
3828
  spine: r,
3839
3829
  viewport: a
3840
- }), p = new Li(i, n, t, r, a), h = new di(a, i, n, r, t), g = [h, p], _ = new ia(i, t, l, () => g.find((e) => e.isActive()) ?? p, T(...g.flatMap((e) => e.layout$ ? [e.layout$] : [])), f, r, a, d, u.isLocked$), ee = v([
3830
+ }), p = new Li(i, n, t, r, a), h = new di(a, i, n, r, t), g = [h, p], _ = new ia(i, t, l, () => g.find((e) => e.isActive()) ?? p, E(...g.flatMap((e) => e.layout$ ? [e.layout$] : [])), f, r, a, d, u.isLocked$), y = v([
3841
3831
  ...g.map((e) => e.isNavigating$),
3842
3832
  u.isLocked$,
3843
3833
  _.locker.isLocked$
3844
- ]).pipe(w((e) => e.some((e) => e) ? "busy" : "free"), y(), k(1)), te = _.navigation$.pipe(w(({ position: e }) => e), y(o), k(1));
3834
+ ]).pipe(T((e) => e.some((e) => e) ? "busy" : "free"), b(), k(1)), ee = _.navigation$.pipe(T(({ position: e }) => e), b(o), k(1));
3845
3835
  return {
3846
3836
  destroy: () => {
3847
3837
  g.forEach((e) => {
@@ -3852,15 +3842,15 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
3852
3842
  internalNavigator: _,
3853
3843
  scrollNavigationController: h,
3854
3844
  controlledNavigationController: p,
3855
- navigationState$: ee,
3845
+ navigationState$: y,
3856
3846
  navigate: (e) => {
3857
- R.info("User navigation", e), c.next(e);
3847
+ L.info("User navigation", e), c.next(e);
3858
3848
  },
3859
3849
  lock: () => u.lock(),
3860
3850
  isLocked$: u.isLocked$,
3861
3851
  navigationResolver: f,
3862
3852
  navigation$: _.navigation$,
3863
- position$: te
3853
+ position$: ee
3864
3854
  };
3865
3855
  }, ka = class extends U {
3866
3856
  constructor(e, t) {
@@ -3882,7 +3872,7 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
3882
3872
  }, Aa = class extends Q {
3883
3873
  constructor(e, t, n, r, i, a, o) {
3884
3874
  super(), this.context = e, this.pagination = t, this.spineItemsManager = n, this.spine = r, this.spineItemLocator = i, this.isNavigationLocked$ = a, this.cfi = o;
3885
- let s = T(this.context.bridgeEvent.navigation$, r.layout$).pipe(j(() => {
3875
+ let s = E(this.context.bridgeEvent.navigation$, r.layout$).pipe(A(() => {
3886
3876
  let e = ({ spineItem: e, position: t }) => this.spine.locator.getVisiblePagesFromViewportPosition({
3887
3877
  spineItem: e,
3888
3878
  position: t,
@@ -3891,7 +3881,7 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
3891
3881
  value: .5
3892
3882
  }
3893
3883
  });
3894
- return this.isNavigationLocked$.pipe(b((e) => !e), me(1), P(this.context.bridgeEvent.navigation$), N(([, t]) => {
3884
+ return this.isNavigationLocked$.pipe(x((e) => !e), he(1), N(this.context.bridgeEvent.navigation$), M(([, t]) => {
3895
3885
  let { position: n } = t, r = this.pagination.value, { beginIndex: i, endIndex: a } = this.spine.locator.getVisibleSpineItemsFromPosition({
3896
3886
  position: n,
3897
3887
  threshold: {
@@ -3920,7 +3910,7 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
3920
3910
  });
3921
3911
  }));
3922
3912
  }));
3923
- T(s, s.pipe(yt(this.context.bridgeEvent.viewportFree$), N(() => {
3913
+ E(s, s.pipe(yt(this.context.bridgeEvent.viewportFree$), M(() => {
3924
3914
  let { beginSpineItemIndex: e, endSpineItemIndex: t, beginPageIndexInSpineItem: n, endPageIndexInSpineItem: r } = this.pagination.value;
3925
3915
  if (n === void 0 || r === void 0 || e === void 0 || t === void 0) return;
3926
3916
  let i = this.spineItemsManager.get(e), a = this.spineItemsManager.get(t);
@@ -3936,7 +3926,7 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
3936
3926
  pageNode: s?.firstVisibleNode
3937
3927
  }) : this.cfi.generateRootCfi(a.item)
3938
3928
  });
3939
- }))).pipe(M(this.destroy$)).subscribe();
3929
+ }))).pipe(j(this.destroy$)).subscribe();
3940
3930
  }
3941
3931
  }, ja = class extends Q {
3942
3932
  constructor(e) {
@@ -3974,14 +3964,14 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
3974
3964
  return this._settings$;
3975
3965
  }
3976
3966
  watch(e) {
3977
- return this.values$.pipe(gt(e), y(o));
3967
+ return this.values$.pipe(gt(e), b(o));
3978
3968
  }
3979
3969
  destroy() {
3980
3970
  super.destroy(), this.outputSettingsUpdateSubject.complete();
3981
3971
  }
3982
3972
  }, Ma = class extends ja {
3983
3973
  constructor(e, t) {
3984
- super(e), this.context = t, t.watch(["hasVerticalWriting"]).pipe(N(() => this.update(this.values)), M(this.destroy$)).subscribe();
3974
+ super(e), this.context = t, t.watch(["hasVerticalWriting"]).pipe(M(() => this.update(this.values)), j(this.destroy$)).subscribe();
3985
3975
  }
3986
3976
  getComputedSettings(e) {
3987
3977
  let t = this.context.manifest, n = this.context.value.hasVerticalWriting ?? !1, r = {
@@ -3994,7 +3984,7 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
3994
3984
  manifest: t
3995
3985
  })
3996
3986
  };
3997
- return t.renditionFlow === "scrolled-continuous" && (r.computedPageTurnMode = "scrollable"), r.computedPageTurnMode === "scrollable" && (r.computedPageTurnDirection = "vertical"), n && r.computedPageTurnAnimation === "slide" && (R.warn(`pageTurnAnimation ${r.computedPageTurnAnimation} incompatible with current book, switching back to default`), r.computedPageTurnAnimation = "none"), r.computedPageTurnMode === "scrollable" ? (r.computedPageTurnAnimationDuration = 0, r.computedPageTurnAnimation = "none") : r.computedPageTurnAnimationDuration = e.pageTurnAnimationDuration === void 0 ? 300 : e.pageTurnAnimationDuration, r;
3987
+ return t.renditionFlow === "scrolled-continuous" && (r.computedPageTurnMode = "scrollable"), r.computedPageTurnMode === "scrollable" && (r.computedPageTurnDirection = "vertical"), n && r.computedPageTurnAnimation === "slide" && (L.warn(`pageTurnAnimation ${r.computedPageTurnAnimation} incompatible with current book, switching back to default`), r.computedPageTurnAnimation = "none"), r.computedPageTurnMode === "scrollable" ? (r.computedPageTurnAnimationDuration = 0, r.computedPageTurnAnimation = "none") : r.computedPageTurnAnimationDuration = e.pageTurnAnimationDuration === void 0 ? 300 : e.pageTurnAnimationDuration, r;
3998
3988
  }
3999
3989
  getOutputSettings(e) {
4000
3990
  let t = this.getComputedSettings(e);
@@ -4022,11 +4012,11 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
4022
4012
  }, Na = class extends Q {
4023
4013
  constructor(e, n, r, i, a, o) {
4024
4014
  super(), this.context = e, this.spineItemsManager = n, this.spineLocator = r, this.settings = i, this.spineLayout = a, this.viewport = o, this.forcedOpenSubject = new l(/* @__PURE__ */ new Map());
4025
- let s = this.forcedOpenSubject.pipe(w((e) => Array.from(e.keys()).sort((e, t) => e - t)), y(t), k({
4015
+ let s = this.forcedOpenSubject.pipe(T((e) => Array.from(e.keys()).sort((e, t) => e - t)), b(t), k({
4026
4016
  bufferSize: 1,
4027
4017
  refCount: !0
4028
4018
  }));
4029
- T(this.context.bridgeEvent.position$, this.viewport.layout$, this.spineLayout.layout$, s, i.watch(["numberOfAdjacentSpineItemToPreLoad"])).pipe(ne(100), b(() => K(this.context.value.rootElement)), yt(this.context.bridgeEvent.viewportFree$), P(this.context.bridgeEvent.position$, s), w(([, e, t]) => {
4019
+ E(this.context.bridgeEvent.position$, this.viewport.layout$, this.spineLayout.layout$, s, i.watch(["numberOfAdjacentSpineItemToPreLoad"])).pipe(te(100), x(() => K(this.context.value.rootElement)), yt(this.context.bridgeEvent.viewportFree$), N(this.context.bridgeEvent.position$, s), T(([, e, t]) => {
4030
4020
  let { numberOfAdjacentSpineItemToPreLoad: a } = i.values, { beginIndex: o = 0, endIndex: s = 0 } = r.getVisibleSpineItemsFromPosition({
4031
4021
  position: e,
4032
4022
  threshold: {
@@ -4038,7 +4028,7 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
4038
4028
  n.items.forEach((e, t) => {
4039
4029
  d.includes(t) ? e.load() : e.unload();
4040
4030
  });
4041
- })).pipe(M(this.destroy$)).subscribe();
4031
+ })).pipe(j(this.destroy$)).subscribe();
4042
4032
  }
4043
4033
  forceOpen(e) {
4044
4034
  let t = e.map((e) => typeof e == "number" ? e : e.index), n = (e) => {
@@ -4274,23 +4264,23 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
4274
4264
  constructor(e) {
4275
4265
  super(), this.spineItemsManager = e;
4276
4266
  let t = e.items;
4277
- this.itemStateChange$ = T(...t.map((e) => e.pipe(w((t) => ({
4267
+ this.itemStateChange$ = E(...t.map((e) => e.pipe(T((t) => ({
4278
4268
  item: e,
4279
4269
  ...t
4280
- })), y(o)))).pipe(O()), this.itemResize$ = T(...t.map((e) => vt(e.element).pipe(w((t) => ({
4270
+ })), b(o)))).pipe(O()), this.itemResize$ = E(...t.map((e) => vt(e.element).pipe(T((t) => ({
4281
4271
  entries: t,
4282
4272
  item: e
4283
- }))))).pipe(O()), this.itemLoad$ = T(...t.map((e) => e.loaded$.pipe(w(() => e)))).pipe(O()), this.itemUnload$ = T(...t.map((e) => e.unloaded$.pipe(w(() => e)))).pipe(O());
4273
+ }))))).pipe(O()), this.itemLoad$ = E(...t.map((e) => e.loaded$.pipe(T(() => e)))).pipe(O()), this.itemUnload$ = E(...t.map((e) => e.unloaded$.pipe(T(() => e)))).pipe(O());
4284
4274
  }
4285
4275
  }, qa = class extends Q {
4286
4276
  constructor(e, t, n, r, i) {
4287
4277
  super(), this.spineItemsManager = e, this.spineItemsObserver = t, this.context = n, this.settings = r, this.viewport = i, this.externalLayoutTrigger = new m(), this.spineItemsRelativeLayouts = [];
4288
- let a = T(t.itemLoad$, t.itemUnload$).pipe(w(() => ({ immediate: !1 }))), o = T(this.externalLayoutTrigger, a);
4289
- this.layout$ = o.pipe(N(() => {
4278
+ let a = E(t.itemLoad$, t.itemUnload$).pipe(T(() => ({ immediate: !1 }))), o = E(this.externalLayoutTrigger, a);
4279
+ this.layout$ = o.pipe(M(() => {
4290
4280
  this.spineItemsManager.items.forEach((e) => {
4291
4281
  e.markDirty();
4292
4282
  });
4293
- }), te((e) => e.immediate ? D(void 0) : _e(50)), j(() => this.spineItemsManager.items.reduce((t, a, o) => t.pipe(ee(({ horizontalOffset: t, verticalOffset: s }) => {
4283
+ }), ee((e) => e.immediate ? D(void 0) : ve(50)), A(() => this.spineItemsManager.items.reduce((t, a, o) => t.pipe(y(({ horizontalOffset: t, verticalOffset: s }) => {
4294
4284
  let c = t % i.absoluteViewport.width === 0, l = o === e.items.length - 1, u = r.values.computedPageTurnDirection === "vertical", d = n.isRTL(), f = this.getSpreadPosition(c, d), { edgeX: p, edgeY: m } = this.getStartEdges(u, c, t, s, i.absoluteViewport.height);
4295
4285
  return a.layout({
4296
4286
  spreadPosition: f,
@@ -4298,7 +4288,7 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
4298
4288
  isLastItem: l,
4299
4289
  edgeX: p,
4300
4290
  edgeY: m
4301
- }).pipe(w(({ width: e, height: t }) => {
4291
+ }).pipe(T(({ width: e, height: t }) => {
4302
4292
  let n = this.createSpineItemLayout(u, d, p, m, e, t, i.absoluteViewport.width);
4303
4293
  return this.spineItemsRelativeLayouts[o] = n, {
4304
4294
  horizontalOffset: p + e,
@@ -4308,12 +4298,12 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
4308
4298
  })), D({
4309
4299
  horizontalOffset: 0,
4310
4300
  verticalOffset: 0
4311
- }))), M(this.destroy$), O()), this.layout$.subscribe(), this.watchForVerticalWritingUpdate();
4301
+ }))), j(this.destroy$), O()), this.layout$.subscribe(), this.watchForVerticalWritingUpdate();
4312
4302
  }
4313
4303
  watchForVerticalWritingUpdate() {
4314
- this.spineItemsObserver.itemLoad$.pipe(N((e) => {
4304
+ this.spineItemsObserver.itemLoad$.pipe(M((e) => {
4315
4305
  this.context.update({ hasVerticalWriting: e.isUsingVerticalWriting() });
4316
- }), M(this.destroy$)).subscribe();
4306
+ }), j(this.destroy$)).subscribe();
4317
4307
  }
4318
4308
  layout(e = {}) {
4319
4309
  this.externalLayoutTrigger.next(e);
@@ -4382,15 +4372,15 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
4382
4372
  spineLayout: this.spineLayout,
4383
4373
  viewport: a
4384
4374
  }), this.spineItemsLoader = new Na(this.context, n, this.locator, i, this.spineLayout, this.viewport), this.pages = new yr(this.spineLayout, this.spineItemsManager, this.spineItemLocator, this.context, this.locator, this.viewport);
4385
- let o = e.watch("rootElement").pipe(be(K), L((e) => {
4386
- let t = e.ownerDocument.createElement("div");
4387
- t.style.cssText = "\n height: 100%;\n position: relative;\n ", t.className = `${X}-spine`, this.elementSubject.next(t);
4375
+ let o = e.watch("rootElement").pipe(xe(K), I(() => {
4376
+ let e = this.context.document.createElement("div");
4377
+ e.style.cssText = "\n height: 100%;\n position: relative;\n ", e.className = `${X}-spine`, this.elementSubject.next(e);
4388
4378
  }));
4389
- T(this.element$.pipe(be(K), L((e) => {
4379
+ E(this.element$.pipe(xe(K), I((e) => {
4390
4380
  this.spineItemsManager.items.forEach((t) => {
4391
4381
  t.attach(e);
4392
4382
  });
4393
- })), o).pipe(I(this.destroy$)).subscribe();
4383
+ })), o).pipe(F(this.destroy$)).subscribe();
4394
4384
  }
4395
4385
  get element() {
4396
4386
  return this.elementSubject.getValue();
@@ -4410,7 +4400,7 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
4410
4400
  }, Ya = class extends At {
4411
4401
  onUnload() {}
4412
4402
  onCreateDocument() {
4413
- return D(document.createElement("div"));
4403
+ return D(this.context.document.createElement("div"));
4414
4404
  }
4415
4405
  onLoadDocument() {
4416
4406
  return u;
@@ -4436,14 +4426,14 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
4436
4426
  blankPagePosition: a
4437
4427
  };
4438
4428
  }, this.adjustPositionOfElement = ({ right: e, left: t, top: n }) => {
4439
- e === void 0 ? V(this.containerElement.style, "right") : B(this.containerElement.style, "right", `${e}px`), t === void 0 ? V(this.containerElement.style, "left") : B(this.containerElement.style, "left", `${t}px`), n === void 0 ? V(this.containerElement.style, "top") : B(this.containerElement.style, "top", `${n}px`);
4440
- }, this.updateContainerLayout = ({ minimumWidth: e, edgeX: t, edgeY: n }) => (r) => r.pipe(w((r) => {
4429
+ e === void 0 ? B(this.containerElement.style, "right") : z(this.containerElement.style, "right", `${e}px`), t === void 0 ? B(this.containerElement.style, "left") : z(this.containerElement.style, "left", `${t}px`), n === void 0 ? B(this.containerElement.style, "top") : z(this.containerElement.style, "top", `${n}px`);
4430
+ }, this.updateContainerLayout = ({ minimumWidth: e, edgeX: t, edgeY: n }) => (r) => r.pipe(T((r) => {
4441
4431
  let { width: i, height: a } = (o(this.lastLayout?.pageSize, this.viewport.pageSize) ? this.lastLayout : void 0) ?? {}, { width: s = i, height: c = a } = r ?? {}, { width: l, height: u } = this.viewport.pageSize, d = this.validateDimension(s ?? l, l, e), f = this.settings.values.computedPageTurnMode === "scrollable" ? c ?? u : this.validateDimension(c ?? u, u, u);
4442
4432
  return this.lastLayout = {
4443
4433
  width: d,
4444
4434
  height: f,
4445
4435
  pageSize: this.viewport.pageSize
4446
- }, B(this.containerElement.style, "width", `${d}px`), B(this.containerElement.style, "height", `${f}px`), this.settings.values.computedPageTurnDirection === "vertical" ? (this.adjustPositionOfElement({
4436
+ }, z(this.containerElement.style, "width", `${d}px`), z(this.containerElement.style, "height", `${f}px`), this.settings.values.computedPageTurnDirection === "vertical" ? (this.adjustPositionOfElement({
4447
4437
  top: n,
4448
4438
  left: t
4449
4439
  }), {
@@ -4460,10 +4450,10 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
4460
4450
  height: f
4461
4451
  });
4462
4452
  })), this.layout = (e) => {
4463
- let t = bt(this.didLayout$.pipe(x()));
4453
+ let t = bt(this.didLayout$.pipe(S()));
4464
4454
  return this.layoutTriggerSubject.next(e), t();
4465
4455
  };
4466
- let l = this.layoutTriggerSubject.pipe(j(({ spreadPosition: e, horizontalOffset: t, isLastItem: n, edgeX: r, edgeY: i }) => {
4456
+ let l = this.layoutTriggerSubject.pipe(A(({ spreadPosition: e, horizontalOffset: t, isLastItem: n, edgeX: r, edgeY: i }) => {
4467
4457
  let { blankPagePosition: a, minimumWidth: o } = this.computeLayoutInformation({
4468
4458
  horizontalOffset: t,
4469
4459
  isLastItem: n,
@@ -4480,11 +4470,11 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
4480
4470
  minimumWidth: o,
4481
4471
  spreadPosition: e
4482
4472
  });
4483
- return T(D({ type: "start" }), s.pipe(this.updateContainerLayout({
4473
+ return E(D({ type: "start" }), s.pipe(this.updateContainerLayout({
4484
4474
  minimumWidth: o,
4485
4475
  edgeX: r,
4486
4476
  edgeY: i
4487
- }), w((e) => (this.hookManager.execute("item.onAfterLayout", {
4477
+ }), T((e) => (this.hookManager.execute("item.onAfterLayout", {
4488
4478
  blankPagePosition: a,
4489
4479
  item: this.item,
4490
4480
  minimumWidth: o
@@ -4493,7 +4483,7 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
4493
4483
  data: e
4494
4484
  }))));
4495
4485
  }), O());
4496
- this.didLayout$ = l.pipe(b((e) => e.type === "end"), w((e) => e.data), O());
4486
+ this.didLayout$ = l.pipe(x((e) => e.type === "end"), T((e) => e.data), O());
4497
4487
  }
4498
4488
  validateDimension(e, t, n) {
4499
4489
  if (e <= 0) return n;
@@ -4528,7 +4518,7 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
4528
4518
  this.mergeCompare({ isDirty: !0 });
4529
4519
  }, this.destroy = () => {
4530
4520
  this.isDestroyed || (super.destroy(), this._layout.destroy(), this.renderer.destroy(), this.containerElement.remove());
4531
- }, this.isUsingVerticalWriting = () => !!this.renderer.writingMode?.startsWith("vertical"), this.layout = (e) => this._layout.layout(e), this.containerElement = Qa(e);
4521
+ }, this.isUsingVerticalWriting = () => !!this.renderer.writingMode?.startsWith("vertical"), this.layout = (e) => this._layout.layout(e), this.containerElement = Qa(e, t.document);
4532
4522
  let o = this.settings.values.getRenderer?.(e);
4533
4523
  this.resourcesHandler = new Mt(e, this.settings);
4534
4524
  let s = {
@@ -4541,19 +4531,19 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
4541
4531
  viewport: this.viewport
4542
4532
  };
4543
4533
  this.renderer = o ? o(s) : new Ya(s), this._layout = new Xa(e, this.containerElement, t, r, this.renderer, this.settings, this.viewport);
4544
- let c = this.renderer.state$.pipe(L(({ state: e, error: t }) => {
4534
+ let c = this.renderer.state$.pipe(I(({ state: e, error: t }) => {
4545
4535
  this.mergeCompare({
4546
4536
  isLoaded: e === "loaded",
4547
4537
  isError: e === "error",
4548
4538
  error: e === "error" ? t : void 0
4549
4539
  });
4550
4540
  }));
4551
- this.didLayout$ = this._layout.didLayout$.pipe(L(() => {
4541
+ this.didLayout$ = this._layout.didLayout$.pipe(I(() => {
4552
4542
  this.mergeCompare({
4553
4543
  isDirty: !1,
4554
4544
  isReady: this.renderer.value.state === "loaded"
4555
4545
  });
4556
- }), we()), T(c, this.didLayout$).pipe(I(this.destroy$)).subscribe();
4546
+ }), Te()), E(c, this.didLayout$).pipe(F(this.destroy$)).subscribe();
4557
4547
  }
4558
4548
  get isReady$() {
4559
4549
  return this.watch("isReady");
@@ -4587,9 +4577,9 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
4587
4577
  pageTurnMode: this.settings.values.pageTurnMode
4588
4578
  });
4589
4579
  }
4590
- }, Qa = (e) => {
4591
- let t = document.createElement("div");
4592
- return t.setAttribute(`data-${wn}`, ""), t.classList.add("spineItem"), t.classList.add(`spineItem-${e.renditionLayout ?? "reflowable"}`), t.style.cssText = "\n position: absolute;\n overflow: hidden;\n ", t.dataset.isReady = "false", t;
4580
+ }, Qa = (e, t) => {
4581
+ let n = t.createElement("div");
4582
+ return n.setAttribute(`data-${wn}`, ""), n.classList.add("spineItem"), n.classList.add(`spineItem-${e.renditionLayout ?? "reflowable"}`), n.style.cssText = "\n position: absolute;\n overflow: hidden;\n ", n.dataset.isReady = "false", n;
4593
4583
  }, $a = class extends Q {
4594
4584
  constructor(e, t, n, r) {
4595
4585
  super(), this.context = e, this.settings = t, this.hookManager = n, this.viewport = r, this.items = e.manifest.spineItems.map((i, a) => new Za(i, e, t, n, a, r));
@@ -4611,7 +4601,7 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
4611
4601
  }
4612
4602
  }, eo = class extends U {
4613
4603
  constructor(e, t) {
4614
- let n = document.createElement("div");
4604
+ let n = e.document.createElement("div");
4615
4605
  n.setAttribute(`data-${Sn}`, ""), super({
4616
4606
  element: n,
4617
4607
  pageSize: {
@@ -4620,11 +4610,11 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
4620
4610
  },
4621
4611
  width: 1,
4622
4612
  height: 1
4623
- }), this.context = e, this.settingsManager = t, this.layoutSubject = new m(), this.layout$ = this.layoutSubject.asObservable(), T(this.settingsManager.watch(["computedSpreadMode"]).pipe(N(() => {
4613
+ }), this.context = e, this.settingsManager = t, this.layoutSubject = new m(), this.layout$ = this.layoutSubject.asObservable(), E(this.settingsManager.watch(["computedSpreadMode"]).pipe(M(() => {
4624
4614
  this.mergeCompare({ pageSize: this.calculatePageSize(this.value) });
4625
- })), this.context.watch("rootElement").pipe(N(() => {
4615
+ })), this.context.watch("rootElement").pipe(M(() => {
4626
4616
  this.layout();
4627
- }))).pipe(M(this.destroy$)).subscribe();
4617
+ }))).pipe(j(this.destroy$)).subscribe();
4628
4618
  }
4629
4619
  calculatePageSize(e) {
4630
4620
  let { computedSpreadMode: t } = this.settingsManager.values;
@@ -4635,7 +4625,7 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
4635
4625
  }
4636
4626
  syncAbsoluteViewportCssVariables(e) {
4637
4627
  let { style: t } = this.value.element;
4638
- e.width > 0 ? B(t, Tn, `${e.width}px`) : V(t, Tn), e.height > 0 ? B(t, En, `${e.height}px`) : V(t, En);
4628
+ e.width > 0 ? z(t, Tn, `${e.width}px`) : B(t, Tn), e.height > 0 ? z(t, En, `${e.height}px`) : B(t, En);
4639
4629
  }
4640
4630
  layout() {
4641
4631
  let e = {
@@ -4670,74 +4660,75 @@ var ii = (e) => (t) => e(t), ai = (e, t, n) => {
4670
4660
  destroy() {
4671
4661
  super.destroy(), this.layoutSubject.complete(), this.value.element.remove();
4672
4662
  }
4673
- }, to = ({ manifest: e, cfi: t, ...n }) => {
4674
- let r = crypto.randomUUID(), i = `${bn}-core-${r}`, a = new m(), o = new m(), s = new Mi(), c = new Ai(e), l = new Ma(n, c), u = new ji(c, l), d = new eo(c, l), f = new $a(c, l, s, d), p = new Di(s, f), h = pa({
4675
- context: c,
4676
- settings: l,
4677
- viewport: d
4678
- }), g = new ka(c, f), _ = new Ja(c, g, f, h, l, d), v = Oa({
4679
- cfi: p,
4680
- context: c,
4681
- spineItemsManager: f,
4682
- hookManager: s,
4683
- spine: _,
4684
- settings: l,
4685
- viewport: d
4686
- }), ee = new Aa(c, g, f, _, h, v.isLocked$, p);
4687
- v.navigationState$.subscribe(c.bridgeEvent.viewportStateSubject), v.navigation$.subscribe(c.bridgeEvent.navigationSubject), v.position$.subscribe(c.bridgeEvent.positionSubject), g.subscribe(c.bridgeEvent.paginationSubject);
4663
+ }, to = ({ manifest: e, cfi: t, ownerDocument: n = globalThis.document, ...r }) => {
4664
+ let i = crypto.randomUUID(), a = `${bn}-core-${i}`, o = new m(), s = new m(), c = new Mi(), l = new Ai(e, n), u = new Ma(r, l), d = new ji(l, u), f = new eo(l, u), p = new $a(l, u, c, f), h = new Di(c, p), g = pa({
4665
+ context: l,
4666
+ settings: u,
4667
+ viewport: f
4668
+ }), _ = new ka(l, p), v = new Ja(l, _, p, g, u, f), y = Oa({
4669
+ cfi: h,
4670
+ context: l,
4671
+ spineItemsManager: p,
4672
+ hookManager: c,
4673
+ spine: v,
4674
+ settings: u,
4675
+ viewport: f
4676
+ }), ee = new Aa(l, _, p, v, g, y.isLocked$, h);
4677
+ y.navigationState$.subscribe(l.bridgeEvent.viewportStateSubject), y.navigation$.subscribe(l.bridgeEvent.navigationSubject), y.position$.subscribe(l.bridgeEvent.positionSubject), _.subscribe(l.bridgeEvent.paginationSubject);
4688
4678
  let te = (e = {}) => {
4689
- a.next(e);
4679
+ o.next(e);
4690
4680
  }, ne = (e) => {
4691
- if (c.value.rootElement) throw Error("This reader is already mounted. A reader renders a single book, destroy it and create a new reader instead.");
4692
- R.log("mount", { containerElement: e }), $e(document, i, Ni);
4693
- let t = io(e, r);
4694
- c.update({ rootElement: t }), te({ immediate: !0 });
4695
- }, re = l.watch(["computedSpreadMode"]).pipe(Ee(1), L(() => te())), ie = T(a.pipe(L((e) => {
4696
- c.value.rootElement && (d.layout(), _.layout(e));
4697
- }), I(o)), re).subscribe();
4681
+ if (l.value.rootElement) throw Error("This reader is already mounted. A reader renders a single book, destroy it and create a new reader instead.");
4682
+ if (e.ownerDocument !== l.document) throw Error("The container element must belong to the reader's document. Pass `ownerDocument` to `createReader` when mounting into a foreign document (eg: an iframe's contentDocument).");
4683
+ L.log("mount", { containerElement: e }), $e(l.document, a, Ni);
4684
+ let t = io(e, i);
4685
+ l.update({ rootElement: t }), te({ immediate: !0 });
4686
+ }, re = u.watch(["computedSpreadMode"]).pipe(De(1), I(() => te())), ie = E(o.pipe(I((e) => {
4687
+ l.value.rootElement && (f.layout(), v.layout(e));
4688
+ }), F(s)), re).subscribe();
4698
4689
  return {
4699
- id: r,
4700
- context: c,
4701
- spine: _,
4702
- hookManager: s,
4703
- cfi: p,
4704
- navigation: v,
4705
- spineItemsObserver: _.spineItemsObserver,
4706
- spineItemsManager: f,
4690
+ id: i,
4691
+ context: l,
4692
+ spine: v,
4693
+ hookManager: c,
4694
+ cfi: h,
4695
+ navigation: y,
4696
+ spineItemsObserver: v.spineItemsObserver,
4697
+ spineItemsManager: p,
4707
4698
  layout: te,
4708
4699
  mount: ne,
4709
4700
  destroy: () => {
4710
- let e = c.value.rootElement;
4711
- et(document, i), e && ao(e), ie.unsubscribe(), f.destroy(), ee.destroy(), l.destroy(), g.destroy(), c.destroy(), v.destroy(), _.destroy(), u.destroy(), o.next(), o.complete(), d.destroy();
4701
+ let e = l.value.rootElement;
4702
+ e && (et(l.document, a), ao(e)), ie.unsubscribe(), p.destroy(), ee.destroy(), u.destroy(), _.destroy(), l.destroy(), y.destroy(), v.destroy(), d.destroy(), s.next(), s.complete(), f.destroy();
4712
4703
  },
4713
4704
  pagination: {
4714
4705
  get state() {
4715
- return g.value;
4706
+ return _.value;
4716
4707
  },
4717
4708
  get state$() {
4718
- return g;
4709
+ return _;
4719
4710
  }
4720
4711
  },
4721
- settings: l,
4722
- renderHeadless: (e) => f.get(e)?.renderer.renderHeadless() ?? D(void 0),
4723
- viewport: d,
4724
- viewportState$: c.bridgeEvent.viewportState$,
4725
- viewportFree$: c.bridgeEvent.viewportFree$,
4726
- mounted$: c.watch("rootElement").pipe(Se(K), ye()),
4727
- features: u,
4728
- $: { destroy$: o }
4712
+ settings: u,
4713
+ renderHeadless: (e) => p.get(e)?.renderer.renderHeadless() ?? D(void 0),
4714
+ viewport: f,
4715
+ viewportState$: l.bridgeEvent.viewportState$,
4716
+ viewportFree$: l.bridgeEvent.viewportFree$,
4717
+ mounted$: l.watch("rootElement").pipe(Ce(K), be()),
4718
+ features: d,
4719
+ $: { destroy$: s }
4729
4720
  };
4730
- }, no = `${X}-reader`, ro = "data-prose-reader-container", io = (e, t) => (e.classList.add(no), z(e, xn, t), z(e, ro, t), e), ao = (e) => {
4721
+ }, no = `${X}-reader`, ro = "data-prose-reader-container", io = (e, t) => (e.classList.add(no), R(e, xn, t), R(e, ro, t), e), ao = (e) => {
4731
4722
  e.classList.remove(no), e.removeAttribute(xn), e.removeAttribute(ro);
4732
- }, oo = ei(Ot(ii(Dt(ct(ri(gi(ur(on(Gn(lt(pt(Yr(Wn(ni(to))))))))))))))), so = (e) => (t) => e(t), co = 5e3, lo = (e, { itemReadinessTimeoutMs: t = co } = {}) => Xn(e).pipe(j((n) => {
4723
+ }, oo = ei(Ot(ii(Dt(ct(ri(gi(ur(on(Gn(lt(pt(Yr(Wn(ni(to))))))))))))))), so = (e) => (t) => e(t), co = 5e3, lo = (e, { itemReadinessTimeoutMs: t = co } = {}) => Xn(e).pipe(A((n) => {
4733
4724
  if (n.boundary === "start") return D(n);
4734
4725
  let r = e.spineItemsManager.items, i = r[r.length - 1];
4735
- return i ? i.value.isReady ? D(n) : i.isReady$.pipe(b(Boolean), x(), w(() => n), t === Infinity ? le : ge({
4726
+ return i ? i.value.isReady ? D(n) : i.isReady$.pipe(x(Boolean), S(), T(() => n), t === Infinity ? ce : _e({
4736
4727
  first: t,
4737
4728
  with: () => u
4738
4729
  }), Yn(e.navigation)) : u;
4739
4730
  }), O());
4740
4731
  //#endregion
4741
- export { fn as AbstractSpinePosition, En as CSS_VAR_ABSOLUTE_VIEWPORT_HEIGHT, Tn as CSS_VAR_ABSOLUTE_VIEWPORT_WIDTH, Di as CfiManager, Ai as Context, Li as ControlledNavigationController, Q as DestroyableClass, At as DocumentRenderer, ji as Features, xn as HTML_ATTRIBUTE_DATA_READER_ID, X as HTML_PREFIX, Cn as HTML_PREFIX_SCROLL_NAVIGATOR, wn as HTML_PREFIX_SPINE_ITEM, Sn as HTML_PREFIX_VIEWPORT, bn as HTML_STYLE_PREFIX, Mi as HookManager, ia as InternalNavigator, sn as LayoutEntry, Yi as Locker, yn as PAGINATION_UPDATE_AFTER_VIEWPORT_ADJUSTMENT_DEBOUNCE, _n as PROSE_READER_NAMESPACE, yr as Pages, ka as Pagination, Aa as PaginationController, U as ReactiveEntity, Mt as ResourceHandler, pr as ResourcesLocator, di as ScrollNavigationController, li as ScrollPosition, ja as SettingsManager, Ja as Spine, Za as SpineItem, ln as SpineItemPageLayout, dn as SpineItemPageSpineLayout, q as SpineItemPosition, un as SpineItemSpineLayout, $a as SpineItemsManager, Ka as SpineItemsObserver, J as SpinePosition, ui as UnboundScrollPosition, cn as UnboundSpineItemPagePosition, Y as UnboundSpinePosition, vn as VIEWPORT_ADJUSTMENT_THROTTLE, eo as Viewport, fr as consolidate, oo as createReader, St as deferIdle, bt as deferNextResult, yi as generateCfiForSpineItemPage, bi as generateCfiFromRange, _i as generateRootCfi, nt as getAttributeValueFromString, mt as getBase64FromBlob, at as getFrameViewportInfo, xi as getItemAnchor, on as htmlEnhancer, xt as idle, $e as injectCSS, rt as injectCSSToFrame, K as isDefined, Xe as isHtmlElement, Ze as isHtmlTagElement, Ci as isRootCfi, a as isShallowEqual, Wn as layoutEnhancer, gt as mapKeysTo, lo as observeBookBoundaryReached, wt as observeIntersection, Ct as observeMutation, Jn as observeNextSettledNavigation, vt as observeResize, qn as observeSettledNavigation, Yr as paginationEnhancer, Ti as parseCfi, ht as pick, Fe as removeAttributeIfPresent, it as removeCSS, V as removeStylePropertyIfPresent, Ei as resolveCfi, so as rootEnhancer, z as setAttributeIfChanged, Ie as setPropertyIfChanged, B as setStylePropertyIfChanged, Vn as shouldEnableSpreadModeForViewport, Hn as shouldUseComputedSpreadModeForViewport, hr as spinePositionToSpineItemSpineLayout, Yn as takeUntilNextNavigationSettled, H as upsertCSSToFrame, ot as waitForFrameLoad, st as waitForFrameReady, Kn as waitForNavigationSettled, yt as waitForSwitch, _t as watchKeys };
4732
+ export { fn as AbstractSpinePosition, En as CSS_VAR_ABSOLUTE_VIEWPORT_HEIGHT, Tn as CSS_VAR_ABSOLUTE_VIEWPORT_WIDTH, Di as CfiManager, Ai as Context, Li as ControlledNavigationController, Q as DestroyableClass, At as DocumentRenderer, ji as Features, xn as HTML_ATTRIBUTE_DATA_READER_ID, X as HTML_PREFIX, Cn as HTML_PREFIX_SCROLL_NAVIGATOR, wn as HTML_PREFIX_SPINE_ITEM, Sn as HTML_PREFIX_VIEWPORT, bn as HTML_STYLE_PREFIX, Mi as HookManager, ia as InternalNavigator, sn as LayoutEntry, Yi as Locker, yn as PAGINATION_UPDATE_AFTER_VIEWPORT_ADJUSTMENT_DEBOUNCE, _n as PROSE_READER_NAMESPACE, yr as Pages, ka as Pagination, Aa as PaginationController, U as ReactiveEntity, Mt as ResourceHandler, pr as ResourcesLocator, di as ScrollNavigationController, li as ScrollPosition, ja as SettingsManager, Ja as Spine, Za as SpineItem, ln as SpineItemPageLayout, dn as SpineItemPageSpineLayout, q as SpineItemPosition, un as SpineItemSpineLayout, $a as SpineItemsManager, Ka as SpineItemsObserver, J as SpinePosition, ui as UnboundScrollPosition, cn as UnboundSpineItemPagePosition, Y as UnboundSpinePosition, vn as VIEWPORT_ADJUSTMENT_THROTTLE, eo as Viewport, fr as consolidate, oo as createReader, St as deferIdle, bt as deferNextResult, yi as generateCfiForSpineItemPage, bi as generateCfiFromRange, _i as generateRootCfi, nt as getAttributeValueFromString, mt as getBase64FromBlob, at as getFrameViewportInfo, xi as getItemAnchor, on as htmlEnhancer, xt as idle, $e as injectCSS, rt as injectCSSToFrame, K as isDefined, Ze as isHtmlElement, V as isHtmlTagElement, Ci as isRootCfi, a as isShallowEqual, Wn as layoutEnhancer, gt as mapKeysTo, lo as observeBookBoundaryReached, wt as observeIntersection, Ct as observeMutation, Jn as observeNextSettledNavigation, vt as observeResize, qn as observeSettledNavigation, Yr as paginationEnhancer, Ti as parseCfi, ht as pick, Ie as removeAttributeIfPresent, it as removeCSS, B as removeStylePropertyIfPresent, Ei as resolveCfi, so as rootEnhancer, R as setAttributeIfChanged, Le as setPropertyIfChanged, z as setStylePropertyIfChanged, Vn as shouldEnableSpreadModeForViewport, Hn as shouldUseComputedSpreadModeForViewport, hr as spinePositionToSpineItemSpineLayout, Yn as takeUntilNextNavigationSettled, H as upsertCSSToFrame, ot as waitForFrameLoad, st as waitForFrameReady, Kn as waitForNavigationSettled, yt as waitForSwitch, _t as watchKeys };
4742
4733
 
4743
4734
  //# sourceMappingURL=index.js.map