@prose-reader/core 1.253.0 → 1.255.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,12 +1,12 @@
1
- import { switchMap as w, of as v, fromEvent as q, take as Tt, map as S, from as N, takeUntil as T, Observable as ne, defer as ke, Subject as R, combineLatest as k, merge as P, EMPTY as Z, NEVER as ge, tap as x, share as E, BehaviorSubject as H, withLatestFrom as O, filter as L, first as U, mergeMap as $e, endWith as me, finalize as de, catchError as Ft, lastValueFrom as rn, scheduled as an, animationFrameScheduler as re, exhaustMap as Ue, debounceTime as Se, distinctUntilChanged as z, throttleTime as cn, startWith as ee, shareReplay as J, switchScan as un, defaultIfEmpty as ln, forkJoin as dn, delay as we, timer as Te, ReplaySubject as st, identity as Pe, skip as Lt, reduce as pn, concatMap as rt } from "rxjs";
2
- import { Report as gn, isShallowEqual as V, shallowMergeIfDefined as xe, getParentPath as hn, parseContentType as mn, detectMimeTypeFromName as Me, arrayEqual as fn } from "@prose-reader/shared";
3
- import { isShallowEqual as sr } from "@prose-reader/shared";
4
- import { map as K, distinctUntilChanged as pe, switchMap as _, first as Mt, startWith as yn, shareReplay as Ce, tap as j, pairwise as Sn, take as In, takeUntil as G, filter as se, debounceTime as bn, skip as Ct, mergeMap as vn, catchError as at } from "rxjs/operators";
5
- import { generate as ze, parse as Et, isIndirectionOnly as wn, isParsedCfiRange as Pn, resolve as xn } from "@prose-reader/cfi";
1
+ import { switchMap as w, of as v, fromEvent as q, take as Tt, map as S, from as N, takeUntil as T, Observable as ne, defer as ke, Subject as R, combineLatest as k, merge as P, EMPTY as Z, NEVER as ge, tap as x, share as E, BehaviorSubject as H, withLatestFrom as O, filter as L, first as U, mergeMap as $e, endWith as me, finalize as de, catchError as Ft, lastValueFrom as an, scheduled as cn, animationFrameScheduler as re, exhaustMap as Ue, debounceTime as Se, distinctUntilChanged as z, throttleTime as un, startWith as ee, shareReplay as J, switchScan as ln, defaultIfEmpty as dn, forkJoin as pn, delay as we, timer as Te, skip as Lt, ReplaySubject as st, identity as Pe, reduce as gn, concatMap as rt } from "rxjs";
2
+ import { Report as hn, isShallowEqual as V, shallowMergeIfDefined as xe, getParentPath as mn, parseContentType as fn, detectMimeTypeFromName as Me, arrayEqual as yn } from "@prose-reader/shared";
3
+ import { isShallowEqual as rr } from "@prose-reader/shared";
4
+ import { map as K, distinctUntilChanged as pe, switchMap as _, first as Mt, startWith as Sn, shareReplay as Ce, tap as j, pairwise as bn, take as In, takeUntil as G, filter as se, debounceTime as vn, skip as Ct, mergeMap as wn, catchError as at } from "rxjs/operators";
5
+ import { generate as ze, parse as Et, isIndirectionOnly as Pn, isParsedCfiRange as xn, resolve as $n } from "@prose-reader/cfi";
6
6
  import { isDefined as Ge } from "reactjrx";
