@readium/navigator
Version:
Next generation SDK for publications in Web Apps
1,208 lines • 385 kB
JavaScript
const O = class at {
constructor(t) {
if (typeof t == "string") {
if (!at.VALID_MODES.has(t.toLowerCase()))
return;
this.value = t.toLowerCase();
} else {
const e = t.filter(
(i) => at.VALID_MODES.has(i.toLowerCase())
);
if (e.length === 0)
return;
this.value = Array.from(new Set(e));
}
}
/**
* Parses a [PrimaryAccessMode] from its RWPM JSON representation.
*/
static deserialize(t) {
if (!t) return;
if (typeof t == "string")
return new at(t);
if (!Array.isArray(t)) return;
const e = t.filter((i) => i ? at.VALID_MODES.has(i.toLowerCase()) : !1);
if (e.length !== 0)
return new at(e);
}
/**
* Serializes a [PrimaryAccessMode] to its RWPM JSON representation.
*/
serialize() {
return this.value;
}
};
O.VALID_MODES = /* @__PURE__ */ new Set(["auditory", "tactile", "textual", "visual"]), O.AUDITORY = new O("auditory"), O.TACTILE = new O("tactile"), O.TEXTUAL = new O("textual"), O.VISUAL = new O("visual");
const f = class yi {
constructor(t) {
this.value = t;
}
/**
* Parses a [Feature] from its RWPM JSON representation.
*/
static deserialize(t) {
if (!(!t || typeof t != "string"))
return new yi(t);
}
/**
* Serializes a [Feature] to its RWPM JSON representation.
*/
serialize() {
return this.value;
}
};
f.NONE = new f("none"), f.ANNOTATIONS = new f("annotations"), f.ARIA = new f("ARIA"), f.INDEX = new f("index"), f.PAGE_BREAK_MARKERS = new f("pageBreakMarkers"), f.PAGE_NAVIGATION = new f("pageNavigation"), f.PRINT_PAGE_NUMBERS = new f("printPageNumbers"), f.READING_ORDER = new f("readingOrder"), f.STRUCTURAL_NAVIGATION = new f("structuralNavigation"), f.TABLE_OF_CONTENTS = new f("tableOfContents"), f.TAGGED_PDF = new f("taggedPDF"), f.ALTERNATIVE_TEXT = new f("alternativeText"), f.AUDIO_DESCRIPTION = new f("audioDescription"), f.CAPTIONS = new f("captions"), f.CLOSED_CAPTIONS = new f("closedCaptions"), f.DESCRIBED_MATH = new f("describedMath"), f.LONG_DESCRIPTION = new f("longDescription"), f.OPEN_CAPTIONS = new f("openCaptions"), f.SIGN_LANGUAGE = new f("signLanguage"), f.TRANSCRIPT = new f("transcript"), f.DISPLAY_TRANSFORMABILITY = new f("displayTransformability"), f.SYNCHRONIZED_AUDIO_TEXT = new f("synchronizedAudioText"), f.TIMING_CONTROL = new f("timingControl"), f.UNLOCKED = new f("unlocked"), f.CHEM_ML = new f("ChemML"), f.LATEX = new f("latex"), f.LATEX_CHEMISTRY = new f("latex-chemistry"), f.MATH_ML = new f("MathML"), f.MATH_ML_CHEMISTRY = new f("MathML-chemistry"), f.TTS_MARKUP = new f("ttsMarkup"), f.HIGH_CONTRAST_AUDIO = new f("highContrastAudio"), f.HIGH_CONTRAST_DISPLAY = new f("highContrastDisplay"), f.LARGE_PRINT = new f("largePrint"), f.BRAILLE = new f("braille"), f.TACTILE_GRAPHIC = new f("tactileGraphic"), f.TACTILE_OBJECT = new f("tactileObject"), f.FULL_RUBY_ANNOTATIONS = new f("fullRubyAnnotations"), f.HORIZONTAL_WRITING = new f("horizontalWriting"), f.RUBY_ANNOTATIONS = new f("rubyAnnotations"), f.VERTICAL_WRITING = new f("verticalWriting"), f.WITH_ADDITIONAL_WORD_SEGMENTATION = new f("withAdditionalWordSegmentation"), f.WITHOUT_ADDITIONAL_WORD_SEGMENTATION = new f("withoutAdditionalWordSegmentation");
let Ii = f;
var B = /* @__PURE__ */ ((r) => (r.reflowable = "reflowable", r.fixed = "fixed", r.scrolled = "scrolled", r))(B || {});
let fA = class Fi {
/**
* Creates a [Encryption].
*/
constructor(t) {
this.algorithm = t.algorithm, this.compression = t.compression, this.originalLength = t.originalLength, this.profile = t.profile, this.scheme = t.scheme;
}
/**
* Parses a [Encryption] from its RWPM JSON representation.
*/
static deserialize(t) {
if (t && t.algorithm)
return new Fi({
algorithm: t.algorithm,
compression: t.compression,
originalLength: t.originalLength,
profile: t.profile,
scheme: t.scheme
});
}
/**
* Serializes a [Encryption] to its RWPM JSON representation.
*/
serialize() {
const t = { algorithm: this.algorithm };
return this.compression !== void 0 && (t.compression = this.compression), this.originalLength !== void 0 && (t.originalLength = this.originalLength), this.profile !== void 0 && (t.profile = this.profile), this.scheme !== void 0 && (t.scheme = this.scheme), t;
}
};
var G = /* @__PURE__ */ ((r) => (r.left = "left", r.right = "right", r.center = "center", r))(G || {});
let k = class he {
constructor(t) {
this.otherProperties = t;
}
get page() {
return this.otherProperties.page;
}
/**
* Creates a [Properties] from its RWPM JSON representation.
*/
static deserialize(t) {
if (t)
return new he(t);
}
/**
* Serializes a [Properties] to its RWPM JSON representation.
*/
serialize() {
return this.otherProperties;
}
/**
* Makes a copy of this [Properties] after merging in the given additional other [properties].
*/
add(t) {
const e = Object.assign({}, this.otherProperties);
for (const i in t)
e[i] = t[i];
return new he(e);
}
};
Object.defineProperty(k.prototype, "encryption", {
get: function() {
return fA.deserialize(this.otherProperties.encrypted);
}
});
function MA(r) {
return r && Array.isArray(r) ? r : void 0;
}
function Ui(r) {
return r && typeof r == "string" ? [r] : MA(r);
}
function ve(r) {
return typeof r == "string" ? new Date(r) : void 0;
}
function Qt(r) {
return isNaN(r) ? void 0 : r;
}
function x(r) {
return Qt(r) !== void 0 && Math.sign(r) >= 0 ? r : void 0;
}
function BA(r) {
const t = new Array();
return r.forEach((e) => t.push(e)), t;
}
class u {
/** Creates a MediaType object. */
constructor(t) {
let e, i, A = t.mediaType.replace(/\s/g, "").split(";");
const n = A[0].split("/");
if (n.length === 2) {
if (e = n[0].toLowerCase().trim(), i = n[1].toLowerCase().trim(), e.length === 0 || i.length === 0)
throw new Error("Invalid media type");
} else
throw new Error("Invalid media type");
const o = {};
for (let g = 1; g < A.length; g++) {
const M = A[g].split("=");
if (M.length === 2) {
const l = M[0].toLocaleLowerCase(), p = l === "charset" ? M[1].toUpperCase() : M[1];
o[l] = p;
}
}
const s = {}, a = Object.keys(o);
a.sort((g, M) => g.localeCompare(M)), a.forEach((g) => s[g] = o[g]);
let h = "";
for (const g in s) {
const M = s[g];
h += `;${g}=${M}`;
}
const c = `${e}/${i}${h}`, d = s.encoding;
this.string = c, this.type = e, this.subtype = i, this.parameters = s, this.encoding = d, this.name = t.name, this.fileExtension = t.fileExtension;
}
static parse(t) {
return new u(t);
}
/** Structured syntax suffix, e.g. `+zip` in `application/epub+zip`.
* Gives a hint on the underlying structure of this media type.
* See. https://tools.ietf.org/html/rfc6838#section-4.2.8
*/
get structuredSyntaxSuffix() {
const t = this.subtype.split("+");
return t.length > 1 ? `+${t[t.length - 1]}` : void 0;
}
/** Parameter values might or might not be case-sensitive, depending on the semantics of
* the parameter name.
* https://tools.ietf.org/html/rfc2616#section-3.7
*
* The character set names may be up to 40 characters taken from the printable characters
* of US-ASCII. However, no distinction is made between use of upper and lower case
* letters.
* https://www.iana.org/assignments/character-sets/character-sets.xhtml
*/
get charset() {
return this.parameters.charset;
}
/** Returns whether the given `other` media type is included in this media type.
* For example, `text/html` contains `text/html;charset=utf-8`.
* - `other` must match the parameters in the `parameters` property, but extra parameters
* are ignored.
* - Order of parameters is ignored.
* - Wildcards are supported, meaning that `image/*` contains `image/png`
*/
contains(t) {
const e = typeof t == "string" ? u.parse({ mediaType: t }) : t;
if (!((this.type === "*" || this.type === e.type) && (this.subtype === "*" || this.subtype === e.subtype)))
return !1;
const i = new Set(
Object.entries(this.parameters).map(([n, o]) => `${n}=${o}`)
), A = new Set(
Object.entries(e.parameters).map(([n, o]) => `${n}=${o}`)
);
for (const n of Array.from(i.values()))
if (!A.has(n))
return !1;
return !0;
}
/** Returns whether this media type and `other` are the same, ignoring parameters that
* are not in both media types.
* For example, `text/html` matches `text/html;charset=utf-8`, but `text/html;charset=ascii`
* doesn't. This is basically like `contains`, but working in both direction.
*/
matches(t) {
const e = typeof t == "string" ? u.parse({ mediaType: t }) : t;
return this.contains(e) || e.contains(this);
}
/**
* Returns whether this media type matches any of the [others] media types.
*/
matchesAny(...t) {
for (const e of t)
if (this.matches(e))
return !0;
return !1;
}
/** Checks the MediaType equals another one (comparing their string) */
equals(t) {
return this.string === t.string;
}
/** Returns whether this media type is structured as a ZIP archive. */
get isZIP() {
return this.matchesAny(
u.ZIP,
u.LCP_PROTECTED_AUDIOBOOK,
u.LCP_PROTECTED_PDF
) || this.structuredSyntaxSuffix === "+zip";
}
/** Returns whether this media type is structured as a JSON file. */
get isJSON() {
return this.matchesAny(u.JSON) || this.structuredSyntaxSuffix === "+json";
}
/** Returns whether this media type is of an OPDS feed. */
get isOPDS() {
return this.matchesAny(
u.OPDS1,
u.OPDS1_ENTRY,
u.OPDS2,
u.OPDS2_PUBLICATION,
u.OPDS_AUTHENTICATION
) || this.structuredSyntaxSuffix === "+json";
}
/** Returns whether this media type is of an HTML document. */
get isHTML() {
return this.matchesAny(u.HTML, u.XHTML);
}
/** Returns whether this media type is of a bitmap image, so excluding vectorial formats. */
get isBitmap() {
return this.matchesAny(
u.BMP,
u.GIF,
u.JPEG,
u.PNG,
u.TIFF,
u.WEBP
);
}
/** Returns whether this media type is of an audio clip. */
get isAudio() {
return this.type === "audio";
}
/** Returns whether this media type is of a video clip. */
get isVideo() {
return this.type === "video";
}
/** Returns whether this media type is of a Readium Web Publication Manifest. */
get isRWPM() {
return this.matchesAny(
u.READIUM_AUDIOBOOK_MANIFEST,
u.DIVINA_MANIFEST,
u.READIUM_WEBPUB_MANIFEST
);
}
/** Returns whether this media type is of a publication file. */
get isPublication() {
return this.matchesAny(
u.READIUM_AUDIOBOOK,
u.READIUM_AUDIOBOOK_MANIFEST,
u.CBZ,
u.DIVINA,
u.DIVINA_MANIFEST,
u.EPUB,
u.LCP_PROTECTED_AUDIOBOOK,
u.LCP_PROTECTED_PDF,
u.LPF,
u.PDF,
u.W3C_WPUB_MANIFEST,
u.READIUM_WEBPUB,
u.READIUM_WEBPUB_MANIFEST,
u.ZAB
);
}
// Known Media Types
static get AAC() {
return u.parse({ mediaType: "audio/aac", fileExtension: "aac" });
}
static get ACSM() {
return u.parse({
mediaType: "application/vnd.adobe.adept+xml",
name: "Adobe Content Server Message",
fileExtension: "acsm"
});
}
static get AIFF() {
return u.parse({ mediaType: "audio/aiff", fileExtension: "aiff" });
}
static get AVI() {
return u.parse({
mediaType: "video/x-msvideo",
fileExtension: "avi"
});
}
static get BINARY() {
return u.parse({ mediaType: "application/octet-stream" });
}
static get BMP() {
return u.parse({ mediaType: "image/bmp", fileExtension: "bmp" });
}
static get CBZ() {
return u.parse({
mediaType: "application/vnd.comicbook+zip",
name: "Comic Book Archive",
fileExtension: "cbz"
});
}
static get CSS() {
return u.parse({ mediaType: "text/css", fileExtension: "css" });
}
static get DIVINA() {
return u.parse({
mediaType: "application/divina+zip",
name: "Digital Visual Narratives",
fileExtension: "divina"
});
}
static get DIVINA_MANIFEST() {
return u.parse({
mediaType: "application/divina+json",
name: "Digital Visual Narratives",
fileExtension: "json"
});
}
static get EPUB() {
return u.parse({
mediaType: "application/epub+zip",
name: "EPUB",
fileExtension: "epub"
});
}
static get GIF() {
return u.parse({ mediaType: "image/gif", fileExtension: "gif" });
}
static get GZ() {
return u.parse({
mediaType: "application/gzip",
fileExtension: "gz"
});
}
static get HTML() {
return u.parse({ mediaType: "text/html", fileExtension: "html" });
}
static get JAVASCRIPT() {
return u.parse({
mediaType: "text/javascript",
fileExtension: "js"
});
}
static get JPEG() {
return u.parse({ mediaType: "image/jpeg", fileExtension: "jpeg" });
}
static get JSON() {
return u.parse({ mediaType: "application/json" });
}
static get LCP_LICENSE_DOCUMENT() {
return u.parse({
mediaType: "application/vnd.readium.lcp.license.v1.0+json",
name: "LCP License",
fileExtension: "lcpl"
});
}
static get LCP_PROTECTED_AUDIOBOOK() {
return u.parse({
mediaType: "application/audiobook+lcp",
name: "LCP Protected Audiobook",
fileExtension: "lcpa"
});
}
static get LCP_PROTECTED_PDF() {
return u.parse({
mediaType: "application/pdf+lcp",
name: "LCP Protected PDF",
fileExtension: "lcpdf"
});
}
static get LCP_STATUS_DOCUMENT() {
return u.parse({
mediaType: "application/vnd.readium.license.status.v1.0+json"
});
}
static get LPF() {
return u.parse({
mediaType: "application/lpf+zip",
fileExtension: "lpf"
});
}
static get MP3() {
return u.parse({ mediaType: "audio/mpeg", fileExtension: "mp3" });
}
static get MPEG() {
return u.parse({ mediaType: "video/mpeg", fileExtension: "mpeg" });
}
static get NCX() {
return u.parse({
mediaType: "application/x-dtbncx+xml",
fileExtension: "ncx"
});
}
static get OGG() {
return u.parse({ mediaType: "audio/ogg", fileExtension: "oga" });
}
static get OGV() {
return u.parse({ mediaType: "video/ogg", fileExtension: "ogv" });
}
static get OPDS1() {
return u.parse({
mediaType: "application/atom+xml;profile=opds-catalog"
});
}
static get OPDS1_ENTRY() {
return u.parse({
mediaType: "application/atom+xml;type=entry;profile=opds-catalog"
});
}
static get OPDS2() {
return u.parse({ mediaType: "application/opds+json" });
}
static get OPDS2_PUBLICATION() {
return u.parse({ mediaType: "application/opds-publication+json" });
}
static get OPDS_AUTHENTICATION() {
return u.parse({
mediaType: "application/opds-authentication+json"
});
}
static get OPUS() {
return u.parse({ mediaType: "audio/opus", fileExtension: "opus" });
}
static get OTF() {
return u.parse({ mediaType: "font/otf", fileExtension: "otf" });
}
static get PDF() {
return u.parse({
mediaType: "application/pdf",
name: "PDF",
fileExtension: "pdf"
});
}
static get PNG() {
return u.parse({ mediaType: "image/png", fileExtension: "png" });
}
static get READIUM_AUDIOBOOK() {
return u.parse({
mediaType: "application/audiobook+zip",
name: "Readium Audiobook",
fileExtension: "audiobook"
});
}
static get READIUM_AUDIOBOOK_MANIFEST() {
return u.parse({
mediaType: "application/audiobook+json",
name: "Readium Audiobook",
fileExtension: "json"
});
}
static get READIUM_CONTENT_DOCUMENT() {
return u.parse({
mediaType: "application/vnd.readium.content+json",
name: "Readium Content Document",
fileExtension: "json"
});
}
static get READIUM_GUIDED_NAVIGATION_DOCUMENT() {
return u.parse({
mediaType: "application/guided-navigation+json",
name: "Readium Guided Navigation Document",
fileExtension: "json"
});
}
static get READIUM_POSITION_LIST() {
return u.parse({
mediaType: "application/vnd.readium.position-list+json",
name: "Readium Position List",
fileExtension: "json"
});
}
static get READIUM_WEBPUB() {
return u.parse({
mediaType: "application/webpub+zip",
name: "Readium Web Publication",
fileExtension: "webpub"
});
}
static get READIUM_WEBPUB_MANIFEST() {
return u.parse({
mediaType: "application/webpub+json",
name: "Readium Web Publication",
fileExtension: "json"
});
}
static get SMIL() {
return u.parse({
mediaType: "application/smil+xml",
fileExtension: "smil"
});
}
static get SVG() {
return u.parse({
mediaType: "image/svg+xml",
fileExtension: "svg"
});
}
static get TEXT() {
return u.parse({ mediaType: "text/plain", fileExtension: "txt" });
}
static get TIFF() {
return u.parse({ mediaType: "image/tiff", fileExtension: "tiff" });
}
static get TTF() {
return u.parse({ mediaType: "font/ttf", fileExtension: "ttf" });
}
static get W3C_WPUB_MANIFEST() {
return u.parse({
mediaType: "application/x.readium.w3c.wpub+json",
name: "Web Publication",
fileExtension: "json"
});
}
static get WAV() {
return u.parse({ mediaType: "audio/wav", fileExtension: "wav" });
}
static get WEBM_AUDIO() {
return u.parse({ mediaType: "audio/webm", fileExtension: "webm" });
}
static get WEBM_VIDEO() {
return u.parse({ mediaType: "video/webm", fileExtension: "webm" });
}
static get WEBP() {
return u.parse({ mediaType: "image/webp", fileExtension: "webp" });
}
static get WOFF() {
return u.parse({ mediaType: "font/woff", fileExtension: "woff" });
}
static get WOFF2() {
return u.parse({ mediaType: "font/woff2", fileExtension: "woff2" });
}
static get XHTML() {
return u.parse({
mediaType: "application/xhtml+xml",
fileExtension: "xhtml"
});
}
static get XML() {
return u.parse({
mediaType: "application/xml",
fileExtension: "xml"
});
}
static get ZAB() {
return u.parse({
mediaType: "application/x.readium.zab+zip",
name: "Zipped Audio Book",
fileExtension: "zab"
});
}
static get ZIP() {
return u.parse({
mediaType: "application/zip",
fileExtension: "zip"
});
}
}
let De = class {
constructor(t) {
this.uri = t, this.parameters = this.getParameters(t);
}
/**
* List of URI template parameter keys, if the [Link] is templated.
*/
getParameters(t) {
const e = /\{\??([^}]+)\}/g, i = t.match(e);
return i ? new Set(
i.join(",").replace(e, "$1").split(",").map((A) => A.trim())
) : /* @__PURE__ */ new Set();
}
/** Expands the URI by replacing the template variables by the given parameters.
* Any extra parameter is appended as query parameters.
* See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
*/
expand(t) {
const e = (A) => A.split(",").map((n) => {
const o = t[n];
return o ? encodeURIComponent(o) : "";
}).join(","), i = (A) => "?" + A.split(",").map((n) => {
const o = n.split("=")[0], s = t[o];
return s ? `${o}=${encodeURIComponent(s)}` : "";
}).join("&");
return this.uri.replace(/\{(\??)([^}]+)\}/g, (...A) => A[1] ? i(A[2]) : e(A[2]));
}
}, j = class Ri {
/**
* Creates a [Locations].
*/
constructor(t) {
this.fragments = t.fragments ? t.fragments : new Array(), this.progression = t.progression, this.totalProgression = t.totalProgression, this.position = t.position, this.otherLocations = t.otherLocations;
}
/**
* Parses a [Locations] from its RWPM JSON representation.
*/
static deserialize(t) {
if (!t) return;
const e = Qt(t.progression), i = Qt(t.totalProgression), A = Qt(t.position), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([
"fragment",
"fragments",
"progression",
"totalProgression",
"position"
]);
return Object.entries(t).forEach(([s, a]) => {
o.has(s) || n.set(s, a);
}), new Ri({
fragments: Ui(t.fragments || t.fragment),
progression: e !== void 0 && e >= 0 && e <= 1 ? e : void 0,
totalProgression: i !== void 0 && i >= 0 && i <= 1 ? i : void 0,
position: A !== void 0 && A > 0 ? A : void 0,
otherLocations: n.size === 0 ? void 0 : n
});
}
/**
* Serializes a [Locations] to its RWPM JSON representation.
*/
serialize() {
const t = {};
return this.fragments && (t.fragments = this.fragments), this.progression !== void 0 && (t.progression = this.progression), this.totalProgression !== void 0 && (t.totalProgression = this.totalProgression), this.position !== void 0 && (t.position = this.position), this.otherLocations && this.otherLocations.forEach((e, i) => t[i] = e), t;
}
}, wA = class Ci {
/**
* Creates a [Text].
*/
constructor(t) {
this.after = t.after, this.before = t.before, this.highlight = t.highlight;
}
/**
* Parses a [Locations] from its RWPM JSON representation.
*/
static deserialize(t) {
if (t)
return new Ci({
after: t.after,
before: t.before,
highlight: t.highlight
});
}
/**
* Serializes a [Locations] to its RWPM JSON representation.
*/
serialize() {
const t = {};
return this.after !== void 0 && (t.after = this.after), this.before !== void 0 && (t.before = this.before), this.highlight !== void 0 && (t.highlight = this.highlight), t;
}
}, dt = class ce {
/**
* Creates a [Locator].
*/
constructor(t) {
this.href = t.href, this.type = t.type, this.title = t.title, this.locations = t.locations ? t.locations : new j({}), this.text = t.text;
}
/**
* Parses a [Link] from its RWPM JSON representation.
*/
static deserialize(t) {
if (t && t.href && t.type)
return new ce({
href: t.href,
type: t.type,
title: t.title,
locations: j.deserialize(t.locations),
text: wA.deserialize(t.text)
});
}
/**
* Serializes a [Link] to its RWPM JSON representation.
*/
serialize() {
const t = { href: this.href, type: this.type };
return this.title !== void 0 && (t.title = this.title), this.locations && (t.locations = this.locations.serialize()), this.text && (t.text = this.text.serialize()), t;
}
/**
* Shortcut to get a copy of the [Locator] with different [Locations] sub-properties.
*/
copyWithLocations(t) {
return new ce({
href: this.href,
type: this.type,
title: this.title,
text: this.text,
locations: new j({ ...this.locations, ...t })
});
}
};
class H {
/**
* Creates a [Link].
*/
constructor(t) {
this.href = t.href, this.templated = t.templated, this.type = t.type, this.title = t.title, this.rels = t.rels, this.properties = t.properties, this.height = t.height, this.width = t.width, this.size = t.size, this.duration = t.duration, this.bitrate = t.bitrate, this.languages = t.languages, this.alternates = t.alternates, this.children = t.children;
}
/**
* Parses a [Link] from its RWPM JSON representation.
*/
static deserialize(t) {
if (!(!t || typeof t.href != "string"))
return new H({
href: t.href,
templated: t.templated,
type: t.type,
title: t.title,
rels: t.rel ? Array.isArray(t.rel) ? new Set(t.rel) : /* @__PURE__ */ new Set([t.rel]) : void 0,
properties: k.deserialize(t.properties),
height: x(t.height),
width: x(t.width),
size: x(t.size),
duration: x(t.duration),
bitrate: x(t.bitrate),
languages: Ui(t.language),
alternates: He.deserialize(t.alternate),
children: He.deserialize(t.children)
});
}
/**
* Serializes a [Link] to its RWPM JSON representation.
*/
serialize() {
const t = { href: this.href };
return this.templated !== void 0 && (t.templated = this.templated), this.type !== void 0 && (t.type = this.type), this.title !== void 0 && (t.title = this.title), this.rels && (t.rel = BA(this.rels)), this.properties && (t.properties = this.properties.serialize()), this.height !== void 0 && (t.height = this.height), this.width !== void 0 && (t.width = this.width), this.size !== void 0 && (t.size = this.size), this.duration !== void 0 && (t.duration = this.duration), this.bitrate !== void 0 && (t.bitrate = this.bitrate), this.languages && (t.language = this.languages), this.alternates && (t.alternate = this.alternates.serialize()), this.children && (t.children = this.children.serialize()), t;
}
/** MediaType of the linked resource. */
get mediaType() {
return this.type !== void 0 ? u.parse({ mediaType: this.type }) : u.BINARY;
}
/** Computes an absolute URL to the link, relative to the given `baseURL`.
* If the link's `href` is already absolute, the `baseURL` is ignored.
*/
toURL(t) {
const e = this.href.replace(/^(\/)/, "");
if (e.length === 0) return;
let i = t || "/";
return i.startsWith("/") && (i = "file://" + i), new URL(e, i).href.replace(/^(file:\/\/)/, "");
}
/** List of URI template parameter keys, if the `Link` is templated. */
get templateParameters() {
return this.templated ? new De(this.href).parameters : /* @__PURE__ */ new Set();
}
/** Expands the `Link`'s HREF by replacing URI template variables by the given parameters.
* See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
*/
expandTemplate(t) {
return new H({
href: new De(this.href).expand(t),
templated: !1
});
}
/**
* Makes a copy of this [Link] after merging in the given additional other [properties].
*/
addProperties(t) {
const e = H.deserialize(this.serialize());
return e.properties = e.properties ? e.properties?.add(t) : new k(t), e;
}
/**
* Creates a [Locator] from a reading order [Link].
*/
get locator() {
let t = this.href.split("#");
return new dt({
href: t.length > 0 && t[0] !== void 0 ? t[0] : this.href,
type: this.type ?? "",
title: this.title,
locations: new j({
fragments: t.length > 1 && t[1] !== void 0 ? [t[1]] : []
})
});
}
}
let He = class Si {
/**
* Creates a [Links].
*/
constructor(t) {
this.items = t;
}
/**
* Creates a list of [Link] from its RWPM JSON representation.
*/
static deserialize(t) {
if (t && Array.isArray(t))
return new Si(
t.map((e) => H.deserialize(e)).filter((e) => e !== void 0)
);
}
/**
* Serializes an array of [Link] to its RWPM JSON representation.
*/
serialize() {
return this.items.map((t) => t.serialize());
}
/** Finds the first link with the given relation. */
findWithRel(t) {
const e = (i) => i.rels && i.rels.has(t);
return this.items.find(e);
}
/** Finds all the links with the given relation. */
filterByRel(t) {
const e = (i) => i.rels && i.rels.has(t);
return this.items.filter(e);
}
/** Finds the first link matching the given HREF. */
findWithHref(t) {
const e = (i) => i.href === t;
return this.items.find(e);
}
/** Finds the index of the first link matching the given HREF. */
findIndexWithHref(t) {
const e = (i) => i.href === t;
return this.items.findIndex(e);
}
/** Finds the first link matching the given media type. */
findWithMediaType(t) {
const e = (i) => i.mediaType.matches(t);
return this.items.find(e);
}
/** Finds all the links matching the given media type. */
filterByMediaType(t) {
const e = (i) => i.mediaType.matches(t);
return this.items.filter(e);
}
/** Finds all the links matching any of the given media types. */
filterByMediaTypes(t) {
const e = (i) => {
for (const A of t)
if (i.mediaType.matches(A))
return !0;
return !1;
};
return this.items.filter(e);
}
/** Returns whether all the resources in the collection are audio clips. */
everyIsAudio() {
const t = (e) => e.mediaType.isAudio;
return this.items.length > 0 && this.items.every(t);
}
/** Returns whether all the resources in the collection are bitmaps. */
everyIsBitmap() {
const t = (e) => e.mediaType.isBitmap;
return this.items.length > 0 && this.items.every(t);
}
/** Returns whether all the resources in the collection are HTML documents. */
everyIsHTML() {
const t = (e) => e.mediaType.isHTML;
return this.items.length > 0 && this.items.every(t);
}
/** Returns whether all the resources in the collection are video clips. */
everyIsVideo() {
const t = (e) => e.mediaType.isVideo;
return this.items.length > 0 && this.items.every(t);
}
/** Returns whether all the resources in the collection are matching any of the given media types. */
everyMatchesMediaType(t) {
return Array.isArray(t) ? this.items.length > 0 && this.items.every((e) => {
for (const i of t)
return e.mediaType.matches(i);
return !1;
}) : this.items.length > 0 && this.items.every((e) => e.mediaType.matches(t));
}
filterLinksHasType() {
return this.items.filter((t) => t.type);
}
};
var zi = /* @__PURE__ */ ((r) => (r.EPUB = "https://readium.org/webpub-manifest/profiles/epub", r.AUDIOBOOK = "https://readium.org/webpub-manifest/profiles/audiobook", r.DIVINA = "https://readium.org/webpub-manifest/profiles/divina", r.PDF = "https://readium.org/webpub-manifest/profiles/pdf", r))(zi || {}), N = /* @__PURE__ */ ((r) => (r.ltr = "ltr", r.rtl = "rtl", r))(N || {});
k.prototype.getContains = function() {
return new Set(this.otherProperties.contains || []);
};
let Ge = class Qi {
/**
* Creates a [DomRange].
*/
constructor(t) {
this.cssSelector = t.cssSelector, this.textNodeIndex = t.textNodeIndex, this.charOffset = t.charOffset;
}
/**
* Parses a [DomRangePoint] from its RWPM JSON representation.
*/
static deserialize(t) {
if (!(t && t.cssSelector)) return;
let e = x(t.textNodeIndex);
if (e === void 0) return;
let i = x(t.charOffset);
return i === void 0 && (i = x(t.offset)), new Qi({
cssSelector: t.cssSelector,
textNodeIndex: e,
charOffset: i
});
}
/**
* Serializes a [DomRangePoint] to its RWPM JSON representation.
*/
serialize() {
const t = {
cssSelector: this.cssSelector,
textNodeIndex: this.textNodeIndex
};
return this.charOffset !== void 0 && (t.charOffset = this.charOffset), t;
}
};
class Ee {
/**
* Creates a [DomRange].
*/
constructor(t) {
this.start = t.start, this.end = t.end;
}
/**
* Parses a [DomRange] from its RWPM JSON representation.
*/
static deserialize(t) {
if (!t) return;
let e = Ge.deserialize(t.start);
if (e)
return new Ee({
start: e,
end: Ge.deserialize(t.end)
});
}
/**
* Serializes a [DomRange] to its RWPM JSON representation.
*/
serialize() {
const t = { start: this.start.serialize() };
return this.end && (t.end = this.end.serialize()), t;
}
}
j.prototype.getCssSelector = function() {
return this.otherLocations?.get("cssSelector");
};
j.prototype.getPartialCfi = function() {
return this.otherLocations?.get("partialCfi");
};
j.prototype.getDomRange = function() {
return Ee.deserialize(this.otherLocations?.get("domRange"));
};
j.prototype.fragmentParameters = function() {
return new Map(
this.fragments.map((r) => r.startsWith("#") ? r.slice(1) : r).join("&").split("&").filter((r) => !r.startsWith("#")).map((r) => r.split("=")).filter((r) => r.length === 2).map((r) => [
r[0].trim().toLowerCase(),
r[1].trim()
])
);
};
j.prototype.htmlId = function() {
if (!this.fragments.length) return;
let r = this.fragments.find((t) => t.length && !t.includes("="));
if (!r) {
const t = this.fragmentParameters();
t.has("id") ? r = t.get("id") : t.has("name") && (r = t.get("name"));
}
return r?.startsWith("#") ? r.slice(1) : r;
};
j.prototype.page = function() {
const r = parseInt(this.fragmentParameters().get("page"));
if (!isNaN(r) && r >= 0) return r;
};
j.prototype.time = function() {
const r = parseInt(this.fragmentParameters().get("t"));
if (!isNaN(r)) return r;
};
j.prototype.space = function() {
const r = this.fragmentParameters();
if (!r.has("xywh")) return;
const t = r.get("xywh").split(",").map((e) => parseInt(e));
if (t.length === 4 && !t.some(isNaN))
return t;
};
let EA = class Yi {
/** Creates a [Price]. */
constructor(t) {
this.currency = t.currency, this.value = t.value;
}
/**
* Parses a [Price] from its RWPM JSON representation.
*/
static deserialize(t) {
if (!t) return;
let e = t.currency;
if (!(e && typeof e == "string" && e.length > 0))
return;
let i = x(t.value);
if (i !== void 0)
return new Yi({ currency: e, value: i });
}
/**
* Serializes a [Price] to its RWPM JSON representation.
*/
serialize() {
return { currency: this.currency, value: this.value };
}
}, yA = class Yt {
/** Creates a [Acquisition]. */
constructor(t) {
this.type = t.type, this.children = t.children;
}
/**
* Parses a [Acquisition] from its RWPM JSON representation.
*/
static deserialize(t) {
if (t && t.type)
return new Yt({
type: t.type,
children: Yt.deserializeArray(t.children)
});
}
static deserializeArray(t) {
if (Array.isArray(t))
return t.map((e) => Yt.deserialize(e)).filter((e) => e !== void 0);
}
/**
* Serializes a [Acquisition] to its RWPM JSON representation.
*/
serialize() {
const t = { type: this.type };
return this.children && (t.children = this.children.map((e) => e.serialize())), t;
}
};
class ye {
/** Creates a [Price]. */
constructor(t) {
this.total = t.total, this.position = t.position;
}
/**
* Parses a [Holds] from its RWPM JSON representation.
*/
static deserialize(t) {
if (t)
return new ye({
total: x(t.total),
position: x(t.position)
});
}
/**
* Serializes a [Holds] to its RWPM JSON representation.
*/
serialize() {
const t = {};
return this.total !== void 0 && (t.total = this.total), this.position !== void 0 && (t.position = this.position), t;
}
}
class Ie {
/** Creates a [Copies]. */
constructor(t) {
this.total = t.total, this.available = t.available;
}
/**
* Parses a [Copies] from its RWPM JSON representation.
*/
static deserialize(t) {
if (t)
return new Ie({
total: x(t.total),
available: x(t.available)
});
}
/**
* Serializes a [Copies] to its RWPM JSON representation.
*/
serialize() {
const t = {};
return this.total !== void 0 && (t.total = this.total), this.available !== void 0 && (t.available = this.available), t;
}
}
class Fe {
/** Creates a [Availability]. */
constructor(t) {
this.state = t.state, this.since = t.since, this.until = t.until;
}
/**
* Parses a [Availability] from its RWPM JSON representation.
*/
static deserialize(t) {
if (t && t.state)
return new Fe({
state: t.state,
since: ve(t.since),
until: ve(t.until)
});
}
/**
* Serializes a [Availability] to its RWPM JSON representation.
*/
serialize() {
const t = { state: this.state };
return this.since !== void 0 && (t.since = this.since.toISOString()), this.until !== void 0 && (t.until = this.until.toISOString()), t;
}
}
k.prototype.getNumberOfItems = function() {
return x(this.otherProperties.numberOfItems);
};
k.prototype.getPrice = function() {
return EA.deserialize(this.otherProperties.price);
};
k.prototype.getIndirectAcquisitions = function() {
const r = this.otherProperties.indirectAcquisition;
if (r && Array.isArray(r))
return r.map((t) => yA.deserialize(t)).filter((t) => t !== void 0);
};
k.prototype.getHolds = function() {
return ye.deserialize(this.otherProperties.holds);
};
k.prototype.getCopies = function() {
return Ie.deserialize(this.otherProperties.copies);
};
k.prototype.getAvailability = function() {
return Fe.deserialize(this.otherProperties.availability);
};
k.prototype.getAuthenticate = function() {
return H.deserialize(this.otherProperties.authenticate);
};
const IA = "CssSelectorGenerator";
function ke(r = "unknown problem", ...t) {
console.warn(`${IA}: ${r}`, ...t);
}
function FA(r) {
return r instanceof RegExp;
}
function UA(r) {
return r.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".+");
}
function RA(r) {
const t = r.map((e) => {
if (FA(e))
return (i) => e.test(i);
if (typeof e == "function")
return (i) => {
const A = e(i);
return typeof A != "boolean" ? (ke("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It's result will be ignored.", e), !1) : A;
};
if (typeof e == "string") {
const i = new RegExp("^" + UA(e) + "$");
return (A) => i.test(A);
}
return ke("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", e), () => !1;
});
return (e) => t.some((i) => i(e));
}
RA([
"class",
"id",
// Angular attributes
"ng-*"
]);
class CA {
}
class Ni extends CA {
/**
* Moves to the left content portion (eg. page) relative to the reading progression direction.
*/
goLeft(t = !1, e) {
this.readingProgression === N.ltr ? this.goBackward(t, e) : this.readingProgression === N.rtl && this.goForward(t, e);
}
/**
* Moves to the right content portion (eg. page) relative to the reading progression direction.
*/
goRight(t = !1, e) {
this.readingProgression === N.ltr ? this.goForward(t, e) : this.readingProgression === N.rtl && this.goBackward(t, e);
}
}
const SA = ':root[style*=--USER__textAlign]{text-align:var(--USER__textAlign)}:root[style*=--USER__textAlign] body,:root[style*=--USER__textAlign] p:not(blockquote p,figcaption p,header p,hgroup p,:root[style*=readium-experimentalHeaderFiltering-on] p[class*=title],:root[style*=readium-experimentalHeaderFiltering-on] div:has(+*)>h1+p,:root[style*=readium-experimentalHeaderFiltering-on] div:has(+*)>p:has(+h1)),:root[style*=--USER__textAlign] li,:root[style*=--USER__textAlign] dd{text-align:var(--USER__textAlign)!important;-moz-text-align-last:auto!important;-epub-text-align-last:auto!important;text-align-last:auto!important}:root[style*=--USER__bodyHyphens]{-webkit-hyphens:var(--USER__bodyHyphens)!important;-moz-hyphens:var(--USER__bodyHyphens)!important;-ms-hyphens:var(--USER__bodyHyphens)!important;-epub-hyphens:var(--USER__bodyHyphens)!important;hyphens:var(--USER__bodyHyphens)!important}:root[style*=--USER__bodyHyphens] body,:root[style*=--USER__bodyHyphens] p,:root[style*=--USER__bodyHyphens] li,:root[style*=--USER__bodyHyphens] div,:root[style*=--USER__bodyHyphens] dd{-webkit-hyphens:inherit;-moz-hyphens:inherit;-ms-hyphens:inherit;-epub-hyphens:inherit;hyphens:inherit}:root[style*=--USER__fontFamily]{font-family:var(--USER__fontFamily)!important}:root[style*=--USER__fontFamily] *{font-family:revert!important}:root[style*=AccessibleDfA]{font-family:AccessibleDfA,Verdana,Tahoma,Trebuchet MS,sans-serif!important}:root[style*="IA Writer Duospace"]{font-family:IA Writer Duospace,Menlo,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier,monospace!important}:root[style*=AccessibleDfA],:root[style*="IA Writer Duospace"],:root[style*=readium-a11y-on]{font-style:normal!important;font-weight:400!important}:root[style*=AccessibleDfA] body *:not(code):not(var):not(kbd):not(samp),:root[style*="IA Writer Duospace"] body *:not(code):not(var):not(kbd):not(samp),:root[style*=readium-a11y-on] body *:not(code):not(var):not(kbd):not(samp){font-family:inherit!important;font-style:inherit!important;font-weight:inherit!important}:root[style*=AccessibleDfA] body *:not(a),:root[style*="IA Writer Duospace"] body *:not(a),:root[style*=readium-a11y-on] body *:not(a){text-decoration:none!important}:root[style*=AccessibleDfA] body *,:root[style*="IA Writer Duospace"] body *,:root[style*=readium-a11y-on] body *{font-variant-caps:normal!important;font-variant-numeric:normal!important;font-variant-position:normal!important}:root[style*=AccessibleDfA] sup,:root[style*="IA Writer Duospace"] sup,:root[style*=readium-a11y-on] sup,:root[style*=AccessibleDfA] sub,:root[style*="IA Writer Duospace"] sub,:root[style*=readium-a11y-on] sub{font-size:1rem!important;vertical-align:baseline!important}:root:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] body{zoom:var(--USER__zoom)!important}:root[style*=readium-iOSPatch-on][style*=--USER__zoom] body{-webkit-text-size-adjust:var(--USER__zoom)!important}@supports selector(figure:has(> img)){:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] figure:has(>img),:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] figure:has(>video),:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] figure:has(>svg),:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] figure:has(>canvas),:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] figure:has(>iframe),:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] figure:has(>audio),:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] div:has(>img:only-child),:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] div:has(>video:only-child),:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] div:has(>svg:only-child),:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] div:has(>canvas:only-child),:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] div:has(>iframe:only-child),:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] div:has(>audio:only-child),:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] table{zoom:calc(100% / var(--USER__zoom))!important}:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] figcaption,:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] caption,:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] td,:root[style*=readium-experimentalZoom-on]:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] th{zoom:var(--USER__zoom)!important}}:root[style*=--USER__lineHeight]{line-height:var(--USER__lineHeight)!important}:root[style*=--USER__lineHeight] body,:root[style*=--USER__lineHeight] p,:root[style*=--USER__lineHeight] li,:root[style*=--USER__lineHeight] div{line-height:inherit}:root[style*=--USER__paraSpacing] p{margin-top:var(--USER__paraSpacing)!important;margin-bottom:var(--USER__paraSpacing)!important}:root[style*=--USER__paraIndent] p:not(blockquote p,figcaption p,header p,hgroup p,:root[style*=readium-experimentalHeaderFiltering-on] p[class*=title],:root[style*=readium-experimentalHeaderFiltering-on] div:has(+*)>h1+p,:root[style*=readium-experimentalHeaderFiltering-on] div:has(+*)>p:has(+h1)){text-indent:var(--USER__paraIndent)!important}:root[style*=--USER__paraIndent] p *,:root[style*=--USER__paraIndent] p:first-letter{text-indent:0!important}:root[style*=--USER__wordSpacing] h1,:root[style*=--USER__wordSpacing] h2,:root[style*=--USER__wordSpacing] h3,:root[style*=--USER__wordSpacing] h4,:root[style*=--USER__wordSpacing] h5,:root[style*=--USER__wordSpacing] h6,:root[style*=--USER__wordSpacing] p,:root[style*=--USER__wordSpacing] li,:root[style*=--USER__wordSpacing] div,:root[style*=--USER__wordSpacing] dt,:root[style*=--USER__wordSpacing] dd{word-spacing:var(--USER__wordSpacing)}:root[style*=--USER__letterSpacing] h1,:root[style*=--USER__letterSpacing] h2,:root[style*=--USER__letterSpacing] h3,:root[style*=--USER__letterSpacing] h4,:root[style*=--USER__letterSpacing] h5,:root[style*=--USER__letterSpacing] h6,:root[style*=--USER__letterSpacing] p,:root[style*=--USER__letterSpacing] li,:root[style*=--USER__letterSpacing] div,:root[style*=--USER__letterSpacing] dt,:root[style*=--USER__letterSpacing] dd{letter-spacing:var(--USER__letterSpacing);font-variant:none}:root[style*=--USER__fontWeight] body{font-weight:var(--USER__fontWeight)!important}:root[style*=--USER__fontWeight] b,:root[style*=--USER__fontWeight] strong{font-weight:bolder}:root[style*=--USER__fontWidth] body{font-stretch:var(--USER__fontWidth)!important}:root[style*=--USER__fontOpticalSizing] body{font-optical-sizing:var(--USER__fontOpticalSizing)!important}:root[style*=readium-noRuby-on] body rt,:root[style*=readium-noRuby-on] body rp{display:none}:root[style*=--USER__ligatures]{font-variant-ligatures:var(--USER__ligatures)!important}:root[style*=--USER__ligatures] *{font-variant-ligatures:inherit!important}:root[style*=readium-iPadOSPatch-on] body{-webkit-text-size-adjust:none}:root[style*=readium-iPadOSPatch-on] p,:root[style*=readium-iPadOSPatch-on] h1,:root[style*=readium-iPadOSPatch-on] h2,:root[style*=readium-iPadOSPatch-on] h3,:root[style*=readium-iPadOSPatch-on] h4,:root[style*=readium-iPadOSPatch-on] h5,:root[style*=readium-iPadOSPatch-on] h6,:root[style*=readium-iPadOSPatch-on] li,:root[style*=readium-iPadOSPatch-on] th,:root[style*=readium-iPadOSPatch-on] td,:root[style*=readium-iPadOSPatch-on] dt,:root[style*=readium-iPadOSPatch-on] dd,:root[style*=readium-iPadOSPatch-on] pre,:root[style*=readium-iPadOSPatch-on] address,:root[style*=readium-iPadOSPatch-on] details,:root[style*=readium-iPadOSPatch-on] summary,:root[style*=readium-iPadOSPatch-on] figcaption,:root[style*=readium-iPadOSPatch-on] div:not(:has(p,h1,h2,h3,h4,h5,h6,li,th,td,dt,dd,pre,address,aside,details,figcaption,summary)),:root[style*=readium-iPadOSPatch-on] aside:not(:has(p,h1,h2,h3,h4,h5,h6,li,th,td,dt,dd,pre,address,aside,details,figcaption,summary)){-webkit-text-zoom:reset}:root[style*=readium-iPadOSPatch-on] abbr,:root[style*=readium-iPadOSPatch-on] b,:root[style*=readium-iPadOSPatch-on] bdi,:root[style*=readium-iPadOSPatch-on] bdo,:root[style*=readium-iPadOSPatch-on] cite,:root[style*=readium-iPadOSPatch-on] code,:root[style*=readium-iPadOSPatch-on] dfn,:root[style*=readium-iPadOSPatch-on] em,:root[style*=readium-iPadOSPatch-on] i,:root[style*=readium-iPadOSPatch-on] kbd,:root[style*=readium-iPadOSPatch-on] mark,:root[style*=readium-iPadOSPatch-on] q,:root[style*=readium-iPadOSPatch-on] rp,:root[style*=readium-iPadOSPatch-on] rt,:root[style*=readium-iPadOSPatch-on] ruby,:root[style*=readium-iPadOSPatch-on] s,:root[style*=readium-iPadOSPatch-on] samp,:root[style*=readium-iPadOSPatch-on] small,:root[style*=readium-iPadOSPatch-on] span,:root[style*=readium-iPadOSPatch-on] strong,:root[style*=readium-iPadOSPatch-on] sub,:root[style*=readium-iPadOSPatch-on] sup,:root[style*=readium-iPadOSPatch-on] time,:root[style*=readium-iPadOSPatch-on] u,:root[style*=readium-iPadOSPatch-on] var{-webkit-text-zoom:normal}:root[style*=readium-iPadOSPatch-on] p:not(:has(b,cite,em,i,q,s,small,span,strong)):first-line{-webkit-text-zoom:normal}', ft = (r, t) => URL.createObjectURL(new Blob([r], { type: t })), xi = (r) => r.replace(/\/\/.*/g, "").replace(/\/\*[\s\S]*?\*\//g, "").replace(/\n/g, "").replace(/\s+/g, " "), zA = (r) => r.replace(/\/\*(?:(?!\*\/)[\s\S])*\*\/|[\r\n\t]+/g, "").replace(/ {2,}/g, " ").replace(/url\((?!(https?:)?\/\/)("?)\/([^\)]+)/g, `url($2${window.location.origin}/$3`), Ue = (r, t) => {
const e = r.createElement("script");
return e.dataset.readium = "true", e.src = t.startsWith("blob:") ? t : ft(t, "text/javascript"), e;
}, QA = (r, t) => {
const e = r.createElement("link");
return e.dataset.readium = "true", e.rel = "stylesheet", e.type = "text/css", e.href = t.startsWith("blob:") ? t : ft(t, "text/css"), e;
}, $t = /* @__PURE__ */ new Map(), Xt = (r, t) => {
if ($t.has(r)) return $t.get(r);
const e = t();
return $t.set(r, e), e;
}, YA = (r) => Ue(r, Xt("css-selector-generator", () => ft(
'!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports._readium_cssSelectorGenerator=e():t._readium_cssSelectorGenerator=e()}(self,(()=>(()=>{"use strict";var t,e,n={d:(t,e)=>{for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},o={};function r(t){return t&&t instanceof Element}function i(t="unknown problem",...e){console.warn(`CssSelectorGenerator: ${t}`,...e)}n.r(o),n.d(o,{default:()=>z,getCssSelector:()=>U}),function(t){t.NONE="none",t.DESCENDANT="descendant",t.CHILD="child"}(t||(t={})),function(t){t.id="id",t.class="class",t.tag="tag",t.attribute="attribute",t.nthchild="nthchild",t.nthoftype="nthoftype"}(e||(e={}));const c={selectors:[e.id,e.class,e.tag,e.attribute],includeTag:!1,whitelist:[],blacklist:[],combineWithinSelector:!0,combineB