@triabin/vue-book-reader
Version:
Forked from jinhuan138/vue-book-reader, add some features
39 lines (38 loc) • 206 kB
JavaScript
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('.reader[data-v-3286d5d6]{position:absolute;inset:50px 50px 20px}.viewHolder[data-v-3286d5d6]{height:100%;width:100%;position:relative}#viewer[data-v-3286d5d6]{height:100%}.container{overflow:hidden;position:relative;height:100%}.containerExpanded{transform:translate(256px)}.readerArea{position:relative;z-index:1;height:100%;width:100%;transition:all .3s ease}.container .titleArea{position:absolute;top:0;left:0;right:0;text-align:center;color:#999;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tocBackground{position:absolute;inset:0 0 0 256px;z-index:1}.tocArea{position:absolute;left:0;top:0;bottom:0;z-index:0;width:256px;overflow-y:auto;-webkit-overflow-scrolling:touch;background:#f2f2f2;padding:10px 0}.tocArea::-webkit-scrollbar{width:5px;height:5px}.tocArea::-webkit-scrollbar-thumb:vertical{height:5px;background-color:#0000001a;border-radius:.5rem}.tocArea .tocAreaButton{-webkit-user-select:none;user-select:none;-webkit-appearance:none;appearance:none;background:none;border:none;display:block;font-family:sans-serif;width:100%;font-size:.9em;text-align:left;padding:.9em 1em;border-bottom:1px solid #ddd;color:#aaa;box-sizing:border-box;outline:none;cursor:pointer;position:relative}.tocArea .tocAreaButton:hover{background:#0000000d}.tocArea .tocAreaButton:active{background:#0000001a}.tocArea .active{color:#1565c0;border-bottom:2px solid #1565c0}.tocArea .tocAreaButton .expansion{cursor:pointer;transform:translateY(-50%);top:50%;right:12px;position:absolute;width:10px;background-color:#a2a5b4;transition:transform .3s ease-in-out,top .3s ease-in-out}.tocArea .tocAreaButton .expansion:after,.tocArea .tocAreaButton .expansion:before{content:"";position:absolute;width:6px;height:2px;background-color:currentcolor;border-radius:2px;transition:transform .3s ease-in-out,top .3s ease-in-out}.tocArea .tocAreaButton .expansion:before{transform:rotate(-45deg) translate(2.5px)}.tocArea .tocAreaButton .expansion:after{transform:rotate(45deg) translate(-2.5px)}.tocArea .tocAreaButton .open:before{transform:rotate(45deg) translate(2.5px)}.tocArea .tocAreaButton .open:after{transform:rotate(-45deg) translate(-2.5px)}.tocButton{background:none;border:none;width:32px;height:32px;position:absolute;top:10px;left:10px;border-radius:2px;outline:none;cursor:pointer}.tocButtonBar{position:absolute;width:60%;background:#ccc;height:2px;left:50%;margin:-1px -30%;top:50%;transition:all .5s ease}.tocButtonExpanded{background:#f2f2f2}.arrow{outline:none;border:none;background:none;position:absolute;top:50%;margin-top:-32px;font-size:64px;padding:0 10px;color:#e2e2e2;font-family:arial,sans-serif;cursor:pointer;-webkit-user-select:none;user-select:none;-webkit-appearance:none;appearance:none;font-weight:400}.arrow:hover{color:#777}.arrow:disabled{cursor:not-allowed;color:#e2e2e2}.prev{left:1px}.next{right:1px}.loadingView{position:absolute;top:50%;left:10%;right:10%;color:#ccc;text-align:center;margin-top:-.5em}')),document.head.appendChild(e)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
(function(Ot,L){typeof exports=="object"&&typeof module<"u"?L(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],L):(Ot=typeof globalThis<"u"?globalThis:Ot||self,L(Ot["vue-book-reader"]={},Ot.Vue))})(this,function(Ot,L){"use strict";const Fo=(n,t)=>n.map((e,r,i)=>t(e,r,i)?r:null).filter(e=>e!=null),yr=(n,t)=>[-1,...t,n.length].reduce(({xs:e,a:r},i)=>({xs:(e==null?void 0:e.concat([n.slice(r+1,i)]))??[],a:i}),{}).xs,zo=(n,t)=>n.slice(0,-1).concat([n[n.length-1].concat(t[0])]).concat(t.slice(1)),dn=/\d/,_e=/^epubcfi\((.*)\)$/,wr=n=>n.replace(/[\^[\](),;=]/g,"^$&"),vr=n=>_e.test(n)?n:`epubcfi(${n})`,Do=n=>{var t;return((t=n.match(_e))==null?void 0:t[1])??n},jo=(n=>(...t)=>`epubcfi(${n(...t.map(e=>{var r;return((r=e.match(_e))==null?void 0:r[1])??e}))})`)((...n)=>n.join("!")),Uo=n=>{const t=[];let e,r,i="";const s=a=>(t.push(a),e=null,i=""),o=a=>(i+=a,r=!1);for(const a of Array.from(n.trim()).concat("")){if(a==="^"&&!r){r=!0;continue}if(e==="!")s(["!"]);else if(e===",")s([","]);else if(e==="/"||e===":")if(dn.test(a)){o(a);continue}else s([e,parseInt(i)]);else if(e==="~")if(dn.test(a)||a==="."){o(a);continue}else s(["~",parseFloat(i)]);else if(e==="@"){if(a===":"){s(["@",parseFloat(i)]),e="@";continue}if(dn.test(a)||a==="."){o(a);continue}else s(["@",parseFloat(i)])}else if(e==="["){a===";"&&!r?(s(["[",i]),e=";"):a===","&&!r?(s(["[",i]),e="["):a==="]"&&!r?s(["[",i]):o(a);continue}else if(e!=null&&e.startsWith(";")){a==="="&&!r?(e=`;${i}`,i=""):a===";"&&!r?(s([e,i]),e=";"):a==="]"&&!r?s([e,i]):o(a);continue}(a==="/"||a===":"||a==="~"||a==="@"||a==="["||a==="!"||a===",")&&(e=a)}return t},Sr=(n,t)=>Fo(n,([e])=>e===t),Wo=n=>{const t=[];let e;for(const[r,i]of n){if(r==="/")t.push({index:i});else{const s=t[t.length-1];if(r===":")s.offset=i;else if(r==="~")s.temporal=i;else if(r==="@")s.spatial=(s.spatial??[]).concat(i);else if(r===";s")s.side=i;else if(r==="[")if(e==="/"&&i)s.id=i;else{s.text=(s.text??[]).concat(i);continue}}e=r}return t},xr=n=>yr(n,Sr(n,"!")).map(Wo),re=n=>{const t=Uo(Do(n)),e=Sr(t,",");if(!e.length)return xr(t);const[r,i,s]=yr(t,e).map(xr);return{parent:r,start:i,end:s}},Ho=({index:n,id:t,offset:e,temporal:r,spatial:i,text:s,side:o})=>{var c;const a=o?`;s=${o}`:"";return`/${n}`+(t?`[${wr(t)}${a}]`:"")+(e!=null&&n%2?`:${e}`:"")+(r?`~${r}`:"")+(i?`@${i.join(":")}`:"")+(s||!t&&o?"["+(((c=s==null?void 0:s.map(wr))==null?void 0:c.join(","))??"")+a+"]":"")},_r=n=>n.parent?[n.parent,n.start,n.end].map(_r).join(","):n.map(t=>t.map(Ho).join("")).join("!"),Ee=n=>vr(_r(n)),Gt=(n,t)=>typeof n=="string"?Ee(Gt(re(n),t)):n.parent?zo(n.parent,n[t?"end":"start"]):n,Vo=(n,t)=>{typeof n=="string"&&(n=re(n)),typeof t=="string"&&(t=re(t)),n=Gt(n),t=Gt(t,!0);const e=n[n.length-1],r=t[t.length-1],i=[],s=[],o=[];let a=!0;const c=Math.max(e.length,r.length);for(let u=0;u<c;u++){const h=e[u],g=r[u];a&&=(h==null?void 0:h.index)===(g==null?void 0:g.index)&&!(h!=null&&h.offset)&&!(g!=null&&g.offset),a?i.push(h):(h&&s.push(h),g&&o.push(g))}const l=n.slice(0,-1).concat([i]);return Ee({parent:l,start:[s],end:[o]})},fn=({nodeType:n})=>n===3||n===4,Te=({nodeType:n})=>n===1,Er=(n,t)=>{const e=Array.from(n.childNodes).filter(r=>fn(r)||Te(r));return t?e.map(r=>{const i=t(r);return i===NodeFilter.FILTER_REJECT?null:i===NodeFilter.FILTER_SKIP?Er(r,t):r}).flat().filter(r=>r):e},pn=(n,t)=>{const e=Er(n,t).reduce((r,i)=>{let s=r[r.length-1];return s?fn(i)?Array.isArray(s)?s.push(i):fn(s)?r[r.length-1]=[s,i]:r.push(i):Te(s)?r.push(null,i):r.push(i):r.push(i),r},[]);return Te(e[0])&&e.unshift("first"),Te(e[e.length-1])&&e.push("last"),e.unshift("before"),e.push("after"),e},gn=(n,t,e)=>{const{id:r}=t[t.length-1];if(r){const o=n.ownerDocument.getElementById(r);if(o)return{node:o,offset:0}}for(const{index:o}of t){const a=n?pn(n,e)[o]:null;if(a==="first")return{node:n.firstChild??n};if(a==="last")return{node:n.lastChild??n};if(a==="before")return{node:n,before:!0};if(a==="after")return{node:n,after:!0};n=a}const{offset:i}=t[t.length-1];if(!Array.isArray(n))return{node:n,offset:i};let s=0;for(const o of n){const{length:a}=o.nodeValue;if(s+a>=i)return{node:o,offset:i-s};s+=a}},ke=(n,t,e)=>{const{parentNode:r,id:i}=n,s=pn(r,e),o=s.findIndex(l=>Array.isArray(l)?l.some(u=>u===n):l===n),a=s[o];if(Array.isArray(a)){let l=0;for(const u of a)if(u===n){l+=t;break}else l+=u.nodeValue.length;t=l}const c={id:i,index:o,offset:t};return(r!==n.ownerDocument.documentElement?ke(r,null,e).concat(c):[c]).filter(l=>l.index!==-1)},qo=(n,t)=>{const{startContainer:e,startOffset:r,endContainer:i,endOffset:s}=n,o=ke(e,r,t);if(n.collapsed)return Ee([o]);const a=ke(i,s,t);return Vo([o],[a])},Tr=(n,t,e)=>{const r=Gt(t),i=Gt(t,!0),s=n.documentElement,o=gn(s,r[0],e),a=gn(s,i[0],e),c=n.createRange();return o.before?c.setStartBefore(o.node):o.after?c.setStartAfter(o.node):c.setStart(o.node,o.offset),a.before?c.setEndBefore(a.node):a.after?c.setEndAfter(a.node):c.setEnd(a.node,a.offset),c},Xo=n=>{const t=[],{parentNode:e}=n[0],r=ke(e);for(const[i,s]of pn(e).entries()){const o=n[t.length];s===o&&t.push(Ee([r.concat({id:o.id,index:i})]))}return t},kr=(n,t)=>gn(n.documentElement,Gt(t)).node,Ar={fromIndex:n=>vr(`/6/${(n+1)*2}`),toIndex:n=>(n==null?void 0:n.at(-1).index)/2-1},Go=n=>{let t=0;const e=r=>{if(r.id=t++,r.subitems)for(const i of r.subitems)e(i)};for(const r of n)e(r);return n},Cr=n=>n.map(t=>{var e;return(e=t.subitems)!=null&&e.length?[t,Cr(t.subitems)].flat():t}).flat();class $r{async init({toc:t,ids:e,splitHref:r,getFragment:i}){Go(t);const s=Cr(t),o=new Map;for(const[c,l]of s.entries()){const[u,h]=await r(l==null?void 0:l.href)??[],g={fragment:h,item:l};o.has(u)?o.get(u).items.push(g):o.set(u,{prev:s[c-1],items:[g]})}const a=new Map;for(const[c,l]of e.entries())o.has(l)?a.set(l,o.get(l)):a.set(l,a.get(e[c-1]));this.ids=e,this.map=a,this.getFragment=i}getProgress(t,e){var c;if(!this.ids)return;const r=this.ids[t],i=this.map.get(r);if(!i)return null;const{prev:s,items:o}=i;if(!o)return s;if(!e||o.length===1&&!o[0].fragment)return o[0].item;const a=e.startContainer.getRootNode();for(const[l,{fragment:u}]of o.entries()){const h=this.getFragment(a,u);if(h&&e.comparePoint(h,0)>0)return((c=o[l-1])==null?void 0:c.item)??s}return o[o.length-1].item}}class Ko{constructor(t,e,r){this.sizes=t.map(i=>i.linear!="no"&&i.size>0?i.size:0),this.sizePerLoc=e,this.sizePerTimeUnit=r,this.sizeTotal=this.sizes.reduce((i,s)=>i+s,0),this.sectionFractions=this.#t()}#t(){const{sizeTotal:t}=this,e=[0];let r=0;for(const i of this.sizes)e.push((r+=i)/t);return e}getProgress(t,e,r=0){const{sizes:i,sizePerLoc:s,sizePerTimeUnit:o,sizeTotal:a}=this,c=i[t]??0,u=i.slice(0,t).reduce((d,b)=>d+b,0)+e*c,h=u+r*c,g=a-u,p=(1-e)*c;return{fraction:h/a,section:{current:t,total:i.length},location:{current:Math.floor(u/s),next:Math.floor(h/s),total:Math.ceil(a/s)},time:{section:p/o,total:g/o}}}getSection(t){if(t<=0)return[0,0];if(t>=1)return[this.sizes.length-1,1];t=t+Number.EPSILON;const{sizeTotal:e}=this;let r=this.sectionFractions.findIndex(s=>s>t)-1;if(r<0)return[0,0];for(;!this.sizes[r];)r++;const i=(t-this.sectionFractions[r])/(this.sizes[r]/e);return[r,i]}}const rt=n=>document.createElementNS("http://www.w3.org/2000/svg",n);class Or{#t=rt("svg");#n=new Map;#e=null;constructor(t){this.#e=t,Object.assign(this.#t.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none"})}get element(){return this.#t}get#r(){return/^((?!chrome|android).)*AppleWebKit/i.test(navigator.userAgent)&&!window.chrome&&window.getComputedStyle(this.#e.body).zoom||1}#i(t){var s;const e=t.commonAncestorContainer,r=Array.from(((s=e.querySelectorAll)==null?void 0:s.call(e,"p"))||[]);if(r.length===0)return[t];const i=[];return r.forEach(o=>{const a=document.createRange();t.intersectsNode(o)&&(a.selectNodeContents(o),a.compareBoundaryPoints(Range.START_TO_START,t)<0&&a.setStart(t.startContainer,t.startOffset),a.compareBoundaryPoints(Range.END_TO_END,t)>0&&a.setEnd(t.endContainer,t.endOffset),i.push(a))}),i}add(t,e,r,i){this.#n.has(t)&&this.remove(t),typeof e=="function"&&(e=e(this.#t.getRootNode()));const s=this.#r;let o=[];this.#i(e).forEach(c=>{const l=Array.from(c.getClientRects()).map(u=>({left:u.left*s,top:u.top*s,right:u.right*s,bottom:u.bottom*s,width:u.width*s,height:u.height*s}));o=o.concat(l)});const a=r(o,i);this.#t.append(a),this.#n.set(t,{range:e,draw:r,options:i,element:a,rects:o})}remove(t){this.#n.has(t)&&(this.#t.removeChild(this.#n.get(t).element),this.#n.delete(t))}redraw(){for(const t of this.#n.values()){const{range:e,draw:r,options:i,element:s}=t;this.#t.removeChild(s);const o=this.#r;let a=[];this.#i(e).forEach(l=>{const u=Array.from(l.getClientRects()).map(h=>({left:h.left*o,top:h.top*o,right:h.right*o,bottom:h.bottom*o,width:h.width*o,height:h.height*o}));a=a.concat(u)});const c=r(a,i);this.#t.append(c),t.element=c,t.rects=a}}hitTest({x:t,y:e}){const r=Array.from(this.#n.entries());for(let i=r.length-1;i>=0;i--){const[s,o]=r[i];for(const{left:a,top:c,right:l,bottom:u}of o.rects)if(c<=e&&a<=t&&u>e&&l>t)return[s,o.range]}return[]}static underline(t,e={}){const{color:r="red",width:i=2,padding:s=0,writingMode:o}=e,a=rt("g");if(a.setAttribute("fill",r),o==="vertical-rl"||o==="vertical-lr")for(const{right:c,top:l,height:u}of t){const h=rt("rect");h.setAttribute("x",c-i/2+s),h.setAttribute("y",l),h.setAttribute("height",u),h.setAttribute("width",i),a.append(h)}else for(const{left:c,bottom:l,width:u}of t){const h=rt("rect");h.setAttribute("x",c),h.setAttribute("y",l-i/2+s),h.setAttribute("height",i),h.setAttribute("width",u),a.append(h)}return a}static strikethrough(t,e={}){const{color:r="red",width:i=2,writingMode:s}=e,o=rt("g");if(o.setAttribute("fill",r),s==="vertical-rl"||s==="vertical-lr")for(const{right:a,left:c,top:l,height:u}of t){const h=rt("rect");h.setAttribute("x",(a+c)/2),h.setAttribute("y",l),h.setAttribute("height",u),h.setAttribute("width",i),o.append(h)}else for(const{left:a,top:c,bottom:l,width:u}of t){const h=rt("rect");h.setAttribute("x",a),h.setAttribute("y",(c+l)/2),h.setAttribute("height",i),h.setAttribute("width",u),o.append(h)}return o}static squiggly(t,e={}){const{color:r="red",width:i=2,padding:s=0,writingMode:o}=e,a=rt("g");a.setAttribute("fill","none"),a.setAttribute("stroke",r),a.setAttribute("stroke-width",i);const c=i*1.5;if(o==="vertical-rl"||o==="vertical-lr")for(const{right:l,top:u,height:h}of t){const g=rt("path"),p=Math.round(h/c/1.5),d=h/p,b=Array.from({length:p},(f,m)=>`l${m%2?-c:c} ${d}`).join("");g.setAttribute("d",`M${l-i/2+s} ${u}${b}`),a.append(g)}else for(const{left:l,bottom:u,width:h}of t){const g=rt("path"),p=Math.round(h/c/1.5),d=h/p,b=Array.from({length:p},(f,m)=>`l${d} ${m%2?c:-c}`).join("");g.setAttribute("d",`M${l} ${u+i/2+s}${b}`),a.append(g)}return a}static highlight(t,e={}){const{color:r="red",padding:i=0}=e,s=rt("g");s.setAttribute("fill",r),s.style.opacity="var(--overlayer-highlight-opacity, .3)",s.style.mixBlendMode="var(--overlayer-highlight-blend-mode, normal)";for(const{left:o,top:a,height:c,width:l}of t){const u=rt("rect");u.setAttribute("x",o-i),u.setAttribute("y",a-i),u.setAttribute("height",c+i*2),u.setAttribute("width",l+i*2),s.append(u)}return s}static outline(t,e={}){const{color:r="red",width:i=3,padding:s=0,radius:o=3}=e,a=rt("g");a.setAttribute("fill","none"),a.setAttribute("stroke",r),a.setAttribute("stroke-width",i);for(const{left:c,top:l,height:u,width:h}of t){const g=rt("rect");g.setAttribute("x",c-s),g.setAttribute("y",l-s),g.setAttribute("height",u+s*2),g.setAttribute("width",h+s*2),g.setAttribute("rx",o),a.append(g)}return a}static copyImage([t],e={}){const{src:r}=e,i=rt("image"),{left:s,top:o,height:a,width:c}=t;return i.setAttribute("href",r),i.setAttribute("x",s),i.setAttribute("y",o),i.setAttribute("height",a),i.setAttribute("width",c),i}}const Yo=(n,t)=>{const e=[];for(let r=t.currentNode;r;r=t.nextNode()){const i=n.comparePoint(r,0);if(i===0)e.push(r);else if(i>0)break}return e},Zo=(n,t)=>{const e=[];for(let r=t.nextNode();r;r=t.nextNode())e.push(r);return e},Jo=NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT|NodeFilter.SHOW_CDATA_SECTION,Qo=n=>{if(n.nodeType===1){const t=n.tagName.toLowerCase();return t==="script"||t==="style"?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_SKIP}return NodeFilter.FILTER_ACCEPT},Ir=function*(n,t){const e=n.commonAncestorContainer??n.body??n,r=document.createTreeWalker(e,Jo,{acceptNode:Qo}),s=(n.commonAncestorContainer?Yo:Zo)(n,r),o=s.map(c=>c.nodeValue??""),a=(c,l,u,h)=>{const g=document.createRange();return g.setStart(s[c],l),g.setEnd(s[u],h),g};for(const c of t(o,a))yield c},ie="foliate-search:",ta=async n=>{const t=new Uint8Array(await n.slice(0,4).arrayBuffer());return t[0]===80&&t[1]===75&&t[2]===3&&t[3]===4},ea=({name:n,type:t})=>t==="application/vnd.comicbook+zip"||n.endsWith(".cbz"),na=({name:n,type:t})=>t==="application/x-fictionbook+xml"||n.endsWith(".fb2"),ra=({name:n,type:t})=>t==="application/x-zip-compressed-fb2"||n.endsWith(".fb2.zip")||n.endsWith(".fbz"),ia=async n=>{const{configure:t,ZipReader:e,BlobReader:r,TextWriter:i,BlobWriter:s}=await Promise.resolve().then(()=>lf);t({useWebWorkers:!1});const a=await new e(new r(n)).getEntries(),c=new Map(a.map(p=>[p.filename,p])),l=p=>(d,...b)=>c.has(d)?p(c.get(d),...b):null,u=l(p=>p.getData(new i)),h=l((p,d)=>p.getData(new s(d)));return{entries:a,loadText:u,loadBlob:h,getSize:p=>{var d;return((d=c.get(p))==null?void 0:d.uncompressedSize)??0}}},Rr=async n=>n.isFile?n:(await Promise.all(Array.from(await new Promise((t,e)=>n.createReader().readEntries(r=>t(r),r=>e(r))),Rr))).flat(),sa=async n=>{const t=await Rr(n),e=await Promise.all(t.map(u=>new Promise((h,g)=>u.file(p=>h([p,u.fullPath]),p=>g(p))))),r=new Map(e.map(([u,h])=>[h.replace(n.fullPath+"/",""),u])),i=new TextDecoder,s=u=>u?i.decode(u):null,o=u=>{var h;return((h=r.get(u))==null?void 0:h.arrayBuffer())??null};return{loadText:async u=>s(await o(u)),loadBlob:u=>r.get(u),getSize:u=>{var h;return((h=r.get(u))==null?void 0:h.size)??0}}};class oa extends Error{}class aa extends Error{}class ca extends Error{}const la=async n=>{const t=await fetch(n);if(!t.ok)throw new oa(`${t.status} ${t.statusText}`,{cause:t});return new File([await t.blob()],new URL(t.url).pathname)},ua=async n=>{typeof n=="string"&&(n=await la(n));let t;if(n.isDirectory){const e=await sa(n),{EPUB:r}=await Promise.resolve().then(()=>eo);t=await new r(e).init()}else if(n.size)if(await ta(n)){const e=await ia(n);if(ea(n)){const{makeComicBook:r}=await Promise.resolve().then(()=>Lf);t=r(e,n)}else if(ra(n)){const{makeFB2:r}=await Promise.resolve().then(()=>io),{entries:i}=e,s=i.find(a=>a.filename.endsWith(".fb2")),o=await e.loadBlob((s??i[0]).filename);t=await r(o)}else{const{EPUB:r}=await Promise.resolve().then(()=>eo);t=await new r(e).init()}}else{const{isMOBI:e,MOBI:r}=await Promise.resolve().then(()=>yp);if(await e(n)){const i=await Promise.resolve().then(()=>Op);t=await new r({unzlib:i.unzlibSync}).open(n)}else if(na(n)){const{makeFB2:i}=await Promise.resolve().then(()=>io);t=await i(n)}}else throw new aa("File not found");if(!t)throw new ca("File type not supported");return t};class mn{#t;#n;#e;#r;constructor(t,e,r={}){this.#n=t,this.#e=e,this.#r=r,this.#r.hidden&&this.hide(),this.#n.addEventListener("mousemove",({screenX:i,screenY:s})=>{i===this.#r.x&&s===this.#r.y||(this.#r.x=i,this.#r.y=s,this.show(),this.#t&&clearTimeout(this.#t),e()&&(this.#t=setTimeout(this.hide.bind(this),1e3)))},!1)}cloneFor(t){return new mn(t,this.#e,this.#r)}hide(){this.#n.style.cursor="none",this.#r.hidden=!0}show(){this.#n.style.removeProperty("cursor"),this.#r.hidden=!1}}class ha extends EventTarget{#t=[];#n=-1;pushState(t){const e=this.#t[this.#n];e===t||e!=null&&e.fraction&&e.fraction===t.fraction||(this.#t[++this.#n]=t,this.#t.length=this.#n+1,this.dispatchEvent(new Event("index-change")))}replaceState(t){const e=this.#n;this.#t[e]=t}back(){const t=this.#n;if(t<=0)return;const e={state:this.#t[t-1]};this.#n=t-1,this.dispatchEvent(new CustomEvent("popstate",{detail:e})),this.dispatchEvent(new Event("index-change"))}forward(){const t=this.#n;if(t>=this.#t.length-1)return;const e={state:this.#t[t+1]};this.#n=t+1,this.dispatchEvent(new CustomEvent("popstate",{detail:e})),this.dispatchEvent(new Event("index-change"))}get canGoBack(){return this.#n>0}get canGoForward(){return this.#n<this.#t.length-1}clear(){this.#t=[],this.#n=-1}}const da=n=>{var t,e;if(!n)return{};try{const r=Intl.getCanonicalLocales(n)[0],i=new Intl.Locale(r),s=["zh","ja","kr"].includes(i.language),o=(e=((t=i.getTextInfo)==null?void 0:t.call(i))??i.textInfo)==null?void 0:e.direction;return{canonical:r,locale:i,isCJK:s,direction:o}}catch(r){return console.warn(r),{}}};let fa=class extends HTMLElement{#t=this.attachShadow({mode:"closed"});#n;#e;#r;#i=new Map;#s=new mn(this,()=>this.hasAttribute("autohide-cursor"));isFixedLayout=!1;lastLocation;history=new ha;constructor(){super(),this.history.addEventListener("popstate",({detail:t})=>{const e=this.resolveNavigation(t.state);this.renderer.goTo(e)})}async open(t){var e,r;if((typeof t=="string"||typeof t.arrayBuffer=="function"||t.isDirectory)&&(t=await ua(t)),this.book=t,this.language=da((e=t.metadata)==null?void 0:e.language),t.splitTOCHref&&t.getTOCFragment){const i=t.sections.map(a=>a.id);this.#n=new Ko(t.sections,1500,1600);const s=t.splitTOCHref.bind(t),o=t.getTOCFragment.bind(t);this.#e=new $r,await this.#e.init({toc:t.toc??[],ids:i,splitHref:s,getFragment:o}),this.#r=new $r,await this.#r.init({toc:t.pageList??[],ids:i,splitHref:s,getFragment:o})}if(this.isFixedLayout=((r=this.book.rendition)==null?void 0:r.layout)==="pre-paginated",this.isFixedLayout?(await Promise.resolve().then(()=>Rp),this.renderer=document.createElement("foliate-fxl")):(await Promise.resolve().then(()=>Vp),this.renderer=document.createElement("foliate-paginator")),this.renderer.setAttribute("exportparts","head,foot,filter,container"),this.renderer.addEventListener("load",i=>this.#c(i.detail)),this.renderer.addEventListener("relocate",i=>this.#o(i.detail)),this.renderer.addEventListener("create-overlayer",i=>i.detail.attach(this.#l(i.detail))),this.renderer.open(t),this.#t.append(this.renderer),t.sections.some(i=>i.mediaOverlay)){const i=t.media.activeClass,s=t.media.playbackActiveClass;this.mediaOverlay=t.getMediaOverlay();let o;this.mediaOverlay.addEventListener("highlight",a=>{const c=this.resolveNavigation(a.detail.text);this.renderer.goTo(c).then(()=>{const{doc:l}=this.renderer.getContents().find(h=>h.index=c.index),u=c.anchor(l);u.classList.add(i),s&&u.ownerDocument.documentElement.classList.add(s),o=new WeakRef(u)})}),this.mediaOverlay.addEventListener("unhighlight",()=>{const a=o==null?void 0:o.deref();a&&(a.classList.remove(i),s&&a.ownerDocument.documentElement.classList.remove(s))})}}close(){var t,e;(t=this.renderer)==null||t.destroy(),(e=this.renderer)==null||e.remove(),this.#n=null,this.#e=null,this.#r=null,this.#i=new Map,this.lastLocation=null,this.history.clear(),this.tts=null,this.mediaOverlay=null}goToTextStart(){var t,e;return this.goTo(((e=(t=this.book.landmarks)==null?void 0:t.find(r=>r.type.includes("bodymatter")||r.type.includes("text")))==null?void 0:e.href)??this.book.sections.findIndex(r=>r.linear!=="no"))}async init({lastLocation:t,showTextStart:e}){const r=t?this.resolveNavigation(t):null;r?(await this.renderer.goTo(r),this.history.pushState(t)):e?await this.goToTextStart():(this.history.pushState(0),await this.next())}#a(t,e,r){return this.dispatchEvent(new CustomEvent(t,{detail:e,cancelable:r}))}#o({reason:t,range:e,index:r,fraction:i,size:s}){var u,h,g;const o=((u=this.#n)==null?void 0:u.getProgress(r,i,s))??{},a=(h=this.#e)==null?void 0:h.getProgress(r,e),c=(g=this.#r)==null?void 0:g.getProgress(r,e),l=this.getCFI(r,e);this.lastLocation={...o,tocItem:a,pageItem:c,cfi:l,range:e},(t==="snap"||t==="page"||t==="scroll")&&this.history.replaceState(l),this.#a("relocate",this.lastLocation)}#c({doc:t,index:e}){t.documentElement.lang||=this.language.canonical??"",this.language.isCJK||(t.documentElement.dir||=this.language.direction??""),this.#u(t,e),this.#s.cloneFor(t.documentElement),this.#a("load",{doc:t,index:e})}#u(t,e){const{book:r}=this,i=r.sections[e];t.addEventListener("click",s=>{var l,u;const o=s.target.closest("a[href]");if(!o)return;s.preventDefault();const a=o.getAttribute("href"),c=((l=i==null?void 0:i.resolveHref)==null?void 0:l.call(i,a))??a;(u=r==null?void 0:r.isExternal)!=null&&u.call(r,c)?Promise.resolve(this.#a("external-link",{a:o,href:c},!0)).then(h=>h?globalThis.open(c,"_blank"):null).catch(h=>console.error(h)):Promise.resolve(this.#a("link",{a:o,href:c},!0)).then(h=>h?this.goTo(c):null).catch(h=>console.error(h))})}async addAnnotation(t,e){var c;const{value:r}=t;if(r.startsWith(ie)){const l=r.replace(ie,""),{index:u,anchor:h}=await this.resolveNavigation(l),g=this.#h(u);if(g){const{overlayer:p,doc:d}=g;if(e){p.remove(r);return}const b=d?h(d):h;p.add(r,b,Or.outline)}return}const{index:i,anchor:s}=await this.resolveNavigation(r),o=this.#h(i);if(o){const{overlayer:l,doc:u}=o;if(l.remove(r),!e){const h=u?s(u):s,g=(p,d)=>l.add(r,h,p,d);this.#a("draw-annotation",{draw:g,annotation:t,doc:u,range:h})}}const a=((c=this.#e.getProgress(i))==null?void 0:c.label)??"";return{index:i,label:a}}deleteAnnotation(t){return this.addAnnotation(t,!0)}#h(t){return this.renderer.getContents().find(e=>e.index===t&&e.overlayer)}#l({doc:t,index:e}){const r=new Or(t);t.addEventListener("click",s=>{const[o,a]=r.hitTest(s);o&&!o.startsWith(ie)&&this.#a("show-annotation",{value:o,index:e,range:a})},!1);const i=this.#i.get(e);if(i)for(const s of i)this.addAnnotation(s);return this.#a("create-overlay",{index:e}),r}async showAnnotation(t){const{value:e}=t,r=await this.goTo(e);if(r){const{index:i,anchor:s}=r,{doc:o}=this.#h(i),a=s(o);this.#a("show-annotation",{value:e,index:i,range:a})}}getCFI(t,e){const r=this.book.sections[t].cfi??Ar.fromIndex(t);return e?jo(r,qo(e)):r}resolveCFI(t){if(this.book.resolveCFI)return this.book.resolveCFI(t);{const e=re(t);return{index:Ar.toIndex((e.parent??e).shift()),anchor:s=>Tr(s,e)}}}resolveNavigation(t){try{if(typeof t=="number")return{index:t};if(typeof t.fraction=="number"){const[e,r]=this.#n.getSection(t.fraction);return{index:e,anchor:r}}return _e.test(t)?this.resolveCFI(t):this.book.resolveHref(t)}catch(e){console.error(e),console.error(`Could not resolve target ${t}`)}}async goTo(t){const e=this.resolveNavigation(t);try{return await this.renderer.goTo(e),this.history.pushState(t),e}catch(r){console.error(r),console.error(`Could not go to ${t}`)}}async goToFraction(t){const[e,r]=this.#n.getSection(t);await this.renderer.goTo({index:e,anchor:r}),this.history.pushState({fraction:t})}async select(t){try{const e=await this.resolveNavigation(t);await this.renderer.goTo({...e,select:!0}),this.history.pushState(t)}catch(e){console.error(e),console.error(`Could not go to ${t}`)}}deselect(){for(const{doc:t}of this.renderer.getContents())t.defaultView.getSelection().removeAllRanges()}getSectionFractions(){var t;return(((t=this.#n)==null?void 0:t.sectionFractions)??[]).map(e=>e+Number.EPSILON)}getProgressOf(t,e){var s,o;const r=(s=this.#e)==null?void 0:s.getProgress(t,e),i=(o=this.#r)==null?void 0:o.getProgress(t,e);return{tocItem:r,pageItem:i}}async getTOCItemOf(t){try{const{index:e,anchor:r}=await this.resolveNavigation(t),i=await this.book.sections[e].createDocument(),s=r(i),o=s instanceof Range,a=o?s:i.createRange();return o||a.selectNodeContents(s),this.#e.getProgress(e,a)}catch(e){console.error(e),console.error(`Could not get ${t}`)}}async prev(t){await this.renderer.prev(t)}async next(t){await this.renderer.next(t)}goLeft(){return this.book.dir==="rtl"?this.next():this.prev()}goRight(){return this.book.dir==="rtl"?this.prev():this.next()}async*#d(t,e,r){const i=await this.book.sections[r].createDocument();for(const{range:s,excerpt:o}of t(i,e))yield{cfi:this.getCFI(r,s),excerpt:o}}async*#p(t,e){const{sections:r}=this.book;for(const[i,{createDocument:s}]of r.entries()){if(!s)continue;const o=await s(),a=Array.from(t(o,e),({range:l,excerpt:u})=>({cfi:this.getCFI(i,l),excerpt:u}));yield{progress:(i+1)/r.length},a.length&&(yield{index:i,subitems:a})}}async*search(t){var c;this.clearSearch();const{searchMatcher:e}=await Promise.resolve().then(()=>Gp),{query:r,index:i}=t,s=e(Ir,{defaultLocale:this.language,...t}),o=i!=null?this.#d(s,r,i):this.#p(s,r),a=[];this.#i.set(i,a);for await(const l of o)if(l.subitems){const u=l.subitems.map(({cfi:h})=>({value:ie+h}));this.#i.set(l.index,u);for(const h of u)this.addAnnotation(h);yield{label:((c=this.#e.getProgress(l.index))==null?void 0:c.label)??"",subitems:l.subitems}}else{if(l.cfi){const u={value:ie+l.cfi};a.push(u),this.addAnnotation(u)}yield l}yield"done"}clearSearch(){for(const t of this.#i.values())for(const e of t)this.deleteAnnotation(e);this.#i.clear()}async initTTS(t="word"){const e=this.renderer.getContents()[0].doc;if(this.tts&&this.tts.doc===e)return;const{TTS:r}=await Promise.resolve().then(()=>ng);this.tts=new r(e,Ir,i=>this.renderer.scrollToAnchor(i,!0),t)}startMediaOverlay(){const{index:t}=this.renderer.getContents()[0];return this.mediaOverlay.start(t)}};customElements.define("foliate-view",fa);var Ae=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},se=function(n){return n&&n.Math===Math&&n},wt=se(typeof globalThis=="object"&&globalThis)||se(typeof window=="object"&&window)||se(typeof self=="object"&&self)||se(typeof Ae=="object"&&Ae)||se(typeof Ae=="object"&&Ae)||function(){return this}()||Function("return this")(),bn={},kt=function(n){try{return!!n()}catch{return!0}},pa=kt,jt=!pa(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7}),ga=kt,yn=!ga(function(){var n=(function(){}).bind();return typeof n!="function"||n.hasOwnProperty("prototype")}),ma=yn,Ce=Function.prototype.call,Kt=ma?Ce.bind(Ce):function(){return Ce.apply(Ce,arguments)},Lr={},Mr={}.propertyIsEnumerable,Pr=Object.getOwnPropertyDescriptor,ba=Pr&&!Mr.call({1:2},1);Lr.f=ba?function(t){var e=Pr(this,t);return!!e&&e.enumerable}:Mr;var Nr=function(n,t){return{enumerable:!(n&1),configurable:!(n&2),writable:!(n&4),value:t}},Br=yn,Fr=Function.prototype,wn=Fr.call,ya=Br&&Fr.bind.bind(wn,wn),ht=Br?ya:function(n){return function(){return wn.apply(n,arguments)}},zr=ht,wa=zr({}.toString),va=zr("".slice),vn=function(n){return va(wa(n),8,-1)},Sa=ht,xa=kt,_a=vn,Sn=Object,Ea=Sa("".split),Ta=xa(function(){return!Sn("z").propertyIsEnumerable(0)})?function(n){return _a(n)==="String"?Ea(n,""):Sn(n)}:Sn,xn=function(n){return n==null},ka=xn,Aa=TypeError,$e=function(n){if(ka(n))throw new Aa("Can't call method on "+n);return n},Ca=Ta,$a=$e,_n=function(n){return Ca($a(n))},En=typeof document=="object"&&document.all,vt=typeof En>"u"&&En!==void 0?function(n){return typeof n=="function"||n===En}:function(n){return typeof n=="function"},Oa=vt,Oe=function(n){return typeof n=="object"?n!==null:Oa(n)},Tn=wt,Ia=vt,Ra=function(n){return Ia(n)?n:void 0},kn=function(n,t){return arguments.length<2?Ra(Tn[n]):Tn[n]&&Tn[n][t]},La=ht,Dr=La({}.isPrototypeOf),Ma=wt,jr=Ma.navigator,Ur=jr&&jr.userAgent,Pa=Ur?String(Ur):"",Wr=wt,An=Pa,Hr=Wr.process,Vr=Wr.Deno,qr=Hr&&Hr.versions||Vr&&Vr.version,Xr=qr&&qr.v8,St,Ie;Xr&&(St=Xr.split("."),Ie=St[0]>0&&St[0]<4?1:+(St[0]+St[1])),!Ie&&An&&(St=An.match(/Edge\/(\d+)/),(!St||St[1]>=74)&&(St=An.match(/Chrome\/(\d+)/),St&&(Ie=+St[1])));var Na=Ie,Gr=Na,Ba=kt,Fa=wt,za=Fa.String,Kr=!!Object.getOwnPropertySymbols&&!Ba(function(){var n=Symbol("symbol detection");return!za(n)||!(Object(n)instanceof Symbol)||!Symbol.sham&&Gr&&Gr<41}),Da=Kr,Yr=Da&&!Symbol.sham&&typeof Symbol.iterator=="symbol",ja=kn,Ua=vt,Wa=Dr,Ha=Yr,Va=Object,Zr=Ha?function(n){return typeof n=="symbol"}:function(n){var t=ja("Symbol");return Ua(t)&&Wa(t.prototype,Va(n))},qa=String,Cn=function(n){try{return qa(n)}catch{return"Object"}},Xa=vt,Ga=Cn,Ka=TypeError,oe=function(n){if(Xa(n))return n;throw new Ka(Ga(n)+" is not a function")},Ya=oe,Za=xn,$n=function(n,t){var e=n[t];return Za(e)?void 0:Ya(e)},On=Kt,In=vt,Rn=Oe,Ja=TypeError,Qa=function(n,t){var e,r;if(t==="string"&&In(e=n.toString)&&!Rn(r=On(e,n))||In(e=n.valueOf)&&!Rn(r=On(e,n))||t!=="string"&&In(e=n.toString)&&!Rn(r=On(e,n)))return r;throw new Ja("Can't convert object to primitive value")},Jr={exports:{}},Qr=wt,tc=Object.defineProperty,Ln=function(n,t){try{tc(Qr,n,{value:t,configurable:!0,writable:!0})}catch{Qr[n]=t}return t},ec=wt,nc=Ln,ti="__core-js_shared__",ei=Jr.exports=ec[ti]||nc(ti,{});(ei.versions||(ei.versions=[])).push({version:"3.45.1",mode:"global",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.45.1/LICENSE",source:"https://github.com/zloirock/core-js"});var Mn=Jr.exports,ni=Mn,ri=function(n,t){return ni[n]||(ni[n]=t||{})},rc=$e,ic=Object,sc=function(n){return ic(rc(n))},oc=ht,ac=sc,cc=oc({}.hasOwnProperty),Ut=Object.hasOwn||function(t,e){return cc(ac(t),e)},lc=ht,uc=0,hc=Math.random(),dc=lc(1.1.toString),ii=function(n){return"Symbol("+(n===void 0?"":n)+")_"+dc(++uc+hc,36)},fc=wt,pc=ri,si=Ut,gc=ii,mc=Kr,bc=Yr,Yt=fc.Symbol,Pn=pc("wks"),yc=bc?Yt.for||Yt:Yt&&Yt.withoutSetter||gc,ae=function(n){return si(Pn,n)||(Pn[n]=mc&&si(Yt,n)?Yt[n]:yc("Symbol."+n)),Pn[n]},wc=Kt,oi=Oe,ai=Zr,vc=$n,Sc=Qa,xc=ae,_c=TypeError,Ec=xc("toPrimitive"),Tc=function(n,t){if(!oi(n)||ai(n))return n;var e=vc(n,Ec),r;if(e){if(t===void 0&&(t="default"),r=wc(e,n,t),!oi(r)||ai(r))return r;throw new _c("Can't convert object to primitive value")}return t===void 0&&(t="number"),Sc(n,t)},kc=Tc,Ac=Zr,Nn=function(n){var t=kc(n,"string");return Ac(t)?t:t+""},Cc=wt,ci=Oe,Bn=Cc.document,$c=ci(Bn)&&ci(Bn.createElement),Oc=function(n){return $c?Bn.createElement(n):{}},Ic=jt,Rc=kt,Lc=Oc,li=!Ic&&!Rc(function(){return Object.defineProperty(Lc("div"),"a",{get:function(){return 7}}).a!==7}),Mc=jt,Pc=Kt,Nc=Lr,Bc=Nr,Fc=_n,zc=Nn,Dc=Ut,jc=li,ui=Object.getOwnPropertyDescriptor;bn.f=Mc?ui:function(t,e){if(t=Fc(t),e=zc(e),jc)try{return ui(t,e)}catch{}if(Dc(t,e))return Bc(!Pc(Nc.f,t,e),t[e])};var Re={},Uc=jt,Wc=kt,Hc=Uc&&Wc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42}),Vc=Oe,qc=String,Xc=TypeError,ce=function(n){if(Vc(n))return n;throw new Xc(qc(n)+" is not an object")},Gc=jt,Kc=li,Yc=Hc,Le=ce,hi=Nn,Zc=TypeError,Fn=Object.defineProperty,Jc=Object.getOwnPropertyDescriptor,zn="enumerable",Dn="configurable",jn="writable";Re.f=Gc?Yc?function(t,e,r){if(Le(t),e=hi(e),Le(r),typeof t=="function"&&e==="prototype"&&"value"in r&&jn in r&&!r[jn]){var i=Jc(t,e);i&&i[jn]&&(t[e]=r.value,r={configurable:Dn in r?r[Dn]:i[Dn],enumerable:zn in r?r[zn]:i[zn],writable:!1})}return Fn(t,e,r)}:Fn:function(t,e,r){if(Le(t),e=hi(e),Le(r),Kc)try{return Fn(t,e,r)}catch{}if("get"in r||"set"in r)throw new Zc("Accessors not supported");return"value"in r&&(t[e]=r.value),t};var Qc=jt,tl=Re,el=Nr,di=Qc?function(n,t,e){return tl.f(n,t,el(1,e))}:function(n,t,e){return n[t]=e,n},fi={exports:{}},Un=jt,nl=Ut,pi=Function.prototype,rl=Un&&Object.getOwnPropertyDescriptor,il=nl(pi,"name"),sl=il&&(!Un||Un&&rl(pi,"name").configurable),ol={CONFIGURABLE:sl},al=ht,cl=vt,Wn=Mn,ll=al(Function.toString);cl(Wn.inspectSource)||(Wn.inspectSource=function(n){return ll(n)});var ul=Wn.inspectSource,hl=wt,dl=vt,gi=hl.WeakMap,fl=dl(gi)&&/native code/.test(String(gi)),pl=ri,gl=ii,mi=pl("keys"),ml=function(n){return mi[n]||(mi[n]=gl(n))},bi={},bl=fl,yi=wt,yl=di,Hn=Ut,Vn=Mn,wl=ml,vl=bi,wi="Object already initialized",vi=yi.TypeError,Sl=yi.WeakMap,qn,Me,Xn,xl=function(n){return Xn(n)?Me(n):qn(n,{})};if(bl||Vn.state){var At=Vn.state||(Vn.state=new Sl);At.get=At.get,At.has=At.has,At.set=At.set,qn=function(n,t){if(At.has(n))throw new vi(wi);return t.facade=n,At.set(n,t),t},Me=function(n){return At.get(n)||{}},Xn=function(n){return At.has(n)}}else{var Zt=wl("state");vl[Zt]=!0,qn=function(n,t){if(Hn(n,Zt))throw new vi(wi);return t.facade=n,yl(n,Zt,t),t},Me=function(n){return Hn(n,Zt)?n[Zt]:{}},Xn=function(n){return Hn(n,Zt)}}var _l={get:Me,enforce:xl},Gn=ht,El=kt,Tl=vt,Pe=Ut,Kn=jt,kl=ol.CONFIGURABLE,Al=ul,Si=_l,Cl=Si.enforce,$l=Si.get,xi=String,Ne=Object.defineProperty,Ol=Gn("".slice),Il=Gn("".replace),Rl=Gn([].join),Ll=Kn&&!El(function(){return Ne(function(){},"length",{value:8}).length!==8}),Ml=String(String).split("String"),Pl=fi.exports=function(n,t,e){Ol(xi(t),0,7)==="Symbol("&&(t="["+Il(xi(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),e&&e.getter&&(t="get "+t),e&&e.setter&&(t="set "+t),(!Pe(n,"name")||kl&&n.name!==t)&&(Kn?Ne(n,"name",{value:t,configurable:!0}):n.name=t),Ll&&e&&Pe(e,"arity")&&n.length!==e.arity&&Ne(n,"length",{value:e.arity});try{e&&Pe(e,"constructor")&&e.constructor?Kn&&Ne(n,"prototype",{writable:!1}):n.prototype&&(n.prototype=void 0)}catch{}var r=Cl(n);return Pe(r,"source")||(r.source=Rl(Ml,typeof t=="string"?t:"")),n};Function.prototype.toString=Pl(function(){return Tl(this)&&$l(this).source||Al(this)},"toString");var Nl=fi.exports,Bl=vt,Fl=Re,zl=Nl,Dl=Ln,jl=function(n,t,e,r){r||(r={});var i=r.enumerable,s=r.name!==void 0?r.name:t;if(Bl(e)&&zl(e,s,r),r.global)i?n[t]=e:Dl(t,e);else{try{r.unsafe?n[t]&&(i=!0):delete n[t]}catch{}i?n[t]=e:Fl.f(n,t,{value:e,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return n},_i={},Ul=Math.ceil,Wl=Math.floor,Hl=Math.trunc||function(t){var e=+t;return(e>0?Wl:Ul)(e)},Vl=Hl,Ei=function(n){var t=+n;return t!==t||t===0?0:Vl(t)},ql=Ei,Xl=Math.max,Gl=Math.min,Kl=function(n,t){var e=ql(n);return e<0?Xl(e+t,0):Gl(e,t)},Yl=Ei,Zl=Math.min,Jl=function(n){var t=Yl(n);return t>0?Zl(t,9007199254740991):0},Ql=Jl,Ti=function(n){return Ql(n.length)},tu=_n,eu=Kl,nu=Ti,ru=function(n){return function(t,e,r){var i=tu(t),s=nu(i);if(s===0)return!n&&-1;var o=eu(r,s),a;if(n&&e!==e){for(;s>o;)if(a=i[o++],a!==a)return!0}else for(;s>o;o++)if((n||o in i)&&i[o]===e)return n||o||0;return!n&&-1}},iu={indexOf:ru(!1)},su=ht,Yn=Ut,ou=_n,au=iu.indexOf,cu=bi,ki=su([].push),lu=function(n,t){var e=ou(n),r=0,i=[],s;for(s in e)!Yn(cu,s)&&Yn(e,s)&&ki(i,s);for(;t.length>r;)Yn(e,s=t[r++])&&(~au(i,s)||ki(i,s));return i},uu=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],hu=lu,du=uu,fu=du.concat("length","prototype");_i.f=Object.getOwnPropertyNames||function(t){return hu(t,fu)};var Ai={};Ai.f=Object.getOwnPropertySymbols;var pu=kn,gu=ht,mu=_i,bu=Ai,yu=ce,wu=gu([].concat),vu=pu("Reflect","ownKeys")||function(t){var e=mu.f(yu(t)),r=bu.f;return r?wu(e,r(t)):e},Ci=Ut,Su=vu,xu=bn,_u=Re,Eu=function(n,t,e){for(var r=Su(t),i=_u.f,s=xu.f,o=0;o<r.length;o++){var a=r[o];!Ci(n,a)&&!(e&&Ci(e,a))&&i(n,a,s(t,a))}},Tu=kt,ku=vt,Au=/#|\.prototype\./,le=function(n,t){var e=$u[Cu(n)];return e===Iu?!0:e===Ou?!1:ku(t)?Tu(t):!!t},Cu=le.normalize=function(n){return String(n).replace(Au,".").toLowerCase()},$u=le.data={},Ou=le.NATIVE="N",Iu=le.POLYFILL="P",Ru=le,Be=wt,Lu=bn.f,Mu=di,Pu=jl,Nu=Ln,Bu=Eu,Fu=Ru,$i=function(n,t){var e=n.target,r=n.global,i=n.stat,s,o,a,c,l,u;if(r?o=Be:i?o=Be[e]||Nu(e,{}):o=Be[e]&&Be[e].prototype,o)for(a in t){if(l=t[a],n.dontCallGetSet?(u=Lu(o,a),c=u&&u.value):c=o[a],s=Fu(r?a:e+(i?".":"#")+a,n.forced),!s&&c!==void 0){if(typeof l==typeof c)continue;Bu(l,c)}(n.sham||c&&c.sham)&&Mu(l,"sham",!0),Pu(o,a,l,n)}},zu=vn,Du=ht,ju=function(n){if(zu(n)==="Function")return Du(n)},Oi=ju,Uu=oe,Wu=yn,Hu=Oi(Oi.bind),Vu=function(n,t){return Uu(n),t===void 0?n:Wu?Hu(n,t):function(){return n.apply(t,arguments)}},Ii={},qu=ae,Xu=Ii,Gu=qu("iterator"),Ku=Array.prototype,Yu=function(n){return n!==void 0&&(Xu.Array===n||Ku[Gu]===n)},Zu=ae,Ju=Zu("toStringTag"),Ri={};Ri[Ju]="z";var Qu=String(Ri)==="[object z]",th=Qu,eh=vt,Fe=vn,nh=ae,rh=nh("toStringTag"),ih=Object,sh=Fe(function(){return arguments}())==="Arguments",oh=function(n,t){try{return n[t]}catch{}},ah=th?Fe:function(n){var t,e,r;return n===void 0?"Undefined":n===null?"Null":typeof(e=oh(t=ih(n),rh))=="string"?e:sh?Fe(t):(r=Fe(t))==="Object"&&eh(t.callee)?"Arguments":r},ch=ah,Li=$n,lh=xn,uh=Ii,hh=ae,dh=hh("iterator"),Mi=function(n){if(!lh(n))return Li(n,dh)||Li(n,"@@iterator")||uh[ch(n)]},fh=Kt,ph=oe,gh=ce,mh=Cn,bh=Mi,yh=TypeError,wh=function(n,t){var e=arguments.length<2?bh(n):t;if(ph(e))return gh(fh(e,n));throw new yh(mh(n)+" is not iterable")},vh=Kt,Pi=ce,Sh=$n,xh=function(n,t,e){var r,i;Pi(n);try{if(r=Sh(n,"return"),!r){if(t==="throw")throw e;return e}r=vh(r,n)}catch(s){i=!0,r=s}if(t==="throw")throw e;if(i)throw r;return Pi(r),e},_h=Vu,Eh=Kt,Th=ce,kh=Cn,Ah=Yu,Ch=Ti,Ni=Dr,$h=wh,Oh=Mi,Bi=xh,Ih=TypeError,ze=function(n,t){this.stopped=n,this.result=t},Fi=ze.prototype,zi=function(n,t,e){var r=e&&e.that,i=!!(e&&e.AS_ENTRIES),s=!!(e&&e.IS_RECORD),o=!!(e&&e.IS_ITERATOR),a=!!(e&&e.INTERRUPTED),c=_h(t,r),l,u,h,g,p,d,b,f=function(y){return l&&Bi(l,"normal"),new ze(!0,y)},m=function(y){return i?(Th(y),a?c(y[0],y[1],f):c(y[0],y[1])):a?c(y,f):c(y)};if(s)l=n.iterator;else if(o)l=n;else{if(u=Oh(n),!u)throw new Ih(kh(n)+" is not iterable");if(Ah(u)){for(h=0,g=Ch(n);g>h;h++)if(p=m(n[h]),p&&Ni(Fi,p))return p;return new ze(!1)}l=$h(n,u)}for(d=s?n.next:l.next;!(b=Eh(d,l)).done;){try{p=m(b.value)}catch(y){Bi(l,"throw",y)}if(typeof p=="object"&&p&&Ni(Fi,p))return p}return new ze(!1)},De=ht,je=Map.prototype,Rh={Map,set:De(je.set),get:De(je.get),has:De(je.has),remove:De(je.delete)},Lh=$i,Mh=ht,Ph=oe,Nh=$e,Bh=zi,Ue=Rh,Fh=kt,Di=Ue.Map,zh=Ue.has,Dh=Ue.get,jh=Ue.set,Uh=Mh([].push),Wh=Fh(function(){return Di.groupBy("ab",function(n){return n}).get("a").length!==1});Lh({target:"Map",stat:!0,forced:Wh},{groupBy:function(t,e){Nh(t),Ph(e);var r=new Di,i=0;return Bh(t,function(s){var o=e(s,i++);zh(r,o)?Uh(Dh(r,o),s):jh(r,o,[s])}),r}});var Hh=$i,Vh=kn,qh=ht,Xh=oe,Gh=$e,Kh=Nn,Yh=zi,Zh=kt,ji=Object.groupBy,Jh=Vh("Object","create"),Qh=qh([].push),td=!ji||Zh(function(){return ji("ab",function(n){return n}).a.length!==1});Hh({target:"Object",stat:!0,forced:td},{groupBy:function(t,e){Gh(t),Xh(e);var r=Jh(null),i=0;return Yh(t,function(s){var o=Kh(e(s,i++));o in r?Qh(r[o],s):r[o]=[s]}),r}});function ed(n,t){n.addEventListener("keyup",e=>{e.key==="ArrowUp"||e.key==="ArrowRight"?t("next"):(e.key==="ArrowDown"||e.key==="ArrowLeft")&&t("prev")},!1)}function nd(n,t){let i=0,s=null;n.addEventListener("wheel",o=>{o.ignore||(o.ignore=!0,s&&clearTimeout(s),i+=o.deltaY,s=setTimeout(()=>{if(Math.abs(i)>=750){let a=Math.sign(i)>0?"next":"prev";t(a),i=0}i=0},50))})}function rd(n,t){let s,o,a;n.addEventListener("touchstart",c=>{c.ignore||(c.ignore=!0,s=c.changedTouches[0].pageX,o=c.changedTouches[0].pageY,a=Date.now())},!1),n.addEventListener("touchend",c=>{var g,p;if(c.ignore)return;c.ignore=!0;const l=c.changedTouches[0].pageX-s,u=c.changedTouches[0].pageY-o;Date.now()-a<=500&&(Math.abs(l)>=50&&Math.abs(u)<=200?t(l<0?"next":"prev"):Math.abs(u)>=50&&Math.abs(l)<=200?t(u<0?"up":"down"):((p=(g=n==null?void 0:n.defaultView)==null?void 0:g.getSelection())==null||p.removeAllRanges(),n.dispatchEvent(new MouseEvent("click",{clientX:s,clientY:o})),c.preventDefault()))},!1)}const id=(n,t)=>{const e=n.__vccOpts||n;for(const[r,i]of t)e[r]=i;return e},sd={class:"reader"},od={class:"viewHolder"},ad={key:0},Ui=id({__name:"BookView",props:{url:{type:[String,File]},location:{type:[String,Number]},tocChanged:Function,getRendition:Function},emits:["update:location"],setup(n,{expose:t,emit:e}){const r=n,{tocChanged:i,getRendition:s}=r,{url:o,location:a}=L.toRefs(r),c=e;let l=null;const u=L.ref(null),h=L.ref(!1),g=({spacing:x,justify:v,hyphenate:A})=>`
@namespace epub "http://www.idpf.org/2007/ops";
html {
color-scheme: light dark;
}
/* https://github.com/whatwg/html/issues/5426 */
@media (prefers-color-scheme: dark) {
a:link {
color: lightblue;
}
}
p, li, blockquote, dd {
line-height: ${x};
text-align: start;
-webkit-hyphens: auto;
hyphens: auto;
-webkit-hyphenate-limit-before: 3;
-webkit-hyphenate-limit-after: 2;
-webkit-hyphenate-limit-lines: 2;
hanging-punctuation: allow-end last;
widows: 2;
}
/* prevent the above from overriding the align attribute */
[align="left"] { text-align: left; }
[align="right"] { text-align: right; }
[align="center"] { text-align: center; }
[align="justify"] { text-align: justify; }
pre {
white-space: pre-wrap !important;
}
aside[epub|type~="endnote"],
aside[epub|type~="footnote"],
aside[epub|type~="note"],
aside[epub|type~="rearnote"] {
display: none;
}
`,p=async()=>{l=document.createElement("foliate-view"),u.value.append(l),o.value&&(l&&l.close(),typeof o.value=="string"?(await l.open(o.value),d()):(l=await getView(o.value,u.value),d()))},d=()=>{var v,A;h.value=!0;const{book:x}=l;(A=(v=l.renderer).setStyles)==null||A.call(v,g({spacing:1.4,justify:!1,hyphenate:!0})),f(),s(l),i&&i(x.toc),a.value?l==null||l.goTo(a.value):l.renderer.next()},b=x=>{x==="next"?w():x==="prev"&&S()},f=()=>{l.addEventListener("load",m),l.addEventListener("relocate",y)},m=({detail:{doc:x}})=>{nd(x,b),rd(x,b),ed(x,b)},y=({detail:x})=>{c("update:location",x)},w=()=>l==null?void 0:l.next(),S=()=>l==null?void 0:l.prev(),_=x=>l==null?void 0:l.goTo(x);return L.watch(o,()=>{p()}),L.onMounted(()=>{p()}),t({nextPage:w,prevPage:S,setLocation:_}),(x,v)=>(L.openBlock(),L.createElementBlock("div",sd,[L.createElementVNode("div",od,[L.withDirectives(L.createElementVNode("div",{ref_key:"viewer",ref:u,id:"viewer"},null,512),[[L.vShow,h.value]]),h.value?L.createCommentVNode("",!0):(L.openBlock(),L.createElementBlock("div",ad,[L.renderSlot(x.$slots,"loadingView",{},void 0,!0)]))])]))}},[["__scopeId","data-v-3286d5d6"]]),cd={class:"container"},ld=["title"],ud={key:0},hd={class:"tocArea"},Wi={__name:"VueReader",props:{title:{type:String},showToc:{type:Boolean,default:!0},getRendition:{type:Function},backgroundColor:{type:String,default:"#fff"},hidePrevNext:{type:Boolean,default:!1},hideTitle:{type:Boolean,default:!1}},emits:["update:location"],setup(n,{expose:t,emit:e}){const r=L.defineComponent({name:"TocComponent",props:{toc:{type:Array,default:()=>[]},current:{type:[String,Number],default:""},setLocation:{type:Function,required:!0},isSubmenu:{type:Boolean,default:!1,required:!1}},setup(w){const S=L.getCurrentInstance(),_=L.h.bind(S),{setLocation:x,isSubmenu:v}=w,{toc:A,current:O}=L.toRefs(w);return()=>A.value.map((T,E)=>_("div",{key:E},[_("button",{class:["tocAreaButton",T.href===O.value?"active":""],onClick:()=>{T.subitems&&T.subitems.length>0?(T.expansion=!T.expansion,x(T.href,!1)):x(T.href)}},[v?" ".repeat(4)+T.label:T.label,T.subitems&&T.subitems.length>0&&_("div",{class:`${T.expansion?"open":""} expansion`})]),T.subitems&&T.subitems.length>0&&_(L.Transition,{name:"collapse-transition"},{default:()=>_("div",{style:{display:T.expansion?void 0:"none"}},[_(r,{toc:T.subitems,current:O.value,setLocation:x,isSubmenu:!0})])})]))}}),i=n,s=e,o=L.reactive({toc:[],expandedToc:!1}),{getRendition:a}=i,{toc:c,expandedToc:l}=L.toRefs(o),u=L.ref(null),h=L.ref(null),g=L.ref(""),p=w=>{var x;a&&a(w);const{book:S}=w,_=(x=S.metadata)==null?void 0:x.title;g.value=_||""},d=w=>{c.value=w},b=()=>{l.value=!l.value},f=()=>{var w;(w=u.value)==null||w.nextPage()},m=()=>{var w;(w=u.value)==null||w.prevPage()},y=(w,S=!0)=>{u.value.setLocation(w),l.value=!1,l.value=!S};return t({next:f,pre:m,setLocation:y}),(w,S)=>(L.openBlock(),L.createElementBlock("div",cd,[L.createElementVNode("div",{class:L.normalizeClass(["readerArea",{containerExpanded:L.unref(l)}]),style:L.normalizeStyle({backgroundColor:n.backgroundColor})},[n.showToc?(L.openBlock(),L.createElementBlock("button",{key:0,class:L.normalizeClass(["tocButton",{tocButtonExpanded:L.unref(l)}]),type:"button",onClick:b},[...S[1]||(S[1]=[L.createElementVNode("span",{class:"tocButtonBar",style:{top:"35%"}},null,-1),L.createElementVNode("span",{class:"tocButtonBar",style:{top:"66%"}},null,-1)])],2)):L.createCommentVNode("",!0),i.hideTitle?L.createCommentVNode("",!0):L.renderSlot(w.$slots,"title",{key:1},()=>[L.createElementVNode("div",{class:"titleArea",title:n.title||g.value},L.toDisplayString(n.title||g.value),9,ld)]),L.createVNode(Ui,L.mergeProps({ref_key:"bookRef",ref:u},w.$attrs,{tocChanged:d,getRendition:p,"onUpdate:location":S[0]||(S[0]=_=>s("update:location",_))}),{loadingView:L.withCtx(()=>[L.renderSlot(w.$slots,"loadingView",{},()=>[S[2]||(S[2]=L.createElementVNode("div",{class:"loadingView"},"Loading…",-1))])]),_:3},16),i.hidePrevNext?L.createCommentVNode("",!0):(L.openBlock(),L.createElementBlock("button",{key:2,class:"arrow pre",onClick:m},"‹")),i.hidePrevNext?L.createCommentVNode("",!0):(L.openBlock(),L.createElementBlock("button",{key:3,class:"arrow next",onClick:f},"›"))],6),n.showToc?(L.openBlock(),L.createElementBlock("div",ud,[L.createElementVNode("div",hd,[L.createVNode(L.unref(r),{toc:L.unref(c),current:h.value,setLocation:y},null,8,["toc","current"])]),L.unref(l)?(L.openBlock(),L.createElementBlock("div",{key:0,class:"tocBackground",onClick:b})):L.createCommentVNode("",!0)])):L.createCommentVNode("",!0)]))}},lt=-2,X=-3,It=-5,dt=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],dd=[96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,192,80,7,10,0,8,96,0,8,32,0,9,160,0,8,0,0,8,128,0,8,64,0,9,224,80,7,6,0,8,88,0,8,24,0,9,144,83,7,59,0,8,120,0,8,56,0,9,208,81,7,17,0,8,104,0,8,40,0,9,176,0,8,8,0,8,136,0,8,72,0,9,240,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,200,81,7,13,0,8,100,0,8,36,0,9,168,0,8,4,0,8,132,0,8,68,0,9,232,80,7,8,0,8,92,0,8,28,0,9,152,84,7,83,0,8,124,0,8,60,0,9,216,82,7,23,0,8,108,0,8,44,0,9,184,0,8,12,0,8,140,0,8,76,0,9,248,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,196,81,7,11,0,8,98,0,8,34,0,9,164,0,8,2,0,8,130,0,8,66,0,9,228,80,7,7,0,8,90,0,8,26,0,9,148,84,7,67,0,8,122,0,8,58,0,9,212,82,7,19,0,8,106,0,8,42,0,9,180,0,8,10,0,8,138,0,8,74,0,9,244,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,204,81,7,15,0,8,102,0,8,38,0,9,172,0,8,6,0,8,134,0,8,70,0,9,236,80,7,9,0,8,94,0,8,30,0,9,156,84,7,99,0,8,126,0,8,62,0,9,220,82,7,27,0,8,110,0,8,46,0,9,188,0,8,14,0,8,142,0,8,78,0,9,252,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,194,80,7,10,0,8,97,0,8,33,0,9,162,0,8,1,0,8,129,0,8,65,0,9,226,80,7,6,0,8,89,0,8,25,0,9,146,83,7,59,0,8,121,0,8,57,0,9,210,81,7,17,0,8,105,0,8,41,0,9,178,0,8,9,0,8,137,0,8,73,0,9,242,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,202,81,7,13,0,8,101,0,8,37,0,9,170,0,8,5,0,8,133,0,8,69,0,9,234,80,7,8,0,8,93,0,8,29,0,9,154,84,7,83,0,8,125,0,8,61,0,9,218,82,7,23,0,8,109,0,8,45,0,9,186,0,8,13,0,8,141,0,8,77,0,9,250,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,198,81,7,11,0,8,99,0,8,35,0,9,166,0,8,3,0,8,131,0,8,67,0,9,230,80,7,7,0,8,91,0,8,27,0,9,150,84,7,67,0,8,123,0,8,59,0,9,214,82,7,19,0,8,107,0,8,43,0,9,182,0,8,11,0,8,139,0,8,75,0,9,246,80,7,5,0,8,87,0,8,23,192,8,0,8