7
- const $n = "@prose-reader/core", D = gn.namespace($n, void 0, {
7
+ const Tn = "@prose-reader/core", D = hn.namespace(Tn, void 0, {
8
8
  color: "#98cde7"
9
- }), Tn = [
9
+ }), Fn = [
10
10
  "pointercancel",
11
11
  "pointerdown",
12
12
  "pointerenter",
@@ -18,24 +18,24 @@ const $n = "@prose-reader/core", D = gn.namespace($n, void 0, {
18
18
  // `touchstart` as const,
19
19
  // `touchend` as const,
20
20
  ];
21
- function Fn(n, e, t) {
21
+ function Ln(n, e, t) {
22
22
  if ("caretPositionFromPoint" in n)
23
23
  return n.caretPositionFromPoint(e, t);
24
24
  if ("caretRangeFromPoint" in n && // @ts-expect-error limited availability
25
25
  typeof n.caretRangeFromPoint < "u")
26
26
  return n.caretRangeFromPoint(e, t);
27
27
  }
28
- const Ln = (n, e) => {
28
+ const Mn = (n, e) => {
29
29
  const t = "body" in n ? We(n.body, e) : We(n, e), i = "createRange" in n ? n : n.ownerDocument;
30
30
  if (t) {
31
31
  let o, s = 0;
32
32
  const r = i.createRange();
33
33
  return Array.from(t.childNodes).some((a) => {
34
34
  r.selectNodeContents(a);
35
- const c = r.getClientRects(), u = Mn(c, e);
35
+ const c = r.getClientRects(), u = Cn(c, e);
36
36
  if (u) {
37
37
  o = r.cloneRange();
38
- const l = Fn(
38
+ const l = Ln(
39
39
  i,
40
40
  Math.ceil(u.left),
41
41
  Math.ceil(u.top)
@@ -65,13 +65,13 @@ const Ln = (n, e) => {
65
65
  function Dt(n, { left: e, right: t }) {
66
66
  return n.left <= e && n.right <= e ? "before" : n.left <= e && n.right > e && n.right <= t ? "partially-before" : n.left <= t && n.right > t ? "partially-after" : n.left > t ? "after" : "within";
67
67
  }
68
- function Mn(n, e) {
68
+ function Cn(n, e) {
69
69
  return Array.from(n).find((t) => {
70
70
  const i = Dt(t, e);
71
71
  return i !== "before" && i !== "after";
72
72
  });
73
73
  }
74
- const Cn = (n, e) => {
74
+ const En = (n, e) => {
75
75
  if (n.nodeType !== Node.CDATA_SECTION_NODE && n.nodeType !== Node.DOCUMENT_TYPE_NODE) {
76
76
  const t = n.ownerDocument?.createRange();
77
77
  t?.selectNodeContents(n);
@@ -93,8 +93,8 @@ const Cn = (n, e) => {
93
93
  if (e.PointerEvent && n instanceof e.PointerEvent)
94
94
  return !0;
95
95
  }
96
- return !!Tn.includes(n.type);
97
- }, En = (n) => {
96
+ return !!Fn.includes(n.type);
97
+ }, Dn = (n) => {
98
98
  if (Ze(n)) return !1;
99
99
  if (n?.target && n?.target?.ownerDocument?.defaultView) {
100
100
  const e = n?.target?.ownerDocument?.defaultView;
@@ -107,7 +107,7 @@ const Cn = (n, e) => {
107
107
  return n instanceof e.MouseEvent;
108
108
  }
109
109
  return !1;
110
- }, Dn = (n) => {
110
+ }, Rn = (n) => {
111
111
  if (n?.target && n?.target?.ownerDocument?.defaultView) {
112
112
  const e = n?.target?.ownerDocument?.defaultView;
113
113
  if (e.TouchEvent)
@@ -119,7 +119,7 @@ const Cn = (n, e) => {
119
119
  return n instanceof e.TouchEvent;
120
120
  }
121
121
  return !1;
122
- }, Rn = () => document.createElement("div"), Rt = (n) => {
122
+ }, An = () => document.createElement("div"), Rt = (n) => {
123
123
  const e = [
124
124
  "img",
125
125
  // Images
@@ -135,7 +135,7 @@ const Cn = (n, e) => {
135
135
  // JavaScript files
136
136
  ].join(",");
137
137
  return Array.from(n?.querySelectorAll(e) || []);
138
- }, An = (n) => {
138
+ }, On = (n) => {
139
139
  if (Rt(n).forEach((t) => {
140
140
  const i = t.getAttribute("src") || t.getAttribute("href");
141
141
  i?.startsWith("blob:") && n?.defaultView?.URL.revokeObjectURL(i);
@@ -170,10 +170,10 @@ function Ot(n) {
170
170
  // biome-ignore lint/suspicious/noExplicitAny: TODO
171
171
  ) && n.nodeType === Node.ELEMENT_NODE;
172
172
  }
173
- function On(n, e) {
173
+ function Nn(n, e) {
174
174
  return Ot(n) && n.tagName.toLowerCase() === e.toLowerCase();
175
175
  }
176
- function Nn(n) {
176
+ function Vn(n) {
177
177
  return At(
178
178
  n,
179
179
  [
@@ -198,9 +198,9 @@ const Je = (n, e, t, i) => {
198
198
  }, ct = (n, e) => {
199
199
  const t = new RegExp(`${e}\\s*=\\s*([0-9.]+)`, "i"), i = n.match(t) || [], o = i[1] || "0";
200
200
  return i && Number.parseFloat(o) || 0;
201
- }, Vn = (n, e, t, i) => {
201
+ }, jn = (n, e, t, i) => {
202
202
  n?.contentDocument?.head && Je(n.contentDocument, e, t, i);
203
- }, Xs = (n, e) => {
203
+ }, Ys = (n, e) => {
204
204
  n?.contentDocument && Ke(n.contentDocument, e);
205
205
  }, te = (n, e, t, i) => {
206
206
  if (!n) return;
@@ -211,7 +211,7 @@ const Je = (n, e, t, i) => {
211
211
  o.innerHTML = t;
212
212
  return;
213
213
  }
214
- Vn(n, e, t, i);
214
+ jn(n, e, t, i);
215
215
  }, Qe = (n) => {
216
216
  if (n?.contentDocument) {
217
217
  const t = n.contentDocument.querySelector("meta[name='viewport']");
@@ -228,17 +228,17 @@ const Je = (n, e, t, i) => {
228
228
  }
229
229
  }
230
230
  return { hasViewport: !1 };
231
- }, jn = (n) => n.pipe(
231
+ }, kn = (n) => n.pipe(
232
232
  w((e) => e.src === "about:blank" && e.contentDocument?.readyState === "complete" && e.contentDocument.body ? v(e) : q(e, "load").pipe(
233
233
  Tt(1),
234
234
  S(() => e)
235
235
  ))
236
- ), kn = (n) => n.pipe(
236
+ ), Un = (n) => n.pipe(
237
237
  w((e) => {
238
238
  const t = e?.contentDocument?.fonts.ready;
239
239
  return t ? N(t).pipe(S(() => e)) : v(void 0);
240
240
  })
241
- ), Un = (n) => (e) => {
241
+ ), zn = (n) => (e) => {
242
242
  const t = n(e), i = new IntersectionObserver((o) => {
243
243
  o.forEach((s) => {
244
244
  s.isIntersecting ? s.target.removeAttribute("tab-index") : s.target.setAttribute("tab-index", "-1");
@@ -273,7 +273,7 @@ const Je = (n, e, t, i) => {
273
273
  ), {
274
274
  ...t
275
275
  };
276
- }, zn = (n) => (e) => {
276
+ }, Wn = (n) => (e) => {
277
277
  const t = n(e);
278
278
  return t.context.watch("rootElement").pipe(T(t.context.destroy$)).subscribe((i) => {
279
279
  if (!i) return;
@@ -294,7 +294,7 @@ const Je = (n, e, t, i) => {
294
294
  clientX: a,
295
295
  clientY: c
296
296
  };
297
- }, Wn = (n, e, t, i) => {
297
+ }, _n = (n, e, t, i) => {
298
298
  const o = e?.view?.frameElement;
299
299
  if (!e || !o) return n;
300
300
  const s = t.getSpineItemFromIframe(o), r = o, { height: a, width: c } = i.pageSize;
@@ -314,7 +314,7 @@ const Je = (n, e, t, i) => {
314
314
  enumerable: !0
315
315
  }), d;
316
316
  }
317
- if (En(n)) {
317
+ if (Dn(n)) {
318
318
  const { clientX: u, clientY: l } = Re({
319
319
  position: n,
320
320
  frameElement: r
@@ -328,7 +328,7 @@ const Je = (n, e, t, i) => {
328
328
  enumerable: !0
329
329
  }), d;
330
330
  }
331
- if (Dn(n)) {
331
+ if (Rn(n)) {
332
332
  const u = Array.from(n.touches).map((d) => {
333
333
  const { clientX: g, clientY: h } = Re({
334
334
  position: d,
@@ -351,7 +351,7 @@ const Je = (n, e, t, i) => {
351
351
  }), l;
352
352
  }
353
353
  return n;
354
- }, _n = [
354
+ }, Hn = [
355
355
  "pointercancel",
356
356
  "pointerdown",
357
357
  "pointerenter",
@@ -360,21 +360,21 @@ const Je = (n, e, t, i) => {
360
360
  "pointerout",
361
361
  "pointerover",
362
362
  "pointerup"
363
- ], Hn = [
364
- ..._n
363
+ ], Bn = [
364
+ ...Hn
365
365
  /*, ...mouseEvents*/
366
- ], Bn = (n) => (e) => {
366
+ ], Xn = (n) => (e) => {
367
367
  const t = n(e);
368
368
  return t.hookManager.register(
369
369
  "item.onDocumentLoad",
370
370
  ({ destroy: i, itemId: o }) => {
371
371
  const s = t.spineItemsManager.get(o), r = s?.renderer.getDocumentFrame();
372
372
  if (!r || !s) return;
373
- const a = Hn.map((c) => {
373
+ const a = Bn.map((c) => {
374
374
  const u = (l) => {
375
375
  let d = l;
376
376
  if (Ze(l) && (d = new PointerEvent(l.type, l)), d !== l) {
377
- const g = Wn(
377
+ const g = _n(
378
378
  d,
379
379
  l,
380
380
  t.spine.locator,
@@ -418,7 +418,7 @@ const Ee = (n) => (e) => e.pipe(
418
418
  K(() => t)
419
419
  )
420
420
  )
421
- ), Xn = (n) => {
421
+ ), Yn = (n) => {
422
422
  let e;
423
423
  const t = n.subscribe((i) => {
424
424
  e = { result: i };
@@ -448,7 +448,7 @@ const lt = (n, e) => new ne((t) => {
448
448
  });
449
449
  return i.observe(n, e), () => i.disconnect();
450
450
  });
451
- function Ys(n, e) {
451
+ function qs(n, e) {
452
452
  return new ne((t) => {
453
453
  const i = new IntersectionObserver((o) => {
454
454
  t.next(o);
@@ -470,7 +470,7 @@ class jt {
470
470
  e
471
471
  ), this.outputSettingsUpdateSubject = new R(), this.values$ = k([
472
472
  this.settingsManager.values$,
473
- this.outputSettingsUpdateSubject.pipe(yn(this.outputSettings))
473
+ this.outputSettingsUpdateSubject.pipe(Sn(this.outputSettings))
474
474
  ]).pipe(
475
475
  K(([o, s]) => ({ ...o, ...s })),
476
476
  Ce(1)
@@ -506,7 +506,7 @@ class jt {
506
506
  this.outputSettingsUpdateSubject.complete();
507
507
  }
508
508
  }
509
- const qs = (n) => {
509
+ const Gs = (n) => {
510
510
  const e = new FileReader();
511
511
  return new Promise((t) => {
512
512
  e.addEventListener(
@@ -518,7 +518,7 @@ const qs = (n) => {
518
518
  ), e.readAsDataURL(n);
519
519
  });
520
520
  };
521
- let Yn = class extends jt {
521
+ let qn = class extends jt {
522
522
  computeOutputSettings(e) {
523
523
  return e;
524
524
  }
@@ -544,8 +544,8 @@ let Yn = class extends jt {
544
544
  };
545
545
  }
546
546
  };
547
- const qn = (n) => (e) => {
548
- const { fontScale: t, lineHeight: i, fontWeight: o, fontJustification: s } = e, r = new R(), a = n(e), c = new Yn(
547
+ const Gn = (n) => (e) => {
548
+ const { fontScale: t, lineHeight: i, fontWeight: o, fontJustification: s } = e, r = new R(), a = n(e), c = new qn(
549
549
  {
550
550
  fontScale: t,
551
551
  lineHeight: i,
@@ -577,7 +577,7 @@ const qn = (n) => (e) => {
577
577
  }
578
578
  });
579
579
  const d = (g) => g.pipe(
580
- Sn(),
580
+ bn(),
581
581
  S(([h, p]) => p.fontScale !== h.fontScale || p.lineHeight !== h.lineHeight)
582
582
  );
583
583
  return c.values$.pipe(
@@ -591,7 +591,7 @@ const qn = (n) => (e) => {
591
591
  },
592
592
  settings: c
593
593
  };
594
- }, Gn = (n) => (e) => {
594
+ }, Zn = (n) => (e) => {
595
595
  const t = n(e), i = (o) => q(o, "keyup").pipe(
596
596
  S((s) => {
597
597
  const { pageTurnDirection: r, computedPageTurnMode: a } = t.settings.values;
@@ -627,7 +627,7 @@ const qn = (n) => (e) => {
627
627
  ),
628
628
  T(t.$.destroy$)
629
629
  ).subscribe(), t;
630
- }, Zn = (n) => n.spine.spineItemsManager.items$.pipe(
630
+ }, Jn = (n) => n.spine.spineItemsManager.items$.pipe(
631
631
  w(
632
632
  (e) => P(
633
633
  ...e.map((t) => t.watch("isLoaded").pipe(
@@ -796,15 +796,15 @@ const Le = class Le extends X {
796
796
  };
797
797
  Le.DOCUMENT_CONTAINER_CLASS_NAME = "prose-reader-document-container";
798
798
  let fe = Le;
799
- const Jn = (n) => new URL(n.href);
799
+ const Kn = (n) => new URL(n.href);
800
800
  class nt {
801
801
  constructor(e, t) {
802
802
  this.item = e, this.settings = t;
803
803
  }
804
804
  async getResource() {
805
- return await rn(
805
+ return await an(
806
806
  this.settings.values.getResource?.(this.item) ?? v(void 0)
807
- ) ?? Jn(this.item);
807
+ ) ?? Kn(this.item);
808
808
  }
809
809
  async fetchResource() {
810
810
  const e = await this.getResource();
@@ -814,7 +814,7 @@ class nt {
814
814
  const kt = (n, e) => {
815
815
  const t = n.startsWith("file://"), i = t ? n.replace("file://", "http://") : n, o = new URL(e, i).toString();
816
816
  return t ? o.replace("http://", "file://") : o;
817
- }, Kn = async (n, e, t, i, o) => {
817
+ }, Qn = async (n, e, t, i, o) => {
818
818
  if (!n || !n.defaultView) return;
819
819
  const s = e.sheet;
820
820
  if (s)
@@ -831,22 +831,22 @@ const kt = (n, e) => {
831
831
  return p;
832
832
  const m = p.match(/url\(['"]?([^'"]+)['"]?\)/);
833
833
  if (!m) return p;
834
- const y = m[1] ?? "", f = i.manifest?.items.find(({ href: I }) => `${kt(t, y).toLowerCase()}`.endsWith(
835
- `${I.toLowerCase()}`
834
+ const y = m[1] ?? "", f = i.manifest?.items.find(({ href: b }) => `${kt(t, y).toLowerCase()}`.endsWith(
835
+ `${b.toLowerCase()}`
836
836
  ));
837
837
  if (f) {
838
- const I = new nt(f, o);
838
+ const b = new nt(f, o);
839
839
  try {
840
- const b = await I.getResource();
841
- if (b instanceof Response) {
842
- const F = await b.blob(), $ = n.defaultView?.URL.createObjectURL(F);
840
+ const I = await b.getResource();
841
+ if (I instanceof Response) {
842
+ const F = await I.blob(), $ = n.defaultView?.URL.createObjectURL(F);
843
843
  return p.replace(
844
844
  m[0],
845
845
  `url("${$}")`
846
846
  );
847
847
  }
848
- } catch (b) {
849
- console.error("Error loading font:", b);
848
+ } catch (I) {
849
+ console.error("Error loading font:", I);
850
850
  }
851
851
  }
852
852
  return p;
@@ -862,7 +862,7 @@ const kt = (n, e) => {
862
862
  } catch (r) {
863
863
  console.error("Could not access stylesheet rules:", r);
864
864
  }
865
- }, Qn = (n, e, t, i, o) => {
865
+ }, ei = (n, e, t, i, o) => {
866
866
  const s = e.getAttribute("src") || e.getAttribute("href");
867
867
  if (!s) return v(null);
868
868
  const r = i.manifest?.items.find(({ href: c }) => `${kt(t, s).toLowerCase()}`.endsWith(
@@ -884,7 +884,7 @@ const kt = (n, e) => {
884
884
  return new ne((l) => {
885
885
  e.onload = async () => {
886
886
  try {
887
- e.sheet && await Kn(
887
+ e.sheet && await Qn(
888
888
  n,
889
889
  e,
890
890
  t,
@@ -899,7 +899,7 @@ const kt = (n, e) => {
899
899
  return v(null);
900
900
  })
901
901
  );
902
- }, ei = ({
902
+ }, ti = ({
903
903
  settings: n,
904
904
  item: e,
905
905
  context: t
@@ -907,8 +907,8 @@ const kt = (n, e) => {
907
907
  w((o) => {
908
908
  const s = Rt(
909
909
  o.contentDocument
910
- ), r = hn(e.href), a = s.map(
911
- (c) => Qn(
910
+ ), r = mn(e.href), a = s.map(
911
+ (c) => ei(
912
912
  o.contentDocument,
913
913
  c,
914
914
  r,
@@ -918,11 +918,11 @@ const kt = (n, e) => {
918
918
  );
919
919
  return k(a).pipe(S(() => o));
920
920
  })
921
- ), ti = (n) => {
922
- An(n?.contentDocument);
923
- }, Zs = "@prose-reader/core", Js = 0, Ks = 200, ni = [".xhtml", ".html", ".htm"], W = "prose-reader", Ut = `${W}-style`, ii = `data-${W}-id`, oi = `${W}-viewport`, si = `${W}-scroll-navigator`, ri = async (n, e) => {
921
+ ), ni = (n) => {
922
+ On(n?.contentDocument);
923
+ }, Js = "@prose-reader/core", Ks = 0, Qs = 200, ii = [".xhtml", ".html", ".htm"], W = "prose-reader", Ut = `${W}-style`, oi = `data-${W}-id`, si = `${W}-viewport`, ri = `${W}-scroll-navigator`, ai = async (n, e) => {
924
924
  if (typeof n == "string") return n;
925
- const t = mn(n.headers.get("Content-Type") || "") || Me(e.href);
925
+ const t = fn(n.headers.get("Content-Type") || "") || Me(e.href);
926
926
  if (["image/jpg", "image/jpeg", "image/png", "image/webp"].some(
927
927
  (o) => o === t
928
928
  )) {
@@ -958,11 +958,11 @@ const kt = (n, e) => {
958
958
  </body>
959
959
  </html>
960
960
  ` : await n.text();
961
- }, ai = ({
961
+ }, ci = ({
962
962
  item: n,
963
963
  resourcesHandler: e
964
964
  }) => {
965
- const t = (i) => ri(i, n);
965
+ const t = (i) => ai(i, n);
966
966
  return (i) => i.pipe(
967
967
  w((o) => N(e.getResource()).pipe(
968
968
  w((s) => s instanceof URL && n.href.startsWith(window.location.origin) && // we have an encoding and it's a valid html
@@ -972,7 +972,7 @@ const kt = (n, e) => {
972
972
  "text/html",
973
973
  "text/xml"
974
974
  ].includes(n.mediaType) || // no encoding ? then try to detect html
975
- !n.mediaType && ni.some(
975
+ !n.mediaType && ii.some(
976
976
  (a) => n.href.endsWith(a)
977
977
  )) ? (o?.setAttribute("src", n.href), v(o)) : (s instanceof URL ? N(e.fetchResource()) : v(s)).pipe(
978
978
  w((a) => {
@@ -994,7 +994,7 @@ const kt = (n, e) => {
994
994
  ))
995
995
  ))
996
996
  );
997
- }, ci = () => {
997
+ }, ui = () => {
998
998
  const n = document.createElement("iframe");
999
999
  return n.frameBorder = "no", n.tabIndex = 0, n.setAttribute(
1000
1000
  "sandbox",
@@ -1027,7 +1027,7 @@ const kt = (n, e) => {
1027
1027
  n / (i.height ?? 1)
1028
1028
  ), computedWidthScale: o, viewportDimensions: i };
1029
1029
  }
1030
- }, ui = ({
1030
+ }, li = ({
1031
1031
  columnWidth: n,
1032
1032
  enableTouch: e,
1033
1033
  spreadPosition: t
@@ -1072,12 +1072,12 @@ const kt = (n, e) => {
1072
1072
  object-fit:contain;
1073
1073
  `}
1074
1074
  }
1075
- `, li = ({
1075
+ `, di = ({
1076
1076
  pageHeight: n,
1077
1077
  pageWidth: e
1078
1078
  }) => ({ columnHeight: n, columnWidth: e }), dt = (n, e) => {
1079
1079
  n.style.width = `${e.width}px`, n.style.height = `${e.height}px`;
1080
- }, di = ({
1080
+ }, pi = ({
1081
1081
  minPageSpread: n,
1082
1082
  blankPagePosition: e,
1083
1083
  spreadPosition: t,
@@ -1089,9 +1089,9 @@ const kt = (n, e) => {
1089
1089
  }) => {
1090
1090
  const c = n * o;
1091
1091
  if (s?.contentDocument && s?.contentWindow) {
1092
- const { viewportDimensions: u, computedScale: l = 1 } = Wt({ frameElement: s, pageHeight: i, pageWidth: o }) ?? {}, d = o, g = i, h = ui(
1092
+ const { viewportDimensions: u, computedScale: l = 1 } = Wt({ frameElement: s, pageHeight: i, pageWidth: o }) ?? {}, d = o, g = i, h = li(
1093
1093
  {
1094
- ...li({ pageHeight: i, pageWidth: o }),
1094
+ ...di({ pageHeight: i, pageWidth: o }),
1095
1095
  enableTouch: a,
1096
1096
  spreadPosition: t
1097
1097
  },
@@ -1121,7 +1121,7 @@ const kt = (n, e) => {
1121
1121
  return { width: c, height: g };
1122
1122
  }
1123
1123
  return { width: c, height: i };
1124
- }, pi = () => `
1124
+ }, gi = () => `
1125
1125
  ${zt()}
1126
1126
  html {
1127
1127
  width: 100%;
@@ -1136,7 +1136,7 @@ const kt = (n, e) => {
1136
1136
  html, body {
1137
1137
  touch-action: none;
1138
1138
  }
1139
- `, gi = ({
1139
+ `, hi = ({
1140
1140
  isScrollable: n,
1141
1141
  enableTouch: e
1142
1142
  }) => `
@@ -1161,7 +1161,7 @@ const kt = (n, e) => {
1161
1161
  display: block;
1162
1162
  }
1163
1163
  ` : ""}
1164
- `, hi = ({
1164
+ `, mi = ({
1165
1165
  width: n,
1166
1166
  columnHeight: e,
1167
1167
  columnWidth: t
@@ -1229,7 +1229,7 @@ const kt = (n, e) => {
1229
1229
  td {
1230
1230
  max-width: ${t}px;
1231
1231
  }
1232
- `, mi = ({
1232
+ `, fi = ({
1233
1233
  isUsingVerticalWriting: n,
1234
1234
  minimumWidth: e,
1235
1235
  pageHeight: t,
@@ -1243,9 +1243,9 @@ const kt = (n, e) => {
1243
1243
  columnWidth: r,
1244
1244
  width: c
1245
1245
  };
1246
- }, be = (n, e) => {
1246
+ }, Ie = (n, e) => {
1247
1247
  n.style.width = `${e.width}px`, n.style.height = `${e.height}px`;
1248
- }, fi = ({
1248
+ }, yi = ({
1249
1249
  pageHeight: n,
1250
1250
  pageWidth: e,
1251
1251
  frameElement: t,
@@ -1270,8 +1270,8 @@ const kt = (n, e) => {
1270
1270
  te(
1271
1271
  t,
1272
1272
  "prose-reader-html-renderer-framce-css",
1273
- pi()
1274
- ), be(t, {
1273
+ gi()
1274
+ ), Ie(t, {
1275
1275
  width: h.width ?? 1,
1276
1276
  height: h.height ?? 1
1277
1277
  }), t?.style.setProperty("position", "absolute"), t?.style.setProperty("top", "50%"), t?.style.setProperty(
@@ -1282,26 +1282,26 @@ const kt = (n, e) => {
1282
1282
  `translate(-50%, -50%) scale(${p})`
1283
1283
  ), t?.style.setProperty("transform-origin", "center center");
1284
1284
  else {
1285
- const b = a ? gi({
1285
+ const I = a ? hi({
1286
1286
  isScrollable: i?.renditionFlow === "scrolled-continuous",
1287
1287
  enableTouch: c
1288
- }) : hi(
1289
- mi({
1288
+ }) : mi(
1289
+ fi({
1290
1290
  isUsingVerticalWriting: u,
1291
1291
  minimumWidth: l,
1292
1292
  pageHeight: g,
1293
1293
  pageWidth: e
1294
1294
  })
1295
1295
  );
1296
- if (te(t, "prose-reader-css", b, !0), u)
1296
+ if (te(t, "prose-reader-css", I, !0), u)
1297
1297
  f = Math.ceil(
1298
1298
  t.contentDocument.documentElement.scrollHeight / g
1299
- ) * g, be(t, {
1299
+ ) * g, Ie(t, {
1300
1300
  width: l,
1301
1301
  height: f
1302
1302
  });
1303
1303
  else if (i?.renditionFlow === "scrolled-continuous")
1304
- f = t.contentDocument.body.scrollHeight, be(t, {
1304
+ f = t.contentDocument.body.scrollHeight, Ie(t, {
1305
1305
  width: l,
1306
1306
  height: f
1307
1307
  });
@@ -1309,7 +1309,7 @@ const kt = (n, e) => {
1309
1309
  const F = Math.ceil(
1310
1310
  t.contentDocument.documentElement.scrollWidth / e
1311
1311
  );
1312
- m ? y = e : y = F * e, be(t, {
1312
+ m ? y = e : y = F * e, Ie(t, {
1313
1313
  width: y,
1314
1314
  height: f
1315
1315
  });
@@ -1318,19 +1318,19 @@ const kt = (n, e) => {
1318
1318
  return y % l === 0 ? t?.style.setProperty("margin-left", "0px") : (y = y + e, s && !u && t?.style.setProperty("margin-left", `${e}px`)), { width: y, height: f };
1319
1319
  }
1320
1320
  };
1321
- class yi extends fe {
1321
+ class Si extends fe {
1322
1322
  constructor() {
1323
1323
  super(...arguments), this.isImageType = () => !!(this.item.mediaType ?? Me(this.item.href))?.startsWith("image/");
1324
1324
  }
1325
1325
  onCreateDocument() {
1326
- const e = ci();
1326
+ const e = ui();
1327
1327
  return this.setDocumentContainer(e), v(e);
1328
1328
  }
1329
1329
  onLoadDocument() {
1330
1330
  const e = this.getFrameElement();
1331
1331
  if (!e) throw new Error("invalid frame");
1332
1332
  return v(e).pipe(
1333
- ai({
1333
+ ci({
1334
1334
  item: this.item,
1335
1335
  resourcesHandler: this.resourcesHandler,
1336
1336
  settings: this.settings
@@ -1339,17 +1339,17 @@ class yi extends fe {
1339
1339
  x(() => {
1340
1340
  this.attach();
1341
1341
  }),
1342
- jn,
1343
- ei({
1342
+ kn,
1343
+ ti({
1344
1344
  context: this.context,
1345
1345
  item: this.item,
1346
1346
  settings: this.settings
1347
1347
  }),
1348
- kn
1348
+ Un
1349
1349
  );
1350
1350
  }
1351
1351
  onUnload() {
1352
- return ti(this.getFrameElement()), this.detach(), Z;
1352
+ return ni(this.getFrameElement()), this.detach(), Z;
1353
1353
  }
1354
1354
  onLayout({
1355
1355
  minPageSpread: e,
@@ -1360,7 +1360,7 @@ class yi extends fe {
1360
1360
  if (!r) return v(void 0);
1361
1361
  const a = !!this.writingMode?.startsWith("vertical");
1362
1362
  if (this.item.renditionLayout === "pre-paginated" || !this.item.renditionLayout && this.context.manifest?.renditionLayout === "pre-paginated") {
1363
- const u = di({
1363
+ const u = pi({
1364
1364
  blankPagePosition: t,
1365
1365
  enableTouch: this.settings.values.computedPageTurnMode !== "scrollable",
1366
1366
  frameElement: r,
@@ -1372,7 +1372,7 @@ class yi extends fe {
1372
1372
  });
1373
1373
  return v(u);
1374
1374
  }
1375
- const c = fi({
1375
+ const c = yi({
1376
1376
  pageHeight: s,
1377
1377
  pageWidth: o,
1378
1378
  frameElement: r,
@@ -1440,13 +1440,13 @@ class yi extends fe {
1440
1440
  return this.getFrameElement();
1441
1441
  }
1442
1442
  }
1443
- const Si = (n) => (e) => {
1443
+ const bi = (n) => (e) => {
1444
1444
  const t = n({
1445
1445
  ...e,
1446
1446
  getRenderer(o) {
1447
- return e.getRenderer?.(o) ?? ((r) => new yi(r));
1447
+ return e.getRenderer?.(o) ?? ((r) => new Si(r));
1448
1448
  }
1449
- }), i = Zn(t);
1449
+ }), i = Jn(t);
1450
1450
  return i.pipe(T(t.$.destroy$)).subscribe(), {
1451
1451
  ...t,
1452
1452
  links$: i
@@ -1480,7 +1480,7 @@ class _e extends it {
1480
1480
  super(...arguments), this.__symbol = "SpineItemSpineLayout";
1481
1481
  }
1482
1482
  }
1483
- class bi extends it {
1483
+ class vi extends it {
1484
1484
  constructor() {
1485
1485
  super(...arguments), this.__symbol = "SpineItemPageSpineLayout";
1486
1486
  }
@@ -1506,17 +1506,17 @@ class ae extends _t {
1506
1506
  return new ae(e);
1507
1507
  }
1508
1508
  }
1509
- const vi = (n, e) => {
1509
+ const wi = (n, e) => {
1510
1510
  const t = e.getBoundingClientRect(), { x: i, y: o } = n, { left: s, top: r } = t, a = t.width / e.offsetWidth, c = t.height / e.offsetHeight, u = i - s, l = o - r;
1511
1511
  return {
1512
1512
  x: u / a,
1513
1513
  y: l / c
1514
1514
  };
1515
- }, wi = (n, e) => new ae(
1516
- vi(n, e)
1517
- ), Pi = (n) => ({
1518
- getSpinePositionFromClientPosition: (e) => n.spine.element ? wi(e, n.spine.element) : void 0
1519
- }), xi = (n) => {
1515
+ }, Pi = (n, e) => new ae(
1516
+ wi(n, e)
1517
+ ), xi = (n) => ({
1518
+ getSpinePositionFromClientPosition: (e) => n.spine.element ? Pi(e, n.spine.element) : void 0
1519
+ }), $i = (n) => {
1520
1520
  let e;
1521
1521
  const t = n.context.watch("rootElement").pipe(
1522
1522
  _((c) => c ? new ne(() => (e = c.ownerDocument.createElement("div"), e.style.cssText = `
@@ -1529,7 +1529,7 @@ const vi = (n, e) => {
1529
1529
  `, c.appendChild(e), () => {
1530
1530
  e?.remove(), e = void 0;
1531
1531
  })) : ge)
1532
- ), i = (c) => an(c, re).pipe(
1532
+ ), i = (c) => cn(c, re).pipe(
1533
1533
  j(() => {
1534
1534
  e?.style.setProperty(
1535
1535
  "visibility",
@@ -1555,11 +1555,11 @@ const vi = (n, e) => {
1555
1555
  G(n.$.destroy$)
1556
1556
  );
1557
1557
  return P(t, a);
1558
- }, $i = (n) => {
1558
+ }, Ti = (n) => {
1559
1559
  n.hookManager.register("item.onDocumentLoad", ({ itemId: e }) => {
1560
1560
  n.spineItemsManager.get(e)?.renderer.getDocumentFrame()?.setAttribute("scrolling", "no");
1561
1561
  });
1562
- }, Ti = (n) => {
1562
+ }, Fi = (n) => {
1563
1563
  n.hookManager.register(
1564
1564
  "item.onAfterLayout",
1565
1565
  ({ item: e, blankPagePosition: t, minimumWidth: i }) => {
@@ -1576,7 +1576,7 @@ const vi = (n, e) => {
1576
1576
  }
1577
1577
  }
1578
1578
  );
1579
- }, Fi = (n) => n.spineItemsManager.items$.pipe(
1579
+ }, Li = (n) => n.spineItemsManager.items$.pipe(
1580
1580
  w(
1581
1581
  (e) => P(
1582
1582
  ...e.map(
@@ -1589,7 +1589,7 @@ const vi = (n, e) => {
1589
1589
  )
1590
1590
  )
1591
1591
  );
1592
- let Li = class extends jt {
1592
+ let Mi = class extends jt {
1593
1593
  computeOutputSettings(e) {
1594
1594
  return e;
1595
1595
  }
@@ -1615,7 +1615,7 @@ let Li = class extends jt {
1615
1615
  };
1616
1616
  }
1617
1617
  };
1618
- const Mi = (n) => k([
1618
+ const Ci = (n) => k([
1619
1619
  n.viewport.watch(["width", "height"]),
1620
1620
  n.context.watch("manifest")
1621
1621
  ]).pipe(
@@ -1623,13 +1623,13 @@ const Mi = (n) => k([
1623
1623
  const o = e > t;
1624
1624
  return !o && i?.renditionSpread === "portrait" ? n.settings.update({ spreadMode: !0 }) : o && (i?.renditionSpread === void 0 || i?.renditionSpread === "auto" || i?.renditionSpread === "landscape" || i?.renditionSpread === "both") ? n.settings.update({ spreadMode: !0 }) : n.settings.update({ spreadMode: !1 });
1625
1625
  })
1626
- ), Ci = (n) => (e) => {
1626
+ ), Ei = (n) => (e) => {
1627
1627
  const {
1628
1628
  pageHorizontalMargin: t,
1629
1629
  pageVerticalMargin: i,
1630
1630
  layoutAutoResize: o,
1631
1631
  layoutLayerTransition: s
1632
- } = e, r = n(e), a = new Li(
1632
+ } = e, r = n(e), a = new Mi(
1633
1633
  {
1634
1634
  pageHorizontalMargin: t,
1635
1635
  pageVerticalMargin: i,
@@ -1645,12 +1645,12 @@ const Mi = (n) => k([
1645
1645
  !p && y && (y.getBoundingClientRect().left, p = !0);
1646
1646
  });
1647
1647
  }), r.hookManager.register("item.onBeforeLayout", ({ item: p }) => {
1648
- const m = r.spineItemsManager.get(p.id), f = !!(p.mediaType ?? Me(p.href))?.startsWith("image/"), { pageHorizontalMargin: I = 0, pageVerticalMargin: b = 0 } = a.values, F = r.viewport.pageSize;
1648
+ const m = r.spineItemsManager.get(p.id), f = !!(p.mediaType ?? Me(p.href))?.startsWith("image/"), { pageHorizontalMargin: b = 0, pageVerticalMargin: I = 0 } = a.values, F = r.viewport.pageSize;
1649
1649
  if (m?.renditionLayout === "reflowable" && !f) {
1650
- let $ = F.width - I * 2;
1651
- const A = F.height - b * 2;
1652
- let Y = F.width - I * 2, B = I * 2;
1653
- m.isUsingVerticalWriting() && (Y = F.width - I * 2, $ = A, B = b * 2);
1650
+ let $ = F.width - b * 2;
1651
+ const A = F.height - I * 2;
1652
+ let Y = F.width - b * 2, B = b * 2;
1653
+ m.isUsingVerticalWriting() && (Y = F.width - b * 2, $ = A, B = I * 2);
1654
1654
  const ie = m?.renderer.getDocumentFrame();
1655
1655
  ie && te(
1656
1656
  ie,
@@ -1658,7 +1658,7 @@ const Mi = (n) => k([
1658
1658
  `
1659
1659
  body {
1660
1660
  width: ${Y}px !important;
1661
- margin: ${b}px ${I}px !important;
1661
+ margin: ${I}px ${b}px !important;
1662
1662
  column-gap: ${B}px !important;
1663
1663
  column-width: ${$}px !important;
1664
1664
  height: ${A}px !important;
@@ -1676,7 +1676,7 @@ const Mi = (n) => k([
1676
1676
  `
1677
1677
  );
1678
1678
  }
1679
- }), Ti(r), $i(r), r.hookManager.register(
1679
+ }), Fi(r), Ti(r), r.hookManager.register(
1680
1680
  "item.onDocumentCreated",
1681
1681
  ({ documentContainer: p }) => {
1682
1682
  p.style.opacity = "0", a.values.layoutLayerTransition && (p.style.transition = "opacity 300ms");
@@ -1696,12 +1696,12 @@ const Mi = (n) => k([
1696
1696
  _(() => r.context.watch("rootElement")),
1697
1697
  se(le),
1698
1698
  _((p) => tt(p)),
1699
- bn(100),
1699
+ vn(100),
1700
1700
  se(le),
1701
1701
  j(() => {
1702
1702
  r?.layout();
1703
1703
  })
1704
- ), l = xi(r);
1704
+ ), l = $i(r);
1705
1705
  a.watch(["pageHorizontalMargin", "pageVerticalMargin"]).pipe(
1706
1706
  Ct(1),
1707
1707
  j(() => {
@@ -1711,7 +1711,7 @@ const Mi = (n) => k([
1711
1711
  ).subscribe();
1712
1712
  const d = r.spine.pages.pipe(
1713
1713
  Ce({ refCount: !0, bufferSize: 1 })
1714
- ), g = Fi(r), h = Mi(r);
1714
+ ), g = Li(r), h = Ci(r);
1715
1715
  return P(
1716
1716
  c,
1717
1717
  l,
@@ -1727,9 +1727,9 @@ const Mi = (n) => k([
1727
1727
  settings: a,
1728
1728
  layout$: r.spine.layout$,
1729
1729
  layoutInfo$: d,
1730
- coordinates: Pi(r)
1730
+ coordinates: xi(r)
1731
1731
  };
1732
- }, Ei = `${W}-enhancer-loading`, Ht = `${Ei}-container`, Di = (n, e) => {
1732
+ }, Di = `${W}-enhancer-loading`, Ht = `${Di}-container`, Ri = (n, e) => {
1733
1733
  const t = n.ownerDocument.createElement("div");
1734
1734
  return t.classList.add(Ht), t.style.cssText = `
1735
1735
  height: 100%;
@@ -1747,7 +1747,7 @@ const Mi = (n) => k([
1747
1747
  background-color: white;
1748
1748
  z-index: 1;
1749
1749
  `, t;
1750
- }, Ri = ({
1750
+ }, Ai = ({
1751
1751
  container: n,
1752
1752
  item: e
1753
1753
  }) => {
@@ -1764,8 +1764,8 @@ const Mi = (n) => k([
1764
1764
  max-width: 300px;
1765
1765
  width: 80%;
1766
1766
  `, n.appendChild(t), n.appendChild(i), n;
1767
- }, Ai = (n) => (e) => {
1768
- const { loadingElementCreate: t = Ri } = e, i = n(e), o = (c) => v(
1767
+ }, Oi = (n) => (e) => {
1768
+ const { loadingElementCreate: t = Ai } = e, i = n(e), o = (c) => v(
1769
1769
  c.reduce((u, { item: l, element: d }) => {
1770
1770
  d.style.zIndex = "0";
1771
1771
  const g = d.querySelector(
@@ -1774,7 +1774,7 @@ const Mi = (n) => k([
1774
1774
  if (g instanceof HTMLElement)
1775
1775
  return u[l.id] = g, u;
1776
1776
  const h = t({
1777
- container: Di(d, i.viewport),
1777
+ container: Ri(d, i.viewport),
1778
1778
  item: l
1779
1779
  });
1780
1780
  return d.appendChild(h), u[l.id] = h, u;
@@ -1825,7 +1825,7 @@ const Mi = (n) => k([
1825
1825
  }
1826
1826
  };
1827
1827
  };
1828
- class Oi extends fe {
1828
+ class Ni extends fe {
1829
1829
  getImageElement() {
1830
1830
  const e = this.documentContainer;
1831
1831
  if (e instanceof HTMLImageElement)
@@ -1877,12 +1877,12 @@ class Oi extends fe {
1877
1877
  getDocumentFrame() {
1878
1878
  }
1879
1879
  }
1880
- const Ni = (n) => (e) => {
1880
+ const Vi = (n) => (e) => {
1881
1881
  const t = n({
1882
1882
  ...e,
1883
1883
  getRenderer(r) {
1884
1884
  const a = e.getRenderer?.(r), u = !!(r.mediaType ?? Me(r.href))?.startsWith("image/");
1885
- return !a && u ? (l) => new Oi(l) : a;
1885
+ return !a && u ? (l) => new Ni(l) : a;
1886
1886
  }
1887
1887
  }), i = new IntersectionObserver(
1888
1888
  (r) => {
@@ -1932,15 +1932,15 @@ const Ni = (n) => (e) => {
1932
1932
  i.disconnect(), o.disconnect(), t.destroy();
1933
1933
  }
1934
1934
  };
1935
- }, Vi = (n, e) => n.links$.pipe(
1935
+ }, ji = (n, e) => n.links$.pipe(
1936
1936
  x((t) => {
1937
- if (!On(t.target, "a") || t.type !== "click") return;
1937
+ if (!Nn(t.target, "a") || t.type !== "click") return;
1938
1938
  const i = new URL(t.target.href), o = `${i.origin}${i.pathname}`;
1939
1939
  n.context.manifest?.spineItems.some(
1940
1940
  (r) => r.href === o
1941
1941
  ) && e.goToUrl(i);
1942
1942
  })
1943
- ), oe = D.namespace("navigation"), ji = ({
1943
+ ), oe = D.namespace("navigation"), ki = ({
1944
1944
  position: n,
1945
1945
  spineItem: e,
1946
1946
  pageHeight: t,
@@ -1972,7 +1972,7 @@ const Ni = (n) => (e) => {
1972
1972
  const u = o.getSpineItemPositionFromSpinePosition(
1973
1973
  n,
1974
1974
  a
1975
- ), l = ji({
1975
+ ), l = ki({
1976
1976
  position: u,
1977
1977
  spineItem: a,
1978
1978
  pageHeight: s.pageSize.height,
@@ -1994,7 +1994,7 @@ const Ni = (n) => (e) => {
1994
1994
  x: 0
1995
1995
  })
1996
1996
  );
1997
- }, ki = ({
1997
+ }, Ui = ({
1998
1998
  position: n,
1999
1999
  spineItem: e,
2000
2000
  context: t,
@@ -2038,7 +2038,7 @@ const Ni = (n) => (e) => {
2038
2038
  return i.getAdjustedPositionForSpread(l);
2039
2039
  }
2040
2040
  return i.getAdjustedPositionForSpread(u);
2041
- }, Ui = ({
2041
+ }, zi = ({
2042
2042
  position: n,
2043
2043
  spineItem: e,
2044
2044
  pageHeight: t,
@@ -2070,7 +2070,7 @@ const Ni = (n) => (e) => {
2070
2070
  const u = o.getSpineItemPositionFromSpinePosition(
2071
2071
  n,
2072
2072
  a
2073
- ), l = Ui({
2073
+ ), l = zi({
2074
2074
  position: u,
2075
2075
  spineItem: a,
2076
2076
  pageHeight: s.pageSize.height,
@@ -2092,7 +2092,7 @@ const Ni = (n) => (e) => {
2092
2092
  x: 0
2093
2093
  })
2094
2094
  );
2095
- }, zi = ({
2095
+ }, Wi = ({
2096
2096
  position: n,
2097
2097
  spineItem: e,
2098
2098
  context: t,
@@ -2140,7 +2140,7 @@ const Ni = (n) => (e) => {
2140
2140
  }
2141
2141
  return i.getAdjustedPositionForSpread(u);
2142
2142
  };
2143
- class Wi {
2143
+ class _i {
2144
2144
  constructor(e) {
2145
2145
  this.reader = e, this.movingLastDelta = { x: 0, y: 0 }, this.movingLastPosition = new M({ x: 0, y: 0 }), this.unlock = void 0;
2146
2146
  }
@@ -2159,7 +2159,7 @@ class Wi {
2159
2159
  turnRightOrBottom() {
2160
2160
  const e = this.reader.navigation.getNavigation(), t = this.reader.spineItemsManager.get(e.spineItem);
2161
2161
  if (!t) return;
2162
- const i = zi({
2162
+ const i = Wi({
2163
2163
  context: this.reader.context,
2164
2164
  navigationResolver: this.reader.navigation.navigationResolver,
2165
2165
  position: e.position,
@@ -2177,7 +2177,7 @@ class Wi {
2177
2177
  turnLeftOrTop() {
2178
2178
  const e = this.reader.navigation.getNavigation(), t = this.reader.spineItemsManager.get(e.spineItem);
2179
2179
  if (!t) return;
2180
- const i = ki({
2180
+ const i = Ui({
2181
2181
  context: this.reader.context,
2182
2182
  navigationResolver: this.reader.navigation.navigationResolver,
2183
2183
  position: e.position,
@@ -2319,7 +2319,7 @@ class Wi {
2319
2319
  }
2320
2320
  }
2321
2321
  }
2322
- class _i {
2322
+ class Hi {
2323
2323
  constructor(e) {
2324
2324
  this.reader = e, this.lastDelta = { x: 0, y: 0 }, this.lastPosition = new M({ x: 0, y: 0 }), this.lastStartPosition = new M({ x: 0, y: 0 }), this.unlock = void 0;
2325
2325
  }
@@ -2358,8 +2358,8 @@ class _i {
2358
2358
  });
2359
2359
  }
2360
2360
  }
2361
- const Hi = 500;
2362
- class Bi extends X {
2361
+ const Bi = 500;
2362
+ class Xi extends X {
2363
2363
  constructor(e, t) {
2364
2364
  super(), this.scrollNavigationController = e, this.locker = t, this.navigationSubject = new R(), this.navigation$ = this.navigationSubject.asObservable();
2365
2365
  const i = this.scrollNavigationController.userScroll$.pipe(
@@ -2370,7 +2370,7 @@ class Bi extends X {
2370
2370
  v(o)
2371
2371
  ).pipe(
2372
2372
  Se(
2373
- Hi,
2373
+ Bi,
2374
2374
  re
2375
2375
  ),
2376
2376
  U(),
@@ -2393,7 +2393,7 @@ class Bi extends X {
2393
2393
  P(i).pipe(T(this.destroy$)).subscribe();
2394
2394
  }
2395
2395
  }
2396
- const Xi = (n) => n.pagination.state$.pipe(
2396
+ const Yi = (n) => n.pagination.state$.pipe(
2397
2397
  O(n.context.manifest$, n.settings.values$),
2398
2398
  S(
2399
2399
  ([
@@ -2413,7 +2413,7 @@ const Xi = (n) => n.pagination.state$.pipe(
2413
2413
  }
2414
2414
  ),
2415
2415
  z(V)
2416
- ), Yi = ({ reader: n, duration: e }) => (t) => {
2416
+ ), qi = ({ reader: n, duration: e }) => (t) => {
2417
2417
  let i;
2418
2418
  const o = () => {
2419
2419
  i?.(), i = void 0;
@@ -2422,18 +2422,18 @@ const Xi = (n) => n.pagination.state$.pipe(
2422
2422
  x(() => {
2423
2423
  i || (i = n?.navigation.lock());
2424
2424
  }),
2425
- cn(e, re, {
2425
+ un(e, re, {
2426
2426
  trailing: !0,
2427
2427
  leading: !0
2428
2428
  }),
2429
2429
  x(o),
2430
2430
  de(o)
2431
2431
  );
2432
- }, qi = (n) => (e) => {
2433
- const t = n(e), i = Xi(t), o = new Wi(t), s = new _i(t), r = new Bi(
2432
+ }, Gi = (n) => (e) => {
2433
+ const t = n(e), i = Yi(t), o = new _i(t), s = new Hi(t), r = new Xi(
2434
2434
  t.navigation.scrollNavigationController,
2435
2435
  t.navigation.locker
2436
- ), a = Vi(t, o), c = r.navigation$.pipe(
2436
+ ), a = ji(t, o), c = r.navigation$.pipe(
2437
2437
  x((d) => {
2438
2438
  t.navigation.navigate(d);
2439
2439
  })
@@ -2450,7 +2450,7 @@ const Xi = (n) => n.pagination.state$.pipe(
2450
2450
  navigation: {
2451
2451
  ...t.navigation,
2452
2452
  state$: i,
2453
- throttleLock: ({ duration: d, trigger: g }) => g.pipe(Yi({ duration: d, reader: t })),
2453
+ throttleLock: ({ duration: d, trigger: g }) => g.pipe(qi({ duration: d, reader: t })),
2454
2454
  moveTo: s.moveTo.bind(s),
2455
2455
  turnBottom: o.turnBottom.bind(o),
2456
2456
  turnTop: o.turnTop.bind(o),
@@ -2498,19 +2498,19 @@ const Xi = (n) => n.pagination.state$.pipe(
2498
2498
  }
2499
2499
  return o;
2500
2500
  }, void 0);
2501
- }, Gi = (n, e) => {
2501
+ }, Zi = (n, e) => {
2502
2502
  const { href: t } = e;
2503
2503
  return Bt(t, n.nav?.toc ?? [], n);
2504
- }, Zi = (n) => {
2504
+ }, Ji = (n) => {
2505
2505
  const e = n.context.manifest, t = n.spineItemsManager.items;
2506
2506
  return e ? t.reduce(
2507
- (i, { item: o }) => (i[o.id] = Gi(e, o), i),
2507
+ (i, { item: o }) => (i[o.id] = Zi(e, o), i),
2508
2508
  {}
2509
2509
  ) : {};
2510
- }, Ji = (n) => n.spineItemsManager.items$.pipe(
2510
+ }, Ki = (n) => n.spineItemsManager.items$.pipe(
2511
2511
  ee([]),
2512
- S(() => Zi(n))
2513
- ), Ki = (n, e, t) => n + e * t, Qi = (n, e, t) => {
2512
+ S(() => Ji(n))
2513
+ ), Qi = (n, e, t) => n + e * t, eo = (n, e, t) => {
2514
2514
  const { height: i, width: o } = t.layout.layoutInfo, { top: s, left: r } = n.spine.getSpineItemSpineLayoutInfo(t);
2515
2515
  return n.settings.values.computedPageTurnDirection === "vertical" ? Math.max(
2516
2516
  0,
@@ -2525,27 +2525,27 @@ const Xi = (n) => n.pagination.state$.pipe(
2525
2525
  (e.x - r + n.viewport.absoluteViewport.width) / o
2526
2526
  )
2527
2527
  );
2528
- }, eo = (n, e, t, i, o) => o.isReady$.pipe(
2528
+ }, to = (n, e, t, i, o) => o.isReady$.pipe(
2529
2529
  U(),
2530
2530
  O(n.layoutInfo$),
2531
2531
  S(([s, r]) => {
2532
- const a = n.context, c = a.manifest?.renditionLayout === "pre-paginated", u = a.manifest?.spineItems.length || 0, l = a.manifest?.spineItems.slice(0, e).reduce((f, I) => f + (I.progressionWeight ?? 0), 0) || 0, d = n.spineItemsManager.getSpineItemIndex(o) ?? 0, g = n.context.manifest?.spineItems.length ?? 0, h = r.pages.filter((f) => f.itemIndex === d).length ?? 0, p = a.manifest?.spineItems[e]?.progressionWeight ?? // if no progressionWeight is defined we "assume" the document weight to be
2532
+ const a = n.context, c = a.manifest?.renditionLayout === "pre-paginated", u = a.manifest?.spineItems.length || 0, l = a.manifest?.spineItems.slice(0, e).reduce((f, b) => f + (b.progressionWeight ?? 0), 0) || 0, d = n.spineItemsManager.getSpineItemIndex(o) ?? 0, g = n.context.manifest?.spineItems.length ?? 0, h = r.pages.filter((f) => f.itemIndex === d).length ?? 0, p = a.manifest?.spineItems[e]?.progressionWeight ?? // if no progressionWeight is defined we "assume" the document weight to be
2533
2533
  // relative to the total number of documents
2534
2534
  (d + 1) / g;
2535
2535
  let m = (t + 1) * (p / h);
2536
2536
  !c && o.renditionLayout === "reflowable" && !s && (m = 0);
2537
2537
  let y = l + m;
2538
- return a.manifest?.renditionFlow === "scrolled-continuous" && (s ? m = Qi(
2538
+ return a.manifest?.renditionFlow === "scrolled-continuous" && (s ? m = eo(
2539
2539
  n,
2540
2540
  i,
2541
2541
  o
2542
- ) : m = 0, y = Ki(
2542
+ ) : m = 0, y = Qi(
2543
2543
  l,
2544
2544
  p,
2545
2545
  m
2546
2546
  )), e === u - 1 && t === h - 1 && y > 0.99 ? 1 : y;
2547
2547
  })
2548
- ), to = (n) => n.spine.layout$.pipe(
2548
+ ), no = (n) => n.spine.layout$.pipe(
2549
2549
  Se(10, re),
2550
2550
  O(n.pagination.state$),
2551
2551
  S(() => ({
@@ -2563,7 +2563,7 @@ const Xi = (n) => n.pagination.state$.pipe(
2563
2563
  numberOfPagesPerItems: [],
2564
2564
  numberOfTotalPages: 0
2565
2565
  })
2566
- ), no = (n, e, t, i) => {
2566
+ ), io = (n, e, t, i) => {
2567
2567
  const o = e.beginSpineItemIndex !== void 0 ? n.spineItemsManager.get(e.beginSpineItemIndex) : void 0, s = e.endSpineItemIndex !== void 0 ? n.spineItemsManager.get(e.endSpineItemIndex) : void 0;
2568
2568
  return v({
2569
2569
  ...e,
@@ -2594,7 +2594,7 @@ const Xi = (n) => n.pagination.state$.pipe(
2594
2594
  // hasPreviousChapter: (reader.spine.spineItemIndex || 0) < (manifest.readingOrder.length - 1),
2595
2595
  // numberOfSpineItems: context.manifest?.readingOrder.length,
2596
2596
  });
2597
- }, io = (n) => k([
2597
+ }, oo = (n) => k([
2598
2598
  n.pagination.state$,
2599
2599
  // Usually pagination change if layout changes (number of pages) however it is especially
2600
2600
  // useful for like webtoon where you still have one page but only the layout will give you the final size
@@ -2603,7 +2603,7 @@ const Xi = (n) => n.pagination.state$.pipe(
2603
2603
  ]).pipe(
2604
2604
  w(([e]) => {
2605
2605
  const t = e.endSpineItemIndex !== void 0 ? n.spineItemsManager.get(e.endSpineItemIndex) : void 0;
2606
- return t ? eo(
2606
+ return t ? to(
2607
2607
  n,
2608
2608
  e.endSpineItemIndex ?? 0,
2609
2609
  e.endPageIndexInSpineItem || 0,
@@ -2611,8 +2611,8 @@ const Xi = (n) => n.pagination.state$.pipe(
2611
2611
  t
2612
2612
  ) : v(0);
2613
2613
  })
2614
- ), oo = (n) => {
2615
- const e = Ji(n), t = to(n), i = new H({
2614
+ ), so = (n) => {
2615
+ const e = Ki(n), t = no(n), i = new H({
2616
2616
  ...n.pagination.state,
2617
2617
  beginChapterInfo: void 0,
2618
2618
  beginCfi: void 0,
@@ -2630,10 +2630,10 @@ const Xi = (n) => n.pagination.state$.pipe(
2630
2630
  }), o = k([
2631
2631
  n.pagination.state$,
2632
2632
  e,
2633
- io(n)
2633
+ oo(n)
2634
2634
  ]).pipe(
2635
2635
  w(
2636
- ([r, a, c]) => no(
2636
+ ([r, a, c]) => io(
2637
2637
  n,
2638
2638
  r,
2639
2639
  a,
@@ -2677,7 +2677,7 @@ const Xi = (n) => n.pagination.state$.pipe(
2677
2677
  item: t
2678
2678
  }) => {
2679
2679
  const i = "ownerDocument" in n ? n.ownerDocument : n.startContainer.ownerDocument;
2680
- return !i || !i?.documentElement || n === i ? he(t) : Nn(n) ? ze({
2680
+ return !i || !i?.documentElement || n === i ? he(t) : Vn(n) ? ze({
2681
2681
  start: {
2682
2682
  node: n.startContainer,
2683
2683
  offset: n.startOffset,
@@ -2709,14 +2709,14 @@ const Xi = (n) => n.pagination.state$.pipe(
2709
2709
  offset: o.offset,
2710
2710
  item: e.item
2711
2711
  }).trim() : he(e.item);
2712
- }, so = (n, e) => Xt({
2712
+ }, ro = (n, e) => Xt({
2713
2713
  nodeOrRange: n,
2714
2714
  item: e
2715
- }), er = (n) => n.index.toString(), ht = (n) => n[0]?.index === 6 && n.length > 1, Be = (n) => {
2715
+ }), tr = (n) => n.index.toString(), ht = (n) => n[0]?.index === 6 && n.length > 1, Be = (n) => {
2716
2716
  const e = Et(n);
2717
- return wn(e);
2718
- }, ro = (n) => Array.isArray(n) ? n[0] && ht(n[0]) ? n[0] : void 0 : n.parent[0] && ht(n.parent[0]) ? n.parent[0] : void 0, ot = (n) => {
2719
- const e = Et(n), s = ((ro(e) ?? [])[1]?.index ?? 2) / 2 - 1, r = Pn(e), a = r ? e.end.at(-1)?.at(-1)?.offset : e.at(-1)?.at(-1)?.offset;
2717
+ return Pn(e);
2718
+ }, ao = (n) => Array.isArray(n) ? n[0] && ht(n[0]) ? n[0] : void 0 : n.parent[0] && ht(n.parent[0]) ? n.parent[0] : void 0, ot = (n) => {
2719
+ const e = Et(n), s = ((ao(e) ?? [])[1]?.index ?? 2) / 2 - 1, r = xn(e), a = r ? e.end.at(-1)?.at(-1)?.offset : e.at(-1)?.at(-1)?.offset;
2720
2720
  return {
2721
2721
  isCfiRange: r,
2722
2722
  cleanedCfi: n,
@@ -2739,7 +2739,7 @@ const Xi = (n) => n.pagination.state$.pipe(
2739
2739
  const r = s.contentWindow?.document;
2740
2740
  if (r)
2741
2741
  try {
2742
- const a = xn(n, r, {
2742
+ const a = $n(n, r, {
2743
2743
  throwOnError: !0
2744
2744
  });
2745
2745
  return {
@@ -2766,7 +2766,7 @@ const Xi = (n) => n.pagination.state$.pipe(
2766
2766
  spineItem: o,
2767
2767
  node: null
2768
2768
  };
2769
- }, ao = (n, e) => {
2769
+ }, co = (n, e) => {
2770
2770
  if ("cfi" in e) {
2771
2771
  const { itemIndex: s, ...r } = n.cfi.parseCfi(e.cfi);
2772
2772
  return {
@@ -2786,7 +2786,7 @@ const Xi = (n) => n.pagination.state$.pipe(
2786
2786
  itemIndex: t.index,
2787
2787
  node: null
2788
2788
  };
2789
- }, co = (n, e) => {
2789
+ }, uo = (n, e) => {
2790
2790
  let t = n?.itemPageIndex;
2791
2791
  const { itemIndex: i, ...o } = e.cfi.parseCfi(n.cfi), s = e.spineItemsManager.get(i);
2792
2792
  return s ? Vt().pipe(
@@ -2819,7 +2819,7 @@ const Xi = (n) => n.pagination.state$.pipe(
2819
2819
  })
2820
2820
  ) : v({ ...n, itemIndex: i, ...o });
2821
2821
  };
2822
- class uo {
2822
+ class lo {
2823
2823
  constructor(e) {
2824
2824
  this.reader = e, this.locatorsByKey = /* @__PURE__ */ new Map(), this.deregisterMemoizedStream = (t) => {
2825
2825
  const i = this.locatorsByKey.get(t);
@@ -2827,7 +2827,7 @@ class uo {
2827
2827
  }, this.locate = (t, i) => {
2828
2828
  const o = {
2829
2829
  resource: t,
2830
- meta: ao(this.reader, t)
2830
+ meta: co(this.reader, t)
2831
2831
  };
2832
2832
  return ut(() => {
2833
2833
  const s = this.reader.spineItemsManager.get(
@@ -2852,7 +2852,7 @@ class uo {
2852
2852
  const d = this.reader.spine.layout$.pipe(
2853
2853
  Se(10),
2854
2854
  ee(o),
2855
- un((g) => co(g.meta, this.reader).pipe(
2855
+ ln((g) => uo(g.meta, this.reader).pipe(
2856
2856
  S((h) => ({
2857
2857
  ...g,
2858
2858
  meta: h
@@ -2871,14 +2871,14 @@ class uo {
2871
2871
  return Array.isArray(e) ? ut(
2872
2872
  () => k(
2873
2873
  e.map((i) => this.locate(i, t ?? {}))
2874
- ).pipe(ln([]))
2874
+ ).pipe(dn([]))
2875
2875
  ) : this.locate(e, t ?? {});
2876
2876
  }
2877
2877
  }
2878
- const lo = (n) => (e) => {
2879
- const t = n(e), { paginationInfo$: i, getPaginationInfo: o } = oo(t);
2878
+ const po = (n) => (e) => {
2879
+ const t = n(e), { paginationInfo$: i, getPaginationInfo: o } = so(t);
2880
2880
  i.pipe(T(t.$.destroy$)).subscribe();
2881
- const s = new uo(t);
2881
+ const s = new lo(t);
2882
2882
  return {
2883
2883
  ...t,
2884
2884
  locateResource: s.locateResource.bind(s),
@@ -2892,7 +2892,7 @@ const lo = (n) => (e) => {
2892
2892
  }
2893
2893
  }
2894
2894
  };
2895
- }, po = (n) => ({
2895
+ }, go = (n) => ({
2896
2896
  put: (s, r) => new Promise((a, c) => {
2897
2897
  const u = n.transaction(["store"], "readwrite");
2898
2898
  u.onerror = (g) => {
@@ -2949,11 +2949,11 @@ const lo = (n) => (e) => {
2949
2949
  i.onerror = (o) => {
2950
2950
  t(o);
2951
2951
  }, i.onsuccess = () => {
2952
- e(po(i.result));
2952
+ e(go(i.result));
2953
2953
  }, i.onupgradeneeded = () => {
2954
2954
  i.result.createObjectStore("store");
2955
2955
  };
2956
- }), go = (n) => {
2956
+ }), ho = (n) => {
2957
2957
  let e = Date.now().toString();
2958
2958
  const t = new R(), i = (c) => {
2959
2959
  if (typeof c == "string" || typeof c == "object") {
@@ -2973,10 +2973,10 @@ const lo = (n) => (e) => {
2973
2973
  t.next({ id: c, data: u });
2974
2974
  };
2975
2975
  t.asObservable().pipe(
2976
- vn(({ id: c, data: u }) => {
2976
+ wn(({ id: c, data: u }) => {
2977
2977
  const l = i(c);
2978
2978
  return l ? N(
2979
- dn([Oe("prose-reader"), N(u.blob())])
2979
+ pn([Oe("prose-reader"), N(u.blob())])
2980
2980
  ).pipe(
2981
2981
  _(([d, g]) => N(d.put(`${e}_${l.id}`, g))),
2982
2982
  at((d) => (D.error(d), Z))
@@ -3011,8 +3011,8 @@ const lo = (n) => (e) => {
3011
3011
  t.complete();
3012
3012
  }
3013
3013
  };
3014
- }, ho = (n) => (e) => {
3015
- const t = n(e), i = go(t.context);
3014
+ }, mo = (n) => (e) => {
3015
+ const t = n(e), i = ho(t.context);
3016
3016
  return {
3017
3017
  ...t,
3018
3018
  // $: {
@@ -3024,7 +3024,7 @@ const lo = (n) => (e) => {
3024
3024
  }
3025
3025
  // load,
3026
3026
  };
3027
- }, mo = (n, e) => {
3027
+ }, fo = (n, e) => {
3028
3028
  const t = n.node.ownerDocument?.createRange(), i = n.node.compareDocumentPosition(e.node);
3029
3029
  if (t) {
3030
3030
  try {
@@ -3044,14 +3044,14 @@ const lo = (n) => (e) => {
3044
3044
  }
3045
3045
  return t;
3046
3046
  }
3047
- }, fo = ({
3047
+ }, yo = ({
3048
3048
  selection: n,
3049
3049
  spineItem: e
3050
3050
  }) => {
3051
3051
  const { anchorNode: t, anchorOffset: i, focusNode: o, focusOffset: s } = n;
3052
3052
  if (!(!t || !o))
3053
3053
  try {
3054
- return mo(
3054
+ return fo(
3055
3055
  { node: t, offset: i },
3056
3056
  { node: o, offset: s }
3057
3057
  );
@@ -3063,7 +3063,7 @@ const lo = (n) => (e) => {
3063
3063
  return;
3064
3064
  }
3065
3065
  };
3066
- class yo extends X {
3066
+ class So extends X {
3067
3067
  constructor(e) {
3068
3068
  super();
3069
3069
  const t = e.contentDocument || e.contentWindow?.document;
@@ -3118,11 +3118,11 @@ class yo extends X {
3118
3118
  }
3119
3119
  }
3120
3120
  }
3121
- const So = (n) => n.watch("isLoaded").pipe(
3121
+ const bo = (n) => n.watch("isLoaded").pipe(
3122
3122
  w(() => {
3123
3123
  const e = n.renderer.getDocumentFrame(), t = e?.contentDocument || e?.contentWindow?.document;
3124
3124
  if (!e || !t) return ge;
3125
- const i = new yo(e);
3125
+ const i = new So(e);
3126
3126
  return P(
3127
3127
  i.selectionChange$.pipe(
3128
3128
  S((o) => {
@@ -3156,7 +3156,7 @@ const So = (n) => n.watch("isLoaded").pipe(
3156
3156
  w((l) => {
3157
3157
  const d = l.map((g) => {
3158
3158
  const h = t.spineItemsManager.getSpineItemIndex(g) ?? 0;
3159
- return So(g).pipe(
3159
+ return bo(g).pipe(
3160
3160
  S((p) => {
3161
3161
  if (p)
3162
3162
  return {
@@ -3204,7 +3204,7 @@ const So = (n) => n.watch("isLoaded").pipe(
3204
3204
  selectionOver$: c,
3205
3205
  lastSelectionOnPointerdown$: u,
3206
3206
  getSelection: () => i,
3207
- createOrderedRangeFromSelection: fo
3207
+ createOrderedRangeFromSelection: yo
3208
3208
  }
3209
3209
  };
3210
3210
  }, mt = [
@@ -3222,7 +3222,7 @@ const So = (n) => n.watch("isLoaded").pipe(
3222
3222
  backgroundColor: "#191717",
3223
3223
  foregroundColor: "#f1ebeb"
3224
3224
  }
3225
- ], bo = (n) => (e) => {
3225
+ ], vo = (n) => (e) => {
3226
3226
  const t = n(e), i = new H(
3227
3227
  e.theme ?? "bright"
3228
3228
  ), o = () => {
@@ -3287,14 +3287,14 @@ const So = (n) => n.watch("isLoaded").pipe(
3287
3287
  }
3288
3288
  }
3289
3289
  };
3290
- }, vo = (n) => (e) => ({
3290
+ }, wo = (n) => (e) => ({
3291
3291
  ...n(e),
3292
3292
  utils: {
3293
3293
  isOrIsWithinValidLink: (o) => !!(Ot(o) && (o.nodeName === "a" ? o : o.closest("a"))?.getAttribute("href"))
3294
3294
  }
3295
3295
  });
3296
3296
  navigator.userAgent.indexOf("") > -1 && navigator.userAgent.indexOf("Chrome") <= -1;
3297
- const wo = (n) => (e) => n(e), Po = "[data-prose-reader-scroll-navigator][data-prose-reader-zooming=true]{overflow:scroll}[data-prose-reader-scroll-navigator][data-prose-reader-zooming=true][data-prose-reader-zooming-direction=down]{overflow-x:auto}";
3297
+ const Po = (n) => (e) => n(e), xo = "[data-prose-reader-scroll-navigator][data-prose-reader-zooming=true]{overflow:scroll}[data-prose-reader-scroll-navigator][data-prose-reader-zooming=true][data-prose-reader-zooming-direction=down]{overflow-x:auto}";
3298
3298
  class ce extends ne {
3299
3299
  constructor(e) {
3300
3300
  super((t) => this.stateSubject.pipe(T(this._destroy$)).subscribe(t)), this._destroy$ = new R(), this.destroy$ = this._destroy$.asObservable(), this.stateSubject = new H(e);
@@ -3322,36 +3322,166 @@ class ce extends ne {
3322
3322
  this.stateSubject.complete(), this._destroy$.complete();
3323
3323
  }
3324
3324
  }
3325
- const xo = (n, e, t) => {
3325
+ const $o = (n, e, t) => {
3326
3326
  t.style.transformOrigin = "0 0";
3327
3327
  const i = `translate3d(${e.x}px, ${e.y}px, 0px)`, o = `scale(${n})`;
3328
3328
  t.style.transform = `${i} ${o}`;
3329
- }, $o = (n, e, t, i) => {
3329
+ }, To = (n, e, t, i) => {
3330
3330
  const o = e / n, s = t.clientWidth, r = t.clientHeight, a = s / 2 - i.x, c = r / 2 - i.y;
3331
3331
  return {
3332
3332
  x: i.x + a * (1 - o),
3333
3333
  y: i.y + c * (1 - o)
3334
3334
  };
3335
- }, To = (n, e, t, i, o) => {
3335
+ };
3336
+ class qt {
3337
+ constructor(e) {
3338
+ this.x = e.x, this.y = e.y;
3339
+ }
3340
+ }
3341
+ class ft extends qt {
3342
+ }
3343
+ class Fo extends qt {
3344
+ constructor() {
3345
+ super(...arguments), this.__symbol = Symbol("UnboundScrollPosition");
3346
+ }
3347
+ }
3348
+ class Lo extends ce {
3349
+ constructor(e, t, i, o, s) {
3350
+ super({
3351
+ element: void 0
3352
+ }), this.viewport = e, this.settings = t, this.hookManager = i, this.spine = o, this.context = s, this.navigateSubject = new R(), this.scrollingSubject = new H(!1), this.isScrolling$ = this.scrollingSubject.asObservable(), this.setViewportPosition = ({
3353
+ position: d
3354
+ }) => {
3355
+ const g = this.value.element;
3356
+ this.scrollingSubject.next(!0);
3357
+ const h = this.fromSpinePosition(d);
3358
+ g?.scrollTo({
3359
+ left: h.x,
3360
+ top: h.y,
3361
+ behavior: "instant"
3362
+ }), Te(1).pipe(
3363
+ x(() => {
3364
+ this.scrollingSubject.next(!1);
3365
+ }),
3366
+ T(P(this.scrollingSubject.pipe(Lt(1)), this.destroy$))
3367
+ ).subscribe(), this.hookManager.execute("onViewportOffsetAdjust", void 0, {});
3368
+ };
3369
+ const r = this.context.pipe(
3370
+ et(["rootElement"]),
3371
+ x(({ rootElement: d }) => {
3372
+ if (!d) return;
3373
+ const g = document.createElement("div");
3374
+ g.setAttribute(`data-${ri}`, ""), g.appendChild(this.viewport.value.element), d.appendChild(g), this.update({ element: g });
3375
+ })
3376
+ ), a = k([
3377
+ t.watch(["computedPageTurnMode"]),
3378
+ this.watch("element")
3379
+ ]).pipe(
3380
+ x(([{ computedPageTurnMode: d }, g]) => {
3381
+ g && (d === "scrollable" ? g.style.display = "block" : g.style.display = "contents");
3382
+ })
3383
+ ), c = this.navigateSubject.pipe(x(this.setViewportPosition));
3384
+ this.isNavigating$ = this.navigateSubject.pipe(
3385
+ ee(!1),
3386
+ w(() => P(v(!0), v(!1))),
3387
+ J(1)
3388
+ );
3389
+ const u = P(
3390
+ o.element$.pipe(
3391
+ L(le),
3392
+ w((d) => tt(d))
3393
+ ),
3394
+ o.element$.pipe(
3395
+ L(le),
3396
+ w((d) => q(d, "scroll"))
3397
+ ),
3398
+ o.spineItemsObserver.itemResize$
3399
+ ).pipe(
3400
+ w(
3401
+ () => Te(10).pipe(
3402
+ S(() => !1),
3403
+ ee(!0)
3404
+ )
3405
+ ),
3406
+ z(),
3407
+ ee(!1)
3408
+ ), l = k([
3409
+ u,
3410
+ this.isScrolling$
3411
+ ]).pipe(
3412
+ S(
3413
+ ([d, g]) => d || g
3414
+ ),
3415
+ J(1)
3416
+ );
3417
+ this.userScroll$ = this.watch("element").pipe(
3418
+ L(le),
3419
+ w(
3420
+ (d) => t.watch(["computedPageTurnMode"]).pipe(
3421
+ w(
3422
+ ({ computedPageTurnMode: g }) => g === "controlled" ? ge : q(d, "scroll").pipe(
3423
+ O(l),
3424
+ L(
3425
+ ([, h]) => !h
3426
+ ),
3427
+ S(([h]) => h)
3428
+ )
3429
+ )
3430
+ )
3431
+ ),
3432
+ E()
3433
+ ), P(r, a, c).pipe(T(this.destroy$)).subscribe();
3434
+ }
3435
+ update(e) {
3436
+ this.mergeCompare(e);
3437
+ }
3438
+ navigate(e) {
3439
+ this.navigateSubject.next(e);
3440
+ }
3441
+ fromScrollPosition(e) {
3442
+ const t = this.viewport.scaleFactor;
3443
+ return new ae({
3444
+ x: e.x / t,
3445
+ y: e.y / t
3446
+ });
3447
+ }
3448
+ fromSpinePosition(e) {
3449
+ const t = this.viewport.scaleFactor;
3450
+ return new ft({
3451
+ x: e.x * t,
3452
+ y: e.y * t
3453
+ });
3454
+ }
3455
+ get scrollPosition() {
3456
+ const e = this.value.element;
3457
+ return new ft({
3458
+ x: e?.scrollLeft ?? 0,
3459
+ y: e?.scrollTop ?? 0
3460
+ });
3461
+ }
3462
+ }
3463
+ const Mo = (n, e, t, i, o) => {
3336
3464
  const s = n.clientWidth, r = n.clientHeight, a = n.scrollLeft, c = n.scrollTop, u = a + s / 2 - i, l = c + r / 2 - o, d = t / e, g = u * d, h = l * d, p = g - s / 2 + i, m = h - r / 2 + o;
3337
- return { newScrollLeft: p, newScrollTop: m };
3338
- }, Fo = (n, e) => {
3339
- const t = e.viewport, i = e.navigation.scrollNavigationController, o = t.value.element, s = i.value.element, r = i.value.element, a = t.scaleFactor, c = o.offsetLeft, u = o.offsetTop, { newScrollLeft: l, newScrollTop: d } = To(
3340
- s ?? Rn(),
3465
+ return new Fo({
3466
+ x: p,
3467
+ y: m
3468
+ });
3469
+ }, Co = (n, e) => {
3470
+ const t = e.viewport, i = e.navigation.scrollNavigationController, o = t.value.element, s = i.value.element, r = i.value.element, a = Math.round(t.scaleFactor * 100) / 100, c = o.offsetLeft, u = o.offsetTop, l = Mo(
3471
+ s ?? An(),
3341
3472
  a,
3342
3473
  n,
3343
3474
  c,
3344
3475
  u
3345
- ), g = n < 1 ? "down" : "up";
3476
+ ), d = n < 1 ? "down" : "up";
3346
3477
  return r?.setAttribute(
3347
3478
  `data-${W}-zooming-direction`,
3348
- g
3349
- ), n < 1 ? o.style.transformOrigin = "top" : n > 1 && (o.style.transformOrigin = `${c}px ${u}px`), o.style.transform = `scale(${n})`, i.fromScrollPosition({
3350
- x: l,
3351
- y: d
3352
- });
3479
+ d
3480
+ ), n < 1 ? o.style.transformOrigin = "top" : n > 1 && (o.style.transformOrigin = `${c}px ${u}px`), o.style.transform = `scale(${n})`, i.fromScrollPosition(
3481
+ l
3482
+ );
3353
3483
  }, ve = 200;
3354
- class Lo extends ce {
3484
+ class Eo extends ce {
3355
3485
  constructor(e) {
3356
3486
  super({
3357
3487
  isZooming: !1,
@@ -3417,7 +3547,7 @@ class Lo extends ce {
3417
3547
  }
3418
3548
  updateZoom(e, t) {
3419
3549
  if (this.isControlled) {
3420
- const i = t || $o(
3550
+ const i = t || To(
3421
3551
  this.value.currentScale,
3422
3552
  e,
3423
3553
  this.viewport.element,
@@ -3434,13 +3564,13 @@ class Lo extends ce {
3434
3564
  }
3435
3565
  applyZoom(e, t) {
3436
3566
  if (this.isControlled)
3437
- xo(
3567
+ $o(
3438
3568
  e,
3439
3569
  t,
3440
3570
  this.viewport.element
3441
3571
  );
3442
3572
  else {
3443
- const i = Fo(e, this.reader);
3573
+ const i = Co(e, this.reader);
3444
3574
  this.reader.navigation.navigate({
3445
3575
  position: i
3446
3576
  });
@@ -3456,11 +3586,11 @@ class Lo extends ce {
3456
3586
  return this.reader.viewport.value;
3457
3587
  }
3458
3588
  }
3459
- const ft = `${Ut}-enhancer-zoom`, Mo = (n) => (e) => {
3460
- const t = n(e), i = new Lo(t);
3461
- Je(document, ft, Po);
3589
+ const yt = `${Ut}-enhancer-zoom`, Do = (n) => (e) => {
3590
+ const t = n(e), i = new Eo(t);
3591
+ Je(document, yt, xo);
3462
3592
  const o = () => {
3463
- Ke(document, ft), i.destroy(), t.destroy();
3593
+ Ke(document, yt), i.destroy(), t.destroy();
3464
3594
  }, s = i;
3465
3595
  return {
3466
3596
  ...t,
@@ -3476,8 +3606,8 @@ const ft = `${Ut}-enhancer-zoom`, Mo = (n) => (e) => {
3476
3606
  }
3477
3607
  }
3478
3608
  };
3479
- }, qt = (n) => n?.renditionLayout === "pre-paginated" || n?.spineItems.every((e) => e.renditionLayout === "pre-paginated");
3480
- class Co {
3609
+ }, Gt = (n) => n?.renditionLayout === "pre-paginated" || n?.spineItems.every((e) => e.renditionLayout === "pre-paginated");
3610
+ class Ro {
3481
3611
  constructor() {
3482
3612
  this.navigationSubject = new st(1), this.viewportStateSubject = new H("free"), this.paginationSubject = new st(), this.navigationIsLockedSubject = new H(!1), this.pagination$ = this.paginationSubject.asObservable(), this.navigationUnlocked$ = this.navigationIsLockedSubject.pipe(
3483
3613
  z(),
@@ -3489,11 +3619,11 @@ class Co {
3489
3619
  ), this.navigation$ = this.navigationSubject.asObservable();
3490
3620
  }
3491
3621
  }
3492
- class Eo extends ce {
3622
+ class Ao extends ce {
3493
3623
  constructor() {
3494
3624
  super({
3495
3625
  assumedRenditionLayout: "reflowable"
3496
- }), this.bridgeEvent = new Co(), this.manifest$ = this.pipe(
3626
+ }), this.bridgeEvent = new Ro(), this.manifest$ = this.pipe(
3497
3627
  K((e) => e.manifest),
3498
3628
  se(le),
3499
3629
  pe()
@@ -3504,7 +3634,7 @@ class Eo extends ce {
3504
3634
  ...t,
3505
3635
  ...e,
3506
3636
  ...e.manifest && {
3507
- isFullyPrePaginated: qt(i),
3637
+ isFullyPrePaginated: Gt(i),
3508
3638
  assumedRenditionLayout: i?.renditionLayout ?? "reflowable"
3509
3639
  }
3510
3640
  };
@@ -3517,7 +3647,7 @@ class Eo extends ce {
3517
3647
  return this.manifest?.readingDirection;
3518
3648
  }
3519
3649
  }
3520
- class Do extends ce {
3650
+ class Oo extends ce {
3521
3651
  constructor(e, t) {
3522
3652
  super({
3523
3653
  supportedPageTurnAnimation: ["fade", "none", "slide"],
@@ -3552,7 +3682,7 @@ class Do extends ce {
3552
3682
  ).subscribe(this.next.bind(this));
3553
3683
  }
3554
3684
  }
3555
- class Ro {
3685
+ class No {
3556
3686
  constructor() {
3557
3687
  this._hooks = [], this._hookExecutions = [];
3558
3688
  }
@@ -3614,17 +3744,17 @@ class Ro {
3614
3744
  return k(s);
3615
3745
  }
3616
3746
  }
3617
- const Ao = "[data-prose-reader-scroll-navigator]{height:100%;width:100%;position:relative;overflow-y:scroll;overflow-x:hidden}[data-prose-reader-viewport]{background-color:#fff;position:relative;height:100%;width:100%}", Oo = (n) => ({
3747
+ const Vo = "[data-prose-reader-scroll-navigator]{height:100%;width:100%;position:relative;overflow-y:scroll;overflow-x:hidden}[data-prose-reader-viewport]{background-color:#fff;position:relative;height:100%;width:100%}", jo = (n) => ({
3618
3748
  x: -n.x,
3619
3749
  y: -n.y
3620
- }), No = (n) => n instanceof DOMMatrix ? new M({
3750
+ }), ko = (n) => n instanceof DOMMatrix ? new M({
3621
3751
  x: -n.e,
3622
3752
  y: -n.f
3623
3753
  }) : new M({
3624
3754
  x: -n.x,
3625
3755
  y: -n.y
3626
- }), Vo = "navigation/ViewportNavigator", yt = D.namespace(Vo);
3627
- class jo extends X {
3756
+ }), Uo = "navigation/ViewportNavigator", St = D.namespace(Uo);
3757
+ class zo extends X {
3628
3758
  constructor(e, t, i, o, s) {
3629
3759
  super(), this.settings = e, this.hookManager = t, this.context = i, this.spine = o, this.viewport = s, this.navigateSubject = new R(), this.element$ = new H(
3630
3760
  document.createElement("div")
@@ -3653,13 +3783,13 @@ class jo extends X {
3653
3783
  );
3654
3784
  this.layout$ = c.pipe(
3655
3785
  x(() => {
3656
- yt.info("layout", e.values);
3786
+ St.info("layout", e.values);
3657
3787
  }),
3658
3788
  E()
3659
3789
  );
3660
3790
  const u = this.navigateSubject.pipe(
3661
3791
  x((l) => {
3662
- yt.info("Navigation requested", l);
3792
+ St.info("Navigation requested", l);
3663
3793
  })
3664
3794
  );
3665
3795
  this.isNavigating$ = u.pipe(
@@ -3736,7 +3866,7 @@ class jo extends X {
3736
3866
  * for remark about flicker / fonts smoothing
3737
3867
  */
3738
3868
  setViewportPosition(e) {
3739
- const t = this.element$.getValue(), i = Oo(e);
3869
+ const t = this.element$.getValue(), i = jo(e);
3740
3870
  t.style.transform = `translate(${i.x}px, ${i.y}px)`, this.hookManager.execute("onViewportOffsetAdjust", void 0, {});
3741
3871
  }
3742
3872
  navigate(e) {
@@ -3751,132 +3881,10 @@ class jo extends X {
3751
3881
  if (!i || i === "none")
3752
3882
  return new M({ x: 0, y: 0 });
3753
3883
  const o = new DOMMatrix(i);
3754
- return No(o);
3884
+ return ko(o);
3755
3885
  }
3756
3886
  }
3757
- class ko {
3758
- constructor(e) {
3759
- this.x = e.x, this.y = e.y;
3760
- }
3761
- }
3762
- class St extends ko {
3763
- }
3764
- class Uo extends ce {
3765
- constructor(e, t, i, o, s) {
3766
- super({
3767
- element: void 0
3768
- }), this.viewport = e, this.settings = t, this.hookManager = i, this.spine = o, this.context = s, this.navigateSubject = new R(), this.scrollingSubject = new H(!1), this.isScrolling$ = this.scrollingSubject.asObservable(), this.setViewportPosition = ({
3769
- position: d
3770
- }) => {
3771
- const g = this.value.element;
3772
- this.scrollingSubject.next(!0);
3773
- const h = this.fromSpinePosition(d);
3774
- g?.scrollTo({
3775
- left: h.x,
3776
- top: h.y,
3777
- behavior: "instant"
3778
- }), Te(1).pipe(
3779
- x(() => {
3780
- this.scrollingSubject.next(!1);
3781
- }),
3782
- T(P(this.scrollingSubject.pipe(Lt(1)), this.destroy$))
3783
- ).subscribe(), this.hookManager.execute("onViewportOffsetAdjust", void 0, {});
3784
- };
3785
- const r = this.context.pipe(
3786
- et(["rootElement"]),
3787
- x(({ rootElement: d }) => {
3788
- if (!d) return;
3789
- const g = document.createElement("div");
3790
- g.setAttribute(`data-${si}`, ""), g.appendChild(this.viewport.value.element), d.appendChild(g), this.update({ element: g });
3791
- })
3792
- ), a = k([
3793
- t.watch(["computedPageTurnMode"]),
3794
- this.watch("element")
3795
- ]).pipe(
3796
- x(([{ computedPageTurnMode: d }, g]) => {
3797
- g && (d === "scrollable" ? g.style.display = "block" : g.style.display = "contents");
3798
- })
3799
- ), c = this.navigateSubject.pipe(x(this.setViewportPosition));
3800
- this.isNavigating$ = this.navigateSubject.pipe(
3801
- ee(!1),
3802
- w(() => P(v(!0), v(!1))),
3803
- J(1)
3804
- );
3805
- const u = P(
3806
- o.element$.pipe(
3807
- L(le),
3808
- w((d) => tt(d))
3809
- ),
3810
- o.element$.pipe(
3811
- L(le),
3812
- w((d) => q(d, "scroll"))
3813
- ),
3814
- o.spineItemsObserver.itemResize$
3815
- ).pipe(
3816
- w(
3817
- () => Te(10).pipe(
3818
- S(() => !1),
3819
- ee(!0)
3820
- )
3821
- ),
3822
- z(),
3823
- ee(!1)
3824
- ), l = k([
3825
- u,
3826
- this.isScrolling$
3827
- ]).pipe(
3828
- S(
3829
- ([d, g]) => d || g
3830
- ),
3831
- J(1)
3832
- );
3833
- this.userScroll$ = this.watch("element").pipe(
3834
- L(le),
3835
- w(
3836
- (d) => t.watch(["computedPageTurnMode"]).pipe(
3837
- w(
3838
- ({ computedPageTurnMode: g }) => g === "controlled" ? ge : q(d, "scroll").pipe(
3839
- O(l),
3840
- L(
3841
- ([, h]) => !h
3842
- ),
3843
- S(([h]) => h)
3844
- )
3845
- )
3846
- )
3847
- ),
3848
- E()
3849
- ), P(r, a, c).pipe(T(this.destroy$)).subscribe();
3850
- }
3851
- update(e) {
3852
- this.mergeCompare(e);
3853
- }
3854
- navigate(e) {
3855
- this.navigateSubject.next(e);
3856
- }
3857
- fromScrollPosition(e) {
3858
- const t = this.viewport.scaleFactor;
3859
- return new ae({
3860
- x: e.x / t,
3861
- y: e.y / t
3862
- });
3863
- }
3864
- fromSpinePosition(e) {
3865
- const t = this.viewport.scaleFactor;
3866
- return new St({
3867
- x: e.x * t,
3868
- y: e.y * t
3869
- });
3870
- }
3871
- get scrollPosition() {
3872
- const e = this.value.element;
3873
- return new St({
3874
- x: e?.scrollLeft ?? 0,
3875
- y: e?.scrollTop ?? 0
3876
- });
3877
- }
3878
- }
3879
- const zo = () => (n) => n.pipe(
3887
+ const Wo = () => (n) => n.pipe(
3880
3888
  S(({ navigation: e, pagination: t, ...i }) => ({
3881
3889
  navigation: {
3882
3890
  ...e,
@@ -3884,7 +3892,7 @@ const zo = () => (n) => n.pipe(
3884
3892
  },
3885
3893
  ...i
3886
3894
  }))
3887
- ), Wo = (n, e, t) => n.bridgeEvent.pagination$.pipe(
3895
+ ), _o = (n, e, t) => n.bridgeEvent.pagination$.pipe(
3888
3896
  O(e),
3889
3897
  L(
3890
3898
  ([i, o]) => i.navigationId === o.id
@@ -3901,7 +3909,7 @@ const zo = () => (n) => n.pipe(
3901
3909
  navigation: o
3902
3910
  }))
3903
3911
  )),
3904
- zo(),
3912
+ Wo(),
3905
3913
  z(
3906
3914
  (i, o) => i.navigation.paginationBeginCfi === o.navigation.paginationBeginCfi
3907
3915
  ),
@@ -3913,7 +3921,7 @@ const zo = () => (n) => n.pipe(
3913
3921
  }
3914
3922
  })
3915
3923
  )
3916
- ), _o = ({ navigationResolver: n }) => (e) => e.pipe(
3924
+ ), Ho = ({ navigationResolver: n }) => (e) => e.pipe(
3917
3925
  S(([t, i]) => {
3918
3926
  const o = {
3919
3927
  type: "api",
@@ -3935,6 +3943,11 @@ const zo = () => (n) => n.pipe(
3935
3943
  *
3936
3944
  * For now having things centered (negative x) on zoom out in scroll mode can be achieved with transform origin for example.
3937
3945
  * This "limitation" is here at the moment to avoid unexpected behaviors.
3946
+ *
3947
+ * @note
3948
+ * Has a bug where scaling from < 1 to 1 was creating positive x offset. This is "expected" since on scroll mode the viewport
3949
+ * is at the offset 0 at scale 0.2 for eg: then when calculating new scroll delta, we get positive x offset. Anyway, to prevent
3950
+ * out of bounds position this should make sure we always stay within an item.
3938
3951
  */
3939
3952
  position: t.position ? n.fromOutOfBoundsSpinePosition(
3940
3953
  t.position
@@ -3945,7 +3958,7 @@ const zo = () => (n) => n.pipe(
3945
3958
  navigation: o
3946
3959
  };
3947
3960
  })
3948
- ), Ho = ({ navigationResolver: n }) => (e) => e.pipe(
3961
+ ), Bo = ({ navigationResolver: n }) => (e) => e.pipe(
3949
3962
  S((t) => {
3950
3963
  if (t.navigation.cfi) {
3951
3964
  const i = n.getNavigationForCfi(
@@ -3962,16 +3975,16 @@ const zo = () => (n) => n.pipe(
3962
3975
  }
3963
3976
  return t;
3964
3977
  })
3965
- ), Bo = ({
3978
+ ), Xo = ({
3966
3979
  navigation: n,
3967
3980
  previousNavigation: e,
3968
3981
  settings: t
3969
- }) => n.directionFromLastNavigation ? n.directionFromLastNavigation : n.url !== void 0 || n.cfi !== void 0 ? "anchor" : e.spineItem === void 0 || n.spineItem || !n.position ? "forward" : t.values.computedPageTurnDirection === "vertical" ? n.position.y > e.position.y || n.position.y === e.position.y && e.directionFromLastNavigation !== "backward" ? "forward" : "backward" : Math.abs(n.position.x) > Math.abs(e.position.x) || n.position.x === e.position.x && e.directionFromLastNavigation !== "backward" ? "forward" : "backward", Xo = ({
3982
+ }) => n.directionFromLastNavigation ? n.directionFromLastNavigation : n.url !== void 0 || n.cfi !== void 0 ? "anchor" : e.spineItem === void 0 || n.spineItem || !n.position ? "forward" : t.values.computedPageTurnDirection === "vertical" ? n.position.y > e.position.y || n.position.y === e.position.y && e.directionFromLastNavigation !== "backward" ? "forward" : "backward" : Math.abs(n.position.x) > Math.abs(e.position.x) || n.position.x === e.position.x && e.directionFromLastNavigation !== "backward" ? "forward" : "backward", Yo = ({
3970
3983
  context: n,
3971
3984
  settings: e
3972
3985
  }) => (t) => t.pipe(
3973
3986
  S(({ navigation: i, previousNavigation: o }) => {
3974
- const s = Bo({
3987
+ const s = Xo({
3975
3988
  navigation: i,
3976
3989
  previousNavigation: o,
3977
3990
  settings: e
@@ -3985,7 +3998,7 @@ const zo = () => (n) => n.pipe(
3985
3998
  direction: s
3986
3999
  };
3987
4000
  })
3988
- ), Yo = ({
4001
+ ), qo = ({
3989
4002
  spineItemsManager: n,
3990
4003
  navigationResolver: e,
3991
4004
  settings: t
@@ -4028,7 +4041,7 @@ const zo = () => (n) => n.pipe(
4028
4041
  ...s
4029
4042
  };
4030
4043
  })
4031
- ), It = ({
4044
+ ), bt = ({
4032
4045
  settings: n,
4033
4046
  spineItemsManager: e,
4034
4047
  navigationResolver: t,
@@ -4058,13 +4071,13 @@ const zo = () => (n) => n.pipe(
4058
4071
  restrictToScreen: !1
4059
4072
  }) ?? {}, m = (l === "forward" || l === "anchor" ? p : h) ?? h, y = e.get(m);
4060
4073
  if (!y) return;
4061
- const { endPageIndex: f, beginPageIndex: I } = i.getVisiblePagesFromViewportPosition({
4074
+ const { endPageIndex: f, beginPageIndex: b } = i.getVisiblePagesFromViewportPosition({
4062
4075
  position: a,
4063
4076
  spineItem: y,
4064
4077
  threshold: d,
4065
4078
  restrictToScreen: !1
4066
- }) ?? {}, b = (l === "forward" || l === "anchor" ? f : I) ?? 0, F = t.getNavigationForSpineItemPage({
4067
- pageIndex: b,
4079
+ }) ?? {}, I = (l === "forward" || l === "anchor" ? f : b) ?? 0, F = t.getNavigationForSpineItemPage({
4080
+ pageIndex: I,
4068
4081
  spineItemId: y
4069
4082
  }), $ = i.getVisibleSpineItemsFromPosition({
4070
4083
  position: F,
@@ -4087,7 +4100,7 @@ const zo = () => (n) => n.pipe(
4087
4100
  };
4088
4101
  })
4089
4102
  );
4090
- }, bt = ({ spine: n }) => (e) => e.pipe(
4103
+ }, It = ({ spine: n }) => (e) => e.pipe(
4091
4104
  w(({ navigation: t, ...i }) => {
4092
4105
  const o = n.getSpineItemSpineLayoutInfo(
4093
4106
  t.spineItem
@@ -4154,7 +4167,7 @@ const zo = () => (n) => n.pipe(
4154
4167
  ...a
4155
4168
  }))
4156
4169
  );
4157
- }, qo = ({ navigationResolver: n }) => (e) => e.pipe(
4170
+ }, Go = ({ navigationResolver: n }) => (e) => e.pipe(
4158
4171
  S((t) => {
4159
4172
  if (t.navigation.url) {
4160
4173
  const i = n.getNavigationForUrl(
@@ -4173,7 +4186,7 @@ const zo = () => (n) => n.pipe(
4173
4186
  return t;
4174
4187
  })
4175
4188
  );
4176
- class Gt {
4189
+ class Zt {
4177
4190
  constructor() {
4178
4191
  this.isLockedSubject = new H(0), this.isLocked$ = this.isLockedSubject.pipe(
4179
4192
  S((e) => !!e),
@@ -4187,7 +4200,7 @@ class Gt {
4187
4200
  };
4188
4201
  }
4189
4202
  }
4190
- const Go = ({
4203
+ const Zo = ({
4191
4204
  spineLocator: n,
4192
4205
  navigation: e,
4193
4206
  navigationResolver: t,
@@ -4244,7 +4257,7 @@ const Go = ({
4244
4257
  return c ? t.getNavigationForPosition(e.position) : t.getNavigationForSpineIndexOrId(s);
4245
4258
  })
4246
4259
  ) : v(new M({ x: 0, y: 0 }));
4247
- }, Zo = ({
4260
+ }, Jo = ({
4248
4261
  navigation: n,
4249
4262
  spineLocator: e,
4250
4263
  spineItemsManager: t,
@@ -4313,7 +4326,7 @@ const Go = ({
4313
4326
  }
4314
4327
  }
4315
4328
  return n.position;
4316
- }, Jo = ({
4329
+ }, Ko = ({
4317
4330
  navigation: n,
4318
4331
  spineItemsManager: e,
4319
4332
  settings: t,
@@ -4321,7 +4334,7 @@ const Go = ({
4321
4334
  navigationResolver: o,
4322
4335
  spine: s
4323
4336
  }) => t.values.computedPageTurnMode === "scrollable" ? v(
4324
- Zo({
4337
+ Jo({
4325
4338
  navigation: n,
4326
4339
  spineLocator: i,
4327
4340
  navigationResolver: o,
@@ -4329,7 +4342,7 @@ const Go = ({
4329
4342
  spineItemsManager: e,
4330
4343
  spine: s
4331
4344
  })
4332
- ) : Go({
4345
+ ) : Zo({
4333
4346
  navigation: n,
4334
4347
  spineLocator: i,
4335
4348
  navigationResolver: o,
@@ -4341,7 +4354,7 @@ const Go = ({
4341
4354
  context: t,
4342
4355
  spine: i
4343
4356
  }) => (o) => o.pipe(
4344
- w((s) => Jo({
4357
+ w((s) => Ko({
4345
4358
  spineLocator: i.locator,
4346
4359
  navigation: s.navigation,
4347
4360
  navigationResolver: e,
@@ -4358,8 +4371,8 @@ const Go = ({
4358
4371
  }
4359
4372
  }))
4360
4373
  ))
4361
- ), Ko = "navigation/InternalNavigator", Qo = D.namespace(Ko);
4362
- class es extends X {
4374
+ ), Qo = "navigation/InternalNavigator", es = D.namespace(Qo);
4375
+ class ts extends X {
4363
4376
  constructor(e, t, i, o, s, r, a, c) {
4364
4377
  super(), this.settings = e, this.context = t, this.userNavigation$ = i, this.controlledNavigationController = o, this.scrollNavigationController = s, this.navigationResolver = r, this.spine = a, this.isUserLocked$ = c, this.navigationSubject = new H({
4365
4378
  animation: !1,
@@ -4371,36 +4384,36 @@ class es extends X {
4371
4384
  type: "api",
4372
4385
  id: Symbol()
4373
4386
  }), this.navigated$ = this.navigationSubject.pipe(Lt(1)), this.navigation$ = this.navigationSubject.pipe(
4374
- S(({ position: f, id: I }) => ({
4387
+ S(({ position: f, id: b }) => ({
4375
4388
  position: f,
4376
- id: I
4389
+ id: b
4377
4390
  })),
4378
4391
  z(
4379
- ({ position: f, ...I }, { position: b, ...F }) => V(I, F) && V(f, b)
4392
+ ({ position: f, ...b }, { position: I, ...F }) => V(b, F) && V(f, I)
4380
4393
  ),
4381
4394
  J(1)
4382
- ), this.locker = new Gt();
4395
+ ), this.locker = new Zt();
4383
4396
  const u = i.pipe(
4384
4397
  O(this.navigationSubject),
4385
- _o({
4398
+ Ho({
4386
4399
  navigationResolver: r
4387
4400
  }),
4388
4401
  /**
4389
4402
  * Url lookup is heavier so we start with it to fill
4390
4403
  * as much information as needed to reduce later lookup
4391
4404
  */
4392
- qo({
4405
+ Go({
4393
4406
  navigationResolver: r
4394
4407
  }),
4395
4408
  /**
4396
4409
  * Cfi lookup is heavier so we start with it to fill
4397
4410
  * as much information as needed to reduce later lookup
4398
4411
  */
4399
- Ho({
4412
+ Bo({
4400
4413
  navigationResolver: r
4401
4414
  }),
4402
- Xo({ context: t, settings: e }),
4403
- It({
4415
+ Yo({ context: t, settings: e }),
4416
+ bt({
4404
4417
  navigationResolver: r,
4405
4418
  settings: e,
4406
4419
  spineItemsManager: a.spineItemsManager,
@@ -4412,20 +4425,20 @@ class es extends X {
4412
4425
  spineItemsManager: a.spineItemsManager,
4413
4426
  spineLocator: a.locator
4414
4427
  }),
4415
- bt({
4428
+ It({
4416
4429
  spine: a
4417
4430
  })
4418
4431
  ).pipe(
4419
- Yo({
4432
+ qo({
4420
4433
  navigationResolver: r,
4421
4434
  spineItemsManager: a.spineItemsManager,
4422
4435
  settings: e
4423
4436
  }),
4424
4437
  O(c),
4425
- w(([f, I]) => {
4426
- const b = f.navigation.cfi || f.navigation.url || e.values.computedPageTurnMode === "scrollable" || I;
4438
+ w(([f, b]) => {
4439
+ const I = f.navigation.cfi || f.navigation.url || e.values.computedPageTurnMode === "scrollable" || b;
4427
4440
  return v(f).pipe(
4428
- b ? Pe : vt({
4441
+ I ? Pe : vt({
4429
4442
  navigationResolver: r,
4430
4443
  settings: e,
4431
4444
  spine: a,
@@ -4445,9 +4458,9 @@ class es extends X {
4445
4458
  O(c),
4446
4459
  L(([, f]) => f),
4447
4460
  w(([f]) => {
4448
- const I = this.locker.lock();
4461
+ const b = this.locker.lock();
4449
4462
  return c.pipe(
4450
- L((b) => !b),
4463
+ L((I) => !I),
4451
4464
  U(),
4452
4465
  S(
4453
4466
  () => ({
@@ -4456,7 +4469,7 @@ class es extends X {
4456
4469
  })
4457
4470
  ),
4458
4471
  de(() => {
4459
- I();
4472
+ b();
4460
4473
  }),
4461
4474
  T(u)
4462
4475
  );
@@ -4500,7 +4513,7 @@ class es extends X {
4500
4513
  spine: a
4501
4514
  }),
4502
4515
  S((f) => {
4503
- const I = {
4516
+ const b = {
4504
4517
  ...f.navigation,
4505
4518
  meta: {
4506
4519
  triggeredBy: "restoration"
@@ -4508,7 +4521,7 @@ class es extends X {
4508
4521
  };
4509
4522
  return {
4510
4523
  ...f,
4511
- navigation: I
4524
+ navigation: b
4512
4525
  };
4513
4526
  }),
4514
4527
  /**
@@ -4516,13 +4529,13 @@ class es extends X {
4516
4529
  * eg: after the reader load and the user has never navigated
4517
4530
  * yet.
4518
4531
  */
4519
- It({
4532
+ bt({
4520
4533
  navigationResolver: r,
4521
4534
  settings: e,
4522
4535
  spineItemsManager: a.spineItemsManager,
4523
4536
  spineLocator: a.locator
4524
4537
  }),
4525
- bt({
4538
+ It({
4526
4539
  spine: a
4527
4540
  }),
4528
4541
  Ne({
@@ -4533,7 +4546,7 @@ class es extends X {
4533
4546
  }),
4534
4547
  S(({ navigation: f }) => f),
4535
4548
  E()
4536
- ), h = Wo(
4549
+ ), h = _o(
4537
4550
  t,
4538
4551
  this.navigationSubject,
4539
4552
  a
@@ -4542,26 +4555,26 @@ class es extends X {
4542
4555
  u,
4543
4556
  h
4544
4557
  ), m = (f) => f.pipe(
4545
- x(([I, b]) => {
4546
- Qo.info(
4547
- `navigation updated from ${I.meta.triggeredBy} of type ${I.type}`,
4558
+ x(([b, I]) => {
4559
+ es.info(
4560
+ `navigation updated from ${b.meta.triggeredBy} of type ${b.type}`,
4548
4561
  {
4549
- previousNavigation: b,
4550
- currentNavigation: I
4562
+ previousNavigation: I,
4563
+ currentNavigation: b
4551
4564
  }
4552
- ), this.navigationSubject.next(I);
4565
+ ), this.navigationSubject.next(b);
4553
4566
  })
4554
4567
  ), y = (f) => f.pipe(
4555
- x(([I, b]) => {
4556
- const F = I.type === "scroll", $ = I.meta.triggeredBy === "pagination", A = I.meta.triggeredBy === "restoration", Y = V(
4557
- b.position,
4558
- I.position
4568
+ x(([b, I]) => {
4569
+ const F = b.type === "scroll", $ = b.meta.triggeredBy === "pagination", A = b.meta.triggeredBy === "restoration", Y = V(
4570
+ I.position,
4571
+ b.position
4559
4572
  );
4560
4573
  if (F && !A || $ || Y)
4561
4574
  return;
4562
4575
  const B = {
4563
- position: I.position,
4564
- animation: I.animation
4576
+ position: b.position,
4577
+ animation: b.animation
4565
4578
  };
4566
4579
  e.values.computedPageTurnMode === "scrollable" ? this.scrollNavigationController.navigate(B) : this.controlledNavigationController.navigate({
4567
4580
  ...B,
@@ -4601,14 +4614,14 @@ const Fe = (n, e, t) => {
4601
4614
  }, wt = (n, e, t) => {
4602
4615
  const i = [...Array(t)].map((o, s) => s * e);
4603
4616
  return n <= 0 || t === 0 ? 0 : n >= t * e ? t - 1 : i.findIndex((o) => n < o + e) ?? 0;
4604
- }, ts = ({
4617
+ }, ns = ({
4605
4618
  itemWidth: n,
4606
4619
  itemHeight: e,
4607
4620
  spineItemPosition: t
4608
4621
  }) => new C({
4609
4622
  x: Math.min(n, Math.max(0, t.x)),
4610
4623
  y: Math.min(e, Math.max(0, t.y))
4611
- }), Zt = ({
4624
+ }), Jt = ({
4612
4625
  itemHeight: n,
4613
4626
  itemWidth: e,
4614
4627
  isUsingVerticalWriting: t,
@@ -4627,11 +4640,11 @@ const Fe = (n, e, t) => {
4627
4640
  pageTurnMode: a,
4628
4641
  isRTL: c
4629
4642
  }) => {
4630
- const l = ts({
4643
+ const l = ns({
4631
4644
  spineItemPosition: t,
4632
4645
  itemHeight: e,
4633
4646
  itemWidth: n
4634
- }).x, d = Zt({
4647
+ }).x, d = Jt({
4635
4648
  isUsingVerticalWriting: i,
4636
4649
  itemHeight: e,
4637
4650
  itemWidth: n,
@@ -4644,7 +4657,7 @@ const Fe = (n, e, t) => {
4644
4657
  return wt(t.y, s, d);
4645
4658
  const g = wt(l, o, d);
4646
4659
  return c ? d - 1 - g : g;
4647
- }, ns = ({
4660
+ }, is = ({
4648
4661
  pageIndex: n,
4649
4662
  itemLayout: e,
4650
4663
  context: t,
@@ -4674,14 +4687,14 @@ const Fe = (n, e, t) => {
4674
4687
  x: s,
4675
4688
  y: 0
4676
4689
  });
4677
- }, Jt = ({
4690
+ }, Kt = ({
4678
4691
  context: n,
4679
4692
  settings: e,
4680
4693
  viewport: t
4681
4694
  }) => {
4682
4695
  const i = (a, c, u) => {
4683
4696
  let l;
4684
- a?.nodeName === "img" || a?.textContent === "" && a.nodeType === Node.ELEMENT_NODE ? l = a.getBoundingClientRect().x : a && (l = (a ? Cn(a, c) : void 0)?.getBoundingClientRect().x || l);
4697
+ a?.nodeName === "img" || a?.textContent === "" && a.nodeType === Node.ELEMENT_NODE ? l = a.getBoundingClientRect().x : a && (l = (a ? En(a, c) : void 0)?.getBoundingClientRect().x || l);
4685
4698
  const d = u.layout.layoutInfo?.width || 0, g = t.pageSize.width;
4686
4699
  if (l !== void 0) {
4687
4700
  const h = Ve(
@@ -4697,7 +4710,7 @@ const Fe = (n, e, t) => {
4697
4710
  getSpineItemPositionFromPageIndex: ({
4698
4711
  pageIndex: a,
4699
4712
  spineItem: c
4700
- }) => ns({
4713
+ }) => is({
4701
4714
  context: n,
4702
4715
  isUsingVerticalWriting: !!c.isUsingVerticalWriting(),
4703
4716
  itemLayout: c.layout.layoutInfo,
@@ -4768,12 +4781,12 @@ const Fe = (n, e, t) => {
4768
4781
  });
4769
4782
  }
4770
4783
  };
4771
- }, is = ({
4784
+ }, os = ({
4772
4785
  context: n,
4773
4786
  settings: e,
4774
4787
  viewport: t
4775
4788
  }) => {
4776
- const i = Jt({
4789
+ const i = Kt({
4777
4790
  context: n,
4778
4791
  settings: e,
4779
4792
  viewport: t
@@ -4797,7 +4810,7 @@ const Fe = (n, e, t) => {
4797
4810
  ) || new C({ x: 0, y: 0 })
4798
4811
  };
4799
4812
  };
4800
- function Kt({
4813
+ function Qt({
4801
4814
  position: n,
4802
4815
  isRTL: e,
4803
4816
  spineItemsManager: t,
@@ -4808,7 +4821,7 @@ function Kt({
4808
4821
  t.items.length - 1
4809
4822
  ), r = i.getSpineItemSpineLayoutInfo(
4810
4823
  s || 0
4811
- ), a = r.bottom, c = Math.max(0, n.y), u = Math.min(c, a);
4824
+ ), a = r.bottom - 1, c = Math.max(0, n.y), u = Math.min(c, a);
4812
4825
  if (e) {
4813
4826
  const h = Math.min(o, n.x), p = Math.max(h, r.left);
4814
4827
  return new M({
@@ -4816,7 +4829,7 @@ function Kt({
4816
4829
  y: u
4817
4830
  });
4818
4831
  }
4819
- const l = r.right, d = Math.max(0, n.x), g = Math.min(d, l);
4832
+ const l = r.right - 1, d = Math.max(0, n.x), g = Math.min(d, l);
4820
4833
  return new M({
4821
4834
  x: g,
4822
4835
  y: u
@@ -4830,7 +4843,7 @@ const xt = ({
4830
4843
  visibleAreaRectWidth: o,
4831
4844
  spine: s
4832
4845
  }) => {
4833
- const r = Kt({
4846
+ const r = Qt({
4834
4847
  position: n,
4835
4848
  isRTL: e,
4836
4849
  spineItemsManager: i,
@@ -4883,7 +4896,7 @@ const xt = ({
4883
4896
  });
4884
4897
  }
4885
4898
  return new M({ x: 0, y: 0 });
4886
- }, os = ({
4899
+ }, ss = ({
4887
4900
  pageIndex: n,
4888
4901
  spineItemsManager: e,
4889
4902
  spineItemId: t,
@@ -4913,28 +4926,28 @@ const xt = ({
4913
4926
  pageSizeWidth: s.pageSize.width,
4914
4927
  visibleAreaRectWidth: s.absoluteViewport.width
4915
4928
  });
4916
- }, ss = (n, e) => {
4929
+ }, rs = (n, e) => {
4917
4930
  if (e && e instanceof HTMLIFrameElement)
4918
4931
  return n.startsWith("#") ? e.contentDocument?.getElementById(
4919
4932
  n.replace("#", "")
4920
4933
  ) : e.contentDocument?.querySelector(n);
4921
- }, rs = ({
4934
+ }, as = ({
4922
4935
  anchor: n,
4923
4936
  spineItem: e,
4924
4937
  spine: t
4925
4938
  }) => {
4926
- const i = ss(
4939
+ const i = rs(
4927
4940
  n,
4928
4941
  e.renderer.getDocumentFrame()
4929
4942
  );
4930
4943
  return i ? t.spineItemLocator.getSpineItemPositionFromNode(i, 0, e)?.x ?? 0 : 0;
4931
- }, as = ({
4944
+ }, cs = ({
4932
4945
  anchor: n,
4933
4946
  spineItem: e,
4934
4947
  spineLocator: t,
4935
4948
  spine: i
4936
4949
  }) => {
4937
- const o = rs({
4950
+ const o = as({
4938
4951
  anchor: n,
4939
4952
  spineItem: e,
4940
4953
  spine: i
@@ -4943,7 +4956,7 @@ const xt = ({
4943
4956
  spineItemPosition: new C({ x: o, y: 0 }),
4944
4957
  spineItem: e
4945
4958
  });
4946
- }, cs = ({
4959
+ }, us = ({
4947
4960
  anchor: n,
4948
4961
  spineItem: e,
4949
4962
  spineLocator: t,
@@ -4951,7 +4964,7 @@ const xt = ({
4951
4964
  pageSizeWidth: o,
4952
4965
  visibleAreaRectWidth: s
4953
4966
  }) => {
4954
- const r = as({
4967
+ const r = cs({
4955
4968
  anchor: n,
4956
4969
  spineItem: e,
4957
4970
  spineLocator: t,
@@ -4962,7 +4975,7 @@ const xt = ({
4962
4975
  pageSizeWidth: o,
4963
4976
  visibleAreaRectWidth: s
4964
4977
  });
4965
- }, us = ({
4978
+ }, ls = ({
4966
4979
  spine: n,
4967
4980
  spineItemsManager: e,
4968
4981
  spineLocator: t,
@@ -4978,7 +4991,7 @@ const xt = ({
4978
4991
  if (u) {
4979
4992
  const l = e.get(u.id);
4980
4993
  if (l) {
4981
- const d = cs({
4994
+ const d = us({
4982
4995
  anchor: a.hash,
4983
4996
  spineItem: l,
4984
4997
  spine: n,
@@ -5001,7 +5014,7 @@ const xt = ({
5001
5014
  console.error(a);
5002
5015
  return;
5003
5016
  }
5004
- }, ls = ({
5017
+ }, ds = ({
5005
5018
  spineItem: n,
5006
5019
  spineItemPosition: e,
5007
5020
  spineLocator: t,
@@ -5020,7 +5033,7 @@ const xt = ({
5020
5033
  pageSizeWidth: o.pageSize.width,
5021
5034
  visibleAreaRectWidth: o.absoluteViewport.width
5022
5035
  });
5023
- }, ds = "spineNavigator", ps = ({
5036
+ }, ps = "spineNavigator", gs = ({
5024
5037
  context: n,
5025
5038
  spineItemsManager: e,
5026
5039
  locator: t,
@@ -5028,13 +5041,13 @@ const xt = ({
5028
5041
  spine: o,
5029
5042
  viewport: s
5030
5043
  }) => {
5031
- const r = is({
5044
+ const r = os({
5032
5045
  context: n,
5033
5046
  settings: i,
5034
5047
  viewport: s
5035
5048
  });
5036
5049
  return {
5037
- getNavigationForUrl: (h) => us({
5050
+ getNavigationForUrl: (h) => ls({
5038
5051
  context: n,
5039
5052
  spineItemsManager: e,
5040
5053
  spineLocator: t,
@@ -5043,14 +5056,14 @@ const xt = ({
5043
5056
  visibleAreaRectWidth: s.absoluteViewport.width,
5044
5057
  spine: o
5045
5058
  }),
5046
- getNavigationForSpineItemPage: (h) => os({
5059
+ getNavigationForSpineItemPage: (h) => ss({
5047
5060
  ...h,
5048
5061
  spineItemsManager: e,
5049
5062
  spineItemNavigationResolver: r,
5050
5063
  spineLocator: t,
5051
5064
  viewport: s
5052
5065
  }),
5053
- getNavigationFromSpineItemPosition: (h) => ls({
5066
+ getNavigationFromSpineItemPosition: (h) => ds({
5054
5067
  ...h,
5055
5068
  spineItemLocator: t.spineItemLocator,
5056
5069
  spineLocator: t,
@@ -5062,15 +5075,15 @@ const xt = ({
5062
5075
  spineItemsManager: e
5063
5076
  });
5064
5077
  if (!p) {
5065
- D.warn(ds, `unable to detect item id from cfi ${h}`);
5078
+ D.warn(ps, `unable to detect item id from cfi ${h}`);
5066
5079
  return;
5067
5080
  }
5068
- const f = m ? r.getNavigationFromNode(p, m, y) : new C({ x: 0, y: 0 }), I = t.getSpinePositionFromSpineItemPosition({
5081
+ const f = m ? r.getNavigationFromNode(p, m, y) : new C({ x: 0, y: 0 }), b = t.getSpinePositionFromSpineItemPosition({
5069
5082
  spineItemPosition: f,
5070
5083
  spineItem: p
5071
5084
  });
5072
5085
  return Q({
5073
- position: I,
5086
+ position: b,
5074
5087
  pageSizeWidth: s.pageSize.width,
5075
5088
  visibleAreaRectWidth: s.absoluteViewport.width
5076
5089
  });
@@ -5105,7 +5118,7 @@ const xt = ({
5105
5118
  viewport: s
5106
5119
  }),
5107
5120
  getMostPredominantNavigationForPosition: (h) => {
5108
- const p = i.values.computedPageTurnDirection, m = 0.5, y = p === "horizontal" ? h.x + s.absoluteViewport.width * m : 0, f = p === "horizontal" ? 0 : h.y + s.absoluteViewport.height * m, I = xt({
5121
+ const p = i.values.computedPageTurnDirection, m = 0.5, y = p === "horizontal" ? h.x + s.absoluteViewport.width * m : 0, f = p === "horizontal" ? 0 : h.y + s.absoluteViewport.height * m, b = xt({
5109
5122
  position: new M({
5110
5123
  x: y,
5111
5124
  y: f
@@ -5119,7 +5132,7 @@ const xt = ({
5119
5132
  return Ye({
5120
5133
  spineItemNavigationResolver: r,
5121
5134
  spineLocator: t,
5122
- viewportPosition: I,
5135
+ viewportPosition: b,
5123
5136
  viewport: s
5124
5137
  });
5125
5138
  },
@@ -5131,7 +5144,7 @@ const xt = ({
5131
5144
  spineItemsManager: e,
5132
5145
  spine: o
5133
5146
  }),
5134
- fromOutOfBoundsSpinePosition: (h) => Kt({
5147
+ fromOutOfBoundsSpinePosition: (h) => Qt({
5135
5148
  position: h,
5136
5149
  isRTL: n.isRTL(),
5137
5150
  spineItemsManager: e,
@@ -5147,7 +5160,7 @@ const xt = ({
5147
5160
  }),
5148
5161
  spineItemNavigator: r
5149
5162
  };
5150
- }, gs = ({
5163
+ }, hs = ({
5151
5164
  spineItemsManager: n,
5152
5165
  context: e,
5153
5166
  hookManager: t,
@@ -5155,26 +5168,26 @@ const xt = ({
5155
5168
  settings: o,
5156
5169
  viewport: s
5157
5170
  }) => {
5158
- const r = new R(), a = r.asObservable(), c = new Gt(), u = ps({
5171
+ const r = new R(), a = r.asObservable(), c = new Zt(), u = gs({
5159
5172
  context: e,
5160
5173
  settings: o,
5161
5174
  spineItemsManager: n,
5162
5175
  locator: i.locator,
5163
5176
  spine: i,
5164
5177
  viewport: s
5165
- }), l = new jo(
5178
+ }), l = new zo(
5166
5179
  o,
5167
5180
  t,
5168
5181
  e,
5169
5182
  i,
5170
5183
  s
5171
- ), d = new Uo(
5184
+ ), d = new Lo(
5172
5185
  s,
5173
5186
  o,
5174
5187
  t,
5175
5188
  i,
5176
5189
  e
5177
- ), g = new es(
5190
+ ), g = new ts(
5178
5191
  o,
5179
5192
  e,
5180
5193
  a,
@@ -5213,7 +5226,7 @@ const xt = ({
5213
5226
  navigation$: g.navigation$
5214
5227
  };
5215
5228
  };
5216
- class hs extends ce {
5229
+ class ms extends ce {
5217
5230
  constructor(e, t) {
5218
5231
  super({
5219
5232
  beginPageIndexInSpineItem: void 0,
@@ -5231,7 +5244,7 @@ class hs extends ce {
5231
5244
  this.mergeCompare(e);
5232
5245
  }
5233
5246
  }
5234
- class ms extends X {
5247
+ class fs extends X {
5235
5248
  constructor(e, t, i, o, s) {
5236
5249
  super(), this.context = e, this.pagination = t, this.spineItemsManager = i, this.spine = o, this.spineItemLocator = s;
5237
5250
  const r = P(
@@ -5259,21 +5272,21 @@ class ms extends X {
5259
5272
  threshold: { type: "percentage", value: 0.5 }
5260
5273
  }) ?? {}, p = this.spineItemsManager.get(g), m = this.spineItemsManager.get(h);
5261
5274
  if (!p || !m) return;
5262
- const y = d.beginCfi, f = d.endCfi, { beginPageIndex: I = 0 } = c({
5275
+ const y = d.beginCfi, f = d.endCfi, { beginPageIndex: b = 0 } = c({
5263
5276
  spineItem: p,
5264
5277
  position: l
5265
- }) ?? {}, { endPageIndex: b = 0 } = c({
5278
+ }) ?? {}, { endPageIndex: I = 0 } = c({
5266
5279
  spineItem: m,
5267
5280
  position: l
5268
5281
  }) ?? {}, F = y === void 0 || Be(y) || d.beginSpineItemIndex !== g, $ = d.endSpineItemIndex !== h || f === void 0 || Be(f), A = F ? he(p.item) : y, Y = $ ? he(m.item) : f, B = p.numberOfPages, ie = m.numberOfPages;
5269
5282
  this.pagination.update({
5270
5283
  beginCfi: A,
5271
5284
  beginNumberOfPagesInSpineItem: B,
5272
- beginPageIndexInSpineItem: I,
5285
+ beginPageIndexInSpineItem: b,
5273
5286
  beginSpineItemIndex: g,
5274
5287
  endCfi: Y,
5275
5288
  endNumberOfPagesInSpineItem: ie,
5276
- endPageIndexInSpineItem: b,
5289
+ endPageIndexInSpineItem: I,
5277
5290
  endSpineItemIndex: h,
5278
5291
  navigationId: u.id
5279
5292
  });
@@ -5309,11 +5322,11 @@ class ms extends X {
5309
5322
  P(r, a).pipe(T(this.destroy$)).subscribe();
5310
5323
  }
5311
5324
  }
5312
- const fs = ({
5325
+ const ys = ({
5313
5326
  manifest: n,
5314
5327
  spreadMode: e
5315
5328
  }) => n?.renditionFlow === "scrolled-continuous" ? !1 : e;
5316
- class ys extends X {
5329
+ class Ss extends X {
5317
5330
  constructor(e) {
5318
5331
  super();
5319
5332
  const t = {
@@ -5358,7 +5371,7 @@ class ys extends X {
5358
5371
  super.destroy(), this.outputSettingsUpdateSubject.complete();
5359
5372
  }
5360
5373
  }
5361
- class Ss extends ys {
5374
+ class bs extends Ss {
5362
5375
  constructor(e, t) {
5363
5376
  super(e), this.context = t, t.watch(["manifest", "hasVerticalWriting"]).pipe(
5364
5377
  x(() => this.update(this.values)),
@@ -5371,7 +5384,7 @@ class Ss extends ys {
5371
5384
  computedPageTurnAnimation: e.pageTurnAnimation,
5372
5385
  computedPageTurnMode: e.pageTurnMode,
5373
5386
  computedPageTurnAnimationDuration: 0,
5374
- computedSpreadMode: fs({
5387
+ computedSpreadMode: ys({
5375
5388
  spreadMode: e.spreadMode,
5376
5389
  manifest: t
5377
5390
  })
@@ -5416,7 +5429,7 @@ class Is extends fe {
5416
5429
  getDocumentFrame() {
5417
5430
  }
5418
5431
  }
5419
- class bs extends X {
5432
+ class vs extends X {
5420
5433
  constructor(e, t, i, o, s, r, a) {
5421
5434
  super(), this.item = e, this.containerElement = t, this.context = i, this.hookManager = o, this.renderer = s, this.settings = r, this.viewport = a, this.layoutTriggerSubject = new R(), this.lastLayout = null, this.applyDimsAfterLayout = ({
5422
5435
  blankPagePosition: c,
@@ -5426,27 +5439,27 @@ class bs extends X {
5426
5439
  const g = V(
5427
5440
  this.lastLayout?.pageSize,
5428
5441
  this.viewport.pageSize
5429
- ) ? this.lastLayout : void 0, { width: h, height: p } = g ?? {}, { width: m = h, height: y = p } = d ?? {}, { width: f, height: I } = this.viewport.pageSize, b = this.validateDimension(
5442
+ ) ? this.lastLayout : void 0, { width: h, height: p } = g ?? {}, { width: m = h, height: y = p } = d ?? {}, { width: f, height: b } = this.viewport.pageSize, I = this.validateDimension(
5430
5443
  m ?? f,
5431
5444
  f,
5432
5445
  u
5433
- ), F = this.settings.values.computedPageTurnMode === "scrollable" ? y ?? I : this.validateDimension(
5434
- y ?? I,
5435
- I,
5436
- I
5446
+ ), F = this.settings.values.computedPageTurnMode === "scrollable" ? y ?? b : this.validateDimension(
5447
+ y ?? b,
5448
+ b,
5449
+ b
5437
5450
  );
5438
5451
  return this.lastLayout = {
5439
- width: b,
5452
+ width: I,
5440
5453
  height: F,
5441
5454
  pageSize: this.viewport.pageSize
5442
- }, this.containerElement.style.width = `${b}px`, this.containerElement.style.height = `${F}px`, this.hookManager.execute("item.onAfterLayout", void 0, {
5455
+ }, this.containerElement.style.width = `${I}px`, this.containerElement.style.height = `${F}px`, this.hookManager.execute("item.onAfterLayout", void 0, {
5443
5456
  blankPagePosition: c,
5444
5457
  item: this.item,
5445
5458
  minimumWidth: u
5446
- }), { width: b, height: F };
5459
+ }), { width: I, height: F };
5447
5460
  })
5448
5461
  ), this.layout = (c) => {
5449
- const u = Xn(this.layout$.pipe(U()));
5462
+ const u = Yn(this.layout$.pipe(U()));
5450
5463
  return this.layoutTriggerSubject.next(c), u();
5451
5464
  }, this.adjustPositionOfElement = ({
5452
5465
  right: c,
@@ -5501,7 +5514,7 @@ class bs extends X {
5501
5514
  };
5502
5515
  }
5503
5516
  }
5504
- class Qt extends ce {
5517
+ class en extends ce {
5505
5518
  constructor(e, t, i, o, s, r, a) {
5506
5519
  super({
5507
5520
  isLoaded: !1,
@@ -5517,7 +5530,7 @@ class Qt extends ce {
5517
5530
  });
5518
5531
  }, this.destroy = () => {
5519
5532
  super.destroy(), this.containerElement.remove(), this.renderer.destroy();
5520
- }, this.isUsingVerticalWriting = () => !!this.renderer.writingMode?.startsWith("vertical"), this.containerElement = vs(
5533
+ }, this.isUsingVerticalWriting = () => !!this.renderer.writingMode?.startsWith("vertical"), this.containerElement = ws(
5521
5534
  t,
5522
5535
  e,
5523
5536
  s
@@ -5533,7 +5546,7 @@ class Qt extends ce {
5533
5546
  resourcesHandler: this.resourcesHandler,
5534
5547
  viewport: this.viewport
5535
5548
  };
5536
- this.renderer = c ? c(u) : new Is(u), this.layout = new bs(
5549
+ this.renderer = c ? c(u) : new Is(u), this.layout = new vs(
5537
5550
  e,
5538
5551
  this.containerElement,
5539
5552
  i,
@@ -5608,7 +5621,7 @@ class Qt extends ce {
5608
5621
  return this.renderer.renditionLayout;
5609
5622
  }
5610
5623
  get numberOfPages() {
5611
- return Zt({
5624
+ return Jt({
5612
5625
  isUsingVerticalWriting: !!this.isUsingVerticalWriting(),
5613
5626
  itemHeight: this.layout.layoutInfo.height,
5614
5627
  itemWidth: this.layout.layoutInfo.width,
@@ -5619,19 +5632,19 @@ class Qt extends ce {
5619
5632
  });
5620
5633
  }
5621
5634
  }
5622
- const vs = (n, e, t) => {
5635
+ const ws = (n, e, t) => {
5623
5636
  const i = n.ownerDocument.createElement("div");
5624
5637
  return i.classList.add("spineItem"), i.classList.add(`spineItem-${e.renditionLayout ?? "reflowable"}`), i.style.cssText = `
5625
5638
  position: absolute;
5626
5639
  overflow: hidden;
5627
5640
  `, i.dataset.isReady = "false", t.execute("item.onBeforeContainerCreated", void 0, { element: i }), i;
5628
5641
  };
5629
- class ws extends X {
5642
+ class Ps extends X {
5630
5643
  constructor(e, t, i, o, s) {
5631
5644
  super(), this.context = e, this.spineItemsManager = t, this.spineLocator = i, this.settings = o, this.spineLayout = s, this.forcedOpenSubject = new H([]);
5632
5645
  const r = this.forcedOpenSubject.pipe(
5633
5646
  S((u) => [...new Set(u.flat())].sort()),
5634
- z(fn),
5647
+ z(yn),
5635
5648
  J({ bufferSize: 1, refCount: !0 })
5636
5649
  );
5637
5650
  P(
@@ -5653,10 +5666,10 @@ class ws extends X {
5653
5666
  useAbsoluteViewport: !1
5654
5667
  }) || {}, p = d === 1 / 0 ? 0 : g - d, m = d === 1 / 0 ? t.items.length - 1 : h + d, y = Array.from(
5655
5668
  { length: m - p + 1 },
5656
- (I, b) => p + b
5669
+ (b, I) => p + I
5657
5670
  ), f = [...l, ...y];
5658
- t.items.forEach((I, b) => {
5659
- f.includes(b) ? I.load() : I.unload();
5671
+ t.items.forEach((b, I) => {
5672
+ f.includes(I) ? b.load() : b.unload();
5660
5673
  });
5661
5674
  })
5662
5675
  ).pipe(T(this.destroy$)).subscribe();
@@ -5677,7 +5690,7 @@ class ws extends X {
5677
5690
  super.destroy(), this.forcedOpenSubject.complete();
5678
5691
  }
5679
5692
  }
5680
- const en = (n, e, t) => {
5693
+ const tn = (n, e, t) => {
5681
5694
  const i = (t.width - e.width) / 2, o = (t.height - e.height) / 2;
5682
5695
  return new ae({
5683
5696
  x: n.x - i,
@@ -5702,17 +5715,17 @@ class ye extends DOMRect {
5702
5715
  return new ye(i.x, i.y, i.width, i.height);
5703
5716
  }
5704
5717
  }
5705
- class Ps {
5718
+ class xs {
5706
5719
  constructor({ width: e, height: t }) {
5707
5720
  this.__symbol = Symbol("AbsoluteViewport"), this.width = e, this.height = t;
5708
5721
  }
5709
5722
  }
5710
- class xs {
5723
+ class $s {
5711
5724
  constructor({ width: e, height: t }) {
5712
5725
  this.__symbol = Symbol("RelativeViewport"), this.width = e, this.height = t;
5713
5726
  }
5714
5727
  }
5715
- const $s = ({
5728
+ const Ts = ({
5716
5729
  pageIndex: n,
5717
5730
  spineItemOrId: e,
5718
5731
  spineItemsManager: t
@@ -5734,7 +5747,7 @@ const $s = ({
5734
5747
  { currentAbsolutePage: 0, found: !1 }
5735
5748
  );
5736
5749
  return s;
5737
- }, Ts = ({
5750
+ }, Fs = ({
5738
5751
  itemHeight: n,
5739
5752
  itemWidth: e,
5740
5753
  visibleWidthOfItem: t,
@@ -5743,7 +5756,7 @@ const $s = ({
5743
5756
  }) => {
5744
5757
  const s = t / e, r = i / n;
5745
5758
  return o.type === "percentage" ? s >= o.value && r >= o.value : t >= o.value && i >= o.value;
5746
- }, Fs = ({
5759
+ }, Ls = ({
5747
5760
  visibleWidthOfItem: n,
5748
5761
  visibleHeightOfItem: e,
5749
5762
  threshold: t,
@@ -5751,7 +5764,7 @@ const $s = ({
5751
5764
  }) => {
5752
5765
  const o = n / i.width, s = e / i.height;
5753
5766
  return t.type === "percentage" ? s >= t.value && o >= t.value : e >= t.value && n >= t.value;
5754
- }, tn = ({
5767
+ }, nn = ({
5755
5768
  itemPosition: {
5756
5769
  bottom: n,
5757
5770
  left: e,
@@ -5775,14 +5788,14 @@ const $s = ({
5775
5788
  Math.min(n, g) - Math.max(i, d)
5776
5789
  );
5777
5790
  if (h <= 0 || p <= 0) return { visible: !1 };
5778
- const y = Fs({
5791
+ const y = Ls({
5779
5792
  threshold: r,
5780
5793
  visibleHeightOfItem: p,
5781
5794
  visibleWidthOfItem: h,
5782
5795
  viewportPosition: a
5783
5796
  });
5784
5797
  return c ? { visible: y } : {
5785
- visible: Ts({
5798
+ visible: Fs({
5786
5799
  itemHeight: s,
5787
5800
  itemWidth: o,
5788
5801
  threshold: r,
@@ -5806,7 +5819,7 @@ const $s = ({
5806
5819
  }) => new M({
5807
5820
  x: e + n.x,
5808
5821
  y: t + n.y
5809
- }), Ls = ({
5822
+ }), Ms = ({
5810
5823
  position: n,
5811
5824
  threshold: e,
5812
5825
  restrictToScreen: t,
@@ -5821,20 +5834,20 @@ const $s = ({
5821
5834
  spineLayout: o
5822
5835
  }) || i.get(0), c = i.items.reduce(
5823
5836
  (h, p) => {
5824
- const m = o.getSpineItemSpineLayoutInfo(p), y = s ? r.absoluteViewport : r.relativeViewport, f = en(
5837
+ const m = o.getSpineItemSpineLayoutInfo(p), y = s ? r.absoluteViewport : r.relativeViewport, f = tn(
5825
5838
  n,
5826
5839
  r.absoluteViewport,
5827
5840
  y
5828
- ), I = ye.from(
5841
+ ), b = ye.from(
5829
5842
  f,
5830
5843
  y
5831
- ), { visible: b } = tn({
5844
+ ), { visible: I } = nn({
5832
5845
  itemPosition: m,
5833
5846
  threshold: e,
5834
- viewportPosition: I,
5847
+ viewportPosition: b,
5835
5848
  restrictToScreen: t
5836
5849
  });
5837
- return b ? [...h, p] : h;
5850
+ return I ? [...h, p] : h;
5838
5851
  },
5839
5852
  []
5840
5853
  ), u = c[0] ?? a, l = c[c.length - 1] ?? u;
@@ -5844,7 +5857,7 @@ const $s = ({
5844
5857
  beginIndex: d ?? 0,
5845
5858
  endIndex: g ?? 0
5846
5859
  };
5847
- }, Ms = ({
5860
+ }, Cs = ({
5848
5861
  spineItemsManager: n,
5849
5862
  context: e,
5850
5863
  spineItemLocator: t,
@@ -5887,44 +5900,44 @@ const $s = ({
5887
5900
  threshold: m,
5888
5901
  spineItem: y,
5889
5902
  restrictToScreen: f,
5890
- useAbsoluteViewport: I = !0,
5891
- viewport: b
5903
+ useAbsoluteViewport: b = !0,
5904
+ viewport: I
5892
5905
  }) => {
5893
- const F = y.numberOfPages, A = Array.from(Array(F)).map((ie, Ie) => {
5906
+ const F = y.numberOfPages, A = Array.from(Array(F)).map((ie, be) => {
5894
5907
  const De = t.getSpineItemPositionFromPageIndex({
5895
- pageIndex: Ie,
5908
+ pageIndex: be,
5896
5909
  spineItem: y
5897
5910
  }), ue = je({
5898
5911
  spineItemPosition: De,
5899
5912
  itemLayout: o.getSpineItemSpineLayoutInfo(y)
5900
5913
  });
5901
5914
  return {
5902
- index: Ie,
5915
+ index: be,
5903
5916
  absolutePosition: {
5904
- width: b.pageSize.width,
5905
- height: b.pageSize.height,
5917
+ width: I.pageSize.width,
5918
+ height: I.pageSize.height,
5906
5919
  left: ue.x,
5907
5920
  top: ue.y,
5908
- bottom: ue.y + b.pageSize.height,
5909
- right: ue.x + b.pageSize.width
5921
+ bottom: ue.y + I.pageSize.height,
5922
+ right: ue.x + I.pageSize.width
5910
5923
  }
5911
5924
  };
5912
5925
  }).reduce(
5913
- (ie, { absolutePosition: Ie, index: De }) => {
5914
- const ue = I ? b.absoluteViewport : b.relativeViewport, nn = en(
5926
+ (ie, { absolutePosition: be, index: De }) => {
5927
+ const ue = b ? I.absoluteViewport : I.relativeViewport, on = tn(
5915
5928
  p,
5916
- b.absoluteViewport,
5929
+ I.absoluteViewport,
5917
5930
  ue
5918
- ), on = ye.from(
5919
- nn,
5931
+ ), sn = ye.from(
5932
+ on,
5920
5933
  ue
5921
- ), { visible: sn } = tn({
5922
- viewportPosition: on,
5934
+ ), { visible: rn } = nn({
5935
+ viewportPosition: sn,
5923
5936
  restrictToScreen: f,
5924
5937
  threshold: m,
5925
- itemPosition: Ie
5938
+ itemPosition: be
5926
5939
  });
5927
- return sn ? [...ie, De] : ie;
5940
+ return rn ? [...ie, De] : ie;
5928
5941
  },
5929
5942
  []
5930
5943
  ), Y = A[0], B = A[A.length - 1] ?? Y;
@@ -5948,7 +5961,7 @@ const $s = ({
5948
5961
  /**
5949
5962
  * @deprecated use Pages
5950
5963
  */
5951
- _getAbsolutePageIndexFromPageIndex: (p) => $s({
5964
+ _getAbsolutePageIndexFromPageIndex: (p) => Ts({
5952
5965
  ...p,
5953
5966
  spineItemsManager: n
5954
5967
  }),
@@ -5968,7 +5981,7 @@ const $s = ({
5968
5981
  itemHeight: m.layout.layoutInfo.height,
5969
5982
  position: y,
5970
5983
  isUsingVerticalWriting: !!m.isUsingVerticalWriting()
5971
- }), I = t.getSpineItemPagePositionFromSpineItemPosition(
5984
+ }), b = t.getSpineItemPagePositionFromSpineItemPosition(
5972
5985
  y,
5973
5986
  f,
5974
5987
  m
@@ -5976,7 +5989,7 @@ const $s = ({
5976
5989
  return {
5977
5990
  spineItem: m,
5978
5991
  spineItemPageIndex: f,
5979
- spineItemPagePosition: I,
5992
+ spineItemPagePosition: b,
5980
5993
  pageSize: s.value.pageSize
5981
5994
  };
5982
5995
  },
@@ -5989,7 +6002,7 @@ const $s = ({
5989
6002
  }),
5990
6003
  getSpineItemFromIframe: c,
5991
6004
  getSpineItemPageIndexFromNode: u,
5992
- getVisibleSpineItemsFromPosition: (p) => Ls({
6005
+ getVisibleSpineItemsFromPosition: (p) => Ms({
5993
6006
  spineItemsManager: n,
5994
6007
  spineLayout: o,
5995
6008
  viewport: s,
@@ -6000,8 +6013,8 @@ const $s = ({
6000
6013
  viewport: s
6001
6014
  }),
6002
6015
  isPositionWithinSpineItem: (p, m) => {
6003
- const { bottom: y, left: f, right: I, top: b } = o.getSpineItemSpineLayoutInfo(m);
6004
- return p.x >= f && p.x <= I && p.y <= y && p.y >= b;
6016
+ const { bottom: y, left: f, right: b, top: I } = o.getSpineItemSpineLayoutInfo(m);
6017
+ return p.x >= f && p.x <= b && p.y <= y && p.y >= I;
6005
6018
  },
6006
6019
  spineItemLocator: t,
6007
6020
  getSafeSpineItemPositionFromUnsafeSpineItemPosition: (p, m) => {
@@ -6012,10 +6025,10 @@ const $s = ({
6012
6025
  });
6013
6026
  }
6014
6027
  };
6015
- }, Cs = D.namespace("spine"), Es = ({
6028
+ }, Es = D.namespace("spine"), Ds = ({
6016
6029
  position: n,
6017
6030
  pageSize: e
6018
- }) => new bi({
6031
+ }) => new vi({
6019
6032
  ...n,
6020
6033
  left: n.x,
6021
6034
  top: n.y,
@@ -6024,7 +6037,7 @@ const $s = ({
6024
6037
  bottom: n.y + e.height,
6025
6038
  right: n.x + e.width
6026
6039
  });
6027
- class Ds extends ce {
6040
+ class Rs extends ce {
6028
6041
  constructor(e, t, i, o, s, r) {
6029
6042
  super({ pages: [] }), this.spineLayout = e, this.spineItemsManager = t, this.spineItemLocator = i, this.context = o, this.locator = s, this.viewport = r, this.fromSpineItemPageIndex = (a, c) => this.value.pages.find(
6030
6043
  (u) => u.itemIndex === a.index && u.pageIndex === c
@@ -6037,14 +6050,14 @@ class Ds extends ce {
6037
6050
  const f = i.getSpineItemPositionFromPageIndex({
6038
6051
  spineItem: d,
6039
6052
  pageIndex: y
6040
- }), I = s.getSpinePositionFromSpineItemPosition({
6053
+ }), b = s.getSpinePositionFromSpineItemPosition({
6041
6054
  spineItem: d,
6042
6055
  spineItemPosition: f
6043
6056
  });
6044
6057
  return {
6045
- absoluteLayout: Es({
6058
+ absoluteLayout: Ds({
6046
6059
  pageSize: a,
6047
- position: I
6060
+ position: b
6048
6061
  }),
6049
6062
  layout: new Ii({
6050
6063
  left: f.x,
@@ -6073,7 +6086,7 @@ class Ds extends ce {
6073
6086
  const p = l.spineItem.renderer?.getDocumentFrame();
6074
6087
  let m;
6075
6088
  p && p?.contentWindow?.document && // very important because it is being used by next functions
6076
- p.contentWindow.document.body !== null && (m = Ln(
6089
+ p.contentWindow.document.body !== null && (m = Mn(
6077
6090
  p.contentWindow.document,
6078
6091
  l.layout
6079
6092
  )), h.next({ ...g, firstVisibleNode: m });
@@ -6081,12 +6094,12 @@ class Ds extends ce {
6081
6094
  })
6082
6095
  );
6083
6096
  }),
6084
- S((a) => (Cs.info("Pages layout", a), { pages: a })),
6097
+ S((a) => (Es.info("Pages layout", a), { pages: a })),
6085
6098
  E()
6086
6099
  ), this.layout$.pipe(T(this.destroy$)).subscribe(this.next.bind(this));
6087
6100
  }
6088
6101
  }
6089
- class Rs extends X {
6102
+ class As extends X {
6090
6103
  constructor(e, t) {
6091
6104
  super(), this.spineItemsManager = e, this.spineLocator = t, this.itemIsReady$ = this.spineItemsManager.items$.pipe(
6092
6105
  w((i) => {
@@ -6109,7 +6122,7 @@ class Rs extends X {
6109
6122
  );
6110
6123
  }
6111
6124
  }
6112
- const As = ({
6125
+ const Os = ({
6113
6126
  horizontalOffset: n,
6114
6127
  verticalOffset: e,
6115
6128
  context: t,
@@ -6134,23 +6147,23 @@ const As = ({
6134
6147
  }).pipe(
6135
6148
  S(({ width: p, height: m }) => {
6136
6149
  if (s.values.computedPageTurnDirection === "vertical") {
6137
- const I = d ? e : e - c.absoluteViewport.height, b = d ? 0 : n;
6150
+ const b = d ? e : e - c.absoluteViewport.height, I = d ? 0 : n;
6138
6151
  t.isRTL() ? a.layout.adjustPositionOfElement({
6139
- top: I,
6140
- left: b
6152
+ top: b,
6153
+ left: I
6141
6154
  }) : a.layout.adjustPositionOfElement({
6142
- top: I,
6143
- left: b
6155
+ top: b,
6156
+ left: I
6144
6157
  });
6145
- const F = p + b, $ = m + I, A = new _e({
6146
- left: b,
6158
+ const F = p + I, $ = m + b, A = new _e({
6159
+ left: I,
6147
6160
  right: F,
6148
- top: I,
6161
+ top: b,
6149
6162
  bottom: $,
6150
6163
  height: m,
6151
6164
  width: p,
6152
- x: b,
6153
- y: I
6165
+ x: I,
6166
+ y: b
6154
6167
  });
6155
6168
  return {
6156
6169
  horizontalOffset: F,
@@ -6179,7 +6192,7 @@ const As = ({
6179
6192
  })
6180
6193
  );
6181
6194
  };
6182
- class Os extends X {
6195
+ class Ns extends X {
6183
6196
  constructor(e, t, i, o) {
6184
6197
  super(), this.spineItemsManager = e, this.context = t, this.settings = i, this.viewport = o, this.layoutSubject = new R(), this.spineItemsRelativeLayouts = [], e.items$.pipe(
6185
6198
  x(() => {
@@ -6223,12 +6236,12 @@ class Os extends X {
6223
6236
  ),
6224
6237
  Ue(() => {
6225
6238
  s.next(!0);
6226
- const r = this.context.manifest, a = qt(r) ?? !1;
6239
+ const r = this.context.manifest, a = Gt(r) ?? !1;
6227
6240
  return N(this.spineItemsManager.items).pipe(
6228
- pn(
6241
+ gn(
6229
6242
  (u, l, d) => u.pipe(
6230
6243
  rt(
6231
- ({ horizontalOffset: g, verticalOffset: h }) => As({
6244
+ ({ horizontalOffset: g, verticalOffset: h }) => Os({
6232
6245
  context: this.context,
6233
6246
  horizontalOffset: g,
6234
6247
  index: d,
@@ -6286,32 +6299,32 @@ class Os extends X {
6286
6299
  super.destroy(), this.layoutSubject.complete();
6287
6300
  }
6288
6301
  }
6289
- class Ns extends X {
6302
+ class Vs extends X {
6290
6303
  constructor(e, t, i, o, s, r, a) {
6291
6304
  super(), this.context = e, this.pagination = t, this.spineItemsManager = i, this.spineItemLocator = o, this.settings = s, this.hookManager = r, this.viewport = a, this.elementSubject = new H(
6292
6305
  void 0
6293
- ), this.element$ = this.elementSubject.asObservable(), this.spineLayout = new Os(
6306
+ ), this.element$ = this.elementSubject.asObservable(), this.spineLayout = new Ns(
6294
6307
  i,
6295
6308
  e,
6296
6309
  s,
6297
6310
  a
6298
- ), this.locator = Ms({
6311
+ ), this.locator = Cs({
6299
6312
  context: e,
6300
6313
  spineItemsManager: i,
6301
6314
  spineItemLocator: o,
6302
6315
  settings: s,
6303
6316
  spineLayout: this.spineLayout,
6304
6317
  viewport: a
6305
- }), this.spineItemsLoader = new ws(
6318
+ }), this.spineItemsLoader = new Ps(
6306
6319
  this.context,
6307
6320
  i,
6308
6321
  this.locator,
6309
6322
  s,
6310
6323
  this.spineLayout
6311
- ), this.spineItemsObserver = new Rs(
6324
+ ), this.spineItemsObserver = new As(
6312
6325
  i,
6313
6326
  this.locator
6314
- ), this.pages = new Ds(
6327
+ ), this.pages = new Rs(
6315
6328
  this.spineLayout,
6316
6329
  this.spineItemsManager,
6317
6330
  this.spineItemLocator,
@@ -6336,7 +6349,7 @@ class Ns extends X {
6336
6349
  if (!d) return;
6337
6350
  this.spineItemsManager.destroyItems();
6338
6351
  const g = l.spineItems.map(
6339
- (h, p) => new Qt(
6352
+ (h, p) => new en(
6340
6353
  h,
6341
6354
  d,
6342
6355
  this.context,
@@ -6367,7 +6380,7 @@ class Ns extends X {
6367
6380
  super.destroy(), this.pages.destroy(), this.spineItemsLoader.destroy(), this.elementSubject.getValue()?.remove(), this.elementSubject.complete();
6368
6381
  }
6369
6382
  }
6370
- class Vs extends X {
6383
+ class js extends X {
6371
6384
  constructor(e, t) {
6372
6385
  super(), this.context = e, this.settings = t, this.orderedSpineItemsSubject = new H([]), this.items$ = this.orderedSpineItemsSubject.asObservable();
6373
6386
  }
@@ -6381,7 +6394,7 @@ class Vs extends X {
6381
6394
  return i > o ? "after" : i === o ? "same" : "before";
6382
6395
  }
6383
6396
  getSpineItemIndex(e) {
6384
- const t = e instanceof Qt ? e : this.get(e);
6397
+ const t = e instanceof en ? e : this.get(e);
6385
6398
  if (!t) return;
6386
6399
  const i = this.orderedSpineItemsSubject.value.indexOf(t);
6387
6400
  return i < 0 ? void 0 : i;
@@ -6410,10 +6423,10 @@ class Vs extends X {
6410
6423
  });
6411
6424
  }
6412
6425
  }
6413
- class js extends ce {
6426
+ class ks extends ce {
6414
6427
  constructor(e, t) {
6415
6428
  const i = document.createElement("div");
6416
- i.setAttribute(`data-${oi}`, ""), super({
6429
+ i.setAttribute(`data-${si}`, ""), super({
6417
6430
  element: i,
6418
6431
  pageSize: {
6419
6432
  width: 1,
@@ -6453,7 +6466,7 @@ class js extends ce {
6453
6466
  });
6454
6467
  }
6455
6468
  get absoluteViewport() {
6456
- return new Ps({
6469
+ return new xs({
6457
6470
  width: this.value.width,
6458
6471
  height: this.value.height
6459
6472
  });
@@ -6481,18 +6494,18 @@ class js extends ce {
6481
6494
  */
6482
6495
  get relativeViewport() {
6483
6496
  const e = this.absoluteViewport, t = this.scaleFactor;
6484
- return new xs({
6497
+ return new $s({
6485
6498
  width: e.width / t,
6486
6499
  height: e.height / t
6487
6500
  });
6488
6501
  }
6489
6502
  }
6490
- const $t = `${Ut}-core`, ks = (n) => {
6491
- const e = crypto.randomUUID(), t = new R(), i = new R(), o = new Ro(), s = new Eo(), r = new Ss(n, s), a = new Do(s, r), c = new Vs(s, r), u = new js(s, r), l = Jt({
6503
+ const $t = `${Ut}-core`, Us = (n) => {
6504
+ const e = crypto.randomUUID(), t = new R(), i = new R(), o = new No(), s = new Ao(), r = new bs(n, s), a = new Oo(s, r), c = new js(s, r), u = new ks(s, r), l = Kt({
6492
6505
  context: s,
6493
6506
  settings: r,
6494
6507
  viewport: u
6495
- }), d = new hs(s, c), g = new Ns(
6508
+ }), d = new ms(s, c), g = new Vs(
6496
6509
  s,
6497
6510
  d,
6498
6511
  c,
@@ -6500,14 +6513,14 @@ const $t = `${Ut}-core`, ks = (n) => {
6500
6513
  r,
6501
6514
  o,
6502
6515
  u
6503
- ), h = gs({
6516
+ ), h = hs({
6504
6517
  context: s,
6505
6518
  spineItemsManager: c,
6506
6519
  hookManager: o,
6507
6520
  spine: g,
6508
6521
  settings: r,
6509
6522
  viewport: u
6510
- }), p = new ms(
6523
+ }), p = new fs(
6511
6524
  s,
6512
6525
  d,
6513
6526
  c,
@@ -6526,21 +6539,21 @@ const $t = `${Ut}-core`, ks = (n) => {
6526
6539
  return;
6527
6540
  }
6528
6541
  D.log("load", { options: $ });
6529
- const B = Us(A, e);
6542
+ const B = zs(A, e);
6530
6543
  s.update({
6531
6544
  manifest: Y,
6532
6545
  rootElement: B
6533
6546
  }), m();
6534
- }, f = r.watch(["computedSpreadMode"]).pipe(Ct(1), j(m)), I = t.pipe(
6547
+ }, f = r.watch(["computedSpreadMode"]).pipe(Ct(1), j(m)), b = t.pipe(
6535
6548
  j(() => {
6536
6549
  const $ = s.value.rootElement;
6537
6550
  $ && ($.style.setProperty("overflow", "hidden"), u.layout(), g.layout());
6538
6551
  }),
6539
6552
  G(i)
6540
- ), b = P(I, f).subscribe();
6541
- Je(document, $t, Ao);
6553
+ ), I = P(b, f).subscribe();
6554
+ Je(document, $t, Vo);
6542
6555
  const F = () => {
6543
- Ke(document, $t), b.unsubscribe(), c.destroy(), p.destroy(), r.destroy(), d.destroy(), s.destroy(), h.destroy(), g.destroy(), a.destroy(), i.next(), i.complete(), u.destroy();
6556
+ Ke(document, $t), I.unsubscribe(), c.destroy(), p.destroy(), r.destroy(), d.destroy(), s.destroy(), h.destroy(), g.destroy(), a.destroy(), i.next(), i.complete(), u.destroy();
6544
6557
  };
6545
6558
  return {
6546
6559
  id: e,
@@ -6548,7 +6561,7 @@ const $t = `${Ut}-core`, ks = (n) => {
6548
6561
  spine: g,
6549
6562
  hookManager: o,
6550
6563
  cfi: {
6551
- generateCfiFromRange: so,
6564
+ generateCfiFromRange: ro,
6552
6565
  parseCfi: ot,
6553
6566
  generateCfiForSpineItemPage: ($) => He({
6554
6567
  ...$,
@@ -6589,31 +6602,31 @@ const $t = `${Ut}-core`, ks = (n) => {
6589
6602
  destroy$: i
6590
6603
  }
6591
6604
  };
6592
- }, Us = (n, e) => (n.style.cssText = `
6605
+ }, zs = (n, e) => (n.style.cssText = `
6593
6606
  ${n.style.cssText}
6594
6607
  background-color: white;
6595
6608
  position: relative;
6596
- `, n.classList.add(`${W}-reader`), n.setAttribute(ii, e), n), tr = (
6609
+ `, n.classList.add(`${W}-reader`), n.setAttribute(oi, e), n), nr = (
6597
6610
  //__
6598
6611
  Io(
6599
- Gn(
6600
- Ai(
6601
- wo(
6602
- qn(
6603
- Un(
6604
- ho(
6605
- vo(
6606
- Mo(
6607
- qi(
6608
- Si(
6609
- Ni(
6610
- zn(
6611
- bo(
6612
- lo(
6613
- Ci(
6614
- Bn(
6612
+ Zn(
6613
+ Oi(
6614
+ Po(
6615
+ Gn(
6616
+ zn(
6617
+ mo(
6618
+ wo(
6619
+ Do(
6620
+ Gi(
6621
+ bi(
6622
+ Vi(
6623
+ Wn(
6624
+ vo(
6625
+ po(
6626
+ Ei(
6627
+ Xn(
6615
6628
  // __
6616
- ks
6629
+ Us
6617
6630
  )
6618
6631
  )
6619
6632
  )
@@ -6631,80 +6644,81 @@ const $t = `${Ut}-core`, ks = (n) => {
6631
6644
  )
6632
6645
  )
6633
6646
  )
6634
- ), nr = (n) => (e) => n(e);
6647
+ ), ir = (n) => (e) => n(e);
6635
6648
  export {
6636
6649
  _t as AbstractSpinePosition,
6637
- Eo as Context,
6638
- jo as ControlledNavigationController,
6650
+ Ao as Context,
6651
+ zo as ControlledNavigationController,
6639
6652
  X as DestroyableClass,
6640
6653
  fe as DocumentRenderer,
6641
- Do as Features,
6642
- ii as HTML_ATTRIBUTE_DATA_READER_ID,
6654
+ Oo as Features,
6655
+ oi as HTML_ATTRIBUTE_DATA_READER_ID,
6643
6656
  W as HTML_PREFIX,
6644
- si as HTML_PREFIX_SCROLL_NAVIGATOR,
6645
- oi as HTML_PREFIX_VIEWPORT,
6657
+ ri as HTML_PREFIX_SCROLL_NAVIGATOR,
6658
+ si as HTML_PREFIX_VIEWPORT,
6646
6659
  Ut as HTML_STYLE_PREFIX,
6647
- Ro as HookManager,
6648
- ni as ITEM_EXTENSION_VALID_FOR_FRAME_SRC,
6649
- es as InternalNavigator,
6660
+ No as HookManager,
6661
+ ii as ITEM_EXTENSION_VALID_FOR_FRAME_SRC,
6662
+ ts as InternalNavigator,
6650
6663
  it as LayoutEntry,
6651
- Gt as Locker,
6652
- Ks as PAGINATION_UPDATE_AFTER_VIEWPORT_ADJUSTMENT_DEBOUNCE,
6653
- Zs as PROSE_READER_NAMESPACE,
6654
- Ds as Pages,
6655
- hs as Pagination,
6656
- ms as PaginationController,
6664
+ Zt as Locker,
6665
+ Qs as PAGINATION_UPDATE_AFTER_VIEWPORT_ADJUSTMENT_DEBOUNCE,
6666
+ Js as PROSE_READER_NAMESPACE,
6667
+ Rs as Pages,
6668
+ ms as Pagination,
6669
+ fs as PaginationController,
6657
6670
  ce as ReactiveEntity,
6658
6671
  nt as ResourceHandler,
6659
- uo as ResourcesLocator,
6660
- Uo as ScrollNavigationController,
6661
- St as ScrollPosition,
6662
- ys as SettingsManager,
6663
- Ns as Spine,
6664
- Qt as SpineItem,
6672
+ lo as ResourcesLocator,
6673
+ Lo as ScrollNavigationController,
6674
+ ft as ScrollPosition,
6675
+ Ss as SettingsManager,
6676
+ Vs as Spine,
6677
+ en as SpineItem,
6665
6678
  Ii as SpineItemPageLayout,
6666
- bi as SpineItemPageSpineLayout,
6679
+ vi as SpineItemPageSpineLayout,
6667
6680
  C as SpineItemPosition,
6668
6681
  _e as SpineItemSpineLayout,
6669
- Vs as SpineItemsManager,
6670
- Rs as SpineItemsObserver,
6682
+ js as SpineItemsManager,
6683
+ As as SpineItemsObserver,
6671
6684
  M as SpinePosition,
6685
+ Fo as UnboundScrollPosition,
6672
6686
  Ae as UnboundSpineItemPagePosition,
6673
6687
  ae as UnboundSpinePosition,
6674
- Js as VIEWPORT_ADJUSTMENT_THROTTLE,
6675
- js as Viewport,
6676
- co as consolidate,
6677
- tr as createReader,
6688
+ Ks as VIEWPORT_ADJUSTMENT_THROTTLE,
6689
+ ks as Viewport,
6690
+ uo as consolidate,
6691
+ nr as createReader,
6678
6692
  ut as deferIdle,
6679
- Xn as deferNextResult,
6693
+ Yn as deferNextResult,
6680
6694
  He as generateCfiForSpineItemPage,
6681
- so as generateCfiFromRange,
6695
+ ro as generateCfiFromRange,
6682
6696
  he as generateRootCfi,
6683
6697
  ct as getAttributeValueFromString,
6684
- qs as getBase64FromBlob,
6698
+ Gs as getBase64FromBlob,
6685
6699
  Qe as getFrameViewportInfo,
6686
- er as getItemAnchor,
6687
- Si as htmlEnhancer,
6700
+ tr as getItemAnchor,
6701
+ bi as htmlEnhancer,
6688
6702
  Vt as idle,
6689
- Vn as injectCSS,
6703
+ jn as injectCSS,
6690
6704
  Ot as isHtmlElement,
6691
- On as isHtmlTagElement,
6705
+ Nn as isHtmlTagElement,
6692
6706
  Be as isRootCfi,
6693
- sr as isShallowEqual,
6694
- Ci as layoutEnhancer,
6707
+ rr as isShallowEqual,
6708
+ Ei as layoutEnhancer,
6695
6709
  Nt as mapKeysTo,
6696
- Ys as observeIntersection,
6710
+ qs as observeIntersection,
6697
6711
  lt as observeMutation,
6698
6712
  tt as observeResize,
6699
- lo as paginationEnhancer,
6713
+ po as paginationEnhancer,
6700
6714
  ot as parseCfi,
6701
- Xs as removeCSS,
6715
+ Ys as removeCSS,
6702
6716
  Yt as resolveCfi,
6703
- nr as rootEnhancer,
6704
- Es as spinePositionToSpineItemSpineLayout,
6717
+ ir as rootEnhancer,
6718
+ Ds as spinePositionToSpineItemSpineLayout,
6705
6719
  te as upsertCSSToFrame,
6706
- jn as waitForFrameLoad,
6707
- kn as waitForFrameReady,
6720
+ kn as waitForFrameLoad,
6721
+ Un as waitForFrameReady,
6708
6722
  Ee as waitForSwitch,
6709
6723
  et as watchKeys
6710
6724
  };