text: /**
   * skylark-browserfs - A version of browserfs that ported to running on skylarkjs.
   * @author 
   * @version v0.9.0
   * @link 
   * @license MIT
   */
  !function(t,e){var r=e.define,require=e.require,s="function"==typeof r&&r.amd,i=!s&&"undefined"!=typeof exports;if(!s&&!r){var n={};r=e.define=function(t,e,r){"function"==typeof r?(n[t]={factory:r,deps:e.map(function(e){return function(t,e){if("."!==t[0])return t;var r=e.split("/"),s=t.split("/");r.pop();for(var i=0;i<s.length;i++)"."!=s[i]&&(".."==s[i]?r.pop():r.push(s[i]));return r.join("/")}(e,t)}),resolved:!1,exports:null},require(t)):n[t]={factory:null,resolved:!0,exports:r}},require=e.require=function(t){if(!n.hasOwnProperty(t))throw new Error("Module "+t+" has not been defined");var module=n[t];if(!module.resolved){var r=[];module.deps.forEach(function(t){r.push(require(t))}),module.exports=module.factory.apply(e,r)||null,module.resolved=!0}return module.exports}}if(!r)throw new Error("The module utility (ex: requirejs or skylark-utils) is not loaded!");if(function(t,require){t("skylark-browserfs/libs/process",["skylark-langx-executive/process"],function(t){"use strict";return t}),t("skylark-browserfs/libs/buffers",["skylark-langx-binary/buffer"],function(t){"use strict";return{Buffer:t}}),t("skylark-browserfs/core/api_error",["../libs/buffers"],function(t){const{Buffer:e}=t;var r;!function(t){t[t.EPERM=1]="EPERM",t[t.ENOENT=2]="ENOENT",t[t.EIO=5]="EIO",t[t.EBADF=9]="EBADF",t[t.EACCES=13]="EACCES",t[t.EBUSY=16]="EBUSY",t[t.EEXIST=17]="EEXIST",t[t.ENOTDIR=20]="ENOTDIR",t[t.EISDIR=21]="EISDIR",t[t.EINVAL=22]="EINVAL",t[t.EFBIG=27]="EFBIG",t[t.ENOSPC=28]="ENOSPC",t[t.EROFS=30]="EROFS",t[t.ENOTEMPTY=39]="ENOTEMPTY",t[t.ENOTSUP=95]="ENOTSUP"}(r||(r={}));const s={};s[r.EPERM]="Operation not permitted.",s[r.ENOENT]="No such file or directory.",s[r.EIO]="Input/output error.",s[r.EBADF]="Bad file descriptor.",s[r.EACCES]="Permission denied.",s[r.EBUSY]="Resource busy or locked.",s[r.EEXIST]="File exists.",s[r.ENOTDIR]="File is not a directory.",s[r.EISDIR]="File is a directory.",s[r.EINVAL]="Invalid argument.",s[r.EFBIG]="File is too big.",s[r.ENOSPC]="No space left on disk.",s[r.EROFS]="Cannot modify a read-only file system.",s[r.ENOTEMPTY]="Directory is not empty.",s[r.ENOTSUP]="Operation is not supported.";class i extends Error{constructor(t,e=s[t],i){super(e),this.syscall="",this.errno=t,this.code=r[t],this.path=i,this.stack=(new Error).stack,this.message=`Error: ${this.code}: ${e}${this.path?`, '${this.path}'`:""}`}static fromJSON(t){const e=new i(0);return e.errno=t.errno,e.code=t.code,e.path=t.path,e.stack=t.stack,e.message=t.message,e}static fromBuffer(t,e=0){return i.fromJSON(JSON.parse(t.toString("utf8",e+4,e+4+t.readUInt32LE(e))))}static FileError(t,e){return new i(t,s[t],e)}static ENOENT(t){return this.FileError(r.ENOENT,t)}static EEXIST(t){return this.FileError(r.EEXIST,t)}static EISDIR(t){return this.FileError(r.EISDIR,t)}static ENOTDIR(t){return this.FileError(r.ENOTDIR,t)}static EPERM(t){return this.FileError(r.EPERM,t)}static ENOTEMPTY(t){return this.FileError(r.ENOTEMPTY,t)}toString(){return this.message}toJSON(){return{errno:this.errno,code:this.code,path:this.path,stack:this.stack,message:this.message}}writeToBuffer(t=e.alloc(this.bufferSize()),r=0){const s=t.write(JSON.stringify(this.toJSON()),r+4);return t.writeUInt32LE(s,r),t}bufferSize(){return 4+e.byteLength(JSON.stringify(this.toJSON()))}}return{ApiError:i,ErrorCode:r,ErrorStrings:s}}),t("skylark-browserfs/core/file_flag",["./api_error"],function(t){"use strict";const{ErrorCode:e,ApiError:r}=t;var s;!function(t){t[t.NOP=0]="NOP",t[t.THROW_EXCEPTION=1]="THROW_EXCEPTION",t[t.TRUNCATE_FILE=2]="TRUNCATE_FILE",t[t.CREATE_FILE=3]="CREATE_FILE"}(s||(s={}));class i{constructor(t){if(this.flagStr=t,i.validFlagStrs.indexOf(t)<0)throw new r(e.EINVAL,"Invalid flag: "+t)}static getFileFlag(t){return i.flagCache.hasOwnProperty(t)?i.flagCache[t]:i.flagCache[t]=new i(t)}getFlagString(){return this.flagStr}isReadable(){return-1!==this.flagStr.indexOf("r")||-1!==this.flagStr.indexOf("+")}isWriteable(){return-1!==this.flagStr.indexOf("w")||-1!==this.flagStr.indexOf("a")||-1!==this.flagStr.indexOf("+")}isTruncating(){return-1!==this.flagStr.indexOf("w")}isAppendable(){return-1!==this.flagStr.indexOf("a")}isSynchronous(){return-1!==this.flagStr.indexOf("s")}isExclusive(){return-1!==this.flagStr.indexOf("x")}pathExistsAction(){return this.isExclusive()?s.THROW_EXCEPTION:this.isTruncating()?s.TRUNCATE_FILE:s.NOP}pathNotExistsAction(){return(this.isWriteable()||this.isAppendable())&&"r+"!==this.flagStr?s.CREATE_FILE:s.THROW_EXCEPTION}}return i.flagCache={},i.validFlagStrs=["r","r+","rs","rs+","w","wx","w+","wx+","a","ax","a+","ax+"],{ActionType:s,FileFlag:i}}),t("skylark-browserfs/libs/path",["skylark-langx-paths"],function(t){"use strict";return t}),t("skylark-browserfs/core/node_fs_stats",["../libs/buffers"],function(t){"use strict";const{Buffer:e}=t;var r;!function(t){t[t.FILE=32768]="FILE",t[t.DIRECTORY=16384]="DIRECTORY",t[t.SYMLINK=40960]="SYMLINK"}(r||(r={}));class s{constructor(t,e,s,i,n,o,a){this.dev=0,this.ino=0,this.rdev=0,this.nlink=1,this.blksize=4096,this.uid=0,this.gid=0,this.fileData=null,this.size=e;let c=0;if("number"!=typeof i&&(c=Date.now(),i=c),"number"!=typeof n&&(c||(c=Date.now()),n=c),"number"!=typeof o&&(c||(c=Date.now()),o=c),"number"!=typeof a&&(c||(c=Date.now()),a=c),this.atimeMs=i,this.ctimeMs=o,this.mtimeMs=n,this.birthtimeMs=a,s)this.mode=s;else switch(t){case r.FILE:this.mode=420;break;case r.DIRECTORY:default:this.mode=511}this.blocks=Math.ceil(e/512),this.mode<4096&&(this.mode|=t)}static fromBuffer(t){const e=t.readUInt32LE(0),r=t.readUInt32LE(4),i=t.readDoubleLE(8),n=t.readDoubleLE(16),o=t.readDoubleLE(24);return new s(61440&r,e,4095&r,i,n,o)}static clone(t){return new s(61440&t.mode,t.size,4095&t.mode,t.atimeMs,t.mtimeMs,t.ctimeMs,t.birthtimeMs)}get atime(){return new Date(this.atimeMs)}get mtime(){return new Date(this.mtimeMs)}get ctime(){return new Date(this.ctimeMs)}get birthtime(){return new Date(this.birthtimeMs)}toBuffer(){const t=e.alloc(32);return t.writeUInt32LE(this.size,0),t.writeUInt32LE(this.mode,4),t.writeDoubleLE(this.atime.getTime(),8),t.writeDoubleLE(this.mtime.getTime(),16),t.writeDoubleLE(this.ctime.getTime(),24),t}isFile(){return(61440&this.mode)===r.FILE}isDirectory(){return(61440&this.mode)===r.DIRECTORY}isSymbolicLink(){return(61440&this.mode)===r.SYMLINK}chmod(t){this.mode=61440&this.mode|t}isSocket(){return!1}isBlockDevice(){return!1}isCharacterDevice(){return!1}isFIFO(){return!1}}return{FileType:r,Stats:s}}),t("skylark-browserfs/core/global",[],function(){"use strict";const t="undefined"!=typeof window?window:"undefined"!=typeof self?self:global;return t}),t("skylark-browserfs/generic/setImmediate",["../core/global"],function(t){"use strict";let e;if("undefined"!=typeof setImmediate)e=setImmediate;else{const r=t,s=[],i="zero-timeout-message",n=function(){if(void 0!==r.importScripts||!r.postMessage)return!1;let t=!0;const e=r.onmessage;return r.onmessage=function(){t=!1},r.postMessage("","*"),r.onmessage=e,t};if(n()){e=function(t){s.push(t),r.postMessage(i,"*")};const t=function(t){if(t.source===self&&t.data===i&&(t.stopPropagation?t.stopPropagation():t.cancelBubble=!0,s.length>0)){const t=s.shift();return t()}};r.addEventListener?r.addEventListener("message",t,!0):r.attachEvent("onmessage",t)}else if(r.MessageChannel){const t=new r.MessageChannel;t.port1.onmessage=(t=>{if(s.length>0)return s.shift()()}),e=(e=>{s.push(e),t.port2.postMessage("")})}else e=function(t){return setTimeout(t,0)}}return e}),t("skylark-browserfs/core/FS",["../libs/buffers","./api_error","./file_flag","../libs/path","./node_fs_stats","../generic/setImmediate"],function(t,e,r,s,i,n){"use strict";const{ApiError:o,ErrorCode:a}=e,{FileFlag:c}=r,{Stats:l}=i,{Buffer:h}=t;let u=function(t,e){return t};function d(t,e){if("function"!=typeof t)throw new Error("Callback must be a function.");const r=u(t,e);switch(e){case 1:return function(t){n(function(){return r(t)})};case 2:return function(t,e){n(function(){return r(t,e)})};case 3:return function(t,e,s){n(function(){return r(t,e,s)})};default:throw new Error("Invalid invocation of wrapCb.")}}function f(t){if(t)return t;throw new o(a.EIO,"Initialize BrowserFS with a file system using BrowserFS.initialize(filesystem)")}function y(t,e){switch(typeof t){case"number":return t;case"string":const r=parseInt(t,8);return isNaN(r)?e:r;default:return e}}function p(t){if(t instanceof Date)return t;if("number"==typeof t)return new Date(1e3*t);throw new o(a.EINVAL,"Invalid time.")}function m(t){if(t.indexOf("\0")>=0)throw new o(a.EINVAL,"Path must be a string without null bytes.");if(""===t)throw new o(a.EINVAL,"Path must not be empty.");return s.resolve(t)}function g(t,e,r,s){switch(null===t?"null":typeof t){case"object":return{encoding:void 0!==t.encoding?t.encoding:e,flag:void 0!==t.flag?t.flag:r,mode:y(t.mode,s)};case"string":return{encoding:t,flag:r,mode:s};case"null":case"undefined":case"function":return{encoding:e,flag:r,mode:s};default:throw new TypeError(`"options" must be a string or an object, got ${typeof t} instead.`)}}function _(){}class S{constructor(){this.F_OK=0,this.R_OK=4,this.W_OK=2,this.X_OK=1,this.root=null,this.fdMap={},this.nextFd=100}initialize(t){if(!t.constructor.isAvailable())throw new o(a.EINVAL,"Tried to instantiate BrowserFS with an unavailable file system.");return this.root=t}_toUnixTimestamp(t){if("number"==typeof t)return t;if(t instanceof Date)return t.getTime()/1e3;throw new Error("Cannot parse time: "+t)}getRootFS(){return this.root?this.root:null}rename(t,e,r=_){const s=d(r,1);try{f(this.root).rename(m(t),m(e),s)}catch(t){s(t)}}renameSync(t,e){f(this.root).renameSync(m(t),m(e))}exists(t,e=_){const r=d(e,1);try{return f(this.root).exists(m(t),r)}catch(t){return r(!1)}}existsSync(t){try{return f(this.root).existsSync(m(t))}catch(t){return!1}}stat(t,e=_){const r=d(e,2);try{return f(this.root).stat(m(t),!1,r)}catch(t){return r(t)}}statSync(t){return f(this.root).statSync(m(t),!1)}lstat(t,e=_){const r=d(e,2);try{return f(this.root).stat(m(t),!0,r)}catch(t){return r(t)}}lstatSync(t){return f(this.root).statSync(m(t),!0)}truncate(t,e=0,r=_){let s=0;"function"==typeof e?r=e:"number"==typeof e&&(s=e);const i=d(r,1);try{if(s<0)throw new o(a.EINVAL);return f(this.root).truncate(m(t),s,i)}catch(t){return i(t)}}truncateSync(t,e=0){if(e<0)throw new o(a.EINVAL);return f(this.root).truncateSync(m(t),e)}unlink(t,e=_){const r=d(e,1);try{return f(this.root).unlink(m(t),r)}catch(t){return r(t)}}unlinkSync(t){return f(this.root).unlinkSync(m(t))}open(t,e,r,s=_){const i=y(r,420),n=d(s="function"==typeof r?r:s,2);try{f(this.root).open(m(t),c.getFileFlag(e),i,(t,e)=>{e?n(t,this.getFdForFile(e)):n(t)})}catch(t){n(t)}}openSync(t,e,r=420){return this.getFdForFile(f(this.root).openSync(m(t),c.getFileFlag(e),y(r,420)))}readFile(t,e={},r=_){const s=g(e,null,"r",null),i=d(r="function"==typeof e?e:r,2);try{const e=c.getFileFlag(s.flag);return e.isReadable()?f(this.root).readFile(m(t),s.encoding,e,i):i(new o(a.EINVAL,"Flag passed to readFile must allow for reading."))}catch(t){return i(t)}}readFileSync(t,e={}){const r=g(e,null,"r",null),s=c.getFileFlag(r.flag);if(!s.isReadable())throw new o(a.EINVAL,"Flag passed to readFile must allow for reading.");return f(this.root).readFileSync(m(t),r.encoding,s)}writeFile(t,e,r={},s=_){const i=g(r,"utf8","w",420),n=d(s="function"==typeof r?r:s,1);try{const r=c.getFileFlag(i.flag);return r.isWriteable()?f(this.root).writeFile(m(t),e,i.encoding,r,i.mode,n):n(new o(a.EINVAL,"Flag passed to writeFile must allow for writing."))}catch(t){return n(t)}}writeFileSync(t,e,r){const s=g(r,"utf8","w",420),i=c.getFileFlag(s.flag);if(!i.isWriteable())throw new o(a.EINVAL,"Flag passed to writeFile must allow for writing.");return f(this.root).writeFileSync(m(t),e,s.encoding,i,s.mode)}appendFile(t,e,r,s=_){const i=g(r,"utf8","a",420),n=d(s="function"==typeof r?r:s,1);try{const r=c.getFileFlag(i.flag);if(!r.isAppendable())return n(new o(a.EINVAL,"Flag passed to appendFile must allow for appending."));f(this.root).appendFile(m(t),e,i.encoding,r,i.mode,n)}catch(t){n(t)}}appendFileSync(t,e,r){const s=g(r,"utf8","a",420),i=c.getFileFlag(s.flag);if(!i.isAppendable())throw new o(a.EINVAL,"Flag passed to appendFile must allow for appending.");return f(this.root).appendFileSync(m(t),e,s.encoding,i,s.mode)}fstat(t,e=_){const r=d(e,2);try{const e=this.fd2file(t);e.stat(r)}catch(t){r(t)}}fstatSync(t){return this.fd2file(t).statSync()}close(t,e=_){const r=d(e,1);try{this.fd2file(t).close(e=>{e||this.closeFd(t),r(e)})}catch(t){r(t)}}closeSync(t){this.fd2file(t).closeSync(),this.closeFd(t)}ftruncate(t,e,r=_){const s="number"==typeof e?e:0,i=d(r="function"==typeof e?e:r,1);try{const e=this.fd2file(t);if(s<0)throw new o(a.EINVAL);e.truncate(s,i)}catch(t){i(t)}}ftruncateSync(t,e=0){const r=this.fd2file(t);if(e<0)throw new o(a.EINVAL);r.truncateSync(e)}fsync(t,e=_){const r=d(e,1);try{this.fd2file(t).sync(r)}catch(t){r(t)}}fsyncSync(t){this.fd2file(t).syncSync()}fdatasync(t,e=_){const r=d(e,1);try{this.fd2file(t).datasync(r)}catch(t){r(t)}}fdatasyncSync(t){this.fd2file(t).datasyncSync()}write(t,e,r,s,i,n=_){let c,l,u,f=null;if("string"==typeof e){let t="utf8";switch(typeof r){case"function":n=r;break;case"number":f=r,t="string"==typeof s?s:"utf8",n="function"==typeof i?i:n;break;default:return(n="function"==typeof s?s:"function"==typeof i?i:n)(new o(a.EINVAL,"Invalid arguments."))}c=h.from(e,t),l=0,u=c.length}else c=e,l=r,u=s,f="number"==typeof i?i:null,n="function"==typeof i?i:n;const y=d(n,3);try{const e=this.fd2file(t);void 0!==f&&null!==f||(f=e.getPos()),e.write(c,l,u,f,y)}catch(t){y(t)}}writeSync(t,e,r,s,i){let n,o,a,c=0;if("string"==typeof e){a="number"==typeof r?r:null;const t="string"==typeof s?s:"utf8";c=0,n=h.from(e,t),o=n.length}else n=e,c=r,o=s,a="number"==typeof i?i:null;const l=this.fd2file(t);return void 0!==a&&null!==a||(a=l.getPos()),l.writeSync(n,c,o,a)}read(t,e,r,s,i,n=_){let o,a,c,l,u;if("number"==typeof e){c=e,o=r;const t=s;n="function"==typeof i?i:n,a=0,l=h.alloc(c),u=d((e,r,s)=>{if(e)return n(e);n(e,s.toString(t),r)},3)}else l=e,a=r,c=s,o=i,u=d(n,3);try{const e=this.fd2file(t);void 0!==o&&null!==o||(o=e.getPos()),e.read(l,a,c,o,u)}catch(t){u(t)}}readSync(t,e,r,s,i){let n,o,a,c,l=!1,u="utf8";"number"==typeof e?(a=e,c=r,u=s,o=0,n=h.alloc(a),l=!0):(n=e,o=r,a=s,c=i);const d=this.fd2file(t);void 0!==c&&null!==c||(c=d.getPos());const f=d.readSync(n,o,a,c);return l?[n.toString(u),f]:f}fchown(t,e,r,s=_){const i=d(s,1);try{this.fd2file(t).chown(e,r,i)}catch(t){i(t)}}fchownSync(t,e,r){this.fd2file(t).chownSync(e,r)}fchmod(t,e,r){const s=d(r,1);try{const r="string"==typeof e?parseInt(e,8):e;this.fd2file(t).chmod(r,s)}catch(t){s(t)}}fchmodSync(t,e){const r="string"==typeof e?parseInt(e,8):e;this.fd2file(t).chmodSync(r)}futimes(t,e,r,s=_){const i=d(s,1);try{const s=this.fd2file(t);"number"==typeof e&&(e=new Date(1e3*e)),"number"==typeof r&&(r=new Date(1e3*r)),s.utimes(e,r,i)}catch(t){i(t)}}futimesSync(t,e,r){this.fd2file(t).utimesSync(p(e),p(r))}rmdir(t,e=_){const r=d(e,1);try{t=m(t),f(this.root).rmdir(t,r)}catch(t){r(t)}}rmdirSync(t){return t=m(t),f(this.root).rmdirSync(t)}mkdir(t,e,r=_){"function"==typeof e&&(r=e,e=511);const s=d(r,1);try{t=m(t),f(this.root).mkdir(t,e,s)}catch(t){s(t)}}mkdirSync(t,e){f(this.root).mkdirSync(m(t),y(e,511))}readdir(t,e=_){const r=d(e,2);try{t=m(t),f(this.root).readdir(t,r)}catch(t){r(t)}}readdirSync(t){return t=m(t),f(this.root).readdirSync(t)}link(t,e,r=_){const s=d(r,1);try{t=m(t),e=m(e),f(this.root).link(t,e,s)}catch(t){s(t)}}linkSync(t,e){return t=m(t),e=m(e),f(this.root).linkSync(t,e)}symlink(t,e,r,s=_){const i="string"==typeof r?r:"file",n=d(s="function"==typeof r?r:s,1);try{if("file"!==i&&"dir"!==i)return n(new o(a.EINVAL,"Invalid type: "+i));t=m(t),e=m(e),f(this.root).symlink(t,e,i,n)}catch(t){n(t)}}symlinkSync(t,e,r){if(r){if("file"!==r&&"dir"!==r)throw new o(a.EINVAL,"Invalid type: "+r)}else r="file";return t=m(t),e=m(e),f(this.root).symlinkSync(t,e,r)}readlink(t,e=_){const r=d(e,2);try{t=m(t),f(this.root).readlink(t,r)}catch(t){r(t)}}readlinkSync(t){return t=m(t),f(this.root).readlinkSync(t)}chown(t,e,r,s=_){const i=d(s,1);try{t=m(t),f(this.root).chown(t,!1,e,r,i)}catch(t){i(t)}}chownSync(t,e,r){t=m(t),f(this.root).chownSync(t,!1,e,r)}lchown(t,e,r,s=_){const i=d(s,1);try{t=m(t),f(this.root).chown(t,!0,e,r,i)}catch(t){i(t)}}lchownSync(t,e,r){t=m(t),f(this.root).chownSync(t,!0,e,r)}chmod(t,e,r=_){const s=d(r,1);try{const r=y(e,-1);if(r<0)throw new o(a.EINVAL,"Invalid mode.");f(this.root).chmod(m(t),!1,r,s)}catch(t){s(t)}}chmodSync(t,e){const r=y(e,-1);if(r<0)throw new o(a.EINVAL,"Invalid mode.");t=m(t),f(this.root).chmodSync(t,!1,r)}lchmod(t,e,r=_){const s=d(r,1);try{const r=y(e,-1);if(r<0)throw new o(a.EINVAL,"Invalid mode.");f(this.root).chmod(m(t),!0,r,s)}catch(t){s(t)}}lchmodSync(t,e){const r=y(e,-1);if(r<1)throw new o(a.EINVAL,"Invalid mode.");f(this.root).chmodSync(m(t),!0,r)}utimes(t,e,r,s=_){const i=d(s,1);try{f(this.root).utimes(m(t),p(e),p(r),i)}catch(t){i(t)}}utimesSync(t,e,r){f(this.root).utimesSync(m(t),p(e),p(r))}realpath(t,e,r=_){const s="object"==typeof e?e:{},i=d("function"==typeof e?e:_,2);try{t=m(t),f(this.root).realpath(t,s,i)}catch(t){i(t)}}realpathSync(t,e={}){return t=m(t),f(this.root).realpathSync(t,e)}watchFile(t,e,r=_){throw new o(a.ENOTSUP)}unwatchFile(t,e=_){throw new o(a.ENOTSUP)}watch(t,e,r=_){throw new o(a.ENOTSUP)}access(t,e,r=_){throw new o(a.ENOTSUP)}accessSync(t,e){throw new o(a.ENOTSUP)}createReadStream(t,e){throw new o(a.ENOTSUP)}createWriteStream(t,e){throw new o(a.ENOTSUP)}wrapCallbacks(t){u=t}getFdForFile(t){const e=this.nextFd++;return this.fdMap[e]=t,e}fd2file(t){const e=this.fdMap[t];if(e)return e;throw new o(a.EBADF,"Invalid file descriptor.")}closeFd(t){delete this.fdMap[t]}}return S.Stats=l,S}),t("skylark-browserfs/core/node_fs",["./FS"],function(t){"use strict";let e=new t;const r={},s=t.prototype,i=Object.getOwnPropertyNames(s);return i.forEach(t=>{"function"==typeof e[t]?r[t]=function(){return e[t].apply(e,arguments)}:r[t]=e[t]}),r.changeFSModule=function(t){e=t},r.getFSModule=function(){return e},r.FS=t,r.Stats=t.Stats,r}),t("skylark-browserfs/core/levenshtein",[],function(){"use strict";function t(t,e,r,s,i){return t<e||r<e?t>r?r+1:t+1:s===i?e:e+1}return function(e,r){if(e===r)return 0;if(e.length>r.length){const t=e;e=r,r=t}let s=e.length,i=r.length;for(;s>0&&e.charCodeAt(s-1)===r.charCodeAt(i-1);)s--,i--;let n=0;for(;n<s&&e.charCodeAt(n)===r.charCodeAt(n);)n++;if(i-=n,0==(s-=n)||1===i)return i;const o=new Array(s<<1);for(let t=0;t<s;)o[s+t]=e.charCodeAt(n+t),o[t]=++t;let a,c,l,h,u;for(a=0;a+3<i;){const e=r.charCodeAt(n+(c=a)),i=r.charCodeAt(n+(l=a+1)),d=r.charCodeAt(n+(h=a+2)),f=r.charCodeAt(n+(u=a+3));let y=a+=4;for(let r=0;r<s;){const n=o[s+r],a=o[r];c=t(a,c,l,e,n),l=t(c,l,h,i,n),h=t(l,h,u,d,n),y=t(h,u,y,f,n),o[r++]=y,u=h,h=l,l=c,c=a}}let d=0;for(;a<i;){const t=r.charCodeAt(n+(c=a));d=++a;for(let e=0;e<s;e++){const r=o[e];o[e]=d=r<c||d<c?r>d?d+1:r+1:t===o[s+e]?c:c+1,c=r}}return d}}),t("skylark-browserfs/core/util",["../libs/buffers","./api_error","./levenshtein","../libs/path"],function(t,e,r,s){"use strict";const{ErrorCode:i,ApiError:n}=e,{Buffer:o}=t;const a="undefined"!=typeof navigator&&!(!/(msie) ([\w.]+)/.exec(navigator.userAgent.toLowerCase())&&-1===navigator.userAgent.indexOf("Trident")),c="undefined"==typeof window;function l(t){return t instanceof Uint8Array?t:new Uint8Array(t)}function h(t){return t instanceof o?t:0===t.byteOffset&&t.byteLength===t.buffer.byteLength?u(t.buffer):o.from(t.buffer,t.byteOffset,t.byteLength)}function u(t){return o.from(t)}let d=null;function f(){return d||(d=o.alloc(0))}return{deprecationMessage:function(t,e,r){t&&console.warn(`[${e}] Direct file system constructor usage is deprecated for this file system, and will be removed in the next major version. Please use the '${e}.Create(${JSON.stringify(r)}, callback)' method instead. See https://github.com/jvilk/BrowserFS/issues/176 for more details.`)},isIE:a,isWebWorker:c,fail:function(){throw new Error("BFS has reached an impossible code path; please file a bug.")},mkdirpSync:function t(e,r,i){i.existsSync(e)||(t(s.dirname(e),r,i),i.mkdirSync(e,r))},buffer2ArrayBuffer:function(t){const e=l(t),r=e.byteOffset,s=e.byteLength;return 0===r&&s===e.buffer.byteLength?e.buffer:e.buffer.slice(r,r+s)},buffer2Uint8array:l,arrayish2Buffer:function(t){return t instanceof o?t:t instanceof Uint8Array?h(t):o.from(t)},uint8Array2Buffer:h,arrayBuffer2Buffer:u,copyingSlice:function(t,e=0,r=t.length){if(e<0||r<0||r>t.length||e>r)throw new TypeError(`Invalid slice bounds on buffer of length ${t.length}: [${e}, ${r}]`);if(0===t.length)return f();{const s=l(t),i=t[0],n=(i+1)%255;return t[0]=n,s[0]===n?(s[0]=i,h(s.slice(e,r))):(t[0]=i,h(s.subarray(e,r)))}},emptyBuffer:f,bufferValidator:function(t,e){o.isBuffer(t)?e():e(new n(i.EINVAL,"option must be a Buffer."))},checkOptions:function(t,e,s){const o=t.Options,a=t.Name;let c=0,l=!1,h=!1;function u(t){l||(t&&(l=!0,s(t)),0===--c&&h&&s())}for(const t in o)if(o.hasOwnProperty(t)){const h=o[t],d=e[t];if(void 0===d||null===d){if(!h.optional){const c=Object.keys(e).filter(t=>!(t in o)).map(e=>({str:e,distance:r(t,e)})).filter(t=>t.distance<5).sort((t,e)=>t.distance-e.distance);if(l)return;return l=!0,s(new n(i.EINVAL,`[${a}] Required option '${t}' not provided.${c.length>0?` You provided unrecognized option '${c[0].str}'; perhaps you meant to type '${t}'.`:""}\nOption description: ${h.description}`))}}else{let e=!1;if(!(e=Array.isArray(h.type)?-1!==h.type.indexOf(typeof d):typeof d===h.type)){if(l)return;return l=!0,s(new n(i.EINVAL,`[${a}] Value provided for option ${t} is not the proper type. Expected ${Array.isArray(h.type)?`one of {${h.type.join(", ")}}`:h.type}, but received ${typeof d}\nOption description: ${h.description}`))}h.validator&&(c++,h.validator(d,u))}}h=!0,0!==c||l||s()}}}),t("skylark-browserfs/generic/emscripten_fs",["../core/node_fs","../core/util"],function(t,e){"use strict";const{uint8Array2Buffer:r}=e;class s{constructor(t){this.fs=t,this.nodefs=t.getNodeFS(),this.FS=t.getFS(),this.PATH=t.getPATH(),this.ERRNO_CODES=t.getERRNO_CODES()}open(t){const e=this.fs.realPath(t.node),r=this.FS;try{r.isFile(t.node.mode)&&(t.nfd=this.nodefs.openSync(e,this.fs.flagsToPermissionString(t.flags)))}catch(t){if(!t.code)throw t;throw new r.ErrnoError(this.ERRNO_CODES[t.code])}}close(t){const e=this.FS;try{e.isFile(t.node.mode)&&t.nfd&&this.nodefs.closeSync(t.nfd)}catch(t){if(!t.code)throw t;throw new e.ErrnoError(this.ERRNO_CODES[t.code])}}read(t,e,s,i,n){try{return this.nodefs.readSync(t.nfd,r(e),s,i,n)}catch(t){throw new this.FS.ErrnoError(this.ERRNO_CODES[t.code])}}write(t,e,s,i,n){try{return this.nodefs.writeSync(t.nfd,r(e),s,i,n)}catch(t){throw new this.FS.ErrnoError(this.ERRNO_CODES[t.code])}}llseek(t,e,r){let s=e;if(1===r)s+=t.position;else if(2===r&&this.FS.isFile(t.node.mode))try{const e=this.nodefs.fstatSync(t.nfd);s+=e.size}catch(t){throw new this.FS.ErrnoError(this.ERRNO_CODES[t.code])}if(s<0)throw new this.FS.ErrnoError(this.ERRNO_CODES.EINVAL);return t.position=s,s}}class i{constructor(t){this.fs=t,this.nodefs=t.getNodeFS(),this.FS=t.getFS(),this.PATH=t.getPATH(),this.ERRNO_CODES=t.getERRNO_CODES()}getattr(t){const e=this.fs.realPath(t);let r;try{r=this.nodefs.lstatSync(e)}catch(t){if(!t.code)throw t;throw new this.FS.ErrnoError(this.ERRNO_CODES[t.code])}return{dev:r.dev,ino:r.ino,mode:r.mode,nlink:r.nlink,uid:r.uid,gid:r.gid,rdev:r.rdev,size:r.size,atime:r.atime,mtime:r.mtime,ctime:r.ctime,blksize:r.blksize,blocks:r.blocks}}setattr(t,e){const r=this.fs.realPath(t);try{if(void 0!==e.mode&&(this.nodefs.chmodSync(r,e.mode),t.mode=e.mode),void 0!==e.timestamp){const t=new Date(e.timestamp);this.nodefs.utimesSync(r,t,t)}}catch(t){if(!t.code)throw t;if("ENOTSUP"!==t.code)throw new this.FS.ErrnoError(this.ERRNO_CODES[t.code])}if(void 0!==e.size)try{this.nodefs.truncateSync(r,e.size)}catch(t){if(!t.code)throw t;throw new this.FS.ErrnoError(this.ERRNO_CODES[t.code])}}lookup(t,e){const r=this.PATH.join2(this.fs.realPath(t),e),s=this.fs.getMode(r);return this.fs.createNode(t,e,s)}mknod(t,e,r,s){const i=this.fs.createNode(t,e,r,s),n=this.fs.realPath(i);try{this.FS.isDir(i.mode)?this.nodefs.mkdirSync(n,i.mode):this.nodefs.writeFileSync(n,"",{mode:i.mode})}catch(t){if(!t.code)throw t;throw new this.FS.ErrnoError(this.ERRNO_CODES[t.code])}return i}rename(t,e,r){const s=this.fs.realPath(t),i=this.PATH.join2(this.fs.realPath(e),r);try{this.nodefs.renameSync(s,i),t.name=r,t.parent=e}catch(t){if(!t.code)throw t;throw new this.FS.ErrnoError(this.ERRNO_CODES[t.code])}}unlink(t,e){const r=this.PATH.join2(this.fs.realPath(t),e);try{this.nodefs.unlinkSync(r)}catch(t){if(!t.code)throw t;throw new this.FS.ErrnoError(this.ERRNO_CODES[t.code])}}rmdir(t,e){const r=this.PATH.join2(this.fs.realPath(t),e);try{this.nodefs.rmdirSync(r)}catch(t){if(!t.code)throw t;throw new this.FS.ErrnoError(this.ERRNO_CODES[t.code])}}readdir(t){const e=this.fs.realPath(t);try{const t=this.nodefs.readdirSync(e);return t.push(".",".."),t}catch(t){if(!t.code)throw t;throw new this.FS.ErrnoError(this.ERRNO_CODES[t.code])}}symlink(t,e,r){const s=this.PATH.join2(this.fs.realPath(t),e);try{this.nodefs.symlinkSync(r,s)}catch(t){if(!t.code)throw t;throw new this.FS.ErrnoError(this.ERRNO_CODES[t.code])}}readlink(t){const e=this.fs.realPath(t);try{return this.nodefs.readlinkSync(e)}catch(t){if(!t.code)throw t;throw new this.FS.ErrnoError(this.ERRNO_CODES[t.code])}}}return class{constructor(e=self.FS,r=self.PATH,n=self.ERRNO_CODES,o=t){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+"},this.nodefs=o,this.FS=e,this.PATH=r,this.ERRNO_CODES=n,this.node_ops=new i(this),this.stream_ops=new s(this)}mount(t){return this.createNode(null,"/",this.getMode(t.opts.root),0)}createNode(t,e,r,s){const i=this.FS;if(!i.isDir(r)&&!i.isFile(r)&&!i.isLink(r))throw new i.ErrnoError(this.ERRNO_CODES.EINVAL);const n=i.createNode(t,e,r);return n.node_ops=this.node_ops,n.stream_ops=this.stream_ops,n}getMode(t){let e;try{e=this.nodefs.lstatSync(t)}catch(t){if(!t.code)throw t;throw new this.FS.ErrnoError(this.ERRNO_CODES[t.code])}return e.mode}realPath(t){const e=[];for(;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)}flagsToPermissionString(t){let e="string"==typeof t?parseInt(t,10):t;return(e&=8191)in this.flagsToPermissionStringMap?this.flagsToPermissionStringMap[e]:t}getNodeFS(){return this.nodefs}getFS(){return this.FS}getPATH(){return this.PATH}getERRNO_CODES(){return this.ERRNO_CODES}}}),t("skylark-browserfs/core/file_system",["../libs/buffers","./api_error","./file_flag","../libs/path","./util"],function(t,e,r,s,i){"use strict";const{ApiError:n,ErrorCode:o}=e,{FileFlag:a,ActionType:c}=r,{fail:l}=i;class h{supportsLinks(){return!1}diskSpace(t,e){e(0,0)}openFile(t,e,r){throw new n(o.ENOTSUP)}createFile(t,e,r,s){throw new n(o.ENOTSUP)}open(t,e,r,i){this.stat(t,!1,(a,h)=>{if(a)switch(e.pathNotExistsAction()){case c.CREATE_FILE:return this.stat(s.dirname(t),!1,(o,a)=>{o?i(o):a&&!a.isDirectory()?i(n.ENOTDIR(s.dirname(t))):this.createFile(t,e,r,i)});case c.THROW_EXCEPTION:return i(n.ENOENT(t));default:return i(new n(o.EINVAL,"Invalid FileFlag object."))}else{if(h&&h.isDirectory())return i(n.EISDIR(t));switch(e.pathExistsAction()){case c.THROW_EXCEPTION:return i(n.EEXIST(t));case c.TRUNCATE_FILE:return this.openFile(t,e,(t,e)=>{t?i(t):e?e.truncate(0,()=>{e.sync(()=>{i(null,e)})}):l()});case c.NOP:return this.openFile(t,e,i);default:return i(new n(o.EINVAL,"Invalid FileFlag object."))}}})}rename(t,e,r){r(new n(o.ENOTSUP))}renameSync(t,e){throw new n(o.ENOTSUP)}stat(t,e,r){r(new n(o.ENOTSUP))}statSync(t,e){throw new n(o.ENOTSUP)}openFileSync(t,e,r){throw new n(o.ENOTSUP)}createFileSync(t,e,r){throw new n(o.ENOTSUP)}openSync(t,e,r){let i;try{i=this.statSync(t,!1)}catch(i){switch(e.pathNotExistsAction()){case c.CREATE_FILE:const i=this.statSync(s.dirname(t),!1);if(!i.isDirectory())throw n.ENOTDIR(s.dirname(t));return this.createFileSync(t,e,r);case c.THROW_EXCEPTION:throw n.ENOENT(t);default:throw new n(o.EINVAL,"Invalid FileFlag object.")}}if(i.isDirectory())throw n.EISDIR(t);switch(e.pathExistsAction()){case c.THROW_EXCEPTION:throw n.EEXIST(t);case c.TRUNCATE_FILE:return this.unlinkSync(t),this.createFileSync(t,e,i.mode);case c.NOP:return this.openFileSync(t,e,r);default:throw new n(o.EINVAL,"Invalid FileFlag object.")}}unlink(t,e){e(new n(o.ENOTSUP))}unlinkSync(t){throw new n(o.ENOTSUP)}rmdir(t,e){e(new n(o.ENOTSUP))}rmdirSync(t){throw new n(o.ENOTSUP)}mkdir(t,e,r){r(new n(o.ENOTSUP))}mkdirSync(t,e){throw new n(o.ENOTSUP)}readdir(t,e){e(new n(o.ENOTSUP))}readdirSync(t){throw new n(o.ENOTSUP)}exists(t,e){this.stat(t,null,function(t){e(!t)})}existsSync(t){try{return this.statSync(t,!0),!0}catch(t){return!1}}realpath(t,e,r){if(this.supportsLinks()){const e=t.split(s.sep);for(let t=0;t<e.length;t++){const r=e.slice(0,t+1);e[t]=s.join.apply(null,r)}}else this.exists(t,function(e){e?r(null,t):r(n.ENOENT(t))})}realpathSync(t,e){if(this.supportsLinks()){const e=t.split(s.sep);for(let t=0;t<e.length;t++){const r=e.slice(0,t+1);e[t]=s.join.apply(s,r)}return e.join(s.sep)}if(this.existsSync(t))return t;throw n.ENOENT(t)}truncate(t,e,r){this.open(t,a.getFileFlag("r+"),420,function(t,s){if(t)return r(t);s.truncate(e,function(t){s.close(function(e){r(t||e)})})})}truncateSync(t,e){const r=this.openSync(t,a.getFileFlag("r+"),420);try{r.truncateSync(e)}catch(t){throw t}finally{r.closeSync()}}readFile(t,e,r,s){const i=s;this.open(t,r,420,(t,r)=>{if(t)return s(t);s=function(t,e){r.close(function(r){return t||(t=r),i(t,e)})},r.stat((t,i)=>{if(t)return s(t);const n=Buffer.alloc(i.size);r.read(n,0,i.size,0,t=>{if(t)return s(t);if(null===e)return s(t,n);try{s(null,n.toString(e))}catch(t){s(t)}})})})}readFileSync(t,e,r){const s=this.openSync(t,r,420);try{const t=s.statSync(),r=Buffer.alloc(t.size);return s.readSync(r,0,t.size,0),s.closeSync(),null===e?r:r.toString(e)}finally{s.closeSync()}}writeFile(t,e,r,s,i,n){const o=n;this.open(t,s,420,function(t,s){if(t)return n(t);n=function(t){s.close(function(e){o(t||e)})};try{"string"==typeof e&&(e=Buffer.from(e,r))}catch(t){return n(t)}s.write(e,0,e.length,0,n)})}writeFileSync(t,e,r,s,i){const n=this.openSync(t,s,i);try{"string"==typeof e&&(e=Buffer.from(e,r)),n.writeSync(e,0,e.length,0)}finally{n.closeSync()}}appendFile(t,e,r,s,i,n){const o=n;this.open(t,s,i,function(t,s){if(t)return n(t);n=function(t){s.close(function(e){o(t||e)})},"string"==typeof e&&(e=Buffer.from(e,r)),s.write(e,0,e.length,null,n)})}appendFileSync(t,e,r,s,i){const n=this.openSync(t,s,i);try{"string"==typeof e&&(e=Buffer.from(e,r)),n.writeSync(e,0,e.length,null)}finally{n.closeSync()}}chmod(t,e,r,s){s(new n(o.ENOTSUP))}chmodSync(t,e,r){throw new n(o.ENOTSUP)}chown(t,e,r,s,i){i(new n(o.ENOTSUP))}chownSync(t,e,r,s){throw new n(o.ENOTSUP)}utimes(t,e,r,s){s(new n(o.ENOTSUP))}utimesSync(t,e,r){throw new n(o.ENOTSUP)}link(t,e,r){r(new n(o.ENOTSUP))}linkSync(t,e){throw new n(o.ENOTSUP)}symlink(t,e,r,s){s(new n(o.ENOTSUP))}symlinkSync(t,e,r){throw new n(o.ENOTSUP)}readlink(t,e){e(new n(o.ENOTSUP))}readlinkSync(t){throw new n(o.ENOTSUP)}}return{BaseFileSystem:h,SynchronousFileSystem:class extends h{supportsSynch(){return!0}rename(t,e,r){try{this.renameSync(t,e),r()}catch(t){r(t)}}stat(t,e,r){try{r(null,this.statSync(t,e))}catch(t){r(t)}}open(t,e,r,s){try{s(null,this.openSync(t,e,r))}catch(t){s(t)}}unlink(t,e){try{this.unlinkSync(t),e()}catch(t){e(t)}}rmdir(t,e){try{this.rmdirSync(t),e()}catch(t){e(t)}}mkdir(t,e,r){try{this.mkdirSync(t,e),r()}catch(t){r(t)}}readdir(t,e){try{e(null,this.readdirSync(t))}catch(t){e(t)}}chmod(t,e,r,s){try{this.chmodSync(t,e,r),s()}catch(t){s(t)}}chown(t,e,r,s,i){try{this.chownSync(t,e,r,s),i()}catch(t){i(t)}}utimes(t,e,r,s){try{this.utimesSync(t,e,r),s()}catch(t){s(t)}}link(t,e,r){try{this.linkSync(t,e),r()}catch(t){r(t)}}symlink(t,e,r,s){try{this.symlinkSync(t,e,r),s()}catch(t){s(t)}}readlink(t,e){try{e(null,this.readlinkSync(t))}catch(t){e(t)}}}}}),t("skylark-browserfs/core/file",["./api_error"],function(t){"use strict";const{ApiError:e,ErrorCode:r}=t;return{BaseFile:class{sync(t){t(new e(r.ENOTSUP))}syncSync(){throw new e(r.ENOTSUP)}datasync(t){this.sync(t)}datasyncSync(){return this.syncSync()}chown(t,s,i){i(new e(r.ENOTSUP))}chownSync(t,s){throw new e(r.ENOTSUP)}chmod(t,s){s(new e(r.ENOTSUP))}chmodSync(t){throw new e(r.ENOTSUP)}utimes(t,s,i){i(new e(r.ENOTSUP))}utimesSync(t,s){throw new e(r.ENOTSUP)}}}}),t("skylark-browserfs/generic/preload_file",["../libs/buffers","../core/file","../core/node_fs_stats","../core/api_error","../core/node_fs","../core/util"],function(t,e,r,s,i,n){"use strict";const{BaseFile:o}=e,{ApiError:a,ErrorCode:c}=s,{emptyBuffer:l}=n,{Buffer:h}=t;class u extends o{constructor(t,e,r,s,i){if(super(),this._pos=0,this._dirty=!1,this._fs=t,this._path=e,this._flag=r,this._stat=s,this._buffer=i||l(),this._stat.size!==this._buffer.length&&this._flag.isReadable())throw new Error(`Invalid buffer: Buffer is ${this._buffer.length} long, yet Stats object specifies that file is ${this._stat.size} long.`)}getBuffer(){return this._buffer}getStats(){return this._stat}getFlag(){return this._flag}getPath(){return this._path}getPos(){return this._flag.isAppendable()?this._stat.size:this._pos}advancePos(t){return this._pos+=t}setPos(t){return this._pos=t}sync(t){try{this.syncSync(),t()}catch(e){t(e)}}syncSync(){throw new a(c.ENOTSUP)}close(t){try{this.closeSync(),t()}catch(e){t(e)}}closeSync(){throw new a(c.ENOTSUP)}stat(t){try{t(null,r.clone(this._stat))}catch(e){t(e)}}statSync(){return r.clone(this._stat)}truncate(t,e){try{this.truncateSync(t),this._flag.isSynchronous()&&!i.getRootFS().supportsSynch()&&this.sync(e),e()}catch(t){return e(t)}}truncateSync(t){if(this._dirty=!0,!this._flag.isWriteable())throw new a(c.EPERM,"File not opened with a writeable mode.");if(this._stat.mtimeMs=Date.now(),t>this._buffer.length){const e=h.alloc(t-this._buffer.length,0);return this.writeSync(e,0,e.length,this._buffer.length),void(this._flag.isSynchronous()&&i.getRootFS().supportsSynch()&&this.syncSync())}this._stat.size=t;const e=h.alloc(t);this._buffer.copy(e,0,0,t),this._buffer=e,this._flag.isSynchronous()&&i.getRootFS().supportsSynch()&&this.syncSync()}write(t,e,r,s,i){try{i(null,this.writeSync(t,e,r,s),t)}catch(t){i(t)}}writeSync(t,e,r,s){if(this._dirty=!0,void 0!==s&&null!==s||(s=this.getPos()),!this._flag.isWriteable())throw new a(c.EPERM,"File not opened with a writeable mode.");const i=s+r;if(i>this._stat.size&&(this._stat.size=i,i>this._buffer.length)){const t=h.alloc(i);this._buffer.copy(t),this._buffer=t}const n=t.copy(this._buffer,s,e,e+r);return this._stat.mtimeMs=Date.now(),this._flag.isSynchronous()?(this.syncSync(),n):(this.setPos(s+n),n)}read(t,e,r,s,i){try{i(null,this.readSync(t,e,r,s),t)}catch(t){i(t)}}readSync(t,e,r,s){if(!this._flag.isReadable())throw new a(c.EPERM,"File not opened with a readable mode.");void 0!==s&&null!==s||(s=this.getPos());const i=s+r;i>this._stat.size&&(r=this._stat.size-s);const n=this._buffer.copy(t,e,s,s+r);return this._stat.atimeMs=Date.now(),this._pos=s+r,n}chmod(t,e){try{this.chmodSync(t),e()}catch(t){e(t)}}chmodSync(t){if(!this._fs.supportsProps())throw new a(c.ENOTSUP);this._dirty=!0,this._stat.chmod(t),this.syncSync()}isDirty(){return this._dirty}resetDirty(){this._dirty=!1}}return{PreloadFile:u,NoSyncFile:class extends u{constructor(t,e,r,s,i){super(t,e,r,s,i)}sync(t){t()}syncSync(){}close(t){t()}closeSync(){}}}}),t("skylark-browserfs/backend/AsyncMirror",["../core/file_system","../core/api_error","../core/file_flag","../generic/preload_file","../libs/path"],function(t,e,r,s,i){"use strict";const{SynchronousFileSystem:n}=t,{ApiError:o,ErrorCode:a}=e,{FileFlag:c}=r,{PreloadFile:l}=s;class h extends l{constructor(t,e,r,s,i){super(t,e,r,s,i)}syncSync(){this.isDirty()&&(this._fs._syncSync(this),this.resetDirty())}closeSync(){this.syncSync()}}class u extends n{constructor(t,e){super(),this._queue=[],this._queueRunning=!1,this._isInitialized=!1,this._initializeCallbacks=[],this._sync=t,this._async=e}static Create(t,e){try{const r=new u(t.sync,t.async);r._initialize(t=>{t?e(t):e(null,r)})}catch(t){e(t)}}static isAvailable(){return!0}getName(){return u.Name}_syncSync(t){this._sync.writeFileSync(t.getPath(),t.getBuffer(),null,c.getFileFlag("w"),t.getStats().mode),this.enqueueOp({apiMethod:"writeFile",arguments:[t.getPath(),t.getBuffer(),null,t.getFlag(),t.getStats().mode]})}isReadOnly(){return!1}supportsSynch(){return!0}supportsLinks(){return!1}supportsProps(){return this._sync.supportsProps()&&this._async.supportsProps()}renameSync(t,e){this._sync.renameSync(t,e),this.enqueueOp({apiMethod:"rename",arguments:[t,e]})}statSync(t,e){return this._sync.statSync(t,e)}openSync(t,e,r){const s=this._sync.openSync(t,e,r);return s.closeSync(),new h(this,t,e,this._sync.statSync(t,!1),this._sync.readFileSync(t,null,c.getFileFlag("r")))}unlinkSync(t){this._sync.unlinkSync(t),this.enqueueOp({apiMethod:"unlink",arguments:[t]})}rmdirSync(t){this._sync.rmdirSync(t),this.enqueueOp({apiMethod:"rmdir",arguments:[t]})}mkdirSync(t,e){this._sync.mkdirSync(t,e),this.enqueueOp({apiMethod:"mkdir",arguments:[t,e]})}readdirSync(t){return this._sync.readdirSync(t)}existsSync(t){return this._sync.existsSync(t)}chmodSync(t,e,r){this._sync.chmodSync(t,e,r),this.enqueueOp({apiMethod:"chmod",arguments:[t,e,r]})}chownSync(t,e,r,s){this._sync.chownSync(t,e,r,s),this.enqueueOp({apiMethod:"chown",arguments:[t,e,r,s]})}utimesSync(t,e,r){this._sync.utimesSync(t,e,r),this.enqueueOp({apiMethod:"utimes",arguments:[t,e,r]})}_initialize(t){const e=this._initializeCallbacks,r=t=>{this._isInitialized=!t,this._initializeCallbacks=[],e.forEach(e=>e(t))};if(this._isInitialized)t();else if(1===e.push(t)){const t=(t,e,r)=>{"/"!==t&&this._sync.mkdirSync(t,e),this._async.readdir(t,(e,n)=>{let o=0;e?r(e):function e(a){a?r(a):o<n.length?(s(i.join(t,n[o]),e),o++):r()}()})},e=(t,e,r)=>{this._async.readFile(t,null,c.getFileFlag("r"),(s,i)=>{if(s)r(s);else try{this._sync.writeFileSync(t,i,null,c.getFileFlag("w"),e)}catch(t){s=t}finally{r(s)}})},s=(r,s)=>{this._async.stat(r,!1,(i,n)=>{i?s(i):n.isDirectory()?t(r,n.mode,s):e(r,n.mode,s)})};t("/",0,r)}}enqueueOp(t){if(this._queue.push(t),!this._queueRunning){this._queueRunning=!0;const t=e=>{if(e)throw new Error(`WARNING: File system has desynchronized. Received following error: ${e}\n$`);if(this._queue.length>0){const e=this._queue.shift(),r=e.arguments;r.push(t),this._async[e.apiMethod].apply(this._async,r)}else this._queueRunning=!1};t()}}}return u.Name="AsyncMirror",u.Options={sync:{type:"object",description:"The synchronous file system to mirror the asynchronous file system to.",validator:(t,e)=>{t&&"function"==typeof t.supportsSynch&&t.supportsSynch()?e():e(new o(a.EINVAL,"'sync' option must be a file system that supports synchronous operations"))}},async:{type:"object",description:"The asynchronous file system to mirror."}},u}),t("skylark-browserfs/backend/Dropbox",["../libs/buffers","../generic/preload_file","../core/file_system","../core/node_fs_stats","../core/api_error","../core/util","../generic/setImmediate","../libs/path"],function(t,e,r,s,i,n,o,a){"use strict";const{BaseFileSystem:c}=r,{Stats:l,FileType:h}=s,{ApiError:u,ErrorCode:d}=i,{arrayBuffer2Buffer:f,buffer2ArrayBuffer:y}=n,{dirname:p}=a,{PreloadFile:m}=e,{Buffer:g}=t;function _(t){return"/"===t?"":t}function S(t){const e=t.error;if(e[".tag"])return e;if(e.error){const t=e.error;return t[".tag"]?t:t.reason&&t.reason[".tag"]?t.reason:t}if("string"==typeof e)try{const r=JSON.parse(e);if(r.error&&r.error.reason&&r.error.reason[".tag"])return r.error.reason}catch(t){}return e}function E(t){if(t.user_message)return t.user_message.text;if(t.error_summary)return t.error_summary;if("string"==typeof t.error)return t.error;if("object"==typeof t.error)return E(t.error);throw new Error(`Dropbox's servers gave us a garbage error message: ${JSON.stringify(t)}`)}function w(t,e,r){switch(t[".tag"]){case"malformed_path":return new u(d.EBADF,r,e);case"not_found":return u.ENOENT(e);case"not_file":return u.EISDIR(e);case"not_folder":return u.ENOTDIR(e);case"restricted_content":return u.EPERM(e);case"other":default:return new u(d.EIO,r,e)}}function b(t,e,r){switch(t[".tag"]){case"malformed_path":case"disallowed_name":return new u(d.EBADF,r,e);case"conflict":case"no_write_permission":case"team_folder":return u.EPERM(e);case"insufficient_space":return new u(d.ENOSPC,r);case"other":default:return new u(d.EIO,r,e)}}function F(t,e,r){const s={path:_(e)};t.filesDeleteV2(s).then(()=>{r()}).catch(s=>{const i=S(s);switch(i[".tag"]){case"path_lookup":r(w(i.path_lookup,e,E(s)));break;case"path_write":r(b(i.path_write,e,E(s)));break;case"too_many_write_operations":setTimeout(()=>F(t,e,r),500+300*Math.random());break;case"other":default:r(new u(d.EIO,E(s),e))}})}class I extends m{constructor(t,e,r,s,i){super(t,e,r,s,i)}sync(t){this._fs._syncFile(this.getPath(),this.getBuffer(),t)}close(t){this.sync(t)}}class k extends c{constructor(t){super(),this._client=t}static Create(t,e){e(null,new k(t.client))}static isAvailable(){return"undefined"!=typeof Dropbox}getName(){return k.Name}isReadOnly(){return!1}supportsSymlinks(){return!1}supportsProps(){return!1}supportsSynch(){return!1}empty(t){this.readdir("/",(e,r)=>{if(r){const e=s=>{0===r.length?t():F(this._client,r.shift(),e)};e()}else t(e)})}rename(t,e,r){this.stat(e,!1,(s,i)=>{const n=()=>{const s={from_path:_(t),to_path:_(e)};this._client.filesMoveV2(s).then(()=>r()).catch(function(s){const i=S(s);switch(i[".tag"]){case"from_lookup":r(w(i.from_lookup,t,E(s)));break;case"from_write":r(b(i.from_write,t,E(s)));break;case"to":r(b(i.to,e,E(s)));break;case"cant_copy_shared_folder":case"cant_nest_shared_folder":r(new u(d.EPERM,E(s),t));break;case"cant_move_folder_into_itself":case"duplicated_or_nested_paths":r(new u(d.EBADF,E(s),t));break;case"too_many_files":r(new u(d.ENOSPC,E(s),t));break;case"other":default:r(new u(d.EIO,E(s),t))}})};s?n():t===e?s?r(u.ENOENT(e)):r():i&&i.isDirectory()?r(u.EISDIR(e)):this.unlink(e,t=>{t?r(t):n()})})}stat(t,e,r){if("/"===t)return void o(function(){r(null,new l(h.DIRECTORY,4096))});const s={path:_(t)};this._client.filesGetMetadata(s).then(e=>{switch(e[".tag"]){case"file":const s=e;r(null,new l(h.FILE,s.size));break;case"folder":r(null,new l(h.DIRECTORY,4096));break;case"deleted":r(u.ENOENT(t))}}).catch(e=>{const s=S(e);switch(s[".tag"]){case"path":r(w(s.path,t,E(e)));break;default:r(new u(d.EIO,E(e),t))}})}openFile(t,e,r){const s={path:_(t)};this._client.filesDownload(s).then(s=>{const i=s.fileBlob,n=new FileReader;n.onload=(()=>{const s=n.result;r(null,new I(this,t,e,new l(h.FILE,s.byteLength),f(s)))}),n.readAsArrayBuffer(i)}).catch(e=>{const s=S(e);switch(s[".tag"]){case"path":const i=s;r(w(i.path,t,E(e)));break;case"other":default:r(new u(d.EIO,E(e),t))}})}createFile(t,e,r,s){const i=g.alloc(0),n=new Blob([y(i)],{type:"octet/stream"}),o={contents:n,path:_(t)};this._client.filesUpload(o).then(r=>{s(null,new I(this,t,e,new l(h.FILE,0),i))}).catch(i=>{const n=S(i);switch(n[".tag"]){case"path":const o=n;s(b(o.path.reason,t,E(i)));break;case"too_many_write_operations":setTimeout(()=>this.createFile(t,e,r,s),500+300*Math.random());break;case"other":default:s(new u(d.EIO,E(i),t))}})}unlink(t,e){this.stat(t,!1,(r,s)=>{s?s.isDirectory()?e(u.EISDIR(t)):F(this._client,t,e):e(r)})}rmdir(t,e){this.readdir(t,(r,s)=>{s?s.length>0?e(u.ENOTEMPTY(t)):F(this._client,t,e):e(r)})}mkdir(t,e,r){const s=p(t);this.stat(s,!1,(i,n)=>{if(i)r(i);else if(n&&!n.isDirectory())r(u.ENOTDIR(s));else{const s={path:_(t)};this._client.filesCreateFolderV2(s).then(()=>r()).catch(s=>{const i=S(s);"too_many_write_operations"===i[".tag"]?setTimeout(()=>this.mkdir(t,e,r),500+300*Math.random()):r(b(S(s).path,t,E(s)))})}})}readdir(t,e){const r={path:_(t)};this._client.filesListFolder(r).then(r=>{!function t(e,r,s,i,n){const o=s.entries.map(t=>t.path_display).filter(t=>!!t);const a=i.concat(o);if(s.has_more){const i={cursor:s.cursor};e.filesListFolderContinue(i).then(s=>{t(e,r,s,a,n)}).catch(t=>{N(t,r,n)})}else n(null,a)}(this._client,t,r,[],e)}).catch(r=>{N(r,t,e)})}_syncFile(t,e,r){const s=new Blob([y(e)],{type:"octet/stream"}),i={contents:s,path:_(t),mode:{".tag":"overwrite"}};this._client.filesUpload(i).then(()=>{r()}).catch(s=>{const i=S(s);switch(i[".tag"]){case"path":const n=i;r(b(n.path.reason,t,E(s)));break;case"too_many_write_operations":setTimeout(()=>this._syncFile(t,e,r),500+300*Math.random());break;case"other":default:r(new u(d.EIO,E(s),t))}})}}function N(t,e,r){const s=S(t);switch(s[".tag"]){case"path":const i=s;r(w(i.path,e,E(t)));break;case"other":default:r(new u(d.EIO,E(t),e))}}return k.Name="DropboxV2",k.Options={client:{type:"object",description:"An *authenticated* Dropbox client. Must be from the 2.5.x JS SDK."}},k.DropboxFile=I,k}),t("skylark-browserfs/backend/Emscripten",["../libs/buffers","../core/file_system","../core/node_fs_stats","../core/file","../core/util","../core/api_error"],function(t,e,r,s,i,n){"use strict";const{SynchronousFileSystem:o}=e,{Stats:a,FileType:c}=r,{BaseFile:l}=s,{uint8Array2Buffer:h,buffer2Uint8array:u}=i,{ApiError:d,ErrorCode:f,ErrorStrings:y}=n,{Buffer:p}=t;function m(t,e=""){const r=t.errno;let s=t.node;const i=[];for(;s&&(i.unshift(s.name),s!==s.parent);)s=s.parent;return new d(r,y[r],i.length>0?"/"+i.join("/"):e)}class g extends l{constructor(t,e,r,s){super(),this._fs=t,this._FS=e,this._path=r,this._stream=s}getPos(){}close(t){let e=null;try{this.closeSync()}catch(t){e=t}finally{t(e)}}closeSync(){try{this._FS.close(this._stream)}catch(t){throw m(t,this._path)}}stat(t){try{t(null,this.statSync())}catch(e){t(e)}}statSync(){try{return this._fs.statSync(this._path,!1)}catch(t){throw m(t,this._path)}}truncate(t,e){let r=null;try{this.truncateSync(t)}catch(t){r=t}finally{e(r)}}truncateSync(t){try{this._FS.ftruncate(this._stream.fd,t)}catch(t){throw m(t,this._path)}}write(t,e,r,s,i){try{i(null,this.writeSync(t,e,r,s),t)}catch(t){i(t)}}writeSync(t,e,r,s){try{const i=u(t),n=null===s?void 0:s;return this._FS.write(this._stream,i,e,r,n)}catch(t){throw m(t,this._path)}}read(t,e,r,s,i){try{i(null,this.readSync(t,e,r,s),t)}catch(t){i(t)}}readSync(t,e,r,s){try{const i=u(t),n=null===s?void 0:s;return this._FS.read(this._stream,i,e,r,n)}catch(t){throw m(t,this._path)}}sync(t){t()}syncSync(){}chown(t,e,r){let s=null;try{this.chownSync(t,e)}catch(t){s=t}finally{r(s)}}chownSync(t,e){try{this._FS.fchown(this._stream.fd,t,e)}catch(t){throw m(t,this._path)}}chmod(t,e){let r=null;try{this.chmodSync(t)}catch(t){r=t}finally{e(r)}}chmodSync(t){try{this._FS.fchmod(this._stream.fd,t)}catch(t){throw m(t,this._path)}}utimes(t,e,r){let s=null;try{this.utimesSync(t,e)}catch(t){s=t}finally{r(s)}}utimesSync(t,e){this._fs.utimesSync(this._path,t,e)}}class _ extends o{constructor(t){super(),this._FS=t}static Create(t,e){e(null,new _(t.FS))}static isAvailable(){return!0}getName(){return this._FS.DB_NAME()}isReadOnly(){return!1}supportsLinks(){return!0}supportsProps(){return!0}supportsSynch(){return!0}renameSync(t,e){try{this._FS.rename(t,e)}catch(r){throw r.errno===f.ENOENT?m(r,this.existsSync(t)?e:t):m(r)}}statSync(t,e){try{const r=e?this._FS.lstat(t):this._FS.stat(t),s=this.modeToFileType(r.mode);return new a(s,r.size,r.mode,r.atime.getTime(),r.mtime.getTime(),r.ctime.getTime())}catch(e){throw m(e,t)}}openSync(t,e,r){try{const s=this._FS.open(t,e.getFlagString(),r);if(this._FS.isDir(s.node.mode))throw this._FS.close(s),d.EISDIR(t);return new g(this,this._FS,t,s)}catch(e){throw m(e,t)}}unlinkSync(t){try{this._FS.unlink(t)}catch(e){throw m(e,t)}}rmdirSync(t){try{this._FS.rmdir(t)}catch(e){throw m(e,t)}}mkdirSync(t,e){try{this._FS.mkdir(t,e)}catch(e){throw m(e,t)}}readdirSync(t){try{return this._FS.readdir(t).filter(t=>"."!==t&&".."!==t)}catch(e){throw m(e,t)}}truncateSync(t,e){try{this._FS.truncate(t,e)}catch(e){throw m(e,t)}}readFileSync(t,e,r){try{const s=this._FS.readFile(t,{flags:r.getFlagString()}),i=h(s);return e?i.toString(e):i}catch(e){throw m(e,t)}}writeFileSync(t,e,r,s,i){try{r&&(e=p.from(e,r));const n=u(e);this._FS.writeFile(t,n,{flags:s.getFlagString(),encoding:"binary"}),this._FS.chmod(t,i)}catch(e){throw m(e,t)}}chmodSync(t,e,r){try{e?this._FS.lchmod(t,r):this._FS.chmod(t,r)}catch(e){throw m(e,t)}}chownSync(t,e,r,s){try{e?this._FS.lchown(t,r,s):this._FS.chown(t,r,s)}catch(e){throw m(e,t)}}symlinkSync(t,e,r){try{this._FS.symlink(t,e)}catch(t){throw m(t)}}readlinkSync(t){try{return this._FS.readlink(t)}catch(e){throw m(e,t)}}utimesSync(t,e,r){try{this._FS.utime(t,e.getTime(),r.getTime())}catch(e){throw m(e,t)}}modeToFileType(t){if(this._FS.isDir(t))return c.DIRECTORY;if(this._FS.isFile(t))return c.FILE;if(this._FS.isLink(t))return c.SYMLINK;throw d.EPERM(`Invalid mode: ${t}`)}}return _.Name="EmscriptenFileSystem",_.Options={FS:{type:"object",description:"The Emscripten file system to use (the `FS` variable)"}},_.EmscriptenFile=g,_}),t("skylark-browserfs/backend/FolderAdapter",["../core/file_system","../libs/path","../core/api_error"],function(t,e,r){"use strict";const{BaseFileSystem:s}=t,{ApiError:i}=r;class n extends s{constructor(t,e){super(),this._folder=t,this._wrapped=e}static Create(t,e){const r=new n(t.folder,t.wrapped);r._initialize(function(t){t?e(t):e(null,r)})}static isAvailable(){return!0}getName(){return this._wrapped.getName()}isReadOnly(){return this._wrapped.isReadOnly()}supportsProps(){return this._wrapped.supportsProps()}supportsSynch(){return this._wrapped.supportsSynch()}supportsLinks(){return!1}_initialize(t){this._wrapped.exists(this._folder,e=>{e?t():this._wrapped.isReadOnly()?t(i.ENOENT(this._folder)):this._wrapped.mkdir(this._folder,511,t)})}}function o(t,r){if(null!==r&&"object"==typeof r){const s=r;let i=s.path;i&&(i="/"+e.relative(t,i),s.message=s.message.replace(s.path,i),s.path=i)}return r}function a(t,r,s){return"Sync"!==t.slice(t.length-4)?function(){var i,n;return arguments.length>0&&(r&&(arguments[0]=e.join(this._folder,arguments[0])),s&&(arguments[1]=e.join(this._folder,arguments[1])),arguments[arguments.length-1]=(i=this._folder,"function"==typeof(n=arguments[arguments.length-1])?function(t){arguments.length>0&&(arguments[0]=o(i,t)),n.apply(null,arguments)}:n)),this._wrapped[t].apply(this._wrapped,arguments)}:function(){try{return r&&(arguments[0]=e.join(this._folder,arguments[0])),s&&(arguments[1]=e.join(this._folder,arguments[1])),this._wrapped[t].apply(this._wrapped,arguments)}catch(t){throw o(this._folder,t)}}}return n.Name="FolderAdapter",n.Options={folder:{type:"string",description:"The folder to use as the root directory"},wrapped:{type:"object",description:"The file system to wrap"}},["diskSpace","stat","statSync","open","openSync","unlink","unlinkSync","rmdir","rmdirSync","mkdir","mkdirSync","readdir","readdirSync","exists","existsSync","realpath","realpathSync","truncate","truncateSync","readFile","readFileSync","writeFile","writeFileSync","appendFile","appendFileSync","chmod","chmodSync","chown","chownSync","utimes","utimesSync","readlink","readlinkSync"].forEach(t=>{n.prototype[t]=a(t,!0,!1)}),["rename","renameSync","link","linkSync","symlink","symlinkSync"].forEach(t=>{n.prototype[t]=a(t,!0,!0)}),n}),t("skylark-browserfs/backend/HTML5FS",["skylark-langx-async","../generic/preload_file","../core/file_system","../core/api_error","../core/file_flag","../core/node_fs_stats","../libs/path","../core/global","../core/util"],function(t,e,r,s,i,n,o,a,c){"use strict";const{BaseFileSystem:l}=r,{ApiError:h,ErrorCode:u}=s,{ActionType:d}=i,{Stats:f,FileType:y}=n,p=t.each,{buffer2ArrayBuffer:m,arrayBuffer2Buffer:g}=c,{PreloadFile:_}=e;const S=a.webkitRequestFileSystem||a.requestFileSystem||null;function E(t,e,r){switch(t.name){case"PathExistsError":return h.EEXIST(e);case"QuotaExceededError":return h.FileError(u.ENOSPC,e);case"NotFoundError":return h.ENOENT(e);case"SecurityError":return h.FileError(u.EACCES,e);case"InvalidModificationError":return h.FileError(u.EPERM,e);case"TypeMismatchError":return h.FileError(r?u.ENOTDIR:u.EISDIR,e);case"EncodingError":case"InvalidStateError":case"NoModificationAllowedError":default:return h.FileError(u.EINVAL,e)}}class w extends _{constructor(t,e,r,s,i,n){super(t,r,s,i,n),this._entry=e}sync(t){if(!this.isDirty())return t();this._entry.createWriter(e=>{const r=this.getBuffer(),s=new Blob([m(r)]),i=s.size;e.onwriteend=(r=>{e.onwriteend=null,e.onerror=null,e.truncate(i),this.resetDirty(),t()}),e.onerror=(e=>{t(E(e,this.getPath(),!1))}),e.write(s)})}close(t){this.sync(t)}}class b extends l{constructor(t=5,e=a.PERSISTENT){super(),this.size=1048576*t,this.type=e}static Create(t,e){const r=new b(t.size,t.type);r._allocate(t=>t?e(t):e(null,r))}static isAvailable(){return!!S}getName(){return b.Name}isReadOnly(){return!1}supportsSymlinks(){return!1}supportsProps(){return!1}supportsSynch(){return!1}empty(t){this._readdir("/",(e,r)=>{if(e)t(e);else{const s=r=>{e?t(e):t()},i=(t,e)=>{const r=()=>{e()},s=r=>{e(E(r,t.fullPath,!t.isDirectory))};t.isDirectory?t.removeRecursively(r,s):t.remove(r,s)};p(r,i,s)}})}rename(t,e,r){let s=2,i=0;const n=this.fs.root;let a=t;const c=t=>{--s<=0&&r(E(t,a,!1))},l=s=>2==++i?r(new h(u.EINVAL,"Something was identified as both a file and a directory. This should never happen.")):t===e?r():(a=o.dirname(e),void n.getDirectory(a,{},i=>{a=o.basename(e),s.moveTo(i,a,t=>{r()},i=>{s.isDirectory?(a=e,this.unlink(e,s=>{s?c(i):this.rename(t,e,r)})):c(i)})},c));n.getFile(t,{},l,c),n.getDirectory(t,{},l,c)}stat(t,e,r){const s={create:!1},i=t=>{const e=new f(y.DIRECTORY,4096);r(null,e)},n=e=>{r(E(e,t,!1))};this.fs.root.getFile(t,s,t=>{t.file(t=>{const e=new f(y.FILE,t.size);r(null,e)},n)},()=>{this.fs.root.getDirectory(t,s,i,n)})}open(t,e,r,s){const i=r=>{"InvalidModificationError"===r.name&&e.isExclusive()?s(h.EEXIST(t)):s(E(r,t,!1))};this.fs.root.getFile(t,{create:e.pathNotExistsAction()===d.CREATE_FILE,exclusive:e.isExclusive()},r=>{r.file(n=>{const o=new FileReader;o.onloadend=(i=>{const a=this._makeFile(t,r,e,n,o.result);s(null,a)}),o.onerror=(t=>{i(o.error)}),o.readAsArrayBuffer(n)},i)},i)}unlink(t,e){this._remove(t,e,!0)}rmdir(t,e){this.readdir(t,(r,s)=>{r?e(r):s.length>0?e(h.ENOTEMPTY(t)):this._remove(t,e,!1)})}mkdir(t,e,r){this.fs.root.getDirectory(t,{create:!0,exclusive:!0},t=>{r()},e=>{r(E(e,t,!0))})}readdir(t,e){this._readdir(t,(t,r)=>{if(!r)return e(t);{const t=[];for(const e of r)t.push(e.name);e(null,t)}})}_makeFile(t,e,r,s,i=new ArrayBuffer(0)){const n=new f(y.FILE,s.size),o=g(i);return new w(this,e,t,r,n,o)}_readdir(t,e){const r=r=>{e(E(r,t,!0))};var s;this.fs.root.getDirectory(t,{create:!1},t=>{const i=t.createReader();let n=[];const o=()=>{i.readEntries(t=>{t.length?(n=n.concat((s=t,Array.prototype.slice.call(s||[],0))),o()):e(null,n)},r)};o()},r)}_allocate(t){const e=e=>{this.fs=e,t()},r=e=>{t(E(e,"/",!0))};this.type===a.PERSISTENT?function(t,e,r,s){if(void 0!==navigator.webkitPersistentStorage)switch(t){case a.PERSISTENT:navigator.webkitPersistentStorage.requestQuota(e,r,s);break;case a.TEMPORARY:navigator.webkitTemporaryStorage.requestQuota(e,r,s);break;default:s(new TypeError(`Invalid storage type: ${t}`))}else a.webkitStorageInfo.requestQuota(t,e,r,s)}(this.type,this.size,t=>{S(this.type,t,e,r)},r):S(this.type,this.size,e,r)}_remove(t,e,r){const s=s=>{s.remove(()=>{e()},s=>{e(E(s,t,!r))})},i=s=>{e(E(s,t,!r))},n={create:!1};r?this.fs.root.getFile(t,n,s,i):this.fs.root.getDirectory(t,n,s,i)}}return b.Name="HTML5FS",b.Options={size:{type:"number",optional:!0,description:"Storage quota to request, in megabytes. Allocated value may be less. Defaults to 5."},type:{type:"number",optional:!0,description:"window.PERSISTENT or window.TEMPORARY. Defaults to PERSISTENT."}},b.HTML5FSFile=w,b}),t("skylark-browserfs/generic/inode",["../libs/buffers","../core/node_fs_stats"],function(t,e){"use strict";const{Stats:r,FileType:s}=e,{Buffer:i}=t;class n{constructor(t,e,r,s,i,n){this.id=t,this.size=e,this.mode=r,this.atime=s,this.mtime=i,this.ctime=n}static fromBuffer(t){if(void 0===t)throw new Error("NO");return new n(t.toString("ascii",30),t.readUInt32LE(0),t.readUInt16LE(4),t.readDoubleLE(6),t.readDoubleLE(14),t.readDoubleLE(22))}toStats(){return new r((61440&this.mode)===s.DIRECTORY?s.DIRECTORY:s.FILE,this.size,this.mode,this.atime,this.mtime,this.ctime)}getSize(){return 30+this.id.length}toBuffer(t=i.alloc(this.getSize())){return t.writeUInt32LE(this.size,0),t.writeUInt16LE(this.mode,4),t.writeDoubleLE(this.atime,6),t.writeDoubleLE(this.mtime,14),t.writeDoubleLE(this.ctime,22),t.write(this.id,30,this.id.length,"ascii"),t}update(t){let e=!1;this.size!==t.size&&(this.size=t.size,e=!0),this.mode!==t.mode&&(this.mode=t.mode,e=!0);const r=t.atime.getTime();this.atime!==r&&(this.atime=r,e=!0);const s=t.mtime.getTime();this.mtime!==s&&(this.mtime=s,e=!0);const i=t.ctime.getTime();return this.ctime!==i&&(this.ctime=i,e=!0),e}isFile(){return(61440&this.mode)===s.FILE}isDirectory(){return(61440&this.mode)===s.DIRECTORY}}return n}),t("skylark-browserfs/generic/key_value_filesystem",["../libs/buffers","../core/file_system","../core/api_error","../core/node_fs_stats","../libs/path","../generic/inode","../generic/preload_file","../core/util"],function(t,e,r,s,i,n,o,a){"use strict";const{BaseFileSystem:c,SynchronousFileSystem:l}=e,{ApiError:h,ErrorCode:u}=r,{FileType:d}=s,{emptyBuffer:f}=a,{PreloadFile:y}=o,{Buffer:p}=t,m="/";let g=null;function _(){return g||(g=p.from("{}"))}function S(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=16*Math.random()|0,r="x"===t?e:3&e|8;return r.toString(16)})}function E(t,e){return!t||(e(t),!1)}function w(t,e,r){return!t||(e.abort(()=>{r(t)}),!1)}class b{constructor(t,e){this.key=t,this.value=e,this.prev=null,this.next=null}}class F{constructor(t){this.limit=t,this.size=0,this.map={},this.head=null,this.tail=null}set(t,e){const r=new b(t,e);this.map[t]?(this.map[t].value=r.value,this.remove(r.key)):this.size>=this.limit&&(delete this.map[this.tail.key],this.size--,this.tail=this.tail.prev,this.tail.next=null),this.setHead(r)}get(t){if(this.map[t]){const e=this.map[t].value,r=new b(t,e);return this.remove(t),this.setHead(r),e}return null}remove(t){const e=this.map[t];e&&(null!==e.prev?e.prev.next=e.next:this.head=e.next,null!==e.next?e.next.prev=e.prev:this.tail=e.prev,delete this.map[t],this.size--)}removeAll(){this.size=0,this.map={},this.head=null,this.tail=null}setHead(t){t.next=this.head,t.prev=null,null!==this.head&&(this.head.prev=t),this.head=t,null===this.tail&&(this.tail=t),this.size++,this.map[t.key]=t}}class I extends y{constructor(t,e,r,s,i){super(t,e,r,s,i)}syncSync(){this.isDirty()&&(this._fs._syncSync(this.getPath(),this.getBuffer(),this.getStats()),this.resetDirty())}closeSync(){this.syncSync()}}class k extends y{constructor(t,e,r,s,i){super(t,e,r,s,i)}sync(t){this.isDirty()?this._fs._sync(this.getPath(),this.getBuffer(),this.getStats(),e=>{e||this.resetDirty(),t(e)}):t()}close(t){this.sync(t)}}return{SimpleSyncRWTransaction:class{constructor(t){this.store=t,this.originalData={},this.modifiedKeys=[]}get(t){const e=this.store.get(t);return this.stashOldValue(t,e),e}put(t,e,r){return this.markModified(t),this.store.put(t,e,r)}del(t){this.markModified(t),this.store.del(t)}commit(){}abort(){for(const t of this.modifiedKeys){const e=this.originalData[t];e?this.store.put(t,e,!0):this.store.del(t)}}stashOldValue(t,e){this.originalData.hasOwnProperty(t)||(this.originalData[t]=e)}markModified(t){-1===this.modifiedKeys.indexOf(t)&&(this.modifiedKeys.push(t),this.originalData.hasOwnProperty(t)||(this.originalData[t]=this.store.get(t)))}},SyncKeyValueFile:I,SyncKeyValueFileSystem:class extends l{static isAvailable(){return!0}constructor(t){super(),this.store=t.store,this.makeRootDirectory()}getName(){return this.store.name()}isReadOnly(){return!1}supportsSymlinks(){return!1}supportsProps(){return!1}supportsSynch(){return!0}empty(){this.store.clear(),this.makeRootDirectory()}renameSync(t,e){const r=this.store.beginTransaction("readwrite"),s=i.dirname(t),n=i.basename(t),o=i.dirname(e),a=i.basename(e),c=this.findINode(r,s),l=this.getDirListing(r,s,c);if(!l[n])throw h.ENOENT(t);const d=l[n];if(delete l[n],0===(o+"/").indexOf(t+"/"))throw new h(u.EBUSY,s);let f,y;if(o===s?(f=c,y=l):(f=this.findINode(r,o),y=this.getDirListing(r,o,f)),y[a]){const t=this.getINode(r,e,y[a]);if(!t.isFile())throw h.EPERM(e);try{r.del(t.id),r.del(y[a])}catch(t){throw r.abort(),t}}y[a]=d;try{r.put(c.id,p.from(JSON.stringify(l)),!0),r.put(f.id,p.from(JSON.stringify(y)),!0)}catch(t){throw r.abort(),t}r.commit()}statSync(t,e){return this.findINode(this.store.beginTransaction("readonly"),t).toStats()}createFileSync(t,e,r){const s=this.store.beginTransaction("readwrite"),i=f(),n=this.commitNewFile(s,t,d.FILE,r,i);return new I(this,t,e,n.toStats(),i)}openFileSync(t,e){const r=this.store.beginTransaction("readonly"),s=this.findINode(r,t),i=r.get(s.id);if(void 0===i)throw h.ENOENT(t);return new I(this,t,e,s.toStats(),i)}unlinkSync(t){this.removeEntry(t,!1)}rmdirSync(t){if(this.readdirSync(t).length>0)throw h.ENOTEMPTY(t);this.removeEntry(t,!0)}mkdirSync(t,e){const r=this.store.beginTransaction("readwrite"),s=p.from("{}");this.commitNewFile(r,t,d.DIRECTORY,e,s)}readdirSync(t){const e=this.store.beginTransaction("readonly");return Object.keys(this.getDirListing(e,t,this.findINode(e,t)))}_syncSync(t,e,r){const s=this.store.beginTransaction("readwrite"),n=this._findINode(s,i.dirname(t),i.basename(t)),o=this.getINode(s,t,n),a=o.update(r);try{s.put(o.id,e,!0),a&&s.put(n,o.toBuffer(),!0)}catch(t){throw s.abort(),t}s.commit()}makeRootDirectory(){const t=this.store.beginTransaction("readwrite");if(void 0===t.get(m)){const e=(new Date).getTime(),r=new n(S(),4096,511|d.DIRECTORY,e,e,e);t.put(r.id,_(),!1),t.put(m,r.toBuffer(),!1),t.commit()}}_findINode(t,e,r){const s=s=>{const n=this.getDirListing(t,e,s);if(n[r])return n[r];throw h.ENOENT(i.resolve(e,r))};return"/"===e?""===r?m:s(this.getINode(t,e,m)):s(this.getINode(t,e+i.sep+r,this._findINode(t,i.dirname(e),i.basename(e))))}findINode(t,e){return this.getINode(t,e,this._findINode(t,i.dirname(e),i.basename(e)))}getINode(t,e,r){const s=t.get(r);if(void 0===s)throw h.ENOENT(e);return n.fromBuffer(s)}getDirListing(t,e,r){if(!r.isDirectory())throw h.ENOTDIR(e);const s=t.get(r.id);if(void 0===s)throw h.ENOENT(e);return JSON.parse(s.toString())}addNewNode(t,e){let r;for(;;)try{return r=S(),t.put(r,e,!1),r}catch(t){}throw new h(u.EIO,"Unable to commit data to key-value store.")}commitNewFile(t,e,r,s,o){const a=i.dirname(e),c=i.basename(e),l=this.findINode(t,a),u=this.getDirListing(t,a,l),d=(new Date).getTime();if("/"===e)throw h.EEXIST(e);if(u[c])throw h.EEXIST(e);let f;try{const e=this.addNewNode(t,o);f=new n(e,o.length,s|r,d,d,d);const i=this.addNewNode(t,f.toBuffer());u[c]=i,t.put(l.id,p.from(JSON.stringify(u)),!0)}catch(e){throw t.abort(),e}return t.commit(),f}removeEntry(t,e){const r=this.store.beginTransaction("readwrite"),s=i.dirname(t),n=this.findINode(r,s),o=this.getDirListing(r,s,n),a=i.basename(t);if(!o[a])throw h.ENOENT(t);const c=o[a];delete o[a];const l=this.getINode(r,t,c);if(!e&&l.isDirectory())throw h.EISDIR(t);if(e&&!l.isDirectory())throw h.ENOTDIR(t);try{r.del(l.id),r.del(c),r.put(n.id,p.from(JSON.stringify(o)),!0)}catch(t){throw r.abort(),t}r.commit()}},AsyncKeyValueFile:k,AsyncKeyValueFileSystem:class extends c{constructor(t){super(),this._cache=null,t>0&&(this._cache=new F(t))}static isAvailable(){return!0}init(t,e){this.store=t,this.makeRootDirectory(e)}getName(){return this.store.name()}isReadOnly(){return!1}supportsSymlinks(){return!1}supportsProps(){return!1}supportsSynch(){return!1}empty(t){this._cache&&this._cache.removeAll(),this.store.clear(e=>{E(e,t)&&this.makeRootDirectory(t)})}rename(t,e,r){if(this._cache){const t=this._cache;this._cache=null,t.removeAll();const e=r;r=(r=>{this._cache=t,e(r)})}const s=this.store.beginTransaction("readwrite"),n=i.dirname(t),o=i.basename(t),a=i.dirname(e),c=i.basename(e),l={},d={};let f=!1;if(0===(a+"/").indexOf(t+"/"))return r(new h(u.EBUSY,n));const y=()=>{if(f||!d.hasOwnProperty(n)||!d.hasOwnProperty(a))return;const i=d[n],u=l[n],y=d[a],m=l[a];if(i[o]){const t=i[o];delete i[o];const l=()=>{y[c]=t,s.put(u.id,p.from(JSON.stringify(i)),!0,t=>{w(t,s,r)&&(n===a?s.commit(r):s.put(m.id,p.from(JSON.stringify(y)),!0,t=>{w(t,s,r)&&s.commit(r)}))})};y[c]?this.getINode(s,e,y[c],(t,i)=>{w(t,s,r)&&(i.isFile()?s.del(i.id,t=>{w(t,s,r)&&s.del(y[c],t=>{w(t,s,r)&&l()})}):s.abort(t=>{r(h.EPERM(e))}))}):l()}else r(h.ENOENT(t))},m=t=>{this.findINodeAndDirListing(s,t,(e,i,n)=>{e?f||(f=!0,s.abort(()=>{r(e)})):(l[t]=i,d[t]=n,y())})};m(n),n!==a&&m(a)}stat(t,e,r){const s=this.store.beginTransaction("readonly");this.findINode(s,t,(t,e)=>{E(t,r)&&r(null,e.toStats())})}createFile(t,e,r,s){const i=this.store.beginTransaction("readwrite"),n=f();this.commitNewFile(i,t,d.FILE,r,n,(r,i)=>{E(r,s)&&s(null,new k(this,t,e,i.toStats(),n))})}openFile(t,e,r){const s=this.store.beginTransaction("readonly");this.findINode(s,t,(i,n)=>{E(i,r)&&s.get(n.id,(s,i)=>{E(s,r)&&(void 0===i?r(h.ENOENT(t)):r(null,new k(this,t,e,n.toStats(),i)))})})}unlink(t,e){this.removeEntry(t,!1,e)}rmdir(t,e){this.readdir(t,(r,s)=>{r?e(r):s.length>0?e(h.ENOTEMPTY(t)):this.removeEntry(t,!0,e)})}mkdir(t,e,r){const s=this.store.beginTransaction("readwrite"),i=p.from("{}");this.commitNewFile(s,t,d.DIRECTORY,e,i,r)}readdir(t,e){const r=this.store.beginTransaction("readonly");this.findINode(r,t,(s,i)=>{E(s,e)&&this.getDirListing(r,t,i,(t,r)=>{E(t,e)&&e(null,Object.keys(r))})})}_sync(t,e,r,s){const n=this.store.beginTransaction("readwrite");this._findINode(n,i.dirname(t),i.basename(t),(i,o)=>{w(i,n,s)&&this.getINode(n,t,o,(t,i)=>{if(w(t,n,s)){const t=i.update(r);n.put(i.id,e,!0,e=>{w(e,n,s)&&(t?n.put(o,i.toBuffer(),!0,t=>{w(t,n,s)&&n.commit(s)}):n.commit(s))})}})})}makeRootDirectory(t){const e=this.store.beginTransaction("readwrite");e.get(m,(r,s)=>{if(r||void 0===s){const r=(new Date).getTime(),s=new n(S(),4096,511|d.DIRECTORY,r,r,r);e.put(s.id,_(),!1,r=>{w(r,e,t)&&e.put(m,s.toBuffer(),!1,r=>{r?e.abort(()=>{t(r)}):e.commit(t)})})}else e.commit(t)})}_findINode(t,e,r,s){if(this._cache){const t=this._cache.get(i.join(e,r));if(t)return s(null,t)}const n=(t,n,o)=>{if(t)s(t);else if(o[r]){const t=o[r];this._cache&&this._cache.set(i.join(e,r),t),s(null,t)}else s(h.ENOENT(i.resolve(e,r)))};"/"===e?""===r?(this._cache&&this._cache.set(i.join(e,r),m),s(null,m)):this.getINode(t,e,m,(r,i)=>{E(r,s)&&this.getDirListing(t,e,i,(t,e)=>{n(t,i,e)})}):this.findINodeAndDirListing(t,e,n)}findINode(t,e,r){this._findINode(t,i.dirname(e),i.basename(e),(s,i)=>{E(s,r)&&this.getINode(t,e,i,r)})}getINode(t,e,r,s){t.get(r,(t,r)=>{E(t,s)&&(void 0===r?s(h.ENOENT(e)):s(null,n.fromBuffer(r)))})}getDirListing(t,e,r,s){r.isDirectory()?t.get(r.id,(t,r)=>{if(E(t,s))try{s(null,JSON.parse(r.toString()))}catch(t){s(h.ENOENT(e))}}):s(h.ENOTDIR(e))}findINodeAndDirListing(t,e,r){this.findINode(t,e,(s,i)=>{E(s,r)&&this.getDirListing(t,e,i,(t,e)=>{E(t,r)&&r(null,i,e)})})}addNewNode(t,e,r){let s,i=0;const n=()=>{5==++i?r(new h(u.EIO,"Unable to commit data to key-value store.")):(s=S(),t.put(s,e,!1,(t,e)=>{t||!e?n():r(null,s)}))};n()}commitNewFile(t,e,r,s,o,a){const c=i.dirname(e),l=i.basename(e),u=(new Date).getTime();if("/"===e)return a(h.EEXIST(e));this.findINodeAndDirListing(t,c,(i,c,d)=>{w(i,t,a)&&(d[l]?t.abort(()=>{a(h.EEXIST(e))}):this.addNewNode(t,o,(e,i)=>{if(w(e,t,a)){const e=new n(i,o.length,s|r,u,u,u);this.addNewNode(t,e.toBuffer(),(r,s)=>{w(r,t,a)&&(d[l]=s,t.put(c.id,p.from(JSON.stringify(d)),!0,r=>{w(r,t,a)&&t.commit(r=>{w(r,t,a)&&a(null,e)})}))})}}))})}removeEntry(t,e,r){this._cache&&this._cache.remove(t);const s=this.store.beginTransaction("readwrite"),n=i.dirname(t),o=i.basename(t);this.findINodeAndDirListing(s,n,(i,n,a)=>{if(w(i,s,r))if(a[o]){const i=a[o];delete a[o],this.getINode(s,t,i,(o,c)=>{w(o,s,r)&&(!e&&c.isDirectory()?s.abort(()=>{r(h.EISDIR(t))}):e&&!c.isDirectory()?s.abort(()=>{r(h.ENOTDIR(t))}):s.del(c.id,t=>{w(t,s,r)&&s.del(i,t=>{w(t,s,r)&&s.put(n.id,p.from(JSON.stringify(a)),!0,t=>{w(t,s,r)&&s.commit(r)})})}))})}else s.abort(()=>{r(h.ENOENT(t))})})}}}}),t("skylark-browserfs/backend/InMemory",["../generic/key_value_filesystem"],function(t){"use strict";const{SimpleSyncRWTransaction:e,SyncKeyValueFileSystem:r}=t;class s{constructor(){this.store={}}name(){return i.Name}clear(){this.store={}}beginTransaction(t){return new e(this)}get(t){return this.store[t]}put(t,e,r){return!(!r&&this.store.hasOwnProperty(t))&&(this.store[t]=e,!0)}del(t){delete this.store[t]}}class i extends r{constructor(){super({store:new s})}static Create(t,e){e(null,new i)}}return i.Name="InMemory",i.Options={},i.InMemoryStore=s,i}),t("skylark-browserfs/backend/IndexedDB",["../generic/key_value_filesystem","../core/api_error","../core/global","../core/util"],function(t,e,r,s){"use strict";const{AsyncKeyValueFileSystem:i}=t,{ApiError:n,ErrorCode:o}=e,{arrayBuffer2Buffer:a,buffer2ArrayBuffer:c}=s,l=r.indexedDB||r.mozIndexedDB||r.webkitIndexedDB||r.msIndexedDB;function h(t,e=t.toString()){switch(t.name){case"NotFoundError":return new n(o.ENOENT,e);case"QuotaExceededError":return new n(o.ENOSPC,e);default:return new n(o.EIO,e)}}function u(t,e=o.EIO,r=null){return function(s){s.preventDefault(),t(new n(e,null!==r?r:void 0))}}class d{constructor(t,e){this.tx=t,this.store=e}get(t,e){try{const r=this.store.get(t);r.onerror=u(e),r.onsuccess=(t=>{const r=t.target.result;e(null,void 0===r?r:a(r))})}catch(t){e(h(t))}}}class f extends d{constructor(t,e){super(t,e)}put(t,e,r,s){try{const i=c(e);let n;(n=r?this.store.put(i,t):this.store.add(i,t)).onerror=u(s),n.onsuccess=(t=>{s(null,!0)})}catch(t){s(h(t))}}del(t,e){try{const r=this.store.delete(t);r.onerror=u(e),r.onsuccess=(t=>{e()})}catch(t){e(h(t))}}commit(t){setTimeout(t,0)}abort(t){let e=null;try{this.tx.abort()}catch(t){e=h(t)}finally{t(e)}}}class y{constructor(t,e){this.db=t,this.storeName=e}static Create(t,e){const r=l.open(t,1);r.onupgradeneeded=(e=>{const r=e.target.result;r.objectStoreNames.contains(t)&&r.deleteObjectStore(t),r.createObjectStore(t)}),r.onsuccess=(r=>{e(null,new y(r.target.result,t))}),r.onerror=u(e,o.EACCES)}name(){return p.Name+" - "+this.storeName}clear(t){try{const e=this.db.transaction(this.storeName,"readwrite"),r=e.objectStore(this.storeName),s=r.clear();s.onsuccess=(e=>{setTimeout(t,0)}),s.onerror=u(t)}catch(e){t(h(e))}}beginTransaction(t="readonly"){const e=this.db.transaction(this.storeName,t),r=e.objectStore(this.storeName);if("readwrite"===t)return new f(e,r);if("readonly"===t)return new d(e,r);throw new n(o.EINVAL,"Invalid transaction type.")}}class p extends i{constructor(t){super(t)}static Create(t={},e){y.Create(t.storeName?t.storeName:"browserfs",(r,s)=>{if(s){const r=new p("number"==typeof t.cacheSize?t.cacheSize:100);r.init(s,t=>{t?e(t):e(null,r)})}else e(r)})}static isAvailable(){try{return void 0!==l&&null!==l.open("__browserfs_test__")}catch(t){return!1}}}return p.Name="IndexedDB",p.Options={storeName:{type:"string",optional:!0,description:"The name of this file system. You can have multiple IndexedDB file systems operating at once, but each must have a different name."},cacheSize:{type:"number",optional:!0,description:"The size of the inode cache. Defaults to 100. A size of 0 or below disables caching."}},p.IndexedDBROTransaction=d,p.IndexedDBRWTransaction=f,p.IndexedDBStore=y,p}),t("skylark-browserfs/backend/LocalStorage",["../libs/buffers","../generic/key_value_filesystem","../core/api_error","../core/global"],function(t,e,r,s){"use strict";const{SyncKeyValueFileSystem:i,SimpleSyncRWTransaction:n}=e,{ApiError:o,ErrorCode:a}=r,{Buffer:c}=t;let l,h=!1;try{s.localStorage.setItem("__test__",String.fromCharCode(55296)),h=s.localStorage.getItem("__test__")===String.fromCharCode(55296)}catch(t){h=!1}l=h?"binary_string":"binary_string_ie",c.isEncoding(l)||(l="base64");class u{name(){return d.Name}clear(){s.localStorage.clear()}beginTransaction(t){return new n(this)}get(t){try{const e=s.localStorage.getItem(t);if(null!==e)return c.from(e,l)}catch(t){}}put(t,e,r){try{return!(!r&&null!==s.localStorage.getItem(t))&&(s.localStorage.setItem(t,e.toString(l)),!0)}catch(t){throw new o(a.ENOSPC,"LocalStorage is full.")}}del(t){try{s.localStorage.removeItem(t)}catch(e){throw new o(a.EIO,"Unable to delete key "+t+": "+e)}}}class d extends i{constructor(){super({store:new u})}static Create(t,e){e(null,new d)}static isAvailable(){return void 0!==s.localStorage}}return d.Name="LocalStorage",d.Options={},d.LocalStorageStore=u,d}),t("skylark-browserfs/backend/MountableFileSystem",["../core/file_system","./InMemory","../core/api_error","../core/node_fs","../libs/path","../core/util"],function(t,e,r,s,i,n){"use strict";const{BaseFileSystem:o}=t,{InMemoryFileSystem:a}=e,{ApiError:c,ErrorCode:l}=r,{mkdirpSync:h}=n;class u extends o{constructor(t){super(),this.mountList=[],this.mntMap={},this.rootFs=t}static Create(t,e){a.Create({},(r,s)=>{if(s){const i=new u(s);try{Object.keys(t).forEach(e=>{i.mount(e,t[e])})}catch(r){return e(r)}e(null,i)}else e(r)})}static isAvailable(){return!0}mount(t,e){if("/"!==t[0]&&(t=`/${t}`),t=i.resolve(t),this.mntMap[t])throw new c(l.EINVAL,"Mount point "+t+" is already taken.");h(t,511,this.rootFs),this.mntMap[t]=e,this.mountList.push(t),this.mountList=this.mountList.sort((t,e)=>e.length-t.length)}umount(t){if("/"!==t[0]&&(t=`/${t}`),t=i.resolve(t),!this.mntMap[t])throw new c(l.EINVAL,"Mount point "+t+" is already unmounted.");for(delete this.mntMap[t],this.mountList.splice(this.mountList.indexOf(t),1);"/"!==t&&0===this.rootFs.readdirSync(t).length;)this.rootFs.rmdirSync(t),t=i.dirname(t)}_getFs(t){const e=this.mountList,r=e.length;for(let s=0;s<r;s++){const r=e[s];if(r.length<=t.length&&0===t.indexOf(r))return""===(t=t.substr(r.length>1?r.length:0))&&(t="/"),{fs:this.mntMap[r],path:t,mountPoint:r}}return{fs:this.rootFs,path:t,mountPoint:"/"}}getName(){return u.Name}diskSpace(t,e){e(0,0)}isReadOnly(){return!1}supportsLinks(){return!1}supportsProps(){return!1}supportsSynch(){return!0}standardizeError(t,e,r){const s=t.message.indexOf(e);return-1!==s&&(t.message=t.message.substr(0,s)+r+t.message.substr(s+e.length),t.path=r),t}rename(t,e,r){const i=this._getFs(t),n=this._getFs(e);return i.fs===n.fs?i.fs.rename(i.path,n.path,s=>{s&&this.standardizeError(this.standardizeError(s,i.path,t),n.path,e),r(s)}):s.readFile(t,function(i,n){if(i)return r(i);s.writeFile(e,n,function(e){if(e)return r(e);s.unlink(t,r)})})}renameSync(t,e){const r=this._getFs(t),i=this._getFs(e);if(r.fs===i.fs)try{return r.fs.renameSync(r.path,i.path)}catch(s){throw this.standardizeError(this.standardizeError(s,r.path,t),i.path,e),s}const n=s.readFileSync(t);return s.writeFileSync(e,n),s.unlinkSync(t)}readdirSync(t){const e=this._getFs(t);let r=null;if(e.fs!==this.rootFs)try{r=this.rootFs.readdirSync(t)}catch(t){}try{const s=e.fs.readdirSync(e.path);return null===r?s:s.concat(r.filter(t=>-1===s.indexOf(t)))}catch(s){if(null===r)throw this.standardizeError(s,e.path,t);return r}}readdir(t,e){const r=this._getFs(t);r.fs.readdir(r.path,(s,i)=>{if(r.fs!==this.rootFs)try{const n=this.rootFs.readdirSync(t);i=i?i.concat(n.filter(t=>-1===i.indexOf(t))):n}catch(i){if(s)return e(this.standardizeError(s,r.path,t))}else if(s)return e(this.standardizeError(s,r.path,t));e(null,i)})}realpathSync(t,e){const r=this._getFs(t);try{const e=r.fs.realpathSync(r.path,{});return i.resolve(i.join(r.mountPoint,e))}catch(e){throw this.standardizeError(e,r.path,t)}}realpath(t,e,r){const s=this._getFs(t);s.fs.realpath(s.path,{},(e,n)=>{e?r(this.standardizeError(e,s.path,t)):r(null,i.resolve(i.join(s.mountPoint,n)))})}rmdirSync(t){const e=this._getFs(t);if(this._containsMountPt(t))throw c.ENOTEMPTY(t);try{e.fs.rmdirSync(e.path)}catch(r){throw this.standardizeError(r,e.path,t)}}rmdir(t,e){const r=this._getFs(t);this._containsMountPt(t)?e(c.ENOTEMPTY(t)):r.fs.rmdir(r.path,s=>{e(s?this.standardizeError(s,r.path,t):null)})}_containsMountPt(t){const e=this.mountList,r=e.length;for(let s=0;s<r;s++){const r=e[s];if(r.length>=t.length&&r.slice(0,t.length)===t)return!0}return!1}}function d(t,e,r){return e?function(...e){const r=e[0],s=this._getFs(r);e[0]=s.path;try{return s.fs[t].apply(s.fs,e)}catch(t){throw this.standardizeError(t,s.path,r),t}}:function(...e){const r=e[0],s=this._getFs(r);if(e[0]=s.path,"function"==typeof e[e.length-1]){const t=e[e.length-1];e[e.length-1]=((...e)=>{e.length>0&&e[0]instanceof c&&this.standardizeError(e[0],s.path,r),t.apply(null,e)})}return s.fs[t].apply(s.fs,e)}}u.Name="MountableFileSystem",u.Options={};const f=[["exists","unlink","readlink"],["stat","mkdir","truncate"],["open","readFile","chmod","utimes"],["chown"],["writeFile","appendFile"]];for(let t=0;t<f.length;t++){const e=f[t];for(const r of e)u.prototype[r]=d(r,!1,t+1),u.prototype[r+"Sync"]=d(r+"Sync",!0,t+1)}return u}),t("skylark-browserfs/generic/mutex",["../generic/setImmediate"],function(t){"use strict";return class{constructor(){this._locked=!1,this._waiters=[]}lock(t){this._locked?this._waiters.push(t):(this._locked=!0,t())}unlock(){if(!this._locked)throw new Error("unlock of a non-locked mutex");const e=this._waiters.shift();e?t(e):this._locked=!1}tryLock(){return!this._locked&&(this._locked=!0,!0)}isLocked(){return this._locked}}}),t("skylark-browserfs/generic/locked_fs",["./mutex"],function(t){"use strict";return class{constructor(e){this._fs=e,this._mu=new t}getName(){return"LockedFS<"+this._fs.getName()+">"}getFSUnlocked(){return this._fs}diskSpace(t,e){this._fs.diskSpace(t,e)}isReadOnly(){return this._fs.isReadOnly()}supportsLinks(){return this._fs.supportsLinks()}supportsProps(){return this._fs.supportsProps()}supportsSynch(){return this._fs.supportsSynch()}rename(t,e,r){this._mu.lock(()=>{this._fs.rename(t,e,t=>{this._mu.unlock(),r(t)})})}renameSync(t,e){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.renameSync(t,e)}stat(t,e,r){this._mu.lock(()=>{this._fs.stat(t,e,(t,e)=>{this._mu.unlock(),r(t,e)})})}statSync(t,e){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.statSync(t,e)}open(t,e,r,s){this._mu.lock(()=>{this._fs.open(t,e,r,(t,e)=>{this._mu.unlock(),s(t,e)})})}openSync(t,e,r){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.openSync(t,e,r)}unlink(t,e){this._mu.lock(()=>{this._fs.unlink(t,t=>{this._mu.unlock(),e(t)})})}unlinkSync(t){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.unlinkSync(t)}rmdir(t,e){this._mu.lock(()=>{this._fs.rmdir(t,t=>{this._mu.unlock(),e(t)})})}rmdirSync(t){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.rmdirSync(t)}mkdir(t,e,r){this._mu.lock(()=>{this._fs.mkdir(t,e,t=>{this._mu.unlock(),r(t)})})}mkdirSync(t,e){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.mkdirSync(t,e)}readdir(t,e){this._mu.lock(()=>{this._fs.readdir(t,(t,r)=>{this._mu.unlock(),e(t,r)})})}readdirSync(t){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.readdirSync(t)}exists(t,e){this._mu.lock(()=>{this._fs.exists(t,t=>{this._mu.unlock(),e(t)})})}existsSync(t){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.existsSync(t)}realpath(t,e,r){this._mu.lock(()=>{this._fs.realpath(t,e,(t,e)=>{this._mu.unlock(),r(t,e)})})}realpathSync(t,e){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.realpathSync(t,e)}truncate(t,e,r){this._mu.lock(()=>{this._fs.truncate(t,e,t=>{this._mu.unlock(),r(t)})})}truncateSync(t,e){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.truncateSync(t,e)}readFile(t,e,r,s){this._mu.lock(()=>{this._fs.readFile(t,e,r,(t,e)=>{this._mu.unlock(),s(t,e)})})}readFileSync(t,e,r){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.readFileSync(t,e,r)}writeFile(t,e,r,s,i,n){this._mu.lock(()=>{this._fs.writeFile(t,e,r,s,i,t=>{this._mu.unlock(),n(t)})})}writeFileSync(t,e,r,s,i){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.writeFileSync(t,e,r,s,i)}appendFile(t,e,r,s,i,n){this._mu.lock(()=>{this._fs.appendFile(t,e,r,s,i,t=>{this._mu.unlock(),n(t)})})}appendFileSync(t,e,r,s,i){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.appendFileSync(t,e,r,s,i)}chmod(t,e,r,s){this._mu.lock(()=>{this._fs.chmod(t,e,r,t=>{this._mu.unlock(),s(t)})})}chmodSync(t,e,r){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.chmodSync(t,e,r)}chown(t,e,r,s,i){this._mu.lock(()=>{this._fs.chown(t,e,r,s,t=>{this._mu.unlock(),i(t)})})}chownSync(t,e,r,s){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.chownSync(t,e,r,s)}utimes(t,e,r,s){this._mu.lock(()=>{this._fs.utimes(t,e,r,t=>{this._mu.unlock(),s(t)})})}utimesSync(t,e,r){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.utimesSync(t,e,r)}link(t,e,r){this._mu.lock(()=>{this._fs.link(t,e,t=>{this._mu.unlock(),r(t)})})}linkSync(t,e){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.linkSync(t,e)}symlink(t,e,r,s){this._mu.lock(()=>{this._fs.symlink(t,e,r,t=>{this._mu.unlock(),s(t)})})}symlinkSync(t,e,r){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.symlinkSync(t,e,r)}readlink(t,e){this._mu.lock(()=>{this._fs.readlink(t,(t,r)=>{this._mu.unlock(),e(t,r)})})}readlinkSync(t){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.readlinkSync(t)}}}),t("skylark-browserfs/backend/OverlayFS",["../core/file_system","../core/api_error","../core/file_flag","../core/node_fs_stats","../generic/preload_file","../generic/locked_fs","../libs/path"],function(t,e,r,s,i,n,o){"use strict";const{BaseFileSystem:a}=t,{ApiError:c,ErrorCode:l}=e,{FileFlag:h,ActionType:u}=r,{Stats:d}=s,{PreloadFile:f}=i,y="/.deletedFiles.log";function p(t){return 146|t}function m(t){return h.getFileFlag(t)}class g extends f{constructor(t,e,r,s,i){super(t,e,r,s,i)}sync(t){this.isDirty()?this._fs._syncAsync(this,e=>{this.resetDirty(),t(e)}):t(null)}syncSync(){this.isDirty()&&(this._fs._syncSync(this),this.resetDirty())}close(t){this.sync(t)}closeSync(){this.syncSync()}}class _ extends a{constructor(t,e){if(super(),this._isInitialized=!1,this._initializeCallbacks=[],this._deletedFiles={},this._deleteLog="",this._deleteLogUpdatePending=!1,this._deleteLogUpdateNeeded=!1,this._deleteLogError=null,this._writable=t,this._readable=e,this._writable.isReadOnly())throw new c(l.EINVAL,"Writable file system must be writable.")}static isAvailable(){return!0}getOverlayedFileSystems(){return{readable:this._readable,writable:this._writable}}_syncAsync(t,e){this.createParentDirectoriesAsync(t.getPath(),r=>{if(r)return e(r);this._writable.writeFile(t.getPath(),t.getBuffer(),null,m("w"),t.getStats().mode,e)})}_syncSync(t){this.createParentDirectories(t.getPath()),this._writable.writeFileSync(t.getPath(),t.getBuffer(),null,m("w"),t.getStats().mode)}getName(){return S.Name}_initialize(t){const e=this._initializeCallbacks,r=t=>{this._isInitialized=!t,this._initializeCallbacks=[],e.forEach(e=>e(t))};if(this._isInitialized)return t();e.push(t),1===e.length&&this._writable.readFile(y,"utf8",m("r"),(t,e)=>{if(t){if(t.errno!==l.ENOENT)return r(t)}else this._deleteLog=e;this._reparseDeletionLog(),r()})}isReadOnly(){return!1}supportsSynch(){return this._readable.supportsSynch()&&this._writable.supportsSynch()}supportsLinks(){return!1}supportsProps(){return this._readable.supportsProps()&&this._writable.supportsProps()}getDeletionLog(){return this._deleteLog}restoreDeletionLog(t){this._deleteLog=t,this._reparseDeletionLog(),this.updateLog("")}rename(t,e,r){if(this.checkInitAsync(r)&&!this.checkPathAsync(t,r)&&!this.checkPathAsync(e,r))return t===y||e===y?r(c.EPERM("Cannot rename deletion log.")):t===e?r():void this.stat(t,!1,(s,i)=>s?r(s):this.stat(e,!1,(s,n)=>{const a=this;function h(s){const i=s.shift();if(!i)return r();const n=o.resolve(t,i),c=o.resolve(e,i);a.rename(n,c,t=>{if(t)return r(t);h(s)})}let u=511;if(i.isDirectory()){if(s)return s.errno!==l.ENOENT?r(s):this._writable.exists(t,s=>{if(s)return this._writable.rename(t,e,r);this._writable.mkdir(e,u,e=>{if(e)return r(e);this._readable.readdir(t,(t,e)=>{if(t)return r();h(e)})})});if(u=n.mode,!n.isDirectory())return r(c.ENOTDIR(e));this.readdir(e,(s,i)=>{if(i&&i.length)return r(c.ENOTEMPTY(e));this._readable.readdir(t,(t,e)=>{if(t)return r();h(e)})})}if(n&&n.isDirectory())return r(c.EISDIR(e));this.readFile(t,null,m("r"),(s,n)=>s?r(s):this.writeFile(e,n,null,m("w"),i.mode,e=>e?r(e):this.unlink(t,r)))}))}renameSync(t,e){if(this.checkInitialized(),this.checkPath(t),this.checkPath(e),t===y||e===y)throw c.EPERM("Cannot rename deletion log.");const r=this.statSync(t,!1);if(r.isDirectory()){if(t===e)return;let r=511;if(this.existsSync(e)){const t=this.statSync(e,!1);if(r=t.mode,!t.isDirectory())throw c.ENOTDIR(e);if(this.readdirSync(e).length>0)throw c.ENOTEMPTY(e)}this._writable.existsSync(t)?this._writable.renameSync(t,e):this._writable.existsSync(e)||this._writable.mkdirSync(e,r),this._readable.existsSync(t)&&this._readable.readdirSync(t).forEach(r=>{this.renameSync(o.resolve(t,r),o.resolve(e,r))})}else{if(this.existsSync(e)&&this.statSync(e,!1).isDirectory())throw c.EISDIR(e);this.writeFileSync(e,this.readFileSync(t,null,m("r")),null,m("w"),r.mode)}t!==e&&this.existsSync(t)&&this.unlinkSync(t)}stat(t,e,r){this.checkInitAsync(r)&&this._writable.stat(t,e,(s,i)=>{s&&s.errno===l.ENOENT?(this._deletedFiles[t]&&r(c.ENOENT(t)),this._readable.stat(t,e,(t,e)=>{e&&((e=d.clone(e)).mode=p(e.mode)),r(t,e)})):r(s,i)})}statSync(t,e){this.checkInitialized();try{return this._writable.statSync(t,e)}catch(r){if(this._deletedFiles[t])throw c.ENOENT(t);const s=d.clone(this._readable.statSync(t,e));return s.mode=p(s.mode),s}}open(t,e,r,s){this.checkInitAsync(s)&&!this.checkPathAsync(t,s)&&this.stat(t,!1,(i,n)=>{if(n)switch(e.pathExistsAction()){case u.TRUNCATE_FILE:return this.createParentDirectoriesAsync(t,i=>{if(i)return s(i);this._writable.open(t,e,r,s)});case u.NOP:return this._writable.exists(t,i=>{i?this._writable.open(t,e,r,s):((n=d.clone(n)).mode=r,this._readable.readFile(t,null,m("r"),(r,i)=>{if(r)return s(r);-1===n.size&&(n.size=i.length);const o=new g(this,t,e,n,i);s(null,o)}))});default:return s(c.EEXIST(t))}else switch(e.pathNotExistsAction()){case u.CREATE_FILE:return this.createParentDirectoriesAsync(t,i=>i?s(i):this._writable.open(t,e,r,s));default:return s(c.ENOENT(t))}})}openSync(t,e,r){if(this.checkInitialized(),this.checkPath(t),t===y)throw c.EPERM("Cannot open deletion log.");if(this.existsSync(t))switch(e.pathExistsAction()){case u.TRUNCATE_FILE:return this.createParentDirectories(t),this._writable.openSync(t,e,r);case u.NOP:if(this._writable.existsSync(t))return this._writable.openSync(t,e,r);{const s=this._readable.readFileSync(t,null,m("r")),i=d.clone(this._readable.statSync(t,!1));return i.mode=r,new g(this,t,e,i,s)}default:throw c.EEXIST(t)}else switch(e.pathNotExistsAction()){case u.CREATE_FILE:return this.createParentDirectories(t),this._writable.openSync(t,e,r);default:throw c.ENOENT(t)}}unlink(t,e){this.checkInitAsync(e)&&!this.checkPathAsync(t,e)&&this.exists(t,r=>{if(!r)return e(c.ENOENT(t));this._writable.exists(t,r=>{if(r)return this._writable.unlink(t,r=>{if(r)return e(r);this.exists(t,r=>{r&&this.deletePath(t),e(null)})});this.deletePath(t),e(null)})})}unlinkSync(t){if(this.checkInitialized(),this.checkPath(t),!this.existsSync(t))throw c.ENOENT(t);this._writable.existsSync(t)&&this._writable.unlinkSync(t),this.existsSync(t)&&this.deletePath(t)}rmdir(t,e){if(!this.checkInitAsync(e))return;const r=()=>{this.readdir(t,(r,s)=>r?e(r):s.length?e(c.ENOTEMPTY(t)):(this.deletePath(t),void e(null)))};this.exists(t,s=>{if(!s)return e(c.ENOENT(t));this._writable.exists(t,s=>{s?this._writable.rmdir(t,s=>{if(s)return e(s);this._readable.exists(t,t=>{t?r():e()})}):r()})})}rmdirSync(t){if(this.checkInitialized(),!this.existsSync(t))throw c.ENOENT(t);if(this._writable.existsSync(t)&&this._writable.rmdirSync(t),this.existsSync(t)){if(this.readdirSync(t).length>0)throw c.ENOTEMPTY(t);this.deletePath(t)}}mkdir(t,e,r){this.checkInitAsync(r)&&this.exists(t,s=>{if(s)return r(c.EEXIST(t));this.createParentDirectoriesAsync(t,s=>{if(s)return r(s);this._writable.mkdir(t,e,r)})})}mkdirSync(t,e){if(this.checkInitialized(),this.existsSync(t))throw c.EEXIST(t);this.createParentDirectories(t),this._writable.mkdirSync(t,e)}readdir(t,e){this.checkInitAsync(e)&&this.stat(t,!1,(r,s)=>r?e(r):s.isDirectory()?void this._writable.readdir(t,(r,s)=>{if(r&&"ENOENT"!==r.code)return e(r);!r&&s||(s=[]),this._readable.readdir(t,(r,i)=>{!r&&i||(i=[]);const n={},o=s.concat(i.filter(e=>!this._deletedFiles[`${t}/${e}`])).filter(t=>{const e=!n[t];return n[t]=!0,e});e(null,o)})}):e(c.ENOTDIR(t)))}readdirSync(t){this.checkInitialized();const e=this.statSync(t,!1);if(!e.isDirectory())throw c.ENOTDIR(t);let r=[];try{r=r.concat(this._writable.readdirSync(t))}catch(t){}try{r=r.concat(this._readable.readdirSync(t).filter(e=>!this._deletedFiles[`${t}/${e}`]))}catch(t){}const s={};return r.filter(t=>{const e=!s[t];return s[t]=!0,e})}exists(t,e){this.checkInitialized(),this._writable.exists(t,r=>{if(r)return e(!0);this._readable.exists(t,r=>{e(r&&!0!==this._deletedFiles[t])})})}existsSync(t){return this.checkInitialized(),this._writable.existsSync(t)||this._readable.existsSync(t)&&!0!==this._deletedFiles[t]}chmod(t,e,r,s){this.checkInitAsync(s)&&this.operateOnWritableAsync(t,i=>{if(i)return s(i);this._writable.chmod(t,e,r,s)})}chmodSync(t,e,r){this.checkInitialized(),this.operateOnWritable(t,()=>{this._writable.chmodSync(t,e,r)})}chown(t,e,r,s,i){this.checkInitAsync(i)&&this.operateOnWritableAsync(t,n=>{if(n)return i(n);this._writable.chown(t,e,r,s,i)})}chownSync(t,e,r,s){this.checkInitialized(),this.operateOnWritable(t,()=>{this._writable.chownSync(t,e,r,s)})}utimes(t,e,r,s){this.checkInitAsync(s)&&this.operateOnWritableAsync(t,i=>{if(i)return s(i);this._writable.utimes(t,e,r,s)})}utimesSync(t,e,r){this.checkInitialized(),this.operateOnWritable(t,()=>{this._writable.utimesSync(t,e,r)})}deletePath(t){this._deletedFiles[t]=!0,this.updateLog(`d${t}\n`)}updateLog(t){this._deleteLog+=t,this._deleteLogUpdatePending?this._deleteLogUpdateNeeded=!0:(this._deleteLogUpdatePending=!0,this._writable.writeFile(y,this._deleteLog,"utf8",h.getFileFlag("w"),420,t=>{this._deleteLogUpdatePending=!1,t?this._deleteLogError=t:this._deleteLogUpdateNeeded&&(this._deleteLogUpdateNeeded=!1,this.updateLog(""))}))}_reparseDeletionLog(){this._deletedFiles={},this._deleteLog.split("\n").forEach(t=>{this._deletedFiles[t.slice(1)]="d"===t.slice(0,1)})}checkInitialized(){if(!this._isInitialized)throw new c(l.EPERM,"OverlayFS is not initialized. Please initialize OverlayFS using its initialize() method before using it.");if(null!==this._deleteLogError){const t=this._deleteLogError;throw this._deleteLogError=null,t}}checkInitAsync(t){if(!this._isInitialized)return t(new c(l.EPERM,"OverlayFS is not initialized. Please initialize OverlayFS using its initialize() method before using it.")),!1;if(null!==this._deleteLogError){const e=this._deleteLogError;return this._deleteLogError=null,t(e),!1}return!0}checkPath(t){if(t===y)throw c.EPERM(t)}checkPathAsync(t,e){return t===y&&(e(c.EPERM(t)),!0)}createParentDirectoriesAsync(t,e){let r=o.dirname(t);const s=[],i=this;this._writable.stat(r,!1,function t(n,a){n?"/"===r?e(new c(l.EBUSY,"Invariant failed: root does not exist!")):(s.push(r),r=o.dirname(r),i._writable.stat(r,!1,t)):function t(){if(!s.length)return e();const r=s.pop();i._readable.stat(r,!1,(s,n)=>{if(!n)return e();i._writable.mkdir(r,n.mode,r=>{if(r)return e(r);t()})})}()})}createParentDirectories(t){let e=o.dirname(t),r=[];for(;!this._writable.existsSync(e);)r.push(e),e=o.dirname(e);(r=r.reverse()).forEach(t=>{this._writable.mkdirSync(t,this.statSync(t,!1).mode)})}operateOnWritable(t,e){if(!this.existsSync(t))throw c.ENOENT(t);this._writable.existsSync(t)||this.copyToWritable(t),e()}operateOnWritableAsync(t,e){this.exists(t,r=>{if(!r)return e(c.ENOENT(t));this._writable.exists(t,r=>{if(!r)return this.copyToWritableAsync(t,e);e()})})}copyToWritable(t){const e=this.statSync(t,!1);e.isDirectory()?this._writable.mkdirSync(t,e.mode):this.writeFileSync(t,this._readable.readFileSync(t,null,m("r")),null,m("w"),this.statSync(t,!1).mode)}copyToWritableAsync(t,e){this.stat(t,!1,(r,s)=>r?e(r):s.isDirectory()?this._writable.mkdir(t,s.mode,e):void this._readable.readFile(t,null,m("r"),(r,i)=>{if(r)return e(r);this.writeFile(t,i,null,m("w"),s.mode,e)}))}}class S extends n{constructor(t,e){super(new _(t,e))}static Create(t,e){try{const r=new S(t.writable,t.readable);r._initialize(t=>{e(t,r)})}catch(t){e(t)}}static isAvailable(){return _.isAvailable()}getOverlayedFileSystems(){return super.getFSUnlocked().getOverlayedFileSystems()}unwrap(){return super.getFSUnlocked()}_initialize(t){super.getFSUnlocked()._initialize(t)}}return S.Name="OverlayFS",S.Options={writable:{type:"object",description:"The file system to write modified files to."},readable:{type:"object",description:"The file system that initially populates this file system."}},S}),t("skylark-browserfs/backend/WorkerFS",["../libs/buffers","../core/file_system","../core/api_error","../core/file_flag","../core/util","../core/file","../core/node_fs_stats","../generic/preload_file","../core/global","../core/node_fs"],function(t,e,r,s,i,n,o,a,c,l){"use strict";const{BaseFileSystem:h}=e,{ApiError:u,ErrorCode:d}=r,{FileFlag:f}=s,{buffer2ArrayBuffer:y,arrayBuffer2Buffer:p,emptyBuffer:m}=i,{BaseFile:g}=n,{Stats:_}=o,{PreloadFile:S}=a,{Buffer:E}=t;var w;!function(t){t[t.CB=0]="CB",t[t.FD=1]="FD",t[t.API_ERROR=2]="API_ERROR",t[t.STATS=3]="STATS",t[t.PROBE=4]="PROBE",t[t.FILEFLAG=5]="FILEFLAG",t[t.BUFFER=6]="BUFFER",t[t.ERROR=7]="ERROR"}(w||(w={}));class b{constructor(){this._callbacks={},this._nextId=0}toRemoteArg(t){const e=this._nextId++;return this._callbacks[e]=t,{type:w.CB,id:e}}toLocalArg(t){const e=this._callbacks[t];return delete this._callbacks[t],e}}class F{constructor(){this._fileDescriptors={},this._nextId=0}toRemoteArg(t,e,r,s){const i=this._nextId++;let n,o;this._fileDescriptors[i]=t,t.stat((a,c)=>{a?s(a):(o=A(c.toBuffer()),r.isReadable()?t.read(E.alloc(c.size),0,c.size,0,(t,a,c)=>{t?s(t):(n=A(c),s(null,{type:w.FD,id:i,data:n,stat:o,path:e,flag:r.getFlagString()}))}):s(null,{type:w.FD,id:i,data:new ArrayBuffer(0),stat:o,path:e,flag:r.getFlagString()}))})}applyFdAPIRequest(t,e){const r=t.args[0];this._applyFdChanges(r,(s,i)=>{s?e(s):i[t.method](s=>{"close"===t.method&&delete this._fileDescriptors[r.id],e(s)})})}_applyFdChanges(t,e){const r=this._fileDescriptors[t.id],s=x(t.data),i=_.fromBuffer(x(t.stat)),n=f.getFileFlag(t.flag);n.isWriteable()?r.write(s,0,s.length,n.isAppendable()?r.getPos():0,t=>{function o(){r.stat((t,s)=>{t?e(t):s.mode!==i.mode?r.chmod(i.mode,t=>{e(t,r)}):e(t,r)})}t?e(t):n.isAppendable()?o():r.truncate(s.length,()=>{o()})}):e(null,r)}}function I(t){return{type:w.API_ERROR,errorData:A(t.writeToBuffer())}}function k(t){return u.fromBuffer(x(t.errorData))}function N(t){return{type:w.ERROR,name:t.name,message:t.message,stack:t.stack}}function O(t){let e=c[t.name];"function"!=typeof e&&(e=Error);const r=new e(t.message);return r.stack=t.stack,r}function T(t){return{type:w.STATS,statsData:A(t.toBuffer())}}function R(t){return _.fromBuffer(x(t.statsData))}function D(t){return{type:w.FILEFLAG,flagStr:t.getFlagString()}}function L(t){return f.getFileFlag(t.flagStr)}function A(t){return y(t)}function x(t){return p(t)}function P(t){return{type:w.BUFFER,data:A(t)}}function v(t){return x(t.data)}class C extends S{constructor(t,e,r,s,i,n){super(t,e,r,s,n),this._remoteFdId=i}getRemoteFdId(){return this._remoteFdId}toRemoteArg(){return{type:w.FD,id:this._remoteFdId,data:A(this.getBuffer()),stat:A(this.getStats().toBuffer()),path:this.getPath(),flag:this.getFlag().getFlagString()}}sync(t){this._syncClose("sync",t)}close(t){this._syncClose("close",t)}_syncClose(t,e){this.isDirty()?this._fs.syncClose(t,this,t=>{t||this.resetDirty(),e(t)}):e()}}class M extends h{constructor(t){var e;super(),this._callbackConverter=new b,this._isInitialized=!1,this._isReadOnly=!1,this._supportLinks=!1,this._supportProps=!1,this._worker=t,this._worker.addEventListener("message",t=>{const r=t.data;if((e=r)&&"object"==typeof e&&e.hasOwnProperty("browserfsMessage")&&e.browserfsMessage){let t;const e=r.args,s=new Array(e.length);for(t=0;t<s.length;t++)s[t]=this._argRemote2Local(e[t]);this._callbackConverter.toLocalArg(r.cbId).apply(null,s)}})}static Create(t,e){const r=new M(t.worker);r._initialize(()=>{e(null,r)})}static isAvailable(){return"undefined"!=typeof importScripts||"undefined"!=typeof Worker}static attachRemoteListener(t){const e=new F;function r(t,r,s){switch(typeof t){case"object":t instanceof _?s(null,T(t)):t instanceof u?s(null,I(t)):t instanceof g?s(null,e.toRemoteArg(t,r[0],r[1],s)):t instanceof f?s(null,D(t)):t instanceof E?s(null,P(t)):t instanceof Error?s(null,N(t)):s(null,t);break;default:s(null,t)}}function s(e,s){if(!e)return e;switch(typeof e){case"object":if("number"!=typeof e.type)return e;{const i=e;switch(i.type){case w.CB:const n=e.id;return function(){let e;const i=new Array(arguments.length);let o,a=arguments.length;function c(e){a>0&&(a=-1,o={browserfsMessage:!0,cbId:n,args:[I(e)]},t.postMessage(o))}for(e=0;e<arguments.length;e++)((e,l)=>{r(l,s,(r,s)=>{i[e]=s,r?c(r):0==--a&&(o={browserfsMessage:!0,cbId:n,args:i},t.postMessage(o))})})(e,arguments[e]);0===arguments.length&&(o={browserfsMessage:!0,cbId:n,args:i},t.postMessage(o))};case w.API_ERROR:return k(i);case w.STATS:return R(i);case w.FILEFLAG:return L(i);case w.BUFFER:return v(i);case w.ERROR:return O(i);default:return e}}default:return e}}var i;t.addEventListener("message",r=>{const n=r.data;if((i=n)&&"object"==typeof i&&i.hasOwnProperty("browserfsMessage")&&i.browserfsMessage){const r=n.args,i=new Array(r.length);switch(n.method){case"close":case"sync":(()=>{const s=r[1];e.applyFdAPIRequest(n,e=>{const r={browserfsMessage:!0,cbId:s.id,args:e?[I(e)]:[]};t.postMessage(r)})})();break;case"probe":(()=>{const e=l.getRootFS(),s=r[1],i={type:w.PROBE,isReadOnly:e.isReadOnly(),supportsLinks:e.supportsLinks(),supportsProps:e.supportsProps()},n={browserfsMessage:!0,cbId:s.id,args:[i]};t.postMessage(n)})();break;default:for(let t=0;t<r.length;t++)i[t]=s(r[t],i);const o=l.getRootFS();o[n.method].apply(o,i)}}})}getName(){return M.Name}isReadOnly(){return this._isReadOnly}supportsSynch(){return!1}supportsLinks(){return this._supportLinks}supportsProps(){return this._supportProps}rename(t,e,r){this._rpc("rename",arguments)}stat(t,e,r){this._rpc("stat",arguments)}open(t,e,r,s){this._rpc("open",arguments)}unlink(t,e){this._rpc("unlink",arguments)}rmdir(t,e){this._rpc("rmdir",arguments)}mkdir(t,e,r){this._rpc("mkdir",arguments)}readdir(t,e){this._rpc("readdir",arguments)}exists(t,e){this._rpc("exists",arguments)}realpath(t,e,r){this._rpc("realpath",arguments)}truncate(t,e,r){this._rpc("truncate",arguments)}readFile(t,e,r,s){this._rpc("readFile",arguments)}writeFile(t,e,r,s,i,n){this._rpc("writeFile",arguments)}appendFile(t,e,r,s,i,n){this._rpc("appendFile",arguments)}chmod(t,e,r,s){this._rpc("chmod",arguments)}chown(t,e,r,s,i){this._rpc("chown",arguments)}utimes(t,e,r,s){this._rpc("utimes",arguments)}link(t,e,r){this._rpc("link",arguments)}symlink(t,e,r,s){this._rpc("symlink",arguments)}readlink(t,e){this._rpc("readlink",arguments)}syncClose(t,e,r){this._worker.postMessage({browserfsMessage:!0,method:t,args:[e.toRemoteArg(),this._callbackConverter.toRemoteArg(r)]})}_initialize(t){if(this._isInitialized)t();else{const e={browserfsMessage:!0,method:"probe",args:[this._argLocal2Remote(m()),this._callbackConverter.toRemoteArg(e=>{this._isInitialized=!0,this._isReadOnly=e.isReadOnly,this._supportLinks=e.supportsLinks,this._supportProps=e.supportsProps,t()})]};this._worker.postMessage(e)}}_argRemote2Local(t){if(!t)return t;switch(typeof t){case"object":if("number"!=typeof t.type)return t;{const e=t;switch(e.type){case w.API_ERROR:return k(e);case w.FD:const r=e;return new C(this,r.path,f.getFileFlag(r.flag),_.fromBuffer(x(r.stat)),r.id,x(r.data));case w.STATS:return R(e);case w.FILEFLAG:return L(e);case w.BUFFER:return v(e);case w.ERROR:return O(e);default:return t}}default:return t}}_rpc(t,e){const r=new Array(e.length);for(let t=0;t<e.length;t++)r[t]=this._argLocal2Remote(e[t]);const s={browserfsMessage:!0,method:t,args:r};this._worker.postMessage(s)}_argLocal2Remote(t){if(!t)return t;switch(typeof t){case"object":return t instanceof _?T(t):t instanceof u?I(t):t instanceof C?t.toRemoteArg():t instanceof f?D(t):t instanceof E?P(t):t instanceof Error?N(t):"Unknown argument";case"function":return this._callbackConverter.toRemoteArg(t);default:return t}}}return M.Name="WorkerFS",M.Options={worker:{type:"object",description:"The target worker that you want to connect to, or the current worker if in a worker context.",validator:function(t,e){t.postMessage?e():e(new u(d.EINVAL,"option must be a Web Worker instance."))}}},M}),t("skylark-browserfs/generic/xhr",["../libs/buffers","../core/util","../core/api_error"],function(t,e,r){"use strict";const{isIE:s,emptyBuffer:i}=e,{ApiError:n,ErrorCode:o}=r,{Buffer:a}=t,c="undefined"!=typeof XMLHttpRequest&&null!==XMLHttpRequest;function l(t,e,r){const s=new XMLHttpRequest;s.open("HEAD",e,t),s.onreadystatechange=function(t){if(4===s.readyState){if(200!==s.status)return r(new n(o.EIO,`XHR HEAD error: response returned code ${s.status}`));try{return r(null,parseInt(s.getResponseHeader("Content-Length")||"-1",10))}catch(t){return r(new n(o.EIO,"XHR HEAD error: Could not read content-length."))}}},s.send()}let h=function(t,e,r){const s=new XMLHttpRequest;s.open("GET",t,!0);let c=!0;switch(e){case"buffer":s.responseType="arraybuffer";break;case"json":try{s.responseType="json",c="json"===s.responseType}catch(t){c=!1}break;default:return r(new n(o.EINVAL,"Invalid download type: "+e))}s.onreadystatechange=function(t){if(4===s.readyState){if(200!==s.status)return r(new n(o.EIO,`XHR error: response returned code ${s.status}`));switch(e){case"buffer":return r(null,s.response?a.from(s.response):i());case"json":return r(null,c?s.response:JSON.parse(s.responseText))}}},s.send()},u=s&&"undefined"!=typeof Blob?function(t,e){const r=new XMLHttpRequest;switch(r.open("GET",t,!1),e){case"buffer":r.responseType="arraybuffer";break;case"json":break;default:throw new n(o.EINVAL,"Invalid download type: "+e)}let s,i;if(r.onreadystatechange=function(t){if(4===r.readyState)if(200===r.status)switch(e){case"buffer":s=a.from(r.response);break;case"json":s=JSON.parse(r.response)}else i=new n(o.EIO,`XHR error: response returned code ${r.status}`)},r.send(),i)throw i;return s}:function(t,e){const r=new XMLHttpRequest;r.open("GET",t,!1);let s=null,i=null;if(r.overrideMimeType("text/plain; charset=x-user-defined"),r.onreadystatechange=function(t){if(4===r.readyState){if(200!==r.status)return void(i=new n(o.EIO,`XHR error: response returned code ${r.status}`));switch(e){case"buffer":const t=r.responseText;s=a.alloc(t.length);for(let e=0;e<t.length;e++)s[e]=t.charCodeAt(e);return;case"json":return void(s=JSON.parse(r.responseText))}}},r.send(),i)throw i;return s};return{xhrIsAvailable:c,asyncDownloadFile:h,syncDownloadFile:u,getFileSizeSync:function(t){let e=-1;return l(!1,t,function(t,r){if(t)throw t;e=r}),e},getFileSizeAsync:function(t,e){l(!0,t,e)}}}),t("skylark-browserfs/generic/fetch",["../libs/buffers","../core/api_error"],function(t,e){"use strict";const{ApiError:r,ErrorCode:s}=e,i="undefined"!=typeof fetch&&null!==fetch,{Buffer:n}=t;return{fetchIsAvailable:i,fetchFileAsync:function(t,e,i){let o;try{o=fetch(t)}catch(t){return i(new r(s.EINVAL,t.message))}o.then(t=>{if(!t.ok)return i(new r(s.EIO,`fetch error: response returned code ${t.status}`));switch(e){case"buffer":t.arrayBuffer().then(t=>i(null,n.from(t))).catch(t=>i(new r(s.EIO,t.message)));break;case"json":t.json().then(t=>i(null,t)).catch(t=>i(new r(s.EIO,t.message)));break;default:i(new r(s.EINVAL,"Invalid download type: "+e))}}).catch(t=>i(new r(s.EIO,t.message)))},fetchFileSizeAsync:function(t,e){fetch(t,{method:"HEAD"}).then(t=>t.ok?e(null,parseInt(t.headers.get("Content-Length")||"-1",10)):e(new r(s.EIO,`fetch HEAD error: response returned code ${t.status}`))).catch(t=>e(new r(s.EIO,t.message)))}}}),t("skylark-browserfs/generic/file_index",["../core/node_fs_stats","../libs/path"],function(t,e){"use strict";const{Stats:r,FileType:s}=t;class i{constructor(){this._index={},this.addPath("/",new o)}static fromListing(t){const e=new i,a=new o;e._index["/"]=a;const c=[["",t,a]];for(;c.length>0;){let t;const i=c.pop(),a=i[0],l=i[1],h=i[2];for(const i in l)if(l.hasOwnProperty(i)){const u=l[i],d=`${a}/${i}`;u?(e._index[d]=t=new o,c.push([d,u,t])):t=new n(new r(s.FILE,-1,365)),h&&(h._ls[i]=t)}}return e}fileIterator(t){for(const e in this._index)if(this._index.hasOwnProperty(e)){const r=this._index[e],s=r.getListing();for(const e of s){const s=r.getItem(e);a(s)&&t(s.getData())}}}addPath(t,e){if(!e)throw new Error("Inode must be specified");if("/"!==t[0])throw new Error("Path must be absolute, got: "+t);if(this._index.hasOwnProperty(t))return this._index[t]===e;const r=this._split_path(t),s=r[0],i=r[1];let n=this._index[s];return!(void 0===n&&"/"!==t&&(n=new o,!this.addPath(s,n)))&&(!("/"!==t&&!n.addItem(i,e))&&(c(e)&&(this._index[t]=e),!0))}addPathFast(t,e){const r=t.lastIndexOf("/"),s=0===r?"/":t.substring(0,r),i=t.substring(r+1);let n=this._index[s];return void 0===n&&(n=new o,this.addPathFast(s,n)),!!n.addItem(i,e)&&(e.isDir()&&(this._index[t]=e),!0)}removePath(t){const e=this._split_path(t),r=e[0],s=e[1],i=this._index[r];if(void 0===i)return null;const n=i.remItem(s);if(null===n)return null;if(c(n)){const e=n.getListing();for(const r of e)this.removePath(t+"/"+r);"/"!==t&&delete this._index[t]}return n}ls(t){const e=this._index[t];return void 0===e?null:e.getListing()}getInode(t){const e=this._split_path(t),r=e[0],s=e[1],i=this._index[r];return void 0===i?null:r===t?i:i.getItem(s)}_split_path(t){const r=e.dirname(t),s=t.substr(r.length+("/"===r?0:1));return[r,s]}}class n{constructor(t){this.data=t}isFile(){return!0}isDir(){return!1}getData(){return this.data}setData(t){this.data=t}}class o{constructor(t=null){this.data=t,this._ls={}}isFile(){return!1}isDir(){return!0}getData(){return this.data}getStats(){return new r(s.DIRECTORY,4096,365)}getListing(){return Object.keys(this._ls)}getItem(t){const e=this._ls[t];return e||null}addItem(t,e){return!(t in this._ls)&&(this._ls[t]=e,!0)}remItem(t){const e=this._ls[t];return void 0===e?null:(delete this._ls[t],e)}}function a(t){return!!t&&t.isFile()}function c(t){return!!t&&t.isDir()}return{FileIndex:i,FileInode:n,DirInode:o,isFileInode:a,isDirInode:c}}),t("skylark-browserfs/backend/HTTPRequest",["../core/file_system","../core/api_error","../core/file_flag","../core/util","../core/node_fs_stats","../generic/preload_file","../generic/xhr","../generic/fetch","../generic/file_index"],function(t,e,r,s,i,n,o,a,c){"use strict";const{BaseFileSystem:l}=t,{ApiError:h,ErrorCode:u}=e,{ActionType:d}=r,{copyingSlice:f}=s,{Stats:y}=i,{NoSyncFile:p}=n,{xhrIsAvailable:m,asyncDownloadFile:g,syncDownloadFile:_,getFileSizeAsync:S,getFileSizeSync:E}=o,{fetchIsAvailable:w,fetchFileAsync:b,fetchFileSizeAsync:F}=a,{FileIndex:I,isFileInode:k,isDirInode:N}=c;function O(){throw new h(u.ENOTSUP,"Synchronous HTTP download methods are not available in this environment.")}class T extends l{constructor(t,e="",r=!1){super(),e.length>0&&"/"!==e.charAt(e.length-1)&&(e+="/"),this.prefixUrl=e,this._index=I.fromListing(t),!w||r&&m?(this._requestFileAsyncInternal=g,this._requestFileSizeAsyncInternal=S):(this._requestFileAsyncInternal=b,this._requestFileSizeAsyncInternal=F),m?(this._requestFileSyncInternal=_,this._requestFileSizeSyncInternal=E):(this._requestFileSyncInternal=O,this._requestFileSizeSyncInternal=O)}static Create(t,e){void 0===t.index&&(t.index="index.json"),"string"==typeof t.index?g(t.index,"json",(r,s)=>{r?e(r):e(null,new T(s,t.baseUrl))}):e(null,new T(t.index,t.baseUrl))}static isAvailable(){return m||w}empty(){this._index.fileIterator(function(t){t.fileData=null})}getName(){return T.Name}diskSpace(t,e){e(0,0)}isReadOnly(){return!0}supportsLinks(){return!1}supportsProps(){return!1}supportsSynch(){return m}preloadFile(t,e){const r=this._index.getInode(t);if(!k(r))throw h.EISDIR(t);{if(null===r)throw h.ENOENT(t);const s=r.getData();s.size=e.length,s.fileData=e}}stat(t,e,r){const s=this._index.getInode(t);if(null===s)return r(h.ENOENT(t));let i;k(s)?(i=s.getData()).size<0?this._requestFileSizeAsync(t,function(t,e){if(t)return r(t);i.size=e,r(null,y.clone(i))}):r(null,y.clone(i)):N(s)?(i=s.getStats(),r(null,i)):r(h.FileError(u.EINVAL,t))}statSync(t,e){const r=this._index.getInode(t);if(null===r)throw h.ENOENT(t);let s;if(k(r))(s=r.getData()).size<0&&(s.size=this._requestFileSizeSync(t));else{if(!N(r))throw h.FileError(u.EINVAL,t);s=r.getStats()}return s}open(t,e,r,s){if(e.isWriteable())return s(new h(u.EPERM,t));const i=this,n=this._index.getInode(t);if(null===n)return s(h.ENOENT(t));if(!k(n))return s(h.EISDIR(t));{const r=n.getData();switch(e.pathExistsAction()){case d.THROW_EXCEPTION:case d.TRUNCATE_FILE:return s(h.EEXIST(t));case d.NOP:if(r.fileData)return s(null,new p(i,t,e,y.clone(r),r.fileData));this._requestFileAsync(t,"buffer",function(n,o){return n?s(n):(r.size=o.length,r.fileData=o,s(null,new p(i,t,e,y.clone(r),o)))});break;default:return s(new h(u.EINVAL,"Invalid FileMode object."))}}}openSync(t,e,r){if(e.isWriteable())throw new h(u.EPERM,t);const s=this._index.getInode(t);if(null===s)throw h.ENOENT(t);if(!k(s))throw h.EISDIR(t);{const r=s.getData();switch(e.pathExistsAction()){case d.THROW_EXCEPTION:case d.TRUNCATE_FILE:throw h.EEXIST(t);case d.NOP:if(r.fileData)return new p(this,t,e,y.clone(r),r.fileData);const s=this._requestFileSync(t,"buffer");return r.size=s.length,r.fileData=s,new p(this,t,e,y.clone(r),s);default:throw new h(u.EINVAL,"Invalid FileMode object.")}}}readdir(t,e){try{e(null,this.readdirSync(t))}catch(t){e(t)}}readdirSync(t){const e=this._index.getInode(t);if(null===e)throw h.ENOENT(t);if(N(e))return e.getListing();throw h.ENOTDIR(t)}readFile(t,e,r,s){const i=s;this.open(t,r,420,function(t,r){if(t)return s(t);s=function(t,e){r.close(function(r){return t||(t=r),i(t,e)})};const n=r,o=n.getBuffer();null===e?s(t,f(o)):function(t,e,r){try{r(null,t.toString(e))}catch(t){r(t)}}(o,e,s)})}readFileSync(t,e,r){const s=this.openSync(t,r,420);try{const t=s,r=t.getBuffer();return null===e?f(r):r.toString(e)}finally{s.closeSync()}}_getHTTPPath(t){return"/"===t.charAt(0)&&(t=t.slice(1)),this.prefixUrl+t}_requestFileAsync(t,e,r){this._requestFileAsyncInternal(this._getHTTPPath(t),e,r)}_requestFileSync(t,e){return this._requestFileSyncInternal(this._getHTTPPath(t),e)}_requestFileSizeAsync(t,e){this._requestFileSizeAsyncInternal(this._getHTTPPath(t),e)}_requestFileSizeSync(t){return this._requestFileSizeSyncInternal(this._getHTTPPath(t))}}return T.Name="HTTPRequest",T.Options={index:{type:["string","object"],optional:!0,description:"URL to a file index as a JSON file or the file index object itself, generated with the make_http_index script. Defaults to `index.json`."},baseUrl:{type:"string",optional:!0,description:"Used as the URL prefix for fetched files. Default: Fetch files relative to the index."},preferXHR:{type:"boolean",optional:!0,description:"Whether to prefer XmlHttpRequest or fetch for async operations if both are available. Default: false"}},T}),t("skylark-browserfs/generic/extended_ascii",[],function(){"use strict";class t{static str2byte(e,r){const s=e.length>r.length?r.length:e.length;for(let i=0;i<s;i++){let s=e.charCodeAt(i);if(s>127){const r=t.extendedChars.indexOf(e.charAt(i));r>-1&&(s=r+128)}r[s]=i}return s}static byte2str(e){const r=new Array(e.length);for(let s=0;s<e.length;s++){const i=e[s];r[s]=i>127?t.extendedChars[i-128]:String.fromCharCode(i)}return r.join("")}static byteLength(t){return t.length}}return t.extendedChars=["Ç","ü","é","â","ä","à","å","ç","ê","ë","è","ï","î","ì","Ä","Å","É","æ","Æ","ô","ö","ò","û","ù","ÿ","Ö","Ü","ø","£","Ø","×","ƒ","á","í","ó","ú","ñ","Ñ","ª","º","¿","®","¬","½","¼","¡","«","»","_","_","_","¦","¦","Á","Â","À","©","¦","¦","+","+","¢","¥","+","+","-","-","+","-","+","ã","Ã","+","+","-","-","¦","-","+","¤","ð","Ð","Ê","Ë","È","i","Í","Î","Ï","+","+","_","_","¦","Ì","_","Ó","ß","Ô","Ò","õ","Õ","µ","þ","Þ","Ú","Û","Ù","ý","Ý","¯","´","­","±","_","¾","¶","§","÷","¸","°","¨","·","¹","³","²","_"," "],t}),t("skylark-browserfs/backend/ZipFS",["../core/api_error","../core/node_fs_stats","../core/file_system","../core/file_flag","../generic/preload_file","../core/util","../generic/extended_ascii","../generic/setImmediate","../generic/file_index"],function(t,e,r,s,i,n,o,a,c){"use strict";const{ApiError:l,ErrorCode:h}=t,{Stats:u,FileType:d}=e,{SynchronousFileSystem:f}=r,{ActionType:y}=s,{NoSyncFile:p}=i,{arrayish2Buffer:m,copyingSlice:g,bufferValidator:_}=n;let S;try{S=require("pako/lib/inflate").inflateRaw}catch(t){console.warn(t)}const{FileIndex:E,DirInode:w,FileInode:b,isDirInode:F,isFileInode:I}="../generic/file_index",k={};var N,O;function T(t,e){const r=31&e,s=(e>>5&15)-1,i=1980+(e>>9),n=31&t,o=t>>5&63,a=t>>11;return new Date(i,s,r,a,o,n)}function R(t,e,r,s){return 0===s?"":e?t.toString("utf8",r,r+s):o.byte2str(t.slice(r,r+s))}!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"}(N||(N={})),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"}(O||(O={}));class D{constructor(t){if(this.data=t,67324752!==t.readUInt32LE(0))throw new l(h.EINVAL,"Invalid Zip file: Local file header has invalid signature: "+this.data.readUInt32LE(0))}versionNeeded(){return this.data.readUInt16LE(4)}flags(){return this.data.readUInt16LE(6)}compressionMethod(){return this.data.readUInt16LE(8)}lastModFileTime(){return T(this.data.readUInt16LE(10),this.data.readUInt16LE(12))}rawLastModFileTime(){return this.data.readUInt32LE(10)}crc32(){return this.data.readUInt32LE(14)}fileNameLength(){return this.data.readUInt16LE(26)}extraFieldLength(){return this.data.readUInt16LE(28)}fileName(){return R(this.data,this.useUTF8(),30,this.fileNameLength())}extraField(){const t=30+this.fileNameLength();return this.data.slice(t,t+this.extraFieldLength())}totalSize(){return 30+this.fileNameLength()+this.extraFieldLength()}useUTF8(){return 2048==(2048&this.flags())}}class L{constructor(t,e,r){this.header=t,this.record=e,this.data=r}decompress(){const t=this.header.compressionMethod(),e=k[t];if(e)return e(this.data,this.record.compressedSize(),this.record.uncompressedSize(),this.record.flag());{let e=O[t];throw e||(e=`Unknown: ${t}`),new l(h.EINVAL,`Invalid compression method on file '${this.header.fileName()}': ${e}`)}}getHeader(){return this.header}getRecord(){return this.record}getRawData(){return this.data}}class A{constructor(t,e){if(this.zipData=t,this.data=e,33639248!==this.data.readUInt32LE(0))throw new l(h.EINVAL,`Invalid Zip file: Central directory record has invalid signature: ${this.data.readUInt32LE(0)}`);this._filename=this.produceFilename()}versionMadeBy(){return this.data.readUInt16LE(4)}versionNeeded(){return this.data.readUInt16LE(6)}flag(){return this.data.readUInt16LE(8)}compressionMethod(){return this.data.readUInt16LE(10)}lastModFileTime(){return T(this.data.readUInt16LE(12),this.data.readUInt16LE(14))}rawLastModFileTime(){return this.data.readUInt32LE(12)}crc32(){return this.data.readUInt32LE(16)}compressedSize(){return this.data.readUInt32LE(20)}uncompressedSize(){return this.data.readUInt32LE(24)}fileNameLength(){return this.data.readUInt16LE(28)}extraFieldLength(){return this.data.readUInt16LE(30)}fileCommentLength(){return this.data.readUInt16LE(32)}diskNumberStart(){return this.data.readUInt16LE(34)}internalAttributes(){return this.data.readUInt16LE(36)}externalAttributes(){return this.data.readUInt32LE(38)}headerRelativeOffset(){return this.data.readUInt32LE(42)}produceFilename(){const t=R(this.data,this.useUTF8(),46,this.fileNameLength());return t.replace(/\\/g,"/")}fileName(){return this._filename}rawFileName(){return this.data.slice(46,46+this.fileNameLength())}extraField(){const t=44+this.fileNameLength();return this.data.slice(t,t+this.extraFieldLength())}fileComment(){const t=46+this.fileNameLength()+this.extraFieldLength();return R(this.data,this.useUTF8(),t,this.fileCommentLength())}rawFileComment(){const t=46+this.fileNameLength()+this.extraFieldLength();return this.data.slice(t,t+this.fileCommentLength())}totalSize(){return 46+this.fileNameLength()+this.extraFieldLength()+this.fileCommentLength()}isDirectory(){const t=this.fileName();return!!(16&this.externalAttributes())||"/"===t.charAt(t.length-1)}isFile(){return!this.isDirectory()}useUTF8(){return 2048==(2048&this.flag())}isEncrypted(){return 1==(1&this.flag())}getFileData(){const t=this.headerRelativeOffset(),e=new D(this.zipData.slice(t));return new L(e,this,this.zipData.slice(t+e.totalSize()))}getData(){return this.getFileData().decompress()}getRawData(){return this.getFileData().getRawData()}getStats(){return new u(d.FILE,this.uncompressedSize(),365,Date.now(),this.lastModFileTime().getTime())}}class x{constructor(t){if(this.data=t,101010256!==this.data.readUInt32LE(0))throw new l(h.EINVAL,`Invalid Zip file: End of central directory record has invalid signature: ${this.data.readUInt32LE(0)}`)}diskNumber(){return this.data.readUInt16LE(4)}cdDiskNumber(){return this.data.readUInt16LE(6)}cdDiskEntryCount(){return this.data.readUInt16LE(8)}cdTotalEntryCount(){return this.data.readUInt16LE(10)}cdSize(){return this.data.readUInt32LE(12)}cdOffset(){return this.data.readUInt32LE(16)}cdZipCommentLength(){return this.data.readUInt16LE(20)}cdZipComment(){return R(this.data,!0,22,this.cdZipCommentLength())}rawCdZipComment(){return this.data.slice(22,22+this.cdZipCommentLength())}}class P{constructor(t,e,r,s){this.index=t,this.directoryEntries=e,this.eocd=r,this.data=s}}class v extends f{constructor(t,e=""){super(),this.name=e,this._index=new E,this._directoryEntries=[],this._eocd=null,this._index=t.index,this._directoryEntries=t.directoryEntries,this._eocd=t.eocd,this.data=t.data}static Create(t,e){try{v._computeIndex(t.zipData,(r,s)=>{if(s){const r=new v(s,t.name);e(null,r)}else e(r)})}catch(t){e(t)}}static isAvailable(){return!0}static RegisterDecompressionMethod(t,e){k[t]=e}static _getEOCD(t){const e=Math.min(65557,t.length-1);for(let r=22;r<e;r++)if(101010256===t.readUInt32LE(t.length-r))return new x(t.slice(t.length-r));throw new l(h.EINVAL,"Invalid ZIP file: Could not locate End of Central Directory signature.")}static _addToIndex(t,e){let r=t.fileName();if("/"===r.charAt(0))throw new l(h.EPERM,"Unexpectedly encountered an absolute path in a zip file. Please file a bug.");"/"===r.charAt(r.length-1)&&(r=r.substr(0,r.length-1)),t.isDirectory()?e.addPathFast("/"+r,new w(t)):e.addPathFast("/"+r,new b(t))}static _computeIndex(t,e){try{const r=new E,s=v._getEOCD(t);if(s.diskNumber()!==s.cdDiskNumber())return e(new l(h.EINVAL,"ZipFS does not support spanned zip files."));const i=s.cdOffset();if(4294967295===i)return e(new l(h.EINVAL,"ZipFS does not support Zip64."));const n=i+s.cdSize();v._computeIndexResponsive(t,r,i,n,e,[],s)}catch(t){e(t)}}static _computeIndexResponsiveTrampoline(t,e,r,s,i,n,o){try{v._computeIndexResponsive(t,e,r,s,i,n,o)}catch(t){i(t)}}static _computeIndexResponsive(t,e,r,s,i,n,o){if(r<s){let c=0;for(;c++<200&&r<s;){const s=new A(t,t.slice(r));v._addToIndex(s,e),r+=s.totalSize(),n.push(s)}a(()=>{v._computeIndexResponsiveTrampoline(t,e,r,s,i,n,o)})}else i(null,new P(e,n,o,t))}getName(){return v.Name+(""!==this.name?` ${this.name}`:"")}getCentralDirectoryEntry(t){const e=this._index.getInode(t);if(null===e)throw l.ENOENT(t);if(I(e))return e.getData();if(F(e))return e.getData();throw l.EPERM(`Invalid inode: ${e}`)}getCentralDirectoryEntryAt(t){const e=this._directoryEntries[t];if(!e)throw new RangeError(`Invalid directory index: ${t}.`);return e}getNumberOfCentralDirectoryEntries(){return this._directoryEntries.length}getEndOfCentralDirectory(){return this._eocd}diskSpace(t,e){e(this.data.length,0)}isReadOnly(){return!0}supportsLinks(){return!1}supportsProps(){return!1}supportsSynch(){return!0}statSync(t,e){const r=this._index.getInode(t);if(null===r)throw l.ENOENT(t);let s;if(I(r))s=r.getData().getStats();else{if(!F(r))throw new l(h.EINVAL,"Invalid inode.");s=r.getStats()}return s}openSync(t,e,r){if(e.isWriteable())throw new l(h.EPERM,t);const s=this._index.getInode(t);if(!s)throw l.ENOENT(t);if(!I(s))throw l.EISDIR(t);{const r=s.getData(),i=r.getStats();switch(e.pathExistsAction()){case y.THROW_EXCEPTION:case y.TRUNCATE_FILE:throw l.EEXIST(t);case y.NOP:return new p(this,t,e,i,r.getData());default:throw new l(h.EINVAL,"Invalid FileMode object.")}}}readdirSync(t){const e=this._index.getInode(t);if(e){if(F(e))return e.getListing();throw l.ENOTDIR(t)}throw l.ENOENT(t)}readFileSync(t,e,r){const s=this.openSync(t,r,420);try{const t=s,r=t.getBuffer();return null===e?g(r):r.toString(e)}finally{s.closeSync()}}}return v.Name="ZipFS",v.Options={zipData:{type:"object",description:"The zip file as a Buffer object.",validator:_},name:{type:"string",optional:!0,description:"The name of the zip file (optional)."}},v.CompressionMethod=O,v.RegisterDecompressionMethod(O.DEFLATE,(t,e,r)=>m(S(t.slice(0,e),{chunkSize:r}))),v.RegisterDecompressionMethod(O.STORED,(t,e,r)=>g(t,0,r)),v}),t("skylark-browserfs/backend/IsoFS",["../core/api_error","../core/node_fs_stats","../core/file_system","../core/file_flag","../generic/preload_file","../core/util","../libs/path"],function(t,e,r,s,i,n,o){"use strict";const{ApiError:a,ErrorCode:c}=t,{Stats:l,FileType:h}=e,{SynchronousFileSystem:u}=r,{ActionType:d}=s,{NoSyncFile:f}=i,{copyingSlice:y,bufferValidator:p}=n,m="IEEE_P1282";function g(t,e,r){return t.toString("ascii",e,e+r).trim()}function _(t,e,r){if(1===r)return String.fromCharCode(t[e]);const s=Math.floor(r/2),i=new Array(s);for(let r=0;r<s;r++){const s=e+(r<<1);i[r]=String.fromCharCode(t[s+1]|t[s]<<8)}return i.join("")}function S(t,e){const r=parseInt(g(t,e,4),10),s=parseInt(g(t,e+4,2),10),i=parseInt(g(t,e+6,2),10),n=parseInt(g(t,e+8,2),10),o=parseInt(g(t,e+10,2),10),a=parseInt(g(t,e+12,2),10),c=parseInt(g(t,e+14,2),10);return new Date(r,s,i,n,o,a,100*c)}function E(t,e){const r=t[e],s=t[e+1],i=t[e+2],n=t[e+3],o=t[e+4],a=t[e+5];return new Date(r,s-1,i,n,o,a)}function w(t,e){const r=t.slice(e),s=new D(r);switch(s.signatureWord()){case 17221:return new L(r);case 20548:return new A(r);case 21328:return new x(r);case 21332:return new P(r);case 17746:return new v(r);case 17747:return new C(r);case 20568:return new U(r);case 20558:return new z(r);case 21324:return new B(r);case 20045:return new j(r);case 17228:return new q(r);case 20556:return new H(r);case 21061:return new W(r);case 21574:return new $(r);case 21318:return new X(r);case 21074:return new M(r);default:return s}}function b(t,e,r,s){r-=4;let i=new Array;for(;e<r;){const r=w(t,e),n=r.length();if(0===n)return i;if(e+=n,r instanceof P)break;r instanceof L?i=i.concat(r.getEntries(s)):i.push(r)}return i}class F{constructor(t){this._data=t}type(){return this._data[0]}standardIdentifier(){return g(this._data,1,5)}version(){return this._data[6]}data(){return this._data.slice(7,2048)}}class I extends F{constructor(t){super(t),this._root=null}systemIdentifier(){return this._getString32(8)}volumeIdentifier(){return this._getString32(40)}volumeSpaceSize(){return this._data.readUInt32LE(80)}volumeSetSize(){return this._data.readUInt16LE(120)}volumeSequenceNumber(){return this._data.readUInt16LE(124)}logicalBlockSize(){return this._data.readUInt16LE(128)}pathTableSize(){return this._data.readUInt32LE(132)}locationOfTypeLPathTable(){return this._data.readUInt32LE(140)}locationOfOptionalTypeLPathTable(){return this._data.readUInt32LE(144)}locationOfTypeMPathTable(){return this._data.readUInt32BE(148)}locationOfOptionalTypeMPathTable(){return this._data.readUInt32BE(152)}rootDirectoryEntry(t){return null===this._root&&(this._root=this._constructRootDirectoryRecord(this._data.slice(156)),this._root.rootCheckForRockRidge(t)),this._root}volumeSetIdentifier(){return this._getString(190,128)}publisherIdentifier(){return this._getString(318,128)}dataPreparerIdentifier(){return this._getString(446,128)}applicationIdentifier(){return this._getString(574,128)}copyrightFileIdentifier(){return this._getString(702,38)}abstractFileIdentifier(){return this._getString(740,36)}bibliographicFileIdentifier(){return this._getString(776,37)}volumeCreationDate(){return S(this._data,813)}volumeModificationDate(){return S(this._data,830)}volumeExpirationDate(){return S(this._data,847)}volumeEffectiveDate(){return S(this._data,864)}fileStructureVersion(){return this._data[881]}applicationUsed(){return this._data.slice(883,1395)}reserved(){return this._data.slice(1395,2048)}_getString32(t){return this._getString(t,32)}}class k extends I{constructor(t){if(super(t),1!==this.type())throw new a(c.EIO,"Invalid primary volume descriptor.")}name(){return"ISO9660"}_constructRootDirectoryRecord(t){return new T(t,-1)}_getString(t,e){return this._getString(t,e)}}class N extends I{constructor(t){if(super(t),2!==this.type())throw new a(c.EIO,"Invalid supplementary volume descriptor.");const e=this.escapeSequence(),r=e[2];if(37!==e[0]||47!==e[1]||64!==r&&67!==r&&69!==r)throw new a(c.EIO,`Unrecognized escape sequence for SupplementaryVolumeDescriptor: ${e.toString()}`)}name(){return"Joliet"}escapeSequence(){return this._data.slice(88,120)}_constructRootDirectoryRecord(t){return new R(t,-1)}_getString(t,e){return _(this._data,t,e)}}class O{constructor(t,e){this._suEntries=null,this._fileOrDir=null,this._data=t,this._rockRidgeOffset=e}hasRockRidge(){return this._rockRidgeOffset>-1}getRockRidgeOffset(){return this._rockRidgeOffset}rootCheckForRockRidge(t){const e=this.getDirectory(t);this._rockRidgeOffset=e.getDotEntry(t)._getRockRidgeOffset(t),this._rockRidgeOffset>-1&&(this._fileOrDir=null)}length(){return this._data[0]}extendedAttributeRecordLength(){return this._data[1]}lba(){return 2048*this._data.readUInt32LE(2)}dataLength(){return this._data.readUInt32LE(10)}recordingDate(){return E(this._data,18)}fileFlags(){return this._data[25]}fileUnitSize(){return this._data[26]}interleaveGapSize(){return this._data[27]}volumeSequenceNumber(){return this._data.readUInt16LE(28)}identifier(){return this._getString(33,this._data[32])}fileName(t){if(this.hasRockRidge()){const e=this._rockRidgeFilename(t);if(null!==e)return e}const e=this.identifier();if(this.isDirectory(t))return e;const r=e.indexOf(";");return-1===r?e:"."===e[r-1]?e.slice(0,r-1):e.slice(0,r)}isDirectory(t){let e=!!(2&this.fileFlags());return!e&&this.hasRockRidge()&&(e=this.getSUEntries(t).filter(t=>t instanceof q).length>0),e}isSymlink(t){return this.hasRockRidge()&&this.getSUEntries(t).filter(t=>t instanceof B).length>0}getSymlinkPath(t){let e="";const r=this.getSUEntries(t),s=this._getGetString();for(const t of r)if(t instanceof B){const r=t.componentRecords();for(const t of r){const r=t.flags();2&r?e+="./":4&r?e+="../":8&r?e+="/":(e+=t.content(s),1&r||(e+="/"))}if(!t.continueFlag())break}return e.length>1&&"/"===e[e.length-1]?e.slice(0,e.length-1):e}getFile(t){if(this.isDirectory(t))throw new Error("Tried to get a File from a directory.");return null===this._fileOrDir&&(this._fileOrDir=t.slice(this.lba(),this.lba()+this.dataLength())),this._fileOrDir}getDirectory(t){if(!this.isDirectory(t))throw new Error("Tried to get a Directory from a file.");return null===this._fileOrDir&&(this._fileOrDir=this._constructDirectory(t)),this._fileOrDir}getSUEntries(t){return this._suEntries||this._constructSUEntries(t),this._suEntries}_rockRidgeFilename(t){const e=this.getSUEntries(t).filter(t=>t instanceof j);if(0===e.length||6&e[0].flags())return null;let r="";const s=this._getGetString();for(const t of e)if(r+=t.name(s),!(1&t.flags()))break;return r}_constructSUEntries(t){let e=33+this._data[32];e%2==1&&e++,e+=this._rockRidgeOffset,this._suEntries=b(this._data,e,this.length(),t)}_getRockRidgeOffset(t){this._rockRidgeOffset=0;const e=this.getSUEntries(t);if(e.length>0){const t=e[0];if(t instanceof x&&t.checkBytesPass())for(let r=1;r<e.length;r++){const s=e[r];if(s instanceof M||s instanceof v&&s.extensionIdentifier()===m)return t.bytesSkipped()}}return this._rockRidgeOffset=-1,-1}}class T extends O{constructor(t,e){super(t,e)}_getString(t,e){return g(this._data,t,e)}_constructDirectory(t){return new J(this,t)}_getGetString(){return g}}class R extends O{constructor(t,e){super(t,e)}_getString(t,e){return _(this._data,t,e)}_constructDirectory(t){return new K(this,t)}_getGetString(){return _}}class D{constructor(t){this._data=t}signatureWord(){return this._data.readUInt16BE(0)}signatureWordString(){return g(this._data,0,2)}length(){return this._data[2]}suVersion(){return this._data[3]}}class L extends D{constructor(t){super(t),this._entries=null}continuationLba(){return this._data.readUInt32LE(4)}continuationLbaOffset(){return this._data.readUInt32LE(12)}continuationLength(){return this._data.readUInt32LE(20)}getEntries(t){if(!this._entries){const e=2048*this.continuationLba()+this.continuationLbaOffset();this._entries=b(t,e,this.continuationLength(),t)}return this._entries}}class A extends D{constructor(t){super(t)}}class x extends D{constructor(t){super(t)}checkBytesPass(){return 190===this._data[4]&&239===this._data[5]}bytesSkipped(){return this._data[6]}}class P extends D{constructor(t){super(t)}}class v extends D{constructor(t){super(t)}identifierLength(){return this._data[4]}descriptorLength(){return this._data[5]}sourceLength(){return this._data[6]}extensionVersion(){return this._data[7]}extensionIdentifier(){return g(this._data,8,this.identifierLength())}extensionDescriptor(){return g(this._data,8+this.identifierLength(),this.descriptorLength())}extensionSource(){return g(this._data,8+this.identifierLength()+this.descriptorLength(),this.sourceLength())}}class C extends D{constructor(t){super(t)}extensionSequence(){return this._data[4]}}class M extends D{constructor(t){super(t)}}class U extends D{constructor(t){super(t)}mode(){return this._data.readUInt32LE(4)}fileLinks(){return this._data.readUInt32LE(12)}uid(){return this._data.readUInt32LE(20)}gid(){return this._data.readUInt32LE(28)}inode(){return this._data.readUInt32LE(36)}}class z extends D{constructor(t){super(t)}devTHigh(){return this._data.readUInt32LE(4)}devTLow(){return this._data.readUInt32LE(12)}}class B extends D{constructor(t){super(t)}flags(){return this._data[4]}continueFlag(){return 1&this.flags()}componentRecords(){const t=new Array;let e=5;for(;e<this.length();){const r=new V(this._data.slice(e));t.push(r),e+=r.length()}return t}}class V{constructor(t){this._data=t}flags(){return this._data[0]}length(){return 2+this.componentLength()}componentLength(){return this._data[1]}content(t){return t(this._data,2,this.componentLength())}}class j extends D{constructor(t){super(t)}flags(){return this._data[4]}name(t){return t(this._data,5,this.length()-5)}}class q extends D{constructor(t){super(t)}childDirectoryLba(){return this._data.readUInt32LE(4)}}class H extends D{constructor(t){super(t)}parentDirectoryLba(){return this._data.readUInt32LE(4)}}class W extends D{constructor(t){super(t)}}class $ extends D{constructor(t){super(t)}flags(){return this._data[4]}creation(){return 1&this.flags()?this._longFormDates()?S(this._data,5):E(this._data,5):null}modify(){if(2&this.flags()){const t=1&this.flags()?1:0;return this._longFormDates?S(this._data,5+17*t):E(this._data,5+7*t)}return null}access(){if(4&this.flags()){let t=1&this.flags()?1:0;return t+=2&this.flags()?1:0,this._longFormDates?S(this._data,5+17*t):E(this._data,5+7*t)}return null}backup(){if(16&this.flags()){let t=1&this.flags()?1:0;return t+=2&this.flags()?1:0,t+=4&this.flags()?1:0,this._longFormDates?S(this._data,5+17*t):E(this._data,5+7*t)}return null}expiration(){if(32&this.flags()){let t=1&this.flags()?1:0;return t+=2&this.flags()?1:0,t+=4&this.flags()?1:0,t+=16&this.flags()?1:0,this._longFormDates?S(this._data,5+17*t):E(this._data,5+7*t)}return null}effective(){if(64&this.flags()){let t=1&this.flags()?1:0;return t+=2&this.flags()?1:0,t+=4&this.flags()?1:0,t+=16&this.flags()?1:0,t+=32&this.flags()?1:0,this._longFormDates?S(this._data,5+17*t):E(this._data,5+7*t)}return null}_longFormDates(){return!!this.flags()}}class X extends D{constructor(t){super(t)}virtualSizeHigh(){return this._data.readUInt32LE(4)}virtualSizeLow(){return this._data.readUInt32LE(12)}tableDepth(){return this._data[20]}}class Y{constructor(t,e){this._fileList=[],this._fileMap={},this._record=t;let r=t.lba(),s=r+t.dataLength();if(!(2&t.fileFlags())){const i=t.getSUEntries(e).filter(t=>t instanceof q)[0];r=2048*i.childDirectoryLba(),s=1/0}for(;r<s;){const t=e[r];if(0===t){r++;continue}const i=this._constructDirectoryRecord(e.slice(r)),n=i.fileName(e);"\0"!==n&&""!==n?i.hasRockRidge()&&0!==i.getSUEntries(e).filter(t=>t instanceof W).length||(this._fileMap[n]=i,this._fileList.push(n)):s===1/0&&(s=r+i.dataLength()),r+=i.length()}}getRecord(t){return this._fileMap[t]}getFileList(){return this._fileList}getDotEntry(t){return this._constructDirectoryRecord(t.slice(this._record.lba()))}}class J extends Y{constructor(t,e){super(t,e)}_constructDirectoryRecord(t){return new T(t,this._record.getRockRidgeOffset())}}class K extends Y{constructor(t,e){super(t,e)}_constructDirectoryRecord(t){return new R(t,this._record.getRockRidgeOffset())}}class Z extends u{constructor(t,e=""){super(),this._data=t;let r=!1,s=32768;const i=new Array;for(;!r;){const e=t.slice(s),n=new F(e);switch(n.type()){case 1:i.push(new k(e));break;case 2:i.push(new N(e));break;case 255:r=!0}s+=2048}if(0===i.length)throw new a(c.EIO,"Unable to find a suitable volume descriptor.");i.forEach(t=>{this._pvd&&2===this._pvd.type()||(this._pvd=t)}),this._root=this._pvd.rootDirectoryEntry(t),this._name=e}static Create(t,e){try{e(null,new Z(t.data,t.name))}catch(t){e(t)}}static isAvailable(){return!0}getName(){let t=`IsoFS${this._name}${this._pvd?`-${this._pvd.name()}`:""}`;return this._root&&this._root.hasRockRidge()&&(t+="-RockRidge"),t}diskSpace(t,e){e(this._data.length,0)}isReadOnly(){return!0}supportsLinks(){return!1}supportsProps(){return!1}supportsSynch(){return!0}statSync(t,e){const r=this._getDirectoryRecord(t);if(null===r)throw a.ENOENT(t);return this._getStats(t,r)}openSync(t,e,r){if(e.isWriteable())throw new a(c.EPERM,t);const s=this._getDirectoryRecord(t);if(!s)throw a.ENOENT(t);if(s.isSymlink(this._data))return this.openSync(o.resolve(t,s.getSymlinkPath(this._data)),e,r);if(s.isDirectory(this._data))throw a.EISDIR(t);{const r=s.getFile(this._data),i=this._getStats(t,s);switch(e.pathExistsAction()){case d.THROW_EXCEPTION:case d.TRUNCATE_FILE:throw a.EEXIST(t);case d.NOP:return new f(this,t,e,i,r);default:throw new a(c.EINVAL,"Invalid FileMode object.")}}}readdirSync(t){const e=this._getDirectoryRecord(t);if(e){if(e.isDirectory(this._data))return e.getDirectory(this._data).getFileList().slice(0);throw a.ENOTDIR(t)}throw a.ENOENT(t)}readFileSync(t,e,r){const s=this.openSync(t,r,420);try{const t=s,r=t.getBuffer();return null===e?y(r):r.toString(e)}finally{s.closeSync()}}_getDirectoryRecord(t){if("/"===t)return this._root;const e=t.split("/").slice(1);let r=this._root;for(const t of e){if(!r.isDirectory(this._data))return null;if(!(r=r.getDirectory(this._data).getRecord(t)))return null}return r}_getStats(t,e){if(e.isSymlink(this._data)){const r=o.resolve(t,e.getSymlinkPath(this._data)),s=this._getDirectoryRecord(r);return s?this._getStats(r,s):null}{const t=e.dataLength();let r=365;const s=e.recordingDate().getTime();let i=s,n=s,o=s;if(e.hasRockRidge()){const t=e.getSUEntries(this._data);for(const e of t)if(e instanceof U)r=e.mode();else if(e instanceof $){const t=e.flags();4&t&&(i=e.access().getTime()),2&t&&(n=e.modify().getTime()),1&t&&(o=e.creation().getTime())}}return r&=365,new l(e.isDirectory(this._data)?h.DIRECTORY:h.FILE,t,r,i,n,o)}}}return Z.Name="IsoFS",Z.Options={data:{type:"object",description:"The ISO file in a buffer",validator:p}},Z}),t("skylark-browserfs/core/backends",["./util","../backend/AsyncMirror","../backend/Dropbox","../backend/Emscripten","../backend/FolderAdapter","../backend/HTML5FS","../backend/InMemory","../backend/IndexedDB","../backend/LocalStorage","../backend/MountableFileSystem","../backend/OverlayFS","../backend/WorkerFS","../backend/HTTPRequest","../backend/ZipFS","../backend/IsoFS"],function(t,e,r,s,i,n,o,a,c,l,h,u,d,f,y){"use strict";const{checkOptions:p}=t;[e,r,s,i,n,o,a,y,c,l,h,u,d,f].forEach(t=>{const e=t.Create;t.Create=function(r,s){const i="function"==typeof r,n=i?r:s,o=i?{}:r;p(t,o,function(r){r?n(r):e.call(t,o,n)})}});const m={AsyncMirror:e,Dropbox:r,Emscripten:s,FolderAdapter:i,HTML5FS:n,InMemory:o,IndexedDB:a,IsoFS:y,LocalStorage:c,MountableFileSystem:l,OverlayFS:h,WorkerFS:u,HTTPRequest:d,XmlHttpRequest:d,ZipFS:f};return m}),t("skylark-browserfs/core/browserfs",["skylark-langx-ns","../libs/process","../libs/buffers","./node_fs","../libs/path","../generic/emscripten_fs","./backends","./util","./api_error","../generic/setImmediate"],function(t,e,r,s,i,n,o,a,c,l){"use strict";const{Buffer:h}=r;function u(module){switch(module){case"fs":return s;case"path":return i;case"buffer":return buffer;case"process":return e;case"bfs_utils":return a;default:return o[module]}}function d(t){return s.initialize(t)}function f(t,e){const r=t.fs;if(!r)return e(new c.ApiError(c.ErrorCode.EPERM,'Missing "fs" property on configuration object.'));const s=t.options;let i=0,n=!1;function a(){if(!n){n=!0;const t=o[r];t?t.Create(s,e):e(new c.ApiError(c.ErrorCode.EPERM,`File system ${r} is not available in BrowserFS.`))}}if(null!==s&&"object"==typeof s){let t=!1;const r=Object.keys(s).filter(t=>"fs"!==t);r.forEach(r=>{const o=s[r];null!==o&&"object"==typeof o&&o.fs&&(i++,f(o,function(o,c){if(i--,o){if(n)return;n=!0,e(o)}else s[r]=c,0===i&&t&&a()}))}),t=!0}0===i&&a()}return e.initializeTTYs&&e.initializeTTYs(),t.attach("intg.BrowserFS",{install:function(t){t.Buffer=h,t.process=e;const r=t.require?t.require:null;t.require=function(t){const e=u(t);return e||r.apply(null,Array.prototype.slice.call(arguments,0))}},registerFileSystem:function(t,e){o[t]=e},BFSRequire:u,initialize:d,configure:function(t,e){f(t,(t,r)=>{r?(d(r),e()):e(t)})},getFileSystem:f,EmscriptenFS:n,FileSystem:o,Errors:c,setImmediate:l})}),t("skylark-browserfs/main",["./core/browserfs"],function(t){return t}),t("skylark-browserfs",["skylark-browserfs/main"],function(t){return t})}(r,require),!s){var o=require("skylark-langx-ns");i?module.exports=o:e.skylarkjs=o}}(0,this);
  //# sourceMappingURL=sourcemaps/skylark-browserfs.js.map
  