@prose-reader/archive-reader 1.355.0 → 1.357.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.
@@ -662,11 +662,11 @@ var Ue = async ({ archive: e, archiveOpf: t }) => {
662
662
  12,
663
663
  13,
664
664
  14
665
- ]), Y = (e) => {
665
+ ]), ht = (e) => {
666
666
  if (e == null) return;
667
667
  let t = String(e).replace(/\D/g, "");
668
668
  if (!(t.length === 0 || !mt.has(t.length))) return t;
669
- }, ht = (e) => {
669
+ }, gt = (e) => {
670
670
  if (e === void 0) return;
671
671
  let t = e.trim().match(/^(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?/);
672
672
  if (t === null) return;
@@ -676,14 +676,14 @@ var Ue = async ({ archive: e, archiveOpf: t }) => {
676
676
  ...r === void 0 ? {} : { month: Number.parseInt(r, 10) },
677
677
  ...i === void 0 ? {} : { day: Number.parseInt(i, 10) }
678
678
  };
679
- }, gt = (e) => {
679
+ }, _t = (e) => {
680
680
  let t = e.trim();
681
681
  if (/^https?:\/\//i.test(t)) try {
682
682
  let e = new URL(t);
683
683
  if ((e.protocol === "http:" || e.protocol === "https:") && e.hostname.length > 0) return "URL";
684
684
  } catch {}
685
- return pt(t) === void 0 ? Y(t) === void 0 ? "Unknown" : "GTIN" : "ISBN";
686
- }, _t = (e) => {
685
+ return pt(t) === void 0 ? ht(t) === void 0 ? "Unknown" : "GTIN" : "ISBN";
686
+ }, vt = (e) => {
687
687
  switch (e.trim().toLowerCase()) {
688
688
  case "isbn": return "ISBN";
689
689
  case "gtin": return "GTIN";
@@ -695,7 +695,7 @@ var Ue = async ({ archive: e, archiveOpf: t }) => {
695
695
  case "unknown": return "Unknown";
696
696
  default: return e.trim();
697
697
  }
698
- }, vt = {
698
+ }, yt = {
699
699
  art: "artist",
700
700
  aut: "author",
701
701
  clr: "colorist",
@@ -704,14 +704,14 @@ var Ue = async ({ archive: e, archiveOpf: t }) => {
704
704
  ill: "illustrator",
705
705
  nrt: "narrator",
706
706
  trl: "translator"
707
- }, yt = (e) => e.map((e) => {
708
- let t = e.roles.map((e) => vt[e.trim().toLowerCase()] ?? e);
707
+ }, bt = (e) => e.map((e) => {
708
+ let t = e.roles.map((e) => yt[e.trim().toLowerCase()] ?? e);
709
709
  return H({
710
710
  name: e.name,
711
711
  roles: t.length > 0 ? t : [e.source === "creator" ? "author" : "contributor"],
712
712
  sortAs: e.fileAs
713
713
  });
714
- }), X = (e, t) => e.refines !== void 0 && e.refines.replace(/^#/, "") === t, bt = {
714
+ }), Y = (e, t) => e.refines !== void 0 && e.refines.replace(/^#/, "") === t, xt = {
715
715
  "02": "ISBN",
716
716
  "03": "GTIN",
717
717
  "04": "UPC",
@@ -727,49 +727,49 @@ var Ue = async ({ archive: e, archiveOpf: t }) => {
727
727
  26: "DOI",
728
728
  34: "GTIN",
729
729
  35: "ARK"
730
- }, xt = (e) => {
730
+ }, St = (e) => {
731
731
  let t = e?.value?.trim();
732
- if (!(t === void 0 || t.length === 0)) return e?.scheme?.trim().toLowerCase() === "onix:codelist5" ? bt[t] ?? t : t;
733
- }, St = (e, t) => {
732
+ if (!(t === void 0 || t.length === 0)) return e?.scheme?.trim().toLowerCase() === "onix:codelist5" ? xt[t] ?? t : t;
733
+ }, Ct = (e, t) => {
734
734
  let n = e.id;
735
- if (n !== void 0) return xt(t.find((e) => e.property === "identifier-type" && X(e, n) && e.value !== void 0));
736
- }, Ct = (e) => {
735
+ if (n !== void 0) return St(t.find((e) => e.property === "identifier-type" && Y(e, n) && e.value !== void 0));
736
+ }, wt = (e) => {
737
737
  let t = e?.trim();
738
738
  if (t === void 0 || !/^\d+(\.\d+)?$/.test(t)) return;
739
739
  let n = Number.parseFloat(t);
740
740
  return Number.isFinite(n) ? n : void 0;
741
- }, wt = (e) => {
741
+ }, Tt = (e) => {
742
742
  let t = e?.trim();
743
743
  if (t === void 0 || !/^\d+$/.test(t)) return;
744
744
  let n = Number.parseInt(t, 10);
745
745
  return Number.isFinite(n) ? n : void 0;
746
- }, Z = (e) => {
746
+ }, Et = (e) => {
747
747
  let t = e?.trim();
748
748
  return t !== void 0 && t.length > 0 ? t : void 0;
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({
749
+ }, X = (e, t, n) => t === void 0 ? void 0 : e.find((e) => Y(e, t) && e.property === n && e.value !== void 0)?.value, Dt = (e, t) => e.map((e) => H({
750
750
  value: e.value,
751
- type: Z(Q(t, e.id, "title-type"))?.toLowerCase(),
752
- displaySeq: wt(Q(t, e.id, "display-seq")),
753
- sortAs: Z(Q(t, e.id, "file-as"))
754
- })), Et = (e, t) => {
751
+ type: Et(X(t, e.id, "title-type"))?.toLowerCase(),
752
+ displaySeq: Tt(X(t, e.id, "display-seq")),
753
+ sortAs: Et(X(t, e.id, "file-as"))
754
+ })), Ot = (e, t) => {
755
755
  if (t === void 0) return;
756
756
  let n = e.flatMap((n) => {
757
- if (!X(n, t) || n.property !== "dcterms:identifier") return [];
758
- let r = Z(n.value);
757
+ if (!Y(n, t) || n.property !== "dcterms:identifier") return [];
758
+ let r = Et(n.value);
759
759
  return r === void 0 ? [] : [{
760
760
  value: r,
761
- scheme: _t(xt(e.find((e) => n.id !== void 0 && X(e, n.id) && e.property === "identifier-type")) ?? gt(r))
761
+ scheme: vt(St(e.find((e) => n.id !== void 0 && Y(e, n.id) && e.property === "identifier-type")) ?? _t(r))
762
762
  }];
763
763
  });
764
764
  return n.length > 0 ? n : void 0;
765
- }, Dt = (e) => {
765
+ }, kt = (e) => {
766
766
  let t = [], n = [];
767
767
  for (let r of e) {
768
768
  if (r.property !== "belongs-to-collection" || r.value === void 0) continue;
769
- let i = r.id, a = (t) => Q(e, i, t), o = a("collection-type")?.trim().toLowerCase(), s = H({
769
+ let i = r.id, a = (t) => X(e, i, t), o = a("collection-type")?.trim().toLowerCase(), s = H({
770
770
  name: r.value,
771
- identifiers: Et(e, i),
772
- position: Ct(a("group-position"))
771
+ identifiers: Ot(e, i),
772
+ position: wt(a("group-position"))
773
773
  });
774
774
  o === "series" ? t.push(s) : n.push(s);
775
775
  }
@@ -777,25 +777,25 @@ var Ue = async ({ archive: e, archiveOpf: t }) => {
777
777
  let n = e.find((e) => e.name?.toLowerCase() === "calibre:series" && e.content !== void 0)?.content;
778
778
  n !== void 0 && t.push(H({
779
779
  name: n,
780
- position: Ct(e.find((e) => e.name?.toLowerCase() === "calibre:series_index")?.content)
780
+ position: wt(e.find((e) => e.name?.toLowerCase() === "calibre:series_index")?.content)
781
781
  }));
782
782
  }
783
783
  return {
784
784
  series: t,
785
785
  collection: n
786
786
  };
787
- }, Ot = (e) => {
787
+ }, At = (e) => {
788
788
  let t = e?.trim();
789
789
  if (t === "scrolled-continuous" || t === "scrolled-doc" || t === "paginated" || t === "auto") return t;
790
- }, kt = (e) => {
790
+ }, jt = (e) => {
791
791
  let t = e?.trim();
792
792
  if (t === "none" || t === "landscape" || t === "portrait" || t === "both" || t === "auto") return t;
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({
793
+ }, Mt = (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 = bt(n), O = Dt(t, m), { series: k, collection: A } = kt(m), j = k.length > 0 || A.length > 0 ? H({
795
795
  series: k.length > 0 ? k : void 0,
796
796
  collection: A.length > 0 ? A : void 0
797
797
  }) : void 0, M = H({
798
- date: ht(c),
798
+ date: gt(c),
799
799
  publisher: r
800
800
  });
801
801
  return H({
@@ -808,18 +808,18 @@ var Ue = async ({ archive: e, archiveOpf: t }) => {
808
808
  contributors: D.length > 0 ? D : void 0,
809
809
  readingDirection: w,
810
810
  renditionLayout: E,
811
- renditionFlow: Ot(u),
812
- renditionSpread: kt(d),
811
+ renditionFlow: At(u),
812
+ renditionSpread: jt(d),
813
813
  identifiers: p.length > 0 ? p.map((e) => H({
814
814
  value: e.value,
815
- scheme: _t(e.scheme ?? St(e, m) ?? gt(e.value)),
815
+ scheme: vt(e.scheme ?? Ct(e, m) ?? _t(e.value)),
816
816
  unique: e.unique
817
817
  })) : void 0,
818
818
  belongsTo: j,
819
819
  properties: m.length > 0 ? [...m] : void 0
820
820
  });
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({
821
+ }, Nt = (e) => e.kind === "comicInfo" ? ct(e) : e.kind === "kobo" ? lt(e) : e.kind === "apple" ? Ke(e) : Mt(e), Pt = (e) => {
822
+ let t = e.opf === void 0 ? void 0 : Mt(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({
823
823
  date: t?.publication?.edition?.date ?? n?.publication?.edition?.date,
824
824
  publisher: t?.publication?.edition?.publisher ?? n?.publication?.edition?.publisher,
825
825
  imprint: t?.publication?.edition?.imprint ?? n?.publication?.edition?.imprint
@@ -845,7 +845,7 @@ var Ue = async ({ archive: e, archiveOpf: t }) => {
845
845
  apple: r?.apple,
846
846
  kobo: i?.kobo
847
847
  });
848
- }, Nt = (e) => {
848
+ }, Ft = (e) => {
849
849
  let t = [...e.records].sort((e, t) => p(e.uri, t.uri)), n = (e, t, r, i, a) => {
850
850
  let o = e.find((e) => e.title === t), [s, ...c] = r;
851
851
  return o ? s ? [...e.filter((e) => e !== o), {
@@ -874,75 +874,75 @@ var Ue = async ({ archive: e, archiveOpf: t }) => {
874
874
  let a = encodeURI(t.uri).replace(/#/g, "%23").replace(/\?/g, "%3F").replace(/\/$/, ""), o = t.uri.replace(/\/$/, "");
875
875
  return n(e, r, i, a, o);
876
876
  }, []);
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 }) => {
877
+ }, It = (e) => e ? e.children.map((e) => e instanceof _ ? e.text : e instanceof g ? It(e) : "").join("").trim() : "", Lt = (e) => k(e.properties).includes("nav"), Rt = (e, { basePath: t }) => {
878
878
  let n = {
879
879
  contents: [],
880
880
  path: "",
881
881
  containerHref: "",
882
882
  title: ""
883
883
  }, r = e.childNamed("span") || e.childNamed("a");
884
- n.title = (r?.attr.title || r?.val.trim() || Pt(r)) ?? "";
884
+ n.title = (r?.attr.title || r?.val.trim() || It(r)) ?? "";
885
885
  let i = r?.name;
886
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);
887
887
  let a = e.childNamed("ol");
888
888
  if (a) {
889
889
  let e = a.childrenNamed("li");
890
- e && e.length > 0 && (n.contents = e.map((e) => It(e, { basePath: t })));
890
+ e && e.length > 0 && (n.contents = e.map((e) => Rt(e, { basePath: t })));
891
891
  }
892
892
  return n;
893
- }, Lt = (e, { basePath: t }) => {
893
+ }, zt = (e, { basePath: t }) => {
894
894
  let n = [], r;
895
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) => {
896
- n.push(It(e, { basePath: t }));
896
+ n.push(Rt(e, { basePath: t }));
897
897
  }), n;
898
- }, Rt = async (e, t) => {
899
- let n = e.manifestItems.find(Ft);
898
+ }, Bt = async (e, t) => {
899
+ let n = e.manifestItems.find(Lt);
900
900
  if (n?.href) {
901
901
  let e = t.records.find((e) => e.uri.endsWith(n.href));
902
- if (e && !e.dir) return Lt(new h(await D(e)), { basePath: c(e.uri) });
902
+ if (e && !e.dir) return zt(new h(await D(e)), { basePath: c(e.uri) });
903
903
  }
904
- }, zt = (e, { basePath: t, prefix: n }) => {
904
+ }, Vt = (e, { basePath: t, prefix: n }) => {
905
905
  let r = m(t, e?.childNamed(`${n}content`)?.attr.src || ""), i = {
906
906
  title: e?.descendantWithPath(`${n}navLabel.${n}text`)?.val || "",
907
907
  path: r,
908
908
  containerHref: r,
909
909
  contents: []
910
910
  }, a = e.childrenNamed(`${n}navPoint`);
911
- return a && a.length > 0 && (i.contents = a.map((e) => zt(e, {
911
+ return a && a.length > 0 && (i.contents = a.map((e) => Vt(e, {
912
912
  basePath: t,
913
913
  prefix: n
914
914
  }))), i;
915
- }, Bt = (e, { basePath: t }) => {
915
+ }, Ht = (e, { basePath: t }) => {
916
916
  let n = [], r = e.name, i = "";
917
917
  return r.indexOf(":") !== -1 && (i = `${r.split(":")[0]}:`), e.childNamed(`${i}navMap`)?.childrenNamed(`${i}navPoint`).forEach((e) => {
918
- n.push(zt(e, {
918
+ n.push(Vt(e, {
919
919
  basePath: t,
920
920
  prefix: i
921
921
  }));
922
922
  }), n;
923
- }, Vt = async ({ opf: e, opfBasePath: t, archive: n }) => {
923
+ }, Ut = async ({ opf: e, opfBasePath: t, archive: n }) => {
924
924
  let r = e.spineTocIdref;
925
925
  if (r) {
926
926
  let i = e.manifestItems.find((e) => e.id === r);
927
927
  if (i) {
928
928
  let e = `${t}${t === "" ? "" : "/"}${i.href}`, r = n.records.find((t) => t.uri.endsWith(e));
929
- if (r && !r.dir) return Bt(new h(await D(r)), { basePath: c(r.uri) });
929
+ if (r && !r.dir) return Ht(new h(await D(r)), { basePath: c(r.uri) });
930
930
  }
931
931
  }
932
- }, Ht = async (e, { opf: t } = {}) => {
932
+ }, Wt = async (e, { opf: t } = {}) => {
933
933
  let n = t ?? await z(e);
934
- if (n) return await Rt(n.opf, e) || await Vt({
934
+ if (n) return await Bt(n.opf, e) || await Ut({
935
935
  opf: n.opf,
936
936
  opfBasePath: n.basePath,
937
937
  archive: e
938
938
  }) || [];
939
- let r = Nt(e);
939
+ let r = Ft(e);
940
940
  return r.length === 0 ? void 0 : r;
941
- }, Ut = [
941
+ }, Gt = [
942
942
  "metadata",
943
943
  "readingOrder",
944
944
  "toc"
945
- ], $ = async (e, n) => {
945
+ ], Z = async (e, n) => {
946
946
  try {
947
947
  return {
948
948
  value: await e(),
@@ -954,14 +954,14 @@ var Ue = async ({ archive: e, archiveOpf: t }) => {
954
954
  failed: !0
955
955
  };
956
956
  }
957
- }, Wt = (e) => {
957
+ }, Kt = (e) => {
958
958
  let t = (e) => e?.startsWith("audio/") === !0 || e?.startsWith("video/") === !0, n = e.filter((e) => e.renditionLayout === "pre-paginated" && !t(e.mediaType)).length;
959
959
  return n > 0 ? n : void 0;
960
- }, Gt = ({ archive: e, opf: t, comicInfo: n, apple: r, kobo: i }) => {
960
+ }, qt = ({ archive: e, opf: t, comicInfo: n, apple: r, kobo: i }) => {
961
961
  let a = [];
962
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({
963
+ }, Jt = 3, Yt = async (e, t = {}) => {
964
+ let n = new Set(t.include ?? Gt), 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(() => z(e), "opf") : void 0, l = c?.value, u = r || i || s, d = u ? await Z(() => Ve(e), "comicInfo") : void 0, f = d?.value, p = u ? await Z(() => Ie(e), "apple") : void 0, m = p?.value, h = u ? await Z(() => He(e), "kobo") : void 0, g = h?.value, _ = r || s ? Pt({
965
965
  opf: l?.opf,
966
966
  comicInfo: f,
967
967
  apple: m,
@@ -977,16 +977,16 @@ var Ue = async ({ archive: e, archiveOpf: t }) => {
977
977
  let t = v ?? await U(e, { opf: l }), n = await Me(e, {
978
978
  opf: l,
979
979
  readingOrder: t
980
- }), r = _.numberOfPages ?? Wt(t);
980
+ }), r = _.numberOfPages ?? Kt(t);
981
981
  _ = H({
982
982
  ..._,
983
983
  cover: n,
984
984
  numberOfPages: r
985
985
  });
986
986
  }
987
- let y = o ? (await $(() => Ht(e, { opf: l }), "toc")).value : void 0, b = {
988
- version: Kt,
989
- unreadableSources: Gt({
987
+ let y = o ? (await Z(() => Wt(e, { opf: l }), "toc")).value : void 0, b = {
988
+ version: Jt,
989
+ unreadableSources: qt({
990
990
  archive: e,
991
991
  opf: c,
992
992
  comicInfo: d,
@@ -1000,14 +1000,137 @@ var Ue = async ({ archive: e, archiveOpf: t }) => {
1000
1000
  apple: m,
1001
1001
  kobo: g
1002
1002
  })), b;
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);
1003
+ }, Xt = (e) => {
1004
+ let t = e.trim().toLowerCase();
1005
+ return t === "url" || t === "uri" || t === "unknown";
1006
+ }, Zt = (e) => {
1007
+ try {
1008
+ return decodeURIComponent(e);
1009
+ } catch {
1010
+ return;
1011
+ }
1012
+ }, Qt = (e) => {
1013
+ try {
1014
+ let t = new URL(e.trim());
1015
+ return t.protocol === "http:" || t.protocol === "https:" ? t : void 0;
1016
+ } catch {
1017
+ return;
1018
+ }
1019
+ }, Q = (e, t) => {
1020
+ let n = Qt(e);
1021
+ return n !== void 0 && t(n.hostname.toLowerCase()) ? n : void 0;
1022
+ }, $t = /^books\.google\.(?:com|[a-z]{2}|com\.[a-z]{2}|co\.[a-z]{2})$/i, en = /* @__PURE__ */ new Set(["books.googleapis.com", "www.googleapis.com"]), tn = /^\/books\/v1\/volumes\/([^/]+)\/?$/i, nn = (e) => {
1023
+ let t = e.trim();
1024
+ return /^[a-z0-9_-]+$/i.test(t) ? t : void 0;
1025
+ }, rn = (e) => {
1026
+ let t = Q(e, (e) => $t.test(e) || en.has(e));
1027
+ if (t !== void 0) {
1028
+ if (en.has(t.hostname.toLowerCase())) {
1029
+ let e = tn.exec(t.pathname)?.[1], n = e === void 0 ? void 0 : Zt(e);
1030
+ return n === void 0 ? void 0 : nn(n);
1031
+ }
1032
+ return nn(t.searchParams.get("id") ?? "");
1033
+ }
1034
+ }, an = /* @__PURE__ */ new Set(["gutenberg.org", "www.gutenberg.org"]), on = [
1035
+ /^\/ebooks\/(\d+)(?:[./]|$)/i,
1036
+ /^\/files\/(\d+)(?:\/|$)/i,
1037
+ /^\/cache\/epub\/(\d+)(?:\/|$)/i,
1038
+ /^\/(\d+)(?:\/|$)/
1039
+ ], sn = (e) => {
1040
+ let t = e.trim();
1041
+ if (!/^\d+$/.test(t)) return;
1042
+ let n = t.replace(/^0+(?=\d)/, "");
1043
+ return n === "0" ? void 0 : n;
1044
+ }, cn = (e) => {
1045
+ let t = Q(e, (e) => an.has(e));
1046
+ if (t !== void 0) for (let e of on) {
1047
+ let n = e.exec(t.pathname)?.[1];
1048
+ if (n !== void 0) return sn(n);
1049
+ }
1050
+ }, ln = /* @__PURE__ */ new Set(["openlibrary.org", "www.openlibrary.org"]), un = /^\/(works|books|authors)\/(OL\d+[A-Z])(?:\/|$)/i, dn = /^OL\d+([MWA])$/i, fn = {
1051
+ M: "books",
1052
+ W: "works",
1053
+ A: "authors"
1054
+ }, pn = (e) => {
1055
+ let t = e.trim(), n = un.exec(t);
1056
+ if (n?.[1] !== void 0 && n[2] !== void 0) return `/${n[1].toLowerCase()}/${n[2].toUpperCase()}`;
1057
+ let r = fn[dn.exec(t)?.[1]?.toUpperCase() ?? ""];
1058
+ return r === void 0 ? void 0 : `/${r}/${t.toUpperCase()}`;
1059
+ }, mn = (e) => {
1060
+ let t = Q(e, (e) => ln.has(e));
1061
+ return t === void 0 ? void 0 : pn(t.pathname);
1062
+ }, hn = /* @__PURE__ */ new Set([
1063
+ "doi.org",
1064
+ "dx.doi.org",
1065
+ "www.doi.org"
1066
+ ]), gn = /^10\.\d{4,9}\/\S+$/, _n = (e) => {
1067
+ let t = e.trim().replace(/^doi:/i, "");
1068
+ return gn.test(t) ? t : void 0;
1069
+ }, vn = [
1070
+ {
1071
+ scheme: "GoogleBooks",
1072
+ normalizeValue: nn,
1073
+ valueFromUrl: rn
1074
+ },
1075
+ {
1076
+ scheme: "ProjectGutenberg",
1077
+ normalizeValue: sn,
1078
+ valueFromUrl: cn
1079
+ },
1080
+ {
1081
+ scheme: "OpenLibrary",
1082
+ normalizeValue: pn,
1083
+ valueFromUrl: mn
1084
+ },
1085
+ {
1086
+ scheme: "DOI",
1087
+ normalizeValue: _n,
1088
+ valueFromUrl: (e) => {
1089
+ let t = Q(e, (e) => hn.has(e)), n = t === void 0 ? void 0 : Zt(t.pathname.replace(/^\//, ""));
1090
+ return n === void 0 ? void 0 : _n(n);
1091
+ }
1092
+ }
1093
+ ], yn = (e) => {
1094
+ for (let t of vn) {
1095
+ let n = t.valueFromUrl(e);
1096
+ if (n !== void 0) return {
1097
+ value: n,
1098
+ scheme: t.scheme
1099
+ };
1100
+ }
1101
+ }, bn = (e) => {
1102
+ let t = vn.find(function(t) {
1103
+ return t.scheme === e;
1104
+ });
1105
+ if (t === void 0) throw Error(`No catalog rule for scheme ${e}`);
1106
+ return t;
1107
+ }, xn = (e) => e === "ISBN" || e === "GTIN", Sn = (e) => ({
1108
+ carries: xn,
1109
+ normalizeValue: e
1110
+ }), $ = (e) => ({
1111
+ carries: (t) => t.trim().toLowerCase() === e.toLowerCase(),
1112
+ ...bn(e)
1113
+ }), Cn = {
1114
+ ISBN: Sn(pt),
1115
+ GTIN: Sn(ht),
1116
+ GoogleBooks: $("GoogleBooks"),
1117
+ OpenLibrary: $("OpenLibrary"),
1118
+ ProjectGutenberg: $("ProjectGutenberg"),
1119
+ DOI: $("DOI")
1120
+ }, wn = (e, t) => {
1121
+ let n = Cn[t];
1122
+ for (let t of e ?? []) {
1123
+ if (n.carries(t.scheme)) {
1124
+ let e = n.normalizeValue(t.value) ?? n.valueFromUrl?.(t.value);
1125
+ if (e !== void 0) return e;
1126
+ continue;
1127
+ }
1128
+ if (n.valueFromUrl === void 0 || !Xt(t.scheme)) continue;
1129
+ let e = n.valueFromUrl(t.value);
1007
1130
  if (e !== void 0) return e;
1008
1131
  }
1009
- }, Xt = (e) => Yt(e, pt), Zt = (e) => Yt(e, Y), Qt = (e) => e?.titles?.[0]?.value;
1132
+ }, Tn = (e) => e?.titles?.[0]?.value;
1010
1133
  //#endregion
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 };
1134
+ 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, yn as catalogIdentifierFromUrl, 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, wn as identifierValue, Ge as isArchiveEpub, Be as isComicInfoManga, S as isDirectoryRecord, x as isFileRecord, T as isImageRecord, xn as isIsbnBearingScheme, Tn as mainTitle, ht as normalizeGtin, ft as normalizeIsbn, me as parseAppleDisplayOptionsXml, ye as parseComicInfo, Se as parseKoboXml, fe as parseOpf, gt as parseW3cDtfDate, Ie as readArchiveApple, Ve as readArchiveComicInfo, He as readArchiveKobo, z as readArchiveOpf, D as readRecordAsText, Pe as readingOrderDocumentsAllHaveViewport, Yt as resolveArchive, Me as resolveArchiveCover, Nt as resolveArchiveMetadata, U as resolveArchiveReadingOrder, Wt as resolveArchiveToc, Pt as resolveMetadata, k as tokenizeXmlSpaceSeparatedList };
1012
1135
 
1013
1136
  //# sourceMappingURL=index.js.map