(function(se,C){typeof exports=="object"&&typeof module=="object"?module.exports=C(require("xmldom"),function(){try{return require("jszip")}catch(m){}}()):typeof define=="function"&&define.amd?define(["xmldom","jszip"],C):typeof exports=="object"?exports.ePub=C(require("xmldom"),function(){try{return require("jszip")}catch(m){}}()):se.ePub=C(se.xmldom,se.jszip)})(this,function(oe,se){return function(C){var y={};function m(S){if(y[S])return y[S].exports;var w=y[S]={i:S,l:!1,exports:{}};return C[S].call(w.exports,w,w.exports,m),w.l=!0,w.exports}return m.m=C,m.c=y,m.d=function(S,w,R){m.o(S,w)||Object.defineProperty(S,w,{configurable:!1,enumerable:!0,get:R})},m.n=function(S){var w=S&&S.__esModule?function(){return S.default}:function(){return S};return m.d(w,"a",w),w},m.o=function(S,w){return Object.prototype.hasOwnProperty.call(S,w)},m.p="/dist/",m(m.s=25)}([function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function O(I,M){for(var q=0;qre)return 1;if(ne=0?ee:ee+1:ie===0?ee:ie===-1?c(O,I,M,ee,$):c(O,I,M,Z,ee))}function a(O,I,M,q,W){var Z=q||0,$=W||I.length,ee=parseInt(Z+($-Z)/2),ie;return M||(M=function(ne,re){if(ne>re)return 1;if(ne-1}function B(O,I){return new Blob([O],{type:I})}function D(O,I){var M,q=B(O,I);return M=h.createObjectURL(q),M}function V(O){return h.revokeObjectURL(O)}function N(O,I){var M,q;if(typeof O=="string")return M=btoa(encodeURIComponent(O)),q="data:"+I+";base64,"+M,q}function z(O){return Object.prototype.toString.call(O).slice(8,-1)}function _(O,I,M){var q,W;return typeof DOMParser=="undefined"||M?W=m(16).DOMParser:W=DOMParser,O.charCodeAt(0)===65279&&(O=O.slice(1)),q=new W().parseFromString(O,I),q}function P(O,I){var M;if(!O)throw new Error("No Element Provided");if(typeof O.querySelector!="undefined")return O.querySelector(I);if(M=O.getElementsByTagName(I),M.length)return M[0]}function x(O,I){return typeof O.querySelector!="undefined"?O.querySelectorAll(I):O.getElementsByTagName(I)}function F(O,I,M){var q,W;if(typeof O.querySelector!="undefined"){I+="[";for(var Z in M)I+=Z+"~='"+M[Z]+"'";return I+="]",O.querySelector(I)}else if(q=O.getElementsByTagName(I),W=Array.prototype.slice.call(q,0).filter(function($){for(var ee in M)if($.getAttribute(ee)===M[ee])return!0;return!1}),W)return W[0]}function G(O,I){var M=O.ownerDocument||O;typeof M.createTreeWalker!="undefined"?X(O,I,NodeFilter.SHOW_TEXT):J(O,function(q){q&&q.nodeType===3&&I(q)},!0)}function X(O,I,M){for(var q=document.createTreeWalker(O,M,null,!1),W=void 0;W=q.nextNode();)I(W)}function J(O,I){if(I(O))return!0;if(O=O.firstChild,O)do{var M=J(O,I);if(M)return!0;O=O.nextSibling}while(O)}function K(O){return new Promise(function(I,M){var q=new FileReader;q.readAsDataURL(O),q.onloadend=function(){I(q.result)}})}function H(){var O=this;this.resolve=null,this.reject=null,this.id=f(),this.promise=new Promise(function(I,M){O.resolve=I,O.reject=M}),Object.freeze(this)}function U(O,I,M){var q;if(typeof O.querySelector!="undefined"&&(q=O.querySelector(I+'[*|type="'+M+'"]')),!q||q.length===0){q=x(O,I);for(var W=0;W1&&(s=t[1],r.terminal=this.parseTerminal(s)),i[0]===""&&i.shift(),r.steps=i.map(function(u){return this.parseStep(u)}.bind(this)),r}},{key:"parseStep",value:function(e){var r,t,i,s,u;if(s=e.match(/\[(.*)\]/),s&&s[1]&&(u=s[1]),t=parseInt(e),!isNaN(t))return t%2==0?(r="element",i=t/2-1):(r="text",i=(t-1)/2),{type:r,index:i,id:u||null}}},{key:"parseTerminal",value:function(e){var r,t,i=e.match(/\[(.*)\]/);return i&&i[1]?(r=parseInt(e.split("[")[0]),t=i[1]):r=parseInt(e),(0,R.isNumber)(r)||(r=null),{offset:r,assertion:t}}},{key:"getChapterComponent",value:function(e){var r=e.split("!");return r[0]}},{key:"getPathComponent",value:function(e){var r=e.split("!");if(r[1]){var t=r[1].split(",");return t[0]}}},{key:"getRange",value:function(e){var r=e.split(",");return r.length===3?[r[1],r[2]]:!1}},{key:"getCharecterOffsetComponent",value:function(e){var r=e.split(":");return r[1]||""}},{key:"joinSteps",value:function(e){return e?e.map(function(r){var t="";return r.type==="element"&&(t+=(r.index+1)*2),r.type==="text"&&(t+=1+2*r.index),r.id&&(t+="["+r.id+"]"),t}).join("/"):""}},{key:"segmentString",value:function(e){var r="/";return r+=this.joinSteps(e.steps),e.terminal&&e.terminal.offset!=null&&(r+=":"+e.terminal.offset),e.terminal&&e.terminal.assertion!=null&&(r+="["+e.terminal.assertion+"]"),r}},{key:"toString",value:function(){var e="epubcfi(";return e+=this.segmentString(this.base),e+="!",e+=this.segmentString(this.path),this.range&&this.start&&(e+=",",e+=this.segmentString(this.start)),this.range&&this.end&&(e+=",",e+=this.segmentString(this.end)),e+=")",e}},{key:"compare",value:function(e,r){var t,i,s,u,c,a,o,o,v,p,b,E;if(typeof e=="string"&&(e=new n(e)),typeof r=="string"&&(r=new n(r)),e.spinePos>r.spinePos)return 1;if(e.spinePosi[L].index)return 1;if(t[L].indexu.offset?1:s.offset=0&&(i.terminal.offset=r,i.steps[i.steps.length-1].type!="text"&&i.steps.push({type:"text",index:0})),i}},{key:"equalStep",value:function(e,r){return!e||!r?!1:e.index===r.index&&e.id===r.id&&e.type===r.type}},{key:"fromRange",value:function(e,r,t){var i={range:!1,base:{},path:{},start:null,end:null},s=e.startContainer,u=e.endContainer,c=e.startOffset,a=e.endOffset,o=!1;if(t&&(o=s.ownerDocument.querySelector("."+t)!=null),typeof r=="string"?(i.base=this.parseComponent(r),i.spinePos=i.base.steps[1].index):(typeof r=="undefined"?"undefined":S(r))==="object"&&(i.base=r),e.collapsed)o&&(c=this.patchOffset(s,c,t)),i.path=this.pathTo(s,c,t);else{i.range=!0,o&&(c=this.patchOffset(s,c,t)),i.start=this.pathTo(s,c,t),o&&(a=this.patchOffset(u,a,t)),i.end=this.pathTo(u,a,t),i.path={steps:[],terminal:null};var v=i.start.steps.length,p;for(p=0;p0&&a===g&&o===g?i[u]=s:r===a&&(s=s+1,i[u]=s),o=a;return i}},{key:"position",value:function(e){var r,t;return e.nodeType===k?(r=e.parentNode.children,r||(r=(0,R.findChildren)(e.parentNode)),t=Array.prototype.indexOf.call(r,e)):(r=this.textNodes(e.parentNode),t=r.indexOf(e)),t}},{key:"filteredPosition",value:function(e,r){var t,i,s;return e.nodeType===k?(t=e.parentNode.children,s=this.normalizedMap(t,k,r)):(t=e.parentNode.childNodes,e.parentNode.classList.contains(r)&&(e=e.parentNode,t=e.parentNode.childNodes),s=this.normalizedMap(t,g,r)),i=Array.prototype.indexOf.call(t,e),s[i]}},{key:"stepsToXpath",value:function(e){var r=[".","*"];return e.forEach(function(t){var i=t.index+1;t.id?r.push("*[position()="+i+" and @id='"+t.id+"']"):t.type==="text"?r.push("text()["+i+"]"):r.push("*["+i+"]")}),r.join("/")}},{key:"stepsToQuerySelector",value:function(e){var r=["html"];return e.forEach(function(t){var i=t.index+1;t.id?r.push("#"+t.id):t.type==="text"||r.push("*:nth-child("+i+")")}),r.join(">")}},{key:"textNodes",value:function(e,r){return Array.prototype.slice.call(e.childNodes).filter(function(t){return t.nodeType===g?!0:!!(r&&t.classList.contains(r))})}},{key:"walkToNode",value:function(e,r,t){var i=r||document,s=i.documentElement,u,c,a=e.length,o;for(o=0;oo)r=r-o;else{a.nodeType===k?s=a.childNodes[0]:s=a;break}}return{container:s,offset:r}}},{key:"toRange",value:function(e,r){var t=e||document,i,s,u,c,a,o=this,v,p,b=r?t.querySelector("."+r)!=null:!1,E;if(typeof t.createRange!="undefined"?i=t.createRange():i=new R.RangeObject,o.range?(s=o.start,v=o.path.steps.concat(s.steps),c=this.findNode(v,t,b?r:null),u=o.end,p=o.path.steps.concat(u.steps),a=this.findNode(p,t,b?r:null)):(s=o.path,v=o.path.steps,c=this.findNode(o.path.steps,t,b?r:null)),c)try{s.terminal.offset!=null?i.setStart(c,s.terminal.offset):i.setStart(c,0)}catch(L){E=this.fixMiss(v,s.terminal.offset,t,b?r:null),i.setStart(E.container,E.offset)}else return console.log("No startContainer found for",this.toString()),null;if(a)try{u.terminal.offset!=null?i.setEnd(a,u.terminal.offset):i.setEnd(a,0)}catch(L){E=this.fixMiss(p,o.end.terminal.offset,t,b?r:null),i.setEnd(E.container,E.offset)}return i}},{key:"isCfiString",value:function(e){return typeof e=="string"&&e.indexOf("epubcfi(")===0&&e[e.length-1]===")"}},{key:"generateChapterComponent",value:function(e,r,t){var i=parseInt(r),s=(e+1)*2,u="/"+s+"/";return u+=(i+1)*2,t&&(u+="["+t+"]"),u}},{key:"collapse",value:function(e){!this.range||(this.range=!1,e?(this.path.steps=this.path.steps.concat(this.start.steps),this.path.terminal=this.start.terminal):(this.path.steps=this.path.steps.concat(this.end.steps),this.path.terminal=this.end.terminal))}}]),n}();y.default=f,C.exports=y.default},function(C,y,m){"use strict";var S=m(27),w=m(41),R=Function.prototype.apply,T=Function.prototype.call,k=Object.create,g=Object.defineProperty,d=Object.defineProperties,h=Object.prototype.hasOwnProperty,f={configurable:!0,enumerable:!1,writable:!0},n,l,e,r,t,i,s;n=function(u,c){var a;return w(c),h.call(this,"__ee__")?a=this.__ee__:(a=f.value=k(null),g(this,"__ee__",f),f.value=null),a[u]?typeof a[u]=="object"?a[u].push(c):a[u]=[a[u],c]:a[u]=c,this},l=function(u,c){var a,o;return w(c),o=this,n.call(this,u,a=function(){e.call(o,u,a),R.call(c,this,arguments)}),a.__eeOnceListener__=c,this},e=function(u,c){var a,o,v,p;if(w(c),!h.call(this,"__ee__"))return this;if(a=this.__ee__,!a[u])return this;if(o=a[u],typeof o=="object")for(p=0;v=o[p];++p)(v===c||v.__eeOnceListener__===c)&&(o.length===2?a[u]=o[p?0:1]:o.splice(p,1));else(o===c||o.__eeOnceListener__===c)&&delete a[u];return this},r=function(u){var c,a,o,v,p;if(!!h.call(this,"__ee__")&&(v=this.__ee__[u],!!v))if(typeof v=="object"){for(a=arguments.length,p=new Array(a-1),c=1;c-1&&(h=new URL(h).pathname),n=this.parse(h),this.path=h,this.isDirectory(h)?this.directory=h:this.directory=n.dir+"/",this.filename=n.base,this.extension=n.ext.slice(1)}return S(d,[{key:"parse",value:function(f){return R.default.parse(f)}},{key:"isAbsolute",value:function(f){return R.default.isAbsolute(f||this.path)}},{key:"isDirectory",value:function(f){return f.charAt(f.length-1)==="/"}},{key:"resolve",value:function(f){return R.default.resolve(this.directory,f)}},{key:"relative",value:function(f){return R.default.relative(this.directory,f)}},{key:"splitPath",value:function(f){return this.splitPathRe.exec(f).slice(1)}},{key:"toString",value:function(){return this.path}}]),d}();y.default=g,C.exports=y.default},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function f(n,l){for(var e=0;e-1,r=n,t;if(this.Url=void 0,this.href=n,this.protocol="",this.origin="",this.hash="",this.hash="",this.search="",this.base=l,!e&&l!==!1&&typeof l!="string"&&window&&window.location&&(this.base=window.location.href),e||this.base)try{this.base?this.Url=new URL(n,this.base):this.Url=new URL(n),this.href=this.Url.href,this.protocol=this.Url.protocol,this.origin=this.Url.origin,this.hash=this.Url.hash,this.search=this.Url.search,r=this.Url.pathname}catch(i){this.Url=void 0,this.base&&(t=new R.default(this.base),r=t.resolve(r))}this.Path=new R.default(r),this.directory=this.Path.directory,this.filename=this.Path.filename,this.extension=this.Path.extension}return S(f,[{key:"path",value:function(){return this.Path}},{key:"resolve",value:function(l){var e=l.indexOf("://")>-1,r;return e?l:(r=k.default.resolve(this.directory,l),this.origin+r)}},{key:"relative",value:function(l){return k.default.relative(l,this.directory)}},{key:"toString",value:function(){return this.href}}]),f}();y.default=h,C.exports=y.default},function(C,y,m){"use strict";if(!S)var S={cwd:function(){return"/"}};function w(g){if(typeof g!="string")throw new TypeError("Path must be a string. Received "+g)}function R(g,d){for(var h="",f=-1,n=0,l,e=0;e<=g.length;++e){if(e2){for(var r=h.length-1,t=r;t>=0&&h.charCodeAt(t)!==47;--t);if(t!==r){t===-1?h="":h=h.slice(0,t),f=e,n=0;continue}}else if(h.length===2||h.length===1){h="",f=e,n=0;continue}}d&&(h.length>0?h+="/..":h="..")}else h.length>0?h+="/"+g.slice(f+1,e):h=g.slice(f+1,e);f=e,n=0}else l===46&&n!==-1?++n:n=-1}return h}function T(g,d){var h=d.dir||d.root,f=d.base||(d.name||"")+(d.ext||"");return h?h===d.root?h+f:h+g+f:f}var k={resolve:function(){for(var d="",h=!1,f,n=arguments.length-1;n>=-1&&!h;n--){var l;n>=0?l=arguments[n]:(f===void 0&&(f=S.cwd()),l=f),w(l),l.length!==0&&(d=l+"/"+d,h=l.charCodeAt(0)===47)}return d=R(d,!h),h?d.length>0?"/"+d:"/":d.length>0?d:"."},normalize:function(d){if(w(d),d.length===0)return".";var h=d.charCodeAt(0)===47,f=d.charCodeAt(d.length-1)===47;return d=R(d,!h),d.length===0&&!h&&(d="."),d.length>0&&f&&(d+="/"),h?"/"+d:d},isAbsolute:function(d){return w(d),d.length>0&&d.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var d,h=0;h0&&(d===void 0?d=f:d+="/"+f)}return d===void 0?".":k.normalize(d)},relative:function(d,h){if(w(d),w(h),d===h||(d=k.resolve(d),h=k.resolve(h),d===h))return"";for(var f=1;fi){if(h.charCodeAt(e+u)===47)return h.slice(e+u+1);if(u===0)return h.slice(e+u)}else l>i&&(d.charCodeAt(f+u)===47?s=u:u===0&&(s=0));break}var c=d.charCodeAt(f+u),a=h.charCodeAt(e+u);if(c!==a)break;c===47&&(s=u)}var o="";for(u=f+s+1;u<=n;++u)(u===n||d.charCodeAt(u)===47)&&(o.length===0?o+="..":o+="/..");return o.length>0?o+h.slice(e+s):(e+=s,h.charCodeAt(e)===47&&++e,h.slice(e))},_makeLong:function(d){return d},dirname:function(d){if(w(d),d.length===0)return".";for(var h=d.charCodeAt(0),f=h===47,n=-1,l=!0,e=d.length-1;e>=1;--e)if(h=d.charCodeAt(e),h===47){if(!l){n=e;break}}else l=!1;return n===-1?f?"/":".":f&&n===1?"//":d.slice(0,n)},basename:function(d,h){if(h!==void 0&&typeof h!="string")throw new TypeError('"ext" argument must be a string');w(d);var f=0,n=-1,l=!0,e;if(h!==void 0&&h.length>0&&h.length<=d.length){if(h.length===d.length&&h===d)return"";var r=h.length-1,t=-1;for(e=d.length-1;e>=0;--e){var i=d.charCodeAt(e);if(i===47){if(!l){f=e+1;break}}else t===-1&&(l=!1,t=e+1),r>=0&&(i===h.charCodeAt(r)?--r==-1&&(n=e):(r=-1,n=t))}return f===n?n=t:n===-1&&(n=d.length),d.slice(f,n)}else{for(e=d.length-1;e>=0;--e)if(d.charCodeAt(e)===47){if(!l){f=e+1;break}}else n===-1&&(l=!1,n=e+1);return n===-1?"":d.slice(f,n)}},extname:function(d){w(d);for(var h=-1,f=0,n=-1,l=!0,e=0,r=d.length-1;r>=0;--r){var t=d.charCodeAt(r);if(t===47){if(!l){f=r+1;break}continue}n===-1&&(l=!1,n=r+1),t===46?h===-1?h=r:e!==1&&(e=1):h!==-1&&(e=-1)}return h===-1||n===-1||e===0||e===1&&h===n-1&&h===f+1?"":d.slice(h,n)},format:function(d){if(d===null||typeof d!="object")throw new TypeError('Parameter "pathObject" must be an object, not '+typeof d);return T("/",d)},parse:function(d){w(d);var h={root:"",dir:"",base:"",ext:"",name:""};if(d.length===0)return h;var f=d.charCodeAt(0),n=f===47,l;n?(h.root="/",l=1):l=0;for(var e=-1,r=0,t=-1,i=!0,s=d.length-1,u=0;s>=l;--s){if(f=d.charCodeAt(s),f===47){if(!i){r=s+1;break}continue}t===-1&&(i=!1,t=s+1),f===46?e===-1?e=s:u!==1&&(u=1):e!==-1&&(u=-1)}return e===-1||t===-1||u===0||u===1&&e===t-1&&e===r+1?t!==-1&&(r===0&&n?h.base=h.name=d.slice(1,t):h.base=h.name=d.slice(r,t)):(r===0&&n?(h.name=d.slice(1,e),h.base=d.slice(1,t)):(h.name=d.slice(r,e),h.base=d.slice(r,t)),h.ext=d.slice(e,t)),r>0?h.dir=d.slice(0,r-1):n&&(h.dir="/"),h},sep:"/",delimiter:":",posix:null};C.exports=k},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0}),y.replaceBase=d,y.replaceCanonical=h,y.replaceMeta=f,y.replaceLinks=n,y.substitute=l;var S=m(0),w=m(5),R=g(w),T=m(4),k=g(T);function g(e){return e&&e.__esModule?e:{default:e}}function d(e,r){var t,i,s=r.url,u=s.indexOf("://")>-1;!e||(i=(0,S.qs)(e,"head"),t=(0,S.qs)(i,"base"),t||(t=e.createElement("base"),i.insertBefore(t,i.firstChild)),!u&&window&&window.location&&(s=window.location.origin+s),t.setAttribute("href",s))}function h(e,r){var t,i,s=r.canonical;!e||(t=(0,S.qs)(e,"head"),i=(0,S.qs)(t,"link[rel='canonical']"),i?i.setAttribute("href",s):(i=e.createElement("link"),i.setAttribute("rel","canonical"),i.setAttribute("href",s),t.appendChild(i)))}function f(e,r){var t,i,s=r.idref;!e||(t=(0,S.qs)(e,"head"),i=(0,S.qs)(t,"link[property='dc.identifier']"),i?i.setAttribute("content",s):(i=e.createElement("meta"),i.setAttribute("name","dc.identifier"),i.setAttribute("content",s),t.appendChild(i)))}function n(e,r){var t=e.querySelectorAll("a[href]");if(!!t.length)for(var i=(0,S.qs)(e.ownerDocument,"base"),s=i?i.getAttribute("href"):void 0,u=function(a){var o=a.getAttribute("href");if(o.indexOf("mailto:")!==0){var v=o.indexOf("://")>-1,p=new R.default(o,s);v?a.setAttribute("target","_blank"):a.onclick=function(){return p&&p.hash?r(p.Path.path+p.hash):r(p?p.Path.path:o),!1}}}.bind(this),c=0;c0?(A.setStart(L,E.startOffset-2),A.setEnd(L,E.startOffset),p=A.getBoundingClientRect()):p=L.parentNode.getBoundingClientRect()}catch(V){console.error(V,V.stack)}}else p=E.getBoundingClientRect()}else if(typeof o=="string"&&o.indexOf("#")>-1){var B=o.substring(o.indexOf("#")+1),D=this.document.getElementById(B);D&&(p=D.getBoundingClientRect())}return p&&(b.left=p.left,b.top=p.top),b}},{key:"addStylesheet",value:function(o){return new Promise(function(v,p){var b,E=!1;if(!this.document){v(!1);return}if(b=this.document.querySelector("link[href='"+o+"']"),b){v(!0);return}b=this.document.createElement("link"),b.type="text/css",b.rel="stylesheet",b.href=o,b.onload=b.onreadystatechange=function(){!E&&(!this.readyState||this.readyState=="complete")&&(E=!0,setTimeout(function(){v(!0)},1))},this.document.head.appendChild(b)}.bind(this))}},{key:"addStylesheetRules",value:function(o){var v,p,b="epubjs-inserted-css";if(!(!this.document||!o||o.length===0))if(v=this.document.getElementById("#"+b),v||(v=this.document.createElement("style"),v.id=b),this.document.head.appendChild(v),p=v.sheet,Object.prototype.toString.call(o)==="[object Array]")for(var E=0,L=o.length;E0&&(v=o.getRangeAt(0),v.collapsed||(p=new g.default(v,this.cfiBase).toString(),this.emit(n.EVENTS.CONTENTS.SELECTED,p),this.emit(n.EVENTS.CONTENTS.SELECTED_RANGE,v)))}},{key:"range",value:function(o,v){var p=new g.default(o);return p.toRange(this.document,v)}},{key:"cfiFromRange",value:function(o,v){return new g.default(o,this.cfiBase,v).toString()}},{key:"cfiFromNode",value:function(o,v){return new g.default(o,this.cfiBase,v).toString()}},{key:"map",value:function(o){var v=new h.default(o);return v.section()}},{key:"size",value:function(o,v){var p={scale:1,scalable:"no"};this.layoutStyle("scrolling"),o>=0&&(this.width(o),p.width=o,this.css("padding","0 "+o/12+"px",!0)),v>=0&&(this.height(v),p.height=v),this.css("margin","0"),this.css("box-sizing","border-box"),this.viewport(p)}},{key:"columns",value:function(o,v,p,b){var E=(0,T.prefixed)("column-axis"),L=(0,T.prefixed)("column-gap"),A=(0,T.prefixed)("column-width"),B=(0,T.prefixed)("column-fill"),D=this.writingMode(),V=D.indexOf("vertical")===0?"vertical":"horizontal";this.layoutStyle("paginated"),this.content.dir==="rtl"&&this.direction("rtl"),this.width(o),this.height(v),this.viewport({width:o,height:v,scale:1,scalable:"no"}),this.css("overflow-y","hidden"),this.css("margin","0",!0),V==="vertical"?this.css("padding",b/2+"px 20px",!0):this.css("padding","20px "+b/2+"px",!0),this.css("box-sizing","border-box"),this.css("max-width","inherit"),this.css(E,"horizontal"),this.css(B,"auto"),this.css(L,b+"px"),this.css(A,p+"px")}},{key:"scaler",value:function(o,v,p){var b="scale("+o+")",E="";this.css("transform-origin","top left"),(v>=0||p>=0)&&(E=" translate("+(v||0)+"px, "+(p||0)+"px )"),this.css("transform",b+E)}},{key:"fit",value:function(o,v){var p=this.viewport(),b=o/parseInt(p.width),E=v/parseInt(p.height),L=b1&&(B=a.next(),B))return this.add(B)}.bind(this)).then(function(){this.views.show(),v.resolve()}.bind(this)),p}},{key:"afterDisplayed",value:function(a){this.emit(r.EVENTS.MANAGERS.ADDED,a)}},{key:"afterResized",value:function(a){this.emit(r.EVENTS.MANAGERS.RESIZE,a.section)}},{key:"moveTo",value:function(a){var o=0,v=0;this.isPaginated?(o=Math.floor(a.left/this.layout.delta)*this.layout.delta,o+this.layout.delta>this.container.scrollWidth&&(o=this.container.scrollWidth-this.layout.delta)):v=a.top,this.scrollTo(o,v,!0)}},{key:"add",value:function(a){var o=this,v=this.createView(a);return this.views.append(v),v.onDisplayed=this.afterDisplayed.bind(this),v.onResize=this.afterResized.bind(this),v.on(r.EVENTS.VIEWS.AXIS,function(p){o.updateAxis(p)}),v.display(this.request)}},{key:"append",value:function(a){var o=this,v=this.createView(a);return this.views.append(v),v.onDisplayed=this.afterDisplayed.bind(this),v.onResize=this.afterResized.bind(this),v.on(r.EVENTS.VIEWS.AXIS,function(p){o.updateAxis(p)}),v.display(this.request)}},{key:"prepend",value:function(a){var o=this,v=this.createView(a);return v.on(r.EVENTS.VIEWS.RESIZED,function(p){o.counter(p)}),this.views.prepend(v),v.onDisplayed=this.afterDisplayed.bind(this),v.onResize=this.afterResized.bind(this),v.on(r.EVENTS.VIEWS.AXIS,function(p){o.updateAxis(p)}),v.display(this.request)}},{key:"counter",value:function(a){this.settings.axis==="vertical"?this.scrollBy(0,a.heightDelta,!0):this.scrollBy(a.widthDelta,0,!0)}},{key:"next",value:function(){var a,o,v=this.settings.direction;if(!!this.views.length){if(this.isPaginated&&this.settings.axis==="horizontal"&&(!v||v==="ltr"))this.scrollLeft=this.container.scrollLeft,o=this.container.scrollLeft+this.container.offsetWidth+this.layout.delta,o<=this.container.scrollWidth?this.scrollBy(this.layout.delta,0,!0):a=this.views.last().section.next();else if(this.isPaginated&&this.settings.axis==="horizontal"&&v==="rtl")this.scrollLeft=this.container.scrollLeft,o=this.container.scrollLeft,o>0?this.scrollBy(this.layout.delta,0,!0):a=this.views.last().section.next();else if(this.isPaginated&&this.settings.axis==="vertical"){this.scrollTop=this.container.scrollTop;var p=this.container.scrollTop+this.container.offsetHeight;p1&&(b=a.next(),b))return this.append(b)}.bind(this),function(b){displaying.reject(b)}).then(function(){this.views.show()}.bind(this))}}},{key:"prev",value:function(){var a,o,v=this.settings.direction;if(!!this.views.length){if(this.isPaginated&&this.settings.axis==="horizontal"&&(!v||v==="ltr"))this.scrollLeft=this.container.scrollLeft,o=this.container.scrollLeft,o>0?this.scrollBy(-this.layout.delta,0,!0):a=this.views.first().section.prev();else if(this.isPaginated&&this.settings.axis==="horizontal"&&v==="rtl")this.scrollLeft=this.container.scrollLeft,o=this.container.scrollLeft+this.container.offsetWidth+this.layout.delta,o<=this.container.scrollWidth?this.scrollBy(-this.layout.delta,0,!0):a=this.views.first().section.prev();else if(this.isPaginated&&this.settings.axis==="vertical"){this.scrollTop=this.container.scrollTop;var p=this.container.scrollTop;p>0?this.scrollBy(0,-this.layout.height,!0):a=this.views.first().section.prev()}else a=this.views.first().section.prev();if(a)return this.clear(),this.prepend(a).then(function(){var b;if(this.layout.name==="pre-paginated"&&this.layout.divisor>1&&(b=a.prev(),b))return this.prepend(b)}.bind(this),function(b){displaying.reject(b)}).then(function(){this.isPaginated&&this.settings.axis==="horizontal"&&(this.settings.direction==="rtl"?this.scrollTo(0,0,!0):this.scrollTo(this.container.scrollWidth-this.layout.delta,0,!0)),this.views.show()}.bind(this))}}},{key:"current",value:function(){var a=this.visible();return a.length?a[a.length-1]:null}},{key:"clear",value:function(){this.views&&(this.views.hide(),this.scrollTo(0,0,!0),this.views.clear())}},{key:"currentLocation",value:function(){return this.settings.axis==="vertical"?this.location=this.scrolledLocation():this.location=this.paginatedLocation(),this.location}},{key:"scrolledLocation",value:function(){var a=this,o=this.visible(),v=this.container.getBoundingClientRect(),p=v.heightz&&(P=z,E=P-_);var x=a.layout.count(z,p).pages,F=Math.ceil(_/p),G=[],X=Math.ceil(P/p);G=[];for(var J=F;J<=X;J++){var K=J+1;G.push(K)}var H=a.mapping.page(A.contents,A.section.cfiBase,_,P);return{index:D,href:V,pages:G,totalPages:x,mapping:H}});return L}},{key:"paginatedLocation",value:function(){var a=this,o=this.visible(),v=this.container.getBoundingClientRect(),p=0,b=0;this.fullsize&&(p=window.scrollX);var E=o.map(function(L){var A=L.section,B=A.index,D=A.href,V=L.offset().left,N=L.position().left,z=L.width(),_=p+v.left-N+b,P=_+a.layout.width-b,x=a.mapping.page(L.contents,L.section.cfiBase,_,P),F=a.layout.count(z).pages,G=Math.floor(_/a.layout.pageWidth),X=[],J=Math.floor(P/a.layout.pageWidth);if(G<0&&(G=0,J=J+1),a.settings.direction==="rtl"){var K=G;G=F-J,J=F-K}for(var H=G+1;H<=J;H++){var U=H;X.push(U)}return{index:B,href:D,pages:X,totalPages:F,mapping:x}});return E}},{key:"isVisible",value:function(a,o,v,p){var b=a.position(),E=p||this.bounds();return this.settings.axis==="horizontal"&&b.right>E.left-o&&b.leftE.top-o&&b.top0&&arguments[0]!==void 0?arguments[0]:"ltr";this.settings.direction=a,this.stage&&this.stage.direction(a),this.viewSettings.direction=a,this.updateLayout()}},{key:"isRendered",value:function(){return this.rendered}}]),u}();(0,R.default)(s.prototype),y.default=s,C.exports=y.default},function(C,y){function m(S){var w=typeof S;return S!=null&&(w=="object"||w=="function")}C.exports=m},function(C,y){C.exports=oe},function(C,y,m){"use strict";var S={application:{ecmascript:["es","ecma"],javascript:"js",ogg:"ogx",pdf:"pdf",postscript:["ps","ai","eps","epsi","epsf","eps2","eps3"],"rdf+xml":"rdf",smil:["smi","smil"],"xhtml+xml":["xhtml","xht"],xml:["xml","xsl","xsd","opf","ncx"],zip:"zip","x-httpd-eruby":"rhtml","x-latex":"latex","x-maker":["frm","maker","frame","fm","fb","book","fbdoc"],"x-object":"o","x-shockwave-flash":["swf","swfl"],"x-silverlight":"scr","epub+zip":"epub","font-tdpfr":"pfr","inkml+xml":["ink","inkml"],json:"json","jsonml+json":"jsonml","mathml+xml":"mathml","metalink+xml":"metalink",mp4:"mp4s","omdoc+xml":"omdoc",oxps:"oxps","vnd.amazon.ebook":"azw",widget:"wgt","x-dtbook+xml":"dtb","x-dtbresource+xml":"res","x-font-bdf":"bdf","x-font-ghostscript":"gsf","x-font-linux-psf":"psf","x-font-otf":"otf","x-font-pcf":"pcf","x-font-snf":"snf","x-font-ttf":["ttf","ttc"],"x-font-type1":["pfa","pfb","pfm","afm"],"x-font-woff":"woff","x-mobipocket-ebook":["prc","mobi"],"x-mspublisher":"pub","x-nzb":"nzb","x-tgif":"obj","xaml+xml":"xaml","xml-dtd":"dtd","xproc+xml":"xpl","xslt+xml":"xslt","internet-property-stream":"acx","x-compress":"z","x-compressed":"tgz","x-gzip":"gz"},audio:{flac:"flac",midi:["mid","midi","kar","rmi"],mpeg:["mpga","mpega","mp2","mp3","m4a","mp2a","m2a","m3a"],mpegurl:"m3u",ogg:["oga","ogg","spx"],"x-aiff":["aif","aiff","aifc"],"x-ms-wma":"wma","x-wav":"wav",adpcm:"adp",mp4:"mp4a",webm:"weba","x-aac":"aac","x-caf":"caf","x-matroska":"mka","x-pn-realaudio-plugin":"rmp",xm:"xm",mid:["mid","rmi"]},image:{gif:"gif",ief:"ief",jpeg:["jpeg","jpg","jpe"],pcx:"pcx",png:"png","svg+xml":["svg","svgz"],tiff:["tiff","tif"],"x-icon":"ico",bmp:"bmp",webp:"webp","x-pict":["pic","pct"],"x-tga":"tga","cis-cod":"cod"},text:{"cache-manifest":["manifest","appcache"],css:"css",csv:"csv",html:["html","htm","shtml","stm"],mathml:"mml",plain:["txt","text","brf","conf","def","list","log","in","bas"],richtext:"rtx","tab-separated-values":"tsv","x-bibtex":"bib"},video:{mpeg:["mpeg","mpg","mpe","m1v","m2v","mp2","mpa","mpv2"],mp4:["mp4","mp4v","mpg4"],quicktime:["qt","mov"],ogg:"ogv","vnd.mpegurl":["mxu","m4u"],"x-flv":"flv","x-la-asf":["lsf","lsx"],"x-mng":"mng","x-ms-asf":["asf","asx","asr"],"x-ms-wm":"wm","x-ms-wmv":"wmv","x-ms-wmx":"wmx","x-ms-wvx":"wvx","x-msvideo":"avi","x-sgi-movie":"movie","x-matroska":["mpv","mkv","mk3d","mks"],"3gpp2":"3g2",h261:"h261",h263:"h263",h264:"h264",jpeg:"jpgv",jpm:["jpm","jpgm"],mj2:["mj2","mjp2"],"vnd.ms-playready.media.pyv":"pyv","vnd.uvvu.mp4":["uvu","uvvu"],"vnd.vivo":"viv",webm:"webm","x-f4v":"f4v","x-m4v":"m4v","x-ms-vob":"vob","x-smv":"smv"}},w=function(){var k,g,d,h,f={};for(k in S)if(S.hasOwnProperty(k)){for(g in S[k])if(S[k].hasOwnProperty(g))if(d=S[k][g],typeof d=="string")f[d]=k+"/"+g;else for(h=0;h0)&&(this.settings.height===0||this.settings.height>0),P={layout:x,spread:F,orientation:G,flow:X,viewport:J,minSpreadWidth:K,direction:H},P}},{key:"flow",value:function(_){var P=_;(_==="scrolled"||_==="scrolled-doc"||_==="scrolled-continuous")&&(P="scrolled"),(_==="auto"||_==="paginated")&&(P="paginated"),this.settings.flow=_,this._layout&&this._layout.flow(P),this.manager&&this._layout&&this.manager.applyLayout(this._layout),this.manager&&this.manager.updateFlow(P),this.manager&&this.manager.isRendered()&&this.location&&(this.manager.clear(),this.display(this.location.start.cfi))}},{key:"layout",value:function(_){var P=this;return _&&(this._layout=new r.default(_),this._layout.spread(_.spread,this.settings.minSpreadWidth),this._layout.on(o.EVENTS.LAYOUT.UPDATED,function(x,F){P.emit(o.EVENTS.RENDITION.LAYOUT,x,F)})),this.manager&&this._layout&&this.manager.applyLayout(this._layout),this._layout}},{key:"spread",value:function(_,P){this._layout.spread(_,P),this.manager.isRendered()&&this.manager.updateLayout()}},{key:"direction",value:function(_){this.settings.direction=_||"ltr",this.manager&&this.manager.direction(this.settings.direction),this.manager&&this.manager.isRendered()&&this.location&&(this.manager.clear(),this.display(this.location.start.cfi))}},{key:"reportLocation",value:function(){return this.q.enqueue(function(){requestAnimationFrame(function(){var x=this.manager.currentLocation();if(x&&x.then&&typeof x.then=="function")x.then(function(G){var X=this.located(G);!X||!X.start||!X.end||(this.location=X,this.emit(o.EVENTS.RENDITION.LOCATION_CHANGED,{index:this.location.start.index,href:this.location.start.href,start:this.location.start.cfi,end:this.location.end.cfi,percentage:this.location.start.percentage}),this.emit(o.EVENTS.RENDITION.RELOCATED,this.location))}.bind(this));else if(x){var F=this.located(x);if(!F||!F.start||!F.end)return;this.location=F,this.emit(o.EVENTS.RENDITION.LOCATION_CHANGED,{index:this.location.start.index,href:this.location.start.href,start:this.location.start.cfi,end:this.location.end.cfi,percentage:this.location.start.percentage}),this.emit(o.EVENTS.RENDITION.RELOCATED,this.location)}}.bind(this))}.bind(this))}},{key:"currentLocation",value:function(){var _=this.manager.currentLocation();if(_&&_.then&&typeof _.then=="function")_.then(function(x){var F=this.located(x);return F}.bind(this));else if(_){var P=this.located(_);return P}}},{key:"located",value:function(_){if(!_.length)return{};var P=_[0],x=_[_.length-1],F={start:{index:P.index,href:P.href,cfi:P.mapping.start,displayed:{page:P.pages[0]||1,total:P.totalPages}},end:{index:x.index,href:x.href,cfi:x.mapping.end,displayed:{page:x.pages[x.pages.length-1]||1,total:x.totalPages}}},G=this.book.locations.locationFromCfi(P.mapping.start),X=this.book.locations.locationFromCfi(x.mapping.end);G!=null&&(F.start.location=G,F.start.percentage=this.book.locations.percentageFromLocation(G)),X!=null&&(F.end.location=X,F.end.percentage=this.book.locations.percentageFromLocation(X));var J=this.book.pageList.pageFromCfi(P.mapping.start),K=this.book.pageList.pageFromCfi(x.mapping.end);return J!=-1&&(F.start.page=J),K!=-1&&(F.end.page=K),x.index===this.book.spine.last().index&&F.end.displayed.page>=F.end.displayed.total&&(F.atEnd=!0),P.index===this.book.spine.first().index&&F.start.displayed.page===1&&(F.atStart=!0),F}},{key:"destroy",value:function(){this.manager&&this.manager.destroy(),this.book=void 0}},{key:"passEvents",value:function(_){var P=this,x=u.default.listenedEvents;x.forEach(function(F){_.on(F,function(G){return P.triggerViewEvent(G,_)})}),_.on(o.EVENTS.CONTENTS.SELECTED,function(F){return P.triggerSelectedEvent(F,_)})}},{key:"triggerViewEvent",value:function(_,P){this.emit(_.type,_,P)}},{key:"triggerSelectedEvent",value:function(_,P){this.emit(o.EVENTS.RENDITION.SELECTED,_,P)}},{key:"triggerMarkEvent",value:function(_,P,x){this.emit(o.EVENTS.RENDITION.MARK_CLICKED,_,P,x)}},{key:"getRange",value:function(_,P){var x=new f.default(_),F=this.manager.visible().filter(function(G){if(x.spinePos===G.index)return!0});if(F.length)return F[0].contents.range(x,P)}},{key:"adjustImages",value:function(_){return this._layout.name==="pre-paginated"?new Promise(function(P){P()}):(_.addStylesheetRules({img:{"max-width":(this._layout.columnWidth?this._layout.columnWidth+"px":"100%")+"!important","max-height":(this._layout.height?this._layout.height*.6+"px":"60%")+"!important","object-fit":"contain","page-break-inside":"avoid"},svg:{"max-width":(this._layout.columnWidth?this._layout.columnWidth+"px":"100%")+"!important","max-height":(this._layout.height?this._layout.height*.6+"px":"60%")+"!important","page-break-inside":"avoid"}}),new Promise(function(P,x){setTimeout(function(){P()},1)}))}},{key:"getContents",value:function(){return this.manager?this.manager.getContents():[]}},{key:"views",value:function(){var _=this.manager?this.manager.views:void 0;return _||[]}},{key:"handleLinks",value:function(_){var P=this;_&&_.on(o.EVENTS.CONTENTS.LINK_CLICKED,function(x){var F=P.book.path.relative(x);P.display(F)})}},{key:"injectStylesheet",value:function(_,P){var x=_.createElement("link");x.setAttribute("type","text/css"),x.setAttribute("rel","stylesheet"),x.setAttribute("href",this.settings.stylesheet),_.getElementsByTagName("head")[0].appendChild(x)}},{key:"injectScript",value:function(_,P){var x=_.createElement("script");x.setAttribute("type","text/javascript"),x.setAttribute("src",this.settings.script),x.textContent=" ",_.getElementsByTagName("head")[0].appendChild(x)}},{key:"injectIdentifier",value:function(_,P){var x=this.book.package.metadata.identifier,F=_.createElement("meta");F.setAttribute("name","dc.relation.ispartof"),x&&F.setAttribute("content",x),_.getElementsByTagName("head")[0].appendChild(F)}}]),N}();(0,T.default)(V.prototype),y.default=V,C.exports=y.default},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function d(h,f){for(var n=0;n0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}},e=l.acceptNode;e.acceptNode=l.acceptNode;for(var r=document.createTreeWalker(f,NodeFilter.SHOW_TEXT,e,!1),t,i;(t=r.nextNode())&&(i=n(t),!i););return i}}},{key:"findRanges",value:function(f){for(var n=[],l=f.contents.scrollWidth(),e=Math.ceil(l/this.layout.spreadWidth),r=e*this.layout.divisor,t=this.layout.columnWidth,i=this.layout.gap,s,u,c=0;c=n&&c<=l)return u;if(a>n)return u;s=u,r.push(u)}else if(e.horizontal&&e.direction==="rtl"){if(c=p.left,a=p.right,a<=l&&a>=n)return u;if(c=n&&o<=l)return u;if(v>n)return u;s=u,r.push(u)}}),i)return this.findTextStartRange(i,n,l);return this.findTextStartRange(s,n,l)}},{key:"findEnd",value:function(f,n,l){for(var e=this,r=[f],t,i=f,s;r.length;)if(t=r.shift(),s=this.walk(t,function(u){var c,a,o,v,p,b;if(p=e.getBounds(u),e.horizontal&&e.direction==="ltr"){if(c=Math.round(p.left),a=Math.round(p.right),c>l&&i)return i;if(a>l)return u;i=u,r.push(u)}else if(e.horizontal&&e.direction==="rtl"){if(c=Math.round(e.horizontal?p.left:p.top),a=Math.round(e.horizontal?p.right:p.bottom),al&&i)return i;if(v>l)return u;i=u,r.push(u)}}),s)return this.findTextEndRange(s,n,l);return this.findTextEndRange(i,n,l)}},{key:"findTextStartRange",value:function(f,n,l){for(var e=this.splitTextNodeIntoRanges(f),r,t,i,s,u,c=0;c=n)return r}else if(this.horizontal&&this.direction==="rtl"){if(u=t.right,u<=l)return r}else if(s=t.top,s>=n)return r;return e[0]}},{key:"findTextEndRange",value:function(f,n,l){for(var e=this.splitTextNodeIntoRanges(f),r,t,i,s,u,c,a,o=0;ol&&r)return r;if(u>l)return t}else if(this.horizontal&&this.direction==="rtl"){if(s=i.left,u=i.right,ul&&r)return r;if(a>l)return t}r=t}return e[e.length-1]}},{key:"splitTextNodeIntoRanges",value:function(f,n){var l=[],e=f.textContent||"",r=e.trim(),t,i=f.ownerDocument,s=n||" ",u=r.indexOf(s);if(u===-1||f.nodeType!=Node.TEXT_NODE)return t=i.createRange(),t.selectNodeContents(f),[t];for(t=i.createRange(),t.setStart(f,0),t.setEnd(f,u),l.push(t),t=!1;u!=-1;)u=r.indexOf(s,u+1),u>0&&(t&&(t.setEnd(f,u),l.push(t)),t=i.createRange(),t.setStart(f,u+1));return t&&(t.setEnd(f,r.length),l.push(t)),l}},{key:"rangePairToCfiPair",value:function(f,n){var l=n.start,e=n.end;l.collapse(!0),e.collapse(!1);var r=new R.default(l,f).toString(),t=new R.default(e,f).toString();return{start:r,end:t}}},{key:"rangeListToCfiList",value:function(f,n){for(var l=[],e,r=0;r0&&(u=Math.ceil(u/this.layout.pageWidth)*this.layout.pageWidth),this.settings.forceEvenPages&&(a=u/this.layout.delta,this.layout.divisor>1&&this.layout.name==="reflowable"&&a%2>0&&(u+=this.layout.gap+this.layout.columnWidth))):this.settings.axis==="vertical"&&(c=this.contents.textHeight()),(this._needsReframe||u!=this._width||c!=this._height)&&this.reframe(u,c),this._expanding=!1)}},{key:"reframe",value:function(s,u){var c;(0,T.isNumber)(s)&&(this.element.style.width=s+"px",this.iframe.style.width=s+"px",this._width=s),(0,T.isNumber)(u)&&(this.element.style.height=u+"px",this.iframe.style.height=u+"px",this._height=u);var a=this.prevBounds?s-this.prevBounds.width:s,o=this.prevBounds?u-this.prevBounds.height:u;c={width:s,height:u,widthDelta:a,heightDelta:o},this.pane&&this.pane.render(),this.onResize(this,c),this.emit(f.EVENTS.VIEWS.RESIZED,c),this.prevBounds=c,this.elementBounds=(0,T.bounds)(this.element)}},{key:"load",value:function(s){var u=new T.defer,c=u.promise;if(!this.iframe)return u.reject(new Error("No Iframe Available")),c;if(this.iframe.onload=function(a){this.onLoad(a,u)}.bind(this),this.settings.method==="blobUrl")this.blobUrl=(0,T.createBlobUrl)(s,"application/xhtml+xml"),this.iframe.src=this.blobUrl;else if(this.settings.method==="srcdoc")this.iframe.srcdoc=s;else{if(this.document=this.iframe.contentDocument,!this.document)return u.reject(new Error("No Document Available")),c;this.iframe.contentDocument.open(),this.iframe.contentDocument.write(s),this.iframe.contentDocument.close()}return c}},{key:"onLoad",value:function(s,u){var c=this;this.window=this.iframe.contentWindow,this.document=this.iframe.contentDocument,this.contents=new h.default(this.document,this.document.body,this.section.cfiBase,this.section.index),this.rendering=!1;var a=this.document.querySelector("link[rel='canonical']");a?a.setAttribute("href",this.section.canonical):(a=this.document.createElement("link"),a.setAttribute("rel","canonical"),a.setAttribute("href",this.section.canonical),this.document.querySelector("head").appendChild(a)),this.contents.on(f.EVENTS.CONTENTS.EXPAND,function(){c.displayed&&c.iframe&&(c.expand(),c.contents&&c.layout.format(c.contents))}),this.contents.on(f.EVENTS.CONTENTS.RESIZE,function(o){c.displayed&&c.iframe&&(c.expand(),c.contents&&c.layout.format(c.contents))}),u.resolve(this.contents)}},{key:"setLayout",value:function(s){this.layout=s,this.contents&&(this.layout.format(this.contents),this.expand())}},{key:"setAxis",value:function(s){this.layout.props.flow==="scrolled"&&(s="vertical"),this.settings.axis=s,s=="horizontal"?this.element.style.flex="none":this.element.style.flex="initial",this.size()}},{key:"addListeners",value:function(){}},{key:"removeListeners",value:function(s){}},{key:"display",value:function(s){var u=new T.defer;return this.displayed?u.resolve(this):this.render(s).then(function(){this.emit(f.EVENTS.VIEWS.DISPLAYED,this),this.onDisplayed(this),this.displayed=!0,u.resolve(this)}.bind(this),function(c){u.reject(c,this)}),u.promise}},{key:"show",value:function(){this.element.style.visibility="visible",this.iframe&&(this.iframe.style.visibility="visible"),this.emit(f.EVENTS.VIEWS.SHOWN,this)}},{key:"hide",value:function(){this.element.style.visibility="hidden",this.iframe.style.visibility="hidden",this.stopExpanding=!0,this.emit(f.EVENTS.VIEWS.HIDDEN,this)}},{key:"offset",value:function(){return{top:this.element.offsetTop,left:this.element.offsetLeft}}},{key:"width",value:function(){return this._width}},{key:"height",value:function(){return this._height}},{key:"position",value:function(){return this.element.getBoundingClientRect()}},{key:"locationOf",value:function(s){var u=this.iframe.getBoundingClientRect(),c=this.contents.locationOf(s,this.settings.ignoreClass);return{left:c.left,top:c.top}}},{key:"onDisplayed",value:function(s){}},{key:"onResize",value:function(s,u){}},{key:"bounds",value:function(s){return(s||!this.elementBounds)&&(this.elementBounds=(0,T.bounds)(this.element)),this.elementBounds}},{key:"highlight",value:function(s){var u=this,c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=arguments[2];if(!!this.contents){var o=this.contents.range(s),v=function(){u.emit(f.EVENTS.VIEWS.MARK_CLICKED,s,c)};c.epubcfi=s,this.pane||(this.pane=new n.Pane(this.iframe,this.element));var p=new n.Highlight(o,"epubjs-hl",c,{fill:"yellow","fill-opacity":"0.3","mix-blend-mode":"multiply"}),b=this.pane.addMark(p);return this.highlights[s]={mark:b,element:b.element,listeners:[v,a]},b.element.setAttribute("ref","epubjs-hl"),b.element.addEventListener("click",v),b.element.addEventListener("touchstart",v),a&&(b.element.addEventListener("click",a),b.element.addEventListener("touchstart",a)),b}}},{key:"underline",value:function(s){var u=this,c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=arguments[2];if(!!this.contents){var o=this.contents.range(s),v=function(){u.emit(f.EVENTS.VIEWS.MARK_CLICKED,s,c)};c.epubcfi=s,this.pane||(this.pane=new n.Pane(this.iframe,this.element));var p=new n.Underline(o,"epubjs-ul",c,{stroke:"black","stroke-opacity":"0.3","mix-blend-mode":"multiply"}),b=this.pane.addMark(p);return this.underlines[s]={mark:b,element:b.element,listeners:[v,a]},b.element.setAttribute("ref","epubjs-ul"),b.element.addEventListener("click",v),b.element.addEventListener("touchstart",v),a&&(b.element.addEventListener("click",a),b.element.addEventListener("touchstart",a)),b}}},{key:"mark",value:function(s){var u=this,c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=arguments[2];if(!!this.contents){if(s in this.marks){var o=this.marks[s];return o}var v=this.contents.range(s);if(!!v){var p=v.commonAncestorContainer,b=p.nodeType===1?p:p.parentNode,E=function(x){u.emit(f.EVENTS.VIEWS.MARK_CLICKED,s,c)};v.collapsed&&p.nodeType===1?(v=new Range,v.selectNodeContents(p)):v.collapsed&&(v=new Range,v.selectNodeContents(b));var L=void 0,A=void 0,B=void 0;if(this.layout.name==="pre-paginated"||this.settings.axis!=="horizontal"){var D=v.getBoundingClientRect();L=D.top,A=D.right}else for(var V=v.getClientRects(),N=void 0,z=0;z!=V.length;z++)N=V[z],(!B||N.left=f||z<0||a&&_>=r}function L(){var N=w();if(E(N))return A(N);i=setTimeout(L,b(N))}function A(N){return i=void 0,o&&l?v(N):(l=e=void 0,t)}function B(){i!==void 0&&clearTimeout(i),u=0,l=s=e=i=void 0}function D(){return i===void 0?t:A(w())}function V(){var N=w(),z=E(N);if(l=arguments,e=this,s=N,z){if(i===void 0)return p(s);if(a)return i=setTimeout(L,f),v(s)}return i===void 0&&(i=setTimeout(L,f)),t}return V.cancel=B,V.flush=D,V}C.exports=d},function(C,y,m){var S=m(59),w=typeof self=="object"&&self&&self.Object===Object&&self,R=S||w||Function("return this")();C.exports=R},function(C,y,m){var S=m(22),w=S.Symbol;C.exports=w},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function r(t,i){for(var s=0;s0||c>0)&&this.scrollBy(u,c,!0)}},{key:"afterResized",value:function(s){this.emit(k.EVENTS.MANAGERS.RESIZE,s.section)}},{key:"removeShownListeners",value:function(s){s.onDisplayed=function(){}}},{key:"add",value:function(s){var u=this,c=this.createView(s);return this.views.append(c),c.on(k.EVENTS.VIEWS.RESIZED,function(a){c.expanded=!0}),c.on(k.EVENTS.VIEWS.AXIS,function(a){u.updateAxis(a)}),c.onDisplayed=this.afterDisplayed.bind(this),c.onResize=this.afterResized.bind(this),c.display(this.request)}},{key:"append",value:function(s){var u=this.createView(s);return u.on(k.EVENTS.VIEWS.RESIZED,function(c){u.expanded=!0}),this.views.append(u),u.onDisplayed=this.afterDisplayed.bind(this),u}},{key:"prepend",value:function(s){var u=this,c=this.createView(s);return c.on(k.EVENTS.VIEWS.RESIZED,function(a){u.counter(a),c.expanded=!0}),this.views.prepend(c),c.onDisplayed=this.afterDisplayed.bind(this),c}},{key:"counter",value:function(s){this.settings.axis==="vertical"?this.scrollBy(0,s.heightDelta,!0):this.scrollBy(s.widthDelta,0,!0)}},{key:"update",value:function(s){for(var u=this.bounds(),c=this.views.all(),a=c.length,o=[],v=typeof s!="undefined"?s:this.settings.offset||0,p,b,E=new w.defer,L=[],A=0;A=D&&(v&&E?V():N()),A-p<0&&(v&&E?N():V());var z=o.map(function(_){return _.displayed});return o.length?Promise.all(z).then(function(){if(c.layout.name==="pre-paginated"&&c.layout.props.spread)return c.check()}).then(function(){return c.update(p)},function(_){return _}):(this.q.enqueue(function(){this.update()}.bind(this)),a.resolve(!1),a.promise)}},{key:"trim",value:function(){for(var s=new w.defer,u=this.views.displayed(),c=u[0],a=u[u.length-1],o=this.views.indexOf(c),v=this.views.indexOf(a),p=this.views.slice(0,o),b=this.views.slice(v+1),E=0;E-1;return Q?U:(this.path&&(Y=this.path.resolve(U)),j!=!1&&this.url&&(Y=this.url.resolve(Y)),Y)}}},{key:"canonical",value:function(U){var j=U;return U?(this.settings.canonical?j=this.settings.canonical(U):j=this.resolve(U,!0),j):""}},{key:"determineType",value:function(U){var j,Y,Q;if(this.settings.encoding==="base64")return X.BASE64;if(typeof U!="string")return X.BINARY;if(j=new d.default(U),Y=j.path(),Q=Y.extension,!Q)return X.DIRECTORY;if(Q==="epub")return X.EPUB;if(Q==="opf")return X.OPF;if(Q==="json")return X.MANIFEST}},{key:"unpack",value:function(U){var j=this;this.package=U,this.spine.unpack(this.package,this.resolve.bind(this),this.canonical.bind(this)),this.resources=new v.default(this.package.manifest,{archive:this.archive,resolver:this.resolve.bind(this),request:this.request.bind(this),replacements:this.settings.replacements||(this.archived?"blobUrl":"base64")}),this.loadNavigation(this.package).then(function(){j.loading.navigation.resolve(j.navigation)}),this.package.coverPath&&(this.cover=this.resolve(this.package.coverPath)),this.loading.manifest.resolve(this.package.manifest),this.loading.metadata.resolve(this.package.metadata),this.loading.spine.resolve(this.spine),this.loading.cover.resolve(this.cover),this.loading.resources.resolve(this.resources),this.loading.pageList.resolve(this.pageList),this.isOpen=!0,this.archived||this.settings.replacements&&this.settings.replacements!="none"?this.replacements().then(function(){j.opening.resolve(j)}).catch(function(Y){console.error(Y)}):this.opening.resolve(this)}},{key:"loadNavigation",value:function(U){var j=this,Y=U.navPath||U.ncxPath,Q=U.toc;return Q?new Promise(function(te,ae){j.navigation=new a.default(Q),U.pageList&&(j.pageList=new b.default(U.pageList)),te(j.navigation)}):Y?this.load(Y,"xml").then(function(te){return j.navigation=new a.default(te),j.pageList=new b.default(te),j.navigation}):new Promise(function(te,ae){j.navigation=new a.default,j.pageList=new b.default,te(j.navigation)})}},{key:"section",value:function(U){return this.spine.get(U)}},{key:"renderTo",value:function(U,j){return this.rendition=new L.default(this,j),this.rendition.attachTo(U),this.rendition}},{key:"setRequestCredentials",value:function(U){this.settings.requestCredentials=U}},{key:"setRequestHeaders",value:function(U){this.settings.requestHeaders=U}},{key:"unarchive",value:function(U,j){return this.archive=new B.default,this.archive.open(U,j)}},{key:"coverUrl",value:function(){var U=this,j=this.loaded.cover.then(function(Y){return U.archived?U.resources.get(U.cover):U.cover});return j}},{key:"replacements",value:function(){var U=this;return this.spine.hooks.serialize.register(function(j,Y){Y.output=U.resources.substitute(j,Y.url)}),this.resources.replacements().then(function(){return U.resources.replaceCss()})}},{key:"getRange",value:function(U){var j=new z.default(U),Y=this.spine.get(j.spinePos),Q=this.load.bind(this);return Y?Y.load(Q).then(function(te){var ae=j.toRange(Y.document);return ae}):new Promise(function(te,ae){ae("CFI could not be found")})}},{key:"key",value:function(U){var j=U||this.package.metadata.identifier||this.url.filename;return"epubjs:"+G+":"+j}},{key:"destroy",value:function(){this.opened=void 0,this.loading=void 0,this.loaded=void 0,this.ready=void 0,this.isOpen=!1,this.isRendered=!1,this.spine&&this.spine.destroy(),this.locations&&this.locations.destroy(),this.pageList&&this.pageList.destroy(),this.archive&&this.archive.destroy(),this.resources&&this.resources.destroy(),this.container&&this.container.destroy(),this.packaging&&this.packaging.destroy(),this.rendition&&this.rendition.destroy(),this.spine=void 0,this.locations=void 0,this.pageList=void 0,this.archive=void 0,this.resources=void 0,this.container=void 0,this.packaging=void 0,this.rendition=void 0,this.navigation=void 0,this.url=void 0,this.path=void 0,this.archived=!1}}]),K}();(0,T.default)(J.prototype),y.default=J,C.exports=y.default},function(C,y,m){"use strict";var S=m(28),w=m(36),R=m(37),T=m(38),k;k=C.exports=function(g,d){var h,f,n,l,e;return arguments.length<2||typeof g!="string"?(l=d,d=g,g=null):l=arguments[2],g==null?(h=n=!0,f=!1):(h=T.call(g,"c"),f=T.call(g,"e"),n=T.call(g,"w")),e={value:d,configurable:h,enumerable:f,writable:n},l?S(w(l),e):e},k.gs=function(g,d,h){var f,n,l,e;return typeof g!="string"?(l=h,h=d,d=g,g=null):l=arguments[3],d==null?d=void 0:R(d)?h==null?h=void 0:R(h)||(l=h,h=void 0):(l=d,d=h=void 0),g==null?(f=!0,n=!1):(f=T.call(g,"c"),n=T.call(g,"e")),e={get:d,set:h,configurable:f,enumerable:n},l?S(w(l),e):e}},function(C,y,m){"use strict";C.exports=m(29)()?Object.assign:m(30)},function(C,y,m){"use strict";C.exports=function(){var S=Object.assign,w;return typeof S!="function"?!1:(w={foo:"raz"},S(w,{bar:"dwa"},{trzy:"trzy"}),w.foo+w.bar+w.trzy==="razdwatrzy")}},function(C,y,m){"use strict";var S=m(31),w=m(35),R=Math.max;C.exports=function(T,k){var g,d,h=R(arguments.length,2),f;for(T=Object(w(T)),f=function(n){try{T[n]=k[n]}catch(l){g||(g=l)}},d=1;d-1}},function(C,y,m){"use strict";C.exports=function(S){if(typeof S!="function")throw new TypeError(S+" is not a function");return S}},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function e(r,t){for(var i=0;i0;){var b=this.get(p-1);if(b&&b.linear)return b;p-=1}}.bind(u),c.next=function(){for(var p=c.index;p-1)return delete this.spineByHref[t.href],delete this.spineById[t.idref],this.spineItems.splice(i,1)}},{key:"each",value:function(){return this.spineItems.forEach.apply(this.spineItems,arguments)}},{key:"first",value:function(){var t=0;do{var i=this.get(t);if(i&&i.linear)return i;t+=1}while(t=0)}},{key:"destroy",value:function(){this.each(function(t){return t.destroy()}),this.spineItems=void 0,this.spineByHref=void 0,this.spineById=void 0,this.hooks.serialize.clear(),this.hooks.content.clear(),this.hooks=void 0,this.epubcfi=void 0,this.loaded=!1,this.items=void 0,this.manifest=void 0,this.spineNodeIndex=void 0,this.baseUrl=void 0,this.length=void 0}}]),e}();y.default=l,C.exports=y.default},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function l(e,r){for(var t=0;t=0,a;typeof XMLSerializer=="undefined"||c?a=m(16).XMLSerializer:a=XMLSerializer;var o=new a;return this.output=o.serializeToString(s),this.output}.bind(this)).then(function(){return this.hooks.serialize.trigger(this.output,this)}.bind(this)).then(function(){t.resolve(this.output)}.bind(this)).catch(function(s){t.reject(s)}),i}},{key:"find",value:function(r){var t=this,i=[],s=r.toLowerCase(),u=function(a){for(var o=a.textContent.toLowerCase(),v=t.document.createRange(),p,b,E=-1,L,A=150;b!=-1;)b=o.indexOf(s,E+1),b!=-1&&(v=t.document.createRange(),v.setStart(a,b),v.setEnd(a,b+s.length),p=t.cfiFromRange(v),a.textContent.lengthV&&(p+=V,z=V);z=V)p+=V-z,z=V;else{z+=N,a.endContainer=D,a.endOffset=z;var _=new g.default(a,s).toString();c.push(_),p=0}b=D};if((0,w.sprint)(v,L.bind(this)),a&&a.startContainer&&b){a.endContainer=b,a.endOffset=b.length;var A=new g.default(a,s).toString();c.push(A),p=0}return c}},{key:"locationFromCfi",value:function(i){var s=void 0;return g.default.prototype.isCfiString(i)&&(i=new g.default(i)),this._locations.length===0?-1:(s=(0,w.locationOf)(i,this._locations,this.epubcfi.compare),s>this.total?this.total:s)}},{key:"percentageFromCfi",value:function(i){if(this._locations.length===0)return null;var s=this.locationFromCfi(i);return this.percentageFromLocation(s)}},{key:"percentageFromLocation",value:function(i){return!i||!this.total?0:i/this.total}},{key:"cfiFromLocation",value:function(i){var s=-1;return typeof i!="number"&&(i=parseInt(i)),i>=0&&i1&&console.warn("Normalize cfiFromPercentage value to between 0 - 1"),i>=1){var u=new g.default(this._locations[this.total]);return u.collapse(),u.toString()}return s=Math.ceil(this.total*i),this.cfiFromLocation(s)}},{key:"load",value:function(i){return typeof i=="string"?this._locations=JSON.parse(i):this._locations=i,this.total=this._locations.length-1,this._locations}},{key:"save",value:function(){return JSON.stringify(this._locations)}},{key:"getCurrent",value:function(){return this._current}},{key:"setCurrent",value:function(i){var s;if(typeof i=="string")this._currentCfi=i;else if(typeof i=="number")this._current=i;else return;this._locations.length!==0&&(typeof i=="string"?(s=this.locationFromCfi(i),this._current=s):s=i,this.emit(d.EVENTS.LOCATIONS.CHANGED,{percentage:this.percentageFromLocation(s)}))}},{key:"length",value:function(){return this._locations.length}},{key:"destroy",value:function(){this.spine=void 0,this.request=void 0,this.pause=void 0,this.q.stop(),this.q=void 0,this.epubcfi=void 0,this._locations=void 0,this.total=void 0,this.break=void 0,this._current=void 0,this.currentLocation=void 0,this._currentCfi=void 0,clearTimeout(this.processingTimeout)}},{key:"currentLocation",get:function(){return this._current},set:function(i){this.setCurrent(i)}}]),r}();(0,f.default)(e.prototype),y.default=e,C.exports=y.default},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function h(f,n){for(var l=0;l-1&&(this.replacementUrls[b]=p)}.bind(this));a.push(v)}.bind(this)),Promise.all(a)}},{key:"createCssFile",value:function(u){var c=this,a;if(l.default.isAbsolute(u))return new Promise(function(b){b()});var o=this.settings.resolver(u),v;this.settings.archive?v=this.settings.archive.getText(o):v=this.settings.request(o,"text");var p=this.urls.map(function(b){var E=c.settings.resolver(b),L=new f.default(o).relative(E);return L});return v?v.then(function(b){return b=(0,w.substitute)(b,p,c.replacementUrls),c.settings.replacements==="base64"?a=(0,R.createBase64Url)(b,"text/css"):a=(0,R.createBlobUrl)(b,"text/css"),a},function(b){return new Promise(function(E){E()})}):new Promise(function(b){b()})}},{key:"relativeTo",value:function(u,c){return c=c||this.settings.resolver,this.urls.map(function(a){var o=c(a),v=new f.default(u).relative(o);return v}.bind(this))}},{key:"get",value:function(u){var c=this.urls.indexOf(u);if(c!==-1)return this.replacementUrls.length?new Promise(function(a,o){a(this.replacementUrls[c])}.bind(this)):this.createUrl(u)}},{key:"substitute",value:function(u,c){var a;return c?a=this.relativeTo(c):a=this.urls,(0,w.substitute)(u,a,this.replacementUrls)}},{key:"destroy",value:function(){this.settings=void 0,this.manifest=void 0,this.resources=void 0,this.replacementUrls=void 0,this.html=void 0,this.assets=void 0,this.css=void 0,this.urls=void 0,this.cssUrls=void 0}}]),i}();y.default=t,C.exports=y.default},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function h(f,n){for(var l=0;l1?s[1]:!1,{cfi:c,href:e,packageUrl:u,page:t}):{href:e,page:t}}},{key:"process",value:function(n){n.forEach(function(l){this.pages.push(l.page),l.cfi&&this.locations.push(l.cfi)},this),this.firstPage=parseInt(this.pages[0]),this.lastPage=parseInt(this.pages[this.pages.length-1]),this.totalPages=this.lastPage-this.firstPage}},{key:"pageFromCfi",value:function(n){var l=-1;if(this.locations.length===0)return-1;var e=(0,T.indexOfSorted)(n,this.locations,this.epubcfi.compare);return e!=-1?l=this.pages[e]:(e=(0,T.locationOf)(n,this.locations,this.epubcfi.compare),l=e-1>=0?this.pages[e-1]:this.pages[0],l!==void 0||(l=-1)),l}},{key:"cfiFromPage",value:function(n){var l=-1;typeof n!="number"&&(n=parseInt(n));var e=this.pages.indexOf(n);return e!=-1&&(l=this.locations[e]),l}},{key:"pageFromPercentage",value:function(n){var l=Math.round(this.totalPages*n);return l}},{key:"percentageFromPage",value:function(n){var l=(n-this.firstPage)/this.totalPages;return Math.round(l*1e3)/1e3}},{key:"percentageFromCfi",value:function(n){var l=this.pageFromCfi(n),e=this.percentageFromPage(l);return e}},{key:"destroy",value:function(){this.pages=void 0,this.locations=void 0,this.epubcfi=void 0,this.pageList=void 0,this.toc=void 0,this.ncx=void 0}}]),h}();y.default=d,C.exports=y.default},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function f(n,l){for(var e=0;e=0&&(this._minSpreadWidth=e),this._spread}},{key:"calculate",value:function(l,e,r){var t=1,i=r||0,s=l,u=e,c=Math.floor(s/12),a,o,v,p;this._spread&&s>=this._minSpreadWidth?t=2:t=1,this.name==="reflowable"&&this._flow==="paginated"&&!(r>=0)&&(i=c%2==0?c:c-1),this.name==="pre-paginated"&&(i=0),t>1?(a=s/t-i,v=a+i):(a=s,v=s),this.name==="pre-paginated"&&t>1&&(s=a),o=a*t+i,p=s,this.width=s,this.height=u,this.spreadWidth=o,this.pageWidth=v,this.delta=p,this.columnWidth=a,this.gap=i,this.divisor=t,this.update({width:s,height:u,spreadWidth:o,pageWidth:v,delta:p,columnWidth:a,gap:i,divisor:t})}},{key:"format",value:function(l){var e;return this.name==="pre-paginated"?e=l.fit(this.columnWidth,this.height):this._flow==="paginated"?e=l.columns(this.width,this.height,this.columnWidth,this.gap):e=l.size(this.width,null),e}},{key:"count",value:function(l,e){var r=void 0,t=void 0;return this.name==="pre-paginated"?(r=1,t=1):this._flow==="paginated"?(e=e||this.delta,r=Math.ceil(l/e),t=r*this.divisor):(e=e||this.height,r=Math.ceil(l/e),t=r),{spreads:r,pages:t}}},{key:"update",value:function(l){var e=this;if(Object.keys(l).forEach(function(t){e.props[t]===l[t]&&delete l[t]}),Object.keys(l).length>0){var r=(0,w.extend)(this.props,l);this.emit(R.EVENTS.LAYOUT.UPDATED,r,l)}}}]),f}();(0,k.default)(h.prototype),y.default=h,C.exports=y.default},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},w=function(){function h(f,n){for(var l=0;l0||r.url&&l.indexOf(r.url)===-1)&&this.add(t,n),this._injected.push(t));this._current!="default"&&n.addClass(this._current)}},{key:"add",value:function(n,l){var e=this._themes[n];!e||!l||(e.url?l.addStylesheet(e.url):e.serialized||e.rules&&(l.addStylesheetRules(e.rules),e.injected=!0))}},{key:"override",value:function(n,l){var e=this,r=this.rendition.getContents();this._overrides[n]=l,r.forEach(function(t){t.css(n,e._overrides[n])})}},{key:"overrides",value:function(n){var l=this._overrides;for(var e in l)l.hasOwnProperty(e)&&n.css(e,l[e])}},{key:"fontSize",value:function(n){this.override("font-size",n)}},{key:"font",value:function(n){this.override("font-family",n)}},{key:"destroy",value:function(){this.rendition=void 0,this._themes=void 0,this._overrides=void 0,this._current=void 0,this._injected=void 0}}]),h}();y.default=d,C.exports=y.default},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0});var S=function(){function n(l,e){for(var r=0;r1&&arguments[1]!==void 0?arguments[1]:document.body;l(this,a),this.target=o,this.element=k.default.createElement("svg"),this.marks=[],this.element.style.position="absolute",this.element.setAttribute("pointer-events","none"),d.default.proxyMouse(this.target,this.marks),this.container=v,this.container.appendChild(this.element),this.render()}return R(a,[{key:"addMark",value:function(v){var p=k.default.createElement("g");return this.element.appendChild(p),v.bind(p,this.container),this.marks.push(v),v.render(),v}},{key:"removeMark",value:function(v){var p=this.marks.indexOf(v);if(p!==-1){var b=v.unbind();this.element.removeChild(b),this.marks.splice(p,1)}}},{key:"render",value:function(){u(this.element,s(this.target,this.container));var v=!0,p=!1,b=void 0;try{for(var E=this.marks[Symbol.iterator](),L;!(v=(L=E.next()).done);v=!0){var A=L.value;A.render()}}catch(B){p=!0,b=B}finally{try{!v&&E.return&&E.return()}finally{if(p)throw b}}}}]),a}(),r=y.Mark=function(){function a(){l(this,a),this.element=null}return R(a,[{key:"bind",value:function(v,p){this.element=v,this.container=p}},{key:"unbind",value:function(){var v=this.element;return this.element=null,v}},{key:"render",value:function(){}},{key:"dispatchEvent",value:function(v){!this.element||this.element.dispatchEvent(v)}},{key:"getBoundingClientRect",value:function(){return this.element.getBoundingClientRect()}},{key:"getClientRects",value:function(){for(var v=[],p=this.element.firstChild;p;)v.push(p.getBoundingClientRect()),p=p.nextSibling;return v}},{key:"filteredRanges",value:function(){var v=Array.from(this.range.getClientRects());return v.filter(function(p){for(var b=0;b=a.left&&o.top>=a.top&&o.bottom<=a.bottom}},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0}),y.createElement=S;function S(w){return document.createElementNS("http://www.w3.org/2000/svg",w)}y.default={createElement:S}},function(C,y,m){"use strict";Object.defineProperty(y,"__esModule",{value:!0}),y.proxyMouse=S,y.clone=w,y.default={proxyMouse:S};function S(T,k){function g(n){for(var l=k.length-1;l>=0;l--){var e=k[l],r=n.clientX,t=n.clientY;if(n.touches&&n.touches.length&&(r=n.touches[0].clientX,t=n.touches[0].clientY),!!R(e,T,r,t)){e.dispatchEvent(w(n));break}}}if(T.nodeName==="iframe"||T.nodeName==="IFRAME")try{this.target=T.contentDocument}catch(n){this.target=T}else this.target=T;for(var d=["mouseup","mousedown","click","touchstart"],h=0;hs&&o>i}var n=T.getBoundingClientRect();if(!f(n,g,d))return!1;for(var l=T.getClientRects(),e=0,r=l.length;e-1&&this._views.splice(d,1),this.destroy(g),this.length--}},{key:"destroy",value:function(g){g.displayed&&g.destroy(),this.container&&this.container.removeChild(g.element),g=null}},{key:"forEach",value:function(){return this._views.forEach.apply(this._views,arguments)}},{key:"clear",value:function(){var g,d=this.length;if(!!this.length){for(var h=0;h32&&L<127&&[34,35,60,62,63,96].indexOf(L)==-1?E:encodeURIComponent(E)}function s(E){var L=E.charCodeAt(0);return L>32&&L<127&&[34,35,60,62,96].indexOf(L)==-1?E:encodeURIComponent(E)}var u=void 0,c=/[a-zA-Z]/,a=/[a-zA-Z0-9\+\-\.]/;function o(E,L,A){function B(j){P.push(j)}var D=L||"scheme start",V=0,N="",z=!1,_=!1,P=[];e:for(;(E[V-1]!=u||V==0)&&!this._isInvalid;){var x=E[V];switch(D){case"scheme start":if(x&&c.test(x))N+=x.toLowerCase(),D="scheme";else if(L){B("Invalid scheme.");break e}else{N="",D="no scheme";continue}break;case"scheme":if(x&&a.test(x))N+=x.toLowerCase();else if(x==":"){if(this._scheme=N,N="",L)break e;e(this._scheme)&&(this._isRelative=!0),this._scheme=="file"?D="relative":this._isRelative&&A&&A._scheme==this._scheme?D="relative or authority":this._isRelative?D="authority first slash":D="scheme data"}else if(L){if(u==x)break e;B("Code point not allowed in scheme: "+x);break e}else{N="",V=0,D="no scheme";continue}break;case"scheme data":x=="?"?(this._query="?",D="query"):x=="#"?(this._fragment="#",D="fragment"):u!=x&&x!=" "&&x!=` `&&x!="\r"&&(this._schemeData+=i(x));break;case"no scheme":if(!A||!e(A._scheme))B("Missing scheme."),r.call(this);else{D="relative";continue}break;case"relative or authority":if(x=="/"&&E[V+1]=="/")D="authority ignore slashes";else{B("Expected /, got: "+x),D="relative";continue}break;case"relative":if(this._isRelative=!0,this._scheme!="file"&&(this._scheme=A._scheme),u==x){this._host=A._host,this._port=A._port,this._path=A._path.slice(),this._query=A._query,this._username=A._username,this._password=A._password;break e}else if(x=="/"||x=="\\")x=="\\"&&B("\\ is an invalid code point."),D="relative slash";else if(x=="?")this._host=A._host,this._port=A._port,this._path=A._path.slice(),this._query="?",this._username=A._username,this._password=A._password,D="query";else if(x=="#")this._host=A._host,this._port=A._port,this._path=A._path.slice(),this._query=A._query,this._fragment="#",this._username=A._username,this._password=A._password,D="fragment";else{var F=E[V+1],G=E[V+2];(this._scheme!="file"||!c.test(x)||F!=":"&&F!="|"||u!=G&&G!="/"&&G!="\\"&&G!="?"&&G!="#")&&(this._host=A._host,this._port=A._port,this._username=A._username,this._password=A._password,this._path=A._path.slice(),this._path.pop()),D="relative path";continue}break;case"relative slash":if(x=="/"||x=="\\")x=="\\"&&B("\\ is an invalid code point."),this._scheme=="file"?D="file host":D="authority ignore slashes";else{this._scheme!="file"&&(this._host=A._host,this._port=A._port,this._username=A._username,this._password=A._password),D="relative path";continue}break;case"authority first slash":if(x=="/")D="authority second slash";else{B("Expected '/', got: "+x),D="authority ignore slashes";continue}break;case"authority second slash":if(D="authority ignore slashes",x!="/"){B("Expected '/', got: "+x);continue}break;case"authority ignore slashes":if(x!="/"&&x!="\\"){D="authority";continue}else B("Expected authority, got: "+x);break;case"authority":if(x=="@"){z&&(B("@ already seen."),N+="%40"),z=!0;for(var X=0;X