@readium/shared 1.2.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/index.js +1256 -1152
  2. package/dist/index.umd.cjs +3 -3
  3. package/package.json +11 -10
  4. package/src/publication/AltIdentifier.ts +58 -0
  5. package/src/publication/Contributor.ts +15 -0
  6. package/src/publication/GuidedNavigation.ts +126 -15
  7. package/src/publication/Layout.ts +13 -0
  8. package/src/publication/Link.ts +9 -1
  9. package/src/publication/Manifest.ts +5 -5
  10. package/src/publication/Metadata.ts +77 -8
  11. package/src/publication/Profiles.ts +15 -0
  12. package/src/publication/Properties.ts +10 -0
  13. package/src/publication/Publication.ts +2 -2
  14. package/src/publication/ReadingProgression.ts +2 -15
  15. package/src/publication/TDM.ts +56 -0
  16. package/src/publication/epub/MediaOverlay.ts +43 -0
  17. package/src/publication/epub/Metadata.ts +16 -0
  18. package/src/publication/epub/Properties.ts +0 -10
  19. package/src/publication/epub/index.ts +2 -2
  20. package/src/publication/index.ts +4 -1
  21. package/src/util/JSONParse.ts +3 -3
  22. package/types/src/publication/AltIdentifier.d.ts +23 -0
  23. package/types/src/publication/Contributor.d.ts +4 -0
  24. package/types/src/publication/GuidedNavigation.d.ts +62 -9
  25. package/types/src/publication/Layout.d.ts +8 -0
  26. package/types/src/publication/Link.d.ts +3 -0
  27. package/types/src/publication/Manifest.d.ts +2 -2
  28. package/types/src/publication/Metadata.d.ts +25 -2
  29. package/types/src/publication/Profiles.d.ts +10 -0
  30. package/types/src/publication/Properties.d.ts +6 -0
  31. package/types/src/publication/Publication.d.ts +1 -1
  32. package/types/src/publication/ReadingProgression.d.ts +2 -5
  33. package/types/src/publication/TDM.d.ts +30 -0
  34. package/types/src/publication/accessibility/Accessibility.d.ts +196 -0
  35. package/types/src/publication/accessibility/AccessibilityMetadataDisplayGuide.d.ts +211 -0
  36. package/types/src/publication/accessibility/Localization.d.ts +37 -0
  37. package/types/src/publication/accessibility/index.d.ts +3 -0
  38. package/types/src/publication/epub/MediaOverlay.d.ts +19 -0
  39. package/types/src/publication/epub/Metadata.d.ts +6 -0
  40. package/types/src/publication/epub/Properties.d.ts +1 -5
  41. package/types/src/publication/epub/index.d.ts +2 -2
  42. package/types/src/publication/index.d.ts +4 -1
  43. package/types/src/util/JSONParse.d.ts +2 -2
  44. package/LICENSE +0 -28
  45. package/src/publication/epub/EPUBLayout.ts +0 -10
  46. package/src/publication/epub/Presentation.ts +0 -16
  47. package/src/publication/presentation/Metadata.ts +0 -19
  48. package/src/publication/presentation/Presentation.ts +0 -155
  49. package/src/publication/presentation/Properties.ts +0 -70
  50. package/src/publication/presentation/index.ts +0 -3
  51. package/types/src/publication/epub/EPUBLayout.d.ts +0 -5
  52. package/types/src/publication/epub/Presentation.d.ts +0 -7
  53. package/types/src/publication/presentation/Metadata.d.ts +0 -6
  54. package/types/src/publication/presentation/Presentation.d.ts +0 -95
  55. package/types/src/publication/presentation/Properties.d.ts +0 -32
  56. package/types/src/publication/presentation/index.d.ts +0 -3
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- class Ae {
1
+ class Ce {
2
2
  close() {
3
3
  }
4
4
  links() {
@@ -8,7 +8,7 @@ class Ae {
8
8
  throw Error("This is an empty fetcher");
9
9
  }
10
10
  }
11
- class mr {
11
+ class wr {
12
12
  constructor(t, e) {
13
13
  this.client = t || window.fetch.bind(window), this.baseUrl = e;
14
14
  }
@@ -19,12 +19,12 @@ class mr {
19
19
  const e = t.toURL(this.baseUrl);
20
20
  if (e === void 0)
21
21
  throw Error(`Invalid HREF: ${t.href}`);
22
- return new Se(this.client, t, e);
22
+ return new Re(this.client, t, e);
23
23
  }
24
24
  close() {
25
25
  }
26
26
  }
27
- class Se {
27
+ class Re {
28
28
  constructor(t, e, r) {
29
29
  this.client = t || window.fetch.bind(window), this._link = e, this.url = r;
30
30
  }
@@ -90,12 +90,12 @@ class Se {
90
90
  );
91
91
  }
92
92
  }
93
- class Er {
93
+ class Ar {
94
94
  constructor(t, e) {
95
95
  this.start = t, this.endInclusive = e;
96
96
  }
97
97
  }
98
- class br {
98
+ class Ir {
99
99
  readAsString() {
100
100
  return this.read().then((t) => t === void 0 ? t : new TextDecoder().decode(t));
101
101
  }
@@ -106,7 +106,7 @@ class br {
106
106
  return this.readAsString().then((t) => t === void 0 ? t : new DOMParser().parseFromString(t, "text/xml"));
107
107
  }
108
108
  }
109
- class ht {
109
+ class pt {
110
110
  /**
111
111
  * Creates a [Encryption].
112
112
  */
@@ -118,7 +118,7 @@ class ht {
118
118
  */
119
119
  static deserialize(t) {
120
120
  if (t && t.algorithm)
121
- return new ht({
121
+ return new pt({
122
122
  algorithm: t.algorithm,
123
123
  compression: t.compression,
124
124
  originalLength: t.originalLength,
@@ -134,16 +134,20 @@ class ht {
134
134
  return this.compression !== void 0 && (t.compression = this.compression), this.originalLength !== void 0 && (t.originalLength = this.originalLength), this.profile !== void 0 && (t.profile = this.profile), this.scheme !== void 0 && (t.scheme = this.scheme), t;
135
135
  }
136
136
  }
137
- class m {
137
+ var at = /* @__PURE__ */ ((i) => (i.left = "left", i.right = "right", i.center = "center", i))(at || {});
138
+ class A {
138
139
  constructor(t) {
139
140
  this.otherProperties = t;
140
141
  }
142
+ get page() {
143
+ return this.otherProperties.page;
144
+ }
141
145
  /**
142
146
  * Creates a [Properties] from its RWPM JSON representation.
143
147
  */
144
148
  static deserialize(t) {
145
149
  if (t)
146
- return new m(t);
150
+ return new A(t);
147
151
  }
148
152
  /**
149
153
  * Serializes a [Properties] to its RWPM JSON representation.
@@ -158,54 +162,85 @@ class m {
158
162
  const e = Object.assign({}, this.otherProperties);
159
163
  for (const r in t)
160
164
  e[r] = t[r];
161
- return new m(e);
165
+ return new A(e);
162
166
  }
163
167
  }
164
- Object.defineProperty(m.prototype, "encryption", {
168
+ Object.defineProperty(A.prototype, "encryption", {
165
169
  get: function() {
166
- return ht.deserialize(this.otherProperties.encrypted);
170
+ return pt.deserialize(this.otherProperties.encrypted);
167
171
  }
168
172
  });
169
- var Rt = /* @__PURE__ */ ((i) => (i.fixed = "fixed", i.reflowable = "reflowable", i))(Rt || {}), Ie = /* @__PURE__ */ ((i) => (i.auto = "auto", i.landscape = "landscape", i.portrait = "portrait", i))(Ie || {}), Te = /* @__PURE__ */ ((i) => (i.auto = "auto", i.clipped = "clipped", i.paginated = "paginated", i.scrolled = "scrolled", i))(Te || {}), H = /* @__PURE__ */ ((i) => (i.left = "left", i.right = "right", i.center = "center", i))(H || {}), ze = /* @__PURE__ */ ((i) => (i.auto = "auto", i.both = "both", i.none = "none", i.landscape = "landscape", i))(ze || {}), ve = /* @__PURE__ */ ((i) => (i.contain = "contain", i.cover = "cover", i.width = "width", i.height = "height", i))(ve || {});
170
- class _ {
171
- /** Creates a [Presentation]. */
173
+ class gt {
174
+ /** Creates a MediaOverlay object */
172
175
  constructor(t) {
173
- this.clipped = t.clipped, this.fit = t.fit, this.orientation = t.orientation, this.spread = t.spread, this.layout = t.layout, this.continuous = t.continuous, this.overflow = t.overflow;
176
+ this.activeClass = t.activeClass, this.playbackActiveClass = t.playbackActiveClass;
174
177
  }
175
178
  /**
176
- * Parses a [Presentation] from its RWPM JSON representation.
177
- *
179
+ * Parses a MediaOverlay from its RWPM JSON representation.
178
180
  */
179
181
  static deserialize(t) {
180
182
  if (t)
181
- return new _({
182
- clipped: t.clipped,
183
- continuous: t.continuous,
184
- fit: t.fit,
185
- orientation: t.orientation,
186
- overflow: t.overflow,
187
- spread: t.spread,
188
- layout: t.layout
183
+ return new gt({
184
+ activeClass: t.activeClass,
185
+ playbackActiveClass: t.playbackActiveClass
189
186
  });
190
187
  }
191
188
  /**
192
- * Serializes a [Presentation] to its RWPM JSON representation.
189
+ * Serializes a MediaOverlay to its RWPM JSON representation.
193
190
  */
194
191
  serialize() {
195
192
  const t = {};
196
- return this.clipped !== void 0 && (t.clipped = this.clipped), this.continuous !== void 0 && (t.continuous = this.continuous), this.fit !== void 0 && (t.fit = this.fit), this.orientation !== void 0 && (t.orientation = this.orientation), this.overflow !== void 0 && (t.overflow = this.overflow), this.spread !== void 0 && (t.spread = this.spread), this.layout !== void 0 && (t.layout = this.layout), t;
193
+ return this.activeClass && (t.activeClass = this.activeClass), this.playbackActiveClass && (t.playbackActiveClass = this.playbackActiveClass), t;
194
+ }
195
+ }
196
+ function Pe(i) {
197
+ return i && i instanceof Array ? i : void 0;
198
+ }
199
+ function N(i) {
200
+ return i && typeof i == "string" ? [i] : Pe(i);
201
+ }
202
+ function K(i) {
203
+ return typeof i == "string" ? new Date(i) : void 0;
204
+ }
205
+ function L(i) {
206
+ return isNaN(i) ? void 0 : i;
207
+ }
208
+ function b(i) {
209
+ return L(i) !== void 0 && Math.sign(i) >= 0 ? i : void 0;
210
+ }
211
+ function q(i) {
212
+ const t = new Array();
213
+ return i.forEach((e) => t.push(e)), t;
214
+ }
215
+ class k {
216
+ /** Creates an AltIdentifier object */
217
+ constructor(t) {
218
+ this.value = t.value, this.scheme = t.scheme;
219
+ }
220
+ /**
221
+ * Parses an AltIdentifier from its RWPM JSON representation.
222
+ */
223
+ static deserialize(t) {
224
+ if (t) {
225
+ if (typeof t == "string")
226
+ return new k({ value: t });
227
+ if (typeof t == "object" && t.value)
228
+ return new k({
229
+ value: t.value,
230
+ scheme: t.scheme
231
+ });
232
+ }
233
+ }
234
+ /**
235
+ * Serializes an AltIdentifier to its RWPM JSON representation.
236
+ */
237
+ serialize() {
238
+ return this.scheme ? {
239
+ value: this.value,
240
+ scheme: this.scheme
241
+ } : this.value;
197
242
  }
198
243
  }
199
- _.prototype.layoutOf = function(i) {
200
- var t;
201
- return ((t = i.properties) == null ? void 0 : t.getLayout()) || this.layout || Rt.reflowable;
202
- };
203
- m.prototype.getContains = function() {
204
- return new Set(this.otherProperties.contains || []);
205
- };
206
- m.prototype.getLayout = function() {
207
- return this.otherProperties.layout;
208
- };
209
244
  class a {
210
245
  /** Creates a MediaType object. */
211
246
  constructor(t) {
@@ -218,21 +253,21 @@ class a {
218
253
  throw new Error("Invalid media type");
219
254
  const o = {};
220
255
  for (let f = 1; f < s.length; f++) {
221
- const d = s[f].split("=");
222
- if (d.length === 2) {
223
- const I = d[0].toLocaleLowerCase(), L = I === "charset" ? d[1].toUpperCase() : d[1];
224
- o[I] = L;
256
+ const p = s[f].split("=");
257
+ if (p.length === 2) {
258
+ const S = p[0].toLocaleLowerCase(), D = S === "charset" ? p[1].toUpperCase() : p[1];
259
+ o[S] = D;
225
260
  }
226
261
  }
227
262
  const l = {}, c = Object.keys(o);
228
- c.sort((f, d) => f.localeCompare(d)), c.forEach((f) => l[f] = o[f]);
263
+ c.sort((f, p) => f.localeCompare(p)), c.forEach((f) => l[f] = o[f]);
229
264
  let h = "";
230
265
  for (const f in l) {
231
- const d = l[f];
232
- h += `;${f}=${d}`;
266
+ const p = l[f];
267
+ h += `;${f}=${p}`;
233
268
  }
234
- const u = `${e}/${r}${h}`, p = l.encoding;
235
- this.string = u, this.type = e, this.subtype = r, this.parameters = l, this.encoding = p, this.name = t.name, this.fileExtension = t.fileExtension;
269
+ const u = `${e}/${r}${h}`, d = l.encoding;
270
+ this.string = u, this.type = e, this.subtype = r, this.parameters = l, this.encoding = d, this.name = t.name, this.fileExtension = t.fileExtension;
236
271
  }
237
272
  static parse(t) {
238
273
  return new a(t);
@@ -661,7 +696,7 @@ class a {
661
696
  });
662
697
  }
663
698
  }
664
- class J {
699
+ class Z {
665
700
  constructor(t) {
666
701
  this.uri = t, this.parameters = this.getParameters(t);
667
702
  }
@@ -689,26 +724,7 @@ class J {
689
724
  return this.uri.replace(/\{(\??)([^}]+)\}/g, (...s) => s[1] ? r(s[2]) : e(s[2]));
690
725
  }
691
726
  }
692
- function Oe(i) {
693
- return i && i instanceof Array ? i : void 0;
694
- }
695
- function R(i) {
696
- return i && typeof i == "string" ? [i] : Oe(i);
697
- }
698
- function Y(i) {
699
- return typeof i == "string" ? new Date(i) : void 0;
700
- }
701
- function C(i) {
702
- return isNaN(i) ? void 0 : i;
703
- }
704
- function y(i) {
705
- return C(i) !== void 0 && Math.sign(i) >= 0 ? i : void 0;
706
- }
707
- function ut(i) {
708
- const t = new Array();
709
- return i.forEach((e) => t.push(e)), t;
710
- }
711
- class E {
727
+ class m {
712
728
  /**
713
729
  * Creates a [Locations].
714
730
  */
@@ -721,7 +737,7 @@ class E {
721
737
  static deserialize(t) {
722
738
  if (!t)
723
739
  return;
724
- const e = C(t.progression), r = C(t.totalProgression), s = C(t.position), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([
740
+ const e = L(t.progression), r = L(t.totalProgression), s = L(t.position), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([
725
741
  "fragment",
726
742
  "fragments",
727
743
  "progression",
@@ -730,8 +746,8 @@ class E {
730
746
  ]);
731
747
  return Object.entries(t).forEach(([l, c]) => {
732
748
  o.has(l) || n.set(l, c);
733
- }), new E({
734
- fragments: R(t.fragments || t.fragment),
749
+ }), new m({
750
+ fragments: N(t.fragments || t.fragment),
735
751
  progression: e !== void 0 && e >= 0 && e <= 1 ? e : void 0,
736
752
  totalProgression: r !== void 0 && r >= 0 && r <= 1 ? r : void 0,
737
753
  position: s !== void 0 && s > 0 ? s : void 0,
@@ -746,7 +762,7 @@ class E {
746
762
  return this.fragments && (t.fragments = this.fragments), this.progression !== void 0 && (t.progression = this.progression), this.totalProgression !== void 0 && (t.totalProgression = this.totalProgression), this.position !== void 0 && (t.position = this.position), this.otherLocations && this.otherLocations.forEach((e, r) => t[r] = e), t;
747
763
  }
748
764
  }
749
- class M {
765
+ class H {
750
766
  /**
751
767
  * Creates a [Text].
752
768
  */
@@ -758,7 +774,7 @@ class M {
758
774
  */
759
775
  static deserialize(t) {
760
776
  if (t)
761
- return new M({
777
+ return new H({
762
778
  after: t.after,
763
779
  before: t.before,
764
780
  highlight: t.highlight
@@ -772,24 +788,24 @@ class M {
772
788
  return this.after !== void 0 && (t.after = this.after), this.before !== void 0 && (t.before = this.before), this.highlight !== void 0 && (t.highlight = this.highlight), t;
773
789
  }
774
790
  }
775
- class A {
791
+ class w {
776
792
  /**
777
793
  * Creates a [Locator].
778
794
  */
779
795
  constructor(t) {
780
- this.href = t.href, this.type = t.type, this.title = t.title, this.locations = t.locations ? t.locations : new E({}), this.text = t.text;
796
+ this.href = t.href, this.type = t.type, this.title = t.title, this.locations = t.locations ? t.locations : new m({}), this.text = t.text;
781
797
  }
782
798
  /**
783
799
  * Parses a [Link] from its RWPM JSON representation.
784
800
  */
785
801
  static deserialize(t) {
786
802
  if (t && t.href && t.type)
787
- return new A({
803
+ return new w({
788
804
  href: t.href,
789
805
  type: t.type,
790
806
  title: t.title,
791
- locations: E.deserialize(t.locations),
792
- text: M.deserialize(t.text)
807
+ locations: m.deserialize(t.locations),
808
+ text: H.deserialize(t.text)
793
809
  });
794
810
  }
795
811
  /**
@@ -803,39 +819,40 @@ class A {
803
819
  * Shortcut to get a copy of the [Locator] with different [Locations] sub-properties.
804
820
  */
805
821
  copyWithLocations(t) {
806
- return new A({
822
+ return new w({
807
823
  href: this.href,
808
824
  type: this.type,
809
825
  title: this.title,
810
826
  text: this.text,
811
- locations: new E({ ...this.locations, ...t })
827
+ locations: new m({ ...this.locations, ...t })
812
828
  });
813
829
  }
814
830
  }
815
- class S {
831
+ class I {
816
832
  /**
817
833
  * Creates a [Link].
818
834
  */
819
835
  constructor(t) {
820
- this.href = t.href, this.templated = t.templated, this.type = t.type, this.title = t.title, this.rels = t.rels, this.properties = t.properties, this.height = t.height, this.width = t.width, this.duration = t.duration, this.bitrate = t.bitrate, this.languages = t.languages, this.alternates = t.alternates, this.children = t.children;
836
+ this.href = t.href, this.templated = t.templated, this.type = t.type, this.title = t.title, this.rels = t.rels, this.properties = t.properties, this.height = t.height, this.width = t.width, this.size = t.size, this.duration = t.duration, this.bitrate = t.bitrate, this.languages = t.languages, this.alternates = t.alternates, this.children = t.children;
821
837
  }
822
838
  /**
823
839
  * Parses a [Link] from its RWPM JSON representation.
824
840
  */
825
841
  static deserialize(t) {
826
- if (t && t.href && typeof t.href == "string")
827
- return new S({
842
+ if (!(!t || typeof t.href != "string"))
843
+ return new I({
828
844
  href: t.href,
829
845
  templated: t.templated,
830
846
  type: t.type,
831
847
  title: t.title,
832
848
  rels: t.rel ? t.rel instanceof Array ? new Set(t.rel) : /* @__PURE__ */ new Set([t.rel]) : void 0,
833
- properties: m.deserialize(t.properties),
834
- height: y(t.height),
835
- width: y(t.width),
836
- duration: y(t.duration),
837
- bitrate: y(t.bitrate),
838
- languages: R(t.language),
849
+ properties: A.deserialize(t.properties),
850
+ height: b(t.height),
851
+ width: b(t.width),
852
+ size: b(t.size),
853
+ duration: b(t.duration),
854
+ bitrate: b(t.bitrate),
855
+ languages: N(t.language),
839
856
  alternates: x.deserialize(t.alternate),
840
857
  children: x.deserialize(t.children)
841
858
  });
@@ -845,7 +862,7 @@ class S {
845
862
  */
846
863
  serialize() {
847
864
  const t = { href: this.href };
848
- return this.templated !== void 0 && (t.templated = this.templated), this.type !== void 0 && (t.type = this.type), this.title !== void 0 && (t.title = this.title), this.rels && (t.rel = ut(this.rels)), this.properties && (t.properties = this.properties.serialize()), this.height !== void 0 && (t.height = this.height), this.width !== void 0 && (t.width = this.width), this.duration !== void 0 && (t.duration = this.duration), this.bitrate !== void 0 && (t.bitrate = this.bitrate), this.languages && (t.language = this.languages), this.alternates && (t.alternate = this.alternates.serialize()), this.children && (t.children = this.children.serialize()), t;
865
+ return this.templated !== void 0 && (t.templated = this.templated), this.type !== void 0 && (t.type = this.type), this.title !== void 0 && (t.title = this.title), this.rels && (t.rel = q(this.rels)), this.properties && (t.properties = this.properties.serialize()), this.height !== void 0 && (t.height = this.height), this.width !== void 0 && (t.width = this.width), this.size !== void 0 && (t.size = this.size), this.duration !== void 0 && (t.duration = this.duration), this.bitrate !== void 0 && (t.bitrate = this.bitrate), this.languages && (t.language = this.languages), this.alternates && (t.alternate = this.alternates.serialize()), this.children && (t.children = this.children.serialize()), t;
849
866
  }
850
867
  /** MediaType of the linked resource. */
851
868
  get mediaType() {
@@ -863,14 +880,14 @@ class S {
863
880
  }
864
881
  /** List of URI template parameter keys, if the `Link` is templated. */
865
882
  get templateParameters() {
866
- return this.templated ? new J(this.href).parameters : /* @__PURE__ */ new Set();
883
+ return this.templated ? new Z(this.href).parameters : /* @__PURE__ */ new Set();
867
884
  }
868
885
  /** Expands the `Link`'s HREF by replacing URI template variables by the given parameters.
869
886
  * See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
870
887
  */
871
888
  expandTemplate(t) {
872
- return new S({
873
- href: new J(this.href).expand(t),
889
+ return new I({
890
+ href: new Z(this.href).expand(t),
874
891
  templated: !1
875
892
  });
876
893
  }
@@ -879,19 +896,19 @@ class S {
879
896
  */
880
897
  addProperties(t) {
881
898
  var r;
882
- const e = S.deserialize(this.serialize());
883
- return e.properties = e.properties ? (r = e.properties) == null ? void 0 : r.add(t) : new m(t), e;
899
+ const e = I.deserialize(this.serialize());
900
+ return e.properties = e.properties ? (r = e.properties) == null ? void 0 : r.add(t) : new A(t), e;
884
901
  }
885
902
  /**
886
903
  * Creates a [Locator] from a reading order [Link].
887
904
  */
888
905
  get locator() {
889
906
  let t = this.href.split("#");
890
- return new A({
907
+ return new w({
891
908
  href: t.length > 0 && t[0] !== void 0 ? t[0] : this.href,
892
909
  type: this.type ?? "",
893
910
  title: this.title,
894
- locations: new E({
911
+ locations: new m({
895
912
  fragments: t.length > 1 && t[1] !== void 0 ? [t[1]] : []
896
913
  })
897
914
  });
@@ -910,7 +927,7 @@ class x {
910
927
  static deserialize(t) {
911
928
  if (t && t instanceof Array)
912
929
  return new x(
913
- t.map((e) => S.deserialize(e)).filter((e) => e !== void 0)
930
+ t.map((e) => I.deserialize(e)).filter((e) => e !== void 0)
914
931
  );
915
932
  }
916
933
  /**
@@ -991,107 +1008,534 @@ class x {
991
1008
  return this.items.filter((t) => t.type);
992
1009
  }
993
1010
  }
994
- class ft {
1011
+ const mt = class R {
1012
+ /**
1013
+ * translations can be a string or a collection of language/translation pairs,
1014
+ * for a single string the language is assumed to be undefined
1015
+ */
995
1016
  constructor(t) {
996
- this.links = t.links, this.guided = t.guided;
1017
+ this.translations = typeof t == "string" ? { [R.UNDEFINED_LANGUAGE]: t } : t;
997
1018
  }
1019
+ /**
1020
+ * Parses a [LocalizedString] from its RWPM JSON representation.
1021
+ *
1022
+ * "anyOf": [
1023
+ * {
1024
+ * "type": "string"
1025
+ * },
1026
+ * {
1027
+ * "description": "The language in a language map must be a valid BCP 47 tag.",
1028
+ * "type": "object",
1029
+ * "patternProperties": {
1030
+ * "^((?<grandfathered>(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)|(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang))|((?<language>([A-Za-z]{2,3}(-(?<extlang>[A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-(?<script>[A-Za-z]{4}))?(-(?<region>[A-Za-z]{2}|[0-9]{3}))?(-(?<variant>[A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-(?<extension>[0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(?<privateUse>x(-[A-Za-z0-9]{1,8})+))?)|(?<privateUse2>x(-[A-Za-z0-9]{1,8})+))$": {
1031
+ * "type": "string"
1032
+ * }
1033
+ * },
1034
+ * "additionalProperties": false,
1035
+ * "minProperties": 1
1036
+ * }
1037
+ * ]
1038
+ */
1039
+ static deserialize(t) {
1040
+ if (t && (typeof t == "string" || t.constructor === Object))
1041
+ return new R(t);
1042
+ }
1043
+ serialize() {
1044
+ return this.translations;
1045
+ }
1046
+ /**
1047
+ * Returns the first translation for the given [language] BCP–47 tag.
1048
+ * If not found, then fallback:
1049
+ * 1. on the undefined language
1050
+ * 2. on the English language
1051
+ * 3. the first translation found
1052
+ * 4. returns empty string
1053
+ */
1054
+ getTranslation(t) {
1055
+ return this.translations[t || R.UNDEFINED_LANGUAGE] || this.translations[R.UNDEFINED_LANGUAGE] || this.translations[R.LANGUAGE_EN] || (Object.values(this.translations).length === 0 ? "" : Object.values(this.translations)[0]);
1056
+ }
1057
+ };
1058
+ mt.UNDEFINED_LANGUAGE = "undefined";
1059
+ mt.LANGUAGE_EN = "en";
1060
+ let T = mt;
1061
+ class X {
1062
+ /**
1063
+ * Creates a [Contributor] object.
1064
+ */
1065
+ constructor(t) {
1066
+ this.name = t.name, this.sortAs = t.sortAs, this.identifier = t.identifier, this.altIdentifiers = t.altIdentifiers, this.roles = t.roles, this.links = t.links, this.position = t.position;
1067
+ }
1068
+ /**
1069
+ * Parses a [Contributor] from its RWPM JSON representation.
1070
+ *
1071
+ * A contributor can be parsed from a single string, or a full-fledged object.
1072
+ */
998
1073
  static deserialize(t) {
999
1074
  if (t)
1000
- return new ft({
1075
+ return typeof t == "string" ? new X({
1076
+ name: T.deserialize(t)
1077
+ }) : t.name ? new X({
1078
+ name: T.deserialize(t.name),
1079
+ sortAs: t.sortAs,
1080
+ identifier: t.identifier,
1081
+ altIdentifiers: t.altIdentifier ? t.altIdentifier instanceof Array ? new Set(t.altIdentifier.map((e) => k.deserialize(e)).filter((e) => e !== void 0)) : new Set([k.deserialize(t.altIdentifier)].filter((e) => e !== void 0)) : void 0,
1082
+ roles: t.role ? new Set(N(t.role)) : void 0,
1001
1083
  links: x.deserialize(t.links),
1002
- guided: k.deserializeArray(t.guided)
1003
- });
1084
+ position: L(t.position)
1085
+ }) : void 0;
1004
1086
  }
1087
+ /**
1088
+ * Serializes a [Contributor] to its RWPM JSON representation.
1089
+ */
1005
1090
  serialize() {
1006
- const t = {};
1007
- return this.links !== void 0 && (t.links = this.links.serialize()), this.guided !== void 0 && (t.guided = this.guided.map((e) => e.serialize())), t;
1091
+ const t = { name: this.name.serialize() };
1092
+ return this.sortAs !== void 0 && (t.sortAs = this.sortAs), this.identifier !== void 0 && (t.identifier = this.identifier), this.altIdentifiers && (t.altIdentifier = q(this.altIdentifiers).map((e) => e.serialize())), this.roles && (t.role = q(this.roles)), this.links && (t.links = this.links.serialize()), this.position !== void 0 && (t.position = this.position), t;
1008
1093
  }
1009
1094
  }
1010
- class k {
1095
+ class E {
1011
1096
  /**
1012
- * Creates a [GuidedNavigation] object.
1013
- */
1097
+ * Creates a [Contributors] object.
1098
+ */
1014
1099
  constructor(t) {
1015
- this.audioref = t.audioref, this.children = t.children, this.imgref = t.imgref, this.role = t.role, this.text = t.text, this.textref = t.textref;
1100
+ this.items = t;
1016
1101
  }
1017
1102
  /**
1018
- * Parses a [GuidedNavigationObject] from its RWPM JSON representation.
1103
+ * Parses a [Contributors] from its RWPM JSON representation.
1019
1104
  *
1020
- * A GuidedNavigationObject can be parsed from a single string, or a full-fledged object.
1021
- */
1105
+ */
1022
1106
  static deserialize(t) {
1023
- if (t)
1024
- return new k({
1025
- audioref: t.audioref,
1026
- children: k.deserializeArray(t.children),
1027
- imgref: t.imgref,
1028
- role: t.role ? new Set(R(t.role)) : void 0,
1029
- text: t.text,
1030
- textref: t.textref
1031
- });
1107
+ if (!t)
1108
+ return;
1109
+ const e = t instanceof Array ? t : [t];
1110
+ return new E(
1111
+ e.map((r) => X.deserialize(r)).filter((r) => r !== void 0)
1112
+ );
1032
1113
  }
1033
- /**
1034
- * Parses a [GuidedNavigationObject] array from its RWPM JSON representation.
1035
- */
1036
- static deserializeArray(t) {
1037
- if (t instanceof Array)
1038
- return t.map((e) => k.deserialize(e)).filter((e) => e !== void 0);
1114
+ /**
1115
+ * Serializes a [Contributors] to its RWPM JSON representation.
1116
+ */
1117
+ serialize() {
1118
+ return this.items.map((t) => t.serialize());
1119
+ }
1120
+ }
1121
+ class F {
1122
+ /** Creates an Array of [Subject]. */
1123
+ constructor(t) {
1124
+ this.items = t && t.items ? t.items : /* @__PURE__ */ new Map();
1039
1125
  }
1040
1126
  /**
1041
- * Serializes a [GuidedNavigationObject] to its RWPM JSON representation.
1042
- */
1127
+ * Parses a [BelongsTo] from its RWPM JSON representation.
1128
+ */
1129
+ static deserialize(t) {
1130
+ if (!(t && t instanceof Object))
1131
+ return;
1132
+ const e = /* @__PURE__ */ new Map();
1133
+ return Object.entries(t).forEach(([r, s]) => {
1134
+ const n = E.deserialize(s);
1135
+ n && n.items.length > 0 && e.set(r, n);
1136
+ }), new F({ items: e });
1137
+ }
1138
+ /**
1139
+ * Serializes a [BelongsTo] to its RWPM JSON representation.
1140
+ */
1043
1141
  serialize() {
1044
1142
  const t = {};
1045
- return this.audioref !== void 0 && (t.audioref = this.audioref), this.children !== void 0 && (t.children = this.children.map((e) => e.serialize())), this.imgref !== void 0 && (t.imgref = this.imgref), this.role !== void 0 && (t.role = ut(this.role)), this.text !== void 0 && (t.text = this.text), this.textref !== void 0 && (t.textref = this.textref), t;
1143
+ return this.items.forEach(
1144
+ (e, r) => t[r] = e.serialize()
1145
+ ), t;
1046
1146
  }
1047
- get audioFile() {
1048
- var t;
1049
- return (t = this.audioref) == null ? void 0 : t.split("#")[0];
1147
+ }
1148
+ var U = /* @__PURE__ */ ((i) => (i.reflowable = "reflowable", i.fixed = "fixed", i.scrolled = "scrolled", i))(U || {}), B = /* @__PURE__ */ ((i) => (i.EPUB = "https://readium.org/webpub-manifest/profiles/epub", i.AUDIOBOOK = "https://readium.org/webpub-manifest/profiles/audiobook", i.DIVINA = "https://readium.org/webpub-manifest/profiles/divina", i.PDF = "https://readium.org/webpub-manifest/profiles/pdf", i))(B || {}), O = /* @__PURE__ */ ((i) => (i.ltr = "ltr", i.rtl = "rtl", i))(O || {});
1149
+ function Sr(i) {
1150
+ return i === "rtl" ? at.right : at.left;
1151
+ }
1152
+ class Q {
1153
+ /** Creates a [Subject]. */
1154
+ constructor(t) {
1155
+ this.name = t.name, this.sortAs = t.sortAs, this.code = t.code, this.scheme = t.scheme, this.links = t.links;
1050
1156
  }
1051
- get audioTime() {
1052
- var t;
1053
- if ((t = this.audioref) != null && t.includes("#"))
1054
- return this.audioref.split("#", 2)[1];
1157
+ /**
1158
+ * Parses a [Subject] from its RWPM JSON representation.
1159
+ *
1160
+ * A [Subject] can be parsed from a single string, or a full-fledged object.
1161
+ */
1162
+ static deserialize(t) {
1163
+ if (t)
1164
+ return typeof t == "string" ? new Q({
1165
+ name: T.deserialize(t)
1166
+ }) : t.name ? new Q({
1167
+ name: T.deserialize(t.name),
1168
+ sortAs: t.sortAs,
1169
+ code: t.code,
1170
+ scheme: t.scheme,
1171
+ links: x.deserialize(t.links)
1172
+ }) : void 0;
1055
1173
  }
1056
- get textFile() {
1057
- var t;
1058
- return (t = this.textref) == null ? void 0 : t.split("#")[0];
1174
+ /**
1175
+ * Serializes a [Subject] to its RWPM JSON representation.
1176
+ */
1177
+ serialize() {
1178
+ const t = { name: this.name.serialize() };
1179
+ return this.sortAs !== void 0 && (t.sortAs = this.sortAs), this.code !== void 0 && (t.code = this.code), this.scheme !== void 0 && (t.scheme = this.scheme), this.links && (t.links = this.links.serialize()), t;
1059
1180
  }
1060
- get fragmentId() {
1061
- var t;
1062
- if ((t = this.textref) != null && t.includes("#"))
1063
- return this.textref.split("#", 2)[1];
1181
+ }
1182
+ class Et {
1183
+ /** Creates an Array of [Subject]. */
1184
+ constructor(t) {
1185
+ this.items = t;
1064
1186
  }
1065
- get clip() {
1066
- const t = this.audioFile;
1187
+ /**
1188
+ * Parses a [Subjects] from its RWPM JSON representation.
1189
+ */
1190
+ static deserialize(t) {
1067
1191
  if (!t)
1068
1192
  return;
1069
- const e = this.audioTime, r = {
1070
- audioResource: t,
1071
- fragmentId: this.fragmentId
1072
- };
1073
- if (!e)
1074
- return r;
1075
- const s = this.parseTimer(e);
1076
- return r.start = s[0], r.end = s[1], r;
1193
+ const e = t instanceof Array ? t : [t];
1194
+ return new Et(
1195
+ e.map((r) => Q.deserialize(r)).filter((r) => r !== void 0)
1196
+ );
1077
1197
  }
1078
- parseTimer(t) {
1079
- if (!t || !t.startsWith("t="))
1080
- return [void 0, void 0];
1081
- const e = t.substring(2).split(",").map((r) => parseFloat(r));
1082
- return e.length === 1 ? [isNaN(e[0]) ? void 0 : e[0], void 0] : e.length > 2 ? [void 0, void 0] : [isNaN(e[0]) ? void 0 : e[0], isNaN(e[1]) ? void 0 : e[1]];
1198
+ /**
1199
+ * Serializes a [Subjects] to its RWPM JSON representation.
1200
+ */
1201
+ serialize() {
1202
+ return this.items.map((t) => t.serialize());
1083
1203
  }
1084
1204
  }
1085
- function Ne(i, t) {
1086
- return t.length > 1 ? t.indexOf(i.slice(-1)) > -1 : i.slice(-1) === t;
1087
- }
1088
- function Pe(i, t) {
1089
- return i.slice(i.length - t.length) === t;
1205
+ var Le = /* @__PURE__ */ ((i) => (i.all = "all", i.none = "none", i))(Le || {});
1206
+ class bt {
1207
+ /** Creates a [TDM] object */
1208
+ constructor(t) {
1209
+ this.reservation = t.reservation, this.policy = t.policy;
1210
+ }
1211
+ /**
1212
+ * Parses a [TDM] from its RWPM JSON representation.
1213
+ */
1214
+ static deserialize(t) {
1215
+ if (t)
1216
+ return new bt({
1217
+ reservation: t.reservation,
1218
+ policy: t.policy
1219
+ });
1220
+ }
1221
+ /**
1222
+ * Serializes a [TDM] to its RWPM JSON representation.
1223
+ */
1224
+ serialize() {
1225
+ const t = {};
1226
+ return this.reservation !== void 0 && (t.reservation = this.reservation), this.policy !== void 0 && (t.policy = this.policy), t;
1227
+ }
1090
1228
  }
1091
- const et = {
1092
- endsWith: Pe,
1093
- endsWithChar: Ne
1094
- }, Ce = [
1229
+ const Bt = class lt {
1230
+ /** Creates [Metadata] object */
1231
+ constructor(t) {
1232
+ this.title = t.title, this.typeUri = t.typeUri, this.conformsTo = t.conformsTo, this.identifier = t.identifier, this.altIdentifier = t.altIdentifier, this.subtitle = t.subtitle, this.sortAs = t.sortAs, this.artists = t.artists, this.authors = t.authors, this.colorists = t.colorists, this.contributors = t.contributors, this.editors = t.editors, this.illustrators = t.illustrators, this.inkers = t.inkers, this.letterers = t.letterers, this.narrators = t.narrators, this.pencilers = t.pencilers, this.translators = t.translators, this.languages = t.languages, this.description = t.description, this.publishers = t.publishers, this.imprints = t.imprints, this.published = t.published, this.modified = t.modified, this.subjects = t.subjects, this.belongsTo = t.belongsTo, this.belongsToCollections = t.belongsToCollections, this.belongsToSeries = t.belongsToSeries, this.belongsToCollections && this.belongsToCollections.items.length > 0 && (this.belongsTo || (this.belongsTo = new F()), this.belongsTo.items.set("collection", this.belongsToCollections)), this.belongsToSeries && this.belongsToSeries.items.length > 0 && (this.belongsTo || (this.belongsTo = new F()), this.belongsTo.items.set("series", this.belongsToSeries)), this.layout = t.layout, this.readingProgression = t.readingProgression, this.duration = t.duration, this.numberOfPages = t.numberOfPages, this.tdm = t.tdm, this.otherMetadata = t.otherMetadata;
1233
+ }
1234
+ /**
1235
+ * Parses a [Metadata] from its RWPM JSON representation.
1236
+ *
1237
+ * If the metadata can't be parsed, a warning will be logged with [warnings].
1238
+ */
1239
+ static deserialize(t) {
1240
+ if (!(t && t.title))
1241
+ return;
1242
+ const e = T.deserialize(t.title), r = t["@type"], s = N(t.conformsTo), n = t.identifier, o = k.deserialize(t.altIdentifier), l = T.deserialize(t.subtitle), c = T.deserialize(t.sortAs), h = E.deserialize(t.artist), u = E.deserialize(t.author), d = E.deserialize(t.colorist), f = E.deserialize(t.contributor), p = E.deserialize(t.editor), S = E.deserialize(t.illustrator), D = E.deserialize(t.inker), fe = E.deserialize(t.letterer), de = E.deserialize(t.narrator), pe = E.deserialize(t.penciler), ge = E.deserialize(t.translator), me = N(t.language), Ee = t.description, be = E.deserialize(t.publisher), xe = E.deserialize(t.imprint), ye = K(t.published), we = K(t.modified), Ae = Et.deserialize(t.subject), Ie = F.deserialize(t.belongsTo), Se = t.layout, ve = t.readingProgression, ze = b(t.duration), Te = b(t.numberOfPages), Oe = bt.deserialize(t.tdm);
1243
+ let J = Object.assign({}, t);
1244
+ return lt.mappedProperties.forEach((Ne) => delete J[Ne]), Object.keys(J).length === 0 && (J = void 0), new lt({
1245
+ title: e,
1246
+ typeUri: r,
1247
+ conformsTo: s,
1248
+ identifier: n,
1249
+ altIdentifier: o,
1250
+ subtitle: l,
1251
+ sortAs: c,
1252
+ artists: h,
1253
+ authors: u,
1254
+ colorists: d,
1255
+ contributors: f,
1256
+ editors: p,
1257
+ illustrators: S,
1258
+ inkers: D,
1259
+ letterers: fe,
1260
+ narrators: de,
1261
+ pencilers: pe,
1262
+ translators: ge,
1263
+ languages: me,
1264
+ description: Ee,
1265
+ publishers: be,
1266
+ imprints: xe,
1267
+ published: ye,
1268
+ modified: we,
1269
+ subjects: Ae,
1270
+ belongsTo: Ie,
1271
+ layout: Se,
1272
+ readingProgression: ve,
1273
+ duration: ze,
1274
+ numberOfPages: Te,
1275
+ tdm: Oe,
1276
+ otherMetadata: J
1277
+ });
1278
+ }
1279
+ /**
1280
+ * Serializes a [Metadata] to its RWPM JSON representation.
1281
+ */
1282
+ serialize() {
1283
+ const t = { title: this.title.serialize() };
1284
+ if (this.typeUri !== void 0 && (t["@type"] = this.typeUri), this.conformsTo && (t.conformsTo = this.conformsTo), this.identifier !== void 0 && (t.identifier = this.identifier), this.altIdentifier && (t.altIdentifier = this.altIdentifier.serialize()), this.subtitle && (t.subtitle = this.subtitle.serialize()), this.sortAs && (t.sortAs = this.sortAs.serialize()), this.editors && (t.editor = this.editors.serialize()), this.artists && (t.artist = this.artists.serialize()), this.authors && (t.author = this.authors.serialize()), this.colorists && (t.colorist = this.colorists.serialize()), this.contributors && (t.contributor = this.contributors.serialize()), this.illustrators && (t.illustrator = this.illustrators.serialize()), this.letterers && (t.letterer = this.letterers.serialize()), this.narrators && (t.narrator = this.narrators.serialize()), this.pencilers && (t.penciler = this.pencilers.serialize()), this.translators && (t.translator = this.translators.serialize()), this.inkers && (t.inker = this.inkers.serialize()), this.languages && (t.language = this.languages), this.description !== void 0 && (t.description = this.description), this.publishers && (t.publisher = this.publishers.serialize()), this.imprints && (t.imprint = this.imprints.serialize()), this.published !== void 0 && (t.published = this.published.toISOString()), this.modified !== void 0 && (t.modified = this.modified.toISOString()), this.subjects && (t.subject = this.subjects.serialize()), this.belongsTo && (t.belongsTo = this.belongsTo.serialize()), this.layout && (t.layout = this.layout), this.readingProgression && (t.readingProgression = this.readingProgression), this.duration !== void 0 && (t.duration = this.duration), this.numberOfPages !== void 0 && (t.numberOfPages = this.numberOfPages), this.tdm && (t.tdm = this.tdm.serialize()), this.otherMetadata) {
1285
+ const e = this.otherMetadata;
1286
+ Object.keys(e).forEach((r) => t[r] = e[r]);
1287
+ }
1288
+ return t;
1289
+ }
1290
+ /**
1291
+ * Computes a [Layout] using the [conformsTo] profile and layout property.
1292
+ *
1293
+ * Special cases:
1294
+ * - EPUB profile defaults to reflowable if layout is not present
1295
+ * - Divina profile defaults to fixed if layout is not present
1296
+ * - Layout is ignored for audiobook and PDF profiles
1297
+ * - Layout is ignored if set to reflowable on a Divina profile
1298
+ *
1299
+ * Note: Stops at the first matching profile.
1300
+ */
1301
+ get effectiveLayout() {
1302
+ if (!this.conformsTo)
1303
+ return null;
1304
+ for (const t of this.conformsTo)
1305
+ switch (t) {
1306
+ case B.EPUB:
1307
+ return this.layout || U.reflowable;
1308
+ case B.DIVINA:
1309
+ return this.layout === U.reflowable ? U.fixed : this.layout || U.fixed;
1310
+ case B.AUDIOBOOK:
1311
+ case B.PDF:
1312
+ return null;
1313
+ }
1314
+ return null;
1315
+ }
1316
+ /**
1317
+ * Computes a [ReadingProgression] when the value of [readingProgression] is undefined, using the publication language.
1318
+ *
1319
+ * See this issue for more details: https://github.com/readium/architecture/issues/113
1320
+ */
1321
+ get effectiveReadingProgression() {
1322
+ var r;
1323
+ if (this.readingProgression)
1324
+ return this.readingProgression;
1325
+ if (((r = this.languages) == null ? void 0 : r.length) !== 1)
1326
+ return O.ltr;
1327
+ const t = this.languages[0].toLowerCase();
1328
+ if (t === "zh-hant" || t === "zh-tw")
1329
+ return O.rtl;
1330
+ switch (t.split("-")[0]) {
1331
+ case "ar":
1332
+ return O.rtl;
1333
+ case "fa":
1334
+ return O.rtl;
1335
+ case "he":
1336
+ return O.rtl;
1337
+ default:
1338
+ return O.ltr;
1339
+ }
1340
+ }
1341
+ };
1342
+ Bt.mappedProperties = [
1343
+ "title",
1344
+ "@type",
1345
+ "conformsTo",
1346
+ "identifier",
1347
+ "altIdentifier",
1348
+ "subtitle",
1349
+ "sortAs",
1350
+ "artist",
1351
+ "author",
1352
+ "colorist",
1353
+ "contributor",
1354
+ "editor",
1355
+ "illustrator",
1356
+ "inker",
1357
+ "letterer",
1358
+ "narrator",
1359
+ "penciler",
1360
+ "translator",
1361
+ "language",
1362
+ "description",
1363
+ "publisher",
1364
+ "imprint",
1365
+ "published",
1366
+ "modified",
1367
+ "subject",
1368
+ "belongsTo",
1369
+ "layout",
1370
+ "readingProgression",
1371
+ "duration",
1372
+ "numberOfPages",
1373
+ "tdm"
1374
+ ];
1375
+ let Ft = Bt;
1376
+ Ft.prototype.getMediaOverlay = function() {
1377
+ var t;
1378
+ const i = (t = this.otherMetadata) == null ? void 0 : t.mediaOverlay;
1379
+ if (i)
1380
+ return gt.deserialize(i);
1381
+ };
1382
+ A.prototype.getContains = function() {
1383
+ return new Set(this.otherProperties.contains || []);
1384
+ };
1385
+ class xt {
1386
+ constructor(t) {
1387
+ this.links = t.links, this.guided = t.guided;
1388
+ }
1389
+ static deserialize(t) {
1390
+ if (t)
1391
+ return new xt({
1392
+ links: x.deserialize(t.links),
1393
+ guided: P.deserializeArray(t.guided)
1394
+ });
1395
+ }
1396
+ serialize() {
1397
+ const t = {};
1398
+ return this.links !== void 0 && (t.links = this.links.serialize()), this.guided !== void 0 && (t.guided = this.guided.map((e) => e.serialize())), t;
1399
+ }
1400
+ }
1401
+ class _ {
1402
+ constructor(t) {
1403
+ this.plain = t.plain, this.ssml = t.ssml, this.language = t.language;
1404
+ }
1405
+ /**
1406
+ * Deserializes a GuidedNavigationText from JSON
1407
+ */
1408
+ static deserialize(t) {
1409
+ if (t != null) {
1410
+ if (typeof t == "string")
1411
+ return new _({ plain: t });
1412
+ if (t.plain || t.ssml || t.language)
1413
+ return new _({
1414
+ plain: t.plain,
1415
+ ssml: t.ssml,
1416
+ language: t.language
1417
+ });
1418
+ }
1419
+ }
1420
+ /**
1421
+ * Serializes the text to a plain object
1422
+ */
1423
+ serialize() {
1424
+ const t = {};
1425
+ return this.plain !== void 0 && (t.plain = this.plain), this.ssml !== void 0 && (t.ssml = this.ssml), this.language !== void 0 && (t.language = this.language), Object.keys(t).length > 0 ? t : void 0;
1426
+ }
1427
+ }
1428
+ class P {
1429
+ /**
1430
+ * Creates a [GuidedNavigation] object.
1431
+ */
1432
+ constructor(t) {
1433
+ this.audioref = t.audioref, this.children = t.children, this.imgref = t.imgref, this.role = t.role, this.level = t.level !== void 0 ? Math.min(6, Math.max(1, t.level)) : void 0, this.text = t.text, this.textref = t.textref, this.description = t.description;
1434
+ }
1435
+ /**
1436
+ * Gets the plain text content.
1437
+ * Returns undefined if no text is available.
1438
+ */
1439
+ get plainText() {
1440
+ var t;
1441
+ return (t = this.text) == null ? void 0 : t.plain;
1442
+ }
1443
+ /**
1444
+ * Gets the SSML content if available.
1445
+ */
1446
+ get ssmlText() {
1447
+ var t;
1448
+ return (t = this.text) == null ? void 0 : t.ssml;
1449
+ }
1450
+ /**
1451
+ * Gets the language of the text if available.
1452
+ */
1453
+ get textLanguage() {
1454
+ var t;
1455
+ return (t = this.text) == null ? void 0 : t.language;
1456
+ }
1457
+ /**
1458
+ * Deserializes a GuidedNavigationObject from JSON
1459
+ */
1460
+ static deserialize(t) {
1461
+ if (t)
1462
+ return new P({
1463
+ audioref: t.audioref,
1464
+ children: P.deserializeArray(t.children),
1465
+ imgref: t.imgref,
1466
+ role: t.role ? new Set(N(t.role)) : void 0,
1467
+ level: typeof t.level == "number" ? t.level : void 0,
1468
+ text: _.deserialize(t.text),
1469
+ textref: t.textref,
1470
+ description: P.deserialize(t.description)
1471
+ });
1472
+ }
1473
+ /**
1474
+ * Parses a [GuidedNavigationObject] array from its RWPM JSON representation.
1475
+ */
1476
+ static deserializeArray(t) {
1477
+ if (t instanceof Array)
1478
+ return t.map((e) => P.deserialize(e)).filter((e) => e !== void 0);
1479
+ }
1480
+ /**
1481
+ * Serializes a [GuidedNavigationObject] to its RWPM JSON representation.
1482
+ */
1483
+ serialize() {
1484
+ const t = {};
1485
+ if (this.audioref !== void 0 && (t.audioref = this.audioref), this.children !== void 0 && (t.children = this.children.map((e) => e.serialize())), this.imgref !== void 0 && (t.imgref = this.imgref), this.role !== void 0 && (t.role = q(this.role)), this.level !== void 0 && (t.level = this.level), this.text !== void 0) {
1486
+ const e = this.text.serialize();
1487
+ e !== void 0 && (t.text = e);
1488
+ }
1489
+ return this.textref !== void 0 && (t.textref = this.textref), this.description && (t.description = this.description.serialize()), t;
1490
+ }
1491
+ get audioFile() {
1492
+ var t;
1493
+ return (t = this.audioref) == null ? void 0 : t.split("#")[0];
1494
+ }
1495
+ get audioTime() {
1496
+ var t;
1497
+ if ((t = this.audioref) != null && t.includes("#"))
1498
+ return this.audioref.split("#", 2)[1];
1499
+ }
1500
+ get textFile() {
1501
+ var t;
1502
+ return (t = this.textref) == null ? void 0 : t.split("#")[0];
1503
+ }
1504
+ get fragmentId() {
1505
+ var t;
1506
+ if ((t = this.textref) != null && t.includes("#"))
1507
+ return this.textref.split("#", 2)[1];
1508
+ }
1509
+ get clip() {
1510
+ const t = this.audioFile;
1511
+ if (!t)
1512
+ return;
1513
+ const e = this.audioTime, r = {
1514
+ audioResource: t,
1515
+ fragmentId: this.fragmentId
1516
+ };
1517
+ if (!e)
1518
+ return r;
1519
+ const s = this.parseTimer(e);
1520
+ return r.start = s[0], r.end = s[1], r;
1521
+ }
1522
+ parseTimer(t) {
1523
+ if (!t || !t.startsWith("t="))
1524
+ return [void 0, void 0];
1525
+ const e = t.substring(2).split(",").map((r) => parseFloat(r));
1526
+ return e.length === 1 ? [isNaN(e[0]) ? void 0 : e[0], void 0] : e.length > 2 ? [void 0, void 0] : [isNaN(e[0]) ? void 0 : e[0], isNaN(e[1]) ? void 0 : e[1]];
1527
+ }
1528
+ }
1529
+ function ke(i, t) {
1530
+ return t.length > 1 ? t.indexOf(i.slice(-1)) > -1 : i.slice(-1) === t;
1531
+ }
1532
+ function De(i, t) {
1533
+ return i.slice(i.length - t.length) === t;
1534
+ }
1535
+ const st = {
1536
+ endsWith: De,
1537
+ endsWithChar: ke
1538
+ }, Ue = [
1095
1539
  "ie",
1096
1540
  "eg",
1097
1541
  "ext",
@@ -1183,16 +1627,16 @@ const et = {
1183
1627
  "Fri",
1184
1628
  "Sat"
1185
1629
  ];
1186
- function Lt(i) {
1187
- return /^[A-Z][a-z].*/.test(i) || st(i);
1630
+ function Wt(i) {
1631
+ return /^[A-Z][a-z].*/.test(i) || ct(i);
1188
1632
  }
1189
- function Re(i) {
1190
- return Lt(i) || /``|"|'/.test(i.substring(0, 2));
1633
+ function Be(i) {
1634
+ return Wt(i) || /``|"|'/.test(i.substring(0, 2));
1191
1635
  }
1192
- function Le(i) {
1193
- return ~Ce.indexOf(i.replace(/\W+/g, ""));
1636
+ function Fe(i) {
1637
+ return ~Ue.indexOf(i.replace(/\W+/g, ""));
1194
1638
  }
1195
- function ke(i, t) {
1639
+ function We(i, t) {
1196
1640
  if (i === "a.m." || i === "p.m.") {
1197
1641
  var e = t.replace(/\W+/g, "").slice(-3).toLowerCase();
1198
1642
  if (e === "day")
@@ -1200,23 +1644,23 @@ function ke(i, t) {
1200
1644
  }
1201
1645
  return !1;
1202
1646
  }
1203
- function St(i) {
1647
+ function Ot(i) {
1204
1648
  var t = i.replace(/[\(\)\[\]\{\}]/g, "").match(/(.\.)*/);
1205
1649
  return t && t[0].length > 0;
1206
1650
  }
1207
- function It(i) {
1208
- return i.length <= 3 ? !0 : Lt(i);
1651
+ function Nt(i) {
1652
+ return i.length <= 3 ? !0 : Wt(i);
1209
1653
  }
1210
- function st(i, t) {
1654
+ function ct(i, t) {
1211
1655
  return t && (i = i.slice(t - 1, t + 2)), !isNaN(Number(i));
1212
1656
  }
1213
- function De(i) {
1657
+ function Me(i) {
1214
1658
  return i.match(/^(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?$/);
1215
1659
  }
1216
- function Ue(i) {
1660
+ function $e(i) {
1217
1661
  return i.match(/[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/);
1218
1662
  }
1219
- function Be(i) {
1663
+ function Ge(i) {
1220
1664
  var t = 0;
1221
1665
  if ((t = i.indexOf(".")) > -1 || (t = i.indexOf("!")) > -1 || (t = i.indexOf("?")) > -1) {
1222
1666
  var e = i.charAt(t + 1);
@@ -1225,10 +1669,10 @@ function Be(i) {
1225
1669
  }
1226
1670
  return !1;
1227
1671
  }
1228
- function Fe(i) {
1672
+ function He(i) {
1229
1673
  return i === "." || i === "!" || i === "?";
1230
1674
  }
1231
- function We(i, t) {
1675
+ function Ve(i, t) {
1232
1676
  t = Object.assign(t || {}, {
1233
1677
  newlineBoundary: t && t.newlineBoundary || !0
1234
1678
  });
@@ -1238,30 +1682,30 @@ function We(i, t) {
1238
1682
  i.re(e, { split: !0 }),
1239
1683
  // Merge words as sentences
1240
1684
  i.splitAndMerge(function(r, s, n, o, l, c) {
1241
- var h, u = [r, null], p = r, f = c.slice(l + 1).find(function(I) {
1242
- return !e.test(I.value);
1685
+ var h, u = [r, null], d = r, f = c.slice(l + 1).find(function(S) {
1686
+ return !e.test(S.value);
1243
1687
  });
1244
1688
  if (r === `
1245
- ` && t.newlineBoundary || Fe(r) || et.endsWithChar(r, "?!"))
1689
+ ` && t.newlineBoundary || He(r) || st.endsWithChar(r, "?!"))
1246
1690
  return u;
1247
- if (et.endsWithChar(r, ".")) {
1691
+ if (st.endsWithChar(r, ".")) {
1248
1692
  if (f) {
1249
- if (r.length === 2 && isNaN(r.charAt(0)) && r.match(/[a-zA-Z]/) || Le(r))
1250
- return p;
1251
- if (Re(f.value)) {
1252
- if (ke(r, f.value) || st(f.value) && It(r))
1253
- return p;
1254
- } else if (et.endsWith(r, "..") || St(r) || It(r))
1255
- return p;
1693
+ if (r.length === 2 && isNaN(r.charAt(0)) && r.match(/[a-zA-Z]/) || Fe(r))
1694
+ return d;
1695
+ if (Be(f.value)) {
1696
+ if (We(r, f.value) || ct(f.value) && Nt(r))
1697
+ return d;
1698
+ } else if (st.endsWith(r, "..") || Ot(r) || Nt(r))
1699
+ return d;
1256
1700
  }
1257
1701
  return u;
1258
1702
  }
1259
- let d;
1260
- return (d = r.indexOf(".")) > -1 && (st(r, d) || St(r) || Ue(r) || De(r)) ? p : (h = Be(r)) ? [
1703
+ let p;
1704
+ return (p = r.indexOf(".")) > -1 && (ct(r, p) || Ot(r) || $e(r) || Me(r)) ? d : (h = Ge(r)) ? [
1261
1705
  h[0] + h[1],
1262
1706
  null,
1263
1707
  h[2]
1264
- ] : p;
1708
+ ] : d;
1265
1709
  }),
1266
1710
  // Filter empty sentences
1267
1711
  i.filter(function(r) {
@@ -1269,13 +1713,13 @@ function We(i, t) {
1269
1713
  })
1270
1714
  );
1271
1715
  }
1272
- const Me = (i, ...t) => (...e) => i(...t, ...e);
1273
- function $e(i) {
1716
+ const Je = (i, ...t) => (...e) => i(...t, ...e);
1717
+ function Ye(i) {
1274
1718
  return {
1275
- sentences: Me(We, i)
1719
+ sentences: Je(Ve, i)
1276
1720
  };
1277
1721
  }
1278
- function Ge(i, t) {
1722
+ function Ke(i, t) {
1279
1723
  return t ? i.reduce(function(e, r) {
1280
1724
  var s = [
1281
1725
  r.index,
@@ -1285,11 +1729,11 @@ function Ge(i, t) {
1285
1729
  return [e, s].join(":");
1286
1730
  }, t) : null;
1287
1731
  }
1288
- function He(i) {
1732
+ function qe(i) {
1289
1733
  const { index: t, offset: e, value: r, ...s } = i;
1290
1734
  return s;
1291
1735
  }
1292
- function Ve(i, t) {
1736
+ function Ze(i, t) {
1293
1737
  var e = 0;
1294
1738
  return Array.isArray(t) || (t = [t]), t.map(function(r) {
1295
1739
  return r === null ? null : (typeof r == "string" && (r = {
@@ -1299,7 +1743,7 @@ function Ve(i, t) {
1299
1743
  }), typeof r == "object" && (r.index = r.index || 0, e = e + r.index + r.offset, r.index = i.index + r.index, r.offset = r.offset || r.value.length), r);
1300
1744
  });
1301
1745
  }
1302
- function Je(i, t) {
1746
+ function Xe(i, t) {
1303
1747
  var n;
1304
1748
  if (i.length == 0)
1305
1749
  return null;
@@ -1318,18 +1762,18 @@ function Je(i, t) {
1318
1762
  offset: Math.max(r, e.length)
1319
1763
  };
1320
1764
  }
1321
- const D = {
1322
- tokensId: Ge,
1323
- normalize: Ve,
1324
- properties: He,
1325
- merge: Je
1765
+ const W = {
1766
+ tokensId: Ke,
1767
+ normalize: Ze,
1768
+ properties: qe,
1769
+ merge: Xe
1326
1770
  };
1327
- var Ye = ' \r\n  !"#$%&()*+,-.\\/:;<=>?@[\\]^_`{|}~', qe = new RegExp(
1328
- "([^" + Ye + "]+)"
1771
+ var Qe = ' \r\n  !"#$%&()*+,-.\\/:;<=>?@[\\]^_`{|}~', _e = new RegExp(
1772
+ "([^" + Qe + "]+)"
1329
1773
  );
1330
- function w(i) {
1331
- if (!(this instanceof w))
1332
- return new w(i);
1774
+ function y(i) {
1775
+ if (!(this instanceof y))
1776
+ return new y(i);
1333
1777
  this.opts = Object.assign({
1334
1778
  cacheGet: function(t) {
1335
1779
  return null;
@@ -1338,7 +1782,7 @@ function w(i) {
1338
1782
  }
1339
1783
  }, i);
1340
1784
  }
1341
- w.prototype.split = function(t, e = {}) {
1785
+ y.prototype.split = function(t, e = {}) {
1342
1786
  var r = this;
1343
1787
  return e = Object.assign({ preserveProperties: !0, cache: () => null }, e), function(s, n) {
1344
1788
  if (arguments.length === 6)
@@ -1350,42 +1794,42 @@ w.prototype.split = function(t, e = {}) {
1350
1794
  value: s,
1351
1795
  index: 0,
1352
1796
  offset: s.length
1353
- }] : Array.isArray(s) || (s = [s]), l = D.tokensId(s, e.cache()), l && (c = r.opts.cacheGet(l), c))
1797
+ }] : Array.isArray(s) || (s = [s]), l = W.tokensId(s, e.cache()), l && (c = r.opts.cacheGet(l), c))
1354
1798
  return c;
1355
- var h = s.map(function(u, p) {
1356
- var f = s[p + 1], d = t(
1799
+ var h = s.map(function(u, d) {
1800
+ var f = s[d + 1], p = t(
1357
1801
  u.value,
1358
1802
  Object.assign({}, u),
1359
1803
  o ? Object.assign({}, o) : null,
1360
1804
  f ? Object.assign({}, f) : null,
1361
- p,
1805
+ d,
1362
1806
  s
1363
1807
  ) || [];
1364
- if (d = D.normalize(u, d), e.preserveProperties) {
1365
- var I = D.properties(u);
1366
- d = d.map(function(L) {
1367
- return Object.assign({}, L, I);
1808
+ if (p = W.normalize(u, p), e.preserveProperties) {
1809
+ var S = W.properties(u);
1810
+ p = p.map(function(D) {
1811
+ return Object.assign({}, D, S);
1368
1812
  });
1369
1813
  }
1370
- return o = u, d;
1814
+ return o = u, p;
1371
1815
  }).filter(Boolean).flat();
1372
1816
  return l && r.opts.cacheSet(l, h), h;
1373
1817
  };
1374
1818
  };
1375
- w.prototype.re = function(t, e = {}) {
1819
+ y.prototype.re = function(t, e = {}) {
1376
1820
  return e = Object.assign({ split: !1 }, e), this.split(function(r, s) {
1377
1821
  for (var n = r, o = [], l, c = 0; l = t.exec(r); ) {
1378
- var h = l.index, u = c + h, p = l[0] || "", f = p.length;
1822
+ var h = l.index, u = c + h, d = l[0] || "", f = d.length;
1379
1823
  if (e.split && c < u) {
1380
- var d = n.slice(c, u);
1824
+ var p = n.slice(c, u);
1381
1825
  o.push({
1382
- value: d,
1826
+ value: p,
1383
1827
  index: c,
1384
- offset: d.length
1828
+ offset: p.length
1385
1829
  });
1386
1830
  }
1387
1831
  o.push({
1388
- value: p,
1832
+ value: d,
1389
1833
  index: u,
1390
1834
  offset: f,
1391
1835
  match: l
@@ -1402,25 +1846,25 @@ w.prototype.re = function(t, e = {}) {
1402
1846
  }
1403
1847
  });
1404
1848
  };
1405
- w.prototype.splitAndMerge = function(t, e = {}) {
1849
+ y.prototype.splitAndMerge = function(t, e = {}) {
1406
1850
  var r = this;
1407
1851
  return e = Object.assign({ mergeWith: "" }, e), function(s) {
1408
1852
  var n = [], o = [];
1409
1853
  function l() {
1410
1854
  if (o.length != 0) {
1411
- var c = D.merge(o, e.mergeWith);
1855
+ var c = W.merge(o, e.mergeWith);
1412
1856
  n.push(c), o = [];
1413
1857
  }
1414
1858
  }
1415
1859
  return r.split(function(c, h) {
1416
1860
  var u = t.apply(null, arguments);
1417
- u = D.normalize(h, u), u.forEach(function(p) {
1418
- p === null ? l() : o.push(p);
1861
+ u = W.normalize(h, u), u.forEach(function(d) {
1862
+ d === null ? l() : o.push(d);
1419
1863
  });
1420
1864
  })(s), l(), n;
1421
1865
  };
1422
1866
  };
1423
- w.prototype.filter = function(t) {
1867
+ y.prototype.filter = function(t) {
1424
1868
  return this.split(function(e, r) {
1425
1869
  if (t.apply(null, arguments))
1426
1870
  return {
@@ -1430,7 +1874,7 @@ w.prototype.filter = function(t) {
1430
1874
  };
1431
1875
  });
1432
1876
  };
1433
- w.prototype.extend = function(t) {
1877
+ y.prototype.extend = function(t) {
1434
1878
  return this.split(function(e, r) {
1435
1879
  var s = typeof t == "function" ? t.apply(null, arguments) : t;
1436
1880
  return Object.assign({
@@ -1440,7 +1884,7 @@ w.prototype.extend = function(t) {
1440
1884
  }, s);
1441
1885
  });
1442
1886
  };
1443
- w.prototype.ifthen = function(i, t) {
1887
+ y.prototype.ifthen = function(i, t) {
1444
1888
  return this.split(function(e, r) {
1445
1889
  if (i.apply(null, arguments))
1446
1890
  return t.apply(null, arguments);
@@ -1448,35 +1892,35 @@ w.prototype.ifthen = function(i, t) {
1448
1892
  return n;
1449
1893
  });
1450
1894
  };
1451
- w.prototype.test = function(t) {
1895
+ y.prototype.test = function(t) {
1452
1896
  return this.filter(function(e, r) {
1453
1897
  return t.test(e);
1454
1898
  }, {
1455
1899
  cache: t.toString()
1456
1900
  });
1457
1901
  };
1458
- w.prototype.flow = function(...t) {
1902
+ y.prototype.flow = function(...t) {
1459
1903
  const e = t.reduce((r, s) => (...n) => s(r(...n)));
1460
1904
  return this.split(e);
1461
1905
  };
1462
- w.prototype.serie = function(...t) {
1906
+ y.prototype.serie = function(...t) {
1463
1907
  return t.reduce((e, r) => (...s) => r(e(...s)));
1464
1908
  };
1465
- w.prototype.merge = function() {
1909
+ y.prototype.merge = function() {
1466
1910
  return this.splitAndMerge((i) => [i]);
1467
1911
  };
1468
- w.prototype.sections = function() {
1912
+ y.prototype.sections = function() {
1469
1913
  return this.re(/([^\n\.,;!?]+)/i, { split: !1 });
1470
1914
  };
1471
- w.prototype.words = function() {
1472
- return this.re(qe);
1915
+ y.prototype.words = function() {
1916
+ return this.re(_e);
1473
1917
  };
1474
- w.prototype.characters = function() {
1918
+ y.prototype.characters = function() {
1475
1919
  return this.re(/[^\s]/);
1476
1920
  };
1477
- var Ke = /* @__PURE__ */ ((i) => (i.Word = "word", i.Sentence = "sentence", i.Paragraph = "paragraph", i))(Ke || {});
1478
- const Ze = (i, t) => "Segmenter" in Intl ? new Xe(i, t) : new Qe(i, t);
1479
- class Xe {
1921
+ var je = /* @__PURE__ */ ((i) => (i.Word = "word", i.Sentence = "sentence", i.Paragraph = "paragraph", i))(je || {});
1922
+ const ti = (i, t) => "Segmenter" in Intl ? new ei(i, t) : new ii(i, t);
1923
+ class ei {
1480
1924
  constructor(t, e) {
1481
1925
  if (this.unit = e, t = t ?? (navigator == null ? void 0 : navigator.language), !("Segmenter" in Intl))
1482
1926
  throw new Error("Intl.Segmenter is not supported in this environment");
@@ -1491,17 +1935,17 @@ class Xe {
1491
1935
  for (let s of e) {
1492
1936
  if (this.unit === "word" && s.isWordLike === !1)
1493
1937
  continue;
1494
- const n = kt(s.segment);
1938
+ const n = Mt(s.segment);
1495
1939
  n !== null && r.push([s.index, s.index + n.length]);
1496
1940
  }
1497
1941
  return r;
1498
1942
  }
1499
1943
  }
1500
- class Qe {
1944
+ class ii {
1501
1945
  constructor(t, e) {
1502
1946
  if (this.unit = e, t = t ?? (navigator == null ? void 0 : navigator.language), this.isEnglish = t.toLowerCase().split("-")[0] === "en", e === "paragraph")
1503
1947
  throw new Error("NaiveTextTokenizer does not handle TextUnit.Paragraph");
1504
- this.tokenizer = new w();
1948
+ this.tokenizer = new y();
1505
1949
  }
1506
1950
  tokenize(t) {
1507
1951
  let e = [];
@@ -1510,7 +1954,7 @@ class Qe {
1510
1954
  e = this.tokenizer.words()(t);
1511
1955
  break;
1512
1956
  case "sentence":
1513
- this.isEnglish ? e = $e(this.tokenizer).sentences()(t) : e = this.tokenizer.sections()(t);
1957
+ this.isEnglish ? e = Ye(this.tokenizer).sentences()(t) : e = this.tokenizer.sections()(t);
1514
1958
  break;
1515
1959
  default:
1516
1960
  e = [];
@@ -1521,18 +1965,18 @@ class Qe {
1521
1965
  return e.forEach((s) => {
1522
1966
  if (s.value.length === 0)
1523
1967
  return;
1524
- const n = kt(s.value);
1968
+ const n = Mt(s.value);
1525
1969
  n !== null && r.push([s.index, s.index + n.length]);
1526
1970
  }), r;
1527
1971
  }
1528
1972
  }
1529
- const _e = new RegExp("[\\p{L}\\p{N}]+", "u"), kt = (i) => {
1973
+ const ri = new RegExp("[\\p{L}\\p{N}]+", "u"), Mt = (i) => {
1530
1974
  const t = i.trimEnd();
1531
- return t.length === 0 || t.match(_e) === null ? null : t;
1975
+ return t.length === 0 || t.match(ri) === null ? null : t;
1532
1976
  };
1533
- class N {
1977
+ class C {
1534
1978
  constructor(t) {
1535
- this.fetcher = new Ae(), t.fetcher && (this.fetcher = t.fetcher), this.manifest = t.manifest, this.context = t.manifest.context, this.metadata = t.manifest.metadata, this.links = t.manifest.links, this.readingOrder = t.manifest.readingOrder, this.resources = t.manifest.resources, this.tableOfContents = t.manifest.tableOfContents, this.subcollections = t.manifest.subcollections;
1979
+ this.fetcher = new Ce(), t.fetcher && (this.fetcher = t.fetcher), this.manifest = t.manifest, this.context = t.manifest.context, this.metadata = t.manifest.metadata, this.links = t.manifest.links, this.readingOrder = t.manifest.readingOrder, this.resources = t.manifest.resources, this.toc = t.manifest.toc, this.subcollections = t.manifest.subcollections;
1536
1980
  }
1537
1981
  /** The URL where this publication is served, computed from the `Link` with `self` relation.
1538
1982
  * e.g. https://provider.com/pub1293/manifest.json gives https://provider.com/pub1293/
@@ -1572,7 +2016,7 @@ class N {
1572
2016
  const e = await this.get(
1573
2017
  t
1574
2018
  ).readAsJSON();
1575
- return e.total ? e.positions.map((r) => A.deserialize(r)).filter((r) => r !== void 0) : [];
2019
+ return e.total ? e.positions.map((r) => w.deserialize(r)).filter((r) => r !== void 0) : [];
1576
2020
  }
1577
2021
  async guideForLink(t) {
1578
2022
  const e = (o) => {
@@ -1592,13 +2036,13 @@ class N {
1592
2036
  return;
1593
2037
  let s = r.href;
1594
2038
  if (r.templated) {
1595
- const o = new J(s), l = {};
1596
- o.parameters.has("ref") && (l.ref = t.href), s = new J(s).expand(l);
2039
+ const o = new Z(s), l = {};
2040
+ o.parameters.has("ref") && (l.ref = t.href), s = new Z(s).expand(l);
1597
2041
  }
1598
- const n = await this.get(new S({
2042
+ const n = await this.get(new I({
1599
2043
  href: s
1600
2044
  })).readAsJSON();
1601
- return ft.deserialize(n);
2045
+ return xt.deserialize(n);
1602
2046
  }
1603
2047
  /**
1604
2048
  * Returns the resource targeted by the given non-templated [link].
@@ -1607,25 +2051,25 @@ class N {
1607
2051
  return this.fetcher.get(t);
1608
2052
  }
1609
2053
  }
1610
- N.prototype.getPageList = function() {
2054
+ C.prototype.getPageList = function() {
1611
2055
  return this.linksWithRole("pageList");
1612
2056
  };
1613
- N.prototype.getLandmarks = function() {
2057
+ C.prototype.getLandmarks = function() {
1614
2058
  return this.linksWithRole("landmarks");
1615
2059
  };
1616
- N.prototype.getListOfAudioClips = function() {
2060
+ C.prototype.getListOfAudioClips = function() {
1617
2061
  return this.linksWithRole("loa");
1618
2062
  };
1619
- N.prototype.getListOfIllustrations = function() {
2063
+ C.prototype.getListOfIllustrations = function() {
1620
2064
  return this.linksWithRole("loi");
1621
2065
  };
1622
- N.prototype.getListOfTables = function() {
2066
+ C.prototype.getListOfTables = function() {
1623
2067
  return this.linksWithRole("lot");
1624
2068
  };
1625
- N.prototype.getListOfVideoClips = function() {
2069
+ C.prototype.getListOfVideoClips = function() {
1626
2070
  return this.linksWithRole("lov");
1627
2071
  };
1628
- class q {
2072
+ class j {
1629
2073
  /**
1630
2074
  * Creates a [DomRange].
1631
2075
  */
@@ -1638,11 +2082,11 @@ class q {
1638
2082
  static deserialize(t) {
1639
2083
  if (!(t && t.cssSelector))
1640
2084
  return;
1641
- let e = y(t.textNodeIndex);
2085
+ let e = b(t.textNodeIndex);
1642
2086
  if (e === void 0)
1643
2087
  return;
1644
- let r = y(t.charOffset);
1645
- return r === void 0 && (r = y(t.offset)), new q({
2088
+ let r = b(t.charOffset);
2089
+ return r === void 0 && (r = b(t.offset)), new j({
1646
2090
  cssSelector: t.cssSelector,
1647
2091
  textNodeIndex: e,
1648
2092
  charOffset: r
@@ -1653,579 +2097,238 @@ class q {
1653
2097
  */
1654
2098
  serialize() {
1655
2099
  const t = {
1656
- cssSelector: this.cssSelector,
1657
- textNodeIndex: this.textNodeIndex
1658
- };
1659
- return this.charOffset !== void 0 && (t.charOffset = this.charOffset), t;
1660
- }
1661
- }
1662
- class pt {
1663
- /**
1664
- * Creates a [DomRange].
1665
- */
1666
- constructor(t) {
1667
- this.start = t.start, this.end = t.end;
1668
- }
1669
- /**
1670
- * Parses a [DomRange] from its RWPM JSON representation.
1671
- */
1672
- static deserialize(t) {
1673
- if (!t)
1674
- return;
1675
- let e = q.deserialize(t.start);
1676
- if (e)
1677
- return new pt({
1678
- start: e,
1679
- end: q.deserialize(t.end)
1680
- });
1681
- }
1682
- /**
1683
- * Serializes a [DomRange] to its RWPM JSON representation.
1684
- */
1685
- serialize() {
1686
- const t = { start: this.start.serialize() };
1687
- return this.end && (t.end = this.end.serialize()), t;
1688
- }
1689
- }
1690
- E.prototype.getCssSelector = function() {
1691
- var i;
1692
- return (i = this.otherLocations) == null ? void 0 : i.get("cssSelector");
1693
- };
1694
- E.prototype.getPartialCfi = function() {
1695
- var i;
1696
- return (i = this.otherLocations) == null ? void 0 : i.get("partialCfi");
1697
- };
1698
- E.prototype.getDomRange = function() {
1699
- var i;
1700
- return pt.deserialize((i = this.otherLocations) == null ? void 0 : i.get("domRange"));
1701
- };
1702
- E.prototype.fragmentParameters = function() {
1703
- return new Map(
1704
- 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) => [
1705
- i[0].trim().toLowerCase(),
1706
- i[1].trim()
1707
- ])
1708
- );
1709
- };
1710
- E.prototype.htmlId = function() {
1711
- if (!this.fragments.length)
1712
- return;
1713
- let i = this.fragments.find((t) => t.length && !t.includes("="));
1714
- if (!i) {
1715
- const t = this.fragmentParameters();
1716
- t.has("id") ? i = t.get("id") : t.has("name") && (i = t.get("name"));
1717
- }
1718
- return i != null && i.startsWith("#") ? i.slice(1) : i;
1719
- };
1720
- E.prototype.page = function() {
1721
- const i = parseInt(this.fragmentParameters().get("page"));
1722
- if (!isNaN(i) && i >= 0)
1723
- return i;
1724
- };
1725
- E.prototype.time = function() {
1726
- const i = parseInt(this.fragmentParameters().get("t"));
1727
- if (!isNaN(i))
1728
- return i;
1729
- };
1730
- E.prototype.space = function() {
1731
- const i = this.fragmentParameters();
1732
- if (!i.has("xywh"))
1733
- return;
1734
- const t = i.get("xywh").split(",").map((e) => parseInt(e));
1735
- if (t.length === 4 && !t.some(isNaN))
1736
- return t;
1737
- };
1738
- class dt {
1739
- /** Creates a [Price]. */
1740
- constructor(t) {
1741
- this.currency = t.currency, this.value = t.value;
1742
- }
1743
- /**
1744
- * Parses a [Price] from its RWPM JSON representation.
1745
- */
1746
- static deserialize(t) {
1747
- if (!t)
1748
- return;
1749
- let e = t.currency;
1750
- if (!(e && typeof e == "string" && e.length > 0))
1751
- return;
1752
- let r = y(t.value);
1753
- if (r !== void 0)
1754
- return new dt({ currency: e, value: r });
1755
- }
1756
- /**
1757
- * Serializes a [Price] to its RWPM JSON representation.
1758
- */
1759
- serialize() {
1760
- return { currency: this.currency, value: this.value };
1761
- }
1762
- }
1763
- class U {
1764
- /** Creates a [Acquisition]. */
1765
- constructor(t) {
1766
- this.type = t.type, this.children = t.children;
1767
- }
1768
- /**
1769
- * Parses a [Acquisition] from its RWPM JSON representation.
1770
- */
1771
- static deserialize(t) {
1772
- if (t && t.type)
1773
- return new U({
1774
- type: t.type,
1775
- children: U.deserializeArray(t.children)
1776
- });
1777
- }
1778
- static deserializeArray(t) {
1779
- if (t instanceof Array)
1780
- return t.map((e) => U.deserialize(e)).filter((e) => e !== void 0);
1781
- }
1782
- /**
1783
- * Serializes a [Acquisition] to its RWPM JSON representation.
1784
- */
1785
- serialize() {
1786
- const t = { type: this.type };
1787
- return this.children && (t.children = this.children.map((e) => e.serialize())), t;
1788
- }
1789
- }
1790
- class gt {
1791
- /** Creates a [Price]. */
1792
- constructor(t) {
1793
- this.total = t.total, this.position = t.position;
1794
- }
1795
- /**
1796
- * Parses a [Holds] from its RWPM JSON representation.
1797
- */
1798
- static deserialize(t) {
1799
- if (t)
1800
- return new gt({
1801
- total: y(t.total),
1802
- position: y(t.position)
1803
- });
1804
- }
1805
- /**
1806
- * Serializes a [Holds] to its RWPM JSON representation.
1807
- */
1808
- serialize() {
1809
- const t = {};
1810
- return this.total !== void 0 && (t.total = this.total), this.position !== void 0 && (t.position = this.position), t;
1811
- }
1812
- }
1813
- class mt {
1814
- /** Creates a [Copies]. */
1815
- constructor(t) {
1816
- this.total = t.total, this.available = t.available;
1817
- }
1818
- /**
1819
- * Parses a [Copies] from its RWPM JSON representation.
1820
- */
1821
- static deserialize(t) {
1822
- if (t)
1823
- return new mt({
1824
- total: y(t.total),
1825
- available: y(t.available)
1826
- });
1827
- }
1828
- /**
1829
- * Serializes a [Copies] to its RWPM JSON representation.
1830
- */
1831
- serialize() {
1832
- const t = {};
1833
- return this.total !== void 0 && (t.total = this.total), this.available !== void 0 && (t.available = this.available), t;
1834
- }
1835
- }
1836
- var je = /* @__PURE__ */ ((i) => (i.available = "available", i.reserved = "reserved", i.ready = "ready", i))(je || {});
1837
- class Et {
1838
- /** Creates a [Availability]. */
1839
- constructor(t) {
1840
- this.state = t.state, this.since = t.since, this.until = t.until;
1841
- }
1842
- /**
1843
- * Parses a [Availability] from its RWPM JSON representation.
1844
- */
1845
- static deserialize(t) {
1846
- if (t && t.state)
1847
- return new Et({
1848
- state: t.state,
1849
- since: Y(t.since),
1850
- until: Y(t.until)
1851
- });
1852
- }
1853
- /**
1854
- * Serializes a [Availability] to its RWPM JSON representation.
1855
- */
1856
- serialize() {
1857
- const t = { state: this.state };
1858
- return this.since !== void 0 && (t.since = this.since.toISOString()), this.until !== void 0 && (t.until = this.until.toISOString()), t;
1859
- }
1860
- }
1861
- m.prototype.getNumberOfItems = function() {
1862
- return y(this.otherProperties.numberOfItems);
1863
- };
1864
- m.prototype.getPrice = function() {
1865
- return dt.deserialize(this.otherProperties.price);
1866
- };
1867
- m.prototype.getIndirectAcquisitions = function() {
1868
- const i = this.otherProperties.indirectAcquisition;
1869
- if (i && i instanceof Array)
1870
- return i.map((t) => U.deserialize(t)).filter((t) => t !== void 0);
1871
- };
1872
- m.prototype.getHolds = function() {
1873
- return gt.deserialize(this.otherProperties.holds);
1874
- };
1875
- m.prototype.getCopies = function() {
1876
- return mt.deserialize(this.otherProperties.copies);
1877
- };
1878
- m.prototype.getAvailability = function() {
1879
- return Et.deserialize(this.otherProperties.availability);
1880
- };
1881
- m.prototype.getAuthenticate = function() {
1882
- return S.deserialize(this.otherProperties.authenticate);
1883
- };
1884
- N.prototype.getImages = function() {
1885
- return this.linksWithRole("images");
1886
- };
1887
- const bt = class P {
1888
- /**
1889
- * translations can be a string or a collection of language/translation pairs,
1890
- * for a single string the language is assumed to be undefined
1891
- */
1892
- constructor(t) {
1893
- this.translations = typeof t == "string" ? { [P.UNDEFINED_LANGUAGE]: t } : t;
1894
- }
1895
- /**
1896
- * Parses a [LocalizedString] from its RWPM JSON representation.
1897
- *
1898
- * "anyOf": [
1899
- * {
1900
- * "type": "string"
1901
- * },
1902
- * {
1903
- * "description": "The language in a language map must be a valid BCP 47 tag.",
1904
- * "type": "object",
1905
- * "patternProperties": {
1906
- * "^((?<grandfathered>(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)|(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang))|((?<language>([A-Za-z]{2,3}(-(?<extlang>[A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-(?<script>[A-Za-z]{4}))?(-(?<region>[A-Za-z]{2}|[0-9]{3}))?(-(?<variant>[A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-(?<extension>[0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(?<privateUse>x(-[A-Za-z0-9]{1,8})+))?)|(?<privateUse2>x(-[A-Za-z0-9]{1,8})+))$": {
1907
- * "type": "string"
1908
- * }
1909
- * },
1910
- * "additionalProperties": false,
1911
- * "minProperties": 1
1912
- * }
1913
- * ]
1914
- */
1915
- static deserialize(t) {
1916
- if (t && (typeof t == "string" || t.constructor === Object))
1917
- return new P(t);
1918
- }
1919
- serialize() {
1920
- return this.translations;
1921
- }
1922
- /**
1923
- * Returns the first translation for the given [language] BCP–47 tag.
1924
- * If not found, then fallback:
1925
- * 1. on the undefined language
1926
- * 2. on the English language
1927
- * 3. the first translation found
1928
- * 4. returns empty string
1929
- */
1930
- getTranslation(t) {
1931
- return this.translations[t || P.UNDEFINED_LANGUAGE] || this.translations[P.UNDEFINED_LANGUAGE] || this.translations[P.LANGUAGE_EN] || (Object.values(this.translations).length === 0 ? "" : Object.values(this.translations)[0]);
2100
+ cssSelector: this.cssSelector,
2101
+ textNodeIndex: this.textNodeIndex
2102
+ };
2103
+ return this.charOffset !== void 0 && (t.charOffset = this.charOffset), t;
1932
2104
  }
1933
- };
1934
- bt.UNDEFINED_LANGUAGE = "undefined";
1935
- bt.LANGUAGE_EN = "en";
1936
- let O = bt;
1937
- class K {
2105
+ }
2106
+ class yt {
1938
2107
  /**
1939
- * Creates a [Contributor] object.
2108
+ * Creates a [DomRange].
1940
2109
  */
1941
2110
  constructor(t) {
1942
- this.name = t.name, this.sortAs = t.sortAs, this.identifier = t.identifier, this.roles = t.roles, this.links = t.links, this.position = t.position;
2111
+ this.start = t.start, this.end = t.end;
1943
2112
  }
1944
2113
  /**
1945
- * Parses a [Contributor] from its RWPM JSON representation.
1946
- *
1947
- * A contributor can be parsed from a single string, or a full-fledged object.
2114
+ * Parses a [DomRange] from its RWPM JSON representation.
1948
2115
  */
1949
2116
  static deserialize(t) {
1950
- if (t)
1951
- return typeof t == "string" ? new K({
1952
- name: O.deserialize(t)
1953
- }) : t.name ? new K({
1954
- name: O.deserialize(t.name),
1955
- sortAs: t.sortAs,
1956
- identifier: t.identifier,
1957
- roles: t.role ? new Set(R(t.role)) : void 0,
1958
- links: x.deserialize(t.links),
1959
- position: C(t.position)
1960
- }) : void 0;
2117
+ if (!t)
2118
+ return;
2119
+ let e = j.deserialize(t.start);
2120
+ if (e)
2121
+ return new yt({
2122
+ start: e,
2123
+ end: j.deserialize(t.end)
2124
+ });
1961
2125
  }
1962
2126
  /**
1963
- * Serializes a [Contributor] to its RWPM JSON representation.
2127
+ * Serializes a [DomRange] to its RWPM JSON representation.
1964
2128
  */
1965
2129
  serialize() {
1966
- const t = { name: this.name.serialize() };
1967
- return this.sortAs !== void 0 && (t.sortAs = this.sortAs), this.identifier !== void 0 && (t.identifier = this.identifier), this.roles && (t.role = ut(this.roles)), this.links && (t.links = this.links.serialize()), this.position !== void 0 && (t.position = this.position), t;
2130
+ const t = { start: this.start.serialize() };
2131
+ return this.end && (t.end = this.end.serialize()), t;
1968
2132
  }
1969
2133
  }
1970
- class b {
1971
- /**
1972
- * Creates a [Contributors] object.
1973
- */
2134
+ m.prototype.getCssSelector = function() {
2135
+ var i;
2136
+ return (i = this.otherLocations) == null ? void 0 : i.get("cssSelector");
2137
+ };
2138
+ m.prototype.getPartialCfi = function() {
2139
+ var i;
2140
+ return (i = this.otherLocations) == null ? void 0 : i.get("partialCfi");
2141
+ };
2142
+ m.prototype.getDomRange = function() {
2143
+ var i;
2144
+ return yt.deserialize((i = this.otherLocations) == null ? void 0 : i.get("domRange"));
2145
+ };
2146
+ m.prototype.fragmentParameters = function() {
2147
+ return new Map(
2148
+ 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) => [
2149
+ i[0].trim().toLowerCase(),
2150
+ i[1].trim()
2151
+ ])
2152
+ );
2153
+ };
2154
+ m.prototype.htmlId = function() {
2155
+ if (!this.fragments.length)
2156
+ return;
2157
+ let i = this.fragments.find((t) => t.length && !t.includes("="));
2158
+ if (!i) {
2159
+ const t = this.fragmentParameters();
2160
+ t.has("id") ? i = t.get("id") : t.has("name") && (i = t.get("name"));
2161
+ }
2162
+ return i != null && i.startsWith("#") ? i.slice(1) : i;
2163
+ };
2164
+ m.prototype.page = function() {
2165
+ const i = parseInt(this.fragmentParameters().get("page"));
2166
+ if (!isNaN(i) && i >= 0)
2167
+ return i;
2168
+ };
2169
+ m.prototype.time = function() {
2170
+ const i = parseInt(this.fragmentParameters().get("t"));
2171
+ if (!isNaN(i))
2172
+ return i;
2173
+ };
2174
+ m.prototype.space = function() {
2175
+ const i = this.fragmentParameters();
2176
+ if (!i.has("xywh"))
2177
+ return;
2178
+ const t = i.get("xywh").split(",").map((e) => parseInt(e));
2179
+ if (t.length === 4 && !t.some(isNaN))
2180
+ return t;
2181
+ };
2182
+ class wt {
2183
+ /** Creates a [Price]. */
1974
2184
  constructor(t) {
1975
- this.items = t;
2185
+ this.currency = t.currency, this.value = t.value;
1976
2186
  }
1977
2187
  /**
1978
- * Parses a [Contributors] from its RWPM JSON representation.
1979
- *
2188
+ * Parses a [Price] from its RWPM JSON representation.
1980
2189
  */
1981
2190
  static deserialize(t) {
1982
2191
  if (!t)
1983
2192
  return;
1984
- const e = t instanceof Array ? t : [t];
1985
- return new b(
1986
- e.map((r) => K.deserialize(r)).filter((r) => r !== void 0)
1987
- );
2193
+ let e = t.currency;
2194
+ if (!(e && typeof e == "string" && e.length > 0))
2195
+ return;
2196
+ let r = b(t.value);
2197
+ if (r !== void 0)
2198
+ return new wt({ currency: e, value: r });
1988
2199
  }
1989
2200
  /**
1990
- * Serializes a [Contributors] to its RWPM JSON representation.
2201
+ * Serializes a [Price] to its RWPM JSON representation.
1991
2202
  */
1992
2203
  serialize() {
1993
- return this.items.map((t) => t.serialize());
2204
+ return { currency: this.currency, value: this.value };
1994
2205
  }
1995
2206
  }
1996
- class B {
1997
- /** Creates an Array of [Subject]. */
2207
+ class M {
2208
+ /** Creates a [Acquisition]. */
1998
2209
  constructor(t) {
1999
- this.items = t && t.items ? t.items : /* @__PURE__ */ new Map();
2210
+ this.type = t.type, this.children = t.children;
2000
2211
  }
2001
2212
  /**
2002
- * Parses a [BelongsTo] from its RWPM JSON representation.
2213
+ * Parses a [Acquisition] from its RWPM JSON representation.
2003
2214
  */
2004
2215
  static deserialize(t) {
2005
- if (!(t && t instanceof Object))
2006
- return;
2007
- const e = /* @__PURE__ */ new Map();
2008
- return Object.entries(t).forEach(([r, s]) => {
2009
- const n = b.deserialize(s);
2010
- n && n.items.length > 0 && e.set(r, n);
2011
- }), new B({ items: e });
2216
+ if (t && t.type)
2217
+ return new M({
2218
+ type: t.type,
2219
+ children: M.deserializeArray(t.children)
2220
+ });
2221
+ }
2222
+ static deserializeArray(t) {
2223
+ if (t instanceof Array)
2224
+ return t.map((e) => M.deserialize(e)).filter((e) => e !== void 0);
2012
2225
  }
2013
2226
  /**
2014
- * Serializes a [BelongsTo] to its RWPM JSON representation.
2227
+ * Serializes a [Acquisition] to its RWPM JSON representation.
2015
2228
  */
2016
2229
  serialize() {
2017
- const t = {};
2018
- return this.items.forEach(
2019
- (e, r) => t[r] = e.serialize()
2020
- ), t;
2021
- }
2022
- }
2023
- var z = /* @__PURE__ */ ((i) => (i.auto = "auto", i.btt = "btt", i.ltr = "ltr", i.rtl = "rtl", i.ttb = "ttb", i))(z || {});
2024
- function xr(i) {
2025
- switch (i) {
2026
- case "auto":
2027
- case "ttb":
2028
- case "ltr":
2029
- return H.left;
2030
- case "rtl":
2031
- case "btt":
2032
- return H.right;
2033
- default:
2034
- return H.left;
2230
+ const t = { type: this.type };
2231
+ return this.children && (t.children = this.children.map((e) => e.serialize())), t;
2035
2232
  }
2036
2233
  }
2037
- class Z {
2038
- /** Creates a [Subject]. */
2234
+ class At {
2235
+ /** Creates a [Price]. */
2039
2236
  constructor(t) {
2040
- this.name = t.name, this.sortAs = t.sortAs, this.code = t.code, this.scheme = t.scheme, this.links = t.links;
2237
+ this.total = t.total, this.position = t.position;
2041
2238
  }
2042
2239
  /**
2043
- * Parses a [Subject] from its RWPM JSON representation.
2044
- *
2045
- * A [Subject] can be parsed from a single string, or a full-fledged object.
2240
+ * Parses a [Holds] from its RWPM JSON representation.
2046
2241
  */
2047
2242
  static deserialize(t) {
2048
2243
  if (t)
2049
- return typeof t == "string" ? new Z({
2050
- name: O.deserialize(t)
2051
- }) : t.name ? new Z({
2052
- name: O.deserialize(t.name),
2053
- sortAs: t.sortAs,
2054
- code: t.code,
2055
- scheme: t.scheme,
2056
- links: x.deserialize(t.links)
2057
- }) : void 0;
2244
+ return new At({
2245
+ total: b(t.total),
2246
+ position: b(t.position)
2247
+ });
2058
2248
  }
2059
2249
  /**
2060
- * Serializes a [Subject] to its RWPM JSON representation.
2250
+ * Serializes a [Holds] to its RWPM JSON representation.
2061
2251
  */
2062
2252
  serialize() {
2063
- const t = { name: this.name.serialize() };
2064
- return this.sortAs !== void 0 && (t.sortAs = this.sortAs), this.code !== void 0 && (t.code = this.code), this.scheme !== void 0 && (t.scheme = this.scheme), this.links && (t.links = this.links.serialize()), t;
2253
+ const t = {};
2254
+ return this.total !== void 0 && (t.total = this.total), this.position !== void 0 && (t.position = this.position), t;
2065
2255
  }
2066
2256
  }
2067
- class xt {
2068
- /** Creates an Array of [Subject]. */
2257
+ class It {
2258
+ /** Creates a [Copies]. */
2069
2259
  constructor(t) {
2070
- this.items = t;
2260
+ this.total = t.total, this.available = t.available;
2071
2261
  }
2072
2262
  /**
2073
- * Parses a [Subjects] from its RWPM JSON representation.
2263
+ * Parses a [Copies] from its RWPM JSON representation.
2074
2264
  */
2075
2265
  static deserialize(t) {
2076
- if (!t)
2077
- return;
2078
- const e = t instanceof Array ? t : [t];
2079
- return new xt(
2080
- e.map((r) => Z.deserialize(r)).filter((r) => r !== void 0)
2081
- );
2266
+ if (t)
2267
+ return new It({
2268
+ total: b(t.total),
2269
+ available: b(t.available)
2270
+ });
2082
2271
  }
2083
2272
  /**
2084
- * Serializes a [Subjects] to its RWPM JSON representation.
2273
+ * Serializes a [Copies] to its RWPM JSON representation.
2085
2274
  */
2086
2275
  serialize() {
2087
- return this.items.map((t) => t.serialize());
2276
+ const t = {};
2277
+ return this.total !== void 0 && (t.total = this.total), this.available !== void 0 && (t.available = this.available), t;
2088
2278
  }
2089
2279
  }
2090
- const Dt = class nt {
2091
- /** Creates [Metadata] object */
2280
+ var si = /* @__PURE__ */ ((i) => (i.available = "available", i.reserved = "reserved", i.ready = "ready", i))(si || {});
2281
+ class St {
2282
+ /** Creates a [Availability]. */
2092
2283
  constructor(t) {
2093
- this.title = t.title, this.typeUri = t.typeUri, this.identifier = t.identifier, this.subtitle = t.subtitle, this.sortAs = t.sortAs, this.artists = t.artists, this.authors = t.authors, this.colorists = t.colorists, this.contributors = t.contributors, this.editors = t.editors, this.illustrators = t.illustrators, this.inkers = t.inkers, this.letterers = t.letterers, this.narrators = t.narrators, this.pencilers = t.pencilers, this.translators = t.translators, this.languages = t.languages, this.description = t.description, this.publishers = t.publishers, this.imprints = t.imprints, this.published = t.published, this.modified = t.modified, this.subjects = t.subjects, this.belongsTo = t.belongsTo, this.belongsToCollections = t.belongsToCollections, this.belongsToSeries = t.belongsToSeries, this.belongsToCollections && this.belongsToCollections.items.length > 0 && (this.belongsTo || (this.belongsTo = new B()), this.belongsTo.items.set("collection", this.belongsToCollections)), this.belongsToSeries && this.belongsToSeries.items.length > 0 && (this.belongsTo || (this.belongsTo = new B()), this.belongsTo.items.set("series", this.belongsToSeries)), this.readingProgression = t.readingProgression, this.duration = t.duration, this.numberOfPages = t.numberOfPages, this.otherMetadata = t.otherMetadata;
2284
+ this.state = t.state, this.since = t.since, this.until = t.until;
2094
2285
  }
2095
2286
  /**
2096
- * Parses a [Metadata] from its RWPM JSON representation.
2097
- *
2098
- * If the metadata can't be parsed, a warning will be logged with [warnings].
2287
+ * Parses a [Availability] from its RWPM JSON representation.
2099
2288
  */
2100
2289
  static deserialize(t) {
2101
- if (!(t && t.title))
2102
- return;
2103
- const e = O.deserialize(t.title), r = t["@type"], s = t.identifier, n = O.deserialize(t.subtitle), o = O.deserialize(t.sortAs), l = b.deserialize(t.artist), c = b.deserialize(t.author), h = b.deserialize(t.colorist), u = b.deserialize(t.contributor), p = b.deserialize(t.editor), f = b.deserialize(t.illustrator), d = b.deserialize(t.inker), I = b.deserialize(t.letterer), L = b.deserialize(t.narrator), le = b.deserialize(t.penciler), ce = b.deserialize(t.translator), he = R(t.language), ue = t.description, fe = b.deserialize(t.publisher), pe = b.deserialize(t.imprint), de = Y(t.published), ge = Y(t.modified), me = xt.deserialize(t.subject), Ee = B.deserialize(t.belongsTo), be = t.readingProgression, xe = y(t.duration), we = y(t.numberOfPages);
2104
- let G = Object.assign({}, t);
2105
- return nt.mappedProperties.forEach((ye) => delete G[ye]), Object.keys(G).length === 0 && (G = void 0), new nt({
2106
- title: e,
2107
- typeUri: r,
2108
- identifier: s,
2109
- subtitle: n,
2110
- sortAs: o,
2111
- artists: l,
2112
- authors: c,
2113
- colorists: h,
2114
- contributors: u,
2115
- editors: p,
2116
- illustrators: f,
2117
- inkers: d,
2118
- letterers: I,
2119
- narrators: L,
2120
- pencilers: le,
2121
- translators: ce,
2122
- languages: he,
2123
- description: ue,
2124
- publishers: fe,
2125
- imprints: pe,
2126
- published: de,
2127
- modified: ge,
2128
- subjects: me,
2129
- belongsTo: Ee,
2130
- readingProgression: be,
2131
- duration: xe,
2132
- numberOfPages: we,
2133
- otherMetadata: G
2134
- });
2290
+ if (t && t.state)
2291
+ return new St({
2292
+ state: t.state,
2293
+ since: K(t.since),
2294
+ until: K(t.until)
2295
+ });
2135
2296
  }
2136
2297
  /**
2137
- * Serializes a [Metadata] to its RWPM JSON representation.
2298
+ * Serializes a [Availability] to its RWPM JSON representation.
2138
2299
  */
2139
2300
  serialize() {
2140
- const t = { title: this.title.serialize() };
2141
- if (this.typeUri !== void 0 && (t["@type"] = this.typeUri), this.identifier !== void 0 && (t.identifier = this.identifier), this.subtitle && (t.subtitle = this.subtitle.serialize()), this.sortAs && (t.sortAs = this.sortAs.serialize()), this.editors && (t.editor = this.editors.serialize()), this.artists && (t.artist = this.artists.serialize()), this.authors && (t.author = this.authors.serialize()), this.colorists && (t.colorist = this.colorists.serialize()), this.contributors && (t.contributor = this.contributors.serialize()), this.illustrators && (t.illustrator = this.illustrators.serialize()), this.letterers && (t.letterer = this.letterers.serialize()), this.narrators && (t.narrator = this.narrators.serialize()), this.pencilers && (t.penciler = this.pencilers.serialize()), this.translators && (t.translator = this.translators.serialize()), this.inkers && (t.inker = this.inkers.serialize()), this.languages && (t.language = this.languages), this.description !== void 0 && (t.description = this.description), this.publishers && (t.publisher = this.publishers.serialize()), this.imprints && (t.imprint = this.imprints.serialize()), this.published !== void 0 && (t.published = this.published.toISOString()), this.modified !== void 0 && (t.modified = this.modified.toISOString()), this.subjects && (t.subject = this.subjects.serialize()), this.belongsTo && (t.belongsTo = this.belongsTo.serialize()), this.readingProgression && (t.readingProgression = this.readingProgression), this.duration !== void 0 && (t.duration = this.duration), this.numberOfPages !== void 0 && (t.numberOfPages = this.numberOfPages), this.otherMetadata) {
2142
- const e = this.otherMetadata;
2143
- Object.keys(e).forEach((r) => t[r] = e[r]);
2144
- }
2145
- return t;
2146
- }
2147
- /**
2148
- * Computes a [ReadingProgression] when the value of [readingProgression] is set to
2149
- * auto, using the publication language.
2150
- *
2151
- * See this issue for more details: https://github.com/readium/architecture/issues/113
2152
- */
2153
- get effectiveReadingProgression() {
2154
- var r;
2155
- if (this.readingProgression && this.readingProgression !== z.auto)
2156
- return this.readingProgression;
2157
- if (((r = this.languages) == null ? void 0 : r.length) !== 1)
2158
- return z.ltr;
2159
- const t = this.languages[0].toLowerCase();
2160
- if (t === "zh-hant" || t === "zh-tw")
2161
- return z.rtl;
2162
- switch (t.split("-")[0]) {
2163
- case "ar":
2164
- return z.rtl;
2165
- case "fa":
2166
- return z.rtl;
2167
- case "he":
2168
- return z.rtl;
2169
- default:
2170
- return z.ltr;
2171
- }
2301
+ const t = { state: this.state };
2302
+ return this.since !== void 0 && (t.since = this.since.toISOString()), this.until !== void 0 && (t.until = this.until.toISOString()), t;
2172
2303
  }
2304
+ }
2305
+ A.prototype.getNumberOfItems = function() {
2306
+ return b(this.otherProperties.numberOfItems);
2173
2307
  };
2174
- Dt.mappedProperties = [
2175
- "title",
2176
- "@type",
2177
- "identifier",
2178
- "subtitle",
2179
- "sortAs",
2180
- "artist",
2181
- "author",
2182
- "colorist",
2183
- "contributor",
2184
- "editor",
2185
- "illustrator",
2186
- "inker",
2187
- "letterer",
2188
- "narrator",
2189
- "penciler",
2190
- "translator",
2191
- "language",
2192
- "description",
2193
- "publisher",
2194
- "imprint",
2195
- "published",
2196
- "modified",
2197
- "subject",
2198
- "belongsTo",
2199
- "readingProgression",
2200
- "duration",
2201
- "numberOfPages"
2202
- ];
2203
- let Ut = Dt;
2204
- Ut.prototype.getPresentation = function() {
2205
- var t, e;
2206
- const i = ((t = this.otherMetadata) == null ? void 0 : t.presentation) || ((e = this.otherMetadata) == null ? void 0 : e.rendition);
2207
- if (i)
2208
- return _.deserialize(i);
2308
+ A.prototype.getPrice = function() {
2309
+ return wt.deserialize(this.otherProperties.price);
2209
2310
  };
2210
- m.prototype.getClipped = function() {
2211
- return this.otherProperties.clipped;
2311
+ A.prototype.getIndirectAcquisitions = function() {
2312
+ const i = this.otherProperties.indirectAcquisition;
2313
+ if (i && i instanceof Array)
2314
+ return i.map((t) => M.deserialize(t)).filter((t) => t !== void 0);
2212
2315
  };
2213
- m.prototype.getFit = function() {
2214
- return this.otherProperties.fit;
2316
+ A.prototype.getHolds = function() {
2317
+ return At.deserialize(this.otherProperties.holds);
2215
2318
  };
2216
- m.prototype.getOrientation = function() {
2217
- return this.otherProperties.orientation;
2319
+ A.prototype.getCopies = function() {
2320
+ return It.deserialize(this.otherProperties.copies);
2218
2321
  };
2219
- m.prototype.getOverflow = function() {
2220
- return this.otherProperties.overflow;
2322
+ A.prototype.getAvailability = function() {
2323
+ return St.deserialize(this.otherProperties.availability);
2221
2324
  };
2222
- m.prototype.getPage = function() {
2223
- return this.otherProperties.page || void 0;
2325
+ A.prototype.getAuthenticate = function() {
2326
+ return I.deserialize(this.otherProperties.authenticate);
2224
2327
  };
2225
- m.prototype.getSpread = function() {
2226
- return this.otherProperties.spread || void 0;
2328
+ C.prototype.getImages = function() {
2329
+ return this.linksWithRole("images");
2227
2330
  };
2228
- class wr {
2331
+ class vr {
2229
2332
  /**
2230
2333
  * Extracts the full raw text, or returns null if no text content can be found.
2231
2334
  * @param separator Separator to use between individual elements. Defaults to newline.
@@ -2244,13 +2347,13 @@ class wr {
2244
2347
  return t;
2245
2348
  }
2246
2349
  }
2247
- class Tt {
2350
+ class Ct {
2248
2351
  constructor(t, e) {
2249
2352
  this.key = t, this.value = e;
2250
2353
  }
2251
2354
  }
2252
- var ot = /* @__PURE__ */ ((i) => (i.ACCESSIBILITY_LABEL = "accessibilityLabel", i.LANGUAGE = "language", i))(ot || {});
2253
- class Bt {
2355
+ var ht = /* @__PURE__ */ ((i) => (i.ACCESSIBILITY_LABEL = "accessibilityLabel", i.LANGUAGE = "language", i))(ht || {});
2356
+ class $t {
2254
2357
  constructor(t = []) {
2255
2358
  this._attributes = t;
2256
2359
  }
@@ -2280,12 +2383,12 @@ class Bt {
2280
2383
  return this._attributes.filter((e) => e.key === t).map((e) => e.value);
2281
2384
  }
2282
2385
  }
2283
- class Ft extends Bt {
2386
+ class Gt extends $t {
2284
2387
  constructor(t, e = []) {
2285
2388
  super(e), this.locator = t;
2286
2389
  }
2287
2390
  }
2288
- class j extends Ft {
2391
+ class it extends Gt {
2289
2392
  /**
2290
2393
  * Human-readable text representation for this element.
2291
2394
  */
@@ -2293,17 +2396,17 @@ class j extends Ft {
2293
2396
  return this.accessibilityLabel;
2294
2397
  }
2295
2398
  }
2296
- class ti extends j {
2399
+ class ni extends it {
2297
2400
  constructor(t, e, r = []) {
2298
2401
  super(t, r), this.embeddedLink = e;
2299
2402
  }
2300
2403
  }
2301
- class ei extends j {
2404
+ class oi extends it {
2302
2405
  constructor(t, e, r = []) {
2303
2406
  super(t, r), this.embeddedLink = e;
2304
2407
  }
2305
2408
  }
2306
- class ii extends j {
2409
+ class ai extends it {
2307
2410
  constructor(t, e, r, s = []) {
2308
2411
  super(t, s), this.embeddedLink = e, this.caption = r;
2309
2412
  }
@@ -2312,12 +2415,12 @@ class ii extends j {
2312
2415
  return (((t = this.caption) == null ? void 0 : t.length) || 0) > 0 ? this.caption : super.text;
2313
2416
  }
2314
2417
  }
2315
- class Wt extends Bt {
2418
+ class Ht extends $t {
2316
2419
  constructor(t, e, r = []) {
2317
2420
  super(r), this.locator = t, this.text = e;
2318
2421
  }
2319
2422
  }
2320
- class at extends j {
2423
+ class ut extends it {
2321
2424
  constructor(t, e, r, s = []) {
2322
2425
  super(t, s), this.role = e, this.segments = r;
2323
2426
  }
@@ -2325,7 +2428,7 @@ class at extends j {
2325
2428
  return this.segments.map((t) => t.text).join("");
2326
2429
  }
2327
2430
  }
2328
- class ri {
2431
+ class li {
2329
2432
  constructor(t) {
2330
2433
  this.level = t;
2331
2434
  }
@@ -2333,17 +2436,17 @@ class ri {
2333
2436
  return `heading-${this.level}`;
2334
2437
  }
2335
2438
  }
2336
- const si = {
2439
+ const ci = {
2337
2440
  role: "body"
2338
- }, ni = {
2441
+ }, hi = {
2339
2442
  role: "footnote"
2340
2443
  };
2341
- class oi {
2444
+ class ui {
2342
2445
  constructor(t, e) {
2343
2446
  this.referenceUrl = t, this.referenceTitle = e, this.role = "quote";
2344
2447
  }
2345
2448
  }
2346
- class yr {
2449
+ class zr {
2347
2450
  /**
2348
2451
  *
2349
2452
  * @param defaultLanguage The default assumed language
@@ -2351,12 +2454,12 @@ class yr {
2351
2454
  * @param contextSnippetLength Length of `before` and `after` snippets in the produced [Locator]s.
2352
2455
  * @param textTokenizerFactory Factory to create a [TextTokenizer] from, using the specified language and unit.
2353
2456
  */
2354
- constructor(t, e, r = 50, s = (n) => Ze(n, e)) {
2457
+ constructor(t, e, r = 50, s = (n) => ti(n, e)) {
2355
2458
  this.defaultLanguage = t, this.contextSnippetLength = r, this.textTokenizerFactory = s;
2356
2459
  }
2357
2460
  tokenize(t) {
2358
- return t instanceof at ? [
2359
- new at(
2461
+ return t instanceof ut ? [
2462
+ new ut(
2360
2463
  t.locator,
2361
2464
  t.role,
2362
2465
  t.segments.map((e) => this.tokenizeSegment(e)).flat()
@@ -2364,8 +2467,8 @@ class yr {
2364
2467
  ] : [t];
2365
2468
  }
2366
2469
  tokenizeSegment(t) {
2367
- return this.textTokenizerFactory(t.language ?? this.defaultLanguage).tokenize(t.text).map((e) => new Wt(
2368
- new A({
2470
+ return this.textTokenizerFactory(t.language ?? this.defaultLanguage).tokenize(t.text).map((e) => new Ht(
2471
+ new w({
2369
2472
  href: t.locator.href,
2370
2473
  type: t.locator.type,
2371
2474
  title: t.locator.title,
@@ -2378,19 +2481,19 @@ class yr {
2378
2481
  }
2379
2482
  extractTextContextIn(t, e) {
2380
2483
  const r = t.substring(e[1], e[1] + this.contextSnippetLength), s = t.substring(e[0] - this.contextSnippetLength, e[0]);
2381
- return new M({
2484
+ return new H({
2382
2485
  after: r.length > 0 ? r : void 0,
2383
2486
  before: s.length > 0 ? s : void 0,
2384
2487
  highlight: t.substring(e[0], e[1])
2385
2488
  });
2386
2489
  }
2387
2490
  }
2388
- class F extends Error {
2491
+ class $ extends Error {
2389
2492
  constructor(t) {
2390
2493
  super(t);
2391
2494
  }
2392
2495
  }
2393
- class wt {
2496
+ class vt {
2394
2497
  /**
2395
2498
  * Advances to the next item and returns it, or null if we reached the end.
2396
2499
  */
@@ -2404,12 +2507,12 @@ class wt {
2404
2507
  return await this.hasPrevious() ? this.previous() : null;
2405
2508
  }
2406
2509
  }
2407
- let ai = class {
2510
+ let fi = class {
2408
2511
  constructor(t, e) {
2409
2512
  this.element = t, this.direction = e;
2410
2513
  }
2411
2514
  };
2412
- class Sr extends wt {
2515
+ class Or extends vt {
2413
2516
  constructor(t, e, r) {
2414
2517
  super(), this.publication = t, this.startLocator = e, this.resourceContentIteratorFactories = r, this._currentIterator = null, this.currentElement = null;
2415
2518
  }
@@ -2422,7 +2525,7 @@ class Sr extends wt {
2422
2525
  previous() {
2423
2526
  var t;
2424
2527
  if (((t = this.currentElement) == null ? void 0 : t.direction) !== -1)
2425
- throw new F("Called previous() without a successful call to hasPrevious() first");
2528
+ throw new $("Called previous() without a successful call to hasPrevious() first");
2426
2529
  return this.currentElement.element;
2427
2530
  }
2428
2531
  async hasNext() {
@@ -2434,7 +2537,7 @@ class Sr extends wt {
2434
2537
  next() {
2435
2538
  var t;
2436
2539
  if (((t = this.currentElement) == null ? void 0 : t.direction) !== 1)
2437
- throw new F("Called next() without a successful call to hasNext() first");
2540
+ throw new $("Called next() without a successful call to hasNext() first");
2438
2541
  return this.currentElement.element;
2439
2542
  }
2440
2543
  async nextIn(t) {
@@ -2446,7 +2549,7 @@ class Sr extends wt {
2446
2549
  const s = this.nextIteratorIn(t, e.index);
2447
2550
  return s ? (this._currentIterator = s, this.nextIn(t)) : null;
2448
2551
  }
2449
- return new ai(r, t);
2552
+ return new fi(r, t);
2450
2553
  }
2451
2554
  /**
2452
2555
  * Returns the [Iterator] for the current [Resource] in the reading order.
@@ -2488,7 +2591,7 @@ class Sr extends wt {
2488
2591
  return null;
2489
2592
  }
2490
2593
  }
2491
- class it extends Ft {
2594
+ class nt extends Gt {
2492
2595
  constructor(t, e, r = []) {
2493
2596
  super(t, r), this.element = e;
2494
2597
  }
@@ -2496,25 +2599,25 @@ class it extends Ft {
2496
2599
  return this.element.text;
2497
2600
  }
2498
2601
  }
2499
- class zt {
2602
+ class Rt {
2500
2603
  constructor(t, e) {
2501
2604
  this.element = t, this.direction = e;
2502
2605
  }
2503
2606
  }
2504
- class Ir extends wt {
2607
+ class Nr extends vt {
2505
2608
  constructor(t, e) {
2506
2609
  var s, n;
2507
2610
  super(), this.pageContent = t, this.startLocator = e, this.pageContentFiltered = [], this.currentElement = null, this.currentProgression = 0, this.currentElementIndex = 0;
2508
2611
  const r = this.pageContent.filter(
2509
2612
  (o) => (o == null ? void 0 : o.str) !== " " && (o == null ? void 0 : o.str) !== ""
2510
2613
  );
2511
- if (this.pageContentFiltered = r.map((o) => new it(o.locator, {
2614
+ if (this.pageContentFiltered = r.map((o) => new nt(o.locator, {
2512
2615
  index: r.indexOf(o),
2513
2616
  text: o.str,
2514
2617
  readingDirection: o.dir
2515
2618
  })), this.startLocator && (this.currentProgression = ((n = (s = this.startLocator) == null ? void 0 : s.locations) == null ? void 0 : n.progression) || 0, this.updateElementIndex()), this.pageContentFiltered.length > 0) {
2516
2619
  const o = this.currentElementIndex;
2517
- (o || o === 0) && (this.currentElement = new zt(
2620
+ (o || o === 0) && (this.currentElement = new Rt(
2518
2621
  this.pageContentFiltered[o],
2519
2622
  1
2520
2623
  /* Forward */
@@ -2534,7 +2637,7 @@ class Ir extends wt {
2534
2637
  }
2535
2638
  previous() {
2536
2639
  if (!this.currentElement)
2537
- throw new F("Called next() without a successful call to hasNext() first");
2640
+ throw new $("Called next() without a successful call to hasNext() first");
2538
2641
  if (this.currentElement = this.nextIn(
2539
2642
  -1
2540
2643
  /* Backward */
@@ -2542,7 +2645,7 @@ class Ir extends wt {
2542
2645
  const t = this.currentElementIndex - 1;
2543
2646
  this.currentProgression = t / this.pageContentFiltered.length * 100, this.currentElementIndex = t;
2544
2647
  }
2545
- return this.currentElement ? this.currentElement.element : new it(new A({ href: "", type: "" }), { index: -1, text: "" });
2648
+ return this.currentElement ? this.currentElement.element : new nt(new w({ href: "", type: "" }), { index: -1, text: "" });
2546
2649
  }
2547
2650
  async hasNext() {
2548
2651
  var t;
@@ -2561,14 +2664,14 @@ class Ir extends wt {
2561
2664
  const e = t + 1;
2562
2665
  this.currentProgression = e / this.pageContentFiltered.length * 100, this.currentElementIndex = e;
2563
2666
  }
2564
- return this.currentElement ? this.currentElement.element : new it(new A({ href: "", type: "" }), { index: -1, text: "" });
2667
+ return this.currentElement ? this.currentElement.element : new nt(new w({ href: "", type: "" }), { index: -1, text: "" });
2565
2668
  }
2566
2669
  nextIn(t) {
2567
2670
  const e = this.currentElementIndex;
2568
2671
  if (e === null || e === this.pageContentFiltered.length - 1 && t === 1 || e === 0 && t === -1)
2569
2672
  return null;
2570
2673
  const r = this.pageContentFiltered[e + t];
2571
- return r ? new zt(r, t) : null;
2674
+ return r ? new Rt(r, t) : null;
2572
2675
  }
2573
2676
  /**
2574
2677
  * Updates the current [PDFReadableElement] position in the pageContentFiltered array
@@ -2578,7 +2681,7 @@ class Ir extends wt {
2578
2681
  return this.currentProgression === 0 ? 0 : this.currentProgression < 0 || this.currentProgression >= 100 ? null : Math.floor(this.currentProgression * this.pageContentFiltered.length / 100);
2579
2682
  }
2580
2683
  }
2581
- const li = [
2684
+ const di = [
2582
2685
  "OBJECT",
2583
2686
  "BASE",
2584
2687
  "FONT",
@@ -2646,10 +2749,10 @@ const li = [
2646
2749
  "NOBR",
2647
2750
  "RB"
2648
2751
  ];
2649
- function vt(i) {
2650
- return li.includes(i.nodeName.toUpperCase());
2752
+ function Pt(i) {
2753
+ return di.includes(i.nodeName.toUpperCase());
2651
2754
  }
2652
- function rt(i, t) {
2755
+ function ot(i, t) {
2653
2756
  const e = i.getAttribute("src");
2654
2757
  if (!(e != null && e.length))
2655
2758
  return null;
@@ -2659,18 +2762,18 @@ function rt(i, t) {
2659
2762
  return e;
2660
2763
  }
2661
2764
  }
2662
- const W = "[\\s\\u0085\\u00A0\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000]", ci = new RegExp(`^${W}+$`, "g"), hi = new RegExp(`^${W}+|${W}+$/g`, "g"), Mt = new RegExp(`^${W}+`, "g"), $t = new RegExp(`${W}+$`, "g"), V = (i) => (
2765
+ const G = "[\\s\\u0085\\u00A0\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000]", pi = new RegExp(`^${G}+$`, "g"), gi = new RegExp(`^${G}+|${G}+$/g`, "g"), Vt = new RegExp(`^${G}+`, "g"), Jt = new RegExp(`${G}+$`, "g"), Y = (i) => (
2663
2766
  // Normal spaces, \t, \n, \v, \f, \r, U+0085, U+00A0, U+2000 to U+200A, U+2028, U+2029, U+202F, U+205F, U+3000
2664
- i != null && i.length ? ci.test(i) : !0
2665
- ), Gt = (i) => i.replace(hi, ""), ui = (i) => i.replace(Mt, ""), fi = (i) => i.replace($t, ""), Ot = (i, t = "") => {
2767
+ i != null && i.length ? pi.test(i) : !0
2768
+ ), Yt = (i) => i.replace(gi, ""), mi = (i) => i.replace(Vt, ""), Ei = (i) => i.replace(Jt, ""), Lt = (i, t = "") => {
2666
2769
  var e, r;
2667
- return new M({
2668
- before: t + (((e = Mt.exec(i)) == null ? void 0 : e[0]) ?? ""),
2669
- highlight: Gt(i),
2670
- after: ((r = $t.exec(i)) == null ? void 0 : r[0]) ?? ""
2770
+ return new H({
2771
+ before: t + (((e = Vt.exec(i)) == null ? void 0 : e[0]) ?? ""),
2772
+ highlight: Yt(i),
2773
+ after: ((r = Jt.exec(i)) == null ? void 0 : r[0]) ?? ""
2671
2774
  });
2672
2775
  };
2673
- function pi(i) {
2776
+ function bi(i) {
2674
2777
  for (; i; ) {
2675
2778
  let t = i.getAttribute("lang") || i.getAttributeNS("http://www.w3.org/1999/xhtml", "lang") || i.getAttributeNS("http://www.w3.org/XML/1998/namespace", "lang");
2676
2779
  if (t)
@@ -2679,11 +2782,11 @@ function pi(i) {
2679
2782
  }
2680
2783
  return null;
2681
2784
  }
2682
- function di(i, t) {
2785
+ function xi(i, t) {
2683
2786
  const e = i.length > 0 && i[i.length - 1] === " ";
2684
2787
  let r = !1, s = !1;
2685
2788
  for (let n = 0; n < t.length; n++)
2686
- if (V(t[n])) {
2789
+ if (Y(t[n])) {
2687
2790
  if (e && !s || r)
2688
2791
  continue;
2689
2792
  i += " ", r = !0;
@@ -2693,25 +2796,25 @@ function di(i, t) {
2693
2796
  }
2694
2797
  return i;
2695
2798
  }
2696
- function yt(i) {
2799
+ function zt(i) {
2697
2800
  return i && i instanceof Element;
2698
2801
  }
2699
- var T;
2802
+ var v;
2700
2803
  (function(i) {
2701
2804
  i.NONE = "none", i.DESCENDANT = "descendant", i.CHILD = "child";
2702
- })(T || (T = {}));
2805
+ })(v || (v = {}));
2703
2806
  var g;
2704
2807
  (function(i) {
2705
2808
  i.id = "id", i.class = "class", i.tag = "tag", i.attribute = "attribute", i.nthchild = "nthchild", i.nthoftype = "nthoftype";
2706
2809
  })(g || (g = {}));
2707
- function gi(i, t) {
2810
+ function yi(i, t) {
2708
2811
  return Object.values(i).includes(t);
2709
2812
  }
2710
- const mi = "CssSelectorGenerator";
2711
- function X(i = "unknown problem", ...t) {
2712
- console.warn(`${mi}: ${i}`, ...t);
2813
+ const wi = "CssSelectorGenerator";
2814
+ function tt(i = "unknown problem", ...t) {
2815
+ console.warn(`${wi}: ${i}`, ...t);
2713
2816
  }
2714
- const Ei = {
2817
+ const Ai = {
2715
2818
  selectors: [
2716
2819
  g.id,
2717
2820
  g.class,
@@ -2728,190 +2831,190 @@ const Ei = {
2728
2831
  maxCombinations: Number.POSITIVE_INFINITY,
2729
2832
  maxCandidates: Number.POSITIVE_INFINITY
2730
2833
  };
2731
- function bi(i) {
2732
- return Array.isArray(i) ? i.filter((t) => gi(g, t)) : [];
2834
+ function Ii(i) {
2835
+ return Array.isArray(i) ? i.filter((t) => yi(g, t)) : [];
2733
2836
  }
2734
- function Ht(i) {
2837
+ function Kt(i) {
2735
2838
  return i instanceof RegExp;
2736
2839
  }
2737
- function xi(i) {
2738
- return ["string", "function"].includes(typeof i) || Ht(i);
2840
+ function Si(i) {
2841
+ return ["string", "function"].includes(typeof i) || Kt(i);
2739
2842
  }
2740
- function Nt(i) {
2741
- return Array.isArray(i) ? i.filter(xi) : [];
2843
+ function kt(i) {
2844
+ return Array.isArray(i) ? i.filter(Si) : [];
2742
2845
  }
2743
- function wi(i) {
2846
+ function vi(i) {
2744
2847
  return i instanceof Node;
2745
2848
  }
2746
- function Pt(i) {
2849
+ function Dt(i) {
2747
2850
  const t = [
2748
2851
  Node.DOCUMENT_NODE,
2749
2852
  Node.DOCUMENT_FRAGMENT_NODE,
2750
2853
  Node.ELEMENT_NODE
2751
2854
  ];
2752
- return wi(i) && t.includes(i.nodeType);
2855
+ return vi(i) && t.includes(i.nodeType);
2753
2856
  }
2754
- function Vt(i, t) {
2755
- if (Pt(i))
2756
- return i.contains(t) || X("element root mismatch", "Provided root does not contain the element. This will most likely result in producing a fallback selector using element's real root node. If you plan to use the selector using provided root (e.g. `root.querySelector`), it will nto work as intended."), i;
2857
+ function qt(i, t) {
2858
+ if (Dt(i))
2859
+ return i.contains(t) || tt("element root mismatch", "Provided root does not contain the element. This will most likely result in producing a fallback selector using element's real root node. If you plan to use the selector using provided root (e.g. `root.querySelector`), it will nto work as intended."), i;
2757
2860
  const e = t.getRootNode({ composed: !1 });
2758
- return Pt(e) ? (e !== document && X("shadow root inferred", "You did not provide a root and the element is a child of Shadow DOM. This will produce a selector using ShadowRoot as a root. If you plan to use the selector using document as a root (e.g. `document.querySelector`), it will not work as intended."), e) : t.ownerDocument.querySelector(":root");
2861
+ return Dt(e) ? (e !== document && tt("shadow root inferred", "You did not provide a root and the element is a child of Shadow DOM. This will produce a selector using ShadowRoot as a root. If you plan to use the selector using document as a root (e.g. `document.querySelector`), it will not work as intended."), e) : t.ownerDocument.querySelector(":root");
2759
2862
  }
2760
- function Ct(i) {
2863
+ function Ut(i) {
2761
2864
  return typeof i == "number" ? i : Number.POSITIVE_INFINITY;
2762
2865
  }
2763
- function yi(i, t = {}) {
2764
- const e = Object.assign(Object.assign({}, Ei), t);
2866
+ function zi(i, t = {}) {
2867
+ const e = Object.assign(Object.assign({}, Ai), t);
2765
2868
  return {
2766
- selectors: bi(e.selectors),
2767
- whitelist: Nt(e.whitelist),
2768
- blacklist: Nt(e.blacklist),
2769
- root: Vt(e.root, i),
2869
+ selectors: Ii(e.selectors),
2870
+ whitelist: kt(e.whitelist),
2871
+ blacklist: kt(e.blacklist),
2872
+ root: qt(e.root, i),
2770
2873
  combineWithinSelector: !!e.combineWithinSelector,
2771
2874
  combineBetweenSelectors: !!e.combineBetweenSelectors,
2772
2875
  includeTag: !!e.includeTag,
2773
- maxCombinations: Ct(e.maxCombinations),
2774
- maxCandidates: Ct(e.maxCandidates)
2876
+ maxCombinations: Ut(e.maxCombinations),
2877
+ maxCandidates: Ut(e.maxCandidates)
2775
2878
  };
2776
2879
  }
2777
- function $(i = []) {
2880
+ function V(i = []) {
2778
2881
  const [t = [], ...e] = i;
2779
2882
  return e.length === 0 ? t : e.reduce((r, s) => r.filter((n) => s.includes(n)), t);
2780
2883
  }
2781
- function Jt(i) {
2884
+ function Zt(i) {
2782
2885
  return [].concat(...i);
2783
2886
  }
2784
- function Ai(i) {
2887
+ function Ti(i) {
2785
2888
  return i.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".+");
2786
2889
  }
2787
- function lt(i) {
2890
+ function ft(i) {
2788
2891
  const t = i.map((e) => {
2789
- if (Ht(e))
2892
+ if (Kt(e))
2790
2893
  return (r) => e.test(r);
2791
2894
  if (typeof e == "function")
2792
2895
  return (r) => {
2793
2896
  const s = e(r);
2794
- return typeof s != "boolean" ? (X("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It's result will be ignored.", e), !1) : s;
2897
+ return typeof s != "boolean" ? (tt("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It's result will be ignored.", e), !1) : s;
2795
2898
  };
2796
2899
  if (typeof e == "string") {
2797
- const r = new RegExp("^" + Ai(e) + "$");
2900
+ const r = new RegExp("^" + Ti(e) + "$");
2798
2901
  return (s) => r.test(s);
2799
2902
  }
2800
- return X("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", e), () => !1;
2903
+ return tt("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", e), () => !1;
2801
2904
  });
2802
2905
  return (e) => t.some((r) => r(e));
2803
2906
  }
2804
- function At(i, t, e) {
2805
- const r = Array.from(Vt(e, i[0]).querySelectorAll(t));
2907
+ function Tt(i, t, e) {
2908
+ const r = Array.from(qt(e, i[0]).querySelectorAll(t));
2806
2909
  return r.length === i.length && i.every((s) => r.includes(s));
2807
2910
  }
2808
- function Yt(i, t) {
2809
- t = t ?? Ii(i);
2911
+ function Xt(i, t) {
2912
+ t = t ?? Ni(i);
2810
2913
  const e = [];
2811
2914
  let r = i;
2812
- for (; yt(r) && r !== t; )
2915
+ for (; zt(r) && r !== t; )
2813
2916
  e.push(r), r = r.parentElement;
2814
2917
  return e;
2815
2918
  }
2816
- function Si(i, t) {
2817
- return $(i.map((e) => Yt(e, t)));
2919
+ function Oi(i, t) {
2920
+ return V(i.map((e) => Xt(e, t)));
2818
2921
  }
2819
- function Ii(i) {
2922
+ function Ni(i) {
2820
2923
  return i.ownerDocument.querySelector(":root");
2821
2924
  }
2822
- const Ti = "", qt = " > ", Kt = " ", zi = {
2823
- [T.NONE]: {
2824
- type: T.NONE,
2825
- value: Ti
2925
+ const Ci = "", Qt = " > ", _t = " ", Ri = {
2926
+ [v.NONE]: {
2927
+ type: v.NONE,
2928
+ value: Ci
2826
2929
  },
2827
- [T.DESCENDANT]: {
2828
- type: T.DESCENDANT,
2829
- value: qt
2930
+ [v.DESCENDANT]: {
2931
+ type: v.DESCENDANT,
2932
+ value: Qt
2830
2933
  },
2831
- [T.CHILD]: {
2832
- type: T.CHILD,
2833
- value: Kt
2934
+ [v.CHILD]: {
2935
+ type: v.CHILD,
2936
+ value: _t
2834
2937
  }
2835
- }, Zt = ", ", vi = new RegExp([
2938
+ }, jt = ", ", Pi = new RegExp([
2836
2939
  "^$",
2837
2940
  "\\s"
2838
2941
  // contains whitespace
2839
- ].join("|")), Oi = new RegExp([
2942
+ ].join("|")), Li = new RegExp([
2840
2943
  "^$"
2841
2944
  // empty or not set
2842
- ].join("|")), Xt = [
2945
+ ].join("|")), te = [
2843
2946
  g.nthoftype,
2844
2947
  g.tag,
2845
2948
  g.id,
2846
2949
  g.class,
2847
2950
  g.attribute,
2848
2951
  g.nthchild
2849
- ], Ni = lt([
2952
+ ], ki = ft([
2850
2953
  "class",
2851
2954
  "id",
2852
2955
  // Angular attributes
2853
2956
  "ng-*"
2854
2957
  ]);
2855
- function Pi({ nodeName: i }) {
2958
+ function Di({ nodeName: i }) {
2856
2959
  return `[${i}]`;
2857
2960
  }
2858
- function Ci({ nodeName: i, nodeValue: t }) {
2859
- return `[${i}='${tt(t)}']`;
2961
+ function Ui({ nodeName: i, nodeValue: t }) {
2962
+ return `[${i}='${rt(t)}']`;
2860
2963
  }
2861
- function Ri({ nodeName: i }, t) {
2964
+ function Bi({ nodeName: i }, t) {
2862
2965
  const e = t.tagName.toLowerCase();
2863
- return ["input", "option"].includes(e) && i === "value" ? !1 : !Ni(i);
2966
+ return ["input", "option"].includes(e) && i === "value" ? !1 : !ki(i);
2864
2967
  }
2865
- function Qt(i) {
2866
- const t = Array.from(i.attributes).filter((e) => Ri(e, i));
2968
+ function ee(i) {
2969
+ const t = Array.from(i.attributes).filter((e) => Bi(e, i));
2867
2970
  return [
2868
- ...t.map(Pi),
2869
- ...t.map(Ci)
2971
+ ...t.map(Di),
2972
+ ...t.map(Ui)
2870
2973
  ];
2871
2974
  }
2872
- function Li(i) {
2873
- const t = i.map(Qt);
2874
- return $(t);
2975
+ function Fi(i) {
2976
+ const t = i.map(ee);
2977
+ return V(t);
2875
2978
  }
2876
- function _t(i) {
2877
- return (i.getAttribute("class") || "").trim().split(/\s+/).filter((t) => !Oi.test(t)).map((t) => `.${tt(t)}`);
2979
+ function ie(i) {
2980
+ return (i.getAttribute("class") || "").trim().split(/\s+/).filter((t) => !Li.test(t)).map((t) => `.${rt(t)}`);
2878
2981
  }
2879
- function ki(i) {
2880
- const t = i.map(_t);
2881
- return $(t);
2982
+ function Wi(i) {
2983
+ const t = i.map(ie);
2984
+ return V(t);
2882
2985
  }
2883
- function jt(i) {
2884
- const t = i.getAttribute("id") || "", e = `#${tt(t)}`, r = i.getRootNode({ composed: !1 });
2885
- return !vi.test(t) && At([i], e, r) ? [e] : [];
2986
+ function re(i) {
2987
+ const t = i.getAttribute("id") || "", e = `#${rt(t)}`, r = i.getRootNode({ composed: !1 });
2988
+ return !Pi.test(t) && Tt([i], e, r) ? [e] : [];
2886
2989
  }
2887
- function Di(i) {
2888
- return i.length === 0 || i.length > 1 ? [] : jt(i[0]);
2990
+ function Mi(i) {
2991
+ return i.length === 0 || i.length > 1 ? [] : re(i[0]);
2889
2992
  }
2890
- function te(i) {
2993
+ function se(i) {
2891
2994
  const t = i.parentNode;
2892
2995
  if (t) {
2893
- const r = Array.from(t.childNodes).filter(yt).indexOf(i);
2996
+ const r = Array.from(t.childNodes).filter(zt).indexOf(i);
2894
2997
  if (r > -1)
2895
2998
  return [`:nth-child(${r + 1})`];
2896
2999
  }
2897
3000
  return [];
2898
3001
  }
2899
- function Ui(i) {
2900
- return $(i.map(te));
3002
+ function $i(i) {
3003
+ return V(i.map(se));
2901
3004
  }
2902
- function ee(i) {
3005
+ function ne(i) {
2903
3006
  return [
2904
- tt(i.tagName.toLowerCase())
3007
+ rt(i.tagName.toLowerCase())
2905
3008
  ];
2906
3009
  }
2907
- function ie(i) {
3010
+ function oe(i) {
2908
3011
  const t = [
2909
- ...new Set(Jt(i.map(ee)))
3012
+ ...new Set(Zt(i.map(ne)))
2910
3013
  ];
2911
3014
  return t.length === 0 || t.length > 1 ? [] : [t[0]];
2912
3015
  }
2913
- function re(i) {
2914
- const t = ie([i])[0], e = i.parentElement;
3016
+ function ae(i) {
3017
+ const t = oe([i])[0], e = i.parentElement;
2915
3018
  if (e) {
2916
3019
  const s = Array.from(e.children).filter((n) => n.tagName.toLowerCase() === t).indexOf(i);
2917
3020
  if (s > -1)
@@ -2919,17 +3022,17 @@ function re(i) {
2919
3022
  }
2920
3023
  return [];
2921
3024
  }
2922
- function Bi(i) {
2923
- return $(i.map(re));
3025
+ function Gi(i) {
3026
+ return V(i.map(ae));
2924
3027
  }
2925
- function se(i = [], { maxResults: t = Number.POSITIVE_INFINITY } = {}) {
3028
+ function le(i = [], { maxResults: t = Number.POSITIVE_INFINITY } = {}) {
2926
3029
  const e = [];
2927
- let r = 0, s = ct(1);
3030
+ let r = 0, s = dt(1);
2928
3031
  for (; s.length <= i.length && r < t; )
2929
- r += 1, e.push(s.map((n) => i[n])), s = Fi(s, i.length - 1);
3032
+ r += 1, e.push(s.map((n) => i[n])), s = Hi(s, i.length - 1);
2930
3033
  return e;
2931
3034
  }
2932
- function Fi(i = [], t = 0) {
3035
+ function Hi(i = [], t = 0) {
2933
3036
  const e = i.length;
2934
3037
  if (e === 0)
2935
3038
  return [];
@@ -2938,123 +3041,123 @@ function Fi(i = [], t = 0) {
2938
3041
  for (let s = e - 1; s >= 0; s--)
2939
3042
  if (r[s] > t) {
2940
3043
  if (s === 0)
2941
- return ct(e + 1);
3044
+ return dt(e + 1);
2942
3045
  r[s - 1]++, r[s] = r[s - 1] + 1;
2943
3046
  }
2944
- return r[e - 1] > t ? ct(e + 1) : r;
3047
+ return r[e - 1] > t ? dt(e + 1) : r;
2945
3048
  }
2946
- function ct(i = 1) {
3049
+ function dt(i = 1) {
2947
3050
  return Array.from(Array(i).keys());
2948
3051
  }
2949
- function Wi(i = {}) {
3052
+ function Vi(i = {}) {
2950
3053
  let t = [];
2951
3054
  return Object.entries(i).forEach(([e, r]) => {
2952
3055
  t = r.flatMap((s) => t.length === 0 ? [{ [e]: s }] : t.map((n) => Object.assign(Object.assign({}, n), { [e]: s })));
2953
3056
  }), t;
2954
3057
  }
2955
- const Mi = ":".charCodeAt(0).toString(16).toUpperCase(), $i = /[ !"#$%&'()\[\]{|}<>*+,./;=?@^`~\\]/;
2956
- function tt(i = "") {
3058
+ const Ji = ":".charCodeAt(0).toString(16).toUpperCase(), Yi = /[ !"#$%&'()\[\]{|}<>*+,./;=?@^`~\\]/;
3059
+ function rt(i = "") {
2957
3060
  var t, e;
2958
- return (e = (t = CSS == null ? void 0 : CSS.escape) === null || t === void 0 ? void 0 : t.call(CSS, i)) !== null && e !== void 0 ? e : Gi(i);
2959
- }
2960
- function Gi(i = "") {
2961
- return i.split("").map((t) => t === ":" ? `\\${Mi} ` : $i.test(t) ? `\\${t}` : escape(t).replace(/%/g, "\\")).join("");
2962
- }
2963
- const Hi = {
2964
- tag: ie,
2965
- id: Di,
2966
- class: ki,
2967
- attribute: Li,
2968
- nthchild: Ui,
2969
- nthoftype: Bi
2970
- }, Vi = {
2971
- tag: ee,
2972
- id: jt,
2973
- class: _t,
2974
- attribute: Qt,
2975
- nthchild: te,
2976
- nthoftype: re
3061
+ return (e = (t = CSS == null ? void 0 : CSS.escape) === null || t === void 0 ? void 0 : t.call(CSS, i)) !== null && e !== void 0 ? e : Ki(i);
3062
+ }
3063
+ function Ki(i = "") {
3064
+ return i.split("").map((t) => t === ":" ? `\\${Ji} ` : Yi.test(t) ? `\\${t}` : escape(t).replace(/%/g, "\\")).join("");
3065
+ }
3066
+ const qi = {
3067
+ tag: oe,
3068
+ id: Mi,
3069
+ class: Wi,
3070
+ attribute: Fi,
3071
+ nthchild: $i,
3072
+ nthoftype: Gi
3073
+ }, Zi = {
3074
+ tag: ne,
3075
+ id: re,
3076
+ class: ie,
3077
+ attribute: ee,
3078
+ nthchild: se,
3079
+ nthoftype: ae
2977
3080
  };
2978
- function Ji(i, t) {
2979
- return Vi[t](i);
3081
+ function Xi(i, t) {
3082
+ return Zi[t](i);
2980
3083
  }
2981
- function Yi(i, t) {
3084
+ function Qi(i, t) {
2982
3085
  var e;
2983
- return ((e = Hi[t]) !== null && e !== void 0 ? e : () => [])(i);
3086
+ return ((e = qi[t]) !== null && e !== void 0 ? e : () => [])(i);
2984
3087
  }
2985
- function qi(i = [], t, e) {
3088
+ function _i(i = [], t, e) {
2986
3089
  return i.filter((r) => e(r) || !t(r));
2987
3090
  }
2988
- function Ki(i = [], t) {
3091
+ function ji(i = [], t) {
2989
3092
  return i.sort((e, r) => {
2990
3093
  const s = t(e), n = t(r);
2991
3094
  return s && !n ? -1 : !s && n ? 1 : 0;
2992
3095
  });
2993
3096
  }
2994
- function Zi(i, t, e) {
2995
- const r = Xi(i, e), s = tr(r, e), n = Jt(s);
3097
+ function tr(i, t, e) {
3098
+ const r = er(i, e), s = nr(r, e), n = Zt(s);
2996
3099
  return [...new Set(n)];
2997
3100
  }
2998
- function Xi(i, t) {
2999
- const { blacklist: e, whitelist: r, combineWithinSelector: s, maxCombinations: n } = t, o = lt(e), l = lt(r), c = (h, u) => {
3000
- const p = Yi(i, u), f = qi(p, o, l), d = Ki(f, l);
3001
- return h[u] = s ? se(d, { maxResults: n }) : d.map((I) => [I]), h;
3101
+ function er(i, t) {
3102
+ const { blacklist: e, whitelist: r, combineWithinSelector: s, maxCombinations: n } = t, o = ft(e), l = ft(r), c = (h, u) => {
3103
+ const d = Qi(i, u), f = _i(d, o, l), p = ji(f, l);
3104
+ return h[u] = s ? le(p, { maxResults: n }) : p.map((S) => [S]), h;
3002
3105
  };
3003
- return Qi(t).reduce(c, {});
3106
+ return ir(t).reduce(c, {});
3004
3107
  }
3005
- function Qi(i) {
3108
+ function ir(i) {
3006
3109
  const { selectors: t, includeTag: e } = i, r = [].concat(t);
3007
3110
  return e && !r.includes("tag") && r.push("tag"), r;
3008
3111
  }
3009
- function _i(i) {
3112
+ function rr(i) {
3010
3113
  return i.includes(g.tag) || i.includes(g.nthoftype) ? [...i] : [...i, g.tag];
3011
3114
  }
3012
- function ji(i) {
3013
- const { selectors: t, combineBetweenSelectors: e, includeTag: r, maxCandidates: s } = i, n = e ? se(t, { maxResults: s }) : t.map((o) => [o]);
3014
- return r ? n.map(_i) : n;
3115
+ function sr(i) {
3116
+ const { selectors: t, combineBetweenSelectors: e, includeTag: r, maxCandidates: s } = i, n = e ? le(t, { maxResults: s }) : t.map((o) => [o]);
3117
+ return r ? n.map(rr) : n;
3015
3118
  }
3016
- function tr(i, t) {
3017
- return ji(t).map((e) => er(e, i)).filter((e) => e.length > 0);
3119
+ function nr(i, t) {
3120
+ return sr(t).map((e) => or(e, i)).filter((e) => e.length > 0);
3018
3121
  }
3019
- function er(i, t) {
3122
+ function or(i, t) {
3020
3123
  const e = {};
3021
3124
  return i.forEach((s) => {
3022
3125
  const n = t[s];
3023
3126
  n.length > 0 && (e[s] = n);
3024
- }), Wi(e).map(rr);
3127
+ }), Vi(e).map(lr);
3025
3128
  }
3026
- function ir(i, t) {
3129
+ function ar(i, t) {
3027
3130
  return t[i] ? t[i].join("") : "";
3028
3131
  }
3029
- function rr(i = {}) {
3030
- const t = [...Xt];
3031
- return i[g.tag] && i[g.nthoftype] && t.splice(t.indexOf(g.tag), 1), t.map((e) => ir(e, i)).join("");
3132
+ function lr(i = {}) {
3133
+ const t = [...te];
3134
+ return i[g.tag] && i[g.nthoftype] && t.splice(t.indexOf(g.tag), 1), t.map((e) => ar(e, i)).join("");
3032
3135
  }
3033
- function sr(i, t) {
3136
+ function cr(i, t) {
3034
3137
  return [
3035
- ...i.map((e) => t + Kt + e),
3036
- ...i.map((e) => t + qt + e)
3138
+ ...i.map((e) => t + _t + e),
3139
+ ...i.map((e) => t + Qt + e)
3037
3140
  ];
3038
3141
  }
3039
- function nr(i, t) {
3040
- return t === "" ? i : sr(i, t);
3142
+ function hr(i, t) {
3143
+ return t === "" ? i : cr(i, t);
3041
3144
  }
3042
- function or(i, t, e = "", r) {
3043
- const s = Zi(i, r.root, r), n = nr(s, e);
3145
+ function ur(i, t, e = "", r) {
3146
+ const s = tr(i, r.root, r), n = hr(s, e);
3044
3147
  for (const o of n)
3045
- if (At(i, o, r.root))
3148
+ if (Tt(i, o, r.root))
3046
3149
  return o;
3047
3150
  return null;
3048
3151
  }
3049
- function ar(i, t, e = "", r) {
3152
+ function fr(i, t, e = "", r) {
3050
3153
  if (i.length === 0)
3051
3154
  return null;
3052
3155
  const s = [
3053
3156
  i.length > 1 ? i : [],
3054
- ...Si(i, t).map((n) => [n])
3157
+ ...Oi(i, t).map((n) => [n])
3055
3158
  ];
3056
3159
  for (const n of s) {
3057
- const o = or(n, t, e, r);
3160
+ const o = ur(n, t, e, r);
3058
3161
  if (o)
3059
3162
  return {
3060
3163
  foundElements: n,
@@ -3063,28 +3166,28 @@ function ar(i, t, e = "", r) {
3063
3166
  }
3064
3167
  return null;
3065
3168
  }
3066
- function lr(i) {
3067
- const t = (Array.isArray(i) ? i : [i]).filter(yt);
3169
+ function dr(i) {
3170
+ const t = (Array.isArray(i) ? i : [i]).filter(zt);
3068
3171
  return [...new Set(t)];
3069
3172
  }
3070
- function cr(i) {
3173
+ function pr(i) {
3071
3174
  return {
3072
3175
  value: i,
3073
3176
  include: !1
3074
3177
  };
3075
3178
  }
3076
- function hr(i, t, e = T.NONE) {
3179
+ function gr(i, t, e = v.NONE) {
3077
3180
  const r = {};
3078
3181
  return t.forEach((s) => {
3079
- Reflect.set(r, s, Ji(i, s).map(cr));
3182
+ Reflect.set(r, s, Xi(i, s).map(pr));
3080
3183
  }), {
3081
3184
  element: i,
3082
- operator: zi[e],
3185
+ operator: Ri[e],
3083
3186
  selectors: r
3084
3187
  };
3085
3188
  }
3086
- function ur({ selectors: i, operator: t }) {
3087
- let e = [...Xt];
3189
+ function mr({ selectors: i, operator: t }) {
3190
+ let e = [...te];
3088
3191
  i[g.tag] && i[g.nthoftype] && (e = e.filter((s) => s !== g.tag));
3089
3192
  let r = "";
3090
3193
  return e.forEach((s) => {
@@ -3093,33 +3196,33 @@ function ur({ selectors: i, operator: t }) {
3093
3196
  });
3094
3197
  }), t.value + r;
3095
3198
  }
3096
- function fr(i) {
3097
- return [":root", ...Yt(i).reverse().map((r) => {
3098
- const s = hr(r, [g.nthchild], T.DESCENDANT);
3199
+ function Er(i) {
3200
+ return [":root", ...Xt(i).reverse().map((r) => {
3201
+ const s = gr(r, [g.nthchild], v.DESCENDANT);
3099
3202
  return s.selectors.nthchild.forEach((n) => {
3100
3203
  n.include = !0;
3101
3204
  }), s;
3102
- }).map(ur)].join("");
3205
+ }).map(mr)].join("");
3103
3206
  }
3104
- function pr(i) {
3105
- return i.map(fr).join(Zt);
3207
+ function br(i) {
3208
+ return i.map(Er).join(jt);
3106
3209
  }
3107
- function ne(i, t = {}) {
3108
- const e = lr(i), r = yi(e[0], t);
3210
+ function ce(i, t = {}) {
3211
+ const e = dr(i), r = zi(e[0], t);
3109
3212
  let s = "", n = r.root;
3110
3213
  function o() {
3111
- return ar(e, n, s, r);
3214
+ return fr(e, n, s, r);
3112
3215
  }
3113
3216
  let l = o();
3114
3217
  for (; l; ) {
3115
3218
  const { foundElements: c, selector: h } = l;
3116
- if (At(e, h, r.root))
3219
+ if (Tt(e, h, r.root))
3117
3220
  return h;
3118
3221
  n = c[0], s = h, l = o();
3119
3222
  }
3120
- return e.length > 1 ? e.map((c) => ne(c, r)).join(Zt) : pr(e);
3223
+ return e.length > 1 ? e.map((c) => ce(c, r)).join(jt) : br(e);
3121
3224
  }
3122
- class Tr extends wt {
3225
+ class Cr extends vt {
3123
3226
  constructor(t, e, r = 50) {
3124
3227
  super(), this.resource = t, this.locator = e, this.beforeMaxLength = r, this.currentElement = null, this.currentIndex = null, this.parsedElementRecipes = null, this.parser = null;
3125
3228
  }
@@ -3135,7 +3238,7 @@ class Tr extends wt {
3135
3238
  }
3136
3239
  previous() {
3137
3240
  if (!this.currentElement || this.currentElement.delta !== -1)
3138
- throw new F("Called previous() without a successful call to hasPrevious() first");
3241
+ throw new $("Called previous() without a successful call to hasPrevious() first");
3139
3242
  const t = this.currentElement.element;
3140
3243
  return this.currentElement = null, t;
3141
3244
  }
@@ -3151,7 +3254,7 @@ class Tr extends wt {
3151
3254
  }
3152
3255
  next() {
3153
3256
  if (!this.currentElement || this.currentElement.delta !== 1)
3154
- throw new F("Called next() without a successful call to hasNext() first");
3257
+ throw new $("Called next() without a successful call to hasNext() first");
3155
3258
  const t = this.currentElement.element;
3156
3259
  return this.currentElement = null, t;
3157
3260
  }
@@ -3160,15 +3263,15 @@ class Tr extends wt {
3160
3263
  }
3161
3264
  async parseElements() {
3162
3265
  const t = await this.resource.readAsString(), e = new DOMParser().parseFromString(t, this.locator.type);
3163
- return this.parser = new gr(
3266
+ return this.parser = new yr(
3164
3267
  e,
3165
3268
  this.locator,
3166
3269
  this.locator.locations.getCssSelector() ? e.querySelector(this.locator.locations.getCssSelector()) : null,
3167
3270
  this.beforeMaxLength
3168
- ), dr(this.parser, e.body), this.parser.result();
3271
+ ), xr(this.parser, e.body), this.parser.result();
3169
3272
  }
3170
3273
  }
3171
- function dr(i, t) {
3274
+ function xr(i, t) {
3172
3275
  let e = t, r = 0;
3173
3276
  for (; e != null; )
3174
3277
  if (i.head(e, r), e.firstChild != null)
@@ -3181,7 +3284,7 @@ function dr(i, t) {
3181
3284
  e = (e == null ? void 0 : e.nextSibling) || null;
3182
3285
  }
3183
3286
  }
3184
- class gr {
3287
+ class yr {
3185
3288
  constructor(t, e, r, s) {
3186
3289
  this.doc = t, this.baseLocator = e, this.startElement = r, this.beforeMaxLength = s, this.elementRecipes = [], this.startIndex = 0, this.segmentRecipesAcc = [], this.textAcc = "", this.wholeRawTextAcc = null, this.elementRawTextAcc = "", this.rawTextAcc = "", this.currentLanguage = null, this.breadcrumbs = [], this.recipeCssSelectorCache = /* @__PURE__ */ new WeakMap();
3187
3290
  }
@@ -3196,38 +3299,38 @@ class gr {
3196
3299
  const e = t.recipe.cssSelectorNode ? this.cssSelector(t.recipe.cssSelectorNode) : null;
3197
3300
  if (t.type === 1) {
3198
3301
  const s = t.recipe;
3199
- return new ii(
3200
- new A({
3302
+ return new ai(
3303
+ new w({
3201
3304
  href: this.baseLocator.href,
3202
3305
  type: this.baseLocator.type,
3203
3306
  title: this.baseLocator.title,
3204
- locations: new E(e ? {
3307
+ locations: new m(e ? {
3205
3308
  otherLocations: /* @__PURE__ */ new Map([
3206
3309
  ["cssSelector", e]
3207
3310
  ])
3208
3311
  } : {})
3209
3312
  }),
3210
- new S({
3313
+ new I({
3211
3314
  href: s.href
3212
3315
  }),
3213
3316
  s.caption,
3214
3317
  s.attributes
3215
3318
  );
3216
3319
  } else if (t.type === 2 || t.type === 3) {
3217
- const s = new A({
3320
+ const s = new w({
3218
3321
  href: this.baseLocator.href,
3219
3322
  type: this.baseLocator.type,
3220
3323
  title: this.baseLocator.title,
3221
- locations: new E(e ? {
3324
+ locations: new m(e ? {
3222
3325
  otherLocations: /* @__PURE__ */ new Map([
3223
3326
  ["cssSelector", e]
3224
3327
  ])
3225
3328
  } : {})
3226
3329
  }), n = t.recipe;
3227
- return t.type === 3 ? new ei(
3330
+ return t.type === 3 ? new oi(
3228
3331
  s,
3229
3332
  n.link
3230
- ) : new ti(
3333
+ ) : new ni(
3231
3334
  s,
3232
3335
  n.link
3233
3336
  );
@@ -3235,13 +3338,13 @@ class gr {
3235
3338
  const s = t.recipe, n = s.segments.map((o) => {
3236
3339
  var c;
3237
3340
  const l = o.cssSelectorNode ? this.cssSelector(o.cssSelectorNode) : null;
3238
- return new Wt(
3239
- new A({
3341
+ return new Ht(
3342
+ new w({
3240
3343
  href: this.baseLocator.href,
3241
3344
  type: this.baseLocator.type,
3242
3345
  title: this.baseLocator.title,
3243
- text: Ot(o.text, (c = this.wholeRawTextAcc) == null ? void 0 : c.substring(o.beforeRange[0], o.beforeRange[1])),
3244
- locations: new E(l ? {
3346
+ text: Lt(o.text, (c = this.wholeRawTextAcc) == null ? void 0 : c.substring(o.beforeRange[0], o.beforeRange[1])),
3347
+ locations: new m(l ? {
3245
3348
  otherLocations: /* @__PURE__ */ new Map([
3246
3349
  ["cssSelector", l]
3247
3350
  ])
@@ -3251,13 +3354,13 @@ class gr {
3251
3354
  o.attributes
3252
3355
  );
3253
3356
  });
3254
- return new at(
3255
- new A({
3357
+ return new ut(
3358
+ new w({
3256
3359
  href: this.baseLocator.href,
3257
3360
  type: this.baseLocator.type,
3258
3361
  title: this.baseLocator.title,
3259
- text: Ot(s.text, n.length && ((r = n[0].locator.text) == null ? void 0 : r.before) || ""),
3260
- locations: new E(e ? {
3362
+ text: Lt(s.text, n.length && ((r = n[0].locator.text) == null ? void 0 : r.before) || ""),
3363
+ locations: new m(e ? {
3261
3364
  otherLocations: /* @__PURE__ */ new Map([
3262
3365
  ["cssSelector", e]
3263
3366
  ])
@@ -3282,7 +3385,7 @@ class gr {
3282
3385
  }
3283
3386
  n = n.parentElement;
3284
3387
  }
3285
- const o = ne(e, {
3388
+ const o = ce(e, {
3286
3389
  root: this.doc
3287
3390
  });
3288
3391
  return s.forEach((l, c) => l.forEach((h) => c.attributes.setNamedItem(h))), this.recipeCssSelectorCache.set(e, o), o;
@@ -3290,14 +3393,14 @@ class gr {
3290
3393
  // Implements NodeTraversor
3291
3394
  head(t, e) {
3292
3395
  if (t.nodeType == Node.ELEMENT_NODE) {
3293
- const r = !vt(t);
3396
+ const r = !Pt(t);
3294
3397
  r && (this.flushText(), this.breadcrumbs.push(t));
3295
3398
  const s = t.nodeName.toUpperCase();
3296
3399
  if (s === "BR")
3297
3400
  this.flushText();
3298
3401
  else if (s === "IMG" || s === "AUDIO" || s === "VIDEO")
3299
3402
  if (this.flushText(), s === "IMG") {
3300
- const n = t, o = rt(n, this.baseLocator.href);
3403
+ const n = t, o = ot(n, this.baseLocator.href);
3301
3404
  let l = n.getAttribute("alt");
3302
3405
  l != null && l.length || (l = n.getAttribute("title")), o != null && this.elementRecipes.push({
3303
3406
  type: 1,
@@ -3306,28 +3409,28 @@ class gr {
3306
3409
  caption: void 0,
3307
3410
  // FIXME: Get the caption from figcaption
3308
3411
  cssSelectorNode: t,
3309
- attributes: l != null && l.length ? [new Tt(
3310
- ot.ACCESSIBILITY_LABEL,
3412
+ attributes: l != null && l.length ? [new Ct(
3413
+ ht.ACCESSIBILITY_LABEL,
3311
3414
  l
3312
3415
  )] : []
3313
3416
  }
3314
3417
  });
3315
3418
  } else {
3316
- const n = t, o = rt(n, this.baseLocator.href);
3419
+ const n = t, o = ot(n, this.baseLocator.href);
3317
3420
  let l;
3318
3421
  if (o != null)
3319
- l = new S({
3422
+ l = new I({
3320
3423
  href: o
3321
3424
  });
3322
3425
  else {
3323
3426
  const c = [...n.getElementsByTagName("source")].map((h) => {
3324
- const u = rt(h, this.baseLocator.href);
3325
- return u ? new S({
3427
+ const u = ot(h, this.baseLocator.href);
3428
+ return u ? new I({
3326
3429
  href: u,
3327
3430
  type: h.getAttribute("type") || void 0
3328
3431
  }) : null;
3329
3432
  }).filter((h) => !!h);
3330
- c.length > 0 && (l = new S({
3433
+ c.length > 0 && (l = new I({
3331
3434
  href: c[0].href,
3332
3435
  type: c[0].type,
3333
3436
  alternates: c.length > 1 ? new x(c.slice(1)) : void 0
@@ -3352,10 +3455,10 @@ class gr {
3352
3455
  }
3353
3456
  // Implements NodeTraversor
3354
3457
  tail(t, e) {
3355
- if (t.nodeType === Node.TEXT_NODE && !V(t.textContent)) {
3356
- const r = pi(t.parentElement);
3357
- this.currentLanguage !== r && (this.flushSegment(), this.currentLanguage = r), this.rawTextAcc += t.textContent, this.textAcc = di(this.textAcc, t.textContent);
3358
- } else if (t.nodeType === Node.ELEMENT_NODE && !vt(t)) {
3458
+ if (t.nodeType === Node.TEXT_NODE && !Y(t.textContent)) {
3459
+ const r = bi(t.parentElement);
3460
+ this.currentLanguage !== r && (this.flushSegment(), this.currentLanguage = r), this.rawTextAcc += t.textContent, this.textAcc = xi(this.textAcc, t.textContent);
3461
+ } else if (t.nodeType === Node.ELEMENT_NODE && !Pt(t)) {
3359
3462
  if (!this.breadcrumbs.length || this.breadcrumbs.at(-1) !== t)
3360
3463
  throw new Error("HTMLContentIterator: breadcrumbs mismatch");
3361
3464
  this.flushText(), this.breadcrumbs.pop();
@@ -3365,14 +3468,14 @@ class gr {
3365
3468
  var e;
3366
3469
  if (this.flushSegment(), this.startIndex === 0 && this.startElement && this.breadcrumbs.length && this.breadcrumbs.at(-1) === this.startElement && (this.startIndex = this.elementRecipes.length), !this.segmentRecipesAcc.length)
3367
3470
  return;
3368
- this.segmentRecipesAcc[this.segmentRecipesAcc.length - 1].text = fi(
3471
+ this.segmentRecipesAcc[this.segmentRecipesAcc.length - 1].text = Ei(
3369
3472
  this.segmentRecipesAcc[this.segmentRecipesAcc.length - 1].text
3370
3473
  );
3371
- let t = si;
3474
+ let t = ci;
3372
3475
  if (this.breadcrumbs.length > 0) {
3373
3476
  const r = this.breadcrumbs.at(-1);
3374
3477
  if (r.getAttributeNS("http://www.idpf.org/2007/ops", "type") === "footnote")
3375
- t = ni;
3478
+ t = hi;
3376
3479
  else
3377
3480
  switch (r.nodeName.toUpperCase()) {
3378
3481
  case "H1":
@@ -3381,11 +3484,11 @@ class gr {
3381
3484
  case "H4":
3382
3485
  case "H5":
3383
3486
  case "H6":
3384
- t = new ri(parseInt(r.nodeName[1]));
3487
+ t = new li(parseInt(r.nodeName[1]));
3385
3488
  break;
3386
3489
  case "BLOCKQUOTE":
3387
3490
  case "Q":
3388
- t = new oi(
3491
+ t = new ui(
3389
3492
  (e = r.getAttribute("cite")) != null && e.length || 0 > 0 ? new URL(r.getAttribute("cite")) : void 0,
3390
3493
  r.getAttribute("title") || void 0
3391
3494
  );
@@ -3404,17 +3507,17 @@ class gr {
3404
3507
  }
3405
3508
  flushSegment() {
3406
3509
  let t = this.textAcc;
3407
- const e = Gt(t);
3408
- if (!V(e)) {
3510
+ const e = Yt(t);
3511
+ if (!Y(e)) {
3409
3512
  if (!this.segmentRecipesAcc.length) {
3410
- t = ui(t);
3411
- const r = t.length && V(t[t.length - 1]) ? t[t.length - 1] : "";
3513
+ t = mi(t);
3514
+ const r = t.length && Y(t[t.length - 1]) ? t[t.length - 1] : "";
3412
3515
  t = e + r;
3413
3516
  }
3414
3517
  this.segmentRecipesAcc.push({
3415
3518
  text: t,
3416
- attributes: this.currentLanguage ? [new Tt(
3417
- ot.LANGUAGE,
3519
+ attributes: this.currentLanguage ? [new Ct(
3520
+ ht.LANGUAGE,
3418
3521
  this.currentLanguage
3419
3522
  )] : [],
3420
3523
  beforeRange: this.wholeRawTextAcc ? [this.wholeRawTextAcc.length - this.beforeMaxLength, this.wholeRawTextAcc.length] : [0, 0],
@@ -3424,7 +3527,7 @@ class gr {
3424
3527
  this.rawTextAcc.length && (this.wholeRawTextAcc = (this.wholeRawTextAcc || "") + this.rawTextAcc, this.elementRawTextAcc += this.rawTextAcc), this.rawTextAcc = "", this.textAcc = "";
3425
3528
  }
3426
3529
  }
3427
- class Q {
3530
+ class et {
3428
3531
  /**
3429
3532
  * Creates a [LocatorMetadata].
3430
3533
  */
@@ -3440,9 +3543,9 @@ class Q {
3440
3543
  const e = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(["title", "numberOfItems"]);
3441
3544
  return Object.entries(t).forEach(([s, n]) => {
3442
3545
  r.has(s) || e.set(s, n);
3443
- }), new Q({
3444
- title: O.deserialize(t.title),
3445
- numberOfItems: C(t.numberOfItems),
3546
+ }), new et({
3547
+ title: T.deserialize(t.title),
3548
+ numberOfItems: L(t.numberOfItems),
3446
3549
  otherMetadata: e.size === 0 ? void 0 : e
3447
3550
  });
3448
3551
  }
@@ -3454,12 +3557,12 @@ class Q {
3454
3557
  return this.title && (t.title = this.title.serialize()), this.numberOfItems !== void 0 && (t.numberOfItems = this.numberOfItems), this.otherMetadata && this.otherMetadata.forEach((e, r) => t[r] = e), t;
3455
3558
  }
3456
3559
  }
3457
- class oe {
3560
+ class he {
3458
3561
  /**
3459
3562
  * Creates a [LocatorCollection].
3460
3563
  */
3461
3564
  constructor(t) {
3462
- this.metadata = t.metadata ?? new Q({}), this.links = t.links ?? new x([]), this.locators = t.locators ?? [];
3565
+ this.metadata = t.metadata ?? new et({}), this.links = t.links ?? new x([]), this.locators = t.locators ?? [];
3463
3566
  }
3464
3567
  /**
3465
3568
  * Parses a [LocatorCollection] from its RWPM JSON representation.
@@ -3468,8 +3571,8 @@ class oe {
3468
3571
  if (!t)
3469
3572
  return;
3470
3573
  let e, r = t.locators;
3471
- return r && r instanceof Array && (e = r.map((s) => A.deserialize(s)).filter((s) => s !== void 0)), new oe({
3472
- metadata: Q.deserialize(t.metadata),
3574
+ return r && r instanceof Array && (e = r.map((s) => w.deserialize(s)).filter((s) => s !== void 0)), new he({
3575
+ metadata: et.deserialize(t.metadata),
3473
3576
  links: x.deserialize(t.links),
3474
3577
  locators: e
3475
3578
  });
@@ -3486,7 +3589,7 @@ class oe {
3486
3589
  return this.links && this.links.items.length > 0 && (t.links = this.links.serialize()), this.locators && (t.locators = this.locators.map((e) => e.serialize())), t;
3487
3590
  }
3488
3591
  }
3489
- class v {
3592
+ class z {
3490
3593
  /**
3491
3594
  * Creates a [PublicationCollection].
3492
3595
  */
@@ -3505,11 +3608,11 @@ class v {
3505
3608
  else if (t instanceof Object)
3506
3609
  e = x.deserialize(t.links), r = /* @__PURE__ */ new Map(), t.metadata && Object.entries(t.metadata).forEach(([n, o]) => {
3507
3610
  r == null || r.set(n, o);
3508
- }), s = v.deserializeCollections(t);
3611
+ }), s = z.deserializeCollections(t);
3509
3612
  else
3510
3613
  return;
3511
3614
  if (!(!e || e.items.length === 0))
3512
- return new v({
3615
+ return new z({
3513
3616
  metadata: r != null && r.size ? r : void 0,
3514
3617
  links: e,
3515
3618
  subcollections: s != null && s.size ? s : void 0
@@ -3525,13 +3628,13 @@ class v {
3525
3628
  const e = /* @__PURE__ */ new Map();
3526
3629
  return Object.entries(t).forEach(([r, s]) => {
3527
3630
  if (r !== "links" && r !== "metadata") {
3528
- const n = v.deserialize(s);
3631
+ const n = z.deserialize(s);
3529
3632
  if (n) {
3530
3633
  const o = new Array();
3531
3634
  o.push(n), e.set(r, o);
3532
3635
  } else if (s instanceof Array) {
3533
3636
  const o = s.map(
3534
- (l) => v.deserialize(l)
3637
+ (l) => z.deserialize(l)
3535
3638
  ).filter((l) => l !== void 0);
3536
3639
  e.set(r, o);
3537
3640
  }
@@ -3545,7 +3648,7 @@ class v {
3545
3648
  const t = {};
3546
3649
  return this.metadata && (t.metadata = {}, this.metadata.forEach(
3547
3650
  (e, r) => t.metadata[r] = e
3548
- )), this.links.items.length && (t.links = this.links.serialize()), v.serializeCollection(t, this.subcollections), t;
3651
+ )), this.links.items.length && (t.links = this.links.serialize()), z.serializeCollection(t, this.subcollections), t;
3549
3652
  }
3550
3653
  static serializeCollection(t, e) {
3551
3654
  e && e.size > 0 && e.forEach(
@@ -3555,9 +3658,9 @@ class v {
3555
3658
  );
3556
3659
  }
3557
3660
  }
3558
- class ae {
3661
+ class ue {
3559
3662
  constructor(t) {
3560
- this.context = t.context, this.metadata = t.metadata, this.links = t.links, this.readingOrder = t.readingOrder, this.resources = t.resources, this.tableOfContents = t.tableOfContents, this.subcollections = t.subcollections;
3663
+ this.context = t.context, this.metadata = t.metadata, this.links = t.links, this.readingOrder = t.readingOrder, this.resources = t.resources, this.toc = t.toc, this.subcollections = t.subcollections;
3561
3664
  }
3562
3665
  /**
3563
3666
  * Parses a [Publication] from its RWPM JSON representation.
@@ -3568,7 +3671,7 @@ class ae {
3568
3671
  static deserialize(t) {
3569
3672
  if (!t)
3570
3673
  return;
3571
- const e = Ut.deserialize(t.metadata);
3674
+ const e = Ft.deserialize(t.metadata);
3572
3675
  if (!e)
3573
3676
  return;
3574
3677
  const r = x.deserialize(t.links);
@@ -3578,14 +3681,14 @@ class ae {
3578
3681
  t.readingOrder ? t.readingOrder : t.spine
3579
3682
  );
3580
3683
  if (s)
3581
- return new ae({
3582
- context: R(t["@context"]),
3684
+ return new ue({
3685
+ context: N(t["@context"]),
3583
3686
  metadata: e,
3584
3687
  links: r,
3585
3688
  readingOrder: s,
3586
3689
  resources: x.deserialize(t.resources),
3587
- tableOfContents: x.deserialize(t.toc),
3588
- subcollections: v.deserializeCollections({
3690
+ toc: x.deserialize(t.toc),
3691
+ subcollections: z.deserializeCollections({
3589
3692
  sub: t.sub
3590
3693
  })
3591
3694
  });
@@ -3595,7 +3698,7 @@ class ae {
3595
3698
  */
3596
3699
  serialize() {
3597
3700
  const t = {};
3598
- return this.context !== void 0 && (t["@context"] = this.context), t.metadata = this.metadata.serialize(), t.links = this.links.serialize(), t.readingOrder = this.readingOrder.serialize(), this.resources && (t.resources = this.resources.serialize()), this.tableOfContents && (t.toc = this.tableOfContents.serialize()), v.serializeCollection(t, this.subcollections), t;
3701
+ return this.context !== void 0 && (t["@context"] = this.context), t.metadata = this.metadata.serialize(), t.links = this.links.serialize(), t.readingOrder = this.readingOrder.serialize(), this.resources && (t.resources = this.resources.serialize()), this.toc && (t.toc = this.toc.serialize()), z.serializeCollection(t, this.subcollections), t;
3599
3702
  }
3600
3703
  /** Finds the first link with the given relation in the manifest's links. */
3601
3704
  linkWithRel(t) {
@@ -3624,11 +3727,11 @@ class ae {
3624
3727
  if (!n)
3625
3728
  return;
3626
3729
  const o = e.length == 2 ? e[1] : void 0;
3627
- return new A({
3730
+ return new w({
3628
3731
  href: r,
3629
3732
  type: n,
3630
3733
  title: s.title ?? t.title,
3631
- locations: new E({
3734
+ locations: new m({
3632
3735
  fragments: o ? [o] : void 0,
3633
3736
  progression: o ? void 0 : 0
3634
3737
  })
@@ -3643,10 +3746,10 @@ class ae {
3643
3746
  return c;
3644
3747
  const h = new Array();
3645
3748
  return l.forEach((u) => {
3646
- const p = [];
3749
+ const d = [];
3647
3750
  for (const f of u.items)
3648
- f.alternates && p.push(f.alternates), f.children && p.push(f.children);
3649
- h.push(...p);
3751
+ f.alternates && d.push(f.alternates), f.children && d.push(f.children);
3752
+ h.push(...d);
3650
3753
  }), h.length > 0 && (c = e(h)), c;
3651
3754
  }, r = [];
3652
3755
  r.push(this.readingOrder), this.resources && r.push(this.resources), r.push(this.links);
@@ -3685,7 +3788,7 @@ class ae {
3685
3788
  return e.rels === void 0 || !((r = e.rels) != null && r.has("self"));
3686
3789
  }
3687
3790
  ), this.links.items.push(
3688
- new S({
3791
+ new I({
3689
3792
  href: t,
3690
3793
  type: a.READIUM_WEBPUB_MANIFEST.string,
3691
3794
  rels: /* @__PURE__ */ new Set(["self"])
@@ -3694,82 +3797,83 @@ class ae {
3694
3797
  }
3695
3798
  }
3696
3799
  export {
3697
- U as Acquisition,
3698
- Tt as Attribute,
3699
- ot as AttributeKeys,
3700
- Bt as AttributesHolder,
3701
- ti as AudioElement,
3702
- Et as Availability,
3703
- je as AvailabilityStatus,
3704
- B as BelongsTo,
3705
- si as Body,
3706
- wr as Content,
3707
- Ft as ContentElement,
3708
- K as Contributor,
3709
- b as Contributors,
3710
- mt as Copies,
3711
- Ze as DefaultTextContentTokenizer,
3712
- pt as DomRange,
3713
- q as DomRangePoint,
3714
- Rt as EPUBLayout,
3715
- Ae as EmptyFetcher,
3716
- ht as Encryption,
3717
- ve as Fit,
3718
- ni as Footnote,
3719
- ft as GuidedNavigationDocument,
3720
- k as GuidedNavigationObject,
3721
- Tr as HTMLResourceContentIterator,
3722
- ri as Heading,
3723
- gt as Holds,
3724
- mr as HttpFetcher,
3725
- Se as HttpResource,
3726
- F as IllegalStateError,
3727
- ii as ImageElement,
3728
- Xe as IntlTextTokenizer,
3729
- wt as Iterator,
3730
- S as Link,
3800
+ M as Acquisition,
3801
+ k as AltIdentifier,
3802
+ Ct as Attribute,
3803
+ ht as AttributeKeys,
3804
+ $t as AttributesHolder,
3805
+ ni as AudioElement,
3806
+ St as Availability,
3807
+ si as AvailabilityStatus,
3808
+ F as BelongsTo,
3809
+ ci as Body,
3810
+ vr as Content,
3811
+ Gt as ContentElement,
3812
+ X as Contributor,
3813
+ E as Contributors,
3814
+ It as Copies,
3815
+ ti as DefaultTextContentTokenizer,
3816
+ yt as DomRange,
3817
+ j as DomRangePoint,
3818
+ Ce as EmptyFetcher,
3819
+ pt as Encryption,
3820
+ hi as Footnote,
3821
+ xt as GuidedNavigationDocument,
3822
+ P as GuidedNavigationObject,
3823
+ _ as GuidedNavigationText,
3824
+ Cr as HTMLResourceContentIterator,
3825
+ li as Heading,
3826
+ At as Holds,
3827
+ wr as HttpFetcher,
3828
+ Re as HttpResource,
3829
+ $ as IllegalStateError,
3830
+ ai as ImageElement,
3831
+ ei as IntlTextTokenizer,
3832
+ vt as Iterator,
3833
+ U as Layout,
3834
+ I as Link,
3731
3835
  x as Links,
3732
- O as LocalizedString,
3733
- A as Locator,
3734
- oe as LocatorCollection,
3735
- Q as LocatorCollectionMetadata,
3736
- E as LocatorLocations,
3737
- M as LocatorText,
3738
- ae as Manifest,
3836
+ T as LocalizedString,
3837
+ w as Locator,
3838
+ he as LocatorCollection,
3839
+ et as LocatorCollectionMetadata,
3840
+ m as LocatorLocations,
3841
+ H as LocatorText,
3842
+ ue as Manifest,
3843
+ gt as MediaOverlay,
3739
3844
  a as MediaType,
3740
- Ut as Metadata,
3741
- Qe as NaiveTextTokenizer,
3742
- Er as NumberRange,
3743
- Ie as Orientation,
3744
- Te as Overflow,
3745
- it as PDFContentElement,
3746
- H as Page,
3747
- Ir as PageContentIteratorPDF,
3748
- _ as Presentation,
3749
- dt as Price,
3750
- m as Properties,
3751
- N as Publication,
3752
- v as PublicationCollection,
3753
- Sr as PublicationContentIterator,
3754
- z as ReadingProgression,
3755
- br as Resource,
3756
- ze as Spread,
3757
- Z as Subject,
3758
- xt as Subjects,
3759
- yr as TextContentTokenizer,
3760
- at as TextElement,
3761
- oi as TextQuote,
3762
- Wt as TextSegment,
3763
- Ke as TextUnit,
3764
- j as TextualElement,
3765
- J as URITemplate,
3766
- ei as VideoElement,
3767
- Oe as arrayfromJSON,
3768
- R as arrayfromJSONorString,
3769
- Y as datefromJSON,
3770
- xr as leadingPage,
3771
- C as numberfromJSON,
3772
- y as positiveNumberfromJSON,
3773
- ut as setToArray,
3774
- kt as speakableToken
3845
+ Ft as Metadata,
3846
+ ii as NaiveTextTokenizer,
3847
+ Ar as NumberRange,
3848
+ nt as PDFContentElement,
3849
+ at as Page,
3850
+ Nr as PageContentIteratorPDF,
3851
+ wt as Price,
3852
+ B as Profile,
3853
+ A as Properties,
3854
+ C as Publication,
3855
+ z as PublicationCollection,
3856
+ Or as PublicationContentIterator,
3857
+ O as ReadingProgression,
3858
+ Ir as Resource,
3859
+ Q as Subject,
3860
+ Et as Subjects,
3861
+ bt as TDM,
3862
+ Le as TDMReservation,
3863
+ zr as TextContentTokenizer,
3864
+ ut as TextElement,
3865
+ ui as TextQuote,
3866
+ Ht as TextSegment,
3867
+ je as TextUnit,
3868
+ it as TextualElement,
3869
+ Z as URITemplate,
3870
+ oi as VideoElement,
3871
+ Pe as arrayfromJSON,
3872
+ N as arrayfromJSONorString,
3873
+ K as datefromJSON,
3874
+ Sr as leadingPage,
3875
+ L as numberfromJSON,
3876
+ b as positiveNumberfromJSON,
3877
+ q as setToArray,
3878
+ Mt as speakableToken
3775
3879
  };