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