@readium/navigator 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +28 -0
- package/README.MD +11 -0
- package/dist/assets/AccessibleDfA.otf +0 -0
- package/dist/assets/iAWriterDuospace-Regular.ttf +0 -0
- package/dist/index.js +6263 -0
- package/dist/index.umd.cjs +107 -0
- package/package.json +65 -0
- package/src/Navigator.ts +66 -0
- package/src/audio/engine/AudioEngine.ts +136 -0
- package/src/audio/engine/WebAudioEngine.ts +286 -0
- package/src/audio/engine/index.ts +2 -0
- package/src/audio/index.ts +1 -0
- package/src/epub/EpubNavigator.ts +507 -0
- package/src/epub/frame/FrameBlobBuilder.ts +211 -0
- package/src/epub/frame/FrameComms.ts +142 -0
- package/src/epub/frame/FrameManager.ts +134 -0
- package/src/epub/frame/FramePoolManager.ts +179 -0
- package/src/epub/frame/index.ts +3 -0
- package/src/epub/fxl/FXLCoordinator.ts +152 -0
- package/src/epub/fxl/FXLFrameManager.ts +286 -0
- package/src/epub/fxl/FXLFramePoolManager.ts +632 -0
- package/src/epub/fxl/FXLPeripherals.ts +587 -0
- package/src/epub/fxl/FXLPeripheralsDebug.ts +46 -0
- package/src/epub/fxl/FXLSpreader.ts +95 -0
- package/src/epub/fxl/index.ts +5 -0
- package/src/epub/index.ts +3 -0
- package/src/helpers/sML.ts +120 -0
- package/src/index.ts +3 -0
- package/types/src/Navigator.d.ts +41 -0
- package/types/src/audio/engine/AudioEngine.d.ts +114 -0
- package/types/src/audio/engine/WebAudioEngine.d.ts +107 -0
- package/types/src/audio/engine/index.d.ts +2 -0
- package/types/src/audio/index.d.ts +1 -0
- package/types/src/epub/EpubNavigator.d.ts +66 -0
- package/types/src/epub/frame/FrameBlobBuilder.d.ts +13 -0
- package/types/src/epub/frame/FrameComms.d.ts +26 -0
- package/types/src/epub/frame/FrameManager.d.ts +21 -0
- package/types/src/epub/frame/FramePoolManager.d.ts +17 -0
- package/types/src/epub/frame/index.d.ts +3 -0
- package/types/src/epub/fxl/FXLCoordinator.d.ts +37 -0
- package/types/src/epub/fxl/FXLFrameManager.d.ts +41 -0
- package/types/src/epub/fxl/FXLFramePoolManager.d.ts +93 -0
- package/types/src/epub/fxl/FXLPeripherals.d.ts +97 -0
- package/types/src/epub/fxl/FXLPeripheralsDebug.d.ts +13 -0
- package/types/src/epub/fxl/FXLSpreader.d.ts +12 -0
- package/types/src/epub/fxl/index.d.ts +5 -0
- package/types/src/epub/index.d.ts +3 -0
- package/types/src/helpers/sML.d.ts +51 -0
- package/types/src/index.d.ts +3 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
(function(v,S){typeof exports=="object"&&typeof module<"u"?S(exports):typeof define=="function"&&define.amd?define(["exports"],S):(v=typeof globalThis<"u"?globalThis:v||self,S(v.navigator={}))})(this,function(v){"use strict";class S{constructor(A){this.algorithm=A.algorithm,this.compression=A.compression,this.originalLength=A.originalLength,this.profile=A.profile,this.scheme=A.scheme}static deserialize(A){if(A&&A.algorithm)return new S({algorithm:A.algorithm,compression:A.compression,originalLength:A.originalLength,profile:A.profile,scheme:A.scheme})}serialize(){const A={algorithm:this.algorithm};return this.compression!==void 0&&(A.compression=this.compression),this.originalLength!==void 0&&(A.originalLength=this.originalLength),this.profile!==void 0&&(A.profile=this.profile),this.scheme!==void 0&&(A.scheme=this.scheme),A}}class Y{constructor(A){this.otherProperties=A}static deserialize(A){if(A)return new Y(A)}serialize(){return this.otherProperties}add(A){const t=Object.assign({},this.otherProperties);for(const i in A)t[i]=A[i];return new Y(t)}}Object.defineProperty(Y.prototype,"encryption",{get:function(){return S.deserialize(this.otherProperties.encrypted)}});var C=(e=>(e.fixed="fixed",e.reflowable="reflowable",e))(C||{}),J=(e=>(e.auto="auto",e.landscape="landscape",e.portrait="portrait",e))(J||{}),G=(e=>(e.left="left",e.right="right",e.center="center",e))(G||{}),MA=(e=>(e.auto="auto",e.both="both",e.none="none",e.landscape="landscape",e))(MA||{});Y.prototype.getContains=function(){return new Set(this.otherProperties.contains||[])},Y.prototype.getLayout=function(){return this.otherProperties.layout};class w{constructor(A){let t,i,o=A.mediaType.replace(/\s/g,"").split(";");const s=o[0].split("/");if(s.length===2){if(t=s[0].toLowerCase().trim(),i=s[1].toLowerCase().trim(),t.length===0||i.length===0)throw new Error("Invalid media type")}else throw new Error("Invalid media type");const r={};for(let g=1;g<o.length;g++){const I=o[g].split("=");if(I.length===2){const d=I[0].toLocaleLowerCase(),l=d==="charset"?I[1].toUpperCase():I[1];r[d]=l}}const n={},a=Object.keys(r);a.sort((g,I)=>g.localeCompare(I)),a.forEach(g=>n[g]=r[g]);let c="";for(const g in n){const I=n[g];c+=`;${g}=${I}`}const B=`${t}/${i}${c}`,h=n.encoding;this.string=B,this.type=t,this.subtype=i,this.parameters=n,this.encoding=h,this.name=A.name,this.fileExtension=A.fileExtension}static parse(A){return new w(A)}get structuredSyntaxSuffix(){const A=this.subtype.split("+");return A.length>1?`+${A[A.length-1]}`:void 0}get charset(){return this.parameters.charset}contains(A){const t=typeof A=="string"?w.parse({mediaType:A}):A;if(!((this.type==="*"||this.type===t.type)&&(this.subtype==="*"||this.subtype===t.subtype)))return!1;const i=new Set(Object.entries(this.parameters).map(([s,r])=>`${s}=${r}`)),o=new Set(Object.entries(t.parameters).map(([s,r])=>`${s}=${r}`));for(const s of Array.from(i.values()))if(!o.has(s))return!1;return!0}matches(A){const t=typeof A=="string"?w.parse({mediaType:A}):A;return this.contains(t)||t.contains(this)}matchesAny(...A){for(const t of A)if(this.matches(t))return!0;return!1}equals(A){return this.string===A.string}get isZIP(){return this.matchesAny(w.ZIP,w.LCP_PROTECTED_AUDIOBOOK,w.LCP_PROTECTED_PDF)||this.structuredSyntaxSuffix==="+zip"}get isJSON(){return this.matchesAny(w.JSON)||this.structuredSyntaxSuffix==="+json"}get isOPDS(){return this.matchesAny(w.OPDS1,w.OPDS1_ENTRY,w.OPDS2,w.OPDS2_PUBLICATION,w.OPDS_AUTHENTICATION)||this.structuredSyntaxSuffix==="+json"}get isHTML(){return this.matchesAny(w.HTML,w.XHTML)}get isBitmap(){return this.matchesAny(w.BMP,w.GIF,w.JPEG,w.PNG,w.TIFF,w.WEBP)}get isAudio(){return this.type==="audio"}get isVideo(){return this.type==="video"}get isRWPM(){return this.matchesAny(w.READIUM_AUDIOBOOK_MANIFEST,w.DIVINA_MANIFEST,w.READIUM_WEBPUB_MANIFEST)}get isPublication(){return this.matchesAny(w.READIUM_AUDIOBOOK,w.READIUM_AUDIOBOOK_MANIFEST,w.CBZ,w.DIVINA,w.DIVINA_MANIFEST,w.EPUB,w.LCP_PROTECTED_AUDIOBOOK,w.LCP_PROTECTED_PDF,w.LPF,w.PDF,w.W3C_WPUB_MANIFEST,w.READIUM_WEBPUB,w.READIUM_WEBPUB_MANIFEST,w.ZAB)}static get AAC(){return w.parse({mediaType:"audio/aac",fileExtension:"aac"})}static get ACSM(){return w.parse({mediaType:"application/vnd.adobe.adept+xml",name:"Adobe Content Server Message",fileExtension:"acsm"})}static get AIFF(){return w.parse({mediaType:"audio/aiff",fileExtension:"aiff"})}static get AVI(){return w.parse({mediaType:"video/x-msvideo",fileExtension:"avi"})}static get BINARY(){return w.parse({mediaType:"application/octet-stream"})}static get BMP(){return w.parse({mediaType:"image/bmp",fileExtension:"bmp"})}static get CBZ(){return w.parse({mediaType:"application/vnd.comicbook+zip",name:"Comic Book Archive",fileExtension:"cbz"})}static get CSS(){return w.parse({mediaType:"text/css",fileExtension:"css"})}static get DIVINA(){return w.parse({mediaType:"application/divina+zip",name:"Digital Visual Narratives",fileExtension:"divina"})}static get DIVINA_MANIFEST(){return w.parse({mediaType:"application/divina+json",name:"Digital Visual Narratives",fileExtension:"json"})}static get EPUB(){return w.parse({mediaType:"application/epub+zip",name:"EPUB",fileExtension:"epub"})}static get GIF(){return w.parse({mediaType:"image/gif",fileExtension:"gif"})}static get GZ(){return w.parse({mediaType:"application/gzip",fileExtension:"gz"})}static get HTML(){return w.parse({mediaType:"text/html",fileExtension:"html"})}static get JAVASCRIPT(){return w.parse({mediaType:"text/javascript",fileExtension:"js"})}static get JPEG(){return w.parse({mediaType:"image/jpeg",fileExtension:"jpeg"})}static get JSON(){return w.parse({mediaType:"application/json"})}static get LCP_LICENSE_DOCUMENT(){return w.parse({mediaType:"application/vnd.readium.lcp.license.v1.0+json",name:"LCP License",fileExtension:"lcpl"})}static get LCP_PROTECTED_AUDIOBOOK(){return w.parse({mediaType:"application/audiobook+lcp",name:"LCP Protected Audiobook",fileExtension:"lcpa"})}static get LCP_PROTECTED_PDF(){return w.parse({mediaType:"application/pdf+lcp",name:"LCP Protected PDF",fileExtension:"lcpdf"})}static get LCP_STATUS_DOCUMENT(){return w.parse({mediaType:"application/vnd.readium.license.status.v1.0+json"})}static get LPF(){return w.parse({mediaType:"application/lpf+zip",fileExtension:"lpf"})}static get MP3(){return w.parse({mediaType:"audio/mpeg",fileExtension:"mp3"})}static get MPEG(){return w.parse({mediaType:"video/mpeg",fileExtension:"mpeg"})}static get NCX(){return w.parse({mediaType:"application/x-dtbncx+xml",fileExtension:"ncx"})}static get OGG(){return w.parse({mediaType:"audio/ogg",fileExtension:"oga"})}static get OGV(){return w.parse({mediaType:"video/ogg",fileExtension:"ogv"})}static get OPDS1(){return w.parse({mediaType:"application/atom+xml;profile=opds-catalog"})}static get OPDS1_ENTRY(){return w.parse({mediaType:"application/atom+xml;type=entry;profile=opds-catalog"})}static get OPDS2(){return w.parse({mediaType:"application/opds+json"})}static get OPDS2_PUBLICATION(){return w.parse({mediaType:"application/opds-publication+json"})}static get OPDS_AUTHENTICATION(){return w.parse({mediaType:"application/opds-authentication+json"})}static get OPUS(){return w.parse({mediaType:"audio/opus",fileExtension:"opus"})}static get OTF(){return w.parse({mediaType:"font/otf",fileExtension:"otf"})}static get PDF(){return w.parse({mediaType:"application/pdf",name:"PDF",fileExtension:"pdf"})}static get PNG(){return w.parse({mediaType:"image/png",fileExtension:"png"})}static get READIUM_AUDIOBOOK(){return w.parse({mediaType:"application/audiobook+zip",name:"Readium Audiobook",fileExtension:"audiobook"})}static get READIUM_AUDIOBOOK_MANIFEST(){return w.parse({mediaType:"application/audiobook+json",name:"Readium Audiobook",fileExtension:"json"})}static get READIUM_CONTENT_DOCUMENT(){return w.parse({mediaType:"application/vnd.readium.content+json",name:"Readium Content Document",fileExtension:"json"})}static get READIUM_GUIDED_NAVIGATION_DOCUMENT(){return w.parse({mediaType:"application/guided-navigation+json",name:"Readium Guided Navigation Document",fileExtension:"json"})}static get READIUM_POSITION_LIST(){return w.parse({mediaType:"application/vnd.readium.position-list+json",name:"Readium Position List",fileExtension:"json"})}static get READIUM_WEBPUB(){return w.parse({mediaType:"application/webpub+zip",name:"Readium Web Publication",fileExtension:"webpub"})}static get READIUM_WEBPUB_MANIFEST(){return w.parse({mediaType:"application/webpub+json",name:"Readium Web Publication",fileExtension:"json"})}static get SMIL(){return w.parse({mediaType:"application/smil+xml",fileExtension:"smil"})}static get SVG(){return w.parse({mediaType:"image/svg+xml",fileExtension:"svg"})}static get TEXT(){return w.parse({mediaType:"text/plain",fileExtension:"txt"})}static get TIFF(){return w.parse({mediaType:"image/tiff",fileExtension:"tiff"})}static get TTF(){return w.parse({mediaType:"font/ttf",fileExtension:"ttf"})}static get W3C_WPUB_MANIFEST(){return w.parse({mediaType:"application/x.readium.w3c.wpub+json",name:"Web Publication",fileExtension:"json"})}static get WAV(){return w.parse({mediaType:"audio/wav",fileExtension:"wav"})}static get WEBM_AUDIO(){return w.parse({mediaType:"audio/webm",fileExtension:"webm"})}static get WEBM_VIDEO(){return w.parse({mediaType:"video/webm",fileExtension:"webm"})}static get WEBP(){return w.parse({mediaType:"image/webp",fileExtension:"webp"})}static get WOFF(){return w.parse({mediaType:"font/woff",fileExtension:"woff"})}static get WOFF2(){return w.parse({mediaType:"font/woff2",fileExtension:"woff2"})}static get XHTML(){return w.parse({mediaType:"application/xhtml+xml",fileExtension:"xhtml"})}static get XML(){return w.parse({mediaType:"application/xml",fileExtension:"xml"})}static get ZAB(){return w.parse({mediaType:"application/x.readium.zab+zip",name:"Zipped Audio Book",fileExtension:"zab"})}static get ZIP(){return w.parse({mediaType:"application/zip",fileExtension:"zip"})}}class nt{constructor(A){this.uri=A,this.parameters=this.getParameters(A)}getParameters(A){const t=/\{\??([^}]+)\}/g,i=A.match(t);return i?new Set(i.join(",").replace(t,"$1").split(",").map(o=>o.trim())):new Set}expand(A){const t=o=>o.split(",").map(s=>{const r=A[s];return r?encodeURIComponent(r):""}).join(","),i=o=>"?"+o.split(",").map(s=>{const r=s.split("=")[0],n=A[r];return n?`${r}=${encodeURIComponent(n)}`:""}).join("&");return this.uri.replace(/\{(\??)([^}]+)\}/g,(...o)=>o[1]?i(o[2]):t(o[2]))}}function Vi(e){return e&&e instanceof Array?e:void 0}function at(e){return e&&typeof e=="string"?[e]:Vi(e)}function ct(e){return typeof e=="string"?new Date(e):void 0}function IA(e){return isNaN(e)?void 0:e}function D(e){return IA(e)!==void 0&&Math.sign(e)>=0?e:void 0}function Ni(e){const A=new Array;return e.forEach(t=>A.push(t)),A}class z{constructor(A){this.fragments=A.fragments?A.fragments:new Array,this.progression=A.progression,this.totalProgression=A.totalProgression,this.position=A.position,this.otherLocations=A.otherLocations}static deserialize(A){if(!A)return;const t=IA(A.progression),i=IA(A.totalProgression),o=IA(A.position),s=new Map,r=new Set(["fragment","fragments","progression","totalProgression","position"]);return Object.entries(A).forEach(([n,a])=>{r.has(n)||s.set(n,a)}),new z({fragments:at(A.fragments||A.fragment),progression:t!==void 0&&t>=0&&t<=1?t:void 0,totalProgression:i!==void 0&&i>=0&&i<=1?i:void 0,position:o!==void 0&&o>0?o:void 0,otherLocations:s.size===0?void 0:s})}serialize(){const A={};return this.fragments&&(A.fragments=this.fragments),this.progression!==void 0&&(A.progression=this.progression),this.totalProgression!==void 0&&(A.totalProgression=this.totalProgression),this.position!==void 0&&(A.position=this.position),this.otherLocations&&this.otherLocations.forEach((t,i)=>A[i]=t),A}}class DA{constructor(A){this.after=A.after,this.before=A.before,this.highlight=A.highlight}static deserialize(A){if(A)return new DA({after:A.after,before:A.before,highlight:A.highlight})}serialize(){const A={};return this.after!==void 0&&(A.after=this.after),this.before!==void 0&&(A.before=this.before),this.highlight!==void 0&&(A.highlight=this.highlight),A}}class ${constructor(A){this.href=A.href,this.type=A.type,this.title=A.title,this.locations=A.locations?A.locations:new z({}),this.text=A.text}static deserialize(A){if(A&&A.href&&A.type)return new $({href:A.href,type:A.type,title:A.title,locations:z.deserialize(A.locations),text:DA.deserialize(A.text)})}serialize(){const A={href:this.href,type:this.type};return this.title!==void 0&&(A.title=this.title),this.locations&&(A.locations=this.locations.serialize()),this.text&&(A.text=this.text.serialize()),A}copyWithLocations(A){return new $({href:this.href,type:this.type,title:this.title,text:this.text,locations:new z({...this.locations,...A})})}}let aA=class HA{constructor(A){this.href=A.href,this.templated=A.templated,this.type=A.type,this.title=A.title,this.rels=A.rels,this.properties=A.properties,this.height=A.height,this.width=A.width,this.duration=A.duration,this.bitrate=A.bitrate,this.languages=A.languages,this.alternates=A.alternates,this.children=A.children}static deserialize(A){if(A&&A.href&&typeof A.href=="string")return new HA({href:A.href,templated:A.templated,type:A.type,title:A.title,rels:A.rel?A.rel instanceof Array?new Set(A.rel):new Set([A.rel]):void 0,properties:Y.deserialize(A.properties),height:D(A.height),width:D(A.width),duration:D(A.duration),bitrate:D(A.bitrate),languages:at(A.language),alternates:Bt.deserialize(A.alternate),children:Bt.deserialize(A.children)})}serialize(){const A={href:this.href};return this.templated!==void 0&&(A.templated=this.templated),this.type!==void 0&&(A.type=this.type),this.title!==void 0&&(A.title=this.title),this.rels&&(A.rel=Ni(this.rels)),this.properties&&(A.properties=this.properties.serialize()),this.height!==void 0&&(A.height=this.height),this.width!==void 0&&(A.width=this.width),this.duration!==void 0&&(A.duration=this.duration),this.bitrate!==void 0&&(A.bitrate=this.bitrate),this.languages&&(A.language=this.languages),this.alternates&&(A.alternate=this.alternates.serialize()),this.children&&(A.children=this.children.serialize()),A}get mediaType(){return this.type!==void 0?w.parse({mediaType:this.type}):w.BINARY}toURL(A){const t=this.href.replace(/^(\/)/,"");if(t.length===0)return;let i=A||"/";return i.startsWith("/")&&(i="file://"+i),new URL(t,i).href.replace(/^(file:\/\/)/,"")}get templateParameters(){return this.templated?new nt(this.href).parameters:new Set}expandTemplate(A){return new HA({href:new nt(this.href).expand(A),templated:!1})}addProperties(A){var t;const i=HA.deserialize(this.serialize());return i.properties=i.properties?(t=i.properties)==null?void 0:t.add(A):new Y(A),i}get locator(){let A=this.href.split("#");return new $({href:A.length>0&&A[0]!==void 0?A[0]:this.href,type:this.type??"",title:this.title,locations:new z({fragments:A.length>1&&A[1]!==void 0?[A[1]]:[]})})}},Bt=class Ri{constructor(A){this.items=A}static deserialize(A){if(A&&A instanceof Array)return new Ri(A.map(t=>aA.deserialize(t)).filter(t=>t!==void 0))}serialize(){return this.items.map(A=>A.serialize())}findWithRel(A){const t=i=>i.rels&&i.rels.has(A);return this.items.find(t)}filterByRel(A){const t=i=>i.rels&&i.rels.has(A);return this.items.filter(t)}findWithHref(A){const t=i=>i.href===A;return this.items.find(t)}findIndexWithHref(A){const t=i=>i.href===A;return this.items.findIndex(t)}findWithMediaType(A){const t=i=>i.mediaType.matches(A);return this.items.find(t)}filterByMediaType(A){const t=i=>i.mediaType.matches(A);return this.items.filter(t)}filterByMediaTypes(A){const t=i=>{for(const o of A)if(i.mediaType.matches(o))return!0;return!1};return this.items.filter(t)}everyIsAudio(){const A=t=>t.mediaType.isAudio;return this.items.length>0&&this.items.every(A)}everyIsBitmap(){const A=t=>t.mediaType.isBitmap;return this.items.length>0&&this.items.every(A)}everyIsHTML(){const A=t=>t.mediaType.isHTML;return this.items.length>0&&this.items.every(A)}everyIsVideo(){const A=t=>t.mediaType.isVideo;return this.items.length>0&&this.items.every(A)}everyMatchesMediaType(A){return Array.isArray(A)?this.items.length>0&&this.items.every(t=>{for(const i of A)return t.mediaType.matches(i);return!1}):this.items.length>0&&this.items.every(t=>t.mediaType.matches(A))}filterLinksHasType(){return this.items.filter(A=>A.type)}},ht=class Li{constructor(A){this.cssSelector=A.cssSelector,this.textNodeIndex=A.textNodeIndex,this.charOffset=A.charOffset}static deserialize(A){if(!(A&&A.cssSelector))return;let t=D(A.textNodeIndex);if(t===void 0)return;let i=D(A.charOffset);return i===void 0&&(i=D(A.offset)),new Li({cssSelector:A.cssSelector,textNodeIndex:t,charOffset:i})}serialize(){const A={cssSelector:this.cssSelector,textNodeIndex:this.textNodeIndex};return this.charOffset!==void 0&&(A.charOffset=this.charOffset),A}},Ti=class xi{constructor(A){this.start=A.start,this.end=A.end}static deserialize(A){if(!A)return;let t=ht.deserialize(A.start);if(t)return new xi({start:t,end:ht.deserialize(A.end)})}serialize(){const A={start:this.start.serialize()};return this.end&&(A.end=this.end.serialize()),A}};z.prototype.getCssSelector=function(){var e;return(e=this.otherLocations)==null?void 0:e.get("cssSelector")},z.prototype.getPartialCfi=function(){var e;return(e=this.otherLocations)==null?void 0:e.get("partialCfi")},z.prototype.getDomRange=function(){var e;return Ti.deserialize((e=this.otherLocations)==null?void 0:e.get("domRange"))},z.prototype.fragmentParameters=function(){return new Map(this.fragments.map(e=>e.startsWith("#")?e.slice(1):e).join("&").split("&").filter(e=>!e.startsWith("#")).map(e=>e.split("=")).filter(e=>e.length===2).map(e=>[e[0].trim().toLowerCase(),e[1].trim()]))},z.prototype.htmlId=function(){if(!this.fragments.length)return;let e=this.fragments.find(A=>A.length&&!A.includes("="));if(!e){const A=this.fragmentParameters();A.has("id")?e=A.get("id"):A.has("name")&&(e=A.get("name"))}return e!=null&&e.startsWith("#")?e.slice(1):e},z.prototype.page=function(){const e=parseInt(this.fragmentParameters().get("page"));if(!isNaN(e)&&e>=0)return e},z.prototype.time=function(){const e=parseInt(this.fragmentParameters().get("t"));if(!isNaN(e))return e},z.prototype.space=function(){const e=this.fragmentParameters();if(!e.has("xywh"))return;const A=e.get("xywh").split(",").map(t=>parseInt(t));if(A.length===4&&!A.some(isNaN))return A};class RA{constructor(A){this.currency=A.currency,this.value=A.value}static deserialize(A){if(!A)return;let t=A.currency;if(!(t&&typeof t=="string"&&t.length>0))return;let i=D(A.value);if(i!==void 0)return new RA({currency:t,value:i})}serialize(){return{currency:this.currency,value:this.value}}}class cA{constructor(A){this.type=A.type,this.children=A.children}static deserialize(A){if(A&&A.type)return new cA({type:A.type,children:cA.deserializeArray(A.children)})}static deserializeArray(A){if(A instanceof Array)return A.map(t=>cA.deserialize(t)).filter(t=>t!==void 0)}serialize(){const A={type:this.type};return this.children&&(A.children=this.children.map(t=>t.serialize())),A}}let Pi=class Gi{constructor(A){this.total=A.total,this.position=A.position}static deserialize(A){if(A)return new Gi({total:D(A.total),position:D(A.position)})}serialize(){const A={};return this.total!==void 0&&(A.total=this.total),this.position!==void 0&&(A.position=this.position),A}},Wi=class bi{constructor(A){this.total=A.total,this.available=A.available}static deserialize(A){if(A)return new bi({total:D(A.total),available:D(A.available)})}serialize(){const A={};return this.total!==void 0&&(A.total=this.total),this.available!==void 0&&(A.available=this.available),A}},ki=class ji{constructor(A){this.state=A.state,this.since=A.since,this.until=A.until}static deserialize(A){if(A&&A.state)return new ji({state:A.state,since:ct(A.since),until:ct(A.until)})}serialize(){const A={state:this.state};return this.since!==void 0&&(A.since=this.since.toISOString()),this.until!==void 0&&(A.until=this.until.toISOString()),A}};Y.prototype.getNumberOfItems=function(){return D(this.otherProperties.numberOfItems)},Y.prototype.getPrice=function(){return RA.deserialize(this.otherProperties.price)},Y.prototype.getIndirectAcquisitions=function(){const e=this.otherProperties.indirectAcquisition;if(e&&e instanceof Array)return e.map(A=>cA.deserialize(A)).filter(A=>A!==void 0)},Y.prototype.getHolds=function(){return Pi.deserialize(this.otherProperties.holds)},Y.prototype.getCopies=function(){return Wi.deserialize(this.otherProperties.copies)},Y.prototype.getAvailability=function(){return ki.deserialize(this.otherProperties.availability)},Y.prototype.getAuthenticate=function(){return aA.deserialize(this.otherProperties.authenticate)};var p=(e=>(e.auto="auto",e.btt="btt",e.ltr="ltr",e.rtl="rtl",e.ttb="ttb",e))(p||{});Y.prototype.getClipped=function(){return this.otherProperties.clipped},Y.prototype.getFit=function(){return this.otherProperties.fit},Y.prototype.getOrientation=function(){return this.otherProperties.orientation},Y.prototype.getOverflow=function(){return this.otherProperties.overflow},Y.prototype.getPage=function(){return this.otherProperties.page||void 0},Y.prototype.getSpread=function(){return this.otherProperties.spread||void 0};class gt{}class wt extends gt{goLeft(A=!1,t){this.readingProgression===p.ltr||this.readingProgression===p.ttb||this.readingProgression===p.auto?this.goBackward(A,t):(this.readingProgression===p.rtl||this.readingProgression===p.btt)&&this.goForward(A,t)}goRight(A=!1,t){this.readingProgression===p.ltr||this.readingProgression===p.ttb||this.readingProgression===p.auto?this.goForward(A,t):(this.readingProgression===p.rtl||this.readingProgression===p.btt)&&this.goBackward(A,t)}}const Si=`@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__colWidth: 45em;--RS__colCount: 1;--RS__colGap: 0;--RS__maxLineLength: 40rem;--RS__pageGutter: 20px}@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:100%;height:100vh;max-width:100%;max-height:100vh;min-width:100%;min-height:100vh;padding:0!important;margin:0!important;font-size:100%!important;-webkit-text-size-adjust:100%;box-sizing:border-box;-webkit-perspective:1;-webkit-touch-callout:none}body{width:100%;max-width:var(--RS__maxLineLength)!important;padding:0 var(--RS__pageGutter)!important;margin:0 auto!important;box-sizing:border-box}@media screen and (min-width: 35em){:root{--RS__pageGutter: 30px}}@media screen and (min-width: 45em){:root{--RS__pageGutter: 40px}}@media screen and (min-width: 75em){:root{--RS__pageGutter: 50px}}@media screen and (min-width: 60em),screen and (min-device-width: 36em) and (max-device-width: 47em) and (orientation: landscape){:root{--RS__colWidth: 20em;--RS__colCount: 2;--RS__maxLineLength: 39.99rem}}: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{--RS__maxLineLength: 40rem !important}:root[style*=readium-night-on]{--RS__backgroundColor: #000000;--RS__textColor: #FEFEFE;--RS__linkColor: #63caff;--RS__visitedColor: #0099E5;--RS__selectionBackgroundColor: #b4d8fe;--RS__selectionTextColor: inherit}:root[style*=readium-night-on] *:not(a){color:inherit!important;background-color:transparent!important;border-color:currentColor!important}:root[style*=readium-night-on] svg text{fill:currentColor!important;stroke:none!important}:root[style*=readium-night-on] a:link,:root[style*=readium-night-on] a:link *{color:var(--RS__linkColor)!important}:root[style*=readium-night-on] a:visited,:root[style*=readium-night-on] a:visited *{color:var(--RS__visitedColor)!important}:root[style*=readium-night-on] img[class*=gaiji],:root[style*=readium-night-on] *[epub\\:type~=titlepage] img:only-child,:root[style*=readium-night-on] *[epub|type~=titlepage] img:only-child{-webkit-filter:invert(100%);filter:invert(100%)}:root[style*=readium-night-on][style*=readium-darken-on] img{-webkit-filter:brightness(80%);filter:brightness(80%)}:root[style*=readium-night-on][style*=readium-invert-on] img{-webkit-filter:invert(100%);filter:invert(100%)}:root[style*=readium-night-on][style*=readium-darken-on][style*=readium-invert-on] img{-webkit-filter:brightness(80%) invert(100%);filter:brightness(80%) invert(100%)}:root[style*=readium-sepia-on]{--RS__backgroundColor: #faf4e8;--RS__textColor: #121212;--RS__linkColor: #0000EE;--RS__visitedColor: #551A8B;--RS__selectionBackgroundColor: #b4d8fe;--RS__selectionTextColor: inherit;--RS__maxLineLength: 40.01rem}:root[style*=readium-sepia-on] *:not(a){color:inherit!important;background-color:transparent!important}:root[style*=readium-sepia-on] a:link,:root[style*=readium-sepia-on] a:link *{color:var(--RS__linkColor)}:root[style*=readium-sepia-on] a:visited,:root[style*=readium-sepia-on] a:visited *{color:var(--RS__visitedColor)}:root[style*=readium-sepia-on] svg,:root[style*=readium-sepia-on] img{background-color:transparent!important;mix-blend-mode:multiply}@media screen and (-ms-high-contrast: active){:root{color:windowText!important;background-color:window!important}:root :not(#\\#):not(#\\#):not(#\\#),:root :not(#\\#):not(#\\#):not(#\\#) :not(#\\#):not(#\\#):not(#\\#) :root :not(#\\#):not(#\\#):not(#\\#) :not(#\\#):not(#\\#):not(#\\#) :not(#\\#):not(#\\#):not(#\\#){color:inherit!important;background-color:inherit!important}.readiumCSS-mo-active-default{color:highlightText!important;background-color:highlight!important}}@media screen and (-ms-high-contrast: white-on-black){:root[style*=readium-night-on] img[class*=gaiji],:root[style*=readium-night-on] *[epub\\:type~=titlepage] img:only-child,:root[style*=readium-night-on] *[epub|type~=titlepage] img:only-child{-webkit-filter:none!important;filter:none!important}:root[style*=readium-night-on][style*=readium-invert-on] img{-webkit-filter:none!important;filter:none!important}:root[style*=readium-night-on][style*=readium-darken-on][style*=readium-invert-on] img{-webkit-filter:brightness(80%);filter:brightness(80%)}}@media screen and (inverted-colors){:root[style*=readium-night-on] img[class*=gaiji],:root[style*=readium-night-on] *[epub\\:type~=titlepage] img:only-child,:root[style*=readium-night-on] *[epub|type~=titlepage] img:only-child{-webkit-filter:none!important;filter:none!important}:root[style*=readium-night-on][style*=readium-invert-on] img{-webkit-filter:none!important;filter:none!important}:root[style*=readium-night-on][style*=readium-darken-on][style*=readium-invert-on] img{-webkit-filter:brightness(80%);filter:brightness(80%)}}@media screen and (min-width: 60em),screen and (min-device-width: 36em) and (max-device-width: 47em) and (orientation: landscape){:root[style*="--USER__colCount: 1"],:root[style*="--USER__colCount:1"],:root[style*="--USER__colCount: 2"],:root[style*="--USER__colCount:2"]{-webkit-column-count:var(--USER__colCount);-moz-column-count:var(--USER__colCount);column-count:var(--USER__colCount)}:root[style*="--USER__colCount: 1"],:root[style*="--USER__colCount:1"]{--RS__maxLineLength: 40rem !important;--RS__colWidth: 100vw}:root[style*="--USER__colCount: 2"],:root[style*="--USER__colCount:2"]{--RS__colWidth: auto}}:root[style*=--USER__pageMargins] body{padding:0 calc(var(--RS__pageGutter) * var(--USER__pageMargins))!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(h1):not(h2):not(h3):not(h4):not(h5):not(h6):not(pre){color:inherit!important}:root[style*=readium-advanced-on][style*=--USER__textAlign]{text-align:var(--USER__textAlign)}:root[style*=readium-advanced-on][style*=--USER__textAlign] body,:root[style*=readium-advanced-on][style*=--USER__textAlign] *:not(blockquote):not(figcaption) p,:root[style*=readium-advanced-on][style*=--USER__textAlign] li{text-align:inherit!important;-moz-text-align-last:auto!important;-epub-text-align-last:auto!important;text-align-last:auto!important}:root[style*=readium-advanced-on][dir=rtl][style*="--USER__textAlign: left"],:root[style*=readium-advanced-on][dir=rtl][style*="--USER__textAlign:left"],:root[style*=readium-advanced-on][style*="--USER__textAlign: left"] *[dir=rtl],:root[style*=readium-advanced-on][style*="--USER__textAlign:left"] *[dir=rtl]{text-align:right}:root[style*=readium-advanced-on][dir=rtl][style*="--USER__textAlign: start"],:root[style*=readium-advanced-on][dir=rtl][style*="--USER__textAlign:start"]{text-align:right}:root[style*=readium-advanced-on][style*="--USER__textAlign: justify"] body,:root[style*=readium-advanced-on][style*="--USER__textAlign:justify"] body{-webkit-hyphens:auto;-moz-hyphens:auto;-ms-hyphens:auto;-epub-hyphens:auto;hyphens:auto}:root[style*=readium-advanced-on][style*="--USER__textAlign: left"] body,:root[style*=readium-advanced-on][style*="--USER__textAlign:left"] body,:root[style*=readium-advanced-on][style*="--USER__textAlign: right"] body,:root[style*=readium-advanced-on][style*="--USER__textAlign:right"] body{-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;-epub-hyphens:none;hyphens:none}:root[style*=readium-advanced-on][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*=readium-advanced-on][style*=--USER__bodyHyphens] body,:root[style*=readium-advanced-on][style*=--USER__bodyHyphens] p,:root[style*=readium-advanced-on][style*=--USER__bodyHyphens] li,:root[style*=readium-advanced-on][style*=--USER__bodyHyphens] div,:root[style*=readium-advanced-on][style*=--USER__bodyHyphens] dd{-webkit-hyphens:inherit;-moz-hyphens:inherit;-ms-hyphens:inherit;-epub-hyphens:inherit;hyphens:inherit}:root[style*=readium-font-on][style*=--USER__fontFamily]{font-family:var(--USER__fontFamily)!important}:root[style*=readium-font-on][style*=--USER__fontFamily] body,:root[style*=readium-font-on][style*=--USER__fontFamily] p,:root[style*=readium-font-on][style*=--USER__fontFamily] li,:root[style*=readium-font-on][style*=--USER__fontFamily] div,:root[style*=readium-font-on][style*=--USER__fontFamily] dt,:root[style*=readium-font-on][style*=--USER__fontFamily] dd{font-family:inherit!important}:root[style*=readium-font-on][style*=--USER__fontFamily] i:not([lang]),:root[style*=readium-font-on][style*=--USER__fontFamily] i:not([xml\\:lang]),:root[style*=readium-font-on][style*=--USER__fontFamily] em:not([lang]),:root[style*=readium-font-on][style*=--USER__fontFamily] em:not([xml\\:lang]),:root[style*=readium-font-on][style*=--USER__fontFamily] cite:not([lang]),:root[style*=readium-font-on][style*=--USER__fontFamily] cite:not([xml\\:lang]),:root[style*=readium-font-on][style*=--USER__fontFamily] b:not([lang]),:root[style*=readium-font-on][style*=--USER__fontFamily] b:not([xml\\:lang]),:root[style*=readium-font-on][style*=--USER__fontFamily] strong:not([lang]),:root[style*=readium-font-on][style*=--USER__fontFamily] strong:not([xml\\:lang]),:root[style*=readium-font-on][style*=--USER__fontFamily] span:not([lang]),:root[style*=readium-font-on][style*=--USER__fontFamily] span:not([xml\\:lang]){font-family:inherit!important}:root[style*=readium-font-on][style*=AccessibleDfA]{font-family:AccessibleDfA,Verdana,Tahoma,Trebuchet MS,sans-serif!important;--RS__lineHeightCompensation: 1.167}:root[style*=readium-font-on][style*="IA Writer Duospace"]{font-family:IA Writer Duospace,Menlo,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier,monospace!important;--RS__lineHeightCompensation: 1.167}:root[style*=readium-font-on][style*=readium-a11y-on]{font-family:var(--USER__fontFamily)!important;--RS__lineHeightCompensation: 1.167}:root[style*=readium-font-on][style*=AccessibleDfA],:root[style*=readium-font-on][style*="IA Writer Duospace"],:root[style*=readium-font-on][style*=readium-a11y-on]{font-style:normal!important;font-weight:400!important}:root[style*=readium-font-on][style*=AccessibleDfA] *:not(code):not(var):not(kbd):not(samp),:root[style*=readium-font-on][style*="IA Writer Duospace"] *:not(code):not(var):not(kbd):not(samp),:root[style*=readium-font-on][style*=readium-a11y-on] *:not(code):not(var):not(kbd):not(samp){font-family:inherit!important;font-style:inherit!important;font-weight:inherit!important}:root[style*=readium-font-on][style*=AccessibleDfA] *,:root[style*=readium-font-on][style*="IA Writer Duospace"] *,:root[style*=readium-font-on][style*=readium-a11y-on] *{text-decoration:none!important;font-variant-caps:normal!important;font-variant-numeric:normal!important;font-variant-position:normal!important}:root[style*=readium-font-on][style*=AccessibleDfA] sup,:root[style*=readium-font-on][style*="IA Writer Duospace"] sup,:root[style*=readium-font-on][style*=readium-a11y-on] sup,:root[style*=readium-font-on][style*=AccessibleDfA] sub,:root[style*=readium-font-on][style*="IA Writer Duospace"] sub,:root[style*=readium-font-on][style*=readium-a11y-on] sub{font-size:1rem!important;vertical-align:baseline!important}:root[style*=--USER__fontSize]{font-size:var(--USER__fontSize)!important}:root[style*=readium-advanced-on][style*=--USER__lineHeight]{line-height:var(--USER__lineHeight)!important}:root[style*=readium-advanced-on][style*=--USER__lineHeight] body,:root[style*=readium-advanced-on][style*=--USER__lineHeight] p,:root[style*=readium-advanced-on][style*=--USER__lineHeight] li,:root[style*=readium-advanced-on][style*=--USER__lineHeight] div{line-height:inherit}:root[style*=readium-advanced-on][style*=--USER__paraSpacing] p{margin-top:var(--USER__paraSpacing)!important;margin-bottom:var(--USER__paraSpacing)!important}:root[style*=readium-advanced-on][style*=--USER__paraIndent] p{text-indent:var(--USER__paraIndent)!important}:root[style*=readium-advanced-on][style*=--USER__paraIndent] p *,:root[style*=readium-advanced-on][style*=--USER__paraIndent] p:first-letter{text-indent:0!important}:root[style*=readium-advanced-on][style*=--USER__wordSpacing] h1,:root[style*=readium-advanced-on][style*=--USER__wordSpacing] h2,:root[style*=readium-advanced-on][style*=--USER__wordSpacing] h3,:root[style*=readium-advanced-on][style*=--USER__wordSpacing] h4,:root[style*=readium-advanced-on][style*=--USER__wordSpacing] h5,:root[style*=readium-advanced-on][style*=--USER__wordSpacing] h6,:root[style*=readium-advanced-on][style*=--USER__wordSpacing] p,:root[style*=readium-advanced-on][style*=--USER__wordSpacing] li,:root[style*=readium-advanced-on][style*=--USER__wordSpacing] div{word-spacing:var(--USER__wordSpacing)}:root[style*=readium-advanced-on][style*=--USER__letterSpacing] h1,:root[style*=readium-advanced-on][style*=--USER__letterSpacing] h2,:root[style*=readium-advanced-on][style*=--USER__letterSpacing] h3,:root[style*=readium-advanced-on][style*=--USER__letterSpacing] h4,:root[style*=readium-advanced-on][style*=--USER__letterSpacing] h5,:root[style*=readium-advanced-on][style*=--USER__letterSpacing] h6,:root[style*=readium-advanced-on][style*=--USER__letterSpacing] p,:root[style*=readium-advanced-on][style*=--USER__letterSpacing] li,:root[style*=readium-advanced-on][style*=--USER__letterSpacing] div{letter-spacing:var(--USER__letterSpacing);font-variant:none}:root[style*=readium-advanced-on]{--USER__typeScale: 1.2}:root[style*=readium-advanced-on] p,:root[style*=readium-advanced-on] li,:root[style*=readium-advanced-on] div,:root[style*=readium-advanced-on] pre,:root[style*=readium-advanced-on] dd{font-size:1rem!important}:root[style*=readium-advanced-on] h1{font-size:1.75rem!important;font-size:calc(((1rem * var(--USER__typeScale)) * var(--USER__typeScale)) * var(--USER__typeScale))!important}:root[style*=readium-advanced-on] h2{font-size:1.5rem!important;font-size:calc((1rem * var(--USER__typeScale)) * var(--USER__typeScale))!important}:root[style*=readium-advanced-on] h3{font-size:1.25rem!important;font-size:calc(1rem * var(--USER__typeScale))!important}:root[style*=readium-advanced-on] h4,:root[style*=readium-advanced-on] h5,:root[style*=readium-advanced-on] h6{font-size:1rem!important}:root[style*=readium-advanced-on] small{font-size:smaller!important}:root[style*=readium-advanced-on] sub,:root[style*=readium-advanced-on] sup{font-size:67.5%!important}:root[style*=readium-advanced-on][style*=--USER__typeScale] h1{font-size:calc(((1rem * var(--USER__typeScale)) * var(--USER__typeScale)) * var(--USER__typeScale))!important}:root[style*=readium-advanced-on][style*=--USER__typeScale] h2{font-size:calc((1rem * var(--USER__typeScale)) * var(--USER__typeScale))!important}:root[style*=readium-advanced-on][style*=--USER__typeScale] h3{font-size:calc(1rem * var(--USER__typeScale))!important}.readiumCSS-yellow-highlight,:root[style*=readium-sepia-on] .readiumCSS-yellow-highlight,:root[style*=readium-night-on] .readiumCSS-yellow-highlight{background-color:#ffff0080!important}.readiumCSS-green-highlight,:root[style*=readium-sepia-on] .readiumCSS-green-highlight,:root[style*=readium-night-on] .readiumCSS-green-highlight{background-color:#00ff0080!important}.readiumCSS-orange-highlight,:root[style*=readium-sepia-on] .readiumCSS-orange-highlight,:root[style*=readium-night-on] .readiumCSS-orange-highlight{background-color:#ffa50080!important}.readiumCSS-pink-highlight,:root[style*=readium-sepia-on] .readiumCSS-pink-highlight,:root[style*=readium-night-on] .readiumCSS-pink-highlight{background-color:#ff69b480!important}.readiumCSS-mo-active-default{color:#000!important;background-color:#ff0!important}
|
|
2
|
+
`,Ji=`@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__oldStyleTf: "Iowan Old Style", "Sitka Text", Palatino, "Book Antiqua", serif;--RS__modernTf: Athelas, Constantia, Georgia, serif;--RS__sansTf: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;--RS__humanistTf: Seravek, Calibri, Roboto, Arial, sans-serif;--RS__monospaceTf: "Andale Mono", Consolas, monospace;--RS__baseFontFamily: var(--RS__oldStyleTf);--RS__lineHeightCompensation: 1;--RS__baseLineHeight: calc((1em + (2ex - 1ch) - ((1rem - 16px) * .1667)) * var(--RS__lineHeightCompensation))}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 Sans", "Yu Gothic UI", "Meiryo UI", "MS Gothic", Roboto, Noto, "Noto Sans CJK JP", sans-serif;--RS__lineHeightCompensation: 1.167;--RS__serif-ja: "MS P明朝", "MS PMincho", "Hiragino Mincho Pro", "ヒラギノ明朝 Pro W3", "游明朝", "YuMincho", "MS 明朝", "MS Mincho", "Hiragino Mincho ProN", serif;--RS__sans-serif-ja: "MS Pゴシック", "MS PGothic", "Hiragino Kaku Gothic Pro W3", "ヒラギノ角ゴ Pro W3", "Hiragino Sans GB", "ヒラギノ角ゴシック W3", "游ゴシック", "YuGothic", "MS ゴシック", "MS Gothic", "Hiragino Sans", sans-serif;--RS__serif-ja-v: "MS 明朝", "MS Mincho", "Hiragino Mincho Pro", "ヒラギノ明朝 Pro W3", "游明朝", "YuMincho", "MS P明朝", "MS PMincho", "Hiragino Mincho ProN", serif;--RS__sans-serif-ja-v: "MS ゴシック", "MS Gothic", "Hiragino Kaku Gothic Pro W3", "ヒラギノ角ゴ Pro W3", "Hiragino Sans GB", "ヒラギノ角ゴシック W3", "游ゴシック", "YuGothic", "MS Pゴシック", "MS PGothic", "Hiragino Sans", 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}:root{--RS__backgroundColor: #FFFFFF;--RS__textColor: #121212;--RS__selectionBackgroundColor: #b4d8fe;--RS__selectionTextColor: inherit}:root{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)}@font-face{font-family:AccessibleDfA;font-style:normal;font-weight:400;src:local("AccessibleDfA"),url(./assets/AccessibleDfA.otf) format("opentype")}@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),*:lang(zh),*:lang(ko),:lang(ja) cite,:lang(ja) dfn,:lang(ja) em,:lang(ja) i,:lang(zh) cite,:lang(zh) dfn,:lang(zh) em,:lang(zh) i,:lang(ko) cite,:lang(ko) dfn,:lang(ko) em,:lang(ko) 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}html{-webkit-line-box-contain:block glyphs replaced}:lang(ja){-webkit-line-box-contain:block inline replaced}a,h1,h2,h3,h4,h5,h6{word-wrap:break-word}div{max-width:var(--RS__maxMediaWidth)}img,svg,audio,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}table{max-width:var(--RS__maxMediaWidth);box-sizing:var(--RS__boxSizingTable)}
|
|
3
|
+
`,Oi=`@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}
|
|
4
|
+
`,T=(e,A)=>URL.createObjectURL(new Blob([e],{type:A})),Mt=e=>e.replace(/\/\/.*/g,"").replace(/\/\*[\s\S]*?\*\//g,"").replace(/\n/g,"").replace(/\s+/g," "),LA=e=>e.replace(/\/\*(?:(?!\*\/)[\s\S])*\*\/|[\r\n\t]+/g,"").replace(/ {2,}/g," ").replace(/url\((?!(https?:)?\/\/)("?)\/([^\)]+)/g,`url($2${window.location.origin}/$3`),xA=(e,A)=>{const t=e.createElement("script");return t.dataset.readium="true",t.src=A.startsWith("blob:")?A:T(A,"text/javascript"),t},GA=(e,A)=>{const t=e.createElement("link");return t.dataset.readium="true",t.rel="stylesheet",t.type="text/css",t.href=A.startsWith("blob:")?A:T(A,"text/css"),t},bA=new Map,AA=(e,A)=>{if(bA.has(e))return bA.get(e);const t=A();return bA.set(e,t),t},Xi=e=>xA(e,AA("css-selector-generator",()=>T('!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&&o<e;)o+=1,n.push(r.map((e=>t[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})()));',"text/javascript"))),qi=e=>xA(e,AA("JS-Before",()=>T(Mt(`
|
|
5
|
+
window._readium_blockedEvents = [];
|
|
6
|
+
window._readium_blockEvents = true;
|
|
7
|
+
window._readium_eventBlocker = (e) => {
|
|
8
|
+
if(!window._readium_blockEvents) return;
|
|
9
|
+
e.preventDefault();
|
|
10
|
+
e.stopImmediatePropagation();
|
|
11
|
+
_readium_blockedEvents.push([
|
|
12
|
+
1, e, e.currentTarget || e.target
|
|
13
|
+
]);
|
|
14
|
+
};
|
|
15
|
+
window.addEventListener("DOMContentLoaded", window._readium_eventBlocker, true);
|
|
16
|
+
window.addEventListener("load", window._readium_eventBlocker, true);`),"text/javascript"))),Ki=e=>xA(e,AA("JS-After",()=>T(Mt(`
|
|
17
|
+
if(window.onload) window.onload = new Proxy(window.onload, {
|
|
18
|
+
apply: function(target, receiver, args) {
|
|
19
|
+
if(!window._readium_blockEvents) {
|
|
20
|
+
Reflect.apply(target, receiver, args);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
_readium_blockedEvents.push([
|
|
24
|
+
0, target, receiver, args
|
|
25
|
+
]);
|
|
26
|
+
}
|
|
27
|
+
});`),"text/javascript")));class It{constructor(A,t,i){this.pub=A,this.item=i,this.burl=i.toURL(t)||""}async build(A=!1){if(this.item.mediaType.isHTML)return await this.buildHtmlFrame(A);if(this.item.mediaType.isBitmap)return this.buildImageFrame();throw Error("Unsupported frame mediatype "+this.item.mediaType.string)}async buildHtmlFrame(A=!1){const t=await this.pub.get(this.item).readAsString();if(!t)throw new Error(`Failed reading item ${this.item.href}`);const i=new DOMParser().parseFromString(t,this.item.mediaType.string),o=i.querySelector("parsererror");if(o){const s=o.querySelector("div");throw new Error(`Failed parsing item ${this.item.href}: ${(s==null?void 0:s.textContent)||o.textContent}`)}return this.finalizeDOM(i,this.burl,this.item.mediaType,A)}buildImageFrame(){const A=document.implementation.createHTMLDocument(this.item.title||this.item.href),t=document.createElement("img");return t.src=this.burl||"",t.alt=this.item.title||"",t.decoding="async",A.body.appendChild(t),this.finalizeDOM(A,this.burl,this.item.mediaType,!0)}hasExecutable(A){return!!A.querySelector("script")||!!A.querySelector("body[onload]:not(body[onload=''])")}hasStyle(A){return!!(A.querySelector("link[rel='stylesheet']")||A.querySelector("style")||A.querySelector("[style]:not([style=''])"))}finalizeDOM(A,t,i,o=!1){if(!A)return"";if(!o){const r=GA(A,AA("ReadiumCSS-before",()=>T(LA(Ji),"text/css")));A.head.firstChild?A.head.firstChild.before(r):A.head.appendChild(r);const n=A.createElement("style");n.dataset.readium="true",n.innerHTML="audio[controls] { width: revert; height: revert; }",r.after(n),this.hasStyle(A)||r.after(GA(A,AA("ReadiumCSS-default",()=>T(LA(Oi),"text/css")))),A.head.appendChild(GA(A,AA("ReadiumCSS-after",()=>T(LA(Si),"text/css"))))}if(A.body.querySelectorAll("img").forEach(r=>{r.setAttribute("fetchpriority","high")}),t!==void 0){const r=A.createElement("base");r.href=t,r.dataset.readium="true",A.head.firstChild.before(r)}const s=this.hasExecutable(A);return s&&A.head.firstChild.before(qi(A)),A.head.firstChild.before(Xi(A)),s&&A.head.appendChild(Ki(A)),URL.createObjectURL(new Blob([new XMLSerializer().serializeToString(A)],{type:i.isHTML?i.string:"application/xhtml+xml"}))}}const Zi=Math.pow(2,32),dt=()=>Math.round(Math.random()*Zi).toString(36),jA=()=>`${Math.round(performance.now())}-${dt()}-${dt()}`,tA=1;class _i{constructor(A){this.destination=null,this.registrar=new Map,this.origin="",this.channelId="",this.receiver=this.receive.bind(this),this.preLog=[],this.wnd=A,A.addEventListener("message",this.receiver)}receive(A){if(A.source===null)throw Error("Event source is null");if(typeof A.data!="object")return;const t=A.data;if(!(!("_readium"in t)||!t._readium||t._readium<=0)){if(t.key==="_ping"){if(!this.destination){if(this.destination=A.source,this.origin=A.origin,this.channelId=t._channel,t._readium!==tA){t._readium>tA?this.send("error",`received comms version ${t._readium} higher than ${tA}`):this.send("error",`received comms version ${t._readium} lower than ${tA}`),this.destination=null,this.origin="",this.channelId="";return}this.send("_pong",void 0),this.preLog.forEach(i=>this.send("log",i)),this.preLog=[]}return}else if(this.channelId){if(t._channel!==this.channelId||A.origin!==this.origin)return}else return;this.handle(t)}}handle(A){const t=this.registrar.get(A.key);if(!t||t.length===0){A.strict&&this.send("_unhandled",A);return}t.forEach(i=>i.cb(A.data,o=>{this.send("_ack",o,A.id)}))}register(A,t,i){Array.isArray(A)||(A=[A]),A.forEach(o=>{const s=this.registrar.get(o);if(s&&s.length>=0){if(s.find(r=>r.module===t))throw new Error(`Trying to register another callback for combination of event ${o} and module ${t}`);s.push({cb:i,module:t}),this.registrar.set(o,s)}else this.registrar.set(o,[{cb:i,module:t}])})}unregister(A,t){Array.isArray(A)||(A=[A]),A.forEach(i=>{const o=this.registrar.get(i);!o||o.length===0||o.splice(o.findIndex(s=>s.module===t),1)})}unregisterAll(A){this.registrar.forEach((t,i)=>this.registrar.set(i,t.filter(o=>o.module!==A)))}log(...A){this.destination?this.send("log",A):this.preLog.push(A)}get ready(){return!!this.destination}destroy(){this.destination=null,this.channelId="",this.preLog=[],this.registrar.clear(),this.wnd.removeEventListener("message",this.receiver)}send(A,t,i=void 0,o=[]){if(!this.destination)throw Error("Attempted to send comms message before destination has been initialized");const s={_readium:tA,_channel:this.channelId,id:i??jA(),key:A,data:t};try{this.destination.postMessage(s,{targetOrigin:this.origin,transfer:o})}catch(r){if(o.length>0)throw r;this.destination.postMessage(s,this.origin,o)}}}class dA{}var O=[],$i=function(){return O.some(function(e){return e.activeTargets.length>0})},Ae=function(){return O.some(function(e){return e.skippedTargets.length>0})},lt="ResizeObserver loop completed with undelivered notifications.",te=function(){var e;typeof ErrorEvent=="function"?e=new ErrorEvent("error",{message:lt}):(e=document.createEvent("Event"),e.initEvent("error",!1,!1),e.message=lt),window.dispatchEvent(e)},BA;(function(e){e.BORDER_BOX="border-box",e.CONTENT_BOX="content-box",e.DEVICE_PIXEL_CONTENT_BOX="device-pixel-content-box"})(BA||(BA={}));var X=function(e){return Object.freeze(e)},ie=function(){function e(A,t){this.inlineSize=A,this.blockSize=t,X(this)}return e}(),ut=function(){function e(A,t,i,o){return this.x=A,this.y=t,this.width=i,this.height=o,this.top=this.y,this.left=this.x,this.bottom=this.top+this.height,this.right=this.left+this.width,X(this)}return e.prototype.toJSON=function(){var A=this,t=A.x,i=A.y,o=A.top,s=A.right,r=A.bottom,n=A.left,a=A.width,c=A.height;return{x:t,y:i,top:o,right:s,bottom:r,left:n,width:a,height:c}},e.fromRect=function(A){return new e(A.x,A.y,A.width,A.height)},e}(),VA=function(e){return e instanceof SVGElement&&"getBBox"in e},Ft=function(e){if(VA(e)){var A=e.getBBox(),t=A.width,i=A.height;return!t&&!i}var o=e,s=o.offsetWidth,r=o.offsetHeight;return!(s||r||e.getClientRects().length)},mt=function(e){var A;if(e instanceof Element)return!0;var t=(A=e==null?void 0:e.ownerDocument)===null||A===void 0?void 0:A.defaultView;return!!(t&&e instanceof t.Element)},ee=function(e){switch(e.tagName){case"INPUT":if(e.type!=="image")break;case"VIDEO":case"AUDIO":case"EMBED":case"OBJECT":case"CANVAS":case"IFRAME":case"IMG":return!0}return!1},hA=typeof window<"u"?window:{},lA=new WeakMap,Qt=/auto|scroll/,oe=/^tb|vertical/,se=/msie|trident/i.test(hA.navigator&&hA.navigator.userAgent),j=function(e){return parseFloat(e||"0")},iA=function(e,A,t){return e===void 0&&(e=0),A===void 0&&(A=0),t===void 0&&(t=!1),new ie((t?A:e)||0,(t?e:A)||0)},ft=X({devicePixelContentBoxSize:iA(),borderBoxSize:iA(),contentBoxSize:iA(),contentRect:new ut(0,0,0,0)}),pt=function(e,A){if(A===void 0&&(A=!1),lA.has(e)&&!A)return lA.get(e);if(Ft(e))return lA.set(e,ft),ft;var t=getComputedStyle(e),i=VA(e)&&e.ownerSVGElement&&e.getBBox(),o=!se&&t.boxSizing==="border-box",s=oe.test(t.writingMode||""),r=!i&&Qt.test(t.overflowY||""),n=!i&&Qt.test(t.overflowX||""),a=i?0:j(t.paddingTop),c=i?0:j(t.paddingRight),B=i?0:j(t.paddingBottom),h=i?0:j(t.paddingLeft),g=i?0:j(t.borderTopWidth),I=i?0:j(t.borderRightWidth),d=i?0:j(t.borderBottomWidth),l=i?0:j(t.borderLeftWidth),F=h+c,u=a+B,Q=l+I,m=g+d,f=n?e.offsetHeight-m-e.clientHeight:0,y=r?e.offsetWidth-Q-e.clientWidth:0,rA=o?F+Q:0,K=o?u+m:0,Z=i?i.width:j(t.width)-rA-y,_=i?i.height:j(t.height)-K-f,CA=Z+F+y+Q,zA=_+u+f+m,nA=X({devicePixelContentBoxSize:iA(Math.round(Z*devicePixelRatio),Math.round(_*devicePixelRatio),s),borderBoxSize:iA(CA,zA,s),contentBoxSize:iA(Z,_,s),contentRect:new ut(h,a,Z,_)});return lA.set(e,nA),nA},Yt=function(e,A,t){var i=pt(e,t),o=i.borderBoxSize,s=i.contentBoxSize,r=i.devicePixelContentBoxSize;switch(A){case BA.DEVICE_PIXEL_CONTENT_BOX:return r;case BA.BORDER_BOX:return o;default:return s}},re=function(){function e(A){var t=pt(A);this.target=A,this.contentRect=t.contentRect,this.borderBoxSize=X([t.borderBoxSize]),this.contentBoxSize=X([t.contentBoxSize]),this.devicePixelContentBoxSize=X([t.devicePixelContentBoxSize])}return e}(),Et=function(e){if(Ft(e))return 1/0;for(var A=0,t=e.parentNode;t;)A+=1,t=t.parentNode;return A},ne=function(){var e=1/0,A=[];O.forEach(function(s){if(s.activeTargets.length!==0){var r=[];s.activeTargets.forEach(function(n){var a=new re(n.target),c=Et(n.target);r.push(a),n.lastReportedSize=Yt(n.target,n.observedBox),c<e&&(e=c)}),A.push(function(){s.callback.call(s.observer,r,s.observer)}),s.activeTargets.splice(0,s.activeTargets.length)}});for(var t=0,i=A;t<i.length;t++){var o=i[t];o()}return e},vt=function(e){O.forEach(function(A){A.activeTargets.splice(0,A.activeTargets.length),A.skippedTargets.splice(0,A.skippedTargets.length),A.observationTargets.forEach(function(t){t.isActive()&&(Et(t.target)>e?A.activeTargets.push(t):A.skippedTargets.push(t))})})},ae=function(){var e=0;for(vt(e);$i();)e=ne(),vt(e);return Ae()&&te(),e>0},NA,Ut=[],ce=function(){return Ut.splice(0).forEach(function(e){return e()})},Be=function(e){if(!NA){var A=0,t=document.createTextNode(""),i={characterData:!0};new MutationObserver(function(){return ce()}).observe(t,i),NA=function(){t.textContent="".concat(A?A--:A++)}}Ut.push(e),NA()},he=function(e){Be(function(){requestAnimationFrame(e)})},uA=0,ge=function(){return!!uA},we=250,Me={attributes:!0,characterData:!0,childList:!0,subtree:!0},yt=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],Ct=function(e){return e===void 0&&(e=0),Date.now()+e},TA=!1,Ie=function(){function e(){var A=this;this.stopped=!0,this.listener=function(){return A.schedule()}}return e.prototype.run=function(A){var t=this;if(A===void 0&&(A=we),!TA){TA=!0;var i=Ct(A);he(function(){var o=!1;try{o=ae()}finally{if(TA=!1,A=i-Ct(),!ge())return;o?t.run(1e3):A>0?t.run(A):t.start()}})}},e.prototype.schedule=function(){this.stop(),this.run()},e.prototype.observe=function(){var A=this,t=function(){return A.observer&&A.observer.observe(document.body,Me)};document.body?t():hA.addEventListener("DOMContentLoaded",t)},e.prototype.start=function(){var A=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),yt.forEach(function(t){return hA.addEventListener(t,A.listener,!0)}))},e.prototype.stop=function(){var A=this;this.stopped||(this.observer&&this.observer.disconnect(),yt.forEach(function(t){return hA.removeEventListener(t,A.listener,!0)}),this.stopped=!0)},e}(),PA=new Ie,zt=function(e){!uA&&e>0&&PA.start(),uA+=e,!uA&&PA.stop()},de=function(e){return!VA(e)&&!ee(e)&&getComputedStyle(e).display==="inline"},le=function(){function e(A,t){this.target=A,this.observedBox=t||BA.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return e.prototype.isActive=function(){var A=Yt(this.target,this.observedBox,!0);return de(this.target)&&(this.lastReportedSize=A),this.lastReportedSize.inlineSize!==A.inlineSize||this.lastReportedSize.blockSize!==A.blockSize},e}(),ue=function(){function e(A,t){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=A,this.callback=t}return e}(),FA=new WeakMap,Ht=function(e,A){for(var t=0;t<e.length;t+=1)if(e[t].target===A)return t;return-1},mA=function(){function e(){}return e.connect=function(A,t){var i=new ue(A,t);FA.set(A,i)},e.observe=function(A,t,i){var o=FA.get(A),s=o.observationTargets.length===0;Ht(o.observationTargets,t)<0&&(s&&O.push(o),o.observationTargets.push(new le(t,i&&i.box)),zt(1),PA.schedule())},e.unobserve=function(A,t){var i=FA.get(A),o=Ht(i.observationTargets,t),s=i.observationTargets.length===1;o>=0&&(s&&O.splice(O.indexOf(i),1),i.observationTargets.splice(o,1),zt(-1))},e.disconnect=function(A){var t=this,i=FA.get(A);i.observationTargets.slice().forEach(function(o){return t.unobserve(A,o.target)}),i.activeTargets.splice(0,i.activeTargets.length)},e}(),Dt=function(){function e(A){if(arguments.length===0)throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");if(typeof A!="function")throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");mA.connect(this,A)}return e.prototype.observe=function(A,t){if(arguments.length===0)throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!mt(A))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");mA.observe(this,A,t)},e.prototype.unobserve=function(A){if(arguments.length===0)throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!mt(A))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");mA.unobserve(this,A)},e.prototype.disconnect=function(){mA.disconnect(this)},e.toString=function(){return"function ResizeObserver () { [polyfill code] }"},e}();const Rt="readium-snapper-style",Lt=class ot extends dA{constructor(){super(...arguments),this.protected=!1}buildStyles(){return`
|
|
28
|
+
html, body {
|
|
29
|
+
touch-action: manipulation;
|
|
30
|
+
user-select: ${this.protected?"none":"auto"};
|
|
31
|
+
}`}mount(A,t){const i=A.document.createElement("style");return i.dataset.readium="true",i.id=Rt,i.textContent=this.buildStyles(),A.document.head.appendChild(i),t.register("protect",ot.moduleName,(o,s)=>{this.protected=!0,i.textContent=this.buildStyles(),s(!0)}),t.register("unprotect",ot.moduleName,(o,s)=>{this.protected=!1,i.textContent=this.buildStyles(),s(!0)}),t.log("Snapper Mounted"),!0}unmount(A,t){var i;return(i=A.document.getElementById(Rt))==null||i.remove(),t.log("Snapper Unmounted"),!0}};Lt.moduleName="snapper";let xt=Lt;function q(e){return e.document.body.dir.toLowerCase()==="rtl"}function Gt(e){return parseInt(e.getComputedStyle(e.document.documentElement).getPropertyValue("column-count"))}function Fe(e){const A="readium-virtual-page";let t=e.document.getElementById(A);if(Gt(e)!==2)t&&t.remove();else{const i=e.document.scrollingElement.scrollWidth/e.innerWidth;Math.round(i*2)/2%1>.1&&(t?t.remove():(t=e.document.createElement("div"),t.setAttribute("id",A),t.dataset.readium="true",t.style.breakBefore="column",t.innerHTML="​",e.document.body.appendChild(t)))}}function me(e){return e<.5?2*e*e:-1+(4-2*e)*e}class WA{constructor(A){this.algorithm=A.algorithm,this.compression=A.compression,this.originalLength=A.originalLength,this.profile=A.profile,this.scheme=A.scheme}static deserialize(A){if(A&&A.algorithm)return new WA({algorithm:A.algorithm,compression:A.compression,originalLength:A.originalLength,profile:A.profile,scheme:A.scheme})}serialize(){const A={algorithm:this.algorithm};return this.compression!==void 0&&(A.compression=this.compression),this.originalLength!==void 0&&(A.originalLength=this.originalLength),this.profile!==void 0&&(A.profile=this.profile),this.scheme!==void 0&&(A.scheme=this.scheme),A}}class E{constructor(A){this.otherProperties=A}static deserialize(A){if(A)return new E(A)}serialize(){return this.otherProperties}add(A){const t=Object.assign({},this.otherProperties);for(const i in A)t[i]=A[i];return new E(t)}}Object.defineProperty(E.prototype,"encryption",{get:function(){return WA.deserialize(this.otherProperties.encrypted)}}),E.prototype.getContains=function(){return new Set(this.otherProperties.contains||[])},E.prototype.getLayout=function(){return this.otherProperties.layout};class M{constructor(A){let t,i,o=A.mediaType.replace(/\s/g,"").split(";");const s=o[0].split("/");if(s.length===2){if(t=s[0].toLowerCase().trim(),i=s[1].toLowerCase().trim(),t.length===0||i.length===0)throw new Error("Invalid media type")}else throw new Error("Invalid media type");const r={};for(let g=1;g<o.length;g++){const I=o[g].split("=");if(I.length===2){const d=I[0].toLocaleLowerCase(),l=d==="charset"?I[1].toUpperCase():I[1];r[d]=l}}const n={},a=Object.keys(r);a.sort((g,I)=>g.localeCompare(I)),a.forEach(g=>n[g]=r[g]);let c="";for(const g in n){const I=n[g];c+=`;${g}=${I}`}const B=`${t}/${i}${c}`,h=n.encoding;this.string=B,this.type=t,this.subtype=i,this.parameters=n,this.encoding=h,this.name=A.name,this.fileExtension=A.fileExtension}static parse(A){return new M(A)}get structuredSyntaxSuffix(){const A=this.subtype.split("+");return A.length>1?`+${A[A.length-1]}`:void 0}get charset(){return this.parameters.charset}contains(A){const t=typeof A=="string"?M.parse({mediaType:A}):A;if(!((this.type==="*"||this.type===t.type)&&(this.subtype==="*"||this.subtype===t.subtype)))return!1;const i=new Set(Object.entries(this.parameters).map(([s,r])=>`${s}=${r}`)),o=new Set(Object.entries(t.parameters).map(([s,r])=>`${s}=${r}`));for(const s of Array.from(i.values()))if(!o.has(s))return!1;return!0}matches(A){const t=typeof A=="string"?M.parse({mediaType:A}):A;return this.contains(t)||t.contains(this)}matchesAny(...A){for(const t of A)if(this.matches(t))return!0;return!1}equals(A){return this.string===A.string}get isZIP(){return this.matchesAny(M.ZIP,M.LCP_PROTECTED_AUDIOBOOK,M.LCP_PROTECTED_PDF)||this.structuredSyntaxSuffix==="+zip"}get isJSON(){return this.matchesAny(M.JSON)||this.structuredSyntaxSuffix==="+json"}get isOPDS(){return this.matchesAny(M.OPDS1,M.OPDS1_ENTRY,M.OPDS2,M.OPDS2_PUBLICATION,M.OPDS_AUTHENTICATION)||this.structuredSyntaxSuffix==="+json"}get isHTML(){return this.matchesAny(M.HTML,M.XHTML)}get isBitmap(){return this.matchesAny(M.BMP,M.GIF,M.JPEG,M.PNG,M.TIFF,M.WEBP)}get isAudio(){return this.type==="audio"}get isVideo(){return this.type==="video"}get isRWPM(){return this.matchesAny(M.READIUM_AUDIOBOOK_MANIFEST,M.DIVINA_MANIFEST,M.READIUM_WEBPUB_MANIFEST)}get isPublication(){return this.matchesAny(M.READIUM_AUDIOBOOK,M.READIUM_AUDIOBOOK_MANIFEST,M.CBZ,M.DIVINA,M.DIVINA_MANIFEST,M.EPUB,M.LCP_PROTECTED_AUDIOBOOK,M.LCP_PROTECTED_PDF,M.LPF,M.PDF,M.W3C_WPUB_MANIFEST,M.READIUM_WEBPUB,M.READIUM_WEBPUB_MANIFEST,M.ZAB)}static get AAC(){return M.parse({mediaType:"audio/aac",fileExtension:"aac"})}static get ACSM(){return M.parse({mediaType:"application/vnd.adobe.adept+xml",name:"Adobe Content Server Message",fileExtension:"acsm"})}static get AIFF(){return M.parse({mediaType:"audio/aiff",fileExtension:"aiff"})}static get AVI(){return M.parse({mediaType:"video/x-msvideo",fileExtension:"avi"})}static get BINARY(){return M.parse({mediaType:"application/octet-stream"})}static get BMP(){return M.parse({mediaType:"image/bmp",fileExtension:"bmp"})}static get CBZ(){return M.parse({mediaType:"application/vnd.comicbook+zip",name:"Comic Book Archive",fileExtension:"cbz"})}static get CSS(){return M.parse({mediaType:"text/css",fileExtension:"css"})}static get DIVINA(){return M.parse({mediaType:"application/divina+zip",name:"Digital Visual Narratives",fileExtension:"divina"})}static get DIVINA_MANIFEST(){return M.parse({mediaType:"application/divina+json",name:"Digital Visual Narratives",fileExtension:"json"})}static get EPUB(){return M.parse({mediaType:"application/epub+zip",name:"EPUB",fileExtension:"epub"})}static get GIF(){return M.parse({mediaType:"image/gif",fileExtension:"gif"})}static get GZ(){return M.parse({mediaType:"application/gzip",fileExtension:"gz"})}static get HTML(){return M.parse({mediaType:"text/html",fileExtension:"html"})}static get JAVASCRIPT(){return M.parse({mediaType:"text/javascript",fileExtension:"js"})}static get JPEG(){return M.parse({mediaType:"image/jpeg",fileExtension:"jpeg"})}static get JSON(){return M.parse({mediaType:"application/json"})}static get LCP_LICENSE_DOCUMENT(){return M.parse({mediaType:"application/vnd.readium.lcp.license.v1.0+json",name:"LCP License",fileExtension:"lcpl"})}static get LCP_PROTECTED_AUDIOBOOK(){return M.parse({mediaType:"application/audiobook+lcp",name:"LCP Protected Audiobook",fileExtension:"lcpa"})}static get LCP_PROTECTED_PDF(){return M.parse({mediaType:"application/pdf+lcp",name:"LCP Protected PDF",fileExtension:"lcpdf"})}static get LCP_STATUS_DOCUMENT(){return M.parse({mediaType:"application/vnd.readium.license.status.v1.0+json"})}static get LPF(){return M.parse({mediaType:"application/lpf+zip",fileExtension:"lpf"})}static get MP3(){return M.parse({mediaType:"audio/mpeg",fileExtension:"mp3"})}static get MPEG(){return M.parse({mediaType:"video/mpeg",fileExtension:"mpeg"})}static get NCX(){return M.parse({mediaType:"application/x-dtbncx+xml",fileExtension:"ncx"})}static get OGG(){return M.parse({mediaType:"audio/ogg",fileExtension:"oga"})}static get OGV(){return M.parse({mediaType:"video/ogg",fileExtension:"ogv"})}static get OPDS1(){return M.parse({mediaType:"application/atom+xml;profile=opds-catalog"})}static get OPDS1_ENTRY(){return M.parse({mediaType:"application/atom+xml;type=entry;profile=opds-catalog"})}static get OPDS2(){return M.parse({mediaType:"application/opds+json"})}static get OPDS2_PUBLICATION(){return M.parse({mediaType:"application/opds-publication+json"})}static get OPDS_AUTHENTICATION(){return M.parse({mediaType:"application/opds-authentication+json"})}static get OPUS(){return M.parse({mediaType:"audio/opus",fileExtension:"opus"})}static get OTF(){return M.parse({mediaType:"font/otf",fileExtension:"otf"})}static get PDF(){return M.parse({mediaType:"application/pdf",name:"PDF",fileExtension:"pdf"})}static get PNG(){return M.parse({mediaType:"image/png",fileExtension:"png"})}static get READIUM_AUDIOBOOK(){return M.parse({mediaType:"application/audiobook+zip",name:"Readium Audiobook",fileExtension:"audiobook"})}static get READIUM_AUDIOBOOK_MANIFEST(){return M.parse({mediaType:"application/audiobook+json",name:"Readium Audiobook",fileExtension:"json"})}static get READIUM_CONTENT_DOCUMENT(){return M.parse({mediaType:"application/vnd.readium.content+json",name:"Readium Content Document",fileExtension:"json"})}static get READIUM_GUIDED_NAVIGATION_DOCUMENT(){return M.parse({mediaType:"application/guided-navigation+json",name:"Readium Guided Navigation Document",fileExtension:"json"})}static get READIUM_POSITION_LIST(){return M.parse({mediaType:"application/vnd.readium.position-list+json",name:"Readium Position List",fileExtension:"json"})}static get READIUM_WEBPUB(){return M.parse({mediaType:"application/webpub+zip",name:"Readium Web Publication",fileExtension:"webpub"})}static get READIUM_WEBPUB_MANIFEST(){return M.parse({mediaType:"application/webpub+json",name:"Readium Web Publication",fileExtension:"json"})}static get SMIL(){return M.parse({mediaType:"application/smil+xml",fileExtension:"smil"})}static get SVG(){return M.parse({mediaType:"image/svg+xml",fileExtension:"svg"})}static get TEXT(){return M.parse({mediaType:"text/plain",fileExtension:"txt"})}static get TIFF(){return M.parse({mediaType:"image/tiff",fileExtension:"tiff"})}static get TTF(){return M.parse({mediaType:"font/ttf",fileExtension:"ttf"})}static get W3C_WPUB_MANIFEST(){return M.parse({mediaType:"application/x.readium.w3c.wpub+json",name:"Web Publication",fileExtension:"json"})}static get WAV(){return M.parse({mediaType:"audio/wav",fileExtension:"wav"})}static get WEBM_AUDIO(){return M.parse({mediaType:"audio/webm",fileExtension:"webm"})}static get WEBM_VIDEO(){return M.parse({mediaType:"video/webm",fileExtension:"webm"})}static get WEBP(){return M.parse({mediaType:"image/webp",fileExtension:"webp"})}static get WOFF(){return M.parse({mediaType:"font/woff",fileExtension:"woff"})}static get WOFF2(){return M.parse({mediaType:"font/woff2",fileExtension:"woff2"})}static get XHTML(){return M.parse({mediaType:"application/xhtml+xml",fileExtension:"xhtml"})}static get XML(){return M.parse({mediaType:"application/xml",fileExtension:"xml"})}static get ZAB(){return M.parse({mediaType:"application/x.readium.zab+zip",name:"Zipped Audio Book",fileExtension:"zab"})}static get ZIP(){return M.parse({mediaType:"application/zip",fileExtension:"zip"})}}class bt{constructor(A){this.uri=A,this.parameters=this.getParameters(A)}getParameters(A){const t=/\{\??([^}]+)\}/g,i=A.match(t);return i?new Set(i.join(",").replace(t,"$1").split(",").map(o=>o.trim())):new Set}expand(A){const t=o=>o.split(",").map(s=>{const r=A[s];return r?encodeURIComponent(r):""}).join(","),i=o=>"?"+o.split(",").map(s=>{const r=s.split("=")[0],n=A[r];return n?`${r}=${encodeURIComponent(n)}`:""}).join("&");return this.uri.replace(/\{(\??)([^}]+)\}/g,(...o)=>o[1]?i(o[2]):t(o[2]))}}function Qe(e){return e&&e instanceof Array?e:void 0}function jt(e){return e&&typeof e=="string"?[e]:Qe(e)}function Vt(e){return typeof e=="string"?new Date(e):void 0}function QA(e){return isNaN(e)?void 0:e}function R(e){return QA(e)!==void 0&&Math.sign(e)>=0?e:void 0}function fe(e){const A=new Array;return e.forEach(t=>A.push(t)),A}class U{constructor(A){this.fragments=A.fragments?A.fragments:new Array,this.progression=A.progression,this.totalProgression=A.totalProgression,this.position=A.position,this.otherLocations=A.otherLocations}static deserialize(A){if(!A)return;const t=QA(A.progression),i=QA(A.totalProgression),o=QA(A.position),s=new Map,r=new Set(["fragment","fragments","progression","totalProgression","position"]);return Object.entries(A).forEach(([n,a])=>{r.has(n)||s.set(n,a)}),new U({fragments:jt(A.fragments||A.fragment),progression:t!==void 0&&t>=0&&t<=1?t:void 0,totalProgression:i!==void 0&&i>=0&&i<=1?i:void 0,position:o!==void 0&&o>0?o:void 0,otherLocations:s.size===0?void 0:s})}serialize(){const A={};return this.fragments&&(A.fragments=this.fragments),this.progression!==void 0&&(A.progression=this.progression),this.totalProgression!==void 0&&(A.totalProgression=this.totalProgression),this.position!==void 0&&(A.position=this.position),this.otherLocations&&this.otherLocations.forEach((t,i)=>A[i]=t),A}}class eA{constructor(A){this.after=A.after,this.before=A.before,this.highlight=A.highlight}static deserialize(A){if(A)return new eA({after:A.after,before:A.before,highlight:A.highlight})}serialize(){const A={};return this.after!==void 0&&(A.after=this.after),this.before!==void 0&&(A.before=this.before),this.highlight!==void 0&&(A.highlight=this.highlight),A}}class P{constructor(A){this.href=A.href,this.type=A.type,this.title=A.title,this.locations=A.locations?A.locations:new U({}),this.text=A.text}static deserialize(A){if(A&&A.href&&A.type)return new P({href:A.href,type:A.type,title:A.title,locations:U.deserialize(A.locations),text:eA.deserialize(A.text)})}serialize(){const A={href:this.href,type:this.type};return this.title!==void 0&&(A.title=this.title),this.locations&&(A.locations=this.locations.serialize()),this.text&&(A.text=this.text.serialize()),A}copyWithLocations(A){return new P({href:this.href,type:this.type,title:this.title,text:this.text,locations:new U({...this.locations,...A})})}}class oA{constructor(A){this.href=A.href,this.templated=A.templated,this.type=A.type,this.title=A.title,this.rels=A.rels,this.properties=A.properties,this.height=A.height,this.width=A.width,this.duration=A.duration,this.bitrate=A.bitrate,this.languages=A.languages,this.alternates=A.alternates,this.children=A.children}static deserialize(A){if(A&&A.href&&typeof A.href=="string")return new oA({href:A.href,templated:A.templated,type:A.type,title:A.title,rels:A.rel?A.rel instanceof Array?new Set(A.rel):new Set([A.rel]):void 0,properties:E.deserialize(A.properties),height:R(A.height),width:R(A.width),duration:R(A.duration),bitrate:R(A.bitrate),languages:jt(A.language),alternates:fA.deserialize(A.alternate),children:fA.deserialize(A.children)})}serialize(){const A={href:this.href};return this.templated!==void 0&&(A.templated=this.templated),this.type!==void 0&&(A.type=this.type),this.title!==void 0&&(A.title=this.title),this.rels&&(A.rel=fe(this.rels)),this.properties&&(A.properties=this.properties.serialize()),this.height!==void 0&&(A.height=this.height),this.width!==void 0&&(A.width=this.width),this.duration!==void 0&&(A.duration=this.duration),this.bitrate!==void 0&&(A.bitrate=this.bitrate),this.languages&&(A.language=this.languages),this.alternates&&(A.alternate=this.alternates.serialize()),this.children&&(A.children=this.children.serialize()),A}get mediaType(){return this.type!==void 0?M.parse({mediaType:this.type}):M.BINARY}toURL(A){const t=this.href.replace(/^(\/)/,"");if(t.length===0)return;let i=A||"/";return i.startsWith("/")&&(i="file://"+i),new URL(t,i).href.replace(/^(file:\/\/)/,"")}get templateParameters(){return this.templated?new bt(this.href).parameters:new Set}expandTemplate(A){return new oA({href:new bt(this.href).expand(A),templated:!1})}addProperties(A){var t;const i=oA.deserialize(this.serialize());return i.properties=i.properties?(t=i.properties)==null?void 0:t.add(A):new E(A),i}get locator(){let A=this.href.split("#");return new P({href:A.length>0&&A[0]!==void 0?A[0]:this.href,type:this.type??"",title:this.title,locations:new U({fragments:A.length>1&&A[1]!==void 0?[A[1]]:[]})})}}class fA{constructor(A){this.items=A}static deserialize(A){if(A&&A instanceof Array)return new fA(A.map(t=>oA.deserialize(t)).filter(t=>t!==void 0))}serialize(){return this.items.map(A=>A.serialize())}findWithRel(A){const t=i=>i.rels&&i.rels.has(A);return this.items.find(t)}filterByRel(A){const t=i=>i.rels&&i.rels.has(A);return this.items.filter(t)}findWithHref(A){const t=i=>i.href===A;return this.items.find(t)}findIndexWithHref(A){const t=i=>i.href===A;return this.items.findIndex(t)}findWithMediaType(A){const t=i=>i.mediaType.matches(A);return this.items.find(t)}filterByMediaType(A){const t=i=>i.mediaType.matches(A);return this.items.filter(t)}filterByMediaTypes(A){const t=i=>{for(const o of A)if(i.mediaType.matches(o))return!0;return!1};return this.items.filter(t)}everyIsAudio(){const A=t=>t.mediaType.isAudio;return this.items.length>0&&this.items.every(A)}everyIsBitmap(){const A=t=>t.mediaType.isBitmap;return this.items.length>0&&this.items.every(A)}everyIsHTML(){const A=t=>t.mediaType.isHTML;return this.items.length>0&&this.items.every(A)}everyIsVideo(){const A=t=>t.mediaType.isVideo;return this.items.length>0&&this.items.every(A)}everyMatchesMediaType(A){return Array.isArray(A)?this.items.length>0&&this.items.every(t=>{for(const i of A)return t.mediaType.matches(i);return!1}):this.items.length>0&&this.items.every(t=>t.mediaType.matches(A))}filterLinksHasType(){return this.items.filter(A=>A.type)}}class pA{constructor(A){this.cssSelector=A.cssSelector,this.textNodeIndex=A.textNodeIndex,this.charOffset=A.charOffset}static deserialize(A){if(!(A&&A.cssSelector))return;let t=R(A.textNodeIndex);if(t===void 0)return;let i=R(A.charOffset);return i===void 0&&(i=R(A.offset)),new pA({cssSelector:A.cssSelector,textNodeIndex:t,charOffset:i})}serialize(){const A={cssSelector:this.cssSelector,textNodeIndex:this.textNodeIndex};return this.charOffset!==void 0&&(A.charOffset=this.charOffset),A}}class kA{constructor(A){this.start=A.start,this.end=A.end}static deserialize(A){if(!A)return;let t=pA.deserialize(A.start);if(t)return new kA({start:t,end:pA.deserialize(A.end)})}serialize(){const A={start:this.start.serialize()};return this.end&&(A.end=this.end.serialize()),A}}U.prototype.getCssSelector=function(){var e;return(e=this.otherLocations)==null?void 0:e.get("cssSelector")},U.prototype.getPartialCfi=function(){var e;return(e=this.otherLocations)==null?void 0:e.get("partialCfi")},U.prototype.getDomRange=function(){var e;return kA.deserialize((e=this.otherLocations)==null?void 0:e.get("domRange"))},U.prototype.fragmentParameters=function(){return new Map(this.fragments.map(e=>e.startsWith("#")?e.slice(1):e).join("&").split("&").filter(e=>!e.startsWith("#")).map(e=>e.split("=")).filter(e=>e.length===2).map(e=>[e[0].trim().toLowerCase(),e[1].trim()]))},U.prototype.htmlId=function(){if(!this.fragments.length)return;let e=this.fragments.find(A=>A.length&&!A.includes("="));if(!e){const A=this.fragmentParameters();A.has("id")?e=A.get("id"):A.has("name")&&(e=A.get("name"))}return e!=null&&e.startsWith("#")?e.slice(1):e},U.prototype.page=function(){const e=parseInt(this.fragmentParameters().get("page"));if(!isNaN(e)&&e>=0)return e},U.prototype.time=function(){const e=parseInt(this.fragmentParameters().get("t"));if(!isNaN(e))return e},U.prototype.space=function(){const e=this.fragmentParameters();if(!e.has("xywh"))return;const A=e.get("xywh").split(",").map(t=>parseInt(t));if(A.length===4&&!A.some(isNaN))return A};class SA{constructor(A){this.currency=A.currency,this.value=A.value}static deserialize(A){if(!A)return;let t=A.currency;if(!(t&&typeof t=="string"&&t.length>0))return;let i=R(A.value);if(i!==void 0)return new SA({currency:t,value:i})}serialize(){return{currency:this.currency,value:this.value}}}class gA{constructor(A){this.type=A.type,this.children=A.children}static deserialize(A){if(A&&A.type)return new gA({type:A.type,children:gA.deserializeArray(A.children)})}static deserializeArray(A){if(A instanceof Array)return A.map(t=>gA.deserialize(t)).filter(t=>t!==void 0)}serialize(){const A={type:this.type};return this.children&&(A.children=this.children.map(t=>t.serialize())),A}}class JA{constructor(A){this.total=A.total,this.position=A.position}static deserialize(A){if(A)return new JA({total:R(A.total),position:R(A.position)})}serialize(){const A={};return this.total!==void 0&&(A.total=this.total),this.position!==void 0&&(A.position=this.position),A}}class OA{constructor(A){this.total=A.total,this.available=A.available}static deserialize(A){if(A)return new OA({total:R(A.total),available:R(A.available)})}serialize(){const A={};return this.total!==void 0&&(A.total=this.total),this.available!==void 0&&(A.available=this.available),A}}class XA{constructor(A){this.state=A.state,this.since=A.since,this.until=A.until}static deserialize(A){if(A&&A.state)return new XA({state:A.state,since:Vt(A.since),until:Vt(A.until)})}serialize(){const A={state:this.state};return this.since!==void 0&&(A.since=this.since.toISOString()),this.until!==void 0&&(A.until=this.until.toISOString()),A}}E.prototype.getNumberOfItems=function(){return R(this.otherProperties.numberOfItems)},E.prototype.getPrice=function(){return SA.deserialize(this.otherProperties.price)},E.prototype.getIndirectAcquisitions=function(){const e=this.otherProperties.indirectAcquisition;if(e&&e instanceof Array)return e.map(A=>gA.deserialize(A)).filter(A=>A!==void 0)},E.prototype.getHolds=function(){return JA.deserialize(this.otherProperties.holds)},E.prototype.getCopies=function(){return OA.deserialize(this.otherProperties.copies)},E.prototype.getAvailability=function(){return XA.deserialize(this.otherProperties.availability)},E.prototype.getAuthenticate=function(){return oA.deserialize(this.otherProperties.authenticate)},E.prototype.getClipped=function(){return this.otherProperties.clipped},E.prototype.getFit=function(){return this.otherProperties.fit},E.prototype.getOrientation=function(){return this.otherProperties.orientation},E.prototype.getOverflow=function(){return this.otherProperties.overflow},E.prototype.getPage=function(){return this.otherProperties.page||void 0},E.prototype.getSpread=function(){return this.otherProperties.spread||void 0};function Nt(e){return e.split("").reverse().join("")}function pe(e,A,t){const i=Nt(A);return t.map(o=>{const s=Math.max(0,o.end-A.length-o.errors),r=Nt(e.slice(s,o.end));return{start:Pt(r,i,o.errors).reduce((n,a)=>o.end-a.end<n?o.end-a.end:n,o.end),end:o.end,errors:o.errors}})}function qA(e){return(e|-e)>>31&1}function Tt(e,A,t,i){let o=e.P[t],s=e.M[t];const r=i>>>31,n=A[t]|r,a=n|s,c=(n&o)+o^o|n;let B=s|~(c|o),h=o&c;const g=qA(B&e.lastRowMask[t])-qA(h&e.lastRowMask[t]);return B<<=1,h<<=1,h|=r,B|=qA(i)-r,o=h|~(a|B),s=B&a,e.P[t]=o,e.M[t]=s,g}function Pt(e,A,t){if(A.length===0)return[];t=Math.min(t,A.length);const i=[],o=32,s=Math.ceil(A.length/o)-1,r={P:new Uint32Array(s+1),M:new Uint32Array(s+1),lastRowMask:new Uint32Array(s+1)};r.lastRowMask.fill(1<<31),r.lastRowMask[s]=1<<(A.length-1)%o;const n=new Uint32Array(s+1),a=new Map,c=[];for(let g=0;g<256;g++)c.push(n);for(let g=0;g<A.length;g+=1){const I=A.charCodeAt(g);if(a.has(I))continue;const d=new Uint32Array(s+1);a.set(I,d),I<c.length&&(c[I]=d);for(let l=0;l<=s;l+=1){d[l]=0;for(let F=0;F<o;F+=1){const u=l*o+F;u>=A.length||A.charCodeAt(u)===I&&(d[l]|=1<<F)}}}let B=Math.max(0,Math.ceil(t/o)-1);const h=new Uint32Array(s+1);for(let g=0;g<=B;g+=1)h[g]=(g+1)*o;h[s]=A.length;for(let g=0;g<=B;g+=1)r.P[g]=-1,r.M[g]=0;for(let g=0;g<e.length;g+=1){const I=e.charCodeAt(g);let d;I<c.length?d=c[I]:(d=a.get(I),typeof d>"u"&&(d=n));let l=0;for(let F=0;F<=B;F+=1)l=Tt(r,d,F,l),h[F]+=l;if(h[B]-l<=t&&B<s&&(d[B+1]&1||l<0)){B+=1,r.P[B]=-1,r.M[B]=0;let F;if(B===s){const u=A.length%o;F=u===0?o:u}else F=o;h[B]=h[B-1]+F-l+Tt(r,d,B,l)}else for(;B>0&&h[B]>=t+o;)B-=1;B===s&&h[B]<=t&&(h[B]<t&&i.splice(0,i.length),i.push({start:-1,end:g+1,errors:h[B]}),t=h[B])}return i}function Ye(e,A,t){const i=Pt(e,A,t);return pe(e,A,i)}function Wt(e,A,t){let i=0;const o=[];for(;i!==-1;)i=e.indexOf(A,i),i!==-1&&(o.push({start:i,end:i+A.length,errors:0}),i+=1);return o.length>0?o:Ye(e,A,t)}function kt(e,A){return A.length===0||e.length===0?0:1-Wt(e,A,A.length)[0].errors/A.length}function Ee(e,A,t={}){if(A.length===0)return null;const i=Math.min(256,A.length/2),o=Wt(e,A,i);if(o.length===0)return null;const s=n=>{const a=1-n.errors/A.length,c=t.prefix?kt(e.slice(Math.max(0,n.start-t.prefix.length),n.start),t.prefix):1,B=t.suffix?kt(e.slice(n.end,n.end+t.suffix.length),t.suffix):1;let h=1;typeof t.hint=="number"&&(h=1-Math.abs(n.start-t.hint)/e.length);const g=50*a+20*c+20*B+2*h,I=50+20+20+2;return g/I},r=o.map(n=>({start:n.start,end:n.end,score:s(n)}));return r.sort((n,a)=>a.score-n.score),r[0]}function KA(e,A,t){const i=t===1?A:A-1;if(e.charAt(i).trim()!=="")return A;let o,s;if(t===2?(o=e.substring(0,A),s=o.trimEnd()):(o=e.substring(A),s=o.trimStart()),!s.length)return-1;const r=o.length-s.length;return t===2?A-r:A+r}function St(e,A){const t=e.commonAncestorContainer.ownerDocument.createNodeIterator(e.commonAncestorContainer,NodeFilter.SHOW_TEXT),i=A===1?e.startContainer:e.endContainer,o=A===1?e.endContainer:e.startContainer;let s=t.nextNode();for(;s&&s!==i;)s=t.nextNode();A===2&&(s=t.previousNode());let r=-1;const n=()=>{if(s=A===1?t.nextNode():t.previousNode(),s){const a=s.textContent,c=A===1?0:a.length;r=KA(a,c,A)}};for(;s&&r===-1&&s!==o;)n();if(s&&r>=0)return{node:s,offset:r};throw new RangeError("No text nodes with non-whitespace text found in range")}function ve(e){if(!e.toString().trim().length)throw new RangeError("Range contains no non-whitespace text");if(e.startContainer.nodeType!==Node.TEXT_NODE)throw new RangeError("Range startContainer is not a text node");if(e.endContainer.nodeType!==Node.TEXT_NODE)throw new RangeError("Range endContainer is not a text node");const A=e.cloneRange();let t=!1,i=!1;const o={start:KA(e.startContainer.textContent,e.startOffset,1),end:KA(e.endContainer.textContent,e.endOffset,2)};if(o.start>=0&&(A.setStart(e.startContainer,o.start),t=!0),o.end>0&&(A.setEnd(e.endContainer,o.end),i=!0),t&&i)return A;if(!t){const{node:s,offset:r}=St(A,1);s&&r>=0&&A.setStart(s,r)}if(!i){const{node:s,offset:r}=St(A,2);s&&r>0&&A.setEnd(s,r)}return A}function Jt(e){var A;switch(e.nodeType){case Node.ELEMENT_NODE:case Node.TEXT_NODE:return((A=e.textContent)==null?void 0:A.length)??0;default:return 0}}function Ot(e){let A=e.previousSibling,t=0;for(;A;)t+=Jt(A),A=A.previousSibling;return t}function Xt(e,...A){let t=A.shift();const i=e.ownerDocument.createNodeIterator(e,NodeFilter.SHOW_TEXT),o=[];let s=i.nextNode(),r,n=0;for(;t!==void 0&&s;)r=s,n+r.data.length>t?(o.push({node:r,offset:t-n}),t=A.shift()):(s=i.nextNode(),n+=r.data.length);for(;t!==void 0&&r&&n===t;)o.push({node:r,offset:r.data.length}),t=A.shift();if(t!==void 0)throw new RangeError("Offset exceeds text length");return o}class V{constructor(A,t){if(t<0)throw new Error("Offset is invalid");this.element=A,this.offset=t}relativeTo(A){if(!A.contains(this.element))throw new Error("Parent is not an ancestor of current element");let t=this.element,i=this.offset;for(;t!==A;)i+=Ot(t),t=t.parentElement;return new V(t,i)}resolve(A={}){try{return Xt(this.element,this.offset)[0]}catch(t){if(this.offset===0&&A.direction!==void 0){const i=document.createTreeWalker(this.element.getRootNode(),NodeFilter.SHOW_TEXT);i.currentNode=this.element;const o=A.direction===1,s=o?i.nextNode():i.previousNode();if(!s)throw t;return{node:s,offset:o?0:s.data.length}}else throw t}}static fromCharOffset(A,t){switch(A.nodeType){case Node.TEXT_NODE:return V.fromPoint(A,t);case Node.ELEMENT_NODE:return new V(A,t);default:throw new Error("Node is not an element or text node")}}static fromPoint(A,t){switch(A.nodeType){case Node.TEXT_NODE:{if(t<0||t>A.data.length)throw new Error("Text node offset is out of range");if(!A.parentElement)throw new Error("Text node has no parent");const i=Ot(A)+t;return new V(A.parentElement,i)}case Node.ELEMENT_NODE:{if(t<0||t>A.childNodes.length)throw new Error("Child node offset is out of range");let i=0;for(let o=0;o<t;o++)i+=Jt(A.childNodes[o]);return new V(A,i)}default:throw new Error("Point is not in an element or text node")}}}class W{constructor(A,t){this.start=A,this.end=t}relativeTo(A){return new W(this.start.relativeTo(A),this.end.relativeTo(A))}toRange(){let A,t;this.start.element===this.end.element&&this.start.offset<=this.end.offset?[A,t]=Xt(this.start.element,this.start.offset,this.end.offset):(A=this.start.resolve({direction:1}),t=this.end.resolve({direction:2}));const i=new Range;return i.setStart(A.node,A.offset),i.setEnd(t.node,t.offset),i}static fromRange(A){const t=V.fromPoint(A.startContainer,A.startOffset),i=V.fromPoint(A.endContainer,A.endOffset);return new W(t,i)}static fromOffsets(A,t,i){return new W(new V(A,t),new V(A,i))}static trimmedRange(A){return ve(W.fromRange(A).toRange())}}class YA{constructor(A,t,i){this.root=A,this.start=t,this.end=i}static fromRange(A,t){const i=W.fromRange(t).relativeTo(A);return new YA(A,i.start.offset,i.end.offset)}static fromSelector(A,t){return new YA(A,t.start,t.end)}toSelector(){return{type:"TextPositionSelector",start:this.start,end:this.end}}toRange(){return W.fromOffsets(this.root,this.start,this.end).toRange()}}class EA{constructor(A,t,i={}){this.root=A,this.exact=t,this.context=i}static fromRange(A,t){const i=A.textContent,o=W.fromRange(t).relativeTo(A),s=o.start.offset,r=o.end.offset,n=32;return new EA(A,i.slice(s,r),{prefix:i.slice(Math.max(0,s-n),s),suffix:i.slice(r,Math.min(i.length,r+n))})}static fromSelector(A,t){const{prefix:i,suffix:o}=t;return new EA(A,t.exact,{prefix:i,suffix:o})}toSelector(){return{type:"TextQuoteSelector",exact:this.exact,prefix:this.context.prefix,suffix:this.context.suffix}}toRange(A={}){return this.toPositionAnchor(A).toRange()}toPositionAnchor(A={}){const t=this.root.textContent,i=Ee(t,this.exact,{...this.context,hint:A.hint});if(!i)throw new Error("Quote not found");return new YA(this.root,i.start,i.end)}}function ZA(e,A){try{let i=A.locations,o=A.text;if(o&&o.highlight){let s;i&&i.getCssSelector()&&(s=e.querySelector(i.getCssSelector())),s||(s=e.body);let r=new EA(s,o.highlight,{prefix:o.before,suffix:o.after});try{return r.toRange()}catch{return console.warn("Quote not found:",r),null}}if(i){var t=null;if(!t&&i.getCssSelector()&&(t=e.querySelector(i.getCssSelector())),!t&&i.fragments){for(const s of i.fragments)if(t=e.getElementById(s),t)break}if(t){let s=e.createRange();return t.childNodes.length===0?(s.selectNodeContents(t),s):(s.setStartBefore(t),s.setEndAfter(t),s)}}}catch(i){console.error(i)}return null}function H(e){const A=e.getSelection();A&&A.removeAllRanges()}const Ue=["a","audio","button","canvas","details","input","label","option","select","submit","textarea","video"];function qt(e){var A;return Ue.indexOf(e.nodeName.toLowerCase())!==-1||e.hasAttribute("contenteditable")&&((A=e.getAttribute("contenteditable"))==null?void 0:A.toLowerCase())!=="false"?e:e.parentElement?qt(e.parentElement):null}function Kt(e,A){const t=Zt(e,e.document.body,A);return new P({href:"#",type:"application/xhtml+xml",locations:new U({otherLocations:new Map([["cssSelector",e._readium_cssSelectorGenerator.getCssSelector(t)]])}),text:new eA({highlight:t.textContent||void 0})})}function Zt(e,A,t){for(var i=0;i<A.children.length;i++){const o=A.children[i];if(!Ce(o)&&ye(e,o,t))return Zt(e,o,t)}return A}function ye(e,A,t){if(A===document.body||A===document.documentElement)return!0;if(!document||!document.documentElement||!document.body)return!1;const i=A.getBoundingClientRect();return t?i.bottom>0&&i.top<e.innerHeight:i.right>0&&i.left<e.innerWidth}function Ce(e){const A=getComputedStyle(e);return!!(A&&(A.getPropertyValue("display")!="block"||A.getPropertyValue("opacity")==="0"))}const _t="readium-column-snapper-style",ze=200,$t=class L extends xt{constructor(){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)}doc(){return this.wnd.document.scrollingElement}scrollOffset(){return this.doc().scrollLeft>0?this.doc().scrollLeft:this.alreadyScrollLeft}snapOffset(A){const t=A+(q(this.wnd)?-1:1);return t-t%this.wnd.innerWidth}reportProgress(){this.comms.send("progress",this.wnd.scrollX/this.cachedScrollWidth)}shake(){if(this.overscroll!==0||this.shakeTimeout!==0)return;const A=this.doc();A.classList.add(q(this.wnd)?"readium-bounce-l":"readium-bounce-r");const t=this.scrollOffset();this.shakeTimeout=this.wnd.setTimeout(()=>{A.classList.remove("readium-bounce-l"),A.classList.remove("readium-bounce-r"),this.shakeTimeout=0,this.doc().scrollLeft=t},150)}takeOverSnap(){var A;this.snappingCancelled=!0,this.clearTouches();const t=this.doc();this.overscroll=((A=t.style.transform)==null?void 0:A.length)>12?parseFloat(t.style.transform.slice(12).split("px")[0]):0}snapCurrentOffset(A=!1,t=!1){const i=this.wnd.scrollX>0?this.wnd.scrollX:this.alreadyScrollLeft,o=this.doc(),s=this.dragOffset(),r=Gt(this.wnd),n=Math.min(Math.max(0,i),this.cachedScrollWidth),a=q(this.wnd)?-1:1,c=a*(this.wnd.innerWidth/3)*(a*s>0?2:1),B=this.snapOffset(n+c);if(A&&B!==this.scrollOffset()){this.snappingCancelled=!1;const h=(l,F,u,Q)=>u>Q?F:l+(F-l)*me(u/Q),g=ze*r;let I;const d=l=>{if(this.snappingCancelled)return;I||(I=l);const F=l-I,u=h(this.overscroll,0,F,g),Q=h(i,B,F,g);o.scrollLeft=Q,this.overscroll!==0&&(o.style.transform=`translate3d(${-u}px, 0px, 0px)`),F<g?this.wnd.requestAnimationFrame(d):(this.clearTouches(),o.style.removeProperty("transform"),o.scrollLeft=B,t||this.reportProgress())};this.wnd.requestAnimationFrame(d)}else o.style.removeProperty("transform"),this.wnd.requestAnimationFrame(()=>{o.scrollLeft=B,this.clearTouches(),t||this.reportProgress()})}dragOffset(){return(this.startingX??0)-(this.endingX??0)}clearTouches(){this.startingX=void 0,this.endingX=void 0,this.overscroll=0}onTouchStart(A){switch(A.stopPropagation(),this.takeOverSnap(),A.touches.length){case 1:break;case 2:this.onTouchEnd(A);return;default:{this.onTouchEnd(A),this.comms.send("tap_more",A.touches.length);return}}this.startingX=A.touches[0].clientX,this.alreadyScrollLeft=this.doc().scrollLeft,this.touchState=1}onTouchEnd(A){if(this.touchState===2){const t=this.dragOffset(),i=this.scrollOffset();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)}this.touchState=0}onWidthChange(){this.cachedScrollWidth=this.doc().scrollWidth,this.comms.ready&&this.snapCurrentOffset()}onTouchMove(A){if(this.touchState===0)return;this.touchState===1&&(this.touchState=2,H(this.wnd)),this.endingX=A.touches[0].clientX;const t=this.dragOffset(),i=this.alreadyScrollLeft+t;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)}mount(A,t){if(this.wnd=A,this.comms=t,!super.mount(A,t))return!1;const i=A.document.createElement("style");i.dataset.readium="true",i.id=_t,i.textContent=`
|
|
32
|
+
@keyframes readium-bounce-l-animation {
|
|
33
|
+
0%, 100% {transform: translate3d(0, 0, 0);}
|
|
34
|
+
50% {transform: translate3d(-50px, 0, 0);}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@keyframes readium-bounce-r-animation {
|
|
38
|
+
0%, 100% {transform: translate3d(0, 0, 0);}
|
|
39
|
+
50% {transform: translate3d(50px, 0, 0);}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.readium-bounce-l {
|
|
43
|
+
animation: readium-bounce-l-animation 150ms ease-out 1;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.readium-bounce-r {
|
|
47
|
+
animation: readium-bounce-r-animation 150ms ease-out 1;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
html {
|
|
51
|
+
overflow: hidden;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
body {
|
|
55
|
+
-ms-overflow-style: none; /* for Internet Explorer, Edge */
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
* {
|
|
59
|
+
scrollbar-width: none; /* for Firefox */
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
body::-webkit-scrollbar {
|
|
63
|
+
display: none; /* for Chrome, Safari, and Opera */
|
|
64
|
+
}
|
|
65
|
+
`,A.document.head.appendChild(i);const o=A.ResizeObserver||Dt;this.resizeObserver=new o(()=>A.requestAnimationFrame(()=>{A&&Fe(A)})),this.resizeObserver.observe(A.document.body),this.mutationObserver=new MutationObserver(()=>{this.wnd.requestAnimationFrame(()=>this.cachedScrollWidth=this.doc().scrollWidth)}),A.frameElement&&this.mutationObserver.observe(A.frameElement,{attributes:!0,attributeFilter:["style"]}),this.mutationObserver.observe(A.document,{attributes:!0,attributeFilter:["style"]});const s=r=>{const n=this.doc().scrollLeft;return this.doc().scrollLeft=this.snapOffset(r),n!==this.doc().scrollLeft};return A.addEventListener("orientationchange",this.onWidthChanger),A.addEventListener("resize",this.onWidthChanger),A.requestAnimationFrame(()=>this.cachedScrollWidth=this.doc().scrollWidth),t.register("go_progression",L.moduleName,(r,n)=>{const a=r;if(a<0||a>1){t.send("error",{message:"go_progression must be given a position from 0.0 to 1.0"}),n(!1);return}this.wnd.requestAnimationFrame(()=>{this.cachedScrollWidth=this.doc().scrollWidth;const c=this.cachedScrollWidth,B=q(A)?-1:1,h=c*a*B;this.doc().scrollLeft=this.snapOffset(h),this.reportProgress(),H(this.wnd),n(!0)})}),t.register("go_id",L.moduleName,(r,n)=>{const a=A.document.getElementById(r);if(!a){n(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollLeft=this.snapOffset(a.getBoundingClientRect().left+A.scrollX),this.reportProgress(),H(this.wnd),n(!0)})}),t.register("go_text",L.moduleName,(r,n)=>{let a;Array.isArray(r)&&(r.length>1&&(a=r[1]),r=r[0]);const c=eA.deserialize(r),B=ZA(this.wnd.document,new P({href:A.location.href,type:"text/html",text:c,locations:a?new U({otherLocations:new Map([["cssSelector",a]])}):void 0}));if(!B){n(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollLeft=this.snapOffset(B.getBoundingClientRect().left+A.scrollX),this.reportProgress(),H(this.wnd),n(!0)})}),t.register("go_end",L.moduleName,(r,n)=>{const a=q(A)?-1:1;this.wnd.requestAnimationFrame(()=>{this.cachedScrollWidth=this.doc().scrollWidth;const c=this.cachedScrollWidth*a;if(this.doc().scrollLeft===c)return n(!1);this.doc().scrollLeft=this.snapOffset(c),this.reportProgress(),H(this.wnd),n(!0)})}),t.register("go_start",L.moduleName,(r,n)=>{this.wnd.requestAnimationFrame(()=>{if(this.doc().scrollLeft===0)return n(!1);this.doc().scrollLeft=0,this.reportProgress(),H(this.wnd),n(!0)})}),t.register("go_prev",L.moduleName,(r,n)=>{this.wnd.requestAnimationFrame(()=>{const a=A.scrollX-A.innerWidth,c=q(A)?-(this.cachedScrollWidth-A.innerWidth):0,B=s(Math.max(a,c));B&&(this.reportProgress(),H(this.wnd)),n(B)})}),t.register("go_next",L.moduleName,(r,n)=>{this.wnd.requestAnimationFrame(()=>{const a=A.scrollX+A.innerWidth,c=q(A)?0:this.cachedScrollWidth-A.innerWidth,B=s(Math.min(a,c));B&&(this.reportProgress(),H(this.wnd)),n(B)})}),t.register("unfocus",L.moduleName,(r,n)=>{this.snappingCancelled=!0,H(this.wnd),n(!0)}),t.register("shake",L.moduleName,(r,n)=>{this.shake(),n(!0)}),t.register("focus",L.moduleName,(r,n)=>{this.wnd.requestAnimationFrame(()=>{this.cachedScrollWidth=this.doc().scrollWidth,this.snapCurrentOffset(!1,!0),this.reportProgress(),n(!0)})}),t.register("first_visible_locator",L.moduleName,(r,n)=>{const a=Kt(A,!1);this.comms.send("first_visible_locator",a.serialize()),n(!0)}),A.addEventListener("touchstart",this.onTouchStarter,{passive:!0}),A.addEventListener("touchend",this.onTouchEnder,{passive:!0}),A.addEventListener("touchmove",this.onTouchMover,{passive:!0}),A.document.addEventListener("touchstart",()=>{}),t.log("ColumnSnapper Mounted"),!0}unmount(A,t){var i;return this.snappingCancelled=!0,t.unregisterAll(L.moduleName),this.resizeObserver.disconnect(),this.mutationObserver.disconnect(),A.removeEventListener("touchstart",this.onTouchStarter),A.removeEventListener("touchend",this.onTouchEnder),A.removeEventListener("touchmove",this.onTouchMover),A.removeEventListener("orientationchange",this.onWidthChanger),A.removeEventListener("resize",this.onWidthChanger),(i=A.document.getElementById(_t))==null||i.remove(),t.log("ColumnSnapper Unmounted"),super.unmount(A,t)}};$t.moduleName="column_snapper";let He=$t;const vA={top:"js-iframe-reader-top-anchor",bottom:"js-iframe-reader-bottom-anchor"};class De extends HTMLElement{connectedCallback(){this.setAttribute("aria-hidden","true"),this.style.setProperty("display","block","important"),this.style.setProperty("padding","0","important"),this.style.setProperty("margin","0","important"),this.style.setProperty("visibility","hidden","important")}}function Re(e){const A=e.getElementsByTagName("body")[0],t=document.createElement("anchor-observer"),i=document.createElement("anchor-observer");t.dataset.readium="true",i.dataset.readium="true",t==null||t.setAttribute("id",vA.top),t==null||t.style.setProperty("height","115px","important"),i==null||i.setAttribute("id",vA.bottom),i==null||i.style.setProperty("height","80px","important"),A==null||A.insertBefore(t,A.firstChild),A==null||A.appendChild(i)}function Le(e){var A,t;const i=e.getElementsByTagName("body")[0],o=i==null?void 0:i.querySelector(`#${vA.top}`),s=i==null?void 0:i.querySelector(`#${vA.bottom}`);o&&((A=o.parentElement)==null||A.removeChild(o)),s&&((t=s.parentElement)==null||t.removeChild(s))}const Ai="readium-scroll-snapper-style",ti=class b extends xt{constructor(){super(...arguments),this.createAnchorElements=()=>{Re(this.doc())},this.removeAnchorElements=()=>{Le(this.doc())},this.createCustomElement=()=>{customElements.get("anchor-observer")||customElements.define("anchor-observer",De)}}doc(){return this.wnd.document.scrollingElement}reportProgress(A){this.comms.send("progress",A)}mount(A,t){this.wnd=A,this.comms=t;const i=A.document.createElement("style");return i.dataset.readium="true",i.id=Ai,i.textContent=`
|
|
66
|
+
* {
|
|
67
|
+
scrollbar-width: none; /* for Firefox */
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
body::-webkit-scrollbar {
|
|
71
|
+
display: none; /* for Chrome, Safari, and Opera */
|
|
72
|
+
}
|
|
73
|
+
`,A.document.head.appendChild(i),t.register("go_progression",b.moduleName,(o,s)=>{const r=o;if(r<0||r>1){t.send("error",{message:"go_progression must be given a position from 0.0 to 1.0"}),s(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=this.doc().offsetHeight*r,this.reportProgress(r),H(this.wnd),s(!0)})}),t.register("go_id",b.moduleName,(o,s)=>{const r=A.document.getElementById(o);if(!r){s(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=r.getBoundingClientRect().top+A.scrollY-A.innerHeight/2,this.reportProgress(this.doc().scrollTop/this.doc().offsetHeight),H(this.wnd),s(!0)})}),t.register("go_text",b.moduleName,(o,s)=>{let r;Array.isArray(o)&&(o.length>1&&(r=o[1]),o=o[0]);const n=eA.deserialize(o),a=ZA(this.wnd.document,new P({href:A.location.href,type:"text/html",text:n,locations:r?new U({otherLocations:new Map([["cssSelector",r]])}):void 0}));if(!a){s(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=a.getBoundingClientRect().top+A.scrollY-A.innerHeight/2,this.reportProgress(this.doc().scrollTop/this.doc().offsetHeight),H(this.wnd),s(!0)})}),t.register("go_start",b.moduleName,(o,s)=>{if(this.doc().scrollTop===0)return s(!1);this.doc().scrollTop=0,this.reportProgress(0),s(!0)}),t.register("go_end",b.moduleName,(o,s)=>{if(this.doc().scrollTop===0)return s(!1);this.doc().scrollTop=0,this.reportProgress(0),s(!0)}),t.register("unfocus",b.moduleName,(o,s)=>{H(this.wnd),s(!0)}),t.register(["go_next","go_prev"],b.moduleName,(o,s)=>s(!1)),t.register("focus",b.moduleName,(o,s)=>{this.reportProgress(this.doc().scrollTop/this.doc().offsetHeight),s(!0)}),t.register("first_visible_locator",b.moduleName,(o,s)=>{const r=Kt(A,!0);this.comms.send("first_visible_locator",r.serialize()),s(!0)}),t.log("ScrollSnapper Mounted"),this.createCustomElement(),this.createAnchorElements(),!0}unmount(A,t){var i;return t.unregisterAll(b.moduleName),this.removeAnchorElements(),(i=A.document.getElementById(Ai))==null||i.remove(),t.log("ScrollSnapper Unmounted"),!0}};ti.moduleName="scroll_snapper";let xe=ti;class ii extends dA{constructor(){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)}onPointUp(A){var t,i,o,s,r;const n=this.wnd.getSelection();if(n&&((t=n.toString())==null?void 0:t.length)>0){const c=(i=n.getRangeAt(0))==null?void 0:i.getClientRects();if(!c||c.length===0)return;const B=c[0],h={text:n.toString(),x:B.x,y:B.y,width:B.width,height:B.height,targetFrameSrc:(s=(o=this.wnd)==null?void 0:o.location)==null?void 0:s.href};this.comms.send("text_selected",h)}if(this.pointerMoved){this.pointerMoved=!1;return}if(!(n!=null&&n.isCollapsed)||!A.isPrimary)return;const a=this.wnd.devicePixelRatio;A.preventDefault(),this.comms.send(A.pointerType==="touch"?"tap":"click",{defaultPrevented:A.defaultPrevented,x:A.clientX*a,y:A.clientY*a,targetFrameSrc:this.wnd.location.href,targetElement:A.target.outerHTML,interactiveElement:(r=qt(A.target))==null?void 0:r.outerHTML,cssSelector:this.wnd._readium_cssSelectorGenerator.getCssSelector(A.target)}),this.pointerMoved=!1}onPointMove(A){if(A.movementY!==void 0&&A.movementX!==void 0){(Math.abs(A.movementX)>1||Math.abs(A.movementY)>1)&&(this.pointerMoved=!0);return}this.pointerMoved=!0}onPointDown(){this.pointerMoved=!1}onContext(A){this.onPointUp(A),this.pointerMoved=!1}onClick(A){if(A.preventDefault(),!A.isTrusted){const t=new PointerEvent("pointerup",{isPrimary:!0,pointerType:"mouse",clientX:A.clientX,clientY:A.clientY});Object.defineProperty(t,"target",{writable:!1,value:A.target}),Object.defineProperty(t,"defaultPrevented",{writable:!1,value:A.defaultPrevented}),this.onPointUp(t)}}mount(A,t){return this.wnd=A,this.comms=t,A.document.addEventListener("pointerdown",this.onPointerDown),A.document.addEventListener("pointerup",this.onPointerUp),A.document.addEventListener("contextmenu",this.onContextMenu),A.document.addEventListener("pointermove",this.onPointerMove),A.document.addEventListener("click",this.onClicker),t.log("Peripherals Mounted"),!0}unmount(A,t){return A.document.removeEventListener("pointerdown",this.onPointerDown),A.document.removeEventListener("pointerup",this.onPointerUp),A.document.removeEventListener("contextmenu",this.onContextMenu),A.document.removeEventListener("pointermove",this.onPointerMove),A.document.removeEventListener("click",this.onClicker),t.log("Peripherals Unmounted"),!0}}ii.moduleName="peripherals";const ei=class st extends dA{constructor(){super(...arguments),this.mediaPlayingCount=0,this.allAnimations=new Set}wndOnErr(A){var t;(t=this.comms)==null||t.send("error",{message:A.message,filename:A.filename,lineno:A.lineno,colno:A.colno})}unblock(A){var t;for(A._readium_blockEvents=!1;((t=A._readium_blockedEvents)==null?void 0:t.length)>0;){const i=A._readium_blockedEvents.shift();switch(i[0]){case 0:Reflect.apply(i[1],i[2],i[3]);break;case 1:const o=i[1],s=i[2];A.removeEventListener(o.type,A._readium_eventBlocker,!0);const r=new Event(o.type,{bubbles:o.bubbles,cancelable:o.cancelable});s?s.dispatchEvent(r):A.dispatchEvent(r);break}}}onMediaPlayEvent(){var A;this.mediaPlayingCount++,(A=this.comms)==null||A.send("media_play",this.mediaPlayingCount)}onMediaPauseEvent(){var A;this.mediaPlayingCount>0&&this.mediaPlayingCount--,(A=this.comms)==null||A.send("media_pause",this.mediaPlayingCount)}pauseAllMedia(A){const t=A.document.querySelectorAll("audio,video");for(let i=0;i<t.length;i++)t[i].pause()}mount(A,t){this.comms=t,A.addEventListener("error",this.wndOnErr,!1),"getAnimations"in A.document&&A.document.getAnimations().forEach(o=>{o.cancel(),this.allAnimations.add(o)}),t.register("activate",st.moduleName,(o,s)=>{this.allAnimations.forEach(r=>{r.cancel(),r.play()}),s(!0)}),t.register("unfocus",st.moduleName,(o,s)=>{this.pauseAllMedia(A),this.allAnimations.forEach(r=>r.pause()),s(!0)});const i=A.document.querySelectorAll("audio,video");for(let o=0;o<i.length;o++){const s=i[o];s.addEventListener("play",this.onMediaPlayEvent,{passive:!0}),s.addEventListener("pause",this.onMediaPauseEvent,{passive:!0})}return t.log("Setup Mounted"),!0}unmount(A,t){return A.removeEventListener("error",this.wndOnErr),A.removeEventListener("play",this.onMediaPlayEvent),A.removeEventListener("pause",this.onMediaPauseEvent),this.allAnimations.forEach(i=>i.cancel()),this.allAnimations.clear(),t.log("Setup Unmounted"),!0}};ei.moduleName="setup";let oi=ei;function Ge(e,A){return e.document.documentElement.style.getPropertyValue(A)}function _A(e,A,t){e.document.documentElement.style.setProperty(A,t)}function si(e,A){e.document.documentElement.style.removeProperty(A)}const ri="readium-viewport",ni=class wA extends oi{onViewportWidthChanged(A){const t=A.target;_A(t,"--RS__viewportWidth",`${t.innerWidth}px`)}mount(A,t){if(!super.mount(A,t))return!1;const i=A.document.createElement("meta");return i.dataset.readium="true",i.setAttribute("name","viewport"),i.setAttribute("id",ri),i.setAttribute("content","width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"),A.document.head.appendChild(i),A.addEventListener("orientationchange",this.onViewportWidthChanged),A.addEventListener("resize",this.onViewportWidthChanged),this.onViewportWidthChanged({target:A}),t.register("set_property",wA.moduleName,(o,s)=>{const r=o;_A(A,r[0],r[1]),s(!0)}),t.register("remove_property",wA.moduleName,(o,s)=>{si(A,o),s(!0)}),t.register("activate",wA.moduleName,(o,s)=>{this.unblock(A),s(!0)}),t.log("ReflowableSetup Mounted"),!0}unmount(A,t){var i;return t.unregisterAll(wA.moduleName),(i=A.document.head.querySelector(`#${ri}`))==null||i.remove(),A.removeEventListener("orientationchange",this.onViewportWidthChanged),t.log("ReflowableSetup Unmounted"),super.unmount(A,t)}};ni.moduleName="reflowable_setup";let be=ni;const ai="readium-fixed-style",ci=class k extends oi{mount(A,t){if(!super.mount(A,t))return!1;const i=A.document.createElement("style");return i.id=ai,i.dataset.readium="true",i.textContent=`
|
|
74
|
+
html, body {
|
|
75
|
+
text-size-adjust: none;
|
|
76
|
+
-ms-text-size-adjust: none;
|
|
77
|
+
-webkit-text-size-adjust: none;
|
|
78
|
+
-moz-text-size-adjust: none;
|
|
79
|
+
|
|
80
|
+
/* Fight Safari pinches */
|
|
81
|
+
touch-action: none !important;
|
|
82
|
+
min-height: 100%;
|
|
83
|
+
|
|
84
|
+
/*cursor: var() TODO*/
|
|
85
|
+
}`,A.document.head.appendChild(i),t.register("set_property",k.moduleName,(o,s)=>{const r=o;_A(A,r[0],r[1]),s(!0)}),t.register("remove_property",k.moduleName,(o,s)=>{si(A,o),s(!0)}),t.register("first_visible_locator",k.moduleName,(o,s)=>s(!1)),t.register("unfocus",k.moduleName,(o,s)=>{H(A),s(!0)}),t.register(["focus","go_next","go_prev","go_id","go_end","go_start","go_text","go_progression"],k.moduleName,(o,s)=>s(!0)),t.register("activate",k.moduleName,(o,s)=>{this.unblock(A),s(!0)}),t.log("FixedSetup Mounted"),!0}unmount(A,t){var i;return t.unregisterAll(k.moduleName),(i=A.document.getElementById(ai))==null||i.remove(),t.log("FixedSetup Unmounted"),super.unmount(A,t)}};ci.moduleName="fixed_setup";let je=ci;function Ve(e,A){let t=e.getClientRects();t.length||e.commonAncestorContainer.nodeType===Node.ELEMENT_NODE&&(t=e.commonAncestorContainer.getClientRects());const i=1,o=[];for(const c of t)o.push({bottom:c.bottom,height:c.height,left:c.left,right:c.right,top:c.top,width:c.width});const s=Bi(o,i,A),r=Te(s,i),n=hi(r),a=2*2;for(let c=n.length-1;c>=0;c--){const B=n[c];if(!(B.width*B.height>a))if(n.length>1)n.splice(c,1);else break}return n}function Bi(e,A,t){for(let i=0;i<e.length;i++)for(let o=i+1;o<e.length;o++){const s=e[i],r=e[o];if(s===r)continue;const n=x(s.top,r.top,A)&&x(s.bottom,r.bottom,A),a=x(s.left,r.left,A)&&x(s.right,r.right,A);if((a&&!t||n&&!a)&&wi(s,r,A)){const c=e.filter(h=>h!==s&&h!==r),B=Ne(s,r);return c.push(B),Bi(c,A,t)}}return e}function Ne(e,A){const t=Math.min(e.left,A.left),i=Math.max(e.right,A.right),o=Math.min(e.top,A.top),s=Math.max(e.bottom,A.bottom);return{bottom:s,height:s-o,left:t,right:i,top:o,width:i-t}}function Te(e,A){const t=new Set(e);for(const i of e){if(!(i.width>1&&i.height>1)){t.delete(i);continue}for(const o of e)if(i!==o&&t.has(o)&&Pe(o,i,A)){t.delete(i);break}}return Array.from(t)}function Pe(e,A,t){return UA(e,A.left,A.top,t)&&UA(e,A.right,A.top,t)&&UA(e,A.left,A.bottom,t)&&UA(e,A.right,A.bottom,t)}function UA(e,A,t,i){return(e.left<A||x(e.left,A,i))&&(e.right>A||x(e.right,A,i))&&(e.top<t||x(e.top,t,i))&&(e.bottom>t||x(e.bottom,t,i))}function hi(e){for(let A=0;A<e.length;A++)for(let t=A+1;t<e.length;t++){const i=e[A],o=e[t];if(i!==o&&wi(i,o,-1)){let s=[],r;const n=gi(i,o);if(n.length===1)s=n,r=i;else{const c=gi(o,i);n.length<c.length?(s=n,r=i):(s=c,r=o)}const a=e.filter(c=>c!==r);return Array.prototype.push.apply(a,s),hi(a)}}return e}function gi(e,A){const t=We(A,e);if(t.height===0||t.width===0)return[e];const i=[];{const o={bottom:e.bottom,height:0,left:e.left,right:t.left,top:e.top,width:0};o.width=o.right-o.left,o.height=o.bottom-o.top,o.height!==0&&o.width!==0&&i.push(o)}{const o={bottom:t.top,height:0,left:t.left,right:t.right,top:e.top,width:0};o.width=o.right-o.left,o.height=o.bottom-o.top,o.height!==0&&o.width!==0&&i.push(o)}{const o={bottom:e.bottom,height:0,left:t.left,right:t.right,top:t.bottom,width:0};o.width=o.right-o.left,o.height=o.bottom-o.top,o.height!==0&&o.width!==0&&i.push(o)}{const o={bottom:e.bottom,height:0,left:t.right,right:e.right,top:e.top,width:0};o.width=o.right-o.left,o.height=o.bottom-o.top,o.height!==0&&o.width!==0&&i.push(o)}return i}function We(e,A){const t=Math.max(e.left,A.left),i=Math.min(e.right,A.right),o=Math.max(e.top,A.top),s=Math.min(e.bottom,A.bottom);return{bottom:s,height:Math.max(0,s-o),left:t,right:i,top:o,width:Math.max(0,i-t)}}function wi(e,A,t){return(e.left<A.right||t>=0&&x(e.left,A.right,t))&&(A.left<e.right||t>=0&&x(A.left,e.right,t))&&(e.top<A.bottom||t>=0&&x(e.top,A.bottom,t))&&(A.top<e.bottom||t>=0&&x(A.top,e.bottom,t))}function x(e,A,t){return Math.abs(e-A)<=t}const ke=window.ResizeObserver||Dt,Se="Highlight"in window,Mi=["IMG","IMAGE","AUDIO","VIDEO","SVG"];class Je{constructor(A,t,i,o){this.wnd=A,this.comms=t,this.id=i,this.name=o,this.items=[],this.lastItemId=0,this.container=void 0,this.activateable=!1,this.experimentalHighlights=!1,this.currentRender=0,Se&&(this.experimentalHighlights=!0,this.notTextFlag=new Map)}get activeable(){return this.activateable}set activeable(A){this.activateable=A}add(A){var t,i,o,s;const r=`${this.id}-${this.lastItemId++}`,n=ZA(this.wnd.document,A.locator);if(!n){this.comms.log("Can't locate DOM range for decoration",A);return}const a=n.commonAncestorContainer;a.nodeType!==Node.TEXT_NODE&&this.experimentalHighlights&&(Mi.includes(a.nodeName.toUpperCase())&&((t=this.notTextFlag)==null||t.set(r,!0)),a.querySelector(Mi.join(", ").toLowerCase())&&((i=this.notTextFlag)==null||i.set(r,!0)),(((o=a.textContent)==null?void 0:o.trim())||"").length===0&&((s=this.notTextFlag)==null||s.set(r,!0)));const c={decoration:A,id:r,range:n};this.items.push(c),this.layout(c),this.renderLayout([c])}remove(A){var t,i;const o=this.items.findIndex(r=>r.decoration.id===A);if(o<0)return;const s=this.items[o];if(this.items.splice(o,1),s.clickableElements=void 0,s.container&&(s.container.remove(),s.container=void 0),this.experimentalHighlights&&!((t=this.notTextFlag)!=null&&t.has(s.id))){const r=this.wnd.CSS.highlights.get(this.id);r==null||r.delete(s.range)}(i=this.notTextFlag)==null||i.delete(s.id)}update(A){this.remove(A.id),this.add(A)}clear(){var A;this.clearContainer(),this.items.length=0,(A=this.notTextFlag)==null||A.clear()}requestLayout(){this.wnd.cancelAnimationFrame(this.currentRender),this.clearContainer(),this.items.forEach(A=>this.layout(A)),this.renderLayout(this.items)}experimentalLayout(A){var t,i;const[o,s]=this.requireContainer(!0);s.add(A.range),o.innerHTML=`
|
|
86
|
+
::highlight(${this.id}) {
|
|
87
|
+
color: black;
|
|
88
|
+
background-color: ${((i=(t=A.decoration)==null?void 0:t.style)==null?void 0:i.tint)??"yellow"};
|
|
89
|
+
}`}layout(A){var t,i,o,s,r;if(this.experimentalHighlights&&!((t=this.notTextFlag)!=null&&t.has(A.id)))return this.experimentalLayout(A);const n=this.wnd.document.createElement("div");n.setAttribute("id",A.id),n.style.setProperty("pointer-events","none");const a=this.wnd.innerWidth,c=parseInt(getComputedStyle(this.wnd.document.documentElement).getPropertyValue("column-count")),B=a/(c||1),h=this.wnd.document.scrollingElement,g=h.scrollLeft,I=h.scrollTop,d=(m,f,y)=>{var rA,K,Z,_,CA,zA;if(m.style.position="absolute",((K=(rA=A.decoration)==null?void 0:rA.style)==null?void 0:K.width)==="viewport"){m.style.width=`${a}px`,m.style.height=`${f.height}px`;let nA=Math.floor(f.left/a)*a;m.style.left=`${nA+g}px`,m.style.top=`${f.top+I}px`}else if(((_=(Z=A.decoration)==null?void 0:Z.style)==null?void 0:_.width)==="bounds")m.style.width=`${y.width}px`,m.style.height=`${f.height}px`,m.style.left=`${y.left+g}px`,m.style.top=`${f.top+I}px`;else if(((zA=(CA=A.decoration)==null?void 0:CA.style)==null?void 0:zA.width)==="page"){m.style.width=`${B}px`,m.style.height=`${f.height}px`;let nA=Math.floor(f.left/B)*B;m.style.left=`${nA+g}px`,m.style.top=`${f.top+I}px`}else m.style.width=`${f.width}px`,m.style.height=`${f.height}px`,m.style.left=`${f.left+g}px`,m.style.top=`${f.top+I}px`},l=A.range.getBoundingClientRect();let F=this.wnd.document.createElement("template");const u=Ge(this.wnd,"--USER__appearance")==="readium-night-on";F.innerHTML=`
|
|
90
|
+
<div
|
|
91
|
+
class="r2-highlight-0"
|
|
92
|
+
style="${[`background-color: ${((o=(i=A.decoration)==null?void 0:i.style)==null?void 0:o.tint)??"yellow"} !important`,`mix-blend-mode: ${u?"exclusion":"multiply"} !important`,"opacity: 1 !important","box-sizing: border-box !important"].join("; ")}"
|
|
93
|
+
>
|
|
94
|
+
</div>
|
|
95
|
+
`.trim();const Q=F.content.firstElementChild;if(((r=(s=A.decoration)==null?void 0:s.style)==null?void 0:r.layout)==="bounds"){const m=Q.cloneNode(!0);m.style.setProperty("pointer-events","none"),d(m,l,l),n.append(m)}else{let m=Ve(A.range,!0);m=m.sort((f,y)=>f.top<y.top?-1:f.top>y.top?1:0);for(let f of m){const y=Q.cloneNode(!0);y.style.setProperty("pointer-events","none"),d(y,f,l),n.append(y)}}A.container=n,A.clickableElements=Array.from(n.querySelectorAll("[data-activable='1']")),A.clickableElements.length||(A.clickableElements=Array.from(n.children))}renderLayout(A){this.wnd.cancelAnimationFrame(this.currentRender),this.currentRender=this.wnd.requestAnimationFrame(()=>{A=A.filter(t=>{var i;return!this.experimentalHighlights||!!((i=this.notTextFlag)!=null&&i.has(t.id))}),!(!A||A.length===0)&&this.requireContainer().append(...A.map(t=>t.container).filter(t=>!!t))})}requireContainer(A=!1){if(A){let t;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));let i;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]}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}clearContainer(){this.experimentalHighlights&&this.wnd.CSS.highlights.delete(this.id),this.container&&(this.container.remove(),this.container=void 0)}}const Ii=class rt extends dA{constructor(){super(...arguments),this.resizeFrame=0,this.lastGroupId=0,this.groups=new Map,this.handleResizer=this.handleResize.bind(this)}cleanup(){this.groups.forEach(A=>A.clear()),this.groups.clear()}handleResize(){this.wnd.clearTimeout(this.resizeFrame),this.resizeFrame=this.wnd.setTimeout(()=>{this.groups.forEach(A=>{A.experimentalHighlights||A.requestLayout()})},50)}mount(A,t){return this.wnd=A,t.register("decorate",rt.moduleName,(i,o)=>{const s=i;s.decoration&&s.decoration.locator&&(s.decoration.locator=P.deserialize(s.decoration.locator)),this.groups.has(s.group)||this.groups.set(s.group,new Je(A,t,`readium-decoration-${this.lastGroupId++}`,s.group));const r=this.groups.get(s.group);switch(s.action){case"add":r==null||r.add(s.decoration);break;case"remove":r==null||r.remove(s.decoration.id);break;case"clear":r==null||r.clear();break;case"update":r==null||r.update(s.decoration);break}o(!0)}),this.resizeObserver=new ke(()=>A.requestAnimationFrame(()=>this.handleResize())),this.resizeObserver.observe(A.document.body),A.addEventListener("orientationchange",this.handleResizer),A.addEventListener("resize",this.handleResizer),t.log("Decorator Mounted"),!0}unmount(A,t){return A.removeEventListener("orientationchange",this.handleResizer),A.removeEventListener("resize",this.handleResizer),t.unregisterAll(rt.moduleName),this.resizeObserver.disconnect(),this.cleanup(),t.log("Decorator Unmounted"),!0}};Ii.moduleName="decorator";let Oe=Ii;const Xe=["fixed_setup","decorator","peripherals"],qe=["reflowable_setup","decorator","peripherals","column_snapper","scroll_snapper"],$A=new Map([je,be,ii,Oe,He,xe].map(e=>[e.moduleName,e]));class yA{constructor(A=window,t=[]){this.loadedModules=[],this.wnd=A,this.comms=new _i(A);const i=[...new Set(t)];if(i.length){if(typeof A>"u")throw Error("Loader is not in a web browser");A.parent!==A&&this.comms.log("Loader is probably in a frame"),this.loadedModules=i.map(o=>{const s=this.loadModule(o);if(s)return s.mount(this.wnd,this.comms),s}).filter(o=>o!==void 0)}}loadModule(A){const t=$A.get(A);return t===void 0?(this.comms.log(`Module "${name}" does not exist in the library`),t):new t}addModule(A){const t=this.loadModule(A);return!t||!t.mount(this.wnd,this.comms)?!1:(this.loadedModules.push(t),!0)}removeModule(A){const t=$A.get(A);if(t===void 0)return this.comms.log(`Module "${A}" does not exist in the library`),!1;const i=this.loadedModules.findIndex(o=>o instanceof t);return i<0?!1:(this.loadedModules[i].unmount(this.wnd,this.comms),this.loadedModules.splice(i,1),!0)}destroy(){this.comms.destroy(),this.loadedModules.forEach(A=>A.unmount(this.wnd,this.comms)),this.loadedModules=[]}}const Ke=1e4;class At{constructor(A,t){this.registry=new Map,this._ready=!1,this.listenerBuffer=[],this.handler=this.handle.bind(this),this.wnd=A,this.origin=t;try{this.channelId=window.crypto.randomUUID()}catch{this.channelId=jA()}this.gc=setInterval(()=>{this.registry.forEach((i,o)=>{performance.now()-i.time>Ke&&(console.warn(o,"event for",i.key,"was never handled!"),this.registry.delete(o))})},5e3),window.addEventListener("message",this.handler),this.send("_ping",void 0)}set listener(A){this.listenerBuffer.length>0&&this.listenerBuffer.forEach(t=>A(t[0],t[1])),this.listenerBuffer=[],this._listener=A}clearListener(){typeof this._listener=="function"&&(this._listener=void 0)}halt(){this._ready=!1,window.removeEventListener("message",this.handler),clearInterval(this.gc),this._listener=void 0,this.registry.clear()}resume(){window.addEventListener("message",this.handler),this._ready=!0}handle(A){const t=A.data;if(!t._readium){console.warn("Ignoring",t);return}if(t._channel===this.channelId)switch(t.key){case"_ack":{if(!t.id)return;const i=this.registry.get(t.id);if(!i)return;this.registry.delete(t.id),i.cb(!!t.data);return}case"_pong":this._ready=!0;default:{if(!this.ready)return;typeof this._listener=="function"?this._listener(t.key,t.data):this.listenerBuffer.push([t.key,t.data])}}}get ready(){return this._ready}send(A,t,i,o=!1,s=[]){const r=jA();return i&&this.registry.set(r,{cb:i,time:performance.now(),key:A}),this.wnd.postMessage({_readium:tA,_channel:this.channelId,id:r,data:t,key:A,strict:o},"/",s),r}}class di{constructor(A){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.source=A}async load(A){return new Promise((t,i)=>{var o;if(this.loader){const s=this.frame.contentWindow;if([...this.currModules].sort().join("|")===[...A].sort().join("|")){try{t(s)}catch{}return}(o=this.comms)==null||o.halt(),this.loader.destroy(),this.loader=new yA(s,A),this.currModules=A,this.comms=void 0;try{t(s)}catch{}return}this.frame.onload=()=>{const s=this.frame.contentWindow;this.loader=new yA(s,A),this.currModules=A;try{t(s)}catch{}},this.frame.onerror=s=>{try{i(s)}catch{}},this.frame.contentWindow.location.replace(this.source)})}async destroy(){var A;await this.hide(),(A=this.loader)==null||A.destroy(),this.frame.remove()}async hide(){var A;if(this.frame.style.visibility="hidden",this.frame.style.setProperty("aria-hidden","true"),this.frame.style.opacity="0",this.frame.style.pointerEvents="none",this.frame.parentElement)return this.comms===void 0?void 0:new Promise((t,i)=>{var o;(o=this.comms)==null||o.send("unfocus",void 0,s=>{var r;(r=this.comms)==null||r.halt(),t()})});(A=this.comms)==null||A.halt()}async show(A){if(!this.frame.parentElement){console.warn("Trying to show frame that is not attached to the DOM");return}return this.comms?this.comms.resume():this.comms=new At(this.frame.contentWindow,this.source),new Promise((t,i)=>{var o;(o=this.comms)==null||o.send("activate",void 0,()=>{var s;(s=this.comms)==null||s.send("focus",void 0,()=>{var n;const r=()=>{this.frame.style.removeProperty("visibility"),this.frame.style.removeProperty("aria-hidden"),this.frame.style.removeProperty("opacity"),this.frame.style.removeProperty("pointer-events"),t()};A&&A>0?(n=this.comms)==null||n.send("go_progression",A,r):r()})})})}get iframe(){return this.frame}get realSize(){return this.frame.getBoundingClientRect()}get window(){if(!this.frame.contentWindow)throw Error("Trying to use frame window when it doesn't exist");return this.frame.contentWindow}get atLeft(){return this.window.scrollX<5}get atRight(){return this.window.scrollX>this.window.document.scrollingElement.scrollWidth-this.window.innerWidth-5}get msg(){return this.comms}get ldr(){return this.loader}}const li=5,ui=3;class Fi{constructor(A,t){this.pool=new Map,this.blobs=new Map,this.inprogress=new Map,this.container=A,this.positions=t}async destroy(){let A=this.inprogress.values(),t=A.next();const i=[];for(;t.value;)i.push(t.value),t=A.next();i.length>0&&await Promise.allSettled(i),this.inprogress.clear();let o=this.pool.values(),s=o.next();for(;s.value;)await s.value.destroy(),s=o.next();this.pool.clear(),this.blobs.forEach(r=>URL.revokeObjectURL(r)),this.container.childNodes.forEach(r=>{(r.nodeType===Node.ELEMENT_NODE||r.nodeType===Node.TEXT_NODE)&&r.remove()})}async update(A,t,i,o=!1){let s=this.positions.findIndex(a=>a.locations.position===t.locations.position);if(s<0)throw Error(`Locator not found in position list: ${t.locations.position} > ${this.positions.reduce((a,c)=>c.locations.position||0>a?c.locations.position||0:a,0)}`);const r=this.positions[s].href;this.inprogress.has(r)&&await this.inprogress.get(r);const n=new Promise(async(a,c)=>{var d,l,F;const B=[],h=[];this.positions.forEach((u,Q)=>{(Q>s+li||Q<s-li)&&(B.includes(u.href)||B.push(u.href)),Q<s+ui&&Q>s-ui&&(h.includes(u.href)||h.push(u.href))}),B.forEach(async u=>{var Q;h.includes(u)||this.pool.has(u)&&(await((Q=this.pool.get(u))==null?void 0:Q.destroy()),this.pool.delete(u))}),this.currentBaseURL!==void 0&&A.baseURL!==this.currentBaseURL&&(this.blobs.forEach(u=>URL.revokeObjectURL(u)),this.blobs.clear()),this.currentBaseURL=A.baseURL;const g=async u=>{if(this.pool.has(u)){const f=this.pool.get(u);if(!this.blobs.has(u))await f.destroy(),this.pool.delete(u);else{await f.load(i);return}}const Q=A.readingOrder.findWithHref(u);if(!Q)return;if(!this.blobs.has(u)){const y=await new It(A,this.currentBaseURL||"",Q).build();this.blobs.set(u,y)}const m=new di(this.blobs.get(u));u!==r&&await m.hide(),this.container.appendChild(m.iframe),await m.load(i),this.pool.set(u,m)};try{await Promise.all(h.map(u=>g(u)))}catch(u){c(u)}const I=this.pool.get(r);if((I==null?void 0:I.source)!==((d=this._currentFrame)==null?void 0:d.source)||o){await((l=this._currentFrame)==null?void 0:l.hide()),I&&await I.load(i);const u=(((F=t==null?void 0:t.locations)==null?void 0:F.progression)??0)>0;I&&await I.show(u?t.locations.progression:void 0),this._currentFrame=I}a()});this.inprogress.set(r,n),await n,this.inprogress.delete(r)}get currentFrames(){return[this._currentFrame]}get currentBounds(){const A={x:0,y:0,width:0,height:0,top:0,right:0,bottom:0,left:0,toJSON(){return this}};return this.currentFrames.forEach(t=>{if(!t)return;const i=t.realSize;A.x=Math.min(A.x,i.x),A.y=Math.min(A.y,i.y),A.width+=i.width,A.height=Math.max(A.height,i.height),A.top=Math.min(A.top,i.top),A.right=Math.min(A.right,i.right),A.bottom=Math.min(A.bottom,i.bottom),A.left=Math.min(A.left,i.left)}),A}}class mi{constructor(A,t,i){this.currModules=[],this.cachedPage=void 0,this.peripherals=A,this.debugHref=i,this.frame=document.createElement("iframe"),this.frame.classList.add("readium-navigator-iframe"),this.frame.classList.add("blank"),this.frame.scrolling="no",this.frame.style.visibility="hidden",this.frame.style.setProperty("aria-hidden","true"),this.frame.style.display="none",this.frame.style.position="absolute",this.frame.style.pointerEvents="none",this.frame.style.transformOrigin="0 0",this.frame.style.transform="scale(1)",this.frame.style.background="#fff",this.frame.style.touchAction="none",this.frame.dataset.originalHref=i,this.source="about:blank",this.wrapper=document.createElement("div"),this.wrapper.style.position="relative",this.wrapper.style.float=this.wrapper.style.cssFloat=t===p.rtl?"right":"left",this.wrapper.appendChild(this.frame)}async load(A,t){return this.source===t&&this.loadPromise&&[...this.currModules].sort().join("|")===[...A].sort().join("|")?this.loadPromise:(this.loaded&&this.source!==t&&this.window.stop(),this.source=t,this.loadPromise=new Promise((i,o)=>{var s;if(this.loader&&this.loaded){const r=this.frame.contentWindow;if([...this.currModules].sort().join("|")===[...A].sort().join("|")){try{i(r),this.loadPromise=void 0}catch{}return}(s=this.comms)==null||s.halt(),this.loader.destroy(),this.loader=new yA(r,A),this.currModules=A,this.comms=void 0;try{i(r),this.loadPromise=void 0}catch{}return}this.frame.addEventListener("load",()=>{const r=this.frame.contentWindow;this.loader=new yA(r,A),this.currModules=A,this.peripherals.observe(this.wrapper),this.peripherals.observe(r);try{i(r)}catch{}},{once:!0}),this.frame.addEventListener("error",r=>{try{o(r.error),this.loadPromise=void 0}catch{}},{once:!0}),this.frame.style.removeProperty("display"),this.frame.contentWindow.location.replace(this.source)}),this.loadPromise)}loadPageSize(){const A=this.frame.contentWindow,t=A.document.head.querySelector("meta[name=viewport]");if(t){const i=/(\w+) *= *([^\s,]+)/g;let o,s=0,r=0;for(;o=i.exec(t.content);)o[1]==="width"?s=Number.parseFloat(o[2]):o[1]==="height"&&(r=Number.parseFloat(o[2]));if(s>0&&r>0)return{width:s,height:r}}return{width:A.document.body.scrollWidth,height:A.document.body.scrollHeight}}update(A){if(!this.loaded)return;const t=this.loadPageSize();this.frame.style.height=`${t.height}px`,this.frame.style.width=`${t.width}px`;const i=Math.min(this.wrapper.clientWidth/t.width,this.wrapper.clientHeight/t.height);this.frame.style.transform=`scale(${i})`;const o=this.frame.getBoundingClientRect(),s=this.wrapper.clientHeight-o.height;if(this.frame.style.top=`${s/2}px`,A===G.left){const r=this.wrapper.clientWidth-o.width;this.frame.style.left=`${r}px`}else if(A===G.center){const r=this.wrapper.clientWidth-o.width;this.frame.style.left=`${r/2}px`}else this.frame.style.left="0px";this.frame.style.removeProperty("visibility"),this.frame.style.removeProperty("aria-hidden"),this.frame.style.removeProperty("pointer-events"),this.frame.classList.remove("blank"),this.frame.classList.add("loaded")}async destroy(){var A;await this.unfocus(),(A=this.loader)==null||A.destroy(),this.wrapper.remove()}async unload(){var A,t;if(this.loaded)return this.deselect(),this.frame.style.visibility="hidden",this.frame.style.setProperty("aria-hidden","true"),this.frame.style.pointerEvents="none",this.frame.classList.add("blank"),this.frame.classList.remove("loaded"),(A=this.comms)==null||A.halt(),(t=this.loader)==null||t.destroy(),this.comms=void 0,this.frame.blur(),new Promise((i,o)=>{this.frame.addEventListener("load",()=>{try{this.showPromise=void 0,i()}catch{}},{once:!0}),this.frame.addEventListener("error",s=>{try{this.showPromise=void 0,o(s.error)}catch{}},{once:!0}),this.source="about:blank",this.frame.contentWindow.location.replace("about:blank"),this.frame.style.display="none"})}deselect(){var A,t;(t=(A=this.frame.contentWindow)==null?void 0:A.getSelection())==null||t.removeAllRanges()}async unfocus(){var A;if(this.frame.parentElement)return this.comms===void 0?void 0:new Promise((t,i)=>{var o;(o=this.comms)==null||o.send("unfocus",void 0,s=>{var r;(r=this.comms)==null||r.halt(),this.showPromise=void 0,t()})});(A=this.comms)==null||A.halt()}async show(A){if(!this.frame.parentElement){console.warn("Trying to show frame that is not attached to the DOM");return}if(!this.loaded){this.showPromise=void 0;return}return this.showPromise?(this.cachedPage!==A&&(this.update(A),this.cachedPage=A),this.showPromise):(this.cachedPage=A,this.comms?this.comms.resume():this.comms=new At(this.frame.contentWindow,this.source),this.showPromise=new Promise((t,i)=>{this.comms.send("focus",void 0,o=>{this.update(this.cachedPage),t()})}),this.showPromise)}async activate(){return new Promise((A,t)=>{var i;if(!this.comms)return A();(i=this.comms)==null||i.send("activate",void 0,()=>{A()})})}get element(){return this.wrapper}get iframe(){return this.frame}get realSize(){return this.frame.getBoundingClientRect()}get loaded(){return this.frame.contentWindow&&this.frame.contentWindow.location.href!=="about:blank"}set width(A){const t=`${A}%`;this.wrapper.style.width!==t&&(this.wrapper.style.width=t)}set height(A){const t=`${A}px`;this.wrapper.style.height!==t&&(this.wrapper.style.height=t)}get window(){if(!this.frame.contentWindow)throw Error("Trying to use frame window when it doesn't exist");return this.frame.contentWindow}get atLeft(){return this.window.scrollX<5}get atRight(){return this.window.scrollX>this.window.document.scrollingElement.scrollWidth-this.window.innerWidth-5}get msg(){return this.comms}get ldr(){return this.loader}}/*!
|
|
96
|
+
* (℠)
|
|
97
|
+
* # sML.js | I'm a Simple and Middling Library.
|
|
98
|
+
*
|
|
99
|
+
* * Copyright (c) Satoru MATSUSHIMA - https://github.com/satorumurmur/sML
|
|
100
|
+
* * Licensed under the MIT license. - http://www.opensource.org/licenses/mit-license.php
|
|
101
|
+
*
|
|
102
|
+
* Portions of this code come from the sML library
|
|
103
|
+
* Current version: 1.0.36
|
|
104
|
+
*/class Ze{constructor(){const A=navigator.userAgentData,t=navigator.userAgent,i=s=>(typeof s=="string"||typeof s=="number")&&s?String(s).replace(/_/g,".").split(".").map(r=>parseInt(r)||0):[],o=(s="")=>{if(!s)return[];const r=new RegExp("^.*"+s+"[ :\\/]?(\\d+([\\._]\\d+)*).*$");return r.test(t)?i(t.replace(r,"$1")):[]};this.OS=(s=>(/(macOS|Mac OS X)/.test(t)?(/\(iP(hone|od touch);/.test(t)&&(s.iOS=o("CPU (?:iPhone )?OS ")),/\(iPad;/.test(t)?s.iOS=s.iPadOS=o("CPU (?:iPhone )?OS "):/(macOS|Mac OS X) \d/.test(t)&&(document.ontouchend!==void 0?s.iOS=s.iPadOS=o():s.macOS=o("(?:macOS|Mac OS X) "))):/Windows( NT)? \d/.test(t)?s.Windows=(r=>r[0]!==6||!r[1]?r:r[1]===1?[7]:r[1]===2?[8]:[8,1])(o("Windows(?: NT)?")):/Android \d/.test(t)?s.Android=o("Android"):/CrOS/.test(t)?s.ChromeOS=o():/X11;/.test(t)&&(s.Linux=o()),s))({}),A&&A.getHighEntropyValues(["architecture","model","platform","platformVersion","uaFullVersion"]).then(s=>(r=>{const n=s.platform,a=s.platformVersion;if(!(!n||!a)){if(/^i(OS|P(hone|od touch))$/.test(n))r.iOS=i(a);else if(/^iPad(OS)?$/.test(n))r.iOS=r.iPadOS=i(a);else if(/^(macOS|(Mac )?OS X|Mac(Intel)?)$/.test(n))document.ontouchend!==void 0?r.iOS=r.iPadOS=i():r.macOS=i(a);else if(/^(Microsoft )?Windows$/.test(n))r.Windows=i(a);else if(/^(Google )?Android$/.test(n))r.Android=i(a);else if(/^((Google )?Chrome OS|CrOS)$/.test(n))r.ChromeOS=i(a);else if(/^(Linux|Ubuntu|X11)$/.test(n))r.Linux=i(a);else return;Object.keys(this.OS).forEach(c=>delete this.OS[c]),Object.assign(this.OS,r)}})({})),this.UA=(s=>{let r=!1;if(A&&Array.isArray(A.brands)){const n=A.brands.reduce((a,c)=>(a[c.brand]=[c.version*1],a),{});n["Google Chrome"]?(r=!0,s.Blink=s.Chromium=n.Chromium||[],s.Chrome=n["Google Chrome"]):n["Microsoft Edge"]?(r=!0,s.Blink=s.Chromium=n.Chromium||[],s.Edge=n["Microsoft Edge"]):n.Opera&&(r=!0,s.Blink=s.Chromium=n.Chromium||[],s.Opera=n.Opera)}return r||(/ Gecko\/\d/.test(t)?(s.Gecko=o("rv"),/ Waterfox\/\d/.test(t)?s.Waterfox=o("Waterfox"):/ Firefox\/\d/.test(t)&&(s.Firefox=o("Firefox"))):/ Edge\/\d/.test(t)?(s.EdgeHTML=o("Edge"),s.Edge=s.EdgeHTML):/ Chrom(ium|e)\/\d/.test(t)?(s.Blink=s.Chromium=(n=>n[0]?n:o("Chrome"))(o("Chromium")),/ EdgA?\/\d/.test(t)?s.Edge=(n=>n[0]?n:o("Edg"))(o("EdgA")):/ OPR\/\d/.test(t)?s.Opera=o("OPR"):/ Vivaldi\/\d/.test(t)?s.Vivaldi=o("Vivaldi"):/ Silk\/\d/.test(t)?s.Silk=o("Silk"):/ UCBrowser\/\d/.test(t)?s.UCBrowser=o("UCBrowser"):/ Phoebe\/\d/.test(t)?s.Phoebe=o("Phoebe"):s.Chrome=(n=>n[0]?n:s.Chromium)(o("Chrome"))):/ AppleWebKit\/\d/.test(t)?(s.WebKit=o("AppleWebKit"),/ CriOS \d/.test(t)?s.Chrome=o("CriOS"):/ FxiOS \d/.test(t)?s.Firefox=o("FxiOS"):/ EdgiOS\/\d/.test(t)?s.Edge=o("EdgiOS"):/ Version\/\d/.test(t)&&(s.Safari=o("Version"))):/ Trident\/\d/.test(t)&&(s.Trident=o("Trident"),s.InternetExplorer=(n=>n[0]?n:o("MSIE"))(o("rv")))),/[\[; ]FB(AN|_IAB)\//.test(t)&&(s.Facebook=o("FBAV")),/ Line\/\d/.test(t)&&(s.LINE=o("Line")),s})({}),this.Env={get:()=>[this.OS,this.UA].reduce((s,r)=>{for(const n in r)r[n]&&s.push(n);return s},[])}}}const tt=new Ze;var Qi=(e=>(e[e.Left=0]="Left",e[e.Center=1]="Center",e[e.Right=2]="Right",e))(Qi||{}),fi=(e=>(e[e.Top=0]="Top",e[e.Middle=1]="Middle",e[e.Bottom=2]="Bottom",e))(fi||{});class pi{constructor(){this.outerWidth=0,this.outerHeight=0,this.HTML=document.documentElement,this.Head=document.head,this.Body=document.body}refreshOuterPixels(A){tt.OS.iOS||(this.outerHeight=window.outerHeight-window.innerHeight,tt.OS.Android&&tt.UA.Chrome&&window.screen.height>window.innerHeight&&(this.outerHeight=(window.screen.height-window.innerHeight)/1.5),this.outerWidth=window.outerWidth-window.innerWidth)}getBibiEventCoord(A,t=0){var o;const i={X:0,Y:0};return/^touch/.test(A.type)?(i.X=A.touches[t].screenX,i.Y=A.touches[t].screenY):(i.X=A.screenX,i.Y=A.screenY),(((o=A.target.ownerDocument)==null?void 0:o.documentElement)||A.target.documentElement)===this.HTML&&(i.X-=this.HTML.scrollLeft+this.Body.scrollLeft,i.Y-=this.HTML.scrollTop+this.Body.scrollTop),i.X-=this.outerWidth,i.Y-=this.outerHeight,i}getTouchDistance(A){if(A.touches.length!==2)return 0;const t=A.touches[0].screenX-this.outerWidth,i=A.touches[0].screenY-this.outerHeight,o=A.touches[1].screenX-this.outerWidth,s=A.touches[1].screenY-this.outerHeight;return Math.sqrt(Math.pow(o-t,2)+Math.pow(s-i,2))}getTouchCenter(A){if(A.touches.length!==2)return null;const t=this.HTML.scrollLeft+this.Body.scrollLeft,i=this.HTML.scrollTop+this.Body.scrollTop,o=A.touches[0].screenX-this.outerWidth-t,s=A.touches[0].screenY-this.outerHeight-i,r=A.touches[1].screenX-this.outerWidth-t,n=A.touches[1].screenY-this.outerHeight-i;return{X:(o+r)/2,Y:(s+n)/2}}getBibiEvent(A){if(!A)return{Coord:null,Division:null,Ratio:null,Target:null};const t=this.getBibiEventCoord(A);let i=.3;const o={X:t.X/window.innerWidth,Y:t.Y/window.innerHeight};let s,r,n,a;n=s=i,a=r=1-i;const c={X:null,Y:null};return o.X<n?c.X=0:a<o.X?c.X=2:c.X=1,o.Y<s?c.Y=0:r<o.Y?c.Y=2:c.Y=1,{Target:A.target,Coord:t,Ratio:o,Division:c}}}class _e{constructor(){this._DOM={show:!1,pinchTarget:document.createElement("div"),touch1:document.createElement("div"),touch2:document.createElement("div"),center:document.createElement("div"),stats:document.createElement("div")},this._DOM.show=!0,this._DOM.pinchTarget.style.zIndex=this._DOM.stats.style.zIndex=this._DOM.center.style.zIndex=this._DOM.touch1.style.zIndex=this._DOM.touch2.style.zIndex="100000",this._DOM.pinchTarget.style.position=this._DOM.stats.style.position=this._DOM.center.style.position=this._DOM.touch1.style.position=this._DOM.touch2.style.position="absolute",this._DOM.pinchTarget.style.borderRadius=this._DOM.center.style.borderRadius=this._DOM.touch1.style.borderRadius=this._DOM.touch2.style.borderRadius="50%",this._DOM.pinchTarget.style.pointerEvents=this._DOM.stats.style.pointerEvents=this._DOM.center.style.pointerEvents=this._DOM.touch1.style.pointerEvents=this._DOM.touch2.style.pointerEvents="none",this._DOM.pinchTarget.style.display=this._DOM.center.style.display=this._DOM.touch1.style.display=this._DOM.touch2.style.display="none",this._DOM.pinchTarget.style.paddingTop=this._DOM.center.style.paddingTop="10px",this._DOM.pinchTarget.style.width=this._DOM.pinchTarget.style.height=this._DOM.center.style.width=this._DOM.center.style.height="10px",this._DOM.pinchTarget.style.backgroundColor="green",this._DOM.center.style.backgroundColor="red",this._DOM.touch1.style.backgroundColor=this._DOM.touch2.style.backgroundColor="blue",this._DOM.touch1.style.height=this._DOM.touch2.style.height="20px",this._DOM.touch1.style.width=this._DOM.touch2.style.width="20px",this._DOM.touch1.style.paddingTop=this._DOM.touch2.style.paddingTop="20px",this._DOM.touch1.textContent="1",this._DOM.touch2.textContent="2",this._DOM.stats.style.padding="20px",this._DOM.stats.style.backgroundColor="rgba(0,0,0,0.5)",this._DOM.stats.style.color="white",this._DOM.stats.textContent="[stats]",document.body.appendChild(this._DOM.stats),document.body.appendChild(this._DOM.center),document.body.appendChild(this._DOM.touch1),document.body.appendChild(this._DOM.touch2),document.body.appendChild(this._DOM.pinchTarget)}get show(){return this.DOM.show}get DOM(){return this._DOM}}const Yi=6,it=1.02,Ei=50;class vi{constructor(A,t=!1){this.dragState=0,this.minimumMoved=!1,this.pan={startX:0,endX:0,startY:0,overscrollX:0,overscrollY:0,letItGo:!1,preventClick:!1,translateX:0,translateY:0,touchID:0},this.pinch={startDistance:0,startScale:0,target:{X:0,Y:0},touchN:0,startTranslate:{X:0,Y:0}},this._scale=1,this.scaleDebouncer=0,this.frameBounds=null,this.debugger=null,this.btouchstartHandler=this.touchstartHandler.bind(this),this.btouchendHandler=this.touchendHandler.bind(this),this.btouchmoveHandler=this.touchmoveHandler.bind(this),this.bdblclickHandler=this.dblclickHandler.bind(this),this.bmousedownHandler=this.mousedownHandler.bind(this),this.bmouseupHandler=this.mouseupHandler.bind(this),this.bmousemoveHandler=this.mousemoveHandler.bind(this),this.moveFrame=0,this.manager=A,this.coordinator=new pi,this.attachEvents(),t&&(this.debugger=new _e)}get scale(){return this._scale}set scale(A){isNaN(A)&&(A=1),window.clearTimeout(this.scaleDebouncer),this.scaleDebouncer=window.setTimeout(()=>{this.dragState===0&&this.scale<it&&(this.pan.translateX=0,this.pan.translateY=0,this.clearPan(),this.manager.updateBookStyle()),this.manager.listener("zoom",A)},100),this._scale=A}attachEvents(){this.observe(this.manager.spineElement),this.pan={startX:0,startY:0,endX:0,overscrollX:0,overscrollY:0,letItGo:!1,preventClick:!1,translateX:0,translateY:0,touchID:0},this.pinch={startDistance:0,startScale:0,target:{X:0,Y:0},startTranslate:{X:0,Y:0},touchN:0}}clearPan(){this.pan.letItGo=!1,this.pan.touchID=0,this.pan.endX=0,this.pan.overscrollX=0,this.pan.overscrollY=0}clearPinch(){this.pinch={startDistance:0,startScale:this.pinch.startScale,target:{X:0,Y:0},touchN:0,startTranslate:{X:0,Y:0}}}observe(A){A.addEventListener("touchstart",this.btouchstartHandler),A.addEventListener("touchend",this.btouchendHandler),A.addEventListener("touchmove",this.btouchmoveHandler,{passive:!0}),A.addEventListener("dblclick",this.bdblclickHandler,{passive:!0}),A.addEventListener("mousedown",this.bmousedownHandler),A.addEventListener("mouseup",this.bmouseupHandler),A.addEventListener("mousemove",this.bmousemoveHandler)}clickHandler(A){}touchstartHandler(A){var o,s;if(["TEXTAREA","OPTION","INPUT","SELECT"].indexOf(A.target.nodeName)!==-1)return;switch(A.stopPropagation(),this.frameBounds=this.manager.currentBounds,this.coordinator.refreshOuterPixels(this.frameBounds),A.touches.length){case 3:return;case 2:{A.preventDefault(),this.pinch.startDistance=this.coordinator.getTouchDistance(A);const r=this.startTouch(A);this.pan.startX=r.X,this.pan.startY=r.Y,this.dragState=2,this.manager.updateBookStyle(!0),this.isScaled?(this.pinch.target.X-=this.pan.translateX*(this.pinch.startScale/this.scale),this.pinch.target.Y-=this.pan.translateY*(this.pinch.startScale/this.scale),this.pinch.target={X:0,Y:0},this.pinch.startScale=1/this.scale):(this.pinch.target={X:0,Y:0},this.pinch.startScale=this.scale),this.pinch.startTranslate={X:this.pan.translateX,Y:this.pan.translateY},(o=this.debugger)!=null&&o.show&&(this.debugger.DOM.touch2.style.display="",this.debugger.DOM.center.style.display="",this.debugger.DOM.pinchTarget.style.display="");return}case 1:this.pan.touchID=A.touches[0].identifier,(s=this.debugger)!=null&&s.show&&(this.debugger.DOM.touch1.style.display="");default:this.dragState<1&&(this.dragState=1),this.manager.updateBookStyle(!0)}this.manager.updateSpineStyle(!1);const i=this.startTouch(A);this.pan.startX=i.X,this.pan.startY=i.Y}startTouch(A){const t=this.coordinator.getTouchCenter(A)||this.coordinator.getBibiEventCoord(A);return{X:t.X-this.manager.width/2-this.pan.translateX*this.scale+this.manager.width/2,Y:t.Y-this.manager.height/2-this.pan.translateY*this.scale+this.manager.height/2}}touchendHandler(A){var t,i;if(A.stopPropagation(),!A.touches||A.touches.length===0)this.pan.endX&&!this.isScaled?(this.pinch.touchN&&(this.pan.endX=this.pan.startX),this.updateAfterDrag()):!this.pinch.touchN&&Math.abs(this.pan.overscrollX)>Ei&&Math.abs(this.pan.overscrollY)<Ei/2&&(this.pan.startX=0,this.pan.endX=-this.pan.overscrollX,this.updateAfterDrag()),this.dragState=0,this.minimumMoved=!1,this.clearPinch(),(t=this.debugger)!=null&&t.show&&(this.debugger.DOM.center.style.display="none",this.debugger.DOM.touch1.style.display="none",this.debugger.DOM.touch2.style.display="none");else if(A.touches.length===1){this.dragState=1,A.touches[0].identifier!==this.pan.touchID&&(this.pan.touchID=A.touches[0].identifier),(i=this.debugger)!=null&&i.show&&(this.debugger.DOM.center.style.display="none",this.debugger.DOM.touch2.style.display="none",this.debugger.DOM.pinchTarget.style.display="none");const o=this.startTouch(A);this.pan.startX=o.X,this.pan.startY=o.Y}window.setTimeout(()=>{this.manager.updateBookStyle(!0),this.dragState===0&&(this.scale<it&&(this.pan.translateX=0,this.pan.translateY=0),this.clearPan()),this.manager.updateBookStyle(!0)},50)}touchmoveHandler(A){var r,n,a,c,B;A.stopPropagation();const t=this.coordinator.getBibiEventCoord(A);Math.abs(this.pan.startY-t.Y)+Math.abs(this.pan.startX-t.X)>5&&(this.minimumMoved||(this.manager.deselect(),this.minimumMoved=!0),this.dragState<1&&(this.dragState=1));const i=(r=this.coordinator)==null?void 0:r.getTouchDistance(A);let o=!1;const s=this.scale;if(this.dragState===2&&i){if(this.pinch.touchN++,this.pinch.touchN<4)return;let h=i/this.pinch.startDistance*this.scale;h>=Yi&&(h=Yi),h<=it&&(h=1),this.scale=h,this.pinch.startDistance=i,o=!0}if(this.pan.letItGo===!1&&(this.pan.letItGo=Math.abs(this.pan.startY-t.Y)<Math.abs(this.pan.startX-t.X)),(n=this.debugger)!=null&&n.show&&(this.debugger.DOM.touch1.style.top=`${t.Y-10}px`,this.debugger.DOM.touch1.style.left=`${t.X-10}px`,this.debugger.DOM.touch1.innerText=`${t.X.toFixed(2)},${t.Y.toFixed(2)}`),this.dragState>0&&this.isScaled||this.dragState>1){if(this.dragState===1){const I={X:t.X-this.manager.width/2,Y:t.Y-this.manager.height/2};this.pan.translateX=(I.X-(this.pan.startX-this.manager.width/2))*1/this.scale,this.pan.translateY=(I.Y-(this.pan.startY-this.manager.height/2))*1/this.scale}else if(this.dragState===2){const I=this.coordinator.getTouchCenter(A);if((a=this.debugger)!=null&&a.show){this.debugger.DOM.center.style.top=`${I.Y-5}px`,this.debugger.DOM.center.style.left=`${I.X-5}px`,this.debugger.DOM.center.innerText=`${I.X.toFixed(2)},${I.Y.toFixed(2)}`;const Q=this.coordinator.getBibiEventCoord(A,1);this.debugger.DOM.touch2.style.top=`${Q.Y-10}px`,this.debugger.DOM.touch2.style.left=`${Q.X-10}px`,this.debugger.DOM.touch2.innerText=`${Q.X.toFixed(2)},${Q.Y.toFixed(2)}`}I.X-=this.manager.width/2,I.Y-=this.manager.height/2;let d=-I.X/s;d+=I.X/this.scale,this.pinch.target.X+=d,I.X+=this.pinch.target.X*this.scale/this.pinch.startScale;let l=-I.Y/s;l+=I.Y/this.scale,this.pinch.target.Y+=l,I.Y+=this.pinch.target.Y*this.scale/this.pinch.startScale;let F=(I.X-(this.pan.startX-this.manager.width/2))*1/this.scale,u=(I.Y-(this.pan.startY-this.manager.height/2))*1/this.scale;this.pan.translateX=F,this.pan.translateY=u,(c=this.debugger)!=null&&c.show&&(this.debugger.DOM.pinchTarget.style.left=`${this.pinch.target.X*this.scale/this.pinch.startScale-5+this.manager.width/2}px`,this.debugger.DOM.pinchTarget.style.top=`${this.pinch.target.Y*this.scale/this.pinch.startScale-5+this.manager.height/2}px`,this.debugger.DOM.pinchTarget.innerText=`${(this.pinch.target.X*this.scale/this.pinch.startScale).toFixed(2)},${(this.pinch.target.Y*this.scale/this.pinch.startScale).toFixed(2)}`)}const h=this.frameBounds.width/6,g=this.frameBounds.height/6;this.pan.translateX<-h&&(this.pan.overscrollX=-(h+this.pan.translateX),this.pan.translateX=-h),this.pan.translateY<-g&&(this.pan.overscrollY=-(g+this.pan.translateY),this.pan.translateY=-g),this.pan.translateX>h&&(this.pan.overscrollX=h-this.pan.translateX,this.pan.translateX=h),this.pan.translateY>g&&(this.pan.overscrollY=g-this.pan.translateY,this.pan.translateY=g),o=!0,(B=this.debugger)!=null&&B.show&&(this.debugger.DOM.stats.innerText=`TX: ${this.pan.translateX.toFixed(2)}
|
|
105
|
+
TY: ${this.pan.translateY.toFixed(2)}
|
|
106
|
+
Zoom: ${this.scale.toFixed(2)}
|
|
107
|
+
Overscroll: ${this.pan.overscrollX.toFixed(2)},${this.pan.overscrollY.toFixed(2)}`)}if(o){this.manager.updateBookStyle();return}if(this.dragState>0&&this.pan.letItGo){this.pan.endX=t.X;const g=this.manager.currentSlide*(this.manager.width/this.manager.perPage),I=this.pan.endX-this.pan.startX,d=this.manager.rtl?g+I:g-I;cancelAnimationFrame(this.moveFrame),this.moveFrame=requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.manager.spineElement.style.transform=`translate3d(${(this.manager.rtl?1:-1)*d}px, 0, 0)`})})}}dblclickHandler(A){clearTimeout(this.dtimer),this.pdblclick=!0,this.dtimer=window.setTimeout(()=>this.pdblclick=!1,200),!this.disableDblClick&&this.isScaled&&(this.scale=1)}get isScaled(){return this.scale>1}addTouch(A){A.touches=[{pageX:A.pageX,pageY:A.pageY}]}mousedownHandler(A){this.isScaled&&(this.addTouch(A),this.touchstartHandler(A))}mouseupHandler(A){this.isScaled&&this.touchendHandler(A)}mousemoveHandler(A){this.isScaled&&A.buttons>0&&(A.preventDefault(),this.addTouch(A),this.touchmoveHandler(A))}updateAfterDrag(){const A=(this.manager.rtl?-1:1)*(this.pan.endX-this.pan.startX),t=Math.abs(A);A>0&&t>this.manager.threshold&&this.manager.slength>this.manager.perPage?this.manager.listener("no_less",void 0):A<0&&t>this.manager.threshold&&this.manager.slength>this.manager.perPage&&this.manager.listener("no_more",void 0),this.manager.slideToCurrent(!0,!0)}}class Ui{constructor(A){this.shift=!0,this.spreads=[],this.nLandscape=0,this.index(A),this.testShift(A),console.log(`Indexed ${this.spreads.length} spreads for ${A.readingOrder.items.length} items`)}index(A,t=!1){this.nLandscape=0,A.readingOrder.items.forEach((i,o)=>{var r,n,a,c,B;t||(A.readingOrder.items[o]=i.addProperties({number:o+1,isImage:((r=i.type)==null?void 0:r.indexOf("image/"))===0}));const s=((n=i.properties)==null?void 0:n.getOrientation())===J.landscape;(!((a=i.properties)!=null&&a.getPage())||t)&&(i.properties=(c=i.properties)==null?void 0:c.add({page:s?"center":((this.shift?0:1)+o-this.nLandscape)%2?A.metadata.readingProgression===p.rtl?"right":"left":A.metadata.readingProgression===p.rtl?"left":"right"})),(s||(B=i.properties)!=null&&B.otherProperties.addBlank)&&this.nLandscape++}),t&&(this.spreads=[]),this.buildSpreads(A.readingOrder)}testShift(A){let t=!1;this.spreads.forEach((i,o)=>{var n,a,c,B,h;if(i.length>1)return;const s=i[0],r=(n=s.properties)==null?void 0:n.getOrientation();o===0&&(r===J.landscape||r!==J.portrait&&((s.width||0)>(s.height||0)||((a=s.properties)==null?void 0:a.getSpread())===MA.both))&&(this.shift=!1),t&&((c=s.properties)==null?void 0:c.getPage())===G.center&&this.spreads[o-1][0].addProperties({addBlank:!0}),r===J.portrait&&((B=s.properties)==null?void 0:B.getPage())!=="center"&&((h=s.properties)==null?void 0:h.otherProperties.number)>1?t=!0:t=!1}),this.shift||this.index(A,!0)}buildSpreads(A){let t=[];A.items.forEach((i,o)=>{var s;!o&&this.shift?this.spreads.push([i]):((s=i.properties)==null?void 0:s.getPage())===G.center?(t.length>0&&this.spreads.push(t),this.spreads.push([i]),t=[]):t.length>=2?(this.spreads.push(t),t=[i]):t.push(i)}),t.length>0&&this.spreads.push(t)}currentSpread(A,t){return this.spreads[Math.min(Math.floor(A/t),this.spreads.length-1)]}findByLink(A){return this.spreads.find(t=>t.includes(A))||void 0}}const yi=8,Ci=5,$e=300,Ao=15e3,to=250,io=150,eo=500;class zi{constructor(A,t,i){var o;if(this.pool=new Map,this.blobs=new Map,this.inprogress=new Map,this.delayedShow=new Map,this.delayedTimeout=new Map,this.previousFrames=[],this.width=0,this.height=0,this.transform="",this.currentSlide=0,this.spread=!0,this.orientationInternal=-1,this.container=A,this.positions=t,this.pub=i,this.spreadPresentation=((o=i.metadata.getPresentation())==null?void 0:o.spread)||MA.auto,this.pub.metadata.effectiveReadingProgression!==p.rtl&&this.pub.metadata.effectiveReadingProgression!==p.ltr)throw Error("Unsupported reading progression for EPUB");this.spreader=new Ui(this.pub),this.containerHeightCached=A.clientHeight,this.resizeBoundHandler=this.nativeResizeHandler.bind(this),this.ownerWindow.addEventListener("resize",this.resizeBoundHandler),this.ownerWindow.addEventListener("orientationchange",this.resizeBoundHandler),this.bookElement=document.createElement("div"),this.bookElement.ariaLabel="Book",this.bookElement.tabIndex=-1,this.updateBookStyle(!0),this.spineElement=document.createElement("div"),this.spineElement.ariaLabel="Spine",this.bookElement.appendChild(this.spineElement),this.container.appendChild(this.bookElement),this.updateSpineStyle(!0),this.peripherals=new vi(this),this.pub.readingOrder.items.forEach(s=>{var n,a;const r=new mi(this.peripherals,this.pub.metadata.effectiveReadingProgression,s.href);this.spineElement.appendChild(r.element),this.pool.set(s.href,r),r.width=100/this.length*(((n=s.properties)==null?void 0:n.getOrientation())===J.landscape||(a=s.properties)!=null&&a.otherProperties.addBlank?this.perPage:1),r.height=this.height})}set listener(A){this._listener=A}get listener(){return this._listener}get doNotDisturb(){return this.peripherals.pan.touchID>0}nativeResizeHandler(A){this.resizeHandler(!0)}resizeHandler(A=!0,t=!0){this.currentSlide+this.perPage>this.length&&(this.currentSlide=this.length<=this.perPage?0:this.length-1),this.containerHeightCached=this.container.clientHeight,this.orientationInternal=-1,this.updateSpineStyle(!0),A&&(this.currentSlide=this.reAlign(),this.slideToCurrent(!t,t)),clearTimeout(this.resizeTimeout),this.resizeTimeout=window.setTimeout(()=>{this.pool.forEach((i,o)=>{var a,c;let s=this.pub.readingOrder.items.findIndex(B=>B.href===o);const r=this.pub.readingOrder.items[s];if(i.width=100/this.length*(((a=r.properties)==null?void 0:a.getOrientation())===J.landscape||(c=r.properties)!=null&&c.otherProperties.addBlank?this.perPage:1),i.height=this.height,!i.loaded)return;const n=this.spreader.findByLink(r);i.update(this.spreadPosition(n,r))})},to)}updateDimensions(){this.width=this.bookElement.clientWidth,this.height=this.bookElement.clientHeight}get rtl(){return this.pub.metadata.effectiveReadingProgression===p.rtl}get single(){return!this.spread||this.portrait}get perPage(){return this.spread&&!this.portrait?2:1}get threshold(){return 50}get portrait(){return this.spreadPresentation===MA.none?!0:(this.orientationInternal===-1&&(this.orientationInternal=this.containerHeightCached>this.container.clientWidth?1:0),this.orientationInternal===1)}updateSpineStyle(A,t=!0){let i="0";this.updateDimensions(),this.perPage>1&&(i=`${this.width/2}px`);const o={transition:A?`all ${t?io:eo}ms ease-out`:"all 0ms ease-out",marginRight:this.rtl?i:"0",marginLeft:this.rtl?"0":i,width:`${this.width/this.perPage*this.length}px`,transform:this.transform,contain:"content"};Object.assign(this.spineElement.style,o)}updateBookStyle(A=!1){var t,i;if(A){const o={overflow:"hidden",direction:this.pub.metadata.effectiveReadingProgression,cursor:"",height:"100%",width:"100%",position:"relative",outline:"none",transition:(t=this.peripherals)!=null&&t.dragState?"none":"transform .15s ease-in-out",touchAction:"none"};Object.assign(this.bookElement.style,o)}this.bookElement.style.transform=`scale(${((i=this.peripherals)==null?void 0:i.scale)||1})`+(this.peripherals?` translate3d(${this.peripherals.pan.translateX}px, ${this.peripherals.pan.translateY}px, 0px)`:"")}goTo(A){if(this.slength<=this.perPage)return;A=this.reAlign(A);const t=this.currentSlide;this.currentSlide=Math.min(Math.max(A,0),this.length-1),t!==this.currentSlide&&this.slideToCurrent(!1)}onChange(){this.peripherals.scale=1,this.updateBookStyle()}get offset(){return(this.rtl?1:-1)*this.currentSlide*(this.width/this.perPage)}get length(){if(this.single)return this.slength;const A=this.slength+this.nLandscape;return this.shift&&A%2===0?A+1:A}get slength(){return this.pub.readingOrder.items.length||0}get shift(){return this.spreader.shift}get nLandscape(){return this.spreader.nLandscape}setPerPage(A){A===0?this.spread=!0:A===1?this.spread=!1:this.spread=!0,requestAnimationFrame(()=>this.resizeHandler(!0))}slideToCurrent(A,t=!0){if(this.updateDimensions(),A)requestAnimationFrame(()=>{requestAnimationFrame(()=>{const i=`translate3d(${this.offset}px, 0, 0)`;this.spineElement.style.transform!==i&&(this.transform=i,this.updateSpineStyle(!0,t),this.deselect())})});else{const i=`translate3d(${this.offset}px, 0, 0)`;if(this.spineElement.style.transform===i)return;this.transform=i,this.updateSpineStyle(!1),this.deselect()}}bounce(A=!1){requestAnimationFrame(()=>{this.transform=`translate3d(${this.offset+50*(A?1:-1)}px, 0, 0)`,this.updateSpineStyle(!0,!0),setTimeout(()=>{this.transform=`translate3d(${this.offset}px, 0, 0)`,this.updateSpineStyle(!0,!0)},100)})}next(A=1){if(this.slength<=this.perPage)return!1;const t=this.currentSlide;return this.currentSlide=Math.min(this.currentSlide+A,this.length-1),this.perPage>1&&this.currentSlide%2&&this.currentSlide--,this.currentSlide===t&&(this.currentSlide+1,this.length),t!==this.currentSlide?(this.slideToCurrent(!0),this.onChange(),!0):(this.bounce(this.rtl),!1)}prev(A=1){if(this.slength<=this.perPage)return!1;const t=this.currentSlide;return this.currentSlide=Math.max(this.currentSlide-A,0),this.perPage>1&&this.currentSlide%2&&this.currentSlide++,t!==this.currentSlide?(this.slideToCurrent(!0),this.onChange(),!0):(this.bounce(!this.rtl),!1)}get ownerWindow(){return this.container.ownerDocument.defaultView||window}async destroy(){this.ownerWindow.removeEventListener("resize",this.resizeBoundHandler),this.ownerWindow.removeEventListener("orientationchange",this.resizeBoundHandler);let A=this.inprogress.values(),t=A.next();const i=[];for(;t.value;)i.push(t.value),t=A.next();i.length>0&&await Promise.allSettled(i),this.inprogress.clear();let o=this.pool.values(),s=o.next();for(;s.value;)await s.value.destroy(),s=o.next();this.pool.clear(),this.blobs.forEach(r=>URL.revokeObjectURL(r)),this.container.childNodes.forEach(r=>{(r.nodeType===Node.ELEMENT_NODE||r.nodeType===Node.TEXT_NODE)&&r.remove()})}makeSpread(A){return this.perPage<2?[this.pub.readingOrder.items[A]]:this.spreader.currentSpread(A,this.perPage)}reAlign(A=this.currentSlide){return A%2&&!this.single&&A++,A}spreadPosition(A,t){return this.perPage<2||A.length<2?G.center:t.href===A[0].href?this.rtl?G.right:G.left:this.rtl?G.left:G.right}async waitForItem(A){if(this.inprogress.has(A)&&await this.inprogress.get(A),this.delayedShow.has(A)){const t=this.delayedTimeout.get(A);t>0?clearTimeout(t):await this.delayedShow.get(A),this.delayedTimeout.set(A,0),this.delayedShow.delete(A)}}async cancelShowing(A){if(this.delayedShow.has(A)){const t=this.delayedTimeout.get(A);t>0&&clearTimeout(t),this.delayedShow.delete(A)}}async update(A,t,i,o=!1){let s=this.pub.readingOrder.items.findIndex(a=>a.href===t.href);if(s<0)throw Error("Href not found in reading order");this.currentSlide!==s&&(this.currentSlide=this.reAlign(s),this.slideToCurrent(!0));const r=this.makeSpread(this.currentSlide);this.perPage>1&&s++;for(const a of r)await this.waitForItem(a.href);const n=new Promise(async(a,c)=>{const B=[],h=[];this.positions.forEach((d,l)=>{(l>s+yi||l<s-yi)&&(B.includes(d.href)||B.push(d.href)),l<s+Ci&&l>s-Ci&&(h.includes(d.href)||h.push(d.href))}),B.forEach(async d=>{var l;h.includes(d)||this.pool.has(d)&&(this.cancelShowing(d),await((l=this.pool.get(d))==null?void 0:l.unload()))}),this.currentBaseURL!==void 0&&A.baseURL!==this.currentBaseURL&&(this.blobs.forEach(d=>URL.revokeObjectURL(d)),this.blobs.clear()),this.currentBaseURL=A.baseURL;const g=async d=>{const l=A.readingOrder.findIndexWithHref(d),F=A.readingOrder.items[l];if(F){if(!this.blobs.has(d)){const Q=await new It(A,this.currentBaseURL||"",F).build(!0);this.blobs.set(d,Q)}this.delayedShow.has(d)||this.delayedShow.set(d,new Promise((u,Q)=>{let m=!1;const f=window.setTimeout(async()=>{this.delayedTimeout.set(d,0);const y=this.makeSpread(this.reAlign(l)),rA=this.spreadPosition(y,F),K=this.pool.get(d);await K.load(i,this.blobs.get(d)),this.peripherals.isScaled||await K.show(rA),this.delayedShow.delete(d),m=!0,u()},$e);setTimeout(()=>{!m&&this.delayedShow.has(d)&&Q(`Offscreen load timeout: ${d}`)},Ao),this.delayedTimeout.set(d,f)}))}};try{await Promise.all(h.map(d=>g(d)))}catch(d){c(d)}const I=[];for(const d of r){const l=this.pool.get(d.href),F=this.blobs.get(d.href);F&&(this.cancelShowing(d.href),await l.load(i,F),await l.show(this.spreadPosition(r,d)),this.previousFrames.push(l),await l.activate(),I.push(l))}for(;this.previousFrames.length>0;){const d=this.previousFrames.shift();d&&!I.includes(d)&&await d.unfocus()}this.previousFrames=I,a()});for(const a of r)this.inprogress.set(a.href,n);await n;for(const a of r)this.inprogress.delete(a.href)}get currentFrames(){if(this.perPage<2){const t=this.pub.readingOrder.items[this.currentSlide];return[this.pool.get(t.href)]}return this.spreader.currentSpread(this.currentSlide,this.perPage).map(t=>this.pool.get(t.href))}get currentBounds(){const A={x:0,y:0,width:0,height:0,top:0,right:0,bottom:0,left:0,toJSON(){return this}};return this.currentFrames.forEach(t=>{if(!t)return;const i=t.realSize;A.x=Math.min(A.x,i.x),A.y=Math.min(A.y,i.y),A.width+=i.width,A.height=Math.max(A.height,i.height),A.top=Math.min(A.top,i.top),A.right=Math.min(A.right,i.right),A.bottom=Math.min(A.bottom,i.bottom),A.left=Math.min(A.left,i.left)}),A}get currentNumbers(){var t,i,o,s;if(this.perPage<2)return[(t=this.pub.readingOrder.items[this.currentSlide].properties)==null?void 0:t.otherProperties.number];const A=this.spreader.currentSpread(this.currentSlide,this.perPage);return A.length>1?[(i=A[0].properties)==null?void 0:i.otherProperties.number,(o=A[A.length-1].properties)==null?void 0:o.otherProperties.number]:[(s=A[0].properties)==null?void 0:s.otherProperties.number]}deselect(){var A;(A=this.currentFrames)==null||A.forEach(t=>t==null?void 0:t.deselect())}}function N(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function Hi(e,A){for(var t="",i=0,o=-1,s=0,r,n=0;n<=e.length;++n){if(n<e.length)r=e.charCodeAt(n);else{if(r===47)break;r=47}if(r===47){if(!(o===n-1||s===1))if(o!==n-1&&s===2){if(t.length<2||i!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){var a=t.lastIndexOf("/");if(a!==t.length-1){a===-1?(t="",i=0):(t=t.slice(0,a),i=t.length-1-t.lastIndexOf("/")),o=n,s=0;continue}}else if(t.length===2||t.length===1){t="",i=0,o=n,s=0;continue}}A&&(t.length>0?t+="/..":t="..",i=2)}else t.length>0?t+="/"+e.slice(o+1,n):t=e.slice(o+1,n),i=n-o-1;o=n,s=0}else r===46&&s!==-1?++s:s=-1}return t}function oo(e,A){var t=A.dir||A.root,i=A.base||(A.name||"")+(A.ext||"");return t?t===A.root?t+i:t+e+i:i}var sA={resolve:function(){for(var A="",t=!1,i,o=arguments.length-1;o>=-1&&!t;o--){var s;o>=0?s=arguments[o]:(i===void 0&&(i=process.cwd()),s=i),N(s),s.length!==0&&(A=s+"/"+A,t=s.charCodeAt(0)===47)}return A=Hi(A,!t),t?A.length>0?"/"+A:"/":A.length>0?A:"."},normalize:function(A){if(N(A),A.length===0)return".";var t=A.charCodeAt(0)===47,i=A.charCodeAt(A.length-1)===47;return A=Hi(A,!t),A.length===0&&!t&&(A="."),A.length>0&&i&&(A+="/"),t?"/"+A:A},isAbsolute:function(A){return N(A),A.length>0&&A.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var A,t=0;t<arguments.length;++t){var i=arguments[t];N(i),i.length>0&&(A===void 0?A=i:A+="/"+i)}return A===void 0?".":sA.normalize(A)},relative:function(A,t){if(N(A),N(t),A===t||(A=sA.resolve(A),t=sA.resolve(t),A===t))return"";for(var i=1;i<A.length&&A.charCodeAt(i)===47;++i);for(var o=A.length,s=o-i,r=1;r<t.length&&t.charCodeAt(r)===47;++r);for(var n=t.length,a=n-r,c=s<a?s:a,B=-1,h=0;h<=c;++h){if(h===c){if(a>c){if(t.charCodeAt(r+h)===47)return t.slice(r+h+1);if(h===0)return t.slice(r+h)}else s>c&&(A.charCodeAt(i+h)===47?B=h:h===0&&(B=0));break}var g=A.charCodeAt(i+h),I=t.charCodeAt(r+h);if(g!==I)break;g===47&&(B=h)}var d="";for(h=i+B+1;h<=o;++h)(h===o||A.charCodeAt(h)===47)&&(d.length===0?d+="..":d+="/..");return d.length>0?d+t.slice(r+B):(r+=B,t.charCodeAt(r)===47&&++r,t.slice(r))},_makeLong:function(A){return A},dirname:function(A){if(N(A),A.length===0)return".";for(var t=A.charCodeAt(0),i=t===47,o=-1,s=!0,r=A.length-1;r>=1;--r)if(t=A.charCodeAt(r),t===47){if(!s){o=r;break}}else s=!1;return o===-1?i?"/":".":i&&o===1?"//":A.slice(0,o)},basename:function(A,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');N(A);var i=0,o=-1,s=!0,r;if(t!==void 0&&t.length>0&&t.length<=A.length){if(t.length===A.length&&t===A)return"";var n=t.length-1,a=-1;for(r=A.length-1;r>=0;--r){var c=A.charCodeAt(r);if(c===47){if(!s){i=r+1;break}}else a===-1&&(s=!1,a=r+1),n>=0&&(c===t.charCodeAt(n)?--n===-1&&(o=r):(n=-1,o=a))}return i===o?o=a:o===-1&&(o=A.length),A.slice(i,o)}else{for(r=A.length-1;r>=0;--r)if(A.charCodeAt(r)===47){if(!s){i=r+1;break}}else o===-1&&(s=!1,o=r+1);return o===-1?"":A.slice(i,o)}},extname:function(A){N(A);for(var t=-1,i=0,o=-1,s=!0,r=0,n=A.length-1;n>=0;--n){var a=A.charCodeAt(n);if(a===47){if(!s){i=n+1;break}continue}o===-1&&(s=!1,o=n+1),a===46?t===-1?t=n:r!==1&&(r=1):t!==-1&&(r=-1)}return t===-1||o===-1||r===0||r===1&&t===o-1&&t===i+1?"":A.slice(t,o)},format:function(A){if(A===null||typeof A!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof A);return oo("/",A)},parse:function(A){N(A);var t={root:"",dir:"",base:"",ext:"",name:""};if(A.length===0)return t;var i=A.charCodeAt(0),o=i===47,s;o?(t.root="/",s=1):s=0;for(var r=-1,n=0,a=-1,c=!0,B=A.length-1,h=0;B>=s;--B){if(i=A.charCodeAt(B),i===47){if(!c){n=B+1;break}continue}a===-1&&(c=!1,a=B+1),i===46?r===-1?r=B:h!==1&&(h=1):r!==-1&&(h=-1)}return r===-1||a===-1||h===0||h===1&&r===a-1&&r===n+1?a!==-1&&(n===0&&o?t.base=t.name=A.slice(1,a):t.base=t.name=A.slice(n,a)):(n===0&&o?(t.name=A.slice(1,r),t.base=A.slice(1,a)):(t.name=A.slice(n,r),t.base=A.slice(n,a)),t.ext=A.slice(r,a)),n>0?t.dir=A.slice(0,n-1):o&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};sA.posix=sA;var Di=sA;const so=e=>({frameLoaded:e.frameLoaded||(()=>{}),positionChanged:e.positionChanged||(()=>{}),tap:e.tap||(()=>!1),click:e.click||(()=>!1),zoom:e.zoom||(()=>{}),miscPointer:e.miscPointer||(()=>{}),customEvent:e.customEvent||(()=>{}),handleLocator:e.handleLocator||(()=>!1),textSelected:e.textSelected||(()=>{})});class et extends wt{constructor(A,t,i,o=[],s=void 0){super(),this.pub=t,this.layout=et.determineLayout(t),this.currentProgression=t.metadata.effectiveReadingProgression,this.container=A,this.listeners=so(i),this.currentLocation=s,o.length&&(this.positions=o)}static determineLayout(A){var i;const t=A.metadata.getPresentation();return(t==null?void 0:t.layout)==C.fixed||A.metadata.otherMetadata&&"http://openmangaformat.org/schema/1.0#version"in A.metadata.otherMetadata||((i=A.metadata.otherMetadata)==null?void 0:i.conformsTo)==="https://readium.org/webpub-manifest/profiles/divina"?C.fixed:C.reflowable}async load(){var A;(A=this.positions)!=null&&A.length||(this.positions=await this.pub.positionsFromManifest()),this.layout===C.fixed?(this.framePool=new zi(this.container,this.positions,this.pub),this.framePool.listener=(t,i)=>{this.eventListener(t,i)}):this.framePool=new Fi(this.container,this.positions),this.currentLocation===void 0&&(this.currentLocation=this.positions[0]),await this.apply()}get _cframes(){return this.framePool.currentFrames}get pool(){return this.framePool}eventListener(A,t){var i,o,s,r,n,a;switch(A){case"_pong":this.listeners.frameLoaded(this._cframes[0].iframe.contentWindow),this.listeners.positionChanged(this.currentLocation);break;case"first_visible_locator":const c=$.deserialize(t);if(!c)break;this.currentLocation=new $({href:this.currentLocation.href,type:this.currentLocation.type,title:this.currentLocation.title,locations:c==null?void 0:c.locations,text:c==null?void 0:c.text}),this.listeners.positionChanged(this.currentLocation);break;case"text_selected":this.listeners.textSelected(t);break;case"click":case"tap":const B=t;if(B.interactiveElement){const h=new DOMParser().parseFromString(B.interactiveElement,"text/html").body.children[0];if(h.nodeType===h.ELEMENT_NODE&&h.nodeName==="A"&&h.hasAttribute("href")){const g=(i=h.attributes.getNamedItem("href"))==null?void 0:i.value;if(g.startsWith("#"))this.go(this.currentLocation.copyWithLocations({fragments:[g.substring(1)]}),!1,()=>{});else if(g.startsWith("http://")||g.startsWith("https://")||g.startsWith("mailto:")||g.startsWith("tel:"))this.listeners.handleLocator(new aA({href:g}).locator);else try{this.goLink(new aA({href:Di.join(Di.dirname(this.currentLocation.href),g)}),!1,()=>{})}catch(I){console.warn(`Couldn't go to link for ${g}: ${I}`),this.listeners.handleLocator(new aA({href:g}).locator)}}else console.log("Clicked on",h)}else{if(this.layout===C.fixed&&this.framePool.doNotDisturb&&(B.doNotDisturb=!0),this.layout===C.fixed&&(this.currentProgression===p.rtl||this.currentProgression===p.ltr)&&this.framePool.currentFrames.length>1){const I=this.framePool.currentFrames;B.targetFrameSrc===((o=I[this.currentProgression===p.rtl?0:1])==null?void 0:o.source)&&(B.x+=(((r=(s=I[this.currentProgression===p.rtl?1:0])==null?void 0:s.iframe.contentWindow)==null?void 0:r.innerWidth)??0)*window.devicePixelRatio)}if(A==="click"?this.listeners.click(B):this.listeners.tap(B))break;if(this.currentProgression===p.ttb||this.currentProgression===p.btt)return;const g=(this._cframes.length===2?this._cframes[0].window.innerWidth+this._cframes[1].window.innerWidth:this._cframes[0].window.innerWidth)*window.devicePixelRatio/4;B.x>=g&&B.x<=g*3&&this.listeners.miscPointer(1),B.x<g?this.goLeft(!1,()=>{}):B.x>g*3&&this.goRight(!1,()=>{})}break;case"tap_more":this.listeners.miscPointer(t);break;case"no_more":this.changeResource(1);break;case"no_less":this.changeResource(-1);break;case"swipe":break;case"zoom":this.listeners.zoom(t);break;case"progress":this.syncLocation(t);break;case"log":console.log((a=(n=this._cframes[0])==null?void 0:n.source)==null?void 0:a.split("/")[3],...t);break;default:this.listeners.customEvent(A,t);break}}determineModules(){let A=Array.from($A.keys());return this.layout===C.fixed?A.filter(t=>Xe.includes(t)):(A=A.filter(t=>qe.includes(t)),this.readingProgression===p.ttb||this.readingProgression===p.btt?A=A.filter(t=>t!=="column_snapper"):A=A.filter(t=>t!=="scroll_snapper"),A)}attachListener(){const A=this._cframes.filter(t=>!!t);if(A.length===0)throw Error("no cframe to attach listener to");A.forEach(t=>{t.msg&&(t.msg.listener=(i,o)=>{this.eventListener(i,o)})})}async apply(){if(await this.framePool.update(this.pub,this.currentLocator,this.determineModules()),this.attachListener(),this.pub.readingOrder.findIndexWithHref(this.currentLocation.href)<0)throw Error("Link for "+this.currentLocation.href+" not found!")}async destroy(){var A;await((A=this.framePool)==null?void 0:A.destroy())}async changeResource(A){var o,s;if(A===0)return!1;if(this.layout===C.fixed){const r=this.framePool,n=r.currentNumbers[0];if(A===1){if(!r.next(r.perPage))return!1}else if(A===-1){if(!r.prev(r.perPage))return!1}else throw Error("Invalid relative value for FXL");const a=r.currentNumbers[0];if(n>a){for(let c=this.positions.length-1;c>=0;c--)if(this.positions[c].href===this.pub.readingOrder.items[a-1].href){this.currentLocation=this.positions[c].copyWithLocations({progression:.999999999999});break}}else if(n<a){for(let c=0;c<this.positions.length;c++)if(this.positions[c].href===this.pub.readingOrder.items[a-1].href){this.currentLocation=this.positions[c];break}}return await this.apply(),!0}const t=this.pub.readingOrder.findIndexWithHref(this.currentLocation.href),i=Math.max(0,Math.min(this.pub.readingOrder.items.length-1,t+A));if(i===t)return(s=(o=this._cframes[0])==null?void 0:o.msg)==null||s.send("shake",void 0,async r=>{}),!1;if(t>i){for(let r=this.positions.length-1;r>=0;r--)if(this.positions[r].href===this.pub.readingOrder.items[i].href){this.currentLocation=this.positions[r].copyWithLocations({progression:.999999999999});break}}else for(let r=0;r<this.positions.length;r++)if(this.positions[r].href===this.pub.readingOrder.items[i].href){this.currentLocation=this.positions[r];break}return await this.apply(),!0}findNearestPosition(A){const t=this.positions.filter(o=>o.href===this.currentLocation.href);let i=this.currentLocation;return t.some(o=>{const s=o.locations.progression??0;return A<=s?(i=o,!0):!1}),i}async syncLocation(A){this.currentLocation=this.findNearestPosition(A).copyWithLocations({progression:A}),this.listeners.positionChanged(this.currentLocation),await this.framePool.update(this.pub,this.currentLocation,this.determineModules())}goBackward(A,t){var i,o;this.layout===C.fixed?(this.changeResource(-1),t(!0)):(o=(i=this._cframes[0])==null?void 0:i.msg)==null||o.send("go_prev",void 0,async s=>{t(s?!0:await this.changeResource(-1))})}goForward(A,t){var i,o;this.layout===C.fixed?(this.changeResource(1),t(!0)):(o=(i=this._cframes[0])==null?void 0:i.msg)==null||o.send("go_next",void 0,async s=>{t(s?!0:await this.changeResource(1))})}get currentLocator(){return this.currentLocation}get currentPositionNumbers(){var A;return this.layout===C.fixed?this.framePool.currentNumbers:[((A=this.currentLocator)==null?void 0:A.locations.position)??0]}get readingProgression(){return this.currentProgression}async setReadingProgression(A){this.currentProgression!==A&&(this.currentProgression=A,await this.framePool.update(this.pub,this.currentLocator,this.determineModules(),!0),this.attachListener())}get publication(){return this.pub}async loadLocator(A,t){var a,c;let i=!1,o=typeof A.locations.getCssSelector=="function"&&A.locations.getCssSelector();if((a=A.text)!=null&&a.highlight?i=await new Promise((B,h)=>{var g,I;this._cframes[0].msg.send("go_text",o?[(g=A.text)==null?void 0:g.serialize(),o]:(I=A.text)==null?void 0:I.serialize(),d=>B(d))}):o&&(i=await new Promise((B,h)=>{this._cframes[0].msg.send("go_text",["",o],g=>B(g))})),i){t(i);return}const s=typeof A.locations.htmlId=="function"&&A.locations.htmlId();if(s&&(i=await new Promise((B,h)=>{this._cframes[0].msg.send("go_id",s,g=>B(g))})),i){t(i);return}const r=(c=A==null?void 0:A.locations)==null?void 0:c.progression;r&&r>0?i=await new Promise((B,h)=>{this._cframes[0].msg.send("go_progression",r,g=>B(g))}):i=!0,t(i)}go(A,t,i){const o=A.href.split("#")[0];let s=this.pub.readingOrder.findWithHref(o);if(!s)return i(this.listeners.handleLocator(A));this.currentLocation=this.positions.find(r=>r.href===s.href),this.apply().then(()=>this.loadLocator(A,r=>i(r))).then(()=>{this.attachListener()})}goLink(A,t,i){return this.go(A.locator,t,i)}}class ro{constructor(A){var t;this.sourceNode=null,this.listeners={},this.isMutedValue=!1,this.isPlayingValue=!1,this.isPausedValue=!1,this.isLoadingValue=!1,this.isLoadedValue=!1,this.isEndedValue=!1,this.playback=A.playback,this.audioContext=A.audioContext,this.gainNode=(t=this.audioContext)==null?void 0:t.createGain(),this.setVolume(this.playback.state.volume),this.mediaElement=document.createElement("audio"),this.mediaElement.crossOrigin="use-credentials",this.mediaElement.addEventListener("canplaythrough",this.onCanPlayThrough.bind(this)),this.mediaElement.addEventListener("timeupdate",this.onTimeUpdate.bind(this)),this.mediaElement.addEventListener("error",this.onError.bind(this)),this.mediaElement.addEventListener("ended",this.onEnded.bind(this)),this.mediaElement.currentTime=this.playback.state.currentTime}on(A,t){this.listeners[A]||(this.listeners[A]=[]),this.listeners[A].push(t)}off(A,t){this.listeners[A]&&(this.listeners[A]=this.listeners[A].filter(i=>i!==t))}loadAudio(A){this.isLoadingValue=!0,this.mediaElement.src=A,this.mediaElement.load(),this.sourceNode||(this.sourceNode=new MediaElementAudioSourceNode(this.audioContext,{mediaElement:this.mediaElement}),this.sourceNode.connect(this.gainNode),this.gainNode.connect(this.audioContext.destination))}async ensureAudioContextRunning(){this.audioContext.state==="suspended"&&await this.audioContext.resume()}onTimeUpdate(){this.emit("timeupdate",this.mediaElement.currentTime)}onCanPlayThrough(){this.isLoadingValue=!1,this.isLoadedValue=!0,this.emit("canplaythrough",null)}onError(){console.error("Error loading media element"),this.emit("error",this.mediaElement.error)}onEnded(){this.isPlayingValue=!1,this.isPausedValue=!1,this.isEndedValue=!0,this.emit("ended",null)}emit(A,t){this.listeners[A]&&this.listeners[A].forEach(i=>i(t))}async playLocator(A,t){}async play(){if(await this.ensureAudioContextRunning(),this.isPlayingValue){this.stop(),console.error("Audio is already playing");return}try{await this.mediaElement.play(),this.isPlayingValue=!0,this.isPausedValue=!1}catch(A){console.error("error trying to play media element",A)}}pause(){this.mediaElement.pause(),this.isPlayingValue=!1,this.isPausedValue=!0}stop(){this.mediaElement.pause(),this.mediaElement.currentTime=0,this.isPlayingValue=!1,this.isPausedValue=!1}setVolume(A){if(A<0){this.gainNode.gain.value=0,this.isMutedValue=!0;return}if(A>1){this.setVolume(A/100);return}this.gainNode.gain.value=A}skip(A){if(!this.mediaElement){console.error("Audio not loaded");return}const t=this.mediaElement.currentTime+A;t<0?this.mediaElement.currentTime=0:t>this.mediaElement.duration?this.mediaElement.currentTime=this.mediaElement.duration:this.mediaElement.currentTime=t}currentTime(){return this.mediaElement.currentTime}duration(){return this.mediaElement.duration}isPlaying(){return this.isPlayingValue}isPaused(){return this.isPausedValue}isStopped(){return!1}isLoading(){return this.isLoadingValue}isLoaded(){return this.isLoadedValue}isEnded(){return this.isEndedValue}isMuted(){return this.isMutedValue}}v.EpubNavigator=et,v.FXLCoordinator=pi,v.FXLFrameManager=mi,v.FXLFramePoolManager=zi,v.FXLPeripherals=vi,v.FXLSpreader=Ui,v.FrameComms=At,v.FrameManager=di,v.FramePoolManager=Fi,v.HorizontalThird=Qi,v.Navigator=gt,v.VerticalThird=fi,v.VisualNavigator=wt,v.WebAudioEngine=ro,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
|