react-book-reader 1.0.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.
@@ -0,0 +1,715 @@
1
+ (function(){"use strict";try{if(typeof document<"u"){var o=document.createElement("style");o.appendChild(document.createTextNode('.reader{position:absolute;top:50px;right:50px;bottom:20px;left:50px}.viewHolder{height:100%;width:100%;position:relative}#viewer{height:100%}.container{overflow:hidden;position:relative;height:100%}.containerExpanded{transform:translate(256px)}.readerArea{position:relative;z-index:1;height:100%;width:100%;background-color:#fff;transition:all .3s ease}.container .titleArea{position:absolute;top:20px;left:50px;right:50px;text-align:center;color:#999;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tocBackground{position:absolute;left:256px;top:0;bottom:0;right:0;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;-moz-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;-moz-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(o)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
2
+ (function(q,W){typeof exports=="object"&&typeof module<"u"?W(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],W):(q=typeof globalThis<"u"?globalThis:q||self,W(q["react-book-reader"]={},q.require$$0))})(this,function(q,W){"use strict";var cf=Object.defineProperty;var lf=(q,W,it)=>W in q?cf(q,W,{enumerable:!0,configurable:!0,writable:!0,value:it}):q[W]=it;var It=(q,W,it)=>(lf(q,typeof W!="symbol"?W+"":W,it),it),no=(q,W,it)=>{if(!W.has(q))throw TypeError("Cannot "+it)};var u=(q,W,it)=>(no(q,W,"read from private field"),it?it.call(q):W.get(q)),E=(q,W,it)=>{if(W.has(q))throw TypeError("Cannot add the same private member more than once");W instanceof WeakSet?W.add(q):W.set(q,it)},R=(q,W,it,ne)=>(no(q,W,"write to private field"),ne?ne.call(q,it):W.set(q,it),it);var hr=(q,W,it,ne)=>({set _(gr){R(q,W,gr,it)},get _(){return u(q,W,ne)}}),C=(q,W,it)=>(no(q,W,"access private method"),it);var Wr,nl,oe,ae,$t,Ct,Hr,ye,Yt,$e,ve,qs,Xs,Gs,Ys,Ks,Kt,Pe,Vr,il,qr,rl,Xr,sl,Bn,ls,Gr,ol,Yr,al,Kr,cl,Wc,fn,Ci,xe,We,Dn,Zt,Jt,Qt,He,Un,us,pn,dr,Ri,io,Ii,ro,Mi,so,jn,hs,zi,zt,dt,Oi,gt,Et,Pi,$n,ce,Wn,Ve,Ni,gn,Ot,qe,mn,Z,Wt,te,_e,le,Se,Hn,bn,Fi,Bi,Di,Vn,Xe,wn,qn,Zr,ll,Ui,oo,ji,ao,$i,co,Wi,lo,yn,fr,Jr,ul,Ge,hi,Ye,di,Qr,hl,ts,dl,vn,pr,Hi,uo,Vi,ho,Xn,ds,es,fl,ns,pl,ke,Ln,qi,fo,ft,Gn,Pt,ee,Ee,Yn,ue,Xi,Kn,fs,Ke,fi,Ze,Gi,xn,Ht,Rt,yt,Yi,Ki,is,gl,Zn,ps,Je,pi,Ae,Cn,Zi,po,Jn,gs,Te,Rn,Ji,Qn,Qi,Le,Ce,he,_n,ti,Re,In,ei,ni,ii,tr,er,nr,ri,ir,rr,go,rs,ml,Sn,si,kn,Qe,sr,or,de,oi,En,An,Tn,tn,en,Ie,ss,os,nn,ar,cr,mo;var it={exports:{}},ne={};/**
3
+ * @license React
4
+ * react-jsx-runtime.production.min.js
5
+ *
6
+ * Copyright (c) Facebook, Inc. and its affiliates.
7
+ *
8
+ * This source code is licensed under the MIT license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ */var gr;function bl(){if(gr)return ne;gr=1;var r=W,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function o(c,a,l){var h,d={},g=null,b=null;l!==void 0&&(g=""+l),a.key!==void 0&&(g=""+a.key),a.ref!==void 0&&(b=a.ref);for(h in a)n.call(a,h)&&!s.hasOwnProperty(h)&&(d[h]=a[h]);if(c&&c.defaultProps)for(h in a=c.defaultProps,a)d[h]===void 0&&(d[h]=a[h]);return{$$typeof:e,type:c,key:g,ref:b,props:d,_owner:i.current}}return ne.Fragment=t,ne.jsx=o,ne.jsxs=o,ne}var gi={};/**
11
+ * @license React
12
+ * react-jsx-runtime.development.js
13
+ *
14
+ * Copyright (c) Facebook, Inc. and its affiliates.
15
+ *
16
+ * This source code is licensed under the MIT license found in the
17
+ * LICENSE file in the root directory of this source tree.
18
+ */var bo;function wl(){return bo||(bo=1,process.env.NODE_ENV!=="production"&&function(){var r=W,e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),c=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.offscreen"),f=Symbol.iterator,w="@@iterator";function p(v){if(v===null||typeof v!="object")return null;var O=f&&v[f]||v[w];return typeof O=="function"?O:null}var m=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function y(v){{for(var O=arguments.length,N=new Array(O>1?O-1:0),$=1;$<O;$++)N[$-1]=arguments[$];S("error",v,N)}}function S(v,O,N){{var $=m.ReactDebugCurrentFrame,K=$.getStackAddendum();K!==""&&(O+="%s",N=N.concat([K]));var J=N.map(function(G){return String(G)});J.unshift("Warning: "+O),Function.prototype.apply.call(console[v],console,J)}}var _=!1,k=!1,T=!1,x=!1,I=!1,F;F=Symbol.for("react.module.reference");function P(v){return!!(typeof v=="string"||typeof v=="function"||v===n||v===s||I||v===i||v===l||v===h||x||v===b||_||k||T||typeof v=="object"&&v!==null&&(v.$$typeof===g||v.$$typeof===d||v.$$typeof===o||v.$$typeof===c||v.$$typeof===a||v.$$typeof===F||v.getModuleId!==void 0))}function A(v,O,N){var $=v.displayName;if($)return $;var K=O.displayName||O.name||"";return K!==""?N+"("+K+")":N}function L(v){return v.displayName||"Context"}function z(v){if(v==null)return null;if(typeof v.tag=="number"&&y("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof v=="function")return v.displayName||v.name||null;if(typeof v=="string")return v;switch(v){case n:return"Fragment";case t:return"Portal";case s:return"Profiler";case i:return"StrictMode";case l:return"Suspense";case h:return"SuspenseList"}if(typeof v=="object")switch(v.$$typeof){case c:var O=v;return L(O)+".Consumer";case o:var N=v;return L(N._context)+".Provider";case a:return A(v,v.render,"ForwardRef");case d:var $=v.displayName||null;return $!==null?$:z(v.type)||"Memo";case g:{var K=v,J=K._payload,G=K._init;try{return z(G(J))}catch{return null}}}return null}var B=Object.assign,U=0,M,j,pt,ot,D,Q,H;function X(){}X.__reactDisabledLog=!0;function fe(){{if(U===0){M=console.log,j=console.info,pt=console.warn,ot=console.error,D=console.group,Q=console.groupCollapsed,H=console.groupEnd;var v={configurable:!0,enumerable:!0,value:X,writable:!0};Object.defineProperties(console,{info:v,log:v,warn:v,error:v,group:v,groupCollapsed:v,groupEnd:v})}U++}}function Me(){{if(U--,U===0){var v={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:B({},v,{value:M}),info:B({},v,{value:j}),warn:B({},v,{value:pt}),error:B({},v,{value:ot}),group:B({},v,{value:D}),groupCollapsed:B({},v,{value:Q}),groupEnd:B({},v,{value:H})})}U<0&&y("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var mt=m.ReactCurrentDispatcher,bt;function lt(v,O,N){{if(bt===void 0)try{throw Error()}catch(K){var $=K.stack.trim().match(/\n( *(at )?)/);bt=$&&$[1]||""}return`
19
+ `+bt+v}}var Nt=!1,ze;{var rn=typeof WeakMap=="function"?WeakMap:Map;ze=new rn}function ai(v,O){if(!v||Nt)return"";{var N=ze.get(v);if(N!==void 0)return N}var $;Nt=!0;var K=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var J;J=mt.current,mt.current=null,fe();try{if(O){var G=function(){throw Error()};if(Object.defineProperty(G.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(G,[])}catch(Oe){$=Oe}Reflect.construct(v,[],G)}else{try{G.call()}catch(Oe){$=Oe}v.call(G.prototype)}}else{try{throw Error()}catch(Oe){$=Oe}v()}}catch(Oe){if(Oe&&$&&typeof Oe.stack=="string"){for(var V=Oe.stack.split(`
20
+ `),At=$.stack.split(`
21
+ `),at=V.length-1,ct=At.length-1;at>=1&&ct>=0&&V[at]!==At[ct];)ct--;for(;at>=1&&ct>=0;at--,ct--)if(V[at]!==At[ct]){if(at!==1||ct!==1)do if(at--,ct--,ct<0||V[at]!==At[ct]){var Vt=`
22
+ `+V[at].replace(" at new "," at ");return v.displayName&&Vt.includes("<anonymous>")&&(Vt=Vt.replace("<anonymous>",v.displayName)),typeof v=="function"&&ze.set(v,Vt),Vt}while(at>=1&&ct>=0);break}}}finally{Nt=!1,mt.current=J,Me(),Error.prepareStackTrace=K}var ui=v?v.displayName||v.name:"",el=ui?lt(ui):"";return typeof v=="function"&&ze.set(v,el),el}function lr(v,O,N){return ai(v,!1)}function vt(v){var O=v.prototype;return!!(O&&O.isReactComponent)}function pe(v,O,N){if(v==null)return"";if(typeof v=="function")return ai(v,vt(v));if(typeof v=="string")return lt(v);switch(v){case l:return lt("Suspense");case h:return lt("SuspenseList")}if(typeof v=="object")switch(v.$$typeof){case a:return lr(v.render);case d:return pe(v.type,O,N);case g:{var $=v,K=$._payload,J=$._init;try{return pe(J(K),O,N)}catch{}}}return""}var ci=Object.prototype.hasOwnProperty,as={},Hc=m.ReactDebugCurrentFrame;function cs(v){if(v){var O=v._owner,N=pe(v.type,v._source,O?O.type:null);Hc.setExtraStackFrame(N)}else Hc.setExtraStackFrame(null)}function jd(v,O,N,$,K){{var J=Function.call.bind(ci);for(var G in v)if(J(v,G)){var V=void 0;try{if(typeof v[G]!="function"){var At=Error(($||"React class")+": "+N+" type `"+G+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof v[G]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw At.name="Invariant Violation",At}V=v[G](O,G,$,N,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(at){V=at}V&&!(V instanceof Error)&&(cs(K),y("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",$||"React class",N,G,typeof V),cs(null)),V instanceof Error&&!(V.message in as)&&(as[V.message]=!0,cs(K),y("Failed %s type: %s",N,V.message),cs(null))}}}var $d=Array.isArray;function Zs(v){return $d(v)}function Wd(v){{var O=typeof Symbol=="function"&&Symbol.toStringTag,N=O&&v[Symbol.toStringTag]||v.constructor.name||"Object";return N}}function Hd(v){try{return Vc(v),!1}catch{return!0}}function Vc(v){return""+v}function qc(v){if(Hd(v))return y("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Wd(v)),Vc(v)}var ur=m.ReactCurrentOwner,Vd={key:!0,ref:!0,__self:!0,__source:!0},Xc,Gc,Js;Js={};function qd(v){if(ci.call(v,"ref")){var O=Object.getOwnPropertyDescriptor(v,"ref").get;if(O&&O.isReactWarning)return!1}return v.ref!==void 0}function Xd(v){if(ci.call(v,"key")){var O=Object.getOwnPropertyDescriptor(v,"key").get;if(O&&O.isReactWarning)return!1}return v.key!==void 0}function Gd(v,O){if(typeof v.ref=="string"&&ur.current&&O&&ur.current.stateNode!==O){var N=z(ur.current.type);Js[N]||(y('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',z(ur.current.type),v.ref),Js[N]=!0)}}function Yd(v,O){{var N=function(){Xc||(Xc=!0,y("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",O))};N.isReactWarning=!0,Object.defineProperty(v,"key",{get:N,configurable:!0})}}function Kd(v,O){{var N=function(){Gc||(Gc=!0,y("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",O))};N.isReactWarning=!0,Object.defineProperty(v,"ref",{get:N,configurable:!0})}}var Zd=function(v,O,N,$,K,J,G){var V={$$typeof:e,type:v,key:O,ref:N,props:G,_owner:J};return V._store={},Object.defineProperty(V._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(V,"_self",{configurable:!1,enumerable:!1,writable:!1,value:$}),Object.defineProperty(V,"_source",{configurable:!1,enumerable:!1,writable:!1,value:K}),Object.freeze&&(Object.freeze(V.props),Object.freeze(V)),V};function Jd(v,O,N,$,K){{var J,G={},V=null,At=null;N!==void 0&&(qc(N),V=""+N),Xd(O)&&(qc(O.key),V=""+O.key),qd(O)&&(At=O.ref,Gd(O,K));for(J in O)ci.call(O,J)&&!Vd.hasOwnProperty(J)&&(G[J]=O[J]);if(v&&v.defaultProps){var at=v.defaultProps;for(J in at)G[J]===void 0&&(G[J]=at[J])}if(V||At){var ct=typeof v=="function"?v.displayName||v.name||"Unknown":v;V&&Yd(G,ct),At&&Kd(G,ct)}return Zd(v,V,At,K,$,ur.current,G)}}var Qs=m.ReactCurrentOwner,Yc=m.ReactDebugCurrentFrame;function li(v){if(v){var O=v._owner,N=pe(v.type,v._source,O?O.type:null);Yc.setExtraStackFrame(N)}else Yc.setExtraStackFrame(null)}var to;to=!1;function eo(v){return typeof v=="object"&&v!==null&&v.$$typeof===e}function Kc(){{if(Qs.current){var v=z(Qs.current.type);if(v)return`
23
+
24
+ Check the render method of \``+v+"`."}return""}}function Qd(v){{if(v!==void 0){var O=v.fileName.replace(/^.*[\\\/]/,""),N=v.lineNumber;return`
25
+
26
+ Check your code at `+O+":"+N+"."}return""}}var Zc={};function tf(v){{var O=Kc();if(!O){var N=typeof v=="string"?v:v.displayName||v.name;N&&(O=`
27
+
28
+ Check the top-level render call using <`+N+">.")}return O}}function Jc(v,O){{if(!v._store||v._store.validated||v.key!=null)return;v._store.validated=!0;var N=tf(O);if(Zc[N])return;Zc[N]=!0;var $="";v&&v._owner&&v._owner!==Qs.current&&($=" It was passed a child from "+z(v._owner.type)+"."),li(v),y('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',N,$),li(null)}}function Qc(v,O){{if(typeof v!="object")return;if(Zs(v))for(var N=0;N<v.length;N++){var $=v[N];eo($)&&Jc($,O)}else if(eo(v))v._store&&(v._store.validated=!0);else if(v){var K=p(v);if(typeof K=="function"&&K!==v.entries)for(var J=K.call(v),G;!(G=J.next()).done;)eo(G.value)&&Jc(G.value,O)}}}function ef(v){{var O=v.type;if(O==null||typeof O=="string")return;var N;if(typeof O=="function")N=O.propTypes;else if(typeof O=="object"&&(O.$$typeof===a||O.$$typeof===d))N=O.propTypes;else return;if(N){var $=z(O);jd(N,v.props,"prop",$,v)}else if(O.PropTypes!==void 0&&!to){to=!0;var K=z(O);y("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",K||"Unknown")}typeof O.getDefaultProps=="function"&&!O.getDefaultProps.isReactClassApproved&&y("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function nf(v){{for(var O=Object.keys(v.props),N=0;N<O.length;N++){var $=O[N];if($!=="children"&&$!=="key"){li(v),y("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",$),li(null);break}}v.ref!==null&&(li(v),y("Invalid attribute `ref` supplied to `React.Fragment`."),li(null))}}function tl(v,O,N,$,K,J){{var G=P(v);if(!G){var V="";(v===void 0||typeof v=="object"&&v!==null&&Object.keys(v).length===0)&&(V+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var At=Qd(K);At?V+=At:V+=Kc();var at;v===null?at="null":Zs(v)?at="array":v!==void 0&&v.$$typeof===e?(at="<"+(z(v.type)||"Unknown")+" />",V=" Did you accidentally export a JSX literal instead of a component?"):at=typeof v,y("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",at,V)}var ct=Jd(v,O,N,K,J);if(ct==null)return ct;if(G){var Vt=O.children;if(Vt!==void 0)if($)if(Zs(Vt)){for(var ui=0;ui<Vt.length;ui++)Qc(Vt[ui],v);Object.freeze&&Object.freeze(Vt)}else y("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Qc(Vt,v)}return v===n?nf(ct):ef(ct),ct}}function rf(v,O,N){return tl(v,O,N,!0)}function sf(v,O,N){return tl(v,O,N,!1)}var of=sf,af=rf;gi.Fragment=n,gi.jsx=of,gi.jsxs=af}()),gi}process.env.NODE_ENV==="production"?it.exports=bl():it.exports=wl();var tt=it.exports;const yl=(r,e)=>r.map((t,n,i)=>e(t,n,i)?n:null).filter(t=>t!=null),wo=(r,e)=>[-1,...e,r.length].reduce(({xs:t,a:n},i)=>({xs:(t==null?void 0:t.concat([r.slice(n+1,i)]))??[],a:i}),{}).xs,vl=(r,e)=>r.slice(0,-1).concat([r[r.length-1].concat(e[0])]).concat(e.slice(1)),ms=/\d/,mr=/^epubcfi\((.*)\)$/,yo=r=>r.replace(/[\^[\](),;=]/g,"^$&"),vo=r=>mr.test(r)?r:`epubcfi(${r})`,xl=r=>{var e;return((e=r.match(mr))==null?void 0:e[1])??r},_l=(r=>(...e)=>`epubcfi(${r(...e.map(t=>{var n;return((n=t.match(mr))==null?void 0:n[1])??t}))})`)((...r)=>r.join("!")),Sl=r=>{const e=[];let t,n,i="";const s=c=>(e.push(c),t=null,i=""),o=c=>(i+=c,n=!1);for(const c of Array.from(r.trim()).concat("")){if(c==="^"&&!n){n=!0;continue}if(t==="!")s(["!"]);else if(t===",")s([","]);else if(t==="/"||t===":")if(ms.test(c)){o(c);continue}else s([t,parseInt(i)]);else if(t==="~")if(ms.test(c)||c==="."){o(c);continue}else s(["~",parseFloat(i)]);else if(t==="@"){if(c===":"){s(["@",parseFloat(i)]),t="@";continue}if(ms.test(c)||c==="."){o(c);continue}else s(["@",parseFloat(i)])}else if(t==="["){c===";"&&!n?(s(["[",i]),t=";"):c===","&&!n?(s(["[",i]),t="["):c==="]"&&!n?s(["[",i]):o(c);continue}else if(t!=null&&t.startsWith(";")){c==="="&&!n?(t=`;${i}`,i=""):c===";"&&!n?(s([t,i]),t=";"):c==="]"&&!n?s([t,i]):o(c);continue}(c==="/"||c===":"||c==="~"||c==="@"||c==="["||c==="!"||c===",")&&(t=c)}return e},xo=(r,e)=>yl(r,([t])=>t===e),kl=r=>{const e=[];let t;for(const[n,i]of r){if(n==="/")e.push({index:i});else{const s=e[e.length-1];if(n===":")s.offset=i;else if(n==="~")s.temporal=i;else if(n==="@")s.spatial=(s.spatial??[]).concat(i);else if(n===";s")s.side=i;else if(n==="[")if(t==="/"&&i)s.id=i;else{s.text=(s.text??[]).concat(i);continue}}t=n}return e},_o=r=>wo(r,xo(r,"!")).map(kl),mi=r=>{const e=Sl(xl(r)),t=xo(e,",");if(!t.length)return _o(e);const[n,i,s]=wo(e,t).map(_o);return{parent:n,start:i,end:s}},El=({index:r,id:e,offset:t,temporal:n,spatial:i,text:s,side:o})=>{var a;const c=o?`;s=${o}`:"";return`/${r}`+(e?`[${yo(e)}${c}]`:"")+(t!=null&&r%2?`:${t}`:"")+(n?`~${n}`:"")+(i?`@${i.join(":")}`:"")+(s||!e&&o?"["+(((a=s==null?void 0:s.map(yo))==null?void 0:a.join(","))??"")+c+"]":"")},So=r=>r.parent?[r.parent,r.start,r.end].map(So).join(","):r.map(e=>e.map(El).join("")).join("!"),br=r=>vo(So(r)),Mn=(r,e)=>typeof r=="string"?br(Mn(mi(r),e)):r.parent?vl(r.parent,r[e?"end":"start"]):r,Al=(r,e)=>{typeof r=="string"&&(r=mi(r)),typeof e=="string"&&(e=mi(e)),r=Mn(r),e=Mn(e,!0);const t=r[r.length-1],n=e[e.length-1],i=[],s=[],o=[];let c=!0;const a=Math.max(t.length,n.length);for(let h=0;h<a;h++){const d=t[h],g=n[h];c&&(c=(d==null?void 0:d.index)===(g==null?void 0:g.index)&&!(d!=null&&d.offset)&&!(g!=null&&g.offset)),c?i.push(d):(d&&s.push(d),g&&o.push(g))}const l=r.slice(0,-1).concat([i]);return br({parent:l,start:[s],end:[o]})},bs=({nodeType:r})=>r===3||r===4,wr=({nodeType:r})=>r===1,ko=(r,e)=>{const t=Array.from(r.childNodes).filter(n=>bs(n)||wr(n));return e?t.map(n=>{const i=e(n);return i===NodeFilter.FILTER_REJECT?null:i===NodeFilter.FILTER_SKIP?ko(n,e):n}).flat().filter(n=>n):t},ws=(r,e)=>{const t=ko(r,e).reduce((n,i)=>{let s=n[n.length-1];return s?bs(i)?Array.isArray(s)?s.push(i):bs(s)?n[n.length-1]=[s,i]:n.push(i):wr(s)?n.push(null,i):n.push(i):n.push(i),n},[]);return wr(t[0])&&t.unshift("first"),wr(t[t.length-1])&&t.push("last"),t.unshift("before"),t.push("after"),t},ys=(r,e,t)=>{const{id:n}=e[e.length-1];if(n){const o=r.ownerDocument.getElementById(n);if(o)return{node:o,offset:0}}for(const{index:o}of e){const c=r?ws(r,t)[o]:null;if(c==="first")return{node:r.firstChild??r};if(c==="last")return{node:r.lastChild??r};if(c==="before")return{node:r,before:!0};if(c==="after")return{node:r,after:!0};r=c}const{offset:i}=e[e.length-1];if(!Array.isArray(r))return{node:r,offset:i};let s=0;for(const o of r){const{length:c}=o.nodeValue;if(s+c>=i)return{node:o,offset:i-s};s+=c}},yr=(r,e,t)=>{const{parentNode:n,id:i}=r,s=ws(n,t),o=s.findIndex(l=>Array.isArray(l)?l.some(h=>h===r):l===r),c=s[o];if(Array.isArray(c)){let l=0;for(const h of c)if(h===r){l+=e;break}else l+=h.nodeValue.length;e=l}const a={id:i,index:o,offset:e};return(n!==r.ownerDocument.documentElement?yr(n,null,t).concat(a):[a]).filter(l=>l.index!==-1)},Tl=(r,e)=>{const{startContainer:t,startOffset:n,endContainer:i,endOffset:s}=r,o=yr(t,n,e);if(r.collapsed)return br([o]);const c=yr(i,s,e);return Al([o],[c])},Eo=(r,e,t)=>{const n=Mn(e),i=Mn(e,!0),s=r.documentElement,o=ys(s,n[0],t),c=ys(s,i[0],t),a=r.createRange();return o.before?a.setStartBefore(o.node):o.after?a.setStartAfter(o.node):a.setStart(o.node,o.offset),c.before?a.setEndBefore(c.node):c.after?a.setEndAfter(c.node):a.setEnd(c.node,c.offset),a},Ll=r=>{const e=[],{parentNode:t}=r[0],n=yr(t);for(const[i,s]of ws(t).entries()){const o=r[e.length];s===o&&e.push(br([n.concat({id:o.id,index:i})]))}return e},Ao=(r,e)=>ys(r.documentElement,Mn(e)).node,To={fromIndex:r=>vo(`/6/${(r+1)*2}`),toIndex:r=>(r==null?void 0:r.at(-1).index)/2-1},Cl=r=>{let e=0;const t=n=>{if(n.id=e++,n.subitems)for(const i of n.subitems)t(i)};for(const n of r)t(n);return r},Lo=r=>r.map(e=>{var t;return(t=e.subitems)!=null&&t.length?[e,Lo(e.subitems)].flat():e}).flat();class Co{async init({toc:e,ids:t,splitHref:n,getFragment:i}){Cl(e);const s=Lo(e),o=new Map;for(const[a,l]of s.entries()){const[h,d]=await n(l==null?void 0:l.href)??[],g={fragment:d,item:l};o.has(h)?o.get(h).items.push(g):o.set(h,{prev:s[a-1],items:[g]})}const c=new Map;for(const[a,l]of t.entries())o.has(l)?c.set(l,o.get(l)):c.set(l,c.get(t[a-1]));this.ids=t,this.map=c,this.getFragment=i}getProgress(e,t){var a;if(!this.ids)return;const n=this.ids[e],i=this.map.get(n);if(!i)return null;const{prev:s,items:o}=i;if(!o)return s;if(!t||o.length===1&&!o[0].fragment)return o[0].item;const c=t.startContainer.getRootNode();for(const[l,{fragment:h}]of o.entries()){const d=this.getFragment(c,h);if(d&&t.comparePoint(d,0)>0)return((a=o[l-1])==null?void 0:a.item)??s}return o[o.length-1].item}}class Rl{constructor(e,t,n){E(this,Wr);this.sizes=e.map(i=>i.linear!="no"&&i.size>0?i.size:0),this.sizePerLoc=t,this.sizePerTimeUnit=n,this.sizeTotal=this.sizes.reduce((i,s)=>i+s,0),this.sectionFractions=C(this,Wr,nl).call(this)}getProgress(e,t,n=0){const{sizes:i,sizePerLoc:s,sizePerTimeUnit:o,sizeTotal:c}=this,a=i[e]??0,h=i.slice(0,e).reduce((f,w)=>f+w,0)+t*a,d=h+n*a,g=c-h,b=(1-t)*a;return{fraction:d/c,section:{current:e,total:i.length},location:{current:Math.floor(h/s),next:Math.floor(d/s),total:Math.ceil(c/s)},time:{section:b/o,total:g/o}}}getSection(e){if(e<=0)return[0,0];if(e>=1)return[this.sizes.length-1,1];e=e+Number.EPSILON;const{sizeTotal:t}=this;let n=this.sectionFractions.findIndex(s=>s>e)-1;if(n<0)return[0,0];for(;!this.sizes[n];)n++;const i=(e-this.sectionFractions[n])/(this.sizes[n]/t);return[n,i]}}Wr=new WeakSet,nl=function(){const{sizeTotal:e}=this,t=[0];let n=0;for(const i of this.sizes)t.push((n+=i)/e);return t};const xt=r=>document.createElementNS("http://www.w3.org/2000/svg",r);class Ro{constructor(){E(this,oe,xt("svg"));E(this,ae,new Map);Object.assign(u(this,oe).style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none"})}get element(){return u(this,oe)}add(e,t,n,i){u(this,ae).has(e)&&this.remove(e),typeof t=="function"&&(t=t(u(this,oe).getRootNode()));const s=t.getClientRects(),o=n(s,i);u(this,oe).append(o),u(this,ae).set(e,{range:t,draw:n,options:i,element:o,rects:s})}remove(e){u(this,ae).has(e)&&(u(this,oe).removeChild(u(this,ae).get(e).element),u(this,ae).delete(e))}redraw(){for(const e of u(this,ae).values()){const{range:t,draw:n,options:i,element:s}=e;u(this,oe).removeChild(s);const o=t.getClientRects(),c=n(o,i);u(this,oe).append(c),e.element=c,e.rects=o}}hitTest({x:e,y:t}){const n=Array.from(u(this,ae).entries());for(let i=n.length-1;i>=0;i--){const[s,o]=n[i];for(const{left:c,top:a,right:l,bottom:h}of o.rects)if(a<=t&&c<=e&&h>t&&l>e)return[s,o.range]}return[]}static underline(e,t={}){const{color:n="red",width:i=2,writingMode:s}=t,o=xt("g");if(o.setAttribute("fill",n),s==="vertical-rl"||s==="vertical-lr")for(const{right:c,top:a,height:l}of e){const h=xt("rect");h.setAttribute("x",c-i),h.setAttribute("y",a),h.setAttribute("height",l),h.setAttribute("width",i),o.append(h)}else for(const{left:c,bottom:a,width:l}of e){const h=xt("rect");h.setAttribute("x",c),h.setAttribute("y",a-i),h.setAttribute("height",i),h.setAttribute("width",l),o.append(h)}return o}static strikethrough(e,t={}){const{color:n="red",width:i=2,writingMode:s}=t,o=xt("g");if(o.setAttribute("fill",n),s==="vertical-rl"||s==="vertical-lr")for(const{right:c,left:a,top:l,height:h}of e){const d=xt("rect");d.setAttribute("x",(c+a)/2),d.setAttribute("y",l),d.setAttribute("height",h),d.setAttribute("width",i),o.append(d)}else for(const{left:c,top:a,bottom:l,width:h}of e){const d=xt("rect");d.setAttribute("x",c),d.setAttribute("y",(a+l)/2),d.setAttribute("height",i),d.setAttribute("width",h),o.append(d)}return o}static squiggly(e,t={}){const{color:n="red",width:i=2,writingMode:s}=t,o=xt("g");o.setAttribute("fill","none"),o.setAttribute("stroke",n),o.setAttribute("stroke-width",i);const c=i*1.5;if(s==="vertical-rl"||s==="vertical-lr")for(const{right:a,top:l,height:h}of e){const d=xt("path"),g=Math.round(h/c/1.5),b=h/g,f=Array.from({length:g},(w,p)=>`l${p%2?-c:c} ${b}`).join("");d.setAttribute("d",`M${a} ${l}${f}`),o.append(d)}else for(const{left:a,bottom:l,width:h}of e){const d=xt("path"),g=Math.round(h/c/1.5),b=h/g,f=Array.from({length:g},(w,p)=>`l${b} ${p%2?c:-c}`).join("");d.setAttribute("d",`M${a} ${l}${f}`),o.append(d)}return o}static highlight(e,t={}){const{color:n="red"}=t,i=xt("g");i.setAttribute("fill",n),i.style.opacity="var(--overlayer-highlight-opacity, .3)",i.style.mixBlendMode="var(--overlayer-highlight-blend-mode, normal)";for(const{left:s,top:o,height:c,width:a}of e){const l=xt("rect");l.setAttribute("x",s),l.setAttribute("y",o),l.setAttribute("height",c),l.setAttribute("width",a),i.append(l)}return i}static outline(e,t={}){const{color:n="red",width:i=3,radius:s=3}=t,o=xt("g");o.setAttribute("fill","none"),o.setAttribute("stroke",n),o.setAttribute("stroke-width",i);for(const{left:c,top:a,height:l,width:h}of e){const d=xt("rect");d.setAttribute("x",c),d.setAttribute("y",a),d.setAttribute("height",l),d.setAttribute("width",h),d.setAttribute("rx",s),o.append(d)}return o}static copyImage([e],t={}){const{src:n}=t,i=xt("image"),{left:s,top:o,height:c,width:a}=e;return i.setAttribute("href",n),i.setAttribute("x",s),i.setAttribute("y",o),i.setAttribute("height",c),i.setAttribute("width",a),i}}oe=new WeakMap,ae=new WeakMap;const Il=(r,e)=>{const t=[];for(let n=e.currentNode;n;n=e.nextNode()){const i=r.comparePoint(n,0);if(i===0)t.push(n);else if(i>0)break}return t},Ml=(r,e)=>{const t=[];for(let n=e.nextNode();n;n=e.nextNode())t.push(n);return t},zl=NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT|NodeFilter.SHOW_CDATA_SECTION,Ol=r=>{if(r.nodeType===1){const e=r.tagName.toLowerCase();return e==="script"||e==="style"?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_SKIP}return NodeFilter.FILTER_ACCEPT},Io=function*(r,e){const t=r.commonAncestorContainer??r.body??r,n=document.createTreeWalker(t,zl,{acceptNode:Ol}),s=(r.commonAncestorContainer?Il:Ml)(r,n),o=s.map(a=>a.nodeValue),c=(a,l,h,d)=>{const g=document.createRange();return g.setStart(s[a],l),g.setEnd(s[h],d),g};for(const a of e(o,c))yield a},bi="foliate-search:";class Pl extends EventTarget{constructor(){super(...arguments);E(this,$t,[]);E(this,Ct,-1)}pushState(t){const n=u(this,$t)[u(this,Ct)];n===t||n!=null&&n.fraction&&n.fraction===t.fraction||(u(this,$t)[++hr(this,Ct)._]=t,u(this,$t).length=u(this,Ct)+1,this.dispatchEvent(new Event("index-change")))}replaceState(t){const n=u(this,Ct);u(this,$t)[n]=t}back(){const t=u(this,Ct);if(t<=0)return;const n={state:u(this,$t)[t-1]};R(this,Ct,t-1),this.dispatchEvent(new CustomEvent("popstate",{detail:n})),this.dispatchEvent(new Event("index-change"))}forward(){const t=u(this,Ct);if(t>=u(this,$t).length-1)return;const n={state:u(this,$t)[t+1]};R(this,Ct,t+1),this.dispatchEvent(new CustomEvent("popstate",{detail:n})),this.dispatchEvent(new Event("index-change"))}get canGoBack(){return u(this,Ct)>0}get canGoForward(){return u(this,Ct)<u(this,$t).length-1}clear(){R(this,$t,[]),R(this,Ct,-1)}}$t=new WeakMap,Ct=new WeakMap;const Nl=r=>{var e,t;if(!r)return{};try{const n=Intl.getCanonicalLocales(r)[0],i=new Intl.Locale(n),s=["zh","ja","kr"].includes(i.language),o=(t=((e=i.getTextInfo)==null?void 0:e.call(i))??i.textInfo)==null?void 0:t.direction;return{canonical:n,locale:i,isCJK:s,direction:o}}catch(n){return console.warn(n),{}}};let Fl=(Wc=class extends HTMLElement{constructor(){super();E(this,Kt);E(this,Vr);E(this,qr);E(this,Xr);E(this,Bn);E(this,Gr);E(this,Yr);E(this,Kr);E(this,Hr,this.attachShadow({mode:"closed"}));E(this,ye,void 0);E(this,Yt,void 0);E(this,$e,void 0);E(this,ve,new Map);E(this,qs,void 0);E(this,Xs,void 0);E(this,Gs,void 0);E(this,Ys,void 0);E(this,Ks,void 0);It(this,"isFixedLayout",!1);It(this,"lastLocation");It(this,"history",new Pl);this.history.addEventListener("popstate",({detail:t})=>{const n=this.resolveNavigation(t.state);this.renderer.goTo(n)})}async open(t){var n,i,s;if(this.book=t,this.language=Nl((n=t.metadata)==null?void 0:n.language),t.splitTOCHref&&t.getTOCFragment){const o=t.sections.map(l=>l.id);R(this,ye,new Rl(t.sections,1500,1600));const c=t.splitTOCHref.bind(t),a=t.getTOCFragment.bind(t);R(this,Yt,new Co),await u(this,Yt).init({toc:t.toc??[],ids:o,splitHref:c,getFragment:a}),R(this,$e,new Co),await u(this,$e).init({toc:t.pageList??[],ids:o,splitHref:c,getFragment:a})}if(this.isFixedLayout=((i=this.book.rendition)==null?void 0:i.layout)==="pre-paginated",this.isFixedLayout?(await Promise.resolve().then(()=>Yl),this.renderer=document.createElement("foliate-fxl")):(await Promise.resolve().then(()=>cu),this.renderer=document.createElement("foliate-paginator")),this.renderer.setAttribute("exportparts","head,foot,filter"),this.renderer.addEventListener("load",o=>C(this,qr,rl).call(this,o.detail)),this.renderer.addEventListener("relocate",o=>C(this,Vr,il).call(this,o.detail)),this.renderer.addEventListener("create-overlayer",o=>o.detail.attach(C(this,Gr,ol).call(this,o.detail))),this.renderer.open(t),u(this,Hr).append(this.renderer),t.sections.some(o=>o.mediaOverlay)){(s=t.media).activeClass||(s.activeClass="-epub-media-overlay-active");const o=t.media.activeClass;this.mediaOverlay=t.getMediaOverlay();let c;this.mediaOverlay.addEventListener("highlight",a=>{const l=this.resolveNavigation(a.detail.text);this.renderer.goTo(l).then(()=>{const{doc:h}=this.renderer.getContents().find(g=>g.index=l.index),d=l.anchor(h);d.classList.add(o),c=new WeakRef(d)})}),this.mediaOverlay.addEventListener("unhighlight",()=>{var a,l;(l=(a=c==null?void 0:c.deref())==null?void 0:a.classList)==null||l.remove(o)})}}close(){var t,n;(t=this.renderer)==null||t.destroy(),(n=this.renderer)==null||n.remove(),R(this,ye,null),R(this,Yt,null),R(this,$e,null),R(this,ve,new Map),this.lastLocation=null,this.history.clear(),this.tts=null,this.mediaOverlay=null}goToTextStart(){var t,n;return this.goTo(((n=(t=this.book.landmarks)==null?void 0:t.find(i=>i.type.includes("bodymatter")||i.type.includes("text")))==null?void 0:n.href)??this.book.sections.findIndex(i=>i.linear!=="no"))}async init({lastLocation:t,showTextStart:n}){const i=t?this.resolveNavigation(t):null;i?(await this.renderer.goTo(i),this.history.pushState(t)):n?await this.goToTextStart():(this.history.pushState(0),await this.next())}async addAnnotation(t,n){var l;const{value:i}=t;if(i.startsWith(bi)){const h=i.replace(bi,""),{index:d,anchor:g}=await this.resolveNavigation(h),b=C(this,Bn,ls).call(this,d);if(b){const{overlayer:f,doc:w}=b;if(n){f.remove(i);return}const p=w?g(w):g;f.add(i,p,Ro.outline)}return}const{index:s,anchor:o}=await this.resolveNavigation(i),c=C(this,Bn,ls).call(this,s);if(c){const{overlayer:h,doc:d}=c;if(h.remove(i),!n){const g=d?o(d):o,b=(f,w)=>h.add(i,g,f,w);C(this,Kt,Pe).call(this,"draw-annotation",{draw:b,annotation:t,doc:d,range:g})}}const a=((l=u(this,Yt).getProgress(s))==null?void 0:l.label)??"";return{index:s,label:a}}deleteAnnotation(t){return this.addAnnotation(t,!0)}async showAnnotation(t){const{value:n}=t,i=await this.goTo(n);if(i){const{index:s,anchor:o}=i,{doc:c}=C(this,Bn,ls).call(this,s),a=o(c);C(this,Kt,Pe).call(this,"show-annotation",{value:n,index:s,range:a})}}getCFI(t,n){const i=this.book.sections[t].cfi??To.fromIndex(t);return n?_l(i,Tl(n)):i}resolveCFI(t){if(this.book.resolveCFI)return this.book.resolveCFI(t);{const n=mi(t);return{index:To.toIndex((n.parent??n).shift()),anchor:o=>Eo(o,n)}}}resolveNavigation(t){try{if(typeof t=="number")return{index:t};if(typeof t.fraction=="number"){const[n,i]=u(this,ye).getSection(t.fraction);return{index:n,anchor:i}}return mr.test(t)?this.resolveCFI(t):this.book.resolveHref(t)}catch(n){console.error(n),console.error(`Could not resolve target ${t}`)}}async goTo(t){const n=this.resolveNavigation(t);try{return await this.renderer.goTo(n),this.history.pushState(t),n}catch(i){console.error(i),console.error(`Could not go to ${t}`)}}async goToFraction(t){const[n,i]=u(this,ye).getSection(t);await this.renderer.goTo({index:n,anchor:i}),this.history.pushState({fraction:t})}async select(t){try{const n=await this.resolveNavigation(t);await this.renderer.goTo({...n,select:!0}),this.history.pushState(t)}catch(n){console.error(n),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=u(this,ye))==null?void 0:t.sectionFractions)??[]).map(n=>n+Number.EPSILON)}getProgressOf(t,n){var o,c;const i=(o=u(this,Yt))==null?void 0:o.getProgress(t,n),s=(c=u(this,$e))==null?void 0:c.getProgress(t,n);return{tocItem:i,pageItem:s}}async getTOCItemOf(t){try{const{index:n,anchor:i}=await this.resolveNavigation(t),s=await this.book.sections[n].createDocument(),o=i(s),c=o instanceof Range,a=c?o:s.createRange();return c||a.selectNodeContents(o),u(this,Yt).getProgress(n,a)}catch(n){console.error(n),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*search(t){var l;this.clearSearch();const{searchMatcher:n}=await Promise.resolve().then(()=>hu),{query:i,index:s}=t,o=n(Io,{defaultLocale:this.language,...t}),c=s!=null?C(this,Yr,al).call(this,o,i,s):C(this,Kr,cl).call(this,o,i),a=[];u(this,ve).set(s,a);for await(const h of c)if(h.subitems){const d=h.subitems.map(({cfi:g})=>({value:bi+g}));u(this,ve).set(h.index,d);for(const g of d)this.addAnnotation(g);yield{label:((l=u(this,Yt).getProgress(h.index))==null?void 0:l.label)??"",subitems:h.subitems}}else{if(h.cfi){const d={value:bi+h.cfi};a.push(d),this.addAnnotation(d)}yield h}yield"done"}clearSearch(){for(const t of u(this,ve).values())for(const n of t)this.deleteAnnotation(n);u(this,ve).clear()}async initTTS(){const t=this.renderer.getContents()[0].doc;if(this.tts&&this.tts.doc===t)return;const{TTS:n}=await Promise.resolve().then(()=>yu);this.tts=new n(t,Io,i=>this.renderer.scrollToAnchor(i,!0))}startMediaOverlay(){const{index:t}=this.renderer.getContents()[0];return this.mediaOverlay.start(t)}},Hr=new WeakMap,ye=new WeakMap,Yt=new WeakMap,$e=new WeakMap,ve=new WeakMap,qs=new WeakMap,Xs=new WeakMap,Gs=new WeakMap,Ys=new WeakMap,Ks=new WeakMap,Kt=new WeakSet,Pe=function(t,n,i){return this.dispatchEvent(new CustomEvent(t,{detail:n,cancelable:i}))},Vr=new WeakSet,il=function({reason:t,range:n,index:i,fraction:s,size:o}){var d,g,b;const c=((d=u(this,ye))==null?void 0:d.getProgress(i,s,o))??{},a=(g=u(this,Yt))==null?void 0:g.getProgress(i,n),l=(b=u(this,$e))==null?void 0:b.getProgress(i,n),h=this.getCFI(i,n);this.lastLocation={...c,tocItem:a,pageItem:l,cfi:h,range:n},(t==="snap"||t==="page"||t==="scroll")&&this.history.replaceState(h),C(this,Kt,Pe).call(this,"relocate",this.lastLocation)},qr=new WeakSet,rl=function({doc:t,index:n}){var i,s;(i=t.documentElement).lang||(i.lang=this.language.canonical??""),this.language.isCJK||(s=t.documentElement).dir||(s.dir=this.language.direction??""),C(this,Xr,sl).call(this,t,n),C(this,Kt,Pe).call(this,"load",{doc:t,index:n})},Xr=new WeakSet,sl=function(t,n){const{book:i}=this,s=i.sections[n];for(const o of t.querySelectorAll("a[href]"))o.addEventListener("click",c=>{var h,d;c.preventDefault();const a=o.getAttribute("href"),l=((h=s==null?void 0:s.resolveHref)==null?void 0:h.call(s,a))??a;(d=i==null?void 0:i.isExternal)!=null&&d.call(i,l)?Promise.resolve(C(this,Kt,Pe).call(this,"external-link",{a:o,href:l},!0)).then(g=>g?globalThis.open(l,"_blank"):null).catch(g=>console.error(g)):Promise.resolve(C(this,Kt,Pe).call(this,"link",{a:o,href:l},!0)).then(g=>g?this.goTo(l):null).catch(g=>console.error(g))})},Bn=new WeakSet,ls=function(t){return this.renderer.getContents().find(n=>n.index===t&&n.overlayer)},Gr=new WeakSet,ol=function({doc:t,index:n}){const i=new Ro;t.addEventListener("click",o=>{const[c,a]=i.hitTest(o);c&&!c.startsWith(bi)&&C(this,Kt,Pe).call(this,"show-annotation",{value:c,index:n,range:a})},!1);const s=u(this,ve).get(n);if(s)for(const o of s)this.addAnnotation(o);return C(this,Kt,Pe).call(this,"create-overlay",{index:n}),i},Yr=new WeakSet,al=async function*(t,n,i){const s=await this.book.sections[i].createDocument();for(const{range:o,excerpt:c}of t(s,n))yield{cfi:this.getCFI(i,o),excerpt:c}},Kr=new WeakSet,cl=async function*(t,n){const{sections:i}=this.book;for(const[s,{createDocument:o}]of i.entries()){if(!o)continue;const c=await o(),a=Array.from(t(c,n),({range:h,excerpt:d})=>({cfi:this.getCFI(s,h),excerpt:d}));yield{progress:(s+1)/i.length},a.length&&(yield{index:s,subitems:a})}},Wc);customElements.define("foliate-view",Fl);const Bl=async r=>{const e=new Uint8Array(await r.slice(0,4).arrayBuffer());return e[0]===80&&e[1]===75&&e[2]===3&&e[3]===4},Dl=async r=>{const e=new Uint8Array(await r.slice(0,5).arrayBuffer());return e[0]===37&&e[1]===80&&e[2]===68&&e[3]===70&&e[4]===45},Ul=async r=>{const{configure:e,ZipReader:t,BlobReader:n,TextWriter:i,BlobWriter:s}=await Promise.resolve().then(()=>xh);e({useWebWorkers:!1});const c=await new t(new n(r)).getEntries(),a=new Map(c.map(b=>[b.filename,b])),l=b=>(f,...w)=>a.has(f)?b(a.get(f),...w):null,h=l(b=>b.getData(new i)),d=l((b,f)=>b.getData(new s(f)));return{entries:c,loadText:h,loadBlob:d,getSize:b=>{var f;return((f=a.get(b))==null?void 0:f.uncompressedSize)??0}}},Mo=async r=>r.isFile?r:(await Promise.all(Array.from(await new Promise((e,t)=>r.createReader().readEntries(n=>e(n),n=>t(n))),Mo))).flat(),jl=async r=>{const e=await Mo(r),t=await Promise.all(e.map(h=>new Promise((d,g)=>h.file(b=>d([b,h.fullPath]),b=>g(b))))),n=new Map(t.map(([h,d])=>[d.replace(r.fullPath+"/",""),h])),i=new TextDecoder,s=h=>h?i.decode(h):null,o=h=>{var d;return((d=n.get(h))==null?void 0:d.arrayBuffer())??null};return{loadText:async h=>s(await o(h)),loadBlob:h=>n.get(h),getSize:h=>{var d;return((d=n.get(h))==null?void 0:d.size)??0}}},$l=({name:r,type:e})=>e==="application/vnd.comicbook+zip"||r.endsWith(".cbz"),Wl=({name:r,type:e})=>e==="application/x-fictionbook+xml"||r.endsWith(".fb2"),Hl=({name:r,type:e})=>e==="application/x-zip-compressed-fb2"||r.endsWith(".fb2.zip")||r.endsWith(".fbz"),zo=async(r,e)=>{let t;if(r.isDirectory){const i=await jl(r),{EPUB:s}=await Promise.resolve().then(()=>vc);t=await new s(i).init()}else if(r.size)if(await Bl(r)){const i=await Ul(r);if($l(r)){const{makeComicBook:s}=await Promise.resolve().then(()=>jh);t=s(i,r)}else if(Hl(r)){const{makeFB2:s}=await Promise.resolve().then(()=>kc),{entries:o}=i,c=o.find(l=>l.filename.endsWith(".fb2")),a=await i.loadBlob((c??o[0]).filename);t=await s(a)}else{const{EPUB:s}=await Promise.resolve().then(()=>vc);t=await new s(i).init()}}else if(await Dl(r)){const{makePDF:i}=await Promise.resolve().then(()=>Kh);t=await i(r)}else{const{isMOBI:i,MOBI:s}=await Promise.resolve().then(()=>Cd);if(await i(r)){const o=await Promise.resolve().then(()=>Ud);t=await new s({unzlib:o.unzlibSync}).open(r)}else if(Wl(r)){const{makeFB2:o}=await Promise.resolve().then(()=>kc);t=await o(r)}}else throw new Error("File not found");if(!t)throw new Error("File type not supported");const n=document.createElement("foliate-view");return e.append(n),await n.open(t),n};function Vl(r,e){r.addEventListener("keyup",t=>{t.key==="ArrowUp"||t.key==="ArrowRight"?e("next"):(t.key==="ArrowDown"||t.key==="ArrowLeft")&&e("prev")},!1)}function ql(r,e){let i=0,s;r.addEventListener("wheel",o=>{o.ignore||(o.ignore=!0,clearTimeout(s),i+=o.deltaY,s=setTimeout(()=>{if(Math.abs(i)>=750){let c=Math.sign(i)>0?"next":"prev";e(c),i=0}i=0},50))})}function Xl(r,e){let s,o,c;r.addEventListener("touchstart",a=>{a.ignore||(a.ignore=!0,s=a.changedTouches[0].pageX,o=a.changedTouches[0].pageY,c=Date.now())},!1),r.addEventListener("touchend",a=>{var g,b;if(a.ignore)return;a.ignore=!0;const l=a.changedTouches[0].pageX-s,h=a.changedTouches[0].pageY-o;Date.now()-c<=500&&(Math.abs(l)>=50&&Math.abs(h)<=200?e(l<0?"prev":"next"):Math.abs(h)>=50&&Math.abs(l)<=200?e(h<0?"up":"down"):((b=(g=r==null?void 0:r.defaultView)==null?void 0:g.getSelection())==null||b.removeAllRanges(),r.dispatchEvent(new MouseEvent("click",{clientX:s,clientY:o})),a.preventDefault()))},!1)}const Oo=W.forwardRef((r,e)=>{const{url:t,getRendition:n,tocChanged:i}=r,[s,o]=W.useState(!1),c=W.useRef(null),[a,l]=W.useState(null),h=({spacing:_,justify:k,hyphenate:T})=>`
29
+ @namespace epub "http://www.idpf.org/2007/ops";
30
+ html {
31
+ color-scheme: light dark;
32
+ }
33
+ /* https://github.com/whatwg/html/issues/5426 */
34
+ @media (prefers-color-scheme: dark) {
35
+ a:link {
36
+ color: lightblue;
37
+ }
38
+ }
39
+ p, li, blockquote, dd {
40
+ line-height: ${_};
41
+ text-align: ${k?"justify":"start"};
42
+ -webkit-hyphens: ${T?"auto":"manual"};
43
+ hyphens: ${T?"auto":"manual"};
44
+ -webkit-hyphenate-limit-before: 3;
45
+ -webkit-hyphenate-limit-after: 2;
46
+ -webkit-hyphenate-limit-lines: 2;
47
+ hanging-punctuation: allow-end last;
48
+ widows: 2;
49
+ }
50
+ /* prevent the above from overriding the align attribute */
51
+ [align="left"] { text-align: left; }
52
+ [align="right"] { text-align: right; }
53
+ [align="center"] { text-align: center; }
54
+ [align="justify"] { text-align: justify; }
55
+
56
+ pre {
57
+ white-space: pre-wrap !important;
58
+ }
59
+ aside[epub|type~="endnote"],
60
+ aside[epub|type~="footnote"],
61
+ aside[epub|type~="note"],
62
+ aside[epub|type~="rearnote"] {
63
+ display: none;
64
+ }
65
+ `,d=async()=>{if(t)if(a&&a.close(),typeof t=="string")fetch(t).then(_=>_.blob()).then(async _=>{const k=t.split("/"),T=await zo(new File([_],k[k.length-1]),c.current);l(T),g()}).catch(_=>console.error(_));else{const _=await zo(t,c.current);l(_),g()}},g=()=>{var k,T;if(!a)return;o(!0);const{book:_}=a;(T=(k=a.renderer).setStyles)==null||T.call(k,h({spacing:1.4,justify:!0,hyphenate:!0})),f(),n&&n(a),i&&i(_.toc),a.renderer.next()},b=_=>{_==="next"?m():_==="prev"&&y()},f=()=>{a.addEventListener("load",w),a.addEventListener("relocate",p)},w=({detail:{doc:_}})=>{ql(_,b),Xl(_,b),Vl(_,b)},p=({detail:_})=>{},m=()=>a==null?void 0:a.next(),y=()=>a==null?void 0:a.prev(),S=_=>a==null?void 0:a.goTo(_);return W.useImperativeHandle(e,()=>({prevPage:y,nextPage:m,setLocation:S})),W.useEffect(()=>{d()},[]),W.useEffect(()=>{a&&g()},[a]),tt.jsx("div",{className:"reader",children:tt.jsxs("div",{className:"viewHolder",children:[tt.jsx("div",{ref:c,id:"viewer",style:{display:s?"":"none"}}),s&&tt.jsx("div",{children:tt.jsx("slot",{name:"loadingView",children:" "})})]})})},[]),Po=r=>{const{toc:e=[],current:t="",setLocation:n,isSubmenu:i=!1}=r;return tt.jsx(tt.Fragment,{children:e.map((s,o)=>tt.jsxs("div",{children:[tt.jsxs("button",{className:`tocAreaButton ${s.href===t?"active":""}`,onClick:()=>{s.subitems&&s.subitems.length>0?(s.expansion=!s.expansion,n(s.href,!1)):n(s.href)},children:[i?" ".repeat(4)+s.label:s.label,s.subitems&&s.subitems.length>0&&tt.jsx("div",{className:`expansion ${s.expansion?"open":""}`})]}),s.subitems&&s.subitems.length>0&&tt.jsx("div",{"v-show":s.expansion,children:tt.jsx(Po,{toc:s.subitems,current:t,setLocation:n,isSubmenu:!0})})]},o))})},No=r=>{const{showToc:e=!0,url:t,getRendition:n,...i}=r,s=W.useRef(null),[o,c]=W.useState([]),[a,l]=W.useState(!1),[h,d]=W.useState(""),[g,b]=W.useState(""),f=_=>{var x;n&&n(_);const{book:k}=_,T=(x=k.metadata)==null?void 0:x.title;d(T||"")},w=_=>{c(_)},p=()=>{s.current.nextPage()},m=()=>{s.current.nextPage()},y=()=>{l(!a)},S=(_,k=!0)=>{s.current.setLocation(_),b(_),l(!k)};return tt.jsxs("div",{className:"container",children:[tt.jsxs("div",{className:`readerArea ${a?"containerExpanded":""}`,children:[e&&tt.jsxs("button",{className:`tocButton ${a?"tocButtonExpanded":""}`,onClick:y,children:[tt.jsx("span",{className:"tocButtonBar",style:{top:"35%"}}),tt.jsx("span",{className:"tocButtonBar",style:{top:"66%"}})]}),tt.jsx("div",{className:"titleArea",title:h}),tt.jsx(Oo,{ref:s,url:t,onGetRendition:f,tocChanged:w,...i}),tt.jsx("button",{className:"arrow pre",onClick:p,children:"‹"}),tt.jsx("button",{className:"arrow next",onClick:m,children:"›"})]}),e&&tt.jsxs("div",{children:[tt.jsx("div",{className:"tocArea",children:tt.jsx(Po,{toc:o,current:g,setLocation:S})}),a&&tt.jsx("div",{className:"tocBackground",onClick:y})]})]})},Fo=r=>{var e,t;return(t=(e=r==null?void 0:r.split(/[,;\s]/))==null?void 0:e.filter(n=>n))==null?void 0:t.map(n=>n.split("=").map(i=>i.trim()))},Gl=(r,e)=>{var i,s;if(r.documentElement.localName==="svg"){const[,,o,c]=((i=r.documentElement.getAttribute("viewBox"))==null?void 0:i.split(/\s/))??[];return{width:o,height:c}}const t=Fo((s=r.querySelector('meta[name="viewport"]'))==null?void 0:s.getAttribute("content"));if(t)return Object.fromEntries(t);if(typeof e=="string")return Fo(e);if(e)return e;const n=r.querySelector("img");return n?{width:n.naturalWidth,height:n.naturalHeight}:(console.warn(new Error("Missing viewport properties")),{width:1e3,height:2e3})};class Bo extends HTMLElement{constructor(){super();E(this,Un);E(this,pn);E(this,Ri);E(this,Ii);E(this,Mi);E(this,jn);E(this,fn,this.attachShadow({mode:"closed"}));E(this,Ci,new ResizeObserver(()=>C(this,pn,dr).call(this)));E(this,xe,void 0);E(this,We,-1);It(this,"defaultViewport");It(this,"spread");E(this,Dn,!1);E(this,Zt,void 0);E(this,Jt,void 0);E(this,Qt,void 0);E(this,He,void 0);const t=new CSSStyleSheet;u(this,fn).adoptedStyleSheets=[t],t.replaceSync(`:host {
66
+ width: 100%;
67
+ height: 100%;
68
+ display: flex;
69
+ justify-content: center;
70
+ align-items: center;
71
+ }`),u(this,Ci).observe(this)}open(t){this.book=t;const{rendition:n}=t;this.spread=n==null?void 0:n.spread,this.defaultViewport=n==null?void 0:n.viewport;const i=t.dir==="rtl",s=!i;this.rtl=i,(n==null?void 0:n.spread)==="none"?R(this,xe,t.sections.map(o=>({center:o}))):R(this,xe,t.sections.reduce((o,c)=>{const a=o[o.length-1],{linear:l,pageSpread:h}=c;if(l==="no")return o;const d=()=>{const g={};return o.push(g),g};if(h==="center"){const g=a.left||a.right?d():a;g.center=c}else if(h==="left"){const g=a.center||a.left||s?d():a;g.left=c}else if(h==="right"){const g=a.center||a.right||i?d():a;g.right=c}else s?a.center||a.right?d().left=c:a.left?a.right=c:a.left=c:a.center||a.left?d().right=c:a.right?a.left=c:a.right=c;return o},[{}]))}get index(){const t=u(this,xe)[u(this,We)],n=(t==null?void 0:t.center)??(this.side==="left"?t.left??t.right:t.right??t.left);return this.book.sections.indexOf(n)}getSpreadOf(t){const n=u(this,xe);for(let i=0;i<n.length;i++){const{left:s,right:o,center:c}=n[i];if(s===t)return{index:i,side:"left"};if(o===t)return{index:i,side:"right"};if(c===t)return{index:i,side:"center"}}}async goToSpread(t,n,i){var o,c,a,l,h,d;if(t<0||t>u(this,xe).length-1)return;if(t===u(this,We)){C(this,pn,dr).call(this,n);return}R(this,We,t);const s=u(this,xe)[t];if(s.center){const g=this.book.sections.indexOf(s.center),b=await((c=(o=s.center)==null?void 0:o.load)==null?void 0:c.call(o));await C(this,Ri,io).call(this,{center:{index:g,src:b}})}else{const g=this.book.sections.indexOf(s.left),b=this.book.sections.indexOf(s.right),f=await((l=(a=s.left)==null?void 0:a.load)==null?void 0:l.call(a)),w=await((d=(h=s.right)==null?void 0:h.load)==null?void 0:d.call(h)),p={index:g,src:f},m={index:b,src:w};await C(this,Ri,io).call(this,{left:p,right:m,side:n})}C(this,jn,hs).call(this,i)}async select(t){await this.goTo(t)}async goTo(t){const{book:n}=this,i=await t,s=n.sections[i.index];if(!s)return;const{index:o,side:c}=this.getSpreadOf(s);await this.goToSpread(o,c)}async next(){if(this.rtl?C(this,Ii,ro).call(this):C(this,Mi,so).call(this))C(this,jn,hs).call(this,"page");else return this.goToSpread(u(this,We)+1,this.rtl?"right":"left","page")}async prev(){if(this.rtl?C(this,Mi,so).call(this):C(this,Ii,ro).call(this))C(this,jn,hs).call(this,"page");else return this.goToSpread(u(this,We)-1,this.rtl?"left":"right","page")}getContents(){return Array.from(u(this,fn).querySelectorAll("iframe"),t=>({doc:t.contentDocument}))}destroy(){u(this,Ci).unobserve(this)}}fn=new WeakMap,Ci=new WeakMap,xe=new WeakMap,We=new WeakMap,Dn=new WeakMap,Zt=new WeakMap,Jt=new WeakMap,Qt=new WeakMap,He=new WeakMap,Un=new WeakSet,us=async function({index:t,src:n}){const i=document.createElement("div"),s=document.createElement("iframe");return i.append(s),Object.assign(s.style,{border:"0",display:"none",overflow:"hidden"}),s.setAttribute("sandbox","allow-same-origin allow-scripts"),s.setAttribute("scrolling","no"),s.setAttribute("part","filter"),u(this,fn).append(i),n?new Promise(o=>{const c=()=>{s.removeEventListener("load",c);const a=s.contentDocument;this.dispatchEvent(new CustomEvent("load",{detail:{doc:a,index:t}}));const{width:l,height:h}=Gl(a,this.defaultViewport);o({element:i,iframe:s,width:parseFloat(l),height:parseFloat(h)})};s.addEventListener("load",c),s.src=n}):{blank:!0,element:i,iframe:s}},pn=new WeakSet,dr=function(t=u(this,He)){if(!t)return;const n=u(this,Zt)??{},i=u(this,Qt)??u(this,Jt),s=t==="left"?n:i,{width:o,height:c}=this.getBoundingClientRect(),a=this.spread!=="both"&&this.spread!=="portrait"&&c>o;R(this,Dn,a);const l=n.width??i.width,h=n.height??i.height,d=a||u(this,Qt)?Math.min(o/(s.width??l),c/(s.height??h)):Math.min(o/((n.width??l)+(i.width??l)),c/Math.max(n.height??h,i.height??h)),g=b=>{const{element:f,iframe:w,width:p,height:m,blank:y}=b;Object.assign(w.style,{width:`${p}px`,height:`${m}px`,transform:`scale(${d})`,transformOrigin:"top left",display:y?"none":"block"}),Object.assign(f.style,{width:`${(p??l)*d}px`,height:`${(m??h)*d}px`,overflow:"hidden",display:"block"}),a&&b!==s&&(f.style.display="none")};u(this,Qt)?g(u(this,Qt)):(g(n),g(i))},Ri=new WeakSet,io=async function({left:t,right:n,center:i,side:s}){u(this,fn).replaceChildren(),R(this,Zt,null),R(this,Jt,null),R(this,Qt,null),i?(R(this,Qt,await C(this,Un,us).call(this,i)),R(this,He,"center"),C(this,pn,dr).call(this)):(R(this,Zt,await C(this,Un,us).call(this,t)),R(this,Jt,await C(this,Un,us).call(this,n)),R(this,He,u(this,Zt).blank?"right":u(this,Jt).blank?"left":s),C(this,pn,dr).call(this))},Ii=new WeakSet,ro=function(){var t,n,i,s;if(!(u(this,Qt)||(t=u(this,Zt))!=null&&t.blank)&&u(this,Dn)&&((s=(i=(n=u(this,Zt))==null?void 0:n.element)==null?void 0:i.style)==null?void 0:s.display)==="none")return u(this,Jt).element.style.display="none",u(this,Zt).element.style.display="block",R(this,He,"left"),!0},Mi=new WeakSet,so=function(){var t,n,i,s;if(!(u(this,Qt)||(t=u(this,Jt))!=null&&t.blank)&&u(this,Dn)&&((s=(i=(n=u(this,Jt))==null?void 0:n.element)==null?void 0:i.style)==null?void 0:s.display)==="none")return u(this,Zt).element.style.display="none",u(this,Jt).element.style.display="block",R(this,He,"right"),!0},jn=new WeakSet,hs=function(t){this.dispatchEvent(new CustomEvent("relocate",{detail:{reason:t,range:null,index:this.index,fraction:0,size:1}}))},customElements.define("foliate-fxl",Bo);const Yl=Object.freeze(Object.defineProperty({__proto__:null,FixedLayout:Bo},Symbol.toStringTag,{value:"Module"})),Kl=r=>new Promise(e=>setTimeout(e,r)),Zl=(r,e,t)=>{let n;return(...i)=>{const s=()=>{n=null,t||r(...i)},o=t&&!n;n&&clearTimeout(n),n=setTimeout(s,e),o&&r(...i)}},Jl=(r,e,t)=>t*(e-r)+r,Ql=r=>1-(1-r)*(1-r),tu=(r,e,t,n,i)=>new Promise(s=>{let o;const c=a=>{o??(o=a);const l=Math.min(1,(a-o)/t);i(Jl(r,e,n(l))),l<1?requestAnimationFrame(c):s()};requestAnimationFrame(c)}),eu=r=>{if(!(r!=null&&r.collapsed))return r;const{endOffset:e,endContainer:t}=r;if(t.nodeType===1)return t;if(e+1<t.length)r.setEnd(t,e+1);else if(e>1)r.setStart(t,e-1);else return t.parentNode;return r},vr=(r,e,t,n=t)=>{const i=r.createRange();return i.setStart(e,t),i.setEnd(e,n),i},xr=(r,e,t,n=0,i=e.nodeValue.length)=>{if(i-n===1)return t(vr(r,e,n),vr(r,e,i))<0?n:i;const s=Math.floor(n+(i-n)/2),o=t(vr(r,e,n,s),vr(r,e,s,i));return o<0?xr(r,e,t,n,s):o>0?xr(r,e,t,s,i):s},{SHOW_ELEMENT:nu,SHOW_TEXT:iu,SHOW_CDATA_SECTION:ru,FILTER_ACCEPT:Do,FILTER_REJECT:Uo,FILTER_SKIP:jo}=NodeFilter,su=nu|iu|ru,$o=(r,e,t,n)=>{const i=g=>{var f,w;const b=(f=g.localName)==null?void 0:f.toLowerCase();if(b==="script"||b==="style")return Uo;if(g.nodeType===1){const{left:p,right:m}=n(g.getBoundingClientRect());if(m<e||p>t)return Uo;if(p>=e&&m<=t)return Do}else{if(!((w=g.nodeValue)!=null&&w.trim()))return jo;const p=r.createRange();p.selectNodeContents(g);const{left:m,right:y}=n(p.getBoundingClientRect());if(y>=e&&m<=t)return Do}return jo},s=r.createTreeWalker(r.body,su,{acceptNode:i}),o=[];for(let g=s.nextNode();g;g=s.nextNode())o.push(g);const c=o[0]??r.body,a=o[o.length-1]??c,l=c.nodeType===1?0:xr(r,c,(g,b)=>{const f=n(g.getBoundingClientRect()),w=n(b.getBoundingClientRect());return f.right<e&&w.left>e?0:w.left>e?-1:1}),h=a.nodeType===1?0:xr(r,a,(g,b)=>{const f=n(g.getBoundingClientRect()),w=n(b.getBoundingClientRect());return f.right<t&&w.left>t?0:w.left>t?-1:1}),d=r.createRange();return d.setStart(c,l),d.setEnd(a,h),d},ou=r=>{const{defaultView:e}=r,{writingMode:t,direction:n}=e.getComputedStyle(r.body),i=t==="vertical-rl"||t==="vertical-lr",s=r.body.dir==="rtl"||n==="rtl"||r.documentElement.dir==="rtl";return{vertical:i,rtl:s}},vs=r=>{const e=r.defaultView.getComputedStyle(r.body);return e.backgroundColor==="rgba(0, 0, 0, 0)"&&e.backgroundImage==="none"?r.defaultView.getComputedStyle(r.documentElement).background:e.background},Wo=(r,e)=>Array.from({length:r},()=>{const t=document.createElement("div"),n=document.createElement("div");return t.append(n),n.setAttribute("part",e),t}),wi=(r,e)=>{const{style:t}=r;for(const[n,i]of Object.entries(e))t.setProperty(n,i,"important")};class au{constructor({container:e,onExpand:t}){E(this,zi,new ResizeObserver(()=>this.expand()));E(this,zt,document.createElement("div"));E(this,dt,document.createElement("iframe"));E(this,Oi,document.createRange());E(this,gt,void 0);E(this,Et,!1);E(this,Pi,!1);E(this,$n,!0);E(this,ce,void 0);E(this,Wn,{});this.container=e,this.onExpand=t,u(this,dt).setAttribute("part","filter"),u(this,zt).append(u(this,dt)),Object.assign(u(this,zt).style,{boxSizing:"content-box",position:"relative",overflow:"hidden",flex:"0 0 auto",width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"}),Object.assign(u(this,dt).style,{overflow:"hidden",border:"0",display:"none",width:"100%",height:"100%"}),u(this,dt).setAttribute("sandbox","allow-same-origin allow-scripts"),u(this,dt).setAttribute("scrolling","no")}get element(){return u(this,zt)}get document(){return u(this,dt).contentDocument}async load(e,t,n){if(typeof e!="string")throw new Error(`${e} is not string`);return new Promise(i=>{u(this,dt).addEventListener("load",()=>{const s=this.document;t==null||t(s),u(this,dt).style.display="block";const{vertical:o,rtl:c}=ou(s),a=vs(s);u(this,dt).style.display="none",R(this,Et,o),R(this,Pi,c),u(this,Oi).selectNodeContents(s.body);const l=n==null?void 0:n({vertical:o,rtl:c,background:a});u(this,dt).style.display="block",this.render(l),u(this,zi).observe(s.body),s.fonts.ready.then(()=>this.expand()),i()},{once:!0}),u(this,dt).src=e})}render(e){e&&(R(this,$n,e.flow!=="scrolled"),R(this,Wn,e),u(this,$n)?this.columnize(e):this.scrolled(e))}scrolled({gap:e,columnWidth:t}){const n=u(this,Et),i=this.document;wi(i.documentElement,{"box-sizing":"border-box",padding:n?`${e}px 0`:`0 ${e}px`,"column-width":"auto",height:"auto",width:"auto"}),wi(i.body,{[n?"max-height":"max-width"]:`${t}px`,margin:"auto"}),this.setImageSize(),this.expand()}columnize({width:e,height:t,gap:n,columnWidth:i}){const s=u(this,Et);R(this,ce,s?t:e);const o=this.document;wi(o.documentElement,{"box-sizing":"border-box","column-width":`${Math.trunc(i)}px`,"column-gap":`${n}px`,"column-fill":"auto",...s?{width:`${e}px`}:{height:`${t}px`},padding:s?`${n/2}px 0`:`0 ${n/2}px`,overflow:"hidden","overflow-wrap":"break-word",position:"static",border:"0",margin:"0","max-height":"none","max-width":"none","min-height":"none","min-width":"none","-webkit-line-box-contain":"block glyphs replaced"}),wi(o.body,{"max-height":"none","max-width":"none",margin:"0"}),this.setImageSize(),this.expand()}setImageSize(){const{width:e,height:t,margin:n}=u(this,Wn),i=u(this,Et),s=this.document;for(const o of s.body.querySelectorAll("img, svg, video")){const{maxHeight:c,maxWidth:a}=s.defaultView.getComputedStyle(o);wi(o,{"max-height":i?c!=="none"&&c!=="0px"?c:"100%":`${t-n*2}px`,"max-width":i?`${e-n*2}px`:a!=="none"&&a!=="0px"?a:"100%","object-fit":"contain","page-break-inside":"avoid","break-inside":"avoid","box-sizing":"border-box"})}}expand(){const{documentElement:e}=this.document;if(u(this,$n)){const t=u(this,Et)?"height":"width",n=u(this,Et)?"width":"height",i=u(this,Oi).getBoundingClientRect(),s=e.getBoundingClientRect(),c=(u(this,Et)?0:u(this,Pi)?s.right-i.right:i.left-s.left)+i[t],l=Math.ceil(c/u(this,ce))*u(this,ce);u(this,zt).style.padding="0",u(this,dt).style[t]=`${l}px`,u(this,zt).style[t]=`${l+u(this,ce)*2}px`,u(this,dt).style[n]="100%",u(this,zt).style[n]="100%",e.style[t]=`${u(this,ce)}px`,u(this,gt)&&(u(this,gt).element.style.margin="0",u(this,gt).element.style.left=u(this,Et)?"0":`${u(this,ce)}px`,u(this,gt).element.style.top=u(this,Et)?`${u(this,ce)}px`:"0",u(this,gt).element.style[t]=`${l}px`,u(this,gt).redraw())}else{const t=u(this,Et)?"width":"height",n=u(this,Et)?"height":"width",s=e.getBoundingClientRect()[t],{margin:o}=u(this,Wn),c=u(this,Et)?`0 ${o}px`:`${o}px 0`;u(this,zt).style.padding=c,u(this,dt).style[t]=`${s}px`,u(this,zt).style[t]=`${s}px`,u(this,dt).style[n]="100%",u(this,zt).style[n]="100%",u(this,gt)&&(u(this,gt).element.style.margin=c,u(this,gt).element.style.left="0",u(this,gt).element.style.top="0",u(this,gt).element.style[t]=`${s}px`,u(this,gt).redraw())}this.onExpand()}set overlayer(e){R(this,gt,e),u(this,zt).append(e.element)}get overlayer(){return u(this,gt)}destroy(){this.document&&u(this,zi).unobserve(this.document.body)}}zi=new WeakMap,zt=new WeakMap,dt=new WeakMap,Oi=new WeakMap,gt=new WeakMap,Et=new WeakMap,Pi=new WeakMap,$n=new WeakMap,ce=new WeakMap,Wn=new WeakMap;class xs extends HTMLElement{constructor(){super();E(this,Zr);E(this,Ui);E(this,ji);E(this,$i);E(this,Wi);E(this,yn);E(this,Jr);E(this,Ge);E(this,Ye);E(this,Qr);E(this,ts);E(this,vn);E(this,Hi);E(this,Vi);E(this,Xn);E(this,es);E(this,ns);E(this,ke);E(this,qi);E(this,Ve,this.attachShadow({mode:"closed"}));E(this,Ni,new ResizeObserver(()=>this.render()));E(this,gn,void 0);E(this,Ot,void 0);E(this,qe,void 0);E(this,mn,void 0);E(this,Z,void 0);E(this,Wt,!1);E(this,te,!1);E(this,_e,0);E(this,le,-1);E(this,Se,0);E(this,Hn,!1);E(this,bn,!1);E(this,Fi,void 0);E(this,Bi,new WeakMap);E(this,Di,matchMedia("(prefers-color-scheme: dark)"));E(this,Vn,void 0);E(this,Xe,void 0);E(this,wn,void 0);E(this,qn,void 0);u(this,Ve).innerHTML=`<style>
72
+ :host {
73
+ --_gap: 7%;
74
+ --_margin: 48px;
75
+ --_max-inline-size: 720px;
76
+ --_max-block-size: 1440px;
77
+ --_max-column-count: 2;
78
+ --_vertical: 0;
79
+ --_half-gap: calc(var(--_gap) / 2);
80
+ --_max-width: calc(
81
+ var(--_vertical) * var(--_max-block-size)
82
+ + (1 - var(--_vertical)) * var(--_max-inline-size) * var(--_max-column-count)
83
+ );
84
+ --_max-height: calc(
85
+ var(--_vertical) * var(--_max-inline-size) * var(--_max-column-count)
86
+ + (1 - var(--_vertical)) * var(--_max-block-size)
87
+ );
88
+ display: grid;
89
+ grid-template-columns:
90
+ minmax(var(--_half-gap), 1fr)
91
+ minmax(0, var(--_max-width))
92
+ minmax(var(--_half-gap), 1fr);
93
+ grid-template-rows:
94
+ minmax(var(--_margin), 1fr)
95
+ minmax(0, var(--_max-height))
96
+ minmax(var(--_margin), 1fr);
97
+ box-sizing: border-box;
98
+ position: relative;
99
+ overflow: hidden;
100
+ width: 100%;
101
+ height: 100%;
102
+ }
103
+ #background {
104
+ grid-column-start: 1;
105
+ grid-column-end: 4;
106
+ grid-row-start: 1;
107
+ grid-row-end: 4;
108
+ }
109
+ #container {
110
+ grid-column-start: 2;
111
+ grid-row-start: 2;
112
+ overflow: hidden;
113
+ }
114
+ :host([flow="scrolled"]) #container {
115
+ grid-column-start: 1;
116
+ grid-column-end: 4;
117
+ grid-row-start: 1;
118
+ grid-row-end: 4;
119
+ overflow: auto;
120
+ }
121
+ #header {
122
+ grid-column-start: 2;
123
+ grid-row-start: 1;
124
+ }
125
+ #footer {
126
+ grid-column-start: 2;
127
+ grid-row-start: 3;
128
+ align-self: end;
129
+ }
130
+ #header, #footer {
131
+ display: grid;
132
+ height: var(--_margin);
133
+ }
134
+ :is(#header, #footer) > * {
135
+ display: flex;
136
+ align-items: center;
137
+ min-width: 0;
138
+ }
139
+ :is(#header, #footer) > * > * {
140
+ width: 100%;
141
+ overflow: hidden;
142
+ white-space: nowrap;
143
+ text-overflow: ellipsis;
144
+ text-align: center;
145
+ font-size: .75em;
146
+ opacity: .6;
147
+ }
148
+ </style>
149
+ <div id="background" part="filter"></div>
150
+ <div id="header"></div>
151
+ <div id="container"></div>
152
+ <div id="footer"></div>
153
+ `,R(this,gn,u(this,Ve).getElementById("background")),R(this,Ot,u(this,Ve).getElementById("container")),R(this,qe,u(this,Ve).getElementById("header")),R(this,mn,u(this,Ve).getElementById("footer")),u(this,Ni).observe(u(this,Ot)),u(this,Ot).addEventListener("scroll",Zl(()=>{this.scrolled&&(u(this,Hn)?R(this,Hn,!1):C(this,vn,pr).call(this,"scroll"))},250));const t={passive:!1};this.addEventListener("touchstart",C(this,ji,ao).bind(this),t),this.addEventListener("touchmove",C(this,$i,co).bind(this),t),this.addEventListener("touchend",C(this,Wi,lo).bind(this)),this.addEventListener("load",({detail:{doc:n}})=>{n.addEventListener("touchstart",C(this,ji,ao).bind(this),t),n.addEventListener("touchmove",C(this,$i,co).bind(this),t),n.addEventListener("touchend",C(this,Wi,lo).bind(this))}),R(this,Vn,()=>{u(this,Z)&&(u(this,gn).style.background=vs(u(this,Z).document))}),u(this,Di).addEventListener("change",u(this,Vn))}attributeChangedCallback(t,n,i){switch(t){case"flow":this.render();break;case"gap":case"margin":case"max-block-size":case"max-column-count":this.style.setProperty("--_"+t,i);break;case"max-inline-size":this.style.setProperty("--_"+t,i),this.render();break}}open(t){this.bookDir=t.dir,this.sections=t.sections}render(){u(this,Z)&&(u(this,Z).render(C(this,Ui,oo).call(this,{vertical:u(this,Wt),rtl:u(this,te)})),this.scrollToAnchor(u(this,Se)))}get scrolled(){return this.getAttribute("flow")==="scrolled"}get scrollProp(){const{scrolled:t}=this;return u(this,Wt)?t?"scrollLeft":"scrollTop":t?"scrollTop":"scrollLeft"}get sideProp(){const{scrolled:t}=this;return u(this,Wt)?t?"width":"height":t?"height":"width"}get size(){return u(this,Ot).getBoundingClientRect()[this.sideProp]}get viewSize(){return u(this,Z).element.getBoundingClientRect()[this.sideProp]}get start(){return Math.abs(u(this,Ot)[this.scrollProp])}get end(){return this.start+this.size}get page(){return Math.floor((this.start+this.end)/2/this.size)}get pages(){return Math.round(this.viewSize/this.size)}scrollBy(t,n){const i=u(this,Wt)?n:t,s=u(this,Ot),{scrollProp:o}=this,[c,a,l]=u(this,Xe),h=u(this,te),d=h?c-l:c-a,g=h?c+a:c+l;s[o]=Math.max(d,Math.min(g,s[o]+i))}snap(t,n){const i=u(this,Wt)?n:t,[s,o,c]=u(this,Xe),{start:a,end:l,pages:h,size:d}=this,g=Math.abs(s)-o,b=Math.abs(s)+c,f=i*(u(this,te)?-d:d),w=Math.floor(Math.max(g,Math.min(b,(a+l)/2+(isNaN(f)?0:f)))/d);C(this,Ye,di).call(this,w,"snap").then(()=>{const p=w<=0?-1:w>=h-1?1:null;if(p)return C(this,Xn,ds).call(this,{index:C(this,ke,Ln).call(this,p),anchor:p<0?()=>1:()=>0})})}async scrollToAnchor(t,n){var a,l;R(this,Se,t);const i=(l=(a=eu(t))==null?void 0:a.getClientRects)==null?void 0:l.call(a);if(i){const h=Array.from(i).find(d=>d.width>0&&d.height>0)||i[0];if(!h)return;await C(this,Jr,ul).call(this,h,"anchor"),n&&C(this,Qr,hl).call(this);return}if(this.scrolled){await C(this,Ge,hi).call(this,t*this.viewSize,"anchor");return}const{pages:s}=this;if(!s)return;const o=s-2,c=Math.round(t*(o-1));await C(this,Ye,di).call(this,c+1,"anchor")}async goTo(t){if(u(this,bn))return;const n=await t;if(C(this,Vi,ho).call(this,n.index))return C(this,Xn,ds).call(this,n)}get atStart(){return C(this,ke,Ln).call(this,-1)==null&&this.page<=1}get atEnd(){return C(this,ke,Ln).call(this,1)==null&&this.page>=this.pages-2}prev(t){return C(this,qi,fo).call(this,-1,t)}next(t){return C(this,qi,fo).call(this,1,t)}prevSection(){return this.goTo({index:C(this,ke,Ln).call(this,-1)})}nextSection(){return this.goTo({index:C(this,ke,Ln).call(this,1)})}firstSection(){const t=this.sections.findIndex(n=>n.linear!=="no");return this.goTo({index:t})}lastSection(){const t=this.sections.findLastIndex(n=>n.linear!=="no");return this.goTo({index:t})}getContents(){return u(this,Z)?[{index:u(this,le),overlayer:u(this,Z).overlayer,doc:u(this,Z).document}]:[]}setStyles(t){var o,c,a,l,h;R(this,Fi,t);const n=u(this,Bi).get((o=u(this,Z))==null?void 0:o.document);if(!n)return;const[i,s]=n;if(Array.isArray(t)){const[d,g]=t;i.textContent=d,s.textContent=g}else s.textContent=t;u(this,gn).style.background=vs(u(this,Z).document),(h=(l=(a=(c=u(this,Z))==null?void 0:c.document)==null?void 0:a.fonts)==null?void 0:l.ready)==null||h.then(()=>u(this,Z).expand())}destroy(){var t,n;u(this,Ni).unobserve(this),u(this,Z).destroy(),R(this,Z,null),(n=(t=this.sections[u(this,le)])==null?void 0:t.unload)==null||n.call(t),u(this,Di).removeEventListener("change",u(this,Vn))}}Ve=new WeakMap,Ni=new WeakMap,gn=new WeakMap,Ot=new WeakMap,qe=new WeakMap,mn=new WeakMap,Z=new WeakMap,Wt=new WeakMap,te=new WeakMap,_e=new WeakMap,le=new WeakMap,Se=new WeakMap,Hn=new WeakMap,bn=new WeakMap,Fi=new WeakMap,Bi=new WeakMap,Di=new WeakMap,Vn=new WeakMap,Xe=new WeakMap,wn=new WeakMap,qn=new WeakMap,Zr=new WeakSet,ll=function(){return u(this,Z)&&(u(this,Z).destroy(),u(this,Ot).removeChild(u(this,Z).element)),R(this,Z,new au({container:this,onExpand:()=>this.scrollToAnchor(u(this,Se))})),u(this,Ot).append(u(this,Z).element),u(this,Z)},Ui=new WeakSet,oo=function({vertical:t,rtl:n,background:i}){R(this,Wt,t),R(this,te,n),this.style.setProperty("--_vertical",t?1:0),u(this,gn).style.background=i;const{width:s,height:o}=u(this,Ot).getBoundingClientRect(),c=t?o:s,a=getComputedStyle(this),l=parseFloat(a.getPropertyValue("--_max-inline-size")),h=parseInt(a.getPropertyValue("--_max-column-count")),d=parseFloat(a.getPropertyValue("--_margin"));R(this,_e,d);const g=parseFloat(a.getPropertyValue("--_gap"))/100,b=-g/(g-1)*c,f=this.getAttribute("flow");if(f==="scrolled"){this.setAttribute("dir",t?"rtl":"ltr"),this.style.padding="0";const k=l;return this.heads=null,this.feet=null,u(this,qe).replaceChildren(),u(this,mn).replaceChildren(),{flow:f,margin:d,gap:b,columnWidth:k}}const w=Math.min(h,Math.ceil(c/l)),p=c/w-b;this.setAttribute("dir",n?"rtl":"ltr");const m=t?Math.min(2,Math.ceil(s/l)):w,y={gridTemplateColumns:`repeat(${m}, 1fr)`,gap:`${b}px`,padding:t?"0":`0 ${b/2}px`,direction:this.bookDir==="rtl"?"rtl":"ltr"};Object.assign(u(this,qe).style,y),Object.assign(u(this,mn).style,y);const S=Wo(m,"head"),_=Wo(m,"foot");return this.heads=S.map(k=>k.children[0]),this.feet=_.map(k=>k.children[0]),u(this,qe).replaceChildren(...S),u(this,mn).replaceChildren(..._),{height:o,width:s,margin:d,gap:b,columnWidth:p}},ji=new WeakSet,ao=function(t){const n=t.changedTouches[0];R(this,wn,{x:n==null?void 0:n.screenX,y:n==null?void 0:n.screenY,t:t.timeStamp,vx:0,xy:0})},$i=new WeakSet,co=function(t){const n=u(this,wn);if(n.pinched||(n.pinched=globalThis.visualViewport.scale>1,this.scrolled||n.pinched))return;if(t.touches.length>1){u(this,qn)&&t.preventDefault();return}t.preventDefault();const i=t.changedTouches[0],s=i.screenX,o=i.screenY,c=n.x-s,a=n.y-o,l=t.timeStamp-n.t;n.x=s,n.y=o,n.t=t.timeStamp,n.vx=c/l,n.vy=a/l,R(this,qn,!0),this.scrollBy(c,a)},Wi=new WeakSet,lo=function(){R(this,qn,!1),!this.scrolled&&requestAnimationFrame(()=>{globalThis.visualViewport.scale===1&&this.snap(u(this,wn).vx,u(this,wn).vy)})},yn=new WeakSet,fr=function(){if(this.scrolled){const n=this.viewSize,i=u(this,_e);return u(this,Wt)?({left:s,right:o})=>({left:n-o-i,right:n-s-i}):({top:s,bottom:o})=>({left:s+i,right:o+i})}const t=this.pages*this.size;return u(this,te)?({left:n,right:i})=>({left:t-i,right:t-n}):u(this,Wt)?({top:n,bottom:i})=>({left:n,right:i}):n=>n},Jr=new WeakSet,ul=async function(t,n){if(this.scrolled){const s=C(this,yn,fr).call(this)(t).left-u(this,_e);return C(this,Ge,hi).call(this,s,n)}const i=C(this,yn,fr).call(this)(t).left+u(this,_e)/2;return C(this,Ye,di).call(this,Math.floor(i/this.size)+(u(this,te)?-1:1),n)},Ge=new WeakSet,hi=async function(t,n,i){const s=u(this,Ot),{scrollProp:o,size:c}=this;if(s[o]===t){R(this,Xe,[t,this.atStart?0:c,this.atEnd?0:c]),C(this,vn,pr).call(this,n);return}if(this.scrolled&&u(this,Wt)&&(t=-t),(n==="snap"||i)&&this.hasAttribute("animated"))return tu(s[o],t,300,Ql,a=>s[o]=a).then(()=>{R(this,Xe,[t,this.atStart?0:c,this.atEnd?0:c]),C(this,vn,pr).call(this,n)});s[o]=t,R(this,Xe,[t,this.atStart?0:c,this.atEnd?0:c]),C(this,vn,pr).call(this,n)},Ye=new WeakSet,di=async function(t,n,i){const s=this.size*(u(this,te)?-t:t);return C(this,Ge,hi).call(this,s,n,i)},Qr=new WeakSet,hl=function(){const{defaultView:t}=u(this,Z).document;if(u(this,Se).startContainer){const n=t.getSelection();n.removeAllRanges(),n.addRange(u(this,Se))}},ts=new WeakSet,dl=function(){if(this.scrolled)return $o(u(this,Z).document,this.start+u(this,_e),this.end-u(this,_e),C(this,yn,fr).call(this));const t=u(this,te)?-this.size:this.size;return $o(u(this,Z).document,this.start-t,this.end-t,C(this,yn,fr).call(this))},vn=new WeakSet,pr=function(t){const n=C(this,ts,dl).call(this);t!=="anchor"?R(this,Se,n):R(this,Hn,!0);const i=u(this,le),s={reason:t,range:n,index:i};if(this.scrolled)s.fraction=this.start/this.viewSize;else if(this.pages>0){const{page:o,pages:c}=this;u(this,qe).style.visibility=o>1?"visible":"hidden",s.fraction=(o-1)/(c-2),s.size=1/(c-2)}this.dispatchEvent(new CustomEvent("relocate",{detail:s}))},Hi=new WeakSet,uo=async function(t){const{index:n,src:i,anchor:s,onLoad:o,select:c}=await t;if(R(this,le,n),i){const a=C(this,Zr,ll).call(this),l=d=>{if(d.head){const g=d.createElement("style");d.head.prepend(g);const b=d.createElement("style");d.head.append(b),u(this,Bi).set(d,[g,b])}o==null||o({doc:d,index:n})},h=C(this,Ui,oo).bind(this);await a.load(i,l,h),this.dispatchEvent(new CustomEvent("create-overlayer",{detail:{doc:a.document,index:n,attach:d=>a.overlayer=d}})),R(this,Z,a)}await this.scrollToAnchor((typeof s=="function"?s(u(this,Z).document):s)??0,c)},Vi=new WeakSet,ho=function(t){return t>=0&&t<=this.sections.length-1},Xn=new WeakSet,ds=async function({index:t,anchor:n,select:i}){if(t===u(this,le))await C(this,Hi,uo).call(this,{index:t,anchor:n,select:i});else{const s=u(this,le),o=c=>{var a,l;(l=(a=this.sections[s])==null?void 0:a.unload)==null||l.call(a),this.setStyles(u(this,Fi)),this.dispatchEvent(new CustomEvent("load",{detail:c}))};await C(this,Hi,uo).call(this,Promise.resolve(this.sections[t].load()).then(c=>({index:t,src:c,anchor:n,onLoad:o,select:i})).catch(c=>(console.warn(c),console.warn(new Error(`Failed to load section ${t}`)),{})))}},es=new WeakSet,fl=function(t){if(!u(this,Z))return!0;if(this.scrolled)return this.start>0?C(this,Ge,hi).call(this,Math.max(0,this.start-(t??this.size)),null,!0):!0;if(this.atStart)return;const n=this.page-1;return C(this,Ye,di).call(this,n,"page",!0).then(()=>n<=0)},ns=new WeakSet,pl=function(t){if(!u(this,Z))return!0;if(this.scrolled)return this.viewSize-this.end>2?C(this,Ge,hi).call(this,Math.min(this.viewSize,t?this.start+t:this.end),null,!0):!0;if(this.atEnd)return;const n=this.page+1,i=this.pages;return C(this,Ye,di).call(this,n,"page",!0).then(()=>n>=i-1)},ke=new WeakSet,Ln=function(t){var n;for(let i=u(this,le)+t;C(this,Vi,ho).call(this,i);i+=t)if(((n=this.sections[i])==null?void 0:n.linear)!=="no")return i},qi=new WeakSet,fo=async function(t,n){if(u(this,bn))return;R(this,bn,!0);const i=t===-1,s=await(i?C(this,es,fl).call(this,n):C(this,ns,pl).call(this,n));s&&await C(this,Xn,ds).call(this,{index:C(this,ke,Ln).call(this,t),anchor:i?()=>1:()=>0}),(s||!this.hasAttribute("animated"))&&await Kl(100),R(this,bn,!1)},It(xs,"observedAttributes",["flow","gap","margin","max-inline-size","max-block-size","max-column-count"]),customElements.define("foliate-paginator",xs);const cu=Object.freeze(Object.defineProperty({__proto__:null,Paginator:xs},Symbol.toStringTag,{value:"Module"})),_r=50,Ho=r=>r.replace(/\s+/g," "),Vo=(r,{startIndex:e,startOffset:t,endIndex:n,endOffset:i})=>{const s=r[e],o=r[n],c=s===o?s.slice(t,i):s.slice(t)+r.slice(s+1,o).join("")+o.slice(0,i),a=Ho(s.slice(0,t)).trimStart(),l=Ho(o.slice(i)).trimEnd(),h=a.length<_r?"":"…",d=l.length<_r?"":"…",g=`${h}${a.slice(-_r)}`,b=`${l.slice(0,_r)}${d}`;return{pre:g,match:c,post:b}},lu=function*(r,e,t={}){const{locales:n="en",sensitivity:i}=t,s=i==="variant",o=r.join(""),c=s?o:o.toLocaleLowerCase(n),a=s?e:e.toLocaleLowerCase(n),l=a.length;let h=-1,d=-1,g=0;do if(h=c.indexOf(a,h+1),h>-1){for(;g<=h;)g+=r[++d].length;const b=d,f=h-(g-r[d].length),w=h+l;for(;g<=w;)g+=r[++d].length;const p=d,m=w-(g-r[d].length),y={startIndex:b,startOffset:f,endIndex:p,endOffset:m};yield{range:y,excerpt:Vo(r,y)}}while(h>-1)},uu=function*(r,e,t={}){var g;const{locales:n="en",granularity:i="word",sensitivity:s="base"}=t;let o,c;try{o=new Intl.Segmenter(n,{usage:"search",granularity:i}),c=new Intl.Collator(n,{sensitivity:s})}catch(b){console.warn(b),o=new Intl.Segmenter("en",{usage:"search",granularity:i}),c=new Intl.Collator("en",{sensitivity:s})}const a=Array.from(o.segment(e)).length,l=[];let h=0,d=o.segment(r[h])[Symbol.iterator]();t:for(;h<r.length;){for(;l.length<a;){const{done:f,value:w}=d.next();if(f)if(h++,h<r.length){d=o.segment(r[h])[Symbol.iterator]();continue}else break t;const{index:p,segment:m}=w;if(/[^\p{Format}]/u.test(m)){if(/\s/u.test(m)){/\s/u.test((g=l[l.length-1])==null?void 0:g.segment)||l.push({strIndex:h,index:p,segment:" "});continue}w.strIndex=h,l.push(w)}}const b=l.map(f=>f.segment).join("");if(c.compare(e,b)===0){const f=h,w=l[l.length-1],p=w.index+w.segment.length,m=l[0].strIndex,y=l[0].index,S={startIndex:m,startOffset:y,endIndex:f,endOffset:p};yield{range:S,excerpt:Vo(r,S)}}l.shift()}},qo=(r,e,t)=>{const{granularity:n="grapheme",sensitivity:i="base"}=t;return!(Intl!=null&&Intl.Segmenter)||n==="grapheme"&&(i==="variant"||i==="accent")?lu(r,e,t):uu(r,e,t)},hu=Object.freeze(Object.defineProperty({__proto__:null,search:qo,searchMatcher:(r,e)=>{const{defalutLocale:t,matchCase:n,matchDiacritics:i,matchWholeWords:s}=e;return function*(o,c){const a=r(o,function*(l,h){for(const d of qo(l,c,{locales:o.body.lang||o.documentElement.lang||t||"en",granularity:s?"word":"grapheme",sensitivity:i&&n?"variant":i&&!n?"accent":!i&&n?"case":"base"})){const{startIndex:g,startOffset:b,endIndex:f,endOffset:w}=d.range;d.range=h(g,b,f,w),yield d}});for(const l of a)yield l}}},Symbol.toStringTag,{value:"Module"})),Tt={XML:"http://www.w3.org/XML/1998/namespace",SSML:"http://www.w3.org/2001/10/synthesis"},du=new Set(["article","aside","audio","blockquote","caption","details","dialog","div","dl","dt","dd","figure","footer","form","figcaption","h1","h2","h3","h4","h5","h6","header","hgroup","hr","li","main","math","nav","ol","p","pre","section","tr"]),Xo=r=>{var t;const e=r.lang||((t=r==null?void 0:r.getAttributeNS)==null?void 0:t.call(r,Tt.XML,"lang"));return e||(r.parentElement?Xo(r.parentElement):null)},Go=r=>{var t;const e=(t=r==null?void 0:r.getAttributeNS)==null?void 0:t.call(r,Tt.XML,"lang");return e||(r.parentElement?Go(r.parentElement):null)},fu=(r="en",e="word")=>{const t=new Intl.Segmenter(r,{granularity:e}),n=e==="word";return function*(i,s){const o=i.join("");let c=0,a=-1,l=0;for(const{index:h,segment:d,isWordLike:g}of t.segment(o)){if(n&&!g)continue;for(;l<=h;)l+=i[++a].length;const b=a,f=h-(l-i[a].length),w=h+d.length;if(w<o.length)for(;l<=w;)l+=i[++a].length;const p=a,m=w-(l-i[a].length);yield[(c++).toString(),s(b,f,p,m)]}}},pu=(r,e)=>{const t=document.implementation.createDocument(Tt.SSML,"speak"),{lang:n}=e;n&&t.documentElement.setAttributeNS(Tt.XML,"lang",n);const i=(s,o,c)=>{if(!s)return;if(s.nodeType===3)return t.createTextNode(s.textContent);if(s.nodeType===4)return t.createCDATASection(s.textContent);if(s.nodeType!==1)return;let a;const l=s.nodeName.toLowerCase();l==="foliate-mark"?(a=t.createElementNS(Tt.SSML,"mark"),a.setAttribute("name",s.dataset.name)):l==="br"?a=t.createElementNS(Tt.SSML,"break"):(l==="em"||l==="strong")&&(a=t.createElementNS(Tt.SSML,"emphasis"));const h=s.lang||s.getAttributeNS(Tt.XML,"lang");h&&(a||(a=t.createElementNS(Tt.SSML,"lang")),a.setAttributeNS(Tt.XML,"lang",h));const d=s.getAttributeNS(Tt.SSML,"alphabet")||c;if(!a){const b=s.getAttributeNS(Tt.SSML,"ph");b&&(a=t.createElementNS(Tt.SSML,"phoneme"),d&&a.setAttribute("alphabet",d),a.setAttribute("ph",b))}a||(a=o);let g=s.firstChild;for(;g;){const b=i(g,a,d);b&&a!==b&&a.append(b),g=g.nextSibling}return a};return i(r.firstChild,t.documentElement,e.alphabet),t},gu=(r,e,t)=>{const n=Xo(r.commonAncestorContainer),i=Go(r.commonAncestorContainer),s=fu(n,t),o=r.cloneContents(),c=[...e(r,s)],a=[...e(o,s)];for(const[h,d]of a){const g=document.createElement("foliate-mark");g.dataset.name=h,d.insertNode(g)}const l=pu(o,{lang:n,alphabet:i});return{entries:c,ssml:l}},Yo=r=>!r.toString().trim();function*mu(r){let e;const t=r.createTreeWalker(r.body,NodeFilter.SHOW_ELEMENT);for(let n=t.nextNode();n;n=t.nextNode()){const i=n.tagName.toLowerCase();du.has(i)&&(e&&(e.setEndBefore(n),Yo(e)||(yield e)),e=r.createRange(),e.setStart(n,0))}e||(e=r.createRange(),e.setStart(r.body.firstChild??r.body,0)),e.setEndAfter(r.body.lastChild??r.body),Yo(e)||(yield e)}class bu{constructor(e,t=n=>n){E(this,ft,[]);E(this,Gn,void 0);E(this,Pt,-1);E(this,ee,void 0);R(this,Gn,e),R(this,ee,t)}current(){if(u(this,ft)[u(this,Pt)])return u(this,ee).call(this,u(this,ft)[u(this,Pt)])}first(){if(u(this,ft)[0])return R(this,Pt,0),u(this,ee).call(this,u(this,ft)[0])}prev(){const e=u(this,Pt)-1;if(u(this,ft)[e])return R(this,Pt,e),u(this,ee).call(this,u(this,ft)[e])}next(){const e=u(this,Pt)+1;if(u(this,ft)[e])return R(this,Pt,e),u(this,ee).call(this,u(this,ft)[e]);for(;;){const{done:t,value:n}=u(this,Gn).next();if(t)break;if(u(this,ft).push(n),u(this,ft)[e])return R(this,Pt,e),u(this,ee).call(this,u(this,ft)[e])}}find(e){const t=u(this,ft).findIndex(n=>e(n));if(t>-1)return R(this,Pt,t),u(this,ee).call(this,u(this,ft)[t]);for(;;){const{done:n,value:i}=u(this,Gn).next();if(n)break;if(u(this,ft).push(i),e(i))return R(this,Pt,u(this,ft).length-1),u(this,ee).call(this,i)}}}ft=new WeakMap,Gn=new WeakMap,Pt=new WeakMap,ee=new WeakMap;class wu{constructor(e,t,n){E(this,Kn);E(this,Ke);E(this,Ee,void 0);E(this,Yn,void 0);E(this,ue,void 0);E(this,Xi,new XMLSerializer);this.doc=e,this.highlight=n,R(this,Ee,new bu(mu(e),i=>{const{entries:s,ssml:o}=gu(i,t);return R(this,Yn,new Map(s)),[o,i]}))}start(){R(this,ue,null);const[e]=u(this,Ee).first()??[];return e?C(this,Ke,fi).call(this,e,t=>C(this,Kn,fs).call(this,t,u(this,ue))):this.next()}resume(){const[e]=u(this,Ee).current()??[];return e?C(this,Ke,fi).call(this,e,t=>C(this,Kn,fs).call(this,t,u(this,ue))):this.next()}prev(e){R(this,ue,null);const[t,n]=u(this,Ee).prev()??[];return e&&n&&this.highlight(n.cloneRange()),C(this,Ke,fi).call(this,t)}next(e){R(this,ue,null);const[t,n]=u(this,Ee).next()??[];return e&&n&&this.highlight(n.cloneRange()),C(this,Ke,fi).call(this,t)}from(e){R(this,ue,null);const[t]=u(this,Ee).find(i=>e.compareBoundaryPoints(Range.END_TO_START,i)<=0);let n;for(const[i,s]of u(this,Yn).entries())if(e.compareBoundaryPoints(Range.START_TO_START,s)<=0){n=i;break}return C(this,Ke,fi).call(this,t,i=>C(this,Kn,fs).call(this,i,n))}setMark(e){const t=u(this,Yn).get(e);t&&(R(this,ue,e),this.highlight(t.cloneRange()))}}Ee=new WeakMap,Yn=new WeakMap,ue=new WeakMap,Xi=new WeakMap,Kn=new WeakSet,fs=function(e,t){return t?e.querySelector(`mark[name="${CSS.escape(t)}"`):null},Ke=new WeakSet,fi=function(e,t){var s,o;if(!e)return;if(!t)return u(this,Xi).serializeToString(e);const n=document.implementation.createDocument(Tt.SSML,"speak");n.documentElement.replaceWith(n.importNode(e.documentElement,!0));let i=(s=t(n))==null?void 0:s.previousSibling;for(;i;){const c=i.previousSibling??((o=i.parentNode)==null?void 0:o.previousSibling);i.parentNode.removeChild(i),i=c}return u(this,Xi).serializeToString(n)};const yu=Object.freeze(Object.defineProperty({__proto__:null,TTS:wu},Symbol.toStringTag,{value:"Module"})),Y=0,ge=1,Lt=-2,et=-3,Ko=-4,me=-5,Mt=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],Zo=1440,vu=[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,83,7,51,0,8,119,0,8,55,0,9,206,81,7,15,0,8,103,0,8,39,0,9,174,0,8,7,0,8,135,0,8,71,0,9,238,80,7,9,0,8,95,0,8,31,0,9,158,84,7,99,0,8,127,0,8,63,0,9,222,82,7,27,0,8,111,0,8,47,0,9,190,0,8,15,0,8,143,0,8,79,0,9,254,96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,193,80,7,10,0,8,96,0,8,32,0,9,161,0,8,0,0,8,128,0,8,64,0,9,225,80,7,6,0,8,88,0,8,24,0,9,145,83,7,59,0,8,120,0,8,56,0,9,209,81,7,17,0,8,104,0,8,40,0,9,177,0,8,8,0,8,136,0,8,72,0,9,241,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,201,81,7,13,0,8,100,0,8,36,0,9,169,0,8,4,0,8,132,0,8,68,0,9,233,80,7,8,0,8,92,0,8,28,0,9,153,84,7,83,0,8,124,0,8,60,0,9,217,82,7,23,0,8,108,0,8,44,0,9,185,0,8,12,0,8,140,0,8,76,0,9,249,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,197,81,7,11,0,8,98,0,8,34,0,9,165,0,8,2,0,8,130,0,8,66,0,9,229,80,7,7,0,8,90,0,8,26,0,9,149,84,7,67,0,8,122,0,8,58,0,9,213,82,7,19,0,8,106,0,8,42,0,9,181,0,8,10,0,8,138,0,8,74,0,9,245,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,205,81,7,15,0,8,102,0,8,38,0,9,173,0,8,6,0,8,134,0,8,70,0,9,237,80,7,9,0,8,94,0,8,30,0,9,157,84,7,99,0,8,126,0,8,62,0,9,221,82,7,27,0,8,110,0,8,46,0,9,189,0,8,14,0,8,142,0,8,78,0,9,253,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,195,80,7,10,0,8,97,0,8,33,0,9,163,0,8,1,0,8,129,0,8,65,0,9,227,80,7,6,0,8,89,0,8,25,0,9,147,83,7,59,0,8,121,0,8,57,0,9,211,81,7,17,0,8,105,0,8,41,0,9,179,0,8,9,0,8,137,0,8,73,0,9,243,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,203,81,7,13,0,8,101,0,8,37,0,9,171,0,8,5,0,8,133,0,8,69,0,9,235,80,7,8,0,8,93,0,8,29,0,9,155,84,7,83,0,8,125,0,8,61,0,9,219,82,7,23,0,8,109,0,8,45,0,9,187,0,8,13,0,8,141,0,8,77,0,9,251,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,199,81,7,11,0,8,99,0,8,35,0,9,167,0,8,3,0,8,131,0,8,67,0,9,231,80,7,7,0,8,91,0,8,27,0,9,151,84,7,67,0,8,123,0,8,59,0,9,215,82,7,19,0,8,107,0,8,43,0,9,183,0,8,11,0,8,139,0,8,75,0,9,247,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,207,81,7,15,0,8,103,0,8,39,0,9,175,0,8,7,0,8,135,0,8,71,0,9,239,80,7,9,0,8,95,0,8,31,0,9,159,84,7,99,0,8,127,0,8,63,0,9,223,82,7,27,0,8,111,0,8,47,0,9,191,0,8,15,0,8,143,0,8,79,0,9,255],xu=[80,5,1,87,5,257,83,5,17,91,5,4097,81,5,5,89,5,1025,85,5,65,93,5,16385,80,5,3,88,5,513,84,5,33,92,5,8193,82,5,9,90,5,2049,86,5,129,192,5,24577,80,5,2,87,5,385,83,5,25,91,5,6145,81,5,7,89,5,1537,85,5,97,93,5,24577,80,5,4,88,5,769,84,5,49,92,5,12289,82,5,13,90,5,3073,86,5,193,192,5,24577],_u=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],Su=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,112,112],ku=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],Eu=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Ne=15;function _s(){let r,e,t,n,i,s;function o(a,l,h,d,g,b,f,w,p,m,y){let S,_,k,T,x,I,F,P,A,L,z,B,U,M,j;L=0,x=h;do t[a[l+L]]++,L++,x--;while(x!==0);if(t[0]==h)return f[0]=-1,w[0]=0,Y;for(P=w[0],I=1;I<=Ne&&t[I]===0;I++);for(F=I,P<I&&(P=I),x=Ne;x!==0&&t[x]===0;x--);for(k=x,P>x&&(P=x),w[0]=P,M=1<<I;I<x;I++,M<<=1)if((M-=t[I])<0)return et;if((M-=t[x])<0)return et;for(t[x]+=M,s[1]=I=0,L=1,U=2;--x!=0;)s[U]=I+=t[L],U++,L++;x=0,L=0;do(I=a[l+L])!==0&&(y[s[I]++]=x),L++;while(++x<h);for(h=s[k],s[0]=x=0,L=0,T=-1,B=-P,i[0]=0,z=0,j=0;F<=k;F++)for(S=t[F];S--!=0;){for(;F>B+P;){if(T++,B+=P,j=k-B,j=j>P?P:j,(_=1<<(I=F-B))>S+1&&(_-=S+1,U=F,I<j))for(;++I<j&&!((_<<=1)<=t[++U]);)_-=t[U];if(j=1<<I,m[0]+j>Zo)return et;i[T]=z=m[0],m[0]+=j,T!==0?(s[T]=x,n[0]=I,n[1]=P,I=x>>>B-P,n[2]=z-i[T-1]-I,p.set(n,3*(i[T-1]+I))):f[0]=z}for(n[1]=F-B,L>=h?n[0]=192:y[L]<d?(n[0]=y[L]<256?0:96,n[2]=y[L++]):(n[0]=b[y[L]-d]+16+64,n[2]=g[y[L++]-d]),_=1<<F-B,I=x>>>B;I<j;I+=_)p.set(n,3*(z+I));for(I=1<<F-1;x&I;I>>>=1)x^=I;for(x^=I,A=(1<<B)-1;(x&A)!=s[T];)T--,B-=P,A=(1<<B)-1}return M!==0&&k!=1?me:Y}function c(a){let l;for(r||(r=[],e=[],t=new Int32Array(Ne+1),n=[],i=new Int32Array(Ne),s=new Int32Array(Ne+1)),e.length<a&&(e=[]),l=0;l<a;l++)e[l]=0;for(l=0;l<Ne+1;l++)t[l]=0;for(l=0;l<3;l++)n[l]=0;i.set(t.subarray(0,Ne),0),s.set(t.subarray(0,Ne+1),0)}this.inflate_trees_bits=function(a,l,h,d,g){let b;return c(19),r[0]=0,b=o(a,0,19,19,null,null,h,l,d,r,e),b==et?g.msg="oversubscribed dynamic bit lengths tree":b!=me&&l[0]!==0||(g.msg="incomplete dynamic bit lengths tree",b=et),b},this.inflate_trees_dynamic=function(a,l,h,d,g,b,f,w,p){let m;return c(288),r[0]=0,m=o(h,0,a,257,_u,Su,b,d,w,r,e),m!=Y||d[0]===0?(m==et?p.msg="oversubscribed literal/length tree":m!=Ko&&(p.msg="incomplete literal/length tree",m=et),m):(c(288),m=o(h,a,l,0,ku,Eu,f,g,w,r,e),m!=Y||g[0]===0&&a>257?(m==et?p.msg="oversubscribed distance tree":m==me?(p.msg="incomplete distance tree",m=et):m!=Ko&&(p.msg="empty distance tree with lengths",m=et),m):Y)}}_s.inflate_trees_fixed=function(r,e,t,n){return r[0]=9,e[0]=5,t[0]=vu,n[0]=xu,Y};const Sr=0,Jo=1,Qo=2,ta=3,ea=4,na=5,ia=6,Ss=7,ra=8,kr=9;function Au(){const r=this;let e,t,n,i,s=0,o=0,c=0,a=0,l=0,h=0,d=0,g=0,b=0,f=0;function w(p,m,y,S,_,k,T,x){let I,F,P,A,L,z,B,U,M,j,pt,ot,D,Q,H,X;B=x.next_in_index,U=x.avail_in,L=T.bitb,z=T.bitk,M=T.write,j=M<T.read?T.read-M-1:T.end-M,pt=Mt[p],ot=Mt[m];do{for(;z<20;)U--,L|=(255&x.read_byte(B++))<<z,z+=8;if(I=L&pt,F=y,P=S,X=3*(P+I),(A=F[X])!==0)for(;;){if(L>>=F[X+1],z-=F[X+1],(16&A)!=0){for(A&=15,D=F[X+2]+(L&Mt[A]),L>>=A,z-=A;z<15;)U--,L|=(255&x.read_byte(B++))<<z,z+=8;for(I=L&ot,F=_,P=k,X=3*(P+I),A=F[X];;){if(L>>=F[X+1],z-=F[X+1],(16&A)!=0){for(A&=15;z<A;)U--,L|=(255&x.read_byte(B++))<<z,z+=8;if(Q=F[X+2]+(L&Mt[A]),L>>=A,z-=A,j-=D,M>=Q)H=M-Q,M-H>0&&2>M-H?(T.win[M++]=T.win[H++],T.win[M++]=T.win[H++],D-=2):(T.win.set(T.win.subarray(H,H+2),M),M+=2,H+=2,D-=2);else{H=M-Q;do H+=T.end;while(H<0);if(A=T.end-H,D>A){if(D-=A,M-H>0&&A>M-H)do T.win[M++]=T.win[H++];while(--A!=0);else T.win.set(T.win.subarray(H,H+A),M),M+=A,H+=A,A=0;H=0}}if(M-H>0&&D>M-H)do T.win[M++]=T.win[H++];while(--D!=0);else T.win.set(T.win.subarray(H,H+D),M),M+=D,H+=D,D=0;break}if(64&A)return x.msg="invalid distance code",D=x.avail_in-U,D=z>>3<D?z>>3:D,U+=D,B-=D,z-=D<<3,T.bitb=L,T.bitk=z,x.avail_in=U,x.total_in+=B-x.next_in_index,x.next_in_index=B,T.write=M,et;I+=F[X+2],I+=L&Mt[A],X=3*(P+I),A=F[X]}break}if(64&A)return 32&A?(D=x.avail_in-U,D=z>>3<D?z>>3:D,U+=D,B-=D,z-=D<<3,T.bitb=L,T.bitk=z,x.avail_in=U,x.total_in+=B-x.next_in_index,x.next_in_index=B,T.write=M,ge):(x.msg="invalid literal/length code",D=x.avail_in-U,D=z>>3<D?z>>3:D,U+=D,B-=D,z-=D<<3,T.bitb=L,T.bitk=z,x.avail_in=U,x.total_in+=B-x.next_in_index,x.next_in_index=B,T.write=M,et);if(I+=F[X+2],I+=L&Mt[A],X=3*(P+I),(A=F[X])===0){L>>=F[X+1],z-=F[X+1],T.win[M++]=F[X+2],j--;break}}else L>>=F[X+1],z-=F[X+1],T.win[M++]=F[X+2],j--}while(j>=258&&U>=10);return D=x.avail_in-U,D=z>>3<D?z>>3:D,U+=D,B-=D,z-=D<<3,T.bitb=L,T.bitk=z,x.avail_in=U,x.total_in+=B-x.next_in_index,x.next_in_index=B,T.write=M,Y}r.init=function(p,m,y,S,_,k){e=Sr,d=p,g=m,n=y,b=S,i=_,f=k,t=null},r.proc=function(p,m,y){let S,_,k,T,x,I,F,P=0,A=0,L=0;for(L=m.next_in_index,T=m.avail_in,P=p.bitb,A=p.bitk,x=p.write,I=x<p.read?p.read-x-1:p.end-x;;)switch(e){case Sr:if(I>=258&&T>=10&&(p.bitb=P,p.bitk=A,m.avail_in=T,m.total_in+=L-m.next_in_index,m.next_in_index=L,p.write=x,y=w(d,g,n,b,i,f,p,m),L=m.next_in_index,T=m.avail_in,P=p.bitb,A=p.bitk,x=p.write,I=x<p.read?p.read-x-1:p.end-x,y!=Y)){e=y==ge?Ss:kr;break}c=d,t=n,o=b,e=Jo;case Jo:for(S=c;A<S;){if(T===0)return p.bitb=P,p.bitk=A,m.avail_in=T,m.total_in+=L-m.next_in_index,m.next_in_index=L,p.write=x,p.inflate_flush(m,y);y=Y,T--,P|=(255&m.read_byte(L++))<<A,A+=8}if(_=3*(o+(P&Mt[S])),P>>>=t[_+1],A-=t[_+1],k=t[_],k===0){a=t[_+2],e=ia;break}if(16&k){l=15&k,s=t[_+2],e=Qo;break}if(!(64&k)){c=k,o=_/3+t[_+2];break}if(32&k){e=Ss;break}return e=kr,m.msg="invalid literal/length code",y=et,p.bitb=P,p.bitk=A,m.avail_in=T,m.total_in+=L-m.next_in_index,m.next_in_index=L,p.write=x,p.inflate_flush(m,y);case Qo:for(S=l;A<S;){if(T===0)return p.bitb=P,p.bitk=A,m.avail_in=T,m.total_in+=L-m.next_in_index,m.next_in_index=L,p.write=x,p.inflate_flush(m,y);y=Y,T--,P|=(255&m.read_byte(L++))<<A,A+=8}s+=P&Mt[S],P>>=S,A-=S,c=g,t=i,o=f,e=ta;case ta:for(S=c;A<S;){if(T===0)return p.bitb=P,p.bitk=A,m.avail_in=T,m.total_in+=L-m.next_in_index,m.next_in_index=L,p.write=x,p.inflate_flush(m,y);y=Y,T--,P|=(255&m.read_byte(L++))<<A,A+=8}if(_=3*(o+(P&Mt[S])),P>>=t[_+1],A-=t[_+1],k=t[_],(16&k)!=0){l=15&k,h=t[_+2],e=ea;break}if(!(64&k)){c=k,o=_/3+t[_+2];break}return e=kr,m.msg="invalid distance code",y=et,p.bitb=P,p.bitk=A,m.avail_in=T,m.total_in+=L-m.next_in_index,m.next_in_index=L,p.write=x,p.inflate_flush(m,y);case ea:for(S=l;A<S;){if(T===0)return p.bitb=P,p.bitk=A,m.avail_in=T,m.total_in+=L-m.next_in_index,m.next_in_index=L,p.write=x,p.inflate_flush(m,y);y=Y,T--,P|=(255&m.read_byte(L++))<<A,A+=8}h+=P&Mt[S],P>>=S,A-=S,e=na;case na:for(F=x-h;F<0;)F+=p.end;for(;s!==0;){if(I===0&&(x==p.end&&p.read!==0&&(x=0,I=x<p.read?p.read-x-1:p.end-x),I===0&&(p.write=x,y=p.inflate_flush(m,y),x=p.write,I=x<p.read?p.read-x-1:p.end-x,x==p.end&&p.read!==0&&(x=0,I=x<p.read?p.read-x-1:p.end-x),I===0)))return p.bitb=P,p.bitk=A,m.avail_in=T,m.total_in+=L-m.next_in_index,m.next_in_index=L,p.write=x,p.inflate_flush(m,y);p.win[x++]=p.win[F++],I--,F==p.end&&(F=0),s--}e=Sr;break;case ia:if(I===0&&(x==p.end&&p.read!==0&&(x=0,I=x<p.read?p.read-x-1:p.end-x),I===0&&(p.write=x,y=p.inflate_flush(m,y),x=p.write,I=x<p.read?p.read-x-1:p.end-x,x==p.end&&p.read!==0&&(x=0,I=x<p.read?p.read-x-1:p.end-x),I===0)))return p.bitb=P,p.bitk=A,m.avail_in=T,m.total_in+=L-m.next_in_index,m.next_in_index=L,p.write=x,p.inflate_flush(m,y);y=Y,p.win[x++]=a,I--,e=Sr;break;case Ss:if(A>7&&(A-=8,T++,L--),p.write=x,y=p.inflate_flush(m,y),x=p.write,I=x<p.read?p.read-x-1:p.end-x,p.read!=p.write)return p.bitb=P,p.bitk=A,m.avail_in=T,m.total_in+=L-m.next_in_index,m.next_in_index=L,p.write=x,p.inflate_flush(m,y);e=ra;case ra:return y=ge,p.bitb=P,p.bitk=A,m.avail_in=T,m.total_in+=L-m.next_in_index,m.next_in_index=L,p.write=x,p.inflate_flush(m,y);case kr:return y=et,p.bitb=P,p.bitk=A,m.avail_in=T,m.total_in+=L-m.next_in_index,m.next_in_index=L,p.write=x,p.inflate_flush(m,y);default:return y=Lt,p.bitb=P,p.bitk=A,m.avail_in=T,m.total_in+=L-m.next_in_index,m.next_in_index=L,p.write=x,p.inflate_flush(m,y)}},r.free=function(){}}const sa=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],zn=0,ks=1,oa=2,aa=3,ca=4,la=5,Er=6,Ar=7,ua=8,sn=9;function Tu(r,e){const t=this;let n,i=zn,s=0,o=0,c=0;const a=[0],l=[0],h=new Au;let d=0,g=new Int32Array(3*Zo);const b=new _s;t.bitk=0,t.bitb=0,t.win=new Uint8Array(e),t.end=e,t.read=0,t.write=0,t.reset=function(f,w){w&&(w[0]=0),i==Er&&h.free(f),i=zn,t.bitk=0,t.bitb=0,t.read=t.write=0},t.reset(r,null),t.inflate_flush=function(f,w){let p,m,y;return m=f.next_out_index,y=t.read,p=(y<=t.write?t.write:t.end)-y,p>f.avail_out&&(p=f.avail_out),p!==0&&w==me&&(w=Y),f.avail_out-=p,f.total_out+=p,f.next_out.set(t.win.subarray(y,y+p),m),m+=p,y+=p,y==t.end&&(y=0,t.write==t.end&&(t.write=0),p=t.write-y,p>f.avail_out&&(p=f.avail_out),p!==0&&w==me&&(w=Y),f.avail_out-=p,f.total_out+=p,f.next_out.set(t.win.subarray(y,y+p),m),m+=p,y+=p),f.next_out_index=m,t.read=y,w},t.proc=function(f,w){let p,m,y,S,_,k,T,x;for(S=f.next_in_index,_=f.avail_in,m=t.bitb,y=t.bitk,k=t.write,T=k<t.read?t.read-k-1:t.end-k;;){let I,F,P,A,L,z,B,U;switch(i){case zn:for(;y<3;){if(_===0)return t.bitb=m,t.bitk=y,f.avail_in=_,f.total_in+=S-f.next_in_index,f.next_in_index=S,t.write=k,t.inflate_flush(f,w);w=Y,_--,m|=(255&f.read_byte(S++))<<y,y+=8}switch(p=7&m,d=1&p,p>>>1){case 0:m>>>=3,y-=3,p=7&y,m>>>=p,y-=p,i=ks;break;case 1:I=[],F=[],P=[[]],A=[[]],_s.inflate_trees_fixed(I,F,P,A),h.init(I[0],F[0],P[0],0,A[0],0),m>>>=3,y-=3,i=Er;break;case 2:m>>>=3,y-=3,i=aa;break;case 3:return m>>>=3,y-=3,i=sn,f.msg="invalid block type",w=et,t.bitb=m,t.bitk=y,f.avail_in=_,f.total_in+=S-f.next_in_index,f.next_in_index=S,t.write=k,t.inflate_flush(f,w)}break;case ks:for(;y<32;){if(_===0)return t.bitb=m,t.bitk=y,f.avail_in=_,f.total_in+=S-f.next_in_index,f.next_in_index=S,t.write=k,t.inflate_flush(f,w);w=Y,_--,m|=(255&f.read_byte(S++))<<y,y+=8}if((~m>>>16&65535)!=(65535&m))return i=sn,f.msg="invalid stored block lengths",w=et,t.bitb=m,t.bitk=y,f.avail_in=_,f.total_in+=S-f.next_in_index,f.next_in_index=S,t.write=k,t.inflate_flush(f,w);s=65535&m,m=y=0,i=s!==0?oa:d!==0?Ar:zn;break;case oa:if(_===0||T===0&&(k==t.end&&t.read!==0&&(k=0,T=k<t.read?t.read-k-1:t.end-k),T===0&&(t.write=k,w=t.inflate_flush(f,w),k=t.write,T=k<t.read?t.read-k-1:t.end-k,k==t.end&&t.read!==0&&(k=0,T=k<t.read?t.read-k-1:t.end-k),T===0)))return t.bitb=m,t.bitk=y,f.avail_in=_,f.total_in+=S-f.next_in_index,f.next_in_index=S,t.write=k,t.inflate_flush(f,w);if(w=Y,p=s,p>_&&(p=_),p>T&&(p=T),t.win.set(f.read_buf(S,p),k),S+=p,_-=p,k+=p,T-=p,(s-=p)!=0)break;i=d!==0?Ar:zn;break;case aa:for(;y<14;){if(_===0)return t.bitb=m,t.bitk=y,f.avail_in=_,f.total_in+=S-f.next_in_index,f.next_in_index=S,t.write=k,t.inflate_flush(f,w);w=Y,_--,m|=(255&f.read_byte(S++))<<y,y+=8}if(o=p=16383&m,(31&p)>29||(p>>5&31)>29)return i=sn,f.msg="too many length or distance symbols",w=et,t.bitb=m,t.bitk=y,f.avail_in=_,f.total_in+=S-f.next_in_index,f.next_in_index=S,t.write=k,t.inflate_flush(f,w);if(p=258+(31&p)+(p>>5&31),!n||n.length<p)n=[];else for(x=0;x<p;x++)n[x]=0;m>>>=14,y-=14,c=0,i=ca;case ca:for(;c<4+(o>>>10);){for(;y<3;){if(_===0)return t.bitb=m,t.bitk=y,f.avail_in=_,f.total_in+=S-f.next_in_index,f.next_in_index=S,t.write=k,t.inflate_flush(f,w);w=Y,_--,m|=(255&f.read_byte(S++))<<y,y+=8}n[sa[c++]]=7&m,m>>>=3,y-=3}for(;c<19;)n[sa[c++]]=0;if(a[0]=7,p=b.inflate_trees_bits(n,a,l,g,f),p!=Y)return(w=p)==et&&(n=null,i=sn),t.bitb=m,t.bitk=y,f.avail_in=_,f.total_in+=S-f.next_in_index,f.next_in_index=S,t.write=k,t.inflate_flush(f,w);c=0,i=la;case la:for(;p=o,!(c>=258+(31&p)+(p>>5&31));){let M,j;for(p=a[0];y<p;){if(_===0)return t.bitb=m,t.bitk=y,f.avail_in=_,f.total_in+=S-f.next_in_index,f.next_in_index=S,t.write=k,t.inflate_flush(f,w);w=Y,_--,m|=(255&f.read_byte(S++))<<y,y+=8}if(p=g[3*(l[0]+(m&Mt[p]))+1],j=g[3*(l[0]+(m&Mt[p]))+2],j<16)m>>>=p,y-=p,n[c++]=j;else{for(x=j==18?7:j-14,M=j==18?11:3;y<p+x;){if(_===0)return t.bitb=m,t.bitk=y,f.avail_in=_,f.total_in+=S-f.next_in_index,f.next_in_index=S,t.write=k,t.inflate_flush(f,w);w=Y,_--,m|=(255&f.read_byte(S++))<<y,y+=8}if(m>>>=p,y-=p,M+=m&Mt[x],m>>>=x,y-=x,x=c,p=o,x+M>258+(31&p)+(p>>5&31)||j==16&&x<1)return n=null,i=sn,f.msg="invalid bit length repeat",w=et,t.bitb=m,t.bitk=y,f.avail_in=_,f.total_in+=S-f.next_in_index,f.next_in_index=S,t.write=k,t.inflate_flush(f,w);j=j==16?n[x-1]:0;do n[x++]=j;while(--M!=0);c=x}}if(l[0]=-1,L=[],z=[],B=[],U=[],L[0]=9,z[0]=6,p=o,p=b.inflate_trees_dynamic(257+(31&p),1+(p>>5&31),n,L,z,B,U,g,f),p!=Y)return p==et&&(n=null,i=sn),w=p,t.bitb=m,t.bitk=y,f.avail_in=_,f.total_in+=S-f.next_in_index,f.next_in_index=S,t.write=k,t.inflate_flush(f,w);h.init(L[0],z[0],g,B[0],g,U[0]),i=Er;case Er:if(t.bitb=m,t.bitk=y,f.avail_in=_,f.total_in+=S-f.next_in_index,f.next_in_index=S,t.write=k,(w=h.proc(t,f,w))!=ge)return t.inflate_flush(f,w);if(w=Y,h.free(f),S=f.next_in_index,_=f.avail_in,m=t.bitb,y=t.bitk,k=t.write,T=k<t.read?t.read-k-1:t.end-k,d===0){i=zn;break}i=Ar;case Ar:if(t.write=k,w=t.inflate_flush(f,w),k=t.write,T=k<t.read?t.read-k-1:t.end-k,t.read!=t.write)return t.bitb=m,t.bitk=y,f.avail_in=_,f.total_in+=S-f.next_in_index,f.next_in_index=S,t.write=k,t.inflate_flush(f,w);i=ua;case ua:return w=ge,t.bitb=m,t.bitk=y,f.avail_in=_,f.total_in+=S-f.next_in_index,f.next_in_index=S,t.write=k,t.inflate_flush(f,w);case sn:return w=et,t.bitb=m,t.bitk=y,f.avail_in=_,f.total_in+=S-f.next_in_index,f.next_in_index=S,t.write=k,t.inflate_flush(f,w);default:return w=Lt,t.bitb=m,t.bitk=y,f.avail_in=_,f.total_in+=S-f.next_in_index,f.next_in_index=S,t.write=k,t.inflate_flush(f,w)}}},t.free=function(f){t.reset(f,null),t.win=null,g=null},t.set_dictionary=function(f,w,p){t.win.set(f.subarray(w,w+p),0),t.read=t.write=p},t.sync_point=function(){return i==ks?1:0}}const Fe=13,Lu=[0,0,255,255];function Cu(){const r=this;function e(t){return t&&t.istate?(t.total_in=t.total_out=0,t.msg=null,t.istate.mode=7,t.istate.blocks.reset(t,null),Y):Lt}r.mode=0,r.method=0,r.was=[0],r.need=0,r.marker=0,r.wbits=0,r.inflateEnd=function(t){return r.blocks&&r.blocks.free(t),r.blocks=null,Y},r.inflateInit=function(t,n){return t.msg=null,r.blocks=null,n<8||n>15?(r.inflateEnd(t),Lt):(r.wbits=n,t.istate.blocks=new Tu(t,1<<n),e(t),Y)},r.inflate=function(t,n){let i,s;if(!t||!t.istate||!t.next_in)return Lt;const o=t.istate;for(n=n==4?me:Y,i=me;;)switch(o.mode){case 0:if(t.avail_in===0)return i;if(i=n,t.avail_in--,t.total_in++,(15&(o.method=t.read_byte(t.next_in_index++)))!=8){o.mode=Fe,t.msg="unknown compression method",o.marker=5;break}if(8+(o.method>>4)>o.wbits){o.mode=Fe,t.msg="invalid win size",o.marker=5;break}o.mode=1;case 1:if(t.avail_in===0)return i;if(i=n,t.avail_in--,t.total_in++,s=255&t.read_byte(t.next_in_index++),((o.method<<8)+s)%31!=0){o.mode=Fe,t.msg="incorrect header check",o.marker=5;break}if(!(32&s)){o.mode=7;break}o.mode=2;case 2:if(t.avail_in===0)return i;i=n,t.avail_in--,t.total_in++,o.need=(255&t.read_byte(t.next_in_index++))<<24&4278190080,o.mode=3;case 3:if(t.avail_in===0)return i;i=n,t.avail_in--,t.total_in++,o.need+=(255&t.read_byte(t.next_in_index++))<<16&16711680,o.mode=4;case 4:if(t.avail_in===0)return i;i=n,t.avail_in--,t.total_in++,o.need+=(255&t.read_byte(t.next_in_index++))<<8&65280,o.mode=5;case 5:return t.avail_in===0?i:(i=n,t.avail_in--,t.total_in++,o.need+=255&t.read_byte(t.next_in_index++),o.mode=6,2);case 6:return o.mode=Fe,t.msg="need dictionary",o.marker=0,Lt;case 7:if(i=o.blocks.proc(t,i),i==et){o.mode=Fe,o.marker=0;break}if(i==Y&&(i=n),i!=ge)return i;i=n,o.blocks.reset(t,o.was),o.mode=12;case 12:return t.avail_in=0,ge;case Fe:return et;default:return Lt}},r.inflateSetDictionary=function(t,n,i){let s=0,o=i;if(!t||!t.istate||t.istate.mode!=6)return Lt;const c=t.istate;return o>=1<<c.wbits&&(o=(1<<c.wbits)-1,s=i-o),c.blocks.set_dictionary(n,s,o),c.mode=7,Y},r.inflateSync=function(t){let n,i,s,o,c;if(!t||!t.istate)return Lt;const a=t.istate;if(a.mode!=Fe&&(a.mode=Fe,a.marker=0),(n=t.avail_in)===0)return me;for(i=t.next_in_index,s=a.marker;n!==0&&s<4;)t.read_byte(i)==Lu[s]?s++:s=t.read_byte(i)!==0?0:4-s,i++,n--;return t.total_in+=i-t.next_in_index,t.next_in_index=i,t.avail_in=n,a.marker=s,s!=4?et:(o=t.total_in,c=t.total_out,e(t),t.total_in=o,t.total_out=c,a.mode=7,Y)},r.inflateSyncPoint=function(t){return t&&t.istate&&t.istate.blocks?t.istate.blocks.sync_point():Lt}}function ha(){}ha.prototype={inflateInit(r){const e=this;return e.istate=new Cu,r||(r=15),e.istate.inflateInit(e,r)},inflate(r){const e=this;return e.istate?e.istate.inflate(e,r):Lt},inflateEnd(){const r=this;if(!r.istate)return Lt;const e=r.istate.inflateEnd(r);return r.istate=null,e},inflateSync(){const r=this;return r.istate?r.istate.inflateSync(r):Lt},inflateSetDictionary(r,e){const t=this;return t.istate?t.istate.inflateSetDictionary(t,r,e):Lt},read_byte(r){return this.next_in[r]},read_buf(r,e){return this.next_in.subarray(r,r+e)}};const on=4294967295,an=65535,da=33639248,fa=101075792,Ru=1,qt=void 0,Tr="undefined",pa="function";class ga{constructor(e){return class extends TransformStream{constructor(t,n){const i=new e(n);super({transform(s,o){o.enqueue(i.append(s))},flush(s){const o=i.flush();o&&s.enqueue(o)}})}}}}let ma=2;try{typeof navigator!=Tr&&navigator.hardwareConcurrency&&(ma=navigator.hardwareConcurrency)}catch{}const Iu={chunkSize:524288,maxWorkers:ma,terminateWorkerTimeout:5e3,useWebWorkers:!0,useCompressionStream:!0,workerScripts:qt,CompressionStreamNative:typeof CompressionStream!=Tr&&CompressionStream,DecompressionStreamNative:typeof DecompressionStream!=Tr&&DecompressionStream},Be=Object.assign({},Iu);function ba(r){const{baseURL:e,chunkSize:t,maxWorkers:n,terminateWorkerTimeout:i,useCompressionStream:s,useWebWorkers:o,Deflate:c,Inflate:a,CompressionStream:l,DecompressionStream:h,workerScripts:d}=r;if(De("baseURL",e),De("chunkSize",t),De("maxWorkers",n),De("terminateWorkerTimeout",i),De("useCompressionStream",s),De("useWebWorkers",o),c&&(Be.CompressionStream=new ga(c)),a&&(Be.DecompressionStream=new ga(a)),De("CompressionStream",l),De("DecompressionStream",h),d!==qt){const{deflate:g,inflate:b}=d;if((g||b)&&(Be.workerScripts||(Be.workerScripts={})),g){if(!Array.isArray(g))throw new Error("workerScripts.deflate must be an array");Be.workerScripts.deflate=g}if(b){if(!Array.isArray(b))throw new Error("workerScripts.inflate must be an array");Be.workerScripts.inflate=b}}}function De(r,e){e!==qt&&(Be[r]=e)}const wa=[];for(let r=0;r<256;r++){let e=r;for(let t=0;t<8;t++)1&e?e=e>>>1^3988292384:e>>>=1;wa[r]=e}class Lr{constructor(e){this.crc=e||-1}append(e){let t=0|this.crc;for(let n=0,i=0|e.length;n<i;n++)t=t>>>8^wa[255&(t^e[n])];this.crc=t}get(){return~this.crc}}class ya extends TransformStream{constructor(){let e;const t=new Lr;super({transform(n,i){t.append(n),i.enqueue(n)},flush(){const n=new Uint8Array(4);new DataView(n.buffer).setUint32(0,t.get()),e.value=n}}),e=this}}const _t={concat(r,e){if(r.length===0||e.length===0)return r.concat(e);const t=r[r.length-1],n=_t.getPartial(t);return n===32?r.concat(e):_t._shiftRight(e,n,0|t,r.slice(0,r.length-1))},bitLength(r){const e=r.length;if(e===0)return 0;const t=r[e-1];return 32*(e-1)+_t.getPartial(t)},clamp(r,e){if(32*r.length<e)return r;const t=(r=r.slice(0,Math.ceil(e/32))).length;return e&=31,t>0&&e&&(r[t-1]=_t.partial(e,r[t-1]&2147483648>>e-1,1)),r},partial:(r,e,t)=>r===32?e:(t?0|e:e<<32-r)+1099511627776*r,getPartial:r=>Math.round(r/1099511627776)||32,_shiftRight(r,e,t,n){for(n===void 0&&(n=[]);e>=32;e-=32)n.push(t),t=0;if(e===0)return n.concat(r);for(let o=0;o<r.length;o++)n.push(t|r[o]>>>e),t=r[o]<<32-e;const i=r.length?r[r.length-1]:0,s=_t.getPartial(i);return n.push(_t.partial(e+s&31,e+s>32?t:n.pop(),1)),n}},Cr={bytes:{fromBits(r){const e=_t.bitLength(r)/8,t=new Uint8Array(e);let n;for(let i=0;i<e;i++)!(3&i)&&(n=r[i/4]),t[i]=n>>>24,n<<=8;return t},toBits(r){const e=[];let t,n=0;for(t=0;t<r.length;t++)n=n<<8|r[t],(3&t)==3&&(e.push(n),n=0);return 3&t&&e.push(_t.partial(8*(3&t),n)),e}}},Mu={sha1:class{constructor(r){const e=this;e.blockSize=512,e._init=[1732584193,4023233417,2562383102,271733878,3285377520],e._key=[1518500249,1859775393,2400959708,3395469782],r?(e._h=r._h.slice(0),e._buffer=r._buffer.slice(0),e._length=r._length):e.reset()}reset(){const r=this;return r._h=r._init.slice(0),r._buffer=[],r._length=0,r}update(r){const e=this;typeof r=="string"&&(r=Cr.utf8String.toBits(r));const t=e._buffer=_t.concat(e._buffer,r),n=e._length,i=e._length=n+_t.bitLength(r);if(i>9007199254740991)throw new Error("Cannot hash more than 2^53 - 1 bits");const s=new Uint32Array(t);let o=0;for(let c=e.blockSize+n-(e.blockSize+n&e.blockSize-1);c<=i;c+=e.blockSize)e._block(s.subarray(16*o,16*(o+1))),o+=1;return t.splice(0,16*o),e}finalize(){const r=this;let e=r._buffer;const t=r._h;e=_t.concat(e,[_t.partial(1,1)]);for(let n=e.length+2;15&n;n++)e.push(0);for(e.push(Math.floor(r._length/4294967296)),e.push(0|r._length);e.length;)r._block(e.splice(0,16));return r.reset(),t}_f(r,e,t,n){return r<=19?e&t|~e&n:r<=39?e^t^n:r<=59?e&t|e&n|t&n:r<=79?e^t^n:void 0}_S(r,e){return e<<r|e>>>32-r}_block(r){const e=this,t=e._h,n=Array(80);for(let l=0;l<16;l++)n[l]=r[l];let i=t[0],s=t[1],o=t[2],c=t[3],a=t[4];for(let l=0;l<=79;l++){l>=16&&(n[l]=e._S(1,n[l-3]^n[l-8]^n[l-14]^n[l-16]));const h=e._S(5,i)+e._f(l,s,o,c)+a+n[l]+e._key[Math.floor(l/20)]|0;a=c,c=o,o=e._S(30,s),s=i,i=h}t[0]=t[0]+i|0,t[1]=t[1]+s|0,t[2]=t[2]+o|0,t[3]=t[3]+c|0,t[4]=t[4]+a|0}}},zu={aes:class{constructor(r){const e=this;e._tables=[[[],[],[],[],[]],[[],[],[],[],[]]],e._tables[0][0][0]||e._precompute();const t=e._tables[0][4],n=e._tables[1],i=r.length;let s,o,c,a=1;if(i!==4&&i!==6&&i!==8)throw new Error("invalid aes key size");for(e._key=[o=r.slice(0),c=[]],s=i;s<4*i+28;s++){let l=o[s-1];(s%i==0||i===8&&s%i==4)&&(l=t[l>>>24]<<24^t[l>>16&255]<<16^t[l>>8&255]<<8^t[255&l],s%i==0&&(l=l<<8^l>>>24^a<<24,a=a<<1^283*(a>>7))),o[s]=o[s-i]^l}for(let l=0;s;l++,s--){const h=o[3&l?s:s-4];c[l]=s<=4||l<4?h:n[0][t[h>>>24]]^n[1][t[h>>16&255]]^n[2][t[h>>8&255]]^n[3][t[255&h]]}}encrypt(r){return this._crypt(r,0)}decrypt(r){return this._crypt(r,1)}_precompute(){const r=this._tables[0],e=this._tables[1],t=r[4],n=e[4],i=[],s=[];let o,c,a,l;for(let h=0;h<256;h++)s[(i[h]=h<<1^283*(h>>7))^h]=h;for(let h=o=0;!t[h];h^=c||1,o=s[o]||1){let d=o^o<<1^o<<2^o<<3^o<<4;d=d>>8^255&d^99,t[h]=d,n[d]=h,l=i[a=i[c=i[h]]];let g=16843009*l^65537*a^257*c^16843008*h,b=257*i[d]^16843008*d;for(let f=0;f<4;f++)r[f][h]=b=b<<24^b>>>8,e[f][d]=g=g<<24^g>>>8}for(let h=0;h<5;h++)r[h]=r[h].slice(0),e[h]=e[h].slice(0)}_crypt(r,e){if(r.length!==4)throw new Error("invalid aes block size");const t=this._key[e],n=t.length/4-2,i=[0,0,0,0],s=this._tables[e],o=s[0],c=s[1],a=s[2],l=s[3],h=s[4];let d,g,b,f=r[0]^t[0],w=r[e?3:1]^t[1],p=r[2]^t[2],m=r[e?1:3]^t[3],y=4;for(let S=0;S<n;S++)d=o[f>>>24]^c[w>>16&255]^a[p>>8&255]^l[255&m]^t[y],g=o[w>>>24]^c[p>>16&255]^a[m>>8&255]^l[255&f]^t[y+1],b=o[p>>>24]^c[m>>16&255]^a[f>>8&255]^l[255&w]^t[y+2],m=o[m>>>24]^c[f>>16&255]^a[w>>8&255]^l[255&p]^t[y+3],y+=4,f=d,w=g,p=b;for(let S=0;S<4;S++)i[e?3&-S:S]=h[f>>>24]<<24^h[w>>16&255]<<16^h[p>>8&255]<<8^h[255&m]^t[y++],d=f,f=w,w=p,p=m,m=d;return i}}},Ou={getRandomValues(r){const e=new Uint32Array(r.buffer),t=n=>{let i=987654321;const s=4294967295;return function(){return i=36969*(65535&i)+(i>>16)&s,(((i<<16)+(n=18e3*(65535&n)+(n>>16)&s)&s)/4294967296+.5)*(Math.random()>.5?1:-1)}};for(let n,i=0;i<r.length;i+=4){const s=t(4294967296*(n||Math.random()));n=987654071*s(),e[i/4]=4294967296*s()|0}return r}},Pu={ctrGladman:class{constructor(r,e){this._prf=r,this._initIv=e,this._iv=e}reset(){this._iv=this._initIv}update(r){return this.calculate(this._prf,r,this._iv)}incWord(r){if((r>>24&255)==255){let e=r>>16&255,t=r>>8&255,n=255&r;e===255?(e=0,t===255?(t=0,n===255?n=0:++n):++t):++e,r=0,r+=e<<16,r+=t<<8,r+=n}else r+=1<<24;return r}incCounter(r){(r[0]=this.incWord(r[0]))===0&&(r[1]=this.incWord(r[1]))}calculate(r,e,t){let n;if(!(n=e.length))return[];const i=_t.bitLength(e);for(let s=0;s<n;s+=4){this.incCounter(t);const o=r.encrypt(t);e[s]^=o[0],e[s+1]^=o[1],e[s+2]^=o[2],e[s+3]^=o[3]}return _t.clamp(e,i)}}},On={importKey:r=>new On.hmacSha1(Cr.bytes.toBits(r)),pbkdf2(r,e,t,n){if(t=t||1e4,n<0||t<0)throw new Error("invalid params to pbkdf2");const i=1+(n>>5)<<2;let s,o,c,a,l;const h=new ArrayBuffer(i),d=new DataView(h);let g=0;const b=_t;for(e=Cr.bytes.toBits(e),l=1;g<(i||1);l++){for(s=o=r.encrypt(b.concat(e,[l])),c=1;c<t;c++)for(o=r.encrypt(o),a=0;a<o.length;a++)s[a]^=o[a];for(c=0;g<(i||1)&&c<s.length;c++)d.setInt32(g,s[c]),g+=4}return h.slice(0,n/8)},hmacSha1:class{constructor(r){const e=this,t=e._hash=Mu.sha1,n=[[],[]];e._baseHash=[new t,new t];const i=e._baseHash[0].blockSize/32;r.length>i&&(r=new t().update(r).finalize());for(let s=0;s<i;s++)n[0][s]=909522486^r[s],n[1][s]=1549556828^r[s];e._baseHash[0].update(n[0]),e._baseHash[1].update(n[1]),e._resultHash=new t(e._baseHash[0])}reset(){const r=this;r._resultHash=new r._hash(r._baseHash[0]),r._updated=!1}update(r){this._updated=!0,this._resultHash.update(r)}digest(){const r=this,e=r._resultHash.finalize(),t=new r._hash(r._baseHash[1]).update(e).finalize();return r.reset(),t}encrypt(r){if(this._updated)throw new Error("encrypt on already updated hmac called!");return this.update(r),this.digest(r)}}},Nu=typeof crypto<"u"&&typeof crypto.getRandomValues=="function",va="Invalid password",xa="Invalid signature",Es="zipjs-abort-check-password";function _a(r){return Nu?crypto.getRandomValues(r):Ou.getRandomValues(r)}const Pn=16,Fu="raw",Sa={name:"PBKDF2"},Bu=Object.assign({hash:{name:"HMAC"}},Sa),As=Object.assign({iterations:1e3,hash:{name:"SHA-1"}},Sa),Du=["deriveBits"],yi=[8,12,16],vi=[16,24,32],Ue=10,Uu=[0,0,0,0],ka="undefined",Ea="function",Rr=typeof crypto!=ka,xi=Rr&&crypto.subtle,Aa=Rr&&typeof xi!=ka,ie=Cr.bytes,ju=zu.aes,$u=Pu.ctrGladman,Wu=On.hmacSha1;let Ta=Rr&&Aa&&typeof xi.importKey==Ea,La=Rr&&Aa&&typeof xi.deriveBits==Ea;class Hu extends TransformStream{constructor({password:e,signed:t,encryptionStrength:n,checkPasswordOnly:i}){super({start(){Object.assign(this,{ready:new Promise(s=>this.resolveReady=s),password:e,signed:t,strength:n-1,pending:new Uint8Array})},async transform(s,o){const c=this,{password:a,strength:l,resolveReady:h,ready:d}=c;a?(await async function(b,f,w,p){const m=await Ra(b,f,w,Ft(p,0,yi[f])),y=Ft(p,yi[f]);if(m[0]!=y[0]||m[1]!=y[1])throw new Error(va)}(c,l,a,Ft(s,0,yi[l]+2)),s=Ft(s,yi[l]+2),i?o.error(new Error(Es)):h()):await d;const g=new Uint8Array(s.length-Ue-(s.length-Ue)%Pn);o.enqueue(Ca(c,s,g,0,Ue,!0))},async flush(s){const{signed:o,ctr:c,hmac:a,pending:l,ready:h}=this;if(a&&c){await h;const d=Ft(l,0,l.length-Ue),g=Ft(l,l.length-Ue);let b=new Uint8Array;if(d.length){const f=Si(ie,d);a.update(f);const w=c.update(f);b=_i(ie,w)}if(o){const f=Ft(_i(ie,a.digest()),0,Ue);for(let w=0;w<Ue;w++)if(f[w]!=g[w])throw new Error(xa)}s.enqueue(b)}}})}}class Vu extends TransformStream{constructor({password:e,encryptionStrength:t}){let n;super({start(){Object.assign(this,{ready:new Promise(i=>this.resolveReady=i),password:e,strength:t-1,pending:new Uint8Array})},async transform(i,s){const o=this,{password:c,strength:a,resolveReady:l,ready:h}=o;let d=new Uint8Array;c?(d=await async function(b,f,w){const p=_a(new Uint8Array(yi[f])),m=await Ra(b,f,w,p);return Ts(p,m)}(o,a,c),l()):await h;const g=new Uint8Array(d.length+i.length-i.length%Pn);g.set(d,0),s.enqueue(Ca(o,i,g,d.length,0))},async flush(i){const{ctr:s,hmac:o,pending:c,ready:a}=this;if(o&&s){await a;let l=new Uint8Array;if(c.length){const h=s.update(Si(ie,c));o.update(h),l=_i(ie,h)}n.signature=_i(ie,o.digest()).slice(0,Ue),i.enqueue(Ts(l,n.signature))}}}),n=this}}function Ca(r,e,t,n,i,s){const{ctr:o,hmac:c,pending:a}=r,l=e.length-i;let h;for(a.length&&(e=Ts(a,e),t=function(d,g){if(g&&g>d.length){const b=d;(d=new Uint8Array(g)).set(b,0)}return d}(t,l-l%Pn)),h=0;h<=l-Pn;h+=Pn){const d=Si(ie,Ft(e,h,h+Pn));s&&c.update(d);const g=o.update(d);s||c.update(g),t.set(_i(ie,g),h+n)}return r.pending=Ft(e,h),t}async function Ra(r,e,t,n){r.password=null;const i=function(d){if(typeof TextEncoder>"u"){d=unescape(encodeURIComponent(d));const g=new Uint8Array(d.length);for(let b=0;b<g.length;b++)g[b]=d.charCodeAt(b);return g}return new TextEncoder().encode(d)}(t),s=await async function(d,g,b,f,w){if(!Ta)return On.importKey(g);try{return await xi.importKey(d,g,b,f,w)}catch{return Ta=!1,On.importKey(g)}}(Fu,i,Bu,!1,Du),o=await async function(d,g,b){if(!La)return On.pbkdf2(g,d.salt,As.iterations,b);try{return await xi.deriveBits(d,g,b)}catch{return La=!1,On.pbkdf2(g,d.salt,As.iterations,b)}}(Object.assign({salt:n},As),s,8*(2*vi[e]+2)),c=new Uint8Array(o),a=Si(ie,Ft(c,0,vi[e])),l=Si(ie,Ft(c,vi[e],2*vi[e])),h=Ft(c,2*vi[e]);return Object.assign(r,{keys:{key:a,authentication:l,passwordVerification:h},ctr:new $u(new ju(a),Array.from(Uu)),hmac:new Wu(l)}),h}function Ts(r,e){let t=r;return r.length+e.length&&(t=new Uint8Array(r.length+e.length),t.set(r,0),t.set(e,r.length)),t}function Ft(r,e,t){return r.subarray(e,t)}function _i(r,e){return r.fromBits(e)}function Si(r,e){return r.toBits(e)}const Ir=12;class qu extends TransformStream{constructor({password:e,passwordVerification:t,checkPasswordOnly:n}){super({start(){Object.assign(this,{password:e,passwordVerification:t}),za(this,e)},transform(i,s){const o=this;if(o.password){const c=Ia(o,i.subarray(0,Ir));if(o.password=null,c[11]!=o.passwordVerification)throw new Error(va);i=i.subarray(Ir)}n?s.error(new Error(Es)):s.enqueue(Ia(o,i))}})}}class Xu extends TransformStream{constructor({password:e,passwordVerification:t}){super({start(){Object.assign(this,{password:e,passwordVerification:t}),za(this,e)},transform(n,i){const s=this;let o,c;if(s.password){s.password=null;const a=_a(new Uint8Array(Ir));a[11]=s.passwordVerification,o=new Uint8Array(n.length+a.length),o.set(Ma(s,a),0),c=Ir}else o=new Uint8Array(n.length),c=0;o.set(Ma(s,n),c),i.enqueue(o)}})}}function Ia(r,e){const t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=Oa(r)^e[n],Ls(r,t[n]);return t}function Ma(r,e){const t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=Oa(r)^e[n],Ls(r,e[n]);return t}function za(r,e){const t=[305419896,591751049,878082192];Object.assign(r,{keys:t,crcKey0:new Lr(t[0]),crcKey2:new Lr(t[2])});for(let n=0;n<e.length;n++)Ls(r,e.charCodeAt(n))}function Ls(r,e){let[t,n,i]=r.keys;r.crcKey0.append([e]),t=~r.crcKey0.get(),n=Na(Math.imul(Na(n+Pa(t)),134775813)+1),r.crcKey2.append([n>>>24]),i=~r.crcKey2.get(),r.keys=[t,n,i]}function Oa(r){const e=2|r.keys[2];return Pa(Math.imul(e,1^e)>>>8)}function Pa(r){return 255&r}function Na(r){return 4294967295&r}const Fa="deflate-raw";class Gu extends TransformStream{constructor(e,{chunkSize:t,CompressionStream:n,CompressionStreamNative:i}){super({});const{compressed:s,encrypted:o,useCompressionStream:c,zipCrypto:a,signed:l,level:h}=e,d=this;let g,b,f=Ba(super.readable);o&&!a||!l||(g=new ya,f=re(f,g)),s&&(f=Ua(f,c,{level:h,chunkSize:t},i,n)),o&&(a?f=re(f,new Xu(e)):(b=new Vu(e),f=re(f,b))),Da(d,f,()=>{let w;o&&!a&&(w=b.signature),o&&!a||!l||(w=new DataView(g.value.buffer).getUint32(0)),d.signature=w})}}class Yu extends TransformStream{constructor(e,{chunkSize:t,DecompressionStream:n,DecompressionStreamNative:i}){super({});const{zipCrypto:s,encrypted:o,signed:c,signature:a,compressed:l,useCompressionStream:h}=e;let d,g,b=Ba(super.readable);o&&(s?b=re(b,new qu(e)):(g=new Hu(e),b=re(b,g))),l&&(b=Ua(b,h,{chunkSize:t},i,n)),o&&!s||!c||(d=new ya,b=re(b,d)),Da(this,b,()=>{if((!o||s)&&c){const f=new DataView(d.value.buffer);if(a!=f.getUint32(0,!1))throw new Error(xa)}})}}function Ba(r){return re(r,new TransformStream({transform(e,t){e&&e.length&&t.enqueue(e)}}))}function Da(r,e,t){e=re(e,new TransformStream({flush:t})),Object.defineProperty(r,"readable",{get:()=>e})}function Ua(r,e,t,n,i){try{r=re(r,new(e&&n?n:i)(Fa,t))}catch(s){if(!e)throw s;r=re(r,new i(Fa,t))}return r}function re(r,e){return r.pipeThrough(e)}const Ku="message",Zu="start",Ju="pull",ja="data",Qu="ack",th="close",$a="inflate";class eh extends TransformStream{constructor(e,t){super({});const n=this,{codecType:i}=e;let s;i.startsWith("deflate")?s=Gu:i.startsWith($a)&&(s=Yu);let o=0;const c=new s(e,t),a=super.readable,l=new TransformStream({transform(h,d){h&&h.length&&(o+=h.length,d.enqueue(h))},flush(){const{signature:h}=c;Object.assign(n,{signature:h,size:o})}});Object.defineProperty(n,"readable",{get:()=>a.pipeThrough(c).pipeThrough(l)})}}const nh=typeof Worker!=Tr;class Cs{constructor(e,{readable:t,writable:n},{options:i,config:s,streamOptions:o,useWebWorkers:c,transferStreams:a,scripts:l},h){const{signal:d}=o;return Object.assign(e,{busy:!0,readable:t.pipeThrough(new ih(t,o,s),{signal:d}),writable:n,options:Object.assign({},i),scripts:l,transferStreams:a,terminate(){const{worker:g,busy:b}=e;g&&!b&&(g.terminate(),e.interface=null)},onTaskFinished(){e.busy=!1,h(e)}}),(c&&nh?sh:rh)(e,s)}}class ih extends TransformStream{constructor(e,{onstart:t,onprogress:n,size:i,onend:s},{chunkSize:o}){let c=0;super({start(){t&&Rs(t,i)},async transform(a,l){c+=a.length,n&&await Rs(n,c,i),l.enqueue(a)},flush(){e.size=c,s&&Rs(s,c)}},{highWaterMark:1,size:()=>o})}}async function Rs(r,...e){try{await r(...e)}catch{}}function rh(r,e){return{run:()=>async function({options:t,readable:n,writable:i,onTaskFinished:s},o){const c=new eh(t,o);try{await n.pipeThrough(c).pipeTo(i,{preventClose:!0,preventAbort:!0});const{signature:a,size:l}=c;return{signature:a,size:l}}finally{s()}}(r,e)}}function sh(r,{baseURL:e,chunkSize:t}){return r.interface||Object.assign(r,{worker:oh(r.scripts[0],e,r),interface:{run:()=>async function(n,i){let s,o;const c=new Promise((w,p)=>{s=w,o=p});Object.assign(n,{reader:null,writer:null,resolveResult:s,rejectResult:o,result:c});const{readable:a,options:l,scripts:h}=n,{writable:d,closed:g}=function(w){const p=w.getWriter();let m;const y=new Promise(_=>m=_);return{writable:new WritableStream({async write(_){await p.ready,await p.write(_)},close(){p.releaseLock(),m()},abort:_=>p.abort(_)}),closed:y}}(n.writable);Is({type:Zu,scripts:h.slice(1),options:l,config:i,readable:a,writable:d},n)||Object.assign(n,{reader:a.getReader(),writer:d.getWriter()});const f=await c;try{await d.getWriter().close()}catch{}return await g,f}(r,{chunkSize:t})}}),r.interface}let Wa=!0,Ha=!0;function oh(r,e,t){const n={type:"module"};let i,s;typeof r==pa&&(r=r());try{i=new URL(r,e)}catch{i=r}if(Wa)try{s=new Worker(i)}catch{Wa=!1,s=new Worker(i,n)}else s=new Worker(i,n);return s.addEventListener(Ku,o=>async function({data:c},a){const{type:l,value:h,messageId:d,result:g,error:b}=c,{reader:f,writer:w,resolveResult:p,rejectResult:m,onTaskFinished:y}=a;try{if(b){const{message:_,stack:k,code:T,name:x}=b,I=new Error(_);Object.assign(I,{stack:k,code:T,name:x}),S(I)}else{if(l==Ju){const{value:_,done:k}=await f.read();Is({type:ja,value:_,done:k,messageId:d},a)}l==ja&&(await w.ready,await w.write(new Uint8Array(h)),Is({type:Qu,messageId:d},a)),l==th&&S(null,g)}}catch(_){S(_)}function S(_,k){_?m(_):p(k),w&&w.releaseLock(),y()}}(o,t)),s}function Is(r,{worker:e,writer:t,onTaskFinished:n,transferStreams:i}){try{let{value:s,readable:o,writable:c}=r;const a=[];if(s&&(r.value=s.buffer,a.push(r.value)),i&&Ha?(o&&a.push(o),c&&a.push(c)):r.readable=r.writable=null,a.length)try{return e.postMessage(r,a),!0}catch{Ha=!1,r.readable=r.writable=null,e.postMessage(r)}else e.postMessage(r)}catch(s){throw t&&t.releaseLock(),n(),s}}let cn=[];const Ms=[];let Va=0;function qa(r){const{terminateTimeout:e}=r;e&&(clearTimeout(e),r.terminateTimeout=null)}const ah=65536,Xa="writable";class zs{constructor(){this.size=0}init(){this.initialized=!0}}class Ga extends zs{get readable(){const e=this,{chunkSize:t=ah}=e,n=new ReadableStream({start(){this.chunkOffset=0},async pull(i){const{offset:s=0,size:o,diskNumberStart:c}=n,{chunkOffset:a}=this;i.enqueue(await wt(e,s+a,Math.min(t,o-a),c)),a+t>o?i.close():this.chunkOffset+=t}});return n}}class Ya extends Ga{constructor(e){super(),Object.assign(this,{blob:e,size:e.size})}async readUint8Array(e,t){const n=this,i=e+t;let o=await(e||i<n.size?n.blob.slice(e,i):n.blob).arrayBuffer();return o.byteLength>t&&(o=o.slice(e,i)),new Uint8Array(o)}}class Ka extends zs{constructor(e){super();const t=new TransformStream,n=[];e&&n.push(["Content-Type",e]),Object.defineProperty(this,Xa,{get:()=>t.writable}),this.blob=new Response(t.readable,{headers:n}).blob()}getData(){return this.blob}}class ch extends Ka{constructor(e){super(e),Object.assign(this,{encoding:e,utf8:!e||e.toLowerCase()=="utf-8"})}async getData(){const{encoding:e,utf8:t}=this,n=await super.getData();if(n.text&&t)return n.text();{const i=new FileReader;return new Promise((s,o)=>{Object.assign(i,{onload:({target:c})=>s(c.result),onerror:()=>o(i.error)}),i.readAsText(n,e)})}}}class lh extends Ga{constructor(e){super(),this.readers=e}async init(){const e=this,{readers:t}=e;e.lastDiskNumber=0,e.lastDiskOffset=0,await Promise.all(t.map(async(n,i)=>{await n.init(),i!=t.length-1&&(e.lastDiskOffset+=n.size),e.size+=n.size})),super.init()}async readUint8Array(e,t,n=0){const i=this,{readers:s}=this;let o,c=n;c==-1&&(c=s.length-1);let a=e;for(;a>=s[c].size;)a-=s[c].size,c++;const l=s[c],h=l.size;if(a+t<=h)o=await wt(l,a,t);else{const d=h-a;o=new Uint8Array(t),o.set(await wt(l,a,d)),o.set(await i.readUint8Array(e+d,t-d,n),d)}return i.lastDiskNumber=Math.max(c,i.lastDiskNumber),o}}class Za extends zs{constructor(e,t=4294967295){super();const n=this;let i,s,o;Object.assign(n,{diskNumber:0,diskOffset:0,size:0,maxSize:t,availableSize:t});const c=new WritableStream({async write(h){const{availableSize:d}=n;if(o)h.length>=d?(await a(h.slice(0,d)),await l(),n.diskOffset+=i.size,n.diskNumber++,o=null,await this.write(h.slice(d))):await a(h);else{const{value:g,done:b}=await e.next();if(b&&!g)throw new Error("Writer iterator completed too soon");i=g,i.size=0,i.maxSize&&(n.maxSize=i.maxSize),n.availableSize=n.maxSize,await Mr(i),s=g.writable,o=s.getWriter(),await this.write(h)}},async close(){await o.ready,await l()}});async function a(h){const d=h.length;d&&(await o.ready,await o.write(h),i.size+=d,n.size+=d,n.availableSize-=d)}async function l(){s.size=i.size,await o.close()}Object.defineProperty(n,Xa,{get:()=>c})}}async function Mr(r,e){r.init&&!r.initialized&&await r.init(e)}function uh(r){return Array.isArray(r)&&(r=new lh(r)),r instanceof ReadableStream&&(r={readable:r}),r}function wt(r,e,t,n){return r.readUint8Array(e,t,n)}const Ja="\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split(""),hh=Ja.length==256;function Os(r,e){return e&&e.trim().toLowerCase()=="cp437"?function(t){if(hh){let n="";for(let i=0;i<t.length;i++)n+=Ja[t[i]];return n}return new TextDecoder().decode(t)}(r):new TextDecoder(e).decode(r)}const Qa="filename",tc="rawFilename",ec="comment",nc="rawComment",ic="uncompressedSize",rc="compressedSize",sc="offset",Ps="diskNumberStart",Ns="lastModDate",Fs="rawLastModDate",oc="lastAccessDate",dh="rawLastAccessDate",ac="creationDate",fh="rawCreationDate",ph=[Qa,tc,rc,ic,Ns,Fs,ec,nc,oc,ac,sc,Ps,Ps,"internalFileAttribute","externalFileAttribute","msDosCompatible","zip64","directory","bitFlag","encrypted","signature","filenameUTF8","commentUTF8","compressionMethod","version","versionMadeBy","extraField","rawExtraField","extraFieldZip64","extraFieldUnicodePath","extraFieldUnicodeComment","extraFieldAES","extraFieldNTFS","extraFieldExtendedTimestamp"];class cc{constructor(e){ph.forEach(t=>this[t]=e[t])}}const Bs="File format is not recognized",gh="Zip64 extra field not found",lc="Compression method not supported",uc="Split zip file",hc="utf-8",dc="cp437",mh=[[ic,on],[rc,on],[sc,on],[Ps,an]],bh={[an]:{getValue:st,bytes:4},[on]:{getValue:zr,bytes:8}};class wh{constructor(e,t={}){Object.assign(this,{reader:uh(e),options:t,config:Be})}async*getEntriesGenerator(e={}){const t=this;let{reader:n}=t;const{config:i}=t;if(await Mr(n),n.size!==qt&&n.readUint8Array||(n=new Ya(await new Response(n.readable).blob()),await Mr(n)),n.size<22)throw new Error(Bs);n.chunkSize=function(P){return Math.max(P.chunkSize,64)}(i);const s=await async function(P,A,L,z,B){const U=new Uint8Array(4);(function(pt,ot,D){pt.setUint32(ot,D,!0)})(ht(U),0,A);const M=z+B;return await j(z)||await j(Math.min(M,L));async function j(pt){const ot=L-pt,D=await wt(P,ot,pt);for(let Q=D.length-z;Q>=0;Q--)if(D[Q]==U[0]&&D[Q+1]==U[1]&&D[Q+2]==U[2]&&D[Q+3]==U[3])return{offset:ot+Q,buffer:D.slice(Q,Q+z).buffer}}}(n,101010256,n.size,22,1048560);if(!s)throw st(ht(await wt(n,0,4)))==134695760?new Error(uc):new Error("End of central directory not found");const o=ht(s);let c=st(o,12),a=st(o,16);const l=s.offset,h=ut(o,20),d=l+22+h;let g=ut(o,4);const b=n.lastDiskNumber||0;let f=ut(o,6),w=ut(o,8),p=0,m=0;if(a==on||c==on||w==an||f==an){const P=ht(await wt(n,s.offset-20,20));if(st(P,0)!=117853008)throw new Error("End of Zip64 central directory not found");a=zr(P,8);let A=await wt(n,a,56,-1),L=ht(A);const z=s.offset-20-56;if(st(L,0)!=fa&&a!=z){const B=a;a=z,p=a-B,A=await wt(n,a,56,-1),L=ht(A)}if(st(L,0)!=fa)throw new Error("End of Zip64 central directory locator not found");g==an&&(g=st(L,16)),f==an&&(f=st(L,20)),w==an&&(w=zr(L,32)),c==on&&(c=zr(L,40)),a-=c}if(b!=g)throw new Error(uc);if(a<0||a>=n.size)throw new Error(Bs);let y=0,S=await wt(n,a,c,f),_=ht(S);if(c){const P=s.offset-c;if(st(_,y)!=da&&a!=P){const A=a;a=P,p=a-A,S=await wt(n,a,c,f),_=ht(S)}}const k=s.offset-a-(n.lastDiskOffset||0);if(c!=k&&k>=0&&(c=k,S=await wt(n,a,c,f),_=ht(S)),a<0||a>=n.size)throw new Error(Bs);const T=Bt(t,e,"filenameEncoding"),x=Bt(t,e,"commentEncoding");for(let P=0;P<w;P++){const A=new yh(n,i,t.options);if(st(_,y)!=da)throw new Error("Central directory header not found");fc(A,_,y+6);const L=!!A.bitFlag.languageEncodingFlag,z=y+46,B=z+A.filenameLength,U=B+A.extraFieldLength,M=ut(_,y+4),j=(0&M)==0,pt=S.subarray(z,B),ot=ut(_,y+32),D=U+ot,Q=S.subarray(U,D),H=L,X=L,fe=j&&(16&Nn(_,y+38))==16,Me=st(_,y+42)+p;Object.assign(A,{versionMadeBy:M,msDosCompatible:j,compressedSize:0,uncompressedSize:0,commentLength:ot,directory:fe,offset:Me,diskNumberStart:ut(_,y+34),internalFileAttribute:ut(_,y+36),externalFileAttribute:st(_,y+38),rawFilename:pt,filenameUTF8:H,commentUTF8:X,rawExtraField:S.subarray(B,U)});const[mt,bt]=await Promise.all([Os(pt,H?hc:T||dc),Os(Q,X?hc:x||dc)]);Object.assign(A,{rawComment:Q,filename:mt,comment:bt,directory:fe||mt.endsWith("/")}),m=Math.max(Me,m),await pc(A,A,_,y+6);const lt=new cc(A);lt.getData=(ze,rn)=>A.getData(ze,lt,rn),y=D;const{onprogress:Nt}=e;if(Nt)try{await Nt(P+1,w,new cc(A))}catch{}yield lt}const I=Bt(t,e,"extractPrependedData"),F=Bt(t,e,"extractAppendedData");return I&&(t.prependedData=m>0?await wt(n,0,m):new Uint8Array),t.comment=h?await wt(n,l+22,h):new Uint8Array,F&&(t.appendedData=d<n.size?await wt(n,d,n.size-d):new Uint8Array),!0}async getEntries(e={}){const t=[];for await(const n of this.getEntriesGenerator(e))t.push(n);return t}async close(){}}class yh{constructor(e,t,n){Object.assign(this,{reader:e,config:t,options:n})}async getData(e,t,n={}){const i=this,{reader:s,offset:o,diskNumberStart:c,extraFieldAES:a,compressionMethod:l,config:h,bitFlag:d,signature:g,rawLastModDate:b,uncompressedSize:f,compressedSize:w}=i,p=t.localDirectory={},m=ht(await wt(s,o,30,c));let y=Bt(i,n,"password");if(y=y&&y.length&&y,a&&a.originalCompressionMethod!=99)throw new Error(lc);if(l!=0&&l!=8)throw new Error(lc);if(st(m,0)!=67324752)throw new Error("Local file header not found");fc(p,m,4),p.rawExtraField=p.extraFieldLength?await wt(s,o+30+p.filenameLength,p.extraFieldLength,c):new Uint8Array,await pc(i,p,m,4,!0),Object.assign(t,{lastAccessDate:p.lastAccessDate,creationDate:p.creationDate});const S=i.encrypted&&p.encrypted,_=S&&!a;if(S){if(!_&&a.strength===qt)throw new Error("Encryption method not supported");if(!y)throw new Error("File contains encrypted entry")}const k=o+30+p.filenameLength+p.extraFieldLength,T=w,x=s.readable;Object.assign(x,{diskNumberStart:c,offset:k,size:T});const I=Bt(i,n,"signal"),F=Bt(i,n,"checkPasswordOnly");F&&(e=new WritableStream),e=function(M){M.writable===qt&&typeof M.next==pa&&(M=new Za(M)),M instanceof WritableStream&&(M={writable:M});const{writable:j}=M;return j.size===qt&&(j.size=0),M instanceof Za||Object.assign(M,{diskNumber:0,diskOffset:0,availableSize:1/0,maxSize:1/0}),M}(e),await Mr(e,f);const{writable:P}=e,{onstart:A,onprogress:L,onend:z}=n,B={options:{codecType:$a,password:y,zipCrypto:_,encryptionStrength:a&&a.strength,signed:Bt(i,n,"checkSignature"),passwordVerification:_&&(d.dataDescriptor?b>>>8&255:g>>>24&255),signature:g,compressed:l!=0,encrypted:S,useWebWorkers:Bt(i,n,"useWebWorkers"),useCompressionStream:Bt(i,n,"useCompressionStream"),transferStreams:Bt(i,n,"transferStreams"),checkPasswordOnly:F},config:h,streamOptions:{signal:I,size:T,onstart:A,onprogress:L,onend:z}};let U=0;try{({outputSize:U}=await async function(M,j){const{options:pt,config:ot}=j,{transferStreams:D,useWebWorkers:Q,useCompressionStream:H,codecType:X,compressed:fe,signed:Me,encrypted:mt}=pt,{workerScripts:bt,maxWorkers:lt,terminateWorkerTimeout:Nt}=ot;j.transferStreams=D||D===qt;const ze=!(fe||Me||mt||j.transferStreams);let rn;j.useWebWorkers=!ze&&(Q||Q===qt&&ot.useWebWorkers),j.scripts=j.useWebWorkers&&bt?bt[X]:[],pt.useCompressionStream=H||H===qt&&ot.useCompressionStream;const ai=cn.find(vt=>!vt.busy);if(ai)qa(ai),rn=new Cs(ai,M,j,lr);else if(cn.length<lt){const vt={indexWorker:Va};Va++,cn.push(vt),rn=new Cs(vt,M,j,lr)}else rn=await new Promise(vt=>Ms.push({resolve:vt,stream:M,workerOptions:j}));return rn.run();function lr(vt){if(Ms.length){const[{resolve:pe,stream:ci,workerOptions:as}]=Ms.splice(0,1);pe(new Cs(vt,ci,as,lr))}else vt.worker?(qa(vt),Number.isFinite(Nt)&&Nt>=0&&(vt.terminateTimeout=setTimeout(()=>{cn=cn.filter(pe=>pe!=vt),vt.terminate()},Nt))):cn=cn.filter(pe=>pe!=vt)}}({readable:x,writable:P},B))}catch(M){if(!F||M.message!=Es)throw M}finally{const M=Bt(i,n,"preventClose");P.size+=U,M||P.locked||await P.getWriter().close()}return F?void 0:e.getData?e.getData():P}}function fc(r,e,t){const n=r.rawBitFlag=ut(e,t+2),i=(1&n)==1,s=st(e,t+6);Object.assign(r,{encrypted:i,version:ut(e,t),bitFlag:{level:(6&n)>>1,dataDescriptor:(8&n)==8,languageEncodingFlag:(2048&n)==2048},rawLastModDate:s,lastModDate:vh(s),filenameLength:ut(e,t+22),extraFieldLength:ut(e,t+24)})}async function pc(r,e,t,n,i){const{rawExtraField:s}=e,o=e.extraField=new Map,c=ht(new Uint8Array(s));let a=0;try{for(;a<s.length;){const m=ut(c,a),y=ut(c,a+2);o.set(m,{type:m,data:s.slice(a+4,a+4+y)}),a+=4+y}}catch{}const l=ut(t,n+4);Object.assign(e,{signature:st(t,n+10),uncompressedSize:st(t,n+18),compressedSize:st(t,n+14)});const h=o.get(1);h&&(function(m,y){y.zip64=!0;const S=ht(m.data),_=mh.filter(([k,T])=>y[k]==T);for(let k=0,T=0;k<_.length;k++){const[x,I]=_[k];if(y[x]==I){const F=bh[I];y[x]=m[x]=F.getValue(S,T),T+=F.bytes}else if(m[x])throw new Error(gh)}}(h,e),e.extraFieldZip64=h);const d=o.get(28789);d&&(await gc(d,Qa,tc,e,r),e.extraFieldUnicodePath=d);const g=o.get(25461);g&&(await gc(g,ec,nc,e,r),e.extraFieldUnicodeComment=g);const b=o.get(39169);b?(function(m,y,S){const _=ht(m.data),k=Nn(_,4);Object.assign(m,{vendorVersion:Nn(_,0),vendorId:Nn(_,2),strength:k,originalCompressionMethod:S,compressionMethod:ut(_,5)}),y.compressionMethod=m.compressionMethod}(b,e,l),e.extraFieldAES=b):e.compressionMethod=l;const f=o.get(10);f&&(function(m,y){const S=ht(m.data);let _,k=4;try{for(;k<m.data.length&&!_;){const T=ut(S,k),x=ut(S,k+2);T==Ru&&(_=m.data.slice(k+4,k+4+x)),k+=4+x}}catch{}try{if(_&&_.length==24){const T=ht(_),x=T.getBigUint64(0,!0),I=T.getBigUint64(8,!0),F=T.getBigUint64(16,!0);Object.assign(m,{rawLastModDate:x,rawLastAccessDate:I,rawCreationDate:F});const P=Ds(x),A=Ds(I),L={lastModDate:P,lastAccessDate:A,creationDate:Ds(F)};Object.assign(m,L),Object.assign(y,L)}}catch{}}(f,e),e.extraFieldNTFS=f);const w=o.get(21589);w&&(function(m,y,S){const _=ht(m.data),k=Nn(_,0),T=[],x=[];S?((1&k)==1&&(T.push(Ns),x.push(Fs)),(2&k)==2&&(T.push(oc),x.push(dh)),(4&k)==4&&(T.push(ac),x.push(fh))):m.data.length>=5&&(T.push(Ns),x.push(Fs));let I=1;T.forEach((F,P)=>{if(m.data.length>=I+4){const A=st(_,I);y[F]=m[F]=new Date(1e3*A);const L=x[P];m[L]=A}I+=4})}(w,e,i),e.extraFieldExtendedTimestamp=w);const p=o.get(6534);p&&(e.extraFieldUSDZ=p)}async function gc(r,e,t,n,i){const s=ht(r.data),o=new Lr;o.append(i[t]);const c=ht(new Uint8Array(4));c.setUint32(0,o.get(),!0);const a=st(s,1);Object.assign(r,{version:Nn(s,0),[e]:Os(r.data.subarray(5)),valid:!i.bitFlag.languageEncodingFlag&&a==st(c,0)}),r.valid&&(n[e]=r[e],n[e+"UTF8"]=!0)}function Bt(r,e,t){return e[t]===qt?r.options[t]:e[t]}function vh(r){const e=(4294901760&r)>>16,t=65535&r;try{return new Date(1980+((65024&e)>>9),((480&e)>>5)-1,31&e,(63488&t)>>11,(2016&t)>>5,2*(31&t),0)}catch{}}function Ds(r){return new Date(Number(r/BigInt(1e4)-BigInt(116444736e5)))}function Nn(r,e){return r.getUint8(e)}function ut(r,e){return r.getUint16(e,!0)}function st(r,e){return r.getUint32(e,!0)}function zr(r,e){return Number(r.getBigUint64(e,!0))}function ht(r){return new DataView(r.buffer)}ba({Inflate:function(r){const e=new ha,t=r&&r.chunkSize?Math.floor(2*r.chunkSize):131072,n=new Uint8Array(t);let i=!1;e.inflateInit(),e.next_out=n,this.append=function(s,o){const c=[];let a,l,h=0,d=0,g=0;if(s.length!==0){e.next_in_index=0,e.next_in=s,e.avail_in=s.length;do{if(e.next_out_index=0,e.avail_out=t,e.avail_in!==0||i||(e.next_in_index=0,i=!0),a=e.inflate(0),i&&a===me){if(e.avail_in!==0)throw new Error("inflating: bad input")}else if(a!==Y&&a!==ge)throw new Error("inflating: "+e.msg);if((i||a===ge)&&e.avail_in===s.length)throw new Error("inflating: bad input");e.next_out_index&&(e.next_out_index===t?c.push(new Uint8Array(n)):c.push(n.subarray(0,e.next_out_index))),g+=e.next_out_index,o&&e.next_in_index>0&&e.next_in_index!=h&&(o(e.next_in_index),h=e.next_in_index)}while(e.avail_in>0||e.avail_out===0);return c.length>1?(l=new Uint8Array(g),c.forEach(function(b){l.set(b,d),d+=b.length})):l=c[0]?new Uint8Array(c[0]):new Uint8Array,l}},this.flush=function(){e.inflateEnd()}}});const xh=Object.freeze(Object.defineProperty({__proto__:null,BlobReader:Ya,BlobWriter:Ka,TextWriter:ch,ZipReader:wh,configure:ba},Symbol.toStringTag,{value:"Module"})),rt={CONTAINER:"urn:oasis:names:tc:opendocument:xmlns:container",XHTML:"http://www.w3.org/1999/xhtml",OPF:"http://www.idpf.org/2007/opf",EPUB:"http://www.idpf.org/2007/ops",DC:"http://purl.org/dc/elements/1.1/",DCTERMS:"http://purl.org/dc/terms/",ENC:"http://www.w3.org/2001/04/xmlenc#",NCX:"http://www.daisy.org/z3986/2005/ncx/",XLINK:"http://www.w3.org/1999/xlink",SMIL:"http://www.w3.org/ns/SMIL"},St={XML:"application/xml",NCX:"application/x-dtbncx+xml",XHTML:"application/xhtml+xml",HTML:"text/html",CSS:"text/css",SVG:"image/svg+xml",JS:/\/(x-)?(javascript|ecmascript)/},Or=r=>r.toLowerCase().replace(/[-:](.)/g,(e,t)=>t.toUpperCase()),_h=r=>r?r.replace(/[\t\n\f\r ]+/g," ").replace(/^[\t\n\f\r ]+/,"").replace(/[\t\n\f\r ]+$/,""):"",ki=(r,e,t)=>t?n=>{var i,s;return(s=(i=n.getAttribute(r))==null?void 0:i.split(/\s/))==null?void 0:s.includes(e)}:typeof e=="function"?n=>e(n.getAttribute(r)):n=>n.getAttribute(r)===e,Pr=(...r)=>e=>e?Object.fromEntries(r.map(t=>[Or(t),e.getAttribute(t)])):null,be=r=>_h(r==null?void 0:r.textContent),Ei=(r,e)=>{const t=r.lookupNamespaceURI(null)===e||r.lookupPrefix(e),n=t?(i,s)=>o=>o.namespaceURI===e&&o.localName===s:(i,s)=>o=>o.localName===s;return{$:(i,s)=>[...i.children].find(n(i,s)),$$:(i,s)=>[...i.children].filter(n(i,s)),$$$:t?(i,s)=>[...i.getElementsByTagNameNS(e,s)]:(i,s)=>[...i.getElementsByTagName(s)]}},Fn=(r,e)=>{try{if(e.includes(":"))return new URL(r,e);const t="https://invalid.invalid/",n=new URL(r,t+e);return n.search="",decodeURI(n.href.replace(t,""))}catch(t){return console.warn(t),r}},mc=r=>/^(?!blob)\w+:/i.test(r),Sh=(r,e)=>{if(!r)return e;const t=r.replace(/\/$/,"").split("/"),n=e.replace(/\/$/,"").split("/"),i=(t.length>n.length?t:n).findIndex((s,o)=>t[o]!==n[o]);return i<0?"":Array(t.length-i).fill("..").concat(n.slice(i)).join("/")},kh=r=>r.slice(0,r.lastIndexOf("/")+1),Nr=async(r,e,t)=>{const n=[];r.replace(e,(...s)=>(n.push(s),null));const i=[];for(const s of n)i.push(await t(...s));return r.replace(e,()=>i.shift())},Eh=r=>r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),je={attrs:["dir","xml:lang"]},ln={name:"alternate-script",many:!0,...je,props:["file-as"]},bc={many:!0,...je,props:[{name:"role",many:!0,attrs:["scheme"]},"file-as",ln],setLegacyAttrs:(r,e)=>{var t;if(!((t=r.role)!=null&&t.length)){const n=e.getAttributeNS(rt.OPF,"role");n&&(r.role=[{value:n}])}r.fileAs??(r.fileAs=e.getAttributeNS(rt.OPF,"file-as"))}},Ah=[{name:"title",many:!0,...je,props:["title-type","display-seq","file-as",ln]},{name:"identifier",many:!0,props:[{name:"identifier-type",attrs:["scheme"]}],setLegacyAttrs:(r,e)=>{if(!r.identifierType){const t=e.getAttributeNS(rt.OPF,"scheme");t&&(r.identifierType={value:t})}}},{name:"language",many:!0},{name:"creator",...bc},{name:"contributor",...bc},{name:"publisher",...je,props:["file-as",ln]},{name:"description",...je,props:[ln]},{name:"rights",...je,props:[ln]},{name:"date"},{name:"dcterms:modified",type:"meta"},{name:"subject",many:!0,...je,props:["term","authority",ln],setLegacyAttrs:(r,e)=>{r.term??(r.term=e.getAttributeNS(rt.OPF,"term")),r.authority??(r.authority=e.getAttributeNS(rt.OPF,"authority"))}},{name:"source",many:!0},{name:"belongs-to-collection",type:"meta",many:!0,...je,props:["collection-type","group-position","dcterms:identifier","file-as",ln,{name:"belongs-to-collection",recursive:!0}]}],Th=r=>{var g,b;const{$:e,$$:t}=Ei(r,rt.OPF),n=e(r.documentElement,"metadata"),i=Array.from(n.children),s=(f,w)=>{var T;if(!w)return null;const{props:p=[],attrs:m=[]}=f,y=be(w);if(!p.length&&!m.length)return y;const S=w.getAttribute("id"),_=S?i.filter(ki("refines","#"+S)):[],k=Object.fromEntries([["value",y]].concat(p.map(x=>{const{many:I,recursive:F}=x,P=typeof x=="string"?x:x.name,A=ki("property",P),L=F?f:x;return[Or(P),I?_.filter(A).map(z=>s(L,z)):s(L,_.find(A))]})).concat(m.map(x=>[Or(x),w.getAttribute(x)])));return(T=f.setLegacyAttrs)==null||T.call(f,k,w),k},o=i.filter(ki("refines",null)),c=Object.fromEntries(Ah.map(f=>{const{type:w,name:p,many:m}=f,y=w==="meta"?S=>S.namespaceURI===rt.OPF&&S.getAttribute("property")===p:S=>S.namespaceURI===rt.DC&&S.localName===p;return[Or(p),m?o.filter(y).map(S=>s(f,S)):s(f,o.find(y))]})),a=t(n,"meta"),l=f=>a.filter(ki("property",w=>w==null?void 0:w.startsWith(f))).map(w=>[w.getAttribute("property").replace(f,""),w]),h=Object.fromEntries(l("rendition:").map(([f,w])=>[f,be(w)])),d={narrator:[],duration:{}};for(const[f,w]of l("media:")){const p=be(w);f==="duration"?d.duration[((b=(g=w.getAttribute("refines"))==null?void 0:g.split("#"))==null?void 0:b[1])??""]=Us(p):f==="active-class"?d.activeClass=p:f==="narrator"?d.narrator.push(p):f==="playback-active-class"&&(d.playbackActiveClass=p)}return{metadata:c,rendition:h,media:d}},Lh=(r,e=t=>t)=>{var f;const{$:t,$$:n,$$$:i}=Ei(r,rt.XHTML),s=w=>w?decodeURI(e(w)):null,o=w=>p=>{var T;const m=t(p,"a")??t(p,"span"),y=t(p,"ol"),S=s(m==null?void 0:m.getAttribute("href")),k={label:be(m)||(m==null?void 0:m.getAttribute("title")),href:S,subitems:c(y)};return w&&(k.type=(T=m==null?void 0:m.getAttributeNS(rt.EPUB,"type"))==null?void 0:T.split(/\s/)),k},c=(w,p)=>w?n(w,"li").map(o(p)):null,a=(w,p)=>c(t(w,"ol"),p),l=i(r,"nav");let h=null,d=null,g=null,b=[];for(const w of l){const p=((f=w.getAttributeNS(rt.EPUB,"type"))==null?void 0:f.split(/\s/))??[];p.includes("toc")?h??(h=a(w)):p.includes("page-list")?d??(d=a(w)):p.includes("landmarks")?g??(g=a(w,!0)):b.push({label:be(w.firstElementChild),type:p,list:a(w)})}return{toc:h,pageList:d,landmarks:g,others:b}},Ch=(r,e=t=>t)=>{const{$:t,$$:n}=Ei(r,rt.NCX),i=a=>a?decodeURI(e(a)):null,s=a=>{const l=t(a,"navLabel"),h=t(a,"content"),d=be(l),g=i(h.getAttribute("src"));if(a.localName==="navPoint"){const b=n(a,"navPoint");return{label:d,href:g,subitems:b.length?b.map(s):null}}return{label:d,href:g}},o=(a,l)=>n(a,l).map(s),c=(a,l)=>{const h=t(r.documentElement,a);return h?o(h,l):null};return{toc:c("navMap","navPoint"),pageList:c("pageList","pageTarget"),others:n(r.documentElement,"navList").map(a=>({label:be(t(a,"navLabel")),list:o(a,"navTarget")}))}},Us=r=>{if(!r)return;const e=r.split(":").map(o=>parseFloat(o));if(e.length===3){const[o,c,a]=e;return o*60*60+c*60+a}if(e.length===2){const[o,c]=e;return o*60+c}const[t,n]=r.split(/(?=[^\d.])/),i=parseFloat(t),s=n==="h"?60*60:n==="min"?60:n==="ms"?.001:1;return i*s};class Rh extends EventTarget{constructor(t,n){super();E(this,is);E(this,Zn);E(this,Je);E(this,Ae);E(this,Zi);E(this,Jn);E(this,Te);E(this,Ze,void 0);E(this,Gi,void 0);E(this,xn,void 0);E(this,Ht,void 0);E(this,Rt,void 0);E(this,yt,void 0);E(this,Yi,1);E(this,Ki,1);this.book=t,this.loadXML=n}async start(t,n=()=>!0){var c;(c=u(this,yt))==null||c.pause();const i=this.book.sections[t],s=i==null?void 0:i.id;if(!s)return;const{mediaOverlay:o}=i;if(!o)return this.start(t+1);R(this,xn,t),await C(this,is,gl).call(this,o);for(let a=0;a<u(this,Ze).length;a++){const{items:l}=u(this,Ze)[a];for(let h=0;h<l.length;h++)if(l[h].text.split("#")[0]===s&&n(l[h],h,l))return C(this,Te,Rn).call(this,a,h).catch(d=>C(this,Ae,Cn).call(this,d))}}pause(){var t;(t=u(this,yt))==null||t.pause()}resume(){var t;(t=u(this,yt))==null||t.play().catch(n=>C(this,Ae,Cn).call(this,n))}prev(){u(this,Rt)>0?C(this,Te,Rn).call(this,u(this,Ht),u(this,Rt)-1):u(this,Ht)>0?C(this,Te,Rn).call(this,u(this,Ht)-1,u(this,Ze)[u(this,Ht)-1].items.length-1):u(this,xn)>0&&this.start(u(this,xn)-1,(t,n,i)=>n===i.length-1)}next(){C(this,Te,Rn).call(this,u(this,Ht),u(this,Rt)+1)}setVolume(t){R(this,Yi,t),u(this,yt)&&(u(this,yt).volume=t)}setRate(t){R(this,Ki,t),u(this,yt)&&(u(this,yt).playbackRate=t)}}Ze=new WeakMap,Gi=new WeakMap,xn=new WeakMap,Ht=new WeakMap,Rt=new WeakMap,yt=new WeakMap,Yi=new WeakMap,Ki=new WeakMap,is=new WeakSet,gl=async function(t){if(u(this,Gi)===t)return;const n=await this.loadXML(t.href),i=c=>c?Fn(c,t.href):null,{$:s,$$$:o}=Ei(n,rt.SMIL);R(this,Ht,-1),R(this,Rt,-1),R(this,Ze,o(n,"par").reduce((c,a)=>{var w;const l=i((w=s(a,"text"))==null?void 0:w.getAttribute("src")),h=s(a,"audio");if(!l||!h)return c;const d=i(h.getAttribute("src")),g=Us(h.getAttribute("clipBegin")),b=Us(h.getAttribute("clipEnd")),f=c.at(-1);return(f==null?void 0:f.src)===d?f.items.push({text:l,begin:g,end:b}):c.push({src:d,items:[{text:l,begin:g,end:b}]}),c},[])),R(this,Gi,t)},Zn=new WeakSet,ps=function(){return u(this,Ze)[u(this,Ht)]},Je=new WeakSet,pi=function(){var t,n;return(n=(t=u(this,Zn,ps))==null?void 0:t.items)==null?void 0:n[u(this,Rt)]},Ae=new WeakSet,Cn=function(t){console.error(t),this.dispatchEvent(new CustomEvent("error",{detail:t}))},Zi=new WeakSet,po=function(){this.dispatchEvent(new CustomEvent("highlight",{detail:u(this,Je,pi)}))},Jn=new WeakSet,gs=function(){this.dispatchEvent(new CustomEvent("unhighlight",{detail:u(this,Je,pi)}))},Te=new WeakSet,Rn=async function(t,n){var c;u(this,yt)&&(u(this,yt).pause(),URL.revokeObjectURL(u(this,yt).src),R(this,yt,null)),R(this,Ht,t),R(this,Rt,n);const i=(c=u(this,Zn,ps))==null?void 0:c.src;if(!i||!u(this,Je,pi))return this.start(u(this,xn)+1);const s=URL.createObjectURL(await this.book.loadBlob(i)),o=new Audio(s);R(this,yt,o),o.addEventListener("timeupdate",()=>{var d,g;if(o.paused)return;const a=o.currentTime,{items:l}=u(this,Zn,ps);if(a>((d=u(this,Je,pi))==null?void 0:d.end)&&(C(this,Jn,gs).call(this),u(this,Rt)===l.length-1)){C(this,Te,Rn).call(this,u(this,Ht)+1,0).catch(b=>C(this,Ae,Cn).call(this,b));return}const h=u(this,Rt);for(;((g=l[u(this,Rt)+1])==null?void 0:g.begin)<=a;)hr(this,Rt)._++;u(this,Rt)!==h&&C(this,Zi,po).call(this)}),o.addEventListener("error",()=>C(this,Ae,Cn).call(this,new Error(`Failed to load ${i}`))),o.addEventListener("playing",()=>C(this,Zi,po).call(this)),o.addEventListener("pause",()=>C(this,Jn,gs).call(this)),o.addEventListener("ended",()=>{C(this,Jn,gs).call(this),URL.revokeObjectURL(s),R(this,yt,null),C(this,Te,Rn).call(this,t+1,0).catch(a=>C(this,Ae,Cn).call(this,a))}),o.addEventListener("canplaythrough",()=>{o.currentTime=u(this,Je,pi).begin??0,o.volume=u(this,Yi),o.playbackRate=u(this,Ki),o.play().catch(a=>C(this,Ae,Cn).call(this,a))})};const Ih=/([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})/,Mh=r=>{for(const e of r.getElementsByTagNameNS(rt.DC,"identifier")){const[t]=be(e).split(":").slice(-1);if(Ih.test(t))return t}return""},wc=r=>be(r.getElementById(r.documentElement.getAttribute("unique-identifier"))??r.getElementsByTagNameNS(rt.DC,"identifier")[0]),yc=async(r,e,t)=>{const n=new Uint8Array(await t.slice(0,e).arrayBuffer());e=Math.min(e,n.length);for(var i=0;i<e;i++)n[i]=n[i]^r[i%r.length];return new Blob([n,t.slice(e)],{type:t.type})},zh=async r=>{const e=new TextEncoder().encode(r),t=await globalThis.crypto.subtle.digest("SHA-1",e);return new Uint8Array(t)},Oh=(r=zh)=>({"http://www.idpf.org/2008/embedding":{key:e=>r(wc(e).replaceAll(/[\u0020\u0009\u000d\u000a]/g,"")),decode:(e,t)=>yc(e,1040,t)},"http://ns.adobe.com/pdf/enc#RC":{key:e=>{const t=Mh(e).replaceAll("-","");return Uint8Array.from({length:16},(n,i)=>parseInt(t.slice(i*2,i*2+2),16))},decode:(e,t)=>yc(e,1024,t)}});class Ph{constructor(e){E(this,Ji,new Map);E(this,Qn,new Map);E(this,Qi,void 0);R(this,Qi,e)}async init(e,t){if(!e)return;const n=Array.from(e.getElementsByTagNameNS(rt.ENC,"EncryptedData"),i=>{var s,o;return{algorithm:(s=i.getElementsByTagNameNS(rt.ENC,"EncryptionMethod")[0])==null?void 0:s.getAttribute("Algorithm"),uri:(o=i.getElementsByTagNameNS(rt.ENC,"CipherReference")[0])==null?void 0:o.getAttribute("URI")}});for(const{algorithm:i,uri:s}of n){if(!u(this,Qn).has(i)){const o=u(this,Qi)[i];if(!o){console.warn("Unknown encryption algorithm");continue}const c=await o.key(t);u(this,Qn).set(i,a=>o.decode(c,a))}u(this,Ji).set(s,i)}}getDecoder(e){return u(this,Qn).get(u(this,Ji).get(e))??(t=>t)}}Ji=new WeakMap,Qn=new WeakMap,Qi=new WeakMap;class Nh{constructor({opf:e,resolveHref:t}){var h,d,g,b,f;this.opf=e;const{$:n,$$:i,$$$:s}=Ei(e,rt.OPF),o=n(e.documentElement,"manifest"),c=n(e.documentElement,"spine"),a=i(c,"itemref");this.manifest=i(o,"item").map(Pr("href","id","media-type","properties","media-overlay")).map(w=>{var p;return w.href=t(w.href),w.properties=(p=w.properties)==null?void 0:p.split(/\s/),w}),this.spine=a.map(Pr("idref","id","linear","properties")).map(w=>{var p;return w.properties=(p=w.properties)==null?void 0:p.split(/\s/),w}),this.pageProgressionDirection=c.getAttribute("page-progression-direction"),this.navPath=(h=this.getItemByProperty("nav"))==null?void 0:h.href,this.ncxPath=(d=this.getItemByID(c.getAttribute("toc"))??this.manifest.find(w=>w.mediaType===St.NCX))==null?void 0:d.href;const l=n(e.documentElement,"guide");l&&(this.guide=i(l,"reference").map(Pr("type","title","href")).map(({type:w,title:p,href:m})=>({label:p,type:w.split(/\s/),href:t(m)}))),this.cover=this.getItemByProperty("cover-image")??this.getItemByID((g=s(e,"meta").find(ki("name","cover")))==null?void 0:g.getAttribute("content"))??this.getItemByHref((f=(b=this.guide)==null?void 0:b.find(w=>w.type.includes("cover")))==null?void 0:f.href),this.cfis=Ll(a)}getItemByID(e){return this.manifest.find(t=>t.id===e)}getItemByHref(e){return this.manifest.find(t=>t.href===e)}getItemByProperty(e){return this.manifest.find(t=>{var n;return(n=t.properties)==null?void 0:n.includes(e)})}resolveCFI(e){const t=mi(e),n=(t.parent??t).shift();let i=Ao(this.opf,n);i&&i.nodeName!=="idref"&&(n.at(-1).id=null,i=Ao(this.opf,n));const s=i==null?void 0:i.getAttribute("idref");return{index:this.spine.findIndex(a=>a.idref===s),anchor:a=>Eo(a,t)}}}class Fh{constructor({loadText:e,loadBlob:t,resources:n}){E(this,Le,new Map);E(this,Ce,new Map);E(this,he,new Map);It(this,"allowScript",!1);this.loadText=e,this.loadBlob=t,this.manifest=n.manifest,this.assets=n.manifest}createURL(e,t,n,i){if(!t)return"";const s=URL.createObjectURL(new Blob([t],{type:n}));if(u(this,Le).set(e,s),u(this,he).set(e,1),i){const o=u(this,Ce).get(i);o?o.push(e):u(this,Ce).set(i,[e])}return s}ref(e,t){const n=u(this,Ce).get(t);return n!=null&&n.includes(e)||(u(this,he).set(e,u(this,he).get(e)+1),n?n.push(e):u(this,Ce).set(t,[e])),u(this,Le).get(e)}unref(e){if(!u(this,he).has(e))return;const t=u(this,he).get(e)-1;if(t<1){URL.revokeObjectURL(u(this,Le).get(e)),u(this,Le).delete(e),u(this,he).delete(e);const n=u(this,Ce).get(e);if(n)for(;n.length;)this.unref(n.pop());u(this,Ce).delete(e)}else u(this,he).set(e,t)}async loadItem(e,t=[]){if(!e)return null;const{href:n,mediaType:i}=e,s=St.JS.test(e.mediaType);if(s&&!this.allowScript)return null;const o=t.at(-1);return u(this,Le).has(n)?this.ref(n,o):(s||[St.XHTML,St.HTML,St.CSS,St.SVG].includes(i))&&t.every(a=>a!==n)?this.loadReplaced(e,t):this.createURL(n,await this.loadBlob(n),i,o)}async loadHref(e,t,n=[]){if(mc(e))return e;const i=Fn(e,t),s=this.manifest.find(o=>o.href===i);return s?this.loadItem(s,n.concat(t)):e}async loadReplaced(e,t=[]){const{href:n,mediaType:i}=e,s=t.at(-1),o=await this.loadText(n);if(!o)return null;if([St.XHTML,St.HTML,St.SVG].includes(i)){let a=new DOMParser().parseFromString(o,i);if(i===St.XHTML&&a.querySelector("parsererror")&&(console.warn(a.querySelector("parsererror").innerText),e.mediaType=St.HTML,a=new DOMParser().parseFromString(o,e.mediaType)),[St.XHTML,St.SVG].includes(e.mediaType)){let d=a.firstChild;for(;d instanceof ProcessingInstruction;){if(d.data){const g=await Nr(d.data,/(?:^|\s*)(href\s*=\s*['"])([^'"]*)(['"])/i,(b,f,w,p)=>this.loadHref(w,n,t).then(m=>`${f}${m}${p}`));d.replaceWith(a.createProcessingInstruction(d.target,g))}d=d.nextSibling}}const l=async(d,g)=>d.setAttribute(g,await this.loadHref(d.getAttribute(g),n,t));for(const d of a.querySelectorAll("link[href]"))await l(d,"href");for(const d of a.querySelectorAll("[src]"))await l(d,"src");for(const d of a.querySelectorAll("[poster]"))await l(d,"poster");for(const d of a.querySelectorAll("object[data]"))await l(d,"data");for(const d of a.querySelectorAll("[*|href]:not([href]"))d.setAttributeNS(rt.XLINK,"href",await this.loadHref(d.getAttributeNS(rt.XLINK,"href"),n,t));for(const d of a.querySelectorAll("style"))d.textContent&&(d.textContent=await this.replaceCSS(d.textContent,n,t));for(const d of a.querySelectorAll("[style]"))d.setAttribute("style",await this.replaceCSS(d.getAttribute("style"),n,t));const h=new XMLSerializer().serializeToString(a);return this.createURL(n,h,e.mediaType,s)}const c=i===St.CSS?await this.replaceCSS(o,n,t):await this.replaceString(o,n,t);return this.createURL(n,c,i,s)}async replaceCSS(e,t,n=[]){const i=await Nr(e,/url\(\s*["']?([^'"\n]*?)\s*["']?\s*\)/gi,(a,l)=>this.loadHref(l,t,n).then(h=>`url("${h}")`)),s=await Nr(i,/@import\s*["']([^"'\n]*?)["']/gi,(a,l)=>this.loadHref(l,t,n).then(h=>`@import "${h}"`)),o=(window==null?void 0:window.innerWidth)??800,c=(window==null?void 0:window.innerHeight)??600;return s.replace(new RegExp("(?<=[{\\s;])-epub-","gi"),"").replace(/(\d*\.?\d+)vw/gi,(a,l)=>parseFloat(l)*o/100+"px").replace(/(\d*\.?\d+)vh/gi,(a,l)=>parseFloat(l)*c/100+"px").replace(/page-break-(after|before|inside)\s*:/gi,(a,l)=>`-webkit-column-break-${l}:`).replace(/break-(after|before|inside)\s*:\s*(avoid-)?page/gi,(a,l,h)=>`break-${l}: ${h??""}column`)}replaceString(e,t,n=[]){const i=new Map,s=this.assets.map(c=>{if(c.href===t)return;const a=Sh(kh(t),c.href),l=encodeURI(a),h="/"+c.href,d=encodeURI(h),g=new Set([a,l,h,d]);for(const b of g)i.set(b,c);return Array.from(g)}).flat().filter(c=>c);if(!s.length)return e;const o=new RegExp(s.map(Eh).join("|"),"g");return Nr(e,o,async c=>this.loadItem(i.get(c.replace(/^\//,"")),n.concat(t)))}unloadItem(e){this.unref(e==null?void 0:e.href)}destroy(){for(const e of u(this,Le).values())URL.revokeObjectURL(e)}}Le=new WeakMap,Ce=new WeakMap,he=new WeakMap;const Bh=(r,e)=>r.getElementById(e)??r.querySelector(`[name="${CSS.escape(e)}"]`),Dh=r=>{for(const e of r){if(e==="page-spread-left"||e==="rendition:page-spread-left")return"left";if(e==="page-spread-right"||e==="rendition:page-spread-right")return"right";if(e==="rendition:page-spread-center")return"center"}};class Uh{constructor({loadText:e,loadBlob:t,getSize:n,sha1:i}){E(this,Re);It(this,"parser",new DOMParser);E(this,_n,void 0);E(this,ti,void 0);this.loadText=e,this.loadBlob=t,this.getSize=n,R(this,ti,new Ph(Oh(i)))}async init(){var f,w,p,m,y,S,_,k,T,x,I,F,P;const e=await C(this,Re,In).call(this,"META-INF/container.xml");if(!e)throw new Error("Failed to load container file");const t=Array.from(e.getElementsByTagNameNS(rt.CONTAINER,"rootfile"),Pr("full-path","media-type")).filter(A=>A.mediaType==="application/oebps-package+xml");if(!t.length)throw new Error("No package document defined in container");const n=t[0].fullPath,i=await C(this,Re,In).call(this,n);if(!i)throw new Error("Failed to load package document");const s=await C(this,Re,In).call(this,"META-INF/encryption.xml");await u(this,ti).init(s,i),this.resources=new Nh({opf:i,resolveHref:A=>Fn(A,n)}),R(this,_n,new Fh({loadText:this.loadText,loadBlob:A=>Promise.resolve(this.loadBlob(A)).then(u(this,ti).getDecoder(A)),resources:this.resources})),this.sections=this.resources.spine.map((A,L)=>{const{idref:z,linear:B,properties:U=[]}=A,M=this.resources.getItemByID(z);return M?{id:M.href,load:()=>u(this,_n).loadItem(M),unload:()=>u(this,_n).unloadItem(M),createDocument:()=>this.loadDocument(M),size:this.getSize(M.href),cfi:this.resources.cfis[L],linear:B,pageSpread:Dh(U),resolveHref:j=>Fn(j,M.href),mediaOverlay:M.mediaOverlay?this.resources.getItemByID(M.mediaOverlay):null}:(console.warn(`Could not find item with ID "${z}" in manifest`),null)}).filter(A=>A);const{navPath:o,ncxPath:c}=this.resources;if(o)try{const A=z=>Fn(z,o),L=Lh(await C(this,Re,In).call(this,o),A);this.toc=L.toc,this.pageList=L.pageList,this.landmarks=L.landmarks}catch(A){console.warn(A)}if(!this.toc&&c)try{const A=z=>Fn(z,c),L=Ch(await C(this,Re,In).call(this,c),A);this.toc=L.toc,this.pageList=L.pageList}catch(A){console.warn(A)}this.landmarks??(this.landmarks=this.resources.guide);const{metadata:a,rendition:l,media:h}=Th(i);this.rendition=l,this.media=h,this.dir=this.resources.pageProgressionDirection,this.parsedMetadata=a;const d=(f=a==null?void 0:a.title)==null?void 0:f[0];this.metadata={title:d==null?void 0:d.value,subtitle:(p=(w=a==null?void 0:a.title)==null?void 0:w.find(A=>A.titleType==="subtitle"))==null?void 0:p.value,sortAs:d==null?void 0:d.fileAs,language:a==null?void 0:a.language,identifier:wc(i),description:(m=a==null?void 0:a.description)==null?void 0:m.value,publisher:(y=a==null?void 0:a.publisher)==null?void 0:y.value,published:a==null?void 0:a.date,modified:a==null?void 0:a.dctermsModified,subject:(_=(S=a==null?void 0:a.subject)==null?void 0:S.filter(({value:A,term:L})=>A||L))==null?void 0:_.map(({value:A,term:L,authority:z})=>({name:A,code:L,scheme:z})),rights:(k=a==null?void 0:a.rights)==null?void 0:k.value};const g={art:"artist",aut:"author",bkp:"producer",clr:"colorist",edt:"editor",ill:"illustrator",nrt:"narrator",trl:"translator",pbl:"publisher"},b=A=>L=>{var U;const z=[...new Set((U=L.role)==null?void 0:U.map(({value:M,scheme:j})=>(!j||j==="marc:relators"?g[M]:null)??A))],B={name:L.value,sortAs:L.fileAs};return[z!=null&&z.length?z:[A],B]};return(P=(F=(T=a==null?void 0:a.creator)==null?void 0:T.map(b("author")))==null?void 0:F.concat((I=(x=a==null?void 0:a.contributor)==null?void 0:x.map)==null?void 0:I.call(x,b("contributor"))))==null||P.forEach(([A,L])=>A.forEach(z=>{this.metadata[z]?this.metadata[z].push(L):this.metadata[z]=[L]})),this}async loadDocument(e){const t=await this.loadText(e.href);return this.parser.parseFromString(t,e.mediaType)}getMediaOverlay(){return new Rh(this,C(this,Re,In).bind(this))}resolveCFI(e){return this.resources.resolveCFI(e)}resolveHref(e){const[t,n]=e.split("#"),i=this.resources.getItemByHref(decodeURI(t));return i?{index:this.resources.spine.findIndex(({idref:c})=>c===i.id),anchor:n?c=>Bh(c,n):()=>0}:null}splitTOCHref(e){return(e==null?void 0:e.split("#"))??[]}getTOCFragment(e,t){return e.getElementById(t)??e.querySelector(`[name="${CSS.escape(t)}"]`)}isExternal(e){return mc(e)}async getCover(){var t;const e=(t=this.resources)==null?void 0:t.cover;return e!=null&&e.href?new Blob([await this.loadBlob(e.href)],{type:e.mediaType}):null}async getCalibreBookmarks(){const e=await this.loadText("META-INF/calibre_bookmarks.txt"),t="encoding=json+base64:";if(e!=null&&e.startsWith(t)){const n=atob(e.slice(t.length));return JSON.parse(n)}}destroy(){var e;(e=u(this,_n))==null||e.destroy()}}_n=new WeakMap,ti=new WeakMap,Re=new WeakSet,In=async function(e){const t=await this.loadText(e);if(!t)return null;const n=this.parser.parseFromString(t,St.XML);if(n.querySelector("parsererror"))throw new Error(`XML parsing error: ${e}
154
+ ${n.querySelector("parsererror").innerText}`);return n};const vc=Object.freeze(Object.defineProperty({__proto__:null,EPUB:Uh},Symbol.toStringTag,{value:"Module"})),jh=Object.freeze(Object.defineProperty({__proto__:null,makeComicBook:({entries:r,loadBlob:e,getSize:t},n)=>{const i=new Map,s=new Map,o=async d=>{if(i.has(d))return i.get(d);const g=URL.createObjectURL(await e(d)),b=URL.createObjectURL(new Blob([`<img src="${g}">`],{type:"text/html"}));return s.set(d,[g,b]),i.set(d,b),b},c=d=>{var g,b;(b=(g=s.get(d))==null?void 0:g.forEach)==null||b.call(g,f=>URL.revokeObjectURL(f)),s.delete(d),i.delete(d)},a=[".jpg",".jpeg",".png",".gif",".bmp",".webp",".svg",".jxl",".avif"],l=r.map(d=>d.filename).filter(d=>a.some(g=>d.endsWith(g))).sort();if(!l.length)throw new Error("No supported image files in archive");const h={};return h.getCover=()=>e(l[0]),h.metadata={title:n.name},h.sections=l.map(d=>({id:d,load:()=>o(d),unload:()=>c(d),size:t(d)})),h.toc=l.map(d=>({label:d,href:d})),h.rendition={layout:"pre-paginated"},h.resolveHref=d=>({index:h.sections.findIndex(g=>g.id===d)}),h.splitTOCHref=d=>[d,null],h.getTOCFragment=d=>d.documentElement,h.destroy=()=>{for(const d of s.values())for(const g of d)URL.revokeObjectURL(g)},h}},Symbol.toStringTag,{value:"Module"})),xc=r=>r?r.replace(/[\t\n\f\r ]+/g," ").replace(/^[\t\n\f\r ]+/,"").replace(/[\t\n\f\r ]+$/,""):"",Dt=r=>xc(r==null?void 0:r.textContent),Fr={XLINK:"http://www.w3.org/1999/xlink",EPUB:"http://www.idpf.org/2007/ops"},Br={XML:"application/xml",XHTML:"application/xhtml+xml"},Xt={strong:["strong","self"],emphasis:["em","self"],style:["span","self"],a:"anchor",strikethrough:["s","self"],sub:["sub","self"],sup:["sup","self"],code:["code","self"],image:"image"},$h={tr:["tr",["align"]],th:["th",["colspan","rowspan","align","valign"]],td:["td",["colspan","rowspan","align","valign"]]},_c={epigraph:["blockquote"],subtitle:["h2",Xt],"text-author":["p",Xt],date:["p",Xt],stanza:"stanza"},Dr={title:["header",{p:["h1",Xt],"empty-line":["br"]}],epigraph:["blockquote","self"],image:"image",annotation:["aside"],section:["section","self"],p:["p",Xt],poem:["blockquote",_c],subtitle:["h2",Xt],cite:["blockquote","self"],"empty-line":["br"],table:["table",$h],"text-author":["p",Xt]};_c.epigraph.push(Dr);const Wh={image:"image",title:["section",{p:["h1",Xt],"empty-line":["br"]}],epigraph:["section",Dr],section:["section",Dr]},Sc=r=>{const e=r.getAttributeNS(Fr.XLINK,"href"),[,t]=e.split("#"),n=r.getRootNode().getElementById(t);return n?`data:${n.getAttribute("content-type")};base64,${n.textContent}`:e};class Hh{constructor(e){this.fb2=e,this.doc=document.implementation.createDocument(Fr.XHTML,"html")}image(e){const t=this.doc.createElement("img");return t.alt=e.getAttribute("alt"),t.title=e.getAttribute("title"),t.setAttribute("src",Sc(e)),t}anchor(e){const t=this.convert(e,{a:["a",Xt]});return t.setAttribute("href",e.getAttributeNS(Fr.XLINK,"href")),e.getAttribute("type")==="note"&&t.setAttributeNS(Fr.EPUB,"epub:type","noteref"),t}stanza(e){const t=this.convert(e,{stanza:["p",{title:["header",{p:["strong",Xt],"empty-line":["br"]}],subtitle:["p",Xt]}]});for(const n of e.children)n.nodeName==="v"&&(t.append(this.doc.createTextNode(n.textContent)),t.append(this.doc.createElement("br")));return t}convert(e,t){if(e.nodeType===3)return this.doc.createTextNode(e.textContent);if(e.nodeType===4)return this.doc.createCDATASection(e.textContent);if(e.nodeType===8)return this.doc.createComment(e.textContent);const n=t==null?void 0:t[e.nodeName];if(!n)return null;if(typeof n=="string")return this[n](e);const[i,s]=n,o=this.doc.createElement(i);if(e.id&&(o.id=e.id),o.classList.add(e.nodeName),Array.isArray(s))for(const l of s)o.setAttribute(l,e.getAttribute(l));const c=s==="self"?t:Array.isArray(s)?null:s;let a=e.firstChild;for(;a;){const l=this.convert(a,c);l&&o.append(l),a=a.nextSibling}return o}}const Vh=async r=>{var o;const e=await r.arrayBuffer(),t=new TextDecoder("utf-8").decode(e),n=new DOMParser,i=n.parseFromString(t,Br.XML),s=i.xmlEncoding||((o=t.match(/^<\?xml\s+version\s*=\s*["']1.\d+"\s+encoding\s*=\s*["']([A-Za-z0-9._-]*)["']/))==null?void 0:o[1]);if(s&&s.toLowerCase()!=="utf-8"){const c=new TextDecoder(s).decode(e);return n.parseFromString(c,Br.XML)}return i},qh=URL.createObjectURL(new Blob([`
155
+ @namespace epub "http://www.idpf.org/2007/ops";
156
+ body > img, section > img {
157
+ display: block;
158
+ margin: auto;
159
+ }
160
+ .title h1 {
161
+ text-align: center;
162
+ }
163
+ body > section > .title, body.notesBodyType > .title {
164
+ margin: 3em 0;
165
+ }
166
+ body.notesBodyType > section .title h1 {
167
+ text-align: start;
168
+ }
169
+ body.notesBodyType > section .title {
170
+ margin: 1em 0;
171
+ }
172
+ p {
173
+ text-indent: 1em;
174
+ margin: 0;
175
+ }
176
+ :not(p) + p, p:first-child {
177
+ text-indent: 0;
178
+ }
179
+ .poem p {
180
+ text-indent: 0;
181
+ margin: 1em 0;
182
+ }
183
+ .text-author, .date {
184
+ text-align: end;
185
+ }
186
+ .text-author:before {
187
+ content: "—";
188
+ }
189
+ table {
190
+ border-collapse: collapse;
191
+ }
192
+ td, th {
193
+ padding: .25em;
194
+ }
195
+ a[epub|type~="noteref"] {
196
+ font-size: .75em;
197
+ vertical-align: super;
198
+ }
199
+ body:not(.notesBodyType) > .title, body:not(.notesBodyType) > .epigraph {
200
+ margin: 3em 0;
201
+ }
202
+ `],{type:"text/css"})),Xh=r=>`<?xml version="1.0" encoding="utf-8"?>
203
+ <html xmlns="http://www.w3.org/1999/xhtml">
204
+ <head><link href="${qh}" rel="stylesheet" type="text/css"/></head>
205
+ <body>${r}</body>
206
+ </html>`,js="data-foliate-id",kc=Object.freeze(Object.defineProperty({__proto__:null,makeFB2:async r=>{const e={},t=await Vh(r),n=new Hh(t),i=b=>t.querySelector(b),s=b=>[...t.querySelectorAll(b)],o=b=>{const f=Dt(b.querySelector("nickname"));if(f)return f;const w=Dt(b.querySelector("first-name")),p=Dt(b.querySelector("middle-name")),m=Dt(b.querySelector("last-name")),y=[w,p,m].filter(_=>_).join(" "),S=m?[m,[w,p].filter(_=>_).join(" ")].join(", "):null;return{name:y,sortAs:S}},c=b=>(b==null?void 0:b.getAttribute("value"))??Dt(b),a=i("title-info annotation");if(e.metadata={title:Dt(i("title-info book-title")),identifier:Dt(i("document-info id")),language:Dt(i("title-info lang")),author:s("title-info author").map(o),translator:s("title-info translator").map(o),producer:s("document-info author").map(o).concat(s("document-info program-used").map(Dt)),publisher:Dt(i("publish-info publisher")),published:c(i("title-info date")),modified:c(i("document-info date")),description:a?n.convert(a,{annotation:["div",Dr]}).innerHTML:null,subject:s("title-info genre").map(Dt)},i("coverpage image")){const b=Sc(i("coverpage image"));e.getCover=()=>fetch(b).then(f=>f.blob())}else e.getCover=()=>null;const l=Array.from(t.querySelectorAll("body"),b=>{const f=n.convert(b,{body:["body",Wh]});return[Array.from(f.children,w=>{const p=[w,...w.querySelectorAll("[id]")].map(m=>m.id);return{el:w,ids:p}}),f]}),h=[],d=l[0][0].map(({el:b,ids:f})=>{const w=Array.from(b.querySelectorAll(":scope > section > .title"),(p,m)=>(p.setAttribute(js,m),{title:Dt(p),index:m}));return{ids:f,titles:w,el:b}}).concat(l.slice(1).map(([b,f])=>{const w=b.map(p=>p.ids).flat();return f.classList.add("notesBodyType"),{ids:w,el:f,linear:"no"}})).map(({ids:b,titles:f,el:w,linear:p})=>{var k;const m=Xh(w.outerHTML),y=new Blob([m],{type:Br.XHTML}),S=URL.createObjectURL(y);h.push(S);const _=xc(((k=w.querySelector(".title, .subtitle, p"))==null?void 0:k.textContent)??(w.classList.contains("title")?w.textContent:""));return{ids:b,title:_,titles:f,load:()=>S,createDocument:()=>new DOMParser().parseFromString(m,Br.XHTML),size:y.size-Array.from(w.querySelectorAll("[src]"),T=>{var x;return((x=T.getAttribute("src"))==null?void 0:x.length)??0}).reduce((T,x)=>T+x,0),linear:p}}),g=new Map;return e.sections=d.map((b,f)=>{const{ids:w,load:p,createDocument:m,size:y,linear:S}=b;for(const _ of w)_&&g.set(_,f);return{id:f,load:p,createDocument:m,size:y,linear:S}}),e.toc=d.map(({title:b,titles:f},w)=>{const p=w.toString();return{label:b,href:p,subitems:f!=null&&f.length?f.map(({title:m,index:y})=>({label:m,href:`${p}#${y}`})):null}}).filter(b=>b),e.resolveHref=b=>{const[f,w]=b.split("#");return f?{index:Number(f),anchor:p=>p.querySelector(`[${js}="${w}"]`)}:{index:g.get(w),anchor:p=>p.getElementById(w)}},e.splitTOCHref=b=>{var f;return((f=b==null?void 0:b.split("#"))==null?void 0:f.map(w=>Number(w)))??[]},e.getTOCFragment=(b,f)=>b.querySelector(`[${js}="${f}"]`),e.destroy=()=>{for(const b of h)URL.revokeObjectURL(b)},e}},Symbol.toStringTag,{value:"Module"})),Gh=`
207
+ /* Copyright 2014 Mozilla Foundation
208
+ *
209
+ * Licensed under the Apache License, Version 2.0 (the "License");
210
+ * you may not use this file except in compliance with the License.
211
+ * You may obtain a copy of the License at
212
+ *
213
+ * http://www.apache.org/licenses/LICENSE-2.0
214
+ *
215
+ * Unless required by applicable law or agreed to in writing, software
216
+ * distributed under the License is distributed on an "AS IS" BASIS,
217
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
218
+ * See the License for the specific language governing permissions and
219
+ * limitations under the License.
220
+ */
221
+
222
+ :root {
223
+ --highlight-bg-color: rgb(180 0 170);
224
+ --highlight-selected-bg-color: rgb(0 100 0);
225
+ }
226
+
227
+ @media screen and (forced-colors: active) {
228
+ :root {
229
+ --highlight-bg-color: Highlight;
230
+ --highlight-selected-bg-color: ButtonText;
231
+ }
232
+ }
233
+
234
+ .textLayer {
235
+ position: absolute;
236
+ text-align: initial;
237
+ inset: 0;
238
+ overflow: hidden;
239
+ opacity: 0.25;
240
+ line-height: 1;
241
+ text-size-adjust: none;
242
+ forced-color-adjust: none;
243
+ transform-origin: 0 0;
244
+ z-index: 2;
245
+ }
246
+
247
+ .textLayer :is(span, br) {
248
+ color: transparent;
249
+ position: absolute;
250
+ white-space: pre;
251
+ cursor: text;
252
+ transform-origin: 0% 0%;
253
+ }
254
+
255
+ /* Only necessary in Google Chrome, see issue 14205, and most unfortunately
256
+ * the problem doesn't show up in "text" reference tests. */
257
+ /*#if !MOZCENTRAL*/
258
+ .textLayer span.markedContent {
259
+ top: 0;
260
+ height: 0;
261
+ }
262
+ /*#endif*/
263
+
264
+ .textLayer .highlight {
265
+ margin: -1px;
266
+ padding: 1px;
267
+ background-color: var(--highlight-bg-color);
268
+ border-radius: 4px;
269
+ }
270
+
271
+ .textLayer .highlight.appended {
272
+ position: initial;
273
+ }
274
+
275
+ .textLayer .highlight.begin {
276
+ border-radius: 4px 0 0 4px;
277
+ }
278
+
279
+ .textLayer .highlight.end {
280
+ border-radius: 0 4px 4px 0;
281
+ }
282
+
283
+ .textLayer .highlight.middle {
284
+ border-radius: 0;
285
+ }
286
+
287
+ .textLayer .highlight.selected {
288
+ background-color: var(--highlight-selected-bg-color);
289
+ }
290
+
291
+ .textLayer ::selection {
292
+ /*#if !MOZCENTRAL*/
293
+ background: blue;
294
+ /*#endif*/
295
+ background: AccentColor; /* stylelint-disable-line declaration-block-no-duplicate-properties */
296
+ }
297
+
298
+ /* Avoids https://github.com/mozilla/pdf.js/issues/13840 in Chrome */
299
+ /*#if !MOZCENTRAL*/
300
+ .textLayer br::selection {
301
+ background: transparent;
302
+ }
303
+ /*#endif*/
304
+
305
+ .textLayer .endOfContent {
306
+ display: block;
307
+ position: absolute;
308
+ inset: 100% 0 0;
309
+ z-index: -1;
310
+ cursor: default;
311
+ user-select: none;
312
+ }
313
+
314
+ .textLayer .endOfContent.active {
315
+ top: 0;
316
+ }
317
+ `,Yh=`
318
+ /* Copyright 2014 Mozilla Foundation
319
+ *
320
+ * Licensed under the Apache License, Version 2.0 (the "License");
321
+ * you may not use this file except in compliance with the License.
322
+ * You may obtain a copy of the License at
323
+ *
324
+ * http://www.apache.org/licenses/LICENSE-2.0
325
+ *
326
+ * Unless required by applicable law or agreed to in writing, software
327
+ * distributed under the License is distributed on an "AS IS" BASIS,
328
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
329
+ * See the License for the specific language governing permissions and
330
+ * limitations under the License.
331
+ */
332
+
333
+ :root {
334
+ --annotation-unfocused-field-background: url("data:image/svg+xml;charset=UTF-8,<svg width='1px' height='1px' xmlns='http://www.w3.org/2000/svg'><rect width='100%' height='100%' style='fill:rgba(0, 54, 255, 0.13);'/></svg>");
335
+ --input-focus-border-color: Highlight;
336
+ --input-focus-outline: 1px solid Canvas;
337
+ --input-unfocused-border-color: transparent;
338
+ --input-disabled-border-color: transparent;
339
+ --input-hover-border-color: black;
340
+ --link-outline: none;
341
+ }
342
+
343
+ @media screen and (forced-colors: active) {
344
+ :root {
345
+ --input-focus-border-color: CanvasText;
346
+ --input-unfocused-border-color: ActiveText;
347
+ --input-disabled-border-color: GrayText;
348
+ --input-hover-border-color: Highlight;
349
+ --link-outline: 1.5px solid LinkText;
350
+ --hcm-highligh-filter: invert(100%);
351
+ }
352
+ .annotationLayer .textWidgetAnnotation :is(input, textarea):required,
353
+ .annotationLayer .choiceWidgetAnnotation select:required,
354
+ .annotationLayer
355
+ .buttonWidgetAnnotation:is(.checkBox, .radioButton)
356
+ input:required {
357
+ outline: 1.5px solid selectedItem;
358
+ }
359
+
360
+ .annotationLayer .linkAnnotation:hover {
361
+ backdrop-filter: var(--hcm-highligh-filter);
362
+ }
363
+
364
+ .annotationLayer .linkAnnotation > a:hover {
365
+ opacity: 0 !important;
366
+ background: none !important;
367
+ box-shadow: none;
368
+ }
369
+
370
+ .annotationLayer .popupAnnotation .popup {
371
+ outline: calc(1.5px * var(--scale-factor)) solid CanvasText !important;
372
+ background-color: ButtonFace !important;
373
+ color: ButtonText !important;
374
+ }
375
+
376
+ .annotationLayer .highlightArea:hover::after {
377
+ position: absolute;
378
+ top: 0;
379
+ left: 0;
380
+ width: 100%;
381
+ height: 100%;
382
+ backdrop-filter: var(--hcm-highligh-filter);
383
+ content: "";
384
+ pointer-events: none;
385
+ }
386
+
387
+ .annotationLayer .popupAnnotation.focused .popup {
388
+ outline: calc(3px * var(--scale-factor)) solid Highlight !important;
389
+ }
390
+ }
391
+
392
+ .annotationLayer {
393
+ position: absolute;
394
+ top: 0;
395
+ left: 0;
396
+ pointer-events: none;
397
+ transform-origin: 0 0;
398
+ z-index: 3;
399
+ }
400
+
401
+ .annotationLayer[data-main-rotation="90"] .norotate {
402
+ transform: rotate(270deg) translateX(-100%);
403
+ }
404
+ .annotationLayer[data-main-rotation="180"] .norotate {
405
+ transform: rotate(180deg) translate(-100%, -100%);
406
+ }
407
+ .annotationLayer[data-main-rotation="270"] .norotate {
408
+ transform: rotate(90deg) translateY(-100%);
409
+ }
410
+
411
+ .annotationLayer canvas {
412
+ position: absolute;
413
+ width: 100%;
414
+ height: 100%;
415
+ pointer-events: none;
416
+ }
417
+
418
+ .annotationLayer section {
419
+ position: absolute;
420
+ text-align: initial;
421
+ pointer-events: auto;
422
+ box-sizing: border-box;
423
+ transform-origin: 0 0;
424
+ }
425
+
426
+ .annotationLayer .linkAnnotation {
427
+ outline: var(--link-outline);
428
+ }
429
+
430
+ .annotationLayer :is(.linkAnnotation, .buttonWidgetAnnotation.pushButton) > a {
431
+ position: absolute;
432
+ font-size: 1em;
433
+ top: 0;
434
+ left: 0;
435
+ width: 100%;
436
+ height: 100%;
437
+ }
438
+
439
+ .annotationLayer
440
+ :is(.linkAnnotation, .buttonWidgetAnnotation.pushButton):not(.hasBorder)
441
+ > a:hover {
442
+ opacity: 0.2;
443
+ background-color: rgb(255 255 0);
444
+ box-shadow: 0 2px 10px rgb(255 255 0);
445
+ }
446
+
447
+ .annotationLayer .linkAnnotation.hasBorder:hover {
448
+ background-color: rgb(255 255 0 / 0.2);
449
+ }
450
+
451
+ .annotationLayer .hasBorder {
452
+ background-size: 100% 100%;
453
+ }
454
+
455
+ .annotationLayer .textAnnotation img {
456
+ position: absolute;
457
+ cursor: pointer;
458
+ width: 100%;
459
+ height: 100%;
460
+ top: 0;
461
+ left: 0;
462
+ }
463
+
464
+ .annotationLayer .textWidgetAnnotation :is(input, textarea),
465
+ .annotationLayer .choiceWidgetAnnotation select,
466
+ .annotationLayer .buttonWidgetAnnotation:is(.checkBox, .radioButton) input {
467
+ background-image: var(--annotation-unfocused-field-background);
468
+ border: 2px solid var(--input-unfocused-border-color);
469
+ box-sizing: border-box;
470
+ font: calc(9px * var(--scale-factor)) sans-serif;
471
+ height: 100%;
472
+ margin: 0;
473
+ vertical-align: top;
474
+ width: 100%;
475
+ }
476
+
477
+ .annotationLayer .textWidgetAnnotation :is(input, textarea):required,
478
+ .annotationLayer .choiceWidgetAnnotation select:required,
479
+ .annotationLayer
480
+ .buttonWidgetAnnotation:is(.checkBox, .radioButton)
481
+ input:required {
482
+ outline: 1.5px solid red;
483
+ }
484
+
485
+ .annotationLayer .choiceWidgetAnnotation select option {
486
+ padding: 0;
487
+ }
488
+
489
+ .annotationLayer .buttonWidgetAnnotation.radioButton input {
490
+ border-radius: 50%;
491
+ }
492
+
493
+ .annotationLayer .textWidgetAnnotation textarea {
494
+ resize: none;
495
+ }
496
+
497
+ .annotationLayer .textWidgetAnnotation :is(input, textarea)[disabled],
498
+ .annotationLayer .choiceWidgetAnnotation select[disabled],
499
+ .annotationLayer
500
+ .buttonWidgetAnnotation:is(.checkBox, .radioButton)
501
+ input[disabled] {
502
+ background: none;
503
+ border: 2px solid var(--input-disabled-border-color);
504
+ cursor: not-allowed;
505
+ }
506
+
507
+ .annotationLayer .textWidgetAnnotation :is(input, textarea):hover,
508
+ .annotationLayer .choiceWidgetAnnotation select:hover,
509
+ .annotationLayer
510
+ .buttonWidgetAnnotation:is(.checkBox, .radioButton)
511
+ input:hover {
512
+ border: 2px solid var(--input-hover-border-color);
513
+ }
514
+ .annotationLayer .textWidgetAnnotation :is(input, textarea):hover,
515
+ .annotationLayer .choiceWidgetAnnotation select:hover,
516
+ .annotationLayer .buttonWidgetAnnotation.checkBox input:hover {
517
+ border-radius: 2px;
518
+ }
519
+
520
+ .annotationLayer .textWidgetAnnotation :is(input, textarea):focus,
521
+ .annotationLayer .choiceWidgetAnnotation select:focus {
522
+ background: none;
523
+ border: 2px solid var(--input-focus-border-color);
524
+ border-radius: 2px;
525
+ outline: var(--input-focus-outline);
526
+ }
527
+
528
+ .annotationLayer .buttonWidgetAnnotation:is(.checkBox, .radioButton) :focus {
529
+ background-image: none;
530
+ background-color: transparent;
531
+ }
532
+
533
+ .annotationLayer .buttonWidgetAnnotation.checkBox :focus {
534
+ border: 2px solid var(--input-focus-border-color);
535
+ border-radius: 2px;
536
+ outline: var(--input-focus-outline);
537
+ }
538
+
539
+ .annotationLayer .buttonWidgetAnnotation.radioButton :focus {
540
+ border: 2px solid var(--input-focus-border-color);
541
+ outline: var(--input-focus-outline);
542
+ }
543
+
544
+ .annotationLayer .buttonWidgetAnnotation.checkBox input:checked::before,
545
+ .annotationLayer .buttonWidgetAnnotation.checkBox input:checked::after,
546
+ .annotationLayer .buttonWidgetAnnotation.radioButton input:checked::before {
547
+ background-color: CanvasText;
548
+ content: "";
549
+ display: block;
550
+ position: absolute;
551
+ }
552
+
553
+ .annotationLayer .buttonWidgetAnnotation.checkBox input:checked::before,
554
+ .annotationLayer .buttonWidgetAnnotation.checkBox input:checked::after {
555
+ height: 80%;
556
+ left: 45%;
557
+ width: 1px;
558
+ }
559
+
560
+ .annotationLayer .buttonWidgetAnnotation.checkBox input:checked::before {
561
+ transform: rotate(45deg);
562
+ }
563
+
564
+ .annotationLayer .buttonWidgetAnnotation.checkBox input:checked::after {
565
+ transform: rotate(-45deg);
566
+ }
567
+
568
+ .annotationLayer .buttonWidgetAnnotation.radioButton input:checked::before {
569
+ border-radius: 50%;
570
+ height: 50%;
571
+ left: 30%;
572
+ top: 20%;
573
+ width: 50%;
574
+ }
575
+
576
+ .annotationLayer .textWidgetAnnotation input.comb {
577
+ font-family: monospace;
578
+ padding-left: 2px;
579
+ padding-right: 0;
580
+ }
581
+
582
+ .annotationLayer .textWidgetAnnotation input.comb:focus {
583
+ /*
584
+ * Letter spacing is placed on the right side of each character. Hence, the
585
+ * letter spacing of the last character may be placed outside the visible
586
+ * area, causing horizontal scrolling. We avoid this by extending the width
587
+ * when the element has focus and revert this when it loses focus.
588
+ */
589
+ width: 103%;
590
+ }
591
+
592
+ .annotationLayer .buttonWidgetAnnotation:is(.checkBox, .radioButton) input {
593
+ appearance: none;
594
+ }
595
+
596
+ .annotationLayer .fileAttachmentAnnotation .popupTriggerArea {
597
+ height: 100%;
598
+ width: 100%;
599
+ }
600
+
601
+ .annotationLayer .popupAnnotation {
602
+ position: absolute;
603
+ font-size: calc(9px * var(--scale-factor));
604
+ pointer-events: none;
605
+ width: max-content;
606
+ max-width: 45%;
607
+ height: auto;
608
+ }
609
+
610
+ .annotationLayer .popup {
611
+ background-color: rgb(255 255 153);
612
+ box-shadow: 0 calc(2px * var(--scale-factor)) calc(5px * var(--scale-factor))
613
+ rgb(136 136 136);
614
+ border-radius: calc(2px * var(--scale-factor));
615
+ outline: 1.5px solid rgb(255 255 74);
616
+ padding: calc(6px * var(--scale-factor));
617
+ cursor: pointer;
618
+ font: message-box;
619
+ white-space: normal;
620
+ word-wrap: break-word;
621
+ pointer-events: auto;
622
+ }
623
+
624
+ .annotationLayer .popupAnnotation.focused .popup {
625
+ outline-width: 3px;
626
+ }
627
+
628
+ .annotationLayer .popup * {
629
+ font-size: calc(9px * var(--scale-factor));
630
+ }
631
+
632
+ .annotationLayer .popup > .header {
633
+ display: inline-block;
634
+ }
635
+
636
+ .annotationLayer .popup > .header h1 {
637
+ display: inline;
638
+ }
639
+
640
+ .annotationLayer .popup > .header .popupDate {
641
+ display: inline-block;
642
+ margin-left: calc(5px * var(--scale-factor));
643
+ width: fit-content;
644
+ }
645
+
646
+ .annotationLayer .popupContent {
647
+ border-top: 1px solid rgb(51 51 51);
648
+ margin-top: calc(2px * var(--scale-factor));
649
+ padding-top: calc(2px * var(--scale-factor));
650
+ }
651
+
652
+ .annotationLayer .richText > * {
653
+ white-space: pre-wrap;
654
+ font-size: calc(9px * var(--scale-factor));
655
+ }
656
+
657
+ .annotationLayer .popupTriggerArea {
658
+ cursor: pointer;
659
+ }
660
+
661
+ .annotationLayer section svg {
662
+ position: absolute;
663
+ width: 100%;
664
+ height: 100%;
665
+ top: 0;
666
+ left: 0;
667
+ }
668
+
669
+ .annotationLayer .annotationTextContent {
670
+ position: absolute;
671
+ width: 100%;
672
+ height: 100%;
673
+ opacity: 0;
674
+ color: transparent;
675
+ user-select: none;
676
+ pointer-events: none;
677
+ }
678
+
679
+ .annotationLayer .annotationTextContent span {
680
+ width: 100%;
681
+ display: inline-block;
682
+ }
683
+
684
+ .annotationLayer svg.quadrilateralsContainer {
685
+ contain: strict;
686
+ width: 0;
687
+ height: 0;
688
+ position: absolute;
689
+ top: 0;
690
+ left: 0;
691
+ z-index: -1;
692
+ }
693
+ `,Ec=async(r,e)=>{const t=devicePixelRatio,n=r.getViewport({scale:t}),i=document.createElement("canvas");i.height=n.height,i.width=n.width;const s=i.getContext("2d");await r.render({canvasContext:s,viewport:n}).promise;const o=await new Promise(d=>i.toBlob(d));if(e)return o;const c=document.createElement("div");c.classList.add("textLayer"),await pdfjsLib.renderTextLayer({textContentSource:await r.getTextContent(),container:c,viewport:n}).promise;const a=document.createElement("div");a.classList.add("annotationLayer"),await new pdfjsLib.AnnotationLayer({page:r,viewport:n,div:a}).render({annotations:await r.getAnnotations(),linkService:{getDestinationHash:d=>JSON.stringify(d),addLinkAttributes:(d,g)=>d.href=g}});const l=URL.createObjectURL(o);return URL.createObjectURL(new Blob([`
694
+ <!DOCTYPE html>
695
+ <meta charset="utf-8">
696
+ <style>
697
+ :root {
698
+ --scale-factor: ${t};
699
+ }
700
+ html, body {
701
+ margin: 0;
702
+ padding: 0;
703
+ }
704
+ ${Gh}
705
+ ${Yh}
706
+ </style>
707
+ <img src="${l}">
708
+ ${c.outerHTML}
709
+ ${a.outerHTML}
710
+ `],{type:"text/html"}))},Ac=r=>({label:r.title,href:JSON.stringify(r.dest),subitems:r.items.length?r.items.map(Ac):null}),Kh=Object.freeze(Object.defineProperty({__proto__:null,makePDF:async r=>{var c;const e=new Uint8Array(await r.arrayBuffer()),t=await pdfjsLib.getDocument({data:e}).promise,n={rendition:{layout:"pre-paginated"}},i=(c=await t.getMetadata())==null?void 0:c.info;n.metadata={title:i==null?void 0:i.Title,author:i==null?void 0:i.Author};const s=await t.getOutline();n.toc=s==null?void 0:s.map(Ac);const o=new Map;return n.sections=Array.from({length:t.numPages}).map((a,l)=>({id:l,load:async()=>{const h=o.get(l);if(h)return h;const d=await Ec(await t.getPage(l+1));return o.set(l,d),d},size:1e3})),n.isExternal=a=>/^\w+:/i.test(a),n.resolveHref=async a=>{const l=JSON.parse(a),h=typeof l=="string"?await t.getDestination(l):l;return{index:await t.getPageIndex(h[0])}},n.splitTOCHref=async a=>{const l=JSON.parse(a),h=typeof l=="string"?await t.getDestination(l):l;return[await t.getPageIndex(h[0]),null]},n.getTOCFragment=a=>a.documentElement,n.getCover=async()=>Ec(await t.getPage(1),!0),n}},Symbol.toStringTag,{value:"Module"})),un=r=>{if(!r)return"";const e=document.createElement("textarea");return e.innerHTML=r,e.value},we={XML:"application/xml",XHTML:"application/xhtml+xml",HTML:"text/html",CSS:"text/css",SVG:"image/svg+xml"},Zh={name:[0,32,"string"],type:[60,4,"string"],creator:[64,4,"string"],numRecords:[76,2,"uint"]},Jh={compression:[0,2,"uint"],numTextRecords:[8,2,"uint"],recordSize:[10,2,"uint"],encryption:[12,2,"uint"]},Qh={magic:[16,4,"string"],length:[20,4,"uint"],type:[24,4,"uint"],encoding:[28,4,"uint"],uid:[32,4,"uint"],version:[36,4,"uint"],titleOffset:[84,4,"uint"],titleLength:[88,4,"uint"],localeRegion:[94,1,"uint"],localeLanguage:[95,1,"uint"],resourceStart:[108,4,"uint"],huffcdic:[112,4,"uint"],numHuffcdic:[116,4,"uint"],exthFlag:[128,4,"uint"],trailingFlags:[240,4,"uint"],indx:[244,4,"uint"]},td={resourceStart:[108,4,"uint"],fdst:[192,4,"uint"],numFdst:[196,4,"uint"],frag:[248,4,"uint"],skel:[252,4,"uint"],guide:[260,4,"uint"]},ed={magic:[0,4,"string"],length:[4,4,"uint"],count:[8,4,"uint"]},Tc={magic:[0,4,"string"],length:[4,4,"uint"],type:[8,4,"uint"],idxt:[20,4,"uint"],numRecords:[24,4,"uint"],encoding:[28,4,"uint"],language:[32,4,"uint"],total:[36,4,"uint"],ordt:[40,4,"uint"],ligt:[44,4,"uint"],numLigt:[48,4,"uint"],numCncx:[52,4,"uint"]},nd={magic:[0,4,"string"],length:[4,4,"uint"],numControlBytes:[8,4,"uint"]},id={magic:[0,4,"string"],offset1:[8,4,"uint"],offset2:[12,4,"uint"]},rd={magic:[0,4,"string"],length:[4,4,"uint"],numEntries:[8,4,"uint"],codeLength:[12,4,"uint"]},sd={magic:[0,4,"string"],numEntries:[8,4,"uint"]},od={flags:[8,4,"uint"],dataStart:[12,4,"uint"],keyLength:[16,4,"uint"],keyStart:[20,4,"uint"]},ad={1252:"windows-1252",65001:"utf-8"},Lc={100:["creator","string",!0],101:["publisher"],103:["description"],104:["isbn"],105:["subject","string",!0],106:["date"],108:["contributor","string",!0],109:["rights"],110:["subjectCode","string",!0],112:["source","string",!0],113:["asin"],121:["boundary","uint"],122:["fixedLayout"],125:["numResources","uint"],126:["originalResolution"],127:["zeroGutter"],128:["zeroMargin"],129:["coverURI"],132:["regionMagnification"],201:["coverOffset","uint"],202:["thumbnailOffset","uint"],503:["title"],524:["language","string",!0],527:["pageProgressionDirection"]},cd={1:["ar","ar-SA","ar-IQ","ar-EG","ar-LY","ar-DZ","ar-MA","ar-TN","ar-OM","ar-YE","ar-SY","ar-JO","ar-LB","ar-KW","ar-AE","ar-BH","ar-QA"],2:["bg"],3:["ca"],4:["zh","zh-TW","zh-CN","zh-HK","zh-SG"],5:["cs"],6:["da"],7:["de","de-DE","de-CH","de-AT","de-LU","de-LI"],8:["el"],9:["en","en-US","en-GB","en-AU","en-CA","en-NZ","en-IE","en-ZA","en-JM",null,"en-BZ","en-TT","en-ZW","en-PH"],10:["es","es-ES","es-MX",null,"es-GT","es-CR","es-PA","es-DO","es-VE","es-CO","es-PE","es-AR","es-EC","es-CL","es-UY","es-PY","es-BO","es-SV","es-HN","es-NI","es-PR"],11:["fi"],12:["fr","fr-FR","fr-BE","fr-CA","fr-CH","fr-LU","fr-MC"],13:["he"],14:["hu"],15:["is"],16:["it","it-IT","it-CH"],17:["ja"],18:["ko"],19:["nl","nl-NL","nl-BE"],20:["no","nb","nn"],21:["pl"],22:["pt","pt-BR","pt-PT"],23:["rm"],24:["ro"],25:["ru"],26:["hr",null,"sr"],27:["sk"],28:["sq"],29:["sv","sv-SE","sv-FI"],30:["th"],31:["tr"],32:["ur"],33:["id"],34:["uk"],35:["be"],36:["sl"],37:["et"],38:["lv"],39:["lt"],41:["fa"],42:["vi"],43:["hy"],44:["az"],45:["eu"],46:["hsb"],47:["mk"],48:["st"],49:["ts"],50:["tn"],52:["xh"],53:["zu"],54:["af"],55:["ka"],56:["fo"],57:["hi"],58:["mt"],59:["se"],62:["ms"],63:["kk"],65:["sw"],67:["uz",null,"uz-UZ"],68:["tt"],69:["bn"],70:["pa"],71:["gu"],72:["or"],73:["ta"],74:["te"],75:["kn"],76:["ml"],77:["as"],78:["mr"],79:["sa"],82:["cy","cy-GB"],83:["gl","gl-ES"],87:["kok"],97:["ne"],98:["fy"]},Ur=(r,e)=>{const t=new r.constructor(r.length+e.length);return t.set(r),t.set(e,r.length),t},Cc=(r,e,t)=>{const n=new r.constructor(r.length+e.length+t.length);return n.set(r),n.set(e,r.length),n.set(t,r.length+e.length),n},ld=new TextDecoder,Ai=r=>ld.decode(r),kt=r=>{if(!r)return;const e=r.byteLength,t=e===4?"getUint32":e===2?"getUint16":"getUint8";return new DataView(r)[t](0)},Ut=(r,e)=>Object.fromEntries(Array.from(Object.entries(r)).map(([t,[n,i,s]])=>[t,(s==="string"?Ai:kt)(e.slice(n,n+i))])),$s=r=>new TextDecoder(ad[r]),jr=(r,e=0)=>{let t=0,n=0;for(const i of r.subarray(e,e+4))if(t=t<<7|(i&127)>>>0,n++,i&128)break;return{value:t,length:n}},ud=r=>{let e=0;for(const t of r.subarray(-4))t&128&&(e=0),e=e<<7|t&127;return e},Rc=r=>{let e=0;for(;r>0;r=r>>1)(r&1)===1&&e++;return e},hd=r=>{let e=0;for(;!(r&1);)r=r>>1,e++;return e},dd=r=>{let e=[];for(let t=0;t<r.length;t++){const n=r[t];if(n===0)e.push(0);else if(n<=8)for(const i of r.subarray(t+1,(t+=n)+1))e.push(i);else if(n<=127)e.push(n);else if(n<=191){const i=n<<8|r[t+++1],s=(i&16383)>>>3,o=(i&7)+3;for(let c=0;c<o;c++)e.push(e[e.length-s])}else e.push(32,n^128)}return Uint8Array.from(e)},fd=(r,e)=>{const t=e>>3,n=e+32,i=n>>3;let s=0n;for(let o=t;o<=i;o++)s=s<<8n|BigInt(r[o]??0);return s>>8n-BigInt(n&7)&0xffffffffn},pd=async(r,e)=>{const t=await e(r.huffcdic),{magic:n,offset1:i,offset2:s}=Ut(id,t);if(n!=="HUFF")throw new Error("Invalid HUFF record");const o=Array.from({length:256},(h,d)=>i+d*4).map(h=>kt(t.slice(h,h+4))).map(h=>[h&128,h&31,h>>>8]),c=[null].concat(Array.from({length:32},(h,d)=>s+d*8).map(h=>[kt(t.slice(h,h+4)),kt(t.slice(h+4,h+8))])),a=[];for(let h=1;h<r.numHuffcdic;h++){const d=await e(r.huffcdic+h),g=Ut(rd,d);if(g.magic!=="CDIC")throw new Error("Invalid CDIC record");const b=Math.min(1<<g.codeLength,g.numEntries-a.length),f=d.slice(g.length);for(let w=0;w<b;w++){const p=kt(f.slice(w*2,w*2+2)),m=kt(f.slice(p,p+2)),y=m&32767,S=m&32768,_=new Uint8Array(f.slice(p+2,p+2+y));a.push([_,S])}}const l=h=>{let d=new Uint8Array;const g=h.byteLength*8;for(let b=0;b<g;){const f=Number(fd(h,b));let[w,p,m]=o[f>>>24];if(!w){for(;f>>>32-p<c[p][0];)p+=1;m=c[p][1]}if((b+=p)>g)break;const y=m-(f>>>32-p);let[S,_]=a[y];_||(S=l(S),a[y]=[S,!0]),d=Ur(d,S)}return d};return l},$r=async(r,e)=>{const t=await e(r),n=Ut(Tc,t);if(n.magic!=="INDX")throw new Error("Invalid INDX record");const i=$s(n.encoding),s=t.slice(n.length),o=Ut(nd,s);if(o.magic!=="TAGX")throw new Error("Invalid TAGX section");const c=(o.length-12)/4,a=Array.from({length:c},(g,b)=>new Uint8Array(s.slice(12+b*4,12+b*4+4))),l={};let h=0;for(let g=0;g<n.numCncx;g++){const b=await e(r+n.numRecords+g+1),f=new Uint8Array(b);for(let w=0;w<f.byteLength;){const p=w,{value:m,length:y}=jr(f,w);w+=y;const S=b.slice(w,w+m);w+=m,l[h+p]=i.decode(S)}h+=65536}const d=[];for(let g=0;g<n.numRecords;g++){const b=await e(r+1+g),f=new Uint8Array(b),w=Ut(Tc,b);if(w.magic!=="INDX")throw new Error("Invalid INDX record");for(let p=0;p<w.numRecords;p++){const m=w.idxt+4+2*p,y=kt(b.slice(m,m+2)),S=kt(b.slice(y,y+1)),_=Ai(b.slice(y+1,y+1+S)),k=[],T=y+1+S;let x=0,I=T+o.numControlBytes;for(const[P,A,L,z]of a){if(z&1){x++;continue}const B=T+x,U=kt(b.slice(B,B+1))&L;if(U===L)if(Rc(L)>1){const{value:M,length:j}=jr(f,I);k.push([P,null,M,A]),I+=j}else k.push([P,1,null,A]);else k.push([P,U>>hd(L),null,A])}const F={};for(const[P,A,L,z]of k){const B=[];if(A!=null)for(let U=0;U<A*z;U++){const{value:M,length:j}=jr(f,I);B.push(M),I+=j}else{let U=0;for(;U<L;){const{value:M,length:j}=jr(f,I);B.push(M),I+=j,U+=j}}F[P]=B}d.push({name:_,tagMap:F})}}return{table:d,cncx:l}},gd=async(r,e)=>{const{table:t,cncx:n}=await $r(r,e),i=t.map(({tagMap:o},c)=>{var a,l,h,d,g,b;return{index:c,offset:(a=o[1])==null?void 0:a[0],size:(l=o[2])==null?void 0:l[0],label:n[o[3]]??"",headingLevel:(h=o[4])==null?void 0:h[0],pos:o[6],parent:(d=o[21])==null?void 0:d[0],firstChild:(g=o[22])==null?void 0:g[0],lastChild:(b=o[23])==null?void 0:b[0]}}),s=o=>(o.firstChild==null||(o.children=i.filter(c=>c.parent===o.index).map(s)),o);return i.filter(o=>o.headingLevel===0).map(s)},md=(r,e)=>{const{magic:t,count:n}=Ut(ed,r);if(t!=="EXTH")throw new Error("Invalid EXTH header");const i=$s(e),s={};let o=12;for(let c=0;c<n;c++){const a=kt(r.slice(o,o+4)),l=kt(r.slice(o+4,o+8));if(a in Lc){const[h,d,g]=Lc[a],b=r.slice(o+8,o+l),f=d==="uint"?kt(b):i.decode(b);g?(s[h]??(s[h]=[]),s[h].push(f)):s[h]=f}o+=l}return s},bd=async(r,e)=>{const{flags:t,dataStart:n,keyLength:i,keyStart:s}=Ut(od,r),o=new Uint8Array(r.slice(n));if(t&2){const a=i===16?1024:1040,l=new Uint8Array(r.slice(s,s+i)),h=Math.min(a,o.length);for(var c=0;c<h;c++)o[c]=o[c]^l[c%l.length]}if(t&1)try{return await e(o)}catch(a){console.warn(a),console.warn("Failed to decompress font")}return o},wd=async r=>Ai(await r.slice(60,68).arrayBuffer())==="BOOKMOBI";class yd{constructor(){E(this,ei,void 0);E(this,ni,void 0);It(this,"pdb")}async open(e){R(this,ei,e);const t=Ut(Zh,await e.slice(0,78).arrayBuffer());this.pdb=t;const n=await e.slice(78,78+t.numRecords*8).arrayBuffer();R(this,ni,Array.from({length:t.numRecords},(i,s)=>kt(n.slice(s*8,s*8+4))).map((i,s,o)=>[i,o[s+1]]))}loadRecord(e){const t=u(this,ni)[e];if(!t)throw new RangeError("Record index out of bounds");return u(this,ei).slice(...t).arrayBuffer()}async loadMagic(e){const t=u(this,ni)[e][0];return Ai(await u(this,ei).slice(t,t+4).arrayBuffer())}}ei=new WeakMap,ni=new WeakMap;class vd extends yd{constructor({unzlib:t}){super();E(this,rr);E(this,rs);E(this,ii,0);E(this,tr,void 0);E(this,er,void 0);E(this,nr,void 0);E(this,ri,void 0);E(this,ir,void 0);this.unzlib=t}async open(t){var i;await super.open(t),this.headers=C(this,rr,go).call(this,await super.loadRecord(0)),R(this,tr,this.headers.mobi.resourceStart);let n=this.headers.mobi.version>=8;if(!n){const s=(i=this.headers.exth)==null?void 0:i.boundary;if(s<4294967295)try{this.headers=C(this,rr,go).call(this,await super.loadRecord(s)),R(this,ii,s),n=!0}catch(o){console.warn(o),console.warn("Failed to open KF8; falling back to MOBI")}}return await C(this,rs,ml).call(this),n?new Ld(this).init():new Sd(this).init()}decode(...t){return u(this,er).decode(...t)}encode(...t){return u(this,nr).encode(...t)}loadRecord(t){return super.loadRecord(u(this,ii)+t)}loadMagic(t){return super.loadMagic(u(this,ii)+t)}loadText(t){return this.loadRecord(t+1).then(n=>new Uint8Array(n)).then(u(this,ir)).then(u(this,ri))}async loadResource(t){const n=await super.loadRecord(u(this,tr)+t),i=Ai(n.slice(0,4));return i==="FONT"?bd(n,this.unzlib):i==="VIDE"||i==="AUDI"?n.slice(12):n}getNCX(){const t=this.headers.mobi.indx;if(t<4294967295)return gd(t,this.loadRecord.bind(this))}getMetadata(){var i,s;const{mobi:t,exth:n}=this.headers;return{identifier:t.uid.toString(),title:un((n==null?void 0:n.title)||this.decode(t.title)),author:(i=n==null?void 0:n.creator)==null?void 0:i.map(un),publisher:un(n==null?void 0:n.publisher),language:(n==null?void 0:n.language)??t.language,published:n==null?void 0:n.date,description:un(n==null?void 0:n.description),subject:(s=n==null?void 0:n.subject)==null?void 0:s.map(un),rights:un(n==null?void 0:n.rights)}}async getCover(){const{exth:t}=this.headers,n=(t==null?void 0:t.coverOffset)<4294967295?t==null?void 0:t.coverOffset:(t==null?void 0:t.thumbnailOffset)<4294967295?t==null?void 0:t.thumbnailOffset:null;if(n!=null){const i=await this.loadResource(n);return new Blob([i])}}}ii=new WeakMap,tr=new WeakMap,er=new WeakMap,nr=new WeakMap,ri=new WeakMap,ir=new WeakMap,rr=new WeakSet,go=function(t){const n=Ut(Jh,t),i=Ut(Qh,t);if(i.magic!=="MOBI")throw new Error("Missing MOBI header");const{titleOffset:s,titleLength:o,localeLanguage:c,localeRegion:a}=i;i.title=t.slice(s,s+o);const l=cd[c];i.language=(l==null?void 0:l[a>>2])??(l==null?void 0:l[0]);const h=i.exthFlag&64?md(t.slice(i.length+16),i.encoding):null,d=i.version>=8?Ut(td,t):null;return{palmdoc:n,mobi:i,exth:h,kf8:d}},rs=new WeakSet,ml=async function(){const{palmdoc:t,mobi:n}=this.headers;R(this,er,$s(n.encoding)),R(this,nr,new TextEncoder);const{compression:i}=t;if(R(this,ri,i===1?a=>a:i===2?dd:i===17480?await pd(n,this.loadRecord.bind(this)):null),!u(this,ri))throw new Error("Unknown compression type");const{trailingFlags:s}=n,o=s&1,c=Rc(s>>>1);R(this,ir,a=>{for(let l=0;l<c;l++){const h=ud(a);a=a.subarray(0,-h)}if(o){const l=(a[a.length-1]&3)+1;a=a.subarray(0,-l)}return a})};const Ic=/<\s*(?:mbp:)?pagebreak[^>]*>/gi,xd=/<[^<>]+filepos=['"]{0,1}(\d+)[^<>]*>/gi,_d=r=>{let e=0;for(;r;){const t=r.parentElement;if(t){const n=t.tagName.toLowerCase();n==="p"?e+=1.5:n==="blockquote"&&(e+=2)}r=t}return e};class Sd{constructor(e){It(this,"parser",new DOMParser);It(this,"serializer",new XMLSerializer);E(this,Sn,new Map);E(this,si,new Map);E(this,kn,new Map);E(this,Qe,void 0);E(this,sr,[]);E(this,or,we.HTML);this.mobi=e}async init(){var n;let e=new Uint8Array;for(let i=0;i<this.mobi.headers.palmdoc.numTextRecords;i++)e=Ur(e,await this.mobi.loadText(i));const t=Array.from(new Uint8Array(e),i=>String.fromCharCode(i)).join("");R(this,Qe,[0].concat(Array.from(t.matchAll(Ic),i=>i.index)).map((i,s,o)=>t.slice(i,o[s+1])).map(i=>Uint8Array.from(i,s=>s.charCodeAt(0))).map(i=>({book:this,raw:i})).reduce((i,s)=>{const o=i[i.length-1];return s.start=(o==null?void 0:o.end)??0,s.end=s.start+s.raw.byteLength,i.concat(s)},[])),this.sections=u(this,Qe).map((i,s)=>({id:s,load:()=>this.loadSection(i),createDocument:()=>this.createDocument(i),size:i.end-i.start}));try{this.landmarks=await this.getGuide();const i=(n=this.landmarks.find(({type:s})=>s==null?void 0:s.includes("toc")))==null?void 0:n.href;if(i){const{index:s}=this.resolveHref(i),o=await this.sections[s].createDocument();let c,a=0,l=0;const h=new Map,d=new Map;this.toc=Array.from(o.querySelectorAll("a[filepos]")).reduce((g,b)=>{var m;const f=_d(b),w={label:(m=b.innerText)==null?void 0:m.trim(),href:`filepos:${b.getAttribute("filepos")}`},p=f>l?a+1:f===l?a:h.get(f)??Math.max(0,a-1);if(p>a)c?(c.subitems??(c.subitems=[]),c.subitems.push(w),d.set(p,c)):g.push(w);else{const y=d.get(p);y?y.subitems.push(w):g.push(w)}return c=w,a=p,l=f,h.set(f,p),g},[])}}catch(i){console.warn(i)}return R(this,sr,[...new Set(Array.from(t.matchAll(xd),i=>i[1]))].map(i=>({filepos:i,number:Number(i)})).sort((i,s)=>i.number-s.number)),this.metadata=this.mobi.getMetadata(),this.getCover=this.mobi.getCover.bind(this.mobi),this}async getGuide(){const e=await this.createDocument(u(this,Qe)[0]);return Array.from(e.getElementsByTagName("reference"),t=>{var n;return{label:t.getAttribute("title"),type:(n=t.getAttribute("type"))==null?void 0:n.split(/\s/),href:`filepos:${t.getAttribute("filepos")}`}})}async loadResource(e){if(u(this,Sn).has(e))return u(this,Sn).get(e);const t=await this.mobi.loadResource(e),n=URL.createObjectURL(new Blob([t]));return u(this,Sn).set(e,n),n}async loadRecindex(e){return this.loadResource(Number(e)-1)}async replaceResources(e){for(const t of e.querySelectorAll("img[recindex]")){const n=t.getAttribute("recindex");try{t.src=await this.loadRecindex(n)}catch{console.warn(`Failed to load image ${n}`)}}for(const t of e.querySelectorAll("[mediarecindex]")){const n=t.getAttribute("mediarecindex"),i=t.getAttribute("recindex");try{t.src=await this.loadRecindex(n),i&&(t.poster=await this.loadRecindex(i))}catch{console.warn(`Failed to load media ${n}`)}}for(const t of e.querySelectorAll("[filepos]")){const n=t.getAttribute("filepos");t.href=`filepos:${n}`}}async loadText(e){if(u(this,si).has(e))return u(this,si).get(e);const{raw:t}=e,n=u(this,sr).filter(({number:o})=>o>=e.start&&o<e.end).map(o=>({...o,offset:o.number-e.start}));let i=t;n.length&&(i=t.subarray(0,n[0].offset),n.forEach(({filepos:o,offset:c},a)=>{const l=n[a+1],h=this.mobi.encode(`<a id="filepos${o}"></a>`);i=Cc(i,h,t.subarray(c,l==null?void 0:l.offset))}));const s=this.mobi.decode(i).replaceAll(Ic,"");return u(this,si).set(e,s),s}async createDocument(e){const t=await this.loadText(e);return this.parser.parseFromString(t,u(this,or))}async loadSection(e){if(u(this,kn).has(e))return u(this,kn).get(e);const t=await this.createDocument(e),n=t.createElement("style");t.head.append(n),n.append(t.createTextNode(`blockquote {
711
+ margin-block-start: 0;
712
+ margin-block-end: 0;
713
+ margin-inline-start: 1em;
714
+ margin-inline-end: 0;
715
+ }`)),await this.replaceResources(t);const i=this.serializer.serializeToString(t),s=URL.createObjectURL(new Blob([i],{type:u(this,or)}));return u(this,kn).set(e,s),s}resolveHref(e){const t=e.match(/filepos:(.*)/)[1],n=Number(t);return{index:u(this,Qe).findIndex(o=>o.end>n),anchor:o=>o.getElementById(`filepos${t}`)}}splitTOCHref(e){const t=e.match(/filepos:(.*)/)[1],n=Number(t);return[u(this,Qe).findIndex(s=>s.end>n),`filepos${t}`]}getTOCFragment(e,t){return e.getElementById(t)}isExternal(e){return/^(?!blob|filepos)\w+:/i.test(e)}destroy(){for(const e of u(this,Sn).values())URL.revokeObjectURL(e);for(const e of u(this,kn).values())URL.revokeObjectURL(e)}}Sn=new WeakMap,si=new WeakMap,kn=new WeakMap,Qe=new WeakMap,sr=new WeakMap,or=new WeakMap;const Mc=/kindle:(flow|embed):(\w+)(?:\?mime=(\w+\/[-+.\w]+))?/,kd=/kindle:pos:fid:(\w+):off:(\w+)/,Ed=r=>{const[e,t,n]=r.match(Mc).slice(1);return{resourceType:e,id:parseInt(t,32),type:n}},zc=r=>{const[e,t]=r.match(kd).slice(1);return{fid:parseInt(e,32),off:parseInt(t,32)}},Oc=(r=0,e=0)=>`kindle:pos:fid:${r.toString(32).toUpperCase().padStart(4,"0")}:off:${e.toString(32).toUpperCase().padStart(10,"0")}`,Pc=r=>{const e=r.match(/\s(id|name|aid)\s*=\s*['"]([^'"]*)['"]/i);if(!e)return;const[,t,n]=e;return`[${t}="${CSS.escape(n)}"]`},Ad=async(r,e,t)=>{const n=[];r.replace(e,(...s)=>(n.push(s),null));const i=[];for(const s of n)i.push(await t(...s));return r.replace(e,()=>i.shift())},Td=r=>{for(const e of r){if(e==="page-spread-left"||e==="rendition:page-spread-left")return"left";if(e==="page-spread-right"||e==="rendition:page-spread-right")return"right";if(e==="rendition:page-spread-center")return"center"}};class Ld{constructor(e){E(this,cr);It(this,"parser",new DOMParser);It(this,"serializer",new XMLSerializer);E(this,de,new Map);E(this,oi,new Map);E(this,En,new Map);E(this,An,{});E(this,Tn,void 0);E(this,tn,void 0);E(this,en,new Uint8Array);E(this,Ie,new Uint8Array);E(this,ss,-1);E(this,os,-1);E(this,nn,we.XHTML);E(this,ar,new Map);this.mobi=e}async init(){var l,h,d,g;const e=this.mobi.loadRecord.bind(this.mobi),{kf8:t}=this.mobi.headers;try{const b=await e(t.fdst),f=Ut(sd,b);if(f.magic!=="FDST")throw new Error("Missing FDST record");const w=Array.from({length:f.numEntries},(p,m)=>12+m*8).map(p=>[kt(b.slice(p,p+4)),kt(b.slice(p+4,p+8))]);u(this,An).fdstTable=w,R(this,tn,w[w.length-1][1])}catch{}const n=(await $r(t.skel,e)).table.map(({name:b,tagMap:f},w)=>({index:w,name:b,numFrag:f[1][0],offset:f[6][0],length:f[6][1]})),i=await $r(t.frag,e),s=i.table.map(({name:b,tagMap:f})=>({insertOffset:parseInt(b),selector:i.cncx[f[2][0]],index:f[4][0],offset:f[6][0],length:f[6][1]}));u(this,An).skelTable=n,u(this,An).fragTable=s,R(this,Tn,n.reduce((b,f)=>{const w=b[b.length-1],p=(w==null?void 0:w.fragEnd)??0,m=p+f.numFrag,y=s.slice(p,m),S=f.length+y.map(k=>k.length).reduce((k,T)=>k+T),_=((w==null?void 0:w.totalLength)??0)+S;return b.concat({skel:f,frags:y,fragEnd:m,length:S,totalLength:_})},[]));const o=await this.getResourcesByMagic(["RESC","PAGE"]),c=new Map;if(o.RESC){const b=await this.mobi.loadRecord(o.RESC),f=this.mobi.decode(b.slice(16)).replace(/\0/g,""),w=f.search(/\?>/),p=`<package>${f.slice(w)}</package>`,m=this.parser.parseFromString(p,we.XML);for(const y of m.querySelectorAll("spine > itemref")){const S=parseInt(y.getAttribute("skelid"));c.set(S,Td(((l=y.getAttribute("properties"))==null?void 0:l.split(" "))??[]))}}this.sections=u(this,Tn).map((b,f)=>b.frags.length?{id:f,load:()=>this.loadSection(b),createDocument:()=>this.createDocument(b),size:b.length,pageSpread:c.get(f)}:{linear:"no"});try{const b=await this.mobi.getNCX(),f=({label:w,pos:p,children:m})=>{const[y,S]=p,_=Oc(y,S),k=u(this,oi).get(y);return k?k.push(S):u(this,oi).set(y,[S]),{label:un(w),href:_,subitems:m==null?void 0:m.map(f)}};this.toc=b==null?void 0:b.map(f),this.landmarks=await this.getGuide()}catch(b){console.warn(b)}const{exth:a}=this.mobi.headers;return this.dir=a.pageProgressionDirection,this.rendition={layout:a.fixedLayout==="true"?"pre-paginated":"reflowable",viewport:Object.fromEntries(((g=(d=(h=a.originalResolution)==null?void 0:h.split("x"))==null?void 0:d.slice(0,2))==null?void 0:g.map((b,f)=>[f?"height":"width",b]))??[])},this.metadata=this.mobi.getMetadata(),this.getCover=this.mobi.getCover.bind(this.mobi),this}async getResourcesByMagic(e){const t={},n=this.mobi.headers.kf8.resourceStart,i=this.mobi.pdb.numRecords;for(let s=n;s<i;s++)try{const o=await this.mobi.loadMagic(s),c=e.find(a=>a===o);c&&(t[c]=s)}catch{}return t}async getGuide(){const e=this.mobi.headers.kf8.guide;if(e<4294967295){const t=this.mobi.loadRecord.bind(this.mobi),{table:n,cncx:i}=await $r(e,t);return n.map(({name:s,tagMap:o})=>{var c,a;return{label:i[o[1][0]]??"",type:s==null?void 0:s.split(/\s/),href:Oc(((c=o[6])==null?void 0:c[0])??((a=o[3])==null?void 0:a[0]))}})}}async loadResourceBlob(e){var a;const{resourceType:t,id:n,type:i}=Ed(e),s=t==="flow"?await this.loadFlow(n):await this.mobi.loadResource(n-1),o=[we.XHTML,we.HTML,we.CSS,we.SVG].includes(i)?await this.replaceResources(this.mobi.decode(s)):s,c=i===we.SVG?this.parser.parseFromString(o,i):null;return[new Blob([o],{type:i}),(a=c==null?void 0:c.getElementsByTagNameNS("http://www.w3.org/2000/svg","image"))!=null&&a.length?c.documentElement:null]}async loadResource(e){if(u(this,de).has(e))return u(this,de).get(e);const[t,n]=await this.loadResourceBlob(e),i=n?e:URL.createObjectURL(t);return n&&u(this,ar).set(i,n),u(this,de).set(e,i),i}replaceResources(e){const t=new RegExp(Mc,"g");return Ad(e,t,this.loadResource.bind(this))}async loadRaw(e,t){const n=t-u(this,en).length,i=u(this,tn)==null?1/0:u(this,tn)-u(this,Ie).length-e;if(n<0||n<i){for(;u(this,en).length<t;){const o=++hr(this,ss)._,c=await this.mobi.loadText(o);R(this,en,Ur(u(this,en),c))}return u(this,en).slice(e,t)}for(;u(this,tn)-u(this,Ie).length>e;){const o=this.mobi.headers.palmdoc.numTextRecords-1-++hr(this,os)._,c=await this.mobi.loadText(o);R(this,Ie,Ur(c,u(this,Ie)))}const s=u(this,tn)-u(this,Ie).length;return u(this,Ie).slice(e-s,t-s)}loadFlow(e){if(e<4294967295)return this.loadRaw(...u(this,An).fdstTable[e])}async loadText(e){const{skel:t,frags:n,length:i}=e,s=await this.loadRaw(t.offset,t.offset+i);let o=s.slice(0,t.length);for(const c of n){const a=c.insertOffset-t.offset,l=t.length+c.offset,h=s.slice(l,l+c.length);o=Cc(o.slice(0,a),h,o.slice(a));const d=u(this,oi).get(c.index);if(d)for(const g of d){const b=this.mobi.decode(h).slice(g),f=Pc(b);C(this,cr,mo).call(this,c.index,g,f)}}return this.mobi.decode(o)}async createDocument(e){const t=await this.loadText(e);return this.parser.parseFromString(t,u(this,nn))}async loadSection(e){if(u(this,de).has(e))return u(this,de).get(e);const t=await this.loadText(e),n=await this.replaceResources(t);let i=this.parser.parseFromString(n,u(this,nn));i.querySelector("parsererror")&&(R(this,nn,we.HTML),i=this.parser.parseFromString(n,u(this,nn)));for(const[o,c]of u(this,ar))for(const a of i.querySelectorAll(`img[src="${o}"]`))a.replaceWith(c);const s=URL.createObjectURL(new Blob([this.serializer.serializeToString(i)],{type:u(this,nn)}));return u(this,de).set(e,s),s}getIndexByFID(e){return u(this,Tn).findIndex(t=>t.frags.some(n=>n.index===e))}async resolveHref(e){var f;const{fid:t,off:n}=zc(e),i=this.getIndexByFID(t);if(i<0)return;const s=(f=u(this,En).get(t))==null?void 0:f.get(n);if(s)return{index:i,anchor:w=>w.querySelector(s)};const{skel:o,frags:c}=u(this,Tn)[i],a=c.find(w=>w.index===t),l=o.offset+o.length+a.offset,h=await this.loadRaw(l,l+a.length),d=this.mobi.decode(h).slice(n),g=Pc(d);return C(this,cr,mo).call(this,t,n,g),{index:i,anchor:w=>w.querySelector(g)}}splitTOCHref(e){const t=zc(e);return[this.getIndexByFID(t.fid),t]}getTOCFragment(e,{fid:t,off:n}){var s;const i=(s=u(this,En).get(t))==null?void 0:s.get(n);return e.querySelector(i)}isExternal(e){return/^(?!blob|kindle)\w+:/i.test(e)}destroy(){for(const e of u(this,de).values())URL.revokeObjectURL(e)}}de=new WeakMap,oi=new WeakMap,En=new WeakMap,An=new WeakMap,Tn=new WeakMap,tn=new WeakMap,en=new WeakMap,Ie=new WeakMap,ss=new WeakMap,os=new WeakMap,nn=new WeakMap,ar=new WeakMap,cr=new WeakSet,mo=function(e,t,n){const i=u(this,En).get(e);if(i)i.set(t,n);else{const s=new Map;u(this,En).set(e,s),s.set(t,n)}};const Cd=Object.freeze(Object.defineProperty({__proto__:null,MOBI:vd,isMOBI:wd},Symbol.toStringTag,{value:"Module"}));var jt=Uint8Array,hn=Uint16Array,Nc=Uint32Array,Fc=new jt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Bc=new jt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Rd=new jt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Dc=function(r,e){for(var t=new hn(31),n=0;n<31;++n)t[n]=e+=1<<r[n-1];var i=new Nc(t[30]);for(n=1;n<30;++n)for(var s=t[n];s<t[n+1];++s)i[s]=s-t[n]<<5|n;return[t,i]},Uc=Dc(Fc,2),jc=Uc[0],Id=Uc[1];jc[28]=258,Id[258]=28;for(var Md=Dc(Bc,0)[0],Ws=new hn(32768),nt=0;nt<32768;++nt){var dn=(43690&nt)>>>1|(21845&nt)<<1;dn=(61680&(dn=(52428&dn)>>>2|(13107&dn)<<2))>>>4|(3855&dn)<<4,Ws[nt]=((65280&dn)>>>8|(255&dn)<<8)>>>1}var Ti=function(r,e,t){for(var n=r.length,i=0,s=new hn(e);i<n;++i)r[i]&&++s[r[i]-1];var o,c=new hn(e);for(i=0;i<e;++i)c[i]=c[i-1]+s[i-1]<<1;if(t){o=new hn(1<<e);var a=15-e;for(i=0;i<n;++i)if(r[i])for(var l=i<<4|r[i],h=e-r[i],d=c[r[i]-1]++<<h,g=d|(1<<h)-1;d<=g;++d)o[Ws[d]>>>a]=l}else for(o=new hn(n),i=0;i<n;++i)r[i]&&(o[i]=Ws[c[r[i]-1]++]>>>15-r[i]);return o},Li=new jt(288);for(nt=0;nt<144;++nt)Li[nt]=8;for(nt=144;nt<256;++nt)Li[nt]=9;for(nt=256;nt<280;++nt)Li[nt]=7;for(nt=280;nt<288;++nt)Li[nt]=8;var $c=new jt(32);for(nt=0;nt<32;++nt)$c[nt]=5;var zd=Ti(Li,9,1),Od=Ti($c,5,1),Hs=function(r){for(var e=r[0],t=1;t<r.length;++t)r[t]>e&&(e=r[t]);return e},Gt=function(r,e,t){var n=e/8|0;return(r[n]|r[n+1]<<8)>>(7&e)&t},Vs=function(r,e){var t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(7&e)},Pd=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],se=function(r,e,t){var n=new Error(e||Pd[r]);if(n.code=r,Error.captureStackTrace&&Error.captureStackTrace(n,se),!t)throw n;return n},Nd=function(r,e,t){var n=r.length;if(!n||t&&t.f&&!t.l)return e||new jt(0);var i=!e||t,s=!t||t.i;t||(t={}),e||(e=new jt(3*n));var o=function(mt){var bt=e.length;if(mt>bt){var lt=new jt(Math.max(2*bt,mt));lt.set(e),e=lt}},c=t.f||0,a=t.p||0,l=t.b||0,h=t.l,d=t.d,g=t.m,b=t.n,f=8*n;do{if(!h){c=Gt(r,a,1);var w=Gt(r,a+1,3);if(a+=3,!w){var p=r[(A=4+((a+7)/8|0))-4]|r[A-3]<<8,m=A+p;if(m>n){s&&se(0);break}i&&o(l+p),e.set(r.subarray(A,m),l),t.b=l+=p,t.p=a=8*m,t.f=c;continue}if(w==1)h=zd,d=Od,g=9,b=5;else if(w==2){var y=Gt(r,a,31)+257,S=Gt(r,a+10,15)+4,_=y+Gt(r,a+5,31)+1;a+=14;for(var k=new jt(_),T=new jt(19),x=0;x<S;++x)T[Rd[x]]=Gt(r,a+3*x,7);a+=3*S;var I=Hs(T),F=(1<<I)-1,P=Ti(T,I,1);for(x=0;x<_;){var A,L=P[Gt(r,a,F)];if(a+=15&L,(A=L>>>4)<16)k[x++]=A;else{var z=0,B=0;for(A==16?(B=3+Gt(r,a,3),a+=2,z=k[x-1]):A==17?(B=3+Gt(r,a,7),a+=3):A==18&&(B=11+Gt(r,a,127),a+=7);B--;)k[x++]=z}}var U=k.subarray(0,y),M=k.subarray(y);g=Hs(U),b=Hs(M),h=Ti(U,g,1),d=Ti(M,b,1)}else se(1);if(a>f){s&&se(0);break}}i&&o(l+131072);for(var j=(1<<g)-1,pt=(1<<b)-1,ot=a;;ot=a){var D=(z=h[Vs(r,a)&j])>>>4;if((a+=15&z)>f){s&&se(0);break}if(z||se(2),D<256)e[l++]=D;else{if(D==256){ot=a,h=null;break}var Q=D-254;if(D>264){var H=Fc[x=D-257];Q=Gt(r,a,(1<<H)-1)+jc[x],a+=H}var X=d[Vs(r,a)&pt],fe=X>>>4;if(X||se(3),a+=15&X,M=Md[fe],fe>3&&(H=Bc[fe],M+=Vs(r,a)&(1<<H)-1,a+=H),a>f){s&&se(0);break}i&&o(l+131072);for(var Me=l+Q;l<Me;l+=4)e[l]=e[l-M],e[l+1]=e[l+1-M],e[l+2]=e[l+2-M],e[l+3]=e[l+3-M];l=Me}}t.l=h,t.p=ot,t.b=l,t.f=c,h&&(c=1,t.m=g,t.d=d,t.n=b)}while(!c);return l==e.length?e:function(mt,bt,lt){(bt==null||bt<0)&&(bt=0),(lt==null||lt>mt.length)&&(lt=mt.length);var Nt=new(mt.BYTES_PER_ELEMENT==2?hn:mt.BYTES_PER_ELEMENT==4?Nc:jt)(lt-bt);return Nt.set(mt.subarray(bt,lt)),Nt}(e,0,l)},Fd=new jt(0);function Bd(r,e){return Nd((((15&(t=r)[0])!=8||t[0]>>>4>7||(t[0]<<8|t[1])%31)&&se(6,"invalid zlib data"),32&t[1]&&se(6,"invalid zlib data: preset dictionaries not supported"),r.subarray(2,-4)),e);var t}var Dd=typeof TextDecoder<"u"&&new TextDecoder;try{Dd.decode(Fd,{stream:!0})}catch{}const Ud=Object.freeze(Object.defineProperty({__proto__:null,unzlibSync:Bd},Symbol.toStringTag,{value:"Module"}));q.BookView=Oo,q.ReactReader=No,q.default=No,Object.defineProperties(q,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});