@dcrays/dcgchat-test 0.5.25 → 0.5.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +2 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -100,7 +100,8 @@ raw xml: ${i}`,a.status=t.status,a.requestId=t.headers&&t.headers["x-oss-request
|
|
|
100
100
|
`,lre=du.encode(Wo),pre=2,rx=class{constructor(t,r){let{escapeName:n}=this.constructor,i=j.isString(r),o=`Content-Disposition: form-data; name="${n(t)}"${!i&&r.name?`; filename="${n(r.name)}"`:""}${Wo}`;i?r=du.encode(String(r).replace(/\r?\n|\r\n?/g,Wo)):o+=`Content-Type: ${r.type||"application/octet-stream"}${Wo}`,this.headers=du.encode(o+Wo),this.contentLength=i?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+pre,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;j.isTypedArray(t)?yield t:yield*Md(t),yield lre}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},fre=(e,t,r)=>{let{tag:n="form-data-boundary",size:i=25,boundary:o=n+"-"+Ne.generateString(i,ure)}=r||{};if(!j.isFormData(e))throw TypeError("FormData instance required");if(o.length<1||o.length>70)throw Error("boundary must be 10-70 characters long");let s=du.encode("--"+o+Wo),a=du.encode("--"+o+"--"+Wo),c=a.byteLength,u=Array.from(e.entries()).map(([p,f])=>{let d=new rx(p,f);return c+=d.size,d});c+=s.byteLength*u.length,c=j.toFiniteNumber(c);let l={"Content-Type":`multipart/form-data; boundary=${o}`};return Number.isFinite(c)&&(l["Content-Length"]=c),t&&t(l),cre.from((async function*(){for(let p of u)yield s,yield*p.encode();yield a})())},MP=fre});import dre from"stream";var nx,LP,BP=se(()=>{"use strict";nx=class extends dre.Transform{__transform(t,r,n){this.push(t),n()}_transform(t,r,n){if(t.length!==0&&(this._transform=this.__transform,t[0]!==120)){let i=Buffer.alloc(2);i[0]=120,i[1]=156,this.push(i,r)}this.__transform(t,r,n)}},LP=nx});var hre,UP,$P=se(()=>{We();hre=(e,t)=>j.isAsyncFn(e)?function(...r){let n=r.pop();e.apply(this,r).then(i=>{try{t?n(null,...t(i)):n(null,i)}catch(o){n(o)}},n)}:e,UP=hre});function mre(e,t){e=e||10;let r=new Array(e),n=new Array(e),i=0,o=0,s;return t=t!==void 0?t:1e3,function(c){let u=Date.now(),l=n[o];s||(s=u),r[i]=c,n[i]=u;let p=o,f=0;for(;p!==i;)f+=r[p++],p=p%e;if(i=(i+1)%e,i===o&&(o=(o+1)%e),u-s<t)return;let d=l&&u-l;return d?Math.round(f*1e3/d):void 0}}var zP,WP=se(()=>{"use strict";zP=mre});function gre(e,t){let r=0,n=1e3/t,i,o,s=(u,l=Date.now())=>{r=l,i=null,o&&(clearTimeout(o),o=null),e(...u)};return[(...u)=>{let l=Date.now(),p=l-r;p>=n?s(u,l):(i=u,o||(o=setTimeout(()=>{o=null,s(i)},n-p)))},()=>i&&s(i)]}var HP,GP=se(()=>{HP=gre});var Xn,da,ha,jd=se(()=>{WP();GP();We();Xn=(e,t,r=3)=>{let n=0,i=zP(50,250);return HP(o=>{let s=o.loaded,a=o.lengthComputable?o.total:void 0,c=s-n,u=i(c),l=s<=a;n=s;let p={loaded:s,total:a,progress:a?s/a:void 0,bytes:c,rate:u||void 0,estimated:u&&a&&l?(a-s)/u:void 0,event:o,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(p)},r)},da=(e,t)=>{let r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},ha=e=>(...t)=>j.asap(()=>e(...t))});function ix(e){if(!e||typeof e!="string"||!e.startsWith("data:"))return 0;let t=e.indexOf(",");if(t<0)return 0;let r=e.slice(5,t),n=e.slice(t+1);if(/;base64/i.test(r)){let o=n.length,s=n.length;for(let f=0;f<s;f++)if(n.charCodeAt(f)===37&&f+2<s){let d=n.charCodeAt(f+1),h=n.charCodeAt(f+2);(d>=48&&d<=57||d>=65&&d<=70||d>=97&&d<=102)&&(h>=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102)&&(o-=2,f+=2)}let a=0,c=s-1,u=f=>f>=2&&n.charCodeAt(f-2)===37&&n.charCodeAt(f-1)===51&&(n.charCodeAt(f)===68||n.charCodeAt(f)===100);c>=0&&(n.charCodeAt(c)===61?(a++,c--):u(c)&&(a++,c-=3)),a===1&&c>=0&&(n.charCodeAt(c)===61||u(c))&&a++;let p=Math.floor(o/4)*3-(a||0);return p>0?p:0}return Buffer.byteLength(n,"utf8")}var VP=se(()=>{});import yre from"http";import vre from"https";import eD from"http2";import tD from"util";import Ai from"zlib";import Oi from"stream";import{EventEmitter as bre}from"events";function kre(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function nD(e,t,r){let n=t;if(!n&&n!==!1){let i=ZP.default.getProxyForUrl(r);i&&(n=new URL(i))}if(n){if(n.username&&(n.auth=(n.username||"")+":"+(n.password||"")),n.auth){if(!!(n.auth.username||n.auth.password))n.auth=(n.auth.username||"")+":"+(n.auth.password||"");else if(typeof n.auth=="object")throw new ue("Invalid proxy authorization",ue.ERR_BAD_OPTION,{proxy:n});let s=Buffer.from(n.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+s}e.headers.host=e.hostname+(e.port?":"+e.port:"");let i=n.hostname||n.host;e.hostname=i,e.host=i,e.port=n.port,e.path=r,n.protocol&&(e.protocol=n.protocol.includes(":")?n.protocol:`${n.protocol}:`)}e.beforeRedirects.proxy=function(o){nD(o,t,o.href)}}var ZP,rD,KP,xre,XP,wre,_re,Sre,JP,YP,ox,Ere,Tre,Cre,Ore,QP,Are,iD,oD=se(()=>{We();Dd();Nd();Rd();ZP=Br(TP(),1),rD=Br(PP(),1);Fd();iu();wr();Lo();Kr();DP();wn();NP();jP();tx();BP();$P();jd();VP();KP={flush:Ai.constants.Z_SYNC_FLUSH,finishFlush:Ai.constants.Z_SYNC_FLUSH},xre={flush:Ai.constants.BROTLI_OPERATION_FLUSH,finishFlush:Ai.constants.BROTLI_OPERATION_FLUSH},XP=j.isFunction(Ai.createBrotliDecompress),{http:wre,https:_re}=rD.default,Sre=/https:?/,JP=Ne.protocols.map(e=>e+":"),YP=(e,[t,r])=>(e.on("end",r).on("error",r),t),ox=class{constructor(){this.sessions=Object.create(null)}getSession(t,r){r=Object.assign({sessionTimeout:1e3},r);let n=this.sessions[t];if(n){let l=n.length;for(let p=0;p<l;p++){let[f,d]=n[p];if(!f.destroyed&&!f.closed&&tD.isDeepStrictEqual(d,r))return f}}let i=eD.connect(t,r),o,s=()=>{if(o)return;o=!0;let l=n,p=l.length,f=p;for(;f--;)if(l[f][0]===i){p===1?delete this.sessions[t]:l.splice(f,1);return}},a=i.request,{sessionTimeout:c}=r;if(c!=null){let l,p=0;i.request=function(){let f=a.apply(this,arguments);return p++,l&&(clearTimeout(l),l=null),f.once("close",()=>{--p||(l=setTimeout(()=>{l=null,s()},c))}),f}}i.once("close",s);let u=[i,r];return n?n.push(u):n=this.sessions[t]=[u],i}},Ere=new ox;Tre=typeof process<"u"&&j.kindOf(process)==="process",Cre=e=>new Promise((t,r)=>{let n,i,o=(c,u)=>{i||(i=!0,n&&n(c,u))},s=c=>{o(c),t(c)},a=c=>{o(c,!0),r(c)};e(s,a,c=>n=c).catch(a)}),Ore=({address:e,family:t})=>{if(!j.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},QP=(e,t)=>Ore(j.isObject(e)?e:{address:e,family:t}),Are={request(e,t){let r=e.protocol+"//"+e.hostname+":"+(e.port||(e.protocol==="https:"?443:80)),{http2Options:n,headers:i}=e,o=Ere.getSession(r,n),{HTTP2_HEADER_SCHEME:s,HTTP2_HEADER_METHOD:a,HTTP2_HEADER_PATH:c,HTTP2_HEADER_STATUS:u}=eD.constants,l={[s]:e.protocol.replace(":",""),[a]:e.method,[c]:e.path};j.forEach(i,(f,d)=>{d.charAt(0)!==":"&&(l[d]=f)});let p=o.request(l);return p.once("response",f=>{let d=p;f=Object.assign({},f);let h=f[u];delete f[u],d.headers=f,d.statusCode=+h,t(d)}),p}},iD=Tre&&function(t){return Cre(async function(n,i,o){let{data:s,lookup:a,family:c,httpVersion:u=1,http2Options:l}=t,{responseType:p,responseEncoding:f}=t,d=t.method.toUpperCase(),h,m=!1,v;if(u=+u,Number.isNaN(u))throw TypeError(`Invalid protocol version: '${t.httpVersion}' is not a number`);if(u!==1&&u!==2)throw TypeError(`Unsupported protocol version '${u}'`);let E=u===2;if(a){let te=UP(a,W=>j.isArray(W)?W:[W]);a=(W,X,A)=>{te(W,X,(B,G,Y)=>{if(B)return A(B);let D=j.isArray(G)?G.map(le=>QP(le)):[QP(G,Y)];X.all?A(B,D):A(B,D[0].address,D[0].family)})}}let S=new bre;function b(te){try{S.emit("abort",!te||te.type?new _r(null,t,v):te)}catch(W){console.warn("emit error",W)}}S.once("abort",i);let g=()=>{t.cancelToken&&t.cancelToken.unsubscribe(b),t.signal&&t.signal.removeEventListener("abort",b),S.removeAllListeners()};(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(b),t.signal&&(t.signal.aborted?b():t.signal.addEventListener("abort",b))),o((te,W)=>{if(h=!0,W){m=!0,g();return}let{data:X}=te;if(X instanceof Oi.Readable||X instanceof Oi.Duplex){let A=Oi.finished(X,()=>{A(),g()})}else g()});let y=Bo(t.baseURL,t.url,t.allowAbsoluteUrls),T=new URL(y,Ne.hasBrowserEnv?Ne.origin:void 0),R=T.protocol||JP[0];if(R==="data:"){if(t.maxContentLength>-1){let W=String(t.url||y||"");if(ix(W)>t.maxContentLength)return i(new ue("maxContentLength size of "+t.maxContentLength+" exceeded",ue.ERR_BAD_RESPONSE,t))}let te;if(d!=="GET")return _n(n,i,{status:405,statusText:"method not allowed",headers:{},config:t});try{te=Yb(t.url,p==="blob",{Blob:t.env&&t.env.Blob})}catch(W){throw ue.from(W,ue.ERR_BAD_REQUEST,t)}return p==="text"?(te=te.toString(f),(!f||f==="utf8")&&(te=j.stripBOM(te))):p==="stream"&&(te=Oi.Readable.from(te)),_n(n,i,{data:te,status:200,statusText:"OK",headers:new at,config:t})}if(JP.indexOf(R)===-1)return i(new ue("Unsupported protocol "+R,ue.ERR_BAD_REQUEST,t));let k=at.from(t.headers).normalize();k.set("User-Agent","axios/"+zo,!1);let{onUploadProgress:_,onDownloadProgress:C}=t,q=t.maxRate,N,P;if(j.isSpecCompliantForm(s)){let te=k.getContentType(/boundary=([-_\w\d]{10,70})/i);s=MP(s,W=>{k.set(W)},{tag:`axios-${zo}-boundary`,boundary:te&&te[1]||void 0})}else if(j.isFormData(s)&&j.isFunction(s.getHeaders)){if(k.set(s.getHeaders()),!k.hasContentLength())try{let te=await tD.promisify(s.getLength).call(s);Number.isFinite(te)&&te>=0&&k.setContentLength(te)}catch{}}else if(j.isBlob(s)||j.isFile(s))s.size&&k.setContentType(s.type||"application/octet-stream"),k.setContentLength(s.size||0),s=Oi.Readable.from(Md(s));else if(s&&!j.isStream(s)){if(!Buffer.isBuffer(s))if(j.isArrayBuffer(s))s=Buffer.from(new Uint8Array(s));else if(j.isString(s))s=Buffer.from(s,"utf-8");else return i(new ue("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",ue.ERR_BAD_REQUEST,t));if(k.setContentLength(s.length,!1),t.maxBodyLength>-1&&s.length>t.maxBodyLength)return i(new ue("Request body larger than maxBodyLength limit",ue.ERR_BAD_REQUEST,t))}let V=j.toFiniteNumber(k.getContentLength());j.isArray(q)?(N=q[0],P=q[1]):N=P=q,s&&(_||N)&&(j.isStream(s)||(s=Oi.Readable.from(s,{objectMode:!1})),s=Oi.pipeline([s,new ex({maxRate:j.toFiniteNumber(N)})],j.noop),_&&s.on("progress",YP(s,da(V,Xn(ha(_),!1,3)))));let I;if(t.auth){let te=t.auth.username||"",W=t.auth.password||"";I=te+":"+W}if(!I&&T.username){let te=T.username,W=T.password;I=te+":"+W}I&&k.delete("authorization");let H;try{H=jo(T.pathname+T.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(te){let W=new Error(te.message);return W.config=t,W.url=t.url,W.exists=!0,i(W)}k.set("Accept-Encoding","gzip, compress, deflate"+(XP?", br":""),!1);let J={path:H,method:d,headers:k.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:I,protocol:R,family:c,beforeRedirect:kre,beforeRedirects:{},http2Options:l};!j.isUndefined(a)&&(J.lookup=a),t.socketPath?J.socketPath=t.socketPath:(J.hostname=T.hostname.startsWith("[")?T.hostname.slice(1,-1):T.hostname,J.port=T.port,nD(J,t.proxy,R+"//"+T.hostname+(T.port?":"+T.port:"")+J.path));let re,M=Sre.test(J.protocol);if(J.agent=M?t.httpsAgent:t.httpAgent,E?re=Are:t.transport?re=t.transport:t.maxRedirects===0?re=M?vre:yre:(t.maxRedirects&&(J.maxRedirects=t.maxRedirects),t.beforeRedirect&&(J.beforeRedirects.config=t.beforeRedirect),re=M?_re:wre),t.maxBodyLength>-1?J.maxBodyLength=t.maxBodyLength:J.maxBodyLength=1/0,t.insecureHTTPParser&&(J.insecureHTTPParser=t.insecureHTTPParser),v=re.request(J,function(W){if(v.destroyed)return;let X=[W],A=j.toFiniteNumber(W.headers["content-length"]);if(C||P){let D=new ex({maxRate:j.toFiniteNumber(P)});C&&D.on("progress",YP(D,da(A,Xn(ha(C),!0,3)))),X.push(D)}let B=W,G=W.req||v;if(t.decompress!==!1&&W.headers["content-encoding"])switch((d==="HEAD"||W.statusCode===204)&&delete W.headers["content-encoding"],(W.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":X.push(Ai.createUnzip(KP)),delete W.headers["content-encoding"];break;case"deflate":X.push(new LP),X.push(Ai.createUnzip(KP)),delete W.headers["content-encoding"];break;case"br":XP&&(X.push(Ai.createBrotliDecompress(xre)),delete W.headers["content-encoding"])}B=X.length>1?Oi.pipeline(X,j.noop):X[0];let Y={status:W.statusCode,statusText:W.statusMessage,headers:new at(W.headers),config:t,request:G};if(p==="stream")Y.data=B,_n(n,i,Y);else{let D=[],le=0;B.on("data",function(de){D.push(de),le+=de.length,t.maxContentLength>-1&&le>t.maxContentLength&&(m=!0,B.destroy(),b(new ue("maxContentLength size of "+t.maxContentLength+" exceeded",ue.ERR_BAD_RESPONSE,t,G)))}),B.on("aborted",function(){if(m)return;let de=new ue("stream has been aborted",ue.ERR_BAD_RESPONSE,t,G);B.destroy(de),i(de)}),B.on("error",function(de){v.destroyed||i(ue.from(de,null,t,G))}),B.on("end",function(){try{let de=D.length===1?D[0]:Buffer.concat(D);p!=="arraybuffer"&&(de=de.toString(f),(!f||f==="utf8")&&(de=j.stripBOM(de))),Y.data=de}catch(de){return i(ue.from(de,null,t,Y.request,Y))}_n(n,i,Y)})}S.once("abort",D=>{B.destroyed||(B.emit("error",D),B.destroy())})}),S.once("abort",te=>{v.close?v.close():v.destroy(te)}),v.on("error",function(W){i(ue.from(W,null,t,v))}),v.on("socket",function(W){W.setKeepAlive(!0,1e3*60)}),t.timeout){let te=parseInt(t.timeout,10);if(Number.isNaN(te)){b(new ue("error trying to parse `config.timeout` to int",ue.ERR_BAD_OPTION_VALUE,t,v));return}v.setTimeout(te,function(){if(h)return;let X=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",A=t.transitional||Ci;t.timeoutErrorMessage&&(X=t.timeoutErrorMessage),b(new ue(X,A.clarifyTimeoutError?ue.ETIMEDOUT:ue.ECONNABORTED,t,v))})}else v.setTimeout(0);if(j.isStream(s)){let te=!1,W=!1;s.on("end",()=>{te=!0}),s.once("error",X=>{W=!0,v.destroy(X)}),s.on("close",()=>{!te&&!W&&b(new _r("Request stream has been aborted",t,v))}),s.pipe(v)}else s&&v.write(s),v.end()})}});var sD,aD=se(()=>{Kr();sD=Ne.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,Ne.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(Ne.origin),Ne.navigator&&/(msie|trident)/i.test(Ne.navigator.userAgent)):()=>!0});var cD,uD=se(()=>{We();Kr();cD=Ne.hasStandardBrowserEnv?{write(e,t,r,n,i,o,s){if(typeof document>"u")return;let a=[`${e}=${encodeURIComponent(t)}`];j.isNumber(r)&&a.push(`expires=${new Date(r).toUTCString()}`),j.isString(n)&&a.push(`path=${n}`),j.isString(i)&&a.push(`domain=${i}`),o===!0&&a.push("secure"),j.isString(s)&&a.push(`SameSite=${s}`),document.cookie=a.join("; ")},read(e){if(typeof document>"u")return null;let t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}}});function Xr(e,t){t=t||{};let r={};function n(u,l,p,f){return j.isPlainObject(u)&&j.isPlainObject(l)?j.merge.call({caseless:f},u,l):j.isPlainObject(l)?j.merge({},l):j.isArray(l)?l.slice():l}function i(u,l,p,f){if(j.isUndefined(l)){if(!j.isUndefined(u))return n(void 0,u,p,f)}else return n(u,l,p,f)}function o(u,l){if(!j.isUndefined(l))return n(void 0,l)}function s(u,l){if(j.isUndefined(l)){if(!j.isUndefined(u))return n(void 0,u)}else return n(void 0,l)}function a(u,l,p){if(p in t)return n(u,l);if(p in e)return n(void 0,u)}let c={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(u,l,p)=>i(lD(u),lD(l),p,!0)};return j.forEach(Object.keys({...e,...t}),function(l){if(l==="__proto__"||l==="constructor"||l==="prototype")return;let p=j.hasOwnProp(c,l)?c[l]:i,f=p(e[l],t[l],l);j.isUndefined(f)&&p!==a||(r[l]=f)}),r}var lD,Ld=se(()=>{"use strict";We();wn();lD=e=>e instanceof at?{...e}:e});var Bd,sx=se(()=>{Kr();We();aD();uD();Nd();Ld();wn();Rd();Bd=e=>{let t=Xr({},e),{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:o,headers:s,auth:a}=t;if(t.headers=s=at.from(s),t.url=jo(Bo(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),j.isFormData(r)){if(Ne.hasStandardBrowserEnv||Ne.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(j.isFunction(r.getHeaders)){let c=r.getHeaders(),u=["content-type","content-length"];Object.entries(c).forEach(([l,p])=>{u.includes(l.toLowerCase())&&s.set(l,p)})}}if(Ne.hasStandardBrowserEnv&&(n&&j.isFunction(n)&&(n=n(t)),n||n!==!1&&sD(t.url))){let c=i&&o&&cD.read(o);c&&s.set(i,c)}return t}});var Rre,pD,fD=se(()=>{We();Dd();iu();wr();Lo();Jb();Kr();wn();jd();sx();Rre=typeof XMLHttpRequest<"u",pD=Rre&&function(e){return new Promise(function(r,n){let i=Bd(e),o=i.data,s=at.from(i.headers).normalize(),{responseType:a,onUploadProgress:c,onDownloadProgress:u}=i,l,p,f,d,h;function m(){d&&d(),h&&h(),i.cancelToken&&i.cancelToken.unsubscribe(l),i.signal&&i.signal.removeEventListener("abort",l)}let v=new XMLHttpRequest;v.open(i.method.toUpperCase(),i.url,!0),v.timeout=i.timeout;function E(){if(!v)return;let b=at.from("getAllResponseHeaders"in v&&v.getAllResponseHeaders()),y={data:!a||a==="text"||a==="json"?v.responseText:v.response,status:v.status,statusText:v.statusText,headers:b,config:e,request:v};_n(function(R){r(R),m()},function(R){n(R),m()},y),v=null}"onloadend"in v?v.onloadend=E:v.onreadystatechange=function(){!v||v.readyState!==4||v.status===0&&!(v.responseURL&&v.responseURL.indexOf("file:")===0)||setTimeout(E)},v.onabort=function(){v&&(n(new ue("Request aborted",ue.ECONNABORTED,e,v)),v=null)},v.onerror=function(g){let y=g&&g.message?g.message:"Network Error",T=new ue(y,ue.ERR_NETWORK,e,v);T.event=g||null,n(T),v=null},v.ontimeout=function(){let g=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded",y=i.transitional||Ci;i.timeoutErrorMessage&&(g=i.timeoutErrorMessage),n(new ue(g,y.clarifyTimeoutError?ue.ETIMEDOUT:ue.ECONNABORTED,e,v)),v=null},o===void 0&&s.setContentType(null),"setRequestHeader"in v&&j.forEach(s.toJSON(),function(g,y){v.setRequestHeader(y,g)}),j.isUndefined(i.withCredentials)||(v.withCredentials=!!i.withCredentials),a&&a!=="json"&&(v.responseType=i.responseType),u&&([f,h]=Xn(u,!0),v.addEventListener("progress",f)),c&&v.upload&&([p,d]=Xn(c),v.upload.addEventListener("progress",p),v.upload.addEventListener("loadend",d)),(i.cancelToken||i.signal)&&(l=b=>{v&&(n(!b||b.type?new _r(null,e,v):b),v.abort(),v=null)},i.cancelToken&&i.cancelToken.subscribe(l),i.signal&&(i.signal.aborted?l():i.signal.addEventListener("abort",l)));let S=fu(i.url);if(S&&Ne.protocols.indexOf(S)===-1){n(new ue("Unsupported protocol "+S+":",ue.ERR_BAD_REQUEST,e));return}v.send(o||null)})}});var Ire,dD,hD=se(()=>{Lo();wr();We();Ire=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,i,o=function(u){if(!i){i=!0,a();let l=u instanceof Error?u:this.reason;n.abort(l instanceof ue?l:new _r(l instanceof Error?l.message:l))}},s=t&&setTimeout(()=>{s=null,o(new ue(`timeout of ${t}ms exceeded`,ue.ETIMEDOUT))},t),a=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(o):u.removeEventListener("abort",o)}),e=null)};e.forEach(u=>u.addEventListener("abort",o));let{signal:c}=n;return c.unsubscribe=()=>j.asap(a),c}},dD=Ire});var qre,Pre,Dre,ax,mD=se(()=>{qre=function*(e,t){let r=e.byteLength;if(!t||r<t){yield e;return}let n=0,i;for(;n<r;)i=n+t,yield e.slice(n,i),n=i},Pre=async function*(e,t){for await(let r of Dre(e))yield*qre(r,t)},Dre=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},ax=(e,t,r,n)=>{let i=Pre(e,t),o=0,s,a=c=>{s||(s=!0,n&&n(c))};return new ReadableStream({async pull(c){try{let{done:u,value:l}=await i.next();if(u){a(),c.close();return}let p=l.byteLength;if(r){let f=o+=p;r(f)}c.enqueue(new Uint8Array(l))}catch(u){throw a(u),u}},cancel(c){return a(c),i.return()}},{highWaterMark:2})}});var gD,Ud,Nre,yD,vD,bD,Fre,Mre,cx,o_e,xD=se(()=>{Kr();We();wr();hD();mD();wn();jd();sx();Dd();gD=64*1024,{isFunction:Ud}=j,Nre=(({Request:e,Response:t})=>({Request:e,Response:t}))(j.global),{ReadableStream:yD,TextEncoder:vD}=j.global,bD=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Fre=e=>{e=j.merge.call({skipUndefined:!0},Nre,e);let{fetch:t,Request:r,Response:n}=e,i=t?Ud(t):typeof fetch=="function",o=Ud(r),s=Ud(n);if(!i)return!1;let a=i&&Ud(yD),c=i&&(typeof vD=="function"?(h=>m=>h.encode(m))(new vD):async h=>new Uint8Array(await new r(h).arrayBuffer())),u=o&&a&&bD(()=>{let h=!1,m=new r(Ne.origin,{body:new yD,method:"POST",get duplex(){return h=!0,"half"}}).headers.has("Content-Type");return h&&!m}),l=s&&a&&bD(()=>j.isReadableStream(new n("").body)),p={stream:l&&(h=>h.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(h=>{!p[h]&&(p[h]=(m,v)=>{let E=m&&m[h];if(E)return E.call(m);throw new ue(`Response type '${h}' is not supported`,ue.ERR_NOT_SUPPORT,v)})});let f=async h=>{if(h==null)return 0;if(j.isBlob(h))return h.size;if(j.isSpecCompliantForm(h))return(await new r(Ne.origin,{method:"POST",body:h}).arrayBuffer()).byteLength;if(j.isArrayBufferView(h)||j.isArrayBuffer(h))return h.byteLength;if(j.isURLSearchParams(h)&&(h=h+""),j.isString(h))return(await c(h)).byteLength},d=async(h,m)=>{let v=j.toFiniteNumber(h.getContentLength());return v??f(m)};return async h=>{let{url:m,method:v,data:E,signal:S,cancelToken:b,timeout:g,onDownloadProgress:y,onUploadProgress:T,responseType:R,headers:k,withCredentials:_="same-origin",fetchOptions:C}=Bd(h),q=t||fetch;R=R?(R+"").toLowerCase():"text";let N=dD([S,b&&b.toAbortSignal()],g),P=null,V=N&&N.unsubscribe&&(()=>{N.unsubscribe()}),I;try{if(T&&u&&v!=="get"&&v!=="head"&&(I=await d(k,E))!==0){let W=new r(m,{method:"POST",body:E,duplex:"half"}),X;if(j.isFormData(E)&&(X=W.headers.get("content-type"))&&k.setContentType(X),W.body){let[A,B]=da(I,Xn(ha(T)));E=ax(W.body,gD,A,B)}}j.isString(_)||(_=_?"include":"omit");let H=o&&"credentials"in r.prototype,J={...C,signal:N,method:v.toUpperCase(),headers:k.normalize().toJSON(),body:E,duplex:"half",credentials:H?_:void 0};P=o&&new r(m,J);let re=await(o?q(P,C):q(m,J)),M=l&&(R==="stream"||R==="response");if(l&&(y||M&&V)){let W={};["status","statusText","headers"].forEach(G=>{W[G]=re[G]});let X=j.toFiniteNumber(re.headers.get("content-length")),[A,B]=y&&da(X,Xn(ha(y),!0))||[];re=new n(ax(re.body,gD,A,()=>{B&&B(),V&&V()}),W)}R=R||"text";let te=await p[j.findKey(p,R)||"text"](re,h);return!M&&V&&V(),await new Promise((W,X)=>{_n(W,X,{data:te,headers:at.from(re.headers),status:re.status,statusText:re.statusText,config:h,request:P})})}catch(H){throw V&&V(),H&&H.name==="TypeError"&&/Load failed|fetch/i.test(H.message)?Object.assign(new ue("Network Error",ue.ERR_NETWORK,h,P,H&&H.response),{cause:H.cause||H}):ue.from(H,H&&H.code,h,P,H&&H.response)}}},Mre=new Map,cx=e=>{let t=e&&e.env||{},{fetch:r,Request:n,Response:i}=t,o=[n,i,r],s=o.length,a=s,c,u,l=Mre;for(;a--;)c=o[a],u=l.get(c),u===void 0&&l.set(c,u=a?new Map:Fre(t)),l=u;return u},o_e=cx()});function Bre(e,t){e=j.isArray(e)?e:[e];let{length:r}=e,n,i,o={};for(let s=0;s<r;s++){n=e[s];let a;if(i=n,!Lre(n)&&(i=ux[(a=String(n)).toLowerCase()],i===void 0))throw new ue(`Unknown adapter '${a}'`);if(i&&(j.isFunction(i)||(i=i.get(t))))break;o[a||"#"+s]=i}if(!i){let s=Object.entries(o).map(([c,u])=>`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build")),a=r?s.length>1?`since :
|
|
101
101
|
`+s.map(wD).join(`
|
|
102
102
|
`):" "+wD(s[0]):"as no adapter specified";throw new ue("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return i}var ux,wD,Lre,$d,lx=se(()=>{We();oD();fD();xD();wr();ux={http:iD,xhr:pD,fetch:{get:cx}};j.forEach(ux,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});wD=e=>`- ${e}`,Lre=e=>j.isFunction(e)||e===null||e===!1;$d={getAdapter:Bre,adapters:ux}});function px(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new _r(null,e)}function zd(e){return px(e),e.headers=at.from(e.headers),e.data=su.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),$d.getAdapter(e.adapter||la.adapter,e)(e).then(function(n){return px(e),n.data=su.call(e,e.transformResponse,n),n.headers=at.from(n.headers),n},function(n){return au(n)||(px(e),n&&n.response&&(n.response.data=su.call(e,e.transformResponse,n.response),n.response.headers=at.from(n.response.headers))),Promise.reject(n)})}var _D=se(()=>{"use strict";_P();Db();qd();Lo();wn();lx()});function Ure(e,t,r){if(typeof e!="object")throw new ue("options must be an object",ue.ERR_BAD_OPTION_VALUE);let n=Object.keys(e),i=n.length;for(;i-- >0;){let o=n[i],s=t[o];if(s){let a=e[o],c=a===void 0||s(a,o,e);if(c!==!0)throw new ue("option "+o+" must be "+c,ue.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new ue("Unknown option "+o,ue.ERR_BAD_OPTION)}}var Wd,SD,hu,ED=se(()=>{"use strict";Fd();wr();Wd={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Wd[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});SD={};Wd.transitional=function(t,r,n){function i(o,s){return"[Axios v"+zo+"] Transitional option '"+o+"'"+s+(n?". "+n:"")}return(o,s,a)=>{if(t===!1)throw new ue(i(s," has been removed"+(r?" in "+r:"")),ue.ERR_DEPRECATED);return r&&!SD[s]&&(SD[s]=!0,console.warn(i(s," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(o,s,a):!0}};Wd.spelling=function(t){return(r,n)=>(console.warn(`${n} is likely a misspelling of ${t}`),!0)};hu={assertOptions:Ure,validators:Wd}});var Pr,ma,mu,kD=se(()=>{"use strict";We();Rd();lP();_D();Ld();Nd();ED();wn();iu();Pr=hu.validators,ma=class{constructor(t){this.defaults=t||{},this.interceptors={request:new kb,response:new kb}}async request(t,r){try{return await this._request(t,r)}catch(n){if(n instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;let o=i.stack?i.stack.replace(/^.+\n/,""):"";try{n.stack?o&&!String(n.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(n.stack+=`
|
|
103
|
-
`+o):n.stack=o}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=Xr(this.defaults,r);let{transitional:n,paramsSerializer:i,headers:o}=r;n!==void 0&&hu.assertOptions(n,{silentJSONParsing:Pr.transitional(Pr.boolean),forcedJSONParsing:Pr.transitional(Pr.boolean),clarifyTimeoutError:Pr.transitional(Pr.boolean),legacyInterceptorReqResOrdering:Pr.transitional(Pr.boolean)},!1),i!=null&&(j.isFunction(i)?r.paramsSerializer={serialize:i}:hu.assertOptions(i,{encode:Pr.function,serialize:Pr.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),hu.assertOptions(r,{baseUrl:Pr.spelling("baseURL"),withXsrfToken:Pr.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=o&&j.merge(o.common,o[r.method]);o&&j.forEach(["delete","get","head","post","put","patch","common"],h=>{delete o[h]}),r.headers=at.concat(s,o);let a=[],c=!0;this.interceptors.request.forEach(function(m){if(typeof m.runWhen=="function"&&m.runWhen(r)===!1)return;c=c&&m.synchronous;let v=r.transitional||Ci;v&&v.legacyInterceptorReqResOrdering?a.unshift(m.fulfilled,m.rejected):a.push(m.fulfilled,m.rejected)});let u=[];this.interceptors.response.forEach(function(m){u.push(m.fulfilled,m.rejected)});let l,p=0,f;if(!c){let h=[zd.bind(this),void 0];for(h.unshift(...a),h.push(...u),f=h.length,l=Promise.resolve(r);p<f;)l=l.then(h[p++],h[p++]);return l}f=a.length;let d=r;for(;p<f;){let h=a[p++],m=a[p++];try{d=h(d)}catch(v){m.call(this,v);break}}try{l=zd.call(this,d)}catch(h){return Promise.reject(h)}for(p=0,f=u.length;p<f;)l=l.then(u[p++],u[p++]);return l}getUri(t){t=Xr(this.defaults,t);let r=Bo(t.baseURL,t.url,t.allowAbsoluteUrls);return jo(r,t.params,t.paramsSerializer)}};j.forEach(["delete","get","head","options"],function(t){ma.prototype[t]=function(r,n){return this.request(Xr(n||{},{method:t,url:r,data:(n||{}).data}))}});j.forEach(["post","put","patch"],function(t){function r(n){return function(o,s,a){return this.request(Xr(a||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:o,data:s}))}}ma.prototype[t]=r(),ma.prototype[t+"Form"]=r(!0)});mu=ma});var fx,TD,CD=se(()=>{"use strict";Lo();fx=class e{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(o){r=o});let n=this;this.promise.then(i=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](i);n._listeners=null}),this.promise.then=i=>{let o,s=new Promise(a=>{n.subscribe(a),o=a}).then(i);return s.cancel=function(){n.unsubscribe(o)},s},t(function(o,s,a){n.reason||(n.reason=new _r(o,s,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){let t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new e(function(i){t=i}),cancel:t}}},TD=fx});function dx(e){return function(r){return e.apply(null,r)}}var OD=se(()=>{"use strict"});function hx(e){return j.isObject(e)&&e.isAxiosError===!0}var AD=se(()=>{"use strict";We()});var mx,RD,ID=se(()=>{mx={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(mx).forEach(([e,t])=>{mx[t]=e});RD=mx});function qD(e){let t=new mu(e),r=Zc(mu.prototype.request,t);return j.extend(r,mu.prototype,t,{allOwnKeys:!0}),j.extend(r,t,null,{allOwnKeys:!0}),r.create=function(i){return qD(Xr(e,i))},r}var wt,Ri,PD=se(()=>{"use strict";We();cb();kD();Ld();qd();Ib();Lo();CD();Db();Fd();nu();wr();OD();AD();wn();lx();ID();wt=qD(la);wt.Axios=mu;wt.CanceledError=_r;wt.CancelToken=TD;wt.isCancel=au;wt.VERSION=zo;wt.toFormData=Ti;wt.AxiosError=ue;wt.Cancel=wt.CanceledError;wt.all=function(t){return Promise.all(t)};wt.spread=dx;wt.isAxiosError=hx;wt.mergeConfig=Xr;wt.AxiosHeaders=at;wt.formToJSON=e=>Id(j.isHTMLForm(e)?new FormData(e):e);wt.getAdapter=$d.getAdapter;wt.HttpStatusCode=RD;wt.default=wt;Ri=wt});var r1e,n1e,i1e,o1e,s1e,a1e,c1e,u1e,l1e,p1e,f1e,d1e,h1e,m1e,g1e,y1e,Hd=se(()=>{PD();({Axios:r1e,AxiosError:n1e,CanceledError:i1e,isCancel:o1e,CancelToken:s1e,VERSION:a1e,all:c1e,Cancel:u1e,isAxiosError:l1e,spread:p1e,toFormData:f1e,AxiosHeaders:d1e,HttpStatusCode:h1e,formToJSON:m1e,getAdapter:g1e,mergeConfig:y1e}=Ri)});var ND=x((b1e,DD)=>{(function(){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t={rotl:function(r,n){return r<<n|r>>>32-n},rotr:function(r,n){return r<<32-n|r>>>n},endian:function(r){if(r.constructor==Number)return t.rotl(r,8)&16711935|t.rotl(r,24)&4278255360;for(var n=0;n<r.length;n++)r[n]=t.endian(r[n]);return r},randomBytes:function(r){for(var n=[];r>0;r--)n.push(Math.floor(Math.random()*256));return n},bytesToWords:function(r){for(var n=[],i=0,o=0;i<r.length;i++,o+=8)n[o>>>5]|=r[i]<<24-o%32;return n},wordsToBytes:function(r){for(var n=[],i=0;i<r.length*32;i+=8)n.push(r[i>>>5]>>>24-i%32&255);return n},bytesToHex:function(r){for(var n=[],i=0;i<r.length;i++)n.push((r[i]>>>4).toString(16)),n.push((r[i]&15).toString(16));return n.join("")},hexToBytes:function(r){for(var n=[],i=0;i<r.length;i+=2)n.push(parseInt(r.substr(i,2),16));return n},bytesToBase64:function(r){for(var n=[],i=0;i<r.length;i+=3)for(var o=r[i]<<16|r[i+1]<<8|r[i+2],s=0;s<4;s++)i*8+s*6<=r.length*8?n.push(e.charAt(o>>>6*(3-s)&63)):n.push("=");return n.join("")},base64ToBytes:function(r){r=r.replace(/[^A-Z0-9+\/]/ig,"");for(var n=[],i=0,o=0;i<r.length;o=++i%4)o!=0&&n.push((e.indexOf(r.charAt(i-1))&Math.pow(2,-2*o+8)-1)<<o*2|e.indexOf(r.charAt(i))>>>6-o*2);return n}};DD.exports=t})()});var yx=x((x1e,FD)=>{var gx={utf8:{stringToBytes:function(e){return gx.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(gx.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],r=0;r<e.length;r++)t.push(e.charCodeAt(r)&255);return t},bytesToString:function(e){for(var t=[],r=0;r<e.length;r++)t.push(String.fromCharCode(e[r]));return t.join("")}}};FD.exports=gx});var LD=x((w1e,jD)=>{jD.exports=function(e){return e!=null&&(MD(e)||$re(e)||!!e._isBuffer)};function MD(e){return!!e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function $re(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&MD(e.slice(0,0))}});var UD=x((_1e,BD)=>{(function(){var e=ND(),t=yx().utf8,r=LD(),n=yx().bin,i=function(o,s){o.constructor==String?s&&s.encoding==="binary"?o=n.stringToBytes(o):o=t.stringToBytes(o):r(o)?o=Array.prototype.slice.call(o,0):!Array.isArray(o)&&o.constructor!==Uint8Array&&(o=o.toString());for(var a=e.bytesToWords(o),c=o.length*8,u=1732584193,l=-271733879,p=-1732584194,f=271733878,d=0;d<a.length;d++)a[d]=(a[d]<<8|a[d]>>>24)&16711935|(a[d]<<24|a[d]>>>8)&4278255360;a[c>>>5]|=128<<c%32,a[(c+64>>>9<<4)+14]=c;for(var h=i._ff,m=i._gg,v=i._hh,E=i._ii,d=0;d<a.length;d+=16){var S=u,b=l,g=p,y=f;u=h(u,l,p,f,a[d+0],7,-680876936),f=h(f,u,l,p,a[d+1],12,-389564586),p=h(p,f,u,l,a[d+2],17,606105819),l=h(l,p,f,u,a[d+3],22,-1044525330),u=h(u,l,p,f,a[d+4],7,-176418897),f=h(f,u,l,p,a[d+5],12,1200080426),p=h(p,f,u,l,a[d+6],17,-1473231341),l=h(l,p,f,u,a[d+7],22,-45705983),u=h(u,l,p,f,a[d+8],7,1770035416),f=h(f,u,l,p,a[d+9],12,-1958414417),p=h(p,f,u,l,a[d+10],17,-42063),l=h(l,p,f,u,a[d+11],22,-1990404162),u=h(u,l,p,f,a[d+12],7,1804603682),f=h(f,u,l,p,a[d+13],12,-40341101),p=h(p,f,u,l,a[d+14],17,-1502002290),l=h(l,p,f,u,a[d+15],22,1236535329),u=m(u,l,p,f,a[d+1],5,-165796510),f=m(f,u,l,p,a[d+6],9,-1069501632),p=m(p,f,u,l,a[d+11],14,643717713),l=m(l,p,f,u,a[d+0],20,-373897302),u=m(u,l,p,f,a[d+5],5,-701558691),f=m(f,u,l,p,a[d+10],9,38016083),p=m(p,f,u,l,a[d+15],14,-660478335),l=m(l,p,f,u,a[d+4],20,-405537848),u=m(u,l,p,f,a[d+9],5,568446438),f=m(f,u,l,p,a[d+14],9,-1019803690),p=m(p,f,u,l,a[d+3],14,-187363961),l=m(l,p,f,u,a[d+8],20,1163531501),u=m(u,l,p,f,a[d+13],5,-1444681467),f=m(f,u,l,p,a[d+2],9,-51403784),p=m(p,f,u,l,a[d+7],14,1735328473),l=m(l,p,f,u,a[d+12],20,-1926607734),u=v(u,l,p,f,a[d+5],4,-378558),f=v(f,u,l,p,a[d+8],11,-2022574463),p=v(p,f,u,l,a[d+11],16,1839030562),l=v(l,p,f,u,a[d+14],23,-35309556),u=v(u,l,p,f,a[d+1],4,-1530992060),f=v(f,u,l,p,a[d+4],11,1272893353),p=v(p,f,u,l,a[d+7],16,-155497632),l=v(l,p,f,u,a[d+10],23,-1094730640),u=v(u,l,p,f,a[d+13],4,681279174),f=v(f,u,l,p,a[d+0],11,-358537222),p=v(p,f,u,l,a[d+3],16,-722521979),l=v(l,p,f,u,a[d+6],23,76029189),u=v(u,l,p,f,a[d+9],4,-640364487),f=v(f,u,l,p,a[d+12],11,-421815835),p=v(p,f,u,l,a[d+15],16,530742520),l=v(l,p,f,u,a[d+2],23,-995338651),u=E(u,l,p,f,a[d+0],6,-198630844),f=E(f,u,l,p,a[d+7],10,1126891415),p=E(p,f,u,l,a[d+14],15,-1416354905),l=E(l,p,f,u,a[d+5],21,-57434055),u=E(u,l,p,f,a[d+12],6,1700485571),f=E(f,u,l,p,a[d+3],10,-1894986606),p=E(p,f,u,l,a[d+10],15,-1051523),l=E(l,p,f,u,a[d+1],21,-2054922799),u=E(u,l,p,f,a[d+8],6,1873313359),f=E(f,u,l,p,a[d+15],10,-30611744),p=E(p,f,u,l,a[d+6],15,-1560198380),l=E(l,p,f,u,a[d+13],21,1309151649),u=E(u,l,p,f,a[d+4],6,-145523070),f=E(f,u,l,p,a[d+11],10,-1120210379),p=E(p,f,u,l,a[d+2],15,718787259),l=E(l,p,f,u,a[d+9],21,-343485551),u=u+S>>>0,l=l+b>>>0,p=p+g>>>0,f=f+y>>>0}return e.endian([u,l,p,f])};i._ff=function(o,s,a,c,u,l,p){var f=o+(s&a|~s&c)+(u>>>0)+p;return(f<<l|f>>>32-l)+s},i._gg=function(o,s,a,c,u,l,p){var f=o+(s&c|a&~c)+(u>>>0)+p;return(f<<l|f>>>32-l)+s},i._hh=function(o,s,a,c,u,l,p){var f=o+(s^a^c)+(u>>>0)+p;return(f<<l|f>>>32-l)+s},i._ii=function(o,s,a,c,u,l,p){var f=o+(a^(s|~c))+(u>>>0)+p;return(f<<l|f>>>32-l)+s},i._blocksize=16,i._digestsize=16,BD.exports=function(o,s){if(o==null)throw new Error("Illegal argument "+o);var a=e.wordsToBytes(i(o,s));return s&&s.asBytes?a:s&&s.asString?n.bytesToString(a):e.bytesToHex(a)}})()});function $D(e,t){let r=Date.now()+zre;vx.set(e,{token:t,expiresAt:r})}function Gd(e){let t=vx.get(e);return t?Date.now()>=t.expiresAt?(vx.delete(e),null):t.token:null}var zre,vx,bx=se(()=>{"use strict";zre=3600*1e3,vx=new Map});function Vre(e){let t=e.baseURL??"",r=e.url??"",n=r.startsWith("http")?r:`${t.replace(/\/$/,"")}/${r.replace(/^\//,"")}`,i=(e.method??"GET").toUpperCase(),o=e.headers??{},s=["curl","-X",i,`'${n}'`];for(let[a,c]of Object.entries(o))c!==void 0&&c!==""&&s.push("-H",`'${a}: ${c}'`);if(i!=="GET"&&e.data!==void 0){let a=typeof e.data=="string"?e.data:JSON.stringify(e.data);s.push("-d",`'${a.replace(/'/g,"'\\''")}'`)}return s.join(" ")}function Kre(e,t,r,n,i="1.0.0"){let o={timestamp:t,path:r,version:i,...e},a=Object.keys(o).sort().map(c=>{let u=o[c];return u===void 0?"":`${c}${typeof u=="object"?JSON.stringify(u):u}`}).join("")+Gre[n];return(0,WD.default)(a).toUpperCase()}function Xre(e,t,r){let n=Date.now(),i={"Content-Type":"application/json",appKey:Hre[dl],sign:Kre(e,n,t,dl,zD),timestamp:n,version:zD};return r&&(i.authorization=r),i}function Vd(e,t,r){let n=or()||{appId:100},i={method:"POST",url:e,data:{...t,_appId:n.appId},headers:Xre({...t,_appId:n.appId},e,r?.userToken)};return r?.botToken&&(i.__botToken=r.botToken),xx.request(i)}var WD,Wre,Hre,Gre,zD,xx,HD=se(()=>{"use strict";Hd();WD=Br(UD(),1);bx();Er();zt();Ke();Wre={production:"https://api-gateway.shuwenda.com",test:"https://api-gateway.shuwenda.icu",develop:"https://shenyu-dev.shuwenda.icu"},Hre={production:"2A1C74D315CB4A01BF3DA8983695AFE2",test:"7374A073CCBD4C8CA84FAD33896F0B69",develop:"7374A073CCBD4C8CA84FAD33896F0B69"},Gre={production:"34E9023008EA445AAE6CC075CC954F46",test:"FE93D3322CB94E978CE95BD4AA2A37D7",develop:"FE93D3322CB94E978CE95BD4AA2A37D7"},zD="1.0.0";xx=Ri.create({baseURL:Wre[dl],timeout:1e4});xx.interceptors.request.use(e=>{if(e.headers?.authorization)return e;let t=e.__botToken;if(t){let r=Gd(t);r&&(e.headers=e.headers||{},e.headers.authorization=r)}return e},e=>Promise.reject(e));xx.interceptors.response.use(e=>e.data,e=>{let t=e.config??{},r=Vre(t);return $(`[request] curl for backend (failed request): ${r}`,"error"),Promise.reject(e)})});var GD,VD,Jre,Kd,wx=se(()=>{"use strict";HD();bx();Er();Ke();GD=async(e,t,r)=>{await Kd(t);let n=await Vd("/user/getStsTokenByAsync",{sourceFileName:e,isPrivate:r},{botToken:t});if(!n||!n.data||!n.data.bucket)throw new Error("\u83B7\u53D6 OSS \u4E34\u65F6\u51ED\u8BC1\u5931\u8D25");return n.data},VD=async(e,t)=>{try{await Kd(t);let r=await Vd("/user/generateSignUrl",{loudPlatform:0,fileName:e},{botToken:t});return r.code===0&&r.data?r.data.filePath??"":""}catch{return""}},Jre=async e=>{let t=gr(),r=await Vd("/organization/queryUserTokenByBotTokenV2",{botToken:e,_userId:t.userId??0});return!r||!r.data||!r.data.token?($("\u83B7\u53D6\u7ED1\u5B9A\u7684\u7528\u6237\u4FE1\u606F\u5931\u8D25: token:"+e+"|"+JSON.stringify(r),"error"),""):r.data.token},Kd=async e=>{let t=Gd(e);if(t)return t;$(`[api] cache miss, fetching userToken for botToken=${e.slice(0,10)}...`);let r=await Jre(e);return $D(e,r),r}});import{extname as Yre}from"node:path";import{fileURLToPath as Qre}from"node:url";function tne(e){if(typeof e=="string"){let t=e.trim();if(t.startsWith("file:"))try{return Qre(t)}catch{return e}return e}if(Buffer.isBuffer(e))return e;if(e&&typeof e=="object"){if(ArrayBuffer.isView(e)&&!(e instanceof DataView)&&!Buffer.isBuffer(e)){let n=e;return Buffer.from(n.buffer,n.byteOffset,n.byteLength)}let t=e,r=t.path??t.filePath;if(typeof r=="string"&&r.trim())return r.trim()}return e}function _x(e){let t=e.split(/[/\\]/).pop()??e,r=Yre(t).toLowerCase();return r?rne[r]:void 0}function nne(e,t){if(typeof e=="string")return _x(e)??"application/octet-stream";if(Buffer.isBuffer(e)){if(t){let i=_x(t);if(i)return i}return"application/octet-stream"}let r=e.type?.trim();if(r&&r!=="application/octet-stream")return r;let n=typeof e.name=="string"&&e.name?e.name:"";if(n){let i=_x(n);if(i)return i}return r||"application/octet-stream"}async function ine(e){if(Buffer.isBuffer(e))return{content:e,fileName:"file"};if(typeof e=="string")return{content:e,fileName:e.split(/[/\\]/).pop()??"file"};let t=Buffer.from(await e.arrayBuffer()),r=e.name;return{content:t,fileName:typeof r=="string"&&r?r:"file"}}var KD,L1e,Zre,ene,rne,Xd,Sx=se(()=>{"use strict";KD=Br(aq(),1);wx();Ke();L1e=1024*1024,Zre=1024*1024,ene=900*1e3;rne={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".gif":"image/gif",".webp":"image/webp",".bmp":"image/bmp",".svg":"image/svg+xml",".ico":"image/x-icon",".avif":"image/avif",".heic":"image/heic",".heif":"image/heif",".pdf":"application/pdf",".mp4":"video/mp4",".webm":"video/webm",".mov":"video/quicktime",".mp3":"audio/mpeg",".wav":"audio/wav",".ogg":"audio/ogg",".opus":"audio/opus",".m4a":"audio/mp4",".aac":"audio/aac",".flac":"audio/flac",".txt":"text/plain; charset=utf-8",".log":"text/plain; charset=utf-8",".csv":"text/csv; charset=utf-8",".html":"text/html; charset=utf-8",".htm":"text/html; charset=utf-8",".css":"text/css; charset=utf-8",".js":"text/javascript; charset=utf-8",".mjs":"text/javascript; charset=utf-8",".json":"application/json; charset=utf-8",".xml":"application/xml; charset=utf-8",".md":"text/markdown; charset=utf-8",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation"};Xd=async(e,t,r=1,n)=>{await Kd(t);let i=tne(e),{content:o,fileName:s}=await ine(i),a=await GD(s,t,r),c=nne(i,s),u=n?.onProgress,l={accessKeyId:a.tempAccessKeyId,accessKeySecret:a.tempAccessKeySecret,stsToken:a.tempSecurityToken,bucket:a.bucket,endpoint:a.endPoint,region:a.region,secure:!0,cname:!0,authorizationV4:!0,timeout:n?.timeoutMs??ene},p=new KD.default(l),f=`${a.uploadDir}${a.ossFileKey}`;try{let d,h={progress:E=>{u?.(E)},parallel:4,partSize:Zre,mime:c,headers:{"Content-Disposition":"inline"}};if(d=await p.multipartUpload(f,o,h),d?.res?.status!==200)return $(`OSS \u4E0A\u4F20\u5931\u8D25, ${d?.res?.status}`,"error"),"";let v=(d?.res?.requestUrls||[])[0]||"";return $(`OSS \u4E0A\u4F20\u6210\u529F, ${r===1&&d.name||v}`),r===1&&d.name||v}catch(d){$(`OSS \u4E0A\u4F20\u5931\u8D25: ${d}`,"error")}}});import one from"node:path";import kx from"node:fs";function Ii(){let t=Et().replace("workspace","cron");return one.join(t,"jobs.json")}function Ho(e,t){let r=t?.trim();if(!r)return null;if(!kx.existsSync(e))return $(`readCronJobSessionKey: file not found ${e}`,"error"),null;try{let n=kx.readFileSync(e,"utf8");return(JSON.parse(n).jobs??[]).find(s=>s.id===r)||null}catch(n){return $(`readCronJobSessionKey: failed to read ${e}: ${String(n)}`,"error"),null}}async function sne(e){let t=Ii(),r=gr().botToken;if(kx.existsSync(t))try{let n=await Xd(t,r??"",0);$(`\u5B9A\u65F6\u4EFB\u52A1\u66F4\u65B0\u6210\u529F: ${n}`);let i=e?.split(":")||[],o=i.at(-1)??"",s=i.at(-2)??"";K_({event_type:"cron",operation_type:"install",session_id:o,agent_id:s,oss_url:n})}catch(n){$(`${t} upload failed: ${n}`,"error")}else $(`${t} not found`,"error")}function ga(e){let t=Ii(),r=Ho(t,e);if(!r||!r.sessionKey){$(`sendDcgchatCron: invalid job or missing sessionKey for jobId=${e}`,"error");return}let{sessionKey:n}=r;$(`sessionKey: ${n}, jobId: ${e}`),Ex!==null&&clearTimeout(Ex),Ex=setTimeout(()=>{sne(n)},C_)}var Ex,XD,JD,YD,QD,Tx,Jd=se(()=>{"use strict";$r();lt();Sx();Ke();qi();Er();zt();Ex=null;XD=async e=>{if(!e?.trim()){$("onRemoveCronJob: empty jobId","error");return}xt({method:"cron.remove",params:{id:e}})},JD=async e=>{if(!e?.trim()){$("onRemoveCronJob: empty jobId","error");return}xt({method:"cron.update",params:{id:e,patch:{enabled:!1}}})},YD=async e=>{if(!e?.trim()){$("onRemoveCronJob: empty jobId","error");return}xt({method:"cron.update",params:{id:e,patch:{enabled:!0}}})},QD=async(e,t)=>{let r=e?.trim();if(!r){$("onRemoveCronJob: empty jobId","error");return}let n=Ii(),{sessionKey:i}=Ho(n,e)||{};if(!i){$(`onRunCronJob: no sessionKey for job id=${r}`,"error");return}no(i,t),xt({method:"cron.runs",params:{scope:"job",id:e,limit:50,offset:0,status:"all",sortDir:"desc"}}),xt({method:"cron.run",params:{id:e,mode:"force"}})},Tx=async(e,t,r)=>{let n=e?.trim();if(!n){$("finishedDcgchatCron: empty jobId","error");return}let i=Ii(),{sessionKey:o,name:s}=Ho(i,n)||{};if(!o){$(`finishedDcgchatCron: no sessionKey for job id=${n}`,"error");return}let a=Dn(o)||`${Date.now()}`,c=o.split(":"),u=c.at(-1)??"",l=c.at(-2)??"",p=W_({agentId:l,sessionId:`${u}`,messageId:a||`${Date.now()}`,real_mobook:u?"":1}),f={source:"cron"};r&&(f.hasFile=!0),sn(p,{response:t,message_tags:f,is_finish:-1}),setTimeout(()=>{sr(p,"cron send")},200);let d=Sr(),h=gr();yr()&&d?.send(JSON.stringify({messageType:"openclaw_bot_event",source:"client",content:{event_type:"notify",operation_type:"cron",bot_token:h.botToken,app_id:h.appId,session_id:u,agent_id:l,real_mobook:u?"":1,title:s}})),N_(o),$(`finishedDcgchatCron: job=${n} sessionKey=${o}`)}});import Cx from"node:os";import Pi from"node:path";function eN(e){return Pi.normalize(e.trim()).replace(/\\/g,"/")}function ZD(e,t){let r=Pi.resolve(t),n=Pi.resolve(e),i=Pi.relative(r,n);return!(i.startsWith("..")||Pi.isAbsolute(i))}function Ox(e,t,r){let n=t?.trim();if(n&&ZD(e,n))return!0;if(r?.length){for(let o of r)if(ZD(e,o))return!0}let i=eN(e);return i.startsWith("/workspace/")||i==="/workspace"||i.startsWith("/mobook/")||i==="/mobook"?!0:/^[A-Za-z]:\/(workspace|mobook)(\/|$)/.test(i)}function Ax(e){return e.replace(/[`'",,*_)\]]+$/u,"").trimEnd()}function Rx(e){let t=e.trim();return t&&(t==="~"?Cx.homedir():t.startsWith("~/")?Pi.resolve(Cx.homedir(),t.slice(2)):t.startsWith("~\\")?Pi.resolve(Cx.homedir(),t.slice(2)):t)}function tN(e,t){if(!e)return[];let r=e.match(/\/workspace\/[^\s]+|\/mobook\/[^\s]+/g)??[],n=e.match(/[A-Za-z]:[/\\](?:workspace|mobook)[/\\][^\s]+/g)??[],i=e.match(/~[/\\][^\s`'")\]]+/g)??[],o=[],s=t?.trim();if(s){let u=new Set;u.add(s),u.add(eN(s)),Pi.sep==="\\"&&u.add(s.replace(/\//g,"\\"));for(let l of u){if(!l)continue;let p=0;for(;p<e.length;){let f=e.indexOf(l,p);if(f===-1)break;let d=f+l.length;for(;d<e.length&&!/\s/.test(e[d]);)d++;o.push(e.slice(f,d)),p=f+1}}}let c=[...r,...n,...i,...o].map(u=>Ax(u)).filter(Boolean).map(u=>u.startsWith("~")?Rx(u):u);return[...new Set(c)]}var rN=se(()=>{"use strict"});function ane(e,t){if(typeof e=="string"){let r=e.trim();r&&t.push(r);return}if(e&&typeof e=="object"){let r=e,n=typeof r.path=="string"?r.path.trim():"",i=typeof r.file=="string"?r.file.trim():"",o=n||i;o&&t.push(o)}}function cne(e){if(e==null||typeof e!="object")return[];let r=e.attachments;if(!Array.isArray(r))return[];let n=[];for(let i of r)ane(i,n);return[...new Set(n)]}function nN(e){let t=new Set,r=[];for(let n of e)!n||t.has(n)||(t.add(n),r.push(n));return r}function iN(e,t,r,n){let o=cne(e).map(a=>Rx(Ax(a))).filter(Boolean).filter(a=>Ox(a,r,n));if(o.length>0)return nN(o);let s=tN(t,r).filter(a=>Ox(a,r,n));return nN(s)}var oN=se(()=>{"use strict";rN()});async function sN(e){try{if(e.event==="agent"){let t=e.payload,r=B_(t.runId),n=or(r);t.data?.delta&&n.sessionId&&_l(t.data.delta,n,0)}if(e.event==="cron"){let t=e.payload;if(t?.action==="started"?$(`[Gateway] \u5B9A\u65F6\u4EFB\u52A1\u6267\u884C\u5F00\u59CB: ${JSON.stringify(t)}`):$(`[Gateway] \u6536\u5230\u5B9A\u65F6\u4EFB\u52A1\u4E8B\u4EF6: ${JSON.stringify(t)}`),t?.action==="added"&&ga(t?.jobId),t?.action==="updated"&&ga(t?.jobId),t?.action==="removed"&&ga(t?.jobId),t?.action==="finished"){let r=typeof t?.jobId=="string"?t.jobId.trim():"";if(t?.status==="ok"){let n=typeof t?.summary=="string"?t.summary:"";n.indexOf("HEARTBEAT_OK")>=0&&n!=="HEARTBEAT_OK"&&(n=n.replace("HEARTBEAT_OK",""));let o=gt()?.channels?.[be],s=iN(t,n,Et(),o?.allowedPaths),a=Ii(),c=r?Ho(a,r):null,u=c&&typeof c.sessionKey=="string"?c.sessionKey.trim():"";if(u&&s.length>0){let p=Dn(u)||`${Date.now()}`;no(u,p);for(let f of s)try{await Jr({sessionKey:u,mediaUrl:f,messageId:p})}catch(d){$(`[Gateway] cron \u9644\u4EF6\u7ECF\u901A\u9053\u53D1\u9001\u5931\u8D25: ${f} ${String(d)}`,"error")}}else s.length>0&&!u&&$(`[Gateway] cron finished \u6709\u53EF\u53D1\u9001\u9644\u4EF6\u8DEF\u5F84\u4F46 jobs.json \u65E0 sessionKey: jobId=${r}`,"error");let l=s.length>0;Tx(r,n,l),ga(r)}else Tx(r,"\u5B9A\u65F6\u4EFB\u52A1\u6267\u884C\u5931\u8D25",!1),ga(r)}}}catch(t){$(`[Gateway] \u5904\u7406\u4E8B\u4EF6\u5931\u8D25: ${t}`,"error")}return{type:e.event,payload:e.payload,seq:e.seq}}var aN=se(()=>{"use strict";Jd();ya();oN();zt();Ke();Er();$r();lt()});import cN from"crypto";var Yd,uN=se(()=>{"use strict";Zm();pS();Ke();lt();aN();Yd=class{ws=null;config;deviceId;privateKeyPem;publicKeyB64Url;connected=!1;connId=null;connectChallengeNonce=null;connectSent=!1;pendingRpcById=new Map;eventHandlers=new Set;constructor(t){this.config={url:t.url,token:t.token,role:t.role||"operator",scopes:t.scopes||["operator.admin"],reconnectInterval:t.reconnectInterval||5e3,maxReconnectAttempts:t.maxReconnectAttempts||10};let r=this.loadOrCreateDeviceIdentity();this.deviceId=r.deviceId,this.privateKeyPem=r.privateKeyPem,this.publicKeyB64Url=r.publicKeyB64Url}loadOrCreateDeviceIdentity(){let t=z("fs"),r=z("path"),n=Et(),i=r.join(n,".state"),o=r.join(i,"device.json");if(t.existsSync(o)){let p=JSON.parse(t.readFileSync(o,"utf8"));if(p.deviceId&&p.publicKeyPem&&p.privateKeyPem){let f=tg(p.publicKeyPem),d=f!==p.deviceId?f:p.deviceId;if(f!==p.deviceId)try{t.writeFileSync(o,JSON.stringify({...p,deviceId:f},null,2))}catch{}return{deviceId:d,publicKeyPem:p.publicKeyPem,privateKeyPem:p.privateKeyPem,publicKeyB64Url:eg(p.publicKeyPem)}}}let s=cN.generateKeyPairSync("ed25519"),a=s.publicKey.export({type:"spki",format:"pem"}).toString(),c=s.privateKey.export({type:"pkcs8",format:"pem"}).toString(),u=tg(a),l=eg(a);return t.existsSync(i)||t.mkdirSync(i,{recursive:!0}),t.writeFileSync(o,JSON.stringify({version:1,deviceId:u,publicKeyPem:a,privateKeyPem:c,createdAtMs:Date.now()},null,2)),t.chmodSync(o,384),{deviceId:u,publicKeyPem:a,privateKeyPem:c,publicKeyB64Url:l}}async connect(){return new Promise((t,r)=>{this.connectChallengeNonce=null,this.connectSent=!1,this.ws=new Ml.default(this.config.url);let n=!1,i=s=>{n||(n=!0,clearTimeout(o),s())},o=setTimeout(()=>{i(()=>r(new Error("Gateway connection timeout")))},15e3);this.ws.on("open",()=>{$("Gateway connection opened\uFF08\u7B49\u5F85 connect.challenge\uFF09")}),this.ws.on("message",s=>{try{let a=JSON.parse(s.toString());this.handleMessage(a,c=>i(()=>t(c)),c=>i(()=>r(c)),o)}catch(a){$(`[Gateway=>\u63D2\u4EF6]-[\u6D88\u606F\u89E3\u6790\u5931\u8D25]: ${a}`,"error")}}),this.ws.on("close",()=>{this.connected=!1,i(()=>r(new Error("Gateway \u5728\u63E1\u624B\u5B8C\u6210\u524D\u5173\u95ED\u4E86\u8FDE\u63A5")))}),this.ws.on("error",s=>{$(`Gateway \u8FDE\u63A5\u9519\u8BEF: ${s}`,"error"),i(()=>r(s))})})}sendConnect(){if(this.connectSent)return;let t=this.connectChallengeNonce?.trim()??"";if(!t)return;this.connectSent=!0;let r=Date.now(),n=process.platform,i=lS({deviceId:this.deviceId,clientId:"gateway-client",clientMode:"backend",role:this.config.role,scopes:this.config.scopes,signedAtMs:r,token:this.config.token,nonce:t,platform:n,deviceFamily:""}),o=uS(this.privateKeyPem,i),s=JSON.stringify({type:"req",id:"1",method:"connect",params:{minProtocol:3,maxProtocol:3,client:{id:"gateway-client",version:"1.0.0",platform:n,mode:"backend"},auth:{token:this.config.token},role:this.config.role,scopes:this.config.scopes,device:{id:this.deviceId,publicKey:this.publicKeyB64Url,signature:o,signedAt:r,nonce:t}}});this.ws?.send(s)}mapHelloPayloadToHelloOk(t){let r=t.server,n=t.features;return{server:{connId:typeof r?.connId=="string"?r.connId:""},features:{methods:Array.isArray(n?.methods)?n.methods:[],events:Array.isArray(n?.events)?n.events:[]},policy:t.policy,auth:t.auth}}acknowledgeGatewayHelloOk(t){clearTimeout(t)}handleMessage(t,r,n,i){let o=t.type;if(t.type==="event"&&t.event==="connect.challenge"){let s=t.payload,a=typeof s?.nonce=="string"?s.nonce.trim():"";if(!a){n(new Error("connect.challenge \u7F3A\u5C11 nonce"));return}this.connectChallengeNonce=a,this.sendConnect();return}if(t.type==="res"&&!this.connected){let s=t.ok===!0,a=t.payload;if(s&&a&&a.type==="hello-ok"){this.connected=!0;let c=a.server;this.connId=typeof c?.connId=="string"?c.connId:null,this.acknowledgeGatewayHelloOk(i),r(this.mapHelloPayloadToHelloOk(a));return}if(t.ok===!1){let c=t.error,u=typeof c?.message=="string"&&c.message||"Gateway connect \u88AB\u62D2\u7EDD";clearTimeout(i),n(new Error(u));return}}if(o==="hello-ok"||!o&&t.server){this.connected=!0,this.connId=t.server?.connId||null,this.acknowledgeGatewayHelloOk(i),r(t);return}if(t.type==="res"){let s=this.pendingRpcById.get(t.id);s&&(this.pendingRpcById.delete(t.id),s(t));return}t.type==="event"&&sN(t).then(s=>{this.eventHandlers.forEach(a=>a(s))}).catch(s=>{$(`[Gateway] event \u5904\u7406\u5F02\u6B65\u5931\u8D25: ${String(s)}`,"error")})}async callMethod(t,r={}){let n=cN.randomUUID();return new Promise((i,o)=>{if(!this.connected||!this.ws){o(new Error("Not connected to gateway"));return}let s=setTimeout(()=>{this.pendingRpcById.delete(n),o(new Error("Method call timeout"))},3e4);this.pendingRpcById.set(n,c=>{if(clearTimeout(s),c.ok){let u=c.result!==void 0?c.result:c.payload;i(u)}else o(new Error(c.error?.message||"Method call failed"))});let a=JSON.stringify({type:"req",id:n,method:t,params:r});this.ws.send(a),$(`[\u63D2\u4EF6=>Gateway]-[callMethod]: ${a}`)})}onEvent(t){return this.eventHandlers.add(t),()=>this.eventHandlers.delete(t)}close(){this.ws?.close(1e3,"Plugin stopped"),this.connected=!1}isConnected(){return this.connected}getConnId(){return this.connId}getWebSocket(){return this.ws}ping(){this.ws?.ping()}}});function une(e){return e!==null&&typeof e=="object"&&Object.keys(e).length===0}function gu(e){if(!e||typeof e!="object"||une(e))return!1;let t=e.channels;return!t||typeof t!="object"||Object.keys(t).length===0?!1:t[be]!=null}var Ix=se(()=>{"use strict";zt()});function lne(e){return e.gateway}function pne(e){if(!e)throw new Error("OpenClaw \u914D\u7F6E\u672A\u521D\u59CB\u5316\uFF08\u9700\u5148\u5B8C\u6210\u63D2\u4EF6 register\uFF09");let t=lne(e),r=process.env.OPENCLAW_GATEWAY_TOKEN||t?.auth?.token||"";if(!r)throw new Error("\u7F3A\u5C11 Gateway token\uFF1A\u8BF7\u5728 openclaw.json \u7684 gateway.auth.token \u8BBE\u7F6E\uFF0C\u6216\u8BBE\u7F6E\u73AF\u5883\u53D8\u91CF OPENCLAW_GATEWAY_TOKEN");let n=t?.tls?.enabled===!0?"wss":"ws";return{url:process.env.OPENCLAW_GATEWAY_URL||t?.remote?.url||`${n}://127.0.0.1:${t?.port??18789}`,token:r,role:"operator",scopes:["operator.admin"]}}function fne(){let e=gt();if(gu(e))return e;try{let t=Ur().config.loadConfig();return gu(t)?t:null}catch{return null}}function dne(){try{let e=fne();return e?pne(e):($("Gateway \u6301\u4E45\u8FDE\u63A5\u672A\u542F\u52A8: \u65E0\u53EF\u7528 OpenClaw \u914D\u7F6E\uFF08plugins.register \u672A\u5B8C\u6210\u6216 loadConfig \u5931\u8D25\uFF09","error"),null)}catch(e){return $(`Gateway \u6301\u4E45\u8FDE\u63A5\u672A\u542F\u52A8: ${e}`,"error"),null}}function Dx(){Qd&&(clearInterval(Qd),Qd=null)}function hne(){va&&(clearTimeout(va),va=null)}function mne(e){Dx(),Qd=setInterval(()=>{if(e.isConnected())try{e.ping()}catch(t){$(`Gateway ping \u5931\u8D25: ${t}`,"error")}},hl)}function pN(){ba||va||(va=setTimeout(()=>{va=null,fN()},rc))}function gne(e,t){let r=e.getWebSocket();if(!r)return;let n=()=>{t===Zd&&(Dx(),Sn===e&&(Sn=null),$("Gateway WebSocket \u5DF2\u65AD\u5F00\uFF0C\u5C06\u5728 5s \u540E\u91CD\u8FDE","error"),ba||pN())};r.once("close",n),r.once("error",n)}async function fN(){if(ba||Sn?.isConnected()||Px)return;let e=dne();if(e){Px=!0;try{Zd+=1;let t=Zd;if(Sn){try{Sn.close()}catch{}Sn=null}let r=new Yd(e);if(await r.connect(),ba){try{r.close()}catch{}return}if(t!==Zd){try{r.close()}catch{}return}Sn=r,gne(r,t),mne(r),$(`Gateway \u6301\u4E45\u8FDE\u63A5\u6210\u529F connId=${r.getConnId()??"?"}`)}catch(t){$(`Gateway \u8FDE\u63A5\u5931\u8D25: ${t}`,"error"),Sn=null,Dx(),ba||pN()}finally{Px=!1}}}function dN(){ba=!1,hne(),qx==null&&(qx=setTimeout(()=>{qx=null,fN()},0))}function lN(){return Sn?.isConnected()??!1}async function hN(e){let t=e?.timeoutMs??yne,r=e?.intervalMs??vne,n=Date.now()+t;for(;;){if(e?.signal?.aborted)return!1;if(lN())return!0;if(Date.now()>=n)return lN();await new Promise(i=>setTimeout(i,r))}}async function bne(e,t={}){let r=Sn;if(!r?.isConnected())throw new Error("Gateway \u672A\u8FDE\u63A5\uFF08\u7B49\u5F85\u91CD\u8FDE\u6216\u68C0\u67E5\u914D\u7F6E\uFF09");return r.callMethod(e,t)}async function xt(e){return bne(e.method,e.params??{})}var Sn,Qd,va,qx,Px,ba,Zd,yne,vne,qi=se(()=>{"use strict";lt();uN();Ke();Ix();zt();Sn=null,Qd=null,va=null,qx=null,Px=!1,ba=!0,Zd=0;yne=12e4,vne=150});import Ni from"node:fs";import Nx from"node:path";function Mx(){let e=Et();return e?Nx.join(Nx.dirname(e),xne):null}function mN(e){let t=Mx();if(!t){$("writeSessionStateFile: workspace dir not initialized, skip","error");return}let r={version:Fx,savedAt:Date.now(),params:$_(),global:F_(),subagent:e};try{let n=Nx.dirname(t);Ni.existsSync(n)||Ni.mkdirSync(n,{recursive:!0});let i=`${t}.tmp`;Ni.writeFileSync(i,JSON.stringify(r,null,2),"utf8"),Ni.renameSync(i,t),$(`session state persisted: ${t}`)}catch(n){$(`writeSessionStateFile failed: ${String(n)}`,"error")}}function gN(){let e=Mx();if(!e||!Ni.existsSync(e))return null;try{let t=Ni.readFileSync(e,"utf8"),r=JSON.parse(t);return!r||typeof r!="object"?null:r.version!==Fx?($(`readSessionStateFile: version mismatch ${r.version} vs ${Fx}`,"error"),null):r}catch(t){return $(`readSessionStateFile failed: ${String(t)}`,"error"),null}}function yN(e){e&&(z_(e.params),M_(e.global))}function vN(){let e=Mx();if(e)try{Ni.existsSync(e)&&Ni.unlinkSync(e)}catch(t){$(`removeSessionStateFile failed: ${String(t)}`,"error")}}function Di(e,t){let r=t?.trim();r&&e.add(r)}function bN(e){if(!e)return[];let t=new Set;for(let[r]of e.params?.paramsMessageMap??[])Di(t,r);for(let[,r]of e.params?.subagentRunIdMap??[])Di(t,r);for(let[r]of e.global?.msgStatusBySessionKey??[])Di(t,r);for(let[r]of e.global?.cronMessageIdMap??[])Di(t,r);for(let[r]of e.subagent?.activeSubagentRunIdsByRequester??[])Di(t,r);for(let[r,n]of e.subagent?.requesterByChildSessionKey??[])Di(t,r),Di(t,n);for(let[r]of e.subagent?.runIdByChildSessionKey??[])Di(t,r);return[...t]}var Fx,xne,xN=se(()=>{"use strict";lt();Er();Ke();Fx=1,xne="session-state.json"});function wN(e){jx=e}function wne(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Array.isArray(e.messages)}function _N(){let e=globalThis;if(e.__dcgchatLlmBodyExtFetchPatched1)return;e.__dcgchatLlmBodyExtFetchPatched1=!0;let t=globalThis.fetch.bind(globalThis);async function r(n,i){let o=jx;if(!o||i?.body==null||typeof i.body!="string")return t(n,i);try{let s=JSON.parse(i.body);if(!wne(s))return t(n,i);let a="ext"in s&&typeof s.ext=="object"&&s.ext!==null&&!Array.isArray(s.ext)?{...s.ext}:{};return s.ext={...a,sessionKey:o.sessionKey,agentCloneCode:o.agentCloneCode},jx=void 0,t(n,{...i,body:JSON.stringify(s)})}catch{return t(n,i)}}Object.assign(r,t),globalThis.fetch=r}var jx,SN=se(()=>{"use strict"});import{randomUUID as _ne}from"node:crypto";function AN(e){let t=e.trim(),r=or(t);if(r.messageId?.trim()||r.sessionId?.trim())return r;let n=Dr.get(t);if(n){let i=or(n);if(i.messageId?.trim()||i.sessionId?.trim())return i}return r}function yu(e){let t=e.trim();if(!t)return!1;if(Am(t)==="running")return!0;let r=Dr.get(t);return r?Am(r)==="running":!1}function Lx(e,t,r,n){let i=AN(e);sn(i,{is_finish:-1,tool_call_id:r,is_cover:n,thinking_content:t,response:""},!1)}function Ene(e){return e==="before_tool_call"||e==="after_tool_call"}function EN(e,t,r,n){let i=r.toolCallId||r.runId||Date.now().toString();return{callId:i,text:JSON.stringify({type:e,specialIdentification:"dcgchat_tool_call_special_identification",callId:i,...t,status:n})}}function kN(e){let t=Nr.get(e);return t||(t=new Set,Nr.set(e,t)),t}function kne(e){let t=Nr.get(e);if(t&&t.size>0)return;Nr.delete(e);let r=Fi.get(e);if(r?.size){Fi.delete(e);for(let n of r)try{n()}catch(i){$(`subagent idle waiter error: ${String(i)}`,"error")}}}function Tne(e,t,r){let n=e.trim(),i=t.trim(),o=r.trim();if(!n||!i||!o){$(`subagent track spawn skipped: missing key req=${n} runId=${i} child=${o}`);return}kN(n).add(i),Dr.set(o,n),Mi.set(o,i),$(`subagent track spawn: requester=${n} runId=${i} child=${o} active=${kN(n).size}`)}function Cne(e,t,r){let n=t.trim();if(!n)return;let i=e.requesterSessionKey?.trim()||Dr.get(n)||e.sessionKey?.trim()||"",o=(r?.trim()||Mi.get(n)||"").trim();if(Im(o),!i){$(`subagent track end: no requester for child=${n} runId=${o}`),Dr.delete(n),Mi.delete(n);return}let s=Nr.get(i);s&&o&&s.delete(o),Dr.delete(n),Mi.delete(n),$(`subagent track end: requester=${i} runId=${o||"n/a"} remaining=${s?.size??0}`),s&&s.size===0&&Nr.delete(i),kne(i)}function TN(e){let t=e.trim();if(!t)return[];let r=[];for(let[n,i]of Dr.entries())i===t&&r.push(n);return r}function RN(e){let t=e.trim();if(!t)return[];let r=[],n=new Set,i=TN(t);for(;i.length>0;){let o=[];for(let s of i){let a=s.trim();!a||n.has(a)||(n.add(a),r.push(a),o.push(...TN(a)))}i=o}return r}function eh(e){let t=e.trim();if(!t)return;let r=Nr.get(t);if(r)for(let i of r)Im(i);for(let[i,o]of[...Dr.entries()])o===t&&(Dr.delete(i),Mi.delete(i));Nr.delete(t);let n=Fi.get(t);if(n?.size){Fi.delete(t);for(let i of n)try{i()}catch(o){$(`subagent idle waiter error: ${String(o)}`,"error")}}}function CN(e){let t=e?.trim();return t?Nr.get(t)?.size??0:0}function IN(e,t){let r=e?.trim();return!r||CN(r)===0?Promise.resolve():new Promise((n,i)=>{let o=!1,s=f=>{o||(o=!0,l&&clearTimeout(l),t?.signal?.removeEventListener("abort",u),a(),f())},a=()=>{let f=Fi.get(r);f&&(f.delete(c),f.size===0&&Fi.delete(r))},c=()=>s(()=>n()),u=()=>{let f=t?.signal?.reason;s(()=>i(f instanceof Error?f:new Error(String(f??"Aborted"))))},l;if(t?.timeoutMs!=null&&t.timeoutMs>0&&(l=setTimeout(()=>s(()=>i(new Error(`waitUntilSubagentsIdle timeout ${t.timeoutMs}ms`))),t.timeoutMs)),t?.signal){if(t.signal.aborted){u();return}t.signal.addEventListener("abort",u,{once:!0})}let p=Fi.get(r);p||(p=new Set,Fi.set(r,p)),p.add(c),CN(r)===0&&c()})}function One(e,t){return e==="subagent_spawned"||e==="subagent_ended"||e==="subagent_spawning"||e==="subagent_delivery_target"?(t?.runId&&t?.requesterSessionKey&&U_(t?.runId,t?.requesterSessionKey),(t?.requesterSessionKey||t?.sessionKey||"").trim()):(t?.sessionKey||"").trim()}function Ane(e){if(e?.toolName==="cron")return!0;let t=e?.params?.command;return e?.toolName==="exec"&&typeof t=="string"?t.includes("cron create")||t.includes("cron add"):!1}function Rne(){return{activeSubagentRunIdsByRequester:[...Nr.entries()].map(([e,t])=>[e,[...t]]),requesterByChildSessionKey:[...Dr.entries()],runIdByChildSessionKey:[...Mi.entries()]}}function Ine(e){if(Nr.clear(),Dr.clear(),Mi.clear(),!!e){for(let[t,r]of e.activeSubagentRunIdsByRequester??[]){if(typeof t!="string"||!t||!Array.isArray(r))continue;let n=new Set;for(let i of r)typeof i=="string"&&i&&n.add(i);n.size>0&&Nr.set(t,n)}for(let[t,r]of e.requesterByChildSessionKey??[])typeof t=="string"&&typeof r=="string"&&t&&r&&Dr.set(t,r);for(let[t,r]of e.runIdByChildSessionKey??[])typeof t=="string"&&typeof r=="string"&&t&&r&&Mi.set(t,r)}}async function qne(e){if(!await hN({timeoutMs:12e4,intervalMs:150})){$("gateway_start resume: Gateway \u5728\u8D85\u65F6\u5185\u672A\u5C31\u7EEA\uFF0C\u5DF2\u8DF3\u8FC7\u300C\u7EE7\u7EED\u6267\u884C\u300D chat.send\uFF1B\u8BF7\u91CD\u8FDE\u540E\u624B\u52A8\u53D1\u6D88\u606F\u6216\u518D\u6B21\u89E6\u53D1\u6062\u590D","error");return}for(let r of e)try{await xt({method:"chat.send",params:{sessionKey:r,message:"\u7EE7\u7EED\u6267\u884C",deliver:!1,idempotencyKey:_ne()}}),$(`gateway_start resume: chat.send ok sessionKey=${r}`)}catch(n){$(`gateway_start resume: chat.send failed sessionKey=${r}: ${String(n)}`,"error")}}function Pne(e,t,r){if(e==="subagent_spawned"){let n=typeof t?.runId=="string"?t.runId:"",i=typeof t?.childSessionKey=="string"?t.childSessionKey:"",o=typeof r?.requesterSessionKey=="string"?r.requesterSessionKey:typeof r?.sessionKey=="string"?r.sessionKey:"";Tne(o,n,i);return}if(e==="subagent_ended"){let n=typeof t?.targetSessionKey=="string"?t.targetSessionKey:"",i=typeof t?.runId=="string"?t.runId:void 0;Cne(r??{},n,i)}}function qN(e){if(!ON.has(e)){ON.add(e),_N(),e.on("llm_input",(t,r)=>{let n=typeof r?.sessionKey=="string"?r.sessionKey.trim():"",i=r?.agentId;wN(n&&i!=="main"?{sessionKey:n,agentCloneCode:typeof i=="string"?i:String(i??"")}:void 0)}),e.on("gateway_stop",(t,r)=>{try{mN(Rne())}catch(n){$(`gateway_stopped persist session state failed: ${String(n)}`,"error")}}),e.on("gateway_start",(t,r)=>{try{let n=gN();if(!n)return;let i=bN(n);if(yN(n),Ine(n?.subagent),vN(),!i.length)return;$(`gateway_started: \u5DF2\u4ECE\u5FEB\u7167\u6062\u590D session state\uFF08savedAt=${n.savedAt}, \u6062\u590D\u4F1A\u8BDD\u6570\u91CF\uFF1A${i.toString()}\uFF09`),qne(i)}catch(n){$(`gateway_started restore session state failed: ${String(n)}`,"error")}});for(let t of Sne)e.on(t.event,(r,n)=>{if(t.event==="subagent_ended"&&r?.targetKind==="acp")return;Pne(t.event,r,n);let i=One(t.event,n??{});if(!i){t.event!=="before_tool_call"&&$(`\u5DE5\u5177\u8C03\u7528\u7ED3\u679C\uFF1A ~ event:${t.event} ~ \u6CA1\u6709sessionKey \u4E3A\u6267\u884C`,"error");return}if(!(yu(i)||t.event==="before_tool_call"&&Ane(r)))return;if(Ene(t.event)){let{result:u,...l}=r;if($(`\u5DE5\u5177\u8C03\u7528\u7ED3\u679C\uFF1A ~ event:${t.event} ~ params:${JSON.stringify(l)}`),t.event==="before_tool_call"){let d=Z_(l,i),{text:h,callId:m}=EN(t.event,l,r,"running");return Lx(i,h,m,0),d}let{text:p,callId:f}=EN(t.event,l,r,"finished");Lx(i,p,f,1);return}let s=AN(i);if(t.event==="llm_output"&&r.lastAssistant?.errorMessage==="1003-\u989D\u5EA6\u4E0D\u8DB3\u8BF7\u5145\u503C"){an("\u60A8\u7684\u58A8\u6EF4\u5DF2\u6D88\u8017\u5B8C\uFF0C\u60A8\u53EF\u4EE5\u901A\u8FC7\u5145\u503C\u58A8\u6EF4\u6765\u7EE7\u7EED\u4F7F\u7528",s,{message_tags:{insufficient_balance:1},is_finish:-1}),sr(s,"\u58A8\u6EF4\u4E0D\u8DB3");return}let a=r.runId||Date.now().toString(),c=JSON.stringify({type:t.event,specialIdentification:"dcgchat_tool_call_special_identification",toolName:"",callId:a,params:""});Lx(i,c,a,0),$(`\u5DE5\u5177\u8C03\u7528\u7ED3\u679C\uFF1A ~ event:${t.event}`)})}}var Sne,Nr,Dr,Mi,Fi,ON,xa=se(()=>{"use strict";lt();Ke();$r();Er();e1();qi();xN();SN();Sne=[{event:"subagent_spawning"},{event:"subagent_spawned"},{event:"subagent_delivery_target"},{event:"llm_output"},{event:"subagent_ended"},{event:"before_tool_call"},{event:"after_tool_call"}];Nr=new Map,Dr=new Map,Mi=new Map,Fi=new Map;ON=new WeakSet});function vu(e){let t=e.replace("dcg-cron:","").trim();return t?xl(t)?.sessionKey?.trim()||t:""}function th(e){let t=e.split(":").filter(n=>n.length>0),r=t.findIndex(n=>n.toLowerCase()==="cron");return r<0||r+1>=t.length?null:t[r+1]??null}function Bx(e){let t=th(e);if(!t)return e;let r=Ho(Ii(),t),n=r&&typeof r.sessionKey=="string"?r.sessionKey.trim():"";return n||($(`dcgchat: cron job ${t} has no sessionKey in jobs.json, keep outbound key=${e}`,"error"),e)}function wa(e,t){let r=e?.trim()??"";return r.indexOf("dcg-cron:")>=0?r:t}var Ux=se(()=>{"use strict";Jd();Ke();Er()});import Dne from"node:fs";function $x(e,t){if(e!=null){if(typeof e=="string"){let r=e.trim();if(!r)return;if(r.startsWith("["))try{let n=JSON.parse(r);$x(n,t);return}catch{}t.push(r);return}if(Array.isArray(e)){for(let r of e)$x(r,t);return}if(typeof e=="object"){let r=e,n=r.file??r.path??r.url;typeof n=="string"&&n.trim()&&t.push(n.trim())}}}function _a(e){let t=[];return $x(e,t),[...new Set(t.filter(Boolean))]}function Fne(e,t,r,n){let i=!e?.messageId||String(e?.messageId).length===Nne;return{response:t?.text??"",message_tags:i?{mark:"empty_text_file"}:{},is_finish:i?-1:0,files:[{url:r??"",name:n}]}}async function Jr(e){let t=(e.sessionKey??"").trim(),r=t.replace(/^dcg-cron:/i,"").trim(),n=th(r)!==null,i=t.toLowerCase().startsWith("dcg-cron:"),o=vu(e.sessionKey??"");o=Bx(o),!e.messageId?.trim()&&(n||i)&&!Dn(o)&&no(o,`${Date.now()}`);let s=Dn(o),a=oc(o),c=e.messageId?.trim()?{...a,messageId:e.messageId.trim()}:s?{...a,messageId:s}:a;if(!yr()){$(`dcgchat: outbound media skipped -> ws not isWsOpen failed open: ${e.mediaUrl??""}`);return}let u=_a(e.mediaUrl);if(u.length===0){$(`dcgchat: sendMedia skipped (no resolvable path): ${typeof e.mediaUrl=="string"?e.mediaUrl:JSON.stringify(e.mediaUrl)} sessionKey=${o}`,"error");return}if(u.length>1){for(let m of u)await Jr({...e,mediaUrl:m});return}let l=u[0],{sessionId:p,agentId:f}=Rm(o);if(c.sessionId||(c.sessionId=p),c.agentId||(c.agentId=f),!l||!c.sessionId){$(`dcgchat: sendMedia skipped (duplicate in session): ${l} sessionId=${c.sessionId} sessionKey=${o}`);return}let d;try{d=Dne.statSync(l)}catch(m){$(`dcgchat: sendMedia skipped (cannot stat path): ${l} ${String(m)} sessionKey=${o}`,"error");return}if(!d.isFile()){let m=d.isDirectory()?"directory":"non-regular";$(`dcgchat: sendMedia skipped (not a regular file, ${m}): ${l} sessionKey=${o}`,"error");return}if(l&&c.sessionId){let m=vl(c.messageId,c.sessionId,o);if(!m){$(`dcgchat: sendMedia skipped (no media dedupe bucket): ${l} sessionKey=${o}`,"error");return}if(D_(m,l)){$(`dcgchat: sendMedia skipped (hasSentMediaKey): ${l} dedupeBucket=${m} sessionKey=${o}`);return}P_(m,l)}let h=l?.split(/[\\/]/).pop()||"";try{let m=c.botToken??gt()?.channels?.[be]?.botToken??"",v=l?await Xd(l,m,1):"";sn(c,Fne(c,e,v,h)),$(`dcgchat: sendMedia session=${o}, file=${h}`)}catch(m){$(`dcgchat: error sendMedia session=${o}: ${String(m)}`,"error")}}async function PN(e){let t=vu(e.to),r=e.to.indexOf("dcg-cron:")>=0||th(t)!==null,n=Bx(t),i=oc(n),o=xl(n)??i;r&&!Dn(n)&&no(n,`${Date.now()}`);let s=Dn(n),a=`${Date.now()}`,c=s||(r?a:o?.messageId||a),{sessionId:u}=Rm(n);if(!u)return $(`dcgchat: channel sendMedia to ${e.to} -> sessionId not found`,"error"),{messageId:c,chatId:wa(e.to,n||"")};$(`dcgchat: channel sendMedia to ${e.to}`);let l=e.mediaUrls??e.mediaUrl,p=_a(l);for(let f of p)await Jr({sessionKey:n||"",mediaUrl:f,...r?{messageId:c}:{}});return{messageId:c,chatId:wa(e.to,n||"")}}var Nne,zx=se(()=>{"use strict";Sx();lt();Ke();Er();$r();zt();Ux();Nne=13});var nh=x((rEe,DN)=>{var rh=z("stream"),Mne=z("util"),jne="function";function ji(){if(!(this instanceof ji))return new ji;rh.Duplex.call(this,{decodeStrings:!1,objectMode:!0}),this.buffer=Buffer.from("");let e=this;e.on("finish",function(){e.finished=!0,e.emit("chunk",!1)})}Mne.inherits(ji,rh.Duplex);ji.prototype._write=function(e,t,r){this.buffer=Buffer.concat([this.buffer,e]),this.cb=r,this.emit("chunk")};ji.prototype.stream=function(e,t){let r=rh.PassThrough(),n,i=this;function o(){if(typeof i.cb===jne){let a=i.cb;return i.cb=void 0,a()}}function s(){let a;if(i.buffer&&i.buffer.length){if(typeof e=="number")a=i.buffer.slice(0,e),i.buffer=i.buffer.slice(e),e-=a.length,n=n||!e;else{let c=i.buffer.indexOf(e);if(c!==-1)i.match=c,t&&(c=c+e.length),a=i.buffer.slice(0,c),i.buffer=i.buffer.slice(c),n=!0;else{let u=i.buffer.length-e.length;u<=0?o():(a=i.buffer.slice(0,u),i.buffer=i.buffer.slice(u))}}a&&r.write(a,function(){(i.buffer.length===0||e.length&&i.buffer.length<=e.length)&&o()})}if(n)i.removeListener("chunk",s),r.end();else if(i.finished){i.removeListener("chunk",s),i.emit("error",new Error("FILE_ENDED"));return}}return i.on("chunk",s),s(),r};ji.prototype.pull=function(e,t){if(e===0)return Promise.resolve("");if(!isNaN(e)&&this.buffer.length>e){let a=this.buffer.slice(0,e);return this.buffer=this.buffer.slice(e),Promise.resolve(a)}let r=Buffer.from(""),n=this,i=new rh.Transform;i._transform=function(a,c,u){r=Buffer.concat([r,a]),u()};let o,s;return new Promise(function(a,c){if(o=c,s=function(u){n.__emittedError=u,c(u)},n.finished)return c(new Error("FILE_ENDED"));n.once("error",s),n.stream(e,t).on("error",c).pipe(i).on("finish",function(){a(r)}).on("error",c)}).finally(function(){n.removeListener("error",o),n.removeListener("error",s)})};ji.prototype._read=function(){};DN.exports=ji});var MN=x((nEe,FN)=>{var NN=z("stream"),Lne=z("util");function bu(){if(!(this instanceof bu))return new bu;NN.Transform.call(this)}Lne.inherits(bu,NN.Transform);bu.prototype._transform=function(e,t,r){r()};FN.exports=bu});var ih=x((iEe,jN)=>{var Bne=z("stream");jN.exports=function(e){return new Promise(function(t,r){let n=[],i=Bne.Transform().on("finish",function(){t(Buffer.concat(n))}).on("error",r);i._transform=function(o,s,a){n.push(o),a()},e.on("error",r).pipe(i)})}});var xu=x((oEe,LN)=>{var Une=function(e,t,r){let n;switch(r){case 1:n=e.readUInt8(t);break;case 2:n=e.readUInt16LE(t);break;case 4:n=e.readUInt32LE(t);break;case 8:n=Number(e.readBigUInt64LE(t));break;default:throw new Error("Unsupported UInt LE size!")}return n},$ne=function(e,t){let r={},n=0;for(let[i,o]of t)e.length>=n+o?r[i]=Une(e,n,o):r[i]=null,n+=o;return r};LN.exports={parse:$ne}});var oh=x((sEe,UN)=>{var BN=xu();UN.exports=function(e,t){let r;for(;!r&&e&&e.length;){let n=BN.parse(e,[["signature",2],["partSize",2]]);if(n.signature===1){let i=[];t.uncompressedSize===4294967295&&i.push(["uncompressedSize",8]),t.compressedSize===4294967295&&i.push(["compressedSize",8]),t.offsetToLocalFileHeader===4294967295&&i.push(["offsetToLocalFileHeader",8]),r=BN.parse(e.slice(4),i)}else e=e.slice(n.partSize+4)}return r=r||{},t.compressedSize===4294967295&&(t.compressedSize=r.compressedSize),t.uncompressedSize===4294967295&&(t.uncompressedSize=r.uncompressedSize),t.offsetToLocalFileHeader===4294967295&&(t.offsetToLocalFileHeader=r.offsetToLocalFileHeader),r}});var sh=x((aEe,$N)=>{$N.exports=function(t,r){let n=t&31,i=t>>5&15,o=(t>>9&127)+1980,s=r?(r&31)*2:0,a=r?r>>5&63:0,c=r?r>>11:0;return new Date(Date.UTC(o,i-1,n,c,a,s))}});var ah=x((cEe,HN)=>{var zne=z("util"),Wne=z("zlib"),Wx=z("stream"),zN=nh(),Hne=MN(),Gne=ih(),Vne=oh(),Kne=sh(),Xne=Wx.pipeline,wu=xu(),WN=Buffer.alloc(4);WN.writeUInt32LE(101010256,0);function Yr(e){if(!(this instanceof Yr))return new Yr(e);let t=this;t._opts=e||{verbose:!1},zN.call(t,t._opts),t.on("finish",function(){t.emit("end"),t.emit("close")}),t._readRecord().catch(function(r){(!t.__emittedError||t.__emittedError!==r)&&t.emit("error",r)})}zne.inherits(Yr,zN);Yr.prototype._readRecord=function(){let e=this;return e.pull(4).then(function(t){if(t.length===0)return;let r=t.readUInt32LE(0);if(r===875721283)return e._readCrxHeader();if(r===67324752)return e._readFile();if(r===33639248)return e.reachedCD=!0,e._readCentralDirectoryFileHeader();if(r===101010256)return e._readEndOfCentralDirectoryRecord();if(e.reachedCD)return e.pull(WN,!0).then(function(){return e._readEndOfCentralDirectoryRecord()});e.emit("error",new Error("invalid signature: 0x"+r.toString(16)))}).then((function(t){if(t)return e._readRecord()}))};Yr.prototype._readCrxHeader=function(){let e=this;return e.pull(12).then(function(t){return e.crxHeader=wu.parse(t,[["version",4],["pubKeyLength",4],["signatureLength",4]]),e.pull(e.crxHeader.pubKeyLength+e.crxHeader.signatureLength)}).then(function(t){return e.crxHeader.publicKey=t.slice(0,e.crxHeader.pubKeyLength),e.crxHeader.signature=t.slice(e.crxHeader.pubKeyLength),e.emit("crx-header",e.crxHeader),!0})};Yr.prototype._readFile=function(){let e=this;return e.pull(26).then(function(t){let r=wu.parse(t,[["versionsNeededToExtract",2],["flags",2],["compressionMethod",2],["lastModifiedTime",2],["lastModifiedDate",2],["crc32",4],["compressedSize",4],["uncompressedSize",4],["fileNameLength",2],["extraFieldLength",2]]);return r.lastModifiedDateTime=Kne(r.lastModifiedDate,r.lastModifiedTime),e.crxHeader&&(r.crxHeader=e.crxHeader),e.pull(r.fileNameLength).then(function(n){let i=n.toString("utf8"),o=Wx.PassThrough(),s=!1;return o.autodrain=function(){s=!0;let a=o.pipe(Hne());return a.promise=function(){return new Promise(function(c,u){a.on("finish",c),a.on("error",u)})},a},o.buffer=function(){return Gne(o)},o.path=i,o.props={},o.props.path=i,o.props.pathBuffer=n,o.props.flags={isUnicode:(r.flags&2048)!=0},o.type=r.uncompressedSize===0&&/[/\\]$/.test(i)?"Directory":"File",e._opts.verbose&&(o.type==="Directory"?console.log(" creating:",i):o.type==="File"&&(r.compressionMethod===0?console.log(" extracting:",i):console.log(" inflating:",i))),e.pull(r.extraFieldLength).then(function(a){let c=Vne(a,r);o.vars=r,o.extra=c,e._opts.forceStream?e.push(o):(e.emit("entry",o),(e._readableState.pipesCount||e._readableState.pipes&&e._readableState.pipes.length)&&e.push(o)),e._opts.verbose&&console.log({filename:i,vars:r,extra:c});let u=!(r.flags&8)||r.compressedSize>0,l;o.__autodraining=s;let p=r.compressionMethod&&!s?Wne.createInflateRaw():Wx.PassThrough();return u?(o.size=r.uncompressedSize,l=r.compressedSize):(l=Buffer.alloc(4),l.writeUInt32LE(134695760,0)),new Promise(function(f,d){Xne(e.stream(l),p,o,function(h){return h?d(h):u?f(u):e._processDataDescriptor(o).then(f).catch(d)})})})})})};Yr.prototype._processDataDescriptor=function(e){return this.pull(16).then(function(r){let n=wu.parse(r,[["dataDescriptorSignature",4],["crc32",4],["compressedSize",4],["uncompressedSize",4]]);return e.size=n.uncompressedSize,!0})};Yr.prototype._readCentralDirectoryFileHeader=function(){let e=this;return e.pull(42).then(function(t){let r=wu.parse(t,[["versionMadeBy",2],["versionsNeededToExtract",2],["flags",2],["compressionMethod",2],["lastModifiedTime",2],["lastModifiedDate",2],["crc32",4],["compressedSize",4],["uncompressedSize",4],["fileNameLength",2],["extraFieldLength",2],["fileCommentLength",2],["diskNumber",2],["internalFileAttributes",2],["externalFileAttributes",4],["offsetToLocalFileHeader",4]]);return e.pull(r.fileNameLength).then(function(n){return r.fileName=n.toString("utf8"),e.pull(r.extraFieldLength)}).then(function(){return e.pull(r.fileCommentLength)}).then(function(){return!0})})};Yr.prototype._readEndOfCentralDirectoryRecord=function(){let e=this;return e.pull(18).then(function(t){let r=wu.parse(t,[["diskNumber",2],["diskStart",2],["numberOfRecordsOnDisk",2],["numberOfRecords",2],["sizeOfCentralDirectory",4],["offsetToStartOfCentralDirectory",4],["commentLength",2]]);return e.pull(r.commentLength).then(function(){e.end(),e.push(null)})})};Yr.prototype.promise=function(){let e=this;return new Promise(function(t,r){e.on("finish",t),e.on("error",r)})};HN.exports=Yr});var _u=x((uEe,Hx)=>{"use strict";typeof process>"u"||!process.version||process.version.indexOf("v0.")===0||process.version.indexOf("v1.")===0&&process.version.indexOf("v1.8.")!==0?Hx.exports={nextTick:Jne}:Hx.exports=process;function Jne(e,t,r,n){if(typeof e!="function")throw new TypeError('"callback" argument must be a function');var i=arguments.length,o,s;switch(i){case 0:case 1:return process.nextTick(e);case 2:return process.nextTick(function(){e.call(null,t)});case 3:return process.nextTick(function(){e.call(null,t,r)});case 4:return process.nextTick(function(){e.call(null,t,r,n)});default:for(o=new Array(i-1),s=0;s<o.length;)o[s++]=arguments[s];return process.nextTick(function(){e.apply(null,o)})}}});var VN=x((lEe,GN)=>{var Yne={}.toString;GN.exports=Array.isArray||function(e){return Yne.call(e)=="[object Array]"}});var Gx=x((pEe,KN)=>{KN.exports=z("stream")});var Su=x((Vx,JN)=>{var ch=z("buffer"),Jn=ch.Buffer;function XN(e,t){for(var r in e)t[r]=e[r]}Jn.from&&Jn.alloc&&Jn.allocUnsafe&&Jn.allocUnsafeSlow?JN.exports=ch:(XN(ch,Vx),Vx.Buffer=Sa);function Sa(e,t,r){return Jn(e,t,r)}XN(Jn,Sa);Sa.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return Jn(e,t,r)};Sa.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=Jn(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};Sa.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return Jn(e)};Sa.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return ch.SlowBuffer(e)}});var YN=x((fEe,Kx)=>{typeof Object.create=="function"?Kx.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:Kx.exports=function(t,r){if(r){t.super_=r;var n=function(){};n.prototype=r.prototype,t.prototype=new n,t.prototype.constructor=t}}});var Ea=x((dEe,Jx)=>{try{if(Xx=z("util"),typeof Xx.inherits!="function")throw"";Jx.exports=Xx.inherits}catch{Jx.exports=YN()}var Xx});var ZN=x((hEe,Yx)=>{"use strict";function Qne(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var QN=Su().Buffer,Eu=z("util");function Zne(e,t,r){e.copy(t,r)}Yx.exports=(function(){function e(){Qne(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(r){var n={data:r,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function(r){var n={data:r,next:this.head};this.length===0&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function(){if(this.length!==0){var r=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,r}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(r){if(this.length===0)return"";for(var n=this.head,i=""+n.data;n=n.next;)i+=r+n.data;return i},e.prototype.concat=function(r){if(this.length===0)return QN.alloc(0);for(var n=QN.allocUnsafe(r>>>0),i=this.head,o=0;i;)Zne(i.data,n,o),o+=i.data.length,i=i.next;return n},e})();Eu&&Eu.inspect&&Eu.inspect.custom&&(Yx.exports.prototype[Eu.inspect.custom]=function(){var e=Eu.inspect({length:this.length});return this.constructor.name+" "+e})});var Qx=x((mEe,e6)=>{"use strict";var uh=_u();function eie(e,t){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,uh.nextTick(lh,this,e)):uh.nextTick(lh,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(o){!t&&o?r._writableState?r._writableState.errorEmitted||(r._writableState.errorEmitted=!0,uh.nextTick(lh,r,o)):uh.nextTick(lh,r,o):t&&t(o)}),this)}function tie(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function lh(e,t){e.emit("error",t)}e6.exports={destroy:eie,undestroy:tie}});var r6=x((gEe,t6)=>{t6.exports=z("util").deprecate});var e0=x((yEe,l6)=>{"use strict";var Go=_u();l6.exports=_t;function i6(e){var t=this;this.next=null,this.entry=null,this.finish=function(){bie(t,e)}}var rie=!process.browser&&["v0.10","v0.9."].indexOf(process.version.slice(0,5))>-1?setImmediate:Go.nextTick,ka;_t.WritableState=Tu;var o6=Object.create(Ao());o6.inherits=Ea();var nie={deprecate:r6()},s6=Gx(),fh=Su().Buffer,iie=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function oie(e){return fh.from(e)}function sie(e){return fh.isBuffer(e)||e instanceof iie}var a6=Qx();o6.inherits(_t,s6);function aie(){}function Tu(e,t){ka=ka||Vo(),e=e||{};var r=t instanceof ka;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,i=e.writableHighWaterMark,o=this.objectMode?16:16*1024;n||n===0?this.highWaterMark=n:r&&(i||i===0)?this.highWaterMark=i:this.highWaterMark=o,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=e.decodeStrings===!1;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(a){hie(t,a)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new i6(this)}Tu.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};(function(){try{Object.defineProperty(Tu.prototype,"buffer",{get:nie.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var ph;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(ph=Function.prototype[Symbol.hasInstance],Object.defineProperty(_t,Symbol.hasInstance,{value:function(e){return ph.call(this,e)?!0:this!==_t?!1:e&&e._writableState instanceof Tu}})):ph=function(e){return e instanceof this};function _t(e){if(ka=ka||Vo(),!ph.call(_t,this)&&!(this instanceof ka))return new _t(e);this._writableState=new Tu(e,this),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev),typeof e.destroy=="function"&&(this._destroy=e.destroy),typeof e.final=="function"&&(this._final=e.final)),s6.call(this)}_t.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function cie(e,t){var r=new Error("write after end");e.emit("error",r),Go.nextTick(t,r)}function uie(e,t,r,n){var i=!0,o=!1;return r===null?o=new TypeError("May not write null values to stream"):typeof r!="string"&&r!==void 0&&!t.objectMode&&(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),Go.nextTick(n,o),i=!1),i}_t.prototype.write=function(e,t,r){var n=this._writableState,i=!1,o=!n.objectMode&&sie(e);return o&&!fh.isBuffer(e)&&(e=oie(e)),typeof t=="function"&&(r=t,t=null),o?t="buffer":t||(t=n.defaultEncoding),typeof r!="function"&&(r=aie),n.ended?cie(this,r):(o||uie(this,n,e,r))&&(n.pendingcb++,i=pie(this,n,o,e,t,r)),i};_t.prototype.cork=function(){var e=this._writableState;e.corked++};_t.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&c6(this,e))};_t.prototype.setDefaultEncoding=function(t){if(typeof t=="string"&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this};function lie(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=fh.from(t,r)),t}Object.defineProperty(_t.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function pie(e,t,r,n,i,o){if(!r){var s=lie(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var c=t.length<t.highWaterMark;if(c||(t.needDrain=!0),t.writing||t.corked){var u=t.lastBufferedRequest;t.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},u?u.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else Zx(e,t,!1,a,n,i,o);return c}function Zx(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function fie(e,t,r,n,i){--t.pendingcb,r?(Go.nextTick(i,n),Go.nextTick(ku,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),ku(e,t))}function die(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function hie(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(die(r),t)fie(e,r,n,t,i);else{var o=u6(r);!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&c6(e,r),n?rie(n6,e,r,o,i):n6(e,r,o,i)}}function n6(e,t,r,n){r||mie(e,t),t.pendingcb--,n(),ku(e,t)}function mie(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function c6(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,Zx(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new i6(t),t.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,u=r.encoding,l=r.callback,p=t.objectMode?1:c.length;if(Zx(e,t,!1,p,c,u,l),r=r.next,t.bufferedRequestCount--,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}_t.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))};_t.prototype._writev=null;_t.prototype.end=function(e,t,r){var n=this._writableState;typeof e=="function"?(r=e,e=null,t=null):typeof t=="function"&&(r=t,t=null),e!=null&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||vie(this,n,r)};function u6(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function gie(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),ku(e,t)})}function yie(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"?(t.pendingcb++,t.finalCalled=!0,Go.nextTick(gie,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function ku(e,t){var r=u6(t);return r&&(yie(e,t),t.pendingcb===0&&(t.finished=!0,e.emit("finish"))),r}function vie(e,t,r){t.ending=!0,ku(e,t),r&&(t.finished?Go.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function bie(e,t,r){var n=e.entry;for(e.entry=null;n;){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree.next=e}Object.defineProperty(_t.prototype,"destroyed",{get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}});_t.prototype.destroy=a6.destroy;_t.prototype._undestroy=a6.undestroy;_t.prototype._destroy=function(e,t){this.end(),t(e)}});var Vo=x((vEe,h6)=>{"use strict";var p6=_u(),xie=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};h6.exports=Yn;var f6=Object.create(Ao());f6.inherits=Ea();var d6=n0(),r0=e0();f6.inherits(Yn,d6);for(t0=xie(r0.prototype),dh=0;dh<t0.length;dh++)hh=t0[dh],Yn.prototype[hh]||(Yn.prototype[hh]=r0.prototype[hh]);var t0,hh,dh;function Yn(e){if(!(this instanceof Yn))return new Yn(e);d6.call(this,e),r0.call(this,e),e&&e.readable===!1&&(this.readable=!1),e&&e.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",wie)}Object.defineProperty(Yn.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function wie(){this.allowHalfOpen||this._writableState.ended||p6.nextTick(_ie,this)}function _ie(e){e.end()}Object.defineProperty(Yn.prototype,"destroyed",{get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(e){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=e,this._writableState.destroyed=e)}});Yn.prototype._destroy=function(e,t){this.push(null),this.end(),p6.nextTick(t,e)}});var s0=x(g6=>{"use strict";var o0=Su().Buffer,m6=o0.isEncoding||function(e){switch(e=""+e,e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function Sie(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function Eie(e){var t=Sie(e);if(typeof t!="string"&&(o0.isEncoding===m6||!m6(e)))throw new Error("Unknown encoding: "+e);return t||e}g6.StringDecoder=Cu;function Cu(e){this.encoding=Eie(e);var t;switch(this.encoding){case"utf16le":this.text=Rie,this.end=Iie,t=4;break;case"utf8":this.fillLast=Cie,t=4;break;case"base64":this.text=qie,this.end=Pie,t=3;break;default:this.write=Die,this.end=Nie;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=o0.allocUnsafe(t)}Cu.prototype.write=function(e){if(e.length===0)return"";var t,r;if(this.lastNeed){if(t=this.fillLast(e),t===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""};Cu.prototype.end=Aie;Cu.prototype.text=Oie;Cu.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};function i0(e){return e<=127?0:e>>5===6?2:e>>4===14?3:e>>3===30?4:e>>6===2?-1:-2}function kie(e,t,r){var n=t.length-1;if(n<r)return 0;var i=i0(t[n]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--n<r||i===-2?0:(i=i0(t[n]),i>=0?(i>0&&(e.lastNeed=i-2),i):--n<r||i===-2?0:(i=i0(t[n]),i>=0?(i>0&&(i===2?i=0:e.lastNeed=i-3),i):0))}function Tie(e,t,r){if((t[0]&192)!==128)return e.lastNeed=0,"\uFFFD";if(e.lastNeed>1&&t.length>1){if((t[1]&192)!==128)return e.lastNeed=1,"\uFFFD";if(e.lastNeed>2&&t.length>2&&(t[2]&192)!==128)return e.lastNeed=2,"\uFFFD"}}function Cie(e){var t=this.lastTotal-this.lastNeed,r=Tie(this,e,t);if(r!==void 0)return r;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}function Oie(e,t){var r=kie(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)}function Aie(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"\uFFFD":t}function Rie(e,t){if((e.length-t)%2===0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function Iie(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function qie(e,t){var r=(e.length-t)%3;return r===0?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function Pie(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function Die(e){return e.toString(this.encoding)}function Nie(e){return e&&e.length?this.write(e):""}});var n0=x((wEe,O6)=>{"use strict";var Ca=_u();O6.exports=Xe;var Fie=VN(),Ou;Xe.ReadableState=S6;var xEe=z("events").EventEmitter,x6=function(e,t){return e.listeners(t).length},p0=Gx(),Au=Su().Buffer,Mie=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function jie(e){return Au.from(e)}function Lie(e){return Au.isBuffer(e)||e instanceof Mie}var w6=Object.create(Ao());w6.inherits=Ea();var a0=z("util"),Fe=void 0;a0&&a0.debuglog?Fe=a0.debuglog("stream"):Fe=function(){};var Bie=ZN(),_6=Qx(),Ta;w6.inherits(Xe,p0);var c0=["error","close","destroy","pause","resume"];function Uie(e,t,r){if(typeof e.prependListener=="function")return e.prependListener(t,r);!e._events||!e._events[t]?e.on(t,r):Fie(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]}function S6(e,t){Ou=Ou||Vo(),e=e||{};var r=t instanceof Ou;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var n=e.highWaterMark,i=e.readableHighWaterMark,o=this.objectMode?16:16*1024;n||n===0?this.highWaterMark=n:r&&(i||i===0)?this.highWaterMark=i:this.highWaterMark=o,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new Bie,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(Ta||(Ta=s0().StringDecoder),this.decoder=new Ta(e.encoding),this.encoding=e.encoding)}function Xe(e){if(Ou=Ou||Vo(),!(this instanceof Xe))return new Xe(e);this._readableState=new S6(e,this),this.readable=!0,e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy)),p0.call(this)}Object.defineProperty(Xe.prototype,"destroyed",{get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}});Xe.prototype.destroy=_6.destroy;Xe.prototype._undestroy=_6.undestroy;Xe.prototype._destroy=function(e,t){this.push(null),t(e)};Xe.prototype.push=function(e,t){var r=this._readableState,n;return r.objectMode?n=!0:typeof e=="string"&&(t=t||r.defaultEncoding,t!==r.encoding&&(e=Au.from(e,t),t=""),n=!0),E6(this,e,t,!1,n)};Xe.prototype.unshift=function(e){return E6(this,e,null,!0,!1)};function E6(e,t,r,n,i){var o=e._readableState;if(t===null)o.reading=!1,Hie(e,o);else{var s;i||(s=$ie(o,t)),s?e.emit("error",s):o.objectMode||t&&t.length>0?(typeof t!="string"&&!o.objectMode&&Object.getPrototypeOf(t)!==Au.prototype&&(t=jie(t)),n?o.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):u0(e,o,t,!0):o.ended?e.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!r?(t=o.decoder.write(t),o.objectMode||t.length!==0?u0(e,o,t,!1):k6(e,o)):u0(e,o,t,!1))):n||(o.reading=!1)}return zie(o)}function u0(e,t,r,n){t.flowing&&t.length===0&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&mh(e)),k6(e,t)}function $ie(e,t){var r;return!Lie(t)&&typeof t!="string"&&t!==void 0&&!e.objectMode&&(r=new TypeError("Invalid non-string/buffer chunk")),r}function zie(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}Xe.prototype.isPaused=function(){return this._readableState.flowing===!1};Xe.prototype.setEncoding=function(e){return Ta||(Ta=s0().StringDecoder),this._readableState.decoder=new Ta(e),this._readableState.encoding=e,this};var y6=8388608;function Wie(e){return e>=y6?e=y6:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function v6(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=Wie(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}Xe.prototype.read=function(e){Fe("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return Fe("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?l0(this):mh(this),null;if(e=v6(e,t),e===0&&t.ended)return t.length===0&&l0(this),null;var n=t.needReadable;Fe("need readable",n),(t.length===0||t.length-e<t.highWaterMark)&&(n=!0,Fe("length less than watermark",n)),t.ended||t.reading?(n=!1,Fe("reading or ended",n)):n&&(Fe("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=v6(r,t)));var i;return e>0?i=T6(e,t):i=null,i===null?(t.needReadable=!0,e=0):t.length-=e,t.length===0&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&l0(this)),i!==null&&this.emit("data",i),i};function Hie(e,t){if(!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,mh(e)}}function mh(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Fe("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ca.nextTick(b6,e):b6(e))}function b6(e){Fe("emit readable"),e.emit("readable"),f0(e)}function k6(e,t){t.readingMore||(t.readingMore=!0,Ca.nextTick(Gie,e,t))}function Gie(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(Fe("maybeReadMore read 0"),e.read(0),r!==t.length);)r=t.length;t.readingMore=!1}Xe.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))};Xe.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e);break}n.pipesCount+=1,Fe("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||t.end!==!1)&&e!==process.stdout&&e!==process.stderr,o=i?a:v;n.endEmitted?Ca.nextTick(o):r.once("end",o),e.on("unpipe",s);function s(E,S){Fe("onunpipe"),E===r&&S&&S.hasUnpiped===!1&&(S.hasUnpiped=!0,l())}function a(){Fe("onend"),e.end()}var c=Vie(r);e.on("drain",c);var u=!1;function l(){Fe("cleanup"),e.removeListener("close",h),e.removeListener("finish",m),e.removeListener("drain",c),e.removeListener("error",d),e.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",v),r.removeListener("data",f),u=!0,n.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&c()}var p=!1;r.on("data",f);function f(E){Fe("ondata"),p=!1;var S=e.write(E);S===!1&&!p&&((n.pipesCount===1&&n.pipes===e||n.pipesCount>1&&C6(n.pipes,e)!==-1)&&!u&&(Fe("false write response, pause",n.awaitDrain),n.awaitDrain++,p=!0),r.pause())}function d(E){Fe("onerror",E),v(),e.removeListener("error",d),x6(e,"error")===0&&e.emit("error",E)}Uie(e,"error",d);function h(){e.removeListener("finish",m),v()}e.once("close",h);function m(){Fe("onfinish"),e.removeListener("close",h),v()}e.once("finish",m);function v(){Fe("unpipe"),r.unpipe(e)}return e.emit("pipe",r),n.flowing||(Fe("pipe resume"),r.resume()),e};function Vie(e){return function(){var t=e._readableState;Fe("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&x6(e,"data")&&(t.flowing=!0,f0(e))}}Xe.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=C6(t.pipes,e);return s===-1?this:(t.pipes.splice(s,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r),this)};Xe.prototype.on=function(e,t){var r=p0.prototype.on.call(this,e,t);if(e==="data")this._readableState.flowing!==!1&&this.resume();else if(e==="readable"){var n=this._readableState;!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.emittedReadable=!1,n.reading?n.length&&mh(this):Ca.nextTick(Kie,this))}return r};Xe.prototype.addListener=Xe.prototype.on;function Kie(e){Fe("readable nexttick read 0"),e.read(0)}Xe.prototype.resume=function(){var e=this._readableState;return e.flowing||(Fe("resume"),e.flowing=!0,Xie(this,e)),this};function Xie(e,t){t.resumeScheduled||(t.resumeScheduled=!0,Ca.nextTick(Jie,e,t))}function Jie(e,t){t.reading||(Fe("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),f0(e),t.flowing&&!t.reading&&e.read(0)}Xe.prototype.pause=function(){return Fe("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(Fe("pause"),this._readableState.flowing=!1,this.emit("pause")),this};function f0(e){var t=e._readableState;for(Fe("flow",t.flowing);t.flowing&&e.read()!==null;);}Xe.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;e.on("end",function(){if(Fe("wrapped end"),r.decoder&&!r.ended){var s=r.decoder.end();s&&s.length&&t.push(s)}t.push(null)}),e.on("data",function(s){if(Fe("wrapped data"),r.decoder&&(s=r.decoder.write(s)),!(r.objectMode&&s==null)&&!(!r.objectMode&&(!s||!s.length))){var a=t.push(s);a||(n=!0,e.pause())}});for(var i in e)this[i]===void 0&&typeof e[i]=="function"&&(this[i]=(function(s){return function(){return e[s].apply(e,arguments)}})(i));for(var o=0;o<c0.length;o++)e.on(c0[o],this.emit.bind(this,c0[o]));return this._read=function(s){Fe("wrapped _read",s),n&&(n=!1,e.resume())},this};Object.defineProperty(Xe.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});Xe._fromList=T6;function T6(e,t){if(t.length===0)return null;var r;return t.objectMode?r=t.buffer.shift():!e||e>=t.length?(t.decoder?r=t.buffer.join(""):t.buffer.length===1?r=t.buffer.head.data:r=t.buffer.concat(t.length),t.buffer.clear()):r=Yie(e,t.buffer,t.decoder),r}function Yie(e,t,r){var n;return e<t.head.data.length?(n=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):e===t.head.data.length?n=t.shift():n=r?Qie(e,t):Zie(e,t),n}function Qie(e,t){var r=t.head,n=1,i=r.data;for(e-=i.length;r=r.next;){var o=r.data,s=e>o.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),e-=s,e===0){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}function Zie(e,t){var r=Au.allocUnsafe(e),n=t.head,i=1;for(n.data.copy(r),e-=n.data.length;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),e-=s,e===0){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}function l0(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ca.nextTick(eoe,t,e))}function eoe(e,t){!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function C6(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}});var d0=x((_Ee,I6)=>{"use strict";I6.exports=Qn;var gh=Vo(),R6=Object.create(Ao());R6.inherits=Ea();R6.inherits(Qn,gh);function toe(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,t!=null&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function Qn(e){if(!(this instanceof Qn))return new Qn(e);gh.call(this,e),this._transformState={afterTransform:toe.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",roe)}function roe(){var e=this;typeof this._flush=="function"?this._flush(function(t,r){A6(e,t,r)}):A6(this,null,null)}Qn.prototype.push=function(e,t){return this._transformState.needTransform=!1,gh.prototype.push.call(this,e,t)};Qn.prototype._transform=function(e,t,r){throw new Error("_transform() is not implemented")};Qn.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}};Qn.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};Qn.prototype._destroy=function(e,t){var r=this;gh.prototype._destroy.call(this,e,function(n){t(n),r.emit("close")})};function A6(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}});var N6=x((SEe,D6)=>{"use strict";D6.exports=Ru;var q6=d0(),P6=Object.create(Ao());P6.inherits=Ea();P6.inherits(Ru,q6);function Ru(e){if(!(this instanceof Ru))return new Ru(e);q6.call(this,e)}Ru.prototype._transform=function(e,t,r){r(null,e)}});var F6=x((Ut,yh)=>{var En=z("stream");process.env.READABLE_STREAM==="disable"&&En?(yh.exports=En,Ut=yh.exports=En.Readable,Ut.Readable=En.Readable,Ut.Writable=En.Writable,Ut.Duplex=En.Duplex,Ut.Transform=En.Transform,Ut.PassThrough=En.PassThrough,Ut.Stream=En):(Ut=yh.exports=n0(),Ut.Stream=En||Ut,Ut.Readable=Ut,Ut.Writable=e0(),Ut.Duplex=Vo(),Ut.Transform=d0(),Ut.PassThrough=N6())});var g0=x((EEe,m0)=>{"use strict";var h0=F6();function Oa(e,t,r){typeof r>"u"&&(r=t,t=e,e=null),h0.Duplex.call(this,e),typeof r.read!="function"&&(r=new h0.Readable(e).wrap(r)),this._writable=t,this._readable=r,this._waiting=!1;var n=this;t.once("finish",function(){n.end()}),this.once("finish",function(){t.end()}),r.on("readable",function(){n._waiting&&(n._waiting=!1,n._read())}),r.once("end",function(){n.push(null)}),(!e||typeof e.bubbleErrors>"u"||e.bubbleErrors)&&(t.on("error",function(i){n.emit("error",i)}),r.on("error",function(i){n.emit("error",i)}))}Oa.prototype=Object.create(h0.Duplex.prototype,{constructor:{value:Oa}});Oa.prototype._write=function(t,r,n){this._writable.write(t,r,n)};Oa.prototype._read=function(){for(var t,r=0;(t=this._readable.read())!==null;)this.push(t),r++;r===0&&(this._waiting=!0)};m0.exports=function(t,r,n){return new Oa(t,r,n)};m0.exports.DuplexWrapper=Oa});var j6=x((kEe,M6)=>{var y0=z("stream"),noe=ah(),ioe=g0(),ooe=ih();function soe(e,t){let r=y0.PassThrough({objectMode:!0}),n=y0.PassThrough(),i=y0.Transform({objectMode:!0}),o=e instanceof RegExp?e:e&&new RegExp(e),s;i._transform=function(c,u,l){if(s||o&&!o.exec(c.path))return c.autodrain(),l();s=!0,a.emit("entry",c),c.on("error",function(p){n.emit("error",p)}),c.pipe(n).on("error",function(p){l(p)}).on("finish",function(p){l(null,p)})},r.pipe(noe(t)).on("error",function(c){n.emit("error",c)}).pipe(i).on("error",Object).on("finish",function(){s?n.end():n.emit("error",new Error("PATTERN_NOT_FOUND"))});let a=ioe(r,n);return a.buffer=function(){return ooe(n)},a}M6.exports=soe});var Nt=x(v0=>{"use strict";v0.fromCallback=function(e){return Object.defineProperty(function(...t){if(typeof t[t.length-1]=="function")e.apply(this,t);else return new Promise((r,n)=>{t.push((i,o)=>i!=null?n(i):r(o)),e.apply(this,t)})},"name",{value:e.name})};v0.fromPromise=function(e){return Object.defineProperty(function(...t){let r=t[t.length-1];if(typeof r!="function")return e.apply(this,t);t.pop(),e.apply(this,t).then(n=>r(null,n),r)},"name",{value:e.name})}});var tr=x(Zn=>{"use strict";var L6=Nt().fromCallback,er=hi(),aoe=["access","appendFile","chmod","chown","close","copyFile","cp","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","glob","lchmod","lchown","lutimes","link","lstat","mkdir","mkdtemp","open","opendir","readdir","readFile","readlink","realpath","rename","rm","rmdir","stat","statfs","symlink","truncate","unlink","utimes","writeFile"].filter(e=>typeof er[e]=="function");Object.assign(Zn,er);aoe.forEach(e=>{Zn[e]=L6(er[e])});Zn.exists=function(e,t){return typeof t=="function"?er.exists(e,t):new Promise(r=>er.exists(e,r))};Zn.read=function(e,t,r,n,i,o){return typeof o=="function"?er.read(e,t,r,n,i,o):new Promise((s,a)=>{er.read(e,t,r,n,i,(c,u,l)=>{if(c)return a(c);s({bytesRead:u,buffer:l})})})};Zn.write=function(e,t,...r){return typeof r[r.length-1]=="function"?er.write(e,t,...r):new Promise((n,i)=>{er.write(e,t,...r,(o,s,a)=>{if(o)return i(o);n({bytesWritten:s,buffer:a})})})};Zn.readv=function(e,t,...r){return typeof r[r.length-1]=="function"?er.readv(e,t,...r):new Promise((n,i)=>{er.readv(e,t,...r,(o,s,a)=>{if(o)return i(o);n({bytesRead:s,buffers:a})})})};Zn.writev=function(e,t,...r){return typeof r[r.length-1]=="function"?er.writev(e,t,...r):new Promise((n,i)=>{er.writev(e,t,...r,(o,s,a)=>{if(o)return i(o);n({bytesWritten:s,buffers:a})})})};typeof er.realpath.native=="function"?Zn.realpath.native=L6(er.realpath.native):process.emitWarning("fs.realpath.native is not a function. Is fs being monkey-patched?","Warning","fs-extra-WARN0003")});var U6=x((OEe,B6)=>{"use strict";var coe=z("path");B6.exports.checkPath=function(t){if(process.platform==="win32"&&/[<>:"|?*]/.test(t.replace(coe.parse(t).root,""))){let n=new Error(`Path contains invalid characters: ${t}`);throw n.code="EINVAL",n}}});var H6=x((AEe,b0)=>{"use strict";var $6=tr(),{checkPath:z6}=U6(),W6=e=>{let t={mode:511};return typeof e=="number"?e:{...t,...e}.mode};b0.exports.makeDir=async(e,t)=>(z6(e),$6.mkdir(e,{mode:W6(t),recursive:!0}));b0.exports.makeDirSync=(e,t)=>(z6(e),$6.mkdirSync(e,{mode:W6(t),recursive:!0}))});var Qr=x((REe,G6)=>{"use strict";var uoe=Nt().fromPromise,{makeDir:loe,makeDirSync:x0}=H6(),w0=uoe(loe);G6.exports={mkdirs:w0,mkdirsSync:x0,mkdirp:w0,mkdirpSync:x0,ensureDir:w0,ensureDirSync:x0}});var Li=x((IEe,K6)=>{"use strict";var poe=Nt().fromPromise,V6=tr();function foe(e){return V6.access(e).then(()=>!0).catch(()=>!1)}K6.exports={pathExists:poe(foe),pathExistsSync:V6.existsSync}});var _0=x((qEe,X6)=>{"use strict";var Aa=tr(),doe=Nt().fromPromise;async function hoe(e,t,r){let n=await Aa.open(e,"r+"),i=null;try{await Aa.futimes(n,t,r)}finally{try{await Aa.close(n)}catch(o){i=o}}if(i)throw i}function moe(e,t,r){let n=Aa.openSync(e,"r+");return Aa.futimesSync(n,t,r),Aa.closeSync(n)}X6.exports={utimesMillis:doe(hoe),utimesMillisSync:moe}});var Ko=x((PEe,Z6)=>{"use strict";var Ra=tr(),Ft=z("path"),J6=Nt().fromPromise;function goe(e,t,r){let n=r.dereference?i=>Ra.stat(i,{bigint:!0}):i=>Ra.lstat(i,{bigint:!0});return Promise.all([n(e),n(t).catch(i=>{if(i.code==="ENOENT")return null;throw i})]).then(([i,o])=>({srcStat:i,destStat:o}))}function yoe(e,t,r){let n,i=r.dereference?s=>Ra.statSync(s,{bigint:!0}):s=>Ra.lstatSync(s,{bigint:!0}),o=i(e);try{n=i(t)}catch(s){if(s.code==="ENOENT")return{srcStat:o,destStat:null};throw s}return{srcStat:o,destStat:n}}async function voe(e,t,r,n){let{srcStat:i,destStat:o}=await goe(e,t,n);if(o){if(Iu(i,o)){let s=Ft.basename(e),a=Ft.basename(t);if(r==="move"&&s!==a&&s.toLowerCase()===a.toLowerCase())return{srcStat:i,destStat:o,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(i.isDirectory()&&!o.isDirectory())throw new Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`);if(!i.isDirectory()&&o.isDirectory())throw new Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`)}if(i.isDirectory()&&S0(e,t))throw new Error(vh(e,t,r));return{srcStat:i,destStat:o}}function boe(e,t,r,n){let{srcStat:i,destStat:o}=yoe(e,t,n);if(o){if(Iu(i,o)){let s=Ft.basename(e),a=Ft.basename(t);if(r==="move"&&s!==a&&s.toLowerCase()===a.toLowerCase())return{srcStat:i,destStat:o,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(i.isDirectory()&&!o.isDirectory())throw new Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`);if(!i.isDirectory()&&o.isDirectory())throw new Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`)}if(i.isDirectory()&&S0(e,t))throw new Error(vh(e,t,r));return{srcStat:i,destStat:o}}async function Y6(e,t,r,n){let i=Ft.resolve(Ft.dirname(e)),o=Ft.resolve(Ft.dirname(r));if(o===i||o===Ft.parse(o).root)return;let s;try{s=await Ra.stat(o,{bigint:!0})}catch(a){if(a.code==="ENOENT")return;throw a}if(Iu(t,s))throw new Error(vh(e,r,n));return Y6(e,t,o,n)}function Q6(e,t,r,n){let i=Ft.resolve(Ft.dirname(e)),o=Ft.resolve(Ft.dirname(r));if(o===i||o===Ft.parse(o).root)return;let s;try{s=Ra.statSync(o,{bigint:!0})}catch(a){if(a.code==="ENOENT")return;throw a}if(Iu(t,s))throw new Error(vh(e,r,n));return Q6(e,t,o,n)}function Iu(e,t){return t.ino!==void 0&&t.dev!==void 0&&t.ino===e.ino&&t.dev===e.dev}function S0(e,t){let r=Ft.resolve(e).split(Ft.sep).filter(i=>i),n=Ft.resolve(t).split(Ft.sep).filter(i=>i);return r.every((i,o)=>n[o]===i)}function vh(e,t,r){return`Cannot ${r} '${e}' to a subdirectory of itself, '${t}'.`}Z6.exports={checkPaths:J6(voe),checkPathsSync:boe,checkParentPaths:J6(Y6),checkParentPathsSync:Q6,isSrcSubdir:S0,areIdentical:Iu}});var tF=x((DEe,eF)=>{"use strict";async function xoe(e,t){let r=[];for await(let n of e)r.push(t(n).then(()=>null,i=>i??new Error("unknown error")));await Promise.all(r.map(n=>n.then(i=>{if(i!==null)throw i})))}eF.exports={asyncIteratorConcurrentProcess:xoe}});var sF=x((NEe,oF)=>{"use strict";var Gt=tr(),qu=z("path"),{mkdirs:woe}=Qr(),{pathExists:_oe}=Li(),{utimesMillis:Soe}=_0(),Pu=Ko(),{asyncIteratorConcurrentProcess:Eoe}=tF();async function koe(e,t,r={}){typeof r=="function"&&(r={filter:r}),r.clobber="clobber"in r?!!r.clobber:!0,r.overwrite="overwrite"in r?!!r.overwrite:r.clobber,r.preserveTimestamps&&process.arch==="ia32"&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
|
|
103
|
+
`+o):n.stack=o}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=Xr(this.defaults,r);let{transitional:n,paramsSerializer:i,headers:o}=r;n!==void 0&&hu.assertOptions(n,{silentJSONParsing:Pr.transitional(Pr.boolean),forcedJSONParsing:Pr.transitional(Pr.boolean),clarifyTimeoutError:Pr.transitional(Pr.boolean),legacyInterceptorReqResOrdering:Pr.transitional(Pr.boolean)},!1),i!=null&&(j.isFunction(i)?r.paramsSerializer={serialize:i}:hu.assertOptions(i,{encode:Pr.function,serialize:Pr.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),hu.assertOptions(r,{baseUrl:Pr.spelling("baseURL"),withXsrfToken:Pr.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=o&&j.merge(o.common,o[r.method]);o&&j.forEach(["delete","get","head","post","put","patch","common"],h=>{delete o[h]}),r.headers=at.concat(s,o);let a=[],c=!0;this.interceptors.request.forEach(function(m){if(typeof m.runWhen=="function"&&m.runWhen(r)===!1)return;c=c&&m.synchronous;let v=r.transitional||Ci;v&&v.legacyInterceptorReqResOrdering?a.unshift(m.fulfilled,m.rejected):a.push(m.fulfilled,m.rejected)});let u=[];this.interceptors.response.forEach(function(m){u.push(m.fulfilled,m.rejected)});let l,p=0,f;if(!c){let h=[zd.bind(this),void 0];for(h.unshift(...a),h.push(...u),f=h.length,l=Promise.resolve(r);p<f;)l=l.then(h[p++],h[p++]);return l}f=a.length;let d=r;for(;p<f;){let h=a[p++],m=a[p++];try{d=h(d)}catch(v){m.call(this,v);break}}try{l=zd.call(this,d)}catch(h){return Promise.reject(h)}for(p=0,f=u.length;p<f;)l=l.then(u[p++],u[p++]);return l}getUri(t){t=Xr(this.defaults,t);let r=Bo(t.baseURL,t.url,t.allowAbsoluteUrls);return jo(r,t.params,t.paramsSerializer)}};j.forEach(["delete","get","head","options"],function(t){ma.prototype[t]=function(r,n){return this.request(Xr(n||{},{method:t,url:r,data:(n||{}).data}))}});j.forEach(["post","put","patch"],function(t){function r(n){return function(o,s,a){return this.request(Xr(a||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:o,data:s}))}}ma.prototype[t]=r(),ma.prototype[t+"Form"]=r(!0)});mu=ma});var fx,TD,CD=se(()=>{"use strict";Lo();fx=class e{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(o){r=o});let n=this;this.promise.then(i=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](i);n._listeners=null}),this.promise.then=i=>{let o,s=new Promise(a=>{n.subscribe(a),o=a}).then(i);return s.cancel=function(){n.unsubscribe(o)},s},t(function(o,s,a){n.reason||(n.reason=new _r(o,s,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){let t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new e(function(i){t=i}),cancel:t}}},TD=fx});function dx(e){return function(r){return e.apply(null,r)}}var OD=se(()=>{"use strict"});function hx(e){return j.isObject(e)&&e.isAxiosError===!0}var AD=se(()=>{"use strict";We()});var mx,RD,ID=se(()=>{mx={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(mx).forEach(([e,t])=>{mx[t]=e});RD=mx});function qD(e){let t=new mu(e),r=Zc(mu.prototype.request,t);return j.extend(r,mu.prototype,t,{allOwnKeys:!0}),j.extend(r,t,null,{allOwnKeys:!0}),r.create=function(i){return qD(Xr(e,i))},r}var wt,Ri,PD=se(()=>{"use strict";We();cb();kD();Ld();qd();Ib();Lo();CD();Db();Fd();nu();wr();OD();AD();wn();lx();ID();wt=qD(la);wt.Axios=mu;wt.CanceledError=_r;wt.CancelToken=TD;wt.isCancel=au;wt.VERSION=zo;wt.toFormData=Ti;wt.AxiosError=ue;wt.Cancel=wt.CanceledError;wt.all=function(t){return Promise.all(t)};wt.spread=dx;wt.isAxiosError=hx;wt.mergeConfig=Xr;wt.AxiosHeaders=at;wt.formToJSON=e=>Id(j.isHTMLForm(e)?new FormData(e):e);wt.getAdapter=$d.getAdapter;wt.HttpStatusCode=RD;wt.default=wt;Ri=wt});var r1e,n1e,i1e,o1e,s1e,a1e,c1e,u1e,l1e,p1e,f1e,d1e,h1e,m1e,g1e,y1e,Hd=se(()=>{PD();({Axios:r1e,AxiosError:n1e,CanceledError:i1e,isCancel:o1e,CancelToken:s1e,VERSION:a1e,all:c1e,Cancel:u1e,isAxiosError:l1e,spread:p1e,toFormData:f1e,AxiosHeaders:d1e,HttpStatusCode:h1e,formToJSON:m1e,getAdapter:g1e,mergeConfig:y1e}=Ri)});var ND=x((b1e,DD)=>{(function(){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t={rotl:function(r,n){return r<<n|r>>>32-n},rotr:function(r,n){return r<<32-n|r>>>n},endian:function(r){if(r.constructor==Number)return t.rotl(r,8)&16711935|t.rotl(r,24)&4278255360;for(var n=0;n<r.length;n++)r[n]=t.endian(r[n]);return r},randomBytes:function(r){for(var n=[];r>0;r--)n.push(Math.floor(Math.random()*256));return n},bytesToWords:function(r){for(var n=[],i=0,o=0;i<r.length;i++,o+=8)n[o>>>5]|=r[i]<<24-o%32;return n},wordsToBytes:function(r){for(var n=[],i=0;i<r.length*32;i+=8)n.push(r[i>>>5]>>>24-i%32&255);return n},bytesToHex:function(r){for(var n=[],i=0;i<r.length;i++)n.push((r[i]>>>4).toString(16)),n.push((r[i]&15).toString(16));return n.join("")},hexToBytes:function(r){for(var n=[],i=0;i<r.length;i+=2)n.push(parseInt(r.substr(i,2),16));return n},bytesToBase64:function(r){for(var n=[],i=0;i<r.length;i+=3)for(var o=r[i]<<16|r[i+1]<<8|r[i+2],s=0;s<4;s++)i*8+s*6<=r.length*8?n.push(e.charAt(o>>>6*(3-s)&63)):n.push("=");return n.join("")},base64ToBytes:function(r){r=r.replace(/[^A-Z0-9+\/]/ig,"");for(var n=[],i=0,o=0;i<r.length;o=++i%4)o!=0&&n.push((e.indexOf(r.charAt(i-1))&Math.pow(2,-2*o+8)-1)<<o*2|e.indexOf(r.charAt(i))>>>6-o*2);return n}};DD.exports=t})()});var yx=x((x1e,FD)=>{var gx={utf8:{stringToBytes:function(e){return gx.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(gx.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],r=0;r<e.length;r++)t.push(e.charCodeAt(r)&255);return t},bytesToString:function(e){for(var t=[],r=0;r<e.length;r++)t.push(String.fromCharCode(e[r]));return t.join("")}}};FD.exports=gx});var LD=x((w1e,jD)=>{jD.exports=function(e){return e!=null&&(MD(e)||$re(e)||!!e._isBuffer)};function MD(e){return!!e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function $re(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&MD(e.slice(0,0))}});var UD=x((_1e,BD)=>{(function(){var e=ND(),t=yx().utf8,r=LD(),n=yx().bin,i=function(o,s){o.constructor==String?s&&s.encoding==="binary"?o=n.stringToBytes(o):o=t.stringToBytes(o):r(o)?o=Array.prototype.slice.call(o,0):!Array.isArray(o)&&o.constructor!==Uint8Array&&(o=o.toString());for(var a=e.bytesToWords(o),c=o.length*8,u=1732584193,l=-271733879,p=-1732584194,f=271733878,d=0;d<a.length;d++)a[d]=(a[d]<<8|a[d]>>>24)&16711935|(a[d]<<24|a[d]>>>8)&4278255360;a[c>>>5]|=128<<c%32,a[(c+64>>>9<<4)+14]=c;for(var h=i._ff,m=i._gg,v=i._hh,E=i._ii,d=0;d<a.length;d+=16){var S=u,b=l,g=p,y=f;u=h(u,l,p,f,a[d+0],7,-680876936),f=h(f,u,l,p,a[d+1],12,-389564586),p=h(p,f,u,l,a[d+2],17,606105819),l=h(l,p,f,u,a[d+3],22,-1044525330),u=h(u,l,p,f,a[d+4],7,-176418897),f=h(f,u,l,p,a[d+5],12,1200080426),p=h(p,f,u,l,a[d+6],17,-1473231341),l=h(l,p,f,u,a[d+7],22,-45705983),u=h(u,l,p,f,a[d+8],7,1770035416),f=h(f,u,l,p,a[d+9],12,-1958414417),p=h(p,f,u,l,a[d+10],17,-42063),l=h(l,p,f,u,a[d+11],22,-1990404162),u=h(u,l,p,f,a[d+12],7,1804603682),f=h(f,u,l,p,a[d+13],12,-40341101),p=h(p,f,u,l,a[d+14],17,-1502002290),l=h(l,p,f,u,a[d+15],22,1236535329),u=m(u,l,p,f,a[d+1],5,-165796510),f=m(f,u,l,p,a[d+6],9,-1069501632),p=m(p,f,u,l,a[d+11],14,643717713),l=m(l,p,f,u,a[d+0],20,-373897302),u=m(u,l,p,f,a[d+5],5,-701558691),f=m(f,u,l,p,a[d+10],9,38016083),p=m(p,f,u,l,a[d+15],14,-660478335),l=m(l,p,f,u,a[d+4],20,-405537848),u=m(u,l,p,f,a[d+9],5,568446438),f=m(f,u,l,p,a[d+14],9,-1019803690),p=m(p,f,u,l,a[d+3],14,-187363961),l=m(l,p,f,u,a[d+8],20,1163531501),u=m(u,l,p,f,a[d+13],5,-1444681467),f=m(f,u,l,p,a[d+2],9,-51403784),p=m(p,f,u,l,a[d+7],14,1735328473),l=m(l,p,f,u,a[d+12],20,-1926607734),u=v(u,l,p,f,a[d+5],4,-378558),f=v(f,u,l,p,a[d+8],11,-2022574463),p=v(p,f,u,l,a[d+11],16,1839030562),l=v(l,p,f,u,a[d+14],23,-35309556),u=v(u,l,p,f,a[d+1],4,-1530992060),f=v(f,u,l,p,a[d+4],11,1272893353),p=v(p,f,u,l,a[d+7],16,-155497632),l=v(l,p,f,u,a[d+10],23,-1094730640),u=v(u,l,p,f,a[d+13],4,681279174),f=v(f,u,l,p,a[d+0],11,-358537222),p=v(p,f,u,l,a[d+3],16,-722521979),l=v(l,p,f,u,a[d+6],23,76029189),u=v(u,l,p,f,a[d+9],4,-640364487),f=v(f,u,l,p,a[d+12],11,-421815835),p=v(p,f,u,l,a[d+15],16,530742520),l=v(l,p,f,u,a[d+2],23,-995338651),u=E(u,l,p,f,a[d+0],6,-198630844),f=E(f,u,l,p,a[d+7],10,1126891415),p=E(p,f,u,l,a[d+14],15,-1416354905),l=E(l,p,f,u,a[d+5],21,-57434055),u=E(u,l,p,f,a[d+12],6,1700485571),f=E(f,u,l,p,a[d+3],10,-1894986606),p=E(p,f,u,l,a[d+10],15,-1051523),l=E(l,p,f,u,a[d+1],21,-2054922799),u=E(u,l,p,f,a[d+8],6,1873313359),f=E(f,u,l,p,a[d+15],10,-30611744),p=E(p,f,u,l,a[d+6],15,-1560198380),l=E(l,p,f,u,a[d+13],21,1309151649),u=E(u,l,p,f,a[d+4],6,-145523070),f=E(f,u,l,p,a[d+11],10,-1120210379),p=E(p,f,u,l,a[d+2],15,718787259),l=E(l,p,f,u,a[d+9],21,-343485551),u=u+S>>>0,l=l+b>>>0,p=p+g>>>0,f=f+y>>>0}return e.endian([u,l,p,f])};i._ff=function(o,s,a,c,u,l,p){var f=o+(s&a|~s&c)+(u>>>0)+p;return(f<<l|f>>>32-l)+s},i._gg=function(o,s,a,c,u,l,p){var f=o+(s&c|a&~c)+(u>>>0)+p;return(f<<l|f>>>32-l)+s},i._hh=function(o,s,a,c,u,l,p){var f=o+(s^a^c)+(u>>>0)+p;return(f<<l|f>>>32-l)+s},i._ii=function(o,s,a,c,u,l,p){var f=o+(a^(s|~c))+(u>>>0)+p;return(f<<l|f>>>32-l)+s},i._blocksize=16,i._digestsize=16,BD.exports=function(o,s){if(o==null)throw new Error("Illegal argument "+o);var a=e.wordsToBytes(i(o,s));return s&&s.asBytes?a:s&&s.asString?n.bytesToString(a):e.bytesToHex(a)}})()});function $D(e,t){let r=Date.now()+zre;vx.set(e,{token:t,expiresAt:r})}function Gd(e){let t=vx.get(e);return t?Date.now()>=t.expiresAt?(vx.delete(e),null):t.token:null}var zre,vx,bx=se(()=>{"use strict";zre=3600*1e3,vx=new Map});function Vre(e){let t=e.baseURL??"",r=e.url??"",n=r.startsWith("http")?r:`${t.replace(/\/$/,"")}/${r.replace(/^\//,"")}`,i=(e.method??"GET").toUpperCase(),o=e.headers??{},s=["curl","-X",i,`'${n}'`];for(let[a,c]of Object.entries(o))c!==void 0&&c!==""&&s.push("-H",`'${a}: ${c}'`);if(i!=="GET"&&e.data!==void 0){let a=typeof e.data=="string"?e.data:JSON.stringify(e.data);s.push("-d",`'${a.replace(/'/g,"'\\''")}'`)}return s.join(" ")}function Kre(e,t,r,n,i="1.0.0"){let o={timestamp:t,path:r,version:i,...e},a=Object.keys(o).sort().map(c=>{let u=o[c];return u===void 0?"":`${c}${typeof u=="object"?JSON.stringify(u):u}`}).join("")+Gre[n];return(0,WD.default)(a).toUpperCase()}function Xre(e,t,r){let n=Date.now(),i={"Content-Type":"application/json",appKey:Hre[dl],sign:Kre(e,n,t,dl,zD),timestamp:n,version:zD};return r&&(i.authorization=r),i}function Vd(e,t,r){let n=or()||{appId:100},i={method:"POST",url:e,data:{...t,_appId:n.appId},headers:Xre({...t,_appId:n.appId},e,r?.userToken)};return r?.botToken&&(i.__botToken=r.botToken),xx.request(i)}var WD,Wre,Hre,Gre,zD,xx,HD=se(()=>{"use strict";Hd();WD=Br(UD(),1);bx();Er();zt();Ke();Wre={production:"https://api-gateway.shuwenda.com",test:"https://api-gateway.shuwenda.icu",develop:"https://shenyu-dev.shuwenda.icu"},Hre={production:"2A1C74D315CB4A01BF3DA8983695AFE2",test:"7374A073CCBD4C8CA84FAD33896F0B69",develop:"7374A073CCBD4C8CA84FAD33896F0B69"},Gre={production:"34E9023008EA445AAE6CC075CC954F46",test:"FE93D3322CB94E978CE95BD4AA2A37D7",develop:"FE93D3322CB94E978CE95BD4AA2A37D7"},zD="1.0.0";xx=Ri.create({baseURL:Wre[dl],timeout:1e4});xx.interceptors.request.use(e=>{if(e.headers?.authorization)return e;let t=e.__botToken;if(t){let r=Gd(t);r&&(e.headers=e.headers||{},e.headers.authorization=r)}return e},e=>Promise.reject(e));xx.interceptors.response.use(e=>e.data,e=>{let t=e.config??{},r=Vre(t);return $(`[request] curl for backend (failed request): ${r}`,"error"),Promise.reject(e)})});var GD,VD,Jre,Kd,wx=se(()=>{"use strict";HD();bx();Er();Ke();GD=async(e,t,r)=>{await Kd(t);let n=await Vd("/user/getStsTokenByAsync",{sourceFileName:e,isPrivate:r},{botToken:t});if(!n||!n.data||!n.data.bucket)throw new Error("\u83B7\u53D6 OSS \u4E34\u65F6\u51ED\u8BC1\u5931\u8D25");return n.data},VD=async(e,t)=>{try{await Kd(t);let r=await Vd("/user/generateSignUrl",{loudPlatform:0,fileName:e},{botToken:t});return r.code===0&&r.data?r.data.filePath??"":""}catch{return""}},Jre=async e=>{let t=gr(),r=await Vd("/organization/queryUserTokenByBotTokenV2",{botToken:e,_userId:t.userId??0});return!r||!r.data||!r.data.token?($("\u83B7\u53D6\u7ED1\u5B9A\u7684\u7528\u6237\u4FE1\u606F\u5931\u8D25: token:"+e+"|"+JSON.stringify(r),"error"),""):r.data.token},Kd=async e=>{let t=Gd(e);if(t)return t;$(`[api] cache miss, fetching userToken for botToken=${e.slice(0,10)}...`);let r=await Jre(e);return $D(e,r),r}});import{extname as Yre}from"node:path";import{fileURLToPath as Qre}from"node:url";function tne(e){if(typeof e=="string"){let t=e.trim();if(t.startsWith("file:"))try{return Qre(t)}catch{return e}return e}if(Buffer.isBuffer(e))return e;if(e&&typeof e=="object"){if(ArrayBuffer.isView(e)&&!(e instanceof DataView)&&!Buffer.isBuffer(e)){let n=e;return Buffer.from(n.buffer,n.byteOffset,n.byteLength)}let t=e,r=t.path??t.filePath;if(typeof r=="string"&&r.trim())return r.trim()}return e}function _x(e){let t=e.split(/[/\\]/).pop()??e,r=Yre(t).toLowerCase();return r?rne[r]:void 0}function nne(e,t){if(typeof e=="string")return _x(e)??"application/octet-stream";if(Buffer.isBuffer(e)){if(t){let i=_x(t);if(i)return i}return"application/octet-stream"}let r=e.type?.trim();if(r&&r!=="application/octet-stream")return r;let n=typeof e.name=="string"&&e.name?e.name:"";if(n){let i=_x(n);if(i)return i}return r||"application/octet-stream"}async function ine(e){if(Buffer.isBuffer(e))return{content:e,fileName:"file"};if(typeof e=="string")return{content:e,fileName:e.split(/[/\\]/).pop()??"file"};let t=Buffer.from(await e.arrayBuffer()),r=e.name;return{content:t,fileName:typeof r=="string"&&r?r:"file"}}var KD,L1e,Zre,ene,rne,Xd,Sx=se(()=>{"use strict";KD=Br(aq(),1);wx();Ke();L1e=1024*1024,Zre=1024*1024,ene=900*1e3;rne={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".gif":"image/gif",".webp":"image/webp",".bmp":"image/bmp",".svg":"image/svg+xml",".ico":"image/x-icon",".avif":"image/avif",".heic":"image/heic",".heif":"image/heif",".pdf":"application/pdf",".mp4":"video/mp4",".webm":"video/webm",".mov":"video/quicktime",".mp3":"audio/mpeg",".wav":"audio/wav",".ogg":"audio/ogg",".opus":"audio/opus",".m4a":"audio/mp4",".aac":"audio/aac",".flac":"audio/flac",".txt":"text/plain; charset=utf-8",".log":"text/plain; charset=utf-8",".csv":"text/csv; charset=utf-8",".html":"text/html; charset=utf-8",".htm":"text/html; charset=utf-8",".css":"text/css; charset=utf-8",".js":"text/javascript; charset=utf-8",".mjs":"text/javascript; charset=utf-8",".json":"application/json; charset=utf-8",".xml":"application/xml; charset=utf-8",".md":"text/markdown; charset=utf-8",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation"};Xd=async(e,t,r=1,n)=>{await Kd(t);let i=tne(e),{content:o,fileName:s}=await ine(i),a=await GD(s,t,r),c=nne(i,s),u=n?.onProgress,l={accessKeyId:a.tempAccessKeyId,accessKeySecret:a.tempAccessKeySecret,stsToken:a.tempSecurityToken,bucket:a.bucket,endpoint:a.endPoint,region:a.region,secure:!0,cname:!0,authorizationV4:!0,timeout:n?.timeoutMs??ene},p=new KD.default(l),f=`${a.uploadDir}${a.ossFileKey}`;try{let d,h={progress:E=>{u?.(E)},parallel:4,partSize:Zre,mime:c,headers:{"Content-Disposition":"inline"}};if(d=await p.multipartUpload(f,o,h),d?.res?.status!==200)return $(`OSS \u4E0A\u4F20\u5931\u8D25, ${d?.res?.status}`,"error"),"";let v=(d?.res?.requestUrls||[])[0]||"";return $(`OSS \u4E0A\u4F20\u6210\u529F, ${r===1&&d.name||v}`),r===1&&d.name||v}catch(d){$(`OSS \u4E0A\u4F20\u5931\u8D25: ${d}`,"error")}}});import one from"node:path";import kx from"node:fs";function Ii(){let t=Et().replace("workspace","cron");return one.join(t,"jobs.json")}function Ho(e,t){let r=t?.trim();if(!r)return null;if(!kx.existsSync(e))return $(`readCronJobSessionKey: file not found ${e}`,"error"),null;try{let n=kx.readFileSync(e,"utf8");return(JSON.parse(n).jobs??[]).find(s=>s.id===r)||null}catch(n){return $(`readCronJobSessionKey: failed to read ${e}: ${String(n)}`,"error"),null}}async function sne(e){let t=Ii(),r=gr().botToken;if(kx.existsSync(t))try{let n=await Xd(t,r??"",0);$(`\u5B9A\u65F6\u4EFB\u52A1\u66F4\u65B0\u6210\u529F: ${n}`);let i=e?.split(":")||[],o=i.at(-1)??"",s=i.at(-2)??"";K_({event_type:"cron",operation_type:"install",session_id:o,agent_id:s,oss_url:n})}catch(n){$(`${t} upload failed: ${n}`,"error")}else $(`${t} not found`,"error")}function ga(e){let t=Ii(),r=Ho(t,e);if(!r||!r.sessionKey){$(`sendDcgchatCron: invalid job or missing sessionKey for jobId=${e}`,"error");return}let{sessionKey:n}=r;$(`sessionKey: ${n}, jobId: ${e}`),Ex!==null&&clearTimeout(Ex),Ex=setTimeout(()=>{sne(n)},C_)}var Ex,XD,JD,YD,QD,Tx,Jd=se(()=>{"use strict";$r();lt();Sx();Ke();qi();Er();zt();Ex=null;XD=async e=>{if(!e?.trim()){$("onRemoveCronJob: empty jobId","error");return}xt({method:"cron.remove",params:{id:e}})},JD=async e=>{if(!e?.trim()){$("onRemoveCronJob: empty jobId","error");return}xt({method:"cron.update",params:{id:e,patch:{enabled:!1}}})},YD=async e=>{if(!e?.trim()){$("onRemoveCronJob: empty jobId","error");return}xt({method:"cron.update",params:{id:e,patch:{enabled:!0}}})},QD=async(e,t)=>{let r=e?.trim();if(!r){$("onRemoveCronJob: empty jobId","error");return}let n=Ii(),{sessionKey:i}=Ho(n,e)||{};if(!i){$(`onRunCronJob: no sessionKey for job id=${r}`,"error");return}no(i,t),xt({method:"cron.runs",params:{scope:"job",id:e,limit:50,offset:0,status:"all",sortDir:"desc"}}),xt({method:"cron.run",params:{id:e,mode:"force"}})},Tx=async(e,t,r)=>{let n=e?.trim();if(!n){$("finishedDcgchatCron: empty jobId","error");return}let i=Ii(),{sessionKey:o,name:s}=Ho(i,n)||{};if(!o){$(`finishedDcgchatCron: no sessionKey for job id=${n}`,"error");return}let a=Dn(o)||`${Date.now()}`,c=o.split(":"),u=c.at(-1)??"",l=c.at(-2)??"",p=W_({agentId:l,sessionId:`${u}`,messageId:a||`${Date.now()}`,real_mobook:u?"":1}),f={source:"cron"};r&&(f.hasFile=!0),sn(p,{response:t,message_tags:f,is_finish:-1}),setTimeout(()=>{sr(p,"cron send")},200);let d=Sr(),h=gr();yr()&&d?.send(JSON.stringify({messageType:"openclaw_bot_event",source:"client",content:{event_type:"notify",operation_type:"cron",bot_token:h.botToken,app_id:h.appId,session_id:u,agent_id:l,real_mobook:u?"":1,title:s}})),N_(o),$(`finishedDcgchatCron: job=${n} sessionKey=${o}`)}});import Cx from"node:os";import Pi from"node:path";function eN(e){return Pi.normalize(e.trim()).replace(/\\/g,"/")}function ZD(e,t){let r=Pi.resolve(t),n=Pi.resolve(e),i=Pi.relative(r,n);return!(i.startsWith("..")||Pi.isAbsolute(i))}function Ox(e,t,r){let n=t?.trim();if(n&&ZD(e,n))return!0;if(r?.length){for(let o of r)if(ZD(e,o))return!0}let i=eN(e);return i.startsWith("/workspace/")||i==="/workspace"||i.startsWith("/mobook/")||i==="/mobook"?!0:/^[A-Za-z]:\/(workspace|mobook)(\/|$)/.test(i)}function Ax(e){return e.replace(/[`'",,*_)\]]+$/u,"").trimEnd()}function Rx(e){let t=e.trim();return t&&(t==="~"?Cx.homedir():t.startsWith("~/")?Pi.resolve(Cx.homedir(),t.slice(2)):t.startsWith("~\\")?Pi.resolve(Cx.homedir(),t.slice(2)):t)}function tN(e,t){if(!e)return[];let r=e.match(/\/workspace\/[^\s]+|\/mobook\/[^\s]+/g)??[],n=e.match(/[A-Za-z]:[/\\](?:workspace|mobook)[/\\][^\s]+/g)??[],i=e.match(/~[/\\][^\s`'")\]]+/g)??[],o=[],s=t?.trim();if(s){let u=new Set;u.add(s),u.add(eN(s)),Pi.sep==="\\"&&u.add(s.replace(/\//g,"\\"));for(let l of u){if(!l)continue;let p=0;for(;p<e.length;){let f=e.indexOf(l,p);if(f===-1)break;let d=f+l.length;for(;d<e.length&&!/\s/.test(e[d]);)d++;o.push(e.slice(f,d)),p=f+1}}}let c=[...r,...n,...i,...o].map(u=>Ax(u)).filter(Boolean).map(u=>u.startsWith("~")?Rx(u):u);return[...new Set(c)]}var rN=se(()=>{"use strict"});function ane(e,t){if(typeof e=="string"){let r=e.trim();r&&t.push(r);return}if(e&&typeof e=="object"){let r=e,n=typeof r.path=="string"?r.path.trim():"",i=typeof r.file=="string"?r.file.trim():"",o=n||i;o&&t.push(o)}}function cne(e){if(e==null||typeof e!="object")return[];let r=e.attachments;if(!Array.isArray(r))return[];let n=[];for(let i of r)ane(i,n);return[...new Set(n)]}function nN(e){let t=new Set,r=[];for(let n of e)!n||t.has(n)||(t.add(n),r.push(n));return r}function iN(e,t,r,n){let o=cne(e).map(a=>Rx(Ax(a))).filter(Boolean).filter(a=>Ox(a,r,n));if(o.length>0)return nN(o);let s=tN(t,r).filter(a=>Ox(a,r,n));return nN(s)}var oN=se(()=>{"use strict";rN()});async function sN(e){try{if(e.event==="agent"){let t=e.payload,r=B_(t.runId),n=or(r);t.data?.delta&&n.sessionId&&_l(t.data.delta,n,0)}if(e.event==="cron"){let t=e.payload;if(t?.action==="started"?$(`[Gateway] \u5B9A\u65F6\u4EFB\u52A1\u6267\u884C\u5F00\u59CB: ${JSON.stringify(t)}`):$(`[Gateway] \u6536\u5230\u5B9A\u65F6\u4EFB\u52A1\u4E8B\u4EF6: ${JSON.stringify(t)}`),t?.action==="added"&&ga(t?.jobId),t?.action==="updated"&&ga(t?.jobId),t?.action==="removed"&&ga(t?.jobId),t?.action==="finished"){let r=typeof t?.jobId=="string"?t.jobId.trim():"";if(t?.status==="ok"){let n=typeof t?.summary=="string"?t.summary:"";n.indexOf("HEARTBEAT_OK")>=0&&n!=="HEARTBEAT_OK"&&(n=n.replace("HEARTBEAT_OK",""));let o=gt()?.channels?.[be],s=iN(t,n,Et(),o?.allowedPaths),a=Ii(),c=r?Ho(a,r):null,u=c&&typeof c.sessionKey=="string"?c.sessionKey.trim():"";if(u&&s.length>0){let p=Dn(u)||`${Date.now()}`;no(u,p);for(let f of s)try{await Jr({sessionKey:u,mediaUrl:f,messageId:p})}catch(d){$(`[Gateway] cron \u9644\u4EF6\u7ECF\u901A\u9053\u53D1\u9001\u5931\u8D25: ${f} ${String(d)}`,"error")}}else s.length>0&&!u&&$(`[Gateway] cron finished \u6709\u53EF\u53D1\u9001\u9644\u4EF6\u8DEF\u5F84\u4F46 jobs.json \u65E0 sessionKey: jobId=${r}`,"error");let l=s.length>0;Tx(r,n,l),ga(r)}else{let n=typeof t?.summary=="string"?t.summary:"";Tx(r,"\u5B9A\u65F6\u4EFB\u52A1\u6267\u884C\u5931\u8D25"+(n?`
|
|
104
|
+
${n}`:""),!1),ga(r)}}}}catch(t){$(`[Gateway] \u5904\u7406\u4E8B\u4EF6\u5931\u8D25: ${t}`,"error")}return{type:e.event,payload:e.payload,seq:e.seq}}var aN=se(()=>{"use strict";Jd();ya();oN();zt();Ke();Er();$r();lt()});import cN from"crypto";var Yd,uN=se(()=>{"use strict";Zm();pS();Ke();lt();aN();Yd=class{ws=null;config;deviceId;privateKeyPem;publicKeyB64Url;connected=!1;connId=null;connectChallengeNonce=null;connectSent=!1;pendingRpcById=new Map;eventHandlers=new Set;constructor(t){this.config={url:t.url,token:t.token,role:t.role||"operator",scopes:t.scopes||["operator.admin"],reconnectInterval:t.reconnectInterval||5e3,maxReconnectAttempts:t.maxReconnectAttempts||10};let r=this.loadOrCreateDeviceIdentity();this.deviceId=r.deviceId,this.privateKeyPem=r.privateKeyPem,this.publicKeyB64Url=r.publicKeyB64Url}loadOrCreateDeviceIdentity(){let t=z("fs"),r=z("path"),n=Et(),i=r.join(n,".state"),o=r.join(i,"device.json");if(t.existsSync(o)){let p=JSON.parse(t.readFileSync(o,"utf8"));if(p.deviceId&&p.publicKeyPem&&p.privateKeyPem){let f=tg(p.publicKeyPem),d=f!==p.deviceId?f:p.deviceId;if(f!==p.deviceId)try{t.writeFileSync(o,JSON.stringify({...p,deviceId:f},null,2))}catch{}return{deviceId:d,publicKeyPem:p.publicKeyPem,privateKeyPem:p.privateKeyPem,publicKeyB64Url:eg(p.publicKeyPem)}}}let s=cN.generateKeyPairSync("ed25519"),a=s.publicKey.export({type:"spki",format:"pem"}).toString(),c=s.privateKey.export({type:"pkcs8",format:"pem"}).toString(),u=tg(a),l=eg(a);return t.existsSync(i)||t.mkdirSync(i,{recursive:!0}),t.writeFileSync(o,JSON.stringify({version:1,deviceId:u,publicKeyPem:a,privateKeyPem:c,createdAtMs:Date.now()},null,2)),t.chmodSync(o,384),{deviceId:u,publicKeyPem:a,privateKeyPem:c,publicKeyB64Url:l}}async connect(){return new Promise((t,r)=>{this.connectChallengeNonce=null,this.connectSent=!1,this.ws=new Ml.default(this.config.url);let n=!1,i=s=>{n||(n=!0,clearTimeout(o),s())},o=setTimeout(()=>{i(()=>r(new Error("Gateway connection timeout")))},15e3);this.ws.on("open",()=>{$("Gateway connection opened\uFF08\u7B49\u5F85 connect.challenge\uFF09")}),this.ws.on("message",s=>{try{let a=JSON.parse(s.toString());this.handleMessage(a,c=>i(()=>t(c)),c=>i(()=>r(c)),o)}catch(a){$(`[Gateway=>\u63D2\u4EF6]-[\u6D88\u606F\u89E3\u6790\u5931\u8D25]: ${a}`,"error")}}),this.ws.on("close",()=>{this.connected=!1,i(()=>r(new Error("Gateway \u5728\u63E1\u624B\u5B8C\u6210\u524D\u5173\u95ED\u4E86\u8FDE\u63A5")))}),this.ws.on("error",s=>{$(`Gateway \u8FDE\u63A5\u9519\u8BEF: ${s}`,"error"),i(()=>r(s))})})}sendConnect(){if(this.connectSent)return;let t=this.connectChallengeNonce?.trim()??"";if(!t)return;this.connectSent=!0;let r=Date.now(),n=process.platform,i=lS({deviceId:this.deviceId,clientId:"gateway-client",clientMode:"backend",role:this.config.role,scopes:this.config.scopes,signedAtMs:r,token:this.config.token,nonce:t,platform:n,deviceFamily:""}),o=uS(this.privateKeyPem,i),s=JSON.stringify({type:"req",id:"1",method:"connect",params:{minProtocol:3,maxProtocol:3,client:{id:"gateway-client",version:"1.0.0",platform:n,mode:"backend"},auth:{token:this.config.token},role:this.config.role,scopes:this.config.scopes,device:{id:this.deviceId,publicKey:this.publicKeyB64Url,signature:o,signedAt:r,nonce:t}}});this.ws?.send(s)}mapHelloPayloadToHelloOk(t){let r=t.server,n=t.features;return{server:{connId:typeof r?.connId=="string"?r.connId:""},features:{methods:Array.isArray(n?.methods)?n.methods:[],events:Array.isArray(n?.events)?n.events:[]},policy:t.policy,auth:t.auth}}acknowledgeGatewayHelloOk(t){clearTimeout(t)}handleMessage(t,r,n,i){let o=t.type;if(t.type==="event"&&t.event==="connect.challenge"){let s=t.payload,a=typeof s?.nonce=="string"?s.nonce.trim():"";if(!a){n(new Error("connect.challenge \u7F3A\u5C11 nonce"));return}this.connectChallengeNonce=a,this.sendConnect();return}if(t.type==="res"&&!this.connected){let s=t.ok===!0,a=t.payload;if(s&&a&&a.type==="hello-ok"){this.connected=!0;let c=a.server;this.connId=typeof c?.connId=="string"?c.connId:null,this.acknowledgeGatewayHelloOk(i),r(this.mapHelloPayloadToHelloOk(a));return}if(t.ok===!1){let c=t.error,u=typeof c?.message=="string"&&c.message||"Gateway connect \u88AB\u62D2\u7EDD";clearTimeout(i),n(new Error(u));return}}if(o==="hello-ok"||!o&&t.server){this.connected=!0,this.connId=t.server?.connId||null,this.acknowledgeGatewayHelloOk(i),r(t);return}if(t.type==="res"){let s=this.pendingRpcById.get(t.id);s&&(this.pendingRpcById.delete(t.id),s(t));return}t.type==="event"&&sN(t).then(s=>{this.eventHandlers.forEach(a=>a(s))}).catch(s=>{$(`[Gateway] event \u5904\u7406\u5F02\u6B65\u5931\u8D25: ${String(s)}`,"error")})}async callMethod(t,r={}){let n=cN.randomUUID();return new Promise((i,o)=>{if(!this.connected||!this.ws){o(new Error("Not connected to gateway"));return}let s=setTimeout(()=>{this.pendingRpcById.delete(n),o(new Error("Method call timeout"))},3e4);this.pendingRpcById.set(n,c=>{if(clearTimeout(s),c.ok){let u=c.result!==void 0?c.result:c.payload;i(u)}else o(new Error(c.error?.message||"Method call failed"))});let a=JSON.stringify({type:"req",id:n,method:t,params:r});this.ws.send(a),$(`[\u63D2\u4EF6=>Gateway]-[callMethod]: ${a}`)})}onEvent(t){return this.eventHandlers.add(t),()=>this.eventHandlers.delete(t)}close(){this.ws?.close(1e3,"Plugin stopped"),this.connected=!1}isConnected(){return this.connected}getConnId(){return this.connId}getWebSocket(){return this.ws}ping(){this.ws?.ping()}}});function une(e){return e!==null&&typeof e=="object"&&Object.keys(e).length===0}function gu(e){if(!e||typeof e!="object"||une(e))return!1;let t=e.channels;return!t||typeof t!="object"||Object.keys(t).length===0?!1:t[be]!=null}var Ix=se(()=>{"use strict";zt()});function lne(e){return e.gateway}function pne(e){if(!e)throw new Error("OpenClaw \u914D\u7F6E\u672A\u521D\u59CB\u5316\uFF08\u9700\u5148\u5B8C\u6210\u63D2\u4EF6 register\uFF09");let t=lne(e),r=process.env.OPENCLAW_GATEWAY_TOKEN||t?.auth?.token||"";if(!r)throw new Error("\u7F3A\u5C11 Gateway token\uFF1A\u8BF7\u5728 openclaw.json \u7684 gateway.auth.token \u8BBE\u7F6E\uFF0C\u6216\u8BBE\u7F6E\u73AF\u5883\u53D8\u91CF OPENCLAW_GATEWAY_TOKEN");let n=t?.tls?.enabled===!0?"wss":"ws";return{url:process.env.OPENCLAW_GATEWAY_URL||t?.remote?.url||`${n}://127.0.0.1:${t?.port??18789}`,token:r,role:"operator",scopes:["operator.admin"]}}function fne(){let e=gt();if(gu(e))return e;try{let t=Ur().config.loadConfig();return gu(t)?t:null}catch{return null}}function dne(){try{let e=fne();return e?pne(e):($("Gateway \u6301\u4E45\u8FDE\u63A5\u672A\u542F\u52A8: \u65E0\u53EF\u7528 OpenClaw \u914D\u7F6E\uFF08plugins.register \u672A\u5B8C\u6210\u6216 loadConfig \u5931\u8D25\uFF09","error"),null)}catch(e){return $(`Gateway \u6301\u4E45\u8FDE\u63A5\u672A\u542F\u52A8: ${e}`,"error"),null}}function Dx(){Qd&&(clearInterval(Qd),Qd=null)}function hne(){va&&(clearTimeout(va),va=null)}function mne(e){Dx(),Qd=setInterval(()=>{if(e.isConnected())try{e.ping()}catch(t){$(`Gateway ping \u5931\u8D25: ${t}`,"error")}},hl)}function pN(){ba||va||(va=setTimeout(()=>{va=null,fN()},rc))}function gne(e,t){let r=e.getWebSocket();if(!r)return;let n=()=>{t===Zd&&(Dx(),Sn===e&&(Sn=null),$("Gateway WebSocket \u5DF2\u65AD\u5F00\uFF0C\u5C06\u5728 5s \u540E\u91CD\u8FDE","error"),ba||pN())};r.once("close",n),r.once("error",n)}async function fN(){if(ba||Sn?.isConnected()||Px)return;let e=dne();if(e){Px=!0;try{Zd+=1;let t=Zd;if(Sn){try{Sn.close()}catch{}Sn=null}let r=new Yd(e);if(await r.connect(),ba){try{r.close()}catch{}return}if(t!==Zd){try{r.close()}catch{}return}Sn=r,gne(r,t),mne(r),$(`Gateway \u6301\u4E45\u8FDE\u63A5\u6210\u529F connId=${r.getConnId()??"?"}`)}catch(t){$(`Gateway \u8FDE\u63A5\u5931\u8D25: ${t}`,"error"),Sn=null,Dx(),ba||pN()}finally{Px=!1}}}function dN(){ba=!1,hne(),qx==null&&(qx=setTimeout(()=>{qx=null,fN()},0))}function lN(){return Sn?.isConnected()??!1}async function hN(e){let t=e?.timeoutMs??yne,r=e?.intervalMs??vne,n=Date.now()+t;for(;;){if(e?.signal?.aborted)return!1;if(lN())return!0;if(Date.now()>=n)return lN();await new Promise(i=>setTimeout(i,r))}}async function bne(e,t={}){let r=Sn;if(!r?.isConnected())throw new Error("Gateway \u672A\u8FDE\u63A5\uFF08\u7B49\u5F85\u91CD\u8FDE\u6216\u68C0\u67E5\u914D\u7F6E\uFF09");return r.callMethod(e,t)}async function xt(e){return bne(e.method,e.params??{})}var Sn,Qd,va,qx,Px,ba,Zd,yne,vne,qi=se(()=>{"use strict";lt();uN();Ke();Ix();zt();Sn=null,Qd=null,va=null,qx=null,Px=!1,ba=!0,Zd=0;yne=12e4,vne=150});import Ni from"node:fs";import Nx from"node:path";function Mx(){let e=Et();return e?Nx.join(Nx.dirname(e),xne):null}function mN(e){let t=Mx();if(!t){$("writeSessionStateFile: workspace dir not initialized, skip","error");return}let r={version:Fx,savedAt:Date.now(),params:$_(),global:F_(),subagent:e};try{let n=Nx.dirname(t);Ni.existsSync(n)||Ni.mkdirSync(n,{recursive:!0});let i=`${t}.tmp`;Ni.writeFileSync(i,JSON.stringify(r,null,2),"utf8"),Ni.renameSync(i,t),$(`session state persisted: ${t}`)}catch(n){$(`writeSessionStateFile failed: ${String(n)}`,"error")}}function gN(){let e=Mx();if(!e||!Ni.existsSync(e))return null;try{let t=Ni.readFileSync(e,"utf8"),r=JSON.parse(t);return!r||typeof r!="object"?null:r.version!==Fx?($(`readSessionStateFile: version mismatch ${r.version} vs ${Fx}`,"error"),null):r}catch(t){return $(`readSessionStateFile failed: ${String(t)}`,"error"),null}}function yN(e){e&&(z_(e.params),M_(e.global))}function vN(){let e=Mx();if(e)try{Ni.existsSync(e)&&Ni.unlinkSync(e)}catch(t){$(`removeSessionStateFile failed: ${String(t)}`,"error")}}function Di(e,t){let r=t?.trim();r&&e.add(r)}function bN(e){if(!e)return[];let t=new Set;for(let[r]of e.params?.paramsMessageMap??[])Di(t,r);for(let[,r]of e.params?.subagentRunIdMap??[])Di(t,r);for(let[r]of e.global?.msgStatusBySessionKey??[])Di(t,r);for(let[r]of e.global?.cronMessageIdMap??[])Di(t,r);for(let[r]of e.subagent?.activeSubagentRunIdsByRequester??[])Di(t,r);for(let[r,n]of e.subagent?.requesterByChildSessionKey??[])Di(t,r),Di(t,n);for(let[r]of e.subagent?.runIdByChildSessionKey??[])Di(t,r);return[...t]}var Fx,xne,xN=se(()=>{"use strict";lt();Er();Ke();Fx=1,xne="session-state.json"});function wN(e){jx=e}function wne(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Array.isArray(e.messages)}function _N(){let e=globalThis;if(e.__dcgchatLlmBodyExtFetchPatched1)return;e.__dcgchatLlmBodyExtFetchPatched1=!0;let t=globalThis.fetch.bind(globalThis);async function r(n,i){let o=jx;if(!o||i?.body==null||typeof i.body!="string")return t(n,i);try{let s=JSON.parse(i.body);if(!wne(s))return t(n,i);let a="ext"in s&&typeof s.ext=="object"&&s.ext!==null&&!Array.isArray(s.ext)?{...s.ext}:{};return s.ext={...a,sessionKey:o.sessionKey,agentCloneCode:o.agentCloneCode},jx=void 0,t(n,{...i,body:JSON.stringify(s)})}catch{return t(n,i)}}Object.assign(r,t),globalThis.fetch=r}var jx,SN=se(()=>{"use strict"});import{randomUUID as _ne}from"node:crypto";function AN(e){let t=e.trim(),r=or(t);if(r.messageId?.trim()||r.sessionId?.trim())return r;let n=Dr.get(t);if(n){let i=or(n);if(i.messageId?.trim()||i.sessionId?.trim())return i}return r}function yu(e){let t=e.trim();if(!t)return!1;if(Am(t)==="running")return!0;let r=Dr.get(t);return r?Am(r)==="running":!1}function Lx(e,t,r,n){let i=AN(e);sn(i,{is_finish:-1,tool_call_id:r,is_cover:n,thinking_content:t,response:""},!1)}function Ene(e){return e==="before_tool_call"||e==="after_tool_call"}function EN(e,t,r,n){let i=r.toolCallId||r.runId||Date.now().toString();return{callId:i,text:JSON.stringify({type:e,specialIdentification:"dcgchat_tool_call_special_identification",callId:i,...t,status:n})}}function kN(e){let t=Nr.get(e);return t||(t=new Set,Nr.set(e,t)),t}function kne(e){let t=Nr.get(e);if(t&&t.size>0)return;Nr.delete(e);let r=Fi.get(e);if(r?.size){Fi.delete(e);for(let n of r)try{n()}catch(i){$(`subagent idle waiter error: ${String(i)}`,"error")}}}function Tne(e,t,r){let n=e.trim(),i=t.trim(),o=r.trim();if(!n||!i||!o){$(`subagent track spawn skipped: missing key req=${n} runId=${i} child=${o}`);return}kN(n).add(i),Dr.set(o,n),Mi.set(o,i),$(`subagent track spawn: requester=${n} runId=${i} child=${o} active=${kN(n).size}`)}function Cne(e,t,r){let n=t.trim();if(!n)return;let i=e.requesterSessionKey?.trim()||Dr.get(n)||e.sessionKey?.trim()||"",o=(r?.trim()||Mi.get(n)||"").trim();if(Im(o),!i){$(`subagent track end: no requester for child=${n} runId=${o}`),Dr.delete(n),Mi.delete(n);return}let s=Nr.get(i);s&&o&&s.delete(o),Dr.delete(n),Mi.delete(n),$(`subagent track end: requester=${i} runId=${o||"n/a"} remaining=${s?.size??0}`),s&&s.size===0&&Nr.delete(i),kne(i)}function TN(e){let t=e.trim();if(!t)return[];let r=[];for(let[n,i]of Dr.entries())i===t&&r.push(n);return r}function RN(e){let t=e.trim();if(!t)return[];let r=[],n=new Set,i=TN(t);for(;i.length>0;){let o=[];for(let s of i){let a=s.trim();!a||n.has(a)||(n.add(a),r.push(a),o.push(...TN(a)))}i=o}return r}function eh(e){let t=e.trim();if(!t)return;let r=Nr.get(t);if(r)for(let i of r)Im(i);for(let[i,o]of[...Dr.entries()])o===t&&(Dr.delete(i),Mi.delete(i));Nr.delete(t);let n=Fi.get(t);if(n?.size){Fi.delete(t);for(let i of n)try{i()}catch(o){$(`subagent idle waiter error: ${String(o)}`,"error")}}}function CN(e){let t=e?.trim();return t?Nr.get(t)?.size??0:0}function IN(e,t){let r=e?.trim();return!r||CN(r)===0?Promise.resolve():new Promise((n,i)=>{let o=!1,s=f=>{o||(o=!0,l&&clearTimeout(l),t?.signal?.removeEventListener("abort",u),a(),f())},a=()=>{let f=Fi.get(r);f&&(f.delete(c),f.size===0&&Fi.delete(r))},c=()=>s(()=>n()),u=()=>{let f=t?.signal?.reason;s(()=>i(f instanceof Error?f:new Error(String(f??"Aborted"))))},l;if(t?.timeoutMs!=null&&t.timeoutMs>0&&(l=setTimeout(()=>s(()=>i(new Error(`waitUntilSubagentsIdle timeout ${t.timeoutMs}ms`))),t.timeoutMs)),t?.signal){if(t.signal.aborted){u();return}t.signal.addEventListener("abort",u,{once:!0})}let p=Fi.get(r);p||(p=new Set,Fi.set(r,p)),p.add(c),CN(r)===0&&c()})}function One(e,t){return e==="subagent_spawned"||e==="subagent_ended"||e==="subagent_spawning"||e==="subagent_delivery_target"?(t?.runId&&t?.requesterSessionKey&&U_(t?.runId,t?.requesterSessionKey),(t?.requesterSessionKey||t?.sessionKey||"").trim()):(t?.sessionKey||"").trim()}function Ane(e){if(e?.toolName==="cron")return!0;let t=e?.params?.command;return e?.toolName==="exec"&&typeof t=="string"?t.includes("cron create")||t.includes("cron add"):!1}function Rne(){return{activeSubagentRunIdsByRequester:[...Nr.entries()].map(([e,t])=>[e,[...t]]),requesterByChildSessionKey:[...Dr.entries()],runIdByChildSessionKey:[...Mi.entries()]}}function Ine(e){if(Nr.clear(),Dr.clear(),Mi.clear(),!!e){for(let[t,r]of e.activeSubagentRunIdsByRequester??[]){if(typeof t!="string"||!t||!Array.isArray(r))continue;let n=new Set;for(let i of r)typeof i=="string"&&i&&n.add(i);n.size>0&&Nr.set(t,n)}for(let[t,r]of e.requesterByChildSessionKey??[])typeof t=="string"&&typeof r=="string"&&t&&r&&Dr.set(t,r);for(let[t,r]of e.runIdByChildSessionKey??[])typeof t=="string"&&typeof r=="string"&&t&&r&&Mi.set(t,r)}}async function qne(e){if(!await hN({timeoutMs:12e4,intervalMs:150})){$("gateway_start resume: Gateway \u5728\u8D85\u65F6\u5185\u672A\u5C31\u7EEA\uFF0C\u5DF2\u8DF3\u8FC7\u300C\u7EE7\u7EED\u6267\u884C\u300D chat.send\uFF1B\u8BF7\u91CD\u8FDE\u540E\u624B\u52A8\u53D1\u6D88\u606F\u6216\u518D\u6B21\u89E6\u53D1\u6062\u590D","error");return}for(let r of e)try{await xt({method:"chat.send",params:{sessionKey:r,message:"\u7EE7\u7EED\u6267\u884C",deliver:!1,idempotencyKey:_ne()}}),$(`gateway_start resume: chat.send ok sessionKey=${r}`)}catch(n){$(`gateway_start resume: chat.send failed sessionKey=${r}: ${String(n)}`,"error")}}function Pne(e,t,r){if(e==="subagent_spawned"){let n=typeof t?.runId=="string"?t.runId:"",i=typeof t?.childSessionKey=="string"?t.childSessionKey:"",o=typeof r?.requesterSessionKey=="string"?r.requesterSessionKey:typeof r?.sessionKey=="string"?r.sessionKey:"";Tne(o,n,i);return}if(e==="subagent_ended"){let n=typeof t?.targetSessionKey=="string"?t.targetSessionKey:"",i=typeof t?.runId=="string"?t.runId:void 0;Cne(r??{},n,i)}}function qN(e){if(!ON.has(e)){ON.add(e),_N(),e.on("llm_input",(t,r)=>{let n=typeof r?.sessionKey=="string"?r.sessionKey.trim():"",i=r?.agentId;wN(n&&i!=="main"?{sessionKey:n,agentCloneCode:typeof i=="string"?i:String(i??"")}:void 0)}),e.on("gateway_stop",(t,r)=>{try{mN(Rne())}catch(n){$(`gateway_stopped persist session state failed: ${String(n)}`,"error")}}),e.on("gateway_start",(t,r)=>{try{let n=gN();if(!n)return;let i=bN(n);if(yN(n),Ine(n?.subagent),vN(),!i.length)return;$(`gateway_started: \u5DF2\u4ECE\u5FEB\u7167\u6062\u590D session state\uFF08savedAt=${n.savedAt}, \u6062\u590D\u4F1A\u8BDD\u6570\u91CF\uFF1A${i.toString()}\uFF09`),qne(i)}catch(n){$(`gateway_started restore session state failed: ${String(n)}`,"error")}});for(let t of Sne)e.on(t.event,(r,n)=>{if(t.event==="subagent_ended"&&r?.targetKind==="acp")return;Pne(t.event,r,n);let i=One(t.event,n??{});if(!i){t.event!=="before_tool_call"&&$(`\u5DE5\u5177\u8C03\u7528\u7ED3\u679C\uFF1A ~ event:${t.event} ~ \u6CA1\u6709sessionKey \u4E3A\u6267\u884C`,"error");return}if(!(yu(i)||t.event==="before_tool_call"&&Ane(r)))return;if(Ene(t.event)){let{result:u,...l}=r;if($(`\u5DE5\u5177\u8C03\u7528\u7ED3\u679C\uFF1A ~ event:${t.event} ~ params:${JSON.stringify(l)}`),t.event==="before_tool_call"){let d=Z_(l,i),{text:h,callId:m}=EN(t.event,l,r,"running");return Lx(i,h,m,0),d}let{text:p,callId:f}=EN(t.event,l,r,"finished");Lx(i,p,f,1);return}let s=AN(i);if(t.event==="llm_output"&&r.lastAssistant?.errorMessage==="1003-\u989D\u5EA6\u4E0D\u8DB3\u8BF7\u5145\u503C"){an("\u60A8\u7684\u58A8\u6EF4\u5DF2\u6D88\u8017\u5B8C\uFF0C\u60A8\u53EF\u4EE5\u901A\u8FC7\u5145\u503C\u58A8\u6EF4\u6765\u7EE7\u7EED\u4F7F\u7528",s,{message_tags:{insufficient_balance:1},is_finish:-1}),sr(s,"\u58A8\u6EF4\u4E0D\u8DB3");return}let a=r.runId||Date.now().toString(),c=JSON.stringify({type:t.event,specialIdentification:"dcgchat_tool_call_special_identification",toolName:"",callId:a,params:""});Lx(i,c,a,0),$(`\u5DE5\u5177\u8C03\u7528\u7ED3\u679C\uFF1A ~ event:${t.event}`)})}}var Sne,Nr,Dr,Mi,Fi,ON,xa=se(()=>{"use strict";lt();Ke();$r();Er();e1();qi();xN();SN();Sne=[{event:"subagent_spawning"},{event:"subagent_spawned"},{event:"subagent_delivery_target"},{event:"llm_output"},{event:"subagent_ended"},{event:"before_tool_call"},{event:"after_tool_call"}];Nr=new Map,Dr=new Map,Mi=new Map,Fi=new Map;ON=new WeakSet});function vu(e){let t=e.replace("dcg-cron:","").trim();return t?xl(t)?.sessionKey?.trim()||t:""}function th(e){let t=e.split(":").filter(n=>n.length>0),r=t.findIndex(n=>n.toLowerCase()==="cron");return r<0||r+1>=t.length?null:t[r+1]??null}function Bx(e){let t=th(e);if(!t)return e;let r=Ho(Ii(),t),n=r&&typeof r.sessionKey=="string"?r.sessionKey.trim():"";return n||($(`dcgchat: cron job ${t} has no sessionKey in jobs.json, keep outbound key=${e}`,"error"),e)}function wa(e,t){let r=e?.trim()??"";return r.indexOf("dcg-cron:")>=0?r:t}var Ux=se(()=>{"use strict";Jd();Ke();Er()});import Dne from"node:fs";function $x(e,t){if(e!=null){if(typeof e=="string"){let r=e.trim();if(!r)return;if(r.startsWith("["))try{let n=JSON.parse(r);$x(n,t);return}catch{}t.push(r);return}if(Array.isArray(e)){for(let r of e)$x(r,t);return}if(typeof e=="object"){let r=e,n=r.file??r.path??r.url;typeof n=="string"&&n.trim()&&t.push(n.trim())}}}function _a(e){let t=[];return $x(e,t),[...new Set(t.filter(Boolean))]}function Fne(e,t,r,n){let i=!e?.messageId||String(e?.messageId).length===Nne;return{response:t?.text??"",message_tags:i?{mark:"empty_text_file"}:{},is_finish:i?-1:0,files:[{url:r??"",name:n}]}}async function Jr(e){let t=(e.sessionKey??"").trim(),r=t.replace(/^dcg-cron:/i,"").trim(),n=th(r)!==null,i=t.toLowerCase().startsWith("dcg-cron:"),o=vu(e.sessionKey??"");o=Bx(o),!e.messageId?.trim()&&(n||i)&&!Dn(o)&&no(o,`${Date.now()}`);let s=Dn(o),a=oc(o),c=e.messageId?.trim()?{...a,messageId:e.messageId.trim()}:s?{...a,messageId:s}:a;if(!yr()){$(`dcgchat: outbound media skipped -> ws not isWsOpen failed open: ${e.mediaUrl??""}`);return}let u=_a(e.mediaUrl);if(u.length===0){$(`dcgchat: sendMedia skipped (no resolvable path): ${typeof e.mediaUrl=="string"?e.mediaUrl:JSON.stringify(e.mediaUrl)} sessionKey=${o}`,"error");return}if(u.length>1){for(let m of u)await Jr({...e,mediaUrl:m});return}let l=u[0],{sessionId:p,agentId:f}=Rm(o);if(c.sessionId||(c.sessionId=p),c.agentId||(c.agentId=f),!l||!c.sessionId){$(`dcgchat: sendMedia skipped (duplicate in session): ${l} sessionId=${c.sessionId} sessionKey=${o}`);return}let d;try{d=Dne.statSync(l)}catch(m){$(`dcgchat: sendMedia skipped (cannot stat path): ${l} ${String(m)} sessionKey=${o}`,"error");return}if(!d.isFile()){let m=d.isDirectory()?"directory":"non-regular";$(`dcgchat: sendMedia skipped (not a regular file, ${m}): ${l} sessionKey=${o}`,"error");return}if(l&&c.sessionId){let m=vl(c.messageId,c.sessionId,o);if(!m){$(`dcgchat: sendMedia skipped (no media dedupe bucket): ${l} sessionKey=${o}`,"error");return}if(D_(m,l)){$(`dcgchat: sendMedia skipped (hasSentMediaKey): ${l} dedupeBucket=${m} sessionKey=${o}`);return}P_(m,l)}let h=l?.split(/[\\/]/).pop()||"";try{let m=c.botToken??gt()?.channels?.[be]?.botToken??"",v=l?await Xd(l,m,1):"";sn(c,Fne(c,e,v,h)),$(`dcgchat: sendMedia session=${o}, file=${h}`)}catch(m){$(`dcgchat: error sendMedia session=${o}: ${String(m)}`,"error")}}async function PN(e){let t=vu(e.to),r=e.to.indexOf("dcg-cron:")>=0||th(t)!==null,n=Bx(t),i=oc(n),o=xl(n)??i;r&&!Dn(n)&&no(n,`${Date.now()}`);let s=Dn(n),a=`${Date.now()}`,c=s||(r?a:o?.messageId||a),{sessionId:u}=Rm(n);if(!u)return $(`dcgchat: channel sendMedia to ${e.to} -> sessionId not found`,"error"),{messageId:c,chatId:wa(e.to,n||"")};$(`dcgchat: channel sendMedia to ${e.to}`);let l=e.mediaUrls??e.mediaUrl,p=_a(l);for(let f of p)await Jr({sessionKey:n||"",mediaUrl:f,...r?{messageId:c}:{}});return{messageId:c,chatId:wa(e.to,n||"")}}var Nne,zx=se(()=>{"use strict";Sx();lt();Ke();Er();$r();zt();Ux();Nne=13});var nh=x((rEe,DN)=>{var rh=z("stream"),Mne=z("util"),jne="function";function ji(){if(!(this instanceof ji))return new ji;rh.Duplex.call(this,{decodeStrings:!1,objectMode:!0}),this.buffer=Buffer.from("");let e=this;e.on("finish",function(){e.finished=!0,e.emit("chunk",!1)})}Mne.inherits(ji,rh.Duplex);ji.prototype._write=function(e,t,r){this.buffer=Buffer.concat([this.buffer,e]),this.cb=r,this.emit("chunk")};ji.prototype.stream=function(e,t){let r=rh.PassThrough(),n,i=this;function o(){if(typeof i.cb===jne){let a=i.cb;return i.cb=void 0,a()}}function s(){let a;if(i.buffer&&i.buffer.length){if(typeof e=="number")a=i.buffer.slice(0,e),i.buffer=i.buffer.slice(e),e-=a.length,n=n||!e;else{let c=i.buffer.indexOf(e);if(c!==-1)i.match=c,t&&(c=c+e.length),a=i.buffer.slice(0,c),i.buffer=i.buffer.slice(c),n=!0;else{let u=i.buffer.length-e.length;u<=0?o():(a=i.buffer.slice(0,u),i.buffer=i.buffer.slice(u))}}a&&r.write(a,function(){(i.buffer.length===0||e.length&&i.buffer.length<=e.length)&&o()})}if(n)i.removeListener("chunk",s),r.end();else if(i.finished){i.removeListener("chunk",s),i.emit("error",new Error("FILE_ENDED"));return}}return i.on("chunk",s),s(),r};ji.prototype.pull=function(e,t){if(e===0)return Promise.resolve("");if(!isNaN(e)&&this.buffer.length>e){let a=this.buffer.slice(0,e);return this.buffer=this.buffer.slice(e),Promise.resolve(a)}let r=Buffer.from(""),n=this,i=new rh.Transform;i._transform=function(a,c,u){r=Buffer.concat([r,a]),u()};let o,s;return new Promise(function(a,c){if(o=c,s=function(u){n.__emittedError=u,c(u)},n.finished)return c(new Error("FILE_ENDED"));n.once("error",s),n.stream(e,t).on("error",c).pipe(i).on("finish",function(){a(r)}).on("error",c)}).finally(function(){n.removeListener("error",o),n.removeListener("error",s)})};ji.prototype._read=function(){};DN.exports=ji});var MN=x((nEe,FN)=>{var NN=z("stream"),Lne=z("util");function bu(){if(!(this instanceof bu))return new bu;NN.Transform.call(this)}Lne.inherits(bu,NN.Transform);bu.prototype._transform=function(e,t,r){r()};FN.exports=bu});var ih=x((iEe,jN)=>{var Bne=z("stream");jN.exports=function(e){return new Promise(function(t,r){let n=[],i=Bne.Transform().on("finish",function(){t(Buffer.concat(n))}).on("error",r);i._transform=function(o,s,a){n.push(o),a()},e.on("error",r).pipe(i)})}});var xu=x((oEe,LN)=>{var Une=function(e,t,r){let n;switch(r){case 1:n=e.readUInt8(t);break;case 2:n=e.readUInt16LE(t);break;case 4:n=e.readUInt32LE(t);break;case 8:n=Number(e.readBigUInt64LE(t));break;default:throw new Error("Unsupported UInt LE size!")}return n},$ne=function(e,t){let r={},n=0;for(let[i,o]of t)e.length>=n+o?r[i]=Une(e,n,o):r[i]=null,n+=o;return r};LN.exports={parse:$ne}});var oh=x((sEe,UN)=>{var BN=xu();UN.exports=function(e,t){let r;for(;!r&&e&&e.length;){let n=BN.parse(e,[["signature",2],["partSize",2]]);if(n.signature===1){let i=[];t.uncompressedSize===4294967295&&i.push(["uncompressedSize",8]),t.compressedSize===4294967295&&i.push(["compressedSize",8]),t.offsetToLocalFileHeader===4294967295&&i.push(["offsetToLocalFileHeader",8]),r=BN.parse(e.slice(4),i)}else e=e.slice(n.partSize+4)}return r=r||{},t.compressedSize===4294967295&&(t.compressedSize=r.compressedSize),t.uncompressedSize===4294967295&&(t.uncompressedSize=r.uncompressedSize),t.offsetToLocalFileHeader===4294967295&&(t.offsetToLocalFileHeader=r.offsetToLocalFileHeader),r}});var sh=x((aEe,$N)=>{$N.exports=function(t,r){let n=t&31,i=t>>5&15,o=(t>>9&127)+1980,s=r?(r&31)*2:0,a=r?r>>5&63:0,c=r?r>>11:0;return new Date(Date.UTC(o,i-1,n,c,a,s))}});var ah=x((cEe,HN)=>{var zne=z("util"),Wne=z("zlib"),Wx=z("stream"),zN=nh(),Hne=MN(),Gne=ih(),Vne=oh(),Kne=sh(),Xne=Wx.pipeline,wu=xu(),WN=Buffer.alloc(4);WN.writeUInt32LE(101010256,0);function Yr(e){if(!(this instanceof Yr))return new Yr(e);let t=this;t._opts=e||{verbose:!1},zN.call(t,t._opts),t.on("finish",function(){t.emit("end"),t.emit("close")}),t._readRecord().catch(function(r){(!t.__emittedError||t.__emittedError!==r)&&t.emit("error",r)})}zne.inherits(Yr,zN);Yr.prototype._readRecord=function(){let e=this;return e.pull(4).then(function(t){if(t.length===0)return;let r=t.readUInt32LE(0);if(r===875721283)return e._readCrxHeader();if(r===67324752)return e._readFile();if(r===33639248)return e.reachedCD=!0,e._readCentralDirectoryFileHeader();if(r===101010256)return e._readEndOfCentralDirectoryRecord();if(e.reachedCD)return e.pull(WN,!0).then(function(){return e._readEndOfCentralDirectoryRecord()});e.emit("error",new Error("invalid signature: 0x"+r.toString(16)))}).then((function(t){if(t)return e._readRecord()}))};Yr.prototype._readCrxHeader=function(){let e=this;return e.pull(12).then(function(t){return e.crxHeader=wu.parse(t,[["version",4],["pubKeyLength",4],["signatureLength",4]]),e.pull(e.crxHeader.pubKeyLength+e.crxHeader.signatureLength)}).then(function(t){return e.crxHeader.publicKey=t.slice(0,e.crxHeader.pubKeyLength),e.crxHeader.signature=t.slice(e.crxHeader.pubKeyLength),e.emit("crx-header",e.crxHeader),!0})};Yr.prototype._readFile=function(){let e=this;return e.pull(26).then(function(t){let r=wu.parse(t,[["versionsNeededToExtract",2],["flags",2],["compressionMethod",2],["lastModifiedTime",2],["lastModifiedDate",2],["crc32",4],["compressedSize",4],["uncompressedSize",4],["fileNameLength",2],["extraFieldLength",2]]);return r.lastModifiedDateTime=Kne(r.lastModifiedDate,r.lastModifiedTime),e.crxHeader&&(r.crxHeader=e.crxHeader),e.pull(r.fileNameLength).then(function(n){let i=n.toString("utf8"),o=Wx.PassThrough(),s=!1;return o.autodrain=function(){s=!0;let a=o.pipe(Hne());return a.promise=function(){return new Promise(function(c,u){a.on("finish",c),a.on("error",u)})},a},o.buffer=function(){return Gne(o)},o.path=i,o.props={},o.props.path=i,o.props.pathBuffer=n,o.props.flags={isUnicode:(r.flags&2048)!=0},o.type=r.uncompressedSize===0&&/[/\\]$/.test(i)?"Directory":"File",e._opts.verbose&&(o.type==="Directory"?console.log(" creating:",i):o.type==="File"&&(r.compressionMethod===0?console.log(" extracting:",i):console.log(" inflating:",i))),e.pull(r.extraFieldLength).then(function(a){let c=Vne(a,r);o.vars=r,o.extra=c,e._opts.forceStream?e.push(o):(e.emit("entry",o),(e._readableState.pipesCount||e._readableState.pipes&&e._readableState.pipes.length)&&e.push(o)),e._opts.verbose&&console.log({filename:i,vars:r,extra:c});let u=!(r.flags&8)||r.compressedSize>0,l;o.__autodraining=s;let p=r.compressionMethod&&!s?Wne.createInflateRaw():Wx.PassThrough();return u?(o.size=r.uncompressedSize,l=r.compressedSize):(l=Buffer.alloc(4),l.writeUInt32LE(134695760,0)),new Promise(function(f,d){Xne(e.stream(l),p,o,function(h){return h?d(h):u?f(u):e._processDataDescriptor(o).then(f).catch(d)})})})})})};Yr.prototype._processDataDescriptor=function(e){return this.pull(16).then(function(r){let n=wu.parse(r,[["dataDescriptorSignature",4],["crc32",4],["compressedSize",4],["uncompressedSize",4]]);return e.size=n.uncompressedSize,!0})};Yr.prototype._readCentralDirectoryFileHeader=function(){let e=this;return e.pull(42).then(function(t){let r=wu.parse(t,[["versionMadeBy",2],["versionsNeededToExtract",2],["flags",2],["compressionMethod",2],["lastModifiedTime",2],["lastModifiedDate",2],["crc32",4],["compressedSize",4],["uncompressedSize",4],["fileNameLength",2],["extraFieldLength",2],["fileCommentLength",2],["diskNumber",2],["internalFileAttributes",2],["externalFileAttributes",4],["offsetToLocalFileHeader",4]]);return e.pull(r.fileNameLength).then(function(n){return r.fileName=n.toString("utf8"),e.pull(r.extraFieldLength)}).then(function(){return e.pull(r.fileCommentLength)}).then(function(){return!0})})};Yr.prototype._readEndOfCentralDirectoryRecord=function(){let e=this;return e.pull(18).then(function(t){let r=wu.parse(t,[["diskNumber",2],["diskStart",2],["numberOfRecordsOnDisk",2],["numberOfRecords",2],["sizeOfCentralDirectory",4],["offsetToStartOfCentralDirectory",4],["commentLength",2]]);return e.pull(r.commentLength).then(function(){e.end(),e.push(null)})})};Yr.prototype.promise=function(){let e=this;return new Promise(function(t,r){e.on("finish",t),e.on("error",r)})};HN.exports=Yr});var _u=x((uEe,Hx)=>{"use strict";typeof process>"u"||!process.version||process.version.indexOf("v0.")===0||process.version.indexOf("v1.")===0&&process.version.indexOf("v1.8.")!==0?Hx.exports={nextTick:Jne}:Hx.exports=process;function Jne(e,t,r,n){if(typeof e!="function")throw new TypeError('"callback" argument must be a function');var i=arguments.length,o,s;switch(i){case 0:case 1:return process.nextTick(e);case 2:return process.nextTick(function(){e.call(null,t)});case 3:return process.nextTick(function(){e.call(null,t,r)});case 4:return process.nextTick(function(){e.call(null,t,r,n)});default:for(o=new Array(i-1),s=0;s<o.length;)o[s++]=arguments[s];return process.nextTick(function(){e.apply(null,o)})}}});var VN=x((lEe,GN)=>{var Yne={}.toString;GN.exports=Array.isArray||function(e){return Yne.call(e)=="[object Array]"}});var Gx=x((pEe,KN)=>{KN.exports=z("stream")});var Su=x((Vx,JN)=>{var ch=z("buffer"),Jn=ch.Buffer;function XN(e,t){for(var r in e)t[r]=e[r]}Jn.from&&Jn.alloc&&Jn.allocUnsafe&&Jn.allocUnsafeSlow?JN.exports=ch:(XN(ch,Vx),Vx.Buffer=Sa);function Sa(e,t,r){return Jn(e,t,r)}XN(Jn,Sa);Sa.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return Jn(e,t,r)};Sa.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=Jn(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};Sa.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return Jn(e)};Sa.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return ch.SlowBuffer(e)}});var YN=x((fEe,Kx)=>{typeof Object.create=="function"?Kx.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:Kx.exports=function(t,r){if(r){t.super_=r;var n=function(){};n.prototype=r.prototype,t.prototype=new n,t.prototype.constructor=t}}});var Ea=x((dEe,Jx)=>{try{if(Xx=z("util"),typeof Xx.inherits!="function")throw"";Jx.exports=Xx.inherits}catch{Jx.exports=YN()}var Xx});var ZN=x((hEe,Yx)=>{"use strict";function Qne(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var QN=Su().Buffer,Eu=z("util");function Zne(e,t,r){e.copy(t,r)}Yx.exports=(function(){function e(){Qne(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(r){var n={data:r,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function(r){var n={data:r,next:this.head};this.length===0&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function(){if(this.length!==0){var r=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,r}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(r){if(this.length===0)return"";for(var n=this.head,i=""+n.data;n=n.next;)i+=r+n.data;return i},e.prototype.concat=function(r){if(this.length===0)return QN.alloc(0);for(var n=QN.allocUnsafe(r>>>0),i=this.head,o=0;i;)Zne(i.data,n,o),o+=i.data.length,i=i.next;return n},e})();Eu&&Eu.inspect&&Eu.inspect.custom&&(Yx.exports.prototype[Eu.inspect.custom]=function(){var e=Eu.inspect({length:this.length});return this.constructor.name+" "+e})});var Qx=x((mEe,e6)=>{"use strict";var uh=_u();function eie(e,t){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,uh.nextTick(lh,this,e)):uh.nextTick(lh,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(o){!t&&o?r._writableState?r._writableState.errorEmitted||(r._writableState.errorEmitted=!0,uh.nextTick(lh,r,o)):uh.nextTick(lh,r,o):t&&t(o)}),this)}function tie(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function lh(e,t){e.emit("error",t)}e6.exports={destroy:eie,undestroy:tie}});var r6=x((gEe,t6)=>{t6.exports=z("util").deprecate});var e0=x((yEe,l6)=>{"use strict";var Go=_u();l6.exports=_t;function i6(e){var t=this;this.next=null,this.entry=null,this.finish=function(){bie(t,e)}}var rie=!process.browser&&["v0.10","v0.9."].indexOf(process.version.slice(0,5))>-1?setImmediate:Go.nextTick,ka;_t.WritableState=Tu;var o6=Object.create(Ao());o6.inherits=Ea();var nie={deprecate:r6()},s6=Gx(),fh=Su().Buffer,iie=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function oie(e){return fh.from(e)}function sie(e){return fh.isBuffer(e)||e instanceof iie}var a6=Qx();o6.inherits(_t,s6);function aie(){}function Tu(e,t){ka=ka||Vo(),e=e||{};var r=t instanceof ka;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,i=e.writableHighWaterMark,o=this.objectMode?16:16*1024;n||n===0?this.highWaterMark=n:r&&(i||i===0)?this.highWaterMark=i:this.highWaterMark=o,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=e.decodeStrings===!1;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(a){hie(t,a)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new i6(this)}Tu.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};(function(){try{Object.defineProperty(Tu.prototype,"buffer",{get:nie.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var ph;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(ph=Function.prototype[Symbol.hasInstance],Object.defineProperty(_t,Symbol.hasInstance,{value:function(e){return ph.call(this,e)?!0:this!==_t?!1:e&&e._writableState instanceof Tu}})):ph=function(e){return e instanceof this};function _t(e){if(ka=ka||Vo(),!ph.call(_t,this)&&!(this instanceof ka))return new _t(e);this._writableState=new Tu(e,this),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev),typeof e.destroy=="function"&&(this._destroy=e.destroy),typeof e.final=="function"&&(this._final=e.final)),s6.call(this)}_t.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function cie(e,t){var r=new Error("write after end");e.emit("error",r),Go.nextTick(t,r)}function uie(e,t,r,n){var i=!0,o=!1;return r===null?o=new TypeError("May not write null values to stream"):typeof r!="string"&&r!==void 0&&!t.objectMode&&(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),Go.nextTick(n,o),i=!1),i}_t.prototype.write=function(e,t,r){var n=this._writableState,i=!1,o=!n.objectMode&&sie(e);return o&&!fh.isBuffer(e)&&(e=oie(e)),typeof t=="function"&&(r=t,t=null),o?t="buffer":t||(t=n.defaultEncoding),typeof r!="function"&&(r=aie),n.ended?cie(this,r):(o||uie(this,n,e,r))&&(n.pendingcb++,i=pie(this,n,o,e,t,r)),i};_t.prototype.cork=function(){var e=this._writableState;e.corked++};_t.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&c6(this,e))};_t.prototype.setDefaultEncoding=function(t){if(typeof t=="string"&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this};function lie(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=fh.from(t,r)),t}Object.defineProperty(_t.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function pie(e,t,r,n,i,o){if(!r){var s=lie(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var c=t.length<t.highWaterMark;if(c||(t.needDrain=!0),t.writing||t.corked){var u=t.lastBufferedRequest;t.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},u?u.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else Zx(e,t,!1,a,n,i,o);return c}function Zx(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function fie(e,t,r,n,i){--t.pendingcb,r?(Go.nextTick(i,n),Go.nextTick(ku,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),ku(e,t))}function die(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function hie(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(die(r),t)fie(e,r,n,t,i);else{var o=u6(r);!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&c6(e,r),n?rie(n6,e,r,o,i):n6(e,r,o,i)}}function n6(e,t,r,n){r||mie(e,t),t.pendingcb--,n(),ku(e,t)}function mie(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function c6(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,Zx(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new i6(t),t.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,u=r.encoding,l=r.callback,p=t.objectMode?1:c.length;if(Zx(e,t,!1,p,c,u,l),r=r.next,t.bufferedRequestCount--,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}_t.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))};_t.prototype._writev=null;_t.prototype.end=function(e,t,r){var n=this._writableState;typeof e=="function"?(r=e,e=null,t=null):typeof t=="function"&&(r=t,t=null),e!=null&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||vie(this,n,r)};function u6(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function gie(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),ku(e,t)})}function yie(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"?(t.pendingcb++,t.finalCalled=!0,Go.nextTick(gie,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function ku(e,t){var r=u6(t);return r&&(yie(e,t),t.pendingcb===0&&(t.finished=!0,e.emit("finish"))),r}function vie(e,t,r){t.ending=!0,ku(e,t),r&&(t.finished?Go.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function bie(e,t,r){var n=e.entry;for(e.entry=null;n;){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree.next=e}Object.defineProperty(_t.prototype,"destroyed",{get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}});_t.prototype.destroy=a6.destroy;_t.prototype._undestroy=a6.undestroy;_t.prototype._destroy=function(e,t){this.end(),t(e)}});var Vo=x((vEe,h6)=>{"use strict";var p6=_u(),xie=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};h6.exports=Yn;var f6=Object.create(Ao());f6.inherits=Ea();var d6=n0(),r0=e0();f6.inherits(Yn,d6);for(t0=xie(r0.prototype),dh=0;dh<t0.length;dh++)hh=t0[dh],Yn.prototype[hh]||(Yn.prototype[hh]=r0.prototype[hh]);var t0,hh,dh;function Yn(e){if(!(this instanceof Yn))return new Yn(e);d6.call(this,e),r0.call(this,e),e&&e.readable===!1&&(this.readable=!1),e&&e.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",wie)}Object.defineProperty(Yn.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function wie(){this.allowHalfOpen||this._writableState.ended||p6.nextTick(_ie,this)}function _ie(e){e.end()}Object.defineProperty(Yn.prototype,"destroyed",{get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(e){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=e,this._writableState.destroyed=e)}});Yn.prototype._destroy=function(e,t){this.push(null),this.end(),p6.nextTick(t,e)}});var s0=x(g6=>{"use strict";var o0=Su().Buffer,m6=o0.isEncoding||function(e){switch(e=""+e,e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function Sie(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function Eie(e){var t=Sie(e);if(typeof t!="string"&&(o0.isEncoding===m6||!m6(e)))throw new Error("Unknown encoding: "+e);return t||e}g6.StringDecoder=Cu;function Cu(e){this.encoding=Eie(e);var t;switch(this.encoding){case"utf16le":this.text=Rie,this.end=Iie,t=4;break;case"utf8":this.fillLast=Cie,t=4;break;case"base64":this.text=qie,this.end=Pie,t=3;break;default:this.write=Die,this.end=Nie;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=o0.allocUnsafe(t)}Cu.prototype.write=function(e){if(e.length===0)return"";var t,r;if(this.lastNeed){if(t=this.fillLast(e),t===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""};Cu.prototype.end=Aie;Cu.prototype.text=Oie;Cu.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};function i0(e){return e<=127?0:e>>5===6?2:e>>4===14?3:e>>3===30?4:e>>6===2?-1:-2}function kie(e,t,r){var n=t.length-1;if(n<r)return 0;var i=i0(t[n]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--n<r||i===-2?0:(i=i0(t[n]),i>=0?(i>0&&(e.lastNeed=i-2),i):--n<r||i===-2?0:(i=i0(t[n]),i>=0?(i>0&&(i===2?i=0:e.lastNeed=i-3),i):0))}function Tie(e,t,r){if((t[0]&192)!==128)return e.lastNeed=0,"\uFFFD";if(e.lastNeed>1&&t.length>1){if((t[1]&192)!==128)return e.lastNeed=1,"\uFFFD";if(e.lastNeed>2&&t.length>2&&(t[2]&192)!==128)return e.lastNeed=2,"\uFFFD"}}function Cie(e){var t=this.lastTotal-this.lastNeed,r=Tie(this,e,t);if(r!==void 0)return r;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}function Oie(e,t){var r=kie(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)}function Aie(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"\uFFFD":t}function Rie(e,t){if((e.length-t)%2===0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function Iie(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function qie(e,t){var r=(e.length-t)%3;return r===0?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function Pie(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function Die(e){return e.toString(this.encoding)}function Nie(e){return e&&e.length?this.write(e):""}});var n0=x((wEe,O6)=>{"use strict";var Ca=_u();O6.exports=Xe;var Fie=VN(),Ou;Xe.ReadableState=S6;var xEe=z("events").EventEmitter,x6=function(e,t){return e.listeners(t).length},p0=Gx(),Au=Su().Buffer,Mie=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function jie(e){return Au.from(e)}function Lie(e){return Au.isBuffer(e)||e instanceof Mie}var w6=Object.create(Ao());w6.inherits=Ea();var a0=z("util"),Fe=void 0;a0&&a0.debuglog?Fe=a0.debuglog("stream"):Fe=function(){};var Bie=ZN(),_6=Qx(),Ta;w6.inherits(Xe,p0);var c0=["error","close","destroy","pause","resume"];function Uie(e,t,r){if(typeof e.prependListener=="function")return e.prependListener(t,r);!e._events||!e._events[t]?e.on(t,r):Fie(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]}function S6(e,t){Ou=Ou||Vo(),e=e||{};var r=t instanceof Ou;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var n=e.highWaterMark,i=e.readableHighWaterMark,o=this.objectMode?16:16*1024;n||n===0?this.highWaterMark=n:r&&(i||i===0)?this.highWaterMark=i:this.highWaterMark=o,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new Bie,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(Ta||(Ta=s0().StringDecoder),this.decoder=new Ta(e.encoding),this.encoding=e.encoding)}function Xe(e){if(Ou=Ou||Vo(),!(this instanceof Xe))return new Xe(e);this._readableState=new S6(e,this),this.readable=!0,e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy)),p0.call(this)}Object.defineProperty(Xe.prototype,"destroyed",{get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}});Xe.prototype.destroy=_6.destroy;Xe.prototype._undestroy=_6.undestroy;Xe.prototype._destroy=function(e,t){this.push(null),t(e)};Xe.prototype.push=function(e,t){var r=this._readableState,n;return r.objectMode?n=!0:typeof e=="string"&&(t=t||r.defaultEncoding,t!==r.encoding&&(e=Au.from(e,t),t=""),n=!0),E6(this,e,t,!1,n)};Xe.prototype.unshift=function(e){return E6(this,e,null,!0,!1)};function E6(e,t,r,n,i){var o=e._readableState;if(t===null)o.reading=!1,Hie(e,o);else{var s;i||(s=$ie(o,t)),s?e.emit("error",s):o.objectMode||t&&t.length>0?(typeof t!="string"&&!o.objectMode&&Object.getPrototypeOf(t)!==Au.prototype&&(t=jie(t)),n?o.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):u0(e,o,t,!0):o.ended?e.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!r?(t=o.decoder.write(t),o.objectMode||t.length!==0?u0(e,o,t,!1):k6(e,o)):u0(e,o,t,!1))):n||(o.reading=!1)}return zie(o)}function u0(e,t,r,n){t.flowing&&t.length===0&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&mh(e)),k6(e,t)}function $ie(e,t){var r;return!Lie(t)&&typeof t!="string"&&t!==void 0&&!e.objectMode&&(r=new TypeError("Invalid non-string/buffer chunk")),r}function zie(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}Xe.prototype.isPaused=function(){return this._readableState.flowing===!1};Xe.prototype.setEncoding=function(e){return Ta||(Ta=s0().StringDecoder),this._readableState.decoder=new Ta(e),this._readableState.encoding=e,this};var y6=8388608;function Wie(e){return e>=y6?e=y6:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function v6(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=Wie(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}Xe.prototype.read=function(e){Fe("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return Fe("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?l0(this):mh(this),null;if(e=v6(e,t),e===0&&t.ended)return t.length===0&&l0(this),null;var n=t.needReadable;Fe("need readable",n),(t.length===0||t.length-e<t.highWaterMark)&&(n=!0,Fe("length less than watermark",n)),t.ended||t.reading?(n=!1,Fe("reading or ended",n)):n&&(Fe("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=v6(r,t)));var i;return e>0?i=T6(e,t):i=null,i===null?(t.needReadable=!0,e=0):t.length-=e,t.length===0&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&l0(this)),i!==null&&this.emit("data",i),i};function Hie(e,t){if(!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,mh(e)}}function mh(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Fe("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ca.nextTick(b6,e):b6(e))}function b6(e){Fe("emit readable"),e.emit("readable"),f0(e)}function k6(e,t){t.readingMore||(t.readingMore=!0,Ca.nextTick(Gie,e,t))}function Gie(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(Fe("maybeReadMore read 0"),e.read(0),r!==t.length);)r=t.length;t.readingMore=!1}Xe.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))};Xe.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e);break}n.pipesCount+=1,Fe("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||t.end!==!1)&&e!==process.stdout&&e!==process.stderr,o=i?a:v;n.endEmitted?Ca.nextTick(o):r.once("end",o),e.on("unpipe",s);function s(E,S){Fe("onunpipe"),E===r&&S&&S.hasUnpiped===!1&&(S.hasUnpiped=!0,l())}function a(){Fe("onend"),e.end()}var c=Vie(r);e.on("drain",c);var u=!1;function l(){Fe("cleanup"),e.removeListener("close",h),e.removeListener("finish",m),e.removeListener("drain",c),e.removeListener("error",d),e.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",v),r.removeListener("data",f),u=!0,n.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&c()}var p=!1;r.on("data",f);function f(E){Fe("ondata"),p=!1;var S=e.write(E);S===!1&&!p&&((n.pipesCount===1&&n.pipes===e||n.pipesCount>1&&C6(n.pipes,e)!==-1)&&!u&&(Fe("false write response, pause",n.awaitDrain),n.awaitDrain++,p=!0),r.pause())}function d(E){Fe("onerror",E),v(),e.removeListener("error",d),x6(e,"error")===0&&e.emit("error",E)}Uie(e,"error",d);function h(){e.removeListener("finish",m),v()}e.once("close",h);function m(){Fe("onfinish"),e.removeListener("close",h),v()}e.once("finish",m);function v(){Fe("unpipe"),r.unpipe(e)}return e.emit("pipe",r),n.flowing||(Fe("pipe resume"),r.resume()),e};function Vie(e){return function(){var t=e._readableState;Fe("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&x6(e,"data")&&(t.flowing=!0,f0(e))}}Xe.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=C6(t.pipes,e);return s===-1?this:(t.pipes.splice(s,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r),this)};Xe.prototype.on=function(e,t){var r=p0.prototype.on.call(this,e,t);if(e==="data")this._readableState.flowing!==!1&&this.resume();else if(e==="readable"){var n=this._readableState;!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.emittedReadable=!1,n.reading?n.length&&mh(this):Ca.nextTick(Kie,this))}return r};Xe.prototype.addListener=Xe.prototype.on;function Kie(e){Fe("readable nexttick read 0"),e.read(0)}Xe.prototype.resume=function(){var e=this._readableState;return e.flowing||(Fe("resume"),e.flowing=!0,Xie(this,e)),this};function Xie(e,t){t.resumeScheduled||(t.resumeScheduled=!0,Ca.nextTick(Jie,e,t))}function Jie(e,t){t.reading||(Fe("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),f0(e),t.flowing&&!t.reading&&e.read(0)}Xe.prototype.pause=function(){return Fe("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(Fe("pause"),this._readableState.flowing=!1,this.emit("pause")),this};function f0(e){var t=e._readableState;for(Fe("flow",t.flowing);t.flowing&&e.read()!==null;);}Xe.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;e.on("end",function(){if(Fe("wrapped end"),r.decoder&&!r.ended){var s=r.decoder.end();s&&s.length&&t.push(s)}t.push(null)}),e.on("data",function(s){if(Fe("wrapped data"),r.decoder&&(s=r.decoder.write(s)),!(r.objectMode&&s==null)&&!(!r.objectMode&&(!s||!s.length))){var a=t.push(s);a||(n=!0,e.pause())}});for(var i in e)this[i]===void 0&&typeof e[i]=="function"&&(this[i]=(function(s){return function(){return e[s].apply(e,arguments)}})(i));for(var o=0;o<c0.length;o++)e.on(c0[o],this.emit.bind(this,c0[o]));return this._read=function(s){Fe("wrapped _read",s),n&&(n=!1,e.resume())},this};Object.defineProperty(Xe.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});Xe._fromList=T6;function T6(e,t){if(t.length===0)return null;var r;return t.objectMode?r=t.buffer.shift():!e||e>=t.length?(t.decoder?r=t.buffer.join(""):t.buffer.length===1?r=t.buffer.head.data:r=t.buffer.concat(t.length),t.buffer.clear()):r=Yie(e,t.buffer,t.decoder),r}function Yie(e,t,r){var n;return e<t.head.data.length?(n=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):e===t.head.data.length?n=t.shift():n=r?Qie(e,t):Zie(e,t),n}function Qie(e,t){var r=t.head,n=1,i=r.data;for(e-=i.length;r=r.next;){var o=r.data,s=e>o.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),e-=s,e===0){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}function Zie(e,t){var r=Au.allocUnsafe(e),n=t.head,i=1;for(n.data.copy(r),e-=n.data.length;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),e-=s,e===0){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}function l0(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ca.nextTick(eoe,t,e))}function eoe(e,t){!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function C6(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}});var d0=x((_Ee,I6)=>{"use strict";I6.exports=Qn;var gh=Vo(),R6=Object.create(Ao());R6.inherits=Ea();R6.inherits(Qn,gh);function toe(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,t!=null&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function Qn(e){if(!(this instanceof Qn))return new Qn(e);gh.call(this,e),this._transformState={afterTransform:toe.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",roe)}function roe(){var e=this;typeof this._flush=="function"?this._flush(function(t,r){A6(e,t,r)}):A6(this,null,null)}Qn.prototype.push=function(e,t){return this._transformState.needTransform=!1,gh.prototype.push.call(this,e,t)};Qn.prototype._transform=function(e,t,r){throw new Error("_transform() is not implemented")};Qn.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}};Qn.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};Qn.prototype._destroy=function(e,t){var r=this;gh.prototype._destroy.call(this,e,function(n){t(n),r.emit("close")})};function A6(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}});var N6=x((SEe,D6)=>{"use strict";D6.exports=Ru;var q6=d0(),P6=Object.create(Ao());P6.inherits=Ea();P6.inherits(Ru,q6);function Ru(e){if(!(this instanceof Ru))return new Ru(e);q6.call(this,e)}Ru.prototype._transform=function(e,t,r){r(null,e)}});var F6=x((Ut,yh)=>{var En=z("stream");process.env.READABLE_STREAM==="disable"&&En?(yh.exports=En,Ut=yh.exports=En.Readable,Ut.Readable=En.Readable,Ut.Writable=En.Writable,Ut.Duplex=En.Duplex,Ut.Transform=En.Transform,Ut.PassThrough=En.PassThrough,Ut.Stream=En):(Ut=yh.exports=n0(),Ut.Stream=En||Ut,Ut.Readable=Ut,Ut.Writable=e0(),Ut.Duplex=Vo(),Ut.Transform=d0(),Ut.PassThrough=N6())});var g0=x((EEe,m0)=>{"use strict";var h0=F6();function Oa(e,t,r){typeof r>"u"&&(r=t,t=e,e=null),h0.Duplex.call(this,e),typeof r.read!="function"&&(r=new h0.Readable(e).wrap(r)),this._writable=t,this._readable=r,this._waiting=!1;var n=this;t.once("finish",function(){n.end()}),this.once("finish",function(){t.end()}),r.on("readable",function(){n._waiting&&(n._waiting=!1,n._read())}),r.once("end",function(){n.push(null)}),(!e||typeof e.bubbleErrors>"u"||e.bubbleErrors)&&(t.on("error",function(i){n.emit("error",i)}),r.on("error",function(i){n.emit("error",i)}))}Oa.prototype=Object.create(h0.Duplex.prototype,{constructor:{value:Oa}});Oa.prototype._write=function(t,r,n){this._writable.write(t,r,n)};Oa.prototype._read=function(){for(var t,r=0;(t=this._readable.read())!==null;)this.push(t),r++;r===0&&(this._waiting=!0)};m0.exports=function(t,r,n){return new Oa(t,r,n)};m0.exports.DuplexWrapper=Oa});var j6=x((kEe,M6)=>{var y0=z("stream"),noe=ah(),ioe=g0(),ooe=ih();function soe(e,t){let r=y0.PassThrough({objectMode:!0}),n=y0.PassThrough(),i=y0.Transform({objectMode:!0}),o=e instanceof RegExp?e:e&&new RegExp(e),s;i._transform=function(c,u,l){if(s||o&&!o.exec(c.path))return c.autodrain(),l();s=!0,a.emit("entry",c),c.on("error",function(p){n.emit("error",p)}),c.pipe(n).on("error",function(p){l(p)}).on("finish",function(p){l(null,p)})},r.pipe(noe(t)).on("error",function(c){n.emit("error",c)}).pipe(i).on("error",Object).on("finish",function(){s?n.end():n.emit("error",new Error("PATTERN_NOT_FOUND"))});let a=ioe(r,n);return a.buffer=function(){return ooe(n)},a}M6.exports=soe});var Nt=x(v0=>{"use strict";v0.fromCallback=function(e){return Object.defineProperty(function(...t){if(typeof t[t.length-1]=="function")e.apply(this,t);else return new Promise((r,n)=>{t.push((i,o)=>i!=null?n(i):r(o)),e.apply(this,t)})},"name",{value:e.name})};v0.fromPromise=function(e){return Object.defineProperty(function(...t){let r=t[t.length-1];if(typeof r!="function")return e.apply(this,t);t.pop(),e.apply(this,t).then(n=>r(null,n),r)},"name",{value:e.name})}});var tr=x(Zn=>{"use strict";var L6=Nt().fromCallback,er=hi(),aoe=["access","appendFile","chmod","chown","close","copyFile","cp","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","glob","lchmod","lchown","lutimes","link","lstat","mkdir","mkdtemp","open","opendir","readdir","readFile","readlink","realpath","rename","rm","rmdir","stat","statfs","symlink","truncate","unlink","utimes","writeFile"].filter(e=>typeof er[e]=="function");Object.assign(Zn,er);aoe.forEach(e=>{Zn[e]=L6(er[e])});Zn.exists=function(e,t){return typeof t=="function"?er.exists(e,t):new Promise(r=>er.exists(e,r))};Zn.read=function(e,t,r,n,i,o){return typeof o=="function"?er.read(e,t,r,n,i,o):new Promise((s,a)=>{er.read(e,t,r,n,i,(c,u,l)=>{if(c)return a(c);s({bytesRead:u,buffer:l})})})};Zn.write=function(e,t,...r){return typeof r[r.length-1]=="function"?er.write(e,t,...r):new Promise((n,i)=>{er.write(e,t,...r,(o,s,a)=>{if(o)return i(o);n({bytesWritten:s,buffer:a})})})};Zn.readv=function(e,t,...r){return typeof r[r.length-1]=="function"?er.readv(e,t,...r):new Promise((n,i)=>{er.readv(e,t,...r,(o,s,a)=>{if(o)return i(o);n({bytesRead:s,buffers:a})})})};Zn.writev=function(e,t,...r){return typeof r[r.length-1]=="function"?er.writev(e,t,...r):new Promise((n,i)=>{er.writev(e,t,...r,(o,s,a)=>{if(o)return i(o);n({bytesWritten:s,buffers:a})})})};typeof er.realpath.native=="function"?Zn.realpath.native=L6(er.realpath.native):process.emitWarning("fs.realpath.native is not a function. Is fs being monkey-patched?","Warning","fs-extra-WARN0003")});var U6=x((OEe,B6)=>{"use strict";var coe=z("path");B6.exports.checkPath=function(t){if(process.platform==="win32"&&/[<>:"|?*]/.test(t.replace(coe.parse(t).root,""))){let n=new Error(`Path contains invalid characters: ${t}`);throw n.code="EINVAL",n}}});var H6=x((AEe,b0)=>{"use strict";var $6=tr(),{checkPath:z6}=U6(),W6=e=>{let t={mode:511};return typeof e=="number"?e:{...t,...e}.mode};b0.exports.makeDir=async(e,t)=>(z6(e),$6.mkdir(e,{mode:W6(t),recursive:!0}));b0.exports.makeDirSync=(e,t)=>(z6(e),$6.mkdirSync(e,{mode:W6(t),recursive:!0}))});var Qr=x((REe,G6)=>{"use strict";var uoe=Nt().fromPromise,{makeDir:loe,makeDirSync:x0}=H6(),w0=uoe(loe);G6.exports={mkdirs:w0,mkdirsSync:x0,mkdirp:w0,mkdirpSync:x0,ensureDir:w0,ensureDirSync:x0}});var Li=x((IEe,K6)=>{"use strict";var poe=Nt().fromPromise,V6=tr();function foe(e){return V6.access(e).then(()=>!0).catch(()=>!1)}K6.exports={pathExists:poe(foe),pathExistsSync:V6.existsSync}});var _0=x((qEe,X6)=>{"use strict";var Aa=tr(),doe=Nt().fromPromise;async function hoe(e,t,r){let n=await Aa.open(e,"r+"),i=null;try{await Aa.futimes(n,t,r)}finally{try{await Aa.close(n)}catch(o){i=o}}if(i)throw i}function moe(e,t,r){let n=Aa.openSync(e,"r+");return Aa.futimesSync(n,t,r),Aa.closeSync(n)}X6.exports={utimesMillis:doe(hoe),utimesMillisSync:moe}});var Ko=x((PEe,Z6)=>{"use strict";var Ra=tr(),Ft=z("path"),J6=Nt().fromPromise;function goe(e,t,r){let n=r.dereference?i=>Ra.stat(i,{bigint:!0}):i=>Ra.lstat(i,{bigint:!0});return Promise.all([n(e),n(t).catch(i=>{if(i.code==="ENOENT")return null;throw i})]).then(([i,o])=>({srcStat:i,destStat:o}))}function yoe(e,t,r){let n,i=r.dereference?s=>Ra.statSync(s,{bigint:!0}):s=>Ra.lstatSync(s,{bigint:!0}),o=i(e);try{n=i(t)}catch(s){if(s.code==="ENOENT")return{srcStat:o,destStat:null};throw s}return{srcStat:o,destStat:n}}async function voe(e,t,r,n){let{srcStat:i,destStat:o}=await goe(e,t,n);if(o){if(Iu(i,o)){let s=Ft.basename(e),a=Ft.basename(t);if(r==="move"&&s!==a&&s.toLowerCase()===a.toLowerCase())return{srcStat:i,destStat:o,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(i.isDirectory()&&!o.isDirectory())throw new Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`);if(!i.isDirectory()&&o.isDirectory())throw new Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`)}if(i.isDirectory()&&S0(e,t))throw new Error(vh(e,t,r));return{srcStat:i,destStat:o}}function boe(e,t,r,n){let{srcStat:i,destStat:o}=yoe(e,t,n);if(o){if(Iu(i,o)){let s=Ft.basename(e),a=Ft.basename(t);if(r==="move"&&s!==a&&s.toLowerCase()===a.toLowerCase())return{srcStat:i,destStat:o,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(i.isDirectory()&&!o.isDirectory())throw new Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`);if(!i.isDirectory()&&o.isDirectory())throw new Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`)}if(i.isDirectory()&&S0(e,t))throw new Error(vh(e,t,r));return{srcStat:i,destStat:o}}async function Y6(e,t,r,n){let i=Ft.resolve(Ft.dirname(e)),o=Ft.resolve(Ft.dirname(r));if(o===i||o===Ft.parse(o).root)return;let s;try{s=await Ra.stat(o,{bigint:!0})}catch(a){if(a.code==="ENOENT")return;throw a}if(Iu(t,s))throw new Error(vh(e,r,n));return Y6(e,t,o,n)}function Q6(e,t,r,n){let i=Ft.resolve(Ft.dirname(e)),o=Ft.resolve(Ft.dirname(r));if(o===i||o===Ft.parse(o).root)return;let s;try{s=Ra.statSync(o,{bigint:!0})}catch(a){if(a.code==="ENOENT")return;throw a}if(Iu(t,s))throw new Error(vh(e,r,n));return Q6(e,t,o,n)}function Iu(e,t){return t.ino!==void 0&&t.dev!==void 0&&t.ino===e.ino&&t.dev===e.dev}function S0(e,t){let r=Ft.resolve(e).split(Ft.sep).filter(i=>i),n=Ft.resolve(t).split(Ft.sep).filter(i=>i);return r.every((i,o)=>n[o]===i)}function vh(e,t,r){return`Cannot ${r} '${e}' to a subdirectory of itself, '${t}'.`}Z6.exports={checkPaths:J6(voe),checkPathsSync:boe,checkParentPaths:J6(Y6),checkParentPathsSync:Q6,isSrcSubdir:S0,areIdentical:Iu}});var tF=x((DEe,eF)=>{"use strict";async function xoe(e,t){let r=[];for await(let n of e)r.push(t(n).then(()=>null,i=>i??new Error("unknown error")));await Promise.all(r.map(n=>n.then(i=>{if(i!==null)throw i})))}eF.exports={asyncIteratorConcurrentProcess:xoe}});var sF=x((NEe,oF)=>{"use strict";var Gt=tr(),qu=z("path"),{mkdirs:woe}=Qr(),{pathExists:_oe}=Li(),{utimesMillis:Soe}=_0(),Pu=Ko(),{asyncIteratorConcurrentProcess:Eoe}=tF();async function koe(e,t,r={}){typeof r=="function"&&(r={filter:r}),r.clobber="clobber"in r?!!r.clobber:!0,r.overwrite="overwrite"in r?!!r.overwrite:r.clobber,r.preserveTimestamps&&process.arch==="ia32"&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
|
|
104
105
|
|
|
105
106
|
see https://github.com/jprichardson/node-fs-extra/issues/269`,"Warning","fs-extra-WARN0001");let{srcStat:n,destStat:i}=await Pu.checkPaths(e,t,"copy",r);if(await Pu.checkParentPaths(e,n,t,"copy"),!await nF(e,t,r))return;let s=qu.dirname(t);await _oe(s)||await woe(s),await iF(i,e,t,r)}async function nF(e,t,r){return r.filter?r.filter(e,t):!0}async function iF(e,t,r,n){let o=await(n.dereference?Gt.stat:Gt.lstat)(t);if(o.isDirectory())return Aoe(o,e,t,r,n);if(o.isFile()||o.isCharacterDevice()||o.isBlockDevice())return Toe(o,e,t,r,n);if(o.isSymbolicLink())return Roe(e,t,r,n);throw o.isSocket()?new Error(`Cannot copy a socket file: ${t}`):o.isFIFO()?new Error(`Cannot copy a FIFO pipe: ${t}`):new Error(`Unknown file: ${t}`)}async function Toe(e,t,r,n,i){if(!t)return rF(e,r,n,i);if(i.overwrite)return await Gt.unlink(n),rF(e,r,n,i);if(i.errorOnExist)throw new Error(`'${n}' already exists`)}async function rF(e,t,r,n){if(await Gt.copyFile(t,r),n.preserveTimestamps){Coe(e.mode)&&await Ooe(r,e.mode);let i=await Gt.stat(t);await Soe(r,i.atime,i.mtime)}return Gt.chmod(r,e.mode)}function Coe(e){return(e&128)===0}function Ooe(e,t){return Gt.chmod(e,t|128)}async function Aoe(e,t,r,n,i){t||await Gt.mkdir(n),await Eoe(await Gt.opendir(r),async o=>{let s=qu.join(r,o.name),a=qu.join(n,o.name);if(await nF(s,a,i)){let{destStat:u}=await Pu.checkPaths(s,a,"copy",i);await iF(u,s,a,i)}}),t||await Gt.chmod(n,e.mode)}async function Roe(e,t,r,n){let i=await Gt.readlink(t);if(n.dereference&&(i=qu.resolve(process.cwd(),i)),!e)return Gt.symlink(i,r);let o=null;try{o=await Gt.readlink(r)}catch(s){if(s.code==="EINVAL"||s.code==="UNKNOWN")return Gt.symlink(i,r);throw s}if(n.dereference&&(o=qu.resolve(process.cwd(),o)),i!==o){if(Pu.isSrcSubdir(i,o))throw new Error(`Cannot copy '${i}' to a subdirectory of itself, '${o}'.`);if(Pu.isSrcSubdir(o,i))throw new Error(`Cannot overwrite '${o}' with '${i}'.`)}return await Gt.unlink(r),Gt.symlink(i,r)}oF.exports=koe});var pF=x((FEe,lF)=>{"use strict";var rr=hi(),Du=z("path"),Ioe=Qr().mkdirsSync,qoe=_0().utimesMillisSync,Nu=Ko();function Poe(e,t,r){typeof r=="function"&&(r={filter:r}),r=r||{},r.clobber="clobber"in r?!!r.clobber:!0,r.overwrite="overwrite"in r?!!r.overwrite:r.clobber,r.preserveTimestamps&&process.arch==="ia32"&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
|
|
106
107
|
|