@readium/navigator-html-injectables 2.3.1 → 2.4.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +816 -660
- package/dist/index.umd.cjs +21 -10
- package/package.json +1 -1
- package/src/Loader.ts +3 -3
- package/src/helpers/document.ts +4 -1
- package/src/modules/ModuleLibrary.ts +4 -0
- package/src/modules/snapper/CJKVerticalSnapper.ts +322 -0
- package/src/modules/snapper/ColumnSnapper.ts +139 -58
- package/types/src/Loader.d.ts +2 -2
- package/types/src/modules/ModuleLibrary.d.ts +1 -1
- package/types/src/modules/snapper/CJKVerticalSnapper.d.ts +57 -0
- package/types/src/modules/snapper/ColumnSnapper.d.ts +11 -0
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
class
|
|
1
|
+
const Ue = Math.pow(2, 32), qt = () => Math.round(Math.random() * Ue).toString(36), Be = () => `${Math.round(performance.now())}-${qt()}-${qt()}`, J = 1;
|
|
2
|
+
class He {
|
|
3
3
|
constructor(t) {
|
|
4
4
|
this.destination = null, this.registrar = /* @__PURE__ */ new Map(), this.origin = "", this.channelId = "", this.receiver = this.receive.bind(this), this.preLog = [], this.wnd = t, t.addEventListener("message", this.receiver);
|
|
5
5
|
}
|
|
@@ -10,8 +10,8 @@ class ze {
|
|
|
10
10
|
if (!(!("_readium" in e) || !e._readium || e._readium <= 0)) {
|
|
11
11
|
if (e.key === "_ping") {
|
|
12
12
|
if (!this.destination) {
|
|
13
|
-
if (this.destination = t.source, this.origin = t.origin, this.channelId = e._channel, e._readium !==
|
|
14
|
-
e._readium >
|
|
13
|
+
if (this.destination = t.source, this.origin = t.origin, this.channelId = e._channel, e._readium !== J) {
|
|
14
|
+
e._readium > J ? this.send("error", `received comms version ${e._readium} higher than ${J}`) : this.send("error", `received comms version ${e._readium} lower than ${J}`), 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 = [];
|
|
@@ -71,9 +71,9 @@ class ze {
|
|
|
71
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:
|
|
74
|
+
_readium: J,
|
|
75
75
|
_channel: this.channelId,
|
|
76
|
-
id: i ??
|
|
76
|
+
id: i ?? Be(),
|
|
77
77
|
// scrict,
|
|
78
78
|
key: t,
|
|
79
79
|
data: e
|
|
@@ -126,7 +126,7 @@ const y = class y {
|
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
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
|
|
129
|
+
let Xt = y;
|
|
130
130
|
const w = class w {
|
|
131
131
|
constructor(t) {
|
|
132
132
|
this.value = t;
|
|
@@ -146,16 +146,16 @@ const w = class w {
|
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
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
|
|
150
|
-
const
|
|
149
|
+
let Kt = w;
|
|
150
|
+
const x = class x {
|
|
151
151
|
constructor(t) {
|
|
152
152
|
if (typeof t == "string") {
|
|
153
|
-
if (!
|
|
153
|
+
if (!x.VALID_MODES.has(t.toLowerCase()))
|
|
154
154
|
return;
|
|
155
155
|
this.value = t.toLowerCase();
|
|
156
156
|
} else {
|
|
157
157
|
const e = t.filter(
|
|
158
|
-
(i) =>
|
|
158
|
+
(i) => x.VALID_MODES.has(i.toLowerCase())
|
|
159
159
|
);
|
|
160
160
|
if (e.length === 0)
|
|
161
161
|
return;
|
|
@@ -168,11 +168,11 @@ const T = class T {
|
|
|
168
168
|
static deserialize(t) {
|
|
169
169
|
if (!t) return;
|
|
170
170
|
if (typeof t == "string")
|
|
171
|
-
return new
|
|
171
|
+
return new x(t);
|
|
172
172
|
if (!Array.isArray(t)) return;
|
|
173
|
-
const e = t.filter((i) => i ?
|
|
173
|
+
const e = t.filter((i) => i ? x.VALID_MODES.has(i.toLowerCase()) : !1);
|
|
174
174
|
if (e.length !== 0)
|
|
175
|
-
return new
|
|
175
|
+
return new x(e);
|
|
176
176
|
}
|
|
177
177
|
/**
|
|
178
178
|
* Serializes a [PrimaryAccessMode] to its RWPM JSON representation.
|
|
@@ -181,9 +181,9 @@ const T = class T {
|
|
|
181
181
|
return this.value;
|
|
182
182
|
}
|
|
183
183
|
};
|
|
184
|
-
|
|
185
|
-
let
|
|
186
|
-
const
|
|
184
|
+
x.VALID_MODES = /* @__PURE__ */ new Set(["auditory", "tactile", "textual", "visual"]), x.AUDITORY = new x("auditory"), x.TACTILE = new x("tactile"), x.TEXTUAL = new x("textual"), x.VISUAL = new x("visual");
|
|
185
|
+
let Zt = x;
|
|
186
|
+
const h = class h {
|
|
187
187
|
constructor(t) {
|
|
188
188
|
this.value = t;
|
|
189
189
|
}
|
|
@@ -192,7 +192,7 @@ const c = class c {
|
|
|
192
192
|
*/
|
|
193
193
|
static deserialize(t) {
|
|
194
194
|
if (!(!t || typeof t != "string"))
|
|
195
|
-
return new
|
|
195
|
+
return new h(t);
|
|
196
196
|
}
|
|
197
197
|
/**
|
|
198
198
|
* Serializes a [Feature] to its RWPM JSON representation.
|
|
@@ -201,9 +201,9 @@ const c = class c {
|
|
|
201
201
|
return this.value;
|
|
202
202
|
}
|
|
203
203
|
};
|
|
204
|
-
|
|
205
|
-
let
|
|
206
|
-
const
|
|
204
|
+
h.NONE = new h("none"), h.ANNOTATIONS = new h("annotations"), h.ARIA = new h("ARIA"), h.INDEX = new h("index"), h.PAGE_BREAK_MARKERS = new h("pageBreakMarkers"), h.PAGE_NAVIGATION = new h("pageNavigation"), h.PRINT_PAGE_NUMBERS = new h("printPageNumbers"), h.READING_ORDER = new h("readingOrder"), h.STRUCTURAL_NAVIGATION = new h("structuralNavigation"), h.TABLE_OF_CONTENTS = new h("tableOfContents"), h.TAGGED_PDF = new h("taggedPDF"), h.ALTERNATIVE_TEXT = new h("alternativeText"), h.AUDIO_DESCRIPTION = new h("audioDescription"), h.CAPTIONS = new h("captions"), h.CLOSED_CAPTIONS = new h("closedCaptions"), h.DESCRIBED_MATH = new h("describedMath"), h.LONG_DESCRIPTION = new h("longDescription"), h.OPEN_CAPTIONS = new h("openCaptions"), h.SIGN_LANGUAGE = new h("signLanguage"), h.TRANSCRIPT = new h("transcript"), h.DISPLAY_TRANSFORMABILITY = new h("displayTransformability"), h.SYNCHRONIZED_AUDIO_TEXT = new h("synchronizedAudioText"), h.TIMING_CONTROL = new h("timingControl"), h.UNLOCKED = new h("unlocked"), h.CHEM_ML = new h("ChemML"), h.LATEX = new h("latex"), h.LATEX_CHEMISTRY = new h("latex-chemistry"), h.MATH_ML = new h("MathML"), h.MATH_ML_CHEMISTRY = new h("MathML-chemistry"), h.TTS_MARKUP = new h("ttsMarkup"), h.HIGH_CONTRAST_AUDIO = new h("highContrastAudio"), h.HIGH_CONTRAST_DISPLAY = new h("highContrastDisplay"), h.LARGE_PRINT = new h("largePrint"), h.BRAILLE = new h("braille"), h.TACTILE_GRAPHIC = new h("tactileGraphic"), h.TACTILE_OBJECT = new h("tactileObject"), h.FULL_RUBY_ANNOTATIONS = new h("fullRubyAnnotations"), h.HORIZONTAL_WRITING = new h("horizontalWriting"), h.RUBY_ANNOTATIONS = new h("rubyAnnotations"), h.VERTICAL_WRITING = new h("verticalWriting"), h.WITH_ADDITIONAL_WORD_SEGMENTATION = new h("withAdditionalWordSegmentation"), h.WITHOUT_ADDITIONAL_WORD_SEGMENTATION = new h("withoutAdditionalWordSegmentation");
|
|
205
|
+
let Jt = h;
|
|
206
|
+
const S = class S {
|
|
207
207
|
constructor(t) {
|
|
208
208
|
this.value = t;
|
|
209
209
|
}
|
|
@@ -212,7 +212,7 @@ const E = class E {
|
|
|
212
212
|
*/
|
|
213
213
|
static deserialize(t) {
|
|
214
214
|
if (!(!t || typeof t != "string"))
|
|
215
|
-
return new
|
|
215
|
+
return new S(t);
|
|
216
216
|
}
|
|
217
217
|
/**
|
|
218
218
|
* Serializes a [Hazard] to its RWPM JSON representation.
|
|
@@ -221,9 +221,9 @@ const E = class E {
|
|
|
221
221
|
return this.value;
|
|
222
222
|
}
|
|
223
223
|
};
|
|
224
|
-
|
|
225
|
-
let
|
|
226
|
-
const
|
|
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 Qt = S;
|
|
226
|
+
const E = class E {
|
|
227
227
|
constructor(t) {
|
|
228
228
|
this.value = t;
|
|
229
229
|
}
|
|
@@ -232,7 +232,7 @@ const S = class S {
|
|
|
232
232
|
*/
|
|
233
233
|
static deserialize(t) {
|
|
234
234
|
if (!(!t || typeof t != "string"))
|
|
235
|
-
return new
|
|
235
|
+
return new E(t);
|
|
236
236
|
}
|
|
237
237
|
/**
|
|
238
238
|
* Serializes an [Exemption] to its RWPM JSON representation.
|
|
@@ -241,11 +241,11 @@ const S = class S {
|
|
|
241
241
|
return this.value;
|
|
242
242
|
}
|
|
243
243
|
};
|
|
244
|
-
|
|
245
|
-
let
|
|
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:
|
|
248
|
-
},
|
|
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 jt = E;
|
|
246
|
+
const te = ["en", "ar", "da", "fr", "it", "pt_PT", "sv"], _e = /* @__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"}}`), Ve = {
|
|
247
|
+
publication: _e
|
|
248
|
+
}, ee = {
|
|
249
249
|
fr: () => import("./fr-C5HEel98.js"),
|
|
250
250
|
ar: () => import("./ar-DyHX_uy2.js"),
|
|
251
251
|
da: () => import("./da-Dct0PS3E.js"),
|
|
@@ -256,13 +256,13 @@ const Xt = ["en", "ar", "da", "fr", "it", "pt_PT", "sv"], Me = /* @__PURE__ */ J
|
|
|
256
256
|
sv: () => import("./sv-BfzAFsVN.js")
|
|
257
257
|
// 'tr': () => import('@edrlab/thorium-locales/publication-metadata/tr.json'),
|
|
258
258
|
// 'uk': () => import('@edrlab/thorium-locales/publication-metadata/uk.json')
|
|
259
|
-
},
|
|
260
|
-
class
|
|
259
|
+
}, ie = Ve?.publication?.metadata?.accessibility?.["display-guide"] || {};
|
|
260
|
+
class Y {
|
|
261
261
|
constructor() {
|
|
262
|
-
this.currentLocaleCode = "en", this.locale =
|
|
262
|
+
this.currentLocaleCode = "en", this.locale = ie, this.loadedLocales = {}, this.loadedLocales.en = ie;
|
|
263
263
|
}
|
|
264
264
|
static getInstance() {
|
|
265
|
-
return
|
|
265
|
+
return Y.instance || (Y.instance = new Y()), Y.instance;
|
|
266
266
|
}
|
|
267
267
|
/**
|
|
268
268
|
* Loads a locale dynamically
|
|
@@ -270,14 +270,14 @@ class F {
|
|
|
270
270
|
* @returns Promise indicating if the locale was loaded successfully
|
|
271
271
|
*/
|
|
272
272
|
async loadLocale(t) {
|
|
273
|
-
if (!
|
|
273
|
+
if (!te.includes(t))
|
|
274
274
|
return console.warn(`Locale '${t}' is not enabled`), !1;
|
|
275
275
|
if (t in this.loadedLocales)
|
|
276
276
|
return !0;
|
|
277
277
|
try {
|
|
278
|
-
if (!(t in
|
|
278
|
+
if (!(t in ee))
|
|
279
279
|
return console.warn(`Locale file not found for: ${t}`), !1;
|
|
280
|
-
const s = (await
|
|
280
|
+
const s = (await ee[t]()).default?.publication?.metadata?.accessibility?.["display-guide"];
|
|
281
281
|
return s ? (this.loadedLocales[t] = s, !0) : (console.warn(`No accessibility strings found in locale ${t}`), !1);
|
|
282
282
|
} catch (e) {
|
|
283
283
|
return console.warn(`Failed to load locale ${t}:`, e), !1;
|
|
@@ -311,7 +311,7 @@ class F {
|
|
|
311
311
|
* Gets a list of available locale codes
|
|
312
312
|
*/
|
|
313
313
|
getAvailableLocales() {
|
|
314
|
-
return
|
|
314
|
+
return te;
|
|
315
315
|
}
|
|
316
316
|
getNestedValue(t, e) {
|
|
317
317
|
const i = e.split(".");
|
|
@@ -333,8 +333,8 @@ class F {
|
|
|
333
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
334
|
}
|
|
335
335
|
}
|
|
336
|
-
|
|
337
|
-
class
|
|
336
|
+
Y.getInstance();
|
|
337
|
+
class Ut {
|
|
338
338
|
/**
|
|
339
339
|
* Creates a [Encryption].
|
|
340
340
|
*/
|
|
@@ -346,7 +346,7 @@ class Rt {
|
|
|
346
346
|
*/
|
|
347
347
|
static deserialize(t) {
|
|
348
348
|
if (t && t.algorithm)
|
|
349
|
-
return new
|
|
349
|
+
return new Ut({
|
|
350
350
|
algorithm: t.algorithm,
|
|
351
351
|
compression: t.compression,
|
|
352
352
|
originalLength: t.originalLength,
|
|
@@ -362,7 +362,7 @@ class Rt {
|
|
|
362
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;
|
|
363
363
|
}
|
|
364
364
|
}
|
|
365
|
-
class
|
|
365
|
+
class D {
|
|
366
366
|
constructor(t) {
|
|
367
367
|
this.otherProperties = t;
|
|
368
368
|
}
|
|
@@ -374,7 +374,7 @@ class R {
|
|
|
374
374
|
*/
|
|
375
375
|
static deserialize(t) {
|
|
376
376
|
if (t)
|
|
377
|
-
return new
|
|
377
|
+
return new D(t);
|
|
378
378
|
}
|
|
379
379
|
/**
|
|
380
380
|
* Serializes a [Properties] to its RWPM JSON representation.
|
|
@@ -389,30 +389,30 @@ class R {
|
|
|
389
389
|
const e = Object.assign({}, this.otherProperties);
|
|
390
390
|
for (const i in t)
|
|
391
391
|
e[i] = t[i];
|
|
392
|
-
return new
|
|
392
|
+
return new D(e);
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
|
-
Object.defineProperty(
|
|
395
|
+
Object.defineProperty(D.prototype, "encryption", {
|
|
396
396
|
get: function() {
|
|
397
|
-
return
|
|
397
|
+
return Ut.deserialize(this.otherProperties.encrypted);
|
|
398
398
|
}
|
|
399
399
|
});
|
|
400
|
-
function
|
|
400
|
+
function Fe(r) {
|
|
401
401
|
return r && Array.isArray(r) ? r : void 0;
|
|
402
402
|
}
|
|
403
|
-
function
|
|
404
|
-
return r && typeof r == "string" ? [r] :
|
|
403
|
+
function xe(r) {
|
|
404
|
+
return r && typeof r == "string" ? [r] : Fe(r);
|
|
405
405
|
}
|
|
406
|
-
function
|
|
406
|
+
function se(r) {
|
|
407
407
|
return typeof r == "string" ? new Date(r) : void 0;
|
|
408
408
|
}
|
|
409
|
-
function
|
|
409
|
+
function ut(r) {
|
|
410
410
|
return isNaN(r) ? void 0 : r;
|
|
411
411
|
}
|
|
412
|
-
function
|
|
413
|
-
return
|
|
412
|
+
function R(r) {
|
|
413
|
+
return ut(r) !== void 0 && Math.sign(r) >= 0 ? r : void 0;
|
|
414
414
|
}
|
|
415
|
-
function
|
|
415
|
+
function Ge(r) {
|
|
416
416
|
const t = new Array();
|
|
417
417
|
return r.forEach((e) => t.push(e)), t;
|
|
418
418
|
}
|
|
@@ -427,21 +427,21 @@ class l {
|
|
|
427
427
|
} else
|
|
428
428
|
throw new Error("Invalid media type");
|
|
429
429
|
const o = {};
|
|
430
|
-
for (let
|
|
431
|
-
const v = s[
|
|
430
|
+
for (let p = 1; p < s.length; p++) {
|
|
431
|
+
const v = s[p].split("=");
|
|
432
432
|
if (v.length === 2) {
|
|
433
|
-
const f = v[0].toLocaleLowerCase(),
|
|
434
|
-
o[f] =
|
|
433
|
+
const f = v[0].toLocaleLowerCase(), m = f === "charset" ? v[1].toUpperCase() : v[1];
|
|
434
|
+
o[f] = m;
|
|
435
435
|
}
|
|
436
436
|
}
|
|
437
|
-
const a = {},
|
|
438
|
-
|
|
439
|
-
let
|
|
440
|
-
for (const
|
|
441
|
-
const v = a[
|
|
442
|
-
|
|
437
|
+
const a = {}, c = Object.keys(o);
|
|
438
|
+
c.sort((p, v) => p.localeCompare(v)), c.forEach((p) => a[p] = o[p]);
|
|
439
|
+
let d = "";
|
|
440
|
+
for (const p in a) {
|
|
441
|
+
const v = a[p];
|
|
442
|
+
d += `;${p}=${v}`;
|
|
443
443
|
}
|
|
444
|
-
const u = `${e}/${i}${
|
|
444
|
+
const u = `${e}/${i}${d}`, g = a.encoding;
|
|
445
445
|
this.string = u, this.type = e, this.subtype = i, this.parameters = a, this.encoding = g, this.name = t.name, this.fileExtension = t.fileExtension;
|
|
446
446
|
}
|
|
447
447
|
static parse(t) {
|
|
@@ -875,7 +875,7 @@ class l {
|
|
|
875
875
|
});
|
|
876
876
|
}
|
|
877
877
|
}
|
|
878
|
-
class
|
|
878
|
+
class ne {
|
|
879
879
|
constructor(t) {
|
|
880
880
|
this.uri = t, this.parameters = this.getParameters(t);
|
|
881
881
|
}
|
|
@@ -915,17 +915,17 @@ class C {
|
|
|
915
915
|
*/
|
|
916
916
|
static deserialize(t) {
|
|
917
917
|
if (!t) return;
|
|
918
|
-
const e =
|
|
918
|
+
const e = ut(t.progression), i = ut(t.totalProgression), s = ut(t.position), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([
|
|
919
919
|
"fragment",
|
|
920
920
|
"fragments",
|
|
921
921
|
"progression",
|
|
922
922
|
"totalProgression",
|
|
923
923
|
"position"
|
|
924
924
|
]);
|
|
925
|
-
return Object.entries(t).forEach(([a,
|
|
926
|
-
o.has(a) || n.set(a,
|
|
925
|
+
return Object.entries(t).forEach(([a, c]) => {
|
|
926
|
+
o.has(a) || n.set(a, c);
|
|
927
927
|
}), new C({
|
|
928
|
-
fragments:
|
|
928
|
+
fragments: xe(t.fragments || t.fragment),
|
|
929
929
|
progression: e !== void 0 && e >= 0 && e <= 1 ? e : void 0,
|
|
930
930
|
totalProgression: i !== void 0 && i >= 0 && i <= 1 ? i : void 0,
|
|
931
931
|
position: s !== void 0 && s > 0 ? s : void 0,
|
|
@@ -940,7 +940,7 @@ class C {
|
|
|
940
940
|
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;
|
|
941
941
|
}
|
|
942
942
|
}
|
|
943
|
-
class
|
|
943
|
+
class _ {
|
|
944
944
|
/**
|
|
945
945
|
* Creates a [Text].
|
|
946
946
|
*/
|
|
@@ -952,7 +952,7 @@ class H {
|
|
|
952
952
|
*/
|
|
953
953
|
static deserialize(t) {
|
|
954
954
|
if (t)
|
|
955
|
-
return new
|
|
955
|
+
return new _({
|
|
956
956
|
after: t.after,
|
|
957
957
|
before: t.before,
|
|
958
958
|
highlight: t.highlight
|
|
@@ -983,7 +983,7 @@ class W {
|
|
|
983
983
|
type: t.type,
|
|
984
984
|
title: t.title,
|
|
985
985
|
locations: C.deserialize(t.locations),
|
|
986
|
-
text:
|
|
986
|
+
text: _.deserialize(t.text)
|
|
987
987
|
});
|
|
988
988
|
}
|
|
989
989
|
/**
|
|
@@ -1006,7 +1006,7 @@ class W {
|
|
|
1006
1006
|
});
|
|
1007
1007
|
}
|
|
1008
1008
|
}
|
|
1009
|
-
class
|
|
1009
|
+
class X {
|
|
1010
1010
|
/**
|
|
1011
1011
|
* Creates a [Link].
|
|
1012
1012
|
*/
|
|
@@ -1018,21 +1018,21 @@ class Y {
|
|
|
1018
1018
|
*/
|
|
1019
1019
|
static deserialize(t) {
|
|
1020
1020
|
if (!(!t || typeof t.href != "string"))
|
|
1021
|
-
return new
|
|
1021
|
+
return new X({
|
|
1022
1022
|
href: t.href,
|
|
1023
1023
|
templated: t.templated,
|
|
1024
1024
|
type: t.type,
|
|
1025
1025
|
title: t.title,
|
|
1026
1026
|
rels: t.rel ? Array.isArray(t.rel) ? new Set(t.rel) : /* @__PURE__ */ new Set([t.rel]) : void 0,
|
|
1027
|
-
properties:
|
|
1028
|
-
height:
|
|
1029
|
-
width:
|
|
1030
|
-
size:
|
|
1031
|
-
duration:
|
|
1032
|
-
bitrate:
|
|
1033
|
-
languages:
|
|
1034
|
-
alternates:
|
|
1035
|
-
children:
|
|
1027
|
+
properties: D.deserialize(t.properties),
|
|
1028
|
+
height: R(t.height),
|
|
1029
|
+
width: R(t.width),
|
|
1030
|
+
size: R(t.size),
|
|
1031
|
+
duration: R(t.duration),
|
|
1032
|
+
bitrate: R(t.bitrate),
|
|
1033
|
+
languages: xe(t.language),
|
|
1034
|
+
alternates: pt.deserialize(t.alternate),
|
|
1035
|
+
children: pt.deserialize(t.children)
|
|
1036
1036
|
});
|
|
1037
1037
|
}
|
|
1038
1038
|
/**
|
|
@@ -1040,7 +1040,7 @@ class Y {
|
|
|
1040
1040
|
*/
|
|
1041
1041
|
serialize() {
|
|
1042
1042
|
const t = { href: this.href };
|
|
1043
|
-
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 =
|
|
1043
|
+
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 = Ge(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;
|
|
1044
1044
|
}
|
|
1045
1045
|
/** MediaType of the linked resource. */
|
|
1046
1046
|
get mediaType() {
|
|
@@ -1057,14 +1057,14 @@ class Y {
|
|
|
1057
1057
|
}
|
|
1058
1058
|
/** List of URI template parameter keys, if the `Link` is templated. */
|
|
1059
1059
|
get templateParameters() {
|
|
1060
|
-
return this.templated ? new
|
|
1060
|
+
return this.templated ? new ne(this.href).parameters : /* @__PURE__ */ new Set();
|
|
1061
1061
|
}
|
|
1062
1062
|
/** Expands the `Link`'s HREF by replacing URI template variables by the given parameters.
|
|
1063
1063
|
* See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
|
|
1064
1064
|
*/
|
|
1065
1065
|
expandTemplate(t) {
|
|
1066
|
-
return new
|
|
1067
|
-
href: new
|
|
1066
|
+
return new X({
|
|
1067
|
+
href: new ne(this.href).expand(t),
|
|
1068
1068
|
templated: !1
|
|
1069
1069
|
});
|
|
1070
1070
|
}
|
|
@@ -1072,8 +1072,8 @@ class Y {
|
|
|
1072
1072
|
* Makes a copy of this [Link] after merging in the given additional other [properties].
|
|
1073
1073
|
*/
|
|
1074
1074
|
addProperties(t) {
|
|
1075
|
-
const e =
|
|
1076
|
-
return e.properties = e.properties ? e.properties?.add(t) : new
|
|
1075
|
+
const e = X.deserialize(this.serialize());
|
|
1076
|
+
return e.properties = e.properties ? e.properties?.add(t) : new D(t), e;
|
|
1077
1077
|
}
|
|
1078
1078
|
/**
|
|
1079
1079
|
* Creates a [Locator] from a reading order [Link].
|
|
@@ -1090,7 +1090,7 @@ class Y {
|
|
|
1090
1090
|
});
|
|
1091
1091
|
}
|
|
1092
1092
|
}
|
|
1093
|
-
class
|
|
1093
|
+
class pt {
|
|
1094
1094
|
/**
|
|
1095
1095
|
* Creates a [Links].
|
|
1096
1096
|
*/
|
|
@@ -1102,8 +1102,8 @@ class lt {
|
|
|
1102
1102
|
*/
|
|
1103
1103
|
static deserialize(t) {
|
|
1104
1104
|
if (t && Array.isArray(t))
|
|
1105
|
-
return new
|
|
1106
|
-
t.map((e) =>
|
|
1105
|
+
return new pt(
|
|
1106
|
+
t.map((e) => X.deserialize(e)).filter((e) => e !== void 0)
|
|
1107
1107
|
);
|
|
1108
1108
|
}
|
|
1109
1109
|
/**
|
|
@@ -1184,10 +1184,10 @@ class lt {
|
|
|
1184
1184
|
return this.items.filter((t) => t.type);
|
|
1185
1185
|
}
|
|
1186
1186
|
}
|
|
1187
|
-
|
|
1187
|
+
D.prototype.getContains = function() {
|
|
1188
1188
|
return new Set(this.otherProperties.contains || []);
|
|
1189
1189
|
};
|
|
1190
|
-
class
|
|
1190
|
+
class mt {
|
|
1191
1191
|
/**
|
|
1192
1192
|
* Creates a [DomRange].
|
|
1193
1193
|
*/
|
|
@@ -1199,10 +1199,10 @@ class ct {
|
|
|
1199
1199
|
*/
|
|
1200
1200
|
static deserialize(t) {
|
|
1201
1201
|
if (!(t && t.cssSelector)) return;
|
|
1202
|
-
let e =
|
|
1202
|
+
let e = R(t.textNodeIndex);
|
|
1203
1203
|
if (e === void 0) return;
|
|
1204
|
-
let i =
|
|
1205
|
-
return i === void 0 && (i =
|
|
1204
|
+
let i = R(t.charOffset);
|
|
1205
|
+
return i === void 0 && (i = R(t.offset)), new mt({
|
|
1206
1206
|
cssSelector: t.cssSelector,
|
|
1207
1207
|
textNodeIndex: e,
|
|
1208
1208
|
charOffset: i
|
|
@@ -1219,7 +1219,7 @@ class ct {
|
|
|
1219
1219
|
return this.charOffset !== void 0 && (t.charOffset = this.charOffset), t;
|
|
1220
1220
|
}
|
|
1221
1221
|
}
|
|
1222
|
-
class
|
|
1222
|
+
class Bt {
|
|
1223
1223
|
/**
|
|
1224
1224
|
* Creates a [DomRange].
|
|
1225
1225
|
*/
|
|
@@ -1231,11 +1231,11 @@ class It {
|
|
|
1231
1231
|
*/
|
|
1232
1232
|
static deserialize(t) {
|
|
1233
1233
|
if (!t) return;
|
|
1234
|
-
let e =
|
|
1234
|
+
let e = mt.deserialize(t.start);
|
|
1235
1235
|
if (e)
|
|
1236
|
-
return new
|
|
1236
|
+
return new Bt({
|
|
1237
1237
|
start: e,
|
|
1238
|
-
end:
|
|
1238
|
+
end: mt.deserialize(t.end)
|
|
1239
1239
|
});
|
|
1240
1240
|
}
|
|
1241
1241
|
/**
|
|
@@ -1253,7 +1253,7 @@ C.prototype.getPartialCfi = function() {
|
|
|
1253
1253
|
return this.otherLocations?.get("partialCfi");
|
|
1254
1254
|
};
|
|
1255
1255
|
C.prototype.getDomRange = function() {
|
|
1256
|
-
return
|
|
1256
|
+
return Bt.deserialize(this.otherLocations?.get("domRange"));
|
|
1257
1257
|
};
|
|
1258
1258
|
C.prototype.fragmentParameters = function() {
|
|
1259
1259
|
return new Map(
|
|
@@ -1287,7 +1287,7 @@ C.prototype.space = function() {
|
|
|
1287
1287
|
if (t.length === 4 && !t.some(isNaN))
|
|
1288
1288
|
return t;
|
|
1289
1289
|
};
|
|
1290
|
-
class
|
|
1290
|
+
class Ht {
|
|
1291
1291
|
/** Creates a [Price]. */
|
|
1292
1292
|
constructor(t) {
|
|
1293
1293
|
this.currency = t.currency, this.value = t.value;
|
|
@@ -1300,9 +1300,9 @@ class Dt {
|
|
|
1300
1300
|
let e = t.currency;
|
|
1301
1301
|
if (!(e && typeof e == "string" && e.length > 0))
|
|
1302
1302
|
return;
|
|
1303
|
-
let i =
|
|
1303
|
+
let i = R(t.value);
|
|
1304
1304
|
if (i !== void 0)
|
|
1305
|
-
return new
|
|
1305
|
+
return new Ht({ currency: e, value: i });
|
|
1306
1306
|
}
|
|
1307
1307
|
/**
|
|
1308
1308
|
* Serializes a [Price] to its RWPM JSON representation.
|
|
@@ -1311,7 +1311,7 @@ class Dt {
|
|
|
1311
1311
|
return { currency: this.currency, value: this.value };
|
|
1312
1312
|
}
|
|
1313
1313
|
}
|
|
1314
|
-
class
|
|
1314
|
+
class j {
|
|
1315
1315
|
/** Creates a [Acquisition]. */
|
|
1316
1316
|
constructor(t) {
|
|
1317
1317
|
this.type = t.type, this.children = t.children;
|
|
@@ -1321,14 +1321,14 @@ class J {
|
|
|
1321
1321
|
*/
|
|
1322
1322
|
static deserialize(t) {
|
|
1323
1323
|
if (t && t.type)
|
|
1324
|
-
return new
|
|
1324
|
+
return new j({
|
|
1325
1325
|
type: t.type,
|
|
1326
|
-
children:
|
|
1326
|
+
children: j.deserializeArray(t.children)
|
|
1327
1327
|
});
|
|
1328
1328
|
}
|
|
1329
1329
|
static deserializeArray(t) {
|
|
1330
1330
|
if (Array.isArray(t))
|
|
1331
|
-
return t.map((e) =>
|
|
1331
|
+
return t.map((e) => j.deserialize(e)).filter((e) => e !== void 0);
|
|
1332
1332
|
}
|
|
1333
1333
|
/**
|
|
1334
1334
|
* Serializes a [Acquisition] to its RWPM JSON representation.
|
|
@@ -1338,7 +1338,7 @@ class J {
|
|
|
1338
1338
|
return this.children && (t.children = this.children.map((e) => e.serialize())), t;
|
|
1339
1339
|
}
|
|
1340
1340
|
}
|
|
1341
|
-
class
|
|
1341
|
+
class _t {
|
|
1342
1342
|
/** Creates a [Price]. */
|
|
1343
1343
|
constructor(t) {
|
|
1344
1344
|
this.total = t.total, this.position = t.position;
|
|
@@ -1348,9 +1348,9 @@ class zt {
|
|
|
1348
1348
|
*/
|
|
1349
1349
|
static deserialize(t) {
|
|
1350
1350
|
if (t)
|
|
1351
|
-
return new
|
|
1352
|
-
total:
|
|
1353
|
-
position:
|
|
1351
|
+
return new _t({
|
|
1352
|
+
total: R(t.total),
|
|
1353
|
+
position: R(t.position)
|
|
1354
1354
|
});
|
|
1355
1355
|
}
|
|
1356
1356
|
/**
|
|
@@ -1361,7 +1361,7 @@ class zt {
|
|
|
1361
1361
|
return this.total !== void 0 && (t.total = this.total), this.position !== void 0 && (t.position = this.position), t;
|
|
1362
1362
|
}
|
|
1363
1363
|
}
|
|
1364
|
-
class
|
|
1364
|
+
class Vt {
|
|
1365
1365
|
/** Creates a [Copies]. */
|
|
1366
1366
|
constructor(t) {
|
|
1367
1367
|
this.total = t.total, this.available = t.available;
|
|
@@ -1371,9 +1371,9 @@ class Mt {
|
|
|
1371
1371
|
*/
|
|
1372
1372
|
static deserialize(t) {
|
|
1373
1373
|
if (t)
|
|
1374
|
-
return new
|
|
1375
|
-
total:
|
|
1376
|
-
available:
|
|
1374
|
+
return new Vt({
|
|
1375
|
+
total: R(t.total),
|
|
1376
|
+
available: R(t.available)
|
|
1377
1377
|
});
|
|
1378
1378
|
}
|
|
1379
1379
|
/**
|
|
@@ -1384,7 +1384,7 @@ class Mt {
|
|
|
1384
1384
|
return this.total !== void 0 && (t.total = this.total), this.available !== void 0 && (t.available = this.available), t;
|
|
1385
1385
|
}
|
|
1386
1386
|
}
|
|
1387
|
-
class
|
|
1387
|
+
class Ft {
|
|
1388
1388
|
/** Creates a [Availability]. */
|
|
1389
1389
|
constructor(t) {
|
|
1390
1390
|
this.state = t.state, this.since = t.since, this.until = t.until;
|
|
@@ -1394,10 +1394,10 @@ class kt {
|
|
|
1394
1394
|
*/
|
|
1395
1395
|
static deserialize(t) {
|
|
1396
1396
|
if (t && t.state)
|
|
1397
|
-
return new
|
|
1397
|
+
return new Ft({
|
|
1398
1398
|
state: t.state,
|
|
1399
|
-
since:
|
|
1400
|
-
until:
|
|
1399
|
+
since: se(t.since),
|
|
1400
|
+
until: se(t.until)
|
|
1401
1401
|
});
|
|
1402
1402
|
}
|
|
1403
1403
|
/**
|
|
@@ -1408,89 +1408,89 @@ class kt {
|
|
|
1408
1408
|
return this.since !== void 0 && (t.since = this.since.toISOString()), this.until !== void 0 && (t.until = this.until.toISOString()), t;
|
|
1409
1409
|
}
|
|
1410
1410
|
}
|
|
1411
|
-
|
|
1412
|
-
return
|
|
1411
|
+
D.prototype.getNumberOfItems = function() {
|
|
1412
|
+
return R(this.otherProperties.numberOfItems);
|
|
1413
1413
|
};
|
|
1414
|
-
|
|
1415
|
-
return
|
|
1414
|
+
D.prototype.getPrice = function() {
|
|
1415
|
+
return Ht.deserialize(this.otherProperties.price);
|
|
1416
1416
|
};
|
|
1417
|
-
|
|
1417
|
+
D.prototype.getIndirectAcquisitions = function() {
|
|
1418
1418
|
const r = this.otherProperties.indirectAcquisition;
|
|
1419
1419
|
if (r && Array.isArray(r))
|
|
1420
|
-
return r.map((t) =>
|
|
1420
|
+
return r.map((t) => j.deserialize(t)).filter((t) => t !== void 0);
|
|
1421
1421
|
};
|
|
1422
|
-
|
|
1423
|
-
return
|
|
1422
|
+
D.prototype.getHolds = function() {
|
|
1423
|
+
return _t.deserialize(this.otherProperties.holds);
|
|
1424
1424
|
};
|
|
1425
|
-
|
|
1426
|
-
return
|
|
1425
|
+
D.prototype.getCopies = function() {
|
|
1426
|
+
return Vt.deserialize(this.otherProperties.copies);
|
|
1427
1427
|
};
|
|
1428
|
-
|
|
1429
|
-
return
|
|
1428
|
+
D.prototype.getAvailability = function() {
|
|
1429
|
+
return Ft.deserialize(this.otherProperties.availability);
|
|
1430
1430
|
};
|
|
1431
|
-
|
|
1432
|
-
return
|
|
1431
|
+
D.prototype.getAuthenticate = function() {
|
|
1432
|
+
return X.deserialize(this.otherProperties.authenticate);
|
|
1433
1433
|
};
|
|
1434
|
-
const
|
|
1435
|
-
function
|
|
1436
|
-
console.warn(`${
|
|
1434
|
+
const $e = "CssSelectorGenerator";
|
|
1435
|
+
function re(r = "unknown problem", ...t) {
|
|
1436
|
+
console.warn(`${$e}: ${r}`, ...t);
|
|
1437
1437
|
}
|
|
1438
|
-
function
|
|
1438
|
+
function Ye(r) {
|
|
1439
1439
|
return r instanceof RegExp;
|
|
1440
1440
|
}
|
|
1441
|
-
function
|
|
1441
|
+
function qe(r) {
|
|
1442
1442
|
return r.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".+");
|
|
1443
1443
|
}
|
|
1444
|
-
function
|
|
1444
|
+
function Xe(r) {
|
|
1445
1445
|
const t = r.map((e) => {
|
|
1446
|
-
if (
|
|
1446
|
+
if (Ye(e))
|
|
1447
1447
|
return (i) => e.test(i);
|
|
1448
1448
|
if (typeof e == "function")
|
|
1449
1449
|
return (i) => {
|
|
1450
1450
|
const s = e(i);
|
|
1451
|
-
return typeof s != "boolean" ? (
|
|
1451
|
+
return typeof s != "boolean" ? (re("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It's result will be ignored.", e), !1) : s;
|
|
1452
1452
|
};
|
|
1453
1453
|
if (typeof e == "string") {
|
|
1454
|
-
const i = new RegExp("^" +
|
|
1454
|
+
const i = new RegExp("^" + qe(e) + "$");
|
|
1455
1455
|
return (s) => i.test(s);
|
|
1456
1456
|
}
|
|
1457
|
-
return
|
|
1457
|
+
return re("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", e), () => !1;
|
|
1458
1458
|
});
|
|
1459
1459
|
return (e) => t.some((i) => i(e));
|
|
1460
1460
|
}
|
|
1461
|
-
|
|
1461
|
+
Xe([
|
|
1462
1462
|
"class",
|
|
1463
1463
|
"id",
|
|
1464
1464
|
// Angular attributes
|
|
1465
1465
|
"ng-*"
|
|
1466
1466
|
]);
|
|
1467
|
-
class
|
|
1467
|
+
class Z {
|
|
1468
1468
|
}
|
|
1469
|
-
function
|
|
1469
|
+
function oe(r) {
|
|
1470
1470
|
return r.split("").reverse().join("");
|
|
1471
1471
|
}
|
|
1472
|
-
function
|
|
1473
|
-
const i =
|
|
1472
|
+
function Ke(r, t, e) {
|
|
1473
|
+
const i = oe(t);
|
|
1474
1474
|
return e.map((s) => {
|
|
1475
|
-
const n = Math.max(0, s.end - t.length - s.errors), o =
|
|
1475
|
+
const n = Math.max(0, s.end - t.length - s.errors), o = oe(r.slice(n, s.end));
|
|
1476
1476
|
return {
|
|
1477
|
-
start:
|
|
1477
|
+
start: Te(o, i, s.errors).reduce((c, d) => s.end - d.end < c ? s.end - d.end : c, s.end),
|
|
1478
1478
|
end: s.end,
|
|
1479
1479
|
errors: s.errors
|
|
1480
1480
|
};
|
|
1481
1481
|
});
|
|
1482
1482
|
}
|
|
1483
|
-
function
|
|
1483
|
+
function St(r) {
|
|
1484
1484
|
return (r | -r) >> 31 & 1;
|
|
1485
1485
|
}
|
|
1486
|
-
function
|
|
1486
|
+
function ae(r, t, e, i) {
|
|
1487
1487
|
let s = r.P[e], n = r.M[e];
|
|
1488
|
-
const o = i >>> 31, a = t[e] | o,
|
|
1489
|
-
let u = n | ~(
|
|
1490
|
-
const
|
|
1491
|
-
return u <<= 1, g <<= 1, g |= o, u |=
|
|
1488
|
+
const o = i >>> 31, a = t[e] | o, c = a | n, d = (a & s) + s ^ s | a;
|
|
1489
|
+
let u = n | ~(d | s), g = s & d;
|
|
1490
|
+
const p = St(u & r.lastRowMask[e]) - St(g & r.lastRowMask[e]);
|
|
1491
|
+
return u <<= 1, g <<= 1, g |= o, u |= St(i) - o, s = g | ~(c | u), n = u & c, r.P[e] = s, r.M[e] = n, p;
|
|
1492
1492
|
}
|
|
1493
|
-
function
|
|
1493
|
+
function Te(r, t, e) {
|
|
1494
1494
|
if (t.length === 0)
|
|
1495
1495
|
return [];
|
|
1496
1496
|
e = Math.min(e, t.length);
|
|
@@ -1500,64 +1500,64 @@ function be(r, t, e) {
|
|
|
1500
1500
|
lastRowMask: new Uint32Array(n + 1)
|
|
1501
1501
|
};
|
|
1502
1502
|
o.lastRowMask.fill(1 << 31), o.lastRowMask[n] = 1 << (t.length - 1) % s;
|
|
1503
|
-
const a = new Uint32Array(n + 1),
|
|
1504
|
-
for (let
|
|
1505
|
-
|
|
1506
|
-
for (let
|
|
1507
|
-
const v = t.charCodeAt(
|
|
1508
|
-
if (
|
|
1503
|
+
const a = new Uint32Array(n + 1), c = /* @__PURE__ */ new Map(), d = [];
|
|
1504
|
+
for (let p = 0; p < 256; p++)
|
|
1505
|
+
d.push(a);
|
|
1506
|
+
for (let p = 0; p < t.length; p += 1) {
|
|
1507
|
+
const v = t.charCodeAt(p);
|
|
1508
|
+
if (c.has(v))
|
|
1509
1509
|
continue;
|
|
1510
1510
|
const f = new Uint32Array(n + 1);
|
|
1511
|
-
|
|
1512
|
-
for (let
|
|
1513
|
-
f[
|
|
1511
|
+
c.set(v, f), v < d.length && (d[v] = f);
|
|
1512
|
+
for (let m = 0; m <= n; m += 1) {
|
|
1513
|
+
f[m] = 0;
|
|
1514
1514
|
for (let b = 0; b < s; b += 1) {
|
|
1515
|
-
const
|
|
1516
|
-
if (
|
|
1515
|
+
const O = m * s + b;
|
|
1516
|
+
if (O >= t.length)
|
|
1517
1517
|
continue;
|
|
1518
|
-
t.charCodeAt(
|
|
1518
|
+
t.charCodeAt(O) === v && (f[m] |= 1 << b);
|
|
1519
1519
|
}
|
|
1520
1520
|
}
|
|
1521
1521
|
}
|
|
1522
1522
|
let u = Math.max(0, Math.ceil(e / s) - 1);
|
|
1523
1523
|
const g = new Uint32Array(n + 1);
|
|
1524
|
-
for (let
|
|
1525
|
-
g[
|
|
1524
|
+
for (let p = 0; p <= u; p += 1)
|
|
1525
|
+
g[p] = (p + 1) * s;
|
|
1526
1526
|
g[n] = t.length;
|
|
1527
|
-
for (let
|
|
1528
|
-
o.P[
|
|
1529
|
-
for (let
|
|
1530
|
-
const v = r.charCodeAt(
|
|
1527
|
+
for (let p = 0; p <= u; p += 1)
|
|
1528
|
+
o.P[p] = -1, o.M[p] = 0;
|
|
1529
|
+
for (let p = 0; p < r.length; p += 1) {
|
|
1530
|
+
const v = r.charCodeAt(p);
|
|
1531
1531
|
let f;
|
|
1532
|
-
v <
|
|
1533
|
-
let
|
|
1532
|
+
v < d.length ? f = d[v] : (f = c.get(v), typeof f > "u" && (f = a));
|
|
1533
|
+
let m = 0;
|
|
1534
1534
|
for (let b = 0; b <= u; b += 1)
|
|
1535
|
-
|
|
1536
|
-
if (g[u] -
|
|
1535
|
+
m = ae(o, f, b, m), g[b] += m;
|
|
1536
|
+
if (g[u] - m <= e && u < n && (f[u + 1] & 1 || m < 0)) {
|
|
1537
1537
|
u += 1, o.P[u] = -1, o.M[u] = 0;
|
|
1538
1538
|
let b;
|
|
1539
1539
|
if (u === n) {
|
|
1540
|
-
const
|
|
1541
|
-
b =
|
|
1540
|
+
const O = t.length % s;
|
|
1541
|
+
b = O === 0 ? s : O;
|
|
1542
1542
|
} else
|
|
1543
1543
|
b = s;
|
|
1544
|
-
g[u] = g[u - 1] + b -
|
|
1544
|
+
g[u] = g[u - 1] + b - m + ae(o, f, u, m);
|
|
1545
1545
|
} else
|
|
1546
1546
|
for (; u > 0 && g[u] >= e + s; )
|
|
1547
1547
|
u -= 1;
|
|
1548
1548
|
u === n && g[u] <= e && (g[u] < e && i.splice(0, i.length), i.push({
|
|
1549
1549
|
start: -1,
|
|
1550
|
-
end:
|
|
1550
|
+
end: p + 1,
|
|
1551
1551
|
errors: g[u]
|
|
1552
1552
|
}), e = g[u]);
|
|
1553
1553
|
}
|
|
1554
1554
|
return i;
|
|
1555
1555
|
}
|
|
1556
|
-
function
|
|
1557
|
-
const i =
|
|
1558
|
-
return
|
|
1556
|
+
function Ze(r, t, e) {
|
|
1557
|
+
const i = Te(r, t, e);
|
|
1558
|
+
return Ke(r, t, i);
|
|
1559
1559
|
}
|
|
1560
|
-
function
|
|
1560
|
+
function Pe(r, t, e) {
|
|
1561
1561
|
let i = 0;
|
|
1562
1562
|
const s = [];
|
|
1563
1563
|
for (; i !== -1; )
|
|
@@ -1566,38 +1566,38 @@ function ve(r, t, e) {
|
|
|
1566
1566
|
end: i + t.length,
|
|
1567
1567
|
errors: 0
|
|
1568
1568
|
}), i += 1);
|
|
1569
|
-
return s.length > 0 ? s :
|
|
1569
|
+
return s.length > 0 ? s : Ze(r, t, e);
|
|
1570
1570
|
}
|
|
1571
|
-
function
|
|
1572
|
-
return t.length === 0 || r.length === 0 ? 0 : 1 -
|
|
1571
|
+
function le(r, t) {
|
|
1572
|
+
return t.length === 0 || r.length === 0 ? 0 : 1 - Pe(r, t, t.length)[0].errors / t.length;
|
|
1573
1573
|
}
|
|
1574
|
-
function
|
|
1574
|
+
function Je(r, t, e = {}) {
|
|
1575
1575
|
if (t.length === 0)
|
|
1576
1576
|
return null;
|
|
1577
|
-
const i = Math.min(256, t.length / 2), s =
|
|
1577
|
+
const i = Math.min(256, t.length / 2), s = Pe(r, t, i);
|
|
1578
1578
|
if (s.length === 0)
|
|
1579
1579
|
return null;
|
|
1580
1580
|
const n = (a) => {
|
|
1581
|
-
const
|
|
1581
|
+
const p = 1 - a.errors / t.length, v = e.prefix ? le(
|
|
1582
1582
|
r.slice(
|
|
1583
1583
|
Math.max(0, a.start - e.prefix.length),
|
|
1584
1584
|
a.start
|
|
1585
1585
|
),
|
|
1586
1586
|
e.prefix
|
|
1587
|
-
) : 1, f = e.suffix ?
|
|
1587
|
+
) : 1, f = e.suffix ? le(
|
|
1588
1588
|
r.slice(a.end, a.end + e.suffix.length),
|
|
1589
1589
|
e.suffix
|
|
1590
1590
|
) : 1;
|
|
1591
|
-
let
|
|
1592
|
-
return typeof e.hint == "number" && (
|
|
1591
|
+
let m = 1;
|
|
1592
|
+
return typeof e.hint == "number" && (m = 1 - Math.abs(a.start - e.hint) / r.length), (50 * p + 20 * v + 20 * f + 2 * m) / 92;
|
|
1593
1593
|
}, o = s.map((a) => ({
|
|
1594
1594
|
start: a.start,
|
|
1595
1595
|
end: a.end,
|
|
1596
1596
|
score: n(a)
|
|
1597
1597
|
}));
|
|
1598
|
-
return o.sort((a,
|
|
1598
|
+
return o.sort((a, c) => c.score - a.score), o[0];
|
|
1599
1599
|
}
|
|
1600
|
-
function
|
|
1600
|
+
function xt(r, t, e) {
|
|
1601
1601
|
const i = e === 1 ? t : t - 1;
|
|
1602
1602
|
if (r.charAt(i).trim() !== "")
|
|
1603
1603
|
return t;
|
|
@@ -1607,7 +1607,7 @@ function vt(r, t, e) {
|
|
|
1607
1607
|
const o = s.length - n.length;
|
|
1608
1608
|
return e === 2 ? t - o : t + o;
|
|
1609
1609
|
}
|
|
1610
|
-
function
|
|
1610
|
+
function ce(r, t) {
|
|
1611
1611
|
const e = r.commonAncestorContainer.ownerDocument.createNodeIterator(
|
|
1612
1612
|
r.commonAncestorContainer,
|
|
1613
1613
|
NodeFilter.SHOW_TEXT
|
|
@@ -1619,8 +1619,8 @@ function ie(r, t) {
|
|
|
1619
1619
|
let o = -1;
|
|
1620
1620
|
const a = () => {
|
|
1621
1621
|
if (n = t === 1 ? e.nextNode() : e.previousNode(), n) {
|
|
1622
|
-
const
|
|
1623
|
-
o =
|
|
1622
|
+
const c = n.textContent, d = t === 1 ? 0 : c.length;
|
|
1623
|
+
o = xt(c, d, t);
|
|
1624
1624
|
}
|
|
1625
1625
|
};
|
|
1626
1626
|
for (; n && o === -1 && n !== s; )
|
|
@@ -1629,7 +1629,7 @@ function ie(r, t) {
|
|
|
1629
1629
|
return { node: n, offset: o };
|
|
1630
1630
|
throw new RangeError("No text nodes with non-whitespace text found in range");
|
|
1631
1631
|
}
|
|
1632
|
-
function
|
|
1632
|
+
function Qe(r) {
|
|
1633
1633
|
if (!r.toString().trim().length)
|
|
1634
1634
|
throw new RangeError("Range contains no non-whitespace text");
|
|
1635
1635
|
if (r.startContainer.nodeType !== Node.TEXT_NODE)
|
|
@@ -1639,13 +1639,13 @@ function Ye(r) {
|
|
|
1639
1639
|
const t = r.cloneRange();
|
|
1640
1640
|
let e = !1, i = !1;
|
|
1641
1641
|
const s = {
|
|
1642
|
-
start:
|
|
1642
|
+
start: xt(
|
|
1643
1643
|
r.startContainer.textContent,
|
|
1644
1644
|
r.startOffset,
|
|
1645
1645
|
1
|
|
1646
1646
|
/* Forwards */
|
|
1647
1647
|
),
|
|
1648
|
-
end:
|
|
1648
|
+
end: xt(
|
|
1649
1649
|
r.endContainer.textContent,
|
|
1650
1650
|
r.endOffset,
|
|
1651
1651
|
2
|
|
@@ -1655,7 +1655,7 @@ function Ye(r) {
|
|
|
1655
1655
|
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)
|
|
1656
1656
|
return t;
|
|
1657
1657
|
if (!e) {
|
|
1658
|
-
const { node: n, offset: o } =
|
|
1658
|
+
const { node: n, offset: o } = ce(
|
|
1659
1659
|
t,
|
|
1660
1660
|
1
|
|
1661
1661
|
/* Forwards */
|
|
@@ -1663,7 +1663,7 @@ function Ye(r) {
|
|
|
1663
1663
|
n && o >= 0 && t.setStart(n, o);
|
|
1664
1664
|
}
|
|
1665
1665
|
if (!i) {
|
|
1666
|
-
const { node: n, offset: o } =
|
|
1666
|
+
const { node: n, offset: o } = ce(
|
|
1667
1667
|
t,
|
|
1668
1668
|
2
|
|
1669
1669
|
/* Backwards */
|
|
@@ -1672,7 +1672,7 @@ function Ye(r) {
|
|
|
1672
1672
|
}
|
|
1673
1673
|
return t;
|
|
1674
1674
|
}
|
|
1675
|
-
function
|
|
1675
|
+
function Ne(r) {
|
|
1676
1676
|
switch (r.nodeType) {
|
|
1677
1677
|
case Node.ELEMENT_NODE:
|
|
1678
1678
|
case Node.TEXT_NODE:
|
|
@@ -1681,13 +1681,13 @@ function we(r) {
|
|
|
1681
1681
|
return 0;
|
|
1682
1682
|
}
|
|
1683
1683
|
}
|
|
1684
|
-
function
|
|
1684
|
+
function he(r) {
|
|
1685
1685
|
let t = r.previousSibling, e = 0;
|
|
1686
1686
|
for (; t; )
|
|
1687
|
-
e +=
|
|
1687
|
+
e += Ne(t), t = t.previousSibling;
|
|
1688
1688
|
return e;
|
|
1689
1689
|
}
|
|
1690
|
-
function
|
|
1690
|
+
function Le(r, ...t) {
|
|
1691
1691
|
let e = t.shift();
|
|
1692
1692
|
const i = r.ownerDocument.createNodeIterator(
|
|
1693
1693
|
r,
|
|
@@ -1702,7 +1702,7 @@ function Ee(r, ...t) {
|
|
|
1702
1702
|
throw new RangeError("Offset exceeds text length");
|
|
1703
1703
|
return s;
|
|
1704
1704
|
}
|
|
1705
|
-
class
|
|
1705
|
+
class k {
|
|
1706
1706
|
constructor(t, e) {
|
|
1707
1707
|
if (e < 0)
|
|
1708
1708
|
throw new Error("Offset is invalid");
|
|
@@ -1719,8 +1719,8 @@ class z {
|
|
|
1719
1719
|
throw new Error("Parent is not an ancestor of current element");
|
|
1720
1720
|
let e = this.element, i = this.offset;
|
|
1721
1721
|
for (; e !== t; )
|
|
1722
|
-
i +=
|
|
1723
|
-
return new
|
|
1722
|
+
i += he(e), e = e.parentElement;
|
|
1723
|
+
return new k(e, i);
|
|
1724
1724
|
}
|
|
1725
1725
|
/**
|
|
1726
1726
|
* Resolve the position to a specific text node and offset within that node.
|
|
@@ -1741,7 +1741,7 @@ class z {
|
|
|
1741
1741
|
*/
|
|
1742
1742
|
resolve(t = {}) {
|
|
1743
1743
|
try {
|
|
1744
|
-
return
|
|
1744
|
+
return Le(this.element, this.offset)[0];
|
|
1745
1745
|
} catch (e) {
|
|
1746
1746
|
if (this.offset === 0 && t.direction !== void 0) {
|
|
1747
1747
|
const i = document.createTreeWalker(
|
|
@@ -1764,9 +1764,9 @@ class z {
|
|
|
1764
1764
|
static fromCharOffset(t, e) {
|
|
1765
1765
|
switch (t.nodeType) {
|
|
1766
1766
|
case Node.TEXT_NODE:
|
|
1767
|
-
return
|
|
1767
|
+
return k.fromPoint(t, e);
|
|
1768
1768
|
case Node.ELEMENT_NODE:
|
|
1769
|
-
return new
|
|
1769
|
+
return new k(t, e);
|
|
1770
1770
|
default:
|
|
1771
1771
|
throw new Error("Node is not an element or text node");
|
|
1772
1772
|
}
|
|
@@ -1784,23 +1784,23 @@ class z {
|
|
|
1784
1784
|
throw new Error("Text node offset is out of range");
|
|
1785
1785
|
if (!t.parentElement)
|
|
1786
1786
|
throw new Error("Text node has no parent");
|
|
1787
|
-
const i =
|
|
1788
|
-
return new
|
|
1787
|
+
const i = he(t) + e;
|
|
1788
|
+
return new k(t.parentElement, i);
|
|
1789
1789
|
}
|
|
1790
1790
|
case Node.ELEMENT_NODE: {
|
|
1791
1791
|
if (e < 0 || e > t.childNodes.length)
|
|
1792
1792
|
throw new Error("Child node offset is out of range");
|
|
1793
1793
|
let i = 0;
|
|
1794
1794
|
for (let s = 0; s < e; s++)
|
|
1795
|
-
i +=
|
|
1796
|
-
return new
|
|
1795
|
+
i += Ne(t.childNodes[s]);
|
|
1796
|
+
return new k(t, i);
|
|
1797
1797
|
}
|
|
1798
1798
|
default:
|
|
1799
1799
|
throw new Error("Point is not in an element or text node");
|
|
1800
1800
|
}
|
|
1801
1801
|
}
|
|
1802
1802
|
}
|
|
1803
|
-
class
|
|
1803
|
+
class H {
|
|
1804
1804
|
constructor(t, e) {
|
|
1805
1805
|
this.start = t, this.end = e;
|
|
1806
1806
|
}
|
|
@@ -1810,7 +1810,7 @@ class U {
|
|
|
1810
1810
|
* `end.element`.
|
|
1811
1811
|
*/
|
|
1812
1812
|
relativeTo(t) {
|
|
1813
|
-
return new
|
|
1813
|
+
return new H(
|
|
1814
1814
|
this.start.relativeTo(t),
|
|
1815
1815
|
this.end.relativeTo(t)
|
|
1816
1816
|
);
|
|
@@ -1826,7 +1826,7 @@ class U {
|
|
|
1826
1826
|
*/
|
|
1827
1827
|
toRange() {
|
|
1828
1828
|
let t, e;
|
|
1829
|
-
this.start.element === this.end.element && this.start.offset <= this.end.offset ? [t, e] =
|
|
1829
|
+
this.start.element === this.end.element && this.start.offset <= this.end.offset ? [t, e] = Le(
|
|
1830
1830
|
this.start.element,
|
|
1831
1831
|
this.start.offset,
|
|
1832
1832
|
this.end.offset
|
|
@@ -1844,20 +1844,20 @@ class U {
|
|
|
1844
1844
|
* Create a TextRange from a (DOM) Range
|
|
1845
1845
|
*/
|
|
1846
1846
|
static fromRange(t) {
|
|
1847
|
-
const e =
|
|
1847
|
+
const e = k.fromPoint(
|
|
1848
1848
|
t.startContainer,
|
|
1849
1849
|
t.startOffset
|
|
1850
|
-
), i =
|
|
1851
|
-
return new
|
|
1850
|
+
), i = k.fromPoint(t.endContainer, t.endOffset);
|
|
1851
|
+
return new H(e, i);
|
|
1852
1852
|
}
|
|
1853
1853
|
/**
|
|
1854
1854
|
* Create a TextRange representing the `start`th to `end`th characters in
|
|
1855
1855
|
* `root`
|
|
1856
1856
|
*/
|
|
1857
1857
|
static fromOffsets(t, e, i) {
|
|
1858
|
-
return new
|
|
1859
|
-
new
|
|
1860
|
-
new
|
|
1858
|
+
return new H(
|
|
1859
|
+
new k(t, e),
|
|
1860
|
+
new k(t, i)
|
|
1861
1861
|
);
|
|
1862
1862
|
}
|
|
1863
1863
|
/**
|
|
@@ -1865,23 +1865,23 @@ class U {
|
|
|
1865
1865
|
* whitespace
|
|
1866
1866
|
*/
|
|
1867
1867
|
static trimmedRange(t) {
|
|
1868
|
-
return
|
|
1868
|
+
return Qe(H.fromRange(t).toRange());
|
|
1869
1869
|
}
|
|
1870
1870
|
}
|
|
1871
|
-
class
|
|
1871
|
+
class ft {
|
|
1872
1872
|
constructor(t, e, i) {
|
|
1873
1873
|
this.root = t, this.start = e, this.end = i;
|
|
1874
1874
|
}
|
|
1875
1875
|
static fromRange(t, e) {
|
|
1876
|
-
const i =
|
|
1877
|
-
return new
|
|
1876
|
+
const i = H.fromRange(e).relativeTo(t);
|
|
1877
|
+
return new ft(
|
|
1878
1878
|
t,
|
|
1879
1879
|
i.start.offset,
|
|
1880
1880
|
i.end.offset
|
|
1881
1881
|
);
|
|
1882
1882
|
}
|
|
1883
1883
|
static fromSelector(t, e) {
|
|
1884
|
-
return new
|
|
1884
|
+
return new ft(t, e.start, e.end);
|
|
1885
1885
|
}
|
|
1886
1886
|
toSelector() {
|
|
1887
1887
|
return {
|
|
@@ -1891,10 +1891,10 @@ class ht {
|
|
|
1891
1891
|
};
|
|
1892
1892
|
}
|
|
1893
1893
|
toRange() {
|
|
1894
|
-
return
|
|
1894
|
+
return H.fromOffsets(this.root, this.start, this.end).toRange();
|
|
1895
1895
|
}
|
|
1896
1896
|
}
|
|
1897
|
-
class
|
|
1897
|
+
class gt {
|
|
1898
1898
|
/**
|
|
1899
1899
|
* @param root - A root element from which to anchor.
|
|
1900
1900
|
*/
|
|
@@ -1907,15 +1907,15 @@ class dt {
|
|
|
1907
1907
|
* Will throw if `range` does not contain any text nodes.
|
|
1908
1908
|
*/
|
|
1909
1909
|
static fromRange(t, e) {
|
|
1910
|
-
const i = t.textContent, s =
|
|
1911
|
-
return new
|
|
1910
|
+
const i = t.textContent, s = H.fromRange(e).relativeTo(t), n = s.start.offset, o = s.end.offset, a = 32;
|
|
1911
|
+
return new gt(t, i.slice(n, o), {
|
|
1912
1912
|
prefix: i.slice(Math.max(0, n - a), n),
|
|
1913
1913
|
suffix: i.slice(o, Math.min(i.length, o + a))
|
|
1914
1914
|
});
|
|
1915
1915
|
}
|
|
1916
1916
|
static fromSelector(t, e) {
|
|
1917
1917
|
const { prefix: i, suffix: s } = e;
|
|
1918
|
-
return new
|
|
1918
|
+
return new gt(t, e.exact, { prefix: i, suffix: s });
|
|
1919
1919
|
}
|
|
1920
1920
|
toSelector() {
|
|
1921
1921
|
return {
|
|
@@ -1929,26 +1929,26 @@ class dt {
|
|
|
1929
1929
|
return this.toPositionAnchor(t).toRange();
|
|
1930
1930
|
}
|
|
1931
1931
|
toPositionAnchor(t = {}) {
|
|
1932
|
-
const e = this.root.textContent, i =
|
|
1932
|
+
const e = this.root.textContent, i = Je(e, this.exact, {
|
|
1933
1933
|
...this.context,
|
|
1934
1934
|
hint: t.hint
|
|
1935
1935
|
});
|
|
1936
1936
|
if (!i)
|
|
1937
1937
|
throw new Error("Quote not found");
|
|
1938
|
-
return new
|
|
1938
|
+
return new ft(this.root, i.start, i.end);
|
|
1939
1939
|
}
|
|
1940
1940
|
}
|
|
1941
|
-
function
|
|
1941
|
+
function je(r) {
|
|
1942
1942
|
const t = r.tagName.toUpperCase();
|
|
1943
1943
|
return t === "IMG" || t === "VIDEO" || t === "AUDIO" || t === "IFRAME" || t === "OBJECT" || t === "EMBED" || t === "CANVAS";
|
|
1944
1944
|
}
|
|
1945
|
-
function
|
|
1945
|
+
function rt(r, t) {
|
|
1946
1946
|
try {
|
|
1947
1947
|
const e = t.locations, i = t.text;
|
|
1948
1948
|
if (i && i.highlight) {
|
|
1949
1949
|
let s;
|
|
1950
1950
|
e && e.getCssSelector() && (s = r.querySelector(e.getCssSelector())), s || (s = r.body);
|
|
1951
|
-
const n = new
|
|
1951
|
+
const n = new gt(s, i.highlight, {
|
|
1952
1952
|
prefix: i.before,
|
|
1953
1953
|
suffix: i.after
|
|
1954
1954
|
});
|
|
@@ -1967,7 +1967,7 @@ function pt(r, t) {
|
|
|
1967
1967
|
}
|
|
1968
1968
|
if (s) {
|
|
1969
1969
|
const n = r.createRange();
|
|
1970
|
-
return s.childNodes.length === 0 ||
|
|
1970
|
+
return s.childNodes.length === 0 || je(s) ? (n.selectNode(s), n) : (n.setStartBefore(s), n.setEndAfter(s), n);
|
|
1971
1971
|
}
|
|
1972
1972
|
}
|
|
1973
1973
|
} catch (e) {
|
|
@@ -1975,43 +1975,43 @@ function pt(r, t) {
|
|
|
1975
1975
|
}
|
|
1976
1976
|
return null;
|
|
1977
1977
|
}
|
|
1978
|
-
function
|
|
1978
|
+
function ti(r, t) {
|
|
1979
1979
|
let e = r.getClientRects();
|
|
1980
1980
|
e.length || r.commonAncestorContainer.nodeType === Node.ELEMENT_NODE && (e = r.commonAncestorContainer.getClientRects());
|
|
1981
1981
|
const i = 1, s = [];
|
|
1982
|
-
for (const
|
|
1982
|
+
for (const d of e)
|
|
1983
1983
|
s.push({
|
|
1984
|
-
bottom:
|
|
1985
|
-
height:
|
|
1986
|
-
left:
|
|
1987
|
-
right:
|
|
1988
|
-
top:
|
|
1989
|
-
width:
|
|
1984
|
+
bottom: d.bottom,
|
|
1985
|
+
height: d.height,
|
|
1986
|
+
left: d.left,
|
|
1987
|
+
right: d.right,
|
|
1988
|
+
top: d.top,
|
|
1989
|
+
width: d.width
|
|
1990
1990
|
});
|
|
1991
|
-
const n =
|
|
1991
|
+
const n = Oe(
|
|
1992
1992
|
s,
|
|
1993
1993
|
i
|
|
1994
|
-
), o =
|
|
1995
|
-
for (let
|
|
1996
|
-
const u = a[
|
|
1997
|
-
if (!(u.width * u.height >
|
|
1994
|
+
), o = ii(n, i), a = Re(o), c = 4;
|
|
1995
|
+
for (let d = a.length - 1; d >= 0; d--) {
|
|
1996
|
+
const u = a[d];
|
|
1997
|
+
if (!(u.width * u.height > c))
|
|
1998
1998
|
if (a.length > 1)
|
|
1999
|
-
a.splice(
|
|
1999
|
+
a.splice(d, 1);
|
|
2000
2000
|
else
|
|
2001
2001
|
break;
|
|
2002
2002
|
}
|
|
2003
2003
|
return a;
|
|
2004
2004
|
}
|
|
2005
|
-
function
|
|
2005
|
+
function Oe(r, t, e) {
|
|
2006
2006
|
for (let i = 0; i < r.length; i++)
|
|
2007
2007
|
for (let s = i + 1; s < r.length; s++) {
|
|
2008
2008
|
const n = r[i], o = r[s];
|
|
2009
2009
|
if (n === o)
|
|
2010
2010
|
continue;
|
|
2011
|
-
const a =
|
|
2012
|
-
if (a && !
|
|
2013
|
-
const g = r.filter((v) => v !== n && v !== o),
|
|
2014
|
-
return g.push(
|
|
2011
|
+
const a = z(n.top, o.top, t) && z(n.bottom, o.bottom, t), c = z(n.left, o.left, t) && z(n.right, o.right, t);
|
|
2012
|
+
if (a && !c && De(n, o, t)) {
|
|
2013
|
+
const g = r.filter((v) => v !== n && v !== o), p = ei(n, o);
|
|
2014
|
+
return g.push(p), Oe(
|
|
2015
2015
|
g,
|
|
2016
2016
|
t
|
|
2017
2017
|
);
|
|
@@ -2019,7 +2019,7 @@ function Se(r, t, e) {
|
|
|
2019
2019
|
}
|
|
2020
2020
|
return r;
|
|
2021
2021
|
}
|
|
2022
|
-
function
|
|
2022
|
+
function ei(r, t) {
|
|
2023
2023
|
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);
|
|
2024
2024
|
return {
|
|
2025
2025
|
bottom: n,
|
|
@@ -2030,7 +2030,7 @@ function Ke(r, t) {
|
|
|
2030
2030
|
width: i - e
|
|
2031
2031
|
};
|
|
2032
2032
|
}
|
|
2033
|
-
function
|
|
2033
|
+
function ii(r, t) {
|
|
2034
2034
|
const e = new Set(r);
|
|
2035
2035
|
for (const i of r) {
|
|
2036
2036
|
if (!(i.width > 1 && i.height > 1)) {
|
|
@@ -2038,40 +2038,40 @@ function Ze(r, t) {
|
|
|
2038
2038
|
continue;
|
|
2039
2039
|
}
|
|
2040
2040
|
for (const n of r)
|
|
2041
|
-
if (i !== n && e.has(n) &&
|
|
2041
|
+
if (i !== n && e.has(n) && si(n, i, t)) {
|
|
2042
2042
|
e.delete(i);
|
|
2043
2043
|
break;
|
|
2044
2044
|
}
|
|
2045
2045
|
}
|
|
2046
2046
|
return Array.from(e);
|
|
2047
2047
|
}
|
|
2048
|
-
function
|
|
2049
|
-
return
|
|
2048
|
+
function si(r, t, e) {
|
|
2049
|
+
return ct(r, t.left, t.top, e) && ct(r, t.right, t.top, e) && ct(r, t.left, t.bottom, e) && ct(r, t.right, t.bottom, e);
|
|
2050
2050
|
}
|
|
2051
|
-
function
|
|
2052
|
-
return (r.left < t ||
|
|
2051
|
+
function ct(r, t, e, i) {
|
|
2052
|
+
return (r.left < t || z(r.left, t, i)) && (r.right > t || z(r.right, t, i)) && (r.top < e || z(r.top, e, i)) && (r.bottom > e || z(r.bottom, e, i));
|
|
2053
2053
|
}
|
|
2054
|
-
function
|
|
2054
|
+
function Re(r) {
|
|
2055
2055
|
for (let t = 0; t < r.length; t++)
|
|
2056
2056
|
for (let e = t + 1; e < r.length; e++) {
|
|
2057
2057
|
const i = r[t], s = r[e];
|
|
2058
|
-
if (i !== s &&
|
|
2058
|
+
if (i !== s && De(i, s, -1)) {
|
|
2059
2059
|
let n = [], o;
|
|
2060
|
-
const a =
|
|
2060
|
+
const a = de(i, s);
|
|
2061
2061
|
if (a.length === 1)
|
|
2062
2062
|
n = a, o = i;
|
|
2063
2063
|
else {
|
|
2064
|
-
const
|
|
2065
|
-
a.length <
|
|
2064
|
+
const d = de(s, i);
|
|
2065
|
+
a.length < d.length ? (n = a, o = i) : (n = d, o = s);
|
|
2066
2066
|
}
|
|
2067
|
-
const
|
|
2068
|
-
return Array.prototype.push.apply(
|
|
2067
|
+
const c = r.filter((d) => d !== o);
|
|
2068
|
+
return Array.prototype.push.apply(c, n), Re(c);
|
|
2069
2069
|
}
|
|
2070
2070
|
}
|
|
2071
2071
|
return r;
|
|
2072
2072
|
}
|
|
2073
|
-
function
|
|
2074
|
-
const e =
|
|
2073
|
+
function de(r, t) {
|
|
2074
|
+
const e = ni(t, r);
|
|
2075
2075
|
if (e.height === 0 || e.width === 0)
|
|
2076
2076
|
return [r];
|
|
2077
2077
|
const i = [];
|
|
@@ -2121,7 +2121,7 @@ function ne(r, t) {
|
|
|
2121
2121
|
}
|
|
2122
2122
|
return i;
|
|
2123
2123
|
}
|
|
2124
|
-
function
|
|
2124
|
+
function ni(r, t) {
|
|
2125
2125
|
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);
|
|
2126
2126
|
return {
|
|
2127
2127
|
bottom: n,
|
|
@@ -2132,52 +2132,52 @@ function Qe(r, t) {
|
|
|
2132
2132
|
width: Math.max(0, i - e)
|
|
2133
2133
|
};
|
|
2134
2134
|
}
|
|
2135
|
-
function
|
|
2136
|
-
return (r.left < t.right || e >= 0 &&
|
|
2135
|
+
function De(r, t, e) {
|
|
2136
|
+
return (r.left < t.right || e >= 0 && z(r.left, t.right, e)) && (t.left < r.right || e >= 0 && z(t.left, r.right, e)) && (r.top < t.bottom || e >= 0 && z(r.top, t.bottom, e)) && (t.top < r.bottom || e >= 0 && z(t.top, r.bottom, e));
|
|
2137
2137
|
}
|
|
2138
|
-
function
|
|
2138
|
+
function z(r, t, e) {
|
|
2139
2139
|
return Math.abs(r - t) <= e;
|
|
2140
2140
|
}
|
|
2141
|
-
function
|
|
2141
|
+
function Gt(r) {
|
|
2142
2142
|
const t = {}, e = r.document.documentElement.style;
|
|
2143
2143
|
for (const i in r.document.documentElement.style)
|
|
2144
2144
|
Object.hasOwn(e, i) && !Number.isNaN(Number.parseInt(i)) && (t[e[i]] = e.getPropertyValue(e[i]));
|
|
2145
2145
|
return t;
|
|
2146
2146
|
}
|
|
2147
|
-
function
|
|
2148
|
-
const e =
|
|
2147
|
+
function Ie(r, t) {
|
|
2148
|
+
const e = Gt(r);
|
|
2149
2149
|
Object.keys(e).forEach((i) => {
|
|
2150
|
-
t.hasOwnProperty(i) ||
|
|
2150
|
+
t.hasOwnProperty(i) || bt(r, i);
|
|
2151
2151
|
}), Object.entries(t).forEach(([i, s]) => {
|
|
2152
|
-
e[i] !== s &&
|
|
2152
|
+
e[i] !== s && nt(r, i, s);
|
|
2153
2153
|
});
|
|
2154
2154
|
}
|
|
2155
|
-
function
|
|
2155
|
+
function Et(r, t) {
|
|
2156
2156
|
return r.document.documentElement.style.getPropertyValue(t);
|
|
2157
2157
|
}
|
|
2158
|
-
function
|
|
2158
|
+
function nt(r, t, e) {
|
|
2159
2159
|
r.document.documentElement.style.setProperty(t, e);
|
|
2160
2160
|
}
|
|
2161
|
-
function
|
|
2161
|
+
function bt(r, t) {
|
|
2162
2162
|
r.document.documentElement.style.removeProperty(t);
|
|
2163
2163
|
}
|
|
2164
|
-
let
|
|
2165
|
-
const
|
|
2166
|
-
if (!
|
|
2164
|
+
let ht = null, At = null, Q = 0;
|
|
2165
|
+
const $ = { r: 255, g: 255, b: 255, a: 1 }, G = /* @__PURE__ */ new Map(), ri = () => {
|
|
2166
|
+
if (!ht)
|
|
2167
2167
|
if (typeof OffscreenCanvas < "u")
|
|
2168
|
-
|
|
2168
|
+
ht = new OffscreenCanvas(5, 5), At = ht.getContext("2d", {
|
|
2169
2169
|
willReadFrequently: !0,
|
|
2170
2170
|
desynchronized: !0
|
|
2171
2171
|
});
|
|
2172
2172
|
else {
|
|
2173
2173
|
const r = document.createElement("canvas");
|
|
2174
|
-
r.width = 5, r.height = 5,
|
|
2174
|
+
r.width = 5, r.height = 5, ht = r, At = r.getContext("2d", {
|
|
2175
2175
|
willReadFrequently: !0,
|
|
2176
2176
|
desynchronized: !0
|
|
2177
2177
|
});
|
|
2178
2178
|
}
|
|
2179
|
-
return
|
|
2180
|
-
},
|
|
2179
|
+
return At;
|
|
2180
|
+
}, oi = (r) => {
|
|
2181
2181
|
if (!r) return !0;
|
|
2182
2182
|
const t = r.trim().toLowerCase();
|
|
2183
2183
|
return t.startsWith("var(") || [
|
|
@@ -2196,56 +2196,56 @@ const G = { r: 255, g: 255, b: 255, a: 1 }, V = /* @__PURE__ */ new Map(), je =
|
|
|
2196
2196
|
"repeating-radial-gradient",
|
|
2197
2197
|
"repeating-conic-gradient"
|
|
2198
2198
|
].some((s) => t.includes(s));
|
|
2199
|
-
},
|
|
2199
|
+
}, dt = (r, t) => {
|
|
2200
2200
|
console.warn(
|
|
2201
|
-
`[Decorator] Could not parse color: "${r}". ${t} Falling back to ${JSON.stringify(
|
|
2201
|
+
`[Decorator] Could not parse color: "${r}". ${t} Falling back to ${JSON.stringify($)} to compute contrast. Please use a CSS color value that can be computed to RGB(A).`
|
|
2202
2202
|
);
|
|
2203
|
-
},
|
|
2204
|
-
const e = t ? `${r}|${t}` : r, i =
|
|
2203
|
+
}, Tt = (r, t = null) => {
|
|
2204
|
+
const e = t ? `${r}|${t}` : r, i = G.get(e);
|
|
2205
2205
|
if (i !== void 0)
|
|
2206
|
-
return i ??
|
|
2207
|
-
if (
|
|
2208
|
-
return
|
|
2209
|
-
const s =
|
|
2206
|
+
return i ?? $;
|
|
2207
|
+
if (oi(r))
|
|
2208
|
+
return dt(r, "Unsupported color format or special value."), G.set(e, null), $;
|
|
2209
|
+
const s = ri();
|
|
2210
2210
|
if (!s)
|
|
2211
|
-
return
|
|
2211
|
+
return dt(r, "Could not get canvas context."), G.set(e, null), $;
|
|
2212
2212
|
try {
|
|
2213
|
-
|
|
2214
|
-
const n =
|
|
2213
|
+
Q === 0 && s.clearRect(0, 0, 5, 5);
|
|
2214
|
+
const n = Q % 5, o = Math.floor(Q / 5);
|
|
2215
2215
|
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);
|
|
2216
2216
|
const a = s.getImageData(n, o, 1, 1);
|
|
2217
|
-
|
|
2218
|
-
const [
|
|
2217
|
+
Q = (Q + 1) % 25;
|
|
2218
|
+
const [c, d, u, g] = a.data;
|
|
2219
2219
|
if (g === 0)
|
|
2220
|
-
return
|
|
2221
|
-
const
|
|
2222
|
-
return
|
|
2220
|
+
return dt(r, "Fully transparent color."), G.set(e, null), $;
|
|
2221
|
+
const p = { r: c, g: d, b: u, a: g / 255 };
|
|
2222
|
+
return G.set(e, p), p;
|
|
2223
2223
|
} catch (n) {
|
|
2224
|
-
return
|
|
2224
|
+
return dt(r, `Error: ${n instanceof Error ? n.message : String(n)}`), G.set(e, null), $;
|
|
2225
2225
|
}
|
|
2226
|
-
},
|
|
2226
|
+
}, Ct = (r) => {
|
|
2227
2227
|
const t = r / 255;
|
|
2228
2228
|
return t <= 0.03928 ? t / 12.92 : Math.pow((t + 0.055) / 1.055, 2.4);
|
|
2229
|
-
},
|
|
2230
|
-
const t =
|
|
2229
|
+
}, ue = (r) => {
|
|
2230
|
+
const t = Ct(r.r), e = Ct(r.g), i = Ct(r.b);
|
|
2231
2231
|
return 0.2126 * t + 0.7152 * e + 0.0722 * i;
|
|
2232
|
-
},
|
|
2233
|
-
const e = typeof r == "string" ?
|
|
2232
|
+
}, pe = (r, t) => {
|
|
2233
|
+
const e = typeof r == "string" ? Tt(r) : r, i = typeof t == "string" ? Tt(t) : t, s = ue(e), n = ue(i), o = Math.max(s, n), a = Math.min(s, n);
|
|
2234
2234
|
return (o + 0.05) / (a + 0.05);
|
|
2235
|
-
},
|
|
2236
|
-
const e =
|
|
2235
|
+
}, Pt = (r, t = null) => {
|
|
2236
|
+
const e = Tt(r, t), i = pe(e, { r: 255, g: 255, b: 255, a: 1 }), s = pe(e, { r: 0, g: 0, b: 0, a: 1 });
|
|
2237
2237
|
return i > s;
|
|
2238
|
-
},
|
|
2239
|
-
var
|
|
2240
|
-
const
|
|
2241
|
-
class
|
|
2238
|
+
}, ai = (r, t = null) => Pt(r, t) ? "white" : "black", me = "#FFFF00";
|
|
2239
|
+
var li = /* @__PURE__ */ ((r) => (r.Wrap = "wrap", r.Viewport = "viewport", r.Bounds = "bounds", r.Page = "page", r))(li || {}), ci = /* @__PURE__ */ ((r) => (r.Boxes = "boxes", r.Bounds = "bounds", r))(ci || {});
|
|
2240
|
+
const hi = () => "Highlight" in window, fe = ["IMG", "IMAGE", "AUDIO", "VIDEO", "SVG"];
|
|
2241
|
+
class di {
|
|
2242
2242
|
/**
|
|
2243
2243
|
* Creates a DecorationGroup object
|
|
2244
2244
|
* @param id Unique HTML ID-adhering name of the group
|
|
2245
2245
|
* @param name Human-readable name of the group
|
|
2246
2246
|
*/
|
|
2247
2247
|
constructor(t, e, i, s) {
|
|
2248
|
-
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,
|
|
2248
|
+
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, hi() && (this.experimentalHighlights = !0, this.notTextFlag = /* @__PURE__ */ new Map());
|
|
2249
2249
|
}
|
|
2250
2250
|
get activeable() {
|
|
2251
2251
|
return this.activateable;
|
|
@@ -2258,13 +2258,13 @@ class ri {
|
|
|
2258
2258
|
* @param decoration Decoration to add
|
|
2259
2259
|
*/
|
|
2260
2260
|
add(t) {
|
|
2261
|
-
const e = `${this.id}-${this.lastItemId++}`, i =
|
|
2261
|
+
const e = `${this.id}-${this.lastItemId++}`, i = rt(this.wnd.document, t.locator);
|
|
2262
2262
|
if (!i) {
|
|
2263
2263
|
this.comms.log("Can't locate DOM range for decoration", t);
|
|
2264
2264
|
return;
|
|
2265
2265
|
}
|
|
2266
2266
|
const s = i.commonAncestorContainer;
|
|
2267
|
-
s.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (
|
|
2267
|
+
s.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (fe.includes(s.nodeName.toUpperCase()) && this.notTextFlag?.set(e, !0), i.cloneContents().querySelector(fe.join(", ").toLowerCase()) && this.notTextFlag?.set(e, !0), (s.textContent?.trim() || "").length === 0 && this.notTextFlag?.set(e, !0));
|
|
2268
2268
|
const n = {
|
|
2269
2269
|
decoration: t,
|
|
2270
2270
|
id: e,
|
|
@@ -2305,10 +2305,10 @@ class ri {
|
|
|
2305
2305
|
experimentalLayout(t) {
|
|
2306
2306
|
const [e, i] = this.requireContainer(!0);
|
|
2307
2307
|
i.add(t.range);
|
|
2308
|
-
const s =
|
|
2308
|
+
const s = Et(this.wnd, "--USER__backgroundColor") || this.wnd.getComputedStyle(this.wnd.document.documentElement).getPropertyValue("background-color"), n = t.decoration?.style?.tint ?? me;
|
|
2309
2309
|
e.innerHTML = `
|
|
2310
2310
|
::highlight(${this.id}) {
|
|
2311
|
-
color: ${
|
|
2311
|
+
color: ${ai(n, s)};
|
|
2312
2312
|
background-color: ${n};
|
|
2313
2313
|
}`;
|
|
2314
2314
|
}
|
|
@@ -2325,30 +2325,30 @@ class ri {
|
|
|
2325
2325
|
getComputedStyle(this.wnd.document.documentElement).getPropertyValue(
|
|
2326
2326
|
"column-count"
|
|
2327
2327
|
)
|
|
2328
|
-
), n = i / (s || 1), o = this.wnd.document.scrollingElement, a = o.scrollLeft,
|
|
2328
|
+
), n = i / (s || 1), o = this.wnd.document.scrollingElement, a = o.scrollLeft, c = o.scrollTop, d = (f, m, b) => {
|
|
2329
2329
|
if (f.style.position = "absolute", t.decoration?.style?.width === "viewport") {
|
|
2330
|
-
f.style.width = `${i}px`, f.style.height = `${
|
|
2331
|
-
let
|
|
2332
|
-
f.style.left = `${
|
|
2330
|
+
f.style.width = `${i}px`, f.style.height = `${m.height}px`;
|
|
2331
|
+
let O = Math.floor(m.left / i) * i;
|
|
2332
|
+
f.style.left = `${O + a}px`, f.style.top = `${m.top + c}px`;
|
|
2333
2333
|
} else if (t.decoration?.style?.width === "bounds")
|
|
2334
|
-
f.style.width = `${b.width}px`, f.style.height = `${
|
|
2334
|
+
f.style.width = `${b.width}px`, f.style.height = `${m.height}px`, f.style.left = `${b.left + a}px`, f.style.top = `${m.top + c}px`;
|
|
2335
2335
|
else if (t.decoration?.style?.width === "page") {
|
|
2336
|
-
f.style.width = `${n}px`, f.style.height = `${
|
|
2337
|
-
let
|
|
2338
|
-
f.style.left = `${
|
|
2336
|
+
f.style.width = `${n}px`, f.style.height = `${m.height}px`;
|
|
2337
|
+
let O = Math.floor(m.left / n) * n;
|
|
2338
|
+
f.style.left = `${O + a}px`, f.style.top = `${m.top + c}px`;
|
|
2339
2339
|
} else
|
|
2340
|
-
f.style.width = `${
|
|
2340
|
+
f.style.width = `${m.width}px`, f.style.height = `${m.height}px`, f.style.left = `${m.left + a}px`, f.style.top = `${m.top + c}px`;
|
|
2341
2341
|
}, u = t.range.getBoundingClientRect();
|
|
2342
2342
|
let g = this.wnd.document.createElement("template");
|
|
2343
|
-
const
|
|
2343
|
+
const p = this.getCurrentDarkMode();
|
|
2344
2344
|
g.innerHTML = `
|
|
2345
2345
|
<div
|
|
2346
2346
|
data-readium="true"
|
|
2347
2347
|
class="readium-highlight"
|
|
2348
2348
|
style="${[
|
|
2349
|
-
`background-color: ${t.decoration?.style?.tint ??
|
|
2349
|
+
`background-color: ${t.decoration?.style?.tint ?? me} !important`,
|
|
2350
2350
|
//"opacity: 0.3 !important",
|
|
2351
|
-
`mix-blend-mode: ${
|
|
2351
|
+
`mix-blend-mode: ${p ? "exclusion" : "multiply"} !important`,
|
|
2352
2352
|
"opacity: 1 !important",
|
|
2353
2353
|
"box-sizing: border-box !important"
|
|
2354
2354
|
].join("; ")}"
|
|
@@ -2358,15 +2358,15 @@ class ri {
|
|
|
2358
2358
|
const v = g.content.firstElementChild;
|
|
2359
2359
|
if (t.decoration?.style?.layout === "bounds") {
|
|
2360
2360
|
const f = v.cloneNode(!0);
|
|
2361
|
-
f.style.setProperty("pointer-events", "none"),
|
|
2361
|
+
f.style.setProperty("pointer-events", "none"), d(f, u, u), e.append(f);
|
|
2362
2362
|
} else {
|
|
2363
|
-
let f =
|
|
2363
|
+
let f = ti(
|
|
2364
2364
|
t.range
|
|
2365
2365
|
);
|
|
2366
|
-
f = f.sort((
|
|
2367
|
-
for (let
|
|
2366
|
+
f = f.sort((m, b) => m.top < b.top ? -1 : m.top > b.top ? 1 : 0);
|
|
2367
|
+
for (let m of f) {
|
|
2368
2368
|
const b = v.cloneNode(!0);
|
|
2369
|
-
b.style.setProperty("pointer-events", "none"),
|
|
2369
|
+
b.style.setProperty("pointer-events", "none"), d(b, m, u), e.append(b);
|
|
2370
2370
|
}
|
|
2371
2371
|
}
|
|
2372
2372
|
t.container = e, t.clickableElements = Array.from(
|
|
@@ -2393,7 +2393,7 @@ class ri {
|
|
|
2393
2393
|
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;
|
|
2394
2394
|
}
|
|
2395
2395
|
getCurrentDarkMode() {
|
|
2396
|
-
return
|
|
2396
|
+
return Et(this.wnd, "--USER__appearance") === "readium-night-on" || Pt(Et(this.wnd, "--USER__backgroundColor")) || Pt(this.wnd.getComputedStyle(this.wnd.document.documentElement).getPropertyValue("background-color"));
|
|
2397
2397
|
}
|
|
2398
2398
|
/**
|
|
2399
2399
|
* Removes the group container.
|
|
@@ -2402,7 +2402,7 @@ class ri {
|
|
|
2402
2402
|
this.experimentalHighlights && this.wnd.CSS.highlights.delete(this.id), this.container && (this.container.remove(), this.container = void 0);
|
|
2403
2403
|
}
|
|
2404
2404
|
}
|
|
2405
|
-
const
|
|
2405
|
+
const tt = class tt extends Z {
|
|
2406
2406
|
constructor() {
|
|
2407
2407
|
super(...arguments), this.resizeFrame = 0, this.lastGroupId = 0, this.groups = /* @__PURE__ */ new Map(), this.handleResizer = this.handleResize.bind(this);
|
|
2408
2408
|
}
|
|
@@ -2427,9 +2427,9 @@ const Q = class Q extends X {
|
|
|
2427
2427
|
}, 50);
|
|
2428
2428
|
}
|
|
2429
2429
|
mount(t, e) {
|
|
2430
|
-
return this.wnd = t, e.register("decorate",
|
|
2430
|
+
return this.wnd = t, e.register("decorate", tt.moduleName, (i, s) => {
|
|
2431
2431
|
const n = i;
|
|
2432
|
-
n.decoration && n.decoration.locator && (n.decoration.locator = W.deserialize(n.decoration.locator)), this.groups.has(n.group) || this.groups.set(n.group, new
|
|
2432
|
+
n.decoration && n.decoration.locator && (n.decoration.locator = W.deserialize(n.decoration.locator)), this.groups.has(n.group) || this.groups.set(n.group, new di(
|
|
2433
2433
|
t,
|
|
2434
2434
|
e,
|
|
2435
2435
|
`readium-decoration-${this.lastGroupId++}`,
|
|
@@ -2454,8 +2454,8 @@ const Q = class Q extends X {
|
|
|
2454
2454
|
}), 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) => {
|
|
2455
2455
|
i.some((n) => {
|
|
2456
2456
|
if (n.type === "attributes" && n.attributeName === "style") {
|
|
2457
|
-
const o = n.target, a = n.oldValue,
|
|
2458
|
-
return
|
|
2457
|
+
const o = n.target, a = n.oldValue, c = o.getAttribute("style"), d = this.extractCustomProperty(a, "--USER__appearance"), u = this.extractCustomProperty(c, "--USER__appearance"), g = this.extractCustomProperty(a, "--USER__backgroundColor"), p = this.extractCustomProperty(c, "--USER__backgroundColor");
|
|
2458
|
+
return d !== u || g !== p;
|
|
2459
2459
|
}
|
|
2460
2460
|
return !1;
|
|
2461
2461
|
}) && this.updateHighlightStyles();
|
|
@@ -2467,12 +2467,12 @@ const Q = class Q extends X {
|
|
|
2467
2467
|
}), e.log("Decorator Mounted"), !0;
|
|
2468
2468
|
}
|
|
2469
2469
|
unmount(t, e) {
|
|
2470
|
-
return t.removeEventListener("orientationchange", this.handleResizer), t.removeEventListener("resize", this.handleResizer), e.unregisterAll(
|
|
2470
|
+
return t.removeEventListener("orientationchange", this.handleResizer), t.removeEventListener("resize", this.handleResizer), e.unregisterAll(tt.moduleName), this.resizeObserver.disconnect(), this.backgroundObserver.disconnect(), this.cleanup(), e.log("Decorator Unmounted"), !0;
|
|
2471
2471
|
}
|
|
2472
2472
|
};
|
|
2473
|
-
|
|
2474
|
-
let
|
|
2475
|
-
const
|
|
2473
|
+
tt.moduleName = "decorator";
|
|
2474
|
+
let Nt = tt;
|
|
2475
|
+
const ge = "readium-snapper-style", et = class et extends Z {
|
|
2476
2476
|
constructor() {
|
|
2477
2477
|
super(...arguments), this.protected = !1;
|
|
2478
2478
|
}
|
|
@@ -2485,59 +2485,59 @@ const ce = "readium-snapper-style", j = class j extends X {
|
|
|
2485
2485
|
}
|
|
2486
2486
|
mount(t, e) {
|
|
2487
2487
|
const i = t.document.createElement("style");
|
|
2488
|
-
return i.dataset.readium = "true", i.id =
|
|
2488
|
+
return i.dataset.readium = "true", i.id = ge, i.textContent = this.buildStyles(), t.document.head.appendChild(i), e.register("protect", et.moduleName, (s, n) => {
|
|
2489
2489
|
this.protected = !0, i.textContent = this.buildStyles(), n(!0);
|
|
2490
|
-
}), e.register("unprotect",
|
|
2490
|
+
}), e.register("unprotect", et.moduleName, (s, n) => {
|
|
2491
2491
|
this.protected = !1, i.textContent = this.buildStyles(), n(!0);
|
|
2492
2492
|
}), e.log("Snapper Mounted"), !0;
|
|
2493
2493
|
}
|
|
2494
2494
|
unmount(t, e) {
|
|
2495
|
-
return t.document.getElementById(
|
|
2495
|
+
return t.document.getElementById(ge)?.remove(), e.log("Snapper Unmounted"), !0;
|
|
2496
2496
|
}
|
|
2497
2497
|
};
|
|
2498
|
-
|
|
2499
|
-
let
|
|
2500
|
-
function
|
|
2501
|
-
return r.document.body.dir.toLowerCase() === "rtl";
|
|
2498
|
+
et.moduleName = "snapper";
|
|
2499
|
+
let K = et;
|
|
2500
|
+
function I(r) {
|
|
2501
|
+
return (r.document.body.dir || r.document.documentElement.dir).toLowerCase() === "rtl";
|
|
2502
2502
|
}
|
|
2503
|
-
function
|
|
2503
|
+
function ze(r) {
|
|
2504
2504
|
return parseInt(
|
|
2505
2505
|
r.getComputedStyle(
|
|
2506
2506
|
r.document.documentElement
|
|
2507
2507
|
).getPropertyValue("column-count")
|
|
2508
2508
|
);
|
|
2509
2509
|
}
|
|
2510
|
-
function
|
|
2510
|
+
function ye(r) {
|
|
2511
2511
|
const t = getComputedStyle(r), e = parseFloat(t.paddingTop || "0"), i = parseFloat(t.paddingBottom || "0");
|
|
2512
2512
|
return r.clientHeight - e - i;
|
|
2513
2513
|
}
|
|
2514
|
-
function
|
|
2515
|
-
const t =
|
|
2514
|
+
function be(r) {
|
|
2515
|
+
const t = ze(r);
|
|
2516
2516
|
if (!t)
|
|
2517
2517
|
return !1;
|
|
2518
2518
|
const e = r.document.querySelectorAll("div[id^='readium-virtual-page']");
|
|
2519
|
-
for (const
|
|
2520
|
-
|
|
2521
|
-
const i = e.length, s = r.document.scrollingElement.scrollWidth, n = r.visualViewport.width, a = Math.round(s / n * t) % t,
|
|
2522
|
-
if (
|
|
2523
|
-
for (let
|
|
2519
|
+
for (const d of e)
|
|
2520
|
+
d.remove();
|
|
2521
|
+
const i = e.length, s = r.document.scrollingElement.scrollWidth, n = r.visualViewport.width, a = Math.round(s / n * t) % t, c = t === 1 || a === 0 ? 0 : t - a;
|
|
2522
|
+
if (c > 0)
|
|
2523
|
+
for (let d = 0; d < c; d++) {
|
|
2524
2524
|
const u = r.document.createElement("div");
|
|
2525
|
-
u.setAttribute("id", `readium-virtual-page-${
|
|
2525
|
+
u.setAttribute("id", `readium-virtual-page-${d}`), 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 = ye(r.document.documentElement) + "px"), u.innerHTML = "​", r.document.body.appendChild(u);
|
|
2526
2526
|
}
|
|
2527
|
-
return i !==
|
|
2527
|
+
return i !== c;
|
|
2528
2528
|
}
|
|
2529
|
-
function
|
|
2529
|
+
function $t(r) {
|
|
2530
2530
|
const t = r.document.createElement("style");
|
|
2531
2531
|
t.appendChild(r.document.createTextNode("*{}")), r.document.body.appendChild(t), r.document.body.removeChild(t);
|
|
2532
2532
|
}
|
|
2533
|
-
function
|
|
2533
|
+
function ui(r) {
|
|
2534
2534
|
return r < 0.5 ? 2 * r * r : -1 + (4 - 2 * r) * r;
|
|
2535
2535
|
}
|
|
2536
2536
|
function A(r) {
|
|
2537
2537
|
const t = r.getSelection();
|
|
2538
2538
|
t && t.removeAllRanges();
|
|
2539
2539
|
}
|
|
2540
|
-
const
|
|
2540
|
+
const pi = [
|
|
2541
2541
|
"a",
|
|
2542
2542
|
"audio",
|
|
2543
2543
|
"button",
|
|
@@ -2551,11 +2551,11 @@ const ai = [
|
|
|
2551
2551
|
"textarea",
|
|
2552
2552
|
"video"
|
|
2553
2553
|
];
|
|
2554
|
-
function
|
|
2555
|
-
return
|
|
2554
|
+
function Me(r) {
|
|
2555
|
+
return pi.indexOf(r.nodeName.toLowerCase()) !== -1 || r.hasAttribute("contenteditable") && r.getAttribute("contenteditable")?.toLowerCase() !== "false" ? r : r.parentElement ? Me(r.parentElement) : null;
|
|
2556
2556
|
}
|
|
2557
|
-
function
|
|
2558
|
-
const e =
|
|
2557
|
+
function vt(r, t) {
|
|
2558
|
+
const e = ke(r, r.document.body, t), i = r._readium_cssSelectorGenerator.getCssSelector(e, {
|
|
2559
2559
|
selectors: ["tag", "id", "class", "nthchild", "nthoftype", "attribute"]
|
|
2560
2560
|
});
|
|
2561
2561
|
return new W({
|
|
@@ -2566,20 +2566,20 @@ function Ut(r, t) {
|
|
|
2566
2566
|
["cssSelector", i]
|
|
2567
2567
|
])
|
|
2568
2568
|
}),
|
|
2569
|
-
text: new
|
|
2569
|
+
text: new _({
|
|
2570
2570
|
highlight: e.textContent || void 0
|
|
2571
2571
|
})
|
|
2572
2572
|
});
|
|
2573
2573
|
}
|
|
2574
|
-
function
|
|
2574
|
+
function ke(r, t, e) {
|
|
2575
2575
|
for (var i = 0; i < t.children.length; i++) {
|
|
2576
2576
|
const s = t.children[i];
|
|
2577
|
-
if (!
|
|
2578
|
-
return
|
|
2577
|
+
if (!gi(s) && mi(r, s, e))
|
|
2578
|
+
return fi(r, s) ? s : ke(r, s, e);
|
|
2579
2579
|
}
|
|
2580
2580
|
return t;
|
|
2581
2581
|
}
|
|
2582
|
-
function
|
|
2582
|
+
function mi(r, t, e) {
|
|
2583
2583
|
if (t === document.body || t === document.documentElement)
|
|
2584
2584
|
return !0;
|
|
2585
2585
|
if (!document || !document.documentElement || !document.body)
|
|
@@ -2587,11 +2587,11 @@ function li(r, t, e) {
|
|
|
2587
2587
|
const i = t.getBoundingClientRect();
|
|
2588
2588
|
return e ? i.bottom > 0 && i.top < r.innerHeight : i.right > 0 && i.left < r.innerWidth;
|
|
2589
2589
|
}
|
|
2590
|
-
function
|
|
2590
|
+
function fi(r, t) {
|
|
2591
2591
|
const e = t.getBoundingClientRect();
|
|
2592
2592
|
return e.top >= 0 && e.left >= 0 && e.bottom <= r.innerHeight && e.right <= r.innerWidth;
|
|
2593
2593
|
}
|
|
2594
|
-
function
|
|
2594
|
+
function gi(r) {
|
|
2595
2595
|
const t = getComputedStyle(r);
|
|
2596
2596
|
if (t) {
|
|
2597
2597
|
const e = t.getPropertyValue("display");
|
|
@@ -2600,7 +2600,7 @@ function hi(r) {
|
|
|
2600
2600
|
}
|
|
2601
2601
|
return !1;
|
|
2602
2602
|
}
|
|
2603
|
-
const
|
|
2603
|
+
const yi = {
|
|
2604
2604
|
maxVelocity: 200,
|
|
2605
2605
|
// Reasonable default for human-like scrolling (pixels/ms)
|
|
2606
2606
|
minVariance: 0.01,
|
|
@@ -2611,7 +2611,7 @@ const di = {
|
|
|
2611
2611
|
// Reasonable default for detecting patterns
|
|
2612
2612
|
maxConsistentScrolls: 15
|
|
2613
2613
|
// Balanced threshold for flagging
|
|
2614
|
-
},
|
|
2614
|
+
}, Yt = {
|
|
2615
2615
|
maxVelocity: 200,
|
|
2616
2616
|
// Extremely fast scrolling (pixels/ms)
|
|
2617
2617
|
minVariance: 1e-5,
|
|
@@ -2622,20 +2622,20 @@ const di = {
|
|
|
2622
2622
|
// Only trigger on near-perfect patterns
|
|
2623
2623
|
maxConsistentScrolls: 20
|
|
2624
2624
|
// Need many consistent scrolls
|
|
2625
|
-
},
|
|
2625
|
+
}, We = {
|
|
2626
2626
|
maxSelectionsPerSecond: 500,
|
|
2627
2627
|
minVariance: 50,
|
|
2628
2628
|
historySize: 20
|
|
2629
|
-
},
|
|
2629
|
+
}, bi = {
|
|
2630
2630
|
enabled: !0,
|
|
2631
2631
|
maxSelectionPercent: 0.1,
|
|
2632
2632
|
minThreshold: 100,
|
|
2633
2633
|
absoluteMaxChars: 5e3,
|
|
2634
2634
|
historySize: 20
|
|
2635
2635
|
};
|
|
2636
|
-
class
|
|
2636
|
+
class wt {
|
|
2637
2637
|
constructor(t = {}) {
|
|
2638
|
-
this.history = [], this.consistentScrollCount = 0, this.options = { ...
|
|
2638
|
+
this.history = [], this.consistentScrollCount = 0, this.options = { ...yi, ...t };
|
|
2639
2639
|
}
|
|
2640
2640
|
analyze(t, e, i) {
|
|
2641
2641
|
if (i <= 0) return !1;
|
|
@@ -2645,19 +2645,19 @@ class Bt {
|
|
|
2645
2645
|
direction: t,
|
|
2646
2646
|
velocity: s,
|
|
2647
2647
|
distance: Math.abs(e)
|
|
2648
|
-
}), this.history = this.history.filter((
|
|
2648
|
+
}), this.history = this.history.filter((m) => n - m.timestamp < 2e3).slice(-(this.options.historySize || 20)), this.history.length < 3) return !1;
|
|
2649
2649
|
if (s > this.options.maxVelocity)
|
|
2650
2650
|
return this.resetAfterDetection(), !0;
|
|
2651
|
-
const o = this.history.map((
|
|
2652
|
-
if (u < this.options.minVariance && g <
|
|
2651
|
+
const o = this.history.map((m) => m.velocity), a = this.history.map((m) => m.distance), c = o.reduce((m, b) => m + b, 0) / o.length, d = a.reduce((m, b) => m + b, 0) / a.length, u = o.reduce((m, b) => m + Math.pow(b - c, 2), 0) / o.length, g = a.reduce((m, b) => m + Math.pow(b - d, 2), 0) / a.length;
|
|
2652
|
+
if (u < this.options.minVariance && g < d * 0.1) {
|
|
2653
2653
|
if (this.consistentScrollCount++, this.consistentScrollCount >= (this.options.maxConsistentScrolls || 10))
|
|
2654
2654
|
return this.resetAfterDetection(), !0;
|
|
2655
2655
|
} else
|
|
2656
2656
|
this.consistentScrollCount = Math.max(0, this.consistentScrollCount - 1);
|
|
2657
|
-
let
|
|
2658
|
-
for (let
|
|
2659
|
-
this.history[
|
|
2660
|
-
return
|
|
2657
|
+
let p = 0, v = this.history[0].direction;
|
|
2658
|
+
for (let m = 1; m < this.history.length; m++)
|
|
2659
|
+
this.history[m].direction !== v && (p++, v = this.history[m].direction);
|
|
2660
|
+
return p / this.history.length > (this.options.minDirectionChanges || 0.3) ? (this.resetAfterDetection(), !0) : !1;
|
|
2661
2661
|
}
|
|
2662
2662
|
resetAfterDetection() {
|
|
2663
2663
|
this.history = this.history.slice(-3), this.consistentScrollCount = 0;
|
|
@@ -2666,7 +2666,7 @@ class Bt {
|
|
|
2666
2666
|
this.history = [], this.consistentScrollCount = 0;
|
|
2667
2667
|
}
|
|
2668
2668
|
}
|
|
2669
|
-
const
|
|
2669
|
+
const ve = "readium-column-snapper-style", vi = 200, T = class T extends K {
|
|
2670
2670
|
constructor() {
|
|
2671
2671
|
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);
|
|
2672
2672
|
}
|
|
@@ -2674,26 +2674,44 @@ const ue = "readium-column-snapper-style", pi = 200, P = class P extends st {
|
|
|
2674
2674
|
return this.wnd.document.scrollingElement;
|
|
2675
2675
|
}
|
|
2676
2676
|
scrollOffset() {
|
|
2677
|
-
|
|
2677
|
+
const t = this.doc().scrollLeft;
|
|
2678
|
+
return t !== 0 ? t : this.alreadyScrollLeft;
|
|
2678
2679
|
}
|
|
2679
2680
|
snapOffset(t) {
|
|
2680
|
-
const e = t + (
|
|
2681
|
+
const e = t + (I(this.wnd) ? -1 : 1);
|
|
2682
|
+
return e - e % this.wnd.innerWidth;
|
|
2683
|
+
}
|
|
2684
|
+
/**
|
|
2685
|
+
* Snap a non-negative normalized offset (distance from document start) to
|
|
2686
|
+
* the nearest page boundary. Works identically regardless of reading direction.
|
|
2687
|
+
*/
|
|
2688
|
+
snapNormOffset(t) {
|
|
2689
|
+
const e = t + 1;
|
|
2681
2690
|
return e - e % this.wnd.innerWidth;
|
|
2682
2691
|
}
|
|
2692
|
+
/**
|
|
2693
|
+
* Normalized scroll position: distance from document start, always in
|
|
2694
|
+
* [0, scrollWidth - innerWidth] regardless of reading direction.
|
|
2695
|
+
* scrollLeft may be negative depending on the browser — Math.abs() normalizes it.
|
|
2696
|
+
*/
|
|
2697
|
+
normScroll() {
|
|
2698
|
+
const t = I(this.wnd), e = this.doc().scrollLeft || this.alreadyScrollLeft;
|
|
2699
|
+
return t ? Math.abs(e) : Math.max(0, this.wnd.scrollX > 0 ? this.wnd.scrollX : e);
|
|
2700
|
+
}
|
|
2683
2701
|
reportProgress() {
|
|
2684
|
-
const t = this.
|
|
2702
|
+
const t = this.cachedScrollWidth, e = this.wnd.innerWidth, i = this.normScroll(), s = Math.max(1, t - e), n = Math.max(0, Math.min(1, i / s)), o = Math.max(0, Math.min(1, (i + e) / t));
|
|
2685
2703
|
this.comms.send("progress", {
|
|
2686
|
-
start:
|
|
2687
|
-
end:
|
|
2704
|
+
start: n,
|
|
2705
|
+
end: o
|
|
2688
2706
|
});
|
|
2689
2707
|
}
|
|
2690
2708
|
shake() {
|
|
2691
2709
|
if (this.overscroll !== 0 || this.shakeTimeout !== 0) return;
|
|
2692
|
-
const t = this.doc();
|
|
2693
|
-
t.classList.add(
|
|
2694
|
-
const
|
|
2710
|
+
const t = this.doc(), e = this.normScroll() < 5, i = I(this.wnd) ? e ? "readium-bounce-r" : "readium-bounce-l" : "readium-bounce-r";
|
|
2711
|
+
t.classList.add(i);
|
|
2712
|
+
const s = this.scrollOffset();
|
|
2695
2713
|
this.shakeTimeout = this.wnd.setTimeout(() => {
|
|
2696
|
-
t.classList.remove(
|
|
2714
|
+
t.classList.remove(i), this.shakeTimeout = 0, this.doc().scrollLeft = s;
|
|
2697
2715
|
}, 150);
|
|
2698
2716
|
}
|
|
2699
2717
|
// We have to cache this because during overscroll (transform, or left) the width is incorrect due to browser
|
|
@@ -2704,27 +2722,21 @@ const ue = "readium-column-snapper-style", pi = 200, P = class P extends st {
|
|
|
2704
2722
|
}
|
|
2705
2723
|
// Snaps the current offset to the page width.
|
|
2706
2724
|
snapCurrentOffset(t = !1, e = !1) {
|
|
2707
|
-
const i = this.wnd.
|
|
2708
|
-
|
|
2709
|
-
d * (this.wnd.innerWidth / 3) * (d * n > 0 ? 2 : 1)
|
|
2710
|
-
), u = this.snapOffset(a + h), g = u > this.scrollOffset() ? "right" : "left";
|
|
2711
|
-
if (this.checkSuspiciousSnap(g, Math.abs(u - this.scrollOffset())), t && u !== this.scrollOffset()) {
|
|
2725
|
+
const i = I(this.wnd), s = this.doc(), n = ze(this.wnd), o = this.cachedScrollWidth - this.wnd.innerWidth, a = Math.min(Math.max(0, this.normScroll()), o), c = this.dragOffset(), d = i ? -c : c, u = this.wnd.innerWidth / 3 * (d > 0 ? 2 : 1), g = Math.min(o, Math.max(0, this.snapNormOffset(a + u))), p = i ? -g : g, v = i ? -a : a, f = p > v ? "right" : "left";
|
|
2726
|
+
if (this.checkSuspiciousSnap(f, Math.abs(p - v)), t && p !== v) {
|
|
2712
2727
|
this.snappingCancelled = !1;
|
|
2713
|
-
const m = (
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
);
|
|
2717
|
-
let f;
|
|
2718
|
-
const p = (b) => {
|
|
2728
|
+
const m = (V, F, at, lt) => at > lt ? F : V + (F - V) * ui(at / lt), b = vi * n;
|
|
2729
|
+
let O;
|
|
2730
|
+
const ot = (V) => {
|
|
2719
2731
|
if (this.snappingCancelled) return;
|
|
2720
|
-
|
|
2721
|
-
const
|
|
2722
|
-
s.scrollLeft =
|
|
2732
|
+
O || (O = V);
|
|
2733
|
+
const F = V - O, at = m(this.overscroll, 0, F, b), lt = m(v, p, F, b);
|
|
2734
|
+
s.scrollLeft = lt, this.overscroll !== 0 && (s.style.transform = `translate3d(${-at}px, 0px, 0px)`), F < b ? this.wnd.requestAnimationFrame(ot) : (this.clearTouches(), s.style.removeProperty("transform"), s.scrollLeft = p, e || this.reportProgress());
|
|
2723
2735
|
};
|
|
2724
|
-
this.wnd.requestAnimationFrame(
|
|
2736
|
+
this.wnd.requestAnimationFrame(ot);
|
|
2725
2737
|
} else
|
|
2726
2738
|
s.style.removeProperty("transform"), this.wnd.requestAnimationFrame(() => {
|
|
2727
|
-
s.scrollLeft =
|
|
2739
|
+
s.scrollLeft = p, this.clearTouches(), e || this.reportProgress();
|
|
2728
2740
|
});
|
|
2729
2741
|
}
|
|
2730
2742
|
dragOffset() {
|
|
@@ -2749,8 +2761,8 @@ const ue = "readium-column-snapper-style", pi = 200, P = class P extends st {
|
|
|
2749
2761
|
}
|
|
2750
2762
|
onTouchEnd(t) {
|
|
2751
2763
|
if (this.touchState === 2) {
|
|
2752
|
-
const e = this.dragOffset(), i = this.
|
|
2753
|
-
this.cachedScrollWidth <= this.wnd.innerWidth ? (this.reportProgress(),
|
|
2764
|
+
const e = this.dragOffset(), i = I(this.wnd), s = this.normScroll(), n = this.cachedScrollWidth - this.wnd.innerWidth, o = i ? -e : e;
|
|
2765
|
+
this.cachedScrollWidth <= this.wnd.innerWidth ? (this.reportProgress(), o > 5 && this.comms.send("no_more", void 0), o < -5 && this.comms.send("no_less", void 0)) : s < 5 && o < 5 ? (this.alreadyScrollLeft = 0, this.comms.send("no_less", void 0)) : n - s < 5 && o > 5 && (this.alreadyScrollLeft = i ? -n : n, this.comms.send("no_more", void 0)), this.snapCurrentOffset(!0), this.comms.send("swipe", e);
|
|
2754
2766
|
}
|
|
2755
2767
|
this.touchState = 0;
|
|
2756
2768
|
}
|
|
@@ -2760,11 +2772,11 @@ const ue = "readium-column-snapper-style", pi = 200, P = class P extends st {
|
|
|
2760
2772
|
onTouchMove(t) {
|
|
2761
2773
|
if (this.touchState === 0) return;
|
|
2762
2774
|
this.touchState === 1 && (this.touchState = 2, A(this.wnd)), this.endingX = t.touches[0].clientX;
|
|
2763
|
-
const e = this.dragOffset(), i = this.alreadyScrollLeft + e;
|
|
2764
|
-
i <
|
|
2775
|
+
const e = this.dragOffset(), i = this.alreadyScrollLeft + e, s = I(this.wnd) ? -(this.cachedScrollWidth - this.wnd.innerWidth) : 0, n = I(this.wnd) ? 0 : this.cachedScrollWidth - this.wnd.innerWidth;
|
|
2776
|
+
i < s ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-this.overscroll}px, 0px, 0px)`) : i > n ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-i}px, 0px, 0px)`) : (this.overscroll = 0, this.doc().style.removeProperty("transform"), this.doc().scrollLeft = i);
|
|
2765
2777
|
}
|
|
2766
2778
|
enableSnapProtection() {
|
|
2767
|
-
this.patternAnalyzer || (this.patternAnalyzer = new
|
|
2779
|
+
this.patternAnalyzer || (this.patternAnalyzer = new wt({
|
|
2768
2780
|
maxVelocity: this.wnd.innerWidth,
|
|
2769
2781
|
// page width
|
|
2770
2782
|
minVariance: 0.1,
|
|
@@ -2790,7 +2802,7 @@ const ue = "readium-column-snapper-style", pi = 200, P = class P extends st {
|
|
|
2790
2802
|
if (this.wnd = t, this.comms = e, !super.mount(t, e)) return !1;
|
|
2791
2803
|
t.navigator.epubReadingSystem && (t.navigator.epubReadingSystem.layoutStyle = "paginated");
|
|
2792
2804
|
const i = t.document.createElement("style");
|
|
2793
|
-
i.dataset.readium = "true", i.id =
|
|
2805
|
+
i.dataset.readium = "true", i.id = ve, i.textContent = `
|
|
2794
2806
|
@keyframes readium-bounce-l-animation {
|
|
2795
2807
|
0%, 100% {transform: translate3d(0, 0, 0);}
|
|
2796
2808
|
50% {transform: translate3d(-50px, 0, 0);}
|
|
@@ -2826,112 +2838,114 @@ const ue = "readium-column-snapper-style", pi = 200, P = class P extends st {
|
|
|
2826
2838
|
}
|
|
2827
2839
|
`, t.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
|
|
2828
2840
|
t.requestAnimationFrame(() => {
|
|
2829
|
-
t &&
|
|
2841
|
+
t && be(t);
|
|
2830
2842
|
}), this.onWidthChange();
|
|
2831
|
-
}), this.resizeObserver.observe(t.document.body), this.mutationObserver = new MutationObserver((
|
|
2832
|
-
for (const
|
|
2833
|
-
if (
|
|
2834
|
-
const
|
|
2835
|
-
(!
|
|
2836
|
-
t &&
|
|
2843
|
+
}), this.resizeObserver.observe(t.document.body), this.mutationObserver = new MutationObserver((o) => {
|
|
2844
|
+
for (const a of o)
|
|
2845
|
+
if (a.target === this.wnd.document.documentElement) {
|
|
2846
|
+
const c = a.oldValue, d = a.target.getAttribute("style"), u = /transform\s*:\s*([^;]+)/, g = c?.match(u), p = d?.match(u);
|
|
2847
|
+
(!g && !p || g && !p || g && p && g[1] !== p[1]) && (t.requestAnimationFrame(() => {
|
|
2848
|
+
t && be(t);
|
|
2837
2849
|
}), this.onWidthChange());
|
|
2838
2850
|
} else
|
|
2839
2851
|
t.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth);
|
|
2840
|
-
}), 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",
|
|
2841
|
-
this.enableSnapProtection(),
|
|
2852
|
+
}), 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", T.moduleName, (o, a) => {
|
|
2853
|
+
this.enableSnapProtection(), a(!0);
|
|
2842
2854
|
});
|
|
2843
|
-
const s = (
|
|
2844
|
-
const
|
|
2845
|
-
return this.doc().scrollLeft = this.snapOffset(
|
|
2855
|
+
const s = (o) => {
|
|
2856
|
+
const a = this.doc().scrollLeft;
|
|
2857
|
+
return this.doc().scrollLeft = this.snapOffset(o), a !== this.doc().scrollLeft;
|
|
2858
|
+
}, n = (o) => {
|
|
2859
|
+
const a = this.doc().scrollLeft, c = this.snapNormOffset(Math.max(0, Math.min(this.cachedScrollWidth - t.innerWidth, o)));
|
|
2860
|
+
return this.doc().scrollLeft = -c, a !== this.doc().scrollLeft;
|
|
2846
2861
|
};
|
|
2847
|
-
return t.addEventListener("orientationchange", this.onWidthChanger), t.addEventListener("resize", this.onWidthChanger), t.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), e.register("go_progression",
|
|
2848
|
-
const
|
|
2849
|
-
if (
|
|
2862
|
+
return t.addEventListener("orientationchange", this.onWidthChanger), t.addEventListener("resize", this.onWidthChanger), t.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), e.register("go_progression", T.moduleName, (o, a) => {
|
|
2863
|
+
const c = o;
|
|
2864
|
+
if (c < 0 || c > 1) {
|
|
2850
2865
|
e.send("error", {
|
|
2851
2866
|
message: "go_progression must be given a position from 0.0 to 1.0"
|
|
2852
|
-
}),
|
|
2867
|
+
}), a(!1);
|
|
2853
2868
|
return;
|
|
2854
2869
|
}
|
|
2855
2870
|
this.wnd.requestAnimationFrame(() => {
|
|
2856
2871
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2857
|
-
const
|
|
2858
|
-
this.doc().scrollLeft = this.snapOffset(u), this.reportProgress(), A(this.wnd),
|
|
2872
|
+
const u = (this.cachedScrollWidth - t.innerWidth) * c;
|
|
2873
|
+
I(t) ? this.doc().scrollLeft = -this.snapNormOffset(u) : this.doc().scrollLeft = this.snapOffset(u), this.reportProgress(), A(this.wnd), a(!0);
|
|
2859
2874
|
});
|
|
2860
|
-
}), e.register("go_id",
|
|
2861
|
-
const
|
|
2862
|
-
if (!
|
|
2863
|
-
|
|
2875
|
+
}), e.register("go_id", T.moduleName, (o, a) => {
|
|
2876
|
+
const c = t.document.getElementById(o);
|
|
2877
|
+
if (!c) {
|
|
2878
|
+
a(!1);
|
|
2864
2879
|
return;
|
|
2865
2880
|
}
|
|
2866
2881
|
this.wnd.requestAnimationFrame(() => {
|
|
2867
|
-
this.doc().scrollLeft = this.snapOffset(
|
|
2882
|
+
I(t) ? this.doc().scrollLeft = -this.snapNormOffset(c.getBoundingClientRect().left + t.scrollX) : this.doc().scrollLeft = this.snapOffset(c.getBoundingClientRect().left + t.scrollX), this.reportProgress(), A(this.wnd), a(!0);
|
|
2868
2883
|
});
|
|
2869
|
-
}), e.register("go_text",
|
|
2870
|
-
let
|
|
2871
|
-
Array.isArray(
|
|
2872
|
-
const d =
|
|
2884
|
+
}), e.register("go_text", T.moduleName, (o, a) => {
|
|
2885
|
+
let c;
|
|
2886
|
+
Array.isArray(o) && (o.length > 1 && (c = o[1]), o = o[0]);
|
|
2887
|
+
const d = _.deserialize(o), u = rt(this.wnd.document, new W({
|
|
2873
2888
|
href: t.location.href,
|
|
2874
2889
|
type: "text/html",
|
|
2875
2890
|
text: d,
|
|
2876
|
-
locations:
|
|
2891
|
+
locations: c ? new C({
|
|
2877
2892
|
otherLocations: /* @__PURE__ */ new Map([
|
|
2878
|
-
["cssSelector",
|
|
2893
|
+
["cssSelector", c]
|
|
2879
2894
|
])
|
|
2880
2895
|
}) : void 0
|
|
2881
2896
|
}));
|
|
2882
|
-
if (!
|
|
2883
|
-
|
|
2897
|
+
if (!u) {
|
|
2898
|
+
a(!1);
|
|
2884
2899
|
return;
|
|
2885
2900
|
}
|
|
2886
2901
|
this.wnd.requestAnimationFrame(() => {
|
|
2887
|
-
this.doc().scrollLeft = this.snapOffset(
|
|
2902
|
+
I(t) ? this.doc().scrollLeft = -this.snapNormOffset(u.getBoundingClientRect().left + t.scrollX) : this.doc().scrollLeft = this.snapOffset(u.getBoundingClientRect().left + t.scrollX), this.reportProgress(), A(this.wnd), a(!0);
|
|
2888
2903
|
});
|
|
2889
|
-
}), e.register("go_end",
|
|
2890
|
-
const a = B(t) ? -1 : 1;
|
|
2904
|
+
}), e.register("go_end", T.moduleName, (o, a) => {
|
|
2891
2905
|
this.wnd.requestAnimationFrame(() => {
|
|
2892
2906
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2893
|
-
|
|
2894
|
-
if (this.doc().scrollLeft ===
|
|
2895
|
-
this.doc().scrollLeft =
|
|
2907
|
+
let c;
|
|
2908
|
+
if (I(t) ? c = -this.snapNormOffset(this.cachedScrollWidth - t.innerWidth) : c = this.snapOffset(this.cachedScrollWidth), this.doc().scrollLeft === c) return a(!1);
|
|
2909
|
+
this.doc().scrollLeft = c, this.reportProgress(), A(this.wnd), a(!0);
|
|
2896
2910
|
});
|
|
2897
|
-
}), e.register("go_start",
|
|
2911
|
+
}), e.register("go_start", T.moduleName, (o, a) => {
|
|
2898
2912
|
this.wnd.requestAnimationFrame(() => {
|
|
2899
|
-
if (this.doc().scrollLeft === 0) return
|
|
2900
|
-
this.doc().scrollLeft = 0, this.reportProgress(), A(this.wnd),
|
|
2913
|
+
if (this.doc().scrollLeft === 0) return a(!1);
|
|
2914
|
+
this.doc().scrollLeft = 0, this.reportProgress(), A(this.wnd), a(!0);
|
|
2901
2915
|
});
|
|
2902
|
-
}), e.register("go_prev",
|
|
2916
|
+
}), e.register("go_prev", T.moduleName, (o, a) => {
|
|
2903
2917
|
this.wnd.requestAnimationFrame(() => {
|
|
2904
2918
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2905
|
-
|
|
2906
|
-
|
|
2919
|
+
let c;
|
|
2920
|
+
I(t) ? c = n(this.normScroll() - t.innerWidth) : c = s(t.scrollX - t.innerWidth), this.reportProgress(), c && (A(this.wnd), this.checkSuspiciousSnap("left", this.wnd.innerWidth)), a(c);
|
|
2907
2921
|
});
|
|
2908
|
-
}), e.register("go_next",
|
|
2922
|
+
}), e.register("go_next", T.moduleName, (o, a) => {
|
|
2909
2923
|
this.wnd.requestAnimationFrame(() => {
|
|
2910
2924
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2911
|
-
|
|
2912
|
-
|
|
2925
|
+
let c;
|
|
2926
|
+
I(t) ? c = n(this.normScroll() + t.innerWidth) : c = s(t.scrollX + t.innerWidth), this.reportProgress(), c && (A(this.wnd), this.checkSuspiciousSnap("right", this.wnd.innerWidth)), a(c);
|
|
2913
2927
|
});
|
|
2914
|
-
}), e.register("unfocus",
|
|
2915
|
-
this.snappingCancelled = !0, A(this.wnd),
|
|
2916
|
-
}), e.register("shake",
|
|
2917
|
-
this.shake(),
|
|
2918
|
-
}), e.register("focus",
|
|
2928
|
+
}), e.register("unfocus", T.moduleName, (o, a) => {
|
|
2929
|
+
this.snappingCancelled = !0, A(this.wnd), a(!0);
|
|
2930
|
+
}), e.register("shake", T.moduleName, (o, a) => {
|
|
2931
|
+
this.shake(), a(!0);
|
|
2932
|
+
}), e.register("focus", T.moduleName, (o, a) => {
|
|
2919
2933
|
this.wnd.requestAnimationFrame(() => {
|
|
2920
|
-
this.cachedScrollWidth = this.doc().scrollWidth, this.snapCurrentOffset(!1, !0), this.reportProgress(),
|
|
2934
|
+
this.cachedScrollWidth = this.doc().scrollWidth, this.snapCurrentOffset(!1, !0), this.reportProgress(), a(!0);
|
|
2921
2935
|
});
|
|
2922
|
-
}), e.register("first_visible_locator",
|
|
2923
|
-
const
|
|
2924
|
-
this.comms.send("first_visible_locator",
|
|
2936
|
+
}), e.register("first_visible_locator", T.moduleName, (o, a) => {
|
|
2937
|
+
const c = vt(t, !1);
|
|
2938
|
+
this.comms.send("first_visible_locator", c.serialize()), a(!0);
|
|
2925
2939
|
}), 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", () => {
|
|
2926
2940
|
}), e.log("ColumnSnapper Mounted"), !0;
|
|
2927
2941
|
}
|
|
2928
2942
|
unmount(t, e) {
|
|
2929
|
-
return this.snappingCancelled = !0, e.unregisterAll(
|
|
2943
|
+
return this.snappingCancelled = !0, e.unregisterAll(T.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(ve)?.remove(), e.log("ColumnSnapper Unmounted"), super.unmount(t, e);
|
|
2930
2944
|
}
|
|
2931
2945
|
};
|
|
2932
|
-
|
|
2933
|
-
let
|
|
2934
|
-
const
|
|
2946
|
+
T.moduleName = "column_snapper";
|
|
2947
|
+
let Lt = T;
|
|
2948
|
+
const we = "readium-scroll-snapper-style", P = class P extends K {
|
|
2935
2949
|
constructor() {
|
|
2936
2950
|
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) => {
|
|
2937
2951
|
if (this.comms.ready && !this.isResizing) {
|
|
@@ -2977,12 +2991,12 @@ const pe = "readium-scroll-snapper-style", N = class N extends st {
|
|
|
2977
2991
|
});
|
|
2978
2992
|
}
|
|
2979
2993
|
enableScrollProtection() {
|
|
2980
|
-
this.patternAnalyzer || (this.patternAnalyzer = new
|
|
2994
|
+
this.patternAnalyzer || (this.patternAnalyzer = new wt(Yt), this.isScrollProtectionEnabled = !0, this.comms?.log("Scroll protection enabled"));
|
|
2981
2995
|
}
|
|
2982
2996
|
mount(t, e) {
|
|
2983
2997
|
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");
|
|
2984
2998
|
const i = t.document.createElement("style");
|
|
2985
|
-
return i.dataset.readium = "true", i.id =
|
|
2999
|
+
return i.dataset.readium = "true", i.id = we, i.textContent = `
|
|
2986
3000
|
* {
|
|
2987
3001
|
scrollbar-width: none; /* for Firefox */
|
|
2988
3002
|
}
|
|
@@ -2994,11 +3008,11 @@ const pe = "readium-scroll-snapper-style", N = class N extends st {
|
|
|
2994
3008
|
this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {
|
|
2995
3009
|
this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();
|
|
2996
3010
|
}, 50);
|
|
2997
|
-
}), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc",
|
|
2998
|
-
|
|
3011
|
+
}), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc", P.moduleName, () => {
|
|
3012
|
+
$t(this.wnd);
|
|
2999
3013
|
const s = this.doc().scrollTop;
|
|
3000
3014
|
s > 1 ? this.doc().scrollTop = s - 1 : this.doc().scrollTop = s + 1, this.doc().scrollTop = s;
|
|
3001
|
-
}), e.register("go_progression",
|
|
3015
|
+
}), e.register("go_progression", P.moduleName, (s, n) => {
|
|
3002
3016
|
const o = s;
|
|
3003
3017
|
if (o < 0 || o > 1) {
|
|
3004
3018
|
e.send("error", {
|
|
@@ -3009,7 +3023,7 @@ const pe = "readium-scroll-snapper-style", N = class N extends st {
|
|
|
3009
3023
|
this.wnd.requestAnimationFrame(() => {
|
|
3010
3024
|
this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(), A(this.wnd), n(!0);
|
|
3011
3025
|
});
|
|
3012
|
-
}), e.register("go_id",
|
|
3026
|
+
}), e.register("go_id", P.moduleName, (s, n) => {
|
|
3013
3027
|
const o = t.document.getElementById(s);
|
|
3014
3028
|
if (!o) {
|
|
3015
3029
|
n(!1);
|
|
@@ -3018,10 +3032,10 @@ const pe = "readium-scroll-snapper-style", N = class N extends st {
|
|
|
3018
3032
|
this.wnd.requestAnimationFrame(() => {
|
|
3019
3033
|
this.doc().scrollTop = o.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd), n(!0);
|
|
3020
3034
|
});
|
|
3021
|
-
}), e.register("go_text",
|
|
3035
|
+
}), e.register("go_text", P.moduleName, (s, n) => {
|
|
3022
3036
|
let o;
|
|
3023
3037
|
Array.isArray(s) && (s.length > 1 && (o = s[1]), s = s[0]);
|
|
3024
|
-
const a =
|
|
3038
|
+
const a = _.deserialize(s), c = rt(this.wnd.document, new W({
|
|
3025
3039
|
href: t.location.href,
|
|
3026
3040
|
type: "text/html",
|
|
3027
3041
|
text: a,
|
|
@@ -3031,40 +3045,40 @@ const pe = "readium-scroll-snapper-style", N = class N extends st {
|
|
|
3031
3045
|
])
|
|
3032
3046
|
}) : void 0
|
|
3033
3047
|
}));
|
|
3034
|
-
if (!
|
|
3048
|
+
if (!c) {
|
|
3035
3049
|
n(!1);
|
|
3036
3050
|
return;
|
|
3037
3051
|
}
|
|
3038
3052
|
this.wnd.requestAnimationFrame(() => {
|
|
3039
|
-
this.doc().scrollTop =
|
|
3053
|
+
this.doc().scrollTop = c.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd), n(!0);
|
|
3040
3054
|
});
|
|
3041
|
-
}), e.register("go_start",
|
|
3055
|
+
}), e.register("go_start", P.moduleName, (s, n) => {
|
|
3042
3056
|
if (this.doc().scrollTop === 0) return n(!1);
|
|
3043
3057
|
this.doc().scrollTop = 0, this.reportProgress(), n(!0);
|
|
3044
|
-
}), e.register("go_end",
|
|
3058
|
+
}), e.register("go_end", P.moduleName, (s, n) => {
|
|
3045
3059
|
if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return n(!1);
|
|
3046
3060
|
this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), n(!0);
|
|
3047
|
-
}), e.register("unfocus",
|
|
3061
|
+
}), e.register("unfocus", P.moduleName, (s, n) => {
|
|
3048
3062
|
A(this.wnd), n(!0);
|
|
3049
|
-
}), e.register("scroll_protection",
|
|
3063
|
+
}), e.register("scroll_protection", P.moduleName, (s, n) => {
|
|
3050
3064
|
this.enableScrollProtection(), n(!0);
|
|
3051
3065
|
}), e.register([
|
|
3052
3066
|
"go_next",
|
|
3053
3067
|
"go_prev"
|
|
3054
|
-
],
|
|
3068
|
+
], P.moduleName, (s, n) => n(!1)), e.register("focus", P.moduleName, (s, n) => {
|
|
3055
3069
|
this.reportProgress(), n(!0);
|
|
3056
|
-
}), e.register("first_visible_locator",
|
|
3057
|
-
const o =
|
|
3070
|
+
}), e.register("first_visible_locator", P.moduleName, (s, n) => {
|
|
3071
|
+
const o = vt(t, !0);
|
|
3058
3072
|
this.comms.send("first_visible_locator", o.serialize()), n(!0);
|
|
3059
3073
|
}), e.log("ScrollSnapper Mounted"), !0;
|
|
3060
3074
|
}
|
|
3061
3075
|
unmount(t, e) {
|
|
3062
|
-
return e.unregisterAll(
|
|
3076
|
+
return e.unregisterAll(P.moduleName), this.resizeObserver.disconnect(), this.handleScroll && t.removeEventListener("scroll", this.handleScroll), t.document.getElementById(we)?.remove(), this.patternAnalyzer && (this.patternAnalyzer.clear(), this.patternAnalyzer = null, this.isScrollProtectionEnabled = !1), e.log("ScrollSnapper Unmounted"), !0;
|
|
3063
3077
|
}
|
|
3064
3078
|
};
|
|
3065
|
-
|
|
3066
|
-
let
|
|
3067
|
-
const
|
|
3079
|
+
P.moduleName = "scroll_snapper";
|
|
3080
|
+
let Ot = P;
|
|
3081
|
+
const N = class N extends K {
|
|
3068
3082
|
constructor() {
|
|
3069
3083
|
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) => {
|
|
3070
3084
|
if (this.comms.ready && !this.isResizing) {
|
|
@@ -3110,18 +3124,18 @@ const L = class L extends st {
|
|
|
3110
3124
|
});
|
|
3111
3125
|
}
|
|
3112
3126
|
enableScrollProtection() {
|
|
3113
|
-
this.patternAnalyzer || (this.patternAnalyzer = new
|
|
3127
|
+
this.patternAnalyzer || (this.patternAnalyzer = new wt(Yt), this.isScrollProtectionEnabled = !0, this.comms?.log("Scroll protection enabled"));
|
|
3114
3128
|
}
|
|
3115
3129
|
mount(t, e) {
|
|
3116
3130
|
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(() => {
|
|
3117
3131
|
this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {
|
|
3118
3132
|
this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();
|
|
3119
3133
|
}, 50);
|
|
3120
|
-
}), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc",
|
|
3121
|
-
|
|
3134
|
+
}), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc", N.moduleName, () => {
|
|
3135
|
+
$t(this.wnd);
|
|
3122
3136
|
const i = this.doc().scrollTop;
|
|
3123
3137
|
i > 1 ? this.doc().scrollTop = i - 1 : this.doc().scrollTop = i + 1, this.doc().scrollTop = i;
|
|
3124
|
-
}), e.register("go_progression",
|
|
3138
|
+
}), e.register("go_progression", N.moduleName, (i, s) => {
|
|
3125
3139
|
const n = i;
|
|
3126
3140
|
if (n < 0 || n > 1) {
|
|
3127
3141
|
e.send("error", {
|
|
@@ -3132,7 +3146,7 @@ const L = class L extends st {
|
|
|
3132
3146
|
this.wnd.requestAnimationFrame(() => {
|
|
3133
3147
|
this.doc().scrollTop = this.doc().offsetHeight * n, this.reportProgress(), A(this.wnd), s(!0);
|
|
3134
3148
|
});
|
|
3135
|
-
}), e.register("go_id",
|
|
3149
|
+
}), e.register("go_id", N.moduleName, (i, s) => {
|
|
3136
3150
|
const n = t.document.getElementById(i);
|
|
3137
3151
|
if (!n) {
|
|
3138
3152
|
s(!1);
|
|
@@ -3141,10 +3155,10 @@ const L = class L extends st {
|
|
|
3141
3155
|
this.wnd.requestAnimationFrame(() => {
|
|
3142
3156
|
this.doc().scrollTop = n.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd), s(!0);
|
|
3143
3157
|
});
|
|
3144
|
-
}), e.register("go_text",
|
|
3158
|
+
}), e.register("go_text", N.moduleName, (i, s) => {
|
|
3145
3159
|
let n;
|
|
3146
3160
|
Array.isArray(i) && (i.length > 1 && (n = i[1]), i = i[0]);
|
|
3147
|
-
const o =
|
|
3161
|
+
const o = _.deserialize(i), a = rt(this.wnd.document, new W({
|
|
3148
3162
|
href: t.location.href,
|
|
3149
3163
|
type: "text/html",
|
|
3150
3164
|
text: o,
|
|
@@ -3161,33 +3175,33 @@ const L = class L extends st {
|
|
|
3161
3175
|
this.wnd.requestAnimationFrame(() => {
|
|
3162
3176
|
this.doc().scrollTop = a.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd), s(!0);
|
|
3163
3177
|
});
|
|
3164
|
-
}), e.register("go_start",
|
|
3178
|
+
}), e.register("go_start", N.moduleName, (i, s) => {
|
|
3165
3179
|
if (this.doc().scrollTop === 0) return s(!1);
|
|
3166
3180
|
this.doc().scrollTop = 0, this.reportProgress(), s(!0);
|
|
3167
|
-
}), e.register("go_end",
|
|
3181
|
+
}), e.register("go_end", N.moduleName, (i, s) => {
|
|
3168
3182
|
if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return s(!1);
|
|
3169
3183
|
this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), s(!0);
|
|
3170
|
-
}), e.register("unfocus",
|
|
3184
|
+
}), e.register("unfocus", N.moduleName, (i, s) => {
|
|
3171
3185
|
A(this.wnd), s(!0);
|
|
3172
|
-
}), e.register("scroll_protection",
|
|
3186
|
+
}), e.register("scroll_protection", N.moduleName, (i, s) => {
|
|
3173
3187
|
this.enableScrollProtection(), s(!0);
|
|
3174
3188
|
}), e.register([
|
|
3175
3189
|
"go_next",
|
|
3176
3190
|
"go_prev"
|
|
3177
|
-
],
|
|
3191
|
+
], N.moduleName, (i, s) => s(!1)), e.register("focus", N.moduleName, (i, s) => {
|
|
3178
3192
|
this.reportProgress(), s(!0);
|
|
3179
|
-
}), e.register("first_visible_locator",
|
|
3180
|
-
const n =
|
|
3193
|
+
}), e.register("first_visible_locator", N.moduleName, (i, s) => {
|
|
3194
|
+
const n = vt(t, !0);
|
|
3181
3195
|
e.send("first_visible_locator", n.serialize()), s(!0);
|
|
3182
3196
|
}), e.log("WebPubSnapper Mounted"), !0;
|
|
3183
3197
|
}
|
|
3184
3198
|
unmount(t, e) {
|
|
3185
|
-
return e.unregisterAll(
|
|
3199
|
+
return e.unregisterAll(N.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;
|
|
3186
3200
|
}
|
|
3187
3201
|
};
|
|
3188
|
-
|
|
3189
|
-
let
|
|
3190
|
-
class
|
|
3202
|
+
N.moduleName = "webpub_snapper";
|
|
3203
|
+
let Rt = N;
|
|
3204
|
+
class wi {
|
|
3191
3205
|
constructor(t, e) {
|
|
3192
3206
|
this.window = t, this.copyHistory = [], this.lastSelectionLength = 0, this.lastSelectionTime = 0, this.options = e;
|
|
3193
3207
|
}
|
|
@@ -3213,10 +3227,10 @@ class mi {
|
|
|
3213
3227
|
length: s,
|
|
3214
3228
|
wasBlocked: !1
|
|
3215
3229
|
}), !0;
|
|
3216
|
-
const
|
|
3230
|
+
const c = o - this.lastSelectionTime < 100 && s > this.lastSelectionLength * 1.5, d = Math.min(
|
|
3217
3231
|
n * this.options.maxSelectionPercent,
|
|
3218
3232
|
this.options.absoluteMaxChars
|
|
3219
|
-
), u = this.isSuspiciousPattern(o), g = s >
|
|
3233
|
+
), u = this.isSuspiciousPattern(o), g = s > d || c || u;
|
|
3220
3234
|
return this.copyHistory.push({
|
|
3221
3235
|
timestamp: o,
|
|
3222
3236
|
length: s,
|
|
@@ -3227,8 +3241,8 @@ class mi {
|
|
|
3227
3241
|
this.lastSelectionLength = 0, this.lastSelectionTime = 0, this.copyHistory = [], this.options.enabled = !1;
|
|
3228
3242
|
}
|
|
3229
3243
|
}
|
|
3230
|
-
class
|
|
3231
|
-
constructor(t =
|
|
3244
|
+
class Si {
|
|
3245
|
+
constructor(t = We) {
|
|
3232
3246
|
this.options = t, this.events = [], this.selectionStartTime = 0, this.lastSelectionTime = 0, this.lastSelectionPosition = 0, this.selectionPatterns = [], this.lastSelectedText = "";
|
|
3233
3247
|
}
|
|
3234
3248
|
analyze(t) {
|
|
@@ -3254,8 +3268,8 @@ class fi {
|
|
|
3254
3268
|
if (!t.rangeCount) return !1;
|
|
3255
3269
|
const i = t.getRangeAt(0), s = i.toString(), n = (e - this.selectionStartTime) / 1e3;
|
|
3256
3270
|
if (s.length / Math.max(1, n) > this.options.maxSelectionsPerSecond) return !0;
|
|
3257
|
-
const a = i.startOffset,
|
|
3258
|
-
return this.selectionPatterns.push(
|
|
3271
|
+
const a = i.startOffset, c = Math.abs(a - this.lastSelectionPosition);
|
|
3272
|
+
return this.selectionPatterns.push(c), this.selectionPatterns.length > this.options.historySize && (this.selectionPatterns.shift(), this.calculateVariance(this.selectionPatterns) < this.options.minVariance) ? !0 : (this.lastSelectionPosition = a, !1);
|
|
3259
3273
|
}
|
|
3260
3274
|
calculateVariance(t) {
|
|
3261
3275
|
if (t.length === 0) return 0;
|
|
@@ -3269,14 +3283,14 @@ class fi {
|
|
|
3269
3283
|
this.events = [], this.selectionStartTime = 0, this.lastSelectionTime = 0, this.lastSelectionPosition = 0, this.selectionPatterns = [], this.lastSelectedText = "";
|
|
3270
3284
|
}
|
|
3271
3285
|
}
|
|
3272
|
-
class
|
|
3286
|
+
class Ei {
|
|
3273
3287
|
/**
|
|
3274
3288
|
* Checks if the given keyboard event matches any of the provided key combinations
|
|
3275
3289
|
*/
|
|
3276
3290
|
match(t, e) {
|
|
3277
3291
|
for (const i of e) {
|
|
3278
|
-
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,
|
|
3279
|
-
if (s && n && o && a &&
|
|
3292
|
+
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, c = i.meta === void 0 || t.metaKey === i.meta;
|
|
3293
|
+
if (s && n && o && a && c)
|
|
3280
3294
|
return !0;
|
|
3281
3295
|
}
|
|
3282
3296
|
return !1;
|
|
@@ -3295,13 +3309,13 @@ class gi {
|
|
|
3295
3309
|
createActivityEvent(t, e, i, s) {
|
|
3296
3310
|
let n;
|
|
3297
3311
|
if (s) {
|
|
3298
|
-
const o = s.getSelection(), a = o?.toString() || "",
|
|
3299
|
-
|
|
3312
|
+
const o = s.getSelection(), a = o?.toString() || "", d = (a && o?.rangeCount ? o.getRangeAt(0)?.getClientRects() : null)?.[0];
|
|
3313
|
+
d && a && (n = {
|
|
3300
3314
|
text: a,
|
|
3301
|
-
x:
|
|
3302
|
-
y:
|
|
3303
|
-
width:
|
|
3304
|
-
height:
|
|
3315
|
+
x: d.x,
|
|
3316
|
+
y: d.y,
|
|
3317
|
+
width: d.width,
|
|
3318
|
+
height: d.height
|
|
3305
3319
|
});
|
|
3306
3320
|
}
|
|
3307
3321
|
return {
|
|
@@ -3326,8 +3340,8 @@ class gi {
|
|
|
3326
3340
|
return e.forEach((o) => {
|
|
3327
3341
|
n.push(...o.keyCombos.map((a) => ({
|
|
3328
3342
|
...a,
|
|
3329
|
-
handler: (
|
|
3330
|
-
const
|
|
3343
|
+
handler: (c) => {
|
|
3344
|
+
const d = o.type, u = this.createActivityEvent(c, d, t, s);
|
|
3331
3345
|
i(u);
|
|
3332
3346
|
}
|
|
3333
3347
|
})));
|
|
@@ -3347,9 +3361,9 @@ class gi {
|
|
|
3347
3361
|
};
|
|
3348
3362
|
}
|
|
3349
3363
|
}
|
|
3350
|
-
const
|
|
3364
|
+
const q = class q extends Z {
|
|
3351
3365
|
constructor() {
|
|
3352
|
-
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
|
|
3366
|
+
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 Ei(), this.keyDownHandler = null, this.preventBulkCopy = (t) => {
|
|
3353
3367
|
if (!this.isBulkCopyProtectionEnabled || !this.bulkCopyProtector)
|
|
3354
3368
|
return !0;
|
|
3355
3369
|
if (!this.bulkCopyProtector.shouldAllowCopy(t)) {
|
|
@@ -3377,7 +3391,7 @@ const $ = class $ extends X {
|
|
|
3377
3391
|
const e = this.wnd.getSelection();
|
|
3378
3392
|
if (e) {
|
|
3379
3393
|
if (this.currentSelection = e.toString(), this.selectionAnalyzer.analyze(e) && this.currentSelection) {
|
|
3380
|
-
const s = this.wnd.getSelection(), n = s?.toString() || "", a = (n && s?.rangeCount ? s.getRangeAt(0)?.getClientRects() : null)?.[0],
|
|
3394
|
+
const s = this.wnd.getSelection(), n = s?.toString() || "", a = (n && s?.rangeCount ? s.getRangeAt(0)?.getClientRects() : null)?.[0], c = {
|
|
3381
3395
|
type: "suspicious_selection",
|
|
3382
3396
|
timestamp: Date.now(),
|
|
3383
3397
|
selectionLength: n.length,
|
|
@@ -3391,7 +3405,7 @@ const $ = class $ extends X {
|
|
|
3391
3405
|
eventType: t?.type || "selectionchange",
|
|
3392
3406
|
targetFrameSrc: this.wnd.location.href
|
|
3393
3407
|
};
|
|
3394
|
-
this.comms?.send("content_protection",
|
|
3408
|
+
this.comms?.send("content_protection", c);
|
|
3395
3409
|
}
|
|
3396
3410
|
} else
|
|
3397
3411
|
this.currentSelection = null;
|
|
@@ -3472,16 +3486,16 @@ const $ = class $ extends X {
|
|
|
3472
3486
|
}
|
|
3473
3487
|
addBulkCopyProtection(t = {}) {
|
|
3474
3488
|
if (this.isBulkCopyProtectionEnabled || !this.wnd) return;
|
|
3475
|
-
const e =
|
|
3476
|
-
this.bulkCopyProtector = new
|
|
3489
|
+
const e = bi, i = t ? { ...e, ...t } : e;
|
|
3490
|
+
this.bulkCopyProtector = new wi(this.wnd, i), this.wnd.document.addEventListener("copy", this.preventBulkCopy, !0), this.wnd.document.addEventListener("cut", this.preventBulkCopy, !0), this.isBulkCopyProtectionEnabled = !0;
|
|
3477
3491
|
}
|
|
3478
3492
|
removeBulkCopyProtection() {
|
|
3479
3493
|
!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);
|
|
3480
3494
|
}
|
|
3481
3495
|
addSelectionMonitoring(t) {
|
|
3482
3496
|
if (this.isSelectionMonitoringEnabled || !this.wnd) return;
|
|
3483
|
-
const e = t ||
|
|
3484
|
-
this.selectionAnalyzer = new
|
|
3497
|
+
const e = t || We;
|
|
3498
|
+
this.selectionAnalyzer = new Si(e), this.wnd.document.addEventListener("selectionchange", this.handleSelection), this.isSelectionMonitoringEnabled = !0;
|
|
3485
3499
|
}
|
|
3486
3500
|
removeSelectionMonitoring() {
|
|
3487
3501
|
!this.isSelectionMonitoringEnabled || !this.wnd || (this.wnd.document.removeEventListener("selectionchange", this.handleSelection), this.selectionAnalyzer?.clear(), this.selectionAnalyzer = null, this.isSelectionMonitoringEnabled = !1);
|
|
@@ -3514,7 +3528,7 @@ const $ = class $ extends X {
|
|
|
3514
3528
|
y: t.clientY * i,
|
|
3515
3529
|
targetFrameSrc: this.wnd.location.href,
|
|
3516
3530
|
targetElement: t.target.outerHTML,
|
|
3517
|
-
interactiveElement:
|
|
3531
|
+
interactiveElement: Me(t.target)?.outerHTML,
|
|
3518
3532
|
cssSelector: this.wnd._readium_cssSelectorGenerator.getCssSelector(t.target)
|
|
3519
3533
|
}), this.pointerMoved = !1;
|
|
3520
3534
|
}
|
|
@@ -3541,7 +3555,7 @@ const $ = class $ extends X {
|
|
|
3541
3555
|
}
|
|
3542
3556
|
}
|
|
3543
3557
|
registerProtectionHandlers() {
|
|
3544
|
-
this.comms?.register("peripherals_protection",
|
|
3558
|
+
this.comms?.register("peripherals_protection", q.moduleName, (t, e) => {
|
|
3545
3559
|
const i = t;
|
|
3546
3560
|
if (!this.configApplied) {
|
|
3547
3561
|
if (this.configApplied = !0, i.monitorSelection) {
|
|
@@ -3559,7 +3573,7 @@ const $ = class $ extends X {
|
|
|
3559
3573
|
}), 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"));
|
|
3560
3574
|
}
|
|
3561
3575
|
e(!0);
|
|
3562
|
-
}), this.comms?.register("keyboard_peripherals",
|
|
3576
|
+
}), this.comms?.register("keyboard_peripherals", q.moduleName, (t, e) => {
|
|
3563
3577
|
const i = t;
|
|
3564
3578
|
i && i.length > 0 && (this.enableKeyboardPeripherals(i), this.comms?.log(`Keyboard peripherals enabled: ${i.map((s) => s.type).join(", ")}`)), e(!0);
|
|
3565
3579
|
});
|
|
@@ -3568,12 +3582,12 @@ const $ = class $ extends X {
|
|
|
3568
3582
|
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;
|
|
3569
3583
|
}
|
|
3570
3584
|
unmount(t, e) {
|
|
3571
|
-
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(
|
|
3585
|
+
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(q.moduleName), this.configApplied = !1, e.log("Peripherals Unmounted"), !0;
|
|
3572
3586
|
}
|
|
3573
3587
|
};
|
|
3574
|
-
|
|
3575
|
-
let
|
|
3576
|
-
const
|
|
3588
|
+
q.moduleName = "peripherals";
|
|
3589
|
+
let Dt = q;
|
|
3590
|
+
const it = class it extends Z {
|
|
3577
3591
|
constructor() {
|
|
3578
3592
|
super(...arguments), this.mediaPlayingCount = 0, this.allAnimations = /* @__PURE__ */ new Set();
|
|
3579
3593
|
}
|
|
@@ -3623,7 +3637,7 @@ const tt = class tt extends X {
|
|
|
3623
3637
|
), Reflect.defineProperty(t.navigator, "epubReadingSystem", {
|
|
3624
3638
|
value: {
|
|
3625
3639
|
name: "readium-ts-toolkit",
|
|
3626
|
-
version: "2.
|
|
3640
|
+
version: "2.4.0-beta.1",
|
|
3627
3641
|
hasFeature: (s, n = "") => {
|
|
3628
3642
|
switch (s) {
|
|
3629
3643
|
case "dom-manipulation":
|
|
@@ -3648,11 +3662,11 @@ const tt = class tt extends X {
|
|
|
3648
3662
|
writable: !1
|
|
3649
3663
|
}), "getAnimations" in t.document && t.document.getAnimations().forEach((s) => {
|
|
3650
3664
|
s.cancel(), this.allAnimations.add(s);
|
|
3651
|
-
}), e.register("activate",
|
|
3665
|
+
}), e.register("activate", it.moduleName, (s, n) => {
|
|
3652
3666
|
this.allAnimations.forEach((o) => {
|
|
3653
3667
|
o.cancel(), o.play();
|
|
3654
3668
|
}), n(!0);
|
|
3655
|
-
}), e.register("unfocus",
|
|
3669
|
+
}), e.register("unfocus", it.moduleName, (s, n) => {
|
|
3656
3670
|
this.pauseAllMedia(t), this.allAnimations.forEach((o) => o.pause()), n(!0);
|
|
3657
3671
|
});
|
|
3658
3672
|
const i = t.document.querySelectorAll("audio,video");
|
|
@@ -3670,46 +3684,46 @@ const tt = class tt extends X {
|
|
|
3670
3684
|
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;
|
|
3671
3685
|
}
|
|
3672
3686
|
};
|
|
3673
|
-
|
|
3674
|
-
let
|
|
3675
|
-
const
|
|
3687
|
+
it.moduleName = "setup";
|
|
3688
|
+
let yt = it;
|
|
3689
|
+
const Se = "readium-viewport", U = class U extends yt {
|
|
3676
3690
|
onViewportWidthChanged(t) {
|
|
3677
3691
|
const e = t.target;
|
|
3678
|
-
|
|
3692
|
+
nt(e, "--RS__viewportWidth", `${e.innerWidth}px`);
|
|
3679
3693
|
}
|
|
3680
3694
|
mount(t, e) {
|
|
3681
3695
|
if (!super.mount(t, e)) return !1;
|
|
3682
3696
|
const i = t.document.createElement("meta");
|
|
3683
|
-
return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id",
|
|
3697
|
+
return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id", Se), i.setAttribute(
|
|
3684
3698
|
"content",
|
|
3685
3699
|
"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"
|
|
3686
3700
|
), t.document.head.appendChild(i), t.addEventListener("orientationchange", this.onViewportWidthChanged), t.addEventListener("resize", this.onViewportWidthChanged), this.onViewportWidthChanged({
|
|
3687
3701
|
target: t
|
|
3688
|
-
}), e.register("get_properties",
|
|
3689
|
-
|
|
3690
|
-
}), e.register("update_properties",
|
|
3691
|
-
s["--RS__viewportWidth"] = `${t.innerWidth}px`,
|
|
3692
|
-
}), e.register("set_property",
|
|
3702
|
+
}), e.register("get_properties", U.moduleName, (s, n) => {
|
|
3703
|
+
Gt(t), n(!0);
|
|
3704
|
+
}), e.register("update_properties", U.moduleName, (s, n) => {
|
|
3705
|
+
s["--RS__viewportWidth"] = `${t.innerWidth}px`, Ie(t, s), n(!0);
|
|
3706
|
+
}), e.register("set_property", U.moduleName, (s, n) => {
|
|
3693
3707
|
const o = s;
|
|
3694
|
-
|
|
3695
|
-
}), e.register("remove_property",
|
|
3696
|
-
|
|
3697
|
-
}), e.register("activate",
|
|
3708
|
+
nt(t, o[0], o[1]), n(!0);
|
|
3709
|
+
}), e.register("remove_property", U.moduleName, (s, n) => {
|
|
3710
|
+
bt(t, s), n(!0);
|
|
3711
|
+
}), e.register("activate", U.moduleName, (s, n) => {
|
|
3698
3712
|
this.unblock(t), n(!0);
|
|
3699
3713
|
}), e.log("ReflowableSetup Mounted"), !0;
|
|
3700
3714
|
}
|
|
3701
3715
|
unmount(t, e) {
|
|
3702
|
-
return e.unregisterAll(
|
|
3716
|
+
return e.unregisterAll(U.moduleName), t.document.head.querySelector(`#${Se}`)?.remove(), t.removeEventListener("orientationchange", this.onViewportWidthChanged), e.log("ReflowableSetup Unmounted"), super.unmount(t, e);
|
|
3703
3717
|
}
|
|
3704
3718
|
};
|
|
3705
|
-
|
|
3706
|
-
let
|
|
3707
|
-
const
|
|
3719
|
+
U.moduleName = "reflowable_setup";
|
|
3720
|
+
let It = U;
|
|
3721
|
+
const Ee = "readium-fixed-style", M = class M extends yt {
|
|
3708
3722
|
mount(t, e) {
|
|
3709
3723
|
if (!super.mount(t, e)) return !1;
|
|
3710
3724
|
t.navigator.epubReadingSystem && (t.navigator.epubReadingSystem.layoutStyle = "paginated");
|
|
3711
3725
|
const i = t.document.createElement("style");
|
|
3712
|
-
return i.id =
|
|
3726
|
+
return i.id = Ee, i.dataset.readium = "true", i.textContent = `
|
|
3713
3727
|
html, body {
|
|
3714
3728
|
text-size-adjust: none;
|
|
3715
3729
|
-ms-text-size-adjust: none;
|
|
@@ -3721,12 +3735,12 @@ const fe = "readium-fixed-style", D = class D extends ut {
|
|
|
3721
3735
|
min-height: 100%;
|
|
3722
3736
|
|
|
3723
3737
|
/*cursor: var() TODO*/
|
|
3724
|
-
}`, t.document.head.appendChild(i), e.register("set_property",
|
|
3738
|
+
}`, t.document.head.appendChild(i), e.register("set_property", M.moduleName, (s, n) => {
|
|
3725
3739
|
const o = s;
|
|
3726
|
-
|
|
3727
|
-
}), e.register("remove_property",
|
|
3728
|
-
|
|
3729
|
-
}), e.register("first_visible_locator",
|
|
3740
|
+
nt(t, o[0], o[1]), n(!0);
|
|
3741
|
+
}), e.register("remove_property", M.moduleName, (s, n) => {
|
|
3742
|
+
bt(t, s), n(!0);
|
|
3743
|
+
}), e.register("first_visible_locator", M.moduleName, (s, n) => n(!1)), e.register("unfocus", M.moduleName, (s, n) => {
|
|
3730
3744
|
A(t), n(!0);
|
|
3731
3745
|
}), e.register([
|
|
3732
3746
|
"focus",
|
|
@@ -3737,17 +3751,17 @@ const fe = "readium-fixed-style", D = class D extends ut {
|
|
|
3737
3751
|
"go_start",
|
|
3738
3752
|
"go_text",
|
|
3739
3753
|
"go_progression"
|
|
3740
|
-
],
|
|
3754
|
+
], M.moduleName, (s, n) => n(!0)), e.register("activate", M.moduleName, (s, n) => {
|
|
3741
3755
|
this.unblock(t), n(!0);
|
|
3742
3756
|
}), e.log("FixedSetup Mounted"), !0;
|
|
3743
3757
|
}
|
|
3744
3758
|
unmount(t, e) {
|
|
3745
|
-
return e.unregisterAll(
|
|
3759
|
+
return e.unregisterAll(M.moduleName), t.document.getElementById(Ee)?.remove(), e.log("FixedSetup Unmounted"), super.unmount(t, e);
|
|
3746
3760
|
}
|
|
3747
3761
|
};
|
|
3748
|
-
|
|
3749
|
-
let
|
|
3750
|
-
const
|
|
3762
|
+
M.moduleName = "fixed_setup";
|
|
3763
|
+
let zt = M;
|
|
3764
|
+
const B = class B extends Z {
|
|
3751
3765
|
wndOnErr(t) {
|
|
3752
3766
|
this.comms?.send("error", {
|
|
3753
3767
|
message: t.message,
|
|
@@ -3761,26 +3775,26 @@ const k = class k extends X {
|
|
|
3761
3775
|
"error",
|
|
3762
3776
|
this.wndOnErr,
|
|
3763
3777
|
!1
|
|
3764
|
-
), e.register("get_properties",
|
|
3765
|
-
|
|
3766
|
-
}), e.register("update_properties",
|
|
3767
|
-
|
|
3768
|
-
}), e.register("set_property",
|
|
3778
|
+
), e.register("get_properties", B.moduleName, (i, s) => {
|
|
3779
|
+
Gt(t), s(!0);
|
|
3780
|
+
}), e.register("update_properties", B.moduleName, (i, s) => {
|
|
3781
|
+
Ie(t, i), s(!0);
|
|
3782
|
+
}), e.register("set_property", B.moduleName, (i, s) => {
|
|
3769
3783
|
const n = i;
|
|
3770
|
-
|
|
3771
|
-
}), e.register("remove_property",
|
|
3772
|
-
|
|
3773
|
-
}), e.register("activate",
|
|
3784
|
+
nt(t, n[0], n[1]), s(!0);
|
|
3785
|
+
}), e.register("remove_property", B.moduleName, (i, s) => {
|
|
3786
|
+
bt(t, i), s(!0);
|
|
3787
|
+
}), e.register("activate", B.moduleName, (i, s) => {
|
|
3774
3788
|
s(!0);
|
|
3775
3789
|
}), e.log("WebPubSetup Mounted"), !0;
|
|
3776
3790
|
}
|
|
3777
3791
|
unmount(t, e) {
|
|
3778
|
-
return e.unregisterAll(
|
|
3792
|
+
return e.unregisterAll(B.moduleName), t.removeEventListener("error", this.wndOnErr), e.log("WebPubSetup Unmounted"), !0;
|
|
3779
3793
|
}
|
|
3780
3794
|
};
|
|
3781
|
-
|
|
3782
|
-
let
|
|
3783
|
-
const
|
|
3795
|
+
B.moduleName = "webpub_setup";
|
|
3796
|
+
let Mt = B;
|
|
3797
|
+
const st = class st extends Z {
|
|
3784
3798
|
constructor() {
|
|
3785
3799
|
super(...arguments), this.styleElement = null, this.beforePrintHandler = null, this.configApplied = !1;
|
|
3786
3800
|
}
|
|
@@ -3804,7 +3818,7 @@ const et = class et extends X {
|
|
|
3804
3818
|
`, t.document.head.appendChild(i), this.styleElement = i, this.beforePrintHandler = (s) => (s.preventDefault(), !1), t.addEventListener("beforeprint", this.beforePrintHandler);
|
|
3805
3819
|
}
|
|
3806
3820
|
registerPrintHandlers() {
|
|
3807
|
-
this.comms?.register("print_protection",
|
|
3821
|
+
this.comms?.register("print_protection", st.moduleName, (t) => {
|
|
3808
3822
|
const e = t;
|
|
3809
3823
|
return this.configApplied || (this.configApplied = !0, this.setupPrintProtection(this.wnd, e), this.comms?.log("Print protection configuration applied")), !0;
|
|
3810
3824
|
});
|
|
@@ -3813,48 +3827,190 @@ const et = class et extends X {
|
|
|
3813
3827
|
return this.wnd = t, this.comms = e, this.registerPrintHandlers(), !0;
|
|
3814
3828
|
}
|
|
3815
3829
|
unmount(t, e) {
|
|
3816
|
-
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(
|
|
3830
|
+
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(st.moduleName), this.configApplied = !1, !0;
|
|
3831
|
+
}
|
|
3832
|
+
};
|
|
3833
|
+
st.moduleName = "print_protection";
|
|
3834
|
+
let kt = st;
|
|
3835
|
+
const Ae = "readium-cjk-vertical-snapper-style", L = class L extends K {
|
|
3836
|
+
constructor() {
|
|
3837
|
+
super(...arguments), this.patternAnalyzer = null, this.lastScrollTime = 0, this.isScrollProtectionEnabled = !1, this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollLeft = 0, this.isResizing = !1, this.resizeDebounce = null, this.handleScroll = (t) => {
|
|
3838
|
+
if (this.comms.ready && !this.isResizing) {
|
|
3839
|
+
if (!this.initialScrollHandled) {
|
|
3840
|
+
this.lastScrollLeft = Math.abs(this.doc().scrollLeft), this.initialScrollHandled = !0, this.reportProgress();
|
|
3841
|
+
return;
|
|
3842
|
+
}
|
|
3843
|
+
this.isScrolling || (this.isScrolling = !0, this.wnd.requestAnimationFrame(() => {
|
|
3844
|
+
this.reportProgress();
|
|
3845
|
+
const e = Math.abs(this.doc().scrollLeft), i = e - this.lastScrollLeft;
|
|
3846
|
+
if (this.lastScrollLeft = e, this.isScrollProtectionEnabled && Math.abs(i) > 5) {
|
|
3847
|
+
const s = Date.now(), n = s - (this.lastScrollTime || s);
|
|
3848
|
+
if (this.patternAnalyzer && this.patternAnalyzer.analyze(
|
|
3849
|
+
// In vertical-rl, norm increases when scrolling forward (toward left/end),
|
|
3850
|
+
// so deltaX > 0 = going forward.
|
|
3851
|
+
i > 0 ? "down" : "up",
|
|
3852
|
+
Math.abs(i),
|
|
3853
|
+
n
|
|
3854
|
+
)) {
|
|
3855
|
+
const a = t.target && "tagName" in t.target ? { tagName: t.target.tagName } : null;
|
|
3856
|
+
this.comms?.send("content_protection", {
|
|
3857
|
+
type: "suspicious_scrolling",
|
|
3858
|
+
timestamp: Date.now(),
|
|
3859
|
+
scrollDelta: i,
|
|
3860
|
+
scrollDirection: i > 0 ? "left" : "right",
|
|
3861
|
+
targetElement: a
|
|
3862
|
+
});
|
|
3863
|
+
}
|
|
3864
|
+
this.lastScrollTime = s;
|
|
3865
|
+
}
|
|
3866
|
+
this.comms.send("scroll", i), this.isScrolling = !1;
|
|
3867
|
+
}));
|
|
3868
|
+
}
|
|
3869
|
+
};
|
|
3870
|
+
}
|
|
3871
|
+
doc() {
|
|
3872
|
+
return this.wnd.document.scrollingElement;
|
|
3873
|
+
}
|
|
3874
|
+
/** Total horizontally scrollable distance (magnitude). */
|
|
3875
|
+
scrollable() {
|
|
3876
|
+
return Math.max(0, this.doc().scrollWidth - this.wnd.innerWidth);
|
|
3877
|
+
}
|
|
3878
|
+
reportProgress() {
|
|
3879
|
+
if (!this.comms.ready) return;
|
|
3880
|
+
const t = this.doc().scrollWidth, e = this.wnd.innerWidth, i = Math.max(1, t - e), s = Math.abs(this.doc().scrollLeft), n = Math.max(0, Math.min(1, s / i)), o = Math.max(0, Math.min(1, (s + e) / t));
|
|
3881
|
+
this.comms.send("progress", {
|
|
3882
|
+
start: n,
|
|
3883
|
+
end: o
|
|
3884
|
+
});
|
|
3885
|
+
}
|
|
3886
|
+
enableScrollProtection() {
|
|
3887
|
+
this.patternAnalyzer || (this.patternAnalyzer = new wt(Yt), this.isScrollProtectionEnabled = !0, this.comms?.log("Scroll protection enabled"));
|
|
3888
|
+
}
|
|
3889
|
+
mount(t, e) {
|
|
3890
|
+
this.wnd = t, this.comms = e, this.initialScrollHandled = !1, this.lastScrollLeft = 0, this.isResizing = !1, this.resizeDebounce && (this.wnd.clearTimeout(this.resizeDebounce), this.resizeDebounce = null), t.navigator.epubReadingSystem && (t.navigator.epubReadingSystem.layoutStyle = "scrolling");
|
|
3891
|
+
const i = t.document.createElement("style");
|
|
3892
|
+
return i.dataset.readium = "true", i.id = Ae, i.textContent = `
|
|
3893
|
+
* {
|
|
3894
|
+
scrollbar-width: none;
|
|
3895
|
+
}
|
|
3896
|
+
body::-webkit-scrollbar {
|
|
3897
|
+
display: none;
|
|
3898
|
+
}
|
|
3899
|
+
html {
|
|
3900
|
+
overflow-x: auto !important;
|
|
3901
|
+
overflow-y: hidden !important;
|
|
3902
|
+
}
|
|
3903
|
+
`, t.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
|
|
3904
|
+
this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {
|
|
3905
|
+
this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();
|
|
3906
|
+
}, 50);
|
|
3907
|
+
}), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc", L.moduleName, () => {
|
|
3908
|
+
$t(this.wnd);
|
|
3909
|
+
const s = this.doc().scrollLeft;
|
|
3910
|
+
Math.abs(s) > 1 ? this.doc().scrollLeft = s < 0 ? s + 1 : s - 1 : this.doc().scrollLeft = s < 0 ? s - 1 : s + 1, this.doc().scrollLeft = s;
|
|
3911
|
+
}), e.register("go_progression", L.moduleName, (s, n) => {
|
|
3912
|
+
const o = s;
|
|
3913
|
+
if (o < 0 || o > 1) {
|
|
3914
|
+
e.send("error", {
|
|
3915
|
+
message: "go_progression must be given a position from 0.0 to 1.0"
|
|
3916
|
+
}), n(!1);
|
|
3917
|
+
return;
|
|
3918
|
+
}
|
|
3919
|
+
this.wnd.requestAnimationFrame(() => {
|
|
3920
|
+
this.doc().scrollLeft = -(this.scrollable() * o), this.reportProgress(), A(this.wnd), n(!0);
|
|
3921
|
+
});
|
|
3922
|
+
}), e.register("go_id", L.moduleName, (s, n) => {
|
|
3923
|
+
const o = t.document.getElementById(s);
|
|
3924
|
+
if (!o) {
|
|
3925
|
+
n(!1);
|
|
3926
|
+
return;
|
|
3927
|
+
}
|
|
3928
|
+
this.wnd.requestAnimationFrame(() => {
|
|
3929
|
+
this.doc().scrollLeft += o.getBoundingClientRect().left - t.innerWidth / 2, this.reportProgress(), A(this.wnd), n(!0);
|
|
3930
|
+
});
|
|
3931
|
+
}), e.register("go_text", L.moduleName, (s, n) => {
|
|
3932
|
+
let o;
|
|
3933
|
+
Array.isArray(s) && (s.length > 1 && (o = s[1]), s = s[0]);
|
|
3934
|
+
const a = _.deserialize(s), c = rt(this.wnd.document, new W({
|
|
3935
|
+
href: t.location.href,
|
|
3936
|
+
type: "text/html",
|
|
3937
|
+
text: a,
|
|
3938
|
+
locations: o ? new C({
|
|
3939
|
+
otherLocations: /* @__PURE__ */ new Map([["cssSelector", o]])
|
|
3940
|
+
}) : void 0
|
|
3941
|
+
}));
|
|
3942
|
+
if (!c) {
|
|
3943
|
+
n(!1);
|
|
3944
|
+
return;
|
|
3945
|
+
}
|
|
3946
|
+
this.wnd.requestAnimationFrame(() => {
|
|
3947
|
+
this.doc().scrollLeft += c.getBoundingClientRect().left - t.innerWidth / 2, this.reportProgress(), A(this.wnd), n(!0);
|
|
3948
|
+
});
|
|
3949
|
+
}), e.register("go_start", L.moduleName, (s, n) => {
|
|
3950
|
+
if (this.doc().scrollLeft === 0) return n(!1);
|
|
3951
|
+
this.doc().scrollLeft = 0, this.reportProgress(), n(!0);
|
|
3952
|
+
}), e.register("go_end", L.moduleName, (s, n) => {
|
|
3953
|
+
if (Math.abs(this.doc().scrollLeft) === this.scrollable()) return n(!1);
|
|
3954
|
+
this.doc().scrollLeft = -this.scrollable(), this.reportProgress(), n(!0);
|
|
3955
|
+
}), e.register([
|
|
3956
|
+
"go_next",
|
|
3957
|
+
"go_prev"
|
|
3958
|
+
], L.moduleName, (s, n) => n(!1)), e.register("unfocus", L.moduleName, (s, n) => {
|
|
3959
|
+
A(this.wnd), n(!0);
|
|
3960
|
+
}), e.register("scroll_protection", L.moduleName, (s, n) => {
|
|
3961
|
+
this.enableScrollProtection(), n(!0);
|
|
3962
|
+
}), e.register("focus", L.moduleName, (s, n) => {
|
|
3963
|
+
this.reportProgress(), n(!0);
|
|
3964
|
+
}), e.register("first_visible_locator", L.moduleName, (s, n) => {
|
|
3965
|
+
const o = vt(t, !0);
|
|
3966
|
+
this.comms.send("first_visible_locator", o.serialize()), n(!0);
|
|
3967
|
+
}), e.log("CJKVerticalSnapper Mounted"), !0;
|
|
3968
|
+
}
|
|
3969
|
+
unmount(t, e) {
|
|
3970
|
+
return e.unregisterAll(L.moduleName), this.resizeObserver.disconnect(), this.handleScroll && t.removeEventListener("scroll", this.handleScroll), t.document.getElementById(Ae)?.remove(), this.patternAnalyzer && (this.patternAnalyzer.clear(), this.patternAnalyzer = null, this.isScrollProtectionEnabled = !1), e.log("CJKVerticalSnapper Unmounted"), !0;
|
|
3817
3971
|
}
|
|
3818
3972
|
};
|
|
3819
|
-
|
|
3820
|
-
let
|
|
3821
|
-
const
|
|
3973
|
+
L.moduleName = "cjk_vertical_snapper";
|
|
3974
|
+
let Wt = L;
|
|
3975
|
+
const Ai = [
|
|
3822
3976
|
"fixed_setup",
|
|
3823
3977
|
"decorator",
|
|
3824
3978
|
"peripherals",
|
|
3825
3979
|
"print_protection"
|
|
3826
|
-
],
|
|
3980
|
+
], Ci = [
|
|
3827
3981
|
"reflowable_setup",
|
|
3828
3982
|
"decorator",
|
|
3829
3983
|
"peripherals",
|
|
3830
3984
|
"column_snapper",
|
|
3831
3985
|
"scroll_snapper",
|
|
3986
|
+
"cjk_vertical_snapper",
|
|
3832
3987
|
"print_protection"
|
|
3833
|
-
],
|
|
3988
|
+
], xi = [
|
|
3834
3989
|
"webpub_setup",
|
|
3835
3990
|
"webpub_snapper",
|
|
3836
3991
|
"decorator",
|
|
3837
3992
|
"peripherals",
|
|
3838
3993
|
"print_protection"
|
|
3839
|
-
],
|
|
3994
|
+
], Ce = new Map([
|
|
3840
3995
|
// All modules go here
|
|
3996
|
+
zt,
|
|
3997
|
+
It,
|
|
3998
|
+
Mt,
|
|
3999
|
+
Rt,
|
|
4000
|
+
Dt,
|
|
3841
4001
|
Nt,
|
|
3842
|
-
Pt,
|
|
3843
4002
|
Lt,
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
At,
|
|
3848
|
-
Ct,
|
|
3849
|
-
Ot
|
|
4003
|
+
Ot,
|
|
4004
|
+
Wt,
|
|
4005
|
+
kt
|
|
3850
4006
|
].map((r) => [r.moduleName, r]));
|
|
3851
|
-
class
|
|
4007
|
+
class Ti {
|
|
3852
4008
|
/**
|
|
3853
4009
|
* @param wnd Window instance to operate on
|
|
3854
4010
|
* @param initialModules List of initial modules to load
|
|
3855
4011
|
*/
|
|
3856
4012
|
constructor(t = window, e = []) {
|
|
3857
|
-
this.loadedModules = [], this.wnd = t, this.comms = new
|
|
4013
|
+
this.loadedModules = [], this.wnd = t, this.comms = new He(t);
|
|
3858
4014
|
const i = [...new Set(e)];
|
|
3859
4015
|
if (i.length) {
|
|
3860
4016
|
if (typeof t > "u")
|
|
@@ -3867,7 +4023,7 @@ class wi {
|
|
|
3867
4023
|
}
|
|
3868
4024
|
}
|
|
3869
4025
|
loadModule(t) {
|
|
3870
|
-
const e =
|
|
4026
|
+
const e = Ce.get(t);
|
|
3871
4027
|
return e === void 0 ? (this.comms.log(`Module "${name}" does not exist in the library`), e) : new e();
|
|
3872
4028
|
}
|
|
3873
4029
|
/**
|
|
@@ -3885,7 +4041,7 @@ class wi {
|
|
|
3885
4041
|
* @returns Success
|
|
3886
4042
|
*/
|
|
3887
4043
|
removeModule(t) {
|
|
3888
|
-
const e =
|
|
4044
|
+
const e = Ce.get(t);
|
|
3889
4045
|
if (e === void 0)
|
|
3890
4046
|
return this.comms.log(`Module "${t}" does not exist in the library`), !1;
|
|
3891
4047
|
const i = this.loadedModules.findIndex((s) => s instanceof e);
|
|
@@ -3898,7 +4054,7 @@ class wi {
|
|
|
3898
4054
|
this.comms.destroy(), this.loadedModules.forEach((t) => t.unmount(this.wnd, this.comms)), this.loadedModules = [];
|
|
3899
4055
|
}
|
|
3900
4056
|
}
|
|
3901
|
-
const
|
|
4057
|
+
const Pi = {
|
|
3902
4058
|
type: "developer_tools",
|
|
3903
4059
|
keyCombos: [
|
|
3904
4060
|
{ keyCode: 73, meta: !0, alt: !0 },
|
|
@@ -3922,7 +4078,7 @@ const Ei = {
|
|
|
3922
4078
|
{ keyCode: 123, meta: !0, alt: !0 }
|
|
3923
4079
|
// F12+Meta+Alt
|
|
3924
4080
|
]
|
|
3925
|
-
},
|
|
4081
|
+
}, Ni = {
|
|
3926
4082
|
type: "select_all",
|
|
3927
4083
|
keyCombos: [
|
|
3928
4084
|
{ keyCode: 65, meta: !0 },
|
|
@@ -3930,7 +4086,7 @@ const Ei = {
|
|
|
3930
4086
|
{ keyCode: 65, ctrl: !0 }
|
|
3931
4087
|
// A key (Ctrl+A)
|
|
3932
4088
|
]
|
|
3933
|
-
},
|
|
4089
|
+
}, Li = {
|
|
3934
4090
|
type: "print",
|
|
3935
4091
|
keyCombos: [
|
|
3936
4092
|
{ keyCode: 80, meta: !0 },
|
|
@@ -3946,7 +4102,7 @@ const Ei = {
|
|
|
3946
4102
|
{ keyCode: 80, ctrl: !0, alt: !0 }
|
|
3947
4103
|
// P key (Ctrl+Alt+P)
|
|
3948
4104
|
]
|
|
3949
|
-
},
|
|
4105
|
+
}, Oi = {
|
|
3950
4106
|
type: "save",
|
|
3951
4107
|
keyCombos: [
|
|
3952
4108
|
{ keyCode: 83, meta: !0 },
|
|
@@ -3956,26 +4112,26 @@ const Ei = {
|
|
|
3956
4112
|
]
|
|
3957
4113
|
};
|
|
3958
4114
|
export {
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
4115
|
+
wi as BulkCopyProtector,
|
|
4116
|
+
J as COMMS_VERSION,
|
|
4117
|
+
He as Comms,
|
|
4118
|
+
Pi as DEV_TOOLS,
|
|
4119
|
+
Nt as Decorator,
|
|
4120
|
+
Ai as FXLModules,
|
|
4121
|
+
Ei as KeyCombinationManager,
|
|
4122
|
+
ci as Layout,
|
|
4123
|
+
Ti as Loader,
|
|
4124
|
+
Z as Module,
|
|
4125
|
+
Ce as ModuleLibrary,
|
|
4126
|
+
Li as PRINT,
|
|
4127
|
+
wt as PatternAnalyzer,
|
|
4128
|
+
Dt as Peripherals,
|
|
4129
|
+
kt as PrintProtector,
|
|
4130
|
+
Ci as ReflowableModules,
|
|
4131
|
+
Oi as SAVE,
|
|
4132
|
+
Ni as SELECT_ALL,
|
|
4133
|
+
Si as SelectionAnalyzer,
|
|
4134
|
+
xi as WebPubModules,
|
|
4135
|
+
li as Width,
|
|
4136
|
+
Be as mid
|
|
3981
4137
|
};
|