3 lines
41 KiB
JavaScript
3 lines
41 KiB
JavaScript
|
var Pt=Object.defineProperty,kt=Object.defineProperties;var Nt=Object.getOwnPropertyDescriptors;var B=Object.getOwnPropertySymbols;var de=Object.prototype.hasOwnProperty,pe=Object.prototype.propertyIsEnumerable;var V=(e,t,n)=>t in e?Pt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d=(e,t)=>{for(var n in t||(t={}))de.call(t,n)&&V(e,n,t[n]);if(B)for(var n of B(t))pe.call(t,n)&&V(e,n,t[n]);return e},x=(e,t)=>kt(e,Nt(t));var D=(e,t)=>{var n={};for(var o in e)de.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&B)for(var o of B(e))t.indexOf(o)<0&&pe.call(e,o)&&(n[o]=e[o]);return n};var fe=(e,t,n)=>(V(e,typeof t!="symbol"?t+"":t,n),n);import{i as $t,B as At,a as Tt,b as Lt,R as l,s as It,f as Rt,u as Ot,r as s,G as Ut,Q as Bt,c as Dt,d as jt,e as Mt,g as C,I as Ft,E as zt,h as Wt,j as $,k as R,T as me,M as he,l as qt,L as ge,F as Ht,m as Vt,n as Gt,o as Jt,p as Kt,q as Qt,t as Yt,v as Xt,S as G,w as Zt,x as en,H as tn,y as xe,z as nn}from"./vendor.38e754a4.js";const on=function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))o(r);new MutationObserver(r=>{for(const a of r)if(a.type==="childList")for(const c of a.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&o(c)}).observe(document,{childList:!0,subtree:!0});function n(r){const a={};return r.integrity&&(a.integrity=r.integrity),r.referrerpolicy&&(a.referrerPolicy=r.referrerpolicy),r.crossorigin==="use-credentials"?a.credentials="include":r.crossorigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function o(r){if(r.ep)return;r.ep=!0;const a=n(r);fetch(r.href,a)}};on();const rn="modulepreload",ye={},sn="./",v=function(t,n){return!n||n.length===0?t():Promise.all(n.map(o=>{if(o=`${sn}${o}`,o in ye)return;ye[o]=!0;const r=o.endsWith(".css"),a=r?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${a}`))return;const c=document.createElement("link");if(c.rel=r?"stylesheet":rn,r||(c.as="script",c.crossOrigin=""),c.href=o,document.head.appendChild(c),r)return new Promise((i,u)=>{c.addEventListener("load",i),c.addEventListener("error",u)})})).then(()=>t())},ve={zh:v(()=>import("./zh.247ad8fa.js"),[]),en:v(()=>import("./en.f1dd5536.js"),[])};$t.use(At).use(Tt).use(Lt).init({debug:!1,backend:{loadPath:"/__{{lng}}/{{ns}}.json",request:function(e,t,n,o){let r;switch(t){case"/__zh/translation.json":case"/__zh-CN/translation.json":r=ve.zh;break;case"/__en/translation.json":default:r=ve.en;break}r&&r.then(a=>{o(null,{status:200,data:a.data})})}},supportedLngs:["en","zh"],fallbackLng:"en",interpolation:{escapeValue:!1}});function an(e,t){let n;return(...o)=>{n&&clearTimeout(n),n=setTimeout(()=>{e(...o)},t)}}function _e(e){return e.replace(/\/$/,"")}function oa(e,t){let n=String(e);for(;n.length<t;)n="0"+n;return n}const cn={"Content-Type":"application/json"};function ln({secret:e}){const t=d({},cn);return e&&(t.Authorization=`Bearer ${e}`),t}function Ee(e,t,n){const o="?"+t.toString(),r=new URL(e);return r.protocol==="https:"?r.protocol="wss:":r.protocol="ws:",`${_e(r.href)}${n}${o}`}function h({baseURL:e,secret:t}){const n=ln({secret:t});return{url:e,init:{headers:n}}}function we(e,t){const{baseURL:n,secret:o}=e,r=new URLSearchParams({token:o});return Ee(n,r,t)}function ra(e,t){const{baseURL:n,secret:o,logLevel:r}=e,a=new URLSearchParams({token:o,level:r});return Ee(n,a,t)}async function un(e,t){let n={};try{const{url:o,init:r}=h(t),a=await fetch(o+e,r);a.ok&&(n=await a.json())}catch(o){console.log(`failed to fetch ${e}`,o)}return n}const dn="_root_1o14m_1",pn="_h1_1o14m_7";var be={root:dn,h1:pn};function fn({title:e}){return l.createElement("div",{className:be.root},l.createElement("h1",{className:be.h1},e))}var Ce=l.memo(fn);It(!1);const{createContext:J,memo:mn,useMemo:hn,useRef:gn,useEffect:xn,useCallback:Se,useContext:K,useState:yn}=l,Pe=J(null),ke=J(null),Ne=J(null);function vn(){return K(Ne)}function _n({initialState:e,actions:t={},children:n}){const o=gn(e),[r,a]=yn(e),c=Se(()=>o.current,[]);xn(()=>{},
|
||
|
`),a=r[r.length-1];for(let c=0;c<r.length-1;c++)Q(r[c]);if(t){Q(a),M="",console.log("GET /traffic streaming done"),A=!1;return}else M=a;return Re(e)})}let F;function Y(e){if(A||F===1)return O;F=1;const t=we(e,Ie),n=new WebSocket(t);return n.addEventListener("error",function(o){F=3}),n.addEventListener("close",function(o){F=3,Pn(e)}),n.addEventListener("message",function(o){Q(o.data)}),O}function Pn(e){if(A)return O;A=!0;const{url:t,init:n}=h(e);return fetch(t+Ie,n).then(o=>{if(o.ok){const r=o.body.getReader();Re(r)}else A=!1},o=>{console.log("fetch /traffic error",o),A=!1}),O}function Oe(e){return t=>{t(`openModal:${e}`,n=>{n.modals[e]=!0})}}function kn(e){return t=>{t(`closeModal:${e}`,n=>{n.modals[e]=!1})}}const Nn={apiConfig:!1},sa=e=>e.configs.configs,$n=e=>e.configs.haveFetchedConfig,aa=e=>e.configs.configs["log-level"];function Ue(e){return async(t,n)=>{let o;try{o=await Le(e)}catch{t(Oe("apiConfig"));return}if(!o.ok){console.log("Error fetch configs",o.statusText),t(Oe("apiConfig"));return}const r=await o.json();t("store/configs#fetchConfigs",c=>{c.configs.configs=r}),$n(n())?Y(e):t(An())}}function An(){return e=>{e("store/configs#markHaveFetchedConfig",t=>{t.configs.haveFetchedConfig=!0})}}function ca(e,t){return async n=>{Cn(e,t).then(o=>{o.ok===!1&&console.log("Error update configs",o.statusText)},o=>{throw console.log("Error update configs",o),o}).then(()=>{n(Ue(e))}),n("storeConfigsOptimisticUpdateConfigs",o=>{o.configs.configs=d(d({},o.configs.configs),t)})}}const Tn={configs:{port:7890,"socks-port":7891,"redir-port":0,"allow-lan":!1,mode:"Rule","log-level":"uninit"},haveFetchedConfig:!1},T=e=>{const t=e.app.selectedClashAPIConfigIndex;return e.app.clashAPIConfigs[t]},Be=e=>e.app.selectedClashAPIConfigIndex,X=e=>e.app.clashAPIConfigs,Z=e=>e.app.theme,Ln=e=>e.app.selectedChartStyleIndex,In=e=>e.app.latencyTestUrl,la=e=>e.app.collapsibleIsOpen,ia=e=>e.app.proxySortBy,ua=e=>e.app.hideUnavailableProxies,Rn=e=>e.app.autoCloseOldConns,da=e=>e.app.logStreamingPaused,On=an(k,600);function ee(e,{baseURL:t,secret:n}){const o=X(e());for(let r=0;r<o.length;r++){const a=o[r];if(a.baseURL===t&&a.secret===n)return r}}function Un({baseURL:e,secret:t}){return async(n,o)=>{if(ee(o,{baseURL:e,secret:t}))return;const a={baseURL:e,secret:t,addedAt:Date.now()};n("addClashAPIConfig",c=>{c.app.clashAPIConfigs.push(a)}),k(o().app)}}function Bn({baseURL:e,secret:t}){return async(n,o)=>{const r=ee(o,{baseURL:e,secret:t});n("removeClashAPIConfig",a=>{a.app.clashAPIConfigs.splice(r,1)}),k(o().app)}}function Dn({baseURL:e,secret:t}){return async(n,o)=>{const r=ee(o,{baseURL:e,secret:t});Be(o())!==r&&n("selectClashAPIConfig",c=>{c.app.selectedClashAPIConfigIndex=r}),k(o().app);try{window.location.reload()}catch{}}}const De=document.querySelector("html"),je=document.querySelector('meta[name="theme-color"]');function Me(e="dark"){e==="dark"?(De.setAttribute("data-theme","dark"),je.setAttribute("content","#202020")):(De.setAttribute("data-theme","light"),je.setAttribute("content","#f7f7f7"))}function jn(){return(e,t)=>{const o=Z(t())==="light"?"dark":"light";Me(o),e("storeSwitchTheme",r=>{r.app.theme=o}),k(t().app)}}function Mn(e){return(t,n)=>{t("appSelectChartStyleIndex",o=>{o.app.selectedChartStyleIndex=Number(e)}),k(n().app)}}function Fe(e,t){return(n,o)=>{n("appUpdateAppConfig",r=>{r.app[e]=t}),k(o().app)}}function Fn(e,t,n){return(o,r)=>{o("updateCollapsibleIsOpen",a=>{a.app.collapsibleIsOpen[`${e}:${t}`]=n}),On(r().app)}}var Ct,St;const zn={baseURL:(St=(Ct=document.getElementById("app"))==null?void 0:Ct.getAttribute("data-base-url"))!=null?St:"http://127.0.0.1:9090",secret:"",addedAt:0},Wn={selectedClashAPIConfigIndex:0,clashAPIConfigs:[zn],latencyTestUrl:"http://www.gstatic.com/generate_204",selectedChartStyleIndex:0,theme:"dark",collapsibleIsOpen:{},proxySortBy:"Natural",hideUnavailableProxies:!1,autoCloseOldConns:!1,logStreamingPaused:!1};function qn(){const{search:e}=window.location,t={};if(typeof e!="string"||e==="")return t;const n=e.replace(/^\?/,"").split("&");for(let o=0;o<n.length;o++){const[r,a]=n[o].split("=");t[r]=encode
|