class e{static name="Lodash";static version="1.2.2";static about(){return console.log(`\n🟧 ${this.name} v${this.version}\n`)}static get(e={},t="",s=void 0){Array.isArray(t)||(t=this.toPath(t));const n=t.reduce(((e,t)=>Object(e)[t]),e);return void 0===n?s:n}static set(e={},t="",s){return Array.isArray(t)||(t=this.toPath(t)),t.slice(0,-1).reduce(((e,s,n)=>Object(e[s])===e[s]?e[s]:e[s]=/^\d+$/.test(t[n+1])?[]:{}),e)[t[t.length-1]]=s,e}static unset(e={},t=""){return Array.isArray(t)||(t=this.toPath(t)),t.reduce(((e,s,n)=>n===t.length-1?(delete e[s],!0):Object(e)[s]),e)}static toPath(e){return e.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean)}static escape(e){const t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,(e=>t[e]))}static unescape(e){const t={"&":"&","<":"<",">":">",""":'"',"'":"'"};return e.replace(/&|<|>|"|'/g,(e=>t[e]))}}class t{static name="$Storage";static version="1.0.9";static about(){return console.log(`\n🟧 ${this.name} v${this.version}\n`)}static data=null;static dataFile="box.dat";static#e=/^@(?[^.]+)(?:\.(?.*))?$/;static#t(){return"undefined"!=typeof $environment&&$environment["surge-version"]?"Surge":"undefined"!=typeof $environment&&$environment["stash-version"]?"Stash":"undefined"!=typeof module&&module.exports?"Node.js":"undefined"!=typeof $task?"Quantumult X":"undefined"!=typeof $loon?"Loon":"undefined"!=typeof $rocket?"Shadowrocket":"undefined"!=typeof Egern?"Egern":void 0}static getItem(t=new String,s=null){let n=s;if(!0===t.startsWith("@")){const{key:s,path:o}=t.match(this.#e)?.groups;t=s;let a=this.getItem(t,{});"object"!=typeof a&&(a={}),n=e.get(a,o);try{n=JSON.parse(n)}catch(e){}}else{switch(this.#t()){case"Surge":case"Loon":case"Stash":case"Egern":case"Shadowrocket":n=$persistentStore.read(t);break;case"Quantumult X":n=$prefs.valueForKey(t);break;case"Node.js":this.data=this.#s(this.dataFile),n=this.data?.[t];break;default:n=this.data?.[t]||null}try{n=JSON.parse(n)}catch(e){}}return n??s}static setItem(t=new String,s=new String){let n=!1;if("object"==typeof s)s=JSON.stringify(s);else s=String(s);if(!0===t.startsWith("@")){const{key:o,path:a}=t.match(this.#e)?.groups;t=o;let r=this.getItem(t,{});"object"!=typeof r&&(r={}),e.set(r,a,s),n=this.setItem(t,r)}else switch(this.#t()){case"Surge":case"Loon":case"Stash":case"Egern":case"Shadowrocket":n=$persistentStore.write(s,t);break;case"Quantumult X":n=$prefs.setValueForKey(s,t);break;case"Node.js":this.data=this.#s(this.dataFile),this.data[t]=s,this.#n(this.dataFile),n=!0;break;default:n=this.data?.[t]||null}return n}static removeItem(t){let s=!1;if(!0===t.startsWith("@")){const{key:n,path:o}=t.match(this.#e)?.groups;t=n;let a=this.getItem(t);"object"!=typeof a&&(a={}),keyValue=e.unset(a,o),s=this.setItem(t,a)}else switch(this.#t()){case"Surge":case"Loon":case"Stash":case"Egern":case"Shadowrocket":case"Node.js":default:s=!1;break;case"Quantumult X":s=$prefs.removeValueForKey(t)}return s}static clear(){let e=!1;switch(this.#t()){case"Surge":case"Loon":case"Stash":case"Egern":case"Shadowrocket":case"Node.js":default:e=!1;break;case"Quantumult X":e=$prefs.removeAllValues()}return e}static#s(e){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(e),s=this.path.resolve(process.cwd(),e),n=this.fs.existsSync(t),o=!n&&this.fs.existsSync(s);if(!n&&!o)return{};{const e=n?t:s;try{return JSON.parse(this.fs.readFileSync(e))}catch(e){return{}}}}}static#n(e=this.dataFile){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(e),s=this.path.resolve(process.cwd(),e),n=this.fs.existsSync(t),o=!n&&this.fs.existsSync(s),a=JSON.stringify(this.data);n?this.fs.writeFileSync(t,a):o?this.fs.writeFileSync(s,a):this.fs.writeFileSync(t,a)}}}class s{static name="ENV";static version="1.8.3";static about(){return console.log(`\n🟧 ${this.name} v${this.version}\n`)}constructor(e,t){console.log(`\n🟧 ${s.name} v${s.version}\n`),this.name=e,this.logs=[],this.isMute=!1,this.isMuteLog=!1,this.logSeparator="\n",this.encoding="utf-8",this.startTime=(new Date).getTime(),Object.assign(this,t),this.log(`\n🚩 开始!\n${e}\n`)}environment(){switch(this.platform()){case"Surge":return $environment.app="Surge",$environment;case"Stash":return $environment.app="Stash",$environment;case"Egern":return $environment.app="Egern",$environment;case"Loon":let e=$loon.split(" ");return{device:e[0],ios:e[1],"loon-version":e[2],app:"Loon"};case"Quantumult X":return{app:"Quantumult X"};case"Node.js":return process.env.app="Node.js",process.env;default:return{}}}platform(){return"undefined"!=typeof $environment&&$environment["surge-version"]?"Surge":"undefined"!=typeof $environment&&$environment["stash-version"]?"Stash":"undefined"!=typeof module&&module.exports?"Node.js":"undefined"!=typeof $task?"Quantumult X":"undefined"!=typeof $loon?"Loon":"undefined"!=typeof $rocket?"Shadowrocket":"undefined"!=typeof Egern?"Egern":void 0}isNode(){return"Node.js"===this.platform()}isQuanX(){return"Quantumult X"===this.platform()}isSurge(){return"Surge"===this.platform()}isLoon(){return"Loon"===this.platform()}isShadowrocket(){return"Shadowrocket"===this.platform()}isStash(){return"Stash"===this.platform()}isEgern(){return"Egern"===this.platform()}async getScript(e){return await this.fetch(e).then((e=>e.body))}async runScript(e,s){let n=t.getItem("@chavy_boxjs_userCfgs.httpapi");n=n?.replace?.(/\n/g,"")?.trim();let o=t.getItem("@chavy_boxjs_userCfgs.httpapi_timeout");o=1*o??20,o=s?.timeout??o;const[a,r]=n.split("@"),i={url:`http://${r}/v1/scripting/evaluate`,body:{script_text:e,mock_type:"cron",timeout:o},headers:{"X-Key":a,Accept:"*/*"},timeout:o};await this.fetch(i).then((e=>e.body),(e=>this.logErr(e)))}initGotEnv(e){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,e&&(e.headers=e.headers?e.headers:{},void 0===e.headers.Cookie&&void 0===e.cookieJar&&(e.cookieJar=this.ckjar))}async fetch(t={}||"",s={}){switch(t.constructor){case Object:t={...s,...t};break;case String:t={...s,url:t}}t.method||(t.method="GET",(t.body??t.bodyBytes)&&(t.method="POST")),delete t.headers?.Host,delete t.headers?.[":authority"],delete t.headers?.["Content-Length"],delete t.headers?.["content-length"];const n=t.method.toLocaleLowerCase();switch(this.platform()){case"Loon":case"Surge":case"Stash":case"Egern":case"Shadowrocket":default:return t.timeout&&(t.timeout=parseInt(t.timeout,10),this.isSurge()||(t.timeout=1e3*t.timeout)),t.policy&&(this.isLoon()&&(t.node=t.policy),this.isStash()&&e.set(t,"headers.X-Stash-Selected-Proxy",encodeURI(t.policy)),this.isShadowrocket()&&e.set(t,"headers.X-Surge-Proxy",t.policy)),"boolean"==typeof t.redirection&&(t["auto-redirect"]=t.redirection),t.bodyBytes&&!t.body&&(t.body=t.bodyBytes,delete t.bodyBytes),await new Promise(((e,s)=>{$httpClient[n](t,((n,o,a)=>{n?s(n):(o.ok=/^2\d\d$/.test(o.status),o.statusCode=o.status,a&&(o.body=a,1==t["binary-mode"]&&(o.bodyBytes=a)),e(o))}))}));case"Quantumult X":return t.policy&&e.set(t,"opts.policy",t.policy),"boolean"==typeof t["auto-redirect"]&&e.set(t,"opts.redirection",t["auto-redirect"]),t.body instanceof ArrayBuffer?(t.bodyBytes=t.body,delete t.body):ArrayBuffer.isView(t.body)?(t.bodyBytes=t.body.buffer.slice(t.body.byteOffset,t.body.byteLength+t.body.byteOffset),delete object.body):t.body&&delete t.bodyBytes,await $task.fetch(t).then((e=>(e.ok=/^2\d\d$/.test(e.statusCode),e.status=e.statusCode,e)),(e=>Promise.reject(e.error)));case"Node.js":let s=require("iconv-lite");this.initGotEnv(t);const{url:o,...a}=t;return await this.got[n](o,a).on("redirect",((e,t)=>{try{if(e.headers["set-cookie"]){const s=e.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();s&&this.ckjar.setCookieSync(s,null),t.cookieJar=this.ckjar}}catch(e){this.logErr(e)}})).then((e=>(e.statusCode=e.status,e.body=s.decode(e.rawBody,this.encoding),e.bodyBytes=e.rawBody,e)),(e=>Promise.reject(e.message)))}}time(e,t=null){const s=t?new Date(t):new Date;let n={"M+":s.getMonth()+1,"d+":s.getDate(),"H+":s.getHours(),"m+":s.getMinutes(),"s+":s.getSeconds(),"q+":Math.floor((s.getMonth()+3)/3),S:s.getMilliseconds()};/(y+)/.test(e)&&(e=e.replace(RegExp.$1,(s.getFullYear()+"").substr(4-RegExp.$1.length)));for(let t in n)new RegExp("("+t+")").test(e)&&(e=e.replace(RegExp.$1,1==RegExp.$1.length?n[t]:("00"+n[t]).substr((""+n[t]).length)));return e}msg(e=name,t="",s="",n){const o=e=>{switch(typeof e){case void 0:return e;case"string":switch(this.platform()){case"Surge":case"Stash":case"Egern":default:return{url:e};case"Loon":case"Shadowrocket":return e;case"Quantumult X":return{"open-url":e};case"Node.js":return}case"object":switch(this.platform()){case"Surge":case"Stash":case"Egern":case"Shadowrocket":default:return{url:e.url||e.openUrl||e["open-url"]};case"Loon":return{openUrl:e.openUrl||e.url||e["open-url"],mediaUrl:e.mediaUrl||e["media-url"]};case"Quantumult X":return{"open-url":e["open-url"]||e.url||e.openUrl,"media-url":e["media-url"]||e.mediaUrl,"update-pasteboard":e["update-pasteboard"]||e.updatePasteboard};case"Node.js":return}default:return}};if(!this.isMute)switch(this.platform()){case"Surge":case"Loon":case"Stash":case"Egern":case"Shadowrocket":default:$notification.post(e,t,s,o(n));break;case"Quantumult X":$notify(e,t,s,o(n));case"Node.js":}if(!this.isMuteLog){let n=["","==============📣系统通知📣=============="];n.push(e),t&&n.push(t),s&&n.push(s),console.log(n.join("\n")),this.logs=this.logs.concat(n)}}log(...e){e.length>0&&(this.logs=[...this.logs,...e]),console.log(e.join(this.logSeparator))}logErr(e){switch(this.platform()){case"Surge":case"Loon":case"Stash":case"Egern":case"Shadowrocket":case"Quantumult X":default:this.log("",`❗️ ${this.name}, 错误!`,e);break;case"Node.js":this.log("",`❗️${this.name}, 错误!`,e.stack)}}wait(e){return new Promise((t=>setTimeout(t,e)))}done(t={}){const s=((new Date).getTime()-this.startTime)/1e3;switch(this.log("",`🚩 ${this.name}, 结束! 🕛 ${s} 秒`,""),this.platform()){case"Surge":t.policy&&e.set(t,"headers.X-Surge-Policy",t.policy),$done(t);break;case"Loon":t.policy&&(t.node=t.policy),$done(t);break;case"Stash":t.policy&&e.set(t,"headers.X-Stash-Selected-Proxy",encodeURI(t.policy)),$done(t);break;case"Egern":case"Shadowrocket":default:$done(t);break;case"Quantumult X":t.policy&&e.set(t,"opts.policy",t.policy),delete t["auto-redirect"],delete t["auto-cookie"],delete t["binary-mode"],delete t.charset,delete t.host,delete t.insecure,delete t.method,delete t.opt,delete t.path,delete t.policy,delete t["policy-descriptor"],delete t.scheme,delete t.sessionIndex,delete t.statusCode,delete t.timeout,t.body instanceof ArrayBuffer?(t.bodyBytes=t.body,delete t.body):ArrayBuffer.isView(t.body)?(t.bodyBytes=t.body.buffer.slice(t.body.byteOffset,t.body.byteLength+t.body.byteOffset),delete t.body):t.body&&delete t.bodyBytes,$done(t);break;case"Node.js":process.exit(1)}}}function n(s,n,o){let a=t.getItem(s,o),r={};if("undefined"!=typeof $argument&&Boolean($argument)){let t=Object.fromEntries($argument.split("&").map((e=>e.split("=").map((e=>e.replace(/\"/g,""))))));for(let s in t)e.set(r,s,t[s])}const i={Settings:o?.Default?.Settings||{},Configs:o?.Default?.Configs||{},Caches:{}};Array.isArray(n)||(n=[n]);for(let e of n)i.Settings={...i.Settings,...o?.[e]?.Settings,...r,...a?.[e]?.Settings},i.Configs={...i.Configs,...o?.[e]?.Configs},a?.[e]?.Caches&&"string"==typeof a?.[e]?.Caches&&(a[e].Caches=JSON.parse(a?.[e]?.Caches)),i.Caches={...i.Caches,...a?.[e]?.Caches};return function e(t,s){for(var n in t){var o=t[n];t[n]="object"==typeof o&&null!==o?e(o,s):s(n,o)}return t}(i.Settings,((e,t)=>("true"===t||"false"===t?t=JSON.parse(t):"string"==typeof t&&(t=t.includes(",")?t.split(",").map((e=>c(e))):c(t)),t))),i;function c(e){return e&&!isNaN(e)&&(e=parseInt(e,10)),e}}var o={Switch:!0},a={Settings:o},r={Switch:!0,Title:"☁ 𝙒𝘼𝙍𝙋 𝙄𝙣𝙛𝙤",Icon:"lock.icloud.fill",IconColor:"#f48220",BackgroundColor:"#f6821f",Language:"auto"},i={Request:{url:"https://api.cloudflareclient.com",headers:{authorization:null,"content-Type":"application/json","user-agent":"1.1.1.1/6.22","cf-client-version":"i-6.22-2308151957.1"}},i18n:{"zh-Hans":{IPv4:"IPv4",IPv6:"IPv6",COLO:"托管中心",WARP_Level:"隐私保护",Account_Type:"账户类型",Data_Info:"流量信息",Unknown:"未知",Fail:"获取失败",WARP_Level_Off:"关闭",WARP_Level_On:"开启",WARP_Level_Plus:"增强",Account_Type_unlimited:"无限版",Account_Type_limited:"有限版",Account_Type_team:"团队版",Account_Type_plus:"WARP+",Account_Type_free:"免费版",Data_Info_Used:"已用",Data_Info_Residual:"剩余",Data_Info_Total:"总计",Data_Info_Unlimited:"无限"},"zh-Hant":{IPv4:"IPv4",IPv6:"IPv6",COLO:"託管中心",WARP_Level:"隱私保護",Account_Type:"賬戶類型",Data_Info:"流量信息",Unknown:"未知",Fail:"獲取失敗",WARP_Level_Off:"關閉",WARP_Level_On:"開啟",WARP_Level_Plus:"增強",Account_Type_unlimited:"無限版",Account_Type_limited:"有限版",Account_Type_team:"團隊版",Account_Type_plus:"WARP+",Account_Type_free:"免費版",Data_Info_Used:"已用",Data_Info_Residual:"剩餘",Data_Info_Total:"總計",Data_Info_Unlimited:"無限"},en:{IPv4:"IPv4",IPv6:"IPv6",COLO:"Colo Center",WARP_Level:"WARP Level",Account_Type:"Account Type",Data_Info:"Data Info.",Unknown:"Unknown",Fail:"Fail to Get",WARP_Level_Off:"OFF",WARP_Level_On:"ON",WARP_Level_Plus:"PLUS",Account_Type_unlimited:"Unlimited",Account_Type_limited:"Limited",Account_Type_team:"Team",Account_Type_plus:"WARP+",Account_Type_free:"Free",Data_Info_Used:"Used",Data_Info_Residual:"Remaining",Data_Info_Total:"Earned",Data_Info_Unlimited:"Unlimited"}}},c={Settings:r,Configs:i},l={Switch:!0,setupMode:"ChangeKeypair",Verify:{RegistrationId:null,Mode:"Token",Content:null}},d={Settings:l},u={Switch:!0,IPServer:"ipw.cn",Verify:{Mode:"Token",Content:""},zone:{id:"",name:"",dns_records:[{id:"",type:"A",name:"",content:"",ttl:1,proxied:!1}]}},p={Request:{url:"https://api.cloudflare.com/client/v4",headers:{"content-type":"application/json"}}},h={Settings:u,Configs:p},f={Switch:!0,setupMode:null,deviceType:"iOS",Verify:{License:null,Mode:"Token",Content:null,RegistrationId:null}},g={Request:{url:"https://api.cloudflareclient.com",headers:{authorization:null,"content-Type":"application/json","user-agent":"1.1.1.1/6.22","cf-client-version":"i-6.22-2308151957.1"}},Environment:{iOS:{Type:"i",Version:"v0i2308151957",headers:{"user-agent":"1.1.1.1/6.22","cf-client-version":"i-6.22-2308151957.1"}},macOS:{Type:"m",Version:"v0i2109031904",headers:{"user-agent":"1.1.1.1/2109031904.1 CFNetwork/1327.0.4 Darwin/21.2.0","cf-client-version":"m-2021.12.1.0-0"}},Android:{Type:"a",Version:"v0a1922",headers:{"user-agent":"okhttp/3.12.1","cf-client-version":"a-6.3-1922"}},Windows:{Type:"w",Version:"",headers:{"user-agent":"","cf-client-version":""}},Linux:{Type:"l",Version:"",headers:{"user-agent":"","cf-client-version":""}}}},y={Settings:f,Configs:g},m={Switch:!0,PrivateKey:"",PublicKey:""},v={interface:{addresses:{v4:"",v6:""}},peers:[{public_key:"",endpoint:{host:"",v4:"",v6:""}}]},S={Settings:m,Configs:v},$=Database={Default:Object.freeze({__proto__:null,Settings:o,default:a}),Panel:Object.freeze({__proto__:null,Configs:i,Settings:r,default:c}),"1dot1dot1dot1":Object.freeze({__proto__:null,Settings:l,default:d}),DNS:Object.freeze({__proto__:null,Configs:p,Settings:u,default:h}),WARP:Object.freeze({__proto__:null,Configs:g,Settings:f,default:y}),VPN:Object.freeze({__proto__:null,Configs:v,Settings:m,default:S})};const b=new s("☁ Cloudflare: 1️⃣ 1.1.1.1 v3.2.0(1).response"),_=new URL($request.url);b.log(`⚠ url: ${_.toJSON()}`,"");const k=$request.method,w=_.hostname,C=_.pathname,P=_.pathname.split("/").filter(Boolean);b.log(`⚠ METHOD: ${k}, HOST: ${w}, PATH: ${C}`,"");const A=($response.headers?.["Content-Type"]??$response.headers?.["content-type"])?.split(";")?.[0];b.log(`⚠ FORMAT: ${A}`,""),(async()=>{const{Settings:s,Caches:o,Configs:a}=function(t,s,o){console.log("☑️ Set Environment Variables","");let{Settings:a,Caches:r,Configs:i}=n(t,s,o);switch(a.Verify?.Mode){case"Token":e.set(i,"Request.headers.authorization",`Bearer ${a.Verify?.Content}`);break;case"ServiceKey":e.set(i,"Request.headers.x-auth-user-service-key",a.Verify?.Content);break;case"Key":e.set(a,"Verify.Content",Array.from(a.Verify?.Content.split("\n"))),e.set(i,"Request.headers.x-auth-key",a.Verify?.Content[0]),e.set(i,"Request.headers.x-auth-email",a.Verify?.Content[1]);break;default:console.log(`无可用授权方式\nMode=${a.Verify?.Mode}\nContent=${a.Verify?.Content}`);case void 0:}return a.zone?.dns_records&&(a.zone.dns_records=Array.from(a.zone.dns_records.split("\n")),a.zone.dns_records.forEach(((e,t)=>{a.zone.dns_records[t]=Object.fromEntries(e.split("&").map((e=>e.split("=")))),a.zone.dns_records[t].proxied=JSON.parse(a.zone.dns_records[t].proxied)}))),console.log(`✅ Set Environment Variables, Settings: ${typeof a}, Settings内容: ${JSON.stringify(a)}`,""),{Settings:a,Caches:r,Configs:i}}("Cloudflare","1dot1dot1dot1",$);switch(b.log(`⚠ Settings.Switch: ${s?.Switch}`,""),s.Switch){case!0:default:const e=n("WireGuard","VPN",$),o=($request?.headers?.Authorization??$request?.headers?.authorization)?.match(/Bearer (\S*)/)?.[1],a=`/${P[1]}/${P[2]}`==`/reg/${s.Verify.RegistrationId}`?"RegistrationId":"/reg"==`/${P[1]}`?"Registration":void 0;b.log(`🚧 KIND: ${a}`,"");let r={};switch(A){case void 0:case"application/x-www-form-urlencoded":case"text/plain":default:case"application/x-mpegURL":case"application/x-mpegurl":case"application/vnd.apple.mpegurl":case"audio/mpegurl":case"text/xml":case"text/html":case"text/plist":case"application/xml":case"application/plist":case"application/x-plist":case"text/vtt":case"application/vtt":break;case"text/json":case"application/json":switch(r=JSON.parse($response.body),Array.isArray(r.messages)&&r.messages.forEach((e=>b.msg(b.name,`code: ${e.code}`,`message: ${e.message}`))),r.success){case!0:const s=r?.result?.[0]??r?.result;if(s){s.config.reserved=function(e="AAAA"){b.log("☑️ Set Reserved",`client_id: ${e}`,"");let t=s(atob(e.toString(16)).toString());return b.log("✅ Set Reserved",`reserved: ${t}`,""),t;function s(e){return e.split("").map((e=>e.charCodeAt().toString(10)))}}(s?.config?.client_id),await async function(e,s,n){return b.log("☑️ Set Configs",""),t.setItem(`@${e}.${s}.Configs.interface.addresses.v4`,n?.interface?.addresses?.v4),t.setItem(`@${e}.${s}.Configs.interface.addresses.v6`,n?.interface?.addresses?.v6),t.setItem(`@${e}.${s}.Configs.Reserved`,n?.reserved),t.setItem(`@${e}.${s}.Configs.peers[0].public_key`,n?.peers?.[0]?.public_key),t.setItem(`@${e}.${s}.Configs.peers[0].endpoint.host`,n?.peers?.[0]?.endpoint?.host),t.setItem(`@${e}.${s}.Configs.peers[0].endpoint.v4`,n?.peers?.[0]?.endpoint?.v4),t.setItem(`@${e}.${s}.Configs.peers[0].endpoint.v6`,n?.peers?.[0]?.endpoint?.v6),b.log("✅ Set Configs","")}("WireGuard","VPN",s.config);const n=await async function(e,t){b.log("☑️ Set Message","");const s=`当前客户端公钥为:\n${e.key}\n用户设置公钥为:\n${t?.Settings?.PublicKey??"未设置,请到BoxJs面板中进行设置"}\n如两者一致,下列配置有效`;let n=`有效性验证:\n${s}\n\n\n⚠️注意留存本文件\n\n\n`;switch(b.platform()){case"Surge":n+=`Surge用配置:\n${`[Proxy]\nWARP = wireguard, section-name=Cloudflare, test-url=http://cp.cloudflare.com/generate_204\n\n[WireGuard Cloudflare]\nprivate-key = ${t?.Settings?.PrivateKey}\nself-ip = ${e?.config?.interface?.addresses?.v4}\nself-ip-v6 = ${e?.config?.interface?.addresses?.v6}\ndns-server = 1.1.1.1, 2606:4700:4700::1111\nmtu = 1280\npeer = (public-key = bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo=, allowed-ips = "0.0.0.0/0, ::/0", endpoint = engage.nanocat.cloud:2408, keepalive = 45, client-id = ${e?.config?.reserved?.[0]}/${e?.config?.reserved?.[1]}/${e?.config?.reserved?.[2]})`}`;break;case"Loon":n+=`Loon用配置:\n${`[Proxy]\nWARP = wireguard, interface-ip=${e?.config?.interface?.addresses?.v4}, interface-ipv6=${e?.config?.interface?.addresses?.v6}, private-key="${t?.Settings?.PrivateKey}", mtu=1280, dns=1.1.1.1, dnsv6=2606:4700:4700::1111, keepalive=45, peers=[{public-key="bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo=", allowed-ips="0.0.0.0/0, ::/0", endpoint=engage.nanocat.cloud:2408, reserved=[${e?.config?.reserved}]}]`}`;break;case"Shadowrocket":n+=`Shadowrocket用配置:\n${`[Proxy]\nWARP = wireguard, section-name=Cloudflare, test-url=http://cp.cloudflare.com/generate_204\n\n[WireGuard Cloudflare]\nprivate-key = ${t?.Settings?.PrivateKey}\nself-ip = ${e?.config?.interface?.addresses?.v4}\nself-ip-v6 = ${e?.config?.interface?.addresses?.v6}\ndns-server = 1.1.1.1, 2606:4700:4700::1111\nmtu = 1280\npeer = (public-key = bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo=, allowed-ips = "0.0.0.0/0, ::/0", endpoint = engage.nanocat.cloud:2408, keepalive = 45, client-id = ${e?.config?.reserved?.[0]}/${e?.config?.reserved?.[1]}/${e?.config?.reserved?.[2]})`}\n\n\nShadowrocket点击一键添加:\nshadowrocket://add/${`wg://engage.nanocat.cloud:2408?publicKey=bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo=&privateKey=${t?.Settings?.PrivateKey}&ip=${e?.config?.interface?.addresses?.v4}&dns=1.1.1.1&mtu=1280&keepalive=45&udp=1&reserved=${e?.config?.reserved?.[0]}/${e?.config?.reserved?.[1]}/${e?.config?.reserved?.[2]}#☁️%20Cloudflare%20for%20${e?.account?.account_type}`}`;break;case"Stash":n+=`Stash用配置:\n${`name: Cloudflare\ntype: wireguard\nserver: engage.nanocat.cloud # domain is supported\nport: 2408\nip: ${e?.config?.interface?.addresses?.v4}\nipv6: ${e?.config?.interface?.addresses?.v6} # optional\nprivate-key: ${t?.Settings?.PrivateKey}\npublic-key: bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo= # peer public key\n# preshared-key: # optional\ndns: [1.1.1.1, 2606:4700:4700::1111] # optional\nmtu: 1280 # optional\nreserved: [${e?.config?.reserved}] # optional\nkeepalive: 45 # optional\n# underlying-proxy: # optional\n# type: trojan\n# server: your-underlying-proxy\n# port: 443\n# password: your-password`}`;break;case"Node.js":break;case"Quantumult X":n+="Quantumult X不支持 Wireguard 协议,仅显示提取后完整配置"}const o=JSON.stringify(e);n+=`\n\n\n完整配置内容:\n${o}`;const a=encodeURIComponent(`☁️ Cloudflare for ${e?.account?.account_type}配置文件`),r=`mailto:engage@nanocat.me?subject=${a}&body=${encodeURIComponent(n)}`;return b.log("✅ Set Message",`message: ${r}`,""),r}(s,e);switch(a){case"Registration":"GET"!==$request.method&&"PUT"!==$request.method||(b.msg(b.name,`检测到${s?.account?.account_type}配置文件`,`点击此通知在“邮件”中打开,查看完整配置。\n设备注册ID:\n${s?.id}\n设备令牌Token:\n${o}\n客户端公钥:\n${s?.key}\n节点公钥:\n${s?.config?.peers?.[0]?.public_key}`,n),b.log(b.name,`检测到${s?.account?.account_type}配置文件`,`原始配置文件:\n注意!文本内容未转义!字符串中可能包含额外字符!\n${JSON.stringify(s)}`,""));break;case"RegistrationId":"PUT"===$request.method&&(b.msg(b.name,"重置密钥",`点击此通知在“邮件”中打开,查看完整配置。\n收到回复数据,当前客户端公钥为:\n${s?.key}\n用户设置公钥为:\n${e?.Settings?.PublicKey}\n如两者一致,则替换成功`,n),b.log(b.name,`检测到${s?.account?.account_type}配置文件`,`原始配置文件:\n注意!文本内容未转义!字符串中可能包含额外字符!\n${JSON.stringify(s)}`,""))}}case!1:Array.isArray(r.errors)&&r.errors.forEach((e=>{b.msg(b.name,`code: ${e.code}`,`message: ${e.message}`)}));break;case void 0:throw new Error($response)}case"application/protobuf":case"application/x-protobuf":case"application/vnd.google.protobuf":case"application/grpc":case"application/grpc+proto":case"application/octet-stream":}case!1:}})().catch((e=>b.logErr(e))).finally((()=>b.done($response)));