diff --git a/flutter_readium/example/lib/widgets/reader.widget.dart b/flutter_readium/example/lib/widgets/reader.widget.dart index b2001b4..9da021b 100644 --- a/flutter_readium/example/lib/widgets/reader.widget.dart +++ b/flutter_readium/example/lib/widgets/reader.widget.dart @@ -63,9 +63,18 @@ class ReaderWidget extends StatelessWidget { container: true, explicitChildNodes: true, child: ExcludeSemantics( - child: ReadiumReaderWidget( - publication: state.publication!, - initialLocator: state.initialLocator, + child: BlocBuilder( + builder: (context, settings) { + return Container( + // Ensure this color is the same as the pub background to avoid flashes of different colors + // predominantly happens on web when chapter changes + color: settings.theme.backgroundColor, + child: ReadiumReaderWidget( + publication: state.publication!, + initialLocator: state.initialLocator, + ), + ); + }, ), ), ); diff --git a/flutter_readium/example/web/readiumReader.js b/flutter_readium/example/web/readiumReader.js index 141913e..67d1b67 100644 --- a/flutter_readium/example/web/readiumReader.js +++ b/flutter_readium/example/web/readiumReader.js @@ -1,2 +1,2 @@ /*! For license information please see readiumReader.js.LICENSE.txt */ -(()=>{"use strict";var __webpack_modules__={"./node_modules/css-loader/dist/cjs.js!./web/_scripts/style.css":(module,__webpack_exports__,__webpack_require__)=>{eval('__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../node_modules/css-loader/dist/runtime/noSourceMaps.js */ "./node_modules/css-loader/dist/runtime/noSourceMaps.js");\n/* harmony import */ var _node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../node_modules/css-loader/dist/runtime/api.js */ "./node_modules/css-loader/dist/runtime/api.js");\n/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);\n// Imports\n\n\nvar ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));\n// Module\n___CSS_LOADER_EXPORT___.push([module.id, `:root {\n /* Material UI */\n font-family: \'Roboto\', system-ui, sans-serif;\n}\n\nhtml,\nbody {\n min-height: 100%;\n overflow: hidden;\n touch-action: pan-x pan-y;\n overscroll-behavior-x: none;\n overscroll-behavior-y: none;\n}\n\nbody {\n margin: 0;\n background: #eee;\n}\n\n#bottom-bar,\n#top-bar {\n height: 48px;\n display: flex;\n justify-content: center;\n align-items: center;\n gap: 2px;\n touch-action: manipulation;\n}\n\n#top-bar {\n justify-content: space-between;\n padding: 0 1em;\n}\n\n#wrapper {\n height: calc(100vh - 96px) !important;\n height: calc(100dvh - 96px) !important; /* New browsers */\n display: flex;\n margin: 0;\n}\n\n#container {\n contain: content;\n width: 100% !important;\n height: 100% !important;\n}\n\n.readium-navigator-iframe {\n width: 100%;\n height: 100%;\n border-width: 0;\n}\n\n/* Loading spinner for resources */\n@keyframes loading {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n\ndiv:has(> .readium-navigator-iframe.blank)::after {\n content: \'\';\n position: absolute;\n top: 50%;\n left: 50%;\n margin-top: -30px;\n margin-left: -30px;\n width: 50px;\n height: 50px;\n border-radius: 50px;\n border: 5px solid grey;\n border-top-color: black;\n animation: loading 2s linear infinite;\n}\n\n[type=\'pagebreak\'] {\n border-top: 1px solid !important;\n display: block !important;\n width: 100% !important;\n line-height: 100% !important;\n padding-top: 8px !important;\n margin-top: 40px !important;\n margin-bottom: 20px !important;\n text-align: right !important;\n font-size: 98% !important;\n}\nspan#activeLocation {\n border-radius: 4px;\n background-color: var(--USER__highlightBackgroundColor) !important;\n color: var(--USER__highlightForegroundColor) !important;\n}\nbody > *:first-child {\n margin-top: 50px !important;\n}\n* {\n word-wrap: break-word;\n}\ntable {\n border-collapse: collapse;\n border-spacing: 0;\n margin: 15px 0;\n width: calc(100% - var(--RS__pageGutter) / 2);\n word-break: break-word;\n}\ntable h1,\ntable h2,\ntable h3,\ntable h4,\ntable h5,\ntable h6 {\n margin: 0;\n}\ntable * {\n font-size: 1rem;\n}\ntable td,\ntable th {\n border-collapse: collapse;\n border: 1px solid #ccc;\n margin: 0;\n padding: 16px;\n vertical-align: top;\n}\ntable caption {\n margin-bottom: 16px;\n}\ntable.transparent-table,\ntable.docx-table,\ntable.plain-table {\n table-layout: fixed;\n width: 100%;\n}\ntable.transparent-table th,\ntable.transparent-table td,\ntable.docx-table th,\ntable.docx-table td,\ntable.plain-table th,\ntable.plain-table td {\n width: auto;\n max-width: 100%;\n}\ntable.transparent-table {\n border-width: 0;\n}\ntable.transparent-table td,\ntable.transparent-table th {\n border-width: 0;\n}\ntable.has-first-row-headers tr:first-child {\n display: none;\n}\ntable.has-header {\n border: none !important;\n}\ntable.has-header tr {\n display: block;\n margin-bottom: 25px;\n}\ntable.has-header tr td {\n border-top-width: 0;\n display: block;\n width: 100% !important;\n box-sizing: border-box;\n}\ntable.has-header tr td:first-child {\n border-top-width: 1px;\n}\ntable.has-header tr td:not(.mobile-header):before {\n background-color: #7c7c7c;\n color: #fff;\n content: attr(data-th);\n display: block;\n margin: -16px -16px 5px;\n padding: 8px 16px;\n}\ntable.has-header tr td.mobile-header {\n text-transform: uppercase;\n background-color: #241f20 !important;\n}\ntable.has-header tr td.mobile-header h6 {\n color: #fff;\n}\ntable.has-header thead tr:first-child {\n display: none;\n}\n`, ""]);\n// Exports\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);\n\n\n//# sourceURL=webpack:///./web/_scripts/style.css?./node_modules/css-loader/dist/cjs.js')},"./node_modules/css-loader/dist/runtime/api.js":module=>{eval('\n\n/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n Author Tobias Koppers @sokra\n*/\nmodule.exports = function (cssWithMappingToString) {\n var list = [];\n\n // return the list of modules as css string\n list.toString = function toString() {\n return this.map(function (item) {\n var content = "";\n var needLayer = typeof item[5] !== "undefined";\n if (item[4]) {\n content += "@supports (".concat(item[4], ") {");\n }\n if (item[2]) {\n content += "@media ".concat(item[2], " {");\n }\n if (needLayer) {\n content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");\n }\n content += cssWithMappingToString(item);\n if (needLayer) {\n content += "}";\n }\n if (item[2]) {\n content += "}";\n }\n if (item[4]) {\n content += "}";\n }\n return content;\n }).join("");\n };\n\n // import a list of modules into the list\n list.i = function i(modules, media, dedupe, supports, layer) {\n if (typeof modules === "string") {\n modules = [[null, modules, undefined]];\n }\n var alreadyImportedModules = {};\n if (dedupe) {\n for (var k = 0; k < this.length; k++) {\n var id = this[k][0];\n if (id != null) {\n alreadyImportedModules[id] = true;\n }\n }\n }\n for (var _k = 0; _k < modules.length; _k++) {\n var item = [].concat(modules[_k]);\n if (dedupe && alreadyImportedModules[item[0]]) {\n continue;\n }\n if (typeof layer !== "undefined") {\n if (typeof item[5] === "undefined") {\n item[5] = layer;\n } else {\n item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");\n item[5] = layer;\n }\n }\n if (media) {\n if (!item[2]) {\n item[2] = media;\n } else {\n item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");\n item[2] = media;\n }\n }\n if (supports) {\n if (!item[4]) {\n item[4] = "".concat(supports);\n } else {\n item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");\n item[4] = supports;\n }\n }\n list.push(item);\n }\n };\n return list;\n};\n\n//# sourceURL=webpack:///./node_modules/css-loader/dist/runtime/api.js?')},"./node_modules/css-loader/dist/runtime/noSourceMaps.js":module=>{eval("\n\nmodule.exports = function (i) {\n return i[1];\n};\n\n//# sourceURL=webpack:///./node_modules/css-loader/dist/runtime/noSourceMaps.js?")},"./web/_scripts/style.css":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval('__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! !../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js */ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js");\n/* harmony import */ var _node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _node_modules_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! !../../node_modules/style-loader/dist/runtime/styleDomAPI.js */ "./node_modules/style-loader/dist/runtime/styleDomAPI.js");\n/* harmony import */ var _node_modules_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _node_modules_style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! !../../node_modules/style-loader/dist/runtime/insertBySelector.js */ "./node_modules/style-loader/dist/runtime/insertBySelector.js");\n/* harmony import */ var _node_modules_style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_node_modules_style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _node_modules_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! !../../node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js */ "./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js");\n/* harmony import */ var _node_modules_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_node_modules_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _node_modules_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! !../../node_modules/style-loader/dist/runtime/insertStyleElement.js */ "./node_modules/style-loader/dist/runtime/insertStyleElement.js");\n/* harmony import */ var _node_modules_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_node_modules_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var _node_modules_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! !../../node_modules/style-loader/dist/runtime/styleTagTransform.js */ "./node_modules/style-loader/dist/runtime/styleTagTransform.js");\n/* harmony import */ var _node_modules_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_node_modules_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5__);\n/* harmony import */ var _node_modules_css_loader_dist_cjs_js_style_css__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! !!../../node_modules/css-loader/dist/cjs.js!./style.css */ "./node_modules/css-loader/dist/cjs.js!./web/_scripts/style.css");\n\n \n \n \n \n \n \n \n \n \n\nvar options = {};\n\noptions.styleTagTransform = (_node_modules_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default());\noptions.setAttributes = (_node_modules_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default());\noptions.insert = _node_modules_style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default().bind(null, "head");\noptions.domAPI = (_node_modules_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default());\noptions.insertStyleElement = (_node_modules_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default());\n\nvar update = _node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default()(_node_modules_css_loader_dist_cjs_js_style_css__WEBPACK_IMPORTED_MODULE_6__["default"], options);\n\n\n\n\n /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_node_modules_css_loader_dist_cjs_js_style_css__WEBPACK_IMPORTED_MODULE_6__["default"] && _node_modules_css_loader_dist_cjs_js_style_css__WEBPACK_IMPORTED_MODULE_6__["default"].locals ? _node_modules_css_loader_dist_cjs_js_style_css__WEBPACK_IMPORTED_MODULE_6__["default"].locals : undefined);\n\n\n//# sourceURL=webpack:///./web/_scripts/style.css?')},"./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js":module=>{eval('\n\nvar stylesInDOM = [];\nfunction getIndexByIdentifier(identifier) {\n var result = -1;\n for (var i = 0; i < stylesInDOM.length; i++) {\n if (stylesInDOM[i].identifier === identifier) {\n result = i;\n break;\n }\n }\n return result;\n}\nfunction modulesToDom(list, options) {\n var idCountMap = {};\n var identifiers = [];\n for (var i = 0; i < list.length; i++) {\n var item = list[i];\n var id = options.base ? item[0] + options.base : item[0];\n var count = idCountMap[id] || 0;\n var identifier = "".concat(id, " ").concat(count);\n idCountMap[id] = count + 1;\n var indexByIdentifier = getIndexByIdentifier(identifier);\n var obj = {\n css: item[1],\n media: item[2],\n sourceMap: item[3],\n supports: item[4],\n layer: item[5]\n };\n if (indexByIdentifier !== -1) {\n stylesInDOM[indexByIdentifier].references++;\n stylesInDOM[indexByIdentifier].updater(obj);\n } else {\n var updater = addElementStyle(obj, options);\n options.byIndex = i;\n stylesInDOM.splice(i, 0, {\n identifier: identifier,\n updater: updater,\n references: 1\n });\n }\n identifiers.push(identifier);\n }\n return identifiers;\n}\nfunction addElementStyle(obj, options) {\n var api = options.domAPI(options);\n api.update(obj);\n var updater = function updater(newObj) {\n if (newObj) {\n if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) {\n return;\n }\n api.update(obj = newObj);\n } else {\n api.remove();\n }\n };\n return updater;\n}\nmodule.exports = function (list, options) {\n options = options || {};\n list = list || [];\n var lastIdentifiers = modulesToDom(list, options);\n return function update(newList) {\n newList = newList || [];\n for (var i = 0; i < lastIdentifiers.length; i++) {\n var identifier = lastIdentifiers[i];\n var index = getIndexByIdentifier(identifier);\n stylesInDOM[index].references--;\n }\n var newLastIdentifiers = modulesToDom(newList, options);\n for (var _i = 0; _i < lastIdentifiers.length; _i++) {\n var _identifier = lastIdentifiers[_i];\n var _index = getIndexByIdentifier(_identifier);\n if (stylesInDOM[_index].references === 0) {\n stylesInDOM[_index].updater();\n stylesInDOM.splice(_index, 1);\n }\n }\n lastIdentifiers = newLastIdentifiers;\n };\n};\n\n//# sourceURL=webpack:///./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js?')},"./node_modules/style-loader/dist/runtime/insertBySelector.js":module=>{eval('\n\nvar memo = {};\n\n/* istanbul ignore next */\nfunction getTarget(target) {\n if (typeof memo[target] === "undefined") {\n var styleTarget = document.querySelector(target);\n\n // Special case to return head of iframe instead of iframe itself\n if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {\n try {\n // This will throw an exception if access to iframe is blocked\n // due to cross-origin restrictions\n styleTarget = styleTarget.contentDocument.head;\n } catch (e) {\n // istanbul ignore next\n styleTarget = null;\n }\n }\n memo[target] = styleTarget;\n }\n return memo[target];\n}\n\n/* istanbul ignore next */\nfunction insertBySelector(insert, style) {\n var target = getTarget(insert);\n if (!target) {\n throw new Error("Couldn\'t find a style target. This probably means that the value for the \'insert\' parameter is invalid.");\n }\n target.appendChild(style);\n}\nmodule.exports = insertBySelector;\n\n//# sourceURL=webpack:///./node_modules/style-loader/dist/runtime/insertBySelector.js?')},"./node_modules/style-loader/dist/runtime/insertStyleElement.js":module=>{eval('\n\n/* istanbul ignore next */\nfunction insertStyleElement(options) {\n var element = document.createElement("style");\n options.setAttributes(element, options.attributes);\n options.insert(element, options.options);\n return element;\n}\nmodule.exports = insertStyleElement;\n\n//# sourceURL=webpack:///./node_modules/style-loader/dist/runtime/insertStyleElement.js?')},"./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js":(module,__unused_webpack_exports,__webpack_require__)=>{eval('\n\n/* istanbul ignore next */\nfunction setAttributesWithoutAttributes(styleElement) {\n var nonce = true ? __webpack_require__.nc : 0;\n if (nonce) {\n styleElement.setAttribute("nonce", nonce);\n }\n}\nmodule.exports = setAttributesWithoutAttributes;\n\n//# sourceURL=webpack:///./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js?')},"./node_modules/style-loader/dist/runtime/styleDomAPI.js":module=>{eval('\n\n/* istanbul ignore next */\nfunction apply(styleElement, options, obj) {\n var css = "";\n if (obj.supports) {\n css += "@supports (".concat(obj.supports, ") {");\n }\n if (obj.media) {\n css += "@media ".concat(obj.media, " {");\n }\n var needLayer = typeof obj.layer !== "undefined";\n if (needLayer) {\n css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");\n }\n css += obj.css;\n if (needLayer) {\n css += "}";\n }\n if (obj.media) {\n css += "}";\n }\n if (obj.supports) {\n css += "}";\n }\n var sourceMap = obj.sourceMap;\n if (sourceMap && typeof btoa !== "undefined") {\n css += "\\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");\n }\n\n // For old IE\n /* istanbul ignore if */\n options.styleTagTransform(css, styleElement, options.options);\n}\nfunction removeStyleElement(styleElement) {\n // istanbul ignore if\n if (styleElement.parentNode === null) {\n return false;\n }\n styleElement.parentNode.removeChild(styleElement);\n}\n\n/* istanbul ignore next */\nfunction domAPI(options) {\n if (typeof document === "undefined") {\n return {\n update: function update() {},\n remove: function remove() {}\n };\n }\n var styleElement = options.insertStyleElement(options);\n return {\n update: function update(obj) {\n apply(styleElement, options, obj);\n },\n remove: function remove() {\n removeStyleElement(styleElement);\n }\n };\n}\nmodule.exports = domAPI;\n\n//# sourceURL=webpack:///./node_modules/style-loader/dist/runtime/styleDomAPI.js?')},"./node_modules/style-loader/dist/runtime/styleTagTransform.js":module=>{eval("\n\n/* istanbul ignore next */\nfunction styleTagTransform(css, styleElement) {\n if (styleElement.styleSheet) {\n styleElement.styleSheet.cssText = css;\n } else {\n while (styleElement.firstChild) {\n styleElement.removeChild(styleElement.firstChild);\n }\n styleElement.appendChild(document.createTextNode(css));\n }\n}\nmodule.exports = styleTagTransform;\n\n//# sourceURL=webpack:///./node_modules/style-loader/dist/runtime/styleTagTransform.js?")},"./web/_scripts/Epub/epubNavigator.ts":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval('__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ initializeEpubNavigatorAndPeripherals: () => (/* binding */ initializeEpubNavigatorAndPeripherals)\n/* harmony export */ });\n/* harmony import */ var _readium_navigator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @readium/navigator */ "./node_modules/@readium/navigator/dist/index.js");\n/* harmony import */ var _readium_shared__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @readium/shared */ "./node_modules/@readium/shared/dist/index.js");\n/* harmony import */ var _peripherals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../peripherals */ "./web/_scripts/peripherals.ts");\n/* harmony import */ var _epubPreferences__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./epubPreferences */ "./web/_scripts/Epub/epubPreferences.ts");\n/* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../helpers */ "./web/_scripts/helpers.ts");\n\n\n\n\n\nasync function initializeEpubNavigatorAndPeripherals(container, publication, initialPosition = undefined, preferencesJsonString, setNav) {\n console.log("Initializing EpubNavigator");\n let positions = await publication.positionsFromManifest();\n if (positions.length === 0) {\n positions = publication.manifest.readingOrder.items.map((link, index) => {\n return new _readium_shared__WEBPACK_IMPORTED_MODULE_1__.Locator({\n href: link.href,\n type: link.type ?? "text/html",\n title: link.title,\n locations: new _readium_shared__WEBPACK_IMPORTED_MODULE_1__.LocatorLocations({\n position: index + 1,\n }),\n });\n });\n }\n let preferences = (0,_epubPreferences__WEBPACK_IMPORTED_MODULE_3__.initializeEpubPreferencesFromString)(preferencesJsonString);\n const configuration = {\n preferences,\n defaults: _epubPreferences__WEBPACK_IMPORTED_MODULE_3__.defaults,\n };\n const p = new _peripherals__WEBPACK_IMPORTED_MODULE_2__["default"]({\n moveTo: (direction) => {\n if (direction === "right") {\n nav.goRight(true, () => { });\n }\n else if (direction === "left") {\n nav.goLeft(true, () => { });\n }\n else if (direction === "up") {\n const iframes = document.querySelectorAll(".readium-navigator-iframe");\n iframes.forEach((iframe) => {\n if (iframe instanceof HTMLIFrameElement) {\n if (iframe.style.visibility !== "hidden") {\n iframe.contentWindow?.scrollBy(0, -100);\n }\n }\n });\n }\n else if (direction === "down") {\n const iframes = document.querySelectorAll(".readium-navigator-iframe");\n iframes.forEach((iframe) => {\n if (iframe instanceof HTMLIFrameElement) {\n if (iframe.style.visibility !== "hidden") {\n iframe.contentWindow?.scrollBy(0, 100);\n }\n }\n });\n }\n },\n menu: (_show) => {\n },\n goProgression: (_shiftKey) => {\n nav.goForward(true, () => { });\n },\n });\n const listeners = {\n scroll: function (_amount) { },\n frameLoaded: function (_wnd) {\n nav._cframes.forEach((frameManager) => {\n if (frameManager) {\n p.observe(frameManager.window);\n }\n });\n p.observe(window);\n },\n positionChanged: (_locator) => {\n window.focus();\n window.updateTextLocator?.(JSON.stringify(_locator));\n },\n tap: function (_e) {\n return false;\n },\n click: function (_e) {\n return false;\n },\n zoom: function (_scale) { },\n miscPointer: function (_amount) {\n },\n customEvent: function (_key, _data) { },\n handleLocator: function (locator) {\n const href = locator.href;\n if (href.startsWith("http://") ||\n href.startsWith("https://") ||\n href.startsWith("mailto:") ||\n href.startsWith("tel:")) {\n if (confirm(`Open "${href}" ?`))\n window.open(href, "_blank");\n }\n else {\n console.warn("Unhandled locator", locator);\n }\n return false;\n },\n textSelected: function (_selection) {\n (0,_helpers__WEBPACK_IMPORTED_MODULE_4__.highlightSelection)(nav, publication, _selection);\n },\n };\n const nav = new _readium_navigator__WEBPACK_IMPORTED_MODULE_0__.EpubNavigator(container, publication, listeners, positions, initialPosition, configuration);\n try {\n await nav.load();\n }\n catch (error) {\n throw error;\n }\n setNav(nav);\n p.observe(window);\n}\n\n\n//# sourceURL=webpack:///./web/_scripts/Epub/epubNavigator.ts?')},"./web/_scripts/Epub/epubPreferences.ts":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval('__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ defaults: () => (/* binding */ defaults),\n/* harmony export */ initializeEpubPreferencesFromString: () => (/* binding */ initializeEpubPreferencesFromString)\n/* harmony export */ });\n/* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../helpers */ "./web/_scripts/helpers.ts");\n\nfunction initializeEpubPreferencesFromString(preferencesString) {\n const prefs = JSON.parse(preferencesString);\n (0,_helpers__WEBPACK_IMPORTED_MODULE_0__.convertVerticalScroll)(prefs);\n if (prefs.textAlign != null) {\n prefs.textAlign = (0,_helpers__WEBPACK_IMPORTED_MODULE_0__.textAlignFromJson)(prefs.textAlign);\n }\n let preferences = {\n backgroundColor: prefs.backgroundColor ?? null,\n blendFilter: prefs.blendFilter ?? null,\n columnCount: prefs.columnCount ?? null,\n constraint: prefs.constraint ?? null,\n darkenFilter: prefs.darkenFilter ?? null,\n deprecatedFontSize: prefs.deprecatedFontSize ?? null,\n fontFamily: prefs.fontFamily ?? null,\n fontSize: prefs.fontSize ?? null,\n fontSizeNormalize: prefs.fontSizeNormalize ?? null,\n fontOpticalSizing: prefs.fontOpticalSizing ?? null,\n fontWeight: prefs.fontWeight ?? null,\n fontWidth: prefs.fontWidth ?? null,\n hyphens: prefs.hyphens ?? null,\n invertFilter: prefs.invertFilter ?? null,\n invertGaijiFilter: prefs.invertGaijiFilter ?? null,\n iOSPatch: prefs.iOSPatch ?? null,\n iPadOSPatch: prefs.iPadOSPatch ?? null,\n letterSpacing: prefs.letterSpacing ?? null,\n ligatures: prefs.ligatures ?? null,\n lineHeight: prefs.lineHeight ?? null,\n linkColor: prefs.linkColor ?? null,\n maximalLineLength: prefs.maximalLineLength ?? null,\n minimalLineLength: prefs.minimalLineLength ?? null,\n noRuby: prefs.noRuby ?? null,\n optimalLineLength: prefs.optimalLineLength ?? null,\n pageGutter: prefs.pageGutter ?? prefs.pageMargins ?? null,\n paragraphIndent: prefs.paragraphIndent ?? null,\n paragraphSpacing: prefs.paragraphSpacing ?? null,\n scroll: prefs.scroll ?? null,\n scrollPaddingTop: prefs.scrollPaddingTop ?? null,\n scrollPaddingBottom: prefs.scrollPaddingBottom ?? null,\n selectionBackgroundColor: prefs.selectionBackgroundColor ?? null,\n selectionTextColor: prefs.selectionTextColor ?? null,\n textAlign: prefs.textAlign ?? null,\n textColor: prefs.textColor ?? null,\n textNormalization: prefs.textNormalization ?? null,\n visitedColor: prefs.visitedColor ?? null,\n wordSpacing: prefs.wordSpacing ?? null,\n };\n preferences = (0,_helpers__WEBPACK_IMPORTED_MODULE_0__.normalizeTypes)(preferences);\n return preferences;\n}\nconst defaults = {\n backgroundColor: null,\n blendFilter: true,\n columnCount: 2,\n fontFamily: "Arial",\n fontSize: 1,\n fontWeight: 400,\n hyphens: true,\n ligatures: true,\n lineHeight: 1.5,\n pageGutter: 10,\n scroll: false,\n selectionBackgroundColor: "#cccccc",\n selectionTextColor: "#000000",\n visitedColor: "#551a8b",\n wordSpacing: 0,\n};\n\n\n//# sourceURL=webpack:///./web/_scripts/Epub/epubPreferences.ts?')},"./web/_scripts/ReadiumReader.ts":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval('__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _style_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./style.css */ "./web/_scripts/style.css");\n/* harmony import */ var _readium_shared__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @readium/shared */ "./node_modules/@readium/shared/dist/index.js");\n/* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./helpers */ "./web/_scripts/helpers.ts");\n/* harmony import */ var _enums__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./enums */ "./web/_scripts/enums.ts");\n/* harmony import */ var _extensions_ReadiumPublication__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./extensions/ReadiumPublication */ "./web/_scripts/extensions/ReadiumPublication.ts");\n/* harmony import */ var _Epub_epubNavigator__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Epub/epubNavigator */ "./web/_scripts/Epub/epubNavigator.ts");\n/* harmony import */ var _WebPub_webpubNavigator__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./WebPub/webpubNavigator */ "./web/_scripts/WebPub/webpubNavigator.ts");\n\n\n\n\n\n\n\n\nclass _ReadiumReader {\n constructor() {\n console.log("R2Navigator initialized");\n }\n _publication;\n _nav;\n get isNavigatorReady() {\n return !!this._nav;\n }\n static _publications = new Map();\n async getPublication(publicationURL) {\n try {\n const { manifest, fetcher } = await (0,_helpers__WEBPACK_IMPORTED_MODULE_2__.fetchManifest)(publicationURL);\n this._publication = new _extensions_ReadiumPublication__WEBPACK_IMPORTED_MODULE_4__.ReadiumPublication({ manifest, fetcher });\n let pubId = this._publication.metadata.identifier ?? "unidentified";\n _ReadiumReader._publications.set(pubId, this._publication);\n return JSON.stringify(this._publication);\n }\n catch (error) {\n throw new Error("Error getting publication: " + error);\n }\n }\n goRight() {\n this._nav?.goRight(true, () => { });\n }\n goLeft() {\n this._nav?.goLeft(true, () => { });\n }\n async goTo(href) {\n let link = this._nav?.publication.resources?.findWithHref(href);\n if (!link) {\n let publicationLinks = this._nav?.publication.resources;\n let linksString = publicationLinks?.items\n .map((link) => link.href)\n .join(", ");\n console.error("Link not found " + href + ". Available links: " + linksString);\n let error = new Error("Link not found " + href);\n throw error;\n }\n this._nav?.goLink(link, true, (ok) => {\n if (!ok) {\n let error = new Error("Failed to navigate to link " + href);\n throw error;\n }\n });\n }\n async openPublication(publicationURL, pubId, initialPositionJson, preferencesJson) {\n window.updateReaderStatus?.(_enums__WEBPACK_IMPORTED_MODULE_3__.ReadiumReaderStatus.loading);\n const container = document.body.querySelector("#container");\n if (!container) {\n console.error("Container element not found");\n window.updateReaderStatus?.("error");\n throw new Error("Container element not found");\n }\n let initialPosition;\n if (initialPositionJson) {\n initialPosition = _readium_shared__WEBPACK_IMPORTED_MODULE_1__.Locator.deserialize(JSON.parse(initialPositionJson));\n }\n let preferencesJsonString = !preferencesJson || preferencesJson === "null" ? "{}" : preferencesJson;\n try {\n this._publication = _ReadiumReader._publications.get(pubId);\n if (!this._publication) {\n const { manifest, fetcher } = await (0,_helpers__WEBPACK_IMPORTED_MODULE_2__.fetchManifest)(publicationURL);\n this._publication = new _extensions_ReadiumPublication__WEBPACK_IMPORTED_MODULE_4__.ReadiumPublication({ manifest, fetcher });\n _ReadiumReader._publications.set(pubId, this._publication);\n }\n let conformsToArray = this._publication.manifest.metadata.conformsTo;\n if (this._publication.conformsToAudiobook) {\n }\n else {\n if (this._publication.conformsToEpub) {\n await (0,_Epub_epubNavigator__WEBPACK_IMPORTED_MODULE_5__.initializeEpubNavigatorAndPeripherals)(container, this._publication, initialPosition, preferencesJsonString, (nav) => {\n this._nav = nav;\n window.updateReaderStatus?.(_enums__WEBPACK_IMPORTED_MODULE_3__.ReadiumReaderStatus.ready);\n });\n }\n else {\n await (0,_WebPub_webpubNavigator__WEBPACK_IMPORTED_MODULE_6__.initializeWebPubNavigatorAndPeripherals)(container, this._publication, initialPosition, preferencesJsonString, (nav) => {\n this._nav = nav;\n window.updateReaderStatus?.(_enums__WEBPACK_IMPORTED_MODULE_3__.ReadiumReaderStatus.ready);\n });\n }\n }\n }\n catch (error) {\n this.closePublication(error);\n throw new Error("Error opening publication: " + error);\n }\n }\n setEPUBPreferences(newPreferencesString) {\n if (!this._nav) {\n throw new Error("Navigator is not initialized");\n }\n (0,_helpers__WEBPACK_IMPORTED_MODULE_2__.setPreferencesFromString)(newPreferencesString, this._nav);\n }\n closePublication(error) {\n this._publication = undefined;\n this._nav?.destroy();\n const container = document.getElementById("container");\n if (container) {\n container.innerHTML = "";\n }\n if (error) {\n window.updateReaderStatus?.(_enums__WEBPACK_IMPORTED_MODULE_3__.ReadiumReaderStatus.error);\n }\n else {\n window.updateReaderStatus?.(_enums__WEBPACK_IMPORTED_MODULE_3__.ReadiumReaderStatus.closed);\n }\n delete window.updateTextLocator;\n delete window.updateReaderStatus;\n }\n async getResource(linkString, asBytes = false) {\n let linkJson = JSON.parse(linkString.toString());\n let link = _readium_shared__WEBPACK_IMPORTED_MODULE_1__.Link.deserialize(linkJson);\n if (!link) {\n console.error("Invalid link string");\n }\n let resourceLink = this._publication?.get(link);\n if (!resourceLink) {\n console.error("Resource not found", link);\n }\n let resourceString;\n if (asBytes) {\n let resourceBytes = await resourceLink?.read();\n resourceString = JSON.stringify(Array.from(resourceBytes));\n }\n else {\n resourceString = await resourceLink?.readAsString();\n }\n return resourceString;\n }\n}\nglobalThis.ReadiumReader = _ReadiumReader;\n\n\n//# sourceURL=webpack:///./web/_scripts/ReadiumReader.ts?')},"./web/_scripts/WebPub/webPubPrefences.ts":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval('__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ defaults: () => (/* binding */ defaults),\n/* harmony export */ initializeWebPubPreferencesFromString: () => (/* binding */ initializeWebPubPreferencesFromString)\n/* harmony export */ });\n/* harmony import */ var _readium_navigator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @readium/navigator */ "./node_modules/@readium/navigator/dist/index.js");\n/* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../helpers */ "./web/_scripts/helpers.ts");\n\n\nfunction initializeWebPubPreferencesFromString(preferencesString) {\n const prefs = JSON.parse(preferencesString);\n (0,_helpers__WEBPACK_IMPORTED_MODULE_1__.convertVerticalScroll)(prefs);\n if (prefs.textAlign != null) {\n prefs.textAlign = (0,_helpers__WEBPACK_IMPORTED_MODULE_1__.textAlignFromJson)(prefs.textAlign);\n }\n let preferences = {\n fontFamily: prefs.fontFamily ?? null,\n fontWeight: prefs.fontWeight ?? null,\n hyphens: prefs.hyphens ?? null,\n iOSPatch: prefs.iOSPatch ?? null,\n iPadOSPatch: prefs.iPadOSPatch ?? null,\n letterSpacing: prefs.letterSpacing ?? null,\n ligatures: prefs.ligatures ?? null,\n lineHeight: prefs.lineHeight ?? null,\n noRuby: prefs.noRuby ?? null,\n paragraphIndent: prefs.paragraphIndent ?? null,\n paragraphSpacing: prefs.paragraphSpacing ?? null,\n textAlign: prefs.textAlign ?? null,\n textNormalization: prefs.textNormalization ?? null,\n wordSpacing: prefs.wordSpacing ?? null,\n zoom: prefs.zoom ?? null,\n };\n preferences = (0,_helpers__WEBPACK_IMPORTED_MODULE_1__.normalizeTypes)(preferences);\n return preferences;\n}\nconst defaults = {\n fontFamily: "Arial",\n fontWeight: 400,\n hyphens: true,\n letterSpacing: 0,\n ligatures: true,\n lineHeight: 1.5,\n noRuby: false,\n paragraphIndent: 0,\n paragraphSpacing: 0,\n textAlign: _readium_navigator__WEBPACK_IMPORTED_MODULE_0__.TextAlignment.justify,\n textNormalization: true,\n wordSpacing: 0,\n zoom: 1,\n};\n\n\n//# sourceURL=webpack:///./web/_scripts/WebPub/webPubPrefences.ts?')},"./web/_scripts/WebPub/webpubNavigator.ts":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval('__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ initializeWebPubNavigatorAndPeripherals: () => (/* binding */ initializeWebPubNavigatorAndPeripherals)\n/* harmony export */ });\n/* harmony import */ var _readium_navigator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @readium/navigator */ "./node_modules/@readium/navigator/dist/index.js");\n/* harmony import */ var _peripherals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../peripherals */ "./web/_scripts/peripherals.ts");\n/* harmony import */ var _webPubPrefences__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webPubPrefences */ "./web/_scripts/WebPub/webPubPrefences.ts");\n/* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../helpers */ "./web/_scripts/helpers.ts");\n\n\n\n\nasync function initializeWebPubNavigatorAndPeripherals(container, publication, initialPosition = undefined, preferencesJsonString, setNav) {\n console.log("Initializing WebPubNavigator");\n let preferences = (0,_webPubPrefences__WEBPACK_IMPORTED_MODULE_2__.initializeWebPubPreferencesFromString)(preferencesJsonString);\n const configuration = {\n preferences,\n defaults: _webPubPrefences__WEBPACK_IMPORTED_MODULE_2__.defaults,\n };\n const p = new _peripherals__WEBPACK_IMPORTED_MODULE_1__["default"]({\n moveTo: (direction) => {\n if (direction === "right") {\n nav.goRight(true, () => { });\n }\n else if (direction === "left") {\n nav.goLeft(true, () => { });\n }\n else if (direction === "up") {\n const iframes = document.querySelectorAll(".readium-navigator-iframe");\n iframes.forEach((iframe) => {\n if (iframe instanceof HTMLIFrameElement) {\n if (iframe.style.visibility !== "hidden") {\n iframe.contentWindow?.scrollBy(0, -100);\n }\n }\n });\n }\n else if (direction === "down") {\n const iframes = document.querySelectorAll(".readium-navigator-iframe");\n iframes.forEach((iframe) => {\n if (iframe instanceof HTMLIFrameElement) {\n if (iframe.style.visibility !== "hidden") {\n iframe.contentWindow?.scrollBy(0, 100);\n }\n }\n });\n }\n },\n menu: (_show) => {\n },\n goProgression: (_shiftKey) => {\n nav.goForward(true, () => { });\n },\n });\n const listeners = {\n scroll: function (_amount) { },\n frameLoaded: function (_wnd) {\n nav._cframes.forEach((frameManager) => {\n if (frameManager) {\n p.observe(frameManager.window);\n }\n });\n p.observe(window);\n },\n positionChanged: (_locator) => {\n window.focus();\n window.updateTextLocator?.(JSON.stringify(_locator));\n },\n tap: function (_e) {\n console.log("tap event received in WebPubNavigator");\n return false;\n },\n click: function (_e) {\n console.log("click event received in WebPubNavigator");\n return false;\n },\n zoom: function (_scale) { },\n customEvent: function (_key, _data) { },\n handleLocator: function (locator) {\n const href = locator.href;\n if (href.startsWith("http://") ||\n href.startsWith("https://") ||\n href.startsWith("mailto:") ||\n href.startsWith("tel:")) {\n if (confirm(`Open "${href}" ?`))\n window.open(href, "_blank");\n }\n else {\n console.warn("Unhandled locator", locator);\n }\n return false;\n },\n textSelected: function (_selection) {\n (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.highlightSelection)(nav, publication, _selection);\n },\n };\n const nav = new _readium_navigator__WEBPACK_IMPORTED_MODULE_0__.WebPubNavigator(container, publication, listeners, initialPosition, configuration);\n try {\n await nav.load();\n }\n catch (error) {\n throw error;\n }\n setNav(nav);\n p.observe(window);\n}\n\n\n//# sourceURL=webpack:///./web/_scripts/WebPub/webpubNavigator.ts?')},"./web/_scripts/enums.ts":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval('__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ReadiumReaderStatus: () => (/* binding */ ReadiumReaderStatus)\n/* harmony export */ });\nvar ReadiumReaderStatus;\n(function (ReadiumReaderStatus) {\n ReadiumReaderStatus["loading"] = "loading";\n ReadiumReaderStatus["ready"] = "ready";\n ReadiumReaderStatus["closed"] = "closed";\n ReadiumReaderStatus["reachedEndOfPublication"] = "reachedEndOfPublication";\n ReadiumReaderStatus["error"] = "error";\n})(ReadiumReaderStatus || (ReadiumReaderStatus = {}));\n\n\n//# sourceURL=webpack:///./web/_scripts/enums.ts?')},"./web/_scripts/extensions/ReadiumPublication.ts":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval('__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ReadiumPublication: () => (/* binding */ ReadiumPublication)\n/* harmony export */ });\n/* harmony import */ var _readium_shared__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @readium/shared */ "./node_modules/@readium/shared/dist/index.js");\n\nclass ReadiumPublication extends _readium_shared__WEBPACK_IMPORTED_MODULE_0__.Publication {\n conformsToArray = this.manifest.metadata.conformsTo;\n conformsToEpub = this.conformsToArray?.some((profile) => {\n return profile == _readium_shared__WEBPACK_IMPORTED_MODULE_0__.Profile.EPUB;\n }) ?? false;\n conformsToAudiobook = this.conformsToArray?.some((profile) => {\n return profile == _readium_shared__WEBPACK_IMPORTED_MODULE_0__.Profile.AUDIOBOOK;\n }) ?? false;\n conformsToDivina = this.conformsToArray?.some((profile) => {\n return profile == _readium_shared__WEBPACK_IMPORTED_MODULE_0__.Profile.DIVINA;\n }) ?? false;\n conformsToPDF = this.conformsToArray?.some((profile) => {\n return profile == _readium_shared__WEBPACK_IMPORTED_MODULE_0__.Profile.PDF;\n }) ?? false;\n}\n\n\n//# sourceURL=webpack:///./web/_scripts/extensions/ReadiumPublication.ts?')},"./web/_scripts/helpers.ts":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval('__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ convertVerticalScroll: () => (/* binding */ convertVerticalScroll),\n/* harmony export */ fetchManifest: () => (/* binding */ fetchManifest),\n/* harmony export */ highlightSelection: () => (/* binding */ highlightSelection),\n/* harmony export */ mediaTypes: () => (/* binding */ mediaTypes),\n/* harmony export */ normalizeTypes: () => (/* binding */ normalizeTypes),\n/* harmony export */ setPreferencesFromString: () => (/* binding */ setPreferencesFromString),\n/* harmony export */ textAlignFromJson: () => (/* binding */ textAlignFromJson)\n/* harmony export */ });\n/* harmony import */ var _readium_navigator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @readium/navigator */ "./node_modules/@readium/navigator/dist/index.js");\n/* harmony import */ var _readium_navigator_html_injectables__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @readium/navigator-html-injectables */ "./node_modules/@readium/navigator-html-injectables/dist/index.js");\n/* harmony import */ var _readium_shared__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @readium/shared */ "./node_modules/@readium/shared/dist/index.js");\n\n\n\nasync function fetchManifest(publicationURL) {\n const manifestLink = new _readium_shared__WEBPACK_IMPORTED_MODULE_2__.Link({ href: "manifest.json" });\n const fetcher = new _readium_shared__WEBPACK_IMPORTED_MODULE_2__.HttpFetcher(undefined, publicationURL);\n const resource = fetcher.get(manifestLink);\n const resourceLink = await resource.link();\n const selfLink = resourceLink.toURL(publicationURL);\n const manifest = await resource.readAsJSON().then((response) => {\n const manifest = _readium_shared__WEBPACK_IMPORTED_MODULE_2__.Manifest.deserialize(response);\n manifest.setSelfLink(selfLink);\n return manifest;\n });\n return { manifest, fetcher, selfLink };\n}\nfunction mediaTypes(publication) {\n let selfLinks = publication.manifest.linksWithRel("self");\n let mediaTypesString = selfLinks\n .map((link) => link.type)\n .filter((type) => typeof type === "string");\n let mediaTypes = mediaTypesString.map((type) => _readium_shared__WEBPACK_IMPORTED_MODULE_2__.MediaType.parse({ mediaType: type }));\n return mediaTypes;\n}\nfunction convertVerticalScroll(prefs) {\n if ("verticalScroll" in prefs) {\n prefs.scroll = prefs.verticalScroll;\n delete prefs.verticalScroll;\n }\n}\nfunction textAlignFromJson(textAlignString) {\n switch (textAlignString) {\n case "left":\n return _readium_navigator__WEBPACK_IMPORTED_MODULE_0__.TextAlignment.left;\n case "right":\n return _readium_navigator__WEBPACK_IMPORTED_MODULE_0__.TextAlignment.right;\n case "start":\n return _readium_navigator__WEBPACK_IMPORTED_MODULE_0__.TextAlignment.start;\n case "justify":\n return _readium_navigator__WEBPACK_IMPORTED_MODULE_0__.TextAlignment.justify;\n default:\n return _readium_navigator__WEBPACK_IMPORTED_MODULE_0__.TextAlignment.left;\n }\n}\nfunction normalizeTypes(obj) {\n if (Array.isArray(obj)) {\n return obj.map(normalizeTypes);\n }\n else if (obj !== null && typeof obj === "object") {\n for (const key in obj) {\n if (!obj.hasOwnProperty(key))\n continue;\n const value = obj[key];\n if (typeof value === "string") {\n if (value === "true") {\n obj[key] = true;\n }\n else if (value === "false") {\n obj[key] = false;\n }\n else if (/^-?\\d+(\\.\\d+)?$/.test(value)) {\n obj[key] = value.includes(".")\n ? parseFloat(value)\n : parseInt(value, 10);\n }\n }\n else if (typeof value === "object" && value !== null) {\n obj[key] = normalizeTypes(value);\n }\n else if (value === "null" || value == null) {\n delete obj[key];\n }\n }\n }\n return obj;\n}\nfunction setPreferencesFromString(newPreferencesString, nav) {\n let newPreferences = JSON.parse(newPreferencesString);\n convertVerticalScroll(newPreferences);\n if (newPreferences.textAlign != null) {\n newPreferences.textAlign = textAlignFromJson(newPreferences.textAlign);\n }\n if (newPreferences.pageMargins != null) {\n newPreferences.pageGutter = newPreferences.pageMargins;\n delete newPreferences.pageMargins;\n }\n newPreferences = normalizeTypes(newPreferences);\n nav.submitPreferences(newPreferences);\n}\nfunction highlightSelection(nav, publication, selection) {\n const currentLocator = nav.currentLocator;\n const locator = new _readium_shared__WEBPACK_IMPORTED_MODULE_2__.Locator({\n href: currentLocator.href,\n type: currentLocator.type,\n locations: currentLocator.locations,\n text: {\n highlight: selection.text,\n },\n });\n const decorationId = [selection.text, selection.x, selection.y].join("_");\n const decoration = {\n id: decorationId,\n locator,\n style: {\n tint: "#ff9fff55",\n layout: _readium_navigator_html_injectables__WEBPACK_IMPORTED_MODULE_1__.Layout.Bounds,\n width: _readium_navigator_html_injectables__WEBPACK_IMPORTED_MODULE_1__.Width.Wrap,\n },\n };\n const frameComms = nav._cframes[0]?.msg;\n if (frameComms) {\n frameComms.send("decorate", {\n group: "selection_" + publication.metadata.identifier,\n action: "add",\n decoration,\n });\n }\n else {\n throw new Error("Could not find frame comms to send decoration");\n }\n}\n\n\n//# sourceURL=webpack:///./web/_scripts/helpers.ts?')},"./web/_scripts/peripherals.ts":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ Peripherals)\n/* harmony export */ });\nclass Peripherals {\n observers = ['keyup', 'keydown'];\n targets = [];\n callbacks;\n constructor(callbacks) {\n this.observers.forEach((method) => {\n this['on' + method] = this['on' + method].bind(this);\n });\n this.callbacks = callbacks;\n }\n destroy() {\n this.targets.forEach((t) => this.unobserve(t));\n }\n unobserve(item) {\n if (!item)\n return;\n this.observers.forEach((EventName) => {\n item.removeEventListener(EventName, this['on' + EventName], false);\n });\n this.targets = this.targets.filter((t) => t !== item);\n }\n observe(item) {\n if (!item)\n return;\n if (this.targets.includes(item))\n return;\n this.observers.forEach((EventName) => {\n item.addEventListener(EventName, this['on' + EventName], false);\n });\n this.targets.push(item);\n }\n onkeyup(e) {\n if (e.code === 'Space')\n this.callbacks.goProgression(e.shiftKey);\n if (e.code === 'Enter')\n this.callbacks.menu(true);\n }\n onkeydown(e) {\n switch (e.code) {\n case 'ArrowRight':\n this.callbacks.moveTo('right');\n e.preventDefault();\n break;\n case 'ArrowLeft':\n this.callbacks.moveTo('left');\n e.preventDefault();\n break;\n case 'ArrowUp':\n this.callbacks.moveTo('up');\n e.preventDefault();\n break;\n case 'ArrowDown':\n this.callbacks.moveTo('down');\n e.preventDefault();\n break;\n }\n }\n}\n\n\n//# sourceURL=webpack:///./web/_scripts/peripherals.ts?")},"./node_modules/@readium/navigator-html-injectables/dist/index.js":(__unused_webpack___webpack_module__,__webpack_exports__,__webpack_require__)=>{eval('__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ COMMS_VERSION: () => (/* binding */ B),\n/* harmony export */ Comms: () => (/* binding */ it),\n/* harmony export */ Decorator: () => (/* binding */ re),\n/* harmony export */ FXLModules: () => (/* binding */ Rt),\n/* harmony export */ Layout: () => (/* binding */ wt),\n/* harmony export */ Loader: () => (/* binding */ Wt),\n/* harmony export */ Module: () => (/* binding */ X),\n/* harmony export */ ModuleLibrary: () => (/* binding */ He),\n/* harmony export */ Peripherals: () => (/* binding */ le),\n/* harmony export */ ReflowableModules: () => (/* binding */ zt),\n/* harmony export */ WebPubModules: () => (/* binding */ Dt),\n/* harmony export */ Width: () => (/* binding */ Tt),\n/* harmony export */ mid: () => (/* binding */ tt)\n/* harmony export */ });\nconst et = Math.pow(2, 32), xe = () => Math.round(Math.random() * et).toString(36), tt = () => `${Math.round(performance.now())}-${xe()}-${xe()}`, B = 1;\nclass it {\n constructor(e) {\n this.destination = null, this.registrar = /* @__PURE__ */ new Map(), this.origin = "", this.channelId = "", this.receiver = this.receive.bind(this), this.preLog = [], this.wnd = e, e.addEventListener("message", this.receiver);\n }\n receive(e) {\n if (e.source === null) throw Error("Event source is null");\n if (typeof e.data != "object") return;\n const t = e.data;\n if (!(!("_readium" in t) || !t._readium || t._readium <= 0)) {\n if (t.key === "_ping") {\n if (!this.destination) {\n if (this.destination = e.source, this.origin = e.origin, this.channelId = t._channel, t._readium !== B) {\n t._readium > B ? this.send("error", `received comms version ${t._readium} higher than ${B}`) : this.send("error", `received comms version ${t._readium} lower than ${B}`), this.destination = null, this.origin = "", this.channelId = "";\n return;\n }\n this.send("_pong", void 0), this.preLog.forEach((i) => this.send("log", i)), this.preLog = [];\n }\n return;\n } else if (this.channelId) {\n if (t._channel !== this.channelId || e.origin !== this.origin) return;\n } else\n return;\n this.handle(t);\n }\n }\n handle(e) {\n const t = this.registrar.get(e.key);\n if (!t || t.length === 0) {\n e.strict && this.send("_unhandled", e);\n return;\n }\n t.forEach((i) => i.cb(e.data, (s) => {\n this.send("_ack", s, e.id);\n }));\n }\n register(e, t, i) {\n Array.isArray(e) || (e = [e]), e.forEach((s) => {\n const n = this.registrar.get(s);\n if (n && n.length >= 0) {\n if (n.find((l) => l.module === t)) throw new Error(`Trying to register another callback for combination of event ${s} and module ${t}`);\n n.push({\n cb: i,\n module: t\n }), this.registrar.set(s, n);\n } else\n this.registrar.set(s, [{\n cb: i,\n module: t\n }]);\n });\n }\n unregister(e, t) {\n Array.isArray(e) || (e = [e]), e.forEach((i) => {\n const s = this.registrar.get(i);\n !s || s.length === 0 || s.splice(s.findIndex((n) => n.module === t), 1);\n });\n }\n unregisterAll(e) {\n this.registrar.forEach((t, i) => this.registrar.set(i, t.filter((s) => s.module !== e)));\n }\n log(...e) {\n this.destination ? this.send("log", e) : this.preLog.push(e);\n }\n get ready() {\n return !!this.destination;\n }\n destroy() {\n this.destination = null, this.channelId = "", this.preLog = [], this.registrar.clear(), this.wnd.removeEventListener("message", this.receiver);\n }\n send(e, t, i = void 0, s = []) {\n if (!this.destination) throw Error("Attempted to send comms message before destination has been initialized");\n const n = {\n _readium: B,\n _channel: this.channelId,\n id: i ?? tt(),\n // scrict,\n key: e,\n data: t\n };\n try {\n this.destination.postMessage(n, {\n targetOrigin: this.origin,\n transfer: s\n });\n } catch (o) {\n if (s.length > 0) throw o;\n this.destination.postMessage(n, this.origin, s);\n }\n }\n}\nconst N = class F {\n constructor(e) {\n if (typeof e == "string") {\n if (!F.VALID_MODES.has(e.toLowerCase()))\n return;\n this.value = e.toLowerCase();\n } else {\n const t = e.filter(\n (i) => F.VALID_MODES.has(i.toLowerCase())\n );\n if (t.length === 0)\n return;\n this.value = Array.from(new Set(t));\n }\n }\n /**\n * Parses a [PrimaryAccessMode] from its RWPM JSON representation.\n */\n static deserialize(e) {\n if (!e) return;\n if (typeof e == "string")\n return new F(e);\n if (!Array.isArray(e)) return;\n const t = e.filter((i) => i ? F.VALID_MODES.has(i.toLowerCase()) : !1);\n if (t.length !== 0)\n return new F(t);\n }\n /**\n * Serializes a [PrimaryAccessMode] to its RWPM JSON representation.\n */\n serialize() {\n return this.value;\n }\n};\nN.VALID_MODES = /* @__PURE__ */ new Set(["auditory", "tactile", "textual", "visual"]), N.AUDITORY = new N("auditory"), N.TACTILE = new N("tactile"), N.TEXTUAL = new N("textual"), N.VISUAL = new N("visual");\nclass de {\n /**\n * Creates a [Encryption].\n */\n constructor(e) {\n this.algorithm = e.algorithm, this.compression = e.compression, this.originalLength = e.originalLength, this.profile = e.profile, this.scheme = e.scheme;\n }\n /**\n * Parses a [Encryption] from its RWPM JSON representation.\n */\n static deserialize(e) {\n if (e && e.algorithm)\n return new de({\n algorithm: e.algorithm,\n compression: e.compression,\n originalLength: e.originalLength,\n profile: e.profile,\n scheme: e.scheme\n });\n }\n /**\n * Serializes a [Encryption] to its RWPM JSON representation.\n */\n serialize() {\n const e = { algorithm: this.algorithm };\n return this.compression !== void 0 && (e.compression = this.compression), this.originalLength !== void 0 && (e.originalLength = this.originalLength), this.profile !== void 0 && (e.profile = this.profile), this.scheme !== void 0 && (e.scheme = this.scheme), e;\n }\n}\nclass C {\n constructor(e) {\n this.otherProperties = e;\n }\n get page() {\n return this.otherProperties.page;\n }\n /**\n * Creates a [Properties] from its RWPM JSON representation.\n */\n static deserialize(e) {\n if (e)\n return new C(e);\n }\n /**\n * Serializes a [Properties] to its RWPM JSON representation.\n */\n serialize() {\n return this.otherProperties;\n }\n /**\n * Makes a copy of this [Properties] after merging in the given additional other [properties].\n */\n add(e) {\n const t = Object.assign({}, this.otherProperties);\n for (const i in e)\n t[i] = e[i];\n return new C(t);\n }\n}\nObject.defineProperty(C.prototype, "encryption", {\n get: function() {\n return de.deserialize(this.otherProperties.encrypted);\n }\n});\nfunction st(r) {\n return r && Array.isArray(r) ? r : void 0;\n}\nfunction $e(r) {\n return r && typeof r == "string" ? [r] : st(r);\n}\nfunction Te(r) {\n return typeof r == "string" ? new Date(r) : void 0;\n}\nfunction G(r) {\n return isNaN(r) ? void 0 : r;\n}\nfunction S(r) {\n return G(r) !== void 0 && Math.sign(r) >= 0 ? r : void 0;\n}\nfunction rt(r) {\n const e = new Array();\n return r.forEach((t) => e.push(t)), e;\n}\nclass a {\n /** Creates a MediaType object. */\n constructor(e) {\n let t, i, s = e.mediaType.replace(/\\s/g, "").split(";");\n const n = s[0].split("/");\n if (n.length === 2) {\n if (t = n[0].toLowerCase().trim(), i = n[1].toLowerCase().trim(), t.length === 0 || i.length === 0)\n throw new Error("Invalid media type");\n } else\n throw new Error("Invalid media type");\n const o = {};\n for (let p = 1; p < s.length; p++) {\n const y = s[p].split("=");\n if (y.length === 2) {\n const d = y[0].toLocaleLowerCase(), f = d === "charset" ? y[1].toUpperCase() : y[1];\n o[d] = f;\n }\n }\n const l = {}, u = Object.keys(o);\n u.sort((p, y) => p.localeCompare(y)), u.forEach((p) => l[p] = o[p]);\n let h = "";\n for (const p in l) {\n const y = l[p];\n h += `;${p}=${y}`;\n }\n const c = `${t}/${i}${h}`, m = l.encoding;\n this.string = c, this.type = t, this.subtype = i, this.parameters = l, this.encoding = m, this.name = e.name, this.fileExtension = e.fileExtension;\n }\n static parse(e) {\n return new a(e);\n }\n /** Structured syntax suffix, e.g. `+zip` in `application/epub+zip`.\n * Gives a hint on the underlying structure of this media type.\n * See. https://tools.ietf.org/html/rfc6838#section-4.2.8\n */\n get structuredSyntaxSuffix() {\n const e = this.subtype.split("+");\n return e.length > 1 ? `+${e[e.length - 1]}` : void 0;\n }\n /** Parameter values might or might not be case-sensitive, depending on the semantics of\n * the parameter name.\n * https://tools.ietf.org/html/rfc2616#section-3.7\n *\n * The character set names may be up to 40 characters taken from the printable characters\n * of US-ASCII. However, no distinction is made between use of upper and lower case\n * letters.\n * https://www.iana.org/assignments/character-sets/character-sets.xhtml\n */\n get charset() {\n return this.parameters.charset;\n }\n /** Returns whether the given `other` media type is included in this media type.\n * For example, `text/html` contains `text/html;charset=utf-8`.\n * - `other` must match the parameters in the `parameters` property, but extra parameters\n * are ignored.\n * - Order of parameters is ignored.\n * - Wildcards are supported, meaning that `image/*` contains `image/png`\n */\n contains(e) {\n const t = typeof e == "string" ? a.parse({ mediaType: e }) : e;\n if (!((this.type === "*" || this.type === t.type) && (this.subtype === "*" || this.subtype === t.subtype)))\n return !1;\n const i = new Set(\n Object.entries(this.parameters).map(([n, o]) => `${n}=${o}`)\n ), s = new Set(\n Object.entries(t.parameters).map(([n, o]) => `${n}=${o}`)\n );\n for (const n of Array.from(i.values()))\n if (!s.has(n))\n return !1;\n return !0;\n }\n /** Returns whether this media type and `other` are the same, ignoring parameters that\n * are not in both media types.\n * For example, `text/html` matches `text/html;charset=utf-8`, but `text/html;charset=ascii`\n * doesn\'t. This is basically like `contains`, but working in both direction.\n */\n matches(e) {\n const t = typeof e == "string" ? a.parse({ mediaType: e }) : e;\n return this.contains(t) || t.contains(this);\n }\n /**\n * Returns whether this media type matches any of the [others] media types.\n */\n matchesAny(...e) {\n for (const t of e)\n if (this.matches(t))\n return !0;\n return !1;\n }\n /** Checks the MediaType equals another one (comparing their string) */\n equals(e) {\n return this.string === e.string;\n }\n /** Returns whether this media type is structured as a ZIP archive. */\n get isZIP() {\n return this.matchesAny(\n a.ZIP,\n a.LCP_PROTECTED_AUDIOBOOK,\n a.LCP_PROTECTED_PDF\n ) || this.structuredSyntaxSuffix === "+zip";\n }\n /** Returns whether this media type is structured as a JSON file. */\n get isJSON() {\n return this.matchesAny(a.JSON) || this.structuredSyntaxSuffix === "+json";\n }\n /** Returns whether this media type is of an OPDS feed. */\n get isOPDS() {\n return this.matchesAny(\n a.OPDS1,\n a.OPDS1_ENTRY,\n a.OPDS2,\n a.OPDS2_PUBLICATION,\n a.OPDS_AUTHENTICATION\n ) || this.structuredSyntaxSuffix === "+json";\n }\n /** Returns whether this media type is of an HTML document. */\n get isHTML() {\n return this.matchesAny(a.HTML, a.XHTML);\n }\n /** Returns whether this media type is of a bitmap image, so excluding vectorial formats. */\n get isBitmap() {\n return this.matchesAny(\n a.BMP,\n a.GIF,\n a.JPEG,\n a.PNG,\n a.TIFF,\n a.WEBP\n );\n }\n /** Returns whether this media type is of an audio clip. */\n get isAudio() {\n return this.type === "audio";\n }\n /** Returns whether this media type is of a video clip. */\n get isVideo() {\n return this.type === "video";\n }\n /** Returns whether this media type is of a Readium Web Publication Manifest. */\n get isRWPM() {\n return this.matchesAny(\n a.READIUM_AUDIOBOOK_MANIFEST,\n a.DIVINA_MANIFEST,\n a.READIUM_WEBPUB_MANIFEST\n );\n }\n /** Returns whether this media type is of a publication file. */\n get isPublication() {\n return this.matchesAny(\n a.READIUM_AUDIOBOOK,\n a.READIUM_AUDIOBOOK_MANIFEST,\n a.CBZ,\n a.DIVINA,\n a.DIVINA_MANIFEST,\n a.EPUB,\n a.LCP_PROTECTED_AUDIOBOOK,\n a.LCP_PROTECTED_PDF,\n a.LPF,\n a.PDF,\n a.W3C_WPUB_MANIFEST,\n a.READIUM_WEBPUB,\n a.READIUM_WEBPUB_MANIFEST,\n a.ZAB\n );\n }\n // Known Media Types\n static get AAC() {\n return a.parse({ mediaType: "audio/aac", fileExtension: "aac" });\n }\n static get ACSM() {\n return a.parse({\n mediaType: "application/vnd.adobe.adept+xml",\n name: "Adobe Content Server Message",\n fileExtension: "acsm"\n });\n }\n static get AIFF() {\n return a.parse({ mediaType: "audio/aiff", fileExtension: "aiff" });\n }\n static get AVI() {\n return a.parse({\n mediaType: "video/x-msvideo",\n fileExtension: "avi"\n });\n }\n static get BINARY() {\n return a.parse({ mediaType: "application/octet-stream" });\n }\n static get BMP() {\n return a.parse({ mediaType: "image/bmp", fileExtension: "bmp" });\n }\n static get CBZ() {\n return a.parse({\n mediaType: "application/vnd.comicbook+zip",\n name: "Comic Book Archive",\n fileExtension: "cbz"\n });\n }\n static get CSS() {\n return a.parse({ mediaType: "text/css", fileExtension: "css" });\n }\n static get DIVINA() {\n return a.parse({\n mediaType: "application/divina+zip",\n name: "Digital Visual Narratives",\n fileExtension: "divina"\n });\n }\n static get DIVINA_MANIFEST() {\n return a.parse({\n mediaType: "application/divina+json",\n name: "Digital Visual Narratives",\n fileExtension: "json"\n });\n }\n static get EPUB() {\n return a.parse({\n mediaType: "application/epub+zip",\n name: "EPUB",\n fileExtension: "epub"\n });\n }\n static get GIF() {\n return a.parse({ mediaType: "image/gif", fileExtension: "gif" });\n }\n static get GZ() {\n return a.parse({\n mediaType: "application/gzip",\n fileExtension: "gz"\n });\n }\n static get HTML() {\n return a.parse({ mediaType: "text/html", fileExtension: "html" });\n }\n static get JAVASCRIPT() {\n return a.parse({\n mediaType: "text/javascript",\n fileExtension: "js"\n });\n }\n static get JPEG() {\n return a.parse({ mediaType: "image/jpeg", fileExtension: "jpeg" });\n }\n static get JSON() {\n return a.parse({ mediaType: "application/json" });\n }\n static get LCP_LICENSE_DOCUMENT() {\n return a.parse({\n mediaType: "application/vnd.readium.lcp.license.v1.0+json",\n name: "LCP License",\n fileExtension: "lcpl"\n });\n }\n static get LCP_PROTECTED_AUDIOBOOK() {\n return a.parse({\n mediaType: "application/audiobook+lcp",\n name: "LCP Protected Audiobook",\n fileExtension: "lcpa"\n });\n }\n static get LCP_PROTECTED_PDF() {\n return a.parse({\n mediaType: "application/pdf+lcp",\n name: "LCP Protected PDF",\n fileExtension: "lcpdf"\n });\n }\n static get LCP_STATUS_DOCUMENT() {\n return a.parse({\n mediaType: "application/vnd.readium.license.status.v1.0+json"\n });\n }\n static get LPF() {\n return a.parse({\n mediaType: "application/lpf+zip",\n fileExtension: "lpf"\n });\n }\n static get MP3() {\n return a.parse({ mediaType: "audio/mpeg", fileExtension: "mp3" });\n }\n static get MPEG() {\n return a.parse({ mediaType: "video/mpeg", fileExtension: "mpeg" });\n }\n static get NCX() {\n return a.parse({\n mediaType: "application/x-dtbncx+xml",\n fileExtension: "ncx"\n });\n }\n static get OGG() {\n return a.parse({ mediaType: "audio/ogg", fileExtension: "oga" });\n }\n static get OGV() {\n return a.parse({ mediaType: "video/ogg", fileExtension: "ogv" });\n }\n static get OPDS1() {\n return a.parse({\n mediaType: "application/atom+xml;profile=opds-catalog"\n });\n }\n static get OPDS1_ENTRY() {\n return a.parse({\n mediaType: "application/atom+xml;type=entry;profile=opds-catalog"\n });\n }\n static get OPDS2() {\n return a.parse({ mediaType: "application/opds+json" });\n }\n static get OPDS2_PUBLICATION() {\n return a.parse({ mediaType: "application/opds-publication+json" });\n }\n static get OPDS_AUTHENTICATION() {\n return a.parse({\n mediaType: "application/opds-authentication+json"\n });\n }\n static get OPUS() {\n return a.parse({ mediaType: "audio/opus", fileExtension: "opus" });\n }\n static get OTF() {\n return a.parse({ mediaType: "font/otf", fileExtension: "otf" });\n }\n static get PDF() {\n return a.parse({\n mediaType: "application/pdf",\n name: "PDF",\n fileExtension: "pdf"\n });\n }\n static get PNG() {\n return a.parse({ mediaType: "image/png", fileExtension: "png" });\n }\n static get READIUM_AUDIOBOOK() {\n return a.parse({\n mediaType: "application/audiobook+zip",\n name: "Readium Audiobook",\n fileExtension: "audiobook"\n });\n }\n static get READIUM_AUDIOBOOK_MANIFEST() {\n return a.parse({\n mediaType: "application/audiobook+json",\n name: "Readium Audiobook",\n fileExtension: "json"\n });\n }\n static get READIUM_CONTENT_DOCUMENT() {\n return a.parse({\n mediaType: "application/vnd.readium.content+json",\n name: "Readium Content Document",\n fileExtension: "json"\n });\n }\n static get READIUM_GUIDED_NAVIGATION_DOCUMENT() {\n return a.parse({\n mediaType: "application/guided-navigation+json",\n name: "Readium Guided Navigation Document",\n fileExtension: "json"\n });\n }\n static get READIUM_POSITION_LIST() {\n return a.parse({\n mediaType: "application/vnd.readium.position-list+json",\n name: "Readium Position List",\n fileExtension: "json"\n });\n }\n static get READIUM_WEBPUB() {\n return a.parse({\n mediaType: "application/webpub+zip",\n name: "Readium Web Publication",\n fileExtension: "webpub"\n });\n }\n static get READIUM_WEBPUB_MANIFEST() {\n return a.parse({\n mediaType: "application/webpub+json",\n name: "Readium Web Publication",\n fileExtension: "json"\n });\n }\n static get SMIL() {\n return a.parse({\n mediaType: "application/smil+xml",\n fileExtension: "smil"\n });\n }\n static get SVG() {\n return a.parse({\n mediaType: "image/svg+xml",\n fileExtension: "svg"\n });\n }\n static get TEXT() {\n return a.parse({ mediaType: "text/plain", fileExtension: "txt" });\n }\n static get TIFF() {\n return a.parse({ mediaType: "image/tiff", fileExtension: "tiff" });\n }\n static get TTF() {\n return a.parse({ mediaType: "font/ttf", fileExtension: "ttf" });\n }\n static get W3C_WPUB_MANIFEST() {\n return a.parse({\n mediaType: "application/x.readium.w3c.wpub+json",\n name: "Web Publication",\n fileExtension: "json"\n });\n }\n static get WAV() {\n return a.parse({ mediaType: "audio/wav", fileExtension: "wav" });\n }\n static get WEBM_AUDIO() {\n return a.parse({ mediaType: "audio/webm", fileExtension: "webm" });\n }\n static get WEBM_VIDEO() {\n return a.parse({ mediaType: "video/webm", fileExtension: "webm" });\n }\n static get WEBP() {\n return a.parse({ mediaType: "image/webp", fileExtension: "webp" });\n }\n static get WOFF() {\n return a.parse({ mediaType: "font/woff", fileExtension: "woff" });\n }\n static get WOFF2() {\n return a.parse({ mediaType: "font/woff2", fileExtension: "woff2" });\n }\n static get XHTML() {\n return a.parse({\n mediaType: "application/xhtml+xml",\n fileExtension: "xhtml"\n });\n }\n static get XML() {\n return a.parse({\n mediaType: "application/xml",\n fileExtension: "xml"\n });\n }\n static get ZAB() {\n return a.parse({\n mediaType: "application/x.readium.zab+zip",\n name: "Zipped Audio Book",\n fileExtension: "zab"\n });\n }\n static get ZIP() {\n return a.parse({\n mediaType: "application/zip",\n fileExtension: "zip"\n });\n }\n}\nclass we {\n constructor(e) {\n this.uri = e, this.parameters = this.getParameters(e);\n }\n /**\n * List of URI template parameter keys, if the [Link] is templated.\n */\n getParameters(e) {\n const t = /\\{\\??([^}]+)\\}/g, i = e.match(t);\n return i ? new Set(\n i.join(",").replace(t, "$1").split(",").map((s) => s.trim())\n ) : /* @__PURE__ */ new Set();\n }\n /** Expands the URI by replacing the template variables by the given parameters.\n * Any extra parameter is appended as query parameters.\n * See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570\n */\n expand(e) {\n const t = (s) => s.split(",").map((n) => {\n const o = e[n];\n return o ? encodeURIComponent(o) : "";\n }).join(","), i = (s) => "?" + s.split(",").map((n) => {\n const o = n.split("=")[0], l = e[o];\n return l ? `${o}=${encodeURIComponent(l)}` : "";\n }).join("&");\n return this.uri.replace(/\\{(\\??)([^}]+)\\}/g, (...s) => s[1] ? i(s[2]) : t(s[2]));\n }\n}\nclass b {\n /**\n * Creates a [Locations].\n */\n constructor(e) {\n this.fragments = e.fragments ? e.fragments : new Array(), this.progression = e.progression, this.totalProgression = e.totalProgression, this.position = e.position, this.otherLocations = e.otherLocations;\n }\n /**\n * Parses a [Locations] from its RWPM JSON representation.\n */\n static deserialize(e) {\n if (!e) return;\n const t = G(e.progression), i = G(e.totalProgression), s = G(e.position), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([\n "fragment",\n "fragments",\n "progression",\n "totalProgression",\n "position"\n ]);\n return Object.entries(e).forEach(([l, u]) => {\n o.has(l) || n.set(l, u);\n }), new b({\n fragments: $e(e.fragments || e.fragment),\n progression: t !== void 0 && t >= 0 && t <= 1 ? t : void 0,\n totalProgression: i !== void 0 && i >= 0 && i <= 1 ? i : void 0,\n position: s !== void 0 && s > 0 ? s : void 0,\n otherLocations: n.size === 0 ? void 0 : n\n });\n }\n /**\n * Serializes a [Locations] to its RWPM JSON representation.\n */\n serialize() {\n const e = {};\n return this.fragments && (e.fragments = this.fragments), this.progression !== void 0 && (e.progression = this.progression), this.totalProgression !== void 0 && (e.totalProgression = this.totalProgression), this.position !== void 0 && (e.position = this.position), this.otherLocations && this.otherLocations.forEach((t, i) => e[i] = t), e;\n }\n}\nclass D {\n /**\n * Creates a [Text].\n */\n constructor(e) {\n this.after = e.after, this.before = e.before, this.highlight = e.highlight;\n }\n /**\n * Parses a [Locations] from its RWPM JSON representation.\n */\n static deserialize(e) {\n if (e)\n return new D({\n after: e.after,\n before: e.before,\n highlight: e.highlight\n });\n }\n /**\n * Serializes a [Locations] to its RWPM JSON representation.\n */\n serialize() {\n const e = {};\n return this.after !== void 0 && (e.after = this.after), this.before !== void 0 && (e.before = this.before), this.highlight !== void 0 && (e.highlight = this.highlight), e;\n }\n}\nclass I {\n /**\n * Creates a [Locator].\n */\n constructor(e) {\n this.href = e.href, this.type = e.type, this.title = e.title, this.locations = e.locations ? e.locations : new b({}), this.text = e.text;\n }\n /**\n * Parses a [Link] from its RWPM JSON representation.\n */\n static deserialize(e) {\n if (e && e.href && e.type)\n return new I({\n href: e.href,\n type: e.type,\n title: e.title,\n locations: b.deserialize(e.locations),\n text: D.deserialize(e.text)\n });\n }\n /**\n * Serializes a [Link] to its RWPM JSON representation.\n */\n serialize() {\n const e = { href: this.href, type: this.type };\n return this.title !== void 0 && (e.title = this.title), this.locations && (e.locations = this.locations.serialize()), this.text && (e.text = this.text.serialize()), e;\n }\n /**\n * Shortcut to get a copy of the [Locator] with different [Locations] sub-properties.\n */\n copyWithLocations(e) {\n return new I({\n href: this.href,\n type: this.type,\n title: this.title,\n text: this.text,\n locations: new b({ ...this.locations, ...e })\n });\n }\n}\nclass U {\n /**\n * Creates a [Link].\n */\n constructor(e) {\n this.href = e.href, this.templated = e.templated, this.type = e.type, this.title = e.title, this.rels = e.rels, this.properties = e.properties, this.height = e.height, this.width = e.width, this.size = e.size, this.duration = e.duration, this.bitrate = e.bitrate, this.languages = e.languages, this.alternates = e.alternates, this.children = e.children;\n }\n /**\n * Parses a [Link] from its RWPM JSON representation.\n */\n static deserialize(e) {\n if (!(!e || typeof e.href != "string"))\n return new U({\n href: e.href,\n templated: e.templated,\n type: e.type,\n title: e.title,\n rels: e.rel ? Array.isArray(e.rel) ? new Set(e.rel) : /* @__PURE__ */ new Set([e.rel]) : void 0,\n properties: C.deserialize(e.properties),\n height: S(e.height),\n width: S(e.width),\n size: S(e.size),\n duration: S(e.duration),\n bitrate: S(e.bitrate),\n languages: $e(e.language),\n alternates: Y.deserialize(e.alternate),\n children: Y.deserialize(e.children)\n });\n }\n /**\n * Serializes a [Link] to its RWPM JSON representation.\n */\n serialize() {\n const e = { href: this.href };\n return this.templated !== void 0 && (e.templated = this.templated), this.type !== void 0 && (e.type = this.type), this.title !== void 0 && (e.title = this.title), this.rels && (e.rel = rt(this.rels)), this.properties && (e.properties = this.properties.serialize()), this.height !== void 0 && (e.height = this.height), this.width !== void 0 && (e.width = this.width), this.size !== void 0 && (e.size = this.size), this.duration !== void 0 && (e.duration = this.duration), this.bitrate !== void 0 && (e.bitrate = this.bitrate), this.languages && (e.language = this.languages), this.alternates && (e.alternate = this.alternates.serialize()), this.children && (e.children = this.children.serialize()), e;\n }\n /** MediaType of the linked resource. */\n get mediaType() {\n return this.type !== void 0 ? a.parse({ mediaType: this.type }) : a.BINARY;\n }\n /** Computes an absolute URL to the link, relative to the given `baseURL`.\n * If the link\'s `href` is already absolute, the `baseURL` is ignored.\n */\n toURL(e) {\n const t = this.href.replace(/^(\\/)/, "");\n if (t.length === 0) return;\n let i = e || "/";\n return i.startsWith("/") && (i = "file://" + i), new URL(t, i).href.replace(/^(file:\\/\\/)/, "");\n }\n /** List of URI template parameter keys, if the `Link` is templated. */\n get templateParameters() {\n return this.templated ? new we(this.href).parameters : /* @__PURE__ */ new Set();\n }\n /** Expands the `Link`\'s HREF by replacing URI template variables by the given parameters.\n * See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570\n */\n expandTemplate(e) {\n return new U({\n href: new we(this.href).expand(e),\n templated: !1\n });\n }\n /**\n * Makes a copy of this [Link] after merging in the given additional other [properties].\n */\n addProperties(e) {\n const t = U.deserialize(this.serialize());\n return t.properties = t.properties ? t.properties?.add(e) : new C(e), t;\n }\n /**\n * Creates a [Locator] from a reading order [Link].\n */\n get locator() {\n let e = this.href.split("#");\n return new I({\n href: e.length > 0 && e[0] !== void 0 ? e[0] : this.href,\n type: this.type ?? "",\n title: this.title,\n locations: new b({\n fragments: e.length > 1 && e[1] !== void 0 ? [e[1]] : []\n })\n });\n }\n}\nclass Y {\n /**\n * Creates a [Links].\n */\n constructor(e) {\n this.items = e;\n }\n /**\n * Creates a list of [Link] from its RWPM JSON representation.\n */\n static deserialize(e) {\n if (e && Array.isArray(e))\n return new Y(\n e.map((t) => U.deserialize(t)).filter((t) => t !== void 0)\n );\n }\n /**\n * Serializes an array of [Link] to its RWPM JSON representation.\n */\n serialize() {\n return this.items.map((e) => e.serialize());\n }\n /** Finds the first link with the given relation. */\n findWithRel(e) {\n const t = (i) => i.rels && i.rels.has(e);\n return this.items.find(t);\n }\n /** Finds all the links with the given relation. */\n filterByRel(e) {\n const t = (i) => i.rels && i.rels.has(e);\n return this.items.filter(t);\n }\n /** Finds the first link matching the given HREF. */\n findWithHref(e) {\n const t = (i) => i.href === e;\n return this.items.find(t);\n }\n /** Finds the index of the first link matching the given HREF. */\n findIndexWithHref(e) {\n const t = (i) => i.href === e;\n return this.items.findIndex(t);\n }\n /** Finds the first link matching the given media type. */\n findWithMediaType(e) {\n const t = (i) => i.mediaType.matches(e);\n return this.items.find(t);\n }\n /** Finds all the links matching the given media type. */\n filterByMediaType(e) {\n const t = (i) => i.mediaType.matches(e);\n return this.items.filter(t);\n }\n /** Finds all the links matching any of the given media types. */\n filterByMediaTypes(e) {\n const t = (i) => {\n for (const s of e)\n if (i.mediaType.matches(s))\n return !0;\n return !1;\n };\n return this.items.filter(t);\n }\n /** Returns whether all the resources in the collection are audio clips. */\n everyIsAudio() {\n const e = (t) => t.mediaType.isAudio;\n return this.items.length > 0 && this.items.every(e);\n }\n /** Returns whether all the resources in the collection are bitmaps. */\n everyIsBitmap() {\n const e = (t) => t.mediaType.isBitmap;\n return this.items.length > 0 && this.items.every(e);\n }\n /** Returns whether all the resources in the collection are HTML documents. */\n everyIsHTML() {\n const e = (t) => t.mediaType.isHTML;\n return this.items.length > 0 && this.items.every(e);\n }\n /** Returns whether all the resources in the collection are video clips. */\n everyIsVideo() {\n const e = (t) => t.mediaType.isVideo;\n return this.items.length > 0 && this.items.every(e);\n }\n /** Returns whether all the resources in the collection are matching any of the given media types. */\n everyMatchesMediaType(e) {\n return Array.isArray(e) ? this.items.length > 0 && this.items.every((t) => {\n for (const i of e)\n return t.mediaType.matches(i);\n return !1;\n }) : this.items.length > 0 && this.items.every((t) => t.mediaType.matches(e));\n }\n filterLinksHasType() {\n return this.items.filter((e) => e.type);\n }\n}\nC.prototype.getContains = function() {\n return new Set(this.otherProperties.contains || []);\n};\nclass K {\n /**\n * Creates a [DomRange].\n */\n constructor(e) {\n this.cssSelector = e.cssSelector, this.textNodeIndex = e.textNodeIndex, this.charOffset = e.charOffset;\n }\n /**\n * Parses a [DomRangePoint] from its RWPM JSON representation.\n */\n static deserialize(e) {\n if (!(e && e.cssSelector)) return;\n let t = S(e.textNodeIndex);\n if (t === void 0) return;\n let i = S(e.charOffset);\n return i === void 0 && (i = S(e.offset)), new K({\n cssSelector: e.cssSelector,\n textNodeIndex: t,\n charOffset: i\n });\n }\n /**\n * Serializes a [DomRangePoint] to its RWPM JSON representation.\n */\n serialize() {\n const e = {\n cssSelector: this.cssSelector,\n textNodeIndex: this.textNodeIndex\n };\n return this.charOffset !== void 0 && (e.charOffset = this.charOffset), e;\n }\n}\nclass pe {\n /**\n * Creates a [DomRange].\n */\n constructor(e) {\n this.start = e.start, this.end = e.end;\n }\n /**\n * Parses a [DomRange] from its RWPM JSON representation.\n */\n static deserialize(e) {\n if (!e) return;\n let t = K.deserialize(e.start);\n if (t)\n return new pe({\n start: t,\n end: K.deserialize(e.end)\n });\n }\n /**\n * Serializes a [DomRange] to its RWPM JSON representation.\n */\n serialize() {\n const e = { start: this.start.serialize() };\n return this.end && (e.end = this.end.serialize()), e;\n }\n}\nb.prototype.getCssSelector = function() {\n return this.otherLocations?.get("cssSelector");\n};\nb.prototype.getPartialCfi = function() {\n return this.otherLocations?.get("partialCfi");\n};\nb.prototype.getDomRange = function() {\n return pe.deserialize(this.otherLocations?.get("domRange"));\n};\nb.prototype.fragmentParameters = function() {\n return new Map(\n 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) => [\n r[0].trim().toLowerCase(),\n r[1].trim()\n ])\n );\n};\nb.prototype.htmlId = function() {\n if (!this.fragments.length) return;\n let r = this.fragments.find((e) => e.length && !e.includes("="));\n if (!r) {\n const e = this.fragmentParameters();\n e.has("id") ? r = e.get("id") : e.has("name") && (r = e.get("name"));\n }\n return r?.startsWith("#") ? r.slice(1) : r;\n};\nb.prototype.page = function() {\n const r = parseInt(this.fragmentParameters().get("page"));\n if (!isNaN(r) && r >= 0) return r;\n};\nb.prototype.time = function() {\n const r = parseInt(this.fragmentParameters().get("t"));\n if (!isNaN(r)) return r;\n};\nb.prototype.space = function() {\n const r = this.fragmentParameters();\n if (!r.has("xywh")) return;\n const e = r.get("xywh").split(",").map((t) => parseInt(t));\n if (e.length === 4 && !e.some(isNaN))\n return e;\n};\nclass fe {\n /** Creates a [Price]. */\n constructor(e) {\n this.currency = e.currency, this.value = e.value;\n }\n /**\n * Parses a [Price] from its RWPM JSON representation.\n */\n static deserialize(e) {\n if (!e) return;\n let t = e.currency;\n if (!(t && typeof t == "string" && t.length > 0))\n return;\n let i = S(e.value);\n if (i !== void 0)\n return new fe({ currency: t, value: i });\n }\n /**\n * Serializes a [Price] to its RWPM JSON representation.\n */\n serialize() {\n return { currency: this.currency, value: this.value };\n }\n}\nclass H {\n /** Creates a [Acquisition]. */\n constructor(e) {\n this.type = e.type, this.children = e.children;\n }\n /**\n * Parses a [Acquisition] from its RWPM JSON representation.\n */\n static deserialize(e) {\n if (e && e.type)\n return new H({\n type: e.type,\n children: H.deserializeArray(e.children)\n });\n }\n static deserializeArray(e) {\n if (Array.isArray(e))\n return e.map((t) => H.deserialize(t)).filter((t) => t !== void 0);\n }\n /**\n * Serializes a [Acquisition] to its RWPM JSON representation.\n */\n serialize() {\n const e = { type: this.type };\n return this.children && (e.children = this.children.map((t) => t.serialize())), e;\n }\n}\nclass me {\n /** Creates a [Price]. */\n constructor(e) {\n this.total = e.total, this.position = e.position;\n }\n /**\n * Parses a [Holds] from its RWPM JSON representation.\n */\n static deserialize(e) {\n if (e)\n return new me({\n total: S(e.total),\n position: S(e.position)\n });\n }\n /**\n * Serializes a [Holds] to its RWPM JSON representation.\n */\n serialize() {\n const e = {};\n return this.total !== void 0 && (e.total = this.total), this.position !== void 0 && (e.position = this.position), e;\n }\n}\nclass ge {\n /** Creates a [Copies]. */\n constructor(e) {\n this.total = e.total, this.available = e.available;\n }\n /**\n * Parses a [Copies] from its RWPM JSON representation.\n */\n static deserialize(e) {\n if (e)\n return new ge({\n total: S(e.total),\n available: S(e.available)\n });\n }\n /**\n * Serializes a [Copies] to its RWPM JSON representation.\n */\n serialize() {\n const e = {};\n return this.total !== void 0 && (e.total = this.total), this.available !== void 0 && (e.available = this.available), e;\n }\n}\nclass ye {\n /** Creates a [Availability]. */\n constructor(e) {\n this.state = e.state, this.since = e.since, this.until = e.until;\n }\n /**\n * Parses a [Availability] from its RWPM JSON representation.\n */\n static deserialize(e) {\n if (e && e.state)\n return new ye({\n state: e.state,\n since: Te(e.since),\n until: Te(e.until)\n });\n }\n /**\n * Serializes a [Availability] to its RWPM JSON representation.\n */\n serialize() {\n const e = { state: this.state };\n return this.since !== void 0 && (e.since = this.since.toISOString()), this.until !== void 0 && (e.until = this.until.toISOString()), e;\n }\n}\nC.prototype.getNumberOfItems = function() {\n return S(this.otherProperties.numberOfItems);\n};\nC.prototype.getPrice = function() {\n return fe.deserialize(this.otherProperties.price);\n};\nC.prototype.getIndirectAcquisitions = function() {\n const r = this.otherProperties.indirectAcquisition;\n if (r && Array.isArray(r))\n return r.map((e) => H.deserialize(e)).filter((e) => e !== void 0);\n};\nC.prototype.getHolds = function() {\n return me.deserialize(this.otherProperties.holds);\n};\nC.prototype.getCopies = function() {\n return ge.deserialize(this.otherProperties.copies);\n};\nC.prototype.getAvailability = function() {\n return ye.deserialize(this.otherProperties.availability);\n};\nC.prototype.getAuthenticate = function() {\n return U.deserialize(this.otherProperties.authenticate);\n};\nconst nt = "CssSelectorGenerator";\nfunction Se(r = "unknown problem", ...e) {\n console.warn(`${nt}: ${r}`, ...e);\n}\nfunction ot(r) {\n return r instanceof RegExp;\n}\nfunction at(r) {\n return r.replace(/[|\\\\{}()[\\]^$+?.]/g, "\\\\$&").replace(/\\*/g, ".+");\n}\nfunction lt(r) {\n const e = r.map((t) => {\n if (ot(t))\n return (i) => t.test(i);\n if (typeof t == "function")\n return (i) => {\n const s = t(i);\n return typeof s != "boolean" ? (Se("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It\'s result will be ignored.", t), !1) : s;\n };\n if (typeof t == "string") {\n const i = new RegExp("^" + at(t) + "$");\n return (s) => i.test(s);\n }\n return Se("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", t), () => !1;\n });\n return (t) => e.some((i) => i(t));\n}\nlt([\n "class",\n "id",\n // Angular attributes\n "ng-*"\n]);\nclass X {\n}\nfunction Ce(r) {\n return r.split("").reverse().join("");\n}\nfunction ht(r, e, t) {\n const i = Ce(e);\n return t.map((s) => {\n const n = Math.max(0, s.end - e.length - s.errors), o = Ce(r.slice(n, s.end));\n return {\n start: ke(o, i, s.errors).reduce((u, h) => s.end - h.end < u ? s.end - h.end : u, s.end),\n end: s.end,\n errors: s.errors\n };\n });\n}\nfunction ie(r) {\n return (r | -r) >> 31 & 1;\n}\nfunction Pe(r, e, t, i) {\n let s = r.P[t], n = r.M[t];\n const o = i >>> 31, l = e[t] | o, u = l | n, h = (l & s) + s ^ s | l;\n let c = n | ~(h | s), m = s & h;\n const p = ie(c & r.lastRowMask[t]) - ie(m & r.lastRowMask[t]);\n return c <<= 1, m <<= 1, m |= o, c |= ie(i) - o, s = m | ~(u | c), n = c & u, r.P[t] = s, r.M[t] = n, p;\n}\nfunction ke(r, e, t) {\n if (e.length === 0)\n return [];\n t = Math.min(t, e.length);\n const i = [], s = 32, n = Math.ceil(e.length / s) - 1, o = {\n P: new Uint32Array(n + 1),\n M: new Uint32Array(n + 1),\n lastRowMask: new Uint32Array(n + 1)\n };\n o.lastRowMask.fill(1 << 31), o.lastRowMask[n] = 1 << (e.length - 1) % s;\n const l = new Uint32Array(n + 1), u = /* @__PURE__ */ new Map(), h = [];\n for (let p = 0; p < 256; p++)\n h.push(l);\n for (let p = 0; p < e.length; p += 1) {\n const y = e.charCodeAt(p);\n if (u.has(y))\n continue;\n const d = new Uint32Array(n + 1);\n u.set(y, d), y < h.length && (h[y] = d);\n for (let f = 0; f <= n; f += 1) {\n d[f] = 0;\n for (let g = 0; g < s; g += 1) {\n const E = f * s + g;\n if (E >= e.length)\n continue;\n e.charCodeAt(E) === y && (d[f] |= 1 << g);\n }\n }\n }\n let c = Math.max(0, Math.ceil(t / s) - 1);\n const m = new Uint32Array(n + 1);\n for (let p = 0; p <= c; p += 1)\n m[p] = (p + 1) * s;\n m[n] = e.length;\n for (let p = 0; p <= c; p += 1)\n o.P[p] = -1, o.M[p] = 0;\n for (let p = 0; p < r.length; p += 1) {\n const y = r.charCodeAt(p);\n let d;\n y < h.length ? d = h[y] : (d = u.get(y), typeof d > "u" && (d = l));\n let f = 0;\n for (let g = 0; g <= c; g += 1)\n f = Pe(o, d, g, f), m[g] += f;\n if (m[c] - f <= t && c < n && (d[c + 1] & 1 || f < 0)) {\n c += 1, o.P[c] = -1, o.M[c] = 0;\n let g;\n if (c === n) {\n const E = e.length % s;\n g = E === 0 ? s : E;\n } else\n g = s;\n m[c] = m[c - 1] + g - f + Pe(o, d, c, f);\n } else\n for (; c > 0 && m[c] >= t + s; )\n c -= 1;\n c === n && m[c] <= t && (m[c] < t && i.splice(0, i.length), i.push({\n start: -1,\n end: p + 1,\n errors: m[c]\n }), t = m[c]);\n }\n return i;\n}\nfunction ct(r, e, t) {\n const i = ke(r, e, t);\n return ht(r, e, i);\n}\nfunction Ve(r, e, t) {\n let i = 0;\n const s = [];\n for (; i !== -1; )\n i = r.indexOf(e, i), i !== -1 && (s.push({\n start: i,\n end: i + e.length,\n errors: 0\n }), i += 1);\n return s.length > 0 ? s : ct(r, e, t);\n}\nfunction Ae(r, e) {\n return e.length === 0 || r.length === 0 ? 0 : 1 - Ve(r, e, e.length)[0].errors / e.length;\n}\nfunction ut(r, e, t = {}) {\n if (e.length === 0)\n return null;\n const i = Math.min(256, e.length / 2), s = Ve(r, e, i);\n if (s.length === 0)\n return null;\n const n = (l) => {\n const p = 1 - l.errors / e.length, y = t.prefix ? Ae(\n r.slice(\n Math.max(0, l.start - t.prefix.length),\n l.start\n ),\n t.prefix\n ) : 1, d = t.suffix ? Ae(\n r.slice(l.end, l.end + t.suffix.length),\n t.suffix\n ) : 1;\n let f = 1;\n return typeof t.hint == "number" && (f = 1 - Math.abs(l.start - t.hint) / r.length), (50 * p + 20 * y + 20 * d + 2 * f) / 92;\n }, o = s.map((l) => ({\n start: l.start,\n end: l.end,\n score: n(l)\n }));\n return o.sort((l, u) => u.score - l.score), o[0];\n}\nfunction se(r, e, t) {\n const i = t === 1 ? e : e - 1;\n if (r.charAt(i).trim() !== "")\n return e;\n let s, n;\n if (t === 2 ? (s = r.substring(0, e), n = s.trimEnd()) : (s = r.substring(e), n = s.trimStart()), !n.length)\n return -1;\n const o = s.length - n.length;\n return t === 2 ? e - o : e + o;\n}\nfunction Me(r, e) {\n const t = r.commonAncestorContainer.ownerDocument.createNodeIterator(\n r.commonAncestorContainer,\n NodeFilter.SHOW_TEXT\n ), i = e === 1 ? r.startContainer : r.endContainer, s = e === 1 ? r.endContainer : r.startContainer;\n let n = t.nextNode();\n for (; n && n !== i; )\n n = t.nextNode();\n e === 2 && (n = t.previousNode());\n let o = -1;\n const l = () => {\n if (n = e === 1 ? t.nextNode() : t.previousNode(), n) {\n const u = n.textContent, h = e === 1 ? 0 : u.length;\n o = se(u, h, e);\n }\n };\n for (; n && o === -1 && n !== s; )\n l();\n if (n && o >= 0)\n return { node: n, offset: o };\n throw new RangeError("No text nodes with non-whitespace text found in range");\n}\nfunction dt(r) {\n if (!r.toString().trim().length)\n throw new RangeError("Range contains no non-whitespace text");\n if (r.startContainer.nodeType !== Node.TEXT_NODE)\n throw new RangeError("Range startContainer is not a text node");\n if (r.endContainer.nodeType !== Node.TEXT_NODE)\n throw new RangeError("Range endContainer is not a text node");\n const e = r.cloneRange();\n let t = !1, i = !1;\n const s = {\n start: se(\n r.startContainer.textContent,\n r.startOffset,\n 1\n /* Forwards */\n ),\n end: se(\n r.endContainer.textContent,\n r.endOffset,\n 2\n /* Backwards */\n )\n };\n if (s.start >= 0 && (e.setStart(r.startContainer, s.start), t = !0), s.end > 0 && (e.setEnd(r.endContainer, s.end), i = !0), t && i)\n return e;\n if (!t) {\n const { node: n, offset: o } = Me(\n e,\n 1\n /* Forwards */\n );\n n && o >= 0 && e.setStart(n, o);\n }\n if (!i) {\n const { node: n, offset: o } = Me(\n e,\n 2\n /* Backwards */\n );\n n && o > 0 && e.setEnd(n, o);\n }\n return e;\n}\nfunction je(r) {\n switch (r.nodeType) {\n case Node.ELEMENT_NODE:\n case Node.TEXT_NODE:\n return r.textContent?.length ?? 0;\n default:\n return 0;\n }\n}\nfunction Ne(r) {\n let e = r.previousSibling, t = 0;\n for (; e; )\n t += je(e), e = e.previousSibling;\n return t;\n}\nfunction qe(r, ...e) {\n let t = e.shift();\n const i = r.ownerDocument.createNodeIterator(\n r,\n NodeFilter.SHOW_TEXT\n ), s = [];\n let n = i.nextNode(), o, l = 0;\n for (; t !== void 0 && n; )\n o = n, l + o.data.length > t ? (s.push({ node: o, offset: t - l }), t = e.shift()) : (n = i.nextNode(), l += o.data.length);\n for (; t !== void 0 && o && l === t; )\n s.push({ node: o, offset: o.data.length }), t = e.shift();\n if (t !== void 0)\n throw new RangeError("Offset exceeds text length");\n return s;\n}\nclass M {\n constructor(e, t) {\n if (t < 0)\n throw new Error("Offset is invalid");\n this.element = e, this.offset = t;\n }\n /**\n * Return a copy of this position with offset relative to a given ancestor\n * element.\n *\n * @param parent - Ancestor of `this.element`\n */\n relativeTo(e) {\n if (!e.contains(this.element))\n throw new Error("Parent is not an ancestor of current element");\n let t = this.element, i = this.offset;\n for (; t !== e; )\n i += Ne(t), t = t.parentElement;\n return new M(t, i);\n }\n /**\n * Resolve the position to a specific text node and offset within that node.\n *\n * Throws if `this.offset` exceeds the length of the element\'s text. In the\n * case where the element has no text and `this.offset` is 0, the `direction`\n * option determines what happens.\n *\n * Offsets at the boundary between two nodes are resolved to the start of the\n * node that begins at the boundary.\n *\n * @param options.direction - Specifies in which direction to search for the\n * nearest text node if `this.offset` is `0` and\n * `this.element` has no text. If not specified an\n * error is thrown.\n *\n * @throws {RangeError}\n */\n resolve(e = {}) {\n try {\n return qe(this.element, this.offset)[0];\n } catch (t) {\n if (this.offset === 0 && e.direction !== void 0) {\n const i = document.createTreeWalker(\n this.element.getRootNode(),\n NodeFilter.SHOW_TEXT\n );\n i.currentNode = this.element;\n const s = e.direction === 1, n = s ? i.nextNode() : i.previousNode();\n if (!n)\n throw t;\n return { node: n, offset: s ? 0 : n.data.length };\n } else\n throw t;\n }\n }\n /**\n * Construct a `TextPosition` that refers to the `offset`th character within\n * `node`.\n */\n static fromCharOffset(e, t) {\n switch (e.nodeType) {\n case Node.TEXT_NODE:\n return M.fromPoint(e, t);\n case Node.ELEMENT_NODE:\n return new M(e, t);\n default:\n throw new Error("Node is not an element or text node");\n }\n }\n /**\n * Construct a `TextPosition` representing the range start or end point (node, offset).\n *\n * @param node\n * @param offset - Offset within the node\n */\n static fromPoint(e, t) {\n switch (e.nodeType) {\n case Node.TEXT_NODE: {\n if (t < 0 || t > e.data.length)\n throw new Error("Text node offset is out of range");\n if (!e.parentElement)\n throw new Error("Text node has no parent");\n const i = Ne(e) + t;\n return new M(e.parentElement, i);\n }\n case Node.ELEMENT_NODE: {\n if (t < 0 || t > e.childNodes.length)\n throw new Error("Child node offset is out of range");\n let i = 0;\n for (let s = 0; s < t; s++)\n i += je(e.childNodes[s]);\n return new M(e, i);\n }\n default:\n throw new Error("Point is not in an element or text node");\n }\n }\n}\nclass R {\n constructor(e, t) {\n this.start = e, this.end = t;\n }\n /**\n * Create a new TextRange whose `start` and `end` are computed relative to\n * `element`. `element` must be an ancestor of both `start.element` and\n * `end.element`.\n */\n relativeTo(e) {\n return new R(\n this.start.relativeTo(e),\n this.end.relativeTo(e)\n );\n }\n /**\n * Resolve this TextRange to a (DOM) Range.\n *\n * The resulting DOM Range will always start and end in a `Text` node.\n * Hence `TextRange.fromRange(range).toRange()` can be used to "shrink" a\n * range to the text it contains.\n *\n * May throw if the `start` or `end` positions cannot be resolved to a range.\n */\n toRange() {\n let e, t;\n this.start.element === this.end.element && this.start.offset <= this.end.offset ? [e, t] = qe(\n this.start.element,\n this.start.offset,\n this.end.offset\n ) : (e = this.start.resolve({\n direction: 1\n /* FORWARDS */\n }), t = this.end.resolve({\n direction: 2\n /* BACKWARDS */\n }));\n const i = new Range();\n return i.setStart(e.node, e.offset), i.setEnd(t.node, t.offset), i;\n }\n /**\n * Create a TextRange from a (DOM) Range\n */\n static fromRange(e) {\n const t = M.fromPoint(\n e.startContainer,\n e.startOffset\n ), i = M.fromPoint(e.endContainer, e.endOffset);\n return new R(t, i);\n }\n /**\n * Create a TextRange representing the `start`th to `end`th characters in\n * `root`\n */\n static fromOffsets(e, t, i) {\n return new R(\n new M(e, t),\n new M(e, i)\n );\n }\n /**\n * Return a new Range representing `range` trimmed of any leading or trailing\n * whitespace\n */\n static trimmedRange(e) {\n return dt(R.fromRange(e).toRange());\n }\n}\nclass Z {\n constructor(e, t, i) {\n this.root = e, this.start = t, this.end = i;\n }\n static fromRange(e, t) {\n const i = R.fromRange(t).relativeTo(e);\n return new Z(\n e,\n i.start.offset,\n i.end.offset\n );\n }\n static fromSelector(e, t) {\n return new Z(e, t.start, t.end);\n }\n toSelector() {\n return {\n type: "TextPositionSelector",\n start: this.start,\n end: this.end\n };\n }\n toRange() {\n return R.fromOffsets(this.root, this.start, this.end).toRange();\n }\n}\nclass J {\n /**\n * @param root - A root element from which to anchor.\n */\n constructor(e, t, i = {}) {\n this.root = e, this.exact = t, this.context = i;\n }\n /**\n * Create a `TextQuoteAnchor` from a range.\n *\n * Will throw if `range` does not contain any text nodes.\n */\n static fromRange(e, t) {\n const i = e.textContent, s = R.fromRange(t).relativeTo(e), n = s.start.offset, o = s.end.offset, l = 32;\n return new J(e, i.slice(n, o), {\n prefix: i.slice(Math.max(0, n - l), n),\n suffix: i.slice(o, Math.min(i.length, o + l))\n });\n }\n static fromSelector(e, t) {\n const { prefix: i, suffix: s } = t;\n return new J(e, t.exact, { prefix: i, suffix: s });\n }\n toSelector() {\n return {\n type: "TextQuoteSelector",\n exact: this.exact,\n prefix: this.context.prefix,\n suffix: this.context.suffix\n };\n }\n toRange(e = {}) {\n return this.toPositionAnchor(e).toRange();\n }\n toPositionAnchor(e = {}) {\n const t = this.root.textContent, i = ut(t, this.exact, {\n ...this.context,\n hint: e.hint\n });\n if (!i)\n throw new Error("Quote not found");\n return new Z(this.root, i.start, i.end);\n }\n}\nfunction pt(r) {\n const e = r.tagName.toUpperCase();\n return e === "IMG" || e === "VIDEO" || e === "AUDIO" || e === "IFRAME" || e === "OBJECT" || e === "EMBED" || e === "CANVAS";\n}\nfunction ee(r, e) {\n try {\n const t = e.locations, i = e.text;\n if (i && i.highlight) {\n let s;\n t && t.getCssSelector() && (s = r.querySelector(t.getCssSelector())), s || (s = r.body);\n const n = new J(s, i.highlight, {\n prefix: i.before,\n suffix: i.after\n });\n try {\n return n.toRange();\n } catch {\n return console.warn("Quote not found:", n), null;\n }\n }\n if (t) {\n let s = null;\n if (!s && t.getCssSelector() && (s = r.querySelector(t.getCssSelector())), !s && t.fragments) {\n for (const n of t.fragments)\n if (s = r.getElementById(n), s)\n break;\n }\n if (s) {\n const n = r.createRange();\n return s.childNodes.length === 0 || pt(s) ? (n.selectNode(s), n) : (n.setStartBefore(s), n.setEndAfter(s), n);\n }\n }\n } catch (t) {\n console.error(t);\n }\n return null;\n}\nfunction ft(r, e) {\n let t = r.getClientRects();\n t.length || r.commonAncestorContainer.nodeType === Node.ELEMENT_NODE && (t = r.commonAncestorContainer.getClientRects());\n const i = 1, s = [];\n for (const h of t)\n s.push({\n bottom: h.bottom,\n height: h.height,\n left: h.left,\n right: h.right,\n top: h.top,\n width: h.width\n });\n const n = Xe(\n s,\n i\n ), o = gt(n, i), l = _e(o), u = 4;\n for (let h = l.length - 1; h >= 0; h--) {\n const c = l[h];\n if (!(c.width * c.height > u))\n if (l.length > 1)\n l.splice(h, 1);\n else\n break;\n }\n return l;\n}\nfunction Xe(r, e, t) {\n for (let i = 0; i < r.length; i++)\n for (let s = i + 1; s < r.length; s++) {\n const n = r[i], o = r[s];\n if (n === o)\n continue;\n const l = P(n.top, o.top, e) && P(n.bottom, o.bottom, e), u = P(n.left, o.left, e) && P(n.right, o.right, e);\n if (l && !u && Ge(n, o, e)) {\n const m = r.filter((y) => y !== n && y !== o), p = mt(n, o);\n return m.push(p), Xe(\n m,\n e\n );\n }\n }\n return r;\n}\nfunction mt(r, e) {\n const t = Math.min(r.left, e.left), i = Math.max(r.right, e.right), s = Math.min(r.top, e.top), n = Math.max(r.bottom, e.bottom);\n return {\n bottom: n,\n height: n - s,\n left: t,\n right: i,\n top: s,\n width: i - t\n };\n}\nfunction gt(r, e) {\n const t = new Set(r);\n for (const i of r) {\n if (!(i.width > 1 && i.height > 1)) {\n t.delete(i);\n continue;\n }\n for (const n of r)\n if (i !== n && t.has(n) && yt(n, i, e)) {\n t.delete(i);\n break;\n }\n }\n return Array.from(t);\n}\nfunction yt(r, e, t) {\n return _(r, e.left, e.top, t) && _(r, e.right, e.top, t) && _(r, e.left, e.bottom, t) && _(r, e.right, e.bottom, t);\n}\nfunction _(r, e, t, i) {\n return (r.left < e || P(r.left, e, i)) && (r.right > e || P(r.right, e, i)) && (r.top < t || P(r.top, t, i)) && (r.bottom > t || P(r.bottom, t, i));\n}\nfunction _e(r) {\n for (let e = 0; e < r.length; e++)\n for (let t = e + 1; t < r.length; t++) {\n const i = r[e], s = r[t];\n if (i !== s && Ge(i, s, -1)) {\n let n = [], o;\n const l = Oe(i, s);\n if (l.length === 1)\n n = l, o = i;\n else {\n const h = Oe(s, i);\n l.length < h.length ? (n = l, o = i) : (n = h, o = s);\n }\n const u = r.filter((h) => h !== o);\n return Array.prototype.push.apply(u, n), _e(u);\n }\n }\n return r;\n}\nfunction Oe(r, e) {\n const t = vt(e, r);\n if (t.height === 0 || t.width === 0)\n return [r];\n const i = [];\n {\n const s = {\n bottom: r.bottom,\n height: 0,\n left: r.left,\n right: t.left,\n top: r.top,\n width: 0\n };\n s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);\n }\n {\n const s = {\n bottom: t.top,\n height: 0,\n left: t.left,\n right: t.right,\n top: r.top,\n width: 0\n };\n s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);\n }\n {\n const s = {\n bottom: r.bottom,\n height: 0,\n left: t.left,\n right: t.right,\n top: t.bottom,\n width: 0\n };\n s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);\n }\n {\n const s = {\n bottom: r.bottom,\n height: 0,\n left: t.right,\n right: r.right,\n top: r.top,\n width: 0\n };\n s.width = s.right - s.left, s.height = s.bottom - s.top, s.height !== 0 && s.width !== 0 && i.push(s);\n }\n return i;\n}\nfunction vt(r, e) {\n const t = Math.max(r.left, e.left), i = Math.min(r.right, e.right), s = Math.max(r.top, e.top), n = Math.min(r.bottom, e.bottom);\n return {\n bottom: n,\n height: Math.max(0, n - s),\n left: t,\n right: i,\n top: s,\n width: Math.max(0, i - t)\n };\n}\nfunction Ge(r, e, t) {\n return (r.left < e.right || t >= 0 && P(r.left, e.right, t)) && (e.left < r.right || t >= 0 && P(e.left, r.right, t)) && (r.top < e.bottom || t >= 0 && P(r.top, e.bottom, t)) && (e.top < r.bottom || t >= 0 && P(e.top, r.bottom, t));\n}\nfunction P(r, e, t) {\n return Math.abs(r - e) <= t;\n}\nfunction ve(r) {\n const e = {}, t = r.document.documentElement.style;\n for (const i in r.document.documentElement.style)\n Object.hasOwn(t, i) && !Number.isNaN(Number.parseInt(i)) && (e[t[i]] = t.getPropertyValue(t[i]));\n return e;\n}\nfunction Ye(r, e) {\n const t = ve(r);\n Object.keys(t).forEach((i) => {\n e.hasOwnProperty(i) || te(r, i);\n }), Object.entries(e).forEach(([i, s]) => {\n t[i] !== s && j(r, i, s);\n });\n}\nfunction Le(r, e) {\n return r.document.documentElement.style.getPropertyValue(e);\n}\nfunction j(r, e, t) {\n r.document.documentElement.style.setProperty(e, t);\n}\nfunction te(r, e) {\n r.document.documentElement.style.removeProperty(e);\n}\nconst bt = (r) => {\n if (r.startsWith("rgb")) {\n const e = r.match(/rgb\\((\\d+),\\s(\\d+),\\s(\\d+)(?:,\\s(\\d+))?\\)/);\n if (e)\n return {\n r: parseInt(e[1], 10),\n g: parseInt(e[2], 10),\n b: parseInt(e[3], 10),\n a: e[4] ? parseInt(e[4], 10) / 255 : 1\n };\n } else if (r.startsWith("#")) {\n const e = r.slice(1);\n if (e.length === 3 || e.length === 4)\n return {\n r: parseInt(e[0] + e[0], 16) / 255,\n g: parseInt(e[1] + e[1], 16) / 255,\n b: parseInt(e[2] + e[2], 16) / 255,\n a: e.length === 4 ? parseInt(e[3] + e[3], 16) / 255 : 1\n };\n if (e.length === 6 || e.length === 8)\n return {\n r: parseInt(e[0] + e[1], 16) / 255,\n g: parseInt(e[2] + e[3], 16) / 255,\n b: parseInt(e[4] + e[5], 16) / 255,\n a: e.length === 8 ? parseInt(e[6] + e[7], 16) / 255 : 1\n };\n }\n return { r: 0, g: 0, b: 0, a: 1 };\n}, Et = (r) => 0.2126 * r.r * r.a + 0.7152 * r.g * r.a + 0.0722 * r.b * r.a, xt = (r) => {\n const e = bt(r);\n return Et(e) < 128;\n};\nvar Tt = /* @__PURE__ */ ((r) => (r.Wrap = "wrap", r.Viewport = "viewport", r.Bounds = "bounds", r.Page = "page", r))(Tt || {}), wt = /* @__PURE__ */ ((r) => (r.Boxes = "boxes", r.Bounds = "bounds", r))(wt || {});\nconst St = () => "Highlight" in window, Ie = ["IMG", "IMAGE", "AUDIO", "VIDEO", "SVG"];\nclass Ct {\n /**\n * Creates a DecorationGroup object\n * @param id Unique HTML ID-adhering name of the group\n * @param name Human-readable name of the group\n */\n constructor(e, t, i, s) {\n this.wnd = e, this.comms = t, this.id = i, this.name = s, this.items = [], this.lastItemId = 0, this.container = void 0, this.activateable = !1, this.experimentalHighlights = !1, this.currentRender = 0, St() && (this.experimentalHighlights = !0, this.notTextFlag = /* @__PURE__ */ new Map());\n }\n get activeable() {\n return this.activateable;\n }\n set activeable(e) {\n this.activateable = e;\n }\n /**\n * Adds a new decoration to the group.\n * @param decoration Decoration to add\n */\n add(e) {\n const t = `${this.id}-${this.lastItemId++}`, i = ee(this.wnd.document, e.locator);\n if (!i) {\n this.comms.log("Can\'t locate DOM range for decoration", e);\n return;\n }\n const s = i.commonAncestorContainer;\n s.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (Ie.includes(s.nodeName.toUpperCase()) && this.notTextFlag?.set(t, !0), s.querySelector(Ie.join(", ").toLowerCase()) && this.notTextFlag?.set(t, !0), (s.textContent?.trim() || "").length === 0 && this.notTextFlag?.set(t, !0));\n const n = {\n decoration: e,\n id: t,\n range: i\n };\n this.items.push(n), this.layout(n), this.renderLayout([n]);\n }\n /**\n * Removes the decoration with given ID from the group.\n * @param identifier ID of item to remove\n */\n remove(e) {\n const t = this.items.findIndex((s) => s.decoration.id === e);\n if (t < 0) return;\n const i = this.items[t];\n this.items.splice(t, 1), i.clickableElements = void 0, i.container && (i.container.remove(), i.container = void 0), this.experimentalHighlights && !this.notTextFlag?.has(i.id) && this.wnd.CSS.highlights.get(this.id)?.delete(i.range), this.notTextFlag?.delete(i.id);\n }\n /**\n * Notifies that the given decoration was modified and needs to be updated.\n * @param decoration Decoration to update\n */\n update(e) {\n this.remove(e.id), this.add(e);\n }\n /**\n * Removes all decorations from this group.\n */\n clear() {\n this.clearContainer(), this.items.length = 0, this.notTextFlag?.clear();\n }\n /**\n * Recreates the decoration elements.\n * To be called after reflowing the resource, for example.\n */\n requestLayout() {\n this.wnd.cancelAnimationFrame(this.currentRender), this.clearContainer(), this.items.forEach((e) => this.layout(e)), this.renderLayout(this.items);\n }\n experimentalLayout(e) {\n const [t, i] = this.requireContainer(!0);\n i.add(e.range), t.innerHTML = `\n ::highlight(${this.id}) {\n color: black;\n background-color: ${e.decoration?.style?.tint ?? "yellow"};\n }`;\n }\n /**\n * Layouts a single DecorationItem.\n * @param item \n */\n layout(e) {\n if (this.experimentalHighlights && !this.notTextFlag?.has(e.id))\n return this.experimentalLayout(e);\n const t = this.wnd.document.createElement("div");\n t.setAttribute("id", e.id), t.style.setProperty("pointer-events", "none");\n const i = this.wnd.innerWidth, s = parseInt(\n getComputedStyle(this.wnd.document.documentElement).getPropertyValue(\n "column-count"\n )\n ), n = i / (s || 1), o = this.wnd.document.scrollingElement, l = o.scrollLeft, u = o.scrollTop, h = (d, f, g) => {\n if (d.style.position = "absolute", e.decoration?.style?.width === "viewport") {\n d.style.width = `${i}px`, d.style.height = `${f.height}px`;\n let E = Math.floor(f.left / i) * i;\n d.style.left = `${E + l}px`, d.style.top = `${f.top + u}px`;\n } else if (e.decoration?.style?.width === "bounds")\n d.style.width = `${g.width}px`, d.style.height = `${f.height}px`, d.style.left = `${g.left + l}px`, d.style.top = `${f.top + u}px`;\n else if (e.decoration?.style?.width === "page") {\n d.style.width = `${n}px`, d.style.height = `${f.height}px`;\n let E = Math.floor(f.left / n) * n;\n d.style.left = `${E + l}px`, d.style.top = `${f.top + u}px`;\n } else\n d.style.width = `${f.width}px`, d.style.height = `${f.height}px`, d.style.left = `${f.left + l}px`, d.style.top = `${f.top + u}px`;\n }, c = e.range.getBoundingClientRect();\n let m = this.wnd.document.createElement("template");\n const p = Le(this.wnd, "--USER__appearance") === "readium-night-on" || xt(Le(this.wnd, "--USER__backgroundColor"));\n m.innerHTML = `\n \n \n `.trim();\n const y = m.content.firstElementChild;\n if (e.decoration?.style?.layout === "bounds") {\n const d = y.cloneNode(!0);\n d.style.setProperty("pointer-events", "none"), h(d, c, c), t.append(d);\n } else {\n let d = ft(\n e.range\n );\n d = d.sort((f, g) => f.top < g.top ? -1 : f.top > g.top ? 1 : 0);\n for (let f of d) {\n const g = y.cloneNode(!0);\n g.style.setProperty("pointer-events", "none"), h(g, f, c), t.append(g);\n }\n }\n e.container = t, e.clickableElements = Array.from(\n t.querySelectorAll("[data-activable=\'1\']")\n ), e.clickableElements.length || (e.clickableElements = Array.from(t.children));\n }\n renderLayout(e) {\n this.wnd.cancelAnimationFrame(this.currentRender), this.currentRender = this.wnd.requestAnimationFrame(() => {\n if (e = e.filter((i) => !this.experimentalHighlights || !!this.notTextFlag?.has(i.id)), !e || e.length === 0) return;\n this.requireContainer().append(...e.map((i) => i.container).filter((i) => !!i));\n });\n }\n /**\n * Returns the group container element, after making sure it exists.\n * @returns Group\'s container\n */\n requireContainer(e = !1) {\n if (e) {\n let t;\n this.wnd.document.getElementById(`${this.id}-style`) ? t = this.wnd.document.getElementById(`${this.id}-style`) : (t = this.wnd.document.createElement("style"), t.dataset.readium = "true", t.id = `${this.id}-style`, this.wnd.document.head.appendChild(t));\n let i;\n return this.wnd.CSS.highlights.has(this.id) ? i = this.wnd.CSS.highlights.get(this.id) : (i = new this.wnd.Highlight(), this.wnd.CSS.highlights.set(this.id, i)), [t, i];\n }\n return this.container || (this.container = this.wnd.document.createElement("div"), this.container.setAttribute("id", this.id), this.container.dataset.group = this.name, this.container.dataset.readium = "true", this.container.style.setProperty("pointer-events", "none"), this.container.style.display = "contents", this.wnd.document.body.append(this.container)), this.container;\n }\n /**\n * Removes the group container.\n */\n clearContainer() {\n this.experimentalHighlights && this.wnd.CSS.highlights.delete(this.id), this.container && (this.container.remove(), this.container = void 0);\n }\n}\nconst $ = class $ extends X {\n constructor() {\n super(...arguments), this.resizeFrame = 0, this.lastGroupId = 0, this.groups = /* @__PURE__ */ new Map(), this.handleResizer = this.handleResize.bind(this);\n }\n cleanup() {\n this.groups.forEach((e) => e.clear()), this.groups.clear();\n }\n handleResize() {\n this.wnd.clearTimeout(this.resizeFrame), this.resizeFrame = this.wnd.setTimeout(() => {\n this.groups.forEach((e) => {\n e.experimentalHighlights || e.requestLayout();\n });\n }, 50);\n }\n mount(e, t) {\n return this.wnd = e, t.register("decorate", $.moduleName, (i, s) => {\n const n = i;\n n.decoration && n.decoration.locator && (n.decoration.locator = I.deserialize(n.decoration.locator)), this.groups.has(n.group) || this.groups.set(n.group, new Ct(\n e,\n t,\n `readium-decoration-${this.lastGroupId++}`,\n n.group\n ));\n const o = this.groups.get(n.group);\n switch (n.action) {\n case "add":\n o?.add(n.decoration);\n break;\n case "remove":\n o?.remove(n.decoration.id);\n break;\n case "clear":\n o?.clear();\n break;\n case "update":\n o?.update(n.decoration);\n break;\n }\n s(!0);\n }), this.resizeObserver = new ResizeObserver(() => e.requestAnimationFrame(() => this.handleResize())), this.resizeObserver.observe(e.document.body), e.addEventListener("orientationchange", this.handleResizer), e.addEventListener("resize", this.handleResizer), t.log("Decorator Mounted"), !0;\n }\n unmount(e, t) {\n return e.removeEventListener("orientationchange", this.handleResizer), e.removeEventListener("resize", this.handleResizer), t.unregisterAll($.moduleName), this.resizeObserver.disconnect(), this.cleanup(), t.log("Decorator Unmounted"), !0;\n }\n};\n$.moduleName = "decorator";\nlet re = $;\nconst Re = "readium-snapper-style", k = class k extends X {\n constructor() {\n super(...arguments), this.protected = !1;\n }\n buildStyles() {\n return `\n html, body {\n touch-action: manipulation;\n user-select: ${this.protected ? "none" : "auto"};\n }`;\n }\n mount(e, t) {\n const i = e.document.createElement("style");\n return i.dataset.readium = "true", i.id = Re, i.textContent = this.buildStyles(), e.document.head.appendChild(i), t.register("protect", k.moduleName, (s, n) => {\n this.protected = !0, i.textContent = this.buildStyles(), n(!0);\n }), t.register("unprotect", k.moduleName, (s, n) => {\n this.protected = !1, i.textContent = this.buildStyles(), n(!0);\n }), t.log("Snapper Mounted"), !0;\n }\n unmount(e, t) {\n return e.document.getElementById(Re)?.remove(), t.log("Snapper Unmounted"), !0;\n }\n};\nk.moduleName = "snapper";\nlet q = k;\nfunction z(r) {\n return r.document.body.dir.toLowerCase() === "rtl";\n}\nfunction Ke(r) {\n return parseInt(\n r.getComputedStyle(\n r.document.documentElement\n ).getPropertyValue("column-count")\n );\n}\nfunction ze(r) {\n const e = getComputedStyle(r), t = parseFloat(e.paddingTop || "0"), i = parseFloat(e.paddingBottom || "0");\n return r.clientHeight - t - i;\n}\nfunction De(r) {\n const e = Ke(r);\n if (!e)\n return !1;\n const t = r.document.querySelectorAll("div[id^=\'readium-virtual-page\']");\n for (const h of t)\n h.remove();\n const i = t.length, s = r.document.scrollingElement.scrollWidth, n = r.visualViewport.width, l = Math.round(s / n * e) % e, u = e === 1 || l === 0 ? 0 : e - l;\n if (u > 0)\n for (let h = 0; h < u; h++) {\n const c = r.document.createElement("div");\n c.setAttribute("id", `readium-virtual-page-${h}`), c.dataset.readium = "true", CSS.supports("break-before", "column") ? c.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (c.style.breakInside = "avoid-column"), c.style.height = ze(r.document.documentElement) + "px"), c.innerHTML = "​", r.document.body.appendChild(c);\n }\n return i !== u;\n}\nfunction Ze(r) {\n const e = r.document.createElement("style");\n e.appendChild(r.document.createTextNode("*{}")), r.document.body.appendChild(e), r.document.body.removeChild(e);\n}\nfunction Pt(r) {\n return r < 0.5 ? 2 * r * r : -1 + (4 - 2 * r) * r;\n}\nfunction v(r) {\n const e = r.getSelection();\n e && e.removeAllRanges();\n}\nconst At = [\n "a",\n "audio",\n "button",\n "canvas",\n "details",\n "input",\n "label",\n "option",\n "select",\n "submit",\n "textarea",\n "video"\n];\nfunction Je(r) {\n return At.indexOf(r.nodeName.toLowerCase()) !== -1 || r.hasAttribute("contenteditable") && r.getAttribute("contenteditable")?.toLowerCase() !== "false" ? r : r.parentElement ? Je(r.parentElement) : null;\n}\nfunction be(r, e) {\n const t = Qe(r, r.document.body, e), i = r._readium_cssSelectorGenerator.getCssSelector(t, {\n selectors: ["tag", "id", "class", "nthchild", "nthoftype", "attribute"]\n });\n return new I({\n href: "#",\n type: "application/xhtml+xml",\n locations: new b({\n otherLocations: /* @__PURE__ */ new Map([\n ["cssSelector", i]\n ])\n }),\n text: new D({\n highlight: t.textContent || void 0\n })\n });\n}\nfunction Qe(r, e, t) {\n for (var i = 0; i < e.children.length; i++) {\n const s = e.children[i];\n if (!Ot(s) && Mt(r, s, t))\n return Nt(r, s) ? s : Qe(r, s, t);\n }\n return e;\n}\nfunction Mt(r, e, t) {\n if (e === document.body || e === document.documentElement)\n return !0;\n if (!document || !document.documentElement || !document.body)\n return !1;\n const i = e.getBoundingClientRect();\n return t ? i.bottom > 0 && i.top < r.innerHeight : i.right > 0 && i.left < r.innerWidth;\n}\nfunction Nt(r, e) {\n const t = e.getBoundingClientRect();\n return t.top >= 0 && t.left >= 0 && t.bottom <= r.innerHeight && t.right <= r.innerWidth;\n}\nfunction Ot(r) {\n const e = getComputedStyle(r);\n if (e) {\n const t = e.getPropertyValue("display");\n if (t != "block" && t != "list-item" || e.getPropertyValue("opacity") === "0")\n return !0;\n }\n return !1;\n}\nconst We = "readium-column-snapper-style", Lt = 200, x = class x extends q {\n constructor() {\n super(...arguments), this.shakeTimeout = 0, this.snappingCancelled = !1, this.alreadyScrollLeft = 0, this.overscroll = 0, this.cachedScrollWidth = 0, this.touchState = 0, this.startingX = void 0, this.endingX = void 0, this.onTouchStarter = this.onTouchStart.bind(this), this.onTouchEnder = this.onTouchEnd.bind(this), this.onWidthChanger = this.onWidthChange.bind(this), this.onTouchMover = this.onTouchMove.bind(this);\n }\n doc() {\n return this.wnd.document.scrollingElement;\n }\n scrollOffset() {\n return this.doc().scrollLeft > 0 ? this.doc().scrollLeft : this.alreadyScrollLeft;\n }\n snapOffset(e) {\n const t = e + (z(this.wnd) ? -1 : 1);\n return t - t % this.wnd.innerWidth;\n }\n reportProgress() {\n const e = this.wnd.scrollX, t = this.cachedScrollWidth, i = Math.max(0, Math.min(1, e / t)), s = Math.max(0, Math.min(1, (e + this.wnd.innerWidth) / t));\n this.comms.send("progress", {\n start: i,\n end: s\n });\n }\n shake() {\n if (this.overscroll !== 0 || this.shakeTimeout !== 0) return;\n const e = this.doc();\n e.classList.add(z(this.wnd) ? "readium-bounce-l" : "readium-bounce-r");\n const t = this.scrollOffset();\n this.shakeTimeout = this.wnd.setTimeout(() => {\n e.classList.remove("readium-bounce-l"), e.classList.remove("readium-bounce-r"), this.shakeTimeout = 0, this.doc().scrollLeft = t;\n }, 150);\n }\n // We have to cache this because during overscroll (transform, or left) the width is incorrect due to browser\n takeOverSnap() {\n this.snappingCancelled = !0, this.clearTouches();\n const e = this.doc();\n this.overscroll = e.style.transform?.length > 12 ? parseFloat(e.style.transform.slice(12).split("px")[0]) : 0;\n }\n // Snaps the current offset to the page width.\n snapCurrentOffset(e = !1, t = !1) {\n const i = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft, s = this.doc(), n = this.dragOffset(), o = Ke(this.wnd), l = Math.min(Math.max(0, i), this.cachedScrollWidth), u = z(this.wnd) ? -1 : 1, h = (\n // The hurdle to overcome in order to change pages\n u * (this.wnd.innerWidth / 3) * (u * n > 0 ? 2 : 1)\n ), c = this.snapOffset(l + h);\n if (e && c !== this.scrollOffset()) {\n this.snappingCancelled = !1;\n const m = (f, g, E, W) => E > W ? g : f + (g - f) * Pt(E / W), p = (\n /*Math.abs(startX - (this.useTransform ? currentOffset : 0)) < 10 ? 1 : */\n Lt * o\n );\n let y;\n const d = (f) => {\n if (this.snappingCancelled) return;\n y || (y = f);\n const g = f - y, E = m(this.overscroll, 0, g, p), W = m(i, c, g, p);\n s.scrollLeft = W, this.overscroll !== 0 && (s.style.transform = `translate3d(${-E}px, 0px, 0px)`), g < p ? this.wnd.requestAnimationFrame(d) : (this.clearTouches(), s.style.removeProperty("transform"), s.scrollLeft = c, t || this.reportProgress());\n };\n this.wnd.requestAnimationFrame(d);\n } else\n s.style.removeProperty("transform"), this.wnd.requestAnimationFrame(() => {\n s.scrollLeft = c, this.clearTouches(), t || this.reportProgress();\n });\n }\n dragOffset() {\n return (this.startingX ?? 0) - (this.endingX ?? 0);\n }\n clearTouches() {\n this.startingX = void 0, this.endingX = void 0, this.overscroll = 0;\n }\n onTouchStart(e) {\n switch (e.stopPropagation(), this.takeOverSnap(), e.touches.length) {\n case 1:\n break;\n case 2:\n this.onTouchEnd(e);\n return;\n default: {\n this.onTouchEnd(e), this.comms.send("tap_more", e.touches.length);\n return;\n }\n }\n this.startingX = e.touches[0].clientX, this.alreadyScrollLeft = this.doc().scrollLeft, this.touchState = 1;\n }\n onTouchEnd(e) {\n if (this.touchState === 2) {\n const t = this.dragOffset(), i = this.scrollOffset();\n this.cachedScrollWidth <= this.wnd.innerWidth ? (this.reportProgress(), t > 5 && this.comms.send("no_more", void 0), t < -5 && this.comms.send("no_less", void 0)) : i < 5 && t < 5 ? (this.alreadyScrollLeft = 0, this.comms.send("no_less", void 0)) : this.cachedScrollWidth - i - this.wnd.innerWidth < 5 && t > 5 && (this.alreadyScrollLeft = this.cachedScrollWidth, this.comms.send("no_more", void 0)), this.snapCurrentOffset(!0), this.comms.send("swipe", t);\n }\n this.touchState = 0;\n }\n onWidthChange() {\n this.cachedScrollWidth = this.doc().scrollWidth, this.comms.ready && this.snapCurrentOffset();\n }\n onTouchMove(e) {\n if (this.touchState === 0) return;\n this.touchState === 1 && (this.touchState = 2, v(this.wnd)), this.endingX = e.touches[0].clientX;\n const t = this.dragOffset(), i = this.alreadyScrollLeft + t;\n i < 0 ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-this.overscroll}px, 0px, 0px)`) : i + this.wnd.innerWidth > this.cachedScrollWidth ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-i}px, 0px, 0px)`) : (this.overscroll = 0, this.doc().style.removeProperty("transform"), this.doc().scrollLeft = this.alreadyScrollLeft + t);\n }\n mount(e, t) {\n if (this.wnd = e, this.comms = t, !super.mount(e, t)) return !1;\n e.navigator.epubReadingSystem && (e.navigator.epubReadingSystem.layoutStyle = "paginated");\n const i = e.document.createElement("style");\n i.dataset.readium = "true", i.id = We, i.textContent = `\n @keyframes readium-bounce-l-animation {\n 0%, 100% {transform: translate3d(0, 0, 0);}\n 50% {transform: translate3d(-50px, 0, 0);}\n }\n\n @keyframes readium-bounce-r-animation {\n 0%, 100% {transform: translate3d(0, 0, 0);}\n 50% {transform: translate3d(50px, 0, 0);}\n }\n\n .readium-bounce-l {\n animation: readium-bounce-l-animation 150ms ease-out 1;\n }\n\n .readium-bounce-r {\n animation: readium-bounce-r-animation 150ms ease-out 1;\n }\n\n html {\n overflow: hidden;\n }\n\n body {\n -ms-overflow-style: none; /* for Internet Explorer, Edge */\n }\n\n * {\n scrollbar-width: none; /* for Firefox */\n }\n \n body::-webkit-scrollbar {\n display: none; /* for Chrome, Safari, and Opera */\n }\n `, e.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {\n e.requestAnimationFrame(() => {\n e && De(e);\n }), this.onWidthChange();\n }), this.resizeObserver.observe(e.document.body), this.mutationObserver = new MutationObserver((n) => {\n for (const o of n)\n if (o.target === this.wnd.document.documentElement) {\n const l = o.oldValue, u = o.target.getAttribute("style"), h = /transform\\s*:\\s*([^;]+)/, c = l?.match(h), m = u?.match(h);\n (!c && !m || c && !m || c && m && c[1] !== m[1]) && (e.requestAnimationFrame(() => {\n e && De(e);\n }), this.onWidthChange());\n } else\n e.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth);\n }), e.frameElement && this.mutationObserver.observe(e.frameElement, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(e.document, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(e.document.documentElement, { attributes: !0, attributeFilter: ["style"] });\n const s = (n) => {\n const o = this.doc().scrollLeft;\n return this.doc().scrollLeft = this.snapOffset(n), o !== this.doc().scrollLeft;\n };\n return e.addEventListener("orientationchange", this.onWidthChanger), e.addEventListener("resize", this.onWidthChanger), e.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), t.register("go_progression", x.moduleName, (n, o) => {\n const l = n;\n if (l < 0 || l > 1) {\n t.send("error", {\n message: "go_progression must be given a position from 0.0 to 1.0"\n }), o(!1);\n return;\n }\n this.wnd.requestAnimationFrame(() => {\n this.cachedScrollWidth = this.doc().scrollWidth;\n const u = this.cachedScrollWidth, h = z(e) ? -1 : 1, c = u * l * h;\n this.doc().scrollLeft = this.snapOffset(c), this.reportProgress(), v(this.wnd), o(!0);\n });\n }), t.register("go_id", x.moduleName, (n, o) => {\n const l = e.document.getElementById(n);\n if (!l) {\n o(!1);\n return;\n }\n this.wnd.requestAnimationFrame(() => {\n this.doc().scrollLeft = this.snapOffset(l.getBoundingClientRect().left + e.scrollX), this.reportProgress(), v(this.wnd), o(!0);\n });\n }), t.register("go_text", x.moduleName, (n, o) => {\n let l;\n Array.isArray(n) && (n.length > 1 && (l = n[1]), n = n[0]);\n const u = D.deserialize(n), h = ee(this.wnd.document, new I({\n href: e.location.href,\n type: "text/html",\n text: u,\n locations: l ? new b({\n otherLocations: /* @__PURE__ */ new Map([\n ["cssSelector", l]\n ])\n }) : void 0\n }));\n if (!h) {\n o(!1);\n return;\n }\n this.wnd.requestAnimationFrame(() => {\n this.doc().scrollLeft = this.snapOffset(h.getBoundingClientRect().left + e.scrollX), this.reportProgress(), v(this.wnd), o(!0);\n });\n }), t.register("go_end", x.moduleName, (n, o) => {\n const l = z(e) ? -1 : 1;\n this.wnd.requestAnimationFrame(() => {\n this.cachedScrollWidth = this.doc().scrollWidth;\n const u = this.cachedScrollWidth * l;\n if (this.doc().scrollLeft === u) return o(!1);\n this.doc().scrollLeft = this.snapOffset(u), this.reportProgress(), v(this.wnd), o(!0);\n });\n }), t.register("go_start", x.moduleName, (n, o) => {\n this.wnd.requestAnimationFrame(() => {\n if (this.doc().scrollLeft === 0) return o(!1);\n this.doc().scrollLeft = 0, this.reportProgress(), v(this.wnd), o(!0);\n });\n }), t.register("go_prev", x.moduleName, (n, o) => {\n this.wnd.requestAnimationFrame(() => {\n this.cachedScrollWidth = this.doc().scrollWidth;\n const l = e.scrollX - e.innerWidth, u = z(e) ? -(this.cachedScrollWidth - e.innerWidth) : 0, h = s(Math.max(l, u));\n h && (this.reportProgress(), v(this.wnd)), o(h);\n });\n }), t.register("go_next", x.moduleName, (n, o) => {\n this.wnd.requestAnimationFrame(() => {\n this.cachedScrollWidth = this.doc().scrollWidth;\n const l = e.scrollX + e.innerWidth, u = z(e) ? 0 : this.cachedScrollWidth - e.innerWidth, h = s(Math.min(l, u));\n h && (this.reportProgress(), v(this.wnd)), o(h);\n });\n }), t.register("unfocus", x.moduleName, (n, o) => {\n this.snappingCancelled = !0, v(this.wnd), o(!0);\n }), t.register("shake", x.moduleName, (n, o) => {\n this.shake(), o(!0);\n }), t.register("focus", x.moduleName, (n, o) => {\n this.wnd.requestAnimationFrame(() => {\n this.cachedScrollWidth = this.doc().scrollWidth, this.snapCurrentOffset(!1, !0), this.reportProgress(), o(!0);\n });\n }), t.register("first_visible_locator", x.moduleName, (n, o) => {\n const l = be(e, !1);\n this.comms.send("first_visible_locator", l.serialize()), o(!0);\n }), e.addEventListener("touchstart", this.onTouchStarter, { passive: !0 }), e.addEventListener("touchend", this.onTouchEnder, { passive: !0 }), e.addEventListener("touchmove", this.onTouchMover, { passive: !0 }), e.document.addEventListener("touchstart", () => {\n }), t.log("ColumnSnapper Mounted"), !0;\n }\n unmount(e, t) {\n return this.snappingCancelled = !0, t.unregisterAll(x.moduleName), this.resizeObserver.disconnect(), this.mutationObserver.disconnect(), e.removeEventListener("touchstart", this.onTouchStarter), e.removeEventListener("touchend", this.onTouchEnder), e.removeEventListener("touchmove", this.onTouchMover), e.removeEventListener("orientationchange", this.onWidthChanger), e.removeEventListener("resize", this.onWidthChanger), e.document.getElementById(We)?.remove(), t.log("ColumnSnapper Unmounted"), super.unmount(e, t);\n }\n};\nx.moduleName = "column_snapper";\nlet ne = x;\nconst Fe = "readium-scroll-snapper-style", T = class T extends q {\n constructor() {\n super(...arguments), this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce = null, this.handleScroll = () => {\n if (this.comms.ready && !this.isResizing) {\n if (!this.initialScrollHandled) {\n this.lastScrollTop = this.doc().scrollTop, this.initialScrollHandled = !0, this.reportProgress();\n return;\n }\n this.isScrolling || (this.isScrolling = !0, this.wnd.requestAnimationFrame(() => {\n this.reportProgress();\n const e = this.doc().scrollTop, t = e - this.lastScrollTop;\n this.lastScrollTop = e, this.comms.send("scroll", t), this.isScrolling = !1;\n }));\n }\n };\n }\n doc() {\n return this.wnd.document.scrollingElement;\n }\n reportProgress() {\n if (!this.comms.ready) return;\n const e = Math.ceil(this.doc().scrollTop), t = this.doc().scrollHeight, i = this.wnd.innerHeight, s = Math.max(0, Math.min(1, e / t)), n = Math.max(0, Math.min(1, (e + i) / t));\n this.comms.send("progress", {\n start: s,\n end: n\n });\n }\n mount(e, t) {\n this.wnd = e, this.comms = t, this.initialScrollHandled = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce && (this.wnd.clearTimeout(this.resizeDebounce), this.resizeDebounce = null), e.navigator.epubReadingSystem && (e.navigator.epubReadingSystem.layoutStyle = "scrolling");\n const i = e.document.createElement("style");\n return i.dataset.readium = "true", i.id = Fe, i.textContent = `\n * {\n scrollbar-width: none; /* for Firefox */\n }\n \n body::-webkit-scrollbar {\n display: none; /* for Chrome, Safari, and Opera */\n }\n `, e.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {\n this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {\n this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();\n }, 50);\n }), this.resizeObserver.observe(e.document.body), e.addEventListener("scroll", this.handleScroll, { passive: !0 }), t.register("force_webkit_recalc", T.moduleName, () => {\n Ze(this.wnd);\n const s = this.doc().scrollTop;\n s > 1 ? this.doc().scrollTop = s - 1 : this.doc().scrollTop = s + 1, this.doc().scrollTop = s;\n }), t.register("go_progression", T.moduleName, (s, n) => {\n const o = s;\n if (o < 0 || o > 1) {\n t.send("error", {\n message: "go_progression must be given a position from 0.0 to 1.0"\n }), n(!1);\n return;\n }\n this.wnd.requestAnimationFrame(() => {\n this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(), v(this.wnd), n(!0);\n });\n }), t.register("go_id", T.moduleName, (s, n) => {\n const o = e.document.getElementById(s);\n if (!o) {\n n(!1);\n return;\n }\n this.wnd.requestAnimationFrame(() => {\n this.doc().scrollTop = o.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), v(this.wnd), n(!0);\n });\n }), t.register("go_text", T.moduleName, (s, n) => {\n let o;\n Array.isArray(s) && (s.length > 1 && (o = s[1]), s = s[0]);\n const l = D.deserialize(s), u = ee(this.wnd.document, new I({\n href: e.location.href,\n type: "text/html",\n text: l,\n locations: o ? new b({\n otherLocations: /* @__PURE__ */ new Map([\n ["cssSelector", o]\n ])\n }) : void 0\n }));\n if (!u) {\n n(!1);\n return;\n }\n this.wnd.requestAnimationFrame(() => {\n this.doc().scrollTop = u.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), v(this.wnd), n(!0);\n });\n }), t.register("go_start", T.moduleName, (s, n) => {\n if (this.doc().scrollTop === 0) return n(!1);\n this.doc().scrollTop = 0, this.reportProgress(), n(!0);\n }), t.register("go_end", T.moduleName, (s, n) => {\n if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return n(!1);\n this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), n(!0);\n }), t.register("unfocus", T.moduleName, (s, n) => {\n v(this.wnd), n(!0);\n }), t.register([\n "go_next",\n "go_prev"\n ], T.moduleName, (s, n) => n(!1)), t.register("focus", T.moduleName, (s, n) => {\n this.reportProgress(), n(!0);\n }), t.register("first_visible_locator", T.moduleName, (s, n) => {\n const o = be(e, !0);\n this.comms.send("first_visible_locator", o.serialize()), n(!0);\n }), t.log("ScrollSnapper Mounted"), !0;\n }\n unmount(e, t) {\n return t.unregisterAll(T.moduleName), this.resizeObserver.disconnect(), this.handleScroll && e.removeEventListener("scroll", this.handleScroll), e.document.getElementById(Fe)?.remove(), t.log("ScrollSnapper Unmounted"), !0;\n }\n};\nT.moduleName = "scroll_snapper";\nlet oe = T;\nconst w = class w extends q {\n constructor() {\n super(...arguments), this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce = null, this.handleScroll = () => {\n if (this.comms.ready && !this.isResizing) {\n if (!this.initialScrollHandled) {\n this.lastScrollTop = this.doc().scrollTop, this.initialScrollHandled = !0, this.reportProgress();\n return;\n }\n this.isScrolling || (this.isScrolling = !0, this.wnd.requestAnimationFrame(() => {\n this.reportProgress();\n const e = this.doc().scrollTop, t = e - this.lastScrollTop;\n this.lastScrollTop = e, this.comms.send("scroll", t), this.isScrolling = !1;\n }));\n }\n };\n }\n doc() {\n return this.wnd.document.scrollingElement;\n }\n reportProgress() {\n if (!this.comms.ready) return;\n const e = Math.ceil(this.doc().scrollTop), t = this.doc().scrollHeight, i = this.wnd.innerHeight, s = Math.max(0, Math.min(1, e / t)), n = Math.max(0, Math.min(1, (e + i) / t));\n this.comms.send("progress", {\n start: s,\n end: n\n });\n }\n mount(e, t) {\n return this.wnd = e, this.comms = t, this.initialScrollHandled = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce && (this.wnd.clearTimeout(this.resizeDebounce), this.resizeDebounce = null), this.resizeObserver = new ResizeObserver(() => {\n this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {\n this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();\n }, 50);\n }), this.resizeObserver.observe(e.document.body), e.addEventListener("scroll", this.handleScroll, { passive: !0 }), t.register("force_webkit_recalc", w.moduleName, () => {\n Ze(this.wnd);\n const i = this.doc().scrollTop;\n i > 1 ? this.doc().scrollTop = i - 1 : this.doc().scrollTop = i + 1, this.doc().scrollTop = i;\n }), t.register("go_progression", w.moduleName, (i, s) => {\n const n = i;\n if (n < 0 || n > 1) {\n t.send("error", {\n message: "go_progression must be given a position from 0.0 to 1.0"\n }), s(!1);\n return;\n }\n this.wnd.requestAnimationFrame(() => {\n this.doc().scrollTop = this.doc().offsetHeight * n, this.reportProgress(), v(this.wnd), s(!0);\n });\n }), this.comms.register("go_id", w.moduleName, (i, s) => {\n const n = e.document.getElementById(i);\n if (!n) {\n s(!1);\n return;\n }\n this.wnd.requestAnimationFrame(() => {\n this.doc().scrollTop = n.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), v(this.wnd), s(!0);\n });\n }), t.register("go_text", w.moduleName, (i, s) => {\n let n;\n Array.isArray(i) && (i.length > 1 && (n = i[1]), i = i[0]);\n const o = D.deserialize(i), l = ee(this.wnd.document, new I({\n href: e.location.href,\n type: "text/html",\n text: o,\n locations: n ? new b({\n otherLocations: /* @__PURE__ */ new Map([\n ["cssSelector", n]\n ])\n }) : void 0\n }));\n if (!l) {\n s(!1);\n return;\n }\n this.wnd.requestAnimationFrame(() => {\n this.doc().scrollTop = l.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2, this.reportProgress(), v(this.wnd), s(!0);\n });\n }), t.register("go_start", w.moduleName, (i, s) => {\n if (this.doc().scrollTop === 0) return s(!1);\n this.doc().scrollTop = 0, this.reportProgress(), s(!0);\n }), t.register("go_end", w.moduleName, (i, s) => {\n if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return s(!1);\n this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), s(!0);\n }), t.register("unfocus", w.moduleName, (i, s) => {\n v(this.wnd), s(!0);\n }), t.register([\n "go_next",\n "go_prev"\n ], w.moduleName, (i, s) => s(!1)), t.register("focus", w.moduleName, (i, s) => {\n this.reportProgress(), s(!0);\n }), t.register("first_visible_locator", w.moduleName, (i, s) => {\n const n = be(e, !0);\n t.send("first_visible_locator", n.serialize()), s(!0);\n }), t.log("WebPubSnapper Mounted"), !0;\n }\n unmount(e, t) {\n return t.unregisterAll(w.moduleName), this.resizeObserver.disconnect(), this.handleScroll && e.removeEventListener("scroll", this.handleScroll), t.log("WebPubSnapper Unmounted"), !0;\n }\n};\nw.moduleName = "webpub_snapper";\nlet ae = w;\nconst Ee = class Ee extends X {\n constructor() {\n super(...arguments), this.pointerMoved = !1, this.onPointerUp = this.onPointUp.bind(this), this.onPointerMove = this.onPointMove.bind(this), this.onPointerDown = this.onPointDown.bind(this), this.onContextMenu = this.onContext.bind(this), this.onClicker = this.onClick.bind(this);\n }\n onPointUp(e) {\n const t = this.wnd.getSelection();\n if (t && t.toString()?.length > 0) {\n const s = t.getRangeAt(0)?.getClientRects();\n if (!s || s.length === 0)\n return;\n const n = s[0], o = {\n text: t.toString(),\n x: n.x,\n y: n.y,\n width: n.width,\n height: n.height,\n targetFrameSrc: this.wnd?.location?.href\n };\n this.comms.send("text_selected", o);\n }\n if (this.pointerMoved) {\n this.pointerMoved = !1;\n return;\n }\n if (!t?.isCollapsed || !e.isPrimary) return;\n const i = this.wnd.devicePixelRatio;\n e.preventDefault(), this.comms.send(e.pointerType === "touch" ? "tap" : "click", {\n defaultPrevented: e.defaultPrevented,\n x: e.clientX * i,\n y: e.clientY * i,\n targetFrameSrc: this.wnd.location.href,\n targetElement: e.target.outerHTML,\n interactiveElement: Je(e.target)?.outerHTML,\n cssSelector: this.wnd._readium_cssSelectorGenerator.getCssSelector(e.target)\n }), this.pointerMoved = !1;\n }\n onPointMove(e) {\n if (e.movementY !== void 0 && e.movementX !== void 0) {\n (Math.abs(e.movementX) > 1 || Math.abs(e.movementY) > 1) && (this.pointerMoved = !0);\n return;\n }\n this.pointerMoved = !0;\n }\n onPointDown() {\n this.pointerMoved = !1;\n }\n onContext(e) {\n this.onPointUp(e), this.pointerMoved = !1;\n }\n onClick(e) {\n if (e.preventDefault(), !e.isTrusted) {\n const t = new PointerEvent("pointerup", {\n isPrimary: !0,\n pointerType: "mouse",\n // Not really a better choice than this\n clientX: e.clientX,\n clientY: e.clientY\n });\n Object.defineProperty(t, "target", { writable: !1, value: e.target }), Object.defineProperty(t, "defaultPrevented", { writable: !1, value: e.defaultPrevented }), this.onPointUp(t);\n }\n }\n mount(e, t) {\n return this.wnd = e, this.comms = t, e.document.addEventListener("pointerdown", this.onPointerDown), e.document.addEventListener("pointerup", this.onPointerUp), e.document.addEventListener("contextmenu", this.onContextMenu), e.document.addEventListener("pointermove", this.onPointerMove), e.document.addEventListener("click", this.onClicker), t.log("Peripherals Mounted"), !0;\n }\n unmount(e, t) {\n return e.document.removeEventListener("pointerdown", this.onPointerDown), e.document.removeEventListener("pointerup", this.onPointerUp), e.document.removeEventListener("contextmenu", this.onContextMenu), e.document.removeEventListener("pointermove", this.onPointerMove), e.document.removeEventListener("click", this.onClicker), t.log("Peripherals Unmounted"), !0;\n }\n};\nEe.moduleName = "peripherals";\nlet le = Ee;\nconst V = class V extends X {\n constructor() {\n super(...arguments), this.mediaPlayingCount = 0, this.allAnimations = /* @__PURE__ */ new Set();\n }\n wndOnErr(e) {\n this.comms?.send("error", {\n message: e.message,\n filename: e.filename,\n lineno: e.lineno,\n colno: e.colno\n });\n }\n unblock(e) {\n for (e._readium_blockEvents = !1; e._readium_blockedEvents?.length > 0; ) {\n const t = e._readium_blockedEvents.shift();\n switch (t[0]) {\n case 0:\n Reflect.apply(t[1], t[2], t[3]);\n break;\n case 1:\n const i = t[1], s = t[2];\n e.removeEventListener(i.type, e._readium_eventBlocker, !0);\n const n = new Event(i.type, {\n bubbles: i.bubbles,\n cancelable: i.cancelable\n });\n s ? s.dispatchEvent(n) : e.dispatchEvent(n);\n break;\n }\n }\n }\n onMediaPlayEvent() {\n this.mediaPlayingCount++, this.comms?.send("media_play", this.mediaPlayingCount);\n }\n onMediaPauseEvent() {\n this.mediaPlayingCount > 0 && this.mediaPlayingCount--, this.comms?.send("media_pause", this.mediaPlayingCount);\n }\n pauseAllMedia(e) {\n const t = e.document.querySelectorAll("audio,video");\n for (let i = 0; i < t.length; i++)\n t[i].pause();\n }\n mount(e, t) {\n this.comms = t, e.addEventListener(\n "error",\n this.wndOnErr,\n !1\n ), Reflect.defineProperty(e.navigator, "epubReadingSystem", {\n value: {\n name: "readium-ts-toolkit",\n version: "2.2.1",\n hasFeature: (s, n = "") => {\n switch (s) {\n case "dom-manipulation":\n return !0;\n case "layout-changes":\n return !0;\n case "touch-events":\n return !0;\n case "mouse-events":\n return !0;\n case "keyboard-events":\n return !0;\n case "spine-scripting":\n return !0;\n case "embedded-web-content":\n return !0;\n default:\n return !1;\n }\n }\n },\n writable: !1\n }), "getAnimations" in e.document && e.document.getAnimations().forEach((s) => {\n s.cancel(), this.allAnimations.add(s);\n }), t.register("activate", V.moduleName, (s, n) => {\n this.allAnimations.forEach((o) => {\n o.cancel(), o.play();\n }), n(!0);\n }), t.register("unfocus", V.moduleName, (s, n) => {\n this.pauseAllMedia(e), this.allAnimations.forEach((o) => o.pause()), n(!0);\n });\n const i = e.document.querySelectorAll("audio,video");\n for (let s = 0; s < i.length; s++) {\n const n = i[s];\n n.addEventListener("play", this.onMediaPlayEvent, {\n passive: !0\n }), n.addEventListener("pause", this.onMediaPauseEvent, {\n passive: !0\n });\n }\n return t.log("Setup Mounted"), !0;\n }\n unmount(e, t) {\n return e.removeEventListener("error", this.wndOnErr), e.removeEventListener("play", this.onMediaPlayEvent), e.removeEventListener("pause", this.onMediaPauseEvent), this.allAnimations.forEach((i) => i.cancel()), this.allAnimations.clear(), t.log("Setup Unmounted"), !0;\n }\n};\nV.moduleName = "setup";\nlet Q = V;\nconst Ue = "readium-viewport", O = class O extends Q {\n onViewportWidthChanged(e) {\n const t = e.target;\n j(t, "--RS__viewportWidth", `${t.innerWidth}px`);\n }\n mount(e, t) {\n if (!super.mount(e, t)) return !1;\n const i = e.document.createElement("meta");\n return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id", Ue), i.setAttribute(\n "content",\n "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"\n ), e.document.head.appendChild(i), e.addEventListener("orientationchange", this.onViewportWidthChanged), e.addEventListener("resize", this.onViewportWidthChanged), this.onViewportWidthChanged({\n target: e\n }), t.register("get_properties", O.moduleName, (s, n) => {\n ve(e), n(!0);\n }), t.register("update_properties", O.moduleName, (s, n) => {\n s["--RS__viewportWidth"] = `${e.innerWidth}px`, Ye(e, s), n(!0);\n }), t.register("set_property", O.moduleName, (s, n) => {\n const o = s;\n j(e, o[0], o[1]), n(!0);\n }), t.register("remove_property", O.moduleName, (s, n) => {\n te(e, s), n(!0);\n }), t.register("activate", O.moduleName, (s, n) => {\n this.unblock(e), n(!0);\n }), t.log("ReflowableSetup Mounted"), !0;\n }\n unmount(e, t) {\n return t.unregisterAll(O.moduleName), e.document.head.querySelector(`#${Ue}`)?.remove(), e.removeEventListener("orientationchange", this.onViewportWidthChanged), t.log("ReflowableSetup Unmounted"), super.unmount(e, t);\n }\n};\nO.moduleName = "reflowable_setup";\nlet he = O;\nconst Be = "readium-fixed-style", A = class A extends Q {\n mount(e, t) {\n if (!super.mount(e, t)) return !1;\n e.navigator.epubReadingSystem && (e.navigator.epubReadingSystem.layoutStyle = "paginated");\n const i = e.document.createElement("style");\n return i.id = Be, i.dataset.readium = "true", i.textContent = `\n html, body {\n text-size-adjust: none;\n -ms-text-size-adjust: none;\n -webkit-text-size-adjust: none;\n -moz-text-size-adjust: none;\n\n /* Fight Safari pinches */\n touch-action: none !important;\n min-height: 100%;\n\n /*cursor: var() TODO*/\n }`, e.document.head.appendChild(i), t.register("set_property", A.moduleName, (s, n) => {\n const o = s;\n j(e, o[0], o[1]), n(!0);\n }), t.register("remove_property", A.moduleName, (s, n) => {\n te(e, s), n(!0);\n }), t.register("first_visible_locator", A.moduleName, (s, n) => n(!1)), t.register("unfocus", A.moduleName, (s, n) => {\n v(e), n(!0);\n }), t.register([\n "focus",\n "go_next",\n "go_prev",\n "go_id",\n "go_end",\n "go_start",\n "go_text",\n "go_progression"\n ], A.moduleName, (s, n) => n(!0)), t.register("activate", A.moduleName, (s, n) => {\n this.unblock(e), n(!0);\n }), t.log("FixedSetup Mounted"), !0;\n }\n unmount(e, t) {\n return t.unregisterAll(A.moduleName), e.document.getElementById(Be)?.remove(), t.log("FixedSetup Unmounted"), super.unmount(e, t);\n }\n};\nA.moduleName = "fixed_setup";\nlet ce = A;\nconst L = class L extends X {\n wndOnErr(e) {\n this.comms?.send("error", {\n message: e.message,\n filename: e.filename,\n lineno: e.lineno,\n colno: e.colno\n });\n }\n mount(e, t) {\n return this.comms = t, e.addEventListener(\n "error",\n this.wndOnErr,\n !1\n ), t.register("get_properties", L.moduleName, (i, s) => {\n ve(e), s(!0);\n }), t.register("update_properties", L.moduleName, (i, s) => {\n Ye(e, i), s(!0);\n }), t.register("set_property", L.moduleName, (i, s) => {\n const n = i;\n j(e, n[0], n[1]), s(!0);\n }), t.register("remove_property", L.moduleName, (i, s) => {\n te(e, i), s(!0);\n }), t.register("activate", L.moduleName, (i, s) => {\n s(!0);\n }), t.log("WebPubSetup Mounted"), !0;\n }\n unmount(e, t) {\n return t.unregisterAll(L.moduleName), e.removeEventListener("error", this.wndOnErr), t.log("WebPubSetup Unmounted"), !0;\n }\n};\nL.moduleName = "webpub_setup";\nlet ue = L;\nconst Rt = [\n "fixed_setup",\n "decorator",\n "peripherals"\n], zt = [\n "reflowable_setup",\n "decorator",\n "peripherals",\n "column_snapper",\n "scroll_snapper"\n], Dt = [\n "webpub_setup",\n "webpub_snapper",\n "decorator",\n "peripherals"\n], He = new Map([\n // All modules go here\n ce,\n he,\n ue,\n ae,\n le,\n re,\n ne,\n oe\n].map((r) => [r.moduleName, r]));\nclass Wt {\n /**\n * @param wnd Window instance to operate on\n * @param initialModules List of initial modules to load\n */\n constructor(e = window, t = []) {\n this.loadedModules = [], this.wnd = e, this.comms = new it(e);\n const i = [...new Set(t)];\n if (i.length) {\n if (typeof e > "u")\n throw Error("Loader is not in a web browser");\n e.parent !== e && this.comms.log("Loader is probably in a frame"), this.loadedModules = i.map((s) => {\n const n = this.loadModule(s);\n if (n)\n return n.mount(this.wnd, this.comms), n;\n }).filter((s) => s !== void 0);\n }\n }\n loadModule(e) {\n const t = He.get(e);\n return t === void 0 ? (this.comms.log(`Module "${name}" does not exist in the library`), t) : new t();\n }\n /**\n * Add a module by name\n * @param moduleName Module name\n * @returns Success\n */\n addModule(e) {\n const t = this.loadModule(e);\n return !t || !t.mount(this.wnd, this.comms) ? !1 : (this.loadedModules.push(t), !0);\n }\n /**\n * Remove a module by name\n * @param moduleName Module name\n * @returns Success\n */\n removeModule(e) {\n const t = He.get(e);\n if (t === void 0)\n return this.comms.log(`Module "${e}" does not exist in the library`), !1;\n const i = this.loadedModules.findIndex((s) => s instanceof t);\n return i < 0 ? !1 : (this.loadedModules[i].unmount(this.wnd, this.comms), this.loadedModules.splice(i, 1), !0);\n }\n /**\n * Unmount and remove all modules\n */\n destroy() {\n this.comms.destroy(), this.loadedModules.forEach((e) => e.unmount(this.wnd, this.comms)), this.loadedModules = [];\n }\n}\n\n\n\n//# sourceURL=webpack:///./node_modules/@readium/navigator-html-injectables/dist/index.js?')},"./node_modules/@readium/navigator/dist/index.js":(__unused_webpack___webpack_module__,__webpack_exports__,__webpack_require__)=>{eval('__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ BooleanPreference: () => (/* binding */ z),\n/* harmony export */ EnumPreference: () => (/* binding */ Ki),\n/* harmony export */ EpubDefaults: () => (/* binding */ Jn),\n/* harmony export */ EpubNavigator: () => (/* binding */ tA),\n/* harmony export */ EpubPreferences: () => (/* binding */ It),\n/* harmony export */ EpubPreferencesEditor: () => (/* binding */ hi),\n/* harmony export */ EpubSettings: () => (/* binding */ ci),\n/* harmony export */ ExperimentalWebPubNavigator: () => (/* binding */ ir),\n/* harmony export */ FXLCoordinator: () => (/* binding */ Tn),\n/* harmony export */ FXLFrameManager: () => (/* binding */ Yn),\n/* harmony export */ FXLFramePoolManager: () => (/* binding */ kn),\n/* harmony export */ FXLPeripherals: () => (/* binding */ bn),\n/* harmony export */ FXLSpreader: () => (/* binding */ jn),\n/* harmony export */ FrameComms: () => (/* binding */ wt),\n/* harmony export */ FrameManager: () => (/* binding */ zn),\n/* harmony export */ FramePoolManager: () => (/* binding */ Qn),\n/* harmony export */ HorizontalThird: () => (/* binding */ Nn),\n/* harmony export */ LineLengths: () => (/* binding */ ft),\n/* harmony export */ Navigator: () => (/* binding */ dA),\n/* harmony export */ Orientation: () => (/* binding */ le),\n/* harmony export */ Preference: () => (/* binding */ Q),\n/* harmony export */ Properties: () => (/* binding */ Ce),\n/* harmony export */ RSProperties: () => (/* binding */ qn),\n/* harmony export */ RangePreference: () => (/* binding */ F),\n/* harmony export */ ReadiumCSS: () => (/* binding */ _n),\n/* harmony export */ Spread: () => (/* binding */ he),\n/* harmony export */ TextAlignment: () => (/* binding */ X),\n/* harmony export */ UserProperties: () => (/* binding */ $i),\n/* harmony export */ VerticalThird: () => (/* binding */ xn),\n/* harmony export */ VisualNavigator: () => (/* binding */ wi),\n/* harmony export */ WebAudioEngine: () => (/* binding */ Ar),\n/* harmony export */ WebPubBlobBuilder: () => (/* binding */ wA),\n/* harmony export */ WebPubCSS: () => (/* binding */ fn),\n/* harmony export */ WebPubDefaults: () => (/* binding */ wn),\n/* harmony export */ WebPubFrameManager: () => (/* binding */ un),\n/* harmony export */ WebPubFramePoolManager: () => (/* binding */ mn),\n/* harmony export */ WebPubNavigator: () => (/* binding */ In),\n/* harmony export */ WebPubPreferences: () => (/* binding */ Et),\n/* harmony export */ WebPubPreferencesEditor: () => (/* binding */ Ai),\n/* harmony export */ WebPubSettings: () => (/* binding */ ii),\n/* harmony export */ WebUserProperties: () => (/* binding */ Zi),\n/* harmony export */ ensureBoolean: () => (/* binding */ y),\n/* harmony export */ ensureEnumValue: () => (/* binding */ Lt),\n/* harmony export */ ensureFilter: () => (/* binding */ dt),\n/* harmony export */ ensureLessThanOrEqual: () => (/* binding */ Mn),\n/* harmony export */ ensureMoreThanOrEqual: () => (/* binding */ Bn),\n/* harmony export */ ensureNonNegative: () => (/* binding */ I),\n/* harmony export */ ensureString: () => (/* binding */ Y),\n/* harmony export */ ensureValueInRange: () => (/* binding */ J),\n/* harmony export */ filterRangeConfig: () => (/* binding */ nt),\n/* harmony export */ fontSizeRangeConfig: () => (/* binding */ bt),\n/* harmony export */ fontWeightRangeConfig: () => (/* binding */ $),\n/* harmony export */ fontWidthRangeConfig: () => (/* binding */ jt),\n/* harmony export */ letterSpacingRangeConfig: () => (/* binding */ Vt),\n/* harmony export */ lineHeightRangeConfig: () => (/* binding */ vt),\n/* harmony export */ lineLengthRangeConfig: () => (/* binding */ rt),\n/* harmony export */ paragraphIndentRangeConfig: () => (/* binding */ Dt),\n/* harmony export */ paragraphSpacingRangeConfig: () => (/* binding */ Ht),\n/* harmony export */ sML: () => (/* binding */ Mt),\n/* harmony export */ sMLWithRequest: () => (/* binding */ U),\n/* harmony export */ withFallback: () => (/* binding */ qt),\n/* harmony export */ wordSpacingRangeConfig: () => (/* binding */ Gt),\n/* harmony export */ zoomRangeConfig: () => (/* binding */ kt)\n/* harmony export */ });\nconst W = class ot {\n constructor(t) {\n if (typeof t == "string") {\n if (!ot.VALID_MODES.has(t.toLowerCase()))\n return;\n this.value = t.toLowerCase();\n } else {\n const e = t.filter(\n (i) => ot.VALID_MODES.has(i.toLowerCase())\n );\n if (e.length === 0)\n return;\n this.value = Array.from(new Set(e));\n }\n }\n /**\n * Parses a [PrimaryAccessMode] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (!t) return;\n if (typeof t == "string")\n return new ot(t);\n if (!Array.isArray(t)) return;\n const e = t.filter((i) => i ? ot.VALID_MODES.has(i.toLowerCase()) : !1);\n if (e.length !== 0)\n return new ot(e);\n }\n /**\n * Serializes a [PrimaryAccessMode] to its RWPM JSON representation.\n */\n serialize() {\n return this.value;\n }\n};\nW.VALID_MODES = /* @__PURE__ */ new Set(["auditory", "tactile", "textual", "visual"]), W.AUDITORY = new W("auditory"), W.TACTILE = new W("tactile"), W.TEXTUAL = new W("textual"), W.VISUAL = new W("visual");\nconst f = class di {\n constructor(t) {\n this.value = t;\n }\n /**\n * Parses a [Feature] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (!(!t || typeof t != "string"))\n return new di(t);\n }\n /**\n * Serializes a [Feature] to its RWPM JSON representation.\n */\n serialize() {\n return this.value;\n }\n};\nf.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");\nlet gi = f;\nvar B = /* @__PURE__ */ ((r) => (r.reflowable = "reflowable", r.fixed = "fixed", r.scrolled = "scrolled", r))(B || {});\nclass ce {\n /**\n * Creates a [Encryption].\n */\n constructor(t) {\n this.algorithm = t.algorithm, this.compression = t.compression, this.originalLength = t.originalLength, this.profile = t.profile, this.scheme = t.scheme;\n }\n /**\n * Parses a [Encryption] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (t && t.algorithm)\n return new ce({\n algorithm: t.algorithm,\n compression: t.compression,\n originalLength: t.originalLength,\n profile: t.profile,\n scheme: t.scheme\n });\n }\n /**\n * Serializes a [Encryption] to its RWPM JSON representation.\n */\n serialize() {\n const t = { algorithm: this.algorithm };\n 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;\n }\n}\nvar H = /* @__PURE__ */ ((r) => (r.left = "left", r.right = "right", r.center = "center", r))(H || {});\nlet G = class ie {\n constructor(t) {\n this.otherProperties = t;\n }\n get page() {\n return this.otherProperties.page;\n }\n /**\n * Creates a [Properties] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (t)\n return new ie(t);\n }\n /**\n * Serializes a [Properties] to its RWPM JSON representation.\n */\n serialize() {\n return this.otherProperties;\n }\n /**\n * Makes a copy of this [Properties] after merging in the given additional other [properties].\n */\n add(t) {\n const e = Object.assign({}, this.otherProperties);\n for (const i in t)\n e[i] = t[i];\n return new ie(e);\n }\n};\nObject.defineProperty(G.prototype, "encryption", {\n get: function() {\n return ce.deserialize(this.otherProperties.encrypted);\n }\n});\nfunction nA(r) {\n return r && Array.isArray(r) ? r : void 0;\n}\nfunction ui(r) {\n return r && typeof r == "string" ? [r] : nA(r);\n}\nfunction Ye(r) {\n return typeof r == "string" ? new Date(r) : void 0;\n}\nfunction Ut(r) {\n return isNaN(r) ? void 0 : r;\n}\nfunction x(r) {\n return Ut(r) !== void 0 && Math.sign(r) >= 0 ? r : void 0;\n}\nfunction rA(r) {\n const t = new Array();\n return r.forEach((e) => t.push(e)), t;\n}\nclass u {\n /** Creates a MediaType object. */\n constructor(t) {\n let e, i, A = t.mediaType.replace(/\\s/g, "").split(";");\n const n = A[0].split("/");\n if (n.length === 2) {\n if (e = n[0].toLowerCase().trim(), i = n[1].toLowerCase().trim(), e.length === 0 || i.length === 0)\n throw new Error("Invalid media type");\n } else\n throw new Error("Invalid media type");\n const s = {};\n for (let g = 1; g < A.length; g++) {\n const M = A[g].split("=");\n if (M.length === 2) {\n const l = M[0].toLocaleLowerCase(), p = l === "charset" ? M[1].toUpperCase() : M[1];\n s[l] = p;\n }\n }\n const o = {}, a = Object.keys(s);\n a.sort((g, M) => g.localeCompare(M)), a.forEach((g) => o[g] = s[g]);\n let h = "";\n for (const g in o) {\n const M = o[g];\n h += `;${g}=${M}`;\n }\n const c = `${e}/${i}${h}`, d = o.encoding;\n this.string = c, this.type = e, this.subtype = i, this.parameters = o, this.encoding = d, this.name = t.name, this.fileExtension = t.fileExtension;\n }\n static parse(t) {\n return new u(t);\n }\n /** Structured syntax suffix, e.g. `+zip` in `application/epub+zip`.\n * Gives a hint on the underlying structure of this media type.\n * See. https://tools.ietf.org/html/rfc6838#section-4.2.8\n */\n get structuredSyntaxSuffix() {\n const t = this.subtype.split("+");\n return t.length > 1 ? `+${t[t.length - 1]}` : void 0;\n }\n /** Parameter values might or might not be case-sensitive, depending on the semantics of\n * the parameter name.\n * https://tools.ietf.org/html/rfc2616#section-3.7\n *\n * The character set names may be up to 40 characters taken from the printable characters\n * of US-ASCII. However, no distinction is made between use of upper and lower case\n * letters.\n * https://www.iana.org/assignments/character-sets/character-sets.xhtml\n */\n get charset() {\n return this.parameters.charset;\n }\n /** Returns whether the given `other` media type is included in this media type.\n * For example, `text/html` contains `text/html;charset=utf-8`.\n * - `other` must match the parameters in the `parameters` property, but extra parameters\n * are ignored.\n * - Order of parameters is ignored.\n * - Wildcards are supported, meaning that `image/*` contains `image/png`\n */\n contains(t) {\n const e = typeof t == "string" ? u.parse({ mediaType: t }) : t;\n if (!((this.type === "*" || this.type === e.type) && (this.subtype === "*" || this.subtype === e.subtype)))\n return !1;\n const i = new Set(\n Object.entries(this.parameters).map(([n, s]) => `${n}=${s}`)\n ), A = new Set(\n Object.entries(e.parameters).map(([n, s]) => `${n}=${s}`)\n );\n for (const n of Array.from(i.values()))\n if (!A.has(n))\n return !1;\n return !0;\n }\n /** Returns whether this media type and `other` are the same, ignoring parameters that\n * are not in both media types.\n * For example, `text/html` matches `text/html;charset=utf-8`, but `text/html;charset=ascii`\n * doesn\'t. This is basically like `contains`, but working in both direction.\n */\n matches(t) {\n const e = typeof t == "string" ? u.parse({ mediaType: t }) : t;\n return this.contains(e) || e.contains(this);\n }\n /**\n * Returns whether this media type matches any of the [others] media types.\n */\n matchesAny(...t) {\n for (const e of t)\n if (this.matches(e))\n return !0;\n return !1;\n }\n /** Checks the MediaType equals another one (comparing their string) */\n equals(t) {\n return this.string === t.string;\n }\n /** Returns whether this media type is structured as a ZIP archive. */\n get isZIP() {\n return this.matchesAny(\n u.ZIP,\n u.LCP_PROTECTED_AUDIOBOOK,\n u.LCP_PROTECTED_PDF\n ) || this.structuredSyntaxSuffix === "+zip";\n }\n /** Returns whether this media type is structured as a JSON file. */\n get isJSON() {\n return this.matchesAny(u.JSON) || this.structuredSyntaxSuffix === "+json";\n }\n /** Returns whether this media type is of an OPDS feed. */\n get isOPDS() {\n return this.matchesAny(\n u.OPDS1,\n u.OPDS1_ENTRY,\n u.OPDS2,\n u.OPDS2_PUBLICATION,\n u.OPDS_AUTHENTICATION\n ) || this.structuredSyntaxSuffix === "+json";\n }\n /** Returns whether this media type is of an HTML document. */\n get isHTML() {\n return this.matchesAny(u.HTML, u.XHTML);\n }\n /** Returns whether this media type is of a bitmap image, so excluding vectorial formats. */\n get isBitmap() {\n return this.matchesAny(\n u.BMP,\n u.GIF,\n u.JPEG,\n u.PNG,\n u.TIFF,\n u.WEBP\n );\n }\n /** Returns whether this media type is of an audio clip. */\n get isAudio() {\n return this.type === "audio";\n }\n /** Returns whether this media type is of a video clip. */\n get isVideo() {\n return this.type === "video";\n }\n /** Returns whether this media type is of a Readium Web Publication Manifest. */\n get isRWPM() {\n return this.matchesAny(\n u.READIUM_AUDIOBOOK_MANIFEST,\n u.DIVINA_MANIFEST,\n u.READIUM_WEBPUB_MANIFEST\n );\n }\n /** Returns whether this media type is of a publication file. */\n get isPublication() {\n return this.matchesAny(\n u.READIUM_AUDIOBOOK,\n u.READIUM_AUDIOBOOK_MANIFEST,\n u.CBZ,\n u.DIVINA,\n u.DIVINA_MANIFEST,\n u.EPUB,\n u.LCP_PROTECTED_AUDIOBOOK,\n u.LCP_PROTECTED_PDF,\n u.LPF,\n u.PDF,\n u.W3C_WPUB_MANIFEST,\n u.READIUM_WEBPUB,\n u.READIUM_WEBPUB_MANIFEST,\n u.ZAB\n );\n }\n // Known Media Types\n static get AAC() {\n return u.parse({ mediaType: "audio/aac", fileExtension: "aac" });\n }\n static get ACSM() {\n return u.parse({\n mediaType: "application/vnd.adobe.adept+xml",\n name: "Adobe Content Server Message",\n fileExtension: "acsm"\n });\n }\n static get AIFF() {\n return u.parse({ mediaType: "audio/aiff", fileExtension: "aiff" });\n }\n static get AVI() {\n return u.parse({\n mediaType: "video/x-msvideo",\n fileExtension: "avi"\n });\n }\n static get BINARY() {\n return u.parse({ mediaType: "application/octet-stream" });\n }\n static get BMP() {\n return u.parse({ mediaType: "image/bmp", fileExtension: "bmp" });\n }\n static get CBZ() {\n return u.parse({\n mediaType: "application/vnd.comicbook+zip",\n name: "Comic Book Archive",\n fileExtension: "cbz"\n });\n }\n static get CSS() {\n return u.parse({ mediaType: "text/css", fileExtension: "css" });\n }\n static get DIVINA() {\n return u.parse({\n mediaType: "application/divina+zip",\n name: "Digital Visual Narratives",\n fileExtension: "divina"\n });\n }\n static get DIVINA_MANIFEST() {\n return u.parse({\n mediaType: "application/divina+json",\n name: "Digital Visual Narratives",\n fileExtension: "json"\n });\n }\n static get EPUB() {\n return u.parse({\n mediaType: "application/epub+zip",\n name: "EPUB",\n fileExtension: "epub"\n });\n }\n static get GIF() {\n return u.parse({ mediaType: "image/gif", fileExtension: "gif" });\n }\n static get GZ() {\n return u.parse({\n mediaType: "application/gzip",\n fileExtension: "gz"\n });\n }\n static get HTML() {\n return u.parse({ mediaType: "text/html", fileExtension: "html" });\n }\n static get JAVASCRIPT() {\n return u.parse({\n mediaType: "text/javascript",\n fileExtension: "js"\n });\n }\n static get JPEG() {\n return u.parse({ mediaType: "image/jpeg", fileExtension: "jpeg" });\n }\n static get JSON() {\n return u.parse({ mediaType: "application/json" });\n }\n static get LCP_LICENSE_DOCUMENT() {\n return u.parse({\n mediaType: "application/vnd.readium.lcp.license.v1.0+json",\n name: "LCP License",\n fileExtension: "lcpl"\n });\n }\n static get LCP_PROTECTED_AUDIOBOOK() {\n return u.parse({\n mediaType: "application/audiobook+lcp",\n name: "LCP Protected Audiobook",\n fileExtension: "lcpa"\n });\n }\n static get LCP_PROTECTED_PDF() {\n return u.parse({\n mediaType: "application/pdf+lcp",\n name: "LCP Protected PDF",\n fileExtension: "lcpdf"\n });\n }\n static get LCP_STATUS_DOCUMENT() {\n return u.parse({\n mediaType: "application/vnd.readium.license.status.v1.0+json"\n });\n }\n static get LPF() {\n return u.parse({\n mediaType: "application/lpf+zip",\n fileExtension: "lpf"\n });\n }\n static get MP3() {\n return u.parse({ mediaType: "audio/mpeg", fileExtension: "mp3" });\n }\n static get MPEG() {\n return u.parse({ mediaType: "video/mpeg", fileExtension: "mpeg" });\n }\n static get NCX() {\n return u.parse({\n mediaType: "application/x-dtbncx+xml",\n fileExtension: "ncx"\n });\n }\n static get OGG() {\n return u.parse({ mediaType: "audio/ogg", fileExtension: "oga" });\n }\n static get OGV() {\n return u.parse({ mediaType: "video/ogg", fileExtension: "ogv" });\n }\n static get OPDS1() {\n return u.parse({\n mediaType: "application/atom+xml;profile=opds-catalog"\n });\n }\n static get OPDS1_ENTRY() {\n return u.parse({\n mediaType: "application/atom+xml;type=entry;profile=opds-catalog"\n });\n }\n static get OPDS2() {\n return u.parse({ mediaType: "application/opds+json" });\n }\n static get OPDS2_PUBLICATION() {\n return u.parse({ mediaType: "application/opds-publication+json" });\n }\n static get OPDS_AUTHENTICATION() {\n return u.parse({\n mediaType: "application/opds-authentication+json"\n });\n }\n static get OPUS() {\n return u.parse({ mediaType: "audio/opus", fileExtension: "opus" });\n }\n static get OTF() {\n return u.parse({ mediaType: "font/otf", fileExtension: "otf" });\n }\n static get PDF() {\n return u.parse({\n mediaType: "application/pdf",\n name: "PDF",\n fileExtension: "pdf"\n });\n }\n static get PNG() {\n return u.parse({ mediaType: "image/png", fileExtension: "png" });\n }\n static get READIUM_AUDIOBOOK() {\n return u.parse({\n mediaType: "application/audiobook+zip",\n name: "Readium Audiobook",\n fileExtension: "audiobook"\n });\n }\n static get READIUM_AUDIOBOOK_MANIFEST() {\n return u.parse({\n mediaType: "application/audiobook+json",\n name: "Readium Audiobook",\n fileExtension: "json"\n });\n }\n static get READIUM_CONTENT_DOCUMENT() {\n return u.parse({\n mediaType: "application/vnd.readium.content+json",\n name: "Readium Content Document",\n fileExtension: "json"\n });\n }\n static get READIUM_GUIDED_NAVIGATION_DOCUMENT() {\n return u.parse({\n mediaType: "application/guided-navigation+json",\n name: "Readium Guided Navigation Document",\n fileExtension: "json"\n });\n }\n static get READIUM_POSITION_LIST() {\n return u.parse({\n mediaType: "application/vnd.readium.position-list+json",\n name: "Readium Position List",\n fileExtension: "json"\n });\n }\n static get READIUM_WEBPUB() {\n return u.parse({\n mediaType: "application/webpub+zip",\n name: "Readium Web Publication",\n fileExtension: "webpub"\n });\n }\n static get READIUM_WEBPUB_MANIFEST() {\n return u.parse({\n mediaType: "application/webpub+json",\n name: "Readium Web Publication",\n fileExtension: "json"\n });\n }\n static get SMIL() {\n return u.parse({\n mediaType: "application/smil+xml",\n fileExtension: "smil"\n });\n }\n static get SVG() {\n return u.parse({\n mediaType: "image/svg+xml",\n fileExtension: "svg"\n });\n }\n static get TEXT() {\n return u.parse({ mediaType: "text/plain", fileExtension: "txt" });\n }\n static get TIFF() {\n return u.parse({ mediaType: "image/tiff", fileExtension: "tiff" });\n }\n static get TTF() {\n return u.parse({ mediaType: "font/ttf", fileExtension: "ttf" });\n }\n static get W3C_WPUB_MANIFEST() {\n return u.parse({\n mediaType: "application/x.readium.w3c.wpub+json",\n name: "Web Publication",\n fileExtension: "json"\n });\n }\n static get WAV() {\n return u.parse({ mediaType: "audio/wav", fileExtension: "wav" });\n }\n static get WEBM_AUDIO() {\n return u.parse({ mediaType: "audio/webm", fileExtension: "webm" });\n }\n static get WEBM_VIDEO() {\n return u.parse({ mediaType: "video/webm", fileExtension: "webm" });\n }\n static get WEBP() {\n return u.parse({ mediaType: "image/webp", fileExtension: "webp" });\n }\n static get WOFF() {\n return u.parse({ mediaType: "font/woff", fileExtension: "woff" });\n }\n static get WOFF2() {\n return u.parse({ mediaType: "font/woff2", fileExtension: "woff2" });\n }\n static get XHTML() {\n return u.parse({\n mediaType: "application/xhtml+xml",\n fileExtension: "xhtml"\n });\n }\n static get XML() {\n return u.parse({\n mediaType: "application/xml",\n fileExtension: "xml"\n });\n }\n static get ZAB() {\n return u.parse({\n mediaType: "application/x.readium.zab+zip",\n name: "Zipped Audio Book",\n fileExtension: "zab"\n });\n }\n static get ZIP() {\n return u.parse({\n mediaType: "application/zip",\n fileExtension: "zip"\n });\n }\n}\nlet Ne = class {\n constructor(t) {\n this.uri = t, this.parameters = this.getParameters(t);\n }\n /**\n * List of URI template parameter keys, if the [Link] is templated.\n */\n getParameters(t) {\n const e = /\\{\\??([^}]+)\\}/g, i = t.match(e);\n return i ? new Set(\n i.join(",").replace(e, "$1").split(",").map((A) => A.trim())\n ) : /* @__PURE__ */ new Set();\n }\n /** Expands the URI by replacing the template variables by the given parameters.\n * Any extra parameter is appended as query parameters.\n * See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570\n */\n expand(t) {\n const e = (A) => A.split(",").map((n) => {\n const s = t[n];\n return s ? encodeURIComponent(s) : "";\n }).join(","), i = (A) => "?" + A.split(",").map((n) => {\n const s = n.split("=")[0], o = t[s];\n return o ? `${s}=${encodeURIComponent(o)}` : "";\n }).join("&");\n return this.uri.replace(/\\{(\\??)([^}]+)\\}/g, (...A) => A[1] ? i(A[2]) : e(A[2]));\n }\n}, j = class mi {\n /**\n * Creates a [Locations].\n */\n constructor(t) {\n this.fragments = t.fragments ? t.fragments : new Array(), this.progression = t.progression, this.totalProgression = t.totalProgression, this.position = t.position, this.otherLocations = t.otherLocations;\n }\n /**\n * Parses a [Locations] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (!t) return;\n const e = Ut(t.progression), i = Ut(t.totalProgression), A = Ut(t.position), n = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set([\n "fragment",\n "fragments",\n "progression",\n "totalProgression",\n "position"\n ]);\n return Object.entries(t).forEach(([o, a]) => {\n s.has(o) || n.set(o, a);\n }), new mi({\n fragments: ui(t.fragments || t.fragment),\n progression: e !== void 0 && e >= 0 && e <= 1 ? e : void 0,\n totalProgression: i !== void 0 && i >= 0 && i <= 1 ? i : void 0,\n position: A !== void 0 && A > 0 ? A : void 0,\n otherLocations: n.size === 0 ? void 0 : n\n });\n }\n /**\n * Serializes a [Locations] to its RWPM JSON representation.\n */\n serialize() {\n const t = {};\n 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;\n }\n}, sA = class pi {\n /**\n * Creates a [Text].\n */\n constructor(t) {\n this.after = t.after, this.before = t.before, this.highlight = t.highlight;\n }\n /**\n * Parses a [Locations] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (t)\n return new pi({\n after: t.after,\n before: t.before,\n highlight: t.highlight\n });\n }\n /**\n * Serializes a [Locations] to its RWPM JSON representation.\n */\n serialize() {\n const t = {};\n 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;\n }\n}, ht = class Ae {\n /**\n * Creates a [Locator].\n */\n constructor(t) {\n this.href = t.href, this.type = t.type, this.title = t.title, this.locations = t.locations ? t.locations : new j({}), this.text = t.text;\n }\n /**\n * Parses a [Link] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (t && t.href && t.type)\n return new Ae({\n href: t.href,\n type: t.type,\n title: t.title,\n locations: j.deserialize(t.locations),\n text: sA.deserialize(t.text)\n });\n }\n /**\n * Serializes a [Link] to its RWPM JSON representation.\n */\n serialize() {\n const t = { href: this.href, type: this.type };\n return this.title !== void 0 && (t.title = this.title), this.locations && (t.locations = this.locations.serialize()), this.text && (t.text = this.text.serialize()), t;\n }\n /**\n * Shortcut to get a copy of the [Locator] with different [Locations] sub-properties.\n */\n copyWithLocations(t) {\n return new Ae({\n href: this.href,\n type: this.type,\n title: this.title,\n text: this.text,\n locations: new j({ ...this.locations, ...t })\n });\n }\n}, q = class Rt {\n /**\n * Creates a [Link].\n */\n constructor(t) {\n 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;\n }\n /**\n * Parses a [Link] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (!(!t || typeof t.href != "string"))\n return new Rt({\n href: t.href,\n templated: t.templated,\n type: t.type,\n title: t.title,\n rels: t.rel ? Array.isArray(t.rel) ? new Set(t.rel) : /* @__PURE__ */ new Set([t.rel]) : void 0,\n properties: G.deserialize(t.properties),\n height: x(t.height),\n width: x(t.width),\n size: x(t.size),\n duration: x(t.duration),\n bitrate: x(t.bitrate),\n languages: ui(t.language),\n alternates: xe.deserialize(t.alternate),\n children: xe.deserialize(t.children)\n });\n }\n /**\n * Serializes a [Link] to its RWPM JSON representation.\n */\n serialize() {\n const t = { href: this.href };\n 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 = rA(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;\n }\n /** MediaType of the linked resource. */\n get mediaType() {\n return this.type !== void 0 ? u.parse({ mediaType: this.type }) : u.BINARY;\n }\n /** Computes an absolute URL to the link, relative to the given `baseURL`.\n * If the link\'s `href` is already absolute, the `baseURL` is ignored.\n */\n toURL(t) {\n const e = this.href.replace(/^(\\/)/, "");\n if (e.length === 0) return;\n let i = t || "/";\n return i.startsWith("/") && (i = "file://" + i), new URL(e, i).href.replace(/^(file:\\/\\/)/, "");\n }\n /** List of URI template parameter keys, if the `Link` is templated. */\n get templateParameters() {\n return this.templated ? new Ne(this.href).parameters : /* @__PURE__ */ new Set();\n }\n /** Expands the `Link`\'s HREF by replacing URI template variables by the given parameters.\n * See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570\n */\n expandTemplate(t) {\n return new Rt({\n href: new Ne(this.href).expand(t),\n templated: !1\n });\n }\n /**\n * Makes a copy of this [Link] after merging in the given additional other [properties].\n */\n addProperties(t) {\n const e = Rt.deserialize(this.serialize());\n return e.properties = e.properties ? e.properties?.add(t) : new G(t), e;\n }\n /**\n * Creates a [Locator] from a reading order [Link].\n */\n get locator() {\n let t = this.href.split("#");\n return new ht({\n href: t.length > 0 && t[0] !== void 0 ? t[0] : this.href,\n type: this.type ?? "",\n title: this.title,\n locations: new j({\n fragments: t.length > 1 && t[1] !== void 0 ? [t[1]] : []\n })\n });\n }\n}, xe = class fi {\n /**\n * Creates a [Links].\n */\n constructor(t) {\n this.items = t;\n }\n /**\n * Creates a list of [Link] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (t && Array.isArray(t))\n return new fi(\n t.map((e) => q.deserialize(e)).filter((e) => e !== void 0)\n );\n }\n /**\n * Serializes an array of [Link] to its RWPM JSON representation.\n */\n serialize() {\n return this.items.map((t) => t.serialize());\n }\n /** Finds the first link with the given relation. */\n findWithRel(t) {\n const e = (i) => i.rels && i.rels.has(t);\n return this.items.find(e);\n }\n /** Finds all the links with the given relation. */\n filterByRel(t) {\n const e = (i) => i.rels && i.rels.has(t);\n return this.items.filter(e);\n }\n /** Finds the first link matching the given HREF. */\n findWithHref(t) {\n const e = (i) => i.href === t;\n return this.items.find(e);\n }\n /** Finds the index of the first link matching the given HREF. */\n findIndexWithHref(t) {\n const e = (i) => i.href === t;\n return this.items.findIndex(e);\n }\n /** Finds the first link matching the given media type. */\n findWithMediaType(t) {\n const e = (i) => i.mediaType.matches(t);\n return this.items.find(e);\n }\n /** Finds all the links matching the given media type. */\n filterByMediaType(t) {\n const e = (i) => i.mediaType.matches(t);\n return this.items.filter(e);\n }\n /** Finds all the links matching any of the given media types. */\n filterByMediaTypes(t) {\n const e = (i) => {\n for (const A of t)\n if (i.mediaType.matches(A))\n return !0;\n return !1;\n };\n return this.items.filter(e);\n }\n /** Returns whether all the resources in the collection are audio clips. */\n everyIsAudio() {\n const t = (e) => e.mediaType.isAudio;\n return this.items.length > 0 && this.items.every(t);\n }\n /** Returns whether all the resources in the collection are bitmaps. */\n everyIsBitmap() {\n const t = (e) => e.mediaType.isBitmap;\n return this.items.length > 0 && this.items.every(t);\n }\n /** Returns whether all the resources in the collection are HTML documents. */\n everyIsHTML() {\n const t = (e) => e.mediaType.isHTML;\n return this.items.length > 0 && this.items.every(t);\n }\n /** Returns whether all the resources in the collection are video clips. */\n everyIsVideo() {\n const t = (e) => e.mediaType.isVideo;\n return this.items.length > 0 && this.items.every(t);\n }\n /** Returns whether all the resources in the collection are matching any of the given media types. */\n everyMatchesMediaType(t) {\n return Array.isArray(t) ? this.items.length > 0 && this.items.every((e) => {\n for (const i of t)\n return e.mediaType.matches(i);\n return !1;\n }) : this.items.length > 0 && this.items.every((e) => e.mediaType.matches(t));\n }\n filterLinksHasType() {\n return this.items.filter((t) => t.type);\n }\n};\nvar Mi = /* @__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))(Mi || {}), N = /* @__PURE__ */ ((r) => (r.ltr = "ltr", r.rtl = "rtl", r))(N || {});\nG.prototype.getContains = function() {\n return new Set(this.otherProperties.contains || []);\n};\nlet Te = class Bi {\n /**\n * Creates a [DomRange].\n */\n constructor(t) {\n this.cssSelector = t.cssSelector, this.textNodeIndex = t.textNodeIndex, this.charOffset = t.charOffset;\n }\n /**\n * Parses a [DomRangePoint] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (!(t && t.cssSelector)) return;\n let e = x(t.textNodeIndex);\n if (e === void 0) return;\n let i = x(t.charOffset);\n return i === void 0 && (i = x(t.offset)), new Bi({\n cssSelector: t.cssSelector,\n textNodeIndex: e,\n charOffset: i\n });\n }\n /**\n * Serializes a [DomRangePoint] to its RWPM JSON representation.\n */\n serialize() {\n const t = {\n cssSelector: this.cssSelector,\n textNodeIndex: this.textNodeIndex\n };\n return this.charOffset !== void 0 && (t.charOffset = this.charOffset), t;\n }\n};\nclass de {\n /**\n * Creates a [DomRange].\n */\n constructor(t) {\n this.start = t.start, this.end = t.end;\n }\n /**\n * Parses a [DomRange] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (!t) return;\n let e = Te.deserialize(t.start);\n if (e)\n return new de({\n start: e,\n end: Te.deserialize(t.end)\n });\n }\n /**\n * Serializes a [DomRange] to its RWPM JSON representation.\n */\n serialize() {\n const t = { start: this.start.serialize() };\n return this.end && (t.end = this.end.serialize()), t;\n }\n}\nj.prototype.getCssSelector = function() {\n return this.otherLocations?.get("cssSelector");\n};\nj.prototype.getPartialCfi = function() {\n return this.otherLocations?.get("partialCfi");\n};\nj.prototype.getDomRange = function() {\n return de.deserialize(this.otherLocations?.get("domRange"));\n};\nj.prototype.fragmentParameters = function() {\n return new Map(\n 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) => [\n r[0].trim().toLowerCase(),\n r[1].trim()\n ])\n );\n};\nj.prototype.htmlId = function() {\n if (!this.fragments.length) return;\n let r = this.fragments.find((t) => t.length && !t.includes("="));\n if (!r) {\n const t = this.fragmentParameters();\n t.has("id") ? r = t.get("id") : t.has("name") && (r = t.get("name"));\n }\n return r?.startsWith("#") ? r.slice(1) : r;\n};\nj.prototype.page = function() {\n const r = parseInt(this.fragmentParameters().get("page"));\n if (!isNaN(r) && r >= 0) return r;\n};\nj.prototype.time = function() {\n const r = parseInt(this.fragmentParameters().get("t"));\n if (!isNaN(r)) return r;\n};\nj.prototype.space = function() {\n const r = this.fragmentParameters();\n if (!r.has("xywh")) return;\n const t = r.get("xywh").split(",").map((e) => parseInt(e));\n if (t.length === 4 && !t.some(isNaN))\n return t;\n};\nclass ge {\n /** Creates a [Price]. */\n constructor(t) {\n this.currency = t.currency, this.value = t.value;\n }\n /**\n * Parses a [Price] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (!t) return;\n let e = t.currency;\n if (!(e && typeof e == "string" && e.length > 0))\n return;\n let i = x(t.value);\n if (i !== void 0)\n return new ge({ currency: e, value: i });\n }\n /**\n * Serializes a [Price] to its RWPM JSON representation.\n */\n serialize() {\n return { currency: this.currency, value: this.value };\n }\n}\nlet oA = class Ct {\n /** Creates a [Acquisition]. */\n constructor(t) {\n this.type = t.type, this.children = t.children;\n }\n /**\n * Parses a [Acquisition] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (t && t.type)\n return new Ct({\n type: t.type,\n children: Ct.deserializeArray(t.children)\n });\n }\n static deserializeArray(t) {\n if (Array.isArray(t))\n return t.map((e) => Ct.deserialize(e)).filter((e) => e !== void 0);\n }\n /**\n * Serializes a [Acquisition] to its RWPM JSON representation.\n */\n serialize() {\n const t = { type: this.type };\n return this.children && (t.children = this.children.map((e) => e.serialize())), t;\n }\n};\nclass ue {\n /** Creates a [Price]. */\n constructor(t) {\n this.total = t.total, this.position = t.position;\n }\n /**\n * Parses a [Holds] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (t)\n return new ue({\n total: x(t.total),\n position: x(t.position)\n });\n }\n /**\n * Serializes a [Holds] to its RWPM JSON representation.\n */\n serialize() {\n const t = {};\n return this.total !== void 0 && (t.total = this.total), this.position !== void 0 && (t.position = this.position), t;\n }\n}\nclass me {\n /** Creates a [Copies]. */\n constructor(t) {\n this.total = t.total, this.available = t.available;\n }\n /**\n * Parses a [Copies] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (t)\n return new me({\n total: x(t.total),\n available: x(t.available)\n });\n }\n /**\n * Serializes a [Copies] to its RWPM JSON representation.\n */\n serialize() {\n const t = {};\n return this.total !== void 0 && (t.total = this.total), this.available !== void 0 && (t.available = this.available), t;\n }\n}\nclass pe {\n /** Creates a [Availability]. */\n constructor(t) {\n this.state = t.state, this.since = t.since, this.until = t.until;\n }\n /**\n * Parses a [Availability] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (t && t.state)\n return new pe({\n state: t.state,\n since: Ye(t.since),\n until: Ye(t.until)\n });\n }\n /**\n * Serializes a [Availability] to its RWPM JSON representation.\n */\n serialize() {\n const t = { state: this.state };\n return this.since !== void 0 && (t.since = this.since.toISOString()), this.until !== void 0 && (t.until = this.until.toISOString()), t;\n }\n}\nG.prototype.getNumberOfItems = function() {\n return x(this.otherProperties.numberOfItems);\n};\nG.prototype.getPrice = function() {\n return ge.deserialize(this.otherProperties.price);\n};\nG.prototype.getIndirectAcquisitions = function() {\n const r = this.otherProperties.indirectAcquisition;\n if (r && Array.isArray(r))\n return r.map((t) => oA.deserialize(t)).filter((t) => t !== void 0);\n};\nG.prototype.getHolds = function() {\n return ue.deserialize(this.otherProperties.holds);\n};\nG.prototype.getCopies = function() {\n return me.deserialize(this.otherProperties.copies);\n};\nG.prototype.getAvailability = function() {\n return pe.deserialize(this.otherProperties.availability);\n};\nG.prototype.getAuthenticate = function() {\n return q.deserialize(this.otherProperties.authenticate);\n};\nconst aA = "CssSelectorGenerator";\nfunction Pe(r = "unknown problem", ...t) {\n console.warn(`${aA}: ${r}`, ...t);\n}\nfunction lA(r) {\n return r instanceof RegExp;\n}\nfunction hA(r) {\n return r.replace(/[|\\\\{}()[\\]^$+?.]/g, "\\\\$&").replace(/\\*/g, ".+");\n}\nfunction cA(r) {\n const t = r.map((e) => {\n if (lA(e))\n return (i) => e.test(i);\n if (typeof e == "function")\n return (i) => {\n const A = e(i);\n return typeof A != "boolean" ? (Pe("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It\'s result will be ignored.", e), !1) : A;\n };\n if (typeof e == "string") {\n const i = new RegExp("^" + hA(e) + "$");\n return (A) => i.test(A);\n }\n return Pe("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", e), () => !1;\n });\n return (e) => t.some((i) => i(e));\n}\ncA([\n "class",\n "id",\n // Angular attributes\n "ng-*"\n]);\nclass dA {\n}\nclass wi extends dA {\n /**\n * Moves to the left content portion (eg. page) relative to the reading progression direction.\n */\n goLeft(t = !1, e) {\n this.readingProgression === N.ltr ? this.goBackward(t, e) : this.readingProgression === N.rtl && this.goForward(t, e);\n }\n /**\n * Moves to the right content portion (eg. page) relative to the reading progression direction.\n */\n goRight(t = !1, e) {\n this.readingProgression === N.ltr ? this.goForward(t, e) : this.readingProgression === N.rtl && this.goBackward(t, e);\n }\n}\nconst gA = `/*!\n * Readium CSS v.2.0.0-beta.22\n * Copyright (c) 2017–2025. Readium Foundation. All rights reserved.\n * Use of this source code is governed by a BSD-style license which is detailed in the\n * LICENSE file present in the project repository where this source code is maintained.\n * Core maintainer: Jiminy Panoz \n * Contributors: \n * Daniel Weck\n * Hadrien Gardeur\n * Innovimax\n * L. Le Meur\n * Mickaël Menu\n * k_taka\n */:root[style*=--USER__textAlign]{text-align:var(--USER__textAlign)}:root[style*=--USER__textAlign] body,:root[style*=--USER__textAlign] p:not([class*=title]):not(blockquote p):not(figcaption p):not(header p):not(hgroup p):not(div:has(+*)>h1+p):not(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:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] figure:has(>img),:root:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] figure:has(>video),:root:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] figure:has(>svg),:root:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] figure:has(>canvas),:root:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] figure:has(>iframe),:root:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] figure:has(>audio),:root:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] div:has(>img),:root:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] div:has(>video),:root:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] div:has(>svg),:root:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] div:has(>canvas),:root:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] div:has(>iframe),:root:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] div:has(>audio),:root:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] table{zoom:calc(100% / var(--USER__zoom))!important}:root:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] figcaption,:root:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] caption,:root:not([style*=readium-iOSPatch-on])[style*=--USER__zoom] td,:root: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([class*=title]):not(blockquote p):not(figcaption p):not(header p):not(hgroup p):not(div:has(+*)>h1+p):not(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}`, mt = (r, t) => URL.createObjectURL(new Blob([r], { type: t })), Ei = (r) => r.replace(/\\/\\/.*/g, "").replace(/\\/\\*[\\s\\S]*?\\*\\//g, "").replace(/\\n/g, "").replace(/\\s+/g, " "), uA = (r) => r.replace(/\\/\\*(?:(?!\\*\\/)[\\s\\S])*\\*\\/|[\\r\\n\\t]+/g, "").replace(/ {2,}/g, " ").replace(/url\\((?!(https?:)?\\/\\/)("?)\\/([^\\)]+)/g, `url($2${window.location.origin}/$3`), fe = (r, t) => {\n const e = r.createElement("script");\n return e.dataset.readium = "true", e.src = t.startsWith("blob:") ? t : mt(t, "text/javascript"), e;\n}, mA = (r, t) => {\n const e = r.createElement("link");\n return e.dataset.readium = "true", e.rel = "stylesheet", e.type = "text/css", e.href = t.startsWith("blob:") ? t : mt(t, "text/css"), e;\n}, Xt = /* @__PURE__ */ new Map(), Jt = (r, t) => {\n if (Xt.has(r)) return Xt.get(r);\n const e = t();\n return Xt.set(r, e), e;\n}, pA = (r) => fe(r, Jt("css-selector-generator", () => mt(\n \'!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,combineBetweenSelectors:!0,root:null,maxCombinations:Number.POSITIVE_INFINITY,maxCandidates:Number.POSITIVE_INFINITY};function u(t){return t instanceof RegExp}function s(t){return["string","function"].includes(typeof t)||u(t)}function l(t){return Array.isArray(t)?t.filter(s):[]}function a(t){const e=[Node.DOCUMENT_NODE,Node.DOCUMENT_FRAGMENT_NODE,Node.ELEMENT_NODE];return function(t){return t instanceof Node}(t)&&e.includes(t.nodeType)}function f(t,e){if(a(t))return t.contains(e)||i("element root mismatch","Provided root does not contain the element. This will most likely result in producing a fallback selector using element\\\'s real root node. If you plan to use the selector using provided root (e.g. `root.querySelector`), it will nto work as intended."),t;const n=e.getRootNode({composed:!1});return a(n)?(n!==document&&i("shadow root inferred","You did not provide a root and the element is a child of Shadow DOM. This will produce a selector using ShadowRoot as a root. If you plan to use the selector using document as a root (e.g. `document.querySelector`), it will not work as intended."),n):e.ownerDocument.querySelector(":root")}function d(t){return"number"==typeof t?t:Number.POSITIVE_INFINITY}function m(t=[]){const[e=[],...n]=t;return 0===n.length?e:n.reduce(((t,e)=>t.filter((t=>e.includes(t)))),e)}function p(t){return[].concat(...t)}function h(t){const e=t.map((t=>{if(u(t))return e=>t.test(e);if("function"==typeof t)return e=>{const n=t(e);return"boolean"!=typeof n?(i("pattern matcher function invalid","Provided pattern matching function does not return boolean. It\\\'s result will be ignored.",t),!1):n};if("string"==typeof t){const e=new RegExp("^"+t.replace(/[|\\\\\\\\{}()[\\\\]^$+?.]/g,"\\\\\\\\$&").replace(/\\\\*/g,".+")+"$");return t=>e.test(t)}return i("pattern matcher invalid","Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.",t),()=>!1}));return t=>e.some((e=>e(t)))}function g(t,e,n){const o=Array.from(f(n,t[0]).querySelectorAll(e));return o.length===t.length&&t.every((t=>o.includes(t)))}function y(t,e){e=null!=e?e:function(t){return t.ownerDocument.querySelector(":root")}(t);const n=[];let o=t;for(;r(o)&&o!==e;)n.push(o),o=o.parentElement;return n}function b(t,e){return m(t.map((t=>y(t,e))))}const N={[t.NONE]:{type:t.NONE,value:""},[t.DESCENDANT]:{type:t.DESCENDANT,value:" > "},[t.CHILD]:{type:t.CHILD,value:" "}},S=new RegExp(["^$","\\\\\\\\s"].join("|")),E=new RegExp(["^$"].join("|")),w=[e.nthoftype,e.tag,e.id,e.class,e.attribute,e.nthchild],v=h(["class","id","ng-*"]);function C({nodeName:t}){return`[${t}]`}function O({nodeName:t,nodeValue:e}){return`[${t}=\\\'${L(e)}\\\']`}function T(t){const e=Array.from(t.attributes).filter((e=>function({nodeName:t},e){const n=e.tagName.toLowerCase();return!(["input","option"].includes(n)&&"value"===t||v(t))}(e,t)));return[...e.map(C),...e.map(O)]}function I(t){return(t.getAttribute("class")||"").trim().split(/\\\\s+/).filter((t=>!E.test(t))).map((t=>`.${L(t)}`))}function x(t){const e=t.getAttribute("id")||"",n=`#${L(e)}`,o=t.getRootNode({composed:!1});return!S.test(e)&&g([t],n,o)?[n]:[]}function j(t){const e=t.parentNode;if(e){const n=Array.from(e.childNodes).filter(r).indexOf(t);if(n>-1)return[`:nth-child(${n+1})`]}return[]}function A(t){return[L(t.tagName.toLowerCase())]}function D(t){const e=[...new Set(p(t.map(A)))];return 0===e.length||e.length>1?[]:[e[0]]}function $(t){const e=D([t])[0],n=t.parentElement;if(n){const o=Array.from(n.children).filter((t=>t.tagName.toLowerCase()===e)),r=o.indexOf(t);if(r>-1)return[`${e}:nth-of-type(${r+1})`]}return[]}function R(t=[],{maxResults:e=Number.POSITIVE_INFINITY}={}){const n=[];let o=0,r=k(1);for(;r.length<=t.length&&ot[e]))),r=P(r,t.length-1);return n}function P(t=[],e=0){const n=t.length;if(0===n)return[];const o=[...t];o[n-1]+=1;for(let t=n-1;t>=0;t--)if(o[t]>e){if(0===t)return k(n+1);o[t-1]++,o[t]=o[t-1]+1}return o[n-1]>e?k(n+1):o}function k(t=1){return Array.from(Array(t).keys())}const _=":".charCodeAt(0).toString(16).toUpperCase(),M=/[ !"#$%&\\\'()\\\\[\\\\]{|}<>*+,./;=?@^`~\\\\\\\\]/;function L(t=""){var e,n;return null!==(n=null===(e=null===CSS||void 0===CSS?void 0:CSS.escape)||void 0===e?void 0:e.call(CSS,t))&&void 0!==n?n:function(t=""){return t.split("").map((t=>":"===t?`\\\\\\\\${_} `:M.test(t)?`\\\\\\\\${t}`:escape(t).replace(/%/g,"\\\\\\\\"))).join("")}(t)}const q={tag:D,id:function(t){return 0===t.length||t.length>1?[]:x(t[0])},class:function(t){return m(t.map(I))},attribute:function(t){return m(t.map(T))},nthchild:function(t){return m(t.map(j))},nthoftype:function(t){return m(t.map($))}},F={tag:A,id:x,class:I,attribute:T,nthchild:j,nthoftype:$};function V(t){return t.includes(e.tag)||t.includes(e.nthoftype)?[...t]:[...t,e.tag]}function Y(t={}){const n=[...w];return t[e.tag]&&t[e.nthoftype]&&n.splice(n.indexOf(e.tag),1),n.map((e=>{return(o=t)[n=e]?o[n].join(""):"";var n,o})).join("")}function B(t,e,n="",o){const r=function(t,e){return""===e?t:function(t,e){return[...t.map((t=>e+" "+t)),...t.map((t=>e+" > "+t))]}(t,e)}(function(t,e,n){const o=function(t,e){const{blacklist:n,whitelist:o,combineWithinSelector:r,maxCombinations:i}=e,c=h(n),u=h(o);return function(t){const{selectors:e,includeTag:n}=t,o=[].concat(e);return n&&!o.includes("tag")&&o.push("tag"),o}(e).reduce(((e,n)=>{const o=function(t,e){var n;return(null!==(n=q[e])&&void 0!==n?n:()=>[])(t)}(t,n),s=function(t=[],e,n){return t.filter((t=>n(t)||!e(t)))}(o,c,u),l=function(t=[],e){return t.sort(((t,n)=>{const o=e(t),r=e(n);return o&&!r?-1:!o&&r?1:0}))}(s,u);return e[n]=r?R(l,{maxResults:i}):l.map((t=>[t])),e}),{})}(t,n),r=function(t,e){return function(t){const{selectors:e,combineBetweenSelectors:n,includeTag:o,maxCandidates:r}=t,i=n?R(e,{maxResults:r}):e.map((t=>[t]));return o?i.map(V):i}(e).map((e=>function(t,e){const n={};return t.forEach((t=>{const o=e[t];o.length>0&&(n[t]=o)})),function(t={}){let e=[];return Object.entries(t).forEach((([t,n])=>{e=n.flatMap((n=>0===e.length?[{[t]:n}]:e.map((e=>Object.assign(Object.assign({},e),{[t]:n})))))})),e}(n).map(Y)}(e,t))).filter((t=>t.length>0))}(o,n),i=p(r);return[...new Set(i)]}(t,o.root,o),n);for(const e of r)if(g(t,e,o.root))return e;return null}function G(t){return{value:t,include:!1}}function W({selectors:t,operator:n}){let o=[...w];t[e.tag]&&t[e.nthoftype]&&(o=o.filter((t=>t!==e.tag)));let r="";return o.forEach((e=>{(t[e]||[]).forEach((({value:t,include:e})=>{e&&(r+=t)}))})),n.value+r}function H(n){return[":root",...y(n).reverse().map((n=>{const o=function(e,n,o=t.NONE){const r={};return n.forEach((t=>{Reflect.set(r,t,function(t,e){return F[e](t)}(e,t).map(G))})),{element:e,operator:N[o],selectors:r}}(n,[e.nthchild],t.DESCENDANT);return o.selectors.nthchild.forEach((t=>{t.include=!0})),o})).map(W)].join("")}function U(t,n={}){const o=function(t){const e=(Array.isArray(t)?t:[t]).filter(r);return[...new Set(e)]}(t),i=function(t,n={}){const o=Object.assign(Object.assign({},c),n);return{selectors:(r=o.selectors,Array.isArray(r)?r.filter((t=>{return n=e,o=t,Object.values(n).includes(o);var n,o})):[]),whitelist:l(o.whitelist),blacklist:l(o.blacklist),root:f(o.root,t),combineWithinSelector:!!o.combineWithinSelector,combineBetweenSelectors:!!o.combineBetweenSelectors,includeTag:!!o.includeTag,maxCombinations:d(o.maxCombinations),maxCandidates:d(o.maxCandidates)};var r}(o[0],n);let u="",s=i.root;function a(){return function(t,e,n="",o){if(0===t.length)return null;const r=[t.length>1?t:[],...b(t,e).map((t=>[t]))];for(const t of r){const e=B(t,0,n,o);if(e)return{foundElements:t,selector:e}}return null}(o,s,u,i)}let m=a();for(;m;){const{foundElements:t,selector:e}=m;if(g(o,e,i.root))return e;s=t[0],u=e,m=a()}return o.length>1?o.map((t=>U(t,i))).join(", "):function(t){return t.map(H).join(", ")}(o)}const z=U;return o})()));\',\n "text/javascript"\n))), fA = `\nwindow._readium_blockedEvents = [];\nwindow._readium_blockEvents = false; // WebPub doesn\'t need event blocking\nwindow._readium_eventBlocker = null;\n`, MA = (r) => fe(r, Jt("webpub-js-before", () => mt(Ei(fA), "text/javascript"))), BA = (r) => fe(r, Jt("webpub-js-after", () => mt(Ei(`\nif(window.onload) window.onload = new Proxy(window.onload, {\n apply: function(target, receiver, args) {\n if(!window._readium_blockEvents) {\n Reflect.apply(target, receiver, args);\n return;\n }\n _readium_blockedEvents.push([0, target, receiver, args]);\n }\n});`), "text/javascript")));\nclass wA {\n constructor(t, e, i, A) {\n this.pub = t, this.item = i, this.burl = i.toURL(e) || "", this.cssProperties = A;\n }\n async build() {\n if (!this.item.mediaType.isHTML)\n throw new Error(`Unsupported media type for WebPub: ${this.item.mediaType.string}`);\n return await this.buildHtmlFrame();\n }\n async buildHtmlFrame() {\n const t = await this.pub.get(this.item).readAsString();\n if (!t) throw new Error(`Failed reading item ${this.item.href}`);\n const e = new DOMParser().parseFromString(\n t,\n this.item.mediaType.string\n ), i = e.querySelector("parsererror");\n if (i) {\n const A = i.querySelector("div");\n throw new Error(`Failed parsing item ${this.item.href}: ${A?.textContent || i.textContent}`);\n }\n return this.finalizeDOM(e, this.burl, this.item.mediaType, t, this.cssProperties);\n }\n hasExecutable(t) {\n return !!t.querySelector("script") || !!t.querySelector("body[onload]:not(body[onload=\'\'])");\n }\n setProperties(t, e) {\n for (const i in t) {\n const A = t[i];\n A && e.documentElement.style.setProperty(i, A);\n }\n }\n finalizeDOM(t, e, i, A, n) {\n if (!t) return "";\n if (t.head.appendChild(mA(t, Jt("ReadiumCSS-webpub", () => mt(uA(gA), "text/css")))), n && this.setProperties(n, t), t.body.querySelectorAll("img").forEach((a) => {\n a.setAttribute("fetchpriority", "high");\n }), e !== void 0) {\n const a = t.createElement("base");\n a.href = e, a.dataset.readium = "true", t.head.firstChild.before(a);\n }\n const s = this.hasExecutable(t);\n s && t.head.firstChild.before(MA(t)), t.head.firstChild.before(pA(t)), s && t.head.appendChild(BA(t));\n let o;\n return i.string === "application/xhtml+xml" ? o = new XMLSerializer().serializeToString(t) : o = this.serializeAsHTML(t, A || ""), URL.createObjectURL(\n new Blob([o], {\n type: i.isHTML ? i.string : "application/xhtml+xml"\n })\n );\n }\n serializeAsHTML(t, e) {\n const i = e.match(/]*>/i), A = i ? i[0] + `\n` : "";\n let s = t.documentElement.outerHTML;\n return A + s;\n }\n}\nconst EA = Math.pow(2, 32), be = () => Math.round(Math.random() * EA).toString(36), ne = () => `${Math.round(performance.now())}-${be()}-${be()}`, at = 1;\nclass IA {\n constructor(t) {\n this.destination = null, this.registrar = /* @__PURE__ */ new Map(), this.origin = "", this.channelId = "", this.receiver = this.receive.bind(this), this.preLog = [], this.wnd = t, t.addEventListener("message", this.receiver);\n }\n receive(t) {\n if (t.source === null) throw Error("Event source is null");\n if (typeof t.data != "object") return;\n const e = t.data;\n if (!(!("_readium" in e) || !e._readium || e._readium <= 0)) {\n if (e.key === "_ping") {\n if (!this.destination) {\n if (this.destination = t.source, this.origin = t.origin, this.channelId = e._channel, e._readium !== at) {\n e._readium > at ? this.send("error", `received comms version ${e._readium} higher than ${at}`) : this.send("error", `received comms version ${e._readium} lower than ${at}`), this.destination = null, this.origin = "", this.channelId = "";\n return;\n }\n this.send("_pong", void 0), this.preLog.forEach((i) => this.send("log", i)), this.preLog = [];\n }\n return;\n } else if (this.channelId) {\n if (e._channel !== this.channelId || t.origin !== this.origin) return;\n } else\n return;\n this.handle(e);\n }\n }\n handle(t) {\n const e = this.registrar.get(t.key);\n if (!e || e.length === 0) {\n t.strict && this.send("_unhandled", t);\n return;\n }\n e.forEach((i) => i.cb(t.data, (A) => {\n this.send("_ack", A, t.id);\n }));\n }\n register(t, e, i) {\n Array.isArray(t) || (t = [t]), t.forEach((A) => {\n const n = this.registrar.get(A);\n if (n && n.length >= 0) {\n if (n.find((s) => s.module === e)) throw new Error(`Trying to register another callback for combination of event ${A} and module ${e}`);\n n.push({\n cb: i,\n module: e\n }), this.registrar.set(A, n);\n } else\n this.registrar.set(A, [{\n cb: i,\n module: e\n }]);\n });\n }\n unregister(t, e) {\n Array.isArray(t) || (t = [t]), t.forEach((i) => {\n const A = this.registrar.get(i);\n !A || A.length === 0 || A.splice(A.findIndex((n) => n.module === e), 1);\n });\n }\n unregisterAll(t) {\n this.registrar.forEach((e, i) => this.registrar.set(i, e.filter((A) => A.module !== t)));\n }\n log(...t) {\n this.destination ? this.send("log", t) : this.preLog.push(t);\n }\n get ready() {\n return !!this.destination;\n }\n destroy() {\n this.destination = null, this.channelId = "", this.preLog = [], this.registrar.clear(), this.wnd.removeEventListener("message", this.receiver);\n }\n send(t, e, i = void 0, A = []) {\n if (!this.destination) throw Error("Attempted to send comms message before destination has been initialized");\n const n = {\n _readium: at,\n _channel: this.channelId,\n id: i ?? ne(),\n // scrict,\n key: t,\n data: e\n };\n try {\n this.destination.postMessage(n, {\n targetOrigin: this.origin,\n transfer: A\n });\n } catch (s) {\n if (A.length > 0) throw s;\n this.destination.postMessage(n, this.origin, A);\n }\n }\n}\nconst O = class lt {\n constructor(t) {\n if (typeof t == "string") {\n if (!lt.VALID_MODES.has(t.toLowerCase()))\n return;\n this.value = t.toLowerCase();\n } else {\n const e = t.filter(\n (i) => lt.VALID_MODES.has(i.toLowerCase())\n );\n if (e.length === 0)\n return;\n this.value = Array.from(new Set(e));\n }\n }\n /**\n * Parses a [PrimaryAccessMode] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (!t) return;\n if (typeof t == "string")\n return new lt(t);\n if (!Array.isArray(t)) return;\n const e = t.filter((i) => i ? lt.VALID_MODES.has(i.toLowerCase()) : !1);\n if (e.length !== 0)\n return new lt(e);\n }\n /**\n * Serializes a [PrimaryAccessMode] to its RWPM JSON representation.\n */\n serialize() {\n return this.value;\n }\n};\nO.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");\nclass Me {\n /**\n * Creates a [Encryption].\n */\n constructor(t) {\n this.algorithm = t.algorithm, this.compression = t.compression, this.originalLength = t.originalLength, this.profile = t.profile, this.scheme = t.scheme;\n }\n /**\n * Parses a [Encryption] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (t && t.algorithm)\n return new Me({\n algorithm: t.algorithm,\n compression: t.compression,\n originalLength: t.originalLength,\n profile: t.profile,\n scheme: t.scheme\n });\n }\n /**\n * Serializes a [Encryption] to its RWPM JSON representation.\n */\n serialize() {\n const t = { algorithm: this.algorithm };\n 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;\n }\n}\nclass P {\n constructor(t) {\n this.otherProperties = t;\n }\n get page() {\n return this.otherProperties.page;\n }\n /**\n * Creates a [Properties] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (t)\n return new P(t);\n }\n /**\n * Serializes a [Properties] to its RWPM JSON representation.\n */\n serialize() {\n return this.otherProperties;\n }\n /**\n * Makes a copy of this [Properties] after merging in the given additional other [properties].\n */\n add(t) {\n const e = Object.assign({}, this.otherProperties);\n for (const i in t)\n e[i] = t[i];\n return new P(e);\n }\n}\nObject.defineProperty(P.prototype, "encryption", {\n get: function() {\n return Me.deserialize(this.otherProperties.encrypted);\n }\n});\nfunction yA(r) {\n return r && Array.isArray(r) ? r : void 0;\n}\nfunction Ii(r) {\n return r && typeof r == "string" ? [r] : yA(r);\n}\nfunction je(r) {\n return typeof r == "string" ? new Date(r) : void 0;\n}\nfunction St(r) {\n return isNaN(r) ? void 0 : r;\n}\nfunction T(r) {\n return St(r) !== void 0 && Math.sign(r) >= 0 ? r : void 0;\n}\nfunction FA(r) {\n const t = new Array();\n return r.forEach((e) => t.push(e)), t;\n}\nclass m {\n /** Creates a MediaType object. */\n constructor(t) {\n let e, i, A = t.mediaType.replace(/\\s/g, "").split(";");\n const n = A[0].split("/");\n if (n.length === 2) {\n if (e = n[0].toLowerCase().trim(), i = n[1].toLowerCase().trim(), e.length === 0 || i.length === 0)\n throw new Error("Invalid media type");\n } else\n throw new Error("Invalid media type");\n const s = {};\n for (let g = 1; g < A.length; g++) {\n const M = A[g].split("=");\n if (M.length === 2) {\n const l = M[0].toLocaleLowerCase(), p = l === "charset" ? M[1].toUpperCase() : M[1];\n s[l] = p;\n }\n }\n const o = {}, a = Object.keys(s);\n a.sort((g, M) => g.localeCompare(M)), a.forEach((g) => o[g] = s[g]);\n let h = "";\n for (const g in o) {\n const M = o[g];\n h += `;${g}=${M}`;\n }\n const c = `${e}/${i}${h}`, d = o.encoding;\n this.string = c, this.type = e, this.subtype = i, this.parameters = o, this.encoding = d, this.name = t.name, this.fileExtension = t.fileExtension;\n }\n static parse(t) {\n return new m(t);\n }\n /** Structured syntax suffix, e.g. `+zip` in `application/epub+zip`.\n * Gives a hint on the underlying structure of this media type.\n * See. https://tools.ietf.org/html/rfc6838#section-4.2.8\n */\n get structuredSyntaxSuffix() {\n const t = this.subtype.split("+");\n return t.length > 1 ? `+${t[t.length - 1]}` : void 0;\n }\n /** Parameter values might or might not be case-sensitive, depending on the semantics of\n * the parameter name.\n * https://tools.ietf.org/html/rfc2616#section-3.7\n *\n * The character set names may be up to 40 characters taken from the printable characters\n * of US-ASCII. However, no distinction is made between use of upper and lower case\n * letters.\n * https://www.iana.org/assignments/character-sets/character-sets.xhtml\n */\n get charset() {\n return this.parameters.charset;\n }\n /** Returns whether the given `other` media type is included in this media type.\n * For example, `text/html` contains `text/html;charset=utf-8`.\n * - `other` must match the parameters in the `parameters` property, but extra parameters\n * are ignored.\n * - Order of parameters is ignored.\n * - Wildcards are supported, meaning that `image/*` contains `image/png`\n */\n contains(t) {\n const e = typeof t == "string" ? m.parse({ mediaType: t }) : t;\n if (!((this.type === "*" || this.type === e.type) && (this.subtype === "*" || this.subtype === e.subtype)))\n return !1;\n const i = new Set(\n Object.entries(this.parameters).map(([n, s]) => `${n}=${s}`)\n ), A = new Set(\n Object.entries(e.parameters).map(([n, s]) => `${n}=${s}`)\n );\n for (const n of Array.from(i.values()))\n if (!A.has(n))\n return !1;\n return !0;\n }\n /** Returns whether this media type and `other` are the same, ignoring parameters that\n * are not in both media types.\n * For example, `text/html` matches `text/html;charset=utf-8`, but `text/html;charset=ascii`\n * doesn\'t. This is basically like `contains`, but working in both direction.\n */\n matches(t) {\n const e = typeof t == "string" ? m.parse({ mediaType: t }) : t;\n return this.contains(e) || e.contains(this);\n }\n /**\n * Returns whether this media type matches any of the [others] media types.\n */\n matchesAny(...t) {\n for (const e of t)\n if (this.matches(e))\n return !0;\n return !1;\n }\n /** Checks the MediaType equals another one (comparing their string) */\n equals(t) {\n return this.string === t.string;\n }\n /** Returns whether this media type is structured as a ZIP archive. */\n get isZIP() {\n return this.matchesAny(\n m.ZIP,\n m.LCP_PROTECTED_AUDIOBOOK,\n m.LCP_PROTECTED_PDF\n ) || this.structuredSyntaxSuffix === "+zip";\n }\n /** Returns whether this media type is structured as a JSON file. */\n get isJSON() {\n return this.matchesAny(m.JSON) || this.structuredSyntaxSuffix === "+json";\n }\n /** Returns whether this media type is of an OPDS feed. */\n get isOPDS() {\n return this.matchesAny(\n m.OPDS1,\n m.OPDS1_ENTRY,\n m.OPDS2,\n m.OPDS2_PUBLICATION,\n m.OPDS_AUTHENTICATION\n ) || this.structuredSyntaxSuffix === "+json";\n }\n /** Returns whether this media type is of an HTML document. */\n get isHTML() {\n return this.matchesAny(m.HTML, m.XHTML);\n }\n /** Returns whether this media type is of a bitmap image, so excluding vectorial formats. */\n get isBitmap() {\n return this.matchesAny(\n m.BMP,\n m.GIF,\n m.JPEG,\n m.PNG,\n m.TIFF,\n m.WEBP\n );\n }\n /** Returns whether this media type is of an audio clip. */\n get isAudio() {\n return this.type === "audio";\n }\n /** Returns whether this media type is of a video clip. */\n get isVideo() {\n return this.type === "video";\n }\n /** Returns whether this media type is of a Readium Web Publication Manifest. */\n get isRWPM() {\n return this.matchesAny(\n m.READIUM_AUDIOBOOK_MANIFEST,\n m.DIVINA_MANIFEST,\n m.READIUM_WEBPUB_MANIFEST\n );\n }\n /** Returns whether this media type is of a publication file. */\n get isPublication() {\n return this.matchesAny(\n m.READIUM_AUDIOBOOK,\n m.READIUM_AUDIOBOOK_MANIFEST,\n m.CBZ,\n m.DIVINA,\n m.DIVINA_MANIFEST,\n m.EPUB,\n m.LCP_PROTECTED_AUDIOBOOK,\n m.LCP_PROTECTED_PDF,\n m.LPF,\n m.PDF,\n m.W3C_WPUB_MANIFEST,\n m.READIUM_WEBPUB,\n m.READIUM_WEBPUB_MANIFEST,\n m.ZAB\n );\n }\n // Known Media Types\n static get AAC() {\n return m.parse({ mediaType: "audio/aac", fileExtension: "aac" });\n }\n static get ACSM() {\n return m.parse({\n mediaType: "application/vnd.adobe.adept+xml",\n name: "Adobe Content Server Message",\n fileExtension: "acsm"\n });\n }\n static get AIFF() {\n return m.parse({ mediaType: "audio/aiff", fileExtension: "aiff" });\n }\n static get AVI() {\n return m.parse({\n mediaType: "video/x-msvideo",\n fileExtension: "avi"\n });\n }\n static get BINARY() {\n return m.parse({ mediaType: "application/octet-stream" });\n }\n static get BMP() {\n return m.parse({ mediaType: "image/bmp", fileExtension: "bmp" });\n }\n static get CBZ() {\n return m.parse({\n mediaType: "application/vnd.comicbook+zip",\n name: "Comic Book Archive",\n fileExtension: "cbz"\n });\n }\n static get CSS() {\n return m.parse({ mediaType: "text/css", fileExtension: "css" });\n }\n static get DIVINA() {\n return m.parse({\n mediaType: "application/divina+zip",\n name: "Digital Visual Narratives",\n fileExtension: "divina"\n });\n }\n static get DIVINA_MANIFEST() {\n return m.parse({\n mediaType: "application/divina+json",\n name: "Digital Visual Narratives",\n fileExtension: "json"\n });\n }\n static get EPUB() {\n return m.parse({\n mediaType: "application/epub+zip",\n name: "EPUB",\n fileExtension: "epub"\n });\n }\n static get GIF() {\n return m.parse({ mediaType: "image/gif", fileExtension: "gif" });\n }\n static get GZ() {\n return m.parse({\n mediaType: "application/gzip",\n fileExtension: "gz"\n });\n }\n static get HTML() {\n return m.parse({ mediaType: "text/html", fileExtension: "html" });\n }\n static get JAVASCRIPT() {\n return m.parse({\n mediaType: "text/javascript",\n fileExtension: "js"\n });\n }\n static get JPEG() {\n return m.parse({ mediaType: "image/jpeg", fileExtension: "jpeg" });\n }\n static get JSON() {\n return m.parse({ mediaType: "application/json" });\n }\n static get LCP_LICENSE_DOCUMENT() {\n return m.parse({\n mediaType: "application/vnd.readium.lcp.license.v1.0+json",\n name: "LCP License",\n fileExtension: "lcpl"\n });\n }\n static get LCP_PROTECTED_AUDIOBOOK() {\n return m.parse({\n mediaType: "application/audiobook+lcp",\n name: "LCP Protected Audiobook",\n fileExtension: "lcpa"\n });\n }\n static get LCP_PROTECTED_PDF() {\n return m.parse({\n mediaType: "application/pdf+lcp",\n name: "LCP Protected PDF",\n fileExtension: "lcpdf"\n });\n }\n static get LCP_STATUS_DOCUMENT() {\n return m.parse({\n mediaType: "application/vnd.readium.license.status.v1.0+json"\n });\n }\n static get LPF() {\n return m.parse({\n mediaType: "application/lpf+zip",\n fileExtension: "lpf"\n });\n }\n static get MP3() {\n return m.parse({ mediaType: "audio/mpeg", fileExtension: "mp3" });\n }\n static get MPEG() {\n return m.parse({ mediaType: "video/mpeg", fileExtension: "mpeg" });\n }\n static get NCX() {\n return m.parse({\n mediaType: "application/x-dtbncx+xml",\n fileExtension: "ncx"\n });\n }\n static get OGG() {\n return m.parse({ mediaType: "audio/ogg", fileExtension: "oga" });\n }\n static get OGV() {\n return m.parse({ mediaType: "video/ogg", fileExtension: "ogv" });\n }\n static get OPDS1() {\n return m.parse({\n mediaType: "application/atom+xml;profile=opds-catalog"\n });\n }\n static get OPDS1_ENTRY() {\n return m.parse({\n mediaType: "application/atom+xml;type=entry;profile=opds-catalog"\n });\n }\n static get OPDS2() {\n return m.parse({ mediaType: "application/opds+json" });\n }\n static get OPDS2_PUBLICATION() {\n return m.parse({ mediaType: "application/opds-publication+json" });\n }\n static get OPDS_AUTHENTICATION() {\n return m.parse({\n mediaType: "application/opds-authentication+json"\n });\n }\n static get OPUS() {\n return m.parse({ mediaType: "audio/opus", fileExtension: "opus" });\n }\n static get OTF() {\n return m.parse({ mediaType: "font/otf", fileExtension: "otf" });\n }\n static get PDF() {\n return m.parse({\n mediaType: "application/pdf",\n name: "PDF",\n fileExtension: "pdf"\n });\n }\n static get PNG() {\n return m.parse({ mediaType: "image/png", fileExtension: "png" });\n }\n static get READIUM_AUDIOBOOK() {\n return m.parse({\n mediaType: "application/audiobook+zip",\n name: "Readium Audiobook",\n fileExtension: "audiobook"\n });\n }\n static get READIUM_AUDIOBOOK_MANIFEST() {\n return m.parse({\n mediaType: "application/audiobook+json",\n name: "Readium Audiobook",\n fileExtension: "json"\n });\n }\n static get READIUM_CONTENT_DOCUMENT() {\n return m.parse({\n mediaType: "application/vnd.readium.content+json",\n name: "Readium Content Document",\n fileExtension: "json"\n });\n }\n static get READIUM_GUIDED_NAVIGATION_DOCUMENT() {\n return m.parse({\n mediaType: "application/guided-navigation+json",\n name: "Readium Guided Navigation Document",\n fileExtension: "json"\n });\n }\n static get READIUM_POSITION_LIST() {\n return m.parse({\n mediaType: "application/vnd.readium.position-list+json",\n name: "Readium Position List",\n fileExtension: "json"\n });\n }\n static get READIUM_WEBPUB() {\n return m.parse({\n mediaType: "application/webpub+zip",\n name: "Readium Web Publication",\n fileExtension: "webpub"\n });\n }\n static get READIUM_WEBPUB_MANIFEST() {\n return m.parse({\n mediaType: "application/webpub+json",\n name: "Readium Web Publication",\n fileExtension: "json"\n });\n }\n static get SMIL() {\n return m.parse({\n mediaType: "application/smil+xml",\n fileExtension: "smil"\n });\n }\n static get SVG() {\n return m.parse({\n mediaType: "image/svg+xml",\n fileExtension: "svg"\n });\n }\n static get TEXT() {\n return m.parse({ mediaType: "text/plain", fileExtension: "txt" });\n }\n static get TIFF() {\n return m.parse({ mediaType: "image/tiff", fileExtension: "tiff" });\n }\n static get TTF() {\n return m.parse({ mediaType: "font/ttf", fileExtension: "ttf" });\n }\n static get W3C_WPUB_MANIFEST() {\n return m.parse({\n mediaType: "application/x.readium.w3c.wpub+json",\n name: "Web Publication",\n fileExtension: "json"\n });\n }\n static get WAV() {\n return m.parse({ mediaType: "audio/wav", fileExtension: "wav" });\n }\n static get WEBM_AUDIO() {\n return m.parse({ mediaType: "audio/webm", fileExtension: "webm" });\n }\n static get WEBM_VIDEO() {\n return m.parse({ mediaType: "video/webm", fileExtension: "webm" });\n }\n static get WEBP() {\n return m.parse({ mediaType: "image/webp", fileExtension: "webp" });\n }\n static get WOFF() {\n return m.parse({ mediaType: "font/woff", fileExtension: "woff" });\n }\n static get WOFF2() {\n return m.parse({ mediaType: "font/woff2", fileExtension: "woff2" });\n }\n static get XHTML() {\n return m.parse({\n mediaType: "application/xhtml+xml",\n fileExtension: "xhtml"\n });\n }\n static get XML() {\n return m.parse({\n mediaType: "application/xml",\n fileExtension: "xml"\n });\n }\n static get ZAB() {\n return m.parse({\n mediaType: "application/x.readium.zab+zip",\n name: "Zipped Audio Book",\n fileExtension: "zab"\n });\n }\n static get ZIP() {\n return m.parse({\n mediaType: "application/zip",\n fileExtension: "zip"\n });\n }\n}\nclass Ve {\n constructor(t) {\n this.uri = t, this.parameters = this.getParameters(t);\n }\n /**\n * List of URI template parameter keys, if the [Link] is templated.\n */\n getParameters(t) {\n const e = /\\{\\??([^}]+)\\}/g, i = t.match(e);\n return i ? new Set(\n i.join(",").replace(e, "$1").split(",").map((A) => A.trim())\n ) : /* @__PURE__ */ new Set();\n }\n /** Expands the URI by replacing the template variables by the given parameters.\n * Any extra parameter is appended as query parameters.\n * See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570\n */\n expand(t) {\n const e = (A) => A.split(",").map((n) => {\n const s = t[n];\n return s ? encodeURIComponent(s) : "";\n }).join(","), i = (A) => "?" + A.split(",").map((n) => {\n const s = n.split("=")[0], o = t[s];\n return o ? `${s}=${encodeURIComponent(o)}` : "";\n }).join("&");\n return this.uri.replace(/\\{(\\??)([^}]+)\\}/g, (...A) => A[1] ? i(A[2]) : e(A[2]));\n }\n}\nclass S {\n /**\n * Creates a [Locations].\n */\n constructor(t) {\n this.fragments = t.fragments ? t.fragments : new Array(), this.progression = t.progression, this.totalProgression = t.totalProgression, this.position = t.position, this.otherLocations = t.otherLocations;\n }\n /**\n * Parses a [Locations] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (!t) return;\n const e = St(t.progression), i = St(t.totalProgression), A = St(t.position), n = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set([\n "fragment",\n "fragments",\n "progression",\n "totalProgression",\n "position"\n ]);\n return Object.entries(t).forEach(([o, a]) => {\n s.has(o) || n.set(o, a);\n }), new S({\n fragments: Ii(t.fragments || t.fragment),\n progression: e !== void 0 && e >= 0 && e <= 1 ? e : void 0,\n totalProgression: i !== void 0 && i >= 0 && i <= 1 ? i : void 0,\n position: A !== void 0 && A > 0 ? A : void 0,\n otherLocations: n.size === 0 ? void 0 : n\n });\n }\n /**\n * Serializes a [Locations] to its RWPM JSON representation.\n */\n serialize() {\n const t = {};\n 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;\n }\n}\nclass At {\n /**\n * Creates a [Text].\n */\n constructor(t) {\n this.after = t.after, this.before = t.before, this.highlight = t.highlight;\n }\n /**\n * Parses a [Locations] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (t)\n return new At({\n after: t.after,\n before: t.before,\n highlight: t.highlight\n });\n }\n /**\n * Serializes a [Locations] to its RWPM JSON representation.\n */\n serialize() {\n const t = {};\n 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;\n }\n}\nclass L {\n /**\n * Creates a [Locator].\n */\n constructor(t) {\n this.href = t.href, this.type = t.type, this.title = t.title, this.locations = t.locations ? t.locations : new S({}), this.text = t.text;\n }\n /**\n * Parses a [Link] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (t && t.href && t.type)\n return new L({\n href: t.href,\n type: t.type,\n title: t.title,\n locations: S.deserialize(t.locations),\n text: At.deserialize(t.text)\n });\n }\n /**\n * Serializes a [Link] to its RWPM JSON representation.\n */\n serialize() {\n const t = { href: this.href, type: this.type };\n return this.title !== void 0 && (t.title = this.title), this.locations && (t.locations = this.locations.serialize()), this.text && (t.text = this.text.serialize()), t;\n }\n /**\n * Shortcut to get a copy of the [Locator] with different [Locations] sub-properties.\n */\n copyWithLocations(t) {\n return new L({\n href: this.href,\n type: this.type,\n title: this.title,\n text: this.text,\n locations: new S({ ...this.locations, ...t })\n });\n }\n}\nclass ct {\n /**\n * Creates a [Link].\n */\n constructor(t) {\n 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;\n }\n /**\n * Parses a [Link] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (!(!t || typeof t.href != "string"))\n return new ct({\n href: t.href,\n templated: t.templated,\n type: t.type,\n title: t.title,\n rels: t.rel ? Array.isArray(t.rel) ? new Set(t.rel) : /* @__PURE__ */ new Set([t.rel]) : void 0,\n properties: P.deserialize(t.properties),\n height: T(t.height),\n width: T(t.width),\n size: T(t.size),\n duration: T(t.duration),\n bitrate: T(t.bitrate),\n languages: Ii(t.language),\n alternates: Qt.deserialize(t.alternate),\n children: Qt.deserialize(t.children)\n });\n }\n /**\n * Serializes a [Link] to its RWPM JSON representation.\n */\n serialize() {\n const t = { href: this.href };\n 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 = FA(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;\n }\n /** MediaType of the linked resource. */\n get mediaType() {\n return this.type !== void 0 ? m.parse({ mediaType: this.type }) : m.BINARY;\n }\n /** Computes an absolute URL to the link, relative to the given `baseURL`.\n * If the link\'s `href` is already absolute, the `baseURL` is ignored.\n */\n toURL(t) {\n const e = this.href.replace(/^(\\/)/, "");\n if (e.length === 0) return;\n let i = t || "/";\n return i.startsWith("/") && (i = "file://" + i), new URL(e, i).href.replace(/^(file:\\/\\/)/, "");\n }\n /** List of URI template parameter keys, if the `Link` is templated. */\n get templateParameters() {\n return this.templated ? new Ve(this.href).parameters : /* @__PURE__ */ new Set();\n }\n /** Expands the `Link`\'s HREF by replacing URI template variables by the given parameters.\n * See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570\n */\n expandTemplate(t) {\n return new ct({\n href: new Ve(this.href).expand(t),\n templated: !1\n });\n }\n /**\n * Makes a copy of this [Link] after merging in the given additional other [properties].\n */\n addProperties(t) {\n const e = ct.deserialize(this.serialize());\n return e.properties = e.properties ? e.properties?.add(t) : new P(t), e;\n }\n /**\n * Creates a [Locator] from a reading order [Link].\n */\n get locator() {\n let t = this.href.split("#");\n return new L({\n href: t.length > 0 && t[0] !== void 0 ? t[0] : this.href,\n type: this.type ?? "",\n title: this.title,\n locations: new S({\n fragments: t.length > 1 && t[1] !== void 0 ? [t[1]] : []\n })\n });\n }\n}\nclass Qt {\n /**\n * Creates a [Links].\n */\n constructor(t) {\n this.items = t;\n }\n /**\n * Creates a list of [Link] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (t && Array.isArray(t))\n return new Qt(\n t.map((e) => ct.deserialize(e)).filter((e) => e !== void 0)\n );\n }\n /**\n * Serializes an array of [Link] to its RWPM JSON representation.\n */\n serialize() {\n return this.items.map((t) => t.serialize());\n }\n /** Finds the first link with the given relation. */\n findWithRel(t) {\n const e = (i) => i.rels && i.rels.has(t);\n return this.items.find(e);\n }\n /** Finds all the links with the given relation. */\n filterByRel(t) {\n const e = (i) => i.rels && i.rels.has(t);\n return this.items.filter(e);\n }\n /** Finds the first link matching the given HREF. */\n findWithHref(t) {\n const e = (i) => i.href === t;\n return this.items.find(e);\n }\n /** Finds the index of the first link matching the given HREF. */\n findIndexWithHref(t) {\n const e = (i) => i.href === t;\n return this.items.findIndex(e);\n }\n /** Finds the first link matching the given media type. */\n findWithMediaType(t) {\n const e = (i) => i.mediaType.matches(t);\n return this.items.find(e);\n }\n /** Finds all the links matching the given media type. */\n filterByMediaType(t) {\n const e = (i) => i.mediaType.matches(t);\n return this.items.filter(e);\n }\n /** Finds all the links matching any of the given media types. */\n filterByMediaTypes(t) {\n const e = (i) => {\n for (const A of t)\n if (i.mediaType.matches(A))\n return !0;\n return !1;\n };\n return this.items.filter(e);\n }\n /** Returns whether all the resources in the collection are audio clips. */\n everyIsAudio() {\n const t = (e) => e.mediaType.isAudio;\n return this.items.length > 0 && this.items.every(t);\n }\n /** Returns whether all the resources in the collection are bitmaps. */\n everyIsBitmap() {\n const t = (e) => e.mediaType.isBitmap;\n return this.items.length > 0 && this.items.every(t);\n }\n /** Returns whether all the resources in the collection are HTML documents. */\n everyIsHTML() {\n const t = (e) => e.mediaType.isHTML;\n return this.items.length > 0 && this.items.every(t);\n }\n /** Returns whether all the resources in the collection are video clips. */\n everyIsVideo() {\n const t = (e) => e.mediaType.isVideo;\n return this.items.length > 0 && this.items.every(t);\n }\n /** Returns whether all the resources in the collection are matching any of the given media types. */\n everyMatchesMediaType(t) {\n return Array.isArray(t) ? this.items.length > 0 && this.items.every((e) => {\n for (const i of t)\n return e.mediaType.matches(i);\n return !1;\n }) : this.items.length > 0 && this.items.every((e) => e.mediaType.matches(t));\n }\n filterLinksHasType() {\n return this.items.filter((t) => t.type);\n }\n}\nP.prototype.getContains = function() {\n return new Set(this.otherProperties.contains || []);\n};\nclass Yt {\n /**\n * Creates a [DomRange].\n */\n constructor(t) {\n this.cssSelector = t.cssSelector, this.textNodeIndex = t.textNodeIndex, this.charOffset = t.charOffset;\n }\n /**\n * Parses a [DomRangePoint] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (!(t && t.cssSelector)) return;\n let e = T(t.textNodeIndex);\n if (e === void 0) return;\n let i = T(t.charOffset);\n return i === void 0 && (i = T(t.offset)), new Yt({\n cssSelector: t.cssSelector,\n textNodeIndex: e,\n charOffset: i\n });\n }\n /**\n * Serializes a [DomRangePoint] to its RWPM JSON representation.\n */\n serialize() {\n const t = {\n cssSelector: this.cssSelector,\n textNodeIndex: this.textNodeIndex\n };\n return this.charOffset !== void 0 && (t.charOffset = this.charOffset), t;\n }\n}\nclass Be {\n /**\n * Creates a [DomRange].\n */\n constructor(t) {\n this.start = t.start, this.end = t.end;\n }\n /**\n * Parses a [DomRange] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (!t) return;\n let e = Yt.deserialize(t.start);\n if (e)\n return new Be({\n start: e,\n end: Yt.deserialize(t.end)\n });\n }\n /**\n * Serializes a [DomRange] to its RWPM JSON representation.\n */\n serialize() {\n const t = { start: this.start.serialize() };\n return this.end && (t.end = this.end.serialize()), t;\n }\n}\nS.prototype.getCssSelector = function() {\n return this.otherLocations?.get("cssSelector");\n};\nS.prototype.getPartialCfi = function() {\n return this.otherLocations?.get("partialCfi");\n};\nS.prototype.getDomRange = function() {\n return Be.deserialize(this.otherLocations?.get("domRange"));\n};\nS.prototype.fragmentParameters = function() {\n return new Map(\n 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) => [\n r[0].trim().toLowerCase(),\n r[1].trim()\n ])\n );\n};\nS.prototype.htmlId = function() {\n if (!this.fragments.length) return;\n let r = this.fragments.find((t) => t.length && !t.includes("="));\n if (!r) {\n const t = this.fragmentParameters();\n t.has("id") ? r = t.get("id") : t.has("name") && (r = t.get("name"));\n }\n return r?.startsWith("#") ? r.slice(1) : r;\n};\nS.prototype.page = function() {\n const r = parseInt(this.fragmentParameters().get("page"));\n if (!isNaN(r) && r >= 0) return r;\n};\nS.prototype.time = function() {\n const r = parseInt(this.fragmentParameters().get("t"));\n if (!isNaN(r)) return r;\n};\nS.prototype.space = function() {\n const r = this.fragmentParameters();\n if (!r.has("xywh")) return;\n const t = r.get("xywh").split(",").map((e) => parseInt(e));\n if (t.length === 4 && !t.some(isNaN))\n return t;\n};\nclass we {\n /** Creates a [Price]. */\n constructor(t) {\n this.currency = t.currency, this.value = t.value;\n }\n /**\n * Parses a [Price] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (!t) return;\n let e = t.currency;\n if (!(e && typeof e == "string" && e.length > 0))\n return;\n let i = T(t.value);\n if (i !== void 0)\n return new we({ currency: e, value: i });\n }\n /**\n * Serializes a [Price] to its RWPM JSON representation.\n */\n serialize() {\n return { currency: this.currency, value: this.value };\n }\n}\nclass pt {\n /** Creates a [Acquisition]. */\n constructor(t) {\n this.type = t.type, this.children = t.children;\n }\n /**\n * Parses a [Acquisition] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (t && t.type)\n return new pt({\n type: t.type,\n children: pt.deserializeArray(t.children)\n });\n }\n static deserializeArray(t) {\n if (Array.isArray(t))\n return t.map((e) => pt.deserialize(e)).filter((e) => e !== void 0);\n }\n /**\n * Serializes a [Acquisition] to its RWPM JSON representation.\n */\n serialize() {\n const t = { type: this.type };\n return this.children && (t.children = this.children.map((e) => e.serialize())), t;\n }\n}\nclass Ee {\n /** Creates a [Price]. */\n constructor(t) {\n this.total = t.total, this.position = t.position;\n }\n /**\n * Parses a [Holds] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (t)\n return new Ee({\n total: T(t.total),\n position: T(t.position)\n });\n }\n /**\n * Serializes a [Holds] to its RWPM JSON representation.\n */\n serialize() {\n const t = {};\n return this.total !== void 0 && (t.total = this.total), this.position !== void 0 && (t.position = this.position), t;\n }\n}\nclass Ie {\n /** Creates a [Copies]. */\n constructor(t) {\n this.total = t.total, this.available = t.available;\n }\n /**\n * Parses a [Copies] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (t)\n return new Ie({\n total: T(t.total),\n available: T(t.available)\n });\n }\n /**\n * Serializes a [Copies] to its RWPM JSON representation.\n */\n serialize() {\n const t = {};\n return this.total !== void 0 && (t.total = this.total), this.available !== void 0 && (t.available = this.available), t;\n }\n}\nclass ye {\n /** Creates a [Availability]. */\n constructor(t) {\n this.state = t.state, this.since = t.since, this.until = t.until;\n }\n /**\n * Parses a [Availability] from its RWPM JSON representation.\n */\n static deserialize(t) {\n if (t && t.state)\n return new ye({\n state: t.state,\n since: je(t.since),\n until: je(t.until)\n });\n }\n /**\n * Serializes a [Availability] to its RWPM JSON representation.\n */\n serialize() {\n const t = { state: this.state };\n return this.since !== void 0 && (t.since = this.since.toISOString()), this.until !== void 0 && (t.until = this.until.toISOString()), t;\n }\n}\nP.prototype.getNumberOfItems = function() {\n return T(this.otherProperties.numberOfItems);\n};\nP.prototype.getPrice = function() {\n return we.deserialize(this.otherProperties.price);\n};\nP.prototype.getIndirectAcquisitions = function() {\n const r = this.otherProperties.indirectAcquisition;\n if (r && Array.isArray(r))\n return r.map((t) => pt.deserialize(t)).filter((t) => t !== void 0);\n};\nP.prototype.getHolds = function() {\n return Ee.deserialize(this.otherProperties.holds);\n};\nP.prototype.getCopies = function() {\n return Ie.deserialize(this.otherProperties.copies);\n};\nP.prototype.getAvailability = function() {\n return ye.deserialize(this.otherProperties.availability);\n};\nP.prototype.getAuthenticate = function() {\n return ct.deserialize(this.otherProperties.authenticate);\n};\nconst UA = "CssSelectorGenerator";\nfunction ve(r = "unknown problem", ...t) {\n console.warn(`${UA}: ${r}`, ...t);\n}\nfunction RA(r) {\n return r instanceof RegExp;\n}\nfunction CA(r) {\n return r.replace(/[|\\\\{}()[\\]^$+?.]/g, "\\\\$&").replace(/\\*/g, ".+");\n}\nfunction SA(r) {\n const t = r.map((e) => {\n if (RA(e))\n return (i) => e.test(i);\n if (typeof e == "function")\n return (i) => {\n const A = e(i);\n return typeof A != "boolean" ? (ve("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It\'s result will be ignored.", e), !1) : A;\n };\n if (typeof e == "string") {\n const i = new RegExp("^" + CA(e) + "$");\n return (A) => i.test(A);\n }\n return ve("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", e), () => !1;\n });\n return (e) => t.some((i) => i(e));\n}\nSA([\n "class",\n "id",\n // Angular attributes\n "ng-*"\n]);\nclass yt {\n}\nfunction De(r) {\n return r.split("").reverse().join("");\n}\nfunction zA(r, t, e) {\n const i = De(t);\n return e.map((A) => {\n const n = Math.max(0, A.end - t.length - A.errors), s = De(r.slice(n, A.end));\n return {\n start: yi(s, i, A.errors).reduce((o, a) => A.end - a.end < o ? A.end - a.end : o, A.end),\n end: A.end,\n errors: A.errors\n };\n });\n}\nfunction Zt(r) {\n return (r | -r) >> 31 & 1;\n}\nfunction He(r, t, e, i) {\n let A = r.P[e], n = r.M[e];\n const s = i >>> 31, o = t[e] | s, a = o | n, h = (o & A) + A ^ A | o;\n let c = n | ~(h | A), d = A & h;\n const g = Zt(c & r.lastRowMask[e]) - Zt(d & r.lastRowMask[e]);\n return c <<= 1, d <<= 1, d |= s, c |= Zt(i) - s, A = d | ~(a | c), n = c & a, r.P[e] = A, r.M[e] = n, g;\n}\nfunction yi(r, t, e) {\n if (t.length === 0)\n return [];\n e = Math.min(e, t.length);\n const i = [], A = 32, n = Math.ceil(t.length / A) - 1, s = {\n P: new Uint32Array(n + 1),\n M: new Uint32Array(n + 1),\n lastRowMask: new Uint32Array(n + 1)\n };\n s.lastRowMask.fill(1 << 31), s.lastRowMask[n] = 1 << (t.length - 1) % A;\n const o = new Uint32Array(n + 1), a = /* @__PURE__ */ new Map(), h = [];\n for (let g = 0; g < 256; g++)\n h.push(o);\n for (let g = 0; g < t.length; g += 1) {\n const M = t.charCodeAt(g);\n if (a.has(M))\n continue;\n const l = new Uint32Array(n + 1);\n a.set(M, l), M < h.length && (h[M] = l);\n for (let p = 0; p <= n; p += 1) {\n l[p] = 0;\n for (let w = 0; w < A; w += 1) {\n const E = p * A + w;\n E >= t.length || t.charCodeAt(E) === M && (l[p] |= 1 << w);\n }\n }\n }\n let c = Math.max(0, Math.ceil(e / A) - 1);\n const d = new Uint32Array(n + 1);\n for (let g = 0; g <= c; g += 1)\n d[g] = (g + 1) * A;\n d[n] = t.length;\n for (let g = 0; g <= c; g += 1)\n s.P[g] = -1, s.M[g] = 0;\n for (let g = 0; g < r.length; g += 1) {\n const M = r.charCodeAt(g);\n let l;\n M < h.length ? l = h[M] : (l = a.get(M), typeof l > "u" && (l = o));\n let p = 0;\n for (let w = 0; w <= c; w += 1)\n p = He(s, l, w, p), d[w] += p;\n if (d[c] - p <= e && c < n && (l[c + 1] & 1 || p < 0)) {\n c += 1, s.P[c] = -1, s.M[c] = 0;\n let w;\n if (c === n) {\n const E = t.length % A;\n w = E === 0 ? A : E;\n } else\n w = A;\n d[c] = d[c - 1] + w - p + He(s, l, c, p);\n } else\n for (; c > 0 && d[c] >= e + A; )\n c -= 1;\n c === n && d[c] <= e && (d[c] < e && i.splice(0, i.length), i.push({\n start: -1,\n end: g + 1,\n errors: d[c]\n }), e = d[c]);\n }\n return i;\n}\nfunction QA(r, t, e) {\n const i = yi(r, t, e);\n return zA(r, t, i);\n}\nfunction Fi(r, t, e) {\n let i = 0;\n const A = [];\n for (; i !== -1; )\n i = r.indexOf(t, i), i !== -1 && (A.push({\n start: i,\n end: i + t.length,\n errors: 0\n }), i += 1);\n return A.length > 0 ? A : QA(r, t, e);\n}\nfunction Ge(r, t) {\n return t.length === 0 || r.length === 0 ? 0 : 1 - Fi(r, t, t.length)[0].errors / t.length;\n}\nfunction YA(r, t, e = {}) {\n if (t.length === 0)\n return null;\n const i = Math.min(256, t.length / 2), A = Fi(r, t, i);\n if (A.length === 0)\n return null;\n const n = (o) => {\n const a = 1 - o.errors / t.length, h = e.prefix ? Ge(\n r.slice(\n Math.max(0, o.start - e.prefix.length),\n o.start\n ),\n e.prefix\n ) : 1, c = e.suffix ? Ge(\n r.slice(o.end, o.end + e.suffix.length),\n e.suffix\n ) : 1;\n let d = 1;\n return typeof e.hint == "number" && (d = 1 - Math.abs(o.start - e.hint) / r.length), (50 * a + 20 * h + 20 * c + 2 * d) / 92;\n }, s = A.map((o) => ({\n start: o.start,\n end: o.end,\n score: n(o)\n }));\n return s.sort((o, a) => a.score - o.score), s[0];\n}\nfunction re(r, t, e) {\n const i = e === 1 ? t : t - 1;\n if (r.charAt(i).trim() !== "")\n return t;\n let A, n;\n if (e === 2 ? (A = r.substring(0, t), n = A.trimEnd()) : (A = r.substring(t), n = A.trimStart()), !n.length)\n return -1;\n const s = A.length - n.length;\n return e === 2 ? t - s : t + s;\n}\nfunction ke(r, t) {\n const e = r.commonAncestorContainer.ownerDocument.createNodeIterator(\n r.commonAncestorContainer,\n NodeFilter.SHOW_TEXT\n ), i = t === 1 ? r.startContainer : r.endContainer, A = t === 1 ? r.endContainer : r.startContainer;\n let n = e.nextNode();\n for (; n && n !== i; )\n n = e.nextNode();\n t === 2 && (n = e.previousNode());\n let s = -1;\n const o = () => {\n if (n = t === 1 ? e.nextNode() : e.previousNode(), n) {\n const a = n.textContent, h = t === 1 ? 0 : a.length;\n s = re(a, h, t);\n }\n };\n for (; n && s === -1 && n !== A; )\n o();\n if (n && s >= 0)\n return { node: n, offset: s };\n throw new RangeError("No text nodes with non-whitespace text found in range");\n}\nfunction NA(r) {\n if (!r.toString().trim().length)\n throw new RangeError("Range contains no non-whitespace text");\n if (r.startContainer.nodeType !== Node.TEXT_NODE)\n throw new RangeError("Range startContainer is not a text node");\n if (r.endContainer.nodeType !== Node.TEXT_NODE)\n throw new RangeError("Range endContainer is not a text node");\n const t = r.cloneRange();\n let e = !1, i = !1;\n const A = {\n start: re(\n r.startContainer.textContent,\n r.startOffset,\n 1\n /* Forwards */\n ),\n end: re(\n r.endContainer.textContent,\n r.endOffset,\n 2\n /* Backwards */\n )\n };\n if (A.start >= 0 && (t.setStart(r.startContainer, A.start), e = !0), A.end > 0 && (t.setEnd(r.endContainer, A.end), i = !0), e && i)\n return t;\n if (!e) {\n const { node: n, offset: s } = ke(\n t,\n 1\n /* Forwards */\n );\n n && s >= 0 && t.setStart(n, s);\n }\n if (!i) {\n const { node: n, offset: s } = ke(\n t,\n 2\n /* Backwards */\n );\n n && s > 0 && t.setEnd(n, s);\n }\n return t;\n}\nfunction Ui(r) {\n switch (r.nodeType) {\n case Node.ELEMENT_NODE:\n case Node.TEXT_NODE:\n return r.textContent?.length ?? 0;\n default:\n return 0;\n }\n}\nfunction Je(r) {\n let t = r.previousSibling, e = 0;\n for (; t; )\n e += Ui(t), t = t.previousSibling;\n return e;\n}\nfunction Ri(r, ...t) {\n let e = t.shift();\n const i = r.ownerDocument.createNodeIterator(\n r,\n NodeFilter.SHOW_TEXT\n ), A = [];\n let n = i.nextNode(), s, o = 0;\n for (; e !== void 0 && n; )\n s = n, o + s.data.length > e ? (A.push({ node: s, offset: e - o }), e = t.shift()) : (n = i.nextNode(), o += s.data.length);\n for (; e !== void 0 && s && o === e; )\n A.push({ node: s, offset: s.data.length }), e = t.shift();\n if (e !== void 0)\n throw new RangeError("Offset exceeds text length");\n return A;\n}\nclass k {\n constructor(t, e) {\n if (e < 0)\n throw new Error("Offset is invalid");\n this.element = t, this.offset = e;\n }\n /**\n * Return a copy of this position with offset relative to a given ancestor\n * element.\n *\n * @param parent - Ancestor of `this.element`\n */\n relativeTo(t) {\n if (!t.contains(this.element))\n throw new Error("Parent is not an ancestor of current element");\n let e = this.element, i = this.offset;\n for (; e !== t; )\n i += Je(e), e = e.parentElement;\n return new k(e, i);\n }\n /**\n * Resolve the position to a specific text node and offset within that node.\n *\n * Throws if `this.offset` exceeds the length of the element\'s text. In the\n * case where the element has no text and `this.offset` is 0, the `direction`\n * option determines what happens.\n *\n * Offsets at the boundary between two nodes are resolved to the start of the\n * node that begins at the boundary.\n *\n * @param options.direction - Specifies in which direction to search for the\n * nearest text node if `this.offset` is `0` and\n * `this.element` has no text. If not specified an\n * error is thrown.\n *\n * @throws {RangeError}\n */\n resolve(t = {}) {\n try {\n return Ri(this.element, this.offset)[0];\n } catch (e) {\n if (this.offset === 0 && t.direction !== void 0) {\n const i = document.createTreeWalker(\n this.element.getRootNode(),\n NodeFilter.SHOW_TEXT\n );\n i.currentNode = this.element;\n const A = t.direction === 1, n = A ? i.nextNode() : i.previousNode();\n if (!n)\n throw e;\n return { node: n, offset: A ? 0 : n.data.length };\n } else\n throw e;\n }\n }\n /**\n * Construct a `TextPosition` that refers to the `offset`th character within\n * `node`.\n */\n static fromCharOffset(t, e) {\n switch (t.nodeType) {\n case Node.TEXT_NODE:\n return k.fromPoint(t, e);\n case Node.ELEMENT_NODE:\n return new k(t, e);\n default:\n throw new Error("Node is not an element or text node");\n }\n }\n /**\n * Construct a `TextPosition` representing the range start or end point (node, offset).\n *\n * @param node\n * @param offset - Offset within the node\n */\n static fromPoint(t, e) {\n switch (t.nodeType) {\n case Node.TEXT_NODE: {\n if (e < 0 || e > t.data.length)\n throw new Error("Text node offset is out of range");\n if (!t.parentElement)\n throw new Error("Text node has no parent");\n const i = Je(t) + e;\n return new k(t.parentElement, i);\n }\n case Node.ELEMENT_NODE: {\n if (e < 0 || e > t.childNodes.length)\n throw new Error("Child node offset is out of range");\n let i = 0;\n for (let A = 0; A < e; A++)\n i += Ui(t.childNodes[A]);\n return new k(t, i);\n }\n default:\n throw new Error("Point is not in an element or text node");\n }\n }\n}\nclass K {\n constructor(t, e) {\n this.start = t, this.end = e;\n }\n /**\n * Create a new TextRange whose `start` and `end` are computed relative to\n * `element`. `element` must be an ancestor of both `start.element` and\n * `end.element`.\n */\n relativeTo(t) {\n return new K(\n this.start.relativeTo(t),\n this.end.relativeTo(t)\n );\n }\n /**\n * Resolve this TextRange to a (DOM) Range.\n *\n * The resulting DOM Range will always start and end in a `Text` node.\n * Hence `TextRange.fromRange(range).toRange()` can be used to "shrink" a\n * range to the text it contains.\n *\n * May throw if the `start` or `end` positions cannot be resolved to a range.\n */\n toRange() {\n let t, e;\n this.start.element === this.end.element && this.start.offset <= this.end.offset ? [t, e] = Ri(\n this.start.element,\n this.start.offset,\n this.end.offset\n ) : (t = this.start.resolve({\n direction: 1\n /* FORWARDS */\n }), e = this.end.resolve({\n direction: 2\n /* BACKWARDS */\n }));\n const i = new Range();\n return i.setStart(t.node, t.offset), i.setEnd(e.node, e.offset), i;\n }\n /**\n * Create a TextRange from a (DOM) Range\n */\n static fromRange(t) {\n const e = k.fromPoint(\n t.startContainer,\n t.startOffset\n ), i = k.fromPoint(t.endContainer, t.endOffset);\n return new K(e, i);\n }\n /**\n * Create a TextRange representing the `start`th to `end`th characters in\n * `root`\n */\n static fromOffsets(t, e, i) {\n return new K(\n new k(t, e),\n new k(t, i)\n );\n }\n /**\n * Return a new Range representing `range` trimmed of any leading or trailing\n * whitespace\n */\n static trimmedRange(t) {\n return NA(K.fromRange(t).toRange());\n }\n}\nclass Nt {\n constructor(t, e, i) {\n this.root = t, this.start = e, this.end = i;\n }\n static fromRange(t, e) {\n const i = K.fromRange(e).relativeTo(t);\n return new Nt(\n t,\n i.start.offset,\n i.end.offset\n );\n }\n static fromSelector(t, e) {\n return new Nt(t, e.start, e.end);\n }\n toSelector() {\n return {\n type: "TextPositionSelector",\n start: this.start,\n end: this.end\n };\n }\n toRange() {\n return K.fromOffsets(this.root, this.start, this.end).toRange();\n }\n}\nclass xt {\n /**\n * @param root - A root element from which to anchor.\n */\n constructor(t, e, i = {}) {\n this.root = t, this.exact = e, this.context = i;\n }\n /**\n * Create a `TextQuoteAnchor` from a range.\n *\n * Will throw if `range` does not contain any text nodes.\n */\n static fromRange(t, e) {\n const i = t.textContent, A = K.fromRange(e).relativeTo(t), n = A.start.offset, s = A.end.offset, o = 32;\n return new xt(t, i.slice(n, s), {\n prefix: i.slice(Math.max(0, n - o), n),\n suffix: i.slice(s, Math.min(i.length, s + o))\n });\n }\n static fromSelector(t, e) {\n const { prefix: i, suffix: A } = e;\n return new xt(t, e.exact, { prefix: i, suffix: A });\n }\n toSelector() {\n return {\n type: "TextQuoteSelector",\n exact: this.exact,\n prefix: this.context.prefix,\n suffix: this.context.suffix\n };\n }\n toRange(t = {}) {\n return this.toPositionAnchor(t).toRange();\n }\n toPositionAnchor(t = {}) {\n const e = this.root.textContent, i = YA(e, this.exact, {\n ...this.context,\n hint: t.hint\n });\n if (!i)\n throw new Error("Quote not found");\n return new Nt(this.root, i.start, i.end);\n }\n}\nfunction xA(r) {\n const t = r.tagName.toUpperCase();\n return t === "IMG" || t === "VIDEO" || t === "AUDIO" || t === "IFRAME" || t === "OBJECT" || t === "EMBED" || t === "CANVAS";\n}\nfunction Wt(r, t) {\n try {\n const e = t.locations, i = t.text;\n if (i && i.highlight) {\n let A;\n e && e.getCssSelector() && (A = r.querySelector(e.getCssSelector())), A || (A = r.body);\n const n = new xt(A, i.highlight, {\n prefix: i.before,\n suffix: i.after\n });\n try {\n return n.toRange();\n } catch {\n return console.warn("Quote not found:", n), null;\n }\n }\n if (e) {\n let A = null;\n if (!A && e.getCssSelector() && (A = r.querySelector(e.getCssSelector())), !A && e.fragments) {\n for (const n of e.fragments)\n if (A = r.getElementById(n), A)\n break;\n }\n if (A) {\n const n = r.createRange();\n return A.childNodes.length === 0 || xA(A) ? (n.selectNode(A), n) : (n.setStartBefore(A), n.setEndAfter(A), n);\n }\n }\n } catch (e) {\n console.error(e);\n }\n return null;\n}\nfunction TA(r, t) {\n let e = r.getClientRects();\n e.length || r.commonAncestorContainer.nodeType === Node.ELEMENT_NODE && (e = r.commonAncestorContainer.getClientRects());\n const i = 1, A = [];\n for (const h of e)\n A.push({\n bottom: h.bottom,\n height: h.height,\n left: h.left,\n right: h.right,\n top: h.top,\n width: h.width\n });\n const n = Ci(\n A,\n i\n ), s = bA(n, i), o = Si(s), a = 4;\n for (let h = o.length - 1; h >= 0; h--) {\n const c = o[h];\n if (!(c.width * c.height > a))\n if (o.length > 1)\n o.splice(h, 1);\n else\n break;\n }\n return o;\n}\nfunction Ci(r, t, e) {\n for (let i = 0; i < r.length; i++)\n for (let A = i + 1; A < r.length; A++) {\n const n = r[i], s = r[A];\n if (n === s)\n continue;\n const o = D(n.top, s.top, t) && D(n.bottom, s.bottom, t), a = D(n.left, s.left, t) && D(n.right, s.right, t);\n if (o && !a && zi(n, s, t)) {\n const h = r.filter((d) => d !== n && d !== s), c = PA(n, s);\n return h.push(c), Ci(\n h,\n t\n );\n }\n }\n return r;\n}\nfunction PA(r, t) {\n const e = Math.min(r.left, t.left), i = Math.max(r.right, t.right), A = Math.min(r.top, t.top), n = Math.max(r.bottom, t.bottom);\n return {\n bottom: n,\n height: n - A,\n left: e,\n right: i,\n top: A,\n width: i - e\n };\n}\nfunction bA(r, t) {\n const e = new Set(r);\n for (const i of r) {\n if (!(i.width > 1 && i.height > 1)) {\n e.delete(i);\n continue;\n }\n for (const A of r)\n if (i !== A && e.has(A) && jA(A, i, t)) {\n e.delete(i);\n break;\n }\n }\n return Array.from(e);\n}\nfunction jA(r, t, e) {\n return Ft(r, t.left, t.top, e) && Ft(r, t.right, t.top, e) && Ft(r, t.left, t.bottom, e) && Ft(r, t.right, t.bottom, e);\n}\nfunction Ft(r, t, e, i) {\n return (r.left < t || D(r.left, t, i)) && (r.right > t || D(r.right, t, i)) && (r.top < e || D(r.top, e, i)) && (r.bottom > e || D(r.bottom, e, i));\n}\nfunction Si(r) {\n for (let t = 0; t < r.length; t++)\n for (let e = t + 1; e < r.length; e++) {\n const i = r[t], A = r[e];\n if (i !== A && zi(i, A, -1)) {\n let n = [], s;\n const o = We(i, A);\n if (o.length === 1)\n n = o, s = i;\n else {\n const h = We(A, i);\n o.length < h.length ? (n = o, s = i) : (n = h, s = A);\n }\n const a = r.filter((h) => h !== s);\n return Array.prototype.push.apply(a, n), Si(a);\n }\n }\n return r;\n}\nfunction We(r, t) {\n const e = VA(t, r);\n if (e.height === 0 || e.width === 0)\n return [r];\n const i = [];\n {\n const A = {\n bottom: r.bottom,\n height: 0,\n left: r.left,\n right: e.left,\n top: r.top,\n width: 0\n };\n A.width = A.right - A.left, A.height = A.bottom - A.top, A.height !== 0 && A.width !== 0 && i.push(A);\n }\n {\n const A = {\n bottom: e.top,\n height: 0,\n left: e.left,\n right: e.right,\n top: r.top,\n width: 0\n };\n A.width = A.right - A.left, A.height = A.bottom - A.top, A.height !== 0 && A.width !== 0 && i.push(A);\n }\n {\n const A = {\n bottom: r.bottom,\n height: 0,\n left: e.left,\n right: e.right,\n top: e.bottom,\n width: 0\n };\n A.width = A.right - A.left, A.height = A.bottom - A.top, A.height !== 0 && A.width !== 0 && i.push(A);\n }\n {\n const A = {\n bottom: r.bottom,\n height: 0,\n left: e.right,\n right: r.right,\n top: r.top,\n width: 0\n };\n A.width = A.right - A.left, A.height = A.bottom - A.top, A.height !== 0 && A.width !== 0 && i.push(A);\n }\n return i;\n}\nfunction VA(r, t) {\n const e = Math.max(r.left, t.left), i = Math.min(r.right, t.right), A = Math.max(r.top, t.top), n = Math.min(r.bottom, t.bottom);\n return {\n bottom: n,\n height: Math.max(0, n - A),\n left: e,\n right: i,\n top: A,\n width: Math.max(0, i - e)\n };\n}\nfunction zi(r, t, e) {\n return (r.left < t.right || e >= 0 && D(r.left, t.right, e)) && (t.left < r.right || e >= 0 && D(t.left, r.right, e)) && (r.top < t.bottom || e >= 0 && D(r.top, t.bottom, e)) && (t.top < r.bottom || e >= 0 && D(t.top, r.bottom, e));\n}\nfunction D(r, t, e) {\n return Math.abs(r - t) <= e;\n}\nfunction Fe(r) {\n const t = {}, e = r.document.documentElement.style;\n for (const i in r.document.documentElement.style)\n Object.hasOwn(e, i) && !Number.isNaN(Number.parseInt(i)) && (t[e[i]] = e.getPropertyValue(e[i]));\n return t;\n}\nfunction Qi(r, t) {\n const e = Fe(r);\n Object.keys(e).forEach((i) => {\n t.hasOwnProperty(i) || Ot(r, i);\n }), Object.entries(t).forEach(([i, A]) => {\n e[i] !== A && Bt(r, i, A);\n });\n}\nfunction Oe(r, t) {\n return r.document.documentElement.style.getPropertyValue(t);\n}\nfunction Bt(r, t, e) {\n r.document.documentElement.style.setProperty(t, e);\n}\nfunction Ot(r, t) {\n r.document.documentElement.style.removeProperty(t);\n}\nconst vA = (r) => {\n if (r.startsWith("rgb")) {\n const t = r.match(/rgb\\((\\d+),\\s(\\d+),\\s(\\d+)(?:,\\s(\\d+))?\\)/);\n if (t)\n return {\n r: parseInt(t[1], 10),\n g: parseInt(t[2], 10),\n b: parseInt(t[3], 10),\n a: t[4] ? parseInt(t[4], 10) / 255 : 1\n };\n } else if (r.startsWith("#")) {\n const t = r.slice(1);\n if (t.length === 3 || t.length === 4)\n return {\n r: parseInt(t[0] + t[0], 16) / 255,\n g: parseInt(t[1] + t[1], 16) / 255,\n b: parseInt(t[2] + t[2], 16) / 255,\n a: t.length === 4 ? parseInt(t[3] + t[3], 16) / 255 : 1\n };\n if (t.length === 6 || t.length === 8)\n return {\n r: parseInt(t[0] + t[1], 16) / 255,\n g: parseInt(t[2] + t[3], 16) / 255,\n b: parseInt(t[4] + t[5], 16) / 255,\n a: t.length === 8 ? parseInt(t[6] + t[7], 16) / 255 : 1\n };\n }\n return { r: 0, g: 0, b: 0, a: 1 };\n}, DA = (r) => 0.2126 * r.r * r.a + 0.7152 * r.g * r.a + 0.0722 * r.b * r.a, HA = (r) => {\n const t = vA(r);\n return DA(t) < 128;\n}, GA = () => "Highlight" in window, Le = ["IMG", "IMAGE", "AUDIO", "VIDEO", "SVG"];\nclass kA {\n /**\n * Creates a DecorationGroup object\n * @param id Unique HTML ID-adhering name of the group\n * @param name Human-readable name of the group\n */\n constructor(t, e, i, A) {\n this.wnd = t, this.comms = e, this.id = i, this.name = A, this.items = [], this.lastItemId = 0, this.container = void 0, this.activateable = !1, this.experimentalHighlights = !1, this.currentRender = 0, GA() && (this.experimentalHighlights = !0, this.notTextFlag = /* @__PURE__ */ new Map());\n }\n get activeable() {\n return this.activateable;\n }\n set activeable(t) {\n this.activateable = t;\n }\n /**\n * Adds a new decoration to the group.\n * @param decoration Decoration to add\n */\n add(t) {\n const e = `${this.id}-${this.lastItemId++}`, i = Wt(this.wnd.document, t.locator);\n if (!i) {\n this.comms.log("Can\'t locate DOM range for decoration", t);\n return;\n }\n const A = i.commonAncestorContainer;\n A.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (Le.includes(A.nodeName.toUpperCase()) && this.notTextFlag?.set(e, !0), A.querySelector(Le.join(", ").toLowerCase()) && this.notTextFlag?.set(e, !0), (A.textContent?.trim() || "").length === 0 && this.notTextFlag?.set(e, !0));\n const n = {\n decoration: t,\n id: e,\n range: i\n };\n this.items.push(n), this.layout(n), this.renderLayout([n]);\n }\n /**\n * Removes the decoration with given ID from the group.\n * @param identifier ID of item to remove\n */\n remove(t) {\n const e = this.items.findIndex((A) => A.decoration.id === t);\n if (e < 0) return;\n const i = this.items[e];\n this.items.splice(e, 1), i.clickableElements = void 0, i.container && (i.container.remove(), i.container = void 0), this.experimentalHighlights && !this.notTextFlag?.has(i.id) && this.wnd.CSS.highlights.get(this.id)?.delete(i.range), this.notTextFlag?.delete(i.id);\n }\n /**\n * Notifies that the given decoration was modified and needs to be updated.\n * @param decoration Decoration to update\n */\n update(t) {\n this.remove(t.id), this.add(t);\n }\n /**\n * Removes all decorations from this group.\n */\n clear() {\n this.clearContainer(), this.items.length = 0, this.notTextFlag?.clear();\n }\n /**\n * Recreates the decoration elements.\n * To be called after reflowing the resource, for example.\n */\n requestLayout() {\n this.wnd.cancelAnimationFrame(this.currentRender), this.clearContainer(), this.items.forEach((t) => this.layout(t)), this.renderLayout(this.items);\n }\n experimentalLayout(t) {\n const [e, i] = this.requireContainer(!0);\n i.add(t.range), e.innerHTML = `\n ::highlight(${this.id}) {\n color: black;\n background-color: ${t.decoration?.style?.tint ?? "yellow"};\n }`;\n }\n /**\n * Layouts a single DecorationItem.\n * @param item \n */\n layout(t) {\n if (this.experimentalHighlights && !this.notTextFlag?.has(t.id))\n return this.experimentalLayout(t);\n const e = this.wnd.document.createElement("div");\n e.setAttribute("id", t.id), e.style.setProperty("pointer-events", "none");\n const i = this.wnd.innerWidth, A = parseInt(\n getComputedStyle(this.wnd.document.documentElement).getPropertyValue(\n "column-count"\n )\n ), n = i / (A || 1), s = this.wnd.document.scrollingElement, o = s.scrollLeft, a = s.scrollTop, h = (l, p, w) => {\n if (l.style.position = "absolute", t.decoration?.style?.width === "viewport") {\n l.style.width = `${i}px`, l.style.height = `${p.height}px`;\n let E = Math.floor(p.left / i) * i;\n l.style.left = `${E + o}px`, l.style.top = `${p.top + a}px`;\n } else if (t.decoration?.style?.width === "bounds")\n l.style.width = `${w.width}px`, l.style.height = `${p.height}px`, l.style.left = `${w.left + o}px`, l.style.top = `${p.top + a}px`;\n else if (t.decoration?.style?.width === "page") {\n l.style.width = `${n}px`, l.style.height = `${p.height}px`;\n let E = Math.floor(p.left / n) * n;\n l.style.left = `${E + o}px`, l.style.top = `${p.top + a}px`;\n } else\n l.style.width = `${p.width}px`, l.style.height = `${p.height}px`, l.style.left = `${p.left + o}px`, l.style.top = `${p.top + a}px`;\n }, c = t.range.getBoundingClientRect();\n let d = this.wnd.document.createElement("template");\n const g = Oe(this.wnd, "--USER__appearance") === "readium-night-on" || HA(Oe(this.wnd, "--USER__backgroundColor"));\n d.innerHTML = `\n \n \n `.trim();\n const M = d.content.firstElementChild;\n if (t.decoration?.style?.layout === "bounds") {\n const l = M.cloneNode(!0);\n l.style.setProperty("pointer-events", "none"), h(l, c, c), e.append(l);\n } else {\n let l = TA(\n t.range\n );\n l = l.sort((p, w) => p.top < w.top ? -1 : p.top > w.top ? 1 : 0);\n for (let p of l) {\n const w = M.cloneNode(!0);\n w.style.setProperty("pointer-events", "none"), h(w, p, c), e.append(w);\n }\n }\n t.container = e, t.clickableElements = Array.from(\n e.querySelectorAll("[data-activable=\'1\']")\n ), t.clickableElements.length || (t.clickableElements = Array.from(e.children));\n }\n renderLayout(t) {\n this.wnd.cancelAnimationFrame(this.currentRender), this.currentRender = this.wnd.requestAnimationFrame(() => {\n t = t.filter((e) => !this.experimentalHighlights || !!this.notTextFlag?.has(e.id)), !(!t || t.length === 0) && this.requireContainer().append(...t.map((e) => e.container).filter((e) => !!e));\n });\n }\n /**\n * Returns the group container element, after making sure it exists.\n * @returns Group\'s container\n */\n requireContainer(t = !1) {\n if (t) {\n let e;\n this.wnd.document.getElementById(`${this.id}-style`) ? e = this.wnd.document.getElementById(`${this.id}-style`) : (e = this.wnd.document.createElement("style"), e.dataset.readium = "true", e.id = `${this.id}-style`, this.wnd.document.head.appendChild(e));\n let i;\n return this.wnd.CSS.highlights.has(this.id) ? i = this.wnd.CSS.highlights.get(this.id) : (i = new this.wnd.Highlight(), this.wnd.CSS.highlights.set(this.id, i)), [e, i];\n }\n return this.container || (this.container = this.wnd.document.createElement("div"), this.container.setAttribute("id", this.id), this.container.dataset.group = this.name, this.container.dataset.readium = "true", this.container.style.setProperty("pointer-events", "none"), this.container.style.display = "contents", this.wnd.document.body.append(this.container)), this.container;\n }\n /**\n * Removes the group container.\n */\n clearContainer() {\n this.experimentalHighlights && this.wnd.CSS.highlights.delete(this.id), this.container && (this.container.remove(), this.container = void 0);\n }\n}\nconst Yi = class se extends yt {\n constructor() {\n super(...arguments), this.resizeFrame = 0, this.lastGroupId = 0, this.groups = /* @__PURE__ */ new Map(), this.handleResizer = this.handleResize.bind(this);\n }\n cleanup() {\n this.groups.forEach((t) => t.clear()), this.groups.clear();\n }\n handleResize() {\n this.wnd.clearTimeout(this.resizeFrame), this.resizeFrame = this.wnd.setTimeout(() => {\n this.groups.forEach((t) => {\n t.experimentalHighlights || t.requestLayout();\n });\n }, 50);\n }\n mount(t, e) {\n return this.wnd = t, e.register("decorate", se.moduleName, (i, A) => {\n const n = i;\n n.decoration && n.decoration.locator && (n.decoration.locator = L.deserialize(n.decoration.locator)), this.groups.has(n.group) || this.groups.set(n.group, new kA(\n t,\n e,\n `readium-decoration-${this.lastGroupId++}`,\n n.group\n ));\n const s = this.groups.get(n.group);\n switch (n.action) {\n case "add":\n s?.add(n.decoration);\n break;\n case "remove":\n s?.remove(n.decoration.id);\n break;\n case "clear":\n s?.clear();\n break;\n case "update":\n s?.update(n.decoration);\n break;\n }\n A(!0);\n }), this.resizeObserver = new ResizeObserver(() => t.requestAnimationFrame(() => this.handleResize())), this.resizeObserver.observe(t.document.body), t.addEventListener("orientationchange", this.handleResizer), t.addEventListener("resize", this.handleResizer), e.log("Decorator Mounted"), !0;\n }\n unmount(t, e) {\n return t.removeEventListener("orientationchange", this.handleResizer), t.removeEventListener("resize", this.handleResizer), e.unregisterAll(se.moduleName), this.resizeObserver.disconnect(), this.cleanup(), e.log("Decorator Unmounted"), !0;\n }\n};\nYi.moduleName = "decorator";\nlet JA = Yi;\nconst Xe = "readium-snapper-style", Ni = class oe extends yt {\n constructor() {\n super(...arguments), this.protected = !1;\n }\n buildStyles() {\n return `\n html, body {\n touch-action: manipulation;\n user-select: ${this.protected ? "none" : "auto"};\n }`;\n }\n mount(t, e) {\n const i = t.document.createElement("style");\n return i.dataset.readium = "true", i.id = Xe, i.textContent = this.buildStyles(), t.document.head.appendChild(i), e.register("protect", oe.moduleName, (A, n) => {\n this.protected = !0, i.textContent = this.buildStyles(), n(!0);\n }), e.register("unprotect", oe.moduleName, (A, n) => {\n this.protected = !1, i.textContent = this.buildStyles(), n(!0);\n }), e.log("Snapper Mounted"), !0;\n }\n unmount(t, e) {\n return t.document.getElementById(Xe)?.remove(), e.log("Snapper Unmounted"), !0;\n }\n};\nNi.moduleName = "snapper";\nlet Ue = Ni;\nfunction tt(r) {\n return r.document.body.dir.toLowerCase() === "rtl";\n}\nfunction xi(r) {\n return parseInt(\n r.getComputedStyle(\n r.document.documentElement\n ).getPropertyValue("column-count")\n );\n}\nfunction WA(r) {\n const t = getComputedStyle(r), e = parseFloat(t.paddingTop || "0"), i = parseFloat(t.paddingBottom || "0");\n return r.clientHeight - e - i;\n}\nfunction Ze(r) {\n const t = xi(r);\n if (!t)\n return !1;\n const e = r.document.querySelectorAll("div[id^=\'readium-virtual-page\']");\n for (const a of e)\n a.remove();\n const i = e.length, A = r.document.scrollingElement.scrollWidth, n = r.visualViewport.width, s = Math.round(A / n * t) % t, o = t === 1 || s === 0 ? 0 : t - s;\n if (o > 0)\n for (let a = 0; a < o; a++) {\n const h = r.document.createElement("div");\n h.setAttribute("id", `readium-virtual-page-${a}`), h.dataset.readium = "true", CSS.supports("break-before", "column") ? h.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (h.style.breakInside = "avoid-column"), h.style.height = WA(r.document.documentElement) + "px"), h.innerHTML = "​", r.document.body.appendChild(h);\n }\n return i !== o;\n}\nfunction Ti(r) {\n const t = r.document.createElement("style");\n t.appendChild(r.document.createTextNode("*{}")), r.document.body.appendChild(t), r.document.body.removeChild(t);\n}\nfunction OA(r) {\n return r < 0.5 ? 2 * r * r : -1 + (4 - 2 * r) * r;\n}\nfunction C(r) {\n const t = r.getSelection();\n t && t.removeAllRanges();\n}\nconst LA = [\n "a",\n "audio",\n "button",\n "canvas",\n "details",\n "input",\n "label",\n "option",\n "select",\n "submit",\n "textarea",\n "video"\n];\nfunction Pi(r) {\n return LA.indexOf(r.nodeName.toLowerCase()) !== -1 || r.hasAttribute("contenteditable") && r.getAttribute("contenteditable")?.toLowerCase() !== "false" ? r : r.parentElement ? Pi(r.parentElement) : null;\n}\nfunction Re(r, t) {\n const e = bi(r, r.document.body, t), i = r._readium_cssSelectorGenerator.getCssSelector(e, {\n selectors: ["tag", "id", "class", "nthchild", "nthoftype", "attribute"]\n });\n return new L({\n href: "#",\n type: "application/xhtml+xml",\n locations: new S({\n otherLocations: /* @__PURE__ */ new Map([\n ["cssSelector", i]\n ])\n }),\n text: new At({\n highlight: e.textContent || void 0\n })\n });\n}\nfunction bi(r, t, e) {\n for (var i = 0; i < t.children.length; i++) {\n const A = t.children[i];\n if (!KA(A) && XA(r, A, e))\n return ZA(r, A) ? A : bi(r, A, e);\n }\n return t;\n}\nfunction XA(r, t, e) {\n if (t === document.body || t === document.documentElement)\n return !0;\n if (!document || !document.documentElement || !document.body)\n return !1;\n const i = t.getBoundingClientRect();\n return e ? i.bottom > 0 && i.top < r.innerHeight : i.right > 0 && i.left < r.innerWidth;\n}\nfunction ZA(r, t) {\n const e = t.getBoundingClientRect();\n return e.top >= 0 && e.left >= 0 && e.bottom <= r.innerHeight && e.right <= r.innerWidth;\n}\nfunction KA(r) {\n const t = getComputedStyle(r);\n if (t) {\n const e = t.getPropertyValue("display");\n if (e != "block" && e != "list-item" || t.getPropertyValue("opacity") === "0")\n return !0;\n }\n return !1;\n}\nconst Ke = "readium-column-snapper-style", qA = 200, ji = class b extends Ue {\n constructor() {\n super(...arguments), this.shakeTimeout = 0, this.snappingCancelled = !1, this.alreadyScrollLeft = 0, this.overscroll = 0, this.cachedScrollWidth = 0, this.touchState = 0, this.startingX = void 0, this.endingX = void 0, this.onTouchStarter = this.onTouchStart.bind(this), this.onTouchEnder = this.onTouchEnd.bind(this), this.onWidthChanger = this.onWidthChange.bind(this), this.onTouchMover = this.onTouchMove.bind(this);\n }\n doc() {\n return this.wnd.document.scrollingElement;\n }\n scrollOffset() {\n return this.doc().scrollLeft > 0 ? this.doc().scrollLeft : this.alreadyScrollLeft;\n }\n snapOffset(t) {\n const e = t + (tt(this.wnd) ? -1 : 1);\n return e - e % this.wnd.innerWidth;\n }\n reportProgress() {\n const t = this.wnd.scrollX, e = this.cachedScrollWidth, i = Math.max(0, Math.min(1, t / e)), A = Math.max(0, Math.min(1, (t + this.wnd.innerWidth) / e));\n this.comms.send("progress", {\n start: i,\n end: A\n });\n }\n shake() {\n if (this.overscroll !== 0 || this.shakeTimeout !== 0) return;\n const t = this.doc();\n t.classList.add(tt(this.wnd) ? "readium-bounce-l" : "readium-bounce-r");\n const e = this.scrollOffset();\n this.shakeTimeout = this.wnd.setTimeout(() => {\n t.classList.remove("readium-bounce-l"), t.classList.remove("readium-bounce-r"), this.shakeTimeout = 0, this.doc().scrollLeft = e;\n }, 150);\n }\n // We have to cache this because during overscroll (transform, or left) the width is incorrect due to browser\n takeOverSnap() {\n this.snappingCancelled = !0, this.clearTouches();\n const t = this.doc();\n this.overscroll = t.style.transform?.length > 12 ? parseFloat(t.style.transform.slice(12).split("px")[0]) : 0;\n }\n // Snaps the current offset to the page width.\n snapCurrentOffset(t = !1, e = !1) {\n const i = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft, A = this.doc(), n = this.dragOffset(), s = xi(this.wnd), o = Math.min(Math.max(0, i), this.cachedScrollWidth), a = tt(this.wnd) ? -1 : 1, h = (\n // The hurdle to overcome in order to change pages\n a * (this.wnd.innerWidth / 3) * (a * n > 0 ? 2 : 1)\n ), c = this.snapOffset(o + h);\n if (t && c !== this.scrollOffset()) {\n this.snappingCancelled = !1;\n const d = (p, w, E, R) => E > R ? w : p + (w - p) * OA(E / R), g = (\n /*Math.abs(startX - (this.useTransform ? currentOffset : 0)) < 10 ? 1 : */\n qA * s\n );\n let M;\n const l = (p) => {\n if (this.snappingCancelled) return;\n M || (M = p);\n const w = p - M, E = d(this.overscroll, 0, w, g), R = d(i, c, w, g);\n A.scrollLeft = R, this.overscroll !== 0 && (A.style.transform = `translate3d(${-E}px, 0px, 0px)`), w < g ? this.wnd.requestAnimationFrame(l) : (this.clearTouches(), A.style.removeProperty("transform"), A.scrollLeft = c, e || this.reportProgress());\n };\n this.wnd.requestAnimationFrame(l);\n } else\n A.style.removeProperty("transform"), this.wnd.requestAnimationFrame(() => {\n A.scrollLeft = c, this.clearTouches(), e || this.reportProgress();\n });\n }\n dragOffset() {\n return (this.startingX ?? 0) - (this.endingX ?? 0);\n }\n clearTouches() {\n this.startingX = void 0, this.endingX = void 0, this.overscroll = 0;\n }\n onTouchStart(t) {\n switch (t.stopPropagation(), this.takeOverSnap(), t.touches.length) {\n case 1:\n break;\n case 2:\n this.onTouchEnd(t);\n return;\n default: {\n this.onTouchEnd(t), this.comms.send("tap_more", t.touches.length);\n return;\n }\n }\n this.startingX = t.touches[0].clientX, this.alreadyScrollLeft = this.doc().scrollLeft, this.touchState = 1;\n }\n onTouchEnd(t) {\n if (this.touchState === 2) {\n const e = this.dragOffset(), i = this.scrollOffset();\n this.cachedScrollWidth <= this.wnd.innerWidth ? (this.reportProgress(), e > 5 && this.comms.send("no_more", void 0), e < -5 && this.comms.send("no_less", void 0)) : i < 5 && e < 5 ? (this.alreadyScrollLeft = 0, this.comms.send("no_less", void 0)) : this.cachedScrollWidth - i - this.wnd.innerWidth < 5 && e > 5 && (this.alreadyScrollLeft = this.cachedScrollWidth, this.comms.send("no_more", void 0)), this.snapCurrentOffset(!0), this.comms.send("swipe", e);\n }\n this.touchState = 0;\n }\n onWidthChange() {\n this.cachedScrollWidth = this.doc().scrollWidth, this.comms.ready && this.snapCurrentOffset();\n }\n onTouchMove(t) {\n if (this.touchState === 0) return;\n this.touchState === 1 && (this.touchState = 2, C(this.wnd)), this.endingX = t.touches[0].clientX;\n const e = this.dragOffset(), i = this.alreadyScrollLeft + e;\n i < 0 ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-this.overscroll}px, 0px, 0px)`) : i + this.wnd.innerWidth > this.cachedScrollWidth ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-i}px, 0px, 0px)`) : (this.overscroll = 0, this.doc().style.removeProperty("transform"), this.doc().scrollLeft = this.alreadyScrollLeft + e);\n }\n mount(t, e) {\n if (this.wnd = t, this.comms = e, !super.mount(t, e)) return !1;\n t.navigator.epubReadingSystem && (t.navigator.epubReadingSystem.layoutStyle = "paginated");\n const i = t.document.createElement("style");\n i.dataset.readium = "true", i.id = Ke, i.textContent = `\n @keyframes readium-bounce-l-animation {\n 0%, 100% {transform: translate3d(0, 0, 0);}\n 50% {transform: translate3d(-50px, 0, 0);}\n }\n\n @keyframes readium-bounce-r-animation {\n 0%, 100% {transform: translate3d(0, 0, 0);}\n 50% {transform: translate3d(50px, 0, 0);}\n }\n\n .readium-bounce-l {\n animation: readium-bounce-l-animation 150ms ease-out 1;\n }\n\n .readium-bounce-r {\n animation: readium-bounce-r-animation 150ms ease-out 1;\n }\n\n html {\n overflow: hidden;\n }\n\n body {\n -ms-overflow-style: none; /* for Internet Explorer, Edge */\n }\n\n * {\n scrollbar-width: none; /* for Firefox */\n }\n \n body::-webkit-scrollbar {\n display: none; /* for Chrome, Safari, and Opera */\n }\n `, t.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {\n t.requestAnimationFrame(() => {\n t && Ze(t);\n }), this.onWidthChange();\n }), this.resizeObserver.observe(t.document.body), this.mutationObserver = new MutationObserver((n) => {\n for (const s of n)\n if (s.target === this.wnd.document.documentElement) {\n const o = s.oldValue, a = s.target.getAttribute("style"), h = /transform\\s*:\\s*([^;]+)/, c = o?.match(h), d = a?.match(h);\n (!c && !d || c && !d || c && d && c[1] !== d[1]) && (t.requestAnimationFrame(() => {\n t && Ze(t);\n }), this.onWidthChange());\n } else\n t.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth);\n }), t.frameElement && this.mutationObserver.observe(t.frameElement, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(t.document, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(t.document.documentElement, { attributes: !0, attributeFilter: ["style"] });\n const A = (n) => {\n const s = this.doc().scrollLeft;\n return this.doc().scrollLeft = this.snapOffset(n), s !== this.doc().scrollLeft;\n };\n return t.addEventListener("orientationchange", this.onWidthChanger), t.addEventListener("resize", this.onWidthChanger), t.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), e.register("go_progression", b.moduleName, (n, s) => {\n const o = n;\n if (o < 0 || o > 1) {\n e.send("error", {\n message: "go_progression must be given a position from 0.0 to 1.0"\n }), s(!1);\n return;\n }\n this.wnd.requestAnimationFrame(() => {\n this.cachedScrollWidth = this.doc().scrollWidth;\n const a = this.cachedScrollWidth, h = tt(t) ? -1 : 1, c = a * o * h;\n this.doc().scrollLeft = this.snapOffset(c), this.reportProgress(), C(this.wnd), s(!0);\n });\n }), e.register("go_id", b.moduleName, (n, s) => {\n const o = t.document.getElementById(n);\n if (!o) {\n s(!1);\n return;\n }\n this.wnd.requestAnimationFrame(() => {\n this.doc().scrollLeft = this.snapOffset(o.getBoundingClientRect().left + t.scrollX), this.reportProgress(), C(this.wnd), s(!0);\n });\n }), e.register("go_text", b.moduleName, (n, s) => {\n let o;\n Array.isArray(n) && (n.length > 1 && (o = n[1]), n = n[0]);\n const a = At.deserialize(n), h = Wt(this.wnd.document, new L({\n href: t.location.href,\n type: "text/html",\n text: a,\n locations: o ? new S({\n otherLocations: /* @__PURE__ */ new Map([\n ["cssSelector", o]\n ])\n }) : void 0\n }));\n if (!h) {\n s(!1);\n return;\n }\n this.wnd.requestAnimationFrame(() => {\n this.doc().scrollLeft = this.snapOffset(h.getBoundingClientRect().left + t.scrollX), this.reportProgress(), C(this.wnd), s(!0);\n });\n }), e.register("go_end", b.moduleName, (n, s) => {\n const o = tt(t) ? -1 : 1;\n this.wnd.requestAnimationFrame(() => {\n this.cachedScrollWidth = this.doc().scrollWidth;\n const a = this.cachedScrollWidth * o;\n if (this.doc().scrollLeft === a) return s(!1);\n this.doc().scrollLeft = this.snapOffset(a), this.reportProgress(), C(this.wnd), s(!0);\n });\n }), e.register("go_start", b.moduleName, (n, s) => {\n this.wnd.requestAnimationFrame(() => {\n if (this.doc().scrollLeft === 0) return s(!1);\n this.doc().scrollLeft = 0, this.reportProgress(), C(this.wnd), s(!0);\n });\n }), e.register("go_prev", b.moduleName, (n, s) => {\n this.wnd.requestAnimationFrame(() => {\n this.cachedScrollWidth = this.doc().scrollWidth;\n const o = t.scrollX - t.innerWidth, a = tt(t) ? -(this.cachedScrollWidth - t.innerWidth) : 0, h = A(Math.max(o, a));\n h && (this.reportProgress(), C(this.wnd)), s(h);\n });\n }), e.register("go_next", b.moduleName, (n, s) => {\n this.wnd.requestAnimationFrame(() => {\n this.cachedScrollWidth = this.doc().scrollWidth;\n const o = t.scrollX + t.innerWidth, a = tt(t) ? 0 : this.cachedScrollWidth - t.innerWidth, h = A(Math.min(o, a));\n h && (this.reportProgress(), C(this.wnd)), s(h);\n });\n }), e.register("unfocus", b.moduleName, (n, s) => {\n this.snappingCancelled = !0, C(this.wnd), s(!0);\n }), e.register("shake", b.moduleName, (n, s) => {\n this.shake(), s(!0);\n }), e.register("focus", b.moduleName, (n, s) => {\n this.wnd.requestAnimationFrame(() => {\n this.cachedScrollWidth = this.doc().scrollWidth, this.snapCurrentOffset(!1, !0), this.reportProgress(), s(!0);\n });\n }), e.register("first_visible_locator", b.moduleName, (n, s) => {\n const o = Re(t, !1);\n this.comms.send("first_visible_locator", o.serialize()), s(!0);\n }), t.addEventListener("touchstart", this.onTouchStarter, { passive: !0 }), t.addEventListener("touchend", this.onTouchEnder, { passive: !0 }), t.addEventListener("touchmove", this.onTouchMover, { passive: !0 }), t.document.addEventListener("touchstart", () => {\n }), e.log("ColumnSnapper Mounted"), !0;\n }\n unmount(t, e) {\n return this.snappingCancelled = !0, e.unregisterAll(b.moduleName), this.resizeObserver.disconnect(), this.mutationObserver.disconnect(), t.removeEventListener("touchstart", this.onTouchStarter), t.removeEventListener("touchend", this.onTouchEnder), t.removeEventListener("touchmove", this.onTouchMover), t.removeEventListener("orientationchange", this.onWidthChanger), t.removeEventListener("resize", this.onWidthChanger), t.document.getElementById(Ke)?.remove(), e.log("ColumnSnapper Unmounted"), super.unmount(t, e);\n }\n};\nji.moduleName = "column_snapper";\nlet _A = ji;\nconst qe = "readium-scroll-snapper-style", Vi = class V extends Ue {\n constructor() {\n super(...arguments), this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce = null, this.handleScroll = () => {\n if (this.comms.ready && !this.isResizing) {\n if (!this.initialScrollHandled) {\n this.lastScrollTop = this.doc().scrollTop, this.initialScrollHandled = !0, this.reportProgress();\n return;\n }\n this.isScrolling || (this.isScrolling = !0, this.wnd.requestAnimationFrame(() => {\n this.reportProgress();\n const t = this.doc().scrollTop, e = t - this.lastScrollTop;\n this.lastScrollTop = t, this.comms.send("scroll", e), this.isScrolling = !1;\n }));\n }\n };\n }\n doc() {\n return this.wnd.document.scrollingElement;\n }\n reportProgress() {\n if (!this.comms.ready) return;\n const t = Math.ceil(this.doc().scrollTop), e = this.doc().scrollHeight, i = this.wnd.innerHeight, A = Math.max(0, Math.min(1, t / e)), n = Math.max(0, Math.min(1, (t + i) / e));\n this.comms.send("progress", {\n start: A,\n end: n\n });\n }\n mount(t, e) {\n this.wnd = t, this.comms = e, this.initialScrollHandled = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce && (this.wnd.clearTimeout(this.resizeDebounce), this.resizeDebounce = null), t.navigator.epubReadingSystem && (t.navigator.epubReadingSystem.layoutStyle = "scrolling");\n const i = t.document.createElement("style");\n return i.dataset.readium = "true", i.id = qe, i.textContent = `\n * {\n scrollbar-width: none; /* for Firefox */\n }\n \n body::-webkit-scrollbar {\n display: none; /* for Chrome, Safari, and Opera */\n }\n `, t.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {\n this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {\n this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();\n }, 50);\n }), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc", V.moduleName, () => {\n Ti(this.wnd);\n const A = this.doc().scrollTop;\n A > 1 ? this.doc().scrollTop = A - 1 : this.doc().scrollTop = A + 1, this.doc().scrollTop = A;\n }), e.register("go_progression", V.moduleName, (A, n) => {\n const s = A;\n if (s < 0 || s > 1) {\n e.send("error", {\n message: "go_progression must be given a position from 0.0 to 1.0"\n }), n(!1);\n return;\n }\n this.wnd.requestAnimationFrame(() => {\n this.doc().scrollTop = this.doc().offsetHeight * s, this.reportProgress(), C(this.wnd), n(!0);\n });\n }), e.register("go_id", V.moduleName, (A, n) => {\n const s = t.document.getElementById(A);\n if (!s) {\n n(!1);\n return;\n }\n this.wnd.requestAnimationFrame(() => {\n this.doc().scrollTop = s.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), C(this.wnd), n(!0);\n });\n }), e.register("go_text", V.moduleName, (A, n) => {\n let s;\n Array.isArray(A) && (A.length > 1 && (s = A[1]), A = A[0]);\n const o = At.deserialize(A), a = Wt(this.wnd.document, new L({\n href: t.location.href,\n type: "text/html",\n text: o,\n locations: s ? new S({\n otherLocations: /* @__PURE__ */ new Map([\n ["cssSelector", s]\n ])\n }) : void 0\n }));\n if (!a) {\n n(!1);\n return;\n }\n this.wnd.requestAnimationFrame(() => {\n this.doc().scrollTop = a.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), C(this.wnd), n(!0);\n });\n }), e.register("go_start", V.moduleName, (A, n) => {\n if (this.doc().scrollTop === 0) return n(!1);\n this.doc().scrollTop = 0, this.reportProgress(), n(!0);\n }), e.register("go_end", V.moduleName, (A, n) => {\n if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return n(!1);\n this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), n(!0);\n }), e.register("unfocus", V.moduleName, (A, n) => {\n C(this.wnd), n(!0);\n }), e.register([\n "go_next",\n "go_prev"\n ], V.moduleName, (A, n) => n(!1)), e.register("focus", V.moduleName, (A, n) => {\n this.reportProgress(), n(!0);\n }), e.register("first_visible_locator", V.moduleName, (A, n) => {\n const s = Re(t, !0);\n this.comms.send("first_visible_locator", s.serialize()), n(!0);\n }), e.log("ScrollSnapper Mounted"), !0;\n }\n unmount(t, e) {\n return e.unregisterAll(V.moduleName), this.resizeObserver.disconnect(), this.handleScroll && t.removeEventListener("scroll", this.handleScroll), t.document.getElementById(qe)?.remove(), e.log("ScrollSnapper Unmounted"), !0;\n }\n};\nVi.moduleName = "scroll_snapper";\nlet $A = Vi;\nconst vi = class v extends Ue {\n constructor() {\n super(...arguments), this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce = null, this.handleScroll = () => {\n if (this.comms.ready && !this.isResizing) {\n if (!this.initialScrollHandled) {\n this.lastScrollTop = this.doc().scrollTop, this.initialScrollHandled = !0, this.reportProgress();\n return;\n }\n this.isScrolling || (this.isScrolling = !0, this.wnd.requestAnimationFrame(() => {\n this.reportProgress();\n const t = this.doc().scrollTop, e = t - this.lastScrollTop;\n this.lastScrollTop = t, this.comms.send("scroll", e), this.isScrolling = !1;\n }));\n }\n };\n }\n doc() {\n return this.wnd.document.scrollingElement;\n }\n reportProgress() {\n if (!this.comms.ready) return;\n const t = Math.ceil(this.doc().scrollTop), e = this.doc().scrollHeight, i = this.wnd.innerHeight, A = Math.max(0, Math.min(1, t / e)), n = Math.max(0, Math.min(1, (t + i) / e));\n this.comms.send("progress", {\n start: A,\n end: n\n });\n }\n mount(t, e) {\n return this.wnd = t, this.comms = e, this.initialScrollHandled = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce && (this.wnd.clearTimeout(this.resizeDebounce), this.resizeDebounce = null), this.resizeObserver = new ResizeObserver(() => {\n this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {\n this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();\n }, 50);\n }), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc", v.moduleName, () => {\n Ti(this.wnd);\n const i = this.doc().scrollTop;\n i > 1 ? this.doc().scrollTop = i - 1 : this.doc().scrollTop = i + 1, this.doc().scrollTop = i;\n }), e.register("go_progression", v.moduleName, (i, A) => {\n const n = i;\n if (n < 0 || n > 1) {\n e.send("error", {\n message: "go_progression must be given a position from 0.0 to 1.0"\n }), A(!1);\n return;\n }\n this.wnd.requestAnimationFrame(() => {\n this.doc().scrollTop = this.doc().offsetHeight * n, this.reportProgress(), C(this.wnd), A(!0);\n });\n }), this.comms.register("go_id", v.moduleName, (i, A) => {\n const n = t.document.getElementById(i);\n if (!n) {\n A(!1);\n return;\n }\n this.wnd.requestAnimationFrame(() => {\n this.doc().scrollTop = n.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), C(this.wnd), A(!0);\n });\n }), e.register("go_text", v.moduleName, (i, A) => {\n let n;\n Array.isArray(i) && (i.length > 1 && (n = i[1]), i = i[0]);\n const s = At.deserialize(i), o = Wt(this.wnd.document, new L({\n href: t.location.href,\n type: "text/html",\n text: s,\n locations: n ? new S({\n otherLocations: /* @__PURE__ */ new Map([\n ["cssSelector", n]\n ])\n }) : void 0\n }));\n if (!o) {\n A(!1);\n return;\n }\n this.wnd.requestAnimationFrame(() => {\n this.doc().scrollTop = o.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), C(this.wnd), A(!0);\n });\n }), e.register("go_start", v.moduleName, (i, A) => {\n if (this.doc().scrollTop === 0) return A(!1);\n this.doc().scrollTop = 0, this.reportProgress(), A(!0);\n }), e.register("go_end", v.moduleName, (i, A) => {\n if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return A(!1);\n this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), A(!0);\n }), e.register("unfocus", v.moduleName, (i, A) => {\n C(this.wnd), A(!0);\n }), e.register([\n "go_next",\n "go_prev"\n ], v.moduleName, (i, A) => A(!1)), e.register("focus", v.moduleName, (i, A) => {\n this.reportProgress(), A(!0);\n }), e.register("first_visible_locator", v.moduleName, (i, A) => {\n const n = Re(t, !0);\n e.send("first_visible_locator", n.serialize()), A(!0);\n }), e.log("WebPubSnapper Mounted"), !0;\n }\n unmount(t, e) {\n return e.unregisterAll(v.moduleName), this.resizeObserver.disconnect(), this.handleScroll && t.removeEventListener("scroll", this.handleScroll), e.log("WebPubSnapper Unmounted"), !0;\n }\n};\nvi.moduleName = "webpub_snapper";\nlet tn = vi;\nconst Di = class extends yt {\n constructor() {\n super(...arguments), this.pointerMoved = !1, this.onPointerUp = this.onPointUp.bind(this), this.onPointerMove = this.onPointMove.bind(this), this.onPointerDown = this.onPointDown.bind(this), this.onContextMenu = this.onContext.bind(this), this.onClicker = this.onClick.bind(this);\n }\n onPointUp(t) {\n const e = this.wnd.getSelection();\n if (e && e.toString()?.length > 0) {\n const A = e.getRangeAt(0)?.getClientRects();\n if (!A || A.length === 0)\n return;\n const n = A[0], s = {\n text: e.toString(),\n x: n.x,\n y: n.y,\n width: n.width,\n height: n.height,\n targetFrameSrc: this.wnd?.location?.href\n };\n this.comms.send("text_selected", s);\n }\n if (this.pointerMoved) {\n this.pointerMoved = !1;\n return;\n }\n if (!e?.isCollapsed || !t.isPrimary) return;\n const i = this.wnd.devicePixelRatio;\n t.preventDefault(), this.comms.send(t.pointerType === "touch" ? "tap" : "click", {\n defaultPrevented: t.defaultPrevented,\n x: t.clientX * i,\n y: t.clientY * i,\n targetFrameSrc: this.wnd.location.href,\n targetElement: t.target.outerHTML,\n interactiveElement: Pi(t.target)?.outerHTML,\n cssSelector: this.wnd._readium_cssSelectorGenerator.getCssSelector(t.target)\n }), this.pointerMoved = !1;\n }\n onPointMove(t) {\n if (t.movementY !== void 0 && t.movementX !== void 0) {\n (Math.abs(t.movementX) > 1 || Math.abs(t.movementY) > 1) && (this.pointerMoved = !0);\n return;\n }\n this.pointerMoved = !0;\n }\n onPointDown() {\n this.pointerMoved = !1;\n }\n onContext(t) {\n this.onPointUp(t), this.pointerMoved = !1;\n }\n onClick(t) {\n if (t.preventDefault(), !t.isTrusted) {\n const e = new PointerEvent("pointerup", {\n isPrimary: !0,\n pointerType: "mouse",\n // Not really a better choice than this\n clientX: t.clientX,\n clientY: t.clientY\n });\n Object.defineProperty(e, "target", { writable: !1, value: t.target }), Object.defineProperty(e, "defaultPrevented", { writable: !1, value: t.defaultPrevented }), this.onPointUp(e);\n }\n }\n mount(t, e) {\n return this.wnd = t, this.comms = e, t.document.addEventListener("pointerdown", this.onPointerDown), t.document.addEventListener("pointerup", this.onPointerUp), t.document.addEventListener("contextmenu", this.onContextMenu), t.document.addEventListener("pointermove", this.onPointerMove), t.document.addEventListener("click", this.onClicker), e.log("Peripherals Mounted"), !0;\n }\n unmount(t, e) {\n return t.document.removeEventListener("pointerdown", this.onPointerDown), t.document.removeEventListener("pointerup", this.onPointerUp), t.document.removeEventListener("contextmenu", this.onContextMenu), t.document.removeEventListener("pointermove", this.onPointerMove), t.document.removeEventListener("click", this.onClicker), e.log("Peripherals Unmounted"), !0;\n }\n};\nDi.moduleName = "peripherals";\nlet en = Di;\nconst Hi = class ae extends yt {\n constructor() {\n super(...arguments), this.mediaPlayingCount = 0, this.allAnimations = /* @__PURE__ */ new Set();\n }\n wndOnErr(t) {\n this.comms?.send("error", {\n message: t.message,\n filename: t.filename,\n lineno: t.lineno,\n colno: t.colno\n });\n }\n unblock(t) {\n for (t._readium_blockEvents = !1; t._readium_blockedEvents?.length > 0; ) {\n const e = t._readium_blockedEvents.shift();\n switch (e[0]) {\n case 0:\n Reflect.apply(e[1], e[2], e[3]);\n break;\n case 1:\n const i = e[1], A = e[2];\n t.removeEventListener(i.type, t._readium_eventBlocker, !0);\n const n = new Event(i.type, {\n bubbles: i.bubbles,\n cancelable: i.cancelable\n });\n A ? A.dispatchEvent(n) : t.dispatchEvent(n);\n break;\n }\n }\n }\n onMediaPlayEvent() {\n this.mediaPlayingCount++, this.comms?.send("media_play", this.mediaPlayingCount);\n }\n onMediaPauseEvent() {\n this.mediaPlayingCount > 0 && this.mediaPlayingCount--, this.comms?.send("media_pause", this.mediaPlayingCount);\n }\n pauseAllMedia(t) {\n const e = t.document.querySelectorAll("audio,video");\n for (let i = 0; i < e.length; i++)\n e[i].pause();\n }\n mount(t, e) {\n this.comms = e, t.addEventListener(\n "error",\n this.wndOnErr,\n !1\n ), Reflect.defineProperty(t.navigator, "epubReadingSystem", {\n value: {\n name: "readium-ts-toolkit",\n version: "2.2.1",\n hasFeature: (A, n = "") => {\n switch (A) {\n case "dom-manipulation":\n return !0;\n case "layout-changes":\n return !0;\n case "touch-events":\n return !0;\n case "mouse-events":\n return !0;\n case "keyboard-events":\n return !0;\n case "spine-scripting":\n return !0;\n case "embedded-web-content":\n return !0;\n default:\n return !1;\n }\n }\n },\n writable: !1\n }), "getAnimations" in t.document && t.document.getAnimations().forEach((A) => {\n A.cancel(), this.allAnimations.add(A);\n }), e.register("activate", ae.moduleName, (A, n) => {\n this.allAnimations.forEach((s) => {\n s.cancel(), s.play();\n }), n(!0);\n }), e.register("unfocus", ae.moduleName, (A, n) => {\n this.pauseAllMedia(t), this.allAnimations.forEach((s) => s.pause()), n(!0);\n });\n const i = t.document.querySelectorAll("audio,video");\n for (let A = 0; A < i.length; A++) {\n const n = i[A];\n n.addEventListener("play", this.onMediaPlayEvent, {\n passive: !0\n }), n.addEventListener("pause", this.onMediaPauseEvent, {\n passive: !0\n });\n }\n return e.log("Setup Mounted"), !0;\n }\n unmount(t, e) {\n return t.removeEventListener("error", this.wndOnErr), t.removeEventListener("play", this.onMediaPlayEvent), t.removeEventListener("pause", this.onMediaPauseEvent), this.allAnimations.forEach((i) => i.cancel()), this.allAnimations.clear(), e.log("Setup Unmounted"), !0;\n }\n};\nHi.moduleName = "setup";\nlet Gi = Hi;\nconst _e = "readium-viewport", ki = class et extends Gi {\n onViewportWidthChanged(t) {\n const e = t.target;\n Bt(e, "--RS__viewportWidth", `${e.innerWidth}px`);\n }\n mount(t, e) {\n if (!super.mount(t, e)) return !1;\n const i = t.document.createElement("meta");\n return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id", _e), i.setAttribute(\n "content",\n "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"\n ), t.document.head.appendChild(i), t.addEventListener("orientationchange", this.onViewportWidthChanged), t.addEventListener("resize", this.onViewportWidthChanged), this.onViewportWidthChanged({\n target: t\n }), e.register("get_properties", et.moduleName, (A, n) => {\n Fe(t), n(!0);\n }), e.register("update_properties", et.moduleName, (A, n) => {\n A["--RS__viewportWidth"] = `${t.innerWidth}px`, Qi(t, A), n(!0);\n }), e.register("set_property", et.moduleName, (A, n) => {\n const s = A;\n Bt(t, s[0], s[1]), n(!0);\n }), e.register("remove_property", et.moduleName, (A, n) => {\n Ot(t, A), n(!0);\n }), e.register("activate", et.moduleName, (A, n) => {\n this.unblock(t), n(!0);\n }), e.log("ReflowableSetup Mounted"), !0;\n }\n unmount(t, e) {\n return e.unregisterAll(et.moduleName), t.document.head.querySelector(`#${_e}`)?.remove(), t.removeEventListener("orientationchange", this.onViewportWidthChanged), e.log("ReflowableSetup Unmounted"), super.unmount(t, e);\n }\n};\nki.moduleName = "reflowable_setup";\nlet An = ki;\nconst $e = "readium-fixed-style", Ji = class Z extends Gi {\n mount(t, e) {\n if (!super.mount(t, e)) return !1;\n t.navigator.epubReadingSystem && (t.navigator.epubReadingSystem.layoutStyle = "paginated");\n const i = t.document.createElement("style");\n return i.id = $e, i.dataset.readium = "true", i.textContent = `\n html, body {\n text-size-adjust: none;\n -ms-text-size-adjust: none;\n -webkit-text-size-adjust: none;\n -moz-text-size-adjust: none;\n\n /* Fight Safari pinches */\n touch-action: none !important;\n min-height: 100%;\n\n /*cursor: var() TODO*/\n }`, t.document.head.appendChild(i), e.register("set_property", Z.moduleName, (A, n) => {\n const s = A;\n Bt(t, s[0], s[1]), n(!0);\n }), e.register("remove_property", Z.moduleName, (A, n) => {\n Ot(t, A), n(!0);\n }), e.register("first_visible_locator", Z.moduleName, (A, n) => n(!1)), e.register("unfocus", Z.moduleName, (A, n) => {\n C(t), n(!0);\n }), e.register([\n "focus",\n "go_next",\n "go_prev",\n "go_id",\n "go_end",\n "go_start",\n "go_text",\n "go_progression"\n ], Z.moduleName, (A, n) => n(!0)), e.register("activate", Z.moduleName, (A, n) => {\n this.unblock(t), n(!0);\n }), e.log("FixedSetup Mounted"), !0;\n }\n unmount(t, e) {\n return e.unregisterAll(Z.moduleName), t.document.getElementById($e)?.remove(), e.log("FixedSetup Unmounted"), super.unmount(t, e);\n }\n};\nJi.moduleName = "fixed_setup";\nlet nn = Ji;\nconst Wi = class it extends yt {\n wndOnErr(t) {\n this.comms?.send("error", {\n message: t.message,\n filename: t.filename,\n lineno: t.lineno,\n colno: t.colno\n });\n }\n mount(t, e) {\n return this.comms = e, t.addEventListener(\n "error",\n this.wndOnErr,\n !1\n ), e.register("get_properties", it.moduleName, (i, A) => {\n Fe(t), A(!0);\n }), e.register("update_properties", it.moduleName, (i, A) => {\n Qi(t, i), A(!0);\n }), e.register("set_property", it.moduleName, (i, A) => {\n const n = i;\n Bt(t, n[0], n[1]), A(!0);\n }), e.register("remove_property", it.moduleName, (i, A) => {\n Ot(t, i), A(!0);\n }), e.register("activate", it.moduleName, (i, A) => {\n A(!0);\n }), e.log("WebPubSetup Mounted"), !0;\n }\n unmount(t, e) {\n return e.unregisterAll(it.moduleName), t.removeEventListener("error", this.wndOnErr), e.log("WebPubSetup Unmounted"), !0;\n }\n};\nWi.moduleName = "webpub_setup";\nlet rn = Wi;\nconst sn = [\n "fixed_setup",\n "decorator",\n "peripherals"\n], on = [\n "reflowable_setup",\n "decorator",\n "peripherals",\n "column_snapper",\n "scroll_snapper"\n], an = [\n "webpub_setup",\n "webpub_snapper",\n "decorator",\n "peripherals"\n], Tt = new Map([\n // All modules go here\n nn,\n An,\n rn,\n tn,\n en,\n JA,\n _A,\n $A\n].map((r) => [r.moduleName, r]));\nclass ut {\n /**\n * @param wnd Window instance to operate on\n * @param initialModules List of initial modules to load\n */\n constructor(t = window, e = []) {\n this.loadedModules = [], this.wnd = t, this.comms = new IA(t);\n const i = [...new Set(e)];\n if (i.length) {\n if (typeof t > "u")\n throw Error("Loader is not in a web browser");\n t.parent !== t && this.comms.log("Loader is probably in a frame"), this.loadedModules = i.map((A) => {\n const n = this.loadModule(A);\n if (n)\n return n.mount(this.wnd, this.comms), n;\n }).filter((A) => A !== void 0);\n }\n }\n loadModule(t) {\n const e = Tt.get(t);\n return e === void 0 ? (this.comms.log(`Module "${name}" does not exist in the library`), e) : new e();\n }\n /**\n * Add a module by name\n * @param moduleName Module name\n * @returns Success\n */\n addModule(t) {\n const e = this.loadModule(t);\n return !e || !e.mount(this.wnd, this.comms) ? !1 : (this.loadedModules.push(e), !0);\n }\n /**\n * Remove a module by name\n * @param moduleName Module name\n * @returns Success\n */\n removeModule(t) {\n const e = Tt.get(t);\n if (e === void 0)\n return this.comms.log(`Module "${t}" does not exist in the library`), !1;\n const i = this.loadedModules.findIndex((A) => A instanceof e);\n return i < 0 ? !1 : (this.loadedModules[i].unmount(this.wnd, this.comms), this.loadedModules.splice(i, 1), !0);\n }\n /**\n * Unmount and remove all modules\n */\n destroy() {\n this.comms.destroy(), this.loadedModules.forEach((t) => t.unmount(this.wnd, this.comms)), this.loadedModules = [];\n }\n}\nconst ln = 1e4;\nclass wt {\n constructor(t, e) {\n this.registry = /* @__PURE__ */ new Map(), this._ready = !1, this.listenerBuffer = [], this.handler = this.handle.bind(this), this.wnd = t, this.origin = e;\n try {\n this.channelId = window.crypto.randomUUID();\n } catch {\n this.channelId = ne();\n }\n this.gc = setInterval(() => {\n this.registry.forEach((i, A) => {\n performance.now() - i.time > ln && (console.warn(A, "event for", i.key, "was never handled!"), this.registry.delete(A));\n });\n }, 5e3), window.addEventListener("message", this.handler), this.send("_ping", void 0);\n }\n set listener(t) {\n this.listenerBuffer.length > 0 && this.listenerBuffer.forEach((e) => t(e[0], e[1])), this.listenerBuffer = [], this._listener = t;\n }\n clearListener() {\n typeof this._listener == "function" && (this._listener = void 0);\n }\n halt() {\n this._ready = !1, window.removeEventListener("message", this.handler), clearInterval(this.gc), this._listener = void 0, this.registry.clear();\n }\n resume() {\n window.addEventListener("message", this.handler), this._ready = !0;\n }\n handle(t) {\n const e = t.data;\n if (!e._readium) {\n console.warn("Ignoring", e);\n return;\n }\n if (e._channel === this.channelId)\n switch (e.key) {\n case "_ack": {\n if (!e.id) return;\n const i = this.registry.get(e.id);\n if (!i) return;\n this.registry.delete(e.id), i.cb(!!e.data);\n return;\n }\n // @ts-ignore\n case "_pong":\n this._ready = !0;\n default: {\n if (!this.ready) return;\n typeof this._listener == "function" ? this._listener(e.key, e.data) : this.listenerBuffer.push([e.key, e.data]);\n }\n }\n }\n get ready() {\n return this._ready;\n }\n /**\n * Send a message to the window using postMessage-based comms communication\n * @returns Identifier associated with the message\n */\n send(t, e, i, A = !1, n = []) {\n const s = ne();\n return i && this.registry.set(s, {\n // Add callback to the registry\n cb: i,\n time: performance.now(),\n key: t\n }), this.wnd.postMessage(\n {\n _readium: at,\n _channel: this.channelId,\n id: s,\n data: e,\n key: t,\n strict: A\n },\n "/",\n // Same origin\n n\n ), s;\n }\n}\nconst hn = "\'Iowan Old Style\', Sitka, \'Sitka Text\', Palatino, \'Book Antiqua\', \'URW Palladio L\', P052, serif", cn = {\n RS__oldStyleTf: hn\n}, dn = 16, ti = cn.RS__oldStyleTf;\nclass ft {\n constructor(t) {\n this._optimalLineLength = null, this._canvas = document.createElement("canvas"), this._optimalChars = t.optimalChars, this._minChars = t.minChars, this._maxChars = t.maxChars, this._baseFontSize = t.baseFontSize || dn, this._fontFace = t.fontFace || ti, this._sample = t.sample || null, this._pageGutter = t.pageGutter || 0, this._letterSpacing = t.letterSpacing ? Math.round(t.letterSpacing * this._baseFontSize) : 0, this._wordSpacing = t.wordSpacing ? Math.round(t.wordSpacing * this._baseFontSize) : 0, this._isCJK = t.isCJK || !1, this._getRelative = t.getRelative || !1, this._padding = this._pageGutter * 2, this._minDivider = this._minChars && this._minChars < this._optimalChars ? this._optimalChars / this._minChars : this._minChars === null ? null : 1, this._maxMultiplier = this._maxChars && this._maxChars > this._optimalChars ? this._maxChars / this._optimalChars : this._maxChars === null ? null : 1, this._approximatedWordSpaces = ft.approximateWordSpaces(this._optimalChars, this._sample);\n }\n updateMultipliers() {\n this._minDivider = this._minChars && this._minChars < this._optimalChars ? this._optimalChars / this._minChars : this._minChars === null ? null : 1, this._maxMultiplier = this._maxChars && this._maxChars > this._optimalChars ? this._maxChars / this._optimalChars : this._maxChars === null ? null : 1;\n }\n // Batch update to guarantee up-to-date values\n // Not filtering because pretty much everything can\n // trigger a recomputation anyway.\n update(t) {\n t.optimalChars && (this._optimalChars = t.optimalChars), t.minChars !== void 0 && (this._minChars = t.minChars), t.maxChars !== void 0 && (this._maxChars = t.maxChars), t.baseFontSize && (this._baseFontSize = t.baseFontSize), t.fontFace !== void 0 && (this._fontFace = t.fontFace || ti), t.letterSpacing && (this._letterSpacing = t.letterSpacing), t.wordSpacing && (this._wordSpacing = t.wordSpacing), t.isCJK != null && (this._isCJK = t.isCJK), t.pageGutter && (this._pageGutter = t.pageGutter), t.getRelative && (this._getRelative = t.getRelative), t.sample && (this._sample = t.sample, this._approximatedWordSpaces = ft.approximateWordSpaces(this._optimalChars, this._sample)), this.updateMultipliers(), this._optimalLineLength = this.getOptimalLineLength();\n }\n get baseFontSize() {\n return this._baseFontSize;\n }\n get minimalLineLength() {\n return this._optimalLineLength || (this._optimalLineLength = this.getOptimalLineLength()), this._minDivider !== null ? Math.round(this._optimalLineLength / this._minDivider + this._padding) / (this._getRelative ? this._baseFontSize : 1) : null;\n }\n get maximalLineLength() {\n return this._optimalLineLength || (this._optimalLineLength = this.getOptimalLineLength()), this._maxMultiplier !== null ? Math.round(this._optimalLineLength * this._maxMultiplier + this._padding) / (this._getRelative ? this._baseFontSize : 1) : null;\n }\n get optimalLineLength() {\n return this._optimalLineLength || (this._optimalLineLength = this.getOptimalLineLength()), Math.round(this._optimalLineLength + this._padding) / (this._getRelative ? this._baseFontSize : 1);\n }\n get all() {\n return this._optimalLineLength || (this._optimalLineLength = this.getOptimalLineLength()), {\n min: this.minimalLineLength,\n max: this.maximalLineLength,\n optimal: this.optimalLineLength,\n baseFontSize: this._baseFontSize\n };\n }\n static approximateWordSpaces(t, e) {\n let i = 0;\n if (e && e.length >= t) {\n const A = e.match(/([\\s]+)/gi);\n i = (A ? A.length : 0) * (t / e.length);\n }\n return i;\n }\n getLineLengthFallback() {\n const t = this._letterSpacing * (this._optimalChars - 1), e = this._wordSpacing * this._approximatedWordSpaces;\n return this._optimalChars * (this._baseFontSize * 0.5) + t + e;\n }\n getOptimalLineLength() {\n if (this._fontFace) {\n if (typeof this._fontFace == "string")\n return this.measureText(this._fontFace);\n {\n const t = new FontFace(this._fontFace.name, `url(${this._fontFace.url})`);\n t.load().then(\n () => (document.fonts.add(t), this.measureText(t.family)),\n (e) => {\n }\n );\n }\n }\n return this.getLineLengthFallback();\n }\n measureText(t) {\n const e = this._canvas.getContext("2d");\n if (e && t) {\n let i = this._isCJK ? "水".repeat(this._optimalChars) : "0".repeat(this._optimalChars);\n if (e.font = `${this._baseFontSize}px ${t}`, this._sample && this._sample.length >= this._optimalChars && (i = this._sample.slice(0, this._optimalChars)), Object.hasOwn(e, "letterSpacing") && Object.hasOwn(e, "wordSpacing"))\n return e.letterSpacing = this._letterSpacing.toString() + "px", e.wordSpacing = this._wordSpacing.toString() + "px", e.measureText(i).width;\n {\n const A = this._letterSpacing * (this._optimalChars - 1), n = this._wordSpacing * ft.approximateWordSpaces(this._optimalChars, this._sample);\n return e.measureText(i).width + A + n;\n }\n } else\n return this.getLineLengthFallback();\n }\n}\n/*!\n * (℠)\n * # sML.js | I\'m a Simple and Middling Library.\n *\n * * Copyright (c) Satoru MATSUSHIMA - https://github.com/satorumurmur/sML\n * * Licensed under the MIT license. - http://www.opensource.org/licenses/mit-license.php\n *\n * Portions of this code come from the sML library\n * Current version: 1.0.36\n */\nconst Oi = () => typeof navigator > "u" ? "" : navigator.userAgent || "", Li = () => typeof navigator > "u" ? void 0 : navigator.userAgentData || void 0;\nclass Xi {\n constructor() {\n const t = Li(), e = Oi(), i = (n) => (typeof n == "string" || typeof n == "number") && n ? String(n).replace(/_/g, ".").split(".").map((s) => parseInt(s) || 0) : [], A = (n = "") => {\n if (!n) return [];\n const s = new RegExp("^.*" + n + "[ :\\\\/]?(\\\\d+([\\\\._]\\\\d+)*).*$");\n return s.test(e) ? i(e.replace(s, "$1")) : [];\n };\n this.OS = ((n) => (/(macOS|Mac OS X)/.test(e) ? (/\\(iP(hone|od touch);/.test(e) && (n.iOS = A("CPU (?:iPhone )?OS ")), /\\(iPad;/.test(e) ? n.iOS = n.iPadOS = A("CPU (?:iPhone )?OS ") : /(macOS|Mac OS X) \\d/.test(e) && (document.ontouchend !== void 0 ? n.iOS = n.iPadOS = A() : n.macOS = A("(?:macOS|Mac OS X) "))) : /Windows( NT)? \\d/.test(e) ? n.Windows = ((s) => s[0] !== 6 || !s[1] ? s : s[1] === 1 ? [7] : s[1] === 2 ? [8] : [8, 1])(A("Windows(?: NT)?")) : /Android \\d/.test(e) ? n.Android = A("Android") : /CrOS/.test(e) ? n.ChromeOS = A() : /X11;/.test(e) && (n.Linux = A()), n))({}), t && t.getHighEntropyValues(["architecture", "model", "platform", "platformVersion", "uaFullVersion"]).then((n) => ((s) => {\n const o = n.platform, a = n.platformVersion;\n if (!(!o || !a)) {\n if (/^i(OS|P(hone|od touch))$/.test(o)) s.iOS = i(a);\n else if (/^iPad(OS)?$/.test(o)) s.iOS = s.iPadOS = i(a);\n else if (/^(macOS|(Mac )?OS X|Mac(Intel)?)$/.test(o)) document.ontouchend !== void 0 ? s.iOS = s.iPadOS = i() : s.macOS = i(a);\n else if (/^(Microsoft )?Windows$/.test(o)) s.Windows = i(a);\n else if (/^(Google )?Android$/.test(o)) s.Android = i(a);\n else if (/^((Google )?Chrome OS|CrOS)$/.test(o)) s.ChromeOS = i(a);\n else if (/^(Linux|Ubuntu|X11)$/.test(o)) s.Linux = i(a);\n else return;\n Object.keys(this.OS).forEach((h) => delete this.OS[h]), Object.assign(this.OS, s);\n }\n })({})), this.UA = ((n) => {\n let s = !1;\n if (t && Array.isArray(t.brands)) {\n const o = t.brands.reduce((a, h) => (a[h.brand] = [h.version * 1], a), {});\n o["Google Chrome"] ? (s = !0, n.Blink = n.Chromium = o.Chromium || [], n.Chrome = o["Google Chrome"]) : o["Microsoft Edge"] ? (s = !0, n.Blink = n.Chromium = o.Chromium || [], n.Edge = o["Microsoft Edge"]) : o.Opera && (s = !0, n.Blink = n.Chromium = o.Chromium || [], n.Opera = o.Opera);\n }\n return s || (/ Gecko\\/\\d/.test(e) ? (n.Gecko = A("rv"), / Waterfox\\/\\d/.test(e) ? n.Waterfox = A("Waterfox") : / Firefox\\/\\d/.test(e) && (n.Firefox = A("Firefox"))) : / Edge\\/\\d/.test(e) ? (n.EdgeHTML = A("Edge"), n.Edge = n.EdgeHTML) : / Chrom(ium|e)\\/\\d/.test(e) ? (n.Blink = n.Chromium = ((o) => o[0] ? o : A("Chrome"))(A("Chromium")), / EdgA?\\/\\d/.test(e) ? n.Edge = ((o) => o[0] ? o : A("Edg"))(A("EdgA")) : / OPR\\/\\d/.test(e) ? n.Opera = A("OPR") : / Vivaldi\\/\\d/.test(e) ? n.Vivaldi = A("Vivaldi") : / Silk\\/\\d/.test(e) ? n.Silk = A("Silk") : / UCBrowser\\/\\d/.test(e) ? n.UCBrowser = A("UCBrowser") : / Phoebe\\/\\d/.test(e) ? n.Phoebe = A("Phoebe") : n.Chrome = ((o) => o[0] ? o : n.Chromium)(A("Chrome"))) : / AppleWebKit\\/\\d/.test(e) ? (n.WebKit = A("AppleWebKit"), / CriOS \\d/.test(e) ? n.Chrome = A("CriOS") : / FxiOS \\d/.test(e) ? n.Firefox = A("FxiOS") : / EdgiOS\\/\\d/.test(e) ? n.Edge = A("EdgiOS") : / Version\\/\\d/.test(e) && (n.Safari = A("Version"))) : / Trident\\/\\d/.test(e) && (n.Trident = A("Trident"), n.InternetExplorer = ((o) => o[0] ? o : A("MSIE"))(A("rv")))), /[\\[; ]FB(AN|_IAB)\\//.test(e) && (n.Facebook = A("FBAV")), / Line\\/\\d/.test(e) && (n.LINE = A("Line")), n;\n })({}), this.Env = { get: () => [this.OS, this.UA].reduce((n, s) => {\n for (const o in s) s[o] && n.push(o);\n return n;\n }, []) };\n }\n}\nclass gn extends Xi {\n get iOSRequest() {\n const t = Li(), e = Oi();\n if (this.OS.iOS && !this.OS.iPadOS)\n return "mobile";\n if (this.OS.iPadOS)\n return /\\(iPad;/.test(e) || t && /^iPad(OS)?$/.test(t.platform) ? "mobile" : "desktop";\n }\n}\nconst Mt = new Xi(), U = new gn();\nclass un {\n constructor(t) {\n this.hidden = !0, this.destroyed = !1, this.currModules = [], this.frame = document.createElement("iframe"), this.frame.classList.add("readium-navigator-iframe"), this.frame.style.visibility = "hidden", this.frame.style.setProperty("aria-hidden", "true"), this.frame.style.opacity = "0", this.frame.style.position = "absolute", this.frame.style.pointerEvents = "none", this.frame.style.transition = "visibility 0s, opacity 0.1s linear", this.frame.style.backgroundColor = "#FFFFFF", this.source = t;\n }\n async load(t = []) {\n return new Promise((e, i) => {\n if (this.loader) {\n const A = this.frame.contentWindow;\n if ([...this.currModules].sort().join("|") === [...t].sort().join("|")) {\n try {\n e(A);\n } catch {\n }\n return;\n }\n this.comms?.halt(), this.loader.destroy(), this.loader = new ut(A, t), this.currModules = t, this.comms = void 0;\n try {\n e(A);\n } catch {\n }\n return;\n }\n this.frame.onload = () => {\n const A = this.frame.contentWindow;\n this.loader = new ut(A, t), this.currModules = t;\n try {\n e(A);\n } catch {\n }\n }, this.frame.onerror = (A) => {\n try {\n i(A);\n } catch {\n }\n }, this.frame.contentWindow.location.replace(this.source);\n });\n }\n async destroy() {\n await this.hide(), this.loader?.destroy(), this.frame.remove(), this.destroyed = !0;\n }\n async hide() {\n if (!this.destroyed) {\n if (this.frame.style.visibility = "hidden", this.frame.style.setProperty("aria-hidden", "true"), this.frame.style.opacity = "0", this.frame.style.pointerEvents = "none", this.hidden = !0, this.frame.parentElement)\n return this.comms === void 0 || !this.comms.ready ? void 0 : new Promise((t, e) => {\n this.comms?.send("unfocus", void 0, (i) => {\n this.comms?.halt(), t();\n });\n });\n this.comms?.halt();\n }\n }\n async show(t) {\n if (this.destroyed) throw Error("Trying to show frame when it doesn\'t exist");\n if (!this.frame.parentElement) throw Error("Trying to show frame that is not attached to the DOM");\n return this.comms ? this.comms.resume() : this.comms = new wt(this.frame.contentWindow, this.source), new Promise((e, i) => {\n this.comms?.send("activate", void 0, () => {\n this.comms?.send("focus", void 0, () => {\n const A = () => {\n this.frame.style.removeProperty("visibility"), this.frame.style.removeProperty("aria-hidden"), this.frame.style.removeProperty("opacity"), this.frame.style.removeProperty("pointer-events"), this.hidden = !1, Mt.UA.WebKit && this.comms?.send("force_webkit_recalc", void 0), e();\n };\n t !== void 0 ? this.comms?.send("go_progression", t, A) : A();\n });\n });\n });\n }\n setCSSProperties(t) {\n this.destroyed || !this.frame.contentWindow || (this.hidden && (this.comms ? this.comms?.resume() : this.comms = new wt(this.frame.contentWindow, this.source)), this.comms?.send("update_properties", t), this.hidden && this.comms?.halt());\n }\n get iframe() {\n if (this.destroyed) throw Error("Trying to use frame when it doesn\'t exist");\n return this.frame;\n }\n get realSize() {\n if (this.destroyed) throw Error("Trying to use frame client rect when it doesn\'t exist");\n return this.frame.getBoundingClientRect();\n }\n get window() {\n if (this.destroyed || !this.frame.contentWindow) throw Error("Trying to use frame window when it doesn\'t exist");\n return this.frame.contentWindow;\n }\n get msg() {\n return this.comms;\n }\n get ldr() {\n return this.loader;\n }\n}\nclass mn {\n constructor(t, e) {\n this.pool = /* @__PURE__ */ new Map(), this.blobs = /* @__PURE__ */ new Map(), this.inprogress = /* @__PURE__ */ new Map(), this.pendingUpdates = /* @__PURE__ */ new Map(), this.container = t, this.currentCssProperties = e;\n }\n async destroy() {\n let t = this.inprogress.values(), e = t.next();\n const i = [];\n for (; e.value; )\n i.push(e.value), e = t.next();\n i.length > 0 && await Promise.allSettled(i), this.inprogress.clear();\n let A = this.pool.values(), n = A.next();\n for (; n.value; )\n await n.value.destroy(), n = A.next();\n this.pool.clear(), this.blobs.forEach((s) => URL.revokeObjectURL(s)), this.blobs.clear(), this.container.childNodes.forEach((s) => {\n (s.nodeType === Node.ELEMENT_NODE || s.nodeType === Node.TEXT_NODE) && s.remove();\n });\n }\n async update(t, e, i) {\n const A = t.readingOrder.items;\n let n = A.findIndex((a) => a.href === e.href);\n if (n < 0) throw Error(`Locator not found in reading order: ${e.href}`);\n const s = A[n].href;\n this.inprogress.has(s) && await this.inprogress.get(s);\n const o = new Promise(async (a, h) => {\n const c = [], d = [];\n t.readingOrder.items.forEach((l, p) => {\n p !== n && p !== n - 1 && p !== n + 1 && (c.includes(l.href) || c.push(l.href)), p === n && (d.includes(l.href) || d.push(l.href));\n }), c.forEach(async (l) => {\n d.includes(l) || this.pool.has(l) && (await this.pool.get(l)?.destroy(), this.pool.delete(l));\n }), this.currentBaseURL !== void 0 && t.baseURL !== this.currentBaseURL && (this.blobs.forEach((l) => URL.revokeObjectURL(l)), this.blobs.clear()), this.currentBaseURL = t.baseURL;\n const g = async (l) => {\n if (this.pendingUpdates.has(l) && this.pendingUpdates.get(l)?.inPool === !1) {\n const E = this.blobs.get(l);\n E && (URL.revokeObjectURL(E), this.blobs.delete(l), this.pendingUpdates.delete(l));\n }\n if (this.pool.has(l)) {\n const E = this.pool.get(l);\n if (!this.blobs.has(l))\n await E.destroy(), this.pool.delete(l), this.pendingUpdates.delete(l);\n else {\n await E.load(i);\n return;\n }\n }\n const p = t.readingOrder.findWithHref(l);\n if (!p) return;\n if (!this.blobs.has(l)) {\n const R = await new wA(t, this.currentBaseURL || "", p, this.currentCssProperties).build();\n this.blobs.set(l, R);\n }\n const w = new un(this.blobs.get(l));\n l !== s && await w.hide(), this.container.appendChild(w.iframe), await w.load(i), this.pool.set(l, w);\n };\n try {\n await Promise.all(d.map((l) => g(l)));\n } catch (l) {\n h(l);\n }\n const M = this.pool.get(s);\n M?.source !== this._currentFrame?.source && (await this._currentFrame?.hide(), M && await M.load(i), M && await M.show(e.locations.progression), this._currentFrame = M), a();\n });\n this.inprogress.set(s, o), await o, this.inprogress.delete(s);\n }\n setCSSProperties(t) {\n if (!((i, A) => {\n const n = Object.keys(i), s = Object.keys(A);\n if (n.length !== s.length)\n return !1;\n for (const o of n)\n if (i[o] !== A[o])\n return !1;\n return !0;\n })(this.currentCssProperties || {}, t)) {\n this.currentCssProperties = t, this.pool.forEach((i) => {\n i.setCSSProperties(t);\n });\n for (const i of this.blobs.keys())\n this.pendingUpdates.set(i, { inPool: this.pool.has(i) });\n }\n }\n get currentFrames() {\n return [this._currentFrame];\n }\n get currentBounds() {\n const t = {\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n toJSON() {\n return this;\n }\n };\n return this.currentFrames.forEach((e) => {\n if (!e) return;\n const i = e.realSize;\n t.x = Math.min(t.x, i.x), t.y = Math.min(t.y, i.y), t.width += i.width, t.height = Math.max(t.height, i.height), t.top = Math.min(t.top, i.top), t.right = Math.min(t.right, i.right), t.bottom = Math.min(t.bottom, i.bottom), t.left = Math.min(t.left, i.left);\n }), t;\n }\n}\nvar Kt, ei;\nfunction pn() {\n if (ei) return Kt;\n ei = 1;\n function r(A) {\n if (typeof A != "string")\n throw new TypeError("Path must be a string. Received " + JSON.stringify(A));\n }\n function t(A, n) {\n for (var s = "", o = 0, a = -1, h = 0, c, d = 0; d <= A.length; ++d) {\n if (d < A.length)\n c = A.charCodeAt(d);\n else {\n if (c === 47)\n break;\n c = 47;\n }\n if (c === 47) {\n if (!(a === d - 1 || h === 1)) if (a !== d - 1 && h === 2) {\n if (s.length < 2 || o !== 2 || s.charCodeAt(s.length - 1) !== 46 || s.charCodeAt(s.length - 2) !== 46) {\n if (s.length > 2) {\n var g = s.lastIndexOf("/");\n if (g !== s.length - 1) {\n g === -1 ? (s = "", o = 0) : (s = s.slice(0, g), o = s.length - 1 - s.lastIndexOf("/")), a = d, h = 0;\n continue;\n }\n } else if (s.length === 2 || s.length === 1) {\n s = "", o = 0, a = d, h = 0;\n continue;\n }\n }\n n && (s.length > 0 ? s += "/.." : s = "..", o = 2);\n } else\n s.length > 0 ? s += "/" + A.slice(a + 1, d) : s = A.slice(a + 1, d), o = d - a - 1;\n a = d, h = 0;\n } else c === 46 && h !== -1 ? ++h : h = -1;\n }\n return s;\n }\n function e(A, n) {\n var s = n.dir || n.root, o = n.base || (n.name || "") + (n.ext || "");\n return s ? s === n.root ? s + o : s + A + o : o;\n }\n var i = {\n // path.resolve([from ...], to)\n resolve: function() {\n for (var n = "", s = !1, o, a = arguments.length - 1; a >= -1 && !s; a--) {\n var h;\n a >= 0 ? h = arguments[a] : (o === void 0 && (o = process.cwd()), h = o), r(h), h.length !== 0 && (n = h + "/" + n, s = h.charCodeAt(0) === 47);\n }\n return n = t(n, !s), s ? n.length > 0 ? "/" + n : "/" : n.length > 0 ? n : ".";\n },\n normalize: function(n) {\n if (r(n), n.length === 0) return ".";\n var s = n.charCodeAt(0) === 47, o = n.charCodeAt(n.length - 1) === 47;\n return n = t(n, !s), n.length === 0 && !s && (n = "."), n.length > 0 && o && (n += "/"), s ? "/" + n : n;\n },\n isAbsolute: function(n) {\n return r(n), n.length > 0 && n.charCodeAt(0) === 47;\n },\n join: function() {\n if (arguments.length === 0)\n return ".";\n for (var n, s = 0; s < arguments.length; ++s) {\n var o = arguments[s];\n r(o), o.length > 0 && (n === void 0 ? n = o : n += "/" + o);\n }\n return n === void 0 ? "." : i.normalize(n);\n },\n relative: function(n, s) {\n if (r(n), r(s), n === s || (n = i.resolve(n), s = i.resolve(s), n === s)) return "";\n for (var o = 1; o < n.length && n.charCodeAt(o) === 47; ++o)\n ;\n for (var a = n.length, h = a - o, c = 1; c < s.length && s.charCodeAt(c) === 47; ++c)\n ;\n for (var d = s.length, g = d - c, M = h < g ? h : g, l = -1, p = 0; p <= M; ++p) {\n if (p === M) {\n if (g > M) {\n if (s.charCodeAt(c + p) === 47)\n return s.slice(c + p + 1);\n if (p === 0)\n return s.slice(c + p);\n } else h > M && (n.charCodeAt(o + p) === 47 ? l = p : p === 0 && (l = 0));\n break;\n }\n var w = n.charCodeAt(o + p), E = s.charCodeAt(c + p);\n if (w !== E)\n break;\n w === 47 && (l = p);\n }\n var R = "";\n for (p = o + l + 1; p <= a; ++p)\n (p === a || n.charCodeAt(p) === 47) && (R.length === 0 ? R += ".." : R += "/..");\n return R.length > 0 ? R + s.slice(c + l) : (c += l, s.charCodeAt(c) === 47 && ++c, s.slice(c));\n },\n _makeLong: function(n) {\n return n;\n },\n dirname: function(n) {\n if (r(n), n.length === 0) return ".";\n for (var s = n.charCodeAt(0), o = s === 47, a = -1, h = !0, c = n.length - 1; c >= 1; --c)\n if (s = n.charCodeAt(c), s === 47) {\n if (!h) {\n a = c;\n break;\n }\n } else\n h = !1;\n return a === -1 ? o ? "/" : "." : o && a === 1 ? "//" : n.slice(0, a);\n },\n basename: function(n, s) {\n if (s !== void 0 && typeof s != "string") throw new TypeError(\'"ext" argument must be a string\');\n r(n);\n var o = 0, a = -1, h = !0, c;\n if (s !== void 0 && s.length > 0 && s.length <= n.length) {\n if (s.length === n.length && s === n) return "";\n var d = s.length - 1, g = -1;\n for (c = n.length - 1; c >= 0; --c) {\n var M = n.charCodeAt(c);\n if (M === 47) {\n if (!h) {\n o = c + 1;\n break;\n }\n } else\n g === -1 && (h = !1, g = c + 1), d >= 0 && (M === s.charCodeAt(d) ? --d === -1 && (a = c) : (d = -1, a = g));\n }\n return o === a ? a = g : a === -1 && (a = n.length), n.slice(o, a);\n } else {\n for (c = n.length - 1; c >= 0; --c)\n if (n.charCodeAt(c) === 47) {\n if (!h) {\n o = c + 1;\n break;\n }\n } else a === -1 && (h = !1, a = c + 1);\n return a === -1 ? "" : n.slice(o, a);\n }\n },\n extname: function(n) {\n r(n);\n for (var s = -1, o = 0, a = -1, h = !0, c = 0, d = n.length - 1; d >= 0; --d) {\n var g = n.charCodeAt(d);\n if (g === 47) {\n if (!h) {\n o = d + 1;\n break;\n }\n continue;\n }\n a === -1 && (h = !1, a = d + 1), g === 46 ? s === -1 ? s = d : c !== 1 && (c = 1) : s !== -1 && (c = -1);\n }\n return s === -1 || a === -1 || // We saw a non-dot character immediately before the dot\n c === 0 || // The (right-most) trimmed path component is exactly \'..\'\n c === 1 && s === a - 1 && s === o + 1 ? "" : n.slice(s, a);\n },\n format: function(n) {\n if (n === null || typeof n != "object")\n throw new TypeError(\'The "pathObject" argument must be of type Object. Received type \' + typeof n);\n return e("/", n);\n },\n parse: function(n) {\n r(n);\n var s = { root: "", dir: "", base: "", ext: "", name: "" };\n if (n.length === 0) return s;\n var o = n.charCodeAt(0), a = o === 47, h;\n a ? (s.root = "/", h = 1) : h = 0;\n for (var c = -1, d = 0, g = -1, M = !0, l = n.length - 1, p = 0; l >= h; --l) {\n if (o = n.charCodeAt(l), o === 47) {\n if (!M) {\n d = l + 1;\n break;\n }\n continue;\n }\n g === -1 && (M = !1, g = l + 1), o === 46 ? c === -1 ? c = l : p !== 1 && (p = 1) : c !== -1 && (p = -1);\n }\n return c === -1 || g === -1 || // We saw a non-dot character immediately before the dot\n p === 0 || // The (right-most) trimmed path component is exactly \'..\'\n p === 1 && c === g - 1 && c === d + 1 ? g !== -1 && (d === 0 && a ? s.base = s.name = n.slice(1, g) : s.base = s.name = n.slice(d, g)) : (d === 0 && a ? (s.name = n.slice(1, c), s.base = n.slice(1, g)) : (s.name = n.slice(d, c), s.base = n.slice(d, g)), s.ext = n.slice(c, g)), d > 0 ? s.dir = n.slice(0, d - 1) : a && (s.dir = "/"), s;\n },\n sep: "/",\n delimiter: ":",\n win32: null,\n posix: null\n };\n return i.posix = i, Kt = i, Kt;\n}\nvar Pt = pn();\nclass Ce {\n constructor() {\n }\n toFlag(t) {\n return `readium-${t}-on`;\n }\n toUnitless(t) {\n return t.toString();\n }\n toPercentage(t, e = !1) {\n return e || t > 0 && t <= 1 ? `${Math.round(t * 100)}%` : `${t}%`;\n }\n toVw(t) {\n const e = Math.round(t * 100);\n return `${Math.min(e, 100)}vw`;\n }\n toVh(t) {\n const e = Math.round(t * 100);\n return `${Math.min(e, 100)}vh`;\n }\n toPx(t) {\n return `${t}px`;\n }\n toRem(t) {\n return `${t}rem`;\n }\n}\nclass Zi extends Ce {\n constructor(t) {\n super(), this.a11yNormalize = t.a11yNormalize ?? null, this.bodyHyphens = t.bodyHyphens ?? null, this.fontFamily = t.fontFamily ?? null, this.fontWeight = t.fontWeight ?? null, this.iOSPatch = t.iOSPatch ?? null, this.iPadOSPatch = t.iPadOSPatch ?? null, this.letterSpacing = t.letterSpacing ?? null, this.ligatures = t.ligatures ?? null, this.lineHeight = t.lineHeight ?? null, this.noRuby = t.noRuby ?? null, this.paraIndent = t.paraIndent ?? null, this.paraSpacing = t.paraSpacing ?? null, this.textAlign = t.textAlign ?? null, this.wordSpacing = t.wordSpacing ?? null, this.zoom = t.zoom ?? null;\n }\n toCSSProperties() {\n const t = {};\n return this.a11yNormalize && (t["--USER__a11yNormalize"] = this.toFlag("a11y")), this.bodyHyphens && (t["--USER__bodyHyphens"] = this.bodyHyphens), this.fontFamily && (t["--USER__fontFamily"] = this.fontFamily), this.fontWeight != null && (t["--USER__fontWeight"] = this.toUnitless(this.fontWeight)), this.iOSPatch && (t["--USER__iOSPatch"] = this.toFlag("iOSPatch")), this.iPadOSPatch && (t["--USER__iPadOSPatch"] = this.toFlag("iPadOSPatch")), this.letterSpacing != null && (t["--USER__letterSpacing"] = this.toRem(this.letterSpacing)), this.ligatures && (t["--USER__ligatures"] = this.ligatures), this.lineHeight != null && (t["--USER__lineHeight"] = this.toUnitless(this.lineHeight)), this.noRuby && (t["--USER__noRuby"] = this.toFlag("noRuby")), this.paraIndent != null && (t["--USER__paraIndent"] = this.toRem(this.paraIndent)), this.paraSpacing != null && (t["--USER__paraSpacing"] = this.toRem(this.paraSpacing)), this.textAlign && (t["--USER__textAlign"] = this.textAlign), this.wordSpacing != null && (t["--USER__wordSpacing"] = this.toRem(this.wordSpacing)), this.zoom !== null && (t["--USER__zoom"] = this.toPercentage(this.zoom, !0)), t;\n }\n}\nclass fn {\n constructor(t) {\n this.userProperties = t.userProperties;\n }\n update(t) {\n const e = {\n a11yNormalize: t.textNormalization,\n bodyHyphens: typeof t.hyphens != "boolean" ? null : t.hyphens ? "auto" : "none",\n fontFamily: t.fontFamily,\n fontWeight: t.fontWeight,\n iOSPatch: t.iOSPatch,\n iPadOSPatch: t.iPadOSPatch,\n letterSpacing: t.letterSpacing,\n ligatures: typeof t.ligatures != "boolean" ? null : t.ligatures ? "common-ligatures" : "none",\n lineHeight: t.lineHeight,\n noRuby: t.noRuby,\n paraIndent: t.paragraphIndent,\n paraSpacing: t.paragraphSpacing,\n textAlign: t.textAlign,\n wordSpacing: t.wordSpacing,\n zoom: t.zoom\n };\n this.userProperties = new Zi(e);\n }\n}\nvar X = /* @__PURE__ */ ((r) => (r.start = "start", r.left = "left", r.right = "right", r.justify = "justify", r))(X || {});\nconst nt = {\n range: [0, 100],\n step: 1\n}, bt = {\n range: [0.7, 4],\n step: 0.05\n}, $ = {\n range: [100, 1e3],\n step: 100\n}, jt = {\n range: [50, 250],\n step: 10\n}, Vt = {\n range: [0, 1],\n step: 0.125\n}, vt = {\n range: [1, 2],\n step: 0.1\n}, rt = {\n range: [20, 100],\n step: 1\n}, Dt = {\n range: [0, 3],\n step: 0.25\n}, Ht = {\n range: [0, 3],\n step: 0.25\n}, Gt = {\n range: [0, 2],\n step: 0.125\n}, kt = {\n range: [0.7, 4],\n step: 0.05\n};\nfunction Mn(r, t) {\n return r == null || t == null || r <= t ? r : void 0;\n}\nfunction Bn(r, t) {\n return r == null || t == null || r >= t ? r : void 0;\n}\nfunction Y(r) {\n return typeof r == "string" ? r : r === null ? null : void 0;\n}\nfunction y(r) {\n return typeof r == "boolean" || r == null ? r : void 0;\n}\nfunction Lt(r, t) {\n if (r !== void 0)\n return r === null ? null : t[r] !== void 0 ? r : void 0;\n}\nfunction dt(r) {\n return typeof r == "boolean" || typeof r == "number" && r >= 0 ? r : r === null ? null : void 0;\n}\nfunction I(r) {\n if (r !== void 0)\n return r === null ? null : r < 0 ? void 0 : r;\n}\nfunction J(r, t) {\n if (r === void 0)\n return;\n if (r === null)\n return null;\n const e = Math.min(...t), i = Math.max(...t);\n return r >= e && r <= i ? r : void 0;\n}\nfunction qt(r, t) {\n return r === void 0 ? t : r;\n}\nclass Et {\n constructor(t = {}) {\n this.fontFamily = Y(t.fontFamily), this.fontWeight = J(t.fontWeight, $.range), this.hyphens = y(t.hyphens), this.iOSPatch = y(t.iOSPatch), this.iPadOSPatch = y(t.iPadOSPatch), this.letterSpacing = I(t.letterSpacing), this.ligatures = y(t.ligatures), this.lineHeight = I(t.lineHeight), this.noRuby = y(t.noRuby), this.paragraphIndent = I(t.paragraphIndent), this.paragraphSpacing = I(t.paragraphSpacing), this.textAlign = Lt(t.textAlign, X), this.textNormalization = y(t.textNormalization), this.wordSpacing = I(t.wordSpacing), this.zoom = J(t.zoom, kt.range);\n }\n static serialize(t) {\n const { ...e } = t;\n return JSON.stringify(e);\n }\n static deserialize(t) {\n try {\n const e = JSON.parse(t);\n return new Et(e);\n } catch (e) {\n return console.error("Failed to deserialize preferences:", e), null;\n }\n }\n merging(t) {\n const e = { ...this };\n for (const i of Object.keys(t))\n t[i] !== void 0 && (e[i] = t[i]);\n return new Et(e);\n }\n}\nclass wn {\n constructor(t) {\n this.fontFamily = Y(t.fontFamily) || null, this.fontWeight = J(t.fontWeight, $.range) || null, this.hyphens = y(t.hyphens) ?? null, this.iOSPatch = t.iOSPatch === !1 ? !1 : (U.OS.iOS || U.OS.iPadOS) && U.iOSRequest === "mobile", this.iPadOSPatch = t.iPadOSPatch === !1 ? !1 : U.OS.iPadOS && U.iOSRequest === "desktop", this.letterSpacing = I(t.letterSpacing) || null, this.ligatures = y(t.ligatures) ?? null, this.lineHeight = I(t.lineHeight) || null, this.noRuby = y(t.noRuby) ?? !1, this.paragraphIndent = I(t.paragraphIndent) ?? null, this.paragraphSpacing = I(t.paragraphSpacing) ?? null, this.textAlign = Lt(t.textAlign, X) || null, this.textNormalization = y(t.textNormalization) ?? !1, this.wordSpacing = I(t.wordSpacing) || null, this.zoom = J(t.zoom, kt.range) || 1;\n }\n}\nclass ii {\n constructor(t, e, i) {\n this.fontFamily = null, this.fontWeight = null, this.hyphens = null, this.iOSPatch = null, this.iPadOSPatch = null, this.letterSpacing = null, this.ligatures = null, this.lineHeight = null, this.noRuby = null, this.paragraphIndent = null, this.paragraphSpacing = null, this.textAlign = null, this.textNormalization = null, this.wordSpacing = null, i && (this.fontFamily = t.fontFamily || e.fontFamily || null, this.fontWeight = t.fontWeight !== void 0 ? t.fontWeight : e.fontWeight !== void 0 ? e.fontWeight : null, this.hyphens = typeof t.hyphens == "boolean" ? t.hyphens : e.hyphens ?? null, this.iOSPatch = t.iOSPatch === !1 ? !1 : t.iOSPatch === !0 ? (U.OS.iOS || U.OS.iPadOS) && U.iOSRequest === "mobile" : e.iOSPatch, this.iPadOSPatch = t.iPadOSPatch === !1 ? !1 : t.iPadOSPatch === !0 ? U.OS.iPadOS && U.iOSRequest === "desktop" : e.iPadOSPatch, this.letterSpacing = t.letterSpacing !== void 0 ? t.letterSpacing : e.letterSpacing !== void 0 ? e.letterSpacing : null, this.ligatures = typeof t.ligatures == "boolean" ? t.ligatures : e.ligatures ?? null, this.lineHeight = t.lineHeight !== void 0 ? t.lineHeight : e.lineHeight !== void 0 ? e.lineHeight : null, this.noRuby = typeof t.noRuby == "boolean" ? t.noRuby : e.noRuby ?? null, this.paragraphIndent = t.paragraphIndent !== void 0 ? t.paragraphIndent : e.paragraphIndent !== void 0 ? e.paragraphIndent : null, this.paragraphSpacing = t.paragraphSpacing !== void 0 ? t.paragraphSpacing : e.paragraphSpacing !== void 0 ? e.paragraphSpacing : null, this.textAlign = t.textAlign || e.textAlign || null, this.textNormalization = typeof t.textNormalization == "boolean" ? t.textNormalization : e.textNormalization ?? null, this.wordSpacing = t.wordSpacing !== void 0 ? t.wordSpacing : e.wordSpacing !== void 0 ? e.wordSpacing : null), this.zoom = t.zoom !== void 0 ? t.zoom : e.zoom !== void 0 ? e.zoom : null;\n }\n}\nclass Q {\n constructor({\n initialValue: t = null,\n effectiveValue: e,\n isEffective: i,\n onChange: A\n }) {\n this._value = t, this._effectiveValue = e, this._isEffective = i, this._onChange = A;\n }\n set value(t) {\n this._value = t, this._onChange(this._value);\n }\n get value() {\n return this._value;\n }\n get effectiveValue() {\n return this._effectiveValue;\n }\n get isEffective() {\n return this._isEffective;\n }\n clear() {\n this._value = null;\n }\n}\nclass z extends Q {\n set value(t) {\n this._value = t, this._onChange(this._value);\n }\n get value() {\n return this._value;\n }\n get effectiveValue() {\n return this._effectiveValue;\n }\n get isEffective() {\n return this._isEffective;\n }\n clear() {\n this._value = null;\n }\n toggle() {\n this._value = !this._value, this._onChange(this._value);\n }\n}\nclass Ki extends Q {\n constructor({\n initialValue: t = null,\n effectiveValue: e,\n isEffective: i,\n onChange: A,\n supportedValues: n\n }) {\n super({ initialValue: t, effectiveValue: e, isEffective: i, onChange: A }), this._supportedValues = n;\n }\n set value(t) {\n if (t && !this._supportedValues.includes(t))\n throw new Error(`Value \'${String(t)}\' is not in the supported values for this preference.`);\n this._value = t, this._onChange(this._value);\n }\n get value() {\n return this._value;\n }\n get effectiveValue() {\n return this._effectiveValue;\n }\n get isEffective() {\n return this._isEffective;\n }\n get supportedValues() {\n return this._supportedValues;\n }\n clear() {\n this._value = null;\n }\n}\nclass F extends Q {\n constructor({\n initialValue: t = null,\n effectiveValue: e,\n isEffective: i,\n onChange: A,\n supportedRange: n,\n step: s\n }) {\n super({ initialValue: t, effectiveValue: e, isEffective: i, onChange: A }), this._supportedRange = n, this._step = s, this._decimals = this._step.toString().includes(".") ? this._step.toString().split(".")[1].length : 0;\n }\n set value(t) {\n if (t && (t < this._supportedRange[0] || t > this._supportedRange[1]))\n throw new Error(`Value \'${String(t)}\' is out of the supported range for this preference.`);\n this._value = t, this._onChange(this._value);\n }\n get value() {\n return this._value;\n }\n get effectiveValue() {\n return this._effectiveValue;\n }\n get isEffective() {\n return this._isEffective;\n }\n get supportedRange() {\n return this._supportedRange;\n }\n get step() {\n return this._step;\n }\n increment() {\n this._value && this._value < this._supportedRange[1] && (this._value = Math.min(\n Math.round((this._value + this._step) * 10 ** this._decimals) / 10 ** this._decimals,\n this._supportedRange[1]\n ), this._onChange(this._value));\n }\n decrement() {\n this._value && this._value > this._supportedRange[0] && (this._value = Math.max(\n Math.round((this._value - this._step) * 10 ** this._decimals) / 10 ** this._decimals,\n this._supportedRange[0]\n ), this._onChange(this._value));\n }\n format(t) {\n return t.toString();\n }\n clear() {\n this._value = null;\n }\n}\nclass Ai {\n constructor(t, e, i) {\n this.preferences = t, this.settings = e, this.metadata = i;\n }\n clear() {\n this.preferences = new Et({});\n }\n updatePreference(t, e) {\n this.preferences[t] = e;\n }\n get isDisplayTransformable() {\n return this.metadata?.accessibility?.feature?.some(\n (t) => t.value === gi.DISPLAY_TRANSFORMABILITY.value\n ) ?? !1;\n }\n get fontFamily() {\n return new Q({\n initialValue: this.preferences.fontFamily,\n effectiveValue: this.settings.fontFamily || null,\n isEffective: this.isDisplayTransformable,\n onChange: (t) => {\n this.updatePreference("fontFamily", t || null);\n }\n });\n }\n get fontWeight() {\n return new F({\n initialValue: this.preferences.fontWeight,\n effectiveValue: this.settings.fontWeight || 400,\n isEffective: this.isDisplayTransformable,\n onChange: (t) => {\n this.updatePreference("fontWeight", t || null);\n },\n supportedRange: $.range,\n step: $.step\n });\n }\n get hyphens() {\n return new z({\n initialValue: this.preferences.hyphens,\n effectiveValue: this.settings.hyphens || !1,\n isEffective: this.isDisplayTransformable,\n onChange: (t) => {\n this.updatePreference("hyphens", t || null);\n }\n });\n }\n get iOSPatch() {\n return new z({\n initialValue: this.preferences.iOSPatch,\n effectiveValue: this.settings.iOSPatch || !1,\n isEffective: !0,\n onChange: (t) => {\n this.updatePreference("iOSPatch", t || null);\n }\n });\n }\n get iPadOSPatch() {\n return new z({\n initialValue: this.preferences.iPadOSPatch,\n effectiveValue: this.settings.iPadOSPatch || !1,\n isEffective: !0,\n onChange: (t) => {\n this.updatePreference("iPadOSPatch", t || null);\n }\n });\n }\n get letterSpacing() {\n return new F({\n initialValue: this.preferences.letterSpacing,\n effectiveValue: this.settings.letterSpacing || 0,\n isEffective: this.isDisplayTransformable,\n onChange: (t) => {\n this.updatePreference("letterSpacing", t || null);\n },\n supportedRange: Vt.range,\n step: Vt.step\n });\n }\n get ligatures() {\n return new z({\n initialValue: this.preferences.ligatures,\n effectiveValue: this.settings.ligatures || !0,\n isEffective: this.isDisplayTransformable,\n onChange: (t) => {\n this.updatePreference("ligatures", t || null);\n }\n });\n }\n get lineHeight() {\n return new F({\n initialValue: this.preferences.lineHeight,\n effectiveValue: this.settings.lineHeight,\n isEffective: this.isDisplayTransformable,\n onChange: (t) => {\n this.updatePreference("lineHeight", t || null);\n },\n supportedRange: vt.range,\n step: vt.step\n });\n }\n get noRuby() {\n return new z({\n initialValue: this.preferences.noRuby,\n effectiveValue: this.settings.noRuby || !1,\n isEffective: this.isDisplayTransformable,\n onChange: (t) => {\n this.updatePreference("noRuby", t || null);\n }\n });\n }\n get paragraphIndent() {\n return new F({\n initialValue: this.preferences.paragraphIndent,\n effectiveValue: this.settings.paragraphIndent || 0,\n isEffective: this.isDisplayTransformable,\n onChange: (t) => {\n this.updatePreference("paragraphIndent", t || null);\n },\n supportedRange: Dt.range,\n step: Dt.step\n });\n }\n get paragraphSpacing() {\n return new F({\n initialValue: this.preferences.paragraphSpacing,\n effectiveValue: this.settings.paragraphSpacing || 0,\n isEffective: this.isDisplayTransformable,\n onChange: (t) => {\n this.updatePreference("paragraphSpacing", t || null);\n },\n supportedRange: Ht.range,\n step: Ht.step\n });\n }\n get textAlign() {\n return new Ki({\n initialValue: this.preferences.textAlign,\n effectiveValue: this.settings.textAlign || X.start,\n isEffective: this.isDisplayTransformable,\n onChange: (t) => {\n this.updatePreference("textAlign", t || null);\n },\n supportedValues: Object.values(X)\n });\n }\n get textNormalization() {\n return new z({\n initialValue: this.preferences.textNormalization,\n effectiveValue: this.settings.textNormalization || !1,\n isEffective: this.isDisplayTransformable,\n onChange: (t) => {\n this.updatePreference("textNormalization", t || null);\n }\n });\n }\n get wordSpacing() {\n return new F({\n initialValue: this.preferences.wordSpacing,\n effectiveValue: this.settings.wordSpacing || 0,\n isEffective: this.isDisplayTransformable,\n onChange: (t) => {\n this.updatePreference("wordSpacing", t || null);\n },\n supportedRange: Gt.range,\n step: Gt.step\n });\n }\n get zoom() {\n return new F({\n initialValue: this.preferences.zoom,\n effectiveValue: this.settings.zoom || 1,\n isEffective: CSS.supports("zoom", "1") ?? !1,\n onChange: (t) => {\n this.updatePreference("zoom", t || null);\n },\n supportedRange: kt.range,\n step: kt.step\n });\n }\n}\nconst En = (r) => ({\n frameLoaded: r.frameLoaded || (() => {\n }),\n positionChanged: r.positionChanged || (() => {\n }),\n tap: r.tap || (() => !1),\n click: r.click || (() => !1),\n zoom: r.zoom || (() => {\n }),\n scroll: r.scroll || (() => {\n }),\n customEvent: r.customEvent || (() => {\n }),\n handleLocator: r.handleLocator || (() => !1),\n textSelected: r.textSelected || (() => {\n })\n});\nclass In extends wi {\n constructor(t, e, i, A = void 0, n = { preferences: {}, defaults: {} }) {\n if (super(), this.currentIndex = 0, this._preferencesEditor = null, this.webViewport = {\n readingOrder: [],\n progressions: /* @__PURE__ */ new Map(),\n positions: null\n }, this.pub = e, this.container = t, this.listeners = En(i), this._preferences = new Et(n.preferences), this._defaults = new wn(n.defaults), this._settings = new ii(this._preferences, this._defaults, this.hasDisplayTransformability), this._css = new fn({\n userProperties: new Zi({ zoom: this._settings.zoom })\n }), A && typeof A.copyWithLocations == "function") {\n this.currentLocation = A;\n const s = this.pub.readingOrder.findIndexWithHref(A.href);\n s >= 0 && (this.currentIndex = s);\n } else\n this.currentLocation = this.createCurrentLocator();\n }\n async load() {\n await this.updateCSS(!1);\n const t = this.compileCSSProperties(this._css);\n this.framePool = new mn(this.container, t), await this.apply();\n }\n // Configurable interface implementation\n get settings() {\n return Object.freeze({ ...this._settings });\n }\n get preferencesEditor() {\n return this._preferencesEditor === null && (this._preferencesEditor = new Ai(this._preferences, this.settings, this.pub.metadata)), this._preferencesEditor;\n }\n async submitPreferences(t) {\n this._preferences = this._preferences.merging(t), await this.applyPreferences();\n }\n async applyPreferences() {\n this._settings = new ii(this._preferences, this._defaults, this.hasDisplayTransformability), this._preferencesEditor !== null && (this._preferencesEditor = new Ai(this._preferences, this.settings, this.pub.metadata)), await this.updateCSS(!0);\n }\n async updateCSS(t) {\n this._css.update(this._settings), t && await this.commitCSS(this._css);\n }\n compileCSSProperties(t) {\n const e = {};\n for (const [i, A] of Object.entries(t.userProperties.toCSSProperties()))\n e[i] = A;\n return e;\n }\n async commitCSS(t) {\n const e = this.compileCSSProperties(t);\n this.framePool.setCSSProperties(e);\n }\n /**\n * Exposed to the public to compensate for lack of implemented readium conveniences\n * TODO remove when settings management is incorporated\n */\n get _cframes() {\n return this.framePool.currentFrames;\n }\n get hasDisplayTransformability() {\n return this.pub.metadata?.accessibility?.feature?.some(\n (t) => t.value === gi.DISPLAY_TRANSFORMABILITY.value\n ) ?? !1;\n }\n eventListener(t, e) {\n switch (t) {\n case "_pong":\n this.listeners.frameLoaded(this.framePool.currentFrames[0].iframe.contentWindow), this.listeners.positionChanged(this.currentLocation);\n break;\n case "first_visible_locator":\n const i = ht.deserialize(e);\n if (!i) break;\n this.currentLocation = new ht({\n href: this.currentLocation.href,\n type: this.currentLocation.type,\n title: this.currentLocation.title,\n locations: i?.locations,\n text: i?.text\n }), this.listeners.positionChanged(this.currentLocation);\n break;\n case "text_selected":\n this.listeners.textSelected(e);\n break;\n case "click":\n case "tap":\n const A = e;\n if (A.interactiveElement) {\n const n = new DOMParser().parseFromString(\n A.interactiveElement,\n "text/html"\n ).body.children[0];\n if (n.nodeType === n.ELEMENT_NODE && n.nodeName === "A" && n.hasAttribute("href")) {\n const s = n.attributes.getNamedItem("href")?.value;\n if (s.startsWith("#"))\n this.go(this.currentLocation.copyWithLocations({\n fragments: [s.substring(1)]\n }), !1, () => {\n });\n else if (s.startsWith("mailto:") || s.startsWith("tel:"))\n this.listeners.handleLocator(new q({\n href: s\n }).locator);\n else\n try {\n let o;\n if (s.startsWith("http://") || s.startsWith("https://"))\n o = s;\n else if (this.currentLocation.href.startsWith("http://") || this.currentLocation.href.startsWith("https://")) {\n const h = new URL(this.currentLocation.href);\n o = new URL(s, h).href;\n } else\n o = Pt.join(Pt.dirname(this.currentLocation.href), s);\n const a = this.pub.readingOrder.findWithHref(o);\n a ? this.goLink(a, !1, () => {\n }) : (console.warn(`Internal link not found in readingOrder: ${o}`), this.listeners.handleLocator(new q({\n href: s\n }).locator));\n } catch (o) {\n console.warn(`Couldn\'t resolve internal link for ${s}: ${o}`), this.listeners.handleLocator(new q({\n href: s\n }).locator);\n }\n } else console.log("Clicked on", n);\n } else if (t === "click" ? this.listeners.click(A) : this.listeners.tap(A)) break;\n break;\n case "scroll":\n this.listeners.scroll(e);\n break;\n case "zoom":\n this.listeners.zoom(e);\n break;\n case "progress":\n this.syncLocation(e);\n break;\n case "log":\n console.log(this.framePool.currentFrames[0]?.source?.split("/")[3], ...e);\n break;\n default:\n this.listeners.customEvent(t, e);\n break;\n }\n }\n determineModules() {\n return Array.from(Tt.keys()).filter((e) => an.includes(e));\n }\n attachListener() {\n this.framePool.currentFrames[0]?.msg && (this.framePool.currentFrames[0].msg.listener = (t, e) => {\n this.eventListener(t, e);\n });\n }\n async apply() {\n if (await this.framePool.update(this.pub, this.currentLocation, this.determineModules()), this.attachListener(), this.pub.readingOrder.findIndexWithHref(this.currentLocation.href) < 0)\n throw Error("Link for " + this.currentLocation.href + " not found!");\n }\n async destroy() {\n await this.framePool?.destroy();\n }\n async changeResource(t) {\n if (t === 0) return !1;\n const e = this.pub.readingOrder.findIndexWithHref(this.currentLocation.href), i = Math.max(\n 0,\n Math.min(this.pub.readingOrder.items.length - 1, e + t)\n );\n return i === e ? !1 : (this.currentIndex = i, this.currentLocation = this.createCurrentLocator(), await this.apply(), !0);\n }\n updateViewport(t) {\n this.webViewport.readingOrder = [], this.webViewport.progressions.clear(), this.webViewport.positions = null, this.currentLocation && (this.webViewport.readingOrder.push(this.currentLocation.href), this.webViewport.progressions.set(this.currentLocation.href, t), this.currentLocation.locations?.position !== void 0 && (this.webViewport.positions = [this.currentLocation.locations.position]));\n }\n async syncLocation(t) {\n const e = t;\n this.currentLocation && (this.currentLocation = this.currentLocation.copyWithLocations({\n progression: e.start\n })), this.updateViewport(e), this.listeners.positionChanged(this.currentLocation), await this.framePool.update(this.pub, this.currentLocation, this.determineModules());\n }\n goBackward(t, e) {\n this.changeResource(-1).then((i) => {\n e(i);\n });\n }\n goForward(t, e) {\n this.changeResource(1).then((i) => {\n e(i);\n });\n }\n get currentLocator() {\n return this.currentLocation;\n }\n get viewport() {\n return this.webViewport;\n }\n get isScrollStart() {\n const t = this.viewport.readingOrder[0];\n return this.viewport.progressions.get(t)?.start === 0;\n }\n get isScrollEnd() {\n const t = this.viewport.readingOrder[this.viewport.readingOrder.length - 1];\n return this.viewport.progressions.get(t)?.end === 1;\n }\n get canGoBackward() {\n const t = this.pub.readingOrder.items[0]?.href;\n return !(this.viewport.progressions.has(t) && this.viewport.progressions.get(t)?.start === 0);\n }\n get canGoForward() {\n const t = this.pub.readingOrder.items[this.pub.readingOrder.items.length - 1]?.href;\n return !(this.viewport.progressions.has(t) && this.viewport.progressions.get(t)?.end === 1);\n }\n get readingProgression() {\n return this.pub.metadata.effectiveReadingProgression;\n }\n get publication() {\n return this.pub;\n }\n async loadLocator(t, e) {\n let i = !1, A = typeof t.locations.getCssSelector == "function" && t.locations.getCssSelector();\n if (t.text?.highlight ? i = await new Promise((a, h) => {\n this.framePool.currentFrames[0].msg.send(\n "go_text",\n A ? [\n t.text?.serialize(),\n A\n // Include CSS selector if it exists\n ] : t.text?.serialize(),\n (c) => a(c)\n );\n }) : A && (i = await new Promise((a, h) => {\n this.framePool.currentFrames[0].msg.send(\n "go_text",\n [\n "",\n // No text!\n A\n // Just CSS selector\n ],\n (c) => a(c)\n );\n })), i) {\n e(i);\n return;\n }\n const n = typeof t.locations.htmlId == "function" && t.locations.htmlId();\n if (n && (i = await new Promise((a, h) => {\n this.framePool.currentFrames[0].msg.send("go_id", n, (c) => a(c));\n })), i) {\n e(i);\n return;\n }\n const s = t?.locations?.progression;\n s && s > 0 ? i = await new Promise((a, h) => {\n this.framePool.currentFrames[0].msg.send("go_progression", s, (c) => a(c));\n }) : i = !0, e(i);\n }\n go(t, e, i) {\n const A = t.href.split("#")[0];\n if (!this.pub.readingOrder.findWithHref(A))\n return i(this.listeners.handleLocator(t));\n const s = this.pub.readingOrder.findIndexWithHref(A);\n s >= 0 && (this.currentIndex = s), this.currentLocation = this.createCurrentLocator(), this.apply().then(() => this.loadLocator(t, (o) => i(o))).then(() => {\n this.attachListener();\n });\n }\n goLink(t, e, i) {\n return this.go(t.locator, e, i);\n }\n // Specifics to WebPub\n // Util method\n createCurrentLocator() {\n const e = this.pub.readingOrder.items[this.currentIndex];\n if (!e)\n throw new Error("No current resource available");\n const A = this.currentLocation && this.currentLocation.href === e.href && this.currentLocation.locations.progression ? this.currentLocation.locations.progression : 0;\n return this.pub.manifest.locatorFromLink(e) || new ht({\n href: e.href,\n type: e.type || "text/html",\n locations: new j({\n fragments: [],\n progression: A,\n position: this.currentIndex + 1\n })\n });\n }\n}\nconst ir = In, yn = `/*!\n * Readium CSS v.2.0.0-beta.22\n * Copyright (c) 2017–2025. Readium Foundation. All rights reserved.\n * Use of this source code is governed by a BSD-style license which is detailed in the\n * LICENSE file present in the project repository where this source code is maintained.\n * Core maintainer: Jiminy Panoz \n * Contributors: \n * Daniel Weck\n * Hadrien Gardeur\n * Innovimax\n * L. Le Meur\n * Mickaël Menu\n * k_taka\n */@namespace url(http://www.w3.org/1999/xhtml);@namespace epub url(http://www.idpf.org/2007/ops);@namespace m url(http://www.w3.org/1998/Math/MathML);@namespace svg url(http://www.w3.org/2000/svg);:root{--RS__viewportWidth:100%;--RS__pageGutter:0;--RS__defaultLineLength:40rem;--RS__colGap:0;--RS__colCount:1;--RS__colWidth:100vw}@page{margin:0!important}:root{position:relative;-webkit-column-width:var(--RS__colWidth);-moz-column-width:var(--RS__colWidth);column-width:var(--RS__colWidth);-webkit-column-count:var(--RS__colCount);-moz-column-count:var(--RS__colCount);column-count:var(--RS__colCount);-webkit-column-gap:var(--RS__colGap);-moz-column-gap:var(--RS__colGap);column-gap:var(--RS__colGap);-moz-column-fill:auto;column-fill:auto;width:var(--RS__viewportWidth);height:100vh;max-width:var(--RS__viewportWidth);max-height:100vh;min-width:var(--RS__viewportWidth);min-height:100vh;padding:0!important;margin:0!important;font-size:1rem!important;box-sizing:border-box;-webkit-touch-callout:none}body{width:100%;max-width:var(--RS__defaultLineLength)!important;padding:0 var(--RS__pageGutter)!important;margin:0 auto!important;box-sizing:border-box}:root:not([style*=readium-noOverflow-on]) body{overflow:hidden}@supports (overflow: clip){:root:not([style*=readium-noOverflow-on]){overflow:clip}:root:not([style*=readium-noOverflow-on]) body{overflow:clip;overflow-clip-margin:content-box}}:root[style*=readium-scroll-on]{-webkit-columns:auto auto!important;-moz-columns:auto auto!important;columns:auto auto!important;width:auto!important;height:auto!important;max-width:none!important;max-height:none!important;min-width:0!important;min-height:0!important}:root[style*=readium-scroll-on] body{max-width:var(--RS__defaultLineLength)!important;box-sizing:border-box!important}:root[style*=readium-scroll-on]:not([style*=readium-noOverflow-on]) body{overflow:auto}@supports (overflow: clip){:root[style*=readium-scroll-on]:not([style*=readium-noOverflow-on]){overflow:auto}:root[style*=readium-scroll-on]:not([style*=readium-noOverflow-on]) body{overflow:clip}}:root[style*=readium-scroll-on][style*=--RS__scrollPaddingTop] body{padding-top:var(--RS__scrollPaddingTop)!important}:root[style*=readium-scroll-on][style*=--RS__scrollPaddingBottom] body{padding-bottom:var(--RS__scrollPaddingBottom)!important}:root[style*=readium-scroll-on][style*=--RS__scrollPaddingLeft] body{padding-left:var(--RS__scrollPaddingLeft)!important}:root[style*=readium-scroll-on][style*=--RS__scrollPaddingRight] body{padding-right:var(--RS__scrollPaddingRight)!important}:root[style*=--USER__backgroundColor]{background-color:var(--USER__backgroundColor)!important}:root[style*=--USER__backgroundColor] *{background-color:transparent!important}:root[style*=--USER__textColor]{color:var(--USER__textColor)!important}:root[style*=--USER__textColor] *:not(a){color:inherit!important;background-color:transparent!important;border-color:currentcolor!important}:root[style*=--USER__textColor] svg text{fill:currentcolor!important;stroke:none!important}:root[style*=--USER__linkColor] a:link,:root[style*=--USER__linkColor] a:link *{color:var(--USER__linkColor)!important}:root[style*=--USER__visitedColor] a:visited,:root[style*=--USER__visitedColor] a:visited *{color:var(--USER__visitedColor)!important}:root[style*=--USER__selectionBackgroundColor][style*=--USER__selectionTextColor] ::-moz-selection{color:var(--USER__selectionTextColor)!important;background-color:var(--USER__selectionBackgroundColor)!important}:root[style*=--USER__selectionBackgroundColor][style*=--USER__selectionTextColor] ::selection{color:var(--USER__selectionTextColor)!important;background-color:var(--USER__selectionBackgroundColor)!important}:root[style*=--USER__colCount]{-webkit-column-count:var(--USER__colCount);-moz-column-count:var(--USER__colCount);column-count:var(--USER__colCount);--RS__colWidth:auto}:root[style*="--USER__colCount: 0"],:root[style*="--USER__colCount:0"]{-webkit-column-count:1;-moz-column-count:1;column-count:1}:root[style*="--USER__colCount: 0"],:root[style*="--USER__colCount:0"],:root[style*="--USER__colCount: 1"],:root[style*="--USER__colCount:1"]{--RS__colWidth:100vw}:root[style*=--USER__lineLength] body{max-width:var(--USER__lineLength)!important}:root[style*=--USER__textAlign]{text-align:var(--USER__textAlign)}:root[style*=--USER__textAlign] body,:root[style*=--USER__textAlign] p:not([class*=title]):not(blockquote p):not(figcaption p):not(header p):not(hgroup p):not(div:has(+*)>h1+p):not(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-deprecatedFontSize-on]):not([style*=readium-iOSPatch-on])[style*=--USER__fontSize] body{zoom:var(--USER__fontSize)!important}:root:not([style*=readium-deprecatedFontSize-on])[style*=readium-iOSPatch-on][style*=--USER__fontSize] body{-webkit-text-size-adjust:var(--USER__fontSize)!important}@supports selector(figure:has(> img)){:root:not([style*=readium-deprecatedFontSize-on]):not([style*=readium-iOSPatch-on])[style*=--USER__fontSize] figure:has(>img),:root:not([style*=readium-deprecatedFontSize-on]):not([style*=readium-iOSPatch-on])[style*=--USER__fontSize] figure:has(>video),:root:not([style*=readium-deprecatedFontSize-on]):not([style*=readium-iOSPatch-on])[style*=--USER__fontSize] figure:has(>svg),:root:not([style*=readium-deprecatedFontSize-on]):not([style*=readium-iOSPatch-on])[style*=--USER__fontSize] figure:has(>canvas),:root:not([style*=readium-deprecatedFontSize-on]):not([style*=readium-iOSPatch-on])[style*=--USER__fontSize] figure:has(>iframe),:root:not([style*=readium-deprecatedFontSize-on]):not([style*=readium-iOSPatch-on])[style*=--USER__fontSize] figure:has(>audio),:root:not([style*=readium-deprecatedFontSize-on]):not([style*=readium-iOSPatch-on])[style*=--USER__fontSize] div:has(>img),:root:not([style*=readium-deprecatedFontSize-on]):not([style*=readium-iOSPatch-on])[style*=--USER__fontSize] div:has(>video),:root:not([style*=readium-deprecatedFontSize-on]):not([style*=readium-iOSPatch-on])[style*=--USER__fontSize] div:has(>svg),:root:not([style*=readium-deprecatedFontSize-on]):not([style*=readium-iOSPatch-on])[style*=--USER__fontSize] div:has(>canvas),:root:not([style*=readium-deprecatedFontSize-on]):not([style*=readium-iOSPatch-on])[style*=--USER__fontSize] div:has(>iframe),:root:not([style*=readium-deprecatedFontSize-on]):not([style*=readium-iOSPatch-on])[style*=--USER__fontSize] div:has(>audio),:root:not([style*=readium-deprecatedFontSize-on]):not([style*=readium-iOSPatch-on])[style*=--USER__fontSize] table{zoom:calc(100% / var(--USER__fontSize))!important}:root:not([style*=readium-deprecatedFontSize-on]):not([style*=readium-iOSPatch-on])[style*=--USER__fontSize] figcaption,:root:not([style*=readium-deprecatedFontSize-on]):not([style*=readium-iOSPatch-on])[style*=--USER__fontSize] caption,:root:not([style*=readium-deprecatedFontSize-on]):not([style*=readium-iOSPatch-on])[style*=--USER__fontSize] td,:root:not([style*=readium-deprecatedFontSize-on]):not([style*=readium-iOSPatch-on])[style*=--USER__fontSize] th{zoom:var(--USER__fontSize)!important}}@supports not (zoom: 1){:root[style*=--USER__fontSize]{font-size:var(--USER__fontSize)!important}}:root[style*=readium-deprecatedFontSize-on][style*=--USER__fontSize]{font-size:var(--USER__fontSize)!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([class*=title]):not(blockquote p):not(figcaption p):not(header p):not(hgroup p):not(div:has(+*)>h1+p):not(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__ligatures]{font-variant-ligatures:var(--USER__ligatures)!important}:root[style*=--USER__ligatures] *{font-variant-ligatures:inherit!important}: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-blend-on] svg,:root[style*=readium-blend-on] img{background-color:transparent!important;mix-blend-mode:multiply!important}:root[style*=--USER__darkenImages] img{-webkit-filter:brightness(var(--USER__darkenImages))!important;filter:brightness(var(--USER__darkenImages))!important}:root[style*=readium-darken-on] img{-webkit-filter:brightness(80%)!important;filter:brightness(80%)!important}:root[style*=--USER__invertImages] img{-webkit-filter:invert(var(--USER__invertImages))!important;filter:invert(var(--USER__invertImages))!important}:root[style*=readium-invert-on] img{-webkit-filter:invert(100%)!important;filter:invert(100%)!important}:root[style*=--USER__darkenImages][style*=--USER__invertImages] img{-webkit-filter:brightness(var(--USER__darkenImages)) invert(var(--USER__invertImages))!important;filter:brightness(var(--USER__darkenImages)) invert(var(--USER__invertImages))!important}:root[style*=readium-darken-on][style*=--USER__invertImages] img{-webkit-filter:brightness(80%) invert(var(--USER__invertImages))!important;filter:brightness(80%) invert(var(--USER__invertImages))!important}:root[style*=--USER__darkenImages][style*=readium-invert-on] img{-webkit-filter:brightness(var(--USER__darkenImages)) invert(100%)!important;filter:brightness(var(--USER__darkenImages)) invert(100%)!important}:root[style*=readium-darken-on][style*=readium-invert-on] img{-webkit-filter:brightness(80%) invert(100%)!important;filter:brightness(80%) invert(100%)!important}:root[style*=--USER__invertGaiji] img[class*=gaiji]{-webkit-filter:invert(var(--USER__invertGaiji))!important;filter:invert(var(--USER__invertGaiji))!important}:root[style*=readium-invertGaiji-on] img[class*=gaiji]{-webkit-filter:invert(100%)!important;filter:invert(100%)!important}:root[style*=readium-normalize-on]{--USER__typeScale:1.2}:root[style*=readium-normalize-on] p,:root[style*=readium-normalize-on] li,:root[style*=readium-normalize-on] div,:root[style*=readium-normalize-on] pre,:root[style*=readium-normalize-on] dd{font-size:1rem!important}:root[style*=readium-normalize-on] h1{font-size:1.75rem!important;font-size:calc(((1rem * var(--USER__typeScale)) * var(--USER__typeScale)) * var(--USER__typeScale))!important}:root[style*=readium-normalize-on] h2{font-size:1.5rem!important;font-size:calc((1rem * var(--USER__typeScale)) * var(--USER__typeScale))!important}:root[style*=readium-normalize-on] h3{font-size:1.25rem!important;font-size:calc(1rem * var(--USER__typeScale))!important}:root[style*=readium-normalize-on] h4,:root[style*=readium-normalize-on] h5,:root[style*=readium-normalize-on] h6{font-size:1rem!important}:root[style*=readium-normalize-on] small{font-size:smaller!important}:root[style*=readium-normalize-on] sub,:root[style*=readium-normalize-on] sup{font-size:67.5%!important}:root[style*=readium-normalize-on][style*=--USER__typeScale] h1{font-size:calc(((1rem * var(--USER__typeScale)) * var(--USER__typeScale)) * var(--USER__typeScale))!important}:root[style*=readium-normalize-on][style*=--USER__typeScale] h2{font-size:calc((1rem * var(--USER__typeScale)) * var(--USER__typeScale))!important}:root[style*=readium-normalize-on][style*=--USER__typeScale] h3{font-size:calc(1rem * var(--USER__typeScale))!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}`, Fn = `/*!\n * Readium CSS v.2.0.0-beta.22\n * Copyright (c) 2017–2025. Readium Foundation. All rights reserved.\n * Use of this source code is governed by a BSD-style license which is detailed in the\n * LICENSE file present in the project repository where this source code is maintained.\n * Core maintainer: Jiminy Panoz \n * Contributors: \n * Daniel Weck\n * Hadrien Gardeur\n * Innovimax\n * L. Le Meur\n * Mickaël Menu\n * k_taka\n */@namespace url(http://www.w3.org/1999/xhtml);@namespace epub url(http://www.idpf.org/2007/ops);@namespace m url(http://www.w3.org/1998/Math/MathML);@namespace svg url(http://www.w3.org/2000/svg);@-ms-viewport{width:device-width}@viewport{width:device-width;zoom:1}:root{--RS__monospaceTf:ui-monospace, "Andale Mono", "Cascadia Code", "Source Code Pro", Menlo, Consolas, "DejaVu Sans Mono", monospace;--RS__humanistTf:Seravek, Calibri, "Gill Sans Nova", Roboto, Ubuntu, "DejaVu Sans", source-sans-pro, sans-serif;--RS__sansTf:-ui-sans-serif, -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Inter, Roboto, "Helvetica Neue", "Arial Nova", "Liberation Sans", Arial, sans-serif;--RS__modernTf:Athelas, Constantia, Charter, "Bitstream Charter", Cambria, "Georgia Pro", Georgia, serif;--RS__oldStyleTf:"Iowan Old Style", Sitka, "Sitka Text", Palatino, "Book Antiqua", "URW Palladio L", P052, serif;--RS__baseFontFamily:var(--RS__oldStyleTf);--RS__lineHeightCompensation:1;--RS__baseLineHeight:calc(1.5 * var(--RS__lineHeightCompensation));--RS__selectionTextColor:inherit;--RS__selectionBackgroundColor:#b4d8fe;--RS__visitedColor:#551A8B;--RS__linkColor:#0000EE;--RS__textColor:#121212;--RS__backgroundColor:#FFFFFF;color:var(--RS__textColor)!important;background-color:var(--RS__backgroundColor)!important}::-moz-selection{color:var(--RS__selectionTextColor);background-color:var(--RS__selectionBackgroundColor)}::selection{color:var(--RS__selectionTextColor);background-color:var(--RS__selectionBackgroundColor)}html{font-family:var(--RS__baseFontFamily);line-height:1.6;line-height:var(--RS__baseLineHeight);text-rendering:optimizelegibility}h1,h2,h3{line-height:normal}:lang(ja),:lang(zh),:lang(ko){word-wrap:break-word;-webkit-line-break:strict;-epub-line-break:strict;line-break:strict}math{font-family:"Latin Modern Math","STIX Two Math","XITS Math","STIX Math","Libertinus Math","TeX Gyre Termes Math","TeX Gyre Bonum Math",TeX Gyre Schola,"DejaVu Math TeX Gyre","TeX Gyre Pagella Math","Asana Math","Cambria Math","Lucida Bright Math","Minion Math",STIXGeneral,STIXSizeOneSym,Symbol,Times New Roman,serif}:lang(am){--RS__baseFontFamily:kefa, nyala, roboto, noto, "Noto Sans Ethiopic", serif;--RS__lineHeightCompensation:1.167}:lang(ar){--RS__baseFontFamily:"Geeza Pro", "Arabic Typesetting", roboto, noto, "Noto Naskh Arabic", "Times New Roman", serif}:lang(bn){--RS__baseFontFamily:"Kohinoor Bangla", "Bangla Sangam MN", vrinda, roboto, noto, "Noto Sans Bengali", sans-serif;--RS__lineHeightCompensation:1.067}:lang(bo){--RS__baseFontFamily:kailasa, "Microsoft Himalaya", roboto, noto, "Noto Sans Tibetan", sans-serif}:lang(chr){--RS__baseFontFamily:"Plantagenet Cherokee", roboto, noto, "Noto Sans Cherokee";--RS__lineHeightCompensation:1.167}:lang(fa){--RS__baseFontFamily:"Geeza Pro", "Arabic Typesetting", roboto, noto, "Noto Naskh Arabic", "Times New Roman", serif}:lang(gu){--RS__baseFontFamily:"Gujarati Sangam MN", "Nirmala UI", shruti, roboto, noto, "Noto Sans Gujarati", sans-serif;--RS__lineHeightCompensation:1.167}:lang(he){--RS__baseFontFamily:"New Peninim MT", "Arial Hebrew", gisha, "Times New Roman", roboto, noto, "Noto Sans Hebrew" sans-serif;--RS__lineHeightCompensation:1.1}:lang(hi){--RS__baseFontFamily:"Kohinoor Devanagari", "Devanagari Sangam MN", kokila, "Nirmala UI", roboto, noto, "Noto Sans Devanagari", sans-serif;--RS__lineHeightCompensation:1.1}:lang(hy){--RS__baseFontFamily:mshtakan, sylfaen, roboto, noto, "Noto Serif Armenian", serif}:lang(iu){--RS__baseFontFamily:"Euphemia UCAS", euphemia, roboto, noto, "Noto Sans Canadian Aboriginal", sans-serif}:lang(ja){--RS__baseFontFamily:yugothic, "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Meiryo UI", "MS Gothic", roboto, noto, "Noto Sans CJK JP", sans-serif;--RS__lineHeightCompensation:1.167;--RS__serif-ja:"Hiragino Mincho ProN", "Hiragino Mincho Pro", "YuMincho", "BIZ UDPMincho", "Yu Mincho", "MS P明朝", "MS PMincho", serif;--RS__sans-serif-ja:"Hiragino Sans", "Hiragino Kaku Gothic ProN", "Hiragino Kaku Gothic Pro", "ヒラギノ角ゴ W3", "YuGothic", "Yu Gothic Medium", "BIZ UDPGothic", "Yu Gothic", "MS Pゴシック", "MS PGothic", sans-serif;--RS__serif-ja-v:"Hiragino Mincho ProN", "Hiragino Mincho Pro", "YuMincho", "BIZ UDMincho", "Yu Mincho", "MS明朝", "MS Mincho", serif;--RS__sans-serif-ja-v:"Hiragino Sans", "Hiragino Kaku Gothic ProN", "Hiragino Kaku Gothic Pro", "ヒラギノ角ゴ W3", "YuGothic", "Yu Gothic Medium", "BIZ UDGothic", "Yu Gothic", "MSゴシック", "MS Gothic", sans-serif}:lang(km){--RS__baseFontFamily:"Khmer Sangam MN", "Leelawadee UI", "Khmer UI", roboto, noto, "Noto Sans Khmer", sans-serif;--RS__lineHeightCompensation:1.067}:lang(kn){--RS__baseFontFamily:"Kannada Sangam MN", "Nirmala UI", tunga, roboto, noto, "Noto Sans Kannada", sans-serif;--RS__lineHeightCompensation:1.1}:lang(ko){--RS__baseFontFamily:"Nanum Gothic", "Apple SD Gothic Neo", "Malgun Gothic", roboto, noto, "Noto Sans CJK KR", sans-serif;--RS__lineHeightCompensation:1.167}:lang(lo){--RS__baseFontFamily:"Lao Sangam MN", "Leelawadee UI", "Lao UI", roboto, noto, "Noto Sans Lao", sans-serif}:lang(ml){--RS__baseFontFamily:"Malayalam Sangam MN", "Nirmala UI", kartika, roboto, noto, "Noto Sans Malayalam", sans-serif;--RS__lineHeightCompensation:1.067}:lang(or){--RS__baseFontFamily:"Oriya Sangam MN", "Nirmala UI", kalinga, roboto, noto, "Noto Sans Oriya", sans-serif;--RS__lineHeightCompensation:1.167}:lang(pa){--RS__baseFontFamily:"Gurmukhi MN", "Nirmala UI", kartika, roboto, noto, "Noto Sans Gurmukhi", sans-serif;--RS__lineHeightCompensation:1.1}:lang(si){--RS__baseFontFamily:"Sinhala Sangam MN", "Nirmala UI", "Iskoola Pota", roboto, noto, "Noto Sans Sinhala", sans-serif;--RS__lineHeightCompensation:1.167}:lang(ta){--RS__baseFontFamily:"Tamil Sangam MN", "Nirmala UI", latha, roboto, noto, "Noto Sans Tamil", sans-serif;--RS__lineHeightCompensation:1.067}:lang(te){--RS__baseFontFamily:"Kohinoor Telugu", "Telugu Sangam MN", "Nirmala UI", gautami, roboto, noto, "Noto Sans Telugu", sans-serif}:lang(th){--RS__baseFontFamily:"Thonburi", "Leelawadee UI", "Cordia New", roboto, noto, "Noto Sans Thai", sans-serif;--RS__lineHeightCompensation:1.067}:lang(zh){--RS__baseFontFamily:"方体", "PingFang SC", "黑体", "Heiti SC", "Microsoft JhengHei UI", "Microsoft JhengHei", roboto, noto, "Noto Sans CJK SC", sans-serif;--RS__lineHeightCompensation:1.167}:lang(zh-Hant),:lang(zh-TW){--RS__baseFontFamily:"方體", "PingFang TC", "黑體", "Heiti TC", "Microsoft JhengHei UI", "Microsoft JhengHei", roboto, noto, "Noto Sans CJK TC", sans-serif;--RS__lineHeightCompensation:1.167}:lang(zh-HK){--RS__baseFontFamily:"方體", "PingFang HK", "方體", "PingFang TC", "黑體", "Heiti TC", "Microsoft JhengHei UI", "Microsoft JhengHei", roboto, noto, "Noto Sans CJK TC", sans-serif;--RS__lineHeightCompensation:1.167}@font-face{font-family:AccessibleDfA;font-style:normal;font-weight:400;src:local("AccessibleDfA"),url(./assets/AccessibleDfA-Regular.woff2) format("woff2"),url(./assets/AccessibleDfA-Regular.woff) format("woff")}@font-face{font-family:AccessibleDfA;font-style:normal;font-weight:700;src:local("AccessibleDfA"),url(./assets/AccessibleDfA-Bold.woff2) format("woff2")}@font-face{font-family:AccessibleDfA;font-style:italic;font-weight:400;src:local("AccessibleDfA"),url(./assets/AccessibleDfA-Italic.woff2) format("woff2")}@font-face{font-family:IA Writer Duospace;font-style:normal;font-weight:400;src:local("iAWriterDuospace-Regular"),url(./assets/iAWriterDuospace-Regular.ttf) format("truetype")}body{widows:2;orphans:2}figcaption,th,td{widows:1;orphans:1}h2,h3,h4,h5,h6,dt,hr,caption{-webkit-column-break-after:avoid;page-break-after:avoid;break-after:avoid}h1,h2,h3,h4,h5,h6,dt,figure,tr{-webkit-column-break-inside:avoid;page-break-inside:avoid;break-inside:avoid}body{-webkit-hyphenate-character:"-";-moz-hyphenate-character:"-";-ms-hyphenate-character:"-";hyphenate-character:"-";-webkit-hyphenate-limit-lines:3;-ms-hyphenate-limit-lines:3;hyphenate-limit-lines:3}h1,h2,h3,h4,h5,h6,dt,figcaption,pre,caption,address,center,code,var{-ms-hyphens:none;-moz-hyphens:none;-webkit-hyphens:none;-epub-hyphens:none;hyphens:none}body{font-variant-numeric:oldstyle-nums proportional-nums}:lang(ja) body,:lang(zh) body,:lang(ko) body{font-variant-numeric:lining-nums proportional-nums}h1,h2,h3,h4,h5,h6,dt{font-variant-numeric:lining-nums proportional-nums}table{font-variant-numeric:lining-nums tabular-nums}code,var{font-variant-ligatures:none;font-variant-numeric:lining-nums tabular-nums slashed-zero}rt{font-variant-east-asian:ruby}:lang(ar){font-variant-ligatures:common-ligatures}:lang(ko){font-kerning:normal}hr{color:inherit;border-color:currentcolor}table,th,td{border-color:currentcolor}figure,blockquote{margin:1em 5%}ul,ol{padding-left:5%}dd{margin-left:5%}pre{white-space:pre-wrap;-ms-tab-size:2;-moz-tab-size:2;-webkit-tab-size:2;tab-size:2}abbr[title],acronym[title]{text-decoration:dotted underline}nobr wbr{white-space:normal}ruby>rt,ruby>rp{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}*:lang(ja):not(:lang(ja-Latn)):not(:lang(ja-Cyrl)),*:lang(zh):not(:lang(zh-Latn)):not(:lang(zh-Cyrl)),*:lang(ko):not(:lang(ko-Latn)):not(:lang(ko-Cyrl)),:lang(ja):not(:lang(ja-Latn)):not(:lang(ja-Cyrl)) cite,:lang(ja):not(:lang(ja-Latn)):not(:lang(ja-Cyrl)) dfn,:lang(ja):not(:lang(ja-Latn)):not(:lang(ja-Cyrl)) em,:lang(ja):not(:lang(ja-Latn)):not(:lang(ja-Cyrl)) i,:lang(zh):not(:lang(zh-Latn)):not(:lang(zh-Cyrl)) cite,:lang(zh):not(:lang(zh-Latn)):not(:lang(zh-Cyrl)) dfn,:lang(zh):not(:lang(zh-Latn)):not(:lang(zh-Cyrl)) em,:lang(zh):not(:lang(zh-Latn)):not(:lang(zh-Cyrl)) i,:lang(ko):not(:lang(ko-Latn)):not(:lang(ko-Cyrl)) cite,:lang(ko):not(:lang(ko-Latn)):not(:lang(ko-Cyrl)) dfn,:lang(ko):not(:lang(ko-Latn)):not(:lang(ko-Cyrl)) em,:lang(ko):not(:lang(ko-Latn)):not(:lang(ko-Cyrl)) i{font-style:normal}:lang(ja) a,:lang(zh) a,:lang(ko) a{text-decoration:none}:root{--RS__maxMediaWidth:100%;--RS__maxMediaHeight:95vh;--RS__boxSizingMedia:border-box;--RS__boxSizingTable:border-box}a,a span,span a,h1,h2,h3,h4,h5,h6{word-wrap:break-word}div{max-width:var(--RS__maxMediaWidth)}img,svg|svg,video{object-fit:contain;width:auto;height:auto;max-width:var(--RS__maxMediaWidth);max-height:var(--RS__maxMediaHeight)!important;box-sizing:var(--RS__boxSizingMedia);-webkit-column-break-inside:avoid;page-break-inside:avoid;break-inside:avoid}audio{max-width:100%;-webkit-column-break-inside:avoid;page-break-inside:avoid;break-inside:avoid}table{max-width:var(--RS__maxMediaWidth);box-sizing:var(--RS__boxSizingTable)}`, Un = `/*!\n * Readium CSS v.2.0.0-beta.22\n * Copyright (c) 2017–2025. Readium Foundation. All rights reserved.\n * Use of this source code is governed by a BSD-style license which is detailed in the\n * LICENSE file present in the project repository where this source code is maintained.\n * Core maintainer: Jiminy Panoz \n * Contributors: \n * Daniel Weck\n * Hadrien Gardeur\n * Innovimax\n * L. Le Meur\n * Mickaël Menu\n * k_taka\n */@namespace url(http://www.w3.org/1999/xhtml);@namespace epub url(http://www.idpf.org/2007/ops);@namespace m url(http://www.w3.org/1998/Math/MathML);@namespace svg url(http://www.w3.org/2000/svg);:root{--RS__compFontFamily:var(--RS__baseFontFamily);--RS__codeFontFamily:var(--RS__monospaceTf);--RS__typeScale:1.125;--RS__baseFontSize:100%;--RS__flowSpacing:1.5rem;--RS__paraSpacing:0;--RS__paraIndent:1em;--RS__linkColor:#0000EE;--RS__visitedColor:#551A8B;--RS__primaryColor:;--RS__secondaryColor:}body{font-size:var(--RS__baseFontSize)}h1,h2,h3,h4,h5,h6{font-family:var(--RS__compFontFamily)}blockquote,figure,p,pre,aside,footer,form,hr{margin-top:var(--RS__flowSpacing);margin-bottom:var(--RS__flowSpacing)}p{margin-top:var(--RS__paraSpacing);margin-bottom:var(--RS__paraSpacing);text-indent:var(--RS__paraIndent)}h1+p,h2+p,h3+p,h4+p,h5+p,h6+p,hr+p{text-indent:0}pre{font-family:var(--RS__codeFontFamily)}code,kbd,samp,tt{font-family:var(--RS__codeFontFamily)}sub,sup{position:relative;font-size:67.5%;line-height:1}sub{bottom:-.2ex}sup{bottom:0}:link{color:var(--RS__linkColor)}:visited{color:var(--RS__visitedColor)}h1{margin-top:calc(var(--RS__flowSpacing) * 2);margin-bottom:calc(var(--RS__flowSpacing) * 2);font-size:calc(((1em * var(--RS__typeScale)) * var(--RS__typeScale)) * var(--RS__typeScale))}h2{margin-top:calc(var(--RS__flowSpacing) * 2);margin-bottom:var(--RS__flowSpacing);font-size:calc((1em * var(--RS__typeScale)) * var(--RS__typeScale))}h3{margin-top:var(--RS__flowSpacing);margin-bottom:var(--RS__flowSpacing);font-size:calc(1em * var(--RS__typeScale))}h4{margin-top:var(--RS__flowSpacing);margin-bottom:var(--RS__flowSpacing);font-size:1em}h5{margin-top:var(--RS__flowSpacing);margin-bottom:var(--RS__flowSpacing);font-size:1em;font-variant:small-caps}h6{margin-top:var(--RS__flowSpacing);margin-bottom:0;font-size:1em;text-transform:lowercase;font-variant:small-caps}dl,ol,ul{margin-top:var(--RS__flowSpacing);margin-bottom:var(--RS__flowSpacing)}table{margin:var(--RS__flowSpacing) 0;border:1px solid currentcolor;border-collapse:collapse;empty-cells:show}thead,tbody,tfoot,table>tr{vertical-align:top}th{text-align:left}th,td{padding:4px;border:1px solid currentcolor}`, _ = (r, t) => URL.createObjectURL(new Blob([r], { type: t })), qi = (r) => r.replace(/\\/\\/.*/g, "").replace(/\\/\\*[\\s\\S]*?\\*\\//g, "").replace(/\\n/g, "").replace(/\\s+/g, " "), _t = (r) => r.replace(/\\/\\*(?:(?!\\*\\/)[\\s\\S])*\\*\\/|[\\r\\n\\t]+/g, "").replace(/ {2,}/g, " ").replace(/url\\((?!(https?:)?\\/\\/)("?)\\/([^\\)]+)/g, `url($2${window.location.origin}/$3`), Se = (r, t) => {\n const e = r.createElement("script");\n return e.dataset.readium = "true", e.src = t.startsWith("blob:") ? t : _(t, "text/javascript"), e;\n}, $t = (r, t) => {\n const e = r.createElement("link");\n return e.dataset.readium = "true", e.rel = "stylesheet", e.type = "text/css", e.href = t.startsWith("blob:") ? t : _(t, "text/css"), e;\n}, te = /* @__PURE__ */ new Map(), gt = (r, t) => {\n if (te.has(r)) return te.get(r);\n const e = t();\n return te.set(r, e), e;\n}, Rn = (r) => Se(r, gt("css-selector-generator", () => _(\n \'!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,combineBetweenSelectors:!0,root:null,maxCombinations:Number.POSITIVE_INFINITY,maxCandidates:Number.POSITIVE_INFINITY};function u(t){return t instanceof RegExp}function s(t){return["string","function"].includes(typeof t)||u(t)}function l(t){return Array.isArray(t)?t.filter(s):[]}function a(t){const e=[Node.DOCUMENT_NODE,Node.DOCUMENT_FRAGMENT_NODE,Node.ELEMENT_NODE];return function(t){return t instanceof Node}(t)&&e.includes(t.nodeType)}function f(t,e){if(a(t))return t.contains(e)||i("element root mismatch","Provided root does not contain the element. This will most likely result in producing a fallback selector using element\\\'s real root node. If you plan to use the selector using provided root (e.g. `root.querySelector`), it will nto work as intended."),t;const n=e.getRootNode({composed:!1});return a(n)?(n!==document&&i("shadow root inferred","You did not provide a root and the element is a child of Shadow DOM. This will produce a selector using ShadowRoot as a root. If you plan to use the selector using document as a root (e.g. `document.querySelector`), it will not work as intended."),n):e.ownerDocument.querySelector(":root")}function d(t){return"number"==typeof t?t:Number.POSITIVE_INFINITY}function m(t=[]){const[e=[],...n]=t;return 0===n.length?e:n.reduce(((t,e)=>t.filter((t=>e.includes(t)))),e)}function p(t){return[].concat(...t)}function h(t){const e=t.map((t=>{if(u(t))return e=>t.test(e);if("function"==typeof t)return e=>{const n=t(e);return"boolean"!=typeof n?(i("pattern matcher function invalid","Provided pattern matching function does not return boolean. It\\\'s result will be ignored.",t),!1):n};if("string"==typeof t){const e=new RegExp("^"+t.replace(/[|\\\\\\\\{}()[\\\\]^$+?.]/g,"\\\\\\\\$&").replace(/\\\\*/g,".+")+"$");return t=>e.test(t)}return i("pattern matcher invalid","Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.",t),()=>!1}));return t=>e.some((e=>e(t)))}function g(t,e,n){const o=Array.from(f(n,t[0]).querySelectorAll(e));return o.length===t.length&&t.every((t=>o.includes(t)))}function y(t,e){e=null!=e?e:function(t){return t.ownerDocument.querySelector(":root")}(t);const n=[];let o=t;for(;r(o)&&o!==e;)n.push(o),o=o.parentElement;return n}function b(t,e){return m(t.map((t=>y(t,e))))}const N={[t.NONE]:{type:t.NONE,value:""},[t.DESCENDANT]:{type:t.DESCENDANT,value:" > "},[t.CHILD]:{type:t.CHILD,value:" "}},S=new RegExp(["^$","\\\\\\\\s"].join("|")),E=new RegExp(["^$"].join("|")),w=[e.nthoftype,e.tag,e.id,e.class,e.attribute,e.nthchild],v=h(["class","id","ng-*"]);function C({nodeName:t}){return`[${t}]`}function O({nodeName:t,nodeValue:e}){return`[${t}=\\\'${L(e)}\\\']`}function T(t){const e=Array.from(t.attributes).filter((e=>function({nodeName:t},e){const n=e.tagName.toLowerCase();return!(["input","option"].includes(n)&&"value"===t||v(t))}(e,t)));return[...e.map(C),...e.map(O)]}function I(t){return(t.getAttribute("class")||"").trim().split(/\\\\s+/).filter((t=>!E.test(t))).map((t=>`.${L(t)}`))}function x(t){const e=t.getAttribute("id")||"",n=`#${L(e)}`,o=t.getRootNode({composed:!1});return!S.test(e)&&g([t],n,o)?[n]:[]}function j(t){const e=t.parentNode;if(e){const n=Array.from(e.childNodes).filter(r).indexOf(t);if(n>-1)return[`:nth-child(${n+1})`]}return[]}function A(t){return[L(t.tagName.toLowerCase())]}function D(t){const e=[...new Set(p(t.map(A)))];return 0===e.length||e.length>1?[]:[e[0]]}function $(t){const e=D([t])[0],n=t.parentElement;if(n){const o=Array.from(n.children).filter((t=>t.tagName.toLowerCase()===e)),r=o.indexOf(t);if(r>-1)return[`${e}:nth-of-type(${r+1})`]}return[]}function R(t=[],{maxResults:e=Number.POSITIVE_INFINITY}={}){const n=[];let o=0,r=k(1);for(;r.length<=t.length&&ot[e]))),r=P(r,t.length-1);return n}function P(t=[],e=0){const n=t.length;if(0===n)return[];const o=[...t];o[n-1]+=1;for(let t=n-1;t>=0;t--)if(o[t]>e){if(0===t)return k(n+1);o[t-1]++,o[t]=o[t-1]+1}return o[n-1]>e?k(n+1):o}function k(t=1){return Array.from(Array(t).keys())}const _=":".charCodeAt(0).toString(16).toUpperCase(),M=/[ !"#$%&\\\'()\\\\[\\\\]{|}<>*+,./;=?@^`~\\\\\\\\]/;function L(t=""){var e,n;return null!==(n=null===(e=null===CSS||void 0===CSS?void 0:CSS.escape)||void 0===e?void 0:e.call(CSS,t))&&void 0!==n?n:function(t=""){return t.split("").map((t=>":"===t?`\\\\\\\\${_} `:M.test(t)?`\\\\\\\\${t}`:escape(t).replace(/%/g,"\\\\\\\\"))).join("")}(t)}const q={tag:D,id:function(t){return 0===t.length||t.length>1?[]:x(t[0])},class:function(t){return m(t.map(I))},attribute:function(t){return m(t.map(T))},nthchild:function(t){return m(t.map(j))},nthoftype:function(t){return m(t.map($))}},F={tag:A,id:x,class:I,attribute:T,nthchild:j,nthoftype:$};function V(t){return t.includes(e.tag)||t.includes(e.nthoftype)?[...t]:[...t,e.tag]}function Y(t={}){const n=[...w];return t[e.tag]&&t[e.nthoftype]&&n.splice(n.indexOf(e.tag),1),n.map((e=>{return(o=t)[n=e]?o[n].join(""):"";var n,o})).join("")}function B(t,e,n="",o){const r=function(t,e){return""===e?t:function(t,e){return[...t.map((t=>e+" "+t)),...t.map((t=>e+" > "+t))]}(t,e)}(function(t,e,n){const o=function(t,e){const{blacklist:n,whitelist:o,combineWithinSelector:r,maxCombinations:i}=e,c=h(n),u=h(o);return function(t){const{selectors:e,includeTag:n}=t,o=[].concat(e);return n&&!o.includes("tag")&&o.push("tag"),o}(e).reduce(((e,n)=>{const o=function(t,e){var n;return(null!==(n=q[e])&&void 0!==n?n:()=>[])(t)}(t,n),s=function(t=[],e,n){return t.filter((t=>n(t)||!e(t)))}(o,c,u),l=function(t=[],e){return t.sort(((t,n)=>{const o=e(t),r=e(n);return o&&!r?-1:!o&&r?1:0}))}(s,u);return e[n]=r?R(l,{maxResults:i}):l.map((t=>[t])),e}),{})}(t,n),r=function(t,e){return function(t){const{selectors:e,combineBetweenSelectors:n,includeTag:o,maxCandidates:r}=t,i=n?R(e,{maxResults:r}):e.map((t=>[t]));return o?i.map(V):i}(e).map((e=>function(t,e){const n={};return t.forEach((t=>{const o=e[t];o.length>0&&(n[t]=o)})),function(t={}){let e=[];return Object.entries(t).forEach((([t,n])=>{e=n.flatMap((n=>0===e.length?[{[t]:n}]:e.map((e=>Object.assign(Object.assign({},e),{[t]:n})))))})),e}(n).map(Y)}(e,t))).filter((t=>t.length>0))}(o,n),i=p(r);return[...new Set(i)]}(t,o.root,o),n);for(const e of r)if(g(t,e,o.root))return e;return null}function G(t){return{value:t,include:!1}}function W({selectors:t,operator:n}){let o=[...w];t[e.tag]&&t[e.nthoftype]&&(o=o.filter((t=>t!==e.tag)));let r="";return o.forEach((e=>{(t[e]||[]).forEach((({value:t,include:e})=>{e&&(r+=t)}))})),n.value+r}function H(n){return[":root",...y(n).reverse().map((n=>{const o=function(e,n,o=t.NONE){const r={};return n.forEach((t=>{Reflect.set(r,t,function(t,e){return F[e](t)}(e,t).map(G))})),{element:e,operator:N[o],selectors:r}}(n,[e.nthchild],t.DESCENDANT);return o.selectors.nthchild.forEach((t=>{t.include=!0})),o})).map(W)].join("")}function U(t,n={}){const o=function(t){const e=(Array.isArray(t)?t:[t]).filter(r);return[...new Set(e)]}(t),i=function(t,n={}){const o=Object.assign(Object.assign({},c),n);return{selectors:(r=o.selectors,Array.isArray(r)?r.filter((t=>{return n=e,o=t,Object.values(n).includes(o);var n,o})):[]),whitelist:l(o.whitelist),blacklist:l(o.blacklist),root:f(o.root,t),combineWithinSelector:!!o.combineWithinSelector,combineBetweenSelectors:!!o.combineBetweenSelectors,includeTag:!!o.includeTag,maxCombinations:d(o.maxCombinations),maxCandidates:d(o.maxCandidates)};var r}(o[0],n);let u="",s=i.root;function a(){return function(t,e,n="",o){if(0===t.length)return null;const r=[t.length>1?t:[],...b(t,e).map((t=>[t]))];for(const t of r){const e=B(t,0,n,o);if(e)return{foundElements:t,selector:e}}return null}(o,s,u,i)}let m=a();for(;m;){const{foundElements:t,selector:e}=m;if(g(o,e,i.root))return e;s=t[0],u=e,m=a()}return o.length>1?o.map((t=>U(t,i))).join(", "):function(t){return t.map(H).join(", ")}(o)}const z=U;return o})()));\',\n "text/javascript"\n))), Cn = (r) => Se(r, gt("JS-Before", () => _(qi(\n `\n window._readium_blockedEvents = [];\n window._readium_blockEvents = true;\n window._readium_eventBlocker = (e) => {\n if(!window._readium_blockEvents) return;\n e.preventDefault();\n e.stopImmediatePropagation();\n _readium_blockedEvents.push([\n 1, e, e.currentTarget || e.target\n ]);\n };\n window.addEventListener("DOMContentLoaded", window._readium_eventBlocker, true);\n window.addEventListener("load", window._readium_eventBlocker, true);`\n), "text/javascript"))), Sn = (r) => Se(r, gt("JS-After", () => _(qi(\n `\n if(window.onload) window.onload = new Proxy(window.onload, {\n apply: function(target, receiver, args) {\n if(!window._readium_blockEvents) {\n Reflect.apply(target, receiver, args);\n return;\n }\n _readium_blockedEvents.push([\n 0, target, receiver, args\n ]);\n }\n });`\n), "text/javascript")));\nclass _i {\n constructor(t, e, i, A) {\n this.pub = t, this.item = i, this.burl = i.toURL(e) || "", this.cssProperties = A;\n }\n async build(t = !1) {\n if (this.item.mediaType.isHTML)\n return await this.buildHtmlFrame(t);\n if (this.item.mediaType.isBitmap)\n return this.buildImageFrame();\n throw Error("Unsupported frame mediatype " + this.item.mediaType.string);\n }\n async buildHtmlFrame(t = !1) {\n const e = await this.pub.get(this.item).readAsString();\n if (!e) throw new Error(`Failed reading item ${this.item.href}`);\n const i = new DOMParser().parseFromString(\n e,\n this.item.mediaType.string\n ), A = i.querySelector("parsererror");\n if (A) {\n const n = A.querySelector("div");\n throw new Error(`Failed parsing item ${this.item.href}: ${n?.textContent || A.textContent}`);\n }\n return this.finalizeDOM(i, this.burl, this.item.mediaType, t, this.cssProperties);\n }\n buildImageFrame() {\n const t = document.implementation.createHTMLDocument(this.item.title || this.item.href), e = document.createElement("img");\n return e.src = this.burl || "", e.alt = this.item.title || "", e.decoding = "async", t.body.appendChild(e), this.finalizeDOM(t, this.burl, this.item.mediaType, !0);\n }\n // Has JS that may have side-effects when the document is loaded, without any user interaction\n hasExecutable(t) {\n return !!t.querySelector("script") || // Any