small-package/luci-app-openclash/root/usr/share/openclash/dashboard/assets/index.ff31c246.js

3 lines
53 KiB
JavaScript

var Ze=Object.defineProperty,et=Object.defineProperties;var tt=Object.getOwnPropertyDescriptors;var Se=Object.getOwnPropertySymbols;var nt=Object.prototype.hasOwnProperty,st=Object.prototype.propertyIsEnumerable;var Fe=(n,t,s)=>t in n?Ze(n,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[t]=s,w=(n,t)=>{for(var s in t||(t={}))nt.call(t,s)&&Fe(n,s,t[s]);if(Se)for(var s of Se(t))st.call(t,s)&&Fe(n,s,t[s]);return n},A=(n,t)=>et(n,tt(t));import{R as e,c as g,f as ot,r as p,a as ne,E as Be,b as le,d as at,e as Y,g as ye,u as De,h as ge,i as B,j as Ie,k as xe,l as K,m as lt,n as Re,o as rt,p as ve,q as ct,s as it,t as ut,v as mt,w as dt,x as pt,y as ft,z as ht,A as Et,B as yt,F as gt,C as xt,N as vt,D as wt,G as Ae,H as Ct,I as bt,J as Nt}from"./vendor.2c5fdbe2.js";const Pt=function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))o(a);new MutationObserver(a=>{for(const l of a)if(l.type==="childList")for(const r of l.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&o(r)}).observe(document,{childList:!0,subtree:!0});function s(a){const l={};return a.integrity&&(l.integrity=a.integrity),a.referrerpolicy&&(l.referrerPolicy=a.referrerpolicy),a.crossorigin==="use-credentials"?l.credentials="include":a.crossorigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function o(a){if(a.ep)return;a.ep=!0;const l=s(a);fetch(a.href,l)}};Pt();function ee(){return navigator.userAgent==="ClashX Runtime"}let b=null;class kt{constructor(t){this.instance=null,window.WebViewJavascriptBridge!=null&&(this.instance=window.WebViewJavascriptBridge),this.initBridge(s=>{this.instance=s,t()})}initBridge(t){if(!ee())return t==null?void 0:t(null);if(window.WebViewJavascriptBridge!=null)return t(window.WebViewJavascriptBridge);if(window.WVJBCallbacks!=null)return window.WVJBCallbacks.push(t);window.WVJBCallbacks=[t];const s=document.createElement("iframe");s.style.display="none",s.src="https://__bridge_loaded__",document.documentElement.appendChild(s),setTimeout(()=>document.documentElement.removeChild(s),0)}async callHandler(t,s){return await new Promise(o=>{var a;(a=this.instance)==null||a.callHandler(t,s,o)})}async ping(){return await this.callHandler("ping")}async readConfigString(){return await this.callHandler("readConfigString")}async getPasteboard(){return await this.callHandler("getPasteboard")}async getAPIInfo(){return await this.callHandler("apiInfo")}async setPasteboard(t){return await this.callHandler("setPasteboard",t)}async writeConfigWithString(t){return await this.callHandler("writeConfigWithString",t)}async setSystemProxy(t){return await this.callHandler("setSystemProxy",t)}async getStartAtLogin(){return await this.callHandler("getStartAtLogin")}async getProxyDelay(t){return await this.callHandler("speedTest",t)}async setStartAtLogin(t){return await this.callHandler("setStartAtLogin",t)}async isSystemProxySet(){return await this.callHandler("isSystemProxySet")}}function St(n){if(b!=null){n();return}b=new kt(n)}function J(n){const{title:t,children:s,className:o,style:a}=n;return e.createElement("header",{className:g("header",o),style:a},e.createElement("h1",{className:"md:text-xl"},t),e.createElement("div",{className:"flex flex-auto items-center justify-end"},s))}function U(n){const{type:t,size:s=14,className:o,style:a}=n,l=g("clash-iconfont",`icon-${t}`,o),r=w({fontSize:s},a),c=A(w({},n),{className:l,style:r});return e.createElement("i",w({},c))}function W(){}function Ft(n,t){const s=[],o=[];for(const a of n)t(a)?s.push(a):o.push(a);return[s,o]}function O(n){var o;const t=["B","KB","MB","GB","TB"],s=Math.floor(Math.log(n||1)/Math.log(1024));return`${ot(n/Math.pow(1024,s),2).toFixed(2)} ${(o=t==null?void 0:t[s])!=null?o:""}`}function Me(n){return n.replace(/.*[/\\]/,"")}function de(n){const{className:t,checked:s=!1,disabled:o=!1,onChange:a=W}=n,l=g("switch",{checked:s,disabled:o},t);function r(){o||a(!s)}return e.createElement("div",{className:l,onClick:r},e.createElement(U,{className:"switch-icon font-bold",type:"check",size:20}))}const z=p.exports.forwardRef((n,t)=>{const{className:s,style:o,children:a}=n;return e.createElement("div",{className:g("card",s),style:o,ref:t},a)});function $e(n){const{options:t,value:s,onSelect:o}=n;return e.createElement("div",{className:"button-select"},t.map(a=>e.createElement("button",{value:a.value,key:a.value,className:g("button-select-options",{actived:s===a.value}),onClick:()=>o==null?void 0:o(a.value)},a.label)))}const Dt={SideBar:{Proxies:"Proxies",Overview:"Overview",Logs:"Logs",Rules:"Rules",Settings:"Setting",Connections:"Connections",Version:"Version"},Settings:{title:"Settings",labels:{startAtLogin:"Start at login",language:"language",setAsSystemProxy:"Set as system proxy",allowConnectFromLan:"Allow connect from Lan",proxyMode:"Mode",socks5ProxyPort:"Socks5 proxy port",httpProxyPort:"HTTP proxy port",mixedProxyPort:"Mixed proxy port",externalController:"External controller"},values:{cn:"\u4E2D\u6587",en:"English",global:"Global",rules:"Rules",direct:"Direct",script:"Script"},versionString:"Current ClashX is the latest version\uFF1A{{version}}",checkUpdate:"Check Update",externalControllerSetting:{title:"External Controller",note:"Please note that modifying this configuration will only configure Dashboard. Will not modify your Clash configuration file. Please make sure that the external controller address matches the address in the Clash configuration file, otherwise, Dashboard will not be able to connect to Clash.",host:"Host",port:"Port",secret:"Secret"}},Logs:{title:"Logs"},Rules:{title:"Rules",providerTitle:"Providers",providerUpdateTime:"Last updated at",ruleCount:"Rule count"},Connections:{title:"Connections",keepClosed:"Keep closed connections",total:{text:"total",upload:"upload",download:"download"},closeAll:{title:"Warning",content:"This would close all connections"},filter:{all:"All"},columns:{host:"Host",network:"Network",type:"Type",chains:"Chains",process:"Process",rule:"Rule",time:"Time",speed:"Speed",upload:"Upload",download:"Download",sourceIP:"Source IP"},info:{title:"Connection",id:"ID",host:"Host",hostEmpty:"Empty",dstIP:"IP",dstIPEmpty:"Empty",srcIP:"Source",upload:"Upload",download:"Download",network:"Network",process:"Process",processPath:"Path",inbound:"Inbound",rule:"Rule",chains:"Chains",status:"Status",opening:"Open",closed:"Closed",closeConnection:"Close"}},Proxies:{title:"Proxies",editDialog:{title:"Edit Proxy",color:"Color",name:"Name",type:"Type",server:"Server",port:"Port",password:"Password",cipher:"Cipher",obfs:"Obfs","obfs-host":"Obfs-host",uuid:"UUID",alterId:"AlterId",tls:"TLS"},groupTitle:"Policy Group",providerTitle:"Providers",providerUpdateTime:"Last updated at",expandText:"Expand",collapseText:"Collapse",speedTestText:"Speed Test",breakConnectionsText:"Close connections which include the group"},Modal:{ok:"Ok",cancel:"Cancel"}},At={SideBar:{Proxies:"\u4EE3\u7406",Overview:"\u603B\u89C8",Logs:"\u65E5\u5FD7",Rules:"\u89C4\u5219",Settings:"\u8BBE\u7F6E",Connections:"\u8FDE\u63A5",Version:"\u7248\u672C"},Settings:{title:"\u8BBE\u7F6E",labels:{startAtLogin:"\u5F00\u673A\u65F6\u542F\u52A8",language:"\u8BED\u8A00",setAsSystemProxy:"\u8BBE\u7F6E\u4E3A\u7CFB\u7EDF\u4EE3\u7406",allowConnectFromLan:"\u5141\u8BB8\u6765\u81EA\u5C40\u57DF\u7F51\u7684\u8FDE\u63A5",proxyMode:"\u4EE3\u7406\u6A21\u5F0F",socks5ProxyPort:"Socks5 \u4EE3\u7406\u7AEF\u53E3",httpProxyPort:"HTTP \u4EE3\u7406\u7AEF\u53E3",mixedProxyPort:"\u6DF7\u5408\u4EE3\u7406\u7AEF\u53E3",externalController:"\u5916\u90E8\u63A7\u5236\u8BBE\u7F6E"},values:{cn:"\u4E2D\u6587",en:"English",global:"\u5168\u5C40",rules:"\u89C4\u5219",direct:"\u76F4\u8FDE",script:"\u811A\u672C"},versionString:"\u5F53\u524D ClashX \u5DF2\u662F\u6700\u65B0\u7248\u672C\uFF1A{{version}}",checkUpdate:"\u68C0\u67E5\u66F4\u65B0",externalControllerSetting:{title:"\u7F16\u8F91\u5916\u90E8\u63A7\u5236\u8BBE\u7F6E",note:"\u8BF7\u6CE8\u610F\uFF0C\u4FEE\u6539\u8BE5\u914D\u7F6E\u9879\u5E76\u4E0D\u4F1A\u4FEE\u6539\u4F60\u7684 Clash \u914D\u7F6E\u6587\u4EF6\uFF0C\u8BF7\u786E\u8BA4\u4FEE\u6539\u540E\u7684\u5916\u90E8\u63A7\u5236\u5730\u5740\u548C Clash \u914D\u7F6E\u6587\u4EF6\u5185\u7684\u5730\u5740\u4E00\u81F4\uFF0C\u5426\u5219\u4F1A\u5BFC\u81F4 Dashboard \u65E0\u6CD5\u8FDE\u63A5\u3002",host:"Host",port:"\u7AEF\u53E3",secret:"\u5BC6\u94A5"}},Logs:{title:"\u65E5\u5FD7"},Rules:{title:"\u89C4\u5219",providerTitle:"\u89C4\u5219\u96C6",providerUpdateTime:"\u6700\u540E\u66F4\u65B0\u4E8E",ruleCount:"\u89C4\u5219\u6761\u6570"},Connections:{title:"\u8FDE\u63A5",keepClosed:"\u4FDD\u7559\u5173\u95ED\u8FDE\u63A5",total:{text:"\u603B\u91CF",upload:"\u4E0A\u4F20",download:"\u4E0B\u8F7D"},closeAll:{title:"\u8B66\u544A",content:"\u5C06\u4F1A\u5173\u95ED\u6240\u6709\u8FDE\u63A5"},filter:{all:"\u5168\u90E8"},columns:{host:"\u57DF\u540D",network:"\u7F51\u7EDC",process:"\u8FDB\u7A0B",type:"\u7C7B\u578B",chains:"\u8282\u70B9\u94FE",rule:"\u89C4\u5219",time:"\u8FDE\u63A5\u65F6\u95F4",speed:"\u901F\u7387",upload:"\u4E0A\u4F20",download:"\u4E0B\u8F7D",sourceIP:"\u6765\u6E90 IP"},info:{title:"\u8FDE\u63A5\u4FE1\u606F",id:"ID",host:"\u57DF\u540D",hostEmpty:"\u7A7A",dstIP:"IP",dstIPEmpty:"\u7A7A",srcIP:"\u6765\u6E90",upload:"\u4E0A\u4F20",download:"\u4E0B\u8F7D",network:"\u7F51\u7EDC",process:"\u8FDB\u7A0B",processPath:"\u8DEF\u5F84",inbound:"\u5165\u53E3",rule:"\u89C4\u5219",chains:"\u4EE3\u7406",status:"\u72B6\u6001",opening:"\u8FDE\u63A5\u4E2D",closed:"\u5DF2\u5173\u95ED",closeConnection:"\u5173\u95ED\u8FDE\u63A5"}},Proxies:{title:"\u4EE3\u7406",editDialog:{title:"\u7F16\u8F91\u4EE3\u7406",color:"\u989C\u8272",name:"\u540D\u5B57",type:"\u7C7B\u578B",server:"\u670D\u52A1\u5668",port:"\u7AEF\u53E3",password:"\u5BC6\u7801",cipher:"\u52A0\u5BC6\u65B9\u5F0F",obfs:"Obfs","obfs-host":"Obfs-host",uuid:"UUID",alterId:"AlterId",tls:"TLS"},groupTitle:"\u7B56\u7565\u7EC4",providerTitle:"\u4EE3\u7406\u96C6",providerUpdateTime:"\u6700\u540E\u66F4\u65B0\u4E8E",expandText:"\u5C55\u5F00",collapseText:"\u6536\u8D77",speedTestText:"\u6D4B\u901F",breakConnectionsText:"\u5207\u6362\u65F6\u6253\u65AD\u5305\u542B\u7B56\u7565\u7EC4\u7684\u8FDE\u63A5"},Modal:{ok:"\u786E \u5B9A",cancel:"\u53D6 \u6D88"}},He={en_US:Dt,zh_CN:At},$t=Object.keys(He);function Lt(){for(const n of window.navigator.languages){if(n.includes("zh"))return"zh_CN";if(n.includes("us"))return"en_US"}return"en_US"}function we(n){return p.exports.useMemo(()=>{function s(o,a){if(typeof o=="string")n(l=>{const r=o,c=a;l[r]=c});else if(typeof o=="function"){const l=o;n(r=>l(r))}else typeof o=="object"&&n(l=>ne(l,r=>{const c=o;for(const m of Object.keys(c)){const f=m;r[f]=c[f]}}))}return s},[n])}class Oe{constructor(t){this.EE=new Be,this.innerBuffer=[],this.isClose=!1,this.config=Object.assign({bufferLength:0,retryInterval:5e3,headers:{}},t),this.config.useWebsocket?this.websocketLoop():this.loop()}websocketLoop(){var o;const t=new URL(this.config.url);t.protocol=t.protocol==="http:"?"ws:":"wss:",t.searchParams.set("token",(o=this.config.token)!=null?o:"");const s=new WebSocket(t.toString());s.addEventListener("message",a=>{const l=JSON.parse(a.data);this.EE.emit("data",[l]),this.config.bufferLength>0&&(this.innerBuffer.push(l),this.innerBuffer.length>this.config.bufferLength&&this.innerBuffer.splice(0,this.innerBuffer.length-this.config.bufferLength))}),s.addEventListener("close",()=>setTimeout(this.websocketLoop,this.config.retryInterval)),s.addEventListener("error",a=>{this.EE.emit("error",a),setTimeout(this.websocketLoop,this.config.retryInterval)})}async loop(){const t=await le.fromPromise(fetch(this.config.url,{mode:"cors",headers:this.config.token?{Authorization:`Bearer ${this.config.token}`}:{}}),a=>a);if(t.isErr()){this.retry(t.error);return}else if(t.value.body==null){this.retry(new Error("fetch body error"));return}const s=t.value.body.getReader(),o=new TextDecoder;for(;!this.isClose;){const a=await le.fromPromise(s==null?void 0:s.read(),c=>c);if(a.isErr()){this.retry(a.error);break}const r=o.decode(a.value.value).trim().split(`
`).map(c=>JSON.parse(c));this.EE.emit("data",r),this.config.bufferLength>0&&(this.innerBuffer.push(...r),this.innerBuffer.length>this.config.bufferLength&&this.innerBuffer.splice(0,this.innerBuffer.length-this.config.bufferLength))}}retry(t){this.isClose||(this.EE.emit("error",t),window.setTimeout(()=>{this.loop()},this.config.retryInterval))}subscribe(t,s){this.EE.addListener(t,s)}unsubscribe(t,s){this.EE.removeListener(t,s)}buffer(){return this.innerBuffer.slice()}destory(){this.EE.removeAllListeners(),this.isClose=!0}}class Tt{constructor(t,s){this.axiosClient=at.create({baseURL:t,headers:s?{Authorization:`Bearer ${s}`}:{}})}async getConfig(){return await this.axiosClient.get("configs")}async updateConfig(t){return await this.axiosClient.patch("configs",t)}async getRules(){return await this.axiosClient.get("rules")}async getProxyProviders(){const t=await this.axiosClient.get("providers/proxies",{validateStatus(s){return s>=200&&s<300||s===404}});return t.status===404&&(t.data={providers:{}}),t}async getRuleProviders(){return await this.axiosClient.get("providers/rules")}async updateProvider(t){return await this.axiosClient.put(`providers/proxies/${encodeURIComponent(t)}`)}async updateRuleProvider(t){return await this.axiosClient.put(`providers/rules/${encodeURIComponent(t)}`)}async healthCheckProvider(t){return await this.axiosClient.get(`providers/proxies/${encodeURIComponent(t)}/healthcheck`)}async getProxies(){return await this.axiosClient.get("proxies")}async getProxy(t){return await this.axiosClient.get(`proxies/${encodeURIComponent(t)}`)}async getVersion(){return await this.axiosClient.get("version")}async getProxyDelay(t){return await this.axiosClient.get(`proxies/${encodeURIComponent(t)}/delay`,{params:{timeout:5e3,url:"http://www.gstatic.com/generate_204"}})}async closeAllConnections(){return await this.axiosClient.delete("connections")}async closeConnection(t){return await this.axiosClient.delete(`connections/${t}`)}async getConnections(){return await this.axiosClient.get("connections")}async changeProxySelected(t,s){return await this.axiosClient.put(`proxies/${encodeURIComponent(t)}`,{name:s})}}const Bt=Y(async()=>{if(!ee())return null;const n=await b.getAPIInfo();return{hostname:n.host,port:n.port,secret:n.secret,protocol:"http:"}}),Ue=ye("externalControllers",[]);function se(){var f,u,d,h,E,x,N,F,L,k,C,T,I,j,Q;const n=De(Bt),t=ge(),s=De(Ue);if(n!=null)return n;let o;{const _=document.querySelector('meta[name="external-controller"]');((f=_==null?void 0:_.content)==null?void 0:f.match(/^https?:/))!=null&&(o=new URL(_.content))}const a=new URLSearchParams(t.search),l=(E=(h=(d=a.get("host"))!=null?d:(u=s==null?void 0:s[0])==null?void 0:u.hostname)!=null?h:o==null?void 0:o.hostname)!=null?E:"127.0.0.1",r=(L=(F=(N=a.get("port"))!=null?N:(x=s==null?void 0:s[0])==null?void 0:x.port)!=null?F:o==null?void 0:o.port)!=null?L:"9090",c=(I=(T=(C=a.get("secret"))!=null?C:(k=s==null?void 0:s[0])==null?void 0:k.secret)!=null?T:o==null?void 0:o.username)!=null?I:"",m=((j=a.get("protocol"))!=null?j:l==="127.0.0.1")?"http:":(Q=o==null?void 0:o.protocol)!=null?Q:window.location.protocol;return{hostname:l,port:r,secret:c,protocol:m}}const It=Y({key:"",instance:null});function $(){const{hostname:n,port:t,secret:s,protocol:o}=se(),[a,l]=B(It),r=`${o}//${n}:${t}?secret=${s}`;if(a.key===r)return a.instance;const c=new Tt(`${o}//${n}:${t}`,s);return l({key:r,instance:c}),c}const Ce=Y(!0),Rt=ye("language",void 0);function P(){const[n,t]=B(Rt),s=p.exports.useMemo(()=>n!=null?n:Lt(),[n]),o=p.exports.useCallback(function(a){function l(r){return lt(He[s][a],r)}return{t:l}},[s]);return{lang:s,locales:$t,setLang:t,translation:o}}const We=Y({version:"",premium:!1});function ie(){const[n,t]=B(We),s=$(),o=xe(Ce);return K([s],async function(){const a=await le.fromPromise(s.getVersion(),l=>l);o(a.isOk()),t(a.isErr()?{version:"",premium:!1}:{version:a.value.data.version,premium:!!a.value.data.premium})}),n}function ze(){const[{premium:n}]=B(We),t=$(),{data:s,mutate:o}=K(["/providers/rule",t,n],async()=>{if(!n)return[];const a=await t.getRuleProviders();return Object.keys(a.data.providers).map(l=>a.data.providers[l])});return{providers:s!=null?s:[],update:o}}const Mt=ye("profile",{breakConnections:!1});function je(){const[n,t]=B(Mt),s=p.exports.useCallback(o=>{t(ne(n,o))},[n,t]);return{data:n,set:we(s)}}const _e=Y([]);function Ge(){const[n,t]=B(_e),s=$(),{data:o,mutate:a}=K(["/providers/proxy",s],async()=>{const l=await s.getProxyProviders();return Object.keys(l.data.providers).map(r=>l.data.providers[r]).filter(r=>r.name!=="default").filter(r=>r.vehicleType!=="Compatible")});return p.exports.useEffect(()=>{t(o!=null?o:[])},[o,t]),{providers:n,update:a}}function be(){const n=$(),{data:t,mutate:s}=K(["/config",n],async()=>{var l;const a=(await n.getConfig()).data;return{port:a.port,socksPort:a["socks-port"],mixedPort:(l=a["mixed-port"])!=null?l:0,redirPort:a["redir-port"],mode:a.mode.toLowerCase(),logLevel:a["log-level"],allowLan:a["allow-lan"]}});return{general:t!=null?t:{},update:s}}const Ve=Ie({proxies:[],groups:[],global:{name:"GLOBAL",type:"Selector",now:"",history:[],all:[]}});function ue(){const[n,t]=B(Ve),s=we(t),o=$(),{mutate:a}=K(["/proxies",o],async()=>{const r=await o.getProxies(),c=r.data.proxies.GLOBAL;c.name="GLOBAL";const m=new Set(["Selector","URLTest","Fallback","LoadBalance"]),f=new Set(["DIRECT","REJECT","GLOBAL"]),u=c.all.filter(E=>!f.has(E)).map(E=>A(w({},r.data.proxies[E]),{name:E})),[d,h]=Ft(u,E=>!m.has(E.type));s({proxies:d,groups:h,global:c})}),l=p.exports.useCallback((r,c)=>{s(m=>{r==="GLOBAL"&&(m.global.now=c);for(const f of m.groups)f.name===r&&(f.now=c)})},[s]);return{proxies:n.proxies,groups:n.groups,global:n.global,update:a,markProxySelected:l,set:s}}const Ht=Y(n=>{const t=n(Ve),s=n(_e),o=new Map;for(const a of t.proxies)o.set(a.name,a);for(const a of s)for(const l of a.proxies)o.set(l.name,l);return o});function Je(){const{data:n,mutate:t}=K("/clashx",async()=>{var a,l;if(!ee())return{isClashX:!1,startAtLogin:!1,systemProxy:!1};const s=(a=await(b==null?void 0:b.getStartAtLogin()))!=null?a:!1,o=(l=await(b==null?void 0:b.isSystemProxySet()))!=null?l:!1;return{startAtLogin:s,systemProxy:o,isClashX:!0}});return{data:n,update:t}}const Ot=Ie([]);function Ut(){const[n,t]=B(Ot),s=we(t),o=$();async function a(){const l=await o.getRules();s(l.data.rules)}return{rules:n,update:a}}const Wt=Y({key:"",instance:null});function Xe(){var u,d;const n=se(),{general:t}=be(),s=ie(),[o,a]=B(Wt);if(!s.version||!t.logLevel)return null;const l=!!s.version||!0,r=`${n.protocol}//${n.hostname}:${n.port}/logs?level=${(u=t.logLevel)!=null?u:""}&useWebsocket=${l}&secret=${n.secret}`;if(o.key===r)return o.instance;const c=o.instance,m=`${n.protocol}//${n.hostname}:${n.port}/logs?level=${(d=t.logLevel)!=null?d:""}`,f=new Oe({url:m,bufferLength:200,token:n.secret,useWebsocket:l});return a({key:r,instance:f}),c!=null&&c.destory(),f}function zt(){const n=se(),t=ie(),s=!!t.version||!0,o=`${n.protocol}//${n.hostname}:${n.port}/connections`;return p.exports.useMemo(()=>t.version?new Oe({url:o,bufferLength:200,token:n.secret,useWebsocket:s}):null,[n.secret,o,s,t.version])}function jt(n){const{className:t,data:s,onClick:o,select:a,canClick:l,errSet:r,rowHeight:c}=n,{translation:m}=P(),{t:f}=m("Proxies"),[u,d]=p.exports.useState(!1),[h,E]=p.exports.useState(!1),x=p.exports.useRef(null);p.exports.useLayoutEffect(()=>{var C,T;E(((T=(C=x==null?void 0:x.current)==null?void 0:C.offsetHeight)!=null?T:0)>30)},[]);const N=u?"auto":c,F=l?o:W;function L(){d(!u)}const k=s.map(C=>{const T=g({"tags-selected":a===C,"cursor-pointer":l,error:r==null?void 0:r.has(C)});return e.createElement("li",{className:T,key:C,onClick:()=>F(C)},C)});return e.createElement("div",{className:g("flex items-start overflow-y-hidden",t),style:{height:N}},e.createElement("ul",{ref:x,className:g("tags",{expand:u})},k),h&&e.createElement("span",{className:"h-7 px-5 select-none cursor-pointer leading-7",onClick:L},f(u?"collapseText":"expandText")))}function Z(n){const{className:t,style:s,value:o="",align:a="center",inside:l=!1,autoFocus:r=!1,type:c="text",disabled:m=!1,onChange:f=W,onBlur:u=W,onEnter:d=W}=n,h=g("input",`text-${a}`,{"focus:shadow-none":l},t);function E(x){x.code==="Enter"&&d(x)}return e.createElement("input",{disabled:m,className:h,style:s,value:o,autoFocus:r,type:c,onChange:x=>f(x.target.value,x),onBlur:u,onKeyDown:E})}function qe(n){const{show:t=!0,title:s="Modal",size:o="small",footer:a=!0,onOk:l=W,onClose:r=W,bodyClassName:c,bodyStyle:m,className:f,style:u,children:d}=n,{translation:h}=P(),{t:E}=h("Modal"),x=p.exports.useRef(document.createElement("div")),N=p.exports.useRef(null);p.exports.useLayoutEffect(()=>{const k=x.current;return document.body.appendChild(k),()=>{document.body.removeChild(k)}},[]);function F(k){k.target===N.current&&r()}const L=e.createElement("div",{className:g("modal-mask",{"modal-show":t}),ref:N,onMouseDown:F},e.createElement("div",{className:g("modal",`modal-${o}`,f),style:u},e.createElement("div",{className:"modal-title"},s),e.createElement("div",{className:g("modal-body",c),style:m},d),a&&e.createElement("div",{className:"footer"},e.createElement(pe,{onClick:()=>r()},E("cancel")),e.createElement(pe,{type:"primary",onClick:()=>l()},E("ok")))));return Re.exports.createPortal(L,x.current)}const _t={success:"check",info:"info",warning:"info",error:"close"};function Gt(n){const{message:t="",type:s="info",inside:o=!1,children:a,className:l,style:r}=n,c=g("alert",`alert-${o?"note":"box"}-${s}`,l);return e.createElement("div",{className:c,style:r},e.createElement("span",{className:"alert-icon"},e.createElement(U,{type:_t[s],size:26})),t?e.createElement("p",{className:"alert-message"},t):e.createElement("div",{className:"alert-message"},a))}function pe(n){const{type:t="normal",onClick:s=W,children:o,className:a,style:l,disiabled:r}=n,c=g("button",`button-${t}`,a,{"button-disabled":r});return e.createElement("button",{className:c,style:l,onClick:s,disabled:r},o)}function re(n){const[t,s]=rt(n),o=p.exports.useMemo(()=>{function a(l,r){typeof l=="string"?s(c=>{const m=l,f=r;c[m]=f}):typeof l=="function"?s(l):typeof l=="object"&&s(c=>{const m=l;for(const f of Object.keys(m)){const u=f;c[u]=m[u]}})}return a},[s]);return[t,o]}function Vt(n,t=0){if(n.length<2)throw new Error("List requires at least two elements");const[s,o]=p.exports.useState(t);function a(){o((s+1)%n.length)}return{current:p.exports.useMemo(()=>n[s],[n,s]),next:a}}function Ne(n=!1){const[t,s]=p.exports.useState(n);function o(){s(!1)}function a(){s(!0)}return{visible:t,hide:o,show:a}}function Ye(n){const{className:t,checked:s=!1,onChange:o=W}=n,a=g("checkbox",{checked:s},t);function l(){o(!s)}return e.createElement("div",{className:a,onClick:l},e.createElement(U,{className:"checkbox-icon",type:"check",size:18}),e.createElement("div",null,n.children))}function ce(n){const{color:t,className:s,style:o}=n,a=g("tag",s),l=w({color:t},o),r=A(w({},n),{className:a,style:l});return e.createElement("span",w({},r),n.children)}function Jt(n){const t=g("spinner",n.className);return e.createElement("div",{className:t},e.createElement("div",{className:"spinner-circle"},e.createElement("div",{className:"spinner-inner"})),e.createElement("div",{className:"spinner-circle"},e.createElement("div",{className:"spinner-inner"})),e.createElement("div",{className:"spinner-circle"},e.createElement("div",{className:"spinner-inner"})),e.createElement("div",{className:"spinner-circle"},e.createElement("div",{className:"spinner-inner"})),e.createElement("div",{className:"spinner-circle"},e.createElement("div",{className:"spinner-inner"})))}function Ke(n){const t=g("loading","visible",n.className);return n.visible?e.createElement("div",{className:t},e.createElement(Jt,{className:n.spinnerClassName})):null}function Xt(n){var a,l,r;const t=p.exports.useRef(document.createElement("div"));p.exports.useLayoutEffect(()=>{const c=t.current;return document.body.appendChild(c),()=>{document.body.removeChild(c)}},[]);const s="absolute h-full right-0 transition-transform transform translate-x-full duration-100 pointer-events-auto",o=e.createElement("div",{className:g(n.className,"absolute inset-0 pointer-events-none z-9999")},e.createElement(z,{className:g(s,{"translate-x-0":n.visible}),style:{width:(a=n.width)!=null?a:400}},n.children));return Re.exports.createPortal(o,(r=(l=n.containerRef)==null?void 0:l.current)!=null?r:t.current)}ve.extend(ct);function Pe(n,t){const s=t==="en_US"?"en":"zh-cn";return ve().locale(s).from(n)}function qt(n){const{translation:t}=P(),s=p.exports.useMemo(()=>t("Connections").t,[t]),{className:o,style:a}=n,l=g("flex flex-wrap px-1",o);function r(c){var m;(m=n.onChange)==null||m.call(n,c)}return e.createElement("div",{className:l,style:a},e.createElement("div",{className:g("connections-devices-item pt-2 mb-2",{selected:n.selected===""}),onClick:()=>r("")},s("filter.all")),n.devices.map(c=>e.createElement("div",{key:c.label,className:g("connections-devices-item pt-2 mb-2",{selected:n.selected===c.label}),onClick:()=>r(c.label)},c.label," (",c.number,")")))}function Yt(n){var o,a,l,r,c,m,f,u,d,h,E,x,N;const{translation:t}=P(),s=p.exports.useMemo(()=>t("Connections").t,[t]);return e.createElement("div",{className:g(n.className,"text-sm flex flex-col")},e.createElement("div",{className:"flex my-3"},e.createElement("span",{className:"font-bold w-20"},s("info.id")),e.createElement("span",{className:"font-mono"},n.connection.id)),e.createElement("div",{className:"flex my-3 justify-between"},e.createElement("div",{className:"flex flex-1"},e.createElement("span",{className:"font-bold w-20"},s("info.network")),e.createElement("span",{className:"font-mono"},(o=n.connection.metadata)==null?void 0:o.network)),e.createElement("div",{className:"flex flex-1"},e.createElement("span",{className:"font-bold w-20"},s("info.inbound")),e.createElement("span",{className:"font-mono"},(a=n.connection.metadata)==null?void 0:a.type))),e.createElement("div",{className:"flex my-3"},e.createElement("span",{className:"font-bold w-20"},s("info.host")),e.createElement("span",{className:"font-mono flex-1 break-all"},(l=n.connection.metadata)!=null&&l.host?`${n.connection.metadata.host}:${(r=n.connection.metadata)==null?void 0:r.destinationPort}`:s("info.hostEmpty"))),e.createElement("div",{className:"flex my-3"},e.createElement("span",{className:"font-bold w-20"},s("info.dstIP")),e.createElement("span",{className:"font-mono"},(c=n.connection.metadata)!=null&&c.destinationIP?`${n.connection.metadata.destinationIP}:${(m=n.connection.metadata)==null?void 0:m.destinationPort}`:s("info.hostEmpty"))),e.createElement("div",{className:"flex my-3"},e.createElement("span",{className:"font-bold w-20"},s("info.srcIP")),e.createElement("span",{className:"font-mono"},`${(f=n.connection.metadata)==null?void 0:f.sourceIP}:${(u=n.connection.metadata)==null?void 0:u.sourcePort}`)),e.createElement("div",{className:"flex my-3"},e.createElement("span",{className:"font-bold w-20"},s("info.process")),e.createElement("span",{className:"font-mono"},(d=n.connection.metadata)!=null&&d.processPath?`${Me(n.connection.metadata.processPath)}`:s("info.hostEmpty"))),e.createElement("div",{className:"flex my-3"},e.createElement("span",{className:"font-bold w-20"},s("info.processPath")),e.createElement("span",{className:"font-mono flex-1 break-all"},(h=n.connection.metadata)!=null&&h.processPath?`${n.connection.metadata.processPath}`:s("info.hostEmpty"))),e.createElement("div",{className:"flex my-3"},e.createElement("span",{className:"font-bold w-20"},s("info.rule")),e.createElement("span",{className:"font-mono"},n.connection.rule&&`${n.connection.rule}${n.connection.rulePayload&&` :: ${n.connection.rulePayload}`}`)),e.createElement("div",{className:"flex my-3"},e.createElement("span",{className:"font-bold w-20"},s("info.chains")),e.createElement("span",{className:"font-mono flex-1 break-all"},(E=n.connection.chains)==null?void 0:E.slice().reverse().join(" / "))),e.createElement("div",{className:"flex my-3 justify-between"},e.createElement("div",{className:"flex flex-1"},e.createElement("span",{className:"font-bold w-20"},s("info.upload")),e.createElement("span",{className:"font-mono"},O((x=n.connection.upload)!=null?x:0))),e.createElement("div",{className:"flex flex-1"},e.createElement("span",{className:"font-bold w-20"},s("info.download")),e.createElement("span",{className:"font-mono"},O((N=n.connection.download)!=null?N:0)))),e.createElement("div",{className:"flex my-3"},e.createElement("span",{className:"font-bold w-20"},s("info.status")),e.createElement("span",{className:"font-mono"},n.connection.completed?e.createElement("span",{className:"text-red"},s("info.closed")):e.createElement("span",{className:"text-green"},s("info.opening")))))}class Kt{constructor(){this.connections=new Map,this.saveDisconnection=!1}appendToSet(t){var o;const s=t.reduce((a,l)=>a.set(l.id,l),new Map);for(const a of this.connections.keys())if(!s.has(a))if(!this.saveDisconnection)this.connections.delete(a);else{const l=this.connections.get(a);l!=null&&this.connections.set(a,ne(l,r=>{r.completed=!0,r.uploadSpeed=0,r.downloadSpeed=0}))}for(const a of s.keys()){if(!this.connections.has(a)){this.connections.set(a,A(w({},s.get(a)),{uploadSpeed:0,downloadSpeed:0}));continue}const l=this.connections.get(a),r=s.get(a);(o=this.connections)==null||o.set(a,A(w({},r),{uploadSpeed:r.upload-l.upload,downloadSpeed:r.download-l.download}))}}toggleSave(){var t,s;if(this.saveDisconnection){this.saveDisconnection=!1;for(const o of this.connections.keys())(s=(t=this.connections)==null?void 0:t.get(o))!=null&&s.completed&&this.connections.delete(o)}else this.saveDisconnection=!0;return this.saveDisconnection}getConnections(){return[...this.connections.values()]}}function Qt(){const n=p.exports.useMemo(()=>new Kt,[]),t=p.exports.useRef(!0),[s,o]=p.exports.useState([]),[a,l]=p.exports.useState(!1),r=p.exports.useCallback(function(m){n.appendToSet(m),t.current&&o(n.getConnections()),t.current=!t.current},[n]),c=p.exports.useCallback(function(){const m=n.toggleSave();l(m),m||o(n.getConnections()),t.current=!0},[n]);return{connections:s,feed:r,toggleSave:c,save:a}}const Zt=new Set(["network","type","speed","upload","download","sourceIP","time","process"]);function en(n,t){switch(!0){case(n===0&&t===0):return"-";case(n!==0&&t!==0):return`\u2191 ${O(n)}/s \u2193 ${O(t)}/s`;case n!==0:return`\u2191 ${O(n)}/s`;default:return`\u2193 ${O(t)}/s`}}const S=it();function tn(){const{translation:n,lang:t}=P(),s=p.exports.useMemo(()=>n("Connections").t,[n]),o=zt(),a=$(),l=p.exports.useRef(null),[r,c]=re({uploadTotal:0,downloadTotal:0}),{visible:m,show:f,hide:u}=Ne();function d(){a.closeAllConnections().finally(()=>u())}const{connections:h,feed:E,save:x,toggleSave:N}=Qt(),F=p.exports.useMemo(()=>h.map(i=>({id:i.id,host:`${i.metadata.host||i.metadata.destinationIP}:${i.metadata.destinationPort}`,chains:i.chains.slice().reverse().join(" / "),rule:i.rulePayload?`${i.rule} :: ${i.rulePayload}`:i.rule,time:new Date(i.start).getTime(),upload:i.upload,download:i.download,sourceIP:i.metadata.sourceIP,type:i.metadata.type,network:i.metadata.network.toUpperCase(),process:i.metadata.processPath,speed:{upload:i.uploadSpeed,download:i.downloadSpeed},completed:!!i.completed,original:i})),[h]),L=p.exports.useMemo(()=>{const i=ut(h,"metadata.sourceIP");return Object.keys(i).map(v=>({label:v,number:i[v].length})).sort((v,y)=>v.label.localeCompare(y.label))},[h]),k=p.exports.useRef(null),C=mt(k,{threshold:[1]}),T=p.exports.useMemo(()=>S.createColumns([S.createDataColumn("host",{minWidth:260,width:260,header:s("columns.host")}),S.createDataColumn("network",{minWidth:80,width:80,header:s("columns.network")}),S.createDataColumn("type",{minWidth:100,width:100,header:s("columns.type")}),S.createDataColumn("chains",{minWidth:200,width:200,header:s("columns.chains")}),S.createDataColumn("rule",{minWidth:140,width:140,header:s("columns.rule")}),S.createDataColumn("process",{minWidth:100,width:100,header:s("columns.process"),cell:i=>i.value?Me(i.value):"-"}),S.createDataColumn(i=>[i.speed.upload,i.speed.download],{id:"speed",header:s("columns.speed"),minWidth:200,width:200,sortDescFirst:!0,sortType(i,v){var H,D,q,ke;const y=(D=(H=i.original)==null?void 0:H.speed)!=null?D:{upload:0,download:0},M=(ke=(q=v.original)==null?void 0:q.speed)!=null?ke:{upload:0,download:0};return y.download===M.download?y.upload-M.upload:y.download-M.download},cell:i=>en(i.value[0],i.value[1])}),S.createDataColumn("upload",{minWidth:100,width:100,header:s("columns.upload"),cell:i=>O(i.value)}),S.createDataColumn("download",{minWidth:100,width:100,header:s("columns.download"),cell:i=>O(i.value)}),S.createDataColumn("sourceIP",{minWidth:140,width:140,header:s("columns.sourceIP"),filterType:"equals"}),S.createDataColumn("time",{minWidth:120,width:120,header:s("columns.time"),cell:i=>Pe(new Date(i.value),t),sortType:(i,v)=>{var y,M,H,D;return((M=(y=v.original)==null?void 0:y.time)!=null?M:0)-((D=(H=i.original)==null?void 0:H.time)!=null?D:0)}})]),[t,s]);p.exports.useLayoutEffect(()=>{function i(v){for(const y of v)c({uploadTotal:y.uploadTotal,downloadTotal:y.downloadTotal}),E(y.connections)}return o==null||o.subscribe("data",i),()=>{o==null||o.unsubscribe("data",i),o==null||o.destory()}},[o,E,c]);const I=dt(S,{data:F,columns:T,getCoreRowModel:ft(),getSortedRowModel:ht(),getColumnFilteredRowModel:Et(),initialState:{sorting:[{id:"time",desc:!1}]},columnResizeMode:"onChange",enableColumnResizing:!0,autoResetSorting:!1,autoResetColumnFilters:!1}),j=I.getHeaderGroups()[0],[Q,_]=p.exports.useState("");function me(i){_(i),I.setColumnFilterValue("sourceIP",i||void 0)}const[R,G]=re({visible:!1,selectedID:"",connection:{}});function V(){G(i=>{i.connection.completed=!0}),a.closeConnection(R.selectedID)}const X=pt(R.connection);p.exports.useEffect(()=>{var v;const i=(v=F.find(y=>y.id===R.selectedID))==null?void 0:v.original;i?G(y=>{y.connection=w({},i),R.selectedID===X.current.id&&(y.connection.completed=X.current.completed)}):Object.keys(X.current).length!==0&&!X.current.completed&&G(y=>{y.connection.completed=!0})},[F,R.selectedID,X,G]);const te=p.exports.useMemo(()=>{var i;return((i=C==null?void 0:C.intersectionRatio)!=null?i:0)<1},[C]),oe=j.headers.map((i,v)=>{const y=i.column,M=y.id;return e.createElement("th",A(w({},i.getHeaderProps(H=>ne(H,D=>{D.className=g("connections-th",{resizing:y.getIsResizing(),fixed:y.id==="host",shadow:te&&y.id==="host"}),!D.style&&(D.style={}),D.style.width=i.getWidth()}))),{ref:y.id==="host"?k:void 0,key:M}),e.createElement("div",w({},y.getToggleSortingProps()),i.renderHeader(),y.getIsSorted()!==!1?y.getIsSorted()==="desc"?" \u2193":" \u2191":null),v!==j.headers.length-1&&e.createElement("div",A(w({},i.getResizerProps()),{className:"connections-resizer"})))}),ae=I.getRowModel().rows.map(i=>{var v;return e.createElement("tr",A(w({},i.getRowProps()),{className:"cursor-default select-none",key:(v=i.original)==null?void 0:v.id,onClick:()=>{var y;return G({visible:!0,selectedID:(y=i.original)==null?void 0:y.id})}}),i.getAllCells().map(y=>{var H;const M=g("connections-block",{"text-center":Zt.has(y.column.id),completed:(H=i.original)==null?void 0:H.completed},{fixed:y.column.id==="host",shadow:te&&y.column.id==="host"});return e.createElement("td",A(w({},y.getCellProps(D=>ne(D,q=>{!q.style&&(q.style={}),q.className=M,q.style.width=y.column.getWidth()}))),{key:y.column.id}),y.renderCell())}))});return e.createElement("div",{className:"page !h-100vh"},e.createElement(J,{title:s("title")},e.createElement("span",{className:"cursor-default flex-1 connections-filter"},`(${s("total.text")}: ${s("total.upload")} ${O(r.uploadTotal)} ${s("total.download")} ${O(r.downloadTotal)})`),e.createElement(Ye,{className:"connections-filter",checked:x,onChange:N},s("keepClosed")),e.createElement(U,{className:"connections-filter dangerous",onClick:f,type:"close-all",size:20})),L.length>1&&e.createElement(qt,{devices:L,selected:Q,onChange:me}),e.createElement(z,{ref:l,className:"connections-card relative"},e.createElement("div",{className:"overflow-auto min-h-full min-w-full"},e.createElement("table",w({},I.getTableProps()),e.createElement("thead",null,e.createElement("tr",A(w({},j.getHeaderGroupProps()),{className:"connections-header"}),oe)),e.createElement("tbody",w({},I.getTableBodyProps()),ae)))),e.createElement(qe,{title:s("closeAll.title"),show:m,onClose:u,onOk:d},s("closeAll.content")),e.createElement(Xt,{containerRef:l,visible:R.visible,width:450},e.createElement("div",{className:"flex h-8 justify-between items-center"},e.createElement("span",{className:"font-bold pl-3"},s("info.title")),e.createElement(U,{type:"close",size:16,className:"cursor-pointer",onClick:()=>G("visible",!1)})),e.createElement(Yt,{className:"mt-3 px-5",connection:R.connection}),e.createElement("div",{className:"flex mt-3 pr-3 justify-end"},e.createElement(pe,{type:"danger",disiabled:R.connection.completed,onClick:()=>V()},s("info.closeConnection")))))}function nn(){const{translation:n}=P(),{t}=n("Settings"),{hostname:s,port:o,secret:a}=se(),[l,r]=B(Ce),[c,m]=re({hostname:"",port:"",secret:""});p.exports.useEffect(()=>{m({hostname:s,port:o,secret:a})},[s,o,a,m]);const f=xe(Ue);function u(){const{hostname:d,port:h,secret:E}=c;f([{hostname:d,port:h,secret:E}])}return e.createElement(qe,{show:!l,title:t("externalControllerSetting.title"),bodyClassName:"external-controller",onClose:()=>r(!0),onOk:u},e.createElement(Gt,{type:"info",inside:!0},e.createElement("p",null,t("externalControllerSetting.note"))),e.createElement("div",{className:"flex items-center"},e.createElement("span",{className:"font-bold my-1 w-14 md:my-3"},t("externalControllerSetting.host")),e.createElement(Z,{className:"flex-1 my-1 md:my-3",align:"left",inside:!0,value:c.hostname,onChange:d=>m("hostname",d),onEnter:u})),e.createElement("div",{className:"flex items-center"},e.createElement("div",{className:"font-bold my-1 w-14 md:my-3"},t("externalControllerSetting.port")),e.createElement(Z,{className:"flex-1 my-1 w-14 md:my-3",align:"left",inside:!0,value:c.port,onChange:d=>m("port",d),onEnter:u})),e.createElement("div",{className:"flex items-center"},e.createElement("div",{className:"font-bold my-1 w-14 md:my-3"},t("externalControllerSetting.secret")),e.createElement(Z,{className:"flex-1 my-1 w-14 md:my-3",align:"left",inside:!0,value:c.secret,onChange:d=>m("secret",d),onEnter:u})))}function sn(){var m,f;const n=p.exports.useRef(null),t=p.exports.useRef([]),[s,o]=p.exports.useState([]),{translation:a}=P(),{t:l}=a("Logs"),r=Xe(),c=p.exports.useRef((f=(m=n.current)==null?void 0:m.scrollHeight)!=null?f:0);return p.exports.useLayoutEffect(()=>{var d;const u=n.current;u!=null&&c.current===u.scrollTop+u.clientHeight&&(u.scrollTop=u.scrollHeight-u.clientHeight),c.current=(d=u==null?void 0:u.scrollHeight)!=null?d:0}),p.exports.useEffect(()=>{function u(d){t.current=t.current.slice().concat(d.map(h=>A(w({},h),{time:new Date}))),o(t.current)}return r!=null&&(r.subscribe("data",u),t.current=r.buffer(),o(t.current)),()=>r==null?void 0:r.unsubscribe("data",u)},[r]),e.createElement("div",{className:"page"},e.createElement(J,{title:l("title")}),e.createElement(z,{className:"flex flex-col flex-1 mt-2.5 md:mt-4"},e.createElement("ul",{className:"logs-panel",ref:n},s.map((u,d)=>e.createElement("li",{className:"leading-5 inline-block",key:d},e.createElement("span",{className:"mr-4 text-gray-400 text-opacity-90"},ve(u.time).format("YYYY-MM-DD HH:mm:ss")),e.createElement("span",null,"[",u.type,"] ",u.payload))))))}var fe=(n=>(n.SPEED_NOTIFY="speed-notify",n))(fe||{});class on{constructor(){this.EE=new Be}notifySpeedTest(){this.EE.emit("speed-notify")}subscribe(t,s){this.EE.addListener(t,s)}unsubscribe(t,s){this.EE.removeListener(t,s)}}var he=new on;const Le={"#909399":0,"#00c520":260,"#ff9a28":600,"#ff3e5e":1/0};function Qe(n){const{config:t,className:s}=n,{set:o}=ue(),a=$(),l=p.exports.useCallback(async d=>{var E;if(ee())return(E=await(b==null?void 0:b.getProxyDelay(d)))!=null?E:0;const{data:{delay:h}}=await a.getProxyDelay(d);return h},[a]),r=p.exports.useCallback(async function(){const d=await le.fromPromise(l(t.name),E=>E),h=d.isErr()?0:d.value;o(E=>{const x=E.proxies.find(N=>N.name===t.name);x!=null&&x.history.push({time:Date.now().toString(),delay:h})})},[t.name,l,o]),c=p.exports.useMemo(()=>{var d;return(d=t.history)!=null&&d.length?t.history.slice(-1)[0].delay:0},[t]);p.exports.useLayoutEffect(()=>{const d=()=>{r()};return he.subscribe(fe.SPEED_NOTIFY,d),()=>he.unsubscribe(fe.SPEED_NOTIFY,d)},[r]);const m=p.exports.useMemo(()=>c===0,[c]),f=p.exports.useMemo(()=>Object.keys(Le).find(d=>c<=Le[d]),[c]),u=m?void 0:f;return e.createElement("div",{className:g("proxy-item",{"proxy-error":m},s)},e.createElement("span",{className:"proxy-type",style:{backgroundColor:u}},t.type),e.createElement("p",{className:"proxy-name"},t.name),e.createElement("p",{className:"proxy-delay"},c===0?"-":`${c}ms`))}function an(n){const{markProxySelected:t}=ue(),[s]=B(Ht),{data:o}=je(),a=$(),{config:l}=n;async function r(f){if(await a.changeProxySelected(n.config.name,f),t(n.config.name,f),o.breakConnections){const u=[],d=await a.getConnections();for(const h of d.data.connections)h.chains.includes(n.config.name)&&u.push(h.id);await Promise.all(u.map(h=>a.closeConnection(h)))}}const c=p.exports.useMemo(()=>{var u;const f=new Set;for(const d of l.all){const h=(u=s.get(d))==null?void 0:u.history;(h==null?void 0:h.length)&&h.slice(-1)[0].delay===0&&f.add(d)}return f},[l.all,s]),m=l.type==="Selector";return e.createElement("div",{className:"proxy-group"},e.createElement("div",{className:"flex h-10 mt-4 w-full items-center justify-between md:h-15 md:mt-0 md:w-auto "},e.createElement("span",{className:"h-6 px-5 w-35 overflow-hidden overflow-ellipsis whitespace-nowrap md:w-30"},l.name),e.createElement(ce,{className:"mr-5 md:mr-0"},l.type)),e.createElement("div",{className:"flex-1 py-2 md:py-4"},e.createElement(jt,{className:"ml-5 md:ml-8",data:l.all,onClick:r,errSet:c,select:l.now,canClick:m,rowHeight:30})))}function ln(n){const{update:t}=Ge(),{translation:s,lang:o}=P(),a=$(),{provider:l}=n,{t:r}=s("Proxies"),{visible:c,hide:m,show:f}=Ne();function u(){f(),a.healthCheckProvider(l.name).then(async()=>await t()).finally(()=>m())}function d(){f(),a.updateProvider(l.name).then(async()=>await t()).finally(()=>m())}const h=p.exports.useMemo(()=>l.proxies.slice().sort((E,x)=>-1*Ee(E,x)),[l.proxies]);return e.createElement(z,{className:"proxy-provider"},e.createElement(Ke,{visible:c}),e.createElement("div",{className:"flex flex-col justify-between md:flex-row md:items-center "},e.createElement("div",{className:"flex items-center"},e.createElement("span",{className:"mr-6"},l.name),e.createElement(ce,null,l.vehicleType)),e.createElement("div",{className:"flex pt-3 items-center md:pt-0"},l.updatedAt&&e.createElement("span",{className:"text-sm"},`${r("providerUpdateTime")}: ${Pe(new Date(l.updatedAt),o)}`),e.createElement(U,{className:"cursor-pointer text-red pl-5",type:"healthcheck",size:18,onClick:u}),e.createElement(U,{className:"cursor-pointer pl-5",type:"update",size:18,onClick:d}))),e.createElement("ul",{className:"proxies-list"},h.map(E=>e.createElement("li",{key:E.name},e.createElement(Qe,{className:"proxy-provider-item",config:E})))))}const rn={[0]:"sort",[1]:"sort-ascending",[2]:"sort-descending"};function Ee(n,t){const s=n.history.length>0?n.history.slice(-1)[0].delay:0;return((t.history.length>0?t.history.slice(-1)[0].delay:0)||Number.MAX_SAFE_INTEGER)-(s||Number.MAX_SAFE_INTEGER)}function cn(){const{groups:n,global:t}=ue(),{data:s,set:o}=je(),{general:a}=be(),{translation:l}=P(),{t:r}=l("Proxies"),c=p.exports.useMemo(()=>a.mode==="global"?[t,...n]:n,[a,n,t]);return e.createElement(e.Fragment,null,c.length!==0&&e.createElement("div",{className:"flex flex-col"},e.createElement(J,{title:r("groupTitle")},e.createElement(Ye,{className:"cursor-pointer text-sm text-shadow-primary text-primary-600",checked:s.breakConnections,onChange:m=>o("breakConnections",m)},r("breakConnectionsText"))),e.createElement(z,{className:"my-2.5 p-0 md:my-4"},e.createElement("ul",{className:"list-none divide-y divide-gray-300"},c.map(m=>e.createElement("li",{key:m.name},e.createElement(an,{config:m})))))))}function un(){const{providers:n}=Ge(),{translation:t}=P(),{t:s}=t("Proxies");return e.createElement(e.Fragment,null,n.length!==0&&e.createElement("div",{className:"flex flex-col"},e.createElement(J,{title:s("providerTitle")}),e.createElement("ul",{className:"list-none"},n.map(o=>e.createElement("li",{className:"my-2.5 md:my-4",key:o.name},e.createElement(ln,{provider:o}))))))}function mn(){const{proxies:n}=ue(),{translation:t}=P(),{t:s}=t("Proxies");function o(){he.notifySpeedTest()}const{current:a,next:l}=Vt([1,2,0]),r=p.exports.useMemo(()=>{switch(a){case 2:return n.slice().sort((m,f)=>Ee(m,f));case 1:return n.slice().sort((m,f)=>-1*Ee(m,f));default:return n.slice()}},[a,n]),c=l;return e.createElement(e.Fragment,null,r.length!==0&&e.createElement("div",{className:"flex flex-col"},e.createElement(J,{title:s("title")},e.createElement(U,{className:"ml-3",type:rn[a],onClick:c,size:20}),e.createElement(U,{className:"ml-3",type:"speed",size:20}),e.createElement("span",{className:"proxies-speed-test",onClick:o},s("speedTestText"))),e.createElement("ul",{className:"proxies-list"},r.map(m=>e.createElement("li",{key:m.name},e.createElement(Qe,{config:m}))))))}function dn(){return e.createElement("div",{className:"page"},e.createElement(cn,null),e.createElement(un,null),e.createElement(mn,null))}function pn(n){const{update:t}=ze(),{translation:s,lang:o}=P(),a=$(),{provider:l}=n,{t:r}=s("Rules"),{visible:c,hide:m,show:f}=Ne();function u(){f(),a.updateRuleProvider(l.name).then(async()=>await t()).finally(()=>m())}const d=g("rule-provider-icon",{"rule-provider-loading":c});return e.createElement("div",{className:"rule-provider"},e.createElement("div",{className:"rule-provider-header"},e.createElement("div",{className:"rule-provider-header-part"},e.createElement("span",{className:"rule-provider-name"},l.name),e.createElement(ce,null,l.vehicleType),e.createElement(ce,{className:"rule-provider-behavior"},l.behavior),e.createElement("span",{className:"rule-provider-update"},`${r("ruleCount")}: ${l.ruleCount}`)),e.createElement("div",{className:"rule-provider-header-part"},l.updatedAt&&e.createElement("span",{className:"rule-provider-update"},`${r("providerUpdateTime")}: ${Pe(new Date(l.updatedAt),o)}`),e.createElement(U,{className:d,type:"update",size:18,onClick:u}))))}function fn(){const{providers:n}=ze(),{translation:t}=P(),{t:s}=t("Rules");return e.createElement(e.Fragment,null,n.length!==0&&e.createElement("div",{className:"flex flex-col"},e.createElement(J,{title:s("providerTitle")}),e.createElement(z,{className:"divide-y rounded shadow-primary mt-4 p-0"},n.map(o=>e.createElement(pn,{key:o.name,provider:o})))))}function hn(){const{rules:n,update:t}=Ut(),{translation:s}=P(),{t:o}=s("Rules");K("rules",t);function a({index:l,style:r}){const c=n[l];return e.createElement("li",{className:"rule-item",style:r},e.createElement("div",{className:"flex py-1"},e.createElement("div",{className:"text-center w-40 rule-type"},c.type),e.createElement("div",{className:"flex-1 text-center payload"},c.payload),e.createElement("div",{className:"text-center w-40 rule-proxy"},c.proxy)))}return e.createElement("div",{className:"page"},e.createElement(fn,null),e.createElement(J,{className:"not-first:mt-7.5",title:o("title")}),e.createElement(z,{className:"flex flex-col flex-1 mt-2.5 p-0 md:mt-4 focus:outline-none"},e.createElement(yt,{className:"min-h-120"},({height:l,width:r})=>e.createElement(gt,{height:l,width:r,itemCount:n.length,itemSize:50},a))))}const En=[{label:"\u4E2D\u6587",value:"zh_CN"},{label:"English",value:"en_US"}];function yn(){var te,oe,ae;const{premium:n}=ie(),{data:t,update:s}=Je(),{general:o,update:a}=be(),l=xe(Ce),r=se(),{translation:c,setLang:m,lang:f}=P(),{t:u}=c("Settings"),d=$(),[h,E]=re({socks5ProxyPort:7891,httpProxyPort:7890,mixedProxyPort:0});p.exports.useEffect(()=>{var i,v,y;E("socks5ProxyPort",(i=o==null?void 0:o.socksPort)!=null?i:0),E("httpProxyPort",(v=o==null?void 0:o.port)!=null?v:0),E("mixedProxyPort",(y=o==null?void 0:o.mixedPort)!=null?y:0)},[o,E]);async function x(i){await d.updateConfig({mode:i}),await a()}async function N(i){await(b==null?void 0:b.setStartAtLogin(i)),await s()}async function F(i){await(b==null?void 0:b.setSystemProxy(i)),await s()}function L(i){m(i)}async function k(){await d.updateConfig({port:h.httpProxyPort}),await a()}async function C(){await d.updateConfig({"socks-port":h.socks5ProxyPort}),await a()}async function T(){await d.updateConfig({"mixed-port":h.mixedProxyPort}),await a()}async function I(i){await d.updateConfig({"allow-lan":i}),await a()}const{hostname:j,port:Q}=r,{allowLan:_,mode:me}=o,R=(te=t==null?void 0:t.startAtLogin)!=null?te:!1,G=(oe=t==null?void 0:t.systemProxy)!=null?oe:!1,V=(ae=t==null?void 0:t.isClashX)!=null?ae:!1,X=p.exports.useMemo(()=>{const i=[{label:u("values.global"),value:"Global"},{label:u("values.rules"),value:"Rule"},{label:u("values.direct"),value:"Direct"}];return n&&i.push({label:u("values.script"),value:"Script"}),i},[u,n]);return e.createElement("div",{className:"page"},e.createElement(J,{title:u("title")}),e.createElement(z,{className:"settings-card"},e.createElement("div",{className:"flex flex-wrap"},e.createElement("div",{className:"flex w-full py-3 px-8 items-center justify-between md:w-1/2"},e.createElement("span",{className:"font-bold label"},u("labels.startAtLogin")),e.createElement(de,{disabled:!(t!=null&&t.isClashX),checked:R,onChange:N})),e.createElement("div",{className:"flex w-full py-3 px-8 items-center justify-between md:w-1/2"},e.createElement("span",{className:"font-bold label"},u("labels.language")),e.createElement($e,{options:En,value:f,onSelect:i=>L(i)}))),e.createElement("div",{className:"flex flex-wrap"},e.createElement("div",{className:"flex w-full py-3 px-8 items-center justify-between md:w-1/2"},e.createElement("span",{className:"font-bold label"},u("labels.setAsSystemProxy")),e.createElement(de,{disabled:!V,checked:G,onChange:F})),e.createElement("div",{className:"flex w-full py-3 px-8 items-center justify-between md:w-1/2"},e.createElement("span",{className:"font-bold label"},u("labels.allowConnectFromLan")),e.createElement(de,{checked:_,onChange:I})))),e.createElement(z,{className:"settings-card"},e.createElement("div",{className:"flex flex-wrap"},e.createElement("div",{className:"flex w-full py-3 px-8 items-center justify-between md:w-1/2"},e.createElement("span",{className:"font-bold label"},u("labels.proxyMode")),e.createElement($e,{options:X,value:xt(me),onSelect:x})),e.createElement("div",{className:"flex w-full py-3 px-8 items-center justify-between md:w-1/2"},e.createElement("span",{className:"font-bold label"},u("labels.socks5ProxyPort")),e.createElement(Z,{className:"w-28",disabled:V,value:h.socks5ProxyPort,onChange:i=>E("socks5ProxyPort",+i),onBlur:C}))),e.createElement("div",{className:"flex flex-wrap"},e.createElement("div",{className:"flex w-full py-3 px-8 items-center justify-between md:w-1/2"},e.createElement("span",{className:"font-bold label"},u("labels.httpProxyPort")),e.createElement(Z,{className:"w-28",disabled:V,value:h.httpProxyPort,onChange:i=>E("httpProxyPort",+i),onBlur:k})),e.createElement("div",{className:"flex w-full py-3 px-8 items-center justify-between md:w-1/2"},e.createElement("span",{className:"font-bold label"},u("labels.mixedProxyPort")),e.createElement(Z,{className:"w-28",disabled:V,value:h.mixedProxyPort,onChange:i=>E("mixedProxyPort",+i),onBlur:T}))),e.createElement("div",{className:"flex flex-wrap"},e.createElement("div",{className:"flex w-full py-3 px-8 items-center justify-between md:w-1/2"},e.createElement("span",{className:"font-bold label"},u("labels.externalController")),e.createElement("span",{className:g({"modify-btn":!V},"external-controller"),onClick:()=>!V&&l(!1)},`${j}:${Q}`)),e.createElement("div",{className:"px-8 w-1/2"}))))}var gn="./assets/logo.b453e72f.png";function xn(n){const{routes:t}=n,{translation:s}=P(),{version:o,premium:a}=ie(),{data:l}=Je(),{t:r}=s("SideBar"),c=ge(),m=t.map(({path:f,name:u,noMobile:d})=>e.createElement("li",{className:g("item",{"no-mobile":d}),key:u},e.createElement(vt,{to:{pathname:f,search:c.search},className:({isActive:h})=>g({active:h})},r(u))));return e.createElement("div",{className:"sidebar"},e.createElement("img",{src:gn,alt:"logo",className:"sidebar-logo"}),e.createElement("ul",{className:"sidebar-menu"},m),e.createElement("div",{className:"sidebar-version"},e.createElement("span",{className:"sidebar-version-label"},"Clash",(l==null?void 0:l.isClashX)&&"X"," ",r("Version")),e.createElement("span",{className:"sidebar-version-text"},o),a&&e.createElement("span",{className:"sidebar-version-label"},"Premium")))}function vn(){Xe();const n=ge(),t=[{path:"/proxies",name:"Proxies",element:e.createElement(dn,null)},{path:"/logs",name:"Logs",element:e.createElement(sn,null)},{path:"/rules",name:"Rules",element:e.createElement(hn,null),noMobile:!0},{path:"/connections",name:"Connections",element:e.createElement(tn,null),noMobile:!0},{path:"/settings",name:"Settings",element:e.createElement(yn,null)}];return e.createElement("div",{className:g("app",{"not-clashx":!ee()})},e.createElement(xn,{routes:t}),e.createElement("div",{className:"page-container"},e.createElement(wt,null,e.createElement(Ae,{path:"/",element:e.createElement(Ct,{to:{pathname:"/proxies",search:n.search},replace:!0})}),t.map(s=>e.createElement(Ae,{path:s.path,key:s.path,element:s.element})))),e.createElement(nn,null))}function Te(){const n=document.getElementById("root"),t=e.createElement(p.exports.StrictMode,null,e.createElement(Nt,null,e.createElement(p.exports.Suspense,{fallback:e.createElement(Ke,{visible:!0})},e.createElement(vn,null))));bt(n).render(t)}ee()?St(()=>Te()):Te();