@prose-reader/archive-reader 1.349.0 → 1.352.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.
@@ -410,7 +410,7 @@ var B = "com.apple.ibooks.display-options.xml", pe = (e) => e.childrenNamed("opt
410
410
  }, je = (e, t) => {
411
411
  let n = C(e, t);
412
412
  if (n !== void 0) return f(n.encodingFormat ?? "") || o(n.basename);
413
- }, W = async (e, { opf: t, readingOrder: n } = {}) => {
413
+ }, Me = async (e, { opf: t, readingOrder: n } = {}) => {
414
414
  let r = t ?? await z(e).catch(() => void 0);
415
415
  if (r !== void 0 && r.opf.coverHref !== void 0) {
416
416
  let t = we(r.opf.coverHref, r.basePath);
@@ -426,10 +426,10 @@ var B = "com.apple.ibooks.display-options.xml", pe = (e) => e.childrenNamed("opt
426
426
  mediaType: i.mediaType,
427
427
  confidence: "assumed"
428
428
  });
429
- }, Me = (e) => {
429
+ }, Ne = (e) => {
430
430
  let t = e.descendantWithPath("head")?.childrenNamed("meta").find((e) => e.attr.name === "viewport");
431
431
  return !!(t && t.attr.name === "viewport");
432
- }, Ne = async (e, n) => {
432
+ }, Pe = async (e, n) => {
433
433
  if (n.length === 0) return !1;
434
434
  for (let r of n) {
435
435
  if (!d({
@@ -439,37 +439,37 @@ var B = "com.apple.ibooks.display-options.xml", pe = (e) => e.childrenNamed("opt
439
439
  let n = C(e, r.uri);
440
440
  if (!n || !x(n)) return !1;
441
441
  try {
442
- if (!Me(new h(await D(n)))) return !1;
442
+ if (!Ne(new h(await D(n)))) return !1;
443
443
  } catch (e) {
444
444
  return t.error(`layout scan: unable to inspect ${r.uri}`, e), !1;
445
445
  }
446
446
  }
447
447
  return !0;
448
- }, Pe = B.toLowerCase();
449
- async function Fe(e) {
450
- let t = e.records.find((e) => x(e) && e.basename.toLowerCase() === Pe);
448
+ }, Fe = B.toLowerCase();
449
+ async function Ie(e) {
450
+ let t = e.records.find((e) => x(e) && e.basename.toLowerCase() === Fe);
451
451
  if (t) return me(await D(t));
452
452
  }
453
453
  //#endregion
454
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 = [
455
+ var Le = V.toLowerCase(), Re = (e) => e.records.find((e) => x(e) && e.basename.toLowerCase() === Le), ze = [
456
456
  "Unknown",
457
457
  "No",
458
458
  "Yes",
459
459
  "YesAndRightToLeft"
460
- ], ze = (e) => {
461
- for (let t of Re) if (t === e) return !0;
460
+ ], Be = (e) => {
461
+ for (let t of ze) 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 Be(e) {
467
- let t = Le(e);
466
+ async function Ve(e) {
467
+ let t = Re(e);
468
468
  if (t) return ye(await D(t));
469
469
  }
470
470
  //#endregion
471
471
  //#region src/metadata/kobo/readArchiveKobo.ts
472
- async function Ve(e) {
472
+ async function He(e) {
473
473
  let n = e.records.filter((e) => x(e) && e.uri.endsWith("com.kobobooks.display-options.xml"));
474
474
  if (n.length === 0) return;
475
475
  let r;
@@ -489,11 +489,11 @@ async function Ve(e) {
489
489
  }
490
490
  //#endregion
491
491
  //#region src/metadata/opf/getSpineItemFilesFromArchive.ts
492
- var He = async ({ archive: e, archiveOpf: t }) => {
492
+ var Ue = async ({ archive: e, archiveOpf: t }) => {
493
493
  if (!t) return [];
494
494
  let { opf: n, basePath: r } = t, { spineRows: i } = n;
495
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) => {
496
+ }, We = (e) => e.toLowerCase().endsWith(".opf"), Ge = (e) => e.records.some((e) => !e.dir && (We(e.basename) || We(e.uri))), Ke = (e) => {
497
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
498
  fixedLayout: r,
499
499
  options: t !== void 0 && t.length > 0 ? t.map(({ name: e, value: t }) => H({
@@ -505,46 +505,46 @@ var He = async ({ archive: e, archiveOpf: t }) => {
505
505
  renditionLayout: r === !0 ? "pre-paginated" : void 0,
506
506
  apple: Object.keys(i).length > 0 ? i : void 0
507
507
  });
508
- }, Ke = (e) => {
508
+ }, qe = (e) => {
509
509
  switch (e.Manga) {
510
510
  case "YesAndRightToLeft": return "rtl";
511
511
  case "Yes":
512
512
  case "No": return "ltr";
513
513
  default: return;
514
514
  }
515
- }, G = (e) => {
515
+ }, W = (e) => {
516
516
  if (e === void 0) return;
517
517
  let t = e.trim();
518
518
  return t.length > 0 ? t : void 0;
519
- }, K = (e) => e === void 0 ? [] : e.split(",").map((e) => e.trim()).filter((e) => e.length > 0), q = (e) => {
520
- let t = G(e);
519
+ }, G = (e) => e === void 0 ? [] : e.split(",").map((e) => e.trim()).filter((e) => e.length > 0), K = (e) => {
520
+ let t = W(e);
521
521
  if (t === void 0 || !/^\d+$/.test(t)) return;
522
522
  let n = Number.parseInt(t, 10);
523
523
  return Number.isFinite(n) ? n : void 0;
524
- }, J = (e) => {
525
- let t = G(e);
524
+ }, q = (e) => {
525
+ let t = W(e);
526
526
  if (t === void 0 || !/^\d+(\.\d+)?$/.test(t)) return;
527
527
  let n = Number.parseFloat(t);
528
528
  return Number.isFinite(n) ? n : void 0;
529
- }, qe = (e) => {
530
- let t = G(e)?.toLowerCase();
529
+ }, Je = (e) => {
530
+ let t = W(e)?.toLowerCase();
531
531
  if (t === "yes") return !0;
532
532
  if (t === "no") return !1;
533
- }, Je = (e) => {
533
+ }, Ye = (e) => {
534
534
  switch (e.Manga) {
535
535
  case "Yes":
536
536
  case "YesAndRightToLeft": return !0;
537
537
  case "No": return !1;
538
538
  default: return;
539
539
  }
540
- }, Ye = (e) => {
541
- let t = q(e.Year), n = q(e.Month), r = q(e.Day);
540
+ }, Xe = (e) => {
541
+ let t = K(e.Year), n = K(e.Month), r = K(e.Day);
542
542
  if (!(t === void 0 && n === void 0 && r === void 0)) return {
543
543
  ...t === void 0 ? {} : { year: t },
544
544
  ...n === void 0 ? {} : { month: n },
545
545
  ...r === void 0 ? {} : { day: r }
546
546
  };
547
- }, Xe = [
547
+ }, Ze = [
548
548
  ["Writer", "author"],
549
549
  ["Penciller", "penciler"],
550
550
  ["Inker", "inker"],
@@ -553,9 +553,9 @@ var He = async ({ archive: e, archiveOpf: t }) => {
553
553
  ["CoverArtist", "coverArtist"],
554
554
  ["Editor", "editor"],
555
555
  ["Translator", "translator"]
556
- ], Ze = (e) => {
556
+ ], Qe = (e) => {
557
557
  let t = /* @__PURE__ */ new Map();
558
- for (let [n, r] of Xe) for (let i of K(e[n])) {
558
+ for (let [n, r] of Ze) for (let i of G(e[n])) {
559
559
  let e = t.get(i);
560
560
  e ? e.roles.includes(r) || e.roles.push(r) : t.set(i, {
561
561
  name: i,
@@ -563,105 +563,110 @@ var He = async ({ archive: e, archiveOpf: t }) => {
563
563
  });
564
564
  }
565
565
  return [...t.values()];
566
- }, Qe = (e) => {
566
+ }, $e = (e) => {
567
567
  let t = H({
568
- name: G(e.Series),
569
- position: J(e.Number),
570
- total: q(e.Count)
568
+ name: W(e.Series),
569
+ position: q(e.Number),
570
+ total: K(e.Count)
571
571
  });
572
572
  return Object.keys(t).length > 0 ? t : void 0;
573
- }, $e = (e) => {
574
- let t = G(e.AlternateSeries);
573
+ }, et = (e) => {
574
+ let t = W(e.AlternateSeries);
575
575
  if (t !== void 0) return H({
576
576
  name: t,
577
- position: J(e.AlternateNumber),
578
- total: q(e.AlternateCount)
577
+ position: q(e.AlternateNumber),
578
+ total: K(e.AlternateCount)
579
579
  });
580
- }, et = (e) => {
581
- let t = K(e.StoryArc);
580
+ }, tt = (e) => {
581
+ let t = G(e.StoryArc);
582
582
  if (t.length === 0) return [];
583
- let n = K(e.StoryArcNumber);
583
+ let n = G(e.StoryArcNumber);
584
584
  return t.map((e, t) => H({
585
585
  name: e,
586
- position: J(n[t])
586
+ position: q(n[t])
587
587
  }));
588
- }, Y = (e) => e.length > 0 ? e : void 0, tt = (e) => (e.Web ?? "").split(/\s+/).filter((e) => e.length > 0), nt = (e) => {
588
+ }, J = (e) => e.length > 0 ? e : void 0, nt = (e) => (e.Web ?? "").split(/\s+/).filter((e) => e.length > 0), rt = (e) => {
589
589
  try {
590
590
  let t = new URL(e);
591
591
  return (t.protocol === "http:" || t.protocol === "https:") && t.hostname.length > 0;
592
592
  } catch {
593
593
  return !1;
594
594
  }
595
- }, rt = (e) => e.filter((e, t, n) => nt(e) && n.indexOf(e) === t).map((e) => ({
595
+ }, it = (e) => e.filter((e, t, n) => rt(e) && n.indexOf(e) === t).map((e) => ({
596
596
  value: e,
597
597
  scheme: "URL"
598
- })), it = (e, t) => {
598
+ })), at = (e, t) => {
599
599
  let n = H({
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)
600
+ manga: Ye(e),
601
+ blackAndWhite: Je(e.BlackAndWhite),
602
+ volume: K(e.Volume),
603
+ format: W(e.Format),
604
+ ageRating: W(e.AgeRating),
605
+ notes: W(e.Notes),
606
+ review: W(e.Review),
607
+ web: J(t),
608
+ scanInformation: W(e.ScanInformation),
609
+ mainCharacterOrTeam: W(e.MainCharacterOrTeam),
610
+ characters: J(G(e.Characters)),
611
+ teams: J(G(e.Teams)),
612
+ locations: J(G(e.Locations)),
613
+ storyArcs: J(tt(e)),
614
+ alternateSeries: et(e)
616
615
  });
617
616
  return Object.keys(n).length > 0 ? n : void 0;
618
- }, at = (e) => {
619
- let t = Qe(e), n = Y(K(e.SeriesGroup).map((e) => ({ name: e })));
617
+ }, ot = (e) => {
618
+ let t = q(e.CommunityRating);
619
+ return t !== void 0 && t <= 5 ? { value: t } : void 0;
620
+ }, st = (e) => {
621
+ let t = $e(e), n = J(G(e.SeriesGroup).map((e) => ({ name: e })));
620
622
  if (!(t === void 0 && n === void 0)) return H({
621
623
  series: t === void 0 ? void 0 : [t],
622
624
  collection: n
623
625
  });
624
- }, ot = (e) => {
625
- let t = e.GTIN, n = G(t), r = tt(e), i = [...n === void 0 ? [] : [{
626
+ }, ct = (e) => {
627
+ let t = e.GTIN, n = W(t), r = nt(e), i = [...n === void 0 ? [] : [{
626
628
  value: n,
627
629
  scheme: "GTIN"
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);
630
+ }], ...it(r)], a = W(e.LanguageISO), o = [...G(e.Genre), ...G(e.Tags)], s = H({
631
+ date: Xe(e),
632
+ publisher: W(e.Publisher),
633
+ imprint: W(e.Imprint)
634
+ }), c = W(e.Title);
633
635
  return H({
634
636
  titles: c === void 0 ? void 0 : [{ value: c }],
635
- description: G(e.Summary),
637
+ description: W(e.Summary),
636
638
  publication: s.date !== void 0 || s.publisher !== void 0 || s.imprint !== void 0 ? { edition: s } : void 0,
637
639
  languages: a === void 0 ? void 0 : [a],
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)
640
+ subjects: J(o),
641
+ contributors: J(Qe(e)),
642
+ readingDirection: qe(e),
643
+ numberOfPages: K(e.PageCount),
644
+ aggregateRating: ot(e),
645
+ identifiers: J(i),
646
+ belongsTo: st(e),
647
+ comicInfo: at(e, r)
645
648
  });
646
- }, st = (e) => H({
649
+ }, lt = (e) => H({
647
650
  renditionLayout: e.renditionLayout,
648
651
  kobo: e.renditionLayout === void 0 ? void 0 : { fixedLayout: e.renditionLayout === "pre-paginated" }
649
- }), ct = /* @__PURE__ */ new Set([
652
+ }), ut = /[0-9Xx]+/g, dt = /^(?:97[89])?\d{9}[\dXx]$/, ft = (e) => {
653
+ if (e == null) return;
654
+ let t = String(e).trim().replace(/^urn:isbn:/i, "").replace(/^isbn[:\s-]*/i, ""), n = t.replace(/[^0-9Xx]/g, "");
655
+ if (n.length === 10 || n.length === 13) return n.toUpperCase();
656
+ for (let e of t.match(ut) ?? []) if (dt.test(e)) return e.toUpperCase();
657
+ }, pt = (e) => {
658
+ let t = ft(e);
659
+ if (t !== void 0) return t.length === 10 || /^97[89]/.test(t) ? t : void 0;
660
+ }, mt = /* @__PURE__ */ new Set([
650
661
  8,
651
662
  12,
652
663
  13,
653
664
  14
654
- ]), lt = (e) => {
665
+ ]), Y = (e) => {
655
666
  if (e == null) return;
656
667
  let t = String(e).replace(/\D/g, "");
657
- if (!(t.length === 0 || !ct.has(t.length))) return t;
658
- }, ut = /(?:97[89])?\d{9}[\dXx]/, dt = (e) => {
659
- if (e == null) return;
660
- let t = String(e).trim().replace(/^urn:isbn:/i, "").replace(/^isbn[:\s-]*/i, ""), n = t.replace(/[^0-9Xx]/g, "");
661
- if (n.length === 10 || n.length === 13) return n.toUpperCase();
662
- let r = t.match(ut);
663
- if (r) return r[0].toUpperCase();
664
- }, ft = (e) => {
668
+ if (!(t.length === 0 || !mt.has(t.length))) return t;
669
+ }, ht = (e) => {
665
670
  if (e === void 0) return;
666
671
  let t = e.trim().match(/^(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?/);
667
672
  if (t === null) return;
@@ -671,15 +676,14 @@ var He = async ({ archive: e, archiveOpf: t }) => {
671
676
  ...r === void 0 ? {} : { month: Number.parseInt(r, 10) },
672
677
  ...i === void 0 ? {} : { day: Number.parseInt(i, 10) }
673
678
  };
674
- }, pt = (e) => {
679
+ }, gt = (e) => {
675
680
  let t = e.trim();
676
681
  if (/^https?:\/\//i.test(t)) try {
677
682
  let e = new URL(t);
678
683
  if ((e.protocol === "http:" || e.protocol === "https:") && e.hostname.length > 0) return "URL";
679
684
  } catch {}
680
- let n = dt(t);
681
- return n !== void 0 && (n.length === 10 || /^97[89]/.test(n)) ? "ISBN" : lt(t) === void 0 ? "Unknown" : "GTIN";
682
- }, mt = (e) => {
685
+ return pt(t) === void 0 ? Y(t) === void 0 ? "Unknown" : "GTIN" : "ISBN";
686
+ }, _t = (e) => {
683
687
  switch (e.trim().toLowerCase()) {
684
688
  case "isbn": return "ISBN";
685
689
  case "gtin": return "GTIN";
@@ -691,7 +695,7 @@ var He = async ({ archive: e, archiveOpf: t }) => {
691
695
  case "unknown": return "Unknown";
692
696
  default: return e.trim();
693
697
  }
694
- }, ht = {
698
+ }, vt = {
695
699
  art: "artist",
696
700
  aut: "author",
697
701
  clr: "colorist",
@@ -700,14 +704,14 @@ var He = async ({ archive: e, archiveOpf: t }) => {
700
704
  ill: "illustrator",
701
705
  nrt: "narrator",
702
706
  trl: "translator"
703
- }, gt = (e) => e.map((e) => {
704
- let t = e.roles.map((e) => ht[e.trim().toLowerCase()] ?? e);
707
+ }, yt = (e) => e.map((e) => {
708
+ let t = e.roles.map((e) => vt[e.trim().toLowerCase()] ?? e);
705
709
  return H({
706
710
  name: e.name,
707
711
  roles: t.length > 0 ? t : [e.source === "creator" ? "author" : "contributor"],
708
712
  sortAs: e.fileAs
709
713
  });
710
- }), X = (e, t) => e.refines !== void 0 && e.refines.replace(/^#/, "") === t, _t = {
714
+ }), X = (e, t) => e.refines !== void 0 && e.refines.replace(/^#/, "") === t, bt = {
711
715
  "02": "ISBN",
712
716
  "03": "GTIN",
713
717
  "04": "UPC",
@@ -723,18 +727,18 @@ var He = async ({ archive: e, archiveOpf: t }) => {
723
727
  26: "DOI",
724
728
  34: "GTIN",
725
729
  35: "ARK"
726
- }, vt = (e) => {
730
+ }, xt = (e) => {
727
731
  let t = e?.value?.trim();
728
- if (!(t === void 0 || t.length === 0)) return e?.scheme?.trim().toLowerCase() === "onix:codelist5" ? _t[t] ?? t : t;
729
- }, yt = (e, t) => {
732
+ if (!(t === void 0 || t.length === 0)) return e?.scheme?.trim().toLowerCase() === "onix:codelist5" ? bt[t] ?? t : t;
733
+ }, St = (e, t) => {
730
734
  let n = e.id;
731
- if (n !== void 0) return vt(t.find((e) => e.property === "identifier-type" && X(e, n) && e.value !== void 0));
732
- }, bt = (e) => {
735
+ if (n !== void 0) return xt(t.find((e) => e.property === "identifier-type" && X(e, n) && e.value !== void 0));
736
+ }, Ct = (e) => {
733
737
  let t = e?.trim();
734
738
  if (t === void 0 || !/^\d+(\.\d+)?$/.test(t)) return;
735
739
  let n = Number.parseFloat(t);
736
740
  return Number.isFinite(n) ? n : void 0;
737
- }, xt = (e) => {
741
+ }, wt = (e) => {
738
742
  let t = e?.trim();
739
743
  if (t === void 0 || !/^\d+$/.test(t)) return;
740
744
  let n = Number.parseInt(t, 10);
@@ -742,30 +746,30 @@ var He = async ({ archive: e, archiveOpf: t }) => {
742
746
  }, Z = (e) => {
743
747
  let t = e?.trim();
744
748
  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({
749
+ }, Q = (e, t, n) => t === void 0 ? void 0 : e.find((e) => X(e, t) && e.property === n && e.value !== void 0)?.value, Tt = (e, t) => e.map((e) => H({
746
750
  value: e.value,
747
751
  type: Z(Q(t, e.id, "title-type"))?.toLowerCase(),
748
- displaySeq: xt(Q(t, e.id, "display-seq")),
752
+ displaySeq: wt(Q(t, e.id, "display-seq")),
749
753
  sortAs: Z(Q(t, e.id, "file-as"))
750
- })), Ct = (e, t) => {
754
+ })), Et = (e, t) => {
751
755
  if (t === void 0) return;
752
756
  let n = e.flatMap((n) => {
753
757
  if (!X(n, t) || n.property !== "dcterms:identifier") return [];
754
758
  let r = Z(n.value);
755
759
  return r === void 0 ? [] : [{
756
760
  value: r,
757
- scheme: mt(vt(e.find((e) => n.id !== void 0 && X(e, n.id) && e.property === "identifier-type")) ?? pt(r))
761
+ scheme: _t(xt(e.find((e) => n.id !== void 0 && X(e, n.id) && e.property === "identifier-type")) ?? gt(r))
758
762
  }];
759
763
  });
760
764
  return n.length > 0 ? n : void 0;
761
- }, wt = (e) => {
765
+ }, Dt = (e) => {
762
766
  let t = [], n = [];
763
767
  for (let r of e) {
764
768
  if (r.property !== "belongs-to-collection" || r.value === void 0) continue;
765
769
  let i = r.id, a = (t) => Q(e, i, t), o = a("collection-type")?.trim().toLowerCase(), s = H({
766
770
  name: r.value,
767
- identifiers: Ct(e, i),
768
- position: bt(a("group-position"))
771
+ identifiers: Et(e, i),
772
+ position: Ct(a("group-position"))
769
773
  });
770
774
  o === "series" ? t.push(s) : n.push(s);
771
775
  }
@@ -773,25 +777,25 @@ var He = async ({ archive: e, archiveOpf: t }) => {
773
777
  let n = e.find((e) => e.name?.toLowerCase() === "calibre:series" && e.content !== void 0)?.content;
774
778
  n !== void 0 && t.push(H({
775
779
  name: n,
776
- position: bt(e.find((e) => e.name?.toLowerCase() === "calibre:series_index")?.content)
780
+ position: Ct(e.find((e) => e.name?.toLowerCase() === "calibre:series_index")?.content)
777
781
  }));
778
782
  }
779
783
  return {
780
784
  series: t,
781
785
  collection: n
782
786
  };
783
- }, Tt = (e) => {
787
+ }, Ot = (e) => {
784
788
  let t = e?.trim();
785
789
  if (t === "scrolled-continuous" || t === "scrolled-doc" || t === "paginated" || t === "auto") return t;
786
- }, Et = (e) => {
790
+ }, kt = (e) => {
787
791
  let t = e?.trim();
788
792
  if (t === "none" || t === "landscape" || t === "portrait" || t === "both" || t === "auto") return t;
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({
793
+ }, At = (e) => {
794
+ 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 = yt(n), O = Tt(t, m), { series: k, collection: A } = Dt(m), j = k.length > 0 || A.length > 0 ? H({
791
795
  series: k.length > 0 ? k : void 0,
792
796
  collection: A.length > 0 ? A : void 0
793
797
  }) : void 0, M = H({
794
- date: ft(c),
798
+ date: ht(c),
795
799
  publisher: r
796
800
  });
797
801
  return H({
@@ -804,18 +808,18 @@ var He = async ({ archive: e, archiveOpf: t }) => {
804
808
  contributors: D.length > 0 ? D : void 0,
805
809
  readingDirection: w,
806
810
  renditionLayout: E,
807
- renditionFlow: Tt(u),
808
- renditionSpread: Et(d),
811
+ renditionFlow: Ot(u),
812
+ renditionSpread: kt(d),
809
813
  identifiers: p.length > 0 ? p.map((e) => H({
810
814
  value: e.value,
811
- scheme: mt(e.scheme ?? yt(e, m) ?? pt(e.value)),
815
+ scheme: _t(e.scheme ?? St(e, m) ?? gt(e.value)),
812
816
  unique: e.unique
813
817
  })) : void 0,
814
818
  belongsTo: j,
815
819
  properties: m.length > 0 ? [...m] : void 0
816
820
  });
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({
821
+ }, jt = (e) => e.kind === "comicInfo" ? ct(e) : e.kind === "kobo" ? lt(e) : e.kind === "apple" ? Ke(e) : At(e), Mt = (e) => {
822
+ let t = e.opf === void 0 ? void 0 : At(e.opf), n = e.comicInfo === void 0 ? void 0 : ct(e.comicInfo), r = e.apple === void 0 ? void 0 : Ke(e.apple), i = e.kobo === void 0 ? void 0 : lt(e.kobo), a = [...t?.identifiers ?? [], ...n?.identifiers ?? []], o = H({
819
823
  date: t?.publication?.edition?.date ?? n?.publication?.edition?.date,
820
824
  publisher: t?.publication?.edition?.publisher ?? n?.publication?.edition?.publisher,
821
825
  imprint: t?.publication?.edition?.imprint ?? n?.publication?.edition?.imprint
@@ -833,6 +837,7 @@ var He = async ({ archive: e, archiveOpf: t }) => {
833
837
  renditionFlow: t?.renditionFlow,
834
838
  renditionSpread: t?.renditionSpread,
835
839
  numberOfPages: n?.numberOfPages,
840
+ aggregateRating: n?.aggregateRating,
836
841
  identifiers: a.length > 0 ? a : void 0,
837
842
  belongsTo: t?.belongsTo ?? n?.belongsTo,
838
843
  properties: t?.properties,
@@ -840,7 +845,7 @@ var He = async ({ archive: e, archiveOpf: t }) => {
840
845
  apple: r?.apple,
841
846
  kobo: i?.kobo
842
847
  });
843
- }, At = (e) => {
848
+ }, Nt = (e) => {
844
849
  let t = [...e.records].sort((e, t) => p(e.uri, t.uri)), n = (e, t, r, i, a) => {
845
850
  let o = e.find((e) => e.title === t), [s, ...c] = r;
846
851
  return o ? s ? [...e.filter((e) => e !== o), {
@@ -869,71 +874,71 @@ var He = async ({ archive: e, archiveOpf: t }) => {
869
874
  let a = encodeURI(t.uri).replace(/#/g, "%23").replace(/\?/g, "%3F").replace(/\/$/, ""), o = t.uri.replace(/\/$/, "");
870
875
  return n(e, r, i, a, o);
871
876
  }, []);
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 }) => {
877
+ }, Pt = (e) => e ? e.children.map((e) => e instanceof _ ? e.text : e instanceof g ? Pt(e) : "").join("").trim() : "", Ft = (e) => k(e.properties).includes("nav"), It = (e, { basePath: t }) => {
873
878
  let n = {
874
879
  contents: [],
875
880
  path: "",
876
881
  containerHref: "",
877
882
  title: ""
878
883
  }, r = e.childNamed("span") || e.childNamed("a");
879
- n.title = (r?.attr.title || r?.val.trim() || jt(r)) ?? "";
884
+ n.title = (r?.attr.title || r?.val.trim() || Pt(r)) ?? "";
880
885
  let i = r?.name;
881
886
  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);
882
887
  let a = e.childNamed("ol");
883
888
  if (a) {
884
889
  let e = a.childrenNamed("li");
885
- e && e.length > 0 && (n.contents = e.map((e) => Nt(e, { basePath: t })));
890
+ e && e.length > 0 && (n.contents = e.map((e) => It(e, { basePath: t })));
886
891
  }
887
892
  return n;
888
- }, Pt = (e, { basePath: t }) => {
893
+ }, Lt = (e, { basePath: t }) => {
889
894
  let n = [], r;
890
895
  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) => {
891
- n.push(Nt(e, { basePath: t }));
896
+ n.push(It(e, { basePath: t }));
892
897
  }), n;
893
- }, Ft = async (e, t) => {
894
- let n = e.manifestItems.find(Mt);
898
+ }, Rt = async (e, t) => {
899
+ let n = e.manifestItems.find(Ft);
895
900
  if (n?.href) {
896
901
  let e = t.records.find((e) => e.uri.endsWith(n.href));
897
- if (e && !e.dir) return Pt(new h(await D(e)), { basePath: c(e.uri) });
902
+ if (e && !e.dir) return Lt(new h(await D(e)), { basePath: c(e.uri) });
898
903
  }
899
- }, It = (e, { basePath: t, prefix: n }) => {
904
+ }, zt = (e, { basePath: t, prefix: n }) => {
900
905
  let r = m(t, e?.childNamed(`${n}content`)?.attr.src || ""), i = {
901
906
  title: e?.descendantWithPath(`${n}navLabel.${n}text`)?.val || "",
902
907
  path: r,
903
908
  containerHref: r,
904
909
  contents: []
905
910
  }, a = e.childrenNamed(`${n}navPoint`);
906
- return a && a.length > 0 && (i.contents = a.map((e) => It(e, {
911
+ return a && a.length > 0 && (i.contents = a.map((e) => zt(e, {
907
912
  basePath: t,
908
913
  prefix: n
909
914
  }))), i;
910
- }, Lt = (e, { basePath: t }) => {
915
+ }, Bt = (e, { basePath: t }) => {
911
916
  let n = [], r = e.name, i = "";
912
917
  return r.indexOf(":") !== -1 && (i = `${r.split(":")[0]}:`), e.childNamed(`${i}navMap`)?.childrenNamed(`${i}navPoint`).forEach((e) => {
913
- n.push(It(e, {
918
+ n.push(zt(e, {
914
919
  basePath: t,
915
920
  prefix: i
916
921
  }));
917
922
  }), n;
918
- }, Rt = async ({ opf: e, opfBasePath: t, archive: n }) => {
923
+ }, Vt = async ({ opf: e, opfBasePath: t, archive: n }) => {
919
924
  let r = e.spineTocIdref;
920
925
  if (r) {
921
926
  let i = e.manifestItems.find((e) => e.id === r);
922
927
  if (i) {
923
928
  let e = `${t}${t === "" ? "" : "/"}${i.href}`, r = n.records.find((t) => t.uri.endsWith(e));
924
- if (r && !r.dir) return Lt(new h(await D(r)), { basePath: c(r.uri) });
929
+ if (r && !r.dir) return Bt(new h(await D(r)), { basePath: c(r.uri) });
925
930
  }
926
931
  }
927
- }, zt = async (e, { opf: t } = {}) => {
932
+ }, Ht = async (e, { opf: t } = {}) => {
928
933
  let n = t ?? await z(e);
929
- if (n) return await Ft(n.opf, e) || await Rt({
934
+ if (n) return await Rt(n.opf, e) || await Vt({
930
935
  opf: n.opf,
931
936
  opfBasePath: n.basePath,
932
937
  archive: e
933
938
  }) || [];
934
- let r = At(e);
939
+ let r = Nt(e);
935
940
  return r.length === 0 ? void 0 : r;
936
- }, Bt = [
941
+ }, Ut = [
937
942
  "metadata",
938
943
  "readingOrder",
939
944
  "toc"
@@ -949,39 +954,39 @@ var He = async ({ archive: e, archiveOpf: t }) => {
949
954
  failed: !0
950
955
  };
951
956
  }
952
- }, Vt = (e) => {
957
+ }, Wt = (e) => {
953
958
  let t = (e) => e?.startsWith("audio/") === !0 || e?.startsWith("video/") === !0, n = e.filter((e) => e.renditionLayout === "pre-paginated" && !t(e.mediaType)).length;
954
959
  return n > 0 ? n : void 0;
955
- }, Ht = ({ archive: e, opf: t, comicInfo: n, apple: r, kobo: i }) => {
960
+ }, Gt = ({ archive: e, opf: t, comicInfo: n, apple: r, kobo: i }) => {
956
961
  let a = [];
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({
962
+ return t !== void 0 && t.value === void 0 && (t.failed || Ge(e)) && a.push("opf"), n?.failed && a.push("comicInfo"), r?.failed && a.push("apple"), i?.failed && a.push("kobo"), a;
963
+ }, Kt = 3, qt = async (e, t = {}) => {
964
+ let n = new Set(t.include ?? Ut), 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 $(() => Ve(e), "comicInfo") : void 0, f = d?.value, p = u ? await $(() => Ie(e), "apple") : void 0, m = p?.value, h = u ? await $(() => He(e), "kobo") : void 0, g = h?.value, _ = r || s ? Mt({
960
965
  opf: l?.opf,
961
966
  comicInfo: f,
962
967
  apple: m,
963
968
  kobo: g
964
969
  }) : void 0, v = a || s ? await U(e, { opf: l }) : void 0;
965
- if (s && _ !== void 0 && v !== void 0 && _.renditionLayout === "reflowable" && v.every((e) => e.renditionLayout === "reflowable") && await Ne(e, v) && (_ = {
970
+ if (s && _ !== void 0 && v !== void 0 && _.renditionLayout === "reflowable" && v.every((e) => e.renditionLayout === "reflowable") && await Pe(e, v) && (_ = {
966
971
  ..._,
967
972
  renditionLayout: "pre-paginated"
968
973
  }, v = v.map((e) => ({
969
974
  ...e,
970
975
  renditionLayout: "pre-paginated"
971
976
  }))), r && _ !== void 0) {
972
- let t = v ?? await U(e, { opf: l }), n = await W(e, {
977
+ let t = v ?? await U(e, { opf: l }), n = await Me(e, {
973
978
  opf: l,
974
979
  readingOrder: t
975
- }), r = _.numberOfPages ?? Vt(t);
980
+ }), r = _.numberOfPages ?? Wt(t);
976
981
  _ = H({
977
982
  ..._,
978
983
  cover: n,
979
984
  numberOfPages: r
980
985
  });
981
986
  }
982
- let y = o ? (await $(() => zt(e, { opf: l }), "toc")).value : void 0, b = {
983
- version: Ut,
984
- unreadableSources: Ht({
987
+ let y = o ? (await $(() => Ht(e, { opf: l }), "toc")).value : void 0, b = {
988
+ version: Kt,
989
+ unreadableSources: Gt({
985
990
  archive: e,
986
991
  opf: c,
987
992
  comicInfo: d,
@@ -995,8 +1000,14 @@ var He = async ({ archive: e, archiveOpf: t }) => {
995
1000
  apple: m,
996
1001
  kobo: g
997
1002
  })), b;
998
- }, Gt = (e) => e?.titles?.[0]?.value;
1003
+ }, Jt = (e) => e === "ISBN" || e === "GTIN", Yt = (e, t) => {
1004
+ for (let n of e ?? []) {
1005
+ if (!Jt(n.scheme)) continue;
1006
+ let e = t(n.value);
1007
+ if (e !== void 0) return e;
1008
+ }
1009
+ }, Xt = (e) => Yt(e, pt), Zt = (e) => Yt(e, Y), Qt = (e) => e?.titles?.[0]?.value;
999
1010
  //#endregion
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 };
1011
+ export { B as APPLE_IBOOKS_DISPLAY_OPTIONS_FILENAME, V as COMIC_INFO_FILENAME, he as COMIC_INFO_KNOWN_FIELDS, ze 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, Re as getArchiveHasComicInfo, E as getArchiveImageRecords, O as getArchiveOpfInfo, Ue as getSpineItemFilesFromArchive, Zt as gtinIdentifierValue, Ge as isArchiveEpub, Be as isComicInfoManga, S as isDirectoryRecord, x as isFileRecord, T as isImageRecord, Jt as isIsbnBearingScheme, Xt as isbnIdentifierValue, Qt as mainTitle, Y as normalizeGtin, ft as normalizeIsbn, me as parseAppleDisplayOptionsXml, ye as parseComicInfo, Se as parseKoboXml, fe as parseOpf, ht as parseW3cDtfDate, Ie as readArchiveApple, Ve as readArchiveComicInfo, He as readArchiveKobo, z as readArchiveOpf, D as readRecordAsText, Pe as readingOrderDocumentsAllHaveViewport, qt as resolveArchive, Me as resolveArchiveCover, jt as resolveArchiveMetadata, U as resolveArchiveReadingOrder, Ht as resolveArchiveToc, Mt as resolveMetadata, k as tokenizeXmlSpaceSeparatedList };
1001
1012
 
1002
1013
  //# sourceMappingURL=index.js.map