11 lines
174 KiB
JavaScript
11 lines
174 KiB
JavaScript
(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","paddingBottom","marginTop","marginBottom","borderTopWidth","borderBottomWidth"],W=0,Z=0;return M.forEach(function($){W+=parseFloat(I[$])||0}),q.forEach(function($){Z+=parseFloat(I[$])||0}),{height:Z,width:W}}function v(O){var I=window.getComputedStyle(O),M=["paddingRight","paddingLeft","marginRight","marginLeft","borderRightWidth","borderLeftWidth"],q=["paddingTop","paddingBottom","marginTop","marginBottom","borderTopWidth","borderBottomWidth"],W=0,Z=0;return M.forEach(function($){W+=parseFloat(I[$])||0}),q.forEach(function($){Z+=parseFloat(I[$])||0}),{height:Z,width:W}}function p(){var O=window.innerWidth,I=window.innerHeight;return{top:0,left:0,right:O,bottom:I,width:O,height:I}}function b(O,I){for(var M=O.parentNode,q=M.childNodes,W,Z=-1,$=0;$<q.length&&(W=q[$],W.nodeType===I&&Z++,W!=O);$++);return Z}function E(O){return b(O,k)}function L(O){return b(O,T)}function A(O){return["xml","opf","ncx"].indexOf(O)>-1}function B(O,I){return new Blob([O],{type:I})}function D(O,I){var M,q=B(O,I);return M=h.createObjectURL(q),M}function V(O){return h.revokeObjectURL(O)}function N(O,I){var M,q;if(typeof O=="string")return M=btoa(encodeURIComponent(O)),q="data:"+I+";base64,"+M,q}function z(O){return Object.prototype.toString.call(O).slice(8,-1)}function _(O,I,M){var q,W;return typeof DOMParser=="undefined"||M?W=m(16).DOMParser:W=DOMParser,O.charCodeAt(0)===65279&&(O=O.slice(1)),q=new W().parseFromString(O,I),q}function P(O,I){var M;if(!O)throw new Error("No Element Provided");if(typeof O.querySelector!="undefined")return O.querySelector(I);if(M=O.getElementsByTagName(I),M.length)return M[0]}function x(O,I){return typeof O.querySelector!="undefined"?O.querySelectorAll(I):O.getElementsByTagName(I)}function F(O,I,M){var q,W;if(typeof O.querySelector!="undefined"){I+="[";for(var Z in M)I+=Z+"~='"+M[Z]+"'";return I+="]",O.querySelector(I)}else if(q=O.getElementsByTagName(I),W=Array.prototype.slice.call(q,0).filter(function($){for(var ee in M)if($.getAttribute(ee)===M[ee])return!0;return!1}),W)return W[0]}function G(O,I){var M=O.ownerDocument||O;typeof M.createTreeWalker!="undefined"?X(O,I,NodeFilter.SHOW_TEXT):J(O,function(q){q&&q.nodeType===3&&I(q)},!0)}function X(O,I,M){for(var q=document.createTreeWalker(O,M,null,!1),W=void 0;W=q.nextNode();)I(W)}function J(O,I){if(I(O))return!0;if(O=O.firstChild,O)do{var M=J(O,I);if(M)return!0;O=O.nextSibling}while(O)}function K(O){return new Promise(function(I,M){var q=new FileReader;q.readAsDataURL(O),q.onloadend=function(){I(q.result)}})}function H(){var O=this;this.resolve=null,this.reject=null,this.id=f(),this.promise=new Promise(function(I,M){O.resolve=I,O.reject=M}),Object.freeze(this)}function U(O,I,M){var q;if(typeof O.querySelector!="undefined"&&(q=O.querySelector(I+'[*|type="'+M+'"]')),!q||q.length===0){q=x(O,I);for(var W=0;W<q.length;W++)if(q[W].getAttributeNS("http://www.idpf.org/2007/ops","type")===M||q[W].getAttribute("epub:type")===M)return q[W]}else return q}function j(O){for(var I=[],M=O.childNodes,q=0;q<M.length;q++){var W=M[q];W.nodeType===1&&I.push(W)}return I}function Y(O){for(var I=[O];O;O=O.parentNode)I.unshift(O);return I}function Q(O,I,M){for(var q=[],W=O.childNodes,Z=0;Z<W.length;Z++){var $=W[Z];if($.nodeType===1&&$.nodeName.toLowerCase()===I){if(M)return $;q.push($)}}if(!M)return q}function te(O,I){var M=void 0;if(!(O===null||I===""))for(M=O.parentNode;M.nodeType===1;){if(M.tagName.toLowerCase()===I)return M;M=M.parentNode}}var ae=y.RangeObject=function(){function O(){w(this,O),this.collapsed=!1,this.commonAncestorContainer=void 0,this.endContainer=void 0,this.endOffset=void 0,this.startContainer=void 0,this.startOffset=void 0}return S(O,[{key:"setStart",value:function(M,q){this.startContainer=M,this.startOffset=q,this.endContainer?this.commonAncestorContainer=this._commonAncestorContainer():this.collapse(!0),this._checkCollapsed()}},{key:"setEnd",value:function(M,q){this.endContainer=M,this.endOffset=q,this.startContainer?(this.collapsed=!1,this.commonAncestorContainer=this._commonAncestorContainer()):this.collapse(!1),this._checkCollapsed()}},{key:"collapse",value:function(M){this.collapsed=!0,M?(this.endContainer=this.startContainer,this.endOffset=this.startOffset,this.commonAncestorContainer=this.startContainer.parentNode):(this.startContainer=this.endContainer,this.startOffset=this.endOffset,this.commonAncestorContainer=this.endOffset.parentNode)}},{key:"selectNode",value:function(M){var q=M.parentNode,W=Array.prototype.indexOf.call(q.childNodes,M);this.setStart(q,W),this.setEnd(q,W+1)}},{key:"selectNodeContents",value:function(M){var q=M.childNodes[M.childNodes-1],W=M.nodeType===3?M.textContent.length:parent.childNodes.length;this.setStart(M,0),this.setEnd(M,W)}},{key:"_commonAncestorContainer",value:function(M,q){var W=Y(M||this.startContainer),Z=Y(q||this.endContainer);if(W[0]==Z[0]){for(var $=0;$<W.length;$++)if(W[$]!=Z[$])return W[$-1]}}},{key:"_checkCollapsed",value:function(){this.startContainer===this.endContainer&&this.startOffset===this.endOffset?this.collapsed=!0:this.collapsed=!1}},{key:"toString",value:function(){}}]),O}()},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},w=function(){function n(l,e){for(var r=0;r<e.length;r++){var t=e[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(l,t.key,t)}}return function(l,e,r){return e&&n(l.prototype,e),r&&n(l,r),l}}(),R=m(0);function T(n,l){if(!(n instanceof l))throw new TypeError("Cannot call a class as a function")}var k=1,g=3,d=8,h=9,f=function(){function n(l,e,r){T(this,n);var t;if(this.str="",this.base={},this.spinePos=0,this.range=!1,this.path={},this.start=null,this.end=null,!(this instanceof n))return new n(l,e,r);if(typeof e=="string"?this.base=this.parseComponent(e):(typeof e=="undefined"?"undefined":S(e))==="object"&&e.steps&&(this.base=e),t=this.checkType(l),t==="string")return this.str=l,(0,R.extend)(this,this.parse(l));if(t==="range")return(0,R.extend)(this,this.fromRange(l,this.base,r));if(t==="node")return(0,R.extend)(this,this.fromNode(l,this.base,r));if(t==="EpubCFI"&&l.path)return l;if(l)throw new TypeError("not a valid argument for EpubCFI");return this}return w(n,[{key:"checkType",value:function(e){return this.isCfiString(e)?"string":(typeof e=="undefined"?"undefined":S(e))==="object"&&((0,R.type)(e)==="Range"||typeof e.startContainer!="undefined")?"range":(typeof e=="undefined"?"undefined":S(e))==="object"&&typeof e.nodeType!="undefined"?"node":(typeof e=="undefined"?"undefined":S(e))==="object"&&e instanceof n?"EpubCFI":!1}},{key:"parse",value:function(e){var r={spinePos:-1,range:!1,base:{},path:{},start:null,end:null},t,i,s;return typeof e!="string"?{spinePos:-1}:(e.indexOf("epubcfi(")===0&&e[e.length-1]===")"&&(e=e.slice(8,e.length-1)),t=this.getChapterComponent(e),t?(r.base=this.parseComponent(t),i=this.getPathComponent(e),r.path=this.parseComponent(i),s=this.getRange(e),s&&(r.range=!0,r.start=this.parseComponent(s[0]),r.end=this.parseComponent(s[1])),r.spinePos=r.base.steps[1].index,r):{spinePos:-1})}},{key:"parseComponent",value:function(e){var r={steps:[],terminal:{offset:null,assertion:null}},t=e.split(":"),i=t[0].split("/"),s;return t.length>1&&(s=t[1],r.terminal=this.parseTerminal(s)),i[0]===""&&i.shift(),r.steps=i.map(function(u){return this.parseStep(u)}.bind(this)),r}},{key:"parseStep",value:function(e){var r,t,i,s,u;if(s=e.match(/\[(.*)\]/),s&&s[1]&&(u=s[1]),t=parseInt(e),!isNaN(t))return t%2==0?(r="element",i=t/2-1):(r="text",i=(t-1)/2),{type:r,index:i,id:u||null}}},{key:"parseTerminal",value:function(e){var r,t,i=e.match(/\[(.*)\]/);return i&&i[1]?(r=parseInt(e.split("[")[0]),t=i[1]):r=parseInt(e),(0,R.isNumber)(r)||(r=null),{offset:r,assertion:t}}},{key:"getChapterComponent",value:function(e){var r=e.split("!");return r[0]}},{key:"getPathComponent",value:function(e){var r=e.split("!");if(r[1]){var t=r[1].split(",");return t[0]}}},{key:"getRange",value:function(e){var r=e.split(",");return r.length===3?[r[1],r[2]]:!1}},{key:"getCharecterOffsetComponent",value:function(e){var r=e.split(":");return r[1]||""}},{key:"joinSteps",value:function(e){return e?e.map(function(r){var t="";return r.type==="element"&&(t+=(r.index+1)*2),r.type==="text"&&(t+=1+2*r.index),r.id&&(t+="["+r.id+"]"),t}).join("/"):""}},{key:"segmentString",value:function(e){var r="/";return r+=this.joinSteps(e.steps),e.terminal&&e.terminal.offset!=null&&(r+=":"+e.terminal.offset),e.terminal&&e.terminal.assertion!=null&&(r+="["+e.terminal.assertion+"]"),r}},{key:"toString",value:function(){var e="epubcfi(";return e+=this.segmentString(this.base),e+="!",e+=this.segmentString(this.path),this.range&&this.start&&(e+=",",e+=this.segmentString(this.start)),this.range&&this.end&&(e+=",",e+=this.segmentString(this.end)),e+=")",e}},{key:"compare",value:function(e,r){var t,i,s,u,c,a,o,o,v,p,b,E;if(typeof e=="string"&&(e=new n(e)),typeof r=="string"&&(r=new n(r)),e.spinePos>r.spinePos)return 1;if(e.spinePos<r.spinePos)return-1;e.range?(t=e.path.steps.concat(e.start.steps),s=e.start.terminal):(t=e.path.steps,s=e.path.terminal),r.range?(i=r.path.steps.concat(r.start.steps),u=r.start.terminal):(i=r.path.steps,u=r.path.terminal);for(var L=0;L<t.length;L++){if(!t[L])return-1;if(!i[L]||t[L].index>i[L].index)return 1;if(t[L].index<i[L].index)return-1}return t.length<i.length||s.offset>u.offset?1:s.offset<u.offset?-1:0}},{key:"step",value:function(e){var r=e.nodeType===g?"text":"element";return{id:e.id,tagName:e.tagName,type:r,index:this.position(e)}}},{key:"filteredStep",value:function(e,r){var t=this.filter(e,r),i;if(!!t)return i=t.nodeType===g?"text":"element",{id:t.id,tagName:t.tagName,type:i,index:this.filteredPosition(t,r)}}},{key:"pathTo",value:function(e,r,t){for(var i={steps:[],terminal:{offset:null,assertion:null}},s=e,u;s&&s.parentNode&&s.parentNode.nodeType!=h;)t?u=this.filteredStep(s,t):u=this.step(s),u&&i.steps.unshift(u),s=s.parentNode;return r!=null&&r>=0&&(i.terminal.offset=r,i.steps[i.steps.length-1].type!="text"&&i.steps.push({type:"text",index:0})),i}},{key:"equalStep",value:function(e,r){return!e||!r?!1:e.index===r.index&&e.id===r.id&&e.type===r.type}},{key:"fromRange",value:function(e,r,t){var i={range:!1,base:{},path:{},start:null,end:null},s=e.startContainer,u=e.endContainer,c=e.startOffset,a=e.endOffset,o=!1;if(t&&(o=s.ownerDocument.querySelector("."+t)!=null),typeof r=="string"?(i.base=this.parseComponent(r),i.spinePos=i.base.steps[1].index):(typeof r=="undefined"?"undefined":S(r))==="object"&&(i.base=r),e.collapsed)o&&(c=this.patchOffset(s,c,t)),i.path=this.pathTo(s,c,t);else{i.range=!0,o&&(c=this.patchOffset(s,c,t)),i.start=this.pathTo(s,c,t),o&&(a=this.patchOffset(u,a,t)),i.end=this.pathTo(u,a,t),i.path={steps:[],terminal:null};var v=i.start.steps.length,p;for(p=0;p<v&&this.equalStep(i.start.steps[p],i.end.steps[p]);p++)p===v-1?i.start.terminal===i.end.terminal&&(i.path.steps.push(i.start.steps[p]),i.range=!1):i.path.steps.push(i.start.steps[p]);i.start.steps=i.start.steps.slice(i.path.steps.length),i.end.steps=i.end.steps.slice(i.path.steps.length)}return i}},{key:"fromNode",value:function(e,r,t){var i={range:!1,base:{},path:{},start:null,end:null};return typeof r=="string"?(i.base=this.parseComponent(r),i.spinePos=i.base.steps[1].index):(typeof r=="undefined"?"undefined":S(r))==="object"&&(i.base=r),i.path=this.pathTo(e,null,t),i}},{key:"filter",value:function(e,r){var t,i,s,u,c,a=!1;return e.nodeType===g?(a=!0,s=e.parentNode,t=e.parentNode.classList.contains(r)):(a=!1,t=e.classList.contains(r)),t&&a?(u=s.previousSibling,c=s.nextSibling,u&&u.nodeType===g?i=u:c&&c.nodeType===g&&(i=c),i||e):t&&!a?!1:e}},{key:"patchOffset",value:function(e,r,t){if(e.nodeType!=g)throw new Error("Anchor must be a text node");var i=e,s=r;for(e.parentNode.classList.contains(t)&&(i=e.parentNode);i.previousSibling;){if(i.previousSibling.nodeType===k)if(i.previousSibling.classList.contains(t))s+=i.previousSibling.textContent.length;else break;else s+=i.previousSibling.textContent.length;i=i.previousSibling}return s}},{key:"normalizedMap",value:function(e,r,t){var i={},s=-1,u,c=e.length,a,o;for(u=0;u<c;u++)a=e[u].nodeType,a===k&&e[u].classList.contains(t)&&(a=g),u>0&&a===g&&o===g?i[u]=s:r===a&&(s=s+1,i[u]=s),o=a;return i}},{key:"position",value:function(e){var r,t;return e.nodeType===k?(r=e.parentNode.children,r||(r=(0,R.findChildren)(e.parentNode)),t=Array.prototype.indexOf.call(r,e)):(r=this.textNodes(e.parentNode),t=r.indexOf(e)),t}},{key:"filteredPosition",value:function(e,r){var t,i,s;return e.nodeType===k?(t=e.parentNode.children,s=this.normalizedMap(t,k,r)):(t=e.parentNode.childNodes,e.parentNode.classList.contains(r)&&(e=e.parentNode,t=e.parentNode.childNodes),s=this.normalizedMap(t,g,r)),i=Array.prototype.indexOf.call(t,e),s[i]}},{key:"stepsToXpath",value:function(e){var r=[".","*"];return e.forEach(function(t){var i=t.index+1;t.id?r.push("*[position()="+i+" and @id='"+t.id+"']"):t.type==="text"?r.push("text()["+i+"]"):r.push("*["+i+"]")}),r.join("/")}},{key:"stepsToQuerySelector",value:function(e){var r=["html"];return e.forEach(function(t){var i=t.index+1;t.id?r.push("#"+t.id):t.type==="text"||r.push("*:nth-child("+i+")")}),r.join(">")}},{key:"textNodes",value:function(e,r){return Array.prototype.slice.call(e.childNodes).filter(function(t){return t.nodeType===g?!0:!!(r&&t.classList.contains(r))})}},{key:"walkToNode",value:function(e,r,t){var i=r||document,s=i.documentElement,u,c,a=e.length,o;for(o=0;o<a&&(c=e[o],c.type==="element"?c.id?s=i.getElementById(c.id):(u=s.children||(0,R.findChildren)(s),s=u[c.index]):c.type==="text"&&(s=this.textNodes(s,t)[c.index]),!!s);o++);return s}},{key:"findNode",value:function(e,r,t){var i=r||document,s,u;return!t&&typeof i.evaluate!="undefined"?(u=this.stepsToXpath(e),s=i.evaluate(u,i,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue):t?s=this.walkToNode(e,i,t):s=this.walkToNode(e,i),s}},{key:"fixMiss",value:function(e,r,t,i){var s=this.findNode(e.slice(0,-1),t,i),u=s.childNodes,c=this.normalizedMap(u,g,i),a,o,v=e[e.length-1].index;for(var p in c){if(!c.hasOwnProperty(p))return;if(c[p]===v)if(a=u[p],o=a.textContent.length,r>o)r=r-o;else{a.nodeType===k?s=a.childNodes[0]:s=a;break}}return{container:s,offset:r}}},{key:"toRange",value:function(e,r){var t=e||document,i,s,u,c,a,o=this,v,p,b=r?t.querySelector("."+r)!=null:!1,E;if(typeof t.createRange!="undefined"?i=t.createRange():i=new R.RangeObject,o.range?(s=o.start,v=o.path.steps.concat(s.steps),c=this.findNode(v,t,b?r:null),u=o.end,p=o.path.steps.concat(u.steps),a=this.findNode(p,t,b?r:null)):(s=o.path,v=o.path.steps,c=this.findNode(o.path.steps,t,b?r:null)),c)try{s.terminal.offset!=null?i.setStart(c,s.terminal.offset):i.setStart(c,0)}catch(L){E=this.fixMiss(v,s.terminal.offset,t,b?r:null),i.setStart(E.container,E.offset)}else return console.log("No startContainer found for",this.toString()),null;if(a)try{u.terminal.offset!=null?i.setEnd(a,u.terminal.offset):i.setEnd(a,0)}catch(L){E=this.fixMiss(p,o.end.terminal.offset,t,b?r:null),i.setEnd(E.container,E.offset)}return i}},{key:"isCfiString",value:function(e){return typeof e=="string"&&e.indexOf("epubcfi(")===0&&e[e.length-1]===")"}},{key:"generateChapterComponent",value:function(e,r,t){var i=parseInt(r),s=(e+1)*2,u="/"+s+"/";return u+=(i+1)*2,t&&(u+="["+t+"]"),u}},{key:"collapse",value:function(e){!this.range||(this.range=!1,e?(this.path.steps=this.path.steps.concat(this.start.steps),this.path.terminal=this.start.terminal):(this.path.steps=this.path.steps.concat(this.end.steps),this.path.terminal=this.end.terminal))}}]),n}();y.default=f,C.exports=y.default},function(C,y,m){"use strict";var S=m(27),w=m(41),R=Function.prototype.apply,T=Function.prototype.call,k=Object.create,g=Object.defineProperty,d=Object.defineProperties,h=Object.prototype.hasOwnProperty,f={configurable:!0,enumerable:!1,writable:!0},n,l,e,r,t,i,s;n=function(u,c){var a;return w(c),h.call(this,"__ee__")?a=this.__ee__:(a=f.value=k(null),g(this,"__ee__",f),f.value=null),a[u]?typeof a[u]=="object"?a[u].push(c):a[u]=[a[u],c]:a[u]=c,this},l=function(u,c){var a,o;return w(c),o=this,n.call(this,u,a=function(){e.call(o,u,a),R.call(c,this,arguments)}),a.__eeOnceListener__=c,this},e=function(u,c){var a,o,v,p;if(w(c),!h.call(this,"__ee__"))return this;if(a=this.__ee__,!a[u])return this;if(o=a[u],typeof o=="object")for(p=0;v=o[p];++p)(v===c||v.__eeOnceListener__===c)&&(o.length===2?a[u]=o[p?0:1]:o.splice(p,1));else(o===c||o.__eeOnceListener__===c)&&delete a[u];return this},r=function(u){var c,a,o,v,p;if(!!h.call(this,"__ee__")&&(v=this.__ee__[u],!!v))if(typeof v=="object"){for(a=arguments.length,p=new Array(a-1),c=1;c<a;++c)p[c-1]=arguments[c];for(v=v.slice(),c=0;o=v[c];++c)R.call(o,this,p)}else switch(arguments.length){case 1:T.call(v,this);break;case 2:T.call(v,this,arguments[1]);break;case 3:T.call(v,this,arguments[1],arguments[2]);break;default:for(a=arguments.length,p=new Array(a-1),c=1;c<a;++c)p[c-1]=arguments[c];R.call(v,this,p)}},t={on:n,once:l,off:e,emit:r},i={on:S(n),once:S(l),off:S(e),emit:S(r)},s=d({},i),C.exports=y=function(u){return u==null?k(s):d(Object(u),i)},y.methods=t},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=y.DOM_EVENTS=["keydown","keyup","keypressed","mouseup","mousedown","click","touchend","touchstart"],w=y.EVENTS={BOOK:{OPEN_FAILED:"openFailed"},CONTENTS:{EXPAND:"expand",RESIZE:"resize",SELECTED:"selected",SELECTED_RANGE:"selectedRange",LINK_CLICKED:"linkClicked"},LOCATIONS:{CHANGED:"changed"},MANAGERS:{RESIZE:"resize",RESIZED:"resized",ORIENTATION_CHANGE:"orientationchange",ADDED:"added",SCROLL:"scroll",SCROLLED:"scrolled"},VIEWS:{AXIS:"axis",LOAD_ERROR:"loaderror",RENDERED:"rendered",RESIZED:"resized",DISPLAYED:"displayed",SHOWN:"shown",HIDDEN:"hidden",MARK_CLICKED:"markClicked"},RENDITION:{STARTED:"started",ATTACHED:"attached",DISPLAYED:"displayed",DISPLAY_ERROR:"displayerror",RENDERED:"rendered",REMOVED:"removed",RESIZED:"resized",ORIENTATION_CHANGE:"orientationchange",LOCATION_CHANGED:"locationChanged",RELOCATED:"relocated",MARK_CLICKED:"markClicked",SELECTED:"selected",LAYOUT:"layout"},LAYOUT:{UPDATED:"updated"}}},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function d(h,f){for(var n=0;n<f.length;n++){var l=f[n];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(h,l.key,l)}}return function(h,f,n){return f&&d(h.prototype,f),n&&d(h,n),h}}(),w=m(6),R=T(w);function T(d){return d&&d.__esModule?d:{default:d}}function k(d,h){if(!(d instanceof h))throw new TypeError("Cannot call a class as a function")}var g=function(){function d(h){k(this,d);var f,n;f=h.indexOf("://"),f>-1&&(h=new URL(h).pathname),n=this.parse(h),this.path=h,this.isDirectory(h)?this.directory=h:this.directory=n.dir+"/",this.filename=n.base,this.extension=n.ext.slice(1)}return S(d,[{key:"parse",value:function(f){return R.default.parse(f)}},{key:"isAbsolute",value:function(f){return R.default.isAbsolute(f||this.path)}},{key:"isDirectory",value:function(f){return f.charAt(f.length-1)==="/"}},{key:"resolve",value:function(f){return R.default.resolve(this.directory,f)}},{key:"relative",value:function(f){return R.default.relative(this.directory,f)}},{key:"splitPath",value:function(f){return this.splitPathRe.exec(f).slice(1)}},{key:"toString",value:function(){return this.path}}]),d}();y.default=g,C.exports=y.default},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function f(n,l){for(var e=0;e<l.length;e++){var r=l[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}return function(n,l,e){return l&&f(n.prototype,l),e&&f(n,e),n}}(),w=m(4),R=g(w),T=m(6),k=g(T);function g(f){return f&&f.__esModule?f:{default:f}}function d(f,n){if(!(f instanceof n))throw new TypeError("Cannot call a class as a function")}var h=function(){function f(n,l){d(this,f);var e=n.indexOf("://")>-1,r=n,t;if(this.Url=void 0,this.href=n,this.protocol="",this.origin="",this.hash="",this.hash="",this.search="",this.base=l,!e&&l!==!1&&typeof l!="string"&&window&&window.location&&(this.base=window.location.href),e||this.base)try{this.base?this.Url=new URL(n,this.base):this.Url=new URL(n),this.href=this.Url.href,this.protocol=this.Url.protocol,this.origin=this.Url.origin,this.hash=this.Url.hash,this.search=this.Url.search,r=this.Url.pathname}catch(i){this.Url=void 0,this.base&&(t=new R.default(this.base),r=t.resolve(r))}this.Path=new R.default(r),this.directory=this.Path.directory,this.filename=this.Path.filename,this.extension=this.Path.extension}return S(f,[{key:"path",value:function(){return this.Path}},{key:"resolve",value:function(l){var e=l.indexOf("://")>-1,r;return e?l:(r=k.default.resolve(this.directory,l),this.origin+r)}},{key:"relative",value:function(l){return k.default.relative(l,this.directory)}},{key:"toString",value:function(){return this.href}}]),f}();y.default=h,C.exports=y.default},function(C,y,m){"use strict";if(!S)var S={cwd:function(){return"/"}};function w(g){if(typeof g!="string")throw new TypeError("Path must be a string. Received "+g)}function R(g,d){for(var h="",f=-1,n=0,l,e=0;e<=g.length;++e){if(e<g.length)l=g.charCodeAt(e);else{if(l===47)break;l=47}if(l===47){if(!(f===e-1||n===1))if(f!==e-1&&n===2){if(h.length<2||h.charCodeAt(h.length-1)!==46||h.charCodeAt(h.length-2)!==46){if(h.length>2){for(var r=h.length-1,t=r;t>=0&&h.charCodeAt(t)!==47;--t);if(t!==r){t===-1?h="":h=h.slice(0,t),f=e,n=0;continue}}else if(h.length===2||h.length===1){h="",f=e,n=0;continue}}d&&(h.length>0?h+="/..":h="..")}else h.length>0?h+="/"+g.slice(f+1,e):h=g.slice(f+1,e);f=e,n=0}else l===46&&n!==-1?++n:n=-1}return h}function T(g,d){var h=d.dir||d.root,f=d.base||(d.name||"")+(d.ext||"");return h?h===d.root?h+f:h+g+f:f}var k={resolve:function(){for(var d="",h=!1,f,n=arguments.length-1;n>=-1&&!h;n--){var l;n>=0?l=arguments[n]:(f===void 0&&(f=S.cwd()),l=f),w(l),l.length!==0&&(d=l+"/"+d,h=l.charCodeAt(0)===47)}return d=R(d,!h),h?d.length>0?"/"+d:"/":d.length>0?d:"."},normalize:function(d){if(w(d),d.length===0)return".";var h=d.charCodeAt(0)===47,f=d.charCodeAt(d.length-1)===47;return d=R(d,!h),d.length===0&&!h&&(d="."),d.length>0&&f&&(d+="/"),h?"/"+d:d},isAbsolute:function(d){return w(d),d.length>0&&d.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var d,h=0;h<arguments.length;++h){var f=arguments[h];w(f),f.length>0&&(d===void 0?d=f:d+="/"+f)}return d===void 0?".":k.normalize(d)},relative:function(d,h){if(w(d),w(h),d===h||(d=k.resolve(d),h=k.resolve(h),d===h))return"";for(var f=1;f<d.length&&d.charCodeAt(f)===47;++f);for(var n=d.length,l=n-f,e=1;e<h.length&&h.charCodeAt(e)===47;++e);for(var r=h.length,t=r-e,i=l<t?l:t,s=-1,u=0;u<=i;++u){if(u===i){if(t>i){if(h.charCodeAt(e+u)===47)return h.slice(e+u+1);if(u===0)return h.slice(e+u)}else l>i&&(d.charCodeAt(f+u)===47?s=u:u===0&&(s=0));break}var c=d.charCodeAt(f+u),a=h.charCodeAt(e+u);if(c!==a)break;c===47&&(s=u)}var o="";for(u=f+s+1;u<=n;++u)(u===n||d.charCodeAt(u)===47)&&(o.length===0?o+="..":o+="/..");return o.length>0?o+h.slice(e+s):(e+=s,h.charCodeAt(e)===47&&++e,h.slice(e))},_makeLong:function(d){return d},dirname:function(d){if(w(d),d.length===0)return".";for(var h=d.charCodeAt(0),f=h===47,n=-1,l=!0,e=d.length-1;e>=1;--e)if(h=d.charCodeAt(e),h===47){if(!l){n=e;break}}else l=!1;return n===-1?f?"/":".":f&&n===1?"//":d.slice(0,n)},basename:function(d,h){if(h!==void 0&&typeof h!="string")throw new TypeError('"ext" argument must be a string');w(d);var f=0,n=-1,l=!0,e;if(h!==void 0&&h.length>0&&h.length<=d.length){if(h.length===d.length&&h===d)return"";var r=h.length-1,t=-1;for(e=d.length-1;e>=0;--e){var i=d.charCodeAt(e);if(i===47){if(!l){f=e+1;break}}else t===-1&&(l=!1,t=e+1),r>=0&&(i===h.charCodeAt(r)?--r==-1&&(n=e):(r=-1,n=t))}return f===n?n=t:n===-1&&(n=d.length),d.slice(f,n)}else{for(e=d.length-1;e>=0;--e)if(d.charCodeAt(e)===47){if(!l){f=e+1;break}}else n===-1&&(l=!1,n=e+1);return n===-1?"":d.slice(f,n)}},extname:function(d){w(d);for(var h=-1,f=0,n=-1,l=!0,e=0,r=d.length-1;r>=0;--r){var t=d.charCodeAt(r);if(t===47){if(!l){f=r+1;break}continue}n===-1&&(l=!1,n=r+1),t===46?h===-1?h=r:e!==1&&(e=1):h!==-1&&(e=-1)}return h===-1||n===-1||e===0||e===1&&h===n-1&&h===f+1?"":d.slice(h,n)},format:function(d){if(d===null||typeof d!="object")throw new TypeError('Parameter "pathObject" must be an object, not '+typeof d);return T("/",d)},parse:function(d){w(d);var h={root:"",dir:"",base:"",ext:"",name:""};if(d.length===0)return h;var f=d.charCodeAt(0),n=f===47,l;n?(h.root="/",l=1):l=0;for(var e=-1,r=0,t=-1,i=!0,s=d.length-1,u=0;s>=l;--s){if(f=d.charCodeAt(s),f===47){if(!i){r=s+1;break}continue}t===-1&&(i=!1,t=s+1),f===46?e===-1?e=s:u!==1&&(u=1):e!==-1&&(u=-1)}return e===-1||t===-1||u===0||u===1&&e===t-1&&e===r+1?t!==-1&&(r===0&&n?h.base=h.name=d.slice(1,t):h.base=h.name=d.slice(r,t)):(r===0&&n?(h.name=d.slice(1,e),h.base=d.slice(1,t)):(h.name=d.slice(r,e),h.base=d.slice(r,t)),h.ext=d.slice(e,t)),r>0?h.dir=d.slice(0,r-1):n&&(h.dir="/"),h},sep:"/",delimiter:":",posix:null};C.exports=k},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0}),y.replaceBase=d,y.replaceCanonical=h,y.replaceMeta=f,y.replaceLinks=n,y.substitute=l;var S=m(0),w=m(5),R=g(w),T=m(4),k=g(T);function g(e){return e&&e.__esModule?e:{default:e}}function d(e,r){var t,i,s=r.url,u=s.indexOf("://")>-1;!e||(i=(0,S.qs)(e,"head"),t=(0,S.qs)(i,"base"),t||(t=e.createElement("base"),i.insertBefore(t,i.firstChild)),!u&&window&&window.location&&(s=window.location.origin+s),t.setAttribute("href",s))}function h(e,r){var t,i,s=r.canonical;!e||(t=(0,S.qs)(e,"head"),i=(0,S.qs)(t,"link[rel='canonical']"),i?i.setAttribute("href",s):(i=e.createElement("link"),i.setAttribute("rel","canonical"),i.setAttribute("href",s),t.appendChild(i)))}function f(e,r){var t,i,s=r.idref;!e||(t=(0,S.qs)(e,"head"),i=(0,S.qs)(t,"link[property='dc.identifier']"),i?i.setAttribute("content",s):(i=e.createElement("meta"),i.setAttribute("name","dc.identifier"),i.setAttribute("content",s),t.appendChild(i)))}function n(e,r){var t=e.querySelectorAll("a[href]");if(!!t.length)for(var i=(0,S.qs)(e.ownerDocument,"base"),s=i?i.getAttribute("href"):void 0,u=function(a){var o=a.getAttribute("href");if(o.indexOf("mailto:")!==0){var v=o.indexOf("://")>-1,p=new R.default(o,s);v?a.setAttribute("target","_blank"):a.onclick=function(){return p&&p.hash?r(p.Path.path+p.hash):r(p?p.Path.path:o),!1}}}.bind(this),c=0;c<t.length;c++)u(t[c])}function l(e,r,t){return r.forEach(function(i,s){i&&t[s]&&(e=e.replace(new RegExp(i,"g"),t[s]))}),e}},function(C,y){var m;m=function(){return this}();try{m=m||Function("return this")()||(0,eval)("this")}catch(S){typeof window=="object"&&(m=window)}C.exports=m},function(C,y,m){"use strict";var S=m(34)();C.exports=function(w){return w!==S&&w!==null}},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function T(k,g){for(var d=0;d<g.length;d++){var h=g[d];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(k,h.key,h)}}return function(k,g,d){return g&&T(k.prototype,g),d&&T(k,d),k}}();function w(T,k){if(!(T instanceof k))throw new TypeError("Cannot call a class as a function")}var R=function(){function T(k){w(this,T),this.context=k||this,this.hooks=[]}return S(T,[{key:"register",value:function(){for(var g=0;g<arguments.length;++g)if(typeof arguments[g]=="function")this.hooks.push(arguments[g]);else for(var d=0;d<arguments[g].length;++d)this.hooks.push(arguments[g][d])}},{key:"trigger",value:function(){var g=arguments,d=this.context,h=[];return this.hooks.forEach(function(f){var n=f.apply(d,g);n&&typeof n.then=="function"&&h.push(n)}),Promise.all(h)}},{key:"list",value:function(){return this.hooks}},{key:"clear",value:function(){return this.hooks=[]}}]),T}();y.default=R,C.exports=y.default},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=m(0),w=m(4),R=T(w);function T(g){return g&&g.__esModule?g:{default:g}}function k(g,d,h,f){var n=typeof window!="undefined"?window.URL:!1,l=n?"blob":"arraybuffer",e=new S.defer,r=new XMLHttpRequest,t=XMLHttpRequest.prototype,i;"overrideMimeType"in t||Object.defineProperty(t,"overrideMimeType",{value:function(){}}),h&&(r.withCredentials=!0),r.onreadystatechange=u,r.onerror=s,r.open("GET",g,!0);for(i in f)r.setRequestHeader(i,f[i]);d=="json"&&r.setRequestHeader("Accept","application/json"),d||(d=new R.default(g).extension),d=="blob"&&(r.responseType=l),(0,S.isXml)(d)&&r.overrideMimeType("text/xml"),d=="xhtml",d=="html"||d=="htm",d=="binary"&&(r.responseType="arraybuffer"),r.send();function s(c){e.reject(c)}function u(){if(this.readyState===XMLHttpRequest.DONE){var c=!1;if((this.responseType===""||this.responseType==="document")&&(c=this.responseXML),this.status===200||c){var a;if(!this.response&&!c)return e.reject({status:this.status,message:"Empty Response",stack:new Error().stack}),e.promise;if(this.status===403)return e.reject({status:this.status,response:this.response,message:"Forbidden",stack:new Error().stack}),e.promise;c?a=this.responseXML:(0,S.isXml)(d)?a=(0,S.parse)(this.response,"text/xml"):d=="xhtml"?a=(0,S.parse)(this.response,"application/xhtml+xml"):d=="html"||d=="htm"?a=(0,S.parse)(this.response,"text/html"):d=="json"?a=JSON.parse(this.response):d=="blob"?n?a=this.response:a=new Blob([this.response]):a=this.response,e.resolve(a)}else e.reject({status:this.status,message:this.response,stack:new Error().stack})}}return e.promise}y.default=k,C.exports=y.default},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0}),y.Task=void 0;var S=function(){function g(d,h){for(var f=0;f<h.length;f++){var n=h[f];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(d,n.key,n)}}return function(d,h,f){return h&&g(d.prototype,h),f&&g(d,f),d}}(),w=m(0);function R(g,d){if(!(g instanceof d))throw new TypeError("Cannot call a class as a function")}var T=function(){function g(d){R(this,g),this._q=[],this.context=d,this.tick=w.requestAnimationFrame,this.running=!1,this.paused=!1}return S(g,[{key:"enqueue",value:function(){var h,f,n,l=[].shift.call(arguments),e=arguments;if(!l)throw new Error("No Task Provided");return typeof l=="function"?(h=new w.defer,f=h.promise,n={task:l,args:e,deferred:h,promise:f}):n={promise:l},this._q.push(n),this.paused==!1&&!this.running&&this.run(),n.promise}},{key:"dequeue",value:function(){var h,f,n;if(this._q.length&&!this.paused){if(h=this._q.shift(),f=h.task,f)return n=f.apply(this.context,h.args),n&&typeof n.then=="function"?n.then(function(){h.deferred.resolve.apply(this.context,arguments)}.bind(this),function(){h.deferred.reject.apply(this.context,arguments)}.bind(this)):(h.deferred.resolve.apply(this.context,n),h.promise);if(h.promise)return h.promise}else return h=new w.defer,h.deferred.resolve(),h.promise}},{key:"dump",value:function(){for(;this._q.length;)this.dequeue()}},{key:"run",value:function(){var h=this;return this.running||(this.running=!0,this.defered=new w.defer),this.tick.call(window,function(){h._q.length?h.dequeue().then(function(){this.run()}.bind(h)):(h.defered.resolve(),h.running=void 0)}),this.paused==!0&&(this.paused=!1),this.defered.promise}},{key:"flush",value:function(){if(this.running)return this.running;if(this._q.length)return this.running=this.dequeue().then(function(){return this.running=void 0,this.flush()}.bind(this)),this.running}},{key:"clear",value:function(){this._q=[]}},{key:"length",value:function(){return this._q.length}},{key:"pause",value:function(){this.paused=!0}},{key:"stop",value:function(){this._q=[],this.running=!1,this.paused=!0}}]),g}(),k=function g(d,h,f){return R(this,g),function(){var n=this,l=arguments||[];return new Promise(function(e,r){var t=function(s,u){!s&&u?r(u):e(s)};l.push(t),d.apply(f||n,l)})}};y.default=T,y.Task=k},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function c(a,o){for(var v=0;v<o.length;v++){var p=o[v];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(a,p.key,p)}}return function(a,o,v){return o&&c(a.prototype,o),v&&c(a,v),a}}(),w=m(2),R=l(w),T=m(0),k=m(1),g=l(k),d=m(19),h=l(d),f=m(7),n=m(3);function l(c){return c&&c.__esModule?c:{default:c}}function e(c,a){if(!(c instanceof a))throw new TypeError("Cannot call a class as a function")}var r=/Chrome/.test(navigator.userAgent),t=!r&&/AppleWebKit/.test(navigator.userAgent),i=1,s=3,u=function(){function c(a,o,v,p){e(this,c),this.epubcfi=new g.default,this.document=a,this.documentElement=this.document.documentElement,this.content=o||this.document.body,this.window=this.document.defaultView,this._size={width:0,height:0},this.sectionIndex=p||0,this.cfiBase=v||"",this.epubReadingSystem("epub.js",ePub.VERSION),this.listeners()}return S(c,[{key:"width",value:function(o){var v=this.content;return o&&(0,T.isNumber)(o)&&(o=o+"px"),o&&(v.style.width=o),this.window.getComputedStyle(v).width}},{key:"height",value:function(o){var v=this.content;return o&&(0,T.isNumber)(o)&&(o=o+"px"),o&&(v.style.height=o),this.window.getComputedStyle(v).height}},{key:"contentWidth",value:function(o){var v=this.content||this.document.body;return o&&(0,T.isNumber)(o)&&(o=o+"px"),o&&(v.style.width=o),this.window.getComputedStyle(v).width}},{key:"contentHeight",value:function(o){var v=this.content||this.document.body;return o&&(0,T.isNumber)(o)&&(o=o+"px"),o&&(v.style.height=o),this.window.getComputedStyle(v).height}},{key:"textWidth",value:function(){var o=void 0,v=this.document.createRange(),p=this.content||this.document.body,b=(0,T.borders)(p);return v.selectNodeContents(p),o=v.getBoundingClientRect().width,b&&b.width&&(o+=b.width),Math.round(o)}},{key:"textHeight",value:function(){var o=void 0,v=this.document.createRange(),p=this.content||this.document.body,b=(0,T.borders)(p);return v.selectNodeContents(p),o=v.getBoundingClientRect().height,o&&b.height&&(o+=b.height),Math.round(o)}},{key:"scrollWidth",value:function(){var o=this.documentElement.scrollWidth;return o}},{key:"scrollHeight",value:function(){var o=this.documentElement.scrollHeight;return o}},{key:"overflow",value:function(o){return o&&(this.documentElement.style.overflow=o),this.window.getComputedStyle(this.documentElement).overflow}},{key:"overflowX",value:function(o){return o&&(this.documentElement.style.overflowX=o),this.window.getComputedStyle(this.documentElement).overflowX}},{key:"overflowY",value:function(o){return o&&(this.documentElement.style.overflowY=o),this.window.getComputedStyle(this.documentElement).overflowY}},{key:"css",value:function(o,v,p){var b=this.content||this.document.body;return v&&b.style.setProperty(o,v,p?"important":""),this.window.getComputedStyle(b)[o]}},{key:"viewport",value:function(o){var v,p,b,E,L,A,B=this.document.querySelector("meta[name='viewport']"),D={width:void 0,height:void 0,scale:void 0,minimum:void 0,maximum:void 0,scalable:void 0},V=[],N={};if(B&&B.hasAttribute("content")){var z=B.getAttribute("content"),_=z.match(/width\s*=\s*([^,]*)/),P=z.match(/height\s*=\s*([^,]*)/),x=z.match(/initial-scale\s*=\s*([^,]*)/),F=z.match(/minimum-scale\s*=\s*([^,]*)/),G=z.match(/maximum-scale\s*=\s*([^,]*)/),X=z.match(/user-scalable\s*=\s*([^,]*)/);_&&_.length&&typeof _[1]!="undefined"&&(D.width=_[1]),P&&P.length&&typeof P[1]!="undefined"&&(D.height=P[1]),x&&x.length&&typeof x[1]!="undefined"&&(D.scale=x[1]),F&&F.length&&typeof F[1]!="undefined"&&(D.minimum=F[1]),G&&G.length&&typeof G[1]!="undefined"&&(D.maximum=G[1]),X&&X.length&&typeof X[1]!="undefined"&&(D.scalable=X[1])}return N=(0,T.defaults)(o||{},D),o&&(N.width&&V.push("width="+N.width),N.height&&V.push("height="+N.height),N.scale&&V.push("initial-scale="+N.scale),N.scalable==="no"?(V.push("minimum-scale="+N.scale),V.push("maximum-scale="+N.scale),V.push("user-scalable="+N.scalable)):(N.scalable&&V.push("user-scalable="+N.scalable),N.minimum&&V.push("minimum-scale="+N.minimum),N.maximum&&V.push("minimum-scale="+N.maximum)),B||(B=this.document.createElement("meta"),B.setAttribute("name","viewport"),this.document.querySelector("head").appendChild(B)),B.setAttribute("content",V.join(", ")),this.window.scrollTo(0,0)),N}},{key:"expand",value:function(){this.emit(n.EVENTS.CONTENTS.EXPAND)}},{key:"listeners",value:function(){this.imageLoadListeners(),this.mediaQueryListeners(),this.addEventListeners(),this.addSelectionListeners(),this.resizeListeners(),this.linksHandler()}},{key:"removeListeners",value:function(){this.removeEventListeners(),this.removeSelectionListeners(),clearTimeout(this.expanding)}},{key:"resizeCheck",value:function(){var o=this.textWidth(),v=this.textHeight();(o!=this._size.width||v!=this._size.height)&&(this._size={width:o,height:v},this.onResize&&this.onResize(this._size),this.emit(n.EVENTS.CONTENTS.RESIZE,this._size))}},{key:"resizeListeners",value:function(){var o,v;clearTimeout(this.expanding),requestAnimationFrame(this.resizeCheck.bind(this)),this.expanding=setTimeout(this.resizeListeners.bind(this),350)}},{key:"transitionListeners",value:function(){var o=this.content;o.style.transitionProperty="font, font-size, font-size-adjust, font-stretch, font-variation-settings, font-weight, width, height",o.style.transitionDuration="0.001ms",o.style.transitionTimingFunction="linear",o.style.transitionDelay="0",this.document.addEventListener("transitionend",this.resizeCheck.bind(this))}},{key:"mediaQueryListeners",value:function(){for(var o=this.document.styleSheets,v=function(A){A.matches&&!this._expanding&&setTimeout(this.expand.bind(this),1)}.bind(this),p=0;p<o.length;p+=1){var b;try{b=o[p].cssRules}catch(A){return}if(!b)return;for(var E=0;E<b.length;E+=1)if(b[E].media){var L=this.window.matchMedia(b[E].media.mediaText);L.addListener(v)}}}},{key:"resizeObservers",value:function(){var o=this;this.observer=new MutationObserver(function(p){o.resizeCheck()});var v={attributes:!0,childList:!0,characterData:!0,subtree:!0};this.observer.observe(this.document,v)}},{key:"imageLoadListeners",value:function(o){for(var v=this.document.querySelectorAll("img"),p,b=0;b<v.length;b++)p=v[b],typeof p.naturalWidth!="undefined"&&p.naturalWidth===0&&(p.onload=this.expand.bind(this))}},{key:"fontLoadListeners",value:function(o){!this.document||!this.document.fonts||this.document.fonts.ready.then(function(){this.resizeCheck()}.bind(this))}},{key:"root",value:function(){return this.document?this.document.documentElement:null}},{key:"locationOf",value:function(o,v){var p,b={left:0,top:0};if(!this.document)return b;if(this.epubcfi.isCfiString(o)){var E=new g.default(o).toRange(this.document,v);if(E)if(E.startContainer.nodeType===Node.ELEMENT_NODE)p=E.startContainer.getBoundingClientRect(),b.left=p.left,b.top=p.top;else if(t){var L=E.startContainer,A=new Range;try{L.nodeType===i?p=L.getBoundingClientRect():E.startOffset+2<L.length?(A.setStart(L,E.startOffset),A.setEnd(L,E.startOffset+2),p=A.getBoundingClientRect()):E.startOffset-2>0?(A.setStart(L,E.startOffset-2),A.setEnd(L,E.startOffset),p=A.getBoundingClientRect()):p=L.parentNode.getBoundingClientRect()}catch(V){console.error(V,V.stack)}}else p=E.getBoundingClientRect()}else if(typeof o=="string"&&o.indexOf("#")>-1){var B=o.substring(o.indexOf("#")+1),D=this.document.getElementById(B);D&&(p=D.getBoundingClientRect())}return p&&(b.left=p.left,b.top=p.top),b}},{key:"addStylesheet",value:function(o){return new Promise(function(v,p){var b,E=!1;if(!this.document){v(!1);return}if(b=this.document.querySelector("link[href='"+o+"']"),b){v(!0);return}b=this.document.createElement("link"),b.type="text/css",b.rel="stylesheet",b.href=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:"addStylesheetRules",value:function(o){var v,p,b="epubjs-inserted-css";if(!(!this.document||!o||o.length===0))if(v=this.document.getElementById("#"+b),v||(v=this.document.createElement("style"),v.id=b),this.document.head.appendChild(v),p=v.sheet,Object.prototype.toString.call(o)==="[object Array]")for(var E=0,L=o.length;E<L;E++){var A=1,B=o[E],D=o[E][0],V="";Object.prototype.toString.call(B[1][0])==="[object Array]"&&(B=B[1],A=0);for(var N=B.length;A<N;A++){var z=B[A];V+=z[0]+":"+z[1]+(z[2]?" !important":"")+`;
|
|
`}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,p,b,E){var L=new h.default(v,E);return L.page(this,o,p,b)}},{key:"linksHandler",value:function(){var o=this;(0,f.replaceLinks)(this.content,function(v){o.emit(n.EVENTS.CONTENTS.LINK_CLICKED,v)})}},{key:"writingMode",value:function(o){var v=(0,T.prefixed)("writing-mode");return o&&this.documentElement&&(this.documentElement.style[v]=o),this.window.getComputedStyle(this.documentElement)[v]||""}},{key:"layoutStyle",value:function(o){return o&&(this._layoutStyle=o,navigator.epubReadingSystem.layoutStyle=this._layoutStyle),this._layoutStyle||"paginated"}},{key:"epubReadingSystem",value:function(o,v){return navigator.epubReadingSystem={name:o,version:v,layoutStyle:this.layoutStyle(),hasFeature:function(b){switch(b){case"dom-manipulation":return!0;case"layout-changes":return!0;case"touch-events":return!0;case"mouse-events":return!0;case"keyboard-events":return!0;case"spine-scripting":return!1;default:return!1}}},navigator.epubReadingSystem}},{key:"destroy",value:function(){this.observer&&this.observer.disconnect(),this.document.removeEventListener("transitionend",this.resizeCheck),this.removeListeners()}}],[{key:"listenedEvents",get:function(){return n.DOM_EVENTS}}]),c}();(0,R.default)(u.prototype),y.default=u,C.exports=y.default},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function u(c,a){for(var o=0;o<a.length;o++){var v=a[o];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(c,v.key,v)}}return function(c,a,o){return a&&u(c.prototype,a),o&&u(c,o),c}}(),w=m(2),R=t(w),T=m(0),k=m(19),g=t(k),d=m(12),h=t(d),f=m(56),n=t(f),l=m(66),e=t(l),r=m(3);function t(u){return u&&u.__esModule?u:{default:u}}function i(u,c){if(!(u instanceof c))throw new TypeError("Cannot call a class as a function")}var s=function(){function u(c){i(this,u),this.name="default",this.View=c.view,this.request=c.request,this.renditionQueue=c.queue,this.q=new h.default(this),this.settings=(0,T.extend)(this.settings||{},{infinite:!0,hidden:!1,width:void 0,height:void 0,axis:void 0,flow:"scrolled",ignoreClass:""}),(0,T.extend)(this.settings,c.settings||{}),this.viewSettings={ignoreClass:this.settings.ignoreClass,axis:this.settings.axis,flow:this.settings.flow,layout:this.layout,method:this.settings.method,width:0,height:0,forceEvenPages:!0},this.rendered=!1}return S(u,[{key:"render",value:function(a,o){var v=a.tagName;v&&(v.toLowerCase()=="body"||v.toLowerCase()=="html")&&(this.fullsize=!0),this.fullsize&&(this.settings.overflow="visible",this.overflow=this.settings.overflow),this.settings.size=o,this.stage=new n.default({width:o.width,height:o.height,overflow:this.overflow,hidden:this.settings.hidden,axis:this.settings.axis,fullsize:this.fullsize,direction:this.settings.direction}),this.stage.attachTo(a),this.container=this.stage.getContainer(),this.views=new e.default(this.container),this._bounds=this.bounds(),this._stageSize=this.stage.size(),this.viewSettings.width=this._stageSize.width,this.viewSettings.height=this._stageSize.height,this.stage.onResize(this.onResized.bind(this)),this.stage.onOrientationChange(this.onOrientationChange.bind(this)),this.addEventListeners(),this.layout&&this.updateLayout(),this.rendered=!0}},{key:"addEventListeners",value:function(){var a;window.addEventListener("unload",function(o){this.destroy()}.bind(this)),this.fullsize?a=window:a=this.container,a.addEventListener("scroll",this.onScroll.bind(this))}},{key:"removeEventListeners",value:function(){var a;this.fullsize?a=window:a=this.container,a.removeEventListener("scroll",this.onScroll.bind(this))}},{key:"destroy",value:function(){clearTimeout(this.orientationTimeout),clearTimeout(this.resizeTimeout),clearTimeout(this.afterScrolled),this.clear(),this.removeEventListeners(),this.stage.destroy(),this.rendered=!1}},{key:"onOrientationChange",value:function(a){var o=window,v=o.orientation;this.resize(),clearTimeout(this.orientationTimeout),this.orientationTimeout=setTimeout(function(){this.orientationTimeout=void 0,this.resize(),this.emit(r.EVENTS.MANAGERS.ORIENTATION_CHANGE,v)}.bind(this),500)}},{key:"onResized",value:function(a){this.resize()}},{key:"resize",value:function(a,o){var v=this.stage.size(a,o);if(this.winBounds=(0,T.windowBounds)(),this.orientationTimeout&&this.winBounds.width===this.winBounds.height){this._stageSize=void 0;return}this._stageSize&&this._stageSize.width===v.width&&this._stageSize.height===v.height||(this._stageSize=v,this._bounds=this.bounds(),this.clear(),this.viewSettings.width=this._stageSize.width,this.viewSettings.height=this._stageSize.height,this.updateLayout(),this.emit(r.EVENTS.MANAGERS.RESIZED,{width:this._stageSize.width,height:this._stageSize.height}))}},{key:"createView",value:function(a){return new this.View(a,this.viewSettings)}},{key:"display",value:function(a,o){var v=new T.defer,p=v.promise;(o===a.href||(0,T.isNumber)(o))&&(o=void 0);var b=this.views.find(a);if(b&&a){var E=b.offset();if(this.settings.direction==="ltr")this.scrollTo(E.left,E.top,!0);else{var L=b.width();this.scrollTo(E.left+L,E.top,!0)}if(o){var A=b.locationOf(o);this.moveTo(A)}return v.resolve(),p}return this.clear(),this.add(a).then(function(B){if(o){var D=B.locationOf(o);this.moveTo(D)}}.bind(this),function(B){v.reject(B)}).then(function(){var B;if(this.layout.name==="pre-paginated"&&this.layout.divisor>1&&(B=a.next(),B))return this.add(B)}.bind(this)).then(function(){this.views.show(),v.resolve()}.bind(this)),p}},{key:"afterDisplayed",value:function(a){this.emit(r.EVENTS.MANAGERS.ADDED,a)}},{key:"afterResized",value:function(a){this.emit(r.EVENTS.MANAGERS.RESIZE,a.section)}},{key:"moveTo",value:function(a){var o=0,v=0;this.isPaginated?(o=Math.floor(a.left/this.layout.delta)*this.layout.delta,o+this.layout.delta>this.container.scrollWidth&&(o=this.container.scrollWidth-this.layout.delta)):v=a.top,this.scrollTo(o,v,!0)}},{key:"add",value:function(a){var o=this,v=this.createView(a);return this.views.append(v),v.onDisplayed=this.afterDisplayed.bind(this),v.onResize=this.afterResized.bind(this),v.on(r.EVENTS.VIEWS.AXIS,function(p){o.updateAxis(p)}),v.display(this.request)}},{key:"append",value:function(a){var o=this,v=this.createView(a);return this.views.append(v),v.onDisplayed=this.afterDisplayed.bind(this),v.onResize=this.afterResized.bind(this),v.on(r.EVENTS.VIEWS.AXIS,function(p){o.updateAxis(p)}),v.display(this.request)}},{key:"prepend",value:function(a){var o=this,v=this.createView(a);return v.on(r.EVENTS.VIEWS.RESIZED,function(p){o.counter(p)}),this.views.prepend(v),v.onDisplayed=this.afterDisplayed.bind(this),v.onResize=this.afterResized.bind(this),v.on(r.EVENTS.VIEWS.AXIS,function(p){o.updateAxis(p)}),v.display(this.request)}},{key:"counter",value:function(a){this.settings.axis==="vertical"?this.scrollBy(0,a.heightDelta,!0):this.scrollBy(a.widthDelta,0,!0)}},{key:"next",value:function(){var a,o,v=this.settings.direction;if(!!this.views.length){if(this.isPaginated&&this.settings.axis==="horizontal"&&(!v||v==="ltr"))this.scrollLeft=this.container.scrollLeft,o=this.container.scrollLeft+this.container.offsetWidth+this.layout.delta,o<=this.container.scrollWidth?this.scrollBy(this.layout.delta,0,!0):a=this.views.last().section.next();else if(this.isPaginated&&this.settings.axis==="horizontal"&&v==="rtl")this.scrollLeft=this.container.scrollLeft,o=this.container.scrollLeft,o>0?this.scrollBy(this.layout.delta,0,!0):a=this.views.last().section.next();else if(this.isPaginated&&this.settings.axis==="vertical"){this.scrollTop=this.container.scrollTop;var p=this.container.scrollTop+this.container.offsetHeight;p<this.container.scrollHeight?this.scrollBy(0,this.layout.height,!0):a=this.views.last().section.next()}else a=this.views.last().section.next();if(a)return this.clear(),this.append(a).then(function(){var b;if(this.layout.name==="pre-paginated"&&this.layout.divisor>1&&(b=a.next(),b))return this.append(b)}.bind(this),function(b){displaying.reject(b)}).then(function(){this.views.show()}.bind(this))}}},{key:"prev",value:function(){var a,o,v=this.settings.direction;if(!!this.views.length){if(this.isPaginated&&this.settings.axis==="horizontal"&&(!v||v==="ltr"))this.scrollLeft=this.container.scrollLeft,o=this.container.scrollLeft,o>0?this.scrollBy(-this.layout.delta,0,!0):a=this.views.first().section.prev();else if(this.isPaginated&&this.settings.axis==="horizontal"&&v==="rtl")this.scrollLeft=this.container.scrollLeft,o=this.container.scrollLeft+this.container.offsetWidth+this.layout.delta,o<=this.container.scrollWidth?this.scrollBy(-this.layout.delta,0,!0):a=this.views.first().section.prev();else if(this.isPaginated&&this.settings.axis==="vertical"){this.scrollTop=this.container.scrollTop;var p=this.container.scrollTop;p>0?this.scrollBy(0,-this.layout.height,!0):a=this.views.first().section.prev()}else a=this.views.first().section.prev();if(a)return this.clear(),this.prepend(a).then(function(){var b;if(this.layout.name==="pre-paginated"&&this.layout.divisor>1&&(b=a.prev(),b))return this.prepend(b)}.bind(this),function(b){displaying.reject(b)}).then(function(){this.isPaginated&&this.settings.axis==="horizontal"&&(this.settings.direction==="rtl"?this.scrollTo(0,0,!0):this.scrollTo(this.container.scrollWidth-this.layout.delta,0,!0)),this.views.show()}.bind(this))}}},{key:"current",value:function(){var a=this.visible();return a.length?a[a.length-1]:null}},{key:"clear",value:function(){this.views&&(this.views.hide(),this.scrollTo(0,0,!0),this.views.clear())}},{key:"currentLocation",value:function(){return this.settings.axis==="vertical"?this.location=this.scrolledLocation():this.location=this.paginatedLocation(),this.location}},{key:"scrolledLocation",value:function(){var a=this,o=this.visible(),v=this.container.getBoundingClientRect(),p=v.height<window.innerHeight?v.height:window.innerHeight,b=0,E=0;this.fullsize&&(b=window.scrollY);var L=o.map(function(A){var B=A.section,D=B.index,V=B.href,N=A.position(),z=A.height(),_=b+v.top-N.top+E,P=_+p-E;P>z&&(P=z,E=P-_);var x=a.layout.count(z,p).pages,F=Math.ceil(_/p),G=[],X=Math.ceil(P/p);G=[];for(var J=F;J<=X;J++){var K=J+1;G.push(K)}var H=a.mapping.page(A.contents,A.section.cfiBase,_,P);return{index:D,href:V,pages:G,totalPages:x,mapping:H}});return L}},{key:"paginatedLocation",value:function(){var a=this,o=this.visible(),v=this.container.getBoundingClientRect(),p=0,b=0;this.fullsize&&(p=window.scrollX);var E=o.map(function(L){var A=L.section,B=A.index,D=A.href,V=L.offset().left,N=L.position().left,z=L.width(),_=p+v.left-N+b,P=_+a.layout.width-b,x=a.mapping.page(L.contents,L.section.cfiBase,_,P),F=a.layout.count(z).pages,G=Math.floor(_/a.layout.pageWidth),X=[],J=Math.floor(P/a.layout.pageWidth);if(G<0&&(G=0,J=J+1),a.settings.direction==="rtl"){var K=G;G=F-J,J=F-K}for(var H=G+1;H<=J;H++){var U=H;X.push(U)}return{index:B,href:D,pages:X,totalPages:F,mapping:x}});return E}},{key:"isVisible",value:function(a,o,v,p){var b=a.position(),E=p||this.bounds();return this.settings.axis==="horizontal"&&b.right>E.left-o&&b.left<E.right+v?!0:this.settings.axis==="vertical"&&b.bottom>E.top-o&&b.top<E.bottom+v}},{key:"visible",value:function(){for(var a=this.bounds(),o=this.views.displayed(),v=o.length,p=[],b,E,L=0;L<v;L++)E=o[L],b=this.isVisible(E,0,0,a),b===!0&&p.push(E);return p}},{key:"scrollBy",value:function(a,o,v){var p=this.settings.direction==="rtl"?-1:1;v&&(this.ignore=!0),this.fullsize?window.scrollBy(a*p,o*p):(a&&(this.container.scrollLeft+=a*p),o&&(this.container.scrollTop+=o)),this.scrolled=!0}},{key:"scrollTo",value:function(a,o,v){v&&(this.ignore=!0),this.fullsize?window.scrollTo(a,o):(this.container.scrollLeft=a,this.container.scrollTop=o),this.scrolled=!0}},{key:"onScroll",value:function(){var a=void 0,o=void 0;this.fullsize?(a=window.scrollY,o=window.scrollX):(a=this.container.scrollTop,o=this.container.scrollLeft),this.scrollTop=a,this.scrollLeft=o,this.ignore?this.ignore=!1:(this.emit(r.EVENTS.MANAGERS.SCROLL,{top:a,left:o}),clearTimeout(this.afterScrolled),this.afterScrolled=setTimeout(function(){this.emit(r.EVENTS.MANAGERS.SCROLLED,{top:this.scrollTop,left:this.scrollLeft})}.bind(this),20))}},{key:"bounds",value:function(){var a;return a=this.stage.bounds(),a}},{key:"applyLayout",value:function(a){this.layout=a,this.updateLayout()}},{key:"updateLayout",value:function(){!this.stage||(this._stageSize=this.stage.size(),this.isPaginated?(this.layout.calculate(this._stageSize.width,this._stageSize.height,this.settings.gap),this.settings.offset=this.layout.delta):this.layout.calculate(this._stageSize.width,this._stageSize.height),this.viewSettings.width=this.layout.width,this.viewSettings.height=this.layout.height,this.setLayout(this.layout))}},{key:"setLayout",value:function(a){this.viewSettings.layout=a,this.mapping=new g.default(a.props,this.settings.direction,this.settings.axis),this.views&&this.views.forEach(function(o){o&&o.setLayout(a)})}},{key:"updateAxis",value:function(a,o){this.isPaginated||(a="vertical"),!(!o&&a===this.settings.axis)&&(this.settings.axis=a,this.stage&&this.stage.axis(a),this.viewSettings.axis=a,this.mapping&&(this.mapping=new g.default(this.layout.props,this.settings.direction,this.settings.axis)),this.layout&&(a==="vertical"?this.layout.spread("none"):this.layout.spread(this.layout.settings.spread)))}},{key:"updateFlow",value:function(a){var o=a==="paginated"||a==="auto";this.isPaginated=o,(a==="scrolled-doc"||a==="scrolled-continuous"||a==="scrolled")&&this.updateAxis("vertical"),this.viewSettings.flow=a,this.settings.overflow?this.overflow=this.settings.overflow:this.overflow=o?"hidden":"auto",this.updateLayout()}},{key:"getContents",value:function(){var a=[];return this.views&&this.views.forEach(function(o){var v=o&&o.contents;v&&a.push(v)}),a}},{key:"direction",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"ltr";this.settings.direction=a,this.stage&&this.stage.direction(a),this.viewSettings.direction=a,this.updateLayout()}},{key:"isRendered",value:function(){return this.rendered}}]),u}();(0,R.default)(s.prototype),y.default=s,C.exports=y.default},function(C,y){function m(S){var w=typeof S;return S!=null&&(w=="object"||w=="function")}C.exports=m},function(C,y){C.exports=oe},function(C,y,m){"use strict";var S={application:{ecmascript:["es","ecma"],javascript:"js",ogg:"ogx",pdf:"pdf",postscript:["ps","ai","eps","epsi","epsf","eps2","eps3"],"rdf+xml":"rdf",smil:["smi","smil"],"xhtml+xml":["xhtml","xht"],xml:["xml","xsl","xsd","opf","ncx"],zip:"zip","x-httpd-eruby":"rhtml","x-latex":"latex","x-maker":["frm","maker","frame","fm","fb","book","fbdoc"],"x-object":"o","x-shockwave-flash":["swf","swfl"],"x-silverlight":"scr","epub+zip":"epub","font-tdpfr":"pfr","inkml+xml":["ink","inkml"],json:"json","jsonml+json":"jsonml","mathml+xml":"mathml","metalink+xml":"metalink",mp4:"mp4s","omdoc+xml":"omdoc",oxps:"oxps","vnd.amazon.ebook":"azw",widget:"wgt","x-dtbook+xml":"dtb","x-dtbresource+xml":"res","x-font-bdf":"bdf","x-font-ghostscript":"gsf","x-font-linux-psf":"psf","x-font-otf":"otf","x-font-pcf":"pcf","x-font-snf":"snf","x-font-ttf":["ttf","ttc"],"x-font-type1":["pfa","pfb","pfm","afm"],"x-font-woff":"woff","x-mobipocket-ebook":["prc","mobi"],"x-mspublisher":"pub","x-nzb":"nzb","x-tgif":"obj","xaml+xml":"xaml","xml-dtd":"dtd","xproc+xml":"xpl","xslt+xml":"xslt","internet-property-stream":"acx","x-compress":"z","x-compressed":"tgz","x-gzip":"gz"},audio:{flac:"flac",midi:["mid","midi","kar","rmi"],mpeg:["mpga","mpega","mp2","mp3","m4a","mp2a","m2a","m3a"],mpegurl:"m3u",ogg:["oga","ogg","spx"],"x-aiff":["aif","aiff","aifc"],"x-ms-wma":"wma","x-wav":"wav",adpcm:"adp",mp4:"mp4a",webm:"weba","x-aac":"aac","x-caf":"caf","x-matroska":"mka","x-pn-realaudio-plugin":"rmp",xm:"xm",mid:["mid","rmi"]},image:{gif:"gif",ief:"ief",jpeg:["jpeg","jpg","jpe"],pcx:"pcx",png:"png","svg+xml":["svg","svgz"],tiff:["tiff","tif"],"x-icon":"ico",bmp:"bmp",webp:"webp","x-pict":["pic","pct"],"x-tga":"tga","cis-cod":"cod"},text:{"cache-manifest":["manifest","appcache"],css:"css",csv:"csv",html:["html","htm","shtml","stm"],mathml:"mml",plain:["txt","text","brf","conf","def","list","log","in","bas"],richtext:"rtx","tab-separated-values":"tsv","x-bibtex":"bib"},video:{mpeg:["mpeg","mpg","mpe","m1v","m2v","mp2","mpa","mpv2"],mp4:["mp4","mp4v","mpg4"],quicktime:["qt","mov"],ogg:"ogv","vnd.mpegurl":["mxu","m4u"],"x-flv":"flv","x-la-asf":["lsf","lsx"],"x-mng":"mng","x-ms-asf":["asf","asx","asr"],"x-ms-wm":"wm","x-ms-wmv":"wmv","x-ms-wmx":"wmx","x-ms-wvx":"wvx","x-msvideo":"avi","x-sgi-movie":"movie","x-matroska":["mpv","mkv","mk3d","mks"],"3gpp2":"3g2",h261:"h261",h263:"h263",h264:"h264",jpeg:"jpgv",jpm:["jpm","jpgm"],mj2:["mj2","mjp2"],"vnd.ms-playready.media.pyv":"pyv","vnd.uvvu.mp4":["uvu","uvvu"],"vnd.vivo":"viv",webm:"webm","x-f4v":"f4v","x-m4v":"m4v","x-ms-vob":"vob","x-smv":"smv"}},w=function(){var k,g,d,h,f={};for(k in S)if(S.hasOwnProperty(k)){for(g in S[k])if(S[k].hasOwnProperty(g))if(d=S[k][g],typeof d=="string")f[d]=k+"/"+g;else for(h=0;h<d.length;h++)f[d[h]]=k+"/"+g}return f}(),R="text/plain";function T(k){return k&&w[k.split(".").pop().toLowerCase()]||R}C.exports={lookup:T}},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(N){return typeof N}:function(N){return N&&typeof Symbol=="function"&&N.constructor===Symbol&&N!==Symbol.prototype?"symbol":typeof N},w=function(){function N(z,_){for(var P=0;P<_.length;P++){var x=_[P];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(z,x.key,x)}}return function(z,_,P){return _&&N(z.prototype,_),P&&N(z,P),z}}(),R=m(2),T=B(R),k=m(0),g=m(10),d=B(g),h=m(1),f=B(h),n=m(12),l=B(n),e=m(50),r=B(e),t=m(51),i=B(t),s=m(13),u=B(s),c=m(52),a=B(c),o=m(3),v=m(20),p=B(v),b=m(14),E=B(b),L=m(24),A=B(L);function B(N){return N&&N.__esModule?N:{default:N}}function D(N,z){if(!(N instanceof z))throw new TypeError("Cannot call a class as a function")}var V=function(){function N(z,_){D(this,N),this.settings=(0,k.extend)(this.settings||{},{width:null,height:null,ignoreClass:"",manager:"default",view:"iframe",flow:null,layout:null,spread:null,minSpreadWidth:800,stylesheet:null,script:null}),(0,k.extend)(this.settings,_),S(this.settings.manager)==="object"&&(this.manager=this.settings.manager),this.book=z,this.hooks={},this.hooks.display=new d.default(this),this.hooks.serialize=new d.default(this),this.hooks.content=new d.default(this),this.hooks.unloaded=new d.default(this),this.hooks.layout=new d.default(this),this.hooks.render=new d.default(this),this.hooks.show=new d.default(this),this.hooks.content.register(this.handleLinks.bind(this)),this.hooks.content.register(this.passEvents.bind(this)),this.hooks.content.register(this.adjustImages.bind(this)),this.book.spine.hooks.content.register(this.injectIdentifier.bind(this)),this.settings.stylesheet&&this.book.spine.hooks.content.register(this.injectStylesheet.bind(this)),this.settings.script&&this.book.spine.hooks.content.register(this.injectScript.bind(this)),this.themes=new i.default(this),this.annotations=new a.default(this),this.epubcfi=new f.default,this.q=new l.default(this),this.location=void 0,this.q.enqueue(this.book.opened),this.starting=new k.defer,this.started=this.starting.promise,this.q.enqueue(this.start)}return w(N,[{key:"setManager",value:function(_){this.manager=_}},{key:"requireManager",value:function(_){var P;return typeof _=="string"&&_==="default"?P=E.default:typeof _=="string"&&_==="continuous"?P=A.default:P=_,P}},{key:"requireView",value:function(_){var P;return typeof _=="string"&&_==="iframe"?P=p.default:P=_,P}},{key:"start",value:function(){this.manager||(this.ViewManager=this.requireManager(this.settings.manager),this.View=this.requireView(this.settings.view),this.manager=new this.ViewManager({view:this.View,queue:this.q,request:this.book.load.bind(this.book),settings:this.settings})),this.direction(this.book.package.metadata.direction),this.settings.globalLayoutProperties=this.determineLayoutProperties(this.book.package.metadata),this.flow(this.settings.globalLayoutProperties.flow),this.layout(this.settings.globalLayoutProperties),this.manager.on(o.EVENTS.MANAGERS.ADDED,this.afterDisplayed.bind(this)),this.manager.on(o.EVENTS.MANAGERS.REMOVED,this.afterRemoved.bind(this)),this.manager.on(o.EVENTS.MANAGERS.RESIZED,this.onResized.bind(this)),this.manager.on(o.EVENTS.MANAGERS.ORIENTATION_CHANGE,this.onOrientationChange.bind(this)),this.manager.on(o.EVENTS.MANAGERS.SCROLLED,this.reportLocation.bind(this)),this.emit(o.EVENTS.RENDITION.STARTED),this.starting.resolve()}},{key:"attachTo",value:function(_){return this.q.enqueue(function(){this.manager.render(_,{width:this.settings.width,height:this.settings.height}),this.emit(o.EVENTS.RENDITION.ATTACHED)}.bind(this))}},{key:"display",value:function(_){return this.displaying&&this.displaying.resolve(),this.q.enqueue(this._display,_)}},{key:"_display",value:function(_){var P=this;if(!!this.book){var x=this.epubcfi.isCfiString(_),F=new k.defer,G=F.promise,X,J;return this.displaying=F,this.book.locations.length()&&((0,k.isFloat)(_)||_==="1.0")&&(_=this.book.locations.cfiFromPercentage(parseFloat(_))),X=this.book.spine.get(_),X?(this.manager.display(X,_).then(function(){F.resolve(X),P.displaying=void 0,P.emit(o.EVENTS.RENDITION.DISPLAYED,X),P.reportLocation()},function(K){P.emit(o.EVENTS.RENDITION.DISPLAY_ERROR,K)}),G):(F.reject(new Error("No Section Found")),G)}}},{key:"afterDisplayed",value:function(_){var P=this;_.on(o.EVENTS.VIEWS.MARK_CLICKED,function(x,F){return P.triggerMarkEvent(x,F,_)}),this.hooks.render.trigger(_,this).then(function(){_.contents?P.hooks.content.trigger(_.contents,P).then(function(){P.emit(o.EVENTS.RENDITION.RENDERED,_.section,_)}):P.emit(o.EVENTS.RENDITION.RENDERED,_.section,_)})}},{key:"afterRemoved",value:function(_){var P=this;this.hooks.unloaded.trigger(_,this).then(function(){P.emit(o.EVENTS.RENDITION.REMOVED,_.section,_)})}},{key:"onResized",value:function(_){this.emit(o.EVENTS.RENDITION.RESIZED,{width:_.width,height:_.height}),this.location&&this.location.start&&this.display(this.location.start.cfi)}},{key:"onOrientationChange",value:function(_){this.emit(o.EVENTS.RENDITION.ORIENTATION_CHANGE,_)}},{key:"moveTo",value:function(_){this.manager.moveTo(_)}},{key:"resize",value:function(_,P){_&&(this.settings.width=_),P&&(this.settings.height=P),this.manager.resize(_,P)}},{key:"clear",value:function(){this.manager.clear()}},{key:"next",value:function(){return this.q.enqueue(this.manager.next.bind(this.manager)).then(this.reportLocation.bind(this))}},{key:"prev",value:function(){return this.q.enqueue(this.manager.prev.bind(this.manager)).then(this.reportLocation.bind(this))}},{key:"determineLayoutProperties",value:function(_){var P,x=this.settings.layout||_.layout||"reflowable",F=this.settings.spread||_.spread||"auto",G=this.settings.orientation||_.orientation||"auto",X=this.settings.flow||_.flow||"auto",J=_.viewport||"",K=this.settings.minSpreadWidth||_.minSpreadWidth||800,H=this.settings.direction||_.direction||"ltr";return(this.settings.width===0||this.settings.width>0)&&(this.settings.height===0||this.settings.height>0),P={layout:x,spread:F,orientation:G,flow:X,viewport:J,minSpreadWidth:K,direction:H},P}},{key:"flow",value:function(_){var P=_;(_==="scrolled"||_==="scrolled-doc"||_==="scrolled-continuous")&&(P="scrolled"),(_==="auto"||_==="paginated")&&(P="paginated"),this.settings.flow=_,this._layout&&this._layout.flow(P),this.manager&&this._layout&&this.manager.applyLayout(this._layout),this.manager&&this.manager.updateFlow(P),this.manager&&this.manager.isRendered()&&this.location&&(this.manager.clear(),this.display(this.location.start.cfi))}},{key:"layout",value:function(_){var P=this;return _&&(this._layout=new r.default(_),this._layout.spread(_.spread,this.settings.minSpreadWidth),this._layout.on(o.EVENTS.LAYOUT.UPDATED,function(x,F){P.emit(o.EVENTS.RENDITION.LAYOUT,x,F)})),this.manager&&this._layout&&this.manager.applyLayout(this._layout),this._layout}},{key:"spread",value:function(_,P){this._layout.spread(_,P),this.manager.isRendered()&&this.manager.updateLayout()}},{key:"direction",value:function(_){this.settings.direction=_||"ltr",this.manager&&this.manager.direction(this.settings.direction),this.manager&&this.manager.isRendered()&&this.location&&(this.manager.clear(),this.display(this.location.start.cfi))}},{key:"reportLocation",value:function(){return this.q.enqueue(function(){requestAnimationFrame(function(){var x=this.manager.currentLocation();if(x&&x.then&&typeof x.then=="function")x.then(function(G){var X=this.located(G);!X||!X.start||!X.end||(this.location=X,this.emit(o.EVENTS.RENDITION.LOCATION_CHANGED,{index:this.location.start.index,href:this.location.start.href,start:this.location.start.cfi,end:this.location.end.cfi,percentage:this.location.start.percentage}),this.emit(o.EVENTS.RENDITION.RELOCATED,this.location))}.bind(this));else if(x){var F=this.located(x);if(!F||!F.start||!F.end)return;this.location=F,this.emit(o.EVENTS.RENDITION.LOCATION_CHANGED,{index:this.location.start.index,href:this.location.start.href,start:this.location.start.cfi,end:this.location.end.cfi,percentage:this.location.start.percentage}),this.emit(o.EVENTS.RENDITION.RELOCATED,this.location)}}.bind(this))}.bind(this))}},{key:"currentLocation",value:function(){var _=this.manager.currentLocation();if(_&&_.then&&typeof _.then=="function")_.then(function(x){var F=this.located(x);return F}.bind(this));else if(_){var P=this.located(_);return P}}},{key:"located",value:function(_){if(!_.length)return{};var P=_[0],x=_[_.length-1],F={start:{index:P.index,href:P.href,cfi:P.mapping.start,displayed:{page:P.pages[0]||1,total:P.totalPages}},end:{index:x.index,href:x.href,cfi:x.mapping.end,displayed:{page:x.pages[x.pages.length-1]||1,total:x.totalPages}}},G=this.book.locations.locationFromCfi(P.mapping.start),X=this.book.locations.locationFromCfi(x.mapping.end);G!=null&&(F.start.location=G,F.start.percentage=this.book.locations.percentageFromLocation(G)),X!=null&&(F.end.location=X,F.end.percentage=this.book.locations.percentageFromLocation(X));var J=this.book.pageList.pageFromCfi(P.mapping.start),K=this.book.pageList.pageFromCfi(x.mapping.end);return J!=-1&&(F.start.page=J),K!=-1&&(F.end.page=K),x.index===this.book.spine.last().index&&F.end.displayed.page>=F.end.displayed.total&&(F.atEnd=!0),P.index===this.book.spine.first().index&&F.start.displayed.page===1&&(F.atStart=!0),F}},{key:"destroy",value:function(){this.manager&&this.manager.destroy(),this.book=void 0}},{key:"passEvents",value:function(_){var P=this,x=u.default.listenedEvents;x.forEach(function(F){_.on(F,function(G){return P.triggerViewEvent(G,_)})}),_.on(o.EVENTS.CONTENTS.SELECTED,function(F){return P.triggerSelectedEvent(F,_)})}},{key:"triggerViewEvent",value:function(_,P){this.emit(_.type,_,P)}},{key:"triggerSelectedEvent",value:function(_,P){this.emit(o.EVENTS.RENDITION.SELECTED,_,P)}},{key:"triggerMarkEvent",value:function(_,P,x){this.emit(o.EVENTS.RENDITION.MARK_CLICKED,_,P,x)}},{key:"getRange",value:function(_,P){var x=new f.default(_),F=this.manager.visible().filter(function(G){if(x.spinePos===G.index)return!0});if(F.length)return F[0].contents.range(x,P)}},{key:"adjustImages",value:function(_){return this._layout.name==="pre-paginated"?new Promise(function(P){P()}):(_.addStylesheetRules({img:{"max-width":(this._layout.columnWidth?this._layout.columnWidth+"px":"100%")+"!important","max-height":(this._layout.height?this._layout.height*.6+"px":"60%")+"!important","object-fit":"contain","page-break-inside":"avoid"},svg:{"max-width":(this._layout.columnWidth?this._layout.columnWidth+"px":"100%")+"!important","max-height":(this._layout.height?this._layout.height*.6+"px":"60%")+"!important","page-break-inside":"avoid"}}),new Promise(function(P,x){setTimeout(function(){P()},1)}))}},{key:"getContents",value:function(){return this.manager?this.manager.getContents():[]}},{key:"views",value:function(){var _=this.manager?this.manager.views:void 0;return _||[]}},{key:"handleLinks",value:function(_){var P=this;_&&_.on(o.EVENTS.CONTENTS.LINK_CLICKED,function(x){var F=P.book.path.relative(x);P.display(F)})}},{key:"injectStylesheet",value:function(_,P){var x=_.createElement("link");x.setAttribute("type","text/css"),x.setAttribute("rel","stylesheet"),x.setAttribute("href",this.settings.stylesheet),_.getElementsByTagName("head")[0].appendChild(x)}},{key:"injectScript",value:function(_,P){var x=_.createElement("script");x.setAttribute("type","text/javascript"),x.setAttribute("src",this.settings.script),x.textContent=" ",_.getElementsByTagName("head")[0].appendChild(x)}},{key:"injectIdentifier",value:function(_,P){var x=this.book.package.metadata.identifier,F=_.createElement("meta");F.setAttribute("name","dc.relation.ispartof"),x&&F.setAttribute("content",x),_.getElementsByTagName("head")[0].appendChild(F)}}]),N}();(0,T.default)(V.prototype),y.default=V,C.exports=y.default},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function d(h,f){for(var n=0;n<f.length;n++){var l=f[n];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(h,l.key,l)}}return function(h,f,n){return f&&d(h.prototype,f),n&&d(h,n),h}}(),w=m(1),R=T(w);function T(d){return d&&d.__esModule?d:{default:d}}function k(d,h){if(!(d instanceof h))throw new TypeError("Cannot call a class as a function")}var g=function(){function d(h,f,n,l){k(this,d),this.layout=h,this.horizontal=n==="horizontal",this.direction=f||"ltr",this._dev=l}return S(d,[{key:"section",value:function(f){var n=this.findRanges(f),l=this.rangeListToCfiList(f.section.cfiBase,n);return l}},{key:"page",value:function(f,n,l,e){var r=f&&f.document?f.document.body:!1,t;if(!!r){if(t=this.rangePairToCfiPair(n,{start:this.findStart(r,l,e),end:this.findEnd(r,l,e)}),this._dev===!0){var i=f.document,s=new R.default(t.start).toRange(i),u=new R.default(t.end).toRange(i),c=i.defaultView.getSelection(),a=i.createRange();c.removeAllRanges(),a.setStart(s.startContainer,s.startOffset),a.setEnd(u.endContainer,u.endOffset),c.addRange(a)}return t}}},{key:"walk",value:function(f,n){if(!(f&&f.nodeType===Node.TEXT_NODE)){var l={acceptNode:function(u){return u.data.trim().length>0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}},e=l.acceptNode;e.acceptNode=l.acceptNode;for(var r=document.createTreeWalker(f,NodeFilter.SHOW_TEXT,e,!1),t,i;(t=r.nextNode())&&(i=n(t),!i););return i}}},{key:"findRanges",value:function(f){for(var n=[],l=f.contents.scrollWidth(),e=Math.ceil(l/this.layout.spreadWidth),r=e*this.layout.divisor,t=this.layout.columnWidth,i=this.layout.gap,s,u,c=0;c<r.pages;c++)s=(t+i)*c,u=t*(c+1)+i*c,n.push({start:this.findStart(f.document.body,s,u),end:this.findEnd(f.document.body,s,u)});return n}},{key:"findStart",value:function(f,n,l){for(var e=this,r=[f],t,i,s=f;r.length;)if(t=r.shift(),i=this.walk(t,function(u){var c,a,o,v,p,b;if(p=e.getBounds(u),e.horizontal&&e.direction==="ltr"){if(c=e.horizontal?p.left:p.top,a=e.horizontal?p.right:p.bottom,c>=n&&c<=l)return u;if(a>n)return u;s=u,r.push(u)}else if(e.horizontal&&e.direction==="rtl"){if(c=p.left,a=p.right,a<=l&&a>=n)return u;if(c<l)return u;s=u,r.push(u)}else{if(o=p.top,v=p.bottom,o>=n&&o<=l)return u;if(v>n)return u;s=u,r.push(u)}}),i)return this.findTextStartRange(i,n,l);return this.findTextStartRange(s,n,l)}},{key:"findEnd",value:function(f,n,l){for(var e=this,r=[f],t,i=f,s;r.length;)if(t=r.shift(),s=this.walk(t,function(u){var c,a,o,v,p,b;if(p=e.getBounds(u),e.horizontal&&e.direction==="ltr"){if(c=Math.round(p.left),a=Math.round(p.right),c>l&&i)return i;if(a>l)return u;i=u,r.push(u)}else if(e.horizontal&&e.direction==="rtl"){if(c=Math.round(e.horizontal?p.left:p.top),a=Math.round(e.horizontal?p.right:p.bottom),a<n&&i)return i;if(c<n)return u;i=u,r.push(u)}else{if(o=Math.round(p.top),v=Math.round(p.bottom),o>l&&i)return i;if(v>l)return u;i=u,r.push(u)}}),s)return this.findTextEndRange(s,n,l);return this.findTextEndRange(i,n,l)}},{key:"findTextStartRange",value:function(f,n,l){for(var e=this.splitTextNodeIntoRanges(f),r,t,i,s,u,c=0;c<e.length;c++)if(r=e[c],t=r.getBoundingClientRect(),this.horizontal&&this.direction==="ltr"){if(i=t.left,i>=n)return r}else if(this.horizontal&&this.direction==="rtl"){if(u=t.right,u<=l)return r}else if(s=t.top,s>=n)return r;return e[0]}},{key:"findTextEndRange",value:function(f,n,l){for(var e=this.splitTextNodeIntoRanges(f),r,t,i,s,u,c,a,o=0;o<e.length;o++){if(t=e[o],i=t.getBoundingClientRect(),this.horizontal&&this.direction==="ltr"){if(s=i.left,u=i.right,s>l&&r)return r;if(u>l)return t}else if(this.horizontal&&this.direction==="rtl"){if(s=i.left,u=i.right,u<n&&r)return r;if(s<n)return t}else{if(c=i.top,a=i.bottom,c>l&&r)return r;if(a>l)return t}r=t}return e[e.length-1]}},{key:"splitTextNodeIntoRanges",value:function(f,n){var l=[],e=f.textContent||"",r=e.trim(),t,i=f.ownerDocument,s=n||" ",u=r.indexOf(s);if(u===-1||f.nodeType!=Node.TEXT_NODE)return t=i.createRange(),t.selectNodeContents(f),[t];for(t=i.createRange(),t.setStart(f,0),t.setEnd(f,u),l.push(t),t=!1;u!=-1;)u=r.indexOf(s,u+1),u>0&&(t&&(t.setEnd(f,u),l.push(t)),t=i.createRange(),t.setStart(f,u+1));return t&&(t.setEnd(f,r.length),l.push(t)),l}},{key:"rangePairToCfiPair",value:function(f,n){var l=n.start,e=n.end;l.collapse(!0),e.collapse(!1);var r=new R.default(l,f).toString(),t=new R.default(e,f).toString();return{start:r,end:t}}},{key:"rangeListToCfiList",value:function(f,n){for(var l=[],e,r=0;r<n.length;r++)e=this.rangePairToCfiPair(f,n[r]),l.push(e);return l}},{key:"getBounds",value:function(f){var n=void 0;if(f.nodeType==Node.TEXT_NODE){var l=document.createRange();l.selectNodeContents(f),n=l.getBoundingClientRect()}else n=f.getBoundingClientRect();return n}},{key:"axis",value:function(f){return f&&(this.horizontal=f==="horizontal"),this.horizontal}}]),d}();y.default=g,C.exports=y.default},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function t(i,s){for(var u=0;u<s.length;u++){var c=s[u];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(i,c.key,c)}}return function(i,s,u){return s&&t(i.prototype,s),u&&t(i,u),i}}(),w=m(2),R=l(w),T=m(0),k=m(1),g=l(k),d=m(13),h=l(d),f=m(3),n=m(53);function l(t){return t&&t.__esModule?t:{default:t}}function e(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}var r=function(){function t(i,s){e(this,t),this.settings=(0,T.extend)({ignoreClass:"",axis:s.layout&&s.layout.props.flow==="scrolled"?"vertical":"horizontal",direction:void 0,width:0,height:0,layout:void 0,globalLayoutProperties:{},method:void 0},s||{}),this.id="epubjs-view-"+(0,T.uuid)(),this.section=i,this.index=i.index,this.element=this.container(this.settings.axis),this.added=!1,this.displayed=!1,this.rendered=!1,this.fixedWidth=0,this.fixedHeight=0,this.epubcfi=new g.default,this.layout=this.settings.layout,this.pane=void 0,this.highlights={},this.underlines={},this.marks={}}return S(t,[{key:"container",value:function(s){var u=document.createElement("div");return u.classList.add("epub-view"),u.style.height="0px",u.style.width="0px",u.style.overflow="hidden",u.style.position="relative",u.style.display="block",s&&s=="horizontal"?u.style.flex="none":u.style.flex="initial",u}},{key:"create",value:function(){return this.iframe?this.iframe:(this.element||(this.element=this.createContainer()),this.iframe=document.createElement("iframe"),this.iframe.id=this.id,this.iframe.scrolling="no",this.iframe.style.overflow="hidden",this.iframe.seamless="seamless",this.iframe.style.border="none",this.iframe.setAttribute("enable-annotation","true"),this.resizing=!0,this.element.style.visibility="hidden",this.iframe.style.visibility="hidden",this.iframe.style.width="0",this.iframe.style.height="0",this._width=0,this._height=0,this.element.setAttribute("ref",this.index),this.element.appendChild(this.iframe),this.added=!0,this.elementBounds=(0,T.bounds)(this.element),"srcdoc"in this.iframe?this.supportsSrcdoc=!0:this.supportsSrcdoc=!1,this.settings.method||(this.settings.method=this.supportsSrcdoc?"srcdoc":"write"),this.iframe)}},{key:"render",value:function(s,u){return this.create(),this.size(),this.sectionRender||(this.sectionRender=this.section.render(s)),this.sectionRender.then(function(c){return this.load(c)}.bind(this)).then(function(){var c=this;this.layout.format(this.contents);var a=this.contents.writingMode(),o=a.indexOf("vertical")===0?"vertical":"horizontal";return this.setAxis(o),this.emit(f.EVENTS.VIEWS.AXIS,o),this.addListeners(),new Promise(function(v,p){c.expand(),v()})}.bind(this),function(c){return this.emit(f.EVENTS.VIEWS.LOAD_ERROR,c),new Promise(function(a,o){o(c)})}.bind(this)).then(function(){this.emit(f.EVENTS.VIEWS.RENDERED,this.section)}.bind(this))}},{key:"reset",value:function(){this.iframe&&(this.iframe.style.width="0",this.iframe.style.height="0",this._width=0,this._height=0,this._textWidth=void 0,this._contentWidth=void 0,this._textHeight=void 0,this._contentHeight=void 0),this._needsReframe=!0}},{key:"size",value:function(s,u){var c=s||this.settings.width,a=u||this.settings.height;this.layout.name==="pre-paginated"?this.lock("both",c,a):this.settings.axis==="horizontal"?this.lock("height",c,a):this.lock("width",c,a),this.settings.width=c,this.settings.height=a}},{key:"lock",value:function(s,u,c){var a=(0,T.borders)(this.element),o;this.iframe?o=(0,T.borders)(this.iframe):o={width:0,height:0},s=="width"&&(0,T.isNumber)(u)&&(this.lockedWidth=u-a.width-o.width),s=="height"&&(0,T.isNumber)(c)&&(this.lockedHeight=c-a.height-o.height),s==="both"&&(0,T.isNumber)(u)&&(0,T.isNumber)(c)&&(this.lockedWidth=u-a.width-o.width,this.lockedHeight=c-a.height-o.height),this.displayed&&this.iframe&&this.expand()}},{key:"expand",value:function(s){var u=this.lockedWidth,c=this.lockedHeight,a,o,v;!this.iframe||this._expanding||(this._expanding=!0,this.layout.name==="pre-paginated"?(u=this.layout.columnWidth,c=this.layout.height):this.settings.axis==="horizontal"?(u=this.contents.textWidth(),u%this.layout.pageWidth>0&&(u=Math.ceil(u/this.layout.pageWidth)*this.layout.pageWidth),this.settings.forceEvenPages&&(a=u/this.layout.delta,this.layout.divisor>1&&this.layout.name==="reflowable"&&a%2>0&&(u+=this.layout.gap+this.layout.columnWidth))):this.settings.axis==="vertical"&&(c=this.contents.textHeight()),(this._needsReframe||u!=this._width||c!=this._height)&&this.reframe(u,c),this._expanding=!1)}},{key:"reframe",value:function(s,u){var c;(0,T.isNumber)(s)&&(this.element.style.width=s+"px",this.iframe.style.width=s+"px",this._width=s),(0,T.isNumber)(u)&&(this.element.style.height=u+"px",this.iframe.style.height=u+"px",this._height=u);var a=this.prevBounds?s-this.prevBounds.width:s,o=this.prevBounds?u-this.prevBounds.height:u;c={width:s,height:u,widthDelta:a,heightDelta:o},this.pane&&this.pane.render(),this.onResize(this,c),this.emit(f.EVENTS.VIEWS.RESIZED,c),this.prevBounds=c,this.elementBounds=(0,T.bounds)(this.element)}},{key:"load",value:function(s){var u=new T.defer,c=u.promise;if(!this.iframe)return u.reject(new Error("No Iframe Available")),c;if(this.iframe.onload=function(a){this.onLoad(a,u)}.bind(this),this.settings.method==="blobUrl")this.blobUrl=(0,T.createBlobUrl)(s,"application/xhtml+xml"),this.iframe.src=this.blobUrl;else if(this.settings.method==="srcdoc")this.iframe.srcdoc=s;else{if(this.document=this.iframe.contentDocument,!this.document)return u.reject(new Error("No Document Available")),c;this.iframe.contentDocument.open(),this.iframe.contentDocument.write(s),this.iframe.contentDocument.close()}return c}},{key:"onLoad",value:function(s,u){var c=this;this.window=this.iframe.contentWindow,this.document=this.iframe.contentDocument,this.contents=new h.default(this.document,this.document.body,this.section.cfiBase,this.section.index),this.rendering=!1;var a=this.document.querySelector("link[rel='canonical']");a?a.setAttribute("href",this.section.canonical):(a=this.document.createElement("link"),a.setAttribute("rel","canonical"),a.setAttribute("href",this.section.canonical),this.document.querySelector("head").appendChild(a)),this.contents.on(f.EVENTS.CONTENTS.EXPAND,function(){c.displayed&&c.iframe&&(c.expand(),c.contents&&c.layout.format(c.contents))}),this.contents.on(f.EVENTS.CONTENTS.RESIZE,function(o){c.displayed&&c.iframe&&(c.expand(),c.contents&&c.layout.format(c.contents))}),u.resolve(this.contents)}},{key:"setLayout",value:function(s){this.layout=s,this.contents&&(this.layout.format(this.contents),this.expand())}},{key:"setAxis",value:function(s){this.layout.props.flow==="scrolled"&&(s="vertical"),this.settings.axis=s,s=="horizontal"?this.element.style.flex="none":this.element.style.flex="initial",this.size()}},{key:"addListeners",value:function(){}},{key:"removeListeners",value:function(s){}},{key:"display",value:function(s){var u=new T.defer;return this.displayed?u.resolve(this):this.render(s).then(function(){this.emit(f.EVENTS.VIEWS.DISPLAYED,this),this.onDisplayed(this),this.displayed=!0,u.resolve(this)}.bind(this),function(c){u.reject(c,this)}),u.promise}},{key:"show",value:function(){this.element.style.visibility="visible",this.iframe&&(this.iframe.style.visibility="visible"),this.emit(f.EVENTS.VIEWS.SHOWN,this)}},{key:"hide",value:function(){this.element.style.visibility="hidden",this.iframe.style.visibility="hidden",this.stopExpanding=!0,this.emit(f.EVENTS.VIEWS.HIDDEN,this)}},{key:"offset",value:function(){return{top:this.element.offsetTop,left:this.element.offsetLeft}}},{key:"width",value:function(){return this._width}},{key:"height",value:function(){return this._height}},{key:"position",value:function(){return this.element.getBoundingClientRect()}},{key:"locationOf",value:function(s){var u=this.iframe.getBoundingClientRect(),c=this.contents.locationOf(s,this.settings.ignoreClass);return{left:c.left,top:c.top}}},{key:"onDisplayed",value:function(s){}},{key:"onResize",value:function(s,u){}},{key:"bounds",value:function(s){return(s||!this.elementBounds)&&(this.elementBounds=(0,T.bounds)(this.element)),this.elementBounds}},{key:"highlight",value:function(s){var u=this,c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=arguments[2];if(!!this.contents){var o=this.contents.range(s),v=function(){u.emit(f.EVENTS.VIEWS.MARK_CLICKED,s,c)};c.epubcfi=s,this.pane||(this.pane=new n.Pane(this.iframe,this.element));var p=new n.Highlight(o,"epubjs-hl",c,{fill:"yellow","fill-opacity":"0.3","mix-blend-mode":"multiply"}),b=this.pane.addMark(p);return this.highlights[s]={mark:b,element:b.element,listeners:[v,a]},b.element.setAttribute("ref","epubjs-hl"),b.element.addEventListener("click",v),b.element.addEventListener("touchstart",v),a&&(b.element.addEventListener("click",a),b.element.addEventListener("touchstart",a)),b}}},{key:"underline",value:function(s){var u=this,c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=arguments[2];if(!!this.contents){var o=this.contents.range(s),v=function(){u.emit(f.EVENTS.VIEWS.MARK_CLICKED,s,c)};c.epubcfi=s,this.pane||(this.pane=new n.Pane(this.iframe,this.element));var p=new n.Underline(o,"epubjs-ul",c,{stroke:"black","stroke-opacity":"0.3","mix-blend-mode":"multiply"}),b=this.pane.addMark(p);return this.underlines[s]={mark:b,element:b.element,listeners:[v,a]},b.element.setAttribute("ref","epubjs-ul"),b.element.addEventListener("click",v),b.element.addEventListener("touchstart",v),a&&(b.element.addEventListener("click",a),b.element.addEventListener("touchstart",a)),b}}},{key:"mark",value:function(s){var u=this,c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=arguments[2];if(!!this.contents){if(s in this.marks){var o=this.marks[s];return o}var v=this.contents.range(s);if(!!v){var p=v.commonAncestorContainer,b=p.nodeType===1?p:p.parentNode,E=function(x){u.emit(f.EVENTS.VIEWS.MARK_CLICKED,s,c)};v.collapsed&&p.nodeType===1?(v=new Range,v.selectNodeContents(p)):v.collapsed&&(v=new Range,v.selectNodeContents(b));var L=void 0,A=void 0,B=void 0;if(this.layout.name==="pre-paginated"||this.settings.axis!=="horizontal"){var D=v.getBoundingClientRect();L=D.top,A=D.right}else for(var V=v.getClientRects(),N=void 0,z=0;z!=V.length;z++)N=V[z],(!B||N.left<B)&&(B=N.left,A=B+this.layout.columnWidth-this.layout.gap,L=N.top);var _=this.document.createElement("a");return _.setAttribute("ref","epubjs-mk"),_.style.position="absolute",_.style.top=L+"px",_.style.left=A+"px",_.dataset.epubcfi=s,c&&Object.keys(c).forEach(function(P){_.dataset[P]=c[P]}),a&&(_.addEventListener("click",a),_.addEventListener("touchstart",a)),_.addEventListener("click",E),_.addEventListener("touchstart",E),this.element.appendChild(_),this.marks[s]={element:_,listeners:[E,a]},b}}}},{key:"unhighlight",value:function(s){var u=void 0;s in this.highlights&&(u=this.highlights[s],this.pane.removeMark(u.mark),u.listeners.forEach(function(c){c&&u.element.removeEventListener("click",c)}),delete this.highlights[s])}},{key:"ununderline",value:function(s){var u=void 0;s in this.underlines&&(u=this.underlines[s],this.pane.removeMark(u.mark),u.listeners.forEach(function(c){c&&u.element.removeEventListener("click",c)}),delete this.underlines[s])}},{key:"unmark",value:function(s){var u=void 0;s in this.marks&&(u=this.marks[s],this.element.removeChild(u.element),u.listeners.forEach(function(c){c&&u.element.removeEventListener("click",c)}),delete this.marks[s])}},{key:"destroy",value:function(){for(var s in this.highlights)this.unhighlight(s);for(var u in this.underlines)this.ununderline(u);for(var c in this.marks)this.unmark(c);this.blobUrl&&(0,T.revokeBlobUrl)(this.blobUrl),this.displayed&&(this.displayed=!1,this.removeListeners(),this.stopExpanding=!0,this.element.removeChild(this.iframe),this.iframe=null,this._textWidth=null,this._textHeight=null,this._width=null,this._height=null)}}]),t}();(0,R.default)(r.prototype),y.default=r,C.exports=y.default},function(C,y,m){var S=m(15),w=m(58),R=m(60),T="Expected a function",k=Math.max,g=Math.min;function d(h,f,n){var l,e,r,t,i,s,u=0,c=!1,a=!1,o=!0;if(typeof h!="function")throw new TypeError(T);f=R(f)||0,S(n)&&(c=!!n.leading,a="maxWait"in n,r=a?k(R(n.maxWait)||0,f):r,o="trailing"in n?!!n.trailing:o);function v(N){var z=l,_=e;return l=e=void 0,u=N,t=h.apply(_,z),t}function p(N){return u=N,i=setTimeout(L,f),c?v(N):t}function b(N){var z=N-s,_=N-u,P=f-z;return a?g(P,r-_):P}function E(N){var z=N-s,_=N-u;return s===void 0||z>=f||z<0||a&&_>=r}function L(){var N=w();if(E(N))return A(N);i=setTimeout(L,b(N))}function A(N){return i=void 0,o&&l?v(N):(l=e=void 0,t)}function B(){i!==void 0&&clearTimeout(i),u=0,l=s=e=i=void 0}function D(){return i===void 0?t:A(w())}function V(){var N=w(),z=E(N);if(l=arguments,e=this,s=N,z){if(i===void 0)return p(s);if(a)return i=setTimeout(L,f),v(s)}return i===void 0&&(i=setTimeout(L,f)),t}return V.cancel=B,V.flush=D,V}C.exports=d},function(C,y,m){var S=m(59),w=typeof self=="object"&&self&&self.Object===Object&&self,R=S||w||Function("return this")();C.exports=R},function(C,y,m){var S=m(22),w=S.Symbol;C.exports=w},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function r(t,i){for(var s=0;s<i.length;s++){var u=i[s];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(t,u.key,u)}}return function(t,i,s){return i&&r(t.prototype,i),s&&r(t,s),t}}(),w=m(0),R=m(14),T=h(R),k=m(3),g=m(21),d=h(g);function h(r){return r&&r.__esModule?r:{default:r}}function f(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function n(r,t){if(!r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t&&(typeof t=="object"||typeof t=="function")?t:r}function l(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof t);r.prototype=Object.create(t&&t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(r,t):r.__proto__=t)}var e=function(r){l(t,r);function t(i){f(this,t);var s=n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,i));return s.name="continuous",s.settings=(0,w.extend)(s.settings||{},{infinite:!0,overflow:void 0,axis:void 0,flow:"scrolled",offset:500,offsetDelta:250,width:void 0,height:void 0}),(0,w.extend)(s.settings,i.settings||{}),i.settings.gap!="undefined"&&i.settings.gap===0&&(s.settings.gap=i.settings.gap),s.viewSettings={ignoreClass:s.settings.ignoreClass,axis:s.settings.axis,flow:s.settings.flow,layout:s.layout,width:0,height:0,forceEvenPages:!1},s.scrollTop=0,s.scrollLeft=0,s}return S(t,[{key:"display",value:function(s,u){return T.default.prototype.display.call(this,s,u).then(function(){return this.fill()}.bind(this))}},{key:"fill",value:function(s){var u=this,c=s||new w.defer;return this.q.enqueue(function(){return u.check()}).then(function(a){a?u.fill(c):c.resolve()}),c.promise}},{key:"moveTo",value:function(s){var u=0,c=0,a=0,o=0;this.isPaginated?(u=Math.floor(s.left/this.layout.delta)*this.layout.delta,a=u+this.settings.offset):(c=s.top,o=s.top+this.settings.offset),(u>0||c>0)&&this.scrollBy(u,c,!0)}},{key:"afterResized",value:function(s){this.emit(k.EVENTS.MANAGERS.RESIZE,s.section)}},{key:"removeShownListeners",value:function(s){s.onDisplayed=function(){}}},{key:"add",value:function(s){var u=this,c=this.createView(s);return this.views.append(c),c.on(k.EVENTS.VIEWS.RESIZED,function(a){c.expanded=!0}),c.on(k.EVENTS.VIEWS.AXIS,function(a){u.updateAxis(a)}),c.onDisplayed=this.afterDisplayed.bind(this),c.onResize=this.afterResized.bind(this),c.display(this.request)}},{key:"append",value:function(s){var u=this.createView(s);return u.on(k.EVENTS.VIEWS.RESIZED,function(c){u.expanded=!0}),this.views.append(u),u.onDisplayed=this.afterDisplayed.bind(this),u}},{key:"prepend",value:function(s){var u=this,c=this.createView(s);return c.on(k.EVENTS.VIEWS.RESIZED,function(a){u.counter(a),c.expanded=!0}),this.views.prepend(c),c.onDisplayed=this.afterDisplayed.bind(this),c}},{key:"counter",value:function(s){this.settings.axis==="vertical"?this.scrollBy(0,s.heightDelta,!0):this.scrollBy(s.widthDelta,0,!0)}},{key:"update",value:function(s){for(var u=this.bounds(),c=this.views.all(),a=c.length,o=[],v=typeof s!="undefined"?s:this.settings.offset||0,p,b,E=new w.defer,L=[],A=0;A<a;A++)if(b=c[A],p=this.isVisible(b,v,v,u),p===!0){if(b.displayed)b.show();else{var B=b.display(this.request).then(function(D){D.show()},function(D){b.hide()});L.push(B)}o.push(b)}else this.q.enqueue(b.destroy.bind(b)),clearTimeout(this.trimTimeout),this.trimTimeout=setTimeout(function(){this.q.enqueue(this.trim.bind(this))}.bind(this),250);return L.length?Promise.all(L).catch(function(D){E.reject(D)}):(E.resolve(),E.promise)}},{key:"check",value:function(s,u){var c=this,a=new w.defer,o=[],v=this.settings.axis==="horizontal",p=this.settings.offset||0;s&&v&&(p=s),u&&!v&&(p=u);var b=this._bounds,E=this.settings.direction==="rtl",L=v&&E?-1:1,A=v?this.scrollLeft:this.scrollTop*L,B=v?b.width:b.height,D=v?this.container.scrollWidth:this.container.scrollHeight,V=function(){var P=c.views.first(),x=P&&P.section.prev();x&&o.push(c.prepend(x))},N=function(){var P=c.views.last(),x=P&&P.section.next();x&&o.push(c.append(x))};A+B+p>=D&&(v&&E?V():N()),A-p<0&&(v&&E?N():V());var z=o.map(function(_){return _.displayed});return o.length?Promise.all(z).then(function(){if(c.layout.name==="pre-paginated"&&c.layout.props.spread)return c.check()}).then(function(){return c.update(p)},function(_){return _}):(this.q.enqueue(function(){this.update()}.bind(this)),a.resolve(!1),a.promise)}},{key:"trim",value:function(){for(var s=new w.defer,u=this.views.displayed(),c=u[0],a=u[u.length-1],o=this.views.indexOf(c),v=this.views.indexOf(a),p=this.views.slice(0,o),b=this.views.slice(v+1),E=0;E<p.length-1;E++)this.erase(p[E],p);for(var L=1;L<b.length;L++)this.erase(b[L]);return s.resolve(),s.promise}},{key:"erase",value:function(s,u){var c,a;this.settings.height?(c=this.container.scrollTop,a=this.container.scrollLeft):(c=window.scrollY,a=window.scrollX);var o=s.bounds();this.views.remove(s),u&&(this.settings.axis==="vertical"?this.scrollTo(0,c-o.height,!0):this.scrollTo(a-o.width,0,!0))}},{key:"addEventListeners",value:function(s){window.addEventListener("unload",function(u){this.ignore=!0,this.destroy()}.bind(this)),this.addScrollListeners()}},{key:"addScrollListeners",value:function(){var s;this.tick=w.requestAnimationFrame,this.settings.height?(this.prevScrollTop=this.container.scrollTop,this.prevScrollLeft=this.container.scrollLeft):(this.prevScrollTop=window.scrollY,this.prevScrollLeft=window.scrollX),this.scrollDeltaVert=0,this.scrollDeltaHorz=0,this.settings.height?(s=this.container,this.scrollTop=this.container.scrollTop,this.scrollLeft=this.container.scrollLeft):(s=window,this.scrollTop=window.scrollY,this.scrollLeft=window.scrollX),s.addEventListener("scroll",this.onScroll.bind(this)),this._scrolled=(0,d.default)(this.scrolled.bind(this),30),this.didScroll=!1}},{key:"removeEventListeners",value:function(){var s;this.settings.height?s=this.container:s=window,s.removeEventListener("scroll",this.onScroll.bind(this))}},{key:"onScroll",value:function(){var s=void 0,u=void 0,c=this.settings.direction==="rtl"?-1:1;this.settings.height?(s=this.container.scrollTop,u=this.container.scrollLeft):(s=window.scrollY*c,u=window.scrollX*c),this.scrollTop=s,this.scrollLeft=u,this.ignore?this.ignore=!1:this._scrolled(),this.scrollDeltaVert+=Math.abs(s-this.prevScrollTop),this.scrollDeltaHorz+=Math.abs(u-this.prevScrollLeft),this.prevScrollTop=s,this.prevScrollLeft=u,clearTimeout(this.scrollTimeout),this.scrollTimeout=setTimeout(function(){this.scrollDeltaVert=0,this.scrollDeltaHorz=0}.bind(this),150),this.didScroll=!1}},{key:"scrolled",value:function(){this.q.enqueue(function(){this.check()}.bind(this)),this.emit(k.EVENTS.MANAGERS.SCROLL,{top:this.scrollTop,left:this.scrollLeft}),clearTimeout(this.afterScrolled),this.afterScrolled=setTimeout(function(){this.emit(k.EVENTS.MANAGERS.SCROLLED,{top:this.scrollTop,left:this.scrollLeft})}.bind(this))}},{key:"next",value:function(){var s=this.settings.direction,u=this.layout.props.name==="pre-paginated"&&this.layout.props.spread?this.layout.props.delta*2:this.layout.props.delta;!this.views.length||(this.isPaginated&&this.settings.axis==="horizontal"?this.scrollBy(u,0,!0):this.scrollBy(0,this.layout.height,!0),this.q.enqueue(function(){this.check()}.bind(this)))}},{key:"prev",value:function(){var s=this.settings.direction,u=this.layout.props.name==="pre-paginated"&&this.layout.props.spread?this.layout.props.delta*2:this.layout.props.delta;!this.views.length||(this.isPaginated&&this.settings.axis==="horizontal"?this.scrollBy(-u,0,!0):this.scrollBy(0,-this.layout.height,!0),this.q.enqueue(function(){this.check()}.bind(this)))}},{key:"updateAxis",value:function(s,u){this.isPaginated||(s="vertical"),!(!u&&s===this.settings.axis)&&(this.settings.axis=s,this.stage&&this.stage.axis(s),this.viewSettings.axis=s,this.mapping&&this.mapping.axis(s),this.layout&&(s==="vertical"?this.layout.spread("none"):this.layout.spread(this.layout.settings.spread)),s==="vertical"?this.settings.infinite=!0:this.settings.infinite=!1)}}]),t}(T.default);y.default=e,C.exports=y.default},function(C,y,m){"use strict";(function(S){Object.defineProperty(y,"__esModule",{value:!0});var w=m(26),R=a(w),T=m(18),k=a(T),g=m(1),d=a(g),h=m(13),f=a(h),n=m(0),l=c(n);m(69);var e=m(20),r=a(e),t=m(14),i=a(t),s=m(24),u=a(s);function c(v){if(v&&v.__esModule)return v;var p={};if(v!=null)for(var b in v)Object.prototype.hasOwnProperty.call(v,b)&&(p[b]=v[b]);return p.default=v,p}function a(v){return v&&v.__esModule?v:{default:v}}function o(v,p){return new R.default(v,p)}o.VERSION="0.3",typeof S!="undefined"&&(S.EPUBJS_VERSION=o.VERSION),o.Book=R.default,o.Rendition=k.default,o.Contents=f.default,o.CFI=d.default,o.utils=l,y.default=o,C.exports=y.default}).call(y,m(8))},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(K){return typeof K}:function(K){return K&&typeof Symbol=="function"&&K.constructor===Symbol&&K!==Symbol.prototype?"symbol":typeof K},w=function(){function K(H,U){for(var j=0;j<U.length;j++){var Y=U[j];Y.enumerable=Y.enumerable||!1,Y.configurable=!0,"value"in Y&&(Y.writable=!0),Object.defineProperty(H,Y.key,Y)}}return function(H,U,j){return U&&K(H.prototype,U),j&&K(H,j),H}}(),R=m(2),T=P(R),k=m(0),g=m(5),d=P(g),h=m(4),f=P(h),n=m(42),l=P(n),e=m(44),r=P(e),t=m(45),i=P(t),s=m(46),u=P(s),c=m(47),a=P(c),o=m(48),v=P(o),p=m(49),b=P(p),E=m(18),L=P(E),A=m(67),B=P(A),D=m(11),V=P(D),N=m(1),z=P(N),_=m(3);function P(K){return K&&K.__esModule?K:{default:K}}function x(K,H){if(!(K instanceof H))throw new TypeError("Cannot call a class as a function")}var F="META-INF/container.xml",G="0.3",X={BINARY:"binary",BASE64:"base64",EPUB:"epub",OPF:"opf",MANIFEST:"json",DIRECTORY:"directory"},J=function(){function K(H,U){var j=this;x(this,K),typeof U=="undefined"&&(typeof H=="undefined"?"undefined":S(H))==="object"&&(U=H,H=void 0),this.settings=(0,k.extend)(this.settings||{},{requestMethod:void 0,requestCredentials:void 0,requestHeaders:void 0,encoding:void 0,replacements:void 0,canonical:void 0}),(0,k.extend)(this.settings,U),this.opening=new k.defer,this.opened=this.opening.promise,this.isOpen=!1,this.loading={manifest:new k.defer,spine:new k.defer,metadata:new k.defer,cover:new k.defer,navigation:new k.defer,pageList:new k.defer,resources:new k.defer},this.loaded={manifest:this.loading.manifest.promise,spine:this.loading.spine.promise,metadata:this.loading.metadata.promise,cover:this.loading.cover.promise,navigation:this.loading.navigation.promise,pageList:this.loading.pageList.promise,resources:this.loading.resources.promise},this.ready=Promise.all([this.loaded.manifest,this.loaded.spine,this.loaded.metadata,this.loaded.cover,this.loaded.navigation,this.loaded.resources]),this.isRendered=!1,this.request=this.settings.requestMethod||V.default,this.spine=new l.default,this.locations=new r.default(this.spine,this.load.bind(this)),this.navigation=void 0,this.pageList=void 0,this.url=void 0,this.path=void 0,this.archived=!1,this.archive=void 0,this.resources=void 0,this.rendition=void 0,this.container=void 0,this.packaging=void 0,H&&this.open(H).catch(function(Y){var Q=new Error("Cannot load book at "+H);j.emit(_.EVENTS.BOOK.OPEN_FAILED,Q)})}return w(K,[{key:"open",value:function(U,j){var Y,Q=j||this.determineType(U);return Q===X.BINARY?(this.archived=!0,this.url=new d.default("/",""),Y=this.openEpub(U)):Q===X.BASE64?(this.archived=!0,this.url=new d.default("/",""),Y=this.openEpub(U,Q)):Q===X.EPUB?(this.archived=!0,this.url=new d.default("/",""),Y=this.request(U,"binary").then(this.openEpub.bind(this))):Q==X.OPF?(this.url=new d.default(U),Y=this.openPackaging(this.url.Path.toString())):Q==X.MANIFEST?(this.url=new d.default(U),Y=this.openManifest(this.url.Path.toString())):(this.url=new d.default(U),Y=this.openContainer(F).then(this.openPackaging.bind(this))),Y}},{key:"openEpub",value:function(U,j){var Y=this;return this.unarchive(U,j||this.settings.encoding).then(function(){return Y.openContainer(F)}).then(function(Q){return Y.openPackaging(Q)})}},{key:"openContainer",value:function(U){var j=this;return this.load(U).then(function(Y){return j.container=new i.default(Y),j.resolve(j.container.packagePath)})}},{key:"openPackaging",value:function(U){var j=this;return this.path=new f.default(U),this.load(U).then(function(Y){return j.packaging=new u.default(Y),j.unpack(j.packaging)})}},{key:"openManifest",value:function(U){var j=this;return this.path=new f.default(U),this.load(U).then(function(Y){return j.packaging=new u.default,j.packaging.load(Y),j.unpack(j.packaging)})}},{key:"load",value:function(U){var j;return this.archived?(j=this.resolve(U),this.archive.request(j)):(j=this.resolve(U),this.request(j,null,this.settings.requestCredentials,this.settings.requestHeaders))}},{key:"resolve",value:function(U,j){if(!!U){var Y=U,Q=U.indexOf("://")>-1;return Q?U:(this.path&&(Y=this.path.resolve(U)),j!=!1&&this.url&&(Y=this.url.resolve(Y)),Y)}}},{key:"canonical",value:function(U){var j=U;return U?(this.settings.canonical?j=this.settings.canonical(U):j=this.resolve(U,!0),j):""}},{key:"determineType",value:function(U){var j,Y,Q;if(this.settings.encoding==="base64")return X.BASE64;if(typeof U!="string")return X.BINARY;if(j=new d.default(U),Y=j.path(),Q=Y.extension,!Q)return X.DIRECTORY;if(Q==="epub")return X.EPUB;if(Q==="opf")return X.OPF;if(Q==="json")return X.MANIFEST}},{key:"unpack",value:function(U){var j=this;this.package=U,this.spine.unpack(this.package,this.resolve.bind(this),this.canonical.bind(this)),this.resources=new v.default(this.package.manifest,{archive:this.archive,resolver:this.resolve.bind(this),request:this.request.bind(this),replacements:this.settings.replacements||(this.archived?"blobUrl":"base64")}),this.loadNavigation(this.package).then(function(){j.loading.navigation.resolve(j.navigation)}),this.package.coverPath&&(this.cover=this.resolve(this.package.coverPath)),this.loading.manifest.resolve(this.package.manifest),this.loading.metadata.resolve(this.package.metadata),this.loading.spine.resolve(this.spine),this.loading.cover.resolve(this.cover),this.loading.resources.resolve(this.resources),this.loading.pageList.resolve(this.pageList),this.isOpen=!0,this.archived||this.settings.replacements&&this.settings.replacements!="none"?this.replacements().then(function(){j.opening.resolve(j)}).catch(function(Y){console.error(Y)}):this.opening.resolve(this)}},{key:"loadNavigation",value:function(U){var j=this,Y=U.navPath||U.ncxPath,Q=U.toc;return Q?new Promise(function(te,ae){j.navigation=new a.default(Q),U.pageList&&(j.pageList=new b.default(U.pageList)),te(j.navigation)}):Y?this.load(Y,"xml").then(function(te){return j.navigation=new a.default(te),j.pageList=new b.default(te),j.navigation}):new Promise(function(te,ae){j.navigation=new a.default,j.pageList=new b.default,te(j.navigation)})}},{key:"section",value:function(U){return this.spine.get(U)}},{key:"renderTo",value:function(U,j){return this.rendition=new L.default(this,j),this.rendition.attachTo(U),this.rendition}},{key:"setRequestCredentials",value:function(U){this.settings.requestCredentials=U}},{key:"setRequestHeaders",value:function(U){this.settings.requestHeaders=U}},{key:"unarchive",value:function(U,j){return this.archive=new B.default,this.archive.open(U,j)}},{key:"coverUrl",value:function(){var U=this,j=this.loaded.cover.then(function(Y){return U.archived?U.resources.get(U.cover):U.cover});return j}},{key:"replacements",value:function(){var U=this;return this.spine.hooks.serialize.register(function(j,Y){Y.output=U.resources.substitute(j,Y.url)}),this.resources.replacements().then(function(){return U.resources.replaceCss()})}},{key:"getRange",value:function(U){var j=new z.default(U),Y=this.spine.get(j.spinePos),Q=this.load.bind(this);return Y?Y.load(Q).then(function(te){var ae=j.toRange(Y.document);return ae}):new Promise(function(te,ae){ae("CFI could not be found")})}},{key:"key",value:function(U){var j=U||this.package.metadata.identifier||this.url.filename;return"epubjs:"+G+":"+j}},{key:"destroy",value:function(){this.opened=void 0,this.loading=void 0,this.loaded=void 0,this.ready=void 0,this.isOpen=!1,this.isRendered=!1,this.spine&&this.spine.destroy(),this.locations&&this.locations.destroy(),this.pageList&&this.pageList.destroy(),this.archive&&this.archive.destroy(),this.resources&&this.resources.destroy(),this.container&&this.container.destroy(),this.packaging&&this.packaging.destroy(),this.rendition&&this.rendition.destroy(),this.spine=void 0,this.locations=void 0,this.pageList=void 0,this.archive=void 0,this.resources=void 0,this.container=void 0,this.packaging=void 0,this.rendition=void 0,this.navigation=void 0,this.url=void 0,this.path=void 0,this.archived=!1}}]),K}();(0,T.default)(J.prototype),y.default=J,C.exports=y.default},function(C,y,m){"use strict";var S=m(28),w=m(36),R=m(37),T=m(38),k;k=C.exports=function(g,d){var h,f,n,l,e;return arguments.length<2||typeof g!="string"?(l=d,d=g,g=null):l=arguments[2],g==null?(h=n=!0,f=!1):(h=T.call(g,"c"),f=T.call(g,"e"),n=T.call(g,"w")),e={value:d,configurable:h,enumerable:f,writable:n},l?S(w(l),e):e},k.gs=function(g,d,h){var f,n,l,e;return typeof g!="string"?(l=h,h=d,d=g,g=null):l=arguments[3],d==null?d=void 0:R(d)?h==null?h=void 0:R(h)||(l=h,h=void 0):(l=d,d=h=void 0),g==null?(f=!0,n=!1):(f=T.call(g,"c"),n=T.call(g,"e")),e={get:d,set:h,configurable:f,enumerable:n},l?S(w(l),e):e}},function(C,y,m){"use strict";C.exports=m(29)()?Object.assign:m(30)},function(C,y,m){"use strict";C.exports=function(){var S=Object.assign,w;return typeof S!="function"?!1:(w={foo:"raz"},S(w,{bar:"dwa"},{trzy:"trzy"}),w.foo+w.bar+w.trzy==="razdwatrzy")}},function(C,y,m){"use strict";var S=m(31),w=m(35),R=Math.max;C.exports=function(T,k){var g,d,h=R(arguments.length,2),f;for(T=Object(w(T)),f=function(n){try{T[n]=k[n]}catch(l){g||(g=l)}},d=1;d<h;++d)k=arguments[d],S(k).forEach(f);if(g!==void 0)throw g;return T}},function(C,y,m){"use strict";C.exports=m(32)()?Object.keys:m(33)},function(C,y,m){"use strict";C.exports=function(){try{return Object.keys("primitive"),!0}catch(S){return!1}}},function(C,y,m){"use strict";var S=m(9),w=Object.keys;C.exports=function(R){return w(S(R)?Object(R):R)}},function(C,y,m){"use strict";C.exports=function(){}},function(C,y,m){"use strict";var S=m(9);C.exports=function(w){if(!S(w))throw new TypeError("Cannot use null or undefined");return w}},function(C,y,m){"use strict";var S=m(9),w=Array.prototype.forEach,R=Object.create,T=function(k,g){var d;for(d in k)g[d]=k[d]};C.exports=function(k){var g=R(null);return w.call(arguments,function(d){!S(d)||T(Object(d),g)}),g}},function(C,y,m){"use strict";C.exports=function(S){return typeof S=="function"}},function(C,y,m){"use strict";C.exports=m(39)()?String.prototype.contains:m(40)},function(C,y,m){"use strict";var S="razdwatrzy";C.exports=function(){return typeof S.contains!="function"?!1:S.contains("dwa")===!0&&S.contains("foo")===!1}},function(C,y,m){"use strict";var S=String.prototype.indexOf;C.exports=function(w){return S.call(this,w,arguments[1])>-1}},function(C,y,m){"use strict";C.exports=function(S){if(typeof S!="function")throw new TypeError(S+" is not a function");return S}},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function e(r,t){for(var i=0;i<t.length;i++){var s=t[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(r,s.key,s)}}return function(r,t,i){return t&&e(r.prototype,t),i&&e(r,i),r}}(),w=m(1),R=f(w),T=m(10),k=f(T),g=m(43),d=f(g),h=m(7);function f(e){return e&&e.__esModule?e:{default:e}}function n(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}var l=function(){function e(){n(this,e),this.spineItems=[],this.spineByHref={},this.spineById={},this.hooks={},this.hooks.serialize=new k.default,this.hooks.content=new k.default,this.hooks.content.register(h.replaceBase),this.hooks.content.register(h.replaceCanonical),this.hooks.content.register(h.replaceMeta),this.epubcfi=new R.default,this.loaded=!1,this.items=void 0,this.manifest=void 0,this.spineNodeIndex=void 0,this.baseUrl=void 0,this.length=void 0}return S(e,[{key:"unpack",value:function(t,i,s){var u=this;this.items=t.spine,this.manifest=t.manifest,this.spineNodeIndex=t.spineNodeIndex,this.baseUrl=t.baseUrl||t.basePath||"",this.length=this.items.length,this.items.forEach(function(c,a){var o=u.manifest[c.idref],v;c.index=a,c.cfiBase=u.epubcfi.generateChapterComponent(u.spineNodeIndex,c.index,c.idref),c.href&&(c.url=i(c.href,!0),c.canonical=s(c.href)),o&&(c.href=o.href,c.url=i(c.href,!0),c.canonical=s(c.href),o.properties.length&&c.properties.push.apply(c.properties,o.properties)),c.linear==="yes"?(c.prev=function(){for(var p=c.index;p>0;){var b=this.get(p-1);if(b&&b.linear)return b;p-=1}}.bind(u),c.next=function(){for(var p=c.index;p<this.spineItems.length-1;){var b=this.get(p+1);if(b&&b.linear)return b;p+=1}}.bind(u)):(c.prev=function(){},c.next=function(){}),v=new d.default(c,u.hooks),u.append(v)}),this.loaded=!0}},{key:"get",value:function(t){var i=0;if(typeof t=="undefined")for(;i<this.spineItems.length;){var s=this.spineItems[i];if(s&&s.linear)break;i+=1}else if(this.epubcfi.isCfiString(t)){var u=new R.default(t);i=u.spinePos}else typeof t=="number"||isNaN(t)===!1?i=t:typeof t=="string"&&t.indexOf("#")===0?i=this.spineById[t.substring(1)]:typeof t=="string"&&(t=t.split("#")[0],i=this.spineByHref[t]||this.spineByHref[encodeURI(t)]);return this.spineItems[i]||null}},{key:"append",value:function(t){var i=this.spineItems.length;return t.index=i,this.spineItems.push(t),this.spineByHref[decodeURI(t.href)]=i,this.spineByHref[encodeURI(t.href)]=i,this.spineByHref[t.href]=i,this.spineById[t.idref]=i,i}},{key:"prepend",value:function(t){return this.spineByHref[t.href]=0,this.spineById[t.idref]=0,this.spineItems.forEach(function(i,s){i.index=s}),0}},{key:"remove",value:function(t){var i=this.spineItems.indexOf(t);if(i>-1)return delete this.spineByHref[t.href],delete this.spineById[t.idref],this.spineItems.splice(i,1)}},{key:"each",value:function(){return this.spineItems.forEach.apply(this.spineItems,arguments)}},{key:"first",value:function(){var t=0;do{var i=this.get(t);if(i&&i.linear)return i;t+=1}while(t<this.spineItems.length)}},{key:"last",value:function(){var t=this.spineItems.length-1;do{var i=this.get(t);if(i&&i.linear)return i;t-=1}while(t>=0)}},{key:"destroy",value:function(){this.each(function(t){return t.destroy()}),this.spineItems=void 0,this.spineByHref=void 0,this.spineById=void 0,this.hooks.serialize.clear(),this.hooks.content.clear(),this.hooks=void 0,this.epubcfi=void 0,this.loaded=!1,this.items=void 0,this.manifest=void 0,this.spineNodeIndex=void 0,this.baseUrl=void 0,this.length=void 0}}]),e}();y.default=l,C.exports=y.default},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function l(e,r){for(var t=0;t<r.length;t++){var i=r[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,r,t){return r&&l(e.prototype,r),t&&l(e,t),e}}(),w=m(0),R=m(1),T=h(R),k=m(10),g=h(k),d=m(7);function h(l){return l&&l.__esModule?l:{default:l}}function f(l,e){if(!(l instanceof e))throw new TypeError("Cannot call a class as a function")}var n=function(){function l(e,r){f(this,l),this.idref=e.idref,this.linear=e.linear==="yes",this.properties=e.properties,this.index=e.index,this.href=e.href,this.url=e.url,this.canonical=e.canonical,this.next=e.next,this.prev=e.prev,this.cfiBase=e.cfiBase,r?this.hooks=r:(this.hooks={},this.hooks.serialize=new g.default(this),this.hooks.content=new g.default(this)),this.document=void 0,this.contents=void 0,this.output=void 0}return S(l,[{key:"load",value:function(r){var t=r||this.request||m(11),i=new w.defer,s=i.promise;return this.contents?i.resolve(this.contents):t(this.url).then(function(u){return this.document=u,this.contents=u.documentElement,this.hooks.content.trigger(this.document,this)}.bind(this)).then(function(){i.resolve(this.contents)}.bind(this)).catch(function(u){i.reject(u)}),s}},{key:"base",value:function(){return(0,d.replaceBase)(this.document,this)}},{key:"render",value:function(r){var t=new w.defer,i=t.promise;return this.output,this.load(r).then(function(s){var u=typeof navigator!="undefined"&&navigator.userAgent||"",c=u.indexOf("Trident")>=0,a;typeof XMLSerializer=="undefined"||c?a=m(16).XMLSerializer:a=XMLSerializer;var o=new a;return this.output=o.serializeToString(s),this.output}.bind(this)).then(function(){return this.hooks.serialize.trigger(this.output,this)}.bind(this)).then(function(){t.resolve(this.output)}.bind(this)).catch(function(s){t.reject(s)}),i}},{key:"find",value:function(r){var t=this,i=[],s=r.toLowerCase(),u=function(a){for(var o=a.textContent.toLowerCase(),v=t.document.createRange(),p,b,E=-1,L,A=150;b!=-1;)b=o.indexOf(s,E+1),b!=-1&&(v=t.document.createRange(),v.setStart(a,b),v.setEnd(a,b+s.length),p=t.cfiFromRange(v),a.textContent.length<A?L=a.textContent:(L=a.textContent.substring(b-A/2,b+A/2),L="..."+L+"..."),i.push({cfi:p,excerpt:L})),E=b};return(0,w.sprint)(t.document,function(c){u(c)}),i}},{key:"reconcileLayoutSettings",value:function(r){var t={layout:r.layout,spread:r.spread,orientation:r.orientation};return this.properties.forEach(function(i){var s=i.replace("rendition:",""),u=s.indexOf("-"),c,a;u!=-1&&(c=s.slice(0,u),a=s.slice(u+1),t[c]=a)}),t}},{key:"cfiFromRange",value:function(r){return new T.default(r,this.cfiBase).toString()}},{key:"cfiFromElement",value:function(r){return new T.default(r,this.cfiBase).toString()}},{key:"unload",value:function(){this.document=void 0,this.contents=void 0,this.output=void 0}},{key:"destroy",value:function(){this.unload(),this.hooks.serialize.clear(),this.hooks.content.clear(),this.hooks=void 0,this.idref=void 0,this.linear=void 0,this.properties=void 0,this.index=void 0,this.href=void 0,this.url=void 0,this.next=void 0,this.prev=void 0,this.cfiBase=void 0}}]),l}();y.default=n,C.exports=y.default},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function r(t,i){for(var s=0;s<i.length;s++){var u=i[s];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(t,u.key,u)}}return function(t,i,s){return i&&r(t.prototype,i),s&&r(t,s),t}}(),w=m(0),R=m(12),T=n(R),k=m(1),g=n(k),d=m(3),h=m(2),f=n(h);function n(r){return r&&r.__esModule?r:{default:r}}function l(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}var e=function(){function r(t,i,s){l(this,r),this.spine=t,this.request=i,this.pause=s||100,this.q=new T.default(this),this.epubcfi=new g.default,this._locations=[],this.total=0,this.break=150,this._current=0,this.currentLocation="",this._currentCfi="",this.processingTimeout=void 0}return S(r,[{key:"generate",value:function(i){return i&&(this.break=i),this.q.pause(),this.spine.each(function(s){s.linear&&this.q.enqueue(this.process.bind(this),s)}.bind(this)),this.q.run().then(function(){return this.total=this._locations.length-1,this._currentCfi&&(this.currentLocation=this._currentCfi),this._locations}.bind(this))}},{key:"createRange",value:function(){return{startContainer:void 0,startOffset:void 0,endContainer:void 0,endOffset:void 0}}},{key:"process",value:function(i){return i.load(this.request).then(function(s){var u=new w.defer,c=this.parse(s,i.cfiBase);return this._locations=this._locations.concat(c),i.unload(),this.processingTimeout=setTimeout(function(){return u.resolve(c)},this.pause),u.promise}.bind(this))}},{key:"parse",value:function(i,s,u){var c=[],a,o=i.ownerDocument,v=(0,w.qs)(o,"body"),p=0,b,E=u||this.break,L=function(D){var V=D.length,N,z=0;if(D.textContent.trim().length===0)return!1;for(p==0&&(a=this.createRange(),a.startContainer=D,a.startOffset=0),N=E-p,N>V&&(p+=V,z=V);z<V;)if(N=E-p,p===0&&(z+=1,a=this.createRange(),a.startContainer=D,a.startOffset=z),z+N>=V)p+=V-z,z=V;else{z+=N,a.endContainer=D,a.endOffset=z;var _=new g.default(a,s).toString();c.push(_),p=0}b=D};if((0,w.sprint)(v,L.bind(this)),a&&a.startContainer&&b){a.endContainer=b,a.endOffset=b.length;var A=new g.default(a,s).toString();c.push(A),p=0}return c}},{key:"locationFromCfi",value:function(i){var s=void 0;return g.default.prototype.isCfiString(i)&&(i=new g.default(i)),this._locations.length===0?-1:(s=(0,w.locationOf)(i,this._locations,this.epubcfi.compare),s>this.total?this.total:s)}},{key:"percentageFromCfi",value:function(i){if(this._locations.length===0)return null;var s=this.locationFromCfi(i);return this.percentageFromLocation(s)}},{key:"percentageFromLocation",value:function(i){return!i||!this.total?0:i/this.total}},{key:"cfiFromLocation",value:function(i){var s=-1;return typeof i!="number"&&(i=parseInt(i)),i>=0&&i<this._locations.length&&(s=this._locations[i]),s}},{key:"cfiFromPercentage",value:function(i){var s=void 0;if(i>1&&console.warn("Normalize cfiFromPercentage value to between 0 - 1"),i>=1){var u=new g.default(this._locations[this.total]);return u.collapse(),u.toString()}return s=Math.ceil(this.total*i),this.cfiFromLocation(s)}},{key:"load",value:function(i){return typeof i=="string"?this._locations=JSON.parse(i):this._locations=i,this.total=this._locations.length-1,this._locations}},{key:"save",value:function(){return JSON.stringify(this._locations)}},{key:"getCurrent",value:function(){return this._current}},{key:"setCurrent",value:function(i){var s;if(typeof i=="string")this._currentCfi=i;else if(typeof i=="number")this._current=i;else return;this._locations.length!==0&&(typeof i=="string"?(s=this.locationFromCfi(i),this._current=s):s=i,this.emit(d.EVENTS.LOCATIONS.CHANGED,{percentage:this.percentageFromLocation(s)}))}},{key:"length",value:function(){return this._locations.length}},{key:"destroy",value:function(){this.spine=void 0,this.request=void 0,this.pause=void 0,this.q.stop(),this.q=void 0,this.epubcfi=void 0,this._locations=void 0,this.total=void 0,this.break=void 0,this._current=void 0,this.currentLocation=void 0,this._currentCfi=void 0,clearTimeout(this.processingTimeout)}},{key:"currentLocation",get:function(){return this._current},set:function(i){this.setCurrent(i)}}]),r}();(0,f.default)(e.prototype),y.default=e,C.exports=y.default},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function h(f,n){for(var l=0;l<n.length;l++){var e=n[l];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(f,e.key,e)}}return function(f,n,l){return n&&h(f.prototype,n),l&&h(f,l),f}}(),w=m(6),R=k(w),T=m(0);function k(h){return h&&h.__esModule?h:{default:h}}function g(h,f){if(!(h instanceof f))throw new TypeError("Cannot call a class as a function")}var d=function(){function h(f){g(this,h),this.packagePath="",this.directory="",this.encoding="",f&&this.parse(f)}return S(h,[{key:"parse",value:function(n){var l;if(!n)throw new Error("Container File Not Found");if(l=(0,T.qs)(n,"rootfile"),!l)throw new Error("No RootFile Found");this.packagePath=l.getAttribute("full-path"),this.directory=R.default.dirname(this.packagePath),this.encoding=n.xmlEncoding}},{key:"destroy",value:function(){this.packagePath=void 0,this.directory=void 0,this.encoding=void 0}}]),h}();y.default=d,C.exports=y.default},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function k(g,d){for(var h=0;h<d.length;h++){var f=d[h];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(g,f.key,f)}}return function(g,d,h){return d&&k(g.prototype,d),h&&k(g,h),g}}(),w=m(0);function R(k,g){if(!(k instanceof g))throw new TypeError("Cannot call a class as a function")}var T=function(){function k(g){R(this,k),this.manifest={},this.navPath="",this.ncxPath="",this.coverPath="",this.spineNodeIndex=0,this.spine=[],this.metadata={},g&&this.parse(g)}return S(k,[{key:"parse",value:function(d){var h,f,n;if(!d)throw new Error("Package File Not Found");if(h=(0,w.qs)(d,"metadata"),!h)throw new Error("No Metadata Found");if(f=(0,w.qs)(d,"manifest"),!f)throw new Error("No Manifest Found");if(n=(0,w.qs)(d,"spine"),!n)throw new Error("No Spine Found");return this.manifest=this.parseManifest(f),this.navPath=this.findNavPath(f),this.ncxPath=this.findNcxPath(f,n),this.coverPath=this.findCoverPath(d),this.spineNodeIndex=(0,w.indexOfElementNode)(n),this.spine=this.parseSpine(n,this.manifest),this.metadata=this.parseMetadata(h),this.metadata.direction=n.getAttribute("page-progression-direction"),{metadata:this.metadata,spine:this.spine,manifest:this.manifest,navPath:this.navPath,ncxPath:this.ncxPath,coverPath:this.coverPath,spineNodeIndex:this.spineNodeIndex}}},{key:"parseMetadata",value:function(d){var h={};return h.title=this.getElementText(d,"title"),h.creator=this.getElementText(d,"creator"),h.description=this.getElementText(d,"description"),h.pubdate=this.getElementText(d,"date"),h.publisher=this.getElementText(d,"publisher"),h.identifier=this.getElementText(d,"identifier"),h.language=this.getElementText(d,"language"),h.rights=this.getElementText(d,"rights"),h.modified_date=this.getPropertyText(d,"dcterms:modified"),h.layout=this.getPropertyText(d,"rendition:layout"),h.orientation=this.getPropertyText(d,"rendition:orientation"),h.flow=this.getPropertyText(d,"rendition:flow"),h.viewport=this.getPropertyText(d,"rendition:viewport"),h}},{key:"parseManifest",value:function(d){var h={},f=(0,w.qsa)(d,"item"),n=Array.prototype.slice.call(f);return n.forEach(function(l){var e=l.getAttribute("id"),r=l.getAttribute("href")||"",t=l.getAttribute("media-type")||"",i=l.getAttribute("properties")||"";h[e]={href:r,type:t,properties:i.length?i.split(" "):[]}}),h}},{key:"parseSpine",value:function(d,h){var f=[],n=(0,w.qsa)(d,"itemref"),l=Array.prototype.slice.call(n);return l.forEach(function(e,r){var t=e.getAttribute("idref"),i=e.getAttribute("properties")||"",s=i.length?i.split(" "):[],u={idref:t,linear:e.getAttribute("linear")||"yes",properties:s,index:r};f.push(u)}),f}},{key:"findNavPath",value:function(d){var h=(0,w.qsp)(d,"item",{properties:"nav"});return h?h.getAttribute("href"):!1}},{key:"findNcxPath",value:function(d,h){var f=(0,w.qsp)(d,"item",{"media-type":"application/x-dtbncx+xml"}),n;return f||(n=h.getAttribute("toc"),n&&(f=d.getElementById(n))),f?f.getAttribute("href"):!1}},{key:"findCoverPath",value:function(d){var h=(0,w.qs)(d,"package"),f=h.getAttribute("version");if(f==="2.0"){var n=(0,w.qsp)(d,"meta",{name:"cover"});if(n){var l=n.getAttribute("content"),e=d.getElementById(l);return e?e.getAttribute("href"):""}else return!1}else{var r=(0,w.qsp)(d,"item",{properties:"cover-image"});return r?r.getAttribute("href"):""}}},{key:"getElementText",value:function(d,h){var f=d.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/",h),n;return!f||f.length===0?"":(n=f[0],n.childNodes.length?n.childNodes[0].nodeValue:"")}},{key:"getPropertyText",value:function(d,h){var f=(0,w.qsp)(d,"meta",{property:h});return f&&f.childNodes.length?f.childNodes[0].nodeValue:""}},{key:"load",value:function(d){var h=this;return this.metadata=d.metadata,this.spine=d.spine.map(function(f,n){return f.index=n,f}),d.resources.forEach(function(f,n){h.manifest[n]=f,f.rel&&f.rel[0]==="cover"&&(h.coverPath=f.href)}),this.spineNodeIndex=0,this.toc=d.toc.map(function(f,n){return f.label=f.title,f}),{metadata:this.metadata,spine:this.spine,manifest:this.manifest,navPath:this.navPath,ncxPath:this.ncxPath,coverPath:this.coverPath,spineNodeIndex:this.spineNodeIndex,toc:this.toc}}},{key:"destroy",value:function(){this.manifest=void 0,this.navPath=void 0,this.ncxPath=void 0,this.coverPath=void 0,this.spineNodeIndex=void 0,this.spine=void 0,this.metadata=void 0}}]),k}();y.default=T,C.exports=y.default},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function k(g,d){for(var h=0;h<d.length;h++){var f=d[h];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(g,f.key,f)}}return function(g,d,h){return d&&k(g.prototype,d),h&&k(g,h),g}}(),w=m(0);function R(k,g){if(!(k instanceof g))throw new TypeError("Cannot call a class as a function")}var T=function(){function k(g){R(this,k),this.toc=[],this.tocByHref={},this.tocById={},this.landmarks=[],this.landmarksByType={},this.length=0,g&&this.parse(g)}return S(k,[{key:"parse",value:function(d){var h=d.nodeType,f=void 0,n=void 0;h&&(f=(0,w.qs)(d,"html"),n=(0,w.qs)(d,"ncx")),h?f?(this.toc=this.parseNav(d),this.landmarks=this.parseLandmarks(d)):n&&(this.toc=this.parseNcx(d)):this.toc=this.load(d),this.length=0,this.unpack(this.toc)}},{key:"unpack",value:function(d){for(var h,f=0;f<d.length;f++)h=d[f],h.href&&(this.tocByHref[h.href]=f),h.id&&(this.tocById[h.id]=f),this.length++,h.subitems.length&&this.unpack(h.subitems)}},{key:"get",value:function(d){var h;return d?(d.indexOf("#")===0?h=this.tocById[d.substring(1)]:d in this.tocByHref&&(h=this.tocByHref[d]),this.toc[h]):this.toc}},{key:"landmark",value:function(d){var h;return d?(h=this.landmarksByType[d],this.landmarks[h]):this.landmarks}},{key:"parseNav",value:function(d){var h=(0,w.querySelectorByType)(d,"nav","toc"),f=h?(0,w.qsa)(h,"li"):[],n=f.length,l,e={},r=[],t,i;if(!f||n===0)return r;for(l=0;l<n;++l)t=this.navItem(f[l]),t&&(e[t.id]=t,t.parent?(i=e[t.parent],i.subitems.push(t)):r.push(t));return r}},{key:"navItem",value:function(d){var h=d.getAttribute("id")||void 0,f=(0,w.filterChildren)(d,"a",!0);if(!!f){var n=f.getAttribute("href")||"",l=f.textContent||"",e=[],r=(0,w.getParentByTagName)(d,"li"),t=void 0;for(r&&(t=r.getAttribute("id"));!t&&r;)r=(0,w.getParentByTagName)(r,"li"),r&&(t=r.getAttribute("id"));return{id:h,href:n,label:l,subitems:e,parent:t}}}},{key:"parseLandmarks",value:function(d){var h=(0,w.querySelectorByType)(d,"nav","landmarks"),f=h?(0,w.qsa)(h,"li"):[],n=f.length,l,e=[],r;if(!f||n===0)return e;for(l=0;l<n;++l)r=this.landmarkItem(f[l]),r&&(e.push(r),this.landmarksByType[r.type]=l);return e}},{key:"landmarkItem",value:function(d){var h=(0,w.filterChildren)(d,"a",!0);if(!!h){var f=h.getAttributeNS("http://www.idpf.org/2007/ops","type")||void 0,n=h.getAttribute("href")||"",l=h.textContent||"";return{href:n,label:l,type:f}}}},{key:"parseNcx",value:function(d){var h=(0,w.qsa)(d,"navPoint"),f=h.length,n,l={},e=[],r,t;if(!h||f===0)return e;for(n=0;n<f;++n)r=this.ncxItem(h[n]),l[r.id]=r,r.parent?(t=l[r.parent],t.subitems.push(r)):e.push(r);return e}},{key:"ncxItem",value:function(d){var h=d.getAttribute("id")||!1,f=(0,w.qs)(d,"content"),n=f.getAttribute("src"),l=(0,w.qs)(d,"navLabel"),e=l.textContent?l.textContent:"",r=[],t=d.parentNode,i;return t&&t.nodeName==="navPoint"&&(i=t.getAttribute("id")),{id:h,href:n,label:e,subitems:r,parent:i}}},{key:"load",value:function(d){var h=this;return d.map(function(f){return f.label=f.title,f.children&&(f.subitems=h.load(f.children)),f})}},{key:"forEach",value:function(d){return this.toc.forEach(d)}}]),k}();y.default=T,C.exports=y.default},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function i(s,u){for(var c=0;c<u.length;c++){var a=u[c];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(s,a.key,a)}}return function(s,u,c){return u&&i(s.prototype,u),c&&i(s,c),s}}(),w=m(7),R=m(0),T=m(5),k=e(T),g=m(17),d=e(g),h=m(4),f=e(h),n=m(6),l=e(n);function e(i){return i&&i.__esModule?i:{default:i}}function r(i,s){if(!(i instanceof s))throw new TypeError("Cannot call a class as a function")}var t=function(){function i(s,u){r(this,i),this.settings={replacements:u&&u.replacements||"base64",archive:u&&u.archive,resolver:u&&u.resolver,request:u&&u.request},this.manifest=s,this.resources=Object.keys(s).map(function(c){return s[c]}),this.replacementUrls=[],this.html=[],this.assets=[],this.css=[],this.urls=[],this.cssUrls=[],this.split(),this.splitUrls()}return S(i,[{key:"split",value:function(){this.html=this.resources.filter(function(u){if(u.type==="application/xhtml+xml"||u.type==="text/html")return!0}),this.assets=this.resources.filter(function(u){if(u.type!=="application/xhtml+xml"&&u.type!=="text/html")return!0}),this.css=this.resources.filter(function(u){if(u.type==="text/css")return!0})}},{key:"splitUrls",value:function(){this.urls=this.assets.map(function(u){return u.href}.bind(this)),this.cssUrls=this.css.map(function(u){return u.href})}},{key:"createUrl",value:function(u){var c=new k.default(u),a=d.default.lookup(c.filename);return this.settings.archive?this.settings.archive.createUrl(u,{base64:this.settings.replacements==="base64"}):this.settings.replacements==="base64"?this.settings.request(u,"blob").then(function(o){return(0,R.blob2base64)(o)}).then(function(o){return(0,R.createBase64Url)(o,a)}):this.settings.request(u,"blob").then(function(o){return(0,R.createBlobUrl)(o,a)})}},{key:"replacements",value:function(){var u=this;if(this.settings.replacements==="none")return new Promise(function(a){a(this.urls)}.bind(this));var c=this.urls.map(function(a){var o=u.settings.resolver(a);return u.createUrl(o).catch(function(v){return console.error(v),null})});return Promise.all(c).then(function(a){return u.replacementUrls=a.filter(function(o){return typeof o=="string"}),a})}},{key:"replaceCss",value:function(u,c){var a=[];return u=u||this.settings.archive,c=c||this.settings.resolver,this.cssUrls.forEach(function(o){var v=this.createCssFile(o,u,c).then(function(p){var b=this.urls.indexOf(o);b>-1&&(this.replacementUrls[b]=p)}.bind(this));a.push(v)}.bind(this)),Promise.all(a)}},{key:"createCssFile",value:function(u){var c=this,a;if(l.default.isAbsolute(u))return new Promise(function(b){b()});var o=this.settings.resolver(u),v;this.settings.archive?v=this.settings.archive.getText(o):v=this.settings.request(o,"text");var p=this.urls.map(function(b){var E=c.settings.resolver(b),L=new f.default(o).relative(E);return L});return v?v.then(function(b){return b=(0,w.substitute)(b,p,c.replacementUrls),c.settings.replacements==="base64"?a=(0,R.createBase64Url)(b,"text/css"):a=(0,R.createBlobUrl)(b,"text/css"),a},function(b){return new Promise(function(E){E()})}):new Promise(function(b){b()})}},{key:"relativeTo",value:function(u,c){return c=c||this.settings.resolver,this.urls.map(function(a){var o=c(a),v=new f.default(u).relative(o);return v}.bind(this))}},{key:"get",value:function(u){var c=this.urls.indexOf(u);if(c!==-1)return this.replacementUrls.length?new Promise(function(a,o){a(this.replacementUrls[c])}.bind(this)):this.createUrl(u)}},{key:"substitute",value:function(u,c){var a;return c?a=this.relativeTo(c):a=this.urls,(0,w.substitute)(u,a,this.replacementUrls)}},{key:"destroy",value:function(){this.settings=void 0,this.manifest=void 0,this.resources=void 0,this.replacementUrls=void 0,this.html=void 0,this.assets=void 0,this.css=void 0,this.urls=void 0,this.cssUrls=void 0}}]),i}();y.default=t,C.exports=y.default},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function h(f,n){for(var l=0;l<n.length;l++){var e=n[l];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(f,e.key,e)}}return function(f,n,l){return n&&h(f.prototype,n),l&&h(f,l),f}}(),w=m(1),R=k(w),T=m(0);function k(h){return h&&h.__esModule?h:{default:h}}function g(h,f){if(!(h instanceof f))throw new TypeError("Cannot call a class as a function")}var d=function(){function h(f){g(this,h),this.pages=[],this.locations=[],this.epubcfi=new R.default,this.firstPage=0,this.lastPage=0,this.totalPages=0,this.toc=void 0,this.ncx=void 0,f&&(this.pageList=this.parse(f)),this.pageList&&this.pageList.length&&this.process(this.pageList)}return S(h,[{key:"parse",value:function(n){var l=(0,T.qs)(n,"html"),e=(0,T.qs)(n,"ncx");if(l)return this.parseNav(n);if(e)return}},{key:"parseNav",value:function(n){var l=(0,T.querySelectorByType)(n,"nav","page-list"),e=l?(0,T.qsa)(l,"li"):[],r=e.length,t,i=[],s;if(!e||r===0)return i;for(t=0;t<r;++t)s=this.item(e[t]),i.push(s);return i}},{key:"item",value:function(n){var l=(0,T.qs)(n,"a"),e=l.getAttribute("href")||"",r=l.textContent||"",t=parseInt(r),i=e.indexOf("epubcfi"),s,u,c;return i!=-1?(s=e.split("#"),u=s[0],c=s.length>1?s[1]:!1,{cfi:c,href:e,packageUrl:u,page:t}):{href:e,page:t}}},{key:"process",value:function(n){n.forEach(function(l){this.pages.push(l.page),l.cfi&&this.locations.push(l.cfi)},this),this.firstPage=parseInt(this.pages[0]),this.lastPage=parseInt(this.pages[this.pages.length-1]),this.totalPages=this.lastPage-this.firstPage}},{key:"pageFromCfi",value:function(n){var l=-1;if(this.locations.length===0)return-1;var e=(0,T.indexOfSorted)(n,this.locations,this.epubcfi.compare);return e!=-1?l=this.pages[e]:(e=(0,T.locationOf)(n,this.locations,this.epubcfi.compare),l=e-1>=0?this.pages[e-1]:this.pages[0],l!==void 0||(l=-1)),l}},{key:"cfiFromPage",value:function(n){var l=-1;typeof n!="number"&&(n=parseInt(n));var e=this.pages.indexOf(n);return e!=-1&&(l=this.locations[e]),l}},{key:"pageFromPercentage",value:function(n){var l=Math.round(this.totalPages*n);return l}},{key:"percentageFromPage",value:function(n){var l=(n-this.firstPage)/this.totalPages;return Math.round(l*1e3)/1e3}},{key:"percentageFromCfi",value:function(n){var l=this.pageFromCfi(n),e=this.percentageFromPage(l);return e}},{key:"destroy",value:function(){this.pages=void 0,this.locations=void 0,this.epubcfi=void 0,this.pageList=void 0,this.toc=void 0,this.ncx=void 0}}]),h}();y.default=d,C.exports=y.default},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function f(n,l){for(var e=0;e<l.length;e++){var r=l[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}return function(n,l,e){return l&&f(n.prototype,l),e&&f(n,e),n}}(),w=m(0),R=m(3),T=m(2),k=g(T);function g(f){return f&&f.__esModule?f:{default:f}}function d(f,n){if(!(f instanceof n))throw new TypeError("Cannot call a class as a function")}var h=function(){function f(n){d(this,f),this.settings=n,this.name=n.layout||"reflowable",this._spread=n.spread!=="none",this._minSpreadWidth=n.minSpreadWidth||800,this._evenSpreads=n.evenSpreads||!1,n.flow==="scrolled"||n.flow==="scrolled-continuous"||n.flow==="scrolled-doc"?this._flow="scrolled":this._flow="paginated",this.width=0,this.height=0,this.spreadWidth=0,this.delta=0,this.columnWidth=0,this.gap=0,this.divisor=1,this.props={name:this.name,spread:this._spread,flow:this._flow,width:0,height:0,spreadWidth:0,delta:0,columnWidth:0,gap:0,divisor:1}}return S(f,[{key:"flow",value:function(l){return typeof l!="undefined"&&(l==="scrolled"||l==="scrolled-continuous"||l==="scrolled-doc"?this._flow="scrolled":this._flow="paginated",this.update({flow:this._flow})),this._flow}},{key:"spread",value:function(l,e){return l&&(this._spread=l!=="none",this.update({spread:this._spread})),e>=0&&(this._minSpreadWidth=e),this._spread}},{key:"calculate",value:function(l,e,r){var t=1,i=r||0,s=l,u=e,c=Math.floor(s/12),a,o,v,p;this._spread&&s>=this._minSpreadWidth?t=2:t=1,this.name==="reflowable"&&this._flow==="paginated"&&!(r>=0)&&(i=c%2==0?c:c-1),this.name==="pre-paginated"&&(i=0),t>1?(a=s/t-i,v=a+i):(a=s,v=s),this.name==="pre-paginated"&&t>1&&(s=a),o=a*t+i,p=s,this.width=s,this.height=u,this.spreadWidth=o,this.pageWidth=v,this.delta=p,this.columnWidth=a,this.gap=i,this.divisor=t,this.update({width:s,height:u,spreadWidth:o,pageWidth:v,delta:p,columnWidth:a,gap:i,divisor:t})}},{key:"format",value:function(l){var e;return this.name==="pre-paginated"?e=l.fit(this.columnWidth,this.height):this._flow==="paginated"?e=l.columns(this.width,this.height,this.columnWidth,this.gap):e=l.size(this.width,null),e}},{key:"count",value:function(l,e){var r=void 0,t=void 0;return this.name==="pre-paginated"?(r=1,t=1):this._flow==="paginated"?(e=e||this.delta,r=Math.ceil(l/e),t=r*this.divisor):(e=e||this.height,r=Math.ceil(l/e),t=r),{spreads:r,pages:t}}},{key:"update",value:function(l){var e=this;if(Object.keys(l).forEach(function(t){e.props[t]===l[t]&&delete l[t]}),Object.keys(l).length>0){var r=(0,w.extend)(this.props,l);this.emit(R.EVENTS.LAYOUT.UPDATED,r,l)}}}]),f}();(0,k.default)(h.prototype),y.default=h,C.exports=y.default},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},w=function(){function h(f,n){for(var l=0;l<n.length;l++){var e=n[l];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(f,e.key,e)}}return function(f,n,l){return n&&h(f.prototype,n),l&&h(f,l),f}}(),R=m(5),T=k(R);function k(h){return h&&h.__esModule?h:{default:h}}function g(h,f){if(!(h instanceof f))throw new TypeError("Cannot call a class as a function")}var d=function(){function h(f){g(this,h),this.rendition=f,this._themes={default:{rules:{},url:"",serialized:""}},this._overrides={},this._current="default",this._injected=[],this.rendition.hooks.content.register(this.inject.bind(this)),this.rendition.hooks.content.register(this.overrides.bind(this))}return w(h,[{key:"register",value:function(){if(arguments.length!==0){if(arguments.length===1&&S(arguments[0])==="object")return this.registerThemes(arguments[0]);if(arguments.length===1&&typeof arguments[0]=="string")return this.default(arguments[0]);if(arguments.length===2&&typeof arguments[1]=="string")return this.registerUrl(arguments[0],arguments[1]);if(arguments.length===2&&S(arguments[1])==="object")return this.registerRules(arguments[0],arguments[1])}}},{key:"default",value:function(n){if(!!n){if(typeof n=="string")return this.registerUrl("default",n);if((typeof n=="undefined"?"undefined":S(n))==="object")return this.registerRules("default",n)}}},{key:"registerThemes",value:function(n){for(var l in n)n.hasOwnProperty(l)&&(typeof n[l]=="string"?this.registerUrl(l,n[l]):this.registerRules(l,n[l]))}},{key:"registerUrl",value:function(n,l){var e=new T.default(l);this._themes[n]={url:e.toString()},this._injected[n]&&this.update(n)}},{key:"registerRules",value:function(n,l){this._themes[n]={rules:l},this._injected[n]&&this.update(n)}},{key:"select",value:function(n){var l=this._current,e;this._current=n,this.update(n),e=this.rendition.getContents(),e.forEach(function(r){r.removeClass(l),r.addClass(n)})}},{key:"update",value:function(n){var l=this,e=this.rendition.getContents();e.forEach(function(r){l.add(n,r)})}},{key:"inject",value:function(n){var l=[],e=this._themes,r;for(var t in e)e.hasOwnProperty(t)&&(t===this._current||t==="default")&&(r=e[t],(r.rules&&Object.keys(r.rules).length>0||r.url&&l.indexOf(r.url)===-1)&&this.add(t,n),this._injected.push(t));this._current!="default"&&n.addClass(this._current)}},{key:"add",value:function(n,l){var e=this._themes[n];!e||!l||(e.url?l.addStylesheet(e.url):e.serialized||e.rules&&(l.addStylesheetRules(e.rules),e.injected=!0))}},{key:"override",value:function(n,l){var e=this,r=this.rendition.getContents();this._overrides[n]=l,r.forEach(function(t){t.css(n,e._overrides[n])})}},{key:"overrides",value:function(n){var l=this._overrides;for(var e in l)l.hasOwnProperty(e)&&n.css(e,l[e])}},{key:"fontSize",value:function(n){this.override("font-size",n)}},{key:"font",value:function(n){this.override("font-family",n)}},{key:"destroy",value:function(){this.rendition=void 0,this._themes=void 0,this._overrides=void 0,this._current=void 0,this._injected=void 0}}]),h}();y.default=d,C.exports=y.default},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function n(l,e){for(var r=0;r<e.length;r++){var t=e[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(l,t.key,t)}}return function(l,e,r){return e&&n(l.prototype,e),r&&n(l,r),l}}(),w=m(2),R=g(w),T=m(1),k=g(T);function g(n){return n&&n.__esModule?n:{default:n}}function d(n,l){if(!(n instanceof l))throw new TypeError("Cannot call a class as a function")}var h=function(){function n(l){d(this,n),this.rendition=l,this.highlights=[],this.underlines=[],this.marks=[],this._annotations={},this._annotationsBySectionIndex={},this.rendition.hooks.render.register(this.inject.bind(this)),this.rendition.hooks.unloaded.register(this.clear.bind(this))}return S(n,[{key:"add",value:function(e,r,t,i){var s=encodeURI(r),u=new k.default(r),c=u.spinePos,a=new f({type:e,cfiRange:r,data:t,sectionIndex:c,cb:i});this._annotations[s]=a,c in this._annotationsBySectionIndex?this._annotationsBySectionIndex[c].push(s):this._annotationsBySectionIndex[c]=[s];var o=this.rendition.views();return o.forEach(function(v){a.sectionIndex===v.index&&a.attach(v)}),a}},{key:"remove",value:function(e,r){var t=this,i=encodeURI(e);if(i in this._annotations){var s=this._annotations[i];if(r&&s.type!==r)return;var u=this.rendition.views();u.forEach(function(c){t._removeFromAnnotationBySectionIndex(s.sectionIndex,i),s.sectionIndex===c.index&&s.detach(c)}),delete this._annotations[i]}}},{key:"_removeFromAnnotationBySectionIndex",value:function(e,r){this._annotationsBySectionIndex[e]=this._annotationsAt(e).filter(function(t){return t!==r})}},{key:"_annotationsAt",value:function(e){return this._annotationsBySectionIndex[e]}},{key:"highlight",value:function(e,r,t){this.add("highlight",e,r,t)}},{key:"underline",value:function(e,r,t){this.add("underline",e,r,t)}},{key:"mark",value:function(e,r,t){this.add("mark",e,r,t)}},{key:"each",value:function(){return this._annotations.forEach.apply(this._annotations,arguments)}},{key:"inject",value:function(e){var r=this,t=e.index;if(t in this._annotationsBySectionIndex){var i=this._annotationsBySectionIndex[t];i.forEach(function(s){var u=r._annotations[s];u.attach(e)})}}},{key:"clear",value:function(e){var r=this,t=e.index;if(t in this._annotationsBySectionIndex){var i=this._annotationsBySectionIndex[t];i.forEach(function(s){var u=r._annotations[s];u.detach(e)})}}},{key:"show",value:function(){}},{key:"hide",value:function(){}}]),n}(),f=function(){function n(l){var e=l.type,r=l.cfiRange,t=l.data,i=l.sectionIndex,s=l.cb;d(this,n),this.type=e,this.cfiRange=r,this.data=t,this.sectionIndex=i,this.mark=void 0,this.cb=s}return S(n,[{key:"update",value:function(e){this.data=e}},{key:"attach",value:function(e){var r=this.cfiRange,t=this.data,i=this.type,s=this.mark,u=this.cb,c=void 0;return i==="highlight"?c=e.highlight(r,t,u):i==="underline"?c=e.underline(r,t,u):i==="mark"&&(c=e.mark(r,t,u)),this.mark=c,c}},{key:"detach",value:function(e){var r=this.cfiRange,t=this.type,i=void 0;return e&&(t==="highlight"?i=e.unhighlight(r):t==="underline"?i=e.ununderline(r):t==="mark"&&(i=e.unmark(r))),this.mark=void 0,i}},{key:"text",value:function(){}}]),n}();(0,R.default)(f.prototype),y.default=h,C.exports=y.default},function(C,y,m){"use strict";var S=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a};Object.defineProperty(y,"__esModule",{value:!0}),y.Underline=y.Highlight=y.Mark=y.Pane=void 0;var w=function a(o,v,p){o===null&&(o=Function.prototype);var b=Object.getOwnPropertyDescriptor(o,v);if(b===void 0){var E=Object.getPrototypeOf(o);return E===null?void 0:a(E,v,p)}else{if("value"in b)return b.value;var L=b.get;return L===void 0?void 0:L.call(p)}},R=function(){function a(o,v){for(var p=0;p<v.length;p++){var b=v[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(o,b.key,b)}}return function(o,v,p){return v&&a(o.prototype,v),p&&a(o,p),o}}(),T=m(54),k=h(T),g=m(55),d=h(g);function h(a){return a&&a.__esModule?a:{default:a}}function f(a,o){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return o&&((typeof o=="undefined"?"undefined":S(o))==="object"||typeof o=="function")?o:a}function n(a,o){if(typeof o!="function"&&o!==null)throw new TypeError("Super expression must either be null or a function, not "+(typeof o=="undefined"?"undefined":S(o)));a.prototype=Object.create(o&&o.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),o&&(Object.setPrototypeOf?Object.setPrototypeOf(a,o):a.__proto__=o)}function l(a,o){if(!(a instanceof o))throw new TypeError("Cannot call a class as a function")}var e=y.Pane=function(){function a(o){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:document.body;l(this,a),this.target=o,this.element=k.default.createElement("svg"),this.marks=[],this.element.style.position="absolute",this.element.setAttribute("pointer-events","none"),d.default.proxyMouse(this.target,this.marks),this.container=v,this.container.appendChild(this.element),this.render()}return R(a,[{key:"addMark",value:function(v){var p=k.default.createElement("g");return this.element.appendChild(p),v.bind(p,this.container),this.marks.push(v),v.render(),v}},{key:"removeMark",value:function(v){var p=this.marks.indexOf(v);if(p!==-1){var b=v.unbind();this.element.removeChild(b),this.marks.splice(p,1)}}},{key:"render",value:function(){u(this.element,s(this.target,this.container));var v=!0,p=!1,b=void 0;try{for(var E=this.marks[Symbol.iterator](),L;!(v=(L=E.next()).done);v=!0){var A=L.value;A.render()}}catch(B){p=!0,b=B}finally{try{!v&&E.return&&E.return()}finally{if(p)throw b}}}}]),a}(),r=y.Mark=function(){function a(){l(this,a),this.element=null}return R(a,[{key:"bind",value:function(v,p){this.element=v,this.container=p}},{key:"unbind",value:function(){var v=this.element;return this.element=null,v}},{key:"render",value:function(){}},{key:"dispatchEvent",value:function(v){!this.element||this.element.dispatchEvent(v)}},{key:"getBoundingClientRect",value:function(){return this.element.getBoundingClientRect()}},{key:"getClientRects",value:function(){for(var v=[],p=this.element.firstChild;p;)v.push(p.getBoundingClientRect()),p=p.nextSibling;return v}},{key:"filteredRanges",value:function(){var v=Array.from(this.range.getClientRects());return v.filter(function(p){for(var b=0;b<v.length;b++){if(v[b]===p)return!0;var E=c(v[b],p);if(E)return!1}return!0})}}]),a}(),t=y.Highlight=function(a){n(o,a);function o(v,p,b,E){l(this,o);var L=f(this,(o.__proto__||Object.getPrototypeOf(o)).call(this));return L.range=v,L.className=p,L.data=b||{},L.attributes=E||{},L}return R(o,[{key:"bind",value:function(p,b){w(o.prototype.__proto__||Object.getPrototypeOf(o.prototype),"bind",this).call(this,p,b);for(var E in this.data)this.data.hasOwnProperty(E)&&(this.element.dataset[E]=this.data[E]);for(var E in this.attributes)this.attributes.hasOwnProperty(E)&&this.element.setAttribute(E,this.attributes[E]);this.className&&this.element.classList.add(this.className)}},{key:"render",value:function(){for(;this.element.firstChild;)this.element.removeChild(this.element.firstChild);for(var p=this.element.ownerDocument.createDocumentFragment(),b=this.filteredRanges(),E=this.element.getBoundingClientRect(),L=this.container.getBoundingClientRect(),A=0,B=b.length;A<B;A++){var D=b[A],V=k.default.createElement("rect");V.setAttribute("x",D.left-E.left+L.left),V.setAttribute("y",D.top-E.top+L.top),V.setAttribute("height",D.height),V.setAttribute("width",D.width),p.appendChild(V)}this.element.appendChild(p)}}]),o}(r),i=y.Underline=function(a){n(o,a);function o(v,p,b,E){return l(this,o),f(this,(o.__proto__||Object.getPrototypeOf(o)).call(this,v,p,b,E))}return R(o,[{key:"render",value:function(){for(;this.element.firstChild;)this.element.removeChild(this.element.firstChild);for(var p=this.element.ownerDocument.createDocumentFragment(),b=this.filteredRanges(),E=this.element.getBoundingClientRect(),L=this.container.getBoundingClientRect(),A=0,B=b.length;A<B;A++){var D=b[A],V=k.default.createElement("rect");V.setAttribute("x",D.left-E.left+L.left),V.setAttribute("y",D.top-E.top+L.top),V.setAttribute("height",D.height),V.setAttribute("width",D.width),V.setAttribute("fill","none");var N=k.default.createElement("line");N.setAttribute("x1",D.left-E.left+L.left),N.setAttribute("x2",D.left-E.left+L.left+D.width),N.setAttribute("y1",D.top-E.top+L.top+D.height-1),N.setAttribute("y2",D.top-E.top+L.top+D.height-1),N.setAttribute("stroke-width",1),N.setAttribute("stroke","black"),N.setAttribute("stroke-linecap","square"),p.appendChild(V),p.appendChild(N)}this.element.appendChild(p)}}]),o}(t);function s(a,o){var v=o.getBoundingClientRect(),p=a.getBoundingClientRect();return{top:p.top-v.top,left:p.left-v.left,height:a.scrollHeight,width:a.scrollWidth}}function u(a,o){a.style.top=o.top+"px",a.style.left=o.left+"px",a.style.height=o.height+"px",a.style.width=o.width+"px"}function c(a,o){return o.right<=a.right&&o.left>=a.left&&o.top>=a.top&&o.bottom<=a.bottom}},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0}),y.createElement=S;function S(w){return document.createElementNS("http://www.w3.org/2000/svg",w)}y.default={createElement:S}},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0}),y.proxyMouse=S,y.clone=w,y.default={proxyMouse:S};function S(T,k){function g(n){for(var l=k.length-1;l>=0;l--){var e=k[l],r=n.clientX,t=n.clientY;if(n.touches&&n.touches.length&&(r=n.touches[0].clientX,t=n.touches[0].clientY),!!R(e,T,r,t)){e.dispatchEvent(w(n));break}}}if(T.nodeName==="iframe"||T.nodeName==="IFRAME")try{this.target=T.contentDocument}catch(n){this.target=T}else this.target=T;for(var d=["mouseup","mousedown","click","touchstart"],h=0;h<d.length;h++){var f=d[h];this.target.addEventListener(f,function(n){return g(n)},!1)}}function w(T){var k=Object.assign({},T,{bubbles:!1});try{return new MouseEvent(T.type,k)}catch(d){var g=document.createEvent("MouseEvents");return g.initMouseEvent(T.type,!1,k.cancelable,k.view,k.detail,k.screenX,k.screenY,k.clientX,k.clientY,k.ctrlKey,k.altKey,k.shiftKey,k.metaKey,k.button,k.relatedTarget),g}}function R(T,k,g,d){var h=k.getBoundingClientRect();function f(t,i,s){var u=t.top-h.top,c=t.left-h.left,a=u+t.height,o=c+t.width;return u<=s&&c<=i&&a>s&&o>i}var n=T.getBoundingClientRect();if(!f(n,g,d))return!1;for(var l=T.getClientRects(),e=0,r=l.length;e<r;e++)if(f(l[e],g,d))return!0;return!1}},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function h(f,n){for(var l=0;l<n.length;l++){var e=n[l];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(f,e.key,e)}}return function(f,n,l){return n&&h(f.prototype,n),l&&h(f,l),f}}(),w=m(0),R=m(57),T=k(R);function k(h){return h&&h.__esModule?h:{default:h}}function g(h,f){if(!(h instanceof f))throw new TypeError("Cannot call a class as a function")}var d=function(){function h(f){g(this,h),this.settings=f||{},this.id="epubjs-container-"+(0,w.uuid)(),this.container=this.create(this.settings),this.settings.hidden&&(this.wrapper=this.wrap(this.container))}return S(h,[{key:"create",value:function(n){var l=n.height,e=n.width,r=n.overflow||!1,t=n.axis||"vertical",i=n.direction;n.height&&(0,w.isNumber)(n.height)&&(l=n.height+"px"),n.width&&(0,w.isNumber)(n.width)&&(e=n.width+"px");var s=document.createElement("div");return s.id=this.id,s.classList.add("epub-container"),s.style.wordSpacing="0",s.style.lineHeight="0",s.style.verticalAlign="top",s.style.position="relative",t==="horizontal"&&(s.style.display="flex",s.style.flexDirection="row",s.style.flexWrap="nowrap"),e&&(s.style.width=e),l&&(s.style.height=l),r&&(s.style.overflow=r),i&&(s.dir=i,s.style.direction=i),i&&this.settings.fullsize&&(document.body.style.direction=i),s}},{key:"wrap",value:function(n){var l=document.createElement("div");return l.style.visibility="hidden",l.style.overflow="hidden",l.style.width="0",l.style.height="0",l.appendChild(n),l}},{key:"getElement",value:function(n){var l;if((0,w.isElement)(n)?l=n:typeof n=="string"&&(l=document.getElementById(n)),!l)throw new Error("Not an Element");return l}},{key:"attachTo",value:function(n){var l=this.getElement(n),e;if(!!l)return this.settings.hidden?e=this.wrapper:e=this.container,l.appendChild(e),this.element=l,l}},{key:"getContainer",value:function(){return this.container}},{key:"onResize",value:function(n){(!(0,w.isNumber)(this.settings.width)||!(0,w.isNumber)(this.settings.height))&&(this.resizeFunc=(0,T.default)(n,50),window.addEventListener("resize",this.resizeFunc,!1))}},{key:"onOrientationChange",value:function(n){this.orientationChangeFunc=n,window.addEventListener("orientationchange",this.orientationChangeFunc,!1)}},{key:"size",value:function(n,l){var e;n===null&&(e=this.element.getBoundingClientRect(),e.width&&(n=e.width,this.container.style.width=e.width+"px")),l===null&&(e=e||this.element.getBoundingClientRect(),e.height&&(l=e.height,this.container.style.height=e.height+"px")),(0,w.isNumber)(n)||(e=this.container.getBoundingClientRect(),n=e.width),(0,w.isNumber)(l)||(e=e||this.container.getBoundingClientRect(),l=e.height),this.containerStyles=window.getComputedStyle(this.container),this.containerPadding={left:parseFloat(this.containerStyles["padding-left"])||0,right:parseFloat(this.containerStyles["padding-right"])||0,top:parseFloat(this.containerStyles["padding-top"])||0,bottom:parseFloat(this.containerStyles["padding-bottom"])||0};var r=(0,w.windowBounds)();return n||(n=r.width),(this.settings.fullsize||!l)&&(l=r.height),{width:n-this.containerPadding.left-this.containerPadding.right,height:l-this.containerPadding.top-this.containerPadding.bottom}}},{key:"bounds",value:function(){var n=void 0;return this.container.style.overflow!=="visible"&&(n=this.container&&this.container.getBoundingClientRect()),!n||!n.width||!n.height?(0,w.windowBounds)():n}},{key:"getSheet",value:function(){var n=document.createElement("style");return n.appendChild(document.createTextNode("")),document.head.appendChild(n),n.sheet}},{key:"addStyleRules",value:function(n,l){var e="#"+this.id+" ",r="";this.sheet||(this.sheet=this.getSheet()),l.forEach(function(t){for(var i in t)t.hasOwnProperty(i)&&(r+=i+":"+t[i]+";")}),this.sheet.insertRule(e+n+" {"+r+"}",0)}},{key:"axis",value:function(n){n==="horizontal"?(this.container.style.display="flex",this.container.style.flexDirection="row",this.container.style.flexWrap="nowrap"):this.container.style.display="block"}},{key:"direction",value:function(n){this.container&&(this.container.dir=n,this.container.style.direction=n),this.settings.fullsize&&(document.body.style.direction=n)}},{key:"destroy",value:function(){var n;this.element&&(this.settings.hidden?n=this.wrapper:n=this.container,this.element.contains(this.container)&&this.element.removeChild(this.container),window.removeEventListener("resize",this.resizeFunc),window.removeEventListener("orientationChange",this.orientationChangeFunc))}}]),h}();y.default=d,C.exports=y.default},function(C,y,m){var S=m(21),w=m(15),R="Expected a function";function T(k,g,d){var h=!0,f=!0;if(typeof k!="function")throw new TypeError(R);return w(d)&&(h="leading"in d?!!d.leading:h,f="trailing"in d?!!d.trailing:f),S(k,g,{leading:h,maxWait:g,trailing:f})}C.exports=T},function(C,y,m){var S=m(22),w=function(){return S.Date.now()};C.exports=w},function(C,y,m){(function(S){var w=typeof S=="object"&&S&&S.Object===Object&&S;C.exports=w}).call(y,m(8))},function(C,y,m){var S=m(15),w=m(61),R=0/0,T=/^\s+|\s+$/g,k=/^[-+]0x[0-9a-f]+$/i,g=/^0b[01]+$/i,d=/^0o[0-7]+$/i,h=parseInt;function f(n){if(typeof n=="number")return n;if(w(n))return R;if(S(n)){var l=typeof n.valueOf=="function"?n.valueOf():n;n=S(l)?l+"":l}if(typeof n!="string")return n===0?n:+n;n=n.replace(T,"");var e=g.test(n);return e||d.test(n)?h(n.slice(2),e?2:8):k.test(n)?R:+n}C.exports=f},function(C,y,m){var S=m(62),w=m(65),R="[object Symbol]";function T(k){return typeof k=="symbol"||w(k)&&S(k)==R}C.exports=T},function(C,y,m){var S=m(23),w=m(63),R=m(64),T="[object Null]",k="[object Undefined]",g=S?S.toStringTag:void 0;function d(h){return h==null?h===void 0?k:T:g&&g in Object(h)?w(h):R(h)}C.exports=d},function(C,y,m){var S=m(23),w=Object.prototype,R=w.hasOwnProperty,T=w.toString,k=S?S.toStringTag:void 0;function g(d){var h=R.call(d,k),f=d[k];try{d[k]=void 0;var n=!0}catch(e){}var l=T.call(d);return n&&(h?d[k]=f:delete d[k]),l}C.exports=g},function(C,y){var m=Object.prototype,S=m.toString;function w(R){return S.call(R)}C.exports=w},function(C,y){function m(S){return S!=null&&typeof S=="object"}C.exports=m},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function T(k,g){for(var d=0;d<g.length;d++){var h=g[d];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(k,h.key,h)}}return function(k,g,d){return g&&T(k.prototype,g),d&&T(k,d),k}}();function w(T,k){if(!(T instanceof k))throw new TypeError("Cannot call a class as a function")}var R=function(){function T(k){w(this,T),this.container=k,this._views=[],this.length=0,this.hidden=!1}return S(T,[{key:"all",value:function(){return this._views}},{key:"first",value:function(){return this._views[0]}},{key:"last",value:function(){return this._views[this._views.length-1]}},{key:"indexOf",value:function(g){return this._views.indexOf(g)}},{key:"slice",value:function(){return this._views.slice.apply(this._views,arguments)}},{key:"get",value:function(g){return this._views[g]}},{key:"append",value:function(g){return this._views.push(g),this.container&&this.container.appendChild(g.element),this.length++,g}},{key:"prepend",value:function(g){return this._views.unshift(g),this.container&&this.container.insertBefore(g.element,this.container.firstChild),this.length++,g}},{key:"insert",value:function(g,d){return this._views.splice(d,0,g),this.container&&(d<this.container.children.length?this.container.insertBefore(g.element,this.container.children[d]):this.container.appendChild(g.element)),this.length++,g}},{key:"remove",value:function(g){var d=this._views.indexOf(g);d>-1&&this._views.splice(d,1),this.destroy(g),this.length--}},{key:"destroy",value:function(g){g.displayed&&g.destroy(),this.container&&this.container.removeChild(g.element),g=null}},{key:"forEach",value:function(){return this._views.forEach.apply(this._views,arguments)}},{key:"clear",value:function(){var g,d=this.length;if(!!this.length){for(var h=0;h<d;h++)g=this._views[h],this.destroy(g);this._views=[],this.length=0}}},{key:"find",value:function(g){for(var d,h=this.length,f=0;f<h;f++)if(d=this._views[f],d.displayed&&d.section.index==g.index)return d}},{key:"displayed",value:function(){for(var g=[],d,h=this.length,f=0;f<h;f++)d=this._views[f],d.displayed&&g.push(d);return g}},{key:"show",value:function(){for(var g,d=this.length,h=0;h<d;h++)g=this._views[h],g.displayed&&g.show();this.hidden=!1}},{key:"hide",value:function(){for(var g,d=this.length,h=0;h<d;h++)g=this._views[h],g.displayed&&g.hide();this.hidden=!0}}]),T}();y.default=R,C.exports=y.default},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function e(r,t){for(var i=0;i<t.length;i++){var s=t[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(r,s.key,s)}}return function(r,t,i){return t&&e(r.prototype,t),i&&e(r,i),r}}(),w=m(0),R=m(11),T=f(R),k=m(17),g=f(k),d=m(4),h=f(d);function f(e){return e&&e.__esModule?e:{default:e}}function n(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}var l=function(){function e(){n(this,e),this.zip=void 0,this.urlCache={},this.checkRequirements()}return S(e,[{key:"checkRequirements",value:function(){try{if(typeof JSZip=="undefined"){var t=m(68);this.zip=new t}else this.zip=new JSZip}catch(i){throw new Error("JSZip lib not loaded")}}},{key:"open",value:function(t,i){return this.zip.loadAsync(t,{base64:i})}},{key:"openUrl",value:function(t,i){return(0,T.default)(t,"binary").then(function(s){return this.zip.loadAsync(s,{base64:i})}.bind(this))}},{key:"request",value:function(t,i){var s=new w.defer,u,c=new h.default(t);return i||(i=c.extension),i=="blob"?u=this.getBlob(t):u=this.getText(t),u?u.then(function(a){var o=this.handleResponse(a,i);s.resolve(o)}.bind(this)):s.reject({message:"File not found in the epub: "+t,stack:new Error().stack}),s.promise}},{key:"handleResponse",value:function(t,i){var s;return i=="json"?s=JSON.parse(t):(0,w.isXml)(i)?s=(0,w.parse)(t,"text/xml"):i=="xhtml"?s=(0,w.parse)(t,"application/xhtml+xml"):i=="html"||i=="htm"?s=(0,w.parse)(t,"text/html"):s=t,s}},{key:"getBlob",value:function(t,i){var s=window.decodeURIComponent(t.substr(1)),u=this.zip.file(s);if(u)return i=i||g.default.lookup(u.name),u.async("uint8array").then(function(c){return new Blob([c],{type:i})})}},{key:"getText",value:function(t,i){var s=window.decodeURIComponent(t.substr(1)),u=this.zip.file(s);if(u)return u.async("string").then(function(c){return c})}},{key:"getBase64",value:function(t,i){var s=window.decodeURIComponent(t.substr(1)),u=this.zip.file(s);if(u)return i=i||g.default.lookup(u.name),u.async("base64").then(function(c){return"data:"+i+";base64,"+c})}},{key:"createUrl",value:function(t,i){var s=new w.defer,u=window.URL||window.webkitURL||window.mozURL,c,a,o=i&&i.base64;return t in this.urlCache?(s.resolve(this.urlCache[t]),s.promise):(o?(a=this.getBase64(t),a&&a.then(function(v){this.urlCache[t]=v,s.resolve(v)}.bind(this))):(a=this.getBlob(t),a&&a.then(function(v){c=u.createObjectURL(v),this.urlCache[t]=c,s.resolve(c)}.bind(this))),a||s.reject({message:"File not found in the epub: "+t,stack:new Error().stack}),s.promise)}},{key:"revokeUrl",value:function(t){var i=window.URL||window.webkitURL||window.mozURL,s=this.urlCache[t];s&&i.revokeObjectURL(s)}},{key:"destroy",value:function(){var t=window.URL||window.webkitURL||window.mozURL;for(var i in this.urlCache)t.revokeObjectURL(i);this.zip=void 0,this.urlCache={}}}]),e}();y.default=l,C.exports=y.default},function(C,y){if(typeof se=="undefined"){var m=new Error('Cannot find module "jszip"');throw m.code="MODULE_NOT_FOUND",m}C.exports=se},function(C,y,m){"use strict";(function(S,w){var R,T,k,g=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d};(function(d,h){d||(d=window||S),g(w)==="object"&&w.exports?w.exports=h(d):(T=[],R=h,k=typeof R=="function"?R.apply(y,T):R,k!==void 0&&(w.exports=k))})(void 0,function(d){var h=!1;if(!d.forceJURL)try{var f=new URL("b","http://a");f.pathname="c%20d",h=f.href==="http://a/c%20d"}catch(E){}if(h)return d.URL;var n=Object.create(null);n.ftp=21,n.file=0,n.gopher=70,n.http=80,n.https=443,n.ws=80,n.wss=443;var l=Object.create(null);l["%2e"]=".",l[".%2e"]="..",l["%2e."]="..",l["%2e%2e"]="..";function e(E){return n[E]!==void 0}function r(){v.call(this),this._isInvalid=!0}function t(E){return E==""&&r.call(this),E.toLowerCase()}function i(E){var L=E.charCodeAt(0);return L>32&&L<127&&[34,35,60,62,63,96].indexOf(L)==-1?E:encodeURIComponent(E)}function s(E){var L=E.charCodeAt(0);return L>32&&L<127&&[34,35,60,62,96].indexOf(L)==-1?E:encodeURIComponent(E)}var u=void 0,c=/[a-zA-Z]/,a=/[a-zA-Z0-9\+\-\.]/;function o(E,L,A){function B(j){P.push(j)}var D=L||"scheme start",V=0,N="",z=!1,_=!1,P=[];e:for(;(E[V-1]!=u||V==0)&&!this._isInvalid;){var x=E[V];switch(D){case"scheme start":if(x&&c.test(x))N+=x.toLowerCase(),D="scheme";else if(L){B("Invalid scheme.");break e}else{N="",D="no scheme";continue}break;case"scheme":if(x&&a.test(x))N+=x.toLowerCase();else if(x==":"){if(this._scheme=N,N="",L)break e;e(this._scheme)&&(this._isRelative=!0),this._scheme=="file"?D="relative":this._isRelative&&A&&A._scheme==this._scheme?D="relative or authority":this._isRelative?D="authority first slash":D="scheme data"}else if(L){if(u==x)break e;B("Code point not allowed in scheme: "+x);break e}else{N="",V=0,D="no scheme";continue}break;case"scheme data":x=="?"?(this._query="?",D="query"):x=="#"?(this._fragment="#",D="fragment"):u!=x&&x!=" "&&x!=`
|
|
`&&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}}])});
|