@prose-reader/archive-reader 1.345.0 → 1.347.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.
@@ -97,7 +97,7 @@ var v = async (e, t = {}) => n(e, (e) => e.isDir ? {
97
97
  data: t,
98
98
  basePath: t?.uri.substring(0, t.uri.lastIndexOf("/")) || ""
99
99
  };
100
- }, k = (e) => e === void 0 || e.trim().length === 0 ? [] : e.trim().split(/\s+/).filter((e) => e.length > 0), ee = (e) => {
100
+ }, k = (e) => e === void 0 || e.trim().length === 0 ? [] : e.trim().split(/\s+/).filter((e) => e.length > 0), A = (e) => {
101
101
  let t = k(e);
102
102
  if (t.length === 0) return {};
103
103
  let n;
@@ -109,16 +109,16 @@ var v = async (e, t = {}) => n(e, (e) => e.isDir ? {
109
109
  ...t.includes("page-spread-left") ? { pageSpreadLeft: !0 } : {},
110
110
  ...t.includes("page-spread-right") ? { pageSpreadRight: !0 } : {}
111
111
  };
112
- }, A = (e) => e.includes(":") ? e.slice(e.lastIndexOf(":") + 1) : e, te = (e, t) => A(e).toLowerCase() === t.toLowerCase(), j = (e) => e.type === "element", M = (e, t) => {
113
- for (let n of e.children) if (j(n) && te(n.name, t)) return n;
114
- }, N = (e, t) => {
112
+ }, j = (e) => e.includes(":") ? e.slice(e.lastIndexOf(":") + 1) : e, M = (e, t) => j(e).toLowerCase() === t.toLowerCase(), ee = (e) => e.type === "element", N = (e, t) => {
113
+ for (let n of e.children) if (ee(n) && M(n.name, t)) return n;
114
+ }, P = (e, t) => {
115
115
  let n = [];
116
- for (let r of e.children) j(r) && te(r.name, t) && n.push(r);
116
+ for (let r of e.children) ee(r) && M(r.name, t) && n.push(r);
117
117
  return n;
118
- }, ne = (e, t) => {
118
+ }, te = (e, t) => {
119
119
  let n = [];
120
120
  return e.eachChild((e) => {
121
- if (A(e.name).toLowerCase() !== "identifier") return;
121
+ if (j(e.name).toLowerCase() !== "identifier") return;
122
122
  let r = e.val.trim();
123
123
  if (r.length === 0) return;
124
124
  let i = (e.attr["opf:scheme"] ?? e.attr["opf:Scheme"] ?? e.attr.scheme)?.trim(), a = e.attr.id?.trim(), o = a !== void 0 && a.length > 0 ? a : void 0;
@@ -129,24 +129,36 @@ var v = async (e, t = {}) => n(e, (e) => e.isDir ? {
129
129
  ...o !== void 0 && o === t ? { unique: !0 } : {}
130
130
  });
131
131
  }), n;
132
- }, P = (e, t) => {
132
+ }, ne = (e) => {
133
+ let t = [];
134
+ return e.eachChild((e) => {
135
+ if (j(e.name).toLowerCase() !== "title") return;
136
+ let n = e.val.trim();
137
+ if (n.length === 0) return;
138
+ let r = e.attr.id?.trim();
139
+ t.push({
140
+ value: n,
141
+ ...r !== void 0 && r.length > 0 ? { id: r } : {}
142
+ });
143
+ }), t;
144
+ }, F = (e, t) => {
133
145
  let n;
134
146
  return e.eachChild((e) => {
135
- if (n !== void 0 || A(e.name).toLowerCase() !== t.toLowerCase()) return;
147
+ if (n !== void 0 || j(e.name).toLowerCase() !== t.toLowerCase()) return;
136
148
  let r = e.val.trim();
137
149
  r.length > 0 && (n = r);
138
150
  }), n;
139
- }, F = (e, t) => {
151
+ }, I = (e, t) => {
140
152
  let n = [];
141
153
  return e.eachChild((e) => {
142
- if (A(e.name).toLowerCase() !== t.toLowerCase()) return;
154
+ if (j(e.name).toLowerCase() !== t.toLowerCase()) return;
143
155
  let r = e.val.trim();
144
156
  r.length > 0 && n.push(r);
145
157
  }), n;
146
158
  }, re = (e) => {
147
159
  let t;
148
160
  return e.eachChild((e) => {
149
- if (t !== void 0 || A(e.name).toLowerCase() !== "meta" || e.attr.name?.toLowerCase() !== "cover") return;
161
+ if (t !== void 0 || j(e.name).toLowerCase() !== "meta" || e.attr.name?.toLowerCase() !== "cover") return;
150
162
  let n = e.attr.content?.trim();
151
163
  n !== void 0 && n.length > 0 && (t = n);
152
164
  }), t;
@@ -161,14 +173,14 @@ var v = async (e, t = {}) => n(e, (e) => e.isDir ? {
161
173
  }
162
174
  }
163
175
  return e.find((e) => e.id.toLowerCase().includes("cover") && n(e))?.href;
164
- }, I = (e, t) => {
176
+ }, L = (e, t) => {
165
177
  let n = e.attr[t]?.trim();
166
178
  return n !== void 0 && n.length > 0 ? n : void 0;
167
179
  }, ae = (e) => {
168
180
  let t = [];
169
181
  return e.eachChild((e) => {
170
- if (A(e.name).toLowerCase() !== "meta") return;
171
- let n = I(e, "property"), r = I(e, "refines"), i = I(e, "scheme"), a = I(e, "id"), o = I(e, "name"), s = I(e, "content"), c = e.val.trim(), l = c.length > 0 ? c : void 0, u = {
182
+ if (j(e.name).toLowerCase() !== "meta") return;
183
+ let n = L(e, "property"), r = L(e, "refines"), i = L(e, "scheme"), a = L(e, "id"), o = L(e, "name"), s = L(e, "content"), c = e.val.trim(), l = c.length > 0 ? c : void 0, u = {
172
184
  ...n === void 0 ? {} : { property: n },
173
185
  ...r === void 0 ? {} : { refines: r },
174
186
  ...i === void 0 ? {} : { scheme: i },
@@ -182,11 +194,11 @@ var v = async (e, t = {}) => n(e, (e) => e.isDir ? {
182
194
  }, oe = (e, t) => e.replace(/^#/, "") === t, se = (e, t) => {
183
195
  let n = [];
184
196
  return e.eachChild((e) => {
185
- let r = A(e.name).toLowerCase();
197
+ let r = j(e.name).toLowerCase();
186
198
  if (r !== "creator" && r !== "contributor") return;
187
199
  let i = e.val.trim();
188
200
  if (i.length === 0) return;
189
- let a = I(e, "id"), o = (e) => a === void 0 ? [] : t.flatMap((t) => t.refines !== void 0 && oe(t.refines, a) && t.property === e && t.value !== void 0 ? [t.value] : []), s = I(e, "opf:role") ?? I(e, "role"), c = [...s === void 0 ? [] : [s], ...o("role")], l = I(e, "opf:file-as") ?? I(e, "file-as") ?? o("file-as")[0];
201
+ let a = L(e, "id"), o = (e) => a === void 0 ? [] : t.flatMap((t) => t.refines !== void 0 && oe(t.refines, a) && t.property === e && t.value !== void 0 ? [t.value] : []), s = L(e, "opf:role") ?? L(e, "role"), c = [...s === void 0 ? [] : [s], ...o("role")], l = L(e, "opf:file-as") ?? L(e, "file-as") ?? o("file-as")[0];
190
202
  n.push({
191
203
  name: i,
192
204
  source: r,
@@ -195,14 +207,14 @@ var v = async (e, t = {}) => n(e, (e) => e.isDir ? {
195
207
  ...l === void 0 ? {} : { fileAs: l }
196
208
  });
197
209
  }), n;
198
- }, L = (e, t) => {
199
- let n = N(e, "meta").find((e) => e.attr.property === t)?.val;
210
+ }, R = (e, t) => {
211
+ let n = P(e, "meta").find((e) => e.attr.property === t)?.val;
200
212
  if (!(n === void 0 || n.trim().length === 0)) return n;
201
213
  }, ce = (e) => {
202
- let t = M(e, "guide");
214
+ let t = N(e, "guide");
203
215
  if (t === void 0) return [];
204
216
  let n = [];
205
- for (let e of N(t, "reference")) {
217
+ for (let e of P(t, "reference")) {
206
218
  let t = e.attr.href?.trim();
207
219
  t === void 0 || t.length === 0 || n.push({
208
220
  href: t,
@@ -223,7 +235,7 @@ var v = async (e, t = {}) => n(e, (e) => e.isDir ? {
223
235
  };
224
236
  }, ue = (e) => {
225
237
  let t = [], n = /* @__PURE__ */ new Map();
226
- for (let r of N(e, "item")) {
238
+ for (let r of P(e, "item")) {
227
239
  let e = le(r);
228
240
  e !== void 0 && (t.push(e), n.set(e.id, e));
229
241
  }
@@ -233,12 +245,12 @@ var v = async (e, t = {}) => n(e, (e) => e.isDir ? {
233
245
  };
234
246
  }, de = (e, t) => {
235
247
  let n = [];
236
- for (let r of N(t, "itemref")) {
248
+ for (let r of P(t, "itemref")) {
237
249
  let t = r.attr.idref;
238
250
  if (t === void 0 || t.trim().length === 0) continue;
239
251
  let i = e.get(t);
240
252
  if (i === void 0) continue;
241
- let a = ee(r.attr.properties);
253
+ let a = A(r.attr.properties);
242
254
  n.push({
243
255
  idref: t,
244
256
  id: i.id,
@@ -253,13 +265,13 @@ var v = async (e, t = {}) => n(e, (e) => e.isDir ? {
253
265
  }
254
266
  return n;
255
267
  }, fe = (e) => {
256
- let t = new h(e), n = M(t, "manifest"), r = M(t, "spine"), i = M(t, "metadata"), a = t.attr["unique-identifier"]?.trim(), o = a !== void 0 && a.length > 0 ? a : void 0, s = [], c = [];
268
+ let t = new h(e), n = N(t, "manifest"), r = N(t, "spine"), i = N(t, "metadata"), a = t.attr["unique-identifier"]?.trim(), o = a !== void 0 && a.length > 0 ? a : void 0, s = [], c = [];
257
269
  if (n !== void 0) {
258
270
  let { items: e, byId: t } = ue(n);
259
271
  s = e, r !== void 0 && (c = de(t, r));
260
272
  }
261
- let l = r?.attr["page-progression-direction"], u = l !== void 0 && l.trim().length > 0 ? l : void 0, d = r?.attr.toc, f = d !== void 0 && d.trim().length > 0 ? d.trim() : void 0, p, m, g, _, v, y = [], b = [], x = [], S = [], C, w, T, E = [], D = [];
262
- i !== void 0 && (p = P(i, "title"), m = P(i, "publisher"), g = P(i, "description"), _ = P(i, "rights"), v = P(i, "date"), y = F(i, "creator"), x = F(i, "language"), S = F(i, "subject"), C = L(i, "rendition:layout"), w = L(i, "rendition:flow"), T = L(i, "rendition:spread"), E = ae(i), b = se(i, E), D.push(...ne(i, o)));
273
+ let l = r?.attr["page-progression-direction"], u = l !== void 0 && l.trim().length > 0 ? l : void 0, d = r?.attr.toc, f = d !== void 0 && d.trim().length > 0 ? d.trim() : void 0, p = [], m, g, _, v, y = [], b = [], x = [], S = [], C, w, T, E = [], D = [];
274
+ i !== void 0 && (p = ne(i), m = F(i, "publisher"), g = F(i, "description"), _ = F(i, "rights"), v = F(i, "date"), y = I(i, "creator"), x = I(i, "language"), S = I(i, "subject"), C = R(i, "rendition:layout"), w = R(i, "rendition:flow"), T = R(i, "rendition:spread"), E = ae(i), b = se(i, E), D.push(...te(i, o)));
263
275
  let O = ie({
264
276
  manifestItems: s,
265
277
  metadataEl: i
@@ -270,7 +282,7 @@ var v = async (e, t = {}) => n(e, (e) => e.isDir ? {
270
282
  spineRows: c,
271
283
  spineTocIdref: f,
272
284
  identifiers: D,
273
- title: p,
285
+ titles: p,
274
286
  creators: y,
275
287
  contributors: b,
276
288
  publisher: m,
@@ -290,7 +302,7 @@ var v = async (e, t = {}) => n(e, (e) => e.isDir ? {
290
302
  };
291
303
  //#endregion
292
304
  //#region src/metadata/opf/readArchiveOpf.ts
293
- async function R(e) {
305
+ async function z(e) {
294
306
  let { data: t, basePath: n } = O(e) || {};
295
307
  if (!(!t || t.dir)) return {
296
308
  opf: fe(await D(t)),
@@ -299,7 +311,7 @@ async function R(e) {
299
311
  }
300
312
  //#endregion
301
313
  //#region src/metadata/apple/parse.ts
302
- var z = "com.apple.ibooks.display-options.xml", pe = (e) => e.childrenNamed("option").map((e) => ({
314
+ var B = "com.apple.ibooks.display-options.xml", pe = (e) => e.childrenNamed("option").map((e) => ({
303
315
  name: e.attr?.name,
304
316
  value: e.val
305
317
  })), me = (e) => {
@@ -310,7 +322,7 @@ var z = "com.apple.ibooks.display-options.xml", pe = (e) => e.childrenNamed("opt
310
322
  kind: "apple",
311
323
  displayOptions: { ...n === void 0 ? {} : { platform: { options: pe(n) } } }
312
324
  };
313
- }, B = "ComicInfo.xml", he = /* @__PURE__ */ "AgeRating.AlternateCount.AlternateNumber.AlternateSeries.BlackAndWhite.Characters.Colorist.CommunityRating.Count.CoverArtist.Day.Editor.Format.Genre.GTIN.Imprint.Inker.LanguageISO.Letterer.Locations.MainCharacterOrTeam.Manga.Month.Notes.Number.PageCount.Penciller.Publisher.Review.ScanInformation.Series.SeriesGroup.StoryArc.StoryArcNumber.Summary.Tags.Teams.Title.Translator.Volume.Web.Writer.Year".split("."), ge = /* @__PURE__ */ new Set(["Pages", "ComicInfo"]), _e = (e) => e.children.some((e) => e.type === "element"), ve = (e) => {
325
+ }, V = "ComicInfo.xml", he = /* @__PURE__ */ "AgeRating.AlternateCount.AlternateNumber.AlternateSeries.BlackAndWhite.Characters.Colorist.CommunityRating.Count.CoverArtist.Day.Editor.Format.Genre.GTIN.Imprint.Inker.LanguageISO.Letterer.Locations.MainCharacterOrTeam.Manga.Month.Notes.Number.PageCount.Penciller.Publisher.Review.ScanInformation.Series.SeriesGroup.StoryArc.StoryArcNumber.Summary.Tags.Teams.Title.Translator.Volume.Web.Writer.Year".split("."), ge = /* @__PURE__ */ new Set(["Pages", "ComicInfo"]), _e = (e) => e.children.some((e) => e.type === "element"), ve = (e) => {
314
326
  let t = e.val.trim();
315
327
  return t.length > 0 ? t : void 0;
316
328
  }, ye = (e) => {
@@ -319,7 +331,7 @@ var z = "com.apple.ibooks.display-options.xml", pe = (e) => e.childrenNamed("opt
319
331
  t = new h(e);
320
332
  } catch (e) {
321
333
  let t = e instanceof Error ? e.message : String(e);
322
- throw Error(`${B} is malformed: ${t}`, { cause: e });
334
+ throw Error(`${V} is malformed: ${t}`, { cause: e });
323
335
  }
324
336
  let n = {};
325
337
  return t.eachChild((e) => {
@@ -330,21 +342,21 @@ var z = "com.apple.ibooks.display-options.xml", pe = (e) => e.childrenNamed("opt
330
342
  kind: "comicInfo",
331
343
  ...n
332
344
  };
333
- }, V = "com.kobobooks.display-options.xml", be = (e) => {
345
+ }, be = "com.kobobooks.display-options.xml", xe = (e) => {
334
346
  let t = e.childNamed("platform");
335
347
  if (!t) return {};
336
348
  for (let e of t.childrenNamed("option")) if (e.attr?.name === "fixed-layout") return e.val.trim().toLowerCase() === "true" ? { renditionLayout: "pre-paginated" } : {};
337
349
  return {};
338
- }, xe = (e) => {
350
+ }, Se = (e) => {
339
351
  let t = new h(e);
340
352
  return t.name?.toLowerCase() === "display_options" ? {
341
353
  kind: "kobo",
342
- ...be(t)
354
+ ...xe(t)
343
355
  } : { kind: "kobo" };
344
356
  }, H = (e) => {
345
357
  let t = Object.entries(e).filter(([, e]) => e !== void 0);
346
358
  return Object.fromEntries(t);
347
- }, Se = (e) => {
359
+ }, Ce = (e) => {
348
360
  let t = [];
349
361
  for (let n of e.split("/")) if (n !== ".") {
350
362
  if (n === "..") {
@@ -354,12 +366,12 @@ var z = "com.apple.ibooks.display-options.xml", pe = (e) => e.childrenNamed("opt
354
366
  t.push(n);
355
367
  }
356
368
  return t.join("/");
357
- }, Ce = (e, t) => /^https?:\/\//.test(e) ? e : Se(t ? `${t}/${e}` : e), we = (e) => {
369
+ }, we = (e, t) => /^https?:\/\//.test(e) ? e : Ce(t ? `${t}/${e}` : e), Te = (e) => {
358
370
  let t = e?.trim().toLowerCase();
359
371
  return t === "reflowable" || t === "pre-paginated" ? t : void 0;
360
- }, Te = (e, { opf: t, basePath: n }) => {
361
- let r = we(t.renditionLayoutMeta), i = t.spineRows.map((t) => {
362
- let r = Ce(t.href, n);
372
+ }, Ee = (e, { opf: t, basePath: n }) => {
373
+ let r = Te(t.renditionLayoutMeta), i = t.spineRows.map((t) => {
374
+ let r = we(t.href, n);
363
375
  return {
364
376
  row: t,
365
377
  uri: r,
@@ -377,11 +389,11 @@ var z = "com.apple.ibooks.display-options.xml", pe = (e) => e.childrenNamed("opt
377
389
  pageSpreadRight: e.pageSpreadRight,
378
390
  progressionWeight: a > 0 ? (i?.size ?? 0) / a : 1 / t.spineRows.length
379
391
  }));
380
- }, Ee = B.toLowerCase(), De = z.toLowerCase(), Oe = (e) => {
392
+ }, De = V.toLowerCase(), Oe = B.toLowerCase(), ke = (e) => {
381
393
  let t = e.basename.toLowerCase();
382
- return t === Ee || t === De || e.uri.endsWith("com.kobobooks.display-options.xml") || t.endsWith(".db");
383
- }, ke = (e) => {
384
- let t = e.records.filter(x).filter((e) => !Oe(e));
394
+ return t === De || t === Oe || e.uri.endsWith("com.kobobooks.display-options.xml") || t.endsWith(".db");
395
+ }, Ae = (e) => {
396
+ let t = e.records.filter(x).filter((e) => !ke(e));
385
397
  return t.map((e) => {
386
398
  let n = f(e.encodingFormat ?? "") || o(e.basename);
387
399
  return H({
@@ -393,18 +405,18 @@ var z = "com.apple.ibooks.display-options.xml", pe = (e) => e.childrenNamed("opt
393
405
  });
394
406
  });
395
407
  }, U = async (e, { opf: t } = {}) => {
396
- let n = t ?? await R(e).catch(() => void 0);
397
- return n ? Te(e, n) : ke(e);
398
- }, Ae = (e, t) => {
408
+ let n = t ?? await z(e).catch(() => void 0);
409
+ return n ? Ee(e, n) : Ae(e);
410
+ }, je = (e, t) => {
399
411
  let n = C(e, t);
400
412
  if (n !== void 0) return f(n.encodingFormat ?? "") || o(n.basename);
401
- }, je = async (e, { opf: t, readingOrder: n } = {}) => {
402
- let r = t ?? await R(e).catch(() => void 0);
413
+ }, W = async (e, { opf: t, readingOrder: n } = {}) => {
414
+ let r = t ?? await z(e).catch(() => void 0);
403
415
  if (r !== void 0 && r.opf.coverHref !== void 0) {
404
- let t = Ce(r.opf.coverHref, r.basePath);
416
+ let t = we(r.opf.coverHref, r.basePath);
405
417
  return H({
406
418
  uri: t,
407
- mediaType: Ae(e, t),
419
+ mediaType: je(e, t),
408
420
  confidence: "derived"
409
421
  });
410
422
  }
@@ -417,7 +429,7 @@ var z = "com.apple.ibooks.display-options.xml", pe = (e) => e.childrenNamed("opt
417
429
  }, Me = (e) => {
418
430
  let t = e.descendantWithPath("head")?.childrenNamed("meta").find((e) => e.attr.name === "viewport");
419
431
  return !!(t && t.attr.name === "viewport");
420
- }, W = async (e, n) => {
432
+ }, Ne = async (e, n) => {
421
433
  if (n.length === 0) return !1;
422
434
  for (let r of n) {
423
435
  if (!d({
@@ -433,126 +445,106 @@ var z = "com.apple.ibooks.display-options.xml", pe = (e) => e.childrenNamed("opt
433
445
  }
434
446
  }
435
447
  return !0;
436
- }, Ne = z.toLowerCase();
437
- async function G(e) {
438
- let t = e.records.find((e) => x(e) && e.basename.toLowerCase() === Ne);
448
+ }, Pe = B.toLowerCase();
449
+ async function Fe(e) {
450
+ let t = e.records.find((e) => x(e) && e.basename.toLowerCase() === Pe);
439
451
  if (t) return me(await D(t));
440
452
  }
441
453
  //#endregion
442
- //#region src/metadata/apple/resolve.ts
443
- var Pe = { displayOptions: "apple.options" }, K = (e) => {
444
- let t = e.displayOptions?.platform?.options, n = t?.find((e) => e.name === "fixed-layout")?.value.trim().toLowerCase(), r = n === "true" || n !== "false" && void 0, i = H({
445
- fixedLayout: r,
446
- options: t !== void 0 && t.length > 0 ? t.map(({ name: e, value: t }) => H({
447
- name: e,
448
- value: t
449
- })) : void 0
450
- });
451
- return H({
452
- renditionLayout: r === !0 ? "pre-paginated" : void 0,
453
- apple: Object.keys(i).length > 0 ? i : void 0
454
- });
455
- }, Fe = B.toLowerCase(), q = (e) => e.records.find((e) => x(e) && e.basename.toLowerCase() === Fe), Ie = [
454
+ //#region src/metadata/comicInfo/getArchiveHasComicInfo.ts
455
+ var Ie = V.toLowerCase(), Le = (e) => e.records.find((e) => x(e) && e.basename.toLowerCase() === Ie), Re = [
456
456
  "Unknown",
457
457
  "No",
458
458
  "Yes",
459
459
  "YesAndRightToLeft"
460
- ], Le = (e) => {
461
- for (let t of Ie) if (t === e) return !0;
460
+ ], ze = (e) => {
461
+ for (let t of Re) if (t === e) return !0;
462
462
  return !1;
463
463
  };
464
464
  //#endregion
465
465
  //#region src/metadata/comicInfo/readArchiveComicInfo.ts
466
- async function Re(e) {
467
- let t = q(e);
466
+ async function Be(e) {
467
+ let t = Le(e);
468
468
  if (t) return ye(await D(t));
469
469
  }
470
470
  //#endregion
471
- //#region src/metadata/comicInfo/resolve.ts
472
- var ze = {
473
- AgeRating: "comic.ageRating",
474
- AlternateCount: "comic.alternateSeries",
475
- AlternateNumber: "comic.alternateSeries",
476
- AlternateSeries: "comic.alternateSeries",
477
- BlackAndWhite: "comic.blackAndWhite",
478
- Characters: "comic.characters",
479
- Colorist: "contributors",
480
- CommunityRating: "comic.communityRating",
481
- Count: "belongsTo.series",
482
- CoverArtist: "contributors",
483
- Day: "publication.edition.date",
484
- Editor: "contributors",
485
- Format: "comic.format",
486
- Genre: "subjects",
487
- GTIN: "identifiers",
488
- Imprint: "publication.edition.imprint",
489
- Inker: "contributors",
490
- LanguageISO: "languages",
491
- Letterer: "contributors",
492
- Locations: "comic.locations",
493
- MainCharacterOrTeam: "comic.mainCharacterOrTeam",
494
- Manga: "readingDirection",
495
- Month: "publication.edition.date",
496
- Notes: "comic.notes",
497
- Number: "belongsTo.series",
498
- PageCount: "numberOfPages",
499
- Penciller: "contributors",
500
- Publisher: "publication.edition.publisher",
501
- Review: "comic.review",
502
- ScanInformation: "comic.scanInformation",
503
- Series: "belongsTo.series",
504
- SeriesGroup: "belongsTo.collection",
505
- StoryArc: "comic.storyArcs",
506
- StoryArcNumber: "comic.storyArcs",
507
- Summary: "description",
508
- Tags: "subjects",
509
- Teams: "comic.teams",
510
- Title: "title",
511
- Translator: "contributors",
512
- Volume: "comic.volume",
513
- Web: "comic.web",
514
- Writer: "contributors",
515
- Year: "publication.edition.date"
516
- }, Be = (e) => {
471
+ //#region src/metadata/kobo/readArchiveKobo.ts
472
+ async function Ve(e) {
473
+ let n = e.records.filter((e) => x(e) && e.uri.endsWith("com.kobobooks.display-options.xml"));
474
+ if (n.length === 0) return;
475
+ let r;
476
+ for (let e of n) {
477
+ let n = await D(e);
478
+ try {
479
+ let { renditionLayout: e } = Se(n);
480
+ e && (r = e);
481
+ } catch (n) {
482
+ t.error(`Unable to parse ${be} (${e.uri})`, n);
483
+ }
484
+ }
485
+ return {
486
+ kind: "kobo",
487
+ ...r === void 0 ? {} : { renditionLayout: r }
488
+ };
489
+ }
490
+ //#endregion
491
+ //#region src/metadata/opf/getSpineItemFilesFromArchive.ts
492
+ var He = async ({ archive: e, archiveOpf: t }) => {
493
+ if (!t) return [];
494
+ let { opf: n, basePath: r } = t, { spineRows: i } = n;
495
+ return e.records.filter((e) => i.find((t) => r ? `${r}/${t.href}` === e.uri : `${t.href}` === e.uri));
496
+ }, Ue = (e) => e.toLowerCase().endsWith(".opf"), We = (e) => e.records.some((e) => !e.dir && (Ue(e.basename) || Ue(e.uri))), Ge = (e) => {
497
+ let t = e.displayOptions?.platform?.options, n = t?.find((e) => e.name === "fixed-layout")?.value.trim().toLowerCase(), r = n === "true" || n !== "false" && void 0, i = H({
498
+ fixedLayout: r,
499
+ options: t !== void 0 && t.length > 0 ? t.map(({ name: e, value: t }) => H({
500
+ name: e,
501
+ value: t
502
+ })) : void 0
503
+ });
504
+ return H({
505
+ renditionLayout: r === !0 ? "pre-paginated" : void 0,
506
+ apple: Object.keys(i).length > 0 ? i : void 0
507
+ });
508
+ }, Ke = (e) => {
517
509
  switch (e.Manga) {
518
510
  case "YesAndRightToLeft": return "rtl";
519
511
  case "Yes":
520
512
  case "No": return "ltr";
521
513
  default: return;
522
514
  }
523
- }, J = (e) => {
515
+ }, G = (e) => {
524
516
  if (e === void 0) return;
525
517
  let t = e.trim();
526
518
  return t.length > 0 ? t : void 0;
527
- }, Y = (e) => e === void 0 ? [] : e.split(",").map((e) => e.trim()).filter((e) => e.length > 0), X = (e) => {
528
- let t = J(e);
519
+ }, K = (e) => e === void 0 ? [] : e.split(",").map((e) => e.trim()).filter((e) => e.length > 0), q = (e) => {
520
+ let t = G(e);
529
521
  if (t === void 0 || !/^\d+$/.test(t)) return;
530
522
  let n = Number.parseInt(t, 10);
531
523
  return Number.isFinite(n) ? n : void 0;
532
- }, Z = (e) => {
533
- let t = J(e);
524
+ }, J = (e) => {
525
+ let t = G(e);
534
526
  if (t === void 0 || !/^\d+(\.\d+)?$/.test(t)) return;
535
527
  let n = Number.parseFloat(t);
536
528
  return Number.isFinite(n) ? n : void 0;
537
- }, Ve = (e) => {
538
- let t = J(e)?.toLowerCase();
529
+ }, qe = (e) => {
530
+ let t = G(e)?.toLowerCase();
539
531
  if (t === "yes") return !0;
540
532
  if (t === "no") return !1;
541
- }, He = (e) => {
533
+ }, Je = (e) => {
542
534
  switch (e.Manga) {
543
535
  case "Yes":
544
536
  case "YesAndRightToLeft": return !0;
545
537
  case "No": return !1;
546
538
  default: return;
547
539
  }
548
- }, Ue = (e) => {
549
- let t = X(e.Year), n = X(e.Month), r = X(e.Day);
540
+ }, Ye = (e) => {
541
+ let t = q(e.Year), n = q(e.Month), r = q(e.Day);
550
542
  if (!(t === void 0 && n === void 0 && r === void 0)) return {
551
543
  ...t === void 0 ? {} : { year: t },
552
544
  ...n === void 0 ? {} : { month: n },
553
545
  ...r === void 0 ? {} : { day: r }
554
546
  };
555
- }, We = [
547
+ }, Xe = [
556
548
  ["Writer", "author"],
557
549
  ["Penciller", "penciler"],
558
550
  ["Inker", "inker"],
@@ -561,9 +553,9 @@ var ze = {
561
553
  ["CoverArtist", "coverArtist"],
562
554
  ["Editor", "editor"],
563
555
  ["Translator", "translator"]
564
- ], Ge = (e) => {
556
+ ], Ze = (e) => {
565
557
  let t = /* @__PURE__ */ new Map();
566
- for (let [n, r] of We) for (let i of Y(e[n])) {
558
+ for (let [n, r] of Xe) for (let i of K(e[n])) {
567
559
  let e = t.get(i);
568
560
  e ? e.roles.includes(r) || e.roles.push(r) : t.set(i, {
569
561
  name: i,
@@ -571,132 +563,105 @@ var ze = {
571
563
  });
572
564
  }
573
565
  return [...t.values()];
574
- }, Ke = (e) => {
575
- let t = J(e.Series);
576
- if (t !== void 0) return H({
577
- name: t,
578
- position: Z(e.Number),
579
- total: X(e.Count)
566
+ }, Qe = (e) => {
567
+ let t = H({
568
+ name: G(e.Series),
569
+ position: J(e.Number),
570
+ total: q(e.Count)
580
571
  });
581
- }, qe = (e) => {
582
- let t = J(e.AlternateSeries);
572
+ return Object.keys(t).length > 0 ? t : void 0;
573
+ }, $e = (e) => {
574
+ let t = G(e.AlternateSeries);
583
575
  if (t !== void 0) return H({
584
576
  name: t,
585
- position: Z(e.AlternateNumber),
586
- total: X(e.AlternateCount)
577
+ position: J(e.AlternateNumber),
578
+ total: q(e.AlternateCount)
587
579
  });
588
- }, Je = (e) => {
589
- let t = Y(e.StoryArc);
580
+ }, et = (e) => {
581
+ let t = K(e.StoryArc);
590
582
  if (t.length === 0) return [];
591
- let n = Y(e.StoryArcNumber);
583
+ let n = K(e.StoryArcNumber);
592
584
  return t.map((e, t) => H({
593
585
  name: e,
594
- position: Z(n[t])
586
+ position: J(n[t])
595
587
  }));
596
- }, Q = (e) => e.length > 0 ? e : void 0, Ye = (e) => (e.Web ?? "").split(/\s+/).filter((e) => e.length > 0), Xe = (e) => {
588
+ }, Y = (e) => e.length > 0 ? e : void 0, tt = (e) => (e.Web ?? "").split(/\s+/).filter((e) => e.length > 0), nt = (e) => {
597
589
  try {
598
590
  let t = new URL(e);
599
591
  return (t.protocol === "http:" || t.protocol === "https:") && t.hostname.length > 0;
600
592
  } catch {
601
593
  return !1;
602
594
  }
603
- }, Ze = (e) => e.filter((e, t, n) => Xe(e) && n.indexOf(e) === t).map((e) => ({
595
+ }, rt = (e) => e.filter((e, t, n) => nt(e) && n.indexOf(e) === t).map((e) => ({
604
596
  value: e,
605
597
  scheme: "URL"
606
- })), Qe = (e, t) => {
598
+ })), it = (e, t) => {
607
599
  let n = H({
608
- manga: He(e),
609
- blackAndWhite: Ve(e.BlackAndWhite),
610
- volume: X(e.Volume),
611
- format: J(e.Format),
612
- ageRating: J(e.AgeRating),
613
- communityRating: Z(e.CommunityRating),
614
- notes: J(e.Notes),
615
- review: J(e.Review),
616
- web: Q(t),
617
- scanInformation: J(e.ScanInformation),
618
- mainCharacterOrTeam: J(e.MainCharacterOrTeam),
619
- characters: Q(Y(e.Characters)),
620
- teams: Q(Y(e.Teams)),
621
- locations: Q(Y(e.Locations)),
622
- storyArcs: Q(Je(e)),
623
- alternateSeries: qe(e)
600
+ manga: Je(e),
601
+ blackAndWhite: qe(e.BlackAndWhite),
602
+ volume: q(e.Volume),
603
+ format: G(e.Format),
604
+ ageRating: G(e.AgeRating),
605
+ communityRating: J(e.CommunityRating),
606
+ notes: G(e.Notes),
607
+ review: G(e.Review),
608
+ web: Y(t),
609
+ scanInformation: G(e.ScanInformation),
610
+ mainCharacterOrTeam: G(e.MainCharacterOrTeam),
611
+ characters: Y(K(e.Characters)),
612
+ teams: Y(K(e.Teams)),
613
+ locations: Y(K(e.Locations)),
614
+ storyArcs: Y(et(e)),
615
+ alternateSeries: $e(e)
624
616
  });
625
617
  return Object.keys(n).length > 0 ? n : void 0;
626
- }, $e = (e) => {
627
- let t = Ke(e), n = Q(Y(e.SeriesGroup).map((e) => ({ name: e })));
618
+ }, at = (e) => {
619
+ let t = Qe(e), n = Y(K(e.SeriesGroup).map((e) => ({ name: e })));
628
620
  if (!(t === void 0 && n === void 0)) return H({
629
621
  series: t === void 0 ? void 0 : [t],
630
622
  collection: n
631
623
  });
632
- }, et = (e) => {
633
- let t = e.GTIN, n = J(t), r = Ye(e), i = [...n === void 0 ? [] : [{
624
+ }, ot = (e) => {
625
+ let t = e.GTIN, n = G(t), r = tt(e), i = [...n === void 0 ? [] : [{
634
626
  value: n,
635
627
  scheme: "GTIN"
636
- }], ...Ze(r)], a = J(e.LanguageISO), o = [...Y(e.Genre), ...Y(e.Tags)], s = H({
637
- date: Ue(e),
638
- publisher: J(e.Publisher),
639
- imprint: J(e.Imprint)
640
- });
628
+ }], ...rt(r)], a = G(e.LanguageISO), o = [...K(e.Genre), ...K(e.Tags)], s = H({
629
+ date: Ye(e),
630
+ publisher: G(e.Publisher),
631
+ imprint: G(e.Imprint)
632
+ }), c = G(e.Title);
641
633
  return H({
642
- title: J(e.Title),
643
- description: J(e.Summary),
634
+ titles: c === void 0 ? void 0 : [{ value: c }],
635
+ description: G(e.Summary),
644
636
  publication: s.date !== void 0 || s.publisher !== void 0 || s.imprint !== void 0 ? { edition: s } : void 0,
645
637
  languages: a === void 0 ? void 0 : [a],
646
- subjects: Q(o),
647
- contributors: Q(Ge(e)),
648
- readingDirection: Be(e),
649
- numberOfPages: X(e.PageCount),
650
- identifiers: Q(i),
651
- belongsTo: $e(e),
652
- comic: Qe(e, r)
638
+ subjects: Y(o),
639
+ contributors: Y(Ze(e)),
640
+ readingDirection: Ke(e),
641
+ numberOfPages: q(e.PageCount),
642
+ identifiers: Y(i),
643
+ belongsTo: at(e),
644
+ comicInfo: it(e, r)
653
645
  });
654
- };
655
- //#endregion
656
- //#region src/metadata/kobo/readArchiveKobo.ts
657
- async function tt(e) {
658
- let n = e.records.filter((e) => x(e) && e.uri.endsWith("com.kobobooks.display-options.xml"));
659
- if (n.length === 0) return;
660
- let r;
661
- for (let e of n) {
662
- let n = await D(e);
663
- try {
664
- let { renditionLayout: e } = xe(n);
665
- e && (r = e);
666
- } catch (n) {
667
- t.error(`Unable to parse ${V} (${e.uri})`, n);
668
- }
669
- }
670
- return {
671
- kind: "kobo",
672
- ...r === void 0 ? {} : { renditionLayout: r }
673
- };
674
- }
675
- //#endregion
676
- //#region src/metadata/kobo/resolve.ts
677
- var nt = { renditionLayout: "renditionLayout" }, rt = (e) => H({
646
+ }, st = (e) => H({
678
647
  renditionLayout: e.renditionLayout,
679
648
  kobo: e.renditionLayout === void 0 ? void 0 : { fixedLayout: e.renditionLayout === "pre-paginated" }
680
- }), it = async ({ archive: e, archiveOpf: t }) => {
681
- if (!t) return [];
682
- let { opf: n, basePath: r } = t, { spineRows: i } = n;
683
- return e.records.filter((e) => i.find((t) => r ? `${r}/${t.href}` === e.uri : `${t.href}` === e.uri));
684
- }, at = (e) => e.toLowerCase().endsWith(".opf"), ot = (e) => e.records.some((e) => !e.dir && (at(e.basename) || at(e.uri))), st = /* @__PURE__ */ new Set([
649
+ }), ct = /* @__PURE__ */ new Set([
685
650
  8,
686
651
  12,
687
652
  13,
688
653
  14
689
- ]), ct = (e) => {
654
+ ]), lt = (e) => {
690
655
  if (e == null) return;
691
656
  let t = String(e).replace(/\D/g, "");
692
- if (!(t.length === 0 || !st.has(t.length))) return t;
693
- }, lt = /(?:97[89])?\d{9}[\dXx]/, ut = (e) => {
657
+ if (!(t.length === 0 || !ct.has(t.length))) return t;
658
+ }, ut = /(?:97[89])?\d{9}[\dXx]/, dt = (e) => {
694
659
  if (e == null) return;
695
660
  let t = String(e).trim().replace(/^urn:isbn:/i, "").replace(/^isbn[:\s-]*/i, ""), n = t.replace(/[^0-9Xx]/g, "");
696
661
  if (n.length === 10 || n.length === 13) return n.toUpperCase();
697
- let r = t.match(lt);
662
+ let r = t.match(ut);
698
663
  if (r) return r[0].toUpperCase();
699
- }, dt = (e) => {
664
+ }, ft = (e) => {
700
665
  if (e === void 0) return;
701
666
  let t = e.trim().match(/^(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?/);
702
667
  if (t === null) return;
@@ -706,35 +671,14 @@ var nt = { renditionLayout: "renditionLayout" }, rt = (e) => H({
706
671
  ...r === void 0 ? {} : { month: Number.parseInt(r, 10) },
707
672
  ...i === void 0 ? {} : { day: Number.parseInt(i, 10) }
708
673
  };
709
- }, ft = {
710
- manifestItems: "readingOrder",
711
- spineRows: "readingOrder",
712
- spineTocIdref: "toc",
713
- identifiers: "identifiers",
714
- title: "title",
715
- creators: "contributors",
716
- contributors: "contributors",
717
- publisher: "publication.edition.publisher",
718
- description: "description",
719
- rights: "rights",
720
- languages: "languages",
721
- subjects: "subjects",
722
- date: "publication.edition.date",
723
- coverHref: "cover",
724
- renditionLayoutMeta: "renditionLayout",
725
- renditionFlowMeta: "renditionFlow",
726
- renditionSpreadMeta: "renditionSpread",
727
- pageProgressionDirection: "readingDirection",
728
- guide: "guide",
729
- metas: "properties"
730
674
  }, pt = (e) => {
731
675
  let t = e.trim();
732
676
  if (/^https?:\/\//i.test(t)) try {
733
677
  let e = new URL(t);
734
678
  if ((e.protocol === "http:" || e.protocol === "https:") && e.hostname.length > 0) return "URL";
735
679
  } catch {}
736
- let n = ut(t);
737
- return n !== void 0 && (n.length === 10 || /^97[89]/.test(n)) ? "ISBN" : ct(t) === void 0 ? "Unknown" : "GTIN";
680
+ let n = dt(t);
681
+ return n !== void 0 && (n.length === 10 || /^97[89]/.test(n)) ? "ISBN" : lt(t) === void 0 ? "Unknown" : "GTIN";
738
682
  }, mt = (e) => {
739
683
  switch (e.trim().toLowerCase()) {
740
684
  case "isbn": return "ISBN";
@@ -756,14 +700,14 @@ var nt = { renditionLayout: "renditionLayout" }, rt = (e) => H({
756
700
  ill: "illustrator",
757
701
  nrt: "narrator",
758
702
  trl: "translator"
759
- }, gt = (e) => e.contributors.map((e) => {
703
+ }, gt = (e) => e.map((e) => {
760
704
  let t = e.roles.map((e) => ht[e.trim().toLowerCase()] ?? e);
761
705
  return H({
762
706
  name: e.name,
763
707
  roles: t.length > 0 ? t : [e.source === "creator" ? "author" : "contributor"],
764
708
  sortAs: e.fileAs
765
709
  });
766
- }), _t = (e, t) => e.refines !== void 0 && e.refines.replace(/^#/, "") === t, vt = {
710
+ }), X = (e, t) => e.refines !== void 0 && e.refines.replace(/^#/, "") === t, _t = {
767
711
  "02": "ISBN",
768
712
  "03": "GTIN",
769
713
  "04": "UPC",
@@ -779,24 +723,49 @@ var nt = { renditionLayout: "renditionLayout" }, rt = (e) => H({
779
723
  26: "DOI",
780
724
  34: "GTIN",
781
725
  35: "ARK"
782
- }, yt = (e) => {
726
+ }, vt = (e) => {
783
727
  let t = e?.value?.trim();
784
- if (!(t === void 0 || t.length === 0)) return e?.scheme?.trim().toLowerCase() === "onix:codelist5" ? vt[t] ?? t : t;
785
- }, bt = (e, t) => {
728
+ if (!(t === void 0 || t.length === 0)) return e?.scheme?.trim().toLowerCase() === "onix:codelist5" ? _t[t] ?? t : t;
729
+ }, yt = (e, t) => {
786
730
  let n = e.id;
787
- if (n !== void 0) return yt(t.find((e) => e.property === "identifier-type" && _t(e, n) && e.value !== void 0));
788
- }, xt = (e) => {
731
+ if (n !== void 0) return vt(t.find((e) => e.property === "identifier-type" && X(e, n) && e.value !== void 0));
732
+ }, bt = (e) => {
789
733
  let t = e?.trim();
790
734
  if (t === void 0 || !/^\d+(\.\d+)?$/.test(t)) return;
791
735
  let n = Number.parseFloat(t);
792
736
  return Number.isFinite(n) ? n : void 0;
793
- }, St = (e) => {
737
+ }, xt = (e) => {
738
+ let t = e?.trim();
739
+ if (t === void 0 || !/^\d+$/.test(t)) return;
740
+ let n = Number.parseInt(t, 10);
741
+ return Number.isFinite(n) ? n : void 0;
742
+ }, Z = (e) => {
743
+ let t = e?.trim();
744
+ return t !== void 0 && t.length > 0 ? t : void 0;
745
+ }, Q = (e, t, n) => t === void 0 ? void 0 : e.find((e) => X(e, t) && e.property === n && e.value !== void 0)?.value, St = (e, t) => e.map((e) => H({
746
+ value: e.value,
747
+ type: Z(Q(t, e.id, "title-type"))?.toLowerCase(),
748
+ displaySeq: xt(Q(t, e.id, "display-seq")),
749
+ sortAs: Z(Q(t, e.id, "file-as"))
750
+ })), Ct = (e, t) => {
751
+ if (t === void 0) return;
752
+ let n = e.flatMap((n) => {
753
+ if (!X(n, t) || n.property !== "dcterms:identifier") return [];
754
+ let r = Z(n.value);
755
+ return r === void 0 ? [] : [{
756
+ value: r,
757
+ scheme: mt(vt(e.find((e) => n.id !== void 0 && X(e, n.id) && e.property === "identifier-type")) ?? pt(r))
758
+ }];
759
+ });
760
+ return n.length > 0 ? n : void 0;
761
+ }, wt = (e) => {
794
762
  let t = [], n = [];
795
763
  for (let r of e) {
796
764
  if (r.property !== "belongs-to-collection" || r.value === void 0) continue;
797
- let i = r.id, a = (t) => i === void 0 ? void 0 : e.find((e) => _t(e, i) && e.property === t && e.value !== void 0)?.value, o = a("collection-type")?.trim().toLowerCase(), s = H({
765
+ let i = r.id, a = (t) => Q(e, i, t), o = a("collection-type")?.trim().toLowerCase(), s = H({
798
766
  name: r.value,
799
- position: xt(a("group-position"))
767
+ identifiers: Ct(e, i),
768
+ position: bt(a("group-position"))
800
769
  });
801
770
  o === "series" ? t.push(s) : n.push(s);
802
771
  }
@@ -804,55 +773,55 @@ var nt = { renditionLayout: "renditionLayout" }, rt = (e) => H({
804
773
  let n = e.find((e) => e.name?.toLowerCase() === "calibre:series" && e.content !== void 0)?.content;
805
774
  n !== void 0 && t.push(H({
806
775
  name: n,
807
- position: xt(e.find((e) => e.name?.toLowerCase() === "calibre:series_index")?.content)
776
+ position: bt(e.find((e) => e.name?.toLowerCase() === "calibre:series_index")?.content)
808
777
  }));
809
778
  }
810
779
  return {
811
780
  series: t,
812
781
  collection: n
813
782
  };
814
- }, Ct = (e) => {
783
+ }, Tt = (e) => {
815
784
  let t = e?.trim();
816
785
  if (t === "scrolled-continuous" || t === "scrolled-doc" || t === "paginated" || t === "auto") return t;
817
- }, wt = (e) => {
786
+ }, Et = (e) => {
818
787
  let t = e?.trim();
819
788
  if (t === "none" || t === "landscape" || t === "portrait" || t === "both" || t === "auto") return t;
820
- }, Tt = (e) => {
821
- let t = e.pageProgressionDirection?.trim().toLowerCase(), n = t === "ltr" || t === "rtl" ? t : void 0, r = e.renditionLayoutMeta?.trim().toLowerCase(), i = r === "reflowable" || r === "pre-paginated" ? r : void 0, a = gt(e), { series: o, collection: s } = St(e.metas), c = o.length > 0 || s.length > 0 ? H({
822
- series: o.length > 0 ? o : void 0,
823
- collection: s.length > 0 ? s : void 0
824
- }) : void 0, l = H({
825
- date: dt(e.date),
826
- publisher: e.publisher
789
+ }, Dt = (e) => {
790
+ let { titles: t, contributors: n, publisher: r, description: i, rights: a, languages: o, subjects: s, date: c, renditionLayoutMeta: l, renditionFlowMeta: u, renditionSpreadMeta: d, pageProgressionDirection: f, identifiers: p, metas: m, kind: h, creators: g, manifestItems: _, spineRows: v, spineTocIdref: y, coverHref: b, guide: x, ...S } = e, C = f?.trim().toLowerCase(), w = C === "ltr" || C === "rtl" ? C : void 0, T = l?.trim().toLowerCase(), E = T === "reflowable" || T === "pre-paginated" ? T : void 0, D = gt(n), O = St(t, m), { series: k, collection: A } = wt(m), j = k.length > 0 || A.length > 0 ? H({
791
+ series: k.length > 0 ? k : void 0,
792
+ collection: A.length > 0 ? A : void 0
793
+ }) : void 0, M = H({
794
+ date: ft(c),
795
+ publisher: r
827
796
  });
828
797
  return H({
829
- title: e.title,
830
- description: e.description,
831
- publication: l.date !== void 0 || l.publisher !== void 0 ? { edition: l } : void 0,
832
- rights: e.rights,
833
- languages: e.languages.length > 0 ? [...e.languages] : void 0,
834
- subjects: e.subjects.length > 0 ? [...e.subjects] : void 0,
835
- contributors: a.length > 0 ? a : void 0,
836
- readingDirection: n,
837
- renditionLayout: i,
838
- renditionFlow: Ct(e.renditionFlowMeta),
839
- renditionSpread: wt(e.renditionSpreadMeta),
840
- identifiers: e.identifiers.length > 0 ? e.identifiers.map((t) => H({
841
- value: t.value,
842
- scheme: mt(t.scheme ?? bt(t, e.metas) ?? pt(t.value)),
843
- unique: t.unique
798
+ titles: O.length > 0 ? O : void 0,
799
+ description: i,
800
+ publication: M.date !== void 0 || M.publisher !== void 0 ? { edition: M } : void 0,
801
+ rights: a,
802
+ languages: o.length > 0 ? [...o] : void 0,
803
+ subjects: s.length > 0 ? [...s] : void 0,
804
+ contributors: D.length > 0 ? D : void 0,
805
+ readingDirection: w,
806
+ renditionLayout: E,
807
+ renditionFlow: Tt(u),
808
+ renditionSpread: Et(d),
809
+ identifiers: p.length > 0 ? p.map((e) => H({
810
+ value: e.value,
811
+ scheme: mt(e.scheme ?? yt(e, m) ?? pt(e.value)),
812
+ unique: e.unique
844
813
  })) : void 0,
845
- belongsTo: c,
846
- properties: e.metas.length > 0 ? [...e.metas] : void 0
814
+ belongsTo: j,
815
+ properties: m.length > 0 ? [...m] : void 0
847
816
  });
848
- }, Et = (e) => e.kind === "comicInfo" ? et(e) : e.kind === "kobo" ? rt(e) : e.kind === "apple" ? K(e) : Tt(e), Dt = (e) => {
849
- let t = e.opf === void 0 ? void 0 : Tt(e.opf), n = e.comicInfo === void 0 ? void 0 : et(e.comicInfo), r = e.apple === void 0 ? void 0 : K(e.apple), i = e.kobo === void 0 ? void 0 : rt(e.kobo), a = [...t?.identifiers ?? [], ...n?.identifiers ?? []], o = H({
817
+ }, Ot = (e) => e.kind === "comicInfo" ? ot(e) : e.kind === "kobo" ? st(e) : e.kind === "apple" ? Ge(e) : Dt(e), kt = (e) => {
818
+ let t = e.opf === void 0 ? void 0 : Dt(e.opf), n = e.comicInfo === void 0 ? void 0 : ot(e.comicInfo), r = e.apple === void 0 ? void 0 : Ge(e.apple), i = e.kobo === void 0 ? void 0 : st(e.kobo), a = [...t?.identifiers ?? [], ...n?.identifiers ?? []], o = H({
850
819
  date: t?.publication?.edition?.date ?? n?.publication?.edition?.date,
851
820
  publisher: t?.publication?.edition?.publisher ?? n?.publication?.edition?.publisher,
852
821
  imprint: t?.publication?.edition?.imprint ?? n?.publication?.edition?.imprint
853
822
  });
854
823
  return H({
855
- title: t?.title ?? n?.title,
824
+ titles: t?.titles ?? n?.titles,
856
825
  description: t?.description ?? n?.description,
857
826
  publication: o.date !== void 0 || o.publisher !== void 0 || o.imprint !== void 0 ? { edition: o } : void 0,
858
827
  rights: t?.rights,
@@ -867,11 +836,11 @@ var nt = { renditionLayout: "renditionLayout" }, rt = (e) => H({
867
836
  identifiers: a.length > 0 ? a : void 0,
868
837
  belongsTo: t?.belongsTo ?? n?.belongsTo,
869
838
  properties: t?.properties,
870
- comic: n?.comic,
839
+ comicInfo: n?.comicInfo,
871
840
  apple: r?.apple,
872
841
  kobo: i?.kobo
873
842
  });
874
- }, Ot = (e) => {
843
+ }, At = (e) => {
875
844
  let t = [...e.records].sort((e, t) => p(e.uri, t.uri)), n = (e, t, r, i, a) => {
876
845
  let o = e.find((e) => e.title === t), [s, ...c] = r;
877
846
  return o ? s ? [...e.filter((e) => e !== o), {
@@ -900,71 +869,71 @@ var nt = { renditionLayout: "renditionLayout" }, rt = (e) => H({
900
869
  let a = encodeURI(t.uri).replace(/#/g, "%23").replace(/\?/g, "%3F").replace(/\/$/, ""), o = t.uri.replace(/\/$/, "");
901
870
  return n(e, r, i, a, o);
902
871
  }, []);
903
- }, kt = (e) => e ? e.children.map((e) => e instanceof _ ? e.text : e instanceof g ? kt(e) : "").join("").trim() : "", At = (e) => k(e.properties).includes("nav"), jt = (e, { basePath: t }) => {
872
+ }, jt = (e) => e ? e.children.map((e) => e instanceof _ ? e.text : e instanceof g ? jt(e) : "").join("").trim() : "", Mt = (e) => k(e.properties).includes("nav"), Nt = (e, { basePath: t }) => {
904
873
  let n = {
905
874
  contents: [],
906
875
  path: "",
907
876
  containerHref: "",
908
877
  title: ""
909
878
  }, r = e.childNamed("span") || e.childNamed("a");
910
- n.title = (r?.attr.title || r?.val.trim() || kt(r)) ?? "";
879
+ n.title = (r?.attr.title || r?.val.trim() || jt(r)) ?? "";
911
880
  let i = r?.name;
912
881
  i !== "a" && (r = e.descendantWithPath(`${i}.a`), r && (i = r.name.toLowerCase())), i === "a" && r?.attr.href && (n.path = m(t, r.attr.href), n.containerHref = n.path);
913
882
  let a = e.childNamed("ol");
914
883
  if (a) {
915
884
  let e = a.childrenNamed("li");
916
- e && e.length > 0 && (n.contents = e.map((e) => jt(e, { basePath: t })));
885
+ e && e.length > 0 && (n.contents = e.map((e) => Nt(e, { basePath: t })));
917
886
  }
918
887
  return n;
919
- }, Mt = (e, { basePath: t }) => {
888
+ }, Pt = (e, { basePath: t }) => {
920
889
  let n = [], r;
921
890
  return e.descendantWithPath("body.nav.ol") ? r = e.descendantWithPath("body.nav.ol")?.children : e.descendantWithPath("body.section.nav.ol") && (r = e.descendantWithPath("body.section.nav.ol")?.children), r && r.length > 0 && r.filter((e) => e instanceof g && e.name === "li").forEach((e) => {
922
- n.push(jt(e, { basePath: t }));
891
+ n.push(Nt(e, { basePath: t }));
923
892
  }), n;
924
- }, Nt = async (e, t) => {
925
- let n = e.manifestItems.find(At);
893
+ }, Ft = async (e, t) => {
894
+ let n = e.manifestItems.find(Mt);
926
895
  if (n?.href) {
927
896
  let e = t.records.find((e) => e.uri.endsWith(n.href));
928
- if (e && !e.dir) return Mt(new h(await D(e)), { basePath: c(e.uri) });
897
+ if (e && !e.dir) return Pt(new h(await D(e)), { basePath: c(e.uri) });
929
898
  }
930
- }, Pt = (e, { basePath: t, prefix: n }) => {
899
+ }, It = (e, { basePath: t, prefix: n }) => {
931
900
  let r = m(t, e?.childNamed(`${n}content`)?.attr.src || ""), i = {
932
901
  title: e?.descendantWithPath(`${n}navLabel.${n}text`)?.val || "",
933
902
  path: r,
934
903
  containerHref: r,
935
904
  contents: []
936
905
  }, a = e.childrenNamed(`${n}navPoint`);
937
- return a && a.length > 0 && (i.contents = a.map((e) => Pt(e, {
906
+ return a && a.length > 0 && (i.contents = a.map((e) => It(e, {
938
907
  basePath: t,
939
908
  prefix: n
940
909
  }))), i;
941
- }, Ft = (e, { basePath: t }) => {
910
+ }, Lt = (e, { basePath: t }) => {
942
911
  let n = [], r = e.name, i = "";
943
912
  return r.indexOf(":") !== -1 && (i = `${r.split(":")[0]}:`), e.childNamed(`${i}navMap`)?.childrenNamed(`${i}navPoint`).forEach((e) => {
944
- n.push(Pt(e, {
913
+ n.push(It(e, {
945
914
  basePath: t,
946
915
  prefix: i
947
916
  }));
948
917
  }), n;
949
- }, It = async ({ opf: e, opfBasePath: t, archive: n }) => {
918
+ }, Rt = async ({ opf: e, opfBasePath: t, archive: n }) => {
950
919
  let r = e.spineTocIdref;
951
920
  if (r) {
952
921
  let i = e.manifestItems.find((e) => e.id === r);
953
922
  if (i) {
954
923
  let e = `${t}${t === "" ? "" : "/"}${i.href}`, r = n.records.find((t) => t.uri.endsWith(e));
955
- if (r && !r.dir) return Ft(new h(await D(r)), { basePath: c(r.uri) });
924
+ if (r && !r.dir) return Lt(new h(await D(r)), { basePath: c(r.uri) });
956
925
  }
957
926
  }
958
- }, Lt = async (e, { opf: t } = {}) => {
959
- let n = t ?? await R(e);
960
- if (n) return await Nt(n.opf, e) || await It({
927
+ }, zt = async (e, { opf: t } = {}) => {
928
+ let n = t ?? await z(e);
929
+ if (n) return await Ft(n.opf, e) || await Rt({
961
930
  opf: n.opf,
962
931
  opfBasePath: n.basePath,
963
932
  archive: e
964
933
  }) || [];
965
- let r = Ot(e);
934
+ let r = At(e);
966
935
  return r.length === 0 ? void 0 : r;
967
- }, Rt = [
936
+ }, Bt = [
968
937
  "metadata",
969
938
  "readingOrder",
970
939
  "toc"
@@ -980,39 +949,39 @@ var nt = { renditionLayout: "renditionLayout" }, rt = (e) => H({
980
949
  failed: !0
981
950
  };
982
951
  }
983
- }, zt = (e) => {
952
+ }, Vt = (e) => {
984
953
  let t = (e) => e?.startsWith("audio/") === !0 || e?.startsWith("video/") === !0, n = e.filter((e) => e.renditionLayout === "pre-paginated" && !t(e.mediaType)).length;
985
954
  return n > 0 ? n : void 0;
986
- }, Bt = ({ archive: e, opf: t, comicInfo: n, apple: r, kobo: i }) => {
955
+ }, Ht = ({ archive: e, opf: t, comicInfo: n, apple: r, kobo: i }) => {
987
956
  let a = [];
988
- return t !== void 0 && t.value === void 0 && (t.failed || ot(e)) && a.push("opf"), n?.failed && a.push("comicInfo"), r?.failed && a.push("apple"), i?.failed && a.push("kobo"), a;
989
- }, Vt = 3, Ht = async (e, t = {}) => {
990
- let n = new Set(t.include ?? Rt), r = n.has("metadata"), i = n.has("sources"), a = n.has("readingOrder"), o = n.has("toc"), s = t.layoutScan === !0 && (r || a), c = r || i || a || o ? await $(() => R(e), "opf") : void 0, l = c?.value, u = r || i || s, d = u ? await $(() => Re(e), "comicInfo") : void 0, f = d?.value, p = u ? await $(() => G(e), "apple") : void 0, m = p?.value, h = u ? await $(() => tt(e), "kobo") : void 0, g = h?.value, _ = r || s ? Dt({
957
+ return t !== void 0 && t.value === void 0 && (t.failed || We(e)) && a.push("opf"), n?.failed && a.push("comicInfo"), r?.failed && a.push("apple"), i?.failed && a.push("kobo"), a;
958
+ }, Ut = 3, Wt = async (e, t = {}) => {
959
+ let n = new Set(t.include ?? Bt), r = n.has("metadata"), i = n.has("sources"), a = n.has("readingOrder"), o = n.has("toc"), s = t.layoutScan === !0 && (r || a), c = r || i || a || o ? await $(() => z(e), "opf") : void 0, l = c?.value, u = r || i || s, d = u ? await $(() => Be(e), "comicInfo") : void 0, f = d?.value, p = u ? await $(() => Fe(e), "apple") : void 0, m = p?.value, h = u ? await $(() => Ve(e), "kobo") : void 0, g = h?.value, _ = r || s ? kt({
991
960
  opf: l?.opf,
992
961
  comicInfo: f,
993
962
  apple: m,
994
963
  kobo: g
995
964
  }) : void 0, v = a || s ? await U(e, { opf: l }) : void 0;
996
- if (s && _ !== void 0 && v !== void 0 && _.renditionLayout === "reflowable" && v.every((e) => e.renditionLayout === "reflowable") && await W(e, v) && (_ = {
965
+ if (s && _ !== void 0 && v !== void 0 && _.renditionLayout === "reflowable" && v.every((e) => e.renditionLayout === "reflowable") && await Ne(e, v) && (_ = {
997
966
  ..._,
998
967
  renditionLayout: "pre-paginated"
999
968
  }, v = v.map((e) => ({
1000
969
  ...e,
1001
970
  renditionLayout: "pre-paginated"
1002
971
  }))), r && _ !== void 0) {
1003
- let t = v ?? await U(e, { opf: l }), n = await je(e, {
972
+ let t = v ?? await U(e, { opf: l }), n = await W(e, {
1004
973
  opf: l,
1005
974
  readingOrder: t
1006
- }), r = _.numberOfPages ?? zt(t);
975
+ }), r = _.numberOfPages ?? Vt(t);
1007
976
  _ = H({
1008
977
  ..._,
1009
978
  cover: n,
1010
979
  numberOfPages: r
1011
980
  });
1012
981
  }
1013
- let y = o ? (await $(() => Lt(e, { opf: l }), "toc")).value : void 0, b = {
1014
- version: Vt,
1015
- unreadableSources: Bt({
982
+ let y = o ? (await $(() => zt(e, { opf: l }), "toc")).value : void 0, b = {
983
+ version: Ut,
984
+ unreadableSources: Ht({
1016
985
  archive: e,
1017
986
  opf: c,
1018
987
  comicInfo: d,
@@ -1026,8 +995,8 @@ var nt = { renditionLayout: "renditionLayout" }, rt = (e) => H({
1026
995
  apple: m,
1027
996
  kobo: g
1028
997
  })), b;
1029
- };
998
+ }, Gt = (e) => e?.titles?.[0]?.value;
1030
999
  //#endregion
1031
- export { z as APPLE_IBOOKS_DISPLAY_OPTIONS_FILENAME, B as COMIC_INFO_FILENAME, he as COMIC_INFO_KNOWN_FIELDS, Ie as COMIC_INFO_MANGA_VALUES, V as KOBO_DISPLAY_OPTIONS_FILENAME, Pe as appleMetadataHomes, i as arrayBufferFileAccessors, r as blobFileAccessors, ze as comicInfoMetadataHomes, e as createArchive, v as createArchiveFromArrayBufferList, n as createArchiveFromEntries, y as createArchiveFromText, b as createArchiveFromUrls, C as getArchiveFileRecordByUri, q as getArchiveHasComicInfo, E as getArchiveImageRecords, O as getArchiveOpfInfo, it as getSpineItemFilesFromArchive, ot as isArchiveEpub, Le as isComicInfoManga, S as isDirectoryRecord, x as isFileRecord, T as isImageRecord, nt as koboMetadataHomes, ct as normalizeGtin, ut as normalizeIsbn, ft as opfMetadataHomes, me as parseAppleDisplayOptionsXml, ye as parseComicInfo, xe as parseKoboXml, fe as parseOpf, dt as parseW3cDtfDate, G as readArchiveApple, Re as readArchiveComicInfo, tt as readArchiveKobo, R as readArchiveOpf, D as readRecordAsText, W as readingOrderDocumentsAllHaveViewport, Ht as resolveArchive, je as resolveArchiveCover, Et as resolveArchiveMetadata, U as resolveArchiveReadingOrder, Lt as resolveArchiveToc, Dt as resolveMetadata, k as tokenizeXmlSpaceSeparatedList };
1000
+ export { B as APPLE_IBOOKS_DISPLAY_OPTIONS_FILENAME, V as COMIC_INFO_FILENAME, he as COMIC_INFO_KNOWN_FIELDS, Re as COMIC_INFO_MANGA_VALUES, be as KOBO_DISPLAY_OPTIONS_FILENAME, i as arrayBufferFileAccessors, r as blobFileAccessors, e as createArchive, v as createArchiveFromArrayBufferList, n as createArchiveFromEntries, y as createArchiveFromText, b as createArchiveFromUrls, C as getArchiveFileRecordByUri, Le as getArchiveHasComicInfo, E as getArchiveImageRecords, O as getArchiveOpfInfo, He as getSpineItemFilesFromArchive, We as isArchiveEpub, ze as isComicInfoManga, S as isDirectoryRecord, x as isFileRecord, T as isImageRecord, Gt as mainTitle, lt as normalizeGtin, dt as normalizeIsbn, me as parseAppleDisplayOptionsXml, ye as parseComicInfo, Se as parseKoboXml, fe as parseOpf, ft as parseW3cDtfDate, Fe as readArchiveApple, Be as readArchiveComicInfo, Ve as readArchiveKobo, z as readArchiveOpf, D as readRecordAsText, Ne as readingOrderDocumentsAllHaveViewport, Wt as resolveArchive, W as resolveArchiveCover, Ot as resolveArchiveMetadata, U as resolveArchiveReadingOrder, zt as resolveArchiveToc, kt as resolveMetadata, k as tokenizeXmlSpaceSeparatedList };
1032
1001
 
1033
1002
  //# sourceMappingURL=index.js.map