import{ap as Be,aq as Ae,ar as he,M as Re,as as je,o as Se,at as He,A as ie,N as Te,u as ne,d as e,t as m,i as l,ab as D,au as Fe,av as ze,E as me,aw as We,ax as Ye,F as B,ay as Ke,az as Ve,aA as Qe,aB as Xe,aC as V,aD as Ze,aE as Je,g as y,aF as qe,aG as Ge,aH as et,aI as ae,aJ as Ne,aK as Le,aL as te,aM as re,aN as ce,aO as tt,Q as rt,D as $,aP as nt,aQ as fe,S as P,aR as de,aS as M,aT as Ue,Z as Q,Y as Ee,a9 as Ie,G as oe,K as lt,W as st,aU as it,J as at,b as ct,y as ot,R as dt,T as ut,B as J,a0 as gt,aV as vt,aW as be,aX as xe,aY as ht,aZ as pe,n as mt}from"./index-BfxF6Zjo.js";import{D as ft}from"./DocumentTitle-qgMGpI7d.js";import{f as bt}from"./time-M8P-MK1v.js";import{I as ye}from"./IconReload-bqqdFQ5q.js";function $e(n){const r={...n},s={...n},i={},d=c=>{let h=i[c];if(!h){if(!He())return r[c];i[c]=h=ie(r[c],{internal:!0}),delete r[c]}return h[0]()};for(const c in n)Object.defineProperty(s,c,{get:()=>d(c),enumerable:!0});const a=(c,h)=>{const o=i[c];if(o)return o[1](h);c in r&&(r[c]=he(h,r[c]))};return[s,(c,h)=>{if(Be(c)){const o=Ae(()=>Object.entries(he(c,s)));Re(()=>{for(const[S,x]of o)a(S,()=>x)})}else a(c,h);return s}]}function xt(n,r){if(je.context){const[s,i]=$e(n);return Se(()=>i(r())),[s,i]}return $e(r())}/**
 * @license @tabler/icons-solidjs v3.31.0 - MIT
 *
 * This source code is licensed under the MIT license.
 * See the LICENSE file in the root directory of this source tree.
 */var we=Te("outline","brand-speedtest","IconBrandSpeedtest",[["path",{d:"M5.636 19.364a9 9 0 1 1 12.728 0"}],["path",{d:"M16 9l-4 4"}]]);/**
 * @license @tabler/icons-solidjs v3.31.0 - MIT
 *
 * This source code is licensed under the MIT license.
 * See the LICENSE file in the root directory of this source tree.
 */var pt=Te("outline","chevron-right","IconChevronRight",[["path",{d:"M9 6l6 6l-6 6"}]]),yt=m('<div class="flex flex-col gap-4"><div><div class="flex w-full justify-center"><input class=toggle type=checkbox></div></div><div class="flex flex-col"><input class=input></div><div><input type=number class=input></div><div><select class=select></select></div><div><div class="flex w-full justify-center"><input class=toggle type=checkbox></div></div><div><div class="flex w-full justify-center"><input class=toggle type=checkbox></div></div><div><select class=select></select></div><div><input type=number class=input><input type=number class=input>'),$t=m('<option class="flex items-center gap-2">'),wt=m("<option>");const _t=n=>{const[r]=ne();return e(rt,{ref:s=>{var i;return(i=n.ref)==null?void 0:i.call(n,s)},get icon(){return e(tt,{size:24})},get title(){return r("proxiesSettings")},get children(){var s=yt(),i=s.firstChild,d=i.firstChild,a=d.firstChild,c=i.nextSibling,h=c.firstChild,o=c.nextSibling,S=o.firstChild,x=o.nextSibling,w=x.firstChild,T=x.nextSibling,k=T.firstChild,p=k.firstChild,N=T.nextSibling,O=N.firstChild,_=O.firstChild,E=N.nextSibling,A=E.firstChild,X=E.nextSibling,z=X.firstChild,Z=z.nextSibling;return l(i,e(D,{withDivider:!0,get children(){return r("autoCloseConns")}}),d),a.addEventListener("change",g=>Fe(g.target.checked)),l(c,e(D,{withDivider:!0,get children(){return r("urlForLatencyTest")}}),h),h.addEventListener("change",g=>ze(g.target.value)),l(o,e(D,{withDivider:!0,get children(){return[me(()=>r("latencyTestTimeoutDuration"))," (",me(()=>r("ms")),")"]}}),S),S.addEventListener("change",g=>We(Number(g.target.value))),l(x,e(D,{withDivider:!0,get children(){return r("proxiesSorting")}}),w),w.addEventListener("change",g=>Ye(g.target.value)),l(w,e(B,{get each(){return Object.values(Ke)},children:g=>(()=>{var I=$t();return I.value=g,l(I,()=>r(g)),I})()})),l(T,e(D,{withDivider:!0,get children(){return r("hideUnavailableProxies")}}),k),p.addEventListener("change",g=>Ve(g.target.checked)),l(N,e(D,{withDivider:!0,get children(){return r("renderInTwoColumns")}}),O),_.addEventListener("change",g=>Qe(g.target.checked)),l(E,e(D,{withDivider:!0,get children(){return r("proxiesPreviewType")}}),A),A.addEventListener("change",g=>Xe(g.target.value)),l(A,e(B,{get each(){return Object.values(V)},children:g=>(()=>{var I=wt();return I.value=g,l(I,()=>r(g)),I})()})),l(X,e(D,{withDivider:!0,get children(){return r("iconHeight")}}),z),z.addEventListener("change",g=>Ze(Number(g.target.value))),l(X,e(D,{withDivider:!0,get children(){return r("iconMarginRight")}}),Z),Z.addEventListener("change",g=>Je(Number(g.target.value))),y(()=>a.checked=qe()),y(()=>h.value=Ge()),y(()=>S.value=et()),y(()=>w.value=ae()),y(()=>p.checked=Ne()),y(()=>_.checked=Le()),y(()=>A.value=te()),y(()=>z.value=re()),y(()=>Z.value=ce()),s}})},_e=n=>{const r=()=>te()===V.OFF,s=$(()=>n.proxyNameList.length<=10),i=$(()=>{const a=te();return a===V.BAR||a===V.Auto&&!s()}),d=$(()=>{const a=te();return a===V.DOTS||a===V.Auto&&s()});return e(P,{get when(){return!r()},get children(){return e(nt,{get children(){return[e(fe,{get when(){return i()},get children(){return e(Pt,{get proxyNameList(){return n.proxyNameList},get testUrl(){return n.testUrl},get now(){return n.now}})}}),e(fe,{get when(){return d()},get children(){return e(Lt,{get proxyNameList(){return n.proxyNameList},get testUrl(){return n.testUrl},get now(){return n.now}})}})]}})}})};var Ct=m('<div class="flex items-center gap-2"><div class="my-1 flex flex-1 items-center justify-center overflow-hidden rounded-2xl [&amp;>*]:h-2"><div class=bg-green-600></div><div class=bg-yellow-500></div><div class=bg-red-500></div><div class=bg-neutral>');const Pt=n=>{const{getLatencyByName:r}=de(),s=$(()=>n.proxyNameList.map(o=>r(o,n.testUrl))),i=$(()=>s().length),d=$(()=>s().filter(o=>o>M().NOT_CONNECTED&&o<=M().MEDIUM).length),a=$(()=>s().filter(o=>o>M().MEDIUM&&o<=M().HIGH).length),c=$(()=>s().filter(o=>o>M().HIGH).length),h=$(()=>s().filter(o=>o===M().NOT_CONNECTED).length);return(()=>{var o=Ct(),S=o.firstChild,x=S.firstChild,w=x.nextSibling,T=w.nextSibling,k=T.nextSibling;return l(o,e(P,{get when(){return n.now},get children(){return e(Ue,{get proxyName(){return n.now},get testUrl(){return n.testUrl}})}}),null),y(p=>{var N=`${d()*100/i()}%`,O=`${a()*100/i()}%`,_=`${c()*100/i()}%`,E=`${h()*100/i()}%`;return N!==p.e&&((p.e=N)!=null?x.style.setProperty("width",N):x.style.removeProperty("width")),O!==p.t&&((p.t=O)!=null?w.style.setProperty("width",O):w.style.removeProperty("width")),_!==p.a&&((p.a=_)!=null?T.style.setProperty("width",_):T.style.removeProperty("width")),E!==p.o&&((p.o=E)!=null?k.style.setProperty("width",E):k.style.removeProperty("width")),p},{e:void 0,t:void 0,a:void 0,o:void 0}),o})()};var St=m("<div>"),Tt=m('<div class="flex items-center gap-2"><div class="flex flex-1 flex-wrap items-center gap-1">');const Nt=n=>{let r=n.selected?"bg-white border-4 border-green-600":"bg-green-600";return typeof n.latency!="number"||n.latency===M().NOT_CONNECTED?r=n.selected?"bg-white border-4 border-neutral":"bg-neutral":n.latency>M().HIGH?r=n.selected?"bg-white border-4 border-red-500":"bg-red-500":n.latency>M().MEDIUM&&(r=n.selected?"bg-white border-4 border-yellow-500":"bg-yellow-500"),(()=>{var s=St();return y(i=>{var d=Q("h-4 w-4 rounded-full",r),a=n.name;return d!==i.e&&Ee(s,i.e=d),a!==i.t&&Ie(s,"title",i.t=a),i},{e:void 0,t:void 0}),s})()},Lt=n=>{const{getLatencyByName:r}=de();return(()=>{var s=Tt(),i=s.firstChild;return l(i,e(B,{get each(){return n.proxyNameList.map(d=>[d,r(d,n.testUrl)])},children:([d,a])=>e(Nt,{name:d,latency:a,get selected(){return n.now===d}})})),l(s,e(P,{get when(){return n.now},get children(){return e(Ue,{get proxyName(){return n.now},get testUrl(){return n.testUrl}})}}),null),s})()};var Ut=m('<div class="flex items-center gap-2 pt-1"><progress class=progress max=100></progress><div class="badge badge-sm badge-secondary">%'),Et=m('<div class="flex flex-wrap items-center justify-between"><div class="text-sm text-slate-500"> / </div><div class="text-sm text-slate-500">: ');const It=n=>{const{Download:r=0,Upload:s=0,Total:i=0,Expire:d=0}=n,a=oe(i,{units:"iec"}),c=oe(r+s,{units:"iec"}),h=Math.min(lt.toFinite(((r+s)/i*100).toFixed(1)),999);return{total:a,used:c,percentage:h,expirePrefix:()=>{const[x]=ne();return x("expire")},expireStr:()=>{const[x]=ne();return d===0?x("noExpire"):st(d*1e3).format("YYYY-MM-DD")}}},Dt=n=>{if(!n.subscriptionInfo)return;const r=It(n.subscriptionInfo);return[(()=>{var s=Ut(),i=s.firstChild,d=i.nextSibling,a=d.firstChild;return l(d,()=>r.percentage,a),y(()=>i.value=r.percentage),s})(),(()=>{var s=Et(),i=s.firstChild,d=i.firstChild,a=i.nextSibling,c=a.firstChild;return l(i,()=>`${r.used}`,d),l(i,()=>`${r.total}`,null),l(a,()=>r.expirePrefix(),c),l(a,()=>r.expireStr(),null),s})()]},Mt={width:0,height:0};function Ce(){return{width:window.innerWidth,height:window.innerHeight}}function kt(){const[n,r]=xt(Mt,Ce);return it(window,"resize",()=>r(Ce())),n}var Ot=m("<div class=mb-2>"),Bt=m('<div class="flex gap-2"><div class=flex-1></div><div class=flex-1>'),At=m('<div class="grid grid-cols-1 place-items-start gap-2">');const Pe=n=>{const r=kt(),s=$(()=>r.width>480);return()=>{const i=at(()=>n.children),d=a=>{var c;return(c=i())==null?void 0:c.filter((h,o)=>o%2===a).map(h=>(()=>{var o=Ot();return l(o,h),o})())};return Le()&&s()?(()=>{var a=Bt(),c=a.firstChild,h=c.nextSibling;return l(c,()=>d(0)),l(h,()=>d(1)),a})():(()=>{var a=At();return l(a,i),a})()}};var Rt=m('<div class="flex h-full flex-col gap-2"><div class="flex items-center gap-2"><div class="tabs tabs-sm gap-2 tabs-box"></div><div class=ml-auto></div></div><div class="flex-1 overflow-y-auto">'),jt=m('<button><span></span><div class="badge badge-sm">'),Ht=m("<div>"),Ft=m("<span class=whitespace-nowrap>"),zt=m('<div class=space-y-2><div class="flex items-center justify-between pr-8"><div class="flex items-center"><span></span><div class="ml-2 badge badge-sm"></div></div></div><div class="flex flex-wrap items-center justify-between gap-2"><div class="badge badge-sm badge-primary"><span class=font-bold></span></div><div class="badge badge-sm badge-secondary">/s'),Wt=m("<img>"),Yt=m('<div class="flex items-center justify-between pr-8"><div class="flex flex-wrap items-center gap-1"><span class="line-clamp-1 break-all"></span><div class="badge badge-sm"></div><div class="badge badge-sm"></div></div><div class="flex items-center gap-2">'),Kt=m('<div class="flex flex-col gap-2"><div class="text-sm text-slate-500"> ');const Jt=()=>{const n=ct();if(!ot())return n("/setup",{replace:!0}),null;let r;const[s]=ne(),{fetchProxies:i,proxies:d,selectProxyInGroup:a,proxyProviders:c,updateProviderByProviderName:h,updateAllProvider:o,proxyGroupLatencyTest:S,proxyProviderLatencyTest:x,proxyGroupLatencyTestingMap:w,proxyProviderLatencyTestingMap:T,isAllProviderUpdating:k,updatingMap:p}=de(),N=$(()=>d().filter(f=>!f.hidden)),{speedGroupByName:O}=dt(),[_,E]=ut(ie({}),{name:"collapsedMap",storage:localStorage}),A=(f,C)=>{E(G=>({...G,[f]:C}))};Se(i);const X=async(f,C)=>{f.stopPropagation(),S(C)},z=f=>f.replace("<svg",~f.indexOf("xmlns")?"<svg":'<svg xmlns="http://www.w3.org/2000/svg"').replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/\{/g,"%7B").replace(/\}/g,"%7D").replace(/</g,"%3C").replace(/>/g,"%3E"),Z=(f,C)=>{f.stopPropagation(),x(C)},g=(f,C)=>{f.stopPropagation(),h(C)},I=async f=>{f.stopPropagation(),o()},[q,De]=ie("proxies"),Me=()=>[{type:"proxies",name:s("proxies"),count:N().length},{type:"proxyProviders",name:s("proxyProviders"),count:c().length}];return[e(ft,{get children(){return s("proxies")}}),(()=>{var f=Rt(),C=f.firstChild,G=C.firstChild,ue=G.nextSibling,ge=C.nextSibling;return l(G,e(B,{get each(){return Me()},children:t=>(()=>{var L=jt(),W=L.firstChild,v=W.nextSibling;return L.$$click=()=>De(t.type),l(W,()=>t.name),l(v,()=>t.count),y(()=>Ee(L,Q(q()===t.type&&"bg-primary !text-neutral","sm:tab-md tab gap-2 px-2"))),L})()})),l(C,e(P,{get when(){return q()==="proxyProviders"},get children(){return e(J,{class:"btn btn-circle btn-sm",get disabled(){return k()},onClick:t=>I(t),get icon(){return e(ye,{get class(){return Q(k()&&"animate-spin text-success")}})}})}}),ue),l(ue,e(J,{class:"btn-circle btn-sm btn-primary",onClick:()=>r==null?void 0:r.showModal(),get icon(){return e(gt,{})}})),l(ge,e(P,{get when(){return q()==="proxies"},get children(){return e(Pe,{get children(){return e(B,{get each(){return N()},children:t=>{const L=$(()=>ht({proxyNames:pe({proxyNames:t.all??[],orderingType:ae(),testUrl:t.testUrl||null}),enabled:Ne(),testUrl:t.testUrl||null})),W=(()=>{var v=zt(),U=v.firstChild,R=U.firstChild,Y=R.firstChild,le=Y.nextSibling,ee=U.nextSibling,j=ee.firstChild,ke=j.firstChild,ve=j.nextSibling,Oe=ve.firstChild;return l(R,e(P,{get when(){return t.icon},get children(){return e(P,{get when(){return t.icon.startsWith("data:image/svg+xml")},get fallback(){return(()=>{var u=Wt();return y(b=>{var K=t.icon,H=`${re()}px`,F=`${ce()}px`;return K!==b.e&&Ie(u,"src",b.e=K),H!==b.t&&((b.t=H)!=null?u.style.setProperty("height",H):u.style.removeProperty("height")),F!==b.a&&((b.a=F)!=null?u.style.setProperty("margin-right",F):u.style.removeProperty("margin-right")),b},{e:void 0,t:void 0,a:void 0}),u})()},get children(){var u=Ht();return u.style.setProperty("color","oklch(var(--p) / var(--tw-bg-opacity))"),u.style.setProperty("background-color","currentColor"),u.style.setProperty("mask-size","100% 100%"),y(b=>{var K=`${re()}px`,H=`${re()}px`,F=`${ce()}px`,se=`url("${z(t.icon)}")`;return K!==b.e&&((b.e=K)!=null?u.style.setProperty("height",K):u.style.removeProperty("height")),H!==b.t&&((b.t=H)!=null?u.style.setProperty("width",H):u.style.removeProperty("width")),F!==b.a&&((b.a=F)!=null?u.style.setProperty("margin-right",F):u.style.removeProperty("margin-right")),se!==b.o&&((b.o=se)!=null?u.style.setProperty("mask-image",se):u.style.removeProperty("mask-image")),b},{e:void 0,t:void 0,a:void 0,o:void 0}),u}})}}),Y),l(Y,()=>t.name),l(le,()=>{var u;return(u=t.all)==null?void 0:u.length}),l(U,e(J,{class:"btn-circle btn-sm",get disabled(){return w()[t.name]},onClick:u=>X(u,t.name),get icon(){return e(we,{get class(){return Q(w()[t.name]&&"animate-pulse text-success")}})}}),null),l(ke,()=>vt(t.type)),l(j,e(P,{get when(){var u;return((u=t.now)==null?void 0:u.length)>0},get children(){return[e(pt,{size:18}),(()=>{var u=Ft();return l(u,()=>t.now),u})()]}}),null),l(ve,()=>oe(O()[t.name]??0).toString(),Oe),l(v,e(P,{get when(){return!_()[t.name]},get children(){return e(_e,{get proxyNameList(){return L()},get now(){return t.now},get testUrl(){return t.testUrl||null}})}}),null),v})();return e(be,{get isOpen(){return _()[t.name]},title:W,onCollapse:v=>A(t.name,v),get children(){return e(B,{get each(){return L()},children:v=>e(xe,{proxyName:v,get testUrl(){return t.testUrl||null},get timeout(){return t.timeout??null},get isSelected(){return t.now===v},onClick:()=>void a(t,v)})})}})}})}})}}),null),l(ge,e(P,{get when(){return q()==="proxyProviders"},get children(){return e(Pe,{get children(){return e(B,{get each(){return c()},children:t=>{const L=$(()=>pe({orderingType:ae(),proxyNames:t.proxies.map(v=>v.name)??[],testUrl:t.testUrl})),W=[(()=>{var v=Yt(),U=v.firstChild,R=U.firstChild,Y=R.nextSibling,le=Y.nextSibling,ee=U.nextSibling;return l(R,()=>t.name),l(Y,()=>t.proxies.length),l(le,()=>t.vehicleType),l(ee,e(J,{class:"btn btn-circle btn-sm",get disabled(){return p()[t.name]},onClick:j=>g(j,t.name),get icon(){return e(ye,{get class(){return Q(p()[t.name]&&"animate-spin text-success")}})}}),null),l(ee,e(J,{class:"btn btn-circle btn-sm",get disabled(){return T()[t.name]},onClick:j=>Z(j,t.name),get icon(){return e(we,{get class(){return Q(T()[t.name]&&"animate-pulse text-success")}})}}),null),v})(),e(Dt,{get subscriptionInfo(){return t.subscriptionInfo}}),(()=>{var v=Kt(),U=v.firstChild,R=U.firstChild;return l(U,()=>s("updated"),R),l(U,()=>bt(t.updatedAt),null),l(v,e(P,{get when(){return!_()[t.name]},get children(){return e(_e,{get proxyNameList(){return L()},get testUrl(){return t.testUrl}})}}),null),v})()];return e(be,{get isOpen(){return _()[t.name]},title:W,onCollapse:v=>A(t.name,v),get children(){return e(B,{get each(){return L()},children:v=>e(xe,{proxyName:v,get testUrl(){return t.testUrl},get timeout(){return t.timeout??null}})})}})}})}})}}),null),l(f,e(_t,{ref:t=>r=t}),null),f})()]};mt(["click"]);export{Jt as default};
