diff --git a/dist/epub.js b/dist/epub.js index accf86d..dde8c44 100644 --- a/dist/epub.js +++ b/dist/epub.js @@ -4398,7 +4398,7 @@ EPUBJS.View.prototype.afterLoad = function() { // Wait for fonts to load to finish - if(this.document.fonts.status === "loading") { + if(this.document.fonts && this.document.fonts.status === "loading") { this.document.fonts.onloading = function(){ this.expand(); }.bind(this); diff --git a/dist/epub.min.js b/dist/epub.min.js index f1a76d4..3248972 100644 --- a/dist/epub.min.js +++ b/dist/epub.min.js @@ -1,2 +1,2 @@ "undefined"==typeof EPUBJS&&(("undefined"!=typeof window?window:this).EPUBJS={}),EPUBJS.VERSION="0.3.0",EPUBJS.Render={},function(t){"use strict";var e=function(t){return new EPUBJS.Book(t)};e.Render={register:function(t,i){e.Render[t]=i}},"object"==typeof exports?(t.RSVP=require("rsvp"),module.exports=e):"function"==typeof define&&define.amd?define(e):t.ePub=e}(this),function(t){var e,i;!function(){var t={},n={};e=function(e,i,n){t[e]={deps:i,callback:n}},i=function(e){function r(t){if("."!==t.charAt(0))return t;for(var i=t.split("/"),n=e.split("/").slice(0,-1),r=0,o=i.length;o>r;r++){var s=i[r];if(".."===s)n.pop();else{if("."===s)continue;n.push(s)}}return n.join("/")}if(n[e])return n[e];if(n[e]={},!t[e])throw new Error("Could not find module "+e);for(var o,s=t[e],a=s.deps,h=s.callback,u=[],c=0,p=a.length;p>c;c++)u.push("exports"===a[c]?o={}:i(r(a[c])));var l=h.apply(this,u);return n[e]=o||l},i.entries=t}(),e("rsvp/-internal",["./utils","./instrument","./config","exports"],function(t,e,i,n){"use strict";function r(){}function o(t){try{return t.then}catch(e){return x.error=e,x}}function s(t,e,i,n){try{t.call(e,i,n)}catch(r){return r}}function a(t,e,i){B.async(function(t){var n=!1,r=s(i,e,function(i){n||(n=!0,e!==i?c(t,i):l(t,i))},function(e){n||(n=!0,d(t,e))},"Settle: "+(t._label||" unknown promise"));!n&&r&&(n=!0,d(t,r))},t)}function h(t,e){t._onerror=null,e._state===U?l(t,e._result):t._state===J?d(t,e._result):f(e,void 0,function(i){e!==i?c(t,i):l(t,i)},function(e){d(t,e)})}function u(t,e){if(e instanceof t.constructor)h(t,e);else{var i=o(e);i===x?d(t,x.error):void 0===i?l(t,e):P(i)?a(t,e,i):l(t,e)}}function c(t,e){t===e?l(t,e):E(e)?u(t,e):l(t,e)}function p(t){t._onerror&&t._onerror(t._result),g(t)}function l(t,e){t._state===b&&(t._result=e,t._state=U,0===t._subscribers.length?B.instrument&&w("fulfilled",t):B.async(g,t))}function d(t,e){t._state===b&&(t._state=J,t._result=e,B.async(p,t))}function f(t,e,i,n){var r=t._subscribers,o=r.length;t._onerror=null,r[o]=e,r[o+U]=i,r[o+J]=n,0===o&&t._state&&B.async(g,t)}function g(t){var e=t._subscribers,i=t._state;if(B.instrument&&w(i===U?"fulfilled":"rejected",t),0!==e.length){for(var n,r,o=t._result,s=0;st;t+=2){var e=p[t],i=p[t+1];e(i),p[t]=void 0,p[t+1]=void 0}s=0}var s=0;t["default"]=function(t,e){p[s]=t,p[s+1]=e,s+=2,2===s&&a()};var a,h="undefined"!=typeof window?window:{},u=h.MutationObserver||h.WebKitMutationObserver,c="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,p=new Array(1e3);a="undefined"!=typeof process&&"[object process]"==={}.toString.call(process)?e():u?i():c?n():r()}),e("rsvp/config",["./events","exports"],function(t,e){"use strict";function i(t,e){return"onerror"===t?void r.on("error",e):2!==arguments.length?r[t]:void(r[t]=e)}var n=t["default"],r={instrument:!1};n.mixin(r),e.config=r,e.configure=i}),e("rsvp/defer",["./promise","exports"],function(t,e){"use strict";var i=t["default"];e["default"]=function(t){var e={};return e.promise=new i(function(t,i){e.resolve=t,e.reject=i},t),e}}),e("rsvp/enumerator",["./utils","./-internal","exports"],function(t,e,i){"use strict";function n(t,e,i){return t===p?{state:"fulfilled",value:i}:{state:"rejected",reason:i}}function r(t,e,i,n){this._instanceConstructor=t,this.promise=new t(a,n),this._abortOnReject=i,this._validateInput(e)?(this._input=e,this.length=e.length,this._remaining=e.length,this._init(),0===this.length?u(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&u(this.promise,this._result))):h(this.promise,this._validationError())}var o=t.isArray,s=t.isMaybeThenable,a=e.noop,h=e.reject,u=e.fulfill,c=e.subscribe,p=e.FULFILLED,l=e.REJECTED,d=e.PENDING,f=!0;i.ABORT_ON_REJECTION=f,i.makeSettledResult=n,r.prototype._validateInput=function(t){return o(t)},r.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},r.prototype._init=function(){this._result=new Array(this.length)},i["default"]=r,r.prototype._enumerate=function(){for(var t=this.length,e=this.promise,i=this._input,n=0;e._state===d&&t>n;n++)this._eachEntry(i[n],n)},r.prototype._eachEntry=function(t,e){var i=this._instanceConstructor;s(t)?t.constructor===i&&t._state!==d?(t._onerror=null,this._settledAt(t._state,e,t._result)):this._willSettleAt(i.resolve(t),e):(this._remaining--,this._result[e]=this._makeResult(p,e,t))},r.prototype._settledAt=function(t,e,i){var n=this.promise;n._state===d&&(this._remaining--,this._abortOnReject&&t===l?h(n,i):this._result[e]=this._makeResult(t,e,i)),0===this._remaining&&u(n,this._result)},r.prototype._makeResult=function(t,e,i){return i},r.prototype._willSettleAt=function(t,e){var i=this;c(t,void 0,function(t){i._settledAt(p,e,t)},function(t){i._settledAt(l,e,t)})}}),e("rsvp/events",["exports"],function(t){"use strict";function e(t,e){for(var i=0,n=t.length;n>i;i++)if(t[i]===e)return i;return-1}function i(t){var e=t._promiseCallbacks;return e||(e=t._promiseCallbacks={}),e}t["default"]={mixin:function(t){return t.on=this.on,t.off=this.off,t.trigger=this.trigger,t._promiseCallbacks=void 0,t},on:function(t,n){var r,o=i(this);r=o[t],r||(r=o[t]=[]),-1===e(r,n)&&r.push(n)},off:function(t,n){var r,o,s=i(this);return n?(r=s[t],o=e(r,n),void(-1!==o&&r.splice(o,1))):void(s[t]=[])},trigger:function(t,e){var n,r,o=i(this);if(n=o[t])for(var s=0;sa;a++)s[a]=e(t[a]);return n.all(s,i).then(function(e){for(var i=new Array(o),n=0,r=0;o>r;r++)e[r]&&(i[n]=t[r],n++);return i.length=n,i})})}}),e("rsvp/hash-settled",["./promise","./enumerator","./promise-hash","./utils","exports"],function(t,e,i,n,r){"use strict";function o(t,e,i){this._superConstructor(t,e,!1,i)}var s=t["default"],a=e.makeSettledResult,h=i["default"],u=e["default"],c=n.o_create;o.prototype=c(h.prototype),o.prototype._superConstructor=u,o.prototype._makeResult=a,o.prototype._validationError=function(){return new Error("hashSettled must be called with an object")},r["default"]=function(t,e){return new o(s,t,e).promise}}),e("rsvp/hash",["./promise","./promise-hash","./enumerator","exports"],function(t,e,i,n){"use strict";{var r=t["default"],o=e["default"];i.ABORT_ON_REJECTION}n["default"]=function(t,e){return new o(r,t,e).promise}}),e("rsvp/instrument",["./config","./utils","exports"],function(t,e,i){"use strict";var n=t.config,r=e.now,o=[];i["default"]=function(t,e,i){1===o.push({name:t,payload:{guid:e._guidKey+e._id,eventName:t,detail:e._result,childGuid:i&&e._guidKey+i._id,label:e._label,timeStamp:r(),stack:new Error(e._label).stack}})&&setTimeout(function(){for(var t,e=0;ea;a++)s[a]=e(t[a]);return n.all(s,i)})}}),e("rsvp/node",["./promise","./utils","exports"],function(t,e,i){"use strict";var n=t["default"],r=e.isArray;i["default"]=function(t,e){function i(){for(var i=arguments.length,r=new Array(i),a=0;i>a;a++)r[a]=arguments[a];var h;return o||s||!e?h=this:("object"==typeof console&&console.warn('Deprecation: RSVP.denodeify() doesn\'t allow setting the "this" binding anymore. Use yourFunction.bind(yourThis) instead.'),h=e),n.all(r).then(function(i){function r(n,r){function a(){for(var t=arguments.length,i=new Array(t),a=0;t>a;a++)i[a]=arguments[a];var h=i[0],u=i[1];if(h)r(h);else if(o)n(i.slice(1));else if(s){var c,p,l={},d=i.slice(1);for(p=0;pa;a++)o=i[a],this._eachEntry(o.entry,o.position)}}),e("rsvp/promise",["./config","./events","./instrument","./utils","./-internal","./promise/cast","./promise/all","./promise/race","./promise/resolve","./promise/reject","exports"],function(t,e,i,n,r,o,s,a,h,u,c){"use strict";function p(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function l(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function d(t,e){this._id=R++,this._label=e,this._subscribers=[],f.instrument&&g("created",this),v!==t&&(m(t)||p(),this instanceof d||l(),E(this,t))}var f=t.config,g=(e["default"],i["default"]),m=(n.objectOrFunction,n.isFunction),y=n.now,v=r.noop,S=(r.resolve,r.reject,r.fulfill,r.subscribe),E=r.initializePromise,P=r.invokeCallback,w=r.FULFILLED,B=o["default"],b=s["default"],U=a["default"],J=h["default"],x=u["default"],C="rsvp_"+y()+"-",R=0;c["default"]=d,d.cast=B,d.all=b,d.race=U,d.resolve=J,d.reject=x,d.prototype={constructor:d,_id:void 0,_guidKey:C,_label:void 0,_state:void 0,_result:void 0,_subscribers:void 0,_onerror:function(t){f.trigger("error",t)},then:function(t,e,i){var n=this;n._onerror=null;var r=new this.constructor(v,i),o=n._state,s=n._result;return f.instrument&&g("chained",n,r),o===w&&t?f.async(function(){P(o,r,t,s)}):S(n,r,t,e),r},"catch":function(t,e){return this.then(null,t,e)},"finally":function(t,e){var i=this.constructor;return this.then(function(e){return i.resolve(t()).then(function(){return e})},function(e){return i.resolve(t()).then(function(){throw e})},e)}}}),e("rsvp/promise/all",["../enumerator","exports"],function(t,e){"use strict";var i=t["default"];e["default"]=function(t,e){return new i(this,t,!0,e).promise}}),e("rsvp/promise/cast",["./resolve","exports"],function(t,e){"use strict";var i=t["default"];e["default"]=i}),e("rsvp/promise/race",["../utils","../-internal","exports"],function(t,e,i){"use strict";var n=t.isArray,r=(t.isFunction,t.isMaybeThenable,e.noop),o=e.resolve,s=e.reject,a=e.subscribe,h=e.PENDING;i["default"]=function(t,e){function i(t){o(p,t)}function u(t){s(p,t)}var c=this,p=new c(r,e);if(!n(t))return s(p,new TypeError("You must pass an array to race.")),p;for(var l=t.length,d=0;p._state===h&&l>d;d++)a(c.resolve(t[d]),void 0,i,u);return p}}),e("rsvp/promise/reject",["../-internal","exports"],function(t,e){"use strict";var i=t.noop,n=t.reject;e["default"]=function(t,e){var r=this,o=new r(i,e);return n(o,t),o}}),e("rsvp/promise/resolve",["../-internal","exports"],function(t,e){"use strict";var i=t.noop,n=t.resolve;e["default"]=function(t,e){var r=this;if(t&&"object"==typeof t&&t.constructor===r)return t;var o=new r(i,e);return n(o,t),o}}),e("rsvp/race",["./promise","exports"],function(t,e){"use strict";var i=t["default"];e["default"]=function(t,e){return i.race(t,e)}}),e("rsvp/reject",["./promise","exports"],function(t,e){"use strict";var i=t["default"];e["default"]=function(t,e){return i.reject(t,e)}}),e("rsvp/resolve",["./promise","exports"],function(t,e){"use strict";var i=t["default"];e["default"]=function(t,e){return i.resolve(t,e)}}),e("rsvp/rethrow",["exports"],function(t){"use strict";t["default"]=function(t){throw setTimeout(function(){throw t}),t}}),e("rsvp/utils",["exports"],function(t){"use strict";function e(t){return"function"==typeof t||"object"==typeof t&&null!==t}function i(t){return"function"==typeof t}function n(t){return"object"==typeof t&&null!==t}t.objectOrFunction=e,t.isFunction=i,t.isMaybeThenable=n;var r;r=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var o=r;t.isArray=o;var s=Date.now||function(){return(new Date).getTime()};t.now=s;var a=Object.create||function(t){var e=function(){};return e.prototype=t,e};t.o_create=a}),e("rsvp",["./rsvp/promise","./rsvp/events","./rsvp/node","./rsvp/all","./rsvp/all-settled","./rsvp/race","./rsvp/hash","./rsvp/hash-settled","./rsvp/rethrow","./rsvp/defer","./rsvp/config","./rsvp/map","./rsvp/resolve","./rsvp/reject","./rsvp/filter","./rsvp/asap","exports"],function(t,e,i,n,r,o,s,a,h,u,c,p,l,d,f,g,m){"use strict";function y(t,e){_.async(t,e)}function v(){_.on.apply(_,arguments)}function S(){_.off.apply(_,arguments)}var E=t["default"],P=e["default"],w=i["default"],B=n["default"],b=r["default"],U=o["default"],J=s["default"],x=a["default"],C=h["default"],R=u["default"],_=c.config,T=c.configure,k=p["default"],I=l["default"],F=d["default"],N=f["default"],L=g["default"];if(_.async=L,"undefined"!=typeof window&&"object"==typeof window.__PROMISE_INSTRUMENTATION__){var A=window.__PROMISE_INSTRUMENTATION__;T("instrument",!0);for(var O in A)A.hasOwnProperty(O)&&v(O,A[O])}m.Promise=E,m.EventTarget=P,m.all=B,m.allSettled=b,m.race=U,m.hash=J,m.hashSettled=x,m.rethrow=C,m.defer=R,m.denodeify=w,m.configure=T,m.on=v,m.off=S,m.resolve=I,m.reject=F,m.async=y,m.map=k,m.filter=N}),t.RSVP=i("rsvp")}(self),EPUBJS.core={},EPUBJS.core.request=function(t,e,i,n){function r(){if(this.readyState===this.DONE)if(200===this.status||this.responseXML){var t;t="xml"==e?this.responseXML?this.responseXML:(new DOMParser).parseFromString(this.response,"text/xml"):"json"==e?JSON.parse(this.response):"blob"==e?s?this.response:new Blob([this.response]):this.response,h.resolve(t)}else h.reject({status:this.status,message:this.response,stack:(new Error).stack})}var o,s=window.URL,a=s?"blob":"arraybuffer",h=new RSVP.defer,u=new XMLHttpRequest,c=XMLHttpRequest.prototype;"overrideMimeType"in c||Object.defineProperty(c,"overrideMimeType",{value:function(){}}),i&&(u.withCredentials=!0),u.open("GET",t,!0);for(o in n)u.setRequestHeader(o,n[o]);return u.onreadystatechange=r,"blob"==e&&(u.responseType=a),"json"==e&&u.setRequestHeader("Accept","application/json"),"xml"==e&&u.overrideMimeType("text/xml"),u.send(),h.promise},EPUBJS.core.uri=function(t){var e,i,n,r={protocol:"",host:"",path:"",origin:"",directory:"",base:"",filename:"",extension:"",fragment:"",href:t},o=t.indexOf("://"),s=t.indexOf("?"),a=t.indexOf("#");return-1!=a&&(r.fragment=t.slice(a+1),t=t.slice(0,a)),-1!=s&&(r.search=t.slice(s+1),t=t.slice(0,s),href=t),-1!=o?(r.protocol=t.slice(0,o),e=t.slice(o+3),n=e.indexOf("/"),-1===n?(r.host=r.path,r.path=""):(r.host=e.slice(0,n),r.path=e.slice(n)),r.origin=r.protocol+"://"+r.host,r.directory=EPUBJS.core.folder(r.path),r.base=r.origin+r.directory):(r.path=t,r.directory=EPUBJS.core.folder(t),r.base=r.directory),r.filename=t.replace(r.base,""),i=r.filename.lastIndexOf("."),-1!=i&&(r.extension=r.filename.slice(i+1)),r},EPUBJS.core.folder=function(t){var e=t.lastIndexOf("/");if(-1==e)var i="";return i=t.slice(0,e+1)},EPUBJS.core.queue=function(t){var e=[],i=t,n=function(t,i,n){return e.push({funcName:t,args:i,context:n}),e},r=function(){var t;e.length&&(t=e.shift(),i[t.funcName].apply(t.context||i,t.args))},o=function(){for(;e.length;)r()},s=function(){e=[]},a=function(){return e.length};return{enqueue:n,dequeue:r,flush:o,clear:s,length:a}},EPUBJS.core.isElement=function(t){return!(!t||1!=t.nodeType)},EPUBJS.core.uuid=function(){var t=(new Date).getTime(),e="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)});return e},EPUBJS.core.values=function(t){for(var e=-1,i=Object.keys(t),n=i.length,r=Array(n);++er;r++)if("undefined"!=typeof document.body.style[e[r]+i])return e[r]+i;return t},EPUBJS.core.defaults=function(t){for(var e=1,i=arguments.length;i>e;e++){var n=arguments[e];for(var r in n)void 0===t[r]&&(t[r]=n[r])}return t},EPUBJS.core.extend=function(t){var e=[].slice.call(arguments,1);return e.forEach(function(e){e&&Object.getOwnPropertyNames(e).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(e,i))})}),t},EPUBJS.core.insert=function(t,e,i){var n=EPUBJS.core.locationOf(t,e,i);return e.splice(n,0,t),n},EPUBJS.core.locationOf=function(t,e,i,n,r){var o,s=n||0,a=r||e.length,h=parseInt(s+(a-s)/2);return i||(i=function(t,e){return t>e?1:e>t?-1:(t=e)?0:void 0}),0>=a-s?h:(o=i(e[h],t),a-s===1?o>0?h:h+1:0===o?h:-1===o?EPUBJS.core.locationOf(t,e,i,h,a):EPUBJS.core.locationOf(t,e,i,s,h))},EPUBJS.core.indexOfSorted=function(t,e,i,n,r){var o,s=n||0,a=r||e.length,h=parseInt(s+(a-s)/2);return i||(i=function(t,e){return t>e?1:e>t?-1:(t=e)?0:void 0}),0>=a-s?-1:(o=i(e[h],t),a-s===1?0===o?h:-1:0===o?h:-1===o?EPUBJS.core.indexOfSorted(t,e,i,h,a):EPUBJS.core.indexOfSorted(t,e,i,s,h))},EPUBJS.core.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame,EPUBJS.Queue=function(t){this._q=[],this.context=t,this.tick=EPUBJS.core.requestAnimationFrame,this.running=!1},EPUBJS.Queue.prototype.enqueue=function(t,e,i){var n,r,o;return e&&!e.length&&(e=[e]),"function"==typeof t?(n=new RSVP.defer,r=n.promise,o={task:t,args:e,context:i,deferred:n,promise:r}):o={promise:t},this._q.push(o),o.promise},EPUBJS.Queue.prototype.dequeue=function(){var t,e;return this._q.length?(t=this._q.shift(),e=t.task,e?e.apply(t.context||this.context,t.args).then(function(){t.deferred.resolve.apply(t.context||this.context,arguments)}.bind(this)):t.promise):(t=new RSVP.defer,t.deferred.resolve(),t.promise)},EPUBJS.Queue.prototype.flush=function(){for(;this._q.length;)this.dequeue()},EPUBJS.Queue.prototype.run=function(){!this.running&&this._q.length&&(this.running=!0,this.dequeue().then(function(){this.running=!1}.bind(this))),this.tick.call(window,this.run.bind(this))},EPUBJS.Queue.prototype.clear=function(){this._q=[]},EPUBJS.Queue.prototype.length=function(){return this._q.length},EPUBJS.Task=function(t){return function(){var e=arguments||[];return new RSVP.Promise(function(i){var n=function(t){i(t)};e.push(n),t.apply(this,e)}.bind(this))}},EPUBJS.Hook=function(t){this.context=t||this,this.hooks=[]},EPUBJS.Hook.prototype.register=function(t){this.hooks.push(t)},EPUBJS.Hook.prototype.trigger=function(){var t,e=this.hooks.length,i=0,n=new RSVP.defer,r=arguments;return e?(t=this.hooks[i].apply(this.context,r),t.then(function(){return i+=1,e>i?this.hooks[i].apply(this.context,r):void 0}.bind(this))):(t=n.promise,n.resolve()),t},EPUBJS.Parser=function(){},EPUBJS.Parser.prototype.container=function(t){var e,i,n,r;return t?(e=t.querySelector("rootfile"))?(i=e.getAttribute("full-path"),n=EPUBJS.core.uri(i).directory,r=t.xmlEncoding,{packagePath:i,basePath:n,encoding:r}):void console.error("No RootFile Found"):void console.error("Container File Not Found")},EPUBJS.Parser.prototype.identifier=function(t){var e;return t?(e=t.querySelector("metadata"),e?this.getElementText(e,"identifier"):void console.error("No Metadata Found")):void console.error("Package File Not Found")},EPUBJS.Parser.prototype.packageContents=function(t){var e,i,n,r,o,s,a,h,u,c=this;return t?(e=t.querySelector("metadata"))?(i=t.querySelector("manifest"))?(n=t.querySelector("spine"))?(r=c.manifest(i),o=c.findNavPath(i),s=c.findNcxPath(i),a=c.findCoverPath(i),h=Array.prototype.indexOf.call(n.parentNode.childNodes,n),u=c.spine(n,r),{metadata:c.metadata(e),spine:u,manifest:r,navPath:o,ncxPath:s,coverPath:a,spineNodeIndex:h}):void console.error("No Spine Found"):void console.error("No Manifest Found"):void console.error("No Metadata Found"):void console.error("Package File Not Found")},EPUBJS.Parser.prototype.findNavPath=function(t){var e=t.querySelector("item[properties^='nav']");return e?e.getAttribute("href"):!1},EPUBJS.Parser.prototype.findNcxPath=function(t){var e=t.querySelector("item[media-type='application/x-dtbncx+xml']");return e?e.getAttribute("href"):!1},EPUBJS.Parser.prototype.findCoverPath=function(t){var e=t.querySelector("item[properties='cover-image']");return e?e.getAttribute("href"):!1},EPUBJS.Parser.prototype.metadata=function(t){var e={},i=this;return e.title=i.getElementText(t,"title"),e.creator=i.getElementText(t,"creator"),e.description=i.getElementText(t,"description"),e.pubdate=i.getElementText(t,"date"),e.publisher=i.getElementText(t,"publisher"),e.identifier=i.getElementText(t,"identifier"),e.language=i.getElementText(t,"language"),e.rights=i.getElementText(t,"rights"),e.modified_date=i.querySelectorText(t,"meta[property='dcterms:modified']"),e.layout=i.querySelectorText(t,"meta[property='rendition:layout']"),e.orientation=i.querySelectorText(t,"meta[property='rendition:orientation']"),e.spread=i.querySelectorText(t,"meta[property='rendition:spread']"),e},EPUBJS.Parser.prototype.getElementText=function(t,e){var i,n=t.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/",e);return n&&0!==n.length?(i=n[0],i.childNodes.length?i.childNodes[0].nodeValue:""):""},EPUBJS.Parser.prototype.querySelectorText=function(t,e){var i=t.querySelector(e);return i&&i.childNodes.length?i.childNodes[0].nodeValue:""},EPUBJS.Parser.prototype.manifest=function(t){var e={},i=t.querySelectorAll("item"),n=Array.prototype.slice.call(i);return n.forEach(function(t){var i=t.getAttribute("id"),n=t.getAttribute("href")||"",r=t.getAttribute("media-type")||"",o=t.getAttribute("properties")||"";e[i]={href:n,type:r,properties:o}}),e},EPUBJS.Parser.prototype.spine=function(t){var e=[],i=t.getElementsByTagName("itemref"),n=Array.prototype.slice.call(i);return n.forEach(function(t,i){var n=t.getAttribute("idref"),r=t.getAttribute("properties")||"",o=r.length?r.split(" "):[],s={idref:n,linear:t.getAttribute("linear")||"",properties:o,index:i};e.push(s)}),e},EPUBJS.Parser.prototype.nav=function(t){function e(t){var e=[];return Array.prototype.slice.call(t.childNodes).forEach(function(t){"ol"==t.tagName&&Array.prototype.slice.call(t.childNodes).forEach(function(t){"li"==t.tagName&&e.push(t)})}),e}function i(t){var e=null;return Array.prototype.slice.call(t.childNodes).forEach(function(t){("a"==t.tagName||"span"==t.tagName)&&(e=t)}),e}function n(t){var r=[],o=e(t),s=Array.prototype.slice.call(o),a=s.length;return 0===a?!1:(s.forEach(function(e){var o=e.getAttribute("id")||!1,s=i(e),a=s.getAttribute("href")||"",h=s.textContent||"",u=a.split("#"),c=(u[0],n(e));r.push({id:o,href:a,label:h,subitems:c,parent:t?t.getAttribute("id"):null})}),r)}var r=t.querySelector('nav[*|type="toc"]');return r?n(r):[]},EPUBJS.Parser.prototype.ncx=function(t){function e(i){var n=[],r=t.evaluate("*[local-name()='navPoint']",i,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null),o=r.snapshotLength;if(0===o)return[];for(var s=o-1;s>=0;s--){var a=r.snapshotItem(s),h=a.getAttribute("id")||!1,u=a.querySelector("content"),c=u.getAttribute("src"),p=a.querySelector("navLabel"),l=p.textContent?p.textContent:"",d=c.split("#"),f=(d[0],e(a));n.unshift({id:h,href:c,label:l,subitems:f,parent:i?i.getAttribute("id"):null})}return n}var i=t.querySelector("navMap");return i?e(i):[]},EPUBJS.EpubCFI=function(t){return t?this.parse(t):void 0},EPUBJS.EpubCFI.prototype.generateChapterComponent=function(t,e,i){var n=parseInt(e),r=t+1,o="/"+r+"/";return o+=2*(n+1),i&&(o+="["+i+"]"),o},EPUBJS.EpubCFI.prototype.generatePathComponent=function(t){var e=[];return t.forEach(function(t){var i="";i+=2*(t.index+1),t.id&&(i+="["+t.id+"]"),e.push(i)}),e.join("/")},EPUBJS.EpubCFI.prototype.generateCfiFromElement=function(t,e){var i=this.pathTo(t),n=this.generatePathComponent(i);return n.length?"epubcfi("+e+"!"+n+"/1:0)":"epubcfi("+e+"!/4/)"},EPUBJS.EpubCFI.prototype.pathTo=function(t){for(var e,i=[];t&&null!==t.parentNode&&9!=t.parentNode.nodeType;)e=t.parentNode.children,i.unshift({id:t.id,tagName:t.tagName,index:e?Array.prototype.indexOf.call(e,t):0}),t=t.parentNode;return i},EPUBJS.EpubCFI.prototype.getChapterComponent=function(t){var e=t.split("!");return e[0]},EPUBJS.EpubCFI.prototype.getPathComponent=function(t){var e=t.split("!"),i=e[1]?e[1].split(":"):"";return i[0]},EPUBJS.EpubCFI.prototype.getCharecterOffsetComponent=function(t){var e=t.split(":");return e[1]||""},EPUBJS.EpubCFI.prototype.parse=function(t){var e,i,n,r,o,s,a,h,u,c={},p=function(t){var e,i,n,r;return e="element",i=parseInt(t)/2-1,n=t.match(/\[(.*)\]/),n&&n[1]&&(r=n[1]),{type:e,index:i,id:r||!1}};return"string"!=typeof t?{spinePos:-1}:(c.str=t,0===t.indexOf("epubcfi(")&&")"===t[t.length-1]&&(t=t.slice(8,t.length-1)),i=this.getChapterComponent(t),n=this.getPathComponent(t)||"",r=this.getCharecterOffsetComponent(t),i&&(e=i.split("/")[2]||"")?(c.spinePos=parseInt(e)/2-1||0,s=e.match(/\[(.*)\]/),c.spineId=s?s[1]:!1,-1!=n.indexOf(",")&&console.warn("CFI Ranges are not supported"),a=n.split("/"),h=a.pop(),c.steps=[],a.forEach(function(t){var e;t&&(e=p(t),c.steps.push(e))}),u=parseInt(h),isNaN(u)||c.steps.push(u%2===0?p(h):{type:"text",index:(u-1)/2}),o=r.match(/\[(.*)\]/),o&&o[1]?(c.characterOffset=parseInt(r.split("[")[0]),c.textLocationAssertion=o[1]):c.characterOffset=parseInt(r),c):{spinePos:-1})},EPUBJS.EpubCFI.prototype.addMarker=function(t,e,i){var n,r,o,s,a=e||document,h=i||this.createMarker(a);return"string"==typeof t&&(t=this.parse(t)),r=t.steps[t.steps.length-1],-1===t.spinePos?!1:(n=this.findParent(t,a))?(r&&"text"===r.type?(o=n.childNodes[r.index],t.characterOffset?(s=o.splitText(t.characterOffset),h.classList.add("EPUBJS-CFI-SPLIT"),n.insertBefore(h,s)):n.insertBefore(h,o)):n.insertBefore(h,n.firstChild),h):!1},EPUBJS.EpubCFI.prototype.createMarker=function(t){var e=t||document,i=e.createElement("span");return i.id="EPUBJS-CFI-MARKER:"+EPUBJS.core.uuid(),i.classList.add("EPUBJS-CFI-MARKER"),i},EPUBJS.EpubCFI.prototype.removeMarker=function(t,e){t.classList.contains("EPUBJS-CFI-SPLIT")?(nextSib=t.nextSibling,prevSib=t.previousSibling,nextSib&&prevSib&&3===nextSib.nodeType&&3===prevSib.nodeType&&(prevSib.textContent+=nextSib.textContent,t.parentNode.removeChild(nextSib)),t.parentNode.removeChild(t)):t.classList.contains("EPUBJS-CFI-MARKER")&&t.parentNode.removeChild(t)},EPUBJS.EpubCFI.prototype.findParent=function(t,e){var i,n,r,o=e||document,s=o.getElementsByTagName("html")[0],a=Array.prototype.slice.call(s.children);if("string"==typeof t&&(t=this.parse(t)),n=t.steps.slice(0),!n.length)return o.getElementsByTagName("body")[0];for(;n&&n.length>0;){if(i=n.shift(),"text"===i.type?(r=s.childNodes[i.index],s=r.parentNode||s):s=i.id?o.getElementById(i.id):a[i.index],"undefined"==typeof s)return console.error("No Element For",i,t.str),!1;a=Array.prototype.slice.call(s.children)}return s},EPUBJS.EpubCFI.prototype.compare=function(t,e){if("string"==typeof t&&(t=new EPUBJS.EpubCFI(t)),"string"==typeof e&&(e=new EPUBJS.EpubCFI(e)),t.spinePos>e.spinePos)return 1;if(t.spinePose.steps[i].index)return 1;if(t.steps[i].indexe.characterOffset?1:t.characterOffset=0?(o=r.length,t.characterOffset-1?(delete this.spineByHref[t.href],delete this.spineById[t.idref],this.spineItems.splice(e,1)):void 0},EPUBJS.replace={},EPUBJS.replace.links=function(t,e){for(var i=new RSVP.defer,n=t.document.querySelectorAll("a[href]"),r=function(t){var i=t.getAttribute("href"),n=new EPUBJS.core.uri(i);n.protocol?t.setAttribute("target","_blank"):0===i.indexOf("#")||(t.onclick=function(){return e.display(i),!1})},o=0;o=u&&(this.width!=r||this.height!=o)?(this.resize(r,o),setTimeout(function(){u+=1,i&&i(this),this.expand(s,u,i)}.bind(this),c)):s.resolve(),this.width=r,this.height=o,a)},EPUBJS.View.prototype.observe=function(t){var e=this,i=new MutationObserver(function(){e.expand()}),n={attributes:!0,childList:!0,characterData:!0,subtree:!0};return i.observe(t,n),i},EPUBJS.View.prototype.show=function(){var t=this.borders();this.element.style.width=this.width+t.width+"px",this.element.style.height=this.height+t.height+"px",this.iframe.style.visibility="visible",this.shown=!0,this.onShown(this),this.trigger("shown",this)},EPUBJS.View.prototype.hide=function(){this.trigger("hidden")},EPUBJS.View.prototype.position=function(){return this.element.getBoundingClientRect()},EPUBJS.View.prototype.onShown=function(){},EPUBJS.View.prototype.borders=function(){return this.iframe&&!this.iframeStyle&&(this.iframeStyle=window.getComputedStyle(this.iframe),this.paddingTopBottom=parseInt(this.iframeStyle.paddingTop)+parseInt(this.iframeStyle.paddingBottom)||0,this.paddingLeftRight=parseInt(this.iframeStyle.paddingLeft)+parseInt(this.iframeStyle.paddingRight)||0,this.marginTopBottom=parseInt(this.iframeStyle.marginTop)+parseInt(this.iframeStyle.marginBottom)||0,this.marginLeftRight=parseInt(this.iframeStyle.marginLeft)+parseInt(this.iframeStyle.marginRight)||0,this.borderTopBottom=parseInt(this.iframeStyle.borderTop)+parseInt(this.iframeStyle.borderBottom)||0,this.borderLeftRight=parseInt(this.iframeStyle.borderLeft)+parseInt(this.iframeStyle.borderRight)||0),this.element&&!this.elementStyle&&(this.elementStyle=window.getComputedStyle(this.element),this.elpaddingTopBottom=parseInt(this.elementStyle.paddingTop)+parseInt(this.elementStyle.paddingBottom)||0,this.elpaddingLeftRight=parseInt(this.elementStyle.paddingLeft)+parseInt(this.elementStyle.paddingRight)||0,this.elmarginTopBottom=parseInt(this.elementStyle.marginTop)+parseInt(this.elementStyle.marginBottom)||0,this.elmarginLeftRight=parseInt(this.elementStyle.marginLeft)+parseInt(this.elementStyle.marginRight)||0,this.elborderTopBottom=parseInt(this.elementStyle.borderTop)+parseInt(this.elementStyle.borderBottom)||0,this.elborderLeftRight=parseInt(this.elementStyle.borderLeft)+parseInt(this.elementStyle.borderRight)||0),{height:this.paddingTopBottom+this.marginTopBottom+this.borderTopBottom,width:this.paddingLeftRight+this.marginLeftRight+this.borderLeftRight}},EPUBJS.View.prototype.bounds=function(){return{height:this.height+this.paddingTopBottom+this.marginTopBottom+this.borderTopBottom+this.elpaddingTopBottom+this.elmarginTopBottom+this.elborderTopBottom,width:this.width+this.paddingLeftRight+this.marginLeftRight+this.borderLeftRight+this.elpaddingLeftRight+this.elmarginLeftRight+this.elborderLeftRight}},EPUBJS.View.prototype.destroy=function(){this.iframe&&(this.element.removeChild(this.iframe),this.shown=!1,this.iframe=null)},RSVP.EventTarget.mixin(EPUBJS.View.prototype),EPUBJS.Layout=EPUBJS.Layout||{},EPUBJS.Layout.Reflowable=function(t){this.view=t,this.spreadWidth=null},EPUBJS.Layout.Reflowable.prototype.format=function(t,e,i,n){var r=EPUBJS.core.prefixed("columnAxis"),o=EPUBJS.core.prefixed("columnGap"),s=EPUBJS.core.prefixed("columnWidth"),a=EPUBJS.core.prefixed("columnFill"),h=Math.floor(e),u=Math.floor(h/8),c=n>=0?n:u%2===0?u:u-1;return this.documentElement=t,this.spreadWidth=h+c,t.style.overflow="hidden",t.style.width=h+"px",t.style.height=i+"px",t.style[r]="horizontal",t.style[a]="auto",t.style[s]=h+"px",t.style[o]=c+"px",this.colWidth=h,this.gap=c,{pageWidth:this.spreadWidth,pageHeight:i}},EPUBJS.Layout.Reflowable.prototype.calculatePages=function(){var t,e;return this.documentElement.style.width="auto",t=this.documentElement.scrollWidth,e=Math.ceil(t/this.spreadWidth),{displayedPages:e,pageCount:e}},EPUBJS.Layout.ReflowableSpreads=function(t){this.view=t,this.documentElement=t.document.documentElement,this.spreadWidth=null},EPUBJS.Layout.ReflowableSpreads.prototype.format=function(t,e,i){var n=EPUBJS.core.prefixed("columnAxis"),r=EPUBJS.core.prefixed("columnGap"),o=EPUBJS.core.prefixed("columnWidth"),s=EPUBJS.core.prefixed("columnFill"),a=2,h=Math.floor(t),u=h%2===0?h:h-1,c=Math.floor(u/8),p=i>=0?i:c%2===0?c:c-1,l=Math.floor((u-p)/a);return this.spreadWidth=(l+p)*a,this.view.document.documentElement.style.overflow="hidden",this.view.document.body.style.width=u+"px",this.view.document.body.style.height=e+"px",this.view.document.body.style[n]="horizontal",this.view.document.body.style[s]="auto",this.view.document.body.style[r]=p+"px",this.view.document.body.style[o]=l+"px",this.colWidth=l,this.gap=p,{pageWidth:this.spreadWidth,pageHeight:e}},EPUBJS.Layout.ReflowableSpreads.prototype.calculatePages=function(){var t=this.documentElement.scrollWidth,e=Math.ceil(t/this.spreadWidth);return{displayedPages:e,pageCount:2*e}},EPUBJS.Layout.Fixed=function(){this.documentElement=null},EPUBJS.Layout.Fixed=function(t){var e,i,n,r,o=EPUBJS.core.prefixed("columnWidth"),s=t.querySelector("[name=viewport");return this.documentElement=t,s&&s.hasAttribute("content")&&(e=s.getAttribute("content"),i=e.split(","),i[0]&&(n=i[0].replace("width=","")),i[1]&&(r=i[1].replace("height=",""))),t.style.width=n+"px"||"auto",t.style.height=r+"px"||"auto",t.style[o]="auto",t.style.overflow="auto",this.colWidth=n,this.gap=0,{pageWidth:n,pageHeight:r}},EPUBJS.Layout.Fixed.prototype.calculatePages=function(){return{displayedPages:1,pageCount:1}},EPUBJS.Infinite=function(t){this.container=t,this.windowHeight=window.innerHeight,this.tick=EPUBJS.core.requestAnimationFrame,this.scrolled=!1,this.ignore=!1,this.tolerance=100,this.prevScrollTop=0,this.prevScrollLeft=0,t&&this.start()},EPUBJS.Infinite.prototype.start=function(){this.container.addEventListener("scroll",function(){this.ignore?this.ignore=!1:this.scrolled=!0}.bind(this)),window.addEventListener("unload",function(){this.ignore=!0}),this.tick.call(window,this.check.bind(this)),this.scrolled=!1},EPUBJS.Infinite.prototype.forwards=function(){this.trigger("forwards")},EPUBJS.Infinite.prototype.backwards=function(){this.trigger("backwards")},EPUBJS.Infinite.prototype.check=function(){this.scrolled&&!this.ignore?(scrollTop=this.container.scrollTop,scrollLeft=this.container.scrollLeft,this.trigger("scroll",{top:scrollTop,left:scrollLeft}),scrollTop-this.prevScrollTop>this.tolerance&&this.forwards(),scrollTop-this.prevScrollTop<-this.tolerance&&this.backwards(),scrollLeft-this.prevScrollLeft>this.tolerance&&this.forwards(),scrollLeft-this.prevScrollLeft<-this.tolerance&&this.backwards(),this.prevScrollTop=scrollTop,this.prevScrollLeft=scrollLeft,this.scrolled=!1):(this.ignore=!1,this.scrolled=!1),this.tick.call(window,this.check.bind(this))},EPUBJS.Infinite.prototype.scrollBy=function(t,e,i){i&&(this.ignore=!0),this.container.scrollLeft+=t,this.container.scrollTop+=e,this.scrolled=!0,this.check()},EPUBJS.Infinite.prototype.scrollTo=function(t,e,i){i&&(this.ignore=!0),this.container.scrollLeft=t,this.container.scrollTop=e,this.scrolled=!0,this.check()},RSVP.EventTarget.mixin(EPUBJS.Infinite.prototype),EPUBJS.Rendition=function(t,e){this.settings=EPUBJS.core.extend(this.settings||{},{infinite:!0,hidden:!1,width:!1,height:!1}),EPUBJS.core.extend(this.settings,e),this.book=t,this.settings.hidden&&(this.wrapper=this.wrap(this.container)),this.views=[],this.hooks={},this.hooks.display=new EPUBJS.Hook(this),this.hooks.replacements=new EPUBJS.Hook(this),this.hooks.replacements.register(EPUBJS.replace.links.bind(this)),this.q=new EPUBJS.Queue(this),this.q.enqueue(this.book.opened)},EPUBJS.Rendition.prototype.initialize=function(t){{var e,i=t||{},n=i.height!==!1?i.height:"100%",r=i.width!==!1?i.width:"100%";i.hidden||!1}return i.height&&EPUBJS.core.isNumber(i.height)&&(n=i.height+"px"),i.width&&EPUBJS.core.isNumber(i.width)&&(r=i.width+"px"),e=document.createElement("div"),"horizontal"===this.settings.axis&&(e.style.whiteSpace="nowrap"),i.width&&(e.style.width=r),i.height&&(e.style.height=n),e.style.overflow=this.settings.overflow,e},EPUBJS.Rendition.wrap=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},EPUBJS.Rendition.prototype.attachTo=function(t){var e;return this.container=this.initialize({width:this.settings.width,height:this.settings.height}),EPUBJS.core.isElement(t)?this.element=t:"string"==typeof t&&(this.element=document.getElementById(t)),this.element?("100%"===this.settings.height&&(e=this.element.getBoundingClientRect(),this.container.style.height=e.height+"px"),"100%"===this.settings.width&&(e=e||this.element.getBoundingClientRect(),this.container.style.width=e.width+"px"),this.element.appendChild(this.container),this.attachListeners(),void this.q.run()):void console.error("Not an Element")},EPUBJS.Rendition.prototype.attachListeners=function(){window.addEventListener("resize",this.onResized.bind(this),!1)},EPUBJS.Rendition.prototype.bounds=function(){return this.container.getBoundingClientRect()},EPUBJS.Rendition.prototype.display=function(t){return this.q.enqueue(function(t){var e,i=new RSVP.defer,n=i.promise,r=this.book.spine.get(t);return this.displaying=!0,r?(e=new EPUBJS.View(r),this.append(e),e.displayed.then(function(){this.trigger("displayed",r),this.displaying=!1,i.resolve(this)}.bind(this))):i.reject(new Error("No Section Found")),n},t)},EPUBJS.Rendition.prototype.moveTo=function(){},EPUBJS.Rendition.prototype.render=function(t){return this.rendering=!0,t.create(),t.display(this.book.request).then(function(){return this.hooks.display.trigger(t)}.bind(this)).then(function(){return this.hooks.replacements.trigger(t,this)}.bind(this)).then(function(){return t.expand()}.bind(this)).then(function(){return t.show(),this.trigger("rendered",t.section),this.rendering=!1,t}.bind(this)).catch(function(t){this.trigger("loaderror",t)}.bind(this))},EPUBJS.Rendition.prototype.afterDisplayed=function(){},EPUBJS.Rendition.prototype.append=function(t){this.clear(),this.views.push(t),this.container.appendChild(t.element),this.render(t),t.onShown=this.afterDisplayed.bind(this)},EPUBJS.Rendition.prototype.clear=function(){this.views.forEach(function(t){this.remove(t)}.bind(this))},EPUBJS.Rendition.prototype.remove=function(t){var e=this.views.indexOf(t);e>-1&&this.views.splice(e,1),this.container.removeChild(t.element),t.shown&&t.destroy(),t=null},EPUBJS.Rendition.prototype.resizeView=function(t){var e=this.container.getBoundingClientRect(),i=window.getComputedStyle(this.container),n={left:parseFloat(i["padding-left"])||0,right:parseFloat(i["padding-right"])||0,top:parseFloat(i["padding-top"])||0,bottom:parseFloat(i["padding-bottom"])||0},r=e.width-n.left-n.right,o=e.height-n.top-n.bottom;"vertical"===this.settings.axis?t.resize(r,0):t.resize(0,o)},EPUBJS.Rendition.prototype.resize=function(t,e){var i=t,n=e,r=window.getComputedStyle(this.container),o={left:parseFloat(r["padding-left"])||0,right:parseFloat(r["padding-right"])||0,top:parseFloat(r["padding-top"])||0,bottom:parseFloat(r["padding-bottom"])||0},s=i-o.left-o.right,a=n-o.top-o.bottom;t||(i=window.innerWidth),e||(n=window.innerHeight),this.trigger("resized",{width:this.width,height:this.height}),this.views.forEach(function(t){"vertical"===this.settings.axis?t.resize(s,0):t.resize(0,a)}.bind(this))},EPUBJS.Rendition.prototype.onResized=function(){var t=this.element.getBoundingClientRect();this.resize(t.width,t.height)},EPUBJS.Rendition.prototype.next=function(){var t,e=this.views[0].section.next();e&&(t=new EPUBJS.View(e),this.append(t))},EPUBJS.Rendition.prototype.prev=function(){var t,e=this.views[0].section.prev();e&&(t=new EPUBJS.View(e),this.append(t))},RSVP.EventTarget.mixin(EPUBJS.Rendition.prototype),EPUBJS.Continuous=function(t,e){EPUBJS.Rendition.apply(this,arguments),this.settings=EPUBJS.core.extend(this.settings||{},{infinite:!0,hidden:!1,width:!1,height:!1,overflow:"auto",axis:"vertical",offset:500}),EPUBJS.core.extend(this.settings,e),this.settings.hidden&&(this.wrapper=this.wrap(this.container))},EPUBJS.Continuous.prototype=Object.create(EPUBJS.Rendition.prototype),EPUBJS.Continuous.prototype.constructor=EPUBJS.Continuous,EPUBJS.Continuous.prototype.attachListeners=function(){window.addEventListener("resize",this.onResized.bind(this),!1),this.settings.infinite&&(this.infinite=new EPUBJS.Infinite(this.container),this.infinite.on("scroll",this.check.bind(this)))},EPUBJS.Continuous.prototype.display=function(t){return this.q.enqueue(function(t){var e,i=new RSVP.defer,n=i.promise,r=this.book.spine.get(t);return this.displaying=!0,r?(e=new EPUBJS.View(r),this.fill(e),this.check(),e.displayed.then(function(){this.trigger("displayed",r),this.displaying=!1,i.resolve(this)}.bind(this))):i.reject(new Error("No Section Found")),n},t)},EPUBJS.Continuous.prototype.moveTo=function(){},EPUBJS.Continuous.prototype.afterDisplayed=function(t){var e,i,n=t.section.next(),r=t.section.prev(),o=this.views.indexOf(t);o+1===this.views.length&&n&&(i=new EPUBJS.View(n),this.append(i)),0===o&&r&&(e=new EPUBJS.View(r),this.prepend(e)),t.onShown=this.afterDisplayed.bind(this)},EPUBJS.Continuous.prototype.afterDisplayedAbove=function(t){var e=t.bounds();return t.countered?void this.afterDisplayed(t):("vertical"===this.settings.axis?this.infinite.scrollBy(0,e.height,!0):this.infinite.scrollBy(e.width,0,!0),t.countered=!0,this.afterDisplayed(t),void(this.afterDisplayedAboveHook&&this.afterDisplayedAboveHook(t)))},EPUBJS.Continuous.prototype.removeShownListeners=function(t){t.onShown=function(){}},EPUBJS.Continuous.prototype.append=function(t){this.views.push(t),this.container.appendChild(t.element),t.onShown=this.afterDisplayed.bind(this)},EPUBJS.Continuous.prototype.prepend=function(t){this.views.unshift(t),this.container.insertBefore(t.element,this.container.firstChild),t.onShown=this.afterDisplayedAbove.bind(this)},EPUBJS.Continuous.prototype.fill=function(t){this.views.length&&this.clear(),this.views.push(t),this.container.appendChild(t.element),t.onShown=this.afterDisplayed.bind(this)},EPUBJS.Continuous.prototype.insert=function(t,e){this.views.splice(e,0,t),e-1&&this.views.splice(e,1),this.container.removeChild(t.element),t.shown&&t.destroy(),t=null},EPUBJS.Continuous.prototype.clear=function(){this.views.forEach(function(t){t.destroy()}),this.views=[]},EPUBJS.Continuous.prototype.first=function(){return this.views[0]},EPUBJS.Continuous.prototype.last=function(){return this.views[this.views.length-1]},EPUBJS.Continuous.prototype.each=function(t){return this.views.forEach(t)},EPUBJS.Continuous.prototype.isVisible=function(t,e){var i=t.position(),n=e||this.container.getBoundingClientRect();i.bottom>=n.top-this.settings.offset&&!(i.top>n.bottom)&&i.right>=n.left&&!(i.left>n.right+this.settings.offset)?t.shown||this.rendering||this.render(t).then(function(){this.check()}.bind(this)):t.shown&&t.destroy()},EPUBJS.Continuous.prototype.check=function(){var t=this.container.getBoundingClientRect();this.views.forEach(function(e){this.isVisible(e,t)}.bind(this)),clearTimeout(this.trimTimeout),this.trimTimeout=setTimeout(function(){this.trim()}.bind(this),250)},EPUBJS.Continuous.prototype.trim=function(){for(var t=!0,e=0;e0?this.views[e-1].shown:!1,r=e+1=0;r--)if(t=this.views[r],e=t.bounds().top,e=0?(o=r.length,t.characterOffset-1?(delete this.spineByHref[t.href],delete this.spineById[t.idref],this.spineItems.splice(e,1)):void 0},EPUBJS.replace={},EPUBJS.replace.links=function(t,e){for(var i=new RSVP.defer,n=t.document.querySelectorAll("a[href]"),r=function(t){var i=t.getAttribute("href"),n=new EPUBJS.core.uri(i);n.protocol?t.setAttribute("target","_blank"):0===i.indexOf("#")||(t.onclick=function(){return e.display(i),!1})},o=0;o=u&&(this.width!=r||this.height!=o)?(this.resize(r,o),setTimeout(function(){u+=1,i&&i(this),this.expand(s,u,i)}.bind(this),c)):s.resolve(),this.width=r,this.height=o,a)},EPUBJS.View.prototype.observe=function(t){var e=this,i=new MutationObserver(function(){e.expand()}),n={attributes:!0,childList:!0,characterData:!0,subtree:!0};return i.observe(t,n),i},EPUBJS.View.prototype.show=function(){var t=this.borders();this.element.style.width=this.width+t.width+"px",this.element.style.height=this.height+t.height+"px",this.iframe.style.visibility="visible",this.shown=!0,this.onShown(this),this.trigger("shown",this)},EPUBJS.View.prototype.hide=function(){this.trigger("hidden")},EPUBJS.View.prototype.position=function(){return this.element.getBoundingClientRect()},EPUBJS.View.prototype.onShown=function(){},EPUBJS.View.prototype.borders=function(){return this.iframe&&!this.iframeStyle&&(this.iframeStyle=window.getComputedStyle(this.iframe),this.paddingTopBottom=parseInt(this.iframeStyle.paddingTop)+parseInt(this.iframeStyle.paddingBottom)||0,this.paddingLeftRight=parseInt(this.iframeStyle.paddingLeft)+parseInt(this.iframeStyle.paddingRight)||0,this.marginTopBottom=parseInt(this.iframeStyle.marginTop)+parseInt(this.iframeStyle.marginBottom)||0,this.marginLeftRight=parseInt(this.iframeStyle.marginLeft)+parseInt(this.iframeStyle.marginRight)||0,this.borderTopBottom=parseInt(this.iframeStyle.borderTop)+parseInt(this.iframeStyle.borderBottom)||0,this.borderLeftRight=parseInt(this.iframeStyle.borderLeft)+parseInt(this.iframeStyle.borderRight)||0),this.element&&!this.elementStyle&&(this.elementStyle=window.getComputedStyle(this.element),this.elpaddingTopBottom=parseInt(this.elementStyle.paddingTop)+parseInt(this.elementStyle.paddingBottom)||0,this.elpaddingLeftRight=parseInt(this.elementStyle.paddingLeft)+parseInt(this.elementStyle.paddingRight)||0,this.elmarginTopBottom=parseInt(this.elementStyle.marginTop)+parseInt(this.elementStyle.marginBottom)||0,this.elmarginLeftRight=parseInt(this.elementStyle.marginLeft)+parseInt(this.elementStyle.marginRight)||0,this.elborderTopBottom=parseInt(this.elementStyle.borderTop)+parseInt(this.elementStyle.borderBottom)||0,this.elborderLeftRight=parseInt(this.elementStyle.borderLeft)+parseInt(this.elementStyle.borderRight)||0),{height:this.paddingTopBottom+this.marginTopBottom+this.borderTopBottom,width:this.paddingLeftRight+this.marginLeftRight+this.borderLeftRight}},EPUBJS.View.prototype.bounds=function(){return{height:this.height+this.paddingTopBottom+this.marginTopBottom+this.borderTopBottom+this.elpaddingTopBottom+this.elmarginTopBottom+this.elborderTopBottom,width:this.width+this.paddingLeftRight+this.marginLeftRight+this.borderLeftRight+this.elpaddingLeftRight+this.elmarginLeftRight+this.elborderLeftRight}},EPUBJS.View.prototype.destroy=function(){this.iframe&&(this.element.removeChild(this.iframe),this.shown=!1,this.iframe=null)},RSVP.EventTarget.mixin(EPUBJS.View.prototype),EPUBJS.Layout=EPUBJS.Layout||{},EPUBJS.Layout.Reflowable=function(t){this.view=t,this.spreadWidth=null},EPUBJS.Layout.Reflowable.prototype.format=function(t,e,i,n){var r=EPUBJS.core.prefixed("columnAxis"),o=EPUBJS.core.prefixed("columnGap"),s=EPUBJS.core.prefixed("columnWidth"),a=EPUBJS.core.prefixed("columnFill"),h=Math.floor(e),u=Math.floor(h/8),c=n>=0?n:u%2===0?u:u-1;return this.documentElement=t,this.spreadWidth=h+c,t.style.overflow="hidden",t.style.width=h+"px",t.style.height=i+"px",t.style[r]="horizontal",t.style[a]="auto",t.style[s]=h+"px",t.style[o]=c+"px",this.colWidth=h,this.gap=c,{pageWidth:this.spreadWidth,pageHeight:i}},EPUBJS.Layout.Reflowable.prototype.calculatePages=function(){var t,e;return this.documentElement.style.width="auto",t=this.documentElement.scrollWidth,e=Math.ceil(t/this.spreadWidth),{displayedPages:e,pageCount:e}},EPUBJS.Layout.ReflowableSpreads=function(t){this.view=t,this.documentElement=t.document.documentElement,this.spreadWidth=null},EPUBJS.Layout.ReflowableSpreads.prototype.format=function(t,e,i){var n=EPUBJS.core.prefixed("columnAxis"),r=EPUBJS.core.prefixed("columnGap"),o=EPUBJS.core.prefixed("columnWidth"),s=EPUBJS.core.prefixed("columnFill"),a=2,h=Math.floor(t),u=h%2===0?h:h-1,c=Math.floor(u/8),p=i>=0?i:c%2===0?c:c-1,l=Math.floor((u-p)/a);return this.spreadWidth=(l+p)*a,this.view.document.documentElement.style.overflow="hidden",this.view.document.body.style.width=u+"px",this.view.document.body.style.height=e+"px",this.view.document.body.style[n]="horizontal",this.view.document.body.style[s]="auto",this.view.document.body.style[r]=p+"px",this.view.document.body.style[o]=l+"px",this.colWidth=l,this.gap=p,{pageWidth:this.spreadWidth,pageHeight:e}},EPUBJS.Layout.ReflowableSpreads.prototype.calculatePages=function(){var t=this.documentElement.scrollWidth,e=Math.ceil(t/this.spreadWidth);return{displayedPages:e,pageCount:2*e}},EPUBJS.Layout.Fixed=function(){this.documentElement=null},EPUBJS.Layout.Fixed=function(t){var e,i,n,r,o=EPUBJS.core.prefixed("columnWidth"),s=t.querySelector("[name=viewport");return this.documentElement=t,s&&s.hasAttribute("content")&&(e=s.getAttribute("content"),i=e.split(","),i[0]&&(n=i[0].replace("width=","")),i[1]&&(r=i[1].replace("height=",""))),t.style.width=n+"px"||"auto",t.style.height=r+"px"||"auto",t.style[o]="auto",t.style.overflow="auto",this.colWidth=n,this.gap=0,{pageWidth:n,pageHeight:r}},EPUBJS.Layout.Fixed.prototype.calculatePages=function(){return{displayedPages:1,pageCount:1}},EPUBJS.Infinite=function(t){this.container=t,this.windowHeight=window.innerHeight,this.tick=EPUBJS.core.requestAnimationFrame,this.scrolled=!1,this.ignore=!1,this.tolerance=100,this.prevScrollTop=0,this.prevScrollLeft=0,t&&this.start()},EPUBJS.Infinite.prototype.start=function(){this.container.addEventListener("scroll",function(){this.ignore?this.ignore=!1:this.scrolled=!0}.bind(this)),window.addEventListener("unload",function(){this.ignore=!0}),this.tick.call(window,this.check.bind(this)),this.scrolled=!1},EPUBJS.Infinite.prototype.forwards=function(){this.trigger("forwards")},EPUBJS.Infinite.prototype.backwards=function(){this.trigger("backwards")},EPUBJS.Infinite.prototype.check=function(){this.scrolled&&!this.ignore?(scrollTop=this.container.scrollTop,scrollLeft=this.container.scrollLeft,this.trigger("scroll",{top:scrollTop,left:scrollLeft}),scrollTop-this.prevScrollTop>this.tolerance&&this.forwards(),scrollTop-this.prevScrollTop<-this.tolerance&&this.backwards(),scrollLeft-this.prevScrollLeft>this.tolerance&&this.forwards(),scrollLeft-this.prevScrollLeft<-this.tolerance&&this.backwards(),this.prevScrollTop=scrollTop,this.prevScrollLeft=scrollLeft,this.scrolled=!1):(this.ignore=!1,this.scrolled=!1),this.tick.call(window,this.check.bind(this))},EPUBJS.Infinite.prototype.scrollBy=function(t,e,i){i&&(this.ignore=!0),this.container.scrollLeft+=t,this.container.scrollTop+=e,this.scrolled=!0,this.check()},EPUBJS.Infinite.prototype.scrollTo=function(t,e,i){i&&(this.ignore=!0),this.container.scrollLeft=t,this.container.scrollTop=e,this.scrolled=!0,this.check()},RSVP.EventTarget.mixin(EPUBJS.Infinite.prototype),EPUBJS.Rendition=function(t,e){this.settings=EPUBJS.core.extend(this.settings||{},{infinite:!0,hidden:!1,width:!1,height:!1}),EPUBJS.core.extend(this.settings,e),this.book=t,this.settings.hidden&&(this.wrapper=this.wrap(this.container)),this.views=[],this.hooks={},this.hooks.display=new EPUBJS.Hook(this),this.hooks.replacements=new EPUBJS.Hook(this),this.hooks.replacements.register(EPUBJS.replace.links.bind(this)),this.q=new EPUBJS.Queue(this),this.q.enqueue(this.book.opened)},EPUBJS.Rendition.prototype.initialize=function(t){{var e,i=t||{},n=i.height!==!1?i.height:"100%",r=i.width!==!1?i.width:"100%";i.hidden||!1}return i.height&&EPUBJS.core.isNumber(i.height)&&(n=i.height+"px"),i.width&&EPUBJS.core.isNumber(i.width)&&(r=i.width+"px"),e=document.createElement("div"),"horizontal"===this.settings.axis&&(e.style.whiteSpace="nowrap"),i.width&&(e.style.width=r),i.height&&(e.style.height=n),e.style.overflow=this.settings.overflow,e},EPUBJS.Rendition.wrap=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},EPUBJS.Rendition.prototype.attachTo=function(t){var e;return this.container=this.initialize({width:this.settings.width,height:this.settings.height}),EPUBJS.core.isElement(t)?this.element=t:"string"==typeof t&&(this.element=document.getElementById(t)),this.element?("100%"===this.settings.height&&(e=this.element.getBoundingClientRect(),this.container.style.height=e.height+"px"),"100%"===this.settings.width&&(e=e||this.element.getBoundingClientRect(),this.container.style.width=e.width+"px"),this.element.appendChild(this.container),this.attachListeners(),void this.q.run()):void console.error("Not an Element")},EPUBJS.Rendition.prototype.attachListeners=function(){window.addEventListener("resize",this.onResized.bind(this),!1)},EPUBJS.Rendition.prototype.bounds=function(){return this.container.getBoundingClientRect()},EPUBJS.Rendition.prototype.display=function(t){return this.q.enqueue(function(t){var e,i=new RSVP.defer,n=i.promise,r=this.book.spine.get(t);return this.displaying=!0,r?(e=new EPUBJS.View(r),this.append(e),e.displayed.then(function(){this.trigger("displayed",r),this.displaying=!1,i.resolve(this)}.bind(this))):i.reject(new Error("No Section Found")),n},t)},EPUBJS.Rendition.prototype.moveTo=function(){},EPUBJS.Rendition.prototype.render=function(t){return this.rendering=!0,t.create(),t.display(this.book.request).then(function(){return this.hooks.display.trigger(t)}.bind(this)).then(function(){return this.hooks.replacements.trigger(t,this)}.bind(this)).then(function(){return t.expand()}.bind(this)).then(function(){return t.show(),this.trigger("rendered",t.section),this.rendering=!1,t}.bind(this)).catch(function(t){this.trigger("loaderror",t)}.bind(this))},EPUBJS.Rendition.prototype.afterDisplayed=function(){},EPUBJS.Rendition.prototype.append=function(t){this.clear(),this.views.push(t),this.container.appendChild(t.element),this.render(t),t.onShown=this.afterDisplayed.bind(this)},EPUBJS.Rendition.prototype.clear=function(){this.views.forEach(function(t){this.remove(t)}.bind(this))},EPUBJS.Rendition.prototype.remove=function(t){var e=this.views.indexOf(t);e>-1&&this.views.splice(e,1),this.container.removeChild(t.element),t.shown&&t.destroy(),t=null},EPUBJS.Rendition.prototype.resizeView=function(t){var e=this.container.getBoundingClientRect(),i=window.getComputedStyle(this.container),n={left:parseFloat(i["padding-left"])||0,right:parseFloat(i["padding-right"])||0,top:parseFloat(i["padding-top"])||0,bottom:parseFloat(i["padding-bottom"])||0},r=e.width-n.left-n.right,o=e.height-n.top-n.bottom;"vertical"===this.settings.axis?t.resize(r,0):t.resize(0,o)},EPUBJS.Rendition.prototype.resize=function(t,e){var i=t,n=e,r=window.getComputedStyle(this.container),o={left:parseFloat(r["padding-left"])||0,right:parseFloat(r["padding-right"])||0,top:parseFloat(r["padding-top"])||0,bottom:parseFloat(r["padding-bottom"])||0},s=i-o.left-o.right,a=n-o.top-o.bottom;t||(i=window.innerWidth),e||(n=window.innerHeight),this.trigger("resized",{width:this.width,height:this.height}),this.views.forEach(function(t){"vertical"===this.settings.axis?t.resize(s,0):t.resize(0,a)}.bind(this))},EPUBJS.Rendition.prototype.onResized=function(){var t=this.element.getBoundingClientRect();this.resize(t.width,t.height)},EPUBJS.Rendition.prototype.next=function(){var t,e=this.views[0].section.next();e&&(t=new EPUBJS.View(e),this.append(t))},EPUBJS.Rendition.prototype.prev=function(){var t,e=this.views[0].section.prev();e&&(t=new EPUBJS.View(e),this.append(t))},RSVP.EventTarget.mixin(EPUBJS.Rendition.prototype),EPUBJS.Continuous=function(t,e){EPUBJS.Rendition.apply(this,arguments),this.settings=EPUBJS.core.extend(this.settings||{},{infinite:!0,hidden:!1,width:!1,height:!1,overflow:"auto",axis:"vertical",offset:500}),EPUBJS.core.extend(this.settings,e),this.settings.hidden&&(this.wrapper=this.wrap(this.container))},EPUBJS.Continuous.prototype=Object.create(EPUBJS.Rendition.prototype),EPUBJS.Continuous.prototype.constructor=EPUBJS.Continuous,EPUBJS.Continuous.prototype.attachListeners=function(){window.addEventListener("resize",this.onResized.bind(this),!1),this.settings.infinite&&(this.infinite=new EPUBJS.Infinite(this.container),this.infinite.on("scroll",this.check.bind(this)))},EPUBJS.Continuous.prototype.display=function(t){return this.q.enqueue(function(t){var e,i=new RSVP.defer,n=i.promise,r=this.book.spine.get(t);return this.displaying=!0,r?(e=new EPUBJS.View(r),this.fill(e),this.check(),e.displayed.then(function(){this.trigger("displayed",r),this.displaying=!1,i.resolve(this)}.bind(this))):i.reject(new Error("No Section Found")),n},t)},EPUBJS.Continuous.prototype.moveTo=function(){},EPUBJS.Continuous.prototype.afterDisplayed=function(t){var e,i,n=t.section.next(),r=t.section.prev(),o=this.views.indexOf(t);o+1===this.views.length&&n&&(i=new EPUBJS.View(n),this.append(i)),0===o&&r&&(e=new EPUBJS.View(r),this.prepend(e)),t.onShown=this.afterDisplayed.bind(this)},EPUBJS.Continuous.prototype.afterDisplayedAbove=function(t){var e=t.bounds();return t.countered?void this.afterDisplayed(t):("vertical"===this.settings.axis?this.infinite.scrollBy(0,e.height,!0):this.infinite.scrollBy(e.width,0,!0),t.countered=!0,this.afterDisplayed(t),void(this.afterDisplayedAboveHook&&this.afterDisplayedAboveHook(t)))},EPUBJS.Continuous.prototype.removeShownListeners=function(t){t.onShown=function(){}},EPUBJS.Continuous.prototype.append=function(t){this.views.push(t),this.container.appendChild(t.element),t.onShown=this.afterDisplayed.bind(this)},EPUBJS.Continuous.prototype.prepend=function(t){this.views.unshift(t),this.container.insertBefore(t.element,this.container.firstChild),t.onShown=this.afterDisplayedAbove.bind(this)},EPUBJS.Continuous.prototype.fill=function(t){this.views.length&&this.clear(),this.views.push(t),this.container.appendChild(t.element),t.onShown=this.afterDisplayed.bind(this)},EPUBJS.Continuous.prototype.insert=function(t,e){this.views.splice(e,0,t),e-1&&this.views.splice(e,1),this.container.removeChild(t.element),t.shown&&t.destroy(),t=null},EPUBJS.Continuous.prototype.clear=function(){this.views.forEach(function(t){t.destroy()}),this.views=[]},EPUBJS.Continuous.prototype.first=function(){return this.views[0]},EPUBJS.Continuous.prototype.last=function(){return this.views[this.views.length-1]},EPUBJS.Continuous.prototype.each=function(t){return this.views.forEach(t)},EPUBJS.Continuous.prototype.isVisible=function(t,e){var i=t.position(),n=e||this.container.getBoundingClientRect();i.bottom>=n.top-this.settings.offset&&!(i.top>n.bottom)&&i.right>=n.left&&!(i.left>n.right+this.settings.offset)?t.shown||this.rendering||this.render(t).then(function(){this.check()}.bind(this)):t.shown&&t.destroy()},EPUBJS.Continuous.prototype.check=function(){var t=this.container.getBoundingClientRect();this.views.forEach(function(e){this.isVisible(e,t)}.bind(this)),clearTimeout(this.trimTimeout),this.trimTimeout=setTimeout(function(){this.trim()}.bind(this),250)},EPUBJS.Continuous.prototype.trim=function(){for(var t=!0,e=0;e0?this.views[e-1].shown:!1,r=e+1=0;r--)if(t=this.views[r],e=t.bounds().top,e