@filebox/core 1.0.17 → 1.0.18

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.
package/dist/index.cjs CHANGED
@@ -3,7 +3,7 @@ var global = typeof global !== 'undefined' ? global : this;
3
3
  `).join(`
4
4
  `+t),s.push(n+"m+"+fi.exports.humanize(this.diff)+"\x1B[0m")}else s[0]=Xt()+e+" "+s[0]}function Xt(){return ae.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Jt(...s){return process.stderr.write(hi.formatWithOptions(ae.inspectOpts,...s)+`
5
5
  `)}function Zt(s){s?process.env.DEBUG=s:delete process.env.DEBUG}function es(){return process.env.DEBUG}function as(s){s.inspectOpts={};let e=Object.keys(ae.inspectOpts);for(let a=0;a<e.length;a++)s.inspectOpts[e[a]]=ae.inspectOpts[e[a]]}fi.exports=Ii()(ae);var{formatters:Qn}=fi.exports;Qn.o=function(s){return this.inspectOpts.colors=this.useColors,hi.inspect(s,this.inspectOpts).split(`
6
- `).map(e=>e.trim()).join(" ")};Qn.O=function(s){return this.inspectOpts.colors=this.useColors,hi.inspect(s,this.inspectOpts)}});var Jn=de((Ms,$i)=>{typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?$i.exports=Wn():$i.exports=Xn()});var ms={};si(ms,{CONTENT_ENCRYPTION_EXTENSION:()=>$e,Cache:()=>Vi,DEFAULT_ENCRYPTION_SALT_HEX:()=>ha,FileBox:()=>Xi,FileEncryptor:()=>da,FileSystem:()=>Ye,FileSystemType:()=>Ye,FsCrypt:()=>ma,HttpFileSystem:()=>Zi,Plugin:()=>Ue,StatConstructorParams:()=>Ce,addContentEncryptionSuffix:()=>Ja,applyEncryptionQueryParams:()=>ei,arrayBufferToBase64Url:()=>Qe,base64UrlToArrayBuffer:()=>ua,calculateEncryptedBytes:()=>Qa,crypt:()=>en,debug:()=>vi,default:()=>us,deriveKey:()=>Ie,filterList:()=>Sa,hexToUint8Array:()=>la,isContentEncryptedName:()=>xa,isContentEncryptionEnabled:()=>Ya,isFilenameEncryptionEnabled:()=>Va,normalizeEncryptionAlgorithm:()=>Le,normalizeEncryptionFeatureEnabled:()=>fa,normalizeEncryptionSaltHex:()=>Ta,normalizePartialEncryption:()=>Ne,parseEncryptionQueryParams:()=>ai,path:()=>pi,resolveEncryptionProfile:()=>Xa,stripContentEncryptionSuffix:()=>Za,type:()=>ta});module.exports=rn(ms);function Fi(s,e){return new Proxy(s,{set:(a,i,n,t)=>(a[i]=n,e(),Reflect.set(a,i,n,t)),get:(a,i,n)=>{let t=Reflect.get(a,i,n);return typeof t=="object"&&t!==null?Fi(t,e):t}})}function cn(s=32){let e="ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678",a=e.length,i="";for(let n=0;n<s;n++)i+=e.charAt(Math.floor(Math.random()*a));return i}function pn(s){return{all:s=s||new Map,on:function(e,a){var i=s.get(e);i?i.push(a):s.set(e,[a])},off:function(e,a){var i=s.get(e);i&&(a?i.splice(i.indexOf(a)>>>0,1):s.set(e,[]))},emit:function(e,a){var i=s.get(e);i&&i.slice().map(function(n){n(a)}),(i=s.get("*"))&&i.slice().map(function(n){n(e,a)})}}}fe();fe();var vt={ResourceLockedError:"The resource has been locked",NotImplementedError:"Unsupported operation",InvalidPathError:"The path must be a string, for example: /aaa",TargetPathDoesNotExistError:"The target path does not exist",SourcePathDoesNotExistError:"The source path does not exist",NoMatchingCopyStrategyError:"No matching copy strategy found",NoMatchingDriverError:"No matching driver provider found",ReadOnlyError:"Read only error",PathNotFound:"Path Not Found",ProviderNotFound:"Provider Not Found"},gt=(s,e=null)=>({type:s,message:vt[s],data:e}),N=gt;fe();fe();var $n=ea(Pn(),1),Nn=ea(jn(),1);fe();var Ua=ea(Ln(),1),Oi=class{constructor(){this.extToMime=new Map;this.mimeToExt=new Map}register(e,a){let i=e.toLowerCase().replace(/^\./,"");this.extToMime.set(i,a),this.mimeToExt.set(a,i)}registerBatch(e){for(let[a,i]of Object.entries(e))this.register(a,i)}lookup(e){let a=e.toLowerCase().replace(/^\./,"");return this.extToMime.has(a)?this.extToMime.get(a):Ua.default.lookup(e)}extension(e){return this.mimeToExt.has(e)?this.mimeToExt.get(e):Ua.default.extension(e)}contentType(e){if(e.includes(".")||!e.includes("/")){let a=this.lookup(e);if(a)return Ua.default.contentType(a)}return Ua.default.contentType(e)}getCustomTypes(){let e={};for(let[a,i]of this.extToMime.entries())e[a]=i;return e}reset(){this.extToMime.clear(),this.mimeToExt.clear()}},Ft=new Oi,ta=Ft;var ui=Symbol("rawData"),Tt=0,ya;ui;var Ui=class{constructor({id:e,name:a="",size:i,thumbnail:n,type:t,atime:o,ctime:r,mtime:p,rawData:l,provider:u,parentId:m=null,mountPath:x,parsePath:w,rootPath:S,hash:j={},duplicate:F=1,cid:_=null}){D(this,ya);this.id=e,this.fid=Tt++,this.original_name=a;let E=aa(a,ia(a));this.basename=E;let G=ia(a);this.duplicate_flag=F>1?`${E}__[D${F-1}]__${G}`:"",this.name=F===1?a:this.duplicate_flag,this.size=i?Nn.default.format(i):null,this.byte=i,this.thumbnail=n,this.provider=u,this.atime=this.formatDate(o),this.ctime=this.formatDate(r),this.mtime=this.formatDate(p),this.hash=j,this.type=t&&t.toLocaleLowerCase(),C(this,ya,S),this.mountPath=M("/"+x),this.path=this.normalizePath(x,w),this.parent=M(`/${x}/${w}`),this.relative=M(`/${w}/${this.name||""}`),this[ui]=l||null,this.is_duplicate=F>1,this.duplicate_num=F,this.cid=_,this.parentId=m,this.mime=t==="folder"?"application/directory":ta.lookup(a),this.driver_name=x,this.isStat=!0}formatDate(e){return(0,$n.default)(e||new Date(0)).format("YYYY-MM-DD HH:mm:ss")}normalizePath(e,a){return M(`/${e}/${a}/${this.name||""}`)}getRawData(e){return e?this[ui][e]:this[ui]}getParentId(){var e;return(e=this.parentId)!=null?e:null}get file(){return this.type!=="folder"}get directory(){return this.type==="folder"}get rootPath(){return c(this,ya)}get realPath(){return he(c(this,ya),this.relative)}};ya=new WeakMap;var Ce=Ui;var Ia=class{constructor(e=[]){this.__lock=new Set(e)}_getPath(e){return e instanceof Ce?e.realPath:decodeURIComponent(e)}lock(e){let a=this._getPath(e);this.__lock.add(a)}unlock(e){let a=this._getPath(e);this.__lock.delete(a)}isLock(e){let a=this._getPath(e);return this.__lock.has(a)}};var vi={};si(vi,{cacheDebug:()=>y,coreDebug:()=>P,createDebug:()=>oa,default:()=>ts,fsDebug:()=>L,pathDebug:()=>is,pluginDebug:()=>ns,volumeDebug:()=>O});var xi=ea(Jn(),1),oa=s=>(0,xi.default)(`FileBox:${s}`),P=oa("core"),L=oa("fs"),O=oa("volume"),is=oa("path"),y=oa("cache"),ns=oa("plugin");process.env.NODE_ENV==="development"&&xi.default.enable("FileBox:*");var ts=xi.default;fe();function Sa(s,e){let a=0,i,n;e!=null&&e.name&&(a++,i=new RegExp(e.name.replace(/\\\\/g,"\\"))),e!=null&&e.size&&(a++,n=new Function("size",`return ${e.size.replaceAll("${size}","size")};`)),e.type&&a++;let t=[],o=[];return(e==null?void 0:e.mode)==="normal"?s.forEach(r=>{let p=0;i&&i.test(r.name)&&p++,n&&n(r.size)&&p++,e.type&&e.type.split(",").includes(r.type)&&p++,p===0?o.push(r):t.push(r)}):s.forEach(r=>{let p=0;i&&i.test(r.name)&&p++,n&&n(r.size)&&p++,e.type&&e.type.split(",").includes(r.type)&&p++,p!==a?o.push(r):t.push(r)}),{filteredFiles:t,unfilteredFiles:o}}var q=class{constructor(e,a,i){O("Creating BaseVolume with name: %s",e),this.name=M(e||"/"),this._fs=a,this.emitter=i,this.instance=a==null?void 0:a.instance,O("BaseVolume created: %s",this.name)}refresh(e){return d(this,null,function*(){if(O("Refreshing cache for path: %s",e),this._fs.cache){let a=this._fs.name+":"+e;yield this._fs.cache.del(a)}O("Cache refreshed for path: %s",e)})}_get(e){return d(this,null,function*(){return this._fs.mode===0?yield this._fs.parse(this._fs.root,e):yield this.stat(e)})}stat(e){return d(this,null,function*(){O("Getting stat for: %s",typeof e=="string"?e:e.path);try{let a=e instanceof Ce?e:yield this._fs.resolvePath(this._fs.root,decodeURIComponent(e));return O("Stat result: %s",a==null?void 0:a.name),a}catch(a){throw O("Error getting stat: %O",a),a}})}list(i){return d(this,arguments,function*(e,a={}){O("Listing path: %s with options: %O",e,a);let{pagination:n={},sort:t={}}=a,o,r,p;e=typeof e=="string"?decodeURIComponent(e):e.relative;try{let l=yield this._fs.list(e,a),u=Array.isArray(l)?l:Array.isArray(l==null?void 0:l.list)?l.list:Array.isArray(l==null?void 0:l.data)?l.data:[];if(O("Got raw list data with %d items",(u==null?void 0:u.length)||0),o=u,r=l&&typeof l=="object"&&l.total!=null&&Number(l.total)||u.length,a.filter){let{unfilteredFiles:x,filteredFiles:w}=Sa(o,a.filter);o=x,p=w,O("Applied filter, %d items remain",(o==null?void 0:o.length)||0)}if(!(l&&typeof l=="object"&&!Array.isArray(l)&&l.total!=null)&&n.page&&n.pageSize&&o.length>n.pageSize){let x=n.pageSize,S=(n.page-1)*x,j=S+x;o=o.slice(S,j),O("Applied pagination, showing items %d to %d",S,j)}return O("List complete with %d items",(o==null?void 0:o.length)||0),{data:o,total:r,filter:p}}catch(l){throw O("Error listing path: %O",l),l}})}readFile(e){return d(this,null,function*(){if(O("Reading file: %s",e),!this._fs.hasMethod("readFile"))throw O("ReadFile method not implemented"),N("NotImplementedError");let a=1024*10*10;try{let i=yield this.stat(e);if(i.size>a)throw O("File size exceeds limit: %s > %s",i.size,a),new Error(`\u8BFB\u53D6\u7684\u6587\u4EF6\u8D85\u51FA\u6700\u5927\u9650\u5236,${a}`);let n=yield this._fs.readFile(i);return O("File read successfully: %s (%d bytes)",e,(n==null?void 0:n.length)||0),n}catch(i){throw O("Error reading file: %O",i),i}})}hasMethod(e){return this._fs.hasMethod(e)}};q.lock=new Ia;var gi=class extends q{constructor(e,a,i){super(e,a,i)}},bi=class extends q{constructor(e,a,i){super(e,a,i)}mkdir(i){return d(this,arguments,function*(e,a={}){var p;if(O("Creating directory: %s with options %O",e,a),!this._fs.hasMethod("mkdir"))throw O("Mkdir method not implemented"),N("NotImplementedError");let n=typeof e=="string"?e:e.realPath;if(q.lock.isLock(n))throw O("Resource locked: %s",n),N("ResourceLockedError");q.lock.lock(n),O("Acquired lock for: %s",n);let t=typeof e=="string"?decodeURIComponent(e):e.realPath,o,r;try{let[l,u]=De(t);return O("Parent path: %s, item: %s",l,u),a.exist?(O("Checking if directory exists: %s",t),o=yield this.stat(t),o):(O("Getting stat for parent: %s",l),r=yield this.stat(l),O("Creating directory %s in %s",u,l),o=yield this._fs.mkdir(r,u),(p=this._fs)!=null&&p.cache&&(O("Updating cache for new directory: %s",u),yield this._fs.cache.handleOperation({type:"create",path:t,parentPath:l,newItem:o,fs:this._fs})),O("Running afterMkdir hooks"),this.emitter&&typeof this.emitter.emit=="function"&&(yield this.emitter.emit("afterMkdir",r,o)),O("Directory created successfully: %s",t),o)}catch(l){throw O("Error creating directory: %O",l),l}finally{O("Releasing lock for: %s",n),q.lock.unlock(n)}})}rapidUpload(e,a,i){return d(this,null,function*(){if(!this._fs.hasMethod("rapidUpload"))throw N("NotImplementedError");if(q.lock.isLock(e))throw N("ResourceLockedError");q.lock.lock(e);let n=null;try{let t=yield this.stat(e);return n=yield this._fs.rapidUpload(t,a,i),n}catch(t){throw t}finally{q.lock.unlock(e)}})}rename(e,a){return d(this,null,function*(){var n;if(q.lock.isLock(e))throw N("ResourceLockedError");if(q.lock.lock(e),this._fs.readOnly)throw N("ReadOnlyError");if(!this._fs.hasMethod("rename"))throw N("NotImplementedError");let i=null;try{let t=yield this.stat(e);return i=yield this._fs.rename(t,a),(n=this._fs)!=null&&n.cache&&(yield this._fs.cache.handleOperation({type:"rename",path:e,newName:a,result:i,fs:this._fs})),i}catch(t){throw t}finally{q.lock.unlock(e)}})}save(e,a){return d(this,null,function*(){if(!this._fs.hasMethod("save"))throw N("NotImplementedError");try{let i=yield this.stat(a||this._fs.rootPath);return yield this._fs.save(i,e)}catch(i){throw i}})}share(e,a){return d(this,null,function*(){if(!this._fs.hasMethod("share"))throw N("NotImplementedError");try{let i=yield this.stat(a||this._fs.rootPath),n=ti({},e);return n.expire!==void 0&&n.expired===void 0&&(n.expired=n.expire),n.expired!==void 0&&n.expire===void 0&&(n.expire=n.expired),yield this._fs.share(i,n)}catch(i){throw i}})}search(e){return d(this,null,function*(){if(!this._fs.hasMethod("search"))throw N("NotImplementedError");let a=yield this._fs.search(e);return this._fs.formatList(a,"/","/")})}remove(i){return d(this,arguments,function*(e,a={}){var o;if(!this._fs.hasMethod("remove"))throw N("NotImplementedError");if(q.lock.isLock(e))throw N("ResourceLockedError");q.lock.lock(e);let n,t;try{return t=yield this.stat(e),n=yield this._fs.remove(t),(o=this._fs)!=null&&o.cache&&(yield this._fs.cache.handleOperation({type:"delete",path:e,parentPath:Y(e),fs:this._fs})),this.emitter&&typeof this.emitter.emit=="function"&&(yield this.emitter.emit("afterRemove",t,n)),n}catch(r){throw r}finally{q.lock.unlock(e)}})}bulkCopy(n,t){return d(this,arguments,function*(e,a,i={}){var o;if(this._fs.hasMethod("bulkCopy")){let r=yield this.stat(M(a)),p=yield Promise.all(e.map(u=>this.stat(M(u)))),l=yield this._fs.bulkCopy(p,r);if((o=this._fs)!=null&&o.cache)for(let u=0;u<e.length;u++)yield this._fs.cache.handleOperation({type:"copy",path:e[u],targetPath:he(a,aa(e[u])),result:l[u]||l,fs:this._fs});return l}else return yield Promise.all(e.map(p=>this.copy(p,a,i)))})}createUpload(e,a,i){return d(this,null,function*(){return this.upload(e,a,i)})}upload(e,a,i){return d(this,null,function*(){let n=yield this.stat(e),t;try{t=yield this._fs.upload(n,a,i)}catch(o){throw yield this.invalidateUploadCache(e,n),o}if(!this._fs.cache)return t;if(t&&typeof t.upload=="function"){let o=t.upload;t.upload=(...r)=>d(this,null,function*(){try{return yield o.apply(t,r)}finally{yield this.invalidateUploadCache(e,n)}})}else yield this.invalidateUploadCache(e,n);return t})}invalidateUploadCache(e,a){return d(this,null,function*(){let i=this._fs.cache;if(i)try{for(let n of new Set([a.realPath,decodeURIComponent(e)]))yield i.invalidateList(n)}catch(n){O("Disabling upload cache after invalidation failed: %O",n),this._fs.cache===i&&(this._fs.cache=void 0)}})}remoteUpload(e,a){return d(this,null,function*(){let i=typeof e=="string"?decodeURIComponent(e):e.realPath,n=yield this.stat(i);return yield this._fs.remoteUpload(n,a)})}download(i){return d(this,arguments,function*(e,a={}){if(q.lock.isLock(e))throw N("ResourceLockedError");if(q.lock.lock(e),!this._fs.hasMethod("link"))throw N("NotImplementedError");try{let n=yield this.stat(e),t=yield this._fs.link(n);return Array.isArray(t)?t:[t]}catch(n){throw n}finally{q.lock.unlock(e)}})}copy(n,t){return d(this,arguments,function*(e,a,i={}){var o;if(e=M(e),a=M(a),q.lock.isLock(e))throw N("ResourceLockedError");if(q.lock.lock(e),!this._fs.hasMethod("copy"))throw N("NotImplementedError");try{let r=yield this.stat(e),p=yield this.stat(a),l=yield this._fs.copy(r,p);return(o=this._fs)!=null&&o.cache&&(yield this._fs.cache.handleOperation({type:"copy",path:e,targetPath:a,result:l,fs:this._fs})),l}catch(r){throw r}finally{q.lock.unlock(e)}})}move(n,t){return d(this,arguments,function*(e,a,i={}){var o;if(q.lock.isLock(e))throw N("ResourceLockedError");if(q.lock.lock(e),!this._fs.hasMethod("move"))throw N("NotImplementedError");try{let r=yield this.stat(e),p=yield this.stat(a),l=yield this._fs.move(r,p);return(o=this._fs)!=null&&o.cache&&(yield this._fs.cache.handleOperation({type:"move",path:e,targetPath:a,result:l,fs:this._fs})),l}catch(r){throw r}finally{q.lock.unlock(e)}})}bulkRemove(i){return d(this,arguments,function*(e,a={}){var t;let n=[...new Set(e)];if(this._fs.hasMethod("bulkRemove")){let o=yield Promise.all(n.map(p=>this.stat(M(p)))),r=yield this._fs.bulkRemove(o);if((t=this._fs)!=null&&t.cache)for(let p of n)yield this._fs.cache.handleOperation({type:"delete",path:p,parentPath:Y(p),fs:this._fs});return r}else return yield Promise.allSettled(n.map(r=>this.remove(r,a)))})}unmount(){return d(this,null,function*(){var e,a;yield(a=(e=this._fs)==null?void 0:e.unmount)==null?void 0:a.call(e)})}};fe();var La=(i=>(i[i.VALID=0]="VALID",i[i.NEEDS_REFRESH=1]="NEEDS_REFRESH",i[i.INVALID=2]="INVALID",i))(La||{});var Ea=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,tt=new Set,Ni=typeof process=="object"&&process?process:{},st=(s,e,a,i)=>{typeof Ni.emitWarning=="function"&&Ni.emitWarning(s,e,a,i)},ki=globalThis.AbortController,et=globalThis.AbortSignal,at;if(typeof ki=="undefined"){et=class{constructor(){H(this,"onabort");H(this,"_onabort",[]);H(this,"reason");H(this,"aborted",!1)}addEventListener(i,n){this._onabort.push(n)}},ki=class{constructor(){H(this,"signal",new et);e()}abort(i){var n,t;if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=!0;for(let o of this.signal._onabort)o(i);(t=(n=this.signal).onabort)==null||t.call(n,i)}}};let s=((at=Ni.env)==null?void 0:at.LRU_CACHE_IGNORE_AC_WARNING)!=="1",e=()=>{s&&(s=!1,st("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}var ss=s=>!tt.has(s),Js=Symbol("type"),Ke=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),ot=s=>Ke(s)?s<=Math.pow(2,8)?Uint8Array:s<=Math.pow(2,16)?Uint16Array:s<=Math.pow(2,32)?Uint32Array:s<=Number.MAX_SAFE_INTEGER?ja:null:null,ja=class extends Array{constructor(e){super(e),this.fill(0)}},_a,ra=class ra{constructor(e,a){H(this,"heap");H(this,"length");if(!c(ra,_a))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new a(e),this.length=0}static create(e){let a=ot(e);if(!a)return[];C(ra,_a,!0);let i=new ra(e,a);return C(ra,_a,!1),i}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}};_a=new WeakMap,D(ra,_a,!1);var qi=ra,it,nt,Se,ge,Ee,je,Aa,za,J,_e,Q,K,z,pe,be,oe,ie,Ae,ne,ze,Fe,ye,Te,Ve,le,h,Bi,ca,Oe,Na,we,rt,pa,Fa,qa,We,He,Ki,yi,wi,B,Wi,$a,Ge,Hi,Gi=class Gi{constructor(e){D(this,h);D(this,Se);D(this,ge);D(this,Ee);D(this,je);D(this,Aa);D(this,za);H(this,"ttl");H(this,"ttlResolution");H(this,"ttlAutopurge");H(this,"updateAgeOnGet");H(this,"updateAgeOnHas");H(this,"allowStale");H(this,"noDisposeOnSet");H(this,"noUpdateTTL");H(this,"maxEntrySize");H(this,"sizeCalculation");H(this,"noDeleteOnFetchRejection");H(this,"noDeleteOnStaleGet");H(this,"allowStaleOnFetchAbort");H(this,"allowStaleOnFetchRejection");H(this,"ignoreFetchAbort");D(this,J);D(this,_e);D(this,Q);D(this,K);D(this,z);D(this,pe);D(this,be);D(this,oe);D(this,ie);D(this,Ae);D(this,ne);D(this,ze);D(this,Fe);D(this,ye);D(this,Te);D(this,Ve);D(this,le);D(this,ca,()=>{});D(this,Oe,()=>{});D(this,Na,()=>{});D(this,we,()=>!1);D(this,pa,e=>{});D(this,Fa,(e,a,i)=>{});D(this,qa,(e,a,i,n)=>{if(i||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});H(this,it,"LRUCache");let{max:a=0,ttl:i,ttlResolution:n=1,ttlAutopurge:t,updateAgeOnGet:o,updateAgeOnHas:r,allowStale:p,dispose:l,disposeAfter:u,noDisposeOnSet:m,noUpdateTTL:x,maxSize:w=0,maxEntrySize:S=0,sizeCalculation:j,fetchMethod:F,memoMethod:_,noDeleteOnFetchRejection:E,noDeleteOnStaleGet:G,allowStaleOnFetchRejection:W,allowStaleOnFetchAbort:ce,ignoreFetchAbort:X}=e;if(a!==0&&!Ke(a))throw new TypeError("max option must be a nonnegative integer");let ue=a?ot(a):Array;if(!ue)throw new Error("invalid max value: "+a);if(C(this,Se,a),C(this,ge,w),this.maxEntrySize=S||c(this,ge),this.sizeCalculation=j,this.sizeCalculation){if(!c(this,ge)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(_!==void 0&&typeof _!="function")throw new TypeError("memoMethod must be a function if defined");if(C(this,za,_),F!==void 0&&typeof F!="function")throw new TypeError("fetchMethod must be a function if specified");if(C(this,Aa,F),C(this,Ve,!!F),C(this,Q,new Map),C(this,K,new Array(a).fill(void 0)),C(this,z,new Array(a).fill(void 0)),C(this,pe,new ue(a)),C(this,be,new ue(a)),C(this,oe,0),C(this,ie,0),C(this,Ae,qi.create(a)),C(this,J,0),C(this,_e,0),typeof l=="function"&&C(this,Ee,l),typeof u=="function"?(C(this,je,u),C(this,ne,[])):(C(this,je,void 0),C(this,ne,void 0)),C(this,Te,!!c(this,Ee)),C(this,le,!!c(this,je)),this.noDisposeOnSet=!!m,this.noUpdateTTL=!!x,this.noDeleteOnFetchRejection=!!E,this.allowStaleOnFetchRejection=!!W,this.allowStaleOnFetchAbort=!!ce,this.ignoreFetchAbort=!!X,this.maxEntrySize!==0){if(c(this,ge)!==0&&!Ke(c(this,ge)))throw new TypeError("maxSize must be a positive integer if specified");if(!Ke(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");g(this,h,rt).call(this)}if(this.allowStale=!!p,this.noDeleteOnStaleGet=!!G,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!r,this.ttlResolution=Ke(n)||n===0?n:1,this.ttlAutopurge=!!t,this.ttl=i||0,this.ttl){if(!Ke(this.ttl))throw new TypeError("ttl must be a positive integer if specified");g(this,h,Bi).call(this)}if(c(this,Se)===0&&this.ttl===0&&c(this,ge)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!c(this,Se)&&!c(this,ge)){let I="LRU_CACHE_UNBOUNDED";ss(I)&&(tt.add(I),st("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",I,Gi))}}static unsafeExposeInternals(e){return{starts:c(e,Fe),ttls:c(e,ye),sizes:c(e,ze),keyMap:c(e,Q),keyList:c(e,K),valList:c(e,z),next:c(e,pe),prev:c(e,be),get head(){return c(e,oe)},get tail(){return c(e,ie)},free:c(e,Ae),isBackgroundFetch:a=>{var i;return g(i=e,h,B).call(i,a)},backgroundFetch:(a,i,n,t)=>{var o;return g(o=e,h,wi).call(o,a,i,n,t)},moveToTail:a=>{var i;return g(i=e,h,$a).call(i,a)},indexes:a=>{var i;return g(i=e,h,We).call(i,a)},rindexes:a=>{var i;return g(i=e,h,He).call(i,a)},isStale:a=>{var i;return c(i=e,we).call(i,a)}}}get max(){return c(this,Se)}get maxSize(){return c(this,ge)}get calculatedSize(){return c(this,_e)}get size(){return c(this,J)}get fetchMethod(){return c(this,Aa)}get memoMethod(){return c(this,za)}get dispose(){return c(this,Ee)}get disposeAfter(){return c(this,je)}getRemainingTTL(e){return c(this,Q).has(e)?1/0:0}*entries(){for(let e of g(this,h,We).call(this))c(this,z)[e]!==void 0&&c(this,K)[e]!==void 0&&!g(this,h,B).call(this,c(this,z)[e])&&(yield[c(this,K)[e],c(this,z)[e]])}*rentries(){for(let e of g(this,h,He).call(this))c(this,z)[e]!==void 0&&c(this,K)[e]!==void 0&&!g(this,h,B).call(this,c(this,z)[e])&&(yield[c(this,K)[e],c(this,z)[e]])}*keys(){for(let e of g(this,h,We).call(this)){let a=c(this,K)[e];a!==void 0&&!g(this,h,B).call(this,c(this,z)[e])&&(yield a)}}*rkeys(){for(let e of g(this,h,He).call(this)){let a=c(this,K)[e];a!==void 0&&!g(this,h,B).call(this,c(this,z)[e])&&(yield a)}}*values(){for(let e of g(this,h,We).call(this))c(this,z)[e]!==void 0&&!g(this,h,B).call(this,c(this,z)[e])&&(yield c(this,z)[e])}*rvalues(){for(let e of g(this,h,He).call(this))c(this,z)[e]!==void 0&&!g(this,h,B).call(this,c(this,z)[e])&&(yield c(this,z)[e])}[(nt=Symbol.iterator,it=Symbol.toStringTag,nt)](){return this.entries()}find(e,a={}){for(let i of g(this,h,We).call(this)){let n=c(this,z)[i],t=g(this,h,B).call(this,n)?n.__staleWhileFetching:n;if(t!==void 0&&e(t,c(this,K)[i],this))return this.get(c(this,K)[i],a)}}forEach(e,a=this){for(let i of g(this,h,We).call(this)){let n=c(this,z)[i],t=g(this,h,B).call(this,n)?n.__staleWhileFetching:n;t!==void 0&&e.call(a,t,c(this,K)[i],this)}}rforEach(e,a=this){for(let i of g(this,h,He).call(this)){let n=c(this,z)[i],t=g(this,h,B).call(this,n)?n.__staleWhileFetching:n;t!==void 0&&e.call(a,t,c(this,K)[i],this)}}purgeStale(){let e=!1;for(let a of g(this,h,He).call(this,{allowStale:!0}))c(this,we).call(this,a)&&(g(this,h,Ge).call(this,c(this,K)[a],"expire"),e=!0);return e}info(e){let a=c(this,Q).get(e);if(a===void 0)return;let i=c(this,z)[a],n=g(this,h,B).call(this,i)?i.__staleWhileFetching:i;if(n===void 0)return;let t={value:n};if(c(this,ye)&&c(this,Fe)){let o=c(this,ye)[a],r=c(this,Fe)[a];if(o&&r){let p=o-(Ea.now()-r);t.ttl=p,t.start=Date.now()}}return c(this,ze)&&(t.size=c(this,ze)[a]),t}dump(){let e=[];for(let a of g(this,h,We).call(this,{allowStale:!0})){let i=c(this,K)[a],n=c(this,z)[a],t=g(this,h,B).call(this,n)?n.__staleWhileFetching:n;if(t===void 0||i===void 0)continue;let o={value:t};if(c(this,ye)&&c(this,Fe)){o.ttl=c(this,ye)[a];let r=Ea.now()-c(this,Fe)[a];o.start=Math.floor(Date.now()-r)}c(this,ze)&&(o.size=c(this,ze)[a]),e.unshift([i,o])}return e}load(e){this.clear();for(let[a,i]of e){if(i.start){let n=Date.now()-i.start;i.start=Ea.now()-n}this.set(a,i.value,i)}}set(e,a,i={}){var x,w,S,j,F;if(a===void 0)return this.delete(e),this;let{ttl:n=this.ttl,start:t,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:r=this.sizeCalculation,status:p}=i,{noUpdateTTL:l=this.noUpdateTTL}=i,u=c(this,qa).call(this,e,a,i.size||0,r);if(this.maxEntrySize&&u>this.maxEntrySize)return p&&(p.set="miss",p.maxEntrySizeExceeded=!0),g(this,h,Ge).call(this,e,"set"),this;let m=c(this,J)===0?void 0:c(this,Q).get(e);if(m===void 0)m=c(this,J)===0?c(this,ie):c(this,Ae).length!==0?c(this,Ae).pop():c(this,J)===c(this,Se)?g(this,h,yi).call(this,!1):c(this,J),c(this,K)[m]=e,c(this,z)[m]=a,c(this,Q).set(e,m),c(this,pe)[c(this,ie)]=m,c(this,be)[m]=c(this,ie),C(this,ie,m),oi(this,J)._++,c(this,Fa).call(this,m,u,p),p&&(p.set="add"),l=!1;else{g(this,h,$a).call(this,m);let _=c(this,z)[m];if(a!==_){if(c(this,Ve)&&g(this,h,B).call(this,_)){_.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:E}=_;E!==void 0&&!o&&(c(this,Te)&&((x=c(this,Ee))==null||x.call(this,E,e,"set")),c(this,le)&&((w=c(this,ne))==null||w.push([E,e,"set"])))}else o||(c(this,Te)&&((S=c(this,Ee))==null||S.call(this,_,e,"set")),c(this,le)&&((j=c(this,ne))==null||j.push([_,e,"set"])));if(c(this,pa).call(this,m),c(this,Fa).call(this,m,u,p),c(this,z)[m]=a,p){p.set="replace";let E=_&&g(this,h,B).call(this,_)?_.__staleWhileFetching:_;E!==void 0&&(p.oldValue=E)}}else p&&(p.set="update")}if(n!==0&&!c(this,ye)&&g(this,h,Bi).call(this),c(this,ye)&&(l||c(this,Na).call(this,m,n,t),p&&c(this,Oe).call(this,p,m)),!o&&c(this,le)&&c(this,ne)){let _=c(this,ne),E;for(;E=_==null?void 0:_.shift();)(F=c(this,je))==null||F.call(this,...E)}return this}pop(){var e;try{for(;c(this,J);){let a=c(this,z)[c(this,oe)];if(g(this,h,yi).call(this,!0),g(this,h,B).call(this,a)){if(a.__staleWhileFetching)return a.__staleWhileFetching}else if(a!==void 0)return a}}finally{if(c(this,le)&&c(this,ne)){let a=c(this,ne),i;for(;i=a==null?void 0:a.shift();)(e=c(this,je))==null||e.call(this,...i)}}}has(e,a={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:n}=a,t=c(this,Q).get(e);if(t!==void 0){let o=c(this,z)[t];if(g(this,h,B).call(this,o)&&o.__staleWhileFetching===void 0)return!1;if(c(this,we).call(this,t))n&&(n.has="stale",c(this,Oe).call(this,n,t));else return i&&c(this,ca).call(this,t),n&&(n.has="hit",c(this,Oe).call(this,n,t)),!0}else n&&(n.has="miss");return!1}peek(e,a={}){let{allowStale:i=this.allowStale}=a,n=c(this,Q).get(e);if(n===void 0||!i&&c(this,we).call(this,n))return;let t=c(this,z)[n];return g(this,h,B).call(this,t)?t.__staleWhileFetching:t}fetch(i){return d(this,arguments,function*(e,a={}){let{allowStale:n=this.allowStale,updateAgeOnGet:t=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:r=this.ttl,noDisposeOnSet:p=this.noDisposeOnSet,size:l=0,sizeCalculation:u=this.sizeCalculation,noUpdateTTL:m=this.noUpdateTTL,noDeleteOnFetchRejection:x=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:w=this.allowStaleOnFetchRejection,ignoreFetchAbort:S=this.ignoreFetchAbort,allowStaleOnFetchAbort:j=this.allowStaleOnFetchAbort,context:F,forceRefresh:_=!1,status:E,signal:G}=a;if(!c(this,Ve))return E&&(E.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:t,noDeleteOnStaleGet:o,status:E});let W={allowStale:n,updateAgeOnGet:t,noDeleteOnStaleGet:o,ttl:r,noDisposeOnSet:p,size:l,sizeCalculation:u,noUpdateTTL:m,noDeleteOnFetchRejection:x,allowStaleOnFetchRejection:w,allowStaleOnFetchAbort:j,ignoreFetchAbort:S,status:E,signal:G},ce=c(this,Q).get(e);if(ce===void 0){E&&(E.fetch="miss");let X=g(this,h,wi).call(this,e,ce,W,F);return X.__returned=X}else{let X=c(this,z)[ce];if(g(this,h,B).call(this,X)){let Ra=n&&X.__staleWhileFetching!==void 0;return E&&(E.fetch="inflight",Ra&&(E.returnedStale=!0)),Ra?X.__staleWhileFetching:X.__returned=X}let ue=c(this,we).call(this,ce);if(!_&&!ue)return E&&(E.fetch="hit"),g(this,h,$a).call(this,ce),t&&c(this,ca).call(this,ce),E&&c(this,Oe).call(this,E,ce),X;let I=g(this,h,wi).call(this,e,ce,W,F),Xe=I.__staleWhileFetching!==void 0&&n;return E&&(E.fetch=ue?"stale":"refresh",Xe&&ue&&(E.returnedStale=!0)),Xe?I.__staleWhileFetching:I.__returned=I}})}forceFetch(i){return d(this,arguments,function*(e,a={}){let n=yield this.fetch(e,a);if(n===void 0)throw new Error("fetch() returned undefined");return n})}memo(e,a={}){let i=c(this,za);if(!i)throw new Error("no memoMethod provided to constructor");let l=a,{context:n,forceRefresh:t}=l,o=sn(l,["context","forceRefresh"]),r=this.get(e,o);if(!t&&r!==void 0)return r;let p=i(e,r,{options:o,context:n});return this.set(e,p,o),p}get(e,a={}){let{allowStale:i=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:t=this.noDeleteOnStaleGet,status:o}=a,r=c(this,Q).get(e);if(r!==void 0){let p=c(this,z)[r],l=g(this,h,B).call(this,p);return o&&c(this,Oe).call(this,o,r),c(this,we).call(this,r)?(o&&(o.get="stale"),l?(o&&i&&p.__staleWhileFetching!==void 0&&(o.returnedStale=!0),i?p.__staleWhileFetching:void 0):(t||g(this,h,Ge).call(this,e,"expire"),o&&i&&(o.returnedStale=!0),i?p:void 0)):(o&&(o.get="hit"),l?p.__staleWhileFetching:(g(this,h,$a).call(this,r),n&&c(this,ca).call(this,r),p))}else o&&(o.get="miss")}delete(e){return g(this,h,Ge).call(this,e,"delete")}clear(){return g(this,h,Hi).call(this,"delete")}};Se=new WeakMap,ge=new WeakMap,Ee=new WeakMap,je=new WeakMap,Aa=new WeakMap,za=new WeakMap,J=new WeakMap,_e=new WeakMap,Q=new WeakMap,K=new WeakMap,z=new WeakMap,pe=new WeakMap,be=new WeakMap,oe=new WeakMap,ie=new WeakMap,Ae=new WeakMap,ne=new WeakMap,ze=new WeakMap,Fe=new WeakMap,ye=new WeakMap,Te=new WeakMap,Ve=new WeakMap,le=new WeakMap,h=new WeakSet,Bi=function(){let e=new ja(c(this,Se)),a=new ja(c(this,Se));C(this,ye,e),C(this,Fe,a),C(this,Na,(t,o,r=Ea.now())=>{if(a[t]=o!==0?r:0,e[t]=o,o!==0&&this.ttlAutopurge){let p=setTimeout(()=>{c(this,we).call(this,t)&&g(this,h,Ge).call(this,c(this,K)[t],"expire")},o+1);p.unref&&p.unref()}}),C(this,ca,t=>{a[t]=e[t]!==0?Ea.now():0}),C(this,Oe,(t,o)=>{if(e[o]){let r=e[o],p=a[o];if(!r||!p)return;t.ttl=r,t.start=p,t.now=i||n();let l=t.now-p;t.remainingTTL=r-l}});let i=0,n=()=>{let t=Ea.now();if(this.ttlResolution>0){i=t;let o=setTimeout(()=>i=0,this.ttlResolution);o.unref&&o.unref()}return t};this.getRemainingTTL=t=>{let o=c(this,Q).get(t);if(o===void 0)return 0;let r=e[o],p=a[o];if(!r||!p)return 1/0;let l=(i||n())-p;return r-l},C(this,we,t=>{let o=a[t],r=e[t];return!!r&&!!o&&(i||n())-o>r})},ca=new WeakMap,Oe=new WeakMap,Na=new WeakMap,we=new WeakMap,rt=function(){let e=new ja(c(this,Se));C(this,_e,0),C(this,ze,e),C(this,pa,a=>{C(this,_e,c(this,_e)-e[a]),e[a]=0}),C(this,qa,(a,i,n,t)=>{if(g(this,h,B).call(this,i))return 0;if(!Ke(n))if(t){if(typeof t!="function")throw new TypeError("sizeCalculation must be a function");if(n=t(i,a),!Ke(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return n}),C(this,Fa,(a,i,n)=>{if(e[a]=i,c(this,ge)){let t=c(this,ge)-e[a];for(;c(this,_e)>t;)g(this,h,yi).call(this,!0)}C(this,_e,c(this,_e)+e[a]),n&&(n.entrySize=i,n.totalCalculatedSize=c(this,_e))})},pa=new WeakMap,Fa=new WeakMap,qa=new WeakMap,We=function*({allowStale:e=this.allowStale}={}){if(c(this,J))for(let a=c(this,ie);!(!g(this,h,Ki).call(this,a)||((e||!c(this,we).call(this,a))&&(yield a),a===c(this,oe)));)a=c(this,be)[a]},He=function*({allowStale:e=this.allowStale}={}){if(c(this,J))for(let a=c(this,oe);!(!g(this,h,Ki).call(this,a)||((e||!c(this,we).call(this,a))&&(yield a),a===c(this,ie)));)a=c(this,pe)[a]},Ki=function(e){return e!==void 0&&c(this,Q).get(c(this,K)[e])===e},yi=function(e){var t,o;let a=c(this,oe),i=c(this,K)[a],n=c(this,z)[a];return c(this,Ve)&&g(this,h,B).call(this,n)?n.__abortController.abort(new Error("evicted")):(c(this,Te)||c(this,le))&&(c(this,Te)&&((t=c(this,Ee))==null||t.call(this,n,i,"evict")),c(this,le)&&((o=c(this,ne))==null||o.push([n,i,"evict"]))),c(this,pa).call(this,a),e&&(c(this,K)[a]=void 0,c(this,z)[a]=void 0,c(this,Ae).push(a)),c(this,J)===1?(C(this,oe,C(this,ie,0)),c(this,Ae).length=0):C(this,oe,c(this,pe)[a]),c(this,Q).delete(i),oi(this,J)._--,a},wi=function(e,a,i,n){let t=a===void 0?void 0:c(this,z)[a];if(g(this,h,B).call(this,t))return t;let o=new ki,{signal:r}=i;r==null||r.addEventListener("abort",()=>o.abort(r.reason),{signal:o.signal});let p={signal:o.signal,options:i,context:n},l=(j,F=!1)=>{let{aborted:_}=o.signal,E=i.ignoreFetchAbort&&j!==void 0;if(i.status&&(_&&!F?(i.status.fetchAborted=!0,i.status.fetchError=o.signal.reason,E&&(i.status.fetchAbortIgnored=!0)):i.status.fetchResolved=!0),_&&!E&&!F)return m(o.signal.reason);let G=w;return c(this,z)[a]===w&&(j===void 0?G.__staleWhileFetching?c(this,z)[a]=G.__staleWhileFetching:g(this,h,Ge).call(this,e,"fetch"):(i.status&&(i.status.fetchUpdated=!0),this.set(e,j,p.options))),j},u=j=>(i.status&&(i.status.fetchRejected=!0,i.status.fetchError=j),m(j)),m=j=>{let{aborted:F}=o.signal,_=F&&i.allowStaleOnFetchAbort,E=_||i.allowStaleOnFetchRejection,G=E||i.noDeleteOnFetchRejection,W=w;if(c(this,z)[a]===w&&(!G||W.__staleWhileFetching===void 0?g(this,h,Ge).call(this,e,"fetch"):_||(c(this,z)[a]=W.__staleWhileFetching)),E)return i.status&&W.__staleWhileFetching!==void 0&&(i.status.returnedStale=!0),W.__staleWhileFetching;if(W.__returned===W)throw j},x=(j,F)=>{var E;let _=(E=c(this,Aa))==null?void 0:E.call(this,e,t,p);_&&_ instanceof Promise&&_.then(G=>j(G===void 0?void 0:G),F),o.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(j(void 0),i.allowStaleOnFetchAbort&&(j=G=>l(G,!0)))})};i.status&&(i.status.fetchDispatched=!0);let w=new Promise(x).then(l,u),S=Object.assign(w,{__abortController:o,__staleWhileFetching:t,__returned:void 0});return a===void 0?(this.set(e,S,tn(ti({},p.options),{status:void 0})),a=c(this,Q).get(e)):c(this,z)[a]=S,S},B=function(e){if(!c(this,Ve))return!1;let a=e;return!!a&&a instanceof Promise&&a.hasOwnProperty("__staleWhileFetching")&&a.__abortController instanceof ki},Wi=function(e,a){c(this,be)[a]=e,c(this,pe)[e]=a},$a=function(e){e!==c(this,ie)&&(e===c(this,oe)?C(this,oe,c(this,pe)[e]):g(this,h,Wi).call(this,c(this,be)[e],c(this,pe)[e]),g(this,h,Wi).call(this,c(this,ie),e),C(this,ie,e))},Ge=function(e,a){var n,t,o,r;let i=!1;if(c(this,J)!==0){let p=c(this,Q).get(e);if(p!==void 0)if(i=!0,c(this,J)===1)g(this,h,Hi).call(this,a);else{c(this,pa).call(this,p);let l=c(this,z)[p];if(g(this,h,B).call(this,l)?l.__abortController.abort(new Error("deleted")):(c(this,Te)||c(this,le))&&(c(this,Te)&&((n=c(this,Ee))==null||n.call(this,l,e,a)),c(this,le)&&((t=c(this,ne))==null||t.push([l,e,a]))),c(this,Q).delete(e),c(this,K)[p]=void 0,c(this,z)[p]=void 0,p===c(this,ie))C(this,ie,c(this,be)[p]);else if(p===c(this,oe))C(this,oe,c(this,pe)[p]);else{let u=c(this,be)[p];c(this,pe)[u]=c(this,pe)[p];let m=c(this,pe)[p];c(this,be)[m]=c(this,be)[p]}oi(this,J)._--,c(this,Ae).push(p)}}if(c(this,le)&&((o=c(this,ne))!=null&&o.length)){let p=c(this,ne),l;for(;l=p==null?void 0:p.shift();)(r=c(this,je))==null||r.call(this,...l)}return i},Hi=function(e){var a,i,n;for(let t of g(this,h,He).call(this,{allowStale:!0})){let o=c(this,z)[t];if(g(this,h,B).call(this,o))o.__abortController.abort(new Error("deleted"));else{let r=c(this,K)[t];c(this,Te)&&((a=c(this,Ee))==null||a.call(this,o,r,e)),c(this,le)&&((i=c(this,ne))==null||i.push([o,r,e]))}}if(c(this,Q).clear(),c(this,z).fill(void 0),c(this,K).fill(void 0),c(this,ye)&&c(this,Fe)&&(c(this,ye).fill(0),c(this,Fe).fill(0)),c(this,ze)&&c(this,ze).fill(0),C(this,oe,0),C(this,ie,0),c(this,Ae).length=0,C(this,_e,0),C(this,J,0),c(this,le)&&c(this,ne)){let t=c(this,ne),o;for(;o=t==null?void 0:t.shift();)(n=c(this,je))==null||n.call(this,...o)}};var Ci=Gi;var Pi=ea(ri(),1);var Ba="FileBox:";var Ka=class{constructor(e={}){let a={max:e.max||100,maxSize:e.maxSize||500,ttl:e.ttl||36e5,sizeCalculation:e.sizeCalculation||((i,n)=>1)};this.cache=new Ci(a),this.prefix=Ba+(e.prefix||""),y("LRU\u7F13\u5B58\u7B56\u7565\u5DF2\u521B\u5EFA\uFF0C\u524D\u7F00: %s",this.prefix)}normalize(e){return`${this.prefix}${Pi.default.normalize(Pi.default.join(e,"/"))}`}has(e){return d(this,null,function*(){let a=this.normalize(e);return this.cache.has(a)})}get(e){return d(this,null,function*(){let a=this.normalize(e);return y("\u83B7\u53D6\u7F13\u5B58 key: %s",a),this.cache.get(a)})}set(e,a,i){return d(this,null,function*(){if(!a){y("\u6CA1\u6709\u4E3Akey\u63D0\u4F9B\u503C: %s, \u8DF3\u8FC7",e);return}let n=this.normalize(e);y("\u8BBE\u7F6E\u7F13\u5B58 key: %s",n);let t=i?{ttl:i}:void 0;this.cache.set(n,a,t),y("\u7F13\u5B58\u8BBE\u7F6E\u6210\u529F\uFF0CTTL: %s\u79D2",i?i/1e3:"\u9ED8\u8BA4")})}del(e){return d(this,null,function*(){let a=this.normalize(e);y("\u5220\u9664\u7F13\u5B58 key: %s",a),this.cache.delete(a)})}scan(e){return d(this,null,function*(){y("\u626B\u63CF\u7F13\u5B58\u524D\u7F00: %s",e);let a=`${this.prefix}${Pi.default.normalize(e)}`,i=this.cache.keys(),n=[];for(let t of i)typeof t=="string"&&t.startsWith(a)&&n.push(t);return y("\u627E\u5230 %d \u4E2A\u5339\u914D\u952E",n.length),n})}};fe();var Wa=class{handleOperation(e,a){return d(this,null,function*(){switch(y("\u5904\u7406\u7F13\u5B58\u64CD\u4F5C: %s -> %s",e.type,e.path),e.type){case"create":yield this.handleCreate(e,a);break;case"update":yield this.handleUpdate(e,a);break;case"delete":yield this.handleDelete(e,a);break;case"move":yield this.handleMove(e,a);break;case"copy":yield this.handleCopy(e,a);break;case"rename":yield this.handleRename(e,a);break;default:y("\u672A\u77E5\u7684\u7F13\u5B58\u64CD\u4F5C\u7C7B\u578B: %s",e.type)}})}handleCreate(e,a){return d(this,null,function*(){if(!e.parentPath||!e.newItem||!e.fs){y("\u521B\u5EFA\u64CD\u4F5C\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570"),e.parentPath&&(yield a.markForRefresh(e.parentPath));return}let i=yield a.get(e.parentPath);if(i&&Array.isArray(i)){if(i.push(e.newItem),yield a.set(e.parentPath,i),e.newItem&&!e.fs.isFile(e.newItem)){let n=he(e.parentPath,e.fs.getName(e.newItem)),t=n.endsWith("/")?n:`${n}/`;yield a.set(t,[]),n.endsWith("/")||(yield a.set(n,[])),y("\u521B\u5EFA\u4E86\u65B0\u76EE\u5F55\u7F13\u5B58: %s",n)}}else yield a.markForRefresh(e.parentPath)})}handleUpdate(e,a){return d(this,null,function*(){yield a.markForRefresh(e.path),e.parentPath&&(yield a.markForRefresh(e.parentPath))})}handleDelete(e,a){return d(this,null,function*(){if(yield a.invalidate(e.path),y("\u5F00\u59CB\u5904\u7406\u5220\u9664\u64CD\u4F5C: %s",e.path),yield this.cascadeDeleteWithPrefix(a,e.path),e.parentPath&&e.fs){let i=yield a.get(e.parentPath);if(i&&Array.isArray(i)){let[,n]=De(e.path),t=i.findIndex(o=>e.fs.getName(o)===n);t!==-1&&(i.splice(t,1),yield a.set(e.parentPath,i),y("\u4ECE\u7236\u76EE\u5F55\u7F13\u5B58\u4E2D\u79FB\u9664\u4E86\u9879\u76EE: %s",n))}}y("\u5220\u9664\u64CD\u4F5C\u5904\u7406\u5B8C\u6210: %s",e.path)})}cascadeDeleteWithPrefix(e,a){return d(this,null,function*(){yield e.del(a);let i=a.endsWith("/")?a:`${a}/`,n=yield e.scan(i);y(`\u627E\u5230 ${n.length} \u4E2A\u5B50\u8DEF\u5F84\u7F13\u5B58\u9879\u9700\u8981\u5220\u9664`);for(let t of n)try{yield e.del(t),y(`\u7EA7\u8054\u5220\u9664\u5B50\u8DEF\u5F84: ${t}`)}catch(o){y(`\u5220\u9664\u5B50\u8DEF\u5F84 ${t} \u65F6\u51FA\u9519: %o`,o)}y(`\u7EA7\u8054\u5220\u9664\u5B8C\u6210\uFF0C\u5171\u5220\u9664 ${n.length+1} \u4E2A\u7F13\u5B58\u9879`)})}handleMove(e,a){return d(this,null,function*(){if(!e.targetPath){y("\u79FB\u52A8\u64CD\u4F5C\u7F3A\u5C11\u76EE\u6807\u8DEF\u5F84");return}let i=e.result||(yield a.get(e.path));yield this.cascadeDeleteWithPrefix(a,e.path);let n=Y(e.path),t=Y(e.targetPath);yield a.markForRefresh(n),yield a.markForRefresh(t),i?(y("\u79FB\u52A8\u6570\u636E\u5230\u76EE\u6807\u8DEF\u5F84: %s -> %s",e.path,e.targetPath),e.fs&&!e.fs.isFile(i)?(yield a.set(e.targetPath,[]),yield a.markForRefresh(e.targetPath),yield a.markPathsMatching(`${e.targetPath}/*`,1),y("\u79FB\u52A8\u7684\u662F\u76EE\u5F55\uFF0C\u8BBE\u7F6E\u4E3A\u7A7A\u76EE\u5F55\u5E76\u6807\u8BB0\u9700\u8981\u5237\u65B0")):(yield a.set(e.targetPath,i),y("\u79FB\u52A8\u7684\u662F\u6587\u4EF6\uFF0C\u76F4\u63A5\u8BBE\u7F6E\u7F13\u5B58\u6570\u636E"))):(y("\u6CA1\u6709\u53EF\u7528\u7684\u6E90\u6570\u636E\uFF0C\u6807\u8BB0\u76EE\u6807\u8DEF\u5F84\u9700\u8981\u5237\u65B0: %s",e.targetPath),yield a.markForRefresh(e.targetPath),yield a.markPathsMatching(`${e.targetPath}/*`,1))})}handleCopy(e,a){return d(this,null,function*(){if(!e.targetPath){y("\u590D\u5236\u64CD\u4F5C\u7F3A\u5C11\u76EE\u6807\u8DEF\u5F84");return}let i=Y(e.targetPath);yield a.markForRefresh(i);let n=e.result||(yield a.get(e.path));n?(y("\u590D\u5236\u6570\u636E\u5230\u76EE\u6807\u8DEF\u5F84: %s -> %s",e.path,e.targetPath),e.fs&&!e.fs.isFile(n)?(yield a.set(e.targetPath,[]),yield a.markForRefresh(e.targetPath),y("\u590D\u5236\u7684\u662F\u76EE\u5F55\uFF0C\u8BBE\u7F6E\u4E3A\u7A7A\u76EE\u5F55\u5E76\u6807\u8BB0\u9700\u8981\u5237\u65B0")):(yield a.set(e.targetPath,n),y("\u590D\u5236\u7684\u662F\u6587\u4EF6\uFF0C\u76F4\u63A5\u8BBE\u7F6E\u7F13\u5B58\u6570\u636E"))):(y("\u6CA1\u6709\u53EF\u7528\u7684\u6E90\u6570\u636E\uFF0C\u6807\u8BB0\u76EE\u6807\u8DEF\u5F84\u9700\u8981\u5237\u65B0: %s",e.targetPath),yield a.markForRefresh(e.targetPath))})}handleRename(e,a){return d(this,null,function*(){if(!e.newName||!e.fs){y("\u91CD\u547D\u540D\u64CD\u4F5C\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570");return}let i=Y(e.path),[,n]=De(e.path),t=he(i,e.newName),o=yield a.get(i);if(o&&Array.isArray(o)){let r=o.findIndex(p=>e.fs.getName(p)===n);r!==-1&&(o[r]=e.result,yield a.set(i,o),y("\u91CD\u547D\u540D\u64CD\u4F5C\u66F4\u65B0\u4E86\u7236\u76EE\u5F55\u7F13\u5B58"))}else yield a.markForRefresh(i);yield this.cascadeDeleteWithPrefix(a,e.path),yield a.markStatus(t,1),e.result&&!e.fs.isFile(e.result)&&(yield a.set(t,[]))})}};fe();fe();var Ha=class{constructor(){this.cacheDependencies=new Map;this.cacheReverseDependencies=new Map}addDependency(e,a){y("\u6DFB\u52A0\u7F13\u5B58\u4F9D\u8D56: %s \u4F9D\u8D56\u4E8E %s",e,a),this.cacheDependencies.has(a)||this.cacheDependencies.set(a,new Set),this.cacheDependencies.get(a).add(e),this.cacheReverseDependencies.has(e)||this.cacheReverseDependencies.set(e,new Set),this.cacheReverseDependencies.get(e).add(a)}addDependencies(e,a){for(let i of a)this.addDependency(e,i)}addPathHierarchyDependencies(e){let a=M(e);if(a==="/")return;let i=a,n;for(;i!=="/"&&(n=Y(i),n==="."&&(n="/"),n!==i);)y("\u6DFB\u52A0\u8DEF\u5F84\u5C42\u7EA7\u4F9D\u8D56: %s \u4F9D\u8D56\u4E8E %s",i,n),this.addDependency(i,n),i=n}removeDependencies(e){if(this.cacheDependencies.has(e)){let a=this.cacheDependencies.get(e);for(let i of a)this.cacheReverseDependencies.has(i)&&(this.cacheReverseDependencies.get(i).delete(e),this.cacheReverseDependencies.get(i).size===0&&this.cacheReverseDependencies.delete(i));this.cacheDependencies.delete(e)}if(this.cacheReverseDependencies.has(e)){let a=this.cacheReverseDependencies.get(e);for(let i of a)this.cacheDependencies.has(i)&&(this.cacheDependencies.get(i).delete(e),this.cacheDependencies.get(i).size===0&&this.cacheDependencies.delete(i));this.cacheReverseDependencies.delete(e)}}getDependents(e){let a=new Set;return this.collectDependents(e,a),Array.from(a)}collectDependents(e,a){if(!this.cacheDependencies.has(e))return;let i=this.cacheDependencies.get(e);for(let n of i)a.has(n)||(a.add(n),this.collectDependents(n,a))}getDependencies(e){return this.cacheReverseDependencies.has(e)?Array.from(this.cacheReverseDependencies.get(e)):[]}};var Re=class{constructor(e={}){this.inited=!1;this.cacheStatus=new Map;this.dependencyManager=new Ha;this.operationsHandler=new Wa;y("\u521B\u5EFA\u7F13\u5B58\u5B9E\u4F8B\uFF0C\u9009\u9879: %O",e),this.fs=e.fs||{name:"default"},e.strategy?(this.strategy=e.strategy,y("\u4F7F\u7528\u7528\u6237\u63D0\u4F9B\u7684\u7F13\u5B58\u7B56\u7565")):(this.strategy=new Ka(e),y("\u4F7F\u7528\u9ED8\u8BA4LRU\u7F13\u5B58\u7B56\u7565"))}init(){return d(this,null,function*(){return this.inited?(y("\u7F13\u5B58\u5DF2\u521D\u59CB\u5316\uFF0C\u8DF3\u8FC7"),this):(y("\u521D\u59CB\u5316\u7F13\u5B58"),typeof this.strategy.init=="function"&&(yield this.strategy.init()),this.inited=!0,y("\u7F13\u5B58\u521D\u59CB\u5316\u5B8C\u6210"),this)})}fullkey(e){return`${Ba}${this.fs.name}:${e}`}get(e){return d(this,null,function*(){let a=this.fullkey(e);this.inited||(yield this.init());let i=this.cacheStatus.get(a)||0;if(i===2)return y("\u7F13\u5B58\u5DF2\u5931\u6548: %s",a),this.cacheStatus.delete(a),yield this.strategy.del(a),null;let n=yield this.strategy.get(a);return i===1&&n&&(y("\u7F13\u5B58\u9700\u8981\u5237\u65B0: %s",a),this.scheduleRefresh(a)),n})}set(e,a,i){return d(this,null,function*(){this.inited||(yield this.init());let n=this.fullkey(e);yield this.strategy.set(n,a,i),this.cacheStatus.set(n,0),this.dependencyManager.addPathHierarchyDependencies(e)})}del(e){return d(this,null,function*(){this.inited||(yield this.init());let a=this.fullkey(e);yield this.strategy.del(a),this.cacheStatus.delete(a);let i=this.dependencyManager.getDependents(e);for(let n of i){y(`\u7EA7\u8054\u5220\u9664\u4F9D\u8D56\u9879: ${n}`);let t=this.fullkey(n);yield this.strategy.del(t),this.cacheStatus.delete(t)}this.dependencyManager.removeDependencies(e)})}invalidateList(e){return d(this,null,function*(){this.inited||(yield this.init());let a=M(e).replace(/\/+$/,"")||"/",i=this.fullkey(""),n=new Set([this.fullkey(a),this.fullkey(a==="/"?a:`${a}/`)]);for(let t of this.cacheStatus.keys()){let o=t.slice(i.length).replace(/::page=[^:]+::size=[^:]+$/,"");(M(o).replace(/\/+$/,"")||"/")===a&&n.add(t)}for(let t of n)this.cacheStatus.set(t,2),yield this.strategy.del(t),this.cacheStatus.delete(t)})}has(e){return d(this,null,function*(){this.inited||(yield this.init());let a=this.fullkey(e);return this.cacheStatus.get(a)===2?!1:this.strategy.has(a)})}scan(i){return d(this,arguments,function*(e,a={}){this.inited||(yield this.init());let n=this.fullkey(e),t=new Set,o=yield this.strategy.scan(n);for(let p of o)t.add(p);let r=Array.from(t).map(p=>{let l=this.fullkey("").replace(/:$/,"");if(p.startsWith(l))return p.substring(l.length);let u=p.split(":");return u.length>=3?u.slice(2).join(":"):p});return y("\u626B\u63CF\u524D\u7F00 %s \u627E\u5230 %d \u4E2A\u952E",e,r.length),r})}close(){return d(this,null,function*(){this.inited&&(typeof this.strategy.close=="function"&&(yield this.strategy.close()),this.inited=!1,y("\u7F13\u5B58\u5DF2\u5173\u95ED"))})}getStrategy(){return this.strategy}markStatus(e,a){return d(this,null,function*(){let i=this.fullkey(e);if(y("\u6807\u8BB0\u7F13\u5B58\u72B6\u6001: %s -> %s",i,La[a]),this.cacheStatus.set(i,a),a===2){yield this.invalidateChildPaths(e);let n=this.dependencyManager.getDependents(e);for(let t of n){let o=this.fullkey(t);this.cacheStatus.set(o,2),y(`\u6807\u8BB0\u4F9D\u8D56\u9879\u4E3A\u65E0\u6548: ${t}`)}}})}invalidateChildPaths(e){return d(this,null,function*(){let a=e.endsWith("/")?e:`${e}/`,i=yield this.scan(a);y(`\u7EA7\u8054\u6807\u8BB0: \u627E\u5230 ${i.length} \u4E2A\u5B50\u8DEF\u5F84\u9700\u8981\u6807\u8BB0\u4E3A\u65E0\u6548`);for(let n of i){let t=this.fullkey(n);this.cacheStatus.set(t,2),y(`\u7EA7\u8054\u6807\u8BB0\u5B50\u8DEF\u5F84\u4E3A\u65E0\u6548: ${n}`)}})}markPathsMatching(e,a){return d(this,null,function*(){if(this.inited||(yield this.init()),!e.includes("*")){yield this.markStatus(e,a);return}let i=e.replace(/\/\*.*$/,"");y("\u6279\u91CF\u6807\u8BB0\u7F13\u5B58\u72B6\u6001: %s (\u57FA\u7840\u8DEF\u5F84: %s) -> %s",e,i,La[a]);let n=yield this.scan(i);for(let t of n)yield this.markStatus(t,a);y("\u5DF2\u6807\u8BB0 %d \u4E2A\u7F13\u5B58\u9879",n.length)})}markForRefresh(e){return d(this,null,function*(){yield this.markStatus(e,1)})}invalidate(e){return d(this,null,function*(){yield this.markStatus(e,2)})}scheduleRefresh(e){setTimeout(()=>d(this,null,function*(){y("\u5EF6\u8FDF\u5237\u65B0\u7F13\u5B58: %s",e);let a=e.replace(`${Ba}${this.fs.name}:`,"");yield this.del(a)}),100)}handleOperation(e){return d(this,null,function*(){this.inited||(yield this.init()),e.type==="create"&&e.path&&this.dependencyManager.addPathHierarchyDependencies(e.path),yield this.operationsHandler.handleOperation(e,this)})}mkdir(e,a){return d(this,null,function*(){y("\u8C03\u7528\u5DF2\u5F03\u7528\u7684mkdir\u65B9\u6CD5, \u5C06\u8F6C\u6362\u4E3AhandleOperation");let[i,n]=Y(e).split("/").slice(-1);yield this.handleOperation({type:"create",path:e,parentPath:i,newItem:a,fs:{getName:t=>t.name||"",isFile:t=>t.type!=="folder"}})})}remove(e,a){return d(this,null,function*(){if(y("\u8C03\u7528\u5DF2\u5F03\u7528\u7684remove\u65B9\u6CD5, \u5C06\u8F6C\u6362\u4E3AhandleOperation"),Array.isArray(e))for(let i of e)yield this.handleOperation({type:"delete",path:i,parentPath:Y(i),fs:a});else yield this.handleOperation({type:"delete",path:e,parentPath:Y(e),fs:a})})}rename(e,a,i){return d(this,null,function*(){y("\u8C03\u7528\u5DF2\u5F03\u7528\u7684rename\u65B9\u6CD5, \u5C06\u8F6C\u6362\u4E3AhandleOperation");let n=Y(e),t=a.getName(i);yield this.handleOperation({type:"rename",path:e,newName:t,result:i,fs:a})})}move(e,a,i,n,t,o){return d(this,null,function*(){y("\u8C03\u7528\u5DF2\u5F03\u7528\u7684move\u65B9\u6CD5, \u5C06\u8F6C\u6362\u4E3AhandleOperation"),yield this.handleOperation({type:"move",path:e,targetPath:a,result:o,fs:t})})}};var Vi=Re;var rs=/__\[D(\d+)\]__/,Yi=class{constructor(e){L("Creating filesystem: %s (%s)",e.name,e.provider),this.cid=e.cid||cn(8),this.mode=0,this.name=e.name,this.provider=e.provider,this.downExpireTime=1e3*60*30,this.encrypName=!1,this.userConfig=e.userConfig,this.readOnly=!1,this.duplicateList=new Map,this.workPath="/",this.rootPath=e.rootPath||"/",e.ttl&&e.ttl>=1&&(this.cache=new Re({ttl:e.ttl,strategy:e.cacheStrategy,enableDependencyCollection:!0,fs:this})),this.initProxy(e),L("Filesystem created: %s",e.name)}initCache(){L("Initializing cache");let e=this.getCacheKey();this.cache=new Re({ttl:this.downExpireTime,prefix:e}),this.downCache=new Re({ttl:this.downExpireTime,prefix:"download:"+e}),L("Cache initialized with prefix: %s",e)}initProxy(e){L("Initializing auth proxy"),Object.defineProperty(this,"auth",{get:()=>e.auth,set:a=>{e.auth=a}})}parse(e,a,i){return d(this,null,function*(){L("Parsing path: %s (workPath: %s)",a,i),this.duplicateList.clear(),this.getRealPath(a);let n=a;if(this.isRoot(a))return L("Path is root, formatting root"),this.format(this.root,i);a=ci(a),a.unshift("/");let t=this.getRecursiveKey(e||this.root),o=null;L("Starting recursive traversal with rootId: %s",t);for(let r=0;r<a.length;r++){let p=M(a.slice(0,r+1).join("/"));L("Traversing level %d: %s",r,p),o=yield this.getCacheOrFetch(p,t);let l=this.findTarget(o,a[r+1]);if(!l)throw L("Target not found: %s",a[r+1]),new Error(`${a[r]||a[r-1]} not found`);if(this.isFile(l)||r+2===a.length)return L("Found target: %s (isFile: %s)",this.getName(l),this.isFile(l)?"true":"false"),this.format(l,i,t);t=this.getRecursiveKey(l),L("Moving to next level with rootId: %s",t)}})}getCacheOrFetch(e,a){return d(this,null,function*(){L("Getting content for %s (rootId: %s)",e,a);let i=this.getRealPath(e);if(this.cache){let n=yield this.cache.get(i);if(n)return L("Cache hit for %s",i),this.unwrapListPayload(n);{L("Cache miss for %s, fetching data",i);let t=yield this.fetchList(a),o=this.unwrapListPayload(t);return yield this.cache.set(i,o),L("Cached %d items for %s",o.length,i),o}}else return L("No cache available, fetching directly"),this.unwrapListPayload(yield this.fetchList(a))})}isRoot(e){return e===this.rootPath||e==="/"}resolvePath(){return d(this,arguments,function*(e=this.root,a){this.duplicateList.clear();let i=M(he("/",Y(a))),n;if(this.isRoot(M(a)))return this.format(this.root,i);if(this.mode===1){let t=this.getRealPath(a);if(typeof this.get=="function"){let u=yield this.get(e,t);return this.format(u,i)}let[o,r]=De(t),p=yield this.getListByPath(o),l=this.findTarget(p,r);return this.duplicateList.clear(),this.format(l,i)}return yield this.parse(e,a,i)})}list(e,a){return d(this,null,function*(){L("Listing path: %s with options %O",e,a),this.cached=!1;let i=he(e==="/"?"":e);try{let n;if(this.mode===1){L("Using direct mode to list %s",e);let r=this.getRealPath(e);n=yield this.getListByPath(r,a)}else L("Using recursive mode to list %s",e),n=yield this.getListByRecursive(e,a);let t=Array.isArray(n)?n:Array.isArray(n==null?void 0:n.list)?n.list:Array.isArray(n==null?void 0:n.data)?n.data:[],o=this.formatList(t,i,e);return L("Listed %d items at %s",(o==null?void 0:o.length)||0,e),n&&typeof n=="object"&&!Array.isArray(n)&&n.total!=null?{list:o,total:Number(n.total)||o.length}:o}catch(n){throw L("Error listing path %s: %O",e,n),n}finally{this.workPath="/"}})}getListByPath(e,a){return d(this,null,function*(){var p,l;let i=!!(a!=null&&a.pagination),n=Number(((p=a==null?void 0:a.pagination)==null?void 0:p.page)||1)||1,t=Number(((l=a==null?void 0:a.pagination)==null?void 0:l.pageSize)||0)||0,o=i?`${e}::page=${n}::size=${t}`:e,r;if(this.cache){let u=yield this.cache.get(o);u?(this.cached=!0,r=u):(r=yield this.fetchList(e,a),i?yield this.cache.set(o,r):yield this.cache.set(o,this.unwrapListPayload(r)))}else r=yield this.fetchList(e,a);return r})}getListByRecursive(e,a){return d(this,null,function*(){var u,m;let n=(yield this.parse(this.root,e,e)).getRawData(),t=this.getRecursiveKey(n),o=!!(a!=null&&a.pagination),r=Number(((u=a==null?void 0:a.pagination)==null?void 0:u.page)||1)||1,p=Number(((m=a==null?void 0:a.pagination)==null?void 0:m.pageSize)||0)||0,l=o?`${e}::page=${r}::size=${p}`:e;if(this.cache){let x=yield this.cache.get(l);if(x)return x;{let w=yield this.fetchList(t,a);return o?yield this.cache.set(l,w):yield this.cache.set(l,this.unwrapListPayload(w)),w}}else return yield this.fetchList(t,a)})}unwrapListPayload(e){return Array.isArray(e)?e:Array.isArray(e==null?void 0:e.list)?e.list:Array.isArray(e==null?void 0:e.data)?e.data:[]}formatList(e,a,i){return L("Formatting list of %d items for %s",e.length,i),this.duplicateList.clear(),e.map(n=>this.format(n,a))}format(e,a,i){var r,p,l;if(e instanceof Ce)return e;let n=this.getName(e);L("Formatting item: %s",n);let t=this.duplicateList.set(n,(this.duplicateList.get(n)||0)+1);t.get(n)>1&&L("Duplicate detected for %s (count: %d)",n,t.get(n));let o=new Ce({id:this.getId(e),name:n,driver:this.name,size:this.getSize(e)||0,atime:(r=this.getATime)==null?void 0:r.call(this,e),ctime:(p=this.getCTime)==null?void 0:p.call(this,e),mtime:this.getMTime(e),type:this.isFile(e)?this.getExt&&this.getExt(e)||ia(n).slice(1):"folder",rawData:e,parentId:i!=null?i:null,thumbnail:this.getThumbnail?this.getThumbnail(e):null,provider:this.provider,hash:(l=this.getHash)==null?void 0:l.call(this,e),mountPath:this.name,parsePath:a,rootPath:this.rootPath,duplicate:t.get(n),cid:e.__cid});return L("Formatted %s: %s (type: %s)",this.isFile(e)?"file":"folder",o.name,o.type),o}findTarget(e,a){let i=a.match(rs),n=a.replace(/__\[D\d+\]__/,""),t=e.filter(o=>this.getName(o)===n);return t.length>1&&this.duplicateList.set(n,t.length-2),i&&i[1]?t[Number(i[1])]:t[0]}hasMethod(e){return typeof this[e]=="function"}getCacheKey(e=""){return this.name+":"+e}getRealPath(e="/"){return M(he("/",this.rootPath,e))}},Ye=Yi;var ve=class ve{constructor(){}static get(e){return ve.plugins.get(e)}static has(e){return ve.plugins.has(e)}static list(){return Array.from(ve.plugins.values())}static values(){return ve.plugins.values()}static keys(){return ve.plugins.keys()}static entries(){return ve.plugins.entries()}static get size(){return ve.plugins.size}static install(e){var a;ve.plugins.has(e.name)||(ve.plugins.set(e.name,e),(a=e==null?void 0:e.install)==null||a.call(e))}static uninstall(e){var i;let a=ve.plugins.get(e);ve.plugins.delete(e),(i=a==null?void 0:a.uninstall)==null||i.call(a)}onload(){}unload(){}};ve.plugins=new Map;var Qi=ve,Ue=Qi;var cs=new Ce({id:-1,name:"",size:0,byte:0,thumbnail:null,type:"folder",atime:null,ctime:null,mtime:null,rawData:{},provider:"ph",mountPath:"/",parsePath:"/",rootPath:"/"}),Si=class{constructor(e={}){P("Initializing FileBox with options %O",e),this.options=e;let{events:a={},cacheStrategy:i}=e;this.emitter=pn(),Object.entries(a).forEach(([n,t])=>{Array.isArray(t)?t.forEach(o=>{this.emitter.on(n,o)}):typeof t=="function"&&this.emitter.on(n,t)}),this.volumeMap=new Map,i&&(P("Setting up cache strategy"),this.cacheStrategy=i,this.cache=new Re({strategy:this.cacheStrategy})),P("FileBox initialized")}static use(e){return P("Installing module %s",e.name||"unknown"),Ue.install(e),this}getProvider(e){return P("Getting provider %s",e||"default"),e?Ue.get(e):Ue}mount(e){return d(this,null,function*(){var t;if(P("Mounting with options %O",e),Array.isArray(e))return P("Mounting multiple options"),Promise.all(e.map(o=>this.mount(o)));let a=e.name;if(!a||typeof a!="string")throw P("Invalid path: %s",a),new Error(N("InvalidPathError").message);let i=M(a);if(P("Mounting at path: %s",i),this.volumeMap.has(i))return P("Volume already exists at path: %s",i),this.volumeMap.get(i);this.emitter.emit("beforeMount",[i,e]);let n=Ue.get(e.provider);if(n){P("Found provider: %s",e.provider);let o=n.package;e.auth&&(e.auth=Fi(e.auth,()=>d(this,null,function*(){P("Auth updated for %s",a),this.emitter.emit("authChange",[a,e])})))||(e.auth={}),e.cacheStrategy=this.cacheStrategy;let r=new o(e);P("Provider instance created: %s",e.provider),yield(t=r==null?void 0:r.mount)==null?void 0:t.call(r,e),P("Provider mounted: %s",e.provider);let p;return e.readOnly?(P("Creating ReadOnlyVolume for %s",i),p=new gi(i,r,this.emitter)):r instanceof Ye?(P("Creating Volume for %s",i),p=new bi(i,r,this.emitter)):(P("Using provider directly as volume for %s",i),p=r),p._options=e,this.volumeMap.set(i,p),P("Volume registered at %s",i),this.emitter.emit("afterMount",[i,p]),p}else throw P("No provider found for: %s",e.provider),new Error(N("NoMatchingDriverError").message)})}mountRaw(e){P("Raw mounting with options %O",e),e.readOnly=!0,this.mount(e)}unmount(e){return d(this,null,function*(){var n;let a=typeof e=="string"?M(e):M((e==null?void 0:e.name)||""),i=typeof e=="string"?this.volumeMap.get(a):e;P("Unmounting volume %s",a||"unknown"),a&&this.volumeMap.has(a)?(yield(n=i==null?void 0:i.unmount)==null?void 0:n.call(i),this.volumeMap.delete(a),P("Volume %s unmounted",a)):P("Volume %s not found",a||"unknown")})}setCache(e){P("Setting global cache strategy"),this.cacheStrategy=e}getCache(){return this.cacheStrategy}readFile(e){return d(this,null,function*(){P("Reading file: %s",e);let{fs:a,driverPath:i}=this._getProvider(e);this.emitter.emit("beforeReadFile",[e]);let n=yield a.readFile(i);return this.emitter.emit("afterReadFile",[e,n]),n})}stat(e){return d(this,null,function*(){P("Getting stat for: %s",e);let{fs:a,driverPath:i}=this._getProvider(e);if(this.emitter.emit("beforeStat",[e]),!a){P("No fs found, returning root stat");let t=cs;return this.emitter.emit("afterStat",[e,t]),t}let n=yield a.stat(i);return this.emitter.emit("afterStat",[e,n]),n})}list(i){return d(this,arguments,function*(e,a={}){if(e=M(e),P("Listing directory: %s with options %O",e,a),this.emitter.emit("beforeList",[e,a]),e==="/")return P("Listing root volumes"),new Promise(r=>d(this,null,function*(){let{pagination:p={}}=a,l,u,m;if(l=Array.from(this.volumeMap.values()).map(w=>{let S=w._options;return new Ce({id:S.id,name:S.name,size:S.size,byte:S.size,thumbnail:null,type:"folder",atime:null,ctime:S.createdAt,mtime:S.updatedAt,rawData:S,provider:S.provider,mountPath:"/",parsePath:"/",rootPath:S.rootPath})}),P("Found %d volumes",l.length),a.filter){let{unfilteredFiles:w,filteredFiles:S}=Sa(l,a.filter);l=w,m=S,P("Applied filter, %d items remain",l.length)}if(u=l.length,p.page&&p.pageSize&&l.length>p.pageSize){let w=p.pageSize,j=(p.page-1)*w,F=j+w;l=l.slice(j,F),P("Applied pagination, showing items %d to %d",j,F)}let x={data:l,total:u,filter:m};this.emitter.emit("afterList",[e,x]),r(x)}));P("Delegating list to volume for path: %s",e);let{fs:n,driverPath:t}=this._getProvider(e);return yield n.list(t,a)})}mkdir(i){return d(this,arguments,function*(e,a={}){P("Creating directory: %s",typeof e=="string"?e:e.path);let n=typeof e=="string"?e:e.path,{fs:t,driverPath:o}=this._getProvider(n);if(!t)throw P("No provider found for path"),N("ProviderNotFound");this.emitter.emit("beforeMkdir",[n,a]);let r=yield t.mkdir(o,a);return this.emitter.emit("afterMkdir",[n,r]),r})}rename(e,a){return d(this,null,function*(){P("Renaming %s to %s",typeof e=="string"?e:e.path,a);let i=typeof e=="string"?e:e.path,{fs:n,driverPath:t}=this._getProvider(i);if(!n)throw P("No provider found for path"),N("ProviderNotFound");this.emitter.emit("beforeRename",[i,a]);let o=yield n.rename(t,a);return this.emitter.emit("afterRename",[i,a,o]),o})}remove(e){return d(this,null,function*(){P("Removing: %s",typeof e=="string"?e:e.path);let a=typeof e=="string"?e:e.path,{fs:i,driverPath:n}=this._getProvider(a);if(!i)throw P("No provider found for path"),N("ProviderNotFound");this.emitter.emit("beforeRemove",[a]);let t=yield i.remove(n);return this.emitter.emit("afterRemove",[a,t]),t})}upload(e,a,i){return d(this,null,function*(){P("Uploading to: %s",e);let{fs:n,driverPath:t}=this._getProvider(e);this.emitter.emit("beforeUpload",[e,a]);let o=yield n.upload(t,a,i);return this.emitter.emit("afterUpload",[e,o]),o})}download(i){return d(this,arguments,function*(e,a={}){P("Downloading: %s",e);let{fs:n,driverPath:t}=this._getProvider(e);this.emitter.emit("beforeDownload",[e,a]);let o=yield n.download(t,a);return this.emitter.emit("afterDownload",[e,o]),o})}copy(n,t){return d(this,arguments,function*(e,a,i={}){P("Copying from %s to %s",e,a);let{fs:o,driverPath:r}=this._getProvider(e),{driverPath:p}=this._getProvider(a);this.emitter.emit("beforeCopy",[e,a,i]);let l=yield o.copy(r,p,i);return this.emitter.emit("afterCopy",[e,a,l]),l})}move(n,t){return d(this,arguments,function*(e,a,i={}){P("Moving from %s to %s",e,a);let{fs:o,driverPath:r}=this._getProvider(e),{driverPath:p}=this._getProvider(a);this.emitter.emit("beforeMove",[e,a,i]);let l=yield o.move(r,p,i);return this.emitter.emit("afterMove",[e,a,l]),l})}bulkRemove(e){return d(this,null,function*(){var n;if(P("Bulk removing %d items",((n=e.paths)==null?void 0:n.length)||0),e.paths.length===0)return P("No paths to remove"),[];let{paths:a}=e;this.emitter.emit("beforeBulkRemove",[a,e]);let i=[];if(this.fs.hasMethod("bulkRemove"))P("Using native bulkRemove"),i=yield this.fs.bulkRemove(a);else{P("Removing files individually");for(let t of a){let o=yield this.remove({path:t});i.push(o)}}return this.emitter.emit("afterBulkRemove",[a,i]),i})}_getProvider(e){let[a,i]=ba(e);P("Getting provider for path: %s (mountPath: %s, driverPath: %s)",e,a,i),a!=="/"&&!a.startsWith("/")&&(a="/"+a);let n=this.getVolume(a);return P("Found provider: %s",n?"yes":"no"),{fs:n,driverPath:i}}getVolume(e,a){if(P("Getting volume: %s",e||"all"),e){let i=this.volumeMap.get(e);if(i)return i;let n=M(e),t=n!=="/"&&n.startsWith("/")?n.slice(1):n,o=n!=="/"&&!n.startsWith("/")?`/${n}`:n;return this.volumeMap.get(n)||this.volumeMap.get(t)||this.volumeMap.get(o)}return this.volumeMap}};Si.plugin=Ue;var Xi=Si;var ct=ea(ri(),1);fe();var Ji=class extends Ye{getRecursiveKey(e){throw new Error("Method not implemented.")}constructor(e){super(e),this.mode=1}get(e,a){return d(this,null,function*(){let i=yield fetch(this.baseURL+"/"+a,{method:"HEAD"}).then(n=>n.headers);return{name:ba("/").pop()||"/",href:a,mtime:i.get("last-modified"),size:i.get("content-length")||"-",type:ps(i.get("content-type"))}})}link(e){return d(this,null,function*(){return{}})}request(e){return d(this,null,function*(){return fetch(e).then(a=>a.text())})}fetchList(e){return d(this,null,function*(){e=ct.default.join(this.baseURL,e).slice(1);try{let a=yield this.request(e);return this.parseHtml(a)}catch(a){throw new Error(a)}})}parseHtml(e){let{$app:a,$html:i,path:n}=e,t=[];return i("a").each((o,r)=>d(this,null,function*(){let p=i(r).attr("href"),l=i(r).text();try{new URL(p)}catch(u){if(p==="../"||p==="/"||p.startsWith("//"))return;t.push({id:p,thumb:"",name:p,size:"",created:"",mtime:"",ext:"",fullPath:p,type:p.endsWith("/")?"folder":p,bytes:""})}})),t}getThumbnail(e){return e==null?void 0:e.thumb}getId(e){return e==null?void 0:e.id}getName(e){return e==null?void 0:e.name}getSize(e){return e==null?void 0:e.size}getBytes(e){return e==null?void 0:e.bytes}getCreated(e){return e==null?void 0:e.created}getCTime(e){return e==null?void 0:e.mtime}getMTime(e){return e==null?void 0:e.mtime}getExt(e){return e.ext}isFile(e){return e.type!=="folder"}};function ps(s){let e=ta.extension(s);return e==="html"?"folder":e}var Zi=Ji;fe();var en={};si(en,{CONTENT_ENCRYPTION_EXTENSION:()=>$e,DEFAULT_ENCRYPTION_SALT_HEX:()=>ha,FileEncryptor:()=>da,FsCrypt:()=>ma,addContentEncryptionSuffix:()=>Ja,applyEncryptionQueryParams:()=>ei,arrayBufferToBase64Url:()=>Qe,base64UrlToArrayBuffer:()=>ua,calculateEncryptedBytes:()=>Qa,deriveKey:()=>Ie,hexToUint8Array:()=>la,isContentEncryptedName:()=>xa,isContentEncryptionEnabled:()=>Ya,isFilenameEncryptionEnabled:()=>Va,normalizeEncryptionAlgorithm:()=>Le,normalizeEncryptionFeatureEnabled:()=>fa,normalizeEncryptionSaltHex:()=>Ta,normalizePartialEncryption:()=>Ne,parseEncryptionQueryParams:()=>ai,resolveEncryptionProfile:()=>Xa,stripContentEncryptionSuffix:()=>Za});var Ei;if(typeof globalThis!="undefined"&&globalThis.crypto)Ei=globalThis.crypto;else if(typeof window!="undefined"&&window.crypto)Ei=window.crypto;else try{let s=require("crypto");s.webcrypto&&(Ei=s.webcrypto)}catch(s){}var re=Ei;function la(s){let e=new Uint8Array(s.length/2);for(let a=0;a<s.length;a+=2)e[a/2]=parseInt(s.substring(a,a+2),16);return e}function Qe(s){return btoa(String.fromCharCode(...new Uint8Array(s))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function ua(s){let e=s.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4;)e+="=";let a=atob(e),i=new Uint8Array(a.length);for(let n=0;n<a.length;n++)i[n]=a.charCodeAt(n);return i}function Ie(s,e,a=80){return d(this,null,function*(){let n=new TextEncoder().encode(s),t=yield re.subtle.importKey("raw",n.buffer,{name:"PBKDF2"},!1,["deriveBits"]),o=yield re.subtle.deriveBits({name:"PBKDF2",salt:e.buffer,iterations:16384,hash:"SHA-256"},t,a*8);return new Uint8Array(o)})}var Ga=class Ga{constructor(e,a){this.password=e,this.salt=a,this._initialized=!1}init(){return d(this,null,function*(){if(this._initialized)return this;let e=yield Ie(this.password,this.salt,80);this.reversibleKey=e.subarray(64,80),this.iv=new Uint8Array(16).fill(0);for(let a=0;a<12;a++)this.iv[a]=this.salt[a%this.salt.length];return this.filenameMarker=this.createFilenameMarker(),this._initialized=!0,this})}createFilenameMarker(){let e=Qe(this.reversibleKey.subarray(0,6));return`${Ga.FILENAME_MARKER_DELIMITER}${e}${Ga.FILENAME_MARKER_DELIMITER}`}hasCurrentMarker(e){return e.startsWith(this.filenameMarker)}stripCurrentMarker(e){return e.slice(this.filenameMarker.length)}reversibleEncrypt(e){return d(this,null,function*(){if(this._initialized||(yield this.init()),e==="")return"";let i=new TextEncoder().encode(e),n=yield re.subtle.importKey("raw",this.reversibleKey,{name:"AES-CTR"},!1,["encrypt"]),t=yield re.subtle.encrypt({name:"AES-CTR",counter:this.iv,length:64},n,i),o=new Uint8Array(t);return Qe(o)})}reversibleDecrypt(e){return d(this,null,function*(){if(this._initialized||(yield this.init()),e==="")return"";let a=ua(e),i=yield re.subtle.importKey("raw",this.reversibleKey,{name:"AES-CTR"},!1,["decrypt"]),n=yield re.subtle.decrypt({name:"AES-CTR",counter:this.iv,length:64},i,a);return new TextDecoder().decode(n)})}encryptFilename(e){return d(this,null,function*(){return this._initialized||(yield this.init()),e===""?"":`${this.filenameMarker}${yield this.reversibleEncrypt(e)}`})}decryptFilename(e){return d(this,null,function*(){return this._initialized||(yield this.init()),e===""?"":this.hasCurrentMarker(e)?this.reversibleDecrypt(this.stripCurrentMarker(e)):e})}isEncrypted(e){return d(this,null,function*(){if(!e)return!1;try{if(this.hasCurrentMarker(e)){let a=yield this.decryptFilename(e);return!!(a&&a!==e&&(yield this.encryptFilename(a))===e)}return!1}catch(a){return!1}})}};Ga.FILENAME_MARKER_DELIMITER="~";var ma=Ga;function Le(s="AES-CTR"){switch(s.trim().replace(/_/g,"-").toLowerCase()){case"aes-ctr":return"AES-CTR";case"aes-gcm":return"AES-GCM";case"rc4":return"RC4";case"chacha20":case"cha-cha20":return"ChaCha20";default:throw new Error(`\u4E0D\u652F\u6301\u7684\u52A0\u5BC6\u7B97\u6CD5: ${s}`)}}var da=class{constructor(e,a,i="AES-CTR"){this.chunkSize=1024*1024;this.partialEncryption={type:"full"};this.password=e,this.salt=a,this.algorithm=Le(i),this._initialized=!1}init(){return d(this,null,function*(){if(this._initialized)return this;let e=yield Ie(this.password,this.salt,48);this.fileKey=e.subarray(0,32),this.iv=new Uint8Array(16);for(let a=0;a<16;a++)this.iv[a]=this.salt[a%this.salt.length];if(this.algorithm==="AES-CTR"||this.algorithm==="AES-GCM"){let a=this.algorithm==="AES-GCM"?"AES-GCM":"AES-CTR";this.cryptoKey=yield re.subtle.importKey("raw",this.fileKey,{name:a},!1,["encrypt","decrypt"])}return this._initialized=!0,this})}encryptChunk(e,a=0){return d(this,null,function*(){switch(this._initialized||(yield this.init()),this.algorithm){case"AES-CTR":return this._encryptAesCtr(e,a);case"AES-GCM":return this._encryptAesGcm(e,a);case"RC4":return this._encryptRc4(e,a);case"ChaCha20":return this._encryptChaCha20(e,a);default:throw new Error(`\u4E0D\u652F\u6301\u7684\u52A0\u5BC6\u7B97\u6CD5: ${this.algorithm}`)}})}decryptChunk(e,a=0){return d(this,null,function*(){switch(this._initialized||(yield this.init()),this.algorithm){case"AES-CTR":return this._decryptAesCtr(e,a);case"AES-GCM":return this._decryptAesGcm(e,a);case"RC4":return this._decryptRc4(e,a);case"ChaCha20":return this._decryptChaCha20(e,a);default:throw new Error(`\u4E0D\u652F\u6301\u7684\u52A0\u5BC6\u7B97\u6CD5: ${this.algorithm}`)}})}createEncryptStream(e,a){let i=0,n=this,t=a!==void 0?this._calculateEncryptBytes(a):1/0;return new ReadableStream({start(r){return d(this,null,function*(){yield n.init()})},pull(r){return d(this,null,function*(){let p=e.getReader();try{let{done:l,value:u}=yield p.read();if(l){r.close();return}if(i<t){let m=Math.min(u.length,t-i);if(m===u.length){let x=yield n.encryptChunk(u,i);r.enqueue(x)}else{let x=u.slice(0,m),w=u.slice(m),S=yield n.encryptChunk(x,i);r.enqueue(S),r.enqueue(w)}}else r.enqueue(u);i+=u.length}finally{p.releaseLock()}})}})}createDecryptStream(e,a){let i=0,n=this,t=a!==void 0?this._calculateEncryptBytes(a):1/0;return new ReadableStream({start(r){return d(this,null,function*(){yield n.init()})},pull(r){return d(this,null,function*(){let p=e.getReader();try{let{done:l,value:u}=yield p.read();if(l){r.close();return}if(i<t){let m=Math.min(u.length,t-i);if(m===u.length){let x=yield n.decryptChunk(u,i);r.enqueue(x)}else{let x=u.slice(0,m),w=u.slice(m),S=yield n.decryptChunk(x,i);r.enqueue(S),r.enqueue(w)}}else r.enqueue(u);i+=u.length}finally{p.releaseLock()}})}})}encryptBlob(e){return d(this,null,function*(){if(this._initialized||(yield this.init()),this.algorithm==="AES-GCM"){let o=yield e.arrayBuffer(),r=yield this.encryptChunk(new Uint8Array(o),0);return new Blob([ji(r)])}let a=[],i=0,n=e.size,t=this._calculateEncryptBytes(n);for(let o=0;o<n;o+=this.chunkSize){let r=Math.min(o+this.chunkSize,n),p=yield e.slice(o,r).arrayBuffer(),l=new Uint8Array(p);if(i<t){let u=Math.min(l.length,t-i);if(u===l.length){let m=yield this.encryptChunk(l,i);a.push(m)}else{let m=l.slice(0,u),x=l.slice(u),w=yield this.encryptChunk(m,i);a.push(w),a.push(x)}}else a.push(l);i+=l.length}return new Blob(a.map(ji))})}decryptBlob(e){return d(this,null,function*(){if(this._initialized||(yield this.init()),this.algorithm==="AES-GCM"){let o=yield e.arrayBuffer(),r=yield this.decryptChunk(new Uint8Array(o),0);return new Blob([ji(r)])}let a=[],i=0,n=e.size,t=this._calculateEncryptBytes(n);for(let o=0;o<n;o+=this.chunkSize){let r=Math.min(o+this.chunkSize,n),p=yield e.slice(o,r).arrayBuffer(),l=new Uint8Array(p);if(i<t){let u=Math.min(l.length,t-i);if(u===l.length){let m=yield this.decryptChunk(l,i);a.push(m)}else{let m=l.slice(0,u),x=l.slice(u),w=yield this.decryptChunk(m,i);a.push(w),a.push(x)}}else a.push(l);i+=l.length}return new Blob(a.map(ji))})}_getCounter(e){let a=new Uint8Array(16);a.set(this.iv);let n=Math.floor(e/16);for(let t=15;t>=8&&n>0;t--)n+=a[t],a[t]=n&255,n=n>>>8;return a}_encryptAesCtr(e,a){return d(this,null,function*(){let n=a%16;if(n===0){let u=this._getCounter(a),m=yield re.subtle.encrypt({name:"AES-CTR",counter:u,length:64},this.cryptoKey,e);return new Uint8Array(m)}let t=a-n,o=n+e.length,r=new Uint8Array(o);r.set(e,n);let p=this._getCounter(t),l=yield re.subtle.encrypt({name:"AES-CTR",counter:p,length:64},this.cryptoKey,r);return new Uint8Array(l).slice(n)})}_decryptAesCtr(e,a){return d(this,null,function*(){let n=a%16;if(n===0){let u=this._getCounter(a),m=yield re.subtle.decrypt({name:"AES-CTR",counter:u,length:64},this.cryptoKey,e);return new Uint8Array(m)}let t=a-n,o=n+e.length,r=new Uint8Array(o);r.set(e,n);let p=this._getCounter(t),l=yield re.subtle.decrypt({name:"AES-CTR",counter:p,length:64},this.cryptoKey,r);return new Uint8Array(l).slice(n)})}_encryptAesGcm(e,a){return d(this,null,function*(){let i=this._getCounter(a).slice(0,12),n=yield re.subtle.encrypt({name:"AES-GCM",iv:i},this.cryptoKey,e);return new Uint8Array(n)})}_decryptAesGcm(e,a){return d(this,null,function*(){let i=this._getCounter(a).slice(0,12),n=yield re.subtle.decrypt({name:"AES-GCM",iv:i},this.cryptoKey,e);return new Uint8Array(n)})}_encryptRc4(e,a){return d(this,null,function*(){let i=new Uint8Array(256);for(let r=0;r<256;r++)i[r]=r;let n=0;for(let r=0;r<256;r++)n=(n+i[r]+this.fileKey[r%this.fileKey.length])%256,[i[r],i[n]]=[i[n],i[r]];let t=0;n=0;for(let r=0;r<a;r++)t=(t+1)%256,n=(n+i[t])%256,[i[t],i[n]]=[i[n],i[t]];let o=new Uint8Array(e.length);for(let r=0;r<e.length;r++){t=(t+1)%256,n=(n+i[t])%256,[i[t],i[n]]=[i[n],i[t]];let p=i[(i[t]+i[n])%256];o[r]=e[r]^p}return o})}_decryptRc4(e,a){return d(this,null,function*(){return this._encryptRc4(e,a)})}_chacha20QuarterRound(e,a,i,n,t){e[a]=e[a]+e[i]>>>0,e[t]^=e[a],e[t]=(e[t]<<16|e[t]>>>16)>>>0,e[n]=e[n]+e[t]>>>0,e[i]^=e[n],e[i]=(e[i]<<12|e[i]>>>20)>>>0,e[a]=e[a]+e[i]>>>0,e[t]^=e[a],e[t]=(e[t]<<8|e[t]>>>24)>>>0,e[n]=e[n]+e[t]>>>0,e[i]^=e[n],e[i]=(e[i]<<7|e[i]>>>25)>>>0}_chacha20Block(e,a,i){let n=new Uint32Array(16);n[0]=1634760805,n[1]=857760878,n[2]=2036477234,n[3]=1797285236;for(let r=0;r<8;r++)n[4+r]=(e[r*4]|e[r*4+1]<<8|e[r*4+2]<<16|e[r*4+3]<<24)>>>0;n[12]=i>>>0;for(let r=0;r<3;r++)n[13+r]=(a[r*4]|a[r*4+1]<<8|a[r*4+2]<<16|a[r*4+3]<<24)>>>0;let t=new Uint32Array(n);for(let r=0;r<10;r++)this._chacha20QuarterRound(t,0,4,8,12),this._chacha20QuarterRound(t,1,5,9,13),this._chacha20QuarterRound(t,2,6,10,14),this._chacha20QuarterRound(t,3,7,11,15),this._chacha20QuarterRound(t,0,5,10,15),this._chacha20QuarterRound(t,1,6,11,12),this._chacha20QuarterRound(t,2,7,8,13),this._chacha20QuarterRound(t,3,4,9,14);for(let r=0;r<16;r++)t[r]=t[r]+n[r]>>>0;let o=new Uint8Array(64);for(let r=0;r<16;r++)o[r*4]=t[r]&255,o[r*4+1]=t[r]>>>8&255,o[r*4+2]=t[r]>>>16&255,o[r*4+3]=t[r]>>>24&255;return o}_encryptChaCha20(e,a){return d(this,null,function*(){let i=new Uint8Array(32);for(let u=0;u<Math.min(32,this.fileKey.length);u++)i[u]=this.fileKey[u];let n=new Uint8Array(12);for(let u=0;u<Math.min(12,this.iv.length);u++)n[u]=this.iv[u];let t=Math.floor(a/64),o=a%64,r=Math.ceil((o+e.length)/64),p=new Uint8Array(r*64);for(let u=0;u<r;u++){let m=this._chacha20Block(i,n,t+u);p.set(m,u*64)}let l=new Uint8Array(e.length);for(let u=0;u<e.length;u++)l[u]=e[u]^p[o+u];return l})}_decryptChaCha20(e,a){return d(this,null,function*(){return this._encryptChaCha20(e,a)})}setChunkSize(e){this.chunkSize=e}getAlgorithm(){return this.algorithm}setPartialEncryption(e){if(e.type==="percentage"){if(e.percentage===void 0||e.percentage<0||e.percentage>100)throw new Error("\u767E\u5206\u6BD4\u5FC5\u987B\u5728 0-100 \u4E4B\u95F4")}else if(e.type==="size"&&(e.bytes===void 0||e.bytes<0))throw new Error("\u5B57\u8282\u6570\u5FC5\u987B\u5927\u4E8E\u7B49\u4E8E 0");this.partialEncryption=e}getPartialEncryption(){return this.partialEncryption}_calculateEncryptBytes(e){let a=this.partialEncryption;if(a.type==="full")return e;if(a.type==="percentage"){let i=a.percentage||0;return Math.floor(e*i/100)}else if(a.type==="size"){let i=a.bytes||0;return Math.min(i,e)}return e}};function ji(s){return s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength)}var ha="66697865642d73616c742d656d652d636f7272656374",$e=".enc";function ls(s,e=!1){if(typeof s=="boolean")return s;if(typeof s=="number")return s!==0;if(typeof s=="string"){let a=s.trim().toLowerCase();if(!a)return e;if(["true","1","yes","on","enabled"].includes(a))return!0;if(["false","0","no","off","disabled"].includes(a))return!1}return e}function fa(s,e=!1){return ls(s,e)}function Va(s={}){let a=(s.encryption||{}).filename||{};return fa(a.enabled,!1)}function Ya(s={}){let a=(s.encryption||{}).content||{};return fa(a.enabled,!1)}function Ta(s){let e=String(s||"").trim().toLowerCase();return!e||!/^[0-9a-f]+$/i.test(e)||e.length%2!==0?ha:e}function Ne(s){var a,i;if(!s||!s.type||s.type==="full")return{type:"full"};if(s.type==="percentage"){let n=Number((a=s.percentage)!=null?a:0);if(!Number.isFinite(n)||n<0||n>100)throw new Error("\u767E\u5206\u6BD4\u5FC5\u987B\u5728 0-100 \u4E4B\u95F4");return{type:"percentage",percentage:n}}let e=Number((i=s.bytes)!=null?i:0);if(!Number.isFinite(e)||e<0)throw new Error("\u5B57\u8282\u6570\u5FC5\u987B\u5927\u4E8E\u7B49\u4E8E 0");return{type:"size",bytes:e}}function Qa(s,e){var i,n;let a=Ne(e);return a.type==="full"?s:a.type==="percentage"?Math.floor(s*((i=a.percentage)!=null?i:0)/100):Math.min((n=a.bytes)!=null?n:0,s)}function Xa(s={}){let e=Ta(s.salt);return{password:s.password||"",saltHex:e,salt:la(e),algorithm:Le(s.algorithm||void 0),partialEncryption:Ne(s.partialEncryption)}}function xa(s){return typeof s=="string"&&s.endsWith($e)}function Ja(s){return s?xa(s)?s:`${s}${$e}`:$e}function Za(s){return xa(s)?s.slice(0,-$e.length):s}function ei(s,e){var i,n;s.searchParams.set("boxcrypt","1"),s.searchParams.set("encAlgorithm",e.algorithm);let a=Ne(e.partialEncryption);return s.searchParams.set("encType",a.type),a.type==="percentage"?(s.searchParams.set("encPercentage",String((i=a.percentage)!=null?i:0)),s.searchParams.delete("encSize")):a.type==="size"?(s.searchParams.set("encSize",String((n=a.bytes)!=null?n:0)),s.searchParams.delete("encPercentage")):(s.searchParams.delete("encPercentage"),s.searchParams.delete("encSize")),s}function ai(s){if(!(s.searchParams.has("boxcrypt")||s.searchParams.has("encAlgorithm")||s.searchParams.has("encType")))return null;let a=s.searchParams.get("encAlgorithm"),i=s.searchParams.get("encType"),n;return!i||i==="full"?n={type:"full"}:i==="percentage"?n={type:"percentage",percentage:Number(s.searchParams.get("encPercentage")||0)}:i==="size"&&(n={type:"size",bytes:Number(s.searchParams.get("encSize")||0)}),{algorithm:a?Le(a):void 0,partialEncryption:n?Ne(n):void 0}}var us={FileBox:Xi,FileSystem:Ye,HttpFileSystem:Zi,path:pi,Plugin:Ue,type:ta,debug:vi,Cache:Vi};0&&(module.exports={CONTENT_ENCRYPTION_EXTENSION,Cache,DEFAULT_ENCRYPTION_SALT_HEX,FileBox,FileEncryptor,FileSystem,FileSystemType,FsCrypt,HttpFileSystem,Plugin,StatConstructorParams,addContentEncryptionSuffix,applyEncryptionQueryParams,arrayBufferToBase64Url,base64UrlToArrayBuffer,calculateEncryptedBytes,crypt,debug,deriveKey,filterList,hexToUint8Array,isContentEncryptedName,isContentEncryptionEnabled,isFilenameEncryptionEnabled,normalizeEncryptionAlgorithm,normalizeEncryptionFeatureEnabled,normalizeEncryptionSaltHex,normalizePartialEncryption,parseEncryptionQueryParams,path,resolveEncryptionProfile,stripContentEncryptionSuffix,type});
6
+ `).map(e=>e.trim()).join(" ")};Qn.O=function(s){return this.inspectOpts.colors=this.useColors,hi.inspect(s,this.inspectOpts)}});var Jn=de((Ms,$i)=>{typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?$i.exports=Wn():$i.exports=Xn()});var ms={};si(ms,{CONTENT_ENCRYPTION_EXTENSION:()=>$e,Cache:()=>Vi,DEFAULT_ENCRYPTION_SALT_HEX:()=>ha,FileBox:()=>Xi,FileEncryptor:()=>da,FileSystem:()=>Ye,FileSystemType:()=>Ye,FsCrypt:()=>ma,HttpFileSystem:()=>Zi,Plugin:()=>Ue,StatConstructorParams:()=>Ce,addContentEncryptionSuffix:()=>Ja,applyEncryptionQueryParams:()=>ei,arrayBufferToBase64Url:()=>Qe,base64UrlToArrayBuffer:()=>ua,calculateEncryptedBytes:()=>Qa,crypt:()=>en,debug:()=>vi,default:()=>us,deriveKey:()=>Ie,filterList:()=>Sa,hexToUint8Array:()=>la,isContentEncryptedName:()=>xa,isContentEncryptionEnabled:()=>Ya,isFilenameEncryptionEnabled:()=>Va,normalizeEncryptionAlgorithm:()=>Le,normalizeEncryptionFeatureEnabled:()=>fa,normalizeEncryptionSaltHex:()=>Ta,normalizePartialEncryption:()=>Ne,parseEncryptionQueryParams:()=>ai,path:()=>pi,resolveEncryptionProfile:()=>Xa,stripContentEncryptionSuffix:()=>Za,type:()=>ta});module.exports=rn(ms);function Fi(s,e){return new Proxy(s,{set:(a,i,n,t)=>(a[i]=n,e(),Reflect.set(a,i,n,t)),get:(a,i,n)=>{let t=Reflect.get(a,i,n);return typeof t=="object"&&t!==null?Fi(t,e):t}})}function cn(s=32){let e="ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678",a=e.length,i="";for(let n=0;n<s;n++)i+=e.charAt(Math.floor(Math.random()*a));return i}function pn(s){return{all:s=s||new Map,on:function(e,a){var i=s.get(e);i?i.push(a):s.set(e,[a])},off:function(e,a){var i=s.get(e);i&&(a?i.splice(i.indexOf(a)>>>0,1):s.set(e,[]))},emit:function(e,a){var i=s.get(e);i&&i.slice().map(function(n){n(a)}),(i=s.get("*"))&&i.slice().map(function(n){n(e,a)})}}}fe();fe();var vt={ResourceLockedError:"The resource has been locked",NotImplementedError:"Unsupported operation",InvalidPathError:"The path must be a string, for example: /aaa",TargetPathDoesNotExistError:"The target path does not exist",SourcePathDoesNotExistError:"The source path does not exist",NoMatchingCopyStrategyError:"No matching copy strategy found",NoMatchingDriverError:"No matching driver provider found",ReadOnlyError:"Read only error",PathNotFound:"Path Not Found",ProviderNotFound:"Provider Not Found"},gt=(s,e=null)=>({type:s,message:vt[s],data:e}),N=gt;fe();fe();var $n=ea(Pn(),1),Nn=ea(jn(),1);fe();var Ua=ea(Ln(),1),Oi=class{constructor(){this.extToMime=new Map;this.mimeToExt=new Map}register(e,a){let i=e.toLowerCase().replace(/^\./,"");this.extToMime.set(i,a),this.mimeToExt.set(a,i)}registerBatch(e){for(let[a,i]of Object.entries(e))this.register(a,i)}lookup(e){let a=e.toLowerCase().replace(/^\./,"");return this.extToMime.has(a)?this.extToMime.get(a):Ua.default.lookup(e)}extension(e){return this.mimeToExt.has(e)?this.mimeToExt.get(e):Ua.default.extension(e)}contentType(e){if(e.includes(".")||!e.includes("/")){let a=this.lookup(e);if(a)return Ua.default.contentType(a)}return Ua.default.contentType(e)}getCustomTypes(){let e={};for(let[a,i]of this.extToMime.entries())e[a]=i;return e}reset(){this.extToMime.clear(),this.mimeToExt.clear()}},Ft=new Oi,ta=Ft;var ui=Symbol("rawData"),Tt=0,ya;ui;var Ui=class{constructor({id:e,name:a="",size:i,thumbnail:n,type:t,atime:o,ctime:r,mtime:p,rawData:l,provider:u,parentId:m=null,mountPath:x,parsePath:w,rootPath:S,hash:j={},duplicate:F=1,cid:_=null}){D(this,ya);this.id=e,this.fid=Tt++,this.original_name=a;let E=aa(a,ia(a));this.basename=E;let G=ia(a);this.duplicate_flag=F>1?`${E}__[D${F-1}]__${G}`:"",this.name=F===1?a:this.duplicate_flag,this.size=i?Nn.default.format(i):null,this.byte=i,this.thumbnail=n,this.provider=u,this.atime=this.formatDate(o),this.ctime=this.formatDate(r),this.mtime=this.formatDate(p),this.hash=j,this.type=t&&t.toLocaleLowerCase(),C(this,ya,S),this.mountPath=M("/"+x),this.path=this.normalizePath(x,w),this.parent=M(`/${x}/${w}`),this.relative=M(`/${w}/${this.name||""}`),this[ui]=l||null,this.is_duplicate=F>1,this.duplicate_num=F,this.cid=_,this.parentId=m,this.mime=t==="folder"?"application/directory":ta.lookup(a),this.driver_name=x,this.isStat=!0}formatDate(e){return(0,$n.default)(e||new Date(0)).format("YYYY-MM-DD HH:mm:ss")}normalizePath(e,a){return M(`/${e}/${a}/${this.name||""}`)}getRawData(e){return e?this[ui][e]:this[ui]}getParentId(){var e;return(e=this.parentId)!=null?e:null}get file(){return this.type!=="folder"}get directory(){return this.type==="folder"}get rootPath(){return c(this,ya)}get realPath(){return he(c(this,ya),this.relative)}};ya=new WeakMap;var Ce=Ui;var Ia=class{constructor(e=[]){this.__lock=new Set(e)}_getPath(e){return e instanceof Ce?e.realPath:decodeURIComponent(e)}lock(e){let a=this._getPath(e);this.__lock.add(a)}unlock(e){let a=this._getPath(e);this.__lock.delete(a)}isLock(e){let a=this._getPath(e);return this.__lock.has(a)}};var vi={};si(vi,{cacheDebug:()=>y,coreDebug:()=>P,createDebug:()=>oa,default:()=>ts,fsDebug:()=>L,pathDebug:()=>is,pluginDebug:()=>ns,volumeDebug:()=>O});var xi=ea(Jn(),1),oa=s=>(0,xi.default)(`FileBox:${s}`),P=oa("core"),L=oa("fs"),O=oa("volume"),is=oa("path"),y=oa("cache"),ns=oa("plugin");process.env.NODE_ENV==="development"&&xi.default.enable("FileBox:*");var ts=xi.default;fe();function Sa(s,e){let a=0,i,n;e!=null&&e.name&&(a++,i=new RegExp(e.name.replace(/\\\\/g,"\\"))),e!=null&&e.size&&(a++,n=new Function("size",`return ${e.size.replaceAll("${size}","size")};`)),e.type&&a++;let t=[],o=[];return(e==null?void 0:e.mode)==="normal"?s.forEach(r=>{let p=0;i&&i.test(r.name)&&p++,n&&n(r.size)&&p++,e.type&&e.type.split(",").includes(r.type)&&p++,p===0?o.push(r):t.push(r)}):s.forEach(r=>{let p=0;i&&i.test(r.name)&&p++,n&&n(r.size)&&p++,e.type&&e.type.split(",").includes(r.type)&&p++,p!==a?o.push(r):t.push(r)}),{filteredFiles:t,unfilteredFiles:o}}var q=class{constructor(e,a,i){O("Creating BaseVolume with name: %s",e),this.name=M(e||"/"),this._fs=a,this.emitter=i,this.instance=a==null?void 0:a.instance,O("BaseVolume created: %s",this.name)}refresh(e){return d(this,null,function*(){var a,i;if(O("Refreshing cache for path: %s",e),this._fs.cache){yield this._fs.cache.invalidateList(e);let n=(i=(a=this._fs).getRealPath)==null?void 0:i.call(a,e);n&&n!==e&&(yield this._fs.cache.invalidateList(n))}O("Cache refreshed for path: %s",e)})}_get(e){return d(this,null,function*(){return this._fs.mode===0?yield this._fs.parse(this._fs.root,e):yield this.stat(e)})}stat(e){return d(this,null,function*(){O("Getting stat for: %s",typeof e=="string"?e:e.path);try{let a=e instanceof Ce?e:yield this._fs.resolvePath(this._fs.root,decodeURIComponent(e));return O("Stat result: %s",a==null?void 0:a.name),a}catch(a){throw O("Error getting stat: %O",a),a}})}list(i){return d(this,arguments,function*(e,a={}){O("Listing path: %s with options: %O",e,a);let{pagination:n={},sort:t={}}=a,o,r,p;e=typeof e=="string"?decodeURIComponent(e):e.relative;try{let l=yield this._fs.list(e,a),u=Array.isArray(l)?l:Array.isArray(l==null?void 0:l.list)?l.list:Array.isArray(l==null?void 0:l.data)?l.data:[];if(O("Got raw list data with %d items",(u==null?void 0:u.length)||0),o=u,r=l&&typeof l=="object"&&l.total!=null&&Number(l.total)||u.length,a.filter){let{unfilteredFiles:x,filteredFiles:w}=Sa(o,a.filter);o=x,p=w,O("Applied filter, %d items remain",(o==null?void 0:o.length)||0)}if(!(l&&typeof l=="object"&&!Array.isArray(l)&&l.total!=null)&&n.page&&n.pageSize&&o.length>n.pageSize){let x=n.pageSize,S=(n.page-1)*x,j=S+x;o=o.slice(S,j),O("Applied pagination, showing items %d to %d",S,j)}return O("List complete with %d items",(o==null?void 0:o.length)||0),{data:o,total:r,filter:p}}catch(l){throw O("Error listing path: %O",l),l}})}readFile(e){return d(this,null,function*(){if(O("Reading file: %s",e),!this._fs.hasMethod("readFile"))throw O("ReadFile method not implemented"),N("NotImplementedError");let a=1024*10*10;try{let i=yield this.stat(e);if(i.size>a)throw O("File size exceeds limit: %s > %s",i.size,a),new Error(`\u8BFB\u53D6\u7684\u6587\u4EF6\u8D85\u51FA\u6700\u5927\u9650\u5236,${a}`);let n=yield this._fs.readFile(i);return O("File read successfully: %s (%d bytes)",e,(n==null?void 0:n.length)||0),n}catch(i){throw O("Error reading file: %O",i),i}})}hasMethod(e){return this._fs.hasMethod(e)}};q.lock=new Ia;var gi=class extends q{constructor(e,a,i){super(e,a,i)}},bi=class extends q{constructor(e,a,i){super(e,a,i)}mkdir(i){return d(this,arguments,function*(e,a={}){var p;if(O("Creating directory: %s with options %O",e,a),!this._fs.hasMethod("mkdir"))throw O("Mkdir method not implemented"),N("NotImplementedError");let n=typeof e=="string"?e:e.realPath;if(q.lock.isLock(n))throw O("Resource locked: %s",n),N("ResourceLockedError");q.lock.lock(n),O("Acquired lock for: %s",n);let t=typeof e=="string"?decodeURIComponent(e):e.realPath,o,r;try{let[l,u]=De(t);return O("Parent path: %s, item: %s",l,u),a.exist?(O("Checking if directory exists: %s",t),o=yield this.stat(t),o):(O("Getting stat for parent: %s",l),r=yield this.stat(l),O("Creating directory %s in %s",u,l),o=yield this._fs.mkdir(r,u),(p=this._fs)!=null&&p.cache&&(O("Updating cache for new directory: %s",u),yield this._fs.cache.handleOperation({type:"create",path:t,parentPath:l,newItem:o,fs:this._fs})),O("Running afterMkdir hooks"),this.emitter&&typeof this.emitter.emit=="function"&&(yield this.emitter.emit("afterMkdir",r,o)),O("Directory created successfully: %s",t),o)}catch(l){throw O("Error creating directory: %O",l),l}finally{O("Releasing lock for: %s",n),q.lock.unlock(n)}})}rapidUpload(e,a,i){return d(this,null,function*(){if(!this._fs.hasMethod("rapidUpload"))throw N("NotImplementedError");if(q.lock.isLock(e))throw N("ResourceLockedError");q.lock.lock(e);let n=null;try{let t=yield this.stat(e);return n=yield this._fs.rapidUpload(t,a,i),n}catch(t){throw t}finally{q.lock.unlock(e)}})}rename(e,a){return d(this,null,function*(){var n;if(q.lock.isLock(e))throw N("ResourceLockedError");if(q.lock.lock(e),this._fs.readOnly)throw N("ReadOnlyError");if(!this._fs.hasMethod("rename"))throw N("NotImplementedError");let i=null;try{let t=yield this.stat(e);return i=yield this._fs.rename(t,a),(n=this._fs)!=null&&n.cache&&(yield this._fs.cache.handleOperation({type:"rename",path:e,newName:a,result:i,fs:this._fs})),i}catch(t){throw t}finally{q.lock.unlock(e)}})}save(e,a){return d(this,null,function*(){if(!this._fs.hasMethod("save"))throw N("NotImplementedError");try{let i=yield this.stat(a||this._fs.rootPath);return yield this._fs.save(i,e)}catch(i){throw i}})}share(e,a){return d(this,null,function*(){if(!this._fs.hasMethod("share"))throw N("NotImplementedError");try{let i=yield this.stat(a||this._fs.rootPath),n=ti({},e);return n.expire!==void 0&&n.expired===void 0&&(n.expired=n.expire),n.expired!==void 0&&n.expire===void 0&&(n.expire=n.expired),yield this._fs.share(i,n)}catch(i){throw i}})}search(e){return d(this,null,function*(){if(!this._fs.hasMethod("search"))throw N("NotImplementedError");let a=yield this._fs.search(e);return this._fs.formatList(a,"/","/")})}remove(i){return d(this,arguments,function*(e,a={}){var o;if(!this._fs.hasMethod("remove"))throw N("NotImplementedError");if(q.lock.isLock(e))throw N("ResourceLockedError");q.lock.lock(e);let n,t;try{return t=yield this.stat(e),n=yield this._fs.remove(t),(o=this._fs)!=null&&o.cache&&(yield this._fs.cache.handleOperation({type:"delete",path:e,parentPath:Y(e),fs:this._fs})),this.emitter&&typeof this.emitter.emit=="function"&&(yield this.emitter.emit("afterRemove",t,n)),n}catch(r){throw r}finally{q.lock.unlock(e)}})}bulkCopy(n,t){return d(this,arguments,function*(e,a,i={}){var o;if(this._fs.hasMethod("bulkCopy")){let r=yield this.stat(M(a)),p=yield Promise.all(e.map(u=>this.stat(M(u)))),l=yield this._fs.bulkCopy(p,r);if((o=this._fs)!=null&&o.cache)for(let u=0;u<e.length;u++)yield this._fs.cache.handleOperation({type:"copy",path:e[u],targetPath:he(a,aa(e[u])),result:l[u]||l,fs:this._fs});return l}else return yield Promise.all(e.map(p=>this.copy(p,a,i)))})}createUpload(e,a,i){return d(this,null,function*(){return this.upload(e,a,i)})}upload(e,a,i){return d(this,null,function*(){let n=yield this.stat(e),t;try{t=yield this._fs.upload(n,a,i)}catch(o){throw yield this.invalidateUploadCache(e,n),o}if(!this._fs.cache)return t;if(t&&typeof t.upload=="function"){let o=t.upload;t.upload=(...r)=>d(this,null,function*(){try{return yield o.apply(t,r)}finally{yield this.invalidateUploadCache(e,n)}})}else yield this.invalidateUploadCache(e,n);return t})}invalidateUploadCache(e,a){return d(this,null,function*(){let i=this._fs.cache;if(i)try{for(let n of new Set([a.realPath,decodeURIComponent(e)]))yield i.invalidateList(n)}catch(n){O("Disabling upload cache after invalidation failed: %O",n),this._fs.cache===i&&(this._fs.cache=void 0)}})}remoteUpload(e,a){return d(this,null,function*(){let i=typeof e=="string"?decodeURIComponent(e):e.realPath,n=yield this.stat(i);return yield this._fs.remoteUpload(n,a)})}download(i){return d(this,arguments,function*(e,a={}){if(q.lock.isLock(e))throw N("ResourceLockedError");if(q.lock.lock(e),!this._fs.hasMethod("link"))throw N("NotImplementedError");try{let n=yield this.stat(e),t=yield this._fs.link(n);return Array.isArray(t)?t:[t]}catch(n){throw n}finally{q.lock.unlock(e)}})}copy(n,t){return d(this,arguments,function*(e,a,i={}){var o;if(e=M(e),a=M(a),q.lock.isLock(e))throw N("ResourceLockedError");if(q.lock.lock(e),!this._fs.hasMethod("copy"))throw N("NotImplementedError");try{let r=yield this.stat(e),p=yield this.stat(a),l=yield this._fs.copy(r,p);return(o=this._fs)!=null&&o.cache&&(yield this._fs.cache.handleOperation({type:"copy",path:e,targetPath:a,result:l,fs:this._fs})),l}catch(r){throw r}finally{q.lock.unlock(e)}})}move(n,t){return d(this,arguments,function*(e,a,i={}){var o;if(q.lock.isLock(e))throw N("ResourceLockedError");if(q.lock.lock(e),!this._fs.hasMethod("move"))throw N("NotImplementedError");try{let r=yield this.stat(e),p=yield this.stat(a),l=yield this._fs.move(r,p);return(o=this._fs)!=null&&o.cache&&(yield this._fs.cache.handleOperation({type:"move",path:e,targetPath:a,result:l,fs:this._fs})),l}catch(r){throw r}finally{q.lock.unlock(e)}})}bulkRemove(i){return d(this,arguments,function*(e,a={}){var t;let n=[...new Set(e)];if(this._fs.hasMethod("bulkRemove")){let o=yield Promise.all(n.map(p=>this.stat(M(p)))),r=yield this._fs.bulkRemove(o);if((t=this._fs)!=null&&t.cache)for(let p of n)yield this._fs.cache.handleOperation({type:"delete",path:p,parentPath:Y(p),fs:this._fs});return r}else return yield Promise.allSettled(n.map(r=>this.remove(r,a)))})}unmount(){return d(this,null,function*(){var e,a;yield(a=(e=this._fs)==null?void 0:e.unmount)==null?void 0:a.call(e)})}};fe();var La=(i=>(i[i.VALID=0]="VALID",i[i.NEEDS_REFRESH=1]="NEEDS_REFRESH",i[i.INVALID=2]="INVALID",i))(La||{});var Ea=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,tt=new Set,Ni=typeof process=="object"&&process?process:{},st=(s,e,a,i)=>{typeof Ni.emitWarning=="function"&&Ni.emitWarning(s,e,a,i)},ki=globalThis.AbortController,et=globalThis.AbortSignal,at;if(typeof ki=="undefined"){et=class{constructor(){H(this,"onabort");H(this,"_onabort",[]);H(this,"reason");H(this,"aborted",!1)}addEventListener(i,n){this._onabort.push(n)}},ki=class{constructor(){H(this,"signal",new et);e()}abort(i){var n,t;if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=!0;for(let o of this.signal._onabort)o(i);(t=(n=this.signal).onabort)==null||t.call(n,i)}}};let s=((at=Ni.env)==null?void 0:at.LRU_CACHE_IGNORE_AC_WARNING)!=="1",e=()=>{s&&(s=!1,st("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}var ss=s=>!tt.has(s),Js=Symbol("type"),Ke=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),ot=s=>Ke(s)?s<=Math.pow(2,8)?Uint8Array:s<=Math.pow(2,16)?Uint16Array:s<=Math.pow(2,32)?Uint32Array:s<=Number.MAX_SAFE_INTEGER?ja:null:null,ja=class extends Array{constructor(e){super(e),this.fill(0)}},_a,ra=class ra{constructor(e,a){H(this,"heap");H(this,"length");if(!c(ra,_a))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new a(e),this.length=0}static create(e){let a=ot(e);if(!a)return[];C(ra,_a,!0);let i=new ra(e,a);return C(ra,_a,!1),i}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}};_a=new WeakMap,D(ra,_a,!1);var qi=ra,it,nt,Se,ge,Ee,je,Aa,za,J,_e,Q,K,z,pe,be,oe,ie,Ae,ne,ze,Fe,ye,Te,Ve,le,h,Bi,ca,Oe,Na,we,rt,pa,Fa,qa,We,He,Ki,yi,wi,B,Wi,$a,Ge,Hi,Gi=class Gi{constructor(e){D(this,h);D(this,Se);D(this,ge);D(this,Ee);D(this,je);D(this,Aa);D(this,za);H(this,"ttl");H(this,"ttlResolution");H(this,"ttlAutopurge");H(this,"updateAgeOnGet");H(this,"updateAgeOnHas");H(this,"allowStale");H(this,"noDisposeOnSet");H(this,"noUpdateTTL");H(this,"maxEntrySize");H(this,"sizeCalculation");H(this,"noDeleteOnFetchRejection");H(this,"noDeleteOnStaleGet");H(this,"allowStaleOnFetchAbort");H(this,"allowStaleOnFetchRejection");H(this,"ignoreFetchAbort");D(this,J);D(this,_e);D(this,Q);D(this,K);D(this,z);D(this,pe);D(this,be);D(this,oe);D(this,ie);D(this,Ae);D(this,ne);D(this,ze);D(this,Fe);D(this,ye);D(this,Te);D(this,Ve);D(this,le);D(this,ca,()=>{});D(this,Oe,()=>{});D(this,Na,()=>{});D(this,we,()=>!1);D(this,pa,e=>{});D(this,Fa,(e,a,i)=>{});D(this,qa,(e,a,i,n)=>{if(i||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});H(this,it,"LRUCache");let{max:a=0,ttl:i,ttlResolution:n=1,ttlAutopurge:t,updateAgeOnGet:o,updateAgeOnHas:r,allowStale:p,dispose:l,disposeAfter:u,noDisposeOnSet:m,noUpdateTTL:x,maxSize:w=0,maxEntrySize:S=0,sizeCalculation:j,fetchMethod:F,memoMethod:_,noDeleteOnFetchRejection:E,noDeleteOnStaleGet:G,allowStaleOnFetchRejection:W,allowStaleOnFetchAbort:ce,ignoreFetchAbort:X}=e;if(a!==0&&!Ke(a))throw new TypeError("max option must be a nonnegative integer");let ue=a?ot(a):Array;if(!ue)throw new Error("invalid max value: "+a);if(C(this,Se,a),C(this,ge,w),this.maxEntrySize=S||c(this,ge),this.sizeCalculation=j,this.sizeCalculation){if(!c(this,ge)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(_!==void 0&&typeof _!="function")throw new TypeError("memoMethod must be a function if defined");if(C(this,za,_),F!==void 0&&typeof F!="function")throw new TypeError("fetchMethod must be a function if specified");if(C(this,Aa,F),C(this,Ve,!!F),C(this,Q,new Map),C(this,K,new Array(a).fill(void 0)),C(this,z,new Array(a).fill(void 0)),C(this,pe,new ue(a)),C(this,be,new ue(a)),C(this,oe,0),C(this,ie,0),C(this,Ae,qi.create(a)),C(this,J,0),C(this,_e,0),typeof l=="function"&&C(this,Ee,l),typeof u=="function"?(C(this,je,u),C(this,ne,[])):(C(this,je,void 0),C(this,ne,void 0)),C(this,Te,!!c(this,Ee)),C(this,le,!!c(this,je)),this.noDisposeOnSet=!!m,this.noUpdateTTL=!!x,this.noDeleteOnFetchRejection=!!E,this.allowStaleOnFetchRejection=!!W,this.allowStaleOnFetchAbort=!!ce,this.ignoreFetchAbort=!!X,this.maxEntrySize!==0){if(c(this,ge)!==0&&!Ke(c(this,ge)))throw new TypeError("maxSize must be a positive integer if specified");if(!Ke(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");g(this,h,rt).call(this)}if(this.allowStale=!!p,this.noDeleteOnStaleGet=!!G,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!r,this.ttlResolution=Ke(n)||n===0?n:1,this.ttlAutopurge=!!t,this.ttl=i||0,this.ttl){if(!Ke(this.ttl))throw new TypeError("ttl must be a positive integer if specified");g(this,h,Bi).call(this)}if(c(this,Se)===0&&this.ttl===0&&c(this,ge)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!c(this,Se)&&!c(this,ge)){let I="LRU_CACHE_UNBOUNDED";ss(I)&&(tt.add(I),st("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",I,Gi))}}static unsafeExposeInternals(e){return{starts:c(e,Fe),ttls:c(e,ye),sizes:c(e,ze),keyMap:c(e,Q),keyList:c(e,K),valList:c(e,z),next:c(e,pe),prev:c(e,be),get head(){return c(e,oe)},get tail(){return c(e,ie)},free:c(e,Ae),isBackgroundFetch:a=>{var i;return g(i=e,h,B).call(i,a)},backgroundFetch:(a,i,n,t)=>{var o;return g(o=e,h,wi).call(o,a,i,n,t)},moveToTail:a=>{var i;return g(i=e,h,$a).call(i,a)},indexes:a=>{var i;return g(i=e,h,We).call(i,a)},rindexes:a=>{var i;return g(i=e,h,He).call(i,a)},isStale:a=>{var i;return c(i=e,we).call(i,a)}}}get max(){return c(this,Se)}get maxSize(){return c(this,ge)}get calculatedSize(){return c(this,_e)}get size(){return c(this,J)}get fetchMethod(){return c(this,Aa)}get memoMethod(){return c(this,za)}get dispose(){return c(this,Ee)}get disposeAfter(){return c(this,je)}getRemainingTTL(e){return c(this,Q).has(e)?1/0:0}*entries(){for(let e of g(this,h,We).call(this))c(this,z)[e]!==void 0&&c(this,K)[e]!==void 0&&!g(this,h,B).call(this,c(this,z)[e])&&(yield[c(this,K)[e],c(this,z)[e]])}*rentries(){for(let e of g(this,h,He).call(this))c(this,z)[e]!==void 0&&c(this,K)[e]!==void 0&&!g(this,h,B).call(this,c(this,z)[e])&&(yield[c(this,K)[e],c(this,z)[e]])}*keys(){for(let e of g(this,h,We).call(this)){let a=c(this,K)[e];a!==void 0&&!g(this,h,B).call(this,c(this,z)[e])&&(yield a)}}*rkeys(){for(let e of g(this,h,He).call(this)){let a=c(this,K)[e];a!==void 0&&!g(this,h,B).call(this,c(this,z)[e])&&(yield a)}}*values(){for(let e of g(this,h,We).call(this))c(this,z)[e]!==void 0&&!g(this,h,B).call(this,c(this,z)[e])&&(yield c(this,z)[e])}*rvalues(){for(let e of g(this,h,He).call(this))c(this,z)[e]!==void 0&&!g(this,h,B).call(this,c(this,z)[e])&&(yield c(this,z)[e])}[(nt=Symbol.iterator,it=Symbol.toStringTag,nt)](){return this.entries()}find(e,a={}){for(let i of g(this,h,We).call(this)){let n=c(this,z)[i],t=g(this,h,B).call(this,n)?n.__staleWhileFetching:n;if(t!==void 0&&e(t,c(this,K)[i],this))return this.get(c(this,K)[i],a)}}forEach(e,a=this){for(let i of g(this,h,We).call(this)){let n=c(this,z)[i],t=g(this,h,B).call(this,n)?n.__staleWhileFetching:n;t!==void 0&&e.call(a,t,c(this,K)[i],this)}}rforEach(e,a=this){for(let i of g(this,h,He).call(this)){let n=c(this,z)[i],t=g(this,h,B).call(this,n)?n.__staleWhileFetching:n;t!==void 0&&e.call(a,t,c(this,K)[i],this)}}purgeStale(){let e=!1;for(let a of g(this,h,He).call(this,{allowStale:!0}))c(this,we).call(this,a)&&(g(this,h,Ge).call(this,c(this,K)[a],"expire"),e=!0);return e}info(e){let a=c(this,Q).get(e);if(a===void 0)return;let i=c(this,z)[a],n=g(this,h,B).call(this,i)?i.__staleWhileFetching:i;if(n===void 0)return;let t={value:n};if(c(this,ye)&&c(this,Fe)){let o=c(this,ye)[a],r=c(this,Fe)[a];if(o&&r){let p=o-(Ea.now()-r);t.ttl=p,t.start=Date.now()}}return c(this,ze)&&(t.size=c(this,ze)[a]),t}dump(){let e=[];for(let a of g(this,h,We).call(this,{allowStale:!0})){let i=c(this,K)[a],n=c(this,z)[a],t=g(this,h,B).call(this,n)?n.__staleWhileFetching:n;if(t===void 0||i===void 0)continue;let o={value:t};if(c(this,ye)&&c(this,Fe)){o.ttl=c(this,ye)[a];let r=Ea.now()-c(this,Fe)[a];o.start=Math.floor(Date.now()-r)}c(this,ze)&&(o.size=c(this,ze)[a]),e.unshift([i,o])}return e}load(e){this.clear();for(let[a,i]of e){if(i.start){let n=Date.now()-i.start;i.start=Ea.now()-n}this.set(a,i.value,i)}}set(e,a,i={}){var x,w,S,j,F;if(a===void 0)return this.delete(e),this;let{ttl:n=this.ttl,start:t,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:r=this.sizeCalculation,status:p}=i,{noUpdateTTL:l=this.noUpdateTTL}=i,u=c(this,qa).call(this,e,a,i.size||0,r);if(this.maxEntrySize&&u>this.maxEntrySize)return p&&(p.set="miss",p.maxEntrySizeExceeded=!0),g(this,h,Ge).call(this,e,"set"),this;let m=c(this,J)===0?void 0:c(this,Q).get(e);if(m===void 0)m=c(this,J)===0?c(this,ie):c(this,Ae).length!==0?c(this,Ae).pop():c(this,J)===c(this,Se)?g(this,h,yi).call(this,!1):c(this,J),c(this,K)[m]=e,c(this,z)[m]=a,c(this,Q).set(e,m),c(this,pe)[c(this,ie)]=m,c(this,be)[m]=c(this,ie),C(this,ie,m),oi(this,J)._++,c(this,Fa).call(this,m,u,p),p&&(p.set="add"),l=!1;else{g(this,h,$a).call(this,m);let _=c(this,z)[m];if(a!==_){if(c(this,Ve)&&g(this,h,B).call(this,_)){_.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:E}=_;E!==void 0&&!o&&(c(this,Te)&&((x=c(this,Ee))==null||x.call(this,E,e,"set")),c(this,le)&&((w=c(this,ne))==null||w.push([E,e,"set"])))}else o||(c(this,Te)&&((S=c(this,Ee))==null||S.call(this,_,e,"set")),c(this,le)&&((j=c(this,ne))==null||j.push([_,e,"set"])));if(c(this,pa).call(this,m),c(this,Fa).call(this,m,u,p),c(this,z)[m]=a,p){p.set="replace";let E=_&&g(this,h,B).call(this,_)?_.__staleWhileFetching:_;E!==void 0&&(p.oldValue=E)}}else p&&(p.set="update")}if(n!==0&&!c(this,ye)&&g(this,h,Bi).call(this),c(this,ye)&&(l||c(this,Na).call(this,m,n,t),p&&c(this,Oe).call(this,p,m)),!o&&c(this,le)&&c(this,ne)){let _=c(this,ne),E;for(;E=_==null?void 0:_.shift();)(F=c(this,je))==null||F.call(this,...E)}return this}pop(){var e;try{for(;c(this,J);){let a=c(this,z)[c(this,oe)];if(g(this,h,yi).call(this,!0),g(this,h,B).call(this,a)){if(a.__staleWhileFetching)return a.__staleWhileFetching}else if(a!==void 0)return a}}finally{if(c(this,le)&&c(this,ne)){let a=c(this,ne),i;for(;i=a==null?void 0:a.shift();)(e=c(this,je))==null||e.call(this,...i)}}}has(e,a={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:n}=a,t=c(this,Q).get(e);if(t!==void 0){let o=c(this,z)[t];if(g(this,h,B).call(this,o)&&o.__staleWhileFetching===void 0)return!1;if(c(this,we).call(this,t))n&&(n.has="stale",c(this,Oe).call(this,n,t));else return i&&c(this,ca).call(this,t),n&&(n.has="hit",c(this,Oe).call(this,n,t)),!0}else n&&(n.has="miss");return!1}peek(e,a={}){let{allowStale:i=this.allowStale}=a,n=c(this,Q).get(e);if(n===void 0||!i&&c(this,we).call(this,n))return;let t=c(this,z)[n];return g(this,h,B).call(this,t)?t.__staleWhileFetching:t}fetch(i){return d(this,arguments,function*(e,a={}){let{allowStale:n=this.allowStale,updateAgeOnGet:t=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:r=this.ttl,noDisposeOnSet:p=this.noDisposeOnSet,size:l=0,sizeCalculation:u=this.sizeCalculation,noUpdateTTL:m=this.noUpdateTTL,noDeleteOnFetchRejection:x=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:w=this.allowStaleOnFetchRejection,ignoreFetchAbort:S=this.ignoreFetchAbort,allowStaleOnFetchAbort:j=this.allowStaleOnFetchAbort,context:F,forceRefresh:_=!1,status:E,signal:G}=a;if(!c(this,Ve))return E&&(E.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:t,noDeleteOnStaleGet:o,status:E});let W={allowStale:n,updateAgeOnGet:t,noDeleteOnStaleGet:o,ttl:r,noDisposeOnSet:p,size:l,sizeCalculation:u,noUpdateTTL:m,noDeleteOnFetchRejection:x,allowStaleOnFetchRejection:w,allowStaleOnFetchAbort:j,ignoreFetchAbort:S,status:E,signal:G},ce=c(this,Q).get(e);if(ce===void 0){E&&(E.fetch="miss");let X=g(this,h,wi).call(this,e,ce,W,F);return X.__returned=X}else{let X=c(this,z)[ce];if(g(this,h,B).call(this,X)){let Ra=n&&X.__staleWhileFetching!==void 0;return E&&(E.fetch="inflight",Ra&&(E.returnedStale=!0)),Ra?X.__staleWhileFetching:X.__returned=X}let ue=c(this,we).call(this,ce);if(!_&&!ue)return E&&(E.fetch="hit"),g(this,h,$a).call(this,ce),t&&c(this,ca).call(this,ce),E&&c(this,Oe).call(this,E,ce),X;let I=g(this,h,wi).call(this,e,ce,W,F),Xe=I.__staleWhileFetching!==void 0&&n;return E&&(E.fetch=ue?"stale":"refresh",Xe&&ue&&(E.returnedStale=!0)),Xe?I.__staleWhileFetching:I.__returned=I}})}forceFetch(i){return d(this,arguments,function*(e,a={}){let n=yield this.fetch(e,a);if(n===void 0)throw new Error("fetch() returned undefined");return n})}memo(e,a={}){let i=c(this,za);if(!i)throw new Error("no memoMethod provided to constructor");let l=a,{context:n,forceRefresh:t}=l,o=sn(l,["context","forceRefresh"]),r=this.get(e,o);if(!t&&r!==void 0)return r;let p=i(e,r,{options:o,context:n});return this.set(e,p,o),p}get(e,a={}){let{allowStale:i=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:t=this.noDeleteOnStaleGet,status:o}=a,r=c(this,Q).get(e);if(r!==void 0){let p=c(this,z)[r],l=g(this,h,B).call(this,p);return o&&c(this,Oe).call(this,o,r),c(this,we).call(this,r)?(o&&(o.get="stale"),l?(o&&i&&p.__staleWhileFetching!==void 0&&(o.returnedStale=!0),i?p.__staleWhileFetching:void 0):(t||g(this,h,Ge).call(this,e,"expire"),o&&i&&(o.returnedStale=!0),i?p:void 0)):(o&&(o.get="hit"),l?p.__staleWhileFetching:(g(this,h,$a).call(this,r),n&&c(this,ca).call(this,r),p))}else o&&(o.get="miss")}delete(e){return g(this,h,Ge).call(this,e,"delete")}clear(){return g(this,h,Hi).call(this,"delete")}};Se=new WeakMap,ge=new WeakMap,Ee=new WeakMap,je=new WeakMap,Aa=new WeakMap,za=new WeakMap,J=new WeakMap,_e=new WeakMap,Q=new WeakMap,K=new WeakMap,z=new WeakMap,pe=new WeakMap,be=new WeakMap,oe=new WeakMap,ie=new WeakMap,Ae=new WeakMap,ne=new WeakMap,ze=new WeakMap,Fe=new WeakMap,ye=new WeakMap,Te=new WeakMap,Ve=new WeakMap,le=new WeakMap,h=new WeakSet,Bi=function(){let e=new ja(c(this,Se)),a=new ja(c(this,Se));C(this,ye,e),C(this,Fe,a),C(this,Na,(t,o,r=Ea.now())=>{if(a[t]=o!==0?r:0,e[t]=o,o!==0&&this.ttlAutopurge){let p=setTimeout(()=>{c(this,we).call(this,t)&&g(this,h,Ge).call(this,c(this,K)[t],"expire")},o+1);p.unref&&p.unref()}}),C(this,ca,t=>{a[t]=e[t]!==0?Ea.now():0}),C(this,Oe,(t,o)=>{if(e[o]){let r=e[o],p=a[o];if(!r||!p)return;t.ttl=r,t.start=p,t.now=i||n();let l=t.now-p;t.remainingTTL=r-l}});let i=0,n=()=>{let t=Ea.now();if(this.ttlResolution>0){i=t;let o=setTimeout(()=>i=0,this.ttlResolution);o.unref&&o.unref()}return t};this.getRemainingTTL=t=>{let o=c(this,Q).get(t);if(o===void 0)return 0;let r=e[o],p=a[o];if(!r||!p)return 1/0;let l=(i||n())-p;return r-l},C(this,we,t=>{let o=a[t],r=e[t];return!!r&&!!o&&(i||n())-o>r})},ca=new WeakMap,Oe=new WeakMap,Na=new WeakMap,we=new WeakMap,rt=function(){let e=new ja(c(this,Se));C(this,_e,0),C(this,ze,e),C(this,pa,a=>{C(this,_e,c(this,_e)-e[a]),e[a]=0}),C(this,qa,(a,i,n,t)=>{if(g(this,h,B).call(this,i))return 0;if(!Ke(n))if(t){if(typeof t!="function")throw new TypeError("sizeCalculation must be a function");if(n=t(i,a),!Ke(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return n}),C(this,Fa,(a,i,n)=>{if(e[a]=i,c(this,ge)){let t=c(this,ge)-e[a];for(;c(this,_e)>t;)g(this,h,yi).call(this,!0)}C(this,_e,c(this,_e)+e[a]),n&&(n.entrySize=i,n.totalCalculatedSize=c(this,_e))})},pa=new WeakMap,Fa=new WeakMap,qa=new WeakMap,We=function*({allowStale:e=this.allowStale}={}){if(c(this,J))for(let a=c(this,ie);!(!g(this,h,Ki).call(this,a)||((e||!c(this,we).call(this,a))&&(yield a),a===c(this,oe)));)a=c(this,be)[a]},He=function*({allowStale:e=this.allowStale}={}){if(c(this,J))for(let a=c(this,oe);!(!g(this,h,Ki).call(this,a)||((e||!c(this,we).call(this,a))&&(yield a),a===c(this,ie)));)a=c(this,pe)[a]},Ki=function(e){return e!==void 0&&c(this,Q).get(c(this,K)[e])===e},yi=function(e){var t,o;let a=c(this,oe),i=c(this,K)[a],n=c(this,z)[a];return c(this,Ve)&&g(this,h,B).call(this,n)?n.__abortController.abort(new Error("evicted")):(c(this,Te)||c(this,le))&&(c(this,Te)&&((t=c(this,Ee))==null||t.call(this,n,i,"evict")),c(this,le)&&((o=c(this,ne))==null||o.push([n,i,"evict"]))),c(this,pa).call(this,a),e&&(c(this,K)[a]=void 0,c(this,z)[a]=void 0,c(this,Ae).push(a)),c(this,J)===1?(C(this,oe,C(this,ie,0)),c(this,Ae).length=0):C(this,oe,c(this,pe)[a]),c(this,Q).delete(i),oi(this,J)._--,a},wi=function(e,a,i,n){let t=a===void 0?void 0:c(this,z)[a];if(g(this,h,B).call(this,t))return t;let o=new ki,{signal:r}=i;r==null||r.addEventListener("abort",()=>o.abort(r.reason),{signal:o.signal});let p={signal:o.signal,options:i,context:n},l=(j,F=!1)=>{let{aborted:_}=o.signal,E=i.ignoreFetchAbort&&j!==void 0;if(i.status&&(_&&!F?(i.status.fetchAborted=!0,i.status.fetchError=o.signal.reason,E&&(i.status.fetchAbortIgnored=!0)):i.status.fetchResolved=!0),_&&!E&&!F)return m(o.signal.reason);let G=w;return c(this,z)[a]===w&&(j===void 0?G.__staleWhileFetching?c(this,z)[a]=G.__staleWhileFetching:g(this,h,Ge).call(this,e,"fetch"):(i.status&&(i.status.fetchUpdated=!0),this.set(e,j,p.options))),j},u=j=>(i.status&&(i.status.fetchRejected=!0,i.status.fetchError=j),m(j)),m=j=>{let{aborted:F}=o.signal,_=F&&i.allowStaleOnFetchAbort,E=_||i.allowStaleOnFetchRejection,G=E||i.noDeleteOnFetchRejection,W=w;if(c(this,z)[a]===w&&(!G||W.__staleWhileFetching===void 0?g(this,h,Ge).call(this,e,"fetch"):_||(c(this,z)[a]=W.__staleWhileFetching)),E)return i.status&&W.__staleWhileFetching!==void 0&&(i.status.returnedStale=!0),W.__staleWhileFetching;if(W.__returned===W)throw j},x=(j,F)=>{var E;let _=(E=c(this,Aa))==null?void 0:E.call(this,e,t,p);_&&_ instanceof Promise&&_.then(G=>j(G===void 0?void 0:G),F),o.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(j(void 0),i.allowStaleOnFetchAbort&&(j=G=>l(G,!0)))})};i.status&&(i.status.fetchDispatched=!0);let w=new Promise(x).then(l,u),S=Object.assign(w,{__abortController:o,__staleWhileFetching:t,__returned:void 0});return a===void 0?(this.set(e,S,tn(ti({},p.options),{status:void 0})),a=c(this,Q).get(e)):c(this,z)[a]=S,S},B=function(e){if(!c(this,Ve))return!1;let a=e;return!!a&&a instanceof Promise&&a.hasOwnProperty("__staleWhileFetching")&&a.__abortController instanceof ki},Wi=function(e,a){c(this,be)[a]=e,c(this,pe)[e]=a},$a=function(e){e!==c(this,ie)&&(e===c(this,oe)?C(this,oe,c(this,pe)[e]):g(this,h,Wi).call(this,c(this,be)[e],c(this,pe)[e]),g(this,h,Wi).call(this,c(this,ie),e),C(this,ie,e))},Ge=function(e,a){var n,t,o,r;let i=!1;if(c(this,J)!==0){let p=c(this,Q).get(e);if(p!==void 0)if(i=!0,c(this,J)===1)g(this,h,Hi).call(this,a);else{c(this,pa).call(this,p);let l=c(this,z)[p];if(g(this,h,B).call(this,l)?l.__abortController.abort(new Error("deleted")):(c(this,Te)||c(this,le))&&(c(this,Te)&&((n=c(this,Ee))==null||n.call(this,l,e,a)),c(this,le)&&((t=c(this,ne))==null||t.push([l,e,a]))),c(this,Q).delete(e),c(this,K)[p]=void 0,c(this,z)[p]=void 0,p===c(this,ie))C(this,ie,c(this,be)[p]);else if(p===c(this,oe))C(this,oe,c(this,pe)[p]);else{let u=c(this,be)[p];c(this,pe)[u]=c(this,pe)[p];let m=c(this,pe)[p];c(this,be)[m]=c(this,be)[p]}oi(this,J)._--,c(this,Ae).push(p)}}if(c(this,le)&&((o=c(this,ne))!=null&&o.length)){let p=c(this,ne),l;for(;l=p==null?void 0:p.shift();)(r=c(this,je))==null||r.call(this,...l)}return i},Hi=function(e){var a,i,n;for(let t of g(this,h,He).call(this,{allowStale:!0})){let o=c(this,z)[t];if(g(this,h,B).call(this,o))o.__abortController.abort(new Error("deleted"));else{let r=c(this,K)[t];c(this,Te)&&((a=c(this,Ee))==null||a.call(this,o,r,e)),c(this,le)&&((i=c(this,ne))==null||i.push([o,r,e]))}}if(c(this,Q).clear(),c(this,z).fill(void 0),c(this,K).fill(void 0),c(this,ye)&&c(this,Fe)&&(c(this,ye).fill(0),c(this,Fe).fill(0)),c(this,ze)&&c(this,ze).fill(0),C(this,oe,0),C(this,ie,0),c(this,Ae).length=0,C(this,_e,0),C(this,J,0),c(this,le)&&c(this,ne)){let t=c(this,ne),o;for(;o=t==null?void 0:t.shift();)(n=c(this,je))==null||n.call(this,...o)}};var Ci=Gi;var Pi=ea(ri(),1);var Ba="FileBox:";var Ka=class{constructor(e={}){let a={max:e.max||100,maxSize:e.maxSize||500,ttl:e.ttl||36e5,sizeCalculation:e.sizeCalculation||((i,n)=>1)};this.cache=new Ci(a),this.prefix=Ba+(e.prefix||""),y("LRU\u7F13\u5B58\u7B56\u7565\u5DF2\u521B\u5EFA\uFF0C\u524D\u7F00: %s",this.prefix)}normalize(e){return`${this.prefix}${Pi.default.normalize(Pi.default.join(e,"/"))}`}has(e){return d(this,null,function*(){let a=this.normalize(e);return this.cache.has(a)})}get(e){return d(this,null,function*(){let a=this.normalize(e);return y("\u83B7\u53D6\u7F13\u5B58 key: %s",a),this.cache.get(a)})}set(e,a,i){return d(this,null,function*(){if(!a){y("\u6CA1\u6709\u4E3Akey\u63D0\u4F9B\u503C: %s, \u8DF3\u8FC7",e);return}let n=this.normalize(e);y("\u8BBE\u7F6E\u7F13\u5B58 key: %s",n);let t=i?{ttl:i}:void 0;this.cache.set(n,a,t),y("\u7F13\u5B58\u8BBE\u7F6E\u6210\u529F\uFF0CTTL: %s\u79D2",i?i/1e3:"\u9ED8\u8BA4")})}del(e){return d(this,null,function*(){let a=this.normalize(e);y("\u5220\u9664\u7F13\u5B58 key: %s",a),this.cache.delete(a)})}scan(e){return d(this,null,function*(){y("\u626B\u63CF\u7F13\u5B58\u524D\u7F00: %s",e);let a=`${this.prefix}${Pi.default.normalize(e)}`,i=this.cache.keys(),n=[];for(let t of i)typeof t=="string"&&t.startsWith(a)&&n.push(t);return y("\u627E\u5230 %d \u4E2A\u5339\u914D\u952E",n.length),n})}};fe();var Wa=class{handleOperation(e,a){return d(this,null,function*(){switch(y("\u5904\u7406\u7F13\u5B58\u64CD\u4F5C: %s -> %s",e.type,e.path),e.type){case"create":yield this.handleCreate(e,a);break;case"update":yield this.handleUpdate(e,a);break;case"delete":yield this.handleDelete(e,a);break;case"move":yield this.handleMove(e,a);break;case"copy":yield this.handleCopy(e,a);break;case"rename":yield this.handleRename(e,a);break;default:y("\u672A\u77E5\u7684\u7F13\u5B58\u64CD\u4F5C\u7C7B\u578B: %s",e.type)}})}handleCreate(e,a){return d(this,null,function*(){if(!e.parentPath||!e.newItem||!e.fs){y("\u521B\u5EFA\u64CD\u4F5C\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570"),e.parentPath&&(yield a.markForRefresh(e.parentPath));return}let i=yield a.get(e.parentPath);if(i&&Array.isArray(i)){if(i.push(e.newItem),yield a.set(e.parentPath,i),e.newItem&&!e.fs.isFile(e.newItem)){let n=he(e.parentPath,e.fs.getName(e.newItem)),t=n.endsWith("/")?n:`${n}/`;yield a.set(t,[]),n.endsWith("/")||(yield a.set(n,[])),y("\u521B\u5EFA\u4E86\u65B0\u76EE\u5F55\u7F13\u5B58: %s",n)}}else yield a.markForRefresh(e.parentPath)})}handleUpdate(e,a){return d(this,null,function*(){yield a.markForRefresh(e.path),e.parentPath&&(yield a.markForRefresh(e.parentPath))})}handleDelete(e,a){return d(this,null,function*(){if(yield a.invalidate(e.path),y("\u5F00\u59CB\u5904\u7406\u5220\u9664\u64CD\u4F5C: %s",e.path),yield this.cascadeDeleteWithPrefix(a,e.path),e.parentPath&&e.fs){let i=yield a.get(e.parentPath);if(i&&Array.isArray(i)){let[,n]=De(e.path),t=i.findIndex(o=>e.fs.getName(o)===n);t!==-1&&(i.splice(t,1),yield a.set(e.parentPath,i),y("\u4ECE\u7236\u76EE\u5F55\u7F13\u5B58\u4E2D\u79FB\u9664\u4E86\u9879\u76EE: %s",n))}}y("\u5220\u9664\u64CD\u4F5C\u5904\u7406\u5B8C\u6210: %s",e.path)})}cascadeDeleteWithPrefix(e,a){return d(this,null,function*(){yield e.del(a);let i=a.endsWith("/")?a:`${a}/`,n=yield e.scan(i);y(`\u627E\u5230 ${n.length} \u4E2A\u5B50\u8DEF\u5F84\u7F13\u5B58\u9879\u9700\u8981\u5220\u9664`);for(let t of n)try{yield e.del(t),y(`\u7EA7\u8054\u5220\u9664\u5B50\u8DEF\u5F84: ${t}`)}catch(o){y(`\u5220\u9664\u5B50\u8DEF\u5F84 ${t} \u65F6\u51FA\u9519: %o`,o)}y(`\u7EA7\u8054\u5220\u9664\u5B8C\u6210\uFF0C\u5171\u5220\u9664 ${n.length+1} \u4E2A\u7F13\u5B58\u9879`)})}handleMove(e,a){return d(this,null,function*(){if(!e.targetPath){y("\u79FB\u52A8\u64CD\u4F5C\u7F3A\u5C11\u76EE\u6807\u8DEF\u5F84");return}let i=e.result||(yield a.get(e.path));yield this.cascadeDeleteWithPrefix(a,e.path);let n=Y(e.path),t=Y(e.targetPath);yield a.markForRefresh(n),yield a.markForRefresh(t),i?(y("\u79FB\u52A8\u6570\u636E\u5230\u76EE\u6807\u8DEF\u5F84: %s -> %s",e.path,e.targetPath),e.fs&&!e.fs.isFile(i)?(yield a.set(e.targetPath,[]),yield a.markForRefresh(e.targetPath),yield a.markPathsMatching(`${e.targetPath}/*`,1),y("\u79FB\u52A8\u7684\u662F\u76EE\u5F55\uFF0C\u8BBE\u7F6E\u4E3A\u7A7A\u76EE\u5F55\u5E76\u6807\u8BB0\u9700\u8981\u5237\u65B0")):(yield a.set(e.targetPath,i),y("\u79FB\u52A8\u7684\u662F\u6587\u4EF6\uFF0C\u76F4\u63A5\u8BBE\u7F6E\u7F13\u5B58\u6570\u636E"))):(y("\u6CA1\u6709\u53EF\u7528\u7684\u6E90\u6570\u636E\uFF0C\u6807\u8BB0\u76EE\u6807\u8DEF\u5F84\u9700\u8981\u5237\u65B0: %s",e.targetPath),yield a.markForRefresh(e.targetPath),yield a.markPathsMatching(`${e.targetPath}/*`,1))})}handleCopy(e,a){return d(this,null,function*(){if(!e.targetPath){y("\u590D\u5236\u64CD\u4F5C\u7F3A\u5C11\u76EE\u6807\u8DEF\u5F84");return}let i=Y(e.targetPath);yield a.markForRefresh(i);let n=e.result||(yield a.get(e.path));n?(y("\u590D\u5236\u6570\u636E\u5230\u76EE\u6807\u8DEF\u5F84: %s -> %s",e.path,e.targetPath),e.fs&&!e.fs.isFile(n)?(yield a.set(e.targetPath,[]),yield a.markForRefresh(e.targetPath),y("\u590D\u5236\u7684\u662F\u76EE\u5F55\uFF0C\u8BBE\u7F6E\u4E3A\u7A7A\u76EE\u5F55\u5E76\u6807\u8BB0\u9700\u8981\u5237\u65B0")):(yield a.set(e.targetPath,n),y("\u590D\u5236\u7684\u662F\u6587\u4EF6\uFF0C\u76F4\u63A5\u8BBE\u7F6E\u7F13\u5B58\u6570\u636E"))):(y("\u6CA1\u6709\u53EF\u7528\u7684\u6E90\u6570\u636E\uFF0C\u6807\u8BB0\u76EE\u6807\u8DEF\u5F84\u9700\u8981\u5237\u65B0: %s",e.targetPath),yield a.markForRefresh(e.targetPath))})}handleRename(e,a){return d(this,null,function*(){if(!e.newName||!e.fs){y("\u91CD\u547D\u540D\u64CD\u4F5C\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570");return}let i=Y(e.path),[,n]=De(e.path),t=he(i,e.newName),o=yield a.get(i);if(o&&Array.isArray(o)){let r=o.findIndex(p=>e.fs.getName(p)===n);r!==-1&&(o[r]=e.result,yield a.set(i,o),y("\u91CD\u547D\u540D\u64CD\u4F5C\u66F4\u65B0\u4E86\u7236\u76EE\u5F55\u7F13\u5B58"))}else yield a.markForRefresh(i);yield this.cascadeDeleteWithPrefix(a,e.path),yield a.markStatus(t,1),e.result&&!e.fs.isFile(e.result)&&(yield a.set(t,[]))})}};fe();fe();var Ha=class{constructor(){this.cacheDependencies=new Map;this.cacheReverseDependencies=new Map}addDependency(e,a){y("\u6DFB\u52A0\u7F13\u5B58\u4F9D\u8D56: %s \u4F9D\u8D56\u4E8E %s",e,a),this.cacheDependencies.has(a)||this.cacheDependencies.set(a,new Set),this.cacheDependencies.get(a).add(e),this.cacheReverseDependencies.has(e)||this.cacheReverseDependencies.set(e,new Set),this.cacheReverseDependencies.get(e).add(a)}addDependencies(e,a){for(let i of a)this.addDependency(e,i)}addPathHierarchyDependencies(e){let a=M(e);if(a==="/")return;let i=a,n;for(;i!=="/"&&(n=Y(i),n==="."&&(n="/"),n!==i);)y("\u6DFB\u52A0\u8DEF\u5F84\u5C42\u7EA7\u4F9D\u8D56: %s \u4F9D\u8D56\u4E8E %s",i,n),this.addDependency(i,n),i=n}removeDependencies(e){if(this.cacheDependencies.has(e)){let a=this.cacheDependencies.get(e);for(let i of a)this.cacheReverseDependencies.has(i)&&(this.cacheReverseDependencies.get(i).delete(e),this.cacheReverseDependencies.get(i).size===0&&this.cacheReverseDependencies.delete(i));this.cacheDependencies.delete(e)}if(this.cacheReverseDependencies.has(e)){let a=this.cacheReverseDependencies.get(e);for(let i of a)this.cacheDependencies.has(i)&&(this.cacheDependencies.get(i).delete(e),this.cacheDependencies.get(i).size===0&&this.cacheDependencies.delete(i));this.cacheReverseDependencies.delete(e)}}getDependents(e){let a=new Set;return this.collectDependents(e,a),Array.from(a)}collectDependents(e,a){if(!this.cacheDependencies.has(e))return;let i=this.cacheDependencies.get(e);for(let n of i)a.has(n)||(a.add(n),this.collectDependents(n,a))}getDependencies(e){return this.cacheReverseDependencies.has(e)?Array.from(this.cacheReverseDependencies.get(e)):[]}};var Re=class{constructor(e={}){this.inited=!1;this.cacheStatus=new Map;this.dependencyManager=new Ha;this.operationsHandler=new Wa;y("\u521B\u5EFA\u7F13\u5B58\u5B9E\u4F8B\uFF0C\u9009\u9879: %O",e),this.fs=e.fs||{name:"default"},e.strategy?(this.strategy=e.strategy,y("\u4F7F\u7528\u7528\u6237\u63D0\u4F9B\u7684\u7F13\u5B58\u7B56\u7565")):(this.strategy=new Ka(e),y("\u4F7F\u7528\u9ED8\u8BA4LRU\u7F13\u5B58\u7B56\u7565"))}init(){return d(this,null,function*(){return this.inited?(y("\u7F13\u5B58\u5DF2\u521D\u59CB\u5316\uFF0C\u8DF3\u8FC7"),this):(y("\u521D\u59CB\u5316\u7F13\u5B58"),typeof this.strategy.init=="function"&&(yield this.strategy.init()),this.inited=!0,y("\u7F13\u5B58\u521D\u59CB\u5316\u5B8C\u6210"),this)})}fullkey(e){return`${Ba}${this.fs.name}:${e}`}get(e){return d(this,null,function*(){let a=this.fullkey(e);this.inited||(yield this.init());let i=this.cacheStatus.get(a)||0;if(i===2)return y("\u7F13\u5B58\u5DF2\u5931\u6548: %s",a),this.cacheStatus.delete(a),yield this.strategy.del(a),null;let n=yield this.strategy.get(a);return i===1&&n&&(y("\u7F13\u5B58\u9700\u8981\u5237\u65B0: %s",a),this.scheduleRefresh(a)),n})}set(e,a,i){return d(this,null,function*(){this.inited||(yield this.init());let n=this.fullkey(e);yield this.strategy.set(n,a,i),this.cacheStatus.set(n,0),this.dependencyManager.addPathHierarchyDependencies(e)})}del(e){return d(this,null,function*(){this.inited||(yield this.init());let a=this.fullkey(e);yield this.strategy.del(a),this.cacheStatus.delete(a);let i=this.dependencyManager.getDependents(e);for(let n of i){y(`\u7EA7\u8054\u5220\u9664\u4F9D\u8D56\u9879: ${n}`);let t=this.fullkey(n);yield this.strategy.del(t),this.cacheStatus.delete(t)}this.dependencyManager.removeDependencies(e)})}invalidateList(e){return d(this,null,function*(){this.inited||(yield this.init());let a=M(e).replace(/\/+$/,"")||"/",i=this.fullkey(""),n=new Set([this.fullkey(a),this.fullkey(a==="/"?a:`${a}/`)]);for(let t of this.cacheStatus.keys()){let o=t.slice(i.length).replace(/::page=[^:]+::size=[^:]+$/,"");(M(o).replace(/\/+$/,"")||"/")===a&&n.add(t)}for(let t of n)this.cacheStatus.set(t,2),yield this.strategy.del(t),this.cacheStatus.delete(t)})}has(e){return d(this,null,function*(){this.inited||(yield this.init());let a=this.fullkey(e);return this.cacheStatus.get(a)===2?!1:this.strategy.has(a)})}scan(i){return d(this,arguments,function*(e,a={}){this.inited||(yield this.init());let n=this.fullkey(e),t=new Set,o=yield this.strategy.scan(n);for(let p of o)t.add(p);let r=Array.from(t).map(p=>{let l=this.fullkey("").replace(/:$/,"");if(p.startsWith(l))return p.substring(l.length);let u=p.split(":");return u.length>=3?u.slice(2).join(":"):p});return y("\u626B\u63CF\u524D\u7F00 %s \u627E\u5230 %d \u4E2A\u952E",e,r.length),r})}close(){return d(this,null,function*(){this.inited&&(typeof this.strategy.close=="function"&&(yield this.strategy.close()),this.inited=!1,y("\u7F13\u5B58\u5DF2\u5173\u95ED"))})}getStrategy(){return this.strategy}markStatus(e,a){return d(this,null,function*(){let i=this.fullkey(e);if(y("\u6807\u8BB0\u7F13\u5B58\u72B6\u6001: %s -> %s",i,La[a]),this.cacheStatus.set(i,a),a===2){yield this.invalidateChildPaths(e);let n=this.dependencyManager.getDependents(e);for(let t of n){let o=this.fullkey(t);this.cacheStatus.set(o,2),y(`\u6807\u8BB0\u4F9D\u8D56\u9879\u4E3A\u65E0\u6548: ${t}`)}}})}invalidateChildPaths(e){return d(this,null,function*(){let a=e.endsWith("/")?e:`${e}/`,i=yield this.scan(a);y(`\u7EA7\u8054\u6807\u8BB0: \u627E\u5230 ${i.length} \u4E2A\u5B50\u8DEF\u5F84\u9700\u8981\u6807\u8BB0\u4E3A\u65E0\u6548`);for(let n of i){let t=this.fullkey(n);this.cacheStatus.set(t,2),y(`\u7EA7\u8054\u6807\u8BB0\u5B50\u8DEF\u5F84\u4E3A\u65E0\u6548: ${n}`)}})}markPathsMatching(e,a){return d(this,null,function*(){if(this.inited||(yield this.init()),!e.includes("*")){yield this.markStatus(e,a);return}let i=e.replace(/\/\*.*$/,"");y("\u6279\u91CF\u6807\u8BB0\u7F13\u5B58\u72B6\u6001: %s (\u57FA\u7840\u8DEF\u5F84: %s) -> %s",e,i,La[a]);let n=yield this.scan(i);for(let t of n)yield this.markStatus(t,a);y("\u5DF2\u6807\u8BB0 %d \u4E2A\u7F13\u5B58\u9879",n.length)})}markForRefresh(e){return d(this,null,function*(){yield this.markStatus(e,1)})}invalidate(e){return d(this,null,function*(){yield this.markStatus(e,2)})}scheduleRefresh(e){setTimeout(()=>d(this,null,function*(){y("\u5EF6\u8FDF\u5237\u65B0\u7F13\u5B58: %s",e);let a=e.replace(`${Ba}${this.fs.name}:`,"");yield this.del(a)}),100)}handleOperation(e){return d(this,null,function*(){this.inited||(yield this.init()),e.type==="create"&&e.path&&this.dependencyManager.addPathHierarchyDependencies(e.path),yield this.operationsHandler.handleOperation(e,this)})}mkdir(e,a){return d(this,null,function*(){y("\u8C03\u7528\u5DF2\u5F03\u7528\u7684mkdir\u65B9\u6CD5, \u5C06\u8F6C\u6362\u4E3AhandleOperation");let[i,n]=Y(e).split("/").slice(-1);yield this.handleOperation({type:"create",path:e,parentPath:i,newItem:a,fs:{getName:t=>t.name||"",isFile:t=>t.type!=="folder"}})})}remove(e,a){return d(this,null,function*(){if(y("\u8C03\u7528\u5DF2\u5F03\u7528\u7684remove\u65B9\u6CD5, \u5C06\u8F6C\u6362\u4E3AhandleOperation"),Array.isArray(e))for(let i of e)yield this.handleOperation({type:"delete",path:i,parentPath:Y(i),fs:a});else yield this.handleOperation({type:"delete",path:e,parentPath:Y(e),fs:a})})}rename(e,a,i){return d(this,null,function*(){y("\u8C03\u7528\u5DF2\u5F03\u7528\u7684rename\u65B9\u6CD5, \u5C06\u8F6C\u6362\u4E3AhandleOperation");let n=Y(e),t=a.getName(i);yield this.handleOperation({type:"rename",path:e,newName:t,result:i,fs:a})})}move(e,a,i,n,t,o){return d(this,null,function*(){y("\u8C03\u7528\u5DF2\u5F03\u7528\u7684move\u65B9\u6CD5, \u5C06\u8F6C\u6362\u4E3AhandleOperation"),yield this.handleOperation({type:"move",path:e,targetPath:a,result:o,fs:t})})}};var Vi=Re;var rs=/__\[D(\d+)\]__/,Yi=class{constructor(e){L("Creating filesystem: %s (%s)",e.name,e.provider),this.cid=e.cid||cn(8),this.mode=0,this.name=e.name,this.provider=e.provider,this.downExpireTime=1e3*60*30,this.encrypName=!1,this.userConfig=e.userConfig,this.readOnly=!1,this.duplicateList=new Map,this.workPath="/",this.rootPath=e.rootPath||"/",e.ttl&&e.ttl>=1&&(this.cache=new Re({ttl:e.ttl,strategy:e.cacheStrategy,enableDependencyCollection:!0,fs:this})),this.initProxy(e),L("Filesystem created: %s",e.name)}initCache(){L("Initializing cache");let e=this.getCacheKey();this.cache=new Re({ttl:this.downExpireTime,prefix:e}),this.downCache=new Re({ttl:this.downExpireTime,prefix:"download:"+e}),L("Cache initialized with prefix: %s",e)}initProxy(e){L("Initializing auth proxy"),Object.defineProperty(this,"auth",{get:()=>e.auth,set:a=>{e.auth=a}})}parse(e,a,i){return d(this,null,function*(){L("Parsing path: %s (workPath: %s)",a,i),this.duplicateList.clear(),this.getRealPath(a);let n=a;if(this.isRoot(a))return L("Path is root, formatting root"),this.format(this.root,i);a=ci(a),a.unshift("/");let t=this.getRecursiveKey(e||this.root),o=null;L("Starting recursive traversal with rootId: %s",t);for(let r=0;r<a.length;r++){let p=M(a.slice(0,r+1).join("/"));L("Traversing level %d: %s",r,p),o=yield this.getCacheOrFetch(p,t);let l=this.findTarget(o,a[r+1]);if(!l)throw L("Target not found: %s",a[r+1]),new Error(`${a[r]||a[r-1]} not found`);if(this.isFile(l)||r+2===a.length)return L("Found target: %s (isFile: %s)",this.getName(l),this.isFile(l)?"true":"false"),this.format(l,i,t);t=this.getRecursiveKey(l),L("Moving to next level with rootId: %s",t)}})}getCacheOrFetch(e,a){return d(this,null,function*(){L("Getting content for %s (rootId: %s)",e,a);let i=this.getRealPath(e);if(this.cache){let n=yield this.cache.get(i);if(n)return L("Cache hit for %s",i),this.unwrapListPayload(n);{L("Cache miss for %s, fetching data",i);let t=yield this.fetchList(a),o=this.unwrapListPayload(t);return yield this.cache.set(i,o),L("Cached %d items for %s",o.length,i),o}}else return L("No cache available, fetching directly"),this.unwrapListPayload(yield this.fetchList(a))})}isRoot(e){return e===this.rootPath||e==="/"}resolvePath(){return d(this,arguments,function*(e=this.root,a){this.duplicateList.clear();let i=M(he("/",Y(a))),n;if(this.isRoot(M(a)))return this.format(this.root,i);if(this.mode===1){let t=this.getRealPath(a);if(typeof this.get=="function"){let u=yield this.get(e,t);return this.format(u,i)}let[o,r]=De(t),p=yield this.getListByPath(o),l=this.findTarget(p,r);return this.duplicateList.clear(),this.format(l,i)}return yield this.parse(e,a,i)})}list(e,a){return d(this,null,function*(){L("Listing path: %s with options %O",e,a),this.cached=!1;let i=he(e==="/"?"":e);try{let n;if(this.mode===1){L("Using direct mode to list %s",e);let r=this.getRealPath(e);n=yield this.getListByPath(r,a)}else L("Using recursive mode to list %s",e),n=yield this.getListByRecursive(e,a);let t=Array.isArray(n)?n:Array.isArray(n==null?void 0:n.list)?n.list:Array.isArray(n==null?void 0:n.data)?n.data:[],o=this.formatList(t,i,e);return L("Listed %d items at %s",(o==null?void 0:o.length)||0,e),n&&typeof n=="object"&&!Array.isArray(n)&&n.total!=null?{list:o,total:Number(n.total)||o.length}:o}catch(n){throw L("Error listing path %s: %O",e,n),n}finally{this.workPath="/"}})}getListByPath(e,a){return d(this,null,function*(){var p,l;let i=!!(a!=null&&a.pagination),n=Number(((p=a==null?void 0:a.pagination)==null?void 0:p.page)||1)||1,t=Number(((l=a==null?void 0:a.pagination)==null?void 0:l.pageSize)||0)||0,o=i?`${e}::page=${n}::size=${t}`:e,r;if(this.cache){let u=yield this.cache.get(o);u?(this.cached=!0,r=u):(r=yield this.fetchList(e,a),i?yield this.cache.set(o,r):yield this.cache.set(o,this.unwrapListPayload(r)))}else r=yield this.fetchList(e,a);return r})}getListByRecursive(e,a){return d(this,null,function*(){var u,m;let n=(yield this.parse(this.root,e,e)).getRawData(),t=this.getRecursiveKey(n),o=!!(a!=null&&a.pagination),r=Number(((u=a==null?void 0:a.pagination)==null?void 0:u.page)||1)||1,p=Number(((m=a==null?void 0:a.pagination)==null?void 0:m.pageSize)||0)||0,l=o?`${e}::page=${r}::size=${p}`:e;if(this.cache){let x=yield this.cache.get(l);if(x)return x;{let w=yield this.fetchList(t,a);return o?yield this.cache.set(l,w):yield this.cache.set(l,this.unwrapListPayload(w)),w}}else return yield this.fetchList(t,a)})}unwrapListPayload(e){return Array.isArray(e)?e:Array.isArray(e==null?void 0:e.list)?e.list:Array.isArray(e==null?void 0:e.data)?e.data:[]}formatList(e,a,i){return L("Formatting list of %d items for %s",e.length,i),this.duplicateList.clear(),e.map(n=>this.format(n,a))}format(e,a,i){var r,p,l;if(e instanceof Ce)return e;let n=this.getName(e);L("Formatting item: %s",n);let t=this.duplicateList.set(n,(this.duplicateList.get(n)||0)+1);t.get(n)>1&&L("Duplicate detected for %s (count: %d)",n,t.get(n));let o=new Ce({id:this.getId(e),name:n,driver:this.name,size:this.getSize(e)||0,atime:(r=this.getATime)==null?void 0:r.call(this,e),ctime:(p=this.getCTime)==null?void 0:p.call(this,e),mtime:this.getMTime(e),type:this.isFile(e)?this.getExt&&this.getExt(e)||ia(n).slice(1):"folder",rawData:e,parentId:i!=null?i:null,thumbnail:this.getThumbnail?this.getThumbnail(e):null,provider:this.provider,hash:(l=this.getHash)==null?void 0:l.call(this,e),mountPath:this.name,parsePath:a,rootPath:this.rootPath,duplicate:t.get(n),cid:e.__cid});return L("Formatted %s: %s (type: %s)",this.isFile(e)?"file":"folder",o.name,o.type),o}findTarget(e,a){let i=a.match(rs),n=a.replace(/__\[D\d+\]__/,""),t=e.filter(o=>this.getName(o)===n);return t.length>1&&this.duplicateList.set(n,t.length-2),i&&i[1]?t[Number(i[1])]:t[0]}hasMethod(e){return typeof this[e]=="function"}getCacheKey(e=""){return this.name+":"+e}getRealPath(e="/"){return M(he("/",this.rootPath,e))}},Ye=Yi;var ve=class ve{constructor(){}static get(e){return ve.plugins.get(e)}static has(e){return ve.plugins.has(e)}static list(){return Array.from(ve.plugins.values())}static values(){return ve.plugins.values()}static keys(){return ve.plugins.keys()}static entries(){return ve.plugins.entries()}static get size(){return ve.plugins.size}static install(e){var a;ve.plugins.has(e.name)||(ve.plugins.set(e.name,e),(a=e==null?void 0:e.install)==null||a.call(e))}static uninstall(e){var i;let a=ve.plugins.get(e);ve.plugins.delete(e),(i=a==null?void 0:a.uninstall)==null||i.call(a)}onload(){}unload(){}};ve.plugins=new Map;var Qi=ve,Ue=Qi;var cs=new Ce({id:-1,name:"",size:0,byte:0,thumbnail:null,type:"folder",atime:null,ctime:null,mtime:null,rawData:{},provider:"ph",mountPath:"/",parsePath:"/",rootPath:"/"}),Si=class{constructor(e={}){P("Initializing FileBox with options %O",e),this.options=e;let{events:a={},cacheStrategy:i}=e;this.emitter=pn(),Object.entries(a).forEach(([n,t])=>{Array.isArray(t)?t.forEach(o=>{this.emitter.on(n,o)}):typeof t=="function"&&this.emitter.on(n,t)}),this.volumeMap=new Map,i&&(P("Setting up cache strategy"),this.cacheStrategy=i,this.cache=new Re({strategy:this.cacheStrategy})),P("FileBox initialized")}static use(e){return P("Installing module %s",e.name||"unknown"),Ue.install(e),this}getProvider(e){return P("Getting provider %s",e||"default"),e?Ue.get(e):Ue}mount(e){return d(this,null,function*(){var t;if(P("Mounting with options %O",e),Array.isArray(e))return P("Mounting multiple options"),Promise.all(e.map(o=>this.mount(o)));let a=e.name;if(!a||typeof a!="string")throw P("Invalid path: %s",a),new Error(N("InvalidPathError").message);let i=M(a);if(P("Mounting at path: %s",i),this.volumeMap.has(i))return P("Volume already exists at path: %s",i),this.volumeMap.get(i);this.emitter.emit("beforeMount",[i,e]);let n=Ue.get(e.provider);if(n){P("Found provider: %s",e.provider);let o=n.package;e.auth&&(e.auth=Fi(e.auth,()=>d(this,null,function*(){P("Auth updated for %s",a),this.emitter.emit("authChange",[a,e])})))||(e.auth={}),e.cacheStrategy=this.cacheStrategy;let r=new o(e);P("Provider instance created: %s",e.provider),yield(t=r==null?void 0:r.mount)==null?void 0:t.call(r,e),P("Provider mounted: %s",e.provider);let p;return e.readOnly?(P("Creating ReadOnlyVolume for %s",i),p=new gi(i,r,this.emitter)):r instanceof Ye?(P("Creating Volume for %s",i),p=new bi(i,r,this.emitter)):(P("Using provider directly as volume for %s",i),p=r),p._options=e,this.volumeMap.set(i,p),P("Volume registered at %s",i),this.emitter.emit("afterMount",[i,p]),p}else throw P("No provider found for: %s",e.provider),new Error(N("NoMatchingDriverError").message)})}mountRaw(e){P("Raw mounting with options %O",e),e.readOnly=!0,this.mount(e)}unmount(e){return d(this,null,function*(){var n;let a=typeof e=="string"?M(e):M((e==null?void 0:e.name)||""),i=typeof e=="string"?this.volumeMap.get(a):e;P("Unmounting volume %s",a||"unknown"),a&&this.volumeMap.has(a)?(yield(n=i==null?void 0:i.unmount)==null?void 0:n.call(i),this.volumeMap.delete(a),P("Volume %s unmounted",a)):P("Volume %s not found",a||"unknown")})}setCache(e){P("Setting global cache strategy"),this.cacheStrategy=e}getCache(){return this.cacheStrategy}readFile(e){return d(this,null,function*(){P("Reading file: %s",e);let{fs:a,driverPath:i}=this._getProvider(e);this.emitter.emit("beforeReadFile",[e]);let n=yield a.readFile(i);return this.emitter.emit("afterReadFile",[e,n]),n})}stat(e){return d(this,null,function*(){P("Getting stat for: %s",e);let{fs:a,driverPath:i}=this._getProvider(e);if(this.emitter.emit("beforeStat",[e]),!a){P("No fs found, returning root stat");let t=cs;return this.emitter.emit("afterStat",[e,t]),t}let n=yield a.stat(i);return this.emitter.emit("afterStat",[e,n]),n})}list(i){return d(this,arguments,function*(e,a={}){if(e=M(e),P("Listing directory: %s with options %O",e,a),this.emitter.emit("beforeList",[e,a]),e==="/")return P("Listing root volumes"),new Promise(r=>d(this,null,function*(){let{pagination:p={}}=a,l,u,m;if(l=Array.from(this.volumeMap.values()).map(w=>{let S=w._options;return new Ce({id:S.id,name:S.name,size:S.size,byte:S.size,thumbnail:null,type:"folder",atime:null,ctime:S.createdAt,mtime:S.updatedAt,rawData:S,provider:S.provider,mountPath:"/",parsePath:"/",rootPath:S.rootPath})}),P("Found %d volumes",l.length),a.filter){let{unfilteredFiles:w,filteredFiles:S}=Sa(l,a.filter);l=w,m=S,P("Applied filter, %d items remain",l.length)}if(u=l.length,p.page&&p.pageSize&&l.length>p.pageSize){let w=p.pageSize,j=(p.page-1)*w,F=j+w;l=l.slice(j,F),P("Applied pagination, showing items %d to %d",j,F)}let x={data:l,total:u,filter:m};this.emitter.emit("afterList",[e,x]),r(x)}));P("Delegating list to volume for path: %s",e);let{fs:n,driverPath:t}=this._getProvider(e);return yield n.list(t,a)})}mkdir(i){return d(this,arguments,function*(e,a={}){P("Creating directory: %s",typeof e=="string"?e:e.path);let n=typeof e=="string"?e:e.path,{fs:t,driverPath:o}=this._getProvider(n);if(!t)throw P("No provider found for path"),N("ProviderNotFound");this.emitter.emit("beforeMkdir",[n,a]);let r=yield t.mkdir(o,a);return this.emitter.emit("afterMkdir",[n,r]),r})}rename(e,a){return d(this,null,function*(){P("Renaming %s to %s",typeof e=="string"?e:e.path,a);let i=typeof e=="string"?e:e.path,{fs:n,driverPath:t}=this._getProvider(i);if(!n)throw P("No provider found for path"),N("ProviderNotFound");this.emitter.emit("beforeRename",[i,a]);let o=yield n.rename(t,a);return this.emitter.emit("afterRename",[i,a,o]),o})}remove(e){return d(this,null,function*(){P("Removing: %s",typeof e=="string"?e:e.path);let a=typeof e=="string"?e:e.path,{fs:i,driverPath:n}=this._getProvider(a);if(!i)throw P("No provider found for path"),N("ProviderNotFound");this.emitter.emit("beforeRemove",[a]);let t=yield i.remove(n);return this.emitter.emit("afterRemove",[a,t]),t})}upload(e,a,i){return d(this,null,function*(){P("Uploading to: %s",e);let{fs:n,driverPath:t}=this._getProvider(e);this.emitter.emit("beforeUpload",[e,a]);let o=yield n.upload(t,a,i);return this.emitter.emit("afterUpload",[e,o]),o})}download(i){return d(this,arguments,function*(e,a={}){P("Downloading: %s",e);let{fs:n,driverPath:t}=this._getProvider(e);this.emitter.emit("beforeDownload",[e,a]);let o=yield n.download(t,a);return this.emitter.emit("afterDownload",[e,o]),o})}copy(n,t){return d(this,arguments,function*(e,a,i={}){P("Copying from %s to %s",e,a);let{fs:o,driverPath:r}=this._getProvider(e),{driverPath:p}=this._getProvider(a);this.emitter.emit("beforeCopy",[e,a,i]);let l=yield o.copy(r,p,i);return this.emitter.emit("afterCopy",[e,a,l]),l})}move(n,t){return d(this,arguments,function*(e,a,i={}){P("Moving from %s to %s",e,a);let{fs:o,driverPath:r}=this._getProvider(e),{driverPath:p}=this._getProvider(a);this.emitter.emit("beforeMove",[e,a,i]);let l=yield o.move(r,p,i);return this.emitter.emit("afterMove",[e,a,l]),l})}bulkRemove(e){return d(this,null,function*(){var n;if(P("Bulk removing %d items",((n=e.paths)==null?void 0:n.length)||0),e.paths.length===0)return P("No paths to remove"),[];let{paths:a}=e;this.emitter.emit("beforeBulkRemove",[a,e]);let i=[];if(this.fs.hasMethod("bulkRemove"))P("Using native bulkRemove"),i=yield this.fs.bulkRemove(a);else{P("Removing files individually");for(let t of a){let o=yield this.remove({path:t});i.push(o)}}return this.emitter.emit("afterBulkRemove",[a,i]),i})}_getProvider(e){let[a,i]=ba(e);P("Getting provider for path: %s (mountPath: %s, driverPath: %s)",e,a,i),a!=="/"&&!a.startsWith("/")&&(a="/"+a);let n=this.getVolume(a);return P("Found provider: %s",n?"yes":"no"),{fs:n,driverPath:i}}getVolume(e,a){if(P("Getting volume: %s",e||"all"),e){let i=this.volumeMap.get(e);if(i)return i;let n=M(e),t=n!=="/"&&n.startsWith("/")?n.slice(1):n,o=n!=="/"&&!n.startsWith("/")?`/${n}`:n;return this.volumeMap.get(n)||this.volumeMap.get(t)||this.volumeMap.get(o)}return this.volumeMap}};Si.plugin=Ue;var Xi=Si;var ct=ea(ri(),1);fe();var Ji=class extends Ye{getRecursiveKey(e){throw new Error("Method not implemented.")}constructor(e){super(e),this.mode=1}get(e,a){return d(this,null,function*(){let i=yield fetch(this.baseURL+"/"+a,{method:"HEAD"}).then(n=>n.headers);return{name:ba("/").pop()||"/",href:a,mtime:i.get("last-modified"),size:i.get("content-length")||"-",type:ps(i.get("content-type"))}})}link(e){return d(this,null,function*(){return{}})}request(e){return d(this,null,function*(){return fetch(e).then(a=>a.text())})}fetchList(e){return d(this,null,function*(){e=ct.default.join(this.baseURL,e).slice(1);try{let a=yield this.request(e);return this.parseHtml(a)}catch(a){throw new Error(a)}})}parseHtml(e){let{$app:a,$html:i,path:n}=e,t=[];return i("a").each((o,r)=>d(this,null,function*(){let p=i(r).attr("href"),l=i(r).text();try{new URL(p)}catch(u){if(p==="../"||p==="/"||p.startsWith("//"))return;t.push({id:p,thumb:"",name:p,size:"",created:"",mtime:"",ext:"",fullPath:p,type:p.endsWith("/")?"folder":p,bytes:""})}})),t}getThumbnail(e){return e==null?void 0:e.thumb}getId(e){return e==null?void 0:e.id}getName(e){return e==null?void 0:e.name}getSize(e){return e==null?void 0:e.size}getBytes(e){return e==null?void 0:e.bytes}getCreated(e){return e==null?void 0:e.created}getCTime(e){return e==null?void 0:e.mtime}getMTime(e){return e==null?void 0:e.mtime}getExt(e){return e.ext}isFile(e){return e.type!=="folder"}};function ps(s){let e=ta.extension(s);return e==="html"?"folder":e}var Zi=Ji;fe();var en={};si(en,{CONTENT_ENCRYPTION_EXTENSION:()=>$e,DEFAULT_ENCRYPTION_SALT_HEX:()=>ha,FileEncryptor:()=>da,FsCrypt:()=>ma,addContentEncryptionSuffix:()=>Ja,applyEncryptionQueryParams:()=>ei,arrayBufferToBase64Url:()=>Qe,base64UrlToArrayBuffer:()=>ua,calculateEncryptedBytes:()=>Qa,deriveKey:()=>Ie,hexToUint8Array:()=>la,isContentEncryptedName:()=>xa,isContentEncryptionEnabled:()=>Ya,isFilenameEncryptionEnabled:()=>Va,normalizeEncryptionAlgorithm:()=>Le,normalizeEncryptionFeatureEnabled:()=>fa,normalizeEncryptionSaltHex:()=>Ta,normalizePartialEncryption:()=>Ne,parseEncryptionQueryParams:()=>ai,resolveEncryptionProfile:()=>Xa,stripContentEncryptionSuffix:()=>Za});var Ei;if(typeof globalThis!="undefined"&&globalThis.crypto)Ei=globalThis.crypto;else if(typeof window!="undefined"&&window.crypto)Ei=window.crypto;else try{let s=require("crypto");s.webcrypto&&(Ei=s.webcrypto)}catch(s){}var re=Ei;function la(s){let e=new Uint8Array(s.length/2);for(let a=0;a<s.length;a+=2)e[a/2]=parseInt(s.substring(a,a+2),16);return e}function Qe(s){return btoa(String.fromCharCode(...new Uint8Array(s))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function ua(s){let e=s.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4;)e+="=";let a=atob(e),i=new Uint8Array(a.length);for(let n=0;n<a.length;n++)i[n]=a.charCodeAt(n);return i}function Ie(s,e,a=80){return d(this,null,function*(){let n=new TextEncoder().encode(s),t=yield re.subtle.importKey("raw",n.buffer,{name:"PBKDF2"},!1,["deriveBits"]),o=yield re.subtle.deriveBits({name:"PBKDF2",salt:e.buffer,iterations:16384,hash:"SHA-256"},t,a*8);return new Uint8Array(o)})}var Ga=class Ga{constructor(e,a){this.password=e,this.salt=a,this._initialized=!1}init(){return d(this,null,function*(){if(this._initialized)return this;let e=yield Ie(this.password,this.salt,80);this.reversibleKey=e.subarray(64,80),this.iv=new Uint8Array(16).fill(0);for(let a=0;a<12;a++)this.iv[a]=this.salt[a%this.salt.length];return this.filenameMarker=this.createFilenameMarker(),this._initialized=!0,this})}createFilenameMarker(){let e=Qe(this.reversibleKey.subarray(0,6));return`${Ga.FILENAME_MARKER_DELIMITER}${e}${Ga.FILENAME_MARKER_DELIMITER}`}hasCurrentMarker(e){return e.startsWith(this.filenameMarker)}stripCurrentMarker(e){return e.slice(this.filenameMarker.length)}reversibleEncrypt(e){return d(this,null,function*(){if(this._initialized||(yield this.init()),e==="")return"";let i=new TextEncoder().encode(e),n=yield re.subtle.importKey("raw",this.reversibleKey,{name:"AES-CTR"},!1,["encrypt"]),t=yield re.subtle.encrypt({name:"AES-CTR",counter:this.iv,length:64},n,i),o=new Uint8Array(t);return Qe(o)})}reversibleDecrypt(e){return d(this,null,function*(){if(this._initialized||(yield this.init()),e==="")return"";let a=ua(e),i=yield re.subtle.importKey("raw",this.reversibleKey,{name:"AES-CTR"},!1,["decrypt"]),n=yield re.subtle.decrypt({name:"AES-CTR",counter:this.iv,length:64},i,a);return new TextDecoder().decode(n)})}encryptFilename(e){return d(this,null,function*(){return this._initialized||(yield this.init()),e===""?"":`${this.filenameMarker}${yield this.reversibleEncrypt(e)}`})}decryptFilename(e){return d(this,null,function*(){return this._initialized||(yield this.init()),e===""?"":this.hasCurrentMarker(e)?this.reversibleDecrypt(this.stripCurrentMarker(e)):e})}isEncrypted(e){return d(this,null,function*(){if(!e)return!1;try{if(this.hasCurrentMarker(e)){let a=yield this.decryptFilename(e);return!!(a&&a!==e&&(yield this.encryptFilename(a))===e)}return!1}catch(a){return!1}})}};Ga.FILENAME_MARKER_DELIMITER="~";var ma=Ga;function Le(s="AES-CTR"){switch(s.trim().replace(/_/g,"-").toLowerCase()){case"aes-ctr":return"AES-CTR";case"aes-gcm":return"AES-GCM";case"rc4":return"RC4";case"chacha20":case"cha-cha20":return"ChaCha20";default:throw new Error(`\u4E0D\u652F\u6301\u7684\u52A0\u5BC6\u7B97\u6CD5: ${s}`)}}var da=class{constructor(e,a,i="AES-CTR"){this.chunkSize=1024*1024;this.partialEncryption={type:"full"};this.password=e,this.salt=a,this.algorithm=Le(i),this._initialized=!1}init(){return d(this,null,function*(){if(this._initialized)return this;let e=yield Ie(this.password,this.salt,48);this.fileKey=e.subarray(0,32),this.iv=new Uint8Array(16);for(let a=0;a<16;a++)this.iv[a]=this.salt[a%this.salt.length];if(this.algorithm==="AES-CTR"||this.algorithm==="AES-GCM"){let a=this.algorithm==="AES-GCM"?"AES-GCM":"AES-CTR";this.cryptoKey=yield re.subtle.importKey("raw",this.fileKey,{name:a},!1,["encrypt","decrypt"])}return this._initialized=!0,this})}encryptChunk(e,a=0){return d(this,null,function*(){switch(this._initialized||(yield this.init()),this.algorithm){case"AES-CTR":return this._encryptAesCtr(e,a);case"AES-GCM":return this._encryptAesGcm(e,a);case"RC4":return this._encryptRc4(e,a);case"ChaCha20":return this._encryptChaCha20(e,a);default:throw new Error(`\u4E0D\u652F\u6301\u7684\u52A0\u5BC6\u7B97\u6CD5: ${this.algorithm}`)}})}decryptChunk(e,a=0){return d(this,null,function*(){switch(this._initialized||(yield this.init()),this.algorithm){case"AES-CTR":return this._decryptAesCtr(e,a);case"AES-GCM":return this._decryptAesGcm(e,a);case"RC4":return this._decryptRc4(e,a);case"ChaCha20":return this._decryptChaCha20(e,a);default:throw new Error(`\u4E0D\u652F\u6301\u7684\u52A0\u5BC6\u7B97\u6CD5: ${this.algorithm}`)}})}createEncryptStream(e,a){let i=0,n=this,t=a!==void 0?this._calculateEncryptBytes(a):1/0;return new ReadableStream({start(r){return d(this,null,function*(){yield n.init()})},pull(r){return d(this,null,function*(){let p=e.getReader();try{let{done:l,value:u}=yield p.read();if(l){r.close();return}if(i<t){let m=Math.min(u.length,t-i);if(m===u.length){let x=yield n.encryptChunk(u,i);r.enqueue(x)}else{let x=u.slice(0,m),w=u.slice(m),S=yield n.encryptChunk(x,i);r.enqueue(S),r.enqueue(w)}}else r.enqueue(u);i+=u.length}finally{p.releaseLock()}})}})}createDecryptStream(e,a){let i=0,n=this,t=a!==void 0?this._calculateEncryptBytes(a):1/0;return new ReadableStream({start(r){return d(this,null,function*(){yield n.init()})},pull(r){return d(this,null,function*(){let p=e.getReader();try{let{done:l,value:u}=yield p.read();if(l){r.close();return}if(i<t){let m=Math.min(u.length,t-i);if(m===u.length){let x=yield n.decryptChunk(u,i);r.enqueue(x)}else{let x=u.slice(0,m),w=u.slice(m),S=yield n.decryptChunk(x,i);r.enqueue(S),r.enqueue(w)}}else r.enqueue(u);i+=u.length}finally{p.releaseLock()}})}})}encryptBlob(e){return d(this,null,function*(){if(this._initialized||(yield this.init()),this.algorithm==="AES-GCM"){let o=yield e.arrayBuffer(),r=yield this.encryptChunk(new Uint8Array(o),0);return new Blob([ji(r)])}let a=[],i=0,n=e.size,t=this._calculateEncryptBytes(n);for(let o=0;o<n;o+=this.chunkSize){let r=Math.min(o+this.chunkSize,n),p=yield e.slice(o,r).arrayBuffer(),l=new Uint8Array(p);if(i<t){let u=Math.min(l.length,t-i);if(u===l.length){let m=yield this.encryptChunk(l,i);a.push(m)}else{let m=l.slice(0,u),x=l.slice(u),w=yield this.encryptChunk(m,i);a.push(w),a.push(x)}}else a.push(l);i+=l.length}return new Blob(a.map(ji))})}decryptBlob(e){return d(this,null,function*(){if(this._initialized||(yield this.init()),this.algorithm==="AES-GCM"){let o=yield e.arrayBuffer(),r=yield this.decryptChunk(new Uint8Array(o),0);return new Blob([ji(r)])}let a=[],i=0,n=e.size,t=this._calculateEncryptBytes(n);for(let o=0;o<n;o+=this.chunkSize){let r=Math.min(o+this.chunkSize,n),p=yield e.slice(o,r).arrayBuffer(),l=new Uint8Array(p);if(i<t){let u=Math.min(l.length,t-i);if(u===l.length){let m=yield this.decryptChunk(l,i);a.push(m)}else{let m=l.slice(0,u),x=l.slice(u),w=yield this.decryptChunk(m,i);a.push(w),a.push(x)}}else a.push(l);i+=l.length}return new Blob(a.map(ji))})}_getCounter(e){let a=new Uint8Array(16);a.set(this.iv);let n=Math.floor(e/16);for(let t=15;t>=8&&n>0;t--)n+=a[t],a[t]=n&255,n=n>>>8;return a}_encryptAesCtr(e,a){return d(this,null,function*(){let n=a%16;if(n===0){let u=this._getCounter(a),m=yield re.subtle.encrypt({name:"AES-CTR",counter:u,length:64},this.cryptoKey,e);return new Uint8Array(m)}let t=a-n,o=n+e.length,r=new Uint8Array(o);r.set(e,n);let p=this._getCounter(t),l=yield re.subtle.encrypt({name:"AES-CTR",counter:p,length:64},this.cryptoKey,r);return new Uint8Array(l).slice(n)})}_decryptAesCtr(e,a){return d(this,null,function*(){let n=a%16;if(n===0){let u=this._getCounter(a),m=yield re.subtle.decrypt({name:"AES-CTR",counter:u,length:64},this.cryptoKey,e);return new Uint8Array(m)}let t=a-n,o=n+e.length,r=new Uint8Array(o);r.set(e,n);let p=this._getCounter(t),l=yield re.subtle.decrypt({name:"AES-CTR",counter:p,length:64},this.cryptoKey,r);return new Uint8Array(l).slice(n)})}_encryptAesGcm(e,a){return d(this,null,function*(){let i=this._getCounter(a).slice(0,12),n=yield re.subtle.encrypt({name:"AES-GCM",iv:i},this.cryptoKey,e);return new Uint8Array(n)})}_decryptAesGcm(e,a){return d(this,null,function*(){let i=this._getCounter(a).slice(0,12),n=yield re.subtle.decrypt({name:"AES-GCM",iv:i},this.cryptoKey,e);return new Uint8Array(n)})}_encryptRc4(e,a){return d(this,null,function*(){let i=new Uint8Array(256);for(let r=0;r<256;r++)i[r]=r;let n=0;for(let r=0;r<256;r++)n=(n+i[r]+this.fileKey[r%this.fileKey.length])%256,[i[r],i[n]]=[i[n],i[r]];let t=0;n=0;for(let r=0;r<a;r++)t=(t+1)%256,n=(n+i[t])%256,[i[t],i[n]]=[i[n],i[t]];let o=new Uint8Array(e.length);for(let r=0;r<e.length;r++){t=(t+1)%256,n=(n+i[t])%256,[i[t],i[n]]=[i[n],i[t]];let p=i[(i[t]+i[n])%256];o[r]=e[r]^p}return o})}_decryptRc4(e,a){return d(this,null,function*(){return this._encryptRc4(e,a)})}_chacha20QuarterRound(e,a,i,n,t){e[a]=e[a]+e[i]>>>0,e[t]^=e[a],e[t]=(e[t]<<16|e[t]>>>16)>>>0,e[n]=e[n]+e[t]>>>0,e[i]^=e[n],e[i]=(e[i]<<12|e[i]>>>20)>>>0,e[a]=e[a]+e[i]>>>0,e[t]^=e[a],e[t]=(e[t]<<8|e[t]>>>24)>>>0,e[n]=e[n]+e[t]>>>0,e[i]^=e[n],e[i]=(e[i]<<7|e[i]>>>25)>>>0}_chacha20Block(e,a,i){let n=new Uint32Array(16);n[0]=1634760805,n[1]=857760878,n[2]=2036477234,n[3]=1797285236;for(let r=0;r<8;r++)n[4+r]=(e[r*4]|e[r*4+1]<<8|e[r*4+2]<<16|e[r*4+3]<<24)>>>0;n[12]=i>>>0;for(let r=0;r<3;r++)n[13+r]=(a[r*4]|a[r*4+1]<<8|a[r*4+2]<<16|a[r*4+3]<<24)>>>0;let t=new Uint32Array(n);for(let r=0;r<10;r++)this._chacha20QuarterRound(t,0,4,8,12),this._chacha20QuarterRound(t,1,5,9,13),this._chacha20QuarterRound(t,2,6,10,14),this._chacha20QuarterRound(t,3,7,11,15),this._chacha20QuarterRound(t,0,5,10,15),this._chacha20QuarterRound(t,1,6,11,12),this._chacha20QuarterRound(t,2,7,8,13),this._chacha20QuarterRound(t,3,4,9,14);for(let r=0;r<16;r++)t[r]=t[r]+n[r]>>>0;let o=new Uint8Array(64);for(let r=0;r<16;r++)o[r*4]=t[r]&255,o[r*4+1]=t[r]>>>8&255,o[r*4+2]=t[r]>>>16&255,o[r*4+3]=t[r]>>>24&255;return o}_encryptChaCha20(e,a){return d(this,null,function*(){let i=new Uint8Array(32);for(let u=0;u<Math.min(32,this.fileKey.length);u++)i[u]=this.fileKey[u];let n=new Uint8Array(12);for(let u=0;u<Math.min(12,this.iv.length);u++)n[u]=this.iv[u];let t=Math.floor(a/64),o=a%64,r=Math.ceil((o+e.length)/64),p=new Uint8Array(r*64);for(let u=0;u<r;u++){let m=this._chacha20Block(i,n,t+u);p.set(m,u*64)}let l=new Uint8Array(e.length);for(let u=0;u<e.length;u++)l[u]=e[u]^p[o+u];return l})}_decryptChaCha20(e,a){return d(this,null,function*(){return this._encryptChaCha20(e,a)})}setChunkSize(e){this.chunkSize=e}getAlgorithm(){return this.algorithm}setPartialEncryption(e){if(e.type==="percentage"){if(e.percentage===void 0||e.percentage<0||e.percentage>100)throw new Error("\u767E\u5206\u6BD4\u5FC5\u987B\u5728 0-100 \u4E4B\u95F4")}else if(e.type==="size"&&(e.bytes===void 0||e.bytes<0))throw new Error("\u5B57\u8282\u6570\u5FC5\u987B\u5927\u4E8E\u7B49\u4E8E 0");this.partialEncryption=e}getPartialEncryption(){return this.partialEncryption}_calculateEncryptBytes(e){let a=this.partialEncryption;if(a.type==="full")return e;if(a.type==="percentage"){let i=a.percentage||0;return Math.floor(e*i/100)}else if(a.type==="size"){let i=a.bytes||0;return Math.min(i,e)}return e}};function ji(s){return s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength)}var ha="66697865642d73616c742d656d652d636f7272656374",$e=".enc";function ls(s,e=!1){if(typeof s=="boolean")return s;if(typeof s=="number")return s!==0;if(typeof s=="string"){let a=s.trim().toLowerCase();if(!a)return e;if(["true","1","yes","on","enabled"].includes(a))return!0;if(["false","0","no","off","disabled"].includes(a))return!1}return e}function fa(s,e=!1){return ls(s,e)}function Va(s={}){let a=(s.encryption||{}).filename||{};return fa(a.enabled,!1)}function Ya(s={}){let a=(s.encryption||{}).content||{};return fa(a.enabled,!1)}function Ta(s){let e=String(s||"").trim().toLowerCase();return!e||!/^[0-9a-f]+$/i.test(e)||e.length%2!==0?ha:e}function Ne(s){var a,i;if(!s||!s.type||s.type==="full")return{type:"full"};if(s.type==="percentage"){let n=Number((a=s.percentage)!=null?a:0);if(!Number.isFinite(n)||n<0||n>100)throw new Error("\u767E\u5206\u6BD4\u5FC5\u987B\u5728 0-100 \u4E4B\u95F4");return{type:"percentage",percentage:n}}let e=Number((i=s.bytes)!=null?i:0);if(!Number.isFinite(e)||e<0)throw new Error("\u5B57\u8282\u6570\u5FC5\u987B\u5927\u4E8E\u7B49\u4E8E 0");return{type:"size",bytes:e}}function Qa(s,e){var i,n;let a=Ne(e);return a.type==="full"?s:a.type==="percentage"?Math.floor(s*((i=a.percentage)!=null?i:0)/100):Math.min((n=a.bytes)!=null?n:0,s)}function Xa(s={}){let e=Ta(s.salt);return{password:s.password||"",saltHex:e,salt:la(e),algorithm:Le(s.algorithm||void 0),partialEncryption:Ne(s.partialEncryption)}}function xa(s){return typeof s=="string"&&s.endsWith($e)}function Ja(s){return s?xa(s)?s:`${s}${$e}`:$e}function Za(s){return xa(s)?s.slice(0,-$e.length):s}function ei(s,e){var i,n;s.searchParams.set("boxcrypt","1"),s.searchParams.set("encAlgorithm",e.algorithm);let a=Ne(e.partialEncryption);return s.searchParams.set("encType",a.type),a.type==="percentage"?(s.searchParams.set("encPercentage",String((i=a.percentage)!=null?i:0)),s.searchParams.delete("encSize")):a.type==="size"?(s.searchParams.set("encSize",String((n=a.bytes)!=null?n:0)),s.searchParams.delete("encPercentage")):(s.searchParams.delete("encPercentage"),s.searchParams.delete("encSize")),s}function ai(s){if(!(s.searchParams.has("boxcrypt")||s.searchParams.has("encAlgorithm")||s.searchParams.has("encType")))return null;let a=s.searchParams.get("encAlgorithm"),i=s.searchParams.get("encType"),n;return!i||i==="full"?n={type:"full"}:i==="percentage"?n={type:"percentage",percentage:Number(s.searchParams.get("encPercentage")||0)}:i==="size"&&(n={type:"size",bytes:Number(s.searchParams.get("encSize")||0)}),{algorithm:a?Le(a):void 0,partialEncryption:n?Ne(n):void 0}}var us={FileBox:Xi,FileSystem:Ye,HttpFileSystem:Zi,path:pi,Plugin:Ue,type:ta,debug:vi,Cache:Vi};0&&(module.exports={CONTENT_ENCRYPTION_EXTENSION,Cache,DEFAULT_ENCRYPTION_SALT_HEX,FileBox,FileEncryptor,FileSystem,FileSystemType,FsCrypt,HttpFileSystem,Plugin,StatConstructorParams,addContentEncryptionSuffix,applyEncryptionQueryParams,arrayBufferToBase64Url,base64UrlToArrayBuffer,calculateEncryptedBytes,crypt,debug,deriveKey,filterList,hexToUint8Array,isContentEncryptedName,isContentEncryptionEnabled,isFilenameEncryptionEnabled,normalizeEncryptionAlgorithm,normalizeEncryptionFeatureEnabled,normalizeEncryptionSaltHex,normalizePartialEncryption,parseEncryptionQueryParams,path,resolveEncryptionProfile,stripContentEncryptionSuffix,type});
7
7
  /*! Bundled license information:
8
8
 
9
9
  bytes/index.js: