filesbox/web/dist/reader/js/epub.js

11 lines
174 KiB
JavaScript
Raw Normal View History

2024-07-26 06:10:54 +00:00
(function(se,C){typeof exports=="object"&&typeof module=="object"?module.exports=C(require("xmldom"),function(){try{return require("jszip")}catch(m){}}()):typeof define=="function"&&define.amd?define(["xmldom","jszip"],C):typeof exports=="object"?exports.ePub=C(require("xmldom"),function(){try{return require("jszip")}catch(m){}}()):se.ePub=C(se.xmldom,se.jszip)})(this,function(oe,se){return function(C){var y={};function m(S){if(y[S])return y[S].exports;var w=y[S]={i:S,l:!1,exports:{}};return C[S].call(w.exports,w,w.exports,m),w.l=!0,w.exports}return m.m=C,m.c=y,m.d=function(S,w,R){m.o(S,w)||Object.defineProperty(S,w,{configurable:!1,enumerable:!0,get:R})},m.n=function(S){var w=S&&S.__esModule?function(){return S.default}:function(){return S};return m.d(w,"a",w),w},m.o=function(S,w){return Object.prototype.hasOwnProperty.call(S,w)},m.p="/dist/",m(m.s=25)}([function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function O(I,M){for(var q=0;q<M.length;q++){var W=M[q];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(I,W.key,W)}}return function(I,M,q){return M&&O(I.prototype,M),q&&O(I,q),I}}();y.uuid=f,y.documentHeight=n,y.isElement=l,y.isNumber=e,y.isFloat=r,y.prefixed=t,y.defaults=i,y.extend=s,y.insert=u,y.locationOf=c,y.indexOfSorted=a,y.bounds=o,y.borders=v,y.windowBounds=p,y.indexOfNode=b,y.indexOfTextNode=E,y.indexOfElementNode=L,y.isXml=A,y.createBlob=B,y.createBlobUrl=D,y.revokeBlobUrl=V,y.createBase64Url=N,y.type=z,y.parse=_,y.qs=P,y.qsa=x,y.qsp=F,y.sprint=G,y.treeWalker=X,y.walk=J,y.blob2base64=K,y.defer=H,y.querySelectorByType=U,y.findChildren=j,y.parents=Y,y.filterChildren=Q,y.getParentByTagName=te;function w(O,I){if(!(O instanceof I))throw new TypeError("Cannot call a class as a function")}var R=y.requestAnimationFrame=typeof window!="undefined"?window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame:!1,T=1,k=3,g=8,d=9,h=typeof URL!="undefined"?URL:typeof window!="undefined"?window.URL||window.webkitURL||window.mozURL:void 0;function f(){var O=new Date().getTime(),I="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(M){var q=(O+Math.random()*16)%16|0;return O=Math.floor(O/16),(M=="x"?q:q&7|8).toString(16)});return I}function n(){return Math.max(document.documentElement.clientHeight,document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight)}function l(O){return!!(O&&O.nodeType==1)}function e(O){return!isNaN(parseFloat(O))&&isFinite(O)}function r(O){var I=parseFloat(O);return I===O&&e(O)&&Math.floor(I)!==O}function t(O){var I=["Webkit","webkit","Moz","O","ms"],M=["-webkit-","-webkit-","-moz-","-o-","-ms-"],q=O[0].toUpperCase()+O.slice(1),W=I.length;if(typeof document=="undefined"||typeof document.body.style[O]!="undefined")return O;for(var Z=0;Z<W;Z++)if(typeof document.body.style[I[Z]+q]!="undefined")return M[Z]+O;return O}function i(O){for(var I=1,M=arguments.length;I<M;I++){var q=arguments[I];for(var W in q)O[W]===void 0&&(O[W]=q[W])}return O}function s(O){var I=[].slice.call(arguments,1);return I.forEach(function(M){!M||Object.getOwnPropertyNames(M).forEach(function(q){Object.defineProperty(O,q,Object.getOwnPropertyDescriptor(M,q))})}),O}function u(O,I,M){var q=c(O,I,M);return I.splice(q,0,O),q}function c(O,I,M,q,W){var Z=q||0,$=W||I.length,ee=parseInt(Z+($-Z)/2),ie;return M||(M=function(ne,re){if(ne>re)return 1;if(ne<re)return-1;if(ne==re)return 0}),$-Z<=0?ee:(ie=M(I[ee],O),$-Z==1?ie>=0?ee:ee+1:ie===0?ee:ie===-1?c(O,I,M,ee,$):c(O,I,M,Z,ee))}function a(O,I,M,q,W){var Z=q||0,$=W||I.length,ee=parseInt(Z+($-Z)/2),ie;return M||(M=function(ne,re){if(ne>re)return 1;if(ne<re)return-1;if(ne==re)return 0}),$-Z<=0?-1:(ie=M(I[ee],O),$-Z==1?ie===0?ee:-1:ie===0?ee:ie===-1?a(O,I,M,ee,$):a(O,I,M,Z,ee))}function o(O){var I=window.getComputedStyle(O),M=["width","paddingRight","paddingLeft","marginRight","marginLeft","borderRightWidth","borderLeftWidth"],q=["height","paddingTop","padd
`}p.insertRule(D+"{"+V+"}",p.cssRules.length)}else{var _=Object.keys(o);_.forEach(function(P){var x=o[P];if(Array.isArray(x))x.forEach(function(X){var J=Object.keys(X),K=J.map(function(H){return H+":"+X[H]}).join(";");p.insertRule(P+"{"+K+"}",p.cssRules.length)});else{var F=Object.keys(x),G=F.map(function(X){return X+":"+x[X]}).join(";");p.insertRule(P+"{"+G+"}",p.cssRules.length)}})}}},{key:"addScript",value:function(o){return new Promise(function(v,p){var b,E=!1;if(!this.document){v(!1);return}b=this.document.createElement("script"),b.type="text/javascript",b.async=!0,b.src=o,b.onload=b.onreadystatechange=function(){!E&&(!this.readyState||this.readyState=="complete")&&(E=!0,setTimeout(function(){v(!0)},1))},this.document.head.appendChild(b)}.bind(this))}},{key:"addClass",value:function(o){var v;!this.document||(v=this.content||this.document.body,v&&v.classList.add(o))}},{key:"removeClass",value:function(o){var v;!this.document||(v=this.content||this.document.body,v&&v.classList.remove(o))}},{key:"addEventListeners",value:function(){!this.document||n.DOM_EVENTS.forEach(function(o){this.document.addEventListener(o,this.triggerEvent.bind(this),!1)},this)}},{key:"removeEventListeners",value:function(){!this.document||n.DOM_EVENTS.forEach(function(o){this.document.removeEventListener(o,this.triggerEvent,!1)},this)}},{key:"triggerEvent",value:function(o){this.emit(o.type,o)}},{key:"addSelectionListeners",value:function(){!this.document||this.document.addEventListener("selectionchange",this.onSelectionChange.bind(this),!1)}},{key:"removeSelectionListeners",value:function(){!this.document||this.document.removeEventListener("selectionchange",this.onSelectionChange,!1)}},{key:"onSelectionChange",value:function(o){this.selectionEndTimeout&&clearTimeout(this.selectionEndTimeout),this.selectionEndTimeout=setTimeout(function(){var v=this.window.getSelection();this.triggerSelectedEvent(v)}.bind(this),250)}},{key:"triggerSelectedEvent",value:function(o){var v,p;o&&o.rangeCount>0&&(v=o.getRangeAt(0),v.collapsed||(p=new g.default(v,this.cfiBase).toString(),this.emit(n.EVENTS.CONTENTS.SELECTED,p),this.emit(n.EVENTS.CONTENTS.SELECTED_RANGE,v)))}},{key:"range",value:function(o,v){var p=new g.default(o);return p.toRange(this.document,v)}},{key:"cfiFromRange",value:function(o,v){return new g.default(o,this.cfiBase,v).toString()}},{key:"cfiFromNode",value:function(o,v){return new g.default(o,this.cfiBase,v).toString()}},{key:"map",value:function(o){var v=new h.default(o);return v.section()}},{key:"size",value:function(o,v){var p={scale:1,scalable:"no"};this.layoutStyle("scrolling"),o>=0&&(this.width(o),p.width=o,this.css("padding","0 "+o/12+"px",!0)),v>=0&&(this.height(v),p.height=v),this.css("margin","0"),this.css("box-sizing","border-box"),this.viewport(p)}},{key:"columns",value:function(o,v,p,b){var E=(0,T.prefixed)("column-axis"),L=(0,T.prefixed)("column-gap"),A=(0,T.prefixed)("column-width"),B=(0,T.prefixed)("column-fill"),D=this.writingMode(),V=D.indexOf("vertical")===0?"vertical":"horizontal";this.layoutStyle("paginated"),this.content.dir==="rtl"&&this.direction("rtl"),this.width(o),this.height(v),this.viewport({width:o,height:v,scale:1,scalable:"no"}),this.css("overflow-y","hidden"),this.css("margin","0",!0),V==="vertical"?this.css("padding",b/2+"px 20px",!0):this.css("padding","20px "+b/2+"px",!0),this.css("box-sizing","border-box"),this.css("max-width","inherit"),this.css(E,"horizontal"),this.css(B,"auto"),this.css(L,b+"px"),this.css(A,p+"px")}},{key:"scaler",value:function(o,v,p){var b="scale("+o+")",E="";this.css("transform-origin","top left"),(v>=0||p>=0)&&(E=" translate("+(v||0)+"px, "+(p||0)+"px )"),this.css("transform",b+E)}},{key:"fit",value:function(o,v){var p=this.viewport(),b=o/parseInt(p.width),E=v/parseInt(p.height),L=b<E?b:E,A=(v-p.height*L)/2;this.layoutStyle("paginated"),this.width(o),this.height(v),this.overflow("hidden"),this.scaler(L,0,A),this.css("background-color","transparent")}},{key:"direction",value:function(o){this.documentElement&&(this.documentElement.style.direction=o)}},{key:"mapPage",value:function(o,v
`&&x!="\r"&&(this._schemeData+=i(x));break;case"no scheme":if(!A||!e(A._scheme))B("Missing scheme."),r.call(this);else{D="relative";continue}break;case"relative or authority":if(x=="/"&&E[V+1]=="/")D="authority ignore slashes";else{B("Expected /, got: "+x),D="relative";continue}break;case"relative":if(this._isRelative=!0,this._scheme!="file"&&(this._scheme=A._scheme),u==x){this._host=A._host,this._port=A._port,this._path=A._path.slice(),this._query=A._query,this._username=A._username,this._password=A._password;break e}else if(x=="/"||x=="\\")x=="\\"&&B("\\ is an invalid code point."),D="relative slash";else if(x=="?")this._host=A._host,this._port=A._port,this._path=A._path.slice(),this._query="?",this._username=A._username,this._password=A._password,D="query";else if(x=="#")this._host=A._host,this._port=A._port,this._path=A._path.slice(),this._query=A._query,this._fragment="#",this._username=A._username,this._password=A._password,D="fragment";else{var F=E[V+1],G=E[V+2];(this._scheme!="file"||!c.test(x)||F!=":"&&F!="|"||u!=G&&G!="/"&&G!="\\"&&G!="?"&&G!="#")&&(this._host=A._host,this._port=A._port,this._username=A._username,this._password=A._password,this._path=A._path.slice(),this._path.pop()),D="relative path";continue}break;case"relative slash":if(x=="/"||x=="\\")x=="\\"&&B("\\ is an invalid code point."),this._scheme=="file"?D="file host":D="authority ignore slashes";else{this._scheme!="file"&&(this._host=A._host,this._port=A._port,this._username=A._username,this._password=A._password),D="relative path";continue}break;case"authority first slash":if(x=="/")D="authority second slash";else{B("Expected '/', got: "+x),D="authority ignore slashes";continue}break;case"authority second slash":if(D="authority ignore slashes",x!="/"){B("Expected '/', got: "+x);continue}break;case"authority ignore slashes":if(x!="/"&&x!="\\"){D="authority";continue}else B("Expected authority, got: "+x);break;case"authority":if(x=="@"){z&&(B("@ already seen."),N+="%40"),z=!0;for(var X=0;X<N.length;X++){var J=N[X];if(J==" "||J==`
`||J=="\r"){B("Invalid whitespace in authority.");continue}if(J==":"&&this._password===null){this._password="";continue}var K=i(J);this._password!==null?this._password+=K:this._username+=K}N=""}else if(u==x||x=="/"||x=="\\"||x=="?"||x=="#"){V-=N.length,N="",D="host";continue}else N+=x;break;case"file host":if(u==x||x=="/"||x=="\\"||x=="?"||x=="#"){N.length==2&&c.test(N[0])&&(N[1]==":"||N[1]=="|")?D="relative path":(N.length==0||(this._host=t.call(this,N),N=""),D="relative path start");continue}else x==" "||x==`
`||x=="\r"?B("Invalid whitespace in file host."):N+=x;break;case"host":case"hostname":if(x==":"&&!_){if(this._host=t.call(this,N),N="",D="port",L=="hostname")break e}else if(u==x||x=="/"||x=="\\"||x=="?"||x=="#"){if(this._host=t.call(this,N),N="",D="relative path start",L)break e;continue}else x!=" "&&x!=`
`&&x!="\r"?(x=="["?_=!0:x=="]"&&(_=!1),N+=x):B("Invalid code point in host/hostname: "+x);break;case"port":if(/[0-9]/.test(x))N+=x;else if(u==x||x=="/"||x=="\\"||x=="?"||x=="#"||L){if(N!=""){var H=parseInt(N,10);H!=n[this._scheme]&&(this._port=H+""),N=""}if(L)break e;D="relative path start";continue}else x==" "||x==`
`||x=="\r"?B("Invalid code point in port: "+x):r.call(this);break;case"relative path start":if(x=="\\"&&B("'\\' not allowed in path."),D="relative path",x!="/"&&x!="\\")continue;break;case"relative path":if(u==x||x=="/"||x=="\\"||!L&&(x=="?"||x=="#")){x=="\\"&&B("\\ not allowed in relative path.");var U;(U=l[N.toLowerCase()])&&(N=U),N==".."?(this._path.pop(),x!="/"&&x!="\\"&&this._path.push("")):N=="."&&x!="/"&&x!="\\"?this._path.push(""):N!="."&&(this._scheme=="file"&&this._path.length==0&&N.length==2&&c.test(N[0])&&N[1]=="|"&&(N=N[0]+":"),this._path.push(N)),N="",x=="?"?(this._query="?",D="query"):x=="#"&&(this._fragment="#",D="fragment")}else x!=" "&&x!=`
`&&x!="\r"&&(N+=i(x));break;case"query":!L&&x=="#"?(this._fragment="#",D="fragment"):u!=x&&x!=" "&&x!=`
`&&x!="\r"&&(this._query+=s(x));break;case"fragment":u!=x&&x!=" "&&x!=`
`&&x!="\r"&&(this._fragment+=x);break}V++}}function v(){this._scheme="",this._schemeData="",this._username="",this._password=null,this._host="",this._port="",this._path=[],this._query="",this._fragment="",this._isInvalid=!1,this._isRelative=!1}function p(E,L){L!==void 0&&!(L instanceof p)&&(L=new p(String(L))),this._url=E,v.call(this);var A=E.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g,"");o.call(this,A,null,L)}p.prototype={toString:function(){return this.href},get href(){if(this._isInvalid)return this._url;var E="";return(this._username!=""||this._password!=null)&&(E=this._username+(this._password!=null?":"+this._password:"")+"@"),this.protocol+(this._isRelative?"//"+E+this.host:"")+this.pathname+this._query+this._fragment},set href(E){v.call(this),o.call(this,E)},get protocol(){return this._scheme+":"},set protocol(E){this._isInvalid||o.call(this,E+":","scheme start")},get host(){return this._isInvalid?"":this._port?this._host+":"+this._port:this._host},set host(E){this._isInvalid||!this._isRelative||o.call(this,E,"host")},get hostname(){return this._host},set hostname(E){this._isInvalid||!this._isRelative||o.call(this,E,"hostname")},get port(){return this._port},set port(E){this._isInvalid||!this._isRelative||o.call(this,E,"port")},get pathname(){return this._isInvalid?"":this._isRelative?"/"+this._path.join("/"):this._schemeData},set pathname(E){this._isInvalid||!this._isRelative||(this._path=[],o.call(this,E,"relative path start"))},get search(){return this._isInvalid||!this._query||this._query=="?"?"":this._query},set search(E){this._isInvalid||!this._isRelative||(this._query="?",E[0]=="?"&&(E=E.slice(1)),o.call(this,E,"query"))},get hash(){return this._isInvalid||!this._fragment||this._fragment=="#"?"":this._fragment},set hash(E){this._isInvalid||(this._fragment="#",E[0]=="#"&&(E=E.slice(1)),o.call(this,E,"fragment"))},get origin(){var E;if(this._isInvalid||!this._scheme)return"";switch(this._scheme){case"file":return"file://";case"data":case"javascript":case"mailto":return"null"}return E=this.host,E?this._scheme+"://"+E:""}};var b=d.URL;return b&&(p.createObjectURL=function(E){return b.createObjectURL.apply(b,arguments)},p.revokeObjectURL=function(E){b.revokeObjectURL(E)}),p})}).call(y,m(8),m(70)(C))},function(C,y){C.exports=function(m){return m.webpackPolyfill||(m.deprecate=function(){},m.paths=[],m.children||(m.children=[]),Object.defineProperty(m,"loaded",{enumerable:!0,get:function(){return m.l}}),Object.defineProperty(m,"id",{enumerable:!0,get:function(){return m.i}}),m.webpackPolyfill=1),m}}])});