import{_ as S,ag as V,L as _,o as n,h as y,B as d,t as c,d as a,w as i,aQ as x,b as h,C,f as m,q as g,aP as P,F as b,i as v,l as p,k,a7 as R,aB as G}from"./index-b7f60880.js";const H={setup(){const{tm:t}=V("features/settings");return{tm:t}},data(){return{githubProxies:["https://edgeone.gh-proxy.com","https://hk.gh-proxy.com/","https://gh-proxy.com/","https://gh.llkk.cc"],githubProxyRadioControl:"0",selectedGitHubProxy:"",radioValue:"0",loadingTestingConnection:!1,testingProxies:{},proxyStatus:{},initializing:!0}},methods:{getProxyByControl(t){const e=String(t);if(e==="-1")return"";const l=Number.parseInt(e,10);return Number.isNaN(l)?"":this.githubProxies[l]||""},async testSingleProxy(t){this.testingProxies[t]=!0;const e=this.githubProxies[t];try{const l=await _.post("/api/stat/test-ghproxy-connection",{proxy_url:e});console.log(l.data),l.status===200?this.proxyStatus[t]={available:!0,latency:Math.round(l.data.data.latency)}:this.proxyStatus[t]={available:!1,latency:0}}catch{this.proxyStatus[t]={available:!1,latency:0}}finally{this.testingProxies[t]=!1}},async testAllProxies(){this.loadingTestingConnection=!0;const t=this.githubProxies.map((e,l)=>this.testSingleProxy(l));await Promise.all(t),this.loadingTestingConnection=!1}},mounted(){this.initializing=!0;const t=localStorage.getItem("selectedGitHubProxy")||"",e=localStorage.getItem("githubProxyRadioValue")||"0",l=String(localStorage.getItem("githubProxyRadioControl")||"0");this.radioValue=e,this.githubProxyRadioControl=l,e==="1"?l!=="-1"?this.selectedGitHubProxy=this.getProxyByControl(l):this.selectedGitHubProxy=t:this.selectedGitHubProxy="",this.initializing=!1},watch:{selectedGitHubProxy:function(t,e){this.initializing||(t||(t=""),localStorage.setItem("selectedGitHubProxy",t))},radioValue:function(t){this.initializing||(localStorage.setItem("githubProxyRadioValue",t),String(t)==="0"?this.selectedGitHubProxy="":String(this.githubProxyRadioControl)!=="-1"&&(this.selectedGitHubProxy=this.getProxyByControl(this.githubProxyRadioControl)))},githubProxyRadioControl:function(t){if(this.initializing)return;const e=String(t);if(localStorage.setItem("githubProxyRadioControl",e),String(this.radioValue)!=="1"){this.selectedGitHubProxy="";return}e!=="-1"&&(this.selectedGitHubProxy=this.getProxyByControl(e))}}},w={key:0,style:{"margin-left":"16px"}},z={class:"d-flex align-center"},B={class:"mr-2"},I={key:0};function N(t,e,l,r,o,f){return n(),y(b,null,[d("h5",null,c(r.tm("network.proxySelector.title")),1),a(P,{class:"mt-2",modelValue:o.radioValue,"onUpdate:modelValue":e[0]||(e[0]=s=>o.radioValue=s),"hide-details":"true"},{default:i(()=>[a(x,{label:r.tm("network.proxySelector.noProxy"),value:"0"},null,8,["label"]),a(x,{value:"1"},{label:i(()=>[d("span",null,c(r.tm("network.proxySelector.useProxy")),1),o.radioValue==="1"?(n(),h(C,{key:0,class:"ml-2",onClick:f.testAllProxies,size:"x-small",variant:"tonal",loading:o.loadingTestingConnection},{default:i(()=>[m(c(r.tm("network.proxySelector.testConnection")),1)]),_:1},8,["onClick","loading"])):g("",!0)]),_:1})]),_:1},8,["modelValue"]),a(G,null,{default:i(()=>[o.radioValue==="1"?(n(),y("div",w,[a(P,{modelValue:o.githubProxyRadioControl,"onUpdate:modelValue":e[2]||(e[2]=s=>o.githubProxyRadioControl=s),class:"mt-2","hide-details":"true"},{default:i(()=>[(n(!0),y(b,null,v(o.githubProxies,(s,u)=>(n(),h(x,{color:"success",key:s,value:String(u)},{label:i(()=>[d("div",z,[d("span",B,c(s),1),o.proxyStatus[u]?(n(),y("div",I,[a(p,{color:o.proxyStatus[u].available?"success":"error",size:"x-small",class:"mr-1"},{default:i(()=>[m(c(o.proxyStatus[u].available?r.tm("network.proxySelector.available"):r.tm("network.proxySelector.unavailable")),1)]),_:2},1032,["color"]),o.proxyStatus[u].available?(n(),h(p,{key:0,color:"info",size:"x-small"},{default:i(()=>[m(c(o.proxyStatus[u].latency)+"ms ",1)]),_:2},1024)):g("",!0)])):g("",!0)])]),_:2},1032,["value"]))),128)),a(x,{color:"primary",value:"-1",label:r.tm("network.proxySelector.custom")},k({_:2},[String(o.githubProxyRadioControl)==="-1"?{name:"label",fn:i(()=>[a(R,{density:"compact",modelValue:o.selectedGitHubProxy,"onUpdate:modelValue":e[1]||(e[1]=s=>o.selectedGitHubProxy=s),variant:"outlined",style:{width:"100vw"},placeholder:r.tm("network.proxySelector.custom"),"hide-details":"true"},null,8,["modelValue","placeholder"])]),key:"0"}:void 0]),1032,["label"])]),_:1},8,["modelValue"])])):g("",!0)]),_:1})],64)}const F=S(H,[["render",N]]);export{F as P};
