@readium/navigator-html-injectables 2.0.0-beta.4 → 2.0.0-beta.5

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,70 +1,70 @@
1
- const at = Math.pow(2, 32), ve = () => Math.round(Math.random() * at).toString(36), lt = () => `${Math.round(performance.now())}-${ve()}-${ve()}`, V = 1;
2
- class ht {
3
- constructor(e) {
4
- this.destination = null, this.registrar = /* @__PURE__ */ new Map(), this.origin = "", this.channelId = "", this.receiver = this.receive.bind(this), this.preLog = [], this.wnd = e, e.addEventListener("message", this.receiver);
1
+ const ne = Math.pow(2, 32), gt = () => Math.round(Math.random() * ne).toString(36), oe = () => `${Math.round(performance.now())}-${gt()}-${gt()}`, k = 1;
2
+ class ae {
3
+ constructor(t) {
4
+ this.destination = null, this.registrar = /* @__PURE__ */ new Map(), this.origin = "", this.channelId = "", this.receiver = this.receive.bind(this), this.preLog = [], this.wnd = t, t.addEventListener("message", this.receiver);
5
5
  }
6
- receive(e) {
7
- if (e.source === null)
6
+ receive(t) {
7
+ if (t.source === null)
8
8
  throw Error("Event source is null");
9
- if (typeof e.data != "object")
9
+ if (typeof t.data != "object")
10
10
  return;
11
- const t = e.data;
12
- if (!(!("_readium" in t) || !t._readium || t._readium <= 0)) {
13
- if (t.key === "_ping") {
11
+ const e = t.data;
12
+ if (!(!("_readium" in e) || !e._readium || e._readium <= 0)) {
13
+ if (e.key === "_ping") {
14
14
  if (!this.destination) {
15
- if (this.destination = e.source, this.origin = e.origin, this.channelId = t._channel, t._readium !== V) {
16
- t._readium > V ? this.send("error", `received comms version ${t._readium} higher than ${V}`) : this.send("error", `received comms version ${t._readium} lower than ${V}`), this.destination = null, this.origin = "", this.channelId = "";
15
+ if (this.destination = t.source, this.origin = t.origin, this.channelId = e._channel, e._readium !== k) {
16
+ e._readium > k ? this.send("error", `received comms version ${e._readium} higher than ${k}`) : this.send("error", `received comms version ${e._readium} lower than ${k}`), this.destination = null, this.origin = "", this.channelId = "";
17
17
  return;
18
18
  }
19
19
  this.send("_pong", void 0), this.preLog.forEach((i) => this.send("log", i)), this.preLog = [];
20
20
  }
21
21
  return;
22
22
  } else if (this.channelId) {
23
- if (t._channel !== this.channelId || e.origin !== this.origin)
23
+ if (e._channel !== this.channelId || t.origin !== this.origin)
24
24
  return;
25
25
  } else
26
26
  return;
27
- this.handle(t);
27
+ this.handle(e);
28
28
  }
29
29
  }
30
- handle(e) {
31
- const t = this.registrar.get(e.key);
32
- if (!t || t.length === 0) {
33
- e.strict && this.send("_unhandled", e);
30
+ handle(t) {
31
+ const e = this.registrar.get(t.key);
32
+ if (!e || e.length === 0) {
33
+ t.strict && this.send("_unhandled", t);
34
34
  return;
35
35
  }
36
- t.forEach((i) => i.cb(e.data, (s) => {
37
- this.send("_ack", s, e.id);
36
+ e.forEach((i) => i.cb(t.data, (s) => {
37
+ this.send("_ack", s, t.id);
38
38
  }));
39
39
  }
40
- register(e, t, i) {
41
- Array.isArray(e) || (e = [e]), e.forEach((s) => {
40
+ register(t, e, i) {
41
+ Array.isArray(t) || (t = [t]), t.forEach((s) => {
42
42
  const n = this.registrar.get(s);
43
43
  if (n && n.length >= 0) {
44
- if (n.find((l) => l.module === t))
45
- throw new Error(`Trying to register another callback for combination of event ${s} and module ${t}`);
44
+ if (n.find((l) => l.module === e))
45
+ throw new Error(`Trying to register another callback for combination of event ${s} and module ${e}`);
46
46
  n.push({
47
47
  cb: i,
48
- module: t
48
+ module: e
49
49
  }), this.registrar.set(s, n);
50
50
  } else
51
51
  this.registrar.set(s, [{
52
52
  cb: i,
53
- module: t
53
+ module: e
54
54
  }]);
55
55
  });
56
56
  }
57
- unregister(e, t) {
58
- Array.isArray(e) || (e = [e]), e.forEach((i) => {
57
+ unregister(t, e) {
58
+ Array.isArray(t) || (t = [t]), t.forEach((i) => {
59
59
  const s = this.registrar.get(i);
60
- !s || s.length === 0 || s.splice(s.findIndex((n) => n.module === t), 1);
60
+ !s || s.length === 0 || s.splice(s.findIndex((n) => n.module === e), 1);
61
61
  });
62
62
  }
63
- unregisterAll(e) {
64
- this.registrar.forEach((t, i) => this.registrar.set(i, t.filter((s) => s.module !== e)));
63
+ unregisterAll(t) {
64
+ this.registrar.forEach((e, i) => this.registrar.set(i, e.filter((s) => s.module !== t)));
65
65
  }
66
- log(...e) {
67
- this.destination ? this.send("log", e) : this.preLog.push(e);
66
+ log(...t) {
67
+ this.destination ? this.send("log", t) : this.preLog.push(t);
68
68
  }
69
69
  get ready() {
70
70
  return !!this.destination;
@@ -72,16 +72,16 @@ class ht {
72
72
  destroy() {
73
73
  this.destination = null, this.channelId = "", this.preLog = [], this.registrar.clear(), this.wnd.removeEventListener("message", this.receiver);
74
74
  }
75
- send(e, t, i = void 0, s = []) {
75
+ send(t, e, i = void 0, s = []) {
76
76
  if (!this.destination)
77
77
  throw Error("Attempted to send comms message before destination has been initialized");
78
78
  const n = {
79
- _readium: V,
79
+ _readium: k,
80
80
  _channel: this.channelId,
81
- id: i ?? lt(),
81
+ id: i ?? oe(),
82
82
  // scrict,
83
- key: e,
84
- data: t
83
+ key: t,
84
+ data: e
85
85
  };
86
86
  try {
87
87
  this.destination.postMessage(n, {
@@ -95,51 +95,44 @@ class ht {
95
95
  }
96
96
  }
97
97
  }
98
- const L = class B {
99
- constructor(e) {
100
- if (typeof e == "string") {
101
- if (!B.VALID_MODES.has(e.toLowerCase()))
102
- return;
103
- this.value = e.toLowerCase();
104
- } else {
105
- const t = e.filter(
106
- (i) => B.VALID_MODES.has(i.toLowerCase())
107
- );
108
- if (t.length === 0)
109
- return;
110
- this.value = Array.from(new Set(t));
111
- }
98
+ class it {
99
+ /**
100
+ * Creates a [Encryption].
101
+ */
102
+ constructor(t) {
103
+ this.algorithm = t.algorithm, this.compression = t.compression, this.originalLength = t.originalLength, this.profile = t.profile, this.scheme = t.scheme;
112
104
  }
113
- static deserialize(e) {
114
- if (!e)
115
- return;
116
- if (typeof e == "string")
117
- return new B(e);
118
- if (!Array.isArray(e))
119
- return;
120
- const t = e.filter((i) => i ? B.VALID_MODES.has(i.toLowerCase()) : !1);
121
- if (t.length !== 0)
122
- return new B(t);
105
+ /**
106
+ * Parses a [Encryption] from its RWPM JSON representation.
107
+ */
108
+ static deserialize(t) {
109
+ if (t && t.algorithm)
110
+ return new it({
111
+ algorithm: t.algorithm,
112
+ compression: t.compression,
113
+ originalLength: t.originalLength,
114
+ profile: t.profile,
115
+ scheme: t.scheme
116
+ });
123
117
  }
118
+ /**
119
+ * Serializes a [Encryption] to its RWPM JSON representation.
120
+ */
124
121
  serialize() {
125
- return this.value;
122
+ const t = { algorithm: this.algorithm };
123
+ return this.compression !== void 0 && (t.compression = this.compression), this.originalLength !== void 0 && (t.originalLength = this.originalLength), this.profile !== void 0 && (t.profile = this.profile), this.scheme !== void 0 && (t.scheme = this.scheme), t;
126
124
  }
127
- };
128
- L.VALID_MODES = /* @__PURE__ */ new Set(["auditory", "tactile", "textual", "visual"]);
129
- L.AUDITORY = new L("auditory");
130
- L.TACTILE = new L("tactile");
131
- L.TEXTUAL = new L("textual");
132
- L.VISUAL = new L("visual");
125
+ }
133
126
  class E {
134
- constructor(e) {
135
- this.otherProperties = e;
127
+ constructor(t) {
128
+ this.otherProperties = t;
136
129
  }
137
130
  /**
138
131
  * Creates a [Properties] from its RWPM JSON representation.
139
132
  */
140
- static deserialize(e) {
141
- if (e)
142
- return new E(e);
133
+ static deserialize(t) {
134
+ if (t)
135
+ return new E(t);
143
136
  }
144
137
  /**
145
138
  * Serializes a [Properties] to its RWPM JSON representation.
@@ -150,13 +143,18 @@ class E {
150
143
  /**
151
144
  * Makes a copy of this [Properties] after merging in the given additional other [properties].
152
145
  */
153
- add(e) {
154
- const t = Object.assign({}, this.otherProperties);
155
- for (const i in e)
156
- t[i] = e[i];
157
- return new E(t);
146
+ add(t) {
147
+ const e = Object.assign({}, this.otherProperties);
148
+ for (const i in t)
149
+ e[i] = t[i];
150
+ return new E(e);
158
151
  }
159
152
  }
153
+ Object.defineProperty(E.prototype, "encryption", {
154
+ get: function() {
155
+ return it.deserialize(this.otherProperties.encrypted);
156
+ }
157
+ });
160
158
  E.prototype.getContains = function() {
161
159
  return new Set(this.otherProperties.contains || []);
162
160
  };
@@ -165,11 +163,11 @@ E.prototype.getLayout = function() {
165
163
  };
166
164
  class a {
167
165
  /** Creates a MediaType object. */
168
- constructor(e) {
169
- let t, i, s = e.mediaType.replace(/\s/g, "").split(";");
166
+ constructor(t) {
167
+ let e, i, s = t.mediaType.replace(/\s/g, "").split(";");
170
168
  const n = s[0].split("/");
171
169
  if (n.length === 2) {
172
- if (t = n[0].toLowerCase().trim(), i = n[1].toLowerCase().trim(), t.length === 0 || i.length === 0)
170
+ if (e = n[0].toLowerCase().trim(), i = n[1].toLowerCase().trim(), e.length === 0 || i.length === 0)
173
171
  throw new Error("Invalid media type");
174
172
  } else
175
173
  throw new Error("Invalid media type");
@@ -188,19 +186,19 @@ class a {
188
186
  const f = l[d];
189
187
  h += `;${d}=${f}`;
190
188
  }
191
- const u = `${t}/${i}${h}`, p = l.encoding;
192
- this.string = u, this.type = t, this.subtype = i, this.parameters = l, this.encoding = p, this.name = e.name, this.fileExtension = e.fileExtension;
189
+ const u = `${e}/${i}${h}`, p = l.encoding;
190
+ this.string = u, this.type = e, this.subtype = i, this.parameters = l, this.encoding = p, this.name = t.name, this.fileExtension = t.fileExtension;
193
191
  }
194
- static parse(e) {
195
- return new a(e);
192
+ static parse(t) {
193
+ return new a(t);
196
194
  }
197
195
  /** Structured syntax suffix, e.g. `+zip` in `application/epub+zip`.
198
196
  * Gives a hint on the underlying structure of this media type.
199
197
  * See. https://tools.ietf.org/html/rfc6838#section-4.2.8
200
198
  */
201
199
  get structuredSyntaxSuffix() {
202
- const e = this.subtype.split("+");
203
- return e.length > 1 ? `+${e[e.length - 1]}` : void 0;
200
+ const t = this.subtype.split("+");
201
+ return t.length > 1 ? `+${t[t.length - 1]}` : void 0;
204
202
  }
205
203
  /** Parameter values might or might not be case-sensitive, depending on the semantics of
206
204
  * the parameter name.
@@ -221,14 +219,14 @@ class a {
221
219
  * - Order of parameters is ignored.
222
220
  * - Wildcards are supported, meaning that `image/*` contains `image/png`
223
221
  */
224
- contains(e) {
225
- const t = typeof e == "string" ? a.parse({ mediaType: e }) : e;
226
- if (!((this.type === "*" || this.type === t.type) && (this.subtype === "*" || this.subtype === t.subtype)))
222
+ contains(t) {
223
+ const e = typeof t == "string" ? a.parse({ mediaType: t }) : t;
224
+ if (!((this.type === "*" || this.type === e.type) && (this.subtype === "*" || this.subtype === e.subtype)))
227
225
  return !1;
228
226
  const i = new Set(
229
227
  Object.entries(this.parameters).map(([n, o]) => `${n}=${o}`)
230
228
  ), s = new Set(
231
- Object.entries(t.parameters).map(([n, o]) => `${n}=${o}`)
229
+ Object.entries(e.parameters).map(([n, o]) => `${n}=${o}`)
232
230
  );
233
231
  for (const n of Array.from(i.values()))
234
232
  if (!s.has(n))
@@ -240,22 +238,22 @@ class a {
240
238
  * For example, `text/html` matches `text/html;charset=utf-8`, but `text/html;charset=ascii`
241
239
  * doesn't. This is basically like `contains`, but working in both direction.
242
240
  */
243
- matches(e) {
244
- const t = typeof e == "string" ? a.parse({ mediaType: e }) : e;
245
- return this.contains(t) || t.contains(this);
241
+ matches(t) {
242
+ const e = typeof t == "string" ? a.parse({ mediaType: t }) : t;
243
+ return this.contains(e) || e.contains(this);
246
244
  }
247
245
  /**
248
246
  * Returns whether this media type matches any of the [others] media types.
249
247
  */
250
- matchesAny(...e) {
251
- for (const t of e)
252
- if (this.matches(t))
248
+ matchesAny(...t) {
249
+ for (const e of t)
250
+ if (this.matches(e))
253
251
  return !0;
254
252
  return !1;
255
253
  }
256
254
  /** Checks the MediaType equals another one (comparing their string) */
257
- equals(e) {
258
- return this.string === e.string;
255
+ equals(t) {
256
+ return this.string === t.string;
259
257
  }
260
258
  /** Returns whether this media type is structured as a ZIP archive. */
261
259
  get isZIP() {
@@ -618,78 +616,78 @@ class a {
618
616
  });
619
617
  }
620
618
  }
621
- class Ee {
622
- constructor(e) {
623
- this.uri = e, this.parameters = this.getParameters(e);
619
+ class yt {
620
+ constructor(t) {
621
+ this.uri = t, this.parameters = this.getParameters(t);
624
622
  }
625
623
  /**
626
624
  * List of URI template parameter keys, if the [Link] is templated.
627
625
  */
628
- getParameters(e) {
629
- const t = /\{\??([^}]+)\}/g, i = e.match(t);
626
+ getParameters(t) {
627
+ const e = /\{\??([^}]+)\}/g, i = t.match(e);
630
628
  return i ? new Set(
631
- i.join(",").replace(t, "$1").split(",").map((s) => s.trim())
629
+ i.join(",").replace(e, "$1").split(",").map((s) => s.trim())
632
630
  ) : /* @__PURE__ */ new Set();
633
631
  }
634
632
  /** Expands the URI by replacing the template variables by the given parameters.
635
633
  * Any extra parameter is appended as query parameters.
636
634
  * See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
637
635
  */
638
- expand(e) {
639
- const t = (s) => s.split(",").map((n) => {
640
- const o = e[n];
636
+ expand(t) {
637
+ const e = (s) => s.split(",").map((n) => {
638
+ const o = t[n];
641
639
  return o ? encodeURIComponent(o) : "";
642
640
  }).join(","), i = (s) => "?" + s.split(",").map((n) => {
643
- const o = n.split("=")[0], l = e[o];
641
+ const o = n.split("=")[0], l = t[o];
644
642
  return l ? `${o}=${encodeURIComponent(l)}` : "";
645
643
  }).join("&");
646
- return this.uri.replace(/\{(\??)([^}]+)\}/g, (...s) => s[1] ? i(s[2]) : t(s[2]));
644
+ return this.uri.replace(/\{(\??)([^}]+)\}/g, (...s) => s[1] ? i(s[2]) : e(s[2]));
647
645
  }
648
646
  }
649
- function ct(r) {
647
+ function le(r) {
650
648
  return r && r instanceof Array ? r : void 0;
651
649
  }
652
- function Ue(r) {
653
- return r && typeof r == "string" ? [r] : ct(r);
650
+ function Wt(r) {
651
+ return r && typeof r == "string" ? [r] : le(r);
654
652
  }
655
- function be(r) {
653
+ function vt(r) {
656
654
  return typeof r == "string" ? new Date(r) : void 0;
657
655
  }
658
- function q(r) {
656
+ function j(r) {
659
657
  return isNaN(r) ? void 0 : r;
660
658
  }
661
659
  function C(r) {
662
- return q(r) !== void 0 && Math.sign(r) >= 0 ? r : void 0;
660
+ return j(r) !== void 0 && Math.sign(r) >= 0 ? r : void 0;
663
661
  }
664
- function ut(r) {
665
- const e = new Array();
666
- return r.forEach((t) => e.push(t)), e;
662
+ function he(r) {
663
+ const t = new Array();
664
+ return r.forEach((e) => t.push(e)), t;
667
665
  }
668
666
  class x {
669
667
  /**
670
668
  * Creates a [Locations].
671
669
  */
672
- constructor(e) {
673
- this.fragments = e.fragments ? e.fragments : new Array(), this.progression = e.progression, this.totalProgression = e.totalProgression, this.position = e.position, this.otherLocations = e.otherLocations;
670
+ constructor(t) {
671
+ this.fragments = t.fragments ? t.fragments : new Array(), this.progression = t.progression, this.totalProgression = t.totalProgression, this.position = t.position, this.otherLocations = t.otherLocations;
674
672
  }
675
673
  /**
676
674
  * Parses a [Locations] from its RWPM JSON representation.
677
675
  */
678
- static deserialize(e) {
679
- if (!e)
676
+ static deserialize(t) {
677
+ if (!t)
680
678
  return;
681
- const t = q(e.progression), i = q(e.totalProgression), s = q(e.position), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([
679
+ const e = j(t.progression), i = j(t.totalProgression), s = j(t.position), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([
682
680
  "fragment",
683
681
  "fragments",
684
682
  "progression",
685
683
  "totalProgression",
686
684
  "position"
687
685
  ]);
688
- return Object.entries(e).forEach(([l, c]) => {
686
+ return Object.entries(t).forEach(([l, c]) => {
689
687
  o.has(l) || n.set(l, c);
690
688
  }), new x({
691
- fragments: Ue(e.fragments || e.fragment),
692
- progression: t !== void 0 && t >= 0 && t <= 1 ? t : void 0,
689
+ fragments: Wt(t.fragments || t.fragment),
690
+ progression: e !== void 0 && e >= 0 && e <= 1 ? e : void 0,
693
691
  totalProgression: i !== void 0 && i >= 0 && i <= 1 ? i : void 0,
694
692
  position: s !== void 0 && s > 0 ? s : void 0,
695
693
  otherLocations: n.size === 0 ? void 0 : n
@@ -699,110 +697,110 @@ class x {
699
697
  * Serializes a [Locations] to its RWPM JSON representation.
700
698
  */
701
699
  serialize() {
702
- const e = {};
703
- return this.fragments && (e.fragments = this.fragments), this.progression !== void 0 && (e.progression = this.progression), this.totalProgression !== void 0 && (e.totalProgression = this.totalProgression), this.position !== void 0 && (e.position = this.position), this.otherLocations && this.otherLocations.forEach((t, i) => e[i] = t), e;
700
+ const t = {};
701
+ return this.fragments && (t.fragments = this.fragments), this.progression !== void 0 && (t.progression = this.progression), this.totalProgression !== void 0 && (t.totalProgression = this.totalProgression), this.position !== void 0 && (t.position = this.position), this.otherLocations && this.otherLocations.forEach((e, i) => t[i] = e), t;
704
702
  }
705
703
  }
706
- class k {
704
+ class U {
707
705
  /**
708
706
  * Creates a [Text].
709
707
  */
710
- constructor(e) {
711
- this.after = e.after, this.before = e.before, this.highlight = e.highlight;
708
+ constructor(t) {
709
+ this.after = t.after, this.before = t.before, this.highlight = t.highlight;
712
710
  }
713
711
  /**
714
712
  * Parses a [Locations] from its RWPM JSON representation.
715
713
  */
716
- static deserialize(e) {
717
- if (e)
718
- return new k({
719
- after: e.after,
720
- before: e.before,
721
- highlight: e.highlight
714
+ static deserialize(t) {
715
+ if (t)
716
+ return new U({
717
+ after: t.after,
718
+ before: t.before,
719
+ highlight: t.highlight
722
720
  });
723
721
  }
724
722
  /**
725
723
  * Serializes a [Locations] to its RWPM JSON representation.
726
724
  */
727
725
  serialize() {
728
- const e = {};
729
- return this.after !== void 0 && (e.after = this.after), this.before !== void 0 && (e.before = this.before), this.highlight !== void 0 && (e.highlight = this.highlight), e;
726
+ const t = {};
727
+ return this.after !== void 0 && (t.after = this.after), this.before !== void 0 && (t.before = this.before), this.highlight !== void 0 && (t.highlight = this.highlight), t;
730
728
  }
731
729
  }
732
- class W {
730
+ class D {
733
731
  /**
734
732
  * Creates a [Locator].
735
733
  */
736
- constructor(e) {
737
- this.href = e.href, this.type = e.type, this.title = e.title, this.locations = e.locations ? e.locations : new x({}), this.text = e.text;
734
+ constructor(t) {
735
+ this.href = t.href, this.type = t.type, this.title = t.title, this.locations = t.locations ? t.locations : new x({}), this.text = t.text;
738
736
  }
739
737
  /**
740
738
  * Parses a [Link] from its RWPM JSON representation.
741
739
  */
742
- static deserialize(e) {
743
- if (e && e.href && e.type)
744
- return new W({
745
- href: e.href,
746
- type: e.type,
747
- title: e.title,
748
- locations: x.deserialize(e.locations),
749
- text: k.deserialize(e.text)
740
+ static deserialize(t) {
741
+ if (t && t.href && t.type)
742
+ return new D({
743
+ href: t.href,
744
+ type: t.type,
745
+ title: t.title,
746
+ locations: x.deserialize(t.locations),
747
+ text: U.deserialize(t.text)
750
748
  });
751
749
  }
752
750
  /**
753
751
  * Serializes a [Link] to its RWPM JSON representation.
754
752
  */
755
753
  serialize() {
756
- const e = { href: this.href, type: this.type };
757
- return this.title !== void 0 && (e.title = this.title), this.locations && (e.locations = this.locations.serialize()), this.text && (e.text = this.text.serialize()), e;
754
+ const t = { href: this.href, type: this.type };
755
+ return this.title !== void 0 && (t.title = this.title), this.locations && (t.locations = this.locations.serialize()), this.text && (t.text = this.text.serialize()), t;
758
756
  }
759
757
  /**
760
758
  * Shortcut to get a copy of the [Locator] with different [Locations] sub-properties.
761
759
  */
762
- copyWithLocations(e) {
763
- return new W({
760
+ copyWithLocations(t) {
761
+ return new D({
764
762
  href: this.href,
765
763
  type: this.type,
766
764
  title: this.title,
767
765
  text: this.text,
768
- locations: new x({ ...this.locations, ...e })
766
+ locations: new x({ ...this.locations, ...t })
769
767
  });
770
768
  }
771
769
  }
772
- class $ {
770
+ class B {
773
771
  /**
774
772
  * Creates a [Link].
775
773
  */
776
- constructor(e) {
777
- this.href = e.href, this.templated = e.templated, this.type = e.type, this.title = e.title, this.rels = e.rels, this.properties = e.properties, this.height = e.height, this.width = e.width, this.duration = e.duration, this.bitrate = e.bitrate, this.languages = e.languages, this.alternates = e.alternates, this.children = e.children;
774
+ constructor(t) {
775
+ this.href = t.href, this.templated = t.templated, this.type = t.type, this.title = t.title, this.rels = t.rels, this.properties = t.properties, this.height = t.height, this.width = t.width, this.duration = t.duration, this.bitrate = t.bitrate, this.languages = t.languages, this.alternates = t.alternates, this.children = t.children;
778
776
  }
779
777
  /**
780
778
  * Parses a [Link] from its RWPM JSON representation.
781
779
  */
782
- static deserialize(e) {
783
- if (!(!e || typeof e.href != "string"))
784
- return new $({
785
- href: e.href,
786
- templated: e.templated,
787
- type: e.type,
788
- title: e.title,
789
- rels: e.rel ? e.rel instanceof Array ? new Set(e.rel) : /* @__PURE__ */ new Set([e.rel]) : void 0,
790
- properties: E.deserialize(e.properties),
791
- height: C(e.height),
792
- width: C(e.width),
793
- duration: C(e.duration),
794
- bitrate: C(e.bitrate),
795
- languages: Ue(e.language),
796
- alternates: _.deserialize(e.alternate),
797
- children: _.deserialize(e.children)
780
+ static deserialize(t) {
781
+ if (!(!t || typeof t.href != "string"))
782
+ return new B({
783
+ href: t.href,
784
+ templated: t.templated,
785
+ type: t.type,
786
+ title: t.title,
787
+ rels: t.rel ? t.rel instanceof Array ? new Set(t.rel) : /* @__PURE__ */ new Set([t.rel]) : void 0,
788
+ properties: E.deserialize(t.properties),
789
+ height: C(t.height),
790
+ width: C(t.width),
791
+ duration: C(t.duration),
792
+ bitrate: C(t.bitrate),
793
+ languages: Wt(t.language),
794
+ alternates: V.deserialize(t.alternate),
795
+ children: V.deserialize(t.children)
798
796
  });
799
797
  }
800
798
  /**
801
799
  * Serializes a [Link] to its RWPM JSON representation.
802
800
  */
803
801
  serialize() {
804
- const e = { href: this.href };
805
- return this.templated !== void 0 && (e.templated = this.templated), this.type !== void 0 && (e.type = this.type), this.title !== void 0 && (e.title = this.title), this.rels && (e.rel = ut(this.rels)), this.properties && (e.properties = this.properties.serialize()), this.height !== void 0 && (e.height = this.height), this.width !== void 0 && (e.width = this.width), this.duration !== void 0 && (e.duration = this.duration), this.bitrate !== void 0 && (e.bitrate = this.bitrate), this.languages && (e.language = this.languages), this.alternates && (e.alternate = this.alternates.serialize()), this.children && (e.children = this.children.serialize()), e;
802
+ const t = { href: this.href };
803
+ return this.templated !== void 0 && (t.templated = this.templated), this.type !== void 0 && (t.type = this.type), this.title !== void 0 && (t.title = this.title), this.rels && (t.rel = he(this.rels)), this.properties && (t.properties = this.properties.serialize()), this.height !== void 0 && (t.height = this.height), this.width !== void 0 && (t.width = this.width), this.duration !== void 0 && (t.duration = this.duration), this.bitrate !== void 0 && (t.bitrate = this.bitrate), this.languages && (t.language = this.languages), this.alternates && (t.alternate = this.alternates.serialize()), this.children && (t.children = this.children.serialize()), t;
806
804
  }
807
805
  /** MediaType of the linked resource. */
808
806
  get mediaType() {
@@ -811,196 +809,163 @@ class $ {
811
809
  /** Computes an absolute URL to the link, relative to the given `baseURL`.
812
810
  * If the link's `href` is already absolute, the `baseURL` is ignored.
813
811
  */
814
- toURL(e) {
815
- const t = this.href.replace(/^(\/)/, "");
816
- if (t.length === 0)
812
+ toURL(t) {
813
+ const e = this.href.replace(/^(\/)/, "");
814
+ if (e.length === 0)
817
815
  return;
818
- let i = e || "/";
819
- return i.startsWith("/") && (i = "file://" + i), new URL(t, i).href.replace(/^(file:\/\/)/, "");
816
+ let i = t || "/";
817
+ return i.startsWith("/") && (i = "file://" + i), new URL(e, i).href.replace(/^(file:\/\/)/, "");
820
818
  }
821
819
  /** List of URI template parameter keys, if the `Link` is templated. */
822
820
  get templateParameters() {
823
- return this.templated ? new Ee(this.href).parameters : /* @__PURE__ */ new Set();
821
+ return this.templated ? new yt(this.href).parameters : /* @__PURE__ */ new Set();
824
822
  }
825
823
  /** Expands the `Link`'s HREF by replacing URI template variables by the given parameters.
826
824
  * See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
827
825
  */
828
- expandTemplate(e) {
829
- return new $({
830
- href: new Ee(this.href).expand(e),
826
+ expandTemplate(t) {
827
+ return new B({
828
+ href: new yt(this.href).expand(t),
831
829
  templated: !1
832
830
  });
833
831
  }
834
832
  /**
835
833
  * Makes a copy of this [Link] after merging in the given additional other [properties].
836
834
  */
837
- addProperties(e) {
838
- var t;
839
- const i = $.deserialize(this.serialize());
840
- return i.properties = i.properties ? (t = i.properties) == null ? void 0 : t.add(e) : new E(e), i;
835
+ addProperties(t) {
836
+ var e;
837
+ const i = B.deserialize(this.serialize());
838
+ return i.properties = i.properties ? (e = i.properties) == null ? void 0 : e.add(t) : new E(t), i;
841
839
  }
842
840
  /**
843
841
  * Creates a [Locator] from a reading order [Link].
844
842
  */
845
843
  get locator() {
846
- let e = this.href.split("#");
847
- return new W({
848
- href: e.length > 0 && e[0] !== void 0 ? e[0] : this.href,
844
+ let t = this.href.split("#");
845
+ return new D({
846
+ href: t.length > 0 && t[0] !== void 0 ? t[0] : this.href,
849
847
  type: this.type ?? "",
850
848
  title: this.title,
851
849
  locations: new x({
852
- fragments: e.length > 1 && e[1] !== void 0 ? [e[1]] : []
850
+ fragments: t.length > 1 && t[1] !== void 0 ? [t[1]] : []
853
851
  })
854
852
  });
855
853
  }
856
854
  }
857
- class _ {
855
+ class V {
858
856
  /**
859
857
  * Creates a [Links].
860
858
  */
861
- constructor(e) {
862
- this.items = e;
859
+ constructor(t) {
860
+ this.items = t;
863
861
  }
864
862
  /**
865
863
  * Creates a list of [Link] from its RWPM JSON representation.
866
864
  */
867
- static deserialize(e) {
868
- if (e && e instanceof Array)
869
- return new _(
870
- e.map((t) => $.deserialize(t)).filter((t) => t !== void 0)
865
+ static deserialize(t) {
866
+ if (t && t instanceof Array)
867
+ return new V(
868
+ t.map((e) => B.deserialize(e)).filter((e) => e !== void 0)
871
869
  );
872
870
  }
873
871
  /**
874
872
  * Serializes an array of [Link] to its RWPM JSON representation.
875
873
  */
876
874
  serialize() {
877
- return this.items.map((e) => e.serialize());
875
+ return this.items.map((t) => t.serialize());
878
876
  }
879
877
  /** Finds the first link with the given relation. */
880
- findWithRel(e) {
881
- const t = (i) => i.rels && i.rels.has(e);
882
- return this.items.find(t);
878
+ findWithRel(t) {
879
+ const e = (i) => i.rels && i.rels.has(t);
880
+ return this.items.find(e);
883
881
  }
884
882
  /** Finds all the links with the given relation. */
885
- filterByRel(e) {
886
- const t = (i) => i.rels && i.rels.has(e);
887
- return this.items.filter(t);
883
+ filterByRel(t) {
884
+ const e = (i) => i.rels && i.rels.has(t);
885
+ return this.items.filter(e);
888
886
  }
889
887
  /** Finds the first link matching the given HREF. */
890
- findWithHref(e) {
891
- const t = (i) => i.href === e;
892
- return this.items.find(t);
888
+ findWithHref(t) {
889
+ const e = (i) => i.href === t;
890
+ return this.items.find(e);
893
891
  }
894
892
  /** Finds the index of the first link matching the given HREF. */
895
- findIndexWithHref(e) {
896
- const t = (i) => i.href === e;
897
- return this.items.findIndex(t);
893
+ findIndexWithHref(t) {
894
+ const e = (i) => i.href === t;
895
+ return this.items.findIndex(e);
898
896
  }
899
897
  /** Finds the first link matching the given media type. */
900
- findWithMediaType(e) {
901
- const t = (i) => i.mediaType.matches(e);
902
- return this.items.find(t);
898
+ findWithMediaType(t) {
899
+ const e = (i) => i.mediaType.matches(t);
900
+ return this.items.find(e);
903
901
  }
904
902
  /** Finds all the links matching the given media type. */
905
- filterByMediaType(e) {
906
- const t = (i) => i.mediaType.matches(e);
907
- return this.items.filter(t);
903
+ filterByMediaType(t) {
904
+ const e = (i) => i.mediaType.matches(t);
905
+ return this.items.filter(e);
908
906
  }
909
907
  /** Finds all the links matching any of the given media types. */
910
- filterByMediaTypes(e) {
911
- const t = (i) => {
912
- for (const s of e)
908
+ filterByMediaTypes(t) {
909
+ const e = (i) => {
910
+ for (const s of t)
913
911
  if (i.mediaType.matches(s))
914
912
  return !0;
915
913
  return !1;
916
914
  };
917
- return this.items.filter(t);
915
+ return this.items.filter(e);
918
916
  }
919
917
  /** Returns whether all the resources in the collection are audio clips. */
920
918
  everyIsAudio() {
921
- const e = (t) => t.mediaType.isAudio;
922
- return this.items.length > 0 && this.items.every(e);
919
+ const t = (e) => e.mediaType.isAudio;
920
+ return this.items.length > 0 && this.items.every(t);
923
921
  }
924
922
  /** Returns whether all the resources in the collection are bitmaps. */
925
923
  everyIsBitmap() {
926
- const e = (t) => t.mediaType.isBitmap;
927
- return this.items.length > 0 && this.items.every(e);
924
+ const t = (e) => e.mediaType.isBitmap;
925
+ return this.items.length > 0 && this.items.every(t);
928
926
  }
929
927
  /** Returns whether all the resources in the collection are HTML documents. */
930
928
  everyIsHTML() {
931
- const e = (t) => t.mediaType.isHTML;
932
- return this.items.length > 0 && this.items.every(e);
929
+ const t = (e) => e.mediaType.isHTML;
930
+ return this.items.length > 0 && this.items.every(t);
933
931
  }
934
932
  /** Returns whether all the resources in the collection are video clips. */
935
933
  everyIsVideo() {
936
- const e = (t) => t.mediaType.isVideo;
937
- return this.items.length > 0 && this.items.every(e);
934
+ const t = (e) => e.mediaType.isVideo;
935
+ return this.items.length > 0 && this.items.every(t);
938
936
  }
939
937
  /** Returns whether all the resources in the collection are matching any of the given media types. */
940
- everyMatchesMediaType(e) {
941
- return Array.isArray(e) ? this.items.length > 0 && this.items.every((t) => {
942
- for (const i of e)
943
- return t.mediaType.matches(i);
938
+ everyMatchesMediaType(t) {
939
+ return Array.isArray(t) ? this.items.length > 0 && this.items.every((e) => {
940
+ for (const i of t)
941
+ return e.mediaType.matches(i);
944
942
  return !1;
945
- }) : this.items.length > 0 && this.items.every((t) => t.mediaType.matches(e));
943
+ }) : this.items.length > 0 && this.items.every((e) => e.mediaType.matches(t));
946
944
  }
947
945
  filterLinksHasType() {
948
- return this.items.filter((e) => e.type);
949
- }
950
- }
951
- class se {
952
- /**
953
- * Creates a [Encryption].
954
- */
955
- constructor(e) {
956
- this.algorithm = e.algorithm, this.compression = e.compression, this.originalLength = e.originalLength, this.profile = e.profile, this.scheme = e.scheme;
957
- }
958
- /**
959
- * Parses a [Encryption] from its RWPM JSON representation.
960
- */
961
- static deserialize(e) {
962
- if (e && e.algorithm)
963
- return new se({
964
- algorithm: e.algorithm,
965
- compression: e.compression,
966
- originalLength: e.originalLength,
967
- profile: e.profile,
968
- scheme: e.scheme
969
- });
970
- }
971
- /**
972
- * Serializes a [Encryption] to its RWPM JSON representation.
973
- */
974
- serialize() {
975
- const e = { algorithm: this.algorithm };
976
- return this.compression !== void 0 && (e.compression = this.compression), this.originalLength !== void 0 && (e.originalLength = this.originalLength), this.profile !== void 0 && (e.profile = this.profile), this.scheme !== void 0 && (e.scheme = this.scheme), e;
946
+ return this.items.filter((t) => t.type);
977
947
  }
978
948
  }
979
- Object.defineProperty(E.prototype, "encryption", {
980
- get: function() {
981
- return se.deserialize(this.otherProperties.encrypted);
982
- }
983
- });
984
- class X {
949
+ class q {
985
950
  /**
986
951
  * Creates a [DomRange].
987
952
  */
988
- constructor(e) {
989
- this.cssSelector = e.cssSelector, this.textNodeIndex = e.textNodeIndex, this.charOffset = e.charOffset;
953
+ constructor(t) {
954
+ this.cssSelector = t.cssSelector, this.textNodeIndex = t.textNodeIndex, this.charOffset = t.charOffset;
990
955
  }
991
956
  /**
992
957
  * Parses a [DomRangePoint] from its RWPM JSON representation.
993
958
  */
994
- static deserialize(e) {
995
- if (!(e && e.cssSelector))
959
+ static deserialize(t) {
960
+ if (!(t && t.cssSelector))
996
961
  return;
997
- let t = C(e.textNodeIndex);
998
- if (t === void 0)
962
+ let e = C(t.textNodeIndex);
963
+ if (e === void 0)
999
964
  return;
1000
- let i = C(e.charOffset);
1001
- return i === void 0 && (i = C(e.offset)), new X({
1002
- cssSelector: e.cssSelector,
1003
- textNodeIndex: t,
965
+ let i = C(t.charOffset);
966
+ return i === void 0 && (i = C(t.offset)), new q({
967
+ cssSelector: t.cssSelector,
968
+ textNodeIndex: e,
1004
969
  charOffset: i
1005
970
  });
1006
971
  }
@@ -1008,39 +973,39 @@ class X {
1008
973
  * Serializes a [DomRangePoint] to its RWPM JSON representation.
1009
974
  */
1010
975
  serialize() {
1011
- const e = {
976
+ const t = {
1012
977
  cssSelector: this.cssSelector,
1013
978
  textNodeIndex: this.textNodeIndex
1014
979
  };
1015
- return this.charOffset !== void 0 && (e.charOffset = this.charOffset), e;
980
+ return this.charOffset !== void 0 && (t.charOffset = this.charOffset), t;
1016
981
  }
1017
982
  }
1018
- class ne {
983
+ class rt {
1019
984
  /**
1020
985
  * Creates a [DomRange].
1021
986
  */
1022
- constructor(e) {
1023
- this.start = e.start, this.end = e.end;
987
+ constructor(t) {
988
+ this.start = t.start, this.end = t.end;
1024
989
  }
1025
990
  /**
1026
991
  * Parses a [DomRange] from its RWPM JSON representation.
1027
992
  */
1028
- static deserialize(e) {
1029
- if (!e)
993
+ static deserialize(t) {
994
+ if (!t)
1030
995
  return;
1031
- let t = X.deserialize(e.start);
1032
- if (t)
1033
- return new ne({
1034
- start: t,
1035
- end: X.deserialize(e.end)
996
+ let e = q.deserialize(t.start);
997
+ if (e)
998
+ return new rt({
999
+ start: e,
1000
+ end: q.deserialize(t.end)
1036
1001
  });
1037
1002
  }
1038
1003
  /**
1039
1004
  * Serializes a [DomRange] to its RWPM JSON representation.
1040
1005
  */
1041
1006
  serialize() {
1042
- const e = { start: this.start.serialize() };
1043
- return this.end && (e.end = this.end.serialize()), e;
1007
+ const t = { start: this.start.serialize() };
1008
+ return this.end && (t.end = this.end.serialize()), t;
1044
1009
  }
1045
1010
  }
1046
1011
  x.prototype.getCssSelector = function() {
@@ -1053,7 +1018,7 @@ x.prototype.getPartialCfi = function() {
1053
1018
  };
1054
1019
  x.prototype.getDomRange = function() {
1055
1020
  var r;
1056
- return ne.deserialize((r = this.otherLocations) == null ? void 0 : r.get("domRange"));
1021
+ return rt.deserialize((r = this.otherLocations) == null ? void 0 : r.get("domRange"));
1057
1022
  };
1058
1023
  x.prototype.fragmentParameters = function() {
1059
1024
  return new Map(
@@ -1066,10 +1031,10 @@ x.prototype.fragmentParameters = function() {
1066
1031
  x.prototype.htmlId = function() {
1067
1032
  if (!this.fragments.length)
1068
1033
  return;
1069
- let r = this.fragments.find((e) => e.length && !e.includes("="));
1034
+ let r = this.fragments.find((t) => t.length && !t.includes("="));
1070
1035
  if (!r) {
1071
- const e = this.fragmentParameters();
1072
- e.has("id") ? r = e.get("id") : e.has("name") && (r = e.get("name"));
1036
+ const t = this.fragmentParameters();
1037
+ t.has("id") ? r = t.get("id") : t.has("name") && (r = t.get("name"));
1073
1038
  }
1074
1039
  return r != null && r.startsWith("#") ? r.slice(1) : r;
1075
1040
  };
@@ -1087,27 +1052,27 @@ x.prototype.space = function() {
1087
1052
  const r = this.fragmentParameters();
1088
1053
  if (!r.has("xywh"))
1089
1054
  return;
1090
- const e = r.get("xywh").split(",").map((t) => parseInt(t));
1091
- if (e.length === 4 && !e.some(isNaN))
1092
- return e;
1055
+ const t = r.get("xywh").split(",").map((e) => parseInt(e));
1056
+ if (t.length === 4 && !t.some(isNaN))
1057
+ return t;
1093
1058
  };
1094
- class oe {
1059
+ class st {
1095
1060
  /** Creates a [Price]. */
1096
- constructor(e) {
1097
- this.currency = e.currency, this.value = e.value;
1061
+ constructor(t) {
1062
+ this.currency = t.currency, this.value = t.value;
1098
1063
  }
1099
1064
  /**
1100
1065
  * Parses a [Price] from its RWPM JSON representation.
1101
1066
  */
1102
- static deserialize(e) {
1103
- if (!e)
1067
+ static deserialize(t) {
1068
+ if (!t)
1104
1069
  return;
1105
- let t = e.currency;
1106
- if (!(t && typeof t == "string" && t.length > 0))
1070
+ let e = t.currency;
1071
+ if (!(e && typeof e == "string" && e.length > 0))
1107
1072
  return;
1108
- let i = C(e.value);
1073
+ let i = C(t.value);
1109
1074
  if (i !== void 0)
1110
- return new oe({ currency: t, value: i });
1075
+ return new st({ currency: e, value: i });
1111
1076
  }
1112
1077
  /**
1113
1078
  * Serializes a [Price] to its RWPM JSON representation.
@@ -1116,125 +1081,125 @@ class oe {
1116
1081
  return { currency: this.currency, value: this.value };
1117
1082
  }
1118
1083
  }
1119
- class j {
1084
+ class $ {
1120
1085
  /** Creates a [Acquisition]. */
1121
- constructor(e) {
1122
- this.type = e.type, this.children = e.children;
1086
+ constructor(t) {
1087
+ this.type = t.type, this.children = t.children;
1123
1088
  }
1124
1089
  /**
1125
1090
  * Parses a [Acquisition] from its RWPM JSON representation.
1126
1091
  */
1127
- static deserialize(e) {
1128
- if (e && e.type)
1129
- return new j({
1130
- type: e.type,
1131
- children: j.deserializeArray(e.children)
1092
+ static deserialize(t) {
1093
+ if (t && t.type)
1094
+ return new $({
1095
+ type: t.type,
1096
+ children: $.deserializeArray(t.children)
1132
1097
  });
1133
1098
  }
1134
- static deserializeArray(e) {
1135
- if (e instanceof Array)
1136
- return e.map((t) => j.deserialize(t)).filter((t) => t !== void 0);
1099
+ static deserializeArray(t) {
1100
+ if (t instanceof Array)
1101
+ return t.map((e) => $.deserialize(e)).filter((e) => e !== void 0);
1137
1102
  }
1138
1103
  /**
1139
1104
  * Serializes a [Acquisition] to its RWPM JSON representation.
1140
1105
  */
1141
1106
  serialize() {
1142
- const e = { type: this.type };
1143
- return this.children && (e.children = this.children.map((t) => t.serialize())), e;
1107
+ const t = { type: this.type };
1108
+ return this.children && (t.children = this.children.map((e) => e.serialize())), t;
1144
1109
  }
1145
1110
  }
1146
- class ae {
1111
+ class nt {
1147
1112
  /** Creates a [Price]. */
1148
- constructor(e) {
1149
- this.total = e.total, this.position = e.position;
1113
+ constructor(t) {
1114
+ this.total = t.total, this.position = t.position;
1150
1115
  }
1151
1116
  /**
1152
1117
  * Parses a [Holds] from its RWPM JSON representation.
1153
1118
  */
1154
- static deserialize(e) {
1155
- if (e)
1156
- return new ae({
1157
- total: C(e.total),
1158
- position: C(e.position)
1119
+ static deserialize(t) {
1120
+ if (t)
1121
+ return new nt({
1122
+ total: C(t.total),
1123
+ position: C(t.position)
1159
1124
  });
1160
1125
  }
1161
1126
  /**
1162
1127
  * Serializes a [Holds] to its RWPM JSON representation.
1163
1128
  */
1164
1129
  serialize() {
1165
- const e = {};
1166
- return this.total !== void 0 && (e.total = this.total), this.position !== void 0 && (e.position = this.position), e;
1130
+ const t = {};
1131
+ return this.total !== void 0 && (t.total = this.total), this.position !== void 0 && (t.position = this.position), t;
1167
1132
  }
1168
1133
  }
1169
- class le {
1134
+ class ot {
1170
1135
  /** Creates a [Copies]. */
1171
- constructor(e) {
1172
- this.total = e.total, this.available = e.available;
1136
+ constructor(t) {
1137
+ this.total = t.total, this.available = t.available;
1173
1138
  }
1174
1139
  /**
1175
1140
  * Parses a [Copies] from its RWPM JSON representation.
1176
1141
  */
1177
- static deserialize(e) {
1178
- if (e)
1179
- return new le({
1180
- total: C(e.total),
1181
- available: C(e.available)
1142
+ static deserialize(t) {
1143
+ if (t)
1144
+ return new ot({
1145
+ total: C(t.total),
1146
+ available: C(t.available)
1182
1147
  });
1183
1148
  }
1184
1149
  /**
1185
1150
  * Serializes a [Copies] to its RWPM JSON representation.
1186
1151
  */
1187
1152
  serialize() {
1188
- const e = {};
1189
- return this.total !== void 0 && (e.total = this.total), this.available !== void 0 && (e.available = this.available), e;
1153
+ const t = {};
1154
+ return this.total !== void 0 && (t.total = this.total), this.available !== void 0 && (t.available = this.available), t;
1190
1155
  }
1191
1156
  }
1192
- class he {
1157
+ class at {
1193
1158
  /** Creates a [Availability]. */
1194
- constructor(e) {
1195
- this.state = e.state, this.since = e.since, this.until = e.until;
1159
+ constructor(t) {
1160
+ this.state = t.state, this.since = t.since, this.until = t.until;
1196
1161
  }
1197
1162
  /**
1198
1163
  * Parses a [Availability] from its RWPM JSON representation.
1199
1164
  */
1200
- static deserialize(e) {
1201
- if (e && e.state)
1202
- return new he({
1203
- state: e.state,
1204
- since: be(e.since),
1205
- until: be(e.until)
1165
+ static deserialize(t) {
1166
+ if (t && t.state)
1167
+ return new at({
1168
+ state: t.state,
1169
+ since: vt(t.since),
1170
+ until: vt(t.until)
1206
1171
  });
1207
1172
  }
1208
1173
  /**
1209
1174
  * Serializes a [Availability] to its RWPM JSON representation.
1210
1175
  */
1211
1176
  serialize() {
1212
- const e = { state: this.state };
1213
- return this.since !== void 0 && (e.since = this.since.toISOString()), this.until !== void 0 && (e.until = this.until.toISOString()), e;
1177
+ const t = { state: this.state };
1178
+ return this.since !== void 0 && (t.since = this.since.toISOString()), this.until !== void 0 && (t.until = this.until.toISOString()), t;
1214
1179
  }
1215
1180
  }
1216
1181
  E.prototype.getNumberOfItems = function() {
1217
1182
  return C(this.otherProperties.numberOfItems);
1218
1183
  };
1219
1184
  E.prototype.getPrice = function() {
1220
- return oe.deserialize(this.otherProperties.price);
1185
+ return st.deserialize(this.otherProperties.price);
1221
1186
  };
1222
1187
  E.prototype.getIndirectAcquisitions = function() {
1223
1188
  const r = this.otherProperties.indirectAcquisition;
1224
1189
  if (r && r instanceof Array)
1225
- return r.map((e) => j.deserialize(e)).filter((e) => e !== void 0);
1190
+ return r.map((t) => $.deserialize(t)).filter((t) => t !== void 0);
1226
1191
  };
1227
1192
  E.prototype.getHolds = function() {
1228
- return ae.deserialize(this.otherProperties.holds);
1193
+ return nt.deserialize(this.otherProperties.holds);
1229
1194
  };
1230
1195
  E.prototype.getCopies = function() {
1231
- return le.deserialize(this.otherProperties.copies);
1196
+ return ot.deserialize(this.otherProperties.copies);
1232
1197
  };
1233
1198
  E.prototype.getAvailability = function() {
1234
- return he.deserialize(this.otherProperties.availability);
1199
+ return at.deserialize(this.otherProperties.availability);
1235
1200
  };
1236
1201
  E.prototype.getAuthenticate = function() {
1237
- return $.deserialize(this.otherProperties.authenticate);
1202
+ return B.deserialize(this.otherProperties.authenticate);
1238
1203
  };
1239
1204
  E.prototype.getClipped = function() {
1240
1205
  return this.otherProperties.clipped;
@@ -1254,92 +1219,92 @@ E.prototype.getPage = function() {
1254
1219
  E.prototype.getSpread = function() {
1255
1220
  return this.otherProperties.spread || void 0;
1256
1221
  };
1257
- var D;
1222
+ var R;
1258
1223
  (function(r) {
1259
1224
  r.NONE = "none", r.DESCENDANT = "descendant", r.CHILD = "child";
1260
- })(D || (D = {}));
1261
- var A;
1225
+ })(R || (R = {}));
1226
+ var N;
1262
1227
  (function(r) {
1263
1228
  r.id = "id", r.class = "class", r.tag = "tag", r.attribute = "attribute", r.nthchild = "nthchild", r.nthoftype = "nthoftype";
1264
- })(A || (A = {}));
1265
- const dt = "CssSelectorGenerator";
1266
- function xe(r = "unknown problem", ...e) {
1267
- console.warn(`${dt}: ${r}`, ...e);
1229
+ })(N || (N = {}));
1230
+ const ce = "CssSelectorGenerator";
1231
+ function Et(r = "unknown problem", ...t) {
1232
+ console.warn(`${ce}: ${r}`, ...t);
1268
1233
  }
1269
- A.id, A.class, A.tag, A.attribute, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY;
1270
- function pt(r) {
1234
+ N.id, N.class, N.tag, N.attribute, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY;
1235
+ function ue(r) {
1271
1236
  return r instanceof RegExp;
1272
1237
  }
1273
- function ft(r) {
1238
+ function de(r) {
1274
1239
  return r.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".+");
1275
1240
  }
1276
- function mt(r) {
1277
- const e = r.map((t) => {
1278
- if (pt(t))
1279
- return (i) => t.test(i);
1280
- if (typeof t == "function")
1241
+ function pe(r) {
1242
+ const t = r.map((e) => {
1243
+ if (ue(e))
1244
+ return (i) => e.test(i);
1245
+ if (typeof e == "function")
1281
1246
  return (i) => {
1282
- const s = t(i);
1283
- return typeof s != "boolean" ? (xe("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It's result will be ignored.", t), !1) : s;
1247
+ const s = e(i);
1248
+ return typeof s != "boolean" ? (Et("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It's result will be ignored.", e), !1) : s;
1284
1249
  };
1285
- if (typeof t == "string") {
1286
- const i = new RegExp("^" + ft(t) + "$");
1250
+ if (typeof e == "string") {
1251
+ const i = new RegExp("^" + de(e) + "$");
1287
1252
  return (s) => i.test(s);
1288
1253
  }
1289
- return xe("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", t), () => !1;
1254
+ return Et("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", e), () => !1;
1290
1255
  });
1291
- return (t) => e.some((i) => i(t));
1256
+ return (e) => t.some((i) => i(e));
1292
1257
  }
1293
- const gt = "", yt = " > ", vt = " ";
1294
- D.NONE + "", D.NONE, D.DESCENDANT + "", D.DESCENDANT, D.CHILD + "", D.CHILD;
1295
- A.nthoftype, A.tag, A.id, A.class, A.attribute, A.nthchild;
1296
- mt([
1258
+ const fe = "", me = " > ", ge = " ";
1259
+ R.NONE + "", R.NONE, R.DESCENDANT + "", R.DESCENDANT, R.CHILD + "", R.CHILD;
1260
+ N.nthoftype, N.tag, N.id, N.class, N.attribute, N.nthchild;
1261
+ pe([
1297
1262
  "class",
1298
1263
  "id",
1299
1264
  // Angular attributes
1300
1265
  "ng-*"
1301
1266
  ]);
1302
- class K {
1267
+ class Y {
1303
1268
  }
1304
- function Se(r) {
1269
+ function bt(r) {
1305
1270
  return r.split("").reverse().join("");
1306
1271
  }
1307
- function Et(r, e, t) {
1308
- const i = Se(e);
1309
- return t.map((s) => {
1310
- const n = Math.max(0, s.end - e.length - s.errors), o = Se(r.slice(n, s.end));
1272
+ function ye(r, t, e) {
1273
+ const i = bt(t);
1274
+ return e.map((s) => {
1275
+ const n = Math.max(0, s.end - t.length - s.errors), o = bt(r.slice(n, s.end));
1311
1276
  return {
1312
- start: Be(o, i, s.errors).reduce((c, h) => s.end - h.end < c ? s.end - h.end : c, s.end),
1277
+ start: Ft(o, i, s.errors).reduce((c, h) => s.end - h.end < c ? s.end - h.end : c, s.end),
1313
1278
  end: s.end,
1314
1279
  errors: s.errors
1315
1280
  };
1316
1281
  });
1317
1282
  }
1318
- function Q(r) {
1283
+ function Z(r) {
1319
1284
  return (r | -r) >> 31 & 1;
1320
1285
  }
1321
- function we(r, e, t, i) {
1322
- let s = r.P[t], n = r.M[t];
1323
- const o = i >>> 31, l = e[t] | o, c = l | n, h = (l & s) + s ^ s | l;
1286
+ function xt(r, t, e, i) {
1287
+ let s = r.P[e], n = r.M[e];
1288
+ const o = i >>> 31, l = t[e] | o, c = l | n, h = (l & s) + s ^ s | l;
1324
1289
  let u = n | ~(h | s), p = s & h;
1325
- const d = Q(u & r.lastRowMask[t]) - Q(p & r.lastRowMask[t]);
1326
- return u <<= 1, p <<= 1, p |= o, u |= Q(i) - o, s = p | ~(c | u), n = u & c, r.P[t] = s, r.M[t] = n, d;
1290
+ const d = Z(u & r.lastRowMask[e]) - Z(p & r.lastRowMask[e]);
1291
+ return u <<= 1, p <<= 1, p |= o, u |= Z(i) - o, s = p | ~(c | u), n = u & c, r.P[e] = s, r.M[e] = n, d;
1327
1292
  }
1328
- function Be(r, e, t) {
1329
- if (e.length === 0)
1293
+ function Ft(r, t, e) {
1294
+ if (t.length === 0)
1330
1295
  return [];
1331
- t = Math.min(t, e.length);
1332
- const i = [], s = 32, n = Math.ceil(e.length / s) - 1, o = {
1296
+ e = Math.min(e, t.length);
1297
+ const i = [], s = 32, n = Math.ceil(t.length / s) - 1, o = {
1333
1298
  P: new Uint32Array(n + 1),
1334
1299
  M: new Uint32Array(n + 1),
1335
1300
  lastRowMask: new Uint32Array(n + 1)
1336
1301
  };
1337
- o.lastRowMask.fill(1 << 31), o.lastRowMask[n] = 1 << (e.length - 1) % s;
1302
+ o.lastRowMask.fill(1 << 31), o.lastRowMask[n] = 1 << (t.length - 1) % s;
1338
1303
  const l = new Uint32Array(n + 1), c = /* @__PURE__ */ new Map(), h = [];
1339
1304
  for (let d = 0; d < 256; d++)
1340
1305
  h.push(l);
1341
- for (let d = 0; d < e.length; d += 1) {
1342
- const f = e.charCodeAt(d);
1306
+ for (let d = 0; d < t.length; d += 1) {
1307
+ const f = t.charCodeAt(d);
1343
1308
  if (c.has(f))
1344
1309
  continue;
1345
1310
  const g = new Uint32Array(n + 1);
@@ -1348,17 +1313,17 @@ function Be(r, e, t) {
1348
1313
  g[m] = 0;
1349
1314
  for (let v = 0; v < s; v += 1) {
1350
1315
  const S = m * s + v;
1351
- if (S >= e.length)
1316
+ if (S >= t.length)
1352
1317
  continue;
1353
- e.charCodeAt(S) === f && (g[m] |= 1 << v);
1318
+ t.charCodeAt(S) === f && (g[m] |= 1 << v);
1354
1319
  }
1355
1320
  }
1356
1321
  }
1357
- let u = Math.max(0, Math.ceil(t / s) - 1);
1322
+ let u = Math.max(0, Math.ceil(e / s) - 1);
1358
1323
  const p = new Uint32Array(n + 1);
1359
1324
  for (let d = 0; d <= u; d += 1)
1360
1325
  p[d] = (d + 1) * s;
1361
- p[n] = e.length;
1326
+ p[n] = t.length;
1362
1327
  for (let d = 0; d <= u; d += 1)
1363
1328
  o.P[d] = -1, o.M[d] = 0;
1364
1329
  for (let d = 0; d < r.length; d += 1) {
@@ -1367,64 +1332,64 @@ function Be(r, e, t) {
1367
1332
  f < h.length ? g = h[f] : (g = c.get(f), typeof g > "u" && (g = l));
1368
1333
  let m = 0;
1369
1334
  for (let v = 0; v <= u; v += 1)
1370
- m = we(o, g, v, m), p[v] += m;
1371
- if (p[u] - m <= t && u < n && (g[u + 1] & 1 || m < 0)) {
1335
+ m = xt(o, g, v, m), p[v] += m;
1336
+ if (p[u] - m <= e && u < n && (g[u + 1] & 1 || m < 0)) {
1372
1337
  u += 1, o.P[u] = -1, o.M[u] = 0;
1373
1338
  let v;
1374
1339
  if (u === n) {
1375
- const S = e.length % s;
1340
+ const S = t.length % s;
1376
1341
  v = S === 0 ? s : S;
1377
1342
  } else
1378
1343
  v = s;
1379
- p[u] = p[u - 1] + v - m + we(o, g, u, m);
1344
+ p[u] = p[u - 1] + v - m + xt(o, g, u, m);
1380
1345
  } else
1381
- for (; u > 0 && p[u] >= t + s; )
1346
+ for (; u > 0 && p[u] >= e + s; )
1382
1347
  u -= 1;
1383
- u === n && p[u] <= t && (p[u] < t && i.splice(0, i.length), i.push({
1348
+ u === n && p[u] <= e && (p[u] < e && i.splice(0, i.length), i.push({
1384
1349
  start: -1,
1385
1350
  end: d + 1,
1386
1351
  errors: p[u]
1387
- }), t = p[u]);
1352
+ }), e = p[u]);
1388
1353
  }
1389
1354
  return i;
1390
1355
  }
1391
- function bt(r, e, t) {
1392
- const i = Be(r, e, t);
1393
- return Et(r, e, i);
1356
+ function ve(r, t, e) {
1357
+ const i = Ft(r, t, e);
1358
+ return ye(r, t, i);
1394
1359
  }
1395
- function $e(r, e, t) {
1360
+ function Bt(r, t, e) {
1396
1361
  let i = 0;
1397
1362
  const s = [];
1398
1363
  for (; i !== -1; )
1399
- i = r.indexOf(e, i), i !== -1 && (s.push({
1364
+ i = r.indexOf(t, i), i !== -1 && (s.push({
1400
1365
  start: i,
1401
- end: i + e.length,
1366
+ end: i + t.length,
1402
1367
  errors: 0
1403
1368
  }), i += 1);
1404
- return s.length > 0 ? s : bt(r, e, t);
1369
+ return s.length > 0 ? s : ve(r, t, e);
1405
1370
  }
1406
- function Te(r, e) {
1407
- return e.length === 0 || r.length === 0 ? 0 : 1 - $e(r, e, e.length)[0].errors / e.length;
1371
+ function St(r, t) {
1372
+ return t.length === 0 || r.length === 0 ? 0 : 1 - Bt(r, t, t.length)[0].errors / t.length;
1408
1373
  }
1409
- function xt(r, e, t = {}) {
1410
- if (e.length === 0)
1374
+ function Ee(r, t, e = {}) {
1375
+ if (t.length === 0)
1411
1376
  return null;
1412
- const i = Math.min(256, e.length / 2), s = $e(r, e, i);
1377
+ const i = Math.min(256, t.length / 2), s = Bt(r, t, i);
1413
1378
  if (s.length === 0)
1414
1379
  return null;
1415
1380
  const n = (l) => {
1416
- const d = 1 - l.errors / e.length, f = t.prefix ? Te(
1381
+ const d = 1 - l.errors / t.length, f = e.prefix ? St(
1417
1382
  r.slice(
1418
- Math.max(0, l.start - t.prefix.length),
1383
+ Math.max(0, l.start - e.prefix.length),
1419
1384
  l.start
1420
1385
  ),
1421
- t.prefix
1422
- ) : 1, g = t.suffix ? Te(
1423
- r.slice(l.end, l.end + t.suffix.length),
1424
- t.suffix
1386
+ e.prefix
1387
+ ) : 1, g = e.suffix ? St(
1388
+ r.slice(l.end, l.end + e.suffix.length),
1389
+ e.suffix
1425
1390
  ) : 1;
1426
1391
  let m = 1;
1427
- typeof t.hint == "number" && (m = 1 - Math.abs(l.start - t.hint) / r.length);
1392
+ typeof e.hint == "number" && (m = 1 - Math.abs(l.start - e.hint) / r.length);
1428
1393
  const v = 50 * d + 20 * f + 20 * g + 2 * m, S = 50 + 20 + 20 + 2;
1429
1394
  return v / S;
1430
1395
  }, o = s.map((l) => ({
@@ -1434,30 +1399,30 @@ function xt(r, e, t = {}) {
1434
1399
  }));
1435
1400
  return o.sort((l, c) => c.score - l.score), o[0];
1436
1401
  }
1437
- function ee(r, e, t) {
1438
- const i = t === 1 ? e : e - 1;
1402
+ function J(r, t, e) {
1403
+ const i = e === 1 ? t : t - 1;
1439
1404
  if (r.charAt(i).trim() !== "")
1440
- return e;
1405
+ return t;
1441
1406
  let s, n;
1442
- if (t === 2 ? (s = r.substring(0, e), n = s.trimEnd()) : (s = r.substring(e), n = s.trimStart()), !n.length)
1407
+ if (e === 2 ? (s = r.substring(0, t), n = s.trimEnd()) : (s = r.substring(t), n = s.trimStart()), !n.length)
1443
1408
  return -1;
1444
1409
  const o = s.length - n.length;
1445
- return t === 2 ? e - o : e + o;
1410
+ return e === 2 ? t - o : t + o;
1446
1411
  }
1447
- function Ce(r, e) {
1448
- const t = r.commonAncestorContainer.ownerDocument.createNodeIterator(
1412
+ function Tt(r, t) {
1413
+ const e = r.commonAncestorContainer.ownerDocument.createNodeIterator(
1449
1414
  r.commonAncestorContainer,
1450
1415
  NodeFilter.SHOW_TEXT
1451
- ), i = e === 1 ? r.startContainer : r.endContainer, s = e === 1 ? r.endContainer : r.startContainer;
1452
- let n = t.nextNode();
1416
+ ), i = t === 1 ? r.startContainer : r.endContainer, s = t === 1 ? r.endContainer : r.startContainer;
1417
+ let n = e.nextNode();
1453
1418
  for (; n && n !== i; )
1454
- n = t.nextNode();
1455
- e === 2 && (n = t.previousNode());
1419
+ n = e.nextNode();
1420
+ t === 2 && (n = e.previousNode());
1456
1421
  let o = -1;
1457
1422
  const l = () => {
1458
- if (n = e === 1 ? t.nextNode() : t.previousNode(), n) {
1459
- const c = n.textContent, h = e === 1 ? 0 : c.length;
1460
- o = ee(c, h, e);
1423
+ if (n = t === 1 ? e.nextNode() : e.previousNode(), n) {
1424
+ const c = n.textContent, h = t === 1 ? 0 : c.length;
1425
+ o = J(c, h, t);
1461
1426
  }
1462
1427
  };
1463
1428
  for (; n && o === -1 && n !== s; )
@@ -1466,85 +1431,85 @@ function Ce(r, e) {
1466
1431
  return { node: n, offset: o };
1467
1432
  throw new RangeError("No text nodes with non-whitespace text found in range");
1468
1433
  }
1469
- function St(r) {
1434
+ function be(r) {
1470
1435
  if (!r.toString().trim().length)
1471
1436
  throw new RangeError("Range contains no non-whitespace text");
1472
1437
  if (r.startContainer.nodeType !== Node.TEXT_NODE)
1473
1438
  throw new RangeError("Range startContainer is not a text node");
1474
1439
  if (r.endContainer.nodeType !== Node.TEXT_NODE)
1475
1440
  throw new RangeError("Range endContainer is not a text node");
1476
- const e = r.cloneRange();
1477
- let t = !1, i = !1;
1441
+ const t = r.cloneRange();
1442
+ let e = !1, i = !1;
1478
1443
  const s = {
1479
- start: ee(
1444
+ start: J(
1480
1445
  r.startContainer.textContent,
1481
1446
  r.startOffset,
1482
1447
  1
1483
1448
  /* Forwards */
1484
1449
  ),
1485
- end: ee(
1450
+ end: J(
1486
1451
  r.endContainer.textContent,
1487
1452
  r.endOffset,
1488
1453
  2
1489
1454
  /* Backwards */
1490
1455
  )
1491
1456
  };
1492
- if (s.start >= 0 && (e.setStart(r.startContainer, s.start), t = !0), s.end > 0 && (e.setEnd(r.endContainer, s.end), i = !0), t && i)
1493
- return e;
1494
- if (!t) {
1495
- const { node: n, offset: o } = Ce(
1496
- e,
1457
+ if (s.start >= 0 && (t.setStart(r.startContainer, s.start), e = !0), s.end > 0 && (t.setEnd(r.endContainer, s.end), i = !0), e && i)
1458
+ return t;
1459
+ if (!e) {
1460
+ const { node: n, offset: o } = Tt(
1461
+ t,
1497
1462
  1
1498
1463
  /* Forwards */
1499
1464
  );
1500
- n && o >= 0 && e.setStart(n, o);
1465
+ n && o >= 0 && t.setStart(n, o);
1501
1466
  }
1502
1467
  if (!i) {
1503
- const { node: n, offset: o } = Ce(
1504
- e,
1468
+ const { node: n, offset: o } = Tt(
1469
+ t,
1505
1470
  2
1506
1471
  /* Backwards */
1507
1472
  );
1508
- n && o > 0 && e.setEnd(n, o);
1473
+ n && o > 0 && t.setEnd(n, o);
1509
1474
  }
1510
- return e;
1475
+ return t;
1511
1476
  }
1512
- function ke(r) {
1513
- var e;
1477
+ function Ut(r) {
1478
+ var t;
1514
1479
  switch (r.nodeType) {
1515
1480
  case Node.ELEMENT_NODE:
1516
1481
  case Node.TEXT_NODE:
1517
- return ((e = r.textContent) == null ? void 0 : e.length) ?? 0;
1482
+ return ((t = r.textContent) == null ? void 0 : t.length) ?? 0;
1518
1483
  default:
1519
1484
  return 0;
1520
1485
  }
1521
1486
  }
1522
- function Pe(r) {
1523
- let e = r.previousSibling, t = 0;
1524
- for (; e; )
1525
- t += ke(e), e = e.previousSibling;
1526
- return t;
1487
+ function wt(r) {
1488
+ let t = r.previousSibling, e = 0;
1489
+ for (; t; )
1490
+ e += Ut(t), t = t.previousSibling;
1491
+ return e;
1527
1492
  }
1528
- function Ve(r, ...e) {
1529
- let t = e.shift();
1493
+ function kt(r, ...t) {
1494
+ let e = t.shift();
1530
1495
  const i = r.ownerDocument.createNodeIterator(
1531
1496
  r,
1532
1497
  NodeFilter.SHOW_TEXT
1533
1498
  ), s = [];
1534
1499
  let n = i.nextNode(), o, l = 0;
1535
- for (; t !== void 0 && n; )
1536
- o = n, l + o.data.length > t ? (s.push({ node: o, offset: t - l }), t = e.shift()) : (n = i.nextNode(), l += o.data.length);
1537
- for (; t !== void 0 && o && l === t; )
1538
- s.push({ node: o, offset: o.data.length }), t = e.shift();
1539
- if (t !== void 0)
1500
+ for (; e !== void 0 && n; )
1501
+ o = n, l + o.data.length > e ? (s.push({ node: o, offset: e - l }), e = t.shift()) : (n = i.nextNode(), l += o.data.length);
1502
+ for (; e !== void 0 && o && l === e; )
1503
+ s.push({ node: o, offset: o.data.length }), e = t.shift();
1504
+ if (e !== void 0)
1540
1505
  throw new RangeError("Offset exceeds text length");
1541
1506
  return s;
1542
1507
  }
1543
- class N {
1544
- constructor(e, t) {
1545
- if (t < 0)
1508
+ class A {
1509
+ constructor(t, e) {
1510
+ if (e < 0)
1546
1511
  throw new Error("Offset is invalid");
1547
- this.element = e, this.offset = t;
1512
+ this.element = t, this.offset = e;
1548
1513
  }
1549
1514
  /**
1550
1515
  * Return a copy of this position with offset relative to a given ancestor
@@ -1552,13 +1517,13 @@ class N {
1552
1517
  *
1553
1518
  * @param parent - Ancestor of `this.element`
1554
1519
  */
1555
- relativeTo(e) {
1556
- if (!e.contains(this.element))
1520
+ relativeTo(t) {
1521
+ if (!t.contains(this.element))
1557
1522
  throw new Error("Parent is not an ancestor of current element");
1558
- let t = this.element, i = this.offset;
1559
- for (; t !== e; )
1560
- i += Pe(t), t = t.parentElement;
1561
- return new N(t, i);
1523
+ let e = this.element, i = this.offset;
1524
+ for (; e !== t; )
1525
+ i += wt(e), e = e.parentElement;
1526
+ return new A(e, i);
1562
1527
  }
1563
1528
  /**
1564
1529
  * Resolve the position to a specific text node and offset within that node.
@@ -1577,34 +1542,34 @@ class N {
1577
1542
  *
1578
1543
  * @throws {RangeError}
1579
1544
  */
1580
- resolve(e = {}) {
1545
+ resolve(t = {}) {
1581
1546
  try {
1582
- return Ve(this.element, this.offset)[0];
1583
- } catch (t) {
1584
- if (this.offset === 0 && e.direction !== void 0) {
1547
+ return kt(this.element, this.offset)[0];
1548
+ } catch (e) {
1549
+ if (this.offset === 0 && t.direction !== void 0) {
1585
1550
  const i = document.createTreeWalker(
1586
1551
  this.element.getRootNode(),
1587
1552
  NodeFilter.SHOW_TEXT
1588
1553
  );
1589
1554
  i.currentNode = this.element;
1590
- const s = e.direction === 1, n = s ? i.nextNode() : i.previousNode();
1555
+ const s = t.direction === 1, n = s ? i.nextNode() : i.previousNode();
1591
1556
  if (!n)
1592
- throw t;
1557
+ throw e;
1593
1558
  return { node: n, offset: s ? 0 : n.data.length };
1594
1559
  } else
1595
- throw t;
1560
+ throw e;
1596
1561
  }
1597
1562
  }
1598
1563
  /**
1599
1564
  * Construct a `TextPosition` that refers to the `offset`th character within
1600
1565
  * `node`.
1601
1566
  */
1602
- static fromCharOffset(e, t) {
1603
- switch (e.nodeType) {
1567
+ static fromCharOffset(t, e) {
1568
+ switch (t.nodeType) {
1604
1569
  case Node.TEXT_NODE:
1605
- return N.fromPoint(e, t);
1570
+ return A.fromPoint(t, e);
1606
1571
  case Node.ELEMENT_NODE:
1607
- return new N(e, t);
1572
+ return new A(t, e);
1608
1573
  default:
1609
1574
  throw new Error("Node is not an element or text node");
1610
1575
  }
@@ -1615,23 +1580,23 @@ class N {
1615
1580
  * @param node
1616
1581
  * @param offset - Offset within the node
1617
1582
  */
1618
- static fromPoint(e, t) {
1619
- switch (e.nodeType) {
1583
+ static fromPoint(t, e) {
1584
+ switch (t.nodeType) {
1620
1585
  case Node.TEXT_NODE: {
1621
- if (t < 0 || t > e.data.length)
1586
+ if (e < 0 || e > t.data.length)
1622
1587
  throw new Error("Text node offset is out of range");
1623
- if (!e.parentElement)
1588
+ if (!t.parentElement)
1624
1589
  throw new Error("Text node has no parent");
1625
- const i = Pe(e) + t;
1626
- return new N(e.parentElement, i);
1590
+ const i = wt(t) + e;
1591
+ return new A(t.parentElement, i);
1627
1592
  }
1628
1593
  case Node.ELEMENT_NODE: {
1629
- if (t < 0 || t > e.childNodes.length)
1594
+ if (e < 0 || e > t.childNodes.length)
1630
1595
  throw new Error("Child node offset is out of range");
1631
1596
  let i = 0;
1632
- for (let s = 0; s < t; s++)
1633
- i += ke(e.childNodes[s]);
1634
- return new N(e, i);
1597
+ for (let s = 0; s < e; s++)
1598
+ i += Ut(t.childNodes[s]);
1599
+ return new A(t, i);
1635
1600
  }
1636
1601
  default:
1637
1602
  throw new Error("Point is not in an element or text node");
@@ -1639,18 +1604,18 @@ class N {
1639
1604
  }
1640
1605
  }
1641
1606
  class z {
1642
- constructor(e, t) {
1643
- this.start = e, this.end = t;
1607
+ constructor(t, e) {
1608
+ this.start = t, this.end = e;
1644
1609
  }
1645
1610
  /**
1646
1611
  * Create a new TextRange whose `start` and `end` are computed relative to
1647
1612
  * `element`. `element` must be an ancestor of both `start.element` and
1648
1613
  * `end.element`.
1649
1614
  */
1650
- relativeTo(e) {
1615
+ relativeTo(t) {
1651
1616
  return new z(
1652
- this.start.relativeTo(e),
1653
- this.end.relativeTo(e)
1617
+ this.start.relativeTo(t),
1618
+ this.end.relativeTo(t)
1654
1619
  );
1655
1620
  }
1656
1621
  /**
@@ -1663,63 +1628,63 @@ class z {
1663
1628
  * May throw if the `start` or `end` positions cannot be resolved to a range.
1664
1629
  */
1665
1630
  toRange() {
1666
- let e, t;
1667
- this.start.element === this.end.element && this.start.offset <= this.end.offset ? [e, t] = Ve(
1631
+ let t, e;
1632
+ this.start.element === this.end.element && this.start.offset <= this.end.offset ? [t, e] = kt(
1668
1633
  this.start.element,
1669
1634
  this.start.offset,
1670
1635
  this.end.offset
1671
- ) : (e = this.start.resolve({
1636
+ ) : (t = this.start.resolve({
1672
1637
  direction: 1
1673
1638
  /* FORWARDS */
1674
- }), t = this.end.resolve({
1639
+ }), e = this.end.resolve({
1675
1640
  direction: 2
1676
1641
  /* BACKWARDS */
1677
1642
  }));
1678
1643
  const i = new Range();
1679
- return i.setStart(e.node, e.offset), i.setEnd(t.node, t.offset), i;
1644
+ return i.setStart(t.node, t.offset), i.setEnd(e.node, e.offset), i;
1680
1645
  }
1681
1646
  /**
1682
1647
  * Create a TextRange from a (DOM) Range
1683
1648
  */
1684
- static fromRange(e) {
1685
- const t = N.fromPoint(
1686
- e.startContainer,
1687
- e.startOffset
1688
- ), i = N.fromPoint(e.endContainer, e.endOffset);
1689
- return new z(t, i);
1649
+ static fromRange(t) {
1650
+ const e = A.fromPoint(
1651
+ t.startContainer,
1652
+ t.startOffset
1653
+ ), i = A.fromPoint(t.endContainer, t.endOffset);
1654
+ return new z(e, i);
1690
1655
  }
1691
1656
  /**
1692
1657
  * Create a TextRange representing the `start`th to `end`th characters in
1693
1658
  * `root`
1694
1659
  */
1695
- static fromOffsets(e, t, i) {
1660
+ static fromOffsets(t, e, i) {
1696
1661
  return new z(
1697
- new N(e, t),
1698
- new N(e, i)
1662
+ new A(t, e),
1663
+ new A(t, i)
1699
1664
  );
1700
1665
  }
1701
1666
  /**
1702
1667
  * Return a new Range representing `range` trimmed of any leading or trailing
1703
1668
  * whitespace
1704
1669
  */
1705
- static trimmedRange(e) {
1706
- return St(z.fromRange(e).toRange());
1670
+ static trimmedRange(t) {
1671
+ return be(z.fromRange(t).toRange());
1707
1672
  }
1708
1673
  }
1709
- class G {
1710
- constructor(e, t, i) {
1711
- this.root = e, this.start = t, this.end = i;
1674
+ class _ {
1675
+ constructor(t, e, i) {
1676
+ this.root = t, this.start = e, this.end = i;
1712
1677
  }
1713
- static fromRange(e, t) {
1714
- const i = z.fromRange(t).relativeTo(e);
1715
- return new G(
1716
- e,
1678
+ static fromRange(t, e) {
1679
+ const i = z.fromRange(e).relativeTo(t);
1680
+ return new _(
1681
+ t,
1717
1682
  i.start.offset,
1718
1683
  i.end.offset
1719
1684
  );
1720
1685
  }
1721
- static fromSelector(e, t) {
1722
- return new G(e, t.start, t.end);
1686
+ static fromSelector(t, e) {
1687
+ return new _(t, e.start, e.end);
1723
1688
  }
1724
1689
  toSelector() {
1725
1690
  return {
@@ -1732,28 +1697,28 @@ class G {
1732
1697
  return z.fromOffsets(this.root, this.start, this.end).toRange();
1733
1698
  }
1734
1699
  }
1735
- class Y {
1700
+ class X {
1736
1701
  /**
1737
1702
  * @param root - A root element from which to anchor.
1738
1703
  */
1739
- constructor(e, t, i = {}) {
1740
- this.root = e, this.exact = t, this.context = i;
1704
+ constructor(t, e, i = {}) {
1705
+ this.root = t, this.exact = e, this.context = i;
1741
1706
  }
1742
1707
  /**
1743
1708
  * Create a `TextQuoteAnchor` from a range.
1744
1709
  *
1745
1710
  * Will throw if `range` does not contain any text nodes.
1746
1711
  */
1747
- static fromRange(e, t) {
1748
- const i = e.textContent, s = z.fromRange(t).relativeTo(e), n = s.start.offset, o = s.end.offset, l = 32;
1749
- return new Y(e, i.slice(n, o), {
1712
+ static fromRange(t, e) {
1713
+ const i = t.textContent, s = z.fromRange(e).relativeTo(t), n = s.start.offset, o = s.end.offset, l = 32;
1714
+ return new X(t, i.slice(n, o), {
1750
1715
  prefix: i.slice(Math.max(0, n - l), n),
1751
1716
  suffix: i.slice(o, Math.min(i.length, o + l))
1752
1717
  });
1753
1718
  }
1754
- static fromSelector(e, t) {
1755
- const { prefix: i, suffix: s } = t;
1756
- return new Y(e, t.exact, { prefix: i, suffix: s });
1719
+ static fromSelector(t, e) {
1720
+ const { prefix: i, suffix: s } = e;
1721
+ return new X(t, e.exact, { prefix: i, suffix: s });
1757
1722
  }
1758
1723
  toSelector() {
1759
1724
  return {
@@ -1763,30 +1728,30 @@ class Y {
1763
1728
  suffix: this.context.suffix
1764
1729
  };
1765
1730
  }
1766
- toRange(e = {}) {
1767
- return this.toPositionAnchor(e).toRange();
1731
+ toRange(t = {}) {
1732
+ return this.toPositionAnchor(t).toRange();
1768
1733
  }
1769
- toPositionAnchor(e = {}) {
1770
- const t = this.root.textContent, i = xt(t, this.exact, {
1734
+ toPositionAnchor(t = {}) {
1735
+ const e = this.root.textContent, i = Ee(e, this.exact, {
1771
1736
  ...this.context,
1772
- hint: e.hint
1737
+ hint: t.hint
1773
1738
  });
1774
1739
  if (!i)
1775
1740
  throw new Error("Quote not found");
1776
- return new G(this.root, i.start, i.end);
1741
+ return new _(this.root, i.start, i.end);
1777
1742
  }
1778
1743
  }
1779
- function wt(r) {
1780
- const e = r.tagName.toUpperCase();
1781
- return e === "IMG" || e === "VIDEO" || e === "AUDIO" || e === "IFRAME" || e === "OBJECT" || e === "EMBED" || e === "CANVAS";
1744
+ function xe(r) {
1745
+ const t = r.tagName.toUpperCase();
1746
+ return t === "IMG" || t === "VIDEO" || t === "AUDIO" || t === "IFRAME" || t === "OBJECT" || t === "EMBED" || t === "CANVAS";
1782
1747
  }
1783
- function ce(r, e) {
1748
+ function lt(r, t) {
1784
1749
  try {
1785
- const t = e.locations, i = e.text;
1750
+ const e = t.locations, i = t.text;
1786
1751
  if (i && i.highlight) {
1787
1752
  let s;
1788
- t && t.getCssSelector() && (s = r.querySelector(t.getCssSelector())), s || (s = r.body);
1789
- const n = new Y(s, i.highlight, {
1753
+ e && e.getCssSelector() && (s = r.querySelector(e.getCssSelector())), s || (s = r.body);
1754
+ const n = new X(s, i.highlight, {
1790
1755
  prefix: i.before,
1791
1756
  suffix: i.after
1792
1757
  });
@@ -1796,28 +1761,28 @@ function ce(r, e) {
1796
1761
  return console.warn("Quote not found:", n), null;
1797
1762
  }
1798
1763
  }
1799
- if (t) {
1764
+ if (e) {
1800
1765
  let s = null;
1801
- if (!s && t.getCssSelector() && (s = r.querySelector(t.getCssSelector())), !s && t.fragments) {
1802
- for (const n of t.fragments)
1766
+ if (!s && e.getCssSelector() && (s = r.querySelector(e.getCssSelector())), !s && e.fragments) {
1767
+ for (const n of e.fragments)
1803
1768
  if (s = r.getElementById(n), s)
1804
1769
  break;
1805
1770
  }
1806
1771
  if (s) {
1807
1772
  const n = r.createRange();
1808
- return s.childNodes.length === 0 || wt(s) ? (n.selectNode(s), n) : (n.setStartBefore(s), n.setEndAfter(s), n);
1773
+ return s.childNodes.length === 0 || xe(s) ? (n.selectNode(s), n) : (n.setStartBefore(s), n.setEndAfter(s), n);
1809
1774
  }
1810
1775
  }
1811
- } catch (t) {
1812
- console.error(t);
1776
+ } catch (e) {
1777
+ console.error(e);
1813
1778
  }
1814
1779
  return null;
1815
1780
  }
1816
- function Tt(r, e) {
1817
- let t = r.getClientRects();
1818
- t.length || r.commonAncestorContainer.nodeType === Node.ELEMENT_NODE && (t = r.commonAncestorContainer.getClientRects());
1781
+ function Se(r, t) {
1782
+ let e = r.getClientRects();
1783
+ e.length || r.commonAncestorContainer.nodeType === Node.ELEMENT_NODE && (e = r.commonAncestorContainer.getClientRects());
1819
1784
  const i = 1, s = [];
1820
- for (const h of t)
1785
+ for (const h of e)
1821
1786
  s.push({
1822
1787
  bottom: h.bottom,
1823
1788
  height: h.height,
@@ -1826,11 +1791,11 @@ function Tt(r, e) {
1826
1791
  top: h.top,
1827
1792
  width: h.width
1828
1793
  });
1829
- const n = je(
1794
+ const n = $t(
1830
1795
  s,
1831
1796
  i,
1832
- e
1833
- ), o = Pt(n, i), l = He(o), c = 2 * 2;
1797
+ t
1798
+ ), o = we(n, i), l = Ht(o), c = 2 * 2;
1834
1799
  for (let h = l.length - 1; h >= 0; h--) {
1835
1800
  const u = l[h];
1836
1801
  if (!(u.width * u.height > c))
@@ -1841,78 +1806,78 @@ function Tt(r, e) {
1841
1806
  }
1842
1807
  return l;
1843
1808
  }
1844
- function je(r, e, t) {
1809
+ function $t(r, t, e) {
1845
1810
  for (let i = 0; i < r.length; i++)
1846
1811
  for (let s = i + 1; s < r.length; s++) {
1847
1812
  const n = r[i], o = r[s];
1848
1813
  if (n === o)
1849
1814
  continue;
1850
- const l = M(n.top, o.top, e) && M(n.bottom, o.bottom, e), c = M(n.left, o.left, e) && M(n.right, o.right, e);
1851
- if ((c && !t || l && !c) && qe(n, o, e)) {
1852
- const d = r.filter((g) => g !== n && g !== o), f = Ct(n, o);
1853
- return d.push(f), je(
1815
+ const l = M(n.top, o.top, t) && M(n.bottom, o.bottom, t), c = M(n.left, o.left, t) && M(n.right, o.right, t);
1816
+ if ((c && !e || l && !c) && jt(n, o, t)) {
1817
+ const d = r.filter((g) => g !== n && g !== o), f = Te(n, o);
1818
+ return d.push(f), $t(
1854
1819
  d,
1855
- e,
1856
- t
1820
+ t,
1821
+ e
1857
1822
  );
1858
1823
  }
1859
1824
  }
1860
1825
  return r;
1861
1826
  }
1862
- function Ct(r, e) {
1863
- const t = Math.min(r.left, e.left), i = Math.max(r.right, e.right), s = Math.min(r.top, e.top), n = Math.max(r.bottom, e.bottom);
1827
+ function Te(r, t) {
1828
+ const e = Math.min(r.left, t.left), i = Math.max(r.right, t.right), s = Math.min(r.top, t.top), n = Math.max(r.bottom, t.bottom);
1864
1829
  return {
1865
1830
  bottom: n,
1866
1831
  height: n - s,
1867
- left: t,
1832
+ left: e,
1868
1833
  right: i,
1869
1834
  top: s,
1870
- width: i - t
1835
+ width: i - e
1871
1836
  };
1872
1837
  }
1873
- function Pt(r, e) {
1874
- const t = new Set(r);
1838
+ function we(r, t) {
1839
+ const e = new Set(r);
1875
1840
  for (const i of r) {
1876
1841
  if (!(i.width > 1 && i.height > 1)) {
1877
- t.delete(i);
1842
+ e.delete(i);
1878
1843
  continue;
1879
1844
  }
1880
1845
  for (const n of r)
1881
- if (i !== n && t.has(n) && At(n, i, e)) {
1882
- t.delete(i);
1846
+ if (i !== n && e.has(n) && Ce(n, i, t)) {
1847
+ e.delete(i);
1883
1848
  break;
1884
1849
  }
1885
1850
  }
1886
- return Array.from(t);
1851
+ return Array.from(e);
1887
1852
  }
1888
- function At(r, e, t) {
1889
- return H(r, e.left, e.top, t) && H(r, e.right, e.top, t) && H(r, e.left, e.bottom, t) && H(r, e.right, e.bottom, t);
1853
+ function Ce(r, t, e) {
1854
+ return H(r, t.left, t.top, e) && H(r, t.right, t.top, e) && H(r, t.left, t.bottom, e) && H(r, t.right, t.bottom, e);
1890
1855
  }
1891
- function H(r, e, t, i) {
1892
- return (r.left < e || M(r.left, e, i)) && (r.right > e || M(r.right, e, i)) && (r.top < t || M(r.top, t, i)) && (r.bottom > t || M(r.bottom, t, i));
1856
+ function H(r, t, e, i) {
1857
+ return (r.left < t || M(r.left, t, i)) && (r.right > t || M(r.right, t, i)) && (r.top < e || M(r.top, e, i)) && (r.bottom > e || M(r.bottom, e, i));
1893
1858
  }
1894
- function He(r) {
1895
- for (let e = 0; e < r.length; e++)
1896
- for (let t = e + 1; t < r.length; t++) {
1897
- const i = r[e], s = r[t];
1898
- if (i !== s && qe(i, s, -1)) {
1859
+ function Ht(r) {
1860
+ for (let t = 0; t < r.length; t++)
1861
+ for (let e = t + 1; e < r.length; e++) {
1862
+ const i = r[t], s = r[e];
1863
+ if (i !== s && jt(i, s, -1)) {
1899
1864
  let n = [], o;
1900
- const l = Ae(i, s);
1865
+ const l = Ct(i, s);
1901
1866
  if (l.length === 1)
1902
1867
  n = l, o = i;
1903
1868
  else {
1904
- const h = Ae(s, i);
1869
+ const h = Ct(s, i);
1905
1870
  l.length < h.length ? (n = l, o = i) : (n = h, o = s);
1906
1871
  }
1907
1872
  const c = r.filter((h) => h !== o);
1908
- return Array.prototype.push.apply(c, n), He(c);
1873
+ return Array.prototype.push.apply(c, n), Ht(c);
1909
1874
  }
1910
1875
  }
1911
1876
  return r;
1912
1877
  }
1913
- function Ae(r, e) {
1914
- const t = Mt(e, r);
1915
- if (t.height === 0 || t.width === 0)
1878
+ function Ct(r, t) {
1879
+ const e = Pe(t, r);
1880
+ if (e.height === 0 || e.width === 0)
1916
1881
  return [r];
1917
1882
  const i = [];
1918
1883
  {
@@ -1920,7 +1885,7 @@ function Ae(r, e) {
1920
1885
  bottom: r.bottom,
1921
1886
  height: 0,
1922
1887
  left: r.left,
1923
- right: t.left,
1888
+ right: e.left,
1924
1889
  top: r.top,
1925
1890
  width: 0
1926
1891
  };
@@ -1928,10 +1893,10 @@ function Ae(r, e) {
1928
1893
  }
1929
1894
  {
1930
1895
  const s = {
1931
- bottom: t.top,
1896
+ bottom: e.top,
1932
1897
  height: 0,
1933
- left: t.left,
1934
- right: t.right,
1898
+ left: e.left,
1899
+ right: e.right,
1935
1900
  top: r.top,
1936
1901
  width: 0
1937
1902
  };
@@ -1941,9 +1906,9 @@ function Ae(r, e) {
1941
1906
  const s = {
1942
1907
  bottom: r.bottom,
1943
1908
  height: 0,
1944
- left: t.left,
1945
- right: t.right,
1946
- top: t.bottom,
1909
+ left: e.left,
1910
+ right: e.right,
1911
+ top: e.bottom,
1947
1912
  width: 0
1948
1913
  };
1949
1914
  s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
@@ -1952,7 +1917,7 @@ function Ae(r, e) {
1952
1917
  const s = {
1953
1918
  bottom: r.bottom,
1954
1919
  height: 0,
1955
- left: t.right,
1920
+ left: e.right,
1956
1921
  right: r.right,
1957
1922
  top: r.top,
1958
1923
  width: 0
@@ -1961,111 +1926,111 @@ function Ae(r, e) {
1961
1926
  }
1962
1927
  return i;
1963
1928
  }
1964
- function Mt(r, e) {
1965
- const t = Math.max(r.left, e.left), i = Math.min(r.right, e.right), s = Math.max(r.top, e.top), n = Math.min(r.bottom, e.bottom);
1929
+ function Pe(r, t) {
1930
+ const e = Math.max(r.left, t.left), i = Math.min(r.right, t.right), s = Math.max(r.top, t.top), n = Math.min(r.bottom, t.bottom);
1966
1931
  return {
1967
1932
  bottom: n,
1968
1933
  height: Math.max(0, n - s),
1969
- left: t,
1934
+ left: e,
1970
1935
  right: i,
1971
1936
  top: s,
1972
- width: Math.max(0, i - t)
1937
+ width: Math.max(0, i - e)
1973
1938
  };
1974
1939
  }
1975
- function qe(r, e, t) {
1976
- return (r.left < e.right || t >= 0 && M(r.left, e.right, t)) && (e.left < r.right || t >= 0 && M(e.left, r.right, t)) && (r.top < e.bottom || t >= 0 && M(r.top, e.bottom, t)) && (e.top < r.bottom || t >= 0 && M(e.top, r.bottom, t));
1940
+ function jt(r, t, e) {
1941
+ return (r.left < t.right || e >= 0 && M(r.left, t.right, e)) && (t.left < r.right || e >= 0 && M(t.left, r.right, e)) && (r.top < t.bottom || e >= 0 && M(r.top, t.bottom, e)) && (t.top < r.bottom || e >= 0 && M(t.top, r.bottom, e));
1977
1942
  }
1978
- function M(r, e, t) {
1979
- return Math.abs(r - e) <= t;
1943
+ function M(r, t, e) {
1944
+ return Math.abs(r - t) <= e;
1980
1945
  }
1981
- function _e(r) {
1982
- const e = {}, t = r.document.documentElement.style;
1946
+ function Vt(r) {
1947
+ const t = {}, e = r.document.documentElement.style;
1983
1948
  for (const i in r.document.documentElement.style)
1984
- Object.hasOwn(t, i) && !Number.isNaN(Number.parseInt(i)) && (e[t[i]] = t.getPropertyValue(t[i]));
1985
- return e;
1949
+ Object.hasOwn(e, i) && !Number.isNaN(Number.parseInt(i)) && (t[e[i]] = e.getPropertyValue(e[i]));
1950
+ return t;
1986
1951
  }
1987
- function Nt(r, e) {
1988
- const t = _e(r);
1989
- Object.keys(t).forEach((i) => {
1990
- e.hasOwnProperty(i) || ue(r, i);
1991
- }), Object.entries(e).forEach(([i, s]) => {
1992
- t[i] !== s && Z(r, i, s);
1952
+ function Ne(r, t) {
1953
+ const e = Vt(r);
1954
+ Object.keys(e).forEach((i) => {
1955
+ t.hasOwnProperty(i) || ht(r, i);
1956
+ }), Object.entries(t).forEach(([i, s]) => {
1957
+ e[i] !== s && G(r, i, s);
1993
1958
  });
1994
1959
  }
1995
- function Me(r, e) {
1996
- return r.document.documentElement.style.getPropertyValue(e);
1960
+ function Pt(r, t) {
1961
+ return r.document.documentElement.style.getPropertyValue(t);
1997
1962
  }
1998
- function Z(r, e, t) {
1999
- r.document.documentElement.style.setProperty(e, t);
1963
+ function G(r, t, e) {
1964
+ r.document.documentElement.style.setProperty(t, e);
2000
1965
  }
2001
- function ue(r, e) {
2002
- r.document.documentElement.style.removeProperty(e);
1966
+ function ht(r, t) {
1967
+ r.document.documentElement.style.removeProperty(t);
2003
1968
  }
2004
- const Ot = (r) => {
1969
+ const Me = (r) => {
2005
1970
  if (r.startsWith("rgb")) {
2006
- const e = r.match(/rgb\((\d+),\s(\d+),\s(\d+)(?:,\s(\d+))?\)/);
2007
- if (e)
1971
+ const t = r.match(/rgb\((\d+),\s(\d+),\s(\d+)(?:,\s(\d+))?\)/);
1972
+ if (t)
2008
1973
  return {
2009
- r: parseInt(e[1], 10),
2010
- g: parseInt(e[2], 10),
2011
- b: parseInt(e[3], 10),
2012
- a: e[4] ? parseInt(e[4], 10) / 255 : 1
1974
+ r: parseInt(t[1], 10),
1975
+ g: parseInt(t[2], 10),
1976
+ b: parseInt(t[3], 10),
1977
+ a: t[4] ? parseInt(t[4], 10) / 255 : 1
2013
1978
  };
2014
1979
  } else if (r.startsWith("#")) {
2015
- const e = r.slice(1);
2016
- if (e.length === 3 || e.length === 4)
1980
+ const t = r.slice(1);
1981
+ if (t.length === 3 || t.length === 4)
2017
1982
  return {
2018
- r: parseInt(e[0] + e[0], 16) / 255,
2019
- g: parseInt(e[1] + e[1], 16) / 255,
2020
- b: parseInt(e[2] + e[2], 16) / 255,
2021
- a: e.length === 4 ? parseInt(e[3] + e[3], 16) / 255 : 1
1983
+ r: parseInt(t[0] + t[0], 16) / 255,
1984
+ g: parseInt(t[1] + t[1], 16) / 255,
1985
+ b: parseInt(t[2] + t[2], 16) / 255,
1986
+ a: t.length === 4 ? parseInt(t[3] + t[3], 16) / 255 : 1
2022
1987
  };
2023
- if (e.length === 6 || e.length === 8)
1988
+ if (t.length === 6 || t.length === 8)
2024
1989
  return {
2025
- r: parseInt(e[0] + e[1], 16) / 255,
2026
- g: parseInt(e[2] + e[3], 16) / 255,
2027
- b: parseInt(e[4] + e[5], 16) / 255,
2028
- a: e.length === 8 ? parseInt(e[6] + e[7], 16) / 255 : 1
1990
+ r: parseInt(t[0] + t[1], 16) / 255,
1991
+ g: parseInt(t[2] + t[3], 16) / 255,
1992
+ b: parseInt(t[4] + t[5], 16) / 255,
1993
+ a: t.length === 8 ? parseInt(t[6] + t[7], 16) / 255 : 1
2029
1994
  };
2030
1995
  }
2031
1996
  return { r: 0, g: 0, b: 0, a: 1 };
2032
- }, It = (r) => 0.2126 * r.r * r.a + 0.7152 * r.g * r.a + 0.0722 * r.b * r.a, Lt = (r) => {
2033
- const e = Ot(r);
2034
- return It(e) < 128;
1997
+ }, Ae = (r) => 0.2126 * r.r * r.a + 0.7152 * r.g * r.a + 0.0722 * r.b * r.a, Oe = (r) => {
1998
+ const t = Me(r);
1999
+ return Ae(t) < 128;
2035
2000
  };
2036
- var Rt = /* @__PURE__ */ ((r) => (r.Wrap = "wrap", r.Viewport = "viewport", r.Bounds = "bounds", r.Page = "page", r))(Rt || {}), Dt = /* @__PURE__ */ ((r) => (r.Boxes = "boxes", r.Bounds = "bounds", r))(Dt || {});
2037
- const zt = () => "Highlight" in window, Ne = ["IMG", "IMAGE", "AUDIO", "VIDEO", "SVG"];
2038
- class Wt {
2001
+ var Ie = /* @__PURE__ */ ((r) => (r.Wrap = "wrap", r.Viewport = "viewport", r.Bounds = "bounds", r.Page = "page", r))(Ie || {}), Le = /* @__PURE__ */ ((r) => (r.Boxes = "boxes", r.Bounds = "bounds", r))(Le || {});
2002
+ const Re = () => "Highlight" in window, Nt = ["IMG", "IMAGE", "AUDIO", "VIDEO", "SVG"];
2003
+ class ze {
2039
2004
  /**
2040
2005
  * Creates a DecorationGroup object
2041
2006
  * @param id Unique HTML ID-adhering name of the group
2042
2007
  * @param name Human-readable name of the group
2043
2008
  */
2044
- constructor(e, t, i, s) {
2045
- this.wnd = e, this.comms = t, this.id = i, this.name = s, this.items = [], this.lastItemId = 0, this.container = void 0, this.activateable = !1, this.experimentalHighlights = !1, this.currentRender = 0, zt() && (this.experimentalHighlights = !0, this.notTextFlag = /* @__PURE__ */ new Map());
2009
+ constructor(t, e, i, s) {
2010
+ this.wnd = t, this.comms = e, this.id = i, this.name = s, this.items = [], this.lastItemId = 0, this.container = void 0, this.activateable = !1, this.experimentalHighlights = !1, this.currentRender = 0, Re() && (this.experimentalHighlights = !0, this.notTextFlag = /* @__PURE__ */ new Map());
2046
2011
  }
2047
2012
  get activeable() {
2048
2013
  return this.activateable;
2049
2014
  }
2050
- set activeable(e) {
2051
- this.activateable = e;
2015
+ set activeable(t) {
2016
+ this.activateable = t;
2052
2017
  }
2053
2018
  /**
2054
2019
  * Adds a new decoration to the group.
2055
2020
  * @param decoration Decoration to add
2056
2021
  */
2057
- add(e) {
2022
+ add(t) {
2058
2023
  var o, l, c, h;
2059
- const t = `${this.id}-${this.lastItemId++}`, i = ce(this.wnd.document, e.locator);
2024
+ const e = `${this.id}-${this.lastItemId++}`, i = lt(this.wnd.document, t.locator);
2060
2025
  if (!i) {
2061
- this.comms.log("Can't locate DOM range for decoration", e);
2026
+ this.comms.log("Can't locate DOM range for decoration", t);
2062
2027
  return;
2063
2028
  }
2064
2029
  const s = i.commonAncestorContainer;
2065
- s.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (Ne.includes(s.nodeName.toUpperCase()) && ((o = this.notTextFlag) == null || o.set(t, !0)), s.querySelector(Ne.join(", ").toLowerCase()) && ((l = this.notTextFlag) == null || l.set(t, !0)), (((c = s.textContent) == null ? void 0 : c.trim()) || "").length === 0 && ((h = this.notTextFlag) == null || h.set(t, !0)));
2030
+ s.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (Nt.includes(s.nodeName.toUpperCase()) && ((o = this.notTextFlag) == null || o.set(e, !0)), s.querySelector(Nt.join(", ").toLowerCase()) && ((l = this.notTextFlag) == null || l.set(e, !0)), (((c = s.textContent) == null ? void 0 : c.trim()) || "").length === 0 && ((h = this.notTextFlag) == null || h.set(e, !0)));
2066
2031
  const n = {
2067
- decoration: e,
2068
- id: t,
2032
+ decoration: t,
2033
+ id: e,
2069
2034
  range: i
2070
2035
  };
2071
2036
  this.items.push(n), this.layout(n), this.renderLayout([n]);
@@ -2074,13 +2039,13 @@ class Wt {
2074
2039
  * Removes the decoration with given ID from the group.
2075
2040
  * @param identifier ID of item to remove
2076
2041
  */
2077
- remove(e) {
2042
+ remove(t) {
2078
2043
  var s, n;
2079
- const t = this.items.findIndex((o) => o.decoration.id === e);
2080
- if (t < 0)
2044
+ const e = this.items.findIndex((o) => o.decoration.id === t);
2045
+ if (e < 0)
2081
2046
  return;
2082
- const i = this.items[t];
2083
- if (this.items.splice(t, 1), i.clickableElements = void 0, i.container && (i.container.remove(), i.container = void 0), this.experimentalHighlights && !((s = this.notTextFlag) != null && s.has(i.id))) {
2047
+ const i = this.items[e];
2048
+ if (this.items.splice(e, 1), i.clickableElements = void 0, i.container && (i.container.remove(), i.container = void 0), this.experimentalHighlights && !((s = this.notTextFlag) != null && s.has(i.id))) {
2084
2049
  const o = this.wnd.CSS.highlights.get(this.id);
2085
2050
  o == null || o.delete(i.range);
2086
2051
  }
@@ -2090,68 +2055,68 @@ class Wt {
2090
2055
  * Notifies that the given decoration was modified and needs to be updated.
2091
2056
  * @param decoration Decoration to update
2092
2057
  */
2093
- update(e) {
2094
- this.remove(e.id), this.add(e);
2058
+ update(t) {
2059
+ this.remove(t.id), this.add(t);
2095
2060
  }
2096
2061
  /**
2097
2062
  * Removes all decorations from this group.
2098
2063
  */
2099
2064
  clear() {
2100
- var e;
2101
- this.clearContainer(), this.items.length = 0, (e = this.notTextFlag) == null || e.clear();
2065
+ var t;
2066
+ this.clearContainer(), this.items.length = 0, (t = this.notTextFlag) == null || t.clear();
2102
2067
  }
2103
2068
  /**
2104
2069
  * Recreates the decoration elements.
2105
2070
  * To be called after reflowing the resource, for example.
2106
2071
  */
2107
2072
  requestLayout() {
2108
- this.wnd.cancelAnimationFrame(this.currentRender), this.clearContainer(), this.items.forEach((e) => this.layout(e)), this.renderLayout(this.items);
2073
+ this.wnd.cancelAnimationFrame(this.currentRender), this.clearContainer(), this.items.forEach((t) => this.layout(t)), this.renderLayout(this.items);
2109
2074
  }
2110
- experimentalLayout(e) {
2075
+ experimentalLayout(t) {
2111
2076
  var s, n;
2112
- const [t, i] = this.requireContainer(!0);
2113
- i.add(e.range), t.innerHTML = `
2077
+ const [e, i] = this.requireContainer(!0);
2078
+ i.add(t.range), e.innerHTML = `
2114
2079
  ::highlight(${this.id}) {
2115
2080
  color: black;
2116
- background-color: ${((n = (s = e.decoration) == null ? void 0 : s.style) == null ? void 0 : n.tint) ?? "yellow"};
2081
+ background-color: ${((n = (s = t.decoration) == null ? void 0 : s.style) == null ? void 0 : n.tint) ?? "yellow"};
2117
2082
  }`;
2118
2083
  }
2119
2084
  /**
2120
2085
  * Layouts a single DecorationItem.
2121
2086
  * @param item
2122
2087
  */
2123
- layout(e) {
2088
+ layout(t) {
2124
2089
  var g, m, v, S, O;
2125
- if (this.experimentalHighlights && !((g = this.notTextFlag) != null && g.has(e.id)))
2126
- return this.experimentalLayout(e);
2127
- const t = this.wnd.document.createElement("div");
2128
- t.setAttribute("id", e.id), t.style.setProperty("pointer-events", "none");
2090
+ if (this.experimentalHighlights && !((g = this.notTextFlag) != null && g.has(t.id)))
2091
+ return this.experimentalLayout(t);
2092
+ const e = this.wnd.document.createElement("div");
2093
+ e.setAttribute("id", t.id), e.style.setProperty("pointer-events", "none");
2129
2094
  const i = this.wnd.innerWidth, s = parseInt(
2130
2095
  getComputedStyle(this.wnd.document.documentElement).getPropertyValue(
2131
2096
  "column-count"
2132
2097
  )
2133
2098
  ), n = i / (s || 1), o = this.wnd.document.scrollingElement, l = o.scrollLeft, c = o.scrollTop, h = (y, b, I) => {
2134
- var de, pe, fe, me, ge, ye;
2135
- if (y.style.position = "absolute", ((pe = (de = e.decoration) == null ? void 0 : de.style) == null ? void 0 : pe.width) === "viewport") {
2099
+ var ct, ut, dt, pt, ft, mt;
2100
+ if (y.style.position = "absolute", ((ut = (ct = t.decoration) == null ? void 0 : ct.style) == null ? void 0 : ut.width) === "viewport") {
2136
2101
  y.style.width = `${i}px`, y.style.height = `${b.height}px`;
2137
- let J = Math.floor(b.left / i) * i;
2138
- y.style.left = `${J + l}px`, y.style.top = `${b.top + c}px`;
2139
- } else if (((me = (fe = e.decoration) == null ? void 0 : fe.style) == null ? void 0 : me.width) === "bounds")
2102
+ let K = Math.floor(b.left / i) * i;
2103
+ y.style.left = `${K + l}px`, y.style.top = `${b.top + c}px`;
2104
+ } else if (((pt = (dt = t.decoration) == null ? void 0 : dt.style) == null ? void 0 : pt.width) === "bounds")
2140
2105
  y.style.width = `${I.width}px`, y.style.height = `${b.height}px`, y.style.left = `${I.left + l}px`, y.style.top = `${b.top + c}px`;
2141
- else if (((ye = (ge = e.decoration) == null ? void 0 : ge.style) == null ? void 0 : ye.width) === "page") {
2106
+ else if (((mt = (ft = t.decoration) == null ? void 0 : ft.style) == null ? void 0 : mt.width) === "page") {
2142
2107
  y.style.width = `${n}px`, y.style.height = `${b.height}px`;
2143
- let J = Math.floor(b.left / n) * n;
2144
- y.style.left = `${J + l}px`, y.style.top = `${b.top + c}px`;
2108
+ let K = Math.floor(b.left / n) * n;
2109
+ y.style.left = `${K + l}px`, y.style.top = `${b.top + c}px`;
2145
2110
  } else
2146
2111
  y.style.width = `${b.width}px`, y.style.height = `${b.height}px`, y.style.left = `${b.left + l}px`, y.style.top = `${b.top + c}px`;
2147
- }, u = e.range.getBoundingClientRect();
2112
+ }, u = t.range.getBoundingClientRect();
2148
2113
  let p = this.wnd.document.createElement("template");
2149
- const d = Me(this.wnd, "--USER__appearance") === "readium-night-on" || Lt(Me(this.wnd, "--USER__backgroundColor"));
2114
+ const d = Pt(this.wnd, "--USER__appearance") === "readium-night-on" || Oe(Pt(this.wnd, "--USER__backgroundColor"));
2150
2115
  p.innerHTML = `
2151
2116
  <div
2152
2117
  class="r2-highlight-0"
2153
2118
  style="${[
2154
- `background-color: ${((v = (m = e.decoration) == null ? void 0 : m.style) == null ? void 0 : v.tint) ?? "yellow"} !important`,
2119
+ `background-color: ${((v = (m = t.decoration) == null ? void 0 : m.style) == null ? void 0 : v.tint) ?? "yellow"} !important`,
2155
2120
  //"opacity: 0.3 !important",
2156
2121
  `mix-blend-mode: ${d ? "exclusion" : "multiply"} !important`,
2157
2122
  "opacity: 1 !important",
@@ -2161,45 +2126,45 @@ class Wt {
2161
2126
  </div>
2162
2127
  `.trim();
2163
2128
  const f = p.content.firstElementChild;
2164
- if (((O = (S = e.decoration) == null ? void 0 : S.style) == null ? void 0 : O.layout) === "bounds") {
2129
+ if (((O = (S = t.decoration) == null ? void 0 : S.style) == null ? void 0 : O.layout) === "bounds") {
2165
2130
  const y = f.cloneNode(!0);
2166
- y.style.setProperty("pointer-events", "none"), h(y, u, u), t.append(y);
2131
+ y.style.setProperty("pointer-events", "none"), h(y, u, u), e.append(y);
2167
2132
  } else {
2168
- let y = Tt(
2169
- e.range,
2133
+ let y = Se(
2134
+ t.range,
2170
2135
  !0
2171
2136
  // doNotMergeHorizontallyAlignedRects
2172
2137
  );
2173
2138
  y = y.sort((b, I) => b.top < I.top ? -1 : b.top > I.top ? 1 : 0);
2174
2139
  for (let b of y) {
2175
2140
  const I = f.cloneNode(!0);
2176
- I.style.setProperty("pointer-events", "none"), h(I, b, u), t.append(I);
2141
+ I.style.setProperty("pointer-events", "none"), h(I, b, u), e.append(I);
2177
2142
  }
2178
2143
  }
2179
- e.container = t, e.clickableElements = Array.from(
2180
- t.querySelectorAll("[data-activable='1']")
2181
- ), e.clickableElements.length || (e.clickableElements = Array.from(t.children));
2144
+ t.container = e, t.clickableElements = Array.from(
2145
+ e.querySelectorAll("[data-activable='1']")
2146
+ ), t.clickableElements.length || (t.clickableElements = Array.from(e.children));
2182
2147
  }
2183
- renderLayout(e) {
2148
+ renderLayout(t) {
2184
2149
  this.wnd.cancelAnimationFrame(this.currentRender), this.currentRender = this.wnd.requestAnimationFrame(() => {
2185
- if (e = e.filter((i) => {
2150
+ if (t = t.filter((i) => {
2186
2151
  var s;
2187
2152
  return !this.experimentalHighlights || !!((s = this.notTextFlag) != null && s.has(i.id));
2188
- }), !e || e.length === 0)
2153
+ }), !t || t.length === 0)
2189
2154
  return;
2190
- this.requireContainer().append(...e.map((i) => i.container).filter((i) => !!i));
2155
+ this.requireContainer().append(...t.map((i) => i.container).filter((i) => !!i));
2191
2156
  });
2192
2157
  }
2193
2158
  /**
2194
2159
  * Returns the group container element, after making sure it exists.
2195
2160
  * @returns Group's container
2196
2161
  */
2197
- requireContainer(e = !1) {
2198
- if (e) {
2199
- let t;
2200
- this.wnd.document.getElementById(`${this.id}-style`) ? t = this.wnd.document.getElementById(`${this.id}-style`) : (t = this.wnd.document.createElement("style"), t.dataset.readium = "true", t.id = `${this.id}-style`, this.wnd.document.head.appendChild(t));
2162
+ requireContainer(t = !1) {
2163
+ if (t) {
2164
+ let e;
2165
+ this.wnd.document.getElementById(`${this.id}-style`) ? e = this.wnd.document.getElementById(`${this.id}-style`) : (e = this.wnd.document.createElement("style"), e.dataset.readium = "true", e.id = `${this.id}-style`, this.wnd.document.head.appendChild(e));
2201
2166
  let i;
2202
- return this.wnd.CSS.highlights.has(this.id) ? i = this.wnd.CSS.highlights.get(this.id) : (i = new this.wnd.Highlight(), this.wnd.CSS.highlights.set(this.id, i)), [t, i];
2167
+ return this.wnd.CSS.highlights.has(this.id) ? i = this.wnd.CSS.highlights.get(this.id) : (i = new this.wnd.Highlight(), this.wnd.CSS.highlights.set(this.id, i)), [e, i];
2203
2168
  }
2204
2169
  return this.container || (this.container = this.wnd.document.createElement("div"), this.container.setAttribute("id", this.id), this.container.dataset.group = this.name, this.container.dataset.readium = "true", this.container.style.setProperty("pointer-events", "none"), this.container.style.display = "contents", this.wnd.document.body.append(this.container)), this.container;
2205
2170
  }
@@ -2210,26 +2175,26 @@ class Wt {
2210
2175
  this.experimentalHighlights && this.wnd.CSS.highlights.delete(this.id), this.container && (this.container.remove(), this.container = void 0);
2211
2176
  }
2212
2177
  }
2213
- const Xe = class te extends K {
2178
+ const qt = class Q extends Y {
2214
2179
  constructor() {
2215
2180
  super(...arguments), this.resizeFrame = 0, this.lastGroupId = 0, this.groups = /* @__PURE__ */ new Map(), this.handleResizer = this.handleResize.bind(this);
2216
2181
  }
2217
2182
  cleanup() {
2218
- this.groups.forEach((e) => e.clear()), this.groups.clear();
2183
+ this.groups.forEach((t) => t.clear()), this.groups.clear();
2219
2184
  }
2220
2185
  handleResize() {
2221
2186
  this.wnd.clearTimeout(this.resizeFrame), this.resizeFrame = this.wnd.setTimeout(() => {
2222
- this.groups.forEach((e) => {
2223
- e.experimentalHighlights || e.requestLayout();
2187
+ this.groups.forEach((t) => {
2188
+ t.experimentalHighlights || t.requestLayout();
2224
2189
  });
2225
2190
  }, 50);
2226
2191
  }
2227
- mount(e, t) {
2228
- return this.wnd = e, t.register("decorate", te.moduleName, (i, s) => {
2192
+ mount(t, e) {
2193
+ return this.wnd = t, e.register("decorate", Q.moduleName, (i, s) => {
2229
2194
  const n = i;
2230
- n.decoration && n.decoration.locator && (n.decoration.locator = W.deserialize(n.decoration.locator)), this.groups.has(n.group) || this.groups.set(n.group, new Wt(
2231
- e,
2195
+ n.decoration && n.decoration.locator && (n.decoration.locator = D.deserialize(n.decoration.locator)), this.groups.has(n.group) || this.groups.set(n.group, new ze(
2232
2196
  t,
2197
+ e,
2233
2198
  `readium-decoration-${this.lastGroupId++}`,
2234
2199
  n.group
2235
2200
  ));
@@ -2249,15 +2214,15 @@ const Xe = class te extends K {
2249
2214
  break;
2250
2215
  }
2251
2216
  s(!0);
2252
- }), this.resizeObserver = new ResizeObserver(() => e.requestAnimationFrame(() => this.handleResize())), this.resizeObserver.observe(e.document.body), e.addEventListener("orientationchange", this.handleResizer), e.addEventListener("resize", this.handleResizer), t.log("Decorator Mounted"), !0;
2217
+ }), this.resizeObserver = new ResizeObserver(() => t.requestAnimationFrame(() => this.handleResize())), this.resizeObserver.observe(t.document.body), t.addEventListener("orientationchange", this.handleResizer), t.addEventListener("resize", this.handleResizer), e.log("Decorator Mounted"), !0;
2253
2218
  }
2254
- unmount(e, t) {
2255
- return e.removeEventListener("orientationchange", this.handleResizer), e.removeEventListener("resize", this.handleResizer), t.unregisterAll(te.moduleName), this.resizeObserver.disconnect(), this.cleanup(), t.log("Decorator Unmounted"), !0;
2219
+ unmount(t, e) {
2220
+ return t.removeEventListener("orientationchange", this.handleResizer), t.removeEventListener("resize", this.handleResizer), e.unregisterAll(Q.moduleName), this.resizeObserver.disconnect(), this.cleanup(), e.log("Decorator Unmounted"), !0;
2256
2221
  }
2257
2222
  };
2258
- Xe.moduleName = "decorator";
2259
- let Ft = Xe;
2260
- const Oe = "readium-snapper-style", Ge = class ie extends K {
2223
+ qt.moduleName = "decorator";
2224
+ let De = qt;
2225
+ const Mt = "readium-snapper-style", _t = class tt extends Y {
2261
2226
  constructor() {
2262
2227
  super(...arguments), this.protected = !1;
2263
2228
  }
@@ -2268,62 +2233,62 @@ const Oe = "readium-snapper-style", Ge = class ie extends K {
2268
2233
  user-select: ${this.protected ? "none" : "auto"};
2269
2234
  }`;
2270
2235
  }
2271
- mount(e, t) {
2272
- const i = e.document.createElement("style");
2273
- return i.dataset.readium = "true", i.id = Oe, i.textContent = this.buildStyles(), e.document.head.appendChild(i), t.register("protect", ie.moduleName, (s, n) => {
2236
+ mount(t, e) {
2237
+ const i = t.document.createElement("style");
2238
+ return i.dataset.readium = "true", i.id = Mt, i.textContent = this.buildStyles(), t.document.head.appendChild(i), e.register("protect", tt.moduleName, (s, n) => {
2274
2239
  this.protected = !0, i.textContent = this.buildStyles(), n(!0);
2275
- }), t.register("unprotect", ie.moduleName, (s, n) => {
2240
+ }), e.register("unprotect", tt.moduleName, (s, n) => {
2276
2241
  this.protected = !1, i.textContent = this.buildStyles(), n(!0);
2277
- }), t.log("Snapper Mounted"), !0;
2242
+ }), e.log("Snapper Mounted"), !0;
2278
2243
  }
2279
- unmount(e, t) {
2244
+ unmount(t, e) {
2280
2245
  var i;
2281
- return (i = e.document.getElementById(Oe)) == null || i.remove(), t.log("Snapper Unmounted"), !0;
2246
+ return (i = t.document.getElementById(Mt)) == null || i.remove(), e.log("Snapper Unmounted"), !0;
2282
2247
  }
2283
2248
  };
2284
- Ge.moduleName = "snapper";
2285
- let Ye = Ge;
2286
- function F(r) {
2249
+ _t.moduleName = "snapper";
2250
+ let Xt = _t;
2251
+ function W(r) {
2287
2252
  return r.document.body.dir.toLowerCase() === "rtl";
2288
2253
  }
2289
- function Ze(r) {
2254
+ function Gt(r) {
2290
2255
  return parseInt(
2291
2256
  r.getComputedStyle(
2292
2257
  r.document.documentElement
2293
2258
  ).getPropertyValue("column-count")
2294
2259
  );
2295
2260
  }
2296
- function Ie(r) {
2297
- const e = getComputedStyle(r), t = parseFloat(e.paddingTop || "0"), i = parseFloat(e.paddingBottom || "0");
2298
- return r.clientHeight - t - i;
2261
+ function At(r) {
2262
+ const t = getComputedStyle(r), e = parseFloat(t.paddingTop || "0"), i = parseFloat(t.paddingBottom || "0");
2263
+ return r.clientHeight - e - i;
2299
2264
  }
2300
- function Le(r) {
2301
- const e = Ze(r);
2302
- if (!e)
2265
+ function Ot(r) {
2266
+ const t = Gt(r);
2267
+ if (!t)
2303
2268
  return !1;
2304
- const t = r.document.querySelectorAll("div[id^='readium-virtual-page']");
2305
- for (const h of t)
2269
+ const e = r.document.querySelectorAll("div[id^='readium-virtual-page']");
2270
+ for (const h of e)
2306
2271
  h.remove();
2307
- const i = t.length, s = r.document.scrollingElement.scrollWidth, n = r.visualViewport.width, l = Math.round(s / n * e) % e, c = e === 1 || l === 0 ? 0 : e - l;
2272
+ const i = e.length, s = r.document.scrollingElement.scrollWidth, n = r.visualViewport.width, l = Math.round(s / n * t) % t, c = t === 1 || l === 0 ? 0 : t - l;
2308
2273
  if (c > 0)
2309
2274
  for (let h = 0; h < c; h++) {
2310
2275
  const u = r.document.createElement("div");
2311
- u.setAttribute("id", `readium-virtual-page-${h}`), u.dataset.readium = "true", CSS.supports("break-before", "column") ? u.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (u.style.breakInside = "avoid-column"), u.style.height = Ie(r.document.documentElement) + "px"), u.innerHTML = "&#8203;", r.document.body.appendChild(u);
2276
+ u.setAttribute("id", `readium-virtual-page-${h}`), u.dataset.readium = "true", CSS.supports("break-before", "column") ? u.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (u.style.breakInside = "avoid-column"), u.style.height = At(r.document.documentElement) + "px"), u.innerHTML = "&#8203;", r.document.body.appendChild(u);
2312
2277
  }
2313
2278
  return i !== c;
2314
2279
  }
2315
- function Ut(r) {
2316
- const e = r.document.createElement("style");
2317
- e.appendChild(r.document.createTextNode("*{}")), r.document.body.appendChild(e), r.document.body.removeChild(e);
2280
+ function We(r) {
2281
+ const t = r.document.createElement("style");
2282
+ t.appendChild(r.document.createTextNode("*{}")), r.document.body.appendChild(t), r.document.body.removeChild(t);
2318
2283
  }
2319
- function Bt(r) {
2284
+ function Fe(r) {
2320
2285
  return r < 0.5 ? 2 * r * r : -1 + (4 - 2 * r) * r;
2321
2286
  }
2322
- function w(r) {
2323
- const e = r.getSelection();
2324
- e && e.removeAllRanges();
2287
+ function T(r) {
2288
+ const t = r.getSelection();
2289
+ t && t.removeAllRanges();
2325
2290
  }
2326
- const $t = [
2291
+ const Be = [
2327
2292
  "a",
2328
2293
  "audio",
2329
2294
  "button",
@@ -2337,15 +2302,15 @@ const $t = [
2337
2302
  "textarea",
2338
2303
  "video"
2339
2304
  ];
2340
- function Ke(r) {
2341
- var e;
2342
- return $t.indexOf(r.nodeName.toLowerCase()) !== -1 || r.hasAttribute("contenteditable") && ((e = r.getAttribute("contenteditable")) == null ? void 0 : e.toLowerCase()) !== "false" ? r : r.parentElement ? Ke(r.parentElement) : null;
2305
+ function Yt(r) {
2306
+ var t;
2307
+ return Be.indexOf(r.nodeName.toLowerCase()) !== -1 || r.hasAttribute("contenteditable") && ((t = r.getAttribute("contenteditable")) == null ? void 0 : t.toLowerCase()) !== "false" ? r : r.parentElement ? Yt(r.parentElement) : null;
2343
2308
  }
2344
- function Je(r, e) {
2345
- const t = Qe(r, r.document.body, e), i = r._readium_cssSelectorGenerator.getCssSelector(t, {
2309
+ function Kt(r, t) {
2310
+ const e = Zt(r, r.document.body, t), i = r._readium_cssSelectorGenerator.getCssSelector(e, {
2346
2311
  selectors: ["tag", "id", "class", "nthchild", "nthoftype", "attribute"]
2347
2312
  });
2348
- return new W({
2313
+ return new D({
2349
2314
  href: "#",
2350
2315
  type: "application/xhtml+xml",
2351
2316
  locations: new x({
@@ -2353,41 +2318,41 @@ function Je(r, e) {
2353
2318
  ["cssSelector", i]
2354
2319
  ])
2355
2320
  }),
2356
- text: new k({
2357
- highlight: t.textContent || void 0
2321
+ text: new U({
2322
+ highlight: e.textContent || void 0
2358
2323
  })
2359
2324
  });
2360
2325
  }
2361
- function Qe(r, e, t) {
2362
- for (var i = 0; i < e.children.length; i++) {
2363
- const s = e.children[i];
2364
- if (!jt(s) && kt(r, s, t))
2365
- return Vt(r, s) ? s : Qe(r, s, t);
2326
+ function Zt(r, t, e) {
2327
+ for (var i = 0; i < t.children.length; i++) {
2328
+ const s = t.children[i];
2329
+ if (!$e(s) && Ue(r, s, e))
2330
+ return ke(r, s) ? s : Zt(r, s, e);
2366
2331
  }
2367
- return e;
2332
+ return t;
2368
2333
  }
2369
- function kt(r, e, t) {
2370
- if (e === document.body || e === document.documentElement)
2334
+ function Ue(r, t, e) {
2335
+ if (t === document.body || t === document.documentElement)
2371
2336
  return !0;
2372
2337
  if (!document || !document.documentElement || !document.body)
2373
2338
  return !1;
2374
- const i = e.getBoundingClientRect();
2375
- return t ? i.bottom > 0 && i.top < r.innerHeight : i.right > 0 && i.left < r.innerWidth;
2376
- }
2377
- function Vt(r, e) {
2378
- const t = e.getBoundingClientRect();
2379
- return t.top >= 0 && t.left >= 0 && t.bottom <= r.innerHeight && t.right <= r.innerWidth;
2380
- }
2381
- function jt(r) {
2382
- const e = getComputedStyle(r);
2383
- if (e) {
2384
- const t = e.getPropertyValue("display");
2385
- if (t != "block" && t != "list-item" || e.getPropertyValue("opacity") === "0")
2339
+ const i = t.getBoundingClientRect();
2340
+ return e ? i.bottom > 0 && i.top < r.innerHeight : i.right > 0 && i.left < r.innerWidth;
2341
+ }
2342
+ function ke(r, t) {
2343
+ const e = t.getBoundingClientRect();
2344
+ return e.top >= 0 && e.left >= 0 && e.bottom <= r.innerHeight && e.right <= r.innerWidth;
2345
+ }
2346
+ function $e(r) {
2347
+ const t = getComputedStyle(r);
2348
+ if (t) {
2349
+ const e = t.getPropertyValue("display");
2350
+ if (e != "block" && e != "list-item" || t.getPropertyValue("opacity") === "0")
2386
2351
  return !0;
2387
2352
  }
2388
2353
  return !1;
2389
2354
  }
2390
- const Re = "readium-column-snapper-style", Ht = 200, et = class T extends Ye {
2355
+ const It = "readium-column-snapper-style", He = 200, Jt = class w extends Xt {
2391
2356
  constructor() {
2392
2357
  super(...arguments), this.shakeTimeout = 0, this.snappingCancelled = !1, this.alreadyScrollLeft = 0, this.overscroll = 0, this.cachedScrollWidth = 0, this.touchState = 0, this.startingX = void 0, this.endingX = void 0, this.onTouchStarter = this.onTouchStart.bind(this), this.onTouchEnder = this.onTouchEnd.bind(this), this.onWidthChanger = this.onWidthChange.bind(this), this.onTouchMover = this.onTouchMove.bind(this);
2393
2358
  }
@@ -2397,12 +2362,12 @@ const Re = "readium-column-snapper-style", Ht = 200, et = class T extends Ye {
2397
2362
  scrollOffset() {
2398
2363
  return this.doc().scrollLeft > 0 ? this.doc().scrollLeft : this.alreadyScrollLeft;
2399
2364
  }
2400
- snapOffset(e) {
2401
- const t = e + (F(this.wnd) ? -1 : 1);
2402
- return t - t % this.wnd.innerWidth;
2365
+ snapOffset(t) {
2366
+ const e = t + (W(this.wnd) ? -1 : 1);
2367
+ return e - e % this.wnd.innerWidth;
2403
2368
  }
2404
2369
  reportProgress() {
2405
- const e = this.wnd.scrollX, t = this.cachedScrollWidth, i = Math.max(0, Math.min(1, e / t)), s = Math.max(0, Math.min(1, (e + this.wnd.innerWidth) / t));
2370
+ const t = this.wnd.scrollX, e = this.cachedScrollWidth, i = Math.max(0, Math.min(1, t / e)), s = Math.max(0, Math.min(1, (t + this.wnd.innerWidth) / e));
2406
2371
  this.comms.send("progress", {
2407
2372
  start: i,
2408
2373
  end: s
@@ -2411,31 +2376,31 @@ const Re = "readium-column-snapper-style", Ht = 200, et = class T extends Ye {
2411
2376
  shake() {
2412
2377
  if (this.overscroll !== 0 || this.shakeTimeout !== 0)
2413
2378
  return;
2414
- const e = this.doc();
2415
- e.classList.add(F(this.wnd) ? "readium-bounce-l" : "readium-bounce-r");
2416
- const t = this.scrollOffset();
2379
+ const t = this.doc();
2380
+ t.classList.add(W(this.wnd) ? "readium-bounce-l" : "readium-bounce-r");
2381
+ const e = this.scrollOffset();
2417
2382
  this.shakeTimeout = this.wnd.setTimeout(() => {
2418
- e.classList.remove("readium-bounce-l"), e.classList.remove("readium-bounce-r"), this.shakeTimeout = 0, this.doc().scrollLeft = t;
2383
+ t.classList.remove("readium-bounce-l"), t.classList.remove("readium-bounce-r"), this.shakeTimeout = 0, this.doc().scrollLeft = e;
2419
2384
  }, 150);
2420
2385
  }
2421
2386
  // We have to cache this because during overscroll (transform, or left) the width is incorrect due to browser
2422
2387
  takeOverSnap() {
2423
- var t;
2388
+ var e;
2424
2389
  this.snappingCancelled = !0, this.clearTouches();
2425
- const e = this.doc();
2426
- this.overscroll = ((t = e.style.transform) == null ? void 0 : t.length) > 12 ? parseFloat(e.style.transform.slice(12).split("px")[0]) : 0;
2390
+ const t = this.doc();
2391
+ this.overscroll = ((e = t.style.transform) == null ? void 0 : e.length) > 12 ? parseFloat(t.style.transform.slice(12).split("px")[0]) : 0;
2427
2392
  }
2428
2393
  // Snaps the current offset to the page width.
2429
- snapCurrentOffset(e = !1, t = !1) {
2430
- const i = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft, s = this.doc(), n = this.dragOffset(), o = Ze(this.wnd), l = Math.min(Math.max(0, i), this.cachedScrollWidth), c = F(this.wnd) ? -1 : 1, h = (
2394
+ snapCurrentOffset(t = !1, e = !1) {
2395
+ const i = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft, s = this.doc(), n = this.dragOffset(), o = Gt(this.wnd), l = Math.min(Math.max(0, i), this.cachedScrollWidth), c = W(this.wnd) ? -1 : 1, h = (
2431
2396
  // The hurdle to overcome in order to change pages
2432
2397
  c * (this.wnd.innerWidth / 3) * (c * n > 0 ? 2 : 1)
2433
2398
  ), u = this.snapOffset(l + h);
2434
- if (e && u !== this.scrollOffset()) {
2399
+ if (t && u !== this.scrollOffset()) {
2435
2400
  this.snappingCancelled = !1;
2436
- const p = (m, v, S, O) => S > O ? v : m + (v - m) * Bt(S / O), d = (
2401
+ const p = (m, v, S, O) => S > O ? v : m + (v - m) * Fe(S / O), d = (
2437
2402
  /*Math.abs(startX - (this.useTransform ? currentOffset : 0)) < 10 ? 1 : */
2438
- Ht * o
2403
+ He * o
2439
2404
  );
2440
2405
  let f;
2441
2406
  const g = (m) => {
@@ -2443,12 +2408,12 @@ const Re = "readium-column-snapper-style", Ht = 200, et = class T extends Ye {
2443
2408
  return;
2444
2409
  f || (f = m);
2445
2410
  const v = m - f, S = p(this.overscroll, 0, v, d), O = p(i, u, v, d);
2446
- s.scrollLeft = O, this.overscroll !== 0 && (s.style.transform = `translate3d(${-S}px, 0px, 0px)`), v < d ? this.wnd.requestAnimationFrame(g) : (this.clearTouches(), s.style.removeProperty("transform"), s.scrollLeft = u, t || this.reportProgress());
2411
+ s.scrollLeft = O, this.overscroll !== 0 && (s.style.transform = `translate3d(${-S}px, 0px, 0px)`), v < d ? this.wnd.requestAnimationFrame(g) : (this.clearTouches(), s.style.removeProperty("transform"), s.scrollLeft = u, e || this.reportProgress());
2447
2412
  };
2448
2413
  this.wnd.requestAnimationFrame(g);
2449
2414
  } else
2450
2415
  s.style.removeProperty("transform"), this.wnd.requestAnimationFrame(() => {
2451
- s.scrollLeft = u, this.clearTouches(), t || this.reportProgress();
2416
+ s.scrollLeft = u, this.clearTouches(), e || this.reportProgress();
2452
2417
  });
2453
2418
  }
2454
2419
  dragOffset() {
@@ -2457,43 +2422,43 @@ const Re = "readium-column-snapper-style", Ht = 200, et = class T extends Ye {
2457
2422
  clearTouches() {
2458
2423
  this.startingX = void 0, this.endingX = void 0, this.overscroll = 0;
2459
2424
  }
2460
- onTouchStart(e) {
2461
- switch (e.stopPropagation(), this.takeOverSnap(), e.touches.length) {
2425
+ onTouchStart(t) {
2426
+ switch (t.stopPropagation(), this.takeOverSnap(), t.touches.length) {
2462
2427
  case 1:
2463
2428
  break;
2464
2429
  case 2:
2465
- this.onTouchEnd(e);
2430
+ this.onTouchEnd(t);
2466
2431
  return;
2467
2432
  default: {
2468
- this.onTouchEnd(e), this.comms.send("tap_more", e.touches.length);
2433
+ this.onTouchEnd(t), this.comms.send("tap_more", t.touches.length);
2469
2434
  return;
2470
2435
  }
2471
2436
  }
2472
- this.startingX = e.touches[0].clientX, this.alreadyScrollLeft = this.doc().scrollLeft, this.touchState = 1;
2437
+ this.startingX = t.touches[0].clientX, this.alreadyScrollLeft = this.doc().scrollLeft, this.touchState = 1;
2473
2438
  }
2474
- onTouchEnd(e) {
2439
+ onTouchEnd(t) {
2475
2440
  if (this.touchState === 2) {
2476
- const t = this.dragOffset(), i = this.scrollOffset();
2477
- this.cachedScrollWidth <= this.wnd.innerWidth ? (this.reportProgress(), t > 5 && this.comms.send("no_more", void 0), t < -5 && this.comms.send("no_less", void 0)) : i < 5 && t < 5 ? (this.alreadyScrollLeft = 0, this.comms.send("no_less", void 0)) : this.cachedScrollWidth - i - this.wnd.innerWidth < 5 && t > 5 && (this.alreadyScrollLeft = this.cachedScrollWidth, this.comms.send("no_more", void 0)), this.snapCurrentOffset(!0), this.comms.send("swipe", t);
2441
+ const e = this.dragOffset(), i = this.scrollOffset();
2442
+ this.cachedScrollWidth <= this.wnd.innerWidth ? (this.reportProgress(), e > 5 && this.comms.send("no_more", void 0), e < -5 && this.comms.send("no_less", void 0)) : i < 5 && e < 5 ? (this.alreadyScrollLeft = 0, this.comms.send("no_less", void 0)) : this.cachedScrollWidth - i - this.wnd.innerWidth < 5 && e > 5 && (this.alreadyScrollLeft = this.cachedScrollWidth, this.comms.send("no_more", void 0)), this.snapCurrentOffset(!0), this.comms.send("swipe", e);
2478
2443
  }
2479
2444
  this.touchState = 0;
2480
2445
  }
2481
2446
  onWidthChange() {
2482
2447
  this.cachedScrollWidth = this.doc().scrollWidth, this.comms.ready && this.snapCurrentOffset();
2483
2448
  }
2484
- onTouchMove(e) {
2449
+ onTouchMove(t) {
2485
2450
  if (this.touchState === 0)
2486
2451
  return;
2487
- this.touchState === 1 && (this.touchState = 2, w(this.wnd)), this.endingX = e.touches[0].clientX;
2488
- const t = this.dragOffset(), i = this.alreadyScrollLeft + t;
2489
- i < 0 ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-this.overscroll}px, 0px, 0px)`) : i + this.wnd.innerWidth > this.cachedScrollWidth ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-i}px, 0px, 0px)`) : (this.overscroll = 0, this.doc().style.removeProperty("transform"), this.doc().scrollLeft = this.alreadyScrollLeft + t);
2452
+ this.touchState === 1 && (this.touchState = 2, T(this.wnd)), this.endingX = t.touches[0].clientX;
2453
+ const e = this.dragOffset(), i = this.alreadyScrollLeft + e;
2454
+ i < 0 ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-this.overscroll}px, 0px, 0px)`) : i + this.wnd.innerWidth > this.cachedScrollWidth ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-i}px, 0px, 0px)`) : (this.overscroll = 0, this.doc().style.removeProperty("transform"), this.doc().scrollLeft = this.alreadyScrollLeft + e);
2490
2455
  }
2491
- mount(e, t) {
2492
- if (this.wnd = e, this.comms = t, !super.mount(e, t))
2456
+ mount(t, e) {
2457
+ if (this.wnd = t, this.comms = e, !super.mount(t, e))
2493
2458
  return !1;
2494
- e.navigator.epubReadingSystem.layoutStyle = "paginated";
2495
- const i = e.document.createElement("style");
2496
- i.dataset.readium = "true", i.id = Re, i.textContent = `
2459
+ t.navigator.epubReadingSystem.layoutStyle = "paginated";
2460
+ const i = t.document.createElement("style");
2461
+ i.dataset.readium = "true", i.id = It, i.textContent = `
2497
2462
  @keyframes readium-bounce-l-animation {
2498
2463
  0%, 100% {transform: translate3d(0, 0, 0);}
2499
2464
  50% {transform: translate3d(-50px, 0, 0);}
@@ -2527,51 +2492,51 @@ const Re = "readium-column-snapper-style", Ht = 200, et = class T extends Ye {
2527
2492
  body::-webkit-scrollbar {
2528
2493
  display: none; /* for Chrome, Safari, and Opera */
2529
2494
  }
2530
- `, e.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
2531
- e.requestAnimationFrame(() => {
2532
- e && Le(e);
2495
+ `, t.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
2496
+ t.requestAnimationFrame(() => {
2497
+ t && Ot(t);
2533
2498
  }), this.onWidthChange();
2534
- }), this.resizeObserver.observe(e.document.body), this.mutationObserver = new MutationObserver((n) => {
2499
+ }), this.resizeObserver.observe(t.document.body), this.mutationObserver = new MutationObserver((n) => {
2535
2500
  for (const o of n)
2536
2501
  if (o.target === this.wnd.document.documentElement) {
2537
2502
  const l = o.oldValue, c = o.target.getAttribute("style"), h = /transform\s*:\s*([^;]+)/, u = l == null ? void 0 : l.match(h), p = c == null ? void 0 : c.match(h);
2538
- (!u && !p || u && !p || u && p && u[1] !== p[1]) && (e.requestAnimationFrame(() => {
2539
- e && Le(e);
2503
+ (!u && !p || u && !p || u && p && u[1] !== p[1]) && (t.requestAnimationFrame(() => {
2504
+ t && Ot(t);
2540
2505
  }), this.onWidthChange());
2541
2506
  } else
2542
- e.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth);
2543
- }), e.frameElement && this.mutationObserver.observe(e.frameElement, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(e.document, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(e.document.documentElement, { attributes: !0, attributeFilter: ["style"] });
2507
+ t.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth);
2508
+ }), t.frameElement && this.mutationObserver.observe(t.frameElement, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(t.document, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(t.document.documentElement, { attributes: !0, attributeFilter: ["style"] });
2544
2509
  const s = (n) => {
2545
2510
  const o = this.doc().scrollLeft;
2546
2511
  return this.doc().scrollLeft = this.snapOffset(n), o !== this.doc().scrollLeft;
2547
2512
  };
2548
- return e.addEventListener("orientationchange", this.onWidthChanger), e.addEventListener("resize", this.onWidthChanger), e.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), t.register("go_progression", T.moduleName, (n, o) => {
2513
+ return t.addEventListener("orientationchange", this.onWidthChanger), t.addEventListener("resize", this.onWidthChanger), t.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), e.register("go_progression", w.moduleName, (n, o) => {
2549
2514
  const l = n;
2550
2515
  if (l < 0 || l > 1) {
2551
- t.send("error", {
2516
+ e.send("error", {
2552
2517
  message: "go_progression must be given a position from 0.0 to 1.0"
2553
2518
  }), o(!1);
2554
2519
  return;
2555
2520
  }
2556
2521
  this.wnd.requestAnimationFrame(() => {
2557
2522
  this.cachedScrollWidth = this.doc().scrollWidth;
2558
- const c = this.cachedScrollWidth, h = F(e) ? -1 : 1, u = c * l * h;
2559
- this.doc().scrollLeft = this.snapOffset(u), this.reportProgress(), w(this.wnd), o(!0);
2523
+ const c = this.cachedScrollWidth, h = W(t) ? -1 : 1, u = c * l * h;
2524
+ this.doc().scrollLeft = this.snapOffset(u), this.reportProgress(), T(this.wnd), o(!0);
2560
2525
  });
2561
- }), t.register("go_id", T.moduleName, (n, o) => {
2562
- const l = e.document.getElementById(n);
2526
+ }), e.register("go_id", w.moduleName, (n, o) => {
2527
+ const l = t.document.getElementById(n);
2563
2528
  if (!l) {
2564
2529
  o(!1);
2565
2530
  return;
2566
2531
  }
2567
2532
  this.wnd.requestAnimationFrame(() => {
2568
- this.doc().scrollLeft = this.snapOffset(l.getBoundingClientRect().left + e.scrollX), this.reportProgress(), w(this.wnd), o(!0);
2533
+ this.doc().scrollLeft = this.snapOffset(l.getBoundingClientRect().left + t.scrollX), this.reportProgress(), T(this.wnd), o(!0);
2569
2534
  });
2570
- }), t.register("go_text", T.moduleName, (n, o) => {
2535
+ }), e.register("go_text", w.moduleName, (n, o) => {
2571
2536
  let l;
2572
2537
  Array.isArray(n) && (n.length > 1 && (l = n[1]), n = n[0]);
2573
- const c = k.deserialize(n), h = ce(this.wnd.document, new W({
2574
- href: e.location.href,
2538
+ const c = U.deserialize(n), h = lt(this.wnd.document, new D({
2539
+ href: t.location.href,
2575
2540
  type: "text/html",
2576
2541
  text: c,
2577
2542
  locations: l ? new x({
@@ -2585,57 +2550,57 @@ const Re = "readium-column-snapper-style", Ht = 200, et = class T extends Ye {
2585
2550
  return;
2586
2551
  }
2587
2552
  this.wnd.requestAnimationFrame(() => {
2588
- this.doc().scrollLeft = this.snapOffset(h.getBoundingClientRect().left + e.scrollX), this.reportProgress(), w(this.wnd), o(!0);
2553
+ this.doc().scrollLeft = this.snapOffset(h.getBoundingClientRect().left + t.scrollX), this.reportProgress(), T(this.wnd), o(!0);
2589
2554
  });
2590
- }), t.register("go_end", T.moduleName, (n, o) => {
2591
- const l = F(e) ? -1 : 1;
2555
+ }), e.register("go_end", w.moduleName, (n, o) => {
2556
+ const l = W(t) ? -1 : 1;
2592
2557
  this.wnd.requestAnimationFrame(() => {
2593
2558
  this.cachedScrollWidth = this.doc().scrollWidth;
2594
2559
  const c = this.cachedScrollWidth * l;
2595
2560
  if (this.doc().scrollLeft === c)
2596
2561
  return o(!1);
2597
- this.doc().scrollLeft = this.snapOffset(c), this.reportProgress(), w(this.wnd), o(!0);
2562
+ this.doc().scrollLeft = this.snapOffset(c), this.reportProgress(), T(this.wnd), o(!0);
2598
2563
  });
2599
- }), t.register("go_start", T.moduleName, (n, o) => {
2564
+ }), e.register("go_start", w.moduleName, (n, o) => {
2600
2565
  this.wnd.requestAnimationFrame(() => {
2601
2566
  if (this.doc().scrollLeft === 0)
2602
2567
  return o(!1);
2603
- this.doc().scrollLeft = 0, this.reportProgress(), w(this.wnd), o(!0);
2568
+ this.doc().scrollLeft = 0, this.reportProgress(), T(this.wnd), o(!0);
2604
2569
  });
2605
- }), t.register("go_prev", T.moduleName, (n, o) => {
2570
+ }), e.register("go_prev", w.moduleName, (n, o) => {
2606
2571
  this.wnd.requestAnimationFrame(() => {
2607
2572
  this.cachedScrollWidth = this.doc().scrollWidth;
2608
- const l = e.scrollX - e.innerWidth, c = F(e) ? -(this.cachedScrollWidth - e.innerWidth) : 0, h = s(Math.max(l, c));
2609
- h && (this.reportProgress(), w(this.wnd)), o(h);
2573
+ const l = t.scrollX - t.innerWidth, c = W(t) ? -(this.cachedScrollWidth - t.innerWidth) : 0, h = s(Math.max(l, c));
2574
+ h && (this.reportProgress(), T(this.wnd)), o(h);
2610
2575
  });
2611
- }), t.register("go_next", T.moduleName, (n, o) => {
2576
+ }), e.register("go_next", w.moduleName, (n, o) => {
2612
2577
  this.wnd.requestAnimationFrame(() => {
2613
2578
  this.cachedScrollWidth = this.doc().scrollWidth;
2614
- const l = e.scrollX + e.innerWidth, c = F(e) ? 0 : this.cachedScrollWidth - e.innerWidth, h = s(Math.min(l, c));
2615
- h && (this.reportProgress(), w(this.wnd)), o(h);
2579
+ const l = t.scrollX + t.innerWidth, c = W(t) ? 0 : this.cachedScrollWidth - t.innerWidth, h = s(Math.min(l, c));
2580
+ h && (this.reportProgress(), T(this.wnd)), o(h);
2616
2581
  });
2617
- }), t.register("unfocus", T.moduleName, (n, o) => {
2618
- this.snappingCancelled = !0, w(this.wnd), o(!0);
2619
- }), t.register("shake", T.moduleName, (n, o) => {
2582
+ }), e.register("unfocus", w.moduleName, (n, o) => {
2583
+ this.snappingCancelled = !0, T(this.wnd), o(!0);
2584
+ }), e.register("shake", w.moduleName, (n, o) => {
2620
2585
  this.shake(), o(!0);
2621
- }), t.register("focus", T.moduleName, (n, o) => {
2586
+ }), e.register("focus", w.moduleName, (n, o) => {
2622
2587
  this.wnd.requestAnimationFrame(() => {
2623
2588
  this.cachedScrollWidth = this.doc().scrollWidth, this.snapCurrentOffset(!1, !0), this.reportProgress(), o(!0);
2624
2589
  });
2625
- }), t.register("first_visible_locator", T.moduleName, (n, o) => {
2626
- const l = Je(e, !1);
2590
+ }), e.register("first_visible_locator", w.moduleName, (n, o) => {
2591
+ const l = Kt(t, !1);
2627
2592
  this.comms.send("first_visible_locator", l.serialize()), o(!0);
2628
- }), e.addEventListener("touchstart", this.onTouchStarter, { passive: !0 }), e.addEventListener("touchend", this.onTouchEnder, { passive: !0 }), e.addEventListener("touchmove", this.onTouchMover, { passive: !0 }), e.document.addEventListener("touchstart", () => {
2629
- }), t.log("ColumnSnapper Mounted"), !0;
2593
+ }), t.addEventListener("touchstart", this.onTouchStarter, { passive: !0 }), t.addEventListener("touchend", this.onTouchEnder, { passive: !0 }), t.addEventListener("touchmove", this.onTouchMover, { passive: !0 }), t.document.addEventListener("touchstart", () => {
2594
+ }), e.log("ColumnSnapper Mounted"), !0;
2630
2595
  }
2631
- unmount(e, t) {
2596
+ unmount(t, e) {
2632
2597
  var i;
2633
- return this.snappingCancelled = !0, t.unregisterAll(T.moduleName), this.resizeObserver.disconnect(), this.mutationObserver.disconnect(), e.removeEventListener("touchstart", this.onTouchStarter), e.removeEventListener("touchend", this.onTouchEnder), e.removeEventListener("touchmove", this.onTouchMover), e.removeEventListener("orientationchange", this.onWidthChanger), e.removeEventListener("resize", this.onWidthChanger), (i = e.document.getElementById(Re)) == null || i.remove(), t.log("ColumnSnapper Unmounted"), super.unmount(e, t);
2598
+ return this.snappingCancelled = !0, e.unregisterAll(w.moduleName), this.resizeObserver.disconnect(), this.mutationObserver.disconnect(), t.removeEventListener("touchstart", this.onTouchStarter), t.removeEventListener("touchend", this.onTouchEnder), t.removeEventListener("touchmove", this.onTouchMover), t.removeEventListener("orientationchange", this.onWidthChanger), t.removeEventListener("resize", this.onWidthChanger), (i = t.document.getElementById(It)) == null || i.remove(), e.log("ColumnSnapper Unmounted"), super.unmount(t, e);
2634
2599
  }
2635
2600
  };
2636
- et.moduleName = "column_snapper";
2637
- let qt = et;
2638
- const De = "readium-scroll-snapper-style", tt = class P extends Ye {
2601
+ Jt.moduleName = "column_snapper";
2602
+ let je = Jt;
2603
+ const Lt = "readium-scroll-snapper-style", Qt = class P extends Xt {
2639
2604
  constructor() {
2640
2605
  super(...arguments), this.isScrolling = !1, this.handleScroll = () => {
2641
2606
  this.isScrolling || (this.isScrolling = !0, this.wnd.requestAnimationFrame(() => {
@@ -2647,16 +2612,16 @@ const De = "readium-scroll-snapper-style", tt = class P extends Ye {
2647
2612
  return this.wnd.document.scrollingElement;
2648
2613
  }
2649
2614
  reportProgress() {
2650
- const e = this.doc().scrollTop, t = this.doc().scrollHeight, i = Math.max(0, Math.min(1, e / t)), s = Math.max(0, Math.min(1, (e + this.wnd.innerHeight) / t));
2615
+ const t = Math.ceil(this.doc().scrollTop), e = this.doc().scrollHeight, i = this.wnd.innerHeight, s = Math.max(0, Math.min(1, t / e)), n = Math.max(0, Math.min(1, (t + i) / e));
2651
2616
  this.comms.send("progress", {
2652
- start: i,
2653
- end: s
2617
+ start: s,
2618
+ end: n
2654
2619
  });
2655
2620
  }
2656
- mount(e, t) {
2657
- this.wnd = e, this.comms = t, e.navigator.epubReadingSystem.layoutStyle = "scrolling";
2658
- const i = e.document.createElement("style");
2659
- return i.dataset.readium = "true", i.id = De, i.textContent = `
2621
+ mount(t, e) {
2622
+ this.wnd = t, this.comms = e, t.navigator.epubReadingSystem.layoutStyle = "scrolling";
2623
+ const i = t.document.createElement("style");
2624
+ return i.dataset.readium = "true", i.id = Lt, i.textContent = `
2660
2625
  * {
2661
2626
  scrollbar-width: none; /* for Firefox */
2662
2627
  }
@@ -2664,39 +2629,39 @@ const De = "readium-scroll-snapper-style", tt = class P extends Ye {
2664
2629
  body::-webkit-scrollbar {
2665
2630
  display: none; /* for Chrome, Safari, and Opera */
2666
2631
  }
2667
- `, e.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
2632
+ `, t.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
2668
2633
  this.comms.ready && this.handleScroll();
2669
- }), this.resizeObserver.observe(e.document.body), e.addEventListener("scroll", this.handleScroll, {
2634
+ }), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, {
2670
2635
  passive: !0
2671
- }), t.register("force_webkit_recalc", P.moduleName, () => {
2672
- Ut(this.wnd);
2636
+ }), e.register("force_webkit_recalc", P.moduleName, () => {
2637
+ We(this.wnd);
2673
2638
  const s = this.doc().scrollTop;
2674
- this.doc().scrollTop = s + 1, this.doc().scrollTop = s;
2675
- }), t.register("go_progression", P.moduleName, (s, n) => {
2639
+ s > 1 ? this.doc().scrollTop = s - 1 : this.doc().scrollTop = s + 1, this.doc().scrollTop = s;
2640
+ }), e.register("go_progression", P.moduleName, (s, n) => {
2676
2641
  const o = s;
2677
2642
  if (o < 0 || o > 1) {
2678
- t.send("error", {
2643
+ e.send("error", {
2679
2644
  message: "go_progression must be given a position from 0.0 to 1.0"
2680
2645
  }), n(!1);
2681
2646
  return;
2682
2647
  }
2683
2648
  this.wnd.requestAnimationFrame(() => {
2684
- this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(), w(this.wnd), n(!0);
2649
+ this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(), T(this.wnd), n(!0);
2685
2650
  });
2686
- }), t.register("go_id", P.moduleName, (s, n) => {
2687
- const o = e.document.getElementById(s);
2651
+ }), e.register("go_id", P.moduleName, (s, n) => {
2652
+ const o = t.document.getElementById(s);
2688
2653
  if (!o) {
2689
2654
  n(!1);
2690
2655
  return;
2691
2656
  }
2692
2657
  this.wnd.requestAnimationFrame(() => {
2693
- this.doc().scrollTop = o.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), w(this.wnd), n(!0);
2658
+ this.doc().scrollTop = o.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), T(this.wnd), n(!0);
2694
2659
  });
2695
- }), t.register("go_text", P.moduleName, (s, n) => {
2660
+ }), e.register("go_text", P.moduleName, (s, n) => {
2696
2661
  let o;
2697
2662
  Array.isArray(s) && (s.length > 1 && (o = s[1]), s = s[0]);
2698
- const l = k.deserialize(s), c = ce(this.wnd.document, new W({
2699
- href: e.location.href,
2663
+ const l = U.deserialize(s), c = lt(this.wnd.document, new D({
2664
+ href: t.location.href,
2700
2665
  type: "text/html",
2701
2666
  text: l,
2702
2667
  locations: o ? new x({
@@ -2710,48 +2675,48 @@ const De = "readium-scroll-snapper-style", tt = class P extends Ye {
2710
2675
  return;
2711
2676
  }
2712
2677
  this.wnd.requestAnimationFrame(() => {
2713
- this.doc().scrollTop = c.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), w(this.wnd), n(!0);
2678
+ this.doc().scrollTop = c.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), T(this.wnd), n(!0);
2714
2679
  });
2715
- }), t.register("go_start", P.moduleName, (s, n) => {
2680
+ }), e.register("go_start", P.moduleName, (s, n) => {
2716
2681
  if (this.doc().scrollTop === 0)
2717
2682
  return n(!1);
2718
2683
  this.doc().scrollTop = 0, this.reportProgress(), n(!0);
2719
- }), t.register("go_end", P.moduleName, (s, n) => {
2684
+ }), e.register("go_end", P.moduleName, (s, n) => {
2720
2685
  if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight)
2721
2686
  return n(!1);
2722
2687
  this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), n(!0);
2723
- }), t.register("unfocus", P.moduleName, (s, n) => {
2724
- w(this.wnd), n(!0);
2725
- }), t.register([
2688
+ }), e.register("unfocus", P.moduleName, (s, n) => {
2689
+ T(this.wnd), n(!0);
2690
+ }), e.register([
2726
2691
  "go_next",
2727
2692
  "go_prev"
2728
- ], P.moduleName, (s, n) => n(!1)), t.register("focus", P.moduleName, (s, n) => {
2693
+ ], P.moduleName, (s, n) => n(!1)), e.register("focus", P.moduleName, (s, n) => {
2729
2694
  this.reportProgress(), n(!0);
2730
- }), t.register("first_visible_locator", P.moduleName, (s, n) => {
2731
- const o = Je(e, !0);
2695
+ }), e.register("first_visible_locator", P.moduleName, (s, n) => {
2696
+ const o = Kt(t, !0);
2732
2697
  this.comms.send("first_visible_locator", o.serialize()), n(!0);
2733
- }), t.log("ScrollSnapper Mounted"), !0;
2698
+ }), e.log("ScrollSnapper Mounted"), !0;
2734
2699
  }
2735
- unmount(e, t) {
2700
+ unmount(t, e) {
2736
2701
  var i;
2737
- return t.unregisterAll(P.moduleName), this.resizeObserver.disconnect(), this.handleScroll && e.removeEventListener("scroll", this.handleScroll), (i = e.document.getElementById(De)) == null || i.remove(), t.log("ScrollSnapper Unmounted"), !0;
2702
+ return e.unregisterAll(P.moduleName), this.resizeObserver.disconnect(), this.handleScroll && t.removeEventListener("scroll", this.handleScroll), (i = t.document.getElementById(Lt)) == null || i.remove(), e.log("ScrollSnapper Unmounted"), !0;
2738
2703
  }
2739
2704
  };
2740
- tt.moduleName = "scroll_snapper";
2741
- let _t = tt;
2742
- class it extends K {
2705
+ Qt.moduleName = "scroll_snapper";
2706
+ let Ve = Qt;
2707
+ class te extends Y {
2743
2708
  constructor() {
2744
2709
  super(...arguments), this.pointerMoved = !1, this.onPointerUp = this.onPointUp.bind(this), this.onPointerMove = this.onPointMove.bind(this), this.onPointerDown = this.onPointDown.bind(this), this.onContextMenu = this.onContext.bind(this), this.onClicker = this.onClick.bind(this);
2745
2710
  }
2746
- onPointUp(e) {
2711
+ onPointUp(t) {
2747
2712
  var s, n, o, l, c;
2748
- const t = this.wnd.getSelection();
2749
- if (t && ((s = t.toString()) == null ? void 0 : s.length) > 0) {
2750
- const h = (n = t.getRangeAt(0)) == null ? void 0 : n.getClientRects();
2713
+ const e = this.wnd.getSelection();
2714
+ if (e && ((s = e.toString()) == null ? void 0 : s.length) > 0) {
2715
+ const h = (n = e.getRangeAt(0)) == null ? void 0 : n.getClientRects();
2751
2716
  if (!h || h.length === 0)
2752
2717
  return;
2753
2718
  const u = h[0], p = {
2754
- text: t.toString(),
2719
+ text: e.toString(),
2755
2720
  x: u.x,
2756
2721
  y: u.y,
2757
2722
  width: u.width,
@@ -2764,22 +2729,22 @@ class it extends K {
2764
2729
  this.pointerMoved = !1;
2765
2730
  return;
2766
2731
  }
2767
- if (!(t != null && t.isCollapsed) || !e.isPrimary)
2732
+ if (!(e != null && e.isCollapsed) || !t.isPrimary)
2768
2733
  return;
2769
2734
  const i = this.wnd.devicePixelRatio;
2770
- e.preventDefault(), this.comms.send(e.pointerType === "touch" ? "tap" : "click", {
2771
- defaultPrevented: e.defaultPrevented,
2772
- x: e.clientX * i,
2773
- y: e.clientY * i,
2735
+ t.preventDefault(), this.comms.send(t.pointerType === "touch" ? "tap" : "click", {
2736
+ defaultPrevented: t.defaultPrevented,
2737
+ x: t.clientX * i,
2738
+ y: t.clientY * i,
2774
2739
  targetFrameSrc: this.wnd.location.href,
2775
- targetElement: e.target.outerHTML,
2776
- interactiveElement: (c = Ke(e.target)) == null ? void 0 : c.outerHTML,
2777
- cssSelector: this.wnd._readium_cssSelectorGenerator.getCssSelector(e.target)
2740
+ targetElement: t.target.outerHTML,
2741
+ interactiveElement: (c = Yt(t.target)) == null ? void 0 : c.outerHTML,
2742
+ cssSelector: this.wnd._readium_cssSelectorGenerator.getCssSelector(t.target)
2778
2743
  }), this.pointerMoved = !1;
2779
2744
  }
2780
- onPointMove(e) {
2781
- if (e.movementY !== void 0 && e.movementX !== void 0) {
2782
- (Math.abs(e.movementX) > 1 || Math.abs(e.movementY) > 1) && (this.pointerMoved = !0);
2745
+ onPointMove(t) {
2746
+ if (t.movementY !== void 0 && t.movementX !== void 0) {
2747
+ (Math.abs(t.movementX) > 1 || Math.abs(t.movementY) > 1) && (this.pointerMoved = !0);
2783
2748
  return;
2784
2749
  }
2785
2750
  this.pointerMoved = !0;
@@ -2787,84 +2752,84 @@ class it extends K {
2787
2752
  onPointDown() {
2788
2753
  this.pointerMoved = !1;
2789
2754
  }
2790
- onContext(e) {
2791
- this.onPointUp(e), this.pointerMoved = !1;
2755
+ onContext(t) {
2756
+ this.onPointUp(t), this.pointerMoved = !1;
2792
2757
  }
2793
- onClick(e) {
2794
- if (e.preventDefault(), !e.isTrusted) {
2795
- const t = new PointerEvent("pointerup", {
2758
+ onClick(t) {
2759
+ if (t.preventDefault(), !t.isTrusted) {
2760
+ const e = new PointerEvent("pointerup", {
2796
2761
  isPrimary: !0,
2797
2762
  pointerType: "mouse",
2798
2763
  // Not really a better choice than this
2799
- clientX: e.clientX,
2800
- clientY: e.clientY
2764
+ clientX: t.clientX,
2765
+ clientY: t.clientY
2801
2766
  });
2802
- Object.defineProperty(t, "target", { writable: !1, value: e.target }), Object.defineProperty(t, "defaultPrevented", { writable: !1, value: e.defaultPrevented }), this.onPointUp(t);
2767
+ Object.defineProperty(e, "target", { writable: !1, value: t.target }), Object.defineProperty(e, "defaultPrevented", { writable: !1, value: t.defaultPrevented }), this.onPointUp(e);
2803
2768
  }
2804
2769
  }
2805
- mount(e, t) {
2806
- return this.wnd = e, this.comms = t, e.document.addEventListener("pointerdown", this.onPointerDown), e.document.addEventListener("pointerup", this.onPointerUp), e.document.addEventListener("contextmenu", this.onContextMenu), e.document.addEventListener("pointermove", this.onPointerMove), e.document.addEventListener("click", this.onClicker), t.log("Peripherals Mounted"), !0;
2770
+ mount(t, e) {
2771
+ return this.wnd = t, this.comms = e, t.document.addEventListener("pointerdown", this.onPointerDown), t.document.addEventListener("pointerup", this.onPointerUp), t.document.addEventListener("contextmenu", this.onContextMenu), t.document.addEventListener("pointermove", this.onPointerMove), t.document.addEventListener("click", this.onClicker), e.log("Peripherals Mounted"), !0;
2807
2772
  }
2808
- unmount(e, t) {
2809
- return e.document.removeEventListener("pointerdown", this.onPointerDown), e.document.removeEventListener("pointerup", this.onPointerUp), e.document.removeEventListener("contextmenu", this.onContextMenu), e.document.removeEventListener("pointermove", this.onPointerMove), e.document.removeEventListener("click", this.onClicker), t.log("Peripherals Unmounted"), !0;
2773
+ unmount(t, e) {
2774
+ return t.document.removeEventListener("pointerdown", this.onPointerDown), t.document.removeEventListener("pointerup", this.onPointerUp), t.document.removeEventListener("contextmenu", this.onContextMenu), t.document.removeEventListener("pointermove", this.onPointerMove), t.document.removeEventListener("click", this.onClicker), e.log("Peripherals Unmounted"), !0;
2810
2775
  }
2811
2776
  }
2812
- it.moduleName = "peripherals";
2813
- const rt = class re extends K {
2777
+ te.moduleName = "peripherals";
2778
+ const ee = class et extends Y {
2814
2779
  constructor() {
2815
2780
  super(...arguments), this.mediaPlayingCount = 0, this.allAnimations = /* @__PURE__ */ new Set();
2816
2781
  }
2817
- wndOnErr(e) {
2818
- var t;
2819
- (t = this.comms) == null || t.send("error", {
2820
- message: e.message,
2821
- filename: e.filename,
2822
- lineno: e.lineno,
2823
- colno: e.colno
2782
+ wndOnErr(t) {
2783
+ var e;
2784
+ (e = this.comms) == null || e.send("error", {
2785
+ message: t.message,
2786
+ filename: t.filename,
2787
+ lineno: t.lineno,
2788
+ colno: t.colno
2824
2789
  });
2825
2790
  }
2826
- unblock(e) {
2827
- var t;
2828
- for (e._readium_blockEvents = !1; ((t = e._readium_blockedEvents) == null ? void 0 : t.length) > 0; ) {
2829
- const i = e._readium_blockedEvents.shift();
2791
+ unblock(t) {
2792
+ var e;
2793
+ for (t._readium_blockEvents = !1; ((e = t._readium_blockedEvents) == null ? void 0 : e.length) > 0; ) {
2794
+ const i = t._readium_blockedEvents.shift();
2830
2795
  switch (i[0]) {
2831
2796
  case 0:
2832
2797
  Reflect.apply(i[1], i[2], i[3]);
2833
2798
  break;
2834
2799
  case 1:
2835
2800
  const s = i[1], n = i[2];
2836
- e.removeEventListener(s.type, e._readium_eventBlocker, !0);
2801
+ t.removeEventListener(s.type, t._readium_eventBlocker, !0);
2837
2802
  const o = new Event(s.type, {
2838
2803
  bubbles: s.bubbles,
2839
2804
  cancelable: s.cancelable
2840
2805
  });
2841
- n ? n.dispatchEvent(o) : e.dispatchEvent(o);
2806
+ n ? n.dispatchEvent(o) : t.dispatchEvent(o);
2842
2807
  break;
2843
2808
  }
2844
2809
  }
2845
2810
  }
2846
2811
  onMediaPlayEvent() {
2847
- var e;
2848
- this.mediaPlayingCount++, (e = this.comms) == null || e.send("media_play", this.mediaPlayingCount);
2812
+ var t;
2813
+ this.mediaPlayingCount++, (t = this.comms) == null || t.send("media_play", this.mediaPlayingCount);
2849
2814
  }
2850
2815
  onMediaPauseEvent() {
2851
- var e;
2852
- this.mediaPlayingCount > 0 && this.mediaPlayingCount--, (e = this.comms) == null || e.send("media_pause", this.mediaPlayingCount);
2816
+ var t;
2817
+ this.mediaPlayingCount > 0 && this.mediaPlayingCount--, (t = this.comms) == null || t.send("media_pause", this.mediaPlayingCount);
2853
2818
  }
2854
- pauseAllMedia(e) {
2855
- const t = e.document.querySelectorAll("audio,video");
2856
- for (let i = 0; i < t.length; i++)
2857
- t[i].pause();
2819
+ pauseAllMedia(t) {
2820
+ const e = t.document.querySelectorAll("audio,video");
2821
+ for (let i = 0; i < e.length; i++)
2822
+ e[i].pause();
2858
2823
  }
2859
- mount(e, t) {
2860
- this.comms = t, e.addEventListener(
2824
+ mount(t, e) {
2825
+ this.comms = e, t.addEventListener(
2861
2826
  "error",
2862
2827
  this.wndOnErr,
2863
2828
  !1
2864
- ), Reflect.defineProperty(e.navigator, "epubReadingSystem", {
2829
+ ), Reflect.defineProperty(t.navigator, "epubReadingSystem", {
2865
2830
  value: {
2866
2831
  name: "readium-ts-toolkit",
2867
- version: "2.0.0-beta.4",
2832
+ version: "2.0.0-beta.5",
2868
2833
  hasFeature: (s, n = "") => {
2869
2834
  switch (s) {
2870
2835
  case "dom-manipulation":
@@ -2887,16 +2852,16 @@ const rt = class re extends K {
2887
2852
  }
2888
2853
  },
2889
2854
  writable: !1
2890
- }), "getAnimations" in e.document && e.document.getAnimations().forEach((s) => {
2855
+ }), "getAnimations" in t.document && t.document.getAnimations().forEach((s) => {
2891
2856
  s.cancel(), this.allAnimations.add(s);
2892
- }), t.register("activate", re.moduleName, (s, n) => {
2857
+ }), e.register("activate", et.moduleName, (s, n) => {
2893
2858
  this.allAnimations.forEach((o) => {
2894
2859
  o.cancel(), o.play();
2895
2860
  }), n(!0);
2896
- }), t.register("unfocus", re.moduleName, (s, n) => {
2897
- this.pauseAllMedia(e), this.allAnimations.forEach((o) => o.pause()), n(!0);
2861
+ }), e.register("unfocus", et.moduleName, (s, n) => {
2862
+ this.pauseAllMedia(t), this.allAnimations.forEach((o) => o.pause()), n(!0);
2898
2863
  });
2899
- const i = e.document.querySelectorAll("audio,video");
2864
+ const i = t.document.querySelectorAll("audio,video");
2900
2865
  for (let s = 0; s < i.length; s++) {
2901
2866
  const n = i[s];
2902
2867
  n.addEventListener("play", this.onMediaPlayEvent, {
@@ -2905,55 +2870,55 @@ const rt = class re extends K {
2905
2870
  passive: !0
2906
2871
  });
2907
2872
  }
2908
- return t.log("Setup Mounted"), !0;
2873
+ return e.log("Setup Mounted"), !0;
2909
2874
  }
2910
- unmount(e, t) {
2911
- return e.removeEventListener("error", this.wndOnErr), e.removeEventListener("play", this.onMediaPlayEvent), e.removeEventListener("pause", this.onMediaPauseEvent), this.allAnimations.forEach((i) => i.cancel()), this.allAnimations.clear(), t.log("Setup Unmounted"), !0;
2875
+ unmount(t, e) {
2876
+ return t.removeEventListener("error", this.wndOnErr), t.removeEventListener("play", this.onMediaPlayEvent), t.removeEventListener("pause", this.onMediaPauseEvent), this.allAnimations.forEach((i) => i.cancel()), this.allAnimations.clear(), e.log("Setup Unmounted"), !0;
2912
2877
  }
2913
2878
  };
2914
- rt.moduleName = "setup";
2915
- let st = rt;
2916
- const ze = "readium-viewport", nt = class U extends st {
2917
- onViewportWidthChanged(e) {
2918
- const t = e.target;
2919
- Z(t, "--RS__viewportWidth", `${t.innerWidth}px`);
2920
- }
2921
- mount(e, t) {
2922
- if (!super.mount(e, t))
2879
+ ee.moduleName = "setup";
2880
+ let ie = ee;
2881
+ const Rt = "readium-viewport", re = class F extends ie {
2882
+ onViewportWidthChanged(t) {
2883
+ const e = t.target;
2884
+ G(e, "--RS__viewportWidth", `${e.innerWidth}px`);
2885
+ }
2886
+ mount(t, e) {
2887
+ if (!super.mount(t, e))
2923
2888
  return !1;
2924
- const i = e.document.createElement("meta");
2925
- return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id", ze), i.setAttribute(
2889
+ const i = t.document.createElement("meta");
2890
+ return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id", Rt), i.setAttribute(
2926
2891
  "content",
2927
2892
  "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"
2928
- ), e.document.head.appendChild(i), e.addEventListener("orientationchange", this.onViewportWidthChanged), e.addEventListener("resize", this.onViewportWidthChanged), this.onViewportWidthChanged({
2929
- target: e
2930
- }), t.register("get_properties", U.moduleName, (s, n) => {
2931
- _e(e), n(!0);
2932
- }), t.register("update_properties", U.moduleName, (s, n) => {
2933
- s["--RS__viewportWidth"] = `${e.innerWidth}px`, Nt(e, s), n(!0);
2934
- }), t.register("set_property", U.moduleName, (s, n) => {
2893
+ ), t.document.head.appendChild(i), t.addEventListener("orientationchange", this.onViewportWidthChanged), t.addEventListener("resize", this.onViewportWidthChanged), this.onViewportWidthChanged({
2894
+ target: t
2895
+ }), e.register("get_properties", F.moduleName, (s, n) => {
2896
+ Vt(t), n(!0);
2897
+ }), e.register("update_properties", F.moduleName, (s, n) => {
2898
+ s["--RS__viewportWidth"] = `${t.innerWidth}px`, Ne(t, s), n(!0);
2899
+ }), e.register("set_property", F.moduleName, (s, n) => {
2935
2900
  const o = s;
2936
- Z(e, o[0], o[1]), n(!0);
2937
- }), t.register("remove_property", U.moduleName, (s, n) => {
2938
- ue(e, s), n(!0);
2939
- }), t.register("activate", U.moduleName, (s, n) => {
2940
- this.unblock(e), n(!0);
2941
- }), t.log("ReflowableSetup Mounted"), !0;
2942
- }
2943
- unmount(e, t) {
2901
+ G(t, o[0], o[1]), n(!0);
2902
+ }), e.register("remove_property", F.moduleName, (s, n) => {
2903
+ ht(t, s), n(!0);
2904
+ }), e.register("activate", F.moduleName, (s, n) => {
2905
+ this.unblock(t), n(!0);
2906
+ }), e.log("ReflowableSetup Mounted"), !0;
2907
+ }
2908
+ unmount(t, e) {
2944
2909
  var i;
2945
- return t.unregisterAll(U.moduleName), (i = e.document.head.querySelector(`#${ze}`)) == null || i.remove(), e.removeEventListener("orientationchange", this.onViewportWidthChanged), t.log("ReflowableSetup Unmounted"), super.unmount(e, t);
2910
+ return e.unregisterAll(F.moduleName), (i = t.document.head.querySelector(`#${Rt}`)) == null || i.remove(), t.removeEventListener("orientationchange", this.onViewportWidthChanged), e.log("ReflowableSetup Unmounted"), super.unmount(t, e);
2946
2911
  }
2947
2912
  };
2948
- nt.moduleName = "reflowable_setup";
2949
- let Xt = nt;
2950
- const We = "readium-fixed-style", ot = class R extends st {
2951
- mount(e, t) {
2952
- if (!super.mount(e, t))
2913
+ re.moduleName = "reflowable_setup";
2914
+ let qe = re;
2915
+ const zt = "readium-fixed-style", se = class L extends ie {
2916
+ mount(t, e) {
2917
+ if (!super.mount(t, e))
2953
2918
  return !1;
2954
- e.navigator.epubReadingSystem.layoutStyle = "paginated";
2955
- const i = e.document.createElement("style");
2956
- return i.id = We, i.dataset.readium = "true", i.textContent = `
2919
+ t.navigator.epubReadingSystem.layoutStyle = "paginated";
2920
+ const i = t.document.createElement("style");
2921
+ return i.id = zt, i.dataset.readium = "true", i.textContent = `
2957
2922
  html, body {
2958
2923
  text-size-adjust: none;
2959
2924
  -ms-text-size-adjust: none;
@@ -2965,14 +2930,14 @@ const We = "readium-fixed-style", ot = class R extends st {
2965
2930
  min-height: 100%;
2966
2931
 
2967
2932
  /*cursor: var() TODO*/
2968
- }`, e.document.head.appendChild(i), t.register("set_property", R.moduleName, (s, n) => {
2933
+ }`, t.document.head.appendChild(i), e.register("set_property", L.moduleName, (s, n) => {
2969
2934
  const o = s;
2970
- Z(e, o[0], o[1]), n(!0);
2971
- }), t.register("remove_property", R.moduleName, (s, n) => {
2972
- ue(e, s), n(!0);
2973
- }), t.register("first_visible_locator", R.moduleName, (s, n) => n(!1)), t.register("unfocus", R.moduleName, (s, n) => {
2974
- w(e), n(!0);
2975
- }), t.register([
2935
+ G(t, o[0], o[1]), n(!0);
2936
+ }), e.register("remove_property", L.moduleName, (s, n) => {
2937
+ ht(t, s), n(!0);
2938
+ }), e.register("first_visible_locator", L.moduleName, (s, n) => n(!1)), e.register("unfocus", L.moduleName, (s, n) => {
2939
+ T(t), n(!0);
2940
+ }), e.register([
2976
2941
  "focus",
2977
2942
  "go_next",
2978
2943
  "go_prev",
@@ -2981,97 +2946,97 @@ const We = "readium-fixed-style", ot = class R extends st {
2981
2946
  "go_start",
2982
2947
  "go_text",
2983
2948
  "go_progression"
2984
- ], R.moduleName, (s, n) => n(!0)), t.register("activate", R.moduleName, (s, n) => {
2985
- this.unblock(e), n(!0);
2986
- }), t.log("FixedSetup Mounted"), !0;
2949
+ ], L.moduleName, (s, n) => n(!0)), e.register("activate", L.moduleName, (s, n) => {
2950
+ this.unblock(t), n(!0);
2951
+ }), e.log("FixedSetup Mounted"), !0;
2987
2952
  }
2988
- unmount(e, t) {
2953
+ unmount(t, e) {
2989
2954
  var i;
2990
- return t.unregisterAll(R.moduleName), (i = e.document.getElementById(We)) == null || i.remove(), t.log("FixedSetup Unmounted"), super.unmount(e, t);
2955
+ return e.unregisterAll(L.moduleName), (i = t.document.getElementById(zt)) == null || i.remove(), e.log("FixedSetup Unmounted"), super.unmount(t, e);
2991
2956
  }
2992
2957
  };
2993
- ot.moduleName = "fixed_setup";
2994
- let Gt = ot;
2995
- const Yt = [
2958
+ se.moduleName = "fixed_setup";
2959
+ let _e = se;
2960
+ const Xe = [
2996
2961
  "fixed_setup",
2997
2962
  "decorator",
2998
2963
  "peripherals"
2999
- ], Zt = [
2964
+ ], Ge = [
3000
2965
  "reflowable_setup",
3001
2966
  "decorator",
3002
2967
  "peripherals",
3003
2968
  "column_snapper",
3004
2969
  "scroll_snapper"
3005
- ], Fe = new Map([
2970
+ ], Dt = new Map([
3006
2971
  // All modules go here
3007
- Gt,
3008
- Xt,
3009
- it,
3010
- Ft,
3011
- qt,
3012
- _t
2972
+ _e,
2973
+ qe,
2974
+ te,
2975
+ De,
2976
+ je,
2977
+ Ve
3013
2978
  ].map((r) => [r.moduleName, r]));
3014
- class Kt {
2979
+ class Ye {
3015
2980
  /**
3016
2981
  * @param wnd Window instance to operate on
3017
2982
  * @param initialModules List of initial modules to load
3018
2983
  */
3019
- constructor(e = window, t = []) {
3020
- this.loadedModules = [], this.wnd = e, this.comms = new ht(e);
3021
- const i = [...new Set(t)];
2984
+ constructor(t = window, e = []) {
2985
+ this.loadedModules = [], this.wnd = t, this.comms = new ae(t);
2986
+ const i = [...new Set(e)];
3022
2987
  if (i.length) {
3023
- if (typeof e > "u")
2988
+ if (typeof t > "u")
3024
2989
  throw Error("Loader is not in a web browser");
3025
- e.parent !== e && this.comms.log("Loader is probably in a frame"), this.loadedModules = i.map((s) => {
2990
+ t.parent !== t && this.comms.log("Loader is probably in a frame"), this.loadedModules = i.map((s) => {
3026
2991
  const n = this.loadModule(s);
3027
2992
  if (n)
3028
2993
  return n.mount(this.wnd, this.comms), n;
3029
2994
  }).filter((s) => s !== void 0);
3030
2995
  }
3031
2996
  }
3032
- loadModule(e) {
3033
- const t = Fe.get(e);
3034
- return t === void 0 ? (this.comms.log(`Module "${name}" does not exist in the library`), t) : new t();
2997
+ loadModule(t) {
2998
+ const e = Dt.get(t);
2999
+ return e === void 0 ? (this.comms.log(`Module "${name}" does not exist in the library`), e) : new e();
3035
3000
  }
3036
3001
  /**
3037
3002
  * Add a module by name
3038
3003
  * @param moduleName Module name
3039
3004
  * @returns Success
3040
3005
  */
3041
- addModule(e) {
3042
- const t = this.loadModule(e);
3043
- return !t || !t.mount(this.wnd, this.comms) ? !1 : (this.loadedModules.push(t), !0);
3006
+ addModule(t) {
3007
+ const e = this.loadModule(t);
3008
+ return !e || !e.mount(this.wnd, this.comms) ? !1 : (this.loadedModules.push(e), !0);
3044
3009
  }
3045
3010
  /**
3046
3011
  * Remove a module by name
3047
3012
  * @param moduleName Module name
3048
3013
  * @returns Success
3049
3014
  */
3050
- removeModule(e) {
3051
- const t = Fe.get(e);
3052
- if (t === void 0)
3053
- return this.comms.log(`Module "${e}" does not exist in the library`), !1;
3054
- const i = this.loadedModules.findIndex((s) => s instanceof t);
3015
+ removeModule(t) {
3016
+ const e = Dt.get(t);
3017
+ if (e === void 0)
3018
+ return this.comms.log(`Module "${t}" does not exist in the library`), !1;
3019
+ const i = this.loadedModules.findIndex((s) => s instanceof e);
3055
3020
  return i < 0 ? !1 : (this.loadedModules[i].unmount(this.wnd, this.comms), this.loadedModules.splice(i, 1), !0);
3056
3021
  }
3057
3022
  /**
3058
3023
  * Unmount and remove all modules
3059
3024
  */
3060
3025
  destroy() {
3061
- this.comms.destroy(), this.loadedModules.forEach((e) => e.unmount(this.wnd, this.comms)), this.loadedModules = [];
3026
+ this.comms.destroy(), this.loadedModules.forEach((t) => t.unmount(this.wnd, this.comms)), this.loadedModules = [];
3062
3027
  }
3063
3028
  }
3064
3029
  export {
3065
- V as COMMS_VERSION,
3066
- ht as Comms,
3067
- Ft as Decorator,
3068
- Yt as FXLModules,
3069
- Dt as Layout,
3070
- Kt as Loader,
3071
- K as Module,
3072
- Fe as ModuleLibrary,
3073
- it as Peripherals,
3074
- Zt as ReflowableModules,
3075
- Rt as Width,
3076
- lt as mid
3030
+ k as COMMS_VERSION,
3031
+ ae as Comms,
3032
+ De as Decorator,
3033
+ Xe as FXLModules,
3034
+ Le as Layout,
3035
+ Ye as Loader,
3036
+ Y as Module,
3037
+ Dt as ModuleLibrary,
3038
+ te as Peripherals,
3039
+ Ge as ReflowableModules,
3040
+ Ie as Width,
3041
+ oe as mid
3077
3042
  };