mirror of
https://github.com/janeczku/calibre-web
synced 2024-11-15 22:34:56 +00:00
2 lines
60 KiB
JavaScript
2 lines
60 KiB
JavaScript
!function(){var a=this,b=a._,c={},d=Array.prototype,e=Object.prototype,f=Function.prototype,g=d.push,h=d.slice,i=d.concat,j=e.toString,k=e.hasOwnProperty,l=d.forEach,m=d.map,n=d.reduce,o=d.reduceRight,p=d.filter,q=d.every,r=d.some,s=d.indexOf,t=d.lastIndexOf,u=Array.isArray,v=Object.keys,w=f.bind,x=function(a){return a instanceof x?a:this instanceof x?(this._wrapped=a,void 0):new x(a)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=x),exports._=x):a._=x,x.VERSION="1.4.4";var y=x.each=x.forEach=function(a,b,d){if(null!=a)if(l&&a.forEach===l)a.forEach(b,d);else if(a.length===+a.length){for(var e=0,f=a.length;f>e;e++)if(b.call(d,a[e],e,a)===c)return}else for(var g in a)if(x.has(a,g)&&b.call(d,a[g],g,a)===c)return};x.map=x.collect=function(a,b,c){var d=[];return null==a?d:m&&a.map===m?a.map(b,c):(y(a,function(a,e,f){d[d.length]=b.call(c,a,e,f)}),d)};var z="Reduce of empty array with no initial value";x.reduce=x.foldl=x.inject=function(a,b,c,d){var e=arguments.length>2;if(null==a&&(a=[]),n&&a.reduce===n)return d&&(b=x.bind(b,d)),e?a.reduce(b,c):a.reduce(b);if(y(a,function(a,f,g){e?c=b.call(d,c,a,f,g):(c=a,e=!0)}),!e)throw new TypeError(z);return c},x.reduceRight=x.foldr=function(a,b,c,d){var e=arguments.length>2;if(null==a&&(a=[]),o&&a.reduceRight===o)return d&&(b=x.bind(b,d)),e?a.reduceRight(b,c):a.reduceRight(b);var f=a.length;if(f!==+f){var g=x.keys(a);f=g.length}if(y(a,function(h,i,j){i=g?g[--f]:--f,e?c=b.call(d,c,a[i],i,j):(c=a[i],e=!0)}),!e)throw new TypeError(z);return c},x.find=x.detect=function(a,b,c){var d;return A(a,function(a,e,f){return b.call(c,a,e,f)?(d=a,!0):void 0}),d},x.filter=x.select=function(a,b,c){var d=[];return null==a?d:p&&a.filter===p?a.filter(b,c):(y(a,function(a,e,f){b.call(c,a,e,f)&&(d[d.length]=a)}),d)},x.reject=function(a,b,c){return x.filter(a,function(a,d,e){return!b.call(c,a,d,e)},c)},x.every=x.all=function(a,b,d){b||(b=x.identity);var e=!0;return null==a?e:q&&a.every===q?a.every(b,d):(y(a,function(a,f,g){return(e=e&&b.call(d,a,f,g))?void 0:c}),!!e)};var A=x.some=x.any=function(a,b,d){b||(b=x.identity);var e=!1;return null==a?e:r&&a.some===r?a.some(b,d):(y(a,function(a,f,g){return e||(e=b.call(d,a,f,g))?c:void 0}),!!e)};x.contains=x.include=function(a,b){return null==a?!1:s&&a.indexOf===s?-1!=a.indexOf(b):A(a,function(a){return a===b})},x.invoke=function(a,b){var c=h.call(arguments,2),d=x.isFunction(b);return x.map(a,function(a){return(d?b:a[b]).apply(a,c)})},x.pluck=function(a,b){return x.map(a,function(a){return a[b]})},x.where=function(a,b,c){return x.isEmpty(b)?c?null:[]:x[c?"find":"filter"](a,function(a){for(var c in b)if(b[c]!==a[c])return!1;return!0})},x.findWhere=function(a,b){return x.where(a,b,!0)},x.max=function(a,b,c){if(!b&&x.isArray(a)&&a[0]===+a[0]&&65535>a.length)return Math.max.apply(Math,a);if(!b&&x.isEmpty(a))return-1/0;var d={computed:-1/0,value:-1/0};return y(a,function(a,e,f){var g=b?b.call(c,a,e,f):a;g>=d.computed&&(d={value:a,computed:g})}),d.value},x.min=function(a,b,c){if(!b&&x.isArray(a)&&a[0]===+a[0]&&65535>a.length)return Math.min.apply(Math,a);if(!b&&x.isEmpty(a))return 1/0;var d={computed:1/0,value:1/0};return y(a,function(a,e,f){var g=b?b.call(c,a,e,f):a;d.computed>g&&(d={value:a,computed:g})}),d.value},x.shuffle=function(a){var b,c=0,d=[];return y(a,function(a){b=x.random(c++),d[c-1]=d[b],d[b]=a}),d};var B=function(a){return x.isFunction(a)?a:function(b){return b[a]}};x.sortBy=function(a,b,c){var d=B(b);return x.pluck(x.map(a,function(a,b,e){return{value:a,index:b,criteria:d.call(c,a,b,e)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;if(c!==d){if(c>d||void 0===c)return 1;if(d>c||void 0===d)return-1}return a.index<b.index?-1:1}),"value")};var C=function(a,b,c,d){var e={},f=B(b||x.identity);return y(a,function(b,g){var h=f.call(c,b,g,a);d(e,h,b)}),e};x.groupBy=function(a,b,c){return C(a,b,c,function(a,b,c){(x.has(a,b)?a[b]:a[b]=[]).push(c)})},x.countBy=function(a,b,c){return C(a,b,c,function(a,b){x.has(a,b)||(a[b]=0),a[b]++})},x.sortedIndex=function(a,b,c,d){c=null==c?x.identity:B(c);for(var e=c.call(d,b),f=0,g=a.length;g>f;){var h=f+g>>>1;e>c.call(d,a[h])?f=h+1:g=h}return f},x.toArray=function(a){return a?x.isArray(a)?h.call(a):a.length===+a.length?x.map(a,x.identity):x.values(a):[]},x.size=function(a){return null==a?0:a.length===+a.length?a.length:x.keys(a).length},x.first=x.head=x.take=function(a,b,c){return null==a?void 0:null==b||c?a[0]:h.call(a,0,b)},x.initial=function(a,b,c){return h.call(a,0,a.length-(null==b||c?1:b))},x.last=function(a,b,c){return null==a?void 0:null==b||c?a[a.length-1]:h.call(a,Math.max(a.length-b,0))},x.rest=x.tail=x.drop=function(a,b,c){return h.call(a,null==b||c?1:b)},x.compact=function(a){return x.filter(a,x.identity)};var D=function(a,b,c){return y(a,function(a){x.isArray(a)?b?g.apply(c,a):D(a,b,c):c.push(a)}),c};x.flatten=function(a,b){return D(a,b,[])},x.without=function(a){return x.difference(a,h.call(arguments,1))},x.uniq=x.unique=function(a,b,c,d){x.isFunction(b)&&(d=c,c=b,b=!1);var e=c?x.map(a,c,d):a,f=[],g=[];return y(e,function(c,d){(b?d&&g[g.length-1]===c:x.contains(g,c))||(g.push(c),f.push(a[d]))}),f},x.union=function(){return x.uniq(i.apply(d,arguments))},x.intersection=function(a){var b=h.call(arguments,1);return x.filter(x.uniq(a),function(a){return x.every(b,function(b){return x.indexOf(b,a)>=0})})},x.difference=function(a){var b=i.apply(d,h.call(arguments,1));return x.filter(a,function(a){return!x.contains(b,a)})},x.zip=function(){for(var a=h.call(arguments),b=x.max(x.pluck(a,"length")),c=Array(b),d=0;b>d;d++)c[d]=x.pluck(a,""+d);return c},x.object=function(a,b){if(null==a)return{};for(var c={},d=0,e=a.length;e>d;d++)b?c[a[d]]=b[d]:c[a[d][0]]=a[d][1];return c},x.indexOf=function(a,b,c){if(null==a)return-1;var d=0,e=a.length;if(c){if("number"!=typeof c)return d=x.sortedIndex(a,b),a[d]===b?d:-1;d=0>c?Math.max(0,e+c):c}if(s&&a.indexOf===s)return a.indexOf(b,c);for(;e>d;d++)if(a[d]===b)return d;return-1},x.lastIndexOf=function(a,b,c){if(null==a)return-1;var d=null!=c;if(t&&a.lastIndexOf===t)return d?a.lastIndexOf(b,c):a.lastIndexOf(b);for(var e=d?c:a.length;e--;)if(a[e]===b)return e;return-1},x.range=function(a,b,c){1>=arguments.length&&(b=a||0,a=0),c=arguments[2]||1;for(var d=Math.max(Math.ceil((b-a)/c),0),e=0,f=Array(d);d>e;)f[e++]=a,a+=c;return f},x.bind=function(a,b){if(a.bind===w&&w)return w.apply(a,h.call(arguments,1));var c=h.call(arguments,2);return function(){return a.apply(b,c.concat(h.call(arguments)))}},x.partial=function(a){var b=h.call(arguments,1);return function(){return a.apply(this,b.concat(h.call(arguments)))}},x.bindAll=function(a){var b=h.call(arguments,1);return 0===b.length&&(b=x.functions(a)),y(b,function(b){a[b]=x.bind(a[b],a)}),a},x.memoize=function(a,b){var c={};return b||(b=x.identity),function(){var d=b.apply(this,arguments);return x.has(c,d)?c[d]:c[d]=a.apply(this,arguments)}},x.delay=function(a,b){var c=h.call(arguments,2);return setTimeout(function(){return a.apply(null,c)},b)},x.defer=function(a){return x.delay.apply(x,[a,1].concat(h.call(arguments,1)))},x.throttle=function(a,b){var c,d,e,f,g=0,h=function(){g=new Date,e=null,f=a.apply(c,d)};return function(){var i=new Date,j=b-(i-g);return c=this,d=arguments,0>=j?(clearTimeout(e),e=null,g=i,f=a.apply(c,d)):e||(e=setTimeout(h,j)),f}},x.debounce=function(a,b,c){var d,e;return function(){var f=this,g=arguments,h=function(){d=null,c||(e=a.apply(f,g))},i=c&&!d;return clearTimeout(d),d=setTimeout(h,b),i&&(e=a.apply(f,g)),e}},x.once=function(a){var b,c=!1;return function(){return c?b:(c=!0,b=a.apply(this,arguments),a=null,b)}},x.wrap=function(a,b){return function(){var c=[a];return g.apply(c,arguments),b.apply(this,c)}},x.compose=function(){var a=arguments;return function(){for(var b=arguments,c=a.length-1;c>=0;c--)b=[a[c].apply(this,b)];return b[0]}},x.after=function(a,b){return 0>=a?b():function(){return 1>--a?b.apply(this,arguments):void 0}},x.keys=v||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var b=[];for(var c in a)x.has(a,c)&&(b[b.length]=c);return b},x.values=function(a){var b=[];for(var c in a)x.has(a,c)&&b.push(a[c]);return b},x.pairs=function(a){var b=[];for(var c in a)x.has(a,c)&&b.push([c,a[c]]);return b},x.invert=function(a){var b={};for(var c in a)x.has(a,c)&&(b[a[c]]=c);return b},x.functions=x.methods=function(a){var b=[];for(var c in a)x.isFunction(a[c])&&b.push(c);return b.sort()},x.extend=function(a){return y(h.call(arguments,1),function(b){if(b)for(var c in b)a[c]=b[c]}),a},x.pick=function(a){var b={},c=i.apply(d,h.call(arguments,1));return y(c,function(c){c in a&&(b[c]=a[c])}),b},x.omit=function(a){var b={},c=i.apply(d,h.call(arguments,1));for(var e in a)x.contains(c,e)||(b[e]=a[e]);return b},x.defaults=function(a){return y(h.call(arguments,1),function(b){if(b)for(var c in b)null==a[c]&&(a[c]=b[c])}),a},x.clone=function(a){return x.isObject(a)?x.isArray(a)?a.slice():x.extend({},a):a},x.tap=function(a,b){return b(a),a};var E=function(a,b,c,d){if(a===b)return 0!==a||1/a==1/b;if(null==a||null==b)return a===b;a instanceof x&&(a=a._wrapped),b instanceof x&&(b=b._wrapped);var e=j.call(a);if(e!=j.call(b))return!1;switch(e){case"[object String]":return a==b+"";case"[object Number]":return a!=+a?b!=+b:0==a?1/a==1/b:a==+b;case"[object Date]":case"[object Boolean]":return+a==+b;case"[object RegExp]":return a.source==b.source&&a.global==b.global&&a.multiline==b.multiline&&a.ignoreCase==b.ignoreCase}if("object"!=typeof a||"object"!=typeof b)return!1;for(var f=c.length;f--;)if(c[f]==a)return d[f]==b;c.push(a),d.push(b);var g=0,h=!0;if("[object Array]"==e){if(g=a.length,h=g==b.length)for(;g--&&(h=E(a[g],b[g],c,d)););}else{var i=a.constructor,k=b.constructor;if(i!==k&&!(x.isFunction(i)&&i instanceof i&&x.isFunction(k)&&k instanceof k))return!1;for(var l in a)if(x.has(a,l)&&(g++,!(h=x.has(b,l)&&E(a[l],b[l],c,d))))break;if(h){for(l in b)if(x.has(b,l)&&!g--)break;h=!g}}return c.pop(),d.pop(),h};x.isEqual=function(a,b){return E(a,b,[],[])},x.isEmpty=function(a){if(null==a)return!0;if(x.isArray(a)||x.isString(a))return 0===a.length;for(var b in a)if(x.has(a,b))return!1;return!0},x.isElement=function(a){return!(!a||1!==a.nodeType)},x.isArray=u||function(a){return"[object Array]"==j.call(a)},x.isObject=function(a){return a===Object(a)},y(["Arguments","Function","String","Number","Date","RegExp"],function(a){x["is"+a]=function(b){return j.call(b)=="[object "+a+"]"}}),x.isArguments(arguments)||(x.isArguments=function(a){return!(!a||!x.has(a,"callee"))}),"function"!=typeof/./&&(x.isFunction=function(a){return"function"==typeof a}),x.isFinite=function(a){return isFinite(a)&&!isNaN(parseFloat(a))},x.isNaN=function(a){return x.isNumber(a)&&a!=+a},x.isBoolean=function(a){return a===!0||a===!1||"[object Boolean]"==j.call(a)},x.isNull=function(a){return null===a},x.isUndefined=function(a){return void 0===a},x.has=function(a,b){return k.call(a,b)},x.noConflict=function(){return a._=b,this},x.identity=function(a){return a},x.times=function(a,b,c){for(var d=Array(a),e=0;a>e;e++)d[e]=b.call(c,e);return d},x.random=function(a,b){return null==b&&(b=a,a=0),a+Math.floor(Math.random()*(b-a+1))};var F={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};F.unescape=x.invert(F.escape);var G={escape:RegExp("["+x.keys(F.escape).join("")+"]","g"),unescape:RegExp("("+x.keys(F.unescape).join("|")+")","g")};x.each(["escape","unescape"],function(a){x[a]=function(b){return null==b?"":(""+b).replace(G[a],function(b){return F[a][b]})}}),x.result=function(a,b){if(null==a)return null;var c=a[b];return x.isFunction(c)?c.call(a):c},x.mixin=function(a){y(x.functions(a),function(b){var c=x[b]=a[b];x.prototype[b]=function(){var a=[this._wrapped];return g.apply(a,arguments),L.call(this,c.apply(x,a))}})};var H=0;x.uniqueId=function(a){var b=++H+"";return a?a+b:b},x.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var I=/(.)^/,J={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},K=/\\|'|\r|\n|\t|\u2028|\u2029/g;x.template=function(a,b,c){var d;c=x.defaults({},c,x.templateSettings);var e=RegExp([(c.escape||I).source,(c.interpolate||I).source,(c.evaluate||I).source].join("|")+"|$","g"),f=0,g="__p+='";a.replace(e,function(b,c,d,e,h){return g+=a.slice(f,h).replace(K,function(a){return"\\"+J[a]}),c&&(g+="'+\n((__t=("+c+"))==null?'':_.escape(__t))+\n'"),d&&(g+="'+\n((__t=("+d+"))==null?'':__t)+\n'"),e&&(g+="';\n"+e+"\n__p+='"),f=h+b.length,b}),g+="';\n",c.variable||(g="with(obj||{}){\n"+g+"}\n"),g="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+g+"return __p;\n";try{d=Function(c.variable||"obj","_",g)}catch(h){throw h.source=g,h}if(b)return d(b,x);var i=function(a){return d.call(this,a,x)};return i.source="function("+(c.variable||"obj")+"){\n"+g+"}",i},x.chain=function(a){return x(a).chain()};var L=function(a){return this._chain?x(a).chain():a};x.mixin(x),y(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=d[a];x.prototype[a]=function(){var c=this._wrapped;return b.apply(c,arguments),"shift"!=a&&"splice"!=a||0!==c.length||delete c[0],L.call(this,c)}}),y(["concat","join","slice"],function(a){var b=d[a];x.prototype[a]=function(){return L.call(this,b.apply(this._wrapped,arguments))}}),x.extend(x.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}.call(this),function(a){var b,c,d,e;!function(){var a={},f={};b=function(b,c,d){a[b]={deps:c,callback:d}},e=d=c=function(b){function d(a){if("."!==a.charAt(0))return a;for(var c=a.split("/"),d=b.split("/").slice(0,-1),e=0,f=c.length;f>e;e++){var g=c[e];if(".."===g)d.pop();else{if("."===g)continue;d.push(g)}}return d.join("/")}if(e._eak_seen=a,f[b])return f[b];if(f[b]={},!a[b])throw new Error("Could not find module "+b);for(var g,h=a[b],i=h.deps,j=h.callback,k=[],l=0,m=i.length;m>l;l++)"exports"===i[l]?k.push(g={}):k.push(c(d(i[l])));var n=j.apply(this,k);return f[b]=g||n}}(),b("rsvp/all",["./promise","exports"],function(a,b){"use strict";var c=a["default"];b["default"]=function(a,b){return c.all(a,b)}}),b("rsvp/asap",["exports"],function(a){"use strict";function b(){return function(){process.nextTick(e)}}function c(){var a=0,b=new h(e),c=document.createTextNode("");return b.observe(c,{characterData:!0}),function(){c.data=a=++a%2}}function d(){return function(){setTimeout(e,1)}}function e(){for(var a=0;a<i.length;a++){var b=i[a],c=b[0],d=b[1];c(d)}i=[]}a["default"]=function(a,b){var c=i.push([a,b]);1===c&&f()};var f,g="undefined"!=typeof window?window:{},h=g.MutationObserver||g.WebKitMutationObserver,i=[];f="undefined"!=typeof process&&"[object process]"==={}.toString.call(process)?b():h?c():d()}),b("rsvp/config",["./events","exports"],function(a,b){"use strict";function c(a,b){return"onerror"===a?(e.on("error",b),void 0):2!==arguments.length?e[a]:(e[a]=b,void 0)}var d=a["default"],e={instrument:!1};d.mixin(e),b.config=e,b.configure=c}),b("rsvp/defer",["./promise","exports"],function(a,b){"use strict";var c=a["default"];b["default"]=function(a){var b={};return b.promise=new c(function(a,c){b.resolve=a,b.reject=c},a),b}}),b("rsvp/events",["exports"],function(a){"use strict";var b=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},c=function(a){var b=a._promiseCallbacks;return b||(b=a._promiseCallbacks={}),b};a["default"]={mixin:function(a){return a.on=this.on,a.off=this.off,a.trigger=this.trigger,a._promiseCallbacks=void 0,a},on:function(a,d){var e,f=c(this);e=f[a],e||(e=f[a]=[]),-1===b(e,d)&&e.push(d)},off:function(a,d){var e,f,g=c(this);return d?(e=g[a],f=b(e,d),-1!==f&&e.splice(f,1),void 0):(g[a]=[],void 0)},trigger:function(a,b){var d,e,f=c(this);if(d=f[a])for(var g=0;g<d.length;g++)e=d[g],e(b)}}}),b("rsvp/filter",["./all","./map","./utils","exports"],function(a,b,c,d){"use strict";function e(a,b,c){if(!i(a))throw new TypeError("You must pass an array to filter.");if(!h(b))throw new TypeError("You must pass a function to filter's second argument.");return f(a,c).then(function(d){return g(a,b,c).then(function(a){var b,c=d.length,e=[];for(b=0;c>b;b++)a[b]&&e.push(d[b]);return e})})}var f=a["default"],g=b["default"],h=c.isFunction,i=c.isArray;d["default"]=e}),b("rsvp/hash",["./promise","./utils","exports"],function(a,b,c){"use strict";var d=a["default"],e=b.isNonThenable,f=b.keysOf;c["default"]=function(a){return new d(function(b,c){function g(a){return function(c){k[a]=c,0===--m&&b(k)}}function h(a){m=0,c(a)}var i,j,k={},l=f(a),m=l.length;if(0===m)return b(k),void 0;for(var n=0;n<l.length;n++)j=l[n],i=a[j],e(i)?(k[j]=i,0===--m&&b(k)):d.cast(i).then(g(j),h)})}}),b("rsvp/instrument",["./config","./utils","exports"],function(a,b,c){"use strict";var d=a.config,e=b.now;c["default"]=function(a,b,c){try{d.trigger(a,{guid:b._guidKey+b._id,eventName:a,detail:b._detail,childGuid:c&&b._guidKey+c._id,label:b._label,timeStamp:e(),stack:new Error(b._label).stack})}catch(f){setTimeout(function(){throw f},0)}}}),b("rsvp/map",["./promise","./all","./utils","exports"],function(a,b,c,d){"use strict";a["default"];var e=b["default"],f=c.isArray,g=c.isFunction;d["default"]=function(a,b,c){if(!f(a))throw new TypeError("You must pass an array to map.");if(!g(b))throw new TypeError("You must pass a function to map's second argument.");return e(a,c).then(function(a){var d,f=a.length,g=[];for(d=0;f>d;d++)g.push(b(a[d]));return e(g,c)})}}),b("rsvp/node",["./promise","exports"],function(a,b){"use strict";function c(a,b){return function(c,d){c?b(c):arguments.length>2?a(e.call(arguments,1)):a(d)}}var d=a["default"],e=Array.prototype.slice;b["default"]=function(a,b){return function(){var f=e.call(arguments),g=this||b;return new d(function(b,e){d.all(f).then(function(d){try{d.push(c(b,e)),a.apply(g,d)}catch(f){e(f)}})})}}}),b("rsvp/promise",["./config","./events","./instrument","./utils","./promise/cast","./promise/all","./promise/race","./promise/resolve","./promise/reject","exports"],function(a,b,c,d,e,f,g,h,i,j){"use strict";function k(){}function l(a,b){if(!z(a))throw new TypeError("You must pass a resolver function as the first argument to the promise constructor");if(!(this instanceof l))throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");this._id=H++,this._label=b,this._subscribers=[],w.instrument&&x("created",this),k!==a&&m(a,this)}function m(a,b){function c(a){r(b,a)}function d(a){t(b,a)}try{a(c,d)}catch(e){d(e)}}function n(a,b,c,d){var e=a._subscribers,f=e.length;e[f]=b,e[f+K]=c,e[f+L]=d}function o(a,b){var c,d,e=a._subscribers,f=a._detail;w.instrument&&x(b===K?"fulfilled":"rejected",a);for(var g=0;g<e.length;g+=3)c=e[g],d=e[g+b],p(b,c,d,f);a._subscribers=null}function p(a,b,c,d){var e,f,g,h,i=z(c);if(i)try{e=c(d),g=!0}catch(j){h=!0,f=j}else e=d,g=!0;q(b,e)||(i&&g?r(b,e):h?t(b,f):a===K?r(b,e):a===L&&t(b,e))}function q(a,b){var c,d=null;try{if(a===b)throw new TypeError("A promises callback cannot return that same promise.");if(y(b)&&(d=b.then,z(d)))return d.call(b,function(d){return c?!0:(c=!0,b!==d?r(a,d):s(a,d),void 0)},function(b){return c?!0:(c=!0,t(a,b),void 0)},"derived from: "+(a._label||" unknown promise")),!0}catch(e){return c?!0:(t(a,e),!0)}return!1}function r(a,b){a===b?s(a,b):q(a,b)||s(a,b)}function s(a,b){a._state===I&&(a._state=J,a._detail=b,w.async(u,a))}function t(a,b){a._state===I&&(a._state=J,a._detail=b,w.async(v,a))}function u(a){o(a,a._state=K)}function v(a){a._onerror&&a._onerror(a._detail),o(a,a._state=L)}var w=a.config;b["default"];var x=c["default"],y=d.objectOrFunction,z=d.isFunction,A=d.now,B=e["default"],C=f["default"],D=g["default"],E=h["default"],F=i["default"],G="rsvp_"+A()+"-",H=0;j["default"]=l,l.cast=B,l.all=C,l.race=D,l.resolve=E,l.reject=F;var I=void 0,J=0,K=1,L=2;l.prototype={constructor:l,_id:void 0,_guidKey:G,_label:void 0,_state:void 0,_detail:void 0,_subscribers:void 0,_onerror:function(a){w.trigger("error",a)},then:function(a,b,c){var d=this;this._onerror=null;var e=new this.constructor(k,c);if(this._state){var f=arguments;w.async(function(){p(d._state,e,f[d._state-1],d._detail)})}else n(this,e,a,b);return w.instrument&&x("chained",d,e),e},"catch":function(a,b){return this.then(null,a,b)},"finally":function(a,b){var c=this.constructor;return this.then(function(b){return c.cast(a()).then(function(){return b})},function(b){return c.cast(a()).then(function(){throw b})},b)}}}),b("rsvp/promise/all",["../utils","exports"],function(a,b){"use strict";var c=a.isArray,d=a.isNonThenable;b["default"]=function(a,b){if(!c(a))throw new TypeError("You must pass an array to all.");var e=this;return new e(function(b,c){function f(a){return function(c){j[a]=c,0===--i&&b(j)}}function g(a){i=0,c(a)}var h,i=a.length,j=new Array(i);if(0===i)return b(j),void 0;for(var k=0;k<a.length;k++)h=a[k],d(h)?(j[k]=h,0===--i&&b(j)):e.cast(h).then(f(k),g)},b)}}),b("rsvp/promise/cast",["exports"],function(a){"use strict";a["default"]=function(a){var b=this;return a&&"object"==typeof a&&a.constructor===b?a:new b(function(b){b(a)})}}),b("rsvp/promise/race",["../utils","exports"],function(a,b){"use strict";var c=a.isArray;a.isFunction;var d=a.isNonThenable;b["default"]=function(a,b){if(!c(a))throw new TypeError("You must pass an array to race.");var e,f=this;return new f(function(b,c){function g(a){i&&(i=!1,b(a))}function h(a){i&&(i=!1,c(a))}for(var i=!0,j=0;j<a.length;j++){if(e=a[j],d(e))return i=!1,b(e),void 0;f.cast(e).then(g,h)}},b)}}),b("rsvp/promise/reject",["exports"],function(a){"use strict";a["default"]=function(a,b){var c=this;return new c(function(b,c){c(a)},b)}}),b("rsvp/promise/resolve",["exports"],function(a){"use strict";a["default"]=function(a,b){var c=this;return new c(function(b){b(a)},b)}}),b("rsvp/race",["./promise","exports"],function(a,b){"use strict";var c=a["default"];b["default"]=function(a,b){return c.race(a,b)}}),b("rsvp/reject",["./promise","exports"],function(a,b){"use strict";var c=a["default"];b["default"]=function(a,b){return c.reject(a,b)}}),b("rsvp/resolve",["./promise","exports"],function(a,b){"use strict";var c=a["default"];b["default"]=function(a,b){return c.resolve(a,b)}}),b("rsvp/rethrow",["exports"],function(a){"use strict";a["default"]=function(a){throw setTimeout(function(){throw a}),a}}),b("rsvp/utils",["exports"],function(a){"use strict";function b(a){return"function"==typeof a||"object"==typeof a&&null!==a}function c(a){return"function"==typeof a}function d(a){return!b(a)}function e(a){return"[object Array]"===Object.prototype.toString.call(a)}a.objectOrFunction=b,a.isFunction=c,a.isNonThenable=d,a.isArray=e;var f=Date.now||function(){return(new Date).getTime()};a.now=f;var g=Object.keys||function(a){var b=[];for(var c in a)b.push(c);return b};a.keysOf=g}),b("rsvp",["./rsvp/promise","./rsvp/events","./rsvp/node","./rsvp/all","./rsvp/race","./rsvp/hash","./rsvp/rethrow","./rsvp/defer","./rsvp/config","./rsvp/map","./rsvp/resolve","./rsvp/reject","./rsvp/asap","./rsvp/filter","exports"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){"use strict";function p(a,b){A.async(a,b)}function q(){A.on.apply(A,arguments)}function r(){A.off.apply(A,arguments)}var s=a["default"],t=b["default"],u=c["default"],v=d["default"],w=e["default"],x=f["default"],y=g["default"],z=h["default"],A=i.config,B=i.configure,C=j["default"],D=k["default"],E=l["default"],F=m["default"],G=n["default"];if(A.async=F,"undefined"!=typeof window&&"object"==typeof window.__PROMISE_INSTRUMENTATION__){var H=window.__PROMISE_INSTRUMENTATION__;B("instrument",!0);for(var I in H)H.hasOwnProperty(I)&&q(I,H[I])}o.Promise=s,o.EventTarget=t,o.all=v,o.race=w,o.hash=x,o.rethrow=y,o.defer=z,o.denodeify=u,o.configure=B,o.on=q,o.off=r,o.resolve=D,o.reject=E,o.async=p,o.map=C,o.filter=G}),a.RSVP=c("rsvp")}(window);var EPUBJS=EPUBJS||{};EPUBJS.VERSION="0.1.9",EPUBJS.plugins=EPUBJS.plugins||{},EPUBJS.filePath=EPUBJS.filePath||"/epubjs/",function(a){var b=a.ePub||{},c=a.ePub=function(){var a,b;return"undefined"!=typeof arguments[0]&&"string"==typeof arguments[0]&&(a=arguments[0],arguments[1]&&"object"==typeof arguments[1]?(b=arguments[1],b.bookPath=a):b={bookPath:a}),arguments[0]&&"object"==typeof arguments[0]&&(b=arguments[0]),new EPUBJS.Book(b)};_.extend(c,{noConflict:function(){return a.ePub=b,this}}),"function"==typeof define&&define.amd?define(function(){return c}):"undefined"!=typeof module&&module.exports&&(module.exports=c)}(window),EPUBJS.Book=function(a){this.settings=_.defaults(a||{},{bookPath:null,bookKey:null,packageUrl:null,storage:!1,fromStorage:!1,saved:!1,online:!0,contained:!1,width:!1,height:!1,spreads:!0,fixedLayout:!1,responsive:!0,version:1,restore:!1,reload:!1,"goto":!1,withCredentials:!1,styles:{}}),this.settings.EPUBJSVERSION=EPUBJS.VERSION,this.spinePos=0,this.stored=!1,this.hooks={beforeChapterDisplay:[]},this.getHooks(),this.online=this.settings.online||navigator.onLine,this.networkListeners(),this.settings.storage!==!1&&(this.storage=new fileStorage.storage(this.settings.storage)),this.ready={manifest:new RSVP.defer,spine:new RSVP.defer,metadata:new RSVP.defer,cover:new RSVP.defer,toc:new RSVP.defer},this.readyPromises=[this.ready.manifest.promise,this.ready.spine.promise,this.ready.metadata.promise,this.ready.cover.promise,this.ready.toc.promise],this.ready.all=RSVP.all(this.readyPromises),this.ready.all.then(this._ready.bind(this)),this._q=[],this.isRendered=!1,this._rendering=!1,this._displayQ=[],this.defer_opened=new RSVP.defer,this.opened=this.defer_opened.promise,"string"==typeof this.settings.bookPath&&this.open(this.settings.bookPath,this.settings.reload),window.addEventListener("beforeunload",this.unload.bind(this),!1)},EPUBJS.Book.prototype.open=function(a,b){var c,d=this,e=new RSVP.defer;return this.settings.bookPath=a,this.bookUrl=this.urlFrom(a),this.settings.contained||this.isContained(a)?(this.settings.contained=this.contained=!0,this.bookUrl="",c=this.unarchive(a).then(function(){return d.loadPackage()})):c=this.loadPackage(),this.settings.restore&&!b?c.then(function(a){var b=d.packageIdentifier(a),c=d.restore(b);c||d.unpack(a),e.resolve(),d.defer_opened.resolve()}):c.then(function(a){d.unpack(a),e.resolve(),d.defer_opened.resolve()}),this.online&&this.settings.storage&&!this.settings.contained&&(this.settings.stored||e.then(d.storeOffline())),e.promise},EPUBJS.Book.prototype.loadPackage=function(a){var b,c=this,d=new EPUBJS.Parser,e=a||"META-INF/container.xml";return b=this.settings.packageUrl?c.loadXml(c.settings.packageUrl):c.loadXml(c.bookUrl+e).then(function(a){return d.container(a)}).then(function(a){return c.settings.contentsPath=c.bookUrl+a.basePath,c.settings.packageUrl=c.bookUrl+a.packagePath,c.settings.encoding=a.encoding,c.loadXml(c.settings.packageUrl)})},EPUBJS.Book.prototype.packageIdentifier=function(a){var b=new EPUBJS.Parser;return b.identifier(a)},EPUBJS.Book.prototype.unpack=function(a){var b=this,c=new EPUBJS.Parser;b.contents=c.packageContents(a,b.settings.contentsPath),b.manifest=b.contents.manifest,b.spine=b.contents.spine,b.spineIndexByURL=b.contents.spineIndexByURL,b.metadata=b.contents.metadata,b.setBookKey(b.metadata.identifier),b.cover=b.contents.cover=b.settings.contentsPath+b.contents.coverPath,b.spineNodeIndex=b.contents.spineNodeIndex,b.ready.manifest.resolve(b.contents.manifest),b.ready.spine.resolve(b.contents.spine),b.ready.metadata.resolve(b.contents.metadata),b.ready.cover.resolve(b.contents.cover),b.contents.navPath?(b.settings.navUrl=b.settings.contentsPath+b.contents.navPath,b.loadXml(b.settings.navUrl).then(function(a){return c.nav(a,b.spineIndexByURL,b.spine)}).then(function(a){b.toc=b.contents.toc=a,b.ready.toc.resolve(b.contents.toc)},function(){b.ready.toc.resolve(!1)})):b.contents.tocPath?(b.settings.tocUrl=b.settings.contentsPath+b.contents.tocPath,b.loadXml(b.settings.tocUrl).then(function(a){return c.toc(a,b.spineIndexByURL,b.spine)}).then(function(a){b.toc=b.contents.toc=a,b.ready.toc.resolve(b.contents.toc)},function(){b.ready.toc.resolve(!1)})):b.ready.toc.resolve(!1)},EPUBJS.Book.prototype.getMetadata=function(){return this.ready.metadata.promise},EPUBJS.Book.prototype.getToc=function(){return this.ready.toc.promise},EPUBJS.Book.prototype.networkListeners=function(){var a=this;window.addEventListener("offline",function(){a.online=!1,a.trigger("book:offline")},!1),window.addEventListener("online",function(){a.online=!0,a.trigger("book:online")},!1)},EPUBJS.Book.prototype.loadXml=function(a){return this.settings.fromStorage?this.storage.getXml(a,this.settings.encoding):this.settings.contained?this.zip.getXml(a,this.settings.encoding):EPUBJS.core.request(a,"xml",this.settings.withCredentials)},EPUBJS.Book.prototype.urlFrom=function(a){var b,c=EPUBJS.core.uri(a),d=c.protocol,e="/"==c.path[0],f=window.location,g=f.origin||f.protocol+"//"+f.host,h=document.getElementsByTagName("base");return h.length&&(b=h[0].href),c.protocol?c.origin+c.path:!d&&e?(b||g)+c.path:d||e?void 0:EPUBJS.core.resolveUrl(b||f.pathname,c.path)},EPUBJS.Book.prototype.unarchive=function(a){return this.zip=new EPUBJS.Unarchiver,this.zip.openZip(a)},EPUBJS.Book.prototype.isContained=function(a){var b=EPUBJS.core.uri(a),c=b.filename.lastIndexOf("."),d=b.filename.slice(c+1);return!d||"epub"!=d&&"zip"!=d?!1:!0},EPUBJS.Book.prototype.isSaved=function(a){var b=localStorage.getItem(a);return localStorage&&null!==b?!0:!1},EPUBJS.Book.prototype.setBookKey=function(a){return this.settings.bookKey||(this.settings.bookKey=this.generateBookKey(a)),this.settings.bookKey},EPUBJS.Book.prototype.generateBookKey=function(a){return"epubjs:"+EPUBJS.VERSION+":"+window.location.host+":"+a},EPUBJS.Book.prototype.saveContents=function(){localStorage.setItem(this.settings.bookKey,JSON.stringify(this.contents))},EPUBJS.Book.prototype.removeSavedContents=function(){localStorage.removeItem(this.settings.bookKey)},EPUBJS.Book.prototype.renderTo=function(a){var b,c=this;if(_.isElement(a))this.element=a;else{if("string"!=typeof a)return console.error("Not an Element"),void 0;this.element=EPUBJS.core.getEl(a)}return b=this.opened.then(function(){return c.render=new EPUBJS.Renderer(c),c._rendered(),c.startDisplay()},function(a){console.error(a)}),b.then(null,function(a){console.error(a)}),b},EPUBJS.Book.prototype.startDisplay=function(){var a;return a=this.settings.goto?this.goto(this.settings.goto):this.settings.previousLocationCfi?this.displayChapter(this.settings.previousLocationCfi):this.displayChapter(this.spinePos)},EPUBJS.Book.prototype.restore=function(a){var b,c=this,d=["manifest","spine","metadata","cover","toc","spineNodeIndex","spineIndexByURL"],e=!1,f=this.setBookKey(a),g=localStorage.getItem(f),h=d.length;if(this.settings.clearSaved&&(e=!0),!e&&"undefined"!=g&&null!=g)for(c.contents=JSON.parse(g),b=0;h>b;b++){var i=d[b];if(!c.contents[i]){e=!0;break}c[i]=c.contents[i]}return!e&&g&&this.contents&&this.settings.contentsPath?(this.ready.manifest.resolve(this.manifest),this.ready.spine.resolve(this.spine),this.ready.metadata.resolve(this.metadata),this.ready.cover.resolve(this.cover),this.ready.toc.resolve(this.toc),!0):!1},EPUBJS.Book.prototype.displayChapter=function(a,b){var c,d,e,f=this;return this.isRendered?this._rendering?(this._displayQ.push(arguments),void 0):(_.isNumber(a)?e=a:(d=new EPUBJS.EpubCFI(a),e=d.spinePos),(0>e||e>=this.spine.length)&&(console.warn("Not A Valid Location"),e=0,b=!1,d=!1),this.spinePos=e,this.chapter=new EPUBJS.Chapter(this.spine[e]),this._rendering=!0,c=f.render.chapter(this.chapter),d?c.then(function(b){b.currentLocationCfi=a,b.gotoCfiFragment(d)}):b&&c.then(function(a){a.gotoChapterEnd()}),this.settings.fromStorage||this.settings.contained||c.then(function(){f.preloadNextChapter()}),c.then(function(){var a;f._rendering=!1,f._displayQ.length&&(a=f._displayQ.unshift(),f.displayChapter.apply(f,a))}),c):this._enqueue("displayChapter",arguments)},EPUBJS.Book.prototype.nextPage=function(){var a;return this.isRendered?(a=this.render.nextPage(),a?void 0:this.nextChapter()):this._enqueue("nextPage",arguments)
|
|
},EPUBJS.Book.prototype.prevPage=function(){var a;return this.isRendered?(a=this.render.prevPage(),a?void 0:this.prevChapter()):this._enqueue("prevPage",arguments)},EPUBJS.Book.prototype.nextChapter=function(){return this.spinePos>this.spine.length?void 0:(this.spinePos++,this.displayChapter(this.spinePos))},EPUBJS.Book.prototype.prevChapter=function(){return this.spinePos<1?void 0:(this.spinePos--,this.displayChapter(this.spinePos,!0))},EPUBJS.Book.prototype.getCurrentLocationCfi=function(){return this.isRendered?this.render.currentLocationCfi:!1},EPUBJS.Book.prototype.gotoCfi=function(a){return this.isRendered?this.displayChapter(a):(this.settings.previousLocationCfi=a,void 0)},EPUBJS.Book.prototype.goto=function(a){var b,c,d,e,f=new RSVP.defer;return this.isRendered?(b=a.split("#"),c=b[0],d=b[1]||!1,e=this.spineIndexByURL[c],c||(e=this.chapter?this.chapter.spinePos:0),"number"!=typeof e?!1:this.chapter&&e==this.chapter.spinePos?(d&&this.render.section(d),f.resolve(this.currentChapter),f.promise):this.displayChapter(e).then(function(){d&&this.render.section(d)}.bind(this))):(this.settings.goto=a,void 0)},EPUBJS.Book.prototype.preloadNextChapter=function(){var a,b=this.spinePos+1;return b>=this.spine.length?!1:(a=new EPUBJS.Chapter(this.spine[b]),a&&EPUBJS.core.request(a.absolute),void 0)},EPUBJS.Book.prototype.storeOffline=function(){var a=this,b=_.values(this.manifest);return EPUBJS.storage.batch(b).then(function(){a.settings.stored=!0,a.trigger("book:stored")})},EPUBJS.Book.prototype.availableOffline=function(){return this.settings.stored>0?!0:!1},EPUBJS.Book.prototype.setStyle=function(a,b,c){return this.isRendered?(this.settings.styles[a]=b,this.render.setStyle(a,b,c),this.render.reformat(),void 0):this._enqueue("setStyle",arguments)},EPUBJS.Book.prototype.removeStyle=function(a){return this.isRendered?(this.render.removeStyle(a),this.render.reformat(),delete this.settings.styles[a],void 0):this._enqueue("removeStyle",arguments)},EPUBJS.Book.prototype.useSpreads=function(a){return this.isRendered?(this.settings.spreads=a,this.render.reformat(),this.trigger("book:spreads",a),void 0):this._enqueue("useSpreads",arguments)},EPUBJS.Book.prototype.unload=function(){this.settings.restore&&this.saveContents(),this.trigger("book:unload")},EPUBJS.Book.prototype.destroy=function(){window.removeEventListener("beforeunload",this.unload),this.currentChapter&&this.currentChapter.unload(),this.unload(),this.render&&this.render.remove()},EPUBJS.Book.prototype._enqueue=function(a,b){this._q.push({command:a,args:b})},EPUBJS.Book.prototype._ready=function(){this.trigger("book:ready")},EPUBJS.Book.prototype._rendered=function(){var a=this;this.isRendered=!0,this.trigger("book:rendered"),this._q.forEach(function(b){a[b.command].apply(a,b.args)})},EPUBJS.Book.prototype.getHooks=function(){var a,b=this;_.values(this.hooks);for(var c in this.hooks)a=_.values(EPUBJS.Hooks[c]),a.forEach(function(a){b.registerHook(c,a)})},EPUBJS.Book.prototype.registerHook=function(a,b,c){var d=this;"undefined"!=typeof this.hooks[a]?"function"==typeof b?c?this.hooks[a].unshift(b):this.hooks[a].push(b):Array.isArray(b)&&b.forEach(function(b){c?d.hooks[a].unshift(b):d.hooks[a].push(b)}):this.hooks[a]=[func]},EPUBJS.Book.prototype.triggerHooks=function(a,b,c){function d(){f--,0>=f&&b&&b()}var e,f;return"undefined"==typeof this.hooks[a]?!1:(e=this.hooks[a],f=e.length,e.forEach(function(a){a(d,c)}),void 0)},RSVP.EventTarget.mixin(EPUBJS.Book.prototype),RSVP.on("error",function(){}),RSVP.configure("instrument",!0),RSVP.on("rejected",function(a){console.error(a.detail.message,a.detail.stack)}),EPUBJS.Chapter=function(a){this.href=a.href,this.absolute=a.url,this.id=a.id,this.spinePos=a.index,this.properties=a.properties,this.linear=a.linear,this.pages=1},EPUBJS.Chapter.prototype.contents=function(a){return a?a.get(href):EPUBJS.core.request(href,"xml")},EPUBJS.Chapter.prototype.url=function(a){var b=new RSVP.defer;return a?(this.tempUrl||(this.tempUrl=a.getUrl(this.absolute)),this.tempUrl):(b.resolve(this.absolute),b.promise)},EPUBJS.Chapter.prototype.setPages=function(a){this.pages=a},EPUBJS.Chapter.prototype.getPages=function(){return this.pages},EPUBJS.Chapter.prototype.getID=function(){return this.ID},EPUBJS.Chapter.prototype.unload=function(a){this.tempUrl&&a&&(a.revokeUrl(this.tempUrl),this.tempUrl=!1)};var EPUBJS=EPUBJS||{};EPUBJS.core={},EPUBJS.core.getEl=function(a){return document.getElementById(a)},EPUBJS.core.getEls=function(a){return document.getElementsByClassName(a)},EPUBJS.core.request=function(a,b,c){function d(){if(this.readyState===this.DONE)if(200===this.status||this.responseXML){var a;a="xml"==b?this.responseXML:"json"==b?JSON.parse(this.response):"blob"==b?e?this.response:new Blob([this.response]):this.response,g.resolve(a)}else g.reject({message:this.response,stack:(new Error).stack})}var e=window.URL,f=e?"blob":"arraybuffer",g=new RSVP.defer,h=new XMLHttpRequest,i=XMLHttpRequest.prototype;return"overrideMimeType"in i||Object.defineProperty(i,"overrideMimeType",{value:function(){}}),c&&(h.withCredentials=!0),h.open("GET",a,!0),h.onreadystatechange=d,"blob"==b&&(h.responseType=f),"json"==b&&h.setRequestHeader("Accept","application/json"),"xml"==b&&h.overrideMimeType("text/xml"),h.send(),g.promise},EPUBJS.core.toArray=function(a){var b=[];for(var c in a){var d;a.hasOwnProperty(c)&&(d=a[c],d.ident=c,b.push(d))}return b},EPUBJS.core.uri=function(a){var b,c,d={protocol:"",host:"",path:"",origin:"",directory:"",base:"",filename:"",href:a},e=a.indexOf("://"),f=a.indexOf("?");return-1!=f&&(d.search=a.slice(f+1),a=a.slice(0,f)),-1!=e?(d.protocol=a.slice(0,e),b=a.slice(e+3),c=b.indexOf("/"),-1===c?(d.host=d.path,d.path=""):(d.host=b.slice(0,c),d.path=b.slice(c)),d.origin=d.protocol+"://"+d.host,d.directory=EPUBJS.core.folder(d.path),d.base=d.origin+d.directory):(d.path=a,d.directory=EPUBJS.core.folder(a),d.base=d.directory),d.filename=a.replace(d.base,""),d},EPUBJS.core.folder=function(a){var b=a.lastIndexOf("/");return-1==b&&(folder=""),folder=a.slice(0,b+1)},EPUBJS.core.dataURLToBlob=function(a){var b,c,d,e,f,g=";base64,";if(-1==a.indexOf(g))return b=a.split(","),c=b[0].split(":")[1],d=b[1],new Blob([d],{type:c});b=a.split(g),c=b[0].split(":")[1],d=window.atob(b[1]),e=d.length,f=new Uint8Array(e);for(var h=0;e>h;++h)f[h]=d.charCodeAt(h);return new Blob([f],{type:c})},EPUBJS.core.addScript=function(a,b,c){var d,e;e=!1,d=document.createElement("script"),d.type="text/javascript",d.async=!1,d.src=a,d.onload=d.onreadystatechange=function(){e||this.readyState&&"complete"!=this.readyState||(e=!0,b&&b())},c=c||document.body,c.appendChild(d)},EPUBJS.core.addScripts=function(a,b,c){var d=a.length,e=0,f=function(){e++,d==e?b&&b():EPUBJS.core.addScript(a[e],f,c)};EPUBJS.core.addScript(a[e],f,c)},EPUBJS.core.addCss=function(a,b,c){var d,e;e=!1,d=document.createElement("link"),d.type="text/css",d.rel="stylesheet",d.href=a,d.onload=d.onreadystatechange=function(){e||this.readyState&&"complete"!=this.readyState||(e=!0,b&&b())},c=c||document.body,c.appendChild(d)},EPUBJS.core.prefixed=function(a){var b=["Webkit","Moz","O","ms"],c=a[0].toUpperCase()+a.slice(1),d=b.length;if("undefined"!=typeof document.body.style[a])return a;for(var e=0;d>e;e++)if("undefined"!=typeof document.body.style[b[e]+c])return b[e]+c;return a},EPUBJS.core.resolveUrl=function(a,b){var c,d,e=[],f=EPUBJS.core.uri(b),g=a.split("/");return f.host?b:(g.pop(),d=b.split("/"),d.forEach(function(a){".."===a?g.pop():e.push(a)}),c=g.concat(e),c.join("/"))},EPUBJS.EpubCFI=function(a){return a?this.parse(a):void 0},EPUBJS.EpubCFI.prototype.generateChapter=function(a,b,c){var d=parseInt(b),e=a+1,f="/"+e+"/";return f+=2*(d+1),c&&(f+="["+c+"]"),f+="!"},EPUBJS.EpubCFI.prototype.generateFragment=function(a,b){var c=this.pathTo(a),d=[];return b&&d.push(b),c.forEach(function(a){var b="";b+=2*(a.index+1),a.id&&"EPUBJS"!=a.id.slice(0,6)&&(b+="["+a.id+"]"),d.push(b)}),d.join("/")},EPUBJS.EpubCFI.prototype.pathTo=function(a){for(var b,c=[];a&&null!==a.parentNode&&9!=a.parentNode.nodeType;)b=a.parentNode.children,c.unshift({id:a.id,tagName:a.tagName,index:b?Array.prototype.indexOf.call(b,a):0}),a=a.parentNode;return c},EPUBJS.EpubCFI.prototype.getChapter=function(a){var b=a.split("!");return b[0]},EPUBJS.EpubCFI.prototype.getFragment=function(a){var b=a.split("!");return b[1]},EPUBJS.EpubCFI.prototype.getOffset=function(a){var b=a.split(":");return[b[0],b[1]]},EPUBJS.EpubCFI.prototype.parse=function(a){var b,c,d,e,f,g={};return g.chapter=this.getChapter(a),b=parseInt(g.chapter.split("/")[2])||!1,g.fragment=this.getFragment(a),b&&g.fragment?(g.spinePos=parseInt(b)/2-1||0,c=g.chapter.match(/\[(.*)\]/),g.spineId=c?c[1]:!1,d=g.fragment.split("/"),e=d[d.length-1],g.sections=[],parseInt(e)%2&&(f=this.getOffset(),g.text=parseInt(f[0]),g.character=parseInt(f[1]),d.pop()),d.forEach(function(a){var b,c,d;a&&(b=parseInt(a)/2-1,c=a.match(/\[(.*)\]/),c&&c[1]&&(d=c[1]),g.sections.push({index:b,id:d||!1}))}),g):{spinePos:-1}},EPUBJS.EpubCFI.prototype.getElement=function(a,b){for(var c,d=b||document,e=a.sections,f=d.getElementsByTagName("html")[0],g=Array.prototype.slice.call(f.children);e&&e.length>0;)c=e.shift(),c.id?f=d.getElementById(c.id):(f=g[c.index],g||console.error("No Kids",f)),f||console.error("No Element For",c),g=Array.prototype.slice.call(f.children);return f},EPUBJS.Events=function(a,b){return this.events={},this.el=b?b:document.createElement("div"),a.createEvent=this.createEvent,a.tell=this.tell,a.listen=this.listen,a.deafen=this.deafen,a.listenUntil=this.listenUntil,this},EPUBJS.Events.prototype.createEvent=function(a){var b=new CustomEvent(a);return this.events[a]=b,b},EPUBJS.Events.prototype.tell=function(a,b){var c;this.events[a]?c=this.events[a]:(console.warn("No event:",a,"defined yet, creating."),c=this.createEvent(a)),b&&(c.msg=b),this.el.dispatchEvent(c)},EPUBJS.Events.prototype.listen=function(a,b,c){return this.events[a]?(c?this.el.addEventListener(a,b.bind(c),!1):this.el.addEventListener(a,b,!1),void 0):(console.warn("No event:",a,"defined yet, creating."),this.createEvent(a),void 0)},EPUBJS.Events.prototype.deafen=function(a,b){this.el.removeEventListener(a,b,!1)},EPUBJS.Events.prototype.listenUntil=function(a,b,c,d){function e(){this.deafen(a,c),this.deafen(b,e)}this.listen(a,c,d),this.listen(b,e,this)},EPUBJS.Hooks=function(){"use strict";return{register:function(a){if(void 0===this[a]&&(this[a]={}),"object"!=typeof this[a])throw"Already registered: "+a;return this[a]}}}(),EPUBJS.Parser=function(a){this.baseUrl=a||""},EPUBJS.Parser.prototype.container=function(a){var b,c,d,e;return a?(b=a.querySelector("rootfile"))?(c=b.getAttribute("full-path"),d=EPUBJS.core.uri(c).directory,e=a.xmlEncoding,{packagePath:c,basePath:d,encoding:e}):(console.error("No RootFile Found"),void 0):(console.error("Container File Not Found"),void 0)},EPUBJS.Parser.prototype.identifier=function(a){var b;return a?(b=a.querySelector("metadata"),b?this.getElementText(b,"identifier"):(console.error("No Metadata Found"),void 0)):(console.error("Package File Not Found"),void 0)},EPUBJS.Parser.prototype.packageContents=function(a,b){var c,d,e,f,g,h,i,j,k,l,m=this;return b&&(this.baseUrl=b),a?(c=a.querySelector("metadata"))?(d=a.querySelector("manifest"),c?(e=a.querySelector("spine"),c?(f=m.manifest(d),g=m.findNavPath(d),h=m.findTocPath(d),i=m.findCoverPath(d),j=Array.prototype.indexOf.call(e.parentNode.childNodes,e),k=m.spine(e,f),l={},k.forEach(function(a){l[a.href]=a.index}),{metadata:m.metadata(c),spine:k,manifest:f,navPath:g,tocPath:h,coverPath:i,spineNodeIndex:j,spineIndexByURL:l}):(console.error("No Spine Found"),void 0)):(console.error("No Manifest Found"),void 0)):(console.error("No Metadata Found"),void 0):(console.error("Package File Not Found"),void 0)},EPUBJS.Parser.prototype.findNavPath=function(a){var b=a.querySelector("item[properties^='nav']");return b?b.getAttribute("href"):!1},EPUBJS.Parser.prototype.findTocPath=function(a){var b=a.querySelector("item[media-type='application/x-dtbncx+xml']");return b?b.getAttribute("href"):!1},EPUBJS.Parser.prototype.findCoverPath=function(a){var b=a.querySelector("item[properties='cover-image']");return b?b.getAttribute("href"):!1},EPUBJS.Parser.prototype.metadata=function(a){var b={},c=this;return b.bookTitle=c.getElementText(a,"title"),b.creator=c.getElementText(a,"creator"),b.description=c.getElementText(a,"description"),b.pubdate=c.getElementText(a,"date"),b.publisher=c.getElementText(a,"publisher"),b.identifier=c.getElementText(a,"identifier"),b.language=c.getElementText(a,"language"),b.rights=c.getElementText(a,"rights"),b.modified_date=c.querySelectorText(a,"meta[property='dcterms:modified']"),b.layout=c.querySelectorText(a,"meta[property='rendition:orientation']"),b.orientation=c.querySelectorText(a,"meta[property='rendition:orientation']"),b.spread=c.querySelectorText(a,"meta[property='rendition:spread']"),b},EPUBJS.Parser.prototype.getElementText=function(a,b){var c,d=a.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/",b);return d&&0!==d.length?(c=d[0],c.childNodes.length?c.childNodes[0].nodeValue:""):""},EPUBJS.Parser.prototype.querySelectorText=function(a,b){var c=a.querySelector(b);return c&&c.childNodes.length?c.childNodes[0].nodeValue:""},EPUBJS.Parser.prototype.manifest=function(a){var b=this.baseUrl,c={},d=a.querySelectorAll("item"),e=Array.prototype.slice.call(d);return e.forEach(function(a){var d=a.getAttribute("id"),e=a.getAttribute("href")||"",f=a.getAttribute("media-type")||"",g=a.getAttribute("properties")||"";c[d]={href:e,url:b+e,type:f,properties:g}}),c},EPUBJS.Parser.prototype.spine=function(a,b){var c=[],d=a.getElementsByTagName("itemref"),e=Array.prototype.slice.call(d);return e.forEach(function(a,d){var e=a.getAttribute("idref"),f={id:e,linear:a.getAttribute("linear")||"",properties:b[e].properties||"",href:b[e].href,url:b[e].url,index:d};c.push(f)}),c},EPUBJS.Parser.prototype.nav=function(a,b,c){function d(a){var b=[];return Array.prototype.slice.call(a.childNodes).forEach(function(a){"ol"==a.tagName&&Array.prototype.slice.call(a.childNodes).forEach(function(a){"li"==a.tagName&&b.push(a)})}),b}function e(a){var b=null;return Array.prototype.slice.call(a.childNodes).forEach(function(a){("a"==a.tagName||"span"==a.tagName)&&(b=a)}),b}function f(a){var g=[],i=d(a),j=Array.prototype.slice.call(i),k=j.length;return 0===k?!1:(j.forEach(function(d){var i,j=d.getAttribute("id")||!1,k=e(d),l=k.getAttribute("href")||"",m=k.textContent||"",n=l.split("#"),o=n[0],p=f(d),q=b[o];j||(q?(i=c[q],j=i.id):j="epubjs-autogen-toc-id-"+h++),d.setAttribute("id",j),g.push({id:j,href:l,label:m,subitems:p,parent:a?a.getAttribute("id"):null})}),g)}var g=a.querySelector("nav"),h=0;return g?f(g):[]},EPUBJS.Parser.prototype.toc=function(a,b,c){function d(a){var e=[],f=[],g=a.querySelectorAll("navPoint"),f=Array.prototype.slice.call(g).reverse(),h=f.length;return 0===h?[]:(f.forEach(function(f){var g,h=f.getAttribute("id")||!1,i=f.querySelector("content"),j=i.getAttribute("src"),k=f.querySelector("navLabel"),l=k.textContent?k.textContent:"",m=j.split("#"),n=m[0],o=b[n],p=d(f);h||(o?(g=c[o],h=g.id):h="epubjs-autogen-toc-id-"+idCounter++),e.unshift({id:h,href:j,label:l,subitems:p,parent:a?a.getAttribute("id"):null})}),e)}var e=a.querySelector("navMap");return e?d(e):[]},EPUBJS.Renderer=function(a){this.el=a.element,this.book=a,this.caches={},this.crossBrowserColumnCss(),this.epubcfi=new EPUBJS.EpubCFI,this.initialize(),this.listenedEvents=["keydown","keyup","keypressed","mouseup","mousedown","click"],this.listeners()},EPUBJS.Renderer.prototype.initialize=function(){this.iframe=document.createElement("iframe"),this.iframe.scrolling="no",this.book.settings.width||this.book.settings.height?this.resizeIframe(this.book.settings.width||this.el.clientWidth,this.book.settings.height||this.el.clientHeight):this.resizeIframe("100%","100%"),this.el.appendChild(this.iframe)},EPUBJS.Renderer.prototype.listeners=function(){this.resized=_.throttle(this.onResized.bind(this),10),this.book.registerHook("beforeChapterDisplay",this.replaceLinks.bind(this),!0),this.determineStore()&&this.book.registerHook("beforeChapterDisplay",[EPUBJS.replace.head,EPUBJS.replace.resources,EPUBJS.replace.svg],!0)},EPUBJS.Renderer.prototype.chapter=function(a){var b=this,c=!1;return this.book.settings.contained&&(c=this.book.zip),this.currentChapter&&(this.currentChapter.unload(),this.trigger("renderer:chapterUnloaded"),this.book.trigger("renderer:chapterUnloaded")),this.currentChapter=a,this.chapterPos=1,this.pageIds={},this.leftPos=0,this.currentChapterCfi=this.epubcfi.generateChapter(this.book.spineNodeIndex,a.spinePos,a.id),this.visibileEl=!1,a.url(c).then(function(a){return b.setIframeSrc(a)})},EPUBJS.Renderer.prototype.addIframeListeners=function(){this.listenedEvents.forEach(function(a){this.doc.addEventListener(a,this.triggerEvent.bind(this),!1)},this)},EPUBJS.Renderer.prototype.removeIframeListeners=function(){this.listenedEvents.forEach(function(a){this.doc.removeEventListener(a,this.triggerEvent,!1)},this)},EPUBJS.Renderer.prototype.triggerEvent=function(a){this.book.trigger("renderer:"+a.type,a)},EPUBJS.Renderer.prototype.addSelectionListeners=function(){this.doc.addEventListener("selectionchange",this.onSelectionChange.bind(this),!1),this.contentWindow.addEventListener("mouseup",this.onMouseUp.bind(this),!1)},EPUBJS.Renderer.prototype.removeSelectionListeners=function(){this.doc.removeEventListener("selectionchange",this.onSelectionChange,!1),this.contentWindow.removeEventListener("mouseup",this.onMouseUp,!1)},EPUBJS.Renderer.prototype.onSelectionChange=function(){this.highlighted=!0},EPUBJS.Renderer.prototype.onMouseUp=function(){var a;this.highlighted&&(a=this.contentWindow.getSelection(),this.book.trigger("renderer:selected",a),this.highlighted=!1)},EPUBJS.Renderer.prototype.onResized=function(){var a={width:this.iframe.clientWidth,height:this.iframe.clientHeight};this.doc&&this.reformat(),this.trigger("renderer:resized",a),this.book.trigger("book:resized",a)},EPUBJS.Renderer.prototype.reformat=function(){var a=this;a.book.settings.fixedLayout?a.fixedLayout():a.formatSpread(),setTimeout(function(){a.calcPages(),a.currentLocationCfi&&a.gotoCfiFragment(a.currentLocationCfi)},10)},EPUBJS.Renderer.prototype.resizeIframe=function(a,b){this.iframe.height=b,isNaN(a)||0===a%2||(a+=1),this.iframe.width=a,this.onResized()},EPUBJS.Renderer.prototype.crossBrowserColumnCss=function(){EPUBJS.Renderer.columnAxis=EPUBJS.core.prefixed("columnAxis"),EPUBJS.Renderer.columnGap=EPUBJS.core.prefixed("columnGap"),EPUBJS.Renderer.columnWidth=EPUBJS.core.prefixed("columnWidth"),EPUBJS.Renderer.transform=EPUBJS.core.prefixed("transform")},EPUBJS.Renderer.prototype.setIframeSrc=function(a){var b=this,c=new RSVP.defer;return this.visible(!1),this.iframe.src=a,this.iframe.onload=function(){b.doc=b.iframe.contentDocument,b.docEl=b.doc.documentElement,b.bodyEl=b.doc.body,b.contentWindow=b.iframe.contentWindow,b.applyStyles(),b.book.settings.fixedLayout?b.fixedLayout():b.formatSpread(),b.beforeDisplay(function(){var a=b.currentChapter;b.calcPages(),c.resolve(b),a.cfi=b.currentLocationCfi=b.getPageCfi(),b.trigger("renderer:chapterDisplayed",a),b.book.trigger("renderer:chapterDisplayed",a),b.book.trigger("renderer:pageChanged",b.currentLocationCfi),b.visible(!0)}),b.contentWindow.addEventListener("resize",b.onResized.bind(b),!1),b.addIframeListeners(),b.addSelectionListeners()},c.promise},EPUBJS.Renderer.prototype.formatSpread=function(){var a=2,b=800;this.elWidth=this.iframe.clientWidth,0!==this.elWidth%2&&(this.elWidth-=1),this.gap=Math.ceil(this.elWidth/8),0!==this.gap%2&&(this.gap+=1),this.elWidth<b||!this.book.settings.spreads?(this.spread=!1,a=1,this.colWidth=Math.floor(this.elWidth/a)):(this.spread=!0,this.colWidth=Math.floor((this.elWidth-this.gap)/a)),this.spreadWidth=(this.colWidth+this.gap)*a,this.bodyEl&&(this.bodyEl.style.margin="0"),this.docEl.style.overflow="hidden",this.docEl.style.width=this.elWidth+"px",this.docEl.style.height=this.iframe.clientHeight+"px",this.docEl.style[EPUBJS.Renderer.columnAxis]="horizontal",this.docEl.style[EPUBJS.Renderer.columnGap]=this.gap+"px",this.docEl.style[EPUBJS.Renderer.columnWidth]=this.colWidth+"px"},EPUBJS.Renderer.prototype.fixedLayout=function(){this.paginated=!1,this.elWidth=this.iframe.width,this.docEl.style.width=this.elWidth,this.docEl.style.width=this.elWidth,this.docEl.style.height="auto",this.docEl.style.overflow="auto",this.iframe.scrolling="yes"},EPUBJS.Renderer.prototype.setStyle=function(a,b,c){c&&(a=EPUBJS.core.prefixed(a)),this.bodyEl&&(this.bodyEl.style[a]=b)},EPUBJS.Renderer.prototype.removeStyle=function(a){this.bodyEl&&(this.bodyEl.style[a]="")},EPUBJS.Renderer.prototype.applyStyles=function(){var a=this.book.settings.styles;for(var b in a)this.setStyle(b,a[b])},EPUBJS.Renderer.prototype.gotoChapterEnd=function(){this.chapterEnd()},EPUBJS.Renderer.prototype.visible=function(a){return"undefined"==typeof a?this.iframe.style.visibility:(a===!0?this.iframe.style.visibility="visible":a===!1&&(this.iframe.style.visibility="hidden"),void 0)},EPUBJS.Renderer.prototype.calcPages=function(){this.totalWidth=this.docEl.scrollWidth,this.displayedPages=Math.ceil(this.totalWidth/this.spreadWidth),this.currentChapter.pages=this.displayedPages},EPUBJS.Renderer.prototype.nextPage=function(){return this.chapterPos<this.displayedPages?(this.chapterPos++,this.leftPos+=this.spreadWidth,this.setLeft(this.leftPos),this.currentLocationCfi=this.getPageCfi(),this.book.trigger("renderer:pageChanged",this.currentLocationCfi),this.chapterPos):!1},EPUBJS.Renderer.prototype.prevPage=function(){return this.chapterPos>1?(this.chapterPos--,this.leftPos-=this.spreadWidth,this.setLeft(this.leftPos),this.currentLocationCfi=this.getPageCfi(),this.book.trigger("renderer:pageChanged",this.currentLocationCfi),this.chapterPos):!1},EPUBJS.Renderer.prototype.chapterEnd=function(){this.page(this.displayedPages)},EPUBJS.Renderer.prototype.setLeft=function(a){this.doc.defaultView.scrollTo(a,0)},EPUBJS.Renderer.prototype.determineStore=function(){return this.book.fromStorage?"filesystem"==this.book.storage.getStorageType()?!1:this.book.store:this.book.contained?this.book.zip:!1},EPUBJS.Renderer.prototype.replace=function(a,b,c,d){var e=this.doc.querySelectorAll(a),f=Array.prototype.slice.call(e),g=f.length,h=function(a,b){g--,d&&d(a,b,g),0>=g&&c&&c(!0)};return 0===g?(c(!1),void 0):(f.forEach(function(a){b(a,h)}.bind(this)),void 0)},EPUBJS.Renderer.prototype.replaceWithStored=function(a,b,c,d){var e,f={},g=this.determineStore(),h=this.caches[a],i=EPUBJS.core.uri(this.book.chapter.absolute),j=i.base,k=b,l=2e3,m=function(a,b){f[b]=a},n=function(){d&&d(),_.each(e,function(a){g.revokeUrl(a)}),h=f};g&&(h||(h={}),e=_.clone(h),this.replace(a,function(b,d){var h=b.getAttribute(k),i=EPUBJS.core.resolveUrl(j,h),m=function(c){var e;b.onload=function(){clearTimeout(e),d(c,i)},b.onerror=function(a){clearTimeout(e),d(c,i),console.error(a)},"image"==a&&b.setAttribute("externalResourcesRequired","true"),"link[href]"==a&&d(c,i),b.setAttribute(k,c),e=setTimeout(function(){d(c,i)},l)};i in e?(m(e[i]),f[i]=e[i],delete e[i]):c(g,i,m,b)},n,m))},EPUBJS.Renderer.prototype.replaceLinks=function(a){var b=this;this.replace("a[href]",function(a,c){var d=a.getAttribute("href"),e=d.search("://");"#"==d[0],-1!=e?a.setAttribute("target","_blank"):a.onclick=function(){return b.book.goto(d),!1},c()},a)},EPUBJS.Renderer.prototype.page=function(a){return a>=1&&a<=this.displayedPages?(this.chapterPos=a,this.leftPos=this.spreadWidth*(a-1),this.setLeft(this.leftPos),this.currentLocationCfi=this.getPageCfi(),this.book.trigger("renderer:pageChanged",this.currentLocationCfi),!0):!1},EPUBJS.Renderer.prototype.section=function(a){var b=this.doc.getElementById(a);b&&this.pageByElement(b)},EPUBJS.Renderer.prototype.pageByElement=function(a){var b,c;a&&(b=this.leftPos+a.getBoundingClientRect().left,c=Math.floor(b/this.spreadWidth)+1,this.page(c))},EPUBJS.Renderer.prototype.beforeDisplay=function(a){this.book.triggerHooks("beforeChapterDisplay",a.bind(this),this)},EPUBJS.Renderer.prototype.walk=function(a){for(var b,c,d,e,f=a,g=[f],h=1e4,i=0;!b&&g.length;){if(a=g.shift(),this.isElementVisible(a)&&(b=a),!b&&a&&a.childElementCount>0){if(c=a.children,!c||!c.length)return b;d=c.length?c.length:0;for(var j=0;d>j;j++)c[j]!=e&&g.push(c[j])}if(!b&&0===g.length&&f&&null!==f.parentNode&&(g.push(f.parentNode),e=f,f=f.parentNode),i++,i>h){console.error("ENDLESS LOOP");break}}return b},EPUBJS.Renderer.prototype.getPageCfi=function(){var a=this.visibileEl;return this.visibileEl=this.findFirstVisible(a),this.visibileEl.id||(this.visibileEl.id="EPUBJS-PAGE-"+this.chapterPos),this.pageIds[this.chapterPos]=this.visibileEl.id,this.epubcfi.generateFragment(this.visibileEl,this.currentChapterCfi)},EPUBJS.Renderer.prototype.gotoCfiFragment=function(a){var b;_.isString(a)&&(a=this.epubcfi.parse(a)),b=this.epubcfi.getElement(a,this.doc),this.pageByElement(b)},EPUBJS.Renderer.prototype.findFirstVisible=function(a){var b,c=a||this.bodyEl;return b=this.walk(c),b?b:a},EPUBJS.Renderer.prototype.isElementVisible=function(a){var b;return a&&"function"==typeof a.getBoundingClientRect&&(b=a.getBoundingClientRect(),0!=b.width&&0!=b.height&&b.left>=0&&b.left<this.spreadWidth)?!0:!1},EPUBJS.Renderer.prototype.height=function(){return this.docEl.offsetHeight},EPUBJS.Renderer.prototype.remove=function(){this.contentWindow.removeEventListener("resize",this.resize),this.removeIframeListeners(),this.removeSelectionListeners(),this.el.removeChild(this.iframe)},RSVP.EventTarget.mixin(EPUBJS.Renderer.prototype);var EPUBJS=EPUBJS||{};EPUBJS.replace={},EPUBJS.replace.head=function(a,b){b.replaceWithStored("link[href]","href",EPUBJS.replace.links,a)},EPUBJS.replace.resources=function(a,b){b.replaceWithStored("[src]","src",EPUBJS.replace.srcs,a)},EPUBJS.replace.svg=function(a,b){b.replaceWithStored("image","xlink:href",function(a,b,c){a.getUrl(b).then(c)},a)},EPUBJS.replace.srcs=function(a,b,c){a.getUrl(b).then(c)},EPUBJS.replace.links=function(a,b,c,d){"stylesheet"===d.getAttribute("rel")?EPUBJS.replace.stylesheets(a,b).then(function(a,b){setTimeout(function(){c(a,b)},5)}):a.getUrl(b).then(c)},EPUBJS.replace.stylesheets=function(a,b){var c=new RSVP.defer;if(a)return a.getText(b).then(function(d){EPUBJS.replace.cssUrls(a,b,d).then(function(a){var b=window.URL||window.webkitURL||window.mozURL,d=new Blob([a],{type:"text/css"}),e=b.createObjectURL(d);c.resolve(e)},function(a){console.error(a)})}),c.promise},EPUBJS.replace.cssUrls=function(a,b,c){var d=new RSVP.defer,e=[],f=c.match(/url\(\'?\"?([^\'|^\"]*)\'?\"?\)/g);if(a)return f?(f.forEach(function(d){var f=EPUBJS.core.resolveUrl(b,d.replace(/url\(|[|\)|\'|\"]/g,"")),g=a.getUrl(f).then(function(a){c=c.replace(d,'url("'+a+'")')},function(a){console.error(a)});e.push(g)}),RSVP.all(e).then(function(){d.resolve(c)}),d.promise):(d.resolve(c),d.promise)},EPUBJS.Unarchiver=function(a){return this.libPath=EPUBJS.filePath,this.zipUrl=a,this.loadLib(),this.urlCache={},this.zipFs=new zip.fs.FS,this.promise},EPUBJS.Unarchiver.prototype.loadLib=function(){"undefined"==typeof zip&&console.error("Zip lib not loaded"),zip.workerScriptsPath=this.libPath},EPUBJS.Unarchiver.prototype.openZip=function(a){var b=new RSVP.defer,c=this.zipFs;return c.importHttpContent(a,!1,function(){b.resolve(c)},this.failed),b.promise},EPUBJS.Unarchiver.prototype.getXml=function(a,b){return this.getText(a,b).then(function(a){var b=new DOMParser;return b.parseFromString(a,"application/xml")})},EPUBJS.Unarchiver.prototype.getUrl=function(a,b){var c=this,d=new RSVP.defer,e=window.decodeURIComponent(a),f=this.zipFs.find(e),g=window.URL||window.webkitURL||window.mozURL;return f?a in this.urlCache?(d.resolve(this.urlCache[a]),d.promise):(f.getBlob(b||zip.getMimeType(f.name),function(b){var e=g.createObjectURL(b);d.resolve(e),c.urlCache[a]=e}),d.promise):(console.error("File not found in the epub:",a),void 0)},EPUBJS.Unarchiver.prototype.getText=function(a,b){var c=new RSVP.defer,d=window.decodeURIComponent(a),e=this.zipFs.find(d);return window.URL||window.webkitURL||window.mozURL,e||console.error(a),e.getText(function(a){c.resolve(a)},null,null,b||"UTF-8"),c.promise},EPUBJS.Unarchiver.prototype.revokeUrl=function(a){var b=window.URL||window.webkitURL||window.mozURL,c=unarchiver.urlCache[a];c&&b.revokeObjectURL(c)},EPUBJS.Unarchiver.prototype.failed=function(a){console.error(a)},EPUBJS.Unarchiver.prototype.afterSaved=function(){this.callback()},EPUBJS.Unarchiver.prototype.toStorage=function(a){function b(){f--,0===f&&e.afterSaved()}var c=0,d=20,e=this,f=a.length;a.forEach(function(a){setTimeout(function(a){e.saveEntryFileToStorage(a,b)},c,a),c+=d}),console.log("time",c)},EPUBJS.Unarchiver.prototype.saveEntryFileToStorage=function(a,b){a.getData(new zip.BlobWriter,function(c){EPUBJS.storage.save(a.filename,c,b)})}; |