opfs-worker 0.5.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ "use strict";class E extends Error{constructor(t,e,n,i){super(t,{cause:i}),this.code=e,this.path=n,this.name="OPFSError"}}class Y extends E{constructor(t){super("OPFS is not supported in this browser","OPFS_NOT_SUPPORTED",void 0,t)}}class ht extends E{constructor(t){super("OPFS is not mounted","OPFS_NOT_MOUNTED",void 0,t)}}class lt extends E{constructor(t,e,n){super(t,"INVALID_PATH",e,n)}}class ut extends E{constructor(t,e){super(`File not found: ${t}`,"FILE_NOT_FOUND",t,e)}}class ft extends E{constructor(t,e){super(`Directory not found: ${t}`,"DIRECTORY_NOT_FOUND",t,e)}}class pt extends E{constructor(t,e,n){super(`Permission denied for ${e} on: ${t}`,"PERMISSION_DENIED",t,n)}}class dt extends E{constructor(t,e,n){super(t,"STORAGE_ERROR",e,n)}}class gt extends E{constructor(t,e,n){super(`Operation timed out: ${t}`,"TIMEOUT_ERROR",e,n)}}const J=(s,t,e)=>{const n=s instanceof RegExp?_(s,e):s,i=t instanceof RegExp?_(t,e):t,r=n!==null&&i!=null&&mt(n,i,e);return r&&{start:r[0],end:r[1],pre:e.slice(0,r[0]),body:e.slice(r[0]+n.length,r[1]),post:e.slice(r[1]+i.length)}},_=(s,t)=>{const e=t.match(s);return e?e[0]:null},mt=(s,t,e)=>{let n,i,r,o,a,h=e.indexOf(s),l=e.indexOf(t,h+1),c=h;if(h>=0&&l>0){if(s===t)return[h,l];for(n=[],r=e.length;c>=0&&!a;){if(c===h)n.push(c),h=e.indexOf(s,c+1);else if(n.length===1){const p=n.pop();p!==void 0&&(a=[p,l])}else i=n.pop(),i!==void 0&&i<r&&(r=i,o=l),l=e.indexOf(t,c+1);c=h<l&&h>=0?h:l}n.length&&o!==void 0&&(a=[r,o])}return a},V="\0SLASH"+Math.random()+"\0",K="\0OPEN"+Math.random()+"\0",j="\0CLOSE"+Math.random()+"\0",Q="\0COMMA"+Math.random()+"\0",tt="\0PERIOD"+Math.random()+"\0",yt=new RegExp(V,"g"),wt=new RegExp(K,"g"),Et=new RegExp(j,"g"),St=new RegExp(Q,"g"),xt=new RegExp(tt,"g"),bt=/\\\\/g,Ot=/\\{/g,Nt=/\\}/g,vt=/\\,/g,At=/\\./g;function I(s){return isNaN(s)?s.charCodeAt(0):parseInt(s,10)}function Pt(s){return s.replace(bt,V).replace(Ot,K).replace(Nt,j).replace(vt,Q).replace(At,tt)}function Tt(s){return s.replace(yt,"\\").replace(wt,"{").replace(Et,"}").replace(St,",").replace(xt,".")}function et(s){if(!s)return[""];const t=[],e=J("{","}",s);if(!e)return s.split(",");const{pre:n,body:i,post:r}=e,o=n.split(",");o[o.length-1]+="{"+i+"}";const a=et(r);return r.length&&(o[o.length-1]+=a.shift(),o.push.apply(o,a)),t.push.apply(t,o),t}function $t(s){return s?(s.slice(0,2)==="{}"&&(s="\\{\\}"+s.slice(2)),T(Pt(s),!0).map(Tt)):[]}function Mt(s){return"{"+s+"}"}function Rt(s){return/^-?0\d/.test(s)}function Ct(s,t){return s<=t}function Ft(s,t){return s>=t}function T(s,t){const e=[],n=J("{","}",s);if(!n)return[s];const i=n.pre,r=n.post.length?T(n.post,!1):[""];if(/\$$/.test(n.pre))for(let o=0;o<r.length;o++){const a=i+"{"+n.body+"}"+r[o];e.push(a)}else{const o=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body),a=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body),h=o||a,l=n.body.indexOf(",")>=0;if(!h&&!l)return n.post.match(/,(?!,).*\}/)?(s=n.pre+"{"+n.body+j+n.post,T(s)):[s];let c;if(h)c=n.body.split(/\.\./);else if(c=et(n.body),c.length===1&&c[0]!==void 0&&(c=T(c[0],!1).map(Mt),c.length===1))return r.map(f=>n.pre+c[0]+f);let p;if(h&&c[0]!==void 0&&c[1]!==void 0){const f=I(c[0]),u=I(c[1]),g=Math.max(c[0].length,c[1].length);let d=c.length===3&&c[2]!==void 0?Math.abs(I(c[2])):1,S=Ct;u<f&&(d*=-1,S=Ft);const v=c.some(Rt);p=[];for(let x=f;S(x,u);x+=d){let m;if(a)m=String.fromCharCode(x),m==="\\"&&(m="");else if(m=String(x),v){const A=g-m.length;if(A>0){const M=new Array(A+1).join("0");x<0?m="-"+M+m.slice(1):m=M+m}}p.push(m)}}else{p=[];for(let f=0;f<c.length;f++)p.push.apply(p,T(c[f],!1))}for(let f=0;f<p.length;f++)for(let u=0;u<r.length;u++){const g=i+p[f]+r[u];(!t||h||g)&&e.push(g)}}return e}const Dt=1024*64,C=s=>{if(typeof s!="string")throw new TypeError("invalid pattern");if(s.length>Dt)throw new TypeError("pattern is too long")},Lt={"[: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]},P=s=>s.replace(/[[\]\\-]/g,"\\$&"),It=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),B=s=>s.join(""),jt=(s,t)=>{const e=t;if(s.charAt(e)!=="[")throw new Error("not in a brace expression");const n=[],i=[];let r=e+1,o=!1,a=!1,h=!1,l=!1,c=e,p="";t:for(;r<s.length;){const d=s.charAt(r);if((d==="!"||d==="^")&&r===e+1){l=!0,r++;continue}if(d==="]"&&o&&!h){c=r+1;break}if(o=!0,d==="\\"&&!h){h=!0,r++;continue}if(d==="["&&!h){for(const[S,[N,v,x]]of Object.entries(Lt))if(s.startsWith(S,r)){if(p)return["$.",!1,s.length-e,!0];r+=S.length,x?i.push(N):n.push(N),a=a||v;continue t}}if(h=!1,p){d>p?n.push(P(p)+"-"+P(d)):d===p&&n.push(P(d)),p="",r++;continue}if(s.startsWith("-]",r+1)){n.push(P(d+"-")),r+=2;continue}if(s.startsWith("-",r+1)){p=d,r+=2;continue}n.push(P(d)),r++}if(c<r)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,s.length-e,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!l){const d=n[0].length===2?n[0].slice(-1):n[0];return[It(d),!1,c-e,!1]}const f="["+(l?"^":"")+B(n)+"]",u="["+(l?"":"^")+B(i)+"]";return[n.length&&i.length?"("+f+"|"+u+")":n.length?f:u,a,c-e,!0]},$=(s,{windowsPathsNoEscape:t=!1}={})=>t?s.replace(/\[([^\/\\])\]/g,"$1"):s.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"),Ut=new Set(["!","?","+","*","@"]),q=s=>Ut.has(s),kt="(?!(?:^|/)\\.\\.?(?:$|/))",R="(?!\\.)",Wt=new Set(["[","."]),zt=new Set(["..","."]),_t=new Set("().*{}+?[]^$\\!"),Bt=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),U="[^/]",G=U+"*?",H=U+"+?";class w{type;#s;#n;#r=!1;#t=[];#e;#o;#a;#c=!1;#i;#h;#u=!1;constructor(t,e,n={}){this.type=t,t&&(this.#n=!0),this.#e=e,this.#s=this.#e?this.#e.#s:this,this.#i=this.#s===this?n:this.#s.#i,this.#a=this.#s===this?[]:this.#s.#a,t==="!"&&!this.#s.#c&&this.#a.push(this),this.#o=this.#e?this.#e.#t.length:0}get hasMagic(){if(this.#n!==void 0)return this.#n;for(const t of this.#t)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#n=!0;return this.#n}toString(){return this.#h!==void 0?this.#h:this.type?this.#h=this.type+"("+this.#t.map(t=>String(t)).join("|")+")":this.#h=this.#t.map(t=>String(t)).join("")}#p(){if(this!==this.#s)throw new Error("should only call on root");if(this.#c)return this;this.toString(),this.#c=!0;let t;for(;t=this.#a.pop();){if(t.type!=="!")continue;let e=t,n=e.#e;for(;n;){for(let i=e.#o+1;!n.type&&i<n.#t.length;i++)for(const r of t.#t){if(typeof r=="string")throw new Error("string part in extglob AST??");r.copyIn(n.#t[i])}e=n,n=e.#e}}return this}push(...t){for(const e of t)if(e!==""){if(typeof e!="string"&&!(e instanceof w&&e.#e===this))throw new Error("invalid part: "+e);this.#t.push(e)}}toJSON(){const t=this.type===null?this.#t.slice().map(e=>typeof e=="string"?e:e.toJSON()):[this.type,...this.#t.map(e=>e.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#s||this.#s.#c&&this.#e?.type==="!")&&t.push({}),t}isStart(){if(this.#s===this)return!0;if(!this.#e?.isStart())return!1;if(this.#o===0)return!0;const t=this.#e;for(let e=0;e<this.#o;e++){const n=t.#t[e];if(!(n instanceof w&&n.type==="!"))return!1}return!0}isEnd(){if(this.#s===this||this.#e?.type==="!")return!0;if(!this.#e?.isEnd())return!1;if(!this.type)return this.#e?.isEnd();const t=this.#e?this.#e.#t.length:0;return this.#o===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){const e=new w(this.type,t);for(const n of this.#t)e.copyIn(n);return e}static#l(t,e,n,i){let r=!1,o=!1,a=-1,h=!1;if(e.type===null){let u=n,g="";for(;u<t.length;){const d=t.charAt(u++);if(r||d==="\\"){r=!r,g+=d;continue}if(o){u===a+1?(d==="^"||d==="!")&&(h=!0):d==="]"&&!(u===a+2&&h)&&(o=!1),g+=d;continue}else if(d==="["){o=!0,a=u,h=!1,g+=d;continue}if(!i.noext&&q(d)&&t.charAt(u)==="("){e.push(g),g="";const S=new w(d,e);u=w.#l(t,S,u,i),e.push(S);continue}g+=d}return e.push(g),u}let l=n+1,c=new w(null,e);const p=[];let f="";for(;l<t.length;){const u=t.charAt(l++);if(r||u==="\\"){r=!r,f+=u;continue}if(o){l===a+1?(u==="^"||u==="!")&&(h=!0):u==="]"&&!(l===a+2&&h)&&(o=!1),f+=u;continue}else if(u==="["){o=!0,a=l,h=!1,f+=u;continue}if(q(u)&&t.charAt(l)==="("){c.push(f),f="";const g=new w(u,c);c.push(g),l=w.#l(t,g,l,i);continue}if(u==="|"){c.push(f),f="",p.push(c),c=new w(null,e);continue}if(u===")")return f===""&&e.#t.length===0&&(e.#u=!0),c.push(f),f="",e.push(...p,c),l;f+=u}return e.type=null,e.#n=void 0,e.#t=[t.substring(n-1)],l}static fromGlob(t,e={}){const n=new w(null,void 0,e);return w.#l(t,n,0,e),n}toMMPattern(){if(this!==this.#s)return this.#s.toMMPattern();const t=this.toString(),[e,n,i,r]=this.toRegExpSource();if(!(i||this.#n||this.#i.nocase&&!this.#i.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;const a=(this.#i.nocase?"i":"")+(r?"u":"");return Object.assign(new RegExp(`^${e}$`,a),{_src:e,_glob:t})}get options(){return this.#i}toRegExpSource(t){const e=t??!!this.#i.dot;if(this.#s===this&&this.#p(),!this.type){const h=this.isStart()&&this.isEnd(),l=this.#t.map(u=>{const[g,d,S,N]=typeof u=="string"?w.#d(u,this.#n,h):u.toRegExpSource(t);return this.#n=this.#n||S,this.#r=this.#r||N,g}).join("");let c="";if(this.isStart()&&typeof this.#t[0]=="string"&&!(this.#t.length===1&&zt.has(this.#t[0]))){const g=Wt,d=e&&g.has(l.charAt(0))||l.startsWith("\\.")&&g.has(l.charAt(2))||l.startsWith("\\.\\.")&&g.has(l.charAt(4)),S=!e&&!t&&g.has(l.charAt(0));c=d?kt:S?R:""}let p="";return this.isEnd()&&this.#s.#c&&this.#e?.type==="!"&&(p="(?:$|\\/)"),[c+l+p,$(l),this.#n=!!this.#n,this.#r]}const n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:";let r=this.#f(e);if(this.isStart()&&this.isEnd()&&!r&&this.type!=="!"){const h=this.toString();return this.#t=[h],this.type=null,this.#n=void 0,[h,$(this.toString()),!1,!1]}let o=!n||t||e||!R?"":this.#f(!0);o===r&&(o=""),o&&(r=`(?:${r})(?:${o})*?`);let a="";if(this.type==="!"&&this.#u)a=(this.isStart()&&!e?R:"")+H;else{const h=this.type==="!"?"))"+(this.isStart()&&!e&&!t?R:"")+G+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;a=i+r+h}return[a,$(r),this.#n=!!this.#n,this.#r]}#f(t){return this.#t.map(e=>{if(typeof e=="string")throw new Error("string type in extglob ast??");const[n,i,r,o]=e.toRegExpSource(t);return this.#r=this.#r||o,n}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join("|")}static#d(t,e,n=!1){let i=!1,r="",o=!1;for(let a=0;a<t.length;a++){const h=t.charAt(a);if(i){i=!1,r+=(_t.has(h)?"\\":"")+h;continue}if(h==="\\"){a===t.length-1?r+="\\\\":i=!0;continue}if(h==="["){const[l,c,p,f]=jt(t,a);if(p){r+=l,o=o||c,a+=p-1,e=e||f;continue}}if(h==="*"){n&&t==="*"?r+=H:r+=G,e=!0;continue}if(h==="?"){r+=U,e=!0;continue}r+=Bt(h)}return[r,$(t),!!e,o]}}const qt=(s,{windowsPathsNoEscape:t=!1}={})=>t?s.replace(/[?*()[\]]/g,"[$&]"):s.replace(/[?*()[\]\\]/g,"\\$&"),y=(s,t,e={})=>(C(t),!e.nocomment&&t.charAt(0)==="#"?!1:new F(t,e).match(s)),Gt=/^\*+([^+@!?\*\[\(]*)$/,Ht=s=>t=>!t.startsWith(".")&&t.endsWith(s),Zt=s=>t=>t.endsWith(s),Xt=s=>(s=s.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(s)),Yt=s=>(s=s.toLowerCase(),t=>t.toLowerCase().endsWith(s)),Jt=/^\*+\.\*+$/,Vt=s=>!s.startsWith(".")&&s.includes("."),Kt=s=>s!=="."&&s!==".."&&s.includes("."),Qt=/^\.\*+$/,te=s=>s!=="."&&s!==".."&&s.startsWith("."),ee=/^\*+$/,se=s=>s.length!==0&&!s.startsWith("."),ne=s=>s.length!==0&&s!=="."&&s!=="..",ie=/^\?+([^+@!?\*\[\(]*)?$/,re=([s,t=""])=>{const e=st([s]);return t?(t=t.toLowerCase(),n=>e(n)&&n.toLowerCase().endsWith(t)):e},oe=([s,t=""])=>{const e=nt([s]);return t?(t=t.toLowerCase(),n=>e(n)&&n.toLowerCase().endsWith(t)):e},ce=([s,t=""])=>{const e=nt([s]);return t?n=>e(n)&&n.endsWith(t):e},ae=([s,t=""])=>{const e=st([s]);return t?n=>e(n)&&n.endsWith(t):e},st=([s])=>{const t=s.length;return e=>e.length===t&&!e.startsWith(".")},nt=([s])=>{const t=s.length;return e=>e.length===t&&e!=="."&&e!==".."},it=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Z={win32:{sep:"\\"},posix:{sep:"/"}},he=it==="win32"?Z.win32.sep:Z.posix.sep;y.sep=he;const O=Symbol("globstar **");y.GLOBSTAR=O;const le="[^/]",ue=le+"*?",fe="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",pe="(?:(?!(?:\\/|^)\\.).)*?",de=(s,t={})=>e=>y(e,s,t);y.filter=de;const b=(s,t={})=>Object.assign({},s,t),ge=s=>{if(!s||typeof s!="object"||!Object.keys(s).length)return y;const t=y;return Object.assign((n,i,r={})=>t(n,i,b(s,r)),{Minimatch:class extends t.Minimatch{constructor(i,r={}){super(i,b(s,r))}static defaults(i){return t.defaults(b(s,i)).Minimatch}},AST:class extends t.AST{constructor(i,r,o={}){super(i,r,b(s,o))}static fromGlob(i,r={}){return t.AST.fromGlob(i,b(s,r))}},unescape:(n,i={})=>t.unescape(n,b(s,i)),escape:(n,i={})=>t.escape(n,b(s,i)),filter:(n,i={})=>t.filter(n,b(s,i)),defaults:n=>t.defaults(b(s,n)),makeRe:(n,i={})=>t.makeRe(n,b(s,i)),braceExpand:(n,i={})=>t.braceExpand(n,b(s,i)),match:(n,i,r={})=>t.match(n,i,b(s,r)),sep:t.sep,GLOBSTAR:O})};y.defaults=ge;const rt=(s,t={})=>(C(s),t.nobrace||!/\{(?:(?!\{).)*\}/.test(s)?[s]:$t(s));y.braceExpand=rt;const me=(s,t={})=>new F(s,t).makeRe();y.makeRe=me;const ye=(s,t,e={})=>{const n=new F(t,e);return s=s.filter(i=>n.match(i)),n.options.nonull&&!s.length&&s.push(t),s};y.match=ye;const X=/[?*]|[+@!]\(.*?\)|\[|\]/,we=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class F{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,e={}){C(t),e=e||{},this.options=e,this.pattern=t,this.platform=e.platform||it,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||e.allowWindowsEscape===!1,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=e.windowsNoMagicRoot!==void 0?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(const t of this.set)for(const e of t)if(typeof e!="string")return!0;return!1}debug(...t){}make(){const 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=(...r)=>console.error(...r)),this.debug(this.pattern,this.globSet);const n=this.globSet.map(r=>this.slashSplit(r));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((r,o,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){const h=r[0]===""&&r[1]===""&&(r[2]==="?"||!X.test(r[2]))&&!X.test(r[3]),l=/^[a-z]:/i.test(r[0]);if(h)return[...r.slice(0,4),...r.slice(4).map(c=>this.parse(c))];if(l)return[r[0],...r.slice(1).map(c=>this.parse(c))]}return r.map(h=>this.parse(h))});if(this.debug(this.pattern,i),this.set=i.filter(r=>r.indexOf(!1)===-1),this.isWindows)for(let r=0;r<this.set.length;r++){const o=this.set[r];o[0]===""&&o[1]===""&&this.globParts[r][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n=0;n<t.length;n++)for(let i=0;i<t[n].length;i++)t[n][i]==="**"&&(t[n][i]="*");const{optimizationLevel:e=1}=this.options;return e>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):e>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(e=>{let n=-1;for(;(n=e.indexOf("**",n+1))!==-1;){let i=n;for(;e[i+1]==="**";)i++;i!==n&&e.splice(n,i-n)}return e})}levelOneOptimize(t){return t.map(e=>(e=e.reduce((n,i)=>{const r=n[n.length-1];return i==="**"&&r==="**"?n:i===".."&&r&&r!==".."&&r!=="."&&r!=="**"?(n.pop(),n):(n.push(i),n)},[]),e.length===0?[""]:e))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let e=!1;do{if(e=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){const r=t[i];i===1&&r===""&&t[0]===""||(r==="."||r==="")&&(e=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(e=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){const i=t[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&(e=!0,t.splice(n-1,2),n-=2)}}while(e);return t.length===0?[""]:t}firstPhasePreProcess(t){let e=!1;do{e=!1;for(let n of t){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let o=i;for(;n[o+1]==="**";)o++;o>i&&n.splice(i+1,o-i);let a=n[i+1];const h=n[i+2],l=n[i+3];if(a!==".."||!h||h==="."||h===".."||!l||l==="."||l==="..")continue;e=!0,n.splice(i,1);const c=n.slice(0);c[i]="**",t.push(c),i--}if(!this.preserveMultipleSlashes){for(let o=1;o<n.length-1;o++){const a=n[o];o===1&&a===""&&n[0]===""||(a==="."||a==="")&&(e=!0,n.splice(o,1),o--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(e=!0,n.pop())}let r=0;for(;(r=n.indexOf("..",r+1))!==-1;){const o=n[r-1];if(o&&o!=="."&&o!==".."&&o!=="**"){e=!0;const h=r===1&&n[r+1]==="**"?["."]:[];n.splice(r-1,2,...h),n.length===0&&n.push(""),r-=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++){const i=this.partsMatch(t[e],t[n],!this.preserveMultipleSlashes);if(i){t[e]=[],t[n]=i;break}}return t.filter(e=>e.length)}partsMatch(t,e,n=!1){let i=0,r=0,o=[],a="";for(;i<t.length&&r<e.length;)if(t[i]===e[r])o.push(a==="b"?e[r]:t[i]),i++,r++;else if(n&&t[i]==="**"&&e[r]===t[i+1])o.push(t[i]),i++;else if(n&&e[r]==="**"&&t[i]===e[r+1])o.push(e[r]),r++;else if(t[i]==="*"&&e[r]&&(this.options.dot||!e[r].startsWith("."))&&e[r]!=="**"){if(a==="b")return!1;a="a",o.push(t[i]),i++,r++}else if(e[r]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(a==="a")return!1;a="b",o.push(e[r]),i++,r++}else return!1;return t.length===e.length&&o}parseNegate(){if(this.nonegate)return;const t=this.pattern;let e=!1,n=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)e=!e,n++;n&&(this.pattern=t.slice(n)),this.negate=e}matchOne(t,e,n=!1){const i=this.options;if(this.isWindows){const d=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),S=!d&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),N=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),v=!N&&e[0]===""&&e[1]===""&&e[2]==="?"&&typeof e[3]=="string"&&/^[a-z]:$/i.test(e[3]),x=S?3:d?0:void 0,m=v?3:N?0:void 0;if(typeof x=="number"&&typeof m=="number"){const[A,M]=[t[x],e[m]];A.toLowerCase()===M.toLowerCase()&&(e[m]=A,m>x?e=e.slice(m):x>m&&(t=t.slice(x)))}}const{optimizationLevel:r=1}=this.options;r>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:e}),this.debug("matchOne",t.length,e.length);for(var o=0,a=0,h=t.length,l=e.length;o<h&&a<l;o++,a++){this.debug("matchOne loop");var c=e[a],p=t[o];if(this.debug(e,c,p),c===!1)return!1;if(c===O){this.debug("GLOBSTAR",[e,c,p]);var f=o,u=a+1;if(u===l){for(this.debug("** at the end");o<h;o++)if(t[o]==="."||t[o]===".."||!i.dot&&t[o].charAt(0)===".")return!1;return!0}for(;f<h;){var g=t[f];if(this.debug(`
2
+ globstar while`,t,f,e,u,g),this.matchOne(t.slice(f),e.slice(u),n))return this.debug("globstar found match!",f,h,g),!0;if(g==="."||g===".."||!i.dot&&g.charAt(0)==="."){this.debug("dot detected!",t,f,e,u);break}this.debug("globstar swallow a segment, and continue"),f++}return!!(n&&(this.debug(`
3
+ >>> no match, partial?`,t,f,e,u),f===h))}let d;if(typeof c=="string"?(d=p===c,this.debug("string match",c,p,d)):(d=c.test(p),this.debug("pattern match",c,p,d)),!d)return!1}if(o===h&&a===l)return!0;if(o===h)return n;if(a===l)return o===h-1&&t[o]==="";throw new Error("wtf?")}braceExpand(){return rt(this.pattern,this.options)}parse(t){C(t);const e=this.options;if(t==="**")return O;if(t==="")return"";let n,i=null;(n=t.match(ee))?i=e.dot?ne:se:(n=t.match(Gt))?i=(e.nocase?e.dot?Yt:Xt:e.dot?Zt:Ht)(n[1]):(n=t.match(ie))?i=(e.nocase?e.dot?oe:re:e.dot?ce:ae)(n):(n=t.match(Jt))?i=e.dot?Kt:Vt:(n=t.match(Qt))&&(i=te);const r=w.fromGlob(t,this.options).toMMPattern();return i&&typeof r=="object"&&Reflect.defineProperty(r,"test",{value:i}),r}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;const t=this.set;if(!t.length)return this.regexp=!1,this.regexp;const e=this.options,n=e.noglobstar?ue:e.dot?fe:pe,i=new Set(e.nocase?["i"]:[]);let r=t.map(h=>{const l=h.map(c=>{if(c instanceof RegExp)for(const p of c.flags.split(""))i.add(p);return typeof c=="string"?we(c):c===O?O:c._src});return l.forEach((c,p)=>{const f=l[p+1],u=l[p-1];c!==O||u===O||(u===void 0?f!==void 0&&f!==O?l[p+1]="(?:\\/|"+n+"\\/)?"+f:l[p]=n:f===void 0?l[p-1]=u+"(?:\\/|"+n+")?":f!==O&&(l[p-1]=u+"(?:\\/|\\/"+n+"\\/)"+f,l[p+1]=O))}),l.filter(c=>c!==O).join("/")}).join("|");const[o,a]=t.length>1?["(?:",")"]:["",""];r="^"+o+r+a+"$",this.negate&&(r="^(?!"+r+").+$");try{this.regexp=new RegExp(r,[...i].join(""))}catch{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;const n=this.options;this.isWindows&&(t=t.split("\\").join("/"));const i=this.slashSplit(t);this.debug(this.pattern,"split",i);const r=this.set;this.debug(this.pattern,"set",r);let o=i[i.length-1];if(!o)for(let a=i.length-2;!o&&a>=0;a--)o=i[a];for(let a=0;a<r.length;a++){const h=r[a];let l=i;if(n.matchBase&&h.length===1&&(l=[o]),this.matchOne(l,h,e))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return y.defaults(t).Minimatch}}y.AST=w;y.Minimatch=F;y.escape=qt;y.unescape=$;function ot(s,t="utf-8"){switch(t){case"utf8":case"utf-8":return new TextEncoder().encode(s);case"utf16le":case"ucs2":case"ucs-2":return Se(s);case"ascii":return Oe(s);case"latin1":return be(s);case"binary":return Uint8Array.from(s,e=>e.charCodeAt(0));case"base64":return Uint8Array.from(atob(s),e=>e.charCodeAt(0));case"hex":if(!/^[\da-f]+$/i.test(s)||s.length%2!==0)throw new E("Invalid hex string","INVALID_HEX_FORMAT");return Uint8Array.from(s.match(/.{1,2}/g).map(e=>parseInt(e,16)));default:return console.warn("Encoding not supported, falling back to UTF-8"),new TextEncoder().encode(s)}}function Ee(s,t="utf-8"){switch(t){case"utf8":case"utf-8":return new TextDecoder().decode(s);case"utf16le":case"utf-16le":case"ucs2":case"ucs-2":return xe(s);case"latin1":return String.fromCharCode(...s);case"ascii":return String.fromCharCode(...s.map(e=>e&127));case"base64":return btoa(String.fromCharCode(...s));case"hex":return Array.from(s).map(e=>e.toString(16).padStart(2,"0")).join("");default:return console.warn("Unsupported encoding, falling back to UTF-8"),new TextDecoder().decode(s)}}function Se(s){const t=new Uint8Array(s.length*2);for(let e=0;e<s.length;e++){const n=s.charCodeAt(e);t[e*2]=n&255,t[e*2+1]=n>>8}return t}function xe(s){s.length%2!==0&&(console.warn("Invalid UTF-16LE buffer length, truncating last byte"),s=s.slice(0,s.length-1));const t=new Uint16Array(s.buffer,s.byteOffset,s.byteLength/2);return String.fromCharCode(...t)}function be(s){const t=new Uint8Array(s.length);for(let e=0;e<s.length;e++)t[e]=s.charCodeAt(e)&255;return t}function Oe(s){const t=new Uint8Array(s.length);for(let e=0;e<s.length;e++)t[e]=s.charCodeAt(e)&127;return t}const ct=[".jpg",".jpeg",".png",".gif",".bmp",".webp",".svg",".ico",".tiff",".tga",".mp3",".wav",".ogg",".flac",".aac",".wma",".m4a",".mp4",".avi",".mov",".wmv",".flv",".webm",".mkv",".m4v",".pdf",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".zip",".rar",".7z",".tar",".gz",".bz2",".exe",".dll",".so",".dylib",".bin",".dat",".db",".sqlite",".bin",".obj",".fbx",".3ds"];function Ne(s){const t=s.toLowerCase().substring(s.lastIndexOf("."));return ct.includes(t)}function ve(){if(!("storage"in navigator)||!("getDirectory"in navigator.storage))throw new Y}async function D(s,t,e){return typeof navigator<"u"&&navigator.locks?.request?navigator.locks.request(`opfs:${s.replace(/\/+/g,"/").toLowerCase()}`,{mode:t},e):e()}function L(s){return Array.isArray(s)?s:(s.startsWith("~/")?s.slice(2):s).split("/").filter(Boolean)}function k(s){return typeof s=="string"?s??"/":`/${s.join("/")}`}function W(s){const t=L(s);return t[t.length-1]||""}function Ae(s){const t=L(s);return t.pop(),k(t)}function z(s){return!s||s==="/"?"/":s.startsWith("~/")?`/${s.slice(2)}`:s.startsWith("/")?s:`/${s}`}function Pe(s,t=!1){return s=s.replace(/\/$/,""),t&&!s.includes("*")?`${s}/**`:s}function Te(s,t){return y(s,t,{dot:!0,matchBase:!0})}function $e(s,t){if(!t||Array.isArray(t)&&t.length===0)return!1;const e=z(s);return(Array.isArray(t)?t:[t]).some(i=>y(e,i,{dot:!0}))}function Me(s){const t=z(s),e=L(t),n=[];for(const i of e)if(!(i==="."||i===""))if(i===".."){if(n.length===0)continue;n.pop()}else n.push(i);return k(n)}function Re(s){const t=W(s),e=t.lastIndexOf(".");return e<=0||e===t.length-1?"":t.slice(e)}function at(s,t="utf-8"){return typeof s=="string"?ot(s,t):s instanceof Uint8Array?s:new Uint8Array(s)}async function Ce(s,t){return D(t,"shared",async()=>{const n=await(await s.getFile()).arrayBuffer();return new Uint8Array(n)})}async function Fe(s,t,e,n,i={}){const r=async()=>{let o=null;const a=i.append||!1,h=!a&&(i.truncate??!0);try{o=await s.createSyncAccessHandle();const l=at(t,e),c=a?o.getSize():0;o.write(l,{at:c}),h&&o.truncate(l.byteLength),o.flush()}catch(l){console.error(l);const c=a?"append":"write";throw new E(`Failed to ${c} file`,`${c.toUpperCase()}_FAILED`,void 0,l)}finally{try{o?.close()}catch{}}};return n?D(n,"exclusive",r):r()}async function De(s,t="SHA-1",e=50*1024*1024){if(s instanceof File&&(s=await s.arrayBuffer()),s.byteLength>e)throw new Error(`File size ${s.byteLength} bytes exceeds maximum allowed size ${e} bytes`);const n=new Uint8Array(s),i=await crypto.subtle.digest(t,n);return Array.from(new Uint8Array(i)).map(o=>o.toString(16).padStart(2,"0")).join("")}function Le(s,t){if(s.length!==t.length)return!1;for(let e=0;e<s.length;e++)if(s[e]!==t[e])return!1;return!0}async function Ie(s){const t=await s.arrayBuffer();return new Uint8Array(t)}async function je(s,t,e={}){const n=W(t);return D(t,"exclusive",async()=>{const i=e.recursive??!1,r=e.force??!1;e.useTrash;try{await s.removeEntry(n,{recursive:i})}catch(o){if(o.name==="NotFoundError"){if(!r)throw new E(`No such file or directory: ${t}`,"ENOENT",void 0,o)}else throw o.name==="InvalidModificationError"?new E(`Directory not empty: ${t}. Use recursive option to force removal.`,"ENOTEMPTY",void 0,o):o.name==="TypeMismatchError"&&!i?new E(`Cannot remove directory without recursive option: ${t}`,"EISDIR",void 0,o):new E(`Failed to remove entry: ${t}`,"RM_FAILED",void 0,o)}})}exports.BINARY_FILE_EXTENSIONS=ct;exports.DirectoryNotFoundError=ft;exports.FileNotFoundError=ut;exports.OPFSError=E;exports.OPFSNotMountedError=ht;exports.OPFSNotSupportedError=Y;exports.PathError=lt;exports.PermissionError=pt;exports.StorageError=dt;exports.TimeoutError=gt;exports.basename=W;exports.buffersEqual=Le;exports.calculateFileHash=De;exports.checkOPFSSupport=ve;exports.convertBlobToUint8Array=Ie;exports.createBuffer=at;exports.decodeBuffer=Ee;exports.dirname=Ae;exports.encodeString=ot;exports.extname=Re;exports.isBinaryFileExtension=Ne;exports.isPathExcluded=$e;exports.joinPath=k;exports.matchMinimatch=Te;exports.normalizeMinimatch=Pe;exports.normalizePath=z;exports.readFileData=Ce;exports.removeEntry=je;exports.resolvePath=Me;exports.splitPath=L;exports.withLock=D;exports.writeFileData=Fe;
4
+ //# sourceMappingURL=helpers-Cvjm0f_r.cjs.map