>>=1)if(X&1&&A.dyn_ltree[Q*2]!==0)return u;if(A.dyn_ltree[18]!==0||A.dyn_ltree[20]!==0||A.dyn_ltree[26]!==0)return l;for(Q=32;Q0?(A.strm.data_type===f&&(A.strm.data_type=ht(A)),et(A,A.l_desc),et(A,A.d_desc),o=Qe(A),z=A.opt_len+3+7>>>3,Z=A.static_len+3+7>>>3,Z<=z&&(z=Z)):z=Z=Q+5,Q+4<=z&&X!==-1?lt(A,X,Q,fe):A.strategy===s||Z===z?(Ee(A,(_<<1)+(fe?1:0),3),me(A,$,oe)):(Ee(A,(m<<1)+(fe?1:0),3),vt(A,A.l_desc.max_code+1,A.d_desc.max_code+1,o+1),me(A,A.dyn_ltree,A.dyn_dtree)),Ve(A),fe&&Ke(A)}function wt(A,X,Q){return A.pending_buf[A.d_buf+A.last_lit*2]=X>>>8&255,A.pending_buf[A.d_buf+A.last_lit*2+1]=X&255,A.pending_buf[A.l_buf+A.last_lit]=Q&255,A.last_lit++,X===0?A.dyn_ltree[Q*2]++:(A.matches++,X--,A.dyn_ltree[(ne[Q]+p+1)*2]++,A.dyn_dtree[Fe(X)*2]++),A.last_lit===A.lit_bufsize-1}r._tr_init=ft,r._tr_stored_block=lt,r._tr_flush_block=st,r._tr_tally=wt,r._tr_align=Ge},{"../utils/common":41}],53:[function(t,i,r){function n(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}i.exports=n},{}],54:[function(t,i,r){(function(n){(function(s,u){if(s.setImmediate)return;var l=1,f={},d=!1,c=s.document,_;function m(R){typeof R!="function"&&(R=new Function(""+R));for(var k=new Array(arguments.length-1),I=0;I"u"?typeof n>"u"?this:n:self)}).call(this,typeof bt<"u"?bt:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(hr)),hr.exports}var Ka=$a();const Qa=Zt(Ka);class Ja{constructor(){this.zip=void 0,this.urlCache={},this.checkRequirements()}checkRequirements(){try{this.zip=new Qa}catch{throw new Error("JSZip lib not loaded")}}open(e,t){return this.zip.loadAsync(e,{base64:t})}openUrl(e,t){return ti(e,"binary").then((function(i){return this.zip.loadAsync(i,{base64:t})}).bind(this))}request(e,t){var i=new Oe,r,n=new It(e);return t||(t=n.extension),t=="blob"?r=this.getBlob(e):r=this.getText(e),r?r.then((function(s){let u=this.handleResponse(s,t);i.resolve(u)}).bind(this)):i.reject({message:"File not found in the epub: "+e,stack:new Error().stack}),i.promise}handleResponse(e,t){var i;return t=="json"?i=JSON.parse(e):ei(t)?i=St(e,"text/xml"):t=="xhtml"?i=St(e,"application/xhtml+xml"):t=="html"||t=="htm"?i=St(e,"text/html"):i=e,i}getBlob(e,t){var i=window.decodeURIComponent(e.substr(1)),r=this.zip.file(i);if(r)return t=t||Ht.lookup(r.name),r.async("uint8array").then(function(n){return new Blob([n],{type:t})})}getText(e,t){var i=window.decodeURIComponent(e.substr(1)),r=this.zip.file(i);if(r)return r.async("string").then(function(n){return n})}getBase64(e,t){var i=window.decodeURIComponent(e.substr(1)),r=this.zip.file(i);if(r)return t=t||Ht.lookup(r.name),r.async("base64").then(function(n){return"data:"+t+";base64,"+n})}createUrl(e,t){var i=new Oe,r=window.URL||window.webkitURL||window.mozURL,n,s,u=t&&t.base64;return e in this.urlCache?(i.resolve(this.urlCache[e]),i.promise):(u?(s=this.getBase64(e),s&&s.then((function(l){this.urlCache[e]=l,i.resolve(l)}).bind(this))):(s=this.getBlob(e),s&&s.then((function(l){n=r.createObjectURL(l),this.urlCache[e]=n,i.resolve(n)}).bind(this))),s||i.reject({message:"File not found in the epub: "+e,stack:new Error().stack}),i.promise)}revokeUrl(e){var t=window.URL||window.webkitURL||window.mozURL,i=this.urlCache[e];i&&t.revokeObjectURL(i)}destroy(){var e=window.URL||window.webkitURL||window.mozURL;for(let t in this.urlCache)e.revokeObjectURL(t);this.zip=void 0,this.urlCache={}}}var fr={exports:{}};/*!
+ localForage -- Offline Storage, Improved
+ Version 1.10.0
+ https://localforage.github.io/localForage
+ (c) 2013-2017 Mozilla, Apache License 2.0
+*/var On;function eo(){return On||(On=1,(function(y,e){(function(t){y.exports=t()})(function(){return(function t(i,r,n){function s(f,d){if(!r[f]){if(!i[f]){var c=typeof Bt=="function"&&Bt;if(!d&&c)return c(f,!0);if(u)return u(f,!0);var _=new Error("Cannot find module '"+f+"'");throw _.code="MODULE_NOT_FOUND",_}var m=r[f]={exports:{}};i[f][0].call(m.exports,function(O){var E=i[f][1][O];return s(E||O)},m,m.exports,t,i,r,n)}return r[f].exports}for(var u=typeof Bt=="function"&&Bt,l=0;l"u"&&t(3);var c=Promise;function _(x,P){P&&x.then(function(C){P(null,C)},function(C){P(C)})}function m(x,P,C){typeof P=="function"&&x.then(P),typeof C=="function"&&x.catch(C)}function O(x){return typeof x!="string"&&(console.warn(x+" used as a key, but it is not a string."),x=String(x)),x}function E(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var h="local-forage-detect-blob-support",p=void 0,g={},D=Object.prototype.toString,B="readonly",w="readwrite";function T(x){for(var P=x.length,C=new ArrayBuffer(P),q=new Uint8Array(C),j=0;j=43)}}).catch(function(){return!1})}function R(x){return typeof p=="boolean"?c.resolve(p):N(x).then(function(P){return p=P,p})}function k(x){var P=g[x.name],C={};C.promise=new c(function(q,j){C.resolve=q,C.reject=j}),P.deferredOperations.push(C),P.dbReady?P.dbReady=P.dbReady.then(function(){return C.promise}):P.dbReady=C.promise}function I(x){var P=g[x.name],C=P.deferredOperations.pop();if(C)return C.resolve(),C.promise}function V(x,P){var C=g[x.name],q=C.deferredOperations.pop();if(q)return q.reject(P),q.promise}function W(x,P){return new c(function(C,q){if(g[x.name]=g[x.name]||de(),x.db)if(P)k(x),x.db.close();else return C(x.db);var j=[x.name];P&&j.push(x.version);var M=l.open.apply(l,j);P&&(M.onupgradeneeded=function(Y){var K=M.result;try{K.createObjectStore(x.storeName),Y.oldVersion<=1&&K.createObjectStore(h)}catch(ie){if(ie.name==="ConstraintError")console.warn('The database "'+x.name+'" has been upgraded from version '+Y.oldVersion+" to version "+Y.newVersion+', but the storage "'+x.storeName+'" already exists.');else throw ie}}),M.onerror=function(Y){Y.preventDefault(),q(M.error)},M.onsuccess=function(){var Y=M.result;Y.onversionchange=function(K){K.target.close()},C(Y),I(x)}})}function G(x){return W(x,!1)}function te(x){return W(x,!0)}function J(x,P){if(!x.db)return!0;var C=!x.db.objectStoreNames.contains(x.storeName),q=x.versionx.db.version;if(q&&(x.version!==P&&console.warn('The database "'+x.name+`" can't be downgraded from version `+x.db.version+" to version "+x.version+"."),x.version=x.db.version),j||C){if(C){var M=x.db.version+1;M>x.version&&(x.version=M)}return!0}return!1}function he(x){return new c(function(P,C){var q=new FileReader;q.onerror=C,q.onloadend=function(j){var M=btoa(j.target.result||"");P({__local_forage_encoded_blob:!0,data:M,type:x.type})},q.readAsBinaryString(x)})}function ee(x){var P=T(atob(x.data));return d([P],{type:x.type})}function $(x){return x&&x.__local_forage_encoded_blob}function oe(x){var P=this,C=P._initReady().then(function(){var q=g[P._dbInfo.name];if(q&&q.dbReady)return q.dbReady});return m(C,x,x),C}function ye(x){k(x);for(var P=g[x.name],C=P.forages,q=0;q0&&(!x.db||M.name==="InvalidStateError"||M.name==="NotFoundError"))return c.resolve().then(function(){if(!x.db||M.name==="NotFoundError"&&!x.db.objectStoreNames.contains(x.storeName)&&x.version<=x.db.version)return x.db&&(x.version=x.db.version+1),te(x)}).then(function(){return ye(x).then(function(){ne(x,P,C,q-1)})}).catch(C);C(M)}}function de(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function Ae(x){var P=this,C={db:null};if(x)for(var q in x)C[q]=x[q];var j=g[C.name];j||(j=de(),g[C.name]=j),j.forages.push(P),P._initReady||(P._initReady=P.ready,P.ready=oe);var M=[];function Y(){return c.resolve()}for(var K=0;K>4,ae[j++]=(Y&15)<<4|K>>2,ae[j++]=(K&3)<<6|ie&63;return re}function st(x){var P=new Uint8Array(x),C="",q;for(q=0;q>2],C+=qe[(P[q]&3)<<4|P[q+1]>>4],C+=qe[(P[q+1]&15)<<2|P[q+2]>>6],C+=qe[P[q+2]&63];return P.length%3===2?C=C.substring(0,C.length-1)+"=":P.length%3===1&&(C=C.substring(0,C.length-2)+"=="),C}function wt(x,P){var C="";if(x&&(C=lt.call(x)),x&&(C==="[object ArrayBuffer]"||x.buffer&<.call(x.buffer)==="[object ArrayBuffer]")){var q,j=Ve;x instanceof ArrayBuffer?(q=x,j+=Xe):(q=x.buffer,C==="[object Int8Array]"?j+=_e:C==="[object Uint8Array]"?j+=me:C==="[object Uint8ClampedArray]"?j+=et:C==="[object Int16Array]"?j+=dt:C==="[object Uint16Array]"?j+=Qe:C==="[object Int32Array]"?j+=ut:C==="[object Uint32Array]"?j+=vt:C==="[object Float32Array]"?j+=ht:C==="[object Float64Array]"?j+=nt:P(new Error("Failed to get type for BinaryArray"))),P(j+st(q))}else if(C==="[object Blob]"){var M=new FileReader;M.onload=function(){var Y=Le+x.type+"~"+st(this.result);P(Ve+be+Y)},M.readAsArrayBuffer(x)}else try{P(JSON.stringify(x))}catch(Y){console.error("Couldn't convert value into a JSON string: ",x),P(null,Y)}}function A(x){if(x.substring(0,Ke)!==Ve)return JSON.parse(x);var P=x.substring(ft),C=x.substring(Ke,ft),q;if(C===be&&ke.test(P)){var j=P.match(ke);q=j[1],P=P.substring(j[0].length)}var M=Ge(P);switch(C){case Xe:return M;case be:return d([M],{type:q});case _e:return new Int8Array(M);case me:return new Uint8Array(M);case et:return new Uint8ClampedArray(M);case dt:return new Int16Array(M);case Qe:return new Uint16Array(M);case ut:return new Int32Array(M);case vt:return new Uint32Array(M);case ht:return new Float32Array(M);case nt:return new Float64Array(M);default:throw new Error("Unkown type: "+C)}}var X={serialize:wt,deserialize:A,stringToBuffer:Ge,bufferToString:st};function Q(x,P,C,q){x.executeSql("CREATE TABLE IF NOT EXISTS "+P.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],C,q)}function fe(x){var P=this,C={db:null};if(x)for(var q in x)C[q]=typeof x[q]!="string"?x[q].toString():x[q];var j=new c(function(M,Y){try{C.db=openDatabase(C.name,String(C.version),C.description,C.size)}catch(K){return Y(K)}C.db.transaction(function(K){Q(K,C,function(){P._dbInfo=C,M()},function(ie,re){Y(re)})},Y)});return C.serializer=X,j}function z(x,P,C,q,j,M){x.executeSql(C,q,j,function(Y,K){K.code===K.SYNTAX_ERR?Y.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[P.storeName],function(ie,re){re.rows.length?M(ie,K):Q(ie,P,function(){ie.executeSql(C,q,j,M)},M)},M):M(Y,K)},M)}function Z(x,P){var C=this;x=O(x);var q=new c(function(j,M){C.ready().then(function(){var Y=C._dbInfo;Y.db.transaction(function(K){z(K,Y,"SELECT * FROM "+Y.storeName+" WHERE key = ? LIMIT 1",[x],function(ie,re){var ae=re.rows.length?re.rows.item(0).value:null;ae&&(ae=Y.serializer.deserialize(ae)),j(ae)},function(ie,re){M(re)})})}).catch(M)});return _(q,P),q}function o(x,P){var C=this,q=new c(function(j,M){C.ready().then(function(){var Y=C._dbInfo;Y.db.transaction(function(K){z(K,Y,"SELECT * FROM "+Y.storeName,[],function(ie,re){for(var ae=re.rows,pe=ae.length,Ce=0;Ce0){Y(v.apply(j,[x,ie,C,q-1]));return}K(Ce)}})})}).catch(K)});return _(M,C),M}function S(x,P,C){return v.apply(this,[x,P,C,1])}function a(x,P){var C=this;x=O(x);var q=new c(function(j,M){C.ready().then(function(){var Y=C._dbInfo;Y.db.transaction(function(K){z(K,Y,"DELETE FROM "+Y.storeName+" WHERE key = ?",[x],function(){j()},function(ie,re){M(re)})})}).catch(M)});return _(q,P),q}function L(x){var P=this,C=new c(function(q,j){P.ready().then(function(){var M=P._dbInfo;M.db.transaction(function(Y){z(Y,M,"DELETE FROM "+M.storeName,[],function(){q()},function(K,ie){j(ie)})})}).catch(j)});return _(C,x),C}function U(x){var P=this,C=new c(function(q,j){P.ready().then(function(){var M=P._dbInfo;M.db.transaction(function(Y){z(Y,M,"SELECT COUNT(key) as c FROM "+M.storeName,[],function(K,ie){var re=ie.rows.item(0).c;q(re)},function(K,ie){j(ie)})})}).catch(j)});return _(C,x),C}function b(x,P){var C=this,q=new c(function(j,M){C.ready().then(function(){var Y=C._dbInfo;Y.db.transaction(function(K){z(K,Y,"SELECT key FROM "+Y.storeName+" WHERE id = ? LIMIT 1",[x+1],function(ie,re){var ae=re.rows.length?re.rows.item(0).key:null;j(ae)},function(ie,re){M(re)})})}).catch(M)});return _(q,P),q}function F(x){var P=this,C=new c(function(q,j){P.ready().then(function(){var M=P._dbInfo;M.db.transaction(function(Y){z(Y,M,"SELECT key FROM "+M.storeName,[],function(K,ie){for(var re=[],ae=0;ae '__WebKitDatabaseInfoTable__'",[],function(j,M){for(var Y=[],K=0;K0}function xe(x){var P=this,C={};if(x)for(var q in x)C[q]=x[q];return C.keyPrefix=we(x,P._defaultConfig),Re()?(P._dbInfo=C,C.serializer=X,c.resolve()):c.reject()}function We(x){var P=this,C=P.ready().then(function(){for(var q=P._dbInfo.keyPrefix,j=localStorage.length-1;j>=0;j--){var M=localStorage.key(j);M.indexOf(q)===0&&localStorage.removeItem(M)}});return _(C,x),C}function Ie(x,P){var C=this;x=O(x);var q=C.ready().then(function(){var j=C._dbInfo,M=localStorage.getItem(j.keyPrefix+x);return M&&(M=j.serializer.deserialize(M)),M});return _(q,P),q}function it(x,P){var C=this,q=C.ready().then(function(){for(var j=C._dbInfo,M=j.keyPrefix,Y=M.length,K=localStorage.length,ie=1,re=0;re=0;Y--){var K=localStorage.key(Y);K.indexOf(M)===0&&localStorage.removeItem(K)}}):j=c.reject("Invalid arguments"),_(j,P),j}var gt={_driver:"localStorageWrapper",_initStorage:xe,_support:ue(),iterate:it,getItem:Ie,setItem:rt,removeItem:ct,clear:We,length:Ze,key:pt,keys:kt,dropInstance:_t},ii=function(P,C){return P===C||typeof P=="number"&&typeof C=="number"&&isNaN(P)&&isNaN(C)},xs=function(P,C){for(var q=P.length,j=0;j"u"?"undefined":n(C))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var q in C){if(q==="storeName"&&(C[q]=C[q].replace(/\W/g,"_")),q==="version"&&typeof C[q]!="number")return new Error("Database version must be a number.");this._config[q]=C[q]}return"driver"in C&&C.driver?this.setDriver(this._config.driver):!0}else return typeof C=="string"?this._config[C]:this._config},x.prototype.defineDriver=function(C,q,j){var M=new c(function(Y,K){try{var ie=C._driver,re=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!C._driver){K(re);return}for(var ae=_i.concat("_initStorage"),pe=0,Ce=ae.length;pe"u"&&(e=Bn),this.storage=e.createInstance({name:this.name})}catch{throw new Error("localForage lib not loaded")}}addListeners(){this._status=this.status.bind(this),window.addEventListener("online",this._status),window.addEventListener("offline",this._status)}removeListeners(){window.removeEventListener("online",this._status),window.removeEventListener("offline",this._status),this._status=void 0}status(e){let t=navigator.onLine;this.online=t,t?this.emit("online",this):this.emit("offline",this)}add(e,t){let i=e.resources.map(r=>{let{href:n}=r,s=this.resolver(n),u=window.encodeURIComponent(s);return this.storage.getItem(u).then(l=>!l||t?this.requester(s,"binary").then(f=>this.storage.setItem(u,f)):l)});return Promise.all(i)}put(e,t,i){let r=window.encodeURIComponent(e);return this.storage.getItem(r).then(n=>n||this.requester(e,"binary",t,i).then(s=>this.storage.setItem(r,s)))}request(e,t,i,r){return this.online?this.requester(e,t,i,r).then(n=>(this.put(e),n)):this.retrieve(e,t)}retrieve(e,t){new Oe;var i,r=new It(e);return t||(t=r.extension),t=="blob"?i=this.getBlob(e):i=this.getText(e),i.then(n=>{var s=new Oe,u;return n?(u=this.handleResponse(n,t),s.resolve(u)):s.reject({message:"File not found in storage: "+e,stack:new Error().stack}),s.promise})}handleResponse(e,t){var i;return t=="json"?i=JSON.parse(e):ei(t)?i=St(e,"text/xml"):t=="xhtml"?i=St(e,"application/xhtml+xml"):t=="html"||t=="htm"?i=St(e,"text/html"):i=e,i}getBlob(e,t){let i=window.encodeURIComponent(e);return this.storage.getItem(i).then(function(r){if(r)return t=t||Ht.lookup(e),new Blob([r],{type:t})})}getText(e,t){let i=window.encodeURIComponent(e);return t=t||Ht.lookup(e),this.storage.getItem(i).then(function(r){var n=new Oe,s=new FileReader,u;if(r)return u=new Blob([r],{type:t}),s.addEventListener("loadend",()=>{n.resolve(s.result)}),s.readAsText(u,t),n.promise})}getBase64(e,t){let i=window.encodeURIComponent(e);return t=t||Ht.lookup(e),this.storage.getItem(i).then(r=>{var n=new Oe,s=new FileReader,u;if(r)return u=new Blob([r],{type:t}),s.addEventListener("loadend",()=>{n.resolve(s.result)}),s.readAsDataURL(u,t),n.promise})}createUrl(e,t){var i=new Oe,r=window.URL||window.webkitURL||window.mozURL,n,s,u=t&&t.base64;return e in this.urlCache?(i.resolve(this.urlCache[e]),i.promise):(u?(s=this.getBase64(e),s&&s.then((function(l){this.urlCache[e]=l,i.resolve(l)}).bind(this))):(s=this.getBlob(e),s&&s.then((function(l){n=r.createObjectURL(l),this.urlCache[e]=n,i.resolve(n)}).bind(this))),s||i.reject({message:"File not found in storage: "+e,stack:new Error().stack}),i.promise)}revokeUrl(e){var t=window.URL||window.webkitURL||window.mozURL,i=this.urlCache[e];i&&t.revokeObjectURL(i)}destroy(){var e=window.URL||window.webkitURL||window.mozURL;for(let t in this.urlCache)e.revokeObjectURL(t);this.urlCache={},this.removeListeners()}}Tt(os.prototype);class cr{constructor(e){this.interactive="",this.fixedLayout="",this.openToSpread="",this.orientationLock="",e&&this.parse(e)}parse(e){if(!e)return this;const t=je(e,"display_options");return t?(Rt(t,"option").forEach(r=>{let n="";switch(r.childNodes.length&&(n=r.childNodes[0].nodeValue),r.attributes.name.value){case"interactive":this.interactive=n;break;case"fixed-layout":this.fixedLayout=n;break;case"open-to-spread":this.openToSpread=n;break;case"orientation-lock":this.orientationLock=n;break}}),this):this}destroy(){this.interactive=void 0,this.fixedLayout=void 0,this.openToSpread=void 0,this.orientationLock=void 0}}const Ln="META-INF/container.xml",io="META-INF/com.apple.ibooks.display-options.xml",xt={BINARY:"binary",BASE64:"base64",EPUB:"epub",OPF:"opf",MANIFEST:"json",DIRECTORY:"directory"};class Rr{constructor(e,t){typeof t>"u"&&typeof e!="string"&&!(e instanceof Blob)&&!(e instanceof ArrayBuffer)&&(t=e,e=void 0),this.settings=ot(this.settings||{},{requestMethod:void 0,requestCredentials:void 0,requestHeaders:void 0,encoding:void 0,replacements:void 0,canonical:void 0,openAs:void 0,store:void 0}),ot(this.settings,t),this.opening=new Oe,this.opened=this.opening.promise,this.isOpen=!1,this.loading={manifest:new Oe,spine:new Oe,metadata:new Oe,cover:new Oe,navigation:new Oe,pageList:new Oe,resources:new Oe,displayOptions:new Oe},this.loaded={manifest:this.loading.manifest.promise,spine:this.loading.spine.promise,metadata:this.loading.metadata.promise,cover:this.loading.cover.promise,navigation:this.loading.navigation.promise,pageList:this.loading.pageList.promise,resources:this.loading.resources.promise,displayOptions:this.loading.displayOptions.promise},this.ready=Promise.all([this.loaded.manifest,this.loaded.spine,this.loaded.metadata,this.loaded.cover,this.loaded.navigation,this.loaded.resources,this.loaded.displayOptions]),this.isRendered=!1,this.request=this.settings.requestMethod||ti,this.spine=new ga,this.locations=new Jn(this.spine,this.load.bind(this)),this.navigation=void 0,this.pageList=void 0,this.url=void 0,this.path=void 0,this.archived=!1,this.archive=void 0,this.storage=void 0,this.resources=void 0,this.rendition=void 0,this.container=void 0,this.packaging=void 0,this.displayOptions=void 0,this.settings.store&&this.store(this.settings.store),e&&this.open(e,this.settings.openAs).catch(i=>{var r=new Error("Cannot load book at "+e);this.emit(le.BOOK.OPEN_FAILED,r)})}open(e,t){var i,r=t||this.determineType(e);return r===xt.BINARY?(this.archived=!0,this.url=new At("/",""),i=this.openEpub(e)):r===xt.BASE64?(this.archived=!0,this.url=new At("/",""),i=this.openEpub(e,r)):r===xt.EPUB?(this.archived=!0,this.url=new At("/",""),i=this.request(e,"binary",this.settings.requestCredentials,this.settings.requestHeaders).then(this.openEpub.bind(this))):r==xt.OPF?(this.url=new At(e),i=this.openPackaging(this.url.Path.toString())):r==xt.MANIFEST?(this.url=new At(e),i=this.openManifest(this.url.Path.toString())):(this.url=new At(e),i=this.openContainer(Ln).then(this.openPackaging.bind(this))),i}openEpub(e,t){return this.unarchive(e,t||this.settings.encoding).then(()=>this.openContainer(Ln)).then(i=>this.openPackaging(i))}openContainer(e){return this.load(e).then(t=>(this.container=new ma(t),this.resolve(this.container.packagePath)))}openPackaging(e){return this.path=new It(e),this.load(e).then(t=>(this.packaging=new cn(t),this.unpack(this.packaging)))}openManifest(e){return this.path=new It(e),this.load(e).then(t=>(this.packaging=new cn,this.packaging.load(t),this.unpack(this.packaging)))}load(e){var t=this.resolve(e);return this.archived?this.archive.request(t):this.request(t,null,this.settings.requestCredentials,this.settings.requestHeaders)}resolve(e,t){if(e){var i=e,r=e.indexOf("://")>-1;return r?e:(this.path&&(i=this.path.resolve(e)),t!=!1&&this.url&&(i=this.url.resolve(i)),i)}}canonical(e){var t=e;return e?(this.settings.canonical?t=this.settings.canonical(e):t=this.resolve(e,!0),t):""}determineType(e){var t,i,r;if(this.settings.encoding==="base64")return xt.BASE64;if(typeof e!="string")return xt.BINARY;if(t=new At(e),i=t.path(),r=i.extension,r&&(r=r.replace(/\?.*$/,"")),!r)return xt.DIRECTORY;if(r==="epub")return xt.EPUB;if(r==="opf")return xt.OPF;if(r==="json")return xt.MANIFEST}unpack(e){this.package=e,this.packaging.metadata.layout===""?this.load(this.url.resolve(io)).then(t=>{this.displayOptions=new cr(t),this.loading.displayOptions.resolve(this.displayOptions)}).catch(t=>{this.displayOptions=new cr,this.loading.displayOptions.resolve(this.displayOptions)}):(this.displayOptions=new cr,this.loading.displayOptions.resolve(this.displayOptions)),this.spine.unpack(this.packaging,this.resolve.bind(this),this.canonical.bind(this)),this.resources=new _a(this.packaging.manifest,{archive:this.archive,resolver:this.resolve.bind(this),request:this.request.bind(this),replacements:this.settings.replacements||(this.archived?"blobUrl":"base64")}),this.loadNavigation(this.packaging).then(()=>{this.loading.navigation.resolve(this.navigation)}),this.packaging.coverPath&&(this.cover=this.resolve(this.packaging.coverPath)),this.loading.manifest.resolve(this.packaging.manifest),this.loading.metadata.resolve(this.packaging.metadata),this.loading.spine.resolve(this.spine),this.loading.cover.resolve(this.cover),this.loading.resources.resolve(this.resources),this.loading.pageList.resolve(this.pageList),this.isOpen=!0,this.archived||this.settings.replacements&&this.settings.replacements!="none"?this.replacements().then(()=>{this.loaded.displayOptions.then(()=>{this.opening.resolve(this)})}).catch(t=>{console.error(t)}):this.loaded.displayOptions.then(()=>{this.opening.resolve(this)})}loadNavigation(e){let t=e.navPath||e.ncxPath,i=e.toc;return i?new Promise((r,n)=>{this.navigation=new Zi(i),e.pageList&&(this.pageList=new Yi(e.pageList)),r(this.navigation)}):t?this.load(t,"xml").then(r=>(this.navigation=new Zi(r),this.pageList=new Yi(r),this.navigation)):new Promise((r,n)=>{this.navigation=new Zi,this.pageList=new Yi,r(this.navigation)})}section(e){return this.spine.get(e)}renderTo(e,t){return this.rendition=new Nr(this,t),this.rendition.attachTo(e),this.rendition}setRequestCredentials(e){this.settings.requestCredentials=e}setRequestHeaders(e){this.settings.requestHeaders=e}unarchive(e,t){return this.archive=new Ja,this.archive.open(e,t)}store(e){let t=this.settings.replacements&&this.settings.replacements!=="none",i=this.url,r=this.settings.requestMethod||ti.bind(this);return this.storage=new os(e,r,this.resolve.bind(this)),this.request=this.storage.request.bind(this.storage),this.opened.then(()=>{this.archived&&(this.storage.requester=this.archive.request.bind(this.archive));let n=(s,u)=>{u.output=this.resources.substitute(s,u.url)};this.resources.settings.replacements=t||"blobUrl",this.resources.replacements().then(()=>this.resources.replaceCss()),this.storage.on("offline",()=>{this.url=new At("/",""),this.spine.hooks.serialize.register(n)}),this.storage.on("online",()=>{this.url=i,this.spine.hooks.serialize.deregister(n)})}),this.storage}coverUrl(){return this.loaded.cover.then(()=>this.cover?this.archived?this.archive.createUrl(this.cover):this.cover:null)}replacements(){return this.spine.hooks.serialize.register((e,t)=>{t.output=this.resources.substitute(e,t.url)}),this.resources.replacements().then(()=>this.resources.replaceCss())}getRange(e){var t=new Be(e),i=this.spine.get(t.spinePos),r=this.load.bind(this);return i?i.load(r).then(function(n){var s=t.toRange(i.document);return s}):new Promise((n,s)=>{s("CFI could not be found")})}key(e){var t=e||this.packaging.metadata.identifier||this.url.filename;return`epubjs:${wi}:${t}`}destroy(){this.opened=void 0,this.loading=void 0,this.loaded=void 0,this.ready=void 0,this.isOpen=!1,this.isRendered=!1,this.spine&&this.spine.destroy(),this.locations&&this.locations.destroy(),this.pageList&&this.pageList.destroy(),this.archive&&this.archive.destroy(),this.resources&&this.resources.destroy(),this.container&&this.container.destroy(),this.packaging&&this.packaging.destroy(),this.rendition&&this.rendition.destroy(),this.displayOptions&&this.displayOptions.destroy(),this.spine=void 0,this.locations=void 0,this.pageList=void 0,this.archive=void 0,this.resources=void 0,this.container=void 0,this.packaging=void 0,this.rendition=void 0,this.navigation=void 0,this.url=void 0,this.path=void 0,this.archived=!1}}Tt(Rr.prototype);function Lt(y,e){return new Rr(y,e)}Lt.VERSION=wi;typeof global<"u"&&(global.EPUBJS_VERSION=wi);Lt.Book=Rr;Lt.Rendition=Nr;Lt.Contents=Tr;Lt.CFI=Be;Lt.utils=ua;function us(){return new Promise((y,e)=>{const t=indexedDB.open("htmlreader-db",1);t.onupgradeneeded=i=>{i.target.result.createObjectStore("handles",{keyPath:"name"})},t.onsuccess=i=>y(i.target.result),t.onerror=i=>e(i.target.error)})}async function ro(y){const e=await us();return new Promise((t,i)=>{const r=e.transaction("handles","readwrite");r.objectStore("handles").put({name:"library",handle:y}),r.oncomplete=()=>t(),r.onabort=r.onerror=s=>i(r.error||s&&s.target&&s.target.error)})}async function no(){const y=await us();return new Promise((e,t)=>{const n=y.transaction("handles","readonly").objectStore("handles").get("library");n.onsuccess=()=>e(n.result?n.result.handle:null),n.onerror=s=>t(s.target.error)})}const dr=document.getElementById("library-container"),pr=document.getElementById("library-content"),vr=document.getElementById("overlay");async function so(){try{let y=await no();if(!y){if(!("showDirectoryPicker"in window)){document.getElementById("library-input")?.click();return}y=await window.showDirectoryPicker(),await ro(y)}if(y.queryPermission&&y.requestPermission&&await y.queryPermission({mode:"read"})!=="granted"&&await y.requestPermission({mode:"read"})!=="granted")throw new Error("Read permission was denied for the library directory.");const e=[];for await(const t of y.values())t.kind==="file"&&t.name.endsWith(".epub")&&e.push(t);ls(e),Gt(!0)}catch(y){Jt("Failed to open library: "+y.message)}}function ao(y){const e=Array.from(y.target.files);ls(e),Gt(!0)}async function ls(y){if(pr.innerHTML="",y.length===0){const e=document.createElement("div");e.textContent="No EPUB files found.",pr.appendChild(e);return}for(const e of y){const t=await oo(e);pr.appendChild(t)}}async function oo(y){const e=document.createElement("div");e.className="library-item";const t=document.createElement("img");t.className="library-cover",t.src="";const i=document.createElement("div");i.className="library-title",i.textContent=y.name,e.appendChild(t),e.appendChild(i);try{const n=await(typeof y.getFile=="function"?await y.getFile():y).arrayBuffer(),s=Lt(n),u=await s.coverUrl();u?t.src=u:t.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAM1BMVEX///+hoaGcnJzPz8/Nzc3FxcXn5+fQ0NDy8vL29vbw8PDv7+/d3d2+vr6UlJSakGz1AAACNklEQVR4nO3d2ZKDIBAFUa8El//+uvLFT6qkSpknG/JpLve86o3QF8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD8S/w66a8vEcn8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ58n8eHS6HQ5+n/wP2S/3mmugUsAAAAASUVORK5CYII=";const l=await s.loaded.metadata;l.title&&(i.textContent=l.title)}catch(r){console.error("Error loading cover for",y.name,r)}return e.addEventListener("click",()=>{vo(y)}),e}function Gt(y){y===!0?(dr.classList.add("open"),vr.classList.add("open")):y===!1?(dr.classList.remove("open"),vr.classList.remove("open")):(dr.classList.toggle("open"),vr.classList.toggle("open"))}let at=null,Ct=null,Fn=null,Ir=null;const uo=document.getElementById("toc-button"),lo=document.getElementById("prev-button"),ho=document.getElementById("next-button"),hs=document.getElementById("current-page"),fs=document.getElementById("overlay"),fo=document.getElementById("total-pages"),gr=document.getElementById("book-title"),cs=document.getElementById("toc-container"),Pn=document.getElementById("toc-content"),co=document.getElementById("viewer");function po(y){const e=y.target.files[0];if(!e)return;if(e.type!=="application/epub+zip"&&!e.name.endsWith(".epub")){Jt("The selected file is not a valid EPUB file.");return}_s();const t=new FileReader;t.onload=function(i){const r=i.target.result;ds(r).then(()=>{li()}).catch(n=>{li(),Jt("Error loading book: "+n.message)})},t.onerror=function(i){li(),Jt("Error reading file: "+i.target.error)},t.readAsArrayBuffer(e)}async function vo(y){Gt(!1),_s();try{const t=await(typeof y?.getFile=="function"?await y.getFile():y).arrayBuffer();await ds(t)}catch(e){Gt(!0),Jt("Error opening book: "+e.message)}finally{li()}}async function ds(y,e){at&&(at=null,Ct=null,co.innerHTML=""),at=Lt(y),await at.ready,Ct=at.renderTo("viewer",{width:"100%",height:"100%",spread:"none"}),Fn=Ct.display(e),await mo(),await go(),lo.disabled=!1,ho.disabled=!1,uo.disabled=!1,Ct.on("relocated",t=>{if(t.start.cfi,Ir){const i=at.locations.locationFromCfi(t.start.cfi);hs.value=i+1}}),window.removeEventListener("keyup",mr),window.addEventListener("keyup",mr),window.addEventListener("keyup",mr);try{const t=await at.loaded.metadata;t.title?gr.textContent=t.title:gr.textContent="Untitled EPUB"}catch{gr.textContent="EPUB Book"}return Fn}async function go(){if(at)try{await at.locations.generate(1e3),Ir=at.locations,fo.textContent=at.locations.length()}catch(y){console.error("Error generating locations:",y)}}async function mo(){if(at)try{const y=await at.navigation.toc;Pn.innerHTML="",y.forEach(e=>{const t=document.createElement("div");t.className="toc-item",t.textContent=e.label,t.addEventListener("click",()=>{Ct.display(e.href),ms()}),Pn.appendChild(t)})}catch(y){console.error("Error generating TOC:",y)}}function ps(){Ct&&Ct.prev()}function vs(){Ct&&Ct.next()}function yo(){if(!at||!Ir)return;const y=parseInt(hs.value,10)-1;if(y>=0&&yys.click());ys.addEventListener("change",po);Do.addEventListener("click",ps);Co.addEventListener("click",vs);So.addEventListener("change",yo);xo.addEventListener("click",gs);Ao.addEventListener("click",gs);_o.addEventListener("click",so);Eo.addEventListener("click",()=>Gt(!1));To.addEventListener("click",()=>{ms(),Gt(!1),Es()});No.addEventListener("click",Es);wo.addEventListener("change",ao);function _s(){bs.classList.add("show")}function li(){bs.classList.remove("show")}function Jt(y){ko.textContent=y,ws.classList.add("show")}function Es(){ws.classList.remove("show")}
+//# sourceMappingURL=index-Cf-RCOeo.js.map
diff --git a/assets/index-Cf-RCOeo.js.map b/assets/index-Cf-RCOeo.js.map
new file mode 100644
index 0000000..57bf47e
--- /dev/null
+++ b/assets/index-Cf-RCOeo.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"index-Cf-RCOeo.js","sources":["../../node_modules/type/value/is.js","../../node_modules/type/object/is.js","../../node_modules/type/prototype/is.js","../../node_modules/type/function/is.js","../../node_modules/type/plain-function/is.js","../../node_modules/es5-ext/object/assign/is-implemented.js","../../node_modules/es5-ext/object/keys/is-implemented.js","../../node_modules/es5-ext/function/noop.js","../../node_modules/es5-ext/object/is-value.js","../../node_modules/es5-ext/object/keys/shim.js","../../node_modules/es5-ext/object/keys/index.js","../../node_modules/es5-ext/object/valid-value.js","../../node_modules/es5-ext/object/assign/shim.js","../../node_modules/es5-ext/object/assign/index.js","../../node_modules/es5-ext/object/normalize-options.js","../../node_modules/es5-ext/string/#/contains/is-implemented.js","../../node_modules/es5-ext/string/#/contains/shim.js","../../node_modules/es5-ext/string/#/contains/index.js","../../node_modules/d/index.js","../../node_modules/es5-ext/object/valid-callable.js","../../node_modules/event-emitter/index.js","../../node_modules/@xmldom/xmldom/lib/conventions.js","../../node_modules/@xmldom/xmldom/lib/dom.js","../../node_modules/@xmldom/xmldom/lib/entities.js","../../node_modules/@xmldom/xmldom/lib/sax.js","../../node_modules/@xmldom/xmldom/lib/dom-parser.js","../../node_modules/@xmldom/xmldom/lib/index.js","../../node_modules/epubjs/src/utils/core.js","../../node_modules/path-webpack/path.js","../../node_modules/epubjs/src/utils/path.js","../../node_modules/epubjs/src/utils/url.js","../../node_modules/epubjs/src/epubcfi.js","../../node_modules/epubjs/src/utils/hook.js","../../node_modules/epubjs/src/utils/replacements.js","../../node_modules/epubjs/src/utils/request.js","../../node_modules/epubjs/src/section.js","../../node_modules/epubjs/src/spine.js","../../node_modules/epubjs/src/utils/queue.js","../../node_modules/epubjs/src/utils/constants.js","../../node_modules/epubjs/src/locations.js","../../node_modules/epubjs/src/container.js","../../node_modules/epubjs/src/packaging.js","../../node_modules/epubjs/src/navigation.js","../../node_modules/epubjs/src/utils/mime.js","../../node_modules/epubjs/src/resources.js","../../node_modules/epubjs/src/pagelist.js","../../node_modules/epubjs/src/layout.js","../../node_modules/epubjs/src/themes.js","../../node_modules/epubjs/src/mapping.js","../../node_modules/epubjs/src/contents.js","../../node_modules/epubjs/src/annotations.js","../../node_modules/marks-pane/lib/svg.js","../../node_modules/marks-pane/lib/events.js","../../node_modules/marks-pane/lib/marks.js","../../node_modules/epubjs/src/managers/views/iframe.js","../../node_modules/epubjs/src/utils/scrolltype.js","../../node_modules/lodash/isObject.js","../../node_modules/lodash/_freeGlobal.js","../../node_modules/lodash/_root.js","../../node_modules/lodash/now.js","../../node_modules/lodash/_trimmedEndIndex.js","../../node_modules/lodash/_baseTrim.js","../../node_modules/lodash/_Symbol.js","../../node_modules/lodash/_getRawTag.js","../../node_modules/lodash/_objectToString.js","../../node_modules/lodash/_baseGetTag.js","../../node_modules/lodash/isObjectLike.js","../../node_modules/lodash/isSymbol.js","../../node_modules/lodash/toNumber.js","../../node_modules/lodash/debounce.js","../../node_modules/lodash/throttle.js","../../node_modules/epubjs/src/managers/helpers/stage.js","../../node_modules/epubjs/src/managers/helpers/views.js","../../node_modules/epubjs/src/managers/default/index.js","../../node_modules/epubjs/src/managers/helpers/snap.js","../../node_modules/epubjs/src/managers/continuous/index.js","../../node_modules/epubjs/src/rendition.js","../../node_modules/jszip/dist/jszip.js","../../node_modules/epubjs/src/archive.js","../../node_modules/localforage/dist/localforage.js","../../node_modules/epubjs/src/store.js","../../node_modules/epubjs/src/displayoptions.js","../../node_modules/epubjs/src/book.js","../../node_modules/epubjs/src/epub.js","../../src/indexedDB.js","../../src/library.js","../../src/book.js","../../src/main.js"],"sourcesContent":["\"use strict\";\n\n// ES3 safe\nvar _undefined = void 0;\n\nmodule.exports = function (value) { return value !== _undefined && value !== null; };\n","\"use strict\";\n\nvar isValue = require(\"../value/is\");\n\n// prettier-ignore\nvar possibleTypes = { \"object\": true, \"function\": true, \"undefined\": true /* document.all */ };\n\nmodule.exports = function (value) {\n\tif (!isValue(value)) return false;\n\treturn hasOwnProperty.call(possibleTypes, typeof value);\n};\n","\"use strict\";\n\nvar isObject = require(\"../object/is\");\n\nmodule.exports = function (value) {\n\tif (!isObject(value)) return false;\n\ttry {\n\t\tif (!value.constructor) return false;\n\t\treturn value.constructor.prototype === value;\n\t} catch (error) {\n\t\treturn false;\n\t}\n};\n","\"use strict\";\n\nvar isPrototype = require(\"../prototype/is\");\n\nmodule.exports = function (value) {\n\tif (typeof value !== \"function\") return false;\n\n\tif (!hasOwnProperty.call(value, \"length\")) return false;\n\n\ttry {\n\t\tif (typeof value.length !== \"number\") return false;\n\t\tif (typeof value.call !== \"function\") return false;\n\t\tif (typeof value.apply !== \"function\") return false;\n\t} catch (error) {\n\t\treturn false;\n\t}\n\n\treturn !isPrototype(value);\n};\n","\"use strict\";\n\nvar isFunction = require(\"../function/is\");\n\nvar classRe = /^\\s*class[\\s{/}]/, functionToString = Function.prototype.toString;\n\nmodule.exports = function (value) {\n\tif (!isFunction(value)) return false;\n\tif (classRe.test(functionToString.call(value))) return false;\n\treturn true;\n};\n","\"use strict\";\n\nmodule.exports = function () {\n\tvar assign = Object.assign, obj;\n\tif (typeof assign !== \"function\") return false;\n\tobj = { foo: \"raz\" };\n\tassign(obj, { bar: \"dwa\" }, { trzy: \"trzy\" });\n\treturn obj.foo + obj.bar + obj.trzy === \"razdwatrzy\";\n};\n","\"use strict\";\n\nmodule.exports = function () {\n\ttry {\n\t\tObject.keys(\"primitive\");\n\t\treturn true;\n\t} catch (e) {\n\t\treturn false;\n\t}\n};\n","\"use strict\";\n\n// eslint-disable-next-line no-empty-function\nmodule.exports = function () {};\n","\"use strict\";\n\nvar _undefined = require(\"../function/noop\")(); // Support ES3 engines\n\nmodule.exports = function (val) { return val !== _undefined && val !== null; };\n","\"use strict\";\n\nvar isValue = require(\"../is-value\");\n\nvar keys = Object.keys;\n\nmodule.exports = function (object) { return keys(isValue(object) ? Object(object) : object); };\n","\"use strict\";\n\nmodule.exports = require(\"./is-implemented\")() ? Object.keys : require(\"./shim\");\n","\"use strict\";\n\nvar isValue = require(\"./is-value\");\n\nmodule.exports = function (value) {\n\tif (!isValue(value)) throw new TypeError(\"Cannot use null or undefined\");\n\treturn value;\n};\n","\"use strict\";\n\nvar keys = require(\"../keys\")\n , value = require(\"../valid-value\")\n , max = Math.max;\n\nmodule.exports = function (dest, src /*, …srcn*/) {\n\tvar error, i, length = max(arguments.length, 2), assign;\n\tdest = Object(value(dest));\n\tassign = function (key) {\n\t\ttry {\n\t\t\tdest[key] = src[key];\n\t\t} catch (e) {\n\t\t\tif (!error) error = e;\n\t\t}\n\t};\n\tfor (i = 1; i < length; ++i) {\n\t\tsrc = arguments[i];\n\t\tkeys(src).forEach(assign);\n\t}\n\tif (error !== undefined) throw error;\n\treturn dest;\n};\n","\"use strict\";\n\nmodule.exports = require(\"./is-implemented\")() ? Object.assign : require(\"./shim\");\n","\"use strict\";\n\nvar isValue = require(\"./is-value\");\n\nvar forEach = Array.prototype.forEach, create = Object.create;\n\nvar process = function (src, obj) {\n\tvar key;\n\tfor (key in src) obj[key] = src[key];\n};\n\n// eslint-disable-next-line no-unused-vars\nmodule.exports = function (opts1 /*, …options*/) {\n\tvar result = create(null);\n\tforEach.call(arguments, function (options) {\n\t\tif (!isValue(options)) return;\n\t\tprocess(Object(options), result);\n\t});\n\treturn result;\n};\n","\"use strict\";\n\nvar str = \"razdwatrzy\";\n\nmodule.exports = function () {\n\tif (typeof str.contains !== \"function\") return false;\n\treturn str.contains(\"dwa\") === true && str.contains(\"foo\") === false;\n};\n","\"use strict\";\n\nvar indexOf = String.prototype.indexOf;\n\nmodule.exports = function (searchString /*, position*/) {\n\treturn indexOf.call(this, searchString, arguments[1]) > -1;\n};\n","\"use strict\";\n\nmodule.exports = require(\"./is-implemented\")() ? String.prototype.contains : require(\"./shim\");\n","\"use strict\";\n\nvar isValue = require(\"type/value/is\")\n , isPlainFunction = require(\"type/plain-function/is\")\n , assign = require(\"es5-ext/object/assign\")\n , normalizeOpts = require(\"es5-ext/object/normalize-options\")\n , contains = require(\"es5-ext/string/#/contains\");\n\nvar d = (module.exports = function (dscr, value/*, options*/) {\n\tvar c, e, w, options, desc;\n\tif (arguments.length < 2 || typeof dscr !== \"string\") {\n\t\toptions = value;\n\t\tvalue = dscr;\n\t\tdscr = null;\n\t} else {\n\t\toptions = arguments[2];\n\t}\n\tif (isValue(dscr)) {\n\t\tc = contains.call(dscr, \"c\");\n\t\te = contains.call(dscr, \"e\");\n\t\tw = contains.call(dscr, \"w\");\n\t} else {\n\t\tc = w = true;\n\t\te = false;\n\t}\n\n\tdesc = { value: value, configurable: c, enumerable: e, writable: w };\n\treturn !options ? desc : assign(normalizeOpts(options), desc);\n});\n\nd.gs = function (dscr, get, set/*, options*/) {\n\tvar c, e, options, desc;\n\tif (typeof dscr !== \"string\") {\n\t\toptions = set;\n\t\tset = get;\n\t\tget = dscr;\n\t\tdscr = null;\n\t} else {\n\t\toptions = arguments[3];\n\t}\n\tif (!isValue(get)) {\n\t\tget = undefined;\n\t} else if (!isPlainFunction(get)) {\n\t\toptions = get;\n\t\tget = set = undefined;\n\t} else if (!isValue(set)) {\n\t\tset = undefined;\n\t} else if (!isPlainFunction(set)) {\n\t\toptions = set;\n\t\tset = undefined;\n\t}\n\tif (isValue(dscr)) {\n\t\tc = contains.call(dscr, \"c\");\n\t\te = contains.call(dscr, \"e\");\n\t} else {\n\t\tc = true;\n\t\te = false;\n\t}\n\n\tdesc = { get: get, set: set, configurable: c, enumerable: e };\n\treturn !options ? desc : assign(normalizeOpts(options), desc);\n};\n","\"use strict\";\n\nmodule.exports = function (fn) {\n\tif (typeof fn !== \"function\") throw new TypeError(fn + \" is not a function\");\n\treturn fn;\n};\n","'use strict';\n\nvar d = require('d')\n , callable = require('es5-ext/object/valid-callable')\n\n , apply = Function.prototype.apply, call = Function.prototype.call\n , create = Object.create, defineProperty = Object.defineProperty\n , defineProperties = Object.defineProperties\n , hasOwnProperty = Object.prototype.hasOwnProperty\n , descriptor = { configurable: true, enumerable: false, writable: true }\n\n , on, once, off, emit, methods, descriptors, base;\n\non = function (type, listener) {\n\tvar data;\n\n\tcallable(listener);\n\n\tif (!hasOwnProperty.call(this, '__ee__')) {\n\t\tdata = descriptor.value = create(null);\n\t\tdefineProperty(this, '__ee__', descriptor);\n\t\tdescriptor.value = null;\n\t} else {\n\t\tdata = this.__ee__;\n\t}\n\tif (!data[type]) data[type] = listener;\n\telse if (typeof data[type] === 'object') data[type].push(listener);\n\telse data[type] = [data[type], listener];\n\n\treturn this;\n};\n\nonce = function (type, listener) {\n\tvar once, self;\n\n\tcallable(listener);\n\tself = this;\n\ton.call(this, type, once = function () {\n\t\toff.call(self, type, once);\n\t\tapply.call(listener, this, arguments);\n\t});\n\n\tonce.__eeOnceListener__ = listener;\n\treturn this;\n};\n\noff = function (type, listener) {\n\tvar data, listeners, candidate, i;\n\n\tcallable(listener);\n\n\tif (!hasOwnProperty.call(this, '__ee__')) return this;\n\tdata = this.__ee__;\n\tif (!data[type]) return this;\n\tlisteners = data[type];\n\n\tif (typeof listeners === 'object') {\n\t\tfor (i = 0; (candidate = listeners[i]); ++i) {\n\t\t\tif ((candidate === listener) ||\n\t\t\t\t\t(candidate.__eeOnceListener__ === listener)) {\n\t\t\t\tif (listeners.length === 2) data[type] = listeners[i ? 0 : 1];\n\t\t\t\telse listeners.splice(i, 1);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tif ((listeners === listener) ||\n\t\t\t\t(listeners.__eeOnceListener__ === listener)) {\n\t\t\tdelete data[type];\n\t\t}\n\t}\n\n\treturn this;\n};\n\nemit = function (type) {\n\tvar i, l, listener, listeners, args;\n\n\tif (!hasOwnProperty.call(this, '__ee__')) return;\n\tlisteners = this.__ee__[type];\n\tif (!listeners) return;\n\n\tif (typeof listeners === 'object') {\n\t\tl = arguments.length;\n\t\targs = new Array(l - 1);\n\t\tfor (i = 1; i < l; ++i) args[i - 1] = arguments[i];\n\n\t\tlisteners = listeners.slice();\n\t\tfor (i = 0; (listener = listeners[i]); ++i) {\n\t\t\tapply.call(listener, this, args);\n\t\t}\n\t} else {\n\t\tswitch (arguments.length) {\n\t\tcase 1:\n\t\t\tcall.call(listeners, this);\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tcall.call(listeners, this, arguments[1]);\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tcall.call(listeners, this, arguments[1], arguments[2]);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tl = arguments.length;\n\t\t\targs = new Array(l - 1);\n\t\t\tfor (i = 1; i < l; ++i) {\n\t\t\t\targs[i - 1] = arguments[i];\n\t\t\t}\n\t\t\tapply.call(listeners, this, args);\n\t\t}\n\t}\n};\n\nmethods = {\n\ton: on,\n\tonce: once,\n\toff: off,\n\temit: emit\n};\n\ndescriptors = {\n\ton: d(on),\n\tonce: d(once),\n\toff: d(off),\n\temit: d(emit)\n};\n\nbase = defineProperties({}, descriptors);\n\nmodule.exports = exports = function (o) {\n\treturn (o == null) ? create(base) : defineProperties(Object(o), descriptors);\n};\nexports.methods = methods;\n","'use strict'\n\n/**\n * Ponyfill for `Array.prototype.find` which is only available in ES6 runtimes.\n *\n * Works with anything that has a `length` property and index access properties, including NodeList.\n *\n * @template {unknown} T\n * @param {Array | ({length:number, [number]: T})} list\n * @param {function (item: T, index: number, list:Array | ({length:number, [number]: T})):boolean} predicate\n * @param {Partial>?} ac `Array.prototype` by default,\n * \t\t\t\tallows injecting a custom implementation in tests\n * @returns {T | undefined}\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find\n * @see https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.find\n */\nfunction find(list, predicate, ac) {\n\tif (ac === undefined) {\n\t\tac = Array.prototype;\n\t}\n\tif (list && typeof ac.find === 'function') {\n\t\treturn ac.find.call(list, predicate);\n\t}\n\tfor (var i = 0; i < list.length; i++) {\n\t\tif (Object.prototype.hasOwnProperty.call(list, i)) {\n\t\t\tvar item = list[i];\n\t\t\tif (predicate.call(undefined, item, i, list)) {\n\t\t\t\treturn item;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * \"Shallow freezes\" an object to render it immutable.\n * Uses `Object.freeze` if available,\n * otherwise the immutability is only in the type.\n *\n * Is used to create \"enum like\" objects.\n *\n * @template T\n * @param {T} object the object to freeze\n * @param {Pick = Object} oc `Object` by default,\n * \t\t\t\tallows to inject custom object constructor for tests\n * @returns {Readonly}\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze\n */\nfunction freeze(object, oc) {\n\tif (oc === undefined) {\n\t\toc = Object\n\t}\n\treturn oc && typeof oc.freeze === 'function' ? oc.freeze(object) : object\n}\n\n/**\n * All mime types that are allowed as input to `DOMParser.parseFromString`\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02 MDN\n * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype WHATWG HTML Spec\n * @see DOMParser.prototype.parseFromString\n */\nvar MIME_TYPE = freeze({\n\t/**\n\t * `text/html`, the only mime type that triggers treating an XML document as HTML.\n\t *\n\t * @see DOMParser.SupportedType.isHTML\n\t * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration\n\t * @see https://en.wikipedia.org/wiki/HTML Wikipedia\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN\n\t * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring WHATWG HTML Spec\n\t */\n\tHTML: 'text/html',\n\n\t/**\n\t * Helper method to check a mime type if it indicates an HTML document\n\t *\n\t * @param {string} [value]\n\t * @returns {boolean}\n\t *\n\t * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration\n\t * @see https://en.wikipedia.org/wiki/HTML Wikipedia\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN\n\t * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring \t */\n\tisHTML: function (value) {\n\t\treturn value === MIME_TYPE.HTML\n\t},\n\n\t/**\n\t * `application/xml`, the standard mime type for XML documents.\n\t *\n\t * @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType registration\n\t * @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303\n\t * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia\n\t */\n\tXML_APPLICATION: 'application/xml',\n\n\t/**\n\t * `text/html`, an alias for `application/xml`.\n\t *\n\t * @see https://tools.ietf.org/html/rfc7303#section-9.2 RFC 7303\n\t * @see https://www.iana.org/assignments/media-types/text/xml IANA MimeType registration\n\t * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia\n\t */\n\tXML_TEXT: 'text/xml',\n\n\t/**\n\t * `application/xhtml+xml`, indicates an XML document that has the default HTML namespace,\n\t * but is parsed as an XML document.\n\t *\n\t * @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType registration\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec\n\t * @see https://en.wikipedia.org/wiki/XHTML Wikipedia\n\t */\n\tXML_XHTML_APPLICATION: 'application/xhtml+xml',\n\n\t/**\n\t * `image/svg+xml`,\n\t *\n\t * @see https://www.iana.org/assignments/media-types/image/svg+xml IANA MimeType registration\n\t * @see https://www.w3.org/TR/SVG11/ W3C SVG 1.1\n\t * @see https://en.wikipedia.org/wiki/Scalable_Vector_Graphics Wikipedia\n\t */\n\tXML_SVG_IMAGE: 'image/svg+xml',\n})\n\n/**\n * Namespaces that are used in this code base.\n *\n * @see http://www.w3.org/TR/REC-xml-names\n */\nvar NAMESPACE = freeze({\n\t/**\n\t * The XHTML namespace.\n\t *\n\t * @see http://www.w3.org/1999/xhtml\n\t */\n\tHTML: 'http://www.w3.org/1999/xhtml',\n\n\t/**\n\t * Checks if `uri` equals `NAMESPACE.HTML`.\n\t *\n\t * @param {string} [uri]\n\t *\n\t * @see NAMESPACE.HTML\n\t */\n\tisHTML: function (uri) {\n\t\treturn uri === NAMESPACE.HTML\n\t},\n\n\t/**\n\t * The SVG namespace.\n\t *\n\t * @see http://www.w3.org/2000/svg\n\t */\n\tSVG: 'http://www.w3.org/2000/svg',\n\n\t/**\n\t * The `xml:` namespace.\n\t *\n\t * @see http://www.w3.org/XML/1998/namespace\n\t */\n\tXML: 'http://www.w3.org/XML/1998/namespace',\n\n\t/**\n\t * The `xmlns:` namespace\n\t *\n\t * @see https://www.w3.org/2000/xmlns/\n\t */\n\tXMLNS: 'http://www.w3.org/2000/xmlns/',\n})\n\nexports.find = find;\nexports.freeze = freeze;\nexports.MIME_TYPE = MIME_TYPE;\nexports.NAMESPACE = NAMESPACE;\n","var conventions = require(\"./conventions\");\n\nvar find = conventions.find;\nvar NAMESPACE = conventions.NAMESPACE;\n\n/**\n * A prerequisite for `[].filter`, to drop elements that are empty\n * @param {string} input\n * @returns {boolean}\n */\nfunction notEmptyString (input) {\n\treturn input !== ''\n}\n/**\n * @see https://infra.spec.whatwg.org/#split-on-ascii-whitespace\n * @see https://infra.spec.whatwg.org/#ascii-whitespace\n *\n * @param {string} input\n * @returns {string[]} (can be empty)\n */\nfunction splitOnASCIIWhitespace(input) {\n\t// U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, U+0020 SPACE\n\treturn input ? input.split(/[\\t\\n\\f\\r ]+/).filter(notEmptyString) : []\n}\n\n/**\n * Adds element as a key to current if it is not already present.\n *\n * @param {Record} current\n * @param {string} element\n * @returns {Record}\n */\nfunction orderedSetReducer (current, element) {\n\tif (!current.hasOwnProperty(element)) {\n\t\tcurrent[element] = true;\n\t}\n\treturn current;\n}\n\n/**\n * @see https://infra.spec.whatwg.org/#ordered-set\n * @param {string} input\n * @returns {string[]}\n */\nfunction toOrderedSet(input) {\n\tif (!input) return [];\n\tvar list = splitOnASCIIWhitespace(input);\n\treturn Object.keys(list.reduce(orderedSetReducer, {}))\n}\n\n/**\n * Uses `list.indexOf` to implement something like `Array.prototype.includes`,\n * which we can not rely on being available.\n *\n * @param {any[]} list\n * @returns {function(any): boolean}\n */\nfunction arrayIncludes (list) {\n\treturn function(element) {\n\t\treturn list && list.indexOf(element) !== -1;\n\t}\n}\n\nfunction copy(src,dest){\n\tfor(var p in src){\n\t\tif (Object.prototype.hasOwnProperty.call(src, p)) {\n\t\t\tdest[p] = src[p];\n\t\t}\n\t}\n}\n\n/**\n^\\w+\\.prototype\\.([_\\w]+)\\s*=\\s*((?:.*\\{\\s*?[\\r\\n][\\s\\S]*?^})|\\S.*?(?=[;\\r\\n]));?\n^\\w+\\.prototype\\.([_\\w]+)\\s*=\\s*(\\S.*?(?=[;\\r\\n]));?\n */\nfunction _extends(Class,Super){\n\tvar pt = Class.prototype;\n\tif(!(pt instanceof Super)){\n\t\tfunction t(){};\n\t\tt.prototype = Super.prototype;\n\t\tt = new t();\n\t\tcopy(pt,t);\n\t\tClass.prototype = pt = t;\n\t}\n\tif(pt.constructor != Class){\n\t\tif(typeof Class != 'function'){\n\t\t\tconsole.error(\"unknown Class:\"+Class)\n\t\t}\n\t\tpt.constructor = Class\n\t}\n}\n\n// Node Types\nvar NodeType = {}\nvar ELEMENT_NODE = NodeType.ELEMENT_NODE = 1;\nvar ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2;\nvar TEXT_NODE = NodeType.TEXT_NODE = 3;\nvar CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4;\nvar ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5;\nvar ENTITY_NODE = NodeType.ENTITY_NODE = 6;\nvar PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7;\nvar COMMENT_NODE = NodeType.COMMENT_NODE = 8;\nvar DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9;\nvar DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10;\nvar DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11;\nvar NOTATION_NODE = NodeType.NOTATION_NODE = 12;\n\n// ExceptionCode\nvar ExceptionCode = {}\nvar ExceptionMessage = {};\nvar INDEX_SIZE_ERR = ExceptionCode.INDEX_SIZE_ERR = ((ExceptionMessage[1]=\"Index size error\"),1);\nvar DOMSTRING_SIZE_ERR = ExceptionCode.DOMSTRING_SIZE_ERR = ((ExceptionMessage[2]=\"DOMString size error\"),2);\nvar HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = ((ExceptionMessage[3]=\"Hierarchy request error\"),3);\nvar WRONG_DOCUMENT_ERR = ExceptionCode.WRONG_DOCUMENT_ERR = ((ExceptionMessage[4]=\"Wrong document\"),4);\nvar INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]=\"Invalid character\"),5);\nvar NO_DATA_ALLOWED_ERR = ExceptionCode.NO_DATA_ALLOWED_ERR = ((ExceptionMessage[6]=\"No data allowed\"),6);\nvar NO_MODIFICATION_ALLOWED_ERR = ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = ((ExceptionMessage[7]=\"No modification allowed\"),7);\nvar NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = ((ExceptionMessage[8]=\"Not found\"),8);\nvar NOT_SUPPORTED_ERR = ExceptionCode.NOT_SUPPORTED_ERR = ((ExceptionMessage[9]=\"Not supported\"),9);\nvar INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = ((ExceptionMessage[10]=\"Attribute in use\"),10);\n//level2\nvar INVALID_STATE_ERR \t= ExceptionCode.INVALID_STATE_ERR \t= ((ExceptionMessage[11]=\"Invalid state\"),11);\nvar SYNTAX_ERR \t= ExceptionCode.SYNTAX_ERR \t= ((ExceptionMessage[12]=\"Syntax error\"),12);\nvar INVALID_MODIFICATION_ERR \t= ExceptionCode.INVALID_MODIFICATION_ERR \t= ((ExceptionMessage[13]=\"Invalid modification\"),13);\nvar NAMESPACE_ERR \t= ExceptionCode.NAMESPACE_ERR \t= ((ExceptionMessage[14]=\"Invalid namespace\"),14);\nvar INVALID_ACCESS_ERR \t= ExceptionCode.INVALID_ACCESS_ERR \t= ((ExceptionMessage[15]=\"Invalid access\"),15);\n\n/**\n * DOM Level 2\n * Object DOMException\n * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html\n * @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html\n */\nfunction DOMException(code, message) {\n\tif(message instanceof Error){\n\t\tvar error = message;\n\t}else{\n\t\terror = this;\n\t\tError.call(this, ExceptionMessage[code]);\n\t\tthis.message = ExceptionMessage[code];\n\t\tif(Error.captureStackTrace) Error.captureStackTrace(this, DOMException);\n\t}\n\terror.code = code;\n\tif(message) this.message = this.message + \": \" + message;\n\treturn error;\n};\nDOMException.prototype = Error.prototype;\ncopy(ExceptionCode,DOMException)\n\n/**\n * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177\n * The NodeList interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented. NodeList objects in the DOM are live.\n * The items in the NodeList are accessible via an integral index, starting from 0.\n */\nfunction NodeList() {\n};\nNodeList.prototype = {\n\t/**\n\t * The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive.\n\t * @standard level1\n\t */\n\tlength:0,\n\t/**\n\t * Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null.\n\t * @standard level1\n\t * @param index unsigned long\n\t * Index into the collection.\n\t * @return Node\n\t * \tThe node at the indexth position in the NodeList, or null if that is not a valid index.\n\t */\n\titem: function(index) {\n\t\treturn index >= 0 && index < this.length ? this[index] : null;\n\t},\n\ttoString:function(isHTML,nodeFilter){\n\t\tfor(var buf = [], i = 0;i=0){\n\t\tvar lastIndex = list.length-1\n\t\twhile(i0 || key == 'xmlns'){\n//\t\t\treturn null;\n//\t\t}\n\t\t//console.log()\n\t\tvar i = this.length;\n\t\twhile(i--){\n\t\t\tvar attr = this[i];\n\t\t\t//console.log(attr.nodeName,key)\n\t\t\tif(attr.nodeName == key){\n\t\t\t\treturn attr;\n\t\t\t}\n\t\t}\n\t},\n\tsetNamedItem: function(attr) {\n\t\tvar el = attr.ownerElement;\n\t\tif(el && el!=this._ownerElement){\n\t\t\tthrow new DOMException(INUSE_ATTRIBUTE_ERR);\n\t\t}\n\t\tvar oldAttr = this.getNamedItem(attr.nodeName);\n\t\t_addNamedNode(this._ownerElement,this,attr,oldAttr);\n\t\treturn oldAttr;\n\t},\n\t/* returns Node */\n\tsetNamedItemNS: function(attr) {// raises: WRONG_DOCUMENT_ERR,NO_MODIFICATION_ALLOWED_ERR,INUSE_ATTRIBUTE_ERR\n\t\tvar el = attr.ownerElement, oldAttr;\n\t\tif(el && el!=this._ownerElement){\n\t\t\tthrow new DOMException(INUSE_ATTRIBUTE_ERR);\n\t\t}\n\t\toldAttr = this.getNamedItemNS(attr.namespaceURI,attr.localName);\n\t\t_addNamedNode(this._ownerElement,this,attr,oldAttr);\n\t\treturn oldAttr;\n\t},\n\n\t/* returns Node */\n\tremoveNamedItem: function(key) {\n\t\tvar attr = this.getNamedItem(key);\n\t\t_removeNamedNode(this._ownerElement,this,attr);\n\t\treturn attr;\n\n\n\t},// raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR\n\n\t//for level2\n\tremoveNamedItemNS:function(namespaceURI,localName){\n\t\tvar attr = this.getNamedItemNS(namespaceURI,localName);\n\t\t_removeNamedNode(this._ownerElement,this,attr);\n\t\treturn attr;\n\t},\n\tgetNamedItemNS: function(namespaceURI, localName) {\n\t\tvar i = this.length;\n\t\twhile(i--){\n\t\t\tvar node = this[i];\n\t\t\tif(node.localName == localName && node.namespaceURI == namespaceURI){\n\t\t\t\treturn node;\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n};\n\n/**\n * The DOMImplementation interface represents an object providing methods\n * which are not dependent on any particular document.\n * Such an object is returned by the `Document.implementation` property.\n *\n * __The individual methods describe the differences compared to the specs.__\n *\n * @constructor\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation MDN\n * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 DOM Level 1 Core (Initial)\n * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-102161490 DOM Level 2 Core\n * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-102161490 DOM Level 3 Core\n * @see https://dom.spec.whatwg.org/#domimplementation DOM Living Standard\n */\nfunction DOMImplementation() {\n}\n\nDOMImplementation.prototype = {\n\t/**\n\t * The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given feature is supported.\n\t * The different implementations fairly diverged in what kind of features were reported.\n\t * The latest version of the spec settled to force this method to always return true, where the functionality was accurate and in use.\n\t *\n\t * @deprecated It is deprecated and modern browsers return true in all cases.\n\t *\n\t * @param {string} feature\n\t * @param {string} [version]\n\t * @returns {boolean} always true\n\t *\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/hasFeature MDN\n\t * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1 Core\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature DOM Living Standard\n\t */\n\thasFeature: function(feature, version) {\n\t\t\treturn true;\n\t},\n\t/**\n\t * Creates an XML Document object of the specified type with its document element.\n\t *\n\t * __It behaves slightly different from the description in the living standard__:\n\t * - There is no interface/class `XMLDocument`, it returns a `Document` instance.\n\t * - `contentType`, `encoding`, `mode`, `origin`, `url` fields are currently not declared.\n\t * - this implementation is not validating names or qualified names\n\t * (when parsing XML strings, the SAX parser takes care of that)\n\t *\n\t * @param {string|null} namespaceURI\n\t * @param {string} qualifiedName\n\t * @param {DocumentType=null} doctype\n\t * @returns {Document}\n\t *\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN\n\t * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM Level 2 Core (initial)\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Level 2 Core\n\t *\n\t * @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract\n\t * @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names\n\t * @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names\n\t */\n\tcreateDocument: function(namespaceURI, qualifiedName, doctype){\n\t\tvar doc = new Document();\n\t\tdoc.implementation = this;\n\t\tdoc.childNodes = new NodeList();\n\t\tdoc.doctype = doctype || null;\n\t\tif (doctype){\n\t\t\tdoc.appendChild(doctype);\n\t\t}\n\t\tif (qualifiedName){\n\t\t\tvar root = doc.createElementNS(namespaceURI, qualifiedName);\n\t\t\tdoc.appendChild(root);\n\t\t}\n\t\treturn doc;\n\t},\n\t/**\n\t * Returns a doctype, with the given `qualifiedName`, `publicId`, and `systemId`.\n\t *\n\t * __This behavior is slightly different from the in the specs__:\n\t * - this implementation is not validating names or qualified names\n\t * (when parsing XML strings, the SAX parser takes care of that)\n\t *\n\t * @param {string} qualifiedName\n\t * @param {string} [publicId]\n\t * @param {string} [systemId]\n\t * @returns {DocumentType} which can either be used with `DOMImplementation.createDocument` upon document creation\n\t * \t\t\t\t or can be put into the document via methods like `Node.insertBefore()` or `Node.replaceChild()`\n\t *\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType MDN\n\t * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM Level 2 Core\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype DOM Living Standard\n\t *\n\t * @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract\n\t * @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names\n\t * @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names\n\t */\n\tcreateDocumentType: function(qualifiedName, publicId, systemId){\n\t\tvar node = new DocumentType();\n\t\tnode.name = qualifiedName;\n\t\tnode.nodeName = qualifiedName;\n\t\tnode.publicId = publicId || '';\n\t\tnode.systemId = systemId || '';\n\n\t\treturn node;\n\t}\n};\n\n\n/**\n * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247\n */\n\nfunction Node() {\n};\n\nNode.prototype = {\n\tfirstChild : null,\n\tlastChild : null,\n\tpreviousSibling : null,\n\tnextSibling : null,\n\tattributes : null,\n\tparentNode : null,\n\tchildNodes : null,\n\townerDocument : null,\n\tnodeValue : null,\n\tnamespaceURI : null,\n\tprefix : null,\n\tlocalName : null,\n\t// Modified in DOM Level 2:\n\tinsertBefore:function(newChild, refChild){//raises\n\t\treturn _insertBefore(this,newChild,refChild);\n\t},\n\treplaceChild:function(newChild, oldChild){//raises\n\t\t_insertBefore(this, newChild,oldChild, assertPreReplacementValidityInDocument);\n\t\tif(oldChild){\n\t\t\tthis.removeChild(oldChild);\n\t\t}\n\t},\n\tremoveChild:function(oldChild){\n\t\treturn _removeChild(this,oldChild);\n\t},\n\tappendChild:function(newChild){\n\t\treturn this.insertBefore(newChild,null);\n\t},\n\thasChildNodes:function(){\n\t\treturn this.firstChild != null;\n\t},\n\tcloneNode:function(deep){\n\t\treturn cloneNode(this.ownerDocument||this,this,deep);\n\t},\n\t// Modified in DOM Level 2:\n\tnormalize:function(){\n\t\tvar child = this.firstChild;\n\t\twhile(child){\n\t\t\tvar next = child.nextSibling;\n\t\t\tif(next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE){\n\t\t\t\tthis.removeChild(next);\n\t\t\t\tchild.appendData(next.data);\n\t\t\t}else{\n\t\t\t\tchild.normalize();\n\t\t\t\tchild = next;\n\t\t\t}\n\t\t}\n\t},\n \t// Introduced in DOM Level 2:\n\tisSupported:function(feature, version){\n\t\treturn this.ownerDocument.implementation.hasFeature(feature,version);\n\t},\n // Introduced in DOM Level 2:\n hasAttributes:function(){\n \treturn this.attributes.length>0;\n },\n\t/**\n\t * Look up the prefix associated to the given namespace URI, starting from this node.\n\t * **The default namespace declarations are ignored by this method.**\n\t * See Namespace Prefix Lookup for details on the algorithm used by this method.\n\t *\n\t * _Note: The implementation seems to be incomplete when compared to the algorithm described in the specs._\n\t *\n\t * @param {string | null} namespaceURI\n\t * @returns {string | null}\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespacePrefix\n\t * @see https://www.w3.org/TR/DOM-Level-3-Core/namespaces-algorithms.html#lookupNamespacePrefixAlgo\n\t * @see https://dom.spec.whatwg.org/#dom-node-lookupprefix\n\t * @see https://github.com/xmldom/xmldom/issues/322\n\t */\n lookupPrefix:function(namespaceURI){\n \tvar el = this;\n \twhile(el){\n \t\tvar map = el._nsMap;\n \t\t//console.dir(map)\n \t\tif(map){\n \t\t\tfor(var n in map){\n\t\t\t\t\tif (Object.prototype.hasOwnProperty.call(map, n) && map[n] === namespaceURI) {\n\t\t\t\t\t\treturn n;\n\t\t\t\t\t}\n \t\t\t}\n \t\t}\n \t\tel = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;\n \t}\n \treturn null;\n },\n // Introduced in DOM Level 3:\n lookupNamespaceURI:function(prefix){\n \tvar el = this;\n \twhile(el){\n \t\tvar map = el._nsMap;\n \t\t//console.dir(map)\n \t\tif(map){\n \t\t\tif(prefix in map){\n\t\t\t\t\tif(Object.prototype.hasOwnProperty.call(map, prefix)){\n\t\t\t\t\t\treturn map[prefix] ;\n\t\t\t\t\t}\n \t\t\t}\n \t\t}\n \t\tel = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;\n \t}\n \treturn null;\n },\n // Introduced in DOM Level 3:\n isDefaultNamespace:function(namespaceURI){\n \tvar prefix = this.lookupPrefix(namespaceURI);\n \treturn prefix == null;\n }\n};\n\n\nfunction _xmlEncoder(c){\n\treturn c == '<' && '<' ||\n c == '>' && '>' ||\n c == '&' && '&' ||\n c == '\"' && '"' ||\n ''+c.charCodeAt()+';'\n}\n\n\ncopy(NodeType,Node);\ncopy(NodeType,Node.prototype);\n\n/**\n * @param callback return true for continue,false for break\n * @return boolean true: break visit;\n */\nfunction _visitNode(node,callback){\n\tif(callback(node)){\n\t\treturn true;\n\t}\n\tif(node = node.firstChild){\n\t\tdo{\n\t\t\tif(_visitNode(node,callback)){return true}\n }while(node=node.nextSibling)\n }\n}\n\n\n\nfunction Document(){\n\tthis.ownerDocument = this;\n}\n\nfunction _onAddAttribute(doc,el,newAttr){\n\tdoc && doc._inc++;\n\tvar ns = newAttr.namespaceURI ;\n\tif(ns === NAMESPACE.XMLNS){\n\t\t//update namespace\n\t\tel._nsMap[newAttr.prefix?newAttr.localName:''] = newAttr.value\n\t}\n}\n\nfunction _onRemoveAttribute(doc,el,newAttr,remove){\n\tdoc && doc._inc++;\n\tvar ns = newAttr.namespaceURI ;\n\tif(ns === NAMESPACE.XMLNS){\n\t\t//update namespace\n\t\tdelete el._nsMap[newAttr.prefix?newAttr.localName:'']\n\t}\n}\n\nfunction _onUpdateChild(doc,el,newChild){\n\tif(doc && doc._inc){\n\t\tdoc._inc++;\n\t\t//update childNodes\n\t\tvar cs = el.childNodes;\n\t\tif(newChild){\n\t\t\tcs[cs.length++] = newChild;\n\t\t}else{\n\t\t\t//console.log(1)\n\t\t\tvar child = el.firstChild;\n\t\t\tvar i = 0;\n\t\t\twhile(child){\n\t\t\t\tcs[i++] = child;\n\t\t\t\tchild =child.nextSibling;\n\t\t\t}\n\t\t\tcs.length = i;\n\t\t\tdelete cs[cs.length];\n\t\t}\n\t}\n}\n\n/**\n * attributes;\n * children;\n *\n * writeable properties:\n * nodeValue,Attr:value,CharacterData:data\n * prefix\n */\nfunction _removeChild(parentNode,child){\n\tvar previous = child.previousSibling;\n\tvar next = child.nextSibling;\n\tif(previous){\n\t\tprevious.nextSibling = next;\n\t}else{\n\t\tparentNode.firstChild = next\n\t}\n\tif(next){\n\t\tnext.previousSibling = previous;\n\t}else{\n\t\tparentNode.lastChild = previous;\n\t}\n\tchild.parentNode = null;\n\tchild.previousSibling = null;\n\tchild.nextSibling = null;\n\t_onUpdateChild(parentNode.ownerDocument,parentNode);\n\treturn child;\n}\n\n/**\n * Returns `true` if `node` can be a parent for insertion.\n * @param {Node} node\n * @returns {boolean}\n */\nfunction hasValidParentNodeType(node) {\n\treturn (\n\t\tnode &&\n\t\t(node.nodeType === Node.DOCUMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE || node.nodeType === Node.ELEMENT_NODE)\n\t);\n}\n\n/**\n * Returns `true` if `node` can be inserted according to it's `nodeType`.\n * @param {Node} node\n * @returns {boolean}\n */\nfunction hasInsertableNodeType(node) {\n\treturn (\n\t\tnode &&\n\t\t(isElementNode(node) ||\n\t\t\tisTextNode(node) ||\n\t\t\tisDocTypeNode(node) ||\n\t\t\tnode.nodeType === Node.DOCUMENT_FRAGMENT_NODE ||\n\t\t\tnode.nodeType === Node.COMMENT_NODE ||\n\t\t\tnode.nodeType === Node.PROCESSING_INSTRUCTION_NODE)\n\t);\n}\n\n/**\n * Returns true if `node` is a DOCTYPE node\n * @param {Node} node\n * @returns {boolean}\n */\nfunction isDocTypeNode(node) {\n\treturn node && node.nodeType === Node.DOCUMENT_TYPE_NODE;\n}\n\n/**\n * Returns true if the node is an element\n * @param {Node} node\n * @returns {boolean}\n */\nfunction isElementNode(node) {\n\treturn node && node.nodeType === Node.ELEMENT_NODE;\n}\n/**\n * Returns true if `node` is a text node\n * @param {Node} node\n * @returns {boolean}\n */\nfunction isTextNode(node) {\n\treturn node && node.nodeType === Node.TEXT_NODE;\n}\n\n/**\n * Check if en element node can be inserted before `child`, or at the end if child is falsy,\n * according to the presence and position of a doctype node on the same level.\n *\n * @param {Document} doc The document node\n * @param {Node} child the node that would become the nextSibling if the element would be inserted\n * @returns {boolean} `true` if an element can be inserted before child\n * @private\n * https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n */\nfunction isElementInsertionPossible(doc, child) {\n\tvar parentChildNodes = doc.childNodes || [];\n\tif (find(parentChildNodes, isElementNode) || isDocTypeNode(child)) {\n\t\treturn false;\n\t}\n\tvar docTypeNode = find(parentChildNodes, isDocTypeNode);\n\treturn !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));\n}\n\n/**\n * Check if en element node can be inserted before `child`, or at the end if child is falsy,\n * according to the presence and position of a doctype node on the same level.\n *\n * @param {Node} doc The document node\n * @param {Node} child the node that would become the nextSibling if the element would be inserted\n * @returns {boolean} `true` if an element can be inserted before child\n * @private\n * https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n */\nfunction isElementReplacementPossible(doc, child) {\n\tvar parentChildNodes = doc.childNodes || [];\n\n\tfunction hasElementChildThatIsNotChild(node) {\n\t\treturn isElementNode(node) && node !== child;\n\t}\n\n\tif (find(parentChildNodes, hasElementChildThatIsNotChild)) {\n\t\treturn false;\n\t}\n\tvar docTypeNode = find(parentChildNodes, isDocTypeNode);\n\treturn !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));\n}\n\n/**\n * @private\n * Steps 1-5 of the checks before inserting and before replacing a child are the same.\n *\n * @param {Node} parent the parent node to insert `node` into\n * @param {Node} node the node to insert\n * @param {Node=} child the node that should become the `nextSibling` of `node`\n * @returns {Node}\n * @throws DOMException for several node combinations that would create a DOM that is not well-formed.\n * @throws DOMException if `child` is provided but is not a child of `parent`.\n * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n * @see https://dom.spec.whatwg.org/#concept-node-replace\n */\nfunction assertPreInsertionValidity1to5(parent, node, child) {\n\t// 1. If `parent` is not a Document, DocumentFragment, or Element node, then throw a \"HierarchyRequestError\" DOMException.\n\tif (!hasValidParentNodeType(parent)) {\n\t\tthrow new DOMException(HIERARCHY_REQUEST_ERR, 'Unexpected parent node type ' + parent.nodeType);\n\t}\n\t// 2. If `node` is a host-including inclusive ancestor of `parent`, then throw a \"HierarchyRequestError\" DOMException.\n\t// not implemented!\n\t// 3. If `child` is non-null and its parent is not `parent`, then throw a \"NotFoundError\" DOMException.\n\tif (child && child.parentNode !== parent) {\n\t\tthrow new DOMException(NOT_FOUND_ERR, 'child not in parent');\n\t}\n\tif (\n\t\t// 4. If `node` is not a DocumentFragment, DocumentType, Element, or CharacterData node, then throw a \"HierarchyRequestError\" DOMException.\n\t\t!hasInsertableNodeType(node) ||\n\t\t// 5. If either `node` is a Text node and `parent` is a document,\n\t\t// the sax parser currently adds top level text nodes, this will be fixed in 0.9.0\n\t\t// || (node.nodeType === Node.TEXT_NODE && parent.nodeType === Node.DOCUMENT_NODE)\n\t\t// or `node` is a doctype and `parent` is not a document, then throw a \"HierarchyRequestError\" DOMException.\n\t\t(isDocTypeNode(node) && parent.nodeType !== Node.DOCUMENT_NODE)\n\t) {\n\t\tthrow new DOMException(\n\t\t\tHIERARCHY_REQUEST_ERR,\n\t\t\t'Unexpected node type ' + node.nodeType + ' for parent node type ' + parent.nodeType\n\t\t);\n\t}\n}\n\n/**\n * @private\n * Step 6 of the checks before inserting and before replacing a child are different.\n *\n * @param {Document} parent the parent node to insert `node` into\n * @param {Node} node the node to insert\n * @param {Node | undefined} child the node that should become the `nextSibling` of `node`\n * @returns {Node}\n * @throws DOMException for several node combinations that would create a DOM that is not well-formed.\n * @throws DOMException if `child` is provided but is not a child of `parent`.\n * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n * @see https://dom.spec.whatwg.org/#concept-node-replace\n */\nfunction assertPreInsertionValidityInDocument(parent, node, child) {\n\tvar parentChildNodes = parent.childNodes || [];\n\tvar nodeChildNodes = node.childNodes || [];\n\n\t// DocumentFragment\n\tif (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n\t\tvar nodeChildElements = nodeChildNodes.filter(isElementNode);\n\t\t// If node has more than one element child or has a Text node child.\n\t\tif (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {\n\t\t\tthrow new DOMException(HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment');\n\t\t}\n\t\t// Otherwise, if `node` has one element child and either `parent` has an element child,\n\t\t// `child` is a doctype, or `child` is non-null and a doctype is following `child`.\n\t\tif (nodeChildElements.length === 1 && !isElementInsertionPossible(parent, child)) {\n\t\t\tthrow new DOMException(HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype');\n\t\t}\n\t}\n\t// Element\n\tif (isElementNode(node)) {\n\t\t// `parent` has an element child, `child` is a doctype,\n\t\t// or `child` is non-null and a doctype is following `child`.\n\t\tif (!isElementInsertionPossible(parent, child)) {\n\t\t\tthrow new DOMException(HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype');\n\t\t}\n\t}\n\t// DocumentType\n\tif (isDocTypeNode(node)) {\n\t\t// `parent` has a doctype child,\n\t\tif (find(parentChildNodes, isDocTypeNode)) {\n\t\t\tthrow new DOMException(HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed');\n\t\t}\n\t\tvar parentElementChild = find(parentChildNodes, isElementNode);\n\t\t// `child` is non-null and an element is preceding `child`,\n\t\tif (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {\n\t\t\tthrow new DOMException(HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element');\n\t\t}\n\t\t// or `child` is null and `parent` has an element child.\n\t\tif (!child && parentElementChild) {\n\t\t\tthrow new DOMException(HIERARCHY_REQUEST_ERR, 'Doctype can not be appended since element is present');\n\t\t}\n\t}\n}\n\n/**\n * @private\n * Step 6 of the checks before inserting and before replacing a child are different.\n *\n * @param {Document} parent the parent node to insert `node` into\n * @param {Node} node the node to insert\n * @param {Node | undefined} child the node that should become the `nextSibling` of `node`\n * @returns {Node}\n * @throws DOMException for several node combinations that would create a DOM that is not well-formed.\n * @throws DOMException if `child` is provided but is not a child of `parent`.\n * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n * @see https://dom.spec.whatwg.org/#concept-node-replace\n */\nfunction assertPreReplacementValidityInDocument(parent, node, child) {\n\tvar parentChildNodes = parent.childNodes || [];\n\tvar nodeChildNodes = node.childNodes || [];\n\n\t// DocumentFragment\n\tif (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n\t\tvar nodeChildElements = nodeChildNodes.filter(isElementNode);\n\t\t// If `node` has more than one element child or has a Text node child.\n\t\tif (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {\n\t\t\tthrow new DOMException(HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment');\n\t\t}\n\t\t// Otherwise, if `node` has one element child and either `parent` has an element child that is not `child` or a doctype is following `child`.\n\t\tif (nodeChildElements.length === 1 && !isElementReplacementPossible(parent, child)) {\n\t\t\tthrow new DOMException(HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype');\n\t\t}\n\t}\n\t// Element\n\tif (isElementNode(node)) {\n\t\t// `parent` has an element child that is not `child` or a doctype is following `child`.\n\t\tif (!isElementReplacementPossible(parent, child)) {\n\t\t\tthrow new DOMException(HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype');\n\t\t}\n\t}\n\t// DocumentType\n\tif (isDocTypeNode(node)) {\n\t\tfunction hasDoctypeChildThatIsNotChild(node) {\n\t\t\treturn isDocTypeNode(node) && node !== child;\n\t\t}\n\n\t\t// `parent` has a doctype child that is not `child`,\n\t\tif (find(parentChildNodes, hasDoctypeChildThatIsNotChild)) {\n\t\t\tthrow new DOMException(HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed');\n\t\t}\n\t\tvar parentElementChild = find(parentChildNodes, isElementNode);\n\t\t// or an element is preceding `child`.\n\t\tif (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {\n\t\t\tthrow new DOMException(HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element');\n\t\t}\n\t}\n}\n\n/**\n * @private\n * @param {Node} parent the parent node to insert `node` into\n * @param {Node} node the node to insert\n * @param {Node=} child the node that should become the `nextSibling` of `node`\n * @returns {Node}\n * @throws DOMException for several node combinations that would create a DOM that is not well-formed.\n * @throws DOMException if `child` is provided but is not a child of `parent`.\n * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity\n */\nfunction _insertBefore(parent, node, child, _inDocumentAssertion) {\n\t// To ensure pre-insertion validity of a node into a parent before a child, run these steps:\n\tassertPreInsertionValidity1to5(parent, node, child);\n\n\t// If parent is a document, and any of the statements below, switched on the interface node implements,\n\t// are true, then throw a \"HierarchyRequestError\" DOMException.\n\tif (parent.nodeType === Node.DOCUMENT_NODE) {\n\t\t(_inDocumentAssertion || assertPreInsertionValidityInDocument)(parent, node, child);\n\t}\n\n\tvar cp = node.parentNode;\n\tif(cp){\n\t\tcp.removeChild(node);//remove and update\n\t}\n\tif(node.nodeType === DOCUMENT_FRAGMENT_NODE){\n\t\tvar newFirst = node.firstChild;\n\t\tif (newFirst == null) {\n\t\t\treturn node;\n\t\t}\n\t\tvar newLast = node.lastChild;\n\t}else{\n\t\tnewFirst = newLast = node;\n\t}\n\tvar pre = child ? child.previousSibling : parent.lastChild;\n\n\tnewFirst.previousSibling = pre;\n\tnewLast.nextSibling = child;\n\n\n\tif(pre){\n\t\tpre.nextSibling = newFirst;\n\t}else{\n\t\tparent.firstChild = newFirst;\n\t}\n\tif(child == null){\n\t\tparent.lastChild = newLast;\n\t}else{\n\t\tchild.previousSibling = newLast;\n\t}\n\tdo{\n\t\tnewFirst.parentNode = parent;\n\t}while(newFirst !== newLast && (newFirst= newFirst.nextSibling))\n\t_onUpdateChild(parent.ownerDocument||parent, parent);\n\t//console.log(parent.lastChild.nextSibling == null)\n\tif (node.nodeType == DOCUMENT_FRAGMENT_NODE) {\n\t\tnode.firstChild = node.lastChild = null;\n\t}\n\treturn node;\n}\nfunction _appendSingleChild(parentNode,newChild){\n\tif (newChild.parentNode) {\n\t\tnewChild.parentNode.removeChild(newChild);\n\t}\n\tnewChild.parentNode = parentNode;\n\tnewChild.previousSibling = parentNode.lastChild;\n\tnewChild.nextSibling = null;\n\tif (newChild.previousSibling) {\n\t\tnewChild.previousSibling.nextSibling = newChild;\n\t}else{\n\t\tparentNode.firstChild = newChild;\n\t}\n\tparentNode.lastChild = newChild;\n\t_onUpdateChild(parentNode.ownerDocument,parentNode,newChild);\n\treturn newChild;\n}\n\nDocument.prototype = {\n\t//implementation : null,\n\tnodeName : '#document',\n\tnodeType : DOCUMENT_NODE,\n\t/**\n\t * The DocumentType node of the document.\n\t *\n\t * @readonly\n\t * @type DocumentType\n\t */\n\tdoctype : null,\n\tdocumentElement : null,\n\t_inc : 1,\n\n\tinsertBefore : function(newChild, refChild){//raises\n\t\tif(newChild.nodeType == DOCUMENT_FRAGMENT_NODE){\n\t\t\tvar child = newChild.firstChild;\n\t\t\twhile(child){\n\t\t\t\tvar next = child.nextSibling;\n\t\t\t\tthis.insertBefore(child,refChild);\n\t\t\t\tchild = next;\n\t\t\t}\n\t\t\treturn newChild;\n\t\t}\n\t\t_insertBefore(this, newChild, refChild);\n\t\tnewChild.ownerDocument = this;\n\t\tif (this.documentElement === null && newChild.nodeType === ELEMENT_NODE) {\n\t\t\tthis.documentElement = newChild;\n\t\t}\n\n\t\treturn newChild;\n\t},\n\tremoveChild : function(oldChild){\n\t\tif(this.documentElement == oldChild){\n\t\t\tthis.documentElement = null;\n\t\t}\n\t\treturn _removeChild(this,oldChild);\n\t},\n\treplaceChild: function (newChild, oldChild) {\n\t\t//raises\n\t\t_insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);\n\t\tnewChild.ownerDocument = this;\n\t\tif (oldChild) {\n\t\t\tthis.removeChild(oldChild);\n\t\t}\n\t\tif (isElementNode(newChild)) {\n\t\t\tthis.documentElement = newChild;\n\t\t}\n\t},\n\t// Introduced in DOM Level 2:\n\timportNode : function(importedNode,deep){\n\t\treturn importNode(this,importedNode,deep);\n\t},\n\t// Introduced in DOM Level 2:\n\tgetElementById :\tfunction(id){\n\t\tvar rtv = null;\n\t\t_visitNode(this.documentElement,function(node){\n\t\t\tif(node.nodeType == ELEMENT_NODE){\n\t\t\t\tif(node.getAttribute('id') == id){\n\t\t\t\t\trtv = node;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t\treturn rtv;\n\t},\n\n\t/**\n\t * The `getElementsByClassName` method of `Document` interface returns an array-like object\n\t * of all child elements which have **all** of the given class name(s).\n\t *\n\t * Returns an empty list if `classeNames` is an empty string or only contains HTML white space characters.\n\t *\n\t *\n\t * Warning: This is a live LiveNodeList.\n\t * Changes in the DOM will reflect in the array as the changes occur.\n\t * If an element selected by this array no longer qualifies for the selector,\n\t * it will automatically be removed. Be aware of this for iteration purposes.\n\t *\n\t * @param {string} classNames is a string representing the class name(s) to match; multiple class names are separated by (ASCII-)whitespace\n\t *\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName\n\t * @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname\n\t */\n\tgetElementsByClassName: function(classNames) {\n\t\tvar classNamesSet = toOrderedSet(classNames)\n\t\treturn new LiveNodeList(this, function(base) {\n\t\t\tvar ls = [];\n\t\t\tif (classNamesSet.length > 0) {\n\t\t\t\t_visitNode(base.documentElement, function(node) {\n\t\t\t\t\tif(node !== base && node.nodeType === ELEMENT_NODE) {\n\t\t\t\t\t\tvar nodeClassNames = node.getAttribute('class')\n\t\t\t\t\t\t// can be null if the attribute does not exist\n\t\t\t\t\t\tif (nodeClassNames) {\n\t\t\t\t\t\t\t// before splitting and iterating just compare them for the most common case\n\t\t\t\t\t\t\tvar matches = classNames === nodeClassNames;\n\t\t\t\t\t\t\tif (!matches) {\n\t\t\t\t\t\t\t\tvar nodeClassNamesSet = toOrderedSet(nodeClassNames)\n\t\t\t\t\t\t\t\tmatches = classNamesSet.every(arrayIncludes(nodeClassNamesSet))\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif(matches) {\n\t\t\t\t\t\t\t\tls.push(node);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn ls;\n\t\t});\n\t},\n\n\t//document factory method:\n\tcreateElement :\tfunction(tagName){\n\t\tvar node = new Element();\n\t\tnode.ownerDocument = this;\n\t\tnode.nodeName = tagName;\n\t\tnode.tagName = tagName;\n\t\tnode.localName = tagName;\n\t\tnode.childNodes = new NodeList();\n\t\tvar attrs\t= node.attributes = new NamedNodeMap();\n\t\tattrs._ownerElement = node;\n\t\treturn node;\n\t},\n\tcreateDocumentFragment :\tfunction(){\n\t\tvar node = new DocumentFragment();\n\t\tnode.ownerDocument = this;\n\t\tnode.childNodes = new NodeList();\n\t\treturn node;\n\t},\n\tcreateTextNode :\tfunction(data){\n\t\tvar node = new Text();\n\t\tnode.ownerDocument = this;\n\t\tnode.appendData(data)\n\t\treturn node;\n\t},\n\tcreateComment :\tfunction(data){\n\t\tvar node = new Comment();\n\t\tnode.ownerDocument = this;\n\t\tnode.appendData(data)\n\t\treturn node;\n\t},\n\tcreateCDATASection :\tfunction(data){\n\t\tvar node = new CDATASection();\n\t\tnode.ownerDocument = this;\n\t\tnode.appendData(data)\n\t\treturn node;\n\t},\n\tcreateProcessingInstruction :\tfunction(target,data){\n\t\tvar node = new ProcessingInstruction();\n\t\tnode.ownerDocument = this;\n\t\tnode.tagName = node.nodeName = node.target = target;\n\t\tnode.nodeValue = node.data = data;\n\t\treturn node;\n\t},\n\tcreateAttribute :\tfunction(name){\n\t\tvar node = new Attr();\n\t\tnode.ownerDocument\t= this;\n\t\tnode.name = name;\n\t\tnode.nodeName\t= name;\n\t\tnode.localName = name;\n\t\tnode.specified = true;\n\t\treturn node;\n\t},\n\tcreateEntityReference :\tfunction(name){\n\t\tvar node = new EntityReference();\n\t\tnode.ownerDocument\t= this;\n\t\tnode.nodeName\t= name;\n\t\treturn node;\n\t},\n\t// Introduced in DOM Level 2:\n\tcreateElementNS :\tfunction(namespaceURI,qualifiedName){\n\t\tvar node = new Element();\n\t\tvar pl = qualifiedName.split(':');\n\t\tvar attrs\t= node.attributes = new NamedNodeMap();\n\t\tnode.childNodes = new NodeList();\n\t\tnode.ownerDocument = this;\n\t\tnode.nodeName = qualifiedName;\n\t\tnode.tagName = qualifiedName;\n\t\tnode.namespaceURI = namespaceURI;\n\t\tif(pl.length == 2){\n\t\t\tnode.prefix = pl[0];\n\t\t\tnode.localName = pl[1];\n\t\t}else{\n\t\t\t//el.prefix = null;\n\t\t\tnode.localName = qualifiedName;\n\t\t}\n\t\tattrs._ownerElement = node;\n\t\treturn node;\n\t},\n\t// Introduced in DOM Level 2:\n\tcreateAttributeNS :\tfunction(namespaceURI,qualifiedName){\n\t\tvar node = new Attr();\n\t\tvar pl = qualifiedName.split(':');\n\t\tnode.ownerDocument = this;\n\t\tnode.nodeName = qualifiedName;\n\t\tnode.name = qualifiedName;\n\t\tnode.namespaceURI = namespaceURI;\n\t\tnode.specified = true;\n\t\tif(pl.length == 2){\n\t\t\tnode.prefix = pl[0];\n\t\t\tnode.localName = pl[1];\n\t\t}else{\n\t\t\t//el.prefix = null;\n\t\t\tnode.localName = qualifiedName;\n\t\t}\n\t\treturn node;\n\t}\n};\n_extends(Document,Node);\n\n\nfunction Element() {\n\tthis._nsMap = {};\n};\nElement.prototype = {\n\tnodeType : ELEMENT_NODE,\n\thasAttribute : function(name){\n\t\treturn this.getAttributeNode(name)!=null;\n\t},\n\tgetAttribute : function(name){\n\t\tvar attr = this.getAttributeNode(name);\n\t\treturn attr && attr.value || '';\n\t},\n\tgetAttributeNode : function(name){\n\t\treturn this.attributes.getNamedItem(name);\n\t},\n\tsetAttribute : function(name, value){\n\t\tvar attr = this.ownerDocument.createAttribute(name);\n\t\tattr.value = attr.nodeValue = \"\" + value;\n\t\tthis.setAttributeNode(attr)\n\t},\n\tremoveAttribute : function(name){\n\t\tvar attr = this.getAttributeNode(name)\n\t\tattr && this.removeAttributeNode(attr);\n\t},\n\n\t//four real opeartion method\n\tappendChild:function(newChild){\n\t\tif(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){\n\t\t\treturn this.insertBefore(newChild,null);\n\t\t}else{\n\t\t\treturn _appendSingleChild(this,newChild);\n\t\t}\n\t},\n\tsetAttributeNode : function(newAttr){\n\t\treturn this.attributes.setNamedItem(newAttr);\n\t},\n\tsetAttributeNodeNS : function(newAttr){\n\t\treturn this.attributes.setNamedItemNS(newAttr);\n\t},\n\tremoveAttributeNode : function(oldAttr){\n\t\t//console.log(this == oldAttr.ownerElement)\n\t\treturn this.attributes.removeNamedItem(oldAttr.nodeName);\n\t},\n\t//get real attribute name,and remove it by removeAttributeNode\n\tremoveAttributeNS : function(namespaceURI, localName){\n\t\tvar old = this.getAttributeNodeNS(namespaceURI, localName);\n\t\told && this.removeAttributeNode(old);\n\t},\n\n\thasAttributeNS : function(namespaceURI, localName){\n\t\treturn this.getAttributeNodeNS(namespaceURI, localName)!=null;\n\t},\n\tgetAttributeNS : function(namespaceURI, localName){\n\t\tvar attr = this.getAttributeNodeNS(namespaceURI, localName);\n\t\treturn attr && attr.value || '';\n\t},\n\tsetAttributeNS : function(namespaceURI, qualifiedName, value){\n\t\tvar attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);\n\t\tattr.value = attr.nodeValue = \"\" + value;\n\t\tthis.setAttributeNode(attr)\n\t},\n\tgetAttributeNodeNS : function(namespaceURI, localName){\n\t\treturn this.attributes.getNamedItemNS(namespaceURI, localName);\n\t},\n\n\tgetElementsByTagName : function(tagName){\n\t\treturn new LiveNodeList(this,function(base){\n\t\t\tvar ls = [];\n\t\t\t_visitNode(base,function(node){\n\t\t\t\tif(node !== base && node.nodeType == ELEMENT_NODE && (tagName === '*' || node.tagName == tagName)){\n\t\t\t\t\tls.push(node);\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn ls;\n\t\t});\n\t},\n\tgetElementsByTagNameNS : function(namespaceURI, localName){\n\t\treturn new LiveNodeList(this,function(base){\n\t\t\tvar ls = [];\n\t\t\t_visitNode(base,function(node){\n\t\t\t\tif(node !== base && node.nodeType === ELEMENT_NODE && (namespaceURI === '*' || node.namespaceURI === namespaceURI) && (localName === '*' || node.localName == localName)){\n\t\t\t\t\tls.push(node);\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn ls;\n\n\t\t});\n\t}\n};\nDocument.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;\nDocument.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;\n\n\n_extends(Element,Node);\nfunction Attr() {\n};\nAttr.prototype.nodeType = ATTRIBUTE_NODE;\n_extends(Attr,Node);\n\n\nfunction CharacterData() {\n};\nCharacterData.prototype = {\n\tdata : '',\n\tsubstringData : function(offset, count) {\n\t\treturn this.data.substring(offset, offset+count);\n\t},\n\tappendData: function(text) {\n\t\ttext = this.data+text;\n\t\tthis.nodeValue = this.data = text;\n\t\tthis.length = text.length;\n\t},\n\tinsertData: function(offset,text) {\n\t\tthis.replaceData(offset,0,text);\n\n\t},\n\tappendChild:function(newChild){\n\t\tthrow new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR])\n\t},\n\tdeleteData: function(offset, count) {\n\t\tthis.replaceData(offset,count,\"\");\n\t},\n\treplaceData: function(offset, count, text) {\n\t\tvar start = this.data.substring(0,offset);\n\t\tvar end = this.data.substring(offset+count);\n\t\ttext = start + text + end;\n\t\tthis.nodeValue = this.data = text;\n\t\tthis.length = text.length;\n\t}\n}\n_extends(CharacterData,Node);\nfunction Text() {\n};\nText.prototype = {\n\tnodeName : \"#text\",\n\tnodeType : TEXT_NODE,\n\tsplitText : function(offset) {\n\t\tvar text = this.data;\n\t\tvar newText = text.substring(offset);\n\t\ttext = text.substring(0, offset);\n\t\tthis.data = this.nodeValue = text;\n\t\tthis.length = text.length;\n\t\tvar newNode = this.ownerDocument.createTextNode(newText);\n\t\tif(this.parentNode){\n\t\t\tthis.parentNode.insertBefore(newNode, this.nextSibling);\n\t\t}\n\t\treturn newNode;\n\t}\n}\n_extends(Text,CharacterData);\nfunction Comment() {\n};\nComment.prototype = {\n\tnodeName : \"#comment\",\n\tnodeType : COMMENT_NODE\n}\n_extends(Comment,CharacterData);\n\nfunction CDATASection() {\n};\nCDATASection.prototype = {\n\tnodeName : \"#cdata-section\",\n\tnodeType : CDATA_SECTION_NODE\n}\n_extends(CDATASection,CharacterData);\n\n\nfunction DocumentType() {\n};\nDocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;\n_extends(DocumentType,Node);\n\nfunction Notation() {\n};\nNotation.prototype.nodeType = NOTATION_NODE;\n_extends(Notation,Node);\n\nfunction Entity() {\n};\nEntity.prototype.nodeType = ENTITY_NODE;\n_extends(Entity,Node);\n\nfunction EntityReference() {\n};\nEntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;\n_extends(EntityReference,Node);\n\nfunction DocumentFragment() {\n};\nDocumentFragment.prototype.nodeName =\t\"#document-fragment\";\nDocumentFragment.prototype.nodeType =\tDOCUMENT_FRAGMENT_NODE;\n_extends(DocumentFragment,Node);\n\n\nfunction ProcessingInstruction() {\n}\nProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;\n_extends(ProcessingInstruction,Node);\nfunction XMLSerializer(){}\nXMLSerializer.prototype.serializeToString = function(node,isHtml,nodeFilter){\n\treturn nodeSerializeToString.call(node,isHtml,nodeFilter);\n}\nNode.prototype.toString = nodeSerializeToString;\nfunction nodeSerializeToString(isHtml,nodeFilter){\n\tvar buf = [];\n\tvar refNode = this.nodeType == 9 && this.documentElement || this;\n\tvar prefix = refNode.prefix;\n\tvar uri = refNode.namespaceURI;\n\n\tif(uri && prefix == null){\n\t\t//console.log(prefix)\n\t\tvar prefix = refNode.lookupPrefix(uri);\n\t\tif(prefix == null){\n\t\t\t//isHTML = true;\n\t\t\tvar visibleNamespaces=[\n\t\t\t{namespace:uri,prefix:null}\n\t\t\t//{namespace:uri,prefix:''}\n\t\t\t]\n\t\t}\n\t}\n\tserializeToString(this,buf,isHtml,nodeFilter,visibleNamespaces);\n\t//console.log('###',this.nodeType,uri,prefix,buf.join(''))\n\treturn buf.join('');\n}\n\nfunction needNamespaceDefine(node, isHTML, visibleNamespaces) {\n\tvar prefix = node.prefix || '';\n\tvar uri = node.namespaceURI;\n\t// According to [Namespaces in XML 1.0](https://www.w3.org/TR/REC-xml-names/#ns-using) ,\n\t// and more specifically https://www.w3.org/TR/REC-xml-names/#nsc-NoPrefixUndecl :\n\t// > In a namespace declaration for a prefix [...], the attribute value MUST NOT be empty.\n\t// in a similar manner [Namespaces in XML 1.1](https://www.w3.org/TR/xml-names11/#ns-using)\n\t// and more specifically https://www.w3.org/TR/xml-names11/#nsc-NSDeclared :\n\t// > [...] Furthermore, the attribute value [...] must not be an empty string.\n\t// so serializing empty namespace value like xmlns:ds=\"\" would produce an invalid XML document.\n\tif (!uri) {\n\t\treturn false;\n\t}\n\tif (prefix === \"xml\" && uri === NAMESPACE.XML || uri === NAMESPACE.XMLNS) {\n\t\treturn false;\n\t}\n\n\tvar i = visibleNamespaces.length\n\twhile (i--) {\n\t\tvar ns = visibleNamespaces[i];\n\t\t// get namespace prefix\n\t\tif (ns.prefix === prefix) {\n\t\t\treturn ns.namespace !== uri;\n\t\t}\n\t}\n\treturn true;\n}\n/**\n * Well-formed constraint: No < in Attribute Values\n * The replacement text of any entity referred to directly or indirectly in an attribute value must not contain a <.\n * @see https://www.w3.org/TR/xml/#CleanAttrVals\n * @see https://www.w3.org/TR/xml/#NT-AttValue\n */\nfunction addSerializedAttribute(buf, qualifiedName, value) {\n\tbuf.push(' ', qualifiedName, '=\"', value.replace(/[<&\"]/g,_xmlEncoder), '\"')\n}\n\nfunction serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){\n\tif (!visibleNamespaces) {\n\t\tvisibleNamespaces = [];\n\t}\n\n\tif(nodeFilter){\n\t\tnode = nodeFilter(node);\n\t\tif(node){\n\t\t\tif(typeof node == 'string'){\n\t\t\t\tbuf.push(node);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}else{\n\t\t\treturn;\n\t\t}\n\t\t//buf.sort.apply(attrs, attributeSorter);\n\t}\n\n\tswitch(node.nodeType){\n\tcase ELEMENT_NODE:\n\t\tvar attrs = node.attributes;\n\t\tvar len = attrs.length;\n\t\tvar child = node.firstChild;\n\t\tvar nodeName = node.tagName;\n\n\t\tisHTML = NAMESPACE.isHTML(node.namespaceURI) || isHTML\n\n\t\tvar prefixedNodeName = nodeName\n\t\tif (!isHTML && !node.prefix && node.namespaceURI) {\n\t\t\tvar defaultNS\n\t\t\t// lookup current default ns from `xmlns` attribute\n\t\t\tfor (var ai = 0; ai < attrs.length; ai++) {\n\t\t\t\tif (attrs.item(ai).name === 'xmlns') {\n\t\t\t\t\tdefaultNS = attrs.item(ai).value\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!defaultNS) {\n\t\t\t\t// lookup current default ns in visibleNamespaces\n\t\t\t\tfor (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {\n\t\t\t\t\tvar namespace = visibleNamespaces[nsi]\n\t\t\t\t\tif (namespace.prefix === '' && namespace.namespace === node.namespaceURI) {\n\t\t\t\t\t\tdefaultNS = namespace.namespace\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (defaultNS !== node.namespaceURI) {\n\t\t\t\tfor (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {\n\t\t\t\t\tvar namespace = visibleNamespaces[nsi]\n\t\t\t\t\tif (namespace.namespace === node.namespaceURI) {\n\t\t\t\t\t\tif (namespace.prefix) {\n\t\t\t\t\t\t\tprefixedNodeName = namespace.prefix + ':' + nodeName\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tbuf.push('<', prefixedNodeName);\n\n\t\tfor(var i=0;i');\n\t\t\t//if is cdata child node\n\t\t\tif(isHTML && /^script$/i.test(nodeName)){\n\t\t\t\twhile(child){\n\t\t\t\t\tif(child.data){\n\t\t\t\t\t\tbuf.push(child.data);\n\t\t\t\t\t}else{\n\t\t\t\t\t\tserializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());\n\t\t\t\t\t}\n\t\t\t\t\tchild = child.nextSibling;\n\t\t\t\t}\n\t\t\t}else\n\t\t\t{\n\t\t\t\twhile(child){\n\t\t\t\t\tserializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());\n\t\t\t\t\tchild = child.nextSibling;\n\t\t\t\t}\n\t\t\t}\n\t\t\tbuf.push('',prefixedNodeName,'>');\n\t\t}else{\n\t\t\tbuf.push('/>');\n\t\t}\n\t\t// remove added visible namespaces\n\t\t//visibleNamespaces.length = startVisibleNamespaces;\n\t\treturn;\n\tcase DOCUMENT_NODE:\n\tcase DOCUMENT_FRAGMENT_NODE:\n\t\tvar child = node.firstChild;\n\t\twhile(child){\n\t\t\tserializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());\n\t\t\tchild = child.nextSibling;\n\t\t}\n\t\treturn;\n\tcase ATTRIBUTE_NODE:\n\t\treturn addSerializedAttribute(buf, node.name, node.value);\n\tcase TEXT_NODE:\n\t\t/**\n\t\t * The ampersand character (&) and the left angle bracket (<) must not appear in their literal form,\n\t\t * except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section.\n\t\t * If they are needed elsewhere, they must be escaped using either numeric character references or the strings\n\t\t * `&` and `<` respectively.\n\t\t * The right angle bracket (>) may be represented using the string \" > \", and must, for compatibility,\n\t\t * be escaped using either `>` or a character reference when it appears in the string `]]>` in content,\n\t\t * when that string is not marking the end of a CDATA section.\n\t\t *\n\t\t * In the content of elements, character data is any string of characters\n\t\t * which does not contain the start-delimiter of any markup\n\t\t * and does not include the CDATA-section-close delimiter, `]]>`.\n\t\t *\n\t\t * @see https://www.w3.org/TR/xml/#NT-CharData\n\t\t */\n\t\treturn buf.push(node.data\n\t\t\t.replace(/[<&]/g,_xmlEncoder)\n\t\t\t.replace(/]]>/g, ']]>')\n\t\t);\n\tcase CDATA_SECTION_NODE:\n\t\treturn buf.push( '');\n\tcase COMMENT_NODE:\n\t\treturn buf.push( \"\");\n\tcase DOCUMENT_TYPE_NODE:\n\t\tvar pubid = node.publicId;\n\t\tvar sysid = node.systemId;\n\t\tbuf.push('');\n\t\t}else if(sysid && sysid!='.'){\n\t\t\tbuf.push(' SYSTEM ', sysid, '>');\n\t\t}else{\n\t\t\tvar sub = node.internalSubset;\n\t\t\tif(sub){\n\t\t\t\tbuf.push(\" [\",sub,\"]\");\n\t\t\t}\n\t\t\tbuf.push(\">\");\n\t\t}\n\t\treturn;\n\tcase PROCESSING_INSTRUCTION_NODE:\n\t\treturn buf.push( \"\",node.target,\" \",node.data,\"?>\");\n\tcase ENTITY_REFERENCE_NODE:\n\t\treturn buf.push( '&',node.nodeName,';');\n\t//case ENTITY_NODE:\n\t//case NOTATION_NODE:\n\tdefault:\n\t\tbuf.push('??',node.nodeName);\n\t}\n}\nfunction importNode(doc,node,deep){\n\tvar node2;\n\tswitch (node.nodeType) {\n\tcase ELEMENT_NODE:\n\t\tnode2 = node.cloneNode(false);\n\t\tnode2.ownerDocument = doc;\n\t\t//var attrs = node2.attributes;\n\t\t//var len = attrs.length;\n\t\t//for(var i=0;i',\n\tlt: '<',\n\tquot: '\"',\n});\n\n/**\n * A map of all entities that are detected in an HTML document.\n * They contain all entries from `XML_ENTITIES`.\n *\n * @see XML_ENTITIES\n * @see DOMParser.parseFromString\n * @see DOMImplementation.prototype.createHTMLDocument\n * @see https://html.spec.whatwg.org/#named-character-references WHATWG HTML(5) Spec\n * @see https://html.spec.whatwg.org/entities.json JSON\n * @see https://www.w3.org/TR/xml-entity-names/ W3C XML Entity Names\n * @see https://www.w3.org/TR/html4/sgml/entities.html W3C HTML4/SGML\n * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entity_references_in_HTML Wikipedia (HTML)\n * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Entities_representing_special_characters_in_XHTML Wikpedia (XHTML)\n */\nexports.HTML_ENTITIES = freeze({\n\tAacute: '\\u00C1',\n\taacute: '\\u00E1',\n\tAbreve: '\\u0102',\n\tabreve: '\\u0103',\n\tac: '\\u223E',\n\tacd: '\\u223F',\n\tacE: '\\u223E\\u0333',\n\tAcirc: '\\u00C2',\n\tacirc: '\\u00E2',\n\tacute: '\\u00B4',\n\tAcy: '\\u0410',\n\tacy: '\\u0430',\n\tAElig: '\\u00C6',\n\taelig: '\\u00E6',\n\taf: '\\u2061',\n\tAfr: '\\uD835\\uDD04',\n\tafr: '\\uD835\\uDD1E',\n\tAgrave: '\\u00C0',\n\tagrave: '\\u00E0',\n\talefsym: '\\u2135',\n\taleph: '\\u2135',\n\tAlpha: '\\u0391',\n\talpha: '\\u03B1',\n\tAmacr: '\\u0100',\n\tamacr: '\\u0101',\n\tamalg: '\\u2A3F',\n\tAMP: '\\u0026',\n\tamp: '\\u0026',\n\tAnd: '\\u2A53',\n\tand: '\\u2227',\n\tandand: '\\u2A55',\n\tandd: '\\u2A5C',\n\tandslope: '\\u2A58',\n\tandv: '\\u2A5A',\n\tang: '\\u2220',\n\tange: '\\u29A4',\n\tangle: '\\u2220',\n\tangmsd: '\\u2221',\n\tangmsdaa: '\\u29A8',\n\tangmsdab: '\\u29A9',\n\tangmsdac: '\\u29AA',\n\tangmsdad: '\\u29AB',\n\tangmsdae: '\\u29AC',\n\tangmsdaf: '\\u29AD',\n\tangmsdag: '\\u29AE',\n\tangmsdah: '\\u29AF',\n\tangrt: '\\u221F',\n\tangrtvb: '\\u22BE',\n\tangrtvbd: '\\u299D',\n\tangsph: '\\u2222',\n\tangst: '\\u00C5',\n\tangzarr: '\\u237C',\n\tAogon: '\\u0104',\n\taogon: '\\u0105',\n\tAopf: '\\uD835\\uDD38',\n\taopf: '\\uD835\\uDD52',\n\tap: '\\u2248',\n\tapacir: '\\u2A6F',\n\tapE: '\\u2A70',\n\tape: '\\u224A',\n\tapid: '\\u224B',\n\tapos: '\\u0027',\n\tApplyFunction: '\\u2061',\n\tapprox: '\\u2248',\n\tapproxeq: '\\u224A',\n\tAring: '\\u00C5',\n\taring: '\\u00E5',\n\tAscr: '\\uD835\\uDC9C',\n\tascr: '\\uD835\\uDCB6',\n\tAssign: '\\u2254',\n\tast: '\\u002A',\n\tasymp: '\\u2248',\n\tasympeq: '\\u224D',\n\tAtilde: '\\u00C3',\n\tatilde: '\\u00E3',\n\tAuml: '\\u00C4',\n\tauml: '\\u00E4',\n\tawconint: '\\u2233',\n\tawint: '\\u2A11',\n\tbackcong: '\\u224C',\n\tbackepsilon: '\\u03F6',\n\tbackprime: '\\u2035',\n\tbacksim: '\\u223D',\n\tbacksimeq: '\\u22CD',\n\tBackslash: '\\u2216',\n\tBarv: '\\u2AE7',\n\tbarvee: '\\u22BD',\n\tBarwed: '\\u2306',\n\tbarwed: '\\u2305',\n\tbarwedge: '\\u2305',\n\tbbrk: '\\u23B5',\n\tbbrktbrk: '\\u23B6',\n\tbcong: '\\u224C',\n\tBcy: '\\u0411',\n\tbcy: '\\u0431',\n\tbdquo: '\\u201E',\n\tbecaus: '\\u2235',\n\tBecause: '\\u2235',\n\tbecause: '\\u2235',\n\tbemptyv: '\\u29B0',\n\tbepsi: '\\u03F6',\n\tbernou: '\\u212C',\n\tBernoullis: '\\u212C',\n\tBeta: '\\u0392',\n\tbeta: '\\u03B2',\n\tbeth: '\\u2136',\n\tbetween: '\\u226C',\n\tBfr: '\\uD835\\uDD05',\n\tbfr: '\\uD835\\uDD1F',\n\tbigcap: '\\u22C2',\n\tbigcirc: '\\u25EF',\n\tbigcup: '\\u22C3',\n\tbigodot: '\\u2A00',\n\tbigoplus: '\\u2A01',\n\tbigotimes: '\\u2A02',\n\tbigsqcup: '\\u2A06',\n\tbigstar: '\\u2605',\n\tbigtriangledown: '\\u25BD',\n\tbigtriangleup: '\\u25B3',\n\tbiguplus: '\\u2A04',\n\tbigvee: '\\u22C1',\n\tbigwedge: '\\u22C0',\n\tbkarow: '\\u290D',\n\tblacklozenge: '\\u29EB',\n\tblacksquare: '\\u25AA',\n\tblacktriangle: '\\u25B4',\n\tblacktriangledown: '\\u25BE',\n\tblacktriangleleft: '\\u25C2',\n\tblacktriangleright: '\\u25B8',\n\tblank: '\\u2423',\n\tblk12: '\\u2592',\n\tblk14: '\\u2591',\n\tblk34: '\\u2593',\n\tblock: '\\u2588',\n\tbne: '\\u003D\\u20E5',\n\tbnequiv: '\\u2261\\u20E5',\n\tbNot: '\\u2AED',\n\tbnot: '\\u2310',\n\tBopf: '\\uD835\\uDD39',\n\tbopf: '\\uD835\\uDD53',\n\tbot: '\\u22A5',\n\tbottom: '\\u22A5',\n\tbowtie: '\\u22C8',\n\tboxbox: '\\u29C9',\n\tboxDL: '\\u2557',\n\tboxDl: '\\u2556',\n\tboxdL: '\\u2555',\n\tboxdl: '\\u2510',\n\tboxDR: '\\u2554',\n\tboxDr: '\\u2553',\n\tboxdR: '\\u2552',\n\tboxdr: '\\u250C',\n\tboxH: '\\u2550',\n\tboxh: '\\u2500',\n\tboxHD: '\\u2566',\n\tboxHd: '\\u2564',\n\tboxhD: '\\u2565',\n\tboxhd: '\\u252C',\n\tboxHU: '\\u2569',\n\tboxHu: '\\u2567',\n\tboxhU: '\\u2568',\n\tboxhu: '\\u2534',\n\tboxminus: '\\u229F',\n\tboxplus: '\\u229E',\n\tboxtimes: '\\u22A0',\n\tboxUL: '\\u255D',\n\tboxUl: '\\u255C',\n\tboxuL: '\\u255B',\n\tboxul: '\\u2518',\n\tboxUR: '\\u255A',\n\tboxUr: '\\u2559',\n\tboxuR: '\\u2558',\n\tboxur: '\\u2514',\n\tboxV: '\\u2551',\n\tboxv: '\\u2502',\n\tboxVH: '\\u256C',\n\tboxVh: '\\u256B',\n\tboxvH: '\\u256A',\n\tboxvh: '\\u253C',\n\tboxVL: '\\u2563',\n\tboxVl: '\\u2562',\n\tboxvL: '\\u2561',\n\tboxvl: '\\u2524',\n\tboxVR: '\\u2560',\n\tboxVr: '\\u255F',\n\tboxvR: '\\u255E',\n\tboxvr: '\\u251C',\n\tbprime: '\\u2035',\n\tBreve: '\\u02D8',\n\tbreve: '\\u02D8',\n\tbrvbar: '\\u00A6',\n\tBscr: '\\u212C',\n\tbscr: '\\uD835\\uDCB7',\n\tbsemi: '\\u204F',\n\tbsim: '\\u223D',\n\tbsime: '\\u22CD',\n\tbsol: '\\u005C',\n\tbsolb: '\\u29C5',\n\tbsolhsub: '\\u27C8',\n\tbull: '\\u2022',\n\tbullet: '\\u2022',\n\tbump: '\\u224E',\n\tbumpE: '\\u2AAE',\n\tbumpe: '\\u224F',\n\tBumpeq: '\\u224E',\n\tbumpeq: '\\u224F',\n\tCacute: '\\u0106',\n\tcacute: '\\u0107',\n\tCap: '\\u22D2',\n\tcap: '\\u2229',\n\tcapand: '\\u2A44',\n\tcapbrcup: '\\u2A49',\n\tcapcap: '\\u2A4B',\n\tcapcup: '\\u2A47',\n\tcapdot: '\\u2A40',\n\tCapitalDifferentialD: '\\u2145',\n\tcaps: '\\u2229\\uFE00',\n\tcaret: '\\u2041',\n\tcaron: '\\u02C7',\n\tCayleys: '\\u212D',\n\tccaps: '\\u2A4D',\n\tCcaron: '\\u010C',\n\tccaron: '\\u010D',\n\tCcedil: '\\u00C7',\n\tccedil: '\\u00E7',\n\tCcirc: '\\u0108',\n\tccirc: '\\u0109',\n\tCconint: '\\u2230',\n\tccups: '\\u2A4C',\n\tccupssm: '\\u2A50',\n\tCdot: '\\u010A',\n\tcdot: '\\u010B',\n\tcedil: '\\u00B8',\n\tCedilla: '\\u00B8',\n\tcemptyv: '\\u29B2',\n\tcent: '\\u00A2',\n\tCenterDot: '\\u00B7',\n\tcenterdot: '\\u00B7',\n\tCfr: '\\u212D',\n\tcfr: '\\uD835\\uDD20',\n\tCHcy: '\\u0427',\n\tchcy: '\\u0447',\n\tcheck: '\\u2713',\n\tcheckmark: '\\u2713',\n\tChi: '\\u03A7',\n\tchi: '\\u03C7',\n\tcir: '\\u25CB',\n\tcirc: '\\u02C6',\n\tcirceq: '\\u2257',\n\tcirclearrowleft: '\\u21BA',\n\tcirclearrowright: '\\u21BB',\n\tcircledast: '\\u229B',\n\tcircledcirc: '\\u229A',\n\tcircleddash: '\\u229D',\n\tCircleDot: '\\u2299',\n\tcircledR: '\\u00AE',\n\tcircledS: '\\u24C8',\n\tCircleMinus: '\\u2296',\n\tCirclePlus: '\\u2295',\n\tCircleTimes: '\\u2297',\n\tcirE: '\\u29C3',\n\tcire: '\\u2257',\n\tcirfnint: '\\u2A10',\n\tcirmid: '\\u2AEF',\n\tcirscir: '\\u29C2',\n\tClockwiseContourIntegral: '\\u2232',\n\tCloseCurlyDoubleQuote: '\\u201D',\n\tCloseCurlyQuote: '\\u2019',\n\tclubs: '\\u2663',\n\tclubsuit: '\\u2663',\n\tColon: '\\u2237',\n\tcolon: '\\u003A',\n\tColone: '\\u2A74',\n\tcolone: '\\u2254',\n\tcoloneq: '\\u2254',\n\tcomma: '\\u002C',\n\tcommat: '\\u0040',\n\tcomp: '\\u2201',\n\tcompfn: '\\u2218',\n\tcomplement: '\\u2201',\n\tcomplexes: '\\u2102',\n\tcong: '\\u2245',\n\tcongdot: '\\u2A6D',\n\tCongruent: '\\u2261',\n\tConint: '\\u222F',\n\tconint: '\\u222E',\n\tContourIntegral: '\\u222E',\n\tCopf: '\\u2102',\n\tcopf: '\\uD835\\uDD54',\n\tcoprod: '\\u2210',\n\tCoproduct: '\\u2210',\n\tCOPY: '\\u00A9',\n\tcopy: '\\u00A9',\n\tcopysr: '\\u2117',\n\tCounterClockwiseContourIntegral: '\\u2233',\n\tcrarr: '\\u21B5',\n\tCross: '\\u2A2F',\n\tcross: '\\u2717',\n\tCscr: '\\uD835\\uDC9E',\n\tcscr: '\\uD835\\uDCB8',\n\tcsub: '\\u2ACF',\n\tcsube: '\\u2AD1',\n\tcsup: '\\u2AD0',\n\tcsupe: '\\u2AD2',\n\tctdot: '\\u22EF',\n\tcudarrl: '\\u2938',\n\tcudarrr: '\\u2935',\n\tcuepr: '\\u22DE',\n\tcuesc: '\\u22DF',\n\tcularr: '\\u21B6',\n\tcularrp: '\\u293D',\n\tCup: '\\u22D3',\n\tcup: '\\u222A',\n\tcupbrcap: '\\u2A48',\n\tCupCap: '\\u224D',\n\tcupcap: '\\u2A46',\n\tcupcup: '\\u2A4A',\n\tcupdot: '\\u228D',\n\tcupor: '\\u2A45',\n\tcups: '\\u222A\\uFE00',\n\tcurarr: '\\u21B7',\n\tcurarrm: '\\u293C',\n\tcurlyeqprec: '\\u22DE',\n\tcurlyeqsucc: '\\u22DF',\n\tcurlyvee: '\\u22CE',\n\tcurlywedge: '\\u22CF',\n\tcurren: '\\u00A4',\n\tcurvearrowleft: '\\u21B6',\n\tcurvearrowright: '\\u21B7',\n\tcuvee: '\\u22CE',\n\tcuwed: '\\u22CF',\n\tcwconint: '\\u2232',\n\tcwint: '\\u2231',\n\tcylcty: '\\u232D',\n\tDagger: '\\u2021',\n\tdagger: '\\u2020',\n\tdaleth: '\\u2138',\n\tDarr: '\\u21A1',\n\tdArr: '\\u21D3',\n\tdarr: '\\u2193',\n\tdash: '\\u2010',\n\tDashv: '\\u2AE4',\n\tdashv: '\\u22A3',\n\tdbkarow: '\\u290F',\n\tdblac: '\\u02DD',\n\tDcaron: '\\u010E',\n\tdcaron: '\\u010F',\n\tDcy: '\\u0414',\n\tdcy: '\\u0434',\n\tDD: '\\u2145',\n\tdd: '\\u2146',\n\tddagger: '\\u2021',\n\tddarr: '\\u21CA',\n\tDDotrahd: '\\u2911',\n\tddotseq: '\\u2A77',\n\tdeg: '\\u00B0',\n\tDel: '\\u2207',\n\tDelta: '\\u0394',\n\tdelta: '\\u03B4',\n\tdemptyv: '\\u29B1',\n\tdfisht: '\\u297F',\n\tDfr: '\\uD835\\uDD07',\n\tdfr: '\\uD835\\uDD21',\n\tdHar: '\\u2965',\n\tdharl: '\\u21C3',\n\tdharr: '\\u21C2',\n\tDiacriticalAcute: '\\u00B4',\n\tDiacriticalDot: '\\u02D9',\n\tDiacriticalDoubleAcute: '\\u02DD',\n\tDiacriticalGrave: '\\u0060',\n\tDiacriticalTilde: '\\u02DC',\n\tdiam: '\\u22C4',\n\tDiamond: '\\u22C4',\n\tdiamond: '\\u22C4',\n\tdiamondsuit: '\\u2666',\n\tdiams: '\\u2666',\n\tdie: '\\u00A8',\n\tDifferentialD: '\\u2146',\n\tdigamma: '\\u03DD',\n\tdisin: '\\u22F2',\n\tdiv: '\\u00F7',\n\tdivide: '\\u00F7',\n\tdivideontimes: '\\u22C7',\n\tdivonx: '\\u22C7',\n\tDJcy: '\\u0402',\n\tdjcy: '\\u0452',\n\tdlcorn: '\\u231E',\n\tdlcrop: '\\u230D',\n\tdollar: '\\u0024',\n\tDopf: '\\uD835\\uDD3B',\n\tdopf: '\\uD835\\uDD55',\n\tDot: '\\u00A8',\n\tdot: '\\u02D9',\n\tDotDot: '\\u20DC',\n\tdoteq: '\\u2250',\n\tdoteqdot: '\\u2251',\n\tDotEqual: '\\u2250',\n\tdotminus: '\\u2238',\n\tdotplus: '\\u2214',\n\tdotsquare: '\\u22A1',\n\tdoublebarwedge: '\\u2306',\n\tDoubleContourIntegral: '\\u222F',\n\tDoubleDot: '\\u00A8',\n\tDoubleDownArrow: '\\u21D3',\n\tDoubleLeftArrow: '\\u21D0',\n\tDoubleLeftRightArrow: '\\u21D4',\n\tDoubleLeftTee: '\\u2AE4',\n\tDoubleLongLeftArrow: '\\u27F8',\n\tDoubleLongLeftRightArrow: '\\u27FA',\n\tDoubleLongRightArrow: '\\u27F9',\n\tDoubleRightArrow: '\\u21D2',\n\tDoubleRightTee: '\\u22A8',\n\tDoubleUpArrow: '\\u21D1',\n\tDoubleUpDownArrow: '\\u21D5',\n\tDoubleVerticalBar: '\\u2225',\n\tDownArrow: '\\u2193',\n\tDownarrow: '\\u21D3',\n\tdownarrow: '\\u2193',\n\tDownArrowBar: '\\u2913',\n\tDownArrowUpArrow: '\\u21F5',\n\tDownBreve: '\\u0311',\n\tdowndownarrows: '\\u21CA',\n\tdownharpoonleft: '\\u21C3',\n\tdownharpoonright: '\\u21C2',\n\tDownLeftRightVector: '\\u2950',\n\tDownLeftTeeVector: '\\u295E',\n\tDownLeftVector: '\\u21BD',\n\tDownLeftVectorBar: '\\u2956',\n\tDownRightTeeVector: '\\u295F',\n\tDownRightVector: '\\u21C1',\n\tDownRightVectorBar: '\\u2957',\n\tDownTee: '\\u22A4',\n\tDownTeeArrow: '\\u21A7',\n\tdrbkarow: '\\u2910',\n\tdrcorn: '\\u231F',\n\tdrcrop: '\\u230C',\n\tDscr: '\\uD835\\uDC9F',\n\tdscr: '\\uD835\\uDCB9',\n\tDScy: '\\u0405',\n\tdscy: '\\u0455',\n\tdsol: '\\u29F6',\n\tDstrok: '\\u0110',\n\tdstrok: '\\u0111',\n\tdtdot: '\\u22F1',\n\tdtri: '\\u25BF',\n\tdtrif: '\\u25BE',\n\tduarr: '\\u21F5',\n\tduhar: '\\u296F',\n\tdwangle: '\\u29A6',\n\tDZcy: '\\u040F',\n\tdzcy: '\\u045F',\n\tdzigrarr: '\\u27FF',\n\tEacute: '\\u00C9',\n\teacute: '\\u00E9',\n\teaster: '\\u2A6E',\n\tEcaron: '\\u011A',\n\tecaron: '\\u011B',\n\tecir: '\\u2256',\n\tEcirc: '\\u00CA',\n\tecirc: '\\u00EA',\n\tecolon: '\\u2255',\n\tEcy: '\\u042D',\n\tecy: '\\u044D',\n\teDDot: '\\u2A77',\n\tEdot: '\\u0116',\n\teDot: '\\u2251',\n\tedot: '\\u0117',\n\tee: '\\u2147',\n\tefDot: '\\u2252',\n\tEfr: '\\uD835\\uDD08',\n\tefr: '\\uD835\\uDD22',\n\teg: '\\u2A9A',\n\tEgrave: '\\u00C8',\n\tegrave: '\\u00E8',\n\tegs: '\\u2A96',\n\tegsdot: '\\u2A98',\n\tel: '\\u2A99',\n\tElement: '\\u2208',\n\telinters: '\\u23E7',\n\tell: '\\u2113',\n\tels: '\\u2A95',\n\telsdot: '\\u2A97',\n\tEmacr: '\\u0112',\n\temacr: '\\u0113',\n\tempty: '\\u2205',\n\temptyset: '\\u2205',\n\tEmptySmallSquare: '\\u25FB',\n\temptyv: '\\u2205',\n\tEmptyVerySmallSquare: '\\u25AB',\n\temsp: '\\u2003',\n\temsp13: '\\u2004',\n\temsp14: '\\u2005',\n\tENG: '\\u014A',\n\teng: '\\u014B',\n\tensp: '\\u2002',\n\tEogon: '\\u0118',\n\teogon: '\\u0119',\n\tEopf: '\\uD835\\uDD3C',\n\teopf: '\\uD835\\uDD56',\n\tepar: '\\u22D5',\n\teparsl: '\\u29E3',\n\teplus: '\\u2A71',\n\tepsi: '\\u03B5',\n\tEpsilon: '\\u0395',\n\tepsilon: '\\u03B5',\n\tepsiv: '\\u03F5',\n\teqcirc: '\\u2256',\n\teqcolon: '\\u2255',\n\teqsim: '\\u2242',\n\teqslantgtr: '\\u2A96',\n\teqslantless: '\\u2A95',\n\tEqual: '\\u2A75',\n\tequals: '\\u003D',\n\tEqualTilde: '\\u2242',\n\tequest: '\\u225F',\n\tEquilibrium: '\\u21CC',\n\tequiv: '\\u2261',\n\tequivDD: '\\u2A78',\n\teqvparsl: '\\u29E5',\n\terarr: '\\u2971',\n\terDot: '\\u2253',\n\tEscr: '\\u2130',\n\tescr: '\\u212F',\n\tesdot: '\\u2250',\n\tEsim: '\\u2A73',\n\tesim: '\\u2242',\n\tEta: '\\u0397',\n\teta: '\\u03B7',\n\tETH: '\\u00D0',\n\teth: '\\u00F0',\n\tEuml: '\\u00CB',\n\teuml: '\\u00EB',\n\teuro: '\\u20AC',\n\texcl: '\\u0021',\n\texist: '\\u2203',\n\tExists: '\\u2203',\n\texpectation: '\\u2130',\n\tExponentialE: '\\u2147',\n\texponentiale: '\\u2147',\n\tfallingdotseq: '\\u2252',\n\tFcy: '\\u0424',\n\tfcy: '\\u0444',\n\tfemale: '\\u2640',\n\tffilig: '\\uFB03',\n\tfflig: '\\uFB00',\n\tffllig: '\\uFB04',\n\tFfr: '\\uD835\\uDD09',\n\tffr: '\\uD835\\uDD23',\n\tfilig: '\\uFB01',\n\tFilledSmallSquare: '\\u25FC',\n\tFilledVerySmallSquare: '\\u25AA',\n\tfjlig: '\\u0066\\u006A',\n\tflat: '\\u266D',\n\tfllig: '\\uFB02',\n\tfltns: '\\u25B1',\n\tfnof: '\\u0192',\n\tFopf: '\\uD835\\uDD3D',\n\tfopf: '\\uD835\\uDD57',\n\tForAll: '\\u2200',\n\tforall: '\\u2200',\n\tfork: '\\u22D4',\n\tforkv: '\\u2AD9',\n\tFouriertrf: '\\u2131',\n\tfpartint: '\\u2A0D',\n\tfrac12: '\\u00BD',\n\tfrac13: '\\u2153',\n\tfrac14: '\\u00BC',\n\tfrac15: '\\u2155',\n\tfrac16: '\\u2159',\n\tfrac18: '\\u215B',\n\tfrac23: '\\u2154',\n\tfrac25: '\\u2156',\n\tfrac34: '\\u00BE',\n\tfrac35: '\\u2157',\n\tfrac38: '\\u215C',\n\tfrac45: '\\u2158',\n\tfrac56: '\\u215A',\n\tfrac58: '\\u215D',\n\tfrac78: '\\u215E',\n\tfrasl: '\\u2044',\n\tfrown: '\\u2322',\n\tFscr: '\\u2131',\n\tfscr: '\\uD835\\uDCBB',\n\tgacute: '\\u01F5',\n\tGamma: '\\u0393',\n\tgamma: '\\u03B3',\n\tGammad: '\\u03DC',\n\tgammad: '\\u03DD',\n\tgap: '\\u2A86',\n\tGbreve: '\\u011E',\n\tgbreve: '\\u011F',\n\tGcedil: '\\u0122',\n\tGcirc: '\\u011C',\n\tgcirc: '\\u011D',\n\tGcy: '\\u0413',\n\tgcy: '\\u0433',\n\tGdot: '\\u0120',\n\tgdot: '\\u0121',\n\tgE: '\\u2267',\n\tge: '\\u2265',\n\tgEl: '\\u2A8C',\n\tgel: '\\u22DB',\n\tgeq: '\\u2265',\n\tgeqq: '\\u2267',\n\tgeqslant: '\\u2A7E',\n\tges: '\\u2A7E',\n\tgescc: '\\u2AA9',\n\tgesdot: '\\u2A80',\n\tgesdoto: '\\u2A82',\n\tgesdotol: '\\u2A84',\n\tgesl: '\\u22DB\\uFE00',\n\tgesles: '\\u2A94',\n\tGfr: '\\uD835\\uDD0A',\n\tgfr: '\\uD835\\uDD24',\n\tGg: '\\u22D9',\n\tgg: '\\u226B',\n\tggg: '\\u22D9',\n\tgimel: '\\u2137',\n\tGJcy: '\\u0403',\n\tgjcy: '\\u0453',\n\tgl: '\\u2277',\n\tgla: '\\u2AA5',\n\tglE: '\\u2A92',\n\tglj: '\\u2AA4',\n\tgnap: '\\u2A8A',\n\tgnapprox: '\\u2A8A',\n\tgnE: '\\u2269',\n\tgne: '\\u2A88',\n\tgneq: '\\u2A88',\n\tgneqq: '\\u2269',\n\tgnsim: '\\u22E7',\n\tGopf: '\\uD835\\uDD3E',\n\tgopf: '\\uD835\\uDD58',\n\tgrave: '\\u0060',\n\tGreaterEqual: '\\u2265',\n\tGreaterEqualLess: '\\u22DB',\n\tGreaterFullEqual: '\\u2267',\n\tGreaterGreater: '\\u2AA2',\n\tGreaterLess: '\\u2277',\n\tGreaterSlantEqual: '\\u2A7E',\n\tGreaterTilde: '\\u2273',\n\tGscr: '\\uD835\\uDCA2',\n\tgscr: '\\u210A',\n\tgsim: '\\u2273',\n\tgsime: '\\u2A8E',\n\tgsiml: '\\u2A90',\n\tGt: '\\u226B',\n\tGT: '\\u003E',\n\tgt: '\\u003E',\n\tgtcc: '\\u2AA7',\n\tgtcir: '\\u2A7A',\n\tgtdot: '\\u22D7',\n\tgtlPar: '\\u2995',\n\tgtquest: '\\u2A7C',\n\tgtrapprox: '\\u2A86',\n\tgtrarr: '\\u2978',\n\tgtrdot: '\\u22D7',\n\tgtreqless: '\\u22DB',\n\tgtreqqless: '\\u2A8C',\n\tgtrless: '\\u2277',\n\tgtrsim: '\\u2273',\n\tgvertneqq: '\\u2269\\uFE00',\n\tgvnE: '\\u2269\\uFE00',\n\tHacek: '\\u02C7',\n\thairsp: '\\u200A',\n\thalf: '\\u00BD',\n\thamilt: '\\u210B',\n\tHARDcy: '\\u042A',\n\thardcy: '\\u044A',\n\thArr: '\\u21D4',\n\tharr: '\\u2194',\n\tharrcir: '\\u2948',\n\tharrw: '\\u21AD',\n\tHat: '\\u005E',\n\thbar: '\\u210F',\n\tHcirc: '\\u0124',\n\thcirc: '\\u0125',\n\thearts: '\\u2665',\n\theartsuit: '\\u2665',\n\thellip: '\\u2026',\n\thercon: '\\u22B9',\n\tHfr: '\\u210C',\n\thfr: '\\uD835\\uDD25',\n\tHilbertSpace: '\\u210B',\n\thksearow: '\\u2925',\n\thkswarow: '\\u2926',\n\thoarr: '\\u21FF',\n\thomtht: '\\u223B',\n\thookleftarrow: '\\u21A9',\n\thookrightarrow: '\\u21AA',\n\tHopf: '\\u210D',\n\thopf: '\\uD835\\uDD59',\n\thorbar: '\\u2015',\n\tHorizontalLine: '\\u2500',\n\tHscr: '\\u210B',\n\thscr: '\\uD835\\uDCBD',\n\thslash: '\\u210F',\n\tHstrok: '\\u0126',\n\thstrok: '\\u0127',\n\tHumpDownHump: '\\u224E',\n\tHumpEqual: '\\u224F',\n\thybull: '\\u2043',\n\thyphen: '\\u2010',\n\tIacute: '\\u00CD',\n\tiacute: '\\u00ED',\n\tic: '\\u2063',\n\tIcirc: '\\u00CE',\n\ticirc: '\\u00EE',\n\tIcy: '\\u0418',\n\ticy: '\\u0438',\n\tIdot: '\\u0130',\n\tIEcy: '\\u0415',\n\tiecy: '\\u0435',\n\tiexcl: '\\u00A1',\n\tiff: '\\u21D4',\n\tIfr: '\\u2111',\n\tifr: '\\uD835\\uDD26',\n\tIgrave: '\\u00CC',\n\tigrave: '\\u00EC',\n\tii: '\\u2148',\n\tiiiint: '\\u2A0C',\n\tiiint: '\\u222D',\n\tiinfin: '\\u29DC',\n\tiiota: '\\u2129',\n\tIJlig: '\\u0132',\n\tijlig: '\\u0133',\n\tIm: '\\u2111',\n\tImacr: '\\u012A',\n\timacr: '\\u012B',\n\timage: '\\u2111',\n\tImaginaryI: '\\u2148',\n\timagline: '\\u2110',\n\timagpart: '\\u2111',\n\timath: '\\u0131',\n\timof: '\\u22B7',\n\timped: '\\u01B5',\n\tImplies: '\\u21D2',\n\tin: '\\u2208',\n\tincare: '\\u2105',\n\tinfin: '\\u221E',\n\tinfintie: '\\u29DD',\n\tinodot: '\\u0131',\n\tInt: '\\u222C',\n\tint: '\\u222B',\n\tintcal: '\\u22BA',\n\tintegers: '\\u2124',\n\tIntegral: '\\u222B',\n\tintercal: '\\u22BA',\n\tIntersection: '\\u22C2',\n\tintlarhk: '\\u2A17',\n\tintprod: '\\u2A3C',\n\tInvisibleComma: '\\u2063',\n\tInvisibleTimes: '\\u2062',\n\tIOcy: '\\u0401',\n\tiocy: '\\u0451',\n\tIogon: '\\u012E',\n\tiogon: '\\u012F',\n\tIopf: '\\uD835\\uDD40',\n\tiopf: '\\uD835\\uDD5A',\n\tIota: '\\u0399',\n\tiota: '\\u03B9',\n\tiprod: '\\u2A3C',\n\tiquest: '\\u00BF',\n\tIscr: '\\u2110',\n\tiscr: '\\uD835\\uDCBE',\n\tisin: '\\u2208',\n\tisindot: '\\u22F5',\n\tisinE: '\\u22F9',\n\tisins: '\\u22F4',\n\tisinsv: '\\u22F3',\n\tisinv: '\\u2208',\n\tit: '\\u2062',\n\tItilde: '\\u0128',\n\titilde: '\\u0129',\n\tIukcy: '\\u0406',\n\tiukcy: '\\u0456',\n\tIuml: '\\u00CF',\n\tiuml: '\\u00EF',\n\tJcirc: '\\u0134',\n\tjcirc: '\\u0135',\n\tJcy: '\\u0419',\n\tjcy: '\\u0439',\n\tJfr: '\\uD835\\uDD0D',\n\tjfr: '\\uD835\\uDD27',\n\tjmath: '\\u0237',\n\tJopf: '\\uD835\\uDD41',\n\tjopf: '\\uD835\\uDD5B',\n\tJscr: '\\uD835\\uDCA5',\n\tjscr: '\\uD835\\uDCBF',\n\tJsercy: '\\u0408',\n\tjsercy: '\\u0458',\n\tJukcy: '\\u0404',\n\tjukcy: '\\u0454',\n\tKappa: '\\u039A',\n\tkappa: '\\u03BA',\n\tkappav: '\\u03F0',\n\tKcedil: '\\u0136',\n\tkcedil: '\\u0137',\n\tKcy: '\\u041A',\n\tkcy: '\\u043A',\n\tKfr: '\\uD835\\uDD0E',\n\tkfr: '\\uD835\\uDD28',\n\tkgreen: '\\u0138',\n\tKHcy: '\\u0425',\n\tkhcy: '\\u0445',\n\tKJcy: '\\u040C',\n\tkjcy: '\\u045C',\n\tKopf: '\\uD835\\uDD42',\n\tkopf: '\\uD835\\uDD5C',\n\tKscr: '\\uD835\\uDCA6',\n\tkscr: '\\uD835\\uDCC0',\n\tlAarr: '\\u21DA',\n\tLacute: '\\u0139',\n\tlacute: '\\u013A',\n\tlaemptyv: '\\u29B4',\n\tlagran: '\\u2112',\n\tLambda: '\\u039B',\n\tlambda: '\\u03BB',\n\tLang: '\\u27EA',\n\tlang: '\\u27E8',\n\tlangd: '\\u2991',\n\tlangle: '\\u27E8',\n\tlap: '\\u2A85',\n\tLaplacetrf: '\\u2112',\n\tlaquo: '\\u00AB',\n\tLarr: '\\u219E',\n\tlArr: '\\u21D0',\n\tlarr: '\\u2190',\n\tlarrb: '\\u21E4',\n\tlarrbfs: '\\u291F',\n\tlarrfs: '\\u291D',\n\tlarrhk: '\\u21A9',\n\tlarrlp: '\\u21AB',\n\tlarrpl: '\\u2939',\n\tlarrsim: '\\u2973',\n\tlarrtl: '\\u21A2',\n\tlat: '\\u2AAB',\n\tlAtail: '\\u291B',\n\tlatail: '\\u2919',\n\tlate: '\\u2AAD',\n\tlates: '\\u2AAD\\uFE00',\n\tlBarr: '\\u290E',\n\tlbarr: '\\u290C',\n\tlbbrk: '\\u2772',\n\tlbrace: '\\u007B',\n\tlbrack: '\\u005B',\n\tlbrke: '\\u298B',\n\tlbrksld: '\\u298F',\n\tlbrkslu: '\\u298D',\n\tLcaron: '\\u013D',\n\tlcaron: '\\u013E',\n\tLcedil: '\\u013B',\n\tlcedil: '\\u013C',\n\tlceil: '\\u2308',\n\tlcub: '\\u007B',\n\tLcy: '\\u041B',\n\tlcy: '\\u043B',\n\tldca: '\\u2936',\n\tldquo: '\\u201C',\n\tldquor: '\\u201E',\n\tldrdhar: '\\u2967',\n\tldrushar: '\\u294B',\n\tldsh: '\\u21B2',\n\tlE: '\\u2266',\n\tle: '\\u2264',\n\tLeftAngleBracket: '\\u27E8',\n\tLeftArrow: '\\u2190',\n\tLeftarrow: '\\u21D0',\n\tleftarrow: '\\u2190',\n\tLeftArrowBar: '\\u21E4',\n\tLeftArrowRightArrow: '\\u21C6',\n\tleftarrowtail: '\\u21A2',\n\tLeftCeiling: '\\u2308',\n\tLeftDoubleBracket: '\\u27E6',\n\tLeftDownTeeVector: '\\u2961',\n\tLeftDownVector: '\\u21C3',\n\tLeftDownVectorBar: '\\u2959',\n\tLeftFloor: '\\u230A',\n\tleftharpoondown: '\\u21BD',\n\tleftharpoonup: '\\u21BC',\n\tleftleftarrows: '\\u21C7',\n\tLeftRightArrow: '\\u2194',\n\tLeftrightarrow: '\\u21D4',\n\tleftrightarrow: '\\u2194',\n\tleftrightarrows: '\\u21C6',\n\tleftrightharpoons: '\\u21CB',\n\tleftrightsquigarrow: '\\u21AD',\n\tLeftRightVector: '\\u294E',\n\tLeftTee: '\\u22A3',\n\tLeftTeeArrow: '\\u21A4',\n\tLeftTeeVector: '\\u295A',\n\tleftthreetimes: '\\u22CB',\n\tLeftTriangle: '\\u22B2',\n\tLeftTriangleBar: '\\u29CF',\n\tLeftTriangleEqual: '\\u22B4',\n\tLeftUpDownVector: '\\u2951',\n\tLeftUpTeeVector: '\\u2960',\n\tLeftUpVector: '\\u21BF',\n\tLeftUpVectorBar: '\\u2958',\n\tLeftVector: '\\u21BC',\n\tLeftVectorBar: '\\u2952',\n\tlEg: '\\u2A8B',\n\tleg: '\\u22DA',\n\tleq: '\\u2264',\n\tleqq: '\\u2266',\n\tleqslant: '\\u2A7D',\n\tles: '\\u2A7D',\n\tlescc: '\\u2AA8',\n\tlesdot: '\\u2A7F',\n\tlesdoto: '\\u2A81',\n\tlesdotor: '\\u2A83',\n\tlesg: '\\u22DA\\uFE00',\n\tlesges: '\\u2A93',\n\tlessapprox: '\\u2A85',\n\tlessdot: '\\u22D6',\n\tlesseqgtr: '\\u22DA',\n\tlesseqqgtr: '\\u2A8B',\n\tLessEqualGreater: '\\u22DA',\n\tLessFullEqual: '\\u2266',\n\tLessGreater: '\\u2276',\n\tlessgtr: '\\u2276',\n\tLessLess: '\\u2AA1',\n\tlesssim: '\\u2272',\n\tLessSlantEqual: '\\u2A7D',\n\tLessTilde: '\\u2272',\n\tlfisht: '\\u297C',\n\tlfloor: '\\u230A',\n\tLfr: '\\uD835\\uDD0F',\n\tlfr: '\\uD835\\uDD29',\n\tlg: '\\u2276',\n\tlgE: '\\u2A91',\n\tlHar: '\\u2962',\n\tlhard: '\\u21BD',\n\tlharu: '\\u21BC',\n\tlharul: '\\u296A',\n\tlhblk: '\\u2584',\n\tLJcy: '\\u0409',\n\tljcy: '\\u0459',\n\tLl: '\\u22D8',\n\tll: '\\u226A',\n\tllarr: '\\u21C7',\n\tllcorner: '\\u231E',\n\tLleftarrow: '\\u21DA',\n\tllhard: '\\u296B',\n\tlltri: '\\u25FA',\n\tLmidot: '\\u013F',\n\tlmidot: '\\u0140',\n\tlmoust: '\\u23B0',\n\tlmoustache: '\\u23B0',\n\tlnap: '\\u2A89',\n\tlnapprox: '\\u2A89',\n\tlnE: '\\u2268',\n\tlne: '\\u2A87',\n\tlneq: '\\u2A87',\n\tlneqq: '\\u2268',\n\tlnsim: '\\u22E6',\n\tloang: '\\u27EC',\n\tloarr: '\\u21FD',\n\tlobrk: '\\u27E6',\n\tLongLeftArrow: '\\u27F5',\n\tLongleftarrow: '\\u27F8',\n\tlongleftarrow: '\\u27F5',\n\tLongLeftRightArrow: '\\u27F7',\n\tLongleftrightarrow: '\\u27FA',\n\tlongleftrightarrow: '\\u27F7',\n\tlongmapsto: '\\u27FC',\n\tLongRightArrow: '\\u27F6',\n\tLongrightarrow: '\\u27F9',\n\tlongrightarrow: '\\u27F6',\n\tlooparrowleft: '\\u21AB',\n\tlooparrowright: '\\u21AC',\n\tlopar: '\\u2985',\n\tLopf: '\\uD835\\uDD43',\n\tlopf: '\\uD835\\uDD5D',\n\tloplus: '\\u2A2D',\n\tlotimes: '\\u2A34',\n\tlowast: '\\u2217',\n\tlowbar: '\\u005F',\n\tLowerLeftArrow: '\\u2199',\n\tLowerRightArrow: '\\u2198',\n\tloz: '\\u25CA',\n\tlozenge: '\\u25CA',\n\tlozf: '\\u29EB',\n\tlpar: '\\u0028',\n\tlparlt: '\\u2993',\n\tlrarr: '\\u21C6',\n\tlrcorner: '\\u231F',\n\tlrhar: '\\u21CB',\n\tlrhard: '\\u296D',\n\tlrm: '\\u200E',\n\tlrtri: '\\u22BF',\n\tlsaquo: '\\u2039',\n\tLscr: '\\u2112',\n\tlscr: '\\uD835\\uDCC1',\n\tLsh: '\\u21B0',\n\tlsh: '\\u21B0',\n\tlsim: '\\u2272',\n\tlsime: '\\u2A8D',\n\tlsimg: '\\u2A8F',\n\tlsqb: '\\u005B',\n\tlsquo: '\\u2018',\n\tlsquor: '\\u201A',\n\tLstrok: '\\u0141',\n\tlstrok: '\\u0142',\n\tLt: '\\u226A',\n\tLT: '\\u003C',\n\tlt: '\\u003C',\n\tltcc: '\\u2AA6',\n\tltcir: '\\u2A79',\n\tltdot: '\\u22D6',\n\tlthree: '\\u22CB',\n\tltimes: '\\u22C9',\n\tltlarr: '\\u2976',\n\tltquest: '\\u2A7B',\n\tltri: '\\u25C3',\n\tltrie: '\\u22B4',\n\tltrif: '\\u25C2',\n\tltrPar: '\\u2996',\n\tlurdshar: '\\u294A',\n\tluruhar: '\\u2966',\n\tlvertneqq: '\\u2268\\uFE00',\n\tlvnE: '\\u2268\\uFE00',\n\tmacr: '\\u00AF',\n\tmale: '\\u2642',\n\tmalt: '\\u2720',\n\tmaltese: '\\u2720',\n\tMap: '\\u2905',\n\tmap: '\\u21A6',\n\tmapsto: '\\u21A6',\n\tmapstodown: '\\u21A7',\n\tmapstoleft: '\\u21A4',\n\tmapstoup: '\\u21A5',\n\tmarker: '\\u25AE',\n\tmcomma: '\\u2A29',\n\tMcy: '\\u041C',\n\tmcy: '\\u043C',\n\tmdash: '\\u2014',\n\tmDDot: '\\u223A',\n\tmeasuredangle: '\\u2221',\n\tMediumSpace: '\\u205F',\n\tMellintrf: '\\u2133',\n\tMfr: '\\uD835\\uDD10',\n\tmfr: '\\uD835\\uDD2A',\n\tmho: '\\u2127',\n\tmicro: '\\u00B5',\n\tmid: '\\u2223',\n\tmidast: '\\u002A',\n\tmidcir: '\\u2AF0',\n\tmiddot: '\\u00B7',\n\tminus: '\\u2212',\n\tminusb: '\\u229F',\n\tminusd: '\\u2238',\n\tminusdu: '\\u2A2A',\n\tMinusPlus: '\\u2213',\n\tmlcp: '\\u2ADB',\n\tmldr: '\\u2026',\n\tmnplus: '\\u2213',\n\tmodels: '\\u22A7',\n\tMopf: '\\uD835\\uDD44',\n\tmopf: '\\uD835\\uDD5E',\n\tmp: '\\u2213',\n\tMscr: '\\u2133',\n\tmscr: '\\uD835\\uDCC2',\n\tmstpos: '\\u223E',\n\tMu: '\\u039C',\n\tmu: '\\u03BC',\n\tmultimap: '\\u22B8',\n\tmumap: '\\u22B8',\n\tnabla: '\\u2207',\n\tNacute: '\\u0143',\n\tnacute: '\\u0144',\n\tnang: '\\u2220\\u20D2',\n\tnap: '\\u2249',\n\tnapE: '\\u2A70\\u0338',\n\tnapid: '\\u224B\\u0338',\n\tnapos: '\\u0149',\n\tnapprox: '\\u2249',\n\tnatur: '\\u266E',\n\tnatural: '\\u266E',\n\tnaturals: '\\u2115',\n\tnbsp: '\\u00A0',\n\tnbump: '\\u224E\\u0338',\n\tnbumpe: '\\u224F\\u0338',\n\tncap: '\\u2A43',\n\tNcaron: '\\u0147',\n\tncaron: '\\u0148',\n\tNcedil: '\\u0145',\n\tncedil: '\\u0146',\n\tncong: '\\u2247',\n\tncongdot: '\\u2A6D\\u0338',\n\tncup: '\\u2A42',\n\tNcy: '\\u041D',\n\tncy: '\\u043D',\n\tndash: '\\u2013',\n\tne: '\\u2260',\n\tnearhk: '\\u2924',\n\tneArr: '\\u21D7',\n\tnearr: '\\u2197',\n\tnearrow: '\\u2197',\n\tnedot: '\\u2250\\u0338',\n\tNegativeMediumSpace: '\\u200B',\n\tNegativeThickSpace: '\\u200B',\n\tNegativeThinSpace: '\\u200B',\n\tNegativeVeryThinSpace: '\\u200B',\n\tnequiv: '\\u2262',\n\tnesear: '\\u2928',\n\tnesim: '\\u2242\\u0338',\n\tNestedGreaterGreater: '\\u226B',\n\tNestedLessLess: '\\u226A',\n\tNewLine: '\\u000A',\n\tnexist: '\\u2204',\n\tnexists: '\\u2204',\n\tNfr: '\\uD835\\uDD11',\n\tnfr: '\\uD835\\uDD2B',\n\tngE: '\\u2267\\u0338',\n\tnge: '\\u2271',\n\tngeq: '\\u2271',\n\tngeqq: '\\u2267\\u0338',\n\tngeqslant: '\\u2A7E\\u0338',\n\tnges: '\\u2A7E\\u0338',\n\tnGg: '\\u22D9\\u0338',\n\tngsim: '\\u2275',\n\tnGt: '\\u226B\\u20D2',\n\tngt: '\\u226F',\n\tngtr: '\\u226F',\n\tnGtv: '\\u226B\\u0338',\n\tnhArr: '\\u21CE',\n\tnharr: '\\u21AE',\n\tnhpar: '\\u2AF2',\n\tni: '\\u220B',\n\tnis: '\\u22FC',\n\tnisd: '\\u22FA',\n\tniv: '\\u220B',\n\tNJcy: '\\u040A',\n\tnjcy: '\\u045A',\n\tnlArr: '\\u21CD',\n\tnlarr: '\\u219A',\n\tnldr: '\\u2025',\n\tnlE: '\\u2266\\u0338',\n\tnle: '\\u2270',\n\tnLeftarrow: '\\u21CD',\n\tnleftarrow: '\\u219A',\n\tnLeftrightarrow: '\\u21CE',\n\tnleftrightarrow: '\\u21AE',\n\tnleq: '\\u2270',\n\tnleqq: '\\u2266\\u0338',\n\tnleqslant: '\\u2A7D\\u0338',\n\tnles: '\\u2A7D\\u0338',\n\tnless: '\\u226E',\n\tnLl: '\\u22D8\\u0338',\n\tnlsim: '\\u2274',\n\tnLt: '\\u226A\\u20D2',\n\tnlt: '\\u226E',\n\tnltri: '\\u22EA',\n\tnltrie: '\\u22EC',\n\tnLtv: '\\u226A\\u0338',\n\tnmid: '\\u2224',\n\tNoBreak: '\\u2060',\n\tNonBreakingSpace: '\\u00A0',\n\tNopf: '\\u2115',\n\tnopf: '\\uD835\\uDD5F',\n\tNot: '\\u2AEC',\n\tnot: '\\u00AC',\n\tNotCongruent: '\\u2262',\n\tNotCupCap: '\\u226D',\n\tNotDoubleVerticalBar: '\\u2226',\n\tNotElement: '\\u2209',\n\tNotEqual: '\\u2260',\n\tNotEqualTilde: '\\u2242\\u0338',\n\tNotExists: '\\u2204',\n\tNotGreater: '\\u226F',\n\tNotGreaterEqual: '\\u2271',\n\tNotGreaterFullEqual: '\\u2267\\u0338',\n\tNotGreaterGreater: '\\u226B\\u0338',\n\tNotGreaterLess: '\\u2279',\n\tNotGreaterSlantEqual: '\\u2A7E\\u0338',\n\tNotGreaterTilde: '\\u2275',\n\tNotHumpDownHump: '\\u224E\\u0338',\n\tNotHumpEqual: '\\u224F\\u0338',\n\tnotin: '\\u2209',\n\tnotindot: '\\u22F5\\u0338',\n\tnotinE: '\\u22F9\\u0338',\n\tnotinva: '\\u2209',\n\tnotinvb: '\\u22F7',\n\tnotinvc: '\\u22F6',\n\tNotLeftTriangle: '\\u22EA',\n\tNotLeftTriangleBar: '\\u29CF\\u0338',\n\tNotLeftTriangleEqual: '\\u22EC',\n\tNotLess: '\\u226E',\n\tNotLessEqual: '\\u2270',\n\tNotLessGreater: '\\u2278',\n\tNotLessLess: '\\u226A\\u0338',\n\tNotLessSlantEqual: '\\u2A7D\\u0338',\n\tNotLessTilde: '\\u2274',\n\tNotNestedGreaterGreater: '\\u2AA2\\u0338',\n\tNotNestedLessLess: '\\u2AA1\\u0338',\n\tnotni: '\\u220C',\n\tnotniva: '\\u220C',\n\tnotnivb: '\\u22FE',\n\tnotnivc: '\\u22FD',\n\tNotPrecedes: '\\u2280',\n\tNotPrecedesEqual: '\\u2AAF\\u0338',\n\tNotPrecedesSlantEqual: '\\u22E0',\n\tNotReverseElement: '\\u220C',\n\tNotRightTriangle: '\\u22EB',\n\tNotRightTriangleBar: '\\u29D0\\u0338',\n\tNotRightTriangleEqual: '\\u22ED',\n\tNotSquareSubset: '\\u228F\\u0338',\n\tNotSquareSubsetEqual: '\\u22E2',\n\tNotSquareSuperset: '\\u2290\\u0338',\n\tNotSquareSupersetEqual: '\\u22E3',\n\tNotSubset: '\\u2282\\u20D2',\n\tNotSubsetEqual: '\\u2288',\n\tNotSucceeds: '\\u2281',\n\tNotSucceedsEqual: '\\u2AB0\\u0338',\n\tNotSucceedsSlantEqual: '\\u22E1',\n\tNotSucceedsTilde: '\\u227F\\u0338',\n\tNotSuperset: '\\u2283\\u20D2',\n\tNotSupersetEqual: '\\u2289',\n\tNotTilde: '\\u2241',\n\tNotTildeEqual: '\\u2244',\n\tNotTildeFullEqual: '\\u2247',\n\tNotTildeTilde: '\\u2249',\n\tNotVerticalBar: '\\u2224',\n\tnpar: '\\u2226',\n\tnparallel: '\\u2226',\n\tnparsl: '\\u2AFD\\u20E5',\n\tnpart: '\\u2202\\u0338',\n\tnpolint: '\\u2A14',\n\tnpr: '\\u2280',\n\tnprcue: '\\u22E0',\n\tnpre: '\\u2AAF\\u0338',\n\tnprec: '\\u2280',\n\tnpreceq: '\\u2AAF\\u0338',\n\tnrArr: '\\u21CF',\n\tnrarr: '\\u219B',\n\tnrarrc: '\\u2933\\u0338',\n\tnrarrw: '\\u219D\\u0338',\n\tnRightarrow: '\\u21CF',\n\tnrightarrow: '\\u219B',\n\tnrtri: '\\u22EB',\n\tnrtrie: '\\u22ED',\n\tnsc: '\\u2281',\n\tnsccue: '\\u22E1',\n\tnsce: '\\u2AB0\\u0338',\n\tNscr: '\\uD835\\uDCA9',\n\tnscr: '\\uD835\\uDCC3',\n\tnshortmid: '\\u2224',\n\tnshortparallel: '\\u2226',\n\tnsim: '\\u2241',\n\tnsime: '\\u2244',\n\tnsimeq: '\\u2244',\n\tnsmid: '\\u2224',\n\tnspar: '\\u2226',\n\tnsqsube: '\\u22E2',\n\tnsqsupe: '\\u22E3',\n\tnsub: '\\u2284',\n\tnsubE: '\\u2AC5\\u0338',\n\tnsube: '\\u2288',\n\tnsubset: '\\u2282\\u20D2',\n\tnsubseteq: '\\u2288',\n\tnsubseteqq: '\\u2AC5\\u0338',\n\tnsucc: '\\u2281',\n\tnsucceq: '\\u2AB0\\u0338',\n\tnsup: '\\u2285',\n\tnsupE: '\\u2AC6\\u0338',\n\tnsupe: '\\u2289',\n\tnsupset: '\\u2283\\u20D2',\n\tnsupseteq: '\\u2289',\n\tnsupseteqq: '\\u2AC6\\u0338',\n\tntgl: '\\u2279',\n\tNtilde: '\\u00D1',\n\tntilde: '\\u00F1',\n\tntlg: '\\u2278',\n\tntriangleleft: '\\u22EA',\n\tntrianglelefteq: '\\u22EC',\n\tntriangleright: '\\u22EB',\n\tntrianglerighteq: '\\u22ED',\n\tNu: '\\u039D',\n\tnu: '\\u03BD',\n\tnum: '\\u0023',\n\tnumero: '\\u2116',\n\tnumsp: '\\u2007',\n\tnvap: '\\u224D\\u20D2',\n\tnVDash: '\\u22AF',\n\tnVdash: '\\u22AE',\n\tnvDash: '\\u22AD',\n\tnvdash: '\\u22AC',\n\tnvge: '\\u2265\\u20D2',\n\tnvgt: '\\u003E\\u20D2',\n\tnvHarr: '\\u2904',\n\tnvinfin: '\\u29DE',\n\tnvlArr: '\\u2902',\n\tnvle: '\\u2264\\u20D2',\n\tnvlt: '\\u003C\\u20D2',\n\tnvltrie: '\\u22B4\\u20D2',\n\tnvrArr: '\\u2903',\n\tnvrtrie: '\\u22B5\\u20D2',\n\tnvsim: '\\u223C\\u20D2',\n\tnwarhk: '\\u2923',\n\tnwArr: '\\u21D6',\n\tnwarr: '\\u2196',\n\tnwarrow: '\\u2196',\n\tnwnear: '\\u2927',\n\tOacute: '\\u00D3',\n\toacute: '\\u00F3',\n\toast: '\\u229B',\n\tocir: '\\u229A',\n\tOcirc: '\\u00D4',\n\tocirc: '\\u00F4',\n\tOcy: '\\u041E',\n\tocy: '\\u043E',\n\todash: '\\u229D',\n\tOdblac: '\\u0150',\n\todblac: '\\u0151',\n\todiv: '\\u2A38',\n\todot: '\\u2299',\n\todsold: '\\u29BC',\n\tOElig: '\\u0152',\n\toelig: '\\u0153',\n\tofcir: '\\u29BF',\n\tOfr: '\\uD835\\uDD12',\n\tofr: '\\uD835\\uDD2C',\n\togon: '\\u02DB',\n\tOgrave: '\\u00D2',\n\tograve: '\\u00F2',\n\togt: '\\u29C1',\n\tohbar: '\\u29B5',\n\tohm: '\\u03A9',\n\toint: '\\u222E',\n\tolarr: '\\u21BA',\n\tolcir: '\\u29BE',\n\tolcross: '\\u29BB',\n\toline: '\\u203E',\n\tolt: '\\u29C0',\n\tOmacr: '\\u014C',\n\tomacr: '\\u014D',\n\tOmega: '\\u03A9',\n\tomega: '\\u03C9',\n\tOmicron: '\\u039F',\n\tomicron: '\\u03BF',\n\tomid: '\\u29B6',\n\tominus: '\\u2296',\n\tOopf: '\\uD835\\uDD46',\n\toopf: '\\uD835\\uDD60',\n\topar: '\\u29B7',\n\tOpenCurlyDoubleQuote: '\\u201C',\n\tOpenCurlyQuote: '\\u2018',\n\toperp: '\\u29B9',\n\toplus: '\\u2295',\n\tOr: '\\u2A54',\n\tor: '\\u2228',\n\torarr: '\\u21BB',\n\tord: '\\u2A5D',\n\torder: '\\u2134',\n\torderof: '\\u2134',\n\tordf: '\\u00AA',\n\tordm: '\\u00BA',\n\torigof: '\\u22B6',\n\toror: '\\u2A56',\n\torslope: '\\u2A57',\n\torv: '\\u2A5B',\n\toS: '\\u24C8',\n\tOscr: '\\uD835\\uDCAA',\n\toscr: '\\u2134',\n\tOslash: '\\u00D8',\n\toslash: '\\u00F8',\n\tosol: '\\u2298',\n\tOtilde: '\\u00D5',\n\totilde: '\\u00F5',\n\tOtimes: '\\u2A37',\n\totimes: '\\u2297',\n\totimesas: '\\u2A36',\n\tOuml: '\\u00D6',\n\touml: '\\u00F6',\n\tovbar: '\\u233D',\n\tOverBar: '\\u203E',\n\tOverBrace: '\\u23DE',\n\tOverBracket: '\\u23B4',\n\tOverParenthesis: '\\u23DC',\n\tpar: '\\u2225',\n\tpara: '\\u00B6',\n\tparallel: '\\u2225',\n\tparsim: '\\u2AF3',\n\tparsl: '\\u2AFD',\n\tpart: '\\u2202',\n\tPartialD: '\\u2202',\n\tPcy: '\\u041F',\n\tpcy: '\\u043F',\n\tpercnt: '\\u0025',\n\tperiod: '\\u002E',\n\tpermil: '\\u2030',\n\tperp: '\\u22A5',\n\tpertenk: '\\u2031',\n\tPfr: '\\uD835\\uDD13',\n\tpfr: '\\uD835\\uDD2D',\n\tPhi: '\\u03A6',\n\tphi: '\\u03C6',\n\tphiv: '\\u03D5',\n\tphmmat: '\\u2133',\n\tphone: '\\u260E',\n\tPi: '\\u03A0',\n\tpi: '\\u03C0',\n\tpitchfork: '\\u22D4',\n\tpiv: '\\u03D6',\n\tplanck: '\\u210F',\n\tplanckh: '\\u210E',\n\tplankv: '\\u210F',\n\tplus: '\\u002B',\n\tplusacir: '\\u2A23',\n\tplusb: '\\u229E',\n\tpluscir: '\\u2A22',\n\tplusdo: '\\u2214',\n\tplusdu: '\\u2A25',\n\tpluse: '\\u2A72',\n\tPlusMinus: '\\u00B1',\n\tplusmn: '\\u00B1',\n\tplussim: '\\u2A26',\n\tplustwo: '\\u2A27',\n\tpm: '\\u00B1',\n\tPoincareplane: '\\u210C',\n\tpointint: '\\u2A15',\n\tPopf: '\\u2119',\n\tpopf: '\\uD835\\uDD61',\n\tpound: '\\u00A3',\n\tPr: '\\u2ABB',\n\tpr: '\\u227A',\n\tprap: '\\u2AB7',\n\tprcue: '\\u227C',\n\tprE: '\\u2AB3',\n\tpre: '\\u2AAF',\n\tprec: '\\u227A',\n\tprecapprox: '\\u2AB7',\n\tpreccurlyeq: '\\u227C',\n\tPrecedes: '\\u227A',\n\tPrecedesEqual: '\\u2AAF',\n\tPrecedesSlantEqual: '\\u227C',\n\tPrecedesTilde: '\\u227E',\n\tpreceq: '\\u2AAF',\n\tprecnapprox: '\\u2AB9',\n\tprecneqq: '\\u2AB5',\n\tprecnsim: '\\u22E8',\n\tprecsim: '\\u227E',\n\tPrime: '\\u2033',\n\tprime: '\\u2032',\n\tprimes: '\\u2119',\n\tprnap: '\\u2AB9',\n\tprnE: '\\u2AB5',\n\tprnsim: '\\u22E8',\n\tprod: '\\u220F',\n\tProduct: '\\u220F',\n\tprofalar: '\\u232E',\n\tprofline: '\\u2312',\n\tprofsurf: '\\u2313',\n\tprop: '\\u221D',\n\tProportion: '\\u2237',\n\tProportional: '\\u221D',\n\tpropto: '\\u221D',\n\tprsim: '\\u227E',\n\tprurel: '\\u22B0',\n\tPscr: '\\uD835\\uDCAB',\n\tpscr: '\\uD835\\uDCC5',\n\tPsi: '\\u03A8',\n\tpsi: '\\u03C8',\n\tpuncsp: '\\u2008',\n\tQfr: '\\uD835\\uDD14',\n\tqfr: '\\uD835\\uDD2E',\n\tqint: '\\u2A0C',\n\tQopf: '\\u211A',\n\tqopf: '\\uD835\\uDD62',\n\tqprime: '\\u2057',\n\tQscr: '\\uD835\\uDCAC',\n\tqscr: '\\uD835\\uDCC6',\n\tquaternions: '\\u210D',\n\tquatint: '\\u2A16',\n\tquest: '\\u003F',\n\tquesteq: '\\u225F',\n\tQUOT: '\\u0022',\n\tquot: '\\u0022',\n\trAarr: '\\u21DB',\n\trace: '\\u223D\\u0331',\n\tRacute: '\\u0154',\n\tracute: '\\u0155',\n\tradic: '\\u221A',\n\traemptyv: '\\u29B3',\n\tRang: '\\u27EB',\n\trang: '\\u27E9',\n\trangd: '\\u2992',\n\trange: '\\u29A5',\n\trangle: '\\u27E9',\n\traquo: '\\u00BB',\n\tRarr: '\\u21A0',\n\trArr: '\\u21D2',\n\trarr: '\\u2192',\n\trarrap: '\\u2975',\n\trarrb: '\\u21E5',\n\trarrbfs: '\\u2920',\n\trarrc: '\\u2933',\n\trarrfs: '\\u291E',\n\trarrhk: '\\u21AA',\n\trarrlp: '\\u21AC',\n\trarrpl: '\\u2945',\n\trarrsim: '\\u2974',\n\tRarrtl: '\\u2916',\n\trarrtl: '\\u21A3',\n\trarrw: '\\u219D',\n\trAtail: '\\u291C',\n\tratail: '\\u291A',\n\tratio: '\\u2236',\n\trationals: '\\u211A',\n\tRBarr: '\\u2910',\n\trBarr: '\\u290F',\n\trbarr: '\\u290D',\n\trbbrk: '\\u2773',\n\trbrace: '\\u007D',\n\trbrack: '\\u005D',\n\trbrke: '\\u298C',\n\trbrksld: '\\u298E',\n\trbrkslu: '\\u2990',\n\tRcaron: '\\u0158',\n\trcaron: '\\u0159',\n\tRcedil: '\\u0156',\n\trcedil: '\\u0157',\n\trceil: '\\u2309',\n\trcub: '\\u007D',\n\tRcy: '\\u0420',\n\trcy: '\\u0440',\n\trdca: '\\u2937',\n\trdldhar: '\\u2969',\n\trdquo: '\\u201D',\n\trdquor: '\\u201D',\n\trdsh: '\\u21B3',\n\tRe: '\\u211C',\n\treal: '\\u211C',\n\trealine: '\\u211B',\n\trealpart: '\\u211C',\n\treals: '\\u211D',\n\trect: '\\u25AD',\n\tREG: '\\u00AE',\n\treg: '\\u00AE',\n\tReverseElement: '\\u220B',\n\tReverseEquilibrium: '\\u21CB',\n\tReverseUpEquilibrium: '\\u296F',\n\trfisht: '\\u297D',\n\trfloor: '\\u230B',\n\tRfr: '\\u211C',\n\trfr: '\\uD835\\uDD2F',\n\trHar: '\\u2964',\n\trhard: '\\u21C1',\n\trharu: '\\u21C0',\n\trharul: '\\u296C',\n\tRho: '\\u03A1',\n\trho: '\\u03C1',\n\trhov: '\\u03F1',\n\tRightAngleBracket: '\\u27E9',\n\tRightArrow: '\\u2192',\n\tRightarrow: '\\u21D2',\n\trightarrow: '\\u2192',\n\tRightArrowBar: '\\u21E5',\n\tRightArrowLeftArrow: '\\u21C4',\n\trightarrowtail: '\\u21A3',\n\tRightCeiling: '\\u2309',\n\tRightDoubleBracket: '\\u27E7',\n\tRightDownTeeVector: '\\u295D',\n\tRightDownVector: '\\u21C2',\n\tRightDownVectorBar: '\\u2955',\n\tRightFloor: '\\u230B',\n\trightharpoondown: '\\u21C1',\n\trightharpoonup: '\\u21C0',\n\trightleftarrows: '\\u21C4',\n\trightleftharpoons: '\\u21CC',\n\trightrightarrows: '\\u21C9',\n\trightsquigarrow: '\\u219D',\n\tRightTee: '\\u22A2',\n\tRightTeeArrow: '\\u21A6',\n\tRightTeeVector: '\\u295B',\n\trightthreetimes: '\\u22CC',\n\tRightTriangle: '\\u22B3',\n\tRightTriangleBar: '\\u29D0',\n\tRightTriangleEqual: '\\u22B5',\n\tRightUpDownVector: '\\u294F',\n\tRightUpTeeVector: '\\u295C',\n\tRightUpVector: '\\u21BE',\n\tRightUpVectorBar: '\\u2954',\n\tRightVector: '\\u21C0',\n\tRightVectorBar: '\\u2953',\n\tring: '\\u02DA',\n\trisingdotseq: '\\u2253',\n\trlarr: '\\u21C4',\n\trlhar: '\\u21CC',\n\trlm: '\\u200F',\n\trmoust: '\\u23B1',\n\trmoustache: '\\u23B1',\n\trnmid: '\\u2AEE',\n\troang: '\\u27ED',\n\troarr: '\\u21FE',\n\trobrk: '\\u27E7',\n\tropar: '\\u2986',\n\tRopf: '\\u211D',\n\tropf: '\\uD835\\uDD63',\n\troplus: '\\u2A2E',\n\trotimes: '\\u2A35',\n\tRoundImplies: '\\u2970',\n\trpar: '\\u0029',\n\trpargt: '\\u2994',\n\trppolint: '\\u2A12',\n\trrarr: '\\u21C9',\n\tRrightarrow: '\\u21DB',\n\trsaquo: '\\u203A',\n\tRscr: '\\u211B',\n\trscr: '\\uD835\\uDCC7',\n\tRsh: '\\u21B1',\n\trsh: '\\u21B1',\n\trsqb: '\\u005D',\n\trsquo: '\\u2019',\n\trsquor: '\\u2019',\n\trthree: '\\u22CC',\n\trtimes: '\\u22CA',\n\trtri: '\\u25B9',\n\trtrie: '\\u22B5',\n\trtrif: '\\u25B8',\n\trtriltri: '\\u29CE',\n\tRuleDelayed: '\\u29F4',\n\truluhar: '\\u2968',\n\trx: '\\u211E',\n\tSacute: '\\u015A',\n\tsacute: '\\u015B',\n\tsbquo: '\\u201A',\n\tSc: '\\u2ABC',\n\tsc: '\\u227B',\n\tscap: '\\u2AB8',\n\tScaron: '\\u0160',\n\tscaron: '\\u0161',\n\tsccue: '\\u227D',\n\tscE: '\\u2AB4',\n\tsce: '\\u2AB0',\n\tScedil: '\\u015E',\n\tscedil: '\\u015F',\n\tScirc: '\\u015C',\n\tscirc: '\\u015D',\n\tscnap: '\\u2ABA',\n\tscnE: '\\u2AB6',\n\tscnsim: '\\u22E9',\n\tscpolint: '\\u2A13',\n\tscsim: '\\u227F',\n\tScy: '\\u0421',\n\tscy: '\\u0441',\n\tsdot: '\\u22C5',\n\tsdotb: '\\u22A1',\n\tsdote: '\\u2A66',\n\tsearhk: '\\u2925',\n\tseArr: '\\u21D8',\n\tsearr: '\\u2198',\n\tsearrow: '\\u2198',\n\tsect: '\\u00A7',\n\tsemi: '\\u003B',\n\tseswar: '\\u2929',\n\tsetminus: '\\u2216',\n\tsetmn: '\\u2216',\n\tsext: '\\u2736',\n\tSfr: '\\uD835\\uDD16',\n\tsfr: '\\uD835\\uDD30',\n\tsfrown: '\\u2322',\n\tsharp: '\\u266F',\n\tSHCHcy: '\\u0429',\n\tshchcy: '\\u0449',\n\tSHcy: '\\u0428',\n\tshcy: '\\u0448',\n\tShortDownArrow: '\\u2193',\n\tShortLeftArrow: '\\u2190',\n\tshortmid: '\\u2223',\n\tshortparallel: '\\u2225',\n\tShortRightArrow: '\\u2192',\n\tShortUpArrow: '\\u2191',\n\tshy: '\\u00AD',\n\tSigma: '\\u03A3',\n\tsigma: '\\u03C3',\n\tsigmaf: '\\u03C2',\n\tsigmav: '\\u03C2',\n\tsim: '\\u223C',\n\tsimdot: '\\u2A6A',\n\tsime: '\\u2243',\n\tsimeq: '\\u2243',\n\tsimg: '\\u2A9E',\n\tsimgE: '\\u2AA0',\n\tsiml: '\\u2A9D',\n\tsimlE: '\\u2A9F',\n\tsimne: '\\u2246',\n\tsimplus: '\\u2A24',\n\tsimrarr: '\\u2972',\n\tslarr: '\\u2190',\n\tSmallCircle: '\\u2218',\n\tsmallsetminus: '\\u2216',\n\tsmashp: '\\u2A33',\n\tsmeparsl: '\\u29E4',\n\tsmid: '\\u2223',\n\tsmile: '\\u2323',\n\tsmt: '\\u2AAA',\n\tsmte: '\\u2AAC',\n\tsmtes: '\\u2AAC\\uFE00',\n\tSOFTcy: '\\u042C',\n\tsoftcy: '\\u044C',\n\tsol: '\\u002F',\n\tsolb: '\\u29C4',\n\tsolbar: '\\u233F',\n\tSopf: '\\uD835\\uDD4A',\n\tsopf: '\\uD835\\uDD64',\n\tspades: '\\u2660',\n\tspadesuit: '\\u2660',\n\tspar: '\\u2225',\n\tsqcap: '\\u2293',\n\tsqcaps: '\\u2293\\uFE00',\n\tsqcup: '\\u2294',\n\tsqcups: '\\u2294\\uFE00',\n\tSqrt: '\\u221A',\n\tsqsub: '\\u228F',\n\tsqsube: '\\u2291',\n\tsqsubset: '\\u228F',\n\tsqsubseteq: '\\u2291',\n\tsqsup: '\\u2290',\n\tsqsupe: '\\u2292',\n\tsqsupset: '\\u2290',\n\tsqsupseteq: '\\u2292',\n\tsqu: '\\u25A1',\n\tSquare: '\\u25A1',\n\tsquare: '\\u25A1',\n\tSquareIntersection: '\\u2293',\n\tSquareSubset: '\\u228F',\n\tSquareSubsetEqual: '\\u2291',\n\tSquareSuperset: '\\u2290',\n\tSquareSupersetEqual: '\\u2292',\n\tSquareUnion: '\\u2294',\n\tsquarf: '\\u25AA',\n\tsquf: '\\u25AA',\n\tsrarr: '\\u2192',\n\tSscr: '\\uD835\\uDCAE',\n\tsscr: '\\uD835\\uDCC8',\n\tssetmn: '\\u2216',\n\tssmile: '\\u2323',\n\tsstarf: '\\u22C6',\n\tStar: '\\u22C6',\n\tstar: '\\u2606',\n\tstarf: '\\u2605',\n\tstraightepsilon: '\\u03F5',\n\tstraightphi: '\\u03D5',\n\tstrns: '\\u00AF',\n\tSub: '\\u22D0',\n\tsub: '\\u2282',\n\tsubdot: '\\u2ABD',\n\tsubE: '\\u2AC5',\n\tsube: '\\u2286',\n\tsubedot: '\\u2AC3',\n\tsubmult: '\\u2AC1',\n\tsubnE: '\\u2ACB',\n\tsubne: '\\u228A',\n\tsubplus: '\\u2ABF',\n\tsubrarr: '\\u2979',\n\tSubset: '\\u22D0',\n\tsubset: '\\u2282',\n\tsubseteq: '\\u2286',\n\tsubseteqq: '\\u2AC5',\n\tSubsetEqual: '\\u2286',\n\tsubsetneq: '\\u228A',\n\tsubsetneqq: '\\u2ACB',\n\tsubsim: '\\u2AC7',\n\tsubsub: '\\u2AD5',\n\tsubsup: '\\u2AD3',\n\tsucc: '\\u227B',\n\tsuccapprox: '\\u2AB8',\n\tsucccurlyeq: '\\u227D',\n\tSucceeds: '\\u227B',\n\tSucceedsEqual: '\\u2AB0',\n\tSucceedsSlantEqual: '\\u227D',\n\tSucceedsTilde: '\\u227F',\n\tsucceq: '\\u2AB0',\n\tsuccnapprox: '\\u2ABA',\n\tsuccneqq: '\\u2AB6',\n\tsuccnsim: '\\u22E9',\n\tsuccsim: '\\u227F',\n\tSuchThat: '\\u220B',\n\tSum: '\\u2211',\n\tsum: '\\u2211',\n\tsung: '\\u266A',\n\tSup: '\\u22D1',\n\tsup: '\\u2283',\n\tsup1: '\\u00B9',\n\tsup2: '\\u00B2',\n\tsup3: '\\u00B3',\n\tsupdot: '\\u2ABE',\n\tsupdsub: '\\u2AD8',\n\tsupE: '\\u2AC6',\n\tsupe: '\\u2287',\n\tsupedot: '\\u2AC4',\n\tSuperset: '\\u2283',\n\tSupersetEqual: '\\u2287',\n\tsuphsol: '\\u27C9',\n\tsuphsub: '\\u2AD7',\n\tsuplarr: '\\u297B',\n\tsupmult: '\\u2AC2',\n\tsupnE: '\\u2ACC',\n\tsupne: '\\u228B',\n\tsupplus: '\\u2AC0',\n\tSupset: '\\u22D1',\n\tsupset: '\\u2283',\n\tsupseteq: '\\u2287',\n\tsupseteqq: '\\u2AC6',\n\tsupsetneq: '\\u228B',\n\tsupsetneqq: '\\u2ACC',\n\tsupsim: '\\u2AC8',\n\tsupsub: '\\u2AD4',\n\tsupsup: '\\u2AD6',\n\tswarhk: '\\u2926',\n\tswArr: '\\u21D9',\n\tswarr: '\\u2199',\n\tswarrow: '\\u2199',\n\tswnwar: '\\u292A',\n\tszlig: '\\u00DF',\n\tTab: '\\u0009',\n\ttarget: '\\u2316',\n\tTau: '\\u03A4',\n\ttau: '\\u03C4',\n\ttbrk: '\\u23B4',\n\tTcaron: '\\u0164',\n\ttcaron: '\\u0165',\n\tTcedil: '\\u0162',\n\ttcedil: '\\u0163',\n\tTcy: '\\u0422',\n\ttcy: '\\u0442',\n\ttdot: '\\u20DB',\n\ttelrec: '\\u2315',\n\tTfr: '\\uD835\\uDD17',\n\ttfr: '\\uD835\\uDD31',\n\tthere4: '\\u2234',\n\tTherefore: '\\u2234',\n\ttherefore: '\\u2234',\n\tTheta: '\\u0398',\n\ttheta: '\\u03B8',\n\tthetasym: '\\u03D1',\n\tthetav: '\\u03D1',\n\tthickapprox: '\\u2248',\n\tthicksim: '\\u223C',\n\tThickSpace: '\\u205F\\u200A',\n\tthinsp: '\\u2009',\n\tThinSpace: '\\u2009',\n\tthkap: '\\u2248',\n\tthksim: '\\u223C',\n\tTHORN: '\\u00DE',\n\tthorn: '\\u00FE',\n\tTilde: '\\u223C',\n\ttilde: '\\u02DC',\n\tTildeEqual: '\\u2243',\n\tTildeFullEqual: '\\u2245',\n\tTildeTilde: '\\u2248',\n\ttimes: '\\u00D7',\n\ttimesb: '\\u22A0',\n\ttimesbar: '\\u2A31',\n\ttimesd: '\\u2A30',\n\ttint: '\\u222D',\n\ttoea: '\\u2928',\n\ttop: '\\u22A4',\n\ttopbot: '\\u2336',\n\ttopcir: '\\u2AF1',\n\tTopf: '\\uD835\\uDD4B',\n\ttopf: '\\uD835\\uDD65',\n\ttopfork: '\\u2ADA',\n\ttosa: '\\u2929',\n\ttprime: '\\u2034',\n\tTRADE: '\\u2122',\n\ttrade: '\\u2122',\n\ttriangle: '\\u25B5',\n\ttriangledown: '\\u25BF',\n\ttriangleleft: '\\u25C3',\n\ttrianglelefteq: '\\u22B4',\n\ttriangleq: '\\u225C',\n\ttriangleright: '\\u25B9',\n\ttrianglerighteq: '\\u22B5',\n\ttridot: '\\u25EC',\n\ttrie: '\\u225C',\n\ttriminus: '\\u2A3A',\n\tTripleDot: '\\u20DB',\n\ttriplus: '\\u2A39',\n\ttrisb: '\\u29CD',\n\ttritime: '\\u2A3B',\n\ttrpezium: '\\u23E2',\n\tTscr: '\\uD835\\uDCAF',\n\ttscr: '\\uD835\\uDCC9',\n\tTScy: '\\u0426',\n\ttscy: '\\u0446',\n\tTSHcy: '\\u040B',\n\ttshcy: '\\u045B',\n\tTstrok: '\\u0166',\n\ttstrok: '\\u0167',\n\ttwixt: '\\u226C',\n\ttwoheadleftarrow: '\\u219E',\n\ttwoheadrightarrow: '\\u21A0',\n\tUacute: '\\u00DA',\n\tuacute: '\\u00FA',\n\tUarr: '\\u219F',\n\tuArr: '\\u21D1',\n\tuarr: '\\u2191',\n\tUarrocir: '\\u2949',\n\tUbrcy: '\\u040E',\n\tubrcy: '\\u045E',\n\tUbreve: '\\u016C',\n\tubreve: '\\u016D',\n\tUcirc: '\\u00DB',\n\tucirc: '\\u00FB',\n\tUcy: '\\u0423',\n\tucy: '\\u0443',\n\tudarr: '\\u21C5',\n\tUdblac: '\\u0170',\n\tudblac: '\\u0171',\n\tudhar: '\\u296E',\n\tufisht: '\\u297E',\n\tUfr: '\\uD835\\uDD18',\n\tufr: '\\uD835\\uDD32',\n\tUgrave: '\\u00D9',\n\tugrave: '\\u00F9',\n\tuHar: '\\u2963',\n\tuharl: '\\u21BF',\n\tuharr: '\\u21BE',\n\tuhblk: '\\u2580',\n\tulcorn: '\\u231C',\n\tulcorner: '\\u231C',\n\tulcrop: '\\u230F',\n\tultri: '\\u25F8',\n\tUmacr: '\\u016A',\n\tumacr: '\\u016B',\n\tuml: '\\u00A8',\n\tUnderBar: '\\u005F',\n\tUnderBrace: '\\u23DF',\n\tUnderBracket: '\\u23B5',\n\tUnderParenthesis: '\\u23DD',\n\tUnion: '\\u22C3',\n\tUnionPlus: '\\u228E',\n\tUogon: '\\u0172',\n\tuogon: '\\u0173',\n\tUopf: '\\uD835\\uDD4C',\n\tuopf: '\\uD835\\uDD66',\n\tUpArrow: '\\u2191',\n\tUparrow: '\\u21D1',\n\tuparrow: '\\u2191',\n\tUpArrowBar: '\\u2912',\n\tUpArrowDownArrow: '\\u21C5',\n\tUpDownArrow: '\\u2195',\n\tUpdownarrow: '\\u21D5',\n\tupdownarrow: '\\u2195',\n\tUpEquilibrium: '\\u296E',\n\tupharpoonleft: '\\u21BF',\n\tupharpoonright: '\\u21BE',\n\tuplus: '\\u228E',\n\tUpperLeftArrow: '\\u2196',\n\tUpperRightArrow: '\\u2197',\n\tUpsi: '\\u03D2',\n\tupsi: '\\u03C5',\n\tupsih: '\\u03D2',\n\tUpsilon: '\\u03A5',\n\tupsilon: '\\u03C5',\n\tUpTee: '\\u22A5',\n\tUpTeeArrow: '\\u21A5',\n\tupuparrows: '\\u21C8',\n\turcorn: '\\u231D',\n\turcorner: '\\u231D',\n\turcrop: '\\u230E',\n\tUring: '\\u016E',\n\turing: '\\u016F',\n\turtri: '\\u25F9',\n\tUscr: '\\uD835\\uDCB0',\n\tuscr: '\\uD835\\uDCCA',\n\tutdot: '\\u22F0',\n\tUtilde: '\\u0168',\n\tutilde: '\\u0169',\n\tutri: '\\u25B5',\n\tutrif: '\\u25B4',\n\tuuarr: '\\u21C8',\n\tUuml: '\\u00DC',\n\tuuml: '\\u00FC',\n\tuwangle: '\\u29A7',\n\tvangrt: '\\u299C',\n\tvarepsilon: '\\u03F5',\n\tvarkappa: '\\u03F0',\n\tvarnothing: '\\u2205',\n\tvarphi: '\\u03D5',\n\tvarpi: '\\u03D6',\n\tvarpropto: '\\u221D',\n\tvArr: '\\u21D5',\n\tvarr: '\\u2195',\n\tvarrho: '\\u03F1',\n\tvarsigma: '\\u03C2',\n\tvarsubsetneq: '\\u228A\\uFE00',\n\tvarsubsetneqq: '\\u2ACB\\uFE00',\n\tvarsupsetneq: '\\u228B\\uFE00',\n\tvarsupsetneqq: '\\u2ACC\\uFE00',\n\tvartheta: '\\u03D1',\n\tvartriangleleft: '\\u22B2',\n\tvartriangleright: '\\u22B3',\n\tVbar: '\\u2AEB',\n\tvBar: '\\u2AE8',\n\tvBarv: '\\u2AE9',\n\tVcy: '\\u0412',\n\tvcy: '\\u0432',\n\tVDash: '\\u22AB',\n\tVdash: '\\u22A9',\n\tvDash: '\\u22A8',\n\tvdash: '\\u22A2',\n\tVdashl: '\\u2AE6',\n\tVee: '\\u22C1',\n\tvee: '\\u2228',\n\tveebar: '\\u22BB',\n\tveeeq: '\\u225A',\n\tvellip: '\\u22EE',\n\tVerbar: '\\u2016',\n\tverbar: '\\u007C',\n\tVert: '\\u2016',\n\tvert: '\\u007C',\n\tVerticalBar: '\\u2223',\n\tVerticalLine: '\\u007C',\n\tVerticalSeparator: '\\u2758',\n\tVerticalTilde: '\\u2240',\n\tVeryThinSpace: '\\u200A',\n\tVfr: '\\uD835\\uDD19',\n\tvfr: '\\uD835\\uDD33',\n\tvltri: '\\u22B2',\n\tvnsub: '\\u2282\\u20D2',\n\tvnsup: '\\u2283\\u20D2',\n\tVopf: '\\uD835\\uDD4D',\n\tvopf: '\\uD835\\uDD67',\n\tvprop: '\\u221D',\n\tvrtri: '\\u22B3',\n\tVscr: '\\uD835\\uDCB1',\n\tvscr: '\\uD835\\uDCCB',\n\tvsubnE: '\\u2ACB\\uFE00',\n\tvsubne: '\\u228A\\uFE00',\n\tvsupnE: '\\u2ACC\\uFE00',\n\tvsupne: '\\u228B\\uFE00',\n\tVvdash: '\\u22AA',\n\tvzigzag: '\\u299A',\n\tWcirc: '\\u0174',\n\twcirc: '\\u0175',\n\twedbar: '\\u2A5F',\n\tWedge: '\\u22C0',\n\twedge: '\\u2227',\n\twedgeq: '\\u2259',\n\tweierp: '\\u2118',\n\tWfr: '\\uD835\\uDD1A',\n\twfr: '\\uD835\\uDD34',\n\tWopf: '\\uD835\\uDD4E',\n\twopf: '\\uD835\\uDD68',\n\twp: '\\u2118',\n\twr: '\\u2240',\n\twreath: '\\u2240',\n\tWscr: '\\uD835\\uDCB2',\n\twscr: '\\uD835\\uDCCC',\n\txcap: '\\u22C2',\n\txcirc: '\\u25EF',\n\txcup: '\\u22C3',\n\txdtri: '\\u25BD',\n\tXfr: '\\uD835\\uDD1B',\n\txfr: '\\uD835\\uDD35',\n\txhArr: '\\u27FA',\n\txharr: '\\u27F7',\n\tXi: '\\u039E',\n\txi: '\\u03BE',\n\txlArr: '\\u27F8',\n\txlarr: '\\u27F5',\n\txmap: '\\u27FC',\n\txnis: '\\u22FB',\n\txodot: '\\u2A00',\n\tXopf: '\\uD835\\uDD4F',\n\txopf: '\\uD835\\uDD69',\n\txoplus: '\\u2A01',\n\txotime: '\\u2A02',\n\txrArr: '\\u27F9',\n\txrarr: '\\u27F6',\n\tXscr: '\\uD835\\uDCB3',\n\txscr: '\\uD835\\uDCCD',\n\txsqcup: '\\u2A06',\n\txuplus: '\\u2A04',\n\txutri: '\\u25B3',\n\txvee: '\\u22C1',\n\txwedge: '\\u22C0',\n\tYacute: '\\u00DD',\n\tyacute: '\\u00FD',\n\tYAcy: '\\u042F',\n\tyacy: '\\u044F',\n\tYcirc: '\\u0176',\n\tycirc: '\\u0177',\n\tYcy: '\\u042B',\n\tycy: '\\u044B',\n\tyen: '\\u00A5',\n\tYfr: '\\uD835\\uDD1C',\n\tyfr: '\\uD835\\uDD36',\n\tYIcy: '\\u0407',\n\tyicy: '\\u0457',\n\tYopf: '\\uD835\\uDD50',\n\tyopf: '\\uD835\\uDD6A',\n\tYscr: '\\uD835\\uDCB4',\n\tyscr: '\\uD835\\uDCCE',\n\tYUcy: '\\u042E',\n\tyucy: '\\u044E',\n\tYuml: '\\u0178',\n\tyuml: '\\u00FF',\n\tZacute: '\\u0179',\n\tzacute: '\\u017A',\n\tZcaron: '\\u017D',\n\tzcaron: '\\u017E',\n\tZcy: '\\u0417',\n\tzcy: '\\u0437',\n\tZdot: '\\u017B',\n\tzdot: '\\u017C',\n\tzeetrf: '\\u2128',\n\tZeroWidthSpace: '\\u200B',\n\tZeta: '\\u0396',\n\tzeta: '\\u03B6',\n\tZfr: '\\u2128',\n\tzfr: '\\uD835\\uDD37',\n\tZHcy: '\\u0416',\n\tzhcy: '\\u0436',\n\tzigrarr: '\\u21DD',\n\tZopf: '\\u2124',\n\tzopf: '\\uD835\\uDD6B',\n\tZscr: '\\uD835\\uDCB5',\n\tzscr: '\\uD835\\uDCCF',\n\tzwj: '\\u200D',\n\tzwnj: '\\u200C',\n});\n\n/**\n * @deprecated use `HTML_ENTITIES` instead\n * @see HTML_ENTITIES\n */\nexports.entityMap = exports.HTML_ENTITIES;\n","var NAMESPACE = require(\"./conventions\").NAMESPACE;\n\n//[4] \tNameStartChar\t ::= \t\":\" | [A-Z] | \"_\" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]\n//[4a] \tNameChar\t ::= \tNameStartChar | \"-\" | \".\" | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]\n//[5] \tName\t ::= \tNameStartChar (NameChar)*\nvar nameStartChar = /[A-Z_a-z\\xC0-\\xD6\\xD8-\\xF6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD]///\\u10000-\\uEFFFF\nvar nameChar = new RegExp(\"[\\\\-\\\\.0-9\"+nameStartChar.source.slice(1,-1)+\"\\\\u00B7\\\\u0300-\\\\u036F\\\\u203F-\\\\u2040]\");\nvar tagNamePattern = new RegExp('^'+nameStartChar.source+nameChar.source+'*(?:\\:'+nameStartChar.source+nameChar.source+'*)?$');\n//var tagNamePattern = /^[a-zA-Z_][\\w\\-\\.]*(?:\\:[a-zA-Z_][\\w\\-\\.]*)?$/\n//var handlers = 'resolveEntity,getExternalSubset,characters,endDocument,endElement,endPrefixMapping,ignorableWhitespace,processingInstruction,setDocumentLocator,skippedEntity,startDocument,startElement,startPrefixMapping,notationDecl,unparsedEntityDecl,error,fatalError,warning,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,comment,endCDATA,endDTD,endEntity,startCDATA,startDTD,startEntity'.split(',')\n\n//S_TAG,\tS_ATTR,\tS_EQ,\tS_ATTR_NOQUOT_VALUE\n//S_ATTR_SPACE,\tS_ATTR_END,\tS_TAG_SPACE, S_TAG_CLOSE\nvar S_TAG = 0;//tag name offerring\nvar S_ATTR = 1;//attr name offerring\nvar S_ATTR_SPACE=2;//attr name end and space offer\nvar S_EQ = 3;//=space?\nvar S_ATTR_NOQUOT_VALUE = 4;//attr value(no quot value only)\nvar S_ATTR_END = 5;//attr value end and no space(quot end)\nvar S_TAG_SPACE = 6;//(attr value end || tag end ) && (space offer)\nvar S_TAG_CLOSE = 7;//closed el\n\n/**\n * Creates an error that will not be caught by XMLReader aka the SAX parser.\n *\n * @param {string} message\n * @param {any?} locator Optional, can provide details about the location in the source\n * @constructor\n */\nfunction ParseError(message, locator) {\n\tthis.message = message\n\tthis.locator = locator\n\tif(Error.captureStackTrace) Error.captureStackTrace(this, ParseError);\n}\nParseError.prototype = new Error();\nParseError.prototype.name = ParseError.name\n\nfunction XMLReader(){\n\n}\n\nXMLReader.prototype = {\n\tparse:function(source,defaultNSMap,entityMap){\n\t\tvar domBuilder = this.domBuilder;\n\t\tdomBuilder.startDocument();\n\t\t_copy(defaultNSMap ,defaultNSMap = {})\n\t\tparse(source,defaultNSMap,entityMap,\n\t\t\t\tdomBuilder,this.errorHandler);\n\t\tdomBuilder.endDocument();\n\t}\n}\nfunction parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){\n\tfunction fixedFromCharCode(code) {\n\t\t// String.prototype.fromCharCode does not supports\n\t\t// > 2 bytes unicode chars directly\n\t\tif (code > 0xffff) {\n\t\t\tcode -= 0x10000;\n\t\t\tvar surrogate1 = 0xd800 + (code >> 10)\n\t\t\t\t, surrogate2 = 0xdc00 + (code & 0x3ff);\n\n\t\t\treturn String.fromCharCode(surrogate1, surrogate2);\n\t\t} else {\n\t\t\treturn String.fromCharCode(code);\n\t\t}\n\t}\n\tfunction entityReplacer(a){\n\t\tvar k = a.slice(1,-1);\n\t\tif(k in entityMap){\n\t\t\treturn entityMap[k];\n\t\t}else if(k.charAt(0) === '#'){\n\t\t\treturn fixedFromCharCode(parseInt(k.substr(1).replace('x','0x')))\n\t\t}else{\n\t\t\terrorHandler.error('entity not found:'+a);\n\t\t\treturn a;\n\t\t}\n\t}\n\tfunction appendText(end){//has some bugs\n\t\tif(end>start){\n\t\t\tvar xt = source.substring(start,end).replace(/?\\w+;/g,entityReplacer);\n\t\t\tlocator&&position(start);\n\t\t\tdomBuilder.characters(xt,0,end-start);\n\t\t\tstart = end\n\t\t}\n\t}\n\tfunction position(p,m){\n\t\twhile(p>=lineEnd && (m = linePattern.exec(source))){\n\t\t\tlineStart = m.index;\n\t\t\tlineEnd = lineStart + m[0].length;\n\t\t\tlocator.lineNumber++;\n\t\t\t//console.log('line++:',locator,startPos,endPos)\n\t\t}\n\t\tlocator.columnNumber = p-lineStart+1;\n\t}\n\tvar lineStart = 0;\n\tvar lineEnd = 0;\n\tvar linePattern = /.*(?:\\r\\n?|\\n)|.*$/g\n\tvar locator = domBuilder.locator;\n\n\tvar parseStack = [{currentNSMap:defaultNSMapCopy}]\n\tvar closeMap = {};\n\tvar start = 0;\n\twhile(true){\n\t\ttry{\n\t\t\tvar tagStart = source.indexOf('<',start);\n\t\t\tif(tagStart<0){\n\t\t\t\tif(!source.substr(start).match(/^\\s*$/)){\n\t\t\t\t\tvar doc = domBuilder.doc;\n\t \t\t\tvar text = doc.createTextNode(source.substr(start));\n\t \t\t\tdoc.appendChild(text);\n\t \t\t\tdomBuilder.currentElement = text;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif(tagStart>start){\n\t\t\t\tappendText(tagStart);\n\t\t\t}\n\t\t\tswitch(source.charAt(tagStart+1)){\n\t\t\tcase '/':\n\t\t\t\tvar end = source.indexOf('>',tagStart+3);\n\t\t\t\tvar tagName = source.substring(tagStart + 2, end).replace(/[ \\t\\n\\r]+$/g, '');\n\t\t\t\tvar config = parseStack.pop();\n\t\t\t\tif(end<0){\n\n\t \t\ttagName = source.substring(tagStart+2).replace(/[\\s<].*/,'');\n\t \t\terrorHandler.error(\"end tag name: \"+tagName+' is not complete:'+config.tagName);\n\t \t\tend = tagStart+1+tagName.length;\n\t \t}else if(tagName.match(/\\s)){\n\t \t\ttagName = tagName.replace(/[\\s<].*/,'');\n\t \t\terrorHandler.error(\"end tag name: \"+tagName+' maybe not complete');\n\t \t\tend = tagStart+1+tagName.length;\n\t\t\t\t}\n\t\t\t\tvar localNSMap = config.localNSMap;\n\t\t\t\tvar endMatch = config.tagName == tagName;\n\t\t\t\tvar endIgnoreCaseMach = endMatch || config.tagName&&config.tagName.toLowerCase() == tagName.toLowerCase()\n\t\t if(endIgnoreCaseMach){\n\t\t \tdomBuilder.endElement(config.uri,config.localName,tagName);\n\t\t\t\t\tif(localNSMap){\n\t\t\t\t\t\tfor(var prefix in localNSMap) {\n\t\t\t\t\t\t\tif (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {\n\t\t\t\t\t\t\t\tdomBuilder.endPrefixMapping(prefix);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif(!endMatch){\n\t\t \terrorHandler.fatalError(\"end tag name: \"+tagName+' is not match the current start tagName:'+config.tagName ); // No known test case\n\t\t\t\t\t}\n\t\t }else{\n\t\t \tparseStack.push(config)\n\t\t }\n\n\t\t\t\tend++;\n\t\t\t\tbreak;\n\t\t\t\t// end elment\n\t\t\tcase '?':// ...?>\n\t\t\t\tlocator&&position(tagStart);\n\t\t\t\tend = parseInstruction(source,tagStart,domBuilder);\n\t\t\t\tbreak;\n\t\t\tcase '!':// start){\n\t\t\tstart = end;\n\t\t}else{\n\t\t\t//TODO: 这里有可能sax回退,有位置错误风险\n\t\t\tappendText(Math.max(tagStart,start)+1);\n\t\t}\n\t}\n}\nfunction copyLocator(f,t){\n\tt.lineNumber = f.lineNumber;\n\tt.columnNumber = f.columnNumber;\n\treturn t;\n}\n\n/**\n * @see #appendElement(source,elStartEnd,el,selfClosed,entityReplacer,domBuilder,parseStack);\n * @return end of the elementStartPart(end of elementEndPart for selfClosed el)\n */\nfunction parseElementStartPart(source,start,el,currentNSMap,entityReplacer,errorHandler){\n\n\t/**\n\t * @param {string} qname\n\t * @param {string} value\n\t * @param {number} startIndex\n\t */\n\tfunction addAttribute(qname, value, startIndex) {\n\t\tif (el.attributeNames.hasOwnProperty(qname)) {\n\t\t\terrorHandler.fatalError('Attribute ' + qname + ' redefined')\n\t\t}\n\t\tel.addValue(qname, value, startIndex)\n\t}\n\tvar attrName;\n\tvar value;\n\tvar p = ++start;\n\tvar s = S_TAG;//status\n\twhile(true){\n\t\tvar c = source.charAt(p);\n\t\tswitch(c){\n\t\tcase '=':\n\t\t\tif(s === S_ATTR){//attrName\n\t\t\t\tattrName = source.slice(start,p);\n\t\t\t\ts = S_EQ;\n\t\t\t}else if(s === S_ATTR_SPACE){\n\t\t\t\ts = S_EQ;\n\t\t\t}else{\n\t\t\t\t//fatalError: equal must after attrName or space after attrName\n\t\t\t\tthrow new Error('attribute equal must after attrName'); // No known test case\n\t\t\t}\n\t\t\tbreak;\n\t\tcase '\\'':\n\t\tcase '\"':\n\t\t\tif(s === S_EQ || s === S_ATTR //|| s == S_ATTR_SPACE\n\t\t\t\t){//equal\n\t\t\t\tif(s === S_ATTR){\n\t\t\t\t\terrorHandler.warning('attribute value must after \"=\"')\n\t\t\t\t\tattrName = source.slice(start,p)\n\t\t\t\t}\n\t\t\t\tstart = p+1;\n\t\t\t\tp = source.indexOf(c,start)\n\t\t\t\tif(p>0){\n\t\t\t\t\tvalue = source.slice(start,p).replace(/?\\w+;/g,entityReplacer);\n\t\t\t\t\taddAttribute(attrName, value, start-1);\n\t\t\t\t\ts = S_ATTR_END;\n\t\t\t\t}else{\n\t\t\t\t\t//fatalError: no end quot match\n\t\t\t\t\tthrow new Error('attribute value no end \\''+c+'\\' match');\n\t\t\t\t}\n\t\t\t}else if(s == S_ATTR_NOQUOT_VALUE){\n\t\t\t\tvalue = source.slice(start,p).replace(/?\\w+;/g,entityReplacer);\n\t\t\t\t//console.log(attrName,value,start,p)\n\t\t\t\taddAttribute(attrName, value, start);\n\t\t\t\t//console.dir(el)\n\t\t\t\terrorHandler.warning('attribute \"'+attrName+'\" missed start quot('+c+')!!');\n\t\t\t\tstart = p+1;\n\t\t\t\ts = S_ATTR_END\n\t\t\t}else{\n\t\t\t\t//fatalError: no equal before\n\t\t\t\tthrow new Error('attribute value must after \"=\"'); // No known test case\n\t\t\t}\n\t\t\tbreak;\n\t\tcase '/':\n\t\t\tswitch(s){\n\t\t\tcase S_TAG:\n\t\t\t\tel.setTagName(source.slice(start,p));\n\t\t\tcase S_ATTR_END:\n\t\t\tcase S_TAG_SPACE:\n\t\t\tcase S_TAG_CLOSE:\n\t\t\t\ts =S_TAG_CLOSE;\n\t\t\t\tel.closed = true;\n\t\t\tcase S_ATTR_NOQUOT_VALUE:\n\t\t\tcase S_ATTR:\n\t\t\t\tbreak;\n\t\t\t\tcase S_ATTR_SPACE:\n\t\t\t\t\tel.closed = true;\n\t\t\t\tbreak;\n\t\t\t//case S_EQ:\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"attribute invalid close char('/')\") // No known test case\n\t\t\t}\n\t\t\tbreak;\n\t\tcase ''://end document\n\t\t\terrorHandler.error('unexpected end of input');\n\t\t\tif(s == S_TAG){\n\t\t\t\tel.setTagName(source.slice(start,p));\n\t\t\t}\n\t\t\treturn p;\n\t\tcase '>':\n\t\t\tswitch(s){\n\t\t\tcase S_TAG:\n\t\t\t\tel.setTagName(source.slice(start,p));\n\t\t\tcase S_ATTR_END:\n\t\t\tcase S_TAG_SPACE:\n\t\t\tcase S_TAG_CLOSE:\n\t\t\t\tbreak;//normal\n\t\t\tcase S_ATTR_NOQUOT_VALUE://Compatible state\n\t\t\tcase S_ATTR:\n\t\t\t\tvalue = source.slice(start,p);\n\t\t\t\tif(value.slice(-1) === '/'){\n\t\t\t\t\tel.closed = true;\n\t\t\t\t\tvalue = value.slice(0,-1)\n\t\t\t\t}\n\t\t\tcase S_ATTR_SPACE:\n\t\t\t\tif(s === S_ATTR_SPACE){\n\t\t\t\t\tvalue = attrName;\n\t\t\t\t}\n\t\t\t\tif(s == S_ATTR_NOQUOT_VALUE){\n\t\t\t\t\terrorHandler.warning('attribute \"'+value+'\" missed quot(\")!');\n\t\t\t\t\taddAttribute(attrName, value.replace(/?\\w+;/g,entityReplacer), start)\n\t\t\t\t}else{\n\t\t\t\t\tif(!NAMESPACE.isHTML(currentNSMap['']) || !value.match(/^(?:disabled|checked|selected)$/i)){\n\t\t\t\t\t\terrorHandler.warning('attribute \"'+value+'\" missed value!! \"'+value+'\" instead!!')\n\t\t\t\t\t}\n\t\t\t\t\taddAttribute(value, value, start)\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase S_EQ:\n\t\t\t\tthrow new Error('attribute value missed!!');\n\t\t\t}\n//\t\t\tconsole.log(tagName,tagNamePattern,tagNamePattern.test(tagName))\n\t\t\treturn p;\n\t\t/*xml space '\\x20' | #x9 | #xD | #xA; */\n\t\tcase '\\u0080':\n\t\t\tc = ' ';\n\t\tdefault:\n\t\t\tif(c<= ' '){//space\n\t\t\t\tswitch(s){\n\t\t\t\tcase S_TAG:\n\t\t\t\t\tel.setTagName(source.slice(start,p));//tagName\n\t\t\t\t\ts = S_TAG_SPACE;\n\t\t\t\t\tbreak;\n\t\t\t\tcase S_ATTR:\n\t\t\t\t\tattrName = source.slice(start,p)\n\t\t\t\t\ts = S_ATTR_SPACE;\n\t\t\t\t\tbreak;\n\t\t\t\tcase S_ATTR_NOQUOT_VALUE:\n\t\t\t\t\tvar value = source.slice(start,p).replace(/?\\w+;/g,entityReplacer);\n\t\t\t\t\terrorHandler.warning('attribute \"'+value+'\" missed quot(\")!!');\n\t\t\t\t\taddAttribute(attrName, value, start)\n\t\t\t\tcase S_ATTR_END:\n\t\t\t\t\ts = S_TAG_SPACE;\n\t\t\t\t\tbreak;\n\t\t\t\t//case S_TAG_SPACE:\n\t\t\t\t//case S_EQ:\n\t\t\t\t//case S_ATTR_SPACE:\n\t\t\t\t//\tvoid();break;\n\t\t\t\t//case S_TAG_CLOSE:\n\t\t\t\t\t//ignore warning\n\t\t\t\t}\n\t\t\t}else{//not space\n//S_TAG,\tS_ATTR,\tS_EQ,\tS_ATTR_NOQUOT_VALUE\n//S_ATTR_SPACE,\tS_ATTR_END,\tS_TAG_SPACE, S_TAG_CLOSE\n\t\t\t\tswitch(s){\n\t\t\t\t//case S_TAG:void();break;\n\t\t\t\t//case S_ATTR:void();break;\n\t\t\t\t//case S_ATTR_NOQUOT_VALUE:void();break;\n\t\t\t\tcase S_ATTR_SPACE:\n\t\t\t\t\tvar tagName = el.tagName;\n\t\t\t\t\tif (!NAMESPACE.isHTML(currentNSMap['']) || !attrName.match(/^(?:disabled|checked|selected)$/i)) {\n\t\t\t\t\t\terrorHandler.warning('attribute \"'+attrName+'\" missed value!! \"'+attrName+'\" instead2!!')\n\t\t\t\t\t}\n\t\t\t\t\taddAttribute(attrName, attrName, start);\n\t\t\t\t\tstart = p;\n\t\t\t\t\ts = S_ATTR;\n\t\t\t\t\tbreak;\n\t\t\t\tcase S_ATTR_END:\n\t\t\t\t\terrorHandler.warning('attribute space is required\"'+attrName+'\"!!')\n\t\t\t\tcase S_TAG_SPACE:\n\t\t\t\t\ts = S_ATTR;\n\t\t\t\t\tstart = p;\n\t\t\t\t\tbreak;\n\t\t\t\tcase S_EQ:\n\t\t\t\t\ts = S_ATTR_NOQUOT_VALUE;\n\t\t\t\t\tstart = p;\n\t\t\t\t\tbreak;\n\t\t\t\tcase S_TAG_CLOSE:\n\t\t\t\t\tthrow new Error(\"elements closed character '/' and '>' must be connected to\");\n\t\t\t\t}\n\t\t\t}\n\t\t}//end outer switch\n\t\t//console.log('p++',p)\n\t\tp++;\n\t}\n}\n/**\n * @return true if has new namespace define\n */\nfunction appendElement(el,domBuilder,currentNSMap){\n\tvar tagName = el.tagName;\n\tvar localNSMap = null;\n\t//var currentNSMap = parseStack[parseStack.length-1].currentNSMap;\n\tvar i = el.length;\n\twhile(i--){\n\t\tvar a = el[i];\n\t\tvar qName = a.qName;\n\t\tvar value = a.value;\n\t\tvar nsp = qName.indexOf(':');\n\t\tif(nsp>0){\n\t\t\tvar prefix = a.prefix = qName.slice(0,nsp);\n\t\t\tvar localName = qName.slice(nsp+1);\n\t\t\tvar nsPrefix = prefix === 'xmlns' && localName\n\t\t}else{\n\t\t\tlocalName = qName;\n\t\t\tprefix = null\n\t\t\tnsPrefix = qName === 'xmlns' && ''\n\t\t}\n\t\t//can not set prefix,because prefix !== ''\n\t\ta.localName = localName ;\n\t\t//prefix == null for no ns prefix attribute\n\t\tif(nsPrefix !== false){//hack!!\n\t\t\tif(localNSMap == null){\n\t\t\t\tlocalNSMap = {}\n\t\t\t\t//console.log(currentNSMap,0)\n\t\t\t\t_copy(currentNSMap,currentNSMap={})\n\t\t\t\t//console.log(currentNSMap,1)\n\t\t\t}\n\t\t\tcurrentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;\n\t\t\ta.uri = NAMESPACE.XMLNS\n\t\t\tdomBuilder.startPrefixMapping(nsPrefix, value)\n\t\t}\n\t}\n\tvar i = el.length;\n\twhile(i--){\n\t\ta = el[i];\n\t\tvar prefix = a.prefix;\n\t\tif(prefix){//no prefix attribute has no namespace\n\t\t\tif(prefix === 'xml'){\n\t\t\t\ta.uri = NAMESPACE.XML;\n\t\t\t}if(prefix !== 'xmlns'){\n\t\t\t\ta.uri = currentNSMap[prefix || '']\n\n\t\t\t\t//{console.log('###'+a.qName,domBuilder.locator.systemId+'',currentNSMap,a.uri)}\n\t\t\t}\n\t\t}\n\t}\n\tvar nsp = tagName.indexOf(':');\n\tif(nsp>0){\n\t\tprefix = el.prefix = tagName.slice(0,nsp);\n\t\tlocalName = el.localName = tagName.slice(nsp+1);\n\t}else{\n\t\tprefix = null;//important!!\n\t\tlocalName = el.localName = tagName;\n\t}\n\t//no prefix element has default namespace\n\tvar ns = el.uri = currentNSMap[prefix || ''];\n\tdomBuilder.startElement(ns,localName,tagName,el);\n\t//endPrefixMapping and startPrefixMapping have not any help for dom builder\n\t//localNSMap = null\n\tif(el.closed){\n\t\tdomBuilder.endElement(ns,localName,tagName);\n\t\tif(localNSMap){\n\t\t\tfor (prefix in localNSMap) {\n\t\t\t\tif (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {\n\t\t\t\t\tdomBuilder.endPrefixMapping(prefix);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}else{\n\t\tel.currentNSMap = currentNSMap;\n\t\tel.localNSMap = localNSMap;\n\t\t//parseStack.push(el);\n\t\treturn true;\n\t}\n}\nfunction parseHtmlSpecialContent(source,elStartEnd,tagName,entityReplacer,domBuilder){\n\tif(/^(?:script|textarea)$/i.test(tagName)){\n\t\tvar elEndStart = source.indexOf(''+tagName+'>',elStartEnd);\n\t\tvar text = source.substring(elStartEnd+1,elEndStart);\n\t\tif(/[&<]/.test(text)){\n\t\t\tif(/^script$/i.test(tagName)){\n\t\t\t\t//if(!/\\]\\]>/.test(text)){\n\t\t\t\t\t//lexHandler.startCDATA();\n\t\t\t\t\tdomBuilder.characters(text,0,text.length);\n\t\t\t\t\t//lexHandler.endCDATA();\n\t\t\t\t\treturn elEndStart;\n\t\t\t\t//}\n\t\t\t}//}else{//text area\n\t\t\t\ttext = text.replace(/?\\w+;/g,entityReplacer);\n\t\t\t\tdomBuilder.characters(text,0,text.length);\n\t\t\t\treturn elEndStart;\n\t\t\t//}\n\n\t\t}\n\t}\n\treturn elStartEnd+1;\n}\nfunction fixSelfClosed(source,elStartEnd,tagName,closeMap){\n\t//if(tagName in closeMap){\n\tvar pos = closeMap[tagName];\n\tif(pos == null){\n\t\t//console.log(tagName)\n\t\tpos = source.lastIndexOf(''+tagName+'>')\n\t\tif(pos',start+4);\n\t\t\t//append comment source.substring(4,end)// https://davidwalsh.name/add-rules-stylesheets\n\t\tstyle.appendChild(document.createTextNode(\"\"));\n\n\t\tdocument.head.appendChild(style);\n\n\t\treturn style.sheet;\n\t}\n\n\taddStyleRules(selector, rulesArray){\n\t\tvar scope = \"#\" + this.id + \" \";\n\t\tvar rules = \"\";\n\n\t\tif(!this.sheet){\n\t\t\tthis.sheet = this.getSheet();\n\t\t}\n\n\t\trulesArray.forEach(function(set) {\n\t\t\tfor (var prop in set) {\n\t\t\t\tif(set.hasOwnProperty(prop)) {\n\t\t\t\t\trules += prop + \":\" + set[prop] + \";\";\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis.sheet.insertRule(scope + selector + \" {\" + rules + \"}\", 0);\n\t}\n\n\taxis(axis) {\n\t\tif(axis === \"horizontal\") {\n\t\t\tthis.container.style.display = \"flex\";\n\t\t\tthis.container.style.flexDirection = \"row\";\n\t\t\tthis.container.style.flexWrap = \"nowrap\";\n\t\t} else {\n\t\t\tthis.container.style.display = \"block\";\n\t\t}\n\t\tthis.settings.axis = axis;\n\t}\n\n\t// orientation(orientation) {\n\t// \tif (orientation === \"landscape\") {\n\t//\n\t// \t} else {\n\t//\n\t// \t}\n\t//\n\t// \tthis.orientation = orientation;\n\t// }\n\n\tdirection(dir) {\n\t\tif (this.container) {\n\t\t\tthis.container.dir = dir;\n\t\t\tthis.container.style[\"direction\"] = dir;\n\t\t}\n\n\t\tif (this.settings.fullsize) {\n\t\t\tdocument.body.style[\"direction\"] = dir;\n\t\t}\n\t\tthis.settings.dir = dir;\n\t}\n\n\toverflow(overflow) {\n\t\tif (this.container) {\n\t\t\tif (overflow === \"scroll\" && this.settings.axis === \"vertical\") {\n\t\t\t\tthis.container.style[\"overflow-y\"] = overflow;\n\t\t\t\tthis.container.style[\"overflow-x\"] = \"hidden\";\n\t\t\t} else if (overflow === \"scroll\" && this.settings.axis === \"horizontal\") {\n\t\t\t\tthis.container.style[\"overflow-y\"] = \"hidden\";\n\t\t\t\tthis.container.style[\"overflow-x\"] = overflow;\n\t\t\t} else {\n\t\t\t\tthis.container.style[\"overflow\"] = overflow;\n\t\t\t}\n\t\t}\n\t\tthis.settings.overflow = overflow;\n\t}\n\n\tdestroy() {\n\t\tvar base;\n\n\t\tif (this.element) {\n\n\t\t\tif(this.settings.hidden) {\n\t\t\t\tbase = this.wrapper;\n\t\t\t} else {\n\t\t\t\tbase = this.container;\n\t\t\t}\n\n\t\t\tif(this.element.contains(this.container)) {\n\t\t\t\tthis.element.removeChild(this.container);\n\t\t\t}\n\n\t\t\twindow.removeEventListener(\"resize\", this.resizeFunc);\n\t\t\twindow.removeEventListener(\"orientationChange\", this.orientationChangeFunc);\n\n\t\t}\n\t}\n}\n\nexport default Stage;\n","class Views {\n\tconstructor(container) {\n\t\tthis.container = container;\n\t\tthis._views = [];\n\t\tthis.length = 0;\n\t\tthis.hidden = false;\n\t}\n\n\tall() {\n\t\treturn this._views;\n\t}\n\n\tfirst() {\n\t\treturn this._views[0];\n\t}\n\n\tlast() {\n\t\treturn this._views[this._views.length-1];\n\t}\n\n\tindexOf(view) {\n\t\treturn this._views.indexOf(view);\n\t}\n\n\tslice() {\n\t\treturn this._views.slice.apply(this._views, arguments);\n\t}\n\n\tget(i) {\n\t\treturn this._views[i];\n\t}\n\n\tappend(view){\n\t\tthis._views.push(view);\n\t\tif(this.container){\n\t\t\tthis.container.appendChild(view.element);\n\t\t}\n\t\tthis.length++;\n\t\treturn view;\n\t}\n\n\tprepend(view){\n\t\tthis._views.unshift(view);\n\t\tif(this.container){\n\t\t\tthis.container.insertBefore(view.element, this.container.firstChild);\n\t\t}\n\t\tthis.length++;\n\t\treturn view;\n\t}\n\n\tinsert(view, index) {\n\t\tthis._views.splice(index, 0, view);\n\n\t\tif(this.container){\n\t\t\tif(index < this.container.children.length){\n\t\t\t\tthis.container.insertBefore(view.element, this.container.children[index]);\n\t\t\t} else {\n\t\t\t\tthis.container.appendChild(view.element);\n\t\t\t}\n\t\t}\n\n\t\tthis.length++;\n\t\treturn view;\n\t}\n\n\tremove(view) {\n\t\tvar index = this._views.indexOf(view);\n\n\t\tif(index > -1) {\n\t\t\tthis._views.splice(index, 1);\n\t\t}\n\n\n\t\tthis.destroy(view);\n\n\t\tthis.length--;\n\t}\n\n\tdestroy(view) {\n\t\tif(view.displayed){\n\t\t\tview.destroy();\n\t\t}\n\t\t\n\t\tif(this.container){\n\t\t\t this.container.removeChild(view.element);\n\t\t}\n\t\tview = null;\n\t}\n\n\t// Iterators\n\n\tforEach() {\n\t\treturn this._views.forEach.apply(this._views, arguments);\n\t}\n\n\tclear(){\n\t\t// Remove all views\n\t\tvar view;\n\t\tvar len = this.length;\n\n\t\tif(!this.length) return;\n\n\t\tfor (var i = 0; i < len; i++) {\n\t\t\tview = this._views[i];\n\t\t\tthis.destroy(view);\n\t\t}\n\n\t\tthis._views = [];\n\t\tthis.length = 0;\n\t}\n\n\tfind(section){\n\n\t\tvar view;\n\t\tvar len = this.length;\n\n\t\tfor (var i = 0; i < len; i++) {\n\t\t\tview = this._views[i];\n\t\t\tif(view.displayed && view.section.index == section.index) {\n\t\t\t\treturn view;\n\t\t\t}\n\t\t}\n\n\t}\n\n\tdisplayed(){\n\t\tvar displayed = [];\n\t\tvar view;\n\t\tvar len = this.length;\n\n\t\tfor (var i = 0; i < len; i++) {\n\t\t\tview = this._views[i];\n\t\t\tif(view.displayed){\n\t\t\t\tdisplayed.push(view);\n\t\t\t}\n\t\t}\n\t\treturn displayed;\n\t}\n\n\tshow(){\n\t\tvar view;\n\t\tvar len = this.length;\n\n\t\tfor (var i = 0; i < len; i++) {\n\t\t\tview = this._views[i];\n\t\t\tif(view.displayed){\n\t\t\t\tview.show();\n\t\t\t}\n\t\t}\n\t\tthis.hidden = false;\n\t}\n\n\thide(){\n\t\tvar view;\n\t\tvar len = this.length;\n\n\t\tfor (var i = 0; i < len; i++) {\n\t\t\tview = this._views[i];\n\t\t\tif(view.displayed){\n\t\t\t\tview.hide();\n\t\t\t}\n\t\t}\n\t\tthis.hidden = true;\n\t}\n}\n\nexport default Views;\n","import EventEmitter from \"event-emitter\";\nimport {extend, defer, windowBounds, isNumber} from \"../../utils/core\";\nimport scrollType from \"../../utils/scrolltype\";\nimport Mapping from \"../../mapping\";\nimport Queue from \"../../utils/queue\";\nimport Stage from \"../helpers/stage\";\nimport Views from \"../helpers/views\";\nimport { EVENTS } from \"../../utils/constants\";\n\nclass DefaultViewManager {\n\tconstructor(options) {\n\n\t\tthis.name = \"default\";\n\t\tthis.optsSettings = options.settings;\n\t\tthis.View = options.view;\n\t\tthis.request = options.request;\n\t\tthis.renditionQueue = options.queue;\n\t\tthis.q = new Queue(this);\n\n\t\tthis.settings = extend(this.settings || {}, {\n\t\t\tinfinite: true,\n\t\t\thidden: false,\n\t\t\twidth: undefined,\n\t\t\theight: undefined,\n\t\t\taxis: undefined,\n\t\t\twritingMode: undefined,\n\t\t\tflow: \"scrolled\",\n\t\t\tignoreClass: \"\",\n\t\t\tfullsize: undefined,\n\t\t\tallowScriptedContent: false,\n\t\t\tallowPopups: false\n\t\t});\n\n\t\textend(this.settings, options.settings || {});\n\n\t\tthis.viewSettings = {\n\t\t\tignoreClass: this.settings.ignoreClass,\n\t\t\taxis: this.settings.axis,\n\t\t\tflow: this.settings.flow,\n\t\t\tlayout: this.layout,\n\t\t\tmethod: this.settings.method, // srcdoc, blobUrl, write\n\t\t\twidth: 0,\n\t\t\theight: 0,\n\t\t\tforceEvenPages: true,\n\t\t\tallowScriptedContent: this.settings.allowScriptedContent,\n\t\t\tallowPopups: this.settings.allowPopups\n\t\t};\n\n\t\tthis.rendered = false;\n\n\t}\n\n\trender(element, size){\n\t\tlet tag = element.tagName;\n\n\t\tif (typeof this.settings.fullsize === \"undefined\" &&\n\t\t\t\ttag && (tag.toLowerCase() == \"body\" ||\n\t\t\t\ttag.toLowerCase() == \"html\")) {\n\t\t\t\tthis.settings.fullsize = true;\n\t\t}\n\n\t\tif (this.settings.fullsize) {\n\t\t\tthis.settings.overflow = \"visible\";\n\t\t\tthis.overflow = this.settings.overflow;\n\t\t}\n\n\t\tthis.settings.size = size;\n\n\t\tthis.settings.rtlScrollType = scrollType();\n\n\t\t// Save the stage\n\t\tthis.stage = new Stage({\n\t\t\twidth: size.width,\n\t\t\theight: size.height,\n\t\t\toverflow: this.overflow,\n\t\t\thidden: this.settings.hidden,\n\t\t\taxis: this.settings.axis,\n\t\t\tfullsize: this.settings.fullsize,\n\t\t\tdirection: this.settings.direction\n\t\t});\n\n\t\tthis.stage.attachTo(element);\n\n\t\t// Get this stage container div\n\t\tthis.container = this.stage.getContainer();\n\n\t\t// Views array methods\n\t\tthis.views = new Views(this.container);\n\n\t\t// Calculate Stage Size\n\t\tthis._bounds = this.bounds();\n\t\tthis._stageSize = this.stage.size();\n\n\t\t// Set the dimensions for views\n\t\tthis.viewSettings.width = this._stageSize.width;\n\t\tthis.viewSettings.height = this._stageSize.height;\n\n\t\t// Function to handle a resize event.\n\t\t// Will only attach if width and height are both fixed.\n\t\tthis.stage.onResize(this.onResized.bind(this));\n\n\t\tthis.stage.onOrientationChange(this.onOrientationChange.bind(this));\n\n\t\t// Add Event Listeners\n\t\tthis.addEventListeners();\n\n\t\t// Add Layout method\n\t\t// this.applyLayoutMethod();\n\t\tif (this.layout) {\n\t\t\tthis.updateLayout();\n\t\t}\n\n\t\tthis.rendered = true;\n\n\t}\n\n\taddEventListeners(){\n\t\tvar scroller;\n\n\t\twindow.addEventListener(\"unload\", function(e){\n\t\t\tthis.destroy();\n\t\t}.bind(this));\n\n\t\tif(!this.settings.fullsize) {\n\t\t\tscroller = this.container;\n\t\t} else {\n\t\t\tscroller = window;\n\t\t}\n\n\t\tthis._onScroll = this.onScroll.bind(this);\n\t\tscroller.addEventListener(\"scroll\", this._onScroll);\n\t}\n\n\tremoveEventListeners(){\n\t\tvar scroller;\n\n\t\tif(!this.settings.fullsize) {\n\t\t\tscroller = this.container;\n\t\t} else {\n\t\t\tscroller = window;\n\t\t}\n\n\t\tscroller.removeEventListener(\"scroll\", this._onScroll);\n\t\tthis._onScroll = undefined;\n\t}\n\n\tdestroy(){\n\t\tclearTimeout(this.orientationTimeout);\n\t\tclearTimeout(this.resizeTimeout);\n\t\tclearTimeout(this.afterScrolled);\n\n\t\tthis.clear();\n\n\t\tthis.removeEventListeners();\n\n\t\tthis.stage.destroy();\n\n\t\tthis.rendered = false;\n\n\t\t/*\n\n\t\t\tclearTimeout(this.trimTimeout);\n\t\t\tif(this.settings.hidden) {\n\t\t\t\tthis.element.removeChild(this.wrapper);\n\t\t\t} else {\n\t\t\t\tthis.element.removeChild(this.container);\n\t\t\t}\n\t\t*/\n\t}\n\n\tonOrientationChange(e) {\n\t\tlet {orientation} = window;\n\n\t\tif(this.optsSettings.resizeOnOrientationChange) {\n\t\t\tthis.resize();\n\t\t}\n\n\t\t// Per ampproject:\n\t\t// In IOS 10.3, the measured size of an element is incorrect if the\n\t\t// element size depends on window size directly and the measurement\n\t\t// happens in window.resize event. Adding a timeout for correct\n\t\t// measurement. See https://github.com/ampproject/amphtml/issues/8479\n\t\tclearTimeout(this.orientationTimeout);\n\t\tthis.orientationTimeout = setTimeout(function(){\n\t\t\tthis.orientationTimeout = undefined;\n\n\t\t\tif(this.optsSettings.resizeOnOrientationChange) {\n\t\t\t\tthis.resize();\n\t\t\t}\n\n\t\t\tthis.emit(EVENTS.MANAGERS.ORIENTATION_CHANGE, orientation);\n\t\t}.bind(this), 500);\n\n\t}\n\n\tonResized(e) {\n\t\tthis.resize();\n\t}\n\n\tresize(width, height, epubcfi){\n\t\tlet stageSize = this.stage.size(width, height);\n\n\t\t// For Safari, wait for orientation to catch up\n\t\t// if the window is a square\n\t\tthis.winBounds = windowBounds();\n\t\tif (this.orientationTimeout &&\n\t\t\t\tthis.winBounds.width === this.winBounds.height) {\n\t\t\t// reset the stage size for next resize\n\t\t\tthis._stageSize = undefined;\n\t\t\treturn;\n\t\t}\n\n\t\tif (this._stageSize &&\n\t\t\t\tthis._stageSize.width === stageSize.width &&\n\t\t\t\tthis._stageSize.height === stageSize.height ) {\n\t\t\t// Size is the same, no need to resize\n\t\t\treturn;\n\t\t}\n\n\t\tthis._stageSize = stageSize;\n\n\t\tthis._bounds = this.bounds();\n\n\t\t// Clear current views\n\t\tthis.clear();\n\n\t\t// Update for new views\n\t\tthis.viewSettings.width = this._stageSize.width;\n\t\tthis.viewSettings.height = this._stageSize.height;\n\n\t\tthis.updateLayout();\n\n\t\tthis.emit(EVENTS.MANAGERS.RESIZED, {\n\t\t\twidth: this._stageSize.width,\n\t\t\theight: this._stageSize.height\n\t\t}, epubcfi);\n\t}\n\n\tcreateView(section, forceRight) {\n\t\treturn new this.View(section, extend(this.viewSettings, { forceRight }) );\n\t}\n\n\thandleNextPrePaginated(forceRight, section, action) {\n\t\tlet next;\n\n\t\tif (this.layout.name === \"pre-paginated\" && this.layout.divisor > 1) {\n\t\t\tif (forceRight || section.index === 0) {\n\t\t\t\t// First page (cover) should stand alone for pre-paginated books\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tnext = section.next();\n\t\t\tif (next && !next.properties.includes(\"page-spread-left\")) {\n\t\t\t\treturn action.call(this, next);\n\t\t\t}\n\t\t}\n\t}\n\n\tdisplay(section, target){\n\n\t\tvar displaying = new defer();\n\t\tvar displayed = displaying.promise;\n\n\t\t// Check if moving to target is needed\n\t\tif (target === section.href || isNumber(target)) {\n\t\t\ttarget = undefined;\n\t\t}\n\n\t\t// Check to make sure the section we want isn't already shown\n\t\tvar visible = this.views.find(section);\n\n\t\t// View is already shown, just move to correct location in view\n\t\tif(visible && section && this.layout.name !== \"pre-paginated\") {\n\t\t\tlet offset = visible.offset();\n\n\t\t\tif (this.settings.direction === \"ltr\") {\n\t\t\t\tthis.scrollTo(offset.left, offset.top, true);\n\t\t\t} else {\n\t\t\t\tlet width = visible.width();\n\t\t\t\tthis.scrollTo(offset.left + width, offset.top, true);\n\t\t\t}\n\n\t\t\tif(target) {\n\t\t\t\tlet offset = visible.locationOf(target);\n\t\t\t\tlet width = visible.width();\n\t\t\t\tthis.moveTo(offset, width);\n\t\t\t}\n\n\t\t\tdisplaying.resolve();\n\t\t\treturn displayed;\n\t\t}\n\n\t\t// Hide all current views\n\t\tthis.clear();\n\n\t\tlet forceRight = false;\n\t\tif (this.layout.name === \"pre-paginated\" && this.layout.divisor === 2 && section.properties.includes(\"page-spread-right\")) {\n\t\t\tforceRight = true;\n\t\t}\n\n\t\tthis.add(section, forceRight)\n\t\t\t.then(function(view){\n\n\t\t\t\t// Move to correct place within the section, if needed\n\t\t\t\tif(target) {\n\t\t\t\t\tlet offset = view.locationOf(target);\n\t\t\t\t\tlet width = view.width();\n\t\t\t\t\tthis.moveTo(offset, width);\n\t\t\t\t}\n\n\t\t\t}.bind(this), (err) => {\n\t\t\t\tdisplaying.reject(err);\n\t\t\t})\n\t\t\t.then(function(){\n\t\t\t\treturn this.handleNextPrePaginated(forceRight, section, this.add);\n\t\t\t}.bind(this))\n\t\t\t.then(function(){\n\n\t\t\t\tthis.views.show();\n\n\t\t\t\tdisplaying.resolve();\n\n\t\t\t}.bind(this));\n\t\t// .then(function(){\n\t\t// \treturn this.hooks.display.trigger(view);\n\t\t// }.bind(this))\n\t\t// .then(function(){\n\t\t// \tthis.views.show();\n\t\t// }.bind(this));\n\t\treturn displayed;\n\t}\n\n\tafterDisplayed(view){\n\t\tthis.emit(EVENTS.MANAGERS.ADDED, view);\n\t}\n\n\tafterResized(view){\n\t\tthis.emit(EVENTS.MANAGERS.RESIZE, view.section);\n\t}\n\n\tmoveTo(offset, width){\n\t\tvar distX = 0,\n\t\t\t\tdistY = 0;\n\n\t\tif(!this.isPaginated) {\n\t\t\tdistY = offset.top;\n\t\t} else {\n\t\t\tdistX = Math.floor(offset.left / this.layout.delta) * this.layout.delta;\n\n\t\t\tif (distX + this.layout.delta > this.container.scrollWidth) {\n\t\t\t\tdistX = this.container.scrollWidth - this.layout.delta;\n\t\t\t}\n\n\t\t\tdistY = Math.floor(offset.top / this.layout.delta) * this.layout.delta;\n\n\t\t\tif (distY + this.layout.delta > this.container.scrollHeight) {\n\t\t\t\tdistY = this.container.scrollHeight - this.layout.delta;\n\t\t\t}\n\t\t}\n\t\tif(this.settings.direction === 'rtl'){\n\t\t\t/***\n\t\t\t\tthe `floor` function above (L343) is on positive values, so we should add one `layout.delta`\n\t\t\t\tto distX or use `Math.ceil` function, or multiply offset.left by -1\n\t\t\t\tbefore `Math.floor`\n\t\t\t*/\n\t\t\tdistX = distX + this.layout.delta\n\t\t\tdistX = distX - width\n\t\t}\n\t\tthis.scrollTo(distX, distY, true);\n\t}\n\n\tadd(section, forceRight){\n\t\tvar view = this.createView(section, forceRight);\n\n\t\tthis.views.append(view);\n\n\t\t// view.on(EVENTS.VIEWS.SHOWN, this.afterDisplayed.bind(this));\n\t\tview.onDisplayed = this.afterDisplayed.bind(this);\n\t\tview.onResize = this.afterResized.bind(this);\n\n\t\tview.on(EVENTS.VIEWS.AXIS, (axis) => {\n\t\t\tthis.updateAxis(axis);\n\t\t});\n\n\t\tview.on(EVENTS.VIEWS.WRITING_MODE, (mode) => {\n\t\t\tthis.updateWritingMode(mode);\n\t\t});\n\n\t\treturn view.display(this.request);\n\t}\n\n\tappend(section, forceRight){\n\t\tvar view = this.createView(section, forceRight);\n\t\tthis.views.append(view);\n\n\t\tview.onDisplayed = this.afterDisplayed.bind(this);\n\t\tview.onResize = this.afterResized.bind(this);\n\n\t\tview.on(EVENTS.VIEWS.AXIS, (axis) => {\n\t\t\tthis.updateAxis(axis);\n\t\t});\n\n\t\tview.on(EVENTS.VIEWS.WRITING_MODE, (mode) => {\n\t\t\tthis.updateWritingMode(mode);\n\t\t});\n\n\t\treturn view.display(this.request);\n\t}\n\n\tprepend(section, forceRight){\n\t\tvar view = this.createView(section, forceRight);\n\n\t\tview.on(EVENTS.VIEWS.RESIZED, (bounds) => {\n\t\t\tthis.counter(bounds);\n\t\t});\n\n\t\tthis.views.prepend(view);\n\n\t\tview.onDisplayed = this.afterDisplayed.bind(this);\n\t\tview.onResize = this.afterResized.bind(this);\n\n\t\tview.on(EVENTS.VIEWS.AXIS, (axis) => {\n\t\t\tthis.updateAxis(axis);\n\t\t});\n\n\t\tview.on(EVENTS.VIEWS.WRITING_MODE, (mode) => {\n\t\t\tthis.updateWritingMode(mode);\n\t\t});\n\n\t\treturn view.display(this.request);\n\t}\n\n\tcounter(bounds){\n\t\tif(this.settings.axis === \"vertical\") {\n\t\t\tthis.scrollBy(0, bounds.heightDelta, true);\n\t\t} else {\n\t\t\tthis.scrollBy(bounds.widthDelta, 0, true);\n\t\t}\n\n\t}\n\n\t// resizeView(view) {\n\t//\n\t// \tif(this.settings.globalLayoutProperties.layout === \"pre-paginated\") {\n\t// \t\tview.lock(\"both\", this.bounds.width, this.bounds.height);\n\t// \t} else {\n\t// \t\tview.lock(\"width\", this.bounds.width, this.bounds.height);\n\t// \t}\n\t//\n\t// };\n\n\tnext(){\n\t\tvar next;\n\t\tvar left;\n\n\t\tlet dir = this.settings.direction;\n\n\t\tif(!this.views.length) return;\n\n\t\tif(this.isPaginated && this.settings.axis === \"horizontal\" && (!dir || dir === \"ltr\")) {\n\n\t\t\tthis.scrollLeft = this.container.scrollLeft;\n\n\t\t\tleft = this.container.scrollLeft + this.container.offsetWidth + this.layout.delta;\n\n\t\t\tif(left <= this.container.scrollWidth) {\n\t\t\t\tthis.scrollBy(this.layout.delta, 0, true);\n\t\t\t} else {\n\t\t\t\tnext = this.views.last().section.next();\n\t\t\t}\n\t\t} else if (this.isPaginated && this.settings.axis === \"horizontal\" && dir === \"rtl\") {\n\n\t\t\tthis.scrollLeft = this.container.scrollLeft;\n\n\t\t\tif (this.settings.rtlScrollType === \"default\"){\n\t\t\t\tleft = this.container.scrollLeft;\n\n\t\t\t\tif (left > 0) {\n\t\t\t\t\tthis.scrollBy(this.layout.delta, 0, true);\n\t\t\t\t} else {\n\t\t\t\t\tnext = this.views.last().section.next();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tleft = this.container.scrollLeft + ( this.layout.delta * -1 );\n\n\t\t\t\tif (left > this.container.scrollWidth * -1){\n\t\t\t\t\tthis.scrollBy(this.layout.delta, 0, true);\n\t\t\t\t} else {\n\t\t\t\t\tnext = this.views.last().section.next();\n\t\t\t\t}\n\t\t\t}\n\n\t\t} else if (this.isPaginated && this.settings.axis === \"vertical\") {\n\n\t\t\tthis.scrollTop = this.container.scrollTop;\n\n\t\t\tlet top = this.container.scrollTop + this.container.offsetHeight;\n\n\t\t\tif(top < this.container.scrollHeight) {\n\t\t\t\tthis.scrollBy(0, this.layout.height, true);\n\t\t\t} else {\n\t\t\t\tnext = this.views.last().section.next();\n\t\t\t}\n\n\t\t} else {\n\t\t\tnext = this.views.last().section.next();\n\t\t}\n\n\t\tif(next) {\n\t\t\tthis.clear();\n\t\t\t// The new section may have a different writing-mode from the old section. Thus, we need to update layout.\n\t\t\tthis.updateLayout();\n\n\t\t\tlet forceRight = false;\n\t\t\tif (this.layout.name === \"pre-paginated\" && this.layout.divisor === 2 && next.properties.includes(\"page-spread-right\")) {\n\t\t\t\tforceRight = true;\n\t\t\t}\n\n\t\t\treturn this.append(next, forceRight)\n\t\t\t\t.then(function(){\n\t\t\t\t\treturn this.handleNextPrePaginated(forceRight, next, this.append);\n\t\t\t\t}.bind(this), (err) => {\n\t\t\t\t\treturn err;\n\t\t\t\t})\n\t\t\t\t.then(function(){\n\n\t\t\t\t\t// Reset position to start for scrolled-doc vertical-rl in default mode\n\t\t\t\t\tif (!this.isPaginated &&\n\t\t\t\t\t\tthis.settings.axis === \"horizontal\" &&\n\t\t\t\t\t\tthis.settings.direction === \"rtl\" &&\n\t\t\t\t\t\tthis.settings.rtlScrollType === \"default\") {\n\t\t\t\t\t\t\n\t\t\t\t\t\tthis.scrollTo(this.container.scrollWidth, 0, true);\n\t\t\t\t\t}\n\t\t\t\t\tthis.views.show();\n\t\t\t\t}.bind(this));\n\t\t}\n\n\n\t}\n\n\tprev(){\n\t\tvar prev;\n\t\tvar left;\n\t\tlet dir = this.settings.direction;\n\n\t\tif(!this.views.length) return;\n\n\t\tif(this.isPaginated && this.settings.axis === \"horizontal\" && (!dir || dir === \"ltr\")) {\n\n\t\t\tthis.scrollLeft = this.container.scrollLeft;\n\n\t\t\tleft = this.container.scrollLeft;\n\n\t\t\tif(left > 0) {\n\t\t\t\tthis.scrollBy(-this.layout.delta, 0, true);\n\t\t\t} else {\n\t\t\t\tprev = this.views.first().section.prev();\n\t\t\t}\n\n\t\t} else if (this.isPaginated && this.settings.axis === \"horizontal\" && dir === \"rtl\") {\n\n\t\t\tthis.scrollLeft = this.container.scrollLeft;\n\n\t\t\tif (this.settings.rtlScrollType === \"default\"){\n\t\t\t\tleft = this.container.scrollLeft + this.container.offsetWidth;\n\n\t\t\t\tif (left < this.container.scrollWidth) {\n\t\t\t\t\tthis.scrollBy(-this.layout.delta, 0, true);\n\t\t\t\t} else {\n\t\t\t\t\tprev = this.views.first().section.prev();\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\tleft = this.container.scrollLeft;\n\n\t\t\t\tif (left < 0) {\n\t\t\t\t\tthis.scrollBy(-this.layout.delta, 0, true);\n\t\t\t\t} else {\n\t\t\t\t\tprev = this.views.first().section.prev();\n\t\t\t\t}\n\t\t\t}\n\n\t\t} else if (this.isPaginated && this.settings.axis === \"vertical\") {\n\n\t\t\tthis.scrollTop = this.container.scrollTop;\n\n\t\t\tlet top = this.container.scrollTop;\n\n\t\t\tif(top > 0) {\n\t\t\t\tthis.scrollBy(0, -(this.layout.height), true);\n\t\t\t} else {\n\t\t\t\tprev = this.views.first().section.prev();\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tprev = this.views.first().section.prev();\n\n\t\t}\n\n\t\tif(prev) {\n\t\t\tthis.clear();\n\t\t\t// The new section may have a different writing-mode from the old section. Thus, we need to update layout.\n\t\t\tthis.updateLayout();\n\n\t\t\tlet forceRight = false;\n\t\t\tif (this.layout.name === \"pre-paginated\" && this.layout.divisor === 2 && typeof prev.prev() !== \"object\") {\n\t\t\t\tforceRight = true;\n\t\t\t}\n\n\t\t\treturn this.prepend(prev, forceRight)\n\t\t\t\t.then(function(){\n\t\t\t\t\tvar left;\n\t\t\t\t\tif (this.layout.name === \"pre-paginated\" && this.layout.divisor > 1) {\n\t\t\t\t\t\tleft = prev.prev();\n\t\t\t\t\t\tif (left) {\n\t\t\t\t\t\t\treturn this.prepend(left);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}.bind(this), (err) => {\n\t\t\t\t\treturn err;\n\t\t\t\t})\n\t\t\t\t.then(function(){\n\t\t\t\t\tif(this.isPaginated && this.settings.axis === \"horizontal\") {\n\t\t\t\t\t\tif (this.settings.direction === \"rtl\") {\n\t\t\t\t\t\t\tif (this.settings.rtlScrollType === \"default\"){\n\t\t\t\t\t\t\t\tthis.scrollTo(0, 0, true);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse{\n\t\t\t\t\t\t\t\tthis.scrollTo((this.container.scrollWidth * -1) + this.layout.delta, 0, true);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.scrollTo(this.container.scrollWidth - this.layout.delta, 0, true);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthis.views.show();\n\t\t\t\t}.bind(this));\n\t\t}\n\t}\n\n\tcurrent(){\n\t\tvar visible = this.visible();\n\t\tif(visible.length){\n\t\t\t// Current is the last visible view\n\t\t\treturn visible[visible.length-1];\n\t\t}\n\t\treturn null;\n\t}\n\n\tclear () {\n\n\t\t// this.q.clear();\n\n\t\tif (this.views) {\n\t\t\tthis.views.hide();\n\t\t\tthis.scrollTo(0,0, true);\n\t\t\tthis.views.clear();\n\t\t}\n\t}\n\n\tcurrentLocation(){\n\t\tthis.updateLayout();\n\t\tif (this.isPaginated && this.settings.axis === \"horizontal\") {\n\t\t\tthis.location = this.paginatedLocation();\n\t\t} else {\n\t\t\tthis.location = this.scrolledLocation();\n\t\t}\n\t\treturn this.location;\n\t}\n\n\tscrolledLocation() {\n\t\tlet visible = this.visible();\n\t\tlet container = this.container.getBoundingClientRect();\n\t\tlet pageHeight = (container.height < window.innerHeight) ? container.height : window.innerHeight;\n\t\tlet pageWidth = (container.width < window.innerWidth) ? container.width : window.innerWidth;\n\t\tlet vertical = (this.settings.axis === \"vertical\");\n\t\tlet rtl = (this.settings.direction === \"rtl\");\n\t\t\n\t\tlet offset = 0;\n\t\tlet used = 0;\n\n\t\tif(this.settings.fullsize) {\n\t\t\toffset = vertical ? window.scrollY : window.scrollX;\n\t\t}\n\n\t\tlet sections = visible.map((view) => {\n\t\t\tlet {index, href} = view.section;\n\t\t\tlet position = view.position();\n\t\t\tlet width = view.width();\n\t\t\tlet height = view.height();\n\n\t\t\tlet startPos;\n\t\t\tlet endPos;\n\t\t\tlet stopPos;\n\t\t\tlet totalPages;\n\n\t\t\tif (vertical) {\n\t\t\t\tstartPos = offset + container.top - position.top + used;\n\t\t\t\tendPos = startPos + pageHeight - used;\n\t\t\t\ttotalPages = this.layout.count(height, pageHeight).pages;\n\t\t\t\tstopPos = pageHeight;\n\t\t\t} else {\n\t\t\t\tstartPos = offset + container.left - position.left + used;\n\t\t\t\tendPos = startPos + pageWidth - used;\n\t\t\t\ttotalPages = this.layout.count(width, pageWidth).pages;\n\t\t\t\tstopPos = pageWidth;\n\t\t\t}\n\n\t\t\tlet currPage = Math.ceil(startPos / stopPos);\n\t\t\tlet pages = [];\n\t\t\tlet endPage = Math.ceil(endPos / stopPos);\n\n\t\t\t// Reverse page counts for horizontal rtl\n\t\t\tif (this.settings.direction === \"rtl\" && !vertical) {\n\t\t\t\tlet tempStartPage = currPage;\n\t\t\t\tcurrPage = totalPages - endPage;\n\t\t\t\tendPage = totalPages - tempStartPage;\n\t\t\t}\n\n\t\t\tpages = [];\n\t\t\tfor (var i = currPage; i <= endPage; i++) {\n\t\t\t\tlet pg = i + 1;\n\t\t\t\tpages.push(pg);\n\t\t\t}\n\n\t\t\tlet mapping = this.mapping.page(view.contents, view.section.cfiBase, startPos, endPos);\n\n\t\t\treturn {\n\t\t\t\tindex,\n\t\t\t\thref,\n\t\t\t\tpages,\n\t\t\t\ttotalPages,\n\t\t\t\tmapping\n\t\t\t};\n\t\t});\n\n\t\treturn sections;\n\t}\n\n\tpaginatedLocation(){\n\t\tlet visible = this.visible();\n\t\tlet container = this.container.getBoundingClientRect();\n\n\t\tlet left = 0;\n\t\tlet used = 0;\n\n\t\tif(this.settings.fullsize) {\n\t\t\tleft = window.scrollX;\n\t\t}\n\n\t\tlet sections = visible.map((view) => {\n\t\t\tlet {index, href} = view.section;\n\t\t\tlet offset;\n\t\t\tlet position = view.position();\n\t\t\tlet width = view.width();\n\n\t\t\t// Find mapping\n\t\t\tlet start;\n\t\t\tlet end;\n\t\t\tlet pageWidth;\n\n\t\t\tif (this.settings.direction === \"rtl\") {\n\t\t\t\toffset = container.right - left;\n\t\t\t\tpageWidth = Math.min(Math.abs(offset - position.left), this.layout.width) - used;\n\t\t\t\tend = position.width - (position.right - offset) - used;\n\t\t\t\tstart = end - pageWidth;\n\t\t\t} else {\n\t\t\t\toffset = container.left + left;\n\t\t\t\tpageWidth = Math.min(position.right - offset, this.layout.width) - used;\n\t\t\t\tstart = offset - position.left + used;\n\t\t\t\tend = start + pageWidth;\n\t\t\t}\n\n\t\t\tused += pageWidth;\n\n\t\t\tlet mapping = this.mapping.page(view.contents, view.section.cfiBase, start, end);\n\n\t\t\tlet totalPages = this.layout.count(width).pages;\n\t\t\tlet startPage = Math.floor(start / this.layout.pageWidth);\n\t\t\tlet pages = [];\n\t\t\tlet endPage = Math.floor(end / this.layout.pageWidth);\n\t\t\t\n\t\t\t// start page should not be negative\n\t\t\tif (startPage < 0) {\n\t\t\t\tstartPage = 0;\n\t\t\t\tendPage = endPage + 1;\n\t\t\t}\n\n\t\t\t// Reverse page counts for rtl\n\t\t\tif (this.settings.direction === \"rtl\") {\n\t\t\t\tlet tempStartPage = startPage;\n\t\t\t\tstartPage = totalPages - endPage;\n\t\t\t\tendPage = totalPages - tempStartPage;\n\t\t\t}\n\n\n\t\t\tfor (var i = startPage + 1; i <= endPage; i++) {\n\t\t\t\tlet pg = i;\n\t\t\t\tpages.push(pg);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tindex,\n\t\t\t\thref,\n\t\t\t\tpages,\n\t\t\t\ttotalPages,\n\t\t\t\tmapping\n\t\t\t};\n\t\t});\n\n\t\treturn sections;\n\t}\n\n\tisVisible(view, offsetPrev, offsetNext, _container){\n\t\tvar position = view.position();\n\t\tvar container = _container || this.bounds();\n\n\t\tif(this.settings.axis === \"horizontal\" &&\n\t\t\tposition.right > container.left - offsetPrev &&\n\t\t\tposition.left < container.right + offsetNext) {\n\n\t\t\treturn true;\n\n\t\t} else if(this.settings.axis === \"vertical\" &&\n\t\t\tposition.bottom > container.top - offsetPrev &&\n\t\t\tposition.top < container.bottom + offsetNext) {\n\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\n\t}\n\n\tvisible(){\n\t\tvar container = this.bounds();\n\t\tvar views = this.views.displayed();\n\t\tvar viewsLength = views.length;\n\t\tvar visible = [];\n\t\tvar isVisible;\n\t\tvar view;\n\n\t\tfor (var i = 0; i < viewsLength; i++) {\n\t\t\tview = views[i];\n\t\t\tisVisible = this.isVisible(view, 0, 0, container);\n\n\t\t\tif(isVisible === true) {\n\t\t\t\tvisible.push(view);\n\t\t\t}\n\n\t\t}\n\t\treturn visible;\n\t}\n\n\tscrollBy(x, y, silent){\n\t\tlet dir = this.settings.direction === \"rtl\" ? -1 : 1;\n\n\t\tif(silent) {\n\t\t\tthis.ignore = true;\n\t\t}\n\n\t\tif(!this.settings.fullsize) {\n\t\t\tif(x) this.container.scrollLeft += x * dir;\n\t\t\tif(y) this.container.scrollTop += y;\n\t\t} else {\n\t\t\twindow.scrollBy(x * dir, y * dir);\n\t\t}\n\t\tthis.scrolled = true;\n\t}\n\n\tscrollTo(x, y, silent){\n\t\tif(silent) {\n\t\t\tthis.ignore = true;\n\t\t}\n\n\t\tif(!this.settings.fullsize) {\n\t\t\tthis.container.scrollLeft = x;\n\t\t\tthis.container.scrollTop = y;\n\t\t} else {\n\t\t\twindow.scrollTo(x,y);\n\t\t}\n\t\tthis.scrolled = true;\n\t}\n\n\tonScroll(){\n\t\tlet scrollTop;\n\t\tlet scrollLeft;\n\n\t\tif(!this.settings.fullsize) {\n\t\t\tscrollTop = this.container.scrollTop;\n\t\t\tscrollLeft = this.container.scrollLeft;\n\t\t} else {\n\t\t\tscrollTop = window.scrollY;\n\t\t\tscrollLeft = window.scrollX;\n\t\t}\n\n\t\tthis.scrollTop = scrollTop;\n\t\tthis.scrollLeft = scrollLeft;\n\n\t\tif(!this.ignore) {\n\t\t\tthis.emit(EVENTS.MANAGERS.SCROLL, {\n\t\t\t\ttop: scrollTop,\n\t\t\t\tleft: scrollLeft\n\t\t\t});\n\n\t\t\tclearTimeout(this.afterScrolled);\n\t\t\tthis.afterScrolled = setTimeout(function () {\n\t\t\t\tthis.emit(EVENTS.MANAGERS.SCROLLED, {\n\t\t\t\t\ttop: this.scrollTop,\n\t\t\t\t\tleft: this.scrollLeft\n\t\t\t\t});\n\t\t\t}.bind(this), 20);\n\n\n\n\t\t} else {\n\t\t\tthis.ignore = false;\n\t\t}\n\n\t}\n\n\tbounds() {\n\t\tvar bounds;\n\n\t\tbounds = this.stage.bounds();\n\n\t\treturn bounds;\n\t}\n\n\tapplyLayout(layout) {\n\n\t\tthis.layout = layout;\n\t\tthis.updateLayout();\n\t\tif (this.views && this.views.length > 0 && this.layout.name === \"pre-paginated\") {\n\t\t\tthis.display(this.views.first().section);\n\t\t}\n\t\t // this.manager.layout(this.layout.format);\n\t}\n\n\tupdateLayout() {\n\n\t\tif (!this.stage) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis._stageSize = this.stage.size();\n\n\t\tif(!this.isPaginated) {\n\t\t\tthis.layout.calculate(this._stageSize.width, this._stageSize.height);\n\t\t} else {\n\t\t\tthis.layout.calculate(\n\t\t\t\tthis._stageSize.width,\n\t\t\t\tthis._stageSize.height,\n\t\t\t\tthis.settings.gap\n\t\t\t);\n\n\t\t\t// Set the look ahead offset for what is visible\n\t\t\tthis.settings.offset = this.layout.delta / this.layout.divisor;\n\n\t\t\t// this.stage.addStyleRules(\"iframe\", [{\"margin-right\" : this.layout.gap + \"px\"}]);\n\n\t\t}\n\n\t\t// Set the dimensions for views\n\t\tthis.viewSettings.width = this.layout.width;\n\t\tthis.viewSettings.height = this.layout.height;\n\n\t\tthis.setLayout(this.layout);\n\t}\n\n\tsetLayout(layout){\n\n\t\tthis.viewSettings.layout = layout;\n\n\t\tthis.mapping = new Mapping(layout.props, this.settings.direction, this.settings.axis);\n\n\t\tif(this.views) {\n\n\t\t\tthis.views.forEach(function(view){\n\t\t\t\tif (view) {\n\t\t\t\t\tview.setLayout(layout);\n\t\t\t\t}\n\t\t\t});\n\n\t\t}\n\n\t}\n\n\tupdateWritingMode(mode) {\n\t\tthis.writingMode = mode;\n\t}\n\n\tupdateAxis(axis, forceUpdate){\n\n\t\tif (!forceUpdate && axis === this.settings.axis) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.settings.axis = axis;\n\n\t\tthis.stage && this.stage.axis(axis);\n\n\t\tthis.viewSettings.axis = axis;\n\n\t\tif (this.mapping) {\n\t\t\tthis.mapping = new Mapping(this.layout.props, this.settings.direction, this.settings.axis);\n\t\t}\n\n\t\tif (this.layout) {\n\t\t\tif (axis === \"vertical\") {\n\t\t\t\tthis.layout.spread(\"none\");\n\t\t\t} else {\n\t\t\t\tthis.layout.spread(this.layout.settings.spread);\n\t\t\t}\n\t\t}\n\t}\n\n\tupdateFlow(flow, defaultScrolledOverflow=\"auto\"){\n\t\tlet isPaginated = (flow === \"paginated\" || flow === \"auto\");\n\n\t\tthis.isPaginated = isPaginated;\n\n\t\tif (flow === \"scrolled-doc\" ||\n\t\t\t\tflow === \"scrolled-continuous\" ||\n\t\t\t\tflow === \"scrolled\") {\n\t\t\tthis.updateAxis(\"vertical\");\n\t\t} else {\n\t\t\tthis.updateAxis(\"horizontal\");\n\t\t}\n\n\t\tthis.viewSettings.flow = flow;\n\n\t\tif (!this.settings.overflow) {\n\t\t\tthis.overflow = isPaginated ? \"hidden\" : defaultScrolledOverflow;\n\t\t} else {\n\t\t\tthis.overflow = this.settings.overflow;\n\t\t}\n\n\t\tthis.stage && this.stage.overflow(this.overflow);\n\n\t\tthis.updateLayout();\n\n\t}\n\n\tgetContents(){\n\t\tvar contents = [];\n\t\tif (!this.views) {\n\t\t\treturn contents;\n\t\t}\n\t\tthis.views.forEach(function(view){\n\t\t\tconst viewContents = view && view.contents;\n\t\t\tif (viewContents) {\n\t\t\t\tcontents.push(viewContents);\n\t\t\t}\n\t\t});\n\t\treturn contents;\n\t}\n\n\tdirection(dir=\"ltr\") {\n\t\tthis.settings.direction = dir;\n\n\t\tthis.stage && this.stage.direction(dir);\n\n\t\tthis.viewSettings.direction = dir;\n\n\t\tthis.updateLayout();\n\t}\n\n\tisRendered() {\n\t\treturn this.rendered;\n\t}\n}\n\n//-- Enable binding events to Manager\nEventEmitter(DefaultViewManager.prototype);\n\nexport default DefaultViewManager;\n","import {extend, defer, requestAnimationFrame, prefixed} from \"../../utils/core\";\nimport { EVENTS, DOM_EVENTS } from \"../../utils/constants\";\nimport EventEmitter from \"event-emitter\";\n\n// easing equations from https://github.com/danro/easing-js/blob/master/easing.js\nconst PI_D2 = (Math.PI / 2);\nconst EASING_EQUATIONS = {\n\t\teaseOutSine: function (pos) {\n\t\t\t\treturn Math.sin(pos * PI_D2);\n\t\t},\n\t\teaseInOutSine: function (pos) {\n\t\t\t\treturn (-0.5 * (Math.cos(Math.PI * pos) - 1));\n\t\t},\n\t\teaseInOutQuint: function (pos) {\n\t\t\t\tif ((pos /= 0.5) < 1) {\n\t\t\t\t\t\treturn 0.5 * Math.pow(pos, 5);\n\t\t\t\t}\n\t\t\t\treturn 0.5 * (Math.pow((pos - 2), 5) + 2);\n\t\t},\n\t\teaseInCubic: function(pos) {\n\t\t\treturn Math.pow(pos, 3);\n \t}\n};\n\nclass Snap {\n\tconstructor(manager, options) {\n\n\t\tthis.settings = extend({\n\t\t\tduration: 80,\n\t\t\tminVelocity: 0.2,\n\t\t\tminDistance: 10,\n\t\t\teasing: EASING_EQUATIONS['easeInCubic']\n\t\t}, options || {});\n\n\t\tthis.supportsTouch = this.supportsTouch();\n\n\t\tif (this.supportsTouch) {\n\t\t\tthis.setup(manager);\n\t\t}\n\t}\n\n\tsetup(manager) {\n\t\tthis.manager = manager;\n\n\t\tthis.layout = this.manager.layout;\n\n\t\tthis.fullsize = this.manager.settings.fullsize;\n\t\tif (this.fullsize) {\n\t\t\tthis.element = this.manager.stage.element;\n\t\t\tthis.scroller = window;\n\t\t\tthis.disableScroll();\n\t\t} else {\n\t\t\tthis.element = this.manager.stage.container;\n\t\t\tthis.scroller = this.element;\n\t\t\tthis.element.style[\"WebkitOverflowScrolling\"] = \"touch\";\n\t\t}\n\n\t\t// this.overflow = this.manager.overflow;\n\n\t\t// set lookahead offset to page width\n\t\tthis.manager.settings.offset = this.layout.width;\n\t\tthis.manager.settings.afterScrolledTimeout = this.settings.duration * 2;\n\n\t\tthis.isVertical = this.manager.settings.axis === \"vertical\";\n\n\t\t// disable snapping if not paginated or axis in not horizontal\n\t\tif (!this.manager.isPaginated || this.isVertical) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.touchCanceler = false;\n\t\tthis.resizeCanceler = false;\n\t\tthis.snapping = false;\n\n\n\t\tthis.scrollLeft;\n\t\tthis.scrollTop;\n\n\t\tthis.startTouchX = undefined;\n\t\tthis.startTouchY = undefined;\n\t\tthis.startTime = undefined;\n\t\tthis.endTouchX = undefined;\n\t\tthis.endTouchY = undefined;\n\t\tthis.endTime = undefined;\n\n\t\tthis.addListeners();\n\t}\n\n\tsupportsTouch() {\n\t\tif (('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tdisableScroll() {\n\t\tthis.element.style.overflow = \"hidden\";\n\t}\n\n\tenableScroll() {\n\t\tthis.element.style.overflow = \"\";\n\t}\n\n\taddListeners() {\n\t\tthis._onResize = this.onResize.bind(this);\n\t\twindow.addEventListener('resize', this._onResize);\n\n\t\tthis._onScroll = this.onScroll.bind(this);\n\t\tthis.scroller.addEventListener('scroll', this._onScroll);\n\n\t\tthis._onTouchStart = this.onTouchStart.bind(this);\n\t\tthis.scroller.addEventListener('touchstart', this._onTouchStart, { passive: true });\n\t\tthis.on('touchstart', this._onTouchStart);\n\n\t\tthis._onTouchMove = this.onTouchMove.bind(this);\n\t\tthis.scroller.addEventListener('touchmove', this._onTouchMove, { passive: true });\n\t\tthis.on('touchmove', this._onTouchMove);\n\n\t\tthis._onTouchEnd = this.onTouchEnd.bind(this);\n\t\tthis.scroller.addEventListener('touchend', this._onTouchEnd, { passive: true });\n\t\tthis.on('touchend', this._onTouchEnd);\n\n\t\tthis._afterDisplayed = this.afterDisplayed.bind(this);\n\t\tthis.manager.on(EVENTS.MANAGERS.ADDED, this._afterDisplayed);\n\t}\n\n\tremoveListeners() {\n\t\twindow.removeEventListener('resize', this._onResize);\n\t\tthis._onResize = undefined;\n\n\t\tthis.scroller.removeEventListener('scroll', this._onScroll);\n\t\tthis._onScroll = undefined;\n\n\t\tthis.scroller.removeEventListener('touchstart', this._onTouchStart, { passive: true });\n\t\tthis.off('touchstart', this._onTouchStart);\n\t\tthis._onTouchStart = undefined;\n\n\t\tthis.scroller.removeEventListener('touchmove', this._onTouchMove, { passive: true });\n\t\tthis.off('touchmove', this._onTouchMove);\n\t\tthis._onTouchMove = undefined;\n\n\t\tthis.scroller.removeEventListener('touchend', this._onTouchEnd, { passive: true });\n\t\tthis.off('touchend', this._onTouchEnd);\n\t\tthis._onTouchEnd = undefined;\n\n\t\tthis.manager.off(EVENTS.MANAGERS.ADDED, this._afterDisplayed);\n\t\tthis._afterDisplayed = undefined;\n\t}\n\n\tafterDisplayed(view) {\n\t\tlet contents = view.contents;\n\t\t[\"touchstart\", \"touchmove\", \"touchend\"].forEach((e) => {\n\t\t\tcontents.on(e, (ev) => this.triggerViewEvent(ev, contents));\n\t\t});\n\t}\n\n\ttriggerViewEvent(e, contents){\n\t\tthis.emit(e.type, e, contents);\n\t}\n\n\tonScroll(e) {\n\t\tthis.scrollLeft = this.fullsize ? window.scrollX : this.scroller.scrollLeft;\n\t\tthis.scrollTop = this.fullsize ? window.scrollY : this.scroller.scrollTop;\n\t}\n\n\tonResize(e) {\n\t\tthis.resizeCanceler = true;\n\t}\n\n\tonTouchStart(e) {\n\t\tlet { screenX, screenY } = e.touches[0];\n\n\t\tif (this.fullsize) {\n\t\t\tthis.enableScroll();\n\t\t}\n\n\t\tthis.touchCanceler = true;\n\n\t\tif (!this.startTouchX) {\n\t\t\tthis.startTouchX = screenX;\n\t\t\tthis.startTouchY = screenY;\n\t\t\tthis.startTime = this.now();\n\t\t}\n\n\t\tthis.endTouchX = screenX;\n\t\tthis.endTouchY = screenY;\n\t\tthis.endTime = this.now();\n\t}\n\n\tonTouchMove(e) {\n\t\tlet { screenX, screenY } = e.touches[0];\n\t\tlet deltaY = Math.abs(screenY - this.endTouchY);\n\n\t\tthis.touchCanceler = true;\n\n\n\t\tif (!this.fullsize && deltaY < 10) {\n\t\t\tthis.element.scrollLeft -= screenX - this.endTouchX;\n\t\t}\n\n\t\tthis.endTouchX = screenX;\n\t\tthis.endTouchY = screenY;\n\t\tthis.endTime = this.now();\n\t}\n\n\tonTouchEnd(e) {\n\t\tif (this.fullsize) {\n\t\t\tthis.disableScroll();\n\t\t}\n\n\t\tthis.touchCanceler = false;\n\n\t\tlet swipped = this.wasSwiped();\n\n\t\tif (swipped !== 0) {\n\t\t\tthis.snap(swipped);\n\t\t} else {\n\t\t\tthis.snap();\n\t\t}\n\n\t\tthis.startTouchX = undefined;\n\t\tthis.startTouchY = undefined;\n\t\tthis.startTime = undefined;\n\t\tthis.endTouchX = undefined;\n\t\tthis.endTouchY = undefined;\n\t\tthis.endTime = undefined;\n\t}\n\n\twasSwiped() {\n\t\tlet snapWidth = this.layout.pageWidth * this.layout.divisor;\n\t\tlet distance = (this.endTouchX - this.startTouchX);\n\t\tlet absolute = Math.abs(distance);\n\t\tlet time = this.endTime - this.startTime;\n\t\tlet velocity = (distance / time);\n\t\tlet minVelocity = this.settings.minVelocity;\n\n\t\tif (absolute <= this.settings.minDistance || absolute >= snapWidth) {\n\t\t\treturn 0;\n\t\t}\n\n\t\tif (velocity > minVelocity) {\n\t\t\t// previous\n\t\t\treturn -1;\n\t\t} else if (velocity < -minVelocity) {\n\t\t\t// next\n\t\t\treturn 1;\n\t\t}\n\t}\n\n\tneedsSnap() {\n\t\tlet left = this.scrollLeft;\n\t\tlet snapWidth = this.layout.pageWidth * this.layout.divisor;\n\t\treturn (left % snapWidth) !== 0;\n\t}\n\n\tsnap(howMany=0) {\n\t\tlet left = this.scrollLeft;\n\t\tlet snapWidth = this.layout.pageWidth * this.layout.divisor;\n\t\tlet snapTo = Math.round(left / snapWidth) * snapWidth;\n\n\t\tif (howMany) {\n\t\t\tsnapTo += (howMany * snapWidth);\n\t\t}\n\n\t\treturn this.smoothScrollTo(snapTo);\n\t}\n\n\tsmoothScrollTo(destination) {\n\t\tconst deferred = new defer();\n\t\tconst start = this.scrollLeft;\n\t\tconst startTime = this.now();\n\n\t\tconst duration = this.settings.duration;\n\t\tconst easing = this.settings.easing;\n\n\t\tthis.snapping = true;\n\n\t\t// add animation loop\n\t\tfunction tick() {\n\t\t\tconst now = this.now();\n\t\t\tconst time = Math.min(1, ((now - startTime) / duration));\n\t\t\tconst timeFunction = easing(time);\n\n\n\t\t\tif (this.touchCanceler || this.resizeCanceler) {\n\t\t\t\tthis.resizeCanceler = false;\n\t\t\t\tthis.snapping = false;\n\t\t\t\tdeferred.resolve();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (time < 1) {\n\t\t\t\t\twindow.requestAnimationFrame(tick.bind(this));\n\t\t\t\t\tthis.scrollTo(start + ((destination - start) * time), 0);\n\t\t\t} else {\n\t\t\t\t\tthis.scrollTo(destination, 0);\n\t\t\t\t\tthis.snapping = false;\n\t\t\t\t\tdeferred.resolve();\n\t\t\t}\n\t\t}\n\n\t\ttick.call(this);\n\n\t\treturn deferred.promise;\n\t}\n\n\tscrollTo(left=0, top=0) {\n\t\tif (this.fullsize) {\n\t\t\twindow.scroll(left, top);\n\t\t} else {\n\t\t\tthis.scroller.scrollLeft = left;\n\t\t\tthis.scroller.scrollTop = top;\n\t\t}\n\t}\n\n\tnow() {\n\t\treturn ('now' in window.performance) ? performance.now() : new Date().getTime();\n\t}\n\n\tdestroy() {\n\t\tif (!this.scroller) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.fullsize) {\n\t\t\tthis.enableScroll();\n\t\t}\n\n\t\tthis.removeListeners();\n\n\t\tthis.scroller = undefined;\n\t}\n}\n\nEventEmitter(Snap.prototype);\n\nexport default Snap;\n","import {extend, defer, requestAnimationFrame} from \"../../utils/core\";\nimport DefaultViewManager from \"../default\";\nimport Snap from \"../helpers/snap\";\nimport { EVENTS } from \"../../utils/constants\";\nimport debounce from \"lodash/debounce\";\n\nclass ContinuousViewManager extends DefaultViewManager {\n\tconstructor(options) {\n\t\tsuper(options);\n\n\t\tthis.name = \"continuous\";\n\n\t\tthis.settings = extend(this.settings || {}, {\n\t\t\tinfinite: true,\n\t\t\toverflow: undefined,\n\t\t\taxis: undefined,\n\t\t\twritingMode: undefined,\n\t\t\tflow: \"scrolled\",\n\t\t\toffset: 500,\n\t\t\toffsetDelta: 250,\n\t\t\twidth: undefined,\n\t\t\theight: undefined,\n\t\t\tsnap: false,\n\t\t\tafterScrolledTimeout: 10,\n\t\t\tallowScriptedContent: false,\n\t\t\tallowPopups: false\n\t\t});\n\n\t\textend(this.settings, options.settings || {});\n\n\t\t// Gap can be 0, but defaults doesn't handle that\n\t\tif (options.settings.gap != \"undefined\" && options.settings.gap === 0) {\n\t\t\tthis.settings.gap = options.settings.gap;\n\t\t}\n\n\t\tthis.viewSettings = {\n\t\t\tignoreClass: this.settings.ignoreClass,\n\t\t\taxis: this.settings.axis,\n\t\t\tflow: this.settings.flow,\n\t\t\tlayout: this.layout,\n\t\t\twidth: 0,\n\t\t\theight: 0,\n\t\t\tforceEvenPages: false,\n\t\t\tallowScriptedContent: this.settings.allowScriptedContent,\n\t\t\tallowPopups: this.settings.allowPopups\n\t\t};\n\n\t\tthis.scrollTop = 0;\n\t\tthis.scrollLeft = 0;\n\t}\n\n\tdisplay(section, target){\n\t\treturn DefaultViewManager.prototype.display.call(this, section, target)\n\t\t\t.then(function () {\n\t\t\t\treturn this.fill();\n\t\t\t}.bind(this));\n\t}\n\n\tfill(_full){\n\t\tvar full = _full || new defer();\n\n\t\tthis.q.enqueue(() => {\n\t\t\treturn this.check();\n\t\t}).then((result) => {\n\t\t\tif (result) {\n\t\t\t\tthis.fill(full);\n\t\t\t} else {\n\t\t\t\tfull.resolve();\n\t\t\t}\n\t\t});\n\n\t\treturn full.promise;\n\t}\n\n\tmoveTo(offset){\n\t\t// var bounds = this.stage.bounds();\n\t\t// var dist = Math.floor(offset.top / bounds.height) * bounds.height;\n\t\tvar distX = 0,\n\t\t\t\tdistY = 0;\n\n\t\tvar offsetX = 0,\n\t\t\t\toffsetY = 0;\n\n\t\tif(!this.isPaginated) {\n\t\t\tdistY = offset.top;\n\t\t\toffsetY = offset.top+this.settings.offsetDelta;\n\t\t} else {\n\t\t\tdistX = Math.floor(offset.left / this.layout.delta) * this.layout.delta;\n\t\t\toffsetX = distX+this.settings.offsetDelta;\n\t\t}\n\n\t\tif (distX > 0 || distY > 0) {\n\t\t\tthis.scrollBy(distX, distY, true);\n\t\t}\n\t}\n\n\tafterResized(view){\n\t\tthis.emit(EVENTS.MANAGERS.RESIZE, view.section);\n\t}\n\n\t// Remove Previous Listeners if present\n\tremoveShownListeners(view){\n\n\t\t// view.off(\"shown\", this.afterDisplayed);\n\t\t// view.off(\"shown\", this.afterDisplayedAbove);\n\t\tview.onDisplayed = function(){};\n\n\t}\n\n\tadd(section){\n\t\tvar view = this.createView(section);\n\n\t\tthis.views.append(view);\n\n\t\tview.on(EVENTS.VIEWS.RESIZED, (bounds) => {\n\t\t\tview.expanded = true;\n\t\t});\n\n\t\tview.on(EVENTS.VIEWS.AXIS, (axis) => {\n\t\t\tthis.updateAxis(axis);\n\t\t});\n\n\t\tview.on(EVENTS.VIEWS.WRITING_MODE, (mode) => {\n\t\t\tthis.updateWritingMode(mode);\n\t\t});\n\n\t\t// view.on(EVENTS.VIEWS.SHOWN, this.afterDisplayed.bind(this));\n\t\tview.onDisplayed = this.afterDisplayed.bind(this);\n\t\tview.onResize = this.afterResized.bind(this);\n\n\t\treturn view.display(this.request);\n\t}\n\n\tappend(section){\n\t\tvar view = this.createView(section);\n\n\t\tview.on(EVENTS.VIEWS.RESIZED, (bounds) => {\n\t\t\tview.expanded = true;\n\t\t});\n\n\t\tview.on(EVENTS.VIEWS.AXIS, (axis) => {\n\t\t\tthis.updateAxis(axis);\n\t\t});\n\n\t\tview.on(EVENTS.VIEWS.WRITING_MODE, (mode) => {\n\t\t\tthis.updateWritingMode(mode);\n\t\t});\n\n\t\tthis.views.append(view);\n\n\t\tview.onDisplayed = this.afterDisplayed.bind(this);\n\n\t\treturn view;\n\t}\n\n\tprepend(section){\n\t\tvar view = this.createView(section);\n\n\t\tview.on(EVENTS.VIEWS.RESIZED, (bounds) => {\n\t\t\tthis.counter(bounds);\n\t\t\tview.expanded = true;\n\t\t});\n\n\t\tview.on(EVENTS.VIEWS.AXIS, (axis) => {\n\t\t\tthis.updateAxis(axis);\n\t\t});\n\n\t\tview.on(EVENTS.VIEWS.WRITING_MODE, (mode) => {\n\t\t\tthis.updateWritingMode(mode);\n\t\t});\n\n\t\tthis.views.prepend(view);\n\n\t\tview.onDisplayed = this.afterDisplayed.bind(this);\n\n\t\treturn view;\n\t}\n\n\tcounter(bounds){\n\t\tif(this.settings.axis === \"vertical\") {\n\t\t\tthis.scrollBy(0, bounds.heightDelta, true);\n\t\t} else {\n\t\t\tthis.scrollBy(bounds.widthDelta, 0, true);\n\t\t}\n\t}\n\n\tupdate(_offset){\n\t\tvar container = this.bounds();\n\t\tvar views = this.views.all();\n\t\tvar viewsLength = views.length;\n\t\tvar visible = [];\n\t\tvar offset = typeof _offset != \"undefined\" ? _offset : (this.settings.offset || 0);\n\t\tvar isVisible;\n\t\tvar view;\n\n\t\tvar updating = new defer();\n\t\tvar promises = [];\n\t\tfor (var i = 0; i < viewsLength; i++) {\n\t\t\tview = views[i];\n\n\t\t\tisVisible = this.isVisible(view, offset, offset, container);\n\n\t\t\tif(isVisible === true) {\n\t\t\t\t// console.log(\"visible \" + view.index, view.displayed);\n\n\t\t\t\tif (!view.displayed) {\n\t\t\t\t\tlet displayed = view.display(this.request)\n\t\t\t\t\t\t.then(function (view) {\n\t\t\t\t\t\t\tview.show();\n\t\t\t\t\t\t}, (err) => {\n\t\t\t\t\t\t\tview.hide();\n\t\t\t\t\t\t});\n\t\t\t\t\tpromises.push(displayed);\n\t\t\t\t} else {\n\t\t\t\t\tview.show();\n\t\t\t\t}\n\t\t\t\tvisible.push(view);\n\t\t\t} else {\n\t\t\t\tthis.q.enqueue(view.destroy.bind(view));\n\t\t\t\t// console.log(\"hidden \" + view.index, view.displayed);\n\n\t\t\t\tclearTimeout(this.trimTimeout);\n\t\t\t\tthis.trimTimeout = setTimeout(function(){\n\t\t\t\t\tthis.q.enqueue(this.trim.bind(this));\n\t\t\t\t}.bind(this), 250);\n\t\t\t}\n\n\t\t}\n\n\t\tif(promises.length){\n\t\t\treturn Promise.all(promises)\n\t\t\t\t.catch((err) => {\n\t\t\t\t\tupdating.reject(err);\n\t\t\t\t});\n\t\t} else {\n\t\t\tupdating.resolve();\n\t\t\treturn updating.promise;\n\t\t}\n\n\t}\n\n\tcheck(_offsetLeft, _offsetTop){\n\t\tvar checking = new defer();\n\t\tvar newViews = [];\n\n\t\tvar horizontal = (this.settings.axis === \"horizontal\");\n\t\tvar delta = this.settings.offset || 0;\n\n\t\tif (_offsetLeft && horizontal) {\n\t\t\tdelta = _offsetLeft;\n\t\t}\n\n\t\tif (_offsetTop && !horizontal) {\n\t\t\tdelta = _offsetTop;\n\t\t}\n\n\t\tvar bounds = this._bounds; // bounds saved this until resize\n\n\t\tlet offset = horizontal ? this.scrollLeft : this.scrollTop;\n\t\tlet visibleLength = horizontal ? Math.floor(bounds.width) : bounds.height;\n\t\tlet contentLength = horizontal ? this.container.scrollWidth : this.container.scrollHeight;\n\t\tlet writingMode = (this.writingMode && this.writingMode.indexOf(\"vertical\") === 0) ? \"vertical\" : \"horizontal\";\n\t\tlet rtlScrollType = this.settings.rtlScrollType;\n\t\tlet rtl = this.settings.direction === \"rtl\";\n\n\t\tif (!this.settings.fullsize) {\n\t\t\t// Scroll offset starts at width of element\n\t\t\tif (rtl && rtlScrollType === \"default\" && writingMode === \"horizontal\") {\n\t\t\t\toffset = contentLength - visibleLength - offset;\n\t\t\t}\n\t\t\t// Scroll offset starts at 0 and goes negative\n\t\t\tif (rtl && rtlScrollType === \"negative\" && writingMode === \"horizontal\") {\n\t\t\t\toffset = offset * -1;\n\t\t\t}\n\t\t} else {\n\t\t\t// Scroll offset starts at 0 and goes negative\n\t\t\tif ((horizontal && rtl && rtlScrollType === \"negative\") ||\n\t\t\t\t(!horizontal && rtl && rtlScrollType === \"default\")) {\n\t\t\t\toffset = offset * -1;\n\t\t\t}\n\t\t}\n\n\t\tlet prepend = () => {\n\t\t\tlet first = this.views.first();\n\t\t\tlet prev = first && first.section.prev();\n\n\t\t\tif(prev) {\n\t\t\t\tnewViews.push(this.prepend(prev));\n\t\t\t}\n\t\t};\n\n\t\tlet append = () => {\n\t\t\tlet last = this.views.last();\n\t\t\tlet next = last && last.section.next();\n\n\t\t\tif(next) {\n\t\t\t\tnewViews.push(this.append(next));\n\t\t\t}\n\n\t\t};\n\n\t\tlet end = offset + visibleLength + delta;\n\t\tlet start = offset - delta;\n\n\t\tif (end >= contentLength) {\n\t\t\tappend();\n\t\t}\n\t\t\n\t\tif (start < 0) {\n\t\t\tprepend();\n\t\t}\n\t\t\n\n\t\tlet promises = newViews.map((view) => {\n\t\t\treturn view.display(this.request);\n\t\t});\n\n\t\tif(newViews.length){\n\t\t\treturn Promise.all(promises)\n\t\t\t\t.then(() => {\n\t\t\t\t\treturn this.check();\n\t\t\t\t})\n\t\t\t\t.then(() => {\n\t\t\t\t\t// Check to see if anything new is on screen after rendering\n\t\t\t\t\treturn this.update(delta);\n\t\t\t\t}, (err) => {\n\t\t\t\t\treturn err;\n\t\t\t\t});\n\t\t} else {\n\t\t\tthis.q.enqueue(function(){\n\t\t\t\tthis.update();\n\t\t\t}.bind(this));\n\t\t\tchecking.resolve(false);\n\t\t\treturn checking.promise;\n\t\t}\n\n\n\t}\n\n\ttrim(){\n\t\tvar task = new defer();\n\t\tvar displayed = this.views.displayed();\n\t\tvar first = displayed[0];\n\t\tvar last = displayed[displayed.length-1];\n\t\tvar firstIndex = this.views.indexOf(first);\n\t\tvar lastIndex = this.views.indexOf(last);\n\t\tvar above = this.views.slice(0, firstIndex);\n\t\tvar below = this.views.slice(lastIndex+1);\n\n\t\t// Erase all but last above\n\t\tfor (var i = 0; i < above.length-1; i++) {\n\t\t\tthis.erase(above[i], above);\n\t\t}\n\n\t\t// Erase all except first below\n\t\tfor (var j = 1; j < below.length; j++) {\n\t\t\tthis.erase(below[j]);\n\t\t}\n\n\t\ttask.resolve();\n\t\treturn task.promise;\n\t}\n\n\terase(view, above){ //Trim\n\n\t\tvar prevTop;\n\t\tvar prevLeft;\n\n\t\tif(!this.settings.fullsize) {\n\t\t\tprevTop = this.container.scrollTop;\n\t\t\tprevLeft = this.container.scrollLeft;\n\t\t} else {\n\t\t\tprevTop = window.scrollY;\n\t\t\tprevLeft = window.scrollX;\n\t\t}\n\n\t\tvar bounds = view.bounds();\n\n\t\tthis.views.remove(view);\n\t\t\n\t\tif(above) {\n\t\t\tif (this.settings.axis === \"vertical\") {\n\t\t\t\tthis.scrollTo(0, prevTop - bounds.height, true);\n\t\t\t} else {\n\t\t\t\tif(this.settings.direction === 'rtl') {\n\t\t\t\t\tif (!this.settings.fullsize) {\n\t\t\t\t\t\tthis.scrollTo(prevLeft, 0, true);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.scrollTo(prevLeft + Math.floor(bounds.width), 0, true);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthis.scrollTo(prevLeft - Math.floor(bounds.width), 0, true);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}\n\n\taddEventListeners(stage){\n\n\t\twindow.addEventListener(\"unload\", function(e){\n\t\t\tthis.ignore = true;\n\t\t\t// this.scrollTo(0,0);\n\t\t\tthis.destroy();\n\t\t}.bind(this));\n\n\t\tthis.addScrollListeners();\n\n\t\tif (this.isPaginated && this.settings.snap) {\n\t\t\tthis.snapper = new Snap(this, this.settings.snap && (typeof this.settings.snap === \"object\") && this.settings.snap);\n\t\t}\n\t}\n\n\taddScrollListeners() {\n\t\tvar scroller;\n\n\t\tthis.tick = requestAnimationFrame;\n\n\t\tlet dir = this.settings.direction === \"rtl\" && this.settings.rtlScrollType === \"default\" ? -1 : 1;\n\n\t\tthis.scrollDeltaVert = 0;\n\t\tthis.scrollDeltaHorz = 0;\n\n\t\tif(!this.settings.fullsize) {\n\t\t\tscroller = this.container;\n\t\t\tthis.scrollTop = this.container.scrollTop;\n\t\t\tthis.scrollLeft = this.container.scrollLeft;\n\t\t} else {\n\t\t\tscroller = window;\n\t\t\tthis.scrollTop = window.scrollY * dir;\n\t\t\tthis.scrollLeft = window.scrollX * dir;\n\t\t}\n\n\t\tthis._onScroll = this.onScroll.bind(this);\n\t\tscroller.addEventListener(\"scroll\", this._onScroll);\n\t\tthis._scrolled = debounce(this.scrolled.bind(this), 30);\n\t\t// this.tick.call(window, this.onScroll.bind(this));\n\n\t\tthis.didScroll = false;\n\n\t}\n\n\tremoveEventListeners(){\n\t\tvar scroller;\n\n\t\tif(!this.settings.fullsize) {\n\t\t\tscroller = this.container;\n\t\t} else {\n\t\t\tscroller = window;\n\t\t}\n\n\t\tscroller.removeEventListener(\"scroll\", this._onScroll);\n\t\tthis._onScroll = undefined;\n\t}\n\n\tonScroll(){\n\t\tlet scrollTop;\n\t\tlet scrollLeft;\n\t\tlet dir = this.settings.direction === \"rtl\" && this.settings.rtlScrollType === \"default\" ? -1 : 1;\n\n\t\tif(!this.settings.fullsize) {\n\t\t\tscrollTop = this.container.scrollTop;\n\t\t\tscrollLeft = this.container.scrollLeft;\n\t\t} else {\n\t\t\tscrollTop = window.scrollY * dir;\n\t\t\tscrollLeft = window.scrollX * dir;\n\t\t}\n\n\t\tthis.scrollTop = scrollTop;\n\t\tthis.scrollLeft = scrollLeft;\n\n\t\tif(!this.ignore) {\n\n\t\t\tthis._scrolled();\n\n\t\t} else {\n\t\t\tthis.ignore = false;\n\t\t}\n\n\t\tthis.scrollDeltaVert += Math.abs(scrollTop-this.prevScrollTop);\n\t\tthis.scrollDeltaHorz += Math.abs(scrollLeft-this.prevScrollLeft);\n\n\t\tthis.prevScrollTop = scrollTop;\n\t\tthis.prevScrollLeft = scrollLeft;\n\n\t\tclearTimeout(this.scrollTimeout);\n\t\tthis.scrollTimeout = setTimeout(function(){\n\t\t\tthis.scrollDeltaVert = 0;\n\t\t\tthis.scrollDeltaHorz = 0;\n\t\t}.bind(this), 150);\n\n\t\tclearTimeout(this.afterScrolled);\n\n\t\tthis.didScroll = false;\n\n\t}\n\n\tscrolled() {\n\n\t\tthis.q.enqueue(function() {\n\t\t\treturn this.check();\n\t\t}.bind(this));\n\n\t\tthis.emit(EVENTS.MANAGERS.SCROLL, {\n\t\t\ttop: this.scrollTop,\n\t\t\tleft: this.scrollLeft\n\t\t});\n\n\t\tclearTimeout(this.afterScrolled);\n\t\tthis.afterScrolled = setTimeout(function () {\n\n\t\t\t// Don't report scroll if we are about the snap\n\t\t\tif (this.snapper && this.snapper.supportsTouch && this.snapper.needsSnap()) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.emit(EVENTS.MANAGERS.SCROLLED, {\n\t\t\t\ttop: this.scrollTop,\n\t\t\t\tleft: this.scrollLeft\n\t\t\t});\n\n\t\t}.bind(this), this.settings.afterScrolledTimeout);\n\t}\n\n\tnext(){\n\n\t\tlet delta = this.layout.props.name === \"pre-paginated\" &&\n\t\t\t\t\t\t\t\tthis.layout.props.spread ? this.layout.props.delta * 2 : this.layout.props.delta;\n\n\t\tif(!this.views.length) return;\n\n\t\tif(this.isPaginated && this.settings.axis === \"horizontal\") {\n\n\t\t\tthis.scrollBy(delta, 0, true);\n\n\t\t} else {\n\n\t\t\tthis.scrollBy(0, this.layout.height, true);\n\n\t\t}\n\n\t\tthis.q.enqueue(function() {\n\t\t\treturn this.check();\n\t\t}.bind(this));\n\t}\n\n\tprev(){\n\n\t\tlet delta = this.layout.props.name === \"pre-paginated\" &&\n\t\t\t\t\t\t\t\tthis.layout.props.spread ? this.layout.props.delta * 2 : this.layout.props.delta;\n\n\t\tif(!this.views.length) return;\n\n\t\tif(this.isPaginated && this.settings.axis === \"horizontal\") {\n\n\t\t\tthis.scrollBy(-delta, 0, true);\n\n\t\t} else {\n\n\t\t\tthis.scrollBy(0, -this.layout.height, true);\n\n\t\t}\n\n\t\tthis.q.enqueue(function() {\n\t\t\treturn this.check();\n\t\t}.bind(this));\n\t}\n\n\tupdateFlow(flow){\n\t\tif (this.rendered && this.snapper) {\n\t\t\tthis.snapper.destroy();\n\t\t\tthis.snapper = undefined;\n\t\t}\n\n\t\tsuper.updateFlow(flow, \"scroll\");\n\n\t\tif (this.rendered && this.isPaginated && this.settings.snap) {\n\t\t\tthis.snapper = new Snap(this, this.settings.snap && (typeof this.settings.snap === \"object\") && this.settings.snap);\n\t\t}\n\t}\n\n\tdestroy(){\n\t\tsuper.destroy();\n\n\t\tif (this.snapper) {\n\t\t\tthis.snapper.destroy();\n\t\t}\n\t}\n\n}\n\nexport default ContinuousViewManager;\n","import EventEmitter from \"event-emitter\";\nimport { extend, defer, isFloat } from \"./utils/core\";\nimport Hook from \"./utils/hook\";\nimport EpubCFI from \"./epubcfi\";\nimport Queue from \"./utils/queue\";\nimport Layout from \"./layout\";\n// import Mapping from \"./mapping\";\nimport Themes from \"./themes\";\nimport Contents from \"./contents\";\nimport Annotations from \"./annotations\";\nimport { EVENTS, DOM_EVENTS } from \"./utils/constants\";\n\n// Default Views\nimport IframeView from \"./managers/views/iframe\";\n\n// Default View Managers\nimport DefaultViewManager from \"./managers/default/index\";\nimport ContinuousViewManager from \"./managers/continuous/index\";\n\n/**\n * Displays an Epub as a series of Views for each Section.\n * Requires Manager and View class to handle specifics of rendering\n * the section content.\n * @class\n * @param {Book} book\n * @param {object} [options]\n * @param {number} [options.width]\n * @param {number} [options.height]\n * @param {string} [options.ignoreClass] class for the cfi parser to ignore\n * @param {string | function | object} [options.manager='default']\n * @param {string | function} [options.view='iframe']\n * @param {string} [options.layout] layout to force\n * @param {string} [options.spread] force spread value\n * @param {number} [options.minSpreadWidth] overridden by spread: none (never) / both (always)\n * @param {string} [options.stylesheet] url of stylesheet to be injected\n * @param {boolean} [options.resizeOnOrientationChange] false to disable orientation events\n * @param {string} [options.script] url of script to be injected\n * @param {boolean | object} [options.snap=false] use snap scrolling\n * @param {string} [options.defaultDirection='ltr'] default text direction\n * @param {boolean} [options.allowScriptedContent=false] enable running scripts in content\n * @param {boolean} [options.allowPopups=false] enable opening popup in content\n */\nclass Rendition {\n\tconstructor(book, options) {\n\n\t\tthis.settings = extend(this.settings || {}, {\n\t\t\twidth: null,\n\t\t\theight: null,\n\t\t\tignoreClass: \"\",\n\t\t\tmanager: \"default\",\n\t\t\tview: \"iframe\",\n\t\t\tflow: null,\n\t\t\tlayout: null,\n\t\t\tspread: null,\n\t\t\tminSpreadWidth: 800,\n\t\t\tstylesheet: null,\n\t\t\tresizeOnOrientationChange: true,\n\t\t\tscript: null,\n\t\t\tsnap: false,\n\t\t\tdefaultDirection: \"ltr\",\n\t\t\tallowScriptedContent: false,\n\t\t\tallowPopups: false\n\t\t});\n\n\t\textend(this.settings, options);\n\n\t\tif (typeof(this.settings.manager) === \"object\") {\n\t\t\tthis.manager = this.settings.manager;\n\t\t}\n\n\t\tthis.book = book;\n\n\t\t/**\n\t\t * Adds Hook methods to the Rendition prototype\n\t\t * @member {object} hooks\n\t\t * @property {Hook} hooks.content\n\t\t * @memberof Rendition\n\t\t */\n\t\tthis.hooks = {};\n\t\tthis.hooks.display = new Hook(this);\n\t\tthis.hooks.serialize = new Hook(this);\n\t\tthis.hooks.content = new Hook(this);\n\t\tthis.hooks.unloaded = new Hook(this);\n\t\tthis.hooks.layout = new Hook(this);\n\t\tthis.hooks.render = new Hook(this);\n\t\tthis.hooks.show = new Hook(this);\n\n\t\tthis.hooks.content.register(this.handleLinks.bind(this));\n\t\tthis.hooks.content.register(this.passEvents.bind(this));\n\t\tthis.hooks.content.register(this.adjustImages.bind(this));\n\n\t\tthis.book.spine.hooks.content.register(this.injectIdentifier.bind(this));\n\n\t\tif (this.settings.stylesheet) {\n\t\t\tthis.book.spine.hooks.content.register(this.injectStylesheet.bind(this));\n\t\t}\n\n\t\tif (this.settings.script) {\n\t\t\tthis.book.spine.hooks.content.register(this.injectScript.bind(this));\n\t\t}\n\n\t\t/**\n\t\t * @member {Themes} themes\n\t\t * @memberof Rendition\n\t\t */\n\t\tthis.themes = new Themes(this);\n\n\t\t/**\n\t\t * @member {Annotations} annotations\n\t\t * @memberof Rendition\n\t\t */\n\t\tthis.annotations = new Annotations(this);\n\n\t\tthis.epubcfi = new EpubCFI();\n\n\t\tthis.q = new Queue(this);\n\n\t\t/**\n\t\t * A Rendered Location Range\n\t\t * @typedef location\n\t\t * @type {Object}\n\t\t * @property {object} start\n\t\t * @property {string} start.index\n\t\t * @property {string} start.href\n\t\t * @property {object} start.displayed\n\t\t * @property {EpubCFI} start.cfi\n\t\t * @property {number} start.location\n\t\t * @property {number} start.percentage\n\t\t * @property {number} start.displayed.page\n\t\t * @property {number} start.displayed.total\n\t\t * @property {object} end\n\t\t * @property {string} end.index\n\t\t * @property {string} end.href\n\t\t * @property {object} end.displayed\n\t\t * @property {EpubCFI} end.cfi\n\t\t * @property {number} end.location\n\t\t * @property {number} end.percentage\n\t\t * @property {number} end.displayed.page\n\t\t * @property {number} end.displayed.total\n\t\t * @property {boolean} atStart\n\t\t * @property {boolean} atEnd\n\t\t * @memberof Rendition\n\t\t */\n\t\tthis.location = undefined;\n\n\t\t// Hold queue until book is opened\n\t\tthis.q.enqueue(this.book.opened);\n\n\t\tthis.starting = new defer();\n\t\t/**\n\t\t * @member {promise} started returns after the rendition has started\n\t\t * @memberof Rendition\n\t\t */\n\t\tthis.started = this.starting.promise;\n\n\t\t// Block the queue until rendering is started\n\t\tthis.q.enqueue(this.start);\n\t}\n\n\t/**\n\t * Set the manager function\n\t * @param {function} manager\n\t */\n\tsetManager(manager) {\n\t\tthis.manager = manager;\n\t}\n\n\t/**\n\t * Require the manager from passed string, or as a class function\n\t * @param {string|object} manager [description]\n\t * @return {method}\n\t */\n\trequireManager(manager) {\n\t\tvar viewManager;\n\n\t\t// If manager is a string, try to load from imported managers\n\t\tif (typeof manager === \"string\" && manager === \"default\") {\n\t\t\tviewManager = DefaultViewManager;\n\t\t} else if (typeof manager === \"string\" && manager === \"continuous\") {\n\t\t\tviewManager = ContinuousViewManager;\n\t\t} else {\n\t\t\t// otherwise, assume we were passed a class function\n\t\t\tviewManager = manager;\n\t\t}\n\n\t\treturn viewManager;\n\t}\n\n\t/**\n\t * Require the view from passed string, or as a class function\n\t * @param {string|object} view\n\t * @return {view}\n\t */\n\trequireView(view) {\n\t\tvar View;\n\n\t\t// If view is a string, try to load from imported views,\n\t\tif (typeof view == \"string\" && view === \"iframe\") {\n\t\t\tView = IframeView;\n\t\t} else {\n\t\t\t// otherwise, assume we were passed a class function\n\t\t\tView = view;\n\t\t}\n\n\t\treturn View;\n\t}\n\n\t/**\n\t * Start the rendering\n\t * @return {Promise} rendering has started\n\t */\n\tstart(){\n\t\tif (!this.settings.layout && (this.book.package.metadata.layout === \"pre-paginated\" || this.book.displayOptions.fixedLayout === \"true\")) {\n\t\t\tthis.settings.layout = \"pre-paginated\";\n\t\t}\n\t\tswitch(this.book.package.metadata.spread) {\n\t\t\tcase 'none':\n\t\t\t\tthis.settings.spread = 'none';\n\t\t\t\tbreak;\n\t\t\tcase 'both':\n\t\t\t\tthis.settings.spread = true;\n\t\t\t\tbreak;\n\t\t}\n\n\t\tif(!this.manager) {\n\t\t\tthis.ViewManager = this.requireManager(this.settings.manager);\n\t\t\tthis.View = this.requireView(this.settings.view);\n\n\t\t\tthis.manager = new this.ViewManager({\n\t\t\t\tview: this.View,\n\t\t\t\tqueue: this.q,\n\t\t\t\trequest: this.book.load.bind(this.book),\n\t\t\t\tsettings: this.settings\n\t\t\t});\n\t\t}\n\n\t\tthis.direction(this.book.package.metadata.direction || this.settings.defaultDirection);\n\n\t\t// Parse metadata to get layout props\n\t\tthis.settings.globalLayoutProperties = this.determineLayoutProperties(this.book.package.metadata);\n\n\t\tthis.flow(this.settings.globalLayoutProperties.flow);\n\n\t\tthis.layout(this.settings.globalLayoutProperties);\n\n\t\t// Listen for displayed views\n\t\tthis.manager.on(EVENTS.MANAGERS.ADDED, this.afterDisplayed.bind(this));\n\t\tthis.manager.on(EVENTS.MANAGERS.REMOVED, this.afterRemoved.bind(this));\n\n\t\t// Listen for resizing\n\t\tthis.manager.on(EVENTS.MANAGERS.RESIZED, this.onResized.bind(this));\n\n\t\t// Listen for rotation\n\t\tthis.manager.on(EVENTS.MANAGERS.ORIENTATION_CHANGE, this.onOrientationChange.bind(this));\n\n\t\t// Listen for scroll changes\n\t\tthis.manager.on(EVENTS.MANAGERS.SCROLLED, this.reportLocation.bind(this));\n\n\t\t/**\n\t\t * Emit that rendering has started\n\t\t * @event started\n\t\t * @memberof Rendition\n\t\t */\n\t\tthis.emit(EVENTS.RENDITION.STARTED);\n\n\t\t// Start processing queue\n\t\tthis.starting.resolve();\n\t}\n\n\t/**\n\t * Call to attach the container to an element in the dom\n\t * Container must be attached before rendering can begin\n\t * @param {element} element to attach to\n\t * @return {Promise}\n\t */\n\tattachTo(element){\n\n\t\treturn this.q.enqueue(function () {\n\n\t\t\t// Start rendering\n\t\t\tthis.manager.render(element, {\n\t\t\t\t\"width\" : this.settings.width,\n\t\t\t\t\"height\" : this.settings.height\n\t\t\t});\n\n\t\t\t/**\n\t\t\t * Emit that rendering has attached to an element\n\t\t\t * @event attached\n\t\t\t * @memberof Rendition\n\t\t\t */\n\t\t\tthis.emit(EVENTS.RENDITION.ATTACHED);\n\n\t\t}.bind(this));\n\n\t}\n\n\t/**\n\t * Display a point in the book\n\t * The request will be added to the rendering Queue,\n\t * so it will wait until book is opened, rendering started\n\t * and all other rendering tasks have finished to be called.\n\t * @param {string} target Url or EpubCFI\n\t * @return {Promise}\n\t */\n\tdisplay(target){\n\t\tif (this.displaying) {\n\t\t\tthis.displaying.resolve();\n\t\t}\n\t\treturn this.q.enqueue(this._display, target);\n\t}\n\n\t/**\n\t * Tells the manager what to display immediately\n\t * @private\n\t * @param {string} target Url or EpubCFI\n\t * @return {Promise}\n\t */\n\t_display(target){\n\t\tif (!this.book) {\n\t\t\treturn;\n\t\t}\n\t\tvar isCfiString = this.epubcfi.isCfiString(target);\n\t\tvar displaying = new defer();\n\t\tvar displayed = displaying.promise;\n\t\tvar section;\n\t\tvar moveTo;\n\n\t\tthis.displaying = displaying;\n\n\t\t// Check if this is a book percentage\n\t\tif (this.book.locations.length() && isFloat(target)) {\n\t\t\ttarget = this.book.locations.cfiFromPercentage(parseFloat(target));\n\t\t}\n\n\t\tsection = this.book.spine.get(target);\n\n\t\tif(!section){\n\t\t\tdisplaying.reject(new Error(\"No Section Found\"));\n\t\t\treturn displayed;\n\t\t}\n\n\t\tthis.manager.display(section, target)\n\t\t\t.then(() => {\n\t\t\t\tdisplaying.resolve(section);\n\t\t\t\tthis.displaying = undefined;\n\n\t\t\t\t/**\n\t\t\t\t * Emit that a section has been displayed\n\t\t\t\t * @event displayed\n\t\t\t\t * @param {Section} section\n\t\t\t\t * @memberof Rendition\n\t\t\t\t */\n\t\t\t\tthis.emit(EVENTS.RENDITION.DISPLAYED, section);\n\t\t\t\tthis.reportLocation();\n\t\t\t}, (err) => {\n\t\t\t\t/**\n\t\t\t\t * Emit that has been an error displaying\n\t\t\t\t * @event displayError\n\t\t\t\t * @param {Section} section\n\t\t\t\t * @memberof Rendition\n\t\t\t\t */\n\t\t\t\tthis.emit(EVENTS.RENDITION.DISPLAY_ERROR, err);\n\t\t\t});\n\n\t\treturn displayed;\n\t}\n\n\t/*\n\trender(view, show) {\n\n\t\t// view.onLayout = this.layout.format.bind(this.layout);\n\t\tview.create();\n\n\t\t// Fit to size of the container, apply padding\n\t\tthis.manager.resizeView(view);\n\n\t\t// Render Chain\n\t\treturn view.section.render(this.book.request)\n\t\t\t.then(function(contents){\n\t\t\t\treturn view.load(contents);\n\t\t\t}.bind(this))\n\t\t\t.then(function(doc){\n\t\t\t\treturn this.hooks.content.trigger(view, this);\n\t\t\t}.bind(this))\n\t\t\t.then(function(){\n\t\t\t\tthis.layout.format(view.contents);\n\t\t\t\treturn this.hooks.layout.trigger(view, this);\n\t\t\t}.bind(this))\n\t\t\t.then(function(){\n\t\t\t\treturn view.display();\n\t\t\t}.bind(this))\n\t\t\t.then(function(){\n\t\t\t\treturn this.hooks.render.trigger(view, this);\n\t\t\t}.bind(this))\n\t\t\t.then(function(){\n\t\t\t\tif(show !== false) {\n\t\t\t\t\tthis.q.enqueue(function(view){\n\t\t\t\t\t\tview.show();\n\t\t\t\t\t}, view);\n\t\t\t\t}\n\t\t\t\t// this.map = new Map(view, this.layout);\n\t\t\t\tthis.hooks.show.trigger(view, this);\n\t\t\t\tthis.trigger(\"rendered\", view.section);\n\n\t\t\t}.bind(this))\n\t\t\t.catch(function(e){\n\t\t\t\tthis.trigger(\"loaderror\", e);\n\t\t\t}.bind(this));\n\n\t}\n\t*/\n\n\t/**\n\t * Report what section has been displayed\n\t * @private\n\t * @param {*} view\n\t */\n\tafterDisplayed(view){\n\n\t\tview.on(EVENTS.VIEWS.MARK_CLICKED, (cfiRange, data) => this.triggerMarkEvent(cfiRange, data, view.contents));\n\n\t\tthis.hooks.render.trigger(view, this)\n\t\t\t.then(() => {\n\t\t\t\tif (view.contents) {\n\t\t\t\t\tthis.hooks.content.trigger(view.contents, this).then(() => {\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * Emit that a section has been rendered\n\t\t\t\t\t\t * @event rendered\n\t\t\t\t\t\t * @param {Section} section\n\t\t\t\t\t\t * @param {View} view\n\t\t\t\t\t\t * @memberof Rendition\n\t\t\t\t\t\t */\n\t\t\t\t\t\tthis.emit(EVENTS.RENDITION.RENDERED, view.section, view);\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tthis.emit(EVENTS.RENDITION.RENDERED, view.section, view);\n\t\t\t\t}\n\t\t\t});\n\n\t}\n\n\t/**\n\t * Report what has been removed\n\t * @private\n\t * @param {*} view\n\t */\n\tafterRemoved(view){\n\t\tthis.hooks.unloaded.trigger(view, this).then(() => {\n\t\t\t/**\n\t\t\t * Emit that a section has been removed\n\t\t\t * @event removed\n\t\t\t * @param {Section} section\n\t\t\t * @param {View} view\n\t\t\t * @memberof Rendition\n\t\t\t */\n\t\t\tthis.emit(EVENTS.RENDITION.REMOVED, view.section, view);\n\t\t});\n\t}\n\n\t/**\n\t * Report resize events and display the last seen location\n\t * @private\n\t */\n\tonResized(size, epubcfi){\n\n\t\t/**\n\t\t * Emit that the rendition has been resized\n\t\t * @event resized\n\t\t * @param {number} width\n\t\t * @param {height} height\n\t\t * @param {string} epubcfi (optional)\n\t\t * @memberof Rendition\n\t\t */\n\t\tthis.emit(EVENTS.RENDITION.RESIZED, {\n\t\t\twidth: size.width,\n\t\t\theight: size.height\n\t\t}, epubcfi);\n\n\t\tif (this.location && this.location.start) {\n\t\t\tthis.display(epubcfi || this.location.start.cfi);\n\t\t}\n\n\t}\n\n\t/**\n\t * Report orientation events and display the last seen location\n\t * @private\n\t */\n\tonOrientationChange(orientation){\n\t\t/**\n\t\t * Emit that the rendition has been rotated\n\t\t * @event orientationchange\n\t\t * @param {string} orientation\n\t\t * @memberof Rendition\n\t\t */\n\t\tthis.emit(EVENTS.RENDITION.ORIENTATION_CHANGE, orientation);\n\t}\n\n\t/**\n\t * Move the Rendition to a specific offset\n\t * Usually you would be better off calling display()\n\t * @param {object} offset\n\t */\n\tmoveTo(offset){\n\t\tthis.manager.moveTo(offset);\n\t}\n\n\t/**\n\t * Trigger a resize of the views\n\t * @param {number} [width]\n\t * @param {number} [height]\n\t * @param {string} [epubcfi] (optional)\n\t */\n\tresize(width, height, epubcfi){\n\t\tif (width) {\n\t\t\tthis.settings.width = width;\n\t\t}\n\t\tif (height) {\n\t\t\tthis.settings.height = height;\n\t\t}\n\t\tthis.manager.resize(width, height, epubcfi);\n\t}\n\n\t/**\n\t * Clear all rendered views\n\t */\n\tclear(){\n\t\tthis.manager.clear();\n\t}\n\n\t/**\n\t * Go to the next \"page\" in the rendition\n\t * @return {Promise}\n\t */\n\tnext(){\n\t\treturn this.q.enqueue(this.manager.next.bind(this.manager))\n\t\t\t.then(this.reportLocation.bind(this));\n\t}\n\n\t/**\n\t * Go to the previous \"page\" in the rendition\n\t * @return {Promise}\n\t */\n\tprev(){\n\t\treturn this.q.enqueue(this.manager.prev.bind(this.manager))\n\t\t\t.then(this.reportLocation.bind(this));\n\t}\n\n\t//-- http://www.idpf.org/epub/301/spec/epub-publications.html#meta-properties-rendering\n\t/**\n\t * Determine the Layout properties from metadata and settings\n\t * @private\n\t * @param {object} metadata\n\t * @return {object} properties\n\t */\n\tdetermineLayoutProperties(metadata){\n\t\tvar properties;\n\t\tvar layout = this.settings.layout || metadata.layout || \"reflowable\";\n\t\tvar spread = this.settings.spread || metadata.spread || \"auto\";\n\t\tvar orientation = this.settings.orientation || metadata.orientation || \"auto\";\n\t\tvar flow = this.settings.flow || metadata.flow || \"auto\";\n\t\tvar viewport = metadata.viewport || \"\";\n\t\tvar minSpreadWidth = this.settings.minSpreadWidth || metadata.minSpreadWidth || 800;\n\t\tvar direction = this.settings.direction || metadata.direction || \"ltr\";\n\n\t\tif ((this.settings.width === 0 || this.settings.width > 0) &&\n\t\t\t\t(this.settings.height === 0 || this.settings.height > 0)) {\n\t\t\t// viewport = \"width=\"+this.settings.width+\", height=\"+this.settings.height+\"\";\n\t\t}\n\n\t\tproperties = {\n\t\t\tlayout : layout,\n\t\t\tspread : spread,\n\t\t\torientation : orientation,\n\t\t\tflow : flow,\n\t\t\tviewport : viewport,\n\t\t\tminSpreadWidth : minSpreadWidth,\n\t\t\tdirection: direction\n\t\t};\n\n\t\treturn properties;\n\t}\n\n\t/**\n\t * Adjust the flow of the rendition to paginated or scrolled\n\t * (scrolled-continuous vs scrolled-doc are handled by different view managers)\n\t * @param {string} flow\n\t */\n\tflow(flow){\n\t\tvar _flow = flow;\n\t\tif (flow === \"scrolled\" ||\n\t\t\t\tflow === \"scrolled-doc\" ||\n\t\t\t\tflow === \"scrolled-continuous\") {\n\t\t\t_flow = \"scrolled\";\n\t\t}\n\n\t\tif (flow === \"auto\" || flow === \"paginated\") {\n\t\t\t_flow = \"paginated\";\n\t\t}\n\n\t\tthis.settings.flow = flow;\n\n\t\tif (this._layout) {\n\t\t\tthis._layout.flow(_flow);\n\t\t}\n\n\t\tif (this.manager && this._layout) {\n\t\t\tthis.manager.applyLayout(this._layout);\n\t\t}\n\n\t\tif (this.manager) {\n\t\t\tthis.manager.updateFlow(_flow);\n\t\t}\n\n\t\tif (this.manager && this.manager.isRendered() && this.location) {\n\t\t\tthis.manager.clear();\n\t\t\tthis.display(this.location.start.cfi);\n\t\t}\n\t}\n\n\t/**\n\t * Adjust the layout of the rendition to reflowable or pre-paginated\n\t * @param {object} settings\n\t */\n\tlayout(settings){\n\t\tif (settings) {\n\t\t\tthis._layout = new Layout(settings);\n\t\t\tthis._layout.spread(settings.spread, this.settings.minSpreadWidth);\n\n\t\t\t// this.mapping = new Mapping(this._layout.props);\n\n\t\t\tthis._layout.on(EVENTS.LAYOUT.UPDATED, (props, changed) => {\n\t\t\t\tthis.emit(EVENTS.RENDITION.LAYOUT, props, changed);\n\t\t\t})\n\t\t}\n\n\t\tif (this.manager && this._layout) {\n\t\t\tthis.manager.applyLayout(this._layout);\n\t\t}\n\n\t\treturn this._layout;\n\t}\n\n\t/**\n\t * Adjust if the rendition uses spreads\n\t * @param {string} spread none | auto (TODO: implement landscape, portrait, both)\n\t * @param {int} [min] min width to use spreads at\n\t */\n\tspread(spread, min){\n\n\t\tthis.settings.spread = spread;\n\n\t\tif (min) {\n\t\t\tthis.settings.minSpreadWidth = min;\n\t\t}\n\n\t\tif (this._layout) {\n\t\t\tthis._layout.spread(spread, min);\n\t\t}\n\n\t\tif (this.manager && this.manager.isRendered()) {\n\t\t\tthis.manager.updateLayout();\n\t\t}\n\t}\n\n\t/**\n\t * Adjust the direction of the rendition\n\t * @param {string} dir\n\t */\n\tdirection(dir){\n\n\t\tthis.settings.direction = dir || \"ltr\";\n\n\t\tif (this.manager) {\n\t\t\tthis.manager.direction(this.settings.direction);\n\t\t}\n\n\t\tif (this.manager && this.manager.isRendered() && this.location) {\n\t\t\tthis.manager.clear();\n\t\t\tthis.display(this.location.start.cfi);\n\t\t}\n\t}\n\n\t/**\n\t * Report the current location\n\t * @fires relocated\n\t * @fires locationChanged\n\t */\n\treportLocation(){\n\t\treturn this.q.enqueue(function reportedLocation(){\n\t\t\trequestAnimationFrame(function reportedLocationAfterRAF() {\n\t\t\t\tvar location = this.manager.currentLocation();\n\t\t\t\tif (location && location.then && typeof location.then === \"function\") {\n\t\t\t\t\tlocation.then(function(result) {\n\t\t\t\t\t\tlet located = this.located(result);\n\n\t\t\t\t\t\tif (!located || !located.start || !located.end) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis.location = located;\n\n\t\t\t\t\t\tthis.emit(EVENTS.RENDITION.LOCATION_CHANGED, {\n\t\t\t\t\t\t\tindex: this.location.start.index,\n\t\t\t\t\t\t\thref: this.location.start.href,\n\t\t\t\t\t\t\tstart: this.location.start.cfi,\n\t\t\t\t\t\t\tend: this.location.end.cfi,\n\t\t\t\t\t\t\tpercentage: this.location.start.percentage\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tthis.emit(EVENTS.RENDITION.RELOCATED, this.location);\n\t\t\t\t\t}.bind(this));\n\t\t\t\t} else if (location) {\n\t\t\t\t\tlet located = this.located(location);\n\n\t\t\t\t\tif (!located || !located.start || !located.end) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.location = located;\n\n\t\t\t\t\t/**\n\t\t\t\t\t * @event locationChanged\n\t\t\t\t\t * @deprecated\n\t\t\t\t\t * @type {object}\n\t\t\t\t\t * @property {number} index\n\t\t\t\t\t * @property {string} href\n\t\t\t\t\t * @property {EpubCFI} start\n\t\t\t\t\t * @property {EpubCFI} end\n\t\t\t\t\t * @property {number} percentage\n\t\t\t\t\t * @memberof Rendition\n\t\t\t\t\t */\n\t\t\t\t\tthis.emit(EVENTS.RENDITION.LOCATION_CHANGED, {\n\t\t\t\t\t\tindex: this.location.start.index,\n\t\t\t\t\t\thref: this.location.start.href,\n\t\t\t\t\t\tstart: this.location.start.cfi,\n\t\t\t\t\t\tend: this.location.end.cfi,\n\t\t\t\t\t\tpercentage: this.location.start.percentage\n\t\t\t\t\t});\n\n\t\t\t\t\t/**\n\t\t\t\t\t * @event relocated\n\t\t\t\t\t * @type {displayedLocation}\n\t\t\t\t\t * @memberof Rendition\n\t\t\t\t\t */\n\t\t\t\t\tthis.emit(EVENTS.RENDITION.RELOCATED, this.location);\n\t\t\t\t}\n\t\t\t}.bind(this));\n\t\t}.bind(this));\n\t}\n\n\t/**\n\t * Get the Current Location object\n\t * @return {displayedLocation | promise} location (may be a promise)\n\t */\n\tcurrentLocation(){\n\t\tvar location = this.manager.currentLocation();\n\t\tif (location && location.then && typeof location.then === \"function\") {\n\t\t\tlocation.then(function(result) {\n\t\t\t\tlet located = this.located(result);\n\t\t\t\treturn located;\n\t\t\t}.bind(this));\n\t\t} else if (location) {\n\t\t\tlet located = this.located(location);\n\t\t\treturn located;\n\t\t}\n\t}\n\n\t/**\n\t * Creates a Rendition#locationRange from location\n\t * passed by the Manager\n\t * @returns {displayedLocation}\n\t * @private\n\t */\n\tlocated(location){\n\t\tif (!location.length) {\n\t\t\treturn {};\n\t\t}\n\t\tlet start = location[0];\n\t\tlet end = location[location.length-1];\n\n\t\tlet located = {\n\t\t\tstart: {\n\t\t\t\tindex: start.index,\n\t\t\t\thref: start.href,\n\t\t\t\tcfi: start.mapping.start,\n\t\t\t\tdisplayed: {\n\t\t\t\t\tpage: start.pages[0] || 1,\n\t\t\t\t\ttotal: start.totalPages\n\t\t\t\t}\n\t\t\t},\n\t\t\tend: {\n\t\t\t\tindex: end.index,\n\t\t\t\thref: end.href,\n\t\t\t\tcfi: end.mapping.end,\n\t\t\t\tdisplayed: {\n\t\t\t\t\tpage: end.pages[end.pages.length-1] || 1,\n\t\t\t\t\ttotal: end.totalPages\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tlet locationStart = this.book.locations.locationFromCfi(start.mapping.start);\n\t\tlet locationEnd = this.book.locations.locationFromCfi(end.mapping.end);\n\n\t\tif (locationStart != null) {\n\t\t\tlocated.start.location = locationStart;\n\t\t\tlocated.start.percentage = this.book.locations.percentageFromLocation(locationStart);\n\t\t}\n\t\tif (locationEnd != null) {\n\t\t\tlocated.end.location = locationEnd;\n\t\t\tlocated.end.percentage = this.book.locations.percentageFromLocation(locationEnd);\n\t\t}\n\n\t\tlet pageStart = this.book.pageList.pageFromCfi(start.mapping.start);\n\t\tlet pageEnd = this.book.pageList.pageFromCfi(end.mapping.end);\n\n\t\tif (pageStart != -1) {\n\t\t\tlocated.start.page = pageStart;\n\t\t}\n\t\tif (pageEnd != -1) {\n\t\t\tlocated.end.page = pageEnd;\n\t\t}\n\n\t\tif (end.index === this.book.spine.last().index &&\n\t\t\t\tlocated.end.displayed.page >= located.end.displayed.total) {\n\t\t\tlocated.atEnd = true;\n\t\t}\n\n\t\tif (start.index === this.book.spine.first().index &&\n\t\t\t\tlocated.start.displayed.page === 1) {\n\t\t\tlocated.atStart = true;\n\t\t}\n\n\t\treturn located;\n\t}\n\n\t/**\n\t * Remove and Clean Up the Rendition\n\t */\n\tdestroy(){\n\t\t// Clear the queue\n\t\t// this.q.clear();\n\t\t// this.q = undefined;\n\n\t\tthis.manager && this.manager.destroy();\n\n\t\tthis.book = undefined;\n\n\t\t// this.views = null;\n\n\t\t// this.hooks.display.clear();\n\t\t// this.hooks.serialize.clear();\n\t\t// this.hooks.content.clear();\n\t\t// this.hooks.layout.clear();\n\t\t// this.hooks.render.clear();\n\t\t// this.hooks.show.clear();\n\t\t// this.hooks = {};\n\n\t\t// this.themes.destroy();\n\t\t// this.themes = undefined;\n\n\t\t// this.epubcfi = undefined;\n\n\t\t// this.starting = undefined;\n\t\t// this.started = undefined;\n\n\n\t}\n\n\t/**\n\t * Pass the events from a view's Contents\n\t * @private\n\t * @param {Contents} view contents\n\t */\n\tpassEvents(contents){\n\t\tDOM_EVENTS.forEach((e) => {\n\t\t\tcontents.on(e, (ev) => this.triggerViewEvent(ev, contents));\n\t\t});\n\n\t\tcontents.on(EVENTS.CONTENTS.SELECTED, (e) => this.triggerSelectedEvent(e, contents));\n\t}\n\n\t/**\n\t * Emit events passed by a view\n\t * @private\n\t * @param {event} e\n\t */\n\ttriggerViewEvent(e, contents){\n\t\tthis.emit(e.type, e, contents);\n\t}\n\n\t/**\n\t * Emit a selection event's CFI Range passed from a a view\n\t * @private\n\t * @param {string} cfirange\n\t */\n\ttriggerSelectedEvent(cfirange, contents){\n\t\t/**\n\t\t * Emit that a text selection has occurred\n\t\t * @event selected\n\t\t * @param {string} cfirange\n\t\t * @param {Contents} contents\n\t\t * @memberof Rendition\n\t\t */\n\t\tthis.emit(EVENTS.RENDITION.SELECTED, cfirange, contents);\n\t}\n\n\t/**\n\t * Emit a markClicked event with the cfiRange and data from a mark\n\t * @private\n\t * @param {EpubCFI} cfirange\n\t */\n\ttriggerMarkEvent(cfiRange, data, contents){\n\t\t/**\n\t\t * Emit that a mark was clicked\n\t\t * @event markClicked\n\t\t * @param {EpubCFI} cfirange\n\t\t * @param {object} data\n\t\t * @param {Contents} contents\n\t\t * @memberof Rendition\n\t\t */\n\t\tthis.emit(EVENTS.RENDITION.MARK_CLICKED, cfiRange, data, contents);\n\t}\n\n\t/**\n\t * Get a Range from a Visible CFI\n\t * @param {string} cfi EpubCfi String\n\t * @param {string} ignoreClass\n\t * @return {range}\n\t */\n\tgetRange(cfi, ignoreClass){\n\t\tvar _cfi = new EpubCFI(cfi);\n\t\tvar found = this.manager.visible().filter(function (view) {\n\t\t\tif(_cfi.spinePos === view.index) return true;\n\t\t});\n\n\t\t// Should only every return 1 item\n\t\tif (found.length) {\n\t\t\treturn found[0].contents.range(_cfi, ignoreClass);\n\t\t}\n\t}\n\n\t/**\n\t * Hook to adjust images to fit in columns\n\t * @param {Contents} contents\n\t * @private\n\t */\n\tadjustImages(contents) {\n\n\t\tif (this._layout.name === \"pre-paginated\") {\n\t\t\treturn new Promise(function(resolve){\n\t\t\t\tresolve();\n\t\t\t});\n\t\t}\n\n\t\tlet computed = contents.window.getComputedStyle(contents.content, null);\n\t\tlet height = (contents.content.offsetHeight - (parseFloat(computed.paddingTop) + parseFloat(computed.paddingBottom))) * .95;\n\t\tlet horizontalPadding = parseFloat(computed.paddingLeft) + parseFloat(computed.paddingRight);\n\n\t\tcontents.addStylesheetRules({\n\t\t\t\"img\" : {\n\t\t\t\t\"max-width\": (this._layout.columnWidth ? (this._layout.columnWidth - horizontalPadding) + \"px\" : \"100%\") + \"!important\",\n\t\t\t\t\"max-height\": height + \"px\" + \"!important\",\n\t\t\t\t\"object-fit\": \"contain\",\n\t\t\t\t\"page-break-inside\": \"avoid\",\n\t\t\t\t\"break-inside\": \"avoid\",\n\t\t\t\t\"box-sizing\": \"border-box\"\n\t\t\t},\n\t\t\t\"svg\" : {\n\t\t\t\t\"max-width\": (this._layout.columnWidth ? (this._layout.columnWidth - horizontalPadding) + \"px\" : \"100%\") + \"!important\",\n\t\t\t\t\"max-height\": height + \"px\" + \"!important\",\n\t\t\t\t\"page-break-inside\": \"avoid\",\n\t\t\t\t\"break-inside\": \"avoid\"\n\t\t\t}\n\t\t});\n\n\t\treturn new Promise(function(resolve, reject){\n\t\t\t// Wait to apply\n\t\t\tsetTimeout(function() {\n\t\t\t\tresolve();\n\t\t\t}, 1);\n\t\t});\n\t}\n\n\t/**\n\t * Get the Contents object of each rendered view\n\t * @returns {Contents[]}\n\t */\n\tgetContents () {\n\t\treturn this.manager ? this.manager.getContents() : [];\n\t}\n\n\t/**\n\t * Get the views member from the manager\n\t * @returns {Views}\n\t */\n\tviews () {\n\t\tlet views = this.manager ? this.manager.views : undefined;\n\t\treturn views || [];\n\t}\n\n\t/**\n\t * Hook to handle link clicks in rendered content\n\t * @param {Contents} contents\n\t * @private\n\t */\n\thandleLinks(contents) {\n\t\tif (contents) {\n\t\t\tcontents.on(EVENTS.CONTENTS.LINK_CLICKED, (href) => {\n\t\t\t\tlet relative = this.book.path.relative(href);\n\t\t\t\tthis.display(relative);\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Hook to handle injecting stylesheet before\n\t * a Section is serialized\n\t * @param {document} doc\n\t * @param {Section} section\n\t * @private\n\t */\n\tinjectStylesheet(doc, section) {\n\t\tlet style = doc.createElement(\"link\");\n\t\tstyle.setAttribute(\"type\", \"text/css\");\n\t\tstyle.setAttribute(\"rel\", \"stylesheet\");\n\t\tstyle.setAttribute(\"href\", this.settings.stylesheet);\n\t\tdoc.getElementsByTagName(\"head\")[0].appendChild(style);\n\t}\n\n\t/**\n\t * Hook to handle injecting scripts before\n\t * a Section is serialized\n\t * @param {document} doc\n\t * @param {Section} section\n\t * @private\n\t */\n\tinjectScript(doc, section) {\n\t\tlet script = doc.createElement(\"script\");\n\t\tscript.setAttribute(\"type\", \"text/javascript\");\n\t\tscript.setAttribute(\"src\", this.settings.script);\n\t\tscript.textContent = \" \"; // Needed to prevent self closing tag\n\t\tdoc.getElementsByTagName(\"head\")[0].appendChild(script);\n\t}\n\n\t/**\n\t * Hook to handle the document identifier before\n\t * a Section is serialized\n\t * @param {document} doc\n\t * @param {Section} section\n\t * @private\n\t */\n\tinjectIdentifier(doc, section) {\n\t\tlet ident = this.book.packaging.metadata.identifier;\n\t\tlet meta = doc.createElement(\"meta\");\n\t\tmeta.setAttribute(\"name\", \"dc.relation.ispartof\");\n\t\tif (ident) {\n\t\t\tmeta.setAttribute(\"content\", ident);\n\t\t}\n\t\tdoc.getElementsByTagName(\"head\")[0].appendChild(meta);\n\t}\n\n}\n\n//-- Enable binding events to Renderer\nEventEmitter(Rendition.prototype);\n\nexport default Rendition;\n","/*!\n\nJSZip v3.10.1 - A JavaScript class for generating and reading zip files\n\n\n(c) 2009-2016 Stuart Knightley \nDual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.\n\nJSZip uses the library pako released under the MIT license :\nhttps://github.com/nodeca/pako/blob/main/LICENSE\n*/\n\n(function(f){if(typeof exports===\"object\"&&typeof module!==\"undefined\"){module.exports=f()}else if(typeof define===\"function\"&&define.amd){define([],f)}else{var g;if(typeof window!==\"undefined\"){g=window}else if(typeof global!==\"undefined\"){g=global}else if(typeof self!==\"undefined\"){g=self}else{g=this}g.JSZip = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o> 2;\n enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);\n enc3 = remainingBytes > 1 ? (((chr2 & 15) << 2) | (chr3 >> 6)) : 64;\n enc4 = remainingBytes > 2 ? (chr3 & 63) : 64;\n\n output.push(_keyStr.charAt(enc1) + _keyStr.charAt(enc2) + _keyStr.charAt(enc3) + _keyStr.charAt(enc4));\n\n }\n\n return output.join(\"\");\n};\n\n// public method for decoding\nexports.decode = function(input) {\n var chr1, chr2, chr3;\n var enc1, enc2, enc3, enc4;\n var i = 0, resultIndex = 0;\n\n var dataUrlPrefix = \"data:\";\n\n if (input.substr(0, dataUrlPrefix.length) === dataUrlPrefix) {\n // This is a common error: people give a data url\n // (data:image/png;base64,iVBOR...) with a {base64: true} and\n // wonders why things don't work.\n // We can detect that the string input looks like a data url but we\n // *can't* be sure it is one: removing everything up to the comma would\n // be too dangerous.\n throw new Error(\"Invalid base64 input, it looks like a data url.\");\n }\n\n input = input.replace(/[^A-Za-z0-9+/=]/g, \"\");\n\n var totalLength = input.length * 3 / 4;\n if(input.charAt(input.length - 1) === _keyStr.charAt(64)) {\n totalLength--;\n }\n if(input.charAt(input.length - 2) === _keyStr.charAt(64)) {\n totalLength--;\n }\n if (totalLength % 1 !== 0) {\n // totalLength is not an integer, the length does not match a valid\n // base64 content. That can happen if:\n // - the input is not a base64 content\n // - the input is *almost* a base64 content, with a extra chars at the\n // beginning or at the end\n // - the input uses a base64 variant (base64url for example)\n throw new Error(\"Invalid base64 input, bad content length.\");\n }\n var output;\n if (support.uint8array) {\n output = new Uint8Array(totalLength|0);\n } else {\n output = new Array(totalLength|0);\n }\n\n while (i < input.length) {\n\n enc1 = _keyStr.indexOf(input.charAt(i++));\n enc2 = _keyStr.indexOf(input.charAt(i++));\n enc3 = _keyStr.indexOf(input.charAt(i++));\n enc4 = _keyStr.indexOf(input.charAt(i++));\n\n chr1 = (enc1 << 2) | (enc2 >> 4);\n chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);\n chr3 = ((enc3 & 3) << 6) | enc4;\n\n output[resultIndex++] = chr1;\n\n if (enc3 !== 64) {\n output[resultIndex++] = chr2;\n }\n if (enc4 !== 64) {\n output[resultIndex++] = chr3;\n }\n\n }\n\n return output;\n};\n\n},{\"./support\":30,\"./utils\":32}],2:[function(require,module,exports){\n\"use strict\";\n\nvar external = require(\"./external\");\nvar DataWorker = require(\"./stream/DataWorker\");\nvar Crc32Probe = require(\"./stream/Crc32Probe\");\nvar DataLengthProbe = require(\"./stream/DataLengthProbe\");\n\n/**\n * Represent a compressed object, with everything needed to decompress it.\n * @constructor\n * @param {number} compressedSize the size of the data compressed.\n * @param {number} uncompressedSize the size of the data after decompression.\n * @param {number} crc32 the crc32 of the decompressed file.\n * @param {object} compression the type of compression, see lib/compressions.js.\n * @param {String|ArrayBuffer|Uint8Array|Buffer} data the compressed data.\n */\nfunction CompressedObject(compressedSize, uncompressedSize, crc32, compression, data) {\n this.compressedSize = compressedSize;\n this.uncompressedSize = uncompressedSize;\n this.crc32 = crc32;\n this.compression = compression;\n this.compressedContent = data;\n}\n\nCompressedObject.prototype = {\n /**\n * Create a worker to get the uncompressed content.\n * @return {GenericWorker} the worker.\n */\n getContentWorker: function () {\n var worker = new DataWorker(external.Promise.resolve(this.compressedContent))\n .pipe(this.compression.uncompressWorker())\n .pipe(new DataLengthProbe(\"data_length\"));\n\n var that = this;\n worker.on(\"end\", function () {\n if (this.streamInfo[\"data_length\"] !== that.uncompressedSize) {\n throw new Error(\"Bug : uncompressed data size mismatch\");\n }\n });\n return worker;\n },\n /**\n * Create a worker to get the compressed content.\n * @return {GenericWorker} the worker.\n */\n getCompressedWorker: function () {\n return new DataWorker(external.Promise.resolve(this.compressedContent))\n .withStreamInfo(\"compressedSize\", this.compressedSize)\n .withStreamInfo(\"uncompressedSize\", this.uncompressedSize)\n .withStreamInfo(\"crc32\", this.crc32)\n .withStreamInfo(\"compression\", this.compression)\n ;\n }\n};\n\n/**\n * Chain the given worker with other workers to compress the content with the\n * given compression.\n * @param {GenericWorker} uncompressedWorker the worker to pipe.\n * @param {Object} compression the compression object.\n * @param {Object} compressionOptions the options to use when compressing.\n * @return {GenericWorker} the new worker compressing the content.\n */\nCompressedObject.createWorkerFrom = function (uncompressedWorker, compression, compressionOptions) {\n return uncompressedWorker\n .pipe(new Crc32Probe())\n .pipe(new DataLengthProbe(\"uncompressedSize\"))\n .pipe(compression.compressWorker(compressionOptions))\n .pipe(new DataLengthProbe(\"compressedSize\"))\n .withStreamInfo(\"compression\", compression);\n};\n\nmodule.exports = CompressedObject;\n\n},{\"./external\":6,\"./stream/Crc32Probe\":25,\"./stream/DataLengthProbe\":26,\"./stream/DataWorker\":27}],3:[function(require,module,exports){\n\"use strict\";\n\nvar GenericWorker = require(\"./stream/GenericWorker\");\n\nexports.STORE = {\n magic: \"\\x00\\x00\",\n compressWorker : function () {\n return new GenericWorker(\"STORE compression\");\n },\n uncompressWorker : function () {\n return new GenericWorker(\"STORE decompression\");\n }\n};\nexports.DEFLATE = require(\"./flate\");\n\n},{\"./flate\":7,\"./stream/GenericWorker\":28}],4:[function(require,module,exports){\n\"use strict\";\n\nvar utils = require(\"./utils\");\n\n/**\n * The following functions come from pako, from pako/lib/zlib/crc32.js\n * released under the MIT license, see pako https://github.com/nodeca/pako/\n */\n\n// Use ordinary array, since untyped makes no boost here\nfunction makeTable() {\n var c, table = [];\n\n for(var n =0; n < 256; n++){\n c = n;\n for(var k =0; k < 8; k++){\n c = ((c&1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n }\n table[n] = c;\n }\n\n return table;\n}\n\n// Create table on load. Just 255 signed longs. Not a problem.\nvar crcTable = makeTable();\n\n\nfunction crc32(crc, buf, len, pos) {\n var t = crcTable, end = pos + len;\n\n crc = crc ^ (-1);\n\n for (var i = pos; i < end; i++ ) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n}\n\n// That's all for the pako functions.\n\n/**\n * Compute the crc32 of a string.\n * This is almost the same as the function crc32, but for strings. Using the\n * same function for the two use cases leads to horrible performances.\n * @param {Number} crc the starting value of the crc.\n * @param {String} str the string to use.\n * @param {Number} len the length of the string.\n * @param {Number} pos the starting position for the crc32 computation.\n * @return {Number} the computed crc32.\n */\nfunction crc32str(crc, str, len, pos) {\n var t = crcTable, end = pos + len;\n\n crc = crc ^ (-1);\n\n for (var i = pos; i < end; i++ ) {\n crc = (crc >>> 8) ^ t[(crc ^ str.charCodeAt(i)) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n}\n\nmodule.exports = function crc32wrapper(input, crc) {\n if (typeof input === \"undefined\" || !input.length) {\n return 0;\n }\n\n var isArray = utils.getTypeOf(input) !== \"string\";\n\n if(isArray) {\n return crc32(crc|0, input, input.length, 0);\n } else {\n return crc32str(crc|0, input, input.length, 0);\n }\n};\n\n},{\"./utils\":32}],5:[function(require,module,exports){\n\"use strict\";\nexports.base64 = false;\nexports.binary = false;\nexports.dir = false;\nexports.createFolders = true;\nexports.date = null;\nexports.compression = null;\nexports.compressionOptions = null;\nexports.comment = null;\nexports.unixPermissions = null;\nexports.dosPermissions = null;\n\n},{}],6:[function(require,module,exports){\n\"use strict\";\n\n// load the global object first:\n// - it should be better integrated in the system (unhandledRejection in node)\n// - the environment may have a custom Promise implementation (see zone.js)\nvar ES6Promise = null;\nif (typeof Promise !== \"undefined\") {\n ES6Promise = Promise;\n} else {\n ES6Promise = require(\"lie\");\n}\n\n/**\n * Let the user use/change some implementations.\n */\nmodule.exports = {\n Promise: ES6Promise\n};\n\n},{\"lie\":37}],7:[function(require,module,exports){\n\"use strict\";\nvar USE_TYPEDARRAY = (typeof Uint8Array !== \"undefined\") && (typeof Uint16Array !== \"undefined\") && (typeof Uint32Array !== \"undefined\");\n\nvar pako = require(\"pako\");\nvar utils = require(\"./utils\");\nvar GenericWorker = require(\"./stream/GenericWorker\");\n\nvar ARRAY_TYPE = USE_TYPEDARRAY ? \"uint8array\" : \"array\";\n\nexports.magic = \"\\x08\\x00\";\n\n/**\n * Create a worker that uses pako to inflate/deflate.\n * @constructor\n * @param {String} action the name of the pako function to call : either \"Deflate\" or \"Inflate\".\n * @param {Object} options the options to use when (de)compressing.\n */\nfunction FlateWorker(action, options) {\n GenericWorker.call(this, \"FlateWorker/\" + action);\n\n this._pako = null;\n this._pakoAction = action;\n this._pakoOptions = options;\n // the `meta` object from the last chunk received\n // this allow this worker to pass around metadata\n this.meta = {};\n}\n\nutils.inherits(FlateWorker, GenericWorker);\n\n/**\n * @see GenericWorker.processChunk\n */\nFlateWorker.prototype.processChunk = function (chunk) {\n this.meta = chunk.meta;\n if (this._pako === null) {\n this._createPako();\n }\n this._pako.push(utils.transformTo(ARRAY_TYPE, chunk.data), false);\n};\n\n/**\n * @see GenericWorker.flush\n */\nFlateWorker.prototype.flush = function () {\n GenericWorker.prototype.flush.call(this);\n if (this._pako === null) {\n this._createPako();\n }\n this._pako.push([], true);\n};\n/**\n * @see GenericWorker.cleanUp\n */\nFlateWorker.prototype.cleanUp = function () {\n GenericWorker.prototype.cleanUp.call(this);\n this._pako = null;\n};\n\n/**\n * Create the _pako object.\n * TODO: lazy-loading this object isn't the best solution but it's the\n * quickest. The best solution is to lazy-load the worker list. See also the\n * issue #446.\n */\nFlateWorker.prototype._createPako = function () {\n this._pako = new pako[this._pakoAction]({\n raw: true,\n level: this._pakoOptions.level || -1 // default compression\n });\n var self = this;\n this._pako.onData = function(data) {\n self.push({\n data : data,\n meta : self.meta\n });\n };\n};\n\nexports.compressWorker = function (compressionOptions) {\n return new FlateWorker(\"Deflate\", compressionOptions);\n};\nexports.uncompressWorker = function () {\n return new FlateWorker(\"Inflate\", {});\n};\n\n},{\"./stream/GenericWorker\":28,\"./utils\":32,\"pako\":38}],8:[function(require,module,exports){\n\"use strict\";\n\nvar utils = require(\"../utils\");\nvar GenericWorker = require(\"../stream/GenericWorker\");\nvar utf8 = require(\"../utf8\");\nvar crc32 = require(\"../crc32\");\nvar signature = require(\"../signature\");\n\n/**\n * Transform an integer into a string in hexadecimal.\n * @private\n * @param {number} dec the number to convert.\n * @param {number} bytes the number of bytes to generate.\n * @returns {string} the result.\n */\nvar decToHex = function(dec, bytes) {\n var hex = \"\", i;\n for (i = 0; i < bytes; i++) {\n hex += String.fromCharCode(dec & 0xff);\n dec = dec >>> 8;\n }\n return hex;\n};\n\n/**\n * Generate the UNIX part of the external file attributes.\n * @param {Object} unixPermissions the unix permissions or null.\n * @param {Boolean} isDir true if the entry is a directory, false otherwise.\n * @return {Number} a 32 bit integer.\n *\n * adapted from http://unix.stackexchange.com/questions/14705/the-zip-formats-external-file-attribute :\n *\n * TTTTsstrwxrwxrwx0000000000ADVSHR\n * ^^^^____________________________ file type, see zipinfo.c (UNX_*)\n * ^^^_________________________ setuid, setgid, sticky\n * ^^^^^^^^^________________ permissions\n * ^^^^^^^^^^______ not used ?\n * ^^^^^^ DOS attribute bits : Archive, Directory, Volume label, System file, Hidden, Read only\n */\nvar generateUnixExternalFileAttr = function (unixPermissions, isDir) {\n\n var result = unixPermissions;\n if (!unixPermissions) {\n // I can't use octal values in strict mode, hence the hexa.\n // 040775 => 0x41fd\n // 0100664 => 0x81b4\n result = isDir ? 0x41fd : 0x81b4;\n }\n return (result & 0xFFFF) << 16;\n};\n\n/**\n * Generate the DOS part of the external file attributes.\n * @param {Object} dosPermissions the dos permissions or null.\n * @param {Boolean} isDir true if the entry is a directory, false otherwise.\n * @return {Number} a 32 bit integer.\n *\n * Bit 0 Read-Only\n * Bit 1 Hidden\n * Bit 2 System\n * Bit 3 Volume Label\n * Bit 4 Directory\n * Bit 5 Archive\n */\nvar generateDosExternalFileAttr = function (dosPermissions) {\n // the dir flag is already set for compatibility\n return (dosPermissions || 0) & 0x3F;\n};\n\n/**\n * Generate the various parts used in the construction of the final zip file.\n * @param {Object} streamInfo the hash with information about the compressed file.\n * @param {Boolean} streamedContent is the content streamed ?\n * @param {Boolean} streamingEnded is the stream finished ?\n * @param {number} offset the current offset from the start of the zip file.\n * @param {String} platform let's pretend we are this platform (change platform dependents fields)\n * @param {Function} encodeFileName the function to encode the file name / comment.\n * @return {Object} the zip parts.\n */\nvar generateZipParts = function(streamInfo, streamedContent, streamingEnded, offset, platform, encodeFileName) {\n var file = streamInfo[\"file\"],\n compression = streamInfo[\"compression\"],\n useCustomEncoding = encodeFileName !== utf8.utf8encode,\n encodedFileName = utils.transformTo(\"string\", encodeFileName(file.name)),\n utfEncodedFileName = utils.transformTo(\"string\", utf8.utf8encode(file.name)),\n comment = file.comment,\n encodedComment = utils.transformTo(\"string\", encodeFileName(comment)),\n utfEncodedComment = utils.transformTo(\"string\", utf8.utf8encode(comment)),\n useUTF8ForFileName = utfEncodedFileName.length !== file.name.length,\n useUTF8ForComment = utfEncodedComment.length !== comment.length,\n dosTime,\n dosDate,\n extraFields = \"\",\n unicodePathExtraField = \"\",\n unicodeCommentExtraField = \"\",\n dir = file.dir,\n date = file.date;\n\n\n var dataInfo = {\n crc32 : 0,\n compressedSize : 0,\n uncompressedSize : 0\n };\n\n // if the content is streamed, the sizes/crc32 are only available AFTER\n // the end of the stream.\n if (!streamedContent || streamingEnded) {\n dataInfo.crc32 = streamInfo[\"crc32\"];\n dataInfo.compressedSize = streamInfo[\"compressedSize\"];\n dataInfo.uncompressedSize = streamInfo[\"uncompressedSize\"];\n }\n\n var bitflag = 0;\n if (streamedContent) {\n // Bit 3: the sizes/crc32 are set to zero in the local header.\n // The correct values are put in the data descriptor immediately\n // following the compressed data.\n bitflag |= 0x0008;\n }\n if (!useCustomEncoding && (useUTF8ForFileName || useUTF8ForComment)) {\n // Bit 11: Language encoding flag (EFS).\n bitflag |= 0x0800;\n }\n\n\n var extFileAttr = 0;\n var versionMadeBy = 0;\n if (dir) {\n // dos or unix, we set the dos dir flag\n extFileAttr |= 0x00010;\n }\n if(platform === \"UNIX\") {\n versionMadeBy = 0x031E; // UNIX, version 3.0\n extFileAttr |= generateUnixExternalFileAttr(file.unixPermissions, dir);\n } else { // DOS or other, fallback to DOS\n versionMadeBy = 0x0014; // DOS, version 2.0\n extFileAttr |= generateDosExternalFileAttr(file.dosPermissions, dir);\n }\n\n // date\n // @see http://www.delorie.com/djgpp/doc/rbinter/it/52/13.html\n // @see http://www.delorie.com/djgpp/doc/rbinter/it/65/16.html\n // @see http://www.delorie.com/djgpp/doc/rbinter/it/66/16.html\n\n dosTime = date.getUTCHours();\n dosTime = dosTime << 6;\n dosTime = dosTime | date.getUTCMinutes();\n dosTime = dosTime << 5;\n dosTime = dosTime | date.getUTCSeconds() / 2;\n\n dosDate = date.getUTCFullYear() - 1980;\n dosDate = dosDate << 4;\n dosDate = dosDate | (date.getUTCMonth() + 1);\n dosDate = dosDate << 5;\n dosDate = dosDate | date.getUTCDate();\n\n if (useUTF8ForFileName) {\n // set the unicode path extra field. unzip needs at least one extra\n // field to correctly handle unicode path, so using the path is as good\n // as any other information. This could improve the situation with\n // other archive managers too.\n // This field is usually used without the utf8 flag, with a non\n // unicode path in the header (winrar, winzip). This helps (a bit)\n // with the messy Windows' default compressed folders feature but\n // breaks on p7zip which doesn't seek the unicode path extra field.\n // So for now, UTF-8 everywhere !\n unicodePathExtraField =\n // Version\n decToHex(1, 1) +\n // NameCRC32\n decToHex(crc32(encodedFileName), 4) +\n // UnicodeName\n utfEncodedFileName;\n\n extraFields +=\n // Info-ZIP Unicode Path Extra Field\n \"\\x75\\x70\" +\n // size\n decToHex(unicodePathExtraField.length, 2) +\n // content\n unicodePathExtraField;\n }\n\n if(useUTF8ForComment) {\n\n unicodeCommentExtraField =\n // Version\n decToHex(1, 1) +\n // CommentCRC32\n decToHex(crc32(encodedComment), 4) +\n // UnicodeName\n utfEncodedComment;\n\n extraFields +=\n // Info-ZIP Unicode Path Extra Field\n \"\\x75\\x63\" +\n // size\n decToHex(unicodeCommentExtraField.length, 2) +\n // content\n unicodeCommentExtraField;\n }\n\n var header = \"\";\n\n // version needed to extract\n header += \"\\x0A\\x00\";\n // general purpose bit flag\n header += decToHex(bitflag, 2);\n // compression method\n header += compression.magic;\n // last mod file time\n header += decToHex(dosTime, 2);\n // last mod file date\n header += decToHex(dosDate, 2);\n // crc-32\n header += decToHex(dataInfo.crc32, 4);\n // compressed size\n header += decToHex(dataInfo.compressedSize, 4);\n // uncompressed size\n header += decToHex(dataInfo.uncompressedSize, 4);\n // file name length\n header += decToHex(encodedFileName.length, 2);\n // extra field length\n header += decToHex(extraFields.length, 2);\n\n\n var fileRecord = signature.LOCAL_FILE_HEADER + header + encodedFileName + extraFields;\n\n var dirRecord = signature.CENTRAL_FILE_HEADER +\n // version made by (00: DOS)\n decToHex(versionMadeBy, 2) +\n // file header (common to file and central directory)\n header +\n // file comment length\n decToHex(encodedComment.length, 2) +\n // disk number start\n \"\\x00\\x00\" +\n // internal file attributes TODO\n \"\\x00\\x00\" +\n // external file attributes\n decToHex(extFileAttr, 4) +\n // relative offset of local header\n decToHex(offset, 4) +\n // file name\n encodedFileName +\n // extra field\n extraFields +\n // file comment\n encodedComment;\n\n return {\n fileRecord: fileRecord,\n dirRecord: dirRecord\n };\n};\n\n/**\n * Generate the EOCD record.\n * @param {Number} entriesCount the number of entries in the zip file.\n * @param {Number} centralDirLength the length (in bytes) of the central dir.\n * @param {Number} localDirLength the length (in bytes) of the local dir.\n * @param {String} comment the zip file comment as a binary string.\n * @param {Function} encodeFileName the function to encode the comment.\n * @return {String} the EOCD record.\n */\nvar generateCentralDirectoryEnd = function (entriesCount, centralDirLength, localDirLength, comment, encodeFileName) {\n var dirEnd = \"\";\n var encodedComment = utils.transformTo(\"string\", encodeFileName(comment));\n\n // end of central dir signature\n dirEnd = signature.CENTRAL_DIRECTORY_END +\n // number of this disk\n \"\\x00\\x00\" +\n // number of the disk with the start of the central directory\n \"\\x00\\x00\" +\n // total number of entries in the central directory on this disk\n decToHex(entriesCount, 2) +\n // total number of entries in the central directory\n decToHex(entriesCount, 2) +\n // size of the central directory 4 bytes\n decToHex(centralDirLength, 4) +\n // offset of start of central directory with respect to the starting disk number\n decToHex(localDirLength, 4) +\n // .ZIP file comment length\n decToHex(encodedComment.length, 2) +\n // .ZIP file comment\n encodedComment;\n\n return dirEnd;\n};\n\n/**\n * Generate data descriptors for a file entry.\n * @param {Object} streamInfo the hash generated by a worker, containing information\n * on the file entry.\n * @return {String} the data descriptors.\n */\nvar generateDataDescriptors = function (streamInfo) {\n var descriptor = \"\";\n descriptor = signature.DATA_DESCRIPTOR +\n // crc-32 4 bytes\n decToHex(streamInfo[\"crc32\"], 4) +\n // compressed size 4 bytes\n decToHex(streamInfo[\"compressedSize\"], 4) +\n // uncompressed size 4 bytes\n decToHex(streamInfo[\"uncompressedSize\"], 4);\n\n return descriptor;\n};\n\n\n/**\n * A worker to concatenate other workers to create a zip file.\n * @param {Boolean} streamFiles `true` to stream the content of the files,\n * `false` to accumulate it.\n * @param {String} comment the comment to use.\n * @param {String} platform the platform to use, \"UNIX\" or \"DOS\".\n * @param {Function} encodeFileName the function to encode file names and comments.\n */\nfunction ZipFileWorker(streamFiles, comment, platform, encodeFileName) {\n GenericWorker.call(this, \"ZipFileWorker\");\n // The number of bytes written so far. This doesn't count accumulated chunks.\n this.bytesWritten = 0;\n // The comment of the zip file\n this.zipComment = comment;\n // The platform \"generating\" the zip file.\n this.zipPlatform = platform;\n // the function to encode file names and comments.\n this.encodeFileName = encodeFileName;\n // Should we stream the content of the files ?\n this.streamFiles = streamFiles;\n // If `streamFiles` is false, we will need to accumulate the content of the\n // files to calculate sizes / crc32 (and write them *before* the content).\n // This boolean indicates if we are accumulating chunks (it will change a lot\n // during the lifetime of this worker).\n this.accumulate = false;\n // The buffer receiving chunks when accumulating content.\n this.contentBuffer = [];\n // The list of generated directory records.\n this.dirRecords = [];\n // The offset (in bytes) from the beginning of the zip file for the current source.\n this.currentSourceOffset = 0;\n // The total number of entries in this zip file.\n this.entriesCount = 0;\n // the name of the file currently being added, null when handling the end of the zip file.\n // Used for the emitted metadata.\n this.currentFile = null;\n\n\n\n this._sources = [];\n}\nutils.inherits(ZipFileWorker, GenericWorker);\n\n/**\n * @see GenericWorker.push\n */\nZipFileWorker.prototype.push = function (chunk) {\n\n var currentFilePercent = chunk.meta.percent || 0;\n var entriesCount = this.entriesCount;\n var remainingFiles = this._sources.length;\n\n if(this.accumulate) {\n this.contentBuffer.push(chunk);\n } else {\n this.bytesWritten += chunk.data.length;\n\n GenericWorker.prototype.push.call(this, {\n data : chunk.data,\n meta : {\n currentFile : this.currentFile,\n percent : entriesCount ? (currentFilePercent + 100 * (entriesCount - remainingFiles - 1)) / entriesCount : 100\n }\n });\n }\n};\n\n/**\n * The worker started a new source (an other worker).\n * @param {Object} streamInfo the streamInfo object from the new source.\n */\nZipFileWorker.prototype.openedSource = function (streamInfo) {\n this.currentSourceOffset = this.bytesWritten;\n this.currentFile = streamInfo[\"file\"].name;\n\n var streamedContent = this.streamFiles && !streamInfo[\"file\"].dir;\n\n // don't stream folders (because they don't have any content)\n if(streamedContent) {\n var record = generateZipParts(streamInfo, streamedContent, false, this.currentSourceOffset, this.zipPlatform, this.encodeFileName);\n this.push({\n data : record.fileRecord,\n meta : {percent:0}\n });\n } else {\n // we need to wait for the whole file before pushing anything\n this.accumulate = true;\n }\n};\n\n/**\n * The worker finished a source (an other worker).\n * @param {Object} streamInfo the streamInfo object from the finished source.\n */\nZipFileWorker.prototype.closedSource = function (streamInfo) {\n this.accumulate = false;\n var streamedContent = this.streamFiles && !streamInfo[\"file\"].dir;\n var record = generateZipParts(streamInfo, streamedContent, true, this.currentSourceOffset, this.zipPlatform, this.encodeFileName);\n\n this.dirRecords.push(record.dirRecord);\n if(streamedContent) {\n // after the streamed file, we put data descriptors\n this.push({\n data : generateDataDescriptors(streamInfo),\n meta : {percent:100}\n });\n } else {\n // the content wasn't streamed, we need to push everything now\n // first the file record, then the content\n this.push({\n data : record.fileRecord,\n meta : {percent:0}\n });\n while(this.contentBuffer.length) {\n this.push(this.contentBuffer.shift());\n }\n }\n this.currentFile = null;\n};\n\n/**\n * @see GenericWorker.flush\n */\nZipFileWorker.prototype.flush = function () {\n\n var localDirLength = this.bytesWritten;\n for(var i = 0; i < this.dirRecords.length; i++) {\n this.push({\n data : this.dirRecords[i],\n meta : {percent:100}\n });\n }\n var centralDirLength = this.bytesWritten - localDirLength;\n\n var dirEnd = generateCentralDirectoryEnd(this.dirRecords.length, centralDirLength, localDirLength, this.zipComment, this.encodeFileName);\n\n this.push({\n data : dirEnd,\n meta : {percent:100}\n });\n};\n\n/**\n * Prepare the next source to be read.\n */\nZipFileWorker.prototype.prepareNextSource = function () {\n this.previous = this._sources.shift();\n this.openedSource(this.previous.streamInfo);\n if (this.isPaused) {\n this.previous.pause();\n } else {\n this.previous.resume();\n }\n};\n\n/**\n * @see GenericWorker.registerPrevious\n */\nZipFileWorker.prototype.registerPrevious = function (previous) {\n this._sources.push(previous);\n var self = this;\n\n previous.on(\"data\", function (chunk) {\n self.processChunk(chunk);\n });\n previous.on(\"end\", function () {\n self.closedSource(self.previous.streamInfo);\n if(self._sources.length) {\n self.prepareNextSource();\n } else {\n self.end();\n }\n });\n previous.on(\"error\", function (e) {\n self.error(e);\n });\n return this;\n};\n\n/**\n * @see GenericWorker.resume\n */\nZipFileWorker.prototype.resume = function () {\n if(!GenericWorker.prototype.resume.call(this)) {\n return false;\n }\n\n if (!this.previous && this._sources.length) {\n this.prepareNextSource();\n return true;\n }\n if (!this.previous && !this._sources.length && !this.generatedError) {\n this.end();\n return true;\n }\n};\n\n/**\n * @see GenericWorker.error\n */\nZipFileWorker.prototype.error = function (e) {\n var sources = this._sources;\n if(!GenericWorker.prototype.error.call(this, e)) {\n return false;\n }\n for(var i = 0; i < sources.length; i++) {\n try {\n sources[i].error(e);\n } catch(e) {\n // the `error` exploded, nothing to do\n }\n }\n return true;\n};\n\n/**\n * @see GenericWorker.lock\n */\nZipFileWorker.prototype.lock = function () {\n GenericWorker.prototype.lock.call(this);\n var sources = this._sources;\n for(var i = 0; i < sources.length; i++) {\n sources[i].lock();\n }\n};\n\nmodule.exports = ZipFileWorker;\n\n},{\"../crc32\":4,\"../signature\":23,\"../stream/GenericWorker\":28,\"../utf8\":31,\"../utils\":32}],9:[function(require,module,exports){\n\"use strict\";\n\nvar compressions = require(\"../compressions\");\nvar ZipFileWorker = require(\"./ZipFileWorker\");\n\n/**\n * Find the compression to use.\n * @param {String} fileCompression the compression defined at the file level, if any.\n * @param {String} zipCompression the compression defined at the load() level.\n * @return {Object} the compression object to use.\n */\nvar getCompression = function (fileCompression, zipCompression) {\n\n var compressionName = fileCompression || zipCompression;\n var compression = compressions[compressionName];\n if (!compression) {\n throw new Error(compressionName + \" is not a valid compression method !\");\n }\n return compression;\n};\n\n/**\n * Create a worker to generate a zip file.\n * @param {JSZip} zip the JSZip instance at the right root level.\n * @param {Object} options to generate the zip file.\n * @param {String} comment the comment to use.\n */\nexports.generateWorker = function (zip, options, comment) {\n\n var zipFileWorker = new ZipFileWorker(options.streamFiles, comment, options.platform, options.encodeFileName);\n var entriesCount = 0;\n try {\n\n zip.forEach(function (relativePath, file) {\n entriesCount++;\n var compression = getCompression(file.options.compression, options.compression);\n var compressionOptions = file.options.compressionOptions || options.compressionOptions || {};\n var dir = file.dir, date = file.date;\n\n file._compressWorker(compression, compressionOptions)\n .withStreamInfo(\"file\", {\n name : relativePath,\n dir : dir,\n date : date,\n comment : file.comment || \"\",\n unixPermissions : file.unixPermissions,\n dosPermissions : file.dosPermissions\n })\n .pipe(zipFileWorker);\n });\n zipFileWorker.entriesCount = entriesCount;\n } catch (e) {\n zipFileWorker.error(e);\n }\n\n return zipFileWorker;\n};\n\n},{\"../compressions\":3,\"./ZipFileWorker\":8}],10:[function(require,module,exports){\n\"use strict\";\n\n/**\n * Representation a of zip file in js\n * @constructor\n */\nfunction JSZip() {\n // if this constructor is used without `new`, it adds `new` before itself:\n if(!(this instanceof JSZip)) {\n return new JSZip();\n }\n\n if(arguments.length) {\n throw new Error(\"The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.\");\n }\n\n // object containing the files :\n // {\n // \"folder/\" : {...},\n // \"folder/data.txt\" : {...}\n // }\n // NOTE: we use a null prototype because we do not\n // want filenames like \"toString\" coming from a zip file\n // to overwrite methods and attributes in a normal Object.\n this.files = Object.create(null);\n\n this.comment = null;\n\n // Where we are in the hierarchy\n this.root = \"\";\n this.clone = function() {\n var newObj = new JSZip();\n for (var i in this) {\n if (typeof this[i] !== \"function\") {\n newObj[i] = this[i];\n }\n }\n return newObj;\n };\n}\nJSZip.prototype = require(\"./object\");\nJSZip.prototype.loadAsync = require(\"./load\");\nJSZip.support = require(\"./support\");\nJSZip.defaults = require(\"./defaults\");\n\n// TODO find a better way to handle this version,\n// a require('package.json').version doesn't work with webpack, see #327\nJSZip.version = \"3.10.1\";\n\nJSZip.loadAsync = function (content, options) {\n return new JSZip().loadAsync(content, options);\n};\n\nJSZip.external = require(\"./external\");\nmodule.exports = JSZip;\n\n},{\"./defaults\":5,\"./external\":6,\"./load\":11,\"./object\":15,\"./support\":30}],11:[function(require,module,exports){\n\"use strict\";\nvar utils = require(\"./utils\");\nvar external = require(\"./external\");\nvar utf8 = require(\"./utf8\");\nvar ZipEntries = require(\"./zipEntries\");\nvar Crc32Probe = require(\"./stream/Crc32Probe\");\nvar nodejsUtils = require(\"./nodejsUtils\");\n\n/**\n * Check the CRC32 of an entry.\n * @param {ZipEntry} zipEntry the zip entry to check.\n * @return {Promise} the result.\n */\nfunction checkEntryCRC32(zipEntry) {\n return new external.Promise(function (resolve, reject) {\n var worker = zipEntry.decompressed.getContentWorker().pipe(new Crc32Probe());\n worker.on(\"error\", function (e) {\n reject(e);\n })\n .on(\"end\", function () {\n if (worker.streamInfo.crc32 !== zipEntry.decompressed.crc32) {\n reject(new Error(\"Corrupted zip : CRC32 mismatch\"));\n } else {\n resolve();\n }\n })\n .resume();\n });\n}\n\nmodule.exports = function (data, options) {\n var zip = this;\n options = utils.extend(options || {}, {\n base64: false,\n checkCRC32: false,\n optimizedBinaryString: false,\n createFolders: false,\n decodeFileName: utf8.utf8decode\n });\n\n if (nodejsUtils.isNode && nodejsUtils.isStream(data)) {\n return external.Promise.reject(new Error(\"JSZip can't accept a stream when loading a zip file.\"));\n }\n\n return utils.prepareContent(\"the loaded zip file\", data, true, options.optimizedBinaryString, options.base64)\n .then(function (data) {\n var zipEntries = new ZipEntries(options);\n zipEntries.load(data);\n return zipEntries;\n }).then(function checkCRC32(zipEntries) {\n var promises = [external.Promise.resolve(zipEntries)];\n var files = zipEntries.files;\n if (options.checkCRC32) {\n for (var i = 0; i < files.length; i++) {\n promises.push(checkEntryCRC32(files[i]));\n }\n }\n return external.Promise.all(promises);\n }).then(function addFiles(results) {\n var zipEntries = results.shift();\n var files = zipEntries.files;\n for (var i = 0; i < files.length; i++) {\n var input = files[i];\n\n var unsafeName = input.fileNameStr;\n var safeName = utils.resolve(input.fileNameStr);\n\n zip.file(safeName, input.decompressed, {\n binary: true,\n optimizedBinaryString: true,\n date: input.date,\n dir: input.dir,\n comment: input.fileCommentStr.length ? input.fileCommentStr : null,\n unixPermissions: input.unixPermissions,\n dosPermissions: input.dosPermissions,\n createFolders: options.createFolders\n });\n if (!input.dir) {\n zip.file(safeName).unsafeOriginalName = unsafeName;\n }\n }\n if (zipEntries.zipComment.length) {\n zip.comment = zipEntries.zipComment;\n }\n\n return zip;\n });\n};\n\n},{\"./external\":6,\"./nodejsUtils\":14,\"./stream/Crc32Probe\":25,\"./utf8\":31,\"./utils\":32,\"./zipEntries\":33}],12:[function(require,module,exports){\n\"use strict\";\n\nvar utils = require(\"../utils\");\nvar GenericWorker = require(\"../stream/GenericWorker\");\n\n/**\n * A worker that use a nodejs stream as source.\n * @constructor\n * @param {String} filename the name of the file entry for this stream.\n * @param {Readable} stream the nodejs stream.\n */\nfunction NodejsStreamInputAdapter(filename, stream) {\n GenericWorker.call(this, \"Nodejs stream input adapter for \" + filename);\n this._upstreamEnded = false;\n this._bindStream(stream);\n}\n\nutils.inherits(NodejsStreamInputAdapter, GenericWorker);\n\n/**\n * Prepare the stream and bind the callbacks on it.\n * Do this ASAP on node 0.10 ! A lazy binding doesn't always work.\n * @param {Stream} stream the nodejs stream to use.\n */\nNodejsStreamInputAdapter.prototype._bindStream = function (stream) {\n var self = this;\n this._stream = stream;\n stream.pause();\n stream\n .on(\"data\", function (chunk) {\n self.push({\n data: chunk,\n meta : {\n percent : 0\n }\n });\n })\n .on(\"error\", function (e) {\n if(self.isPaused) {\n this.generatedError = e;\n } else {\n self.error(e);\n }\n })\n .on(\"end\", function () {\n if(self.isPaused) {\n self._upstreamEnded = true;\n } else {\n self.end();\n }\n });\n};\nNodejsStreamInputAdapter.prototype.pause = function () {\n if(!GenericWorker.prototype.pause.call(this)) {\n return false;\n }\n this._stream.pause();\n return true;\n};\nNodejsStreamInputAdapter.prototype.resume = function () {\n if(!GenericWorker.prototype.resume.call(this)) {\n return false;\n }\n\n if(this._upstreamEnded) {\n this.end();\n } else {\n this._stream.resume();\n }\n\n return true;\n};\n\nmodule.exports = NodejsStreamInputAdapter;\n\n},{\"../stream/GenericWorker\":28,\"../utils\":32}],13:[function(require,module,exports){\n\"use strict\";\n\nvar Readable = require(\"readable-stream\").Readable;\n\nvar utils = require(\"../utils\");\nutils.inherits(NodejsStreamOutputAdapter, Readable);\n\n/**\n* A nodejs stream using a worker as source.\n* @see the SourceWrapper in http://nodejs.org/api/stream.html\n* @constructor\n* @param {StreamHelper} helper the helper wrapping the worker\n* @param {Object} options the nodejs stream options\n* @param {Function} updateCb the update callback.\n*/\nfunction NodejsStreamOutputAdapter(helper, options, updateCb) {\n Readable.call(this, options);\n this._helper = helper;\n\n var self = this;\n helper.on(\"data\", function (data, meta) {\n if (!self.push(data)) {\n self._helper.pause();\n }\n if(updateCb) {\n updateCb(meta);\n }\n })\n .on(\"error\", function(e) {\n self.emit(\"error\", e);\n })\n .on(\"end\", function () {\n self.push(null);\n });\n}\n\n\nNodejsStreamOutputAdapter.prototype._read = function() {\n this._helper.resume();\n};\n\nmodule.exports = NodejsStreamOutputAdapter;\n\n},{\"../utils\":32,\"readable-stream\":16}],14:[function(require,module,exports){\n\"use strict\";\n\nmodule.exports = {\n /**\n * True if this is running in Nodejs, will be undefined in a browser.\n * In a browser, browserify won't include this file and the whole module\n * will be resolved an empty object.\n */\n isNode : typeof Buffer !== \"undefined\",\n /**\n * Create a new nodejs Buffer from an existing content.\n * @param {Object} data the data to pass to the constructor.\n * @param {String} encoding the encoding to use.\n * @return {Buffer} a new Buffer.\n */\n newBufferFrom: function(data, encoding) {\n if (Buffer.from && Buffer.from !== Uint8Array.from) {\n return Buffer.from(data, encoding);\n } else {\n if (typeof data === \"number\") {\n // Safeguard for old Node.js versions. On newer versions,\n // Buffer.from(number) / Buffer(number, encoding) already throw.\n throw new Error(\"The \\\"data\\\" argument must not be a number\");\n }\n return new Buffer(data, encoding);\n }\n },\n /**\n * Create a new nodejs Buffer with the specified size.\n * @param {Integer} size the size of the buffer.\n * @return {Buffer} a new Buffer.\n */\n allocBuffer: function (size) {\n if (Buffer.alloc) {\n return Buffer.alloc(size);\n } else {\n var buf = new Buffer(size);\n buf.fill(0);\n return buf;\n }\n },\n /**\n * Find out if an object is a Buffer.\n * @param {Object} b the object to test.\n * @return {Boolean} true if the object is a Buffer, false otherwise.\n */\n isBuffer : function(b){\n return Buffer.isBuffer(b);\n },\n\n isStream : function (obj) {\n return obj &&\n typeof obj.on === \"function\" &&\n typeof obj.pause === \"function\" &&\n typeof obj.resume === \"function\";\n }\n};\n\n},{}],15:[function(require,module,exports){\n\"use strict\";\nvar utf8 = require(\"./utf8\");\nvar utils = require(\"./utils\");\nvar GenericWorker = require(\"./stream/GenericWorker\");\nvar StreamHelper = require(\"./stream/StreamHelper\");\nvar defaults = require(\"./defaults\");\nvar CompressedObject = require(\"./compressedObject\");\nvar ZipObject = require(\"./zipObject\");\nvar generate = require(\"./generate\");\nvar nodejsUtils = require(\"./nodejsUtils\");\nvar NodejsStreamInputAdapter = require(\"./nodejs/NodejsStreamInputAdapter\");\n\n\n/**\n * Add a file in the current folder.\n * @private\n * @param {string} name the name of the file\n * @param {String|ArrayBuffer|Uint8Array|Buffer} data the data of the file\n * @param {Object} originalOptions the options of the file\n * @return {Object} the new file.\n */\nvar fileAdd = function(name, data, originalOptions) {\n // be sure sub folders exist\n var dataType = utils.getTypeOf(data),\n parent;\n\n\n /*\n * Correct options.\n */\n\n var o = utils.extend(originalOptions || {}, defaults);\n o.date = o.date || new Date();\n if (o.compression !== null) {\n o.compression = o.compression.toUpperCase();\n }\n\n if (typeof o.unixPermissions === \"string\") {\n o.unixPermissions = parseInt(o.unixPermissions, 8);\n }\n\n // UNX_IFDIR 0040000 see zipinfo.c\n if (o.unixPermissions && (o.unixPermissions & 0x4000)) {\n o.dir = true;\n }\n // Bit 4 Directory\n if (o.dosPermissions && (o.dosPermissions & 0x0010)) {\n o.dir = true;\n }\n\n if (o.dir) {\n name = forceTrailingSlash(name);\n }\n if (o.createFolders && (parent = parentFolder(name))) {\n folderAdd.call(this, parent, true);\n }\n\n var isUnicodeString = dataType === \"string\" && o.binary === false && o.base64 === false;\n if (!originalOptions || typeof originalOptions.binary === \"undefined\") {\n o.binary = !isUnicodeString;\n }\n\n\n var isCompressedEmpty = (data instanceof CompressedObject) && data.uncompressedSize === 0;\n\n if (isCompressedEmpty || o.dir || !data || data.length === 0) {\n o.base64 = false;\n o.binary = true;\n data = \"\";\n o.compression = \"STORE\";\n dataType = \"string\";\n }\n\n /*\n * Convert content to fit.\n */\n\n var zipObjectContent = null;\n if (data instanceof CompressedObject || data instanceof GenericWorker) {\n zipObjectContent = data;\n } else if (nodejsUtils.isNode && nodejsUtils.isStream(data)) {\n zipObjectContent = new NodejsStreamInputAdapter(name, data);\n } else {\n zipObjectContent = utils.prepareContent(name, data, o.binary, o.optimizedBinaryString, o.base64);\n }\n\n var object = new ZipObject(name, zipObjectContent, o);\n this.files[name] = object;\n /*\n TODO: we can't throw an exception because we have async promises\n (we can have a promise of a Date() for example) but returning a\n promise is useless because file(name, data) returns the JSZip\n object for chaining. Should we break that to allow the user\n to catch the error ?\n\n return external.Promise.resolve(zipObjectContent)\n .then(function () {\n return object;\n });\n */\n};\n\n/**\n * Find the parent folder of the path.\n * @private\n * @param {string} path the path to use\n * @return {string} the parent folder, or \"\"\n */\nvar parentFolder = function (path) {\n if (path.slice(-1) === \"/\") {\n path = path.substring(0, path.length - 1);\n }\n var lastSlash = path.lastIndexOf(\"/\");\n return (lastSlash > 0) ? path.substring(0, lastSlash) : \"\";\n};\n\n/**\n * Returns the path with a slash at the end.\n * @private\n * @param {String} path the path to check.\n * @return {String} the path with a trailing slash.\n */\nvar forceTrailingSlash = function(path) {\n // Check the name ends with a /\n if (path.slice(-1) !== \"/\") {\n path += \"/\"; // IE doesn't like substr(-1)\n }\n return path;\n};\n\n/**\n * Add a (sub) folder in the current folder.\n * @private\n * @param {string} name the folder's name\n * @param {boolean=} [createFolders] If true, automatically create sub\n * folders. Defaults to false.\n * @return {Object} the new folder.\n */\nvar folderAdd = function(name, createFolders) {\n createFolders = (typeof createFolders !== \"undefined\") ? createFolders : defaults.createFolders;\n\n name = forceTrailingSlash(name);\n\n // Does this folder already exist?\n if (!this.files[name]) {\n fileAdd.call(this, name, null, {\n dir: true,\n createFolders: createFolders\n });\n }\n return this.files[name];\n};\n\n/**\n* Cross-window, cross-Node-context regular expression detection\n* @param {Object} object Anything\n* @return {Boolean} true if the object is a regular expression,\n* false otherwise\n*/\nfunction isRegExp(object) {\n return Object.prototype.toString.call(object) === \"[object RegExp]\";\n}\n\n// return the actual prototype of JSZip\nvar out = {\n /**\n * @see loadAsync\n */\n load: function() {\n throw new Error(\"This method has been removed in JSZip 3.0, please check the upgrade guide.\");\n },\n\n\n /**\n * Call a callback function for each entry at this folder level.\n * @param {Function} cb the callback function:\n * function (relativePath, file) {...}\n * It takes 2 arguments : the relative path and the file.\n */\n forEach: function(cb) {\n var filename, relativePath, file;\n // ignore warning about unwanted properties because this.files is a null prototype object\n /* eslint-disable-next-line guard-for-in */\n for (filename in this.files) {\n file = this.files[filename];\n relativePath = filename.slice(this.root.length, filename.length);\n if (relativePath && filename.slice(0, this.root.length) === this.root) { // the file is in the current root\n cb(relativePath, file); // TODO reverse the parameters ? need to be clean AND consistent with the filter search fn...\n }\n }\n },\n\n /**\n * Filter nested files/folders with the specified function.\n * @param {Function} search the predicate to use :\n * function (relativePath, file) {...}\n * It takes 2 arguments : the relative path and the file.\n * @return {Array} An array of matching elements.\n */\n filter: function(search) {\n var result = [];\n this.forEach(function (relativePath, entry) {\n if (search(relativePath, entry)) { // the file matches the function\n result.push(entry);\n }\n\n });\n return result;\n },\n\n /**\n * Add a file to the zip file, or search a file.\n * @param {string|RegExp} name The name of the file to add (if data is defined),\n * the name of the file to find (if no data) or a regex to match files.\n * @param {String|ArrayBuffer|Uint8Array|Buffer} data The file data, either raw or base64 encoded\n * @param {Object} o File options\n * @return {JSZip|Object|Array} this JSZip object (when adding a file),\n * a file (when searching by string) or an array of files (when searching by regex).\n */\n file: function(name, data, o) {\n if (arguments.length === 1) {\n if (isRegExp(name)) {\n var regexp = name;\n return this.filter(function(relativePath, file) {\n return !file.dir && regexp.test(relativePath);\n });\n }\n else { // text\n var obj = this.files[this.root + name];\n if (obj && !obj.dir) {\n return obj;\n } else {\n return null;\n }\n }\n }\n else { // more than one argument : we have data !\n name = this.root + name;\n fileAdd.call(this, name, data, o);\n }\n return this;\n },\n\n /**\n * Add a directory to the zip file, or search.\n * @param {String|RegExp} arg The name of the directory to add, or a regex to search folders.\n * @return {JSZip} an object with the new directory as the root, or an array containing matching folders.\n */\n folder: function(arg) {\n if (!arg) {\n return this;\n }\n\n if (isRegExp(arg)) {\n return this.filter(function(relativePath, file) {\n return file.dir && arg.test(relativePath);\n });\n }\n\n // else, name is a new folder\n var name = this.root + arg;\n var newFolder = folderAdd.call(this, name);\n\n // Allow chaining by returning a new object with this folder as the root\n var ret = this.clone();\n ret.root = newFolder.name;\n return ret;\n },\n\n /**\n * Delete a file, or a directory and all sub-files, from the zip\n * @param {string} name the name of the file to delete\n * @return {JSZip} this JSZip object\n */\n remove: function(name) {\n name = this.root + name;\n var file = this.files[name];\n if (!file) {\n // Look for any folders\n if (name.slice(-1) !== \"/\") {\n name += \"/\";\n }\n file = this.files[name];\n }\n\n if (file && !file.dir) {\n // file\n delete this.files[name];\n } else {\n // maybe a folder, delete recursively\n var kids = this.filter(function(relativePath, file) {\n return file.name.slice(0, name.length) === name;\n });\n for (var i = 0; i < kids.length; i++) {\n delete this.files[kids[i].name];\n }\n }\n\n return this;\n },\n\n /**\n * @deprecated This method has been removed in JSZip 3.0, please check the upgrade guide.\n */\n generate: function() {\n throw new Error(\"This method has been removed in JSZip 3.0, please check the upgrade guide.\");\n },\n\n /**\n * Generate the complete zip file as an internal stream.\n * @param {Object} options the options to generate the zip file :\n * - compression, \"STORE\" by default.\n * - type, \"base64\" by default. Values are : string, base64, uint8array, arraybuffer, blob.\n * @return {StreamHelper} the streamed zip file.\n */\n generateInternalStream: function(options) {\n var worker, opts = {};\n try {\n opts = utils.extend(options || {}, {\n streamFiles: false,\n compression: \"STORE\",\n compressionOptions : null,\n type: \"\",\n platform: \"DOS\",\n comment: null,\n mimeType: \"application/zip\",\n encodeFileName: utf8.utf8encode\n });\n\n opts.type = opts.type.toLowerCase();\n opts.compression = opts.compression.toUpperCase();\n\n // \"binarystring\" is preferred but the internals use \"string\".\n if(opts.type === \"binarystring\") {\n opts.type = \"string\";\n }\n\n if (!opts.type) {\n throw new Error(\"No output type specified.\");\n }\n\n utils.checkSupport(opts.type);\n\n // accept nodejs `process.platform`\n if(\n opts.platform === \"darwin\" ||\n opts.platform === \"freebsd\" ||\n opts.platform === \"linux\" ||\n opts.platform === \"sunos\"\n ) {\n opts.platform = \"UNIX\";\n }\n if (opts.platform === \"win32\") {\n opts.platform = \"DOS\";\n }\n\n var comment = opts.comment || this.comment || \"\";\n worker = generate.generateWorker(this, opts, comment);\n } catch (e) {\n worker = new GenericWorker(\"error\");\n worker.error(e);\n }\n return new StreamHelper(worker, opts.type || \"string\", opts.mimeType);\n },\n /**\n * Generate the complete zip file asynchronously.\n * @see generateInternalStream\n */\n generateAsync: function(options, onUpdate) {\n return this.generateInternalStream(options).accumulate(onUpdate);\n },\n /**\n * Generate the complete zip file asynchronously.\n * @see generateInternalStream\n */\n generateNodeStream: function(options, onUpdate) {\n options = options || {};\n if (!options.type) {\n options.type = \"nodebuffer\";\n }\n return this.generateInternalStream(options).toNodejsStream(onUpdate);\n }\n};\nmodule.exports = out;\n\n},{\"./compressedObject\":2,\"./defaults\":5,\"./generate\":9,\"./nodejs/NodejsStreamInputAdapter\":12,\"./nodejsUtils\":14,\"./stream/GenericWorker\":28,\"./stream/StreamHelper\":29,\"./utf8\":31,\"./utils\":32,\"./zipObject\":35}],16:[function(require,module,exports){\n\"use strict\";\n/*\n * This file is used by module bundlers (browserify/webpack/etc) when\n * including a stream implementation. We use \"readable-stream\" to get a\n * consistent behavior between nodejs versions but bundlers often have a shim\n * for \"stream\". Using this shim greatly improve the compatibility and greatly\n * reduce the final size of the bundle (only one stream implementation, not\n * two).\n */\nmodule.exports = require(\"stream\");\n\n},{\"stream\":undefined}],17:[function(require,module,exports){\n\"use strict\";\nvar DataReader = require(\"./DataReader\");\nvar utils = require(\"../utils\");\n\nfunction ArrayReader(data) {\n DataReader.call(this, data);\n for(var i = 0; i < this.data.length; i++) {\n data[i] = data[i] & 0xFF;\n }\n}\nutils.inherits(ArrayReader, DataReader);\n/**\n * @see DataReader.byteAt\n */\nArrayReader.prototype.byteAt = function(i) {\n return this.data[this.zero + i];\n};\n/**\n * @see DataReader.lastIndexOfSignature\n */\nArrayReader.prototype.lastIndexOfSignature = function(sig) {\n var sig0 = sig.charCodeAt(0),\n sig1 = sig.charCodeAt(1),\n sig2 = sig.charCodeAt(2),\n sig3 = sig.charCodeAt(3);\n for (var i = this.length - 4; i >= 0; --i) {\n if (this.data[i] === sig0 && this.data[i + 1] === sig1 && this.data[i + 2] === sig2 && this.data[i + 3] === sig3) {\n return i - this.zero;\n }\n }\n\n return -1;\n};\n/**\n * @see DataReader.readAndCheckSignature\n */\nArrayReader.prototype.readAndCheckSignature = function (sig) {\n var sig0 = sig.charCodeAt(0),\n sig1 = sig.charCodeAt(1),\n sig2 = sig.charCodeAt(2),\n sig3 = sig.charCodeAt(3),\n data = this.readData(4);\n return sig0 === data[0] && sig1 === data[1] && sig2 === data[2] && sig3 === data[3];\n};\n/**\n * @see DataReader.readData\n */\nArrayReader.prototype.readData = function(size) {\n this.checkOffset(size);\n if(size === 0) {\n return [];\n }\n var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);\n this.index += size;\n return result;\n};\nmodule.exports = ArrayReader;\n\n},{\"../utils\":32,\"./DataReader\":18}],18:[function(require,module,exports){\n\"use strict\";\nvar utils = require(\"../utils\");\n\nfunction DataReader(data) {\n this.data = data; // type : see implementation\n this.length = data.length;\n this.index = 0;\n this.zero = 0;\n}\nDataReader.prototype = {\n /**\n * Check that the offset will not go too far.\n * @param {string} offset the additional offset to check.\n * @throws {Error} an Error if the offset is out of bounds.\n */\n checkOffset: function(offset) {\n this.checkIndex(this.index + offset);\n },\n /**\n * Check that the specified index will not be too far.\n * @param {string} newIndex the index to check.\n * @throws {Error} an Error if the index is out of bounds.\n */\n checkIndex: function(newIndex) {\n if (this.length < this.zero + newIndex || newIndex < 0) {\n throw new Error(\"End of data reached (data length = \" + this.length + \", asked index = \" + (newIndex) + \"). Corrupted zip ?\");\n }\n },\n /**\n * Change the index.\n * @param {number} newIndex The new index.\n * @throws {Error} if the new index is out of the data.\n */\n setIndex: function(newIndex) {\n this.checkIndex(newIndex);\n this.index = newIndex;\n },\n /**\n * Skip the next n bytes.\n * @param {number} n the number of bytes to skip.\n * @throws {Error} if the new index is out of the data.\n */\n skip: function(n) {\n this.setIndex(this.index + n);\n },\n /**\n * Get the byte at the specified index.\n * @param {number} i the index to use.\n * @return {number} a byte.\n */\n byteAt: function() {\n // see implementations\n },\n /**\n * Get the next number with a given byte size.\n * @param {number} size the number of bytes to read.\n * @return {number} the corresponding number.\n */\n readInt: function(size) {\n var result = 0,\n i;\n this.checkOffset(size);\n for (i = this.index + size - 1; i >= this.index; i--) {\n result = (result << 8) + this.byteAt(i);\n }\n this.index += size;\n return result;\n },\n /**\n * Get the next string with a given byte size.\n * @param {number} size the number of bytes to read.\n * @return {string} the corresponding string.\n */\n readString: function(size) {\n return utils.transformTo(\"string\", this.readData(size));\n },\n /**\n * Get raw data without conversion, bytes.\n * @param {number} size the number of bytes to read.\n * @return {Object} the raw data, implementation specific.\n */\n readData: function() {\n // see implementations\n },\n /**\n * Find the last occurrence of a zip signature (4 bytes).\n * @param {string} sig the signature to find.\n * @return {number} the index of the last occurrence, -1 if not found.\n */\n lastIndexOfSignature: function() {\n // see implementations\n },\n /**\n * Read the signature (4 bytes) at the current position and compare it with sig.\n * @param {string} sig the expected signature\n * @return {boolean} true if the signature matches, false otherwise.\n */\n readAndCheckSignature: function() {\n // see implementations\n },\n /**\n * Get the next date.\n * @return {Date} the date.\n */\n readDate: function() {\n var dostime = this.readInt(4);\n return new Date(Date.UTC(\n ((dostime >> 25) & 0x7f) + 1980, // year\n ((dostime >> 21) & 0x0f) - 1, // month\n (dostime >> 16) & 0x1f, // day\n (dostime >> 11) & 0x1f, // hour\n (dostime >> 5) & 0x3f, // minute\n (dostime & 0x1f) << 1)); // second\n }\n};\nmodule.exports = DataReader;\n\n},{\"../utils\":32}],19:[function(require,module,exports){\n\"use strict\";\nvar Uint8ArrayReader = require(\"./Uint8ArrayReader\");\nvar utils = require(\"../utils\");\n\nfunction NodeBufferReader(data) {\n Uint8ArrayReader.call(this, data);\n}\nutils.inherits(NodeBufferReader, Uint8ArrayReader);\n\n/**\n * @see DataReader.readData\n */\nNodeBufferReader.prototype.readData = function(size) {\n this.checkOffset(size);\n var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);\n this.index += size;\n return result;\n};\nmodule.exports = NodeBufferReader;\n\n},{\"../utils\":32,\"./Uint8ArrayReader\":21}],20:[function(require,module,exports){\n\"use strict\";\nvar DataReader = require(\"./DataReader\");\nvar utils = require(\"../utils\");\n\nfunction StringReader(data) {\n DataReader.call(this, data);\n}\nutils.inherits(StringReader, DataReader);\n/**\n * @see DataReader.byteAt\n */\nStringReader.prototype.byteAt = function(i) {\n return this.data.charCodeAt(this.zero + i);\n};\n/**\n * @see DataReader.lastIndexOfSignature\n */\nStringReader.prototype.lastIndexOfSignature = function(sig) {\n return this.data.lastIndexOf(sig) - this.zero;\n};\n/**\n * @see DataReader.readAndCheckSignature\n */\nStringReader.prototype.readAndCheckSignature = function (sig) {\n var data = this.readData(4);\n return sig === data;\n};\n/**\n * @see DataReader.readData\n */\nStringReader.prototype.readData = function(size) {\n this.checkOffset(size);\n // this will work because the constructor applied the \"& 0xff\" mask.\n var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);\n this.index += size;\n return result;\n};\nmodule.exports = StringReader;\n\n},{\"../utils\":32,\"./DataReader\":18}],21:[function(require,module,exports){\n\"use strict\";\nvar ArrayReader = require(\"./ArrayReader\");\nvar utils = require(\"../utils\");\n\nfunction Uint8ArrayReader(data) {\n ArrayReader.call(this, data);\n}\nutils.inherits(Uint8ArrayReader, ArrayReader);\n/**\n * @see DataReader.readData\n */\nUint8ArrayReader.prototype.readData = function(size) {\n this.checkOffset(size);\n if(size === 0) {\n // in IE10, when using subarray(idx, idx), we get the array [0x00] instead of [].\n return new Uint8Array(0);\n }\n var result = this.data.subarray(this.zero + this.index, this.zero + this.index + size);\n this.index += size;\n return result;\n};\nmodule.exports = Uint8ArrayReader;\n\n},{\"../utils\":32,\"./ArrayReader\":17}],22:[function(require,module,exports){\n\"use strict\";\n\nvar utils = require(\"../utils\");\nvar support = require(\"../support\");\nvar ArrayReader = require(\"./ArrayReader\");\nvar StringReader = require(\"./StringReader\");\nvar NodeBufferReader = require(\"./NodeBufferReader\");\nvar Uint8ArrayReader = require(\"./Uint8ArrayReader\");\n\n/**\n * Create a reader adapted to the data.\n * @param {String|ArrayBuffer|Uint8Array|Buffer} data the data to read.\n * @return {DataReader} the data reader.\n */\nmodule.exports = function (data) {\n var type = utils.getTypeOf(data);\n utils.checkSupport(type);\n if (type === \"string\" && !support.uint8array) {\n return new StringReader(data);\n }\n if (type === \"nodebuffer\") {\n return new NodeBufferReader(data);\n }\n if (support.uint8array) {\n return new Uint8ArrayReader(utils.transformTo(\"uint8array\", data));\n }\n return new ArrayReader(utils.transformTo(\"array\", data));\n};\n\n},{\"../support\":30,\"../utils\":32,\"./ArrayReader\":17,\"./NodeBufferReader\":19,\"./StringReader\":20,\"./Uint8ArrayReader\":21}],23:[function(require,module,exports){\n\"use strict\";\nexports.LOCAL_FILE_HEADER = \"PK\\x03\\x04\";\nexports.CENTRAL_FILE_HEADER = \"PK\\x01\\x02\";\nexports.CENTRAL_DIRECTORY_END = \"PK\\x05\\x06\";\nexports.ZIP64_CENTRAL_DIRECTORY_LOCATOR = \"PK\\x06\\x07\";\nexports.ZIP64_CENTRAL_DIRECTORY_END = \"PK\\x06\\x06\";\nexports.DATA_DESCRIPTOR = \"PK\\x07\\x08\";\n\n},{}],24:[function(require,module,exports){\n\"use strict\";\n\nvar GenericWorker = require(\"./GenericWorker\");\nvar utils = require(\"../utils\");\n\n/**\n * A worker which convert chunks to a specified type.\n * @constructor\n * @param {String} destType the destination type.\n */\nfunction ConvertWorker(destType) {\n GenericWorker.call(this, \"ConvertWorker to \" + destType);\n this.destType = destType;\n}\nutils.inherits(ConvertWorker, GenericWorker);\n\n/**\n * @see GenericWorker.processChunk\n */\nConvertWorker.prototype.processChunk = function (chunk) {\n this.push({\n data : utils.transformTo(this.destType, chunk.data),\n meta : chunk.meta\n });\n};\nmodule.exports = ConvertWorker;\n\n},{\"../utils\":32,\"./GenericWorker\":28}],25:[function(require,module,exports){\n\"use strict\";\n\nvar GenericWorker = require(\"./GenericWorker\");\nvar crc32 = require(\"../crc32\");\nvar utils = require(\"../utils\");\n\n/**\n * A worker which calculate the crc32 of the data flowing through.\n * @constructor\n */\nfunction Crc32Probe() {\n GenericWorker.call(this, \"Crc32Probe\");\n this.withStreamInfo(\"crc32\", 0);\n}\nutils.inherits(Crc32Probe, GenericWorker);\n\n/**\n * @see GenericWorker.processChunk\n */\nCrc32Probe.prototype.processChunk = function (chunk) {\n this.streamInfo.crc32 = crc32(chunk.data, this.streamInfo.crc32 || 0);\n this.push(chunk);\n};\nmodule.exports = Crc32Probe;\n\n},{\"../crc32\":4,\"../utils\":32,\"./GenericWorker\":28}],26:[function(require,module,exports){\n\"use strict\";\n\nvar utils = require(\"../utils\");\nvar GenericWorker = require(\"./GenericWorker\");\n\n/**\n * A worker which calculate the total length of the data flowing through.\n * @constructor\n * @param {String} propName the name used to expose the length\n */\nfunction DataLengthProbe(propName) {\n GenericWorker.call(this, \"DataLengthProbe for \" + propName);\n this.propName = propName;\n this.withStreamInfo(propName, 0);\n}\nutils.inherits(DataLengthProbe, GenericWorker);\n\n/**\n * @see GenericWorker.processChunk\n */\nDataLengthProbe.prototype.processChunk = function (chunk) {\n if(chunk) {\n var length = this.streamInfo[this.propName] || 0;\n this.streamInfo[this.propName] = length + chunk.data.length;\n }\n GenericWorker.prototype.processChunk.call(this, chunk);\n};\nmodule.exports = DataLengthProbe;\n\n\n},{\"../utils\":32,\"./GenericWorker\":28}],27:[function(require,module,exports){\n\"use strict\";\n\nvar utils = require(\"../utils\");\nvar GenericWorker = require(\"./GenericWorker\");\n\n// the size of the generated chunks\n// TODO expose this as a public variable\nvar DEFAULT_BLOCK_SIZE = 16 * 1024;\n\n/**\n * A worker that reads a content and emits chunks.\n * @constructor\n * @param {Promise} dataP the promise of the data to split\n */\nfunction DataWorker(dataP) {\n GenericWorker.call(this, \"DataWorker\");\n var self = this;\n this.dataIsReady = false;\n this.index = 0;\n this.max = 0;\n this.data = null;\n this.type = \"\";\n\n this._tickScheduled = false;\n\n dataP.then(function (data) {\n self.dataIsReady = true;\n self.data = data;\n self.max = data && data.length || 0;\n self.type = utils.getTypeOf(data);\n if(!self.isPaused) {\n self._tickAndRepeat();\n }\n }, function (e) {\n self.error(e);\n });\n}\n\nutils.inherits(DataWorker, GenericWorker);\n\n/**\n * @see GenericWorker.cleanUp\n */\nDataWorker.prototype.cleanUp = function () {\n GenericWorker.prototype.cleanUp.call(this);\n this.data = null;\n};\n\n/**\n * @see GenericWorker.resume\n */\nDataWorker.prototype.resume = function () {\n if(!GenericWorker.prototype.resume.call(this)) {\n return false;\n }\n\n if (!this._tickScheduled && this.dataIsReady) {\n this._tickScheduled = true;\n utils.delay(this._tickAndRepeat, [], this);\n }\n return true;\n};\n\n/**\n * Trigger a tick a schedule an other call to this function.\n */\nDataWorker.prototype._tickAndRepeat = function() {\n this._tickScheduled = false;\n if(this.isPaused || this.isFinished) {\n return;\n }\n this._tick();\n if(!this.isFinished) {\n utils.delay(this._tickAndRepeat, [], this);\n this._tickScheduled = true;\n }\n};\n\n/**\n * Read and push a chunk.\n */\nDataWorker.prototype._tick = function() {\n\n if(this.isPaused || this.isFinished) {\n return false;\n }\n\n var size = DEFAULT_BLOCK_SIZE;\n var data = null, nextIndex = Math.min(this.max, this.index + size);\n if (this.index >= this.max) {\n // EOF\n return this.end();\n } else {\n switch(this.type) {\n case \"string\":\n data = this.data.substring(this.index, nextIndex);\n break;\n case \"uint8array\":\n data = this.data.subarray(this.index, nextIndex);\n break;\n case \"array\":\n case \"nodebuffer\":\n data = this.data.slice(this.index, nextIndex);\n break;\n }\n this.index = nextIndex;\n return this.push({\n data : data,\n meta : {\n percent : this.max ? this.index / this.max * 100 : 0\n }\n });\n }\n};\n\nmodule.exports = DataWorker;\n\n},{\"../utils\":32,\"./GenericWorker\":28}],28:[function(require,module,exports){\n\"use strict\";\n\n/**\n * A worker that does nothing but passing chunks to the next one. This is like\n * a nodejs stream but with some differences. On the good side :\n * - it works on IE 6-9 without any issue / polyfill\n * - it weights less than the full dependencies bundled with browserify\n * - it forwards errors (no need to declare an error handler EVERYWHERE)\n *\n * A chunk is an object with 2 attributes : `meta` and `data`. The former is an\n * object containing anything (`percent` for example), see each worker for more\n * details. The latter is the real data (String, Uint8Array, etc).\n *\n * @constructor\n * @param {String} name the name of the stream (mainly used for debugging purposes)\n */\nfunction GenericWorker(name) {\n // the name of the worker\n this.name = name || \"default\";\n // an object containing metadata about the workers chain\n this.streamInfo = {};\n // an error which happened when the worker was paused\n this.generatedError = null;\n // an object containing metadata to be merged by this worker into the general metadata\n this.extraStreamInfo = {};\n // true if the stream is paused (and should not do anything), false otherwise\n this.isPaused = true;\n // true if the stream is finished (and should not do anything), false otherwise\n this.isFinished = false;\n // true if the stream is locked to prevent further structure updates (pipe), false otherwise\n this.isLocked = false;\n // the event listeners\n this._listeners = {\n \"data\":[],\n \"end\":[],\n \"error\":[]\n };\n // the previous worker, if any\n this.previous = null;\n}\n\nGenericWorker.prototype = {\n /**\n * Push a chunk to the next workers.\n * @param {Object} chunk the chunk to push\n */\n push : function (chunk) {\n this.emit(\"data\", chunk);\n },\n /**\n * End the stream.\n * @return {Boolean} true if this call ended the worker, false otherwise.\n */\n end : function () {\n if (this.isFinished) {\n return false;\n }\n\n this.flush();\n try {\n this.emit(\"end\");\n this.cleanUp();\n this.isFinished = true;\n } catch (e) {\n this.emit(\"error\", e);\n }\n return true;\n },\n /**\n * End the stream with an error.\n * @param {Error} e the error which caused the premature end.\n * @return {Boolean} true if this call ended the worker with an error, false otherwise.\n */\n error : function (e) {\n if (this.isFinished) {\n return false;\n }\n\n if(this.isPaused) {\n this.generatedError = e;\n } else {\n this.isFinished = true;\n\n this.emit(\"error\", e);\n\n // in the workers chain exploded in the middle of the chain,\n // the error event will go downward but we also need to notify\n // workers upward that there has been an error.\n if(this.previous) {\n this.previous.error(e);\n }\n\n this.cleanUp();\n }\n return true;\n },\n /**\n * Add a callback on an event.\n * @param {String} name the name of the event (data, end, error)\n * @param {Function} listener the function to call when the event is triggered\n * @return {GenericWorker} the current object for chainability\n */\n on : function (name, listener) {\n this._listeners[name].push(listener);\n return this;\n },\n /**\n * Clean any references when a worker is ending.\n */\n cleanUp : function () {\n this.streamInfo = this.generatedError = this.extraStreamInfo = null;\n this._listeners = [];\n },\n /**\n * Trigger an event. This will call registered callback with the provided arg.\n * @param {String} name the name of the event (data, end, error)\n * @param {Object} arg the argument to call the callback with.\n */\n emit : function (name, arg) {\n if (this._listeners[name]) {\n for(var i = 0; i < this._listeners[name].length; i++) {\n this._listeners[name][i].call(this, arg);\n }\n }\n },\n /**\n * Chain a worker with an other.\n * @param {Worker} next the worker receiving events from the current one.\n * @return {worker} the next worker for chainability\n */\n pipe : function (next) {\n return next.registerPrevious(this);\n },\n /**\n * Same as `pipe` in the other direction.\n * Using an API with `pipe(next)` is very easy.\n * Implementing the API with the point of view of the next one registering\n * a source is easier, see the ZipFileWorker.\n * @param {Worker} previous the previous worker, sending events to this one\n * @return {Worker} the current worker for chainability\n */\n registerPrevious : function (previous) {\n if (this.isLocked) {\n throw new Error(\"The stream '\" + this + \"' has already been used.\");\n }\n\n // sharing the streamInfo...\n this.streamInfo = previous.streamInfo;\n // ... and adding our own bits\n this.mergeStreamInfo();\n this.previous = previous;\n var self = this;\n previous.on(\"data\", function (chunk) {\n self.processChunk(chunk);\n });\n previous.on(\"end\", function () {\n self.end();\n });\n previous.on(\"error\", function (e) {\n self.error(e);\n });\n return this;\n },\n /**\n * Pause the stream so it doesn't send events anymore.\n * @return {Boolean} true if this call paused the worker, false otherwise.\n */\n pause : function () {\n if(this.isPaused || this.isFinished) {\n return false;\n }\n this.isPaused = true;\n\n if(this.previous) {\n this.previous.pause();\n }\n return true;\n },\n /**\n * Resume a paused stream.\n * @return {Boolean} true if this call resumed the worker, false otherwise.\n */\n resume : function () {\n if(!this.isPaused || this.isFinished) {\n return false;\n }\n this.isPaused = false;\n\n // if true, the worker tried to resume but failed\n var withError = false;\n if(this.generatedError) {\n this.error(this.generatedError);\n withError = true;\n }\n if(this.previous) {\n this.previous.resume();\n }\n\n return !withError;\n },\n /**\n * Flush any remaining bytes as the stream is ending.\n */\n flush : function () {},\n /**\n * Process a chunk. This is usually the method overridden.\n * @param {Object} chunk the chunk to process.\n */\n processChunk : function(chunk) {\n this.push(chunk);\n },\n /**\n * Add a key/value to be added in the workers chain streamInfo once activated.\n * @param {String} key the key to use\n * @param {Object} value the associated value\n * @return {Worker} the current worker for chainability\n */\n withStreamInfo : function (key, value) {\n this.extraStreamInfo[key] = value;\n this.mergeStreamInfo();\n return this;\n },\n /**\n * Merge this worker's streamInfo into the chain's streamInfo.\n */\n mergeStreamInfo : function () {\n for(var key in this.extraStreamInfo) {\n if (!Object.prototype.hasOwnProperty.call(this.extraStreamInfo, key)) {\n continue;\n }\n this.streamInfo[key] = this.extraStreamInfo[key];\n }\n },\n\n /**\n * Lock the stream to prevent further updates on the workers chain.\n * After calling this method, all calls to pipe will fail.\n */\n lock: function () {\n if (this.isLocked) {\n throw new Error(\"The stream '\" + this + \"' has already been used.\");\n }\n this.isLocked = true;\n if (this.previous) {\n this.previous.lock();\n }\n },\n\n /**\n *\n * Pretty print the workers chain.\n */\n toString : function () {\n var me = \"Worker \" + this.name;\n if (this.previous) {\n return this.previous + \" -> \" + me;\n } else {\n return me;\n }\n }\n};\n\nmodule.exports = GenericWorker;\n\n},{}],29:[function(require,module,exports){\n\"use strict\";\n\nvar utils = require(\"../utils\");\nvar ConvertWorker = require(\"./ConvertWorker\");\nvar GenericWorker = require(\"./GenericWorker\");\nvar base64 = require(\"../base64\");\nvar support = require(\"../support\");\nvar external = require(\"../external\");\n\nvar NodejsStreamOutputAdapter = null;\nif (support.nodestream) {\n try {\n NodejsStreamOutputAdapter = require(\"../nodejs/NodejsStreamOutputAdapter\");\n } catch(e) {\n // ignore\n }\n}\n\n/**\n * Apply the final transformation of the data. If the user wants a Blob for\n * example, it's easier to work with an U8intArray and finally do the\n * ArrayBuffer/Blob conversion.\n * @param {String} type the name of the final type\n * @param {String|Uint8Array|Buffer} content the content to transform\n * @param {String} mimeType the mime type of the content, if applicable.\n * @return {String|Uint8Array|ArrayBuffer|Buffer|Blob} the content in the right format.\n */\nfunction transformZipOutput(type, content, mimeType) {\n switch(type) {\n case \"blob\" :\n return utils.newBlob(utils.transformTo(\"arraybuffer\", content), mimeType);\n case \"base64\" :\n return base64.encode(content);\n default :\n return utils.transformTo(type, content);\n }\n}\n\n/**\n * Concatenate an array of data of the given type.\n * @param {String} type the type of the data in the given array.\n * @param {Array} dataArray the array containing the data chunks to concatenate\n * @return {String|Uint8Array|Buffer} the concatenated data\n * @throws Error if the asked type is unsupported\n */\nfunction concat (type, dataArray) {\n var i, index = 0, res = null, totalLength = 0;\n for(i = 0; i < dataArray.length; i++) {\n totalLength += dataArray[i].length;\n }\n switch(type) {\n case \"string\":\n return dataArray.join(\"\");\n case \"array\":\n return Array.prototype.concat.apply([], dataArray);\n case \"uint8array\":\n res = new Uint8Array(totalLength);\n for(i = 0; i < dataArray.length; i++) {\n res.set(dataArray[i], index);\n index += dataArray[i].length;\n }\n return res;\n case \"nodebuffer\":\n return Buffer.concat(dataArray);\n default:\n throw new Error(\"concat : unsupported type '\" + type + \"'\");\n }\n}\n\n/**\n * Listen a StreamHelper, accumulate its content and concatenate it into a\n * complete block.\n * @param {StreamHelper} helper the helper to use.\n * @param {Function} updateCallback a callback called on each update. Called\n * with one arg :\n * - the metadata linked to the update received.\n * @return Promise the promise for the accumulation.\n */\nfunction accumulate(helper, updateCallback) {\n return new external.Promise(function (resolve, reject){\n var dataArray = [];\n var chunkType = helper._internalType,\n resultType = helper._outputType,\n mimeType = helper._mimeType;\n helper\n .on(\"data\", function (data, meta) {\n dataArray.push(data);\n if(updateCallback) {\n updateCallback(meta);\n }\n })\n .on(\"error\", function(err) {\n dataArray = [];\n reject(err);\n })\n .on(\"end\", function (){\n try {\n var result = transformZipOutput(resultType, concat(chunkType, dataArray), mimeType);\n resolve(result);\n } catch (e) {\n reject(e);\n }\n dataArray = [];\n })\n .resume();\n });\n}\n\n/**\n * An helper to easily use workers outside of JSZip.\n * @constructor\n * @param {Worker} worker the worker to wrap\n * @param {String} outputType the type of data expected by the use\n * @param {String} mimeType the mime type of the content, if applicable.\n */\nfunction StreamHelper(worker, outputType, mimeType) {\n var internalType = outputType;\n switch(outputType) {\n case \"blob\":\n case \"arraybuffer\":\n internalType = \"uint8array\";\n break;\n case \"base64\":\n internalType = \"string\";\n break;\n }\n\n try {\n // the type used internally\n this._internalType = internalType;\n // the type used to output results\n this._outputType = outputType;\n // the mime type\n this._mimeType = mimeType;\n utils.checkSupport(internalType);\n this._worker = worker.pipe(new ConvertWorker(internalType));\n // the last workers can be rewired without issues but we need to\n // prevent any updates on previous workers.\n worker.lock();\n } catch(e) {\n this._worker = new GenericWorker(\"error\");\n this._worker.error(e);\n }\n}\n\nStreamHelper.prototype = {\n /**\n * Listen a StreamHelper, accumulate its content and concatenate it into a\n * complete block.\n * @param {Function} updateCb the update callback.\n * @return Promise the promise for the accumulation.\n */\n accumulate : function (updateCb) {\n return accumulate(this, updateCb);\n },\n /**\n * Add a listener on an event triggered on a stream.\n * @param {String} evt the name of the event\n * @param {Function} fn the listener\n * @return {StreamHelper} the current helper.\n */\n on : function (evt, fn) {\n var self = this;\n\n if(evt === \"data\") {\n this._worker.on(evt, function (chunk) {\n fn.call(self, chunk.data, chunk.meta);\n });\n } else {\n this._worker.on(evt, function () {\n utils.delay(fn, arguments, self);\n });\n }\n return this;\n },\n /**\n * Resume the flow of chunks.\n * @return {StreamHelper} the current helper.\n */\n resume : function () {\n utils.delay(this._worker.resume, [], this._worker);\n return this;\n },\n /**\n * Pause the flow of chunks.\n * @return {StreamHelper} the current helper.\n */\n pause : function () {\n this._worker.pause();\n return this;\n },\n /**\n * Return a nodejs stream for this helper.\n * @param {Function} updateCb the update callback.\n * @return {NodejsStreamOutputAdapter} the nodejs stream.\n */\n toNodejsStream : function (updateCb) {\n utils.checkSupport(\"nodestream\");\n if (this._outputType !== \"nodebuffer\") {\n // an object stream containing blob/arraybuffer/uint8array/string\n // is strange and I don't know if it would be useful.\n // I you find this comment and have a good usecase, please open a\n // bug report !\n throw new Error(this._outputType + \" is not supported by this method\");\n }\n\n return new NodejsStreamOutputAdapter(this, {\n objectMode : this._outputType !== \"nodebuffer\"\n }, updateCb);\n }\n};\n\n\nmodule.exports = StreamHelper;\n\n},{\"../base64\":1,\"../external\":6,\"../nodejs/NodejsStreamOutputAdapter\":13,\"../support\":30,\"../utils\":32,\"./ConvertWorker\":24,\"./GenericWorker\":28}],30:[function(require,module,exports){\n\"use strict\";\n\nexports.base64 = true;\nexports.array = true;\nexports.string = true;\nexports.arraybuffer = typeof ArrayBuffer !== \"undefined\" && typeof Uint8Array !== \"undefined\";\nexports.nodebuffer = typeof Buffer !== \"undefined\";\n// contains true if JSZip can read/generate Uint8Array, false otherwise.\nexports.uint8array = typeof Uint8Array !== \"undefined\";\n\nif (typeof ArrayBuffer === \"undefined\") {\n exports.blob = false;\n}\nelse {\n var buffer = new ArrayBuffer(0);\n try {\n exports.blob = new Blob([buffer], {\n type: \"application/zip\"\n }).size === 0;\n }\n catch (e) {\n try {\n var Builder = self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder;\n var builder = new Builder();\n builder.append(buffer);\n exports.blob = builder.getBlob(\"application/zip\").size === 0;\n }\n catch (e) {\n exports.blob = false;\n }\n }\n}\n\ntry {\n exports.nodestream = !!require(\"readable-stream\").Readable;\n} catch(e) {\n exports.nodestream = false;\n}\n\n},{\"readable-stream\":16}],31:[function(require,module,exports){\n\"use strict\";\n\nvar utils = require(\"./utils\");\nvar support = require(\"./support\");\nvar nodejsUtils = require(\"./nodejsUtils\");\nvar GenericWorker = require(\"./stream/GenericWorker\");\n\n/**\n * The following functions come from pako, from pako/lib/utils/strings\n * released under the MIT license, see pako https://github.com/nodeca/pako/\n */\n\n// Table with utf8 lengths (calculated by first byte of sequence)\n// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n// because max possible codepoint is 0x10ffff\nvar _utf8len = new Array(256);\nfor (var i=0; i<256; i++) {\n _utf8len[i] = (i >= 252 ? 6 : i >= 248 ? 5 : i >= 240 ? 4 : i >= 224 ? 3 : i >= 192 ? 2 : 1);\n}\n_utf8len[254]=_utf8len[254]=1; // Invalid sequence start\n\n// convert string to array (typed, when possible)\nvar string2buf = function (str) {\n var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos+1 < str_len)) {\n c2 = str.charCodeAt(m_pos+1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n }\n\n // allocate buffer\n if (support.uint8array) {\n buf = new Uint8Array(buf_len);\n } else {\n buf = new Array(buf_len);\n }\n\n // convert\n for (i=0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos+1 < str_len)) {\n c2 = str.charCodeAt(m_pos+1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c;\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xC0 | (c >>> 6);\n buf[i++] = 0x80 | (c & 0x3f);\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xE0 | (c >>> 12);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18);\n buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n }\n }\n\n return buf;\n};\n\n// Calculate max possible position in utf8 buffer,\n// that will not break sequence. If that's not possible\n// - (very small limits) return max size as is.\n//\n// buf[] - utf8 bytes array\n// max - length limit (mandatory);\nvar utf8border = function(buf, max) {\n var pos;\n\n max = max || buf.length;\n if (max > buf.length) { max = buf.length; }\n\n // go back from last position, until start of sequence found\n pos = max-1;\n while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n // Fuckup - very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) { return max; }\n\n // If we came to start of buffer - that means vuffer is too small,\n // return max too.\n if (pos === 0) { return max; }\n\n return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n};\n\n// convert array to string\nvar buf2string = function (buf) {\n var i, out, c, c_len;\n var len = buf.length;\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n var utf16buf = new Array(len*2);\n\n for (out=0, i=0; i 4) { utf16buf[out++] = 0xfffd; i += c_len-1; continue; }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f);\n c_len--;\n }\n\n // terminated by end of string?\n if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n if (c < 0x10000) {\n utf16buf[out++] = c;\n } else {\n c -= 0x10000;\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n }\n }\n\n // shrinkBuf(utf16buf, out)\n if (utf16buf.length !== out) {\n if(utf16buf.subarray) {\n utf16buf = utf16buf.subarray(0, out);\n } else {\n utf16buf.length = out;\n }\n }\n\n // return String.fromCharCode.apply(null, utf16buf);\n return utils.applyFromCharCode(utf16buf);\n};\n\n\n// That's all for the pako functions.\n\n\n/**\n * Transform a javascript string into an array (typed if possible) of bytes,\n * UTF-8 encoded.\n * @param {String} str the string to encode\n * @return {Array|Uint8Array|Buffer} the UTF-8 encoded string.\n */\nexports.utf8encode = function utf8encode(str) {\n if (support.nodebuffer) {\n return nodejsUtils.newBufferFrom(str, \"utf-8\");\n }\n\n return string2buf(str);\n};\n\n\n/**\n * Transform a bytes array (or a representation) representing an UTF-8 encoded\n * string into a javascript string.\n * @param {Array|Uint8Array|Buffer} buf the data de decode\n * @return {String} the decoded string.\n */\nexports.utf8decode = function utf8decode(buf) {\n if (support.nodebuffer) {\n return utils.transformTo(\"nodebuffer\", buf).toString(\"utf-8\");\n }\n\n buf = utils.transformTo(support.uint8array ? \"uint8array\" : \"array\", buf);\n\n return buf2string(buf);\n};\n\n/**\n * A worker to decode utf8 encoded binary chunks into string chunks.\n * @constructor\n */\nfunction Utf8DecodeWorker() {\n GenericWorker.call(this, \"utf-8 decode\");\n // the last bytes if a chunk didn't end with a complete codepoint.\n this.leftOver = null;\n}\nutils.inherits(Utf8DecodeWorker, GenericWorker);\n\n/**\n * @see GenericWorker.processChunk\n */\nUtf8DecodeWorker.prototype.processChunk = function (chunk) {\n\n var data = utils.transformTo(support.uint8array ? \"uint8array\" : \"array\", chunk.data);\n\n // 1st step, re-use what's left of the previous chunk\n if (this.leftOver && this.leftOver.length) {\n if(support.uint8array) {\n var previousData = data;\n data = new Uint8Array(previousData.length + this.leftOver.length);\n data.set(this.leftOver, 0);\n data.set(previousData, this.leftOver.length);\n } else {\n data = this.leftOver.concat(data);\n }\n this.leftOver = null;\n }\n\n var nextBoundary = utf8border(data);\n var usableData = data;\n if (nextBoundary !== data.length) {\n if (support.uint8array) {\n usableData = data.subarray(0, nextBoundary);\n this.leftOver = data.subarray(nextBoundary, data.length);\n } else {\n usableData = data.slice(0, nextBoundary);\n this.leftOver = data.slice(nextBoundary, data.length);\n }\n }\n\n this.push({\n data : exports.utf8decode(usableData),\n meta : chunk.meta\n });\n};\n\n/**\n * @see GenericWorker.flush\n */\nUtf8DecodeWorker.prototype.flush = function () {\n if(this.leftOver && this.leftOver.length) {\n this.push({\n data : exports.utf8decode(this.leftOver),\n meta : {}\n });\n this.leftOver = null;\n }\n};\nexports.Utf8DecodeWorker = Utf8DecodeWorker;\n\n/**\n * A worker to endcode string chunks into utf8 encoded binary chunks.\n * @constructor\n */\nfunction Utf8EncodeWorker() {\n GenericWorker.call(this, \"utf-8 encode\");\n}\nutils.inherits(Utf8EncodeWorker, GenericWorker);\n\n/**\n * @see GenericWorker.processChunk\n */\nUtf8EncodeWorker.prototype.processChunk = function (chunk) {\n this.push({\n data : exports.utf8encode(chunk.data),\n meta : chunk.meta\n });\n};\nexports.Utf8EncodeWorker = Utf8EncodeWorker;\n\n},{\"./nodejsUtils\":14,\"./stream/GenericWorker\":28,\"./support\":30,\"./utils\":32}],32:[function(require,module,exports){\n\"use strict\";\n\nvar support = require(\"./support\");\nvar base64 = require(\"./base64\");\nvar nodejsUtils = require(\"./nodejsUtils\");\nvar external = require(\"./external\");\nrequire(\"setimmediate\");\n\n\n/**\n * Convert a string that pass as a \"binary string\": it should represent a byte\n * array but may have > 255 char codes. Be sure to take only the first byte\n * and returns the byte array.\n * @param {String} str the string to transform.\n * @return {Array|Uint8Array} the string in a binary format.\n */\nfunction string2binary(str) {\n var result = null;\n if (support.uint8array) {\n result = new Uint8Array(str.length);\n } else {\n result = new Array(str.length);\n }\n return stringToArrayLike(str, result);\n}\n\n/**\n * Create a new blob with the given content and the given type.\n * @param {String|ArrayBuffer} part the content to put in the blob. DO NOT use\n * an Uint8Array because the stock browser of android 4 won't accept it (it\n * will be silently converted to a string, \"[object Uint8Array]\").\n *\n * Use only ONE part to build the blob to avoid a memory leak in IE11 / Edge:\n * when a large amount of Array is used to create the Blob, the amount of\n * memory consumed is nearly 100 times the original data amount.\n *\n * @param {String} type the mime type of the blob.\n * @return {Blob} the created blob.\n */\nexports.newBlob = function(part, type) {\n exports.checkSupport(\"blob\");\n\n try {\n // Blob constructor\n return new Blob([part], {\n type: type\n });\n }\n catch (e) {\n\n try {\n // deprecated, browser only, old way\n var Builder = self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder;\n var builder = new Builder();\n builder.append(part);\n return builder.getBlob(type);\n }\n catch (e) {\n\n // well, fuck ?!\n throw new Error(\"Bug : can't construct the Blob.\");\n }\n }\n\n\n};\n/**\n * The identity function.\n * @param {Object} input the input.\n * @return {Object} the same input.\n */\nfunction identity(input) {\n return input;\n}\n\n/**\n * Fill in an array with a string.\n * @param {String} str the string to use.\n * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to fill in (will be mutated).\n * @return {Array|ArrayBuffer|Uint8Array|Buffer} the updated array.\n */\nfunction stringToArrayLike(str, array) {\n for (var i = 0; i < str.length; ++i) {\n array[i] = str.charCodeAt(i) & 0xFF;\n }\n return array;\n}\n\n/**\n * An helper for the function arrayLikeToString.\n * This contains static information and functions that\n * can be optimized by the browser JIT compiler.\n */\nvar arrayToStringHelper = {\n /**\n * Transform an array of int into a string, chunk by chunk.\n * See the performances notes on arrayLikeToString.\n * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.\n * @param {String} type the type of the array.\n * @param {Integer} chunk the chunk size.\n * @return {String} the resulting string.\n * @throws Error if the chunk is too big for the stack.\n */\n stringifyByChunk: function(array, type, chunk) {\n var result = [], k = 0, len = array.length;\n // shortcut\n if (len <= chunk) {\n return String.fromCharCode.apply(null, array);\n }\n while (k < len) {\n if (type === \"array\" || type === \"nodebuffer\") {\n result.push(String.fromCharCode.apply(null, array.slice(k, Math.min(k + chunk, len))));\n }\n else {\n result.push(String.fromCharCode.apply(null, array.subarray(k, Math.min(k + chunk, len))));\n }\n k += chunk;\n }\n return result.join(\"\");\n },\n /**\n * Call String.fromCharCode on every item in the array.\n * This is the naive implementation, which generate A LOT of intermediate string.\n * This should be used when everything else fail.\n * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.\n * @return {String} the result.\n */\n stringifyByChar: function(array){\n var resultStr = \"\";\n for(var i = 0; i < array.length; i++) {\n resultStr += String.fromCharCode(array[i]);\n }\n return resultStr;\n },\n applyCanBeUsed : {\n /**\n * true if the browser accepts to use String.fromCharCode on Uint8Array\n */\n uint8array : (function () {\n try {\n return support.uint8array && String.fromCharCode.apply(null, new Uint8Array(1)).length === 1;\n } catch (e) {\n return false;\n }\n })(),\n /**\n * true if the browser accepts to use String.fromCharCode on nodejs Buffer.\n */\n nodebuffer : (function () {\n try {\n return support.nodebuffer && String.fromCharCode.apply(null, nodejsUtils.allocBuffer(1)).length === 1;\n } catch (e) {\n return false;\n }\n })()\n }\n};\n\n/**\n * Transform an array-like object to a string.\n * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.\n * @return {String} the result.\n */\nfunction arrayLikeToString(array) {\n // Performances notes :\n // --------------------\n // String.fromCharCode.apply(null, array) is the fastest, see\n // see http://jsperf.com/converting-a-uint8array-to-a-string/2\n // but the stack is limited (and we can get huge arrays !).\n //\n // result += String.fromCharCode(array[i]); generate too many strings !\n //\n // This code is inspired by http://jsperf.com/arraybuffer-to-string-apply-performance/2\n // TODO : we now have workers that split the work. Do we still need that ?\n var chunk = 65536,\n type = exports.getTypeOf(array),\n canUseApply = true;\n if (type === \"uint8array\") {\n canUseApply = arrayToStringHelper.applyCanBeUsed.uint8array;\n } else if (type === \"nodebuffer\") {\n canUseApply = arrayToStringHelper.applyCanBeUsed.nodebuffer;\n }\n\n if (canUseApply) {\n while (chunk > 1) {\n try {\n return arrayToStringHelper.stringifyByChunk(array, type, chunk);\n } catch (e) {\n chunk = Math.floor(chunk / 2);\n }\n }\n }\n\n // no apply or chunk error : slow and painful algorithm\n // default browser on android 4.*\n return arrayToStringHelper.stringifyByChar(array);\n}\n\nexports.applyFromCharCode = arrayLikeToString;\n\n\n/**\n * Copy the data from an array-like to an other array-like.\n * @param {Array|ArrayBuffer|Uint8Array|Buffer} arrayFrom the origin array.\n * @param {Array|ArrayBuffer|Uint8Array|Buffer} arrayTo the destination array which will be mutated.\n * @return {Array|ArrayBuffer|Uint8Array|Buffer} the updated destination array.\n */\nfunction arrayLikeToArrayLike(arrayFrom, arrayTo) {\n for (var i = 0; i < arrayFrom.length; i++) {\n arrayTo[i] = arrayFrom[i];\n }\n return arrayTo;\n}\n\n// a matrix containing functions to transform everything into everything.\nvar transform = {};\n\n// string to ?\ntransform[\"string\"] = {\n \"string\": identity,\n \"array\": function(input) {\n return stringToArrayLike(input, new Array(input.length));\n },\n \"arraybuffer\": function(input) {\n return transform[\"string\"][\"uint8array\"](input).buffer;\n },\n \"uint8array\": function(input) {\n return stringToArrayLike(input, new Uint8Array(input.length));\n },\n \"nodebuffer\": function(input) {\n return stringToArrayLike(input, nodejsUtils.allocBuffer(input.length));\n }\n};\n\n// array to ?\ntransform[\"array\"] = {\n \"string\": arrayLikeToString,\n \"array\": identity,\n \"arraybuffer\": function(input) {\n return (new Uint8Array(input)).buffer;\n },\n \"uint8array\": function(input) {\n return new Uint8Array(input);\n },\n \"nodebuffer\": function(input) {\n return nodejsUtils.newBufferFrom(input);\n }\n};\n\n// arraybuffer to ?\ntransform[\"arraybuffer\"] = {\n \"string\": function(input) {\n return arrayLikeToString(new Uint8Array(input));\n },\n \"array\": function(input) {\n return arrayLikeToArrayLike(new Uint8Array(input), new Array(input.byteLength));\n },\n \"arraybuffer\": identity,\n \"uint8array\": function(input) {\n return new Uint8Array(input);\n },\n \"nodebuffer\": function(input) {\n return nodejsUtils.newBufferFrom(new Uint8Array(input));\n }\n};\n\n// uint8array to ?\ntransform[\"uint8array\"] = {\n \"string\": arrayLikeToString,\n \"array\": function(input) {\n return arrayLikeToArrayLike(input, new Array(input.length));\n },\n \"arraybuffer\": function(input) {\n return input.buffer;\n },\n \"uint8array\": identity,\n \"nodebuffer\": function(input) {\n return nodejsUtils.newBufferFrom(input);\n }\n};\n\n// nodebuffer to ?\ntransform[\"nodebuffer\"] = {\n \"string\": arrayLikeToString,\n \"array\": function(input) {\n return arrayLikeToArrayLike(input, new Array(input.length));\n },\n \"arraybuffer\": function(input) {\n return transform[\"nodebuffer\"][\"uint8array\"](input).buffer;\n },\n \"uint8array\": function(input) {\n return arrayLikeToArrayLike(input, new Uint8Array(input.length));\n },\n \"nodebuffer\": identity\n};\n\n/**\n * Transform an input into any type.\n * The supported output type are : string, array, uint8array, arraybuffer, nodebuffer.\n * If no output type is specified, the unmodified input will be returned.\n * @param {String} outputType the output type.\n * @param {String|Array|ArrayBuffer|Uint8Array|Buffer} input the input to convert.\n * @throws {Error} an Error if the browser doesn't support the requested output type.\n */\nexports.transformTo = function(outputType, input) {\n if (!input) {\n // undefined, null, etc\n // an empty string won't harm.\n input = \"\";\n }\n if (!outputType) {\n return input;\n }\n exports.checkSupport(outputType);\n var inputType = exports.getTypeOf(input);\n var result = transform[inputType][outputType](input);\n return result;\n};\n\n/**\n * Resolve all relative path components, \".\" and \"..\", in a path. If these relative components\n * traverse above the root then the resulting path will only contain the final path component.\n *\n * All empty components, e.g. \"//\", are removed.\n * @param {string} path A path with / or \\ separators\n * @returns {string} The path with all relative path components resolved.\n */\nexports.resolve = function(path) {\n var parts = path.split(\"/\");\n var result = [];\n for (var index = 0; index < parts.length; index++) {\n var part = parts[index];\n // Allow the first and last component to be empty for trailing slashes.\n if (part === \".\" || (part === \"\" && index !== 0 && index !== parts.length - 1)) {\n continue;\n } else if (part === \"..\") {\n result.pop();\n } else {\n result.push(part);\n }\n }\n return result.join(\"/\");\n};\n\n/**\n * Return the type of the input.\n * The type will be in a format valid for JSZip.utils.transformTo : string, array, uint8array, arraybuffer.\n * @param {Object} input the input to identify.\n * @return {String} the (lowercase) type of the input.\n */\nexports.getTypeOf = function(input) {\n if (typeof input === \"string\") {\n return \"string\";\n }\n if (Object.prototype.toString.call(input) === \"[object Array]\") {\n return \"array\";\n }\n if (support.nodebuffer && nodejsUtils.isBuffer(input)) {\n return \"nodebuffer\";\n }\n if (support.uint8array && input instanceof Uint8Array) {\n return \"uint8array\";\n }\n if (support.arraybuffer && input instanceof ArrayBuffer) {\n return \"arraybuffer\";\n }\n};\n\n/**\n * Throw an exception if the type is not supported.\n * @param {String} type the type to check.\n * @throws {Error} an Error if the browser doesn't support the requested type.\n */\nexports.checkSupport = function(type) {\n var supported = support[type.toLowerCase()];\n if (!supported) {\n throw new Error(type + \" is not supported by this platform\");\n }\n};\n\nexports.MAX_VALUE_16BITS = 65535;\nexports.MAX_VALUE_32BITS = -1; // well, \"\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\" is parsed as -1\n\n/**\n * Prettify a string read as binary.\n * @param {string} str the string to prettify.\n * @return {string} a pretty string.\n */\nexports.pretty = function(str) {\n var res = \"\",\n code, i;\n for (i = 0; i < (str || \"\").length; i++) {\n code = str.charCodeAt(i);\n res += \"\\\\x\" + (code < 16 ? \"0\" : \"\") + code.toString(16).toUpperCase();\n }\n return res;\n};\n\n/**\n * Defer the call of a function.\n * @param {Function} callback the function to call asynchronously.\n * @param {Array} args the arguments to give to the callback.\n */\nexports.delay = function(callback, args, self) {\n setImmediate(function () {\n callback.apply(self || null, args || []);\n });\n};\n\n/**\n * Extends a prototype with an other, without calling a constructor with\n * side effects. Inspired by nodejs' `utils.inherits`\n * @param {Function} ctor the constructor to augment\n * @param {Function} superCtor the parent constructor to use\n */\nexports.inherits = function (ctor, superCtor) {\n var Obj = function() {};\n Obj.prototype = superCtor.prototype;\n ctor.prototype = new Obj();\n};\n\n/**\n * Merge the objects passed as parameters into a new one.\n * @private\n * @param {...Object} var_args All objects to merge.\n * @return {Object} a new object with the data of the others.\n */\nexports.extend = function() {\n var result = {}, i, attr;\n for (i = 0; i < arguments.length; i++) { // arguments is not enumerable in some browsers\n for (attr in arguments[i]) {\n if (Object.prototype.hasOwnProperty.call(arguments[i], attr) && typeof result[attr] === \"undefined\") {\n result[attr] = arguments[i][attr];\n }\n }\n }\n return result;\n};\n\n/**\n * Transform arbitrary content into a Promise.\n * @param {String} name a name for the content being processed.\n * @param {Object} inputData the content to process.\n * @param {Boolean} isBinary true if the content is not an unicode string\n * @param {Boolean} isOptimizedBinaryString true if the string content only has one byte per character.\n * @param {Boolean} isBase64 true if the string content is encoded with base64.\n * @return {Promise} a promise in a format usable by JSZip.\n */\nexports.prepareContent = function(name, inputData, isBinary, isOptimizedBinaryString, isBase64) {\n\n // if inputData is already a promise, this flatten it.\n var promise = external.Promise.resolve(inputData).then(function(data) {\n\n\n var isBlob = support.blob && (data instanceof Blob || [\"[object File]\", \"[object Blob]\"].indexOf(Object.prototype.toString.call(data)) !== -1);\n\n if (isBlob && typeof FileReader !== \"undefined\") {\n return new external.Promise(function (resolve, reject) {\n var reader = new FileReader();\n\n reader.onload = function(e) {\n resolve(e.target.result);\n };\n reader.onerror = function(e) {\n reject(e.target.error);\n };\n reader.readAsArrayBuffer(data);\n });\n } else {\n return data;\n }\n });\n\n return promise.then(function(data) {\n var dataType = exports.getTypeOf(data);\n\n if (!dataType) {\n return external.Promise.reject(\n new Error(\"Can't read the data of '\" + name + \"'. Is it \" +\n \"in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?\")\n );\n }\n // special case : it's way easier to work with Uint8Array than with ArrayBuffer\n if (dataType === \"arraybuffer\") {\n data = exports.transformTo(\"uint8array\", data);\n } else if (dataType === \"string\") {\n if (isBase64) {\n data = base64.decode(data);\n }\n else if (isBinary) {\n // optimizedBinaryString === true means that the file has already been filtered with a 0xFF mask\n if (isOptimizedBinaryString !== true) {\n // this is a string, not in a base64 format.\n // Be sure that this is a correct \"binary string\"\n data = string2binary(data);\n }\n }\n }\n return data;\n });\n};\n\n},{\"./base64\":1,\"./external\":6,\"./nodejsUtils\":14,\"./support\":30,\"setimmediate\":54}],33:[function(require,module,exports){\n\"use strict\";\nvar readerFor = require(\"./reader/readerFor\");\nvar utils = require(\"./utils\");\nvar sig = require(\"./signature\");\nvar ZipEntry = require(\"./zipEntry\");\nvar support = require(\"./support\");\n// class ZipEntries {{{\n/**\n * All the entries in the zip file.\n * @constructor\n * @param {Object} loadOptions Options for loading the stream.\n */\nfunction ZipEntries(loadOptions) {\n this.files = [];\n this.loadOptions = loadOptions;\n}\nZipEntries.prototype = {\n /**\n * Check that the reader is on the specified signature.\n * @param {string} expectedSignature the expected signature.\n * @throws {Error} if it is an other signature.\n */\n checkSignature: function(expectedSignature) {\n if (!this.reader.readAndCheckSignature(expectedSignature)) {\n this.reader.index -= 4;\n var signature = this.reader.readString(4);\n throw new Error(\"Corrupted zip or bug: unexpected signature \" + \"(\" + utils.pretty(signature) + \", expected \" + utils.pretty(expectedSignature) + \")\");\n }\n },\n /**\n * Check if the given signature is at the given index.\n * @param {number} askedIndex the index to check.\n * @param {string} expectedSignature the signature to expect.\n * @return {boolean} true if the signature is here, false otherwise.\n */\n isSignature: function(askedIndex, expectedSignature) {\n var currentIndex = this.reader.index;\n this.reader.setIndex(askedIndex);\n var signature = this.reader.readString(4);\n var result = signature === expectedSignature;\n this.reader.setIndex(currentIndex);\n return result;\n },\n /**\n * Read the end of the central directory.\n */\n readBlockEndOfCentral: function() {\n this.diskNumber = this.reader.readInt(2);\n this.diskWithCentralDirStart = this.reader.readInt(2);\n this.centralDirRecordsOnThisDisk = this.reader.readInt(2);\n this.centralDirRecords = this.reader.readInt(2);\n this.centralDirSize = this.reader.readInt(4);\n this.centralDirOffset = this.reader.readInt(4);\n\n this.zipCommentLength = this.reader.readInt(2);\n // warning : the encoding depends of the system locale\n // On a linux machine with LANG=en_US.utf8, this field is utf8 encoded.\n // On a windows machine, this field is encoded with the localized windows code page.\n var zipComment = this.reader.readData(this.zipCommentLength);\n var decodeParamType = support.uint8array ? \"uint8array\" : \"array\";\n // To get consistent behavior with the generation part, we will assume that\n // this is utf8 encoded unless specified otherwise.\n var decodeContent = utils.transformTo(decodeParamType, zipComment);\n this.zipComment = this.loadOptions.decodeFileName(decodeContent);\n },\n /**\n * Read the end of the Zip 64 central directory.\n * Not merged with the method readEndOfCentral :\n * The end of central can coexist with its Zip64 brother,\n * I don't want to read the wrong number of bytes !\n */\n readBlockZip64EndOfCentral: function() {\n this.zip64EndOfCentralSize = this.reader.readInt(8);\n this.reader.skip(4);\n // this.versionMadeBy = this.reader.readString(2);\n // this.versionNeeded = this.reader.readInt(2);\n this.diskNumber = this.reader.readInt(4);\n this.diskWithCentralDirStart = this.reader.readInt(4);\n this.centralDirRecordsOnThisDisk = this.reader.readInt(8);\n this.centralDirRecords = this.reader.readInt(8);\n this.centralDirSize = this.reader.readInt(8);\n this.centralDirOffset = this.reader.readInt(8);\n\n this.zip64ExtensibleData = {};\n var extraDataSize = this.zip64EndOfCentralSize - 44,\n index = 0,\n extraFieldId,\n extraFieldLength,\n extraFieldValue;\n while (index < extraDataSize) {\n extraFieldId = this.reader.readInt(2);\n extraFieldLength = this.reader.readInt(4);\n extraFieldValue = this.reader.readData(extraFieldLength);\n this.zip64ExtensibleData[extraFieldId] = {\n id: extraFieldId,\n length: extraFieldLength,\n value: extraFieldValue\n };\n }\n },\n /**\n * Read the end of the Zip 64 central directory locator.\n */\n readBlockZip64EndOfCentralLocator: function() {\n this.diskWithZip64CentralDirStart = this.reader.readInt(4);\n this.relativeOffsetEndOfZip64CentralDir = this.reader.readInt(8);\n this.disksCount = this.reader.readInt(4);\n if (this.disksCount > 1) {\n throw new Error(\"Multi-volumes zip are not supported\");\n }\n },\n /**\n * Read the local files, based on the offset read in the central part.\n */\n readLocalFiles: function() {\n var i, file;\n for (i = 0; i < this.files.length; i++) {\n file = this.files[i];\n this.reader.setIndex(file.localHeaderOffset);\n this.checkSignature(sig.LOCAL_FILE_HEADER);\n file.readLocalPart(this.reader);\n file.handleUTF8();\n file.processAttributes();\n }\n },\n /**\n * Read the central directory.\n */\n readCentralDir: function() {\n var file;\n\n this.reader.setIndex(this.centralDirOffset);\n while (this.reader.readAndCheckSignature(sig.CENTRAL_FILE_HEADER)) {\n file = new ZipEntry({\n zip64: this.zip64\n }, this.loadOptions);\n file.readCentralPart(this.reader);\n this.files.push(file);\n }\n\n if (this.centralDirRecords !== this.files.length) {\n if (this.centralDirRecords !== 0 && this.files.length === 0) {\n // We expected some records but couldn't find ANY.\n // This is really suspicious, as if something went wrong.\n throw new Error(\"Corrupted zip or bug: expected \" + this.centralDirRecords + \" records in central dir, got \" + this.files.length);\n } else {\n // We found some records but not all.\n // Something is wrong but we got something for the user: no error here.\n // console.warn(\"expected\", this.centralDirRecords, \"records in central dir, got\", this.files.length);\n }\n }\n },\n /**\n * Read the end of central directory.\n */\n readEndOfCentral: function() {\n var offset = this.reader.lastIndexOfSignature(sig.CENTRAL_DIRECTORY_END);\n if (offset < 0) {\n // Check if the content is a truncated zip or complete garbage.\n // A \"LOCAL_FILE_HEADER\" is not required at the beginning (auto\n // extractible zip for example) but it can give a good hint.\n // If an ajax request was used without responseType, we will also\n // get unreadable data.\n var isGarbage = !this.isSignature(0, sig.LOCAL_FILE_HEADER);\n\n if (isGarbage) {\n throw new Error(\"Can't find end of central directory : is this a zip file ? \" +\n \"If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html\");\n } else {\n throw new Error(\"Corrupted zip: can't find end of central directory\");\n }\n\n }\n this.reader.setIndex(offset);\n var endOfCentralDirOffset = offset;\n this.checkSignature(sig.CENTRAL_DIRECTORY_END);\n this.readBlockEndOfCentral();\n\n\n /* extract from the zip spec :\n 4) If one of the fields in the end of central directory\n record is too small to hold required data, the field\n should be set to -1 (0xFFFF or 0xFFFFFFFF) and the\n ZIP64 format record should be created.\n 5) The end of central directory record and the\n Zip64 end of central directory locator record must\n reside on the same disk when splitting or spanning\n an archive.\n */\n if (this.diskNumber === utils.MAX_VALUE_16BITS || this.diskWithCentralDirStart === utils.MAX_VALUE_16BITS || this.centralDirRecordsOnThisDisk === utils.MAX_VALUE_16BITS || this.centralDirRecords === utils.MAX_VALUE_16BITS || this.centralDirSize === utils.MAX_VALUE_32BITS || this.centralDirOffset === utils.MAX_VALUE_32BITS) {\n this.zip64 = true;\n\n /*\n Warning : the zip64 extension is supported, but ONLY if the 64bits integer read from\n the zip file can fit into a 32bits integer. This cannot be solved : JavaScript represents\n all numbers as 64-bit double precision IEEE 754 floating point numbers.\n So, we have 53bits for integers and bitwise operations treat everything as 32bits.\n see https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/Bitwise_Operators\n and http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf section 8.5\n */\n\n // should look for a zip64 EOCD locator\n offset = this.reader.lastIndexOfSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR);\n if (offset < 0) {\n throw new Error(\"Corrupted zip: can't find the ZIP64 end of central directory locator\");\n }\n this.reader.setIndex(offset);\n this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR);\n this.readBlockZip64EndOfCentralLocator();\n\n // now the zip64 EOCD record\n if (!this.isSignature(this.relativeOffsetEndOfZip64CentralDir, sig.ZIP64_CENTRAL_DIRECTORY_END)) {\n // console.warn(\"ZIP64 end of central directory not where expected.\");\n this.relativeOffsetEndOfZip64CentralDir = this.reader.lastIndexOfSignature(sig.ZIP64_CENTRAL_DIRECTORY_END);\n if (this.relativeOffsetEndOfZip64CentralDir < 0) {\n throw new Error(\"Corrupted zip: can't find the ZIP64 end of central directory\");\n }\n }\n this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir);\n this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_END);\n this.readBlockZip64EndOfCentral();\n }\n\n var expectedEndOfCentralDirOffset = this.centralDirOffset + this.centralDirSize;\n if (this.zip64) {\n expectedEndOfCentralDirOffset += 20; // end of central dir 64 locator\n expectedEndOfCentralDirOffset += 12 /* should not include the leading 12 bytes */ + this.zip64EndOfCentralSize;\n }\n\n var extraBytes = endOfCentralDirOffset - expectedEndOfCentralDirOffset;\n\n if (extraBytes > 0) {\n // console.warn(extraBytes, \"extra bytes at beginning or within zipfile\");\n if (this.isSignature(endOfCentralDirOffset, sig.CENTRAL_FILE_HEADER)) {\n // The offsets seem wrong, but we have something at the specified offset.\n // So… we keep it.\n } else {\n // the offset is wrong, update the \"zero\" of the reader\n // this happens if data has been prepended (crx files for example)\n this.reader.zero = extraBytes;\n }\n } else if (extraBytes < 0) {\n throw new Error(\"Corrupted zip: missing \" + Math.abs(extraBytes) + \" bytes.\");\n }\n },\n prepareReader: function(data) {\n this.reader = readerFor(data);\n },\n /**\n * Read a zip file and create ZipEntries.\n * @param {String|ArrayBuffer|Uint8Array|Buffer} data the binary string representing a zip file.\n */\n load: function(data) {\n this.prepareReader(data);\n this.readEndOfCentral();\n this.readCentralDir();\n this.readLocalFiles();\n }\n};\n// }}} end of ZipEntries\nmodule.exports = ZipEntries;\n\n},{\"./reader/readerFor\":22,\"./signature\":23,\"./support\":30,\"./utils\":32,\"./zipEntry\":34}],34:[function(require,module,exports){\n\"use strict\";\nvar readerFor = require(\"./reader/readerFor\");\nvar utils = require(\"./utils\");\nvar CompressedObject = require(\"./compressedObject\");\nvar crc32fn = require(\"./crc32\");\nvar utf8 = require(\"./utf8\");\nvar compressions = require(\"./compressions\");\nvar support = require(\"./support\");\n\nvar MADE_BY_DOS = 0x00;\nvar MADE_BY_UNIX = 0x03;\n\n/**\n * Find a compression registered in JSZip.\n * @param {string} compressionMethod the method magic to find.\n * @return {Object|null} the JSZip compression object, null if none found.\n */\nvar findCompression = function(compressionMethod) {\n for (var method in compressions) {\n if (!Object.prototype.hasOwnProperty.call(compressions, method)) {\n continue;\n }\n if (compressions[method].magic === compressionMethod) {\n return compressions[method];\n }\n }\n return null;\n};\n\n// class ZipEntry {{{\n/**\n * An entry in the zip file.\n * @constructor\n * @param {Object} options Options of the current file.\n * @param {Object} loadOptions Options for loading the stream.\n */\nfunction ZipEntry(options, loadOptions) {\n this.options = options;\n this.loadOptions = loadOptions;\n}\nZipEntry.prototype = {\n /**\n * say if the file is encrypted.\n * @return {boolean} true if the file is encrypted, false otherwise.\n */\n isEncrypted: function() {\n // bit 1 is set\n return (this.bitFlag & 0x0001) === 0x0001;\n },\n /**\n * say if the file has utf-8 filename/comment.\n * @return {boolean} true if the filename/comment is in utf-8, false otherwise.\n */\n useUTF8: function() {\n // bit 11 is set\n return (this.bitFlag & 0x0800) === 0x0800;\n },\n /**\n * Read the local part of a zip file and add the info in this object.\n * @param {DataReader} reader the reader to use.\n */\n readLocalPart: function(reader) {\n var compression, localExtraFieldsLength;\n\n // we already know everything from the central dir !\n // If the central dir data are false, we are doomed.\n // On the bright side, the local part is scary : zip64, data descriptors, both, etc.\n // The less data we get here, the more reliable this should be.\n // Let's skip the whole header and dash to the data !\n reader.skip(22);\n // in some zip created on windows, the filename stored in the central dir contains \\ instead of /.\n // Strangely, the filename here is OK.\n // I would love to treat these zip files as corrupted (see http://www.info-zip.org/FAQ.html#backslashes\n // or APPNOTE#4.4.17.1, \"All slashes MUST be forward slashes '/'\") but there are a lot of bad zip generators...\n // Search \"unzip mismatching \"local\" filename continuing with \"central\" filename version\" on\n // the internet.\n //\n // I think I see the logic here : the central directory is used to display\n // content and the local directory is used to extract the files. Mixing / and \\\n // may be used to display \\ to windows users and use / when extracting the files.\n // Unfortunately, this lead also to some issues : http://seclists.org/fulldisclosure/2009/Sep/394\n this.fileNameLength = reader.readInt(2);\n localExtraFieldsLength = reader.readInt(2); // can't be sure this will be the same as the central dir\n // the fileName is stored as binary data, the handleUTF8 method will take care of the encoding.\n this.fileName = reader.readData(this.fileNameLength);\n reader.skip(localExtraFieldsLength);\n\n if (this.compressedSize === -1 || this.uncompressedSize === -1) {\n throw new Error(\"Bug or corrupted zip : didn't get enough information from the central directory \" + \"(compressedSize === -1 || uncompressedSize === -1)\");\n }\n\n compression = findCompression(this.compressionMethod);\n if (compression === null) { // no compression found\n throw new Error(\"Corrupted zip : compression \" + utils.pretty(this.compressionMethod) + \" unknown (inner file : \" + utils.transformTo(\"string\", this.fileName) + \")\");\n }\n this.decompressed = new CompressedObject(this.compressedSize, this.uncompressedSize, this.crc32, compression, reader.readData(this.compressedSize));\n },\n\n /**\n * Read the central part of a zip file and add the info in this object.\n * @param {DataReader} reader the reader to use.\n */\n readCentralPart: function(reader) {\n this.versionMadeBy = reader.readInt(2);\n reader.skip(2);\n // this.versionNeeded = reader.readInt(2);\n this.bitFlag = reader.readInt(2);\n this.compressionMethod = reader.readString(2);\n this.date = reader.readDate();\n this.crc32 = reader.readInt(4);\n this.compressedSize = reader.readInt(4);\n this.uncompressedSize = reader.readInt(4);\n var fileNameLength = reader.readInt(2);\n this.extraFieldsLength = reader.readInt(2);\n this.fileCommentLength = reader.readInt(2);\n this.diskNumberStart = reader.readInt(2);\n this.internalFileAttributes = reader.readInt(2);\n this.externalFileAttributes = reader.readInt(4);\n this.localHeaderOffset = reader.readInt(4);\n\n if (this.isEncrypted()) {\n throw new Error(\"Encrypted zip are not supported\");\n }\n\n // will be read in the local part, see the comments there\n reader.skip(fileNameLength);\n this.readExtraFields(reader);\n this.parseZIP64ExtraField(reader);\n this.fileComment = reader.readData(this.fileCommentLength);\n },\n\n /**\n * Parse the external file attributes and get the unix/dos permissions.\n */\n processAttributes: function () {\n this.unixPermissions = null;\n this.dosPermissions = null;\n var madeBy = this.versionMadeBy >> 8;\n\n // Check if we have the DOS directory flag set.\n // We look for it in the DOS and UNIX permissions\n // but some unknown platform could set it as a compatibility flag.\n this.dir = this.externalFileAttributes & 0x0010 ? true : false;\n\n if(madeBy === MADE_BY_DOS) {\n // first 6 bits (0 to 5)\n this.dosPermissions = this.externalFileAttributes & 0x3F;\n }\n\n if(madeBy === MADE_BY_UNIX) {\n this.unixPermissions = (this.externalFileAttributes >> 16) & 0xFFFF;\n // the octal permissions are in (this.unixPermissions & 0x01FF).toString(8);\n }\n\n // fail safe : if the name ends with a / it probably means a folder\n if (!this.dir && this.fileNameStr.slice(-1) === \"/\") {\n this.dir = true;\n }\n },\n\n /**\n * Parse the ZIP64 extra field and merge the info in the current ZipEntry.\n * @param {DataReader} reader the reader to use.\n */\n parseZIP64ExtraField: function() {\n if (!this.extraFields[0x0001]) {\n return;\n }\n\n // should be something, preparing the extra reader\n var extraReader = readerFor(this.extraFields[0x0001].value);\n\n // I really hope that these 64bits integer can fit in 32 bits integer, because js\n // won't let us have more.\n if (this.uncompressedSize === utils.MAX_VALUE_32BITS) {\n this.uncompressedSize = extraReader.readInt(8);\n }\n if (this.compressedSize === utils.MAX_VALUE_32BITS) {\n this.compressedSize = extraReader.readInt(8);\n }\n if (this.localHeaderOffset === utils.MAX_VALUE_32BITS) {\n this.localHeaderOffset = extraReader.readInt(8);\n }\n if (this.diskNumberStart === utils.MAX_VALUE_32BITS) {\n this.diskNumberStart = extraReader.readInt(4);\n }\n },\n /**\n * Read the central part of a zip file and add the info in this object.\n * @param {DataReader} reader the reader to use.\n */\n readExtraFields: function(reader) {\n var end = reader.index + this.extraFieldsLength,\n extraFieldId,\n extraFieldLength,\n extraFieldValue;\n\n if (!this.extraFields) {\n this.extraFields = {};\n }\n\n while (reader.index + 4 < end) {\n extraFieldId = reader.readInt(2);\n extraFieldLength = reader.readInt(2);\n extraFieldValue = reader.readData(extraFieldLength);\n\n this.extraFields[extraFieldId] = {\n id: extraFieldId,\n length: extraFieldLength,\n value: extraFieldValue\n };\n }\n\n reader.setIndex(end);\n },\n /**\n * Apply an UTF8 transformation if needed.\n */\n handleUTF8: function() {\n var decodeParamType = support.uint8array ? \"uint8array\" : \"array\";\n if (this.useUTF8()) {\n this.fileNameStr = utf8.utf8decode(this.fileName);\n this.fileCommentStr = utf8.utf8decode(this.fileComment);\n } else {\n var upath = this.findExtraFieldUnicodePath();\n if (upath !== null) {\n this.fileNameStr = upath;\n } else {\n // ASCII text or unsupported code page\n var fileNameByteArray = utils.transformTo(decodeParamType, this.fileName);\n this.fileNameStr = this.loadOptions.decodeFileName(fileNameByteArray);\n }\n\n var ucomment = this.findExtraFieldUnicodeComment();\n if (ucomment !== null) {\n this.fileCommentStr = ucomment;\n } else {\n // ASCII text or unsupported code page\n var commentByteArray = utils.transformTo(decodeParamType, this.fileComment);\n this.fileCommentStr = this.loadOptions.decodeFileName(commentByteArray);\n }\n }\n },\n\n /**\n * Find the unicode path declared in the extra field, if any.\n * @return {String} the unicode path, null otherwise.\n */\n findExtraFieldUnicodePath: function() {\n var upathField = this.extraFields[0x7075];\n if (upathField) {\n var extraReader = readerFor(upathField.value);\n\n // wrong version\n if (extraReader.readInt(1) !== 1) {\n return null;\n }\n\n // the crc of the filename changed, this field is out of date.\n if (crc32fn(this.fileName) !== extraReader.readInt(4)) {\n return null;\n }\n\n return utf8.utf8decode(extraReader.readData(upathField.length - 5));\n }\n return null;\n },\n\n /**\n * Find the unicode comment declared in the extra field, if any.\n * @return {String} the unicode comment, null otherwise.\n */\n findExtraFieldUnicodeComment: function() {\n var ucommentField = this.extraFields[0x6375];\n if (ucommentField) {\n var extraReader = readerFor(ucommentField.value);\n\n // wrong version\n if (extraReader.readInt(1) !== 1) {\n return null;\n }\n\n // the crc of the comment changed, this field is out of date.\n if (crc32fn(this.fileComment) !== extraReader.readInt(4)) {\n return null;\n }\n\n return utf8.utf8decode(extraReader.readData(ucommentField.length - 5));\n }\n return null;\n }\n};\nmodule.exports = ZipEntry;\n\n},{\"./compressedObject\":2,\"./compressions\":3,\"./crc32\":4,\"./reader/readerFor\":22,\"./support\":30,\"./utf8\":31,\"./utils\":32}],35:[function(require,module,exports){\n\"use strict\";\n\nvar StreamHelper = require(\"./stream/StreamHelper\");\nvar DataWorker = require(\"./stream/DataWorker\");\nvar utf8 = require(\"./utf8\");\nvar CompressedObject = require(\"./compressedObject\");\nvar GenericWorker = require(\"./stream/GenericWorker\");\n\n/**\n * A simple object representing a file in the zip file.\n * @constructor\n * @param {string} name the name of the file\n * @param {String|ArrayBuffer|Uint8Array|Buffer} data the data\n * @param {Object} options the options of the file\n */\nvar ZipObject = function(name, data, options) {\n this.name = name;\n this.dir = options.dir;\n this.date = options.date;\n this.comment = options.comment;\n this.unixPermissions = options.unixPermissions;\n this.dosPermissions = options.dosPermissions;\n\n this._data = data;\n this._dataBinary = options.binary;\n // keep only the compression\n this.options = {\n compression : options.compression,\n compressionOptions : options.compressionOptions\n };\n};\n\nZipObject.prototype = {\n /**\n * Create an internal stream for the content of this object.\n * @param {String} type the type of each chunk.\n * @return StreamHelper the stream.\n */\n internalStream: function (type) {\n var result = null, outputType = \"string\";\n try {\n if (!type) {\n throw new Error(\"No output type specified.\");\n }\n outputType = type.toLowerCase();\n var askUnicodeString = outputType === \"string\" || outputType === \"text\";\n if (outputType === \"binarystring\" || outputType === \"text\") {\n outputType = \"string\";\n }\n result = this._decompressWorker();\n\n var isUnicodeString = !this._dataBinary;\n\n if (isUnicodeString && !askUnicodeString) {\n result = result.pipe(new utf8.Utf8EncodeWorker());\n }\n if (!isUnicodeString && askUnicodeString) {\n result = result.pipe(new utf8.Utf8DecodeWorker());\n }\n } catch (e) {\n result = new GenericWorker(\"error\");\n result.error(e);\n }\n\n return new StreamHelper(result, outputType, \"\");\n },\n\n /**\n * Prepare the content in the asked type.\n * @param {String} type the type of the result.\n * @param {Function} onUpdate a function to call on each internal update.\n * @return Promise the promise of the result.\n */\n async: function (type, onUpdate) {\n return this.internalStream(type).accumulate(onUpdate);\n },\n\n /**\n * Prepare the content as a nodejs stream.\n * @param {String} type the type of each chunk.\n * @param {Function} onUpdate a function to call on each internal update.\n * @return Stream the stream.\n */\n nodeStream: function (type, onUpdate) {\n return this.internalStream(type || \"nodebuffer\").toNodejsStream(onUpdate);\n },\n\n /**\n * Return a worker for the compressed content.\n * @private\n * @param {Object} compression the compression object to use.\n * @param {Object} compressionOptions the options to use when compressing.\n * @return Worker the worker.\n */\n _compressWorker: function (compression, compressionOptions) {\n if (\n this._data instanceof CompressedObject &&\n this._data.compression.magic === compression.magic\n ) {\n return this._data.getCompressedWorker();\n } else {\n var result = this._decompressWorker();\n if(!this._dataBinary) {\n result = result.pipe(new utf8.Utf8EncodeWorker());\n }\n return CompressedObject.createWorkerFrom(result, compression, compressionOptions);\n }\n },\n /**\n * Return a worker for the decompressed content.\n * @private\n * @return Worker the worker.\n */\n _decompressWorker : function () {\n if (this._data instanceof CompressedObject) {\n return this._data.getContentWorker();\n } else if (this._data instanceof GenericWorker) {\n return this._data;\n } else {\n return new DataWorker(this._data);\n }\n }\n};\n\nvar removedMethods = [\"asText\", \"asBinary\", \"asNodeBuffer\", \"asUint8Array\", \"asArrayBuffer\"];\nvar removedFn = function () {\n throw new Error(\"This method has been removed in JSZip 3.0, please check the upgrade guide.\");\n};\n\nfor(var i = 0; i < removedMethods.length; i++) {\n ZipObject.prototype[removedMethods[i]] = removedFn;\n}\nmodule.exports = ZipObject;\n\n},{\"./compressedObject\":2,\"./stream/DataWorker\":27,\"./stream/GenericWorker\":28,\"./stream/StreamHelper\":29,\"./utf8\":31}],36:[function(require,module,exports){\n(function (global){\n'use strict';\nvar Mutation = global.MutationObserver || global.WebKitMutationObserver;\n\nvar scheduleDrain;\n\n{\n if (Mutation) {\n var called = 0;\n var observer = new Mutation(nextTick);\n var element = global.document.createTextNode('');\n observer.observe(element, {\n characterData: true\n });\n scheduleDrain = function () {\n element.data = (called = ++called % 2);\n };\n } else if (!global.setImmediate && typeof global.MessageChannel !== 'undefined') {\n var channel = new global.MessageChannel();\n channel.port1.onmessage = nextTick;\n scheduleDrain = function () {\n channel.port2.postMessage(0);\n };\n } else if ('document' in global && 'onreadystatechange' in global.document.createElement('script')) {\n scheduleDrain = function () {\n\n // Create a
-
-
-
+
+
+
+
+
+
+