!function(t){if(Date.now||(Date.now=function(){return(new Date).getTime()}),Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),Object.keys||(Object.keys=function(){var t=Object.prototype.hasOwnProperty,e=!{toString:null}.propertyIsEnumerable("toString"),n=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],r=n.length;return function(i){if("object"!=typeof i&&("function"!=typeof i||null===i))throw new TypeError("Object.keys called on non-object");var o,s,a=[];for(o in i)t.call(i,o)&&a.push(o);if(e)for(s=0;r>s;s++)t.call(i,n[s])&&a.push(n[s]);return a}}()),"b"!=="ab".substr(-1)&&(String.prototype.substr=function(t){return function(e,n){return 0>e&&(e=this.length+e),t.call(this,e,n)}}(String.prototype.substr)),Array.prototype.forEach||(Array.prototype.forEach=function(t,e){for(var n=0;n0)){var e=n.shift();return e()}};e.addEventListener?e.addEventListener("message",o,!0):e.attachEvent("onmessage",o)}else if(e.MessageChannel){var s=new e.MessageChannel;s.port1.onmessage=function(){return n.length>0?n.shift()():void 0},e.setImmediate=function(t){n.push(t),s.port2.postMessage("")}}else e.setImmediate=function(t){return setTimeout(t,0)}}Array.prototype.indexOf||(Array.prototype.indexOf=function(t,e){if(void 0===e&&(e=0),!this)throw new TypeError;var n=this.length;if(0===n||r>=n)return-1;var r=e;0>r&&(r=n+r);for(var i=r;n>i;i++)if(this[i]===t)return i;return-1}),Array.prototype.forEach||(Array.prototype.forEach=function(t,e){var n,r;for(n=0,r=this.length;r>n;++n)n in this&&t.call(e,this[n],n,this)}),Array.prototype.map||(Array.prototype.map=function(t,e){var n,r,i;if(null==this)throw new TypeError(" this is null or not defined");var o=Object(this),s=o.length>>>0;if("function"!=typeof t)throw new TypeError(t+" is not a function");for(e&&(n=e),r=new Array(s),i=0;s>i;){var a,u;i in o&&(a=o[i],u=t.call(n,a,i,o),r[i]=u),i++}return r}),"undefined"!=typeof document&&void 0===window.chrome&&document.write("\r\n\r\n");var a,u,c;!function(t){function e(t,e){return S.call(t,e)}function n(t,e){var n,r,i,o,s,a,u,c,f,h,p,l=e&&e.split("/"),y=m.map,d=y&&y["*"]||{};if(t&&"."===t.charAt(0))if(e){for(t=t.split("/"),s=t.length-1,m.nodeIdCompat&&E.test(t[s])&&(t[s]=t[s].replace(E,"")),t=l.slice(0,l.length-1).concat(t),f=0;f0&&(t.splice(f-1,2),f-=2)}t=t.join("/")}else 0===t.indexOf("./")&&(t=t.substring(2));if((l||d)&&y){for(n=t.split("/"),f=n.length;f>0;f-=1){if(r=n.slice(0,f).join("/"),l)for(h=l.length;h>0;h-=1)if(i=y[l.slice(0,h).join("/")],i&&(i=i[r])){o=i,a=f;break}if(o)break;!u&&d&&d[r]&&(u=d[r],c=f)}!o&&u&&(o=u,a=c),o&&(n.splice(0,a,o),t=n.join("/"))}return t}function r(e,n){return function(){var r=b.call(arguments,0);return"string"!=typeof r[0]&&1===r.length&&r.push(null),l.apply(t,r.concat([e,n]))}}function i(t){return function(e){return n(e,t)}}function o(t){return function(e){g[t]=e}}function s(n){if(e(w,n)){var r=w[n];delete w[n],v[n]=!0,p.apply(t,r)}if(!e(g,n)&&!e(v,n))throw new Error("No "+n);return g[n]}function f(t){var e,n=t?t.indexOf("!"):-1;return n>-1&&(e=t.substring(0,n),t=t.substring(n+1,t.length)),[e,t]}function h(t){return function(){return m&&m.config&&m.config[t]||{}}}var p,l,y,d,g={},w={},m={},v={},S=Object.prototype.hasOwnProperty,b=[].slice,E=/\.js$/;y=function(t,e){var r,o=f(t),a=o[0];return t=o[1],a&&(a=n(a,e),r=s(a)),a?t=r&&r.normalize?r.normalize(t,i(e)):n(t,e):(t=n(t,e),o=f(t),a=o[0],t=o[1],a&&(r=s(a))),{f:a?a+"!"+t:t,n:t,pr:a,p:r}},d={require:function(t){return r(t)},exports:function(t){var e=g[t];return"undefined"!=typeof e?e:g[t]={}},module:function(t){return{id:t,uri:"",exports:g[t],config:h(t)}}},p=function(n,i,a,u){var c,f,h,p,l,m,S=[],b=typeof a;if(u=u||n,"undefined"===b||"function"===b){for(i=!i.length&&a.length?["require","exports","module"]:i,l=0;l>>24)},t.prototype.writeInt16LE=function(t,e){this.writeUInt8(t,255&e),this.writeUInt8(t+1,e>>>8&255|(2147483648&e)>>>24)},t.prototype.writeInt16BE=function(t,e){this.writeUInt8(t+1,255&e),this.writeUInt8(t,e>>>8&255|(2147483648&e)>>>24)},t.prototype.writeInt32LE=function(t,e){this.writeUInt8(t,255&e),this.writeUInt8(t+1,e>>>8&255),this.writeUInt8(t+2,e>>>16&255),this.writeUInt8(t+3,e>>>24&255)},t.prototype.writeInt32BE=function(t,e){this.writeUInt8(t+3,255&e),this.writeUInt8(t+2,e>>>8&255),this.writeUInt8(t+1,e>>>16&255),this.writeUInt8(t,e>>>24&255)},t.prototype.writeUInt8=function(){throw new n.ApiError(14,"BufferCore implementations should implement writeUInt8.")},t.prototype.writeUInt16LE=function(t,e){this.writeUInt8(t,255&e),this.writeUInt8(t+1,e>>8&255)},t.prototype.writeUInt16BE=function(t,e){this.writeUInt8(t+1,255&e),this.writeUInt8(t,e>>8&255)},t.prototype.writeUInt32LE=function(t,e){this.writeInt32LE(t,0|e)},t.prototype.writeUInt32BE=function(t,e){this.writeInt32BE(t,0|e)},t.prototype.writeFloatLE=function(t,e){this.writeInt32LE(t,this.float2intbits(e))},t.prototype.writeFloatBE=function(t,e){this.writeInt32BE(t,this.float2intbits(e))},t.prototype.writeDoubleLE=function(t,e){var n=this.double2longbits(e);this.writeInt32LE(t,n[0]),this.writeInt32LE(t+4,n[1])},t.prototype.writeDoubleBE=function(t,e){var n=this.double2longbits(e);this.writeInt32BE(t+4,n[0]),this.writeInt32BE(t,n[1])},t.prototype.readInt8=function(t){var e=this.readUInt8(t);return 128&e?4294967168|e:e},t.prototype.readInt16LE=function(t){var e=this.readUInt16LE(t);return 32768&e?4294934528|e:e},t.prototype.readInt16BE=function(t){var e=this.readUInt16BE(t);return 32768&e?4294934528|e:e},t.prototype.readInt32LE=function(t){return 0|this.readUInt32LE(t)},t.prototype.readInt32BE=function(t){return 0|this.readUInt32BE(t)},t.prototype.readUInt8=function(){throw new n.ApiError(14,"BufferCore implementations should implement readUInt8.")},t.prototype.readUInt16LE=function(t){return this.readUInt8(t+1)<<8|this.readUInt8(t)},t.prototype.readUInt16BE=function(t){return this.readUInt8(t)<<8|this.readUInt8(t+1)},t.prototype.readUInt32LE=function(t){return(this.readUInt8(t+3)<<24|this.readUInt8(t+2)<<16|this.readUInt8(t+1)<<8|this.readUInt8(t))>>>0},t.prototype.readUInt32BE=function(t){return(this.readUInt8(t)<<24|this.readUInt8(t+1)<<16|this.readUInt8(t+2)<<8|this.readUInt8(t+3))>>>0},t.prototype.readFloatLE=function(t){return this.intbits2float(this.readInt32LE(t))},t.prototype.readFloatBE=function(t){return this.intbits2float(this.readInt32BE(t))},t.prototype.readDoubleLE=function(t){return this.longbits2double(this.readInt32LE(t+4),this.readInt32LE(t))},t.prototype.readDoubleBE=function(t){return this.longbits2double(this.readInt32BE(t),this.readInt32BE(t+4))},t.prototype.copy=function(){throw new n.ApiError(14,"BufferCore implementations should implement copy.")},t.prototype.fill=function(t,e,n){for(var r=e;n>r;r++)this.writeUInt8(r,t)},t.prototype.float2intbits=function(t){var e,n,r;return 0===t?0:t===Number.POSITIVE_INFINITY?o:t===Number.NEGATIVE_INFINITY?s:isNaN(t)?a:(r=0>t?1:0,t=Math.abs(t),1.1754942106924411e-38>=t&&t>=1.401298464324817e-45?(e=0,n=Math.round(t/Math.pow(2,-126)*Math.pow(2,23)),r<<31|e<<23|n):(e=Math.floor(Math.log(t)/Math.LN2),n=Math.round((t/Math.pow(2,e)-1)*Math.pow(2,23)),r<<31|e+127<<23|n))},t.prototype.double2longbits=function(t){var e,n,r,i;return 0===t?[0,0]:t===Number.POSITIVE_INFINITY?[0,2146435072]:t===Number.NEGATIVE_INFINITY?[0,-1048576]:isNaN(t)?[0,2146959360]:(i=0>t?1<<31:0,t=Math.abs(t),2.225073858507201e-308>=t&&t>=5e-324?(e=0,r=t/Math.pow(2,-1022)*Math.pow(2,52)):(e=Math.floor(Math.log(t)/Math.LN2),t>>31,a=(2139095040&t)>>>23,u=8388607&t;return e=0===a?Math.pow(-1,n)*u*Math.pow(2,-149):Math.pow(-1,n)*(1+u*Math.pow(2,-23))*Math.pow(2,a-127),(i>e||e>r)&&(e=0/0),e},t.prototype.longbits2double=function(t,e){var n=(2147483648&t)>>>31,r=(2146435072&t)>>>20,i=(1048575&t)*Math.pow(2,32)+e;return 0===r&&0===i?0:2047===r?0===i?1===n?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY:0/0:0===r?Math.pow(-1,n)*i*Math.pow(2,-1074):Math.pow(-1,n)*(1+i*Math.pow(2,-52))*Math.pow(2,r-1023)},t}();e.BufferCoreCommon=u});var f=this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);n.prototype=e.prototype,t.prototype=new n};c("core/buffer_core_array",["require","exports","./buffer_core"],function(t,e,n){var r=[4294967040,4294902015,4278255615,16777215],i=function(t){function e(e){t.call(this),this.length=e,this.buff=new Array(Math.ceil(e/4));for(var n=this.buff.length,r=0;n>r;r++)this.buff[r]=0}return f(e,t),e.isAvailable=function(){return!0},e.prototype.getLength=function(){return this.length},e.prototype.writeUInt8=function(t,e){e&=255;var n=t>>2,i=3&t;this.buff[n]=this.buff[n]&r[i],this.buff[n]=this.buff[n]|e<<(i<<3)},e.prototype.readUInt8=function(t){var e=t>>2,n=3&t;return this.buff[e]>>(n<<3)&255},e.prototype.copy=function(t,n){for(var r=new e(n-t),i=t;n>i;i++)r.writeUInt8(i-t,this.readUInt8(i));return r},e}(n.BufferCoreCommon);e.BufferCoreArray=i});var f=this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);n.prototype=e.prototype,t.prototype=new n};c("core/buffer_core_arraybuffer",["require","exports","./buffer_core"],function(t,e,n){var r=function(t){function e(e){t.call(this),this.buff="number"==typeof e?new DataView(new ArrayBuffer(e)):e instanceof DataView?e:new DataView(e),this.length=this.buff.byteLength}return f(e,t),e.isAvailable=function(){return"undefined"!=typeof DataView},e.prototype.getLength=function(){return this.length},e.prototype.writeInt8=function(t,e){this.buff.setInt8(t,e)},e.prototype.writeInt16LE=function(t,e){this.buff.setInt16(t,e,!0)},e.prototype.writeInt16BE=function(t,e){this.buff.setInt16(t,e,!1)},e.prototype.writeInt32LE=function(t,e){this.buff.setInt32(t,e,!0)},e.prototype.writeInt32BE=function(t,e){this.buff.setInt32(t,e,!1)},e.prototype.writeUInt8=function(t,e){this.buff.setUint8(t,e)},e.prototype.writeUInt16LE=function(t,e){this.buff.setUint16(t,e,!0)},e.prototype.writeUInt16BE=function(t,e){this.buff.setUint16(t,e,!1)},e.prototype.writeUInt32LE=function(t,e){this.buff.setUint32(t,e,!0)},e.prototype.writeUInt32BE=function(t,e){this.buff.setUint32(t,e,!1)},e.prototype.writeFloatLE=function(t,e){this.buff.setFloat32(t,e,!0)},e.prototype.writeFloatBE=function(t,e){this.buff.setFloat32(t,e,!1)},e.prototype.writeDoubleLE=function(t,e){this.buff.setFloat64(t,e,!0)},e.prototype.writeDoubleBE=function(t,e){this.buff.setFloat64(t,e,!1)},e.prototype.readInt8=function(t){return this.buff.getInt8(t)},e.prototype.readInt16LE=function(t){return this.buff.getInt16(t,!0)},e.prototype.readInt16BE=function(t){return this.buff.getInt16(t,!1)},e.prototype.readInt32LE=function(t){return this.buff.getInt32(t,!0)},e.prototype.readInt32BE=function(t){return this.buff.getInt32(t,!1)},e.prototype.readUInt8=function(t){return this.buff.getUint8(t)},e.prototype.readUInt16LE=function(t){return this.buff.getUint16(t,!0)},e.prototype.readUInt16BE=function(t){return this.buff.getUint16(t,!1)},e.prototype.readUInt32LE=function(t){return this.buff.getUint32(t,!0)},e.prototype.readUInt32BE=function(t){return this.buff.getUint32(t,!1)},e.prototype.readFloatLE=function(t){return this.buff.getFloat32(t,!0)},e.prototype.readFloatBE=function(t){return this.buff.getFloat32(t,!1)},e.prototype.readDoubleLE=function(t){return this.buff.getFloat64(t,!0)},e.prototype.readDoubleBE=function(t){return this.buff.getFloat64(t,!1)},e.prototype.copy=function(t,n){var r,i=this.buff.buffer;if(ArrayBuffer.prototype.slice)r=i.slice(t,n);else{var o=n-t;r=new ArrayBuffer(o);var s=new Uint8Array(r),a=new Uint8Array(i);s.set(a.subarray(t,n))}return new e(r)},e.prototype.fill=function(t,e,n){t=255&t;var r,i=n-e,o=4*(i/4|0),s=t<<24|t<<16|t<<8|t;for(r=0;o>r;r+=4)this.writeInt32LE(r+e,s);for(r=o;i>r;r++)this.writeUInt8(r+e,t)},e.prototype.getDataView=function(){return this.buff},e}(n.BufferCoreCommon);e.BufferCoreArrayBuffer=r});var f=this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);n.prototype=e.prototype,t.prototype=new n};c("core/buffer_core_imagedata",["require","exports","./buffer_core"],function(t,e,n){var r=function(t){function e(n){t.call(this),this.length=n,this.buff=e.getCanvasPixelArray(n)}return f(e,t),e.getCanvasPixelArray=function(t){var n=e.imageDataFactory;return void 0===n&&(e.imageDataFactory=n=document.createElement("canvas").getContext("2d")),0===t&&(t=1),n.createImageData(Math.ceil(t/4),1).data},e.isAvailable=function(){return"undefined"!=typeof CanvasPixelArray},e.prototype.getLength=function(){return this.length},e.prototype.writeUInt8=function(t,e){this.buff[t]=e},e.prototype.readUInt8=function(t){return this.buff[t]},e.prototype.copy=function(t,n){for(var r=new e(n-t),i=t;n>i;i++)r.writeUInt8(i-t,this.buff[i]);return r},e}(n.BufferCoreCommon);e.BufferCoreImageData=r}),c("core/string_util",["require","exports"],function(t,e){function n(t){switch(t=function(){switch(typeof t){case"object":return""+t;case"string":return t;default:throw new Error("Invalid encoding argument specified")}}(),t=t.toLowerCase()){case"utf8":case"utf-8":return r;case"ascii":return i;case"binary":return s;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return u;case"hex":return c;case"base64":return a;case"binary_string":return f;case"binary_string_ie":return h;case"extended_ascii":return o;default:throw new Error("Unknown encoding: "+t)}}e.FindUtil=n;var r=function(){function t(){}return t.str2byte=function(t,e){for(var n=e.length,r=0,i=0,o=n,s=0;ri;){var a=t.charCodeAt(r++),u=t.charCodeAt(r);if(a>=55296&&56319>=a&&u>=56320&&57343>=u){if(i+3>=o)break;s++;var c=(1023&a|1024)<<10|1023&u;e.writeUInt8(c>>18|240,i++),e.writeUInt8(c>>12&63|128,i++),e.writeUInt8(c>>6&63|128,i++),e.writeUInt8(63&c|128,i++),r++}else if(128>a)e.writeUInt8(a,i++),s++;else if(2048>a){if(i+1>=o)break;s++,e.writeUInt8(a>>6|192,i++),e.writeUInt8(63&a|128,i++)}else if(65536>a){if(i+2>=o)break;s++,e.writeUInt8(a>>12|224,i++),e.writeUInt8(a>>6&63|128,i++),e.writeUInt8(63&a|128,i++)}}return i},t.byte2str=function(t){for(var e=[],n=0;nr)e.push(String.fromCharCode(r));else{if(192>r)throw new Error("Found incomplete part of character in string.");if(224>r)e.push(String.fromCharCode((31&r)<<6|63&t.readUInt8(n++)));else if(240>r)e.push(String.fromCharCode((15&r)<<12|(63&t.readUInt8(n++))<<6|63&t.readUInt8(n++)));else{if(!(248>r))throw new Error("Unable to represent UTF-8 string as UTF-16 JavaScript string.");var i=t.readUInt8(n+2);e.push(String.fromCharCode(1023&((7&r)<<8|(63&t.readUInt8(n++))<<2|(63&t.readUInt8(n++))>>4)|55296)),e.push(String.fromCharCode((15&i)<<6|63&t.readUInt8(n++)|56320))}}}return e.join("")},t.byteLength=function(t){var e=encodeURIComponent(t).match(/%[89ABab]/g);return t.length+(e?e.length:0)},t}();e.UTF8=r;var i=function(){function t(){}return t.str2byte=function(t,e){for(var n=t.length>e.length?e.length:t.length,r=0;n>r;r++)e.writeUInt8(t.charCodeAt(r)%256,r);return n},t.byte2str=function(t){for(var e=new Array(t.length),n=0;nn.length?n.length:e.length,i=0;r>i;i++){var o=e.charCodeAt(i);if(o>127){var s=t.extendedChars.indexOf(e.charAt(i));s>-1&&(o=s+128)}n.writeUInt8(o,i)}return r},t.byte2str=function(e){for(var n=new Array(e.length),r=0;r127?t.extendedChars[i-128]:String.fromCharCode(i)}return n.join("")},t.byteLength=function(t){return t.length},t.extendedChars=["Ç","ü","é","â","ä","à","å","ç","ê","ë","è","ï","î","ì","Ä","Å","É","æ","Æ","ô","ö","ò","û","ù","ÿ","Ö","Ü","ø","£","Ø","×","ƒ","á","í","ó","ú","ñ","Ñ","ª","º","¿","®","¬","½","¼","¡","«","»","_","_","_","¦","¦","Á","Â","À","©","¦","¦","+","+","¢","¥","+","+","-","-","+","-","+","ã","Ã","+","+","-","-","¦","-","+","¤","ð","Ð","Ê","Ë","È","i","Í","Î","Ï","+","+","_","_","¦","Ì","_","Ó","ß","Ô","Ò","õ","Õ","µ","þ","Þ","Ú","Û","Ù","ý","Ý","¯","´","­","±","_","¾","¶","§","÷","¸","°","¨","·","¹","³","²","_"," "],t}();e.ExtendedASCII=o;var s=function(){function t(){}return t.str2byte=function(t,e){for(var n=t.length>e.length?e.length:t.length,r=0;n>r;r++)e.writeUInt8(255&t.charCodeAt(r),r);return n},t.byte2str=function(t){for(var e=new Array(t.length),n=0;n>2,u=(3&i)<<4|o>>4,c=(15&o)<<2|s>>6,f=63&s;isNaN(o)?c=f=64:isNaN(s)&&(f=64),n=n+t.num2b64[a]+t.num2b64[u]+t.num2b64[c]+t.num2b64[f]}return n},t.str2byte=function(e,n){var r=n.length,i="",o=0;e=e.replace(/[^A-Za-z0-9\+\/\=\-\_]/g,"");for(var s=0;o>4,p=(15&u)<<4|c>>2,l=(3&c)<<6|f;if(n.writeUInt8(h,s++),s===r)break;if(64!==c&&(i+=n.writeUInt8(p,s++)),s===r)break;if(64!==f&&(i+=n.writeUInt8(l,s++)),s===r)break}return s},t.byteLength=function(t){return Math.floor(6*t.replace(/[^A-Za-z0-9\+\/\-\_]/g,"").length/8)},t.b64chars=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","+","/","="],t.num2b64=function(){for(var e=new Array(t.b64chars.length),n=0;ne.length&&(n=e.length%2===1?(e.length-1)/2:e.length/2);for(var r=0;n>r;r++)e.writeUInt16LE(t.charCodeAt(r),2*r);return 2*n},t.byte2str=function(t){if(t.length%2!==0)throw new Error("Invalid UCS2 byte array.");for(var e=new Array(t.length/2),n=0;n>1;n>e.length&&(n=e.length);for(var r=0;n>r;r++){var i=this.hex2num[t.charAt(r<<1)],o=this.hex2num[t.charAt((r<<1)+1)];e.writeUInt8(i<<4|o,r)}return n},t.byte2str=function(t){for(var e=t.length,n=new Array(e<<1),r=0,i=0;e>i;i++){var o=15&t.readUInt8(i),s=t.readUInt8(i)>>4;n[r++]=this.num2hex[s],n[r++]=this.num2hex[o]}return n.join("")},t.byteLength=function(t){return t.length>>1},t.HEXCHARS="0123456789abcdef",t.num2hex=function(){for(var e=new Array(t.HEXCHARS.length),n=0;nn.length&&(r=n.length);var i=0,o=0,s=o+r,a=e.charCodeAt(i++);0!==a&&(n.writeUInt8(255&a,0),o=1);for(var u=o;s>u;u+=2){var c=e.charCodeAt(i++);s-u===1&&n.writeUInt8(c>>8,u),s-u>=2&&n.writeUInt16BE(c,u)}return r},t.byte2str=function(t){var e=t.length;if(0===e)return"";for(var n=new Array((e>>1)+1),r=0,i=0;ie.length?e.length:t.length,r=0;n>r;r++)e.writeUInt8(t.charCodeAt(r)-32,r);return n},t.byte2str=function(t){for(var e=new Array(t.length),n=0;n>>0)throw new TypeError("Buffer size must be a uint32.");this.length=e,this.data=new u(e)}else if("undefined"!=typeof DataView&&e instanceof DataView)this.data=new i.BufferCoreArrayBuffer(e),this.length=e.byteLength;else if("undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer)this.data=new i.BufferCoreArrayBuffer(e),this.length=e.byteLength;else if(e instanceof t){var f=e;this.data=new u(e.length),this.length=e.length,f.copy(this)}else if(Array.isArray(e)||null!=e&&"object"==typeof e&&"number"==typeof e[0]){for(this.data=new u(e.length),s=0;se?this.writeInt8(e,t):this.writeUInt8(e,t)},t.prototype.get=function(t){return this.readUInt8(t)},t.prototype.write=function(e,n,r,i){if(void 0===n&&(n=0),void 0===r&&(r=this.length),void 0===i&&(i="utf8"),"string"==typeof n?(i=""+n,n=0,r=this.length):"string"==typeof r&&(i=""+r,r=this.length),n>=this.length)return 0;var o=s.FindUtil(i);return r=r+n>this.length?this.length-n:r,n+=this.offset,o.str2byte(e,0===n&&r===this.length?this:new t(this.data,n,r+n))},t.prototype.toString=function(e,n,r){if(void 0===e&&(e="utf8"),void 0===n&&(n=0),void 0===r&&(r=this.length),!(r>=n))throw new Error("Invalid start/end positions: "+n+" - "+r);if(n===r)return"";r>this.length&&(r=this.length);var i=s.FindUtil(e);return i.byte2str(0===n&&r===this.length?this:new t(this.data,n+this.offset,r+this.offset))},t.prototype.toJSON=function(){for(var t=this.length,e=new Array(t),n=0;t>n;n++)e[n]=this.readUInt8(n);return{type:"Buffer",data:e}},t.prototype.toArrayBuffer=function(){var e=this.getBufferCore();if(e instanceof i.BufferCoreArrayBuffer){var n=e.getDataView(),r=n.buffer;return 0===n.byteOffset&&n.byteLength===r.byteLength?r:r.slice(n.byteOffset,n.byteLength)}var r=new ArrayBuffer(this.length),o=new t(r);return this.copy(o,0,0,this.length),r},t.prototype.copy=function(t,e,n,r){if(void 0===e&&(e=0),void 0===n&&(n=0),void 0===r&&(r=this.length),e=0>e?0:e,n=0>n?0:n,n>r)throw new RangeError("sourceEnd < sourceStart");if(r===n)return 0;if(e>=t.length)throw new RangeError("targetStart out of bounds");if(n>=this.length)throw new RangeError("sourceStart out of bounds");if(r>this.length)throw new RangeError("sourceEnd out of bounds");var i,o=Math.min(r-n,t.length-e,this.length-n);for(i=0;o-3>i;i+=4)t.writeInt32LE(this.readInt32LE(n+i),e+i);for(i=4294967292&o;o>i;i++)t.writeUInt8(this.readUInt8(n+i),e+i);return o},t.prototype.slice=function(e,n){if(void 0===e&&(e=0),void 0===n&&(n=this.length),0>e&&(e+=this.length,0>e&&(e=0)),0>n&&(n+=this.length,0>n&&(n=0)),n>this.length&&(n=this.length),e>n&&(e=n),0>e||0>n||e>=this.length||n>this.length)throw new Error("Invalid slice indices.");return new t(this.data,e+this.offset,n+this.offset)},t.prototype.sliceCopy=function(e,n){if(void 0===e&&(e=0),void 0===n&&(n=this.length),0>e&&(e+=this.length,0>e&&(e=0)),0>n&&(n+=this.length,0>n&&(n=0)),n>this.length&&(n=this.length),e>n&&(e=n),0>e||0>n||e>=this.length||n>this.length)throw new Error("Invalid slice indices.");return new t(this.data.copy(e+this.offset,n+this.offset))},t.prototype.fill=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length);var r=typeof t;switch(r){case"string":t=255&t.charCodeAt(0);break;case"number":break;default:throw new Error("Invalid argument to fill.")}e+=this.offset,n+=this.offset,this.data.fill(t,e,n)},t.prototype.readUInt8=function(t,e){return void 0===e&&(e=!1),t+=this.offset,this.data.readUInt8(t)},t.prototype.readUInt16LE=function(t,e){return void 0===e&&(e=!1),t+=this.offset,this.data.readUInt16LE(t)},t.prototype.readUInt16BE=function(t,e){return void 0===e&&(e=!1),t+=this.offset,this.data.readUInt16BE(t)},t.prototype.readUInt32LE=function(t,e){return void 0===e&&(e=!1),t+=this.offset,this.data.readUInt32LE(t)},t.prototype.readUInt32BE=function(t,e){return void 0===e&&(e=!1),t+=this.offset,this.data.readUInt32BE(t)},t.prototype.readInt8=function(t,e){return void 0===e&&(e=!1),t+=this.offset,this.data.readInt8(t)},t.prototype.readInt16LE=function(t,e){return void 0===e&&(e=!1),t+=this.offset,this.data.readInt16LE(t)},t.prototype.readInt16BE=function(t,e){return void 0===e&&(e=!1),t+=this.offset,this.data.readInt16BE(t)},t.prototype.readInt32LE=function(t,e){return void 0===e&&(e=!1),t+=this.offset,this.data.readInt32LE(t)},t.prototype.readInt32BE=function(t,e){return void 0===e&&(e=!1),t+=this.offset,this.data.readInt32BE(t)},t.prototype.readFloatLE=function(t,e){return void 0===e&&(e=!1),t+=this.offset,this.data.readFloatLE(t)},t.prototype.readFloatBE=function(t,e){return void 0===e&&(e=!1),t+=this.offset,this.data.readFloatBE(t)},t.prototype.readDoubleLE=function(t,e){return void 0===e&&(e=!1),t+=this.offset,this.data.readDoubleLE(t)},t.prototype.readDoubleBE=function(t,e){return void 0===e&&(e=!1),t+=this.offset,this.data.readDoubleBE(t)},t.prototype.writeUInt8=function(t,e,n){void 0===n&&(n=!1),e+=this.offset,this.data.writeUInt8(e,t)},t.prototype.writeUInt16LE=function(t,e,n){void 0===n&&(n=!1),e+=this.offset,this.data.writeUInt16LE(e,t)},t.prototype.writeUInt16BE=function(t,e,n){void 0===n&&(n=!1),e+=this.offset,this.data.writeUInt16BE(e,t)},t.prototype.writeUInt32LE=function(t,e,n){void 0===n&&(n=!1),e+=this.offset,this.data.writeUInt32LE(e,t)},t.prototype.writeUInt32BE=function(t,e,n){void 0===n&&(n=!1),e+=this.offset,this.data.writeUInt32BE(e,t)},t.prototype.writeInt8=function(t,e,n){void 0===n&&(n=!1),e+=this.offset,this.data.writeInt8(e,t)},t.prototype.writeInt16LE=function(t,e,n){void 0===n&&(n=!1),e+=this.offset,this.data.writeInt16LE(e,t)},t.prototype.writeInt16BE=function(t,e,n){void 0===n&&(n=!1),e+=this.offset,this.data.writeInt16BE(e,t)},t.prototype.writeInt32LE=function(t,e,n){void 0===n&&(n=!1),e+=this.offset,this.data.writeInt32LE(e,t)},t.prototype.writeInt32BE=function(t,e,n){void 0===n&&(n=!1),e+=this.offset,this.data.writeInt32BE(e,t)},t.prototype.writeFloatLE=function(t,e,n){void 0===n&&(n=!1),e+=this.offset,this.data.writeFloatLE(e,t)},t.prototype.writeFloatBE=function(t,e,n){void 0===n&&(n=!1),e+=this.offset,this.data.writeFloatBE(e,t)},t.prototype.writeDoubleLE=function(t,e,n){void 0===n&&(n=!1),e+=this.offset,this.data.writeDoubleLE(e,t) },t.prototype.writeDoubleBE=function(t,e,n){void 0===n&&(n=!1),e+=this.offset,this.data.writeDoubleBE(e,t)},t.isEncoding=function(t){try{s.FindUtil(t)}catch(e){return!1}return!0},t.isBuffer=function(e){return e instanceof t},t.byteLength=function(t,e){void 0===e&&(e="utf8");var n=s.FindUtil(e);return n.byteLength(t)},t.concat=function(e,n){var r;if(0===e.length||0===n)return new t(0);if(1===e.length)return e[0];if(null==n){n=0;for(var i=0;ithis.maxListeners&&process.stdout.write("Warning: Event "+t+" has more than "+this.maxListeners+" listeners.\n"),this.emit("newListener",t,e),this},t.prototype.on=function(t,e){return this.addListener(t,e)},t.prototype.once=function(t,e){var n=!1,r=function(){this.removeListener(t,r),n||(n=!0,e.apply(this,arguments))};return this.addListener(t,r)},t.prototype._emitRemoveListener=function(t,e){var n;if(this._listeners.removeListener&&this._listeners.removeListener.length>0)for(n=0;n-1&&n.splice(r,1)}return this.emit("removeListener",t,e),this},t.prototype.removeAllListeners=function(t){var e,n,r;if("undefined"!=typeof t)e=this._listeners[t],this._listeners[t]=[],this._emitRemoveListener(t,e);else for(n=Object.keys(this._listeners),r=0;r0&&setTimeout(function(){i.emit("readable")},0):this.resume(),r},e.prototype._processArgs=function(t,e,n){return"string"==typeof e?new s(t,e,n):new s(t,null,e)},e.prototype._processEvents=function(){var t=0===this.buffer.length;this.drained!==t&&this.drained&&this.emit("readable"),this.flowing&&0!==this.buffer.length&&this.emit("data",this.read()),this.drained=0===this.buffer.length},e.prototype.emitEvent=function(t,e){this.emit(t,e.getData(this.encoding)),e.cb&&e.cb()},e.prototype.write=function(t,e,n){if(this.ended)throw new o(0,"Cannot write to an ended stream.");var r=this._processArgs(t,e,n);return this._push(r),this.flowing},e.prototype.end=function(t,e,n){if(this.ended)throw new o(0,"Stream is already closed.");var r=this._processArgs(t,e,n);this.ended=!0,this.endEvent=r,this._processEvents()},e.prototype.read=function(t){var e,n,r,o,a=[],u=[],c=0,f=0,h="number"!=typeof t;for(h&&(t=4294967295),f=0;fc;f++)n=this.buffer[f],a.push(n.getData()),n.cb&&u.push(n.cb),c+=n.size,e=n.cb;if(!h&&t>c)return null;if(this.buffer=this.buffer.slice(a.length),o=c>t?t:c,r=i.concat(a),c>t&&(e&&u.pop(),this._push(new s(r.slice(t),null,e))),u.length>0&&setTimeout(function(){var t;for(t=0;t0&&".."!==i[0])?i.pop():i.push(s))}if(!n&&i.length<2)switch(i.length){case 1:""===i[0]&&i.unshift(".");break;default:i.push(".")}return e=i.join(t.sep),n&&e.charAt(0)!==t.sep&&(e=t.sep+e),e},t.join=function(){for(var e=[],n=0;n1&&a.charAt(a.length-1)===t.sep)return a.substr(0,a.length-1);if(a.charAt(0)!==t.sep){"."!==a.charAt(0)||1!==a.length&&a.charAt(1)!==t.sep||(a=1===a.length?"":a.substr(2));var u=r.cwd();a=""!==a?this.normalize(u+("/"!==u?t.sep:"")+a):u}return a},t.relative=function(e,n){var r;e=t.resolve(e),n=t.resolve(n);var i=e.split(t.sep),o=n.split(t.sep);o.shift(),i.shift();var s=0,a=[];for(r=0;ri.length&&(s=i.length);var c="";for(r=0;s>r;r++)c+="../";return c+=a.join(t.sep),c.length>1&&c.charAt(c.length-1)===t.sep&&(c=c.substr(0,c.length-1)),c},t.dirname=function(e){e=t._removeDuplicateSeps(e);var n=e.charAt(0)===t.sep,r=e.split(t.sep);return""===r.pop()&&r.length>0&&r.pop(),r.length>1||1===r.length&&!n?r.join(t.sep):n?t.sep:"."},t.basename=function(e,n){if(void 0===n&&(n=""),""===e)return e;e=t.normalize(e);var r=e.split(t.sep),i=r[r.length-1];if(""===i&&r.length>1)return r[r.length-2];if(n.length>0){var o=i.substr(i.length-n.length);if(o===n)return i.substr(0,i.length-n.length)}return i},t.extname=function(e){e=t.normalize(e);var n=e.split(t.sep);if(e=n.pop(),""===e&&n.length>0&&(e=n.pop()),".."===e)return"";var r=e.lastIndexOf(".");return-1===r||0===r?"":e.substr(r)},t.isAbsolute=function(e){return e.length>0&&e.charAt(0)===t.sep},t._makeLong=function(t){return t},t._removeDuplicateSeps=function(t){return t=t.replace(this._replaceRegex,this.sep)},t.sep="/",t._replaceRegex=new RegExp("//+","g"),t.delimiter=":",t}();e.path=i}),c("core/node_fs",["require","exports","./api_error","./file_flag","./buffer","./node_path"],function(t,e,n,r,i,o){function s(t,e){if("function"!=typeof t)throw new p(9,"Callback must be a function.");switch("undefined"==typeof __numWaiting&&(__numWaiting=0),__numWaiting++,e){case 1:return function(e){setImmediate(function(){return __numWaiting--,t(e)})};case 2:return function(e,n){setImmediate(function(){return __numWaiting--,t(e,n)})};case 3:return function(e,n,r){setImmediate(function(){return __numWaiting--,t(e,n,r)})};default:throw new Error("Invalid invocation of wrapCb.")}}function a(t){if("function"!=typeof t.write)throw new p(3,"Invalid file descriptor.")}function u(t,e){switch(typeof t){case"number":return t;case"string":var n=parseInt(t,8);if(0/0!==n)return n;default:return e}}function c(t){if(t.indexOf("\x00")>=0)throw new p(9,"Path must be a string without null bytes.");if(""===t)throw new p(9,"Path must not be empty.");return d.resolve(t)}function f(t,e,n,r){switch(typeof t){case"object":return{encoding:"undefined"!=typeof t.encoding?t.encoding:e,flag:"undefined"!=typeof t.flag?t.flag:n,mode:u(t.mode,r)};case"string":return{encoding:t,flag:n,mode:r};default:return{encoding:e,flag:n,mode:r}}}function h(){}var p=n.ApiError,l=(n.ErrorCode,r.FileFlag),y=i.Buffer,d=o.path,g=function(){function t(){}return t._initialize=function(e){if(!e.constructor.isAvailable())throw new p(9,"Tried to instantiate BrowserFS with an unavailable file system.");return t.root=e},t._toUnixTimestamp=function(t){if("number"==typeof t)return t;if(t instanceof Date)return t.getTime()/1e3;throw new Error("Cannot parse time: "+t)},t.getRootFS=function(){return t.root?t.root:null},t.rename=function(e,n,r){void 0===r&&(r=h);var i=s(r,1);try{t.root.rename(c(e),c(n),i)}catch(o){i(o)}},t.renameSync=function(e,n){t.root.renameSync(c(e),c(n))},t.exists=function(e,n){void 0===n&&(n=h);var r=s(n,1);try{return t.root.exists(c(e),r)}catch(i){return r(!1)}},t.existsSync=function(e){try{return t.root.existsSync(c(e))}catch(n){return!1}},t.stat=function(e,n){void 0===n&&(n=h);var r=s(n,2);try{return t.root.stat(c(e),!1,r)}catch(i){return r(i,null)}},t.statSync=function(e){return t.root.statSync(c(e),!1)},t.lstat=function(e,n){void 0===n&&(n=h);var r=s(n,2);try{return t.root.stat(c(e),!0,r)}catch(i){return r(i,null)}},t.lstatSync=function(e){return t.root.statSync(c(e),!0)},t.truncate=function(e,n,r){void 0===n&&(n=0),void 0===r&&(r=h);var i=0;"function"==typeof n?r=n:"number"==typeof n&&(i=n);var o=s(r,1);try{if(0>i)throw new p(9);return t.root.truncate(c(e),i,o)}catch(a){return o(a)}},t.truncateSync=function(e,n){if(void 0===n&&(n=0),0>n)throw new p(9);return t.root.truncateSync(c(e),n)},t.unlink=function(e,n){void 0===n&&(n=h);var r=s(n,1);try{return t.root.unlink(c(e),r)}catch(i){return r(i)}},t.unlinkSync=function(e){return t.root.unlinkSync(c(e))},t.open=function(e,n,r,i){void 0===i&&(i=h);var o=u(r,420);i="function"==typeof r?r:i;var a=s(i,2);try{return t.root.open(c(e),l.getFileFlag(n),o,a)}catch(f){return a(f,null)}},t.openSync=function(e,n,r){return void 0===r&&(r=420),t.root.openSync(c(e),l.getFileFlag(n),r)},t.readFile=function(e,n,r){void 0===n&&(n={}),void 0===r&&(r=h);var i=f(n,null,"r",null);r="function"==typeof n?n:r;var o=s(r,2);try{var a=l.getFileFlag(i.flag);return a.isReadable()?t.root.readFile(c(e),i.encoding,a,o):o(new p(9,"Flag passed to readFile must allow for reading."))}catch(u){return o(u,null)}},t.readFileSync=function(e,n){void 0===n&&(n={});var r=f(n,null,"r",null),i=l.getFileFlag(r.flag);if(!i.isReadable())throw new p(9,"Flag passed to readFile must allow for reading.");return t.root.readFileSync(c(e),r.encoding,i)},t.writeFile=function(e,n,r,i){void 0===r&&(r={}),void 0===i&&(i=h);var o=f(r,"utf8","w",420);i="function"==typeof r?r:i;var a=s(i,1);try{var u=l.getFileFlag(o.flag);return u.isWriteable()?t.root.writeFile(c(e),n,o.encoding,u,o.mode,a):a(new p(9,"Flag passed to writeFile must allow for writing."))}catch(y){return a(y)}},t.writeFileSync=function(e,n,r){var i=f(r,"utf8","w",420),o=l.getFileFlag(i.flag);if(!o.isWriteable())throw new p(9,"Flag passed to writeFile must allow for writing.");return t.root.writeFileSync(c(e),n,i.encoding,o,i.mode)},t.appendFile=function(e,n,r,i){void 0===i&&(i=h);var o=f(r,"utf8","a",420);i="function"==typeof r?r:i;var a=s(i,1);try{var u=l.getFileFlag(o.flag);if(!u.isAppendable())return a(new p(9,"Flag passed to appendFile must allow for appending."));t.root.appendFile(c(e),n,o.encoding,u,o.mode,a)}catch(y){a(y)}},t.appendFileSync=function(e,n,r){var i=f(r,"utf8","a",420),o=l.getFileFlag(i.flag);if(!o.isAppendable())throw new p(9,"Flag passed to appendFile must allow for appending.");return t.root.appendFileSync(c(e),n,i.encoding,o,i.mode)},t.fstat=function(t,e){void 0===e&&(e=h);var n=s(e,2);try{a(t),t.stat(n)}catch(r){n(r)}},t.fstatSync=function(t){return a(t),t.statSync()},t.close=function(t,e){void 0===e&&(e=h);var n=s(e,1);try{a(t),t.close(n)}catch(r){n(r)}},t.closeSync=function(t){return a(t),t.closeSync()},t.ftruncate=function(t,e,n){void 0===n&&(n=h);var r="number"==typeof e?e:0;n="function"==typeof e?e:n;var i=s(n,1);try{if(a(t),0>r)throw new p(9);t.truncate(r,i)}catch(o){i(o)}},t.ftruncateSync=function(t,e){return void 0===e&&(e=0),a(t),t.truncateSync(e)},t.fsync=function(t,e){void 0===e&&(e=h);var n=s(e,1);try{a(t),t.sync(n)}catch(r){n(r)}},t.fsyncSync=function(t){return a(t),t.syncSync()},t.fdatasync=function(t,e){void 0===e&&(e=h);var n=s(e,1);try{a(t),t.datasync(n)}catch(r){n(r)}},t.fdatasyncSync=function(t){a(t),t.datasyncSync()},t.write=function(t,e,n,r,i,o){void 0===o&&(o=h);var u,c,f,l=null;if("string"==typeof e){var d="utf8";switch(typeof n){case"function":o=n;break;case"number":l=n,d="string"==typeof r?r:"utf8",o="function"==typeof i?i:o;break;default:return(o="function"==typeof r?r:"function"==typeof i?i:o)(new p(9,"Invalid arguments."))}u=new y(e,d),c=0,f=u.length}else u=e,c=n,f=r,l="number"==typeof i?i:null,o="function"==typeof i?i:o;var g=s(o,3);try{a(t),null==l&&(l=t.getPos()),t.write(u,c,f,l,g)}catch(w){g(w)}},t.writeSync=function(t,e,n,r,i){var o,s,u,c=0;if("string"==typeof e){u="number"==typeof n?n:null;var f="string"==typeof r?r:"utf8";c=0,o=new y(e,f),s=o.length}else o=e,c=n,s=r,u="number"==typeof i?i:null;return a(t),null==u&&(u=t.getPos()),t.writeSync(o,c,s,u)},t.read=function(t,e,n,r,i,o){void 0===o&&(o=h);var u,c,f,p,l;if("number"==typeof e){f=e,u=n;var d=r;o="function"==typeof i?i:o,c=0,p=new y(f),l=s(function(t,e,n){return t?o(t):void o(t,n.toString(d),e)},3)}else p=e,c=n,f=r,u=i,l=s(o,3);try{a(t),null==u&&(u=t.getPos()),t.read(p,c,f,u,l)}catch(g){l(g)}},t.readSync=function(t,e,n,r,i){var o,s,u,c,f=!1;if("number"==typeof e){u=e,c=n;var h=r;s=0,o=new y(u),f=!0}else o=e,s=n,u=r,c=i;a(t),null==c&&(c=t.getPos());var p=t.readSync(o,s,u,c);return f?[o.toString(h),p]:p},t.fchown=function(t,e,n,r){void 0===r&&(r=h);var i=s(r,1);try{a(t),t.chown(e,n,i)}catch(o){i(o)}},t.fchownSync=function(t,e,n){return a(t),t.chownSync(e,n)},t.fchmod=function(t,e,n){void 0===n&&(n=h);var r=s(n,1);try{e="string"==typeof e?parseInt(e,8):e,a(t),t.chmod(e,r)}catch(i){r(i)}},t.fchmodSync=function(t,e){return e="string"==typeof e?parseInt(e,8):e,a(t),t.chmodSync(e)},t.futimes=function(t,e,n,r){void 0===r&&(r=h);var i=s(r,1);try{a(t),"number"==typeof e&&(e=new Date(1e3*e)),"number"==typeof n&&(n=new Date(1e3*n)),t.utimes(e,n,i)}catch(o){i(o)}},t.futimesSync=function(t,e,n){return a(t),"number"==typeof e&&(e=new Date(1e3*e)),"number"==typeof n&&(n=new Date(1e3*n)),t.utimesSync(e,n)},t.rmdir=function(e,n){void 0===n&&(n=h);var r=s(n,1);try{e=c(e),t.root.rmdir(e,r)}catch(i){r(i)}},t.rmdirSync=function(e){return e=c(e),t.root.rmdirSync(e)},t.mkdir=function(e,n,r){void 0===r&&(r=h),"function"==typeof n&&(r=n,n=511);var i=s(r,1);try{e=c(e),t.root.mkdir(e,n,i)}catch(o){i(o)}},t.mkdirSync=function(e,n){return void 0===n&&(n=511),n="string"==typeof n?parseInt(n,8):n,e=c(e),t.root.mkdirSync(e,n)},t.readdir=function(e,n){void 0===n&&(n=h);var r=s(n,2);try{e=c(e),t.root.readdir(e,r)}catch(i){r(i)}},t.readdirSync=function(e){return e=c(e),t.root.readdirSync(e)},t.link=function(e,n,r){void 0===r&&(r=h);var i=s(r,1);try{e=c(e),n=c(n),t.root.link(e,n,i)}catch(o){i(o)}},t.linkSync=function(e,n){return e=c(e),n=c(n),t.root.linkSync(e,n)},t.symlink=function(e,n,r,i){void 0===i&&(i=h);var o="string"==typeof r?r:"file";i="function"==typeof r?r:i;var a=s(i,1);try{if("file"!==o&&"dir"!==o)return a(new p(9,"Invalid type: "+o));e=c(e),n=c(n),t.root.symlink(e,n,o,a)}catch(u){a(u)}},t.symlinkSync=function(e,n,r){if(null==r)r="file";else if("file"!==r&&"dir"!==r)throw new p(9,"Invalid type: "+r);return e=c(e),n=c(n),t.root.symlinkSync(e,n,r)},t.readlink=function(e,n){void 0===n&&(n=h);var r=s(n,2);try{e=c(e),t.root.readlink(e,r)}catch(i){r(i)}},t.readlinkSync=function(e){return e=c(e),t.root.readlinkSync(e)},t.chown=function(e,n,r,i){void 0===i&&(i=h);var o=s(i,1);try{e=c(e),t.root.chown(e,!1,n,r,o)}catch(a){o(a)}},t.chownSync=function(e,n,r){e=c(e),t.root.chownSync(e,!1,n,r)},t.lchown=function(e,n,r,i){void 0===i&&(i=h);var o=s(i,1);try{e=c(e),t.root.chown(e,!0,n,r,o)}catch(a){o(a)}},t.lchownSync=function(e,n,r){return e=c(e),t.root.chownSync(e,!0,n,r)},t.chmod=function(e,n,r){void 0===r&&(r=h);var i=s(r,1);try{n="string"==typeof n?parseInt(n,8):n,e=c(e),t.root.chmod(e,!1,n,i)}catch(o){i(o)}},t.chmodSync=function(e,n){return n="string"==typeof n?parseInt(n,8):n,e=c(e),t.root.chmodSync(e,!1,n)},t.lchmod=function(e,n,r){void 0===r&&(r=h);var i=s(r,1);try{n="string"==typeof n?parseInt(n,8):n,e=c(e),t.root.chmod(e,!0,n,i)}catch(o){i(o)}},t.lchmodSync=function(e,n){return e=c(e),n="string"==typeof n?parseInt(n,8):n,t.root.chmodSync(e,!0,n)},t.utimes=function(e,n,r,i){void 0===i&&(i=h);var o=s(i,1);try{e=c(e),"number"==typeof n&&(n=new Date(1e3*n)),"number"==typeof r&&(r=new Date(1e3*r)),t.root.utimes(e,n,r,o)}catch(a){o(a)}},t.utimesSync=function(e,n,r){return e=c(e),"number"==typeof n&&(n=new Date(1e3*n)),"number"==typeof r&&(r=new Date(1e3*r)),t.root.utimesSync(e,n,r)},t.realpath=function(e,n,r){void 0===r&&(r=h);var i="object"==typeof n?n:{};r="function"==typeof n?n:h;var o=s(r,2);try{e=c(e),t.root.realpath(e,i,o)}catch(a){o(a)}},t.realpathSync=function(e,n){return void 0===n&&(n={}),e=c(e),t.root.realpathSync(e,n)},t.root=null,t}();e.fs=g}),c("core/browserfs",["require","exports","./buffer","./node_fs","./node_path","./node_process"],function(t,e,n,r,i,o){function s(t){t.Buffer=n.Buffer,t.process=o.process;var e=null!=t.require?t.require:null;t.require=function(t){var n=u(t);return null==n?e.apply(null,Array.prototype.slice.call(arguments,0)):n}}function a(t,n){e.FileSystem[t]=n}function u(t){switch(t){case"fs":return r.fs;case"path":return i.path;case"buffer":return n;case"process":return o.process;default:return e.FileSystem[t]}}function c(t){return r.fs._initialize(t)}e.install=s,e.FileSystem={},e.registerFileSystem=a,e.BFSRequire=u,e.initialize=c}),c("generic/emscripten_fs",["require","exports","../core/browserfs","../core/node_fs","../core/buffer","../core/buffer_core_arraybuffer"],function(t,e,n,r,i,o){var s=i.Buffer,a=o.BufferCoreArrayBuffer,u=r.fs,c=function(){function t(t){this.fs=t,this.FS=t.getFS(),this.PATH=t.getPATH(),this.ERRNO_CODES=t.getERRNO_CODES()}return t.prototype.open=function(t){var e=this.fs.realPath(t.node),n=this.FS;try{n.isFile(t.node.mode)&&(t.nfd=u.openSync(e,this.fs.flagsToPermissionString(t.flags)))}catch(r){if(!r.code)throw r;throw new n.ErrnoError(this.ERRNO_CODES[r.code])}},t.prototype.close=function(t){var e=this.FS;try{e.isFile(t.node.mode)&&t.nfd&&u.closeSync(t.nfd)}catch(n){if(!n.code)throw n;throw new e.ErrnoError(this.ERRNO_CODES[n.code])}},t.prototype.read=function(t,e,n,r,i){var o,c=new a(e.buffer),f=new s(c,e.byteOffset+n,e.byteOffset+n+r);try{o=u.readSync(t.nfd,f,0,r,i)}catch(h){throw new this.FS.ErrnoError(this.ERRNO_CODES[h.code])}return o},t.prototype.write=function(t,e,n,r,i){var o,c=new a(e.buffer),f=new s(c,e.byteOffset+n,e.byteOffset+n+r);try{o=u.writeSync(t.nfd,f,0,r,i)}catch(h){throw new this.FS.ErrnoError(this.ERRNO_CODES[h.code])}return o},t.prototype.llseek=function(t,e,n){var r=e;if(1===n)r+=t.position;else if(2===n&&this.FS.isFile(t.node.mode))try{var i=u.fstatSync(t.nfd);r+=i.size}catch(o){throw new this.FS.ErrnoError(this.ERRNO_CODES[o.code])}if(0>r)throw new this.FS.ErrnoError(this.ERRNO_CODES.EINVAL);return t.position=r,r},t}(),f=function(){function t(t){this.fs=t,this.FS=t.getFS(),this.PATH=t.getPATH(),this.ERRNO_CODES=t.getERRNO_CODES()}return t.prototype.getattr=function(t){var e,n=this.fs.realPath(t);try{e=u.lstatSync(n)}catch(r){if(!r.code)throw r;throw new this.FS.ErrnoError(this.ERRNO_CODES[r.code])}return{dev:e.dev,ino:e.ino,mode:e.mode,nlink:e.nlink,uid:e.uid,gid:e.gid,rdev:e.rdev,size:e.size,atime:e.atime,mtime:e.mtime,ctime:e.ctime,blksize:e.blksize,blocks:e.blocks}},t.prototype.setattr=function(t,e){var n=this.fs.realPath(t);try{if(void 0!==e.mode&&(u.chmodSync(n,e.mode),t.mode=e.mode),void 0!==e.timestamp){var r=new Date(e.timestamp);u.utimesSync(n,r,r)}}catch(i){if(!i.code)throw i;if("ENOTSUP"!==i.code)throw new this.FS.ErrnoError(this.ERRNO_CODES[i.code])}if(void 0!==e.size)try{u.truncateSync(n,e.size)}catch(i){if(!i.code)throw i;throw new this.FS.ErrnoError(this.ERRNO_CODES[i.code])}},t.prototype.lookup=function(t,e){var n=this.PATH.join2(this.fs.realPath(t),e),r=this.fs.getMode(n);return this.fs.createNode(t,e,r)},t.prototype.mknod=function(t,e,n,r){var i=this.fs.createNode(t,e,n,r),o=this.fs.realPath(i);try{this.FS.isDir(i.mode)?u.mkdirSync(o,i.mode):u.writeFileSync(o,"",{mode:i.mode})}catch(s){if(!s.code)throw s;throw new this.FS.ErrnoError(this.ERRNO_CODES[s.code])}return i},t.prototype.rename=function(t,e,n){var r=this.fs.realPath(t),i=this.PATH.join2(this.fs.realPath(e),n);try{u.renameSync(r,i)}catch(o){if(!o.code)throw o;throw new this.FS.ErrnoError(this.ERRNO_CODES[o.code])}},t.prototype.unlink=function(t,e){var n=this.PATH.join2(this.fs.realPath(t),e);try{u.unlinkSync(n)}catch(r){if(!r.code)throw r;throw new this.FS.ErrnoError(this.ERRNO_CODES[r.code])}},t.prototype.rmdir=function(t,e){var n=this.PATH.join2(this.fs.realPath(t),e);try{u.rmdirSync(n)}catch(r){if(!r.code)throw r;throw new this.FS.ErrnoError(this.ERRNO_CODES[r.code])}},t.prototype.readdir=function(t){var e=this.fs.realPath(t);try{return u.readdirSync(e)}catch(n){if(!n.code)throw n;throw new this.FS.ErrnoError(this.ERRNO_CODES[n.code])}},t.prototype.symlink=function(t,e,n){var r=this.PATH.join2(this.fs.realPath(t),e);try{u.symlinkSync(n,r)}catch(i){if(!i.code)throw i;throw new this.FS.ErrnoError(this.ERRNO_CODES[i.code])}},t.prototype.readlink=function(t){var e=this.fs.realPath(t);try{return u.readlinkSync(e)}catch(n){if(!n.code)throw n;throw new this.FS.ErrnoError(this.ERRNO_CODES[n.code])}},t}(),h=function(){function t(t,e,r){if(void 0===t&&(t=self.FS),void 0===e&&(e=self.PATH),void 0===r&&(r=self.ERRNO_CODES),this.flagsToPermissionStringMap={0:"r",1:"r+",2:"r+",64:"r",65:"r+",66:"r+",129:"rx+",193:"rx+",514:"w+",577:"w",578:"w+",705:"wx",706:"wx+",1024:"a",1025:"a",1026:"a+",1089:"a",1090:"a+",1153:"ax",1154:"ax+",1217:"ax",1218:"ax+",4096:"rs",4098:"rs+"},"undefined"==typeof n)throw new Error("BrowserFS is not loaded. Please load it before this library.");this.FS=t,this.PATH=e,this.ERRNO_CODES=r,this.node_ops=new f(this),this.stream_ops=new c(this)}return t.prototype.mount=function(t){return this.createNode(null,"/",this.getMode(t.opts.root),0)},t.prototype.createNode=function(t,e,n){var r=this.FS;if(!r.isDir(n)&&!r.isFile(n)&&!r.isLink(n))throw new r.ErrnoError(this.ERRNO_CODES.EINVAL);var i=r.createNode(t,e,n);return i.node_ops=this.node_ops,i.stream_ops=this.stream_ops,i},t.prototype.getMode=function(t){var e;try{e=u.lstatSync(t)}catch(n){if(!n.code)throw n;throw new this.FS.ErrnoError(this.ERRNO_CODES[n.code])}return e.mode},t.prototype.realPath=function(t){for(var e=[];t.parent!==t;)e.push(t.name),t=t.parent;return e.push(t.mount.opts.root),e.reverse(),this.PATH.join.apply(null,e)},t.prototype.flagsToPermissionString=function(t){return t in this.flagsToPermissionStringMap?this.flagsToPermissionStringMap[t]:t},t.prototype.getFS=function(){return this.FS},t.prototype.getPATH=function(){return this.PATH},t.prototype.getERRNO_CODES=function(){return this.ERRNO_CODES},t}();e.BFSEmscriptenFS=h,n.EmscriptenFS=h});var f=this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);n.prototype=e.prototype,t.prototype=new n};c("core/file_system",["require","exports","./api_error","./file_flag","./node_path","./buffer"],function(t,e,n,r,i,o){var s=n.ApiError,a=(n.ErrorCode,i.path),u=o.Buffer,c=(r.ActionType,function(){function t(){}return t.prototype.supportsLinks=function(){return!1},t.prototype.diskSpace=function(t,e){e(0,0)},t.prototype.openFile=function(){throw new s(14)},t.prototype.createFile=function(){throw new s(14)},t.prototype.open=function(t,e,n,r){var i=this,o=function(o,u){if(o)switch(e.pathNotExistsAction()){case 3:return i.stat(a.dirname(t),!1,function(o,u){o?r(o):u.isDirectory()?i.createFile(t,e,n,r):r(new s(7,a.dirname(t)+" is not a directory."))});case 1:return r(new s(1,""+t+" doesn't exist."));default:return r(new s(9,"Invalid FileFlag object."))}else{if(u.isDirectory())return r(new s(8,t+" is a directory."));switch(e.pathExistsAction()){case 1:return r(new s(6,t+" already exists."));case 2:return i.openFile(t,e,function(t,e){t?r(t):e.truncate(0,function(){e.sync(function(){r(null,e)})})});case 0:return i.openFile(t,e,r);default:return r(new s(9,"Invalid FileFlag object."))}}};this.stat(t,!1,o)},t.prototype.rename=function(t,e,n){n(new s(14))},t.prototype.renameSync=function(){throw new s(14)},t.prototype.stat=function(t,e,n){n(new s(14))},t.prototype.statSync=function(){throw new s(14)},t.prototype.openFileSync=function(){throw new s(14)},t.prototype.createFileSync=function(){throw new s(14)},t.prototype.openSync=function(t,e,n){var r;try{r=this.statSync(t,!1)}catch(i){switch(e.pathNotExistsAction()){case 3:var o=this.statSync(a.dirname(t),!1);if(!o.isDirectory())throw new s(7,a.dirname(t)+" is not a directory.");return this.createFileSync(t,e,n);case 1:throw new s(1,""+t+" doesn't exist.");default:throw new s(9,"Invalid FileFlag object.")}}if(r.isDirectory())throw new s(8,t+" is a directory.");switch(e.pathExistsAction()){case 1:throw new s(6,t+" already exists.");case 2:return this.unlinkSync(t),this.createFileSync(t,e,r.mode);case 0:return this.openFileSync(t,e);default:throw new s(9,"Invalid FileFlag object.")}},t.prototype.unlink=function(t,e){e(new s(14))},t.prototype.unlinkSync=function(){throw new s(14)},t.prototype.rmdir=function(t,e){e(new s(14))},t.prototype.rmdirSync=function(){throw new s(14)},t.prototype.mkdir=function(t,e,n){n(new s(14))},t.prototype.mkdirSync=function(){throw new s(14)},t.prototype.readdir=function(t,e){e(new s(14))},t.prototype.readdirSync=function(){throw new s(14)},t.prototype.exists=function(t,e){this.stat(t,null,function(t){e(null==t)})},t.prototype.existsSync=function(t){try{return this.statSync(t,!0),!0}catch(e){return!1}},t.prototype.realpath=function(t,e,n){if(this.supportsLinks())for(var r=t.split(a.sep),i=0;ithis._buffer.length){var e=new u(t-this._buffer.length);return e.fill(0),this.writeSync(e,0,e.length,this._buffer.length),void(this._flag.isSynchronous()&&a.getRootFS().supportsSynch()&&this.syncSync())}this._stat.size=t;var n=new u(t);this._buffer.copy(n,0,0,t),this._buffer=n,this._flag.isSynchronous()&&a.getRootFS().supportsSynch()&&this.syncSync()},e.prototype.write=function(t,e,n,r,i){try{i(null,this.writeSync(t,e,n,r),t)}catch(o){i(o)}},e.prototype.writeSync=function(t,e,n,r){if(this._dirty=!0,null==r&&(r=this.getPos()),!this._flag.isWriteable())throw new s(0,"File not opened with a writeable mode.");var i=r+n;if(i>this._stat.size&&(this._stat.size=i,i>this._buffer.length)){var o=new u(i);this._buffer.copy(o),this._buffer=o}var a=t.copy(this._buffer,r,e,e+n);return this._stat.mtime=new Date,this._flag.isSynchronous()?(this.syncSync(),a):(this.setPos(r+a),a)},e.prototype.read=function(t,e,n,r,i){try{i(null,this.readSync(t,e,n,r),t)}catch(o){i(o)}},e.prototype.readSync=function(t,e,n,r){if(!this._flag.isReadable())throw new s(0,"File not opened with a readable mode.");null==r&&(r=this.getPos());var i=r+n;i>this._stat.size&&(n=this._stat.size-r);var o=this._buffer.copy(t,e,r,r+n);return this._stat.atime=new Date,this._pos=r+n,o},e.prototype.chmod=function(t,e){try{this.chmodSync(t),e()}catch(n){e(n)}},e.prototype.chmodSync=function(t){if(!this._fs.supportsProps())throw new s(14);this._dirty=!0,this._stat.chmod(t),this.syncSync()},e}(n.BaseFile);e.PreloadFile=c;var h=function(t){function e(e,n,r,i,o){t.call(this,e,n,r,i,o)}return f(e,t),e.prototype.sync=function(t){t()},e.prototype.syncSync=function(){},e.prototype.close=function(t){t()},e.prototype.closeSync=function(){},e}(c);e.NoSyncFile=h});var f=this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);n.prototype=e.prototype,t.prototype=new n};c("generic/key_value_filesystem",["require","exports","../core/file_system","../core/api_error","../core/node_fs_stats","../core/node_path","../generic/inode","../core/buffer","../generic/preload_file"],function(t,e,n,r,i,o,s,a,u){function c(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0,n="x"==t?e:3&e|8;return n.toString(16)})}function h(t,e){return t?(e(t),!1):!0}function p(t,e,n){return t?(e.abort(function(){n(t)}),!1):!0}var l="/",y=o.path,d=r.ApiError,g=a.Buffer,w=function(){function t(t){this.store=t,this.originalData={},this.modifiedKeys=[]}return t.prototype.stashOldValue=function(t,e){this.originalData.hasOwnProperty(t)||(this.originalData[t]=e)},t.prototype.markModified=function(t){-1===this.modifiedKeys.indexOf(t)&&(this.modifiedKeys.push(t),this.originalData.hasOwnProperty(t)||(this.originalData[t]=this.store.get(t)))},t.prototype.get=function(t){var e=this.store.get(t);return this.stashOldValue(t,e),e},t.prototype.put=function(t,e,n){return this.markModified(t),this.store.put(t,e,n)},t.prototype.delete=function(t){this.markModified(t),this.store.delete(t)},t.prototype.commit=function(){},t.prototype.abort=function(){var t,e,n;for(t=0;tr;)try{return n=c(),t.put(n,e,!1),n}catch(i){}throw new d(2,"Unable to commit data to key-value store.")},e.prototype.commitNewFile=function(t,e,n,r,i){var o=y.dirname(e),a=y.basename(e),u=this.findINode(t,o),c=this.getDirListing(t,o,u),f=(new Date).getTime();if("/"===e)throw d.EEXIST(e);if(c[a])throw d.EEXIST(e);try{var h=this.addNewNode(t,i),p=new s(h,i.length,r|n,f,f,f),l=this.addNewNode(t,p.toBuffer());c[a]=l,t.put(u.id,new g(JSON.stringify(c)),!0)}catch(w){throw t.abort(),w}return t.commit(),p},e.prototype.empty=function(){this.store.clear(),this.makeRootDirectory()},e.prototype.renameSync=function(t,e){var n=this.store.beginTransaction("readwrite"),r=y.dirname(t),i=y.basename(t),o=y.dirname(e),s=y.basename(e),a=this.findINode(n,r),u=this.getDirListing(n,r,a);if(!u[i])throw d.ENOENT(t);var c=u[i];if(delete u[i],0===(o+"/").indexOf(t+"/"))throw new d(5,r);var f,h;if(o===r?(f=a,h=u):(f=this.findINode(n,o),h=this.getDirListing(n,o,f)),h[s]){var p=this.getINode(n,e,h[s]);if(!p.isFile())throw d.EPERM(e);try{n.delete(p.id),n.delete(h[s])}catch(l){throw n.abort(),l}}h[s]=c;try{n.put(a.id,new g(JSON.stringify(u)),!0),n.put(f.id,new g(JSON.stringify(h)),!0)}catch(l){throw n.abort(),l}n.commit()},e.prototype.statSync=function(t){return this.findINode(this.store.beginTransaction("readonly"),t).toStats()},e.prototype.createFileSync=function(t,e,n){var r=this.store.beginTransaction("readwrite"),i=new g(0),o=this.commitNewFile(r,t,32768,n,i);return new m(this,t,e,o.toStats(),i)},e.prototype.openFileSync=function(t,e){var n=this.store.beginTransaction("readonly"),r=this.findINode(n,t),i=n.get(r.id);if(void 0===i)throw d.ENOENT(t);return new m(this,t,e,r.toStats(),i)},e.prototype.removeEntry=function(t,e){var n=this.store.beginTransaction("readwrite"),r=y.dirname(t),i=this.findINode(n,r),o=this.getDirListing(n,r,i),s=y.basename(t);if(!o[s])throw d.ENOENT(t);var a=o[s];delete o[s];var u=this.getINode(n,t,a);if(!e&&u.isDirectory())throw d.EISDIR(t);if(e&&!u.isDirectory())throw d.ENOTDIR(t);try{n.delete(u.id),n.delete(a),n.put(i.id,new g(JSON.stringify(o)),!0)}catch(c){throw n.abort(),c}n.commit()},e.prototype.unlinkSync=function(t){this.removeEntry(t,!1)},e.prototype.rmdirSync=function(t){this.removeEntry(t,!0)},e.prototype.mkdirSync=function(t,e){var n=this.store.beginTransaction("readwrite"),r=new g("{}");this.commitNewFile(n,t,16384,e,r)},e.prototype.readdirSync=function(t){var e=this.store.beginTransaction("readonly");return Object.keys(this.getDirListing(e,t,this.findINode(e,t)))},e.prototype._syncSync=function(t,e,n){var r=this.store.beginTransaction("readwrite"),i=this._findINode(r,y.dirname(t),y.basename(t)),o=this.getINode(r,t,i),s=o.update(n);try{r.put(o.id,e,!0),s&&r.put(i,o.toBuffer(),!0)}catch(a){throw r.abort(),a}r.commit()},e}(n.SynchronousFileSystem);e.SyncKeyValueFileSystem=v;var S=function(t){function e(e,n,r,i,o){t.call(this,e,n,r,i,o)}return f(e,t),e.prototype.sync=function(t){var e=this;this.isDirty()?this._fs._sync(this.getPath(),this.getBuffer(),this.getStats(),function(n){n||e.resetDirty(),t(n)}):t()},e.prototype.close=function(t){this.sync(t)},e}(u.PreloadFile);e.AsyncKeyValueFile=S;var b=function(t){function e(){t.apply(this,arguments)}return f(e,t),e.prototype.init=function(t,e){this.store=t,this.makeRootDirectory(e)},e.isAvailable=function(){return!0},e.prototype.getName=function(){return this.store.name()},e.prototype.isReadOnly=function(){return!1},e.prototype.supportsSymlinks=function(){return!1},e.prototype.supportsProps=function(){return!1},e.prototype.supportsSynch=function(){return!1},e.prototype.makeRootDirectory=function(t){var e=this.store.beginTransaction("readwrite");e.get(l,function(n,r){if(n||void 0===r){var i=(new Date).getTime(),o=new s(c(),4096,16895,i,i,i);e.put(o.id,new g("{}"),!1,function(n){p(n,e,t)&&e.put(l,o.toBuffer(),!1,function(n){n?e.abort(function(){t(n)}):e.commit(t)})})}else e.commit(t)})},e.prototype._findINode=function(t,e,n,r){var i=this,o=function(t,i,o){t?r(t):o[n]?r(null,o[n]):r(d.ENOENT(y.resolve(e,n)))};"/"===e?""===n?r(null,l):this.getINode(t,e,l,function(n,s){h(n,r)&&i.getDirListing(t,e,s,function(t,e){o(t,s,e)})}):this.findINodeAndDirListing(t,e,o)},e.prototype.findINode=function(t,e,n){var r=this;this._findINode(t,y.dirname(e),y.basename(e),function(i,o){h(i,n)&&r.getINode(t,e,o,n)})},e.prototype.getINode=function(t,e,n,r){t.get(n,function(t,n){h(t,r)&&(void 0===n?r(d.ENOENT(e)):r(null,s.fromBuffer(n)))})},e.prototype.getDirListing=function(t,e,n,r){n.isDirectory()?t.get(n.id,function(t,n){if(h(t,r))try{r(null,JSON.parse(n.toString()))}catch(t){r(d.ENOENT(e))}}):r(d.ENOTDIR(e))},e.prototype.findINodeAndDirListing=function(t,e,n){var r=this;this.findINode(t,e,function(i,o){h(i,n)&&r.getDirListing(t,e,o,function(t,e){h(t,n)&&n(null,o,e)})})},e.prototype.addNewNode=function(t,e,n){var r,i=0,o=function(){5===++i?n(new d(2,"Unable to commit data to key-value store.")):(r=c(),t.put(r,e,!1,function(t,e){t||!e?o():n(null,r)}))};o()},e.prototype.commitNewFile=function(t,e,n,r,i,o){var a=this,u=y.dirname(e),c=y.basename(e),f=(new Date).getTime();return"/"===e?o(d.EEXIST(e)):void this.findINodeAndDirListing(t,u,function(u,h,l){p(u,t,o)&&(l[c]?t.abort(function(){o(d.EEXIST(e))}):a.addNewNode(t,i,function(e,u){if(p(e,t,o)){var y=new s(u,i.length,r|n,f,f,f);a.addNewNode(t,y.toBuffer(),function(e,n){p(e,t,o)&&(l[c]=n,t.put(h.id,new g(JSON.stringify(l)),!0,function(e){p(e,t,o)&&t.commit(function(e){p(e,t,o)&&o(null,y)})}))})}}))})},e.prototype.empty=function(t){var e=this;this.store.clear(function(n){h(n,t)&&e.makeRootDirectory(t)})},e.prototype.rename=function(t,e,n){var r=this,i=this.store.beginTransaction("readwrite"),o=y.dirname(t),s=y.basename(t),a=y.dirname(e),u=y.basename(e),c={},f={},h=!1;if(0===(a+"/").indexOf(t+"/"))return n(new d(5,o));var l=function(){if(!h&&f.hasOwnProperty(o)&&f.hasOwnProperty(a)){var l=f[o],y=c[o],w=f[a],m=c[a];if(l[s]){var v=l[s];delete l[s];var S=function(){w[u]=v,i.put(y.id,new g(JSON.stringify(l)),!0,function(t){p(t,i,n)&&(o===a?i.commit(n):i.put(m.id,new g(JSON.stringify(w)),!0,function(t){p(t,i,n)&&i.commit(n)}))})};w[u]?r.getINode(i,e,w[u],function(t,r){p(t,i,n)&&(r.isFile()?i.delete(r.id,function(t){p(t,i,n)&&i.delete(w[u],function(t){p(t,i,n)&&S()})}):i.abort(function(){n(d.EPERM(e))}))}):S()}else n(d.ENOENT(t))}},w=function(t){r.findINodeAndDirListing(i,t,function(e,r,o){e?h||(h=!0,i.abort(function(){n(e)})):(c[t]=r,f[t]=o,l())})};w(o),o!==a&&w(a)},e.prototype.stat=function(t,e,n){var r=this.store.beginTransaction("readonly");this.findINode(r,t,function(t,e){h(t,n)&&n(null,e.toStats())})},e.prototype.createFile=function(t,e,n,r){var i=this,o=this.store.beginTransaction("readwrite"),s=new g(0);this.commitNewFile(o,t,32768,n,s,function(n,o){h(n,r)&&r(null,new S(i,t,e,o.toStats(),s))})},e.prototype.openFile=function(t,e,n){var r=this,i=this.store.beginTransaction("readonly");this.findINode(i,t,function(o,s){h(o,n)&&i.get(s.id,function(i,o){h(i,n)&&(void 0===o?n(d.ENOENT(t)):n(null,new S(r,t,e,s.toStats(),o)))})})},e.prototype.removeEntry=function(t,e,n){var r=this,i=this.store.beginTransaction("readwrite"),o=y.dirname(t),s=y.basename(t);this.findINodeAndDirListing(i,o,function(o,a,u){if(p(o,i,n))if(u[s]){var c=u[s];delete u[s],r.getINode(i,t,c,function(r,o){p(r,i,n)&&(!e&&o.isDirectory()?i.abort(function(){n(d.EISDIR(t))}):e&&!o.isDirectory()?i.abort(function(){n(d.ENOTDIR(t))}):i.delete(o.id,function(t){p(t,i,n)&&i.delete(c,function(t){p(t,i,n)&&i.put(a.id,new g(JSON.stringify(u)),!0,function(t){p(t,i,n)&&i.commit(n)})})}))})}else i.abort(function(){n(d.ENOENT(t))})})},e.prototype.unlink=function(t,e){this.removeEntry(t,!1,e)},e.prototype.rmdir=function(t,e){this.removeEntry(t,!0,e)},e.prototype.mkdir=function(t,e,n){var r=this.store.beginTransaction("readwrite"),i=new g("{}");this.commitNewFile(r,t,16384,e,i,n)},e.prototype.readdir=function(t,e){var n=this,r=this.store.beginTransaction("readonly");this.findINode(r,t,function(i,o){h(i,e)&&n.getDirListing(r,t,o,function(t,n){h(t,e)&&e(null,Object.keys(n))})})},e.prototype._sync=function(t,e,n,r){var i=this,o=this.store.beginTransaction("readwrite");this._findINode(o,y.dirname(t),y.basename(t),function(s,a){p(s,o,r)&&i.getINode(o,t,a,function(t,i){if(p(t,o,r)){var s=i.update(n);o.put(i.id,e,!0,function(t){p(t,o,r)&&(s?o.put(a,i.toBuffer(),!0,function(t){p(t,o,r)&&o.commit(r)}):o.commit(r))})}})})},e}(n.BaseFileSystem);e.AsyncKeyValueFileSystem=b}),c("core/global",["require","exports"],function(){var e;return e="undefined"!=typeof window?window:"undefined"!=typeof self?self:t});var f=this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);n.prototype=e.prototype,t.prototype=new n};c("backend/IndexedDB",["require","exports","../core/buffer","../core/browserfs","../generic/key_value_filesystem","../core/api_error","../core/buffer_core_arraybuffer","../core/global"],function(t,e,n,r,i,o,s,a){function u(t,e){switch(void 0===e&&(e=t.toString()),t.name){case"NotFoundError":return new l(1,e);case"QuotaExceededError":return new l(11,e);default:return new l(2,e)}}function c(t,e,n){return void 0===e&&(e=2),void 0===n&&(n=null),function(r){r.preventDefault(),t(new l(e,n))}}function h(t){var e=t.getBufferCore();e instanceof s.BufferCoreArrayBuffer||(t=new p(this._buffer.length),this._buffer.copy(t),e=t.getBufferCore());var n=e.getDataView();return n.buffer}var p=n.Buffer,l=o.ApiError,y=(o.ErrorCode,a.indexedDB||a.mozIndexedDB||a.webkitIndexedDB||a.msIndexedDB),d=function(){function t(t,e){this.tx=t,this.store=e}return t.prototype.get=function(t,e){try{var n=this.store.get(t);n.onerror=c(e),n.onsuccess=function(t){var n=t.target.result;void 0===n?e(null,n):e(null,new p(n))}}catch(r){e(u(r))}},t}();e.IndexedDBROTransaction=d;var g=function(t){function e(e,n){t.call(this,e,n)}return f(e,t),e.prototype.put=function(t,e,n,r){try{var i,o=h(e);i=n?this.store.put(o,t):this.store.add(o,t),i.onerror=c(r),i.onsuccess=function(){r(null,!0)}}catch(s){r(u(s))}},e.prototype.delete=function(t,e){try{var n=this.store.delete(t);n.onerror=c(e),n.onsuccess=function(){e()}}catch(r){e(u(r))}},e.prototype.commit=function(t){setTimeout(t,0)},e.prototype.abort=function(t){var e;try{this.tx.abort()}catch(n){e=u(n)}finally{t(e)}},e}(d);e.IndexedDBRWTransaction=g;var w=function(){function t(t,e){var n=this;void 0===e&&(e="browserfs"),this.storeName=e;var r=y.open(this.storeName,1);r.onupgradeneeded=function(t){var e=t.target.result;e.objectStoreNames.contains(n.storeName)&&e.deleteObjectStore(n.storeName),e.createObjectStore(n.storeName)},r.onsuccess=function(e){n.db=e.target.result,t(null,n)},r.onerror=c(t,4)}return t.prototype.name=function(){return"IndexedDB - "+this.storeName},t.prototype.clear=function(t){try{var e=this.db.transaction(this.storeName,"readwrite"),n=e.objectStore(this.storeName),r=n.clear();r.onsuccess=function(){setTimeout(t,0)},r.onerror=c(t)}catch(i){t(u(i))}},t.prototype.beginTransaction=function(t){void 0===t&&(t="readonly");var e=this.db.transaction(this.storeName,t),n=e.objectStore(this.storeName);if("readwrite"===t)return new g(e,n);if("readonly"===t)return new d(e,n);throw new l(9,"Invalid transaction type.")},t}();e.IndexedDBStore=w;var m=function(t){function e(e,n){var r=this;t.call(this),new w(function(t,n){t?e(t):r.init(n,function(t){e(t,r)})},n)}return f(e,t),e.isAvailable=function(){return"undefined"!=typeof y},e}(i.AsyncKeyValueFileSystem);e.IndexedDBFileSystem=m,r.registerFileSystem("IndexedDB",m)}),c("generic/file_index",["require","exports","../core/node_fs_stats","../core/node_path"],function(t,e,n,r){var i=n.Stats,o=r.path,s=function(){function t(){this._index={},this.addPath("/",new u)}return t.prototype._split_path=function(t){var e=o.dirname(t),n=t.substr(e.length+("/"===e?0:1));return[e,n]},t.prototype.fileIterator=function(t){for(var e in this._index)for(var n=this._index[e],r=n.getListing(),i=0;i0;){var s,c=o.pop(),f=c[0],h=c[1],p=c[2];for(var l in h){var y=h[l],d=""+f+"/"+l;null!=y?(n._index[d]=s=new u,o.push([d,y,s])):s=new a(new i(32768,-1,365)),null!=p&&(p._ls[l]=s)}}return n},t}();e.FileIndex=s;var a=function(){function t(t){this.data=t}return t.prototype.isFile=function(){return!0},t.prototype.isDir=function(){return!1},t.prototype.getData=function(){return this.data},t.prototype.setData=function(t){this.data=t},t}();e.FileInode=a;var u=function(){function t(){this._ls={}}return t.prototype.isFile=function(){return!1},t.prototype.isDir=function(){return!0},t.prototype.getStats=function(){return new i(16384,4096,365)},t.prototype.getListing=function(){return Object.keys(this._ls)},t.prototype.getItem=function(t){var e;return null!=(e=this._ls[t])?e:null},t.prototype.addItem=function(t,e){return t in this._ls?!1:(this._ls[t]=e,!0)},t.prototype.remItem=function(t){var e=this._ls[t];return void 0===e?null:(delete this._ls[t],e)},t}();e.DirInode=u}),c("core/util",["require","exports"],function(t,e){function n(t){var e,n,r,i,o,s;for(r=[],o=[t],e=0;0!==o.length;)if(s=o.pop(),"boolean"==typeof s)e+=4;else if("string"==typeof s)e+=2*s.length;else if("number"==typeof s)e+=8;else if("object"==typeof s&&r.indexOf(s)<0){r.push(s),e+=4;for(n in s)i=s[n],e+=2*n.length,o.push(i)}return e}e.roughSizeOfObject=n,e.isIE="undefined"!=typeof navigator&&(null!=/(msie) ([\w.]+)/.exec(navigator.userAgent.toLowerCase())||-1!==navigator.userAgent.indexOf("Trident")),e.isWebWorker="undefined"==typeof window}),c("generic/xhr",["require","exports","../core/util","../core/buffer","../core/api_error"],function(t,e,n,r,i){function o(t){for(var e=IEBinaryToArray_ByteStr(t),n=IEBinaryToArray_ByteStr_Last(t),r=e.replace(/[\s\S]/g,function(t){var e=t.charCodeAt(0);return String.fromCharCode(255&e,e>>8)})+n,i=new Array(r.length),o=0;o0&&"/"!==n.charAt(n.length-1)&&(n+="/"),this.prefix_url=n;var i=this._requestFileSync(e,"json");if(null==i)throw new Error("Unable to find listing at URL: "+e);this._index=r.FileIndex.from_listing(i)}return f(e,t),e.prototype.empty=function(){this._index.fileIterator(function(t){t.file_data=null})},e.prototype.getXhrPath=function(t){return"/"===t.charAt(0)&&(t=t.slice(1)),this.prefix_url+t},e.prototype._requestFileSizeAsync=function(t,e){c.getFileSizeAsync(this.getXhrPath(t),e)},e.prototype._requestFileSizeSync=function(t){return c.getFileSizeSync(this.getXhrPath(t))},e.prototype._requestFileAsync=function(t,e,n){c.asyncDownloadFile(this.getXhrPath(t),e,n)},e.prototype._requestFileSync=function(t,e){return c.syncDownloadFile(this.getXhrPath(t),e)},e.prototype.getName=function(){return"XmlHttpRequest"},e.isAvailable=function(){return"undefined"!=typeof XMLHttpRequest&&null!==XMLHttpRequest},e.prototype.diskSpace=function(t,e){e(0,0)},e.prototype.isReadOnly=function(){return!0},e.prototype.supportsLinks=function(){return!1},e.prototype.supportsProps=function(){return!1},e.prototype.supportsSynch=function(){return!0},e.prototype.preloadFile=function(t,e){var n=this._index.getInode(t);if(null===n)throw h.ENOENT(t);var r=n.getData();r.size=e.length,r.file_data=e},e.prototype.stat=function(t,e,n){var r=this._index.getInode(t);if(null===r)return n(h.ENOENT(t));var i;r.isFile()?(i=r.getData(),i.size<0?this._requestFileSizeAsync(t,function(t,e){return t?n(t):(i.size=e,void n(null,i.clone()))}):n(null,i.clone())):(i=r.getStats(),n(null,i))},e.prototype.statSync=function(t){var e=this._index.getInode(t);if(null===e)throw h.ENOENT(t);var n;return e.isFile()?(n=e.getData(),n.size<0&&(n.size=this._requestFileSizeSync(t))):n=e.getStats(),n },e.prototype.open=function(t,e,n,r){if(e.isWriteable())return r(new h(0,t));var i=this,o=this._index.getInode(t);if(null===o)return r(h.ENOENT(t));if(o.isDir())return r(h.EISDIR(t));var s=o.getData();switch(e.pathExistsAction()){case 1:case 2:return r(h.EEXIST(t));case 0:if(null!=s.file_data)return r(null,new a.NoSyncFile(i,t,e,s.clone(),s.file_data));this._requestFileAsync(t,"buffer",function(n,o){return n?r(n):(s.size=o.length,s.file_data=o,r(null,new a.NoSyncFile(i,t,e,s.clone(),o)))});break;default:return r(new h(9,"Invalid FileMode object."))}},e.prototype.openSync=function(t,e){if(e.isWriteable())throw new h(0,t);var n=this._index.getInode(t);if(null===n)throw h.ENOENT(t);if(n.isDir())throw h.EISDIR(t);var r=n.getData();switch(e.pathExistsAction()){case 1:case 2:throw h.EEXIST(t);case 0:if(null!=r.file_data)return new a.NoSyncFile(this,t,e,r.clone(),r.file_data);var i=this._requestFileSync(t,"buffer");return r.size=i.length,r.file_data=i,new a.NoSyncFile(this,t,e,r.clone(),i);default:throw new h(9,"Invalid FileMode object.")}},e.prototype.readdir=function(t,e){try{e(null,this.readdirSync(t))}catch(n){e(n)}},e.prototype.readdirSync=function(t){var e=this._index.getInode(t);if(null===e)throw h.ENOENT(t);if(e.isFile())throw h.ENOTDIR(t);return e.getListing()},e.prototype.readFile=function(t,e,n,r){var o=r;this.open(t,n,420,function(t,n){if(t)return r(t);r=function(t,e){n.close(function(n){return null==t&&(t=n),o(t,e)})};var s=n,a=s.getBuffer();if(null===e)return a.length>0?r(t,a.sliceCopy()):r(t,new i.Buffer(0));try{r(null,a.toString(e))}catch(u){r(u)}})},e.prototype.readFileSync=function(t,e,n){var r=this.openSync(t,n,420);try{var o=r,s=o.getBuffer();return null===e?s.length>0?s.sliceCopy():new i.Buffer(0):s.toString(e)}finally{r.closeSync()}},e}(n.BaseFileSystem));e.XmlHttpRequest=p,u.registerFileSystem("XmlHttpRequest",p)});var f=this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);n.prototype=e.prototype,t.prototype=new n};c("backend/async_mirror",["require","exports","../core/file_system","../core/api_error","../core/file_flag","../generic/preload_file","../core/browserfs"],function(t,e,n,r,i,o,s){var a=function(t){function e(e,n,r,i,o){t.call(this,e,n,r,i,o)}return f(e,t),e.prototype.syncSync=function(){this.isDirty()&&(this._fs._syncSync(this),this.resetDirty())},e.prototype.closeSync=function(){this.syncSync()},e}(o.PreloadFile),u=function(t){function e(e,n){if(t.call(this),this._queue=[],this._queueRunning=!1,this._isInitialized=!1,this._sync=e,this._async=n,!e.supportsSynch())throw new Error("Expected synchronous storage.");if(n.supportsSynch())throw new Error("Expected asynchronous storage.")}return f(e,t),e.prototype.getName=function(){return"AsyncMirror"},e.isAvailable=function(){return!0},e.prototype._syncSync=function(t){this._sync.writeFileSync(t.getPath(),t.getBuffer(),null,i.FileFlag.getFileFlag("w"),t.getStats().mode),this.enqueueOp({apiMethod:"writeFile",arguments:[t.getPath(),t.getBuffer(),null,t.getFlag(),t.getStats().mode]})},e.prototype.initialize=function(t){var e=this;if(this._isInitialized)t();else{var n=function(t,n,r){"/"!==t&&e._sync.mkdirSync(t,n),e._async.readdir(t,function(e,n){function i(e){e?r(e):s0){var r=e._queue.shift(),i=r.arguments;i.push(n),e._async[r.apiMethod].apply(e._async,i)}else e._queueRunning=!1};n()}},e.prototype.renameSync=function(t,e){this._sync.renameSync(t,e),this.enqueueOp({apiMethod:"rename",arguments:[t,e]})},e.prototype.statSync=function(t,e){return this._sync.statSync(t,e)},e.prototype.openSync=function(t,e,n){var r=this._sync.openSync(t,e,n);return r.closeSync(),new a(this,t,e,this._sync.statSync(t,!1),this._sync.readFileSync(t,null,i.FileFlag.getFileFlag("r")))},e.prototype.unlinkSync=function(t){this._sync.unlinkSync(t),this.enqueueOp({apiMethod:"unlink",arguments:[t]})},e.prototype.rmdirSync=function(t){this._sync.rmdirSync(t),this.enqueueOp({apiMethod:"rmdir",arguments:[t]})},e.prototype.mkdirSync=function(t,e){this._sync.mkdirSync(t,e),this.enqueueOp({apiMethod:"mkdir",arguments:[t,e]})},e.prototype.readdirSync=function(t){return this._sync.readdirSync(t)},e.prototype.existsSync=function(t){return this._sync.existsSync(t)},e.prototype.chmodSync=function(t,e,n){this._sync.chmodSync(t,e,n),this.enqueueOp({apiMethod:"chmod",arguments:[t,e,n]})},e.prototype.chownSync=function(t,e,n,r){this._sync.chownSync(t,e,n,r),this.enqueueOp({apiMethod:"chown",arguments:[t,e,n,r]})},e.prototype.utimesSync=function(t,e,n){this._sync.utimesSync(t,e,n),this.enqueueOp({apiMethod:"utimes",arguments:[t,e,n]})},e}(n.SynchronousFileSystem);return s.registerFileSystem("AsyncMirrorFS",u),u}),function(){function t(t){var n=!1;return function(){if(n)throw new Error("Callback was already called.");n=!0,t.apply(e,arguments)}}var e,n,r={};e=this,null!=e&&(n=e.async),r.noConflict=function(){return e.async=n,r};var i=function(t,e){if(t.forEach)return t.forEach(e);for(var n=0;n=e.length&&r(null))}))})},r.forEach=r.each,r.eachSeries=function(t,e,n){if(n=n||function(){},!t.length)return n();var r=0,i=function(){e(t[r],function(e){e?(n(e),n=function(){}):(r+=1,r>=t.length?n(null):i())})};i()},r.forEachSeries=r.eachSeries,r.eachLimit=function(t,e,n,r){var i=u(e);i.apply(null,[t,n,r])},r.forEachLimit=r.eachLimit;var u=function(t){return function(e,n,r){if(r=r||function(){},!e.length||0>=t)return r();var i=0,o=0,s=0;!function a(){if(i>=e.length)return r();for(;t>s&&o=e.length?r():a())})}()}},f=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[r.each].concat(e))}},h=function(t,e){return function(){var n=Array.prototype.slice.call(arguments);return e.apply(null,[u(t)].concat(n))}},p=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[r.eachSeries].concat(e))}},l=function(t,e,n,r){var i=[];e=o(e,function(t,e){return{index:e,value:t}}),t(e,function(t,e){n(t.value,function(n,r){i[t.index]=r,e(n)})},function(t){r(t,i)})};r.map=f(l),r.mapSeries=p(l),r.mapLimit=function(t,e,n,r){return y(e)(t,n,r)};var y=function(t){return h(t,l)};r.reduce=function(t,e,n,i){r.eachSeries(t,function(t,r){n(e,t,function(t,n){e=n,r(t)})},function(t){i(t,e)})},r.inject=r.reduce,r.foldl=r.reduce,r.reduceRight=function(t,e,n,i){var s=o(t,function(t){return t}).reverse();r.reduce(s,e,n,i)},r.foldr=r.reduceRight;var d=function(t,e,n,r){var i=[];e=o(e,function(t,e){return{index:e,value:t}}),t(e,function(t,e){n(t.value,function(n){n&&i.push(t),e()})},function(){r(o(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};r.filter=f(d),r.filterSeries=p(d),r.select=r.filter,r.selectSeries=r.filterSeries;var g=function(t,e,n,r){var i=[];e=o(e,function(t,e){return{index:e,value:t}}),t(e,function(t,e){n(t.value,function(n){n||i.push(t),e()})},function(){r(o(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};r.reject=f(g),r.rejectSeries=p(g);var w=function(t,e,n,r){t(e,function(t,e){n(t,function(n){n?(r(t),r=function(){}):e()})},function(){r()})};r.detect=f(w),r.detectSeries=p(w),r.some=function(t,e,n){r.each(t,function(t,r){e(t,function(t){t&&(n(!0),n=function(){}),r()})},function(){n(!1)})},r.any=r.some,r.every=function(t,e,n){r.each(t,function(t,r){e(t,function(t){t||(n(!1),n=function(){}),r()})},function(){n(!0)})},r.all=r.every,r.sortBy=function(t,e,n){r.map(t,function(t,n){e(t,function(e,r){e?n(e):n(null,{value:t,criteria:r})})},function(t,e){if(t)return n(t);var r=function(t,e){var n=t.criteria,r=e.criteria;return r>n?-1:n>r?1:0};n(null,o(e.sort(r),function(t){return t.value}))})},r.auto=function(t,e){e=e||function(){};var n=a(t);if(!n.length)return e(null);var o={},u=[],c=function(t){u.unshift(t)},f=function(t){for(var e=0;ee;e++)t[e].apply(null,arguments)}])))};return i.memo=n,i.unmemoized=t,i},r.unmemoize=function(t){return function(){return(t.unmemoized||t).apply(null,arguments)}},r.times=function(t,e,n){for(var i=[],o=0;t>o;o++)i.push(o);return r.map(i,e,n)},r.timesSeries=function(t,e,n){for(var i=[],o=0;t>o;o++)i.push(o);return r.mapSeries(i,e,n)},r.compose=function(){var t=Array.prototype.reverse.call(arguments);return function(){var e=this,n=Array.prototype.slice.call(arguments),i=n.pop();r.reduce(t,n,function(t,n,r){n.apply(e,t.concat([function(){var t=arguments[0],e=Array.prototype.slice.call(arguments,1);r(t,e)}]))},function(t,n){i.apply(e,[t].concat(n))})}};var b=function(t,e){var n=function(){var n=this,r=Array.prototype.slice.call(arguments),i=r.pop();return t(e,function(t,e){t.apply(n,r.concat([e]))},i)};if(arguments.length>2){var r=Array.prototype.slice.call(arguments,2);return n.apply(this,r)}return n};r.applyEach=f(b),r.applyEachSeries=p(b),r.forever=function(t,e){function n(r){if(r){if(e)return e(r);throw r}t(n)}n()},"undefined"!=typeof c&&c.amd?c("async",[],function(){return r}):"undefined"!=typeof module&&module.exports?module.exports=r:e.async=r}();var f=this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);n.prototype=e.prototype,t.prototype=new n};c("backend/dropbox",["require","exports","../generic/preload_file","../core/file_system","../core/node_fs_stats","../core/buffer","../core/api_error","../core/node_path","../core/browserfs","../core/buffer_core_arraybuffer","async"],function(t,e,n,r,i,o,s,a,u,c){var h=o.Buffer,p=i.Stats,l=s.ApiError,y=(s.ErrorCode,a.path),d=(i.FileType,t("async")),h=o.Buffer,g=function(t){function e(e,n,r,i,o){t.call(this,e,n,r,i,o)}return f(e,t),e.prototype.sync=function(t){var e=this;if(this.isDirty()){var n=this.getBuffer(),r=n.getBufferCore();r instanceof c.BufferCoreArrayBuffer||(n=new h(n.length),this.getBuffer().copy(n),r=n.getBufferCore());var i=r.getDataView(),o=new DataView(i.buffer,i.byteOffset+n.getOffset(),n.length);this._fs._writeFileStrict(this.getPath(),o,function(n){n||e.resetDirty(),t(n)})}else t()},e.prototype.close=function(t){this.sync(t)},e}(n.PreloadFile);e.DropboxFile=g;var w=function(t){function e(e){t.call(this),this.client=e}return f(e,t),e.prototype.getName=function(){return"Dropbox"},e.isAvailable=function(){return"undefined"!=typeof Dropbox},e.prototype.isReadOnly=function(){return!1},e.prototype.supportsSymlinks=function(){return!1},e.prototype.supportsProps=function(){return!1},e.prototype.supportsSynch=function(){return!1},e.prototype.empty=function(t){var e=this;this.client.readdir("/",function(n,r,i,o){if(n)t(e.convert(n));else{var s=function(t,n){e.client.remove(t.path,function(t){n(t?e.convert(t):t)})},a=function(n){n?t(e.convert(n)):t()};d.each(o,s,a)}})},e.prototype.rename=function(t,e,n){this.client.move(t,e,function(r){if(r){var i=r.response.error.indexOf(t)>-1?t:e;n(new l(1,i+" doesn't exist"))}else n()})},e.prototype.stat=function(t,e,n){var r=this;this.client.stat(t,function(e,i){if(!(e||null!=i&&i.isRemoved)){var o=new p(r._statType(i),i.size);return n(null,o)}n(new l(1,t+" doesn't exist"))})},e.prototype.open=function(t,e,n,r){var i=this;this.client.readFile(t,{arrayBuffer:!0},function(n,o,s){if(!n){var a;a=new h(null===o?0:o);var u=i._makeFile(t,e,s,a);return r(null,u)}if(e.isReadable())r(new l(1,t+" doesn't exist"));else switch(n.status){case 0:return console.error("No connection");case 404:var c=new ArrayBuffer(0);return i._writeFileStrict(t,c,function(n,o){if(n)r(n);else{var s=i._makeFile(t,e,o,new h(c));r(null,s)}});default:return console.log("Unhandled error: "+n)}})},e.prototype._writeFileStrict=function(t,e,n){var r=this,i=y.dirname(t);this.stat(i,!1,function(o){o?n(new l(1,"Can't create "+t+" because "+i+" doesn't exist")):r.client.writeFile(t,e,function(t,e){t?n(r.convert(t)):n(null,e)})})},e.prototype._statType=function(t){return t.isFile?32768:16384},e.prototype._makeFile=function(t,e,n,r){var i=this._statType(n),o=new p(i,n.size);return new g(this,t,e,o,r)},e.prototype._remove=function(t,e,n){var r=this;this.client.stat(t,function(i,o){i?e(new l(1,t+" doesn't exist")):o.isFile&&!n?e(new l(7,t+" is a file.")):!o.isFile&&n?e(new l(8,t+" is a directory.")):r.client.remove(t,function(n){e(n?new l(2,"Failed to remove "+t):null)})})},e.prototype.unlink=function(t,e){this._remove(t,e,!0)},e.prototype.rmdir=function(t,e){this._remove(t,e,!1)},e.prototype.mkdir=function(t,e,n){var r=this,i=y.dirname(t);this.client.stat(i,function(e){e?n(new l(1,"Can't create "+t+" because "+i+" doesn't exist")):r.client.mkdir(t,function(e){n(e?new l(6,t+" already exists"):null)})})},e.prototype.readdir=function(t,e){var n=this;this.client.readdir(t,function(t,r){return t?e(n.convert(t)):e(null,r)})},e.prototype.convert=function(t,e){switch(void 0===e&&(e=""),t.status){case 400:return new l(9,e);case 401:case 403:return new l(2,e);case 404:return new l(1,e);case 405:return new l(14,e);case 0:case 304:case 406:case 409:default:return new l(2,e)}},e}(r.BaseFileSystem);e.DropboxFileSystem=w,u.registerFileSystem("Dropbox",w)});var f=this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);n.prototype=e.prototype,t.prototype=new n};c("backend/html5fs",["require","exports","../generic/preload_file","../core/file_system","../core/api_error","../core/file_flag","../core/node_fs_stats","../core/buffer","../core/browserfs","../core/buffer_core_arraybuffer","../core/node_path","../core/global","async"],function(t,e,n,r,i,o,s,a,u,c,h,p){function l(t,e,n,r){if("undefined"!=typeof navigator.webkitPersistentStorage)switch(t){case p.PERSISTENT:navigator.webkitPersistentStorage.requestQuota(e,n,r);break;case p.TEMPORARY:navigator.webkitTemporaryStorage.requestQuota(e,n,r);break;default:r(null)}else p.webkitStorageInfo.requestQuota(t,e,n,r)}function y(t){return Array.prototype.slice.call(t||[],0)}var d=a.Buffer,g=s.Stats,w=(s.FileType,i.ApiError),m=(i.ErrorCode,o.ActionType,t("async")),v=p.webkitRequestFileSystem||p.requestFileSystem||null,S=function(t){function e(e,n,r,i,o){t.call(this,e,n,r,i,o)}return f(e,t),e.prototype.sync=function(t){var e=this;if(this.isDirty()){var n={create:!1},r=this._fs,i=function(n){n.createWriter(function(n){var i=e.getBuffer(),o=i.getBufferCore();o instanceof c.BufferCoreArrayBuffer||(i=new d(i.length),e.getBuffer().copy(i),o=i.getBufferCore());var s=o.getDataView(),a=new DataView(s.buffer,s.byteOffset+i.getOffset(),i.length),u=new Blob([a]),f=u.size;n.onwriteend=function(){n.onwriteend=null,n.truncate(f),e.resetDirty(),t()},n.onerror=function(e){t(r.convert(e))},n.write(u)})},o=function(e){t(r.convert(e))};r.fs.root.getFile(this.getPath(),n,i,o)}else t()},e.prototype.close=function(t){this.sync(t)},e}(n.PreloadFile);e.HTML5FSFile=S;var b=function(t){function e(e,n){t.call(this),this.size=null!=e?e:5,this.type=null!=n?n:p.PERSISTENT;var r=1024,i=r*r;this.size*=i}return f(e,t),e.prototype.getName=function(){return"HTML5 FileSystem"},e.isAvailable=function(){return null!=v},e.prototype.isReadOnly=function(){return!1},e.prototype.supportsSymlinks=function(){return!1},e.prototype.supportsProps=function(){return!1},e.prototype.supportsSynch=function(){return!1},e.prototype.convert=function(t,e){switch(void 0===e&&(e=""),t.name){case"QuotaExceededError":return new w(11,e);case"NotFoundError":return new w(1,e);case"SecurityError":return new w(4,e);case"InvalidModificationError":return new w(0,e);case"SyntaxError":case"TypeMismatchError":return new w(9,e);default:return new w(9,e)}},e.prototype.convertErrorEvent=function(t,e){return void 0===e&&(e=""),new w(1,t.message+"; "+e)},e.prototype.allocate=function(t){var e=this;void 0===t&&(t=function(){});var n=function(n){e.fs=n,t()},r=function(n){t(e.convert(n))};this.type===p.PERSISTENT?l(this.type,this.size,function(t){v(e.type,t,n,r)},r):v(this.type,this.size,n,r)},e.prototype.empty=function(t){var e=this;this._readdir("/",function(n,r){if(n)console.error("Failed to empty FS"),t(n);else{var i=function(){n?(console.error("Failed to empty FS"),t(n)):t()},o=function(t,n){var r=function(){n()},i=function(r){n(e.convert(r,t.fullPath))};t.isFile?t.remove(r,i):t.removeRecursively(r,i)};m.each(r,o,i)}})},e.prototype.rename=function(t,e,n){var r=this,i=2,o=0,s=this.fs.root,a=function(o){0===--i&&n(r.convert(o,"Failed to rename "+t+" to "+e+"."))},u=function(i){return 2===++o?void console.error("Something was identified as both a file and a directory. This should never happen."):t===e?n():void s.getDirectory(h.path.dirname(e),{},function(o){i.moveTo(o,h.path.basename(e),function(){n()},function(o){i.isDirectory?r.unlink(e,function(i){i?a(o):r.rename(t,e,n)}):a(o)})},a)};s.getFile(t,{},u,a),s.getDirectory(t,{},u,a)},e.prototype.stat=function(t,e,n){var r=this,i={create:!1},o=function(t){var e=function(t){var e=new g(32768,t.size);n(null,e)};t.file(e,a)},s=function(){var t=4096,e=new g(16384,t);n(null,e)},a=function(e){n(r.convert(e,t))},u=function(){r.fs.root.getDirectory(t,i,s,a)};this.fs.root.getFile(t,i,o,u)},e.prototype.open=function(t,e,n,r){var i=this,o={create:3===e.pathNotExistsAction(),exclusive:e.isExclusive()},s=function(e){r(i.convertErrorEvent(e,t))},a=function(e){r(i.convert(e,t))},u=function(n){var o=function(n){var o=new FileReader;o.onloadend=function(){var s=i._makeFile(t,e,n,o.result);r(null,s)},o.onerror=s,o.readAsArrayBuffer(n)};n.file(o,a)};this.fs.root.getFile(t,o,u,s)},e.prototype._statType=function(t){return t.isFile?32768:16384},e.prototype._makeFile=function(t,e,n,r){void 0===r&&(r=new ArrayBuffer(0));var i=new g(32768,n.size),o=new d(r);return new S(this,t,e,i,o)},e.prototype._remove=function(t,e,n){var r=this,i=function(n){var i=function(){e()},o=function(n){e(r.convert(n,t))};n.remove(i,o)},o=function(n){e(r.convert(n,t))},s={create:!1};n?this.fs.root.getFile(t,s,i,o):this.fs.root.getDirectory(t,s,i,o)},e.prototype.unlink=function(t,e){this._remove(t,e,!0)},e.prototype.rmdir=function(t,e){this._remove(t,e,!1)},e.prototype.mkdir=function(t,e,n){var r=this,i={create:!0,exclusive:!0},o=function(){n()},s=function(e){n(r.convert(e,t))};this.fs.root.getDirectory(t,i,o,s)},e.prototype._readdir=function(t,e){var n=this;this.fs.root.getDirectory(t,{create:!1},function(r){var i=r.createReader(),o=[],s=function(r){e(n.convert(r,t))},a=function(){i.readEntries(function(t){t.length?(o=o.concat(y(t)),a()):e(null,o)},s)};a()})},e.prototype.readdir=function(t,e){this._readdir(t,function(t,n){if(null!=t)return e(t);for(var r=[],i=0;i0&&t[0]instanceof i.ApiError&&a.standardizeError(t[0],o.path,r),s.apply(null,t)}}return o.fs[t].apply(o.fs,e)}}var u=i.ApiError,c=(i.ErrorCode,o.fs),h=function(t){function e(){t.call(this),this.mntMap={},this.rootFs=new r.InMemoryFileSystem}return f(e,t),e.prototype.mount=function(t,e){if(this.mntMap[t])throw new u(9,"Mount point "+t+" is already taken.");this.rootFs.mkdirSync(t,511),this.mntMap[t]=e},e.prototype.umount=function(t){if(!this.mntMap[t])throw new u(9,"Mount point "+t+" is already unmounted.");delete this.mntMap[t],this.rootFs.rmdirSync(t)},e.prototype._get_fs=function(t){for(var e in this.mntMap){var n=this.mntMap[e];if(0===t.indexOf(e))return t=t.substr(e.length>1?e.length:0),""===t&&(t="/"),{fs:n,path:t}}return{fs:this.rootFs,path:t}},e.prototype.getName=function(){return"MountableFileSystem"},e.isAvailable=function(){return!0},e.prototype.diskSpace=function(t,e){e(0,0)},e.prototype.isReadOnly=function(){return!1},e.prototype.supportsLinks=function(){return!1},e.prototype.supportsProps=function(){return!1},e.prototype.supportsSynch=function(){return!0},e.prototype.standardizeError=function(t,e,n){var r;return-1!==(r=t.message.indexOf(e))&&(t.message=t.message.substr(0,r)+n+t.message.substr(r+e.length)),t},e.prototype.rename=function(t,e,n){var r=this._get_fs(t),i=this._get_fs(e);if(r.fs===i.fs){var o=this;return r.fs.rename(r.path,i.path,function(s){s&&o.standardizeError(o.standardizeError(s,r.path,t),i.path,e),n(s)})}return c.readFile(t,function(r,i){return r?n(r):void c.writeFile(e,i,function(e){return e?n(e):void c.unlink(t,n)})})},e.prototype.renameSync=function(t,e){var n=this._get_fs(t),r=this._get_fs(e);if(n.fs===r.fs)try{return n.fs.renameSync(n.path,r.path)}catch(i){throw this.standardizeError(this.standardizeError(i,n.path,t),r.path,e),i}var o=c.readFileSync(t);return c.writeFileSync(e,o),c.unlinkSync(t)},e}(n.BaseFileSystem);e.MountableFileSystem=h;for(var p=[["readdir","exists","unlink","rmdir","readlink"],["stat","mkdir","realpath","truncate"],["open","readFile","chmod","utimes"],["chown"],["writeFile","appendFile"]],l=0;l0)throw new h(13,"Path "+e+" not empty.")}this._writable.existsSync(t)?this._writable.renameSync(t,e):this._writable.existsSync(e)||this._writable.mkdirSync(e,o),this._readable.existsSync(t)&&this._readable.readdirSync(t).forEach(function(r){n.renameSync(c.resolve(t,r),c.resolve(e,r))})}else{if(this.existsSync(e)&&this.statSync(e,!1).isDirectory())throw new h(8,"Path "+e+" is a directory.");this.writeFileSync(e,this.readFileSync(t,null,i.FileFlag.getFileFlag("r")),null,i.FileFlag.getFileFlag("w"),r.mode)}t!==e&&this.existsSync(t)&&this.unlinkSync(t)},e.prototype.statSync=function(t,e){try{return this._writable.statSync(t,e)}catch(n){if(this._deletedFiles[t])throw new h(1,"Path "+t+" does not exist.");var r=this._readable.statSync(t,e).clone();return r.mode=u(r.mode),r}},e.prototype.openSync=function(t,e,n){if(this.existsSync(t))switch(e.pathExistsAction()){case 2:return this.createParentDirectories(t),this._writable.openSync(t,e,n);case 0:return!this._writable.existsSync(t)&&this._readable.existsSync(t)&&this.copyToWritable(t),this._writable.openSync(t,e,n);default:throw new h(6,"Path "+t+" exists.")}else switch(e.pathNotExistsAction()){case 3:return this.createParentDirectories(t),this._writable.openSync(t,e,n);default:throw new h(1,"Path "+t+" does not exist.")}},e.prototype.unlinkSync=function(t){if(!this.existsSync(t))throw new h(1,"Path "+t+" does not exist.");this._writable.existsSync(t)&&this._writable.unlinkSync(t),this.existsSync(t)&&this.deletePath(t)},e.prototype.rmdirSync=function(t){if(!this.existsSync(t))throw new h(1,"Path "+t+" does not exist.");if(this._writable.existsSync(t)&&this._writable.rmdirSync(t),this.existsSync(t)){if(this.readdirSync(t).length>0)throw new h(13,"Directory "+t+" is not empty.");this.deletePath(t)}},e.prototype.mkdirSync=function(t,e){if(this.existsSync(t))throw new h(6,"Path "+t+" already exists.");this.createParentDirectories(t),this._writable.mkdirSync(t,e)},e.prototype.readdirSync=function(t){var e=this,n=this.statSync(t,!1);if(!n.isDirectory())throw new h(7,"Path "+t+" is not a directory.");var r=[];try{r=r.concat(this._writable.readdirSync(t))}catch(i){}try{r=r.concat(this._readable.readdirSync(t))}catch(i){}var o={};return r.filter(function(n){var r=void 0===o[n]&&e._deletedFiles[t+"/"+n]!==!0;return o[n]=!0,r})},e.prototype.existsSync=function(t){return this._writable.existsSync(t)||this._readable.existsSync(t)&&this._deletedFiles[t]!==!0},e.prototype.chmodSync=function(t,e,n){var r=this;this.operateOnWritable(t,function(){r._writable.chmodSync(t,e,n)})},e.prototype.chownSync=function(t,e,n,r){var i=this;this.operateOnWritable(t,function(){i._writable.chownSync(t,e,n,r)})},e.prototype.utimesSync=function(t,e,n){var r=this;this.operateOnWritable(t,function(){r._writable.utimesSync(t,e,n)})},e.prototype.operateOnWritable=function(t,e){if(!this.existsSync(t))throw new h(1,"Path "+t+" does not exist.");this._writable.existsSync(t)||this.copyToWritable(t),e()},e.prototype.copyToWritable=function(t){var e=this.statSync(t,!1);e.isDirectory()?this._writable.mkdirSync(t,e.mode):this.writeFileSync(t,this._readable.readFileSync(t,null,i.FileFlag.getFileFlag("r")),null,i.FileFlag.getFileFlag("w"),this.statSync(t,!1).mode)},e}(n.SynchronousFileSystem));return s.registerFileSystem("OverlayFS",l),l});var f=this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);n.prototype=e.prototype,t.prototype=new n};c("backend/workerfs",["require","exports","../core/file_system","../core/buffer","../core/api_error","../core/file_flag","../core/file","../core/node_fs_stats","../generic/preload_file","../core/browserfs"],function(t,e,n,r,i,o,s,a,u,c){function h(t){return{type:2,errorData:t.writeToBuffer().toArrayBuffer()}}function p(t){return i.ApiError.fromBuffer(new S(t.errorData))}function l(t){return{type:3,statsData:t.toBuffer().toArrayBuffer()}}function y(t){return a.Stats.fromBuffer(new S(t.statsData))}function d(t){return{type:5,flagStr:t.getFlagString()}}function g(t){return o.FileFlag.getFileFlag(t.flagStr)}function w(t){return{type:6,data:t.toArrayBuffer()}}function m(t){return new S(t.data)}var v,S=r.Buffer;!function(t){t[t.CB=0]="CB",t[t.FD=1]="FD",t[t.ERROR=2]="ERROR",t[t.STATS=3]="STATS",t[t.PROBE=4]="PROBE",t[t.FILEFLAG=5]="FILEFLAG",t[t.BUFFER=6]="BUFFER"}(v||(v={}));var b=function(){function t(){this._callbacks={},this._nextId=0}return t.prototype.toRemoteArg=function(t){var e=this._nextId++;return this._callbacks[e]=t,{type:0,id:e}},t.prototype.toLocalArg=function(t){var e=this._callbacks[t];return delete this._callbacks[t],e},t}(),E=function(){function t(){this._fileDescriptors={},this._nextId=0}return t.prototype.toRemoteArg=function(t,e,n,r){var i,o,s=this._nextId++;this._fileDescriptors[s]=t,t.stat(function(a,u){a?r(a):(o=u.toBuffer().toArrayBuffer(),n.isReadable()?t.read(new S(u.size),0,u.size,0,function(t,a,u){t?r(t):(i=u.toArrayBuffer(),r(null,{type:1,id:s,data:i,stat:o,path:e,flag:n.getFlagString()}))}):r(null,{type:1,id:s,data:new ArrayBuffer(0),stat:o,path:e,flag:n.getFlagString()}))})},t.prototype._applyFdChanges=function(t,e){var n=this._fileDescriptors[t.id],r=new S(t.data),i=a.Stats.fromBuffer(new S(t.stat)),s=o.FileFlag.getFileFlag(t.flag);s.isWriteable()?n.write(r,0,r.length,s.isAppendable()?n.getPos():0,function(t){function o(){n.stat(function(t,r){t?e(t):r.mode!==i.mode?n.chmod(i.mode,function(t){e(t,n)}):e(t,n)})}t?e(t):s.isAppendable()?o():n.truncate(r.length,function(){o()})}):e(null,n)},t.prototype.applyFdAPIRequest=function(t,e){var n=this,r=t.args[0];this._applyFdChanges(r,function(i,o){i?e(i):o[t.method](function(i){"close"===t.method&&delete n._fileDescriptors[r.id],e(i)})})},t}(),_=function(t){function e(e,n,r,i,o,s){t.call(this,e,n,r,i,s),this._remoteFdId=o}return f(e,t),e.prototype.getRemoteFdId=function(){return this._remoteFdId},e.prototype.toRemoteArg=function(){return{type:1,id:this._remoteFdId,data:this.getBuffer().toArrayBuffer(),stat:this.getStats().toBuffer().toArrayBuffer(),path:this.getPath(),flag:this.getFlag().getFlagString()}},e.prototype._syncClose=function(t,e){var n=this;this.isDirty()?this._fs.syncClose(t,this,function(t){t||n.resetDirty(),e(t)}):e()},e.prototype.sync=function(t){this._syncClose("sync",t)},e.prototype.close=function(t){this._syncClose("close",t)},e}(u.PreloadFile),I=function(t){function e(e){var n=this;t.call(this),this._callbackConverter=new b,this._isInitialized=!1,this._isReadOnly=!1,this._supportLinks=!1,this._supportProps=!1,this._outstandingRequests={},this._worker=e,this._worker.addEventListener("message",function(t){if("object"==typeof t.data&&t.data.hasOwnProperty("browserfsMessage")&&t.data.browserfsMessage){var e,r=t.data,i=r.args,o=new Array(i.length);for(e=0;e0&&(u=-1,s={browserfsMessage:!0,cbId:o,args:[h(e)]},t.postMessage(s))}var i,s,a=new Array(arguments.length),u=arguments.length;for(i=0;ic;++c)t[c]>l&&(l=t[c]),t[c]=r;){for(c=0;p>c;++c)if(t[c]===r){for(s=0,u=i,f=0;r>f;++f)s=s<<1|1&u,u>>=1;for(h=r<<16|c,f=s;e>f;f+=o)n[f]=h;++i}++r,i<<=1,o<<=1}return[n,l,y]}function n(t,e){switch(this.g=[],this.h=32768,this.c=this.f=this.d=this.k=0,this.input=a?new Uint8Array(t):t,this.l=!1,this.i=c,this.q=!1,(e||!(e={}))&&(e.index&&(this.d=e.index),e.bufferSize&&(this.h=e.bufferSize),e.bufferType&&(this.i=e.bufferType),e.resize&&(this.q=e.resize)),this.i){case u:this.a=32768,this.b=new(a?Uint8Array:Array)(32768+this.h+258);break;case c:this.a=0,this.b=new(a?Uint8Array:Array)(this.h),this.e=this.v,this.m=this.s,this.j=this.t;break;default:throw Error("invalid inflate mode")}}function r(t,e){for(var n,r=t.f,i=t.c,o=t.input,s=t.d,a=o.length;e>i;){if(s>=a)throw Error("input buffer is broken");r|=o[s++]<>>e,t.c=i-e,t.d=s,n}function i(t,e){for(var n,r,i=t.f,o=t.c,s=t.input,a=t.d,u=s.length,c=e[0],f=e[1];f>o&&!(a>=u);)i|=s[a++]<>>16,t.f=i>>r,t.c=o-r,t.d=a,65535&n}function o(t){function n(t,e,n){var o,s,a,u=this.p;for(a=0;t>a;)switch(o=i(this,e)){case 16:for(s=3+r(this,2);s--;)n[a++]=u;break;case 17:for(s=3+r(this,3);s--;)n[a++]=0;u=0;break;case 18:for(s=11+r(this,7);s--;)n[a++]=0;u=0;break;default:u=n[a++]=o}return this.p=u,n}var o,s,u,c,f=r(t,5)+257,h=r(t,5)+1,p=r(t,4)+4,y=new(a?Uint8Array:Array)(l.length);for(c=0;p>c;++c)y[l[c]]=r(t,3);if(!a)for(c=p,p=y.length;p>c;++c)y[l[c]]=0;o=e(y),s=new(a?Uint8Array:Array)(f),u=new(a?Uint8Array:Array)(h),t.p=0,t.j(e(n.call(t,f,o,s)),e(n.call(t,h,o,u)))}var s=this,a="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array&&"undefined"!=typeof DataView,u=0,c=1;n.prototype.u=function(){for(;!this.l;){var t=r(this,3);switch(1&t&&(this.l=!0),t>>>=1){case 0:var e=this.input,n=this.d,i=this.b,s=this.a,f=e.length,h=void 0,p=void 0,l=i.length,y=void 0;if(this.c=this.f=0,n+1>=f)throw Error("invalid uncompressed block header: LEN");if(h=e[n++]|e[n++]<<8,n+1>=f)throw Error("invalid uncompressed block header: NLEN");if(p=e[n++]|e[n++]<<8,h===~p)throw Error("invalid uncompressed block header: length verify");if(n+h>e.length)throw Error("input buffer is broken");switch(this.i){case u:for(;s+h>i.length;){if(y=l-s,h-=y,a)i.set(e.subarray(n,n+y),s),s+=y,n+=y;else for(;y--;)i[s++]=e[n++];this.a=s,i=this.e(),s=this.a}break;case c:for(;s+h>i.length;)i=this.e({o:2});break;default:throw Error("invalid inflate mode")}if(a)i.set(e.subarray(n,n+h),s),s+=h,n+=h;else for(;h--;)i[s++]=e[n++];this.d=n,this.a=s,this.b=i;break;case 1:this.j(F,x);break;case 2:o(this);break;default:throw Error("unknown BTYPE: "+t)}}return this.m()};var f,h,p=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],l=a?new Uint16Array(p):p,y=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],d=a?new Uint16Array(y):y,g=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],w=a?new Uint8Array(g):g,m=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],v=a?new Uint16Array(m):m,S=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],b=a?new Uint8Array(S):S,E=new(a?Uint8Array:Array)(288);for(f=0,h=E.length;h>f;++f)E[f]=143>=f?8:255>=f?9:279>=f?7:8;var _,I,F=e(E),A=new(a?Uint8Array:Array)(30);for(_=0,I=A.length;I>_;++_)A[_]=5;var x=e(A);n.prototype.j=function(t,e){var n=this.b,o=this.a;this.n=t;for(var s,a,u,c,f=n.length-258;256!==(s=i(this,t));)if(256>s)o>=f&&(this.a=o,n=this.e(),o=this.a),n[o++]=s;else for(a=s-257,c=d[a],0=f&&(this.a=o,n=this.e(),o=this.a);c--;)n[o]=n[o++-u];for(;8<=this.c;)this.c-=8,this.d--;this.a=o},n.prototype.t=function(t,e){var n=this.b,o=this.a;this.n=t;for(var s,a,u,c,f=n.length;256!==(s=i(this,t));)if(256>s)o>=f&&(n=this.e(),f=n.length),n[o++]=s;else for(a=s-257,c=d[a],0f&&(n=this.e(),f=n.length);c--;)n[o]=n[o++-u];for(;8<=this.c;)this.c-=8,this.d--;this.a=o},n.prototype.e=function(){var t,e,n=new(a?Uint8Array:Array)(this.a-32768),r=this.a-32768,i=this.b;if(a)n.set(i.subarray(32768,n.length));else for(t=0,e=n.length;e>t;++t)n[t]=i[t+32768];if(this.g.push(n),this.k+=n.length,a)i.set(i.subarray(r,r+32768));else for(t=0;32768>t;++t)i[t]=i[r+t];return this.a=32768,i},n.prototype.v=function(t){var e,n,r,i,o=this.input.length/this.d+1|0,s=this.input,u=this.b;return t&&("number"==typeof t.o&&(o=t.o),"number"==typeof t.r&&(o+=t.r)),2>o?(n=(s.length-this.d)/this.n[2],i=258*(n/2)|0,r=ie;++e)for(t=u[e],r=0,i=t.length;i>r;++r)c[o++]=t[r];for(e=32768,n=this.a;n>e;++e)c[o++]=s[e];return this.g=[],this.buffer=c},n.prototype.s=function(){var t,e=this.a;return a?this.q?(t=new Uint8Array(e),t.set(this.b.subarray(0,e))):t=this.b.subarray(0,e):(this.b.length>e&&(this.b.length=e),t=this.b),this.buffer=t},t("Zlib.RawInflate",n),t("Zlib.RawInflate.prototype.decompress",n.prototype.u);var D,L,N,k,O={ADAPTIVE:c,BLOCK:u};if(Object.keys)D=Object.keys(O);else for(L in D=[],N=0,O)D[N++]=L;for(N=0,k=D.length;k>N;++N)L=D[N],t("Zlib.RawInflate.BufferType."+L,O[L])}.call(this),c("zlib",function(t){return function(){var e;return e||t.Zlib.RawInflate}}(this));var f=this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);n.prototype=e.prototype,t.prototype=new n};c("backend/zipfs",["require","exports","../core/buffer","../core/api_error","../generic/file_index","../core/browserfs","../core/node_fs_stats","../core/file_system","../core/file_flag","../core/buffer_core_arraybuffer","../generic/preload_file","zlib"],function(t,e,n,r,i,o,s,a,u,c,h){function p(t,e){var n=31&e,r=(e>>5&15)-1,i=(e>>9)+1980,o=31&t,s=t>>5&63,a=t>>11;return new Date(i,r,n,a,s,o)}function l(t,e,n,r){return 0===r?"":t.toString(e?"utf8":"extended_ascii",n,n+r)}var y=r.ApiError,d=(r.ErrorCode,u.ActionType,Zlib.RawInflate);!function(t){t[t.MSDOS=0]="MSDOS",t[t.AMIGA=1]="AMIGA",t[t.OPENVMS=2]="OPENVMS",t[t.UNIX=3]="UNIX",t[t.VM_CMS=4]="VM_CMS",t[t.ATARI_ST=5]="ATARI_ST",t[t.OS2_HPFS=6]="OS2_HPFS",t[t.MAC=7]="MAC",t[t.Z_SYSTEM=8]="Z_SYSTEM",t[t.CP_M=9]="CP_M",t[t.NTFS=10]="NTFS",t[t.MVS=11]="MVS",t[t.VSE=12]="VSE",t[t.ACORN_RISC=13]="ACORN_RISC",t[t.VFAT=14]="VFAT",t[t.ALT_MVS=15]="ALT_MVS",t[t.BEOS=16]="BEOS",t[t.TANDEM=17]="TANDEM",t[t.OS_400=18]="OS_400",t[t.OSX=19]="OSX"}(e.ExternalFileAttributeType||(e.ExternalFileAttributeType={}));e.ExternalFileAttributeType;!function(t){t[t.STORED=0]="STORED",t[t.SHRUNK=1]="SHRUNK",t[t.REDUCED_1=2]="REDUCED_1",t[t.REDUCED_2=3]="REDUCED_2",t[t.REDUCED_3=4]="REDUCED_3",t[t.REDUCED_4=5]="REDUCED_4",t[t.IMPLODE=6]="IMPLODE",t[t.DEFLATE=8]="DEFLATE",t[t.DEFLATE64=9]="DEFLATE64",t[t.TERSE_OLD=10]="TERSE_OLD",t[t.BZIP2=12]="BZIP2",t[t.LZMA=14]="LZMA",t[t.TERSE_NEW=18]="TERSE_NEW",t[t.LZ77=19]="LZ77",t[t.WAVPACK=97]="WAVPACK",t[t.PPMD=98]="PPMD"}(e.CompressionMethod||(e.CompressionMethod={}));var g=e.CompressionMethod,w=function(){function t(t){if(this.data=t,67324752!==t.readUInt32LE(0))throw new y(9,"Invalid Zip file: Local file header has invalid signature: "+this.data.readUInt32LE(0))}return t.prototype.versionNeeded=function(){return this.data.readUInt16LE(4)},t.prototype.flags=function(){return this.data.readUInt16LE(6)},t.prototype.compressionMethod=function(){return this.data.readUInt16LE(8)},t.prototype.lastModFileTime=function(){return p(this.data.readUInt16LE(10),this.data.readUInt16LE(12))},t.prototype.crc32=function(){return this.data.readUInt32LE(14)},t.prototype.fileNameLength=function(){return this.data.readUInt16LE(26)},t.prototype.extraFieldLength=function(){return this.data.readUInt16LE(28)},t.prototype.fileName=function(){return l(this.data,this.useUTF8(),30,this.fileNameLength())},t.prototype.extraField=function(){var t=30+this.fileNameLength();return this.data.slice(t,t+this.extraFieldLength())},t.prototype.totalSize=function(){return 30+this.fileNameLength()+this.extraFieldLength()},t.prototype.useUTF8=function(){return 2048===(2048&this.flags())},t}();e.FileHeader=w;var m=function(){function t(t,e,n){this.header=t,this.record=e,this.data=n}return t.prototype.decompress=function(){var t=this.data,e=this.header.compressionMethod();switch(e){case 8:if(t.getBufferCore()instanceof c.BufferCoreArrayBuffer){var r=t.getBufferCore(),i=r.getDataView(),o=i.byteOffset+t.getOffset(),s=new Uint8Array(i.buffer).subarray(o,o+this.record.compressedSize()),a=new d(s).decompress();return new n.Buffer(new c.BufferCoreArrayBuffer(a.buffer),a.byteOffset,a.byteOffset+a.length)}var u=t.slice(0,this.record.compressedSize());return new n.Buffer(new d(u.toJSON().data).decompress());case 0:return t.sliceCopy(0,this.record.uncompressedSize());default:var f=g[e];throw f=f?f:"Unknown: "+e,new y(9,"Invalid compression method on file '"+this.header.fileName()+"': "+f)}},t}();e.FileData=m;var v=function(){function t(t){this.data=t}return t.prototype.crc32=function(){return this.data.readUInt32LE(0)},t.prototype.compressedSize=function(){return this.data.readUInt32LE(4)},t.prototype.uncompressedSize=function(){return this.data.readUInt32LE(8)},t}();e.DataDescriptor=v;var S=function(){function t(t){if(this.data=t,134630224!==this.data.readUInt32LE(0))throw new y(9,"Invalid archive extra data record signature: "+this.data.readUInt32LE(0))}return t.prototype.length=function(){return this.data.readUInt32LE(4)},t.prototype.extraFieldData=function(){return this.data.slice(8,8+this.length())},t}();e.ArchiveExtraDataRecord=S;var b=function(){function t(t){if(this.data=t,84233040!==this.data.readUInt32LE(0))throw new y(9,"Invalid digital signature signature: "+this.data.readUInt32LE(0))}return t.prototype.size=function(){return this.data.readUInt16LE(4)},t.prototype.signatureData=function(){return this.data.slice(6,6+this.size())},t}();e.DigitalSignature=b;var E=function(){function t(t,e){if(this.zipData=t,this.data=e,33639248!==this.data.readUInt32LE(0))throw new y(9,"Invalid Zip file: Central directory record has invalid signature: "+this.data.readUInt32LE(0))}return t.prototype.versionMadeBy=function(){return this.data.readUInt16LE(4)},t.prototype.versionNeeded=function(){return this.data.readUInt16LE(6)},t.prototype.flag=function(){return this.data.readUInt16LE(8)},t.prototype.compressionMethod=function(){return this.data.readUInt16LE(10)},t.prototype.lastModFileTime=function(){return p(this.data.readUInt16LE(12),this.data.readUInt16LE(14))},t.prototype.crc32=function(){return this.data.readUInt32LE(16)},t.prototype.compressedSize=function(){return this.data.readUInt32LE(20)},t.prototype.uncompressedSize=function(){return this.data.readUInt32LE(24)},t.prototype.fileNameLength=function(){return this.data.readUInt16LE(28)},t.prototype.extraFieldLength=function(){return this.data.readUInt16LE(30)},t.prototype.fileCommentLength=function(){return this.data.readUInt16LE(32)},t.prototype.diskNumberStart=function(){return this.data.readUInt16LE(34)},t.prototype.internalAttributes=function(){return this.data.readUInt16LE(36)},t.prototype.externalAttributes=function(){return this.data.readUInt32LE(38)},t.prototype.headerRelativeOffset=function(){return this.data.readUInt32LE(42)},t.prototype.fileName=function(){var t=l(this.data,this.useUTF8(),46,this.fileNameLength());return t.replace(/\\/g,"/")},t.prototype.extraField=function(){var t=44+this.fileNameLength();return this.data.slice(t,t+this.extraFieldLength())},t.prototype.fileComment=function(){var t=46+this.fileNameLength()+this.extraFieldLength();return l(this.data,this.useUTF8(),t,this.fileCommentLength())},t.prototype.totalSize=function(){return 46+this.fileNameLength()+this.extraFieldLength()+this.fileCommentLength()},t.prototype.isDirectory=function(){var t=this.fileName();return(16&this.externalAttributes()?!0:!1)||"/"===t.charAt(t.length-1)},t.prototype.isFile=function(){return!this.isDirectory()},t.prototype.useUTF8=function(){return 2048===(2048&this.flag())},t.prototype.isEncrypted=function(){return 1===(1&this.flag())},t.prototype.getData=function(){var t=this.headerRelativeOffset(),e=new w(this.zipData.slice(t)),n=new m(e,this,this.zipData.slice(t+e.totalSize()));return n.decompress()},t.prototype.getStats=function(){return new s.Stats(32768,this.uncompressedSize(),365,new Date,this.lastModFileTime())},t}();e.CentralDirectory=E;var _=function(){function t(t){if(this.data=t,101010256!==this.data.readUInt32LE(0))throw new y(9,"Invalid Zip file: End of central directory record has invalid signature: "+this.data.readUInt32LE(0))}return t.prototype.diskNumber=function(){return this.data.readUInt16LE(4)},t.prototype.cdDiskNumber=function(){return this.data.readUInt16LE(6)},t.prototype.cdDiskEntryCount=function(){return this.data.readUInt16LE(8)},t.prototype.cdTotalEntryCount=function(){return this.data.readUInt16LE(10)},t.prototype.cdSize=function(){return this.data.readUInt32LE(12)},t.prototype.cdOffset=function(){return this.data.readUInt32LE(16)},t.prototype.cdZipComment=function(){return l(this.data,!0,22,this.data.readUInt16LE(20))},t}();e.EndOfCentralDirectory=_;var I=function(t){function e(e,n){void 0===n&&(n=""),t.call(this),this.data=e,this.name=n,this._index=new i.FileIndex,this.populateIndex()}return f(e,t),e.prototype.getName=function(){return"ZipFS"+(""!==this.name?" "+this.name:"")},e.isAvailable=function(){return!0},e.prototype.diskSpace=function(t,e){e(this.data.length,0)},e.prototype.isReadOnly=function(){return!0},e.prototype.supportsLinks=function(){return!1},e.prototype.supportsProps=function(){return!1},e.prototype.supportsSynch=function(){return!0},e.prototype.statSync=function(t){var e=this._index.getInode(t);if(null===e)throw new y(1,""+t+" not found.");var n;return n=e.isFile()?e.getData().getStats():e.getStats()},e.prototype.openSync=function(t,e){if(e.isWriteable())throw new y(0,t);var n=this._index.getInode(t);if(null===n)throw new y(1,""+t+" is not in the FileIndex.");if(n.isDir())throw new y(8,""+t+" is a directory.");var r=n.getData(),i=r.getStats();switch(e.pathExistsAction()){case 1:case 2:throw new y(6,""+t+" already exists.");case 0:return new h.NoSyncFile(this,t,e,i,r.getData());default:throw new y(9,"Invalid FileMode object.")}return null},e.prototype.readdirSync=function(t){var e=this._index.getInode(t);if(null===e)throw new y(1,""+t+" not found.");if(e.isFile())throw new y(7,""+t+" is a file, not a directory.");return e.getListing()},e.prototype.readFileSync=function(t,e,r){var i=this.openSync(t,r,420);try{var o=i,s=o.getBuffer();return null===e?s.length>0?s.sliceCopy():new n.Buffer(0):s.toString(e)}finally{i.closeSync()}},e.prototype.getEOCD=function(){for(var t=22,e=Math.min(t+65535,this.data.length-1),n=t;e>n;n++)if(101010256===this.data.readUInt32LE(this.data.length-n))return new _(this.data.slice(this.data.length-n));throw new y(9,"Invalid ZIP file: Could not locate End of Central Directory signature.")},e.prototype.populateIndex=function(){var t=this.getEOCD();if(t.diskNumber()!==t.cdDiskNumber())throw new y(9,"ZipFS does not support spanned zip files.");var e=t.cdOffset();if(4294967295===e)throw new y(9,"ZipFS does not support Zip64.");for(var n=e+t.cdSize();n>e;){var r=new E(this.data,this.data.slice(e));e+=r.totalSize();var o=r.fileName();if("/"===o.charAt(0))throw new Error("WHY IS THIS ABSOLUTE");"/"===o.charAt(o.length-1)&&(o=o.substr(0,o.length-1)),r.isDirectory()?this._index.addPath("/"+o,new i.DirInode):this._index.addPath("/"+o,new i.FileInode(r))}},e}(a.SynchronousFileSystem);e.ZipFS=I,o.registerFileSystem("ZipFS",I)}),t.BrowserFS=u("core/browserfs"),u("generic/emscripten_fs"),u("backend/IndexedDB"),u("backend/XmlHttpRequest"),u("backend/async_mirror"),u("backend/dropbox"),u("backend/html5fs"),u("backend/in_memory"),u("backend/localStorage"),u("backend/mountable_file_system"),u("backend/overlay"),u("backend/workerfs"),u("backend/zipfs")}(this);