From 1fdbf609f5b7bf6e70c6eb30fb87b8a3454106da Mon Sep 17 00:00:00 2001 From: Fred Chasen Date: Thu, 4 Sep 2014 10:58:05 -0400 Subject: [PATCH] updated bower, bug fixes --- bower.json | 26 ++++++++++++++++++++------ dist/epub.js | 29 ++++++++++++++++++++--------- dist/epub.min.js | 4 ++-- examples/basic.html | 7 ++++--- examples/pages.html | 6 +++--- lib/epubjs/pagination.js | 4 ++++ lib/epubjs/renderer.js | 23 +++++++++++++++-------- lib/epubjs/view.js | 2 +- 8 files changed, 69 insertions(+), 32 deletions(-) diff --git a/bower.json b/bower.json index 3457eea..c16dba5 100644 --- a/bower.json +++ b/bower.json @@ -5,7 +5,7 @@ "Fred Chasen " ], "description": "Enhanced eBooks in the browser.", - "main": "lib/epub.js", + "main": "dist/epub.js", "moduleType": [ "amd", "globals", @@ -21,12 +21,26 @@ "node_modules", "bower_components", "test", - "tests" + "tools", + "books", + "examples" ], "devDependencies": { - "qunit": "~1.14.0", - "jquery": "~2.1.1", - "rsvp": "~3.0.8", - "uri.js": "~1.13.2" + "colors": "^0.6.2", + "connect": "^3.0.1", + "express": "^4.5.1", + "gulp": "^3.8.7", + "gulp-concat": "^2.3.4", + "gulp-connect": "~2.0.6", + "gulp-jshint": "^1.8.4", + "gulp-plumber": "^0.6.4", + "gulp-rename": "^1.2.0", + "gulp-uglify": "^0.3.1", + "gulp-util": "^3.0.0", + "morgan": "^1.1.1", + "optimist": "^0.6.1", + "portfinder": "^0.2.1", + "qunitjs": "^1.14.0", + "serve-static": "^1.3.1" } } diff --git a/dist/epub.js b/dist/epub.js index b2bceee..038d728 100644 --- a/dist/epub.js +++ b/dist/epub.js @@ -5948,6 +5948,10 @@ EPUBJS.Paginate.prototype.prev = function(){ console.log("prev", this.formated.pageWidth) this.renderer.infinite.scrollBy(-this.formated.pageWidth, 0); }; + +EPUBJS.Paginate.prototype.display = function(what){ + return this.renderer.display(what) +}; EPUBJS.Parser = function(){}; EPUBJS.Parser.prototype.container = function(containerXml){ @@ -6497,6 +6501,8 @@ EPUBJS.Renderer.prototype.display = function(what){ var displaying = new RSVP.defer(); var displayed = displaying.promise; + // TODO: check for fragments + // Clear views this.clear(); @@ -6761,22 +6767,27 @@ EPUBJS.Renderer.prototype.replacements = function(view, renderer) { var links = view.document.querySelectorAll("a[href]"); var replaceLinks = function(link){ var href = link.getAttribute("href"); - var isRelative = href.search("://"); - // var directory = EPUBJS.core.uri(view.window.location.href).directory; - // var relative; + var uri = new EPUBJS.core.uri(href); - if(isRelative != -1){ + if(uri.protocol){ link.setAttribute("target", "_blank"); }else{ // relative = EPUBJS.core.resolveUrl(directory, href); + // if(uri.fragment && !base) { + // link.onclick = function(){ + // renderer.fragment(href); + // return false; + // }; + // } else { + link.onclick = function(){ + renderer.display(href); + return false; + }; + //} - link.onclick = function(){ - renderer.display(href); - return false; - }; } }; @@ -7053,7 +7064,7 @@ EPUBJS.View.prototype.display = function(contents) { // Reset Body Styles this.document.body.style.margin = "0"; - // this.document.body.style.display = "inline-block"; + this.document.body.style.display = "inline-block"; this.document.documentElement.style.width = "auto"; setTimeout(function(){ diff --git a/dist/epub.min.js b/dist/epub.min.js index e5c92b1..aea1f4e 100644 --- a/dist/epub.min.js +++ b/dist/epub.min.js @@ -1,3 +1,3 @@ "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,r){e.Render[t]=r}},"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,r;!function(){var t={},i={};e=function(e,r,i){t[e]={deps:r,callback:i}},r=function(e){function n(t){if("."!==t.charAt(0))return t;for(var r=t.split("/"),i=e.split("/").slice(0,-1),n=0,s=r.length;s>n;n++){var o=r[n];if(".."===o)i.pop();else{if("."===o)continue;i.push(o)}}return i.join("/")}if(i[e])return i[e];if(i[e]={},!t[e])throw new Error("Could not find module "+e);for(var s,o=t[e],a=o.deps,h=o.callback,u=[],c=0,p=a.length;p>c;c++)u.push("exports"===a[c]?s={}:r(n(a[c])));var l=h.apply(this,u);return i[e]=s||l},r.entries=t}(),e("rsvp/-internal",["./utils","./instrument","./config","exports"],function(t,e,r,i){"use strict";function n(){}function s(t){try{return t.then}catch(e){return U.error=e,U}}function o(t,e,r,i){try{t.call(e,r,i)}catch(n){return n}}function a(t,e,r){w.async(function(t){var i=!1,n=o(r,e,function(r){i||(i=!0,e!==r?c(t,r):l(t,r))},function(e){i||(i=!0,d(t,e))},"Settle: "+(t._label||" unknown promise"));!i&&n&&(i=!0,d(t,n))},t)}function h(t,e){t._onerror=null,e._state===x?l(t,e._result):t._state===B?d(t,e._result):f(e,void 0,function(r){e!==r?c(t,r):l(t,r)},function(e){d(t,e)})}function u(t,e){if(e instanceof t.constructor)h(t,e);else{var r=s(e);r===U?d(t,U.error):void 0===r?l(t,e):S(r)?a(t,e,r):l(t,e)}}function c(t,e){t===e?l(t,e):P(e)?u(t,e):l(t,e)}function p(t){t._onerror&&t._onerror(t._result),m(t)}function l(t,e){t._state===_&&(t._result=e,t._state=x,0===t._subscribers.length?w.instrument&&E("fulfilled",t):w.async(m,t))}function d(t,e){t._state===_&&(t._state=B,t._result=e,w.async(p,t))}function f(t,e,r,i){var n=t._subscribers,s=n.length;t._onerror=null,n[s]=e,n[s+x]=r,n[s+B]=i,0===s&&t._state&&w.async(m,t)}function m(t){var e=t._subscribers,r=t._state;if(w.instrument&&E(r===x?"fulfilled":"rejected",t),0!==e.length){for(var i,n,s=t._result,o=0;ot;t+=2){var e=p[t],r=p[t+1];e(r),p[t]=void 0,p[t+1]=void 0}o=0}var o=0;t["default"]=function(t,e){p[o]=t,p[o+1]=e,o+=2,2===o&&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?r():c?i():n()}),e("rsvp/config",["./events","exports"],function(t,e){"use strict";function r(t,e){return"onerror"===t?void n.on("error",e):2!==arguments.length?n[t]:void(n[t]=e)}var i=t["default"],n={instrument:!1};i.mixin(n),e.config=n,e.configure=r}),e("rsvp/defer",["./promise","exports"],function(t,e){"use strict";var r=t["default"];e["default"]=function(t){var e={};return e.promise=new r(function(t,r){e.resolve=t,e.reject=r},t),e}}),e("rsvp/enumerator",["./utils","./-internal","exports"],function(t,e,r){"use strict";function i(t,e,r){return t===p?{state:"fulfilled",value:r}:{state:"rejected",reason:r}}function n(t,e,r,i){this._instanceConstructor=t,this.promise=new t(a,i),this._abortOnReject=r,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 s=t.isArray,o=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;r.ABORT_ON_REJECTION=f,r.makeSettledResult=i,n.prototype._validateInput=function(t){return s(t)},n.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},n.prototype._init=function(){this._result=new Array(this.length)},r["default"]=n,n.prototype._enumerate=function(){for(var t=this.length,e=this.promise,r=this._input,i=0;e._state===d&&t>i;i++)this._eachEntry(r[i],i)},n.prototype._eachEntry=function(t,e){var r=this._instanceConstructor;o(t)?t.constructor===r&&t._state!==d?(t._onerror=null,this._settledAt(t._state,e,t._result)):this._willSettleAt(r.resolve(t),e):(this._remaining--,this._result[e]=this._makeResult(p,e,t))},n.prototype._settledAt=function(t,e,r){var i=this.promise;i._state===d&&(this._remaining--,this._abortOnReject&&t===l?h(i,r):this._result[e]=this._makeResult(t,e,r)),0===this._remaining&&u(i,this._result)},n.prototype._makeResult=function(t,e,r){return r},n.prototype._willSettleAt=function(t,e){var r=this;c(t,void 0,function(t){r._settledAt(p,e,t)},function(t){r._settledAt(l,e,t)})}}),e("rsvp/events",["exports"],function(t){"use strict";function e(t,e){for(var r=0,i=t.length;i>r;r++)if(t[r]===e)return r;return-1}function r(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,i){var n,s=r(this);n=s[t],n||(n=s[t]=[]),-1===e(n,i)&&n.push(i)},off:function(t,i){var n,s,o=r(this);return i?(n=o[t],s=e(n,i),void(-1!==s&&n.splice(s,1))):void(o[t]=[])},trigger:function(t,e){var i,n,s=r(this);if(i=s[t])for(var o=0;oa;a++)o[a]=e(t[a]);return i.all(o,r).then(function(e){for(var r=new Array(s),i=0,n=0;s>n;n++)e[n]&&(r[i]=t[n],i++);return r.length=i,r})})}}),e("rsvp/hash-settled",["./promise","./enumerator","./promise-hash","./utils","exports"],function(t,e,r,i,n){"use strict";function s(t,e,r){this._superConstructor(t,e,!1,r)}var o=t["default"],a=e.makeSettledResult,h=r["default"],u=e["default"],c=i.o_create;s.prototype=c(h.prototype),s.prototype._superConstructor=u,s.prototype._makeResult=a,s.prototype._validationError=function(){return new Error("hashSettled must be called with an object")},n["default"]=function(t,e){return new s(o,t,e).promise}}),e("rsvp/hash",["./promise","./promise-hash","./enumerator","exports"],function(t,e,r,i){"use strict";{var n=t["default"],s=e["default"];r.ABORT_ON_REJECTION}i["default"]=function(t,e){return new s(n,t,e).promise}}),e("rsvp/instrument",["./config","./utils","exports"],function(t,e,r){"use strict";var i=t.config,n=e.now,s=[];r["default"]=function(t,e,r){1===s.push({name:t,payload:{guid:e._guidKey+e._id,eventName:t,detail:e._result,childGuid:r&&e._guidKey+r._id,label:e._label,timeStamp:n(),stack:new Error(e._label).stack}})&&setTimeout(function(){for(var t,e=0;ea;a++)o[a]=e(t[a]);return i.all(o,r)})}}),e("rsvp/node",["./promise","./utils","exports"],function(t,e,r){"use strict";var i=t["default"],n=e.isArray;r["default"]=function(t,e){function r(){for(var r=arguments.length,n=new Array(r),a=0;r>a;a++)n[a]=arguments[a];var h;return s||o||!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),i.all(n).then(function(r){function n(i,n){function a(){for(var t=arguments.length,r=new Array(t),a=0;t>a;a++)r[a]=arguments[a];var h=r[0],u=r[1];if(h)n(h);else if(s)i(r.slice(1));else if(o){var c,p,l={},d=r.slice(1);for(p=0;pa;a++)s=r[a],this._eachEntry(s.entry,s.position)}}),e("rsvp/promise",["./config","./events","./instrument","./utils","./-internal","./promise/cast","./promise/all","./promise/race","./promise/resolve","./promise/reject","exports"],function(t,e,r,i,n,s,o,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&&m("created",this),v!==t&&(g(t)||p(),this instanceof d||l(),P(this,t))}var f=t.config,m=(e["default"],r["default"]),g=(i.objectOrFunction,i.isFunction),y=i.now,v=n.noop,b=(n.resolve,n.reject,n.fulfill,n.subscribe),P=n.initializePromise,S=n.invokeCallback,E=n.FULFILLED,w=s["default"],_=o["default"],x=a["default"],B=h["default"],U=u["default"],J="rsvp_"+y()+"-",R=0;c["default"]=d,d.cast=w,d.all=_,d.race=x,d.resolve=B,d.reject=U,d.prototype={constructor:d,_id:void 0,_guidKey:J,_label:void 0,_state:void 0,_result:void 0,_subscribers:void 0,_onerror:function(t){f.trigger("error",t)},then:function(t,e,r){var i=this;i._onerror=null;var n=new this.constructor(v,r),s=i._state,o=i._result;return f.instrument&&m("chained",i,n),s===E&&t?f.async(function(){S(s,n,t,o)}):b(i,n,t,e),n},"catch":function(t,e){return this.then(null,t,e)},"finally":function(t,e){var r=this.constructor;return this.then(function(e){return r.resolve(t()).then(function(){return e})},function(e){return r.resolve(t()).then(function(){throw e})},e)}}}),e("rsvp/promise/all",["../enumerator","exports"],function(t,e){"use strict";var r=t["default"];e["default"]=function(t,e){return new r(this,t,!0,e).promise}}),e("rsvp/promise/cast",["./resolve","exports"],function(t,e){"use strict";var r=t["default"];e["default"]=r}),e("rsvp/promise/race",["../utils","../-internal","exports"],function(t,e,r){"use strict";var i=t.isArray,n=(t.isFunction,t.isMaybeThenable,e.noop),s=e.resolve,o=e.reject,a=e.subscribe,h=e.PENDING;r["default"]=function(t,e){function r(t){s(p,t)}function u(t){o(p,t)}var c=this,p=new c(n,e);if(!i(t))return o(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,r,u);return p}}),e("rsvp/promise/reject",["../-internal","exports"],function(t,e){"use strict";var r=t.noop,i=t.reject;e["default"]=function(t,e){var n=this,s=new n(r,e);return i(s,t),s}}),e("rsvp/promise/resolve",["../-internal","exports"],function(t,e){"use strict";var r=t.noop,i=t.resolve;e["default"]=function(t,e){var n=this;if(t&&"object"==typeof t&&t.constructor===n)return t;var s=new n(r,e);return i(s,t),s}}),e("rsvp/race",["./promise","exports"],function(t,e){"use strict";var r=t["default"];e["default"]=function(t,e){return r.race(t,e)}}),e("rsvp/reject",["./promise","exports"],function(t,e){"use strict";var r=t["default"];e["default"]=function(t,e){return r.reject(t,e)}}),e("rsvp/resolve",["./promise","exports"],function(t,e){"use strict";var r=t["default"];e["default"]=function(t,e){return r.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 r(t){return"function"==typeof t}function i(t){return"object"==typeof t&&null!==t}t.objectOrFunction=e,t.isFunction=r,t.isMaybeThenable=i;var n;n=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var s=n;t.isArray=s;var o=Date.now||function(){return(new Date).getTime()};t.now=o;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,r,i,n,s,o,a,h,u,c,p,l,d,f,m,g){"use strict";function y(t,e){A.async(t,e)}function v(){A.on.apply(A,arguments)}function b(){A.off.apply(A,arguments)}var P=t["default"],S=e["default"],E=r["default"],w=i["default"],_=n["default"],x=s["default"],B=o["default"],U=a["default"],J=h["default"],R=u["default"],A=c.config,I=c.configure,C=p["default"],k=l["default"],F=d["default"],T=f["default"],N=m["default"];if(A.async=N,"undefined"!=typeof window&&"object"==typeof window.__PROMISE_INSTRUMENTATION__){var q=window.__PROMISE_INSTRUMENTATION__;I("instrument",!0);for(var O in q)q.hasOwnProperty(O)&&v(O,q[O])}g.Promise=P,g.EventTarget=S,g.all=w,g.allSettled=_,g.race=x,g.hash=B,g.hashSettled=U,g.rethrow=J,g.defer=R,g.denodeify=E,g.configure=I,g.on=v,g.off=b,g.resolve=k,g.reject=F,g.async=y,g.map=C,g.filter=T}),t.RSVP=r("rsvp")}(self),function(t,e){"use strict";"object"==typeof exports?module.exports=e(require("./punycode"),require("./IPv6"),require("./SecondLevelDomains")):"function"==typeof define&&define.amd?define(["./punycode","./IPv6","./SecondLevelDomains"],e):t.URI=e(t.punycode,t.IPv6,t.SecondLevelDomains,t)}(this,function(t,e,r,i){"use strict";function n(t,e){return this instanceof n?(void 0===t&&(t="undefined"!=typeof location?location.href+"":""),this.href(t),void 0!==e?this.absoluteTo(e):this):new n(t,e)}function s(t){return t.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function o(t){return void 0===t?"Undefined":String(Object.prototype.toString.call(t)).slice(8,-1)}function a(t){return"Array"===o(t)}function h(t,e){var r,i,n={};if(a(e))for(r=0,i=e.length;i>r;r++)n[e[r]]=!0;else n[e]=!0;for(r=0,i=t.length;i>r;r++)void 0!==n[t[r]]&&(t.splice(r,1),i--,r--);return t}function u(t,e){var r,i;if(a(e)){for(r=0,i=e.length;i>r;r++)if(!u(t,e[r]))return!1;return!0}var n=o(e);for(r=0,i=t.length;i>r;r++)if("RegExp"===n){if("string"==typeof t[r]&&t[r].match(e))return!0}else if(t[r]===e)return!0;return!1}function c(t,e){if(!a(t)||!a(e))return!1;if(t.length!==e.length)return!1;t.sort(),e.sort();for(var r=0,i=t.length;i>r;r++)if(t[r]!==e[r])return!1;return!0}function p(t){return escape(t)}function l(t){return encodeURIComponent(t).replace(/[!'()*]/g,p).replace(/\*/g,"%2A")}var d=i&&i.URI;n.version="1.13.2";var f=n.prototype,m=Object.prototype.hasOwnProperty;n._parts=function(){return{protocol:null,username:null,password:null,hostname:null,urn:null,port:null,path:null,query:null,fragment:null,duplicateQueryParameters:n.duplicateQueryParameters,escapeQuerySpace:n.escapeQuerySpace}},n.duplicateQueryParameters=!1,n.escapeQuerySpace=!0,n.protocol_expression=/^[a-z][a-z0-9.+-]*$/i,n.idn_expression=/[^a-z0-9\.-]/i,n.punycode_expression=/(xn--)/i,n.ip4_expression=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,n.ip6_expression=/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/,n.find_uri_expression=/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/gi,n.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?«»“”„‘’]+$/},n.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"},n.invalid_hostname_characters=/[^a-zA-Z0-9\.-]/,n.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",img:"src",area:"href",iframe:"src",embed:"src",source:"src",track:"src",input:"src"},n.getDomAttribute=function(t){if(!t||!t.nodeName)return void 0;var e=t.nodeName.toLowerCase();return"input"===e&&"image"!==t.type?void 0:n.domAttributes[e]},n.encode=l,n.decode=decodeURIComponent,n.iso8859=function(){n.encode=escape,n.decode=unescape},n.unicode=function(){n.encode=l,n.decode=decodeURIComponent},n.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/gi,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/gi,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"="}}}},n.encodeQuery=function(t,e){var r=n.encode(t+"");return void 0===e&&(e=n.escapeQuerySpace),e?r.replace(/%20/g,"+"):r},n.decodeQuery=function(t,e){t+="",void 0===e&&(e=n.escapeQuerySpace);try{return n.decode(e?t.replace(/\+/g,"%20"):t)}catch(r){return t}},n.recodePath=function(t){for(var e=(t+"").split("/"),r=0,i=e.length;i>r;r++)e[r]=n.encodePathSegment(n.decode(e[r]));return e.join("/")},n.decodePath=function(t){for(var e=(t+"").split("/"),r=0,i=e.length;i>r;r++)e[r]=n.decodePathSegment(e[r]);return e.join("/")};var g,y={encode:"encode",decode:"decode"},v=function(t,e){return function(r){return n[e](r+"").replace(n.characters[t][e].expression,function(r){return n.characters[t][e].map[r]})}};for(g in y)n[g+"PathSegment"]=v("pathname",y[g]);n.encodeReserved=v("reserved","encode"),n.parse=function(t,e){var r;return e||(e={}),r=t.indexOf("#"),r>-1&&(e.fragment=t.substring(r+1)||null,t=t.substring(0,r)),r=t.indexOf("?"),r>-1&&(e.query=t.substring(r+1)||null,t=t.substring(0,r)),"//"===t.substring(0,2)?(e.protocol=null,t=t.substring(2),t=n.parseAuthority(t,e)):(r=t.indexOf(":"),r>-1&&(e.protocol=t.substring(0,r)||null,e.protocol&&!e.protocol.match(n.protocol_expression)?e.protocol=void 0:"file"===e.protocol?t=t.substring(r+3):"//"===t.substring(r+1,r+3)?(t=t.substring(r+3),t=n.parseAuthority(t,e)):(t=t.substring(r+1),e.urn=!0))),e.path=t,e},n.parseHost=function(t,e){var r,i,n=t.indexOf("/");return-1===n&&(n=t.length),"["===t.charAt(0)?(r=t.indexOf("]"),e.hostname=t.substring(1,r)||null,e.port=t.substring(r+2,n)||null,"/"===e.port&&(e.port=null)):t.indexOf(":")!==t.lastIndexOf(":")?(e.hostname=t.substring(0,n)||null,e.port=null):(i=t.substring(0,n).split(":"),e.hostname=i[0]||null,e.port=i[1]||null),e.hostname&&"/"!==t.substring(n).charAt(0)&&(n++,t="/"+t),t.substring(n)||"/"},n.parseAuthority=function(t,e){return t=n.parseUserinfo(t,e),n.parseHost(t,e)},n.parseUserinfo=function(t,e){var r,i=t.indexOf("/"),s=i>-1?t.lastIndexOf("@",i):t.indexOf("@");return s>-1&&(-1===i||i>s)?(r=t.substring(0,s).split(":"),e.username=r[0]?n.decode(r[0]):null,r.shift(),e.password=r[0]?n.decode(r.join(":")):null,t=t.substring(s+1)):(e.username=null,e.password=null),t},n.parseQuery=function(t,e){if(!t)return{};if(t=t.replace(/&+/g,"&").replace(/^\?*&*|&+$/g,""),!t)return{};for(var r,i,s,o={},a=t.split("&"),h=a.length,u=0;h>u;u++)r=a[u].split("="),i=n.decodeQuery(r.shift(),e),s=r.length?n.decodeQuery(r.join("="),e):null,o[i]?("string"==typeof o[i]&&(o[i]=[o[i]]),o[i].push(s)):o[i]=s;return o},n.build=function(t){var e="";return t.protocol&&(e+=t.protocol+":"),t.urn||!e&&!t.hostname||(e+="//"),e+=n.buildAuthority(t)||"","string"==typeof t.path&&("/"!==t.path.charAt(0)&&"string"==typeof t.hostname&&(e+="/"),e+=t.path),"string"==typeof t.query&&t.query&&(e+="?"+t.query),"string"==typeof t.fragment&&t.fragment&&(e+="#"+t.fragment),e},n.buildHost=function(t){var e="";return t.hostname?(e+=n.ip6_expression.test(t.hostname)?"["+t.hostname+"]":t.hostname,t.port&&(e+=":"+t.port),e):""},n.buildAuthority=function(t){return n.buildUserinfo(t)+n.buildHost(t)},n.buildUserinfo=function(t){var e="";return t.username&&(e+=n.encode(t.username),t.password&&(e+=":"+n.encode(t.password)),e+="@"),e},n.buildQuery=function(t,e,r){var i,s,o,h,u="";for(s in t)if(m.call(t,s)&&s)if(a(t[s]))for(i={},o=0,h=t[s].length;h>o;o++)void 0!==t[s][o]&&void 0===i[t[s][o]+""]&&(u+="&"+n.buildQueryParameter(s,t[s][o],r),e!==!0&&(i[t[s][o]+""]=!0));else void 0!==t[s]&&(u+="&"+n.buildQueryParameter(s,t[s],r));return u.substring(1)},n.buildQueryParameter=function(t,e,r){return n.encodeQuery(t,r)+(null!==e?"="+n.encodeQuery(e,r):"")},n.addQuery=function(t,e,r){if("object"==typeof e)for(var i in e)m.call(e,i)&&n.addQuery(t,i,e[i]);else{if("string"!=typeof e)throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");if(void 0===t[e])return void(t[e]=r);"string"==typeof t[e]&&(t[e]=[t[e]]),a(r)||(r=[r]),t[e]=t[e].concat(r)}},n.removeQuery=function(t,e,r){var i,s,o;if(a(e))for(i=0,s=e.length;s>i;i++)t[e[i]]=void 0;else if("object"==typeof e)for(o in e)m.call(e,o)&&n.removeQuery(t,o,e[o]);else{if("string"!=typeof e)throw new TypeError("URI.addQuery() accepts an object, string as the first parameter");void 0!==r?t[e]===r?t[e]=void 0:a(t[e])&&(t[e]=h(t[e],r)):t[e]=void 0}},n.hasQuery=function(t,e,r,i){if("object"==typeof e){for(var s in e)if(m.call(e,s)&&!n.hasQuery(t,s,e[s]))return!1;return!0}if("string"!=typeof e)throw new TypeError("URI.hasQuery() accepts an object, string as the name parameter");switch(o(r)){case"Undefined":return e in t;case"Boolean":var h=Boolean(a(t[e])?t[e].length:t[e]);return r===h;case"Function":return!!r(t[e],e,t);case"Array":if(!a(t[e]))return!1;var p=i?u:c;return p(t[e],r);case"RegExp":return a(t[e])?i?u(t[e],r):!1:Boolean(t[e]&&t[e].match(r));case"Number":r=String(r);case"String":return a(t[e])?i?u(t[e],r):!1:t[e]===r;default:throw new TypeError("URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter")}},n.commonPath=function(t,e){var r,i=Math.min(t.length,e.length);for(r=0;i>r;r++)if(t.charAt(r)!==e.charAt(r)){r--;break}return 1>r?t.charAt(0)===e.charAt(0)&&"/"===t.charAt(0)?"/":"":(("/"!==t.charAt(r)||"/"!==e.charAt(r))&&(r=t.substring(0,r).lastIndexOf("/")),t.substring(0,r+1))},n.withinString=function(t,e,r){r||(r={});var i=r.start||n.findUri.start,s=r.end||n.findUri.end,o=r.trim||n.findUri.trim,a=/[a-z0-9-]=["']?$/i;for(i.lastIndex=0;;){var h=i.exec(t);if(!h)break;var u=h.index;if(r.ignoreHtml){var c=t.slice(Math.max(u-3,0),u);if(c&&a.test(c))continue}var p=u+t.slice(u).search(s),l=t.slice(u,p).replace(o,"");if(!r.ignore||!r.ignore.test(l)){p=u+l.length;var d=e(l,u,p,t);t=t.slice(0,u)+d+t.slice(p),i.lastIndex=u+d.length}}return i.lastIndex=0,t},n.ensureValidHostname=function(e){if(e.match(n.invalid_hostname_characters)){if(!t)throw new TypeError('Hostname "'+e+'" contains characters other than [A-Z0-9.-] and Punycode.js is not available');if(t.toASCII(e).match(n.invalid_hostname_characters))throw new TypeError('Hostname "'+e+'" contains characters other than [A-Z0-9.-]')}},n.noConflict=function(t){if(t){var e={URI:this.noConflict()};return i.URITemplate&&"function"==typeof i.URITemplate.noConflict&&(e.URITemplate=i.URITemplate.noConflict()),i.IPv6&&"function"==typeof i.IPv6.noConflict&&(e.IPv6=i.IPv6.noConflict()),i.SecondLevelDomains&&"function"==typeof i.SecondLevelDomains.noConflict&&(e.SecondLevelDomains=i.SecondLevelDomains.noConflict()),e}return i.URI===this&&(i.URI=d),this},f.build=function(t){return t===!0?this._deferred_build=!0:(void 0===t||this._deferred_build)&&(this._string=n.build(this._parts),this._deferred_build=!1),this},f.clone=function(){return new n(this)},f.valueOf=f.toString=function(){return this.build(!1)._string},y={protocol:"protocol",username:"username",password:"password",hostname:"hostname",port:"port"},v=function(t){return function(e,r){return void 0===e?this._parts[t]||"":(this._parts[t]=e||null,this.build(!r),this)}};for(g in y)f[g]=v(y[g]);y={query:"?",fragment:"#"},v=function(t,e){return function(r,i){return void 0===r?this._parts[t]||"":(null!==r&&(r+="",r.charAt(0)===e&&(r=r.substring(1))),this._parts[t]=r,this.build(!i),this)}};for(g in y)f[g]=v(g,y[g]);y={search:["?","query"],hash:["#","fragment"]},v=function(t,e){return function(r,i){var n=this[t](r,i);return"string"==typeof n&&n.length?e+n:n}};for(g in y)f[g]=v(y[g][1],y[g][0]);f.pathname=function(t,e){if(void 0===t||t===!0){var r=this._parts.path||(this._parts.hostname?"/":"");return t?n.decodePath(r):r}return this._parts.path=t?n.recodePath(t):"/",this.build(!e),this},f.path=f.pathname,f.href=function(t,e){var r;if(void 0===t)return this.toString();this._string="",this._parts=n._parts();var i=t instanceof n,s="object"==typeof t&&(t.hostname||t.path||t.pathname);if(t.nodeName){var o=n.getDomAttribute(t);t=t[o]||"",s=!1}if(!i&&s&&void 0!==t.pathname&&(t=t.toString()),"string"==typeof t)this._parts=n.parse(t,this._parts);else{if(!i&&!s)throw new TypeError("invalid input");var a=i?t._parts:t;for(r in a)m.call(this._parts,r)&&(this._parts[r]=a[r])}return this.build(!e),this},f.is=function(t){var e=!1,i=!1,s=!1,o=!1,a=!1,h=!1,u=!1,c=!this._parts.urn;switch(this._parts.hostname&&(c=!1,i=n.ip4_expression.test(this._parts.hostname),s=n.ip6_expression.test(this._parts.hostname),e=i||s,o=!e,a=o&&r&&r.has(this._parts.hostname),h=o&&n.idn_expression.test(this._parts.hostname),u=o&&n.punycode_expression.test(this._parts.hostname)),t.toLowerCase()){case"relative":return c;case"absolute":return!c;case"domain":case"name":return o;case"sld":return a;case"ip":return e;case"ip4":case"ipv4":case"inet4":return i;case"ip6":case"ipv6":case"inet6":return s;case"idn":return h;case"url":return!this._parts.urn;case"urn":return!!this._parts.urn;case"punycode":return u}return null};var b=f.protocol,P=f.port,S=f.hostname;f.protocol=function(t,e){if(void 0!==t&&t&&(t=t.replace(/:(\/\/)?$/,""),!t.match(n.protocol_expression)))throw new TypeError('Protocol "'+t+"\" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");return b.call(this,t,e)},f.scheme=f.protocol,f.port=function(t,e){if(this._parts.urn)return void 0===t?"":this;if(void 0!==t&&(0===t&&(t=null),t&&(t+="",":"===t.charAt(0)&&(t=t.substring(1)),t.match(/[^0-9]/))))throw new TypeError('Port "'+t+'" contains characters other than [0-9]');return P.call(this,t,e)},f.hostname=function(t,e){if(this._parts.urn)return void 0===t?"":this;if(void 0!==t){var r={};n.parseHost(t,r),t=r.hostname}return S.call(this,t,e)},f.host=function(t,e){return this._parts.urn?void 0===t?"":this:void 0===t?this._parts.hostname?n.buildHost(this._parts):"":(n.parseHost(t,this._parts),this.build(!e),this)},f.authority=function(t,e){return this._parts.urn?void 0===t?"":this:void 0===t?this._parts.hostname?n.buildAuthority(this._parts):"":(n.parseAuthority(t,this._parts),this.build(!e),this)},f.userinfo=function(t,e){if(this._parts.urn)return void 0===t?"":this;if(void 0===t){if(!this._parts.username)return"";var r=n.buildUserinfo(this._parts);return r.substring(0,r.length-1)}return"@"!==t[t.length-1]&&(t+="@"),n.parseUserinfo(t,this._parts),this.build(!e),this},f.resource=function(t,e){var r;return void 0===t?this.path()+this.search()+this.hash():(r=n.parse(t),this._parts.path=r.path,this._parts.query=r.query,this._parts.fragment=r.fragment,this.build(!e),this)},f.subdomain=function(t,e){if(this._parts.urn)return void 0===t?"":this;if(void 0===t){if(!this._parts.hostname||this.is("IP"))return"";var r=this._parts.hostname.length-this.domain().length-1;return this._parts.hostname.substring(0,r)||""}var i=this._parts.hostname.length-this.domain().length,o=this._parts.hostname.substring(0,i),a=new RegExp("^"+s(o));return t&&"."!==t.charAt(t.length-1)&&(t+="."),t&&n.ensureValidHostname(t),this._parts.hostname=this._parts.hostname.replace(a,t),this.build(!e),this},f.domain=function(t,e){if(this._parts.urn)return void 0===t?"":this;if("boolean"==typeof t&&(e=t,t=void 0),void 0===t){if(!this._parts.hostname||this.is("IP"))return"";var r=this._parts.hostname.match(/\./g);if(r&&r.length<2)return this._parts.hostname;var i=this._parts.hostname.length-this.tld(e).length-1;return i=this._parts.hostname.lastIndexOf(".",i-1)+1,this._parts.hostname.substring(i)||""}if(!t)throw new TypeError("cannot set domain empty");if(n.ensureValidHostname(t),!this._parts.hostname||this.is("IP"))this._parts.hostname=t;else{var o=new RegExp(s(this.domain())+"$");this._parts.hostname=this._parts.hostname.replace(o,t)}return this.build(!e),this},f.tld=function(t,e){if(this._parts.urn)return void 0===t?"":this;if("boolean"==typeof t&&(e=t,t=void 0),void 0===t){if(!this._parts.hostname||this.is("IP"))return"";var i=this._parts.hostname.lastIndexOf("."),n=this._parts.hostname.substring(i+1);return e!==!0&&r&&r.list[n.toLowerCase()]?r.get(this._parts.hostname)||n:n}var o;if(!t)throw new TypeError("cannot set TLD empty"); -if(t.match(/[^a-zA-Z0-9-]/)){if(!r||!r.is(t))throw new TypeError('TLD "'+t+'" contains characters other than [A-Z0-9]');o=new RegExp(s(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(o,t)}else{if(!this._parts.hostname||this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");o=new RegExp(s(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(o,t)}return this.build(!e),this},f.directory=function(t,e){if(this._parts.urn)return void 0===t?"":this;if(void 0===t||t===!0){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";var r=this._parts.path.length-this.filename().length-1,i=this._parts.path.substring(0,r)||(this._parts.hostname?"/":"");return t?n.decodePath(i):i}var o=this._parts.path.length-this.filename().length,a=this._parts.path.substring(0,o),h=new RegExp("^"+s(a));return this.is("relative")||(t||(t="/"),"/"!==t.charAt(0)&&(t="/"+t)),t&&"/"!==t.charAt(t.length-1)&&(t+="/"),t=n.recodePath(t),this._parts.path=this._parts.path.replace(h,t),this.build(!e),this},f.filename=function(t,e){if(this._parts.urn)return void 0===t?"":this;if(void 0===t||t===!0){if(!this._parts.path||"/"===this._parts.path)return"";var r=this._parts.path.lastIndexOf("/"),i=this._parts.path.substring(r+1);return t?n.decodePathSegment(i):i}var o=!1;"/"===t.charAt(0)&&(t=t.substring(1)),t.match(/\.?\//)&&(o=!0);var a=new RegExp(s(this.filename())+"$");return t=n.recodePath(t),this._parts.path=this._parts.path.replace(a,t),o?this.normalizePath(e):this.build(!e),this},f.suffix=function(t,e){if(this._parts.urn)return void 0===t?"":this;if(void 0===t||t===!0){if(!this._parts.path||"/"===this._parts.path)return"";var r,i,o=this.filename(),a=o.lastIndexOf(".");return-1===a?"":(r=o.substring(a+1),i=/^[a-z0-9%]+$/i.test(r)?r:"",t?n.decodePathSegment(i):i)}"."===t.charAt(0)&&(t=t.substring(1));var h,u=this.suffix();if(u)h=new RegExp(t?s(u)+"$":s("."+u)+"$");else{if(!t)return this;this._parts.path+="."+n.recodePath(t)}return h&&(t=n.recodePath(t),this._parts.path=this._parts.path.replace(h,t)),this.build(!e),this},f.segment=function(t,e,r){var i=this._parts.urn?":":"/",n=this.path(),s="/"===n.substring(0,1),o=n.split(i);if(void 0!==t&&"number"!=typeof t&&(r=e,e=t,t=void 0),void 0!==t&&"number"!=typeof t)throw new Error('Bad segment "'+t+'", must be 0-based integer');if(s&&o.shift(),0>t&&(t=Math.max(o.length+t,0)),void 0===e)return void 0===t?o:o[t];if(null===t||void 0===o[t])if(a(e)){o=[];for(var h=0,u=e.length;u>h;h++)(e[h].length||o.length&&o[o.length-1].length)&&(o.length&&!o[o.length-1].length&&o.pop(),o.push(e[h]))}else(e||"string"==typeof e)&&(""===o[o.length-1]?o[o.length-1]=e:o.push(e));else e||"string"==typeof e&&e.length?o[t]=e:o.splice(t,1);return s&&o.unshift(""),this.path(o.join(i),r)},f.segmentCoded=function(t,e,r){var i,s,o;if("number"!=typeof t&&(r=e,e=t,t=void 0),void 0===e){if(i=this.segment(t,e,r),a(i))for(s=0,o=i.length;o>s;s++)i[s]=n.decode(i[s]);else i=void 0!==i?n.decode(i):void 0;return i}if(a(e))for(s=0,o=e.length;o>s;s++)e[s]=n.decode(e[s]);else e="string"==typeof e?n.encode(e):e;return this.segment(t,e,r)};var E=f.query;return f.query=function(t,e){if(t===!0)return n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("function"==typeof t){var r=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace),i=t.call(this,r);return this._parts.query=n.buildQuery(i||r,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!e),this}return void 0!==t&&"string"!=typeof t?(this._parts.query=n.buildQuery(t,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!e),this):E.call(this,t,e)},f.setQuery=function(t,e,r){var i=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("object"==typeof t)for(var s in t)m.call(t,s)&&(i[s]=t[s]);else{if("string"!=typeof t)throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");i[t]=void 0!==e?e:null}return this._parts.query=n.buildQuery(i,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof t&&(r=e),this.build(!r),this},f.addQuery=function(t,e,r){var i=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return n.addQuery(i,t,void 0===e?null:e),this._parts.query=n.buildQuery(i,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof t&&(r=e),this.build(!r),this},f.removeQuery=function(t,e,r){var i=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return n.removeQuery(i,t,e),this._parts.query=n.buildQuery(i,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof t&&(r=e),this.build(!r),this},f.hasQuery=function(t,e,r){var i=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return n.hasQuery(i,t,e,r)},f.setSearch=f.setQuery,f.addSearch=f.addQuery,f.removeSearch=f.removeQuery,f.hasSearch=f.hasQuery,f.normalize=function(){return this._parts.urn?this.normalizeProtocol(!1).normalizeQuery(!1).normalizeFragment(!1).build():this.normalizeProtocol(!1).normalizeHostname(!1).normalizePort(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build()},f.normalizeProtocol=function(t){return"string"==typeof this._parts.protocol&&(this._parts.protocol=this._parts.protocol.toLowerCase(),this.build(!t)),this},f.normalizeHostname=function(r){return this._parts.hostname&&(this.is("IDN")&&t?this._parts.hostname=t.toASCII(this._parts.hostname):this.is("IPv6")&&e&&(this._parts.hostname=e.best(this._parts.hostname)),this._parts.hostname=this._parts.hostname.toLowerCase(),this.build(!r)),this},f.normalizePort=function(t){return"string"==typeof this._parts.protocol&&this._parts.port===n.defaultPorts[this._parts.protocol]&&(this._parts.port=null,this.build(!t)),this},f.normalizePath=function(t){if(this._parts.urn)return this;if(!this._parts.path||"/"===this._parts.path)return this;var e,r,i,s=this._parts.path,o="";for("/"!==s.charAt(0)&&(e=!0,s="/"+s),s=s.replace(/(\/(\.\/)+)|(\/\.$)/g,"/").replace(/\/{2,}/g,"/"),e&&(o=s.substring(1).match(/^(\.\.\/)+/)||"",o&&(o=o[0]));;){if(r=s.indexOf("/.."),-1===r)break;0!==r?(i=s.substring(0,r).lastIndexOf("/"),-1===i&&(i=r),s=s.substring(0,i)+s.substring(r+3)):s=s.substring(3)}return e&&this.is("relative")&&(s=o+s.substring(1)),s=n.recodePath(s),this._parts.path=s,this.build(!t),this},f.normalizePathname=f.normalizePath,f.normalizeQuery=function(t){return"string"==typeof this._parts.query&&(this._parts.query.length?this.query(n.parseQuery(this._parts.query,this._parts.escapeQuerySpace)):this._parts.query=null,this.build(!t)),this},f.normalizeFragment=function(t){return this._parts.fragment||(this._parts.fragment=null,this.build(!t)),this},f.normalizeSearch=f.normalizeQuery,f.normalizeHash=f.normalizeFragment,f.iso8859=function(){var t=n.encode,e=n.decode;return n.encode=escape,n.decode=decodeURIComponent,this.normalize(),n.encode=t,n.decode=e,this},f.unicode=function(){var t=n.encode,e=n.decode;return n.encode=l,n.decode=unescape,this.normalize(),n.encode=t,n.decode=e,this},f.readable=function(){var e=this.clone();e.username("").password("").normalize();var r="";if(e._parts.protocol&&(r+=e._parts.protocol+"://"),e._parts.hostname&&(e.is("punycode")&&t?(r+=t.toUnicode(e._parts.hostname),e._parts.port&&(r+=":"+e._parts.port)):r+=e.host()),e._parts.hostname&&e._parts.path&&"/"!==e._parts.path.charAt(0)&&(r+="/"),r+=e.path(!0),e._parts.query){for(var i="",s=0,o=e._parts.query.split("&"),a=o.length;a>s;s++){var h=(o[s]||"").split("=");i+="&"+n.decodeQuery(h[0],this._parts.escapeQuerySpace).replace(/&/g,"%26"),void 0!==h[1]&&(i+="="+n.decodeQuery(h[1],this._parts.escapeQuerySpace).replace(/&/g,"%26"))}r+="?"+i.substring(1)}return r+=n.decodeQuery(e.hash(),!0)},f.absoluteTo=function(t){var e,r,i,s=this.clone(),o=["protocol","username","password","hostname","port"];if(this._parts.urn)throw new Error("URNs do not have any generally defined hierarchical components");if(t instanceof n||(t=new n(t)),s._parts.protocol||(s._parts.protocol=t._parts.protocol),this._parts.hostname)return s;for(r=0;i=o[r];r++)s._parts[i]=t._parts[i];return s._parts.path?".."===s._parts.path.substring(-2)&&(s._parts.path+="/"):(s._parts.path=t._parts.path,s._parts.query||(s._parts.query=t._parts.query)),"/"!==s.path().charAt(0)&&(e=t.directory(),s._parts.path=(e?e+"/":"")+s._parts.path,s.normalizePath()),s.build(),s},f.relativeTo=function(t){var e,r,i,s,o,a=this.clone().normalize();if(a._parts.urn)throw new Error("URNs do not have any generally defined hierarchical components");if(t=new n(t).normalize(),e=a._parts,r=t._parts,s=a.path(),o=t.path(),"/"!==s.charAt(0))throw new Error("URI is already relative");if("/"!==o.charAt(0))throw new Error("Cannot calculate a URI relative to another relative URI");if(e.protocol===r.protocol&&(e.protocol=null),e.username!==r.username||e.password!==r.password)return a.build();if(null!==e.protocol||null!==e.username||null!==e.password)return a.build();if(e.hostname!==r.hostname||e.port!==r.port)return a.build();if(e.hostname=null,e.port=null,s===o)return e.path="",a.build();if(i=n.commonPath(a.path(),t.path()),!i)return a.build();var h=r.path.substring(i.length).replace(/[^\/]*$/,"").replace(/.*?\//g,"../");return e.path=h+e.path.substring(i.length),a.build()},f.equals=function(t){var e,r,i,s=this.clone(),o=new n(t),h={},u={},p={};if(s.normalize(),o.normalize(),s.toString()===o.toString())return!0;if(e=s.query(),r=o.query(),s.query(""),o.query(""),s.toString()!==o.toString())return!1;if(e.length!==r.length)return!1;h=n.parseQuery(e,this._parts.escapeQuerySpace),u=n.parseQuery(r,this._parts.escapeQuerySpace);for(i in h)if(m.call(h,i)){if(a(h[i])){if(!c(h[i],u[i]))return!1}else if(h[i]!==u[i])return!1;p[i]=!0}for(i in u)if(m.call(u,i)&&!p[i])return!1;return!0},f.duplicateQueryParameters=function(t){return this._parts.duplicateQueryParameters=!!t,this},f.escapeQuerySpace=function(t){return this._parts.escapeQuerySpace=!!t,this},n}),EPUBJS.Book=function(t){this.opening=new RSVP.defer,this.opened=this.opening.promise,this.isOpen=!1,this.url=void 0,this.spine=new EPUBJS.Spine(this.request),this.loading={manifest:new RSVP.defer,spine:new RSVP.defer,metadata:new RSVP.defer,cover:new RSVP.defer,navigation:new RSVP.defer,pageList:new RSVP.defer},this.loaded={manifest:this.loading.manifest.promise,spine:this.loading.spine.promise,metadata:this.loading.metadata.promise,cover:this.loading.cover.promise,navigation:this.loading.navigation.promise,pageList:this.loading.pageList.promise},this.ready=RSVP.hash(this.loaded),this.isRendered=!1,this._q=EPUBJS.core.queue(this),this.request=this.requestMethod.bind(this),t&&this.open(t)},EPUBJS.Book.prototype.open=function(t){var e,r,i,n=new EPUBJS.Parser,s=this,o="META-INF/container.xml";return t?(e="object"==typeof t?t:EPUBJS.core.uri(t),"opf"===e.extension?(this.packageUrl=e.href,this.containerUrl="",e.origin?this.url=e.origin+"/"+e.directory:window?(i=EPUBJS.core.uri(window.location.href),this.url=EPUBJS.core.resolveUrl(i.base,e.directory)):this.url=e.directory,r=this.request(this.packageUrl)):"epub"===e.extension||"zip"===e.extension?(this.archived=!0,this.url=""):e.extension||(this.containerUrl=t+o,r=this.request(this.containerUrl).then(function(t){return n.container(t)}).then(function(e){var r=EPUBJS.core.uri(e.packagePath);return s.packageUrl=t+e.packagePath,s.url=t+r.directory,s.encoding=e.encoding,s.request(s.packageUrl)}).catch(function(t){console.error("Could not load book at: "+(this.packageUrl||this.containerPath)),s.trigger("book:loadFailed",this.packageUrl||this.containerPath),s.opening.reject(t)})),r.then(function(t){s.unpack(t),s.loading.manifest.resolve(s.package.manifest),s.loading.metadata.resolve(s.package.metadata),s.loading.spine.resolve(s.spine),s.loading.cover.resolve(s.cover),this.isOpen=!0,s.opening.resolve(s)}).catch(function(t){console.error(t.message,t.stack),s.opening.reject(t)}),this.opened):(this.opening.resolve(this),this.opened)},EPUBJS.Book.prototype.unpack=function(t){var e=this,r=new EPUBJS.Parser;e.package=r.packageContents(t),e.package.baseUrl=e.url,this.spine.load(e.package),e.navigation=new EPUBJS.Navigation(e.package,this.request),e.navigation.load().then(function(t){e.toc=t,e.loading.navigation.resolve(e.toc)}),e.cover=e.url+e.package.coverPath},EPUBJS.Book.prototype.section=function(t){return this.spine.get(t)},EPUBJS.Book.prototype.renderTo=function(t,e){return this.rendition=new EPUBJS.Renderer(this,e),this.rendition.attachTo(t),this.rendition},EPUBJS.Book.prototype.requestMethod=function(t){return this.archived?void 0:EPUBJS.core.request(t,"xml",this.requestCredentials,this.requestHeaders)},EPUBJS.Book.prototype.setRequestCredentials=function(t){this.requestCredentials=t},EPUBJS.Book.prototype.setRequestHeaders=function(t){this.requestHeaders=t},RSVP.EventTarget.mixin(EPUBJS.Book.prototype),RSVP.on("error",function(){}),RSVP.configure("instrument",!0),RSVP.on("rejected",function(t){console.error(t.detail.message,t.detail.stack)}),EPUBJS.core={},EPUBJS.core.request=function(t,e,r,i){function n(){if(this.readyState===this.DONE)if(200===this.status||this.responseXML){var t;t="xml"==e?this.responseXML:"json"==e?JSON.parse(this.response):"blob"==e?o?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 s,o=window.URL,a=o?"blob":"arraybuffer",h=new RSVP.defer,u=new XMLHttpRequest,c=XMLHttpRequest.prototype;"overrideMimeType"in c||Object.defineProperty(c,"overrideMimeType",{value:function(){}}),r&&(u.withCredentials=!0),u.open("GET",t,!0);for(s in i)u.setRequestHeader(s,i[s]);return u.onreadystatechange=n,"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,r,i,n={protocol:"",host:"",path:"",origin:"",directory:"",base:"",filename:"",extension:"",fragment:"",href:t},s=t.indexOf("://"),o=t.indexOf("?"),a=t.indexOf("#");return-1!=a&&(n.fragment=t.slice(a+1),t=t.slice(0,a)),-1!=o&&(n.search=t.slice(o+1),t=t.slice(0,o),href=t),-1!=s?(n.protocol=t.slice(0,s),e=t.slice(s+3),i=e.indexOf("/"),-1===i?(n.host=n.path,n.path=""):(n.host=e.slice(0,i),n.path=e.slice(i)),n.origin=n.protocol+"://"+n.host,n.directory=EPUBJS.core.folder(n.path),n.base=n.origin+n.directory):(n.path=t,n.directory=EPUBJS.core.folder(t),n.base=n.directory),n.filename=t.replace(n.base,""),r=n.filename.lastIndexOf("."),-1!=r&&(n.extension=n.filename.slice(r+1)),n},EPUBJS.core.folder=function(t){var e=t.lastIndexOf("/");if(-1==e)var r="";return r=t.slice(0,e+1)},EPUBJS.core.queue=function(t){var e=[],r=t,i=function(t,r,i){return e.push({funcName:t,args:r,context:i}),e},n=function(){var t;e.length&&(t=e.shift(),r[t.funcName].apply(t.context||r,t.args))},s=function(){for(;e.length;)n()},o=function(){e=[]},a=function(){return e.length};return{enqueue:i,dequeue:n,flush:s,clear:o,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 r=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?r:7&r|8).toString(16)});return e},EPUBJS.core.values=function(t){for(var e=-1,r=Object.keys(t),i=r.length,n=Array(i);++en;n++)if("undefined"!=typeof document.body.style[e[n]+r])return e[n]+r;return t},EPUBJS.core.defaults=function(t){for(var e=1,r=arguments.length;r>e;e++){var i=arguments[e];for(var n in i)void 0===t[n]&&(t[n]=i[n])}return t},EPUBJS.EpubCFI=function(t){return t?this.parse(t):void 0},EPUBJS.EpubCFI.prototype.generateChapterComponent=function(t,e,r){var i=parseInt(e),n=t+1,s="/"+n+"/";return s+=2*(i+1),r&&(s+="["+r+"]"),s},EPUBJS.EpubCFI.prototype.generatePathComponent=function(t){var e=[];return t.forEach(function(t){var r="";r+=2*(t.index+1),t.id&&(r+="["+t.id+"]"),e.push(r)}),e.join("/")},EPUBJS.EpubCFI.prototype.generateCfiFromElement=function(t,e){var r=this.pathTo(t),i=this.generatePathComponent(r);return i.length?"epubcfi("+e+"!"+i+"/1:0)":"epubcfi("+e+"!/4/)"},EPUBJS.EpubCFI.prototype.pathTo=function(t){for(var e,r=[];t&&null!==t.parentNode&&9!=t.parentNode.nodeType;)e=t.parentNode.children,r.unshift({id:t.id,tagName:t.tagName,index:e?Array.prototype.indexOf.call(e,t):0}),t=t.parentNode;return r},EPUBJS.EpubCFI.prototype.getChapterComponent=function(t){var e=t.split("!");return e[0]},EPUBJS.EpubCFI.prototype.getPathComponent=function(t){var e=t.split("!"),r=e[1]?e[1].split(":"):"";return r[0]},EPUBJS.EpubCFI.prototype.getCharecterOffsetComponent=function(t){var e=t.split(":");return e[1]||""},EPUBJS.EpubCFI.prototype.parse=function(t){var e,r,i,n,s,o,a,h,u,c={},p=function(t){var e,r,i,n;return e="element",r=parseInt(t)/2-1,i=t.match(/\[(.*)\]/),i&&i[1]&&(n=i[1]),{type:e,index:r,id:n||!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)),r=this.getChapterComponent(t),i=this.getPathComponent(t)||"",n=this.getCharecterOffsetComponent(t),r&&(e=r.split("/")[2]||"")?(c.spinePos=parseInt(e)/2-1||0,o=e.match(/\[(.*)\]/),c.spineId=o?o[1]:!1,-1!=i.indexOf(",")&&console.warn("CFI Ranges are not supported"),a=i.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}),s=n.match(/\[(.*)\]/),s&&s[1]?(c.characterOffset=parseInt(n.split("[")[0]),c.textLocationAssertion=s[1]):c.characterOffset=parseInt(n),c):{spinePos:-1})},EPUBJS.EpubCFI.prototype.addMarker=function(t,e,r){var i,n,s,o,a=e||document,h=r||this.createMarker(a);return"string"==typeof t&&(t=this.parse(t)),n=t.steps[t.steps.length-1],-1===t.spinePos?!1:(i=this.findParent(t,a))?(n&&"text"===n.type?(s=i.childNodes[n.index],t.characterOffset?(o=s.splitText(t.characterOffset),h.classList.add("EPUBJS-CFI-SPLIT"),i.insertBefore(h,o)):i.insertBefore(h,s)):i.insertBefore(h,i.firstChild),h):!1},EPUBJS.EpubCFI.prototype.createMarker=function(t){var e=t||document,r=e.createElement("span");return r.id="EPUBJS-CFI-MARKER:"+EPUBJS.core.uuid(),r.classList.add("EPUBJS-CFI-MARKER"),r},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 r,i,n,s=e||document,o=s.getElementsByTagName("html")[0],a=Array.prototype.slice.call(o.children);if("string"==typeof t&&(t=this.parse(t)),i=t.steps.slice(0),!i.length)return s.getElementsByTagName("body")[0];for(;i&&i.length>0;){if(r=i.shift(),"text"===r.type?(n=o.childNodes[r.index],o=n.parentNode||o):o=r.id?s.getElementById(r.id):a[r.index],"undefined"==typeof o)return console.error("No Element For",r,t.str),!1;a=Array.prototype.slice.call(o.children)}return o},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[r].index)return 1;if(t.steps[r].indexe.characterOffset?1:t.characterOffset=0?(s=n.length,t.characterOffsetr?this.hooks[r].apply(this.context,n):void 0}.bind(this))):(t=i.promise,i.resolve()),t},EPUBJS.Infinite=function(t,e){this.container=t,this.windowHeight=window.innerHeight,this.tick=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame,this.scrolled=!1,this.ignore=!1,this.displaying=!1,this.offset=900,this.views=[],this.axis=e,this.prevScrollTop=0},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.displaying?("vertical"===this.axis?this.checkTop():this.checkLeft(),this.scrolled=!1):(this.displaying=!1,this.scrolled=!1),this.tick.call(window,this.check.bind(this))},EPUBJS.Infinite.prototype.checkTop=function(){var t=this.container.scrollTop,e=this.container.scrollHeight,r=t-this.prevScrollTop,i=this.container.getBoundingClientRect().height,n=t+this.offset>e-i,s=t0?this.forwards():s&&0>r&&this.backwards(),this.prevScrollTop=t,t},EPUBJS.Infinite.prototype.checkLeft=function(){var t=this.container.scrollLeft,e=this.container.scrollWidth,r=t-this.prevscrollLeft,i=this.container.getBoundingClientRect().width,n=t+this.offset>e-i,s=t0?this.forwards():s&&0>r&&this.backwards(),this.prevscrollLeft=t,t},EPUBJS.Infinite.prototype.scrollBy=function(t,e,r){r&&(this.displaying=!0),this.container.scrollLeft+=t,this.container.scrollTop+=e,this.scrolled=!0,this.check()},EPUBJS.Infinite.prototype.scroll=function(t,e,r){r&&(this.displaying=!0),this.container.scrollLeft=t,this.container.scrollTop=e,this.scrolled=!0,this.check()},RSVP.EventTarget.mixin(EPUBJS.Infinite.prototype),EPUBJS.Layout=EPUBJS.Layout||{},EPUBJS.Layout.Reflowable=function(){this.documentElement=null,this.spreadWidth=null},EPUBJS.Layout.Reflowable.prototype.format=function(t,e,r,i){var n=EPUBJS.core.prefixed("columnAxis"),s=EPUBJS.core.prefixed("columnGap"),o=EPUBJS.core.prefixed("columnWidth"),a=EPUBJS.core.prefixed("columnFill"),h=Math.floor(e),u=Math.floor(h/8),c=i>=0?i: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=r+"px",t.style[n]="horizontal",t.style[a]="auto",t.style[o]=h+"px",t.style[s]=c+"px",this.colWidth=h,this.gap=c,{pageWidth:this.spreadWidth,pageHeight:r}},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(){this.documentElement=null,this.spreadWidth=null},EPUBJS.Layout.ReflowableSpreads.prototype.format=function(t,e,r,i){var n=EPUBJS.core.prefixed("columnAxis"),s=EPUBJS.core.prefixed("columnGap"),o=EPUBJS.core.prefixed("columnWidth"),a=EPUBJS.core.prefixed("columnFill"),h=2,u=Math.floor(e),c=u%2===0?u:u-1,p=Math.floor(c/8),l=i>=0?i:p%2===0?p:p-1,d=Math.floor((c-l)/h);return this.spreadWidth=(d+l)*h,t.document.documentElement.style.overflow="hidden",t.document.body.style.width=c+"px",t.document.body.style.height=r+"px",t.document.body.style[n]="horizontal",t.document.body.style[a]="auto",t.document.body.style[s]=l+"px",t.document.body.style[o]=d+"px",this.colWidth=d,this.gap=l,t.iframe.style.width=d+"px",t.iframe.style.paddingRight=l+"px",{pageWidth:this.spreadWidth,pageHeight:r}},EPUBJS.Layout.ReflowableSpreads.prototype.calculatePages=function(){var t=this.documentElement.scrollWidth,e=Math.ceil(t/this.spreadWidth);return this.documentElement.style.width=t+this.spreadWidth+"px",{displayedPages:e,pageCount:2*e}},EPUBJS.Layout.Fixed=function(){this.documentElement=null},EPUBJS.Layout.Fixed=function(t){var e,r,i,n,s=EPUBJS.core.prefixed("columnWidth"),o=t.querySelector("[name=viewport");return this.documentElement=t,o&&o.hasAttribute("content")&&(e=o.getAttribute("content"),r=e.split(","),r[0]&&(i=r[0].replace("width=","")),r[1]&&(n=r[1].replace("height=",""))),t.style.width=i+"px"||"auto",t.style.height=n+"px"||"auto",t.style[s]="auto",t.style.overflow="auto",this.colWidth=i,this.gap=0,{pageWidth:i,pageHeight:n}},EPUBJS.Layout.Fixed.prototype.calculatePages=function(){return{displayedPages:1,pageCount:1}},EPUBJS.Navigation=function(t,e){var r=this,i=new EPUBJS.Parser,n=e||EPUBJS.core.request;this.package=t,this.toc=[],this.tocByHref={},this.tocById={},t.navPath&&(this.navUrl=t.baseUrl+t.navPath,this.nav={},this.nav.load=function(){var t=new RSVP.defer,e=t.promise;return n(r.navUrl,"xml").then(function(e){r.toc=i.nav(e),r.loaded(r.toc),t.resolve(r.toc)}),e}),t.ncxPath&&(this.ncxUrl=t.baseUrl+t.ncxPath,this.ncx={},this.ncx.load=function(){var t=new RSVP.defer,e=t.promise;return n(r.ncxUrl,"xml").then(function(e){r.toc=i.ncx(e),r.loaded(r.toc),t.resolve(r.toc)}),e})},EPUBJS.Navigation.prototype.load=function(t){{var e,r;t||EPUBJS.core.request}return this.nav?e=this.nav.load():this.ncx?e=this.ncx.load():(r=new RSVP.defer,r.resolve([]),e=r.promise),e},EPUBJS.Navigation.prototype.loaded=function(t){for(var e,r=0;r=0;o--){var a=n.snapshotItem(o),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));i.unshift({id:h,href:c,label:l,subitems:f,parent:r?r.getAttribute("id"):null})}return i}var r=t.querySelector("navMap");return r?e(r):[]},EPUBJS.Renderer=function(t,e){var r=e||{};this.settings={infinite:"undefined"==typeof r.infinite?!0:r.infinite,hidden:"undefined"==typeof r.hidden?!1:r.hidden,axis:r.axis||"vertical",viewsLimit:r.viewsLimit||5,width:"undefined"==typeof r.width?!1:r.width,height:"undefined"==typeof r.height?!1:r.height},this.book=t,this.epubcfi=new EPUBJS.EpubCFI,this.layoutSettings={},this._q=EPUBJS.core.queue(this),this.position=1,this.initialize({width:this.settings.width,height:this.settings.height}),this.rendering=!1,this.views=[],this.positions=[],this.hooks={},this.hooks.display=new EPUBJS.Hook(this),this.hooks.replacements=new EPUBJS.Hook(this),this.settings.infinite||(this.settings.viewsLimit=1)},EPUBJS.Renderer.prototype.initialize=function(t){{var e=t||{},r=e.height!==!1?e.height:"100%",i=e.width!==!1?e.width:"100%";e.hidden||!1}return e.height&&EPUBJS.core.isNumber(e.height)&&(r=e.height+"px"),e.width&&EPUBJS.core.isNumber(e.width)&&(i=e.width+"px"),this.container=document.createElement("div"),this.settings.infinite&&(this.infinite=new EPUBJS.Infinite(this.container,this.settings.axis)),"horizontal"===this.settings.axis&&(this.container.style.whiteSpace="nowrap"),this.container.style.width=i,this.container.style.height=r,this.container.style.overflow="scroll",e.hidden?(this.wrapper=document.createElement("div"),this.wrapper.style.visibility="hidden",this.wrapper.style.overflow="hidden",this.wrapper.style.width="0",this.wrapper.style.height="0",this.wrapper.appendChild(this.container),this.wrapper):this.container},EPUBJS.Renderer.prototype.resize=function(t,e){var r=t,i=e;t||(r=window.innerWidth),e||(i=window.innerHeight),this.container.style.width=r+"px",this.container.style.height=i+"px",this.trigger("resized",{width:this.width,height:this.height})},EPUBJS.Renderer.prototype.onResized=function(){var t=this.element.getBoundingClientRect();this.resize(t.width,t.height)},EPUBJS.Renderer.prototype.attachTo=function(t){var e;return EPUBJS.core.isElement(t)?this.element=t:"string"==typeof t&&(this.element=document.getElementById(t)),this.element?(this.element.appendChild(this.container),this.settings.height||this.settings.width||(e=this.element.getBoundingClientRect(),this.resize(e.width,e.height)),this.settings.infinite&&(this.infinite.start(),this.infinite.on("forwards",function(){var t=this.last().section.index+1;!this.rendering&&t0&&this.backwards()}.bind(this))),window.addEventListener("resize",this.onResized.bind(this),!1),void this.hooks.replacements.register(this.replacements.bind(this))):void console.error("Not an Element")},EPUBJS.Renderer.prototype.clear=function(){this.views.forEach(function(t){t.destroy()}),this.views=[]},EPUBJS.Renderer.prototype.display=function(t){var e=new RSVP.defer,r=e.promise;return this.clear(),this.book.opened.then(function(){var r,i=this.book.spine.get(t);i?(r=this.render(i),this.settings.infinite&&r.then(this.fill.bind(this)),r.then(function(){e.resolve(this)}.bind(this))):e.reject(new Error("No Section Found"))}.bind(this)),r},EPUBJS.Renderer.prototype.render=function(t){var e,r;return t?(r=new EPUBJS.View(t),this.insert(r,t.index),e=r.render(this.book.request),e.then(function(){return this.hooks.display.trigger(r)}.bind(this)).then(function(){return this.hooks.replacements.trigger(r,this)}.bind(this)).then(function(){return r.expand()}.bind(this)).then(function(){return this.rendering=!1,r.show(),r}.bind(this)).catch(function(t){this.trigger("loaderror",t)}.bind(this))):(e=new RSVP.defer,e.reject(new Error("No Section Provided")),e.promise)},EPUBJS.Renderer.prototype.forwards=function(){var t,e,r;return t=this.last().section.index+1,this.rendering||t===this.book.spine.length?(e=new RSVP.defer,e.reject(new Error("Reject Forwards")),e.promise):(this.rendering=!0,r=this.book.spine.get(t),e=this.render(r),e.then(function(){var t=this.first(),e=t.bounds(),r=this.container.scrollTop,i=this.container.scrollLeft;this.views.length>this.settings.viewsLimit&&(this.remove(t),this.settings.infinite&&("vertical"===this.settings.axis?this.infinite.scroll(0,r-e.height,!0):this.infinite.scroll(i-e.width,!0)))}.bind(this)),e)},EPUBJS.Renderer.prototype.backwards=function(){var t,e,r;return t=this.first().section.index-1,this.rendering||0>t?(e=new RSVP.defer,e.reject(new Error("Reject Backwards")),e.promise):(this.rendering=!0,r=this.book.spine.get(t),e=this.render(r),e.then(function(){var t;this.settings.infinite&&("vertical"===this.settings.axis?this.infinite.scrollBy(0,this.first().bounds().height,!0):this.infinite.scrollBy(this.first().bounds().width,0,!0)),this.views.length>this.settings.viewsLimit&&(t=this.last(),this.remove(t))}.bind(this)),e)},EPUBJS.Renderer.prototype.fill=function(){var t=this.first().section.index-1,e=this.forwards();return e.then("vertical"===this.settings.axis?this.fillVertical.bind(this):this.fillHorizontal.bind(this)),t>0&&e.then(this.backwards.bind(this)),e.then(function(){this.rendering=!1}.bind(this))},EPUBJS.Renderer.prototype.fillVertical=function(){var t=this.container.getBoundingClientRect().height,e=this.last().bounds().bottom,r=new RSVP.defer;return t&&e&&t>e?this.forwards().then(this.fillVertical.bind(this)):(this.rendering=!1,r.resolve(),r.promise)},EPUBJS.Renderer.prototype.fillHorizontal=function(){var t=this.container.getBoundingClientRect().width,e=this.last().bounds().right,r=new RSVP.defer;return t&&e&&t>=e?this.forwards().then(this.fillHorizontal.bind(this)):(this.rendering=!1,r.resolve(),r.promise)},EPUBJS.Renderer.prototype.append=function(t){this.views.push(t),t.appendTo(this.container)},EPUBJS.Renderer.prototype.prepend=function(t){this.views.unshift(t),t.prependTo(this.container)},EPUBJS.Renderer.prototype.insert=function(t,e){this.first()?e-this.first().section.index>=0?this.append(t):e-this.last().section.index<=0&&this.prepend(t):this.append(t)},EPUBJS.Renderer.prototype.remove=function(t){var e=this.views.indexOf(t);t.destroy(),e>-1&&this.views.splice(e,1)},EPUBJS.Renderer.prototype.first=function(){return this.views[0]},EPUBJS.Renderer.prototype.last=function(){return this.views[this.views.length-1]},EPUBJS.Renderer.prototype.replacements=function(t,e){for(var r=new RSVP.defer,i=t.document.querySelectorAll("a[href]"),n=function(t){var r=t.getAttribute("href"),i=r.search("://");-1!=i?t.setAttribute("target","_blank"):t.onclick=function(){return e.display(r),!1}},s=0;s-1?(delete this.spineByHref[t.href],delete this.spineById[t.idref],this.spineItems.splice(e,1)):void 0},EPUBJS.View=function(t){this.id="epubjs-view:"+EPUBJS.core.uuid(),this.rendering=new RSVP.defer,this.rendered=this.rendering.promise,this.iframe=this.create(),this.section=t},EPUBJS.View.prototype.create=function(){return this.iframe=document.createElement("iframe"),this.iframe.id=this.id,this.iframe.scrolling="no",this.iframe.seamless="seamless",this.iframe.style.border="none",this.resizing=!0,this.iframe.style.width="100%",this.iframe.style.height="100%",this.iframe.style.display="none",this.iframe.style.visibility="hidden",this.iframe},EPUBJS.View.prototype.resized=function(){this.resizing?this.resizing=!1:this.expand()},EPUBJS.View.prototype.render=function(t){return this.section.render(t).then(function(t){return this.load(t)}.bind(this)).then(this.display.bind(this)).then(function(){this.rendering.resolve(this)}.bind(this))},EPUBJS.View.prototype.load=function(t){var e=new RSVP.defer,r=e.promise;return this.document=this.iframe.contentDocument,this.iframe.addEventListener("load",function(){this.window=this.iframe.contentWindow,this.document=this.iframe.contentDocument,e.resolve(this)}.bind(this)),this.document.open(),this.document.write(t),this.document.close(),r},EPUBJS.View.prototype.display=function(){var t=new RSVP.defer,e=t.promise;return this.iframe.style.display="inline-block",this.document.body.style.margin="0",this.document.documentElement.style.width="auto",setTimeout(function(){this.window.addEventListener("resize",this.resized.bind(this),!1)}.bind(this),10),this.document.fonts&&"loading"===this.document.fonts.status?this.document.fonts.onloading=function(){this.expand(),t.resolve(this)}.bind(this):(this.expand(),t.resolve(this)),e},EPUBJS.View.prototype.expand=function(){var t,e,r;return t=this.document.body.getBoundingClientRect(),(!t||0===t.height&&0===t.width)&&console.error("View not shown"),this.resizing=!0,r=t.height,this.iframe.style.height=r+"px",e=this.document.documentElement.scrollWidth,this.iframe.style.width=e+"px",t},EPUBJS.View.prototype.observe=function(t){var e=this,r=new MutationObserver(function(){e.expand()}),i={attributes:!0,childList:!0,characterData:!0,subtree:!0};return r.observe(t,i),r},EPUBJS.View.prototype.appendTo=function(t){this.element=t,this.element.appendChild(this.iframe)},EPUBJS.View.prototype.prependTo=function(t){this.element=t,t.insertBefore(this.iframe,t.firstChild)},EPUBJS.View.prototype.show=function(){this.iframe.style.display="inline-block",this.iframe.style.visibility="visible"},EPUBJS.View.prototype.hide=function(){this.iframe.style.display="none",this.iframe.style.visibility="hidden"},EPUBJS.View.prototype.bounds=function(){return this.iframe.getBoundingClientRect()},EPUBJS.View.prototype.destroy=function(){this.element.removeChild(this.iframe)}; \ No newline at end of file +if(t.match(/[^a-zA-Z0-9-]/)){if(!r||!r.is(t))throw new TypeError('TLD "'+t+'" contains characters other than [A-Z0-9]');o=new RegExp(s(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(o,t)}else{if(!this._parts.hostname||this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");o=new RegExp(s(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(o,t)}return this.build(!e),this},f.directory=function(t,e){if(this._parts.urn)return void 0===t?"":this;if(void 0===t||t===!0){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";var r=this._parts.path.length-this.filename().length-1,i=this._parts.path.substring(0,r)||(this._parts.hostname?"/":"");return t?n.decodePath(i):i}var o=this._parts.path.length-this.filename().length,a=this._parts.path.substring(0,o),h=new RegExp("^"+s(a));return this.is("relative")||(t||(t="/"),"/"!==t.charAt(0)&&(t="/"+t)),t&&"/"!==t.charAt(t.length-1)&&(t+="/"),t=n.recodePath(t),this._parts.path=this._parts.path.replace(h,t),this.build(!e),this},f.filename=function(t,e){if(this._parts.urn)return void 0===t?"":this;if(void 0===t||t===!0){if(!this._parts.path||"/"===this._parts.path)return"";var r=this._parts.path.lastIndexOf("/"),i=this._parts.path.substring(r+1);return t?n.decodePathSegment(i):i}var o=!1;"/"===t.charAt(0)&&(t=t.substring(1)),t.match(/\.?\//)&&(o=!0);var a=new RegExp(s(this.filename())+"$");return t=n.recodePath(t),this._parts.path=this._parts.path.replace(a,t),o?this.normalizePath(e):this.build(!e),this},f.suffix=function(t,e){if(this._parts.urn)return void 0===t?"":this;if(void 0===t||t===!0){if(!this._parts.path||"/"===this._parts.path)return"";var r,i,o=this.filename(),a=o.lastIndexOf(".");return-1===a?"":(r=o.substring(a+1),i=/^[a-z0-9%]+$/i.test(r)?r:"",t?n.decodePathSegment(i):i)}"."===t.charAt(0)&&(t=t.substring(1));var h,u=this.suffix();if(u)h=new RegExp(t?s(u)+"$":s("."+u)+"$");else{if(!t)return this;this._parts.path+="."+n.recodePath(t)}return h&&(t=n.recodePath(t),this._parts.path=this._parts.path.replace(h,t)),this.build(!e),this},f.segment=function(t,e,r){var i=this._parts.urn?":":"/",n=this.path(),s="/"===n.substring(0,1),o=n.split(i);if(void 0!==t&&"number"!=typeof t&&(r=e,e=t,t=void 0),void 0!==t&&"number"!=typeof t)throw new Error('Bad segment "'+t+'", must be 0-based integer');if(s&&o.shift(),0>t&&(t=Math.max(o.length+t,0)),void 0===e)return void 0===t?o:o[t];if(null===t||void 0===o[t])if(a(e)){o=[];for(var h=0,u=e.length;u>h;h++)(e[h].length||o.length&&o[o.length-1].length)&&(o.length&&!o[o.length-1].length&&o.pop(),o.push(e[h]))}else(e||"string"==typeof e)&&(""===o[o.length-1]?o[o.length-1]=e:o.push(e));else e||"string"==typeof e&&e.length?o[t]=e:o.splice(t,1);return s&&o.unshift(""),this.path(o.join(i),r)},f.segmentCoded=function(t,e,r){var i,s,o;if("number"!=typeof t&&(r=e,e=t,t=void 0),void 0===e){if(i=this.segment(t,e,r),a(i))for(s=0,o=i.length;o>s;s++)i[s]=n.decode(i[s]);else i=void 0!==i?n.decode(i):void 0;return i}if(a(e))for(s=0,o=e.length;o>s;s++)e[s]=n.decode(e[s]);else e="string"==typeof e?n.encode(e):e;return this.segment(t,e,r)};var E=f.query;return f.query=function(t,e){if(t===!0)return n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("function"==typeof t){var r=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace),i=t.call(this,r);return this._parts.query=n.buildQuery(i||r,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!e),this}return void 0!==t&&"string"!=typeof t?(this._parts.query=n.buildQuery(t,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!e),this):E.call(this,t,e)},f.setQuery=function(t,e,r){var i=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("object"==typeof t)for(var s in t)m.call(t,s)&&(i[s]=t[s]);else{if("string"!=typeof t)throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");i[t]=void 0!==e?e:null}return this._parts.query=n.buildQuery(i,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof t&&(r=e),this.build(!r),this},f.addQuery=function(t,e,r){var i=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return n.addQuery(i,t,void 0===e?null:e),this._parts.query=n.buildQuery(i,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof t&&(r=e),this.build(!r),this},f.removeQuery=function(t,e,r){var i=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return n.removeQuery(i,t,e),this._parts.query=n.buildQuery(i,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof t&&(r=e),this.build(!r),this},f.hasQuery=function(t,e,r){var i=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return n.hasQuery(i,t,e,r)},f.setSearch=f.setQuery,f.addSearch=f.addQuery,f.removeSearch=f.removeQuery,f.hasSearch=f.hasQuery,f.normalize=function(){return this._parts.urn?this.normalizeProtocol(!1).normalizeQuery(!1).normalizeFragment(!1).build():this.normalizeProtocol(!1).normalizeHostname(!1).normalizePort(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build()},f.normalizeProtocol=function(t){return"string"==typeof this._parts.protocol&&(this._parts.protocol=this._parts.protocol.toLowerCase(),this.build(!t)),this},f.normalizeHostname=function(r){return this._parts.hostname&&(this.is("IDN")&&t?this._parts.hostname=t.toASCII(this._parts.hostname):this.is("IPv6")&&e&&(this._parts.hostname=e.best(this._parts.hostname)),this._parts.hostname=this._parts.hostname.toLowerCase(),this.build(!r)),this},f.normalizePort=function(t){return"string"==typeof this._parts.protocol&&this._parts.port===n.defaultPorts[this._parts.protocol]&&(this._parts.port=null,this.build(!t)),this},f.normalizePath=function(t){if(this._parts.urn)return this;if(!this._parts.path||"/"===this._parts.path)return this;var e,r,i,s=this._parts.path,o="";for("/"!==s.charAt(0)&&(e=!0,s="/"+s),s=s.replace(/(\/(\.\/)+)|(\/\.$)/g,"/").replace(/\/{2,}/g,"/"),e&&(o=s.substring(1).match(/^(\.\.\/)+/)||"",o&&(o=o[0]));;){if(r=s.indexOf("/.."),-1===r)break;0!==r?(i=s.substring(0,r).lastIndexOf("/"),-1===i&&(i=r),s=s.substring(0,i)+s.substring(r+3)):s=s.substring(3)}return e&&this.is("relative")&&(s=o+s.substring(1)),s=n.recodePath(s),this._parts.path=s,this.build(!t),this},f.normalizePathname=f.normalizePath,f.normalizeQuery=function(t){return"string"==typeof this._parts.query&&(this._parts.query.length?this.query(n.parseQuery(this._parts.query,this._parts.escapeQuerySpace)):this._parts.query=null,this.build(!t)),this},f.normalizeFragment=function(t){return this._parts.fragment||(this._parts.fragment=null,this.build(!t)),this},f.normalizeSearch=f.normalizeQuery,f.normalizeHash=f.normalizeFragment,f.iso8859=function(){var t=n.encode,e=n.decode;return n.encode=escape,n.decode=decodeURIComponent,this.normalize(),n.encode=t,n.decode=e,this},f.unicode=function(){var t=n.encode,e=n.decode;return n.encode=l,n.decode=unescape,this.normalize(),n.encode=t,n.decode=e,this},f.readable=function(){var e=this.clone();e.username("").password("").normalize();var r="";if(e._parts.protocol&&(r+=e._parts.protocol+"://"),e._parts.hostname&&(e.is("punycode")&&t?(r+=t.toUnicode(e._parts.hostname),e._parts.port&&(r+=":"+e._parts.port)):r+=e.host()),e._parts.hostname&&e._parts.path&&"/"!==e._parts.path.charAt(0)&&(r+="/"),r+=e.path(!0),e._parts.query){for(var i="",s=0,o=e._parts.query.split("&"),a=o.length;a>s;s++){var h=(o[s]||"").split("=");i+="&"+n.decodeQuery(h[0],this._parts.escapeQuerySpace).replace(/&/g,"%26"),void 0!==h[1]&&(i+="="+n.decodeQuery(h[1],this._parts.escapeQuerySpace).replace(/&/g,"%26"))}r+="?"+i.substring(1)}return r+=n.decodeQuery(e.hash(),!0)},f.absoluteTo=function(t){var e,r,i,s=this.clone(),o=["protocol","username","password","hostname","port"];if(this._parts.urn)throw new Error("URNs do not have any generally defined hierarchical components");if(t instanceof n||(t=new n(t)),s._parts.protocol||(s._parts.protocol=t._parts.protocol),this._parts.hostname)return s;for(r=0;i=o[r];r++)s._parts[i]=t._parts[i];return s._parts.path?".."===s._parts.path.substring(-2)&&(s._parts.path+="/"):(s._parts.path=t._parts.path,s._parts.query||(s._parts.query=t._parts.query)),"/"!==s.path().charAt(0)&&(e=t.directory(),s._parts.path=(e?e+"/":"")+s._parts.path,s.normalizePath()),s.build(),s},f.relativeTo=function(t){var e,r,i,s,o,a=this.clone().normalize();if(a._parts.urn)throw new Error("URNs do not have any generally defined hierarchical components");if(t=new n(t).normalize(),e=a._parts,r=t._parts,s=a.path(),o=t.path(),"/"!==s.charAt(0))throw new Error("URI is already relative");if("/"!==o.charAt(0))throw new Error("Cannot calculate a URI relative to another relative URI");if(e.protocol===r.protocol&&(e.protocol=null),e.username!==r.username||e.password!==r.password)return a.build();if(null!==e.protocol||null!==e.username||null!==e.password)return a.build();if(e.hostname!==r.hostname||e.port!==r.port)return a.build();if(e.hostname=null,e.port=null,s===o)return e.path="",a.build();if(i=n.commonPath(a.path(),t.path()),!i)return a.build();var h=r.path.substring(i.length).replace(/[^\/]*$/,"").replace(/.*?\//g,"../");return e.path=h+e.path.substring(i.length),a.build()},f.equals=function(t){var e,r,i,s=this.clone(),o=new n(t),h={},u={},p={};if(s.normalize(),o.normalize(),s.toString()===o.toString())return!0;if(e=s.query(),r=o.query(),s.query(""),o.query(""),s.toString()!==o.toString())return!1;if(e.length!==r.length)return!1;h=n.parseQuery(e,this._parts.escapeQuerySpace),u=n.parseQuery(r,this._parts.escapeQuerySpace);for(i in h)if(m.call(h,i)){if(a(h[i])){if(!c(h[i],u[i]))return!1}else if(h[i]!==u[i])return!1;p[i]=!0}for(i in u)if(m.call(u,i)&&!p[i])return!1;return!0},f.duplicateQueryParameters=function(t){return this._parts.duplicateQueryParameters=!!t,this},f.escapeQuerySpace=function(t){return this._parts.escapeQuerySpace=!!t,this},n}),EPUBJS.Book=function(t){this.opening=new RSVP.defer,this.opened=this.opening.promise,this.isOpen=!1,this.url=void 0,this.spine=new EPUBJS.Spine(this.request),this.loading={manifest:new RSVP.defer,spine:new RSVP.defer,metadata:new RSVP.defer,cover:new RSVP.defer,navigation:new RSVP.defer,pageList:new RSVP.defer},this.loaded={manifest:this.loading.manifest.promise,spine:this.loading.spine.promise,metadata:this.loading.metadata.promise,cover:this.loading.cover.promise,navigation:this.loading.navigation.promise,pageList:this.loading.pageList.promise},this.ready=RSVP.hash(this.loaded),this.isRendered=!1,this._q=EPUBJS.core.queue(this),this.request=this.requestMethod.bind(this),t&&this.open(t)},EPUBJS.Book.prototype.open=function(t){var e,r,i,n=new EPUBJS.Parser,s=this,o="META-INF/container.xml";return t?(e="object"==typeof t?t:EPUBJS.core.uri(t),"opf"===e.extension?(this.packageUrl=e.href,this.containerUrl="",e.origin?this.url=e.origin+"/"+e.directory:window?(i=EPUBJS.core.uri(window.location.href),this.url=EPUBJS.core.resolveUrl(i.base,e.directory)):this.url=e.directory,r=this.request(this.packageUrl)):"epub"===e.extension||"zip"===e.extension?(this.archived=!0,this.url=""):e.extension||(this.containerUrl=t+o,r=this.request(this.containerUrl).then(function(t){return n.container(t)}).then(function(e){var r=EPUBJS.core.uri(e.packagePath);return s.packageUrl=t+e.packagePath,s.url=t+r.directory,s.encoding=e.encoding,s.request(s.packageUrl)}).catch(function(t){console.error("Could not load book at: "+(this.packageUrl||this.containerPath)),s.trigger("book:loadFailed",this.packageUrl||this.containerPath),s.opening.reject(t)})),r.then(function(t){s.unpack(t),s.loading.manifest.resolve(s.package.manifest),s.loading.metadata.resolve(s.package.metadata),s.loading.spine.resolve(s.spine),s.loading.cover.resolve(s.cover),this.isOpen=!0,s.opening.resolve(s)}).catch(function(t){console.error(t.message,t.stack),s.opening.reject(t)}),this.opened):(this.opening.resolve(this),this.opened)},EPUBJS.Book.prototype.unpack=function(t){var e=this,r=new EPUBJS.Parser;e.package=r.packageContents(t),e.package.baseUrl=e.url,this.spine.load(e.package),e.navigation=new EPUBJS.Navigation(e.package,this.request),e.navigation.load().then(function(t){e.toc=t,e.loading.navigation.resolve(e.toc)}),e.cover=e.url+e.package.coverPath},EPUBJS.Book.prototype.section=function(t){return this.spine.get(t)},EPUBJS.Book.prototype.renderTo=function(t,e){return this.rendition=new EPUBJS.Renderer(this,e),this.rendition.attachTo(t),this.rendition},EPUBJS.Book.prototype.requestMethod=function(t){return this.archived?void 0:EPUBJS.core.request(t,"xml",this.requestCredentials,this.requestHeaders)},EPUBJS.Book.prototype.setRequestCredentials=function(t){this.requestCredentials=t},EPUBJS.Book.prototype.setRequestHeaders=function(t){this.requestHeaders=t},RSVP.EventTarget.mixin(EPUBJS.Book.prototype),RSVP.on("error",function(){}),RSVP.configure("instrument",!0),RSVP.on("rejected",function(t){console.error(t.detail.message,t.detail.stack)}),EPUBJS.core={},EPUBJS.core.request=function(t,e,r,i){function n(){if(this.readyState===this.DONE)if(200===this.status||this.responseXML){var t;t="xml"==e?this.responseXML:"json"==e?JSON.parse(this.response):"blob"==e?o?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 s,o=window.URL,a=o?"blob":"arraybuffer",h=new RSVP.defer,u=new XMLHttpRequest,c=XMLHttpRequest.prototype;"overrideMimeType"in c||Object.defineProperty(c,"overrideMimeType",{value:function(){}}),r&&(u.withCredentials=!0),u.open("GET",t,!0);for(s in i)u.setRequestHeader(s,i[s]);return u.onreadystatechange=n,"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,r,i,n={protocol:"",host:"",path:"",origin:"",directory:"",base:"",filename:"",extension:"",fragment:"",href:t},s=t.indexOf("://"),o=t.indexOf("?"),a=t.indexOf("#");return-1!=a&&(n.fragment=t.slice(a+1),t=t.slice(0,a)),-1!=o&&(n.search=t.slice(o+1),t=t.slice(0,o),href=t),-1!=s?(n.protocol=t.slice(0,s),e=t.slice(s+3),i=e.indexOf("/"),-1===i?(n.host=n.path,n.path=""):(n.host=e.slice(0,i),n.path=e.slice(i)),n.origin=n.protocol+"://"+n.host,n.directory=EPUBJS.core.folder(n.path),n.base=n.origin+n.directory):(n.path=t,n.directory=EPUBJS.core.folder(t),n.base=n.directory),n.filename=t.replace(n.base,""),r=n.filename.lastIndexOf("."),-1!=r&&(n.extension=n.filename.slice(r+1)),n},EPUBJS.core.folder=function(t){var e=t.lastIndexOf("/");if(-1==e)var r="";return r=t.slice(0,e+1)},EPUBJS.core.queue=function(t){var e=[],r=t,i=function(t,r,i){return e.push({funcName:t,args:r,context:i}),e},n=function(){var t;e.length&&(t=e.shift(),r[t.funcName].apply(t.context||r,t.args))},s=function(){for(;e.length;)n()},o=function(){e=[]},a=function(){return e.length};return{enqueue:i,dequeue:n,flush:s,clear:o,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 r=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?r:7&r|8).toString(16)});return e},EPUBJS.core.values=function(t){for(var e=-1,r=Object.keys(t),i=r.length,n=Array(i);++en;n++)if("undefined"!=typeof document.body.style[e[n]+r])return e[n]+r;return t},EPUBJS.core.defaults=function(t){for(var e=1,r=arguments.length;r>e;e++){var i=arguments[e];for(var n in i)void 0===t[n]&&(t[n]=i[n])}return t},EPUBJS.EpubCFI=function(t){return t?this.parse(t):void 0},EPUBJS.EpubCFI.prototype.generateChapterComponent=function(t,e,r){var i=parseInt(e),n=t+1,s="/"+n+"/";return s+=2*(i+1),r&&(s+="["+r+"]"),s},EPUBJS.EpubCFI.prototype.generatePathComponent=function(t){var e=[];return t.forEach(function(t){var r="";r+=2*(t.index+1),t.id&&(r+="["+t.id+"]"),e.push(r)}),e.join("/")},EPUBJS.EpubCFI.prototype.generateCfiFromElement=function(t,e){var r=this.pathTo(t),i=this.generatePathComponent(r);return i.length?"epubcfi("+e+"!"+i+"/1:0)":"epubcfi("+e+"!/4/)"},EPUBJS.EpubCFI.prototype.pathTo=function(t){for(var e,r=[];t&&null!==t.parentNode&&9!=t.parentNode.nodeType;)e=t.parentNode.children,r.unshift({id:t.id,tagName:t.tagName,index:e?Array.prototype.indexOf.call(e,t):0}),t=t.parentNode;return r},EPUBJS.EpubCFI.prototype.getChapterComponent=function(t){var e=t.split("!");return e[0]},EPUBJS.EpubCFI.prototype.getPathComponent=function(t){var e=t.split("!"),r=e[1]?e[1].split(":"):"";return r[0]},EPUBJS.EpubCFI.prototype.getCharecterOffsetComponent=function(t){var e=t.split(":");return e[1]||""},EPUBJS.EpubCFI.prototype.parse=function(t){var e,r,i,n,s,o,a,h,u,c={},p=function(t){var e,r,i,n;return e="element",r=parseInt(t)/2-1,i=t.match(/\[(.*)\]/),i&&i[1]&&(n=i[1]),{type:e,index:r,id:n||!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)),r=this.getChapterComponent(t),i=this.getPathComponent(t)||"",n=this.getCharecterOffsetComponent(t),r&&(e=r.split("/")[2]||"")?(c.spinePos=parseInt(e)/2-1||0,o=e.match(/\[(.*)\]/),c.spineId=o?o[1]:!1,-1!=i.indexOf(",")&&console.warn("CFI Ranges are not supported"),a=i.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}),s=n.match(/\[(.*)\]/),s&&s[1]?(c.characterOffset=parseInt(n.split("[")[0]),c.textLocationAssertion=s[1]):c.characterOffset=parseInt(n),c):{spinePos:-1})},EPUBJS.EpubCFI.prototype.addMarker=function(t,e,r){var i,n,s,o,a=e||document,h=r||this.createMarker(a);return"string"==typeof t&&(t=this.parse(t)),n=t.steps[t.steps.length-1],-1===t.spinePos?!1:(i=this.findParent(t,a))?(n&&"text"===n.type?(s=i.childNodes[n.index],t.characterOffset?(o=s.splitText(t.characterOffset),h.classList.add("EPUBJS-CFI-SPLIT"),i.insertBefore(h,o)):i.insertBefore(h,s)):i.insertBefore(h,i.firstChild),h):!1},EPUBJS.EpubCFI.prototype.createMarker=function(t){var e=t||document,r=e.createElement("span");return r.id="EPUBJS-CFI-MARKER:"+EPUBJS.core.uuid(),r.classList.add("EPUBJS-CFI-MARKER"),r},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 r,i,n,s=e||document,o=s.getElementsByTagName("html")[0],a=Array.prototype.slice.call(o.children);if("string"==typeof t&&(t=this.parse(t)),i=t.steps.slice(0),!i.length)return s.getElementsByTagName("body")[0];for(;i&&i.length>0;){if(r=i.shift(),"text"===r.type?(n=o.childNodes[r.index],o=n.parentNode||o):o=r.id?s.getElementById(r.id):a[r.index],"undefined"==typeof o)return console.error("No Element For",r,t.str),!1;a=Array.prototype.slice.call(o.children)}return o},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[r].index)return 1;if(t.steps[r].indexe.characterOffset?1:t.characterOffset=0?(s=n.length,t.characterOffsetr?this.hooks[r].apply(this.context,n):void 0}.bind(this))):(t=i.promise,i.resolve()),t},EPUBJS.Infinite=function(t,e){this.container=t,this.windowHeight=window.innerHeight,this.tick=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame,this.scrolled=!1,this.ignore=!1,this.displaying=!1,this.offset=900,this.views=[],this.axis=e,this.prevScrollTop=0},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.displaying?("vertical"===this.axis?this.checkTop():this.checkLeft(),this.scrolled=!1):(this.displaying=!1,this.scrolled=!1),this.tick.call(window,this.check.bind(this))},EPUBJS.Infinite.prototype.checkTop=function(){var t=this.container.scrollTop,e=this.container.scrollHeight,r=t-this.prevScrollTop,i=this.container.getBoundingClientRect().height,n=t+this.offset>e-i,s=t0?this.forwards():s&&0>r&&this.backwards(),this.prevScrollTop=t,t},EPUBJS.Infinite.prototype.checkLeft=function(){var t=this.container.scrollLeft,e=this.container.scrollWidth,r=t-this.prevscrollLeft,i=this.container.getBoundingClientRect().width,n=t+this.offset>e-i,s=t0?this.forwards():s&&0>r&&this.backwards(),this.prevscrollLeft=t,t},EPUBJS.Infinite.prototype.scrollBy=function(t,e,r){r&&(this.displaying=!0),this.container.scrollLeft+=t,this.container.scrollTop+=e,this.scrolled=!0,this.check()},EPUBJS.Infinite.prototype.scroll=function(t,e,r){r&&(this.displaying=!0),this.container.scrollLeft=t,this.container.scrollTop=e,this.scrolled=!0,this.check()},RSVP.EventTarget.mixin(EPUBJS.Infinite.prototype),EPUBJS.Layout=EPUBJS.Layout||{},EPUBJS.Layout.Reflowable=function(){this.documentElement=null,this.spreadWidth=null},EPUBJS.Layout.Reflowable.prototype.format=function(t,e,r,i){var n=EPUBJS.core.prefixed("columnAxis"),s=EPUBJS.core.prefixed("columnGap"),o=EPUBJS.core.prefixed("columnWidth"),a=EPUBJS.core.prefixed("columnFill"),h=Math.floor(e),u=Math.floor(h/8),c=i>=0?i: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=r+"px",t.style[n]="horizontal",t.style[a]="auto",t.style[o]=h+"px",t.style[s]=c+"px",this.colWidth=h,this.gap=c,{pageWidth:this.spreadWidth,pageHeight:r}},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(){this.documentElement=null,this.spreadWidth=null},EPUBJS.Layout.ReflowableSpreads.prototype.format=function(t,e,r,i){var n=EPUBJS.core.prefixed("columnAxis"),s=EPUBJS.core.prefixed("columnGap"),o=EPUBJS.core.prefixed("columnWidth"),a=EPUBJS.core.prefixed("columnFill"),h=2,u=Math.floor(e),c=u%2===0?u:u-1,p=Math.floor(c/8),l=i>=0?i:p%2===0?p:p-1,d=Math.floor((c-l)/h);return this.spreadWidth=(d+l)*h,t.document.documentElement.style.overflow="hidden",t.document.body.style.width=c+"px",t.document.body.style.height=r+"px",t.document.body.style[n]="horizontal",t.document.body.style[a]="auto",t.document.body.style[s]=l+"px",t.document.body.style[o]=d+"px",this.colWidth=d,this.gap=l,t.iframe.style.width=d+"px",t.iframe.style.paddingRight=l+"px",{pageWidth:this.spreadWidth,pageHeight:r}},EPUBJS.Layout.ReflowableSpreads.prototype.calculatePages=function(){var t=this.documentElement.scrollWidth,e=Math.ceil(t/this.spreadWidth);return this.documentElement.style.width=t+this.spreadWidth+"px",{displayedPages:e,pageCount:2*e}},EPUBJS.Layout.Fixed=function(){this.documentElement=null},EPUBJS.Layout.Fixed=function(t){var e,r,i,n,s=EPUBJS.core.prefixed("columnWidth"),o=t.querySelector("[name=viewport");return this.documentElement=t,o&&o.hasAttribute("content")&&(e=o.getAttribute("content"),r=e.split(","),r[0]&&(i=r[0].replace("width=","")),r[1]&&(n=r[1].replace("height=",""))),t.style.width=i+"px"||"auto",t.style.height=n+"px"||"auto",t.style[s]="auto",t.style.overflow="auto",this.colWidth=i,this.gap=0,{pageWidth:i,pageHeight:n}},EPUBJS.Layout.Fixed.prototype.calculatePages=function(){return{displayedPages:1,pageCount:1}},EPUBJS.Navigation=function(t,e){var r=this,i=new EPUBJS.Parser,n=e||EPUBJS.core.request;this.package=t,this.toc=[],this.tocByHref={},this.tocById={},t.navPath&&(this.navUrl=t.baseUrl+t.navPath,this.nav={},this.nav.load=function(){var t=new RSVP.defer,e=t.promise;return n(r.navUrl,"xml").then(function(e){r.toc=i.nav(e),r.loaded(r.toc),t.resolve(r.toc)}),e}),t.ncxPath&&(this.ncxUrl=t.baseUrl+t.ncxPath,this.ncx={},this.ncx.load=function(){var t=new RSVP.defer,e=t.promise;return n(r.ncxUrl,"xml").then(function(e){r.toc=i.ncx(e),r.loaded(r.toc),t.resolve(r.toc)}),e})},EPUBJS.Navigation.prototype.load=function(t){{var e,r;t||EPUBJS.core.request}return this.nav?e=this.nav.load():this.ncx?e=this.ncx.load():(r=new RSVP.defer,r.resolve([]),e=r.promise),e},EPUBJS.Navigation.prototype.loaded=function(t){for(var e,r=0;r=0;o--){var a=n.snapshotItem(o),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));i.unshift({id:h,href:c,label:l,subitems:f,parent:r?r.getAttribute("id"):null})}return i}var r=t.querySelector("navMap");return r?e(r):[]},EPUBJS.Renderer=function(t,e){var r=e||{};this.settings={infinite:"undefined"==typeof r.infinite?!0:r.infinite,hidden:"undefined"==typeof r.hidden?!1:r.hidden,axis:r.axis||"vertical",viewsLimit:r.viewsLimit||5,width:"undefined"==typeof r.width?!1:r.width,height:"undefined"==typeof r.height?!1:r.height},this.book=t,this.epubcfi=new EPUBJS.EpubCFI,this.layoutSettings={},this._q=EPUBJS.core.queue(this),this.position=1,this.initialize({width:this.settings.width,height:this.settings.height}),this.rendering=!1,this.views=[],this.positions=[],this.hooks={},this.hooks.display=new EPUBJS.Hook(this),this.hooks.replacements=new EPUBJS.Hook(this),this.settings.infinite||(this.settings.viewsLimit=1)},EPUBJS.Renderer.prototype.initialize=function(t){{var e=t||{},r=e.height!==!1?e.height:"100%",i=e.width!==!1?e.width:"100%";e.hidden||!1}return e.height&&EPUBJS.core.isNumber(e.height)&&(r=e.height+"px"),e.width&&EPUBJS.core.isNumber(e.width)&&(i=e.width+"px"),this.container=document.createElement("div"),this.settings.infinite&&(this.infinite=new EPUBJS.Infinite(this.container,this.settings.axis)),"horizontal"===this.settings.axis&&(this.container.style.whiteSpace="nowrap"),this.container.style.width=i,this.container.style.height=r,this.container.style.overflow="scroll",e.hidden?(this.wrapper=document.createElement("div"),this.wrapper.style.visibility="hidden",this.wrapper.style.overflow="hidden",this.wrapper.style.width="0",this.wrapper.style.height="0",this.wrapper.appendChild(this.container),this.wrapper):this.container},EPUBJS.Renderer.prototype.resize=function(t,e){var r=t,i=e;t||(r=window.innerWidth),e||(i=window.innerHeight),this.container.style.width=r+"px",this.container.style.height=i+"px",this.trigger("resized",{width:this.width,height:this.height})},EPUBJS.Renderer.prototype.onResized=function(){var t=this.element.getBoundingClientRect();this.resize(t.width,t.height)},EPUBJS.Renderer.prototype.attachTo=function(t){var e;return EPUBJS.core.isElement(t)?this.element=t:"string"==typeof t&&(this.element=document.getElementById(t)),this.element?(this.element.appendChild(this.container),this.settings.height||this.settings.width||(e=this.element.getBoundingClientRect(),this.resize(e.width,e.height)),this.settings.infinite&&(this.infinite.start(),this.infinite.on("forwards",function(){var t=this.last().section.index+1;!this.rendering&&t0&&this.backwards()}.bind(this))),window.addEventListener("resize",this.onResized.bind(this),!1),void this.hooks.replacements.register(this.replacements.bind(this))):void console.error("Not an Element")},EPUBJS.Renderer.prototype.clear=function(){this.views.forEach(function(t){t.destroy()}),this.views=[]},EPUBJS.Renderer.prototype.display=function(t){var e=new RSVP.defer,r=e.promise;return this.clear(),this.book.opened.then(function(){var r,i=this.book.spine.get(t);i?(r=this.render(i),this.settings.infinite&&r.then(this.fill.bind(this)),r.then(function(){e.resolve(this)}.bind(this))):e.reject(new Error("No Section Found"))}.bind(this)),r},EPUBJS.Renderer.prototype.render=function(t){var e,r;return t?(r=new EPUBJS.View(t),this.insert(r,t.index),e=r.render(this.book.request),e.then(function(){return this.hooks.display.trigger(r)}.bind(this)).then(function(){return this.hooks.replacements.trigger(r,this)}.bind(this)).then(function(){return r.expand()}.bind(this)).then(function(){return this.rendering=!1,r.show(),r}.bind(this)).catch(function(t){this.trigger("loaderror",t)}.bind(this))):(e=new RSVP.defer,e.reject(new Error("No Section Provided")),e.promise)},EPUBJS.Renderer.prototype.forwards=function(){var t,e,r;return t=this.last().section.index+1,this.rendering||t===this.book.spine.length?(e=new RSVP.defer,e.reject(new Error("Reject Forwards")),e.promise):(this.rendering=!0,r=this.book.spine.get(t),e=this.render(r),e.then(function(){var t=this.first(),e=t.bounds(),r=this.container.scrollTop,i=this.container.scrollLeft;this.views.length>this.settings.viewsLimit&&(this.remove(t),this.settings.infinite&&("vertical"===this.settings.axis?this.infinite.scroll(0,r-e.height,!0):this.infinite.scroll(i-e.width,!0)))}.bind(this)),e)},EPUBJS.Renderer.prototype.backwards=function(){var t,e,r;return t=this.first().section.index-1,this.rendering||0>t?(e=new RSVP.defer,e.reject(new Error("Reject Backwards")),e.promise):(this.rendering=!0,r=this.book.spine.get(t),e=this.render(r),e.then(function(){var t;this.settings.infinite&&("vertical"===this.settings.axis?this.infinite.scrollBy(0,this.first().bounds().height,!0):this.infinite.scrollBy(this.first().bounds().width,0,!0)),this.views.length>this.settings.viewsLimit&&(t=this.last(),this.remove(t))}.bind(this)),e)},EPUBJS.Renderer.prototype.fill=function(){var t=this.first().section.index-1,e=this.forwards();return e.then("vertical"===this.settings.axis?this.fillVertical.bind(this):this.fillHorizontal.bind(this)),t>0&&e.then(this.backwards.bind(this)),e.then(function(){this.rendering=!1}.bind(this))},EPUBJS.Renderer.prototype.fillVertical=function(){var t=this.container.getBoundingClientRect().height,e=this.last().bounds().bottom,r=new RSVP.defer;return t&&e&&t>e?this.forwards().then(this.fillVertical.bind(this)):(this.rendering=!1,r.resolve(),r.promise)},EPUBJS.Renderer.prototype.fillHorizontal=function(){var t=this.container.getBoundingClientRect().width,e=this.last().bounds().right,r=new RSVP.defer;return t&&e&&t>=e?this.forwards().then(this.fillHorizontal.bind(this)):(this.rendering=!1,r.resolve(),r.promise)},EPUBJS.Renderer.prototype.append=function(t){this.views.push(t),t.appendTo(this.container)},EPUBJS.Renderer.prototype.prepend=function(t){this.views.unshift(t),t.prependTo(this.container)},EPUBJS.Renderer.prototype.insert=function(t,e){this.first()?e-this.first().section.index>=0?this.append(t):e-this.last().section.index<=0&&this.prepend(t):this.append(t)},EPUBJS.Renderer.prototype.remove=function(t){var e=this.views.indexOf(t);t.destroy(),e>-1&&this.views.splice(e,1)},EPUBJS.Renderer.prototype.first=function(){return this.views[0]},EPUBJS.Renderer.prototype.last=function(){return this.views[this.views.length-1]},EPUBJS.Renderer.prototype.replacements=function(t,e){for(var r=new RSVP.defer,i=t.document.querySelectorAll("a[href]"),n=function(t){var r=t.getAttribute("href"),i=new EPUBJS.core.uri(r);i.protocol?t.setAttribute("target","_blank"):t.onclick=function(){return e.display(r),!1}},s=0;s-1?(delete this.spineByHref[t.href],delete this.spineById[t.idref],this.spineItems.splice(e,1)):void 0},EPUBJS.View=function(t){this.id="epubjs-view:"+EPUBJS.core.uuid(),this.rendering=new RSVP.defer,this.rendered=this.rendering.promise,this.iframe=this.create(),this.section=t},EPUBJS.View.prototype.create=function(){return this.iframe=document.createElement("iframe"),this.iframe.id=this.id,this.iframe.scrolling="no",this.iframe.seamless="seamless",this.iframe.style.border="none",this.resizing=!0,this.iframe.style.width="100%",this.iframe.style.height="100%",this.iframe.style.display="none",this.iframe.style.visibility="hidden",this.iframe},EPUBJS.View.prototype.resized=function(){this.resizing?this.resizing=!1:this.expand()},EPUBJS.View.prototype.render=function(t){return this.section.render(t).then(function(t){return this.load(t)}.bind(this)).then(this.display.bind(this)).then(function(){this.rendering.resolve(this)}.bind(this))},EPUBJS.View.prototype.load=function(t){var e=new RSVP.defer,r=e.promise;return this.document=this.iframe.contentDocument,this.iframe.addEventListener("load",function(){this.window=this.iframe.contentWindow,this.document=this.iframe.contentDocument,e.resolve(this)}.bind(this)),this.document.open(),this.document.write(t),this.document.close(),r},EPUBJS.View.prototype.display=function(){var t=new RSVP.defer,e=t.promise;return this.iframe.style.display="inline-block",this.document.body.style.margin="0",this.document.body.style.display="inline-block",this.document.documentElement.style.width="auto",setTimeout(function(){this.window.addEventListener("resize",this.resized.bind(this),!1)}.bind(this),10),this.document.fonts&&"loading"===this.document.fonts.status?this.document.fonts.onloading=function(){this.expand(),t.resolve(this)}.bind(this):(this.expand(),t.resolve(this)),e},EPUBJS.View.prototype.expand=function(){var t,e,r;return t=this.document.body.getBoundingClientRect(),(!t||0===t.height&&0===t.width)&&console.error("View not shown"),this.resizing=!0,r=t.height,this.iframe.style.height=r+"px",e=this.document.documentElement.scrollWidth,this.iframe.style.width=e+"px",t},EPUBJS.View.prototype.observe=function(t){var e=this,r=new MutationObserver(function(){e.expand()}),i={attributes:!0,childList:!0,characterData:!0,subtree:!0};return r.observe(t,i),r},EPUBJS.View.prototype.appendTo=function(t){this.element=t,this.element.appendChild(this.iframe)},EPUBJS.View.prototype.prependTo=function(t){this.element=t,t.insertBefore(this.iframe,t.firstChild)},EPUBJS.View.prototype.show=function(){this.iframe.style.display="inline-block",this.iframe.style.visibility="visible"},EPUBJS.View.prototype.hide=function(){this.iframe.style.display="none",this.iframe.style.visibility="hidden"},EPUBJS.View.prototype.bounds=function(){return this.iframe.getBoundingClientRect()},EPUBJS.View.prototype.destroy=function(){this.element.removeChild(this.iframe)}; \ No newline at end of file diff --git a/examples/basic.html b/examples/basic.html index 7b95ed0..23d7715 100644 --- a/examples/basic.html +++ b/examples/basic.html @@ -17,16 +17,17 @@ #viewer { display: block; margin: 0; - width: 60%; + width: 100%; height: 100%; margin: 0 auto; + text-align: center; } #viewer iframe { background: white; box-shadow: 0 0 4px #ccc; margin: 10px; - width: calc(100% - 60px) !important; + width: calc(60% - 60px) !important; padding: 20px; } @@ -72,7 +73,7 @@