@readium/navigator-html-injectables 2.2.4 → 2.3.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 (41) hide show
  1. package/dist/ar-DyHX_uy2.js +7 -0
  2. package/dist/da-Dct0PS3E.js +7 -0
  3. package/dist/fr-C5HEel98.js +7 -0
  4. package/dist/index.js +2121 -1352
  5. package/dist/index.umd.cjs +24 -10
  6. package/dist/it-DFOBoXGy.js +7 -0
  7. package/dist/pt_PT-Di3sVjze.js +7 -0
  8. package/dist/sv-BfzAFsVN.js +7 -0
  9. package/package.json +4 -2
  10. package/src/comms/keys.ts +22 -3
  11. package/src/index.ts +2 -1
  12. package/src/modules/ModuleLibrary.ts +10 -4
  13. package/src/modules/Peripherals.ts +458 -13
  14. package/src/modules/snapper/ColumnSnapper.ts +63 -2
  15. package/src/modules/snapper/ScrollSnapper.ts +59 -1
  16. package/src/modules/snapper/WebPubSnapper.ts +57 -3
  17. package/src/protection/BulkCopyProtector.ts +134 -0
  18. package/src/protection/KeyCombinationManager.ts +139 -0
  19. package/src/protection/KeyboardCombinations.ts +60 -0
  20. package/src/protection/PatternAnalyzer.ts +117 -0
  21. package/src/protection/PrintProtector.ts +87 -0
  22. package/src/protection/SelectionAnalyzer.ts +133 -0
  23. package/src/protection/config.ts +33 -0
  24. package/src/protection/index.ts +6 -0
  25. package/types/src/comms/keys.d.ts +3 -2
  26. package/types/src/index.d.ts +1 -0
  27. package/types/src/modules/ModuleLibrary.d.ts +1 -1
  28. package/types/src/modules/Peripherals.d.ts +102 -2
  29. package/types/src/modules/snapper/ColumnSnapper.d.ts +10 -0
  30. package/types/src/modules/snapper/ScrollSnapper.d.ts +13 -0
  31. package/types/src/modules/snapper/WebPubSnapper.d.ts +6 -0
  32. package/types/src/protection/BulkCopyProtector.d.ts +20 -0
  33. package/types/src/protection/KeyCombinationManager.d.ts +33 -0
  34. package/types/src/protection/KeyboardCombinations.d.ts +15 -0
  35. package/types/src/protection/PatternAnalyzer.d.ts +18 -0
  36. package/types/src/protection/PrintProtector.d.ts +20 -0
  37. package/types/src/protection/SelectionAnalyzer.d.ts +20 -0
  38. package/types/src/protection/config.d.ts +7 -0
  39. package/types/src/protection/index.d.ts +6 -0
  40. package/src/types/protection.ts +0 -16
  41. package/types/src/types/protection.d.ts +0 -7
