@readium/navigator-html-injectables 1.3.2 → 2.0.0-beta.1

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