3 lines
53 KiB
JavaScript
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:"swit
|
||
|
`).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.getRulePro
|