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