"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.promisify=e;varr="__ES6-PROMISIFY--CUSTOM-ARGUMENTS__";functione(n){if("function"!=typeofn)thrownewTypeError("Argument to promisify must be a function");varo=n[r],t=e.Promise||Promise;if("function"!=typeoft)thrownewError("No Promise implementation found; do you need a polyfill?");returnfunction(){for(varr=this,e=arguments.length,i=newArray(e),f=0;f<e;f++)i[f]=arguments[f];returnnewt(function(e,t){i.push(function(r){if(r)returnt(r);for(varn=arguments.length,i=newArray(n>1?n-1:0),f=1;f<n;f++)i[f-1]=arguments[f];if(1===i.length||!o)returne(i[0]);varu={};i.forEach(function(r,e){varn=o[e];n&&(u[n]=r)}),e(u)}),n.apply(r,i)})}}e.argumentNames=r,e.Promise=void0;
vart,e,n=module.exports={};functionr(){thrownewError("setTimeout has not been defined")}functiono(){thrownewError("clearTimeout has not been defined")}functioni(e){if(t===setTimeout)returnsetTimeout(e,0);if((t===r||!t)&&setTimeout)returnt=setTimeout,setTimeout(e,0);try{returnt(e,0)}catch(n){try{returnt.call(null,e,0)}catch(n){returnt.call(this,e,0)}}}functionu(t){if(e===clearTimeout)returnclearTimeout(t);if((e===o||!e)&&clearTimeout)returne=clearTimeout,clearTimeout(t);try{returne(t)}catch(n){try{returne.call(null,t)}catch(n){returne.call(this,t)}}}!function(){try{t="function"==typeofsetTimeout?setTimeout:r}catch(n){t=r}try{e="function"==typeofclearTimeout?clearTimeout:o}catch(n){e=o}}();varc,s=[],l=!1,a=-1;functionf(){l&&c&&(l=!1,c.length?s=c.concat(s):a=-1,s.length&&h())}functionh(){if(!l){vart=i(f);l=!0;for(vare=s.length;e;){for(c=s,s=[];++a<e;)c&&c[a].run();a=-1,e=s.length}c=null,l=!1,u(t)}}functionm(t,e){this.fun=t,this.array=e}functionp(){}n.nextTick=function(t){vare=newArray(arguments.length-1);if(arguments.length>1)for(varn=1;n<arguments.length;n++)e[n-1]=arguments[n];s.push(newm(t,e)),1!==s.length||l||i(h)},m.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.env={},n.argv=[],n.version="",n.versions={},n.on=p,n.addListener=p,n.once=p,n.off=p,n.removeListener=p,n.removeAllListeners=p,n.emit=p,n.prependListener=p,n.prependOnceListener=p,n.listeners=function(t){return[]},n.binding=function(t){thrownewError("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(t){thrownewError("process.chdir is not supported")},n.umask=function(){return0};
varr=require("process");functiont(r,t){for(vare=0,n=r.length-1;n>=0;n--){varo=r[n];"."===o?r.splice(n,1):".."===o?(r.splice(n,1),e++):e&&(r.splice(n,1),e--)}if(t)for(;e--;e)r.unshift("..");returnr}functione(r){"string"!=typeofr&&(r+="");vart,e=0,n=-1,o=!0;for(t=r.length-1;t>=0;--t)if(47===r.charCodeAt(t)){if(!o){e=t+1;break}}else-1===n&&(o=!1,n=t+1);return-1===n?"":r.slice(e,n)}functionn(r,t){if(r.filter)returnr.filter(t);for(vare=[],n=0;n<r.length;n++)t(r[n],n,r)&&e.push(r[n]);returne}exports.resolve=function(){for(vare="",o=!1,s=arguments.length-1;s>=-1&&!o;s--){vari=s>=0?arguments[s]:r.cwd();if("string"!=typeofi)thrownewTypeError("Arguments to path.resolve must be strings");i&&(e=i+"/"+e,o="/"===i.charAt(0))}return(o?"/":"")+(e=t(n(e.split("/"),function(r){return!!r}),!o).join("/"))||"."},exports.normalize=function(r){vare=exports.isAbsolute(r),s="/"===o(r,-1);return(r=t(n(r.split("/"),function(r){return!!r}),!e).join("/"))||e||(r="."),r&&s&&(r+="/"),(e?"/":"")+r},exports.isAbsolute=function(r){return"/"===r.charAt(0)},exports.join=function(){varr=Array.prototype.slice.call(arguments,0);returnexports.normalize(n(r,function(r,t){if("string"!=typeofr)thrownewTypeError("Arguments to path.join must be strings");returnr}).join("/"))},exports.relative=function(r,t){functione(r){for(vart=0;t<r.length&&""===r[t];t++);for(vare=r.length-1;e>=0&&""===r[e];e--);returnt>e?[]:r.slice(t,e-t+1)}r=exports.resolve(r).substr(1),t=exports.resolve(t).substr(1);for(varn=e(r.split("/")),o=e(t.split("/")),s=Math.min(n.length,o.length),i=s,u=0;u<s;u++)if(n[u]!==o[u]){i=u;break}varf=[];for(u=i;u<n.length;u++)f.push("..");return(f=f.concat(o.slice(i))).join("/")},exports.sep="/",exports.delimiter=":",exports.dirname=function(r){if("string"!=typeofr&&(r+=""),0===r.length)return".";for(vart=r.charCodeAt(0),e=47===t,n=-1,o=!0,s=r.length-1;s>=1;--s)if(47===(t=r.charCodeAt(s))){if(!o){n=s;break}}elseo=!1;return-1===n?e?"/":".":e&&1===n?"/":r.slice(0,n)},exports.basename=function(r,t){varn=e(r);returnt&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},exports.extname=function(r){"string"!=typeofr&&(r+="");for(vart=-1,e=0,n=-1,o=!0,s=0,i=r.length-1;i>=0;--i){varu=r.charCodeAt(i);if(47!==u)-1===n&&(o=!1,n=i+1),46===u?-1===t?t=i:1!==s&&(s=1):-1!==t&&(s=-1);elseif(!o){e=i+1;break}}return-1===t||-1===n||0===s||1===s&&t===n-1&&t===e+1?"":r.slice(t,n)};varo="b"==="ab".substr(-1)?function(r,t,e){returnr.substr(t,e)}:function(r,t,e){returnt<0&&(t=r.length+t),r.substr(t,e)};
"use strict";exports.byteLength=u,exports.toByteArray=i,exports.fromByteArray=d;for(varr=[],t=[],e="undefined"!=typeofUint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,a=n.length;o<a;++o)r[o]=n[o],t[n.charCodeAt(o)]=o;functionh(r){vart=r.length;if(t%4>0)thrownewError("Invalid string. Length must be a multiple of 4");vare=r.indexOf("=");return-1===e&&(e=t),[e,e===t?0:4-e%4]}functionu(r){vart=h(r),e=t[0],n=t[1];return3*(e+n)/4-n}functionc(r,t,e){return3*(t+e)/4-e}functioni(r){varn,o,a=h(r),u=a[0],i=a[1],f=newe(c(r,u,i)),A=0,d=i>0?u-4:u;for(o=0;o<d;o+=4)n=t[r.charCodeAt(o)]<<18|t[r.charCodeAt(o+1)]<<12|t[r.charCodeAt(o+2)]<<6|t[r.charCodeAt(o+3)],f[A++]=n>>16&255,f[A++]=n>>8&255,f[A++]=255&n;return2===i&&(n=t[r.charCodeAt(o)]<<2|t[r.charCodeAt(o+1)]>>4,f[A++]=255&n),1===i&&(n=t[r.charCodeAt(o)]<<10|t[r.charCodeAt(o+1)]<<4|t[r.charCodeAt(o+2)]>>2,f[A++]=n>>8&255,f[A++]=255&n),f}functionf(t){returnr[t>>18&63]+r[t>>12&63]+r[t>>6&63]+r[63&t]}functionA(r,t,e){for(varn,o=[],a=t;a<e;a+=3)n=(r[a]<<16&16711680)+(r[a+1]<<8&65280)+(255&r[a+2]),o.push(f(n));returno.join("")}functiond(t){for(vare,n=t.length,o=n%3,a=[],h=0,u=n-o;h<u;h+=16383)a.push(A(t,h,h+16383>u?u:h+16383));return1===o?(e=t[n-1],a.push(r[e>>2]+r[e<<4&63]+"==")):2===o&&(e=(t[n-2]<<8)+t[n-1],a.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),a.join("")}t["-".charCodeAt(0)]=62,t["_".charCodeAt(0)]=63;
vart=arguments[3],r=require("base64-js"),e=require("ieee754"),n=require("isarray");functioni(){try{vart=newUint8Array(1);returnt.__proto__={__proto__:Uint8Array.prototype,foo:function(){return42}},42===t.foo()&&"function"==typeoft.subarray&&0===t.subarray(1,1).byteLength}catch(r){return!1}}functiono(){returnf.TYPED_ARRAY_SUPPORT?2147483647:1073741823}functionu(t,r){if(o()<r)thrownewRangeError("Invalid typed array length");returnf.TYPED_ARRAY_SUPPORT?(t=newUint8Array(r)).__proto__=f.prototype:(null===t&&(t=newf(r)),t.length=r),t}functionf(t,r,e){if(!(f.TYPED_ARRAY_SUPPORT||thisinstanceoff))returnnewf(t,r,e);if("number"==typeoft){if("string"==typeofr)thrownewError("If encoding is specified then the first argument must be a string");returnc(this,t)}returns(this,t,r,e)}functions(t,r,e,n){if("number"==typeofr)thrownewTypeError('"value" argument must not be a number');return"undefined"!=typeofArrayBuffer&&rinstanceofArrayBuffer?g(t,r,e,n):"string"==typeofr?l(t,r,e):y(t,r)}functionh(t){if("number"!=typeoft)thrownewTypeError('"size" argument must be a number');if(t<0)thrownewRangeError('"size" argument must not be negative')}functiona(t,r,e,n){returnh(r),r<=0?u(t,r):void0!==e?"string"==typeofn?u(t,r).fill(e,n):u(t,r).fill(e):u(t,r)}functionc(t,r){if(h(r),t=u(t,r<0?0:0|w(r)),!f.TYPED_ARRAY_SUPPORT)for(vare=0;e<r;++e)t[e]=0;returnt}functionl(t,r,e){if("string"==typeofe&&""!==e||(e="utf8"),!f.isEncoding(e))thrownewTypeError('"encoding" must be a valid string encoding');varn=0|v(r,e),i=(t=u(t,n)).write(r,e);returni!==n&&(t=t.slice(0,i)),t}functionp(t,r){vare=r.length<0?0:0|w(r.length);t=u(t,e);for(varn=0;n<e;n+=1)t[n]=255&r[n];returnt}functiong(t,r,e,n){if(r.byteLength,e<0||r.byteLength<e)thrownewRangeError("'offset' is out of bounds");if(r.byteLength<e+(n||0))thrownewRangeError("'length' is out of bounds");returnr=void0===e&&void0===n?newUint8Array(r):void0===n?newUint8Array(r,e):newUint8Array(r,e,n),f.TYPED_ARRAY_SUPPORT?(t=r).__proto__=f.prototype:t=p(t,r),t}functiony(t,r){if(f.isBuffer(r)){vare=0|w(r.length);return0===(t=u(t,e)).length?t:(r.copy(t,0,0,e),t)}if(r){if("undefined"!=typeofArrayBuffer&&r.bufferinstanceofArrayBuffer||"length"inr)return"number"!=typeofr.length||W(r.length)?u(t,0):p(t,r);if("Buffer"===r.type&&n(r.data))returnp(t,r.data)}thrownewTypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}functionw(t){if(t>=o())thrownewRangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return0|t}functiond(t){return+t!=t&&(t=0),f.alloc(+t)}functionv(t,r){if(f.isBuffer(t))returnt.length;if("undefined"!=typeofArrayBuffer&&"function"==typeofArrayBuffer.isView&&(ArrayBuffer.isView(t)||tinstanceofArrayBuffer))returnt.byteLength;"string"!=typeoft&&(t=""+t);vare=t.length;if(0===e)return0;for(varn=!1;;)switch(r){case"ascii":case"latin1":case"binary":returne;case"utf8":case"utf-8":casevoid0:return$(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return2*e;case"hex":returne>>>1;case"base64":returnK(t).length;default:if(n)return$(t).length;r=(""+r).toLowerCase(),n=!0}}functionE(t,r,e){varn=!1;if((void0===r||r<0)&&(r=0),r>this.length)return"";if((void0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":returnx(this,r,e);case"utf8":case"utf-8":returnY(this,r,e);case"ascii":returnL(this,r,e);case"latin1":case"binary":returnD(this,r,e);case"base64":returnS(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":returnC(this,r,e);default:if(n)thrownewTypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}functionb(t,r,e){varn=t[r];t[r]=t[e],t[e]=n}functionR(t,r,e,n,i){if(0===t.length)return-1;if("string"==typeofe?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=i?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(i)return-1;e=t.length-1}elseif(e<0){if(!i)return-1;e=0}if("string"==typeofr&&(r=f.from(r,n)),f.
vart=require("../constants.js").FILE_SYSTEM_NAME,e=require("../../lib/async.js").setImmediate,o=function(){vart={};returnfunction(e){returnObject.prototype.hasOwnProperty.call(t,e)||(t[e]={}),t[e]}}();functionn(t,e){this.readOnly=e,this.objectStore=t}functionr(e){this.name=e||t}n.prototype.clear=function(t){if(this.readOnly)e(function(){t("[MemoryContext] Error: write operation on read only context")});else{varo=this.objectStore;Object.keys(o).forEach(function(t){deleteo[t]}),e(t)}},n.prototype.getObject=n.prototype.getBuffer=function(t,o){varn=this;e(function(){o(null,n.objectStore[t])})},n.prototype.putObject=n.prototype.putBuffer=function(t,o,n){this.readOnly?e(function(){n("[MemoryContext] Error: write operation on read only context")}):(this.objectStore[t]=o,e(n))},n.prototype.delete=function(t,o){this.readOnly?e(function(){o("[MemoryContext] Error: write operation on read only context")}):(deletethis.objectStore[t],e(o))},r.isSupported=function(){return!0},r.prototype.open=function(t){this.db=o(this.name),e(t)},r.prototype.getReadOnlyContext=function(){returnnewn(this.db,!0)},r.prototype.getReadWriteContext=function(){returnnewn(this.db,!1)},module.exports=r;
vart={};["3:EACCES:permission denied","9:EBADF:bad file descriptor","10:EBUSY:resource busy or locked","18:EINVAL:invalid argument","27:ENOTDIR:not a directory","28:EISDIR:illegal operation on a directory","34:ENOENT:no such file or directory","47:EEXIST:file already exists","50:EPERM:operation not permitted","51:ELOOP:too many symbolic links encountered","53:ENOTEMPTY:directory not empty","55:EIO:i/o error","1000:ENOTMOUNTED:not mounted","1001:EFILESYSTEMERROR:missing super node, use 'FORMAT' flag to format filesystem.","1002:ENOATTR:attribute does not exist"].forEach(function(e){varo=+(e=e.split(":"))[0],r=e[1],i=e[2];functions(t,e){Error.call(this),this.name=r,this.code=r,this.errno=o,this.message=t||i,e&&(this.path=e),this.stack=newError(this.message).stack}s.prototype=Object.create(Error.prototype),s.prototype.constructor=s,s.prototype.toString=function(){vart=this.path?", '"+this.path+"'":"";returnthis.name+": "+this.message+t},t[r]=t[o]=s}),module.exports=t;
vare=require("../lib/eventemitter.js"),t=require("./path.js"),n=require("../lib/intercom.js");functionr(){e.call(this);varr,i,o=this,s=!1;functionc(e){(i===e||s&&0===e.indexOf(r))&&o.trigger("change","change",e)}o.start=function(e,o,a){if(!i){if(t.isNull(e))thrownewError("Path must be a string without null bytes.");i=t.normalize(e),(s=!0===a)&&(r="/"===i?"/":i+"/"),n.getInstance().on("change",c)}},o.close=function(){n.getInstance().off("change",c),o.removeAllListeners("change")}}r.prototype=newe,r.prototype.constructor=r,module.exports=r;
functiont(t,i){if(!(tinstanceofi))thrownewTypeError("Cannot call a class as a function")}functioni(t,i){for(vars=0;s<i.length;s++){vare=i[s];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"ine&&(e.writable=!0),Object.defineProperty(t,e.key,e)}}functions(t,s,e){returns&&i(t.prototype,s),e&&i(t,e),t}vare=require("./constants"),n=e.NODE_TYPE_FILE,r=e.NODE_TYPE_DIRECTORY,a=e.NODE_TYPE_SYMBOLIC_LINK,o=e.DEFAULT_FILE_PERMISSIONS,u=e.DEFAULT_DIR_PERMISSIONS,h=require("./constants").fsConstants,c=h.S_IFREG,f=h.S_IFDIR,m=h.S_IFLNK;functiond(t,i,s){if(t[i])returns();t.guid(function(e,n){if(e)returns(e);t[i]=n,s()})}functionl(t,i){switch(t){caser:return(i||u)|f;casea:return(i||o)|m;casen:default:return(i||o)|c}}varp=function(){functioni(s){t(this,i);vare=Date.now();this.id=s.id,this.data=s.data,this.size=s.size||0,this.atime=s.atime||e,this.ctime=s.ctime||e,this.mtime=s.mtime||e,this.flags=s.flags||[],this.xattrs=s.xattrs||{},this.nlinks=s.nlinks||0,"string"==typeofs.type?this.type=s.type:"string"==typeofs.mode?this.type=s.mode:this.type=n,this.permissions=s.permissions||l(this.type),this.uid=s.uid||0,this.gid=s.gid||0}returns(i,[{key:"toJSON",value:function(){return{id:this.id,data:this.data,size:this.size,atime:this.atime,ctime:this.ctime,mtime:this.ctime,flags:this.flags,xattrs:this.xattrs,nlinks:this.nlinks,mode:this.type,permissions:this.permissions,uid:this.uid,gid:this.gid}}},{key:"mode",get:function(){returnl(this.type,this.permissions)},set:function(t){this.permissions=t}}]),i}();module.exports.create=function(t,i){d(t,"id",function(s){if(s)returni(s);d(t,"data",function(s){if(s)returni(s);i(null,newp(t))})})};
vare=require("buffer").Buffer;functiont(e){return(t="function"==typeofSymbol&&"symbol"==typeofSymbol.iterator?function(e){returntypeofe}:function(e){returne&&"function"==typeofSymbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeofe})(e)}varn=require("../path.js"),i=n.normalize,o=n.dirname,r=n.basename,u=n.isAbsolute,a=require("../shared.js"),c=require("../constants.js"),f=c.NODE_TYPE_FILE,l=c.NODE_TYPE_DIRECTORY,s=c.NODE_TYPE_SYMBOLIC_LINK,p=c.NODE_TYPE_META,d=c.FULL_READ_WRITE_EXEC_PERMISSIONS,m=c.ROOT_DIRECTORY_NAME,E=c.SUPER_NODE_ID,g=c.SYMLOOP_MAX,w=c.O_READ,O=c.O_WRITE,b=c.O_CREATE,y=c.O_EXCLUSIVE,v=c.O_APPEND,N=c.O_FLAGS,I=c.XATTR_CREATE,h=c.XATTR_REPLACE,A=c.FS_NOMTIME,D=c.FS_NOCTIME,j=require("../errors.js"),T=require("../directory-entry.js"),L=require("../open-files.js"),R=require("../open-file-description.js"),_=require("../super-node.js"),F=require("../node.js"),V=require("../stats.js");functionS(e,t,n,i,o){varr=e.flags;r.includes(D)&&deletei.ctime,r.includes(A)&&deletei.mtime;varu=!1;functiona(n){e.changes.push({event:"change",path:t}),o(n)}i.ctime&&(n.ctime=i.ctime,n.atime=i.ctime,u=!0),i.atime&&(n.atime=i.atime,u=!0),i.mtime&&(n.mtime=i.mtime,u=!0),u?e.putObject(n.id,n,a):a()}functionB(e,t,n,u){if(n!==l&&n!==f)returnu(newj.EINVAL("type must be a directory or file",t));t=i(t);vara,c,s,p=r(t),d=o(t);functionm(n,i){!n&&i?u(newj.EEXIST("path name already exists",t)):!n||ninstanceofj.ENOENT?e.getObject(a.data,E):u(n)}functionE(t,i){t?u(t):(c=i,F.create({guid:e.guid,type:n},function(t,n){t?u(t):((s=n).nlinks+=1,e.putObject(s.id,s,w))}))}functiong(t){if(t)u(t);else{varn=Date.now();S(e,d,s,{mtime:n,ctime:n},u)}}functionw(t){t?u(t):(c[p]=newT(s.id,n),e.putObject(a.data,c,g))}P(e,d,function(n,i){n?u(n):i.type!==l?u(newj.ENOTDIR("a component of the path prefix is not a directory",t)):(a=i,P(e,t,m))})}functionP(e,t,n){if(!(t=i(t)))returnn(newj.ENOENT("path is an empty string"));varu=r(t),a=o(t),c=0;functionf(t,i){if(t)returnn(t);varo=new_(i);o&&o.type===p&&o.rnode?e.getObject(o.rnode,d):n(newj.EFILESYSTEMERROR)}functiond(e,t){e?n(e):t?F.create(t,n):n(newj.ENOENT)}functionw(i,o){i?n(i):o.type===l&&o.data?e.getObject(o.data,O):n(newj.ENOTDIR("a component of the path prefix is not a directory",t))}functionO(i,o){if(i)n(i);elseif(Object.prototype.hasOwnProperty.call(o,u)){varr=o[u].id;e.getObject(r,b)}elsen(newj.ENOENT(null,t))}functionb(e,t){if(e)returnn(e);F.create(t,y)}functiony(l,p){vard;l?n(l):p.type===s?++c>g?n(newj.ELOOP(null,t)):(d=p.data,d=i(d),a=o(d),u=r(d),m===u?e.getObject(E,f):P(e,a,w)):n(null,p)}m===u?e.getObject(E,f):P(e,a,w)}functionx(e,t,n,i,o,r,u){vara=n.xattrs;r===I&&Object.prototype.hasOwnProperty.call(a,i)?u(newj.EEXIST("attribute already exists",t)):r!==h||Object.prototype.hasOwnProperty.call(a,i)?(a[i]=o,e.putObject(n.id,n,function(i){i?u(i):S(e,t,n,{ctime:Date.now()},u)})):u(newj.ENOATTR(null,t))}functionk(e,t){varn,i,o;functionr(o){o?t(o):F.create({guid:e.guid,id:n.rnode,type:l},function(n,o){n?t(n):((i=o).nlinks+=1,e.putObject(i.id,i,u))})}functionu(n){n?t(n):(o={},e.putObject(i.data,o,t))}e.getObject(E,function(i,o){!i&&o?t():!i||iinstanceofj.ENOENT?_.create({guid:e.guid},function(i,o){i?t(i):(n=o,e.putObject(n.id,n,r))}):t(i)})}functionC(e,t,n){t=i(t);varu,a,c,f,s=r(t),p=o(t);functiond(t,i){t?n(t):(c=i,e.getObject(c.data,m))}functionm(t,i){t?n(t):(f=i,F.create({guid:e.guid,type:l},function(t,i){t?n(t):((u=i).nlinks+=1,e.putObject(u.id,u,E))}))}functionE(t){t?n(t):(a={},e.putObject(u.data,a,w))}functiong(t){if(t)n(t);else{vari=Date.now();S(e,p,c,{mtime:i,ctime:i},n)}}functionw(t){t?n(t):(f[s]=newT(u.id,l),e.putObject(c.data,f,g))}P(e,t,function(i,o){!i&&o?n(newj.EEXIST(null,t)):!i||iinstanceofj.ENOENT?P(e,p,d):n(i)})}functionX(e,t,n,o){varr=c.fsConstants,u=r.F_OK,a=r.R_OK,f=r.W_OK,l=r.X_OK,s=r.S_IXUSR,p=r.S_IXGRP,d=r.S_IXOTH;P(e,t=i(t),function(e,i){if(e)returno(e);if(n===u)returno(null);varr=Ve(i.mode,o);returnr?n&(a|f)?o(null):n&l&&r&(s|p|d)?o(null):voido(newj.EACCES("permission denied",t)):void0}
vare=require("buffer").Buffer,r=require("es6-promisify"),t=r.promisify,n=require("../path.js"),a=require("../providers/index.js"),s=require("../shell/shell.js"),o=require("../../lib/intercom.js"),i=require("../fs-watcher.js"),u=require("../errors.js"),m=require("../shared.js"),c=m.nop,f=m.guid,l=require("../constants.js"),h=l.fsConstants,p=l.FILE_SYSTEM_NAME,d=l.FS_FORMAT,g=l.FS_READY,b=l.FS_PENDING,A=l.FS_ERROR,P=l.FS_NODUPEIDCHECK,v=l.STDIN,y=l.STDOUT,E=l.STDERR,R=require("./implementation.js");functionw(e){return"function"==typeofe?e:function(e){if(e)throwe}}functionS(e){e&&console.error("Filer error: ",e)}functionO(e){if(!(e&&e.protocol&&e.pathname))returne;if("file:"!==e.protocol)thrownewu.EINVAL("only file: URLs are supported for paths",e);for(varr=e.pathname,t=0;t<r.length;t++)if("%"===r[t]){varn=32|r.codePointAt(t+2);if("2"===r[t+1]&&102===n)thrownewu.EINVAL("file: URLs must not include encoded / characters",e)}returndecodeURIComponent(r)}functionx(r){returne.isBuffer(r)?r.toString():r}functionF(e,r){returne?n.isNull(e)?newu.EINVAL("Path must be a string without null bytes.",e):r||n.isAbsolute(e)?void0:newu.EINVAL("Path must be absolute.",e):newu.EINVAL("Path must be a string",e)}function_(e,r,t){varn=e[r],a=F(n=x(n=O(n)),t);if(a)throwa;e[r]=n}functionq(e,r){r=r||S;varm=(e=e||{}).flags||[],l=e.guid?e.guid:f,O=e.provider||newa.Default(e.name||p),x=e.name||O.name,F=m.includes(d),I=this;I.readyState=b,I.name=x,I.error=null,I.stdin=v,I.stdout=y,I.stderr=E,I.constants=h,I.F_OK=h.F_OK,I.R_OK=h.R_OK,I.W_OK=h.W_OK,I.X_OK=h.X_OK,this.Shell=s.bind(void0,this);varN=[];functionj(e){returnfunction(r){m.includes(P)?r(null,l()):functionr(t){varn=l();e.getObject(n,function(e,a){e?t(e):a?r(t):t(null,n)})}(r)}}this.queueOrRun=function(e){varr;returng===I.readyState?e.call(I):A===I.readyState?r=newu.EFILESYSTEMERROR("unknown error"):N.push(e),r},this.watch=function(e,r,t){if(n.isNull(e))thrownewError("Path must be a string without null bytes.");"function"==typeofr&&(t=r,r={}),r=r||{},t=t||c;vara=newi;returna.start(e,!1,r.recursive),a.on("change",t),a},O.open(function(e){functiont(e){functiont(e){varr=O[e]();returnr.name=x,r.flags=m,r.changes=[],r.guid=j(r),r.close=function(){vare=r.changes;!function(e){if(e.length){varr=o.getInstance();e.forEach(function(e){r.emit(e.event,e.path)})}}(e),e.length=0},r}I.provider={openReadWriteContext:function(){returnt("getReadWriteContext")},openReadOnlyContext:function(){returnt("getReadOnlyContext")}},I.readyState=e?A:g,N.forEach(function(e){e.call(this)}.bind(I)),N=null,r(e,I)}if(e)returnt(e);varn=O.getReadWriteContext();n.guid=j(n),F?n.clear(function(e){if(e)returnt(e);R.ensureRootDirectory(n,t)}):R.ensureRootDirectory(n,t)}),q.prototype.promises={},[{name:"appendFile",promises:!0,absPathArgs:[0]},{name:"access",promises:!0,absPathArgs:[0]},{name:"chown",promises:!0,absPathArgs:[0]},{name:"chmod",promises:!0,absPathArgs:[0]},{name:"close"},{name:"exists",absPathArgs:[0]},{name:"fchown"},{name:"fchmod"},{name:"fgetxattr"},{name:"fremovexattr"},{name:"fsetxattr"},{name:"fstat"},{name:"fsync"},{name:"ftruncate"},{name:"futimes"},{name:"getxattr",promises:!0,absPathArgs:[0]},{name:"link",promises:!0,absPathArgs:[0,1]},{name:"lseek"},{name:"lstat",promises:!0},{name:"mkdir",promises:!0,absPathArgs:[0]},{name:"mkdtemp",promises:!0},{name:"mknod",promises:!0,absPathArgs:[0]},{name:"open",promises:!0,absPathArgs:[0]},{name:"readdir",promises:!0,absPathArgs:[0]},{name:"read"},{name:"readFile",promises:!0,absPathArgs:[0]},{name:"readlink",promises:!0,absPathArgs:[0]},{name:"removexattr",promises:!0,absPathArgs:[0]},{name:"rename",promises:!0,absPathArgs:[0,1]},{name:"rmdir",promises:!0,absPathArgs:[0]},{name:"setxattr",promises:!0,absPathArgs:[0]},{name:"stat",promises:!0,absPathArgs:[0]},{name:"symlink",promises:!0,relPathArgs:[0],absPathArgs:[1]},{name:"truncate",promises:!0,absPathArgs:[0]},{name:"unlink",promises:!0,absPathArgs:[0]},{name:"utimes",promises:!0,absPathArgs:[0]},{name:"writeFile",promises:!0,absPathArgs:[0]},{name:"write"}].forEach(