Files
pgsql-jellyfin/publish_test/wwwroot/node_modules.epubjs.e8e2a24909ffe427c795.chunk.js
2026-07-08 13:13:46 -04:00

1 line
179 KiB
JavaScript

"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[52590],{68352:function(t,e,i){i.r(e),i.d(e,{Book:function(){return es},Contents:function(){return Ci},EpubCFI:function(){return ft},Layout:function(){return ai},Rendition:function(){return Pn},default:function(){return ns}});var n={};i.r(n),i.d(n,{RangeObject:function(){return G},blob2base64:function(){return V},borders:function(){return E},bounds:function(){return C},createBase64Url:function(){return q},createBlob:function(){return R},createBlobUrl:function(){return N},defaults:function(){return w},defer:function(){return X},documentHeight:function(){return v},extend:function(){return k},filterChildren:function(){return Z},findChildren:function(){return J},getParentByTagName:function(){return $},indexOfElementNode:function(){return j},indexOfNode:function(){return _},indexOfSorted:function(){return T},indexOfTextNode:function(){return O},insert:function(){return x},isElement:function(){return y},isFloat:function(){return g},isNumber:function(){return m},isXml:function(){return z},locationOf:function(){return S},nodeBounds:function(){return P},parents:function(){return Q},parse:function(){return A},prefixed:function(){return b},qs:function(){return M},qsa:function(){return W},qsp:function(){return F},querySelectorByType:function(){return Y},requestAnimationFrame:function(){return u},revokeBlobUrl:function(){return B},sprint:function(){return U},treeWalker:function(){return D},type:function(){return I},uuid:function(){return p},walk:function(){return H},windowBounds:function(){return L}}),i(29305),i(32733),i(84701),i(81678),i(24776),i(84734),i(44962),i(66781),i(74455),i(4754),i(94),i(36947),i(78557),i(90076),i(95021),i(73687),i(83994),i(93062),i(82367);var s=i(31464),r=i.n(s),o=(i(14382),i(89336),i(74576),i(13225),i(36457),i(40718),i(67593),i(96054),i(23630),i(24362),i(76218),i(99102),i(32854));function a(t){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a(t)}function h(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,l(n.key),n)}}function l(t){var e=function(t){if("object"!=a(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=a(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==a(e)?e:e+""}var u="undefined"!=typeof window&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame),c=1,d=3,f="undefined"!=typeof URL?URL:"undefined"!=typeof window?window.URL||window.webkitURL||window.mozURL:void 0;function p(){var t=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var i=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?i:7&i|8).toString(16)}))}function v(){return Math.max(document.documentElement.clientHeight,document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight)}function y(t){return!(!t||1!=t.nodeType)}function m(t){return!isNaN(parseFloat(t))&&isFinite(t)}function g(t){var e=parseFloat(t);return!1!==m(t)&&("string"==typeof t&&t.indexOf(".")>-1||Math.floor(e)!==e)}function b(t){var e=["-webkit-","-webkit-","-moz-","-o-","-ms-"],i=t.toLowerCase();if("undefined"==typeof document||void 0!==document.body.style[i])return t;for(var n=0;n<5;n++)if(void 0!==document.body.style[e[n]+i])return e[n]+i;return t}function w(t){for(var e=1,i=arguments.length;e<i;e++){var n=arguments[e];for(var s in n)void 0===t[s]&&(t[s]=n[s])}return t}function k(t){return[].slice.call(arguments,1).forEach((function(e){e&&Object.getOwnPropertyNames(e).forEach((function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(e,i))}))})),t}function x(t,e,i){var n=S(t,e,i);return e.splice(n,0,t),n}function S(t,e,i,n,s){var r,o=n||0,a=s||e.length,h=parseInt(o+(a-o)/2);return i||(i=function(t,e){return t>e?1:t<e?-1:t==e?0:void 0}),a-o<=0?h:(r=i(e[h],t),a-o==1?r>=0?h:h+1:0===r?h:-1===r?S(t,e,i,h,a):S(t,e,i,o,h))}function T(t,e,i,n,s){var r,o=n||0,a=s||e.length,h=parseInt(o+(a-o)/2);return i||(i=function(t,e){return t>e?1:t<e?-1:t==e?0:void 0}),a-o<=0?-1:(r=i(e[h],t),a-o==1?0===r?h:-1:0===r?h:-1===r?T(t,e,i,h,a):T(t,e,i,o,h))}function C(t){var e=window.getComputedStyle(t),i=0,n=0;return["width","paddingRight","paddingLeft","marginRight","marginLeft","borderRightWidth","borderLeftWidth"].forEach((function(t){i+=parseFloat(e[t])||0})),["height","paddingTop","paddingBottom","marginTop","marginBottom","borderTopWidth","borderBottomWidth"].forEach((function(t){n+=parseFloat(e[t])||0})),{height:n,width:i}}function E(t){var e=window.getComputedStyle(t),i=0,n=0;return["paddingRight","paddingLeft","marginRight","marginLeft","borderRightWidth","borderLeftWidth"].forEach((function(t){i+=parseFloat(e[t])||0})),["paddingTop","paddingBottom","marginTop","marginBottom","borderTopWidth","borderBottomWidth"].forEach((function(t){n+=parseFloat(e[t])||0})),{height:n,width:i}}function P(t){var e,i=t.ownerDocument;if(t.nodeType==Node.TEXT_NODE){var n=i.createRange();n.selectNodeContents(t),e=n.getBoundingClientRect()}else e=t.getBoundingClientRect();return e}function L(){var t=window.innerWidth,e=window.innerHeight;return{top:0,left:0,right:t,bottom:e,width:t,height:e}}function _(t,e){for(var i,n=t.parentNode.childNodes,s=-1,r=0;r<n.length&&((i=n[r]).nodeType===e&&s++,i!=t);r++);return s}function O(t){return _(t,d)}function j(t){return _(t,c)}function z(t){return["xml","opf","ncx"].indexOf(t)>-1}function R(t,e){return new Blob([t],{type:e})}function N(t,e){var i=R(t,e);return f.createObjectURL(i)}function B(t){return f.revokeObjectURL(t)}function q(t,e){if("string"==typeof t)return"data:"+e+";base64,"+btoa(t)}function I(t){return Object.prototype.toString.call(t).slice(8,-1)}function A(t,e,i){var n;return n="undefined"==typeof DOMParser||i?o.DOMParser:DOMParser,65279===t.charCodeAt(0)&&(t=t.slice(1)),(new n).parseFromString(t,e)}function M(t,e){var i;if(!t)throw new Error("No Element Provided");return void 0!==t.querySelector?t.querySelector(e):(i=t.getElementsByTagName(e)).length?i[0]:void 0}function W(t,e){return void 0!==t.querySelector?t.querySelectorAll(e):t.getElementsByTagName(e)}function F(t,e,i){var n,s;if(void 0!==t.querySelector){for(var r in e+="[",i)e+=r+"~='"+i[r]+"'";return e+="]",t.querySelector(e)}if(n=t.getElementsByTagName(e),s=Array.prototype.slice.call(n,0).filter((function(t){for(var e in i)if(t.getAttribute(e)===i[e])return!0;return!1})),s)return s[0]}function U(t,e){void 0!==(t.ownerDocument||t).createTreeWalker?D(t,e,NodeFilter.SHOW_TEXT):H(t,(function(t){t&&3===t.nodeType&&e(t)}))}function D(t,e,i){for(var n,s=document.createTreeWalker(t,i,null,!1);n=s.nextNode();)e(n)}function H(t,e){if(e(t))return!0;if(t=t.firstChild)do{if(H(t,e))return!0;t=t.nextSibling}while(t)}function V(t){return new Promise((function(e,i){var n=new FileReader;n.readAsDataURL(t),n.onloadend=function(){e(n.result)}}))}function X(){var t=this;this.resolve=null,this.reject=null,this.id=p(),this.promise=new Promise((function(e,i){t.resolve=e,t.reject=i})),Object.freeze(this)}function Y(t,e,i){var n;if(void 0!==t.querySelector&&(n=t.querySelector("".concat(e,'[*|type="').concat(i,'"]'))),n&&0!==n.length)return n;n=W(t,e);for(var s=0;s<n.length;s++)if(n[s].getAttributeNS("http://www.idpf.org/2007/ops","type")===i||n[s].getAttribute("epub:type")===i)return n[s]}function J(t){for(var e=[],i=t.childNodes,n=0;n<i.length;n++){var s=i[n];1===s.nodeType&&e.push(s)}return e}function Q(t){for(var e=[t];t;t=t.parentNode)e.unshift(t);return e}function Z(t,e,i){for(var n=[],s=t.childNodes,r=0;r<s.length;r++){var o=s[r];if(1===o.nodeType&&o.nodeName.toLowerCase()===e){if(i)return o;n.push(o)}}if(!i)return n}function $(t,e){var i;if(null!==t&&""!==e)for(i=t.parentNode;1===i.nodeType;){if(i.tagName.toLowerCase()===e)return i;i=i.parentNode}}var G=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.collapsed=!1,this.commonAncestorContainer=void 0,this.endContainer=void 0,this.endOffset=void 0,this.startContainer=void 0,this.startOffset=void 0},(e=[{key:"setStart",value:function(t,e){this.startContainer=t,this.startOffset=e,this.endContainer?this.commonAncestorContainer=this._commonAncestorContainer():this.collapse(!0),this._checkCollapsed()}},{key:"setEnd",value:function(t,e){this.endContainer=t,this.endOffset=e,this.startContainer?(this.collapsed=!1,this.commonAncestorContainer=this._commonAncestorContainer()):this.collapse(!1),this._checkCollapsed()}},{key:"collapse",value:function(t){this.collapsed=!0,t?(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(t){var e=t.parentNode,i=Array.prototype.indexOf.call(e.childNodes,t);this.setStart(e,i),this.setEnd(e,i+1)}},{key:"selectNodeContents",value:function(t){t.childNodes[t.childNodes-1];var e=3===t.nodeType?t.textContent.length:parent.childNodes.length;this.setStart(t,0),this.setEnd(t,e)}},{key:"_commonAncestorContainer",value:function(t,e){var i=Q(t||this.startContainer),n=Q(e||this.endContainer);if(i[0]==n[0])for(var s=0;s<i.length;s++)if(i[s]!=n[s])return i[s-1]}},{key:"_checkCollapsed",value:function(){this.startContainer===this.endContainer&&this.startOffset===this.endOffset?this.collapsed=!0:this.collapsed=!1}},{key:"toString",value:function(){}}])&&h(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),K=(i(97456),i(87597)),tt=i.n(K);function et(t){return et="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},et(t)}function it(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,nt(n.key),n)}}function nt(t){var e=function(t){if("object"!=et(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=et(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==et(e)?e:e+""}var st=function(){return t=function t(e){var i;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e.indexOf("://")>-1&&(e=new URL(e).pathname),i=this.parse(e),this.path=e,this.isDirectory(e)?this.directory=e:this.directory=i.dir+"/",this.filename=i.base,this.extension=i.ext.slice(1)},(e=[{key:"parse",value:function(t){return tt().parse(t)}},{key:"isAbsolute",value:function(t){return tt().isAbsolute(t||this.path)}},{key:"isDirectory",value:function(t){return"/"===t.charAt(t.length-1)}},{key:"resolve",value:function(t){return tt().resolve(this.directory,t)}},{key:"relative",value:function(t){return t&&t.indexOf("://")>-1?t:tt().relative(this.directory,t)}},{key:"splitPath",value:function(t){return this.splitPathRe.exec(t).slice(1)}},{key:"toString",value:function(){return this.path}}])&&it(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function rt(t){return rt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},rt(t)}function ot(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,at(n.key),n)}}function at(t){var e=function(t){if("object"!=rt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=rt(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==rt(e)?e:e+""}var ht=function(){return t=function t(e,i){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var n=e.indexOf("://")>-1,s=e;if(this.Url=void 0,this.href=e,this.protocol="",this.origin="",this.hash="",this.hash="",this.search="",this.base=i,!n&&!1!==i&&"string"!=typeof i&&window&&window.location&&(this.base=window.location.href),n||this.base)try{this.base?this.Url=new URL(e,this.base):this.Url=new URL(e),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,s=this.Url.pathname+(this.Url.search?this.Url.search:"")}catch(t){this.Url=void 0,this.base&&(s=new st(this.base).resolve(s))}this.Path=new st(s),this.directory=this.Path.directory,this.filename=this.Path.filename,this.extension=this.Path.extension},(e=[{key:"path",value:function(){return this.Path}},{key:"resolve",value:function(t){var e;return t.indexOf("://")>-1?t:(e=tt().resolve(this.directory,t),this.origin+e)}},{key:"relative",value:function(t){return tt().relative(t,this.directory)}},{key:"toString",value:function(){return this.href}}])&&ot(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function lt(t){return lt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},lt(t)}function ut(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ct(n.key),n)}}function ct(t){var e=function(t){if("object"!=lt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=lt(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==lt(e)?e:e+""}i(86584),i(53819);var dt=function(){function t(e,i,n){var s;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.str="",this.base={},this.spinePos=0,this.range=!1,this.path={},this.start=null,this.end=null,!(this instanceof t))return new t(e,i,n);if("string"==typeof i?this.base=this.parseComponent(i):"object"===lt(i)&&i.steps&&(this.base=i),"string"===(s=this.checkType(e)))return this.str=e,k(this,this.parse(e));if("range"===s)return k(this,this.fromRange(e,this.base,n));if("node"===s)return k(this,this.fromNode(e,this.base,n));if("EpubCFI"===s&&e.path)return e;if(e)throw new TypeError("not a valid argument for EpubCFI");return this}return e=t,i=[{key:"checkType",value:function(e){return this.isCfiString(e)?"string":!e||"object"!==lt(e)||"Range"!==I(e)&&void 0===e.startContainer?e&&"object"===lt(e)&&void 0!==e.nodeType?"node":!!(e&&"object"===lt(e)&&e instanceof t)&&"EpubCFI":"range"}},{key:"parse",value:function(t){var e,i,n,s={spinePos:-1,range:!1,base:{},path:{},start:null,end:null};return"string"!=typeof t?{spinePos:-1}:(0===t.indexOf("epubcfi(")&&")"===t[t.length-1]&&(t=t.slice(8,t.length-1)),(e=this.getChapterComponent(t))?(s.base=this.parseComponent(e),i=this.getPathComponent(t),s.path=this.parseComponent(i),(n=this.getRange(t))&&(s.range=!0,s.start=this.parseComponent(n[0]),s.end=this.parseComponent(n[1])),s.spinePos=s.base.steps[1].index,s):{spinePos:-1})}},{key:"parseComponent",value:function(t){var e,i={steps:[],terminal:{offset:null,assertion:null}},n=t.split(":"),s=n[0].split("/");return n.length>1&&(e=n[1],i.terminal=this.parseTerminal(e)),""===s[0]&&s.shift(),i.steps=s.map(function(t){return this.parseStep(t)}.bind(this)),i}},{key:"parseStep",value:function(t){var e,i,n,s,r;if((s=t.match(/\[(.*)\]/))&&s[1]&&(r=s[1]),i=parseInt(t),!isNaN(i))return i%2==0?(e="element",n=i/2-1):(e="text",n=(i-1)/2),{type:e,index:n,id:r||null}}},{key:"parseTerminal",value:function(t){var e,i,n=t.match(/\[(.*)\]/);return n&&n[1]?(e=parseInt(t.split("[")[0]),i=n[1]):e=parseInt(t),m(e)||(e=null),{offset:e,assertion:i}}},{key:"getChapterComponent",value:function(t){return t.split("!")[0]}},{key:"getPathComponent",value:function(t){var e=t.split("!");if(e[1])return e[1].split(",")[0]}},{key:"getRange",value:function(t){var e=t.split(",");return 3===e.length&&[e[1],e[2]]}},{key:"getCharecterOffsetComponent",value:function(t){return t.split(":")[1]||""}},{key:"joinSteps",value:function(t){return t?t.map((function(t){var e="";return"element"===t.type&&(e+=2*(t.index+1)),"text"===t.type&&(e+=1+2*t.index),t.id&&(e+="["+t.id+"]"),e})).join("/"):""}},{key:"segmentString",value:function(t){var e="/";return e+=this.joinSteps(t.steps),t.terminal&&null!=t.terminal.offset&&(e+=":"+t.terminal.offset),t.terminal&&null!=t.terminal.assertion&&(e+="["+t.terminal.assertion+"]"),e}},{key:"toString",value:function(){var t="epubcfi(";return t+=this.segmentString(this.base),t+="!",t+=this.segmentString(this.path),this.range&&this.start&&(t+=",",t+=this.segmentString(this.start)),this.range&&this.end&&(t+=",",t+=this.segmentString(this.end)),t+")"}},{key:"compare",value:function(e,i){var n,s,r,o;if("string"==typeof e&&(e=new t(e)),"string"==typeof i&&(i=new t(i)),e.spinePos>i.spinePos)return 1;if(e.spinePos<i.spinePos)return-1;e.range?(n=e.path.steps.concat(e.start.steps),r=e.start.terminal):(n=e.path.steps,r=e.path.terminal),i.range?(s=i.path.steps.concat(i.start.steps),o=i.start.terminal):(s=i.path.steps,o=i.path.terminal);for(var a=0;a<n.length;a++){if(!n[a])return-1;if(!s[a])return 1;if(n[a].index>s[a].index)return 1;if(n[a].index<s[a].index)return-1}return n.length<s.length?-1:r.offset>o.offset?1:r.offset<o.offset?-1:0}},{key:"step",value:function(t){var e=3===t.nodeType?"text":"element";return{id:t.id,tagName:t.tagName,type:e,index:this.position(t)}}},{key:"filteredStep",value:function(t,e){var i,n=this.filter(t,e);if(n)return i=3===n.nodeType?"text":"element",{id:n.id,tagName:n.tagName,type:i,index:this.filteredPosition(n,e)}}},{key:"pathTo",value:function(t,e,i){for(var n,s={steps:[],terminal:{offset:null,assertion:null}},r=t;r&&r.parentNode&&9!=r.parentNode.nodeType;)(n=i?this.filteredStep(r,i):this.step(r))&&s.steps.unshift(n),r=r.parentNode;return null!=e&&e>=0&&(s.terminal.offset=e,"text"!=s.steps[s.steps.length-1].type&&s.steps.push({type:"text",index:0})),s}},{key:"equalStep",value:function(t,e){return!(!t||!e)&&t.index===e.index&&t.id===e.id&&t.type===e.type}},{key:"fromRange",value:function(t,e,i){var n={range:!1,base:{},path:{},start:null,end:null},s=t.startContainer,r=t.endContainer,o=t.startOffset,a=t.endOffset,h=!1;if(i&&(h=null!=s.ownerDocument.querySelector("."+i)),"string"==typeof e?(n.base=this.parseComponent(e),n.spinePos=n.base.steps[1].index):"object"===lt(e)&&(n.base=e),t.collapsed)h&&(o=this.patchOffset(s,o,i)),n.path=this.pathTo(s,o,i);else{n.range=!0,h&&(o=this.patchOffset(s,o,i)),n.start=this.pathTo(s,o,i),h&&(a=this.patchOffset(r,a,i)),n.end=this.pathTo(r,a,i),n.path={steps:[],terminal:null};var l,u=n.start.steps.length;for(l=0;l<u&&this.equalStep(n.start.steps[l],n.end.steps[l]);l++)l===u-1?n.start.terminal===n.end.terminal&&(n.path.steps.push(n.start.steps[l]),n.range=!1):n.path.steps.push(n.start.steps[l]);n.start.steps=n.start.steps.slice(n.path.steps.length),n.end.steps=n.end.steps.slice(n.path.steps.length)}return n}},{key:"fromNode",value:function(t,e,i){var n={range:!1,base:{},path:{},start:null,end:null};return"string"==typeof e?(n.base=this.parseComponent(e),n.spinePos=n.base.steps[1].index):"object"===lt(e)&&(n.base=e),n.path=this.pathTo(t,null,i),n}},{key:"filter",value:function(t,e){var i,n,s,r,o,a=!1;return 3===t.nodeType?(a=!0,s=t.parentNode,i=t.parentNode.classList.contains(e)):(a=!1,i=t.classList.contains(e)),i&&a?(r=s.previousSibling,o=s.nextSibling,r&&3===r.nodeType?n=r:o&&3===o.nodeType&&(n=o),n||t):!(i&&!a)&&t}},{key:"patchOffset",value:function(t,e,i){if(3!=t.nodeType)throw new Error("Anchor must be a text node");var n=t,s=e;for(t.parentNode.classList.contains(i)&&(n=t.parentNode);n.previousSibling;){if(1===n.previousSibling.nodeType){if(!n.previousSibling.classList.contains(i))break;s+=n.previousSibling.textContent.length}else s+=n.previousSibling.textContent.length;n=n.previousSibling}return s}},{key:"normalizedMap",value:function(t,e,i){var n,s,r,o={},a=-1,h=t.length;for(n=0;n<h;n++)1===(s=t[n].nodeType)&&t[n].classList.contains(i)&&(s=3),n>0&&3===s&&3===r?o[n]=a:e===s&&(a+=1,o[n]=a),r=s;return o}},{key:"position",value:function(t){var e,i;return 1===t.nodeType?((e=t.parentNode.children)||(e=J(t.parentNode)),i=Array.prototype.indexOf.call(e,t)):i=(e=this.textNodes(t.parentNode)).indexOf(t),i}},{key:"filteredPosition",value:function(t,e){var i,n;return 1===t.nodeType?(i=t.parentNode.children,n=this.normalizedMap(i,1,e)):(i=t.parentNode.childNodes,t.parentNode.classList.contains(e)&&(i=(t=t.parentNode).parentNode.childNodes),n=this.normalizedMap(i,3,e)),n[Array.prototype.indexOf.call(i,t)]}},{key:"stepsToXpath",value:function(t){var e=[".","*"];return t.forEach((function(t){var i=t.index+1;t.id?e.push("*[position()="+i+" and @id='"+t.id+"']"):"text"===t.type?e.push("text()["+i+"]"):e.push("*["+i+"]")})),e.join("/")}},{key:"stepsToQuerySelector",value:function(t){var e=["html"];return t.forEach((function(t){var i=t.index+1;t.id?e.push("#"+t.id):"text"===t.type||e.push("*:nth-child("+i+")")})),e.join(">")}},{key:"textNodes",value:function(t,e){return Array.prototype.slice.call(t.childNodes).filter((function(t){return 3===t.nodeType||!(!e||!t.classList.contains(e))}))}},{key:"walkToNode",value:function(t,e,i){var n,s,r=e||document,o=r.documentElement,a=t.length;for(s=0;s<a&&("element"===(n=t[s]).type?o=n.id?r.getElementById(n.id):(o.children||J(o))[n.index]:"text"===n.type&&(o=this.textNodes(o,i)[n.index]),o);s++);return o}},{key:"findNode",value:function(t,e,i){var n,s,r=e||document;return i||void 0===r.evaluate?n=i?this.walkToNode(t,r,i):this.walkToNode(t,r):(s=this.stepsToXpath(t),n=r.evaluate(s,r,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue),n}},{key:"fixMiss",value:function(t,e,i,n){var s,r,o=this.findNode(t.slice(0,-1),i,n),a=o.childNodes,h=this.normalizedMap(a,3,n),l=t[t.length-1].index;for(var u in h){if(!h.hasOwnProperty(u))return;if(h[u]===l){if(!(e>(r=(s=a[u]).textContent.length))){o=1===s.nodeType?s.childNodes[0]:s;break}e-=r}}return{container:o,offset:e}}},{key:"toRange",value:function(t,e){var i,n,s,r,o,a,h,l,u=t||document,c=this,d=!!e&&null!=u.querySelector("."+e);if(i=void 0!==u.createRange?u.createRange():new G,c.range?(n=c.start,a=c.path.steps.concat(n.steps),r=this.findNode(a,u,d?e:null),s=c.end,h=c.path.steps.concat(s.steps),o=this.findNode(h,u,d?e:null)):(n=c.path,a=c.path.steps,r=this.findNode(c.path.steps,u,d?e:null)),!r)return console.log("No startContainer found for",this.toString()),null;try{null!=n.terminal.offset?i.setStart(r,n.terminal.offset):i.setStart(r,0)}catch(t){l=this.fixMiss(a,n.terminal.offset,u,d?e:null),i.setStart(l.container,l.offset)}if(o)try{null!=s.terminal.offset?i.setEnd(o,s.terminal.offset):i.setEnd(o,0)}catch(t){l=this.fixMiss(h,c.end.terminal.offset,u,d?e:null),i.setEnd(l.container,l.offset)}return i}},{key:"isCfiString",value:function(t){return"string"==typeof t&&0===t.indexOf("epubcfi(")&&")"===t[t.length-1]}},{key:"generateChapterComponent",value:function(t,e,i){var n="/"+2*(t+1)+"/";return n+=2*(parseInt(e)+1),i&&(n+="["+i+"]"),n}},{key:"collapse",value:function(t){this.range&&(this.range=!1,t?(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))}}],i&&ut(e.prototype,i),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,i}(),ft=dt;function pt(t){return pt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pt(t)}function vt(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,yt(n.key),n)}}function yt(t){var e=function(t){if("object"!=pt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=pt(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==pt(e)?e:e+""}var mt=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.context=e||this,this.hooks=[]},e=[{key:"register",value:function(){for(var t=0;t<arguments.length;++t)if("function"==typeof arguments[t])this.hooks.push(arguments[t]);else for(var e=0;e<arguments[t].length;++e)this.hooks.push(arguments[t][e])}},{key:"deregister",value:function(t){for(var e=0;e<this.hooks.length;e++)if(this.hooks[e]===t){this.hooks.splice(e,1);break}}},{key:"trigger",value:function(){var t=arguments,e=this.context,i=[];return this.hooks.forEach((function(n){try{var s=n.apply(e,t)}catch(t){console.log(t)}s&&"function"==typeof s.then&&i.push(s)})),Promise.all(i)}},{key:"list",value:function(){return this.hooks}},{key:"clear",value:function(){return this.hooks=[]}}],e&&vt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),gt=mt;function bt(t,e){var i,n,s=e.url,r=s.indexOf("://")>-1;t&&(n=M(t,"head"),(i=M(n,"base"))||(i=t.createElement("base"),n.insertBefore(i,n.firstChild)),!r&&window&&window.location&&(s=window.location.origin+s),i.setAttribute("href",s))}function wt(t,e){var i,n,s=e.canonical;t&&(i=M(t,"head"),(n=M(i,"link[rel='canonical']"))?n.setAttribute("href",s):((n=t.createElement("link")).setAttribute("rel","canonical"),n.setAttribute("href",s),i.appendChild(n)))}function kt(t,e){var i,n,s=e.idref;t&&(i=M(t,"head"),(n=M(i,"link[property='dc.identifier']"))?n.setAttribute("content",s):((n=t.createElement("meta")).setAttribute("name","dc.identifier"),n.setAttribute("content",s),i.appendChild(n)))}function xt(t,e,i){return e.forEach((function(e,n){e&&i[n]&&(e=e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),t=t.replace(new RegExp(e,"g"),i[n]))})),t}i(69703),i(20518),i(646),i(83810);var St=function(t,e,i,n){var s,r="undefined"!=typeof window&&window.URL,o=r?"blob":"arraybuffer",a=new X,h=new XMLHttpRequest,l=XMLHttpRequest.prototype;for(s in"overrideMimeType"in l||Object.defineProperty(l,"overrideMimeType",{value:function(){}}),i&&(h.withCredentials=!0),h.onreadystatechange=function(){if(this.readyState===XMLHttpRequest.DONE){var t=!1;if(""!==this.responseType&&"document"!==this.responseType||(t=this.responseXML),200===this.status||0===this.status||t){var i;if(!this.response&&!t)return a.reject({status:this.status,message:"Empty Response",stack:(new Error).stack}),a.promise;if(403===this.status)return a.reject({status:this.status,response:this.response,message:"Forbidden",stack:(new Error).stack}),a.promise;i=t?this.responseXML:z(e)?A(this.response,"text/xml"):"xhtml"==e?A(this.response,"application/xhtml+xml"):"html"==e||"htm"==e?A(this.response,"text/html"):"json"==e?JSON.parse(this.response):"blob"==e?r?this.response:new Blob([this.response]):this.response,a.resolve(i)}else a.reject({status:this.status,message:this.response,stack:(new Error).stack})}},h.onerror=function(t){a.reject(t)},h.open("GET",t,!0),n)h.setRequestHeader(s,n[s]);return"json"==e&&h.setRequestHeader("Accept","application/json"),e||(e=new st(t).extension),"blob"==e&&(h.responseType=o),z(e)&&h.overrideMimeType("text/xml"),"binary"==e&&(h.responseType="arraybuffer"),h.send(),a.promise};function Tt(t){return Tt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Tt(t)}function Ct(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Et(n.key),n)}}function Et(t){var e=function(t){if("object"!=Tt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=Tt(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Tt(e)?e:e+""}var Pt=function(){return t=function t(e,i){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.idref=e.idref,this.linear="yes"===e.linear,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,i?this.hooks=i:(this.hooks={},this.hooks.serialize=new gt(this),this.hooks.content=new gt(this)),this.document=void 0,this.contents=void 0,this.output=void 0},e=[{key:"load",value:function(t){var e=t||this.request||St,i=new X,n=i.promise;return this.contents?i.resolve(this.contents):e(this.url).then(function(t){return this.document=t,this.contents=t.documentElement,this.hooks.content.trigger(this.document,this)}.bind(this)).then(function(){i.resolve(this.contents)}.bind(this)).catch((function(t){i.reject(t)})),n}},{key:"base",value:function(){return bt(this.document,this)}},{key:"render",value:function(t){var e=new X,i=e.promise;return this.output,this.load(t).then(function(t){var e=("undefined"!=typeof navigator&&navigator.userAgent||"").indexOf("Trident")>=0,i=new("undefined"==typeof XMLSerializer||e?o.DOMParser:XMLSerializer);return this.output=i.serializeToString(t),this.output}.bind(this)).then(function(){return this.hooks.serialize.trigger(this.output,this)}.bind(this)).then(function(){e.resolve(this.output)}.bind(this)).catch((function(t){e.reject(t)})),i}},{key:"find",value:function(t){var e=this,i=[],n=t.toLowerCase();return U(e.document,(function(t){!function(t){for(var s,r,o,a=t.textContent.toLowerCase(),h=e.document.createRange(),l=-1;-1!=r;)-1!=(r=a.indexOf(n,l+1))&&((h=e.document.createRange()).setStart(t,r),h.setEnd(t,r+n.length),s=e.cfiFromRange(h),o=t.textContent.length<150?t.textContent:"..."+(o=t.textContent.substring(r-75,r+75))+"...",i.push({cfi:s,excerpt:o})),l=r}(t)})),i}},{key:"search",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;if(void 0===document.createTreeWalker)return this.find(t);for(var i,n=[],s=this,r=t.toLowerCase(),o=function(t){var e=t.reduce((function(t,e){return t+e.textContent}),"").toLowerCase().indexOf(r);if(-1!=e){var i=e+r.length,o=0,a=0;if(e<t[0].length){for(var h;o<t.length-1&&!(i<=(a+=t[o].length));)o+=1;var l=t[0],u=t[o],c=s.document.createRange();c.setStart(l,e);var d=t.slice(0,o).reduce((function(t,e){return t+e.textContent.length}),0);c.setEnd(u,d>i?i:i-d),h=s.cfiFromRange(c);var f=t.slice(0,o+1).reduce((function(t,e){return t+e.textContent}),"");f.length>150&&(f="..."+(f=f.substring(e-75,e+75))+"..."),n.push({cfi:h,excerpt:f})}}},a=document.createTreeWalker(s.document,NodeFilter.SHOW_TEXT,null,!1),h=[];i=a.nextNode();)h.push(i),h.length==e&&(o(h.slice(0,e)),h=h.slice(1,e));return h.length>0&&o(h),n}},{key:"reconcileLayoutSettings",value:function(t){var e={layout:t.layout,spread:t.spread,orientation:t.orientation};return this.properties.forEach((function(t){var i,n,s=t.replace("rendition:",""),r=s.indexOf("-");-1!=r&&(i=s.slice(0,r),n=s.slice(r+1),e[i]=n)})),e}},{key:"cfiFromRange",value:function(t){return new ft(t,this.cfiBase).toString()}},{key:"cfiFromElement",value:function(t){return new ft(t,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}}],e&&Ct(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),Lt=Pt;function _t(t){return _t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_t(t)}function Ot(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,jt(n.key),n)}}function jt(t){var e=function(t){if("object"!=_t(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=_t(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==_t(e)?e:e+""}var zt=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.spineItems=[],this.spineByHref={},this.spineById={},this.hooks={},this.hooks.serialize=new gt,this.hooks.content=new gt,this.hooks.content.register(bt),this.hooks.content.register(wt),this.hooks.content.register(kt),this.epubcfi=new ft,this.loaded=!1,this.items=void 0,this.manifest=void 0,this.spineNodeIndex=void 0,this.baseUrl=void 0,this.length=void 0},e=[{key:"unpack",value:function(t,e,i){var n=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(t,s){var r,o=n.manifest[t.idref];t.index=s,t.cfiBase=n.epubcfi.generateChapterComponent(n.spineNodeIndex,t.index,t.id),t.href&&(t.url=e(t.href,!0),t.canonical=i(t.href)),o&&(t.href=o.href,t.url=e(t.href,!0),t.canonical=i(t.href),o.properties.length&&t.properties.push.apply(t.properties,o.properties)),"yes"===t.linear?(t.prev=function(){for(var e=t.index;e>0;){var i=this.get(e-1);if(i&&i.linear)return i;e-=1}}.bind(n),t.next=function(){for(var e=t.index;e<this.spineItems.length-1;){var i=this.get(e+1);if(i&&i.linear)return i;e+=1}}.bind(n)):(t.prev=function(){},t.next=function(){}),r=new Lt(t,n.hooks),n.append(r)})),this.loaded=!0}},{key:"get",value:function(t){var e=0;if(void 0===t)for(;e<this.spineItems.length;){var i=this.spineItems[e];if(i&&i.linear)break;e+=1}else this.epubcfi.isCfiString(t)?e=new ft(t).spinePos:"number"==typeof t||!1===isNaN(t)?e=t:"string"==typeof t&&0===t.indexOf("#")?e=this.spineById[t.substring(1)]:"string"==typeof t&&(t=t.split("#")[0],e=this.spineByHref[t]||this.spineByHref[encodeURI(t)]);return this.spineItems[e]||null}},{key:"append",value:function(t){var e=this.spineItems.length;return t.index=e,this.spineItems.push(t),this.spineByHref[decodeURI(t.href)]=e,this.spineByHref[encodeURI(t.href)]=e,this.spineByHref[t.href]=e,this.spineById[t.idref]=e,e}},{key:"prepend",value:function(t){return this.spineByHref[t.href]=0,this.spineById[t.idref]=0,this.spineItems.forEach((function(t,e){t.index=e})),0}},{key:"remove",value:function(t){var e=this.spineItems.indexOf(t);if(e>-1)return delete this.spineByHref[t.href],delete this.spineById[t.idref],this.spineItems.splice(e,1)}},{key:"each",value:function(){return this.spineItems.forEach.apply(this.spineItems,arguments)}},{key:"first",value:function(){var t=0;do{var e=this.get(t);if(e&&e.linear)return e;t+=1}while(t<this.spineItems.length)}},{key:"last",value:function(){var t=this.spineItems.length-1;do{var e=this.get(t);if(e&&e.linear)return e;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&&Ot(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),Rt=zt;function Nt(t){return Nt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Nt(t)}function Bt(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,qt(n.key),n)}}function qt(t){var e=function(t){if("object"!=Nt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=Nt(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Nt(e)?e:e+""}i(46968);var It=function(){return t=function t(e){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),this._q=[],this.context=e,this.tick=u,this.running=!1,this.paused=!1},e=[{key:"enqueue",value:function(){var t,e,i=[].shift.call(arguments),n=arguments;if(!i)throw new Error("No Task Provided");return e="function"==typeof i?{task:i,args:n,deferred:t=new X,promise:t.promise}:{promise:i},this._q.push(e),0!=this.paused||this.running||this.run(),e.promise}},{key:"dequeue",value:function(){var t,e,i;return!this._q.length||this.paused?((t=new X).deferred.resolve(),t.promise):(e=(t=this._q.shift()).task)?(i=e.apply(this.context,t.args))&&"function"==typeof i.then?i.then(function(){t.deferred.resolve.apply(this.context,arguments)}.bind(this),function(){t.deferred.reject.apply(this.context,arguments)}.bind(this)):(t.deferred.resolve.apply(this.context,i),t.promise):t.promise?t.promise:void 0}},{key:"dump",value:function(){for(;this._q.length;)this.dequeue()}},{key:"run",value:function(){var t=this;return this.running||(this.running=!0,this.defered=new X),this.tick.call(window,(function(){t._q.length?t.dequeue().then(function(){this.run()}.bind(t)):(t.defered.resolve(),t.running=void 0)})),1==this.paused&&(this.paused=!1),this.defered.promise}},{key:"flush",value:function(){return this.running?this.running:this._q.length?(this.running=this.dequeue().then(function(){return this.running=void 0,this.flush()}.bind(this)),this.running):void 0}},{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}}],e&&Bt(t.prototype,e),i&&Bt(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,i}(),At=It,Mt="0.3",Wt=["keydown","keyup","keypressed","mouseup","mousedown","mousemove","click","touchend","touchstart","touchmove"],Ft="openFailed",Ut="expand",Dt="resize",Ht="selected",Vt="selectedRange",Xt="linkClicked",Yt="changed",Jt="resize",Qt="resized",Zt="orientationchange",$t="added",Gt="scroll",Kt="scrolled",te="removed",ee="axis",ie="writingMode",ne="loaderror",se="rendered",re="resized",oe="displayed",ae="shown",he="hidden",le="markClicked",ue="started",ce="attached",de="displayed",fe="displayerror",pe="rendered",ve="removed",ye="resized",me="orientationchange",ge="locationChanged",be="relocated",we="markClicked",ke="selected",xe="layout",Se="updated",Te="attach",Ce="detach";function Ee(t){return Ee="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ee(t)}function Pe(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Le(n.key),n)}}function Le(t){var e=function(t){if("object"!=Ee(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=Ee(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ee(e)?e:e+""}var _e=function(){return t=function t(e,i,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.spine=e,this.request=i,this.pause=n||100,this.q=new At(this),this.epubcfi=new ft,this._locations=[],this._locationsWords=[],this.total=0,this.break=150,this._current=0,this._wordCounter=0,this.currentLocation="",this._currentCfi="",this.processingTimeout=void 0},e=[{key:"generate",value:function(t){return t&&(this.break=t),this.q.pause(),this.spine.each(function(t){t.linear&&this.q.enqueue(this.process.bind(this),t)}.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(t){return t.load(this.request).then(function(e){var i=new X,n=this.parse(e,t.cfiBase);return this._locations=this._locations.concat(n),t.unload(),this.processingTimeout=setTimeout((function(){return i.resolve(n)}),this.pause),i.promise}.bind(this))}},{key:"parse",value:function(t,e,i){var n,s,r=[],o=M(t.ownerDocument,"body"),a=0,h=i||this.break;if(U(o,function(t){var i,o=t.length,l=0;if(0===t.textContent.trim().length)return!1;for(0==a&&((n=this.createRange()).startContainer=t,n.startOffset=0),(i=h-a)>o&&(a+=o,l=o);l<o;)if(i=h-a,0===a&&(l+=1,(n=this.createRange()).startContainer=t,n.startOffset=l),l+i>=o)a+=o-l,l=o;else{l+=i,n.endContainer=t,n.endOffset=l;var u=new ft(n,e).toString();r.push(u),a=0}s=t}.bind(this)),n&&n.startContainer&&s){n.endContainer=s,n.endOffset=s.length;var l=new ft(n,e).toString();r.push(l),a=0}return r}},{key:"generateFromWords",value:function(t,e,i){var n=t?new ft(t):void 0;return this.q.pause(),this._locationsWords=[],this._wordCounter=0,this.spine.each(function(t){t.linear&&(n?t.index>=n.spinePos&&this.q.enqueue(this.processWords.bind(this),t,e,n,i):this.q.enqueue(this.processWords.bind(this),t,e,n,i))}.bind(this)),this.q.run().then(function(){return this._currentCfi&&(this.currentLocation=this._currentCfi),this._locationsWords}.bind(this))}},{key:"processWords",value:function(t,e,i,n){return n&&this._locationsWords.length>=n?Promise.resolve():t.load(this.request).then(function(s){var r=new X,o=this.parseWords(s,t,e,i),a=n-this._locationsWords.length;return this._locationsWords=this._locationsWords.concat(o.length>=n?o.slice(0,a):o),t.unload(),this.processingTimeout=setTimeout((function(){return r.resolve(o)}),this.pause),r.promise}.bind(this))}},{key:"countWords",value:function(t){return(t=(t=(t=t.replace(/(^\s*)|(\s*$)/gi,"")).replace(/[ ]{2,}/gi," ")).replace(/\n /,"\n")).split(" ").length}},{key:"parseWords",value:function(t,e,i,n){var s,r=e.cfiBase,o=[],a=M(t.ownerDocument,"body"),h=i,l=!n||n.spinePos!==e.index;return n&&e.index===n.spinePos&&(s=n.findNode(n.range?n.path.steps.concat(n.start.steps):n.path.steps,t.ownerDocument)),U(a,function(t){if(!l){if(t!==s)return!1;l=!0}if(t.textContent.length<10&&0===t.textContent.trim().length)return!1;var e,i=this.countWords(t.textContent),n=0;if(0===i)return!1;for((e=h-this._wordCounter)>i&&(this._wordCounter+=i,n=i);n<i;)if(n+(e=h-this._wordCounter)>=i)this._wordCounter+=i-n,n=i;else{n+=e;var a=new ft(t,r);o.push({cfi:a.toString(),wordCount:this._wordCounter}),this._wordCounter=0}}.bind(this)),o}},{key:"locationFromCfi",value:function(t){var e;return ft.prototype.isCfiString(t)&&(t=new ft(t)),0===this._locations.length?-1:(e=S(t,this._locations,this.epubcfi.compare))>this.total?this.total:e}},{key:"percentageFromCfi",value:function(t){if(0===this._locations.length)return null;var e=this.locationFromCfi(t);return this.percentageFromLocation(e)}},{key:"percentageFromLocation",value:function(t){return t&&this.total?t/this.total:0}},{key:"cfiFromLocation",value:function(t){var e=-1;return"number"!=typeof t&&(t=parseInt(t)),t>=0&&t<this._locations.length&&(e=this._locations[t]),e}},{key:"cfiFromPercentage",value:function(t){var e;if(t>1&&console.warn("Normalize cfiFromPercentage value to between 0 - 1"),t>=1){var i=new ft(this._locations[this.total]);return i.collapse(),i.toString()}return e=Math.ceil(this.total*t),this.cfiFromLocation(e)}},{key:"load",value:function(t){return this._locations="string"==typeof t?JSON.parse(t):t,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(t){var e;if("string"==typeof t)this._currentCfi=t;else{if("number"!=typeof t)return;this._current=t}0!==this._locations.length&&("string"==typeof t?(e=this.locationFromCfi(t),this._current=e):e=t,this.emit(Yt,{percentage:this.percentageFromLocation(e)}))}},{key:"currentLocation",get:function(){return this._current},set:function(t){this.setCurrent(t)}},{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)}}],e&&Pe(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();r()(_e.prototype);var Oe=_e;function je(t){return je="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},je(t)}function ze(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Re(n.key),n)}}function Re(t){var e=function(t){if("object"!=je(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=je(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==je(e)?e:e+""}var Ne=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.packagePath="",this.directory="",this.encoding="",e&&this.parse(e)},(e=[{key:"parse",value:function(t){var e;if(!t)throw new Error("Container File Not Found");if(!(e=M(t,"rootfile")))throw new Error("No RootFile Found");this.packagePath=e.getAttribute("full-path"),this.directory=tt().dirname(this.packagePath),this.encoding=t.xmlEncoding}},{key:"destroy",value:function(){this.packagePath=void 0,this.directory=void 0,this.encoding=void 0}}])&&ze(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function Be(t){return Be="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Be(t)}function qe(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ie(n.key),n)}}function Ie(t){var e=function(t){if("object"!=Be(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=Be(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Be(e)?e:e+""}var Ae=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.manifest={},this.navPath="",this.ncxPath="",this.coverPath="",this.spineNodeIndex=0,this.spine=[],this.metadata={},e&&this.parse(e)},e=[{key:"parse",value:function(t){var e,i,n;if(!t)throw new Error("Package File Not Found");if(!(e=M(t,"metadata")))throw new Error("No Metadata Found");if(!(i=M(t,"manifest")))throw new Error("No Manifest Found");if(!(n=M(t,"spine")))throw new Error("No Spine Found");return this.manifest=this.parseManifest(i),this.navPath=this.findNavPath(i),this.ncxPath=this.findNcxPath(i,n),this.coverPath=this.findCoverPath(t),this.spineNodeIndex=j(n),this.spine=this.parseSpine(n,this.manifest),this.uniqueIdentifier=this.findUniqueIdentifier(t),this.metadata=this.parseMetadata(e),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(t){var e={};return e.title=this.getElementText(t,"title"),e.creator=this.getElementText(t,"creator"),e.description=this.getElementText(t,"description"),e.pubdate=this.getElementText(t,"date"),e.publisher=this.getElementText(t,"publisher"),e.identifier=this.getElementText(t,"identifier"),e.language=this.getElementText(t,"language"),e.rights=this.getElementText(t,"rights"),e.modified_date=this.getPropertyText(t,"dcterms:modified"),e.layout=this.getPropertyText(t,"rendition:layout"),e.orientation=this.getPropertyText(t,"rendition:orientation"),e.flow=this.getPropertyText(t,"rendition:flow"),e.viewport=this.getPropertyText(t,"rendition:viewport"),e.media_active_class=this.getPropertyText(t,"media:active-class"),e.spread=this.getPropertyText(t,"rendition:spread"),e}},{key:"parseManifest",value:function(t){var e={},i=W(t,"item");return Array.prototype.slice.call(i).forEach((function(t){var i=t.getAttribute("id"),n=t.getAttribute("href")||"",s=t.getAttribute("media-type")||"",r=t.getAttribute("media-overlay")||"",o=t.getAttribute("properties")||"";e[i]={href:n,type:s,overlay:r,properties:o.length?o.split(" "):[]}})),e}},{key:"parseSpine",value:function(t,e){var i=[],n=W(t,"itemref");return Array.prototype.slice.call(n).forEach((function(t,e){var n=t.getAttribute("idref"),s=t.getAttribute("properties")||"",r=s.length?s.split(" "):[],o={id:t.getAttribute("id"),idref:n,linear:t.getAttribute("linear")||"yes",properties:r,index:e};i.push(o)})),i}},{key:"findUniqueIdentifier",value:function(t){var e=t.documentElement.getAttribute("unique-identifier");if(!e)return"";var i=t.getElementById(e);return i&&"identifier"===i.localName&&"http://purl.org/dc/elements/1.1/"===i.namespaceURI&&i.childNodes.length>0?i.childNodes[0].nodeValue.trim():""}},{key:"findNavPath",value:function(t){var e=F(t,"item",{properties:"nav"});return!!e&&e.getAttribute("href")}},{key:"findNcxPath",value:function(t,e){var i,n=F(t,"item",{"media-type":"application/x-dtbncx+xml"});return n||(i=e.getAttribute("toc"))&&(n=t.querySelector("#".concat(i))),!!n&&n.getAttribute("href")}},{key:"findCoverPath",value:function(t){M(t,"package").getAttribute("version");var e=F(t,"item",{properties:"cover-image"});if(e)return e.getAttribute("href");var i=F(t,"meta",{name:"cover"});if(i){var n=i.getAttribute("content"),s=t.getElementById(n);return s?s.getAttribute("href"):""}return!1}},{key:"getElementText",value:function(t,e){var i,n=t.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/",e);return n&&0!==n.length&&(i=n[0]).childNodes.length?i.childNodes[0].nodeValue:""}},{key:"getPropertyText",value:function(t,e){var i=F(t,"meta",{property:e});return i&&i.childNodes.length?i.childNodes[0].nodeValue:""}},{key:"load",value:function(t){var e=this;this.metadata=t.metadata;var i=t.readingOrder||t.spine;return this.spine=i.map((function(t,e){return t.index=e,t.linear=t.linear||"yes",t})),t.resources.forEach((function(t,i){e.manifest[i]=t,t.rel&&"cover"===t.rel[0]&&(e.coverPath=t.href)})),this.spineNodeIndex=0,this.toc=t.toc.map((function(t,e){return t.label=t.title,t})),{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}}],e&&qe(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),Me=Ae;function We(t){return We="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},We(t)}function Fe(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ue(n.key),n)}}function Ue(t){var e=function(t){if("object"!=We(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=We(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==We(e)?e:e+""}var De=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.toc=[],this.tocByHref={},this.tocById={},this.landmarks=[],this.landmarksByType={},this.length=0,e&&this.parse(e)},e=[{key:"parse",value:function(t){var e,i,n=t.nodeType;n&&(e=M(t,"html"),i=M(t,"ncx")),n?e?(this.toc=this.parseNav(t),this.landmarks=this.parseLandmarks(t)):i&&(this.toc=this.parseNcx(t)):this.toc=this.load(t),this.length=0,this.unpack(this.toc)}},{key:"unpack",value:function(t){for(var e,i=0;i<t.length;i++)(e=t[i]).href&&(this.tocByHref[e.href]=i),e.id&&(this.tocById[e.id]=i),this.length++,e.subitems.length&&this.unpack(e.subitems)}},{key:"get",value:function(t){var e;return t?(0===t.indexOf("#")?e=this.tocById[t.substring(1)]:t in this.tocByHref&&(e=this.tocByHref[t]),this.getByIndex(t,e,this.toc)):this.toc}},{key:"getByIndex",value:function(t,e,i){if(0!==i.length){var n=i[e];if(!n||t!==n.id&&t!==n.href){for(var s,r=0;r<i.length&&!(s=this.getByIndex(t,e,i[r].subitems));++r);return s}return n}}},{key:"landmark",value:function(t){var e;return t?(e=this.landmarksByType[t],this.landmarks[e]):this.landmarks}},{key:"parseNav",value:function(t){var e=Y(t,"nav","toc"),i=[];if(!e)return i;var n=Z(e,"ol",!0);return n?i=this.parseNavList(n):i}},{key:"parseNavList",value:function(t,e){var i=[];if(!t)return i;if(!t.children)return i;for(var n=0;n<t.children.length;n++){var s=this.navItem(t.children[n],e);s&&i.push(s)}return i}},{key:"navItem",value:function(t,e){var i=t.getAttribute("id")||void 0,n=Z(t,"a",!0)||Z(t,"span",!0);if(n){var s=n.getAttribute("href")||"";i||(i=s);var r=n.textContent||"",o=[],a=Z(t,"ol",!0);return a&&(o=this.parseNavList(a,i)),{id:i,href:s,label:r,subitems:o,parent:e}}}},{key:"parseLandmarks",value:function(t){var e,i,n=Y(t,"nav","landmarks"),s=n?W(n,"li"):[],r=s.length,o=[];if(!s||0===r)return o;for(e=0;e<r;++e)(i=this.landmarkItem(s[e]))&&(o.push(i),this.landmarksByType[i.type]=e);return o}},{key:"landmarkItem",value:function(t){var e=Z(t,"a",!0);if(e){var i=e.getAttributeNS("http://www.idpf.org/2007/ops","type")||void 0;return{href:e.getAttribute("href")||"",label:e.textContent||"",type:i}}}},{key:"parseNcx",value:function(t){var e,i,n=W(t,"navPoint"),s=n.length,r={},o=[];if(!n||0===s)return o;for(e=0;e<s;++e)r[(i=this.ncxItem(n[e])).id]=i,i.parent?r[i.parent].subitems.push(i):o.push(i);return o}},{key:"ncxItem",value:function(t){var e,i=t.getAttribute("id")||!1,n=M(t,"content").getAttribute("src"),s=M(t,"navLabel"),r=s.textContent?s.textContent:"",o=t.parentNode;return!o||"navPoint"!==o.nodeName&&"navPoint"!==o.nodeName.split(":").slice(-1)[0]||(e=o.getAttribute("id")),{id:i,href:n,label:r,subitems:[],parent:e}}},{key:"load",value:function(t){var e=this;return t.map((function(t){return t.label=t.title,t.subitems=t.children?e.load(t.children):[],t}))}},{key:"forEach",value:function(t){return this.toc.forEach(t)}}],e&&Fe(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),He=De,Ve={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"}},Xe=function(){var t,e,i,n,s={};for(t in Ve)if(Ve.hasOwnProperty(t))for(e in Ve[t])if(Ve[t].hasOwnProperty(e))if("string"==typeof(i=Ve[t][e]))s[i]=t+"/"+e;else for(n=0;n<i.length;n++)s[i[n]]=t+"/"+e;return s}(),Ye=function(t){return t&&Xe[t.split(".").pop().toLowerCase()]||"text/plain"};function Je(t){return Je="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Je(t)}function Qe(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ze(n.key),n)}}function Ze(t){var e=function(t){if("object"!=Je(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=Je(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Je(e)?e:e+""}var $e=function(){return t=function t(e,i){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.settings={replacements:i&&i.replacements||"base64",archive:i&&i.archive,resolver:i&&i.resolver,request:i&&i.request},this.process(e)},e=[{key:"process",value:function(t){this.manifest=t,this.resources=Object.keys(t).map((function(e){return t[e]})),this.replacementUrls=[],this.html=[],this.assets=[],this.css=[],this.urls=[],this.cssUrls=[],this.split(),this.splitUrls()}},{key:"split",value:function(){this.html=this.resources.filter((function(t){if("application/xhtml+xml"===t.type||"text/html"===t.type)return!0})),this.assets=this.resources.filter((function(t){if("application/xhtml+xml"!==t.type&&"text/html"!==t.type)return!0})),this.css=this.resources.filter((function(t){if("text/css"===t.type)return!0}))}},{key:"splitUrls",value:function(){this.urls=this.assets.map(function(t){return t.href}.bind(this)),this.cssUrls=this.css.map((function(t){return t.href}))}},{key:"createUrl",value:function(t){var e=new ht(t),i=Ye(e.filename);return this.settings.archive?this.settings.archive.createUrl(t,{base64:"base64"===this.settings.replacements}):"base64"===this.settings.replacements?this.settings.request(t,"blob").then((function(t){return V(t)})).then((function(t){return q(t,i)})):this.settings.request(t,"blob").then((function(t){return N(t,i)}))}},{key:"replacements",value:function(){var t=this;if("none"===this.settings.replacements)return new Promise(function(t){t(this.urls)}.bind(this));var e=this.urls.map((function(e){var i=t.settings.resolver(e);return t.createUrl(i).catch((function(t){return console.error(t),null}))}));return Promise.all(e).then((function(e){return t.replacementUrls=e.filter((function(t){return"string"==typeof t})),e}))}},{key:"replaceCss",value:function(t,e){var i=[];return t=t||this.settings.archive,e=e||this.settings.resolver,this.cssUrls.forEach(function(n){var s=this.createCssFile(n,t,e).then(function(t){var e=this.urls.indexOf(n);e>-1&&(this.replacementUrls[e]=t)}.bind(this));i.push(s)}.bind(this)),Promise.all(i)}},{key:"createCssFile",value:function(t){var e=this;if(tt().isAbsolute(t))return new Promise((function(t){t()}));var i,n=this.settings.resolver(t);i=this.settings.archive?this.settings.archive.getText(n):this.settings.request(n,"text");var s=this.urls.map((function(t){var i=e.settings.resolver(t);return new st(n).relative(i)}));return i?i.then((function(t){return t=xt(t,s,e.replacementUrls),"base64"===e.settings.replacements?q(t,"text/css"):N(t,"text/css")}),(function(t){return new Promise((function(t){t()}))})):new Promise((function(t){t()}))}},{key:"relativeTo",value:function(t,e){return e=e||this.settings.resolver,this.urls.map(function(i){var n=e(i);return new st(t).relative(n)}.bind(this))}},{key:"get",value:function(t){var e=this.urls.indexOf(t);if(-1!==e)return this.replacementUrls.length?new Promise(function(t,i){t(this.replacementUrls[e])}.bind(this)):this.createUrl(t)}},{key:"substitute",value:function(t,e){return xt(t,e?this.relativeTo(e):this.urls,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}}],e&&Qe(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),Ge=$e;function Ke(t){return Ke="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ke(t)}function ti(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ei(n.key),n)}}function ei(t){var e=function(t){if("object"!=Ke(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=Ke(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ke(e)?e:e+""}var ii=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.pages=[],this.locations=[],this.epubcfi=new ft,this.firstPage=0,this.lastPage=0,this.totalPages=0,this.toc=void 0,this.ncx=void 0,e&&(this.pageList=this.parse(e)),this.pageList&&this.pageList.length&&this.process(this.pageList)},(e=[{key:"parse",value:function(t){var e=M(t,"html"),i=M(t,"ncx");return e?this.parseNav(t):i?this.parseNcx(t):void 0}},{key:"parseNav",value:function(t){var e,i,n=Y(t,"nav","page-list"),s=n?W(n,"li"):[],r=s.length,o=[];if(!s||0===r)return o;for(e=0;e<r;++e)i=this.item(s[e]),o.push(i);return o}},{key:"parseNcx",value:function(t){var e,i,n,s,r=[],o=0;if(!(i=M(t,"pageList")))return r;if(s=(n=W(i,"pageTarget")).length,!n||0===n.length)return r;for(o=0;o<s;++o)e=this.ncxItem(n[o]),r.push(e);return r}},{key:"ncxItem",value:function(t){var e=M(t,"navLabel"),i=M(e,"text").textContent;return{href:M(t,"content").getAttribute("src"),page:parseInt(i,10)}}},{key:"item",value:function(t){var e,i,n=M(t,"a"),s=n.getAttribute("href")||"",r=n.textContent||"",o=parseInt(r);return-1!=s.indexOf("epubcfi")?(i=(e=s.split("#"))[0],{cfi:e.length>1&&e[1],href:s,packageUrl:i,page:o}):{href:s,page:o}}},{key:"process",value:function(t){t.forEach((function(t){this.pages.push(t.page),t.cfi&&this.locations.push(t.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(t){var e=-1;if(0===this.locations.length)return-1;var i=T(t,this.locations,this.epubcfi.compare);return-1!=i?e=this.pages[i]:void 0!==(e=(i=S(t,this.locations,this.epubcfi.compare))-1>=0?this.pages[i-1]:this.pages[0])||(e=-1),e}},{key:"cfiFromPage",value:function(t){var e=-1;"number"!=typeof t&&(t=parseInt(t));var i=this.pages.indexOf(t);return-1!=i&&(e=this.locations[i]),e}},{key:"pageFromPercentage",value:function(t){return Math.round(this.totalPages*t)}},{key:"percentageFromPage",value:function(t){var e=(t-this.firstPage)/this.totalPages;return Math.round(1e3*e)/1e3}},{key:"percentageFromCfi",value:function(t){var e=this.pageFromCfi(t);return this.percentageFromPage(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}}])&&ti(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function ni(t){return ni="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ni(t)}function si(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ri(n.key),n)}}function ri(t){var e=function(t){if("object"!=ni(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=ni(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ni(e)?e:e+""}var oi=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.settings=e,this.name=e.layout||"reflowable",this._spread="none"!==e.spread,this._minSpreadWidth=e.minSpreadWidth||800,this._evenSpreads=e.evenSpreads||!1,"scrolled"===e.flow||"scrolled-continuous"===e.flow||"scrolled-doc"===e.flow?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}},e=[{key:"flow",value:function(t){return void 0!==t&&(this._flow="scrolled"===t||"scrolled-continuous"===t||"scrolled-doc"===t?"scrolled":"paginated",this.update({flow:this._flow})),this._flow}},{key:"spread",value:function(t,e){return t&&(this._spread="none"!==t,this.update({spread:this._spread})),e>=0&&(this._minSpreadWidth=e),this._spread}},{key:"calculate",value:function(t,e,i){var n,s,r,o,a,h=i||0,l=t,u=e,c=Math.floor(l/12);a=this._spread&&l>=this._minSpreadWidth?2:1,"reflowable"!==this.name||"paginated"!==this._flow||i>=0||(h=c%2==0?c:c-1),"pre-paginated"===this.name&&(h=0),a>1?r=(n=l/a-h)+h:(n=l,r=l),"pre-paginated"===this.name&&a>1&&(l=n),s=n*a+h,o=l,this.width=l,this.height=u,this.spreadWidth=s,this.pageWidth=r,this.delta=o,this.columnWidth=n,this.gap=h,this.divisor=a,this.update({width:l,height:u,spreadWidth:s,pageWidth:r,delta:o,columnWidth:n,gap:h,divisor:a})}},{key:"format",value:function(t,e,i){return"pre-paginated"===this.name?t.fit(this.columnWidth,this.height,e):"paginated"===this._flow?t.columns(this.width,this.height,this.columnWidth,this.gap,this.settings.direction):i&&"horizontal"===i?t.size(null,this.height):t.size(this.width,null)}},{key:"count",value:function(t,e){var i,n;return"pre-paginated"===this.name?(i=1,n=1):"paginated"===this._flow?(e=e||this.delta,n=(i=Math.ceil(t/e))*this.divisor):(e=e||this.height,n=i=Math.ceil(t/e)),{spreads:i,pages:n}}},{key:"update",value:function(t){var e=this;if(Object.keys(t).forEach((function(i){e.props[i]===t[i]&&delete t[i]})),Object.keys(t).length>0){var i=k(this.props,t);this.emit(Se,i,t)}}}],e&&si(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();r()(oi.prototype);var ai=oi;function hi(t){return hi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},hi(t)}function li(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ui(n.key),n)}}function ui(t){var e=function(t){if("object"!=hi(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=hi(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==hi(e)?e:e+""}var ci=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.rendition=e,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))},e=[{key:"register",value:function(){if(0!==arguments.length)return 1===arguments.length&&"object"===hi(arguments[0])?this.registerThemes(arguments[0]):1===arguments.length&&"string"==typeof arguments[0]?this.default(arguments[0]):2===arguments.length&&"string"==typeof arguments[1]?this.registerUrl(arguments[0],arguments[1]):2===arguments.length&&"object"===hi(arguments[1])?this.registerRules(arguments[0],arguments[1]):void 0}},{key:"default",value:function(t){if(t)return"string"==typeof t?this.registerUrl("default",t):"object"===hi(t)?this.registerRules("default",t):void 0}},{key:"registerThemes",value:function(t){for(var e in t)t.hasOwnProperty(e)&&("string"==typeof t[e]?this.registerUrl(e,t[e]):this.registerRules(e,t[e]))}},{key:"registerCss",value:function(t,e){this._themes[t]={serialized:e},(this._injected[t]||"default"==t)&&this.update(t)}},{key:"registerUrl",value:function(t,e){var i=new ht(e);this._themes[t]={url:i.toString()},(this._injected[t]||"default"==t)&&this.update(t)}},{key:"registerRules",value:function(t,e){this._themes[t]={rules:e},(this._injected[t]||"default"==t)&&this.update(t)}},{key:"select",value:function(t){var e=this._current;this._current=t,this.update(t),this.rendition.getContents().forEach((function(i){i.removeClass(e),i.addClass(t)}))}},{key:"update",value:function(t){var e=this;this.rendition.getContents().forEach((function(i){e.add(t,i)}))}},{key:"inject",value:function(t){var e,i=[],n=this._themes;for(var s in n)!n.hasOwnProperty(s)||s!==this._current&&"default"!==s||(((e=n[s]).rules&&Object.keys(e.rules).length>0||e.url&&-1===i.indexOf(e.url))&&this.add(s,t),this._injected.push(s));"default"!=this._current&&t.addClass(this._current)}},{key:"add",value:function(t,e){var i=this._themes[t];i&&e&&(i.url?e.addStylesheet(i.url):i.serialized?(e.addStylesheetCss(i.serialized,t),i.injected=!0):i.rules&&(e.addStylesheetRules(i.rules,t),i.injected=!0))}},{key:"override",value:function(t,e,i){var n=this,s=this.rendition.getContents();this._overrides[t]={value:e,priority:!0===i},s.forEach((function(e){e.css(t,n._overrides[t].value,n._overrides[t].priority)}))}},{key:"removeOverride",value:function(t){var e=this.rendition.getContents();delete this._overrides[t],e.forEach((function(e){e.css(t)}))}},{key:"overrides",value:function(t){var e=this._overrides;for(var i in e)e.hasOwnProperty(i)&&t.css(i,e[i].value,e[i].priority)}},{key:"fontSize",value:function(t){this.override("font-size",t)}},{key:"font",value:function(t){this.override("font-family",t,!0)}},{key:"destroy",value:function(){this.rendition=void 0,this._themes=void 0,this._overrides=void 0,this._current=void 0,this._injected=void 0}}],e&&li(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),di=ci;function fi(t){return fi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},fi(t)}function pi(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,vi(n.key),n)}}function vi(t){var e=function(t){if("object"!=fi(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=fi(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==fi(e)?e:e+""}i(76281),i(99425);var yi=function(){return t=function t(e,i,n){var s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.layout=e,this.horizontal="horizontal"===n,this.direction=i||"ltr",this._dev=s},e=[{key:"section",value:function(t){var e=this.findRanges(t);return this.rangeListToCfiList(t.section.cfiBase,e)}},{key:"page",value:function(t,e,i,n){var s,r=!(!t||!t.document)&&t.document.body;if(r){if(s=this.rangePairToCfiPair(e,{start:this.findStart(r,i,n),end:this.findEnd(r,i,n)}),!0===this._dev){var o=t.document,a=new ft(s.start).toRange(o),h=new ft(s.end).toRange(o),l=o.defaultView.getSelection(),u=o.createRange();l.removeAllRanges(),u.setStart(a.startContainer,a.startOffset),u.setEnd(h.endContainer,h.endOffset),l.addRange(u)}return s}}},{key:"walk",value:function(t,e){if(!t||t.nodeType!==Node.TEXT_NODE){var i=function(t){return t.data.trim().length>0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT},n=i;n.acceptNode=i;for(var s,r,o=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,n,!1);(s=o.nextNode())&&!(r=e(s)););return r}}},{key:"findRanges",value:function(t){for(var e,i,n=[],s=t.contents.scrollWidth(),r=Math.ceil(s/this.layout.spreadWidth)*this.layout.divisor,o=this.layout.columnWidth,a=this.layout.gap,h=0;h<r.pages;h++)e=(o+a)*h,i=o*(h+1)+a*h,n.push({start:this.findStart(t.document.body,e,i),end:this.findEnd(t.document.body,e,i)});return n}},{key:"findStart",value:function(t,e,i){for(var n,s,r=this,o=[t],a=t;o.length;)if(n=o.shift(),s=this.walk(n,(function(t){var n,s,h,l,u;if(u=P(t),r.horizontal&&"ltr"===r.direction){if(n=r.horizontal?u.left:u.top,s=r.horizontal?u.right:u.bottom,n>=e&&n<=i)return t;if(s>e)return t;a=t,o.push(t)}else if(r.horizontal&&"rtl"===r.direction){if(n=u.left,(s=u.right)<=i&&s>=e)return t;if(n<i)return t;a=t,o.push(t)}else{if(h=u.top,l=u.bottom,h>=e&&h<=i)return t;if(l>e)return t;a=t,o.push(t)}})))return this.findTextStartRange(s,e,i);return this.findTextStartRange(a,e,i)}},{key:"findEnd",value:function(t,e,i){for(var n,s,r=this,o=[t],a=t;o.length;)if(n=o.shift(),s=this.walk(n,(function(t){var n,s,h,l,u;if(u=P(t),r.horizontal&&"ltr"===r.direction){if(n=Math.round(u.left),s=Math.round(u.right),n>i&&a)return a;if(s>i)return t;a=t,o.push(t)}else if(r.horizontal&&"rtl"===r.direction){if(n=Math.round(r.horizontal?u.left:u.top),(s=Math.round(r.horizontal?u.right:u.bottom))<e&&a)return a;if(n<e)return t;a=t,o.push(t)}else{if(h=Math.round(u.top),l=Math.round(u.bottom),h>i&&a)return a;if(l>i)return t;a=t,o.push(t)}})))return this.findTextEndRange(s,e,i);return this.findTextEndRange(a,e,i)}},{key:"findTextStartRange",value:function(t,e,i){for(var n,s,r=this.splitTextNodeIntoRanges(t),o=0;o<r.length;o++)if(s=(n=r[o]).getBoundingClientRect(),this.horizontal&&"ltr"===this.direction){if(s.left>=e)return n}else if(this.horizontal&&"rtl"===this.direction){if(s.right<=i)return n}else if(s.top>=e)return n;return r[0]}},{key:"findTextEndRange",value:function(t,e,i){for(var n,s,r,o,a,h,l,u=this.splitTextNodeIntoRanges(t),c=0;c<u.length;c++){if(r=(s=u[c]).getBoundingClientRect(),this.horizontal&&"ltr"===this.direction){if(o=r.left,a=r.right,o>i&&n)return n;if(a>i)return s}else if(this.horizontal&&"rtl"===this.direction){if(o=r.left,(a=r.right)<e&&n)return n;if(o<e)return s}else{if(h=r.top,l=r.bottom,h>i&&n)return n;if(l>i)return s}n=s}return u[u.length-1]}},{key:"splitTextNodeIntoRanges",value:function(t,e){var i,n=[],s=(t.textContent||"").trim(),r=t.ownerDocument,o=e||" ",a=s.indexOf(o);if(-1===a||t.nodeType!=Node.TEXT_NODE)return(i=r.createRange()).selectNodeContents(t),[i];for((i=r.createRange()).setStart(t,0),i.setEnd(t,a),n.push(i),i=!1;-1!=a;)(a=s.indexOf(o,a+1))>0&&(i&&(i.setEnd(t,a),n.push(i)),(i=r.createRange()).setStart(t,a+1));return i&&(i.setEnd(t,s.length),n.push(i)),n}},{key:"rangePairToCfiPair",value:function(t,e){var i=e.start,n=e.end;return i.collapse(!0),n.collapse(!1),{start:new ft(i,t).toString(),end:new ft(n,t).toString()}}},{key:"rangeListToCfiList",value:function(t,e){for(var i,n=[],s=0;s<e.length;s++)i=this.rangePairToCfiPair(t,e[s]),n.push(i);return n}},{key:"axis",value:function(t){return t&&(this.horizontal="horizontal"===t),this.horizontal}}],e&&pi(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),mi=yi;function gi(t){return gi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},gi(t)}function bi(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,wi(n.key),n)}}function wi(t){var e=function(t){if("object"!=gi(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=gi(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==gi(e)?e:e+""}var ki="undefined"!=typeof navigator,xi=ki&&/Chrome/.test(navigator.userAgent),Si=ki&&!xi&&/AppleWebKit/.test(navigator.userAgent),Ti=function(){return t=function t(e,i,n,s){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.epubcfi=new ft,this.document=e,this.documentElement=this.document.documentElement,this.content=i||this.document.body,this.window=this.document.defaultView,this._size={width:0,height:0},this.sectionIndex=s||0,this.cfiBase=n||"",this.epubReadingSystem("epub.js",Mt),this.called=0,this.active=!0,this.listeners()},e=[{key:"width",value:function(t){var e=this.content;return t&&m(t)&&(t+="px"),t&&(e.style.width=t),parseInt(this.window.getComputedStyle(e).width)}},{key:"height",value:function(t){var e=this.content;return t&&m(t)&&(t+="px"),t&&(e.style.height=t),parseInt(this.window.getComputedStyle(e).height)}},{key:"contentWidth",value:function(t){var e=this.content||this.document.body;return t&&m(t)&&(t+="px"),t&&(e.style.width=t),parseInt(this.window.getComputedStyle(e).width)}},{key:"contentHeight",value:function(t){var e=this.content||this.document.body;return t&&m(t)&&(t+="px"),t&&(e.style.height=t),parseInt(this.window.getComputedStyle(e).height)}},{key:"textWidth",value:function(){var t,e=this.document.createRange(),i=this.content||this.document.body,n=E(i);return e.selectNodeContents(i),t=e.getBoundingClientRect().width,n&&n.width&&(t+=n.width),Math.round(t)}},{key:"textHeight",value:function(){var t,e=this.document.createRange(),i=this.content||this.document.body;return e.selectNodeContents(i),t=e.getBoundingClientRect().bottom,Math.round(t)}},{key:"scrollWidth",value:function(){return this.documentElement.scrollWidth}},{key:"scrollHeight",value:function(){return this.documentElement.scrollHeight}},{key:"overflow",value:function(t){return t&&(this.documentElement.style.overflow=t),this.window.getComputedStyle(this.documentElement).overflow}},{key:"overflowX",value:function(t){return t&&(this.documentElement.style.overflowX=t),this.window.getComputedStyle(this.documentElement).overflowX}},{key:"overflowY",value:function(t){return t&&(this.documentElement.style.overflowY=t),this.window.getComputedStyle(this.documentElement).overflowY}},{key:"css",value:function(t,e,i){var n=this.content||this.document.body;return e?n.style.setProperty(t,e,i?"important":""):n.style.removeProperty(t),this.window.getComputedStyle(n)[t]}},{key:"viewport",value:function(t){var e,i=this.document.querySelector("meta[name='viewport']"),n={width:void 0,height:void 0,scale:void 0,minimum:void 0,maximum:void 0,scalable:void 0},s=[];if(i&&i.hasAttribute("content")){var r=i.getAttribute("content"),o=r.match(/width\s*=\s*([^,]*)/),a=r.match(/height\s*=\s*([^,]*)/),h=r.match(/initial-scale\s*=\s*([^,]*)/),l=r.match(/minimum-scale\s*=\s*([^,]*)/),u=r.match(/maximum-scale\s*=\s*([^,]*)/),c=r.match(/user-scalable\s*=\s*([^,]*)/);o&&o.length&&void 0!==o[1]&&(n.width=o[1]),a&&a.length&&void 0!==a[1]&&(n.height=a[1]),h&&h.length&&void 0!==h[1]&&(n.scale=h[1]),l&&l.length&&void 0!==l[1]&&(n.minimum=l[1]),u&&u.length&&void 0!==u[1]&&(n.maximum=u[1]),c&&c.length&&void 0!==c[1]&&(n.scalable=c[1])}return e=w(t||{},n),t&&(e.width&&s.push("width="+e.width),e.height&&s.push("height="+e.height),e.scale&&s.push("initial-scale="+e.scale),"no"===e.scalable?(s.push("minimum-scale="+e.scale),s.push("maximum-scale="+e.scale),s.push("user-scalable="+e.scalable)):(e.scalable&&s.push("user-scalable="+e.scalable),e.minimum&&s.push("minimum-scale="+e.minimum),e.maximum&&s.push("minimum-scale="+e.maximum)),i||((i=this.document.createElement("meta")).setAttribute("name","viewport"),this.document.querySelector("head").appendChild(i)),i.setAttribute("content",s.join(", ")),this.window.scrollTo(0,0)),e}},{key:"expand",value:function(){this.emit(Ut)}},{key:"listeners",value:function(){this.imageLoadListeners(),this.mediaQueryListeners(),this.addEventListeners(),this.addSelectionListeners(),"undefined"==typeof ResizeObserver?(this.resizeListeners(),this.visibilityListeners()):this.resizeObservers(),this.linksHandler()}},{key:"removeListeners",value:function(){this.removeEventListeners(),this.removeSelectionListeners(),this.observer&&this.observer.disconnect(),clearTimeout(this.expanding)}},{key:"resizeCheck",value:function(){var t=this.textWidth(),e=this.textHeight();t==this._size.width&&e==this._size.height||(this._size={width:t,height:e},this.onResize&&this.onResize(this._size),this.emit(Dt,this._size))}},{key:"resizeListeners",value:function(){clearTimeout(this.expanding),requestAnimationFrame(this.resizeCheck.bind(this)),this.expanding=setTimeout(this.resizeListeners.bind(this),350)}},{key:"visibilityListeners",value:function(){var t=this;document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState&&!1===t.active?(t.active=!0,t.resizeListeners()):(t.active=!1,clearTimeout(t.expanding))}))}},{key:"transitionListeners",value:function(){var t=this.content;t.style.transitionProperty="font, font-size, font-size-adjust, font-stretch, font-variation-settings, font-weight, width, height",t.style.transitionDuration="0.001ms",t.style.transitionTimingFunction="linear",t.style.transitionDelay="0",this._resizeCheck=this.resizeCheck.bind(this),this.document.addEventListener("transitionend",this._resizeCheck)}},{key:"mediaQueryListeners",value:function(){for(var t=this.document.styleSheets,e=function(t){t.matches&&!this._expanding&&setTimeout(this.expand.bind(this),1)}.bind(this),i=0;i<t.length;i+=1){var n;try{n=t[i].cssRules}catch(t){return}if(!n)return;for(var s=0;s<n.length;s+=1)n[s].media&&this.window.matchMedia(n[s].media.mediaText).addListener(e)}}},{key:"resizeObservers",value:function(){var t=this;this.observer=new ResizeObserver((function(e){requestAnimationFrame(t.resizeCheck.bind(t))})),this.observer.observe(this.document.documentElement)}},{key:"mutationObservers",value:function(){var t=this;this.observer=new MutationObserver((function(e){t.resizeCheck()})),this.observer.observe(this.document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})}},{key:"imageLoadListeners",value:function(){for(var t,e=this.document.querySelectorAll("img"),i=0;i<e.length;i++)void 0!==(t=e[i]).naturalWidth&&0===t.naturalWidth&&(t.onload=this.expand.bind(this))}},{key:"fontLoadListeners",value:function(){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(t,e){var i,n={left:0,top:0};if(!this.document)return n;if(this.epubcfi.isCfiString(t)){var s=new ft(t).toRange(this.document,e);if(s){try{if(!s.endContainer||s.startContainer==s.endContainer&&s.startOffset==s.endOffset){var r=s.startContainer.textContent.indexOf(" ",s.startOffset);-1==r&&(r=s.startContainer.textContent.length),s.setEnd(s.startContainer,r)}}catch(t){console.error("setting end offset to start container length failed",t)}if(s.startContainer.nodeType===Node.ELEMENT_NODE)i=s.startContainer.getBoundingClientRect(),n.left=i.left,n.top=i.top;else if(Si){var o=s.startContainer,a=new Range;try{1===o.nodeType?i=o.getBoundingClientRect():s.startOffset+2<o.length?(a.setStart(o,s.startOffset),a.setEnd(o,s.startOffset+2),i=a.getBoundingClientRect()):s.startOffset-2>0?(a.setStart(o,s.startOffset-2),a.setEnd(o,s.startOffset),i=a.getBoundingClientRect()):i=o.parentNode.getBoundingClientRect()}catch(t){console.error(t,t.stack)}}else i=s.getBoundingClientRect()}}else if("string"==typeof t&&t.indexOf("#")>-1){var h=t.substring(t.indexOf("#")+1),l=this.document.getElementById(h);if(l)if(Si){var u=new Range;u.selectNode(l),i=u.getBoundingClientRect()}else i=l.getBoundingClientRect()}return i&&(n.left=i.left,n.top=i.top),n}},{key:"addStylesheet",value:function(t){return new Promise(function(e,i){var n,s=!1;this.document?(n=this.document.querySelector("link[href='"+t+"']"))?e(!0):((n=this.document.createElement("link")).type="text/css",n.rel="stylesheet",n.href=t,n.onload=n.onreadystatechange=function(){s||this.readyState&&"complete"!=this.readyState||(s=!0,setTimeout((function(){e(!0)}),1))},this.document.head.appendChild(n)):e(!1)}.bind(this))}},{key:"_getStylesheetNode",value:function(t){var e;return t="epubjs-inserted-css-"+(t||""),!!this.document&&((e=this.document.getElementById(t))||((e=this.document.createElement("style")).id=t,this.document.head.appendChild(e)),e)}},{key:"addStylesheetCss",value:function(t,e){return!(!this.document||!t||(this._getStylesheetNode(e).innerHTML=t,0))}},{key:"addStylesheetRules",value:function(t,e){var i;if(this.document&&t&&0!==t.length)if(i=this._getStylesheetNode(e).sheet,"[object Array]"===Object.prototype.toString.call(t))for(var n=0,s=t.length;n<s;n++){var r=1,o=t[n],a=t[n][0],h="";"[object Array]"===Object.prototype.toString.call(o[1][0])&&(o=o[1],r=0);for(var l=o.length;r<l;r++){var u=o[r];h+=u[0]+":"+u[1]+(u[2]?" !important":"")+";\n"}i.insertRule(a+"{"+h+"}",i.cssRules.length)}else Object.keys(t).forEach((function(e){var n=t[e];if(Array.isArray(n))n.forEach((function(t){var n=Object.keys(t).map((function(e){return"".concat(e,":").concat(t[e])})).join(";");i.insertRule("".concat(e,"{").concat(n,"}"),i.cssRules.length)}));else{var s=Object.keys(n).map((function(t){return"".concat(t,":").concat(n[t])})).join(";");i.insertRule("".concat(e,"{").concat(s,"}"),i.cssRules.length)}}))}},{key:"addScript",value:function(t){return new Promise(function(e,i){var n,s=!1;this.document?((n=this.document.createElement("script")).type="text/javascript",n.async=!0,n.src=t,n.onload=n.onreadystatechange=function(){s||this.readyState&&"complete"!=this.readyState||(s=!0,setTimeout((function(){e(!0)}),1))},this.document.head.appendChild(n)):e(!1)}.bind(this))}},{key:"addClass",value:function(t){var e;this.document&&(e=this.content||this.document.body)&&e.classList.add(t)}},{key:"removeClass",value:function(t){var e;this.document&&(e=this.content||this.document.body)&&e.classList.remove(t)}},{key:"addEventListeners",value:function(){this.document&&(this._triggerEvent=this.triggerEvent.bind(this),Wt.forEach((function(t){this.document.addEventListener(t,this._triggerEvent,{passive:!0})}),this))}},{key:"removeEventListeners",value:function(){this.document&&(Wt.forEach((function(t){this.document.removeEventListener(t,this._triggerEvent,{passive:!0})}),this),this._triggerEvent=void 0)}},{key:"triggerEvent",value:function(t){this.emit(t.type,t)}},{key:"addSelectionListeners",value:function(){this.document&&(this._onSelectionChange=this.onSelectionChange.bind(this),this.document.addEventListener("selectionchange",this._onSelectionChange,{passive:!0}))}},{key:"removeSelectionListeners",value:function(){this.document&&(this.document.removeEventListener("selectionchange",this._onSelectionChange,{passive:!0}),this._onSelectionChange=void 0)}},{key:"onSelectionChange",value:function(t){this.selectionEndTimeout&&clearTimeout(this.selectionEndTimeout),this.selectionEndTimeout=setTimeout(function(){var t=this.window.getSelection();this.triggerSelectedEvent(t)}.bind(this),250)}},{key:"triggerSelectedEvent",value:function(t){var e,i;t&&t.rangeCount>0&&((e=t.getRangeAt(0)).collapsed||(i=new ft(e,this.cfiBase).toString(),this.emit(Ht,i),this.emit(Vt,e)))}},{key:"range",value:function(t,e){return new ft(t).toRange(this.document,e)}},{key:"cfiFromRange",value:function(t,e){return new ft(t,this.cfiBase,e).toString()}},{key:"cfiFromNode",value:function(t,e){return new ft(t,this.cfiBase,e).toString()}},{key:"map",value:function(t){return new mi(t).section()}},{key:"size",value:function(t,e){var i={scale:1,scalable:"no"};this.layoutStyle("scrolling"),t>=0&&(this.width(t),i.width=t,this.css("padding","0 "+t/12+"px")),e>=0&&(this.height(e),i.height=e),this.css("margin","0"),this.css("box-sizing","border-box"),this.viewport(i)}},{key:"columns",value:function(t,e,i,n,s){var r=b("column-axis"),o=b("column-gap"),a=b("column-width"),h=b("column-fill"),l=0===this.writingMode().indexOf("vertical")?"vertical":"horizontal";this.layoutStyle("paginated"),"rtl"===s&&"horizontal"===l&&this.direction(s),this.width(t),this.height(e),this.viewport({width:t,height:e,scale:1,scalable:"no"}),this.css("overflow-y","hidden"),this.css("margin","0",!0),"vertical"===l?(this.css("padding-top",n/2+"px",!0),this.css("padding-bottom",n/2+"px",!0),this.css("padding-left","20px"),this.css("padding-right","20px"),this.css(r,"vertical")):(this.css("padding-top","20px"),this.css("padding-bottom","20px"),this.css("padding-left",n/2+"px",!0),this.css("padding-right",n/2+"px",!0),this.css(r,"horizontal")),this.css("box-sizing","border-box"),this.css("max-width","inherit"),this.css(h,"auto"),this.css(o,n+"px"),this.css(a,i+"px"),this.css("-webkit-line-box-contain","block glyphs replaced")}},{key:"scaler",value:function(t,e,i){var n="scale("+t+")",s="";this.css("transform-origin","top left"),(e>=0||i>=0)&&(s=" translate("+(e||0)+"px, "+(i||0)+"px )"),this.css("transform",n+s)}},{key:"fit",value:function(t,e,i){var n=this.viewport(),s=parseInt(n.width),r=parseInt(n.height),o=t/s,a=e/r,h=o<a?o:a;if(this.layoutStyle("paginated"),this.width(s),this.height(r),this.overflow("hidden"),this.scaler(h,0,0),this.css("background-size",s*h+"px "+r*h+"px"),this.css("background-color","transparent"),i&&i.properties.includes("page-spread-left")){var l=t-s*h;this.css("margin-left",l+"px")}}},{key:"direction",value:function(t){this.documentElement&&(this.documentElement.style.direction=t)}},{key:"mapPage",value:function(t,e,i,n,s){return new mi(e,s).page(this,t,i,n)}},{key:"linksHandler",value:function(){var t=this;!function(t,e){var i=t.querySelectorAll("a[href]");if(i.length)for(var n=M(t.ownerDocument,"base"),s=n?n.getAttribute("href"):void 0,r=function(t){var i=t.getAttribute("href");if(0!==i.indexOf("mailto:"))if(i.indexOf("://")>-1)t.setAttribute("target","_blank");else{var n;try{n=new ht(i,s)}catch(t){}t.onclick=function(){return n&&n.hash?e(n.Path.path+n.hash):e(n?n.Path.path:i),!1}}}.bind(this),o=0;o<i.length;o++)r(i[o])}(this.content,(function(e){t.emit(Xt,e)}))}},{key:"writingMode",value:function(t){var e=b("writing-mode");return t&&this.documentElement&&(this.documentElement.style[e]=t),this.window.getComputedStyle(this.documentElement)[e]||""}},{key:"layoutStyle",value:function(t){return t&&(this._layoutStyle=t,navigator.epubReadingSystem.layoutStyle=this._layoutStyle),this._layoutStyle||"paginated"}},{key:"epubReadingSystem",value:function(t,e){return navigator.epubReadingSystem={name:t,version:e,layoutStyle:this.layoutStyle(),hasFeature:function(t){switch(t){case"dom-manipulation":case"layout-changes":case"touch-events":case"mouse-events":case"keyboard-events":return!0;default:return!1}}},navigator.epubReadingSystem}},{key:"destroy",value:function(){this.removeListeners()}}],i=[{key:"listenedEvents",get:function(){return Wt}}],e&&bi(t.prototype,e),i&&bi(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,i}();r()(Ti.prototype);var Ci=Ti;function Ei(t){return Ei="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ei(t)}function Pi(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Li(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Oi(n.key),n)}}function _i(t,e,i){return e&&Li(t.prototype,e),i&&Li(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}function Oi(t){var e=function(t){if("object"!=Ei(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=Ei(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ei(e)?e:e+""}var ji=function(){return _i((function t(e){Pi(this,t),this.rendition=e,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))}),[{key:"add",value:function(t,e,i,n,s,r){var o=encodeURI(e+t),a=new ft(e).spinePos,h=new zi({type:t,cfiRange:e,data:i,sectionIndex:a,cb:n,className:s,styles:r});return this._annotations[o]=h,a in this._annotationsBySectionIndex?this._annotationsBySectionIndex[a].push(o):this._annotationsBySectionIndex[a]=[o],this.rendition.views().forEach((function(t){h.sectionIndex===t.index&&h.attach(t)})),h}},{key:"remove",value:function(t,e){var i=this,n=encodeURI(t+e);if(n in this._annotations){var s=this._annotations[n];if(e&&s.type!==e)return;this.rendition.views().forEach((function(t){i._removeFromAnnotationBySectionIndex(s.sectionIndex,n),s.sectionIndex===t.index&&s.detach(t)})),delete this._annotations[n]}}},{key:"_removeFromAnnotationBySectionIndex",value:function(t,e){this._annotationsBySectionIndex[t]=this._annotationsAt(t).filter((function(t){return t!==e}))}},{key:"_annotationsAt",value:function(t){return this._annotationsBySectionIndex[t]}},{key:"highlight",value:function(t,e,i,n,s){return this.add("highlight",t,e,i,n,s)}},{key:"underline",value:function(t,e,i,n,s){return this.add("underline",t,e,i,n,s)}},{key:"mark",value:function(t,e,i){return this.add("mark",t,e,i)}},{key:"each",value:function(){return this._annotations.forEach.apply(this._annotations,arguments)}},{key:"inject",value:function(t){var e=this,i=t.index;i in this._annotationsBySectionIndex&&this._annotationsBySectionIndex[i].forEach((function(i){e._annotations[i].attach(t)}))}},{key:"clear",value:function(t){var e=this,i=t.index;i in this._annotationsBySectionIndex&&this._annotationsBySectionIndex[i].forEach((function(i){e._annotations[i].detach(t)}))}},{key:"show",value:function(){}},{key:"hide",value:function(){}}])}(),zi=function(){return _i((function t(e){var i=e.type,n=e.cfiRange,s=e.data,r=e.sectionIndex,o=e.cb,a=e.className,h=e.styles;Pi(this,t),this.type=i,this.cfiRange=n,this.data=s,this.sectionIndex=r,this.mark=void 0,this.cb=o,this.className=a,this.styles=h}),[{key:"update",value:function(t){this.data=t}},{key:"attach",value:function(t){var e,i=this.cfiRange,n=this.data,s=this.type,r=(this.mark,this.cb),o=this.className,a=this.styles;return"highlight"===s?e=t.highlight(i,n,r,o,a):"underline"===s?e=t.underline(i,n,r,o,a):"mark"===s&&(e=t.mark(i,n,r)),this.mark=e,this.emit(Te,e),e}},{key:"detach",value:function(t){var e,i=this.cfiRange,n=this.type;return t&&("highlight"===n?e=t.unhighlight(i):"underline"===n?e=t.ununderline(i):"mark"===n&&(e=t.unmark(i))),this.mark=void 0,this.emit(Ce,e),e}},{key:"text",value:function(){}}])}();r()(zi.prototype);var Ri=ji,Ni=(i(77575),i(74608));function Bi(t){return Bi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Bi(t)}function qi(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ii(n.key),n)}}function Ii(t){var e=function(t){if("object"!=Bi(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=Bi(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Bi(e)?e:e+""}var Ai=function(){return t=function t(e,i){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.settings=k({ignoreClass:"",axis:void 0,direction:void 0,width:0,height:0,layout:void 0,globalLayoutProperties:{},method:void 0,forceRight:!1,allowScriptedContent:!1,allowPopups:!1},i||{}),this.id="epubjs-view-"+p(),this.section=e,this.index=e.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 ft,this.layout=this.settings.layout,this.pane=void 0,this.highlights={},this.underlines={},this.marks={}},e=[{key:"container",value:function(t){var e=document.createElement("div");return e.classList.add("epub-view"),e.style.height="0px",e.style.width="0px",e.style.overflow="hidden",e.style.position="relative",e.style.display="block",e.style.flex=t&&"horizontal"==t?"none":"initial",e}},{key:"create",value:function(){return 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.sandbox="allow-same-origin",this.settings.allowScriptedContent&&(this.iframe.sandbox+=" allow-scripts"),this.settings.allowPopups&&(this.iframe.sandbox+=" allow-popups"),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.added=!0,this.elementBounds=C(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(t,e){return this.create(),this.size(),this.sectionRender||(this.sectionRender=this.section.render(t)),this.sectionRender.then(function(t){return this.load(t)}.bind(this)).then(function(){var t,e=this,i=this.contents.writingMode();return t="scrolled"===this.settings.flow?0===i.indexOf("vertical")?"horizontal":"vertical":0===i.indexOf("vertical")?"vertical":"horizontal",0===i.indexOf("vertical")&&"paginated"===this.settings.flow&&(this.layout.delta=this.layout.height),this.setAxis(t),this.emit(ee,t),this.setWritingMode(i),this.emit(ie,i),this.layout.format(this.contents,this.section,this.axis),this.addListeners(),new Promise((function(t,i){e.expand(),e.settings.forceRight&&(e.element.style.marginLeft=e.width()+"px"),t()}))}.bind(this),function(t){return this.emit(ne,t),new Promise((function(e,i){i(t)}))}.bind(this)).then(function(){this.emit(se,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(t,e){var i=t||this.settings.width,n=e||this.settings.height;"pre-paginated"===this.layout.name?this.lock("both",i,n):"horizontal"===this.settings.axis?this.lock("height",i,n):this.lock("width",i,n),this.settings.width=i,this.settings.height=n}},{key:"lock",value:function(t,e,i){var n,s=E(this.element);n=this.iframe?E(this.iframe):{width:0,height:0},"width"==t&&m(e)&&(this.lockedWidth=e-s.width-n.width),"height"==t&&m(i)&&(this.lockedHeight=i-s.height-n.height),"both"===t&&m(e)&&m(i)&&(this.lockedWidth=e-s.width-n.width,this.lockedHeight=i-s.height-n.height),this.displayed&&this.iframe&&this.expand()}},{key:"expand",value:function(t){var e,i=this.lockedWidth,n=this.lockedHeight;this.iframe&&!this._expanding&&(this._expanding=!0,"pre-paginated"===this.layout.name?(i=this.layout.columnWidth,n=this.layout.height):"horizontal"===this.settings.axis?((i=this.contents.textWidth())%this.layout.pageWidth>0&&(i=Math.ceil(i/this.layout.pageWidth)*this.layout.pageWidth),this.settings.forceEvenPages&&(e=i/this.layout.pageWidth,this.layout.divisor>1&&"reflowable"===this.layout.name&&e%2>0&&(i+=this.layout.pageWidth))):"vertical"===this.settings.axis&&(n=this.contents.textHeight(),"paginated"===this.settings.flow&&n%this.layout.height>0&&(n=Math.ceil(n/this.layout.height)*this.layout.height)),(this._needsReframe||i!=this._width||n!=this._height)&&this.reframe(i,n),this._expanding=!1)}},{key:"reframe",value:function(t,e){var i,n=this;m(t)&&(this.element.style.width=t+"px",this.iframe.style.width=t+"px",this._width=t),m(e)&&(this.element.style.height=e+"px",this.iframe.style.height=e+"px",this._height=e),i={width:t,height:e,widthDelta:this.prevBounds?t-this.prevBounds.width:t,heightDelta:this.prevBounds?e-this.prevBounds.height:e},this.pane&&this.pane.render(),requestAnimationFrame((function(){var t;for(var e in n.marks)n.marks.hasOwnProperty(e)&&(t=n.marks[e],n.placeMark(t.element,t.range))})),this.onResize(this,i),this.emit(re,i),this.prevBounds=i,this.elementBounds=C(this.element)}},{key:"load",value:function(t){var e=new X,i=e.promise;if(!this.iframe)return e.reject(new Error("No Iframe Available")),i;if(this.iframe.onload=function(t){this.onLoad(t,e)}.bind(this),"blobUrl"===this.settings.method)this.blobUrl=N(t,"application/xhtml+xml"),this.iframe.src=this.blobUrl,this.element.appendChild(this.iframe);else if("srcdoc"===this.settings.method)this.iframe.srcdoc=t,this.element.appendChild(this.iframe);else{if(this.element.appendChild(this.iframe),this.document=this.iframe.contentDocument,!this.document)return e.reject(new Error("No Document Available")),i;if(this.iframe.contentDocument.open(),window.MSApp&&MSApp.execUnsafeLocalFunction){var n=this;MSApp.execUnsafeLocalFunction((function(){n.iframe.contentDocument.write(t)}))}else this.iframe.contentDocument.write(t);this.iframe.contentDocument.close()}return i}},{key:"onLoad",value:function(t,e){var i=this;this.window=this.iframe.contentWindow,this.document=this.iframe.contentDocument,this.contents=new Ci(this.document,this.document.body,this.section.cfiBase,this.section.index),this.rendering=!1;var n=this.document.querySelector("link[rel='canonical']");n?n.setAttribute("href",this.section.canonical):((n=this.document.createElement("link")).setAttribute("rel","canonical"),n.setAttribute("href",this.section.canonical),this.document.querySelector("head").appendChild(n)),this.contents.on(Ut,(function(){i.displayed&&i.iframe&&(i.expand(),i.contents&&i.layout.format(i.contents))})),this.contents.on(Dt,(function(t){i.displayed&&i.iframe&&(i.expand(),i.contents&&i.layout.format(i.contents))})),e.resolve(this.contents)}},{key:"setLayout",value:function(t){this.layout=t,this.contents&&(this.layout.format(this.contents),this.expand())}},{key:"setAxis",value:function(t){this.settings.axis=t,this.element.style.flex="horizontal"==t?"none":"initial",this.size()}},{key:"setWritingMode",value:function(t){this.writingMode=t}},{key:"addListeners",value:function(){}},{key:"removeListeners",value:function(t){}},{key:"display",value:function(t){var e=new X;return this.displayed?e.resolve(this):this.render(t).then(function(){this.emit(oe,this),this.onDisplayed(this),this.displayed=!0,e.resolve(this)}.bind(this),(function(t){e.reject(t,this)})),e.promise}},{key:"show",value:function(){this.element.style.visibility="visible",this.iframe&&(this.iframe.style.visibility="visible",this.iframe.style.transform="translateZ(0)",this.iframe.offsetWidth,this.iframe.style.transform=null),this.emit(ae,this)}},{key:"hide",value:function(){this.element.style.visibility="hidden",this.iframe.style.visibility="hidden",this.stopExpanding=!0,this.emit(he,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(t){this.iframe.getBoundingClientRect();var e=this.contents.locationOf(t,this.settings.ignoreClass);return{left:e.left,top:e.top}}},{key:"onDisplayed",value:function(t){}},{key:"onResize",value:function(t,e){}},{key:"bounds",value:function(t){return!t&&this.elementBounds||(this.elementBounds=C(this.element)),this.elementBounds}},{key:"highlight",value:function(t){var e=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"epubjs-hl",r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};if(this.contents){var o=Object.assign({fill:"yellow","fill-opacity":"0.3","mix-blend-mode":"multiply"},r),a=this.contents.range(t),h=function(){e.emit(le,t,i)};i.epubcfi=t,this.pane||(this.pane=new Ni.Zv(this.iframe,this.element));var l=new Ni.f4(a,s,i,o),u=this.pane.addMark(l);return this.highlights[t]={mark:u,element:u.element,listeners:[h,n]},u.element.setAttribute("ref",s),u.element.addEventListener("click",h),u.element.addEventListener("touchstart",h),n&&(u.element.addEventListener("click",n),u.element.addEventListener("touchstart",n)),u}}},{key:"underline",value:function(t){var e=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"epubjs-ul",r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};if(this.contents){var o=Object.assign({stroke:"black","stroke-opacity":"0.3","mix-blend-mode":"multiply"},r),a=this.contents.range(t),h=function(){e.emit(le,t,i)};i.epubcfi=t,this.pane||(this.pane=new Ni.Zv(this.iframe,this.element));var l=new Ni.z2(a,s,i,o),u=this.pane.addMark(l);return this.underlines[t]={mark:u,element:u.element,listeners:[h,n]},u.element.setAttribute("ref",s),u.element.addEventListener("click",h),u.element.addEventListener("touchstart",h),n&&(u.element.addEventListener("click",n),u.element.addEventListener("touchstart",n)),u}}},{key:"mark",value:function(t){var e=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;if(this.contents){if(t in this.marks)return this.marks[t];var s=this.contents.range(t);if(s){var r=s.commonAncestorContainer,o=1===r.nodeType?r:r.parentNode,a=function(n){e.emit(le,t,i)};s.collapsed&&1===r.nodeType?(s=new Range).selectNodeContents(r):s.collapsed&&(s=new Range).selectNodeContents(o);var h=this.document.createElement("a");return h.setAttribute("ref","epubjs-mk"),h.style.position="absolute",h.dataset.epubcfi=t,i&&Object.keys(i).forEach((function(t){h.dataset[t]=i[t]})),n&&(h.addEventListener("click",n),h.addEventListener("touchstart",n)),h.addEventListener("click",a),h.addEventListener("touchstart",a),this.placeMark(h,s),this.element.appendChild(h),this.marks[t]={element:h,range:s,listeners:[a,n]},o}}}},{key:"placeMark",value:function(t,e){var i,n,s;if("pre-paginated"===this.layout.name||"horizontal"!==this.settings.axis){var r=e.getBoundingClientRect();i=r.top,n=r.right}else for(var o,a=e.getClientRects(),h=0;h!=a.length;h++)o=a[h],(!s||o.left<s)&&(s=o.left,n=Math.ceil(s/this.layout.props.pageWidth)*this.layout.props.pageWidth-this.layout.gap/2,i=o.top);t.style.top="".concat(i,"px"),t.style.left="".concat(n,"px")}},{key:"unhighlight",value:function(t){var e;t in this.highlights&&(e=this.highlights[t],this.pane.removeMark(e.mark),e.listeners.forEach((function(t){t&&(e.element.removeEventListener("click",t),e.element.removeEventListener("touchstart",t))})),delete this.highlights[t])}},{key:"ununderline",value:function(t){var e;t in this.underlines&&(e=this.underlines[t],this.pane.removeMark(e.mark),e.listeners.forEach((function(t){t&&(e.element.removeEventListener("click",t),e.element.removeEventListener("touchstart",t))})),delete this.underlines[t])}},{key:"unmark",value:function(t){var e;t in this.marks&&(e=this.marks[t],this.element.removeChild(e.element),e.listeners.forEach((function(t){t&&(e.element.removeEventListener("click",t),e.element.removeEventListener("touchstart",t))})),delete this.marks[t])}},{key:"destroy",value:function(){for(var t in this.highlights)this.unhighlight(t);for(var e in this.underlines)this.ununderline(e);for(var i in this.marks)this.unmark(i);this.blobUrl&&B(this.blobUrl),this.displayed&&(this.displayed=!1,this.removeListeners(),this.contents.destroy(),this.stopExpanding=!0,this.element.removeChild(this.iframe),this.pane&&(this.pane.element.remove(),this.pane=void 0),this.iframe=void 0,this.contents=void 0,this._textWidth=null,this._textHeight=null,this._width=null,this._height=null)}}],e&&qi(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();r()(Ai.prototype);var Mi=Ai;var Wi=i(32858),Fi=i.n(Wi);function Ui(t){return Ui="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ui(t)}function Di(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Hi(n.key),n)}}function Hi(t){var e=function(t){if("object"!=Ui(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=Ui(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ui(e)?e:e+""}var Vi=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.settings=e||{},this.id="epubjs-container-"+p(),this.container=this.create(this.settings),this.settings.hidden&&(this.wrapper=this.wrap(this.container))},e=[{key:"create",value:function(t){var e=t.height,i=t.width,n=t.overflow||!1,s=t.axis||"vertical",r=t.direction;k(this.settings,t),t.height&&m(t.height)&&(e=t.height+"px"),t.width&&m(t.width)&&(i=t.width+"px");var o=document.createElement("div");return o.id=this.id,o.classList.add("epub-container"),o.style.wordSpacing="0",o.style.lineHeight="0",o.style.verticalAlign="top",o.style.position="relative","horizontal"===s&&(o.style.display="flex",o.style.flexDirection="row",o.style.flexWrap="nowrap"),i&&(o.style.width=i),e&&(o.style.height=e),n&&("scroll"===n&&"vertical"===s?(o.style["overflow-y"]=n,o.style["overflow-x"]="hidden"):"scroll"===n&&"horizontal"===s?(o.style["overflow-y"]="hidden",o.style["overflow-x"]=n):o.style.overflow=n),r&&(o.dir=r,o.style.direction=r),r&&this.settings.fullsize&&(document.body.style.direction=r),o}},{key:"wrap",value:function(t){var e=document.createElement("div");return e.style.visibility="hidden",e.style.overflow="hidden",e.style.width="0",e.style.height="0",e.appendChild(t),e}},{key:"getElement",value:function(t){var e;if(y(t)?e=t:"string"==typeof t&&(e=document.getElementById(t)),!e)throw new Error("Not an Element");return e}},{key:"attachTo",value:function(t){var e,i=this.getElement(t);if(i)return e=this.settings.hidden?this.wrapper:this.container,i.appendChild(e),this.element=i,i}},{key:"getContainer",value:function(){return this.container}},{key:"onResize",value:function(t){m(this.settings.width)&&m(this.settings.height)||(this.resizeFunc=Fi()(t,50),window.addEventListener("resize",this.resizeFunc,!1))}},{key:"onOrientationChange",value:function(t){this.orientationChangeFunc=t,window.addEventListener("orientationchange",this.orientationChangeFunc,!1)}},{key:"size",value:function(t,e){var i,n=t||this.settings.width,s=e||this.settings.height;null===t?(i=this.element.getBoundingClientRect()).width&&(t=Math.floor(i.width),this.container.style.width=t+"px"):m(t)?this.container.style.width=t+"px":this.container.style.width=t,null===e?(i=i||this.element.getBoundingClientRect()).height&&(e=i.height,this.container.style.height=e+"px"):m(e)?this.container.style.height=e+"px":this.container.style.height=e,m(t)||(t=this.container.clientWidth),m(e)||(e=this.container.clientHeight),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=L(),o=window.getComputedStyle(document.body),a=parseFloat(o["padding-left"])||0,h=parseFloat(o["padding-right"])||0,l=parseFloat(o["padding-top"])||0,u=parseFloat(o["padding-bottom"])||0;return n||(t=r.width-a-h),(this.settings.fullsize&&!s||!s)&&(e=r.height-l-u),{width:t-this.containerPadding.left-this.containerPadding.right,height:e-this.containerPadding.top-this.containerPadding.bottom}}},{key:"bounds",value:function(){var t;return"visible"!==this.container.style.overflow&&(t=this.container&&this.container.getBoundingClientRect()),t&&t.width&&t.height?t:L()}},{key:"getSheet",value:function(){var t=document.createElement("style");return t.appendChild(document.createTextNode("")),document.head.appendChild(t),t.sheet}},{key:"addStyleRules",value:function(t,e){var i="#"+this.id+" ",n="";this.sheet||(this.sheet=this.getSheet()),e.forEach((function(t){for(var e in t)t.hasOwnProperty(e)&&(n+=e+":"+t[e]+";")})),this.sheet.insertRule(i+t+" {"+n+"}",0)}},{key:"axis",value:function(t){"horizontal"===t?(this.container.style.display="flex",this.container.style.flexDirection="row",this.container.style.flexWrap="nowrap"):this.container.style.display="block",this.settings.axis=t}},{key:"direction",value:function(t){this.container&&(this.container.dir=t,this.container.style.direction=t),this.settings.fullsize&&(document.body.style.direction=t),this.settings.dir=t}},{key:"overflow",value:function(t){this.container&&("scroll"===t&&"vertical"===this.settings.axis?(this.container.style["overflow-y"]=t,this.container.style["overflow-x"]="hidden"):"scroll"===t&&"horizontal"===this.settings.axis?(this.container.style["overflow-y"]="hidden",this.container.style["overflow-x"]=t):this.container.style.overflow=t),this.settings.overflow=t}},{key:"destroy",value:function(){this.element&&(this.settings.hidden?this.wrapper:this.container,this.element.contains(this.container)&&this.element.removeChild(this.container),window.removeEventListener("resize",this.resizeFunc),window.removeEventListener("orientationChange",this.orientationChangeFunc))}}],e&&Di(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),Xi=Vi;function Yi(t){return Yi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Yi(t)}function Ji(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Qi(n.key),n)}}function Qi(t){var e=function(t){if("object"!=Yi(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=Yi(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Yi(e)?e:e+""}var Zi=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.container=e,this._views=[],this.length=0,this.hidden=!1},e=[{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(t){return this._views.indexOf(t)}},{key:"slice",value:function(){return this._views.slice.apply(this._views,arguments)}},{key:"get",value:function(t){return this._views[t]}},{key:"append",value:function(t){return this._views.push(t),this.container&&this.container.appendChild(t.element),this.length++,t}},{key:"prepend",value:function(t){return this._views.unshift(t),this.container&&this.container.insertBefore(t.element,this.container.firstChild),this.length++,t}},{key:"insert",value:function(t,e){return this._views.splice(e,0,t),this.container&&(e<this.container.children.length?this.container.insertBefore(t.element,this.container.children[e]):this.container.appendChild(t.element)),this.length++,t}},{key:"remove",value:function(t){var e=this._views.indexOf(t);e>-1&&this._views.splice(e,1),this.destroy(t),this.length--}},{key:"destroy",value:function(t){t.displayed&&t.destroy(),this.container&&this.container.removeChild(t.element),t=null}},{key:"forEach",value:function(){return this._views.forEach.apply(this._views,arguments)}},{key:"clear",value:function(){var t,e=this.length;if(this.length){for(var i=0;i<e;i++)t=this._views[i],this.destroy(t);this._views=[],this.length=0}}},{key:"find",value:function(t){for(var e,i=this.length,n=0;n<i;n++)if((e=this._views[n]).displayed&&e.section.index==t.index)return e}},{key:"displayed",value:function(){for(var t,e=[],i=this.length,n=0;n<i;n++)(t=this._views[n]).displayed&&e.push(t);return e}},{key:"show",value:function(){for(var t,e=this.length,i=0;i<e;i++)(t=this._views[i]).displayed&&t.show();this.hidden=!1}},{key:"hide",value:function(){for(var t,e=this.length,i=0;i<e;i++)(t=this._views[i]).displayed&&t.hide();this.hidden=!0}}],e&&Ji(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),$i=Zi;function Gi(t){return Gi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Gi(t)}function Ki(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,tn(n.key),n)}}function tn(t){var e=function(t){if("object"!=Gi(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=Gi(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Gi(e)?e:e+""}var en=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.name="default",this.optsSettings=e.settings,this.View=e.view,this.request=e.request,this.renditionQueue=e.queue,this.q=new At(this),this.settings=k(this.settings||{},{infinite:!0,hidden:!1,width:void 0,height:void 0,axis:void 0,writingMode:void 0,flow:"scrolled",ignoreClass:"",fullsize:void 0,allowScriptedContent:!1,allowPopups:!1}),k(this.settings,e.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,allowScriptedContent:this.settings.allowScriptedContent,allowPopups:this.settings.allowPopups},this.rendered=!1},e=[{key:"render",value:function(t,e){var i=t.tagName;void 0!==this.settings.fullsize||!i||"body"!=i.toLowerCase()&&"html"!=i.toLowerCase()||(this.settings.fullsize=!0),this.settings.fullsize&&(this.settings.overflow="visible",this.overflow=this.settings.overflow),this.settings.size=e,this.settings.rtlScrollType=function(){var t="reverse",e=function(){var t=document.createElement("div");t.dir="rtl",t.style.position="fixed",t.style.width="1px",t.style.height="1px",t.style.top="0px",t.style.left="0px",t.style.overflow="hidden";var e=document.createElement("div");e.style.width="2px";var i=document.createElement("span");i.style.width="1px",i.style.display="inline-block";var n=document.createElement("span");return n.style.width="1px",n.style.display="inline-block",e.appendChild(i),e.appendChild(n),t.appendChild(e),t}();return document.body.appendChild(e),e.scrollLeft>0?t="default":"undefined"!=typeof Element&&Element.prototype.scrollIntoView?(e.children[0].children[1].scrollIntoView(),e.scrollLeft<0&&(t="negative")):(e.scrollLeft=1,0===e.scrollLeft&&(t="negative")),document.body.removeChild(e),t}(),this.stage=new Xi({width:e.width,height:e.height,overflow:this.overflow,hidden:this.settings.hidden,axis:this.settings.axis,fullsize:this.settings.fullsize,direction:this.settings.direction}),this.stage.attachTo(t),this.container=this.stage.getContainer(),this.views=new $i(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 t;window.addEventListener("unload",function(t){this.destroy()}.bind(this)),t=this.settings.fullsize?window:this.container,this._onScroll=this.onScroll.bind(this),t.addEventListener("scroll",this._onScroll)}},{key:"removeEventListeners",value:function(){(this.settings.fullsize?window:this.container).removeEventListener("scroll",this._onScroll),this._onScroll=void 0}},{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(t){var e=window.orientation;this.optsSettings.resizeOnOrientationChange&&this.resize(),clearTimeout(this.orientationTimeout),this.orientationTimeout=setTimeout(function(){this.orientationTimeout=void 0,this.optsSettings.resizeOnOrientationChange&&this.resize(),this.emit(Zt,e)}.bind(this),500)}},{key:"onResized",value:function(t){this.resize()}},{key:"resize",value:function(t,e,i){var n=this.stage.size(t,e);this.winBounds=L(),this.orientationTimeout&&this.winBounds.width===this.winBounds.height?this._stageSize=void 0:this._stageSize&&this._stageSize.width===n.width&&this._stageSize.height===n.height||(this._stageSize=n,this._bounds=this.bounds(),this.clear(),this.viewSettings.width=this._stageSize.width,this.viewSettings.height=this._stageSize.height,this.updateLayout(),this.emit(Qt,{width:this._stageSize.width,height:this._stageSize.height},i))}},{key:"createView",value:function(t,e){return new this.View(t,k(this.viewSettings,{forceRight:e}))}},{key:"handleNextPrePaginated",value:function(t,e,i){var n;if("pre-paginated"===this.layout.name&&this.layout.divisor>1){if(t||0===e.index)return;if((n=e.next())&&!n.properties.includes("page-spread-left"))return i.call(this,n)}}},{key:"display",value:function(t,e){var i=new X,n=i.promise;(e===t.href||m(e))&&(e=void 0);var s=this.views.find(t);if(s&&t&&"pre-paginated"!==this.layout.name){var r=s.offset();if("ltr"===this.settings.direction)this.scrollTo(r.left,r.top,!0);else{var o=s.width();this.scrollTo(r.left+o,r.top,!0)}if(e){var a=s.locationOf(e),h=s.width();this.moveTo(a,h)}return i.resolve(),n}this.clear();var l=!1;return"pre-paginated"===this.layout.name&&2===this.layout.divisor&&t.properties.includes("page-spread-right")&&(l=!0),this.add(t,l).then(function(t){if(e){var i=t.locationOf(e),n=t.width();this.moveTo(i,n)}}.bind(this),(function(t){i.reject(t)})).then(function(){return this.handleNextPrePaginated(l,t,this.add)}.bind(this)).then(function(){this.views.show(),i.resolve()}.bind(this)),n}},{key:"afterDisplayed",value:function(t){this.emit($t,t)}},{key:"afterResized",value:function(t){this.emit(Jt,t.section)}},{key:"moveTo",value:function(t,e){var i=0,n=0;this.isPaginated?((i=Math.floor(t.left/this.layout.delta)*this.layout.delta)+this.layout.delta>this.container.scrollWidth&&(i=this.container.scrollWidth-this.layout.delta),(n=Math.floor(t.top/this.layout.delta)*this.layout.delta)+this.layout.delta>this.container.scrollHeight&&(n=this.container.scrollHeight-this.layout.delta)):n=t.top,"rtl"===this.settings.direction&&(i+=this.layout.delta,i-=e),this.scrollTo(i,n,!0)}},{key:"add",value:function(t,e){var i=this,n=this.createView(t,e);return this.views.append(n),n.onDisplayed=this.afterDisplayed.bind(this),n.onResize=this.afterResized.bind(this),n.on(ee,(function(t){i.updateAxis(t)})),n.on(ie,(function(t){i.updateWritingMode(t)})),n.display(this.request)}},{key:"append",value:function(t,e){var i=this,n=this.createView(t,e);return this.views.append(n),n.onDisplayed=this.afterDisplayed.bind(this),n.onResize=this.afterResized.bind(this),n.on(ee,(function(t){i.updateAxis(t)})),n.on(ie,(function(t){i.updateWritingMode(t)})),n.display(this.request)}},{key:"prepend",value:function(t,e){var i=this,n=this.createView(t,e);return n.on(re,(function(t){i.counter(t)})),this.views.prepend(n),n.onDisplayed=this.afterDisplayed.bind(this),n.onResize=this.afterResized.bind(this),n.on(ee,(function(t){i.updateAxis(t)})),n.on(ie,(function(t){i.updateWritingMode(t)})),n.display(this.request)}},{key:"counter",value:function(t){"vertical"===this.settings.axis?this.scrollBy(0,t.heightDelta,!0):this.scrollBy(t.widthDelta,0,!0)}},{key:"next",value:function(){var t,e=this.settings.direction;if(this.views.length&&(!this.isPaginated||"horizontal"!==this.settings.axis||e&&"ltr"!==e?this.isPaginated&&"horizontal"===this.settings.axis&&"rtl"===e?(this.scrollLeft=this.container.scrollLeft,"default"===this.settings.rtlScrollType?this.container.scrollLeft>0?this.scrollBy(this.layout.delta,0,!0):t=this.views.last().section.next():this.container.scrollLeft+-1*this.layout.delta>-1*this.container.scrollWidth?this.scrollBy(this.layout.delta,0,!0):t=this.views.last().section.next()):this.isPaginated&&"vertical"===this.settings.axis?(this.scrollTop=this.container.scrollTop,this.container.scrollTop+this.container.offsetHeight<this.container.scrollHeight?this.scrollBy(0,this.layout.height,!0):t=this.views.last().section.next()):t=this.views.last().section.next():(this.scrollLeft=this.container.scrollLeft,this.container.scrollLeft+this.container.offsetWidth+this.layout.delta<=this.container.scrollWidth?this.scrollBy(this.layout.delta,0,!0):t=this.views.last().section.next()),t)){this.clear(),this.updateLayout();var i=!1;return"pre-paginated"===this.layout.name&&2===this.layout.divisor&&t.properties.includes("page-spread-right")&&(i=!0),this.append(t,i).then(function(){return this.handleNextPrePaginated(i,t,this.append)}.bind(this),(function(t){return t})).then(function(){this.isPaginated||"horizontal"!==this.settings.axis||"rtl"!==this.settings.direction||"default"!==this.settings.rtlScrollType||this.scrollTo(this.container.scrollWidth,0,!0),this.views.show()}.bind(this))}}},{key:"prev",value:function(){var t,e=this.settings.direction;if(this.views.length&&(!this.isPaginated||"horizontal"!==this.settings.axis||e&&"ltr"!==e?this.isPaginated&&"horizontal"===this.settings.axis&&"rtl"===e?(this.scrollLeft=this.container.scrollLeft,"default"===this.settings.rtlScrollType?this.container.scrollLeft+this.container.offsetWidth<this.container.scrollWidth?this.scrollBy(-this.layout.delta,0,!0):t=this.views.first().section.prev():this.container.scrollLeft<0?this.scrollBy(-this.layout.delta,0,!0):t=this.views.first().section.prev()):this.isPaginated&&"vertical"===this.settings.axis?(this.scrollTop=this.container.scrollTop,this.container.scrollTop>0?this.scrollBy(0,-this.layout.height,!0):t=this.views.first().section.prev()):t=this.views.first().section.prev():(this.scrollLeft=this.container.scrollLeft,this.container.scrollLeft>0?this.scrollBy(-this.layout.delta,0,!0):t=this.views.first().section.prev()),t)){this.clear(),this.updateLayout();var i=!1;return"pre-paginated"===this.layout.name&&2===this.layout.divisor&&"object"!==Gi(t.prev())&&(i=!0),this.prepend(t,i).then(function(){var e;if("pre-paginated"===this.layout.name&&this.layout.divisor>1&&(e=t.prev()))return this.prepend(e)}.bind(this),(function(t){return t})).then(function(){this.isPaginated&&"horizontal"===this.settings.axis&&("rtl"===this.settings.direction?"default"===this.settings.rtlScrollType?this.scrollTo(0,0,!0):this.scrollTo(-1*this.container.scrollWidth+this.layout.delta,0,!0):this.scrollTo(this.container.scrollWidth-this.layout.delta,0,!0)),this.views.show()}.bind(this))}}},{key:"current",value:function(){var t=this.visible();return t.length?t[t.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.updateLayout(),this.isPaginated&&"horizontal"===this.settings.axis?this.location=this.paginatedLocation():this.location=this.scrolledLocation(),this.location}},{key:"scrolledLocation",value:function(){var t=this,e=this.visible(),i=this.container.getBoundingClientRect(),n=i.height<window.innerHeight?i.height:window.innerHeight,s=i.width<window.innerWidth?i.width:window.innerWidth,r="vertical"===this.settings.axis,o=(this.settings.direction,0);return this.settings.fullsize&&(o=r?window.scrollY:window.scrollX),e.map((function(e){var a,h,l,u,c=e.section,d=c.index,f=c.href,p=e.position(),v=e.width(),y=e.height();r?(h=(a=o+i.top-p.top+0)+n-0,u=t.layout.count(y,n).pages,l=n):(h=(a=o+i.left-p.left+0)+s-0,u=t.layout.count(v,s).pages,l=s);var m=Math.ceil(a/l),g=[],b=Math.ceil(h/l);if("rtl"===t.settings.direction&&!r){var w=m;m=u-b,b=u-w}g=[];for(var k=m;k<=b;k++){var x=k+1;g.push(x)}return{index:d,href:f,pages:g,totalPages:u,mapping:t.mapping.page(e.contents,e.section.cfiBase,a,h)}}))}},{key:"paginatedLocation",value:function(){var t=this,e=this.visible(),i=this.container.getBoundingClientRect(),n=0,s=0;return this.settings.fullsize&&(n=window.scrollX),e.map((function(e){var r,o,a,h,l=e.section,u=l.index,c=l.href,d=e.position(),f=e.width();"rtl"===t.settings.direction?(r=i.right-n,h=Math.min(Math.abs(r-d.left),t.layout.width)-s,o=(a=d.width-(d.right-r)-s)-h):(r=i.left+n,h=Math.min(d.right-r,t.layout.width)-s,a=(o=r-d.left+s)+h),s+=h;var p=t.mapping.page(e.contents,e.section.cfiBase,o,a),v=t.layout.count(f).pages,y=Math.floor(o/t.layout.pageWidth),m=[],g=Math.floor(a/t.layout.pageWidth);if(y<0&&(y=0,g+=1),"rtl"===t.settings.direction){var b=y;y=v-g,g=v-b}for(var w=y+1;w<=g;w++){var k=w;m.push(k)}return{index:u,href:c,pages:m,totalPages:v,mapping:p}}))}},{key:"isVisible",value:function(t,e,i,n){var s=t.position(),r=n||this.bounds();return"horizontal"===this.settings.axis&&s.right>r.left-e&&s.left<r.right+i||"vertical"===this.settings.axis&&s.bottom>r.top-e&&s.top<r.bottom+i}},{key:"visible",value:function(){for(var t,e=this.bounds(),i=this.views.displayed(),n=i.length,s=[],r=0;r<n;r++)t=i[r],!0===this.isVisible(t,0,0,e)&&s.push(t);return s}},{key:"scrollBy",value:function(t,e,i){var n="rtl"===this.settings.direction?-1:1;i&&(this.ignore=!0),this.settings.fullsize?window.scrollBy(t*n,e*n):(t&&(this.container.scrollLeft+=t*n),e&&(this.container.scrollTop+=e)),this.scrolled=!0}},{key:"scrollTo",value:function(t,e,i){i&&(this.ignore=!0),this.settings.fullsize?window.scrollTo(t,e):(this.container.scrollLeft=t,this.container.scrollTop=e),this.scrolled=!0}},{key:"onScroll",value:function(){var t,e;this.settings.fullsize?(t=window.scrollY,e=window.scrollX):(t=this.container.scrollTop,e=this.container.scrollLeft),this.scrollTop=t,this.scrollLeft=e,this.ignore?this.ignore=!1:(this.emit(Gt,{top:t,left:e}),clearTimeout(this.afterScrolled),this.afterScrolled=setTimeout(function(){this.emit(Kt,{top:this.scrollTop,left:this.scrollLeft})}.bind(this),20))}},{key:"bounds",value:function(){return this.stage.bounds()}},{key:"applyLayout",value:function(t){this.layout=t,this.updateLayout(),this.views&&this.views.length>0&&"pre-paginated"===this.layout.name&&this.display(this.views.first().section)}},{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.divisor):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(t){this.viewSettings.layout=t,this.mapping=new mi(t.props,this.settings.direction,this.settings.axis),this.views&&this.views.forEach((function(e){e&&e.setLayout(t)}))}},{key:"updateWritingMode",value:function(t){this.writingMode=t}},{key:"updateAxis",value:function(t,e){(e||t!==this.settings.axis)&&(this.settings.axis=t,this.stage&&this.stage.axis(t),this.viewSettings.axis=t,this.mapping&&(this.mapping=new mi(this.layout.props,this.settings.direction,this.settings.axis)),this.layout&&("vertical"===t?this.layout.spread("none"):this.layout.spread(this.layout.settings.spread)))}},{key:"updateFlow",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"auto",i="paginated"===t||"auto"===t;this.isPaginated=i,"scrolled-doc"===t||"scrolled-continuous"===t||"scrolled"===t?this.updateAxis("vertical"):this.updateAxis("horizontal"),this.viewSettings.flow=t,this.settings.overflow?this.overflow=this.settings.overflow:this.overflow=i?"hidden":e,this.stage&&this.stage.overflow(this.overflow),this.updateLayout()}},{key:"getContents",value:function(){var t=[];return this.views?(this.views.forEach((function(e){var i=e&&e.contents;i&&t.push(i)})),t):t}},{key:"direction",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"ltr";this.settings.direction=t,this.stage&&this.stage.direction(t),this.viewSettings.direction=t,this.updateLayout()}},{key:"isRendered",value:function(){return this.rendered}}],e&&Ki(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();r()(en.prototype);var nn=en;function sn(t){return sn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},sn(t)}function rn(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,on(n.key),n)}}function on(t){var e=function(t){if("object"!=sn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=sn(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==sn(e)?e:e+""}i(86765),i(26437),i(52697),i(21359),i(61642);var an=Math.PI/2,hn={easeOutSine:function(t){return Math.sin(t*an)},easeInOutSine:function(t){return-.5*(Math.cos(Math.PI*t)-1)},easeInOutQuint:function(t){return(t/=.5)<1?.5*Math.pow(t,5):.5*(Math.pow(t-2,5)+2)},easeInCubic:function(t){return Math.pow(t,3)}},ln=function(){return t=function t(e,i){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.settings=k({duration:80,minVelocity:.2,minDistance:10,easing:hn.easeInCubic},i||{}),this.supportsTouch=this.supportsTouch(),this.supportsTouch&&this.setup(e)},e=[{key:"setup",value:function(t){this.manager=t,this.layout=this.manager.layout,this.fullsize=this.manager.settings.fullsize,this.fullsize?(this.element=this.manager.stage.element,this.scroller=window,this.disableScroll()):(this.element=this.manager.stage.container,this.scroller=this.element,this.element.style.WebkitOverflowScrolling="touch"),this.manager.settings.offset=this.layout.width,this.manager.settings.afterScrolledTimeout=2*this.settings.duration,this.isVertical="vertical"===this.manager.settings.axis,this.manager.isPaginated&&!this.isVertical&&(this.touchCanceler=!1,this.resizeCanceler=!1,this.snapping=!1,this.scrollLeft,this.scrollTop,this.startTouchX=void 0,this.startTouchY=void 0,this.startTime=void 0,this.endTouchX=void 0,this.endTouchY=void 0,this.endTime=void 0,this.addListeners())}},{key:"supportsTouch",value:function(){return!!("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)}},{key:"disableScroll",value:function(){this.element.style.overflow="hidden"}},{key:"enableScroll",value:function(){this.element.style.overflow=""}},{key:"addListeners",value:function(){this._onResize=this.onResize.bind(this),window.addEventListener("resize",this._onResize),this._onScroll=this.onScroll.bind(this),this.scroller.addEventListener("scroll",this._onScroll),this._onTouchStart=this.onTouchStart.bind(this),this.scroller.addEventListener("touchstart",this._onTouchStart,{passive:!0}),this.on("touchstart",this._onTouchStart),this._onTouchMove=this.onTouchMove.bind(this),this.scroller.addEventListener("touchmove",this._onTouchMove,{passive:!0}),this.on("touchmove",this._onTouchMove),this._onTouchEnd=this.onTouchEnd.bind(this),this.scroller.addEventListener("touchend",this._onTouchEnd,{passive:!0}),this.on("touchend",this._onTouchEnd),this._afterDisplayed=this.afterDisplayed.bind(this),this.manager.on($t,this._afterDisplayed)}},{key:"removeListeners",value:function(){window.removeEventListener("resize",this._onResize),this._onResize=void 0,this.scroller.removeEventListener("scroll",this._onScroll),this._onScroll=void 0,this.scroller.removeEventListener("touchstart",this._onTouchStart,{passive:!0}),this.off("touchstart",this._onTouchStart),this._onTouchStart=void 0,this.scroller.removeEventListener("touchmove",this._onTouchMove,{passive:!0}),this.off("touchmove",this._onTouchMove),this._onTouchMove=void 0,this.scroller.removeEventListener("touchend",this._onTouchEnd,{passive:!0}),this.off("touchend",this._onTouchEnd),this._onTouchEnd=void 0,this.manager.off($t,this._afterDisplayed),this._afterDisplayed=void 0}},{key:"afterDisplayed",value:function(t){var e=this,i=t.contents;["touchstart","touchmove","touchend"].forEach((function(t){i.on(t,(function(t){return e.triggerViewEvent(t,i)}))}))}},{key:"triggerViewEvent",value:function(t,e){this.emit(t.type,t,e)}},{key:"onScroll",value:function(t){this.scrollLeft=this.fullsize?window.scrollX:this.scroller.scrollLeft,this.scrollTop=this.fullsize?window.scrollY:this.scroller.scrollTop}},{key:"onResize",value:function(t){this.resizeCanceler=!0}},{key:"onTouchStart",value:function(t){var e=t.touches[0],i=e.screenX,n=e.screenY;this.fullsize&&this.enableScroll(),this.touchCanceler=!0,this.startTouchX||(this.startTouchX=i,this.startTouchY=n,this.startTime=this.now()),this.endTouchX=i,this.endTouchY=n,this.endTime=this.now()}},{key:"onTouchMove",value:function(t){var e=t.touches[0],i=e.screenX,n=e.screenY,s=Math.abs(n-this.endTouchY);this.touchCanceler=!0,!this.fullsize&&s<10&&(this.element.scrollLeft-=i-this.endTouchX),this.endTouchX=i,this.endTouchY=n,this.endTime=this.now()}},{key:"onTouchEnd",value:function(t){this.fullsize&&this.disableScroll(),this.touchCanceler=!1;var e=this.wasSwiped();0!==e?this.snap(e):this.snap(),this.startTouchX=void 0,this.startTouchY=void 0,this.startTime=void 0,this.endTouchX=void 0,this.endTouchY=void 0,this.endTime=void 0}},{key:"wasSwiped",value:function(){var t=this.layout.pageWidth*this.layout.divisor,e=this.endTouchX-this.startTouchX,i=Math.abs(e),n=e/(this.endTime-this.startTime),s=this.settings.minVelocity;return i<=this.settings.minDistance||i>=t?0:n>s?-1:n<-s?1:void 0}},{key:"needsSnap",value:function(){return this.scrollLeft%(this.layout.pageWidth*this.layout.divisor)!=0}},{key:"snap",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=this.scrollLeft,i=this.layout.pageWidth*this.layout.divisor,n=Math.round(e/i)*i;return t&&(n+=t*i),this.smoothScrollTo(n)}},{key:"smoothScrollTo",value:function(t){var e=new X,i=this.scrollLeft,n=this.now(),s=this.settings.duration,r=this.settings.easing;return this.snapping=!0,function o(){var a=this.now(),h=Math.min(1,(a-n)/s);if(r(h),this.touchCanceler||this.resizeCanceler)return this.resizeCanceler=!1,this.snapping=!1,void e.resolve();h<1?(window.requestAnimationFrame(o.bind(this)),this.scrollTo(i+(t-i)*h,0)):(this.scrollTo(t,0),this.snapping=!1,e.resolve())}.call(this),e.promise}},{key:"scrollTo",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.fullsize?window.scroll(t,e):(this.scroller.scrollLeft=t,this.scroller.scrollTop=e)}},{key:"now",value:function(){return"now"in window.performance?performance.now():(new Date).getTime()}},{key:"destroy",value:function(){this.scroller&&(this.fullsize&&this.enableScroll(),this.removeListeners(),this.scroller=void 0)}}],e&&rn(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();r()(ln.prototype);var un=ln,cn=i(46177),dn=i.n(cn);function fn(t){return fn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},fn(t)}function pn(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,vn(n.key),n)}}function vn(t){var e=function(t){if("object"!=fn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=fn(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==fn(e)?e:e+""}function yn(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(yn=function(){return!!t})()}function mn(t,e,i,n){var s=gn(bn(1&n?t.prototype:t),e,i);return 2&n&&"function"==typeof s?function(t){return s.apply(i,t)}:s}function gn(){return gn="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,i){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=bn(t)););return t}(t,e);if(n){var s=Object.getOwnPropertyDescriptor(n,e);return s.get?s.get.call(arguments.length<3?t:i):s.value}},gn.apply(null,arguments)}function bn(t){return bn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},bn(t)}function wn(t,e){return wn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},wn(t,e)}var kn=function(t){function e(t){var i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(i=function(t,e,i){return e=bn(e),function(t,e){if(e&&("object"==fn(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,yn()?Reflect.construct(e,i||[],bn(t).constructor):e.apply(t,i))}(this,e,[t])).name="continuous",i.settings=k(i.settings||{},{infinite:!0,overflow:void 0,axis:void 0,writingMode:void 0,flow:"scrolled",offset:500,offsetDelta:250,width:void 0,height:void 0,snap:!1,afterScrolledTimeout:10,allowScriptedContent:!1,allowPopups:!1}),k(i.settings,t.settings||{}),"undefined"!=t.settings.gap&&0===t.settings.gap&&(i.settings.gap=t.settings.gap),i.viewSettings={ignoreClass:i.settings.ignoreClass,axis:i.settings.axis,flow:i.settings.flow,layout:i.layout,width:0,height:0,forceEvenPages:!1,allowScriptedContent:i.settings.allowScriptedContent,allowPopups:i.settings.allowPopups},i.scrollTop=0,i.scrollLeft=0,i}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&wn(t,e)}(e,t),i=e,n=[{key:"display",value:function(t,e){return nn.prototype.display.call(this,t,e).then(function(){return this.fill()}.bind(this))}},{key:"fill",value:function(t){var e=this,i=t||new X;return this.q.enqueue((function(){return e.check()})).then((function(t){t?e.fill(i):i.resolve()})),i.promise}},{key:"moveTo",value:function(t){var e=0,i=0;this.isPaginated?(e=Math.floor(t.left/this.layout.delta)*this.layout.delta,this.settings.offsetDelta):(i=t.top,t.top,this.settings.offsetDelta),(e>0||i>0)&&this.scrollBy(e,i,!0)}},{key:"afterResized",value:function(t){this.emit(Jt,t.section)}},{key:"removeShownListeners",value:function(t){t.onDisplayed=function(){}}},{key:"add",value:function(t){var e=this,i=this.createView(t);return this.views.append(i),i.on(re,(function(t){i.expanded=!0})),i.on(ee,(function(t){e.updateAxis(t)})),i.on(ie,(function(t){e.updateWritingMode(t)})),i.onDisplayed=this.afterDisplayed.bind(this),i.onResize=this.afterResized.bind(this),i.display(this.request)}},{key:"append",value:function(t){var e=this,i=this.createView(t);return i.on(re,(function(t){i.expanded=!0})),i.on(ee,(function(t){e.updateAxis(t)})),i.on(ie,(function(t){e.updateWritingMode(t)})),this.views.append(i),i.onDisplayed=this.afterDisplayed.bind(this),i}},{key:"prepend",value:function(t){var e=this,i=this.createView(t);return i.on(re,(function(t){e.counter(t),i.expanded=!0})),i.on(ee,(function(t){e.updateAxis(t)})),i.on(ie,(function(t){e.updateWritingMode(t)})),this.views.prepend(i),i.onDisplayed=this.afterDisplayed.bind(this),i}},{key:"counter",value:function(t){"vertical"===this.settings.axis?this.scrollBy(0,t.heightDelta,!0):this.scrollBy(t.widthDelta,0,!0)}},{key:"update",value:function(t){for(var e,i=this.bounds(),n=this.views.all(),s=n.length,r=[],o=void 0!==t?t:this.settings.offset||0,a=new X,h=[],l=0;l<s;l++)if(e=n[l],!0===this.isVisible(e,o,o,i)){if(e.displayed)e.show();else{var u=e.display(this.request).then((function(t){t.show()}),(function(t){e.hide()}));h.push(u)}r.push(e)}else this.q.enqueue(e.destroy.bind(e)),clearTimeout(this.trimTimeout),this.trimTimeout=setTimeout(function(){this.q.enqueue(this.trim.bind(this))}.bind(this),250);return h.length?Promise.all(h).catch((function(t){a.reject(t)})):(a.resolve(),a.promise)}},{key:"check",value:function(t,e){var i=this,n=new X,s=[],r="horizontal"===this.settings.axis,o=this.settings.offset||0;t&&r&&(o=t),e&&!r&&(o=e);var a=this._bounds,h=r?this.scrollLeft:this.scrollTop,l=r?Math.floor(a.width):a.height,u=r?this.container.scrollWidth:this.container.scrollHeight,c=this.writingMode&&0===this.writingMode.indexOf("vertical")?"vertical":"horizontal",d=this.settings.rtlScrollType,f="rtl"===this.settings.direction;this.settings.fullsize?(r&&f&&"negative"===d||!r&&f&&"default"===d)&&(h*=-1):(f&&"default"===d&&"horizontal"===c&&(h=u-l-h),f&&"negative"===d&&"horizontal"===c&&(h*=-1));var p,v,y,m,g=h-o;h+l+o>=u&&((v=(p=i.views.last())&&p.section.next())&&s.push(i.append(v))),g<0&&((m=(y=i.views.first())&&y.section.prev())&&s.push(i.prepend(m)));var b=s.map((function(t){return t.display(i.request)}));return s.length?Promise.all(b).then((function(){return i.check()})).then((function(){return i.update(o)}),(function(t){return t})):(this.q.enqueue(function(){this.update()}.bind(this)),n.resolve(!1),n.promise)}},{key:"trim",value:function(){for(var t=new X,e=this.views.displayed(),i=e[0],n=e[e.length-1],s=this.views.indexOf(i),r=this.views.indexOf(n),o=this.views.slice(0,s),a=this.views.slice(r+1),h=0;h<o.length-1;h++)this.erase(o[h],o);for(var l=1;l<a.length;l++)this.erase(a[l]);return t.resolve(),t.promise}},{key:"erase",value:function(t,e){var i,n;this.settings.fullsize?(i=window.scrollY,n=window.scrollX):(i=this.container.scrollTop,n=this.container.scrollLeft);var s=t.bounds();this.views.remove(t),e&&("vertical"===this.settings.axis?this.scrollTo(0,i-s.height,!0):"rtl"===this.settings.direction?this.settings.fullsize?this.scrollTo(n+Math.floor(s.width),0,!0):this.scrollTo(n,0,!0):this.scrollTo(n-Math.floor(s.width),0,!0))}},{key:"addEventListeners",value:function(t){window.addEventListener("unload",function(t){this.ignore=!0,this.destroy()}.bind(this)),this.addScrollListeners(),this.isPaginated&&this.settings.snap&&(this.snapper=new un(this,this.settings.snap&&"object"===fn(this.settings.snap)&&this.settings.snap))}},{key:"addScrollListeners",value:function(){var t;this.tick=u;var e="rtl"===this.settings.direction&&"default"===this.settings.rtlScrollType?-1:1;this.scrollDeltaVert=0,this.scrollDeltaHorz=0,this.settings.fullsize?(t=window,this.scrollTop=window.scrollY*e,this.scrollLeft=window.scrollX*e):(t=this.container,this.scrollTop=this.container.scrollTop,this.scrollLeft=this.container.scrollLeft),this._onScroll=this.onScroll.bind(this),t.addEventListener("scroll",this._onScroll),this._scrolled=dn()(this.scrolled.bind(this),30),this.didScroll=!1}},{key:"removeEventListeners",value:function(){(this.settings.fullsize?window:this.container).removeEventListener("scroll",this._onScroll),this._onScroll=void 0}},{key:"onScroll",value:function(){var t,e,i="rtl"===this.settings.direction&&"default"===this.settings.rtlScrollType?-1:1;this.settings.fullsize?(t=window.scrollY*i,e=window.scrollX*i):(t=this.container.scrollTop,e=this.container.scrollLeft),this.scrollTop=t,this.scrollLeft=e,this.ignore?this.ignore=!1:this._scrolled(),this.scrollDeltaVert+=Math.abs(t-this.prevScrollTop),this.scrollDeltaHorz+=Math.abs(e-this.prevScrollLeft),this.prevScrollTop=t,this.prevScrollLeft=e,clearTimeout(this.scrollTimeout),this.scrollTimeout=setTimeout(function(){this.scrollDeltaVert=0,this.scrollDeltaHorz=0}.bind(this),150),clearTimeout(this.afterScrolled),this.didScroll=!1}},{key:"scrolled",value:function(){this.q.enqueue(function(){return this.check()}.bind(this)),this.emit(Gt,{top:this.scrollTop,left:this.scrollLeft}),clearTimeout(this.afterScrolled),this.afterScrolled=setTimeout(function(){this.snapper&&this.snapper.supportsTouch&&this.snapper.needsSnap()||this.emit(Kt,{top:this.scrollTop,left:this.scrollLeft})}.bind(this),this.settings.afterScrolledTimeout)}},{key:"next",value:function(){var t="pre-paginated"===this.layout.props.name&&this.layout.props.spread?2*this.layout.props.delta:this.layout.props.delta;this.views.length&&(this.isPaginated&&"horizontal"===this.settings.axis?this.scrollBy(t,0,!0):this.scrollBy(0,this.layout.height,!0),this.q.enqueue(function(){return this.check()}.bind(this)))}},{key:"prev",value:function(){var t="pre-paginated"===this.layout.props.name&&this.layout.props.spread?2*this.layout.props.delta:this.layout.props.delta;this.views.length&&(this.isPaginated&&"horizontal"===this.settings.axis?this.scrollBy(-t,0,!0):this.scrollBy(0,-this.layout.height,!0),this.q.enqueue(function(){return this.check()}.bind(this)))}},{key:"updateFlow",value:function(t){this.rendered&&this.snapper&&(this.snapper.destroy(),this.snapper=void 0),mn(e,"updateFlow",this,3)([t,"scroll"]),this.rendered&&this.isPaginated&&this.settings.snap&&(this.snapper=new un(this,this.settings.snap&&"object"===fn(this.settings.snap)&&this.settings.snap))}},{key:"destroy",value:function(){mn(e,"destroy",this,3)([]),this.snapper&&this.snapper.destroy()}}],n&&pn(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,n}(nn),xn=kn;function Sn(t){return Sn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Sn(t)}function Tn(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Cn(n.key),n)}}function Cn(t){var e=function(t){if("object"!=Sn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=Sn(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Sn(e)?e:e+""}var En=function(){return t=function t(e,i){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.settings=k(this.settings||{},{width:null,height:null,ignoreClass:"",manager:"default",view:"iframe",flow:null,layout:null,spread:null,minSpreadWidth:800,stylesheet:null,resizeOnOrientationChange:!0,script:null,snap:!1,defaultDirection:"ltr",allowScriptedContent:!1,allowPopups:!1}),k(this.settings,i),"object"===Sn(this.settings.manager)&&(this.manager=this.settings.manager),this.book=e,this.hooks={},this.hooks.display=new gt(this),this.hooks.serialize=new gt(this),this.hooks.content=new gt(this),this.hooks.unloaded=new gt(this),this.hooks.layout=new gt(this),this.hooks.render=new gt(this),this.hooks.show=new gt(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 di(this),this.annotations=new Ri(this),this.epubcfi=new ft,this.q=new At(this),this.location=void 0,this.q.enqueue(this.book.opened),this.starting=new X,this.started=this.starting.promise,this.q.enqueue(this.start)},e=[{key:"setManager",value:function(t){this.manager=t}},{key:"requireManager",value:function(t){return"string"==typeof t&&"default"===t?nn:"string"==typeof t&&"continuous"===t?xn:t}},{key:"requireView",value:function(t){return"string"==typeof t&&"iframe"===t?Mi:t}},{key:"start",value:function(){switch(this.settings.layout||"pre-paginated"!==this.book.package.metadata.layout&&"true"!==this.book.displayOptions.fixedLayout||(this.settings.layout="pre-paginated"),this.book.package.metadata.spread){case"none":this.settings.spread="none";break;case"both":this.settings.spread=!0}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.defaultDirection),this.settings.globalLayoutProperties=this.determineLayoutProperties(this.book.package.metadata),this.flow(this.settings.globalLayoutProperties.flow),this.layout(this.settings.globalLayoutProperties),this.manager.on($t,this.afterDisplayed.bind(this)),this.manager.on(te,this.afterRemoved.bind(this)),this.manager.on(Qt,this.onResized.bind(this)),this.manager.on(Zt,this.onOrientationChange.bind(this)),this.manager.on(Kt,this.reportLocation.bind(this)),this.emit(ue),this.starting.resolve()}},{key:"attachTo",value:function(t){return this.q.enqueue(function(){this.manager.render(t,{width:this.settings.width,height:this.settings.height}),this.emit(ce)}.bind(this))}},{key:"display",value:function(t){return this.displaying&&this.displaying.resolve(),this.q.enqueue(this._display,t)}},{key:"_display",value:function(t){var e=this;if(this.book){this.epubcfi.isCfiString(t);var i,n=new X,s=n.promise;return this.displaying=n,this.book.locations.length()&&g(t)&&(t=this.book.locations.cfiFromPercentage(parseFloat(t))),(i=this.book.spine.get(t))?(this.manager.display(i,t).then((function(){n.resolve(i),e.displaying=void 0,e.emit(de,i),e.reportLocation()}),(function(t){e.emit(fe,t)})),s):(n.reject(new Error("No Section Found")),s)}}},{key:"afterDisplayed",value:function(t){var e=this;t.on(le,(function(i,n){return e.triggerMarkEvent(i,n,t.contents)})),this.hooks.render.trigger(t,this).then((function(){t.contents?e.hooks.content.trigger(t.contents,e).then((function(){e.emit(pe,t.section,t)})):e.emit(pe,t.section,t)}))}},{key:"afterRemoved",value:function(t){var e=this;this.hooks.unloaded.trigger(t,this).then((function(){e.emit(ve,t.section,t)}))}},{key:"onResized",value:function(t,e){this.emit(ye,{width:t.width,height:t.height},e),this.location&&this.location.start&&this.display(e||this.location.start.cfi)}},{key:"onOrientationChange",value:function(t){this.emit(me,t)}},{key:"moveTo",value:function(t){this.manager.moveTo(t)}},{key:"resize",value:function(t,e,i){t&&(this.settings.width=t),e&&(this.settings.height=e),this.manager.resize(t,e,i)}},{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(t){var e=this.settings.layout||t.layout||"reflowable",i=this.settings.spread||t.spread||"auto",n=this.settings.orientation||t.orientation||"auto",s=this.settings.flow||t.flow||"auto",r=t.viewport||"",o=this.settings.minSpreadWidth||t.minSpreadWidth||800,a=this.settings.direction||t.direction||"ltr";return(0===this.settings.width||this.settings.width>0)&&(0===this.settings.height||this.settings.height),{layout:e,spread:i,orientation:n,flow:s,viewport:r,minSpreadWidth:o,direction:a}}},{key:"flow",value:function(t){var e=t;"scrolled"!==t&&"scrolled-doc"!==t&&"scrolled-continuous"!==t||(e="scrolled"),"auto"!==t&&"paginated"!==t||(e="paginated"),this.settings.flow=t,this._layout&&this._layout.flow(e),this.manager&&this._layout&&this.manager.applyLayout(this._layout),this.manager&&this.manager.updateFlow(e),this.manager&&this.manager.isRendered()&&this.location&&(this.manager.clear(),this.display(this.location.start.cfi))}},{key:"layout",value:function(t){var e=this;return t&&(this._layout=new ai(t),this._layout.spread(t.spread,this.settings.minSpreadWidth),this._layout.on(Se,(function(t,i){e.emit(xe,t,i)}))),this.manager&&this._layout&&this.manager.applyLayout(this._layout),this._layout}},{key:"spread",value:function(t,e){this.settings.spread=t,e&&(this.settings.minSpreadWidth=e),this._layout&&this._layout.spread(t,e),this.manager&&this.manager.isRendered()&&this.manager.updateLayout()}},{key:"direction",value:function(t){this.settings.direction=t||"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 t=this.manager.currentLocation();if(t&&t.then&&"function"==typeof t.then)t.then(function(t){var e=this.located(t);e&&e.start&&e.end&&(this.location=e,this.emit(ge,{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(be,this.location))}.bind(this));else if(t){var e=this.located(t);if(!e||!e.start||!e.end)return;this.location=e,this.emit(ge,{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(be,this.location)}}.bind(this))}.bind(this))}},{key:"currentLocation",value:function(){var t=this.manager.currentLocation();if(t&&t.then&&"function"==typeof t.then)t.then(function(t){return this.located(t)}.bind(this));else if(t)return this.located(t)}},{key:"located",value:function(t){if(!t.length)return{};var e=t[0],i=t[t.length-1],n={start:{index:e.index,href:e.href,cfi:e.mapping.start,displayed:{page:e.pages[0]||1,total:e.totalPages}},end:{index:i.index,href:i.href,cfi:i.mapping.end,displayed:{page:i.pages[i.pages.length-1]||1,total:i.totalPages}}},s=this.book.locations.locationFromCfi(e.mapping.start),r=this.book.locations.locationFromCfi(i.mapping.end);null!=s&&(n.start.location=s,n.start.percentage=this.book.locations.percentageFromLocation(s)),null!=r&&(n.end.location=r,n.end.percentage=this.book.locations.percentageFromLocation(r));var o=this.book.pageList.pageFromCfi(e.mapping.start),a=this.book.pageList.pageFromCfi(i.mapping.end);return-1!=o&&(n.start.page=o),-1!=a&&(n.end.page=a),i.index===this.book.spine.last().index&&n.end.displayed.page>=n.end.displayed.total&&(n.atEnd=!0),e.index===this.book.spine.first().index&&1===n.start.displayed.page&&(n.atStart=!0),n}},{key:"destroy",value:function(){this.manager&&this.manager.destroy(),this.book=void 0}},{key:"passEvents",value:function(t){var e=this;Wt.forEach((function(i){t.on(i,(function(i){return e.triggerViewEvent(i,t)}))})),t.on(Ht,(function(i){return e.triggerSelectedEvent(i,t)}))}},{key:"triggerViewEvent",value:function(t,e){this.emit(t.type,t,e)}},{key:"triggerSelectedEvent",value:function(t,e){this.emit(ke,t,e)}},{key:"triggerMarkEvent",value:function(t,e,i){this.emit(we,t,e,i)}},{key:"getRange",value:function(t,e){var i=new ft(t),n=this.manager.visible().filter((function(t){if(i.spinePos===t.index)return!0}));if(n.length)return n[0].contents.range(i,e)}},{key:"adjustImages",value:function(t){if("pre-paginated"===this._layout.name)return new Promise((function(t){t()}));var e=t.window.getComputedStyle(t.content,null),i=.95*(t.content.offsetHeight-(parseFloat(e.paddingTop)+parseFloat(e.paddingBottom))),n=parseFloat(e.paddingLeft)+parseFloat(e.paddingRight);return t.addStylesheetRules({img:{"max-width":(this._layout.columnWidth?this._layout.columnWidth-n+"px":"100%")+"!important","max-height":i+"px!important","object-fit":"contain","page-break-inside":"avoid","break-inside":"avoid","box-sizing":"border-box"},svg:{"max-width":(this._layout.columnWidth?this._layout.columnWidth-n+"px":"100%")+"!important","max-height":i+"px!important","page-break-inside":"avoid","break-inside":"avoid"}}),new Promise((function(t,e){setTimeout((function(){t()}),1)}))}},{key:"getContents",value:function(){return this.manager?this.manager.getContents():[]}},{key:"views",value:function(){return(this.manager?this.manager.views:void 0)||[]}},{key:"handleLinks",value:function(t){var e=this;t&&t.on(Xt,(function(t){var i=e.book.path.relative(t);e.display(i)}))}},{key:"injectStylesheet",value:function(t,e){var i=t.createElement("link");i.setAttribute("type","text/css"),i.setAttribute("rel","stylesheet"),i.setAttribute("href",this.settings.stylesheet),t.getElementsByTagName("head")[0].appendChild(i)}},{key:"injectScript",value:function(t,e){var i=t.createElement("script");i.setAttribute("type","text/javascript"),i.setAttribute("src",this.settings.script),i.textContent=" ",t.getElementsByTagName("head")[0].appendChild(i)}},{key:"injectIdentifier",value:function(t,e){var i=this.book.packaging.metadata.identifier,n=t.createElement("meta");n.setAttribute("name","dc.relation.ispartof"),i&&n.setAttribute("content",i),t.getElementsByTagName("head")[0].appendChild(n)}}],e&&Tn(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();r()(En.prototype);var Pn=En,Ln=i(77256),_n=i.n(Ln);function On(t){return On="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},On(t)}function jn(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,zn(n.key),n)}}function zn(t){var e=function(t){if("object"!=On(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=On(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==On(e)?e:e+""}var Rn=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.zip=void 0,this.urlCache={},this.checkRequirements()},e=[{key:"checkRequirements",value:function(){try{this.zip=new(_n())}catch(t){throw new Error("JSZip lib not loaded")}}},{key:"open",value:function(t,e){return this.zip.loadAsync(t,{base64:e})}},{key:"openUrl",value:function(t,e){return St(t,"binary").then(function(t){return this.zip.loadAsync(t,{base64:e})}.bind(this))}},{key:"request",value:function(t,e){var i,n=new X,s=new st(t);return e||(e=s.extension),(i="blob"==e?this.getBlob(t):this.getText(t))?i.then(function(t){var i=this.handleResponse(t,e);n.resolve(i)}.bind(this)):n.reject({message:"File not found in the epub: "+t,stack:(new Error).stack}),n.promise}},{key:"handleResponse",value:function(t,e){return"json"==e?JSON.parse(t):z(e)?A(t,"text/xml"):"xhtml"==e?A(t,"application/xhtml+xml"):"html"==e||"htm"==e?A(t,"text/html"):t}},{key:"getBlob",value:function(t,e){var i=window.decodeURIComponent(t.substr(1)),n=this.zip.file(i);if(n)return e=e||Ye(n.name),n.async("uint8array").then((function(t){return new Blob([t],{type:e})}))}},{key:"getText",value:function(t,e){var i=window.decodeURIComponent(t.substr(1)),n=this.zip.file(i);if(n)return n.async("string").then((function(t){return t}))}},{key:"getBase64",value:function(t,e){var i=window.decodeURIComponent(t.substr(1)),n=this.zip.file(i);if(n)return e=e||Ye(n.name),n.async("base64").then((function(t){return"data:"+e+";base64,"+t}))}},{key:"createUrl",value:function(t,e){var i,n,s=new X,r=window.URL||window.webkitURL||window.mozURL,o=e&&e.base64;return t in this.urlCache?(s.resolve(this.urlCache[t]),s.promise):(o?(n=this.getBase64(t))&&n.then(function(e){this.urlCache[t]=e,s.resolve(e)}.bind(this)):(n=this.getBlob(t))&&n.then(function(e){i=r.createObjectURL(e),this.urlCache[t]=i,s.resolve(i)}.bind(this)),n||s.reject({message:"File not found in the epub: "+t,stack:(new Error).stack}),s.promise)}},{key:"revokeUrl",value:function(t){var e=window.URL||window.webkitURL||window.mozURL,i=this.urlCache[t];i&&e.revokeObjectURL(i)}},{key:"destroy",value:function(){var t=window.URL||window.webkitURL||window.mozURL;for(var e in this.urlCache)t.revokeObjectURL(e);this.zip=void 0,this.urlCache={}}}],e&&jn(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),Nn=Rn,Bn=i(47914),qn=i.n(Bn);function In(t){return In="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},In(t)}function An(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Mn(n.key),n)}}function Mn(t){var e=function(t){if("object"!=In(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=In(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==In(e)?e:e+""}var Wn=function(){return t=function t(e,i,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.urlCache={},this.storage=void 0,this.name=e,this.requester=i||St,this.resolver=n,this.online=!0,this.checkRequirements(),this.addListeners()},e=[{key:"checkRequirements",value:function(){try{var t;void 0===qn()&&(t=qn()),this.storage=t.createInstance({name:this.name})}catch(t){throw new Error("localForage lib not loaded")}}},{key:"addListeners",value:function(){this._status=this.status.bind(this),window.addEventListener("online",this._status),window.addEventListener("offline",this._status)}},{key:"removeListeners",value:function(){window.removeEventListener("online",this._status),window.removeEventListener("offline",this._status),this._status=void 0}},{key:"status",value:function(t){var e=navigator.onLine;this.online=e,e?this.emit("online",this):this.emit("offline",this)}},{key:"add",value:function(t,e){var i=this,n=t.resources.map((function(t){var n=t.href,s=i.resolver(n),r=window.encodeURIComponent(s);return i.storage.getItem(r).then((function(t){return!t||e?i.requester(s,"binary").then((function(t){return i.storage.setItem(r,t)})):t}))}));return Promise.all(n)}},{key:"put",value:function(t,e,i){var n=this,s=window.encodeURIComponent(t);return this.storage.getItem(s).then((function(r){return r||n.requester(t,"binary",e,i).then((function(t){return n.storage.setItem(s,t)}))}))}},{key:"request",value:function(t,e,i,n){var s=this;return this.online?this.requester(t,e,i,n).then((function(e){return s.put(t),e})):this.retrieve(t,e)}},{key:"retrieve",value:function(t,e){var i=this,n=(new X,new st(t));return e||(e=n.extension),("blob"==e?this.getBlob(t):this.getText(t)).then((function(n){var s,r=new X;return n?(s=i.handleResponse(n,e),r.resolve(s)):r.reject({message:"File not found in storage: "+t,stack:(new Error).stack}),r.promise}))}},{key:"handleResponse",value:function(t,e){return"json"==e?JSON.parse(t):z(e)?A(t,"text/xml"):"xhtml"==e?A(t,"application/xhtml+xml"):"html"==e||"htm"==e?A(t,"text/html"):t}},{key:"getBlob",value:function(t,e){var i=window.encodeURIComponent(t);return this.storage.getItem(i).then((function(i){if(i)return e=e||Ye(t),new Blob([i],{type:e})}))}},{key:"getText",value:function(t,e){var i=window.encodeURIComponent(t);return e=e||Ye(t),this.storage.getItem(i).then((function(t){var i,n=new X,s=new FileReader;if(t)return i=new Blob([t],{type:e}),s.addEventListener("loadend",(function(){n.resolve(s.result)})),s.readAsText(i,e),n.promise}))}},{key:"getBase64",value:function(t,e){var i=window.encodeURIComponent(t);return e=e||Ye(t),this.storage.getItem(i).then((function(t){var i,n=new X,s=new FileReader;if(t)return i=new Blob([t],{type:e}),s.addEventListener("loadend",(function(){n.resolve(s.result)})),s.readAsDataURL(i,e),n.promise}))}},{key:"createUrl",value:function(t,e){var i,n,s=new X,r=window.URL||window.webkitURL||window.mozURL,o=e&&e.base64;return t in this.urlCache?(s.resolve(this.urlCache[t]),s.promise):(o?(n=this.getBase64(t))&&n.then(function(e){this.urlCache[t]=e,s.resolve(e)}.bind(this)):(n=this.getBlob(t))&&n.then(function(e){i=r.createObjectURL(e),this.urlCache[t]=i,s.resolve(i)}.bind(this)),n||s.reject({message:"File not found in storage: "+t,stack:(new Error).stack}),s.promise)}},{key:"revokeUrl",value:function(t){var e=window.URL||window.webkitURL||window.mozURL,i=this.urlCache[t];i&&e.revokeObjectURL(i)}},{key:"destroy",value:function(){var t=window.URL||window.webkitURL||window.mozURL;for(var e in this.urlCache)t.revokeObjectURL(e);this.urlCache={},this.removeListeners()}}],e&&An(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();r()(Wn.prototype);var Fn=Wn;function Un(t){return Un="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Un(t)}function Dn(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Hn(n.key),n)}}function Hn(t){var e=function(t){if("object"!=Un(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=Un(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Un(e)?e:e+""}var Vn=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.interactive="",this.fixedLayout="",this.openToSpread="",this.orientationLock="",e&&this.parse(e)},(e=[{key:"parse",value:function(t){var e=this;if(!t)return this;var i=M(t,"display_options");return i?(W(i,"option").forEach((function(t){var i="";switch(t.childNodes.length&&(i=t.childNodes[0].nodeValue),t.attributes.name.value){case"interactive":e.interactive=i;break;case"fixed-layout":e.fixedLayout=i;break;case"open-to-spread":e.openToSpread=i;break;case"orientation-lock":e.orientationLock=i}})),this):this}},{key:"destroy",value:function(){this.interactive=void 0,this.fixedLayout=void 0,this.openToSpread=void 0,this.orientationLock=void 0}}])&&Dn(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function Xn(t){return Xn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xn(t)}function Yn(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Jn(n.key),n)}}function Jn(t){var e=function(t){if("object"!=Xn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=Xn(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Xn(e)?e:e+""}var Qn="META-INF/container.xml",Zn="binary",$n="base64",Gn="epub",Kn="json",ts=function(){return t=function t(e,i){var n=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),void 0===i&&"string"!=typeof e&&e instanceof Blob==0&&e instanceof ArrayBuffer==0&&(i=e,e=void 0),this.settings=k(this.settings||{},{requestMethod:void 0,requestCredentials:void 0,requestHeaders:void 0,encoding:void 0,replacements:void 0,canonical:void 0,openAs:void 0,store:void 0}),k(this.settings,i),this.opening=new X,this.opened=this.opening.promise,this.isOpen=!1,this.loading={manifest:new X,spine:new X,metadata:new X,cover:new X,navigation:new X,pageList:new X,resources:new X,displayOptions:new X},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,displayOptions:this.loading.displayOptions.promise},this.ready=Promise.all([this.loaded.manifest,this.loaded.spine,this.loaded.metadata,this.loaded.cover,this.loaded.navigation,this.loaded.resources,this.loaded.displayOptions]),this.isRendered=!1,this.request=this.settings.requestMethod||St,this.spine=new Rt,this.locations=new Oe(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.storage=void 0,this.resources=void 0,this.rendition=void 0,this.container=void 0,this.packaging=void 0,this.displayOptions=void 0,this.settings.store&&this.store(this.settings.store),e&&this.open(e,this.settings.openAs).catch((function(t){var i=new Error("Cannot load book at "+e);n.emit(Ft,i)}))},e=[{key:"open",value:function(t,e){var i,n=e||this.determineType(t);return n===Zn?(this.archived=!0,this.url=new ht("/",""),i=this.openEpub(t)):n===$n?(this.archived=!0,this.url=new ht("/",""),i=this.openEpub(t,n)):n===Gn?(this.archived=!0,this.url=new ht("/",""),i=this.request(t,"binary",this.settings.requestCredentials,this.settings.requestHeaders).then(this.openEpub.bind(this))):"opf"==n?(this.url=new ht(t),i=this.openPackaging(this.url.Path.toString())):n==Kn?(this.url=new ht(t),i=this.openManifest(this.url.Path.toString())):(this.url=new ht(t),i=this.openContainer(Qn).then(this.openPackaging.bind(this))),i}},{key:"openEpub",value:function(t,e){var i=this;return this.unarchive(t,e||this.settings.encoding).then((function(){return i.openContainer(Qn)})).then((function(t){return i.openPackaging(t)}))}},{key:"openContainer",value:function(t){var e=this;return this.load(t).then((function(t){return e.container=new Ne(t),e.resolve(e.container.packagePath)}))}},{key:"openPackaging",value:function(t){var e=this;return this.path=new st(t),this.load(t).then((function(t){return e.packaging=new Me(t),e.unpack(e.packaging)}))}},{key:"openManifest",value:function(t){var e=this;return this.path=new st(t),this.load(t).then((function(t){return e.packaging=new Me,e.packaging.load(t),e.unpack(e.packaging)}))}},{key:"load",value:function(t){var e=this.resolve(t);return this.archived?this.archive.request(e):this.request(e,null,this.settings.requestCredentials,this.settings.requestHeaders)}},{key:"resolve",value:function(t,e){if(t){var i=t;return t.indexOf("://")>-1?t:(this.path&&(i=this.path.resolve(t)),0!=e&&this.url&&(i=this.url.resolve(i)),i)}}},{key:"canonical",value:function(t){return t?this.settings.canonical?this.settings.canonical(t):this.resolve(t,!0):""}},{key:"determineType",value:function(t){var e;return"base64"===this.settings.encoding?$n:"string"!=typeof t?Zn:((e=new ht(t).path().extension)&&(e=e.replace(/\?.*$/,"")),e?"epub"===e?Gn:"opf"===e?"opf":"json"===e?Kn:void 0:"directory")}},{key:"unpack",value:function(t){var e=this;this.package=t,""===this.packaging.metadata.layout?this.load(this.url.resolve("META-INF/com.apple.ibooks.display-options.xml")).then((function(t){e.displayOptions=new Vn(t),e.loading.displayOptions.resolve(e.displayOptions)})).catch((function(t){e.displayOptions=new Vn,e.loading.displayOptions.resolve(e.displayOptions)})):(this.displayOptions=new Vn,this.loading.displayOptions.resolve(this.displayOptions)),this.spine.unpack(this.packaging,this.resolve.bind(this),this.canonical.bind(this)),this.resources=new Ge(this.packaging.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.packaging).then((function(){e.loading.navigation.resolve(e.navigation)})),this.packaging.coverPath&&(this.cover=this.resolve(this.packaging.coverPath)),this.loading.manifest.resolve(this.packaging.manifest),this.loading.metadata.resolve(this.packaging.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&&"none"!=this.settings.replacements?this.replacements().then((function(){e.loaded.displayOptions.then((function(){e.opening.resolve(e)}))})).catch((function(t){console.error(t)})):this.loaded.displayOptions.then((function(){e.opening.resolve(e)}))}},{key:"loadNavigation",value:function(t){var e=this,i=t.navPath||t.ncxPath,n=t.toc;return n?new Promise((function(i,s){e.navigation=new He(n),t.pageList&&(e.pageList=new ii(t.pageList)),i(e.navigation)})):i?this.load(i,"xml").then((function(t){return e.navigation=new He(t),e.pageList=new ii(t),e.navigation})):new Promise((function(t,i){e.navigation=new He,e.pageList=new ii,t(e.navigation)}))}},{key:"section",value:function(t){return this.spine.get(t)}},{key:"renderTo",value:function(t,e){return this.rendition=new Pn(this,e),this.rendition.attachTo(t),this.rendition}},{key:"setRequestCredentials",value:function(t){this.settings.requestCredentials=t}},{key:"setRequestHeaders",value:function(t){this.settings.requestHeaders=t}},{key:"unarchive",value:function(t,e){return this.archive=new Nn,this.archive.open(t,e)}},{key:"store",value:function(t){var e=this,i=this.settings.replacements&&"none"!==this.settings.replacements,n=this.url,s=this.settings.requestMethod||St.bind(this);return this.storage=new Fn(t,s,this.resolve.bind(this)),this.request=this.storage.request.bind(this.storage),this.opened.then((function(){e.archived&&(e.storage.requester=e.archive.request.bind(e.archive));var t=function(t,i){i.output=e.resources.substitute(t,i.url)};e.resources.settings.replacements=i||"blobUrl",e.resources.replacements().then((function(){return e.resources.replaceCss()})),e.storage.on("offline",(function(){e.url=new ht("/",""),e.spine.hooks.serialize.register(t)})),e.storage.on("online",(function(){e.url=n,e.spine.hooks.serialize.deregister(t)}))})),this.storage}},{key:"coverUrl",value:function(){var t=this;return this.loaded.cover.then((function(){return t.cover?t.archived?t.archive.createUrl(t.cover):t.cover:null}))}},{key:"replacements",value:function(){var t=this;return this.spine.hooks.serialize.register((function(e,i){i.output=t.resources.substitute(e,i.url)})),this.resources.replacements().then((function(){return t.resources.replaceCss()}))}},{key:"getRange",value:function(t){var e=new ft(t),i=this.spine.get(e.spinePos),n=this.load.bind(this);return i?i.load(n).then((function(t){return e.toRange(i.document)})):new Promise((function(t,e){e("CFI could not be found")}))}},{key:"key",value:function(t){var e=t||this.packaging.metadata.identifier||this.url.filename;return"epubjs:".concat(Mt,":").concat(e)}},{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.displayOptions&&this.displayOptions.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}}],e&&Yn(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();r()(ts.prototype);var es=ts;function is(t,e){return new es(t,e)}is.VERSION=Mt,void 0!==i.g&&(i.g.EPUBJS_VERSION=Mt),is.Book=es,is.Rendition=Pn,is.Contents=Ci,is.CFI=ft,is.utils=n;var ns=is}}]);