@readium/navigator-html-injectables 2.3.1-alpha.2 → 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 +852 -701
- package/dist/index.umd.cjs +24 -13
- package/package.json +8 -8
- package/src/Loader.ts +3 -3
- package/src/comms/comms.ts +5 -5
- package/src/comms/index.ts +3 -3
- package/src/helpers/css.ts +2 -4
- package/src/helpers/document.ts +13 -10
- package/src/helpers/locator.ts +2 -2
- package/src/index.ts +4 -4
- package/src/modules/Decorator.ts +18 -18
- package/src/modules/Module.ts +4 -4
- package/src/modules/ModuleLibrary.ts +15 -11
- package/src/modules/Peripherals.ts +70 -61
- package/src/modules/index.ts +4 -4
- package/src/modules/setup/FixedSetup.ts +6 -6
- package/src/modules/setup/ReflowableSetup.ts +6 -6
- package/src/modules/setup/Setup.ts +5 -5
- package/src/modules/setup/WebPubSetup.ts +5 -5
- package/src/modules/snapper/CJKVerticalSnapper.ts +322 -0
- package/src/modules/snapper/ColumnSnapper.ts +161 -99
- package/src/modules/snapper/ScrollSnapper.ts +18 -18
- package/src/modules/snapper/Snapper.ts +5 -5
- package/src/modules/snapper/WebPubSnapper.ts +15 -15
- package/src/protection/BulkCopyProtector.ts +15 -15
- package/src/protection/KeyCombinationManager.ts +8 -8
- package/src/protection/PatternAnalyzer.ts +18 -18
- package/src/protection/PrintProtector.ts +12 -12
- package/src/protection/SelectionAnalyzer.ts +1 -1
- package/src/protection/config.ts +4 -4
- package/src/protection/index.ts +6 -6
- package/src/vendor/hypothesis/anchoring/html.ts +1 -1
- package/src/vendor/hypothesis/anchoring/types.ts +1 -1
- package/types/src/Loader.d.ts +2 -2
- package/types/src/comms/comms.d.ts +2 -2
- package/types/src/comms/index.d.ts +3 -3
- package/types/src/helpers/css.d.ts +1 -2
- package/types/src/helpers/document.d.ts +1 -1
- package/types/src/index.d.ts +4 -4
- package/types/src/modules/Decorator.d.ts +4 -4
- package/types/src/modules/Module.d.ts +3 -3
- package/types/src/modules/ModuleLibrary.d.ts +2 -2
- package/types/src/modules/Peripherals.d.ts +10 -9
- package/types/src/modules/index.d.ts +4 -4
- package/types/src/modules/setup/FixedSetup.d.ts +4 -4
- package/types/src/modules/setup/ReflowableSetup.d.ts +3 -3
- package/types/src/modules/setup/Setup.d.ts +4 -4
- package/types/src/modules/setup/WebPubSetup.d.ts +3 -3
- package/types/src/modules/snapper/CJKVerticalSnapper.d.ts +57 -0
- package/types/src/modules/snapper/ColumnSnapper.d.ts +16 -5
- package/types/src/modules/snapper/ScrollSnapper.d.ts +5 -5
- package/types/src/modules/snapper/Snapper.d.ts +4 -4
- package/types/src/modules/snapper/WebPubSnapper.d.ts +5 -5
- package/types/src/protection/BulkCopyProtector.d.ts +1 -1
- package/types/src/protection/KeyCombinationManager.d.ts +3 -3
- package/types/src/protection/PrintProtector.d.ts +4 -4
- package/types/src/protection/config.d.ts +3 -3
- package/types/src/protection/index.d.ts +6 -6
- package/types/src/vendor/hypothesis/anchoring/html.d.ts +1 -1
- package/types/src/vendor/hypothesis/anchoring/types.d.ts +1 -1
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 Me {
|
|
|
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 Me {
|
|
|
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,8 +126,8 @@ 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
|
|
130
|
-
const
|
|
129
|
+
let Xt = y;
|
|
130
|
+
const w = class w {
|
|
131
131
|
constructor(t) {
|
|
132
132
|
this.value = t;
|
|
133
133
|
}
|
|
@@ -136,7 +136,7 @@ const v = class v {
|
|
|
136
136
|
*/
|
|
137
137
|
static deserialize(t) {
|
|
138
138
|
if (!(!t || typeof t != "string"))
|
|
139
|
-
return new
|
|
139
|
+
return new w(t);
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
142
142
|
* Serializes an [AccessMode] to its RWPM JSON representation.
|
|
@@ -145,17 +145,17 @@ const v = class v {
|
|
|
145
145
|
return this.value;
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
|
-
|
|
149
|
-
let
|
|
150
|
-
const
|
|
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 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,8 +201,8 @@ const c = class c {
|
|
|
201
201
|
return this.value;
|
|
202
202
|
}
|
|
203
203
|
};
|
|
204
|
-
|
|
205
|
-
let
|
|
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
206
|
const S = class S {
|
|
207
207
|
constructor(t) {
|
|
208
208
|
this.value = t;
|
|
@@ -222,7 +222,7 @@ const S = class S {
|
|
|
222
222
|
}
|
|
223
223
|
};
|
|
224
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
|
|
225
|
+
let Qt = S;
|
|
226
226
|
const E = class E {
|
|
227
227
|
constructor(t) {
|
|
228
228
|
this.value = t;
|
|
@@ -242,10 +242,10 @@ const E = class E {
|
|
|
242
242
|
}
|
|
243
243
|
};
|
|
244
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
|
|
246
|
-
const qt = ["en", "ar", "da", "fr", "it", "pt_PT", "sv"], ke = /* @__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"}}`), We = {
|
|
247
|
-
publication:
|
|
248
|
-
},
|
|
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 qt = ["en", "ar", "da", "fr", "it", "pt_PT", "sv"], ke = /* @__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 It {
|
|
|
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 It {
|
|
|
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
|
|
432
|
-
if (
|
|
433
|
-
const f =
|
|
434
|
-
o[f] =
|
|
430
|
+
for (let p = 1; p < s.length; p++) {
|
|
431
|
+
const v = s[p].split("=");
|
|
432
|
+
if (v.length === 2) {
|
|
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
|
|
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) {
|
|
@@ -539,6 +539,7 @@ class l {
|
|
|
539
539
|
/** Returns whether this media type is of a bitmap image, so excluding vectorial formats. */
|
|
540
540
|
get isBitmap() {
|
|
541
541
|
return this.matchesAny(
|
|
542
|
+
l.AVIF,
|
|
542
543
|
l.BMP,
|
|
543
544
|
l.GIF,
|
|
544
545
|
l.JPEG,
|
|
@@ -602,6 +603,9 @@ class l {
|
|
|
602
603
|
fileExtension: "avi"
|
|
603
604
|
});
|
|
604
605
|
}
|
|
606
|
+
static get AVIF() {
|
|
607
|
+
return l.parse({ mediaType: "image/avif", fileExtension: "avif" });
|
|
608
|
+
}
|
|
605
609
|
static get BINARY() {
|
|
606
610
|
return l.parse({ mediaType: "application/octet-stream" });
|
|
607
611
|
}
|
|
@@ -871,7 +875,7 @@ class l {
|
|
|
871
875
|
});
|
|
872
876
|
}
|
|
873
877
|
}
|
|
874
|
-
class
|
|
878
|
+
class ne {
|
|
875
879
|
constructor(t) {
|
|
876
880
|
this.uri = t, this.parameters = this.getParameters(t);
|
|
877
881
|
}
|
|
@@ -899,7 +903,7 @@ class Qt {
|
|
|
899
903
|
return this.uri.replace(/\{(\??)([^}]+)\}/g, (...s) => s[1] ? i(s[2]) : e(s[2]));
|
|
900
904
|
}
|
|
901
905
|
}
|
|
902
|
-
class
|
|
906
|
+
class C {
|
|
903
907
|
/**
|
|
904
908
|
* Creates a [Locations].
|
|
905
909
|
*/
|
|
@@ -911,17 +915,17 @@ class A {
|
|
|
911
915
|
*/
|
|
912
916
|
static deserialize(t) {
|
|
913
917
|
if (!t) return;
|
|
914
|
-
const e =
|
|
918
|
+
const e = ut(t.progression), i = ut(t.totalProgression), s = ut(t.position), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([
|
|
915
919
|
"fragment",
|
|
916
920
|
"fragments",
|
|
917
921
|
"progression",
|
|
918
922
|
"totalProgression",
|
|
919
923
|
"position"
|
|
920
924
|
]);
|
|
921
|
-
return Object.entries(t).forEach(([a,
|
|
922
|
-
o.has(a) || n.set(a,
|
|
923
|
-
}), new
|
|
924
|
-
fragments:
|
|
925
|
+
return Object.entries(t).forEach(([a, c]) => {
|
|
926
|
+
o.has(a) || n.set(a, c);
|
|
927
|
+
}), new C({
|
|
928
|
+
fragments: xe(t.fragments || t.fragment),
|
|
925
929
|
progression: e !== void 0 && e >= 0 && e <= 1 ? e : void 0,
|
|
926
930
|
totalProgression: i !== void 0 && i >= 0 && i <= 1 ? i : void 0,
|
|
927
931
|
position: s !== void 0 && s > 0 ? s : void 0,
|
|
@@ -967,7 +971,7 @@ class W {
|
|
|
967
971
|
* Creates a [Locator].
|
|
968
972
|
*/
|
|
969
973
|
constructor(t) {
|
|
970
|
-
this.href = t.href, this.type = t.type, this.title = t.title, this.locations = t.locations ? t.locations : new
|
|
974
|
+
this.href = t.href, this.type = t.type, this.title = t.title, this.locations = t.locations ? t.locations : new C({}), this.text = t.text;
|
|
971
975
|
}
|
|
972
976
|
/**
|
|
973
977
|
* Parses a [Link] from its RWPM JSON representation.
|
|
@@ -978,7 +982,7 @@ class W {
|
|
|
978
982
|
href: t.href,
|
|
979
983
|
type: t.type,
|
|
980
984
|
title: t.title,
|
|
981
|
-
locations:
|
|
985
|
+
locations: C.deserialize(t.locations),
|
|
982
986
|
text: _.deserialize(t.text)
|
|
983
987
|
});
|
|
984
988
|
}
|
|
@@ -998,11 +1002,11 @@ class W {
|
|
|
998
1002
|
type: this.type,
|
|
999
1003
|
title: this.title,
|
|
1000
1004
|
text: this.text,
|
|
1001
|
-
locations: new
|
|
1005
|
+
locations: new C({ ...this.locations, ...t })
|
|
1002
1006
|
});
|
|
1003
1007
|
}
|
|
1004
1008
|
}
|
|
1005
|
-
class
|
|
1009
|
+
class X {
|
|
1006
1010
|
/**
|
|
1007
1011
|
* Creates a [Link].
|
|
1008
1012
|
*/
|
|
@@ -1014,21 +1018,21 @@ class Y {
|
|
|
1014
1018
|
*/
|
|
1015
1019
|
static deserialize(t) {
|
|
1016
1020
|
if (!(!t || typeof t.href != "string"))
|
|
1017
|
-
return new
|
|
1021
|
+
return new X({
|
|
1018
1022
|
href: t.href,
|
|
1019
1023
|
templated: t.templated,
|
|
1020
1024
|
type: t.type,
|
|
1021
1025
|
title: t.title,
|
|
1022
1026
|
rels: t.rel ? Array.isArray(t.rel) ? new Set(t.rel) : /* @__PURE__ */ new Set([t.rel]) : void 0,
|
|
1023
|
-
properties:
|
|
1024
|
-
height:
|
|
1025
|
-
width:
|
|
1026
|
-
size:
|
|
1027
|
-
duration:
|
|
1028
|
-
bitrate:
|
|
1029
|
-
languages:
|
|
1030
|
-
alternates:
|
|
1031
|
-
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)
|
|
1032
1036
|
});
|
|
1033
1037
|
}
|
|
1034
1038
|
/**
|
|
@@ -1036,7 +1040,7 @@ class Y {
|
|
|
1036
1040
|
*/
|
|
1037
1041
|
serialize() {
|
|
1038
1042
|
const t = { href: this.href };
|
|
1039
|
-
return this.templated !== void 0 && (t.templated = this.templated), this.type !== void 0 && (t.type = this.type), this.title !== void 0 && (t.title = this.title), this.rels && (t.rel =
|
|
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;
|
|
1040
1044
|
}
|
|
1041
1045
|
/** MediaType of the linked resource. */
|
|
1042
1046
|
get mediaType() {
|
|
@@ -1053,14 +1057,14 @@ class Y {
|
|
|
1053
1057
|
}
|
|
1054
1058
|
/** List of URI template parameter keys, if the `Link` is templated. */
|
|
1055
1059
|
get templateParameters() {
|
|
1056
|
-
return this.templated ? new
|
|
1060
|
+
return this.templated ? new ne(this.href).parameters : /* @__PURE__ */ new Set();
|
|
1057
1061
|
}
|
|
1058
1062
|
/** Expands the `Link`'s HREF by replacing URI template variables by the given parameters.
|
|
1059
1063
|
* See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
|
|
1060
1064
|
*/
|
|
1061
1065
|
expandTemplate(t) {
|
|
1062
|
-
return new
|
|
1063
|
-
href: new
|
|
1066
|
+
return new X({
|
|
1067
|
+
href: new ne(this.href).expand(t),
|
|
1064
1068
|
templated: !1
|
|
1065
1069
|
});
|
|
1066
1070
|
}
|
|
@@ -1068,8 +1072,8 @@ class Y {
|
|
|
1068
1072
|
* Makes a copy of this [Link] after merging in the given additional other [properties].
|
|
1069
1073
|
*/
|
|
1070
1074
|
addProperties(t) {
|
|
1071
|
-
const e =
|
|
1072
|
-
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;
|
|
1073
1077
|
}
|
|
1074
1078
|
/**
|
|
1075
1079
|
* Creates a [Locator] from a reading order [Link].
|
|
@@ -1080,13 +1084,13 @@ class Y {
|
|
|
1080
1084
|
href: t.length > 0 && t[0] !== void 0 ? t[0] : this.href,
|
|
1081
1085
|
type: this.type ?? "",
|
|
1082
1086
|
title: this.title,
|
|
1083
|
-
locations: new
|
|
1087
|
+
locations: new C({
|
|
1084
1088
|
fragments: t.length > 1 && t[1] !== void 0 ? [t[1]] : []
|
|
1085
1089
|
})
|
|
1086
1090
|
});
|
|
1087
1091
|
}
|
|
1088
1092
|
}
|
|
1089
|
-
class
|
|
1093
|
+
class pt {
|
|
1090
1094
|
/**
|
|
1091
1095
|
* Creates a [Links].
|
|
1092
1096
|
*/
|
|
@@ -1098,8 +1102,8 @@ class lt {
|
|
|
1098
1102
|
*/
|
|
1099
1103
|
static deserialize(t) {
|
|
1100
1104
|
if (t && Array.isArray(t))
|
|
1101
|
-
return new
|
|
1102
|
-
t.map((e) =>
|
|
1105
|
+
return new pt(
|
|
1106
|
+
t.map((e) => X.deserialize(e)).filter((e) => e !== void 0)
|
|
1103
1107
|
);
|
|
1104
1108
|
}
|
|
1105
1109
|
/**
|
|
@@ -1180,10 +1184,10 @@ class lt {
|
|
|
1180
1184
|
return this.items.filter((t) => t.type);
|
|
1181
1185
|
}
|
|
1182
1186
|
}
|
|
1183
|
-
|
|
1187
|
+
D.prototype.getContains = function() {
|
|
1184
1188
|
return new Set(this.otherProperties.contains || []);
|
|
1185
1189
|
};
|
|
1186
|
-
class
|
|
1190
|
+
class mt {
|
|
1187
1191
|
/**
|
|
1188
1192
|
* Creates a [DomRange].
|
|
1189
1193
|
*/
|
|
@@ -1195,10 +1199,10 @@ class ct {
|
|
|
1195
1199
|
*/
|
|
1196
1200
|
static deserialize(t) {
|
|
1197
1201
|
if (!(t && t.cssSelector)) return;
|
|
1198
|
-
let e =
|
|
1202
|
+
let e = R(t.textNodeIndex);
|
|
1199
1203
|
if (e === void 0) return;
|
|
1200
|
-
let i =
|
|
1201
|
-
return i === void 0 && (i =
|
|
1204
|
+
let i = R(t.charOffset);
|
|
1205
|
+
return i === void 0 && (i = R(t.offset)), new mt({
|
|
1202
1206
|
cssSelector: t.cssSelector,
|
|
1203
1207
|
textNodeIndex: e,
|
|
1204
1208
|
charOffset: i
|
|
@@ -1215,7 +1219,7 @@ class ct {
|
|
|
1215
1219
|
return this.charOffset !== void 0 && (t.charOffset = this.charOffset), t;
|
|
1216
1220
|
}
|
|
1217
1221
|
}
|
|
1218
|
-
class
|
|
1222
|
+
class Bt {
|
|
1219
1223
|
/**
|
|
1220
1224
|
* Creates a [DomRange].
|
|
1221
1225
|
*/
|
|
@@ -1227,11 +1231,11 @@ class Dt {
|
|
|
1227
1231
|
*/
|
|
1228
1232
|
static deserialize(t) {
|
|
1229
1233
|
if (!t) return;
|
|
1230
|
-
let e =
|
|
1234
|
+
let e = mt.deserialize(t.start);
|
|
1231
1235
|
if (e)
|
|
1232
|
-
return new
|
|
1236
|
+
return new Bt({
|
|
1233
1237
|
start: e,
|
|
1234
|
-
end:
|
|
1238
|
+
end: mt.deserialize(t.end)
|
|
1235
1239
|
});
|
|
1236
1240
|
}
|
|
1237
1241
|
/**
|
|
@@ -1242,16 +1246,16 @@ class Dt {
|
|
|
1242
1246
|
return this.end && (t.end = this.end.serialize()), t;
|
|
1243
1247
|
}
|
|
1244
1248
|
}
|
|
1245
|
-
|
|
1249
|
+
C.prototype.getCssSelector = function() {
|
|
1246
1250
|
return this.otherLocations?.get("cssSelector");
|
|
1247
1251
|
};
|
|
1248
|
-
|
|
1252
|
+
C.prototype.getPartialCfi = function() {
|
|
1249
1253
|
return this.otherLocations?.get("partialCfi");
|
|
1250
1254
|
};
|
|
1251
|
-
|
|
1252
|
-
return
|
|
1255
|
+
C.prototype.getDomRange = function() {
|
|
1256
|
+
return Bt.deserialize(this.otherLocations?.get("domRange"));
|
|
1253
1257
|
};
|
|
1254
|
-
|
|
1258
|
+
C.prototype.fragmentParameters = function() {
|
|
1255
1259
|
return new Map(
|
|
1256
1260
|
this.fragments.map((r) => r.startsWith("#") ? r.slice(1) : r).join("&").split("&").filter((r) => !r.startsWith("#")).map((r) => r.split("=")).filter((r) => r.length === 2).map((r) => [
|
|
1257
1261
|
r[0].trim().toLowerCase(),
|
|
@@ -1259,7 +1263,7 @@ A.prototype.fragmentParameters = function() {
|
|
|
1259
1263
|
])
|
|
1260
1264
|
);
|
|
1261
1265
|
};
|
|
1262
|
-
|
|
1266
|
+
C.prototype.htmlId = function() {
|
|
1263
1267
|
if (!this.fragments.length) return;
|
|
1264
1268
|
let r = this.fragments.find((t) => t.length && !t.includes("="));
|
|
1265
1269
|
if (!r) {
|
|
@@ -1268,26 +1272,22 @@ A.prototype.htmlId = function() {
|
|
|
1268
1272
|
}
|
|
1269
1273
|
return r?.startsWith("#") ? r.slice(1) : r;
|
|
1270
1274
|
};
|
|
1271
|
-
|
|
1275
|
+
C.prototype.page = function() {
|
|
1272
1276
|
const r = parseInt(this.fragmentParameters().get("page"));
|
|
1273
1277
|
if (!isNaN(r) && r >= 0) return r;
|
|
1274
1278
|
};
|
|
1275
|
-
|
|
1279
|
+
C.prototype.time = function() {
|
|
1276
1280
|
const r = parseInt(this.fragmentParameters().get("t"));
|
|
1277
1281
|
if (!isNaN(r)) return r;
|
|
1278
1282
|
};
|
|
1279
|
-
|
|
1283
|
+
C.prototype.space = function() {
|
|
1280
1284
|
const r = this.fragmentParameters();
|
|
1281
1285
|
if (!r.has("xywh")) return;
|
|
1282
1286
|
const t = r.get("xywh").split(",").map((e) => parseInt(e));
|
|
1283
1287
|
if (t.length === 4 && !t.some(isNaN))
|
|
1284
1288
|
return t;
|
|
1285
1289
|
};
|
|
1286
|
-
|
|
1287
|
-
const r = this.fragmentParameters();
|
|
1288
|
-
console.log(r);
|
|
1289
|
-
};
|
|
1290
|
-
class zt {
|
|
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 zt {
|
|
|
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 zt {
|
|
|
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 Mt {
|
|
|
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 Mt {
|
|
|
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 kt {
|
|
|
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 kt {
|
|
|
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 Wt {
|
|
|
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 Wt {
|
|
|
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 we(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
|
|
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
|
|
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
|
-
|
|
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 se(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 se(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 Xe(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 Xe(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 Xe(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 Xe(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 Se(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((
|
|
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 Ae(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 Ze(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 Je(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 re(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,53 +2132,52 @@ function je(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
|
-
|
|
2142
|
-
function Ut(r) {
|
|
2141
|
+
function Gt(r) {
|
|
2143
2142
|
const t = {}, e = r.document.documentElement.style;
|
|
2144
2143
|
for (const i in r.document.documentElement.style)
|
|
2145
2144
|
Object.hasOwn(e, i) && !Number.isNaN(Number.parseInt(i)) && (t[e[i]] = e.getPropertyValue(e[i]));
|
|
2146
2145
|
return t;
|
|
2147
2146
|
}
|
|
2148
|
-
function
|
|
2149
|
-
const e =
|
|
2147
|
+
function Ie(r, t) {
|
|
2148
|
+
const e = Gt(r);
|
|
2150
2149
|
Object.keys(e).forEach((i) => {
|
|
2151
|
-
t.hasOwnProperty(i) ||
|
|
2150
|
+
t.hasOwnProperty(i) || bt(r, i);
|
|
2152
2151
|
}), Object.entries(t).forEach(([i, s]) => {
|
|
2153
|
-
e[i] !== s &&
|
|
2152
|
+
e[i] !== s && nt(r, i, s);
|
|
2154
2153
|
});
|
|
2155
2154
|
}
|
|
2156
|
-
function
|
|
2155
|
+
function Et(r, t) {
|
|
2157
2156
|
return r.document.documentElement.style.getPropertyValue(t);
|
|
2158
2157
|
}
|
|
2159
|
-
function
|
|
2158
|
+
function nt(r, t, e) {
|
|
2160
2159
|
r.document.documentElement.style.setProperty(t, e);
|
|
2161
2160
|
}
|
|
2162
|
-
function
|
|
2161
|
+
function bt(r, t) {
|
|
2163
2162
|
r.document.documentElement.style.removeProperty(t);
|
|
2164
2163
|
}
|
|
2165
|
-
let
|
|
2166
|
-
const
|
|
2167
|
-
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)
|
|
2168
2167
|
if (typeof OffscreenCanvas < "u")
|
|
2169
|
-
|
|
2168
|
+
ht = new OffscreenCanvas(5, 5), At = ht.getContext("2d", {
|
|
2170
2169
|
willReadFrequently: !0,
|
|
2171
2170
|
desynchronized: !0
|
|
2172
2171
|
});
|
|
2173
2172
|
else {
|
|
2174
2173
|
const r = document.createElement("canvas");
|
|
2175
|
-
r.width = 5, r.height = 5,
|
|
2174
|
+
r.width = 5, r.height = 5, ht = r, At = r.getContext("2d", {
|
|
2176
2175
|
willReadFrequently: !0,
|
|
2177
2176
|
desynchronized: !0
|
|
2178
2177
|
});
|
|
2179
2178
|
}
|
|
2180
|
-
return
|
|
2181
|
-
},
|
|
2179
|
+
return At;
|
|
2180
|
+
}, oi = (r) => {
|
|
2182
2181
|
if (!r) return !0;
|
|
2183
2182
|
const t = r.trim().toLowerCase();
|
|
2184
2183
|
return t.startsWith("var(") || [
|
|
@@ -2197,56 +2196,56 @@ const G = { r: 255, g: 255, b: 255, a: 1 }, V = /* @__PURE__ */ new Map(), ti =
|
|
|
2197
2196
|
"repeating-radial-gradient",
|
|
2198
2197
|
"repeating-conic-gradient"
|
|
2199
2198
|
].some((s) => t.includes(s));
|
|
2200
|
-
},
|
|
2199
|
+
}, dt = (r, t) => {
|
|
2201
2200
|
console.warn(
|
|
2202
|
-
`[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).`
|
|
2203
2202
|
);
|
|
2204
|
-
},
|
|
2205
|
-
const e = t ? `${r}|${t}` : r, i =
|
|
2203
|
+
}, Tt = (r, t = null) => {
|
|
2204
|
+
const e = t ? `${r}|${t}` : r, i = G.get(e);
|
|
2206
2205
|
if (i !== void 0)
|
|
2207
|
-
return i ??
|
|
2208
|
-
if (
|
|
2209
|
-
return
|
|
2210
|
-
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();
|
|
2211
2210
|
if (!s)
|
|
2212
|
-
return
|
|
2211
|
+
return dt(r, "Could not get canvas context."), G.set(e, null), $;
|
|
2213
2212
|
try {
|
|
2214
|
-
|
|
2215
|
-
const n =
|
|
2213
|
+
Q === 0 && s.clearRect(0, 0, 5, 5);
|
|
2214
|
+
const n = Q % 5, o = Math.floor(Q / 5);
|
|
2216
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);
|
|
2217
2216
|
const a = s.getImageData(n, o, 1, 1);
|
|
2218
|
-
|
|
2219
|
-
const [
|
|
2217
|
+
Q = (Q + 1) % 25;
|
|
2218
|
+
const [c, d, u, g] = a.data;
|
|
2220
2219
|
if (g === 0)
|
|
2221
|
-
return
|
|
2222
|
-
const
|
|
2223
|
-
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;
|
|
2224
2223
|
} catch (n) {
|
|
2225
|
-
return
|
|
2224
|
+
return dt(r, `Error: ${n instanceof Error ? n.message : String(n)}`), G.set(e, null), $;
|
|
2226
2225
|
}
|
|
2227
|
-
},
|
|
2226
|
+
}, Ct = (r) => {
|
|
2228
2227
|
const t = r / 255;
|
|
2229
2228
|
return t <= 0.03928 ? t / 12.92 : Math.pow((t + 0.055) / 1.055, 2.4);
|
|
2230
|
-
},
|
|
2231
|
-
const t =
|
|
2229
|
+
}, ue = (r) => {
|
|
2230
|
+
const t = Ct(r.r), e = Ct(r.g), i = Ct(r.b);
|
|
2232
2231
|
return 0.2126 * t + 0.7152 * e + 0.0722 * i;
|
|
2233
|
-
},
|
|
2234
|
-
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);
|
|
2235
2234
|
return (o + 0.05) / (a + 0.05);
|
|
2236
|
-
},
|
|
2237
|
-
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 });
|
|
2238
2237
|
return i > s;
|
|
2239
|
-
},
|
|
2240
|
-
var
|
|
2241
|
-
const
|
|
2242
|
-
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 {
|
|
2243
2242
|
/**
|
|
2244
2243
|
* Creates a DecorationGroup object
|
|
2245
2244
|
* @param id Unique HTML ID-adhering name of the group
|
|
2246
2245
|
* @param name Human-readable name of the group
|
|
2247
2246
|
*/
|
|
2248
2247
|
constructor(t, e, i, s) {
|
|
2249
|
-
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());
|
|
2250
2249
|
}
|
|
2251
2250
|
get activeable() {
|
|
2252
2251
|
return this.activateable;
|
|
@@ -2259,13 +2258,13 @@ class oi {
|
|
|
2259
2258
|
* @param decoration Decoration to add
|
|
2260
2259
|
*/
|
|
2261
2260
|
add(t) {
|
|
2262
|
-
const e = `${this.id}-${this.lastItemId++}`, i =
|
|
2261
|
+
const e = `${this.id}-${this.lastItemId++}`, i = rt(this.wnd.document, t.locator);
|
|
2263
2262
|
if (!i) {
|
|
2264
2263
|
this.comms.log("Can't locate DOM range for decoration", t);
|
|
2265
2264
|
return;
|
|
2266
2265
|
}
|
|
2267
2266
|
const s = i.commonAncestorContainer;
|
|
2268
|
-
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));
|
|
2269
2268
|
const n = {
|
|
2270
2269
|
decoration: t,
|
|
2271
2270
|
id: e,
|
|
@@ -2306,16 +2305,16 @@ class oi {
|
|
|
2306
2305
|
experimentalLayout(t) {
|
|
2307
2306
|
const [e, i] = this.requireContainer(!0);
|
|
2308
2307
|
i.add(t.range);
|
|
2309
|
-
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;
|
|
2310
2309
|
e.innerHTML = `
|
|
2311
2310
|
::highlight(${this.id}) {
|
|
2312
|
-
color: ${
|
|
2311
|
+
color: ${ai(n, s)};
|
|
2313
2312
|
background-color: ${n};
|
|
2314
2313
|
}`;
|
|
2315
2314
|
}
|
|
2316
2315
|
/**
|
|
2317
2316
|
* Layouts a single DecorationItem.
|
|
2318
|
-
* @param item
|
|
2317
|
+
* @param item
|
|
2319
2318
|
*/
|
|
2320
2319
|
layout(t) {
|
|
2321
2320
|
if (this.experimentalHighlights && !this.notTextFlag?.has(t.id))
|
|
@@ -2326,48 +2325,48 @@ class oi {
|
|
|
2326
2325
|
getComputedStyle(this.wnd.document.documentElement).getPropertyValue(
|
|
2327
2326
|
"column-count"
|
|
2328
2327
|
)
|
|
2329
|
-
), 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) => {
|
|
2330
2329
|
if (f.style.position = "absolute", t.decoration?.style?.width === "viewport") {
|
|
2331
|
-
f.style.width = `${i}px`, f.style.height = `${
|
|
2332
|
-
let
|
|
2333
|
-
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`;
|
|
2334
2333
|
} else if (t.decoration?.style?.width === "bounds")
|
|
2335
|
-
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`;
|
|
2336
2335
|
else if (t.decoration?.style?.width === "page") {
|
|
2337
|
-
f.style.width = `${n}px`, f.style.height = `${
|
|
2338
|
-
let
|
|
2339
|
-
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`;
|
|
2340
2339
|
} else
|
|
2341
|
-
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`;
|
|
2342
2341
|
}, u = t.range.getBoundingClientRect();
|
|
2343
2342
|
let g = this.wnd.document.createElement("template");
|
|
2344
|
-
const
|
|
2343
|
+
const p = this.getCurrentDarkMode();
|
|
2345
2344
|
g.innerHTML = `
|
|
2346
2345
|
<div
|
|
2347
|
-
data-readium="true"
|
|
2346
|
+
data-readium="true"
|
|
2348
2347
|
class="readium-highlight"
|
|
2349
2348
|
style="${[
|
|
2350
|
-
`background-color: ${t.decoration?.style?.tint ??
|
|
2349
|
+
`background-color: ${t.decoration?.style?.tint ?? me} !important`,
|
|
2351
2350
|
//"opacity: 0.3 !important",
|
|
2352
|
-
`mix-blend-mode: ${
|
|
2351
|
+
`mix-blend-mode: ${p ? "exclusion" : "multiply"} !important`,
|
|
2353
2352
|
"opacity: 1 !important",
|
|
2354
2353
|
"box-sizing: border-box !important"
|
|
2355
2354
|
].join("; ")}"
|
|
2356
2355
|
>
|
|
2357
2356
|
</div>
|
|
2358
2357
|
`.trim();
|
|
2359
|
-
const
|
|
2358
|
+
const v = g.content.firstElementChild;
|
|
2360
2359
|
if (t.decoration?.style?.layout === "bounds") {
|
|
2361
|
-
const f =
|
|
2362
|
-
f.style.setProperty("pointer-events", "none"),
|
|
2360
|
+
const f = v.cloneNode(!0);
|
|
2361
|
+
f.style.setProperty("pointer-events", "none"), d(f, u, u), e.append(f);
|
|
2363
2362
|
} else {
|
|
2364
|
-
let f =
|
|
2363
|
+
let f = ti(
|
|
2365
2364
|
t.range
|
|
2366
2365
|
);
|
|
2367
|
-
f = f.sort((
|
|
2368
|
-
for (let
|
|
2369
|
-
const b =
|
|
2370
|
-
b.style.setProperty("pointer-events", "none"),
|
|
2366
|
+
f = f.sort((m, b) => m.top < b.top ? -1 : m.top > b.top ? 1 : 0);
|
|
2367
|
+
for (let m of f) {
|
|
2368
|
+
const b = v.cloneNode(!0);
|
|
2369
|
+
b.style.setProperty("pointer-events", "none"), d(b, m, u), e.append(b);
|
|
2371
2370
|
}
|
|
2372
2371
|
}
|
|
2373
2372
|
t.container = e, t.clickableElements = Array.from(
|
|
@@ -2394,7 +2393,7 @@ class oi {
|
|
|
2394
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;
|
|
2395
2394
|
}
|
|
2396
2395
|
getCurrentDarkMode() {
|
|
2397
|
-
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"));
|
|
2398
2397
|
}
|
|
2399
2398
|
/**
|
|
2400
2399
|
* Removes the group container.
|
|
@@ -2403,7 +2402,7 @@ class oi {
|
|
|
2403
2402
|
this.experimentalHighlights && this.wnd.CSS.highlights.delete(this.id), this.container && (this.container.remove(), this.container = void 0);
|
|
2404
2403
|
}
|
|
2405
2404
|
}
|
|
2406
|
-
const
|
|
2405
|
+
const tt = class tt extends Z {
|
|
2407
2406
|
constructor() {
|
|
2408
2407
|
super(...arguments), this.resizeFrame = 0, this.lastGroupId = 0, this.groups = /* @__PURE__ */ new Map(), this.handleResizer = this.handleResize.bind(this);
|
|
2409
2408
|
}
|
|
@@ -2428,9 +2427,9 @@ const Q = class Q extends X {
|
|
|
2428
2427
|
}, 50);
|
|
2429
2428
|
}
|
|
2430
2429
|
mount(t, e) {
|
|
2431
|
-
return this.wnd = t, e.register("decorate",
|
|
2430
|
+
return this.wnd = t, e.register("decorate", tt.moduleName, (i, s) => {
|
|
2432
2431
|
const n = i;
|
|
2433
|
-
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(
|
|
2434
2433
|
t,
|
|
2435
2434
|
e,
|
|
2436
2435
|
`readium-decoration-${this.lastGroupId++}`,
|
|
@@ -2455,8 +2454,8 @@ const Q = class Q extends X {
|
|
|
2455
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) => {
|
|
2456
2455
|
i.some((n) => {
|
|
2457
2456
|
if (n.type === "attributes" && n.attributeName === "style") {
|
|
2458
|
-
const o = n.target, a = n.oldValue,
|
|
2459
|
-
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;
|
|
2460
2459
|
}
|
|
2461
2460
|
return !1;
|
|
2462
2461
|
}) && this.updateHighlightStyles();
|
|
@@ -2468,12 +2467,12 @@ const Q = class Q extends X {
|
|
|
2468
2467
|
}), e.log("Decorator Mounted"), !0;
|
|
2469
2468
|
}
|
|
2470
2469
|
unmount(t, e) {
|
|
2471
|
-
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;
|
|
2472
2471
|
}
|
|
2473
2472
|
};
|
|
2474
|
-
|
|
2475
|
-
let
|
|
2476
|
-
const
|
|
2473
|
+
tt.moduleName = "decorator";
|
|
2474
|
+
let Nt = tt;
|
|
2475
|
+
const ge = "readium-snapper-style", et = class et extends Z {
|
|
2477
2476
|
constructor() {
|
|
2478
2477
|
super(...arguments), this.protected = !1;
|
|
2479
2478
|
}
|
|
@@ -2486,59 +2485,59 @@ const he = "readium-snapper-style", j = class j extends X {
|
|
|
2486
2485
|
}
|
|
2487
2486
|
mount(t, e) {
|
|
2488
2487
|
const i = t.document.createElement("style");
|
|
2489
|
-
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) => {
|
|
2490
2489
|
this.protected = !0, i.textContent = this.buildStyles(), n(!0);
|
|
2491
|
-
}), e.register("unprotect",
|
|
2490
|
+
}), e.register("unprotect", et.moduleName, (s, n) => {
|
|
2492
2491
|
this.protected = !1, i.textContent = this.buildStyles(), n(!0);
|
|
2493
2492
|
}), e.log("Snapper Mounted"), !0;
|
|
2494
2493
|
}
|
|
2495
2494
|
unmount(t, e) {
|
|
2496
|
-
return t.document.getElementById(
|
|
2495
|
+
return t.document.getElementById(ge)?.remove(), e.log("Snapper Unmounted"), !0;
|
|
2497
2496
|
}
|
|
2498
2497
|
};
|
|
2499
|
-
|
|
2500
|
-
let
|
|
2501
|
-
function
|
|
2502
|
-
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";
|
|
2503
2502
|
}
|
|
2504
|
-
function
|
|
2503
|
+
function ze(r) {
|
|
2505
2504
|
return parseInt(
|
|
2506
2505
|
r.getComputedStyle(
|
|
2507
2506
|
r.document.documentElement
|
|
2508
2507
|
).getPropertyValue("column-count")
|
|
2509
2508
|
);
|
|
2510
2509
|
}
|
|
2511
|
-
function
|
|
2510
|
+
function ye(r) {
|
|
2512
2511
|
const t = getComputedStyle(r), e = parseFloat(t.paddingTop || "0"), i = parseFloat(t.paddingBottom || "0");
|
|
2513
2512
|
return r.clientHeight - e - i;
|
|
2514
2513
|
}
|
|
2515
|
-
function
|
|
2516
|
-
const t =
|
|
2514
|
+
function be(r) {
|
|
2515
|
+
const t = ze(r);
|
|
2517
2516
|
if (!t)
|
|
2518
2517
|
return !1;
|
|
2519
2518
|
const e = r.document.querySelectorAll("div[id^='readium-virtual-page']");
|
|
2520
|
-
for (const
|
|
2521
|
-
|
|
2522
|
-
const i = e.length, s = r.document.scrollingElement.scrollWidth, n = r.visualViewport.width, a = Math.round(s / n * t) % t,
|
|
2523
|
-
if (
|
|
2524
|
-
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++) {
|
|
2525
2524
|
const u = r.document.createElement("div");
|
|
2526
|
-
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);
|
|
2527
2526
|
}
|
|
2528
|
-
return i !==
|
|
2527
|
+
return i !== c;
|
|
2529
2528
|
}
|
|
2530
|
-
function
|
|
2529
|
+
function $t(r) {
|
|
2531
2530
|
const t = r.document.createElement("style");
|
|
2532
2531
|
t.appendChild(r.document.createTextNode("*{}")), r.document.body.appendChild(t), r.document.body.removeChild(t);
|
|
2533
2532
|
}
|
|
2534
|
-
function
|
|
2533
|
+
function ui(r) {
|
|
2535
2534
|
return r < 0.5 ? 2 * r * r : -1 + (4 - 2 * r) * r;
|
|
2536
2535
|
}
|
|
2537
|
-
function
|
|
2536
|
+
function A(r) {
|
|
2538
2537
|
const t = r.getSelection();
|
|
2539
2538
|
t && t.removeAllRanges();
|
|
2540
2539
|
}
|
|
2541
|
-
const
|
|
2540
|
+
const pi = [
|
|
2542
2541
|
"a",
|
|
2543
2542
|
"audio",
|
|
2544
2543
|
"button",
|
|
@@ -2552,17 +2551,17 @@ const li = [
|
|
|
2552
2551
|
"textarea",
|
|
2553
2552
|
"video"
|
|
2554
2553
|
];
|
|
2555
|
-
function
|
|
2556
|
-
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;
|
|
2557
2556
|
}
|
|
2558
|
-
function
|
|
2559
|
-
const e =
|
|
2557
|
+
function vt(r, t) {
|
|
2558
|
+
const e = ke(r, r.document.body, t), i = r._readium_cssSelectorGenerator.getCssSelector(e, {
|
|
2560
2559
|
selectors: ["tag", "id", "class", "nthchild", "nthoftype", "attribute"]
|
|
2561
2560
|
});
|
|
2562
2561
|
return new W({
|
|
2563
2562
|
href: "#",
|
|
2564
2563
|
type: "application/xhtml+xml",
|
|
2565
|
-
locations: new
|
|
2564
|
+
locations: new C({
|
|
2566
2565
|
otherLocations: /* @__PURE__ */ new Map([
|
|
2567
2566
|
["cssSelector", i]
|
|
2568
2567
|
])
|
|
@@ -2572,15 +2571,15 @@ function Bt(r, t) {
|
|
|
2572
2571
|
})
|
|
2573
2572
|
});
|
|
2574
2573
|
}
|
|
2575
|
-
function
|
|
2574
|
+
function ke(r, t, e) {
|
|
2576
2575
|
for (var i = 0; i < t.children.length; i++) {
|
|
2577
2576
|
const s = t.children[i];
|
|
2578
|
-
if (!
|
|
2579
|
-
return
|
|
2577
|
+
if (!gi(s) && mi(r, s, e))
|
|
2578
|
+
return fi(r, s) ? s : ke(r, s, e);
|
|
2580
2579
|
}
|
|
2581
2580
|
return t;
|
|
2582
2581
|
}
|
|
2583
|
-
function
|
|
2582
|
+
function mi(r, t, e) {
|
|
2584
2583
|
if (t === document.body || t === document.documentElement)
|
|
2585
2584
|
return !0;
|
|
2586
2585
|
if (!document || !document.documentElement || !document.body)
|
|
@@ -2588,11 +2587,11 @@ function ci(r, t, e) {
|
|
|
2588
2587
|
const i = t.getBoundingClientRect();
|
|
2589
2588
|
return e ? i.bottom > 0 && i.top < r.innerHeight : i.right > 0 && i.left < r.innerWidth;
|
|
2590
2589
|
}
|
|
2591
|
-
function
|
|
2590
|
+
function fi(r, t) {
|
|
2592
2591
|
const e = t.getBoundingClientRect();
|
|
2593
2592
|
return e.top >= 0 && e.left >= 0 && e.bottom <= r.innerHeight && e.right <= r.innerWidth;
|
|
2594
2593
|
}
|
|
2595
|
-
function
|
|
2594
|
+
function gi(r) {
|
|
2596
2595
|
const t = getComputedStyle(r);
|
|
2597
2596
|
if (t) {
|
|
2598
2597
|
const e = t.getPropertyValue("display");
|
|
@@ -2601,7 +2600,7 @@ function di(r) {
|
|
|
2601
2600
|
}
|
|
2602
2601
|
return !1;
|
|
2603
2602
|
}
|
|
2604
|
-
const
|
|
2603
|
+
const yi = {
|
|
2605
2604
|
maxVelocity: 200,
|
|
2606
2605
|
// Reasonable default for human-like scrolling (pixels/ms)
|
|
2607
2606
|
minVariance: 0.01,
|
|
@@ -2612,7 +2611,7 @@ const ui = {
|
|
|
2612
2611
|
// Reasonable default for detecting patterns
|
|
2613
2612
|
maxConsistentScrolls: 15
|
|
2614
2613
|
// Balanced threshold for flagging
|
|
2615
|
-
},
|
|
2614
|
+
}, Yt = {
|
|
2616
2615
|
maxVelocity: 200,
|
|
2617
2616
|
// Extremely fast scrolling (pixels/ms)
|
|
2618
2617
|
minVariance: 1e-5,
|
|
@@ -2623,20 +2622,20 @@ const ui = {
|
|
|
2623
2622
|
// Only trigger on near-perfect patterns
|
|
2624
2623
|
maxConsistentScrolls: 20
|
|
2625
2624
|
// Need many consistent scrolls
|
|
2626
|
-
},
|
|
2625
|
+
}, We = {
|
|
2627
2626
|
maxSelectionsPerSecond: 500,
|
|
2628
2627
|
minVariance: 50,
|
|
2629
2628
|
historySize: 20
|
|
2630
|
-
},
|
|
2629
|
+
}, bi = {
|
|
2631
2630
|
enabled: !0,
|
|
2632
2631
|
maxSelectionPercent: 0.1,
|
|
2633
2632
|
minThreshold: 100,
|
|
2634
2633
|
absoluteMaxChars: 5e3,
|
|
2635
2634
|
historySize: 20
|
|
2636
2635
|
};
|
|
2637
|
-
class
|
|
2636
|
+
class wt {
|
|
2638
2637
|
constructor(t = {}) {
|
|
2639
|
-
this.history = [], this.consistentScrollCount = 0, this.options = { ...
|
|
2638
|
+
this.history = [], this.consistentScrollCount = 0, this.options = { ...yi, ...t };
|
|
2640
2639
|
}
|
|
2641
2640
|
analyze(t, e, i) {
|
|
2642
2641
|
if (i <= 0) return !1;
|
|
@@ -2646,19 +2645,19 @@ class Ht {
|
|
|
2646
2645
|
direction: t,
|
|
2647
2646
|
velocity: s,
|
|
2648
2647
|
distance: Math.abs(e)
|
|
2649
|
-
}), 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;
|
|
2650
2649
|
if (s > this.options.maxVelocity)
|
|
2651
2650
|
return this.resetAfterDetection(), !0;
|
|
2652
|
-
const o = this.history.map((
|
|
2653
|
-
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) {
|
|
2654
2653
|
if (this.consistentScrollCount++, this.consistentScrollCount >= (this.options.maxConsistentScrolls || 10))
|
|
2655
2654
|
return this.resetAfterDetection(), !0;
|
|
2656
2655
|
} else
|
|
2657
2656
|
this.consistentScrollCount = Math.max(0, this.consistentScrollCount - 1);
|
|
2658
|
-
let
|
|
2659
|
-
for (let
|
|
2660
|
-
this.history[
|
|
2661
|
-
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;
|
|
2662
2661
|
}
|
|
2663
2662
|
resetAfterDetection() {
|
|
2664
2663
|
this.history = this.history.slice(-3), this.consistentScrollCount = 0;
|
|
@@ -2667,7 +2666,7 @@ class Ht {
|
|
|
2667
2666
|
this.history = [], this.consistentScrollCount = 0;
|
|
2668
2667
|
}
|
|
2669
2668
|
}
|
|
2670
|
-
const
|
|
2669
|
+
const ve = "readium-column-snapper-style", vi = 200, T = class T extends K {
|
|
2671
2670
|
constructor() {
|
|
2672
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);
|
|
2673
2672
|
}
|
|
@@ -2675,26 +2674,44 @@ const pe = "readium-column-snapper-style", mi = 200, P = class P extends st {
|
|
|
2675
2674
|
return this.wnd.document.scrollingElement;
|
|
2676
2675
|
}
|
|
2677
2676
|
scrollOffset() {
|
|
2678
|
-
|
|
2677
|
+
const t = this.doc().scrollLeft;
|
|
2678
|
+
return t !== 0 ? t : this.alreadyScrollLeft;
|
|
2679
2679
|
}
|
|
2680
2680
|
snapOffset(t) {
|
|
2681
|
-
const e = t + (
|
|
2681
|
+
const e = t + (I(this.wnd) ? -1 : 1);
|
|
2682
2682
|
return e - e % this.wnd.innerWidth;
|
|
2683
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;
|
|
2690
|
+
return e - e % this.wnd.innerWidth;
|
|
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
|
+
}
|
|
2684
2701
|
reportProgress() {
|
|
2685
|
-
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));
|
|
2686
2703
|
this.comms.send("progress", {
|
|
2687
|
-
start:
|
|
2688
|
-
end:
|
|
2704
|
+
start: n,
|
|
2705
|
+
end: o
|
|
2689
2706
|
});
|
|
2690
2707
|
}
|
|
2691
2708
|
shake() {
|
|
2692
2709
|
if (this.overscroll !== 0 || this.shakeTimeout !== 0) return;
|
|
2693
|
-
const t = this.doc();
|
|
2694
|
-
t.classList.add(
|
|
2695
|
-
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();
|
|
2696
2713
|
this.shakeTimeout = this.wnd.setTimeout(() => {
|
|
2697
|
-
t.classList.remove(
|
|
2714
|
+
t.classList.remove(i), this.shakeTimeout = 0, this.doc().scrollLeft = s;
|
|
2698
2715
|
}, 150);
|
|
2699
2716
|
}
|
|
2700
2717
|
// We have to cache this because during overscroll (transform, or left) the width is incorrect due to browser
|
|
@@ -2705,29 +2722,21 @@ const pe = "readium-column-snapper-style", mi = 200, P = class P extends st {
|
|
|
2705
2722
|
}
|
|
2706
2723
|
// Snaps the current offset to the page width.
|
|
2707
2724
|
snapCurrentOffset(t = !1, e = !1) {
|
|
2708
|
-
const i = this.wnd.
|
|
2709
|
-
|
|
2710
|
-
d * (this.wnd.innerWidth / 3) * (d * n > 0 ? 2 : 1)
|
|
2711
|
-
), u = this.snapOffset(a + h), g = u > this.scrollOffset() ? "right" : "left";
|
|
2712
|
-
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) {
|
|
2713
2727
|
this.snappingCancelled = !1;
|
|
2714
|
-
const m = (
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
);
|
|
2718
|
-
let f;
|
|
2719
|
-
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) => {
|
|
2720
2731
|
if (this.snappingCancelled) return;
|
|
2721
|
-
|
|
2722
|
-
const
|
|
2723
|
-
s.scrollLeft =
|
|
2724
|
-
new CSSTranslate(CSS.px(-B), CSS.px(0), CSS.px(0))
|
|
2725
|
-
])) : s.style.transform = `translate3d(${-B}px, 0px, 0px)`), x < w ? this.wnd.requestAnimationFrame(p) : (this.clearTouches(), s.style.removeProperty("transform"), s.scrollLeft = u, e || this.reportProgress());
|
|
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());
|
|
2726
2735
|
};
|
|
2727
|
-
this.wnd.requestAnimationFrame(
|
|
2736
|
+
this.wnd.requestAnimationFrame(ot);
|
|
2728
2737
|
} else
|
|
2729
2738
|
s.style.removeProperty("transform"), this.wnd.requestAnimationFrame(() => {
|
|
2730
|
-
s.scrollLeft =
|
|
2739
|
+
s.scrollLeft = p, this.clearTouches(), e || this.reportProgress();
|
|
2731
2740
|
});
|
|
2732
2741
|
}
|
|
2733
2742
|
dragOffset() {
|
|
@@ -2752,8 +2761,8 @@ const pe = "readium-column-snapper-style", mi = 200, P = class P extends st {
|
|
|
2752
2761
|
}
|
|
2753
2762
|
onTouchEnd(t) {
|
|
2754
2763
|
if (this.touchState === 2) {
|
|
2755
|
-
const e = this.dragOffset(), i = this.
|
|
2756
|
-
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);
|
|
2757
2766
|
}
|
|
2758
2767
|
this.touchState = 0;
|
|
2759
2768
|
}
|
|
@@ -2762,16 +2771,12 @@ const pe = "readium-column-snapper-style", mi = 200, P = class P extends st {
|
|
|
2762
2771
|
}
|
|
2763
2772
|
onTouchMove(t) {
|
|
2764
2773
|
if (this.touchState === 0) return;
|
|
2765
|
-
this.touchState === 1 && (this.touchState = 2,
|
|
2766
|
-
const e = this.dragOffset(), i = this.alreadyScrollLeft + e;
|
|
2767
|
-
i <
|
|
2768
|
-
new CSSTranslate(CSS.px(-i), CSS.px(0), CSS.px(0))
|
|
2769
|
-
])) : this.doc().style.transform = `translate3d(${-i}px, 0px, 0px)`) : i + this.wnd.innerWidth > this.cachedScrollWidth ? (this.overscroll = i, gt() ? this.doc().attributeStyleMap.set("transform", new CSSTransformValue([
|
|
2770
|
-
new CSSTranslate(CSS.px(-i), CSS.px(0), CSS.px(0))
|
|
2771
|
-
])) : this.doc().style.transform = `translate3d(${-i}px, 0px, 0px)`) : (this.overscroll = 0, this.doc().style.removeProperty("transform"), this.doc().scrollLeft = this.alreadyScrollLeft + e);
|
|
2774
|
+
this.touchState === 1 && (this.touchState = 2, A(this.wnd)), this.endingX = t.touches[0].clientX;
|
|
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);
|
|
2772
2777
|
}
|
|
2773
2778
|
enableSnapProtection() {
|
|
2774
|
-
this.patternAnalyzer || (this.patternAnalyzer = new
|
|
2779
|
+
this.patternAnalyzer || (this.patternAnalyzer = new wt({
|
|
2775
2780
|
maxVelocity: this.wnd.innerWidth,
|
|
2776
2781
|
// page width
|
|
2777
2782
|
minVariance: 0.1,
|
|
@@ -2797,7 +2802,7 @@ const pe = "readium-column-snapper-style", mi = 200, P = class P extends st {
|
|
|
2797
2802
|
if (this.wnd = t, this.comms = e, !super.mount(t, e)) return !1;
|
|
2798
2803
|
t.navigator.epubReadingSystem && (t.navigator.epubReadingSystem.layoutStyle = "paginated");
|
|
2799
2804
|
const i = t.document.createElement("style");
|
|
2800
|
-
i.dataset.readium = "true", i.id =
|
|
2805
|
+
i.dataset.readium = "true", i.id = ve, i.textContent = `
|
|
2801
2806
|
@keyframes readium-bounce-l-animation {
|
|
2802
2807
|
0%, 100% {transform: translate3d(0, 0, 0);}
|
|
2803
2808
|
50% {transform: translate3d(-50px, 0, 0);}
|
|
@@ -2827,118 +2832,120 @@ const pe = "readium-column-snapper-style", mi = 200, P = class P extends st {
|
|
|
2827
2832
|
* {
|
|
2828
2833
|
scrollbar-width: none; /* for Firefox */
|
|
2829
2834
|
}
|
|
2830
|
-
|
|
2835
|
+
|
|
2831
2836
|
body::-webkit-scrollbar {
|
|
2832
2837
|
display: none; /* for Chrome, Safari, and Opera */
|
|
2833
2838
|
}
|
|
2834
2839
|
`, t.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
|
|
2835
2840
|
t.requestAnimationFrame(() => {
|
|
2836
|
-
t &&
|
|
2841
|
+
t && be(t);
|
|
2837
2842
|
}), this.onWidthChange();
|
|
2838
|
-
}), this.resizeObserver.observe(t.document.body), this.mutationObserver = new MutationObserver((
|
|
2839
|
-
for (const
|
|
2840
|
-
if (
|
|
2841
|
-
const
|
|
2842
|
-
(!
|
|
2843
|
-
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);
|
|
2844
2849
|
}), this.onWidthChange());
|
|
2845
2850
|
} else
|
|
2846
2851
|
t.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth);
|
|
2847
|
-
}), 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",
|
|
2848
|
-
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);
|
|
2849
2854
|
});
|
|
2850
|
-
const s = (
|
|
2851
|
-
const
|
|
2852
|
-
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;
|
|
2853
2861
|
};
|
|
2854
|
-
return t.addEventListener("orientationchange", this.onWidthChanger), t.addEventListener("resize", this.onWidthChanger), t.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), e.register("go_progression",
|
|
2855
|
-
const
|
|
2856
|
-
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) {
|
|
2857
2865
|
e.send("error", {
|
|
2858
2866
|
message: "go_progression must be given a position from 0.0 to 1.0"
|
|
2859
|
-
}),
|
|
2867
|
+
}), a(!1);
|
|
2860
2868
|
return;
|
|
2861
2869
|
}
|
|
2862
2870
|
this.wnd.requestAnimationFrame(() => {
|
|
2863
2871
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2864
|
-
const
|
|
2865
|
-
this.doc().scrollLeft = this.snapOffset(u), this.reportProgress(),
|
|
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);
|
|
2866
2874
|
});
|
|
2867
|
-
}), e.register("go_id",
|
|
2868
|
-
const
|
|
2869
|
-
if (!
|
|
2870
|
-
|
|
2875
|
+
}), e.register("go_id", T.moduleName, (o, a) => {
|
|
2876
|
+
const c = t.document.getElementById(o);
|
|
2877
|
+
if (!c) {
|
|
2878
|
+
a(!1);
|
|
2871
2879
|
return;
|
|
2872
2880
|
}
|
|
2873
2881
|
this.wnd.requestAnimationFrame(() => {
|
|
2874
|
-
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);
|
|
2875
2883
|
});
|
|
2876
|
-
}), e.register("go_text",
|
|
2877
|
-
let
|
|
2878
|
-
Array.isArray(
|
|
2879
|
-
const d = _.deserialize(
|
|
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({
|
|
2880
2888
|
href: t.location.href,
|
|
2881
2889
|
type: "text/html",
|
|
2882
2890
|
text: d,
|
|
2883
|
-
locations:
|
|
2891
|
+
locations: c ? new C({
|
|
2884
2892
|
otherLocations: /* @__PURE__ */ new Map([
|
|
2885
|
-
["cssSelector",
|
|
2893
|
+
["cssSelector", c]
|
|
2886
2894
|
])
|
|
2887
2895
|
}) : void 0
|
|
2888
2896
|
}));
|
|
2889
|
-
if (!
|
|
2890
|
-
|
|
2897
|
+
if (!u) {
|
|
2898
|
+
a(!1);
|
|
2891
2899
|
return;
|
|
2892
2900
|
}
|
|
2893
2901
|
this.wnd.requestAnimationFrame(() => {
|
|
2894
|
-
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);
|
|
2895
2903
|
});
|
|
2896
|
-
}), e.register("go_end",
|
|
2897
|
-
const a = H(t) ? -1 : 1;
|
|
2904
|
+
}), e.register("go_end", T.moduleName, (o, a) => {
|
|
2898
2905
|
this.wnd.requestAnimationFrame(() => {
|
|
2899
2906
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2900
|
-
|
|
2901
|
-
if (this.doc().scrollLeft ===
|
|
2902
|
-
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);
|
|
2903
2910
|
});
|
|
2904
|
-
}), e.register("go_start",
|
|
2911
|
+
}), e.register("go_start", T.moduleName, (o, a) => {
|
|
2905
2912
|
this.wnd.requestAnimationFrame(() => {
|
|
2906
|
-
if (this.doc().scrollLeft === 0) return
|
|
2907
|
-
this.doc().scrollLeft = 0, this.reportProgress(),
|
|
2913
|
+
if (this.doc().scrollLeft === 0) return a(!1);
|
|
2914
|
+
this.doc().scrollLeft = 0, this.reportProgress(), A(this.wnd), a(!0);
|
|
2908
2915
|
});
|
|
2909
|
-
}), e.register("go_prev",
|
|
2916
|
+
}), e.register("go_prev", T.moduleName, (o, a) => {
|
|
2910
2917
|
this.wnd.requestAnimationFrame(() => {
|
|
2911
2918
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2912
|
-
|
|
2913
|
-
|
|
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);
|
|
2914
2921
|
});
|
|
2915
|
-
}), e.register("go_next",
|
|
2922
|
+
}), e.register("go_next", T.moduleName, (o, a) => {
|
|
2916
2923
|
this.wnd.requestAnimationFrame(() => {
|
|
2917
2924
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2918
|
-
|
|
2919
|
-
|
|
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);
|
|
2920
2927
|
});
|
|
2921
|
-
}), e.register("unfocus",
|
|
2922
|
-
this.snappingCancelled = !0,
|
|
2923
|
-
}), e.register("shake",
|
|
2924
|
-
this.shake(),
|
|
2925
|
-
}), 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) => {
|
|
2926
2933
|
this.wnd.requestAnimationFrame(() => {
|
|
2927
|
-
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);
|
|
2928
2935
|
});
|
|
2929
|
-
}), e.register("first_visible_locator",
|
|
2930
|
-
const
|
|
2931
|
-
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);
|
|
2932
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", () => {
|
|
2933
2940
|
}), e.log("ColumnSnapper Mounted"), !0;
|
|
2934
2941
|
}
|
|
2935
2942
|
unmount(t, e) {
|
|
2936
|
-
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);
|
|
2937
2944
|
}
|
|
2938
2945
|
};
|
|
2939
|
-
|
|
2940
|
-
let
|
|
2941
|
-
const
|
|
2946
|
+
T.moduleName = "column_snapper";
|
|
2947
|
+
let Lt = T;
|
|
2948
|
+
const we = "readium-scroll-snapper-style", P = class P extends K {
|
|
2942
2949
|
constructor() {
|
|
2943
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) => {
|
|
2944
2951
|
if (this.comms.ready && !this.isResizing) {
|
|
@@ -2984,16 +2991,16 @@ const me = "readium-scroll-snapper-style", N = class N extends st {
|
|
|
2984
2991
|
});
|
|
2985
2992
|
}
|
|
2986
2993
|
enableScrollProtection() {
|
|
2987
|
-
this.patternAnalyzer || (this.patternAnalyzer = new
|
|
2994
|
+
this.patternAnalyzer || (this.patternAnalyzer = new wt(Yt), this.isScrollProtectionEnabled = !0, this.comms?.log("Scroll protection enabled"));
|
|
2988
2995
|
}
|
|
2989
2996
|
mount(t, e) {
|
|
2990
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");
|
|
2991
2998
|
const i = t.document.createElement("style");
|
|
2992
|
-
return i.dataset.readium = "true", i.id =
|
|
2999
|
+
return i.dataset.readium = "true", i.id = we, i.textContent = `
|
|
2993
3000
|
* {
|
|
2994
3001
|
scrollbar-width: none; /* for Firefox */
|
|
2995
3002
|
}
|
|
2996
|
-
|
|
3003
|
+
|
|
2997
3004
|
body::-webkit-scrollbar {
|
|
2998
3005
|
display: none; /* for Chrome, Safari, and Opera */
|
|
2999
3006
|
}
|
|
@@ -3001,11 +3008,11 @@ const me = "readium-scroll-snapper-style", N = class N extends st {
|
|
|
3001
3008
|
this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {
|
|
3002
3009
|
this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();
|
|
3003
3010
|
}, 50);
|
|
3004
|
-
}), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc",
|
|
3005
|
-
|
|
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);
|
|
3006
3013
|
const s = this.doc().scrollTop;
|
|
3007
3014
|
s > 1 ? this.doc().scrollTop = s - 1 : this.doc().scrollTop = s + 1, this.doc().scrollTop = s;
|
|
3008
|
-
}), e.register("go_progression",
|
|
3015
|
+
}), e.register("go_progression", P.moduleName, (s, n) => {
|
|
3009
3016
|
const o = s;
|
|
3010
3017
|
if (o < 0 || o > 1) {
|
|
3011
3018
|
e.send("error", {
|
|
@@ -3014,64 +3021,64 @@ const me = "readium-scroll-snapper-style", N = class N extends st {
|
|
|
3014
3021
|
return;
|
|
3015
3022
|
}
|
|
3016
3023
|
this.wnd.requestAnimationFrame(() => {
|
|
3017
|
-
this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(),
|
|
3024
|
+
this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(), A(this.wnd), n(!0);
|
|
3018
3025
|
});
|
|
3019
|
-
}), e.register("go_id",
|
|
3026
|
+
}), e.register("go_id", P.moduleName, (s, n) => {
|
|
3020
3027
|
const o = t.document.getElementById(s);
|
|
3021
3028
|
if (!o) {
|
|
3022
3029
|
n(!1);
|
|
3023
3030
|
return;
|
|
3024
3031
|
}
|
|
3025
3032
|
this.wnd.requestAnimationFrame(() => {
|
|
3026
|
-
this.doc().scrollTop = o.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(),
|
|
3033
|
+
this.doc().scrollTop = o.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd), n(!0);
|
|
3027
3034
|
});
|
|
3028
|
-
}), e.register("go_text",
|
|
3035
|
+
}), e.register("go_text", P.moduleName, (s, n) => {
|
|
3029
3036
|
let o;
|
|
3030
3037
|
Array.isArray(s) && (s.length > 1 && (o = s[1]), s = s[0]);
|
|
3031
|
-
const a = _.deserialize(s),
|
|
3038
|
+
const a = _.deserialize(s), c = rt(this.wnd.document, new W({
|
|
3032
3039
|
href: t.location.href,
|
|
3033
3040
|
type: "text/html",
|
|
3034
3041
|
text: a,
|
|
3035
|
-
locations: o ? new
|
|
3042
|
+
locations: o ? new C({
|
|
3036
3043
|
otherLocations: /* @__PURE__ */ new Map([
|
|
3037
3044
|
["cssSelector", o]
|
|
3038
3045
|
])
|
|
3039
3046
|
}) : void 0
|
|
3040
3047
|
}));
|
|
3041
|
-
if (!
|
|
3048
|
+
if (!c) {
|
|
3042
3049
|
n(!1);
|
|
3043
3050
|
return;
|
|
3044
3051
|
}
|
|
3045
3052
|
this.wnd.requestAnimationFrame(() => {
|
|
3046
|
-
this.doc().scrollTop =
|
|
3053
|
+
this.doc().scrollTop = c.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd), n(!0);
|
|
3047
3054
|
});
|
|
3048
|
-
}), e.register("go_start",
|
|
3055
|
+
}), e.register("go_start", P.moduleName, (s, n) => {
|
|
3049
3056
|
if (this.doc().scrollTop === 0) return n(!1);
|
|
3050
3057
|
this.doc().scrollTop = 0, this.reportProgress(), n(!0);
|
|
3051
|
-
}), e.register("go_end",
|
|
3058
|
+
}), e.register("go_end", P.moduleName, (s, n) => {
|
|
3052
3059
|
if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return n(!1);
|
|
3053
3060
|
this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), n(!0);
|
|
3054
|
-
}), e.register("unfocus",
|
|
3055
|
-
|
|
3056
|
-
}), e.register("scroll_protection",
|
|
3061
|
+
}), e.register("unfocus", P.moduleName, (s, n) => {
|
|
3062
|
+
A(this.wnd), n(!0);
|
|
3063
|
+
}), e.register("scroll_protection", P.moduleName, (s, n) => {
|
|
3057
3064
|
this.enableScrollProtection(), n(!0);
|
|
3058
3065
|
}), e.register([
|
|
3059
3066
|
"go_next",
|
|
3060
3067
|
"go_prev"
|
|
3061
|
-
],
|
|
3068
|
+
], P.moduleName, (s, n) => n(!1)), e.register("focus", P.moduleName, (s, n) => {
|
|
3062
3069
|
this.reportProgress(), n(!0);
|
|
3063
|
-
}), e.register("first_visible_locator",
|
|
3064
|
-
const o =
|
|
3070
|
+
}), e.register("first_visible_locator", P.moduleName, (s, n) => {
|
|
3071
|
+
const o = vt(t, !0);
|
|
3065
3072
|
this.comms.send("first_visible_locator", o.serialize()), n(!0);
|
|
3066
3073
|
}), e.log("ScrollSnapper Mounted"), !0;
|
|
3067
3074
|
}
|
|
3068
3075
|
unmount(t, e) {
|
|
3069
|
-
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;
|
|
3070
3077
|
}
|
|
3071
3078
|
};
|
|
3072
|
-
|
|
3073
|
-
let
|
|
3074
|
-
const
|
|
3079
|
+
P.moduleName = "scroll_snapper";
|
|
3080
|
+
let Ot = P;
|
|
3081
|
+
const N = class N extends K {
|
|
3075
3082
|
constructor() {
|
|
3076
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) => {
|
|
3077
3084
|
if (this.comms.ready && !this.isResizing) {
|
|
@@ -3117,18 +3124,18 @@ const L = class L extends st {
|
|
|
3117
3124
|
});
|
|
3118
3125
|
}
|
|
3119
3126
|
enableScrollProtection() {
|
|
3120
|
-
this.patternAnalyzer || (this.patternAnalyzer = new
|
|
3127
|
+
this.patternAnalyzer || (this.patternAnalyzer = new wt(Yt), this.isScrollProtectionEnabled = !0, this.comms?.log("Scroll protection enabled"));
|
|
3121
3128
|
}
|
|
3122
3129
|
mount(t, e) {
|
|
3123
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(() => {
|
|
3124
3131
|
this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {
|
|
3125
3132
|
this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();
|
|
3126
3133
|
}, 50);
|
|
3127
|
-
}), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc",
|
|
3128
|
-
|
|
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);
|
|
3129
3136
|
const i = this.doc().scrollTop;
|
|
3130
3137
|
i > 1 ? this.doc().scrollTop = i - 1 : this.doc().scrollTop = i + 1, this.doc().scrollTop = i;
|
|
3131
|
-
}), e.register("go_progression",
|
|
3138
|
+
}), e.register("go_progression", N.moduleName, (i, s) => {
|
|
3132
3139
|
const n = i;
|
|
3133
3140
|
if (n < 0 || n > 1) {
|
|
3134
3141
|
e.send("error", {
|
|
@@ -3137,25 +3144,25 @@ const L = class L extends st {
|
|
|
3137
3144
|
return;
|
|
3138
3145
|
}
|
|
3139
3146
|
this.wnd.requestAnimationFrame(() => {
|
|
3140
|
-
this.doc().scrollTop = this.doc().offsetHeight * n, this.reportProgress(),
|
|
3147
|
+
this.doc().scrollTop = this.doc().offsetHeight * n, this.reportProgress(), A(this.wnd), s(!0);
|
|
3141
3148
|
});
|
|
3142
|
-
}), e.register("go_id",
|
|
3149
|
+
}), e.register("go_id", N.moduleName, (i, s) => {
|
|
3143
3150
|
const n = t.document.getElementById(i);
|
|
3144
3151
|
if (!n) {
|
|
3145
3152
|
s(!1);
|
|
3146
3153
|
return;
|
|
3147
3154
|
}
|
|
3148
3155
|
this.wnd.requestAnimationFrame(() => {
|
|
3149
|
-
this.doc().scrollTop = n.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(),
|
|
3156
|
+
this.doc().scrollTop = n.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd), s(!0);
|
|
3150
3157
|
});
|
|
3151
|
-
}), e.register("go_text",
|
|
3158
|
+
}), e.register("go_text", N.moduleName, (i, s) => {
|
|
3152
3159
|
let n;
|
|
3153
3160
|
Array.isArray(i) && (i.length > 1 && (n = i[1]), i = i[0]);
|
|
3154
|
-
const o = _.deserialize(i), a =
|
|
3161
|
+
const o = _.deserialize(i), a = rt(this.wnd.document, new W({
|
|
3155
3162
|
href: t.location.href,
|
|
3156
3163
|
type: "text/html",
|
|
3157
3164
|
text: o,
|
|
3158
|
-
locations: n ? new
|
|
3165
|
+
locations: n ? new C({
|
|
3159
3166
|
otherLocations: /* @__PURE__ */ new Map([
|
|
3160
3167
|
["cssSelector", n]
|
|
3161
3168
|
])
|
|
@@ -3166,35 +3173,35 @@ const L = class L extends st {
|
|
|
3166
3173
|
return;
|
|
3167
3174
|
}
|
|
3168
3175
|
this.wnd.requestAnimationFrame(() => {
|
|
3169
|
-
this.doc().scrollTop = a.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(),
|
|
3176
|
+
this.doc().scrollTop = a.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), A(this.wnd), s(!0);
|
|
3170
3177
|
});
|
|
3171
|
-
}), e.register("go_start",
|
|
3178
|
+
}), e.register("go_start", N.moduleName, (i, s) => {
|
|
3172
3179
|
if (this.doc().scrollTop === 0) return s(!1);
|
|
3173
3180
|
this.doc().scrollTop = 0, this.reportProgress(), s(!0);
|
|
3174
|
-
}), e.register("go_end",
|
|
3181
|
+
}), e.register("go_end", N.moduleName, (i, s) => {
|
|
3175
3182
|
if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return s(!1);
|
|
3176
3183
|
this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), s(!0);
|
|
3177
|
-
}), e.register("unfocus",
|
|
3178
|
-
|
|
3179
|
-
}), e.register("scroll_protection",
|
|
3184
|
+
}), e.register("unfocus", N.moduleName, (i, s) => {
|
|
3185
|
+
A(this.wnd), s(!0);
|
|
3186
|
+
}), e.register("scroll_protection", N.moduleName, (i, s) => {
|
|
3180
3187
|
this.enableScrollProtection(), s(!0);
|
|
3181
3188
|
}), e.register([
|
|
3182
3189
|
"go_next",
|
|
3183
3190
|
"go_prev"
|
|
3184
|
-
],
|
|
3191
|
+
], N.moduleName, (i, s) => s(!1)), e.register("focus", N.moduleName, (i, s) => {
|
|
3185
3192
|
this.reportProgress(), s(!0);
|
|
3186
|
-
}), e.register("first_visible_locator",
|
|
3187
|
-
const n =
|
|
3193
|
+
}), e.register("first_visible_locator", N.moduleName, (i, s) => {
|
|
3194
|
+
const n = vt(t, !0);
|
|
3188
3195
|
e.send("first_visible_locator", n.serialize()), s(!0);
|
|
3189
3196
|
}), e.log("WebPubSnapper Mounted"), !0;
|
|
3190
3197
|
}
|
|
3191
3198
|
unmount(t, e) {
|
|
3192
|
-
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;
|
|
3193
3200
|
}
|
|
3194
3201
|
};
|
|
3195
|
-
|
|
3196
|
-
let
|
|
3197
|
-
class
|
|
3202
|
+
N.moduleName = "webpub_snapper";
|
|
3203
|
+
let Rt = N;
|
|
3204
|
+
class wi {
|
|
3198
3205
|
constructor(t, e) {
|
|
3199
3206
|
this.window = t, this.copyHistory = [], this.lastSelectionLength = 0, this.lastSelectionTime = 0, this.options = e;
|
|
3200
3207
|
}
|
|
@@ -3220,10 +3227,10 @@ class fi {
|
|
|
3220
3227
|
length: s,
|
|
3221
3228
|
wasBlocked: !1
|
|
3222
3229
|
}), !0;
|
|
3223
|
-
const
|
|
3230
|
+
const c = o - this.lastSelectionTime < 100 && s > this.lastSelectionLength * 1.5, d = Math.min(
|
|
3224
3231
|
n * this.options.maxSelectionPercent,
|
|
3225
3232
|
this.options.absoluteMaxChars
|
|
3226
|
-
), u = this.isSuspiciousPattern(o), g = s >
|
|
3233
|
+
), u = this.isSuspiciousPattern(o), g = s > d || c || u;
|
|
3227
3234
|
return this.copyHistory.push({
|
|
3228
3235
|
timestamp: o,
|
|
3229
3236
|
length: s,
|
|
@@ -3234,8 +3241,8 @@ class fi {
|
|
|
3234
3241
|
this.lastSelectionLength = 0, this.lastSelectionTime = 0, this.copyHistory = [], this.options.enabled = !1;
|
|
3235
3242
|
}
|
|
3236
3243
|
}
|
|
3237
|
-
class
|
|
3238
|
-
constructor(t =
|
|
3244
|
+
class Si {
|
|
3245
|
+
constructor(t = We) {
|
|
3239
3246
|
this.options = t, this.events = [], this.selectionStartTime = 0, this.lastSelectionTime = 0, this.lastSelectionPosition = 0, this.selectionPatterns = [], this.lastSelectedText = "";
|
|
3240
3247
|
}
|
|
3241
3248
|
analyze(t) {
|
|
@@ -3261,8 +3268,8 @@ class gi {
|
|
|
3261
3268
|
if (!t.rangeCount) return !1;
|
|
3262
3269
|
const i = t.getRangeAt(0), s = i.toString(), n = (e - this.selectionStartTime) / 1e3;
|
|
3263
3270
|
if (s.length / Math.max(1, n) > this.options.maxSelectionsPerSecond) return !0;
|
|
3264
|
-
const a = i.startOffset,
|
|
3265
|
-
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);
|
|
3266
3273
|
}
|
|
3267
3274
|
calculateVariance(t) {
|
|
3268
3275
|
if (t.length === 0) return 0;
|
|
@@ -3276,14 +3283,14 @@ class gi {
|
|
|
3276
3283
|
this.events = [], this.selectionStartTime = 0, this.lastSelectionTime = 0, this.lastSelectionPosition = 0, this.selectionPatterns = [], this.lastSelectedText = "";
|
|
3277
3284
|
}
|
|
3278
3285
|
}
|
|
3279
|
-
class
|
|
3286
|
+
class Ei {
|
|
3280
3287
|
/**
|
|
3281
3288
|
* Checks if the given keyboard event matches any of the provided key combinations
|
|
3282
3289
|
*/
|
|
3283
3290
|
match(t, e) {
|
|
3284
3291
|
for (const i of e) {
|
|
3285
|
-
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,
|
|
3286
|
-
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)
|
|
3287
3294
|
return !0;
|
|
3288
3295
|
}
|
|
3289
3296
|
return !1;
|
|
@@ -3302,13 +3309,13 @@ class yi {
|
|
|
3302
3309
|
createActivityEvent(t, e, i, s) {
|
|
3303
3310
|
let n;
|
|
3304
3311
|
if (s) {
|
|
3305
|
-
const o = s.getSelection(), a = o?.toString() || "",
|
|
3306
|
-
|
|
3312
|
+
const o = s.getSelection(), a = o?.toString() || "", d = (a && o?.rangeCount ? o.getRangeAt(0)?.getClientRects() : null)?.[0];
|
|
3313
|
+
d && a && (n = {
|
|
3307
3314
|
text: a,
|
|
3308
|
-
x:
|
|
3309
|
-
y:
|
|
3310
|
-
width:
|
|
3311
|
-
height:
|
|
3315
|
+
x: d.x,
|
|
3316
|
+
y: d.y,
|
|
3317
|
+
width: d.width,
|
|
3318
|
+
height: d.height
|
|
3312
3319
|
});
|
|
3313
3320
|
}
|
|
3314
3321
|
return {
|
|
@@ -3333,8 +3340,8 @@ class yi {
|
|
|
3333
3340
|
return e.forEach((o) => {
|
|
3334
3341
|
n.push(...o.keyCombos.map((a) => ({
|
|
3335
3342
|
...a,
|
|
3336
|
-
handler: (
|
|
3337
|
-
const
|
|
3343
|
+
handler: (c) => {
|
|
3344
|
+
const d = o.type, u = this.createActivityEvent(c, d, t, s);
|
|
3338
3345
|
i(u);
|
|
3339
3346
|
}
|
|
3340
3347
|
})));
|
|
@@ -3354,9 +3361,9 @@ class yi {
|
|
|
3354
3361
|
};
|
|
3355
3362
|
}
|
|
3356
3363
|
}
|
|
3357
|
-
const
|
|
3364
|
+
const q = class q extends Z {
|
|
3358
3365
|
constructor() {
|
|
3359
|
-
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) => {
|
|
3360
3367
|
if (!this.isBulkCopyProtectionEnabled || !this.bulkCopyProtector)
|
|
3361
3368
|
return !0;
|
|
3362
3369
|
if (!this.bulkCopyProtector.shouldAllowCopy(t)) {
|
|
@@ -3384,7 +3391,7 @@ const $ = class $ extends X {
|
|
|
3384
3391
|
const e = this.wnd.getSelection();
|
|
3385
3392
|
if (e) {
|
|
3386
3393
|
if (this.currentSelection = e.toString(), this.selectionAnalyzer.analyze(e) && this.currentSelection) {
|
|
3387
|
-
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 = {
|
|
3388
3395
|
type: "suspicious_selection",
|
|
3389
3396
|
timestamp: Date.now(),
|
|
3390
3397
|
selectionLength: n.length,
|
|
@@ -3398,10 +3405,12 @@ const $ = class $ extends X {
|
|
|
3398
3405
|
eventType: t?.type || "selectionchange",
|
|
3399
3406
|
targetFrameSrc: this.wnd.location.href
|
|
3400
3407
|
};
|
|
3401
|
-
this.comms?.send("content_protection",
|
|
3408
|
+
this.comms?.send("content_protection", c);
|
|
3402
3409
|
}
|
|
3403
3410
|
} else
|
|
3404
3411
|
this.currentSelection = null;
|
|
3412
|
+
}, this.onDragOver = (t) => {
|
|
3413
|
+
this.isDragAndDropEnabled && (t.preventDefault(), t.stopPropagation());
|
|
3405
3414
|
}, this.onDragStart = (t) => {
|
|
3406
3415
|
if (this.isDragAndDropEnabled) {
|
|
3407
3416
|
t.preventDefault();
|
|
@@ -3456,10 +3465,10 @@ const $ = class $ extends X {
|
|
|
3456
3465
|
!this.isContextMenuEnabled || !this.wnd || (this.wnd.document.removeEventListener("contextmenu", this.onContext), this.isContextMenuEnabled = !1);
|
|
3457
3466
|
}
|
|
3458
3467
|
addDragAndDropPrevention() {
|
|
3459
|
-
this.isDragAndDropEnabled || !this.wnd || (this.wnd.document.addEventListener("dragstart", this.onDragStart), this.wnd.document.addEventListener("drop", this.onDrop), this.isDragAndDropEnabled = !0);
|
|
3468
|
+
this.isDragAndDropEnabled || !this.wnd || (this.wnd.document.addEventListener("dragstart", this.onDragStart), this.wnd.document.addEventListener("dragover", this.onDragOver), this.wnd.document.addEventListener("drop", this.onDrop), this.isDragAndDropEnabled = !0);
|
|
3460
3469
|
}
|
|
3461
3470
|
removeDragAndDropPrevention() {
|
|
3462
|
-
!this.isDragAndDropEnabled || !this.wnd || (this.wnd.document.removeEventListener("dragstart", this.onDragStart), this.wnd.document.removeEventListener("drop", this.onDrop), this.isDragAndDropEnabled = !1);
|
|
3471
|
+
!this.isDragAndDropEnabled || !this.wnd || (this.wnd.document.removeEventListener("dragstart", this.onDragStart), this.wnd.document.removeEventListener("dragover", this.onDragOver), this.wnd.document.removeEventListener("drop", this.onDrop), this.isDragAndDropEnabled = !1);
|
|
3463
3472
|
}
|
|
3464
3473
|
enableKeyboardPeripherals(t = []) {
|
|
3465
3474
|
this.disableKeyboardPeripherals();
|
|
@@ -3477,16 +3486,16 @@ const $ = class $ extends X {
|
|
|
3477
3486
|
}
|
|
3478
3487
|
addBulkCopyProtection(t = {}) {
|
|
3479
3488
|
if (this.isBulkCopyProtectionEnabled || !this.wnd) return;
|
|
3480
|
-
const e =
|
|
3481
|
-
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;
|
|
3482
3491
|
}
|
|
3483
3492
|
removeBulkCopyProtection() {
|
|
3484
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);
|
|
3485
3494
|
}
|
|
3486
3495
|
addSelectionMonitoring(t) {
|
|
3487
3496
|
if (this.isSelectionMonitoringEnabled || !this.wnd) return;
|
|
3488
|
-
const e = t ||
|
|
3489
|
-
this.selectionAnalyzer = new
|
|
3497
|
+
const e = t || We;
|
|
3498
|
+
this.selectionAnalyzer = new Si(e), this.wnd.document.addEventListener("selectionchange", this.handleSelection), this.isSelectionMonitoringEnabled = !0;
|
|
3490
3499
|
}
|
|
3491
3500
|
removeSelectionMonitoring() {
|
|
3492
3501
|
!this.isSelectionMonitoringEnabled || !this.wnd || (this.wnd.document.removeEventListener("selectionchange", this.handleSelection), this.selectionAnalyzer?.clear(), this.selectionAnalyzer = null, this.isSelectionMonitoringEnabled = !1);
|
|
@@ -3519,7 +3528,7 @@ const $ = class $ extends X {
|
|
|
3519
3528
|
y: t.clientY * i,
|
|
3520
3529
|
targetFrameSrc: this.wnd.location.href,
|
|
3521
3530
|
targetElement: t.target.outerHTML,
|
|
3522
|
-
interactiveElement:
|
|
3531
|
+
interactiveElement: Me(t.target)?.outerHTML,
|
|
3523
3532
|
cssSelector: this.wnd._readium_cssSelectorGenerator.getCssSelector(t.target)
|
|
3524
3533
|
}), this.pointerMoved = !1;
|
|
3525
3534
|
}
|
|
@@ -3546,7 +3555,7 @@ const $ = class $ extends X {
|
|
|
3546
3555
|
}
|
|
3547
3556
|
}
|
|
3548
3557
|
registerProtectionHandlers() {
|
|
3549
|
-
this.comms?.register("peripherals_protection",
|
|
3558
|
+
this.comms?.register("peripherals_protection", q.moduleName, (t, e) => {
|
|
3550
3559
|
const i = t;
|
|
3551
3560
|
if (!this.configApplied) {
|
|
3552
3561
|
if (this.configApplied = !0, i.monitorSelection) {
|
|
@@ -3564,7 +3573,7 @@ const $ = class $ extends X {
|
|
|
3564
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"));
|
|
3565
3574
|
}
|
|
3566
3575
|
e(!0);
|
|
3567
|
-
}), this.comms?.register("keyboard_peripherals",
|
|
3576
|
+
}), this.comms?.register("keyboard_peripherals", q.moduleName, (t, e) => {
|
|
3568
3577
|
const i = t;
|
|
3569
3578
|
i && i.length > 0 && (this.enableKeyboardPeripherals(i), this.comms?.log(`Keyboard peripherals enabled: ${i.map((s) => s.type).join(", ")}`)), e(!0);
|
|
3570
3579
|
});
|
|
@@ -3573,12 +3582,12 @@ const $ = class $ extends X {
|
|
|
3573
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;
|
|
3574
3583
|
}
|
|
3575
3584
|
unmount(t, e) {
|
|
3576
|
-
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;
|
|
3577
3586
|
}
|
|
3578
3587
|
};
|
|
3579
|
-
|
|
3580
|
-
let
|
|
3581
|
-
const
|
|
3588
|
+
q.moduleName = "peripherals";
|
|
3589
|
+
let Dt = q;
|
|
3590
|
+
const it = class it extends Z {
|
|
3582
3591
|
constructor() {
|
|
3583
3592
|
super(...arguments), this.mediaPlayingCount = 0, this.allAnimations = /* @__PURE__ */ new Set();
|
|
3584
3593
|
}
|
|
@@ -3628,7 +3637,7 @@ const tt = class tt extends X {
|
|
|
3628
3637
|
), Reflect.defineProperty(t.navigator, "epubReadingSystem", {
|
|
3629
3638
|
value: {
|
|
3630
3639
|
name: "readium-ts-toolkit",
|
|
3631
|
-
version: "2.
|
|
3640
|
+
version: "2.4.0-beta.1",
|
|
3632
3641
|
hasFeature: (s, n = "") => {
|
|
3633
3642
|
switch (s) {
|
|
3634
3643
|
case "dom-manipulation":
|
|
@@ -3653,11 +3662,11 @@ const tt = class tt extends X {
|
|
|
3653
3662
|
writable: !1
|
|
3654
3663
|
}), "getAnimations" in t.document && t.document.getAnimations().forEach((s) => {
|
|
3655
3664
|
s.cancel(), this.allAnimations.add(s);
|
|
3656
|
-
}), e.register("activate",
|
|
3665
|
+
}), e.register("activate", it.moduleName, (s, n) => {
|
|
3657
3666
|
this.allAnimations.forEach((o) => {
|
|
3658
3667
|
o.cancel(), o.play();
|
|
3659
3668
|
}), n(!0);
|
|
3660
|
-
}), e.register("unfocus",
|
|
3669
|
+
}), e.register("unfocus", it.moduleName, (s, n) => {
|
|
3661
3670
|
this.pauseAllMedia(t), this.allAnimations.forEach((o) => o.pause()), n(!0);
|
|
3662
3671
|
});
|
|
3663
3672
|
const i = t.document.querySelectorAll("audio,video");
|
|
@@ -3675,46 +3684,46 @@ const tt = class tt extends X {
|
|
|
3675
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;
|
|
3676
3685
|
}
|
|
3677
3686
|
};
|
|
3678
|
-
|
|
3679
|
-
let
|
|
3680
|
-
const
|
|
3687
|
+
it.moduleName = "setup";
|
|
3688
|
+
let yt = it;
|
|
3689
|
+
const Se = "readium-viewport", U = class U extends yt {
|
|
3681
3690
|
onViewportWidthChanged(t) {
|
|
3682
3691
|
const e = t.target;
|
|
3683
|
-
|
|
3692
|
+
nt(e, "--RS__viewportWidth", `${e.innerWidth}px`);
|
|
3684
3693
|
}
|
|
3685
3694
|
mount(t, e) {
|
|
3686
3695
|
if (!super.mount(t, e)) return !1;
|
|
3687
3696
|
const i = t.document.createElement("meta");
|
|
3688
|
-
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(
|
|
3689
3698
|
"content",
|
|
3690
3699
|
"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"
|
|
3691
3700
|
), t.document.head.appendChild(i), t.addEventListener("orientationchange", this.onViewportWidthChanged), t.addEventListener("resize", this.onViewportWidthChanged), this.onViewportWidthChanged({
|
|
3692
3701
|
target: t
|
|
3693
|
-
}), e.register("get_properties",
|
|
3694
|
-
|
|
3695
|
-
}), e.register("update_properties",
|
|
3696
|
-
s["--RS__viewportWidth"] = `${t.innerWidth}px`,
|
|
3697
|
-
}), 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) => {
|
|
3698
3707
|
const o = s;
|
|
3699
|
-
|
|
3700
|
-
}), e.register("remove_property",
|
|
3701
|
-
|
|
3702
|
-
}), 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) => {
|
|
3703
3712
|
this.unblock(t), n(!0);
|
|
3704
3713
|
}), e.log("ReflowableSetup Mounted"), !0;
|
|
3705
3714
|
}
|
|
3706
3715
|
unmount(t, e) {
|
|
3707
|
-
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);
|
|
3708
3717
|
}
|
|
3709
3718
|
};
|
|
3710
|
-
|
|
3711
|
-
let
|
|
3712
|
-
const
|
|
3719
|
+
U.moduleName = "reflowable_setup";
|
|
3720
|
+
let It = U;
|
|
3721
|
+
const Ee = "readium-fixed-style", M = class M extends yt {
|
|
3713
3722
|
mount(t, e) {
|
|
3714
3723
|
if (!super.mount(t, e)) return !1;
|
|
3715
3724
|
t.navigator.epubReadingSystem && (t.navigator.epubReadingSystem.layoutStyle = "paginated");
|
|
3716
3725
|
const i = t.document.createElement("style");
|
|
3717
|
-
return i.id =
|
|
3726
|
+
return i.id = Ee, i.dataset.readium = "true", i.textContent = `
|
|
3718
3727
|
html, body {
|
|
3719
3728
|
text-size-adjust: none;
|
|
3720
3729
|
-ms-text-size-adjust: none;
|
|
@@ -3726,13 +3735,13 @@ const ge = "readium-fixed-style", D = class D extends ut {
|
|
|
3726
3735
|
min-height: 100%;
|
|
3727
3736
|
|
|
3728
3737
|
/*cursor: var() TODO*/
|
|
3729
|
-
}`, t.document.head.appendChild(i), e.register("set_property",
|
|
3738
|
+
}`, t.document.head.appendChild(i), e.register("set_property", M.moduleName, (s, n) => {
|
|
3730
3739
|
const o = s;
|
|
3731
|
-
|
|
3732
|
-
}), e.register("remove_property",
|
|
3733
|
-
|
|
3734
|
-
}), e.register("first_visible_locator",
|
|
3735
|
-
|
|
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) => {
|
|
3744
|
+
A(t), n(!0);
|
|
3736
3745
|
}), e.register([
|
|
3737
3746
|
"focus",
|
|
3738
3747
|
"go_next",
|
|
@@ -3742,17 +3751,17 @@ const ge = "readium-fixed-style", D = class D extends ut {
|
|
|
3742
3751
|
"go_start",
|
|
3743
3752
|
"go_text",
|
|
3744
3753
|
"go_progression"
|
|
3745
|
-
],
|
|
3754
|
+
], M.moduleName, (s, n) => n(!0)), e.register("activate", M.moduleName, (s, n) => {
|
|
3746
3755
|
this.unblock(t), n(!0);
|
|
3747
3756
|
}), e.log("FixedSetup Mounted"), !0;
|
|
3748
3757
|
}
|
|
3749
3758
|
unmount(t, e) {
|
|
3750
|
-
return e.unregisterAll(
|
|
3759
|
+
return e.unregisterAll(M.moduleName), t.document.getElementById(Ee)?.remove(), e.log("FixedSetup Unmounted"), super.unmount(t, e);
|
|
3751
3760
|
}
|
|
3752
3761
|
};
|
|
3753
|
-
|
|
3754
|
-
let
|
|
3755
|
-
const
|
|
3762
|
+
M.moduleName = "fixed_setup";
|
|
3763
|
+
let zt = M;
|
|
3764
|
+
const B = class B extends Z {
|
|
3756
3765
|
wndOnErr(t) {
|
|
3757
3766
|
this.comms?.send("error", {
|
|
3758
3767
|
message: t.message,
|
|
@@ -3766,26 +3775,26 @@ const k = class k extends X {
|
|
|
3766
3775
|
"error",
|
|
3767
3776
|
this.wndOnErr,
|
|
3768
3777
|
!1
|
|
3769
|
-
), e.register("get_properties",
|
|
3770
|
-
|
|
3771
|
-
}), e.register("update_properties",
|
|
3772
|
-
|
|
3773
|
-
}), 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) => {
|
|
3774
3783
|
const n = i;
|
|
3775
|
-
|
|
3776
|
-
}), e.register("remove_property",
|
|
3777
|
-
|
|
3778
|
-
}), 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) => {
|
|
3779
3788
|
s(!0);
|
|
3780
3789
|
}), e.log("WebPubSetup Mounted"), !0;
|
|
3781
3790
|
}
|
|
3782
3791
|
unmount(t, e) {
|
|
3783
|
-
return e.unregisterAll(
|
|
3792
|
+
return e.unregisterAll(B.moduleName), t.removeEventListener("error", this.wndOnErr), e.log("WebPubSetup Unmounted"), !0;
|
|
3784
3793
|
}
|
|
3785
3794
|
};
|
|
3786
|
-
|
|
3787
|
-
let
|
|
3788
|
-
const
|
|
3795
|
+
B.moduleName = "webpub_setup";
|
|
3796
|
+
let Mt = B;
|
|
3797
|
+
const st = class st extends Z {
|
|
3789
3798
|
constructor() {
|
|
3790
3799
|
super(...arguments), this.styleElement = null, this.beforePrintHandler = null, this.configApplied = !1;
|
|
3791
3800
|
}
|
|
@@ -3809,7 +3818,7 @@ const et = class et extends X {
|
|
|
3809
3818
|
`, t.document.head.appendChild(i), this.styleElement = i, this.beforePrintHandler = (s) => (s.preventDefault(), !1), t.addEventListener("beforeprint", this.beforePrintHandler);
|
|
3810
3819
|
}
|
|
3811
3820
|
registerPrintHandlers() {
|
|
3812
|
-
this.comms?.register("print_protection",
|
|
3821
|
+
this.comms?.register("print_protection", st.moduleName, (t) => {
|
|
3813
3822
|
const e = t;
|
|
3814
3823
|
return this.configApplied || (this.configApplied = !0, this.setupPrintProtection(this.wnd, e), this.comms?.log("Print protection configuration applied")), !0;
|
|
3815
3824
|
});
|
|
@@ -3818,48 +3827,190 @@ const et = class et extends X {
|
|
|
3818
3827
|
return this.wnd = t, this.comms = e, this.registerPrintHandlers(), !0;
|
|
3819
3828
|
}
|
|
3820
3829
|
unmount(t, e) {
|
|
3821
|
-
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;
|
|
3822
3831
|
}
|
|
3823
3832
|
};
|
|
3824
|
-
|
|
3825
|
-
let
|
|
3826
|
-
const
|
|
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;
|
|
3971
|
+
}
|
|
3972
|
+
};
|
|
3973
|
+
L.moduleName = "cjk_vertical_snapper";
|
|
3974
|
+
let Wt = L;
|
|
3975
|
+
const Ai = [
|
|
3827
3976
|
"fixed_setup",
|
|
3828
3977
|
"decorator",
|
|
3829
3978
|
"peripherals",
|
|
3830
3979
|
"print_protection"
|
|
3831
|
-
],
|
|
3980
|
+
], Ci = [
|
|
3832
3981
|
"reflowable_setup",
|
|
3833
3982
|
"decorator",
|
|
3834
3983
|
"peripherals",
|
|
3835
3984
|
"column_snapper",
|
|
3836
3985
|
"scroll_snapper",
|
|
3986
|
+
"cjk_vertical_snapper",
|
|
3837
3987
|
"print_protection"
|
|
3838
|
-
],
|
|
3988
|
+
], xi = [
|
|
3839
3989
|
"webpub_setup",
|
|
3840
3990
|
"webpub_snapper",
|
|
3841
3991
|
"decorator",
|
|
3842
3992
|
"peripherals",
|
|
3843
3993
|
"print_protection"
|
|
3844
|
-
],
|
|
3994
|
+
], Ce = new Map([
|
|
3845
3995
|
// All modules go here
|
|
3846
|
-
|
|
3996
|
+
zt,
|
|
3997
|
+
It,
|
|
3998
|
+
Mt,
|
|
3999
|
+
Rt,
|
|
4000
|
+
Dt,
|
|
3847
4001
|
Nt,
|
|
4002
|
+
Lt,
|
|
3848
4003
|
Ot,
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
At,
|
|
3852
|
-
Ct,
|
|
3853
|
-
xt,
|
|
3854
|
-
Rt
|
|
4004
|
+
Wt,
|
|
4005
|
+
kt
|
|
3855
4006
|
].map((r) => [r.moduleName, r]));
|
|
3856
|
-
class
|
|
4007
|
+
class Ti {
|
|
3857
4008
|
/**
|
|
3858
4009
|
* @param wnd Window instance to operate on
|
|
3859
4010
|
* @param initialModules List of initial modules to load
|
|
3860
4011
|
*/
|
|
3861
4012
|
constructor(t = window, e = []) {
|
|
3862
|
-
this.loadedModules = [], this.wnd = t, this.comms = new
|
|
4013
|
+
this.loadedModules = [], this.wnd = t, this.comms = new He(t);
|
|
3863
4014
|
const i = [...new Set(e)];
|
|
3864
4015
|
if (i.length) {
|
|
3865
4016
|
if (typeof t > "u")
|
|
@@ -3872,7 +4023,7 @@ class Si {
|
|
|
3872
4023
|
}
|
|
3873
4024
|
}
|
|
3874
4025
|
loadModule(t) {
|
|
3875
|
-
const e =
|
|
4026
|
+
const e = Ce.get(t);
|
|
3876
4027
|
return e === void 0 ? (this.comms.log(`Module "${name}" does not exist in the library`), e) : new e();
|
|
3877
4028
|
}
|
|
3878
4029
|
/**
|
|
@@ -3890,7 +4041,7 @@ class Si {
|
|
|
3890
4041
|
* @returns Success
|
|
3891
4042
|
*/
|
|
3892
4043
|
removeModule(t) {
|
|
3893
|
-
const e =
|
|
4044
|
+
const e = Ce.get(t);
|
|
3894
4045
|
if (e === void 0)
|
|
3895
4046
|
return this.comms.log(`Module "${t}" does not exist in the library`), !1;
|
|
3896
4047
|
const i = this.loadedModules.findIndex((s) => s instanceof e);
|
|
@@ -3903,7 +4054,7 @@ class Si {
|
|
|
3903
4054
|
this.comms.destroy(), this.loadedModules.forEach((t) => t.unmount(this.wnd, this.comms)), this.loadedModules = [];
|
|
3904
4055
|
}
|
|
3905
4056
|
}
|
|
3906
|
-
const
|
|
4057
|
+
const Pi = {
|
|
3907
4058
|
type: "developer_tools",
|
|
3908
4059
|
keyCombos: [
|
|
3909
4060
|
{ keyCode: 73, meta: !0, alt: !0 },
|
|
@@ -3927,7 +4078,7 @@ const Ei = {
|
|
|
3927
4078
|
{ keyCode: 123, meta: !0, alt: !0 }
|
|
3928
4079
|
// F12+Meta+Alt
|
|
3929
4080
|
]
|
|
3930
|
-
},
|
|
4081
|
+
}, Ni = {
|
|
3931
4082
|
type: "select_all",
|
|
3932
4083
|
keyCombos: [
|
|
3933
4084
|
{ keyCode: 65, meta: !0 },
|
|
@@ -3935,7 +4086,7 @@ const Ei = {
|
|
|
3935
4086
|
{ keyCode: 65, ctrl: !0 }
|
|
3936
4087
|
// A key (Ctrl+A)
|
|
3937
4088
|
]
|
|
3938
|
-
},
|
|
4089
|
+
}, Li = {
|
|
3939
4090
|
type: "print",
|
|
3940
4091
|
keyCombos: [
|
|
3941
4092
|
{ keyCode: 80, meta: !0 },
|
|
@@ -3951,7 +4102,7 @@ const Ei = {
|
|
|
3951
4102
|
{ keyCode: 80, ctrl: !0, alt: !0 }
|
|
3952
4103
|
// P key (Ctrl+Alt+P)
|
|
3953
4104
|
]
|
|
3954
|
-
},
|
|
4105
|
+
}, Oi = {
|
|
3955
4106
|
type: "save",
|
|
3956
4107
|
keyCombos: [
|
|
3957
4108
|
{ keyCode: 83, meta: !0 },
|
|
@@ -3961,26 +4112,26 @@ const Ei = {
|
|
|
3961
4112
|
]
|
|
3962
4113
|
};
|
|
3963
4114
|
export {
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
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
|
|
3986
4137
|
};
|