@prose-reader/cfi 1.234.0 → 1.236.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/index.js +411 -416
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
function
|
|
2
|
-
const
|
|
3
|
-
let
|
|
4
|
-
for (;
|
|
5
|
-
|
|
6
|
-
return
|
|
7
|
-
}
|
|
8
|
-
function
|
|
9
|
-
if (e ===
|
|
10
|
-
const
|
|
11
|
-
let r =
|
|
1
|
+
function H(e) {
|
|
2
|
+
const n = [e];
|
|
3
|
+
let t = e;
|
|
4
|
+
for (; t.parentNode; )
|
|
5
|
+
n.push(t.parentNode), t = t.parentNode;
|
|
6
|
+
return n;
|
|
7
|
+
}
|
|
8
|
+
function U(e, n) {
|
|
9
|
+
if (e === n) return e;
|
|
10
|
+
const t = H(e), i = new Set(t);
|
|
11
|
+
let r = n;
|
|
12
12
|
for (; r; ) {
|
|
13
13
|
if (i.has(r))
|
|
14
14
|
return r;
|
|
@@ -16,349 +16,346 @@ function Q(e, t) {
|
|
|
16
16
|
}
|
|
17
17
|
return null;
|
|
18
18
|
}
|
|
19
|
-
const
|
|
20
|
-
function
|
|
21
|
-
return e.replace(
|
|
19
|
+
const G = /[[\]^,();]/g;
|
|
20
|
+
function p(e) {
|
|
21
|
+
return e.replace(G, "^$&");
|
|
22
22
|
}
|
|
23
|
-
const
|
|
24
|
-
function
|
|
25
|
-
if (
|
|
23
|
+
const J = /^epubcfi\((.*)\)$/, v = (e) => e.nodeType === Node.ELEMENT_NODE, P = (e) => typeof e == "object" && e !== null && "nodeType" in e && (e.nodeType === Node.ELEMENT_NODE || e.nodeType === Node.TEXT_NODE), K = (e) => e.nodeType === Node.TEXT_NODE;
|
|
24
|
+
function Q(e) {
|
|
25
|
+
if (F(e))
|
|
26
26
|
return !1;
|
|
27
|
-
const
|
|
28
|
-
return e.length > 1 && (
|
|
27
|
+
const n = e[e.length - 1];
|
|
28
|
+
return e.length > 1 && (n === void 0 || n.length === 0);
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function F(e) {
|
|
31
31
|
return e !== null && typeof e == "object" && "parent" in e && "start" in e && "end" in e;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
const
|
|
35
|
-
return
|
|
33
|
+
function Z(e) {
|
|
34
|
+
const n = e.match(J);
|
|
35
|
+
return n && n[1] || e;
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
const
|
|
39
|
-
let
|
|
40
|
-
const s = (
|
|
41
|
-
|
|
42
|
-
},
|
|
43
|
-
r +=
|
|
44
|
-
},
|
|
45
|
-
for (let
|
|
46
|
-
const o =
|
|
37
|
+
function ee(e) {
|
|
38
|
+
const n = [];
|
|
39
|
+
let t = null, i = !1, r = "";
|
|
40
|
+
const s = (f) => {
|
|
41
|
+
n.push(f), t = null, r = "";
|
|
42
|
+
}, l = (f) => {
|
|
43
|
+
r += f, i = !1;
|
|
44
|
+
}, a = Z(e).trim(), c = Array.from(a).concat("");
|
|
45
|
+
for (let f = 0; f < c.length; f++) {
|
|
46
|
+
const o = c[f];
|
|
47
47
|
if (!o) {
|
|
48
|
-
|
|
48
|
+
t === "/" || t === ":" ? s([t, parseInt(r, 10)]) : t === "~" ? s(["~", parseFloat(r)]) : t === "@" ? s(["@", parseFloat(r)]) : t === "[" ? s(["[", r]) : t === ";" || t?.startsWith(";") ? s([t, r]) : t === "!" && s(["!", 0]);
|
|
49
49
|
break;
|
|
50
50
|
}
|
|
51
51
|
if (o === "^" && !i) {
|
|
52
52
|
i = !0;
|
|
53
53
|
continue;
|
|
54
54
|
}
|
|
55
|
-
if (
|
|
55
|
+
if (t === "!")
|
|
56
56
|
s(["!", 0]);
|
|
57
|
-
else if (
|
|
57
|
+
else if (t === ",")
|
|
58
58
|
s([",", 0]);
|
|
59
|
-
else if (
|
|
59
|
+
else if (t === "/" || t === ":") {
|
|
60
60
|
if (/^\d$/.test(o)) {
|
|
61
|
-
|
|
61
|
+
l(o);
|
|
62
62
|
continue;
|
|
63
63
|
}
|
|
64
|
-
s([
|
|
65
|
-
} else if (
|
|
64
|
+
s([t, parseInt(r, 10)]);
|
|
65
|
+
} else if (t === "~") {
|
|
66
66
|
if (/^\d$/.test(o) || o === ".") {
|
|
67
|
-
|
|
67
|
+
l(o);
|
|
68
68
|
continue;
|
|
69
69
|
}
|
|
70
70
|
s(["~", parseFloat(r)]);
|
|
71
|
-
} else if (
|
|
71
|
+
} else if (t === "@") {
|
|
72
72
|
if (o === ":") {
|
|
73
|
-
s(["@", parseFloat(r)]),
|
|
73
|
+
s(["@", parseFloat(r)]), t = "@";
|
|
74
74
|
continue;
|
|
75
75
|
}
|
|
76
76
|
if (/^\d$/.test(o) || o === ".") {
|
|
77
|
-
|
|
77
|
+
l(o);
|
|
78
78
|
continue;
|
|
79
79
|
}
|
|
80
80
|
s(["@", parseFloat(r)]);
|
|
81
|
-
} else if (
|
|
81
|
+
} else if (t === "[")
|
|
82
82
|
if (o === ";" && !i)
|
|
83
|
-
s(["[", r]),
|
|
83
|
+
s(["[", r]), t = ";";
|
|
84
84
|
else if (o === "]" && !i)
|
|
85
85
|
s(["[", r]);
|
|
86
86
|
else {
|
|
87
|
-
|
|
87
|
+
l(o);
|
|
88
88
|
continue;
|
|
89
89
|
}
|
|
90
|
-
else if (
|
|
90
|
+
else if (t === ";")
|
|
91
91
|
if (o === "=" && !i)
|
|
92
|
-
|
|
92
|
+
t = `;${r}`, r = "";
|
|
93
93
|
else if (o === ";" && !i)
|
|
94
|
-
s([
|
|
94
|
+
s([t, r]), t = ";";
|
|
95
95
|
else if (o === "]" && !i)
|
|
96
|
-
s([
|
|
96
|
+
s([t, r]);
|
|
97
97
|
else {
|
|
98
|
-
|
|
98
|
+
l(o);
|
|
99
99
|
continue;
|
|
100
100
|
}
|
|
101
|
-
else if (
|
|
101
|
+
else if (t?.startsWith(";"))
|
|
102
102
|
if (o === ";" && !i)
|
|
103
|
-
s([
|
|
103
|
+
s([t, r]), t = ";";
|
|
104
104
|
else if (o === "]" && !i)
|
|
105
|
-
s([
|
|
105
|
+
s([t, r]);
|
|
106
106
|
else {
|
|
107
|
-
|
|
107
|
+
l(o);
|
|
108
108
|
continue;
|
|
109
109
|
}
|
|
110
|
-
else
|
|
111
|
-
(o === "/" || o === ":" || o === "~" || o === "@" || o === "[" || o === "!" || o === ",") && (
|
|
110
|
+
else t === null && o === ";" && (t = ";");
|
|
111
|
+
(o === "/" || o === ":" || o === "~" || o === "@" || o === "[" || o === "!" || o === ",") && (t = o);
|
|
112
112
|
}
|
|
113
|
-
return
|
|
113
|
+
return n;
|
|
114
114
|
}
|
|
115
|
-
function
|
|
116
|
-
return e ? e.map((
|
|
115
|
+
function z(e, n) {
|
|
116
|
+
return e ? e.map((t, i) => t[0] === n ? i : null).filter((t) => t !== null) : [];
|
|
117
117
|
}
|
|
118
|
-
function
|
|
119
|
-
const
|
|
118
|
+
function Y(e, n) {
|
|
119
|
+
const t = [];
|
|
120
120
|
let i = 0;
|
|
121
|
-
for (const r of
|
|
122
|
-
|
|
123
|
-
return
|
|
121
|
+
for (const r of n)
|
|
122
|
+
t.push(e.slice(i, r)), i = r;
|
|
123
|
+
return t.push(e.slice(i)), t;
|
|
124
124
|
}
|
|
125
|
-
function
|
|
126
|
-
|
|
127
|
-
const t = [], n = {};
|
|
125
|
+
function te(e) {
|
|
126
|
+
const n = [], t = {};
|
|
128
127
|
let i = -1;
|
|
129
|
-
for (let
|
|
130
|
-
const
|
|
131
|
-
if (!
|
|
132
|
-
const [l,
|
|
133
|
-
l === "/" ? (i++,
|
|
128
|
+
for (let r = 0; r < e.length; r++) {
|
|
129
|
+
const s = e[r];
|
|
130
|
+
if (!s) continue;
|
|
131
|
+
const [l, a] = s;
|
|
132
|
+
l === "/" ? (i++, n[i] = { index: a }, t[i] = []) : i >= 0 && t[i]?.push(s);
|
|
134
133
|
}
|
|
135
|
-
for (let
|
|
136
|
-
const
|
|
137
|
-
if (!
|
|
138
|
-
const l =
|
|
139
|
-
for (let
|
|
140
|
-
const c = l[
|
|
134
|
+
for (let r = 0; r < n.length; r++) {
|
|
135
|
+
const s = n[r];
|
|
136
|
+
if (!s) continue;
|
|
137
|
+
const l = t[r] || [];
|
|
138
|
+
for (let a = 0; a < l.length; a++) {
|
|
139
|
+
const c = l[a];
|
|
141
140
|
if (!c) continue;
|
|
142
|
-
const [
|
|
143
|
-
if (
|
|
144
|
-
|
|
145
|
-
else if (
|
|
146
|
-
|
|
147
|
-
else if (
|
|
148
|
-
|
|
149
|
-
else if (
|
|
150
|
-
|
|
151
|
-
else if (
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
} else if (
|
|
155
|
-
const
|
|
156
|
-
if (
|
|
157
|
-
|
|
158
|
-
else if (
|
|
159
|
-
const
|
|
160
|
-
|
|
141
|
+
const [f, o] = c;
|
|
142
|
+
if (f === ":")
|
|
143
|
+
s.offset = o;
|
|
144
|
+
else if (f === "~")
|
|
145
|
+
s.temporal = o;
|
|
146
|
+
else if (f === "@")
|
|
147
|
+
s.spatial = (s.spatial || []).concat(o);
|
|
148
|
+
else if (f === ";s")
|
|
149
|
+
s.side = o;
|
|
150
|
+
else if (f.startsWith(";") && f !== ";s") {
|
|
151
|
+
const u = f.substring(1);
|
|
152
|
+
s.extensions || (s.extensions = {}), s.extensions[u] = o;
|
|
153
|
+
} else if (f === "[") {
|
|
154
|
+
const u = typeof o == "string" && !o.includes(" ") && o.length < 50;
|
|
155
|
+
if (a === 0 && u && !s.id)
|
|
156
|
+
s.id = o;
|
|
157
|
+
else if (o !== "") {
|
|
158
|
+
const d = o.split(",").map((h) => h.trim());
|
|
159
|
+
s.text = d;
|
|
161
160
|
}
|
|
162
161
|
}
|
|
163
162
|
}
|
|
164
163
|
}
|
|
165
|
-
return
|
|
164
|
+
return n;
|
|
166
165
|
}
|
|
167
|
-
function
|
|
168
|
-
const
|
|
169
|
-
return
|
|
166
|
+
function A(e) {
|
|
167
|
+
const n = z(e, "!");
|
|
168
|
+
return Y(e, n).map(te);
|
|
170
169
|
}
|
|
171
|
-
function
|
|
170
|
+
function b(e) {
|
|
172
171
|
if (!e)
|
|
173
172
|
throw new Error("CFI string cannot be empty");
|
|
174
|
-
const
|
|
175
|
-
if (!
|
|
173
|
+
const n = ee(e);
|
|
174
|
+
if (!n || n.length === 0)
|
|
176
175
|
throw new Error("Failed to tokenize CFI string");
|
|
177
|
-
const
|
|
178
|
-
if (
|
|
179
|
-
return
|
|
180
|
-
const [i, r, s] =
|
|
181
|
-
function
|
|
182
|
-
if (!
|
|
183
|
-
const
|
|
184
|
-
if (
|
|
185
|
-
const
|
|
186
|
-
if (
|
|
187
|
-
const
|
|
188
|
-
return
|
|
176
|
+
const t = z(n, ",");
|
|
177
|
+
if (t.length === 0)
|
|
178
|
+
return A(n);
|
|
179
|
+
const [i, r, s] = Y(n, t);
|
|
180
|
+
function l(o, u) {
|
|
181
|
+
if (!u || u.length === 0) return [[]];
|
|
182
|
+
const d = u.filter((h) => h[0] !== ",");
|
|
183
|
+
if (d.length === 1 && d[0] && d[0][0] === ":") {
|
|
184
|
+
const h = o.length > 0 ? o[o.length - 1] : void 0, g = d[0];
|
|
185
|
+
if (h && h.length > 0 && g) {
|
|
186
|
+
const x = h.map((y) => ({ ...y })), E = x[x.length - 1];
|
|
187
|
+
return E && (E.offset = g[1]), [x];
|
|
189
188
|
}
|
|
190
189
|
return [[]];
|
|
191
190
|
}
|
|
192
|
-
return
|
|
191
|
+
return A(u);
|
|
193
192
|
}
|
|
194
|
-
const
|
|
193
|
+
const a = A(i || []), c = l(a, r || []), f = l(a, s || []);
|
|
195
194
|
return {
|
|
196
|
-
parent:
|
|
197
|
-
start:
|
|
198
|
-
end:
|
|
195
|
+
parent: a,
|
|
196
|
+
start: c,
|
|
197
|
+
end: f
|
|
199
198
|
};
|
|
200
199
|
}
|
|
201
|
-
function
|
|
200
|
+
function ce(e, n, t = {}) {
|
|
202
201
|
try {
|
|
203
|
-
const i = typeof e != "string" ? e :
|
|
204
|
-
return
|
|
202
|
+
const i = typeof e != "string" ? e : b(e);
|
|
203
|
+
return ne(i, n, t);
|
|
205
204
|
} catch (i) {
|
|
206
|
-
if (
|
|
205
|
+
if (t.throwOnError)
|
|
207
206
|
throw i;
|
|
208
207
|
return { node: null, isRange: !1 };
|
|
209
208
|
}
|
|
210
209
|
}
|
|
211
|
-
function
|
|
212
|
-
if (
|
|
213
|
-
return
|
|
214
|
-
if (
|
|
215
|
-
return
|
|
210
|
+
function ne(e, n, t = { asRange: !1 }) {
|
|
211
|
+
if (F(e))
|
|
212
|
+
return re(e, n);
|
|
213
|
+
if (Q(e))
|
|
214
|
+
return N(null);
|
|
216
215
|
const i = e.at(-1);
|
|
217
216
|
if (i)
|
|
218
|
-
return
|
|
217
|
+
return w(i, n, t);
|
|
219
218
|
throw new Error("Invalid CFI structure");
|
|
220
219
|
}
|
|
221
|
-
function
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
p(x.node) && (s = x.node);
|
|
220
|
+
function re(e, n) {
|
|
221
|
+
const t = e.parent, i = e.start[0] || [], r = e.end[0] || [];
|
|
222
|
+
let s = n.documentElement;
|
|
223
|
+
if (t.length > 0)
|
|
224
|
+
if (t.length > 1) {
|
|
225
|
+
const d = t[0];
|
|
226
|
+
if (d) {
|
|
227
|
+
const h = w(d, n);
|
|
228
|
+
P(h.node) && (s = h.node);
|
|
231
229
|
}
|
|
232
|
-
if (
|
|
233
|
-
const
|
|
234
|
-
if (
|
|
235
|
-
const
|
|
236
|
-
|
|
230
|
+
if (t.length > 1 && s) {
|
|
231
|
+
const h = t[1];
|
|
232
|
+
if (h) {
|
|
233
|
+
const g = w(h, n);
|
|
234
|
+
P(g.node) && (s = g.node);
|
|
237
235
|
}
|
|
238
236
|
}
|
|
239
237
|
} else {
|
|
240
|
-
const
|
|
241
|
-
if (
|
|
242
|
-
const
|
|
243
|
-
|
|
238
|
+
const d = t[0];
|
|
239
|
+
if (d) {
|
|
240
|
+
const h = w(d, n);
|
|
241
|
+
P(h.node) && (s = h.node);
|
|
244
242
|
}
|
|
245
243
|
}
|
|
246
244
|
if (!s)
|
|
247
245
|
throw new Error("Failed to resolve parent node in CFI range");
|
|
248
|
-
const
|
|
249
|
-
let
|
|
250
|
-
if (
|
|
251
|
-
|
|
252
|
-
const
|
|
253
|
-
|
|
246
|
+
const l = s.nodeType === Node.TEXT_NODE;
|
|
247
|
+
let a, c, f = 0, o = 0;
|
|
248
|
+
if (l) {
|
|
249
|
+
a = s, c = s;
|
|
250
|
+
const d = i[i.length - 1], h = r[r.length - 1];
|
|
251
|
+
f = (Array.isArray(d?.offset) ? d.offset[0] : d?.offset) ?? 0, o = (Array.isArray(h?.offset) ? h.offset[0] : h?.offset) ?? 0;
|
|
254
252
|
} else {
|
|
255
|
-
const
|
|
256
|
-
if (
|
|
253
|
+
const d = i.length === 0 || i.length === 1 && typeof i[0]?.offset == "number", h = r.length === 0 || r.length === 1 && typeof r[0]?.offset == "number";
|
|
254
|
+
if (d) {
|
|
257
255
|
if (!s)
|
|
258
256
|
throw new Error("Failed to resolve parent node in CFI range (start)");
|
|
259
|
-
|
|
257
|
+
a = s, f = i[0]?.offset ?? 0;
|
|
260
258
|
} else {
|
|
261
|
-
const
|
|
262
|
-
if (
|
|
259
|
+
const g = O(s, i, 0, !0);
|
|
260
|
+
if (!g)
|
|
263
261
|
throw new Error("Failed to resolve start node in CFI range");
|
|
264
|
-
|
|
265
|
-
const
|
|
266
|
-
|
|
262
|
+
a = g;
|
|
263
|
+
const x = i[i.length - 1];
|
|
264
|
+
f = (Array.isArray(x?.offset) ? x.offset[0] : x?.offset) ?? 0;
|
|
267
265
|
}
|
|
268
|
-
if (
|
|
266
|
+
if (h) {
|
|
269
267
|
if (!s)
|
|
270
268
|
throw new Error("Failed to resolve parent node in CFI range (end)");
|
|
271
|
-
|
|
269
|
+
c = s, o = r[0]?.offset ?? 0;
|
|
272
270
|
} else {
|
|
273
|
-
const
|
|
274
|
-
if (
|
|
275
|
-
|
|
276
|
-
const
|
|
277
|
-
o = (Array.isArray(
|
|
271
|
+
const g = O(s, r, 0, !0);
|
|
272
|
+
if (!g) throw new Error("Failed to resolve end node in CFI range");
|
|
273
|
+
c = g;
|
|
274
|
+
const x = r[r.length - 1];
|
|
275
|
+
o = (Array.isArray(x?.offset) ? x.offset[0] : x?.offset) ?? 0;
|
|
278
276
|
}
|
|
279
277
|
}
|
|
280
|
-
const
|
|
281
|
-
return
|
|
282
|
-
...
|
|
283
|
-
node:
|
|
278
|
+
const u = n.createRange();
|
|
279
|
+
return u.setStart(a, f), u.setEnd(c, o), {
|
|
280
|
+
...k(i[i.length - 1]),
|
|
281
|
+
node: u,
|
|
284
282
|
isRange: !0
|
|
285
283
|
};
|
|
286
284
|
}
|
|
287
|
-
function
|
|
288
|
-
if (e
|
|
289
|
-
if (e
|
|
290
|
-
const
|
|
291
|
-
if (
|
|
292
|
-
const
|
|
293
|
-
if (
|
|
294
|
-
return
|
|
285
|
+
function ie(e) {
|
|
286
|
+
if (e?.side) return e.side;
|
|
287
|
+
if (e?.text && e.text.length > 0) {
|
|
288
|
+
const n = e.text[0];
|
|
289
|
+
if (n) {
|
|
290
|
+
const t = n.match(/^([ab])$/);
|
|
291
|
+
if (t)
|
|
292
|
+
return t[1];
|
|
295
293
|
}
|
|
296
294
|
}
|
|
297
295
|
}
|
|
298
|
-
function
|
|
296
|
+
function C(e) {
|
|
299
297
|
return e.index % 2 !== 0;
|
|
300
298
|
}
|
|
301
|
-
function
|
|
302
|
-
|
|
303
|
-
return i == null ? void 0 : i.extensions;
|
|
299
|
+
function de(e) {
|
|
300
|
+
return (F(e) ? e.end : e).at(-1)?.at(-1)?.extensions;
|
|
304
301
|
}
|
|
305
|
-
function
|
|
306
|
-
const
|
|
302
|
+
function k(e) {
|
|
303
|
+
const n = ie(e), t = e?.extensions;
|
|
307
304
|
return {
|
|
308
|
-
offset: e
|
|
309
|
-
temporal: e
|
|
310
|
-
spatial: e
|
|
311
|
-
side:
|
|
312
|
-
extensions:
|
|
305
|
+
offset: e?.offset,
|
|
306
|
+
temporal: e?.temporal,
|
|
307
|
+
spatial: e?.spatial,
|
|
308
|
+
side: n,
|
|
309
|
+
extensions: t
|
|
313
310
|
};
|
|
314
311
|
}
|
|
315
|
-
function
|
|
312
|
+
function N(e, n) {
|
|
316
313
|
return {
|
|
317
314
|
node: e,
|
|
318
315
|
isRange: !1,
|
|
319
|
-
...
|
|
316
|
+
...k(n)
|
|
320
317
|
};
|
|
321
318
|
}
|
|
322
|
-
function
|
|
319
|
+
function I(e, n) {
|
|
323
320
|
return {
|
|
324
321
|
node: e,
|
|
325
322
|
isRange: !0,
|
|
326
|
-
...
|
|
323
|
+
...k(n)
|
|
327
324
|
};
|
|
328
325
|
}
|
|
329
|
-
function
|
|
326
|
+
function D(e, n, t) {
|
|
330
327
|
const i = e.createRange();
|
|
331
|
-
if (i.selectNodeContents(
|
|
332
|
-
const r = Array.isArray(
|
|
333
|
-
|
|
328
|
+
if (i.selectNodeContents(n), t !== void 0) {
|
|
329
|
+
const r = Array.isArray(t) ? t[0] : t;
|
|
330
|
+
K(n) && i.setStart(n, r || 0);
|
|
334
331
|
}
|
|
335
332
|
return i;
|
|
336
333
|
}
|
|
337
|
-
function
|
|
334
|
+
function O(e, n, t, i) {
|
|
338
335
|
let r = e;
|
|
339
|
-
for (let s =
|
|
340
|
-
const
|
|
341
|
-
if (!r || !
|
|
342
|
-
if (
|
|
343
|
-
const
|
|
344
|
-
if (
|
|
345
|
-
r = r.childNodes[
|
|
336
|
+
for (let s = t; s < n.length; s++) {
|
|
337
|
+
const l = n[s];
|
|
338
|
+
if (!r || !l) break;
|
|
339
|
+
if (C(l)) {
|
|
340
|
+
const a = l.index - 1;
|
|
341
|
+
if (a >= 0 && a < r.childNodes.length)
|
|
342
|
+
r = r.childNodes[a];
|
|
346
343
|
else {
|
|
347
344
|
if (i)
|
|
348
|
-
throw new Error(`Invalid text node index: ${
|
|
345
|
+
throw new Error(`Invalid text node index: ${l.index}`);
|
|
349
346
|
r = null;
|
|
350
347
|
break;
|
|
351
348
|
}
|
|
352
349
|
} else {
|
|
353
|
-
const
|
|
354
|
-
(
|
|
355
|
-
),
|
|
356
|
-
if (
|
|
357
|
-
const
|
|
358
|
-
|
|
350
|
+
const a = Array.from(r.childNodes).filter(
|
|
351
|
+
(f) => f.nodeType === Node.ELEMENT_NODE
|
|
352
|
+
), c = Math.floor(l.index / 2) - 1;
|
|
353
|
+
if (c >= 0 && c < a.length) {
|
|
354
|
+
const f = a[c];
|
|
355
|
+
f && (r = f);
|
|
359
356
|
} else {
|
|
360
357
|
if (i)
|
|
361
|
-
throw new Error(`Invalid element step index: ${
|
|
358
|
+
throw new Error(`Invalid element step index: ${l.index}`);
|
|
362
359
|
r = null;
|
|
363
360
|
break;
|
|
364
361
|
}
|
|
@@ -366,325 +363,323 @@ function R(e, t, n, i) {
|
|
|
366
363
|
}
|
|
367
364
|
return r;
|
|
368
365
|
}
|
|
369
|
-
function
|
|
370
|
-
const { throwOnError: i = !1, asRange: r = !1 } =
|
|
371
|
-
if (!
|
|
366
|
+
function w(e, n, t = {}) {
|
|
367
|
+
const { throwOnError: i = !1, asRange: r = !1 } = t;
|
|
368
|
+
if (!n) {
|
|
372
369
|
if (i)
|
|
373
370
|
throw new Error("Document is not available");
|
|
374
|
-
return
|
|
371
|
+
return N(null);
|
|
375
372
|
}
|
|
376
|
-
const { node: s, remainingPathIndex:
|
|
377
|
-
if (s &&
|
|
373
|
+
const { node: s, remainingPathIndex: l } = se(n, e);
|
|
374
|
+
if (s && l >= e.length) {
|
|
378
375
|
const o = e.at(-1);
|
|
379
|
-
if (o &&
|
|
380
|
-
const
|
|
381
|
-
if (
|
|
382
|
-
const
|
|
383
|
-
return
|
|
376
|
+
if (o && C(o)) {
|
|
377
|
+
const u = o.index - 1;
|
|
378
|
+
if (u >= 0 && u < s.childNodes.length) {
|
|
379
|
+
const d = s.childNodes[u];
|
|
380
|
+
return N(d, o);
|
|
384
381
|
}
|
|
385
382
|
}
|
|
386
383
|
if (r) {
|
|
387
|
-
const
|
|
388
|
-
return
|
|
384
|
+
const u = D(n, s, o?.offset);
|
|
385
|
+
return I(u, o);
|
|
389
386
|
}
|
|
390
|
-
return
|
|
387
|
+
return N(s, o);
|
|
391
388
|
}
|
|
392
|
-
let
|
|
393
|
-
const
|
|
389
|
+
let a = s || n.documentElement;
|
|
390
|
+
const c = s ? l : 0;
|
|
394
391
|
if (r && e.length > 0) {
|
|
395
392
|
const o = e[e.length - 1];
|
|
396
|
-
if (o && !
|
|
397
|
-
if (o.index === 0 &&
|
|
398
|
-
const
|
|
399
|
-
return
|
|
393
|
+
if (o && !C(o)) {
|
|
394
|
+
if (o.index === 0 && a) {
|
|
395
|
+
const d = n.createRange();
|
|
396
|
+
return d.setStart(a, 0), d.setEnd(a, 0), I(d, o);
|
|
400
397
|
}
|
|
401
|
-
const
|
|
402
|
-
|
|
398
|
+
const u = O(
|
|
399
|
+
a,
|
|
403
400
|
e.slice(0, -1),
|
|
404
|
-
|
|
401
|
+
c,
|
|
405
402
|
i
|
|
406
403
|
);
|
|
407
|
-
if (
|
|
408
|
-
const
|
|
404
|
+
if (u) {
|
|
405
|
+
const d = Array.from(u.childNodes).filter(
|
|
409
406
|
(g) => g.nodeType === Node.ELEMENT_NODE
|
|
410
407
|
);
|
|
411
|
-
if (Math.floor(o.index / 2) - 1 ===
|
|
412
|
-
const g =
|
|
413
|
-
return g.selectNodeContents(
|
|
408
|
+
if (Math.floor(o.index / 2) - 1 === d.length) {
|
|
409
|
+
const g = n.createRange();
|
|
410
|
+
return g.selectNodeContents(u), g.collapse(!1), I(g, o);
|
|
414
411
|
}
|
|
415
412
|
}
|
|
416
413
|
}
|
|
417
414
|
}
|
|
418
|
-
if (
|
|
415
|
+
if (a = O(a, e, c, i), !a) {
|
|
419
416
|
if (i)
|
|
420
417
|
throw new Error("Failed to resolve CFI path");
|
|
421
|
-
return
|
|
418
|
+
return N(null);
|
|
422
419
|
}
|
|
423
|
-
const
|
|
420
|
+
const f = e.at(-1);
|
|
424
421
|
if (r) {
|
|
425
|
-
const o =
|
|
426
|
-
return
|
|
422
|
+
const o = D(n, a, f?.offset);
|
|
423
|
+
return I(o, f);
|
|
427
424
|
}
|
|
428
|
-
return
|
|
425
|
+
return N(a, f);
|
|
429
426
|
}
|
|
430
|
-
function
|
|
431
|
-
for (let
|
|
432
|
-
const i = t
|
|
433
|
-
if (i
|
|
427
|
+
function se(e, n) {
|
|
428
|
+
for (let t = n.length - 1; t >= 0; t--) {
|
|
429
|
+
const i = n[t];
|
|
430
|
+
if (i?.id) {
|
|
434
431
|
const r = e.getElementById(i.id);
|
|
435
|
-
if (r) return { node: r, remainingPathIndex:
|
|
432
|
+
if (r) return { node: r, remainingPathIndex: t + 1 };
|
|
436
433
|
}
|
|
437
434
|
}
|
|
438
435
|
return { node: null, remainingPathIndex: 0 };
|
|
439
436
|
}
|
|
440
|
-
function
|
|
437
|
+
function V(e, n, t = {}) {
|
|
441
438
|
if (!e.textContent || e.textContent.trim() === "")
|
|
442
439
|
return null;
|
|
443
|
-
const i = e.textContent, r =
|
|
444
|
-
if (
|
|
445
|
-
const s = Math.floor(r / 2),
|
|
446
|
-
return i.substring(
|
|
440
|
+
const i = e.textContent, r = t.textAssertionLength || 10;
|
|
441
|
+
if (n !== void 0 && n <= i.length) {
|
|
442
|
+
const s = Math.floor(r / 2), l = Math.max(0, n - s), a = Math.min(i.length, n + s);
|
|
443
|
+
return i.substring(l, a);
|
|
447
444
|
}
|
|
448
445
|
return i.substring(0, Math.min(i.length, r));
|
|
449
446
|
}
|
|
450
|
-
function
|
|
451
|
-
const [
|
|
447
|
+
function oe(e) {
|
|
448
|
+
const [n, t] = e, i = Math.max(0, Math.min(100, n)), r = Math.max(0, Math.min(100, t));
|
|
452
449
|
return `@${i}:${r}`;
|
|
453
450
|
}
|
|
454
|
-
function
|
|
451
|
+
function S(e, n, t) {
|
|
455
452
|
let i = e;
|
|
456
|
-
return
|
|
453
|
+
return n !== void 0 && (i += `~${n}`), t !== void 0 && (i += oe(t)), i;
|
|
457
454
|
}
|
|
458
|
-
function
|
|
455
|
+
function q(e, n, t) {
|
|
459
456
|
let i = e;
|
|
460
|
-
if (
|
|
461
|
-
const r =
|
|
462
|
-
|
|
457
|
+
if (n && (i += `[${p(n)}]`), t) {
|
|
458
|
+
const r = t === "before" ? "b" : "a";
|
|
459
|
+
n ? i = `${i.substring(0, i.length - 1)};s=${r}]` : i += `[;s=${r}]`;
|
|
463
460
|
}
|
|
464
461
|
return i;
|
|
465
462
|
}
|
|
466
|
-
function
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
f = e;
|
|
463
|
+
function R(e, n, t = {}, i) {
|
|
464
|
+
let r = "", s = e, l = null;
|
|
465
|
+
if (e?.nodeType === Node.TEXT_NODE) {
|
|
466
|
+
l = e;
|
|
471
467
|
const c = e.parentNode;
|
|
472
468
|
if (!c)
|
|
473
469
|
throw new Error("Text node doesn't have a parent");
|
|
474
|
-
const
|
|
475
|
-
if (
|
|
470
|
+
const o = Array.from(c.childNodes).indexOf(e);
|
|
471
|
+
if (o === -1)
|
|
476
472
|
throw new Error("Node not found in parent's children");
|
|
477
|
-
if (r = `/${
|
|
478
|
-
const
|
|
479
|
-
r = `/${
|
|
473
|
+
if (r = `/${o + 1}`, v(c) && c.id) {
|
|
474
|
+
const u = c.id, d = Array.from(c.parentNode?.childNodes || []);
|
|
475
|
+
r = `/${d.slice(0, d.indexOf(c) + 1).filter((x) => x.nodeType === Node.ELEMENT_NODE).length * 2}[${p(u)}]${r}`, s = c.parentNode;
|
|
480
476
|
} else
|
|
481
477
|
s = c;
|
|
482
478
|
}
|
|
483
|
-
let
|
|
484
|
-
for (
|
|
485
|
-
if (!(
|
|
486
|
-
const c = s.parentNode,
|
|
487
|
-
if (
|
|
479
|
+
let a = null;
|
|
480
|
+
for (l && t.includeTextAssertions && (a = V(l, n, t)); s?.parentNode; ) {
|
|
481
|
+
if (!(l && s === l.parentNode && r.includes(`[${v(s) ? s.id : ""}]`))) {
|
|
482
|
+
const c = s.parentNode, f = Array.from(c.childNodes), o = f.indexOf(s);
|
|
483
|
+
if (o === -1)
|
|
488
484
|
throw new Error("Node not found in parent's children");
|
|
489
|
-
const
|
|
490
|
-
let
|
|
491
|
-
s.nodeType, Node.ELEMENT_NODE,
|
|
492
|
-
const
|
|
493
|
-
|
|
485
|
+
const u = f.slice(0, o + 1).filter((g) => g.nodeType === Node.ELEMENT_NODE);
|
|
486
|
+
let d;
|
|
487
|
+
s.nodeType, Node.ELEMENT_NODE, d = u.length;
|
|
488
|
+
const h = d * 2;
|
|
489
|
+
v(s) && s.id ? r = `/${h}[${p(s.id)}]${r}` : r = `/${h}${r}`;
|
|
494
490
|
}
|
|
495
491
|
if (s.parentNode.nodeName.toLowerCase() === "html")
|
|
496
492
|
break;
|
|
497
493
|
s = s.parentNode;
|
|
498
494
|
}
|
|
499
|
-
return
|
|
495
|
+
return n !== void 0 && (r += `:${n}`), r = S(
|
|
500
496
|
r,
|
|
501
|
-
i
|
|
502
|
-
|
|
503
|
-
), r =
|
|
504
|
-
}
|
|
505
|
-
function
|
|
506
|
-
if (e ===
|
|
507
|
-
let
|
|
508
|
-
return
|
|
497
|
+
i?.temporal,
|
|
498
|
+
i?.spatial || t.spatialOffset
|
|
499
|
+
), r = q(r, a, t.includeSideBias), r = m(r, t.extensions), r;
|
|
500
|
+
}
|
|
501
|
+
function L(e, n, t, i = {}, r) {
|
|
502
|
+
if (e === n) {
|
|
503
|
+
let c = t !== void 0 ? `:${t}` : "";
|
|
504
|
+
return c = S(c, r?.temporal, r?.spatial), c;
|
|
509
505
|
}
|
|
510
506
|
const s = [];
|
|
511
|
-
let
|
|
512
|
-
for (;
|
|
513
|
-
const
|
|
514
|
-
if (!
|
|
515
|
-
const
|
|
507
|
+
let l = n;
|
|
508
|
+
for (; l && l !== e; ) {
|
|
509
|
+
const c = l.parentNode;
|
|
510
|
+
if (!c) break;
|
|
511
|
+
const f = Array.from(c.childNodes), o = f.indexOf(l);
|
|
516
512
|
if (o === -1)
|
|
517
513
|
throw new Error("Node not found in parent's children");
|
|
518
|
-
let
|
|
519
|
-
|
|
514
|
+
let u;
|
|
515
|
+
l.nodeType === Node.ELEMENT_NODE ? u = (f.filter(
|
|
520
516
|
(g) => g.nodeType === Node.ELEMENT_NODE
|
|
521
|
-
).indexOf(
|
|
517
|
+
).indexOf(l) + 1) * 2 : u = o + 1, v(l) && l.id ? s.unshift(`/${u}[${p(l.id)}]`) : s.unshift(`/${u}`), l = c;
|
|
522
518
|
}
|
|
523
|
-
let
|
|
524
|
-
if (
|
|
525
|
-
const
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
519
|
+
let a = s.join("");
|
|
520
|
+
if (t !== void 0 && (a += `:${t}`), a = S(a, r?.temporal, r?.spatial), i.includeTextAssertions && n.nodeType === Node.TEXT_NODE) {
|
|
521
|
+
const c = V(n, t, i);
|
|
522
|
+
a = q(
|
|
523
|
+
a,
|
|
524
|
+
c,
|
|
529
525
|
i.includeSideBias
|
|
530
526
|
);
|
|
531
527
|
}
|
|
532
|
-
return
|
|
528
|
+
return a = m(a, i.extensions), a;
|
|
533
529
|
}
|
|
534
|
-
const
|
|
535
|
-
const i =
|
|
536
|
-
return `${
|
|
530
|
+
const le = (e) => Object.entries(e).map(([n, t]) => {
|
|
531
|
+
const i = p(t);
|
|
532
|
+
return `${n}=${encodeURIComponent(i)}`;
|
|
537
533
|
}).join(";");
|
|
538
|
-
function
|
|
539
|
-
if (!
|
|
534
|
+
function m(e, n) {
|
|
535
|
+
if (!n || Object.keys(n).length === 0)
|
|
540
536
|
return e;
|
|
541
|
-
const
|
|
537
|
+
const t = le(n);
|
|
542
538
|
if (e.endsWith("]")) {
|
|
543
539
|
const i = e.lastIndexOf("["), r = e.substring(i + 1, e.length - 1);
|
|
544
|
-
return r.includes(
|
|
540
|
+
return r.includes(t) ? e : `${e.substring(0, e.length - 1)}${r.includes(";"), ";"}${t}]`;
|
|
545
541
|
}
|
|
546
|
-
return e.endsWith("!") ? e : `${e}[;${
|
|
542
|
+
return e.endsWith("!") ? e : `${e}[;${t}]`;
|
|
547
543
|
}
|
|
548
|
-
function
|
|
549
|
-
const
|
|
550
|
-
if (!
|
|
544
|
+
function ae(e, n, t, i, r = {}, s, l) {
|
|
545
|
+
const a = U(e, t);
|
|
546
|
+
if (!a)
|
|
551
547
|
throw new Error("No common ancestor found");
|
|
552
|
-
const
|
|
553
|
-
|
|
548
|
+
const c = R(a, void 0, r), f = L(
|
|
549
|
+
a,
|
|
554
550
|
e,
|
|
555
|
-
|
|
551
|
+
n,
|
|
556
552
|
r,
|
|
557
553
|
s
|
|
558
|
-
), o =
|
|
559
|
-
|
|
560
|
-
|
|
554
|
+
), o = L(
|
|
555
|
+
a,
|
|
556
|
+
t,
|
|
561
557
|
i,
|
|
562
558
|
r,
|
|
563
|
-
|
|
559
|
+
l
|
|
564
560
|
);
|
|
565
561
|
if (r.extensions && Object.keys(r.extensions).length > 0) {
|
|
566
|
-
const
|
|
567
|
-
return `${
|
|
562
|
+
const u = m(c, r.extensions), d = m(f, r.extensions), h = m(o, r.extensions);
|
|
563
|
+
return `${u},${d},${h}`;
|
|
568
564
|
}
|
|
569
|
-
return `${
|
|
565
|
+
return `${c},${f},${o}`;
|
|
570
566
|
}
|
|
571
|
-
const
|
|
567
|
+
const B = (e, n, t = {}, i) => {
|
|
572
568
|
const r = "";
|
|
573
|
-
let
|
|
574
|
-
return
|
|
569
|
+
let l = `/6/${(e + 1) * 2}`;
|
|
570
|
+
return n && (l += `[${p(n)}]`), l = i ? m(l, t.extensions) : l, `${l}${r}!`;
|
|
575
571
|
};
|
|
576
|
-
function
|
|
577
|
-
if (
|
|
578
|
-
return `epubcfi(${
|
|
579
|
-
let
|
|
572
|
+
function ue(e, n = {}) {
|
|
573
|
+
if (P(e))
|
|
574
|
+
return `epubcfi(${R(e, void 0, n)})`;
|
|
575
|
+
let t = "";
|
|
580
576
|
if (!("start" in e))
|
|
581
|
-
return e.spineIndex !== void 0 && (
|
|
577
|
+
return e.spineIndex !== void 0 && (t = B(
|
|
582
578
|
e.spineIndex,
|
|
583
579
|
e.spineId,
|
|
584
|
-
|
|
580
|
+
n,
|
|
585
581
|
!e.node
|
|
586
|
-
), !e.node) ? `epubcfi(${
|
|
582
|
+
), !e.node) ? `epubcfi(${t})` : (t += R(
|
|
587
583
|
e.node ?? null,
|
|
588
584
|
e.offset,
|
|
589
|
-
|
|
585
|
+
n,
|
|
590
586
|
e
|
|
591
|
-
), `epubcfi(${
|
|
587
|
+
), `epubcfi(${t})`);
|
|
592
588
|
const { start: i, end: r } = e;
|
|
593
|
-
return i.spineIndex !== void 0 && (
|
|
589
|
+
return i.spineIndex !== void 0 && (t = B(
|
|
594
590
|
i.spineIndex,
|
|
595
591
|
i.spineId,
|
|
596
|
-
|
|
592
|
+
n,
|
|
597
593
|
!i.node
|
|
598
|
-
)), i.node && r.node && (
|
|
594
|
+
)), i.node && r.node && (t += ae(
|
|
599
595
|
i.node,
|
|
600
596
|
i.offset ?? 0,
|
|
601
597
|
r.node,
|
|
602
598
|
r.offset ?? 0,
|
|
603
|
-
|
|
599
|
+
n,
|
|
604
600
|
i,
|
|
605
601
|
r
|
|
606
|
-
)), `epubcfi(${
|
|
602
|
+
)), `epubcfi(${t})`;
|
|
607
603
|
}
|
|
608
|
-
function
|
|
609
|
-
return typeof e == "string" ?
|
|
604
|
+
function $(e, n = !1) {
|
|
605
|
+
return typeof e == "string" ? $(b(e), n) : "parent" in e ? n ? e.parent.concat(e.end) : e.parent.concat(e.start) : e;
|
|
610
606
|
}
|
|
611
|
-
function
|
|
607
|
+
function W(e) {
|
|
612
608
|
return e.offset !== void 0 ? 1 : e.index !== void 0 ? 2 : e.temporal !== void 0 || e.spatial !== void 0 ? 3 : 4;
|
|
613
609
|
}
|
|
614
|
-
function
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
if (!
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
if (
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
if (
|
|
632
|
-
if (
|
|
633
|
-
|
|
634
|
-
if ((
|
|
635
|
-
if ((u.temporal ?? 0) < (g.temporal ?? 0)) return -1;
|
|
610
|
+
function X(e, n) {
|
|
611
|
+
const t = typeof e == "string" ? b(e) : e, i = typeof n == "string" ? b(n) : n;
|
|
612
|
+
if ("parent" in t || "parent" in i)
|
|
613
|
+
return X($(t), $(i)) || X($(t, !0), $(i, !0));
|
|
614
|
+
for (let r = 0; r < Math.max(t.length, i.length); r++) {
|
|
615
|
+
const s = t[r] || [], l = i[r] || [], a = Math.max(s.length, l.length) - 1;
|
|
616
|
+
for (let c = 0; c <= a; c++) {
|
|
617
|
+
const f = s[c], o = l[c];
|
|
618
|
+
if (!f) return -1;
|
|
619
|
+
if (!o) return 1;
|
|
620
|
+
const u = W(f), d = W(o);
|
|
621
|
+
if (u !== d)
|
|
622
|
+
return u - d;
|
|
623
|
+
if (f.index > o.index) return 1;
|
|
624
|
+
if (f.index < o.index) return -1;
|
|
625
|
+
const h = f.temporal !== void 0, g = o.temporal !== void 0;
|
|
626
|
+
if (h && !g) return 1;
|
|
627
|
+
if (!h && g) return -1;
|
|
628
|
+
if (h && g) {
|
|
629
|
+
if ((f.temporal ?? 0) > (o.temporal ?? 0)) return 1;
|
|
630
|
+
if ((f.temporal ?? 0) < (o.temporal ?? 0)) return -1;
|
|
636
631
|
}
|
|
637
|
-
const
|
|
638
|
-
if (
|
|
639
|
-
if (!
|
|
640
|
-
if (
|
|
641
|
-
const
|
|
642
|
-
if (
|
|
643
|
-
if (
|
|
644
|
-
const
|
|
645
|
-
if (
|
|
646
|
-
if (
|
|
632
|
+
const x = f.spatial !== void 0, E = o.spatial !== void 0;
|
|
633
|
+
if (x && !E) return 1;
|
|
634
|
+
if (!x && E) return -1;
|
|
635
|
+
if (x && E) {
|
|
636
|
+
const y = f.spatial?.[1] ?? 0, M = o.spatial?.[1] ?? 0;
|
|
637
|
+
if (y > M) return 1;
|
|
638
|
+
if (y < M) return -1;
|
|
639
|
+
const j = f.spatial?.[0] ?? 0, _ = o.spatial?.[0] ?? 0;
|
|
640
|
+
if (j > _) return 1;
|
|
641
|
+
if (j < _) return -1;
|
|
647
642
|
}
|
|
648
|
-
if (
|
|
649
|
-
if ((
|
|
650
|
-
if ((
|
|
643
|
+
if (c === a) {
|
|
644
|
+
if ((f.offset ?? 0) > (o.offset ?? 0)) return 1;
|
|
645
|
+
if ((f.offset ?? 0) < (o.offset ?? 0)) return -1;
|
|
651
646
|
}
|
|
652
647
|
}
|
|
653
648
|
}
|
|
654
649
|
return 0;
|
|
655
650
|
}
|
|
656
|
-
function
|
|
657
|
-
let
|
|
651
|
+
function fe(e) {
|
|
652
|
+
let n = `/${e.index}`;
|
|
658
653
|
if (e.id) {
|
|
659
|
-
if (
|
|
654
|
+
if (n += `[${p(e.id)}`, e.extensions)
|
|
660
655
|
for (const [i, r] of Object.entries(e.extensions))
|
|
661
|
-
|
|
662
|
-
|
|
656
|
+
n += `;${i}=${p(r)}`;
|
|
657
|
+
n += "]";
|
|
663
658
|
}
|
|
664
|
-
e.offset !== void 0 && (
|
|
665
|
-
const
|
|
666
|
-
if (e.text && e.text.length > 0 &&
|
|
659
|
+
e.offset !== void 0 && (n += `:${e.offset}`), e.temporal !== void 0 && (n += `~${e.temporal}`), e.spatial && e.spatial.length > 0 && (n += `@${e.spatial.join(":")}`);
|
|
660
|
+
const t = [];
|
|
661
|
+
if (e.text && e.text.length > 0 && t.push(e.text.map(p).join(",")), (e.side || e.extensions && !e.id) && (e.side && t.push(`;s=${e.side}`), e.extensions && !e.id))
|
|
667
662
|
for (const [i, r] of Object.entries(e.extensions))
|
|
668
|
-
|
|
669
|
-
return
|
|
663
|
+
t.push(`;${i}=${p(r)}`);
|
|
664
|
+
return t.length > 0 && (n += `[${t.join("")}]`), n;
|
|
670
665
|
}
|
|
671
|
-
function
|
|
672
|
-
return e.map((
|
|
666
|
+
function T(e) {
|
|
667
|
+
return e.map((n) => fe(n)).join("");
|
|
673
668
|
}
|
|
674
|
-
function
|
|
669
|
+
function he(e) {
|
|
675
670
|
if (Array.isArray(e))
|
|
676
|
-
return `epubcfi(${e.map(
|
|
677
|
-
const
|
|
678
|
-
return `epubcfi(${
|
|
671
|
+
return `epubcfi(${e.map(T).join("!")})`;
|
|
672
|
+
const n = e.parent.map(T).join("!"), t = e.start.map(T).join("!"), i = e.end.map(T).join("!");
|
|
673
|
+
return `epubcfi(${n},${t},${i})`;
|
|
679
674
|
}
|
|
680
675
|
export {
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
676
|
+
X as compare,
|
|
677
|
+
ue as generate,
|
|
678
|
+
Q as isIndirectionOnly,
|
|
679
|
+
F as isParsedCfiRange,
|
|
680
|
+
b as parse,
|
|
681
|
+
ce as resolve,
|
|
682
|
+
de as resolveExtensions,
|
|
683
|
+
he as serialize
|
|
689
684
|
};
|
|
690
685
|
//# sourceMappingURL=index.js.map
|