UNPKG

@terbiumos/tfs

Version:

The drop in Filer replacement you have been waiting for. Completely Typed and Built with TypeScript

1 lines 52.8 kB
import{createRequire as t}from"node:module";var e,n={};n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var r={};n.d(r,{k:()=>tN});let i=t(import.meta.url)("buffer");var o=((e={}).EACCES="permission denied",e.EBADF="bad file descriptor",e.EBUSY="resource busy or locked",e.EINVAL="invalid argument",e.ENOTDIR="not a directory",e.EISDIR="illegal operation on a directory",e.ENOENT="no such file or directory",e.EEXIST="file already exists",e.EPERM="operation not permitted",e.ELOOP="too many symbolic links encountered",e.ENOTEMPTY="directory not empty",e.EIO="i/o error",e.ENOSPC="no space left on device",e.UNKNOWN="unknown error",e),s={EACCES:13,EBADF:9,EBUSY:16,EINVAL:22,ENOTDIR:20,EISDIR:21,ENOENT:34,EEXIST:17,EPERM:1,ELOOP:40,ENOTEMPTY:39,EIO:5,ENOSPC:28,UNKNOWN:-1};function a(t,e,n){return"UNKNOWN"===t&&n?{name:"UNKNOWN",code:n,errno:-1,message:o[t],path:e}:{name:t,code:t,errno:s[t],message:o[t],path:e}}function l(t,e){if(t&&"NotFoundError"===t.name)return a("ENOENT",e);if(t&&"TypeMismatchError"===t.name)return a("EISDIR",e);if(t&&"NoModificationAllowedError"===t.name)return a("EPERM",e);if(t&&"QuotaExceededError"===t.name)return a("ENOSPC",e);if(t&&"SecurityError"===t.name)return a("EACCES",e);else if(t&&"InvalidModificationError"===t.name)return a("EEXIST",e);else if(t&&"NotReadableError"===t.name)return a("EIO",e);else if(t&&"DirectoryNotEmptyError"===t.name)return a("ENOTEMPTY",e);else if(t&&"PathExistsError"===t.name)return a("EEXIST",e);else if(t&&"noFD"===t.name)return a("EBADF",e);else return a("UNKNOWN",e,t&&t.message)}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function c(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function f(t){return function(t){if(Array.isArray(t))return u(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return u(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);if("Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return u(t,e)}}(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var h=function(){"use strict";var t;function e(){if(!(this instanceof e))throw TypeError("Cannot call a class as a function");c(this,"sep","/"),c(this,"delimiter",":")}return t=[{key:"normalizePath",value:function(t,e){if(e&&(this.sep=e),!t)return this.sep;t.startsWith("/")||(t=this.sep+"/"+t);var n=t.split("/").filter(Boolean),r=[],i=!0,o=!1,s=void 0;try{for(var a,l=n[Symbol.iterator]();!(i=(a=l.next()).done);i=!0){var u=a.value;"."!==u&&""!==u&&(".."===u?r.length>0&&r.pop():r.push(u))}}catch(t){o=!0,s=t}finally{try{i||null==l.return||l.return()}finally{if(o)throw s}}var c="/"+r.join("/");return"//"===c&&(c="/"),c}},{key:"basename",value:function(t,e){var n=t.split("/").pop()||"";return e&&n.endsWith(e)?n.slice(0,-e.length)||"/":""===n?"/":n}},{key:"normalize",value:function(t){var e=this.normalizePath(t);return"/"===e?"/":this.removeTrailing(e)}},{key:"isNull",value:function(t){return -1!==(""+t).indexOf("\0")}},{key:"addTrailing",value:function(t){return t.replace(/\/*$/,"/")}},{key:"removeTrailing",value:function(t){return""===(t=t.replace(/\/*$/,""))?"/":t}},{key:"join",value:function(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.filter(Boolean).map(function(t,e){return 0===e?t.replace(/\/+$/,""):t.replace(/^\/+|\/+$/g,"")}).join(this.sep)}},{key:"dirname",value:function(t){if(!t||"/"===t)return"/";var e=t.split("/").filter(Boolean);return e.pop(),"/"+e.join("/")}},{key:"extname",value:function(t){var e=t.split("/").pop()||"",n=e.lastIndexOf(".");return n>0?e.slice(n):""}},{key:"isAbsolute",value:function(t){return t.startsWith("/")}},{key:"relative",value:function(t,e){for(var n=this.normalizePath(t).split("/").filter(Boolean),r=this.normalizePath(e).split("/").filter(Boolean),i=0;i<n.length&&i<r.length&&n[i]===r[i];)i++;var o=n.slice(i).map(function(){return".."}),s=r.slice(i);return f(o).concat(f(s)).join("/")||"."}},{key:"resolve",value:function(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];var r="",i=!0,o=!1,s=void 0;try{for(var a,l=e[Symbol.iterator]();!(i=(a=l.next()).done);i=!0){var u=a.value;r=this.isAbsolute(u)?u:this.join(r,u)}}catch(t){o=!0,s=t}finally{try{i||null==l.return||l.return()}finally{if(o)throw s}}return this.normalize(r)}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(e.prototype,t),e}();let p=(t,e,n)=>{let r=t instanceof RegExp?d(t,n):t,i=e instanceof RegExp?d(e,n):e,o=null!==r&&null!=i&&m(r,i,n);return o&&{start:o[0],end:o[1],pre:n.slice(0,o[0]),body:n.slice(o[0]+r.length,o[1]),post:n.slice(o[1]+i.length)}},d=(t,e)=>{let n=e.match(t);return n?n[0]:null},m=(t,e,n)=>{let r,i,o,s,a,l=n.indexOf(t),u=n.indexOf(e,l+1),c=l;if(l>=0&&u>0){if(t===e)return[l,u];for(r=[],o=n.length;c>=0&&!a;){if(c===l)r.push(c),l=n.indexOf(t,c+1);else if(1===r.length){let t=r.pop();void 0!==t&&(a=[t,u])}else void 0!==(i=r.pop())&&i<o&&(o=i,s=u),u=n.indexOf(e,c+1);c=l<u&&l>=0?l:u}r.length&&void 0!==s&&(a=[o,s])}return a},y="\0SLASH"+Math.random()+"\0",g="\0OPEN"+Math.random()+"\0",v="\0CLOSE"+Math.random()+"\0",b="\0COMMA"+Math.random()+"\0",w="\0PERIOD"+Math.random()+"\0",E=RegExp(y,"g"),O=RegExp(g,"g"),S=RegExp(v,"g"),P=RegExp(b,"g"),k=RegExp(w,"g"),M=/\\\\/g,x=/\\{/g,R=/\\}/g,T=/\\,/g,A=/\\./g;function D(t){return isNaN(t)?t.charCodeAt(0):parseInt(t,10)}function I(t){return t.replace(E,"\\").replace(O,"{").replace(S,"}").replace(P,",").replace(k,".")}function N(t){return"{"+t+"}"}function j(t){return/^-?0\d/.test(t)}function F(t,e){return t<=e}function C(t,e){return t>=e}let z=t=>{if("string"!=typeof t)throw TypeError("invalid pattern");if(t.length>65536)throw TypeError("pattern is too long")},$={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},B=t=>t.replace(/[[\]\\-]/g,"\\$&"),L=(t,e)=>{if("["!==t.charAt(e))throw Error("not in a brace expression");let n=[],r=[],i=e+1,o=!1,s=!1,a=!1,l=!1,u=e,c="";t:for(;i<t.length;){let f=t.charAt(i);if(("!"===f||"^"===f)&&i===e+1){l=!0,i++;continue}if("]"===f&&o&&!a){u=i+1;break}if(o=!0,"\\"===f&&!a){a=!0,i++;continue}if("["===f&&!a){for(let[o,[a,l,u]]of Object.entries($))if(t.startsWith(o,i)){if(c)return["$.",!1,t.length-e,!0];i+=o.length,u?r.push(a):n.push(a),s=s||l;continue t}}if(a=!1,c){f>c?n.push(B(c)+"-"+B(f)):f===c&&n.push(B(f)),c="",i++;continue}if(t.startsWith("-]",i+1)){n.push(B(f+"-")),i+=2;continue}if(t.startsWith("-",i+1)){c=f,i+=2;continue}n.push(B(f)),i++}if(u<i)return["",!1,0,!1];if(!n.length&&!r.length)return["$.",!1,t.length-e,!0];if(0===r.length&&1===n.length&&/^\\?.$/.test(n[0])&&!l)return[(2===n[0].length?n[0].slice(-1):n[0]).replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),!1,u-e,!1];let f="["+(l?"^":"")+n.join("")+"]",h="["+(l?"":"^")+r.join("")+"]";return[n.length&&r.length?"("+f+"|"+h+")":n.length?f:h,s,u-e,!0]},W=(t,{windowsPathsNoEscape:e=!1}={})=>e?t.replace(/\[([^\/\\])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"),Y=new Set(["!","?","+","*","@"]),U=t=>Y.has(t),H="(?!\\.)",G=new Set(["[","."]),_=new Set(["..","."]),K=new Set("().*{}+?[]^$\\!"),Z=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),V="[^/]",X=V+"*?",J=V+"+?";class q{type;#t;#e;#n=!1;#r=[];#i;#o;#s;#a=!1;#l;#u;#c=!1;constructor(t,e,n={}){this.type=t,t&&(this.#e=!0),this.#i=e,this.#t=this.#i?this.#i.#t:this,this.#l=this.#t===this?n:this.#t.#l,this.#s=this.#t===this?[]:this.#t.#s,"!"!==t||this.#t.#a||this.#s.push(this),this.#o=this.#i?this.#i.#r.length:0}get hasMagic(){if(void 0!==this.#e)return this.#e;for(let t of this.#r)if("string"!=typeof t&&(t.type||t.hasMagic))return this.#e=!0;return this.#e}toString(){return void 0!==this.#u?this.#u:this.type?this.#u=this.type+"("+this.#r.map(t=>String(t)).join("|")+")":this.#u=this.#r.map(t=>String(t)).join("")}#f(){let t;if(this!==this.#t)throw Error("should only call on root");if(this.#a)return this;for(this.toString(),this.#a=!0;t=this.#s.pop();){if("!"!==t.type)continue;let e=t,n=e.#i;for(;n;){for(let r=e.#o+1;!n.type&&r<n.#r.length;r++)for(let e of t.#r){if("string"==typeof e)throw Error("string part in extglob AST??");e.copyIn(n.#r[r])}n=(e=n).#i}}return this}push(...t){for(let e of t)if(""!==e){if("string"!=typeof e&&!(e instanceof q&&e.#i===this))throw Error("invalid part: "+e);this.#r.push(e)}}toJSON(){let t=null===this.type?this.#r.slice().map(t=>"string"==typeof t?t:t.toJSON()):[this.type,...this.#r.map(t=>t.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#t||this.#t.#a&&this.#i?.type==="!")&&t.push({}),t}isStart(){if(this.#t===this)return!0;if(!this.#i?.isStart())return!1;if(0===this.#o)return!0;let t=this.#i;for(let e=0;e<this.#o;e++){let n=t.#r[e];if(!(n instanceof q&&"!"===n.type))return!1}return!0}isEnd(){if(this.#t===this||this.#i?.type==="!")return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let t=this.#i?this.#i.#r.length:0;return this.#o===t-1}copyIn(t){"string"==typeof t?this.push(t):this.push(t.clone(this))}clone(t){let e=new q(this.type,t);for(let t of this.#r)e.copyIn(t);return e}static #h(t,e,n,r){let i=!1,o=!1,s=-1,a=!1;if(null===e.type){let l=n,u="";for(;l<t.length;){let n=t.charAt(l++);if(i||"\\"===n){i=!i,u+=n;continue}if(o){l===s+1?("^"===n||"!"===n)&&(a=!0):"]"!==n||l===s+2&&a||(o=!1),u+=n;continue}if("["===n){o=!0,s=l,a=!1,u+=n;continue}if(!r.noext&&U(n)&&"("===t.charAt(l)){e.push(u),u="";let i=new q(n,e);l=q.#h(t,i,l,r),e.push(i);continue}u+=n}return e.push(u),l}let l=n+1,u=new q(null,e),c=[],f="";for(;l<t.length;){let n=t.charAt(l++);if(i||"\\"===n){i=!i,f+=n;continue}if(o){l===s+1?("^"===n||"!"===n)&&(a=!0):"]"!==n||l===s+2&&a||(o=!1),f+=n;continue}if("["===n){o=!0,s=l,a=!1,f+=n;continue}if(U(n)&&"("===t.charAt(l)){u.push(f),f="";let e=new q(n,u);u.push(e),l=q.#h(t,e,l,r);continue}if("|"===n){u.push(f),f="",c.push(u),u=new q(null,e);continue}if(")"===n)return""===f&&0===e.#r.length&&(e.#c=!0),u.push(f),f="",e.push(...c,u),l;f+=n}return e.type=null,e.#e=void 0,e.#r=[t.substring(n-1)],l}static fromGlob(t,e={}){let n=new q(null,void 0,e);return q.#h(t,n,0,e),n}toMMPattern(){if(this!==this.#t)return this.#t.toMMPattern();let t=this.toString(),[e,n,r,i]=this.toRegExpSource();return r||this.#e||this.#l.nocase&&!this.#l.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()?Object.assign(RegExp(`^${e}$`,(this.#l.nocase?"i":"")+(i?"u":"")),{_src:e,_glob:t}):n}get options(){return this.#l}toRegExpSource(t){let e=t??!!this.#l.dot;if(this.#t===this&&this.#f(),!this.type){let n=this.isStart()&&this.isEnd(),r=this.#r.map(e=>{let[r,i,o,s]="string"==typeof e?q.#p(e,this.#e,n):e.toRegExpSource(t);return this.#e=this.#e||o,this.#n=this.#n||s,r}).join(""),i="";if(this.isStart()&&"string"==typeof this.#r[0]&&!(1===this.#r.length&&_.has(this.#r[0]))){let n=e&&G.has(r.charAt(0))||r.startsWith("\\.")&&G.has(r.charAt(2))||r.startsWith("\\.\\.")&&G.has(r.charAt(4)),o=!e&&!t&&G.has(r.charAt(0));i=n?"(?!(?:^|/)\\.\\.?(?:$|/))":o?H:""}let o="";return this.isEnd()&&this.#t.#a&&this.#i?.type==="!"&&(o="(?:$|\\/)"),[i+r+o,W(r),this.#e=!!this.#e,this.#n]}let n="*"===this.type||"+"===this.type,r="!"===this.type?"(?:(?!(?:":"(?:",i=this.#d(e);if(this.isStart()&&this.isEnd()&&!i&&"!"!==this.type){let t=this.toString();return this.#r=[t],this.type=null,this.#e=void 0,[t,W(this.toString()),!1,!1]}let o=!n||t||e||!H?"":this.#d(!0);o===i&&(o=""),o&&(i=`(?:${i})(?:${o})*?`);return["!"===this.type&&this.#c?(this.isStart()&&!e?H:"")+J:r+i+("!"===this.type?"))"+(!this.isStart()||e||t?"":H)+X+")":"@"===this.type?")":"?"===this.type?")?":"+"===this.type&&o?")":"*"===this.type&&o?")?":`)${this.type}`),W(i),this.#e=!!this.#e,this.#n]}#d(t){return this.#r.map(e=>{if("string"==typeof e)throw Error("string type in extglob ast??");let[n,r,i,o]=e.toRegExpSource(t);return this.#n=this.#n||o,n}).filter(t=>!(this.isStart()&&this.isEnd())||!!t).join("|")}static #p(t,e,n=!1){let r=!1,i="",o=!1;for(let s=0;s<t.length;s++){let a=t.charAt(s);if(r){r=!1,i+=(K.has(a)?"\\":"")+a;continue}if("\\"===a){s===t.length-1?i+="\\\\":r=!0;continue}if("["===a){let[n,r,a,l]=L(t,s);if(a){i+=n,o=o||r,s+=a-1,e=e||l;continue}}if("*"===a){n&&"*"===t?i+=J:i+=X,e=!0;continue}if("?"===a){i+=V,e=!0;continue}i+=Z(a)}return[i,W(t),!!e,o]}}let Q=(t,e,n={})=>(z(e),(!!n.nocomment||"#"!==e.charAt(0))&&new tg(e,n).match(t)),tt=/^\*+([^+@!?\*\[\(]*)$/,te=/^\*+\.\*+$/,tn=t=>!t.startsWith(".")&&t.includes("."),tr=t=>"."!==t&&".."!==t&&t.includes("."),ti=/^\.\*+$/,to=t=>"."!==t&&".."!==t&&t.startsWith("."),ts=/^\*+$/,ta=t=>0!==t.length&&!t.startsWith("."),tl=t=>0!==t.length&&"."!==t&&".."!==t,tu=/^\?+([^+@!?\*\[\(]*)?$/,tc=([t])=>{let e=t.length;return t=>t.length===e&&!t.startsWith(".")},tf=([t])=>{let e=t.length;return t=>t.length===e&&"."!==t&&".."!==t},th="object"==typeof process&&process?"object"==typeof process.env&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix";Q.sep="win32"===th?"\\":"/";let tp=Symbol("globstar **");Q.GLOBSTAR=tp;Q.filter=(t,e={})=>n=>Q(n,t,e);let td=(t,e={})=>Object.assign({},t,e);Q.defaults=t=>{if(!t||"object"!=typeof t||!Object.keys(t).length)return Q;let e=Q;return Object.assign((n,r,i={})=>e(n,r,td(t,i)),{Minimatch:class extends e.Minimatch{constructor(e,n={}){super(e,td(t,n))}static defaults(n){return e.defaults(td(t,n)).Minimatch}},AST:class extends e.AST{constructor(e,n,r={}){super(e,n,td(t,r))}static fromGlob(n,r={}){return e.AST.fromGlob(n,td(t,r))}},unescape:(n,r={})=>e.unescape(n,td(t,r)),escape:(n,r={})=>e.escape(n,td(t,r)),filter:(n,r={})=>e.filter(n,td(t,r)),defaults:n=>e.defaults(td(t,n)),makeRe:(n,r={})=>e.makeRe(n,td(t,r)),braceExpand:(n,r={})=>e.braceExpand(n,td(t,r)),match:(n,r,i={})=>e.match(n,r,td(t,i)),sep:e.sep,GLOBSTAR:tp})};let tm=(t,e={})=>{if(z(t),e.nobrace||!/\{(?:(?!\{).)*\}/.test(t))return[t];var n=t;return n?("{}"===n.slice(0,2)&&(n="\\{\\}"+n.slice(2)),(function t(e,n){let r=[],i=p("{","}",e);if(!i)return[e];let o=i.pre,s=i.post.length?t(i.post,!1):[""];if(/\$$/.test(i.pre))for(let t=0;t<s.length;t++){let e=o+"{"+i.body+"}"+s[t];r.push(e)}else{let a,l,u=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),c=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),f=u||c,h=i.body.indexOf(",")>=0;if(!f&&!h)return i.post.match(/,(?!,).*\}/)?t(e=i.pre+"{"+i.body+v+i.post):[e];if(f)a=i.body.split(/\.\./);else if(1===(a=function t(e){if(!e)return[""];let n=[],r=p("{","}",e);if(!r)return e.split(",");let{pre:i,body:o,post:s}=r,a=i.split(",");a[a.length-1]+="{"+o+"}";let l=t(s);return s.length&&(a[a.length-1]+=l.shift(),a.push.apply(a,l)),n.push.apply(n,a),n}(i.body)).length&&void 0!==a[0]&&1===(a=t(a[0],!1).map(N)).length)return s.map(t=>i.pre+a[0]+t);if(f&&void 0!==a[0]&&void 0!==a[1]){let t=D(a[0]),e=D(a[1]),n=Math.max(a[0].length,a[1].length),r=3===a.length&&void 0!==a[2]?Math.abs(D(a[2])):1,i=F;e<t&&(r*=-1,i=C);let o=a.some(j);l=[];for(let s=t;i(s,e);s+=r){let t;if(c)"\\"===(t=String.fromCharCode(s))&&(t="");else if(t=String(s),o){let e=n-t.length;if(e>0){let n=Array(e+1).join("0");t=s<0?"-"+n+t.slice(1):n+t}}l.push(t)}}else{l=[];for(let e=0;e<a.length;e++)l.push.apply(l,t(a[e],!1))}for(let t=0;t<l.length;t++)for(let e=0;e<s.length;e++){let i=o+l[t]+s[e];(!n||f||i)&&r.push(i)}}return r})(n.replace(M,y).replace(x,g).replace(R,v).replace(T,b).replace(A,w),!0).map(I)):[]};Q.braceExpand=tm,Q.makeRe=(t,e={})=>new tg(t,e).makeRe(),Q.match=(t,e,n={})=>{let r=new tg(e,n);return t=t.filter(t=>r.match(t)),r.options.nonull&&!t.length&&t.push(e),t};let ty=/[?*]|[+@!]\(.*?\)|\[|\]/;class tg{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,e={}){z(t),e=e||{},this.options=e,this.pattern=t,this.platform=e.platform||th,this.isWindows="win32"===this.platform,this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||!1===e.allowWindowsEscape,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!e.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!e.nonegate,this.comment=!1,this.empty=!1,this.partial=!!e.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=void 0!==e.windowsNoMagicRoot?e.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let e of t)if("string"!=typeof e)return!0;return!1}debug(){}make(){let t=this.pattern,e=this.options;if(!e.nocomment&&"#"===t.charAt(0)){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],e.debug&&(this.debug=(...t)=>console.error(...t)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(t=>this.slashSplit(t));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let r=this.globParts.map((t,e,n)=>{if(this.isWindows&&this.windowsNoMagicRoot){let e=""===t[0]&&""===t[1]&&("?"===t[2]||!ty.test(t[2]))&&!ty.test(t[3]),n=/^[a-z]:/i.test(t[0]);if(e)return[...t.slice(0,4),...t.slice(4).map(t=>this.parse(t))];if(n)return[t[0],...t.slice(1).map(t=>this.parse(t))]}return t.map(t=>this.parse(t))});if(this.debug(this.pattern,r),this.set=r.filter(t=>-1===t.indexOf(!1)),this.isWindows)for(let t=0;t<this.set.length;t++){let e=this.set[t];""===e[0]&&""===e[1]&&"?"===this.globParts[t][2]&&"string"==typeof e[3]&&/^[a-z]:$/i.test(e[3])&&(e[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let e=0;e<t.length;e++)for(let n=0;n<t[e].length;n++)"**"===t[e][n]&&(t[e][n]="*");let{optimizationLevel:e=1}=this.options;return e>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):t=e>=1?this.levelOneOptimize(t):this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(t=>{let e=-1;for(;-1!==(e=t.indexOf("**",e+1));){let n=e;for(;"**"===t[n+1];)n++;n!==e&&t.splice(e,n-e)}return t})}levelOneOptimize(t){return t.map(t=>0===(t=t.reduce((t,e)=>{let n=t[t.length-1];return"**"===e&&"**"===n||(".."===e&&n&&".."!==n&&"."!==n&&"**"!==n?t.pop():t.push(e)),t},[])).length?[""]:t)}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let e=!1;do{if(e=!1,!this.preserveMultipleSlashes){for(let n=1;n<t.length-1;n++){let r=t[n];(1!==n||""!==r||""!==t[0])&&("."===r||""===r)&&(e=!0,t.splice(n,1),n--)}"."===t[0]&&2===t.length&&("."===t[1]||""===t[1])&&(e=!0,t.pop())}let n=0;for(;-1!==(n=t.indexOf("..",n+1));){let r=t[n-1];r&&"."!==r&&".."!==r&&"**"!==r&&(e=!0,t.splice(n-1,2),n-=2)}}while(e);return 0===t.length?[""]:t}firstPhasePreProcess(t){let e=!1;do for(let n of(e=!1,t)){let r=-1;for(;-1!==(r=n.indexOf("**",r+1));){let i=r;for(;"**"===n[i+1];)i++;i>r&&n.splice(r+1,i-r);let o=n[r+1],s=n[r+2],a=n[r+3];if(".."!==o||!s||"."===s||".."===s||!a||"."===a||".."===a)continue;e=!0,n.splice(r,1);let l=n.slice(0);l[r]="**",t.push(l),r--}if(!this.preserveMultipleSlashes){for(let t=1;t<n.length-1;t++){let r=n[t];(1!==t||""!==r||""!==n[0])&&("."===r||""===r)&&(e=!0,n.splice(t,1),t--)}"."===n[0]&&2===n.length&&("."===n[1]||""===n[1])&&(e=!0,n.pop())}let i=0;for(;-1!==(i=n.indexOf("..",i+1));){let t=n[i-1];if(t&&"."!==t&&".."!==t&&"**"!==t){e=!0;let t=1===i&&"**"===n[i+1]?["."]:[];n.splice(i-1,2,...t),0===n.length&&n.push(""),i-=2}}}while(e);return t}secondPhasePreProcess(t){for(let e=0;e<t.length-1;e++)for(let n=e+1;n<t.length;n++){let r=this.partsMatch(t[e],t[n],!this.preserveMultipleSlashes);if(r){t[e]=[],t[n]=r;break}}return t.filter(t=>t.length)}partsMatch(t,e,n=!1){let r=0,i=0,o=[],s="";for(;r<t.length&&i<e.length;)if(t[r]===e[i])o.push("b"===s?e[i]:t[r]),r++,i++;else if(n&&"**"===t[r]&&e[i]===t[r+1])o.push(t[r]),r++;else if(n&&"**"===e[i]&&t[r]===e[i+1])o.push(e[i]),i++;else if("*"===t[r]&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&"**"!==e[i]){if("b"===s)return!1;s="a",o.push(t[r]),r++,i++}else{if("*"!==e[i]||!t[r]||!this.options.dot&&t[r].startsWith(".")||"**"===t[r]||"a"===s)return!1;s="b",o.push(e[i]),r++,i++}return t.length===e.length&&o}parseNegate(){if(this.nonegate)return;let t=this.pattern,e=!1,n=0;for(let r=0;r<t.length&&"!"===t.charAt(r);r++)e=!e,n++;n&&(this.pattern=t.slice(n)),this.negate=e}matchOne(t,e,n=!1){let r=this.options;if(this.isWindows){let n="string"==typeof t[0]&&/^[a-z]:$/i.test(t[0]),r=!n&&""===t[0]&&""===t[1]&&"?"===t[2]&&/^[a-z]:$/i.test(t[3]),i="string"==typeof e[0]&&/^[a-z]:$/i.test(e[0]),o=!i&&""===e[0]&&""===e[1]&&"?"===e[2]&&"string"==typeof e[3]&&/^[a-z]:$/i.test(e[3]),s=r?3:n?0:void 0,a=o?3:i?0:void 0;if("number"==typeof s&&"number"==typeof a){let[n,r]=[t[s],e[a]];n.toLowerCase()===r.toLowerCase()&&(e[a]=n,a>s?e=e.slice(a):s>a&&(t=t.slice(s)))}}let{optimizationLevel:i=1}=this.options;i>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:e}),this.debug("matchOne",t.length,e.length);for(var o=0,s=0,a=t.length,l=e.length;o<a&&s<l;o++,s++){let i;this.debug("matchOne loop");var u=e[s],c=t[o];if(this.debug(e,u,c),!1===u)return!1;if(u===tp){this.debug("GLOBSTAR",[e,u,c]);var f=o,h=s+1;if(h===l){for(this.debug("** at the end");o<a;o++)if("."===t[o]||".."===t[o]||!r.dot&&"."===t[o].charAt(0))return!1;return!0}for(;f<a;){var p=t[f];if(this.debug("\nglobstar while",t,f,e,h,p),this.matchOne(t.slice(f),e.slice(h),n))return this.debug("globstar found match!",f,a,p),!0;if("."===p||".."===p||!r.dot&&"."===p.charAt(0)){this.debug("dot detected!",t,f,e,h);break}this.debug("globstar swallow a segment, and continue"),f++}if(n&&(this.debug("\n>>> no match, partial?",t,f,e,h),f===a))return!0;return!1}if("string"==typeof u?(i=c===u,this.debug("string match",u,c,i)):(i=u.test(c),this.debug("pattern match",u,c,i)),!i)return!1}if(o===a&&s===l)return!0;if(o===a)return n;if(s===l)return o===a-1&&""===t[o];throw Error("wtf?")}braceExpand(){return tm(this.pattern,this.options)}parse(t){let e;z(t);let n=this.options;if("**"===t)return tp;if(""===t)return"";let r=null;(e=t.match(ts))?r=n.dot?tl:ta:(e=t.match(tt))?r=(n.nocase?n.dot?t=>(t=t.toLowerCase(),e=>e.toLowerCase().endsWith(t)):t=>(t=t.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(t)):n.dot?t=>e=>e.endsWith(t):t=>e=>!e.startsWith(".")&&e.endsWith(t))(e[1]):(e=t.match(tu))?r=(n.nocase?n.dot?([t,e=""])=>{let n=tf([t]);return e?(e=e.toLowerCase(),t=>n(t)&&t.toLowerCase().endsWith(e)):n}:([t,e=""])=>{let n=tc([t]);return e?(e=e.toLowerCase(),t=>n(t)&&t.toLowerCase().endsWith(e)):n}:n.dot?([t,e=""])=>{let n=tf([t]);return e?t=>n(t)&&t.endsWith(e):n}:([t,e=""])=>{let n=tc([t]);return e?t=>n(t)&&t.endsWith(e):n})(e):(e=t.match(te))?r=n.dot?tr:tn:(e=t.match(ti))&&(r=to);let i=q.fromGlob(t,this.options).toMMPattern();return r&&"object"==typeof i&&Reflect.defineProperty(i,"test",{value:r}),i}makeRe(){if(this.regexp||!1===this.regexp)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let e=this.options,n=e.noglobstar?"[^/]*?":e.dot?"(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?":"(?:(?!(?:\\/|^)\\.).)*?",r=new Set(e.nocase?["i"]:[]),i=t.map(t=>{let e=t.map(t=>{if(t instanceof RegExp)for(let e of t.flags.split(""))r.add(e);return"string"==typeof t?t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"):t===tp?tp:t._src});return e.forEach((t,r)=>{let i=e[r+1],o=e[r-1];t===tp&&o!==tp&&(void 0===o?void 0!==i&&i!==tp?e[r+1]="(?:\\/|"+n+"\\/)?"+i:e[r]=n:void 0===i?e[r-1]=o+"(?:\\/|"+n+")?":i!==tp&&(e[r-1]=o+"(?:\\/|\\/"+n+"\\/)"+i,e[r+1]=tp))}),e.filter(t=>t!==tp).join("/")}).join("|"),[o,s]=t.length>1?["(?:",")"]:["",""];i="^"+o+i+s+"$",this.negate&&(i="^(?!"+i+").+$");try{this.regexp=new RegExp(i,[...r].join(""))}catch(t){this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,e=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return""===t;if("/"===t&&e)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let r=this.slashSplit(t);this.debug(this.pattern,"split",r);let i=this.set;this.debug(this.pattern,"set",i);let o=r[r.length-1];if(!o)for(let t=r.length-2;!o&&t>=0;t--)o=r[t];for(let t=0;t<i.length;t++){let s=i[t],a=r;if(n.matchBase&&1===s.length&&(a=[o]),this.matchOne(a,s,e)){if(n.flipNegate)return!0;return!this.negate}}return!n.flipNegate&&this.negate}static defaults(t){return Q.defaults(t).Minimatch}}Q.AST=q,Q.Minimatch=tg,Q.escape=(t,{windowsPathsNoEscape:e=!1}={})=>e?t.replace(/[?*()[\]]/g,"[$&]"):t.replace(/[?*()[\]\\]/g,"\\$&"),Q.unescape=W;function tv(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var tb=function(){"use strict";var t;function e(t,n){var r=this,i=this;if(!(this instanceof e))throw TypeError("Cannot call a class as a function");tv(this,"handle",void 0),tv(this,"cwd",void 0),tv(this,"fs",void 0),tv(this,"path",void 0),tv(this,"promises",{cd:function(t){return new Promise(function(e){r.cd(t),e()})},cat:function(t){return new Promise(function(e,n){r.cat(t,function(t,r){t?n(t):e(r)})})},ls:function(t){return new Promise(function(e,n){r.ls(t,function(t,r){t?n(t):e(r)})})},exec:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return new Promise(function(n,r){i.exec(t,e,function(t,e){t?r(t):n(e)})})},touch:function(t){return new Promise(function(e,n){r.touch(t,function(t){t?n(t):e()})})},find:function(t,e){return new Promise(function(n,i){r.find(t,e,function(t,e){t?i(t):n(e)})})},rm:function(t,e){return new Promise(function(n,i){r.rm(t,e,function(t){t?i(t):n()})})},mkdirp:function(t){return new Promise(function(e,n){r.mkdirp(t,function(t){t?n(t):e()})})},tempDir:function(){return new Promise(function(t,e){r.tempDir(function(n,r){n?e(n):t(r)})})},format:function(){return new Promise(function(t,e){r.format(function(n){n?e(n):t()})})}}),t||(t=navigator.storage.getDirectory().then(function(t){return r.handle=t}).catch(function(){throw Error("Failed to get a handle. Try defining one?")})),this.handle=t,this.cwd="/",this.fs=n||new tA(this.handle),this.path=new h}return t=[{key:"cd",value:function(t){var e=this,n=this.path.join(this.cwd,t);this.fs.exists(n,function(t){if(t)e.cwd=n;else throw a("ENOENT","No such file or directory: ".concat(n))})}},{key:"pwd",value:function(){return this.cwd}},{key:"cat",value:function(t,e){var n=this,r=(Array.isArray(t)?t:[t]).map(function(t){return n.path.join(n.cwd,t)}),i=[],o=0;0===r.length?e(l("NotFoundError"),null):r.forEach(function(t,s){n.fs.readFile(t,"utf8",function(t,n){t?e(l(t),null):i[s]=n,++o===r.length&&e(null,i.join(""))})})}},{key:"ls",value:function(t,e){var n=this.path.join(this.cwd,t);this.fs.readdir(n,function(t,n){t?e(l(t),null):e(null,n)})}},{key:"exec",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2?arguments[2]:void 0,i=this.path.join(this.cwd,t);this.fs.readFile(i,"utf8",function(t,i){if(t||!i)return void r(l(t||"NotFoundError"),null);try{var o={fs:e.fs,args:n,callback:r};Function("fs","args","callback",i)(o.fs,o.args,o.callback)}catch(t){r(t,null)}})}},{key:"touch",value:function(t,e){var n=this.path.join(this.cwd,t);this.fs.writeFile(n,"","utf8",function(t){t?e(l(t)):e(null)})}},{key:"find",value:function(t,e,n){var r=this,i=this.path.join(this.cwd,t),o=[],s=0,a=!1,u=function(t){s++,r.fs.readdir(t,function(i,c){if(i){a||(a=!0,n(l(i),null));return}var f=c.length;if(!f){0!=--s||a||(a=!0,n(null,o));return}c.forEach(function(i){var c=r.path.join(t,i);r.fs.stat(c,function(t,r){if(t){a||(a=!0,n(l(t,c),null));return}Q(i,e.name)&&o.push(c),r&&"DIRECTORY"===r.type&&u(c),--f||0!=--s||a||(a=!0,n(null,o))})})})};u(i)}},{key:"rm",value:function(t,e,n){var r=this,i=this.path.join(this.cwd,t);e.recursive?this.fs.readdir(i,function(e,o){if(e)return void n(l(e));var s=o.length;if(!s)return void r.fs.rmdir(i,function(t){t?n(l(t)):n(null)});var a=!1;o.forEach(function(e){var o=r.path.join(i,e);r.fs.stat(o,function(u,c){if(!a){if(u){a=!0,n(l(u,o));return}c&&"DIRECTORY"===c.type?r.rm(r.path.join(t,e),{recursive:!0},function(t){if(!a){if(t){a=!0,n(t);return}--s||r.fs.rmdir(i,function(t){t?n(l(t)):n(null)})}}):r.fs.unlink(o,function(t){if(!a){if(t){a=!0,n(l(t,o));return}--s||r.fs.rmdir(i,function(t){t?n(l(t)):n(null)})}})}})})}):this.fs.unlink(i,function(t){t?n(l(t)):n(null)})}},{key:"mkdirp",value:function(t,e){this.fs.mkdir(t,e)}},{key:"tempDir",value:function(t){var e="temp-".concat(Date.now(),"-").concat(Math.floor(1e3*Math.random())),n=this.path.join(this.cwd,e);this.fs.mkdir(n,function(e){e?t(l(e,n)):t(null,n)})}},{key:"format",value:function(t){var e=this;this.fs.readdir("/",function(n,r){if(n)return void t(l(n));var i=!0,o=!1,s=void 0;try{for(var a,u=r[Symbol.iterator]();!(i=(a=u.next()).done);i=!0)!function(){var n=a.value;e.fs.stat(n,function(r,i){r?t(l(r,n)):i&&"DIRECTORY"===i.type?e.rm(n,{recursive:!0},function(e){if(e)return void t(l(e,n))}):e.fs.unlink(n,function(e){if(e)return void t(l(e,n))})})}()}catch(t){o=!0,s=t}finally{try{i||null==u.return||u.return()}finally{if(o)throw s}}console.log("[TFS] Operation Completed at: ".concat(new Date().toISOString())),t(null)})}}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(e.prototype,t),e}();function tw(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function tE(t,e,n,r,i,o,s){try{var a=t[o](s),l=a.value}catch(t){n(t);return}a.done?e(l):Promise.resolve(l).then(r,i)}function tO(t){return function(){var e=this,n=arguments;return new Promise(function(r,i){var o=t.apply(e,n);function s(t){tE(o,r,i,s,a,"next",t)}function a(t){tE(o,r,i,s,a,"throw",t)}s(void 0)})}}function tS(t,e){if(!(t instanceof e))throw TypeError("Cannot call a class as a function")}function tP(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function tk(t,e,n){return e&&tP(t.prototype,e),n&&tP(t,n),t}function tM(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function tx(t,e){return null!=e&&"undefined"!=typeof Symbol&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](t):t instanceof e}function tR(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n,r,i=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var o=[],s=!0,a=!1;try{for(i=i.call(t);!(s=(n=i.next()).done)&&(o.push(n.value),!e||o.length!==e);s=!0);}catch(t){a=!0,r=t}finally{try{s||null==i.return||i.return()}finally{if(a)throw r}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return tw(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if("Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return tw(t,e)}}(t,e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function tT(t,e){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(l){var u=[a,l];if(n)throw TypeError("Generator is already executing.");for(;s&&(s=0,u[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&u[0]?r.return:u[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,u[1])).done)return i;switch(r=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,r=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(i=(i=o.trys).length>0&&i[i.length-1])&&(6===u[0]||2===u[0])){o=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){o.label=u[1];break}if(6===u[0]&&o.label<i[1]){o.label=i[1],i=u;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(u);break}i[2]&&o.ops.pop(),o.trys.pop();continue}u=e.call(t,o)}catch(t){u=[6,t],r=0}finally{n=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var tA=function(){"use strict";function t(e){var n=this;tS(this,t),tM(this,"handle",void 0),tM(this,"currPath",void 0),tM(this,"shell",void 0),tM(this,"access",this.exists),tM(this,"promises",{writeFile:function(t,e,r){return new Promise(function(i,o){n.writeFile(t,e,r,function(t){t?o(t):i()})})},readFile:function(t,e){return new Promise(function(r,i){e||(e="utf8"),n.readFile(t,e,function(t,e){t?i(t):r(e)})})},mkdir:function(t){return new Promise(function(e,r){n.mkdir(t,function(t){t?r(t):e()})})},readdir:function(t){return new Promise(function(e,r){n.readdir(t,function(t,n){t?r(t):e(n)})})},stat:function(t){return new Promise(function(e,r){n.stat(t,function(t,n){t?r(t):e(n)})})},lstat:function(t){return new Promise(function(e,r){n.lstat(t,function(t,n){t?r(t):e(n)})})},appendFile:function(t,e){return new Promise(function(r,i){n.appendFile(t,e,function(t){t?i(t):r()})})},unlink:function(t){return new Promise(function(e,r){n.unlink(t,function(t){t?r(t):e()})})},exists:function(t){return new Promise(function(e){n.exists(t,function(t){e(t)})})},access:function(t){return new Promise(function(e){n.exists(t,function(t){e(t)})})},rmdir:function(t){return new Promise(function(e,r){n.rmdir(t,function(t){t?r(t):e()})})},rename:function(t,e){return new Promise(function(r,i){n.rename(t,e,function(t){t?i(t):r()})})},copyFile:function(t,e){return new Promise(function(r,i){n.copyFile(t,e,function(t){t?i(t):r()})})},symlink:function(t,e,r){return new Promise(function(i,o){n.symlink(t,e,r,function(t){t?o(t):i()})})},readlink:function(t){return new Promise(function(e,r){n.readlink(t,function(t,n){t?r(t):e(n)})})},cp:function(t,e){return new Promise(function(r,i){n.cp(t,e,function(t){t?i(t):r()})})}}),this.handle=e,this.currPath="/",this.shell=new tb(this.handle,this)}return tk(t,[{key:"normalizePath",value:function(t,e){if(e&&(this.currPath=e),!t)return this.currPath;t.startsWith("/")||(t=this.currPath+"/"+t);var n=t.split("/").filter(Boolean),r=[],i=!0,o=!1,s=void 0;try{for(var a,l=n[Symbol.iterator]();!(i=(a=l.next()).done);i=!0){var u=a.value;"."!==u&&""!==u&&(".."===u?r.length>0&&r.pop():r.push(u))}}catch(t){o=!0,s=t}finally{try{i||null==l.return||l.return()}finally{if(o)throw s}}var c="/"+r.join("/");return"//"===c&&(c="/"),c}},{key:"writeFile",value:function(t,e,n,r){var i,o=function(t){c=c.then(function(e){return e.getDirectoryHandle(u[t],{create:!0})})},s="utf8";"function"==typeof n?i=n:(s=n||"utf8",i=r);for(var a=this.normalizePath(t),u=a.split("/").filter(Boolean),c=Promise.resolve(this.handle),f=0;f<u.length-1;f++)o(f);var h=u[u.length-1];c.then(function(t){return t.getFileHandle(h,{create:!0})}).then(function(t){return t.createWritable()}).then(function(t){return tO(function(){var r,i,o,a,l;return tT(this,function(u){switch(u.label){case 0:if(!(!n||"function"==typeof n))return[3,1];return"string"==typeof e?(r=e,s="utf8"):tx(e,ArrayBuffer)?(r=e,s="arraybuffer"):tx(e,Uint8Array)?(r=e.buffer,s="arraybuffer"):tx(e,Blob)?(r=e,s="blob"):(r=String(e),s="utf8"),[3,23];case 1:switch(s){case"arraybuffer":return[3,2];case"blob":return[3,9];case"base64":return[3,10]}return[3,17];case 2:if("string"!=typeof e)return[3,3];return r=new TextEncoder().encode(e).buffer,[3,8];case 3:if(!tx(e,ArrayBuffer))return[3,4];return r=e,[3,8];case 4:if(!tx(e,Uint8Array))return[3,5];return r=e.buffer,[3,8];case 5:if(!tx(e,Blob))return[3,7];return[4,e.arrayBuffer()];case 6:return r=u.sent(),[3,8];case 7:r=new ArrayBuffer(0),u.label=8;case 8:return[3,23];case 9:return r=tx(e,Blob)?e:"string"==typeof e||tx(e,ArrayBuffer)||tx(e,Uint8Array)?new Blob([e]):new Blob([]),[3,23];case 10:if("string"!=typeof e)return[3,11];for(l=0,a=new Uint8Array(o=(i=atob(e)).length);l<o;l++)a[l]=i.charCodeAt(l);return r=a.buffer,[3,16];case 11:if(!tx(e,ArrayBuffer))return[3,12];return r=e,[3,16];case 12:if(!tx(e,Uint8Array))return[3,13];return r=e.buffer,[3,16];case 13:if(!tx(e,Blob))return[3,15];return[4,e.arrayBuffer()];case 14:return r=u.sent(),[3,16];case 15:r=new ArrayBuffer(0),u.label=16;case 16:return[3,23];case 17:if("string"!=typeof e)return[3,18];return r=e,[3,23];case 18:if(!tx(e,ArrayBuffer))return[3,19];return r=new TextDecoder().decode(e),[3,23];case 19:if(!tx(e,Uint8Array))return[3,20];return r=new TextDecoder().decode(e),[3,23];case 20:if(!tx(e,Blob))return[3,22];return[4,e.text()];case 21:return r=u.sent(),[3,23];case 22:r=String(e),u.label=23;case 23:return[4,t.write(r)];case 24:return u.sent(),[4,t.close()];case 25:return u.sent(),[2]}})})()}).then(function(){i&&i(null)}).catch(function(t){i&&i(l(t,a))})}},{key:"readFile",value:function(t,e,n){var r,i=function(t){u=u.then(function(e){return e.getDirectoryHandle(a[t])})},o=this,s="utf8";"string"==typeof e?(s=e,r=n):r=e;for(var a=this.normalizePath(t).split("/").filter(Boolean),u=Promise.resolve(this.handle),c=0;c<a.length-1;c++)i(c);var f=a[a.length-1];u.then(function(t){return t.getFileHandle(f)}).then(function(t){return t.getFile()}).then(function(t){t.text().then(function(e){var n=/^symlink:(.+?):(file|dir|junction)$/.exec(e);if(n){var i=n[1];"file"===n[2]?o.readFile(i,s,r):r(l(Error("TypeMismatchError"),t.name),null);return}if("arraybuffer"===s)t.arrayBuffer().then(function(t){return r(null,t)});else if("blob"===s)r(null,t);else if("base64"===s){var a=new FileReader;a.onload=function(){r(null,a.result)},a.readAsDataURL(t)}else r(null,e)}).catch(function(e){r(l(e,t.name),null)})}).catch(function(e){r(l(e,t),null)})}},{key:"mkdir",value:function(t,e){var n=this.normalizePath(t).split("/").filter(Boolean),r=Promise.resolve(this.handle),i=!0,o=!1,s=void 0;try{for(var a,u=n[Symbol.iterator]();!(i=(a=u.next()).done);i=!0)!function(){var t=a.value;r=r.then(function(e){return e.getDirectoryHandle(t,{create:!0})})}()}catch(t){o=!0,s=t}finally{try{i||null==u.return||u.return()}finally{if(o)throw s}}e&&r.then(function(){return e(null)}).catch(function(n){e(l(n,t))})}},{key:"readdir",value:function(t,e){var n=this.normalizePath(t).split("/").filter(Boolean),r=Promise.resolve(this.handle),i=!0,o=!1,s=void 0;try{for(var a,u=n[Symbol.iterator]();!(i=(a=u.next()).done);i=!0)!function(){var t=a.value;r=r.then(function(e){return e.getDirectoryHandle(t)})}()}catch(t){o=!0,s=t}finally{try{i||null==u.return||u.return()}finally{if(o)throw s}}r.then(function(n){var r=[],i=n.entries();!function n(){i.next().then(function(t){if(t.done)e(null,r);else{var i=tR(t.value,1)[0];r.push(i),n()}}).catch(function(n){e(l(n,t),null)})}()}).catch(function(n){e(l(n,t),null)})}},{key:"stat",value:function(t,e){var n=function(t){s=s.then(function(e){return e.getDirectoryHandle(o[t])})},r=this,i=this.normalizePath(t);if("/"===i)return void e(null,{name:"/",size:0,mime:"DIRECTORY",type:"DIRECTORY",ctime:0,mtime:0,atime:0,atimeMs:0,ctimeMs:0,mtimeMs:0,dev:"OPFS",isSymbolicLink:function(){return!1},isDirectory:function(){return!0},isFile:function(){return!1},uid:0,gid:0});for(var o=i.split("/").filter(Boolean),s=Promise.resolve(this.handle),a=0;a<o.length-1;a++)n(a);var u=o[o.length-1];s.then(function(n){return n.getFileHandle(u).then(function(t){return t.getFile().then(function(t){return t.text().then(function(n){var i=/^symlink:(.+?):(file|dir|junction)$/.exec(n);if(i){var o=i[1];r.stat(o,function(t,n){if(t)e(l(t,o),null);else{var r,i;n&&e(null,(r=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),r.forEach(function(e){tM(t,e,n[e])})}return t}({},n),i=i={dev:"OPFS",mime:"application/symlink",type:"symlink",isSymbolicLink:function(){return!0},isDirectory:function(){return"DIRECTORY"===n.type},isFile:function(){return"DIRECTORY"!==n.type}},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):(function(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n.push.apply(n,r)}return n})(Object(i)).forEach(function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(i,t))}),r))}})}else e(null,{name:t.name,size:t.size,mime:"DIRECTORY"===t.type?"DIRECTORY":"FILE",type:t.type,ctime:new Date(t.lastModified),mtime:new Date(t.lastModified),atime:new Date,ctimeMs:t.lastModified,mtimeMs:t.lastModified,atimeMs:new Date().getTime(),dev:"OPFS",isSymbolicLink:function(){return!1},isDirectory:function(){return"DIRECTORY"===t.type},isFile:function(){return"DIRECTORY"!==t.type},uid:0,gid:0})})})}).catch(function(r){r&&"NotFoundError"===r.name?n.getDirectoryHandle(u).then(function(){return e(null,{name:u,size:0,type:"DIRECTORY",mime:"DIRECTORY",ctime:0,mtime:0,atime:0,atimeMs:0,ctimeMs:0,mtimeMs:0,dev:"OPFS",isSymbolicLink:function(){return!1},isDirectory:function(){return!0},isFile:function(){return!1},uid:0,gid:0})}).catch(function(n){e(l(n,t),null)}):r&&"TypeMismatchError"===r.name?n.getDirectoryHandle(u).then(function(){return e(null,{name:u,size:0,type:"DIRECTORY",mime:"DIRECTORY",ctime:0,mtime:0,atime:0,ctimeMs:0,mtimeMs:0,atimeMs:0,dev:"OPFS",isSymbolicLink:function(){return!1},isDirectory:function(){return!0},isFile:function(){return!1},uid:0,gid:0})}).catch(function(n){e(l(n,t),null)}):e(l(r,t),null)})}).catch(function(n){e(l(n,t),null)})}},{key:"lstat",value:function(t,e){var n=function(t){o=o.then(function(e){return e.getDirectoryHandle(i[t])})},r=this.normalizePath(t);if("/"===r)return void e(null,{name:"/",size:0,type:"DIRECTORY",mime:"DIRECTORY",ctime:0,mtime:0,atime:0,atimeMs:0,ctimeMs:0,mtimeMs:0,dev:"OPFS",isSymbolicLink:function(){return!1},isDirectory:function(){return!0},isFile:function(){return!1},uid:0,gid:0});for(var i=r.split("/").filter(Boolean),o=Promise.resolve(this.handle),s=0;s<i.length-1;s++)n(s);var a=i[i.length-1];o.then(function(n){return n.getFileHandle(a).then(function(t){return t.getFile().then(function(t){return e(null,{name:t.name,size:t.size,type:t.type,mime:"DIRECTORY"===t.type?"DIRECTORY":"FILE",ctime:new Date(t.lastModified),mtime:new Date(t.lastModified),atime:new Date,ctimeMs:t.lastModified,mtimeMs:t.lastModified,atimeMs:new Date().getTime(),dev:"OPFS",isSymbolicLink:function(){return!1},isDirectory:function(){return"DIRECTORY"===t.type},isFile:function(){return"DIRECTORY"!==t.type},uid:0,gid:0})})}).catch(function(r){r&&"NotFoundError"===r.name?n.getDirectoryHandle(a).then(function(){return e(null,{name:a,size:0,type:"DIRECTORY",mime:"DIRECTORY",ctime:0,mtime:0,atime:0,ctimeMs:0,mtimeMs:0,atimeMs:0,dev:"OPFS",isSymbolicLink:function(){return!1},isDirectory:function(){return!0},isFile:function(){return!1},uid:0,gid:0})}).catch(function(n){e(l(n,t),null)}):r&&"TypeMismatchError"===r.name?n.getDirectoryHandle(a).then(function(){return e(null,{name:a,size:0,type:"DIRECTORY",mime:"DIRECTORY",ctime:0,mtime:0,atime:0,atimeMs:0,ctimeMs:0,mtimeMs:0,dev:"OPFS",isSymbolicLink:function(){return!1},isDirectory:function(){return!0},isFile:function(){return!1},uid:0,gid:0})}).catch(function(n){e(l(n,t),null)}):e(l(r,t),null)})}).catch(function(n){e(l(n,t),null)})}},{key:"appendFile",value:function(t,e,n){var r=this;this.readFile(t,"arraybuffer",function(i,o){if(i&&"NotFoundError"!==i.name)return void n(i);if(o){var s,a,u=new Uint8Array(o);if("string"==typeof e)a=new TextEncoder().encode(e);else if(tx(e,ArrayBuffer))a=new Uint8Array(e);else{if(!ArrayBuffer.isView(e))return void n(l("invalid data type"));a=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var c=new Uint8Array(u.length+a.length);c.set(u,0),c.set(a,u.length),s=c.buffer}else if("string"==typeof e)s=new TextEncoder().encode(e).buffer;else if(tx(e,ArrayBuffer))s=e;else{if(!ArrayBuffer.isView(e))return void n(l("invalid data type"));var f=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);s=tx(f,ArrayBuffer)?f:new ArrayBuffer(0)}r.writeFile(t,s,"arraybuffer",n)})}},{key:"watch",value:function(t,e,n){var r=this,i=this.normalizePath(t),o=!1,s=new Map,a=new(function(){function t(){tS(this,t),tM(this,"listeners",{})}return tk(t,[{key:"on",value:function(t,e){this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e)}},{key:"emit",value:function(t,e){if(this.listeners[t]){var n=!0,r=!1,i=void 0;try{for(var o,s=this.listeners[t][Symbol.iterator]();!(n=(o=s.next()).done);n=!0)(0,o.value)(t,e)}catch(t){r=!0,i=t}finally{try{n||null==s.return||s.return()}finally{if(r)throw i}}}}},{key:"removeAllListeners",value:function(){this.listeners={}}}]),t}());n&&(a.on("change",n),a.on("rename",n));var l=function(){return tO(function(){var t,n,r,l,u,c,f,h,p,d,m,y,g,v,b,w,E,O,S;return tT(this,function(P){switch(P.label){case 0:if(t=this,o)return[2];return n=new Map,r=function(i){return tO(function(){var t,o,s,a,l,u,c,f,h,p;return tT(this,function(d){switch(d.label){case 0:return[4,this.promises.readdir(i).catch(function(){return[]})];case 1:t=d.sent(),o=!0,s=!1,a=void 0,d.label=2;case 2:d.trys.push([2,8,9,10]),l=t[Symbol.iterator](),d.label=3;case 3:if(o=(u=l.next()).done)return[3,7];return c=u.value,f=this.normalizePath(i+"/"+c),[4,this.promises.stat(f).catch(function(){return null})];case 4:if(!(h=d.sent())||(n.set(f,{size:h.size,lastModified:h.mtimeMs,type:h.type}),!((null==e?void 0:e.recursive)&&"DIRECTORY"===h.type)))return[3,6];return[4,r(f)];case 5:d.sent(),d.label=6;case 6:return o=!0,[3,3];case 7:return[3,10];case 8:return p=d.sent(),s=!0,a=p,[3,10];case 9:try{o||null==l.return||l.return()}finally{if(s)throw a}return[7];case 10:return[2]}})}).call(t)},[4,this.promises.stat(i).catch(function(){return null})];case 1:if(!(l=P.sent())||(n.set(i,{size:l.size,lastModified:l.mtimeMs,type:l.type}),!((null==e?void 0:e.recursive)&&"DIRECTORY"===l.type)))return[3,3];return[4,r(i)];case 2:P.sent(),P.label=3;case 3:u=!0,c=!1,f=void 0;try{for(h=n[Symbol.iterator]();!(u=(p=h.next()).done);u=!0)m=(d=tR(p.value,2))[0],y=d[1],s.has(m)?(g=s.get(m),(y.size!==g.size||y.lastModified!==g.lastModified)&&a.emit("change",m)):a.emit("rename",m)}catch(t){c=!0,f=t}finally{try{u||null==h.return||h.return()}finally{if(c)throw f}}v=!0,b=!1,w=void 0;try{for(E=s.keys()[Symbol.iterator]();!(v=(O=E.next()).done);v=!0)S=O.value,n.has(S)||a.emit("rename",S)}catch(t){b=!0,w=t}finally{try{v||null==E.return||E.return()}finally{if(b)throw w}}return s=n,[2]}})}).call(r)},u=setInterval(l,500);return l(),{on:function(t,e){a.on(t,e)},close:function(){o=!0,clearInterval(u),a.removeAllListeners()}}}},{key:"unlink",value:function(t,e){for(var n=function(t){i=i.then(function(e){return e.getDirectoryHandle(r[t])})},r=this.normalizePath(t).split("/").filter(Boolean),i=Promise.resolve(this.handle),o=0;o<r.length-1;o++)n(o);var s=r[r.length-1];i.then(function(t){return t.removeEntry(s)}).then(function(){e&&e(null)}).catch(function(n){e&&e(l(n,t))})}},{key:"rmdir",value:function(t,e){for(var n=function(t){i=i.then(function(e){return e.getDirectoryHandle(r[t])})},r=this.normalizePath(t).split("/").filter(Boolean),i=Promise.resolve(this.handle),o=0;o<r.length-1;o++)n(o);var s=r[r.length-1];i.then(function(t){return t.removeEntry(s)}).then(function(){e&&e(null)}).catch(function(n){e&&e(l(n,t))})}},{key:"rename",value:function(t,e,n){var r=this,i=this.normalizePath(t),o=this.normalizePath(e);this.stat(i,function(e,s){if(e||!s){n&&n(l(e,i));return}if("DIRECTORY"!==s.type)return r.copyFile(i,o,function(e){e?n&&n(l(e,t)):(n&&n(null),r.unlink(i))});r.mkdir(o,function(e){e?n&&n(l(e,o)):r.readdir(i,function(e,s){e?n&&n(l(e,i)):Promise.all(s.map(function(t){return r.promises.rename(i+"/"+t,o+"/"+t)})).then(function(){return r.shell.promises.rm(i,{recursive:!0})}).then(function(){n&&n(null)}).catch(function(e){n&&n(l(e,t))})})})})}},{key:"exists",value:function(t,e){var n=this.normalizePath(t);this.stat(n,function(t,n){t?e&&e(!1):e&&e(!0)})}},{key:"symlink",value:function(t,e,n,r){this.writeFile(e,"symlink:".concat(t,":").concat(n||"file"),"utf8",function(t){t?r&&r(l(t,e)):r&&r(null)})}},{key:"readlink",value:function(t,e){for(var n=function(t){i=i.then(function(e){return e.getDirectoryHandle(r[t])})},r=this.normalizePath(t).split("/").filter(Boolean),i=Promise.resolve(this.handle),o=0;o<r.length-1;o++)n(o);var s=r[r.length-1];i.then(function(t){return t.getFileHandle(s)}).then(function(t){return t.getFile()}).then(function(t){t.text().then(function(t){var n=/^symlink:(.+?):(file|dir|junction)$/.exec(t);if(n){var r=n[1];e&&e(null,r)}})}).catch(function(n){e&&e(l(n,t),null)})}},{key:"copyFile",value:function(t,e,n){var r=this,i=this.normalizePath(t),o=this.normalizePath(e);this.readFile(i,"arraybuffer",function(t,e){t&&l(t,i),r.writeFile(o,e,"arraybuffer",n)})}},{key:"cp",value:function(t,e,n){var r=this;this.stat(t,function(i,o){if(i||!o){n&&n(l(i,t));return}"DIRECTORY"===o.type?r.mkdir(e,function(i){if(i){n&&n(l(i,e));return}r.readdir(t,function(i,o){if(i){n&&n(l