package/dist/index.js CHANGED
@@ -1,66 +1,66 @@
1
- const dt = Math.pow(2, 32), Le = () => Math.round(Math.random() * dt).toString(36), pt = () => `${Math.round(performance.now())}-${Le()}-${Le()}`, k = 1;
2
- class ft {
3
- constructor(e) {
4
- this.destination = null, this.registrar = /* @__PURE__ */ new Map(), this.origin = "", this.channelId = "", this.receiver = this.receive.bind(this), this.preLog = [], this.wnd = e, e.addEventListener("message", this.receiver);
5
- }
6
- receive(e) {
7
- if (e.source === null) throw Error("Event source is null");
8
- if (typeof e.data != "object") return;
9
- const t = e.data;
10
- if (!(!("_readium" in t) || !t._readium || t._readium <= 0)) {
11
- if (t.key === "_ping") {
1
+ const Ie = Math.pow(2, 32), Ht = () => Math.round(Math.random() * Ie).toString(36), De = () => `${Math.round(performance.now())}-${Ht()}-${Ht()}`, K = 1;
2
+ class ze {
3
+ constructor(t) {
4
+ this.destination = null, this.registrar = /* @__PURE__ */ new Map(), this.origin = "", this.channelId = "", this.receiver = this.receive.bind(this), this.preLog = [], this.wnd = t, t.addEventListener("message", this.receiver);
5
+ }
6
+ receive(t) {
7
+ if (t.source === null) throw Error("Event source is null");
8
+ if (typeof t.data != "object") return;
9
+ const e = t.data;
10
+ if (!(!("_readium" in e) || !e._readium || e._readium <= 0)) {
11
+ if (e.key === "_ping") {
12
12
  if (!this.destination) {
13
- if (this.destination = e.source, this.origin = e.origin, this.channelId = t._channel, t._readium !== k) {
14
- t._readium > k ? this.send("error", `received comms version ${t._readium} higher than ${k}`) : this.send("error", `received comms version ${t._readium} lower than ${k}`), this.destination = null, this.origin = "", this.channelId = "";
13
+ if (this.destination = t.source, this.origin = t.origin, this.channelId = e._channel, e._readium !== K) {
14
+ e._readium > K ? this.send("error", `received comms version ${e._readium} higher than ${K}`) : this.send("error", `received comms version ${e._readium} lower than ${K}`), this.destination = null, this.origin = "", this.channelId = "";
15
15
  return;
16
16
  }
17
17
  this.send("_pong", void 0), this.preLog.forEach((i) => this.send("log", i)), this.preLog = [];
18
18
  }
19
19
  return;
20
20
  } else if (this.channelId) {
21
- if (t._channel !== this.channelId || e.origin !== this.origin) return;
21
+ if (e._channel !== this.channelId || t.origin !== this.origin) return;
22
22
  } else
23
23
  return;
24
- this.handle(t);
24
+ this.handle(e);
25
25
  }
26
26
  }
27
- handle(e) {
28
- const t = this.registrar.get(e.key);
29
- if (!t || t.length === 0) {
30
- e.strict && this.send("_unhandled", e);
27
+ handle(t) {
28
+ const e = this.registrar.get(t.key);
29
+ if (!e || e.length === 0) {
30
+ t.strict && this.send("_unhandled", t);
31
31
  return;
32
32
  }
33
- t.forEach((i) => i.cb(e.data, (r) => {
34
- this.send("_ack", r, e.id);
33
+ e.forEach((i) => i.cb(t.data, (s) => {
34
+ this.send("_ack", s, t.id);
35
35
  }));
36
36
  }
37
- register(e, t, i) {
38
- Array.isArray(e) || (e = [e]), e.forEach((r) => {
39
- const n = this.registrar.get(r);
37
+ register(t, e, i) {
38
+ Array.isArray(t) || (t = [t]), t.forEach((s) => {
39
+ const n = this.registrar.get(s);
40
40
  if (n && n.length >= 0) {
41
- if (n.find((a) => a.module === t)) throw new Error(`Trying to register another callback for combination of event ${r} and module ${t}`);
41
+ if (n.find((a) => a.module === e)) throw new Error(`Trying to register another callback for combination of event ${s} and module ${e}`);
42
42
  n.push({
43
43
  cb: i,
44
- module: t
45
- }), this.registrar.set(r, n);
44
+ module: e
45
+ }), this.registrar.set(s, n);
46
46
  } else
47
- this.registrar.set(r, [{
47
+ this.registrar.set(s, [{
48
48
  cb: i,
49
- module: t
49
+ module: e
50
50
  }]);
51
51
  });
52
52
  }
53
- unregister(e, t) {
54
- Array.isArray(e) || (e = [e]), e.forEach((i) => {
55
- const r = this.registrar.get(i);
56
- !r || r.length === 0 || r.splice(r.findIndex((n) => n.module === t), 1);
53
+ unregister(t, e) {
54
+ Array.isArray(t) || (t = [t]), t.forEach((i) => {
55
+ const s = this.registrar.get(i);
56
+ !s || s.length === 0 || s.splice(s.findIndex((n) => n.module === e), 1);
57
57
  });
58
58
  }
59
- unregisterAll(e) {
60
- this.registrar.forEach((t, i) => this.registrar.set(i, t.filter((r) => r.module !== e)));
59
+ unregisterAll(t) {
60
+ this.registrar.forEach((e, i) => this.registrar.set(i, e.filter((s) => s.module !== t)));
61
61
  }
62
- log(...e) {
63
- this.destination ? this.send("log", e) : this.preLog.push(e);
62
+ log(...t) {
63
+ this.destination ? this.send("log", t) : this.preLog.push(t);
64
64
  }
65
65
  get ready() {
66
66
  return !!this.destination;
@@ -68,53 +68,111 @@ class ft {
68
68
  destroy() {
69
69
  this.destination = null, this.channelId = "", this.preLog = [], this.registrar.clear(), this.wnd.removeEventListener("message", this.receiver);
70
70
  }
71
- send(e, t, i = void 0, r = []) {
71
+ send(t, e, i = void 0, s = []) {
72
72
  if (!this.destination) throw Error("Attempted to send comms message before destination has been initialized");
73
73
  const n = {
74
- _readium: k,
74
+ _readium: K,
75
75
  _channel: this.channelId,
76
- id: i ?? pt(),
76
+ id: i ?? De(),
77
77
  // scrict,
78
- key: e,
79
- data: t
78
+ key: t,
79
+ data: e
80
80
  };
81
81
  try {
82
82
  this.destination.postMessage(n, {
83
83
  targetOrigin: this.origin,
84
- transfer: r
84
+ transfer: s
85
85
  });
86
86
  } catch (o) {
87
- if (r.length > 0) throw o;
88
- this.destination.postMessage(n, this.origin, r);
87
+ if (s.length > 0) throw o;
88
+ this.destination.postMessage(n, this.origin, s);
89
89
  }
90
90
  }
91
91
  }
92
- const N = class U {
93
- constructor(e) {
94
- if (typeof e == "string") {
95
- if (!U.VALID_MODES.has(e.toLowerCase()))
92
+ const y = class y {
93
+ constructor(t) {
94
+ this.uri = t;
95
+ }
96
+ /**
97
+ * Parses an [AccessibilityProfile] from its RWPM JSON representation.
98
+ */
99
+ static deserialize(t) {
100
+ if (!(!t || typeof t != "string"))
101
+ return new y(t);
102
+ }
103
+ /**
104
+ * Serializes an [AccessibilityProfile] to its RWPM JSON representation.
105
+ */
106
+ serialize() {
107
+ return this.uri;
108
+ }
109
+ /**
110
+ * Returns true if the profile is a WCAG Level A profile.
111
+ */
112
+ get isWCAGLevelA() {
113
+ return this === y.EPUB_A11Y_10_WCAG_20_A || this === y.EPUB_A11Y_11_WCAG_20_A || this === y.EPUB_A11Y_11_WCAG_21_A || this === y.EPUB_A11Y_11_WCAG_22_A;
114
+ }
115
+ /**
116
+ * Returns true if the profile is a WCAG Level AA profile.
117
+ */
118
+ get isWCAGLevelAA() {
119
+ return this === y.EPUB_A11Y_10_WCAG_20_AA || this === y.EPUB_A11Y_11_WCAG_20_AA || this === y.EPUB_A11Y_11_WCAG_21_AA || this === y.EPUB_A11Y_11_WCAG_22_AA;
120
+ }
121
+ /**
122
+ * Returns true if the profile is a WCAG Level AAA profile.
123
+ */
124
+ get isWCAGLevelAAA() {
125
+ return this === y.EPUB_A11Y_10_WCAG_20_AAA || this === y.EPUB_A11Y_11_WCAG_20_AAA || this === y.EPUB_A11Y_11_WCAG_21_AAA || this === y.EPUB_A11Y_11_WCAG_22_AAA;
126
+ }
127
+ };
128
+ y.EPUB_A11Y_10_WCAG_20_A = new y("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-a"), y.EPUB_A11Y_10_WCAG_20_AA = new y("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aa"), y.EPUB_A11Y_10_WCAG_20_AAA = new y("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aaa"), y.EPUB_A11Y_11_WCAG_20_A = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-a"), y.EPUB_A11Y_11_WCAG_20_AA = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-aa"), y.EPUB_A11Y_11_WCAG_20_AAA = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-aaa"), y.EPUB_A11Y_11_WCAG_21_A = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-a"), y.EPUB_A11Y_11_WCAG_21_AA = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-aa"), y.EPUB_A11Y_11_WCAG_21_AAA = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-aaa"), y.EPUB_A11Y_11_WCAG_22_A = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-a"), y.EPUB_A11Y_11_WCAG_22_AA = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-aa"), y.EPUB_A11Y_11_WCAG_22_AAA = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-aaa");
129
+ let _t = y;
130
+ const w = class w {
131
+ constructor(t) {
132
+ this.value = t;
133
+ }
134
+ /**
135
+ * Parses an [AccessMode] from its RWPM JSON representation.
136
+ */
137
+ static deserialize(t) {
138
+ if (!(!t || typeof t != "string"))
139
+ return new w(t);
140
+ }
141
+ /**
142
+ * Serializes an [AccessMode] to its RWPM JSON representation.
143
+ */
144
+ serialize() {
145
+ return this.value;
146
+ }
147
+ };
148
+ w.AUDITORY = new w("auditory"), w.CHART_ON_VISUAL = new w("chartOnVisual"), w.CHEM_ON_VISUAL = new w("chemOnVisual"), w.COLOR_DEPENDENT = new w("colorDependent"), w.DIAGRAM_ON_VISUAL = new w("diagramOnVisual"), w.MATH_ON_VISUAL = new w("mathOnVisual"), w.MUSIC_ON_VISUAL = new w("musicOnVisual"), w.TACTILE = new w("tactile"), w.TEXT_ON_VISUAL = new w("textOnVisual"), w.TEXTUAL = new w("textual"), w.VISUAL = new w("visual");
149
+ let Vt = w;
150
+ const T = class T {
151
+ constructor(t) {
152
+ if (typeof t == "string") {
153
+ if (!T.VALID_MODES.has(t.toLowerCase()))
96
154
  return;
97
- this.value = e.toLowerCase();
155
+ this.value = t.toLowerCase();
98
156
  } else {
99
- const t = e.filter(
100
- (i) => U.VALID_MODES.has(i.toLowerCase())
157
+ const e = t.filter(
158
+ (i) => T.VALID_MODES.has(i.toLowerCase())
101
159
  );
102
- if (t.length === 0)
160
+ if (e.length === 0)
103
161
  return;
104
- this.value = Array.from(new Set(t));
162
+ this.value = Array.from(new Set(e));
105
163
  }
106
164
  }
107
165
  /**
108
166
  * Parses a [PrimaryAccessMode] from its RWPM JSON representation.
109
167
  */
110
- static deserialize(e) {
111
- if (!e) return;
112
- if (typeof e == "string")
113
- return new U(e);
114
- if (!Array.isArray(e)) return;
115
- const t = e.filter((i) => i ? U.VALID_MODES.has(i.toLowerCase()) : !1);
116
- if (t.length !== 0)
117
- return new U(t);
168
+ static deserialize(t) {
169
+ if (!t) return;
170
+ if (typeof t == "string")
171
+ return new T(t);
172
+ if (!Array.isArray(t)) return;
173
+ const e = t.filter((i) => i ? T.VALID_MODES.has(i.toLowerCase()) : !1);
174
+ if (e.length !== 0)
175
+ return new T(e);
118
176
  }
119
177
  /**
120
178
  * Serializes a [PrimaryAccessMode] to its RWPM JSON representation.
@@ -123,38 +181,190 @@ const N = class U {
123
181
  return this.value;
124
182
  }
125
183
  };
126
- N.VALID_MODES = /* @__PURE__ */ new Set(["auditory", "tactile", "textual", "visual"]), N.AUDITORY = new N("auditory"), N.TACTILE = new N("tactile"), N.TEXTUAL = new N("textual"), N.VISUAL = new N("visual");
127
- class Te {
184
+ T.VALID_MODES = /* @__PURE__ */ new Set(["auditory", "tactile", "textual", "visual"]), T.AUDITORY = new T("auditory"), T.TACTILE = new T("tactile"), T.TEXTUAL = new T("textual"), T.VISUAL = new T("visual");
185
+ let Gt = T;
186
+ const c = class c {
187
+ constructor(t) {
188
+ this.value = t;
189
+ }
190
+ /**
191
+ * Parses a [Feature] from its RWPM JSON representation.
192
+ */
193
+ static deserialize(t) {
194
+ if (!(!t || typeof t != "string"))
195
+ return new c(t);
196
+ }
197
+ /**
198
+ * Serializes a [Feature] to its RWPM JSON representation.
199
+ */
200
+ serialize() {
201
+ return this.value;
202
+ }
203
+ };
204
+ c.NONE = new c("none"), c.ANNOTATIONS = new c("annotations"), c.ARIA = new c("ARIA"), c.INDEX = new c("index"), c.PAGE_BREAK_MARKERS = new c("pageBreakMarkers"), c.PAGE_NAVIGATION = new c("pageNavigation"), c.PRINT_PAGE_NUMBERS = new c("printPageNumbers"), c.READING_ORDER = new c("readingOrder"), c.STRUCTURAL_NAVIGATION = new c("structuralNavigation"), c.TABLE_OF_CONTENTS = new c("tableOfContents"), c.TAGGED_PDF = new c("taggedPDF"), c.ALTERNATIVE_TEXT = new c("alternativeText"), c.AUDIO_DESCRIPTION = new c("audioDescription"), c.CAPTIONS = new c("captions"), c.CLOSED_CAPTIONS = new c("closedCaptions"), c.DESCRIBED_MATH = new c("describedMath"), c.LONG_DESCRIPTION = new c("longDescription"), c.OPEN_CAPTIONS = new c("openCaptions"), c.SIGN_LANGUAGE = new c("signLanguage"), c.TRANSCRIPT = new c("transcript"), c.DISPLAY_TRANSFORMABILITY = new c("displayTransformability"), c.SYNCHRONIZED_AUDIO_TEXT = new c("synchronizedAudioText"), c.TIMING_CONTROL = new c("timingControl"), c.UNLOCKED = new c("unlocked"), c.CHEM_ML = new c("ChemML"), c.LATEX = new c("latex"), c.LATEX_CHEMISTRY = new c("latex-chemistry"), c.MATH_ML = new c("MathML"), c.MATH_ML_CHEMISTRY = new c("MathML-chemistry"), c.TTS_MARKUP = new c("ttsMarkup"), c.HIGH_CONTRAST_AUDIO = new c("highContrastAudio"), c.HIGH_CONTRAST_DISPLAY = new c("highContrastDisplay"), c.LARGE_PRINT = new c("largePrint"), c.BRAILLE = new c("braille"), c.TACTILE_GRAPHIC = new c("tactileGraphic"), c.TACTILE_OBJECT = new c("tactileObject"), c.FULL_RUBY_ANNOTATIONS = new c("fullRubyAnnotations"), c.HORIZONTAL_WRITING = new c("horizontalWriting"), c.RUBY_ANNOTATIONS = new c("rubyAnnotations"), c.VERTICAL_WRITING = new c("verticalWriting"), c.WITH_ADDITIONAL_WORD_SEGMENTATION = new c("withAdditionalWordSegmentation"), c.WITHOUT_ADDITIONAL_WORD_SEGMENTATION = new c("withoutAdditionalWordSegmentation");
205
+ let Ft = c;
206
+ const S = class S {
207
+ constructor(t) {
208
+ this.value = t;
209
+ }
210
+ /**
211
+ * Parses a [Hazard] from its RWPM JSON representation.
212
+ */
213
+ static deserialize(t) {
214
+ if (!(!t || typeof t != "string"))
215
+ return new S(t);
216
+ }
217
+ /**
218
+ * Serializes a [Hazard] to its RWPM JSON representation.
219
+ */
220
+ serialize() {
221
+ return this.value;
222
+ }
223
+ };
224
+ S.FLASHING = new S("flashing"), S.NO_FLASHING_HAZARD = new S("noFlashingHazard"), S.UNKNOWN_FLASHING_HAZARD = new S("unknownFlashingHazard"), S.MOTION_SIMULATION = new S("motionSimulation"), S.NO_MOTION_SIMULATION_HAZARD = new S("noMotionSimulationHazard"), S.UNKNOWN_MOTION_SIMULATION_HAZARD = new S("unknownMotionSimulationHazard"), S.SOUND = new S("sound"), S.NO_SOUND_HAZARD = new S("noSoundHazard"), S.UNKNOWN_SOUND_HAZARD = new S("unknownSoundHazard"), S.UNKNOWN = new S("unknown"), S.NONE = new S("none");
225
+ let $t = S;
226
+ const E = class E {
227
+ constructor(t) {
228
+ this.value = t;
229
+ }
230
+ /**
231
+ * Parses an [Exemption] from its RWPM JSON representation.
232
+ */
233
+ static deserialize(t) {
234
+ if (!(!t || typeof t != "string"))
235
+ return new E(t);
236
+ }
237
+ /**
238
+ * Serializes an [Exemption] to its RWPM JSON representation.
239
+ */
240
+ serialize() {
241
+ return this.value;
242
+ }
243
+ };
244
+ E.NONE = new E("none"), E.DOCUMENTED = new E("documented"), E.LEGAL = new E("legal"), E.TEMPORARY = new E("temporary"), E.TECHNICAL = new E("technical"), E.EAA_DISPROPORTIONATE_BURDEN = new E("eaa-disproportionate-burden"), E.EAA_FUNDAMENTAL_ALTERATION = new E("eaa-fundamental-alteration"), E.EAA_MICROENTERPRISE = new E("eaa-microenterprise"), E.EAA_TECHNICAL_IMPOSSIBILITY = new E("eaa-technical-impossibility"), E.EAA_TEMPORARY = new E("eaa-temporary");
245
+ let Yt = E;
246
+ const Xt = ["en", "ar", "da", "fr", "it", "pt_PT", "sv"], Me = /* @__PURE__ */ JSON.parse(`{"format":{"audiobook":"Audiobook","audiobookJSON":"Audiobook Manifest","cbz":"Comic Book Archive","divina":"Divina Publication","divinaJSON":"Divina Publication Manifest","epub":"EPUB","lcpa":"LCP Protected Audiobook","lcpdf":"LCP Protected PDF","lcpl":"LCP License Document","pdf":"PDF","rwp":"Readium Web Publication","rwpm":"Readium Web Publication Manifest","zab":"Audiobook Archive","zip":"ZIP Archive"},"kind":{"audiobook_one":"audiobook","audiobook_other":"audiobooks","book_one":"book","book_other":"books","comic_one":"comic","comic_other":"comics","document_one":"document","document_other":"documents"},"metadata":{"accessibility":{"display-guide":{"accessibility-summary":{"no-metadata":"No information is available","publisher-contact":"For more information about the accessibility of this product, please contact the publisher: ","title":"Accessibility summary"},"additional-accessibility-information":{"aria":{"compact":"ARIA roles included","descriptive":"Content is enhanced with ARIA roles to optimize organization and facilitate navigation"},"audio-descriptions":"Audio descriptions","braille":"Braille","color-not-sole-means-of-conveying-information":"Color is not the sole means of conveying information","dyslexia-readability":"Dyslexia readability","full-ruby-annotations":"Full ruby annotations","high-contrast-between-foreground-and-background-audio":"High contrast between foreground and background audio","high-contrast-between-text-and-background":"High contrast between foreground text and background","large-print":"Large print","page-breaks":{"compact":"Page breaks included","descriptive":"Page breaks included from the original print source"},"ruby-annotations":"Some Ruby annotations","sign-language":"Sign language","tactile-graphics":{"compact":"Tactile graphics included","descriptive":"Tactile graphics have been integrated to facilitate access to visual elements for blind people"},"tactile-objects":"Tactile 3D objects","text-to-speech-hinting":"Text-to-speech hinting provided","title":"Additional accessibility information","ultra-high-contrast-between-text-and-background":"Ultra high contrast between text and background","visible-page-numbering":"Visible page numbering","without-background-sounds":"Without background sounds"},"conformance":{"a":{"compact":"This publication meets minimum accessibility standards","descriptive":"The publication contains a conformance statement that it meets the EPUB Accessibility and WCAG 2 Level A standard"},"aa":{"compact":"This publication meets accepted accessibility standards","descriptive":"The publication contains a conformance statement that it meets the EPUB Accessibility and WCAG 2 Level AA standard"},"aaa":{"compact":"This publication exceeds accepted accessibility standards","descriptive":"The publication contains a conformance statement that it meets the EPUB Accessibility and WCAG 2 Level AAA standard"},"certifier":"The publication was certified by ","certifier-credentials":"The certifier's credential is ","details":{"certification-info":"The publication was certified on ","certifier-report":"For more information refer to the certifier's report","claim":"This publication claims to meet","epub-accessibility-1-0":"EPUB Accessibility 1.0","epub-accessibility-1-1":"EPUB Accessibility 1.1","level-a":"Level A","level-aa":"Level AA","level-aaa":"Level AAA","wcag-2-0":{"compact":"WCAG 2.0","descriptive":"Web Content Accessibility Guidelines (WCAG) 2.0"},"wcag-2-1":{"compact":"WCAG 2.1","descriptive":"Web Content Accessibility Guidelines (WCAG) 2.1"},"wcag-2-2":{"compact":"WCAG 2.2","descriptive":"Web Content Accessibility Guidelines (WCAG) 2.2"}},"details-title":"Detailed conformance information","no":"No information is available","title":"Conformance","unknown-standard":"Conformance to accepted standards for accessibility of this publication cannot be determined"},"hazards":{"flashing":{"compact":"Flashing content","descriptive":"The publication contains flashing content that can cause photosensitive seizures"},"flashing-none":{"compact":"No flashing hazards","descriptive":"The publication does not contain flashing content that can cause photosensitive seizures"},"flashing-unknown":{"compact":"Flashing hazards not known","descriptive":"The presence of flashing content that can cause photosensitive seizures could not be determined"},"motion":{"compact":"Motion simulation","descriptive":"The publication contains motion simulations that can cause motion sickness"},"motion-none":{"compact":"No motion simulation hazards","descriptive":"The publication does not contain motion simulations that can cause motion sickness"},"motion-unknown":{"compact":"Motion simulation hazards not known","descriptive":"The presence of motion simulations that can cause motion sickness could not be determined"},"no-metadata":"No information is available","none":{"compact":"No hazards","descriptive":"The publication contains no hazards"},"sound":{"compact":"Sounds","descriptive":"The publication contains sounds that can cause sensitivity issues"},"sound-none":{"compact":"No sound hazards","descriptive":"The publication does not contain sounds that can cause sensitivity issues"},"sound-unknown":{"compact":"Sound hazards not known","descriptive":"The presence of sounds that can cause sensitivity issues could not be determined"},"title":"Hazards","unknown":"The presence of hazards is unknown"},"legal-considerations":{"exempt":{"compact":"Claims an accessibility exemption in some jurisdictions","descriptive":"This publication claims an accessibility exemption in some jurisdictions"},"no-metadata":"No information is available","title":"Legal considerations"},"navigation":{"index":{"compact":"Index","descriptive":"Index with links to referenced entries"},"no-metadata":"No information is available","page-navigation":{"compact":"Go to page","descriptive":"Page list to go to pages from the print source version"},"structural":{"compact":"Headings","descriptive":"Elements such as headings, tables, etc for structured navigation"},"title":"Navigation","toc":{"compact":"Table of contents","descriptive":"Table of contents to all chapters of the text via links"}},"rich-content":{"accessible-chemistry-as-latex":{"compact":"Chemical formulas in LaTeX","descriptive":"Chemical formulas in accessible format (LaTeX)"},"accessible-chemistry-as-mathml":{"compact":"Chemical formulas in MathML","descriptive":"Chemical formulas in accessible format (MathML)"},"accessible-math-as-latex":{"compact":"Math as LaTeX","descriptive":"Math formulas in accessible format (LaTeX)"},"accessible-math-described":"Text descriptions of math are provided","closed-captions":{"compact":"Videos have closed captions","descriptive":"Videos included in publications have closed captions"},"extended-descriptions":"Information-rich images are described by extended descriptions","math-as-mathml":{"compact":"Math as MathML","descriptive":"Math formulas in accessible format (MathML)"},"open-captions":{"compact":"Videos have open captions","descriptive":"Videos included in publications have open captions"},"title":"Rich content","transcript":"Transcript(s) provided","unknown":"No information is available"},"ways-of-reading":{"nonvisual-reading":{"alt-text":{"compact":"Has alternative text","descriptive":"Has alternative text descriptions for images"},"no-metadata":"No information about nonvisual reading is available","none":{"compact":"Not readable in read aloud or dynamic braille","descriptive":"The content is not readable as read aloud speech or dynamic braille"},"not-fully":{"compact":"Not fully readable in read aloud or dynamic braille","descriptive":"Not all of the content will be readable as read aloud speech or dynamic braille"},"readable":{"compact":"Readable in read aloud or dynamic braille","descriptive":"All content can be read as read aloud speech or dynamic braille"}},"prerecorded-audio":{"complementary":{"compact":"Prerecorded audio clips","descriptive":"Prerecorded audio clips are embedded in the content"},"no-metadata":"No information about prerecorded audio is available","only":{"compact":"Prerecorded audio only","descriptive":"Audiobook with no text alternative"},"synchronized":{"compact":"Prerecorded audio synchronized with text","descriptive":"All the content is available as prerecorded audio synchronized with text"}},"title":"Ways of reading","visual-adjustments":{"modifiable":{"compact":"Appearance can be modified","descriptive":"Appearance of the text and page layout can be modified according to the capabilities of the reading system (font family and font size, spaces between paragraphs, sentences, words, and letters, as well as color of background and text)"},"unknown":"No information about appearance modifiability is available","unmodifiable":{"compact":"Appearance cannot be modified","descriptive":"Text and page layout cannot be modified as the reading experience is close to a print version, but reading systems can still provide zooming options"}}}}},"altIdentifier_one":"alternate identifier","altIdentifier_other":"alternate identifiers","artist_one":"artist","artist_other":"artists","author_one":"author","author_other":"authors","collection_one":"editorial collection","collection_other":"editorial collections","colorist_one":"colorist","colorist_other":"colorists","contributor_one":"contributor","contributor_other":"contributors","description":"description","duration":"duration","editor_one":"editor","editor_other":"editors","identifier_one":"identifier","identifier_other":"identifiers","illustrator_one":"illustrator","illustrator_other":"illustrators","imprint_one":"imprint","imprint_other":"imprints","inker_one":"inker","inker_other":"inkers","language_one":"language","language_other":"languages","letterer_one":"letterer","letterer_other":"letterers","modified":"modification date","narrator_one":"narrator","narrator_other":"narrators","numberOfPages":"print length","penciler_one":"penciler","penciler_other":"pencilers","published":"publication date","publisher_one":"publisher","publisher_other":"publishers","series_one":"series","series_other":"series","subject_one":"subject","subject_other":"subjects","subtitle":"subtitle","title":"title","translator_one":"translator","translator_other":"translators"}}`), ke = {
247
+ publication: Me
248
+ }, qt = {
249
+ fr: () => import("./fr-C5HEel98.js"),
250
+ ar: () => import("./ar-DyHX_uy2.js"),
251
+ da: () => import("./da-Dct0PS3E.js"),
252
+ // 'el': () => import('@edrlab/thorium-locales/publication-metadata/el.json'),
253
+ // 'et': () => import('@edrlab/thorium-locales/publication-metadata/et.json'),
254
+ it: () => import("./it-DFOBoXGy.js"),
255
+ pt_PT: () => import("./pt_PT-Di3sVjze.js"),
256
+ sv: () => import("./sv-BfzAFsVN.js")
257
+ // 'tr': () => import('@edrlab/thorium-locales/publication-metadata/tr.json'),
258
+ // 'uk': () => import('@edrlab/thorium-locales/publication-metadata/uk.json')
259
+ }, Kt = ke?.publication?.metadata?.accessibility?.["display-guide"] || {};
260
+ class F {
261
+ constructor() {
262
+ this.currentLocaleCode = "en", this.locale = Kt, this.loadedLocales = {}, this.loadedLocales.en = Kt;
263
+ }
264
+ static getInstance() {
265
+ return F.instance || (F.instance = new F()), F.instance;
266
+ }
267
+ /**
268
+ * Loads a locale dynamically
269
+ * @param localeCode BCP 47 language code (e.g., 'en', 'fr')
270
+ * @returns Promise indicating if the locale was loaded successfully
271
+ */
272
+ async loadLocale(t) {
273
+ if (!Xt.includes(t))
274
+ return console.warn(`Locale '${t}' is not enabled`), !1;
275
+ if (t in this.loadedLocales)
276
+ return !0;
277
+ try {
278
+ if (!(t in qt))
279
+ return console.warn(`Locale file not found for: ${t}`), !1;
280
+ const s = (await qt[t]()).default?.publication?.metadata?.accessibility?.["display-guide"];
281
+ return s ? (this.loadedLocales[t] = s, !0) : (console.warn(`No accessibility strings found in locale ${t}`), !1);
282
+ } catch (e) {
283
+ return console.warn(`Failed to load locale ${t}:`, e), !1;
284
+ }
285
+ }
286
+ /**
287
+ * Registers a new locale or updates an existing one
288
+ * @param localeCode BCP 47 language code (e.g., 'en', 'fr-FR')
289
+ * @param localeData The locale data to register
290
+ */
291
+ registerLocale(t, e) {
292
+ if (!t || typeof t != "string")
293
+ throw new Error("Locale code must be a non-empty string");
294
+ this.loadedLocales[t] = e;
295
+ }
296
+ /**
297
+ * Sets the current locale by language code, loading it dynamically if needed
298
+ * @param localeCode BCP 47 language code (e.g., 'en', 'fr')
299
+ * @returns Promise indicating if the locale was set successfully
300
+ */
301
+ async setLocale(t) {
302
+ return t in this.loadedLocales || await this.loadLocale(t), t in this.loadedLocales ? (this.locale = this.loadedLocales[t], this.currentLocaleCode = t, !0) : (console.warn(`Locale '${t}' is not available`), !1);
303
+ }
304
+ /**
305
+ * Gets the current locale code (BCP 47)
306
+ */
307
+ getCurrentLocale() {
308
+ return this.currentLocaleCode;
309
+ }
310
+ /**
311
+ * Gets a list of available locale codes
312
+ */
313
+ getAvailableLocales() {
314
+ return Xt;
315
+ }
316
+ getNestedValue(t, e) {
317
+ const i = e.split(".");
318
+ let s = t;
319
+ for (const n of i) {
320
+ if (s == null)
321
+ return;
322
+ s = s[n];
323
+ }
324
+ return s;
325
+ }
326
+ /**
327
+ * Gets a localized string by key
328
+ * @param key The key for the string to retrieve
329
+ * @returns The localized string as a [L10nString], or an empty string if not found
330
+ */
331
+ getString(t) {
332
+ let e = this.getNestedValue(this.locale, t);
333
+ return e === void 0 && this.currentLocaleCode !== "en" && (e = this.getNestedValue(this.loadedLocales.en, t)), e !== void 0 ? typeof e == "string" ? { compact: e, descriptive: e } : e : (console.warn(`Missing localization for key: ${t}`), { compact: "", descriptive: "" });
334
+ }
335
+ }
336
+ F.getInstance();
337
+ class Rt {
128
338
  /**
129
339
  * Creates a [Encryption].
130
340
  */
131
- constructor(e) {
132
- this.algorithm = e.algorithm, this.compression = e.compression, this.originalLength = e.originalLength, this.profile = e.profile, this.scheme = e.scheme;
341
+ constructor(t) {
342
+ this.algorithm = t.algorithm, this.compression = t.compression, this.originalLength = t.originalLength, this.profile = t.profile, this.scheme = t.scheme;
133
343
  }
134
344
  /**
135
345
  * Parses a [Encryption] from its RWPM JSON representation.
136
346
  */
137
- static deserialize(e) {
138
- if (e && e.algorithm)
139
- return new Te({
140
- algorithm: e.algorithm,
141
- compression: e.compression,
142
- originalLength: e.originalLength,
143
- profile: e.profile,
144
- scheme: e.scheme
347
+ static deserialize(t) {
348
+ if (t && t.algorithm)
349
+ return new Rt({
350
+ algorithm: t.algorithm,
351
+ compression: t.compression,
352
+ originalLength: t.originalLength,
353
+ profile: t.profile,
354
+ scheme: t.scheme
145
355
  });
146
356
  }
147
357
  /**
148
358
  * Serializes a [Encryption] to its RWPM JSON representation.
149
359
  */
150
360
  serialize() {
151
- const e = { algorithm: this.algorithm };
152
- return this.compression !== void 0 && (e.compression = this.compression), this.originalLength !== void 0 && (e.originalLength = this.originalLength), this.profile !== void 0 && (e.profile = this.profile), this.scheme !== void 0 && (e.scheme = this.scheme), e;
361
+ const t = { algorithm: this.algorithm };
362
+ 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;
153
363
  }
154
364
  }
155
- class C {
156
- constructor(e) {
157
- this.otherProperties = e;
365
+ class R {
366
+ constructor(t) {
367
+ this.otherProperties = t;
158
368
  }
159
369
  get page() {
160
370
  return this.otherProperties.page;
@@ -162,9 +372,9 @@ class C {
162
372
  /**
163
373
  * Creates a [Properties] from its RWPM JSON representation.
164
374
  */
165
- static deserialize(e) {
166
- if (e)
167
- return new C(e);
375
+ static deserialize(t) {
376
+ if (t)
377
+ return new R(t);
168
378
  }
169
379
  /**
170
380
  * Serializes a [Properties] to its RWPM JSON representation.
@@ -175,75 +385,75 @@ class C {
175
385
  /**
176
386
  * Makes a copy of this [Properties] after merging in the given additional other [properties].
177
387
  */
178
- add(e) {
179
- const t = Object.assign({}, this.otherProperties);
180
- for (const i in e)
181
- t[i] = e[i];
182
- return new C(t);
388
+ add(t) {
389
+ const e = Object.assign({}, this.otherProperties);
390
+ for (const i in t)
391
+ e[i] = t[i];
392
+ return new R(e);
183
393
  }
184
394
  }
185
- Object.defineProperty(C.prototype, "encryption", {
395
+ Object.defineProperty(R.prototype, "encryption", {
186
396
  get: function() {
187
- return Te.deserialize(this.otherProperties.encrypted);
397
+ return Rt.deserialize(this.otherProperties.encrypted);
188
398
  }
189
399
  });
190
- function mt(s) {
191
- return s && Array.isArray(s) ? s : void 0;
400
+ function We(r) {
401
+ return r && Array.isArray(r) ? r : void 0;
192
402
  }
193
- function Qe(s) {
194
- return s && typeof s == "string" ? [s] : mt(s);
403
+ function ye(r) {
404
+ return r && typeof r == "string" ? [r] : We(r);
195
405
  }
196
- function Re(s) {
197
- return typeof s == "string" ? new Date(s) : void 0;
406
+ function Zt(r) {
407
+ return typeof r == "string" ? new Date(r) : void 0;
198
408
  }
199
- function Q(s) {
200
- return isNaN(s) ? void 0 : s;
409
+ function at(r) {
410
+ return isNaN(r) ? void 0 : r;
201
411
  }
202
- function S(s) {
203
- return Q(s) !== void 0 && Math.sign(s) >= 0 ? s : void 0;
412
+ function O(r) {
413
+ return at(r) !== void 0 && Math.sign(r) >= 0 ? r : void 0;
204
414
  }
205
- function gt(s) {
206
- const e = new Array();
207
- return s.forEach((t) => e.push(t)), e;
415
+ function Ue(r) {
416
+ const t = new Array();
417
+ return r.forEach((e) => t.push(e)), t;
208
418
  }
209
419
  class l {
210
420
  /** Creates a MediaType object. */
211
- constructor(e) {
212
- let t, i, r = e.mediaType.replace(/\s/g, "").split(";");
213
- const n = r[0].split("/");
421
+ constructor(t) {
422
+ let e, i, s = t.mediaType.replace(/\s/g, "").split(";");
423
+ const n = s[0].split("/");
214
424
  if (n.length === 2) {
215
- if (t = n[0].toLowerCase().trim(), i = n[1].toLowerCase().trim(), t.length === 0 || i.length === 0)
425
+ if (e = n[0].toLowerCase().trim(), i = n[1].toLowerCase().trim(), e.length === 0 || i.length === 0)
216
426
  throw new Error("Invalid media type");
217
427
  } else
218
428
  throw new Error("Invalid media type");
219
429
  const o = {};
220
- for (let d = 1; d < r.length; d++) {
221
- const y = r[d].split("=");
222
- if (y.length === 2) {
223
- const p = y[0].toLocaleLowerCase(), f = p === "charset" ? y[1].toUpperCase() : y[1];
224
- o[p] = f;
430
+ for (let m = 1; m < s.length; m++) {
431
+ const v = s[m].split("=");
432
+ if (v.length === 2) {
433
+ const f = v[0].toLocaleLowerCase(), p = f === "charset" ? v[1].toUpperCase() : v[1];
434
+ o[f] = p;
225
435
  }
226
436
  }
227
- const a = {}, u = Object.keys(o);
228
- u.sort((d, y) => d.localeCompare(y)), u.forEach((d) => a[d] = o[d]);
437
+ const a = {}, d = Object.keys(o);
438
+ d.sort((m, v) => m.localeCompare(v)), d.forEach((m) => a[m] = o[m]);
229
439
  let h = "";
230
- for (const d in a) {
231
- const y = a[d];
232
- h += `;${d}=${y}`;
440
+ for (const m in a) {
441
+ const v = a[m];
442
+ h += `;${m}=${v}`;
233
443
  }
234
- const c = `${t}/${i}${h}`, m = a.encoding;
235
- this.string = c, this.type = t, this.subtype = i, this.parameters = a, this.encoding = m, this.name = e.name, this.fileExtension = e.fileExtension;
444
+ const u = `${e}/${i}${h}`, g = a.encoding;
445
+ this.string = u, this.type = e, this.subtype = i, this.parameters = a, this.encoding = g, this.name = t.name, this.fileExtension = t.fileExtension;
236
446
  }
237
- static parse(e) {
238
- return new l(e);
447
+ static parse(t) {
448
+ return new l(t);
239
449
  }
240
450
  /** Structured syntax suffix, e.g. `+zip` in `application/epub+zip`.
241
451
  * Gives a hint on the underlying structure of this media type.
242
452
  * See. https://tools.ietf.org/html/rfc6838#section-4.2.8
243
453
  */
244
454
  get structuredSyntaxSuffix() {
245
- const e = this.subtype.split("+");
246
- return e.length > 1 ? `+${e[e.length - 1]}` : void 0;
455
+ const t = this.subtype.split("+");
456
+ return t.length > 1 ? `+${t[t.length - 1]}` : void 0;
247
457
  }
248
458
  /** Parameter values might or might not be case-sensitive, depending on the semantics of
249
459
  * the parameter name.
@@ -264,17 +474,17 @@ class l {
264
474
  * - Order of parameters is ignored.
265
475
  * - Wildcards are supported, meaning that `image/*` contains `image/png`
266
476
  */
267
- contains(e) {
268
- const t = typeof e == "string" ? l.parse({ mediaType: e }) : e;
269
- if (!((this.type === "*" || this.type === t.type) && (this.subtype === "*" || this.subtype === t.subtype)))
477
+ contains(t) {
478
+ const e = typeof t == "string" ? l.parse({ mediaType: t }) : t;
479
+ if (!((this.type === "*" || this.type === e.type) && (this.subtype === "*" || this.subtype === e.subtype)))
270
480
  return !1;
271
481
  const i = new Set(
272
482
  Object.entries(this.parameters).map(([n, o]) => `${n}=${o}`)
273
- ), r = new Set(
274
- Object.entries(t.parameters).map(([n, o]) => `${n}=${o}`)
483
+ ), s = new Set(
484
+ Object.entries(e.parameters).map(([n, o]) => `${n}=${o}`)
275
485
  );
276
486
  for (const n of Array.from(i.values()))
277
- if (!r.has(n))
487
+ if (!s.has(n))
278
488
  return !1;
279
489
  return !0;
280
490
  }
@@ -283,22 +493,22 @@ class l {
283
493
  * For example, `text/html` matches `text/html;charset=utf-8`, but `text/html;charset=ascii`
284
494
  * doesn't. This is basically like `contains`, but working in both direction.
285
495
  */
286
- matches(e) {
287
- const t = typeof e == "string" ? l.parse({ mediaType: e }) : e;
288
- return this.contains(t) || t.contains(this);
496
+ matches(t) {
497
+ const e = typeof t == "string" ? l.parse({ mediaType: t }) : t;
498
+ return this.contains(e) || e.contains(this);
289
499
  }
290
500
  /**
291
501
  * Returns whether this media type matches any of the [others] media types.
292
502
  */
293
- matchesAny(...e) {
294
- for (const t of e)
295
- if (this.matches(t))
503
+ matchesAny(...t) {
504
+ for (const e of t)
505
+ if (this.matches(e))
296
506
  return !0;
297
507
  return !1;
298
508
  }
299
509
  /** Checks the MediaType equals another one (comparing their string) */
300
- equals(e) {
301
- return this.string === e.string;
510
+ equals(t) {
511
+ return this.string === t.string;
302
512
  }
303
513
  /** Returns whether this media type is structured as a ZIP archive. */
304
514
  get isZIP() {
@@ -661,60 +871,60 @@ class l {
661
871
  });
662
872
  }
663
873
  }
664
- class Ie {
665
- constructor(e) {
666
- this.uri = e, this.parameters = this.getParameters(e);
874
+ class Jt {
875
+ constructor(t) {
876
+ this.uri = t, this.parameters = this.getParameters(t);
667
877
  }
668
878
  /**
669
879
  * List of URI template parameter keys, if the [Link] is templated.
670
880
  */
671
- getParameters(e) {
672
- const t = /\{\??([^}]+)\}/g, i = e.match(t);
881
+ getParameters(t) {
882
+ const e = /\{\??([^}]+)\}/g, i = t.match(e);
673
883
  return i ? new Set(
674
- i.join(",").replace(t, "$1").split(",").map((r) => r.trim())
884
+ i.join(",").replace(e, "$1").split(",").map((s) => s.trim())
675
885
  ) : /* @__PURE__ */ new Set();
676
886
  }
677
887
  /** Expands the URI by replacing the template variables by the given parameters.
678
888
  * Any extra parameter is appended as query parameters.
679
889
  * See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
680
890
  */
681
- expand(e) {
682
- const t = (r) => r.split(",").map((n) => {
683
- const o = e[n];
891
+ expand(t) {
892
+ const e = (s) => s.split(",").map((n) => {
893
+ const o = t[n];
684
894
  return o ? encodeURIComponent(o) : "";
685
- }).join(","), i = (r) => "?" + r.split(",").map((n) => {
686
- const o = n.split("=")[0], a = e[o];
895
+ }).join(","), i = (s) => "?" + s.split(",").map((n) => {
896
+ const o = n.split("=")[0], a = t[o];
687
897
  return a ? `${o}=${encodeURIComponent(a)}` : "";
688
898
  }).join("&");
689
- return this.uri.replace(/\{(\??)([^}]+)\}/g, (...r) => r[1] ? i(r[2]) : t(r[2]));
899
+ return this.uri.replace(/\{(\??)([^}]+)\}/g, (...s) => s[1] ? i(s[2]) : e(s[2]));
690
900
  }
691
901
  }
692
- class b {
902
+ class C {
693
903
  /**
694
904
  * Creates a [Locations].
695
905
  */
696
- constructor(e) {
697
- this.fragments = e.fragments ? e.fragments : new Array(), this.progression = e.progression, this.totalProgression = e.totalProgression, this.position = e.position, this.otherLocations = e.otherLocations;
906
+ constructor(t) {
907
+ this.fragments = t.fragments ? t.fragments : new Array(), this.progression = t.progression, this.totalProgression = t.totalProgression, this.position = t.position, this.otherLocations = t.otherLocations;
698
908
  }
699
909
  /**
700
910
  * Parses a [Locations] from its RWPM JSON representation.
701
911
  */
702
- static deserialize(e) {
703
- if (!e) return;
704
- const t = Q(e.progression), i = Q(e.totalProgression), r = Q(e.position), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([
912
+ static deserialize(t) {
913
+ if (!t) return;
914
+ const e = at(t.progression), i = at(t.totalProgression), s = at(t.position), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([
705
915
  "fragment",
706
916
  "fragments",
707
917
  "progression",
708
918
  "totalProgression",
709
919
  "position"
710
920
  ]);
711
- return Object.entries(e).forEach(([a, u]) => {
712
- o.has(a) || n.set(a, u);
713
- }), new b({
714
- fragments: Qe(e.fragments || e.fragment),
715
- progression: t !== void 0 && t >= 0 && t <= 1 ? t : void 0,
921
+ return Object.entries(t).forEach(([a, d]) => {
922
+ o.has(a) || n.set(a, d);
923
+ }), new C({
924
+ fragments: ye(t.fragments || t.fragment),
925
+ progression: e !== void 0 && e >= 0 && e <= 1 ? e : void 0,
716
926
  totalProgression: i !== void 0 && i >= 0 && i <= 1 ? i : void 0,
717
- position: r !== void 0 && r > 0 ? r : void 0,
927
+ position: s !== void 0 && s > 0 ? s : void 0,
718
928
  otherLocations: n.size === 0 ? void 0 : n
719
929
  });
720
930
  }
@@ -722,111 +932,111 @@ class b {
722
932
  * Serializes a [Locations] to its RWPM JSON representation.
723
933
  */
724
934
  serialize() {
725
- const e = {};
726
- return this.fragments && (e.fragments = this.fragments), this.progression !== void 0 && (e.progression = this.progression), this.totalProgression !== void 0 && (e.totalProgression = this.totalProgression), this.position !== void 0 && (e.position = this.position), this.otherLocations && this.otherLocations.forEach((t, i) => e[i] = t), e;
935
+ const t = {};
936
+ return this.fragments && (t.fragments = this.fragments), this.progression !== void 0 && (t.progression = this.progression), this.totalProgression !== void 0 && (t.totalProgression = this.totalProgression), this.position !== void 0 && (t.position = this.position), this.otherLocations && this.otherLocations.forEach((e, i) => t[i] = e), t;
727
937
  }
728
938
  }
729
- class D {
939
+ class H {
730
940
  /**
731
941
  * Creates a [Text].
732
942
  */
733
- constructor(e) {
734
- this.after = e.after, this.before = e.before, this.highlight = e.highlight;
943
+ constructor(t) {
944
+ this.after = t.after, this.before = t.before, this.highlight = t.highlight;
735
945
  }
736
946
  /**
737
947
  * Parses a [Locations] from its RWPM JSON representation.
738
948
  */
739
- static deserialize(e) {
740
- if (e)
741
- return new D({
742
- after: e.after,
743
- before: e.before,
744
- highlight: e.highlight
949
+ static deserialize(t) {
950
+ if (t)
951
+ return new H({
952
+ after: t.after,
953
+ before: t.before,
954
+ highlight: t.highlight
745
955
  });
746
956
  }
747
957
  /**
748
958
  * Serializes a [Locations] to its RWPM JSON representation.
749
959
  */
750
960
  serialize() {
751
- const e = {};
752
- return this.after !== void 0 && (e.after = this.after), this.before !== void 0 && (e.before = this.before), this.highlight !== void 0 && (e.highlight = this.highlight), e;
961
+ const t = {};
962
+ 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;
753
963
  }
754
964
  }
755
- class R {
965
+ class W {
756
966
  /**
757
967
  * Creates a [Locator].
758
968
  */
759
- constructor(e) {
760
- this.href = e.href, this.type = e.type, this.title = e.title, this.locations = e.locations ? e.locations : new b({}), this.text = e.text;
969
+ constructor(t) {
970
+ this.href = t.href, this.type = t.type, this.title = t.title, this.locations = t.locations ? t.locations : new C({}), this.text = t.text;
761
971
  }
762
972
  /**
763
973
  * Parses a [Link] from its RWPM JSON representation.
764
974
  */
765
- static deserialize(e) {
766
- if (e && e.href && e.type)
767
- return new R({
768
- href: e.href,
769
- type: e.type,
770
- title: e.title,
771
- locations: b.deserialize(e.locations),
772
- text: D.deserialize(e.text)
975
+ static deserialize(t) {
976
+ if (t && t.href && t.type)
977
+ return new W({
978
+ href: t.href,
979
+ type: t.type,
980
+ title: t.title,
981
+ locations: C.deserialize(t.locations),
982
+ text: H.deserialize(t.text)
773
983
  });
774
984
  }
775
985
  /**
776
986
  * Serializes a [Link] to its RWPM JSON representation.
777
987
  */
778
988
  serialize() {
779
- const e = { href: this.href, type: this.type };
780
- return this.title !== void 0 && (e.title = this.title), this.locations && (e.locations = this.locations.serialize()), this.text && (e.text = this.text.serialize()), e;
989
+ const t = { href: this.href, type: this.type };
990
+ return this.title !== void 0 && (t.title = this.title), this.locations && (t.locations = this.locations.serialize()), this.text && (t.text = this.text.serialize()), t;
781
991
  }
782
992
  /**
783
993
  * Shortcut to get a copy of the [Locator] with different [Locations] sub-properties.
784
994
  */
785
- copyWithLocations(e) {
786
- return new R({
995
+ copyWithLocations(t) {
996
+ return new W({
787
997
  href: this.href,
788
998
  type: this.type,
789
999
  title: this.title,
790
1000
  text: this.text,
791
- locations: new b({ ...this.locations, ...e })
1001
+ locations: new C({ ...this.locations, ...t })
792
1002
  });
793
1003
  }
794
1004
  }
795
- class H {
1005
+ class Y {
796
1006
  /**
797
1007
  * Creates a [Link].
798
1008
  */
799
- constructor(e) {
800
- this.href = e.href, this.templated = e.templated, this.type = e.type, this.title = e.title, this.rels = e.rels, this.properties = e.properties, this.height = e.height, this.width = e.width, this.size = e.size, this.duration = e.duration, this.bitrate = e.bitrate, this.languages = e.languages, this.alternates = e.alternates, this.children = e.children;
1009
+ constructor(t) {
1010
+ 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;
801
1011
  }
802
1012
  /**
803
1013
  * Parses a [Link] from its RWPM JSON representation.
804
1014
  */
805
- static deserialize(e) {
806
- if (!(!e || typeof e.href != "string"))
807
- return new H({
808
- href: e.href,
809
- templated: e.templated,
810
- type: e.type,
811
- title: e.title,
812
- rels: e.rel ? Array.isArray(e.rel) ? new Set(e.rel) : /* @__PURE__ */ new Set([e.rel]) : void 0,
813
- properties: C.deserialize(e.properties),
814
- height: S(e.height),
815
- width: S(e.width),
816
- size: S(e.size),
817
- duration: S(e.duration),
818
- bitrate: S(e.bitrate),
819
- languages: Qe(e.language),
820
- alternates: ee.deserialize(e.alternate),
821
- children: ee.deserialize(e.children)
1015
+ static deserialize(t) {
1016
+ if (!(!t || typeof t.href != "string"))
1017
+ return new Y({
1018
+ href: t.href,
1019
+ templated: t.templated,
1020
+ type: t.type,
1021
+ title: t.title,
1022
+ rels: t.rel ? Array.isArray(t.rel) ? new Set(t.rel) : /* @__PURE__ */ new Set([t.rel]) : void 0,
1023
+ properties: R.deserialize(t.properties),
1024
+ height: O(t.height),
1025
+ width: O(t.width),
1026
+ size: O(t.size),
1027
+ duration: O(t.duration),
1028
+ bitrate: O(t.bitrate),
1029
+ languages: ye(t.language),
1030
+ alternates: lt.deserialize(t.alternate),
1031
+ children: lt.deserialize(t.children)
822
1032
  });
823
1033
  }
824
1034
  /**
825
1035
  * Serializes a [Link] to its RWPM JSON representation.
826
1036
  */
827
1037
  serialize() {
828
- const e = { href: this.href };
829
- return this.templated !== void 0 && (e.templated = this.templated), this.type !== void 0 && (e.type = this.type), this.title !== void 0 && (e.title = this.title), this.rels && (e.rel = gt(this.rels)), this.properties && (e.properties = this.properties.serialize()), this.height !== void 0 && (e.height = this.height), this.width !== void 0 && (e.width = this.width), this.size !== void 0 && (e.size = this.size), this.duration !== void 0 && (e.duration = this.duration), this.bitrate !== void 0 && (e.bitrate = this.bitrate), this.languages && (e.language = this.languages), this.alternates && (e.alternate = this.alternates.serialize()), this.children && (e.children = this.children.serialize()), e;
1038
+ const t = { href: this.href };
1039
+ 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 = Ue(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;
830
1040
  }
831
1041
  /** MediaType of the linked resource. */
832
1042
  get mediaType() {
@@ -835,162 +1045,162 @@ class H {
835
1045
  /** Computes an absolute URL to the link, relative to the given `baseURL`.
836
1046
  * If the link's `href` is already absolute, the `baseURL` is ignored.
837
1047
  */
838
- toURL(e) {
839
- const t = this.href.replace(/^(\/)/, "");
840
- if (t.length === 0) return;
841
- let i = e || "/";
842
- return i.startsWith("/") && (i = "file://" + i), new URL(t, i).href.replace(/^(file:\/\/)/, "");
1048
+ toURL(t) {
1049
+ const e = this.href.replace(/^(\/)/, "");
1050
+ if (e.length === 0) return;
1051
+ let i = t || "/";
1052
+ return i.startsWith("/") && (i = "file://" + i), new URL(e, i).href.replace(/^(file:\/\/)/, "");
843
1053
  }
844
1054
  /** List of URI template parameter keys, if the `Link` is templated. */
845
1055
  get templateParameters() {
846
- return this.templated ? new Ie(this.href).parameters : /* @__PURE__ */ new Set();
1056
+ return this.templated ? new Jt(this.href).parameters : /* @__PURE__ */ new Set();
847
1057
  }
848
1058
  /** Expands the `Link`'s HREF by replacing URI template variables by the given parameters.
849
1059
  * See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
850
1060
  */
851
- expandTemplate(e) {
852
- return new H({
853
- href: new Ie(this.href).expand(e),
1061
+ expandTemplate(t) {
1062
+ return new Y({
1063
+ href: new Jt(this.href).expand(t),
854
1064
  templated: !1
855
1065
  });
856
1066
  }
857
1067
  /**
858
1068
  * Makes a copy of this [Link] after merging in the given additional other [properties].
859
1069
  */
860
- addProperties(e) {
861
- const t = H.deserialize(this.serialize());
862
- return t.properties = t.properties ? t.properties?.add(e) : new C(e), t;
1070
+ addProperties(t) {
1071
+ const e = Y.deserialize(this.serialize());
1072
+ return e.properties = e.properties ? e.properties?.add(t) : new R(t), e;
863
1073
  }
864
1074
  /**
865
1075
  * Creates a [Locator] from a reading order [Link].
866
1076
  */
867
1077
  get locator() {
868
- let e = this.href.split("#");
869
- return new R({
870
- href: e.length > 0 && e[0] !== void 0 ? e[0] : this.href,
1078
+ let t = this.href.split("#");
1079
+ return new W({
1080
+ href: t.length > 0 && t[0] !== void 0 ? t[0] : this.href,
871
1081
  type: this.type ?? "",
872
1082
  title: this.title,
873
- locations: new b({
874
- fragments: e.length > 1 && e[1] !== void 0 ? [e[1]] : []
1083
+ locations: new C({
1084
+ fragments: t.length > 1 && t[1] !== void 0 ? [t[1]] : []
875
1085
  })
876
1086
  });
877
1087
  }
878
1088
  }
879
- class ee {
1089
+ class lt {
880
1090
  /**
881
1091
  * Creates a [Links].
882
1092
  */
883
- constructor(e) {
884
- this.items = e;
1093
+ constructor(t) {
1094
+ this.items = t;
885
1095
  }
886
1096
  /**
887
1097
  * Creates a list of [Link] from its RWPM JSON representation.
888
1098
  */
889
- static deserialize(e) {
890
- if (e && Array.isArray(e))
891
- return new ee(
892
- e.map((t) => H.deserialize(t)).filter((t) => t !== void 0)
1099
+ static deserialize(t) {
1100
+ if (t && Array.isArray(t))
1101
+ return new lt(
1102
+ t.map((e) => Y.deserialize(e)).filter((e) => e !== void 0)
893
1103
  );
894
1104
  }
895
1105
  /**
896
1106
  * Serializes an array of [Link] to its RWPM JSON representation.
897
1107
  */
898
1108
  serialize() {
899
- return this.items.map((e) => e.serialize());
1109
+ return this.items.map((t) => t.serialize());
900
1110
  }
901
1111
  /** Finds the first link with the given relation. */
902
- findWithRel(e) {
903
- const t = (i) => i.rels && i.rels.has(e);
904
- return this.items.find(t);
1112
+ findWithRel(t) {
1113
+ const e = (i) => i.rels && i.rels.has(t);
1114
+ return this.items.find(e);
905
1115
  }
906
1116
  /** Finds all the links with the given relation. */
907
- filterByRel(e) {
908
- const t = (i) => i.rels && i.rels.has(e);
909
- return this.items.filter(t);
1117
+ filterByRel(t) {
1118
+ const e = (i) => i.rels && i.rels.has(t);
1119
+ return this.items.filter(e);
910
1120
  }
911
1121
  /** Finds the first link matching the given HREF. */
912
- findWithHref(e) {
913
- const t = (i) => i.href === e;
914
- return this.items.find(t);
1122
+ findWithHref(t) {
1123
+ const e = (i) => i.href === t;
1124
+ return this.items.find(e);
915
1125
  }
916
1126
  /** Finds the index of the first link matching the given HREF. */
917
- findIndexWithHref(e) {
918
- const t = (i) => i.href === e;
919
- return this.items.findIndex(t);
1127
+ findIndexWithHref(t) {
1128
+ const e = (i) => i.href === t;
1129
+ return this.items.findIndex(e);
920
1130
  }
921
1131
  /** Finds the first link matching the given media type. */
922
- findWithMediaType(e) {
923
- const t = (i) => i.mediaType.matches(e);
924
- return this.items.find(t);
1132
+ findWithMediaType(t) {
1133
+ const e = (i) => i.mediaType.matches(t);
1134
+ return this.items.find(e);
925
1135
  }
926
1136
  /** Finds all the links matching the given media type. */
927
- filterByMediaType(e) {
928
- const t = (i) => i.mediaType.matches(e);
929
- return this.items.filter(t);
1137
+ filterByMediaType(t) {
1138
+ const e = (i) => i.mediaType.matches(t);
1139
+ return this.items.filter(e);
930
1140
  }
931
1141
  /** Finds all the links matching any of the given media types. */
932
- filterByMediaTypes(e) {
933
- const t = (i) => {
934
- for (const r of e)
935
- if (i.mediaType.matches(r))
1142
+ filterByMediaTypes(t) {
1143
+ const e = (i) => {
1144
+ for (const s of t)
1145
+ if (i.mediaType.matches(s))
936
1146
  return !0;
937
1147
  return !1;
938
1148
  };
939
- return this.items.filter(t);
1149
+ return this.items.filter(e);
940
1150
  }
941
1151
  /** Returns whether all the resources in the collection are audio clips. */
942
1152
  everyIsAudio() {
943
- const e = (t) => t.mediaType.isAudio;
944
- return this.items.length > 0 && this.items.every(e);
1153
+ const t = (e) => e.mediaType.isAudio;
1154
+ return this.items.length > 0 && this.items.every(t);
945
1155
  }
946
1156
  /** Returns whether all the resources in the collection are bitmaps. */
947
1157
  everyIsBitmap() {
948
- const e = (t) => t.mediaType.isBitmap;
949
- return this.items.length > 0 && this.items.every(e);
1158
+ const t = (e) => e.mediaType.isBitmap;
1159
+ return this.items.length > 0 && this.items.every(t);
950
1160
  }
951
1161
  /** Returns whether all the resources in the collection are HTML documents. */
952
1162
  everyIsHTML() {
953
- const e = (t) => t.mediaType.isHTML;
954
- return this.items.length > 0 && this.items.every(e);
1163
+ const t = (e) => e.mediaType.isHTML;
1164
+ return this.items.length > 0 && this.items.every(t);
955
1165
  }
956
1166
  /** Returns whether all the resources in the collection are video clips. */
957
1167
  everyIsVideo() {
958
- const e = (t) => t.mediaType.isVideo;
959
- return this.items.length > 0 && this.items.every(e);
1168
+ const t = (e) => e.mediaType.isVideo;
1169
+ return this.items.length > 0 && this.items.every(t);
960
1170
  }
961
1171
  /** Returns whether all the resources in the collection are matching any of the given media types. */
962
- everyMatchesMediaType(e) {
963
- return Array.isArray(e) ? this.items.length > 0 && this.items.every((t) => {
964
- for (const i of e)
965
- return t.mediaType.matches(i);
1172
+ everyMatchesMediaType(t) {
1173
+ return Array.isArray(t) ? this.items.length > 0 && this.items.every((e) => {
1174
+ for (const i of t)
1175
+ return e.mediaType.matches(i);
966
1176
  return !1;
967
- }) : this.items.length > 0 && this.items.every((t) => t.mediaType.matches(e));
1177
+ }) : this.items.length > 0 && this.items.every((e) => e.mediaType.matches(t));
968
1178
  }
969
1179
  filterLinksHasType() {
970
- return this.items.filter((e) => e.type);
1180
+ return this.items.filter((t) => t.type);
971
1181
  }
972
1182
  }
973
- C.prototype.getContains = function() {
1183
+ R.prototype.getContains = function() {
974
1184
  return new Set(this.otherProperties.contains || []);
975
1185
  };
976
- class te {
1186
+ class ct {
977
1187
  /**
978
1188
  * Creates a [DomRange].
979
1189
  */
980
- constructor(e) {
981
- this.cssSelector = e.cssSelector, this.textNodeIndex = e.textNodeIndex, this.charOffset = e.charOffset;
1190
+ constructor(t) {
1191
+ this.cssSelector = t.cssSelector, this.textNodeIndex = t.textNodeIndex, this.charOffset = t.charOffset;
982
1192
  }
983
1193
  /**
984
1194
  * Parses a [DomRangePoint] from its RWPM JSON representation.
985
1195
  */
986
- static deserialize(e) {
987
- if (!(e && e.cssSelector)) return;
988
- let t = S(e.textNodeIndex);
989
- if (t === void 0) return;
990
- let i = S(e.charOffset);
991
- return i === void 0 && (i = S(e.offset)), new te({
992
- cssSelector: e.cssSelector,
993
- textNodeIndex: t,
1196
+ static deserialize(t) {
1197
+ if (!(t && t.cssSelector)) return;
1198
+ let e = O(t.textNodeIndex);
1199
+ if (e === void 0) return;
1200
+ let i = O(t.charOffset);
1201
+ return i === void 0 && (i = O(t.offset)), new ct({
1202
+ cssSelector: t.cssSelector,
1203
+ textNodeIndex: e,
994
1204
  charOffset: i
995
1205
  });
996
1206
  }
@@ -998,97 +1208,97 @@ class te {
998
1208
  * Serializes a [DomRangePoint] to its RWPM JSON representation.
999
1209
  */
1000
1210
  serialize() {
1001
- const e = {
1211
+ const t = {
1002
1212
  cssSelector: this.cssSelector,
1003
1213
  textNodeIndex: this.textNodeIndex
1004
1214
  };
1005
- return this.charOffset !== void 0 && (e.charOffset = this.charOffset), e;
1215
+ return this.charOffset !== void 0 && (t.charOffset = this.charOffset), t;
1006
1216
  }
1007
1217
  }
1008
- class we {
1218
+ class It {
1009
1219
  /**
1010
1220
  * Creates a [DomRange].
1011
1221
  */
1012
- constructor(e) {
1013
- this.start = e.start, this.end = e.end;
1222
+ constructor(t) {
1223
+ this.start = t.start, this.end = t.end;
1014
1224
  }
1015
1225
  /**
1016
1226
  * Parses a [DomRange] from its RWPM JSON representation.
1017
1227
  */
1018
- static deserialize(e) {
1019
- if (!e) return;
1020
- let t = te.deserialize(e.start);
1021
- if (t)
1022
- return new we({
1023
- start: t,
1024
- end: te.deserialize(e.end)
1228
+ static deserialize(t) {
1229
+ if (!t) return;
1230
+ let e = ct.deserialize(t.start);
1231
+ if (e)
1232
+ return new It({
1233
+ start: e,
1234
+ end: ct.deserialize(t.end)
1025
1235
  });
1026
1236
  }
1027
1237
  /**
1028
1238
  * Serializes a [DomRange] to its RWPM JSON representation.
1029
1239
  */
1030
1240
  serialize() {
1031
- const e = { start: this.start.serialize() };
1032
- return this.end && (e.end = this.end.serialize()), e;
1241
+ const t = { start: this.start.serialize() };
1242
+ return this.end && (t.end = this.end.serialize()), t;
1033
1243
  }
1034
1244
  }
1035
- b.prototype.getCssSelector = function() {
1245
+ C.prototype.getCssSelector = function() {
1036
1246
  return this.otherLocations?.get("cssSelector");
1037
1247
  };
1038
- b.prototype.getPartialCfi = function() {
1248
+ C.prototype.getPartialCfi = function() {
1039
1249
  return this.otherLocations?.get("partialCfi");
1040
1250
  };
1041
- b.prototype.getDomRange = function() {
1042
- return we.deserialize(this.otherLocations?.get("domRange"));
1251
+ C.prototype.getDomRange = function() {
1252
+ return It.deserialize(this.otherLocations?.get("domRange"));
1043
1253
  };
1044
- b.prototype.fragmentParameters = function() {
1254
+ C.prototype.fragmentParameters = function() {
1045
1255
  return new Map(
1046
- this.fragments.map((s) => s.startsWith("#") ? s.slice(1) : s).join("&").split("&").filter((s) => !s.startsWith("#")).map((s) => s.split("=")).filter((s) => s.length === 2).map((s) => [
1047
- s[0].trim().toLowerCase(),
1048
- s[1].trim()
1256
+ this.fragments.map((r) => r.startsWith("#") ? r.slice(1) : r).join("&").split("&").filter((r) => !r.startsWith("#")).map((r) => r.split("=")).filter((r) => r.length === 2).map((r) => [
1257
+ r[0].trim().toLowerCase(),
1258
+ r[1].trim()
1049
1259
  ])
1050
1260
  );
1051
1261
  };
1052
- b.prototype.htmlId = function() {
1262
+ C.prototype.htmlId = function() {
1053
1263
  if (!this.fragments.length) return;
1054
- let s = this.fragments.find((e) => e.length && !e.includes("="));
1055
- if (!s) {
1056
- const e = this.fragmentParameters();
1057
- e.has("id") ? s = e.get("id") : e.has("name") && (s = e.get("name"));
1264
+ let r = this.fragments.find((t) => t.length && !t.includes("="));
1265
+ if (!r) {
1266
+ const t = this.fragmentParameters();
1267
+ t.has("id") ? r = t.get("id") : t.has("name") && (r = t.get("name"));
1058
1268
  }
1059
- return s?.startsWith("#") ? s.slice(1) : s;
1269
+ return r?.startsWith("#") ? r.slice(1) : r;
1060
1270
  };
1061
- b.prototype.page = function() {
1062
- const s = parseInt(this.fragmentParameters().get("page"));
1063
- if (!isNaN(s) && s >= 0) return s;
1271
+ C.prototype.page = function() {
1272
+ const r = parseInt(this.fragmentParameters().get("page"));
1273
+ if (!isNaN(r) && r >= 0) return r;
1064
1274
  };
1065
- b.prototype.time = function() {
1066
- const s = parseInt(this.fragmentParameters().get("t"));
1067
- if (!isNaN(s)) return s;
1275
+ C.prototype.time = function() {
1276
+ const r = parseInt(this.fragmentParameters().get("t"));
1277
+ if (!isNaN(r)) return r;
1068
1278
  };
1069
- b.prototype.space = function() {
1070
- const s = this.fragmentParameters();
1071
- if (!s.has("xywh")) return;
1072
- const e = s.get("xywh").split(",").map((t) => parseInt(t));
1073
- if (e.length === 4 && !e.some(isNaN))
1074
- return e;
1279
+ C.prototype.space = function() {
1280
+ const r = this.fragmentParameters();
1281
+ if (!r.has("xywh")) return;
1282
+ const t = r.get("xywh").split(",").map((e) => parseInt(e));
1283
+ if (t.length === 4 && !t.some(isNaN))
1284
+ return t;
1075
1285
  };
1076
- class Se {
1286
+ class Dt {
1077
1287
  /** Creates a [Price]. */
1078
- constructor(e) {
1079
- this.currency = e.currency, this.value = e.value;
1288
+ constructor(t) {
1289
+ this.currency = t.currency, this.value = t.value;
1080
1290
  }
1081
1291
  /**
1082
1292
  * Parses a [Price] from its RWPM JSON representation.
1083
1293
  */
1084
- static deserialize(e) {
1085
- if (!e) return;
1086
- let t = e.currency;
1087
- if (!(t && typeof t == "string" && t.length > 0))
1294
+ static deserialize(t) {
1295
+ if (!t) return;
1296
+ let e = t.currency;
1297
+ if (!(e && typeof e == "string" && e.length > 0))
1088
1298
  return;
1089
- let i = S(e.value);
1299
+ let i = O(t.value);
1090
1300
  if (i !== void 0)
1091
- return new Se({ currency: t, value: i });
1301
+ return new Dt({ currency: e, value: i });
1092
1302
  }
1093
1303
  /**
1094
1304
  * Serializes a [Price] to its RWPM JSON representation.
@@ -1097,402 +1307,402 @@ class Se {
1097
1307
  return { currency: this.currency, value: this.value };
1098
1308
  }
1099
1309
  }
1100
- class V {
1310
+ class J {
1101
1311
  /** Creates a [Acquisition]. */
1102
- constructor(e) {
1103
- this.type = e.type, this.children = e.children;
1312
+ constructor(t) {
1313
+ this.type = t.type, this.children = t.children;
1104
1314
  }
1105
1315
  /**
1106
1316
  * Parses a [Acquisition] from its RWPM JSON representation.
1107
1317
  */
1108
- static deserialize(e) {
1109
- if (e && e.type)
1110
- return new V({
1111
- type: e.type,
1112
- children: V.deserializeArray(e.children)
1318
+ static deserialize(t) {
1319
+ if (t && t.type)
1320
+ return new J({
1321
+ type: t.type,
1322
+ children: J.deserializeArray(t.children)
1113
1323
  });
1114
1324
  }
1115
- static deserializeArray(e) {
1116
- if (Array.isArray(e))
1117
- return e.map((t) => V.deserialize(t)).filter((t) => t !== void 0);
1325
+ static deserializeArray(t) {
1326
+ if (Array.isArray(t))
1327
+ return t.map((e) => J.deserialize(e)).filter((e) => e !== void 0);
1118
1328
  }
1119
1329
  /**
1120
1330
  * Serializes a [Acquisition] to its RWPM JSON representation.
1121
1331
  */
1122
1332
  serialize() {
1123
- const e = { type: this.type };
1124
- return this.children && (e.children = this.children.map((t) => t.serialize())), e;
1333
+ const t = { type: this.type };
1334
+ return this.children && (t.children = this.children.map((e) => e.serialize())), t;
1125
1335
  }
1126
1336
  }
1127
- class Ce {
1337
+ class zt {
1128
1338
  /** Creates a [Price]. */
1129
- constructor(e) {
1130
- this.total = e.total, this.position = e.position;
1339
+ constructor(t) {
1340
+ this.total = t.total, this.position = t.position;
1131
1341
  }
1132
1342
  /**
1133
1343
  * Parses a [Holds] from its RWPM JSON representation.
1134
1344
  */
1135
- static deserialize(e) {
1136
- if (e)
1137
- return new Ce({
1138
- total: S(e.total),
1139
- position: S(e.position)
1345
+ static deserialize(t) {
1346
+ if (t)
1347
+ return new zt({
1348
+ total: O(t.total),
1349
+ position: O(t.position)
1140
1350
  });
1141
1351
  }
1142
1352
  /**
1143
1353
  * Serializes a [Holds] to its RWPM JSON representation.
1144
1354
  */
1145
1355
  serialize() {
1146
- const e = {};
1147
- return this.total !== void 0 && (e.total = this.total), this.position !== void 0 && (e.position = this.position), e;
1356
+ const t = {};
1357
+ return this.total !== void 0 && (t.total = this.total), this.position !== void 0 && (t.position = this.position), t;
1148
1358
  }
1149
1359
  }
1150
- class Pe {
1360
+ class Mt {
1151
1361
  /** Creates a [Copies]. */
1152
- constructor(e) {
1153
- this.total = e.total, this.available = e.available;
1362
+ constructor(t) {
1363
+ this.total = t.total, this.available = t.available;
1154
1364
  }
1155
1365
  /**
1156
1366
  * Parses a [Copies] from its RWPM JSON representation.
1157
1367
  */
1158
- static deserialize(e) {
1159
- if (e)
1160
- return new Pe({
1161
- total: S(e.total),
1162
- available: S(e.available)
1368
+ static deserialize(t) {
1369
+ if (t)
1370
+ return new Mt({
1371
+ total: O(t.total),
1372
+ available: O(t.available)
1163
1373
  });
1164
1374
  }
1165
1375
  /**
1166
1376
  * Serializes a [Copies] to its RWPM JSON representation.
1167
1377
  */
1168
1378
  serialize() {
1169
- const e = {};
1170
- return this.total !== void 0 && (e.total = this.total), this.available !== void 0 && (e.available = this.available), e;
1379
+ const t = {};
1380
+ return this.total !== void 0 && (t.total = this.total), this.available !== void 0 && (t.available = this.available), t;
1171
1381
  }
1172
1382
  }
1173
- class Ae {
1383
+ class kt {
1174
1384
  /** Creates a [Availability]. */
1175
- constructor(e) {
1176
- this.state = e.state, this.since = e.since, this.until = e.until;
1385
+ constructor(t) {
1386
+ this.state = t.state, this.since = t.since, this.until = t.until;
1177
1387
  }
1178
1388
  /**
1179
1389
  * Parses a [Availability] from its RWPM JSON representation.
1180
1390
  */
1181
- static deserialize(e) {
1182
- if (e && e.state)
1183
- return new Ae({
1184
- state: e.state,
1185
- since: Re(e.since),
1186
- until: Re(e.until)
1391
+ static deserialize(t) {
1392
+ if (t && t.state)
1393
+ return new kt({
1394
+ state: t.state,
1395
+ since: Zt(t.since),
1396
+ until: Zt(t.until)
1187
1397
  });
1188
1398
  }
1189
1399
  /**
1190
1400
  * Serializes a [Availability] to its RWPM JSON representation.
1191
1401
  */
1192
1402
  serialize() {
1193
- const e = { state: this.state };
1194
- return this.since !== void 0 && (e.since = this.since.toISOString()), this.until !== void 0 && (e.until = this.until.toISOString()), e;
1403
+ const t = { state: this.state };
1404
+ return this.since !== void 0 && (t.since = this.since.toISOString()), this.until !== void 0 && (t.until = this.until.toISOString()), t;
1195
1405
  }
1196
1406
  }
1197
- C.prototype.getNumberOfItems = function() {
1198
- return S(this.otherProperties.numberOfItems);
1407
+ R.prototype.getNumberOfItems = function() {
1408
+ return O(this.otherProperties.numberOfItems);
1199
1409
  };
1200
- C.prototype.getPrice = function() {
1201
- return Se.deserialize(this.otherProperties.price);
1410
+ R.prototype.getPrice = function() {
1411
+ return Dt.deserialize(this.otherProperties.price);
1202
1412
  };
1203
- C.prototype.getIndirectAcquisitions = function() {
1204
- const s = this.otherProperties.indirectAcquisition;
1205
- if (s && Array.isArray(s))
1206
- return s.map((e) => V.deserialize(e)).filter((e) => e !== void 0);
1413
+ R.prototype.getIndirectAcquisitions = function() {
1414
+ const r = this.otherProperties.indirectAcquisition;
1415
+ if (r && Array.isArray(r))
1416
+ return r.map((t) => J.deserialize(t)).filter((t) => t !== void 0);
1207
1417
  };
1208
- C.prototype.getHolds = function() {
1209
- return Ce.deserialize(this.otherProperties.holds);
1418
+ R.prototype.getHolds = function() {
1419
+ return zt.deserialize(this.otherProperties.holds);
1210
1420
  };
1211
- C.prototype.getCopies = function() {
1212
- return Pe.deserialize(this.otherProperties.copies);
1421
+ R.prototype.getCopies = function() {
1422
+ return Mt.deserialize(this.otherProperties.copies);
1213
1423
  };
1214
- C.prototype.getAvailability = function() {
1215
- return Ae.deserialize(this.otherProperties.availability);
1424
+ R.prototype.getAvailability = function() {
1425
+ return kt.deserialize(this.otherProperties.availability);
1216
1426
  };
1217
- C.prototype.getAuthenticate = function() {
1218
- return H.deserialize(this.otherProperties.authenticate);
1427
+ R.prototype.getAuthenticate = function() {
1428
+ return Y.deserialize(this.otherProperties.authenticate);
1219
1429
  };
1220
- const yt = "CssSelectorGenerator";
1221
- function ze(s = "unknown problem", ...e) {
1222
- console.warn(`${yt}: ${s}`, ...e);
1430
+ const Be = "CssSelectorGenerator";
1431
+ function Qt(r = "unknown problem", ...t) {
1432
+ console.warn(`${Be}: ${r}`, ...t);
1223
1433
  }
1224
- function vt(s) {
1225
- return s instanceof RegExp;
1434
+ function He(r) {
1435
+ return r instanceof RegExp;
1226
1436
  }
1227
- function bt(s) {
1228
- return s.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".+");
1437
+ function _e(r) {
1438
+ return r.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".+");
1229
1439
  }
1230
- function Et(s) {
1231
- const e = s.map((t) => {
1232
- if (vt(t))
1233
- return (i) => t.test(i);
1234
- if (typeof t == "function")
1440
+ function Ve(r) {
1441
+ const t = r.map((e) => {
1442
+ if (He(e))
1443
+ return (i) => e.test(i);
1444
+ if (typeof e == "function")
1235
1445
  return (i) => {
1236
- const r = t(i);
1237
- return typeof r != "boolean" ? (ze("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It's result will be ignored.", t), !1) : r;
1446
+ const s = e(i);
1447
+ return typeof s != "boolean" ? (Qt("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It's result will be ignored.", e), !1) : s;
1238
1448
  };
1239
- if (typeof t == "string") {
1240
- const i = new RegExp("^" + bt(t) + "$");
1241
- return (r) => i.test(r);
1449
+ if (typeof e == "string") {
1450
+ const i = new RegExp("^" + _e(e) + "$");
1451
+ return (s) => i.test(s);
1242
1452
  }
1243
- return ze("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", t), () => !1;
1453
+ return Qt("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", e), () => !1;
1244
1454
  });
1245
- return (t) => e.some((i) => i(t));
1455
+ return (e) => t.some((i) => i(e));
1246
1456
  }
1247
- Et([
1457
+ Ve([
1248
1458
  "class",
1249
1459
  "id",
1250
1460
  // Angular attributes
1251
1461
  "ng-*"
1252
1462
  ]);
1253
- class Y {
1463
+ class X {
1254
1464
  }
1255
- function De(s) {
1256
- return s.split("").reverse().join("");
1465
+ function jt(r) {
1466
+ return r.split("").reverse().join("");
1257
1467
  }
1258
- function xt(s, e, t) {
1259
- const i = De(e);
1260
- return t.map((r) => {
1261
- const n = Math.max(0, r.end - e.length - r.errors), o = De(s.slice(n, r.end));
1468
+ function Ge(r, t, e) {
1469
+ const i = jt(t);
1470
+ return e.map((s) => {
1471
+ const n = Math.max(0, s.end - t.length - s.errors), o = jt(r.slice(n, s.end));
1262
1472
  return {
1263
- start: et(o, i, r.errors).reduce((u, h) => r.end - h.end < u ? r.end - h.end : u, r.end),
1264
- end: r.end,
1265
- errors: r.errors
1473
+ start: be(o, i, s.errors).reduce((d, h) => s.end - h.end < d ? s.end - h.end : d, s.end),
1474
+ end: s.end,
1475
+ errors: s.errors
1266
1476
  };
1267
1477
  });
1268
1478
  }
1269
- function ae(s) {
1270
- return (s | -s) >> 31 & 1;
1479
+ function ft(r) {
1480
+ return (r | -r) >> 31 & 1;
1271
1481
  }
1272
- function We(s, e, t, i) {
1273
- let r = s.P[t], n = s.M[t];
1274
- const o = i >>> 31, a = e[t] | o, u = a | n, h = (a & r) + r ^ r | a;
1275
- let c = n | ~(h | r), m = r & h;
1276
- const d = ae(c & s.lastRowMask[t]) - ae(m & s.lastRowMask[t]);
1277
- return c <<= 1, m <<= 1, m |= o, c |= ae(i) - o, r = m | ~(u | c), n = c & u, s.P[t] = r, s.M[t] = n, d;
1482
+ function te(r, t, e, i) {
1483
+ let s = r.P[e], n = r.M[e];
1484
+ const o = i >>> 31, a = t[e] | o, d = a | n, h = (a & s) + s ^ s | a;
1485
+ let u = n | ~(h | s), g = s & h;
1486
+ const m = ft(u & r.lastRowMask[e]) - ft(g & r.lastRowMask[e]);
1487
+ return u <<= 1, g <<= 1, g |= o, u |= ft(i) - o, s = g | ~(d | u), n = u & d, r.P[e] = s, r.M[e] = n, m;
1278
1488
  }
1279
- function et(s, e, t) {
1280
- if (e.length === 0)
1489
+ function be(r, t, e) {
1490
+ if (t.length === 0)
1281
1491
  return [];
1282
- t = Math.min(t, e.length);
1283
- const i = [], r = 32, n = Math.ceil(e.length / r) - 1, o = {
1492
+ e = Math.min(e, t.length);
1493
+ const i = [], s = 32, n = Math.ceil(t.length / s) - 1, o = {
1284
1494
  P: new Uint32Array(n + 1),
1285
1495
  M: new Uint32Array(n + 1),
1286
1496
  lastRowMask: new Uint32Array(n + 1)
1287
1497
  };
1288
- o.lastRowMask.fill(1 << 31), o.lastRowMask[n] = 1 << (e.length - 1) % r;
1289
- const a = new Uint32Array(n + 1), u = /* @__PURE__ */ new Map(), h = [];
1290
- for (let d = 0; d < 256; d++)
1498
+ o.lastRowMask.fill(1 << 31), o.lastRowMask[n] = 1 << (t.length - 1) % s;
1499
+ const a = new Uint32Array(n + 1), d = /* @__PURE__ */ new Map(), h = [];
1500
+ for (let m = 0; m < 256; m++)
1291
1501
  h.push(a);
1292
- for (let d = 0; d < e.length; d += 1) {
1293
- const y = e.charCodeAt(d);
1294
- if (u.has(y))
1502
+ for (let m = 0; m < t.length; m += 1) {
1503
+ const v = t.charCodeAt(m);
1504
+ if (d.has(v))
1295
1505
  continue;
1296
- const p = new Uint32Array(n + 1);
1297
- u.set(y, p), y < h.length && (h[y] = p);
1298
- for (let f = 0; f <= n; f += 1) {
1299
- p[f] = 0;
1300
- for (let g = 0; g < r; g += 1) {
1301
- const E = f * r + g;
1302
- if (E >= e.length)
1506
+ const f = new Uint32Array(n + 1);
1507
+ d.set(v, f), v < h.length && (h[v] = f);
1508
+ for (let p = 0; p <= n; p += 1) {
1509
+ f[p] = 0;
1510
+ for (let b = 0; b < s; b += 1) {
1511
+ const x = p * s + b;
1512
+ if (x >= t.length)
1303
1513
  continue;
1304
- e.charCodeAt(E) === y && (p[f] |= 1 << g);
1514
+ t.charCodeAt(x) === v && (f[p] |= 1 << b);
1305
1515
  }
1306
1516
  }
1307
1517
  }
1308
- let c = Math.max(0, Math.ceil(t / r) - 1);
1309
- const m = new Uint32Array(n + 1);
1310
- for (let d = 0; d <= c; d += 1)
1311
- m[d] = (d + 1) * r;
1312
- m[n] = e.length;
1313
- for (let d = 0; d <= c; d += 1)
1314
- o.P[d] = -1, o.M[d] = 0;
1315
- for (let d = 0; d < s.length; d += 1) {
1316
- const y = s.charCodeAt(d);
1317
- let p;
1318
- y < h.length ? p = h[y] : (p = u.get(y), typeof p > "u" && (p = a));
1319
- let f = 0;
1320
- for (let g = 0; g <= c; g += 1)
1321
- f = We(o, p, g, f), m[g] += f;
1322
- if (m[c] - f <= t && c < n && (p[c + 1] & 1 || f < 0)) {
1323
- c += 1, o.P[c] = -1, o.M[c] = 0;
1324
- let g;
1325
- if (c === n) {
1326
- const E = e.length % r;
1327
- g = E === 0 ? r : E;
1518
+ let u = Math.max(0, Math.ceil(e / s) - 1);
1519
+ const g = new Uint32Array(n + 1);
1520
+ for (let m = 0; m <= u; m += 1)
1521
+ g[m] = (m + 1) * s;
1522
+ g[n] = t.length;
1523
+ for (let m = 0; m <= u; m += 1)
1524
+ o.P[m] = -1, o.M[m] = 0;
1525
+ for (let m = 0; m < r.length; m += 1) {
1526
+ const v = r.charCodeAt(m);
1527
+ let f;
1528
+ v < h.length ? f = h[v] : (f = d.get(v), typeof f > "u" && (f = a));
1529
+ let p = 0;
1530
+ for (let b = 0; b <= u; b += 1)
1531
+ p = te(o, f, b, p), g[b] += p;
1532
+ if (g[u] - p <= e && u < n && (f[u + 1] & 1 || p < 0)) {
1533
+ u += 1, o.P[u] = -1, o.M[u] = 0;
1534
+ let b;
1535
+ if (u === n) {
1536
+ const x = t.length % s;
1537
+ b = x === 0 ? s : x;
1328
1538
  } else
1329
- g = r;
1330
- m[c] = m[c - 1] + g - f + We(o, p, c, f);
1539
+ b = s;
1540
+ g[u] = g[u - 1] + b - p + te(o, f, u, p);
1331
1541
  } else
1332
- for (; c > 0 && m[c] >= t + r; )
1333
- c -= 1;
1334
- c === n && m[c] <= t && (m[c] < t && i.splice(0, i.length), i.push({
1542
+ for (; u > 0 && g[u] >= e + s; )
1543
+ u -= 1;
1544
+ u === n && g[u] <= e && (g[u] < e && i.splice(0, i.length), i.push({
1335
1545
  start: -1,
1336
- end: d + 1,
1337
- errors: m[c]
1338
- }), t = m[c]);
1546
+ end: m + 1,
1547
+ errors: g[u]
1548
+ }), e = g[u]);
1339
1549
  }
1340
1550
  return i;
1341
1551
  }
1342
- function Tt(s, e, t) {
1343
- const i = et(s, e, t);
1344
- return xt(s, e, i);
1552
+ function Fe(r, t, e) {
1553
+ const i = be(r, t, e);
1554
+ return Ge(r, t, i);
1345
1555
  }
1346
- function tt(s, e, t) {
1556
+ function ve(r, t, e) {
1347
1557
  let i = 0;
1348
- const r = [];
1558
+ const s = [];
1349
1559
  for (; i !== -1; )
1350
- i = s.indexOf(e, i), i !== -1 && (r.push({
1560
+ i = r.indexOf(t, i), i !== -1 && (s.push({
1351
1561
  start: i,
1352
- end: i + e.length,
1562
+ end: i + t.length,
1353
1563
  errors: 0
1354
1564
  }), i += 1);
1355
- return r.length > 0 ? r : Tt(s, e, t);
1565
+ return s.length > 0 ? s : Fe(r, t, e);
1356
1566
  }
1357
- function Fe(s, e) {
1358
- return e.length === 0 || s.length === 0 ? 0 : 1 - tt(s, e, e.length)[0].errors / e.length;
1567
+ function ee(r, t) {
1568
+ return t.length === 0 || r.length === 0 ? 0 : 1 - ve(r, t, t.length)[0].errors / t.length;
1359
1569
  }
1360
- function wt(s, e, t = {}) {
1361
- if (e.length === 0)
1570
+ function $e(r, t, e = {}) {
1571
+ if (t.length === 0)
1362
1572
  return null;
1363
- const i = Math.min(256, e.length / 2), r = tt(s, e, i);
1364
- if (r.length === 0)
1573
+ const i = Math.min(256, t.length / 2), s = ve(r, t, i);
1574
+ if (s.length === 0)
1365
1575
  return null;
1366
1576
  const n = (a) => {
1367
- const d = 1 - a.errors / e.length, y = t.prefix ? Fe(
1368
- s.slice(
1369
- Math.max(0, a.start - t.prefix.length),
1577
+ const m = 1 - a.errors / t.length, v = e.prefix ? ee(
1578
+ r.slice(
1579
+ Math.max(0, a.start - e.prefix.length),
1370
1580
  a.start
1371
1581
  ),
1372
- t.prefix
1373
- ) : 1, p = t.suffix ? Fe(
1374
- s.slice(a.end, a.end + t.suffix.length),
1375
- t.suffix
1582
+ e.prefix
1583
+ ) : 1, f = e.suffix ? ee(
1584
+ r.slice(a.end, a.end + e.suffix.length),
1585
+ e.suffix
1376
1586
  ) : 1;
1377
- let f = 1;
1378
- return typeof t.hint == "number" && (f = 1 - Math.abs(a.start - t.hint) / s.length), (50 * d + 20 * y + 20 * p + 2 * f) / 92;
1379
- }, o = r.map((a) => ({
1587
+ let p = 1;
1588
+ return typeof e.hint == "number" && (p = 1 - Math.abs(a.start - e.hint) / r.length), (50 * m + 20 * v + 20 * f + 2 * p) / 92;
1589
+ }, o = s.map((a) => ({
1380
1590
  start: a.start,
1381
1591
  end: a.end,
1382
1592
  score: n(a)
1383
1593
  }));
1384
- return o.sort((a, u) => u.score - a.score), o[0];
1385
- }
1386
- function ue(s, e, t) {
1387
- const i = t === 1 ? e : e - 1;
1388
- if (s.charAt(i).trim() !== "")
1389
- return e;
1390
- let r, n;
1391
- if (t === 2 ? (r = s.substring(0, e), n = r.trimEnd()) : (r = s.substring(e), n = r.trimStart()), !n.length)
1594
+ return o.sort((a, d) => d.score - a.score), o[0];
1595
+ }
1596
+ function vt(r, t, e) {
1597
+ const i = e === 1 ? t : t - 1;
1598
+ if (r.charAt(i).trim() !== "")
1599
+ return t;
1600
+ let s, n;
1601
+ if (e === 2 ? (s = r.substring(0, t), n = s.trimEnd()) : (s = r.substring(t), n = s.trimStart()), !n.length)
1392
1602
  return -1;
1393
- const o = r.length - n.length;
1394
- return t === 2 ? e - o : e + o;
1603
+ const o = s.length - n.length;
1604
+ return e === 2 ? t - o : t + o;
1395
1605
  }
1396
- function Ue(s, e) {
1397
- const t = s.commonAncestorContainer.ownerDocument.createNodeIterator(
1398
- s.commonAncestorContainer,
1606
+ function ie(r, t) {
1607
+ const e = r.commonAncestorContainer.ownerDocument.createNodeIterator(
1608
+ r.commonAncestorContainer,
1399
1609
  NodeFilter.SHOW_TEXT
1400
- ), i = e === 1 ? s.startContainer : s.endContainer, r = e === 1 ? s.endContainer : s.startContainer;
1401
- let n = t.nextNode();
1610
+ ), i = t === 1 ? r.startContainer : r.endContainer, s = t === 1 ? r.endContainer : r.startContainer;
1611
+ let n = e.nextNode();
1402
1612
  for (; n && n !== i; )
1403
- n = t.nextNode();
1404
- e === 2 && (n = t.previousNode());
1613
+ n = e.nextNode();
1614
+ t === 2 && (n = e.previousNode());
1405
1615
  let o = -1;
1406
1616
  const a = () => {
1407
- if (n = e === 1 ? t.nextNode() : t.previousNode(), n) {
1408
- const u = n.textContent, h = e === 1 ? 0 : u.length;
1409
- o = ue(u, h, e);
1617
+ if (n = t === 1 ? e.nextNode() : e.previousNode(), n) {
1618
+ const d = n.textContent, h = t === 1 ? 0 : d.length;
1619
+ o = vt(d, h, t);
1410
1620
  }
1411
1621
  };
1412
- for (; n && o === -1 && n !== r; )
1622
+ for (; n && o === -1 && n !== s; )
1413
1623
  a();
1414
1624
  if (n && o >= 0)
1415
1625
  return { node: n, offset: o };
1416
1626
  throw new RangeError("No text nodes with non-whitespace text found in range");
1417
1627
  }
1418
- function St(s) {
1419
- if (!s.toString().trim().length)
1628
+ function Ye(r) {
1629
+ if (!r.toString().trim().length)
1420
1630
  throw new RangeError("Range contains no non-whitespace text");
1421
- if (s.startContainer.nodeType !== Node.TEXT_NODE)
1631
+ if (r.startContainer.nodeType !== Node.TEXT_NODE)
1422
1632
  throw new RangeError("Range startContainer is not a text node");
1423
- if (s.endContainer.nodeType !== Node.TEXT_NODE)
1633
+ if (r.endContainer.nodeType !== Node.TEXT_NODE)
1424
1634
  throw new RangeError("Range endContainer is not a text node");
1425
- const e = s.cloneRange();
1426
- let t = !1, i = !1;
1427
- const r = {
1428
- start: ue(
1429
- s.startContainer.textContent,
1430
- s.startOffset,
1635
+ const t = r.cloneRange();
1636
+ let e = !1, i = !1;
1637
+ const s = {
1638
+ start: vt(
1639
+ r.startContainer.textContent,
1640
+ r.startOffset,
1431
1641
  1
1432
1642
  /* Forwards */
1433
1643
  ),
1434
- end: ue(
1435
- s.endContainer.textContent,
1436
- s.endOffset,
1644
+ end: vt(
1645
+ r.endContainer.textContent,
1646
+ r.endOffset,
1437
1647
  2
1438
1648
  /* Backwards */
1439
1649
  )
1440
1650
  };
1441
- if (r.start >= 0 && (e.setStart(s.startContainer, r.start), t = !0), r.end > 0 && (e.setEnd(s.endContainer, r.end), i = !0), t && i)
1442
- return e;
1443
- if (!t) {
1444
- const { node: n, offset: o } = Ue(
1445
- e,
1651
+ if (s.start >= 0 && (t.setStart(r.startContainer, s.start), e = !0), s.end > 0 && (t.setEnd(r.endContainer, s.end), i = !0), e && i)
1652
+ return t;
1653
+ if (!e) {
1654
+ const { node: n, offset: o } = ie(
1655
+ t,
1446
1656
  1
1447
1657
  /* Forwards */
1448
1658
  );
1449
- n && o >= 0 && e.setStart(n, o);
1659
+ n && o >= 0 && t.setStart(n, o);
1450
1660
  }
1451
1661
  if (!i) {
1452
- const { node: n, offset: o } = Ue(
1453
- e,
1662
+ const { node: n, offset: o } = ie(
1663
+ t,
1454
1664
  2
1455
1665
  /* Backwards */
1456
1666
  );
1457
- n && o > 0 && e.setEnd(n, o);
1667
+ n && o > 0 && t.setEnd(n, o);
1458
1668
  }
1459
- return e;
1669
+ return t;
1460
1670
  }
1461
- function it(s) {
1462
- switch (s.nodeType) {
1671
+ function we(r) {
1672
+ switch (r.nodeType) {
1463
1673
  case Node.ELEMENT_NODE:
1464
1674
  case Node.TEXT_NODE:
1465
- return s.textContent?.length ?? 0;
1675
+ return r.textContent?.length ?? 0;
1466
1676
  default:
1467
1677
  return 0;
1468
1678
  }
1469
1679
  }
1470
- function Be(s) {
1471
- let e = s.previousSibling, t = 0;
1472
- for (; e; )
1473
- t += it(e), e = e.previousSibling;
1474
- return t;
1680
+ function se(r) {
1681
+ let t = r.previousSibling, e = 0;
1682
+ for (; t; )
1683
+ e += we(t), t = t.previousSibling;
1684
+ return e;
1475
1685
  }
1476
- function rt(s, ...e) {
1477
- let t = e.shift();
1478
- const i = s.ownerDocument.createNodeIterator(
1479
- s,
1686
+ function Se(r, ...t) {
1687
+ let e = t.shift();
1688
+ const i = r.ownerDocument.createNodeIterator(
1689
+ r,
1480
1690
  NodeFilter.SHOW_TEXT
1481
- ), r = [];
1691
+ ), s = [];
1482
1692
  let n = i.nextNode(), o, a = 0;
1483
- for (; t !== void 0 && n; )
1484
- o = n, a + o.data.length > t ? (r.push({ node: o, offset: t - a }), t = e.shift()) : (n = i.nextNode(), a += o.data.length);
1485
- for (; t !== void 0 && o && a === t; )
1486
- r.push({ node: o, offset: o.data.length }), t = e.shift();
1487
- if (t !== void 0)
1693
+ for (; e !== void 0 && n; )
1694
+ o = n, a + o.data.length > e ? (s.push({ node: o, offset: e - a }), e = t.shift()) : (n = i.nextNode(), a += o.data.length);
1695
+ for (; e !== void 0 && o && a === e; )
1696
+ s.push({ node: o, offset: o.data.length }), e = t.shift();
1697
+ if (e !== void 0)
1488
1698
  throw new RangeError("Offset exceeds text length");
1489
- return r;
1699
+ return s;
1490
1700
  }
1491
- class M {
1492
- constructor(e, t) {
1493
- if (t < 0)
1701
+ class z {
1702
+ constructor(t, e) {
1703
+ if (e < 0)
1494
1704
  throw new Error("Offset is invalid");
1495
- this.element = e, this.offset = t;
1705
+ this.element = t, this.offset = e;
1496
1706
  }
1497
1707
  /**
1498
1708
  * Return a copy of this position with offset relative to a given ancestor
@@ -1500,13 +1710,13 @@ class M {
1500
1710
  *
1501
1711
  * @param parent - Ancestor of `this.element`
1502
1712
  */
1503
- relativeTo(e) {
1504
- if (!e.contains(this.element))
1713
+ relativeTo(t) {
1714
+ if (!t.contains(this.element))
1505
1715
  throw new Error("Parent is not an ancestor of current element");
1506
- let t = this.element, i = this.offset;
1507
- for (; t !== e; )
1508
- i += Be(t), t = t.parentElement;
1509
- return new M(t, i);
1716
+ let e = this.element, i = this.offset;
1717
+ for (; e !== t; )
1718
+ i += se(e), e = e.parentElement;
1719
+ return new z(e, i);
1510
1720
  }
1511
1721
  /**
1512
1722
  * Resolve the position to a specific text node and offset within that node.
@@ -1525,34 +1735,34 @@ class M {
1525
1735
  *
1526
1736
  * @throws {RangeError}
1527
1737
  */
1528
- resolve(e = {}) {
1738
+ resolve(t = {}) {
1529
1739
  try {
1530
- return rt(this.element, this.offset)[0];
1531
- } catch (t) {
1532
- if (this.offset === 0 && e.direction !== void 0) {
1740
+ return Se(this.element, this.offset)[0];
1741
+ } catch (e) {
1742
+ if (this.offset === 0 && t.direction !== void 0) {
1533
1743
  const i = document.createTreeWalker(
1534
1744
  this.element.getRootNode(),
1535
1745
  NodeFilter.SHOW_TEXT
1536
1746
  );
1537
1747
  i.currentNode = this.element;
1538
- const r = e.direction === 1, n = r ? i.nextNode() : i.previousNode();
1748
+ const s = t.direction === 1, n = s ? i.nextNode() : i.previousNode();
1539
1749
  if (!n)
1540
- throw t;
1541
- return { node: n, offset: r ? 0 : n.data.length };
1750
+ throw e;
1751
+ return { node: n, offset: s ? 0 : n.data.length };
1542
1752
  } else
1543
- throw t;
1753
+ throw e;
1544
1754
  }
1545
1755
  }
1546
1756
  /**
1547
1757
  * Construct a `TextPosition` that refers to the `offset`th character within
1548
1758
  * `node`.
1549
1759
  */
1550
- static fromCharOffset(e, t) {
1551
- switch (e.nodeType) {
1760
+ static fromCharOffset(t, e) {
1761
+ switch (t.nodeType) {
1552
1762
  case Node.TEXT_NODE:
1553
- return M.fromPoint(e, t);
1763
+ return z.fromPoint(t, e);
1554
1764
  case Node.ELEMENT_NODE:
1555
- return new M(e, t);
1765
+ return new z(t, e);
1556
1766
  default:
1557
1767
  throw new Error("Node is not an element or text node");
1558
1768
  }
@@ -1563,42 +1773,42 @@ class M {
1563
1773
  * @param node
1564
1774
  * @param offset - Offset within the node
1565
1775
  */
1566
- static fromPoint(e, t) {
1567
- switch (e.nodeType) {
1776
+ static fromPoint(t, e) {
1777
+ switch (t.nodeType) {
1568
1778
  case Node.TEXT_NODE: {
1569
- if (t < 0 || t > e.data.length)
1779
+ if (e < 0 || e > t.data.length)
1570
1780
  throw new Error("Text node offset is out of range");
1571
- if (!e.parentElement)
1781
+ if (!t.parentElement)
1572
1782
  throw new Error("Text node has no parent");
1573
- const i = Be(e) + t;
1574
- return new M(e.parentElement, i);
1783
+ const i = se(t) + e;
1784
+ return new z(t.parentElement, i);
1575
1785
  }
1576
1786
  case Node.ELEMENT_NODE: {
1577
- if (t < 0 || t > e.childNodes.length)
1787
+ if (e < 0 || e > t.childNodes.length)
1578
1788
  throw new Error("Child node offset is out of range");
1579
1789
  let i = 0;
1580
- for (let r = 0; r < t; r++)
1581
- i += it(e.childNodes[r]);
1582
- return new M(e, i);
1790
+ for (let s = 0; s < e; s++)
1791
+ i += we(t.childNodes[s]);
1792
+ return new z(t, i);
1583
1793
  }
1584
1794
  default:
1585
1795
  throw new Error("Point is not in an element or text node");
1586
1796
  }
1587
1797
  }
1588
1798
  }
1589
- class I {
1590
- constructor(e, t) {
1591
- this.start = e, this.end = t;
1799
+ class U {
1800
+ constructor(t, e) {
1801
+ this.start = t, this.end = e;
1592
1802
  }
1593
1803
  /**
1594
1804
  * Create a new TextRange whose `start` and `end` are computed relative to
1595
1805
  * `element`. `element` must be an ancestor of both `start.element` and
1596
1806
  * `end.element`.
1597
1807
  */
1598
- relativeTo(e) {
1599
- return new I(
1600
- this.start.relativeTo(e),
1601
- this.end.relativeTo(e)
1808
+ relativeTo(t) {
1809
+ return new U(
1810
+ this.start.relativeTo(t),
1811
+ this.end.relativeTo(t)
1602
1812
  );
1603
1813
  }
1604
1814
  /**
@@ -1611,63 +1821,63 @@ class I {
1611
1821
  * May throw if the `start` or `end` positions cannot be resolved to a range.
1612
1822
  */
1613
1823
  toRange() {
1614
- let e, t;
1615
- this.start.element === this.end.element && this.start.offset <= this.end.offset ? [e, t] = rt(
1824
+ let t, e;
1825
+ this.start.element === this.end.element && this.start.offset <= this.end.offset ? [t, e] = Se(
1616
1826
  this.start.element,
1617
1827
  this.start.offset,
1618
1828
  this.end.offset
1619
- ) : (e = this.start.resolve({
1829
+ ) : (t = this.start.resolve({
1620
1830
  direction: 1
1621
1831
  /* FORWARDS */
1622
- }), t = this.end.resolve({
1832
+ }), e = this.end.resolve({
1623
1833
  direction: 2
1624
1834
  /* BACKWARDS */
1625
1835
  }));
1626
1836
  const i = new Range();
1627
- return i.setStart(e.node, e.offset), i.setEnd(t.node, t.offset), i;
1837
+ return i.setStart(t.node, t.offset), i.setEnd(e.node, e.offset), i;
1628
1838
  }
1629
1839
  /**
1630
1840
  * Create a TextRange from a (DOM) Range
1631
1841
  */
1632
- static fromRange(e) {
1633
- const t = M.fromPoint(
1634
- e.startContainer,
1635
- e.startOffset
1636
- ), i = M.fromPoint(e.endContainer, e.endOffset);
1637
- return new I(t, i);
1842
+ static fromRange(t) {
1843
+ const e = z.fromPoint(
1844
+ t.startContainer,
1845
+ t.startOffset
1846
+ ), i = z.fromPoint(t.endContainer, t.endOffset);
1847
+ return new U(e, i);
1638
1848
  }
1639
1849
  /**
1640
1850
  * Create a TextRange representing the `start`th to `end`th characters in
1641
1851
  * `root`
1642
1852
  */
1643
- static fromOffsets(e, t, i) {
1644
- return new I(
1645
- new M(e, t),
1646
- new M(e, i)
1853
+ static fromOffsets(t, e, i) {
1854
+ return new U(
1855
+ new z(t, e),
1856
+ new z(t, i)
1647
1857
  );
1648
1858
  }
1649
1859
  /**
1650
1860
  * Return a new Range representing `range` trimmed of any leading or trailing
1651
1861
  * whitespace
1652
1862
  */
1653
- static trimmedRange(e) {
1654
- return St(I.fromRange(e).toRange());
1863
+ static trimmedRange(t) {
1864
+ return Ye(U.fromRange(t).toRange());
1655
1865
  }
1656
1866
  }
1657
- class ie {
1658
- constructor(e, t, i) {
1659
- this.root = e, this.start = t, this.end = i;
1867
+ class ht {
1868
+ constructor(t, e, i) {
1869
+ this.root = t, this.start = e, this.end = i;
1660
1870
  }
1661
- static fromRange(e, t) {
1662
- const i = I.fromRange(t).relativeTo(e);
1663
- return new ie(
1664
- e,
1871
+ static fromRange(t, e) {
1872
+ const i = U.fromRange(e).relativeTo(t);
1873
+ return new ht(
1874
+ t,
1665
1875
  i.start.offset,
1666
1876
  i.end.offset
1667
1877
  );
1668
1878
  }
1669
- static fromSelector(e, t) {
1670
- return new ie(e, t.start, t.end);
1879
+ static fromSelector(t, e) {
1880
+ return new ht(t, e.start, e.end);
1671
1881
  }
1672
1882
  toSelector() {
1673
1883
  return {
@@ -1677,31 +1887,31 @@ class ie {
1677
1887
  };
1678
1888
  }
1679
1889
  toRange() {
1680
- return I.fromOffsets(this.root, this.start, this.end).toRange();
1890
+ return U.fromOffsets(this.root, this.start, this.end).toRange();
1681
1891
  }
1682
1892
  }
1683
- class re {
1893
+ class dt {
1684
1894
  /**
1685
1895
  * @param root - A root element from which to anchor.
1686
1896
  */
1687
- constructor(e, t, i = {}) {
1688
- this.root = e, this.exact = t, this.context = i;
1897
+ constructor(t, e, i = {}) {
1898
+ this.root = t, this.exact = e, this.context = i;
1689
1899
  }
1690
1900
  /**
1691
1901
  * Create a `TextQuoteAnchor` from a range.
1692
1902
  *
1693
1903
  * Will throw if `range` does not contain any text nodes.
1694
1904
  */
1695
- static fromRange(e, t) {
1696
- const i = e.textContent, r = I.fromRange(t).relativeTo(e), n = r.start.offset, o = r.end.offset, a = 32;
1697
- return new re(e, i.slice(n, o), {
1905
+ static fromRange(t, e) {
1906
+ const i = t.textContent, s = U.fromRange(e).relativeTo(t), n = s.start.offset, o = s.end.offset, a = 32;
1907
+ return new dt(t, i.slice(n, o), {
1698
1908
  prefix: i.slice(Math.max(0, n - a), n),
1699
1909
  suffix: i.slice(o, Math.min(i.length, o + a))
1700
1910
  });
1701
1911
  }
1702
- static fromSelector(e, t) {
1703
- const { prefix: i, suffix: r } = t;
1704
- return new re(e, t.exact, { prefix: i, suffix: r });
1912
+ static fromSelector(t, e) {
1913
+ const { prefix: i, suffix: s } = e;
1914
+ return new dt(t, e.exact, { prefix: i, suffix: s });
1705
1915
  }
1706
1916
  toSelector() {
1707
1917
  return {
@@ -1711,30 +1921,30 @@ class re {
1711
1921
  suffix: this.context.suffix
1712
1922
  };
1713
1923
  }
1714
- toRange(e = {}) {
1715
- return this.toPositionAnchor(e).toRange();
1924
+ toRange(t = {}) {
1925
+ return this.toPositionAnchor(t).toRange();
1716
1926
  }
1717
- toPositionAnchor(e = {}) {
1718
- const t = this.root.textContent, i = wt(t, this.exact, {
1927
+ toPositionAnchor(t = {}) {
1928
+ const e = this.root.textContent, i = $e(e, this.exact, {
1719
1929
  ...this.context,
1720
- hint: e.hint
1930
+ hint: t.hint
1721
1931
  });
1722
1932
  if (!i)
1723
1933
  throw new Error("Quote not found");
1724
- return new ie(this.root, i.start, i.end);
1934
+ return new ht(this.root, i.start, i.end);
1725
1935
  }
1726
1936
  }
1727
- function Ct(s) {
1728
- const e = s.tagName.toUpperCase();
1729
- return e === "IMG" || e === "VIDEO" || e === "AUDIO" || e === "IFRAME" || e === "OBJECT" || e === "EMBED" || e === "CANVAS";
1937
+ function Xe(r) {
1938
+ const t = r.tagName.toUpperCase();
1939
+ return t === "IMG" || t === "VIDEO" || t === "AUDIO" || t === "IFRAME" || t === "OBJECT" || t === "EMBED" || t === "CANVAS";
1730
1940
  }
1731
- function ne(s, e) {
1941
+ function pt(r, t) {
1732
1942
  try {
1733
- const t = e.locations, i = e.text;
1943
+ const e = t.locations, i = t.text;
1734
1944
  if (i && i.highlight) {
1735
- let r;
1736
- t && t.getCssSelector() && (r = s.querySelector(t.getCssSelector())), r || (r = s.body);
1737
- const n = new re(r, i.highlight, {
1945
+ let s;
1946
+ e && e.getCssSelector() && (s = r.querySelector(e.getCssSelector())), s || (s = r.body);
1947
+ const n = new dt(s, i.highlight, {
1738
1948
  prefix: i.before,
1739
1949
  suffix: i.after
1740
1950
  });
@@ -1744,29 +1954,29 @@ function ne(s, e) {
1744
1954
  return console.warn("Quote not found:", n), null;
1745
1955
  }
1746
1956
  }
1747
- if (t) {
1748
- let r = null;
1749
- if (!r && t.getCssSelector() && (r = s.querySelector(t.getCssSelector())), !r && t.fragments) {
1750
- for (const n of t.fragments)
1751
- if (r = s.getElementById(n), r)
1957
+ if (e) {
1958
+ let s = null;
1959
+ if (!s && e.getCssSelector() && (s = r.querySelector(e.getCssSelector())), !s && e.fragments) {
1960
+ for (const n of e.fragments)
1961
+ if (s = r.getElementById(n), s)
1752
1962
  break;
1753
1963
  }
1754
- if (r) {
1755
- const n = s.createRange();
1756
- return r.childNodes.length === 0 || Ct(r) ? (n.selectNode(r), n) : (n.setStartBefore(r), n.setEndAfter(r), n);
1964
+ if (s) {
1965
+ const n = r.createRange();
1966
+ return s.childNodes.length === 0 || Xe(s) ? (n.selectNode(s), n) : (n.setStartBefore(s), n.setEndAfter(s), n);
1757
1967
  }
1758
1968
  }
1759
- } catch (t) {
1760
- console.error(t);
1969
+ } catch (e) {
1970
+ console.error(e);
1761
1971
  }
1762
1972
  return null;
1763
1973
  }
1764
- function Pt(s, e) {
1765
- let t = s.getClientRects();
1766
- t.length || s.commonAncestorContainer.nodeType === Node.ELEMENT_NODE && (t = s.commonAncestorContainer.getClientRects());
1767
- const i = 1, r = [];
1768
- for (const h of t)
1769
- r.push({
1974
+ function qe(r, t) {
1975
+ let e = r.getClientRects();
1976
+ e.length || r.commonAncestorContainer.nodeType === Node.ELEMENT_NODE && (e = r.commonAncestorContainer.getClientRects());
1977
+ const i = 1, s = [];
1978
+ for (const h of e)
1979
+ s.push({
1770
1980
  bottom: h.bottom,
1771
1981
  height: h.height,
1772
1982
  left: h.left,
@@ -1774,13 +1984,13 @@ function Pt(s, e) {
1774
1984
  top: h.top,
1775
1985
  width: h.width
1776
1986
  });
1777
- const n = st(
1778
- r,
1987
+ const n = Ee(
1988
+ s,
1779
1989
  i
1780
- ), o = Mt(n, i), a = nt(o), u = 4;
1990
+ ), o = Ze(n, i), a = Ae(o), d = 4;
1781
1991
  for (let h = a.length - 1; h >= 0; h--) {
1782
- const c = a[h];
1783
- if (!(c.width * c.height > u))
1992
+ const u = a[h];
1993
+ if (!(u.width * u.height > d))
1784
1994
  if (a.length > 1)
1785
1995
  a.splice(h, 1);
1786
1996
  else
@@ -1788,185 +1998,185 @@ function Pt(s, e) {
1788
1998
  }
1789
1999
  return a;
1790
2000
  }
1791
- function st(s, e, t) {
1792
- for (let i = 0; i < s.length; i++)
1793
- for (let r = i + 1; r < s.length; r++) {
1794
- const n = s[i], o = s[r];
2001
+ function Ee(r, t, e) {
2002
+ for (let i = 0; i < r.length; i++)
2003
+ for (let s = i + 1; s < r.length; s++) {
2004
+ const n = r[i], o = r[s];
1795
2005
  if (n === o)
1796
2006
  continue;
1797
- const a = P(n.top, o.top, e) && P(n.bottom, o.bottom, e), u = P(n.left, o.left, e) && P(n.right, o.right, e);
1798
- if (a && !u && ot(n, o, e)) {
1799
- const m = s.filter((y) => y !== n && y !== o), d = At(n, o);
1800
- return m.push(d), st(
1801
- m,
1802
- e
2007
+ const a = I(n.top, o.top, t) && I(n.bottom, o.bottom, t), d = I(n.left, o.left, t) && I(n.right, o.right, t);
2008
+ if (a && !d && Ce(n, o, t)) {
2009
+ const g = r.filter((v) => v !== n && v !== o), m = Ke(n, o);
2010
+ return g.push(m), Ee(
2011
+ g,
2012
+ t
1803
2013
  );
1804
2014
  }
1805
2015
  }
1806
- return s;
2016
+ return r;
1807
2017
  }
1808
- function At(s, e) {
1809
- const t = Math.min(s.left, e.left), i = Math.max(s.right, e.right), r = Math.min(s.top, e.top), n = Math.max(s.bottom, e.bottom);
2018
+ function Ke(r, t) {
2019
+ const e = Math.min(r.left, t.left), i = Math.max(r.right, t.right), s = Math.min(r.top, t.top), n = Math.max(r.bottom, t.bottom);
1810
2020
  return {
1811
2021
  bottom: n,
1812
- height: n - r,
1813
- left: t,
2022
+ height: n - s,
2023
+ left: e,
1814
2024
  right: i,
1815
- top: r,
1816
- width: i - t
2025
+ top: s,
2026
+ width: i - e
1817
2027
  };
1818
2028
  }
1819
- function Mt(s, e) {
1820
- const t = new Set(s);
1821
- for (const i of s) {
2029
+ function Ze(r, t) {
2030
+ const e = new Set(r);
2031
+ for (const i of r) {
1822
2032
  if (!(i.width > 1 && i.height > 1)) {
1823
- t.delete(i);
2033
+ e.delete(i);
1824
2034
  continue;
1825
2035
  }
1826
- for (const n of s)
1827
- if (i !== n && t.has(n) && Nt(n, i, e)) {
1828
- t.delete(i);
2036
+ for (const n of r)
2037
+ if (i !== n && e.has(n) && Je(n, i, t)) {
2038
+ e.delete(i);
1829
2039
  break;
1830
2040
  }
1831
2041
  }
1832
- return Array.from(t);
2042
+ return Array.from(e);
1833
2043
  }
1834
- function Nt(s, e, t) {
1835
- return K(s, e.left, e.top, t) && K(s, e.right, e.top, t) && K(s, e.left, e.bottom, t) && K(s, e.right, e.bottom, t);
2044
+ function Je(r, t, e) {
2045
+ return nt(r, t.left, t.top, e) && nt(r, t.right, t.top, e) && nt(r, t.left, t.bottom, e) && nt(r, t.right, t.bottom, e);
1836
2046
  }
1837
- function K(s, e, t, i) {
1838
- return (s.left < e || P(s.left, e, i)) && (s.right > e || P(s.right, e, i)) && (s.top < t || P(s.top, t, i)) && (s.bottom > t || P(s.bottom, t, i));
2047
+ function nt(r, t, e, i) {
2048
+ return (r.left < t || I(r.left, t, i)) && (r.right > t || I(r.right, t, i)) && (r.top < e || I(r.top, e, i)) && (r.bottom > e || I(r.bottom, e, i));
1839
2049
  }
1840
- function nt(s) {
1841
- for (let e = 0; e < s.length; e++)
1842
- for (let t = e + 1; t < s.length; t++) {
1843
- const i = s[e], r = s[t];
1844
- if (i !== r && ot(i, r, -1)) {
2050
+ function Ae(r) {
2051
+ for (let t = 0; t < r.length; t++)
2052
+ for (let e = t + 1; e < r.length; e++) {
2053
+ const i = r[t], s = r[e];
2054
+ if (i !== s && Ce(i, s, -1)) {
1845
2055
  let n = [], o;
1846
- const a = He(i, r);
2056
+ const a = ne(i, s);
1847
2057
  if (a.length === 1)
1848
2058
  n = a, o = i;
1849
2059
  else {
1850
- const h = He(r, i);
1851
- a.length < h.length ? (n = a, o = i) : (n = h, o = r);
2060
+ const h = ne(s, i);
2061
+ a.length < h.length ? (n = a, o = i) : (n = h, o = s);
1852
2062
  }
1853
- const u = s.filter((h) => h !== o);
1854
- return Array.prototype.push.apply(u, n), nt(u);
2063
+ const d = r.filter((h) => h !== o);
2064
+ return Array.prototype.push.apply(d, n), Ae(d);
1855
2065
  }
1856
2066
  }
1857
- return s;
2067
+ return r;
1858
2068
  }
1859
- function He(s, e) {
1860
- const t = Ot(e, s);
1861
- if (t.height === 0 || t.width === 0)
1862
- return [s];
2069
+ function ne(r, t) {
2070
+ const e = Qe(t, r);
2071
+ if (e.height === 0 || e.width === 0)
2072
+ return [r];
1863
2073
  const i = [];
1864
2074
  {
1865
- const r = {
1866
- bottom: s.bottom,
2075
+ const s = {
2076
+ bottom: r.bottom,
1867
2077
  height: 0,
1868
- left: s.left,
1869
- right: t.left,
1870
- top: s.top,
2078
+ left: r.left,
2079
+ right: e.left,
2080
+ top: r.top,
1871
2081
  width: 0
1872
2082
  };
1873
- r.width = r.right - r.left, r.height = r.bottom - r.top, r.height !== 0 && r.width !== 0 && i.push(r);
2083
+ s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
1874
2084
  }
1875
2085
  {
1876
- const r = {
1877
- bottom: t.top,
2086
+ const s = {
2087
+ bottom: e.top,
1878
2088
  height: 0,
1879
- left: t.left,
1880
- right: t.right,
1881
- top: s.top,
2089
+ left: e.left,
2090
+ right: e.right,
2091
+ top: r.top,
1882
2092
  width: 0
1883
2093
  };
1884
- r.width = r.right - r.left, r.height = r.bottom - r.top, r.height !== 0 && r.width !== 0 && i.push(r);
2094
+ s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
1885
2095
  }
1886
2096
  {
1887
- const r = {
1888
- bottom: s.bottom,
2097
+ const s = {
2098
+ bottom: r.bottom,
1889
2099
  height: 0,
1890
- left: t.left,
1891
- right: t.right,
1892
- top: t.bottom,
2100
+ left: e.left,
2101
+ right: e.right,
2102
+ top: e.bottom,
1893
2103
  width: 0
1894
2104
  };
1895
- r.width = r.right - r.left, r.height = r.bottom - r.top, r.height !== 0 && r.width !== 0 && i.push(r);
2105
+ s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
1896
2106
  }
1897
2107
  {
1898
- const r = {
1899
- bottom: s.bottom,
2108
+ const s = {
2109
+ bottom: r.bottom,
1900
2110
  height: 0,
1901
- left: t.right,
1902
- right: s.right,
1903
- top: s.top,
2111
+ left: e.right,
2112
+ right: r.right,
2113
+ top: r.top,
1904
2114
  width: 0
1905
2115
  };
1906
- r.width = r.right - r.left, r.height = r.bottom - r.top, r.height !== 0 && r.width !== 0 && i.push(r);
2116
+ s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);
1907
2117
  }
1908
2118
  return i;
1909
2119
  }
1910
- function Ot(s, e) {
1911
- const t = Math.max(s.left, e.left), i = Math.min(s.right, e.right), r = Math.max(s.top, e.top), n = Math.min(s.bottom, e.bottom);
2120
+ function Qe(r, t) {
2121
+ const e = Math.max(r.left, t.left), i = Math.min(r.right, t.right), s = Math.max(r.top, t.top), n = Math.min(r.bottom, t.bottom);
1912
2122
  return {
1913
2123
  bottom: n,
1914
- height: Math.max(0, n - r),
1915
- left: t,
2124
+ height: Math.max(0, n - s),
2125
+ left: e,
1916
2126
  right: i,
1917
- top: r,
1918
- width: Math.max(0, i - t)
2127
+ top: s,
2128
+ width: Math.max(0, i - e)
1919
2129
  };
1920
2130
  }
1921
- function ot(s, e, t) {
1922
- return (s.left < e.right || t >= 0 && P(s.left, e.right, t)) && (e.left < s.right || t >= 0 && P(e.left, s.right, t)) && (s.top < e.bottom || t >= 0 && P(s.top, e.bottom, t)) && (e.top < s.bottom || t >= 0 && P(e.top, s.bottom, t));
2131
+ function Ce(r, t, e) {
2132
+ return (r.left < t.right || e >= 0 && I(r.left, t.right, e)) && (t.left < r.right || e >= 0 && I(t.left, r.right, e)) && (r.top < t.bottom || e >= 0 && I(r.top, t.bottom, e)) && (t.top < r.bottom || e >= 0 && I(t.top, r.bottom, e));
1923
2133
  }
1924
- function P(s, e, t) {
1925
- return Math.abs(s - e) <= t;
2134
+ function I(r, t, e) {
2135
+ return Math.abs(r - t) <= e;
1926
2136
  }
1927
- function Me(s) {
1928
- const e = {}, t = s.document.documentElement.style;
1929
- for (const i in s.document.documentElement.style)
1930
- Object.hasOwn(t, i) && !Number.isNaN(Number.parseInt(i)) && (e[t[i]] = t.getPropertyValue(t[i]));
1931
- return e;
2137
+ function Wt(r) {
2138
+ const t = {}, e = r.document.documentElement.style;
2139
+ for (const i in r.document.documentElement.style)
2140
+ Object.hasOwn(e, i) && !Number.isNaN(Number.parseInt(i)) && (t[e[i]] = e.getPropertyValue(e[i]));
2141
+ return t;
1932
2142
  }
1933
- function at(s, e) {
1934
- const t = Me(s);
1935
- Object.keys(t).forEach((i) => {
1936
- e.hasOwnProperty(i) || oe(s, i);
1937
- }), Object.entries(e).forEach(([i, r]) => {
1938
- t[i] !== r && X(s, i, r);
2143
+ function xe(r, t) {
2144
+ const e = Wt(r);
2145
+ Object.keys(e).forEach((i) => {
2146
+ t.hasOwnProperty(i) || mt(r, i);
2147
+ }), Object.entries(t).forEach(([i, s]) => {
2148
+ e[i] !== s && it(r, i, s);
1939
2149
  });
1940
2150
  }
1941
- function le(s, e) {
1942
- return s.document.documentElement.style.getPropertyValue(e);
2151
+ function gt(r, t) {
2152
+ return r.document.documentElement.style.getPropertyValue(t);
1943
2153
  }
1944
- function X(s, e, t) {
1945
- s.document.documentElement.style.setProperty(e, t);
2154
+ function it(r, t, e) {
2155
+ r.document.documentElement.style.setProperty(t, e);
1946
2156
  }
1947
- function oe(s, e) {
1948
- s.document.documentElement.style.removeProperty(e);
2157
+ function mt(r, t) {
2158
+ r.document.documentElement.style.removeProperty(t);
1949
2159
  }
1950
- let Z = null, he = null, $ = 0;
1951
- const B = { r: 255, g: 255, b: 255, a: 1 }, F = /* @__PURE__ */ new Map(), Lt = () => {
1952
- if (!Z)
2160
+ let rt = null, yt = null, Z = 0;
2161
+ const G = { r: 255, g: 255, b: 255, a: 1 }, V = /* @__PURE__ */ new Map(), je = () => {
2162
+ if (!rt)
1953
2163
  if (typeof OffscreenCanvas < "u")
1954
- Z = new OffscreenCanvas(5, 5), he = Z.getContext("2d", {
2164
+ rt = new OffscreenCanvas(5, 5), yt = rt.getContext("2d", {
1955
2165
  willReadFrequently: !0,
1956
2166
  desynchronized: !0
1957
2167
  });
1958
2168
  else {
1959
- const s = document.createElement("canvas");
1960
- s.width = 5, s.height = 5, Z = s, he = s.getContext("2d", {
2169
+ const r = document.createElement("canvas");
2170
+ r.width = 5, r.height = 5, rt = r, yt = r.getContext("2d", {
1961
2171
  willReadFrequently: !0,
1962
2172
  desynchronized: !0
1963
2173
  });
1964
2174
  }
1965
- return he;
1966
- }, Rt = (s) => {
1967
- if (!s) return !0;
1968
- const e = s.trim().toLowerCase();
1969
- return e.startsWith("var(") || [
2175
+ return yt;
2176
+ }, ti = (r) => {
2177
+ if (!r) return !0;
2178
+ const t = r.trim().toLowerCase();
2179
+ return t.startsWith("var(") || [
1970
2180
  "transparent",
1971
2181
  "currentcolor",
1972
2182
  "inherit",
@@ -1974,86 +2184,86 @@ const B = { r: 255, g: 255, b: 255, a: 1 }, F = /* @__PURE__ */ new Map(), Lt =
1974
2184
  "revert",
1975
2185
  "unset",
1976
2186
  "revert-layer"
1977
- ].includes(e) ? !0 : [
2187
+ ].includes(t) ? !0 : [
1978
2188
  "linear-gradient",
1979
2189
  "radial-gradient",
1980
2190
  "conic-gradient",
1981
2191
  "repeating-linear-gradient",
1982
2192
  "repeating-radial-gradient",
1983
2193
  "repeating-conic-gradient"
1984
- ].some((r) => e.includes(r));
1985
- }, J = (s, e) => {
2194
+ ].some((s) => t.includes(s));
2195
+ }, ot = (r, t) => {
1986
2196
  console.warn(
1987
- `[Decorator] Could not parse color: "${s}". ${e} Falling back to ${JSON.stringify(B)} to compute contrast. Please use a CSS color value that can be computed to RGB(A).`
2197
+ `[Decorator] Could not parse color: "${r}". ${t} Falling back to ${JSON.stringify(G)} to compute contrast. Please use a CSS color value that can be computed to RGB(A).`
1988
2198
  );
1989
- }, de = (s, e = null) => {
1990
- const t = e ? `${s}|${e}` : s, i = F.get(t);
2199
+ }, wt = (r, t = null) => {
2200
+ const e = t ? `${r}|${t}` : r, i = V.get(e);
1991
2201
  if (i !== void 0)
1992
- return i ?? B;
1993
- if (Rt(s))
1994
- return J(s, "Unsupported color format or special value."), F.set(t, null), B;
1995
- const r = Lt();
1996
- if (!r)
1997
- return J(s, "Could not get canvas context."), F.set(t, null), B;
2202
+ return i ?? G;
2203
+ if (ti(r))
2204
+ return ot(r, "Unsupported color format or special value."), V.set(e, null), G;
2205
+ const s = je();
2206
+ if (!s)
2207
+ return ot(r, "Could not get canvas context."), V.set(e, null), G;
1998
2208
  try {
1999
- $ === 0 && r.clearRect(0, 0, 5, 5);
2000
- const n = $ % 5, o = Math.floor($ / 5);
2001
- r.clearRect(n, o, 1, 1), e && (r.fillStyle = e, r.fillRect(n, o, 1, 1)), r.fillStyle = s, r.fillRect(n, o, 1, 1);
2002
- const a = r.getImageData(n, o, 1, 1);
2003
- $ = ($ + 1) % 25;
2004
- const [u, h, c, m] = a.data;
2005
- if (m === 0)
2006
- return J(s, "Fully transparent color."), F.set(t, null), B;
2007
- const d = { r: u, g: h, b: c, a: m / 255 };
2008
- return F.set(t, d), d;
2209
+ Z === 0 && s.clearRect(0, 0, 5, 5);
2210
+ const n = Z % 5, o = Math.floor(Z / 5);
2211
+ s.clearRect(n, o, 1, 1), t && (s.fillStyle = t, s.fillRect(n, o, 1, 1)), s.fillStyle = r, s.fillRect(n, o, 1, 1);
2212
+ const a = s.getImageData(n, o, 1, 1);
2213
+ Z = (Z + 1) % 25;
2214
+ const [d, h, u, g] = a.data;
2215
+ if (g === 0)
2216
+ return ot(r, "Fully transparent color."), V.set(e, null), G;
2217
+ const m = { r: d, g: h, b: u, a: g / 255 };
2218
+ return V.set(e, m), m;
2009
2219
  } catch (n) {
2010
- return J(s, `Error: ${n instanceof Error ? n.message : String(n)}`), F.set(t, null), B;
2011
- }
2012
- }, ce = (s) => {
2013
- const e = s / 255;
2014
- return e <= 0.03928 ? e / 12.92 : Math.pow((e + 0.055) / 1.055, 2.4);
2015
- }, ke = (s) => {
2016
- const e = ce(s.r), t = ce(s.g), i = ce(s.b);
2017
- return 0.2126 * e + 0.7152 * t + 0.0722 * i;
2018
- }, $e = (s, e) => {
2019
- const t = typeof s == "string" ? de(s) : s, i = typeof e == "string" ? de(e) : e, r = ke(t), n = ke(i), o = Math.max(r, n), a = Math.min(r, n);
2220
+ return ot(r, `Error: ${n instanceof Error ? n.message : String(n)}`), V.set(e, null), G;
2221
+ }
2222
+ }, bt = (r) => {
2223
+ const t = r / 255;
2224
+ return t <= 0.03928 ? t / 12.92 : Math.pow((t + 0.055) / 1.055, 2.4);
2225
+ }, re = (r) => {
2226
+ const t = bt(r.r), e = bt(r.g), i = bt(r.b);
2227
+ return 0.2126 * t + 0.7152 * e + 0.0722 * i;
2228
+ }, oe = (r, t) => {
2229
+ const e = typeof r == "string" ? wt(r) : r, i = typeof t == "string" ? wt(t) : t, s = re(e), n = re(i), o = Math.max(s, n), a = Math.min(s, n);
2020
2230
  return (o + 0.05) / (a + 0.05);
2021
- }, pe = (s, e = null) => {
2022
- const t = de(s, e), i = $e(t, { r: 255, g: 255, b: 255, a: 1 }), r = $e(t, { r: 0, g: 0, b: 0, a: 1 });
2023
- return i > r;
2024
- }, It = (s, e = null) => pe(s, e) ? "white" : "black", Ve = "#FFFF00";
2025
- var zt = /* @__PURE__ */ ((s) => (s.Wrap = "wrap", s.Viewport = "viewport", s.Bounds = "bounds", s.Page = "page", s))(zt || {}), Dt = /* @__PURE__ */ ((s) => (s.Boxes = "boxes", s.Bounds = "bounds", s))(Dt || {});
2026
- const Wt = () => "Highlight" in window, qe = ["IMG", "IMAGE", "AUDIO", "VIDEO", "SVG"];
2027
- class Ft {
2231
+ }, St = (r, t = null) => {
2232
+ const e = wt(r, t), i = oe(e, { r: 255, g: 255, b: 255, a: 1 }), s = oe(e, { r: 0, g: 0, b: 0, a: 1 });
2233
+ return i > s;
2234
+ }, ei = (r, t = null) => St(r, t) ? "white" : "black", ae = "#FFFF00";
2235
+ var ii = /* @__PURE__ */ ((r) => (r.Wrap = "wrap", r.Viewport = "viewport", r.Bounds = "bounds", r.Page = "page", r))(ii || {}), si = /* @__PURE__ */ ((r) => (r.Boxes = "boxes", r.Bounds = "bounds", r))(si || {});
2236
+ const ni = () => "Highlight" in window, le = ["IMG", "IMAGE", "AUDIO", "VIDEO", "SVG"];
2237
+ class ri {
2028
2238
  /**
2029
2239
  * Creates a DecorationGroup object
2030
2240
  * @param id Unique HTML ID-adhering name of the group
2031
2241
  * @param name Human-readable name of the group
2032
2242
  */
2033
- constructor(e, t, i, r) {
2034
- this.wnd = e, this.comms = t, this.id = i, this.name = r, this.items = [], this.lastItemId = 0, this.container = void 0, this.activateable = !1, this.experimentalHighlights = !1, this.currentRender = 0, Wt() && (this.experimentalHighlights = !0, this.notTextFlag = /* @__PURE__ */ new Map());
2243
+ constructor(t, e, i, s) {
2244
+ this.wnd = t, this.comms = e, this.id = i, this.name = s, this.items = [], this.lastItemId = 0, this.container = void 0, this.activateable = !1, this.experimentalHighlights = !1, this.currentRender = 0, ni() && (this.experimentalHighlights = !0, this.notTextFlag = /* @__PURE__ */ new Map());
2035
2245
  }
2036
2246
  get activeable() {
2037
2247
  return this.activateable;
2038
2248
  }
2039
- set activeable(e) {
2040
- this.activateable = e;
2249
+ set activeable(t) {
2250
+ this.activateable = t;
2041
2251
  }
2042
2252
  /**
2043
2253
  * Adds a new decoration to the group.
2044
2254
  * @param decoration Decoration to add
2045
2255
  */
2046
- add(e) {
2047
- const t = `${this.id}-${this.lastItemId++}`, i = ne(this.wnd.document, e.locator);
2256
+ add(t) {
2257
+ const e = `${this.id}-${this.lastItemId++}`, i = pt(this.wnd.document, t.locator);
2048
2258
  if (!i) {
2049
- this.comms.log("Can't locate DOM range for decoration", e);
2259
+ this.comms.log("Can't locate DOM range for decoration", t);
2050
2260
  return;
2051
2261
  }
2052
- const r = i.commonAncestorContainer;
2053
- r.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (qe.includes(r.nodeName.toUpperCase()) && this.notTextFlag?.set(t, !0), i.cloneContents().querySelector(qe.join(", ").toLowerCase()) && this.notTextFlag?.set(t, !0), (r.textContent?.trim() || "").length === 0 && this.notTextFlag?.set(t, !0));
2262
+ const s = i.commonAncestorContainer;
2263
+ s.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (le.includes(s.nodeName.toUpperCase()) && this.notTextFlag?.set(e, !0), i.cloneContents().querySelector(le.join(", ").toLowerCase()) && this.notTextFlag?.set(e, !0), (s.textContent?.trim() || "").length === 0 && this.notTextFlag?.set(e, !0));
2054
2264
  const n = {
2055
- decoration: e,
2056
- id: t,
2265
+ decoration: t,
2266
+ id: e,
2057
2267
  range: i
2058
2268
  };
2059
2269
  this.items.push(n), this.layout(n), this.renderLayout([n]);
@@ -2062,18 +2272,18 @@ class Ft {
2062
2272
  * Removes the decoration with given ID from the group.
2063
2273
  * @param identifier ID of item to remove
2064
2274
  */
2065
- remove(e) {
2066
- const t = this.items.findIndex((r) => r.decoration.id === e);
2067
- if (t < 0) return;
2068
- const i = this.items[t];
2069
- this.items.splice(t, 1), i.clickableElements = void 0, i.container && (i.container.remove(), i.container = void 0), this.experimentalHighlights && !this.notTextFlag?.has(i.id) && this.wnd.CSS.highlights.get(this.id)?.delete(i.range), this.notTextFlag?.delete(i.id);
2275
+ remove(t) {
2276
+ const e = this.items.findIndex((s) => s.decoration.id === t);
2277
+ if (e < 0) return;
2278
+ const i = this.items[e];
2279
+ this.items.splice(e, 1), i.clickableElements = void 0, i.container && (i.container.remove(), i.container = void 0), this.experimentalHighlights && !this.notTextFlag?.has(i.id) && this.wnd.CSS.highlights.get(this.id)?.delete(i.range), this.notTextFlag?.delete(i.id);
2070
2280
  }
2071
2281
  /**
2072
2282
  * Notifies that the given decoration was modified and needs to be updated.
2073
2283
  * @param decoration Decoration to update
2074
2284
  */
2075
- update(e) {
2076
- this.remove(e.id), this.add(e);
2285
+ update(t) {
2286
+ this.remove(t.id), this.add(t);
2077
2287
  }
2078
2288
  /**
2079
2289
  * Removes all decorations from this group.
@@ -2086,15 +2296,15 @@ class Ft {
2086
2296
  * To be called after reflowing the resource, for example.
2087
2297
  */
2088
2298
  requestLayout() {
2089
- this.wnd.cancelAnimationFrame(this.currentRender), this.clearContainer(), this.items.forEach((e) => this.layout(e)), this.renderLayout(this.items);
2299
+ this.wnd.cancelAnimationFrame(this.currentRender), this.clearContainer(), this.items.forEach((t) => this.layout(t)), this.renderLayout(this.items);
2090
2300
  }
2091
- experimentalLayout(e) {
2092
- const [t, i] = this.requireContainer(!0);
2093
- i.add(e.range);
2094
- const r = le(this.wnd, "--USER__backgroundColor") || this.wnd.getComputedStyle(this.wnd.document.documentElement).getPropertyValue("background-color"), n = e.decoration?.style?.tint ?? Ve;
2095
- t.innerHTML = `
2301
+ experimentalLayout(t) {
2302
+ const [e, i] = this.requireContainer(!0);
2303
+ i.add(t.range);
2304
+ const s = gt(this.wnd, "--USER__backgroundColor") || this.wnd.getComputedStyle(this.wnd.document.documentElement).getPropertyValue("background-color"), n = t.decoration?.style?.tint ?? ae;
2305
+ e.innerHTML = `
2096
2306
  ::highlight(${this.id}) {
2097
- color: ${It(n, r)};
2307
+ color: ${ei(n, s)};
2098
2308
  background-color: ${n};
2099
2309
  }`;
2100
2310
  }
@@ -2102,84 +2312,84 @@ class Ft {
2102
2312
  * Layouts a single DecorationItem.
2103
2313
  * @param item
2104
2314
  */
2105
- layout(e) {
2106
- if (this.experimentalHighlights && !this.notTextFlag?.has(e.id))
2107
- return this.experimentalLayout(e);
2108
- const t = this.wnd.document.createElement("div");
2109
- t.setAttribute("id", e.id), t.dataset.highlightId = e.decoration.id, t.style.setProperty("pointer-events", "none");
2110
- const i = this.wnd.innerWidth, r = parseInt(
2315
+ layout(t) {
2316
+ if (this.experimentalHighlights && !this.notTextFlag?.has(t.id))
2317
+ return this.experimentalLayout(t);
2318
+ const e = this.wnd.document.createElement("div");
2319
+ e.setAttribute("id", t.id), e.dataset.highlightId = t.decoration.id, e.style.setProperty("pointer-events", "none");
2320
+ const i = this.wnd.innerWidth, s = parseInt(
2111
2321
  getComputedStyle(this.wnd.document.documentElement).getPropertyValue(
2112
2322
  "column-count"
2113
2323
  )
2114
- ), n = i / (r || 1), o = this.wnd.document.scrollingElement, a = o.scrollLeft, u = o.scrollTop, h = (p, f, g) => {
2115
- if (p.style.position = "absolute", e.decoration?.style?.width === "viewport") {
2116
- p.style.width = `${i}px`, p.style.height = `${f.height}px`;
2117
- let E = Math.floor(f.left / i) * i;
2118
- p.style.left = `${E + a}px`, p.style.top = `${f.top + u}px`;
2119
- } else if (e.decoration?.style?.width === "bounds")
2120
- p.style.width = `${g.width}px`, p.style.height = `${f.height}px`, p.style.left = `${g.left + a}px`, p.style.top = `${f.top + u}px`;
2121
- else if (e.decoration?.style?.width === "page") {
2122
- p.style.width = `${n}px`, p.style.height = `${f.height}px`;
2123
- let E = Math.floor(f.left / n) * n;
2124
- p.style.left = `${E + a}px`, p.style.top = `${f.top + u}px`;
2324
+ ), n = i / (s || 1), o = this.wnd.document.scrollingElement, a = o.scrollLeft, d = o.scrollTop, h = (f, p, b) => {
2325
+ if (f.style.position = "absolute", t.decoration?.style?.width === "viewport") {
2326
+ f.style.width = `${i}px`, f.style.height = `${p.height}px`;
2327
+ let x = Math.floor(p.left / i) * i;
2328
+ f.style.left = `${x + a}px`, f.style.top = `${p.top + d}px`;
2329
+ } else if (t.decoration?.style?.width === "bounds")
2330
+ f.style.width = `${b.width}px`, f.style.height = `${p.height}px`, f.style.left = `${b.left + a}px`, f.style.top = `${p.top + d}px`;
2331
+ else if (t.decoration?.style?.width === "page") {
2332
+ f.style.width = `${n}px`, f.style.height = `${p.height}px`;
2333
+ let x = Math.floor(p.left / n) * n;
2334
+ f.style.left = `${x + a}px`, f.style.top = `${p.top + d}px`;
2125
2335
  } else
2126
- p.style.width = `${f.width}px`, p.style.height = `${f.height}px`, p.style.left = `${f.left + a}px`, p.style.top = `${f.top + u}px`;
2127
- }, c = e.range.getBoundingClientRect();
2128
- let m = this.wnd.document.createElement("template");
2129
- const d = this.getCurrentDarkMode();
2130
- m.innerHTML = `
2336
+ f.style.width = `${p.width}px`, f.style.height = `${p.height}px`, f.style.left = `${p.left + a}px`, f.style.top = `${p.top + d}px`;
2337
+ }, u = t.range.getBoundingClientRect();
2338
+ let g = this.wnd.document.createElement("template");
2339
+ const m = this.getCurrentDarkMode();
2340
+ g.innerHTML = `
2131
2341
  <div
2132
2342
  data-readium="true"
2133
2343
  class="readium-highlight"
2134
2344
  style="${[
2135
- `background-color: ${e.decoration?.style?.tint ?? Ve} !important`,
2345
+ `background-color: ${t.decoration?.style?.tint ?? ae} !important`,
2136
2346
  //"opacity: 0.3 !important",
2137
- `mix-blend-mode: ${d ? "exclusion" : "multiply"} !important`,
2347
+ `mix-blend-mode: ${m ? "exclusion" : "multiply"} !important`,
2138
2348
  "opacity: 1 !important",
2139
2349
  "box-sizing: border-box !important"
2140
2350
  ].join("; ")}"
2141
2351
  >
2142
2352
  </div>
2143
2353
  `.trim();
2144
- const y = m.content.firstElementChild;
2145
- if (e.decoration?.style?.layout === "bounds") {
2146
- const p = y.cloneNode(!0);
2147
- p.style.setProperty("pointer-events", "none"), h(p, c, c), t.append(p);
2354
+ const v = g.content.firstElementChild;
2355
+ if (t.decoration?.style?.layout === "bounds") {
2356
+ const f = v.cloneNode(!0);
2357
+ f.style.setProperty("pointer-events", "none"), h(f, u, u), e.append(f);
2148
2358
  } else {
2149
- let p = Pt(
2150
- e.range
2359
+ let f = qe(
2360
+ t.range
2151
2361
  );
2152
- p = p.sort((f, g) => f.top < g.top ? -1 : f.top > g.top ? 1 : 0);
2153
- for (let f of p) {
2154
- const g = y.cloneNode(!0);
2155
- g.style.setProperty("pointer-events", "none"), h(g, f, c), t.append(g);
2362
+ f = f.sort((p, b) => p.top < b.top ? -1 : p.top > b.top ? 1 : 0);
2363
+ for (let p of f) {
2364
+ const b = v.cloneNode(!0);
2365
+ b.style.setProperty("pointer-events", "none"), h(b, p, u), e.append(b);
2156
2366
  }
2157
2367
  }
2158
- e.container = t, e.clickableElements = Array.from(
2159
- t.querySelectorAll("[data-activable='1']")
2160
- ), e.clickableElements.length || (e.clickableElements = Array.from(t.children));
2368
+ t.container = e, t.clickableElements = Array.from(
2369
+ e.querySelectorAll("[data-activable='1']")
2370
+ ), t.clickableElements.length || (t.clickableElements = Array.from(e.children));
2161
2371
  }
2162
- renderLayout(e) {
2372
+ renderLayout(t) {
2163
2373
  this.wnd.cancelAnimationFrame(this.currentRender), this.currentRender = this.wnd.requestAnimationFrame(() => {
2164
- if (e = e.filter((i) => !this.experimentalHighlights || !!this.notTextFlag?.has(i.id)), !e || e.length === 0) return;
2165
- this.requireContainer().append(...e.map((i) => i.container).filter((i) => !!i));
2374
+ if (t = t.filter((i) => !this.experimentalHighlights || !!this.notTextFlag?.has(i.id)), !t || t.length === 0) return;
2375
+ this.requireContainer().append(...t.map((i) => i.container).filter((i) => !!i));
2166
2376
  });
2167
2377
  }
2168
2378
  /**
2169
2379
  * Returns the group container element, after making sure it exists.
2170
2380
  * @returns Group's container
2171
2381
  */
2172
- requireContainer(e = !1) {
2173
- if (e) {
2174
- let t;
2175
- this.wnd.document.getElementById(`${this.id}-style`) ? t = this.wnd.document.getElementById(`${this.id}-style`) : (t = this.wnd.document.createElement("style"), t.dataset.readium = "true", t.id = `${this.id}-style`, this.wnd.document.head.appendChild(t));
2382
+ requireContainer(t = !1) {
2383
+ if (t) {
2384
+ let e;
2385
+ this.wnd.document.getElementById(`${this.id}-style`) ? e = this.wnd.document.getElementById(`${this.id}-style`) : (e = this.wnd.document.createElement("style"), e.dataset.readium = "true", e.id = `${this.id}-style`, this.wnd.document.head.appendChild(e));
2176
2386
  let i;
2177
- return this.wnd.CSS.highlights.has(this.id) ? i = this.wnd.CSS.highlights.get(this.id) : (i = new this.wnd.Highlight(), this.wnd.CSS.highlights.set(this.id, i)), [t, i];
2387
+ return this.wnd.CSS.highlights.has(this.id) ? i = this.wnd.CSS.highlights.get(this.id) : (i = new this.wnd.Highlight(), this.wnd.CSS.highlights.set(this.id, i)), [e, i];
2178
2388
  }
2179
2389
  return this.container || (this.container = this.wnd.document.createElement("div"), this.container.setAttribute("id", this.id), this.container.dataset.group = this.name, this.container.dataset.readium = "true", this.container.style.setProperty("pointer-events", "none"), this.container.style.display = "contents", this.wnd.document.body.append(this.container)), this.container;
2180
2390
  }
2181
2391
  getCurrentDarkMode() {
2182
- return le(this.wnd, "--USER__appearance") === "readium-night-on" || pe(le(this.wnd, "--USER__backgroundColor")) || pe(this.wnd.getComputedStyle(this.wnd.document.documentElement).getPropertyValue("background-color"));
2392
+ return gt(this.wnd, "--USER__appearance") === "readium-night-on" || St(gt(this.wnd, "--USER__backgroundColor")) || St(this.wnd.getComputedStyle(this.wnd.document.documentElement).getPropertyValue("background-color"));
2183
2393
  }
2184
2394
  /**
2185
2395
  * Removes the group container.
@@ -2188,36 +2398,36 @@ class Ft {
2188
2398
  this.experimentalHighlights && this.wnd.CSS.highlights.delete(this.id), this.container && (this.container.remove(), this.container = void 0);
2189
2399
  }
2190
2400
  }
2191
- const q = class q extends Y {
2401
+ const Q = class Q extends X {
2192
2402
  constructor() {
2193
2403
  super(...arguments), this.resizeFrame = 0, this.lastGroupId = 0, this.groups = /* @__PURE__ */ new Map(), this.handleResizer = this.handleResize.bind(this);
2194
2404
  }
2195
2405
  cleanup() {
2196
- this.groups.forEach((e) => e.clear()), this.groups.clear();
2406
+ this.groups.forEach((t) => t.clear()), this.groups.clear();
2197
2407
  }
2198
2408
  updateHighlightStyles() {
2199
- this.groups.forEach((e) => {
2200
- e.requestLayout();
2409
+ this.groups.forEach((t) => {
2410
+ t.requestLayout();
2201
2411
  });
2202
2412
  }
2203
- extractCustomProperty(e, t) {
2204
- if (!e) return null;
2205
- const i = e.match(new RegExp(`${t}:\\s*([^;]+)`));
2413
+ extractCustomProperty(t, e) {
2414
+ if (!t) return null;
2415
+ const i = t.match(new RegExp(`${e}:\\s*([^;]+)`));
2206
2416
  return i ? i[1].trim() : null;
2207
2417
  }
2208
2418
  handleResize() {
2209
2419
  this.wnd.clearTimeout(this.resizeFrame), this.resizeFrame = this.wnd.setTimeout(() => {
2210
- this.groups.forEach((e) => {
2211
- e.experimentalHighlights || e.requestLayout();
2420
+ this.groups.forEach((t) => {
2421
+ t.experimentalHighlights || t.requestLayout();
2212
2422
  });
2213
2423
  }, 50);
2214
2424
  }
2215
- mount(e, t) {
2216
- return this.wnd = e, t.register("decorate", q.moduleName, (i, r) => {
2425
+ mount(t, e) {
2426
+ return this.wnd = t, e.register("decorate", Q.moduleName, (i, s) => {
2217
2427
  const n = i;
2218
- n.decoration && n.decoration.locator && (n.decoration.locator = R.deserialize(n.decoration.locator)), this.groups.has(n.group) || this.groups.set(n.group, new Ft(
2219
- e,
2428
+ n.decoration && n.decoration.locator && (n.decoration.locator = W.deserialize(n.decoration.locator)), this.groups.has(n.group) || this.groups.set(n.group, new ri(
2220
2429
  t,
2430
+ e,
2221
2431
  `readium-decoration-${this.lastGroupId++}`,
2222
2432
  n.group
2223
2433
  ));
@@ -2236,29 +2446,29 @@ const q = class q extends Y {
2236
2446
  o?.update(n.decoration);
2237
2447
  break;
2238
2448
  }
2239
- r(!0);
2240
- }), this.resizeObserver = new ResizeObserver(() => e.requestAnimationFrame(() => this.handleResize())), this.resizeObserver.observe(e.document.body), e.addEventListener("orientationchange", this.handleResizer), e.addEventListener("resize", this.handleResizer), this.backgroundObserver = new MutationObserver((i) => {
2449
+ s(!0);
2450
+ }), this.resizeObserver = new ResizeObserver(() => t.requestAnimationFrame(() => this.handleResize())), this.resizeObserver.observe(t.document.body), t.addEventListener("orientationchange", this.handleResizer), t.addEventListener("resize", this.handleResizer), this.backgroundObserver = new MutationObserver((i) => {
2241
2451
  i.some((n) => {
2242
2452
  if (n.type === "attributes" && n.attributeName === "style") {
2243
- const o = n.target, a = n.oldValue, u = o.getAttribute("style"), h = this.extractCustomProperty(a, "--USER__appearance"), c = this.extractCustomProperty(u, "--USER__appearance"), m = this.extractCustomProperty(a, "--USER__backgroundColor"), d = this.extractCustomProperty(u, "--USER__backgroundColor");
2244
- return h !== c || m !== d;
2453
+ const o = n.target, a = n.oldValue, d = o.getAttribute("style"), h = this.extractCustomProperty(a, "--USER__appearance"), u = this.extractCustomProperty(d, "--USER__appearance"), g = this.extractCustomProperty(a, "--USER__backgroundColor"), m = this.extractCustomProperty(d, "--USER__backgroundColor");
2454
+ return h !== u || g !== m;
2245
2455
  }
2246
2456
  return !1;
2247
2457
  }) && this.updateHighlightStyles();
2248
- }), this.backgroundObserver.observe(e.document.documentElement, {
2458
+ }), this.backgroundObserver.observe(t.document.documentElement, {
2249
2459
  attributes: !0,
2250
2460
  attributeFilter: ["style"],
2251
2461
  attributeOldValue: !0,
2252
2462
  subtree: !0
2253
- }), t.log("Decorator Mounted"), !0;
2463
+ }), e.log("Decorator Mounted"), !0;
2254
2464
  }
2255
- unmount(e, t) {
2256
- return e.removeEventListener("orientationchange", this.handleResizer), e.removeEventListener("resize", this.handleResizer), t.unregisterAll(q.moduleName), this.resizeObserver.disconnect(), this.backgroundObserver.disconnect(), this.cleanup(), t.log("Decorator Unmounted"), !0;
2465
+ unmount(t, e) {
2466
+ return t.removeEventListener("orientationchange", this.handleResizer), t.removeEventListener("resize", this.handleResizer), e.unregisterAll(Q.moduleName), this.resizeObserver.disconnect(), this.backgroundObserver.disconnect(), this.cleanup(), e.log("Decorator Unmounted"), !0;
2257
2467
  }
2258
2468
  };
2259
- q.moduleName = "decorator";
2260
- let fe = q;
2261
- const je = "readium-snapper-style", j = class j extends Y {
2469
+ Q.moduleName = "decorator";
2470
+ let Et = Q;
2471
+ const ce = "readium-snapper-style", j = class j extends X {
2262
2472
  constructor() {
2263
2473
  super(...arguments), this.protected = !1;
2264
2474
  }
@@ -2269,61 +2479,61 @@ const je = "readium-snapper-style", j = class j extends Y {
2269
2479
  user-select: ${this.protected ? "none" : "auto"};
2270
2480
  }`;
2271
2481
  }
2272
- mount(e, t) {
2273
- const i = e.document.createElement("style");
2274
- return i.dataset.readium = "true", i.id = je, i.textContent = this.buildStyles(), e.document.head.appendChild(i), t.register("protect", j.moduleName, (r, n) => {
2482
+ mount(t, e) {
2483
+ const i = t.document.createElement("style");
2484
+ return i.dataset.readium = "true", i.id = ce, i.textContent = this.buildStyles(), t.document.head.appendChild(i), e.register("protect", j.moduleName, (s, n) => {
2275
2485
  this.protected = !0, i.textContent = this.buildStyles(), n(!0);
2276
- }), t.register("unprotect", j.moduleName, (r, n) => {
2486
+ }), e.register("unprotect", j.moduleName, (s, n) => {
2277
2487
  this.protected = !1, i.textContent = this.buildStyles(), n(!0);
2278
- }), t.log("Snapper Mounted"), !0;
2488
+ }), e.log("Snapper Mounted"), !0;
2279
2489
  }
2280
- unmount(e, t) {
2281
- return e.document.getElementById(je)?.remove(), t.log("Snapper Unmounted"), !0;
2490
+ unmount(t, e) {
2491
+ return t.document.getElementById(ce)?.remove(), e.log("Snapper Unmounted"), !0;
2282
2492
  }
2283
2493
  };
2284
2494
  j.moduleName = "snapper";
2285
- let G = j;
2286
- function z(s) {
2287
- return s.document.body.dir.toLowerCase() === "rtl";
2495
+ let st = j;
2496
+ function B(r) {
2497
+ return r.document.body.dir.toLowerCase() === "rtl";
2288
2498
  }
2289
- function lt(s) {
2499
+ function Te(r) {
2290
2500
  return parseInt(
2291
- s.getComputedStyle(
2292
- s.document.documentElement
2501
+ r.getComputedStyle(
2502
+ r.document.documentElement
2293
2503
  ).getPropertyValue("column-count")
2294
2504
  );
2295
2505
  }
2296
- function _e(s) {
2297
- const e = getComputedStyle(s), t = parseFloat(e.paddingTop || "0"), i = parseFloat(e.paddingBottom || "0");
2298
- return s.clientHeight - t - i;
2506
+ function he(r) {
2507
+ const t = getComputedStyle(r), e = parseFloat(t.paddingTop || "0"), i = parseFloat(t.paddingBottom || "0");
2508
+ return r.clientHeight - e - i;
2299
2509
  }
2300
- function Xe(s) {
2301
- const e = lt(s);
2302
- if (!e)
2510
+ function de(r) {
2511
+ const t = Te(r);
2512
+ if (!t)
2303
2513
  return !1;
2304
- const t = s.document.querySelectorAll("div[id^='readium-virtual-page']");
2305
- for (const h of t)
2514
+ const e = r.document.querySelectorAll("div[id^='readium-virtual-page']");
2515
+ for (const h of e)
2306
2516
  h.remove();
2307
- const i = t.length, r = s.document.scrollingElement.scrollWidth, n = s.visualViewport.width, a = Math.round(r / n * e) % e, u = e === 1 || a === 0 ? 0 : e - a;
2308
- if (u > 0)
2309
- for (let h = 0; h < u; h++) {
2310
- const c = s.document.createElement("div");
2311
- c.setAttribute("id", `readium-virtual-page-${h}`), c.dataset.readium = "true", CSS.supports("break-before", "column") ? c.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (c.style.breakInside = "avoid-column"), c.style.height = _e(s.document.documentElement) + "px"), c.innerHTML = "&#8203;", s.document.body.appendChild(c);
2517
+ const i = e.length, s = r.document.scrollingElement.scrollWidth, n = r.visualViewport.width, a = Math.round(s / n * t) % t, d = t === 1 || a === 0 ? 0 : t - a;
2518
+ if (d > 0)
2519
+ for (let h = 0; h < d; h++) {
2520
+ const u = r.document.createElement("div");
2521
+ u.setAttribute("id", `readium-virtual-page-${h}`), u.dataset.readium = "true", CSS.supports("break-before", "column") ? u.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (u.style.breakInside = "avoid-column"), u.style.height = he(r.document.documentElement) + "px"), u.innerHTML = "&#8203;", r.document.body.appendChild(u);
2312
2522
  }
2313
- return i !== u;
2523
+ return i !== d;
2314
2524
  }
2315
- function ht(s) {
2316
- const e = s.document.createElement("style");
2317
- e.appendChild(s.document.createTextNode("*{}")), s.document.body.appendChild(e), s.document.body.removeChild(e);
2525
+ function Pe(r) {
2526
+ const t = r.document.createElement("style");
2527
+ t.appendChild(r.document.createTextNode("*{}")), r.document.body.appendChild(t), r.document.body.removeChild(t);
2318
2528
  }
2319
- function Ut(s) {
2320
- return s < 0.5 ? 2 * s * s : -1 + (4 - 2 * s) * s;
2529
+ function oi(r) {
2530
+ return r < 0.5 ? 2 * r * r : -1 + (4 - 2 * r) * r;
2321
2531
  }
2322
- function v(s) {
2323
- const e = s.getSelection();
2324
- e && e.removeAllRanges();
2532
+ function A(r) {
2533
+ const t = r.getSelection();
2534
+ t && t.removeAllRanges();
2325
2535
  }
2326
- const Bt = [
2536
+ const ai = [
2327
2537
  "a",
2328
2538
  "audio",
2329
2539
  "button",
@@ -2337,58 +2547,124 @@ const Bt = [
2337
2547
  "textarea",
2338
2548
  "video"
2339
2549
  ];
2340
- function ct(s) {
2341
- return Bt.indexOf(s.nodeName.toLowerCase()) !== -1 || s.hasAttribute("contenteditable") && s.getAttribute("contenteditable")?.toLowerCase() !== "false" ? s : s.parentElement ? ct(s.parentElement) : null;
2550
+ function Ne(r) {
2551
+ return ai.indexOf(r.nodeName.toLowerCase()) !== -1 || r.hasAttribute("contenteditable") && r.getAttribute("contenteditable")?.toLowerCase() !== "false" ? r : r.parentElement ? Ne(r.parentElement) : null;
2342
2552
  }
2343
- function Ne(s, e) {
2344
- const t = ut(s, s.document.body, e), i = s._readium_cssSelectorGenerator.getCssSelector(t, {
2553
+ function Ut(r, t) {
2554
+ const e = Le(r, r.document.body, t), i = r._readium_cssSelectorGenerator.getCssSelector(e, {
2345
2555
  selectors: ["tag", "id", "class", "nthchild", "nthoftype", "attribute"]
2346
2556
  });
2347
- return new R({
2557
+ return new W({
2348
2558
  href: "#",
2349
2559
  type: "application/xhtml+xml",
2350
- locations: new b({
2560
+ locations: new C({
2351
2561
  otherLocations: /* @__PURE__ */ new Map([
2352
2562
  ["cssSelector", i]
2353
2563
  ])
2354
2564
  }),
2355
- text: new D({
2356
- highlight: t.textContent || void 0
2565
+ text: new H({
2566
+ highlight: e.textContent || void 0
2357
2567
  })
2358
2568
  });
2359
2569
  }
2360
- function ut(s, e, t) {
2361
- for (var i = 0; i < e.children.length; i++) {
2362
- const r = e.children[i];
2363
- if (!$t(r) && Ht(s, r, t))
2364
- return kt(s, r) ? r : ut(s, r, t);
2570
+ function Le(r, t, e) {
2571
+ for (var i = 0; i < t.children.length; i++) {
2572
+ const s = t.children[i];
2573
+ if (!hi(s) && li(r, s, e))
2574
+ return ci(r, s) ? s : Le(r, s, e);
2365
2575
  }
2366
- return e;
2576
+ return t;
2367
2577
  }
2368
- function Ht(s, e, t) {
2369
- if (e === document.body || e === document.documentElement)
2578
+ function li(r, t, e) {
2579
+ if (t === document.body || t === document.documentElement)
2370
2580
  return !0;
2371
2581
  if (!document || !document.documentElement || !document.body)
2372
2582
  return !1;
2373
- const i = e.getBoundingClientRect();
2374
- return t ? i.bottom > 0 && i.top < s.innerHeight : i.right > 0 && i.left < s.innerWidth;
2375
- }
2376
- function kt(s, e) {
2377
- const t = e.getBoundingClientRect();
2378
- return t.top >= 0 && t.left >= 0 && t.bottom <= s.innerHeight && t.right <= s.innerWidth;
2379
- }
2380
- function $t(s) {
2381
- const e = getComputedStyle(s);
2382
- if (e) {
2383
- const t = e.getPropertyValue("display");
2384
- if (t != "block" && t != "list-item" || e.getPropertyValue("opacity") === "0")
2583
+ const i = t.getBoundingClientRect();
2584
+ return e ? i.bottom > 0 && i.top < r.innerHeight : i.right > 0 && i.left < r.innerWidth;
2585
+ }
2586
+ function ci(r, t) {
2587
+ const e = t.getBoundingClientRect();
2588
+ return e.top >= 0 && e.left >= 0 && e.bottom <= r.innerHeight && e.right <= r.innerWidth;
2589
+ }
2590
+ function hi(r) {
2591
+ const t = getComputedStyle(r);
2592
+ if (t) {
2593
+ const e = t.getPropertyValue("display");
2594
+ if (e != "block" && e != "list-item" || t.getPropertyValue("opacity") === "0")
2385
2595
  return !0;
2386
2596
  }
2387
2597
  return !1;
2388
2598
  }
2389
- const Ge = "readium-column-snapper-style", Vt = 200, x = class x extends G {
2599
+ const di = {
2600
+ maxVelocity: 200,
2601
+ // Reasonable default for human-like scrolling (pixels/ms)
2602
+ minVariance: 0.01,
2603
+ // Default variance threshold
2604
+ historySize: 20,
2605
+ // Balanced history size for performance
2606
+ minDirectionChanges: 0.2,
2607
+ // Reasonable default for detecting patterns
2608
+ maxConsistentScrolls: 15
2609
+ // Balanced threshold for flagging
2610
+ }, Oe = {
2611
+ maxVelocity: 200,
2612
+ // Extremely fast scrolling (pixels/ms)
2613
+ minVariance: 1e-5,
2614
+ // Near-perfect consistency
2615
+ historySize: 100,
2616
+ // Large history window
2617
+ minDirectionChanges: 0.1,
2618
+ // Only trigger on near-perfect patterns
2619
+ maxConsistentScrolls: 20
2620
+ // Need many consistent scrolls
2621
+ }, Re = {
2622
+ maxSelectionsPerSecond: 500,
2623
+ minVariance: 50,
2624
+ historySize: 20
2625
+ }, ui = {
2626
+ enabled: !0,
2627
+ maxSelectionPercent: 0.1,
2628
+ minThreshold: 100,
2629
+ absoluteMaxChars: 5e3,
2630
+ historySize: 20
2631
+ };
2632
+ class Bt {
2633
+ constructor(t = {}) {
2634
+ this.history = [], this.consistentScrollCount = 0, this.options = { ...di, ...t };
2635
+ }
2636
+ analyze(t, e, i) {
2637
+ if (i <= 0) return !1;
2638
+ const s = Math.abs(e) / i, n = Date.now();
2639
+ if (this.history.push({
2640
+ timestamp: n,
2641
+ direction: t,
2642
+ velocity: s,
2643
+ distance: Math.abs(e)
2644
+ }), this.history = this.history.filter((p) => n - p.timestamp < 2e3).slice(-(this.options.historySize || 20)), this.history.length < 3) return !1;
2645
+ if (s > this.options.maxVelocity)
2646
+ return this.resetAfterDetection(), !0;
2647
+ const o = this.history.map((p) => p.velocity), a = this.history.map((p) => p.distance), d = o.reduce((p, b) => p + b, 0) / o.length, h = a.reduce((p, b) => p + b, 0) / a.length, u = o.reduce((p, b) => p + Math.pow(b - d, 2), 0) / o.length, g = a.reduce((p, b) => p + Math.pow(b - h, 2), 0) / a.length;
2648
+ if (u < this.options.minVariance && g < h * 0.1) {
2649
+ if (this.consistentScrollCount++, this.consistentScrollCount >= (this.options.maxConsistentScrolls || 10))
2650
+ return this.resetAfterDetection(), !0;
2651
+ } else
2652
+ this.consistentScrollCount = Math.max(0, this.consistentScrollCount - 1);
2653
+ let m = 0, v = this.history[0].direction;
2654
+ for (let p = 1; p < this.history.length; p++)
2655
+ this.history[p].direction !== v && (m++, v = this.history[p].direction);
2656
+ return m / this.history.length > (this.options.minDirectionChanges || 0.3) ? (this.resetAfterDetection(), !0) : !1;
2657
+ }
2658
+ resetAfterDetection() {
2659
+ this.history = this.history.slice(-3), this.consistentScrollCount = 0;
2660
+ }
2661
+ clear() {
2662
+ this.history = [], this.consistentScrollCount = 0;
2663
+ }
2664
+ }
2665
+ const ue = "readium-column-snapper-style", pi = 200, P = class P extends st {
2390
2666
  constructor() {
2391
- super(...arguments), this.shakeTimeout = 0, this.snappingCancelled = !1, this.alreadyScrollLeft = 0, this.overscroll = 0, this.cachedScrollWidth = 0, this.touchState = 0, this.startingX = void 0, this.endingX = void 0, this.onTouchStarter = this.onTouchStart.bind(this), this.onTouchEnder = this.onTouchEnd.bind(this), this.onWidthChanger = this.onWidthChange.bind(this), this.onTouchMover = this.onTouchMove.bind(this);
2667
+ super(...arguments), this.isSnapProtectionEnabled = !1, this.patternAnalyzer = null, this.lastTurnTime = 0, this.shakeTimeout = 0, this.snappingCancelled = !1, this.alreadyScrollLeft = 0, this.overscroll = 0, this.cachedScrollWidth = 0, this.touchState = 0, this.startingX = void 0, this.endingX = void 0, this.onTouchStarter = this.onTouchStart.bind(this), this.onTouchEnder = this.onTouchEnd.bind(this), this.onWidthChanger = this.onWidthChange.bind(this), this.onTouchMover = this.onTouchMove.bind(this);
2392
2668
  }
2393
2669
  doc() {
2394
2670
  return this.wnd.document.scrollingElement;
@@ -2396,55 +2672,55 @@ const Ge = "readium-column-snapper-style", Vt = 200, x = class x extends G {
2396
2672
  scrollOffset() {
2397
2673
  return this.doc().scrollLeft > 0 ? this.doc().scrollLeft : this.alreadyScrollLeft;
2398
2674
  }
2399
- snapOffset(e) {
2400
- const t = e + (z(this.wnd) ? -1 : 1);
2401
- return t - t % this.wnd.innerWidth;
2675
+ snapOffset(t) {
2676
+ const e = t + (B(this.wnd) ? -1 : 1);
2677
+ return e - e % this.wnd.innerWidth;
2402
2678
  }
2403
2679
  reportProgress() {
2404
- const e = this.wnd.scrollX, t = this.cachedScrollWidth, i = Math.max(0, Math.min(1, e / t)), r = Math.max(0, Math.min(1, (e + this.wnd.innerWidth) / t));
2680
+ const t = this.wnd.scrollX, e = this.cachedScrollWidth, i = Math.max(0, Math.min(1, t / e)), s = Math.max(0, Math.min(1, (t + this.wnd.innerWidth) / e));
2405
2681
  this.comms.send("progress", {
2406
2682
  start: i,
2407
- end: r
2683
+ end: s
2408
2684
  });
2409
2685
  }
2410
2686
  shake() {
2411
2687
  if (this.overscroll !== 0 || this.shakeTimeout !== 0) return;
2412
- const e = this.doc();
2413
- e.classList.add(z(this.wnd) ? "readium-bounce-l" : "readium-bounce-r");
2414
- const t = this.scrollOffset();
2688
+ const t = this.doc();
2689
+ t.classList.add(B(this.wnd) ? "readium-bounce-l" : "readium-bounce-r");
2690
+ const e = this.scrollOffset();
2415
2691
  this.shakeTimeout = this.wnd.setTimeout(() => {
2416
- e.classList.remove("readium-bounce-l"), e.classList.remove("readium-bounce-r"), this.shakeTimeout = 0, this.doc().scrollLeft = t;
2692
+ t.classList.remove("readium-bounce-l"), t.classList.remove("readium-bounce-r"), this.shakeTimeout = 0, this.doc().scrollLeft = e;
2417
2693
  }, 150);
2418
2694
  }
2419
2695
  // We have to cache this because during overscroll (transform, or left) the width is incorrect due to browser
2420
2696
  takeOverSnap() {
2421
2697
  this.snappingCancelled = !0, this.clearTouches();
2422
- const e = this.doc();
2423
- this.overscroll = e.style.transform?.length > 12 ? parseFloat(e.style.transform.slice(12).split("px")[0]) : 0;
2698
+ const t = this.doc();
2699
+ this.overscroll = t.style.transform?.length > 12 ? parseFloat(t.style.transform.slice(12).split("px")[0]) : 0;
2424
2700
  }
2425
2701
  // Snaps the current offset to the page width.
2426
- snapCurrentOffset(e = !1, t = !1) {
2427
- const i = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft, r = this.doc(), n = this.dragOffset(), o = lt(this.wnd), a = Math.min(Math.max(0, i), this.cachedScrollWidth), u = z(this.wnd) ? -1 : 1, h = (
2702
+ snapCurrentOffset(t = !1, e = !1) {
2703
+ const i = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft, s = this.doc(), n = this.dragOffset(), o = Te(this.wnd), a = Math.min(Math.max(0, i), this.cachedScrollWidth), d = B(this.wnd) ? -1 : 1, h = (
2428
2704
  // The hurdle to overcome in order to change pages
2429
- u * (this.wnd.innerWidth / 3) * (u * n > 0 ? 2 : 1)
2430
- ), c = this.snapOffset(a + h);
2431
- if (e && c !== this.scrollOffset()) {
2705
+ d * (this.wnd.innerWidth / 3) * (d * n > 0 ? 2 : 1)
2706
+ ), u = this.snapOffset(a + h), g = u > this.scrollOffset() ? "right" : "left";
2707
+ if (this.checkSuspiciousSnap(g, Math.abs(u - this.scrollOffset())), t && u !== this.scrollOffset()) {
2432
2708
  this.snappingCancelled = !1;
2433
- const m = (f, g, E, W) => E > W ? g : f + (g - f) * Ut(E / W), d = (
2709
+ const m = (b, x, _, q) => _ > q ? x : b + (x - b) * oi(_ / q), v = (
2434
2710
  /*Math.abs(startX - (this.useTransform ? currentOffset : 0)) < 10 ? 1 : */
2435
- Vt * o
2711
+ pi * o
2436
2712
  );
2437
- let y;
2438
- const p = (f) => {
2713
+ let f;
2714
+ const p = (b) => {
2439
2715
  if (this.snappingCancelled) return;
2440
- y || (y = f);
2441
- const g = f - y, E = m(this.overscroll, 0, g, d), W = m(i, c, g, d);
2442
- r.scrollLeft = W, this.overscroll !== 0 && (r.style.transform = `translate3d(${-E}px, 0px, 0px)`), g < d ? this.wnd.requestAnimationFrame(p) : (this.clearTouches(), r.style.removeProperty("transform"), r.scrollLeft = c, t || this.reportProgress());
2716
+ f || (f = b);
2717
+ const x = b - f, _ = m(this.overscroll, 0, x, v), q = m(i, u, x, v);
2718
+ s.scrollLeft = q, this.overscroll !== 0 && (s.style.transform = `translate3d(${-_}px, 0px, 0px)`), x < v ? this.wnd.requestAnimationFrame(p) : (this.clearTouches(), s.style.removeProperty("transform"), s.scrollLeft = u, e || this.reportProgress());
2443
2719
  };
2444
2720
  this.wnd.requestAnimationFrame(p);
2445
2721
  } else
2446
- r.style.removeProperty("transform"), this.wnd.requestAnimationFrame(() => {
2447
- r.scrollLeft = c, this.clearTouches(), t || this.reportProgress();
2722
+ s.style.removeProperty("transform"), this.wnd.requestAnimationFrame(() => {
2723
+ s.scrollLeft = u, this.clearTouches(), e || this.reportProgress();
2448
2724
  });
2449
2725
  }
2450
2726
  dragOffset() {
@@ -2453,41 +2729,64 @@ const Ge = "readium-column-snapper-style", Vt = 200, x = class x extends G {
2453
2729
  clearTouches() {
2454
2730
  this.startingX = void 0, this.endingX = void 0, this.overscroll = 0;
2455
2731
  }
2456
- onTouchStart(e) {
2457
- switch (e.stopPropagation(), this.takeOverSnap(), e.touches.length) {
2732
+ onTouchStart(t) {
2733
+ switch (t.stopPropagation(), this.takeOverSnap(), t.touches.length) {
2458
2734
  case 1:
2459
2735
  break;
2460
2736
  case 2:
2461
- this.onTouchEnd(e);
2737
+ this.onTouchEnd(t);
2462
2738
  return;
2463
2739
  default: {
2464
- this.onTouchEnd(e), this.comms.send("tap_more", e.touches.length);
2740
+ this.onTouchEnd(t), this.comms.send("tap_more", t.touches.length);
2465
2741
  return;
2466
2742
  }
2467
2743
  }
2468
- this.startingX = e.touches[0].clientX, this.alreadyScrollLeft = this.doc().scrollLeft, this.touchState = 1;
2744
+ this.startingX = t.touches[0].clientX, this.alreadyScrollLeft = this.doc().scrollLeft, this.touchState = 1;
2469
2745
  }
2470
- onTouchEnd(e) {
2746
+ onTouchEnd(t) {
2471
2747
  if (this.touchState === 2) {
2472
- const t = this.dragOffset(), i = this.scrollOffset();
2473
- this.cachedScrollWidth <= this.wnd.innerWidth ? (this.reportProgress(), t > 5 && this.comms.send("no_more", void 0), t < -5 && this.comms.send("no_less", void 0)) : i < 5 && t < 5 ? (this.alreadyScrollLeft = 0, this.comms.send("no_less", void 0)) : this.cachedScrollWidth - i - this.wnd.innerWidth < 5 && t > 5 && (this.alreadyScrollLeft = this.cachedScrollWidth, this.comms.send("no_more", void 0)), this.snapCurrentOffset(!0), this.comms.send("swipe", t);
2748
+ const e = this.dragOffset(), i = this.scrollOffset();
2749
+ this.cachedScrollWidth <= this.wnd.innerWidth ? (this.reportProgress(), e > 5 && this.comms.send("no_more", void 0), e < -5 && this.comms.send("no_less", void 0)) : i < 5 && e < 5 ? (this.alreadyScrollLeft = 0, this.comms.send("no_less", void 0)) : this.cachedScrollWidth - i - this.wnd.innerWidth < 5 && e > 5 && (this.alreadyScrollLeft = this.cachedScrollWidth, this.comms.send("no_more", void 0)), this.snapCurrentOffset(!0), this.comms.send("swipe", e);
2474
2750
  }
2475
2751
  this.touchState = 0;
2476
2752
  }
2477
2753
  onWidthChange() {
2478
2754
  this.cachedScrollWidth = this.doc().scrollWidth, this.comms.ready && this.snapCurrentOffset();
2479
2755
  }
2480
- onTouchMove(e) {
2756
+ onTouchMove(t) {
2481
2757
  if (this.touchState === 0) return;
2482
- this.touchState === 1 && (this.touchState = 2, v(this.wnd)), this.endingX = e.touches[0].clientX;
2483
- const t = this.dragOffset(), i = this.alreadyScrollLeft + t;
2484
- i < 0 ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-this.overscroll}px, 0px, 0px)`) : i + this.wnd.innerWidth > this.cachedScrollWidth ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-i}px, 0px, 0px)`) : (this.overscroll = 0, this.doc().style.removeProperty("transform"), this.doc().scrollLeft = this.alreadyScrollLeft + t);
2485
- }
2486
- mount(e, t) {
2487
- if (this.wnd = e, this.comms = t, !super.mount(e, t)) return !1;
2488
- e.navigator.epubReadingSystem && (e.navigator.epubReadingSystem.layoutStyle = "paginated");
2489
- const i = e.document.createElement("style");
2490
- i.dataset.readium = "true", i.id = Ge, i.textContent = `
2758
+ this.touchState === 1 && (this.touchState = 2, A(this.wnd)), this.endingX = t.touches[0].clientX;
2759
+ const e = this.dragOffset(), i = this.alreadyScrollLeft + e;
2760
+ i < 0 ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-this.overscroll}px, 0px, 0px)`) : i + this.wnd.innerWidth > this.cachedScrollWidth ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-i}px, 0px, 0px)`) : (this.overscroll = 0, this.doc().style.removeProperty("transform"), this.doc().scrollLeft = this.alreadyScrollLeft + e);
2761
+ }
2762
+ enableSnapProtection() {
2763
+ this.patternAnalyzer || (this.patternAnalyzer = new Bt({
2764
+ maxVelocity: this.wnd.innerWidth,
2765
+ // page width
2766
+ minVariance: 0.1,
2767
+ // Allow for some variation in swipe speed
2768
+ historySize: 5,
2769
+ // Fewer samples needed for swipe detection
2770
+ maxConsistentScrolls: 3,
2771
+ // Lower threshold for consistent scrolling
2772
+ minDirectionChanges: 0.3
2773
+ // Require more direction changes
2774
+ }), this.isSnapProtectionEnabled = !0, this.comms?.log("Snap protection enabled"));
2775
+ }
2776
+ checkSuspiciousSnap(t, e) {
2777
+ if (!this.isSnapProtectionEnabled || !this.patternAnalyzer) return;
2778
+ const i = Date.now(), s = i - (this.lastTurnTime || i);
2779
+ this.lastTurnTime = i, this.patternAnalyzer.analyze(t, e, s) && this.comms?.send("content_protection", {
2780
+ type: "suspicious_snapping",
2781
+ timestamp: Date.now(),
2782
+ event: null
2783
+ });
2784
+ }
2785
+ mount(t, e) {
2786
+ if (this.wnd = t, this.comms = e, !super.mount(t, e)) return !1;
2787
+ t.navigator.epubReadingSystem && (t.navigator.epubReadingSystem.layoutStyle = "paginated");
2788
+ const i = t.document.createElement("style");
2789
+ i.dataset.readium = "true", i.id = ue, i.textContent = `
2491
2790
  @keyframes readium-bounce-l-animation {
2492
2791
  0%, 100% {transform: translate3d(0, 0, 0);}
2493
2792
  50% {transform: translate3d(-50px, 0, 0);}
@@ -2521,54 +2820,56 @@ const Ge = "readium-column-snapper-style", Vt = 200, x = class x extends G {
2521
2820
  body::-webkit-scrollbar {
2522
2821
  display: none; /* for Chrome, Safari, and Opera */
2523
2822
  }
2524
- `, e.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
2525
- e.requestAnimationFrame(() => {
2526
- e && Xe(e);
2823
+ `, t.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
2824
+ t.requestAnimationFrame(() => {
2825
+ t && de(t);
2527
2826
  }), this.onWidthChange();
2528
- }), this.resizeObserver.observe(e.document.body), this.mutationObserver = new MutationObserver((n) => {
2827
+ }), this.resizeObserver.observe(t.document.body), this.mutationObserver = new MutationObserver((n) => {
2529
2828
  for (const o of n)
2530
2829
  if (o.target === this.wnd.document.documentElement) {
2531
- const a = o.oldValue, u = o.target.getAttribute("style"), h = /transform\s*:\s*([^;]+)/, c = a?.match(h), m = u?.match(h);
2532
- (!c && !m || c && !m || c && m && c[1] !== m[1]) && (e.requestAnimationFrame(() => {
2533
- e && Xe(e);
2830
+ const a = o.oldValue, d = o.target.getAttribute("style"), h = /transform\s*:\s*([^;]+)/, u = a?.match(h), g = d?.match(h);
2831
+ (!u && !g || u && !g || u && g && u[1] !== g[1]) && (t.requestAnimationFrame(() => {
2832
+ t && de(t);
2534
2833
  }), this.onWidthChange());
2535
2834
  } else
2536
- e.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth);
2537
- }), e.frameElement && this.mutationObserver.observe(e.frameElement, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(e.document, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(e.document.documentElement, { attributes: !0, attributeFilter: ["style"] });
2538
- const r = (n) => {
2835
+ t.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth);
2836
+ }), t.frameElement && this.mutationObserver.observe(t.frameElement, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(t.document, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(t.document.documentElement, { attributes: !0, attributeFilter: ["style"] }), e.register("scroll_protection", P.moduleName, (n, o) => {
2837
+ this.enableSnapProtection(), o(!0);
2838
+ });
2839
+ const s = (n) => {
2539
2840
  const o = this.doc().scrollLeft;
2540
2841
  return this.doc().scrollLeft = this.snapOffset(n), o !== this.doc().scrollLeft;
2541
2842
  };
2542
- return e.addEventListener("orientationchange", this.onWidthChanger), e.addEventListener("resize", this.onWidthChanger), e.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), t.register("go_progression", x.moduleName, (n, o) => {
2843
+ return t.addEventListener("orientationchange", this.onWidthChanger), t.addEventListener("resize", this.onWidthChanger), t.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), e.register("go_progression", P.moduleName, (n, o) => {
2543
2844
  const a = n;
2544
2845
  if (a < 0 || a > 1) {
2545
- t.send("error", {
2846
+ e.send("error", {
2546
2847
  message: "go_progression must be given a position from 0.0 to 1.0"
2547
2848
  }), o(!1);
2548
2849
  return;
2549
2850
  }
2550
2851
  this.wnd.requestAnimationFrame(() => {
2551
2852
  this.cachedScrollWidth = this.doc().scrollWidth;
2552
- const u = this.cachedScrollWidth, h = z(e) ? -1 : 1, c = u * a * h;
2553
- this.doc().scrollLeft = this.snapOffset(c), this.reportProgress(), v(this.wnd), o(!0);
2853
+ const d = this.cachedScrollWidth, h = B(t) ? -1 : 1, u = d * a * h;
2854
+ this.doc().scrollLeft = this.snapOffset(u), this.reportProgress(), A(this.wnd), o(!0);
2554
2855
  });
2555
- }), t.register("go_id", x.moduleName, (n, o) => {
2556
- const a = e.document.getElementById(n);
2856
+ }), e.register("go_id", P.moduleName, (n, o) => {
2857
+ const a = t.document.getElementById(n);
2557
2858
  if (!a) {
2558
2859
  o(!1);
2559
2860
  return;
2560
2861
  }
2561
2862
  this.wnd.requestAnimationFrame(() => {
2562
- this.doc().scrollLeft = this.snapOffset(a.getBoundingClientRect().left + e.scrollX), this.reportProgress(), v(this.wnd), o(!0);
2863
+ this.doc().scrollLeft = this.snapOffset(a.getBoundingClientRect().left + t.scrollX), this.reportProgress(), A(this.wnd), o(!0);
2563
2864
  });
2564
- }), t.register("go_text", x.moduleName, (n, o) => {
2865
+ }), e.register("go_text", P.moduleName, (n, o) => {
2565
2866
  let a;
2566
2867
  Array.isArray(n) && (n.length > 1 && (a = n[1]), n = n[0]);
2567
- const u = D.deserialize(n), h = ne(this.wnd.document, new R({
2568
- href: e.location.href,
2868
+ const d = H.deserialize(n), h = pt(this.wnd.document, new W({
2869
+ href: t.location.href,
2569
2870
  type: "text/html",
2570
- text: u,
2571
- locations: a ? new b({
2871
+ text: d,
2872
+ locations: a ? new C({
2572
2873
  otherLocations: /* @__PURE__ */ new Map([
2573
2874
  ["cssSelector", a]
2574
2875
  ])
@@ -2579,56 +2880,56 @@ const Ge = "readium-column-snapper-style", Vt = 200, x = class x extends G {
2579
2880
  return;
2580
2881
  }
2581
2882
  this.wnd.requestAnimationFrame(() => {
2582
- this.doc().scrollLeft = this.snapOffset(h.getBoundingClientRect().left + e.scrollX), this.reportProgress(), v(this.wnd), o(!0);
2883
+ this.doc().scrollLeft = this.snapOffset(h.getBoundingClientRect().left + t.scrollX), this.reportProgress(), A(this.wnd), o(!0);
2583
2884
  });
2584
- }), t.register("go_end", x.moduleName, (n, o) => {
2585
- const a = z(e) ? -1 : 1;
2885
+ }), e.register("go_end", P.moduleName, (n, o) => {
2886
+ const a = B(t) ? -1 : 1;
2586
2887
  this.wnd.requestAnimationFrame(() => {
2587
2888
  this.cachedScrollWidth = this.doc().scrollWidth;
2588
- const u = this.cachedScrollWidth * a;
2589
- if (this.doc().scrollLeft === u) return o(!1);
2590
- this.doc().scrollLeft = this.snapOffset(u), this.reportProgress(), v(this.wnd), o(!0);
2889
+ const d = this.cachedScrollWidth * a;
2890
+ if (this.doc().scrollLeft === d) return o(!1);
2891
+ this.doc().scrollLeft = this.snapOffset(d), this.reportProgress(), A(this.wnd), o(!0);
2591
2892
  });
2592
- }), t.register("go_start", x.moduleName, (n, o) => {
2893
+ }), e.register("go_start", P.moduleName, (n, o) => {
2593
2894
  this.wnd.requestAnimationFrame(() => {
2594
2895
  if (this.doc().scrollLeft === 0) return o(!1);
2595
- this.doc().scrollLeft = 0, this.reportProgress(), v(this.wnd), o(!0);
2896
+ this.doc().scrollLeft = 0, this.reportProgress(), A(this.wnd), o(!0);
2596
2897
  });
2597
- }), t.register("go_prev", x.moduleName, (n, o) => {
2898
+ }), e.register("go_prev", P.moduleName, (n, o) => {
2598
2899
  this.wnd.requestAnimationFrame(() => {
2599
2900
  this.cachedScrollWidth = this.doc().scrollWidth;
2600
- const a = e.scrollX - e.innerWidth, u = z(e) ? -(this.cachedScrollWidth - e.innerWidth) : 0, h = r(Math.max(a, u));
2601
- h && (this.reportProgress(), v(this.wnd)), o(h);
2901
+ const a = t.scrollX - t.innerWidth, d = B(t) ? -(this.cachedScrollWidth - t.innerWidth) : 0, h = s(Math.max(a, d));
2902
+ h && (this.reportProgress(), A(this.wnd), this.checkSuspiciousSnap("left", this.wnd.innerWidth)), o(h);
2602
2903
  });
2603
- }), t.register("go_next", x.moduleName, (n, o) => {
2904
+ }), e.register("go_next", P.moduleName, (n, o) => {
2604
2905
  this.wnd.requestAnimationFrame(() => {
2605
2906
  this.cachedScrollWidth = this.doc().scrollWidth;
2606
- const a = e.scrollX + e.innerWidth, u = z(e) ? 0 : this.cachedScrollWidth - e.innerWidth, h = r(Math.min(a, u));
2607
- h && (this.reportProgress(), v(this.wnd)), o(h);
2907
+ const a = t.scrollX + t.innerWidth, d = B(t) ? 0 : this.cachedScrollWidth - t.innerWidth, h = s(Math.min(a, d));
2908
+ h && (this.reportProgress(), A(this.wnd), this.checkSuspiciousSnap("right", this.wnd.innerWidth)), o(h);
2608
2909
  });
2609
- }), t.register("unfocus", x.moduleName, (n, o) => {
2610
- this.snappingCancelled = !0, v(this.wnd), o(!0);
2611
- }), t.register("shake", x.moduleName, (n, o) => {
2910
+ }), e.register("unfocus", P.moduleName, (n, o) => {
2911
+ this.snappingCancelled = !0, A(this.wnd), o(!0);
2912
+ }), e.register("shake", P.moduleName, (n, o) => {
2612
2913
  this.shake(), o(!0);
2613
- }), t.register("focus", x.moduleName, (n, o) => {
2914
+ }), e.register("focus", P.moduleName, (n, o) => {
2614
2915
  this.wnd.requestAnimationFrame(() => {
2615
2916
  this.cachedScrollWidth = this.doc().scrollWidth, this.snapCurrentOffset(!1, !0), this.reportProgress(), o(!0);
2616
2917
  });
2617
- }), t.register("first_visible_locator", x.moduleName, (n, o) => {
2618
- const a = Ne(e, !1);
2918
+ }), e.register("first_visible_locator", P.moduleName, (n, o) => {
2919
+ const a = Ut(t, !1);
2619
2920
  this.comms.send("first_visible_locator", a.serialize()), o(!0);
2620
- }), e.addEventListener("touchstart", this.onTouchStarter, { passive: !0 }), e.addEventListener("touchend", this.onTouchEnder, { passive: !0 }), e.addEventListener("touchmove", this.onTouchMover, { passive: !0 }), e.document.addEventListener("touchstart", () => {
2621
- }), t.log("ColumnSnapper Mounted"), !0;
2921
+ }), t.addEventListener("touchstart", this.onTouchStarter, { passive: !0 }), t.addEventListener("touchend", this.onTouchEnder, { passive: !0 }), t.addEventListener("touchmove", this.onTouchMover, { passive: !0 }), t.document.addEventListener("touchstart", () => {
2922
+ }), e.log("ColumnSnapper Mounted"), !0;
2622
2923
  }
2623
- unmount(e, t) {
2624
- return this.snappingCancelled = !0, t.unregisterAll(x.moduleName), this.resizeObserver.disconnect(), this.mutationObserver.disconnect(), e.removeEventListener("touchstart", this.onTouchStarter), e.removeEventListener("touchend", this.onTouchEnder), e.removeEventListener("touchmove", this.onTouchMover), e.removeEventListener("orientationchange", this.onWidthChanger), e.removeEventListener("resize", this.onWidthChanger), e.document.getElementById(Ge)?.remove(), t.log("ColumnSnapper Unmounted"), super.unmount(e, t);
2924
+ unmount(t, e) {
2925
+ return this.snappingCancelled = !0, e.unregisterAll(P.moduleName), this.resizeObserver.disconnect(), this.mutationObserver.disconnect(), this.patternAnalyzer && (this.patternAnalyzer.clear(), this.patternAnalyzer = null, this.isSnapProtectionEnabled = !1), t.removeEventListener("touchstart", this.onTouchStarter), t.removeEventListener("touchend", this.onTouchEnder), t.removeEventListener("touchmove", this.onTouchMover), t.removeEventListener("orientationchange", this.onWidthChanger), t.removeEventListener("resize", this.onWidthChanger), t.document.getElementById(ue)?.remove(), e.log("ColumnSnapper Unmounted"), super.unmount(t, e);
2625
2926
  }
2626
2927
  };
2627
- x.moduleName = "column_snapper";
2628
- let me = x;
2629
- const Ye = "readium-scroll-snapper-style", T = class T extends G {
2928
+ P.moduleName = "column_snapper";
2929
+ let At = P;
2930
+ const pe = "readium-scroll-snapper-style", N = class N extends st {
2630
2931
  constructor() {
2631
- super(...arguments), this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce = null, this.handleScroll = () => {
2932
+ super(...arguments), this.patternAnalyzer = null, this.lastScrollTime = 0, this.isScrollProtectionEnabled = !1, this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce = null, this.handleScroll = (t) => {
2632
2933
  if (this.comms.ready && !this.isResizing) {
2633
2934
  if (!this.initialScrollHandled) {
2634
2935
  this.lastScrollTop = this.doc().scrollTop, this.initialScrollHandled = !0, this.reportProgress();
@@ -2636,8 +2937,26 @@ const Ye = "readium-scroll-snapper-style", T = class T extends G {
2636
2937
  }
2637
2938
  this.isScrolling || (this.isScrolling = !0, this.wnd.requestAnimationFrame(() => {
2638
2939
  this.reportProgress();
2639
- const e = this.doc().scrollTop, t = e - this.lastScrollTop;
2640
- this.lastScrollTop = e, this.comms.send("scroll", t), this.isScrolling = !1;
2940
+ const e = this.doc().scrollTop, i = e - this.lastScrollTop;
2941
+ if (this.lastScrollTop = e, this.isScrollProtectionEnabled && Math.abs(i) > 5) {
2942
+ const s = Date.now(), n = s - (this.lastScrollTime || s);
2943
+ if (this.patternAnalyzer && this.patternAnalyzer.analyze(
2944
+ i > 0 ? "down" : "up",
2945
+ Math.abs(i),
2946
+ n
2947
+ )) {
2948
+ const a = t.target && "tagName" in t.target ? { tagName: t.target.tagName } : null;
2949
+ this.comms?.send("content_protection", {
2950
+ type: "suspicious_scrolling",
2951
+ timestamp: Date.now(),
2952
+ scrollDelta: i,
2953
+ scrollDirection: i > 0 ? "down" : "up",
2954
+ targetElement: a
2955
+ });
2956
+ }
2957
+ this.lastScrollTime = s;
2958
+ }
2959
+ this.comms.send("scroll", i), this.isScrolling = !1;
2641
2960
  }));
2642
2961
  }
2643
2962
  };
@@ -2647,16 +2966,19 @@ const Ye = "readium-scroll-snapper-style", T = class T extends G {
2647
2966
  }
2648
2967
  reportProgress() {
2649
2968
  if (!this.comms.ready) return;
2650
- const e = Math.ceil(this.doc().scrollTop), t = this.doc().scrollHeight, i = this.wnd.innerHeight, r = Math.max(0, Math.min(1, e / t)), n = Math.max(0, Math.min(1, (e + i) / t));
2969
+ const t = Math.ceil(this.doc().scrollTop), e = this.doc().scrollHeight, i = this.wnd.innerHeight, s = Math.max(0, Math.min(1, t / e)), n = Math.max(0, Math.min(1, (t + i) / e));
2651
2970
  this.comms.send("progress", {
2652
- start: r,
2971
+ start: s,
2653
2972
  end: n
2654
2973
  });
2655
2974
  }
2656
- mount(e, t) {
2657
- this.wnd = e, this.comms = t, this.initialScrollHandled = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce && (this.wnd.clearTimeout(this.resizeDebounce), this.resizeDebounce = null), e.navigator.epubReadingSystem && (e.navigator.epubReadingSystem.layoutStyle = "scrolling");
2658
- const i = e.document.createElement("style");
2659
- return i.dataset.readium = "true", i.id = Ye, i.textContent = `
2975
+ enableScrollProtection() {
2976
+ this.patternAnalyzer || (this.patternAnalyzer = new Bt(Oe), this.isScrollProtectionEnabled = !0, this.comms?.log("Scroll protection enabled"));
2977
+ }
2978
+ mount(t, e) {
2979
+ this.wnd = t, this.comms = e, this.initialScrollHandled = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce && (this.wnd.clearTimeout(this.resizeDebounce), this.resizeDebounce = null), t.navigator.epubReadingSystem && (t.navigator.epubReadingSystem.layoutStyle = "scrolling");
2980
+ const i = t.document.createElement("style");
2981
+ return i.dataset.readium = "true", i.id = pe, i.textContent = `
2660
2982
  * {
2661
2983
  scrollbar-width: none; /* for Firefox */
2662
2984
  }
@@ -2664,81 +2986,83 @@ const Ye = "readium-scroll-snapper-style", T = class T extends G {
2664
2986
  body::-webkit-scrollbar {
2665
2987
  display: none; /* for Chrome, Safari, and Opera */
2666
2988
  }
2667
- `, e.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
2989
+ `, t.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
2668
2990
  this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {
2669
2991
  this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();
2670
2992
  }, 50);
2671
- }), this.resizeObserver.observe(e.document.body), e.addEventListener("scroll", this.handleScroll, { passive: !0 }), t.register("force_webkit_recalc", T.moduleName, () => {
2672
- ht(this.wnd);
2673
- const r = this.doc().scrollTop;
2674
- r > 1 ? this.doc().scrollTop = r - 1 : this.doc().scrollTop = r + 1, this.doc().scrollTop = r;
2675
- }), t.register("go_progression", T.moduleName, (r, n) => {
2676
- const o = r;
2993
+ }), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc", N.moduleName, () => {
2994
+ Pe(this.wnd);
2995
+ const s = this.doc().scrollTop;
2996
+ s > 1 ? this.doc().scrollTop = s - 1 : this.doc().scrollTop = s + 1, this.doc().scrollTop = s;
2997
+ }), e.register("go_progression", N.moduleName, (s, n) => {
2998
+ const o = s;
2677
2999
  if (o < 0 || o > 1) {
2678
- t.send("error", {
3000
+ e.send("error", {
2679
3001
  message: "go_progression must be given a position from 0.0 to 1.0"
2680
3002
  }), n(!1);
2681
3003
  return;
2682
3004
  }
2683
3005
  this.wnd.requestAnimationFrame(() => {
2684
- this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(), v(this.wnd), n(!0);
3006
+ this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(), A(this.wnd), n(!0);
2685
3007
  });
2686
- }), t.register("go_id", T.moduleName, (r, n) => {
2687
- const o = e.document.getElementById(r);
3008
+ }), e.register("go_id", N.moduleName, (s, n) => {
3009
+ const o = t.document.getElementById(s);
2688
3010
  if (!o) {
2689
3011
  n(!1);
2690
3012
  return;
2691
3013
  }
2692
3014
  this.wnd.requestAnimationFrame(() => {
2693
- this.doc().scrollTop = o.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), v(this.wnd), n(!0);
3015
+ this.doc().scrollTop = o.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd), n(!0);
2694
3016
  });
2695
- }), t.register("go_text", T.moduleName, (r, n) => {
3017
+ }), e.register("go_text", N.moduleName, (s, n) => {
2696
3018
  let o;
2697
- Array.isArray(r) && (r.length > 1 && (o = r[1]), r = r[0]);
2698
- const a = D.deserialize(r), u = ne(this.wnd.document, new R({
2699
- href: e.location.href,
3019
+ Array.isArray(s) && (s.length > 1 && (o = s[1]), s = s[0]);
3020
+ const a = H.deserialize(s), d = pt(this.wnd.document, new W({
3021
+ href: t.location.href,
2700
3022
  type: "text/html",
2701
3023
  text: a,
2702
- locations: o ? new b({
3024
+ locations: o ? new C({
2703
3025
  otherLocations: /* @__PURE__ */ new Map([
2704
3026
  ["cssSelector", o]
2705
3027
  ])
2706
3028
  }) : void 0
2707
3029
  }));
2708
- if (!u) {
3030
+ if (!d) {
2709
3031
  n(!1);
2710
3032
  return;
2711
3033
  }
2712
3034
  this.wnd.requestAnimationFrame(() => {
2713
- this.doc().scrollTop = u.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), v(this.wnd), n(!0);
3035
+ this.doc().scrollTop = d.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd), n(!0);
2714
3036
  });
2715
- }), t.register("go_start", T.moduleName, (r, n) => {
3037
+ }), e.register("go_start", N.moduleName, (s, n) => {
2716
3038
  if (this.doc().scrollTop === 0) return n(!1);
2717
3039
  this.doc().scrollTop = 0, this.reportProgress(), n(!0);
2718
- }), t.register("go_end", T.moduleName, (r, n) => {
3040
+ }), e.register("go_end", N.moduleName, (s, n) => {
2719
3041
  if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return n(!1);
2720
3042
  this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), n(!0);
2721
- }), t.register("unfocus", T.moduleName, (r, n) => {
2722
- v(this.wnd), n(!0);
2723
- }), t.register([
3043
+ }), e.register("unfocus", N.moduleName, (s, n) => {
3044
+ A(this.wnd), n(!0);
3045
+ }), e.register("scroll_protection", N.moduleName, (s, n) => {
3046
+ this.enableScrollProtection(), n(!0);
3047
+ }), e.register([
2724
3048
  "go_next",
2725
3049
  "go_prev"
2726
- ], T.moduleName, (r, n) => n(!1)), t.register("focus", T.moduleName, (r, n) => {
3050
+ ], N.moduleName, (s, n) => n(!1)), e.register("focus", N.moduleName, (s, n) => {
2727
3051
  this.reportProgress(), n(!0);
2728
- }), t.register("first_visible_locator", T.moduleName, (r, n) => {
2729
- const o = Ne(e, !0);
3052
+ }), e.register("first_visible_locator", N.moduleName, (s, n) => {
3053
+ const o = Ut(t, !0);
2730
3054
  this.comms.send("first_visible_locator", o.serialize()), n(!0);
2731
- }), t.log("ScrollSnapper Mounted"), !0;
3055
+ }), e.log("ScrollSnapper Mounted"), !0;
2732
3056
  }
2733
- unmount(e, t) {
2734
- return t.unregisterAll(T.moduleName), this.resizeObserver.disconnect(), this.handleScroll && e.removeEventListener("scroll", this.handleScroll), e.document.getElementById(Ye)?.remove(), t.log("ScrollSnapper Unmounted"), !0;
3057
+ unmount(t, e) {
3058
+ return e.unregisterAll(N.moduleName), this.resizeObserver.disconnect(), this.handleScroll && t.removeEventListener("scroll", this.handleScroll), t.document.getElementById(pe)?.remove(), this.patternAnalyzer && (this.patternAnalyzer.clear(), this.patternAnalyzer = null, this.isScrollProtectionEnabled = !1), e.log("ScrollSnapper Unmounted"), !0;
2735
3059
  }
2736
3060
  };
2737
- T.moduleName = "scroll_snapper";
2738
- let ge = T;
2739
- const w = class w extends G {
3061
+ N.moduleName = "scroll_snapper";
3062
+ let Ct = N;
3063
+ const L = class L extends st {
2740
3064
  constructor() {
2741
- super(...arguments), this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce = null, this.handleScroll = () => {
3065
+ super(...arguments), this.patternAnalyzer = null, this.lastScrollTime = 0, this.isScrollProtectionEnabled = !1, this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce = null, this.handleScroll = (t) => {
2742
3066
  if (this.comms.ready && !this.isResizing) {
2743
3067
  if (!this.initialScrollHandled) {
2744
3068
  this.lastScrollTop = this.doc().scrollTop, this.initialScrollHandled = !0, this.reportProgress();
@@ -2746,8 +3070,26 @@ const w = class w extends G {
2746
3070
  }
2747
3071
  this.isScrolling || (this.isScrolling = !0, this.wnd.requestAnimationFrame(() => {
2748
3072
  this.reportProgress();
2749
- const e = this.doc().scrollTop, t = e - this.lastScrollTop;
2750
- this.lastScrollTop = e, this.comms.send("scroll", t), this.isScrolling = !1;
3073
+ const e = this.doc().scrollTop, i = e - this.lastScrollTop;
3074
+ if (this.lastScrollTop = e, this.isScrollProtectionEnabled && Math.abs(i) > 5) {
3075
+ const s = Date.now(), n = s - (this.lastScrollTime || s);
3076
+ if (this.patternAnalyzer && this.patternAnalyzer.analyze(
3077
+ i > 0 ? "down" : "up",
3078
+ Math.abs(i),
3079
+ n
3080
+ )) {
3081
+ const a = t.target && "tagName" in t.target ? { tagName: t.target.tagName } : null;
3082
+ this.comms?.send("content_protection", {
3083
+ type: "suspicious_scrolling",
3084
+ timestamp: Date.now(),
3085
+ scrollDelta: i,
3086
+ scrollDirection: i > 0 ? "down" : "up",
3087
+ targetElement: a
3088
+ });
3089
+ }
3090
+ this.lastScrollTime = s;
3091
+ }
3092
+ this.comms.send("scroll", i), this.isScrolling = !1;
2751
3093
  }));
2752
3094
  }
2753
3095
  };
@@ -2757,97 +3099,395 @@ const w = class w extends G {
2757
3099
  }
2758
3100
  reportProgress() {
2759
3101
  if (!this.comms.ready) return;
2760
- const e = Math.ceil(this.doc().scrollTop), t = this.doc().scrollHeight, i = this.wnd.innerHeight, r = Math.max(0, Math.min(1, e / t)), n = Math.max(0, Math.min(1, (e + i) / t));
3102
+ const t = Math.ceil(this.doc().scrollTop), e = this.doc().scrollHeight, i = this.wnd.innerHeight, s = Math.max(0, Math.min(1, t / e)), n = Math.max(0, Math.min(1, (t + i) / e));
2761
3103
  this.comms.send("progress", {
2762
- start: r,
3104
+ start: s,
2763
3105
  end: n
2764
3106
  });
2765
3107
  }
2766
- mount(e, t) {
2767
- return this.wnd = e, this.comms = t, this.initialScrollHandled = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce && (this.wnd.clearTimeout(this.resizeDebounce), this.resizeDebounce = null), this.resizeObserver = new ResizeObserver(() => {
3108
+ enableScrollProtection() {
3109
+ this.patternAnalyzer || (this.patternAnalyzer = new Bt(Oe), this.isScrollProtectionEnabled = !0, this.comms?.log("Scroll protection enabled"));
3110
+ }
3111
+ mount(t, e) {
3112
+ return this.wnd = t, this.comms = e, this.initialScrollHandled = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce && (this.wnd.clearTimeout(this.resizeDebounce), this.resizeDebounce = null), this.resizeObserver = new ResizeObserver(() => {
2768
3113
  this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {
2769
3114
  this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();
2770
3115
  }, 50);
2771
- }), this.resizeObserver.observe(e.document.body), e.addEventListener("scroll", this.handleScroll, { passive: !0 }), t.register("force_webkit_recalc", w.moduleName, () => {
2772
- ht(this.wnd);
3116
+ }), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc", L.moduleName, () => {
3117
+ Pe(this.wnd);
2773
3118
  const i = this.doc().scrollTop;
2774
3119
  i > 1 ? this.doc().scrollTop = i - 1 : this.doc().scrollTop = i + 1, this.doc().scrollTop = i;
2775
- }), t.register("go_progression", w.moduleName, (i, r) => {
3120
+ }), e.register("go_progression", L.moduleName, (i, s) => {
2776
3121
  const n = i;
2777
3122
  if (n < 0 || n > 1) {
2778
- t.send("error", {
3123
+ e.send("error", {
2779
3124
  message: "go_progression must be given a position from 0.0 to 1.0"
2780
- }), r(!1);
3125
+ }), s(!1);
2781
3126
  return;
2782
3127
  }
2783
3128
  this.wnd.requestAnimationFrame(() => {
2784
- this.doc().scrollTop = this.doc().offsetHeight * n, this.reportProgress(), v(this.wnd), r(!0);
3129
+ this.doc().scrollTop = this.doc().offsetHeight * n, this.reportProgress(), A(this.wnd), s(!0);
2785
3130
  });
2786
- }), this.comms.register("go_id", w.moduleName, (i, r) => {
2787
- const n = e.document.getElementById(i);
3131
+ }), e.register("go_id", L.moduleName, (i, s) => {
3132
+ const n = t.document.getElementById(i);
2788
3133
  if (!n) {
2789
- r(!1);
3134
+ s(!1);
2790
3135
  return;
2791
3136
  }
2792
3137
  this.wnd.requestAnimationFrame(() => {
2793
- this.doc().scrollTop = n.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), v(this.wnd), r(!0);
3138
+ this.doc().scrollTop = n.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd), s(!0);
2794
3139
  });
2795
- }), t.register("go_text", w.moduleName, (i, r) => {
3140
+ }), e.register("go_text", L.moduleName, (i, s) => {
2796
3141
  let n;
2797
3142
  Array.isArray(i) && (i.length > 1 && (n = i[1]), i = i[0]);
2798
- const o = D.deserialize(i), a = ne(this.wnd.document, new R({
2799
- href: e.location.href,
3143
+ const o = H.deserialize(i), a = pt(this.wnd.document, new W({
3144
+ href: t.location.href,
2800
3145
  type: "text/html",
2801
3146
  text: o,
2802
- locations: n ? new b({
3147
+ locations: n ? new C({
2803
3148
  otherLocations: /* @__PURE__ */ new Map([
2804
3149
  ["cssSelector", n]
2805
3150
  ])
2806
3151
  }) : void 0
2807
3152
  }));
2808
3153
  if (!a) {
2809
- r(!1);
3154
+ s(!1);
2810
3155
  return;
2811
3156
  }
2812
3157
  this.wnd.requestAnimationFrame(() => {
2813
- this.doc().scrollTop = a.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), v(this.wnd), r(!0);
3158
+ this.doc().scrollTop = a.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd), s(!0);
2814
3159
  });
2815
- }), t.register("go_start", w.moduleName, (i, r) => {
2816
- if (this.doc().scrollTop === 0) return r(!1);
2817
- this.doc().scrollTop = 0, this.reportProgress(), r(!0);
2818
- }), t.register("go_end", w.moduleName, (i, r) => {
2819
- if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return r(!1);
2820
- this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), r(!0);
2821
- }), t.register("unfocus", w.moduleName, (i, r) => {
2822
- v(this.wnd), r(!0);
2823
- }), t.register([
3160
+ }), e.register("go_start", L.moduleName, (i, s) => {
3161
+ if (this.doc().scrollTop === 0) return s(!1);
3162
+ this.doc().scrollTop = 0, this.reportProgress(), s(!0);
3163
+ }), e.register("go_end", L.moduleName, (i, s) => {
3164
+ if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return s(!1);
3165
+ this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), s(!0);
3166
+ }), e.register("unfocus", L.moduleName, (i, s) => {
3167
+ A(this.wnd), s(!0);
3168
+ }), e.register("scroll_protection", L.moduleName, (i, s) => {
3169
+ this.enableScrollProtection(), s(!0);
3170
+ }), e.register([
2824
3171
  "go_next",
2825
3172
  "go_prev"
2826
- ], w.moduleName, (i, r) => r(!1)), t.register("focus", w.moduleName, (i, r) => {
2827
- this.reportProgress(), r(!0);
2828
- }), t.register("first_visible_locator", w.moduleName, (i, r) => {
2829
- const n = Ne(e, !0);
2830
- t.send("first_visible_locator", n.serialize()), r(!0);
2831
- }), t.log("WebPubSnapper Mounted"), !0;
3173
+ ], L.moduleName, (i, s) => s(!1)), e.register("focus", L.moduleName, (i, s) => {
3174
+ this.reportProgress(), s(!0);
3175
+ }), e.register("first_visible_locator", L.moduleName, (i, s) => {
3176
+ const n = Ut(t, !0);
3177
+ e.send("first_visible_locator", n.serialize()), s(!0);
3178
+ }), e.log("WebPubSnapper Mounted"), !0;
2832
3179
  }
2833
- unmount(e, t) {
2834
- return t.unregisterAll(w.moduleName), this.resizeObserver.disconnect(), this.handleScroll && e.removeEventListener("scroll", this.handleScroll), t.log("WebPubSnapper Unmounted"), !0;
3180
+ unmount(t, e) {
3181
+ return e.unregisterAll(L.moduleName), this.resizeObserver.disconnect(), this.handleScroll && t.removeEventListener("scroll", this.handleScroll), this.patternAnalyzer && (this.patternAnalyzer.clear(), this.patternAnalyzer = null, this.isScrollProtectionEnabled = !1), e.log("WebPubSnapper Unmounted"), !0;
2835
3182
  }
2836
3183
  };
2837
- w.moduleName = "webpub_snapper";
2838
- let ye = w;
2839
- const Oe = class Oe extends Y {
3184
+ L.moduleName = "webpub_snapper";
3185
+ let xt = L;
3186
+ class mi {
3187
+ constructor(t, e) {
3188
+ this.window = t, this.copyHistory = [], this.lastSelectionLength = 0, this.lastSelectionTime = 0, this.options = e;
3189
+ }
3190
+ cleanupOldHistory(t) {
3191
+ this.copyHistory = this.copyHistory.filter(
3192
+ (i) => t - i.timestamp < 1e4
3193
+ ), this.copyHistory.length > this.options.historySize && (this.copyHistory = this.copyHistory.slice(-this.options.historySize));
3194
+ }
3195
+ isSuspiciousPattern(t) {
3196
+ return this.copyHistory.length < 3 ? !1 : this.copyHistory.filter(
3197
+ (s) => t - s.timestamp < 2e3
3198
+ // Last 2 seconds
3199
+ ).length >= 3 ? !0 : this.copyHistory.slice().sort((s, n) => s.timestamp - n.timestamp).every((s, n, o) => n === 0 ? !0 : s.length > o[n - 1].length * 1.5);
3200
+ }
3201
+ shouldAllowCopy(t) {
3202
+ if (!this.options.enabled) return !0;
3203
+ const e = this.window.getSelection();
3204
+ if (!e) return !0;
3205
+ const s = e.toString().length, n = this.window.document.body.innerText.length, o = Date.now();
3206
+ if (this.cleanupOldHistory(o), s < this.options.minThreshold)
3207
+ return this.copyHistory.push({
3208
+ timestamp: o,
3209
+ length: s,
3210
+ wasBlocked: !1
3211
+ }), !0;
3212
+ const d = o - this.lastSelectionTime < 100 && s > this.lastSelectionLength * 1.5, h = Math.min(
3213
+ n * this.options.maxSelectionPercent,
3214
+ this.options.absoluteMaxChars
3215
+ ), u = this.isSuspiciousPattern(o), g = s > h || d || u;
3216
+ return this.copyHistory.push({
3217
+ timestamp: o,
3218
+ length: s,
3219
+ wasBlocked: g
3220
+ }), g ? (t?.preventDefault(), !1) : (this.lastSelectionLength = s, this.lastSelectionTime = o, !0);
3221
+ }
3222
+ destroy() {
3223
+ this.lastSelectionLength = 0, this.lastSelectionTime = 0, this.copyHistory = [], this.options.enabled = !1;
3224
+ }
3225
+ }
3226
+ class fi {
3227
+ constructor(t = Re) {
3228
+ this.options = t, this.events = [], this.selectionStartTime = 0, this.lastSelectionTime = 0, this.lastSelectionPosition = 0, this.selectionPatterns = [], this.lastSelectedText = "";
3229
+ }
3230
+ analyze(t) {
3231
+ if (!t)
3232
+ return this.clear(), !1;
3233
+ const e = t.toString();
3234
+ if (e.length === 0)
3235
+ return this.clear(), !1;
3236
+ if (t.type !== "Range" || !t.rangeCount)
3237
+ return !1;
3238
+ const i = Date.now();
3239
+ if (e.length <= 50 || e === this.lastSelectedText)
3240
+ return !1;
3241
+ if (this.selectionStartTime === 0)
3242
+ return this.selectionStartTime = i, this.lastSelectedText = e, !1;
3243
+ if (i - this.selectionStartTime < 500)
3244
+ return !1;
3245
+ i - this.lastSelectionTime > 1e3 && (this.lastSelectionTime = i), this.selectionStartTime === 0 && (this.selectionStartTime = i), this.lastSelectedText = e;
3246
+ const n = this.analyzeSelectionPattern(t, i);
3247
+ return this.cleanup(i), n;
3248
+ }
3249
+ analyzeSelectionPattern(t, e) {
3250
+ if (!t.rangeCount) return !1;
3251
+ const i = t.getRangeAt(0), s = i.toString(), n = (e - this.selectionStartTime) / 1e3;
3252
+ if (s.length / Math.max(1, n) > this.options.maxSelectionsPerSecond) return !0;
3253
+ const a = i.startOffset, d = Math.abs(a - this.lastSelectionPosition);
3254
+ return this.selectionPatterns.push(d), this.selectionPatterns.length > this.options.historySize && (this.selectionPatterns.shift(), this.calculateVariance(this.selectionPatterns) < this.options.minVariance) ? !0 : (this.lastSelectionPosition = a, !1);
3255
+ }
3256
+ calculateVariance(t) {
3257
+ if (t.length === 0) return 0;
3258
+ const e = t.reduce((i, s) => i + s, 0) / t.length;
3259
+ return t.reduce((i, s) => i + Math.pow(s - e, 2), 0) / t.length;
3260
+ }
3261
+ cleanup(t) {
3262
+ this.events = this.events.filter((e) => t - e.timestamp <= 1e3);
3263
+ }
3264
+ clear() {
3265
+ this.events = [], this.selectionStartTime = 0, this.lastSelectionTime = 0, this.lastSelectionPosition = 0, this.selectionPatterns = [], this.lastSelectedText = "";
3266
+ }
3267
+ }
3268
+ class gi {
3269
+ /**
3270
+ * Checks if the given keyboard event matches any of the provided key combinations
3271
+ */
3272
+ match(t, e) {
3273
+ for (const i of e) {
3274
+ const s = t.keyCode === i.keyCode, n = i.ctrl === void 0 || t.ctrlKey === i.ctrl, o = i.shift === void 0 || t.shiftKey === i.shift, a = i.alt === void 0 || t.altKey === i.alt, d = i.meta === void 0 || t.metaKey === i.meta;
3275
+ if (s && n && o && a && d)
3276
+ return !0;
3277
+ }
3278
+ return !1;
3279
+ }
3280
+ /**
3281
+ * Creates an event handler that will call the provided handler when any of the key combinations match
3282
+ */
3283
+ createKeyHandler(t, e) {
3284
+ return (i) => {
3285
+ this.match(i, t) && (i.preventDefault(), i.stopPropagation(), e(i));
3286
+ };
3287
+ }
3288
+ /**
3289
+ * Creates a standardized activity event for keyboard shortcuts
3290
+ */
3291
+ createActivityEvent(t, e, i, s) {
3292
+ let n;
3293
+ if (s) {
3294
+ const o = s.getSelection(), a = o?.toString() || "", h = (a && o?.rangeCount ? o.getRangeAt(0)?.getClientRects() : null)?.[0];
3295
+ h && a && (n = {
3296
+ text: a,
3297
+ x: h.x,
3298
+ y: h.y,
3299
+ width: h.width,
3300
+ height: h.height
3301
+ });
3302
+ }
3303
+ return {
3304
+ type: e,
3305
+ timestamp: Date.now(),
3306
+ key: t.key,
3307
+ code: t.code,
3308
+ keyCode: t.keyCode,
3309
+ ctrlKey: t.ctrlKey,
3310
+ altKey: t.altKey,
3311
+ shiftKey: t.shiftKey,
3312
+ metaKey: t.metaKey,
3313
+ targetFrameSrc: i,
3314
+ selectedText: n
3315
+ };
3316
+ }
3317
+ /**
3318
+ * Creates handlers for keyboard shortcuts with centralized activity event dispatch
3319
+ */
3320
+ createKeyboardHandlers(t, e, i, s) {
3321
+ const n = [];
3322
+ return e.forEach((o) => {
3323
+ n.push(...o.keyCombos.map((a) => ({
3324
+ ...a,
3325
+ handler: (d) => {
3326
+ const h = o.type, u = this.createActivityEvent(d, h, t, s);
3327
+ i(u);
3328
+ }
3329
+ })));
3330
+ }), n;
3331
+ }
3332
+ /**
3333
+ * Creates a unified keyboard event handler that processes all shortcuts
3334
+ */
3335
+ createUnifiedHandler(t, e, i, s) {
3336
+ const n = this.createKeyboardHandlers(t, e, i, s);
3337
+ return (o) => {
3338
+ for (const a of n)
3339
+ if (this.match(o, [a])) {
3340
+ o.preventDefault(), o.stopPropagation(), a.handler(o);
3341
+ return;
3342
+ }
3343
+ };
3344
+ }
3345
+ }
3346
+ const $ = class $ extends X {
2840
3347
  constructor() {
2841
- super(...arguments), this.pointerMoved = !1, this.onPointerUp = this.onPointUp.bind(this), this.onPointerMove = this.onPointMove.bind(this), this.onPointerDown = this.onPointDown.bind(this), this.onContextMenu = this.onContext.bind(this), this.onClicker = this.onClick.bind(this);
3348
+ super(...arguments), this.configApplied = !1, this.cleanupCallbacks = [], this.pointerMoved = !1, this.isContextMenuEnabled = !1, this.isDragAndDropEnabled = !1, this.isSelectionMonitoringEnabled = !1, this.isBulkCopyProtectionEnabled = !1, this.selectionAnalyzer = null, this.currentSelection = null, this.bulkCopyProtector = null, this.keyManager = new gi(), this.keyDownHandler = null, this.preventBulkCopy = (t) => {
3349
+ if (!this.isBulkCopyProtectionEnabled || !this.bulkCopyProtector)
3350
+ return !0;
3351
+ if (!this.bulkCopyProtector.shouldAllowCopy(t)) {
3352
+ t.preventDefault();
3353
+ const e = this.wnd.getSelection(), i = e?.toString() || "", n = (i ? e?.getRangeAt(0)?.getClientRects() : null)?.[0], o = {
3354
+ type: "bulk_copy",
3355
+ timestamp: Date.now(),
3356
+ clipboardTypes: t.clipboardData?.types ? [...t.clipboardData.types] : [],
3357
+ selectedText: n ? {
3358
+ text: i,
3359
+ x: n.x,
3360
+ y: n.y,
3361
+ width: n.width,
3362
+ height: n.height
3363
+ } : void 0,
3364
+ selectionLength: i.length,
3365
+ targetFrameSrc: this.wnd.location.href
3366
+ };
3367
+ return this.comms?.send("content_protection", o), !1;
3368
+ }
3369
+ return !0;
3370
+ }, this.handleSelection = (t) => {
3371
+ if (!this.isSelectionMonitoringEnabled || !this.wnd || !this.selectionAnalyzer)
3372
+ return;
3373
+ const e = this.wnd.getSelection();
3374
+ if (e) {
3375
+ if (this.currentSelection = e.toString(), this.selectionAnalyzer.analyze(e) && this.currentSelection) {
3376
+ const s = this.wnd.getSelection(), n = s?.toString() || "", a = (n && s?.rangeCount ? s.getRangeAt(0)?.getClientRects() : null)?.[0], d = {
3377
+ type: "suspicious_selection",
3378
+ timestamp: Date.now(),
3379
+ selectionLength: n.length,
3380
+ selectedText: {
3381
+ text: n,
3382
+ x: a?.x ?? 0,
3383
+ y: a?.y ?? 0,
3384
+ width: a?.width ?? 0,
3385
+ height: a?.height ?? 0
3386
+ },
3387
+ eventType: t?.type || "selectionchange",
3388
+ targetFrameSrc: this.wnd.location.href
3389
+ };
3390
+ this.comms?.send("content_protection", d);
3391
+ }
3392
+ } else
3393
+ this.currentSelection = null;
3394
+ }, this.onDragStart = (t) => {
3395
+ if (this.isDragAndDropEnabled) {
3396
+ t.preventDefault();
3397
+ const e = {
3398
+ type: "drag_detected",
3399
+ timestamp: Date.now(),
3400
+ dataTransferTypes: t.dataTransfer?.types ? [...t.dataTransfer.types] : [],
3401
+ targetFrameSrc: this.wnd.location.href
3402
+ };
3403
+ return this.comms?.send("content_protection", e), !1;
3404
+ } else
3405
+ return !0;
3406
+ }, this.onDrop = (t) => {
3407
+ if (this.isDragAndDropEnabled) {
3408
+ t.preventDefault();
3409
+ const e = t.dataTransfer, i = {
3410
+ type: "drop_detected",
3411
+ timestamp: Date.now(),
3412
+ dataTransferTypes: e?.types ? [...e.types] : [],
3413
+ fileCount: e?.files?.length || 0,
3414
+ targetFrameSrc: this.wnd.location.href
3415
+ };
3416
+ return this.comms?.send("content_protection", i), !1;
3417
+ } else
3418
+ return !0;
3419
+ }, this.onContext = (t) => {
3420
+ if (this.isContextMenuEnabled) {
3421
+ t.preventDefault();
3422
+ const e = this.wnd.getSelection(), i = e?.toString() || "", n = (i && e?.rangeCount ? e.getRangeAt(0)?.getClientRects() : null)?.[0], o = {
3423
+ timestamp: Date.now(),
3424
+ clientX: t.clientX,
3425
+ clientY: t.clientY,
3426
+ ...n && {
3427
+ selectedText: {
3428
+ text: i,
3429
+ x: n.x,
3430
+ y: n.y,
3431
+ width: n.width,
3432
+ height: n.height
3433
+ }
3434
+ },
3435
+ targetFrameSrc: this.wnd.location.href
3436
+ };
3437
+ this.comms?.send("context_menu", o);
3438
+ }
3439
+ }, this.onPointerUp = this.onPointUp.bind(this), this.onPointerMove = this.onPointMove.bind(this), this.onPointerDown = this.onPointDown.bind(this), this.onClicker = this.onClick.bind(this);
2842
3440
  }
2843
- onPointUp(e) {
2844
- const t = this.wnd.getSelection();
2845
- if (t && t.toString()?.length > 0) {
2846
- const r = t.getRangeAt(0)?.getClientRects();
2847
- if (!r || r.length === 0)
3441
+ addContextMenuPrevention() {
3442
+ this.isContextMenuEnabled || !this.wnd || (this.wnd.document.addEventListener("contextmenu", this.onContext), this.isContextMenuEnabled = !0);
3443
+ }
3444
+ removeContextMenuPrevention() {
3445
+ !this.isContextMenuEnabled || !this.wnd || (this.wnd.document.removeEventListener("contextmenu", this.onContext), this.isContextMenuEnabled = !1);
3446
+ }
3447
+ addDragAndDropPrevention() {
3448
+ this.isDragAndDropEnabled || !this.wnd || (this.wnd.document.addEventListener("dragstart", this.onDragStart), this.wnd.document.addEventListener("drop", this.onDrop), this.isDragAndDropEnabled = !0);
3449
+ }
3450
+ removeDragAndDropPrevention() {
3451
+ !this.isDragAndDropEnabled || !this.wnd || (this.wnd.document.removeEventListener("dragstart", this.onDragStart), this.wnd.document.removeEventListener("drop", this.onDrop), this.isDragAndDropEnabled = !1);
3452
+ }
3453
+ enableKeyboardPeripherals(t = []) {
3454
+ this.disableKeyboardPeripherals();
3455
+ const e = (i) => {
3456
+ this.comms?.send("keyboard_peripherals", i);
3457
+ };
3458
+ this.keyDownHandler = this.keyManager.createUnifiedHandler(this.wnd.location.href, t, e, this.wnd), this.wnd && this.wnd.document.addEventListener("keydown", this.keyDownHandler, {
3459
+ capture: !0
3460
+ });
3461
+ }
3462
+ disableKeyboardPeripherals() {
3463
+ this.wnd && this.keyDownHandler && (this.wnd.document.removeEventListener("keydown", this.keyDownHandler, {
3464
+ capture: !0
3465
+ }), this.keyDownHandler = null);
3466
+ }
3467
+ addBulkCopyProtection(t = {}) {
3468
+ if (this.isBulkCopyProtectionEnabled || !this.wnd) return;
3469
+ const e = ui, i = t ? { ...e, ...t } : e;
3470
+ this.bulkCopyProtector = new mi(this.wnd, i), this.wnd.document.addEventListener("copy", this.preventBulkCopy, !0), this.wnd.document.addEventListener("cut", this.preventBulkCopy, !0), this.isBulkCopyProtectionEnabled = !0;
3471
+ }
3472
+ removeBulkCopyProtection() {
3473
+ !this.isBulkCopyProtectionEnabled || !this.wnd || (this.wnd.document.removeEventListener("copy", this.preventBulkCopy, !0), this.wnd.document.removeEventListener("cut", this.preventBulkCopy, !0), this.bulkCopyProtector?.destroy(), this.bulkCopyProtector = null, this.isBulkCopyProtectionEnabled = !1);
3474
+ }
3475
+ addSelectionMonitoring(t) {
3476
+ if (this.isSelectionMonitoringEnabled || !this.wnd) return;
3477
+ const e = t || Re;
3478
+ this.selectionAnalyzer = new fi(e), this.wnd.document.addEventListener("selectionchange", this.handleSelection), this.isSelectionMonitoringEnabled = !0;
3479
+ }
3480
+ removeSelectionMonitoring() {
3481
+ !this.isSelectionMonitoringEnabled || !this.wnd || (this.wnd.document.removeEventListener("selectionchange", this.handleSelection), this.selectionAnalyzer?.clear(), this.selectionAnalyzer = null, this.isSelectionMonitoringEnabled = !1);
3482
+ }
3483
+ onPointUp(t) {
3484
+ const e = this.wnd.getSelection();
3485
+ if (e && e.toString()?.length > 0) {
3486
+ const s = e.getRangeAt(0)?.getClientRects();
3487
+ if (!s || s.length === 0)
2848
3488
  return;
2849
- const n = r[0], o = {
2850
- text: t.toString(),
3489
+ const n = s[0], o = {
3490
+ text: e.toString(),
2851
3491
  x: n.x,
2852
3492
  y: n.y,
2853
3493
  width: n.width,
@@ -2860,21 +3500,21 @@ const Oe = class Oe extends Y {
2860
3500
  this.pointerMoved = !1;
2861
3501
  return;
2862
3502
  }
2863
- if (!t?.isCollapsed || !e.isPrimary) return;
3503
+ if (!e?.isCollapsed || !t.isPrimary) return;
2864
3504
  const i = this.wnd.devicePixelRatio;
2865
- e.preventDefault(), this.comms.send(e.pointerType === "touch" ? "tap" : "click", {
2866
- defaultPrevented: e.defaultPrevented,
2867
- x: e.clientX * i,
2868
- y: e.clientY * i,
3505
+ t.preventDefault(), this.comms.send(t.pointerType === "touch" ? "tap" : "click", {
3506
+ defaultPrevented: t.defaultPrevented,
3507
+ x: t.clientX * i,
3508
+ y: t.clientY * i,
2869
3509
  targetFrameSrc: this.wnd.location.href,
2870
- targetElement: e.target.outerHTML,
2871
- interactiveElement: ct(e.target)?.outerHTML,
2872
- cssSelector: this.wnd._readium_cssSelectorGenerator.getCssSelector(e.target)
3510
+ targetElement: t.target.outerHTML,
3511
+ interactiveElement: Ne(t.target)?.outerHTML,
3512
+ cssSelector: this.wnd._readium_cssSelectorGenerator.getCssSelector(t.target)
2873
3513
  }), this.pointerMoved = !1;
2874
3514
  }
2875
- onPointMove(e) {
2876
- if (e.movementY !== void 0 && e.movementX !== void 0) {
2877
- (Math.abs(e.movementX) > 1 || Math.abs(e.movementY) > 1) && (this.pointerMoved = !0);
3515
+ onPointMove(t) {
3516
+ if (t.movementY !== void 0 && t.movementX !== void 0) {
3517
+ (Math.abs(t.movementX) > 1 || Math.abs(t.movementY) > 1) && (this.pointerMoved = !0);
2878
3518
  return;
2879
3519
  }
2880
3520
  this.pointerMoved = !0;
@@ -2882,57 +3522,78 @@ const Oe = class Oe extends Y {
2882
3522
  onPointDown() {
2883
3523
  this.pointerMoved = !1;
2884
3524
  }
2885
- onContext(e) {
2886
- this.onPointUp(e), this.pointerMoved = !1;
2887
- }
2888
- onClick(e) {
2889
- if (e.preventDefault(), !e.isTrusted) {
2890
- const t = new PointerEvent("pointerup", {
3525
+ onClick(t) {
3526
+ if (t.preventDefault(), !t.isTrusted) {
3527
+ const e = new PointerEvent("pointerup", {
2891
3528
  isPrimary: !0,
2892
3529
  pointerType: "mouse",
2893
3530
  // Not really a better choice than this
2894
- clientX: e.clientX,
2895
- clientY: e.clientY
3531
+ clientX: t.clientX,
3532
+ clientY: t.clientY
2896
3533
  });
2897
- Object.defineProperty(t, "target", { writable: !1, value: e.target }), Object.defineProperty(t, "defaultPrevented", { writable: !1, value: e.defaultPrevented }), this.onPointUp(t);
3534
+ Object.defineProperty(e, "target", { writable: !1, value: t.target }), Object.defineProperty(e, "defaultPrevented", { writable: !1, value: t.defaultPrevented }), this.onPointUp(e);
2898
3535
  }
2899
3536
  }
2900
- mount(e, t) {
2901
- return this.wnd = e, this.comms = t, e.document.addEventListener("pointerdown", this.onPointerDown), e.document.addEventListener("pointerup", this.onPointerUp), e.document.addEventListener("contextmenu", this.onContextMenu), e.document.addEventListener("pointermove", this.onPointerMove), e.document.addEventListener("click", this.onClicker), t.log("Peripherals Mounted"), !0;
3537
+ registerProtectionHandlers() {
3538
+ this.comms?.register("peripherals_protection", $.moduleName, (t, e) => {
3539
+ const i = t;
3540
+ if (!this.configApplied) {
3541
+ if (this.configApplied = !0, i.monitorSelection) {
3542
+ const s = typeof i.monitorSelection == "boolean" ? void 0 : i.monitorSelection;
3543
+ this.addSelectionMonitoring(s), this.comms?.log("Selection monitoring enabled");
3544
+ }
3545
+ typeof i.protectCopy == "object" ? (this.addBulkCopyProtection({
3546
+ enabled: !0,
3547
+ ...i.protectCopy
3548
+ }), this.comms?.log("Copy protection enabled (limited)")) : i.protectCopy === !0 && (this.addBulkCopyProtection({
3549
+ enabled: !0,
3550
+ maxSelectionPercent: 0,
3551
+ minThreshold: 0,
3552
+ absoluteMaxChars: 0
3553
+ }), this.comms?.log("Copy protection enabled")), i.disableContextMenu && (this.addContextMenuPrevention(), this.comms?.log("Context menu protection enabled")), i.disableDragAndDrop && (this.addDragAndDropPrevention(), this.comms?.log("Drag and drop protection enabled"));
3554
+ }
3555
+ e(!0);
3556
+ }), this.comms?.register("keyboard_peripherals", $.moduleName, (t, e) => {
3557
+ const i = t;
3558
+ i && i.length > 0 && (this.enableKeyboardPeripherals(i), this.comms?.log(`Keyboard peripherals enabled: ${i.map((s) => s.type).join(", ")}`)), e(!0);
3559
+ });
3560
+ }
3561
+ mount(t, e) {
3562
+ return this.wnd = t, this.comms = e, this.registerProtectionHandlers(), t.document.addEventListener("pointerdown", this.onPointerDown), t.document.addEventListener("pointerup", this.onPointerUp), t.document.addEventListener("pointermove", this.onPointerMove), t.document.addEventListener("click", this.onClicker), e.log("Peripherals Mounted"), !0;
2902
3563
  }
2903
- unmount(e, t) {
2904
- return e.document.removeEventListener("pointerdown", this.onPointerDown), e.document.removeEventListener("pointerup", this.onPointerUp), e.document.removeEventListener("contextmenu", this.onContextMenu), e.document.removeEventListener("pointermove", this.onPointerMove), e.document.removeEventListener("click", this.onClicker), t.log("Peripherals Unmounted"), !0;
3564
+ unmount(t, e) {
3565
+ return this.removeBulkCopyProtection(), this.removeSelectionMonitoring(), this.removeContextMenuPrevention(), this.removeDragAndDropPrevention(), this.disableKeyboardPeripherals(), this.cleanupCallbacks.forEach((i) => i()), this.cleanupCallbacks = [], t.document.removeEventListener("pointerdown", this.onPointerDown), t.document.removeEventListener("pointerup", this.onPointerUp), t.document.removeEventListener("pointermove", this.onPointerMove), t.document.removeEventListener("click", this.onClicker), e.unregisterAll($.moduleName), this.configApplied = !1, e.log("Peripherals Unmounted"), !0;
2905
3566
  }
2906
3567
  };
2907
- Oe.moduleName = "peripherals";
2908
- let ve = Oe;
2909
- const _ = class _ extends Y {
3568
+ $.moduleName = "peripherals";
3569
+ let Tt = $;
3570
+ const tt = class tt extends X {
2910
3571
  constructor() {
2911
3572
  super(...arguments), this.mediaPlayingCount = 0, this.allAnimations = /* @__PURE__ */ new Set();
2912
3573
  }
2913
- wndOnErr(e) {
3574
+ wndOnErr(t) {
2914
3575
  this.comms?.send("error", {
2915
- message: e.message,
2916
- filename: e.filename,
2917
- lineno: e.lineno,
2918
- colno: e.colno
3576
+ message: t.message,
3577
+ filename: t.filename,
3578
+ lineno: t.lineno,
3579
+ colno: t.colno
2919
3580
  });
2920
3581
  }
2921
- unblock(e) {
2922
- for (e._readium_blockEvents = !1; e._readium_blockedEvents?.length > 0; ) {
2923
- const t = e._readium_blockedEvents.shift();
2924
- switch (t[0]) {
3582
+ unblock(t) {
3583
+ for (t._readium_blockEvents = !1; t._readium_blockedEvents?.length > 0; ) {
3584
+ const e = t._readium_blockedEvents.shift();
3585
+ switch (e[0]) {
2925
3586
  case 0:
2926
- Reflect.apply(t[1], t[2], t[3]);
3587
+ Reflect.apply(e[1], e[2], e[3]);
2927
3588
  break;
2928
3589
  case 1:
2929
- const i = t[1], r = t[2];
2930
- e.removeEventListener(i.type, e._readium_eventBlocker, !0);
3590
+ const i = e[1], s = e[2];
3591
+ t.removeEventListener(i.type, t._readium_eventBlocker, !0);
2931
3592
  const n = new Event(i.type, {
2932
3593
  bubbles: i.bubbles,
2933
3594
  cancelable: i.cancelable
2934
3595
  });
2935
- r ? r.dispatchEvent(n) : e.dispatchEvent(n);
3596
+ s ? s.dispatchEvent(n) : t.dispatchEvent(n);
2936
3597
  break;
2937
3598
  }
2938
3599
  }
@@ -2943,22 +3604,22 @@ const _ = class _ extends Y {
2943
3604
  onMediaPauseEvent() {
2944
3605
  this.mediaPlayingCount > 0 && this.mediaPlayingCount--, this.comms?.send("media_pause", this.mediaPlayingCount);
2945
3606
  }
2946
- pauseAllMedia(e) {
2947
- const t = e.document.querySelectorAll("audio,video");
2948
- for (let i = 0; i < t.length; i++)
2949
- t[i].pause();
3607
+ pauseAllMedia(t) {
3608
+ const e = t.document.querySelectorAll("audio,video");
3609
+ for (let i = 0; i < e.length; i++)
3610
+ e[i].pause();
2950
3611
  }
2951
- mount(e, t) {
2952
- this.comms = t, e.addEventListener(
3612
+ mount(t, e) {
3613
+ this.comms = e, t.addEventListener(
2953
3614
  "error",
2954
3615
  this.wndOnErr,
2955
3616
  !1
2956
- ), Reflect.defineProperty(e.navigator, "epubReadingSystem", {
3617
+ ), Reflect.defineProperty(t.navigator, "epubReadingSystem", {
2957
3618
  value: {
2958
3619
  name: "readium-ts-toolkit",
2959
- version: "2.2.4",
2960
- hasFeature: (r, n = "") => {
2961
- switch (r) {
3620
+ version: "2.3.0",
3621
+ hasFeature: (s, n = "") => {
3622
+ switch (s) {
2962
3623
  case "dom-manipulation":
2963
3624
  return !0;
2964
3625
  case "layout-changes":
@@ -2979,70 +3640,70 @@ const _ = class _ extends Y {
2979
3640
  }
2980
3641
  },
2981
3642
  writable: !1
2982
- }), "getAnimations" in e.document && e.document.getAnimations().forEach((r) => {
2983
- r.cancel(), this.allAnimations.add(r);
2984
- }), t.register("activate", _.moduleName, (r, n) => {
3643
+ }), "getAnimations" in t.document && t.document.getAnimations().forEach((s) => {
3644
+ s.cancel(), this.allAnimations.add(s);
3645
+ }), e.register("activate", tt.moduleName, (s, n) => {
2985
3646
  this.allAnimations.forEach((o) => {
2986
3647
  o.cancel(), o.play();
2987
3648
  }), n(!0);
2988
- }), t.register("unfocus", _.moduleName, (r, n) => {
2989
- this.pauseAllMedia(e), this.allAnimations.forEach((o) => o.pause()), n(!0);
3649
+ }), e.register("unfocus", tt.moduleName, (s, n) => {
3650
+ this.pauseAllMedia(t), this.allAnimations.forEach((o) => o.pause()), n(!0);
2990
3651
  });
2991
- const i = e.document.querySelectorAll("audio,video");
2992
- for (let r = 0; r < i.length; r++) {
2993
- const n = i[r];
3652
+ const i = t.document.querySelectorAll("audio,video");
3653
+ for (let s = 0; s < i.length; s++) {
3654
+ const n = i[s];
2994
3655
  n.addEventListener("play", this.onMediaPlayEvent, {
2995
3656
  passive: !0
2996
3657
  }), n.addEventListener("pause", this.onMediaPauseEvent, {
2997
3658
  passive: !0
2998
3659
  });
2999
3660
  }
3000
- return t.log("Setup Mounted"), !0;
3661
+ return e.log("Setup Mounted"), !0;
3001
3662
  }
3002
- unmount(e, t) {
3003
- return e.removeEventListener("error", this.wndOnErr), e.removeEventListener("play", this.onMediaPlayEvent), e.removeEventListener("pause", this.onMediaPauseEvent), this.allAnimations.forEach((i) => i.cancel()), this.allAnimations.clear(), t.log("Setup Unmounted"), !0;
3663
+ unmount(t, e) {
3664
+ return t.removeEventListener("error", this.wndOnErr), t.removeEventListener("play", this.onMediaPlayEvent), t.removeEventListener("pause", this.onMediaPauseEvent), this.allAnimations.forEach((i) => i.cancel()), this.allAnimations.clear(), e.log("Setup Unmounted"), !0;
3004
3665
  }
3005
3666
  };
3006
- _.moduleName = "setup";
3007
- let se = _;
3008
- const Ke = "readium-viewport", O = class O extends se {
3009
- onViewportWidthChanged(e) {
3010
- const t = e.target;
3011
- X(t, "--RS__viewportWidth", `${t.innerWidth}px`);
3012
- }
3013
- mount(e, t) {
3014
- if (!super.mount(e, t)) return !1;
3015
- const i = e.document.createElement("meta");
3016
- return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id", Ke), i.setAttribute(
3667
+ tt.moduleName = "setup";
3668
+ let ut = tt;
3669
+ const me = "readium-viewport", M = class M extends ut {
3670
+ onViewportWidthChanged(t) {
3671
+ const e = t.target;
3672
+ it(e, "--RS__viewportWidth", `${e.innerWidth}px`);
3673
+ }
3674
+ mount(t, e) {
3675
+ if (!super.mount(t, e)) return !1;
3676
+ const i = t.document.createElement("meta");
3677
+ return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id", me), i.setAttribute(
3017
3678
  "content",
3018
3679
  "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"
3019
- ), e.document.head.appendChild(i), e.addEventListener("orientationchange", this.onViewportWidthChanged), e.addEventListener("resize", this.onViewportWidthChanged), this.onViewportWidthChanged({
3020
- target: e
3021
- }), t.register("get_properties", O.moduleName, (r, n) => {
3022
- Me(e), n(!0);
3023
- }), t.register("update_properties", O.moduleName, (r, n) => {
3024
- r["--RS__viewportWidth"] = `${e.innerWidth}px`, at(e, r), n(!0);
3025
- }), t.register("set_property", O.moduleName, (r, n) => {
3026
- const o = r;
3027
- X(e, o[0], o[1]), n(!0);
3028
- }), t.register("remove_property", O.moduleName, (r, n) => {
3029
- oe(e, r), n(!0);
3030
- }), t.register("activate", O.moduleName, (r, n) => {
3031
- this.unblock(e), n(!0);
3032
- }), t.log("ReflowableSetup Mounted"), !0;
3033
- }
3034
- unmount(e, t) {
3035
- return t.unregisterAll(O.moduleName), e.document.head.querySelector(`#${Ke}`)?.remove(), e.removeEventListener("orientationchange", this.onViewportWidthChanged), t.log("ReflowableSetup Unmounted"), super.unmount(e, t);
3680
+ ), t.document.head.appendChild(i), t.addEventListener("orientationchange", this.onViewportWidthChanged), t.addEventListener("resize", this.onViewportWidthChanged), this.onViewportWidthChanged({
3681
+ target: t
3682
+ }), e.register("get_properties", M.moduleName, (s, n) => {
3683
+ Wt(t), n(!0);
3684
+ }), e.register("update_properties", M.moduleName, (s, n) => {
3685
+ s["--RS__viewportWidth"] = `${t.innerWidth}px`, xe(t, s), n(!0);
3686
+ }), e.register("set_property", M.moduleName, (s, n) => {
3687
+ const o = s;
3688
+ it(t, o[0], o[1]), n(!0);
3689
+ }), e.register("remove_property", M.moduleName, (s, n) => {
3690
+ mt(t, s), n(!0);
3691
+ }), e.register("activate", M.moduleName, (s, n) => {
3692
+ this.unblock(t), n(!0);
3693
+ }), e.log("ReflowableSetup Mounted"), !0;
3694
+ }
3695
+ unmount(t, e) {
3696
+ return e.unregisterAll(M.moduleName), t.document.head.querySelector(`#${me}`)?.remove(), t.removeEventListener("orientationchange", this.onViewportWidthChanged), e.log("ReflowableSetup Unmounted"), super.unmount(t, e);
3036
3697
  }
3037
3698
  };
3038
- O.moduleName = "reflowable_setup";
3039
- let be = O;
3040
- const Ze = "readium-fixed-style", A = class A extends se {
3041
- mount(e, t) {
3042
- if (!super.mount(e, t)) return !1;
3043
- e.navigator.epubReadingSystem && (e.navigator.epubReadingSystem.layoutStyle = "paginated");
3044
- const i = e.document.createElement("style");
3045
- return i.id = Ze, i.dataset.readium = "true", i.textContent = `
3699
+ M.moduleName = "reflowable_setup";
3700
+ let Pt = M;
3701
+ const fe = "readium-fixed-style", D = class D extends ut {
3702
+ mount(t, e) {
3703
+ if (!super.mount(t, e)) return !1;
3704
+ t.navigator.epubReadingSystem && (t.navigator.epubReadingSystem.layoutStyle = "paginated");
3705
+ const i = t.document.createElement("style");
3706
+ return i.id = fe, i.dataset.readium = "true", i.textContent = `
3046
3707
  html, body {
3047
3708
  text-size-adjust: none;
3048
3709
  -ms-text-size-adjust: none;
@@ -3054,14 +3715,14 @@ const Ze = "readium-fixed-style", A = class A extends se {
3054
3715
  min-height: 100%;
3055
3716
 
3056
3717
  /*cursor: var() TODO*/
3057
- }`, e.document.head.appendChild(i), t.register("set_property", A.moduleName, (r, n) => {
3058
- const o = r;
3059
- X(e, o[0], o[1]), n(!0);
3060
- }), t.register("remove_property", A.moduleName, (r, n) => {
3061
- oe(e, r), n(!0);
3062
- }), t.register("first_visible_locator", A.moduleName, (r, n) => n(!1)), t.register("unfocus", A.moduleName, (r, n) => {
3063
- v(e), n(!0);
3064
- }), t.register([
3718
+ }`, t.document.head.appendChild(i), e.register("set_property", D.moduleName, (s, n) => {
3719
+ const o = s;
3720
+ it(t, o[0], o[1]), n(!0);
3721
+ }), e.register("remove_property", D.moduleName, (s, n) => {
3722
+ mt(t, s), n(!0);
3723
+ }), e.register("first_visible_locator", D.moduleName, (s, n) => n(!1)), e.register("unfocus", D.moduleName, (s, n) => {
3724
+ A(t), n(!0);
3725
+ }), e.register([
3065
3726
  "focus",
3066
3727
  "go_next",
3067
3728
  "go_prev",
@@ -3070,137 +3731,245 @@ const Ze = "readium-fixed-style", A = class A extends se {
3070
3731
  "go_start",
3071
3732
  "go_text",
3072
3733
  "go_progression"
3073
- ], A.moduleName, (r, n) => n(!0)), t.register("activate", A.moduleName, (r, n) => {
3074
- this.unblock(e), n(!0);
3075
- }), t.log("FixedSetup Mounted"), !0;
3734
+ ], D.moduleName, (s, n) => n(!0)), e.register("activate", D.moduleName, (s, n) => {
3735
+ this.unblock(t), n(!0);
3736
+ }), e.log("FixedSetup Mounted"), !0;
3076
3737
  }
3077
- unmount(e, t) {
3078
- return t.unregisterAll(A.moduleName), e.document.getElementById(Ze)?.remove(), t.log("FixedSetup Unmounted"), super.unmount(e, t);
3738
+ unmount(t, e) {
3739
+ return e.unregisterAll(D.moduleName), t.document.getElementById(fe)?.remove(), e.log("FixedSetup Unmounted"), super.unmount(t, e);
3079
3740
  }
3080
3741
  };
3081
- A.moduleName = "fixed_setup";
3082
- let Ee = A;
3083
- const L = class L extends Y {
3084
- wndOnErr(e) {
3742
+ D.moduleName = "fixed_setup";
3743
+ let Nt = D;
3744
+ const k = class k extends X {
3745
+ wndOnErr(t) {
3085
3746
  this.comms?.send("error", {
3086
- message: e.message,
3087
- filename: e.filename,
3088
- lineno: e.lineno,
3089
- colno: e.colno
3747
+ message: t.message,
3748
+ filename: t.filename,
3749
+ lineno: t.lineno,
3750
+ colno: t.colno
3090
3751
  });
3091
3752
  }
3092
- mount(e, t) {
3093
- return this.comms = t, e.addEventListener(
3753
+ mount(t, e) {
3754
+ return this.comms = e, t.addEventListener(
3094
3755
  "error",
3095
3756
  this.wndOnErr,
3096
3757
  !1
3097
- ), t.register("get_properties", L.moduleName, (i, r) => {
3098
- Me(e), r(!0);
3099
- }), t.register("update_properties", L.moduleName, (i, r) => {
3100
- at(e, i), r(!0);
3101
- }), t.register("set_property", L.moduleName, (i, r) => {
3758
+ ), e.register("get_properties", k.moduleName, (i, s) => {
3759
+ Wt(t), s(!0);
3760
+ }), e.register("update_properties", k.moduleName, (i, s) => {
3761
+ xe(t, i), s(!0);
3762
+ }), e.register("set_property", k.moduleName, (i, s) => {
3102
3763
  const n = i;
3103
- X(e, n[0], n[1]), r(!0);
3104
- }), t.register("remove_property", L.moduleName, (i, r) => {
3105
- oe(e, i), r(!0);
3106
- }), t.register("activate", L.moduleName, (i, r) => {
3107
- r(!0);
3108
- }), t.log("WebPubSetup Mounted"), !0;
3764
+ it(t, n[0], n[1]), s(!0);
3765
+ }), e.register("remove_property", k.moduleName, (i, s) => {
3766
+ mt(t, i), s(!0);
3767
+ }), e.register("activate", k.moduleName, (i, s) => {
3768
+ s(!0);
3769
+ }), e.log("WebPubSetup Mounted"), !0;
3770
+ }
3771
+ unmount(t, e) {
3772
+ return e.unregisterAll(k.moduleName), t.removeEventListener("error", this.wndOnErr), e.log("WebPubSetup Unmounted"), !0;
3773
+ }
3774
+ };
3775
+ k.moduleName = "webpub_setup";
3776
+ let Lt = k;
3777
+ const et = class et extends X {
3778
+ constructor() {
3779
+ super(...arguments), this.styleElement = null, this.beforePrintHandler = null, this.configApplied = !1;
3780
+ }
3781
+ setupPrintProtection(t, e) {
3782
+ if (!e.disable) return;
3783
+ const i = t.document.createElement("style");
3784
+ i.textContent = `
3785
+ @media print {
3786
+ body * {
3787
+ display: none !important;
3788
+ }
3789
+ body::after {
3790
+ content: "${e.watermark || "Printing has been disabled"}";
3791
+ font-size: 200%;
3792
+ display: block;
3793
+ text-align: center;
3794
+ margin-top: 50vh;
3795
+ transform: translateY(-50%);
3796
+ }
3797
+ }
3798
+ `, t.document.head.appendChild(i), this.styleElement = i, this.beforePrintHandler = (s) => (s.preventDefault(), !1), t.addEventListener("beforeprint", this.beforePrintHandler);
3799
+ }
3800
+ registerPrintHandlers() {
3801
+ this.comms?.register("print_protection", et.moduleName, (t) => {
3802
+ const e = t;
3803
+ return this.configApplied || (this.configApplied = !0, this.setupPrintProtection(this.wnd, e), this.comms?.log("Print protection configuration applied")), !0;
3804
+ });
3805
+ }
3806
+ mount(t, e) {
3807
+ return this.wnd = t, this.comms = e, this.registerPrintHandlers(), !0;
3109
3808
  }
3110
- unmount(e, t) {
3111
- return t.unregisterAll(L.moduleName), e.removeEventListener("error", this.wndOnErr), t.log("WebPubSetup Unmounted"), !0;
3809
+ unmount(t, e) {
3810
+ return this.beforePrintHandler && (t.removeEventListener("beforeprint", this.beforePrintHandler), this.beforePrintHandler = null), this.styleElement?.parentNode && (this.styleElement.parentNode.removeChild(this.styleElement), this.styleElement = null), this.comms?.unregisterAll(et.moduleName), this.configApplied = !1, !0;
3112
3811
  }
3113
3812
  };
3114
- L.moduleName = "webpub_setup";
3115
- let xe = L;
3116
- const jt = [
3813
+ et.moduleName = "print_protection";
3814
+ let Ot = et;
3815
+ const yi = [
3117
3816
  "fixed_setup",
3118
3817
  "decorator",
3119
- "peripherals"
3120
- ], _t = [
3818
+ "peripherals",
3819
+ "print_protection"
3820
+ ], bi = [
3121
3821
  "reflowable_setup",
3122
3822
  "decorator",
3123
3823
  "peripherals",
3124
3824
  "column_snapper",
3125
- "scroll_snapper"
3126
- ], Xt = [
3825
+ "scroll_snapper",
3826
+ "print_protection"
3827
+ ], vi = [
3127
3828
  "webpub_setup",
3128
3829
  "webpub_snapper",
3129
3830
  "decorator",
3130
- "peripherals"
3131
- ], Je = new Map([
3831
+ "peripherals",
3832
+ "print_protection"
3833
+ ], ge = new Map([
3132
3834
  // All modules go here
3133
- Ee,
3134
- be,
3135
- xe,
3136
- ye,
3137
- ve,
3138
- fe,
3139
- me,
3140
- ge
3141
- ].map((s) => [s.moduleName, s]));
3142
- class Gt {
3835
+ Nt,
3836
+ Pt,
3837
+ Lt,
3838
+ xt,
3839
+ Tt,
3840
+ Et,
3841
+ At,
3842
+ Ct,
3843
+ Ot
3844
+ ].map((r) => [r.moduleName, r]));
3845
+ class wi {
3143
3846
  /**
3144
3847
  * @param wnd Window instance to operate on
3145
3848
  * @param initialModules List of initial modules to load
3146
3849
  */
3147
- constructor(e = window, t = []) {
3148
- this.loadedModules = [], this.wnd = e, this.comms = new ft(e);
3149
- const i = [...new Set(t)];
3850
+ constructor(t = window, e = []) {
3851
+ this.loadedModules = [], this.wnd = t, this.comms = new ze(t);
3852
+ const i = [...new Set(e)];
3150
3853
  if (i.length) {
3151
- if (typeof e > "u")
3854
+ if (typeof t > "u")
3152
3855
  throw Error("Loader is not in a web browser");
3153
- e.parent !== e && this.comms.log("Loader is probably in a frame"), this.loadedModules = i.map((r) => {
3154
- const n = this.loadModule(r);
3856
+ t.parent !== t && this.comms.log("Loader is probably in a frame"), this.loadedModules = i.map((s) => {
3857
+ const n = this.loadModule(s);
3155
3858
  if (n)
3156
3859
  return n.mount(this.wnd, this.comms), n;
3157
- }).filter((r) => r !== void 0);
3860
+ }).filter((s) => s !== void 0);
3158
3861
  }
3159
3862
  }
3160
- loadModule(e) {
3161
- const t = Je.get(e);
3162
- return t === void 0 ? (this.comms.log(`Module "${name}" does not exist in the library`), t) : new t();
3863
+ loadModule(t) {
3864
+ const e = ge.get(t);
3865
+ return e === void 0 ? (this.comms.log(`Module "${name}" does not exist in the library`), e) : new e();
3163
3866
  }
3164
3867
  /**
3165
3868
  * Add a module by name
3166
3869
  * @param moduleName Module name
3167
3870
  * @returns Success
3168
3871
  */
3169
- addModule(e) {
3170
- const t = this.loadModule(e);
3171
- return !t || !t.mount(this.wnd, this.comms) ? !1 : (this.loadedModules.push(t), !0);
3872
+ addModule(t) {
3873
+ const e = this.loadModule(t);
3874
+ return !e || !e.mount(this.wnd, this.comms) ? !1 : (this.loadedModules.push(e), !0);
3172
3875
  }
3173
3876
  /**
3174
3877
  * Remove a module by name
3175
3878
  * @param moduleName Module name
3176
3879
  * @returns Success
3177
3880
  */
3178
- removeModule(e) {
3179
- const t = Je.get(e);
3180
- if (t === void 0)
3181
- return this.comms.log(`Module "${e}" does not exist in the library`), !1;
3182
- const i = this.loadedModules.findIndex((r) => r instanceof t);
3881
+ removeModule(t) {
3882
+ const e = ge.get(t);
3883
+ if (e === void 0)
3884
+ return this.comms.log(`Module "${t}" does not exist in the library`), !1;
3885
+ const i = this.loadedModules.findIndex((s) => s instanceof e);
3183
3886
  return i < 0 ? !1 : (this.loadedModules[i].unmount(this.wnd, this.comms), this.loadedModules.splice(i, 1), !0);
3184
3887
  }
3185
3888
  /**
3186
3889
  * Unmount and remove all modules
3187
3890
  */
3188
3891
  destroy() {
3189
- this.comms.destroy(), this.loadedModules.forEach((e) => e.unmount(this.wnd, this.comms)), this.loadedModules = [];
3190
- }
3191
- }
3892
+ this.comms.destroy(), this.loadedModules.forEach((t) => t.unmount(this.wnd, this.comms)), this.loadedModules = [];
3893
+ }
3894
+ }
3895
+ const Si = {
3896
+ type: "developer_tools",
3897
+ keyCombos: [
3898
+ { keyCode: 73, meta: !0, alt: !0 },
3899
+ // I key
3900
+ { keyCode: 74, meta: !0, alt: !0 },
3901
+ // J key
3902
+ { keyCode: 85, meta: !0, alt: !0 },
3903
+ // U key
3904
+ { keyCode: 67, meta: !0, alt: !0 },
3905
+ // C key
3906
+ { keyCode: 67, meta: !0, shift: !0 },
3907
+ // C key (Cmd+Shift+C)
3908
+ { keyCode: 67, ctrl: !0, shift: !0 },
3909
+ // C key (Ctrl+Shift+C)
3910
+ { keyCode: 123 },
3911
+ // F12
3912
+ { keyCode: 123, shift: !0 },
3913
+ // F12+Shift
3914
+ { keyCode: 123, ctrl: !0, shift: !0 },
3915
+ // F12+Ctrl+Shift
3916
+ { keyCode: 123, meta: !0, alt: !0 }
3917
+ // F12+Meta+Alt
3918
+ ]
3919
+ }, Ei = {
3920
+ type: "select_all",
3921
+ keyCombos: [
3922
+ { keyCode: 65, meta: !0 },
3923
+ // A key (Cmd+A)
3924
+ { keyCode: 65, ctrl: !0 }
3925
+ // A key (Ctrl+A)
3926
+ ]
3927
+ }, Ai = {
3928
+ type: "print",
3929
+ keyCombos: [
3930
+ { keyCode: 80, meta: !0 },
3931
+ // P key (Cmd+P)
3932
+ { keyCode: 80, ctrl: !0 },
3933
+ // P key (Ctrl+P)
3934
+ { keyCode: 80, meta: !0, shift: !0 },
3935
+ // P key (Cmd+Shift+P)
3936
+ { keyCode: 80, ctrl: !0, shift: !0 },
3937
+ // P key (Ctrl+Shift+P)
3938
+ { keyCode: 80, meta: !0, alt: !0 },
3939
+ // P key (Cmd+Alt+P)
3940
+ { keyCode: 80, ctrl: !0, alt: !0 }
3941
+ // P key (Ctrl+Alt+P)
3942
+ ]
3943
+ }, Ci = {
3944
+ type: "save",
3945
+ keyCombos: [
3946
+ { keyCode: 83, meta: !0 },
3947
+ // S key (Cmd+S)
3948
+ { keyCode: 83, ctrl: !0 }
3949
+ // S key (Ctrl+S)
3950
+ ]
3951
+ };
3192
3952
  export {
3193
- k as COMMS_VERSION,
3194
- ft as Comms,
3195
- fe as Decorator,
3196
- jt as FXLModules,
3197
- Dt as Layout,
3198
- Gt as Loader,
3199
- Y as Module,
3200
- Je as ModuleLibrary,
3201
- ve as Peripherals,
3202
- _t as ReflowableModules,
3203
- Xt as WebPubModules,
3204
- zt as Width,
3205
- pt as mid
3953
+ mi as BulkCopyProtector,
3954
+ K as COMMS_VERSION,
3955
+ ze as Comms,
3956
+ Si as DEV_TOOLS,
3957
+ Et as Decorator,
3958
+ yi as FXLModules,
3959
+ gi as KeyCombinationManager,
3960
+ si as Layout,
3961
+ wi as Loader,
3962
+ X as Module,
3963
+ ge as ModuleLibrary,
3964
+ Ai as PRINT,
3965
+ Bt as PatternAnalyzer,
3966
+ Tt as Peripherals,
3967
+ Ot as PrintProtector,
3968
+ bi as ReflowableModules,
3969
+ Ci as SAVE,
3970
+ Ei as SELECT_ALL,
3971
+ fi as SelectionAnalyzer,
3972
+ vi as WebPubModules,
3973
+ ii as Width,
3974
+ De as mid
3206
3975
  };