3 lines
50 KiB
JavaScript
3 lines
50 KiB
JavaScript
![]() |
var nt=Object.defineProperty,st=Object.defineProperties;var ot=Object.getOwnPropertyDescriptors;var Fe=Object.getOwnPropertySymbols;var at=Object.prototype.hasOwnProperty,rt=Object.prototype.propertyIsEnumerable;var $e=(e,t,n)=>t in e?nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,P=(e,t)=>{for(var n in t||(t={}))at.call(t,n)&&$e(e,n,t[n]);if(Fe)for(var n of Fe(t))rt.call(t,n)&&$e(e,n,t[n]);return e},k=(e,t)=>st(e,ot(t));import{j as c,c as v,a as s,r as d,f as Le,E as Ie,R as le,b as it,d as G,e as ye,u as Be,g as lt,h as R,i as Te,k as xe,Z as V,l as ct,m as ge,n as ut,o as ve,p as dt,q as mt,s as ht,t as te,v as pt,F as ce,A as ft,w as yt,x as xt,N as gt,S as vt,y as Re,z as wt,H as Ct}from"./vendor.fda3e1c9.js";const bt=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 r of a)if(r.type==="childList")for(const i of r.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&o(i)}).observe(document,{childList:!0,subtree:!0});function n(a){const r={};return a.integrity&&(r.integrity=a.integrity),a.referrerpolicy&&(r.referrerPolicy=a.referrerpolicy),a.crossorigin==="use-credentials"?r.credentials="include":a.crossorigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function o(a){if(a.ep)return;a.ep=!0;const r=n(a);fetch(a.href,r)}};bt();function Y(){return navigator.userAgent==="ClashX Runtime"}let E=null;class Nt{constructor(t){this.instance=null,window.WebViewJavascriptBridge!=null&&(this.instance=window.WebViewJavascriptBridge),this.initBridge(n=>{this.instance=n,t()})}initBridge(t){if(!Y())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 n=document.createElement("iframe");n.style.display="none",n.src="https://__bridge_loaded__",document.documentElement.appendChild(n),setTimeout(()=>document.documentElement.removeChild(n),0)}async callHandler(t,n){return await new Promise(o=>{var a;(a=this.instance)==null||a.callHandler(t,n,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 Pt(e){if(E!=null){e();return}E=new Nt(e)}function W(e){const{title:t,children:n,className:o,style:a}=e;return c("header",{className:v("header",o),style:a,children:[s("h1",{className:"md:text-xl",children:t}),s("div",{className:"flex flex-auto items-center justify-end",children:n})]})}function M(e){const{type:t,size:n=14,className:o,style:a}=e,r=v("clash-iconfont",`icon-${t}`,o),i=P({fontSize:n},a),l=k(P({},e),{className:r,style:i});return s("i",P({},l))}function j(){}function Et(e,t){const n=[],o=[];for(const a of e)t(a)?n.push(a):o.push(a);return[n,o]}function H(e){const t=["B","KB","MB","GB","TB"];let n=0;for(;~~(e/1024)&&n<t.length;)e/=1024,n++;return`${n===0?e:e.toFixed(2)} ${t[n]}`}function we(e){const{className:t,checked:n=!1,disabled:o=!1,onChange:a=j}=e,r=v("switch",{checked:n,disabled:o},t);function i(){o||a(!n)}return s("div",{className:r,onClick:i,children:s(M,{className:"switch-icon font-bold",type:"check",size:20})})}const U=d.exports.forwardRef((e,t)=>{const{className:n,style:o,children:a}=e;return s("div",{className:v("card",n),style:o,ref:t,c
|
||
|
`).map(l=>JSON.parse(l));this.EE.emit("data",i),this.config.bufferLength>0&&(this.innerBuffer.push(...i),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,n){this.EE.addListener(t,n)}unsubscribe(t,n){this.EE.removeListener(t,n)}buffer(){return this.innerBuffer.slice()}destory(){this.EE.removeAllListeners(),this.isClose=!0}}class Ft{constructor(t,n){this.axiosClient=it.create({baseURL:t,headers:n?{Authorization:`Bearer ${n}`}:{}})}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(n){return n>=200&&n<300||n===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,n){return await this.axiosClient.put(`proxies/${encodeURIComponent(t)}`,{name:n})}}const $t=G(async()=>{if(!Y())return null;const e=await E.getAPIInfo();return{hostname:e.host,port:e.port,secret:e.secret,protocol:"http:"}}),Oe=ye("externalControllers",[]);function ne(){var f,h,p,y,x,N,F,$,I,A,S,B,J,X,_;const e=Be($t),t=lt(),n=Be(Oe);if(e!=null)return e;let o;{const O=document.querySelector('meta[name="external-controller"]');((f=O==null?void 0:O.content)==null?void 0:f.match(/^https?:/))!=null&&(o=new URL(O.content))}const a=new URLSearchParams(t.search),r=(x=(y=(p=a.get("host"))!=null?p:(h=n==null?void 0:n[0])==null?void 0:h.hostname)!=null?y:o==null?void 0:o.hostname)!=null?x:"127.0.0.1",i=(I=($=(F=a.get("port"))!=null?F:(N=n==null?void 0:n[0])==null?void 0:N.port)!=null?$:o==null?void 0:o.port)!=null?I:"9090",l=(J=(B=(S=a.get("secret"))!=null?S:(A=n==null?void 0:n[0])==null?void 0:A.secret)!=null?B:o==null?void 0:o.username)!=null?J:"",u=((X=a.get("protocol"))!=null?X:r==="127.0.0.1")?"http:":(_=o==null?void 0:o.protocol)!=null?_:window.location.protocol;return{hostname:r,port:i,secret:l,protocol:u}}const Lt=G({key:"",instance:null});function L(){const{hostname:e,port:t,secret:n,protocol:o}=ne(),[a,r]=R(Lt),i=`${o}//${e}:${t}?secret=${n}`;if(a.key===i)return a.instance;const l=new Ft(`${o}//${e}:${t}`,n);return r({key:i,instance:l}),l}const be=G(!0),It=ye("language",void 0);function D(){const[e,t]=R(It),n=d.exports.useMemo(()=>e!=null?e:At(),[e]),o=d.exports.useCallback(function(a){function r(i){return ct(He[n][a],i)}return{t:r}},[n]);return{lang:n,locales:Dt,setLang:t,translation:o}}const ze=G({version:"",premium:!1});function ue(){const[e,t]=R(ze),n=L(),o=xe(be);return V([n],async function(){const a=await le.fromPromise(n.getVersion(),r=>r);o(a.isOk()),t(a.isErr()?{version:"",premium:!1}:{version:a.value.data.version,premium:!!a.value.data.premium})}),e}function We(){const[{premium:e}]=R(ze),t=L(),{data:n,mutate:o}=V(["/providers/rule",t,e],async()=>{if(!e)return[];const a=await t.getRuleProv
|