cfpilot 0.30.0 → 0.30.2

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/assets/control.js CHANGED
@@ -4,7 +4,7 @@ const __sfx=(()=>{const __t=new TextDecoder(),__c=new Map();return b=>{let v=__c
4
4
  `))),i){let k=""+T+__sfx("IFRyb2phbg==");r.push(k),R.push(k),n.push([__sfx("ICAtIG5hbWU6IA==")+B(k)+"",__sfx("ICAgIHR5cGU6IHRyb2phbg=="),__sfx("ICAgIHBhc3N3b3JkOiA=")+B(e.config.trojanPassword)+"",__sfx("ICAgIHNlcnZlcjog")+h.ip+"",__sfx("ICAgIHBvcnQ6IA==")+S+"",__sfx("ICAgIG5ldHdvcms6IHdz"),__sfx("ICAgIHRsczogdHJ1ZQ=="),__sfx("ICAgIHNuaTog")+e.domain+"",__sfx("ICAgIGNsaWVudC1maW5nZXJwcmludDog")+e.config.clientFingerprint+"",...l()," ws-opts:",__sfx("ICAgICAgcGF0aDog")+B(e.config.trojanPath)+""," headers:",` Host: ${e.domain}`].join(`
5
5
  `))}}});t.push(__sfx("IyBDRlBpbG90IOiHquWKqOeUn+aIkOiuoumYhQ==")),t.push(__sfx("bWl4ZWQtcG9ydDogNzg5MA==")),t.push(__sfx("YWxsb3ctbGFuOiBmYWxzZQ==")),t.push(__sfx("bW9kZTogcnVsZQ==")),t.push(__sfx("bG9nLWxldmVsOiBpbmZv")),t.push(__sfx("dW5pZmllZC1kZWxheTogdHJ1ZQ==")),t.push(__sfx("dGNwLWNvbmN1cnJlbnQ6IHRydWU=")),t.push(""),t.push("dns:"),t.push(__sfx("ICBlbmFibGU6IHRydWU=")),t.push(__sfx("ICBpcHY2OiBmYWxzZQ==")),t.push(__sfx("ICBlbmhhbmNlZC1tb2RlOiBmYWtlLWlw")),t.push(__sfx("ICBmYWtlLWlwLXJhbmdlOiAxOTguMTguMC4xLzE2")),t.push(" default-nameserver:"),t.push(" - 223.5.5.5"),t.push(" - 119.29.29.29"),t.push(" nameserver:"),t.push(" - https://223.5.5.5/dns-query"),t.push(" - https://dns.alidns.com/dns-query"),t.push(" fallback:"),t.push(" - 8.8.4.4"),t.push(" - 1.1.1.1"),t.push(" fallback-filter:"),t.push(__sfx("ICAgIGdlb2lwOiB0cnVl")),t.push(__sfx("ICAgIGdlb2lwLWNvZGU6IENO")),t.push(""),u&&(t.push(" nameserver-policy:"),t.push(` ${B(d)}: ${c?B(c):"https://223.5.5.5/dns-query"}`),t.push(""));let f=Je(e.routeProfile??"",{mainGroup:Q,autoGroup:__sfx("6Ieq5Yqo6YCJ5oup")});if(t.push("proxies:"),n.length===0?t.push(" []"):t.push(...n),t.push(""),t.push(__sfx("cHJveHktZ3JvdXBzOg==")),t.push(__sfx("ICAtIG5hbWU6ICJDRlBpbG90Ig==")),t.push(__sfx("ICAgIHR5cGU6IHNlbGVjdA==")),t.push(" proxies:"),t.push(__sfx("ICAgICAgLSAi6Ieq5Yqo6YCJ5oupIg==")),t.push(__sfx("ICAgICAgLSAi5pWF6Zqc6L2s56e7Ig==")),o.v4.length>0&&t.push(__sfx("ICAgICAgLSAi5LyY6YCJSVB2NCI=")),o.v6.length>0&&t.push(__sfx("ICAgICAgLSAi5LyY6YCJSVB2NiI=")),r.length===0)t.push(" []");else for(let p of r)t.push(` - ${B(p)}`);if(r.length>0){t.push(""),t.push(__sfx("ICAtIG5hbWU6ICLoh6rliqjpgInmi6ki")),t.push(__sfx("ICAgIHR5cGU6IHVybC10ZXN0")),t.push(__sfx("ICAgIHVybDogImh0dHA6Ly93d3cuZ3N0YXRpYy5jb20vZ2VuZXJhdGVfMjA0Ig==")),t.push(__sfx("ICAgIGludGVydmFsOiAzMDA=")),t.push(__sfx("ICAgIHRvbGVyYW5jZTogNTA=")),t.push(" proxies:");for(let h of r)t.push(` - ${B(h)}`);t.push(""),t.push(__sfx("ICAtIG5hbWU6ICLmlYXpmpzovaznp7si")),t.push(__sfx("ICAgIHR5cGU6IGZhbGxiYWNr")),t.push(__sfx("ICAgIHVybDogImh0dHA6Ly93d3cuZ3N0YXRpYy5jb20vZ2VuZXJhdGVfMjA0Ig==")),t.push(__sfx("ICAgIGludGVydmFsOiAzMDA=")),t.push(" proxies:");for(let h of r)t.push(` - ${B(h)}`);let p=(h,g)=>{t.push(""),t.push(__sfx("ICAtIG5hbWU6IA==")+B(h)+""),t.push(__sfx("ICAgIHR5cGU6IHNlbGVjdA==")),t.push(" proxies:");for(let I of g)t.push(` - ${B(I)}`)};o.v4.length>0&&p(__sfx("5LyY6YCJSVB2NA=="),o.v4),o.v6.length>0&&p(__sfx("5LyY6YCJSVB2Ng=="),o.v6)}return f.groups.length>0&&(t.push(""),t.push(...f.groups)),t.push(""),t.push("rules:"),f.rules.length>0?(t.push(...f.rules),f.rules.some(p=>p.includes("MATCH,"))||t.push(` - MATCH,${Q}`)):t.push(..._t(Q)),t.push(""),t.join(`
6
6
  `)}function qr(e){let t=[],n=[],r=re(e.config.subVariants,e.config,an),o=r.some(c=>c===__sfx("dmxlc3Mtd3M=")),s=r.includes(__sfx("dHJvamFu")),a=e.config.ech,i=e.config.echHost.trim()||__sfx("Y2xvdWRmbGFyZS1lY2guY29t"),u=()=>a?{ech:{enabled:!0,query_server_name:i}}:{};for(let c of oe(e)){let l=[];c.entries.forEach((f,p)=>{let h=`${c.name} ${wt(f,"vless",p,"")}`;for(let g of ie(f,e)){let I=e.ports.length>1?`:${g}`:"",R=`${h}${I}`,S=""+R+__sfx("IFRyb2phbg==");o&&l.push(R),s&&l.push(S),o&&t.push({type:__sfx("dmxlc3M="),tag:R,server:f.ip,server_port:g,uuid:e.config.uuid,tls:{enabled:!0,server_name:e.domain,insecure:!1,utls:{enabled:!0,fingerprint:e.config.clientFingerprint},...u()},transport:{type:"ws",path:e.config.wsPath,headers:{Host:e.domain}}}),s&&t.push({type:__sfx("dHJvamFu"),tag:S,server:f.ip,server_port:g,password:e.config.trojanPassword,tls:{enabled:!0,server_name:e.domain,insecure:!1,utls:{enabled:!0,fingerprint:e.config.clientFingerprint},...u()},transport:{type:"ws",path:e.config.trojanPath,headers:{Host:e.domain}}})}}),l.length>0&&n.push({tag:c.name,members:l})}t.push({type:"direct",tag:"direct"});for(let c of n)t.push({type:"selector",tag:c.tag,outbounds:c.members,default:c.members[0]});return t.push({type:"selector",tag:__sfx("Q0ZQaWxvdA=="),outbounds:n.length>0?n.map(c=>c.tag):["direct"],default:n.length>0?n[0].tag:"direct"}),JSON.stringify({log:{level:"info",timestamp:!0},dns:{servers:[{tag:"dns-out",address:"https://1.1.1.1/dns-query"},{tag:"local",address:"local"}],rules:[{domain_suffix:sn,server:"local"}]},inbounds:[{type:"mixed",tag:"mixed-in",listen:__sfx("MTI3LjAuMC4x"),listen_port:2080}],outbounds:t,route:{rules:[{ip_is_private:!0,outbound:"direct"},{domain_suffix:sn,outbound:"direct"}],final:__sfx("Q0ZQaWxvdA=="),auto_detect_interface:!0}},null,2)}function _r(e){let t=[],n=re(e.config.subVariants,e.config);for(let r of oe(e))r.entries.forEach((o,s)=>{let a=wt(o,__sfx("dmxlc3M="),s,r.name);for(let i of ie(o,e)){let u=e.ports.length>1?`:${i}`:"",d=`${a}${u}`,c={...o,port:i};for(let l of n)l===__sfx("dmxlc3Mtd3M=")?t.push(on(c,e,"ws",`${d} WS`)):l===__sfx("dmxlc3MteGh0dHA=")?t.push(on(c,e,__sfx("eGh0dHA="),""+d+__sfx("IFhIVFRQ"))):t.push(Qr(c,e,""+d+__sfx("IFRyb2phbg==")))}});return ve(t.join(`
7
- `))}function dn(e,t){let n=se(t.config.subName);switch(e){case __sfx("Y2xhc2g="):return{body:Vr(t),contentType:"text/yaml; charset=utf-8",fileName:n};case"singbox":return{body:qr(t),contentType:"application/json; charset=utf-8",fileName:n};default:return{body:_r(t),contentType:"text/plain; charset=utf-8",fileName:n}}}var et,Tr,Nr,Ve,qe,_e,Or,Ir,kr,zr,Wr,Yr,tt,Zr,rn,an,Xr,sn,vt=F(()=>{"use strict";ze();Z();qt();$t();et=443;Tr=[__sfx("aXDlnLDlnYA="),__sfx("aXAg5Zyw5Z2A"),"ip",__sfx("5Zyw5Z2A"),__sfx("5pyN5Yqh5Zmo"),"server","host"],Nr=[__sfx("56uv5Y+j"),"port"],Ve=[__sfx("5LiL6L296YCf5bqm"),__sfx("6YCf5bqm"),"speed","download"],qe=[__sfx("5bmz5Z2H5bu26L+f"),__sfx("5bu26L+f"),"latency","delay",__sfx("5ZON5bqU5pe26Ze0"),"rtt"],_e=["colo",__sfx("5py65oi/"),__sfx("5pWw5o2u5Lit5b+D"),__sfx("5Zyw5Yy6"),"region"],Or=[__sfx("5Zu95a62"),"country",__sfx("5Zu95Yir")],Ir=[__sfx("5Z+O5biC"),"city"],kr=["tls",__sfx("5piv5ZCm5pSv5oyBdGxz"),__sfx("5pSv5oyBdGxz")];zr={official:__sfx("5a6Y5pa55LyY6YCJSVA="),domain:__sfx("5LyY6YCJ5Z+f5ZCN"),manual:__sfx("5LyY6YCJ"),api:__sfx("6L+c56iLQVBJ"),csv:__sfx("5rWL6YCfQ1NW")};Wr=12e4,Yr=32,tt=new Map,Zr="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36";rn=[__sfx("dmxlc3Mtd3M="),__sfx("dmxlc3MteGh0dHA="),__sfx("dHJvamFu")];an=[__sfx("dmxlc3Mtd3M="),__sfx("dHJvamFu")];Xr=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;sn=".cn,qq.com,tencent.com,weixin.qq.com,baidu.com,bdstatic.com,bilibili.com,hdslb.com,taobao.com,tmall.com,jd.com,aliyun.com,alicdn.com,alipay.com,163.com,126.net,zhihu.com,weibo.com,sina.com.cn,youku.com,iqiyi.com,douyin.com,xiaohongshu.com,mi.com,huawei.com,csdn.net,gitee.com,cnblogs.com".split(",")});function io(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function wn(e,t){let n=await crypto.subtle.importKey("raw",bn.encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),r=await crypto.subtle.sign("HMAC",n,bn.encode(t));return io(new Uint8Array(r))}async function Ut(e){let t=(await e.get(Lt))?.trim();if(t)return t;if(!(e instanceof X))return Ft();if(le)return le;let n=Date.now();if(Mt===0&&(Mt=n),n-Mt<=ao)return Dt||(Dt=Ft()),Dt;let r=Ft();return await e.put(Lt,r),Mt=0,Dt=r,le=r,r}async function Pn(e){let t=Ft();return e instanceof X?await e.put(Lt,t):await e.put(Lt,t),t}async function En(e,t={}){let n=t.ttlDays??0,r=Math.floor((t.now??Date.now())/1e3),o=n>0?r+Math.round(n*86400):0,s=Math.floor(Math.random()*36**8).toString(36).padStart(8,"0"),a=`${ce}.${o.toString(36)}.${s}`,i=(await wn(e,a)).slice(0,fe);return`${a}.${i}`}async function Ht(e,t,n=Date.now()){if(!e||!t)return{ok:!1,reason:"format"};let r=t.split(".");if(r.length!==4||r[0]!==ce)return{ok:!1,reason:"format"};let o=r[1],s=r[2],a=r[3];if(!o||!s||a.length!==fe)return{ok:!1,reason:"format"};let i=Number.parseInt(o,36);if(!Number.isFinite(i)||i<0)return{ok:!1,reason:"format"};let u=(await wn(e,`${ce}.${o}.${s}`)).slice(0,fe);return W(a,u)?i>0&&Math.floor(n/1e3)>=i?{ok:!1,reason:"expired",exp:i}:{ok:!0,exp:i}:{ok:!1,reason:"signature"}}var Lt,ce,fe,bn,Ft,le,Dt,Mt,ao,pe=F(()=>{"use strict";Et();Z();Lt="SUB_TOKEN_SECRET",ce="v1",fe=22,bn=new TextEncoder;Ft=()=>H(32);le=null,Dt=null,Mt=0,ao=9e4});function co(e){let t="";for(let n of e)t+=(n<16?"0":"")+n.toString(16);return t}function fo(e){if(!/^[0-9a-f]*$/.test(e)||e.length%2!==0)return null;let t=new Uint8Array(new ArrayBuffer(e.length/2));for(let n=0;n<t.length;n++)t[n]=Number.parseInt(e.slice(n*2,n*2+2),16);return t}async function Nn(e,t,n){let r=fo(t);if(!r)return null;let o=await crypto.subtle.importKey("raw",new TextEncoder().encode(e),"PBKDF2",!1,["deriveBits"]),s=await crypto.subtle.deriveBits({name:"PBKDF2",salt:r,iterations:n,hash:"SHA-256"},o,256);return co(new Uint8Array(s))}function On(e){if(e.startsWith(`${ge}$`)){let[r,o,s,a]=e.split("$");if(r!==ge||!s||!a)return null;let i=Number.parseInt(o??"",10);return!Number.isFinite(i)||i<1||i>1e6?null:{scheme:"pbkdf2",salt:s,iterations:i,expected:a}}let[t,n]=e.split(":");return!t||!n?null:{scheme:"sha256",salt:t,iterations:0,expected:n}}async function In(e,t){return e.scheme==="pbkdf2"?await Nn(t,e.salt,e.iterations):await Yt(`${e.salt}:${t}`)}async function me(e,t){let n=await Nn(e,t,An);return n?`${ge}$${An}$${t}$${n}`:`${t}:${await Yt(`${t}:${e}`)}`}async function po(e,t){let n=On(e);if(!n)return!1;let r=await In(n,t);return r?W(r,n.expected):!1}function Rn(e){return`/${e.trim().replace(/^\/+/,"")}`}async function kn(e,t,n){let r=await e.get(xt)??"",o=n&&n.trim()?Rn(n):"";o?r!==o&&(r=o,await e.put(xt,r)):r||(r=Rn(`${Fe}-${ke(6)}`),await e.put(xt,r));let s=await e.get(ft)??"",a=null,i=t&&t.trim()?t.trim():"";if(i){if(!s||!await po(s,i)){let d=H(8);s=await me(i,d),await e.put(ft,s)}await e.get(ot)&&await e.delete(ot)}else if(!s){let u=`cfp-${H(8)}`,d=H(8);s=await me(u,d),await e.put(ft,s),a=u,await e.put(ot,u)}return{panelPath:r,passwordHash:s,generatedPassword:a}}async function vn(e,t){let n=On(e.passwordHash);if(!n)return{ok:!1,legacy:!1};let r=await In(n,t);if(!r)return{ok:!1,legacy:!1};let o=W(r,n.expected);return{ok:o,legacy:o&&n.scheme==="sha256"}}async function Dn(e,t){let n=H(8);await e.put(ft,await me(t,n))}async function Mn(e){await e.get(ot)&&await e.delete(ot)}function Fn(e){let t=e.headers.get("Cookie")??"",n={};for(let r of t.split(";")){let o=r.indexOf("=");if(o<0)continue;let s=r.slice(0,o).trim(),a=r.slice(o+1).trim();s&&(n[s]=decodeURIComponent(a))}return n}async function Ln(e){let t=H(24);return await e.put(`${Ct}${t}`,JSON.stringify({ua:"",t:Date.now()}),Tn),t}async function he(e,t){let n=Fn(t)[jt];return n?!!await e.get(`${Ct}${n}`):!1}function Un(e,t=Tn){return`${jt}=${e}; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=${t}`}function Hn(){return`${jt}=; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=0`}async function Bn(e,t){let n=Fn(t)[jt];n&&await e.delete(`${Ct}${n}`)}async function jn(e){let t=H(20);return await e.put(`${St}${t}`,"1",lo),t}async function Gn(e,t){if(!t)return!1;let n=await e.get("SCANNER_TOKEN");return n&&W(n,t)?!0:await e.get(`${St}${t}`)?(await e.delete(`${St}${t}`),!0):!1}var jt,Tn,lo,An,ge,ye=F(()=>{"use strict";mt();Z();jt=__sfx("Y2ZwaWxvdF9zZXNz"),Tn=3600*24,lo=600,An=3e4,ge="pbkdf2"});function zn(e){return De(e)}async function be(e,t){if(G.config&&Date.now()-G.configAt<go)return G.config;let n=await He(e,t);return G.config=n,G.configAt=Date.now(),n}function Kn(){G.config=null,G.configAt=0}async function we(e,t){if(G.auth&&Date.now()-G.authAt<mo)return G.auth;let n=await kn(e,t.PANEL_PASSWORD,t.PANEL_PATH);return G.auth=n,G.authAt=Date.now(),n}function Pe(e){switch((e??"").toLowerCase()){case __sfx("Y2xhc2g="):case"mihomo":case"yaml":return __sfx("Y2xhc2g=");case"singbox":case"sing-box":case"json":return"singbox";case"v2ray":return"v2ray";case"base64":return"base64";default:return"base64"}}function Pt(e){let t=String(e??"").trim();if(!t)return t;t=t.replace(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//,""),t=t.replace(/[/?#].*$/,"");let n=t.lastIndexOf("@");if(n>=0&&(t=t.slice(n+1)),t.startsWith("[")){let r=t.indexOf("]");r>0&&(t=t.slice(1,r))}else{let r=t.indexOf(":");r>=0&&t.indexOf(":",r+1)<0&&(t=t.slice(0,r))}return t.trim()}function Wn(e){let t=(e??"").toLowerCase();return t?t.includes(__sfx("Y2xhc2g="))||t.includes("mihomo")||t.includes(__sfx("ZmxjbGFzaA=="))||t.includes(__sfx("Y2xhc2h4"))||t.includes("stash")?__sfx("Y2xhc2g="):t.includes("sing-box")||t.includes("singbox")?"singbox":t.includes("v2ray")||t.includes("v2rayng")||t.includes("shadowrocket")||t.includes("nekobox")||t.includes("surge")||t.includes("loon")||t.includes("quantumult")?"base64":null:null}var go,mo,G,Gt=F(()=>{"use strict";Et();mt();ye();go=15e3,mo=6e4,G={config:null,configAt:0,auth:null,authAt:0}});function Se(e){let t=[];if(e.split(/\r?\n/).forEach((s,a)=>{let i=s.trim();if(!i)return;let u=i.replace(/^["']|["']$/g,"").trim();!u||u.startsWith("#")||at(i)===null&&t.push(a+1)}),t.length===0)return"";let r=t.slice(0,3).map(s=>`\u7B2C ${s} \u884C`).join("\u3001"),o=t.length>3?` \u7B49 ${t.length} \u884C`:"";return __sfx("5omL5Yqo5oyH5a6aIElQIOaciSA=")+t.length+__sfx("IOihjOaXoOazleivhuWIq++8iA==")+r+""+o+")"}function Ee(e,t,n){if(!e){n.push({field:t,message:""+t+__sfx("IOS4jeiDveS4uuepug==")});return}if(!e.startsWith("/")){n.push({field:t,message:""+t+__sfx("IOW/hemhu+S7pSAvIOW8gOWktA==")});return}if(e.length>128){n.push({field:t,message:""+t+__sfx("IOi/h+mVv++8iOacgOWkmiAxMjgg5a2X56ym77yJ")});return}/[\s\u0000-\u001f]/.test(e)&&n.push({field:t,message:""+t+__sfx("IOS4jeiDveWMheWQq+epuuagvOaIluaOp+WItuWtl+espg==")})}function nt(e,t,n,r,o){if(!Number.isFinite(e)){o.push({field:t,message:""+t+__sfx("IOW/hemhu+aYr+aVsOWtlw==")});return}(e<n||e>r)&&o.push({field:t,message:""+t+__sfx("IOW/hemhu+WcqCA=")+n+" ~ "+r+__sfx("IOS5i+mXtO+8iOW9k+WJjSA=")+e+")"})}function zt(e,t,n){let r=e.split(/\r?\n|,/).map(o=>o.trim()).filter(Boolean);if(r.length>20){n.push({field:t,message:""+t+__sfx("IOacgOWkmiAyMCDmnaHvvIjlvZPliY0g")+r.length+")"});return}for(let o of r)if(!yo.test(o)){n.push({field:t,message:""+t+__sfx("IOmHjOacieaXoOazleivhuWIq+eahOadoeebru+8mg==")+o.slice(0,40)+""});return}}function Yn(e,t,n){let r=e.split(/\r?\n|,/).map(o=>o.trim()).filter(Boolean);if(r.length>10){n.push({field:t,message:""+t+__sfx("IOacgOWkmiAxMCDmnaHvvIjlvZPliY0g")+r.length+")"});return}for(let o of r)if(!/^https?:\/\/\S+$/i.test(o)){n.push({field:t,message:""+t+__sfx("IOW/hemhu+aYryBodHRwKHMpIOWcsOWdgO+8mg==")+o.slice(0,40)+""});return}}function bo(e,t,n){let r=Se(e);r&&n.push({field:t,message:r})}function Ce(e){let t=[],n=o=>Object.prototype.hasOwnProperty.call(e,o);n("wsPath")&&Ee(String(e.wsPath??""),"wsPath",t),n(__sfx("dHJvamFuUGF0aA=="))&&Ee(String(e.trojanPath??""),__sfx("dHJvamFuUGF0aA=="),t),n(__sfx("eGh0dHBQYXRo"))&&Ee(String(e.xhttpPath??""),__sfx("eGh0dHBQYXRo"),t);let r=["wsPath",__sfx("dHJvamFuUGF0aA=="),__sfx("eGh0dHBQYXRo")].filter(o=>n(o)).map(o=>`${o}=${String(e[o]??"")}`);if(r.length>=2){let o=r.map(s=>s.slice(s.indexOf("=")+1));new Set(o).size!==o.length&&t.push({field:"paths",message:__sfx("d3NQYXRoIC8gdHJvamFuUGF0aCAvIHhodHRwUGF0aCDkuI3og73ph43lpI0=")})}if(n("subDomain")){let o=String(e.subDomain??"").trim();o&&(!ho.test(o)||o.includes("/"))&&t.push({field:"subDomain",message:__sfx("c3ViRG9tYWluIOW/hemhu+aYr+WQiOazleS4u+acuuWQje+8iOS4jeWQq+WNj+iuruS4jui3r+W+hO+8iQ==")})}if(n(__sfx("cHJveHlJcA=="))&&zt(String(e.proxyIp??""),__sfx("cHJveHlJcA=="),t),n(__sfx("c29ja3M1"))&&zt(String(e.socks5??""),__sfx("c29ja3M1"),t),n("httpProxy")&&zt(String(e.httpProxy??""),"httpProxy",t),n("relayPool")&&zt(String(e.relayPool??""),"relayPool",t),n("officialCount")&&nt(Number(e.officialCount),"officialCount",1,200,t),n("domainCount")&&nt(Number(e.domainCount),"domainCount",1,200,t),n("maxNodes")&&nt(Number(e.maxNodes),"maxNodes",0,500,t),n("dls")&&nt(Number(e.dls),"dls",0,1e3,t),n("maxLatency")&&nt(Number(e.maxLatency),"maxLatency",0,1e4,t),n("dataBudgetMB")&&nt(Number(e.dataBudgetMB),"dataBudgetMB",0,102400,t),n("subTokenTtlDays")&&nt(Number(e.subTokenTtlDays),"subTokenTtlDays",0,3650,t),n("subPorts")){let o=String(e.subPorts??"").trim();if(o){let s=o.split(/[\n,;\s]+/).filter(Boolean);s.length>6?t.push({field:"subPorts",message:__sfx("c3ViUG9ydHMg5pyA5aSaIDYg5Liq56uv5Y+j")}):s.every(a=>/^\d{1,5}$/.test(a)&&Number(a)>=1&&Number(a)<=65535)||t.push({field:"subPorts",message:__sfx("c3ViUG9ydHMg6YeM5q+P5Liq56uv5Y+j6YO95b+F6aG75pivIDF+NjU1MzUg55qE5pWw5a2X")})}}if(n("subName")){let o=String(e.subName??"");o.length>40&&t.push({field:"subName",message:__sfx("c3ViTmFtZSDmnIDlpJogNDAg5a2X56ym")}),/[\u0000-\u001f]/.test(o)&&t.push({field:"subName",message:__sfx("c3ViTmFtZSDkuI3og73ljIXlkKvmjqfliLblrZfnrKY=")})}if(n("addApi")&&Yn(String(e.addApi??""),"addApi",t),n("addCsv")&&Yn(String(e.addCsv??""),"addCsv",t),n("add")&&bo(String(e.add??""),"add",t),n("uuid")){let o=String(e.uuid??"").trim();o&&!/^[0-9a-fA-F]{8}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{12}$/.test(o)&&t.push({field:"uuid",message:__sfx("dXVpZCDlv4XpobvmmK/moIflh4YgVVVJRO+8iDM2IOS9je+8jOWPr+W4pui/nuWtl+espu+8iQ==")})}if(n("poolCountries")){let o=String(e.poolCountries??"").trim();if(o){let s=o.split(/[\n,;\s]+/).filter(Boolean);s.length>30?t.push({field:"poolCountries",message:__sfx("cG9vbENvdW50cmllcyDmnIDlpJogMzAg5Liq5Zu95a62L+WcsOWMug==")}):s.every(a=>/^[A-Za-z]{2,3}$/.test(a))||t.push({field:"poolCountries",message:__sfx("cG9vbENvdW50cmllcyDlj6rog73mmK8gMn4zIOS9jeWtl+avjeS7o+eggQ==")})}}if(n("udpDnsEndpoint")){let o=String(e.udpDnsEndpoint??"").trim();o&&!/^https:\/\/\S+$/i.test(o)&&t.push({field:"udpDnsEndpoint",message:__sfx("dWRwRG5zRW5kcG9pbnQg5b+F6aG75pivIGh0dHBzIOWcsOWdgA==")})}return t}function xe(e){return e.length===0?"":e.length===1?e[0].message:"有 "+e.length+__sfx("IOmhuemFjee9ruS4jeWQiOazle+8mg==")+e.map(t=>t.message).join("\uFF1B")+""}var ho,yo,Zn=F(()=>{"use strict";vt();ho=/^(?=.{1,253}$)([A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)(\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/;yo=/^(?:(?:socks5|socks|socks5h|http|https):\/\/)?(?:[^\s@/]+@)?(?:\[[0-9a-fA-F:]+\]|[A-Za-z0-9._-]+)(?::\d{1,5})?$/});function Qn(e,t=Date.now()){let n={};for(let o of Jn){let s=e[o];s!==void 0&&(n[o]=s)}let r=wo.map(o=>({field:o.field,reason:o.reason}));for(let o of[__sfx("c29ja3M1"),"httpProxy"]){let s=String(e[o]??"");if(!s){n[o]="";continue}if(s.includes("@")){r.push({field:o,reason:__sfx("5ZCr55So5oi35ZCNL+WPo+S7pO+8jOmcgOaJi+W3pemHjeaWsOWhq+WGmQ==")});continue}n[o]=s}return{schemaVersion:1,exportedAt:new Date(t).toISOString(),config:n,omitted:r}}function Vn(e){let t=new Set([...Jn.map(String),__sfx("c29ja3M1"),"httpProxy"]),n={};for(let[r,o]of Object.entries(e))t.has(r)&&(n[r]=o);return n}function Xn(e){if(e==null)return"\uFF08\u7A7A\uFF09";if(typeof e=="string"){let t=e.replace(/\s+/g," ").trim();return t.length>60?`${t.slice(0,60)}\u2026`:t||"\uFF08\u7A7A\uFF09"}return String(e)}function qn(e,t){let n=[];for(let[r,o]of Object.entries(t)){let s=e[r];String(s)!==String(o)&&n.push({field:r,from:Xn(s),to:Xn(o)})}return n}var Jn,wo,_n=F(()=>{"use strict";Jn=["poolOfficial","officialCount","poolDomain","domainCount","poolManual","poolCountries","add","dls","maxLatency","maxNodes",__sfx("cHJveHlJcA=="),"relayPool","useBuiltinRelay","proxyMode","nat64","concurrentDial","dataBudgetMB","resolvePreferred","aggressiveRedial",__sfx("ZW5hYmxlVHJvamFu"),__sfx("ZW5hYmxlWGh0dHA="),"subProtocol","subTransport","subVariants","subName","subPorts","clientFingerprint","ech","echHost","echDns","tlsFragment","tlsFragmentSize","tlsFragmentDelay","subToken","subTokenTtlDays","unlockProbe","udpDns","udpDnsEndpoint"],wo=[{field:"uuid",reason:__sfx("5YWl56uZ5Yet5o2u")},{field:__sfx("dHJvamFuUGFzc3dvcmQ="),reason:__sfx("5YWl56uZ5Yet5o2u")},{field:"wsPath",reason:__sfx("5a6e5L6L5qCH6K+G77yI6K6i6ZiF6ZO+5o6l6YeM5Y+v6KeB77yM5a+85Ye65Y2z5pq06Zyy5YWl5Y+j77yJ")},{field:__sfx("dHJvamFuUGF0aA=="),reason:__sfx("5a6e5L6L5qCH6K+G")},{field:__sfx("eGh0dHBQYXRo"),reason:__sfx("5a6e5L6L5qCH6K+G")},{field:"subDomain",reason:__sfx("5a6e5L6L5qCH6K+G")},{field:"addApi",reason:__sfx("VVJMIOWPr+iDveWQq+engeaciSB0b2tlbg==")},{field:"addCsv",reason:__sfx("VVJMIOWPr+iDveWQq+engeaciSB0b2tlbg==")}]});function tr(){return new Response(JSON.stringify({build:Ae,version:Re,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var Ae,Re,$n,Te=F(()=>{"use strict";Ae="df07e58-d3daa12e",Re=__sfx("MC4zMC4w"),$n=__sfx("L19fY2ZwX3ZlcnNpb24=")});var rr={};cr(rr,{API_PREFIX:()=>Ne,getScannerToken:()=>Ao,handleApi:()=>Ro,pruneLoginFailures:()=>nr});function So(e){return e.headers.get("CF-Connecting-IP")??e.headers.get("x-forwarded-for")?.split(",")[0]?.trim()??"unknown"}function Co(e,t){let n=ut.get(e);return n?t>=n.resetAt?(ut.delete(e),!1):n.count>=Po:!1}function nr(e,t,n=Eo){if(!(e.size<n)){for(let[r,o]of e)t>=o.resetAt&&e.delete(r);for(;e.size>=n;){let r=e.keys().next().value;if(r===void 0)break;e.delete(r)}}}function xo(e,t){let n=ut.get(e);if(!n||t>=n.resetAt){nr(ut,t),ut.set(e,{count:1,resetAt:t+er});return}n.count+=1}function E(e,t=200,n={}){return new Response(JSON.stringify(e),{status:t,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store",...n}})}function x(e,t){return E({ok:!1,error:e},t)}async function Ao(e,t){let n=await e.get(Jt);if(n)return n;if(typeof t.SCANNER_TOKEN=="string"&&t.SCANNER_TOKEN)return t.SCANNER_TOKEN;let r=H(24);return await e.put(Jt,r),r}async function Ro(e,t,n){if(!t.pathname.startsWith(Ne))return null;let{store:r,env:o,config:s,auth:a}=n,i=t.pathname.slice(Ne.length)||"/",u=e.method.toUpperCase();if(i==="/session"&&u==="GET"){let c=await he(r,e);return E(c?{ok:!0,authenticated:c,panelPath:a.panelPath}:{ok:!0,authenticated:c})}if(i==="/login"&&u==="POST"){let c="";try{let g=await e.json();c=String(g.password??"")}catch{return x(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}if(!c)return x(__sfx("6K+36L6T5YWl5a+G56CB"),400);let l=So(e),f=Date.now();if(Co(l,f))return new Response(JSON.stringify({ok:!1,error:__sfx("5bCd6K+V6L+H5LqO6aKR57mB77yM6K+356iN5ZCO5YaN6K+V")}),{status:429,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store","Retry-After":String(Math.ceil(er/1e3))}});let p=await vn(a,c);if(!p.ok)return xo(l,f),x(__sfx("5a+G56CB6ZSZ6K+v"),401);ut.delete(l),p.legacy&&await Dn(r,c).catch(()=>{}),await Mn(r).catch(()=>{});let h=await Ln(r);return E({ok:!0},200,{"Set-Cookie":Un(h)})}if(i==="/logout"&&u==="POST")return await Bn(r,e),E({ok:!0},200,{"Set-Cookie":Hn()});if(i==="/preferred-ips"&&u==="POST"){let c=e.headers.get("Authorization")??"",l=c.startsWith("Bearer ")?c.slice(7).trim():c.trim();if(!await Gn(r,l))return x(__sfx("VG9rZW4g5qCh6aqM5aSx6LSl"),401);let p;try{p=await e.json()}catch{return x(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}let g=(Array.isArray(p.ips)?p.ips.map(A=>String(A)):[]).map(A=>A.trim()).filter(A=>A.length>0),I=p.mode==="append",R=A=>A.split("#")[0].trim().replace(/^\[([^\]]+)\]:(\d+)$/,"$1:$2"),S=await r.get(K),O,T=g.length;if(I){let A=(S??"").split(`
7
+ `))}function dn(e,t){let n=se(t.config.subName);switch(e){case __sfx("Y2xhc2g="):return{body:Vr(t),contentType:"text/yaml; charset=utf-8",fileName:n};case"singbox":return{body:qr(t),contentType:"application/json; charset=utf-8",fileName:n};default:return{body:_r(t),contentType:"text/plain; charset=utf-8",fileName:n}}}var et,Tr,Nr,Ve,qe,_e,Or,Ir,kr,zr,Wr,Yr,tt,Zr,rn,an,Xr,sn,vt=F(()=>{"use strict";ze();Z();qt();$t();et=443;Tr=[__sfx("aXDlnLDlnYA="),__sfx("aXAg5Zyw5Z2A"),"ip",__sfx("5Zyw5Z2A"),__sfx("5pyN5Yqh5Zmo"),"server","host"],Nr=[__sfx("56uv5Y+j"),"port"],Ve=[__sfx("5LiL6L296YCf5bqm"),__sfx("6YCf5bqm"),"speed","download"],qe=[__sfx("5bmz5Z2H5bu26L+f"),__sfx("5bu26L+f"),"latency","delay",__sfx("5ZON5bqU5pe26Ze0"),"rtt"],_e=["colo",__sfx("5py65oi/"),__sfx("5pWw5o2u5Lit5b+D"),__sfx("5Zyw5Yy6"),"region"],Or=[__sfx("5Zu95a62"),"country",__sfx("5Zu95Yir")],Ir=[__sfx("5Z+O5biC"),"city"],kr=["tls",__sfx("5piv5ZCm5pSv5oyBdGxz"),__sfx("5pSv5oyBdGxz")];zr={official:__sfx("5a6Y5pa55LyY6YCJSVA="),domain:__sfx("5LyY6YCJ5Z+f5ZCN"),manual:__sfx("5LyY6YCJ"),api:__sfx("6L+c56iLQVBJ"),csv:__sfx("5rWL6YCfQ1NW")};Wr=12e4,Yr=32,tt=new Map,Zr="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36";rn=[__sfx("dmxlc3Mtd3M="),__sfx("dmxlc3MteGh0dHA="),__sfx("dHJvamFu")];an=[__sfx("dmxlc3Mtd3M="),__sfx("dHJvamFu")];Xr=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;sn=".cn,qq.com,tencent.com,weixin.qq.com,baidu.com,bdstatic.com,bilibili.com,hdslb.com,taobao.com,tmall.com,jd.com,aliyun.com,alicdn.com,alipay.com,163.com,126.net,zhihu.com,weibo.com,sina.com.cn,youku.com,iqiyi.com,douyin.com,xiaohongshu.com,mi.com,huawei.com,csdn.net,gitee.com,cnblogs.com".split(",")});function io(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function wn(e,t){let n=await crypto.subtle.importKey("raw",bn.encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),r=await crypto.subtle.sign("HMAC",n,bn.encode(t));return io(new Uint8Array(r))}async function Ut(e){let t=(await e.get(Lt))?.trim();if(t)return t;if(!(e instanceof X))return Ft();if(le)return le;let n=Date.now();if(Mt===0&&(Mt=n),n-Mt<=ao)return Dt||(Dt=Ft()),Dt;let r=Ft();return await e.put(Lt,r),Mt=0,Dt=r,le=r,r}async function Pn(e){let t=Ft();return e instanceof X?await e.put(Lt,t):await e.put(Lt,t),t}async function En(e,t={}){let n=t.ttlDays??0,r=Math.floor((t.now??Date.now())/1e3),o=n>0?r+Math.round(n*86400):0,s=Math.floor(Math.random()*36**8).toString(36).padStart(8,"0"),a=`${ce}.${o.toString(36)}.${s}`,i=(await wn(e,a)).slice(0,fe);return`${a}.${i}`}async function Ht(e,t,n=Date.now()){if(!e||!t)return{ok:!1,reason:"format"};let r=t.split(".");if(r.length!==4||r[0]!==ce)return{ok:!1,reason:"format"};let o=r[1],s=r[2],a=r[3];if(!o||!s||a.length!==fe)return{ok:!1,reason:"format"};let i=Number.parseInt(o,36);if(!Number.isFinite(i)||i<0)return{ok:!1,reason:"format"};let u=(await wn(e,`${ce}.${o}.${s}`)).slice(0,fe);return W(a,u)?i>0&&Math.floor(n/1e3)>=i?{ok:!1,reason:"expired",exp:i}:{ok:!0,exp:i}:{ok:!1,reason:"signature"}}var Lt,ce,fe,bn,Ft,le,Dt,Mt,ao,pe=F(()=>{"use strict";Et();Z();Lt="SUB_TOKEN_SECRET",ce="v1",fe=22,bn=new TextEncoder;Ft=()=>H(32);le=null,Dt=null,Mt=0,ao=9e4});function co(e){let t="";for(let n of e)t+=(n<16?"0":"")+n.toString(16);return t}function fo(e){if(!/^[0-9a-f]*$/.test(e)||e.length%2!==0)return null;let t=new Uint8Array(new ArrayBuffer(e.length/2));for(let n=0;n<t.length;n++)t[n]=Number.parseInt(e.slice(n*2,n*2+2),16);return t}async function Nn(e,t,n){let r=fo(t);if(!r)return null;let o=await crypto.subtle.importKey("raw",new TextEncoder().encode(e),"PBKDF2",!1,["deriveBits"]),s=await crypto.subtle.deriveBits({name:"PBKDF2",salt:r,iterations:n,hash:"SHA-256"},o,256);return co(new Uint8Array(s))}function On(e){if(e.startsWith(`${ge}$`)){let[r,o,s,a]=e.split("$");if(r!==ge||!s||!a)return null;let i=Number.parseInt(o??"",10);return!Number.isFinite(i)||i<1||i>1e6?null:{scheme:"pbkdf2",salt:s,iterations:i,expected:a}}let[t,n]=e.split(":");return!t||!n?null:{scheme:"sha256",salt:t,iterations:0,expected:n}}async function In(e,t){return e.scheme==="pbkdf2"?await Nn(t,e.salt,e.iterations):await Yt(`${e.salt}:${t}`)}async function me(e,t){let n=await Nn(e,t,An);return n?`${ge}$${An}$${t}$${n}`:`${t}:${await Yt(`${t}:${e}`)}`}async function po(e,t){let n=On(e);if(!n)return!1;let r=await In(n,t);return r?W(r,n.expected):!1}function Rn(e){return`/${e.trim().replace(/^\/+/,"")}`}async function kn(e,t,n){let r=await e.get(xt)??"",o=n&&n.trim()?Rn(n):"";o?r!==o&&(r=o,await e.put(xt,r)):r||(r=Rn(`${Fe}-${ke(6)}`),await e.put(xt,r));let s=await e.get(ft)??"",a=null,i=t&&t.trim()?t.trim():"";if(i){if(!s||!await po(s,i)){let d=H(8);s=await me(i,d),await e.put(ft,s)}await e.get(ot)&&await e.delete(ot)}else if(!s){let u=`cfp-${H(8)}`,d=H(8);s=await me(u,d),await e.put(ft,s),a=u,await e.put(ot,u)}return{panelPath:r,passwordHash:s,generatedPassword:a}}async function vn(e,t){let n=On(e.passwordHash);if(!n)return{ok:!1,legacy:!1};let r=await In(n,t);if(!r)return{ok:!1,legacy:!1};let o=W(r,n.expected);return{ok:o,legacy:o&&n.scheme==="sha256"}}async function Dn(e,t){let n=H(8);await e.put(ft,await me(t,n))}async function Mn(e){await e.get(ot)&&await e.delete(ot)}function Fn(e){let t=e.headers.get("Cookie")??"",n={};for(let r of t.split(";")){let o=r.indexOf("=");if(o<0)continue;let s=r.slice(0,o).trim(),a=r.slice(o+1).trim();s&&(n[s]=decodeURIComponent(a))}return n}async function Ln(e){let t=H(24);return await e.put(`${Ct}${t}`,JSON.stringify({ua:"",t:Date.now()}),Tn),t}async function he(e,t){let n=Fn(t)[jt];return n?!!await e.get(`${Ct}${n}`):!1}function Un(e,t=Tn){return`${jt}=${e}; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=${t}`}function Hn(){return`${jt}=; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=0`}async function Bn(e,t){let n=Fn(t)[jt];n&&await e.delete(`${Ct}${n}`)}async function jn(e){let t=H(20);return await e.put(`${St}${t}`,"1",lo),t}async function Gn(e,t){if(!t)return!1;let n=await e.get("SCANNER_TOKEN");return n&&W(n,t)?!0:await e.get(`${St}${t}`)?(await e.delete(`${St}${t}`),!0):!1}var jt,Tn,lo,An,ge,ye=F(()=>{"use strict";mt();Z();jt=__sfx("Y2ZwaWxvdF9zZXNz"),Tn=3600*24,lo=600,An=3e4,ge="pbkdf2"});function zn(e){return De(e)}async function be(e,t){if(G.config&&Date.now()-G.configAt<go)return G.config;let n=await He(e,t);return G.config=n,G.configAt=Date.now(),n}function Kn(){G.config=null,G.configAt=0}async function we(e,t){if(G.auth&&Date.now()-G.authAt<mo)return G.auth;let n=await kn(e,t.PANEL_PASSWORD,t.PANEL_PATH);return G.auth=n,G.authAt=Date.now(),n}function Pe(e){switch((e??"").toLowerCase()){case __sfx("Y2xhc2g="):case"mihomo":case"yaml":return __sfx("Y2xhc2g=");case"singbox":case"sing-box":case"json":return"singbox";case"v2ray":return"v2ray";case"base64":return"base64";default:return"base64"}}function Pt(e){let t=String(e??"").trim();if(!t)return t;t=t.replace(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//,""),t=t.replace(/[/?#].*$/,"");let n=t.lastIndexOf("@");if(n>=0&&(t=t.slice(n+1)),t.startsWith("[")){let r=t.indexOf("]");r>0&&(t=t.slice(1,r))}else{let r=t.indexOf(":");r>=0&&t.indexOf(":",r+1)<0&&(t=t.slice(0,r))}return t.trim()}function Wn(e){let t=(e??"").toLowerCase();return t?t.includes(__sfx("Y2xhc2g="))||t.includes("mihomo")||t.includes(__sfx("ZmxjbGFzaA=="))||t.includes(__sfx("Y2xhc2h4"))||t.includes("stash")?__sfx("Y2xhc2g="):t.includes("sing-box")||t.includes("singbox")?"singbox":t.includes("v2ray")||t.includes("v2rayng")||t.includes("shadowrocket")||t.includes("nekobox")||t.includes("surge")||t.includes("loon")||t.includes("quantumult")?"base64":null:null}var go,mo,G,Gt=F(()=>{"use strict";Et();mt();ye();go=15e3,mo=6e4,G={config:null,configAt:0,auth:null,authAt:0}});function Se(e){let t=[];if(e.split(/\r?\n/).forEach((s,a)=>{let i=s.trim();if(!i)return;let u=i.replace(/^["']|["']$/g,"").trim();!u||u.startsWith("#")||at(i)===null&&t.push(a+1)}),t.length===0)return"";let r=t.slice(0,3).map(s=>`\u7B2C ${s} \u884C`).join("\u3001"),o=t.length>3?` \u7B49 ${t.length} \u884C`:"";return __sfx("5omL5Yqo5oyH5a6aIElQIOaciSA=")+t.length+__sfx("IOihjOaXoOazleivhuWIq++8iA==")+r+""+o+")"}function Ee(e,t,n){if(!e){n.push({field:t,message:""+t+__sfx("IOS4jeiDveS4uuepug==")});return}if(!e.startsWith("/")){n.push({field:t,message:""+t+__sfx("IOW/hemhu+S7pSAvIOW8gOWktA==")});return}if(e.length>128){n.push({field:t,message:""+t+__sfx("IOi/h+mVv++8iOacgOWkmiAxMjgg5a2X56ym77yJ")});return}/[\s\u0000-\u001f]/.test(e)&&n.push({field:t,message:""+t+__sfx("IOS4jeiDveWMheWQq+epuuagvOaIluaOp+WItuWtl+espg==")})}function nt(e,t,n,r,o){if(!Number.isFinite(e)){o.push({field:t,message:""+t+__sfx("IOW/hemhu+aYr+aVsOWtlw==")});return}(e<n||e>r)&&o.push({field:t,message:""+t+__sfx("IOW/hemhu+WcqCA=")+n+" ~ "+r+__sfx("IOS5i+mXtO+8iOW9k+WJjSA=")+e+")"})}function zt(e,t,n){let r=e.split(/\r?\n|,/).map(o=>o.trim()).filter(Boolean);if(r.length>20){n.push({field:t,message:""+t+__sfx("IOacgOWkmiAyMCDmnaHvvIjlvZPliY0g")+r.length+")"});return}for(let o of r)if(!yo.test(o)){n.push({field:t,message:""+t+__sfx("IOmHjOacieaXoOazleivhuWIq+eahOadoeebru+8mg==")+o.slice(0,40)+""});return}}function Yn(e,t,n){let r=e.split(/\r?\n|,/).map(o=>o.trim()).filter(Boolean);if(r.length>10){n.push({field:t,message:""+t+__sfx("IOacgOWkmiAxMCDmnaHvvIjlvZPliY0g")+r.length+")"});return}for(let o of r)if(!/^https?:\/\/\S+$/i.test(o)){n.push({field:t,message:""+t+__sfx("IOW/hemhu+aYryBodHRwKHMpIOWcsOWdgO+8mg==")+o.slice(0,40)+""});return}}function bo(e,t,n){let r=Se(e);r&&n.push({field:t,message:r})}function Ce(e){let t=[],n=o=>Object.prototype.hasOwnProperty.call(e,o);n("wsPath")&&Ee(String(e.wsPath??""),"wsPath",t),n(__sfx("dHJvamFuUGF0aA=="))&&Ee(String(e.trojanPath??""),__sfx("dHJvamFuUGF0aA=="),t),n(__sfx("eGh0dHBQYXRo"))&&Ee(String(e.xhttpPath??""),__sfx("eGh0dHBQYXRo"),t);let r=["wsPath",__sfx("dHJvamFuUGF0aA=="),__sfx("eGh0dHBQYXRo")].filter(o=>n(o)).map(o=>`${o}=${String(e[o]??"")}`);if(r.length>=2){let o=r.map(s=>s.slice(s.indexOf("=")+1));new Set(o).size!==o.length&&t.push({field:"paths",message:__sfx("d3NQYXRoIC8gdHJvamFuUGF0aCAvIHhodHRwUGF0aCDkuI3og73ph43lpI0=")})}if(n("subDomain")){let o=String(e.subDomain??"").trim();o&&(!ho.test(o)||o.includes("/"))&&t.push({field:"subDomain",message:__sfx("c3ViRG9tYWluIOW/hemhu+aYr+WQiOazleS4u+acuuWQje+8iOS4jeWQq+WNj+iuruS4jui3r+W+hO+8iQ==")})}if(n(__sfx("cHJveHlJcA=="))&&zt(String(e.proxyIp??""),__sfx("cHJveHlJcA=="),t),n(__sfx("c29ja3M1"))&&zt(String(e.socks5??""),__sfx("c29ja3M1"),t),n("httpProxy")&&zt(String(e.httpProxy??""),"httpProxy",t),n("relayPool")&&zt(String(e.relayPool??""),"relayPool",t),n("officialCount")&&nt(Number(e.officialCount),"officialCount",1,200,t),n("domainCount")&&nt(Number(e.domainCount),"domainCount",1,200,t),n("maxNodes")&&nt(Number(e.maxNodes),"maxNodes",0,500,t),n("dls")&&nt(Number(e.dls),"dls",0,1e3,t),n("maxLatency")&&nt(Number(e.maxLatency),"maxLatency",0,1e4,t),n("dataBudgetMB")&&nt(Number(e.dataBudgetMB),"dataBudgetMB",0,102400,t),n("subTokenTtlDays")&&nt(Number(e.subTokenTtlDays),"subTokenTtlDays",0,3650,t),n("subPorts")){let o=String(e.subPorts??"").trim();if(o){let s=o.split(/[\n,;\s]+/).filter(Boolean);s.length>6?t.push({field:"subPorts",message:__sfx("c3ViUG9ydHMg5pyA5aSaIDYg5Liq56uv5Y+j")}):s.every(a=>/^\d{1,5}$/.test(a)&&Number(a)>=1&&Number(a)<=65535)||t.push({field:"subPorts",message:__sfx("c3ViUG9ydHMg6YeM5q+P5Liq56uv5Y+j6YO95b+F6aG75pivIDF+NjU1MzUg55qE5pWw5a2X")})}}if(n("subName")){let o=String(e.subName??"");o.length>40&&t.push({field:"subName",message:__sfx("c3ViTmFtZSDmnIDlpJogNDAg5a2X56ym")}),/[\u0000-\u001f]/.test(o)&&t.push({field:"subName",message:__sfx("c3ViTmFtZSDkuI3og73ljIXlkKvmjqfliLblrZfnrKY=")})}if(n("addApi")&&Yn(String(e.addApi??""),"addApi",t),n("addCsv")&&Yn(String(e.addCsv??""),"addCsv",t),n("add")&&bo(String(e.add??""),"add",t),n("uuid")){let o=String(e.uuid??"").trim();o&&!/^[0-9a-fA-F]{8}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{12}$/.test(o)&&t.push({field:"uuid",message:__sfx("dXVpZCDlv4XpobvmmK/moIflh4YgVVVJRO+8iDM2IOS9je+8jOWPr+W4pui/nuWtl+espu+8iQ==")})}if(n("poolCountries")){let o=String(e.poolCountries??"").trim();if(o){let s=o.split(/[\n,;\s]+/).filter(Boolean);s.length>30?t.push({field:"poolCountries",message:__sfx("cG9vbENvdW50cmllcyDmnIDlpJogMzAg5Liq5Zu95a62L+WcsOWMug==")}):s.every(a=>/^[A-Za-z]{2,3}$/.test(a))||t.push({field:"poolCountries",message:__sfx("cG9vbENvdW50cmllcyDlj6rog73mmK8gMn4zIOS9jeWtl+avjeS7o+eggQ==")})}}if(n("udpDnsEndpoint")){let o=String(e.udpDnsEndpoint??"").trim();o&&!/^https:\/\/\S+$/i.test(o)&&t.push({field:"udpDnsEndpoint",message:__sfx("dWRwRG5zRW5kcG9pbnQg5b+F6aG75pivIGh0dHBzIOWcsOWdgA==")})}return t}function xe(e){return e.length===0?"":e.length===1?e[0].message:"有 "+e.length+__sfx("IOmhuemFjee9ruS4jeWQiOazle+8mg==")+e.map(t=>t.message).join("\uFF1B")+""}var ho,yo,Zn=F(()=>{"use strict";vt();ho=/^(?=.{1,253}$)([A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)(\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/;yo=/^(?:(?:socks5|socks|socks5h|http|https):\/\/)?(?:[^\s@/]+@)?(?:\[[0-9a-fA-F:]+\]|[A-Za-z0-9._-]+)(?::\d{1,5})?$/});function Qn(e,t=Date.now()){let n={};for(let o of Jn){let s=e[o];s!==void 0&&(n[o]=s)}let r=wo.map(o=>({field:o.field,reason:o.reason}));for(let o of[__sfx("c29ja3M1"),"httpProxy"]){let s=String(e[o]??"");if(!s){n[o]="";continue}if(s.includes("@")){r.push({field:o,reason:__sfx("5ZCr55So5oi35ZCNL+WPo+S7pO+8jOmcgOaJi+W3pemHjeaWsOWhq+WGmQ==")});continue}n[o]=s}return{schemaVersion:1,exportedAt:new Date(t).toISOString(),config:n,omitted:r}}function Vn(e){let t=new Set([...Jn.map(String),__sfx("c29ja3M1"),"httpProxy"]),n={};for(let[r,o]of Object.entries(e))t.has(r)&&(n[r]=o);return n}function Xn(e){if(e==null)return"\uFF08\u7A7A\uFF09";if(typeof e=="string"){let t=e.replace(/\s+/g," ").trim();return t.length>60?`${t.slice(0,60)}\u2026`:t||"\uFF08\u7A7A\uFF09"}return String(e)}function qn(e,t){let n=[];for(let[r,o]of Object.entries(t)){let s=e[r];String(s)!==String(o)&&n.push({field:r,from:Xn(s),to:Xn(o)})}return n}var Jn,wo,_n=F(()=>{"use strict";Jn=["poolOfficial","officialCount","poolDomain","domainCount","poolManual","poolCountries","add","dls","maxLatency","maxNodes",__sfx("cHJveHlJcA=="),"relayPool","useBuiltinRelay","proxyMode","nat64","concurrentDial","dataBudgetMB","resolvePreferred","aggressiveRedial",__sfx("ZW5hYmxlVHJvamFu"),__sfx("ZW5hYmxlWGh0dHA="),"subProtocol","subTransport","subVariants","subName","subPorts","clientFingerprint","ech","echHost","echDns","tlsFragment","tlsFragmentSize","tlsFragmentDelay","subToken","subTokenTtlDays","unlockProbe","udpDns","udpDnsEndpoint"],wo=[{field:"uuid",reason:__sfx("5YWl56uZ5Yet5o2u")},{field:__sfx("dHJvamFuUGFzc3dvcmQ="),reason:__sfx("5YWl56uZ5Yet5o2u")},{field:"wsPath",reason:__sfx("5a6e5L6L5qCH6K+G77yI6K6i6ZiF6ZO+5o6l6YeM5Y+v6KeB77yM5a+85Ye65Y2z5pq06Zyy5YWl5Y+j77yJ")},{field:__sfx("dHJvamFuUGF0aA=="),reason:__sfx("5a6e5L6L5qCH6K+G")},{field:__sfx("eGh0dHBQYXRo"),reason:__sfx("5a6e5L6L5qCH6K+G")},{field:"subDomain",reason:__sfx("5a6e5L6L5qCH6K+G")},{field:"addApi",reason:__sfx("VVJMIOWPr+iDveWQq+engeaciSB0b2tlbg==")},{field:"addCsv",reason:__sfx("VVJMIOWPr+iDveWQq+engeaciSB0b2tlbg==")}]});function tr(){return new Response(JSON.stringify({build:Ae,version:Re,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var Ae,Re,$n,Te=F(()=>{"use strict";Ae="013d2bc-050a325a",Re=__sfx("MC4zMC4y"),$n=__sfx("L19fY2ZwX3ZlcnNpb24=")});var rr={};cr(rr,{API_PREFIX:()=>Ne,getScannerToken:()=>Ao,handleApi:()=>Ro,pruneLoginFailures:()=>nr});function So(e){return e.headers.get("CF-Connecting-IP")??e.headers.get("x-forwarded-for")?.split(",")[0]?.trim()??"unknown"}function Co(e,t){let n=ut.get(e);return n?t>=n.resetAt?(ut.delete(e),!1):n.count>=Po:!1}function nr(e,t,n=Eo){if(!(e.size<n)){for(let[r,o]of e)t>=o.resetAt&&e.delete(r);for(;e.size>=n;){let r=e.keys().next().value;if(r===void 0)break;e.delete(r)}}}function xo(e,t){let n=ut.get(e);if(!n||t>=n.resetAt){nr(ut,t),ut.set(e,{count:1,resetAt:t+er});return}n.count+=1}function E(e,t=200,n={}){return new Response(JSON.stringify(e),{status:t,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store",...n}})}function x(e,t){return E({ok:!1,error:e},t)}async function Ao(e,t){let n=await e.get(Jt);if(n)return n;if(typeof t.SCANNER_TOKEN=="string"&&t.SCANNER_TOKEN)return t.SCANNER_TOKEN;let r=H(24);return await e.put(Jt,r),r}async function Ro(e,t,n){if(!t.pathname.startsWith(Ne))return null;let{store:r,env:o,config:s,auth:a}=n,i=t.pathname.slice(Ne.length)||"/",u=e.method.toUpperCase();if(i==="/session"&&u==="GET"){let c=await he(r,e);return E(c?{ok:!0,authenticated:c,panelPath:a.panelPath}:{ok:!0,authenticated:c})}if(i==="/login"&&u==="POST"){let c="";try{let g=await e.json();c=String(g.password??"")}catch{return x(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}if(!c)return x(__sfx("6K+36L6T5YWl5a+G56CB"),400);let l=So(e),f=Date.now();if(Co(l,f))return new Response(JSON.stringify({ok:!1,error:__sfx("5bCd6K+V6L+H5LqO6aKR57mB77yM6K+356iN5ZCO5YaN6K+V")}),{status:429,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store","Retry-After":String(Math.ceil(er/1e3))}});let p=await vn(a,c);if(!p.ok)return xo(l,f),x(__sfx("5a+G56CB6ZSZ6K+v"),401);ut.delete(l),p.legacy&&await Dn(r,c).catch(()=>{}),await Mn(r).catch(()=>{});let h=await Ln(r);return E({ok:!0},200,{"Set-Cookie":Un(h)})}if(i==="/logout"&&u==="POST")return await Bn(r,e),E({ok:!0},200,{"Set-Cookie":Hn()});if(i==="/preferred-ips"&&u==="POST"){let c=e.headers.get("Authorization")??"",l=c.startsWith("Bearer ")?c.slice(7).trim():c.trim();if(!await Gn(r,l))return x(__sfx("VG9rZW4g5qCh6aqM5aSx6LSl"),401);let p;try{p=await e.json()}catch{return x(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}let g=(Array.isArray(p.ips)?p.ips.map(A=>String(A)):[]).map(A=>A.trim()).filter(A=>A.length>0),I=p.mode==="append",R=A=>A.split("#")[0].trim().replace(/^\[([^\]]+)\]:(\d+)$/,"$1:$2"),S=await r.get(K),O,T=g.length;if(I){let A=(S??"").split(`
8
8
  `).map(L=>L.trim()).filter(L=>L.length>0),Y=new Set(A.map(R)),z=g.filter(L=>{let w=R(L);return Y.has(w)?!1:(Y.add(w),!0)});T=z.length,O=[...A,...z].join(`
9
9
  `)}else O=g.join(`
10
10
  `);S!==O&&await r.put(K,O);let b={};!I&&(s.add??"").trim()!==""&&(b.add=""),s.poolManual||(b.poolManual=!0);let m=!1;return Object.keys(b).length>0&&(await dt(r,pt(s,b)),n.onConfigChanged(),m=b.add!==void 0),E({ok:!0,mode:I?"append":"replace",count:g.length,added:T,clearedManual:m,enabledManual:b.poolManual===!0})}if(!await he(r,e))return x(__sfx("5pyq55m75b2V5oiW5Lya6K+d5bey6L+H5pyf"),401);if(i==="/status"&&u==="GET"){let c=await At(r),l=It(c),f=Pt(s.subDomain||o.DATA_HOST||t.hostname);return E({ok:!0,panelPath:a.panelPath,domain:t.hostname,nodeDomain:f,dataHost:o.DATA_HOST??"",colo:e.cf?.colo??"UNK",coloLabel:yt(e.cf?.colo??""),localIps:l.length,generatedPassword:a.generatedPassword,version:Ae,pkgVersion:Re,readAt:Date.now()})}if(i==="/config"&&u==="GET")return E({ok:!0,config:s});if(i==="/config"&&u==="PUT"){let c;try{c=await e.json()}catch{return x(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}if(!c.config||typeof c.config!="object")return x(__sfx("57y65bCR6YWN572u5a+56LGh"),400);let l=Ce(c.config);if(l.length>0)return x(xe(l),400);let f=pt(s,c.config);return await dt(r,f),n.onConfigChanged(),E({ok:!0,config:f})}if(i==="/config/export"&&u==="GET")return E({ok:!0,...Qn(s)});if(i==="/config/import"&&u==="POST"){let c;try{c=await e.json()}catch{return x(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}if(!c.config||typeof c.config!="object")return x(__sfx("57y65bCR6YWN572u5a+56LGh"),400);let l=Vn(c.config);if(Object.keys(l).length===0)return x(__sfx("5rKh5pyJ5Y+v5a+85YWl55qE5a2X5q6177yI56Gu6K6k5piv5pys6aG555uu5a+85Ye655qE6YWN572u5paH5Lu277yf77yJ"),400);let f=Ce(l);if(f.length>0)return x(xe(f),400);let p=qn(s,l);if(c.dryRun)return E({ok:!0,dryRun:!0,diff:p,count:p.length});if(p.length===0)return E({ok:!0,applied:0,diff:[],config:s});let h=pt(s,l);return await dt(r,h),n.onConfigChanged(),E({ok:!0,applied:p.length,diff:p,config:h})}if(i==="/ips"&&u==="GET"){let c=await At(r),l=It(c);return E({ok:!0,raw:c,count:l.length,entries:l})}if(i==="/ips"&&u==="DELETE")return await r.delete(K),E({ok:!0});if(i==="/ips"&&u==="PUT"){let c;try{c=await e.json()}catch{return x(__sfx("6K+35rGC5L2T6Kej5p6Q5aSx6LSl"),400)}if(typeof c.raw!="string")return x(__sfx("57y65bCRIHJhdyDlrZfmrrU="),400);let l=Se(c.raw);if(l)return x(l,400);let f=c.raw.split(/\r?\n/).map(p=>p.trim()).filter(p=>p.length>0).join(`
@@ -2,4 +2,4 @@ const __sfx=(()=>{const __t=new TextDecoder(),__c=new Map();return b=>{let v=__c
2
2
  `);await i.write(new TextEncoder().encode(f));let u=Date.now()+mt,c="";for(;;){let x=s.peek(),T=co(x);if(T>=0){c=new TextDecoder().decode(x.subarray(0,T)),s.skip(T+4);break}if(x.byteLength>8192)throw new Error(__sfx("SFRUUCDku6PnkIblk43lupTlpLTotoXov4cgODE5MiDlrZfoioI="));let p=u-Date.now();if(p<=0)throw new Error(__sfx("SFRUUCDku6PnkIbmj6HmiYvotoXml7bvvIg=")+mt+__sfx("bXMg5peg5ZON5bqU77yJ"));let R=null,E;try{E=await Promise.race([s.fill(),new Promise(k=>{R=setTimeout(()=>k("timeout"),p)})])}finally{R&&clearTimeout(R)}if(E==="timeout")throw new Error(__sfx("SFRUUCDku6PnkIbmj6HmiYvotoXml7bvvIg=")+mt+__sfx("bXMg5peg5ZON5bqU77yJ"));if(E===null)throw new Error(__sfx("SFRUUCDku6PnkIblk43lupTkuI3lrozmlbTvvIjov57mjqXooqvmj5DliY3lhbPpl63vvIk="))}let g=c.split(`\r
3
3
  `)[0]??"",y=/^HTTP\/1\.[01]\s+(\d{3})/.exec(g);if(!y)throw new Error(__sfx("SFRUUCDku6PnkIblk43lupTpnZ7ms5U="));if(y[1]!=="200")throw new re(__sfx("SFRUUCDku6PnkIYgQ09OTkVDVCDlpLHotKXvvJo=")+y[1]+"");return s.release()}finally{try{i.releaseLock()}catch{}}}var uo,mt,Cn=S(()=>{"use strict";K();we();Be();uo=[13,10,13,10];mt=6e3});function gt(e){if(e instanceof le||(e instanceof Error?e.message:String(e)).includes(kn))return!0;let n=e instanceof Error?e.cause:void 0;return n!==void 0&&n!==e&&gt(n)}function vn(e){let t=e.split(".");if(t.length!==4)return null;let n=0;for(let o of t){if(!/^\d{1,3}$/.test(o))return null;let r=Number(o);if(r>255)return null;n=n*256+r}return n>>>0}function He(e){let t=vn(e);if(t===null)return null;for(let[n,o,r,s]of fo){let i=vn(n);if(i===null)continue;let a=o===0?0:4294967295<<32-o>>>0;if((t&a)===(i&a))return{kind:r,reason:s}}return null}function ht(e){let t=e[6]??0,n=e[7]??0;return`${t>>>8}.${t&255}.${n>>>8}.${n&255}`}function po(e){let t=(e.split("%")[0]??"").toLowerCase();if(!t.includes(":"))return null;let n=ye(t);if(!n)return null;let o=n[0]===0&&n[1]===0&&n[2]===0&&n[3]===0&&n[4]===0;if(o&&n[5]===65535)return He(ht(n))??null;if(o&&n[5]===0&&n[6]===0&&(n[7]===0||n[7]===1))return n[7]===1?{kind:"loopback",reason:__sfx("546v5Zue5Zyw5Z2A")}:{kind:"unspecified",reason:__sfx("5pyq5oyH5a6a5Zyw5Z2A")};if(o&&n[5]===0)return He(ht(n))??null;if(n[0]===100&&n[1]===65435&&n[2]===0&&n[3]===0&&n[4]===0&&n[5]===0){let s=He(ht(n));if(s)return s}let r=n[0]??0;return(r&65024)===64512?{kind:"ula",reason:__sfx("SVB2NiDllK/kuIDmnKzlnLDlnLDlnYA=")}:(r&65472)===65152?{kind:"link-local",reason:__sfx("SVB2NiDpk77ot6/mnKzlnLDlnLDlnYA=")}:(r&65280)===65280?{kind:"multicast",reason:__sfx("SVB2NiDnu4Tmkq3lnLDlnYA=")}:null}function yt(e){let t=e.trim().toLowerCase().replace(/^\[|\]$/g,"");if(t==="")return null;if(t.includes(":"))return po(t);if(/^\d{1,3}(?:\.\d{1,3}){3}$/.test(t))return He(t);if(t==="localhost"||t.endsWith(".localhost"))return{kind:"loopback",reason:__sfx("546v5Zue5Li75py65ZCN")};for(let n of mo)if(t.endsWith(n))return{kind:"internal-name",reason:__sfx("5YaF572R5Z+f5ZCN5ZCO57yA")};return null}var kn,Dn,le,fo,mo,bt=S(()=>{"use strict";K();kn=__sfx("55uu5qCH5Zyw5Z2A6KKr562W55Wl5oum5oiq"),Dn={kind:"ipv6-direct-unsupported",reason:__sfx("55u06L+e5LiO5Y+N5Luj6YCa6YGT5LiN5pSv5oyBIElQdjYg55uu5qCH77yM5Y+v5pS555So6JC95Zyw5Luj55CG6L2s5Y+R")},le=class extends Error{kind;constructor(t,n){super(`${kn}\uFF1A${t}\uFF08${n.reason}\uFF09`),this.name="TargetBlockedError",this.kind=n.kind}};fo=[[__sfx("MC4wLjAuMA=="),8,"unspecified",__sfx("5pyq5oyH5a6a5Zyw5Z2A")],[__sfx("MTAuMC4wLjA="),8,"private",__sfx("56eB5pyJ572R5q61")],[__sfx("MTAwLjY0LjAuMA=="),10,"cgnat",__sfx("6L+Q6JCl5ZWG57qnIE5BVCDnvZHmrrU=")],[__sfx("MTI3LjAuMC4w"),8,"loopback",__sfx("546v5Zue5Zyw5Z2A")],[__sfx("MTY5LjI1NC4wLjA="),16,"link-local",__sfx("6ZO+6Lev5pys5ZywIC8g5LqR5YWD5pWw5o2u5Zyw5Z2A")],[__sfx("MTcyLjE2LjAuMA=="),12,"private",__sfx("56eB5pyJ572R5q61")],[__sfx("MTkyLjE2OC4wLjA="),16,"private",__sfx("56eB5pyJ572R5q61")],[__sfx("MjI0LjAuMC4w"),4,"multicast",__sfx("57uE5pKt5Zyw5Z2A")],[__sfx("MjQwLjAuMC4w"),4,"reserved",__sfx("5L+d55WZ5Zyw5Z2A")]];mo=[".local",".internal"]});function yo(e){return/^\d{1,3}(\.\d{1,3}){3}$/.test(e)?!0:e.includes(":")&&/^[0-9a-fA-F:.]+$/.test(e)}function wt(e,t){let n=e.trim(),o=/^\[([^\]]+)\](?::(\d+))?$/.exec(n);if(o)return{host:o[1],port:Number(o[2]??t)};if(n.includes(":")&&n.split(":").length>2)return{host:n,port:t};let r=n.lastIndexOf(":");if(r<0)return{host:n,port:t};let s=n.slice(0,r),i=Number(n.slice(r+1));return s?{host:s,port:Number.isInteger(i)&&i>0?i:t}:{host:n,port:t}}async function bo(e,t,n,o=Nn){try{let r=`${e}?name=${encodeURIComponent(t)}&type=${n}`,s=await fetch(r,{headers:{accept:"application/dns-json"},signal:AbortSignal.timeout(o)});if(!s.ok)return null;let i=await s.json();if(!i||i.Status!==0&&i.Status!==3)return null;if(!Array.isArray(i.Answer))return[];let a=n==="TXT"?16:n==="A"?1:28;return i.Answer.filter(l=>l.type===a).map(l=>String(l.data))}catch{return null}}async function Un(e,t,n={}){for(let o of ho){if(n.deadline!==void 0&&Date.now()>=n.deadline)break;let r=n.timeoutMs??Nn,s=n.deadline!==void 0?n.deadline-Date.now():Number[__sfx("UE9TSVRJVkVfSU5GSU5JVFk=")],i=Math.max(50,Math.min(r,s)),a=await bo(o,e,t,i);if(a!==null)return a}return[]}function wo(e,t){let n=[],o=String(e).replace(/^"|"$/g,"").replace(/\\010/g,",").replace(/\\n/g,",").trim();if(!o||o===On)return n;let r=o.split(/[,;\s]+/).filter(Boolean);if(r.length===0)return n;for(let s of r){let i=s.trim();if(!i)continue;let{host:a,port:l}=wt(i,t);if(!B(a)&&!te(a))return[];n.push({hostname:a,port:l})}return n}async function Fe(e,t,n={}){let o=e.trim();if(!o)return[];if(yo(o))return[{hostname:o,port:t}];let r=`${o}:${t}`,s=_.get(r);if(s&&Date.now()-s.at<In)return _.delete(r),_.set(r,s),s.ips;let i=[],[a,l]=await Promise.all([n.skipTxt?Promise.resolve([]):Un(o,"TXT",n),Un(o,"A",n)]);if(!n.skipTxt)for(let c of a){let d=wo(c,t);if(d.length>0){i.push(...d);break}if(String(c).replace(/^"|"$/g,"").replace(/\\010/g,",").trim()===On)break}if(i.length===0)for(let c of l)B(c)&&i.push({hostname:c,port:t});let f=[],u=new Set;for(let c of i){let d=`${c.hostname}:${c.port}`;u.has(d)||(u.add(d),f.push(c))}if(f.length>0){let c=Date.now();for(let[d,g]of _)c-g.at>=In&&_.delete(d);for(;_.size>=go;){let d=_.keys().next().value;if(d===void 0)break;_.delete(d)}_.set(r,{at:c,ips:f})}return f}var On,ho,Nn,In,go,_,Ge=S(()=>{"use strict";K();On=__sfx("QGVkZ2V0dW5uZWw="),ho=["https://cloudflare-dns.com/dns-query","https://dns.google/resolve","https://dns.alidns.com/resolve","https://doh.pub/dns-query"],Nn=4e3,In=300*1e3,go=1e3,_=new Map});var St={};ve(St,{[__sfx("QlVJTFRJTl9SRUxBWV9ET01BSU5T")]:()=>Ln,[__sfx("Q09MT19UT19DT1VOVFJZ")]:()=>Mn,[__sfx("UkVMQVlfQkFUQ0hfU0laRQ==")]:()=>Ke,[__sfx("UkVMQVlfRE9NQUlOX0xJTUlU")]:()=>Pt,clearRelayCache:()=>Eo,collectRelayEndpoints:()=>xe,coloToCountry:()=>xo,relayCacheSize:()=>Ao,resolveRelayEntry:()=>xt,selectRelayDomains:()=>Fn});function xo(e){let t=String(e??"").toUpperCase();return t?Mn[t]??(/^[A-Z]{2}$/.test(t)?t:"US"):"US"}function So(e){for(let[t,n]of J)e-n.at>=Hn&&J.delete(t);for(;J.size>=Po;){let t=J.keys().next().value;if(t===void 0)break;J.delete(t)}}async function xt(e,t=443,n=Bn,o={}){let r=e.trim();if(!r)return[];let s=`${r}:${t}:${n}`,i=J.get(s);if(i&&Date.now()-i.at<Hn)return i.ips;let a=r,l=t,f=(r.match(/:/g)??[]).length;if(f===1){let c=/^(.*):(\d{1,5})$/.exec(r);c&&(a=c[1],l=Number(c[2]))}else if(f>1&&r.startsWith("[")){let c=/^\[([^\]]+)\]:(\d{1,5})$/.exec(r);c&&(a=c[1],l=Number(c[2]))}let u=[];if(B(a)||te(a))u=[{ip:a,port:Number.isInteger(l)&&l>0?l:t,label:r}];else try{u=(await Fe(a,l,{skipTxt:o.skipTxt,deadline:o.deadline,timeoutMs:o.timeoutMs})).slice(0,n).map(d=>({ip:d.hostname,port:d.port,label:`${a} \u2192 ${d.hostname}`}))}catch{u=[]}if(u.length>0){let c=Date.now();So(c),J.set(s,{at:c,ips:u})}return u}function Fn(e=Pt,t=Ln){return t.slice(0,Math.max(0,e))}async function xe(e={}){let t=e.perDomain??Bn,n=[],o=new Set,r=d=>{for(let g of d){let y=`${g.ip}:${g.port}`;o.has(y)||(o.add(y),n.push(g))}},s=(e.userEntries??"").trim(),i=s?s.split(/[\n,;]+/).map(d=>d.trim()).filter(Boolean):[],a=e.domainLimit??Pt,l=e.useBuiltin!==!1?Fn(a):[],f=await Promise.all([...i.map(d=>xt(d,443,t,{deadline:e.deadline,timeoutMs:e.timeoutMs})),...l.map(d=>xt(d,443,t,{skipTxt:!0,deadline:e.deadline,timeoutMs:e.timeoutMs}))]);for(let d=0;d<i.length;d++)r(f[d]);let u=f.slice(i.length),c=u.reduce((d,g)=>Math.max(d,g.length),0);for(let d=0;d<c;d++)for(let g of u)d<g.length&&r([g[d]]);return n}function Eo(){J.clear()}function Ao(){return J.size}var Ln,Mn,Bn,Ke,Pt,Hn,Po,J,Pe=S(()=>{"use strict";K();Ge();Ln=[__sfx("MTkyLjE4LjEzNi4yNTU="),__sfx("MTI4LjEyMS4zMS4yNTI="),__sfx("MTI5LjE1OS4zNy4xMzY="),__sfx("MjMuMTQ0LjEyLjYz"),__sfx("MjE2LjM2Ljg2LjYy"),__sfx("NDUuMTMzLjExNy4xODU="),__sfx("MzguODQuMjAxLjIyOA=="),__sfx("MTA5LjEyMC4xNDIuMjE5"),__sfx("NDUuMTQwLjE2Ny40Mw=="),__sfx("NS4yNTMuMTg4LjEzOQ=="),__sfx("MjE2LjM2LjgyLjMx"),__sfx("MTY3LjI1My45Ni45MA=="),__sfx("MTk0Ljg3LjYyLjEzOQ=="),__sfx("MjMuMTQ0LjIwLjE4NA=="),__sfx("MTI4LjEyMS4zMS41OA=="),__sfx("MTA0LjIzOC4xNTQuNzc="),__sfx("MzguMjQ0LjE1MC4xMTM="),__sfx("MTU1LjI0OC4xODEuMTg5"),__sfx("MjE2LjM2LjgyLjE0MQ=="),__sfx("NjQuMTgxLjI1NS4yMTU="),__sfx("MzEuMjUuMjM5LjY2"),__sfx("NDUuNzYuMjQ2LjE5Mg=="),__sfx("MjMuOTUuMTEzLjYx"),__sfx("MTUxLjI0NC4yMDEuMjA3")],Mn={[__sfx("SEtH")]:"HK",[__sfx("U1lE")]:"AU",[__sfx("TUVM")]:"AU",[__sfx("Qk5F")]:"AU",[__sfx("UEVS")]:"AU",[__sfx("QURM")]:"AU",[__sfx("Q0JS")]:"AU",[__sfx("U0lO")]:"SG",[__sfx("TlJU")]:"JP",[__sfx("SE5E")]:"JP",[__sfx("S0lY")]:"JP",[__sfx("VFlP")]:"JP",[__sfx("T1NB")]:"JP",[__sfx("TkdP")]:"JP",[__sfx("Q1RT")]:"JP",[__sfx("RlVL")]:"JP",[__sfx("T0tB")]:"JP",[__sfx("SUNO")]:"KR",[__sfx("U0VM")]:"KR",[__sfx("UFVT")]:"KR",[__sfx("RlJB")]:"DE",[__sfx("TVVD")]:"DE",[__sfx("RFVT")]:"DE",[__sfx("QkVS")]:"DE",[__sfx("SEFN")]:"DE",[__sfx("U1RS")]:"DE",[__sfx("VklF")]:"DE",[__sfx("WlJI")]:"DE",[__sfx("Q0RH")]:"FR",[__sfx("TUFE")]:"ES",[__sfx("TVhQ")]:"IT",[__sfx("RkNP")]:"IT",[__sfx("UFJH")]:"CZ",[__sfx("V0FX")]:"PL",[__sfx("QVJO")]:"SE",[__sfx("QU1T")]:"NL",[__sfx("SEVM")]:"FI",[__sfx("TEhS")]:"GB",[__sfx("TEdX")]:"GB",[__sfx("TUFO")]:"GB",[__sfx("RURJ")]:"GB",[__sfx("TEFY")]:"US",[__sfx("U0pD")]:"US",[__sfx("U0ZP")]:"US",[__sfx("U0VB")]:"US",[__sfx("UERY")]:"US",[__sfx("U0FO")]:"US",[__sfx("TEFT")]:"US",[__sfx("UEhY")]:"US",[__sfx("U0xD")]:"US",[__sfx("REVO")]:"US",[__sfx("REZX")]:"US",[__sfx("SUFI")]:"US",[__sfx("QVVT")]:"US",[__sfx("T1JE")]:"US",[__sfx("TVNQ")]:"US",[__sfx("RFRX")]:"US",[__sfx("U1RM")]:"US",[__sfx("TUNJ")]:"US",[__sfx("QVRM")]:"US",[__sfx("TUlB")]:"US",[__sfx("TUNP")]:"US",[__sfx("Qk5B")]:"US",[__sfx("Q0xU")]:"US",[__sfx("SUFE")]:"US",[__sfx("Qk9T")]:"US",[__sfx("RVdS")]:"US",[__sfx("SkZL")]:"US",[__sfx("UEhM")]:"US",[__sfx("WVla")]:"CA",[__sfx("WVZS")]:"CA",[__sfx("WVVM")]:"CA",[__sfx("TUVY")]:"MX",[__sfx("R1JV")]:"BR",[__sfx("VFBF")]:"TW",[__sfx("S0hI")]:"TW",[__sfx("VFNB")]:"TW",[__sfx("Uk1R")]:"TW"};Bn=4,Ke=6,Pt=6,Hn=30*1e3,Po=256,J=new Map});function Et(e){let t=e.split(".");if(t.length!==4)return null;let n=0;for(let o of t){if(!/^\d{1,3}$/.test(o))return null;let r=Number(o);if(r>255)return null;n=n*256+r}return n>>>0}function Gn(e){return e.map(([t,n])=>{let o=Et(t)??0,r=n===0?0:4294967295<<32-n>>>0;return[(o&r)>>>0,r]})}function Kn(e){let t=Et(e);if(t===null)return!1;for(let[n,o]of Do)if((t&o)>>>0===n)return!0;return!1}function se(e){let t=Et(e);if(t===null)return!1;for(let[n,o]of ko)if((t&o)>>>0===n)return!0;return!1}function jn(e){let t=[],n=new Set,o=u=>{let c=`${u.source}|${u.host}|${u.port}`;n.has(c)||(n.add(c),t.push(u))};for(let u of e.proxies??[])u.kind==="direct"?o({source:"proxy",host:u.host,port:u.port,label:__sfx("UHJveHlJUCA=")+u.host+":"+u.port+"",via:{kind:"direct",host:u.host,port:u.port}}):o({source:"proxy",host:u.host,port:u.port,label:`${u.kind.toUpperCase()} ${u.host}:${u.port}`,via:{kind:u.kind,host:u.host,port:u.port,username:u.username,password:u.password,serverName:u.serverName}});let s=se(e.targetHost)||e.deprioritizeDirect===!0;o({source:"direct",host:e.targetHost,port:e.targetPort,label:__sfx("55u06L+eIA==")+e.targetHost+":"+e.targetPort+"",deprioritized:s});let i=e.optimizedIps??[],a=i.filter(u=>!se(u.ip)),l=i.filter(u=>se(u.ip));for(let u of a)o({source:"optimized",host:u.ip,port:u.port,label:__sfx("5LyY6YCJIA==")+u.ip+":"+u.port+""});for(let u of l)o({source:"optimized",host:u.ip,port:u.port,label:__sfx("5LyY6YCJIA==")+u.ip+":"+u.port+__sfx("77yIQ2xvdWRmbGFyZSDnvZHmrrXvvIzlj6/og73kuI3lj6/ovr7vvIk="),deprioritized:!0});let f=e.relay??[];for(let u of f)o({source:"relay",host:u.ip,port:u.port,label:__sfx("5Y+N5LujIA==")+u.label+"",deprioritized:!0});return t.map((u,c)=>({candidate:u,index:c})).sort((u,c)=>{let d=+!!u.candidate.deprioritized-+!!c.candidate.deprioritized;return d!==0?d:u.index-c.index}).map(u=>u.candidate)}function Wn(e){let t=e.filter(o=>!o.deprioritized),n=t.filter(o=>o.source==="proxy");return{landing:n.filter(o=>o.via?.kind!=="direct"),[__sfx("cHJveHlJcA==")]:n.filter(o=>o.via?.kind==="direct"),direct:t.filter(o=>o.source!=="proxy"),fallback:e.filter(o=>o.deprioritized)}}function zn(e,t){let n=e instanceof Error?e.message:String(e);return gt(e)?{kind:"policy",message:n,candidate:t}:/proxy request failed|cannot connect to the specified address|TCP Loop/i.test(n)?{kind:"blocked",message:n,candidate:t}:/timeout|超时|timed out|abort/i.test(n)?{kind:"timeout",message:n,candidate:t}:{kind:"other",message:n,candidate:t}}function Xn(e){switch(e.kind){case"blocked":return __sfx("5Ye656uZ6KKrIENsb3VkZmxhcmUg5ouS57ud77yI")+e.candidate+"):"+e.message+__sfx("CiAg5bi46KeB5Y6f5Zug77ya55uu5qCH5Zyw5Z2A5ZyoIENsb3VkZmxhcmUg6Ieq5a62572R5q6177yIV29ya2VyIOS4jeiDveS4u+WKqOi/nuWbniBDRiDoh6rlt7HnmoTlhaXlj6PvvInjgIIKICDihpIg5o2i5LiA5Liq56ys5LiJ5pa5IElQ77yM5oiW5pS555So5Luj55CG6JC95Zyw44CC");case"policy":return __sfx("5Ye656uZ6KKr562W55Wl5ouS57ud77yI")+e.candidate+"):"+e.message+__sfx("CiAg55uu5qCH5bGe5LqO546v5ZueIC8g5YaF572RIC8g6ZO+6Lev5pys5ZywIC8g5L+d55WZ5Zyw5Z2A77yMV29ya2VyIOebtOi/nuaXoOazleWIsOi+vuOAggogIOKGkiDopoHorr/pl67lsYDln5/nvZHorr7lpIfvvIzor7fphY3nva7okL3lnLDku6PnkIbvvIjnlLHku6PnkIbkvqflu7rov57vvInjgII=");case"timeout":return __sfx("5Ye656uZ6LaF5pe277yI")+e.candidate+"):"+e.message+__sfx("CiAg4oaSIOivpeWcsOWdgOW9k+WJjeS4jeWPr+i+vu+8jOWPr+aNouS4gOadoeWAmemAieaIluWQr+eUqOS7o+eQhuiQveWcsOOAgg==");default:return __sfx("5Ye656uZ5aSx6LSl77yI")+e.candidate+"):"+e.message+""}}var To,Ro,Co,vo,ko,Do,At=S(()=>{"use strict";bt();To=[[__sfx("MTAzLjIxLjI0NC4w"),22],[__sfx("MTAzLjIyLjIwMC4w"),22],[__sfx("MTAzLjMxLjQuMA=="),22],[__sfx("MTA0LjE2LjAuMA=="),13],[__sfx("MTA0LjI0LjAuMA=="),14],[__sfx("MTA4LjE2Mi4xOTIuMA=="),18],[__sfx("MTMxLjAuNzIuMA=="),22],[__sfx("MTQxLjEwMS42NC4w"),18],[__sfx("MTYyLjE1OC4wLjA="),15],[__sfx("MTcyLjY0LjAuMA=="),13],[__sfx("MTczLjI0NS40OC4w"),20],[__sfx("MTg4LjExNC45Ni4w"),20],[__sfx("MTkwLjkzLjI0MC4w"),20],[__sfx("MTk3LjIzNC4yNDAuMA=="),22],[__sfx("MTk4LjQxLjEyOC4w"),17]],Ro=[[__sfx("MTA0LjMxLjAuMA=="),15],[__sfx("MTkyLjAuMC4w"),24],[__sfx("MTkyLjAuMi4w"),24],[__sfx("MTkyLjg4Ljk5LjA="),24],[__sfx("MTk5LjI3LjEyOC4w"),21],[__sfx("MS4wLjAuMA=="),24],[__sfx("MS4xLjEuMA=="),24]],Co=[[__sfx("MjIzLjUuNS4w"),24]],vo=[...To,...Ro];ko=Gn(vo),Do=Gn(Co)});function Yn(e,t="direct"){let n=e.trim();if(!n)return null;let o=t,r=n,s=/^([a-z0-9+.-]+):\/\//i.exec(n);if(s){let d=s[1].toLowerCase();r=n.slice(s[0].length),d===__sfx("c29ja3M1")||d===__sfx("c29ja3M=")||d===__sfx("c29ja3M1aA==")?o=__sfx("c29ja3M1"):d==="https"?o="https":d==="http"&&(o="http")}let i=r.lastIndexOf("@"),a={};if(i>=0){let d=r.slice(0,i);r=r.slice(i+1);let g=d.indexOf(":");g>=0?a={username:d.slice(0,g),password:d.slice(g+1)}:a={username:d}}let l,f=/#sni=([^/#]+)/i.exec(r);f&&(l=f[1].trim(),r=r.slice(0,f.index)+r.slice(f.index+f[0].length));let{host:u,port:c}=wt(r,0);return!u||!Number.isInteger(c)||c<=0||c>65535?null:(!l&&o==="https"&&!Io(u)&&(l=u),{host:u,port:c,kind:o,...a,...l?{serverName:l}:{}})}function Io(e){return/^\d{1,3}(\.\d{1,3}){3}$/.test(e)}function Se(e,t="direct"){let n=[];for(let o of e.split(/[\n,;]+/)){let r=o.trim();if(!r)continue;let s=Yn(r,t);s&&n.push(s)}return n}var Tt=S(()=>{"use strict";Ge()});async function Uo(){return Rt||(Rt=(async()=>(await import("cloudflare:sockets")).connect)()),await Rt}function No(e,t){if(!B(e))return null;let n=e.split(".").map(i=>Number(i)),o=(n[0]<<8|n[1]).toString(16),r=(n[2]<<8|n[3]).toString(16);return`${t.replace(/:+$/,"")}::${o}:${r}`}async function je(e,t,n,o,r){let i=(await Uo())({hostname:e,port:t},o?{secureTransport:o}:void 0),a=async(f,u)=>{let c,d=new Promise((g,y)=>{c=setTimeout(()=>y(new Error(""+u+__sfx("6LaF5pe277ya")+e+":"+t+"")),n)});try{return await Promise.race([f,d])}finally{c&&clearTimeout(c)}},l;try{if(await a(i.opened,__sfx("6L+e5o6l")),o==="starttls"){if(l=i.startTls?.(r?{expectedServerHostname:r}:void 0),!l)throw new Error(__sfx("5b2T5YmN6L+Q6KGM5pe25LiN5pSv5oyBIHN0YXJ0VGxz"));return await a(l.opened,__sfx("VExTIOaPoeaJiw==")),l}return i}catch(f){try{await(l??i).close()}catch{}throw f}}async function Lo(e){let t=e.timeoutMs??kt;try{let n=await je(e.hostname,e.port,t);return{readable:n.readable,writable:n.writable,via:"direct",endpoint:`${e.hostname}:${e.port}`,close:()=>{try{n.close()}catch{}}}}catch(n){if(e.nat64&&B(e.hostname)){let o=No(e.hostname,e.nat64);if(o){let r=await je(o,e.port,t);return{readable:r.readable,writable:r.writable,via:"nat64",endpoint:`${o}:${e.port}`,close:()=>{try{r.close()}catch{}}}}}throw n}}function Mo(e){return e.includes(":")}function Bo(e){return e.source==="proxy"&&e.via!==void 0&&e.via.kind!=="direct"}async function Ho(e,t){let n=e.timeoutMs??kt;if(t.kind==="direct"){let s=await je(t.host,t.port,n);return{readable:s.readable,writable:s.writable,via:"direct",endpoint:`${t.host}:${t.port}`,close:()=>{try{s.close()}catch{}}}}let o=t.kind==="https"?"starttls":void 0,r=await je(t.host,t.port,n,o,t.kind==="https"?t.serverName:void 0);try{return t.kind==="http"||t.kind==="https"?{readable:await Rn(r.readable,r.writable,e.hostname,e.port,{username:t.username,password:t.password}),writable:r.writable,via:t.kind,endpoint:`${t.host}:${t.port}`,close:()=>{try{r.close()}catch{}}}:{readable:await An(r.readable,r.writable,e.hostname,e.port,{username:t.username,password:t.password}),writable:r.writable,via:__sfx("c29ja3M1"),endpoint:`${t.host}:${t.port}`,close:()=>{try{r.close()}catch{}}}}catch(s){try{await r.close()}catch{}throw s}}function Zn(e){return e instanceof Error?e.message:typeof e=="string"?e:String(e)}function Go(e){if(e.length===0)return __sfx("5pyq55+l5Y6f5Zug");let t=e.map(Zn),n=t.slice(-Fo),o=t.length-n.length;return`${o>0?`\uFF08\u5171 ${t.length} \u6761\uFF0C\u7701\u7565\u524D ${o} \u6761\uFF09`:""}${n.join("\uFF1B")}`}function Ko(e){return e.length===0?Promise.reject(new Error(__sfx("5rKh5pyJ5Y+v55So55qE5Ye656uZ5ouo5Y+35pa55byP"))):new Promise((t,n)=>{let o=e.length,r=!1,s=[];for(let i of e)i().then(a=>{if(r){try{let l=a.close;Promise.resolve(l?l():a.writable.close()).catch(()=>{})}catch{}return}r=!0,t(a)},a=>{s.push(a),o-=1,o===0&&!r&&(r=!0,n(new Error(__sfx("5pys5om5IA==")+e.length+__sfx("IOS4quWAmemAieWFqOmDqOWksei0pe+8mg==")+Go(s)+"")))})})}async function vt(e,t){if(e.length===0)throw new Error(__sfx("5rKh5pyJ5Y+v55So55qE5Ye656uZ5ouo5Y+35pa55byP"));if(!t||e.length<=1){let s=new Error(__sfx("5ouo5Y+35aSx6LSl"));for(let i of e)try{return await i()}catch(a){s=a}throw s}let n=[],o=new Error(__sfx("5ouo5Y+35aSx6LSl"));for(let s=0;s<e.length;s+=Ct){let i=e.slice(s,s+Ct);try{return await Ko(i)}catch(a){o=a,n.push(Zn(a))}}throw new Error(__sfx("5YWo6YOoIA==")+e.length+__sfx("IOS4quWAmemAieWdh+Wksei0pe+8iOWIhiA=")+n.length+__sfx("IOaJue+8jOavj+aJueacgOWkmiA=")+Ct+__sfx("IOS4quW5tuWPke+8ie+8mgo=")+n.join(`
4
4
  `),{cause:o})}async function Vn(e,t){let n=[...e];if(!t)return n;try{let o=await xe(t),r=new Set(n.map(s=>`${s.ip}:${s.port}`));for(let s of o){let i=`${s.ip}:${s.port}`;r.has(i)||(r.add(i),n.push(s))}}catch{}return n}async function jo(e,t,n){if(e.length===0)return null;for(let o=0;o<e.length;o+=Ke){let s=e.slice(o,o+Ke).map(i=>t({source:"relay",host:i.ip,port:i.port,label:__sfx("5Y+N5LujIA==")+i.label+""}));try{return await vt(s,n)}catch{}}return null}async function fe(e){let t=e.proxies??[],n=e.concurrent??!0;if(!e.skipTargetPolicy&&t.length===0){let h=yt(e.hostname);if(h)throw new le(e.hostname,h)}let o=e.budgetMs??Oo,r=Date.now()+o,s=[...e.optimizedIps??[]],i=!1;if(e.resolvePreferred)try{let h=await Fe(e.hostname,e.port,{deadline:r});if(h.length>0){i=!0;for(let w of h)s.push({ip:w.hostname,port:w.port})}}catch{}let a=se(e.hostname),l=i&&s.length>0&&s.every(h=>se(h.ip)),f=[...e.relay??[]];(l||a)&&e.relayPool&&(f=await Vn(f,{...e.relayPool,deadline:r}));let c=f,d=jn({targetHost:e.hostname,targetPort:e.port,optimizedIps:s,proxies:t,deprioritizeDirect:a,relay:[]});if(d.length===0)throw new Error(__sfx("5rKh5pyJ5Y+v55So55qE5Ye656uZ5ouo5Y+35pa55byP"));let g=h=>async()=>{let w=r-Date.now();if(w<=0)throw new Error(__sfx("5ouo5Y+36aKE566X5bey55So5bC977yI")+o+"ms):"+e.hostname+":"+e.port+"");let v=Math.max(200,Math.min(e.timeoutMs??kt,w)),V={...e,timeoutMs:v};try{if(!Bo(h)&&Mo(e.hostname))throw new le(e.hostname,Dn);if(!e.skipTargetPolicy&&h.source!=="proxy"&&h.source!=="relay"){let O=yt(h.host);if(O)throw new le(h.host,O)}if(h.source==="proxy"&&h.via)try{let O=await Ho(V,{host:h.via.host,port:h.via.port,kind:h.via.kind,username:h.via.username,password:h.via.password,serverName:h.via.serverName});return En(h.via),O}catch(O){throw O instanceof re||Sn(h.via,Date.now()),O}return await Lo({...V,hostname:h.host,port:h.port})}catch(O){let Z=zn(O,h.label);throw e.onFailure?.(Z),O}},y=Wn(d),{landing:x,[__sfx("cHJveHlJcA==")]:T,direct:p,fallback:R}=y,E=x.length>0||T.length>0,k=async()=>{if(x.length===0)throw new Error(__sfx("5pyq6YWN572u6JC95Zyw5Luj55CG"));let h,w=pt(x,v=>v.via,Date.now());for(let v of w)try{return await g(v)()}catch(V){h=V}throw h??new Error(__sfx("6JC95Zyw5Luj55CG5YWo6YOo5aSx6LSl"))},G=async()=>{if(T.length===0)throw new Error(__sfx("5pyq6YWN572uIFByb3h5SVA="));let h=Date.now(),w=pt(T,v=>v.via,h);return await vt(w.map(g),!0)},q=async()=>{let h;if(x.length>0)try{return await k()}catch(w){h=w}if(T.length>0)try{return await G()}catch(w){h=w}throw h??new Error(__sfx("5rKh5pyJ5Y+v55So55qE5Luj55CG"))},N=async()=>await vt(p.map(g),n),Y=async()=>{let h=c;return h.length===0&&e.relayPool&&(h=await Vn([],{...e.relayPool,deadline:r})),await jo(h,g,n)},$=async()=>{for(let h of R)try{return await g(h)()}catch{}return null};if(!E)try{return await N()}catch(h){let w=await Y();if(w)return w;let v=await $();if(v)return v;throw h}let ie=e.proxyMode??"only",I=a||l;if(ie==="only")try{return await q()}catch(h){let w=await Y();if(w)return w;let v=await $();if(v)return v;throw h}if(ie==="global"||ie==="smart"&&I)try{return await q()}catch(h){if(ie==="global")try{return await N()}catch{}let w=await Y();if(w)return w;let v=await $();if(v)return v;throw h}try{return await N()}catch(h){try{return await q()}catch{}let w=await Y();if(w)return w;let v=await $();if(v)return v;throw h}}var Rt,kt,Oo,Ct,Fo,Dt=S(()=>{"use strict";Tn();Cn();bt();Be();K();Ge();Pe();At();Tt();Rt=null;kt=8e3,Oo=15e3;Ct=6,Fo=8});async function _n(e,t,n,o=!0,r,s){let i=e.getReader(),a=t.getWriter();try{for(;!n?.exhausted;){let l;try{l=await i.read()}catch(u){s?.(u,"read");break}if(l.done)break;let f=l.value;if(!(!f||f.byteLength===0)){if(r?.(f.byteLength))break;try{await a.write(f)}catch(u){s?.(u,"write");break}}}}finally{if(o)try{await a.close()}catch{}else try{a.releaseLock()}catch{}try{i.releaseLock()}catch{}}}var ue,We=S(()=>{"use strict";ue=class{constructor(t){this.limitBytes=t}limitBytes;total=0;get enabled(){return this.limitBytes>0}get bytes(){return this.total}add(t){return this.limitBytes<=0||t<=0?!1:(this.total+=t,this.total>this.limitBytes)}}});var nr={};ve(nr,{diagnosticCounters:()=>Xo,[__sfx("aGFuZGxlV2ViU29ja2V0")]:()=>Ve,recentDiagnostics:()=>Vo,recentRoutes:()=>Yo,recordDiagnostics:()=>Q,truncateCloseReason:()=>tr});function tr(e,t=123){let n=new TextEncoder;if(n.encode(e).length<=t)return e;let o=e.slice(0,t);for(;n.encode(o).length>t;)o=o.slice(0,-1);o=o.replace(/\uFFFD+$/,"");let r="\u2026";for(;o.length>0&&n.encode(o+r).length>t;)o=o.slice(0,-1);return o+r}function Xo(){return{...de}}function Yo(){return Ye}function er(e,t,n){Ye.unshift({at:Date.now(),target:e,via:t.via,endpoint:t.endpoint,cfTarget:se(e.split(":")[0]??""),publicDns:Kn(e.split(":")[0]??""),phase:n}),Ye.length>20&&(Ye.length=20)}function Q(e,t,n){Xe.unshift({at:Date.now(),target:e,failures:t,summary:n}),Xe.length>$n&&(Xe.length=$n)}function Vo(){return Xe}function Jo(e){if(!e)return new Uint8Array(0);let t=e.trim();if(!t||t.length>16384)return new Uint8Array(0);try{let n=t.replace(/-/g,"+").replace(/_/g,"/"),o=n.length%4===0?"":"=".repeat(4-n.length%4),r=atob(n+o);if(r.length<17||r.length>8192)return new Uint8Array(0);let s=new Uint8Array(r.length);for(let i=0;i<r.length;i++)s[i]=r.charCodeAt(i);return s}catch{return new Uint8Array(0)}}async function Ve(e,t,n,o,r,s){let[i,a]=Object.values(new WebSocketPair);try{a.accept({allowHalfOpen:!0})}catch{a.accept()}a.binaryType="arraybuffer";let l=Jo(e.headers.get(__sfx("c2VjLXdlYnNvY2tldC1wcm90b2NvbA=="))),f=[],u=0,c=!1,d=null,g=null,y=new Le,x=null,T=null,p=()=>{T&&(clearTimeout(T),T=null)},R=!1,E=new Ne,k=null,G=!1,q=!1,N=null,Y=null,$=m=>{try{a.send(m)}catch{}},ie=m=>{let b=new Uint8Array(2+m.byteLength);b[0]=0,b[1]=m.byteLength,b.set(m,2),$(b)},I=(m,b)=>{G=!0;try{a.close(m,tr(b))}catch{}h()},h=()=>{if(!q){if(q=!0,Xt(),f=[],u=0,p(),x&&(clearTimeout(x),x=null),w&&(clearTimeout(w),w=null),k){let m=k;k=null;try{m.cancel()}catch{}}if(d){let m=d.close;if(m)try{m()}catch{}else try{d.writable.close()}catch{}}}},w=null,v=new Set,V=0,O=[],Z=0,et=m=>{if(!(m.byteLength===0||ae>0)){if(Z+m.byteLength>qn){I(1009,__sfx("5pyq56Gu6K6k6YCa6Lev55qE5LiK6KGM5pWw5o2u6L+H5aSa"));return}if(ze+m.byteLength>zo){I(1009,__sfx("5a6e5L6L5YaF5a2Y6aKE566X5bey5ruh77yM6K+36YeN6K+V"));return}O.push(m),Z+=m.byteLength,ze+=m.byteLength}},Xt=()=>{ze=Math.max(0,ze-Z),O=[],Z=0},tt=0,Ir=()=>{tt+=1},Yt=async()=>{if(!d)return;let m=++tt,b=d.readable.getReader();k=b,w&&clearTimeout(w);let P=setTimeout(()=>{w===P&&(w=null),!(ae>0)&&Z!==0&&Qt("stall")},Qn);w=P;try{for(;;){let{done:H,value:M}=await b.read();if(H)break;if(M&&M.byteLength>0){let U=ae===0;if(ae+=M.byteLength,U&&Xt(),Vt.add(M.byteLength)){Zt();return}let C=E.yieldCount;await E.onChunk(M.byteLength),E.yieldCount>C&&de.downlinkYields++,$(M)}}}catch{}finally{try{b.releaseLock()}catch{}if(clearTimeout(P),w===P&&(w=null),k===b&&(k=null),m!==tt||G)return;if(ae===0&&Z>0&&V<It&&!R){Qt("eof");return}let H=d;I(1e3,H?`done via=${H.via} ep=${H.endpoint} dl=${ae} ret=${Z} rd=${V}`:"done")}},ae=0,Vt=new ue((n.dataBudgetMB||0)*1024*1024),Zt=()=>{let m=__sfx("5Y2V6L+e5o6l5rWB6YeP6LaF6L+HIA==")+n.dataBudgetMB+__sfx("TUIg5LiK6ZmQ");Q(N?`${N.hostname}:${N.port}`:__sfx("5pyq5bu656uL5Ye656uZ"),[],m),I(1009,m)},Ur=async m=>{let b=g;if(b)try{await y.write(()=>g===b?b:null,m)}catch(P){Q(N?`${N.hostname}:${N.port}`:__sfx("5pyq5bu656uL5Ye656uZ"),[],__sfx("5LiK6KGM5YaZ5YWl5aSx6LSl77ya")+String(P)+""),h()}},_t=async m=>{if(f.length===0)return;let b=f;f=[],u=0;for(let P of b)et(P),await m.write(P)},Jt=m=>{if(t===__sfx("dmxlc3M=")){let P=Ie(m,n.uuid);return P?{command:P.header.command,port:P.header.port,hostname:P.header.hostname,headerLength:P.consumed}:null}let b=mn(m,n[__sfx("dHJvamFuUGFzc3dvcmQ=")]);return b?{command:b.header.command,port:b.header.port,hostname:b.header.hostname,headerLength:b.consumed}:null},Or=()=>{x&&(clearTimeout(x),x=null)},Nr=async()=>{if(!(G||c)){if(Jt(l)){await nt();return}I(1008,l.byteLength===0?__sfx("5o+h5omL6LaF5pe277ya5pyq5pS25Yiw5Y2P6K6u5aS0"):__sfx("5o+h5omL6LaF5pe277ya5Y2P6K6u5aS05LiN5a6M5pW05oiW6K6k6K+B5aSx6LSl"))}},nt=async()=>{if(G||c)return;let m=Jt(l);if(!m){l.byteLength>0&&!x&&(x=setTimeout(()=>{x=null,Nr().catch(C=>I(1011,String(C)))},Zo));return}if(Or(),p(),c)return;c=!0,N=m;let b=t===__sfx("dmxlc3M=")?sn:pn;if(m.command===b){if(t===__sfx("dmxlc3M=")&&n.udpDns==="doh"&&m.port===53){ie(new Uint8Array(0)),Y=new Oe({endpoint:n.udpDnsEndpoint,send:$});let C=l.subarray(m.headerLength);C.byteLength>0&&Y.push(C);return}I(1002,n.udpDns==="doh"?__sfx("VURQIOS7heaUr+aMgSBETlPvvIg1MyDnq6/lj6PvvIk="):__sfx("VURQIOacquWQr+eUqO+8iOmdouadv+WPr+W8gOWQryBETlMgb3ZlciBEb0jvvIk="));return}t===__sfx("dmxlc3M=")&&ie(new Uint8Array(0));let P=[],H=null;try{d=await fe({hostname:m.hostname,port:m.port,proxies:o,timeoutMs:Jn,concurrent:n.concurrentDial,nat64:n.nat64||void 0,proxyMode:n.proxyMode,resolvePreferred:n.resolvePreferred,relayPool:{userEntries:n.relayPool||void 0,useBuiltin:n.useBuiltinRelay},onFailure:C=>{P.push(C),s?.failures.push(C)}})}catch(C){H=C}if(!d){let C=P.length>0?P.map(he=>Xn(he)).join(`
5
- `):__sfx("5Ye656uZ6L+e5o6l5aSx6LSl77ya")+String(H)+"";Q(`${m.hostname}:${m.port}`,P,C),I(1011,C);return}let M=d.writable.getWriter();g=M,er(`${m.hostname}:${m.port}`,d,"initial");let U=l.byteLength>m.headerLength?l.subarray(m.headerLength):new Uint8Array(0);l=new Uint8Array(0);try{await y.run(async()=>{U.byteLength>0&&(et(U),await M.write(U)),await _t(M)})}catch(C){Q(`${m.hostname}:${m.port}`,[],__sfx("5LiK6KGM6aaW5YyF5YaZ5YWl5aSx6LSl77ya")+String(C)+""),h()}r?.waitUntil(Yt())},Qt=async m=>{if(G||R)return;let b=N;if(!b){I(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya55uu5qCH5pyq6Kej5p6Q"));return}if(V>=It){I(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya55u06L+e5LiO5Y+N5Luj5YWl5Y+j5Z2H5peg5ZON5bqU"));return}R=!0;let P=bn({via:d?.via,port:b.port,userProxyConfigured:o.length>0||!!n[__sfx("cHJveHlJcA==")],aggressive:n.aggressiveRedial===!0});if(!P.allowed){de.guardedRedials++,Q(`${b.hostname}:${b.port}`,[],__sfx("5Ye656uZ5peg5pWw5o2u77ya")+P.reason+__sfx("77yb5pyq5YiH5o2i5Y+N5Luj77yI5Y+v5byA5ZCvIGFnZ3Jlc3NpdmVSZWRpYWzvvIk=")),I(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya")+P.reason+"");return}V++,m==="stall"?de.stallRedials++:de.eofRedials++,Q(`${b.hostname}:${b.port}`,[],m==="stall"?__sfx("55u06L+eIA==")+Qn+__sfx("bXMg5peg5LiL6KGM5pWw5o2u77yM5pS56LWw5Y+N5Luj5YWl5Y+j"):__sfx("5Ye656uZ6Zu25LiL6KGM5Y2zIEVPRi9SZXNldO+8jOeri+WNs+aUuei1sOWPjeS7o+WFpeWPow=="));let H=[];try{H=await xe({userEntries:n.relayPool||void 0,useBuiltin:n.useBuiltinRelay})}catch{H=[]}let M=H.filter(U=>!v.has(`${U.ip}:${U.port}`));if(M.length===0){I(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya5peg5Y+N5Luj5YWl5Y+j5Y+v55So"));return}for(let U of M.slice(0,It)){if(v.add(`${U.ip}:${U.port}`),Ir(),d){let C=d;if(C.close)try{C.close()}catch{}}g=null,ae=0;try{let C=await fe({hostname:U.ip,port:U.port,timeoutMs:Jn,resolvePreferred:!1,skipTargetPolicy:!0,proxies:n.aggressiveRedial?o:void 0,proxyMode:n.aggressiveRedial?n.proxyMode:void 0});if(!C)continue;d=C,er(`${b.hostname}:${b.port}`,C,"redial");let he=C.writable.getWriter();g=he;let $t=0;for(let Ce of O)$t+=Ce.byteLength;let rt=new Uint8Array($t),en=0;for(let Ce of O)rt.set(Ce,en),en+=Ce.byteLength;await y.run(async()=>{rt.byteLength>0&&await he.write(rt),await _t(he)}),Q(`${b.hostname}:${b.port}`,[],__sfx("5bey5YiH5o2i5Y+N5Luj5YWl5Y+jIA==")+U.ip+":"+U.port+""),r?.waitUntil(Yt());return}catch(C){Q(`${b.hostname}:${b.port}`,[],__sfx("5Y+N5Luj5YWl5Y+jIA==")+U.ip+":"+U.port+__sfx("IOWksei0pe+8mg==")+String(C)+"")}}I(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya5omA5pyJ5Y+N5Luj5YWl5Y+j5Z2H5aSx6LSl"))};a.addEventListener("message",m=>{(async()=>{let b=m.data,P=typeof b=="string"?new TextEncoder().encode(b):new Uint8Array(b);if(P.byteLength!==0){if(p(),Vt.add(P.byteLength)){Zt();return}if(!c){if(l=yn(l,P),l.byteLength>Wo){I(1009,__sfx("5o+h5omL5aS06LaF6L+HIDY0S0I="));return}await nt();return}if(Y){Y.push(P);return}if(!g){if(f.push(P),u+=P.byteLength,u>qn){I(1009,__sfx("5ouo5Y+35pyf6Ze05pWw5o2u6L+H5aSa"));return}return}et(P),await Ur(P)}})()});let qt=()=>{h()};a.addEventListener("close",qt),a.addEventListener("error",qt),l.byteLength>0?nt().catch(m=>I(1011,String(m))):T=setTimeout(()=>{T=null,!(G||c||l.byteLength>0)&&(de.firstPacketTimeouts++,I(1008,__sfx("6aaW5YyF6LaF5pe277ya5pyq5pS25Yiw5Y2P6K6u5aS0")))},_o);try{return new Response(null,{status:101,[__sfx("d2ViU29ja2V0")]:i})}catch(m){return console.error(__sfx("W+iHqueglOaVsOaNrumdol0gMTAxIOWTjeW6lOaehOmAoOWksei0pe+8mg=="),m),new Response(null,{status:200})}}var Jn,Qn,It,Wo,qn,zo,ze,Xe,$n,de,Ye,Zo,_o,Ut=S(()=>{"use strict";ct();hn();gn();we();wn();xn();Dt();We();At();Pe();Jn=5e3,Qn=2500,It=2,Wo=64*1024,qn=8*1024*1024,zo=32*1024*1024,ze=0;Xe=[],$n=20,de={stallRedials:0,eofRedials:0,guardedRedials:0,firstPacketTimeouts:0,downlinkYields:0};Ye=[];Zo=2e3,_o=8e3});var fr={};ve(fr,{[__sfx("Y2xlYXJYaHR0cFNlc3Npb25z")]:()=>rs,[__sfx("aGFuZGxlWGh0dHA=")]:()=>Mt,[__sfx("aXNYaHR0cFBhdGg=")]:()=>Lt,[__sfx("cGFyc2VYaHR0cFJvdXRl")]:()=>Nt,[__sfx("cmVjZW50WGh0dHBEaWFnbm9zdGljcw==")]:()=>$o,[__sfx("cmVjb3JkWGh0dHBEaWFnbm9zdGljcw==")]:()=>X});function qo(e,t){return new Promise(n=>{let o=setTimeout(()=>n(null),t);e.then(r=>{clearTimeout(o),n(r)},()=>{clearTimeout(o),n(null)})})}function X(e,t,n){Ze.unshift({at:Date.now(),target:e,...t,summary:n}),Ze.length>20&&(Ze.length=20)}function $o(){return Ze}function es(e){return String(e||"").trim().replace(/\/+$/,"")||"/"}function Nt(e,t){let n=es(t??__sfx("L3hodHRw"));if(e===n||e===`${n}/`)return{kind:"stream-one"};let o=`${n}/`;if(!e.startsWith(o))return null;let r=e.slice(o.length);if(!r)return null;let s=r.split("/");if(s.length===1&&s[0])return/[\s\u0000-\u001f]/.test(s[0])?null:{kind:"session",sessionId:s[0]};if(s.length===2&&s[0]&&/^\d+$/.test(s[1])){if(/[\s\u0000-\u001f]/.test(s[0]))return null;let i=Number(s[1]);return!Number.isSafeInteger(i)||i<0||i>1e6?null:{kind:__sfx("cGFja2V0LXVw"),sessionId:s[0],seq:i}}return null}function Lt(e,t){return Nt(e,t)!==null}function lr(e){if(e.reservedBytes<=0){e.reservedBytes=0;return}Ee=Math.max(0,Ee-e.reservedBytes),e.reservedBytes=0}function ir(e,t){return t<=0?!0:Ee+t>ns?!1:(Ee+=t,e.reservedBytes+=t,!0)}function rs(){for(let[e,t]of W)z(e,t);W.clear(),Ee=0}function os(e,t){return t-e.lastUploadAt>Ot&&t-e.lastDownlinkAt>Ot&&t-e.lastActivityAt>Ot}function ss(e,t){return e.closed?!0:e.header||e.dialResult||e.downlinkStarted?!1:t-e.createdAt>ar}function ur(e,t,n,o){let r=Date.now();for(let[a,l]of W)(l.closed||os(l,r)||r-l.createdAt>30*6e4)&&z(a,l);let s=W.get(e);if(s)return cr(s,n,r),s;if(W.size>=rr){for(let[a,l]of W)ss(l,r)&&z(a,l);if(W.size>=rr)return null}if(!o){let a=0;for(let l of W.values())l.header||(a+=1);if(a>=ts)return null}let i={id:e,createdAt:r,lastUploadAt:r,lastDownlinkAt:r,lastActivityAt:r,header:void 0,headerWaiters:[],dialPromise:null,dialResult:null,pending:new Map,reservedBytes:0,nextPumpSeq:0,pumpStarted:!1,signalResolve:null,traffic:new ue(t),downlinkStarted:!1,closed:!1,targetLabel:""};return W.set(e,i),i}function cr(e,t,n){t==="upload"?e.lastUploadAt=n:e.lastDownlinkAt=n,e.lastActivityAt=n}function z(e,t){if(!t.closed){t.closed=!0;for(let n of t.headerWaiters)try{n(null)}catch{}if(t.headerWaiters=[],t.signalResolve?.(),t.signalResolve=null,t.dialResult?.close)try{t.dialResult.close()}catch{}lr(t),t.pending.clear(),W.delete(e)}}function is(e){let t=e.signalResolve;e.signalResolve=null,t?.()}function as(e,t){return e.header?Promise.resolve(e.header):e.closed?Promise.resolve(null):new Promise(n=>{let o=s=>{clearTimeout(r),n(s)},r=setTimeout(()=>{let s=e.headerWaiters.indexOf(o);s>=0&&e.headerWaiters.splice(s,1),n(null)},t);e.headerWaiters.push(o)})}function ls(e,t){e.header=t;let n=e.headerWaiters;e.headerWaiters=[];for(let o of n)try{o(t)}catch{}}function L(e){let t=100+Math.floor(Math.random()*900);return{"Content-Type":"text/event-stream","Cache-Control":"no-store","X-Accel-Buffering":"no","Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST","X-Padding":"X".repeat(t),...e}}function us(e){let t=e.addons,n=new Uint8Array(2+t.byteLength);return n[0]=e.version,n[1]=t.byteLength,n.set(t,2),n}async function cs(e,t,n){if(e.dialResult)return e.dialResult;if(!e.dialPromise){let o=e.header;if(!o)throw new Error(__sfx("VkxFU1Mg5aS05pyq5Yiw6L6+"));e.targetLabel=`${o.hostname}:${o.port}`,e.dialPromise=fe({hostname:o.hostname,port:o.port,proxies:n,nat64:t.nat64,concurrent:t.concurrentDial,proxyMode:t.proxyMode,resolvePreferred:t.resolvePreferred,relayPool:{userEntries:t.relayPool||void 0,useBuiltin:t.useBuiltinRelay},onFailure:r=>{X(e.targetLabel,r,__sfx("WEhUVFAg5Ye656uZ5aSx6LSl77yI")+r.candidate+"):"+r.message+"")}}).then(r=>(e.dialResult=r,r)).catch(r=>{throw X(e.targetLabel,{kind:"dial",message:String(r),candidate:"all"},__sfx("WEhUVFAg5Ye656uZ5YWo6YOo5aSx6LSl77ya")+String(r)+""),r})}return await e.dialPromise}async function fs(e,t){let n=t.writable.getWriter();try{for(;!e.closed;){let o=e.pending.get(e.nextPumpSeq);if(o){if(e.pending.delete(e.nextPumpSeq),e.nextPumpSeq+=1,lr(e),o.byteLength===0)continue;if(e.traffic.add(o.byteLength)){X(e.targetLabel,{kind:"budget",message:__sfx("5rWB6YeP6LaF6ZmQ"),candidate:"traffic"},__sfx("WEhUVFAg5LiK6KGM5rWB6YeP6LaF6ZmQ"));break}try{await n.write(o)}catch(i){X(e.targetLabel,{kind:"relay-write",message:String(i),candidate:t.endpoint},__sfx("WEhUVFAg5YaZ5YWl55uu5qCH5aSx6LSl77ya")+String(i)+"");break}continue}let r=null,s=new Promise(i=>{r=i});if(e.signalResolve=r,e.pending.has(e.nextPumpSeq)||e.closed){e.signalResolve=null;continue}await s}}finally{try{n.releaseLock()}catch{}}}async function ds(e,t,n,o,r){let s=(t.dataBudgetMB||0)*1024*1024,i=ur(o,s,"upload",r===0);if(!i)return new Response(__sfx("5Lya6K+d5pWw5bey6L6+5LiK6ZmQ77yM6K+356iN5ZCO6YeN6K+V"),{status:503,headers:L()});if(i.closed)return null;let a=Number(e.headers.get("content-length")??"");if(Number.isFinite(a)&&a>or)return new Response(__sfx("5YiG5YyF6LaF5Ye65LiK6ZmQ"),{status:413,headers:L()});let l;try{let f=await e.arrayBuffer();l=new Uint8Array(f)}catch{return new Response(__sfx("6K+35rGC5L2T6K+75Y+W5aSx6LSl"),{status:400,headers:L()})}if(l.byteLength>or)return new Response(__sfx("5YiG5YyF6LaF5Ye65LiK6ZmQ"),{status:413,headers:L()});if(r===0&&!i.header){let f=Ie(l,t.uuid);if(!f)return z(o,i),new Response(__sfx("VkxFU1Mg5aS06Kej5p6Q5aSx6LSl"),{status:400,headers:L()});if(f.header.command!==ut)return z(o,i),new Response(__sfx("WEhUVFAg5pqC5LiN5pSv5oyBIFVEUA=="),{status:400,headers:L()});ls(i,f.header),i.targetLabel=`${f.header.hostname}:${f.header.port}`;let u=l.subarray(f.consumed);if(r>=i.nextPumpSeq&&!i.pending.has(r)){if(i.pending.size>=sr)return z(o,i),new Response(__sfx("5YiG5YyF57yT5a2Y5bey5ruh"),{status:503,headers:L()});if(!ir(i,u.byteLength))return z(o,i),new Response(__sfx("5pqC5a2Y6LaF6ZmQ"),{status:503,headers:L()});i.pending.set(r,u.slice())}}else{if(r<i.nextPumpSeq||i.pending.has(r))return new Response(null,{status:200,headers:L()});if(i.pending.size>=sr)return z(o,i),new Response(__sfx("5YiG5YyF57yT5a2Y5bey5ruh"),{status:503,headers:L()});if(!ir(i,l.byteLength))return z(o,i),new Response(__sfx("5pqC5a2Y6LaF6ZmQ"),{status:503,headers:L()});i.pending.set(r,l.slice())}return is(i),new Response(null,{status:200,headers:L()})}async function ps(e,t,n,o){let r=(t.dataBudgetMB||0)*1024*1024,s=ur(o,r,"downlink",!1);if(!s)return new Response(__sfx("5Lya6K+d5pWw5bey6L6+5LiK6ZmQ77yM6K+356iN5ZCO6YeN6K+V"),{status:503,headers:L()});if(s.closed||s.downlinkStarted)return null;s.downlinkStarted=!0;let i=as(s,ar),a=!1,l=null,f=null,u=!1,c=null,d=()=>{z(o,s)},g=new ReadableStream({start(y){f=y},async pull(y){if(!a)try{if(!u){let p=await i;if(a)return;if(!p){d(),y.close();return}try{c=await cs(s,t,n)}catch{d(),y.close();return}if(a)return;s.pumpStarted||(s.pumpStarted=!0,fs(s,c).catch(()=>{}));try{y.enqueue(us(p))}catch{}u=!0;return}if(!c)return;l||(l=c.readable.getReader());let{done:x,value:T}=await l.read();if(a)return;if(x){d();try{y.close()}catch{}return}if(T&&T.byteLength>0){if(cr(s,"downlink",Date.now()),s.traffic.add(T.byteLength)){X(s.targetLabel,{kind:"budget",message:__sfx("5rWB6YeP6LaF6ZmQ"),candidate:"traffic"},__sfx("WEhUVFAg5LiL6KGM5rWB6YeP6LaF6ZmQ")),d();try{y.close()}catch{}return}y.enqueue(T)}}catch(x){if(a)return;d();try{y.error(x)}catch{}}},cancel(y){if(a=!0,c)try{c.readable.cancel(y)}catch{}d()}});return new Response(g,{status:200,headers:L()})}async function Mt(e,t,n){let o=__sfx("L3hodHRw");try{o=new URL(e.url).pathname}catch{o=__sfx("L3hodHRw")}let r=Nt(o,t[__sfx("eGh0dHBQYXRo")]);return r?r.kind==="stream-one"?e.method!=="POST"?null:await ms(e,t,n):r.kind===__sfx("cGFja2V0LXVw")?e.method!=="POST"?null:await ds(e,t,n,r.sessionId,r.seq):e.method==="GET"?await ps(e,t,n,r.sessionId):null:null}async function ms(e,t,n){let o=e.body;if(!o)return new Response(__sfx("57y65bCR6K+35rGC5L2T"),{status:400});let r=new ne(o),s=await qo(ln(r,t.uuid),Qo);if(!s)return await r.cancel("header timeout"),new Response(__sfx("VkxFU1Mg5aS06Kej5p6Q5aSx6LSl"),{status:400});if(s.header.command!==ut)return await s.payload.cancel("unsupported UDP"),new Response(__sfx("WEhUVFAg5pqC5LiN5pSv5oyBIFVEUA=="),{status:400});let i;try{i=await fe({hostname:s.header.hostname,port:s.header.port,proxies:n,nat64:t.nat64,concurrent:t.concurrentDial,proxyMode:t.proxyMode,resolvePreferred:t.resolvePreferred,relayPool:{userEntries:t.relayPool||void 0,useBuiltin:t.useBuiltinRelay},onFailure:p=>{X(`${s.header.hostname}:${s.header.port}`,p,__sfx("WEhUVFAg5Ye656uZ5aSx6LSl77yI")+p.candidate+"):"+p.message+"")}})}catch(p){X(`${s.header.hostname}:${s.header.port}`,{kind:"dial",message:String(p),candidate:"all"},__sfx("WEhUVFAg5Ye656uZ5YWo6YOo5aSx6LSl77ya")+String(p)+"");try{s.payload.cancel("dial failed").catch(()=>{})}catch{}return new Response(__sfx("5Ye656uZ5LiN5Y+v55So"),{status:502})}let a=s.header.addons;if(a.byteLength>255)return new Response(__sfx("QWRkb25zIOmVv+W6pui2heWHuiBWTEVTUyDljY/orq7kuIrpmZA="),{status:400});let l=new Uint8Array(2+a.byteLength);l[0]=s.header.version,l[1]=a.byteLength,l.set(a,2);let f=!1,u=null,c=!1,d=new ue((t.dataBudgetMB||0)*1024*1024),g=null,y=()=>{if(c)return;c=!0;let p=__sfx("5Y2V6L+e5o6l5rWB6YeP6LaF6L+HIA==")+t.dataBudgetMB+__sfx("TUIg5LiK6ZmQ");if(X(`${s.header.hostname}:${s.header.port}`,{kind:"budget",message:p,candidate:"traffic"},p),i.close)try{i.close()}catch{}try{g?.close()}catch{}},x=p=>d.add(p)?(y(),!0):!1;_n(s.payload,i.writable,void 0,!1,x,(p,R)=>{let E=p instanceof Error?p.message:String(p),k=`relay-${R}`;/cancel|abort|closed/i.test(E)?k=`relay-${R}-client-cancel`:/reset|broken pipe/i.test(E)&&(k=`relay-${R}-upstream-reset`),X(`${s.header.hostname}:${s.header.port}`,{kind:k,message:E.slice(0,200),candidate:i.endpoint},__sfx("WEhUVFAg5Lit57un")+R==="read"?"\u8BFB\u4E0A\u6E38":"\u5199\u76EE\u6807"+__sfx("5aSx6LSl77yI")+k+"):"+E.slice(0,120)+"")}).catch(()=>{});let T=new ReadableStream({start(p){g=p,p.enqueue(l),f=!0},async pull(p){if(!(c||!f)){u||(u=i.readable.getReader());try{let{done:R,value:E}=await u.read();if(c)return;if(R){if(i.close)try{i.close()}catch{}p.close();return}if(E&&E.byteLength>0){if(d.add(E.byteLength)){y();return}p.enqueue(E)}}catch(R){if(c)return;if(i.close)try{i.close()}catch{}try{p.error(R)}catch{}}}},cancel(p){c=!0;try{i.readable.cancel(p)}catch{}if(i.close)try{i.close()}catch{}}});return new Response(T,{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-store","X-Accel-Buffering":"no"}})}var Qo,Ze,W,ar,rr,ts,Ot,or,sr,ns,Ee,Bt=S(()=>{"use strict";we();ct();We();Dt();Qo=2e3;Ze=[];W=new Map,ar=3e4,rr=100,ts=20,Ot=10*6e4,or=10*1024*1024,sr=30,ns=32*1024*1024,Ee=0});function Je(){return new Response(JSON.stringify({build:Ht,version:hs,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var Ht,hs,_e,Ft=S(()=>{"use strict";Ht="df07e58-d3daa12e",hs=__sfx("MC4zMC4w"),_e=__sfx("L19fY2ZwX3ZlcnNpb24=")});function dr(e){return e[__sfx("S1Y=")]?new pe(e[__sfx("S1Y=")]):new Gt}var pe,Gt,Qe=S(()=>{"use strict";pe=class{constructor(t){this.kv=t}kv;async get(t){return await this.kv.get(t)}async put(t,n,o){o&&o>=60?await this.kv.put(t,n,{expirationTtl:o}):await this.kv.put(t,n)}async delete(t){await this.kv.delete(t)}async list(t){let n=[],o;do{let r=await this.kv.list({prefix:t,cursor:o});for(let s of r.keys)n.push(s.name);o=r.list_complete?void 0:r.cursor}while(o);return n}},Gt=class{data=new Map;async get(t){let n=this.data.get(t);return n?n.expiresAt>0&&n.expiresAt<=Date.now()?(this.data.delete(t),null):n.value:null}async put(t,n,o){let r=o?Date.now()+o*1e3:0;this.data.set(t,{value:n,expiresAt:r})}async delete(t){this.data.delete(t)}async list(t){return[...this.data.keys()].filter(n=>n.startsWith(t))}}});function ce(e,t){if(e==null)return t;let n=String(e).trim();if(n==="")return t;let o=Number(n);return Number.isFinite(o)?o:t}function F(e,t){if(e==null||e==="")return t;let n=String(e).trim().toLowerCase();return["1","true","yes","on"].includes(n)?!0:["0","false","no","off"].includes(n)?!1:t}function gs(e){let t=e.trim().toLowerCase();return t==="global"||t==="fallback"||t==="smart"?t:"only"}function mr(e){return e.trim().toLowerCase()==="signed"?"signed":"legacy"}function hr(e){return e.trim().toLowerCase()==="doh"?"doh":"off"}function D(e,t){return e==null?t:String(e)}function ys(e){return{uuid:D(e[__sfx("VVVJRA==")],""),[__sfx("dHJvamFuUGFzc3dvcmQ=")]:D(e[__sfx("VFJPSkFOX1BBU1NXT1JE")],""),wsPath:D(e[__sfx("V1NfUEFUSA==")]||e[__sfx("UEFUSA==")],A.wsPath),[__sfx("dHJvamFuUGF0aA==")]:A[__sfx("dHJvamFuUGF0aA==")],[__sfx("eGh0dHBQYXRo")]:A[__sfx("eGh0dHBQYXRo")],add:D(e[__sfx("QURE")],""),addApi:D(e[__sfx("QUREQVBJ")],""),addCsv:D(e[__sfx("QUREX0NTVg==")],""),poolOfficial:F(e[__sfx("T0ZGSUNJQUxfSVA=")],A.poolOfficial),officialCount:ce(e[__sfx("T0ZGSUNJQUxfSVBfQ09VTlQ=")],A.officialCount),poolDomain:F(e[__sfx("UFJFRkVSUkVEX0RPTUFJTg==")],A.poolDomain),domainCount:ce(e[__sfx("UFJFRkVSUkVEX0RPTUFJTl9DT1VOVA==")],A.domainCount),poolManual:F(e[__sfx("TUFOVUFMX0lQ")],A.poolManual),poolCountries:D(e[__sfx("UE9PTF9DT1VOVFJJRVM=")],A.poolCountries),dls:ce(e[__sfx("RExT")],0),maxLatency:ce(e[__sfx("TUFYX0xBVEVOQ1k=")],0),maxNodes:0,[__sfx("cHJveHlJcA==")]:D(e[__sfx("UFJPWFlJUA==")],""),[__sfx("c29ja3M1")]:D(e[__sfx("U09DS1M1")],""),httpProxy:D(e[__sfx("SFRUUF9QUk9YWQ==")],""),proxyMode:gs(D(e[__sfx("UFJPWFlfTU9ERQ==")],"")),nat64:D(e[__sfx("TkFUNjQ=")],""),concurrentDial:F(e[__sfx("VENQX0NPTkNVUlJFTlRfRElBTA==")],!0),dataBudgetMB:ce(e[__sfx("REFUQV9CVURHRVRfTUI=")],A.dataBudgetMB),resolvePreferred:F(e[__sfx("UkVTT0xWRV9QUkVGRVJSRUQ=")],A.resolvePreferred),aggressiveRedial:F(e[__sfx("QUdHUkVTU0lWRV9SRURJQUw=")],A.aggressiveRedial),relayPool:D(e[__sfx("UkVMQVlfUE9PTA==")],""),useBuiltinRelay:F(e[__sfx("VVNFX0JVSUxUSU5fUkVMQVk=")],A.useBuiltinRelay),[__sfx("ZW5hYmxlVHJvamFu")]:F(e[__sfx("RU5BQkxFX1RST0pBTg==")]??e[__sfx("VFJPSkFO")],A[__sfx("ZW5hYmxlVHJvamFu")]),[__sfx("ZW5hYmxlWGh0dHA=")]:F(e[__sfx("RU5BQkxFX1hIVFRQ")]??e[__sfx("WEhUVFA=")],A[__sfx("ZW5hYmxlWGh0dHA=")]),subDomain:"",subProtocol:"both",subTransport:"both",subVariants:D(e[__sfx("U1VCX1ZBUklBTlRT")],A.subVariants),subName:D(e[__sfx("U1VCX05BTUU=")],A.subName).trim()||A.subName,subPorts:D(e[__sfx("U1VCX1BPUlRT")],A.subPorts),clientFingerprint:A.clientFingerprint,ech:F(e[__sfx("RUNI")],A.ech),echHost:D(e[__sfx("RUNIX0hPU1Q=")],A.echHost),echDns:D(e[__sfx("RUNIX0ROUw==")],A.echDns),tlsFragment:!1,tlsFragmentSize:A.tlsFragmentSize,tlsFragmentDelay:A.tlsFragmentDelay,subToken:mr(D(e[__sfx("U1VCX1RPS0VOX01PREU=")],"")),subTokenTtlDays:ce(e[__sfx("U1VCX1RPS0VOX1RUTF9EQVlT")],A.subTokenTtlDays),unlockProbe:F(e[__sfx("VU5MT0NLX1BST0JF")],A.unlockProbe),udpDns:hr(D(e[__sfx("VURQX0ROUw==")],"")),udpDnsEndpoint:D(e[__sfx("VURQX0ROU19FTkRQT0lOVA==")],A.udpDnsEndpoint)}}function bs(e,t){let n={...e};for(let[o,r]of Object.entries(t))if(r!=null)if(o==="dls"||o==="maxLatency"||o==="maxNodes"||o==="officialCount"||o==="domainCount"||o==="dataBudgetMB"||o==="subTokenTtlDays")n[o]=ce(r,0);else if(o==="concurrentDial"||o==="resolvePreferred"||o==="aggressiveRedial"||o==="useBuiltinRelay"||o===__sfx("ZW5hYmxlVHJvamFu")||o===__sfx("ZW5hYmxlWGh0dHA=")||o==="tlsFragment"||o==="ech"||o==="poolOfficial"||o==="poolDomain"||o==="poolManual"||o==="unlockProbe")n[o]=F(r,!1);else if(o==="subProtocol"){let s=String(r);n[o]=s===__sfx("dmxlc3M=")||s===__sfx("dHJvamFu")||s==="both"?s:"both"}else if(o==="subTransport"){let s=String(r);n[o]=s==="ws"||s===__sfx("eGh0dHA=")||s==="both"?s:"both"}else o==="subToken"?n[o]=mr(String(r)):o==="udpDns"?n[o]=hr(String(r)):n[o]=String(r);return n}async function gr(e,t){let n=ys(t),o=await e.get(pr),r={};if(o)try{r=JSON.parse(o)}catch{r={}}let s=bs(n,r),i=!1,a=e instanceof pe,l=Date.now();o?Ae=0:Ae===0&&(Ae=l);let f=l-Ae>ws;return a&&f&&(s.uuid||(s.uuid=ot(),i=!0),s[__sfx("dHJvamFuUGFzc3dvcmQ=")]||(s[__sfx("dHJvamFuUGFzc3dvcmQ=")]=ot().replace(/-/g,"").slice(0,16),i=!0),Ae=0),o&&(s.officialCount<1||s.domainCount<1)&&(s.officialCount<1&&(s.officialCount=A.officialCount,i=!0),s.domainCount<1&&(s.domainCount=A.domainCount,i=!0)),i&&await xs(e,s),s}async function xs(e,t){await e.put(pr,JSON.stringify(t))}var pr,A,Ae,ws,qe=S(()=>{"use strict";ee();Qe();pr="CONFIG",A={uuid:"",[__sfx("dHJvamFuUGFzc3dvcmQ=")]:"",wsPath:__sfx("L3ZsZXNz"),[__sfx("dHJvamFuUGF0aA==")]:__sfx("L3Ryb2phbg=="),[__sfx("eGh0dHBQYXRo")]:__sfx("L3hodHRw"),add:"",addApi:"",addCsv:"",poolOfficial:!0,officialCount:20,poolDomain:!0,domainCount:10,poolManual:!0,poolCountries:"",dls:0,maxLatency:0,maxNodes:0,[__sfx("cHJveHlJcA==")]:"",[__sfx("c29ja3M1")]:"",httpProxy:"",proxyMode:"only",nat64:"",concurrentDial:!0,dataBudgetMB:0,resolvePreferred:!0,aggressiveRedial:!1,relayPool:"",useBuiltinRelay:!0,[__sfx("ZW5hYmxlVHJvamFu")]:!0,[__sfx("ZW5hYmxlWGh0dHA=")]:!0,subDomain:"",subProtocol:__sfx("dmxlc3M="),subTransport:"ws",subVariants:__sfx("dmxlc3Mtd3M="),subName:__sfx("Q0ZQaWxvdA=="),subPorts:"443",clientFingerprint:"chrome",ech:!1,echHost:__sfx("Y2xvdWRmbGFyZS1lY2guY29t"),echDns:"",tlsFragment:!1,tlsFragmentSize:"10-20",tlsFragmentDelay:"10-20",subToken:"legacy",subTokenTtlDays:0,unlockProbe:!1,udpDns:"off",udpDnsEndpoint:"https://dns.google/dns-query"};Ae=0,ws=9e4});var yr,Ps,Yi,Ss,Vi,br=S(()=>{"use strict";yr={[__sfx("SEs=")]:["HKG"],[__sfx("VFc=")]:["TPE","KHH"],[__sfx("SlA=")]:["NRT","KIX","CTS","FUK"],[__sfx("S1I=")]:["ICN","PUS"],[__sfx("U0c=")]:["SIN"],[__sfx("TVk=")]:["KUL"],[__sfx("VEg=")]:["BKK"],[__sfx("Vk4=")]:["SGN","HAN"],[__sfx("SUQ=")]:["CGK","DPS"],[__sfx("UEg=")]:["MNL"],[__sfx("SU4=")]:["BOM","MAA","DEL"],[__sfx("QVU=")]:["SYD","MEL","BNE","PER"],[__sfx("Tlo=")]:["AKL"],[__sfx("VVM=")]:["LAX","SJC","SEA","ORD","DFW","IAD","EWR","ATL","MIA","DEN","PHX","BOS"],[__sfx("Q0E=")]:["YYZ","YVR","YYC"],[__sfx("R0I=")]:["LHR","MAN"],[__sfx("REU=")]:["FRA","MUC","BER"],[__sfx("RlI=")]:["CDG","MRS"],[__sfx("Tkw=")]:["AMS"],[__sfx("SVQ=")]:["MXP","FCO"],[__sfx("RVM=")]:["MAD","BCN"],[__sfx("U0U=")]:["ARN"],[__sfx("Q0g=")]:["ZRH"],[__sfx("QVQ=")]:["VIE"],[__sfx("UEw=")]:["WAW"],[__sfx("UlU=")]:["DME","SVO"],[__sfx("VFI=")]:["IST"],[__sfx("QUU=")]:["DXB"],[__sfx("SUw=")]:["TLV"],[__sfx("WkE=")]:["JNB"],[__sfx("QlI=")]:["GRU","GIG"],[__sfx("QVI=")]:["EZE"],[__sfx("Q0w=")]:["SCL"],[__sfx("TVg=")]:["MEX"]},Ps=__sfx("SEtH6aaZ5rivLFRQReWPsOWMlyxOUlTkuJzkuqwsS0lY5aSn6ZiqLElDTummluWwlCxTSU7mlrDliqDlnaEsS1VM5ZCJ6ZqG5Z2hLEJLS+abvOiwtyxTR07og6Hlv5fmmI7luIIsTU5M6ams5bC85ouJLFNZROaCieWwvCxNRUzloqjlsJTmnKwsTEFY5rSb5p2J55+2LFNKQ+Wco+S9leWhnixTRUHopb/pm4Xlm74sT1JE6Iqd5Yqg5ZOlLElBROWNjuebm+mhvyxFV1Lnur3nk6blhYssWVla5aSa5Lym5aSaLFlWUua4qeWTpeWNjixMSFLkvKbmlaYsRlJB5rOV5YWw5YWL56aPLENER+W3tOm7jixBTVPpmL/lp4bmlq/nibnkuLksTUFE6ams5b636YeMLEFSTuaWr+W+t+WTpeWwlOaRqSxJU1TkvIrmlq/lnabluIPlsJQsRFhC6L+q5ouc"),Yi=(()=>{let e={};for(let t of Ps.split(","))t.length>3&&(e[t.slice(0,3)]=t.slice(3));return e})(),Ss=new Map;for(let[e,t]of Object.entries(yr))for(let n of t)Ss.set(n,e);Vi=Object.keys(yr)});var _i,wr=S(()=>{"use strict";_i=new Set("GEOSITE GEOIP GEOIP-CIDR DOMAIN DOMAIN-SUFFIX DOMAIN-KEYWORD IP-CIDR IP-CIDR6 SRC-IP-CIDR DST-PORT SRC-PORT PROCESS-NAME MATCH".split(" "))});var fa,xr=S(()=>{"use strict";K();ee();br();wr();fa=".cn,qq.com,tencent.com,weixin.qq.com,baidu.com,bdstatic.com,bilibili.com,hdslb.com,taobao.com,tmall.com,jd.com,aliyun.com,alicdn.com,alipay.com,163.com,126.net,zhihu.com,weibo.com,sina.com.cn,youku.com,iqiyi.com,douyin.com,xiaohongshu.com,mi.com,huawei.com,csdn.net,gitee.com,cnblogs.com".split(",")});var ha,Pr=S(()=>{"use strict";Qe();ee();ha=new TextEncoder});var Ua,Sr=S(()=>{"use strict";qe();ee();Ua=3600*24});function Er(e){return dr(e)}async function Ar(e,t){if(Te.config&&Date.now()-Te.configAt<Es)return Te.config;let n=await gr(e,t);return Te.config=n,Te.configAt=Date.now(),n}var Es,Te,jt=S(()=>{"use strict";Qe();qe();Sr();Es=15e3,Te={config:null,configAt:0,auth:null,authAt:0}});var Rr={};ve(Rr,{clearUnlockCache:()=>Us,runUnlockProbe:()=>Is});function ks(e,t,n){return e===200?"ok":e===404?t==="status"?"region":"unknown":e===403||e===451?"blocked":t==="trace"&&/\bloc=[A-Z]{2}\b/.test(n)?"ok":"unknown"}async function Ds(e){let t=Date.now(),n=new AbortController,o=setTimeout(()=>n.abort(),Rs);try{let r=await fetch(e.url,{method:"GET",redirect:"manual",signal:n.signal,headers:{"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0 Safari/537.36",Accept:"text/html,application/xhtml+xml,*/*"}}),s="";e.mode==="trace"&&(s=(await r.text()).slice(0,512));let i=/\bloc=([A-Z]{2})\b/.exec(s)?.[1];return{id:e.id,status:r.status,verdict:ks(r.status,e.mode,s),ms:Date.now()-t,...i?{loc:i}:{}}}catch(r){let s=r instanceof Error?r.message:String(r);return{id:e.id,status:0,verdict:"unknown",ms:Date.now()-t,error:/abort/i.test(s)?"timeout":"fetch-failed"}}finally{clearTimeout(o)}}async function Is(e,t){let n=e||"UNK",o=Date.now(),r=me.get(n);if(r&&o-r.at<Cs)return{...r.data,cached:!0};let s=await Promise.all(Ts.map(a=>Ds(a))),i={colo:n,region:t,cached:!1,at:o,targets:s};if(me.size>=vs){let a="",l=Number[__sfx("UE9TSVRJVkVfSU5GSU5JVFk=")];for(let[f,u]of me)u.at<l&&(l=u.at,a=f);a&&me.delete(a)}return me.set(n,{at:o,data:i}),i}function Us(){me.clear()}var Ts,Rs,Cs,vs,me,Cr=S(()=>{"use strict";Ts=[{id:"netflix",url:"https://www.netflix.com/title/81215567",mode:"status"},{id:"youtube",url:"https://www.youtube.com/premium",mode:"status"},{id:"gemini",url:"https://gemini.google.com/",mode:"status"}],Rs=4e3,Cs=600*1e3,vs=16,me=new Map});ee();var Mr=8*1024*1024,Br=2*1024*1024,nn=600*1e3,Hr=6*1024*1024*1024,st=Date.now(),it=0;function rn(e){e-st>=nn&&(st=e,it=0)}function Fr(e,t=Date.now()){rn(t),it+=e}function tn(e){return rn(e),Hr-it}var Gr=(()=>{let e=new Uint8Array(65536),t=2654435769;for(let n=0;n<e.length;n++)t^=t<<13,t^=t>>>17,t^=t<<5,e[n]=t&255;return e})(),Kr=5e3;function jr(e,t=Kr){let n=!1,o=setTimeout(()=>{if(!n){n=!0;try{e(1e3,"Probe idle timeout")}catch{}}},t),r=o;return typeof r?.unref=="function"&&r.unref(),{cancel:()=>{n||(n=!0,clearTimeout(o))}}}async function at(e){let t=new URL(e.url);if(e.headers.get("Upgrade")?.toLowerCase()===__sfx("d2Vic29ja2V0")){let f=new WebSocketPair,[u,c]=Object.values(f);c.accept();let d=jr((g,y)=>c.close(g,y));return c.addEventListener("message",g=>{let y=typeof g.data=="string"?g.data:"";if(y==="PING"||y==="ping"){d.cancel(),c.send(JSON.stringify({pong:!0,colo:e.cf?.colo??"UNK",clientIp:e.headers.get("CF-Connecting-IP")??""}));try{c.close(1e3,"Probe complete")}catch{}return}d.cancel();try{c.close(1e3,"Probe aborted")}catch{}}),c.addEventListener("close",()=>d.cancel()),c.addEventListener("error",()=>d.cancel()),new Response(null,{status:101,[__sfx("d2ViU29ja2V0")]:u})}let o=Number.parseInt(t.searchParams.get("bytes")??"",10),r=Number.isFinite(o)&&o>0?Math.min(o,Mr):Br,s=Date.now();if(tn(s)<=0){let f=Math.max(1e3,st+nn-s);return new Response(JSON.stringify({ok:!1,error:"probe budget exhausted"}),{status:429,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store","Retry-After":String(Math.ceil(f/1e3))}})}let i=Gr,a=0,l=new ReadableStream({pull(f){let u=tn(Date.now());if(a>=r||u<=0){f.close();return}let c=Math.min(i.byteLength,r-a,u);f.enqueue(i.subarray(0,c)),a+=c,Fr(c)}});return new Response(l,{status:200,headers:{"Content-Type":"application/octet-stream","Content-Encoding":"identity","Cache-Control":"no-store","Access-Control-Allow-Origin":"*","X-Probe-Bytes":String(r),"X-Probe-Nonce":De(4)}})}Ut();Bt();Tt();Ft();ee();qe();We();xr();Pr();ee();function Kt(e){let t=e===200?"Welcome":e===404?"Not Found":"Service Unavailable",n=`<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${t}</title><style>body{margin:0;min-height:100vh;display:flex;align-items:center;justify-content:center;background:#f7f8fa;color:#333;font-family:-apple-system,"Segoe UI","PingFang SC",sans-serif}.c{text-align:center}h1{font-size:22px;font-weight:600;margin:0 0 10px}p{color:#888;font-size:14px;margin:0}</style></head><body><div class="c"><h1>${t}</h1><p>This site is up and running.</p></div></body></html>`;return new Response(n,{status:e,headers:{"Content-Type":"text/html; charset=utf-8","Cache-Control":"no-store","X-Content-Type-Options":"nosniff"}})}jt();jt();async function Tr(e){let t=Er(e);return await Ar(t,e)}function Wt(e){let t=[];return t.push(...Se(e[__sfx("cHJveHlJcA==")],"direct")),t.push(...Se(e[__sfx("c29ja3M1")],__sfx("c29ja3M1"))),t.push(...Se(e.httpProxy,"http")),t}var zt=6e4,Os=10,Re=0,$e=0;function vr(e){return e>=$e?(Re=0,$e=e+zt,!1):Re>=Os}function kr(e,t){if(!t)return!1;let n=(e.headers.get(__sfx("eC1jZnBpbG90LXRva2Vu"))??"").trim();if(!n)return!1;let o=Date.now();return ge(n,t)?(Re=0,!0):(o>=$e&&($e=o+zt,Re=0),Re+=1,!1)}async function Dr(e,t,n){let o=new URL(e.url);if(o.pathname===__sfx("L19fZWRnZV9wcm9iZQ=="))return at(e);if(o.pathname===_e||o.pathname===__sfx("L19fdmVyc2lvbg=="))return Je();if(o.pathname==="/region"&&e.method==="GET"){let{coloToCountry:i}=await Promise.resolve().then(()=>(Pe(),St)),a=e.cf?.colo??"",l=a?i(a):"";return new Response(JSON.stringify({ok:!0,colo:a,region:l,timestamp:new Date().toISOString()},null,2),{status:200,headers:{"Content-Type":"application/json; charset=utf-8"}})}let r=await Tr(t);if(o.pathname===__sfx("L19fZGlhZw==")){if(vr(Date.now()))return new Response(JSON.stringify({ok:!1,error:"token attempts throttled"},null,2),{status:429,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store","Retry-After":String(Math.ceil(zt/1e3))}});if(!kr(e,r.uuid))return null;let{recentDiagnostics:i,diagnosticCounters:a,recentRoutes:l}=await Promise.resolve().then(()=>(Ut(),nr)),{[__sfx("cmVjZW50WGh0dHBEaWFnbm9zdGljcw==")]:f}=await Promise.resolve().then(()=>(Bt(),fr));return new Response(JSON.stringify({ok:!0,impl:"self",build:Ht,recent:i(),[__sfx("eGh0dHA=")]:f(),counters:a(),routes:l()},null,2),{status:200,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}})}if(o.pathname==="/__unlock_probe"){if(!r.unlockProbe)return null;if(vr(Date.now()))return new Response(JSON.stringify({ok:!1,error:"token attempts throttled"},null,2),{status:429,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}});if(!kr(e,r.uuid))return null;let{coloToCountry:i}=await Promise.resolve().then(()=>(Pe(),St)),{runUnlockProbe:a}=await Promise.resolve().then(()=>(Cr(),Rr)),l=e.cf?.colo??"",f=l?i(l):"",u=await a(l,f);return new Response(JSON.stringify({ok:!0,...u},null,2),{status:200,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}})}let s=e.headers.get("Upgrade")?.toLowerCase();return o.pathname===r.wsPath?s!==__sfx("d2Vic29ja2V0")?null:await Ve(e,__sfx("dmxlc3M="),r,Wt(r),n):r[__sfx("ZW5hYmxlVHJvamFu")]&&o.pathname===r[__sfx("dHJvamFuUGF0aA==")]?s!==__sfx("d2Vic29ja2V0")?null:await Ve(e,__sfx("dHJvamFu"),r,Wt(r),n):r[__sfx("ZW5hYmxlWGh0dHA=")]&&Lt(o.pathname,r[__sfx("eGh0dHBQYXRo")])?await Mt(e,r,Wt(r)):null}Ft();var Al={async fetch(e,t,n){try{return new URL(e.url).pathname===_e?Je():await Dr(e,t,n)??Kt(200)}catch{return Kt(500)}}};export{Al as default};
5
+ `):__sfx("5Ye656uZ6L+e5o6l5aSx6LSl77ya")+String(H)+"";Q(`${m.hostname}:${m.port}`,P,C),I(1011,C);return}let M=d.writable.getWriter();g=M,er(`${m.hostname}:${m.port}`,d,"initial");let U=l.byteLength>m.headerLength?l.subarray(m.headerLength):new Uint8Array(0);l=new Uint8Array(0);try{await y.run(async()=>{U.byteLength>0&&(et(U),await M.write(U)),await _t(M)})}catch(C){Q(`${m.hostname}:${m.port}`,[],__sfx("5LiK6KGM6aaW5YyF5YaZ5YWl5aSx6LSl77ya")+String(C)+""),h()}r?.waitUntil(Yt())},Qt=async m=>{if(G||R)return;let b=N;if(!b){I(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya55uu5qCH5pyq6Kej5p6Q"));return}if(V>=It){I(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya55u06L+e5LiO5Y+N5Luj5YWl5Y+j5Z2H5peg5ZON5bqU"));return}R=!0;let P=bn({via:d?.via,port:b.port,userProxyConfigured:o.length>0||!!n[__sfx("cHJveHlJcA==")],aggressive:n.aggressiveRedial===!0});if(!P.allowed){de.guardedRedials++,Q(`${b.hostname}:${b.port}`,[],__sfx("5Ye656uZ5peg5pWw5o2u77ya")+P.reason+__sfx("77yb5pyq5YiH5o2i5Y+N5Luj77yI5Y+v5byA5ZCvIGFnZ3Jlc3NpdmVSZWRpYWzvvIk=")),I(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya")+P.reason+"");return}V++,m==="stall"?de.stallRedials++:de.eofRedials++,Q(`${b.hostname}:${b.port}`,[],m==="stall"?__sfx("55u06L+eIA==")+Qn+__sfx("bXMg5peg5LiL6KGM5pWw5o2u77yM5pS56LWw5Y+N5Luj5YWl5Y+j"):__sfx("5Ye656uZ6Zu25LiL6KGM5Y2zIEVPRi9SZXNldO+8jOeri+WNs+aUuei1sOWPjeS7o+WFpeWPow=="));let H=[];try{H=await xe({userEntries:n.relayPool||void 0,useBuiltin:n.useBuiltinRelay})}catch{H=[]}let M=H.filter(U=>!v.has(`${U.ip}:${U.port}`));if(M.length===0){I(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya5peg5Y+N5Luj5YWl5Y+j5Y+v55So"));return}for(let U of M.slice(0,It)){if(v.add(`${U.ip}:${U.port}`),Ir(),d){let C=d;if(C.close)try{C.close()}catch{}}g=null,ae=0;try{let C=await fe({hostname:U.ip,port:U.port,timeoutMs:Jn,resolvePreferred:!1,skipTargetPolicy:!0,proxies:n.aggressiveRedial?o:void 0,proxyMode:n.aggressiveRedial?n.proxyMode:void 0});if(!C)continue;d=C,er(`${b.hostname}:${b.port}`,C,"redial");let he=C.writable.getWriter();g=he;let $t=0;for(let Ce of O)$t+=Ce.byteLength;let rt=new Uint8Array($t),en=0;for(let Ce of O)rt.set(Ce,en),en+=Ce.byteLength;await y.run(async()=>{rt.byteLength>0&&await he.write(rt),await _t(he)}),Q(`${b.hostname}:${b.port}`,[],__sfx("5bey5YiH5o2i5Y+N5Luj5YWl5Y+jIA==")+U.ip+":"+U.port+""),r?.waitUntil(Yt());return}catch(C){Q(`${b.hostname}:${b.port}`,[],__sfx("5Y+N5Luj5YWl5Y+jIA==")+U.ip+":"+U.port+__sfx("IOWksei0pe+8mg==")+String(C)+"")}}I(1011,__sfx("5Ye656uZ5peg5pWw5o2u77ya5omA5pyJ5Y+N5Luj5YWl5Y+j5Z2H5aSx6LSl"))};a.addEventListener("message",m=>{(async()=>{let b=m.data,P=typeof b=="string"?new TextEncoder().encode(b):new Uint8Array(b);if(P.byteLength!==0){if(p(),Vt.add(P.byteLength)){Zt();return}if(!c){if(l=yn(l,P),l.byteLength>Wo){I(1009,__sfx("5o+h5omL5aS06LaF6L+HIDY0S0I="));return}await nt();return}if(Y){Y.push(P);return}if(!g){if(f.push(P),u+=P.byteLength,u>qn){I(1009,__sfx("5ouo5Y+35pyf6Ze05pWw5o2u6L+H5aSa"));return}return}et(P),await Ur(P)}})()});let qt=()=>{h()};a.addEventListener("close",qt),a.addEventListener("error",qt),l.byteLength>0?nt().catch(m=>I(1011,String(m))):T=setTimeout(()=>{T=null,!(G||c||l.byteLength>0)&&(de.firstPacketTimeouts++,I(1008,__sfx("6aaW5YyF6LaF5pe277ya5pyq5pS25Yiw5Y2P6K6u5aS0")))},_o);try{return new Response(null,{status:101,[__sfx("d2ViU29ja2V0")]:i})}catch(m){return console.error(__sfx("W+iHqueglOaVsOaNrumdol0gMTAxIOWTjeW6lOaehOmAoOWksei0pe+8mg=="),m),new Response(null,{status:200})}}var Jn,Qn,It,Wo,qn,zo,ze,Xe,$n,de,Ye,Zo,_o,Ut=S(()=>{"use strict";ct();hn();gn();we();wn();xn();Dt();We();At();Pe();Jn=5e3,Qn=2500,It=2,Wo=64*1024,qn=8*1024*1024,zo=32*1024*1024,ze=0;Xe=[],$n=20,de={stallRedials:0,eofRedials:0,guardedRedials:0,firstPacketTimeouts:0,downlinkYields:0};Ye=[];Zo=2e3,_o=8e3});var fr={};ve(fr,{[__sfx("Y2xlYXJYaHR0cFNlc3Npb25z")]:()=>rs,[__sfx("aGFuZGxlWGh0dHA=")]:()=>Mt,[__sfx("aXNYaHR0cFBhdGg=")]:()=>Lt,[__sfx("cGFyc2VYaHR0cFJvdXRl")]:()=>Nt,[__sfx("cmVjZW50WGh0dHBEaWFnbm9zdGljcw==")]:()=>$o,[__sfx("cmVjb3JkWGh0dHBEaWFnbm9zdGljcw==")]:()=>X});function qo(e,t){return new Promise(n=>{let o=setTimeout(()=>n(null),t);e.then(r=>{clearTimeout(o),n(r)},()=>{clearTimeout(o),n(null)})})}function X(e,t,n){Ze.unshift({at:Date.now(),target:e,...t,summary:n}),Ze.length>20&&(Ze.length=20)}function $o(){return Ze}function es(e){return String(e||"").trim().replace(/\/+$/,"")||"/"}function Nt(e,t){let n=es(t??__sfx("L3hodHRw"));if(e===n||e===`${n}/`)return{kind:"stream-one"};let o=`${n}/`;if(!e.startsWith(o))return null;let r=e.slice(o.length);if(!r)return null;let s=r.split("/");if(s.length===1&&s[0])return/[\s\u0000-\u001f]/.test(s[0])?null:{kind:"session",sessionId:s[0]};if(s.length===2&&s[0]&&/^\d+$/.test(s[1])){if(/[\s\u0000-\u001f]/.test(s[0]))return null;let i=Number(s[1]);return!Number.isSafeInteger(i)||i<0||i>1e6?null:{kind:__sfx("cGFja2V0LXVw"),sessionId:s[0],seq:i}}return null}function Lt(e,t){return Nt(e,t)!==null}function lr(e){if(e.reservedBytes<=0){e.reservedBytes=0;return}Ee=Math.max(0,Ee-e.reservedBytes),e.reservedBytes=0}function ir(e,t){return t<=0?!0:Ee+t>ns?!1:(Ee+=t,e.reservedBytes+=t,!0)}function rs(){for(let[e,t]of W)z(e,t);W.clear(),Ee=0}function os(e,t){return t-e.lastUploadAt>Ot&&t-e.lastDownlinkAt>Ot&&t-e.lastActivityAt>Ot}function ss(e,t){return e.closed?!0:e.header||e.dialResult||e.downlinkStarted?!1:t-e.createdAt>ar}function ur(e,t,n,o){let r=Date.now();for(let[a,l]of W)(l.closed||os(l,r)||r-l.createdAt>30*6e4)&&z(a,l);let s=W.get(e);if(s)return cr(s,n,r),s;if(W.size>=rr){for(let[a,l]of W)ss(l,r)&&z(a,l);if(W.size>=rr)return null}if(!o){let a=0;for(let l of W.values())l.header||(a+=1);if(a>=ts)return null}let i={id:e,createdAt:r,lastUploadAt:r,lastDownlinkAt:r,lastActivityAt:r,header:void 0,headerWaiters:[],dialPromise:null,dialResult:null,pending:new Map,reservedBytes:0,nextPumpSeq:0,pumpStarted:!1,signalResolve:null,traffic:new ue(t),downlinkStarted:!1,closed:!1,targetLabel:""};return W.set(e,i),i}function cr(e,t,n){t==="upload"?e.lastUploadAt=n:e.lastDownlinkAt=n,e.lastActivityAt=n}function z(e,t){if(!t.closed){t.closed=!0;for(let n of t.headerWaiters)try{n(null)}catch{}if(t.headerWaiters=[],t.signalResolve?.(),t.signalResolve=null,t.dialResult?.close)try{t.dialResult.close()}catch{}lr(t),t.pending.clear(),W.delete(e)}}function is(e){let t=e.signalResolve;e.signalResolve=null,t?.()}function as(e,t){return e.header?Promise.resolve(e.header):e.closed?Promise.resolve(null):new Promise(n=>{let o=s=>{clearTimeout(r),n(s)},r=setTimeout(()=>{let s=e.headerWaiters.indexOf(o);s>=0&&e.headerWaiters.splice(s,1),n(null)},t);e.headerWaiters.push(o)})}function ls(e,t){e.header=t;let n=e.headerWaiters;e.headerWaiters=[];for(let o of n)try{o(t)}catch{}}function L(e){let t=100+Math.floor(Math.random()*900);return{"Content-Type":"text/event-stream","Cache-Control":"no-store","X-Accel-Buffering":"no","Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST","X-Padding":"X".repeat(t),...e}}function us(e){let t=e.addons,n=new Uint8Array(2+t.byteLength);return n[0]=e.version,n[1]=t.byteLength,n.set(t,2),n}async function cs(e,t,n){if(e.dialResult)return e.dialResult;if(!e.dialPromise){let o=e.header;if(!o)throw new Error(__sfx("VkxFU1Mg5aS05pyq5Yiw6L6+"));e.targetLabel=`${o.hostname}:${o.port}`,e.dialPromise=fe({hostname:o.hostname,port:o.port,proxies:n,nat64:t.nat64,concurrent:t.concurrentDial,proxyMode:t.proxyMode,resolvePreferred:t.resolvePreferred,relayPool:{userEntries:t.relayPool||void 0,useBuiltin:t.useBuiltinRelay},onFailure:r=>{X(e.targetLabel,r,__sfx("WEhUVFAg5Ye656uZ5aSx6LSl77yI")+r.candidate+"):"+r.message+"")}}).then(r=>(e.dialResult=r,r)).catch(r=>{throw X(e.targetLabel,{kind:"dial",message:String(r),candidate:"all"},__sfx("WEhUVFAg5Ye656uZ5YWo6YOo5aSx6LSl77ya")+String(r)+""),r})}return await e.dialPromise}async function fs(e,t){let n=t.writable.getWriter();try{for(;!e.closed;){let o=e.pending.get(e.nextPumpSeq);if(o){if(e.pending.delete(e.nextPumpSeq),e.nextPumpSeq+=1,lr(e),o.byteLength===0)continue;if(e.traffic.add(o.byteLength)){X(e.targetLabel,{kind:"budget",message:__sfx("5rWB6YeP6LaF6ZmQ"),candidate:"traffic"},__sfx("WEhUVFAg5LiK6KGM5rWB6YeP6LaF6ZmQ"));break}try{await n.write(o)}catch(i){X(e.targetLabel,{kind:"relay-write",message:String(i),candidate:t.endpoint},__sfx("WEhUVFAg5YaZ5YWl55uu5qCH5aSx6LSl77ya")+String(i)+"");break}continue}let r=null,s=new Promise(i=>{r=i});if(e.signalResolve=r,e.pending.has(e.nextPumpSeq)||e.closed){e.signalResolve=null;continue}await s}}finally{try{n.releaseLock()}catch{}}}async function ds(e,t,n,o,r){let s=(t.dataBudgetMB||0)*1024*1024,i=ur(o,s,"upload",r===0);if(!i)return new Response(__sfx("5Lya6K+d5pWw5bey6L6+5LiK6ZmQ77yM6K+356iN5ZCO6YeN6K+V"),{status:503,headers:L()});if(i.closed)return null;let a=Number(e.headers.get("content-length")??"");if(Number.isFinite(a)&&a>or)return new Response(__sfx("5YiG5YyF6LaF5Ye65LiK6ZmQ"),{status:413,headers:L()});let l;try{let f=await e.arrayBuffer();l=new Uint8Array(f)}catch{return new Response(__sfx("6K+35rGC5L2T6K+75Y+W5aSx6LSl"),{status:400,headers:L()})}if(l.byteLength>or)return new Response(__sfx("5YiG5YyF6LaF5Ye65LiK6ZmQ"),{status:413,headers:L()});if(r===0&&!i.header){let f=Ie(l,t.uuid);if(!f)return z(o,i),new Response(__sfx("VkxFU1Mg5aS06Kej5p6Q5aSx6LSl"),{status:400,headers:L()});if(f.header.command!==ut)return z(o,i),new Response(__sfx("WEhUVFAg5pqC5LiN5pSv5oyBIFVEUA=="),{status:400,headers:L()});ls(i,f.header),i.targetLabel=`${f.header.hostname}:${f.header.port}`;let u=l.subarray(f.consumed);if(r>=i.nextPumpSeq&&!i.pending.has(r)){if(i.pending.size>=sr)return z(o,i),new Response(__sfx("5YiG5YyF57yT5a2Y5bey5ruh"),{status:503,headers:L()});if(!ir(i,u.byteLength))return z(o,i),new Response(__sfx("5pqC5a2Y6LaF6ZmQ"),{status:503,headers:L()});i.pending.set(r,u.slice())}}else{if(r<i.nextPumpSeq||i.pending.has(r))return new Response(null,{status:200,headers:L()});if(i.pending.size>=sr)return z(o,i),new Response(__sfx("5YiG5YyF57yT5a2Y5bey5ruh"),{status:503,headers:L()});if(!ir(i,l.byteLength))return z(o,i),new Response(__sfx("5pqC5a2Y6LaF6ZmQ"),{status:503,headers:L()});i.pending.set(r,l.slice())}return is(i),new Response(null,{status:200,headers:L()})}async function ps(e,t,n,o){let r=(t.dataBudgetMB||0)*1024*1024,s=ur(o,r,"downlink",!1);if(!s)return new Response(__sfx("5Lya6K+d5pWw5bey6L6+5LiK6ZmQ77yM6K+356iN5ZCO6YeN6K+V"),{status:503,headers:L()});if(s.closed||s.downlinkStarted)return null;s.downlinkStarted=!0;let i=as(s,ar),a=!1,l=null,f=null,u=!1,c=null,d=()=>{z(o,s)},g=new ReadableStream({start(y){f=y},async pull(y){if(!a)try{if(!u){let p=await i;if(a)return;if(!p){d(),y.close();return}try{c=await cs(s,t,n)}catch{d(),y.close();return}if(a)return;s.pumpStarted||(s.pumpStarted=!0,fs(s,c).catch(()=>{}));try{y.enqueue(us(p))}catch{}u=!0;return}if(!c)return;l||(l=c.readable.getReader());let{done:x,value:T}=await l.read();if(a)return;if(x){d();try{y.close()}catch{}return}if(T&&T.byteLength>0){if(cr(s,"downlink",Date.now()),s.traffic.add(T.byteLength)){X(s.targetLabel,{kind:"budget",message:__sfx("5rWB6YeP6LaF6ZmQ"),candidate:"traffic"},__sfx("WEhUVFAg5LiL6KGM5rWB6YeP6LaF6ZmQ")),d();try{y.close()}catch{}return}y.enqueue(T)}}catch(x){if(a)return;d();try{y.error(x)}catch{}}},cancel(y){if(a=!0,c)try{c.readable.cancel(y)}catch{}d()}});return new Response(g,{status:200,headers:L()})}async function Mt(e,t,n){let o=__sfx("L3hodHRw");try{o=new URL(e.url).pathname}catch{o=__sfx("L3hodHRw")}let r=Nt(o,t[__sfx("eGh0dHBQYXRo")]);return r?r.kind==="stream-one"?e.method!=="POST"?null:await ms(e,t,n):r.kind===__sfx("cGFja2V0LXVw")?e.method!=="POST"?null:await ds(e,t,n,r.sessionId,r.seq):e.method==="GET"?await ps(e,t,n,r.sessionId):null:null}async function ms(e,t,n){let o=e.body;if(!o)return new Response(__sfx("57y65bCR6K+35rGC5L2T"),{status:400});let r=new ne(o),s=await qo(ln(r,t.uuid),Qo);if(!s)return await r.cancel("header timeout"),new Response(__sfx("VkxFU1Mg5aS06Kej5p6Q5aSx6LSl"),{status:400});if(s.header.command!==ut)return await s.payload.cancel("unsupported UDP"),new Response(__sfx("WEhUVFAg5pqC5LiN5pSv5oyBIFVEUA=="),{status:400});let i;try{i=await fe({hostname:s.header.hostname,port:s.header.port,proxies:n,nat64:t.nat64,concurrent:t.concurrentDial,proxyMode:t.proxyMode,resolvePreferred:t.resolvePreferred,relayPool:{userEntries:t.relayPool||void 0,useBuiltin:t.useBuiltinRelay},onFailure:p=>{X(`${s.header.hostname}:${s.header.port}`,p,__sfx("WEhUVFAg5Ye656uZ5aSx6LSl77yI")+p.candidate+"):"+p.message+"")}})}catch(p){X(`${s.header.hostname}:${s.header.port}`,{kind:"dial",message:String(p),candidate:"all"},__sfx("WEhUVFAg5Ye656uZ5YWo6YOo5aSx6LSl77ya")+String(p)+"");try{s.payload.cancel("dial failed").catch(()=>{})}catch{}return new Response(__sfx("5Ye656uZ5LiN5Y+v55So"),{status:502})}let a=s.header.addons;if(a.byteLength>255)return new Response(__sfx("QWRkb25zIOmVv+W6pui2heWHuiBWTEVTUyDljY/orq7kuIrpmZA="),{status:400});let l=new Uint8Array(2+a.byteLength);l[0]=s.header.version,l[1]=a.byteLength,l.set(a,2);let f=!1,u=null,c=!1,d=new ue((t.dataBudgetMB||0)*1024*1024),g=null,y=()=>{if(c)return;c=!0;let p=__sfx("5Y2V6L+e5o6l5rWB6YeP6LaF6L+HIA==")+t.dataBudgetMB+__sfx("TUIg5LiK6ZmQ");if(X(`${s.header.hostname}:${s.header.port}`,{kind:"budget",message:p,candidate:"traffic"},p),i.close)try{i.close()}catch{}try{g?.close()}catch{}},x=p=>d.add(p)?(y(),!0):!1;_n(s.payload,i.writable,void 0,!1,x,(p,R)=>{let E=p instanceof Error?p.message:String(p),k=`relay-${R}`;/cancel|abort|closed/i.test(E)?k=`relay-${R}-client-cancel`:/reset|broken pipe/i.test(E)&&(k=`relay-${R}-upstream-reset`),X(`${s.header.hostname}:${s.header.port}`,{kind:k,message:E.slice(0,200),candidate:i.endpoint},__sfx("WEhUVFAg5Lit57un")+R==="read"?"\u8BFB\u4E0A\u6E38":"\u5199\u76EE\u6807"+__sfx("5aSx6LSl77yI")+k+"):"+E.slice(0,120)+"")}).catch(()=>{});let T=new ReadableStream({start(p){g=p,p.enqueue(l),f=!0},async pull(p){if(!(c||!f)){u||(u=i.readable.getReader());try{let{done:R,value:E}=await u.read();if(c)return;if(R){if(i.close)try{i.close()}catch{}p.close();return}if(E&&E.byteLength>0){if(d.add(E.byteLength)){y();return}p.enqueue(E)}}catch(R){if(c)return;if(i.close)try{i.close()}catch{}try{p.error(R)}catch{}}}},cancel(p){c=!0;try{i.readable.cancel(p)}catch{}if(i.close)try{i.close()}catch{}}});return new Response(T,{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-store","X-Accel-Buffering":"no"}})}var Qo,Ze,W,ar,rr,ts,Ot,or,sr,ns,Ee,Bt=S(()=>{"use strict";we();ct();We();Dt();Qo=2e3;Ze=[];W=new Map,ar=3e4,rr=100,ts=20,Ot=10*6e4,or=10*1024*1024,sr=30,ns=32*1024*1024,Ee=0});function Je(){return new Response(JSON.stringify({build:Ht,version:hs,ts:Date.now()}),{status:200,headers:{"Content-Type":"application/json","Cache-Control":"no-store","Access-Control-Allow-Origin":"*"}})}var Ht,hs,_e,Ft=S(()=>{"use strict";Ht="013d2bc-050a325a",hs=__sfx("MC4zMC4y"),_e=__sfx("L19fY2ZwX3ZlcnNpb24=")});function dr(e){return e[__sfx("S1Y=")]?new pe(e[__sfx("S1Y=")]):new Gt}var pe,Gt,Qe=S(()=>{"use strict";pe=class{constructor(t){this.kv=t}kv;async get(t){return await this.kv.get(t)}async put(t,n,o){o&&o>=60?await this.kv.put(t,n,{expirationTtl:o}):await this.kv.put(t,n)}async delete(t){await this.kv.delete(t)}async list(t){let n=[],o;do{let r=await this.kv.list({prefix:t,cursor:o});for(let s of r.keys)n.push(s.name);o=r.list_complete?void 0:r.cursor}while(o);return n}},Gt=class{data=new Map;async get(t){let n=this.data.get(t);return n?n.expiresAt>0&&n.expiresAt<=Date.now()?(this.data.delete(t),null):n.value:null}async put(t,n,o){let r=o?Date.now()+o*1e3:0;this.data.set(t,{value:n,expiresAt:r})}async delete(t){this.data.delete(t)}async list(t){return[...this.data.keys()].filter(n=>n.startsWith(t))}}});function ce(e,t){if(e==null)return t;let n=String(e).trim();if(n==="")return t;let o=Number(n);return Number.isFinite(o)?o:t}function F(e,t){if(e==null||e==="")return t;let n=String(e).trim().toLowerCase();return["1","true","yes","on"].includes(n)?!0:["0","false","no","off"].includes(n)?!1:t}function gs(e){let t=e.trim().toLowerCase();return t==="global"||t==="fallback"||t==="smart"?t:"only"}function mr(e){return e.trim().toLowerCase()==="signed"?"signed":"legacy"}function hr(e){return e.trim().toLowerCase()==="doh"?"doh":"off"}function D(e,t){return e==null?t:String(e)}function ys(e){return{uuid:D(e[__sfx("VVVJRA==")],""),[__sfx("dHJvamFuUGFzc3dvcmQ=")]:D(e[__sfx("VFJPSkFOX1BBU1NXT1JE")],""),wsPath:D(e[__sfx("V1NfUEFUSA==")]||e[__sfx("UEFUSA==")],A.wsPath),[__sfx("dHJvamFuUGF0aA==")]:A[__sfx("dHJvamFuUGF0aA==")],[__sfx("eGh0dHBQYXRo")]:A[__sfx("eGh0dHBQYXRo")],add:D(e[__sfx("QURE")],""),addApi:D(e[__sfx("QUREQVBJ")],""),addCsv:D(e[__sfx("QUREX0NTVg==")],""),poolOfficial:F(e[__sfx("T0ZGSUNJQUxfSVA=")],A.poolOfficial),officialCount:ce(e[__sfx("T0ZGSUNJQUxfSVBfQ09VTlQ=")],A.officialCount),poolDomain:F(e[__sfx("UFJFRkVSUkVEX0RPTUFJTg==")],A.poolDomain),domainCount:ce(e[__sfx("UFJFRkVSUkVEX0RPTUFJTl9DT1VOVA==")],A.domainCount),poolManual:F(e[__sfx("TUFOVUFMX0lQ")],A.poolManual),poolCountries:D(e[__sfx("UE9PTF9DT1VOVFJJRVM=")],A.poolCountries),dls:ce(e[__sfx("RExT")],0),maxLatency:ce(e[__sfx("TUFYX0xBVEVOQ1k=")],0),maxNodes:0,[__sfx("cHJveHlJcA==")]:D(e[__sfx("UFJPWFlJUA==")],""),[__sfx("c29ja3M1")]:D(e[__sfx("U09DS1M1")],""),httpProxy:D(e[__sfx("SFRUUF9QUk9YWQ==")],""),proxyMode:gs(D(e[__sfx("UFJPWFlfTU9ERQ==")],"")),nat64:D(e[__sfx("TkFUNjQ=")],""),concurrentDial:F(e[__sfx("VENQX0NPTkNVUlJFTlRfRElBTA==")],!0),dataBudgetMB:ce(e[__sfx("REFUQV9CVURHRVRfTUI=")],A.dataBudgetMB),resolvePreferred:F(e[__sfx("UkVTT0xWRV9QUkVGRVJSRUQ=")],A.resolvePreferred),aggressiveRedial:F(e[__sfx("QUdHUkVTU0lWRV9SRURJQUw=")],A.aggressiveRedial),relayPool:D(e[__sfx("UkVMQVlfUE9PTA==")],""),useBuiltinRelay:F(e[__sfx("VVNFX0JVSUxUSU5fUkVMQVk=")],A.useBuiltinRelay),[__sfx("ZW5hYmxlVHJvamFu")]:F(e[__sfx("RU5BQkxFX1RST0pBTg==")]??e[__sfx("VFJPSkFO")],A[__sfx("ZW5hYmxlVHJvamFu")]),[__sfx("ZW5hYmxlWGh0dHA=")]:F(e[__sfx("RU5BQkxFX1hIVFRQ")]??e[__sfx("WEhUVFA=")],A[__sfx("ZW5hYmxlWGh0dHA=")]),subDomain:"",subProtocol:"both",subTransport:"both",subVariants:D(e[__sfx("U1VCX1ZBUklBTlRT")],A.subVariants),subName:D(e[__sfx("U1VCX05BTUU=")],A.subName).trim()||A.subName,subPorts:D(e[__sfx("U1VCX1BPUlRT")],A.subPorts),clientFingerprint:A.clientFingerprint,ech:F(e[__sfx("RUNI")],A.ech),echHost:D(e[__sfx("RUNIX0hPU1Q=")],A.echHost),echDns:D(e[__sfx("RUNIX0ROUw==")],A.echDns),tlsFragment:!1,tlsFragmentSize:A.tlsFragmentSize,tlsFragmentDelay:A.tlsFragmentDelay,subToken:mr(D(e[__sfx("U1VCX1RPS0VOX01PREU=")],"")),subTokenTtlDays:ce(e[__sfx("U1VCX1RPS0VOX1RUTF9EQVlT")],A.subTokenTtlDays),unlockProbe:F(e[__sfx("VU5MT0NLX1BST0JF")],A.unlockProbe),udpDns:hr(D(e[__sfx("VURQX0ROUw==")],"")),udpDnsEndpoint:D(e[__sfx("VURQX0ROU19FTkRQT0lOVA==")],A.udpDnsEndpoint)}}function bs(e,t){let n={...e};for(let[o,r]of Object.entries(t))if(r!=null)if(o==="dls"||o==="maxLatency"||o==="maxNodes"||o==="officialCount"||o==="domainCount"||o==="dataBudgetMB"||o==="subTokenTtlDays")n[o]=ce(r,0);else if(o==="concurrentDial"||o==="resolvePreferred"||o==="aggressiveRedial"||o==="useBuiltinRelay"||o===__sfx("ZW5hYmxlVHJvamFu")||o===__sfx("ZW5hYmxlWGh0dHA=")||o==="tlsFragment"||o==="ech"||o==="poolOfficial"||o==="poolDomain"||o==="poolManual"||o==="unlockProbe")n[o]=F(r,!1);else if(o==="subProtocol"){let s=String(r);n[o]=s===__sfx("dmxlc3M=")||s===__sfx("dHJvamFu")||s==="both"?s:"both"}else if(o==="subTransport"){let s=String(r);n[o]=s==="ws"||s===__sfx("eGh0dHA=")||s==="both"?s:"both"}else o==="subToken"?n[o]=mr(String(r)):o==="udpDns"?n[o]=hr(String(r)):n[o]=String(r);return n}async function gr(e,t){let n=ys(t),o=await e.get(pr),r={};if(o)try{r=JSON.parse(o)}catch{r={}}let s=bs(n,r),i=!1,a=e instanceof pe,l=Date.now();o?Ae=0:Ae===0&&(Ae=l);let f=l-Ae>ws;return a&&f&&(s.uuid||(s.uuid=ot(),i=!0),s[__sfx("dHJvamFuUGFzc3dvcmQ=")]||(s[__sfx("dHJvamFuUGFzc3dvcmQ=")]=ot().replace(/-/g,"").slice(0,16),i=!0),Ae=0),o&&(s.officialCount<1||s.domainCount<1)&&(s.officialCount<1&&(s.officialCount=A.officialCount,i=!0),s.domainCount<1&&(s.domainCount=A.domainCount,i=!0)),i&&await xs(e,s),s}async function xs(e,t){await e.put(pr,JSON.stringify(t))}var pr,A,Ae,ws,qe=S(()=>{"use strict";ee();Qe();pr="CONFIG",A={uuid:"",[__sfx("dHJvamFuUGFzc3dvcmQ=")]:"",wsPath:__sfx("L3ZsZXNz"),[__sfx("dHJvamFuUGF0aA==")]:__sfx("L3Ryb2phbg=="),[__sfx("eGh0dHBQYXRo")]:__sfx("L3hodHRw"),add:"",addApi:"",addCsv:"",poolOfficial:!0,officialCount:20,poolDomain:!0,domainCount:10,poolManual:!0,poolCountries:"",dls:0,maxLatency:0,maxNodes:0,[__sfx("cHJveHlJcA==")]:"",[__sfx("c29ja3M1")]:"",httpProxy:"",proxyMode:"only",nat64:"",concurrentDial:!0,dataBudgetMB:0,resolvePreferred:!0,aggressiveRedial:!1,relayPool:"",useBuiltinRelay:!0,[__sfx("ZW5hYmxlVHJvamFu")]:!0,[__sfx("ZW5hYmxlWGh0dHA=")]:!0,subDomain:"",subProtocol:__sfx("dmxlc3M="),subTransport:"ws",subVariants:__sfx("dmxlc3Mtd3M="),subName:__sfx("Q0ZQaWxvdA=="),subPorts:"443",clientFingerprint:"chrome",ech:!1,echHost:__sfx("Y2xvdWRmbGFyZS1lY2guY29t"),echDns:"",tlsFragment:!1,tlsFragmentSize:"10-20",tlsFragmentDelay:"10-20",subToken:"legacy",subTokenTtlDays:0,unlockProbe:!1,udpDns:"off",udpDnsEndpoint:"https://dns.google/dns-query"};Ae=0,ws=9e4});var yr,Ps,Yi,Ss,Vi,br=S(()=>{"use strict";yr={[__sfx("SEs=")]:["HKG"],[__sfx("VFc=")]:["TPE","KHH"],[__sfx("SlA=")]:["NRT","KIX","CTS","FUK"],[__sfx("S1I=")]:["ICN","PUS"],[__sfx("U0c=")]:["SIN"],[__sfx("TVk=")]:["KUL"],[__sfx("VEg=")]:["BKK"],[__sfx("Vk4=")]:["SGN","HAN"],[__sfx("SUQ=")]:["CGK","DPS"],[__sfx("UEg=")]:["MNL"],[__sfx("SU4=")]:["BOM","MAA","DEL"],[__sfx("QVU=")]:["SYD","MEL","BNE","PER"],[__sfx("Tlo=")]:["AKL"],[__sfx("VVM=")]:["LAX","SJC","SEA","ORD","DFW","IAD","EWR","ATL","MIA","DEN","PHX","BOS"],[__sfx("Q0E=")]:["YYZ","YVR","YYC"],[__sfx("R0I=")]:["LHR","MAN"],[__sfx("REU=")]:["FRA","MUC","BER"],[__sfx("RlI=")]:["CDG","MRS"],[__sfx("Tkw=")]:["AMS"],[__sfx("SVQ=")]:["MXP","FCO"],[__sfx("RVM=")]:["MAD","BCN"],[__sfx("U0U=")]:["ARN"],[__sfx("Q0g=")]:["ZRH"],[__sfx("QVQ=")]:["VIE"],[__sfx("UEw=")]:["WAW"],[__sfx("UlU=")]:["DME","SVO"],[__sfx("VFI=")]:["IST"],[__sfx("QUU=")]:["DXB"],[__sfx("SUw=")]:["TLV"],[__sfx("WkE=")]:["JNB"],[__sfx("QlI=")]:["GRU","GIG"],[__sfx("QVI=")]:["EZE"],[__sfx("Q0w=")]:["SCL"],[__sfx("TVg=")]:["MEX"]},Ps=__sfx("SEtH6aaZ5rivLFRQReWPsOWMlyxOUlTkuJzkuqwsS0lY5aSn6ZiqLElDTummluWwlCxTSU7mlrDliqDlnaEsS1VM5ZCJ6ZqG5Z2hLEJLS+abvOiwtyxTR07og6Hlv5fmmI7luIIsTU5M6ams5bC85ouJLFNZROaCieWwvCxNRUzloqjlsJTmnKwsTEFY5rSb5p2J55+2LFNKQ+Wco+S9leWhnixTRUHopb/pm4Xlm74sT1JE6Iqd5Yqg5ZOlLElBROWNjuebm+mhvyxFV1Lnur3nk6blhYssWVla5aSa5Lym5aSaLFlWUua4qeWTpeWNjixMSFLkvKbmlaYsRlJB5rOV5YWw5YWL56aPLENER+W3tOm7jixBTVPpmL/lp4bmlq/nibnkuLksTUFE6ams5b636YeMLEFSTuaWr+W+t+WTpeWwlOaRqSxJU1TkvIrmlq/lnabluIPlsJQsRFhC6L+q5ouc"),Yi=(()=>{let e={};for(let t of Ps.split(","))t.length>3&&(e[t.slice(0,3)]=t.slice(3));return e})(),Ss=new Map;for(let[e,t]of Object.entries(yr))for(let n of t)Ss.set(n,e);Vi=Object.keys(yr)});var _i,wr=S(()=>{"use strict";_i=new Set("GEOSITE GEOIP GEOIP-CIDR DOMAIN DOMAIN-SUFFIX DOMAIN-KEYWORD IP-CIDR IP-CIDR6 SRC-IP-CIDR DST-PORT SRC-PORT PROCESS-NAME MATCH".split(" "))});var fa,xr=S(()=>{"use strict";K();ee();br();wr();fa=".cn,qq.com,tencent.com,weixin.qq.com,baidu.com,bdstatic.com,bilibili.com,hdslb.com,taobao.com,tmall.com,jd.com,aliyun.com,alicdn.com,alipay.com,163.com,126.net,zhihu.com,weibo.com,sina.com.cn,youku.com,iqiyi.com,douyin.com,xiaohongshu.com,mi.com,huawei.com,csdn.net,gitee.com,cnblogs.com".split(",")});var ha,Pr=S(()=>{"use strict";Qe();ee();ha=new TextEncoder});var Ua,Sr=S(()=>{"use strict";qe();ee();Ua=3600*24});function Er(e){return dr(e)}async function Ar(e,t){if(Te.config&&Date.now()-Te.configAt<Es)return Te.config;let n=await gr(e,t);return Te.config=n,Te.configAt=Date.now(),n}var Es,Te,jt=S(()=>{"use strict";Qe();qe();Sr();Es=15e3,Te={config:null,configAt:0,auth:null,authAt:0}});var Rr={};ve(Rr,{clearUnlockCache:()=>Us,runUnlockProbe:()=>Is});function ks(e,t,n){return e===200?"ok":e===404?t==="status"?"region":"unknown":e===403||e===451?"blocked":t==="trace"&&/\bloc=[A-Z]{2}\b/.test(n)?"ok":"unknown"}async function Ds(e){let t=Date.now(),n=new AbortController,o=setTimeout(()=>n.abort(),Rs);try{let r=await fetch(e.url,{method:"GET",redirect:"manual",signal:n.signal,headers:{"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0 Safari/537.36",Accept:"text/html,application/xhtml+xml,*/*"}}),s="";e.mode==="trace"&&(s=(await r.text()).slice(0,512));let i=/\bloc=([A-Z]{2})\b/.exec(s)?.[1];return{id:e.id,status:r.status,verdict:ks(r.status,e.mode,s),ms:Date.now()-t,...i?{loc:i}:{}}}catch(r){let s=r instanceof Error?r.message:String(r);return{id:e.id,status:0,verdict:"unknown",ms:Date.now()-t,error:/abort/i.test(s)?"timeout":"fetch-failed"}}finally{clearTimeout(o)}}async function Is(e,t){let n=e||"UNK",o=Date.now(),r=me.get(n);if(r&&o-r.at<Cs)return{...r.data,cached:!0};let s=await Promise.all(Ts.map(a=>Ds(a))),i={colo:n,region:t,cached:!1,at:o,targets:s};if(me.size>=vs){let a="",l=Number[__sfx("UE9TSVRJVkVfSU5GSU5JVFk=")];for(let[f,u]of me)u.at<l&&(l=u.at,a=f);a&&me.delete(a)}return me.set(n,{at:o,data:i}),i}function Us(){me.clear()}var Ts,Rs,Cs,vs,me,Cr=S(()=>{"use strict";Ts=[{id:"netflix",url:"https://www.netflix.com/title/81215567",mode:"status"},{id:"youtube",url:"https://www.youtube.com/premium",mode:"status"},{id:"gemini",url:"https://gemini.google.com/",mode:"status"}],Rs=4e3,Cs=600*1e3,vs=16,me=new Map});ee();var Mr=8*1024*1024,Br=2*1024*1024,nn=600*1e3,Hr=6*1024*1024*1024,st=Date.now(),it=0;function rn(e){e-st>=nn&&(st=e,it=0)}function Fr(e,t=Date.now()){rn(t),it+=e}function tn(e){return rn(e),Hr-it}var Gr=(()=>{let e=new Uint8Array(65536),t=2654435769;for(let n=0;n<e.length;n++)t^=t<<13,t^=t>>>17,t^=t<<5,e[n]=t&255;return e})(),Kr=5e3;function jr(e,t=Kr){let n=!1,o=setTimeout(()=>{if(!n){n=!0;try{e(1e3,"Probe idle timeout")}catch{}}},t),r=o;return typeof r?.unref=="function"&&r.unref(),{cancel:()=>{n||(n=!0,clearTimeout(o))}}}async function at(e){let t=new URL(e.url);if(e.headers.get("Upgrade")?.toLowerCase()===__sfx("d2Vic29ja2V0")){let f=new WebSocketPair,[u,c]=Object.values(f);c.accept();let d=jr((g,y)=>c.close(g,y));return c.addEventListener("message",g=>{let y=typeof g.data=="string"?g.data:"";if(y==="PING"||y==="ping"){d.cancel(),c.send(JSON.stringify({pong:!0,colo:e.cf?.colo??"UNK",clientIp:e.headers.get("CF-Connecting-IP")??""}));try{c.close(1e3,"Probe complete")}catch{}return}d.cancel();try{c.close(1e3,"Probe aborted")}catch{}}),c.addEventListener("close",()=>d.cancel()),c.addEventListener("error",()=>d.cancel()),new Response(null,{status:101,[__sfx("d2ViU29ja2V0")]:u})}let o=Number.parseInt(t.searchParams.get("bytes")??"",10),r=Number.isFinite(o)&&o>0?Math.min(o,Mr):Br,s=Date.now();if(tn(s)<=0){let f=Math.max(1e3,st+nn-s);return new Response(JSON.stringify({ok:!1,error:"probe budget exhausted"}),{status:429,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store","Retry-After":String(Math.ceil(f/1e3))}})}let i=Gr,a=0,l=new ReadableStream({pull(f){let u=tn(Date.now());if(a>=r||u<=0){f.close();return}let c=Math.min(i.byteLength,r-a,u);f.enqueue(i.subarray(0,c)),a+=c,Fr(c)}});return new Response(l,{status:200,headers:{"Content-Type":"application/octet-stream","Content-Encoding":"identity","Cache-Control":"no-store","Access-Control-Allow-Origin":"*","X-Probe-Bytes":String(r),"X-Probe-Nonce":De(4)}})}Ut();Bt();Tt();Ft();ee();qe();We();xr();Pr();ee();function Kt(e){let t=e===200?"Welcome":e===404?"Not Found":"Service Unavailable",n=`<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${t}</title><style>body{margin:0;min-height:100vh;display:flex;align-items:center;justify-content:center;background:#f7f8fa;color:#333;font-family:-apple-system,"Segoe UI","PingFang SC",sans-serif}.c{text-align:center}h1{font-size:22px;font-weight:600;margin:0 0 10px}p{color:#888;font-size:14px;margin:0}</style></head><body><div class="c"><h1>${t}</h1><p>This site is up and running.</p></div></body></html>`;return new Response(n,{status:e,headers:{"Content-Type":"text/html; charset=utf-8","Cache-Control":"no-store","X-Content-Type-Options":"nosniff"}})}jt();jt();async function Tr(e){let t=Er(e);return await Ar(t,e)}function Wt(e){let t=[];return t.push(...Se(e[__sfx("cHJveHlJcA==")],"direct")),t.push(...Se(e[__sfx("c29ja3M1")],__sfx("c29ja3M1"))),t.push(...Se(e.httpProxy,"http")),t}var zt=6e4,Os=10,Re=0,$e=0;function vr(e){return e>=$e?(Re=0,$e=e+zt,!1):Re>=Os}function kr(e,t){if(!t)return!1;let n=(e.headers.get(__sfx("eC1jZnBpbG90LXRva2Vu"))??"").trim();if(!n)return!1;let o=Date.now();return ge(n,t)?(Re=0,!0):(o>=$e&&($e=o+zt,Re=0),Re+=1,!1)}async function Dr(e,t,n){let o=new URL(e.url);if(o.pathname===__sfx("L19fZWRnZV9wcm9iZQ=="))return at(e);if(o.pathname===_e||o.pathname===__sfx("L19fdmVyc2lvbg=="))return Je();if(o.pathname==="/region"&&e.method==="GET"){let{coloToCountry:i}=await Promise.resolve().then(()=>(Pe(),St)),a=e.cf?.colo??"",l=a?i(a):"";return new Response(JSON.stringify({ok:!0,colo:a,region:l,timestamp:new Date().toISOString()},null,2),{status:200,headers:{"Content-Type":"application/json; charset=utf-8"}})}let r=await Tr(t);if(o.pathname===__sfx("L19fZGlhZw==")){if(vr(Date.now()))return new Response(JSON.stringify({ok:!1,error:"token attempts throttled"},null,2),{status:429,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store","Retry-After":String(Math.ceil(zt/1e3))}});if(!kr(e,r.uuid))return null;let{recentDiagnostics:i,diagnosticCounters:a,recentRoutes:l}=await Promise.resolve().then(()=>(Ut(),nr)),{[__sfx("cmVjZW50WGh0dHBEaWFnbm9zdGljcw==")]:f}=await Promise.resolve().then(()=>(Bt(),fr));return new Response(JSON.stringify({ok:!0,impl:"self",build:Ht,recent:i(),[__sfx("eGh0dHA=")]:f(),counters:a(),routes:l()},null,2),{status:200,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}})}if(o.pathname==="/__unlock_probe"){if(!r.unlockProbe)return null;if(vr(Date.now()))return new Response(JSON.stringify({ok:!1,error:"token attempts throttled"},null,2),{status:429,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}});if(!kr(e,r.uuid))return null;let{coloToCountry:i}=await Promise.resolve().then(()=>(Pe(),St)),{runUnlockProbe:a}=await Promise.resolve().then(()=>(Cr(),Rr)),l=e.cf?.colo??"",f=l?i(l):"",u=await a(l,f);return new Response(JSON.stringify({ok:!0,...u},null,2),{status:200,headers:{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}})}let s=e.headers.get("Upgrade")?.toLowerCase();return o.pathname===r.wsPath?s!==__sfx("d2Vic29ja2V0")?null:await Ve(e,__sfx("dmxlc3M="),r,Wt(r),n):r[__sfx("ZW5hYmxlVHJvamFu")]&&o.pathname===r[__sfx("dHJvamFuUGF0aA==")]?s!==__sfx("d2Vic29ja2V0")?null:await Ve(e,__sfx("dHJvamFu"),r,Wt(r),n):r[__sfx("ZW5hYmxlWGh0dHA=")]&&Lt(o.pathname,r[__sfx("eGh0dHBQYXRo")])?await Mt(e,r,Wt(r)):null}Ft();var Al={async fetch(e,t,n){try{return new URL(e.url).pathname===_e?Je():await Dr(e,t,n)??Kt(200)}catch{return Kt(500)}}};export{Al as default};