@wengine-ai/claude-code-router-shared 2.3.235 → 2.3.237
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setup(): () => void;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
export declare const CLIENT_IDS: readonly ["claudeCode", "codex", "pi", "qwenCode", "opencode"];
|
|
2
2
|
export type ClientId = (typeof CLIENT_IDS)[number];
|
|
3
3
|
export type ClientAction = "enable" | "disable" | "restore";
|
|
4
|
-
export interface ClientRoutingConfig {
|
|
5
|
-
extendedContextRatio?: number;
|
|
6
|
-
}
|
|
7
4
|
export interface ClientConfig {
|
|
8
5
|
enabled?: boolean;
|
|
9
6
|
managed?: boolean;
|
|
@@ -12,7 +9,6 @@ export interface ClientConfig {
|
|
|
12
9
|
activeAccountId?: string;
|
|
13
10
|
autoSwitchAccounts?: boolean;
|
|
14
11
|
autoRefreshTokens?: boolean;
|
|
15
|
-
routing?: ClientRoutingConfig;
|
|
16
12
|
quota?: {
|
|
17
13
|
limit5h?: number;
|
|
18
14
|
limit7d?: number;
|
|
@@ -91,8 +87,7 @@ export interface CodexTokenRefreshResult {
|
|
|
91
87
|
refreshed: boolean;
|
|
92
88
|
error?: string;
|
|
93
89
|
}
|
|
94
|
-
interface ResolvedClientConfig extends
|
|
95
|
-
routing?: ClientRoutingConfig;
|
|
90
|
+
interface ResolvedClientConfig extends Required<ClientConfig> {
|
|
96
91
|
}
|
|
97
92
|
interface ClientOperationOptions {
|
|
98
93
|
updateEnabled?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
`+C+"}"}}return u.pop(),i=C,o}function f(D){if(D.length===0)return h(D,!0);let C=String.fromCodePoint(D.codePointAt(0));if(!Sn.isIdStartChar(C))return h(D,!0);for(let d=C.length;d<D.length;d++)if(!Sn.isIdContinueChar(String.fromCodePoint(D.codePointAt(d))))return h(D,!0);return D}function E(D){if(u.indexOf(D)>=0)throw TypeError("Converting circular structure to JSON5");u.push(D);let C=i;i=i+c;let d=[];for(let o=0;o<D.length;o++){let l=y(String(o),D);d.push(l!==void 0?l:"null")}let A;if(d.length===0)A="[]";else if(c==="")A="["+d.join(",")+"]";else{let o=`,
|
|
12
12
|
`+i,l=d.join(o);A=`[
|
|
13
13
|
`+i+l+`,
|
|
14
|
-
`+C+"]"}return u.pop(),i=C,A}}});var xn=W((Os,Mr)=>{var Do=Tr(),Co=br(),Eo={parse:Do,stringify:Co};Mr.exports=Eo});var In=W((vs,Ur)=>{Ur.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var Lt=W(jr=>{var kr={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function po(e){return function(...t){return t.length&&(e=e.replace(/\{(\d)\}/g,(n,r)=>t[r]||"")),new Error("ADM-ZIP: "+e)}}for(let e of Object.keys(kr))jr[e]=po(kr[e])});var Wr=W((Bs,zr)=>{var Ao=require("fs"),K=require("path"),Hr=In(),mo=Lt(),go=typeof process=="object"&&process.platform==="win32",$r=e=>typeof e=="object"&&e!==null,Vr=new Uint32Array(256).map((e,t)=>{for(let n=0;n<8;n++)(t&1)!==0?t=3988292384^t>>>1:t>>>=1;return t>>>0});function $(e){this.sep=K.sep,this.fs=Ao,$r(e)&&$r(e.fs)&&typeof e.fs.statSync=="function"&&(this.fs=e.fs)}zr.exports=$;$.prototype.makeDir=function(e){let t=this;function n(r){let u=r.split(t.sep)[0];r.split(t.sep).forEach(function(i){if(!(!i||i.substr(-1,1)===":")){u+=t.sep+i;var s;try{s=t.fs.statSync(u)}catch{t.fs.mkdirSync(u)}if(s&&s.isFile())throw mo.FILE_IN_THE_WAY(`"${u}"`)}})}n(e)};$.prototype.writeFileTo=function(e,t,n,r){let u=this;if(u.fs.existsSync(e)){if(!n)return!1;var i=u.fs.statSync(e);if(i.isDirectory())return!1}var s=K.dirname(e);u.fs.existsSync(s)||u.makeDir(s);var a;try{a=u.fs.openSync(e,"w",438)}catch{u.fs.chmodSync(e,438),a=u.fs.openSync(e,"w",438)}if(a)try{u.fs.writeSync(a,t,0,t.length,0)}finally{u.fs.closeSync(a)}return u.fs.chmodSync(e,r||438),!0};$.prototype.writeFileToAsync=function(e,t,n,r,u){typeof r=="function"&&(u=r,r=void 0);let i=this;i.fs.exists(e,function(s){if(s&&!n)return u(!1);i.fs.stat(e,function(a,c){if(s&&c.isDirectory())return u(!1);var g=K.dirname(e);i.fs.exists(g,function(y){y||i.makeDir(g),i.fs.open(e,"w",438,function(h,O){h?i.fs.chmod(e,438,function(){i.fs.open(e,"w",438,function(f,E){i.fs.write(E,t,0,t.length,0,function(){i.fs.close(E,function(){i.fs.chmod(e,r||438,function(){u(!0)})})})})}):O?i.fs.write(O,t,0,t.length,0,function(){i.fs.close(O,function(){i.fs.chmod(e,r||438,function(){u(!0)})})}):i.fs.chmod(e,r||438,function(){u(!0)})})})})})};$.prototype.findFiles=function(e){let t=this;function n(r,u,i){typeof u=="boolean"&&(i=u,u=void 0);let s=[];return t.fs.readdirSync(r).forEach(function(a){let c=K.join(r,a),g=t.fs.statSync(c);(!u||u.test(c))&&s.push(K.normalize(c)+(g.isDirectory()?t.sep:"")),g.isDirectory()&&i&&(s=s.concat(n(c,u,i)))}),s}return n(e,void 0,!0)};$.prototype.findFilesAsync=function(e,t){let n=this,r=[];n.fs.readdir(e,function(u,i){if(u)return t(u);let s=i.length;if(!s)return t(null,r);i.forEach(function(a){a=K.join(e,a),n.fs.stat(a,function(c,g){if(c)return t(c);g&&(r.push(K.normalize(a)+(g.isDirectory()?n.sep:"")),g.isDirectory()?n.findFilesAsync(a,function(y,h){if(y)return t(y);r=r.concat(h),--s||t(null,r)}):--s||t(null,r))})})})};$.prototype.getAttributes=function(){};$.prototype.setAttributes=function(){};$.crc32update=function(e,t){return Vr[(e^t)&255]^e>>>8};$.crc32=function(e){typeof e=="string"&&(e=Buffer.from(e,"utf8"));let t=e.length,n=-1;for(let r=0;r<t;)n=$.crc32update(n,e[r++]);return~n>>>0};$.methodToString=function(e){switch(e){case Hr.STORED:return"STORED ("+e+")";case Hr.DEFLATED:return"DEFLATED ("+e+")";default:return"UNSUPPORTED ("+e+")"}};$.canonical=function(e){if(!e)return"";let t=K.posix.normalize("/"+e.split("\\").join("/"));return K.join(".",t)};$.zipnamefix=function(e){if(!e)return"";let t=K.posix.normalize("/"+e.split("\\").join("/"));return K.posix.join(".",t)};$.findLast=function(e,t){if(!Array.isArray(e))throw new TypeError("arr is not array");let n=e.length>>>0;for(let r=n-1;r>=0;r--)if(t(e[r],r,e))return e[r]};$.sanitize=function(e,t){e=K.resolve(K.normalize(e));for(var n=t.split("/"),r=0,u=n.length;r<u;r++){var i=K.normalize(K.join(e,n.slice(r,u).join(K.sep)));if(i.indexOf(e)===0)return i}return K.normalize(K.join(e,K.basename(t)))};$.toBuffer=function(t,n){return Buffer.isBuffer(t)?t:t instanceof Uint8Array?Buffer.from(t):typeof t=="string"?n(t):Buffer.alloc(0)};$.readBigUInt64LE=function(e,t){var n=Buffer.from(e.slice(t,t+8));return n.swap64(),parseInt(`0x${n.toString("hex")}`)};$.fromDOS2Date=function(e){return new Date((e>>25&127)+1980,Math.max((e>>21&15)-1,0),Math.max(e>>16&31,1),e>>11&31,e>>5&63,(e&31)<<1)};$.fromDate2DOS=function(e){let t=0,n=0;return e.getFullYear()>1979&&(t=(e.getFullYear()-1980&127)<<9|e.getMonth()+1<<5|e.getDate(),n=e.getHours()<<11|e.getMinutes()<<5|e.getSeconds()>>1),t<<16|n};$.isWin=go;$.crcTable=Vr});var qr=W((ws,Zr)=>{var ho=require("path");Zr.exports=function(e,{fs:t}){var n=e||"",r=i(),u=null;function i(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return n&&t.existsSync(n)?(u=t.statSync(n),r.directory=u.isDirectory(),r.mtime=u.mtime,r.atime=u.atime,r.executable=(73&u.mode)!==0,r.readonly=(128&u.mode)===0,r.hidden=ho.basename(n)[0]==="."):console.warn("Invalid path: "+n),{get directory(){return r.directory},get readOnly(){return r.readonly},get hidden(){return r.hidden},get mtime(){return r.mtime},get atime(){return r.atime},get executable(){return r.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:n,isDirectory:r.directory,isReadOnly:r.readonly,isHidden:r.hidden,isExecutable:r.executable,mTime:r.mtime,aTime:r.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Gr=W((Ps,Kr)=>{Kr.exports={efs:!0,encode:e=>Buffer.from(e,"utf8"),decode:e=>e.toString("utf8")}});var Ve=W((Ns,$e)=>{$e.exports=Wr();$e.exports.Constants=In();$e.exports.Errors=Lt();$e.exports.FileAttr=qr();$e.exports.decoder=Gr()});var Xr=W((Ts,Jr)=>{var Ie=Ve(),F=Ie.Constants;Jr.exports=function(){var e=20,t=10,n=0,r=0,u=0,i=0,s=0,a=0,c=0,g=0,y=0,h=0,O=0,f=0,E=0;e|=Ie.isWin?2560:768,n|=F.FLG_EFS;let D={extraLen:0},C=o=>Math.max(0,o)>>>0,d=o=>Math.max(0,o)&65535,A=o=>Math.max(0,o)&255;return u=Ie.fromDate2DOS(new Date),{get made(){return e},set made(o){e=o},get version(){return t},set version(o){t=o},get flags(){return n},set flags(o){n=o},get flags_efs(){return(n&F.FLG_EFS)>0},set flags_efs(o){o?n|=F.FLG_EFS:n&=~F.FLG_EFS},get flags_desc(){return(n&F.FLG_DESC)>0},set flags_desc(o){o?n|=F.FLG_DESC:n&=~F.FLG_DESC},get method(){return r},set method(o){switch(o){case F.STORED:this.version=10;case F.DEFLATED:default:this.version=20}r=o},get time(){return Ie.fromDOS2Date(this.timeval)},set time(o){this.timeval=Ie.fromDate2DOS(o)},get timeval(){return u},set timeval(o){u=C(o)},get timeHighByte(){return A(u>>>8)},get crc(){return i},set crc(o){i=C(o)},get compressedSize(){return s},set compressedSize(o){s=C(o)},get size(){return a},set size(o){a=C(o)},get fileNameLength(){return c},set fileNameLength(o){c=o},get extraLength(){return g},set extraLength(o){g=o},get extraLocalLength(){return D.extraLen},set extraLocalLength(o){D.extraLen=o},get commentLength(){return y},set commentLength(o){y=o},get diskNumStart(){return h},set diskNumStart(o){h=C(o)},get inAttr(){return O},set inAttr(o){O=C(o)},get attr(){return f},set attr(o){f=C(o)},get fileAttr(){return(f||0)>>16&4095},get offset(){return E},set offset(o){E=C(o)},get encrypted(){return(n&F.FLG_ENC)===F.FLG_ENC},get centralHeaderSize(){return F.CENHDR+c+g+y},get realDataOffset(){return E+F.LOCHDR+D.fnameLen+D.extraLen},get localHeader(){return D},loadLocalHeaderFromBinary:function(o){var l=o.slice(E,E+F.LOCHDR);if(l.readUInt32LE(0)!==F.LOCSIG)throw Ie.Errors.INVALID_LOC();D.version=l.readUInt16LE(F.LOCVER),D.flags=l.readUInt16LE(F.LOCFLG),D.method=l.readUInt16LE(F.LOCHOW),D.time=l.readUInt32LE(F.LOCTIM),D.crc=l.readUInt32LE(F.LOCCRC),D.compressedSize=l.readUInt32LE(F.LOCSIZ),D.size=l.readUInt32LE(F.LOCLEN),D.fnameLen=l.readUInt16LE(F.LOCNAM),D.extraLen=l.readUInt16LE(F.LOCEXT);let p=E+F.LOCHDR+D.fnameLen,x=p+D.extraLen;return o.slice(p,x)},loadFromBinary:function(o){if(o.length!==F.CENHDR||o.readUInt32LE(0)!==F.CENSIG)throw Ie.Errors.INVALID_CEN();e=o.readUInt16LE(F.CENVEM),t=o.readUInt16LE(F.CENVER),n=o.readUInt16LE(F.CENFLG),r=o.readUInt16LE(F.CENHOW),u=o.readUInt32LE(F.CENTIM),i=o.readUInt32LE(F.CENCRC),s=o.readUInt32LE(F.CENSIZ),a=o.readUInt32LE(F.CENLEN),c=o.readUInt16LE(F.CENNAM),g=o.readUInt16LE(F.CENEXT),y=o.readUInt16LE(F.CENCOM),h=o.readUInt16LE(F.CENDSK),O=o.readUInt16LE(F.CENATT),f=o.readUInt32LE(F.CENATX),E=o.readUInt32LE(F.CENOFF)},localHeaderToBinary:function(){var o=Buffer.alloc(F.LOCHDR);return o.writeUInt32LE(F.LOCSIG,0),o.writeUInt16LE(t,F.LOCVER),o.writeUInt16LE(n,F.LOCFLG),o.writeUInt16LE(r,F.LOCHOW),o.writeUInt32LE(u,F.LOCTIM),o.writeUInt32LE(i,F.LOCCRC),o.writeUInt32LE(s,F.LOCSIZ),o.writeUInt32LE(a,F.LOCLEN),o.writeUInt16LE(c,F.LOCNAM),o.writeUInt16LE(D.extraLen,F.LOCEXT),o},centralHeaderToBinary:function(){var o=Buffer.alloc(F.CENHDR+c+g+y);return o.writeUInt32LE(F.CENSIG,0),o.writeUInt16LE(e,F.CENVEM),o.writeUInt16LE(t,F.CENVER),o.writeUInt16LE(n,F.CENFLG),o.writeUInt16LE(r,F.CENHOW),o.writeUInt32LE(u,F.CENTIM),o.writeUInt32LE(i,F.CENCRC),o.writeUInt32LE(s,F.CENSIZ),o.writeUInt32LE(a,F.CENLEN),o.writeUInt16LE(c,F.CENNAM),o.writeUInt16LE(g,F.CENEXT),o.writeUInt16LE(y,F.CENCOM),o.writeUInt16LE(h,F.CENDSK),o.writeUInt16LE(O,F.CENATT),o.writeUInt32LE(f,F.CENATX),o.writeUInt32LE(E,F.CENOFF),o},toJSON:function(){let o=function(l){return l+" bytes"};return{made:e,version:t,flags:n,method:Ie.methodToString(r),time:this.time,crc:"0x"+i.toString(16).toUpperCase(),compressedSize:o(s),size:o(a),fileNameLength:o(c),extraLength:o(g),commentLength:o(y),diskNumStart:h,inAttr:O,attr:f,offset:E,centralHeaderSize:o(F.CENHDR+c+g+y)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Qr=W((Ls,Yr)=>{var ze=Ve(),k=ze.Constants;Yr.exports=function(){var e=0,t=0,n=0,r=0,u=0;return{get diskEntries(){return e},set diskEntries(i){e=t=i},get totalEntries(){return t},set totalEntries(i){t=e=i},get size(){return n},set size(i){n=i},get offset(){return r},set offset(i){r=i},get commentLength(){return u},set commentLength(i){u=i},get mainHeaderSize(){return k.ENDHDR+u},loadFromBinary:function(i){if((i.length!==k.ENDHDR||i.readUInt32LE(0)!==k.ENDSIG)&&(i.length<k.ZIP64HDR||i.readUInt32LE(0)!==k.ZIP64SIG))throw ze.Errors.INVALID_END();i.readUInt32LE(0)===k.ENDSIG?(e=i.readUInt16LE(k.ENDSUB),t=i.readUInt16LE(k.ENDTOT),n=i.readUInt32LE(k.ENDSIZ),r=i.readUInt32LE(k.ENDOFF),u=i.readUInt16LE(k.ENDCOM)):(e=ze.readBigUInt64LE(i,k.ZIP64SUB),t=ze.readBigUInt64LE(i,k.ZIP64TOT),n=ze.readBigUInt64LE(i,k.ZIP64SIZE),r=ze.readBigUInt64LE(i,k.ZIP64OFF),u=0)},toBinary:function(){var i=Buffer.alloc(k.ENDHDR+u);return i.writeUInt32LE(k.ENDSIG,0),i.writeUInt32LE(0,4),i.writeUInt16LE(e,k.ENDSUB),i.writeUInt16LE(t,k.ENDTOT),i.writeUInt32LE(n,k.ENDSIZ),i.writeUInt32LE(r,k.ENDOFF),i.writeUInt16LE(u,k.ENDCOM),i.fill(" ",k.ENDHDR),i},toJSON:function(){let i=function(s,a){let c=s.toString(16).toUpperCase();for(;c.length<a;)c="0"+c;return"0x"+c};return{diskEntries:e,totalEntries:t,size:n+" bytes",offset:i(r,4),commentLength:u}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var On=W(_n=>{_n.EntryHeader=Xr();_n.MainHeader=Qr()});var tu=W((Ms,eu)=>{eu.exports=function(e){var t=require("zlib"),n={chunkSize:(parseInt(e.length/1024)+1)*1024};return{deflate:function(){return t.deflateRawSync(e,n)},deflateAsync:function(r){var u=t.createDeflateRaw(n),i=[],s=0;u.on("data",function(a){i.push(a),s+=a.length}),u.on("end",function(){var a=Buffer.alloc(s),c=0;a.fill(0);for(var g=0;g<i.length;g++){var y=i[g];y.copy(a,c),c+=y.length}r&&r(a)}),u.end(e)}}}});var ru=W((Us,nu)=>{var Fo=+(process.versions?process.versions.node:"").split(".")[0]||0;nu.exports=function(e,t){var n=require("zlib");let r=Fo>=15&&t>0?{maxOutputLength:t}:{};return{inflate:function(){return n.inflateRawSync(e,r)},inflateAsync:function(u){var i=n.createInflateRaw(r),s=[],a=0;i.on("data",function(c){s.push(c),a+=c.length}),i.on("end",function(){var c=Buffer.alloc(a),g=0;c.fill(0);for(var y=0;y<s.length;y++){var h=s[y];h.copy(c,g),g+=h.length}u&&u(c)}),i.end(e)}}}});var au=W((ks,su)=>{"use strict";var{randomFillSync:uu}=require("crypto"),yo=Lt(),So=new Uint32Array(256).map((e,t)=>{for(let n=0;n<8;n++)(t&1)!==0?t=t>>>1^3988292384:t>>>=1;return t>>>0}),ou=(e,t)=>Math.imul(e,t)>>>0,iu=(e,t)=>So[(e^t)&255]^e>>>8,Qe=()=>typeof uu=="function"?uu(Buffer.alloc(12)):Qe.node();Qe.node=()=>{let e=Buffer.alloc(12),t=e.length;for(let n=0;n<t;n++)e[n]=Math.random()*256&255;return e};var bt={genSalt:Qe};function Mt(e){let t=Buffer.isBuffer(e)?e:Buffer.from(e);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let n=0;n<t.length;n++)this.updateKeys(t[n])}Mt.prototype.updateKeys=function(e){let t=this.keys;return t[0]=iu(t[0],e),t[1]+=t[0]&255,t[1]=ou(t[1],134775813)+1,t[2]=iu(t[2],t[1]>>>24),e};Mt.prototype.next=function(){let e=(this.keys[2]|2)>>>0;return ou(e,e^1)>>8&255};function xo(e){let t=new Mt(e);return function(n){let r=Buffer.alloc(n.length),u=0;for(let i of n)r[u++]=t.updateKeys(i^t.next());return r}}function Io(e){let t=new Mt(e);return function(n,r,u=0){r||(r=Buffer.alloc(n.length));for(let i of n){let s=t.next();r[u++]=i^s,t.updateKeys(i)}return r}}function _o(e,t,n){if(!e||!Buffer.isBuffer(e)||e.length<12)return Buffer.alloc(0);let r=xo(n),u=r(e.slice(0,12)),i=(t.flags&8)===8?t.timeHighByte:t.crc>>>24;if(u[11]!==i)throw yo.WRONG_PASSWORD();return r(e.slice(12))}function Oo(e){Buffer.isBuffer(e)&&e.length>=12?bt.genSalt=function(){return e.slice(0,12)}:e==="node"?bt.genSalt=Qe.node:bt.genSalt=Qe}function vo(e,t,n,r=!1){e==null&&(e=Buffer.alloc(0)),Buffer.isBuffer(e)||(e=Buffer.from(e.toString()));let u=Io(n),i=bt.genSalt();i[11]=t.crc>>>24&255,r&&(i[10]=t.crc>>>16&255);let s=Buffer.alloc(e.length+12);return u(i,s),u(e,s,12)}su.exports={decrypt:_o,encrypt:vo,_salter:Oo}});var cu=W(Ut=>{Ut.Deflater=tu();Ut.Inflater=ru();Ut.ZipCrypto=au()});var Rn=W((Hs,fu)=>{var N=Ve(),Ro=On(),V=N.Constants,vn=cu();fu.exports=function(e,t){var n=new Ro.EntryHeader,r=Buffer.alloc(0),u=Buffer.alloc(0),i=!1,s=null,a=Buffer.alloc(0),c=Buffer.alloc(0),g=!0;let y=e,h=typeof y.decoder=="object"?y.decoder:N.decoder;g=h.hasOwnProperty("efs")?h.efs:!1;function O(){return!t||!(t instanceof Uint8Array)?Buffer.alloc(0):(c=n.loadLocalHeaderFromBinary(t),t.slice(n.realDataOffset,n.realDataOffset+n.compressedSize))}function f(o){if(n.flags_desc){let l={},p=n.realDataOffset+n.compressedSize;if(t.readUInt32LE(p)==V.LOCSIG||t.readUInt32LE(p)==V.CENSIG)throw N.Errors.DESCRIPTOR_NOT_EXIST();if(t.readUInt32LE(p)==V.EXTSIG)l.crc=t.readUInt32LE(p+V.EXTCRC),l.compressedSize=t.readUInt32LE(p+V.EXTSIZ),l.size=t.readUInt32LE(p+V.EXTLEN);else if(t.readUInt16LE(p+12)===19280)l.crc=t.readUInt32LE(p+V.EXTCRC-4),l.compressedSize=t.readUInt32LE(p+V.EXTSIZ-4),l.size=t.readUInt32LE(p+V.EXTLEN-4);else throw N.Errors.DESCRIPTOR_UNKNOWN();if(l.compressedSize!==n.compressedSize||l.size!==n.size||l.crc!==n.crc)throw N.Errors.DESCRIPTOR_FAULTY();if(N.crc32(o)!==l.crc)return!1}else if(N.crc32(o)!==n.localHeader.crc)return!1;return!0}function E(o,l,p){if(typeof l>"u"&&typeof o=="string"&&(p=o,o=void 0),i)return o&&l&&l(Buffer.alloc(0),N.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var x=O();if(x.length===0)return o&&l&&l(x),x;if(n.encrypted){if(typeof p!="string"&&!Buffer.isBuffer(p))throw N.Errors.INVALID_PASS_PARAM();x=vn.ZipCrypto.decrypt(x,n,p)}var S=Buffer.alloc(n.size);switch(n.method){case N.Constants.STORED:if(x.copy(S),f(S))return o&&l&&l(S),S;throw o&&l&&l(S,N.Errors.BAD_CRC()),N.Errors.BAD_CRC();case N.Constants.DEFLATED:var T=new vn.Inflater(x,n.size);if(o)T.inflateAsync(function(P){P.copy(P,0),l&&(f(P)?l(P):l(P,N.Errors.BAD_CRC()))});else{if(T.inflate(S).copy(S,0),!f(S))throw N.Errors.BAD_CRC(`"${h.decode(r)}"`);return S}break;default:throw o&&l&&l(Buffer.alloc(0),N.Errors.UNKNOWN_METHOD()),N.Errors.UNKNOWN_METHOD()}}function D(o,l){if((!s||!s.length)&&Buffer.isBuffer(t))return o&&l&&l(O()),O();if(s.length&&!i){var p;switch(n.method){case N.Constants.STORED:return n.compressedSize=n.size,p=Buffer.alloc(s.length),s.copy(p),o&&l&&l(p),p;default:case N.Constants.DEFLATED:var x=new vn.Deflater(s);if(o)x.deflateAsync(function(T){p=Buffer.alloc(T.length),n.compressedSize=T.length,T.copy(p),l&&l(p)});else{var S=x.deflate();return n.compressedSize=S.length,S}x=null;break}}else if(o&&l)l(Buffer.alloc(0));else return Buffer.alloc(0)}function C(o,l){return(o.readUInt32LE(l+4)<<4)+o.readUInt32LE(l)}function d(o){try{for(var l=0,p,x,S;l+4<o.length;)p=o.readUInt16LE(l),l+=2,x=o.readUInt16LE(l),l+=2,S=o.slice(l,l+x),l+=x,V.ID_ZIP64===p&&A(S)}catch{throw N.Errors.EXTRA_FIELD_PARSE_ERROR()}}function A(o){var l,p,x,S;o.length>=V.EF_ZIP64_SCOMP&&(l=C(o,V.EF_ZIP64_SUNCOMP),n.size===V.EF_ZIP64_OR_32&&(n.size=l)),o.length>=V.EF_ZIP64_RHO&&(p=C(o,V.EF_ZIP64_SCOMP),n.compressedSize===V.EF_ZIP64_OR_32&&(n.compressedSize=p)),o.length>=V.EF_ZIP64_DSN&&(x=C(o,V.EF_ZIP64_RHO),n.offset===V.EF_ZIP64_OR_32&&(n.offset=x)),o.length>=V.EF_ZIP64_DSN+4&&(S=o.readUInt32LE(V.EF_ZIP64_DSN),n.diskNumStart===V.EF_ZIP64_OR_16&&(n.diskNumStart=S))}return{get entryName(){return h.decode(r)},get rawEntryName(){return r},set entryName(o){r=N.toBuffer(o,h.encode);var l=r[r.length-1];i=l===47||l===92,n.fileNameLength=r.length},get efs(){return typeof g=="function"?g(this.entryName):g},get extra(){return a},set extra(o){a=o,n.extraLength=o.length,d(o)},get comment(){return h.decode(u)},set comment(o){if(u=N.toBuffer(o,h.encode),n.commentLength=u.length,u.length>65535)throw N.Errors.COMMENT_TOO_LONG()},get name(){var o=h.decode(r);return i?o.substr(o.length-1).split("/").pop():o.split("/").pop()},get isDirectory(){return i},getCompressedData:function(){return D(!1,null)},getCompressedDataAsync:function(o){D(!0,o)},setData:function(o){s=N.toBuffer(o,N.decoder.encode),!i&&s.length?(n.size=s.length,n.method=N.Constants.DEFLATED,n.crc=N.crc32(o),n.changed=!0):n.method=N.Constants.STORED},getData:function(o){return n.changed?s:E(!1,null,o)},getDataAsync:function(o,l){n.changed?o(s):E(!0,o,l)},set attr(o){n.attr=o},get attr(){return n.attr},set header(o){n.loadFromBinary(o)},get header(){return n},packCentralHeader:function(){n.flags_efs=this.efs,n.extraLength=a.length;var o=n.centralHeaderToBinary(),l=N.Constants.CENHDR;return r.copy(o,l),l+=r.length,a.copy(o,l),l+=n.extraLength,u.copy(o,l),o},packLocalHeader:function(){let o=0;n.flags_efs=this.efs,n.extraLocalLength=c.length;let l=n.localHeaderToBinary(),p=Buffer.alloc(l.length+r.length+n.extraLocalLength);return l.copy(p,o),o+=l.length,r.copy(p,o),o+=r.length,c.copy(p,o),o+=c.length,p},toJSON:function(){let o=function(l){return"<"+(l&&l.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:n.toJSON(),compressedData:o(t),data:o(s)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Du=W(($s,lu)=>{var du=Rn(),Bo=On(),te=Ve();lu.exports=function(e,t){var n=[],r={},u=Buffer.alloc(0),i=new Bo.MainHeader,s=!1,a=null;let c=new Set,g=t,{noSort:y,decoder:h}=g;e?E(g.readEntries):s=!0;function O(){let C=new Set;for(let d of Object.keys(r)){let A=d.split("/");if(A.pop(),!!A.length)for(let o=0;o<A.length;o++){let l=A.slice(0,o+1).join("/")+"/";C.add(l)}}for(let d of C)if(!(d in r)){let A=new du(g);A.entryName=d,A.attr=16,A.temporary=!0,n.push(A),r[A.entryName]=A,c.add(A)}}function f(){if(s=!0,r={},i.diskEntries>(e.length-i.offset)/te.Constants.CENHDR)throw te.Errors.DISK_ENTRY_TOO_LARGE();n=new Array(i.diskEntries);for(var C=i.offset,d=0;d<n.length;d++){var A=C,o=new du(g,e);o.header=e.slice(A,A+=te.Constants.CENHDR),o.entryName=e.slice(A,A+=o.header.fileNameLength),o.header.extraLength&&(o.extra=e.slice(A,A+=o.header.extraLength)),o.header.commentLength&&(o.comment=e.slice(A,A+o.header.commentLength)),C+=o.header.centralHeaderSize,n[d]=o,r[o.entryName]=o}c.clear(),O()}function E(C){var d=e.length-te.Constants.ENDHDR,A=Math.max(0,d-65535),o=A,l=e.length,p=-1,x=0;for((typeof g.trailingSpace=="boolean"?g.trailingSpace:!1)&&(A=0),d;d>=o;d--)if(e[d]===80){if(e.readUInt32LE(d)===te.Constants.ENDSIG){p=d,x=d,l=d+te.Constants.ENDHDR,o=d-te.Constants.END64HDR;continue}if(e.readUInt32LE(d)===te.Constants.END64SIG){o=A;continue}if(e.readUInt32LE(d)===te.Constants.ZIP64SIG){p=d,l=d+te.readBigUInt64LE(e,d+te.Constants.ZIP64SIZE)+te.Constants.ZIP64LEAD;break}}if(p==-1)throw te.Errors.INVALID_FORMAT();i.loadFromBinary(e.slice(p,l)),i.commentLength&&(u=e.slice(x+te.Constants.ENDHDR)),C&&f()}function D(){n.length>1&&!y&&n.sort((C,d)=>C.entryName.toLowerCase().localeCompare(d.entryName.toLowerCase()))}return{get entries(){return s||f(),n.filter(C=>!c.has(C))},get comment(){return h.decode(u)},set comment(C){u=te.toBuffer(C,h.encode),i.commentLength=u.length},getEntryCount:function(){return s?n.length:i.diskEntries},forEach:function(C){this.entries.forEach(C)},getEntry:function(C){return s||f(),r[C]||null},setEntry:function(C){s||f(),n.push(C),r[C.entryName]=C,i.totalEntries=n.length},deleteFile:function(C,d=!0){s||f();let A=r[C];this.getEntryChildren(A,d).map(l=>l.entryName).forEach(this.deleteEntry)},deleteEntry:function(C){s||f();let d=r[C],A=n.indexOf(d);A>=0&&(n.splice(A,1),delete r[C],i.totalEntries=n.length)},getEntryChildren:function(C,d=!0){if(s||f(),typeof C=="object")if(C.isDirectory&&d){let A=[],o=C.entryName;for(let l of n)l.entryName.startsWith(o)&&A.push(l);return A}else return[C];return[]},getChildCount:function(C){if(C&&C.isDirectory){let d=this.getEntryChildren(C);return d.includes(C)?d.length-1:d.length}return 0},compressToBuffer:function(){s||f(),D();let C=[],d=[],A=0,o=0;i.size=0,i.offset=0;let l=0;for(let S of this.entries){let T=S.getCompressedData();S.header.offset=o;let P=S.packLocalHeader(),J=P.length+T.length;o+=J,C.push(P),C.push(T);let L=S.packCentralHeader();d.push(L),i.size+=L.length,A+=J+L.length,l++}A+=i.mainHeaderSize,i.offset=o,i.totalEntries=l,o=0;let p=Buffer.alloc(A);for(let S of C)S.copy(p,o),o+=S.length;for(let S of d)S.copy(p,o),o+=S.length;let x=i.toBinary();return u&&u.copy(x,te.Constants.ENDHDR),x.copy(p,o),e=p,s=!1,p},toAsyncBuffer:function(C,d,A,o){try{s||f(),D();let l=[],p=[],x=0,S=0,T=0;i.size=0,i.offset=0;let P=function(J){if(J.length>0){let L=J.shift(),le=L.entryName+L.extra.toString();A&&A(le),L.getCompressedDataAsync(function(ie){o&&o(le),L.header.offset=S;let tt=L.packLocalHeader(),Un=tt.length+ie.length;S+=Un,l.push(tt),l.push(ie);let jt=L.packCentralHeader();p.push(jt),i.size+=jt.length,x+=Un+jt.length,T++,P(J)})}else{x+=i.mainHeaderSize,i.offset=S,i.totalEntries=T,S=0;let L=Buffer.alloc(x);l.forEach(function(ie){ie.copy(L,S),S+=ie.length}),p.forEach(function(ie){ie.copy(L,S),S+=ie.length});let le=i.toBinary();u&&u.copy(le,te.Constants.ENDHDR),le.copy(L,S),e=L,s=!1,C(L)}};P(Array.from(this.entries))}catch(l){d(l)}}}}});var pu=W((Vs,Eu)=>{var j=Ve(),z=require("path"),wo=Rn(),Po=Du(),Ne=(...e)=>j.findLast(e,t=>typeof t=="boolean"),Cu=(...e)=>j.findLast(e,t=>typeof t=="string"),No=(...e)=>j.findLast(e,t=>typeof t=="function"),To={noSort:!1,readEntries:!1,method:j.Constants.NONE,fs:null};Eu.exports=function(e,t){let n=null,r=Object.assign(Object.create(null),To);e&&typeof e=="object"&&(e instanceof Uint8Array||(Object.assign(r,e),e=r.input?r.input:void 0,r.input&&delete r.input),Buffer.isBuffer(e)&&(n=e,r.method=j.Constants.BUFFER,e=void 0)),Object.assign(r,t);let u=new j(r);if((typeof r.decoder!="object"||typeof r.decoder.encode!="function"||typeof r.decoder.decode!="function")&&(r.decoder=j.decoder),e&&typeof e=="string")if(u.fs.existsSync(e))r.method=j.Constants.FILE,r.filename=e,n=u.fs.readFileSync(e);else throw j.Errors.INVALID_FILENAME();let i=new Po(n,r),{canonical:s,sanitize:a,zipnamefix:c}=j;function g(f){if(f&&i){var E;if(typeof f=="string"&&(E=i.getEntry(z.posix.normalize(f))),typeof f=="object"&&typeof f.entryName<"u"&&typeof f.header<"u"&&(E=i.getEntry(f.entryName)),E)return E}return null}function y(f){let{join:E,normalize:D,sep:C}=z.posix;return E(".",D(C+f.split("\\").join(C)+C))}function h(f){return f instanceof RegExp?(function(E){return function(D){return E.test(D)}})(f):typeof f!="function"?()=>!0:f}let O=(f,E)=>{let D=E.slice(-1);return D=D===u.sep?u.sep:"",z.relative(f,E)+D};return{readFile:function(f,E){var D=g(f);return D&&D.getData(E)||null},childCount:function(f){let E=g(f);if(E)return i.getChildCount(E)},readFileAsync:function(f,E){var D=g(f);D?D.getDataAsync(E):E(null,"getEntry failed for:"+f)},readAsText:function(f,E){var D=g(f);if(D){var C=D.getData();if(C&&C.length)return C.toString(E||"utf8")}return""},readAsTextAsync:function(f,E,D){var C=g(f);C?C.getDataAsync(function(d,A){if(A){E(d,A);return}d&&d.length?E(d.toString(D||"utf8")):E("")}):E("")},deleteFile:function(f,E=!0){var D=g(f);D&&i.deleteFile(D.entryName,E)},deleteEntry:function(f){var E=g(f);E&&i.deleteEntry(E.entryName)},addZipComment:function(f){i.comment=f},getZipComment:function(){return i.comment||""},addZipEntryComment:function(f,E){var D=g(f);D&&(D.comment=E)},getZipEntryComment:function(f){var E=g(f);return E&&E.comment||""},updateFile:function(f,E){var D=g(f);D&&D.setData(E)},addLocalFile:function(f,E,D,C){if(u.fs.existsSync(f)){E=E?y(E):"";let d=z.win32.basename(z.win32.normalize(f));E+=D||d;let A=u.fs.statSync(f),o=A.isFile()?u.fs.readFileSync(f):Buffer.alloc(0);A.isDirectory()&&(E+=u.sep),this.addFile(E,o,C,A)}else throw j.Errors.FILE_NOT_FOUND(f)},addLocalFileAsync:function(f,E){f=typeof f=="object"?f:{localPath:f};let D=z.resolve(f.localPath),{comment:C}=f,{zipPath:d,zipName:A}=f,o=this;u.fs.stat(D,function(l,p){if(l)return E(l,!1);d=d?y(d):"";let x=z.win32.basename(z.win32.normalize(D));if(d+=A||x,p.isFile())u.fs.readFile(D,function(S,T){return S?E(S,!1):(o.addFile(d,T,C,p),setImmediate(E,void 0,!0))});else if(p.isDirectory())return d+=u.sep,o.addFile(d,Buffer.alloc(0),C,p),setImmediate(E,void 0,!0)})},addLocalFolder:function(f,E,D){if(D=h(D),E=E?y(E):"",f=z.normalize(f),u.fs.existsSync(f)){let C=u.findFiles(f),d=this;if(C.length)for(let A of C){let o=z.join(E,O(f,A));D(o)&&d.addLocalFile(A,z.dirname(o))}}else throw j.Errors.FILE_NOT_FOUND(f)},addLocalFolderAsync:function(f,E,D,C){C=h(C),D=D?y(D):"",f=z.normalize(f);var d=this;u.fs.open(f,"r",function(A){if(A&&A.code==="ENOENT")E(void 0,j.Errors.FILE_NOT_FOUND(f));else if(A)E(void 0,A);else{var o=u.findFiles(f),l=-1,p=function(){if(l+=1,l<o.length){var x=o[l],S=O(f,x).split("\\").join("/");S=S.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),C(S)?u.fs.stat(x,function(T,P){T&&E(void 0,T),P.isFile()?u.fs.readFile(x,function(J,L){J?E(void 0,J):(d.addFile(D+S,L,"",P),p())}):(d.addFile(D+S+"/",Buffer.alloc(0),"",P),p())}):process.nextTick(()=>{p()})}else E(!0,void 0)};p()}})},addLocalFolderAsync2:function(f,E){let D=this;f=typeof f=="object"?f:{localPath:f},localPath=z.resolve(y(f.localPath));let{zipPath:C,filter:d,namefix:A}=f;d instanceof RegExp?d=(function(p){return function(x){return p.test(x)}})(d):typeof d!="function"&&(d=function(){return!0}),C=C?y(C):"",A=="latin1"&&(A=p=>p.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof A!="function"&&(A=p=>p);let o=p=>z.join(C,A(O(localPath,p))),l=p=>z.win32.basename(z.win32.normalize(A(p)));u.fs.open(localPath,"r",function(p){p&&p.code==="ENOENT"?E(void 0,j.Errors.FILE_NOT_FOUND(localPath)):p?E(void 0,p):u.findFilesAsync(localPath,function(x,S){if(x)return E(x);S=S.filter(T=>d(o(T))),S.length||E(void 0,!1),setImmediate(S.reverse().reduce(function(T,P){return function(J,L){if(J||L===!1)return setImmediate(T,J,!1);D.addLocalFileAsync({localPath:P,zipPath:z.dirname(o(P)),zipName:l(P)},T)}},E))})})},addLocalFolderPromise:function(f,E){return new Promise((D,C)=>{this.addLocalFolderAsync2(Object.assign({localPath:f},E),(d,A)=>{d&&C(d),A&&D(this)})})},addFile:function(f,E,D,C){f=c(f);let d=g(f),A=d!=null;A||(d=new wo(r),d.entryName=f),d.comment=D||"";let o=typeof C=="object"&&C instanceof u.fs.Stats;o&&(d.header.time=C.mtime);var l=d.isDirectory?16:0;let p=d.isDirectory?16384:32768;return o?p|=4095&C.mode:typeof C=="number"?p|=4095&C:p|=d.isDirectory?493:420,l=(l|p<<16)>>>0,d.attr=l,d.setData(E),A||i.setEntry(d),d},getEntries:function(f){return i.password=f,i?i.entries:[]},getEntry:function(f){return g(f)},getEntryCount:function(){return i.getEntryCount()},forEach:function(f){return i.forEach(f)},extractEntryTo:function(f,E,D,C,d,A){C=Ne(!1,C),d=Ne(!1,d),D=Ne(!0,D),A=Cu(d,A);var o=g(f);if(!o)throw j.Errors.NO_ENTRY();var l=s(o.entryName),p=a(E,A&&!o.isDirectory?A:D?l:z.basename(l));if(o.isDirectory){var x=i.getEntryChildren(o);return x.forEach(function(P){if(P.isDirectory)return;var J=P.getData();if(!J)throw j.Errors.CANT_EXTRACT_FILE();var L=s(P.entryName),le=a(E,D?L:z.basename(L));let ie=d?P.header.fileAttr:void 0;u.writeFileTo(le,J,C,ie)}),!0}var S=o.getData(i.password);if(!S)throw j.Errors.CANT_EXTRACT_FILE();if(u.fs.existsSync(p)&&!C)throw j.Errors.CANT_OVERRIDE();let T=d?f.header.fileAttr:void 0;return u.writeFileTo(p,S,C,T),!0},test:function(f){if(!i)return!1;for(var E in i.entries)try{if(E.isDirectory)continue;var D=i.entries[E].getData(f);if(!D)return!1}catch{return!1}return!0},extractAllTo:function(f,E,D,C){if(D=Ne(!1,D),C=Cu(D,C),E=Ne(!1,E),!i)throw j.Errors.NO_ZIP();i.entries.forEach(function(d){var A=a(f,s(d.entryName));if(d.isDirectory){u.makeDir(A);return}var o=d.getData(C);if(!o)throw j.Errors.CANT_EXTRACT_FILE();let l=D?d.header.fileAttr:void 0;u.writeFileTo(A,o,E,l);try{u.fs.utimesSync(A,d.header.time,d.header.time)}catch{throw j.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(f,E,D,C){if(C=No(E,D,C),D=Ne(!1,D),E=Ne(!1,E),!C)return new Promise((p,x)=>{this.extractAllToAsync(f,E,D,function(S){S?x(S):p(this)})});if(!i){C(j.Errors.NO_ZIP());return}f=z.resolve(f);let d=p=>a(f,z.normalize(s(p.entryName))),A=(p,x)=>new Error(p+': "'+x+'"'),o=[],l=[];i.entries.forEach(p=>{p.isDirectory?o.push(p):l.push(p)});for(let p of o){let x=d(p),S=D?p.header.fileAttr:void 0;try{u.makeDir(x),S&&u.fs.chmodSync(x,S),u.fs.utimesSync(x,p.header.time,p.header.time)}catch{C(A("Unable to create folder",x))}}l.reverse().reduce(function(p,x){return function(S){if(S)p(S);else{let T=z.normalize(s(x.entryName)),P=a(f,T);x.getDataAsync(function(J,L){if(L)p(L);else if(!J)p(j.Errors.CANT_EXTRACT_FILE());else{let le=D?x.header.fileAttr:void 0;u.writeFileToAsync(P,J,E,le,function(ie){ie||p(A("Unable to write file",P)),u.fs.utimes(P,x.header.time,x.header.time,function(tt){tt?p(A("Unable to set times",P)):p()})})}})}}},C)()},writeZip:function(f,E){if(arguments.length===1&&typeof f=="function"&&(E=f,f=""),!f&&r.filename&&(f=r.filename),!!f){var D=i.compressToBuffer();if(D){var C=u.writeFileTo(f,D,!0);typeof E=="function"&&E(C?null:new Error("failed"),"")}}},writeZipPromise:function(f,E){let{overwrite:D,perm:C}=Object.assign({overwrite:!0},E);return new Promise((d,A)=>{!f&&r.filename&&(f=r.filename),f||A("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(o=>{let l=p=>p?d(p):A("ADM-ZIP: Wasn't able to write zip file");u.writeFileToAsync(f,o,D,C,l)},A)})},toBufferPromise:function(){return new Promise((f,E)=>{i.toAsyncBuffer(f,E)})},toBuffer:function(f,E,D,C){return typeof f=="function"?(i.toAsyncBuffer(f,E,D,C),null):i.compressToBuffer()}}}});var as={};Tu(as,{CLAUDE_PROJECTS_DIR:()=>ju,CLIENT_IDS:()=>Ue,CLIENT_STATE_FILE:()=>$t,CONFIG_FILE:()=>bu,DEFAULT_CONFIG:()=>Hu,DEFAULT_CONTEXT_WINDOW:()=>Kn,HOME_DIR:()=>Z,InputType:()=>ln,MergeStrategy:()=>Dn,PID_FILE:()=>Uu,PLUGINS_DIR:()=>Mu,PRESETS_DIR:()=>Ht,PROJECT_TAKEOVER_CLIENT_IDS:()=>He,REFERENCE_COUNT_FILE:()=>ku,activateCodexAccount:()=>hi,applyCcrProjectTakeover:()=>gt,applyClientSelection:()=>Hi,applyConfigMappings:()=>mu,applyOpencodeProjectTakeover:()=>_t,applyPiProjectTakeover:()=>yt,applyQwenProjectTakeover:()=>xt,applyUserInputs:()=>gu,buildDependencyGraph:()=>hu,createManifest:()=>ns,deleteCodexAccount:()=>Fi,deleteProjectConfig:()=>qi,disableClient:()=>dn,disableConfiguredClients:()=>Vi,downloadPresetToTemp:()=>Go,enableClient:()=>fn,enableConfiguredClients:()=>$i,evaluateCondition:()=>Bn,evaluateConditions:()=>Tn,exportCodexRefreshToken:()=>Ai,exportPreset:()=>rs,extractMetadata:()=>Yo,extractPreset:()=>Zo,fillSensitiveInputs:()=>to,findMarketPresetByName:()=>ss,generateEnvVarName:()=>_r,getActiveCodexAccount:()=>Di,getAffectedFields:()=>$o,getCcrTakeoverStatus:()=>Fr,getClaudeProjectId:()=>jn,getClaudeSettingsLocalPath:()=>Rt,getClientConfig:()=>Y,getContextWindow:()=>Ke,getDefaultClientsConfig:()=>ei,getDefaultValue:()=>jo,getDynamicOptions:()=>Au,getMarketPresets:()=>vu,getPresetDir:()=>We,getProjectConfigDir:()=>me,getProjectConfigPath:()=>ut,getProjectTakeoverClients:()=>xr,getTempDir:()=>Su,getValueByPath:()=>Lo,importCodexAccountFromRefreshToken:()=>mi,importCurrentCodexAccount:()=>pi,isCcrProjectTakeoverActive:()=>Je,isClientEnabled:()=>Xt,isClientId:()=>Yn,isOpencodeProjectTakeoverActive:()=>Ot,isPiProjectTakeoverActive:()=>St,isPresetInstalled:()=>es,isProjectTakeoverClient:()=>ki,isQwenProjectTakeoverActive:()=>It,listClientStatuses:()=>vt,listCodexAccounts:()=>li,listPresets:()=>ts,listProjectConfigs:()=>hr,loadConfigFromManifest:()=>Ln,loadPreset:()=>Jo,manifestToPresetFile:()=>bn,markActiveCodexAccountLimitedAndSwitch:()=>Ei,mergeConfig:()=>oo,parseFieldPath:()=>Pn,readClaudeSettingsLocal:()=>Bt,readManifestFromDir:()=>xu,readPresetFile:()=>us,readProjectConfig:()=>Wi,readProjectConfigById:()=>Ki,refreshCcrProjectTakeover:()=>Sr,refreshCodexAccountTokens:()=>dr,refreshDueCodexAccounts:()=>gi,refreshProjectTakeovers:()=>Ir,removeCcrProjectTakeover:()=>Yt,removeOpencodeProjectTakeover:()=>an,removePiProjectTakeover:()=>en,removeQwenProjectTakeover:()=>un,replaceTemplateVariables:()=>et,resolveOptions:()=>Mo,restoreClient:()=>ji,sanitizeConfig:()=>En,saveManifest:()=>Qo,setCcrTakeover:()=>yr,setProjectTakeover:()=>Ji,setValueByPath:()=>Nn,shouldShowField:()=>bo,sortFieldsByDependencies:()=>Ho,syncGlobalProjectTakeovers:()=>Xi,validateInput:()=>ko,validatePreset:()=>Xo,writeProjectConfig:()=>Zi});module.exports=Lu(as);var oe=X(require("node:path")),rt=X(require("node:os")),Z=oe.default.join(rt.default.homedir(),".claude-code-router"),bu=oe.default.join(Z,"config.json"),Mu=oe.default.join(Z,"plugins"),Ht=oe.default.join(Z,"presets"),Uu=oe.default.join(Z,".claude-code-router.pid"),$t=oe.default.join(Z,"client-state.json"),ku=oe.default.join(rt.default.tmpdir(),"claude-code-reference-count.txt"),ju=oe.default.join(rt.default.homedir(),".claude","projects");function jn(e){return e.replace(/[\\/.]/g,"-")}function me(e=process.cwd()){return oe.default.join(Z,jn(e))}function ut(e=process.cwd()){return oe.default.join(me(e),"config.json")}var Hu={LOG:!1,OPENAI_API_KEY:"",OPENAI_BASE_URL:"",OPENAI_MODEL:""};var I=X(require("node:fs")),Zt=X(require("node:os")),b=X(require("node:path")),Zn=X(require("node:crypto"));var Ue=["claudeCode","codex","pi","qwenCode","opencode"],ue={claudeCode:{id:"claudeCode",name:"Claude Code",defaultConfig:{enabled:!1,managed:!1,configPath:"~/.claude/settings.json",modelAlias:"",activeAccountId:"",autoSwitchAccounts:!0,autoRefreshTokens:!0,quota:{}}},codex:{id:"codex",name:"Codex",defaultConfig:{enabled:!1,managed:!1,configPath:"~/.codex/config.toml",modelAlias:"ccr-opus",activeAccountId:"",autoSwitchAccounts:!0,autoRefreshTokens:!0,quota:{}}},pi:{id:"pi",name:"pi",defaultConfig:{enabled:!1,managed:!1,configPath:"~/.pi/agent",modelAlias:"ccr-opus",activeAccountId:"",autoSwitchAccounts:!0,autoRefreshTokens:!0,quota:{}}},qwenCode:{id:"qwenCode",name:"Qwen Code",defaultConfig:{enabled:!1,managed:!1,configPath:"~/.qwen/settings.json",modelAlias:"ccr-opus",activeAccountId:"",autoSwitchAccounts:!0,autoRefreshTokens:!0,quota:{}}},opencode:{id:"opencode",name:"opencode",defaultConfig:{enabled:!1,managed:!1,configPath:"~/.config/opencode/opencode.json",modelAlias:"ccr-opus",activeAccountId:"",autoSwitchAccounts:!0,autoRefreshTokens:!0,quota:{}}}},qn=b.default.join(Z,"backups","clients"),Et=b.default.join(Z,"codex-accounts"),lt=b.default.join(Et,"accounts.json"),$u="app_EMoamEEZ73f0CkXaXp7hrann",Vu="https://auth.openai.com/oauth/token",zu=1440*60,Wu=10080*60*1e3,Vt=b.default.join(Z,".statusline-backup.json"),zt=b.default.join(Z,".model-env-backup.json"),pt=["ANTHROPIC_MODEL","ANTHROPIC_DEFAULT_SONNET_MODEL","ANTHROPIC_DEFAULT_OPUS_MODEL","ANTHROPIC_DEFAULT_HAIKU_MODEL","ANTHROPIC_REASONING_MODEL"],Gt={CLAUDE_CODE_AUTO_COMPACT_WINDOW:"200000",CLAUDE_AUTOCOMPACT_PCT_OVERRIDE:"90",CLAUDE_CODE_SIMPLE:"1"},Kn=2e5;function _(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Ke(e){let t=e?.ContextWindow;if(typeof t=="number"&&Number.isFinite(t)&&t>0)return Math.floor(t);if(typeof t=="string"&&/^\d+$/.test(t.trim())){let n=parseInt(t.trim(),10);if(n>0)return n}return Kn}function Jt(){return $t}function Zu(e){return b.default.join(me(e),"ccr-state.json")}function qu(e){return w(e)}function Ku(e){let t=w(Jt());return t&&t[e]||{}}function Gu(e,t){q(e,t)}function Ju(e,t){let n=Jt(),r=w(n);r[e]=t,q(n,r)}function Gn(e){try{I.default.existsSync(e)&&I.default.unlinkSync(e)}catch{}}function Xu(e){let t=Jt(),n=w(t);n&&n[e]&&(delete n[e],Object.keys(n).length>0?q(t,n):Gn(t))}function Hn(e){return{read:()=>Ku(e),write:t=>Ju(e,t),clear:()=>Xu(e)}}function Jn(e){if(!e)return;let t=Zu(e);return{read:()=>qu(t),write:n=>Gu(t,n),clear:()=>Gn(t)}}function Ce(e){return e instanceof Error?e.message:String(e)}function At(e){return e==="~"?Zt.default.homedir():e.startsWith("~/")?b.default.join(Zt.default.homedir(),e.slice(2)):e}function Yu(e){return ue[e]}function Xn(e,t){let r=(_(e.Clients)?e.Clients:{})[t];return _(r)?r:{}}function Ge(e){let t=e?.Router?.families;return _(t)&&Object.keys(t).length>0}function Qu(e){return!!(e?.StatusLine?.enabled||Ge(e))}function ei(){return{claudeCode:{...ue.claudeCode.defaultConfig},codex:{...ue.codex.defaultConfig},pi:{...ue.pi.defaultConfig},qwenCode:{...ue.qwenCode.defaultConfig},opencode:{...ue.opencode.defaultConfig}}}function Y(e,t){let n=Yu(t),r=Xn(e,t),i=typeof r.enabled=="boolean"?!!r.enabled:t==="claudeCode"&&!_(e.Clients)?Qu(e):n.defaultConfig.enabled;return{...n.defaultConfig,...r,enabled:i,managed:!!r.managed,configPath:r.configPath||n.defaultConfig.configPath,modelAlias:r.modelAlias||n.defaultConfig.modelAlias,activeAccountId:r.activeAccountId||n.defaultConfig.activeAccountId}}function Yn(e){return Ue.includes(e)}function Xt(e,t){return Y(e,t).enabled}function Qn(e,t,n){let r=_(e.Clients)?{...e.Clients}:{},i={...Y(e,t),...n};return r[t]=i,e.Clients=r,i}function De(e,t){return At(Y(e,t).configPath)}function mt(e){let t=b.default.dirname(e);I.default.existsSync(t)||I.default.mkdirSync(t,{recursive:!0})}function de(e,t){if(!I.default.existsSync(t))return null;let n=b.default.join(qn,e);I.default.mkdirSync(n,{recursive:!0});let r=new Date().toISOString().replace(/[:.]/g,"-"),u=b.default.extname(t)||".bak",i=b.default.join(n,`${r}${u}`);return I.default.copyFileSync(t,i),i}function ti(e){let t=b.default.join(qn,e);if(!I.default.existsSync(t))return null;let n=I.default.readdirSync(t).filter(r=>!r.startsWith(".")).sort();return n.length===0?null:b.default.join(t,n[n.length-1])}function Me(e,t){let n=ti(e);return n?(mt(t),I.default.copyFileSync(n,t),n):null}function w(e){if(!I.default.existsSync(e))return{};let t;try{t=I.default.readFileSync(e,"utf-8")}catch{return{}}if(!t.trim())return{};let n;try{n=JSON.parse(t)}catch{return{}}return _(n)?n:{}}function q(e,t){let n=`${JSON.stringify(t,null,2)}
|
|
14
|
+
`+C+"]"}return u.pop(),i=C,A}}});var xn=W((Os,Mr)=>{var Do=Tr(),Co=br(),Eo={parse:Do,stringify:Co};Mr.exports=Eo});var In=W((vs,Ur)=>{Ur.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var Lt=W(jr=>{var kr={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function po(e){return function(...t){return t.length&&(e=e.replace(/\{(\d)\}/g,(n,r)=>t[r]||"")),new Error("ADM-ZIP: "+e)}}for(let e of Object.keys(kr))jr[e]=po(kr[e])});var Wr=W((Bs,zr)=>{var Ao=require("fs"),K=require("path"),Hr=In(),mo=Lt(),go=typeof process=="object"&&process.platform==="win32",$r=e=>typeof e=="object"&&e!==null,Vr=new Uint32Array(256).map((e,t)=>{for(let n=0;n<8;n++)(t&1)!==0?t=3988292384^t>>>1:t>>>=1;return t>>>0});function $(e){this.sep=K.sep,this.fs=Ao,$r(e)&&$r(e.fs)&&typeof e.fs.statSync=="function"&&(this.fs=e.fs)}zr.exports=$;$.prototype.makeDir=function(e){let t=this;function n(r){let u=r.split(t.sep)[0];r.split(t.sep).forEach(function(i){if(!(!i||i.substr(-1,1)===":")){u+=t.sep+i;var s;try{s=t.fs.statSync(u)}catch{t.fs.mkdirSync(u)}if(s&&s.isFile())throw mo.FILE_IN_THE_WAY(`"${u}"`)}})}n(e)};$.prototype.writeFileTo=function(e,t,n,r){let u=this;if(u.fs.existsSync(e)){if(!n)return!1;var i=u.fs.statSync(e);if(i.isDirectory())return!1}var s=K.dirname(e);u.fs.existsSync(s)||u.makeDir(s);var a;try{a=u.fs.openSync(e,"w",438)}catch{u.fs.chmodSync(e,438),a=u.fs.openSync(e,"w",438)}if(a)try{u.fs.writeSync(a,t,0,t.length,0)}finally{u.fs.closeSync(a)}return u.fs.chmodSync(e,r||438),!0};$.prototype.writeFileToAsync=function(e,t,n,r,u){typeof r=="function"&&(u=r,r=void 0);let i=this;i.fs.exists(e,function(s){if(s&&!n)return u(!1);i.fs.stat(e,function(a,c){if(s&&c.isDirectory())return u(!1);var g=K.dirname(e);i.fs.exists(g,function(y){y||i.makeDir(g),i.fs.open(e,"w",438,function(h,O){h?i.fs.chmod(e,438,function(){i.fs.open(e,"w",438,function(f,E){i.fs.write(E,t,0,t.length,0,function(){i.fs.close(E,function(){i.fs.chmod(e,r||438,function(){u(!0)})})})})}):O?i.fs.write(O,t,0,t.length,0,function(){i.fs.close(O,function(){i.fs.chmod(e,r||438,function(){u(!0)})})}):i.fs.chmod(e,r||438,function(){u(!0)})})})})})};$.prototype.findFiles=function(e){let t=this;function n(r,u,i){typeof u=="boolean"&&(i=u,u=void 0);let s=[];return t.fs.readdirSync(r).forEach(function(a){let c=K.join(r,a),g=t.fs.statSync(c);(!u||u.test(c))&&s.push(K.normalize(c)+(g.isDirectory()?t.sep:"")),g.isDirectory()&&i&&(s=s.concat(n(c,u,i)))}),s}return n(e,void 0,!0)};$.prototype.findFilesAsync=function(e,t){let n=this,r=[];n.fs.readdir(e,function(u,i){if(u)return t(u);let s=i.length;if(!s)return t(null,r);i.forEach(function(a){a=K.join(e,a),n.fs.stat(a,function(c,g){if(c)return t(c);g&&(r.push(K.normalize(a)+(g.isDirectory()?n.sep:"")),g.isDirectory()?n.findFilesAsync(a,function(y,h){if(y)return t(y);r=r.concat(h),--s||t(null,r)}):--s||t(null,r))})})})};$.prototype.getAttributes=function(){};$.prototype.setAttributes=function(){};$.crc32update=function(e,t){return Vr[(e^t)&255]^e>>>8};$.crc32=function(e){typeof e=="string"&&(e=Buffer.from(e,"utf8"));let t=e.length,n=-1;for(let r=0;r<t;)n=$.crc32update(n,e[r++]);return~n>>>0};$.methodToString=function(e){switch(e){case Hr.STORED:return"STORED ("+e+")";case Hr.DEFLATED:return"DEFLATED ("+e+")";default:return"UNSUPPORTED ("+e+")"}};$.canonical=function(e){if(!e)return"";let t=K.posix.normalize("/"+e.split("\\").join("/"));return K.join(".",t)};$.zipnamefix=function(e){if(!e)return"";let t=K.posix.normalize("/"+e.split("\\").join("/"));return K.posix.join(".",t)};$.findLast=function(e,t){if(!Array.isArray(e))throw new TypeError("arr is not array");let n=e.length>>>0;for(let r=n-1;r>=0;r--)if(t(e[r],r,e))return e[r]};$.sanitize=function(e,t){e=K.resolve(K.normalize(e));for(var n=t.split("/"),r=0,u=n.length;r<u;r++){var i=K.normalize(K.join(e,n.slice(r,u).join(K.sep)));if(i.indexOf(e)===0)return i}return K.normalize(K.join(e,K.basename(t)))};$.toBuffer=function(t,n){return Buffer.isBuffer(t)?t:t instanceof Uint8Array?Buffer.from(t):typeof t=="string"?n(t):Buffer.alloc(0)};$.readBigUInt64LE=function(e,t){var n=Buffer.from(e.slice(t,t+8));return n.swap64(),parseInt(`0x${n.toString("hex")}`)};$.fromDOS2Date=function(e){return new Date((e>>25&127)+1980,Math.max((e>>21&15)-1,0),Math.max(e>>16&31,1),e>>11&31,e>>5&63,(e&31)<<1)};$.fromDate2DOS=function(e){let t=0,n=0;return e.getFullYear()>1979&&(t=(e.getFullYear()-1980&127)<<9|e.getMonth()+1<<5|e.getDate(),n=e.getHours()<<11|e.getMinutes()<<5|e.getSeconds()>>1),t<<16|n};$.isWin=go;$.crcTable=Vr});var qr=W((ws,Zr)=>{var ho=require("path");Zr.exports=function(e,{fs:t}){var n=e||"",r=i(),u=null;function i(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return n&&t.existsSync(n)?(u=t.statSync(n),r.directory=u.isDirectory(),r.mtime=u.mtime,r.atime=u.atime,r.executable=(73&u.mode)!==0,r.readonly=(128&u.mode)===0,r.hidden=ho.basename(n)[0]==="."):console.warn("Invalid path: "+n),{get directory(){return r.directory},get readOnly(){return r.readonly},get hidden(){return r.hidden},get mtime(){return r.mtime},get atime(){return r.atime},get executable(){return r.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:n,isDirectory:r.directory,isReadOnly:r.readonly,isHidden:r.hidden,isExecutable:r.executable,mTime:r.mtime,aTime:r.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Gr=W((Ps,Kr)=>{Kr.exports={efs:!0,encode:e=>Buffer.from(e,"utf8"),decode:e=>e.toString("utf8")}});var Ve=W((Ns,$e)=>{$e.exports=Wr();$e.exports.Constants=In();$e.exports.Errors=Lt();$e.exports.FileAttr=qr();$e.exports.decoder=Gr()});var Xr=W((Ts,Jr)=>{var Ie=Ve(),F=Ie.Constants;Jr.exports=function(){var e=20,t=10,n=0,r=0,u=0,i=0,s=0,a=0,c=0,g=0,y=0,h=0,O=0,f=0,E=0;e|=Ie.isWin?2560:768,n|=F.FLG_EFS;let D={extraLen:0},C=o=>Math.max(0,o)>>>0,d=o=>Math.max(0,o)&65535,A=o=>Math.max(0,o)&255;return u=Ie.fromDate2DOS(new Date),{get made(){return e},set made(o){e=o},get version(){return t},set version(o){t=o},get flags(){return n},set flags(o){n=o},get flags_efs(){return(n&F.FLG_EFS)>0},set flags_efs(o){o?n|=F.FLG_EFS:n&=~F.FLG_EFS},get flags_desc(){return(n&F.FLG_DESC)>0},set flags_desc(o){o?n|=F.FLG_DESC:n&=~F.FLG_DESC},get method(){return r},set method(o){switch(o){case F.STORED:this.version=10;case F.DEFLATED:default:this.version=20}r=o},get time(){return Ie.fromDOS2Date(this.timeval)},set time(o){this.timeval=Ie.fromDate2DOS(o)},get timeval(){return u},set timeval(o){u=C(o)},get timeHighByte(){return A(u>>>8)},get crc(){return i},set crc(o){i=C(o)},get compressedSize(){return s},set compressedSize(o){s=C(o)},get size(){return a},set size(o){a=C(o)},get fileNameLength(){return c},set fileNameLength(o){c=o},get extraLength(){return g},set extraLength(o){g=o},get extraLocalLength(){return D.extraLen},set extraLocalLength(o){D.extraLen=o},get commentLength(){return y},set commentLength(o){y=o},get diskNumStart(){return h},set diskNumStart(o){h=C(o)},get inAttr(){return O},set inAttr(o){O=C(o)},get attr(){return f},set attr(o){f=C(o)},get fileAttr(){return(f||0)>>16&4095},get offset(){return E},set offset(o){E=C(o)},get encrypted(){return(n&F.FLG_ENC)===F.FLG_ENC},get centralHeaderSize(){return F.CENHDR+c+g+y},get realDataOffset(){return E+F.LOCHDR+D.fnameLen+D.extraLen},get localHeader(){return D},loadLocalHeaderFromBinary:function(o){var l=o.slice(E,E+F.LOCHDR);if(l.readUInt32LE(0)!==F.LOCSIG)throw Ie.Errors.INVALID_LOC();D.version=l.readUInt16LE(F.LOCVER),D.flags=l.readUInt16LE(F.LOCFLG),D.method=l.readUInt16LE(F.LOCHOW),D.time=l.readUInt32LE(F.LOCTIM),D.crc=l.readUInt32LE(F.LOCCRC),D.compressedSize=l.readUInt32LE(F.LOCSIZ),D.size=l.readUInt32LE(F.LOCLEN),D.fnameLen=l.readUInt16LE(F.LOCNAM),D.extraLen=l.readUInt16LE(F.LOCEXT);let p=E+F.LOCHDR+D.fnameLen,x=p+D.extraLen;return o.slice(p,x)},loadFromBinary:function(o){if(o.length!==F.CENHDR||o.readUInt32LE(0)!==F.CENSIG)throw Ie.Errors.INVALID_CEN();e=o.readUInt16LE(F.CENVEM),t=o.readUInt16LE(F.CENVER),n=o.readUInt16LE(F.CENFLG),r=o.readUInt16LE(F.CENHOW),u=o.readUInt32LE(F.CENTIM),i=o.readUInt32LE(F.CENCRC),s=o.readUInt32LE(F.CENSIZ),a=o.readUInt32LE(F.CENLEN),c=o.readUInt16LE(F.CENNAM),g=o.readUInt16LE(F.CENEXT),y=o.readUInt16LE(F.CENCOM),h=o.readUInt16LE(F.CENDSK),O=o.readUInt16LE(F.CENATT),f=o.readUInt32LE(F.CENATX),E=o.readUInt32LE(F.CENOFF)},localHeaderToBinary:function(){var o=Buffer.alloc(F.LOCHDR);return o.writeUInt32LE(F.LOCSIG,0),o.writeUInt16LE(t,F.LOCVER),o.writeUInt16LE(n,F.LOCFLG),o.writeUInt16LE(r,F.LOCHOW),o.writeUInt32LE(u,F.LOCTIM),o.writeUInt32LE(i,F.LOCCRC),o.writeUInt32LE(s,F.LOCSIZ),o.writeUInt32LE(a,F.LOCLEN),o.writeUInt16LE(c,F.LOCNAM),o.writeUInt16LE(D.extraLen,F.LOCEXT),o},centralHeaderToBinary:function(){var o=Buffer.alloc(F.CENHDR+c+g+y);return o.writeUInt32LE(F.CENSIG,0),o.writeUInt16LE(e,F.CENVEM),o.writeUInt16LE(t,F.CENVER),o.writeUInt16LE(n,F.CENFLG),o.writeUInt16LE(r,F.CENHOW),o.writeUInt32LE(u,F.CENTIM),o.writeUInt32LE(i,F.CENCRC),o.writeUInt32LE(s,F.CENSIZ),o.writeUInt32LE(a,F.CENLEN),o.writeUInt16LE(c,F.CENNAM),o.writeUInt16LE(g,F.CENEXT),o.writeUInt16LE(y,F.CENCOM),o.writeUInt16LE(h,F.CENDSK),o.writeUInt16LE(O,F.CENATT),o.writeUInt32LE(f,F.CENATX),o.writeUInt32LE(E,F.CENOFF),o},toJSON:function(){let o=function(l){return l+" bytes"};return{made:e,version:t,flags:n,method:Ie.methodToString(r),time:this.time,crc:"0x"+i.toString(16).toUpperCase(),compressedSize:o(s),size:o(a),fileNameLength:o(c),extraLength:o(g),commentLength:o(y),diskNumStart:h,inAttr:O,attr:f,offset:E,centralHeaderSize:o(F.CENHDR+c+g+y)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Qr=W((Ls,Yr)=>{var ze=Ve(),k=ze.Constants;Yr.exports=function(){var e=0,t=0,n=0,r=0,u=0;return{get diskEntries(){return e},set diskEntries(i){e=t=i},get totalEntries(){return t},set totalEntries(i){t=e=i},get size(){return n},set size(i){n=i},get offset(){return r},set offset(i){r=i},get commentLength(){return u},set commentLength(i){u=i},get mainHeaderSize(){return k.ENDHDR+u},loadFromBinary:function(i){if((i.length!==k.ENDHDR||i.readUInt32LE(0)!==k.ENDSIG)&&(i.length<k.ZIP64HDR||i.readUInt32LE(0)!==k.ZIP64SIG))throw ze.Errors.INVALID_END();i.readUInt32LE(0)===k.ENDSIG?(e=i.readUInt16LE(k.ENDSUB),t=i.readUInt16LE(k.ENDTOT),n=i.readUInt32LE(k.ENDSIZ),r=i.readUInt32LE(k.ENDOFF),u=i.readUInt16LE(k.ENDCOM)):(e=ze.readBigUInt64LE(i,k.ZIP64SUB),t=ze.readBigUInt64LE(i,k.ZIP64TOT),n=ze.readBigUInt64LE(i,k.ZIP64SIZE),r=ze.readBigUInt64LE(i,k.ZIP64OFF),u=0)},toBinary:function(){var i=Buffer.alloc(k.ENDHDR+u);return i.writeUInt32LE(k.ENDSIG,0),i.writeUInt32LE(0,4),i.writeUInt16LE(e,k.ENDSUB),i.writeUInt16LE(t,k.ENDTOT),i.writeUInt32LE(n,k.ENDSIZ),i.writeUInt32LE(r,k.ENDOFF),i.writeUInt16LE(u,k.ENDCOM),i.fill(" ",k.ENDHDR),i},toJSON:function(){let i=function(s,a){let c=s.toString(16).toUpperCase();for(;c.length<a;)c="0"+c;return"0x"+c};return{diskEntries:e,totalEntries:t,size:n+" bytes",offset:i(r,4),commentLength:u}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var On=W(_n=>{_n.EntryHeader=Xr();_n.MainHeader=Qr()});var tu=W((Ms,eu)=>{eu.exports=function(e){var t=require("zlib"),n={chunkSize:(parseInt(e.length/1024)+1)*1024};return{deflate:function(){return t.deflateRawSync(e,n)},deflateAsync:function(r){var u=t.createDeflateRaw(n),i=[],s=0;u.on("data",function(a){i.push(a),s+=a.length}),u.on("end",function(){var a=Buffer.alloc(s),c=0;a.fill(0);for(var g=0;g<i.length;g++){var y=i[g];y.copy(a,c),c+=y.length}r&&r(a)}),u.end(e)}}}});var ru=W((Us,nu)=>{var Fo=+(process.versions?process.versions.node:"").split(".")[0]||0;nu.exports=function(e,t){var n=require("zlib");let r=Fo>=15&&t>0?{maxOutputLength:t}:{};return{inflate:function(){return n.inflateRawSync(e,r)},inflateAsync:function(u){var i=n.createInflateRaw(r),s=[],a=0;i.on("data",function(c){s.push(c),a+=c.length}),i.on("end",function(){var c=Buffer.alloc(a),g=0;c.fill(0);for(var y=0;y<s.length;y++){var h=s[y];h.copy(c,g),g+=h.length}u&&u(c)}),i.end(e)}}}});var au=W((ks,su)=>{"use strict";var{randomFillSync:uu}=require("crypto"),yo=Lt(),So=new Uint32Array(256).map((e,t)=>{for(let n=0;n<8;n++)(t&1)!==0?t=t>>>1^3988292384:t>>>=1;return t>>>0}),ou=(e,t)=>Math.imul(e,t)>>>0,iu=(e,t)=>So[(e^t)&255]^e>>>8,Qe=()=>typeof uu=="function"?uu(Buffer.alloc(12)):Qe.node();Qe.node=()=>{let e=Buffer.alloc(12),t=e.length;for(let n=0;n<t;n++)e[n]=Math.random()*256&255;return e};var bt={genSalt:Qe};function Mt(e){let t=Buffer.isBuffer(e)?e:Buffer.from(e);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let n=0;n<t.length;n++)this.updateKeys(t[n])}Mt.prototype.updateKeys=function(e){let t=this.keys;return t[0]=iu(t[0],e),t[1]+=t[0]&255,t[1]=ou(t[1],134775813)+1,t[2]=iu(t[2],t[1]>>>24),e};Mt.prototype.next=function(){let e=(this.keys[2]|2)>>>0;return ou(e,e^1)>>8&255};function xo(e){let t=new Mt(e);return function(n){let r=Buffer.alloc(n.length),u=0;for(let i of n)r[u++]=t.updateKeys(i^t.next());return r}}function Io(e){let t=new Mt(e);return function(n,r,u=0){r||(r=Buffer.alloc(n.length));for(let i of n){let s=t.next();r[u++]=i^s,t.updateKeys(i)}return r}}function _o(e,t,n){if(!e||!Buffer.isBuffer(e)||e.length<12)return Buffer.alloc(0);let r=xo(n),u=r(e.slice(0,12)),i=(t.flags&8)===8?t.timeHighByte:t.crc>>>24;if(u[11]!==i)throw yo.WRONG_PASSWORD();return r(e.slice(12))}function Oo(e){Buffer.isBuffer(e)&&e.length>=12?bt.genSalt=function(){return e.slice(0,12)}:e==="node"?bt.genSalt=Qe.node:bt.genSalt=Qe}function vo(e,t,n,r=!1){e==null&&(e=Buffer.alloc(0)),Buffer.isBuffer(e)||(e=Buffer.from(e.toString()));let u=Io(n),i=bt.genSalt();i[11]=t.crc>>>24&255,r&&(i[10]=t.crc>>>16&255);let s=Buffer.alloc(e.length+12);return u(i,s),u(e,s,12)}su.exports={decrypt:_o,encrypt:vo,_salter:Oo}});var cu=W(Ut=>{Ut.Deflater=tu();Ut.Inflater=ru();Ut.ZipCrypto=au()});var Rn=W((Hs,fu)=>{var N=Ve(),Ro=On(),V=N.Constants,vn=cu();fu.exports=function(e,t){var n=new Ro.EntryHeader,r=Buffer.alloc(0),u=Buffer.alloc(0),i=!1,s=null,a=Buffer.alloc(0),c=Buffer.alloc(0),g=!0;let y=e,h=typeof y.decoder=="object"?y.decoder:N.decoder;g=h.hasOwnProperty("efs")?h.efs:!1;function O(){return!t||!(t instanceof Uint8Array)?Buffer.alloc(0):(c=n.loadLocalHeaderFromBinary(t),t.slice(n.realDataOffset,n.realDataOffset+n.compressedSize))}function f(o){if(n.flags_desc){let l={},p=n.realDataOffset+n.compressedSize;if(t.readUInt32LE(p)==V.LOCSIG||t.readUInt32LE(p)==V.CENSIG)throw N.Errors.DESCRIPTOR_NOT_EXIST();if(t.readUInt32LE(p)==V.EXTSIG)l.crc=t.readUInt32LE(p+V.EXTCRC),l.compressedSize=t.readUInt32LE(p+V.EXTSIZ),l.size=t.readUInt32LE(p+V.EXTLEN);else if(t.readUInt16LE(p+12)===19280)l.crc=t.readUInt32LE(p+V.EXTCRC-4),l.compressedSize=t.readUInt32LE(p+V.EXTSIZ-4),l.size=t.readUInt32LE(p+V.EXTLEN-4);else throw N.Errors.DESCRIPTOR_UNKNOWN();if(l.compressedSize!==n.compressedSize||l.size!==n.size||l.crc!==n.crc)throw N.Errors.DESCRIPTOR_FAULTY();if(N.crc32(o)!==l.crc)return!1}else if(N.crc32(o)!==n.localHeader.crc)return!1;return!0}function E(o,l,p){if(typeof l>"u"&&typeof o=="string"&&(p=o,o=void 0),i)return o&&l&&l(Buffer.alloc(0),N.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var x=O();if(x.length===0)return o&&l&&l(x),x;if(n.encrypted){if(typeof p!="string"&&!Buffer.isBuffer(p))throw N.Errors.INVALID_PASS_PARAM();x=vn.ZipCrypto.decrypt(x,n,p)}var S=Buffer.alloc(n.size);switch(n.method){case N.Constants.STORED:if(x.copy(S),f(S))return o&&l&&l(S),S;throw o&&l&&l(S,N.Errors.BAD_CRC()),N.Errors.BAD_CRC();case N.Constants.DEFLATED:var T=new vn.Inflater(x,n.size);if(o)T.inflateAsync(function(P){P.copy(P,0),l&&(f(P)?l(P):l(P,N.Errors.BAD_CRC()))});else{if(T.inflate(S).copy(S,0),!f(S))throw N.Errors.BAD_CRC(`"${h.decode(r)}"`);return S}break;default:throw o&&l&&l(Buffer.alloc(0),N.Errors.UNKNOWN_METHOD()),N.Errors.UNKNOWN_METHOD()}}function D(o,l){if((!s||!s.length)&&Buffer.isBuffer(t))return o&&l&&l(O()),O();if(s.length&&!i){var p;switch(n.method){case N.Constants.STORED:return n.compressedSize=n.size,p=Buffer.alloc(s.length),s.copy(p),o&&l&&l(p),p;default:case N.Constants.DEFLATED:var x=new vn.Deflater(s);if(o)x.deflateAsync(function(T){p=Buffer.alloc(T.length),n.compressedSize=T.length,T.copy(p),l&&l(p)});else{var S=x.deflate();return n.compressedSize=S.length,S}x=null;break}}else if(o&&l)l(Buffer.alloc(0));else return Buffer.alloc(0)}function C(o,l){return(o.readUInt32LE(l+4)<<4)+o.readUInt32LE(l)}function d(o){try{for(var l=0,p,x,S;l+4<o.length;)p=o.readUInt16LE(l),l+=2,x=o.readUInt16LE(l),l+=2,S=o.slice(l,l+x),l+=x,V.ID_ZIP64===p&&A(S)}catch{throw N.Errors.EXTRA_FIELD_PARSE_ERROR()}}function A(o){var l,p,x,S;o.length>=V.EF_ZIP64_SCOMP&&(l=C(o,V.EF_ZIP64_SUNCOMP),n.size===V.EF_ZIP64_OR_32&&(n.size=l)),o.length>=V.EF_ZIP64_RHO&&(p=C(o,V.EF_ZIP64_SCOMP),n.compressedSize===V.EF_ZIP64_OR_32&&(n.compressedSize=p)),o.length>=V.EF_ZIP64_DSN&&(x=C(o,V.EF_ZIP64_RHO),n.offset===V.EF_ZIP64_OR_32&&(n.offset=x)),o.length>=V.EF_ZIP64_DSN+4&&(S=o.readUInt32LE(V.EF_ZIP64_DSN),n.diskNumStart===V.EF_ZIP64_OR_16&&(n.diskNumStart=S))}return{get entryName(){return h.decode(r)},get rawEntryName(){return r},set entryName(o){r=N.toBuffer(o,h.encode);var l=r[r.length-1];i=l===47||l===92,n.fileNameLength=r.length},get efs(){return typeof g=="function"?g(this.entryName):g},get extra(){return a},set extra(o){a=o,n.extraLength=o.length,d(o)},get comment(){return h.decode(u)},set comment(o){if(u=N.toBuffer(o,h.encode),n.commentLength=u.length,u.length>65535)throw N.Errors.COMMENT_TOO_LONG()},get name(){var o=h.decode(r);return i?o.substr(o.length-1).split("/").pop():o.split("/").pop()},get isDirectory(){return i},getCompressedData:function(){return D(!1,null)},getCompressedDataAsync:function(o){D(!0,o)},setData:function(o){s=N.toBuffer(o,N.decoder.encode),!i&&s.length?(n.size=s.length,n.method=N.Constants.DEFLATED,n.crc=N.crc32(o),n.changed=!0):n.method=N.Constants.STORED},getData:function(o){return n.changed?s:E(!1,null,o)},getDataAsync:function(o,l){n.changed?o(s):E(!0,o,l)},set attr(o){n.attr=o},get attr(){return n.attr},set header(o){n.loadFromBinary(o)},get header(){return n},packCentralHeader:function(){n.flags_efs=this.efs,n.extraLength=a.length;var o=n.centralHeaderToBinary(),l=N.Constants.CENHDR;return r.copy(o,l),l+=r.length,a.copy(o,l),l+=n.extraLength,u.copy(o,l),o},packLocalHeader:function(){let o=0;n.flags_efs=this.efs,n.extraLocalLength=c.length;let l=n.localHeaderToBinary(),p=Buffer.alloc(l.length+r.length+n.extraLocalLength);return l.copy(p,o),o+=l.length,r.copy(p,o),o+=r.length,c.copy(p,o),o+=c.length,p},toJSON:function(){let o=function(l){return"<"+(l&&l.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:n.toJSON(),compressedData:o(t),data:o(s)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Du=W(($s,lu)=>{var du=Rn(),Bo=On(),te=Ve();lu.exports=function(e,t){var n=[],r={},u=Buffer.alloc(0),i=new Bo.MainHeader,s=!1,a=null;let c=new Set,g=t,{noSort:y,decoder:h}=g;e?E(g.readEntries):s=!0;function O(){let C=new Set;for(let d of Object.keys(r)){let A=d.split("/");if(A.pop(),!!A.length)for(let o=0;o<A.length;o++){let l=A.slice(0,o+1).join("/")+"/";C.add(l)}}for(let d of C)if(!(d in r)){let A=new du(g);A.entryName=d,A.attr=16,A.temporary=!0,n.push(A),r[A.entryName]=A,c.add(A)}}function f(){if(s=!0,r={},i.diskEntries>(e.length-i.offset)/te.Constants.CENHDR)throw te.Errors.DISK_ENTRY_TOO_LARGE();n=new Array(i.diskEntries);for(var C=i.offset,d=0;d<n.length;d++){var A=C,o=new du(g,e);o.header=e.slice(A,A+=te.Constants.CENHDR),o.entryName=e.slice(A,A+=o.header.fileNameLength),o.header.extraLength&&(o.extra=e.slice(A,A+=o.header.extraLength)),o.header.commentLength&&(o.comment=e.slice(A,A+o.header.commentLength)),C+=o.header.centralHeaderSize,n[d]=o,r[o.entryName]=o}c.clear(),O()}function E(C){var d=e.length-te.Constants.ENDHDR,A=Math.max(0,d-65535),o=A,l=e.length,p=-1,x=0;for((typeof g.trailingSpace=="boolean"?g.trailingSpace:!1)&&(A=0),d;d>=o;d--)if(e[d]===80){if(e.readUInt32LE(d)===te.Constants.ENDSIG){p=d,x=d,l=d+te.Constants.ENDHDR,o=d-te.Constants.END64HDR;continue}if(e.readUInt32LE(d)===te.Constants.END64SIG){o=A;continue}if(e.readUInt32LE(d)===te.Constants.ZIP64SIG){p=d,l=d+te.readBigUInt64LE(e,d+te.Constants.ZIP64SIZE)+te.Constants.ZIP64LEAD;break}}if(p==-1)throw te.Errors.INVALID_FORMAT();i.loadFromBinary(e.slice(p,l)),i.commentLength&&(u=e.slice(x+te.Constants.ENDHDR)),C&&f()}function D(){n.length>1&&!y&&n.sort((C,d)=>C.entryName.toLowerCase().localeCompare(d.entryName.toLowerCase()))}return{get entries(){return s||f(),n.filter(C=>!c.has(C))},get comment(){return h.decode(u)},set comment(C){u=te.toBuffer(C,h.encode),i.commentLength=u.length},getEntryCount:function(){return s?n.length:i.diskEntries},forEach:function(C){this.entries.forEach(C)},getEntry:function(C){return s||f(),r[C]||null},setEntry:function(C){s||f(),n.push(C),r[C.entryName]=C,i.totalEntries=n.length},deleteFile:function(C,d=!0){s||f();let A=r[C];this.getEntryChildren(A,d).map(l=>l.entryName).forEach(this.deleteEntry)},deleteEntry:function(C){s||f();let d=r[C],A=n.indexOf(d);A>=0&&(n.splice(A,1),delete r[C],i.totalEntries=n.length)},getEntryChildren:function(C,d=!0){if(s||f(),typeof C=="object")if(C.isDirectory&&d){let A=[],o=C.entryName;for(let l of n)l.entryName.startsWith(o)&&A.push(l);return A}else return[C];return[]},getChildCount:function(C){if(C&&C.isDirectory){let d=this.getEntryChildren(C);return d.includes(C)?d.length-1:d.length}return 0},compressToBuffer:function(){s||f(),D();let C=[],d=[],A=0,o=0;i.size=0,i.offset=0;let l=0;for(let S of this.entries){let T=S.getCompressedData();S.header.offset=o;let P=S.packLocalHeader(),J=P.length+T.length;o+=J,C.push(P),C.push(T);let L=S.packCentralHeader();d.push(L),i.size+=L.length,A+=J+L.length,l++}A+=i.mainHeaderSize,i.offset=o,i.totalEntries=l,o=0;let p=Buffer.alloc(A);for(let S of C)S.copy(p,o),o+=S.length;for(let S of d)S.copy(p,o),o+=S.length;let x=i.toBinary();return u&&u.copy(x,te.Constants.ENDHDR),x.copy(p,o),e=p,s=!1,p},toAsyncBuffer:function(C,d,A,o){try{s||f(),D();let l=[],p=[],x=0,S=0,T=0;i.size=0,i.offset=0;let P=function(J){if(J.length>0){let L=J.shift(),le=L.entryName+L.extra.toString();A&&A(le),L.getCompressedDataAsync(function(ie){o&&o(le),L.header.offset=S;let tt=L.packLocalHeader(),Un=tt.length+ie.length;S+=Un,l.push(tt),l.push(ie);let jt=L.packCentralHeader();p.push(jt),i.size+=jt.length,x+=Un+jt.length,T++,P(J)})}else{x+=i.mainHeaderSize,i.offset=S,i.totalEntries=T,S=0;let L=Buffer.alloc(x);l.forEach(function(ie){ie.copy(L,S),S+=ie.length}),p.forEach(function(ie){ie.copy(L,S),S+=ie.length});let le=i.toBinary();u&&u.copy(le,te.Constants.ENDHDR),le.copy(L,S),e=L,s=!1,C(L)}};P(Array.from(this.entries))}catch(l){d(l)}}}}});var pu=W((Vs,Eu)=>{var j=Ve(),z=require("path"),wo=Rn(),Po=Du(),Ne=(...e)=>j.findLast(e,t=>typeof t=="boolean"),Cu=(...e)=>j.findLast(e,t=>typeof t=="string"),No=(...e)=>j.findLast(e,t=>typeof t=="function"),To={noSort:!1,readEntries:!1,method:j.Constants.NONE,fs:null};Eu.exports=function(e,t){let n=null,r=Object.assign(Object.create(null),To);e&&typeof e=="object"&&(e instanceof Uint8Array||(Object.assign(r,e),e=r.input?r.input:void 0,r.input&&delete r.input),Buffer.isBuffer(e)&&(n=e,r.method=j.Constants.BUFFER,e=void 0)),Object.assign(r,t);let u=new j(r);if((typeof r.decoder!="object"||typeof r.decoder.encode!="function"||typeof r.decoder.decode!="function")&&(r.decoder=j.decoder),e&&typeof e=="string")if(u.fs.existsSync(e))r.method=j.Constants.FILE,r.filename=e,n=u.fs.readFileSync(e);else throw j.Errors.INVALID_FILENAME();let i=new Po(n,r),{canonical:s,sanitize:a,zipnamefix:c}=j;function g(f){if(f&&i){var E;if(typeof f=="string"&&(E=i.getEntry(z.posix.normalize(f))),typeof f=="object"&&typeof f.entryName<"u"&&typeof f.header<"u"&&(E=i.getEntry(f.entryName)),E)return E}return null}function y(f){let{join:E,normalize:D,sep:C}=z.posix;return E(".",D(C+f.split("\\").join(C)+C))}function h(f){return f instanceof RegExp?(function(E){return function(D){return E.test(D)}})(f):typeof f!="function"?()=>!0:f}let O=(f,E)=>{let D=E.slice(-1);return D=D===u.sep?u.sep:"",z.relative(f,E)+D};return{readFile:function(f,E){var D=g(f);return D&&D.getData(E)||null},childCount:function(f){let E=g(f);if(E)return i.getChildCount(E)},readFileAsync:function(f,E){var D=g(f);D?D.getDataAsync(E):E(null,"getEntry failed for:"+f)},readAsText:function(f,E){var D=g(f);if(D){var C=D.getData();if(C&&C.length)return C.toString(E||"utf8")}return""},readAsTextAsync:function(f,E,D){var C=g(f);C?C.getDataAsync(function(d,A){if(A){E(d,A);return}d&&d.length?E(d.toString(D||"utf8")):E("")}):E("")},deleteFile:function(f,E=!0){var D=g(f);D&&i.deleteFile(D.entryName,E)},deleteEntry:function(f){var E=g(f);E&&i.deleteEntry(E.entryName)},addZipComment:function(f){i.comment=f},getZipComment:function(){return i.comment||""},addZipEntryComment:function(f,E){var D=g(f);D&&(D.comment=E)},getZipEntryComment:function(f){var E=g(f);return E&&E.comment||""},updateFile:function(f,E){var D=g(f);D&&D.setData(E)},addLocalFile:function(f,E,D,C){if(u.fs.existsSync(f)){E=E?y(E):"";let d=z.win32.basename(z.win32.normalize(f));E+=D||d;let A=u.fs.statSync(f),o=A.isFile()?u.fs.readFileSync(f):Buffer.alloc(0);A.isDirectory()&&(E+=u.sep),this.addFile(E,o,C,A)}else throw j.Errors.FILE_NOT_FOUND(f)},addLocalFileAsync:function(f,E){f=typeof f=="object"?f:{localPath:f};let D=z.resolve(f.localPath),{comment:C}=f,{zipPath:d,zipName:A}=f,o=this;u.fs.stat(D,function(l,p){if(l)return E(l,!1);d=d?y(d):"";let x=z.win32.basename(z.win32.normalize(D));if(d+=A||x,p.isFile())u.fs.readFile(D,function(S,T){return S?E(S,!1):(o.addFile(d,T,C,p),setImmediate(E,void 0,!0))});else if(p.isDirectory())return d+=u.sep,o.addFile(d,Buffer.alloc(0),C,p),setImmediate(E,void 0,!0)})},addLocalFolder:function(f,E,D){if(D=h(D),E=E?y(E):"",f=z.normalize(f),u.fs.existsSync(f)){let C=u.findFiles(f),d=this;if(C.length)for(let A of C){let o=z.join(E,O(f,A));D(o)&&d.addLocalFile(A,z.dirname(o))}}else throw j.Errors.FILE_NOT_FOUND(f)},addLocalFolderAsync:function(f,E,D,C){C=h(C),D=D?y(D):"",f=z.normalize(f);var d=this;u.fs.open(f,"r",function(A){if(A&&A.code==="ENOENT")E(void 0,j.Errors.FILE_NOT_FOUND(f));else if(A)E(void 0,A);else{var o=u.findFiles(f),l=-1,p=function(){if(l+=1,l<o.length){var x=o[l],S=O(f,x).split("\\").join("/");S=S.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),C(S)?u.fs.stat(x,function(T,P){T&&E(void 0,T),P.isFile()?u.fs.readFile(x,function(J,L){J?E(void 0,J):(d.addFile(D+S,L,"",P),p())}):(d.addFile(D+S+"/",Buffer.alloc(0),"",P),p())}):process.nextTick(()=>{p()})}else E(!0,void 0)};p()}})},addLocalFolderAsync2:function(f,E){let D=this;f=typeof f=="object"?f:{localPath:f},localPath=z.resolve(y(f.localPath));let{zipPath:C,filter:d,namefix:A}=f;d instanceof RegExp?d=(function(p){return function(x){return p.test(x)}})(d):typeof d!="function"&&(d=function(){return!0}),C=C?y(C):"",A=="latin1"&&(A=p=>p.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof A!="function"&&(A=p=>p);let o=p=>z.join(C,A(O(localPath,p))),l=p=>z.win32.basename(z.win32.normalize(A(p)));u.fs.open(localPath,"r",function(p){p&&p.code==="ENOENT"?E(void 0,j.Errors.FILE_NOT_FOUND(localPath)):p?E(void 0,p):u.findFilesAsync(localPath,function(x,S){if(x)return E(x);S=S.filter(T=>d(o(T))),S.length||E(void 0,!1),setImmediate(S.reverse().reduce(function(T,P){return function(J,L){if(J||L===!1)return setImmediate(T,J,!1);D.addLocalFileAsync({localPath:P,zipPath:z.dirname(o(P)),zipName:l(P)},T)}},E))})})},addLocalFolderPromise:function(f,E){return new Promise((D,C)=>{this.addLocalFolderAsync2(Object.assign({localPath:f},E),(d,A)=>{d&&C(d),A&&D(this)})})},addFile:function(f,E,D,C){f=c(f);let d=g(f),A=d!=null;A||(d=new wo(r),d.entryName=f),d.comment=D||"";let o=typeof C=="object"&&C instanceof u.fs.Stats;o&&(d.header.time=C.mtime);var l=d.isDirectory?16:0;let p=d.isDirectory?16384:32768;return o?p|=4095&C.mode:typeof C=="number"?p|=4095&C:p|=d.isDirectory?493:420,l=(l|p<<16)>>>0,d.attr=l,d.setData(E),A||i.setEntry(d),d},getEntries:function(f){return i.password=f,i?i.entries:[]},getEntry:function(f){return g(f)},getEntryCount:function(){return i.getEntryCount()},forEach:function(f){return i.forEach(f)},extractEntryTo:function(f,E,D,C,d,A){C=Ne(!1,C),d=Ne(!1,d),D=Ne(!0,D),A=Cu(d,A);var o=g(f);if(!o)throw j.Errors.NO_ENTRY();var l=s(o.entryName),p=a(E,A&&!o.isDirectory?A:D?l:z.basename(l));if(o.isDirectory){var x=i.getEntryChildren(o);return x.forEach(function(P){if(P.isDirectory)return;var J=P.getData();if(!J)throw j.Errors.CANT_EXTRACT_FILE();var L=s(P.entryName),le=a(E,D?L:z.basename(L));let ie=d?P.header.fileAttr:void 0;u.writeFileTo(le,J,C,ie)}),!0}var S=o.getData(i.password);if(!S)throw j.Errors.CANT_EXTRACT_FILE();if(u.fs.existsSync(p)&&!C)throw j.Errors.CANT_OVERRIDE();let T=d?f.header.fileAttr:void 0;return u.writeFileTo(p,S,C,T),!0},test:function(f){if(!i)return!1;for(var E in i.entries)try{if(E.isDirectory)continue;var D=i.entries[E].getData(f);if(!D)return!1}catch{return!1}return!0},extractAllTo:function(f,E,D,C){if(D=Ne(!1,D),C=Cu(D,C),E=Ne(!1,E),!i)throw j.Errors.NO_ZIP();i.entries.forEach(function(d){var A=a(f,s(d.entryName));if(d.isDirectory){u.makeDir(A);return}var o=d.getData(C);if(!o)throw j.Errors.CANT_EXTRACT_FILE();let l=D?d.header.fileAttr:void 0;u.writeFileTo(A,o,E,l);try{u.fs.utimesSync(A,d.header.time,d.header.time)}catch{throw j.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(f,E,D,C){if(C=No(E,D,C),D=Ne(!1,D),E=Ne(!1,E),!C)return new Promise((p,x)=>{this.extractAllToAsync(f,E,D,function(S){S?x(S):p(this)})});if(!i){C(j.Errors.NO_ZIP());return}f=z.resolve(f);let d=p=>a(f,z.normalize(s(p.entryName))),A=(p,x)=>new Error(p+': "'+x+'"'),o=[],l=[];i.entries.forEach(p=>{p.isDirectory?o.push(p):l.push(p)});for(let p of o){let x=d(p),S=D?p.header.fileAttr:void 0;try{u.makeDir(x),S&&u.fs.chmodSync(x,S),u.fs.utimesSync(x,p.header.time,p.header.time)}catch{C(A("Unable to create folder",x))}}l.reverse().reduce(function(p,x){return function(S){if(S)p(S);else{let T=z.normalize(s(x.entryName)),P=a(f,T);x.getDataAsync(function(J,L){if(L)p(L);else if(!J)p(j.Errors.CANT_EXTRACT_FILE());else{let le=D?x.header.fileAttr:void 0;u.writeFileToAsync(P,J,E,le,function(ie){ie||p(A("Unable to write file",P)),u.fs.utimes(P,x.header.time,x.header.time,function(tt){tt?p(A("Unable to set times",P)):p()})})}})}}},C)()},writeZip:function(f,E){if(arguments.length===1&&typeof f=="function"&&(E=f,f=""),!f&&r.filename&&(f=r.filename),!!f){var D=i.compressToBuffer();if(D){var C=u.writeFileTo(f,D,!0);typeof E=="function"&&E(C?null:new Error("failed"),"")}}},writeZipPromise:function(f,E){let{overwrite:D,perm:C}=Object.assign({overwrite:!0},E);return new Promise((d,A)=>{!f&&r.filename&&(f=r.filename),f||A("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(o=>{let l=p=>p?d(p):A("ADM-ZIP: Wasn't able to write zip file");u.writeFileToAsync(f,o,D,C,l)},A)})},toBufferPromise:function(){return new Promise((f,E)=>{i.toAsyncBuffer(f,E)})},toBuffer:function(f,E,D,C){return typeof f=="function"?(i.toAsyncBuffer(f,E,D,C),null):i.compressToBuffer()}}}});var as={};Tu(as,{CLAUDE_PROJECTS_DIR:()=>ju,CLIENT_IDS:()=>Ue,CLIENT_STATE_FILE:()=>$t,CONFIG_FILE:()=>bu,DEFAULT_CONFIG:()=>Hu,DEFAULT_CONTEXT_WINDOW:()=>Kn,HOME_DIR:()=>Z,InputType:()=>ln,MergeStrategy:()=>Dn,PID_FILE:()=>Uu,PLUGINS_DIR:()=>Mu,PRESETS_DIR:()=>Ht,PROJECT_TAKEOVER_CLIENT_IDS:()=>He,REFERENCE_COUNT_FILE:()=>ku,activateCodexAccount:()=>hi,applyCcrProjectTakeover:()=>gt,applyClientSelection:()=>Hi,applyConfigMappings:()=>mu,applyOpencodeProjectTakeover:()=>_t,applyPiProjectTakeover:()=>yt,applyQwenProjectTakeover:()=>xt,applyUserInputs:()=>gu,buildDependencyGraph:()=>hu,createManifest:()=>ns,deleteCodexAccount:()=>Fi,deleteProjectConfig:()=>qi,disableClient:()=>dn,disableConfiguredClients:()=>Vi,downloadPresetToTemp:()=>Go,enableClient:()=>fn,enableConfiguredClients:()=>$i,evaluateCondition:()=>Bn,evaluateConditions:()=>Tn,exportCodexRefreshToken:()=>Ai,exportPreset:()=>rs,extractMetadata:()=>Yo,extractPreset:()=>Zo,fillSensitiveInputs:()=>to,findMarketPresetByName:()=>ss,generateEnvVarName:()=>_r,getActiveCodexAccount:()=>Di,getAffectedFields:()=>$o,getCcrTakeoverStatus:()=>Fr,getClaudeProjectId:()=>jn,getClaudeSettingsLocalPath:()=>Rt,getClientConfig:()=>Y,getContextWindow:()=>Ke,getDefaultClientsConfig:()=>ei,getDefaultValue:()=>jo,getDynamicOptions:()=>Au,getMarketPresets:()=>vu,getPresetDir:()=>We,getProjectConfigDir:()=>me,getProjectConfigPath:()=>ut,getProjectTakeoverClients:()=>xr,getTempDir:()=>Su,getValueByPath:()=>Lo,importCodexAccountFromRefreshToken:()=>mi,importCurrentCodexAccount:()=>pi,isCcrProjectTakeoverActive:()=>Je,isClientEnabled:()=>Xt,isClientId:()=>Yn,isOpencodeProjectTakeoverActive:()=>Ot,isPiProjectTakeoverActive:()=>St,isPresetInstalled:()=>es,isProjectTakeoverClient:()=>ki,isQwenProjectTakeoverActive:()=>It,listClientStatuses:()=>vt,listCodexAccounts:()=>li,listPresets:()=>ts,listProjectConfigs:()=>hr,loadConfigFromManifest:()=>Ln,loadPreset:()=>Jo,manifestToPresetFile:()=>bn,markActiveCodexAccountLimitedAndSwitch:()=>Ei,mergeConfig:()=>oo,parseFieldPath:()=>Pn,readClaudeSettingsLocal:()=>Bt,readManifestFromDir:()=>xu,readPresetFile:()=>us,readProjectConfig:()=>Wi,readProjectConfigById:()=>Ki,refreshCcrProjectTakeover:()=>Sr,refreshCodexAccountTokens:()=>dr,refreshDueCodexAccounts:()=>gi,refreshProjectTakeovers:()=>Ir,removeCcrProjectTakeover:()=>Yt,removeOpencodeProjectTakeover:()=>an,removePiProjectTakeover:()=>en,removeQwenProjectTakeover:()=>un,replaceTemplateVariables:()=>et,resolveOptions:()=>Mo,restoreClient:()=>ji,sanitizeConfig:()=>En,saveManifest:()=>Qo,setCcrTakeover:()=>yr,setProjectTakeover:()=>Ji,setValueByPath:()=>Nn,shouldShowField:()=>bo,sortFieldsByDependencies:()=>Ho,syncGlobalProjectTakeovers:()=>Xi,validateInput:()=>ko,validatePreset:()=>Xo,writeProjectConfig:()=>Zi});module.exports=Lu(as);var oe=X(require("node:path")),rt=X(require("node:os")),Z=process.env.CCR_CONFIG_DIR||oe.default.join(rt.default.homedir(),".claude-code-router"),bu=oe.default.join(Z,"config.json"),Mu=oe.default.join(Z,"plugins"),Ht=oe.default.join(Z,"presets"),Uu=oe.default.join(Z,".claude-code-router.pid"),$t=oe.default.join(Z,"client-state.json"),ku=oe.default.join(rt.default.tmpdir(),"claude-code-reference-count.txt"),ju=oe.default.join(rt.default.homedir(),".claude","projects");function jn(e){return e.replace(/[\\/.]/g,"-")}function me(e=process.cwd()){return oe.default.join(Z,jn(e))}function ut(e=process.cwd()){return oe.default.join(me(e),"config.json")}var Hu={LOG:!1,OPENAI_API_KEY:"",OPENAI_BASE_URL:"",OPENAI_MODEL:""};var I=X(require("node:fs")),Zt=X(require("node:os")),b=X(require("node:path")),Zn=X(require("node:crypto"));var Ue=["claudeCode","codex","pi","qwenCode","opencode"],ue={claudeCode:{id:"claudeCode",name:"Claude Code",defaultConfig:{enabled:!1,managed:!1,configPath:"~/.claude/settings.json",modelAlias:"",activeAccountId:"",autoSwitchAccounts:!0,autoRefreshTokens:!0,quota:{}}},codex:{id:"codex",name:"Codex",defaultConfig:{enabled:!1,managed:!1,configPath:"~/.codex/config.toml",modelAlias:"ccr-opus",activeAccountId:"",autoSwitchAccounts:!0,autoRefreshTokens:!0,quota:{}}},pi:{id:"pi",name:"pi",defaultConfig:{enabled:!1,managed:!1,configPath:"~/.pi/agent",modelAlias:"ccr-opus",activeAccountId:"",autoSwitchAccounts:!0,autoRefreshTokens:!0,quota:{}}},qwenCode:{id:"qwenCode",name:"Qwen Code",defaultConfig:{enabled:!1,managed:!1,configPath:"~/.qwen/settings.json",modelAlias:"ccr-opus",activeAccountId:"",autoSwitchAccounts:!0,autoRefreshTokens:!0,quota:{}}},opencode:{id:"opencode",name:"opencode",defaultConfig:{enabled:!1,managed:!1,configPath:"~/.config/opencode/opencode.json",modelAlias:"ccr-opus",activeAccountId:"",autoSwitchAccounts:!0,autoRefreshTokens:!0,quota:{}}}},qn=b.default.join(Z,"backups","clients"),Et=b.default.join(Z,"codex-accounts"),lt=b.default.join(Et,"accounts.json"),$u="app_EMoamEEZ73f0CkXaXp7hrann",Vu="https://auth.openai.com/oauth/token",zu=1440*60,Wu=10080*60*1e3,Vt=b.default.join(Z,".statusline-backup.json"),zt=b.default.join(Z,".model-env-backup.json"),pt=["ANTHROPIC_MODEL","ANTHROPIC_DEFAULT_SONNET_MODEL","ANTHROPIC_DEFAULT_OPUS_MODEL","ANTHROPIC_DEFAULT_HAIKU_MODEL","ANTHROPIC_REASONING_MODEL"],Gt={CLAUDE_CODE_AUTO_COMPACT_WINDOW:"200000",CLAUDE_AUTOCOMPACT_PCT_OVERRIDE:"90",CLAUDE_CODE_SIMPLE:"1"},Kn=2e5;function _(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Ke(e){let t=e?.ContextWindow;if(typeof t=="number"&&Number.isFinite(t)&&t>0)return Math.floor(t);if(typeof t=="string"&&/^\d+$/.test(t.trim())){let n=parseInt(t.trim(),10);if(n>0)return n}return Kn}function Jt(){return $t}function Zu(e){return b.default.join(me(e),"ccr-state.json")}function qu(e){return w(e)}function Ku(e){let t=w(Jt());return t&&t[e]||{}}function Gu(e,t){q(e,t)}function Ju(e,t){let n=Jt(),r=w(n);r[e]=t,q(n,r)}function Gn(e){try{I.default.existsSync(e)&&I.default.unlinkSync(e)}catch{}}function Xu(e){let t=Jt(),n=w(t);n&&n[e]&&(delete n[e],Object.keys(n).length>0?q(t,n):Gn(t))}function Hn(e){return{read:()=>Ku(e),write:t=>Ju(e,t),clear:()=>Xu(e)}}function Jn(e){if(!e)return;let t=Zu(e);return{read:()=>qu(t),write:n=>Gu(t,n),clear:()=>Gn(t)}}function Ce(e){return e instanceof Error?e.message:String(e)}function At(e){return e==="~"?Zt.default.homedir():e.startsWith("~/")?b.default.join(Zt.default.homedir(),e.slice(2)):e}function Yu(e){return ue[e]}function Xn(e,t){let r=(_(e.Clients)?e.Clients:{})[t];return _(r)?r:{}}function Ge(e){let t=e?.Router?.families;return _(t)&&Object.keys(t).length>0}function Qu(e){return!!(e?.StatusLine?.enabled||Ge(e))}function ei(){return{claudeCode:{...ue.claudeCode.defaultConfig},codex:{...ue.codex.defaultConfig},pi:{...ue.pi.defaultConfig},qwenCode:{...ue.qwenCode.defaultConfig},opencode:{...ue.opencode.defaultConfig}}}function Y(e,t){let n=Yu(t),r=Xn(e,t),i=typeof r.enabled=="boolean"?!!r.enabled:t==="claudeCode"&&!_(e.Clients)?Qu(e):n.defaultConfig.enabled;return{...n.defaultConfig,...r,enabled:i,managed:!!r.managed,configPath:r.configPath||n.defaultConfig.configPath,modelAlias:r.modelAlias||n.defaultConfig.modelAlias,activeAccountId:r.activeAccountId||n.defaultConfig.activeAccountId}}function Yn(e){return Ue.includes(e)}function Xt(e,t){return Y(e,t).enabled}function Qn(e,t,n){let r=_(e.Clients)?{...e.Clients}:{},i={...Y(e,t),...n};return r[t]=i,e.Clients=r,i}function De(e,t){return At(Y(e,t).configPath)}function mt(e){let t=b.default.dirname(e);I.default.existsSync(t)||I.default.mkdirSync(t,{recursive:!0})}function de(e,t){if(!I.default.existsSync(t))return null;let n=b.default.join(qn,e);I.default.mkdirSync(n,{recursive:!0});let r=new Date().toISOString().replace(/[:.]/g,"-"),u=b.default.extname(t)||".bak",i=b.default.join(n,`${r}${u}`);return I.default.copyFileSync(t,i),i}function ti(e){let t=b.default.join(qn,e);if(!I.default.existsSync(t))return null;let n=I.default.readdirSync(t).filter(r=>!r.startsWith(".")).sort();return n.length===0?null:b.default.join(t,n[n.length-1])}function Me(e,t){let n=ti(e);return n?(mt(t),I.default.copyFileSync(n,t),n):null}function w(e){if(!I.default.existsSync(e))return{};let t;try{t=I.default.readFileSync(e,"utf-8")}catch{return{}}if(!t.trim())return{};let n;try{n=JSON.parse(t)}catch{return{}}return _(n)?n:{}}function q(e,t){let n=`${JSON.stringify(t,null,2)}
|
|
15
15
|
`;if(I.default.existsSync(e))try{if(I.default.readFileSync(e,"utf-8")===n)return}catch{}mt(e),I.default.writeFileSync(e,n,"utf-8")}function ke(e,t=""){return`http://127.0.0.1:${e.PORT||3456}${t}`}function ae(e){return typeof e!="string"?!1:/^https?:\/\/(127\.0\.0\.1|localhost):\d+(?:\/.*)?$/i.test(e.trim())}function Te(e){return e?.enableExtendedContext===!0}function er(e,t){_(e.env)||(e.env={});for(let a of pt)typeof e.env[a]=="string"&&e.env[a].startsWith("ccr-")&&delete e.env[a];if(!Ge(t))return;let n=t.Router.families,r=Object.keys(n),u=null;for(let a of r){let c=n[a],g=Te(c)?"[1m]":"",y=`ccr-${a}${g}`;switch(a){case"opus":e.env.ANTHROPIC_DEFAULT_OPUS_MODEL=y,u||(u="opus");break;case"sonnet":e.env.ANTHROPIC_DEFAULT_SONNET_MODEL=y,u||(u="sonnet");break;case"haiku":e.env.ANTHROPIC_DEFAULT_HAIKU_MODEL=y,u||(u="haiku");break}}let i=n.opus?"opus":u;if(i){let a=n[i],c=Te(a)?"[1m]":"";e.env.ANTHROPIC_MODEL=`ccr-${i}${c}`}let s=r.find(a=>n[a]?.think);if(s){let a=n[s],c=Te(a)?"[1m]":"";e.env.ANTHROPIC_REASONING_MODEL=`ccr-${s}${c}`}else if(u){let a=n[u],c=Te(a)?"[1m]":"";e.env.ANTHROPIC_REASONING_MODEL=`ccr-${u}${c}`}}function tr(e,t,n){e.autoCompactEnabled=!0,_(e.env)||(e.env={}),e.env.CLAUDE_AUTOCOMPACT_PCT_OVERRIDE==="0.8"&&delete e.env.CLAUDE_AUTOCOMPACT_PCT_OVERRIDE;let r=String(Ke(t)),u=e.env.CLAUDE_CODE_AUTO_COMPACT_WINDOW,i=n?.read().autoCompactWindow;if(u===void 0||u===i||i===void 0){let c=i===void 0&&u!==void 0&&u!==r?u:n?.read().previousAutoCompactWindow;e.env.CLAUDE_CODE_AUTO_COMPACT_WINDOW=r,n?.write({autoCompactWindow:r,...c!==void 0?{previousAutoCompactWindow:c}:{}})}let a=Gt.CLAUDE_AUTOCOMPACT_PCT_OVERRIDE;(e.env.CLAUDE_AUTOCOMPACT_PCT_OVERRIDE===void 0||e.env.CLAUDE_AUTOCOMPACT_PCT_OVERRIDE===a)&&(e.env.CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=a)}function nr(e,t){_(e.env)||(e.env={}),t.disableAttributionHeader===!1?delete e.env.CLAUDE_CODE_ATTRIBUTION_HEADER:e.env.CLAUDE_CODE_ATTRIBUTION_HEADER="0"}function ni(e){if(e.statusLine?.command==="ccr statusline"&&I.default.existsSync(Vt))try{let t=JSON.parse(I.default.readFileSync(Vt,"utf-8"));e.statusLine=t,I.default.unlinkSync(Vt)}catch{delete e.statusLine}if(I.default.existsSync(zt))try{let t=JSON.parse(I.default.readFileSync(zt,"utf-8"));_(e.env)||(e.env={});for(let[n,r]of Object.entries(t))e.env[n]=r;I.default.unlinkSync(zt)}catch{}}function ri(e,t){if(ni(e),_(e.env)){ae(e.env.ANTHROPIC_BASE_URL)&&(delete e.env.ANTHROPIC_BASE_URL,delete e.env.ANTHROPIC_AUTH_TOKEN);for(let u of pt)typeof e.env[u]=="string"&&e.env[u].startsWith("ccr-")&&delete e.env[u];let r=t?.read().autoCompactWindow;e.env.CLAUDE_CODE_AUTO_COMPACT_WINDOW===r&&delete e.env.CLAUDE_CODE_AUTO_COMPACT_WINDOW,t?.clear();for(let[u,i]of Object.entries(Gt))u!=="CLAUDE_CODE_AUTO_COMPACT_WINDOW"&&e.env[u]===i&&delete e.env[u];delete e.env.CLAUDE_CODE_ATTRIBUTION_HEADER,Object.keys(e.env).length===0&&delete e.env}e.statusLine?.command==="ccr statusline"&&delete e.statusLine,e.autoCompactEnabled===!0&&delete e.autoCompactEnabled}function ui(e){let t=_(e.env)?e.env:{};return t.ANTHROPIC_MODEL||t.ANTHROPIC_DEFAULT_SONNET_MODEL||t.ANTHROPIC_DEFAULT_OPUS_MODEL||t.ANTHROPIC_DEFAULT_HAIKU_MODEL}function rr(e){let t=_(e.env)?e.env:{};return!!(ae(t.ANTHROPIC_BASE_URL)||pt.some(n=>typeof t[n]=="string"&&t[n].startsWith("ccr-"))||e.statusLine?.command==="ccr statusline")}function it(e,t,n){let r=Y(e,"claudeCode"),u=De(e,"claudeCode"),i=t||{};return{id:"claudeCode",name:ue.claudeCode.name,enabled:r.enabled,managed:rr(i),configPath:r.configPath,exists:I.default.existsSync(u),activeModel:ui(i),details:n}}var ii={status(e){let t=De(e,"claudeCode");try{return it(e,w(t))}catch(n){return it(e,{},Ce(n))}},enable(e){let t=De(e,"claudeCode");this.status(e).managed||de("claudeCode",t);let r=w(t);return _(r.env)||(r.env={}),r.env.ANTHROPIC_BASE_URL=ke(e),r.env.ANTHROPIC_AUTH_TOKEN=e.APIKEY||"test",er(r,e),tr(r,e,Hn("claudeCode")),nr(r,e),e?.StatusLine?.enabled?r.statusLine={type:"command",command:"ccr statusline",padding:0}:r.statusLine?.command==="ccr statusline"&&delete r.statusLine,q(t,r),it(e,r)},disable(e){let t=De(e,"claudeCode");if(Me("claudeCode",t))return this.status(e);if(!I.default.existsSync(t))return this.status(e);let n=w(t);return ri(n,Hn("claudeCode")),q(t,n),it(e,n)},restore(e){return this.disable(e)}};function gt(e,t,n){_(e.env)||(e.env={}),e.env.ANTHROPIC_BASE_URL=ke(t),e.env.ANTHROPIC_AUTH_TOKEN=t.APIKEY||"test",er(e,t),tr(e,t,Jn(n)),nr(e,t),t?.StatusLine?.enabled?e.statusLine={type:"command",command:"ccr statusline",padding:0}:e.statusLine?.command==="ccr statusline"&&delete e.statusLine}function Yt(e,t,n){let r=Jn(t);if(_(e.env)){ae(e.env.ANTHROPIC_BASE_URL)&&(delete e.env.ANTHROPIC_BASE_URL,delete e.env.ANTHROPIC_AUTH_TOKEN);for(let c of pt)typeof e.env[c]=="string"&&e.env[c].startsWith("ccr-")&&delete e.env[c];let u=r?.read().autoCompactWindow,i=e.env.CLAUDE_CODE_AUTO_COMPACT_WINDOW,s=n?String(Ke(n)):void 0;(i===u||u===void 0&&s!==void 0&&i===s)&&delete e.env.CLAUDE_CODE_AUTO_COMPACT_WINDOW,r?.clear();for(let[c,g]of Object.entries(Gt))c!=="CLAUDE_CODE_AUTO_COMPACT_WINDOW"&&e.env[c]===g&&delete e.env[c];delete e.env.CLAUDE_CODE_ATTRIBUTION_HEADER,Object.keys(e.env).length===0&&delete e.env}e.statusLine?.command==="ccr statusline"&&delete e.statusLine,e.autoCompactEnabled===!0&&delete e.autoCompactEnabled}function Je(e){return rr(e)}function oi(e){if(!e)return;let t=e.trim(),n=t.match(/^"((?:\\.|[^"\\])*)"/);if(n)return n[1].replace(/\\"/g,'"').replace(/\\\\/g,"\\");let r=t.match(/^'([^']*)'/);return r?r[1]:t.match(/^([^#\s]+)/)?.[1]}function je(e){let t=!1,n=!1,r=!1;for(let u=0;u<e.length;u+=1){let i=e[u];if(r){r=!1;continue}if(i==="\\"&&n){r=!0;continue}if(i==='"'&&!t){n=!n;continue}if(i==="'"&&!n){t=!t;continue}if(i==="#"&&!t&&!n)return e.slice(0,u)}return e}function Dt(e,t){let n=!1;for(let r of e.split(/\r?\n/)){let u=je(r).trim();if(!u)continue;if(/^\[[^\]]+\]$/.test(u)){n=!0;continue}if(n)continue;let i=u.match(/^([A-Za-z0-9_.-]+)\s*=\s*(.+)$/);if(i?.[1]===t)return oi(i[2])}}function si(e,t){return e.split(/\r?\n/).some(n=>je(n).trim()===`[${t}]`)}function ur(e){return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function $n(e){return typeof e=="number"?String(e):ur(e)}function ai(e,t){let n=e?e.split(/\r?\n/):[],r=new Set,u=n.findIndex(a=>/^\s*\[[^\]]+\]\s*(?:#.*)?$/.test(a)),i=u===-1?n.length:u;for(let a=0;a<i;a+=1){let c=je(n[a]).trim().match(/^([A-Za-z0-9_.-]+)\s*=/);c&&Object.prototype.hasOwnProperty.call(t,c[1])&&(n[a]=`${c[1]} = ${$n(t[c[1]])}`,r.add(c[1]))}let s=Object.entries(t).filter(([a])=>!r.has(a)).map(([a,c])=>`${a} = ${$n(c)}`);return s.length>0&&n.splice(i,0,...s,""),n.join(`
|
|
16
16
|
`).replace(/\n{3,}/g,`
|
|
17
17
|
|