import{r as f,J as R,o,g as n,a as i,u,d as S,e as w,F as A,D as N,c as $,w as D,f as d,t as c,h as v,i as g,b as F,L as J}from"./app-SC54XQDl.js";import{u as q}from"./app-Ba7ZqSpq.js";import{T as C}from"./app-DoVkxbmA.js";const G=["name","value"],H={key:0,class:"flex flex-wrap gap-2 items-center"},z={key:0},M={key:1},j={key:2},K={key:3,class:"italic"},Q={key:0,class:"label-group"},W={key:0},X={key:1},Y={key:2},Z={key:3,class:"italic"},ee=["onClick"],te=i("i",{class:"pi pi-pencil small"},null,-1),oe=[te],se=["onClick"],ne=i("i",{class:"pi pi-remove"},null,-1),re=[ne],pe={__name:"NetworkAddressesBox",props:["v-server-type","v-addresses","v-protocol","v-name","v-from","v-support-range","v-url","minPort","maxPort"],emits:["change","update:modelValue"],setup(V,{expose:b,emit:B}){const t=V,P=q(),y=B,{addresses:s,protocol:k,name:L,from:x,isEditing:_}=function(){let r=t.vAddresses;r==null&&(r=[]);let l=t.vProtocol;l==null&&(l="");let e=t.vName;e==null&&(e="addresses");let a=t.vFrom;return a==null&&(a=""),{addresses:f(r),protocol:f(l),name:f(e),from:f(a),isEditing:f(!1)}}();setTimeout(()=>h());let m="";R(()=>t.vServerType,()=>{s.value=[]}),R(()=>t.vAddresses,()=>{t.vAddresses!=null&&(s.value=t.vAddresses)});const U=function(){_.value=!0,window.UPDATING_ADDR=null;let r=t.vUrl;r==null&&(r="/servers/addPortPopup"),P.popup(r+"?serverType="+t.vServerType+"&protocol="+k.value+"&from="+x.value+"&supportRange="+(T()?1:0)+"&minPort="+(t.minPort?t.minPort:0)+"&maxPort="+(t.maxPort?t.maxPort:0),{callback:function(l){var e=l.data.address;if(s.value.$find(function(a,p){return e.host==p.host&&e.portRange==p.portRange&&e.protocol==p.protocol})!=null){P.warn("要添加的网络地址已经存在");return}s.value.push(e),["https","https4","https6"].$contains(e.protocol)?m="HTTPS":["tls","tls4","tls6"].$contains(e.protocol)&&(m="TLS"),h()}})},I=function(r){s.value.$remove(r),h()},O=function(r,l){window.UPDATING_ADDR=l;let e=t.vUrl;e==null&&(e="/servers/addPortPopup"),P.popup(e+"?serverType="+t.vServerType+"&protocol="+k.value+"&from="+x.value+"&supportRange="+(T()?1:0)+"&minPort="+(t.minPort?t.minPort:0)+"&maxPort="+(t.maxPort?t.maxPort:0),{callback:function(a){var p=a.data.address;s.value[r]=p,["https","https4","https6"].$contains(p.protocol)?m="HTTPS":["tls","tls4","tls6"].$contains(p.protocol)&&(m="TLS"),h()}}),h()},T=function(){return t.vSupportRange||t.vServerType=="tcpProxy"||t.vServerType=="udpProxy"},E=function(){_.value=!0},h=()=>{y("change",s.value),y("update:modelValue",JSON.stringify(s.value))};return b({tlsProtocolName:m}),(r,l)=>(o(),n("div",null,[i("input",{type:"hidden",name:u(L),value:JSON.stringify(u(s))},null,8,G),S(i("div",null,[u(s).length>0?(o(),n("div",H,[(o(!0),n(A,null,N(u(s),(e,a)=>(o(),$(C,{outlined:""},{default:D(()=>[d(c(e.protocol)+"://",1),e.host.length>0?(o(),n("span",z,c(e.host.quoteIP()),1)):v("",!0),e.host.length==0?(o(),n("span",M,"*")):v("",!0),d(":"),e.portRange.indexOf("-")<0?(o(),n("span",j,c(e.portRange),1)):(o(),n("span",K,c(e.portRange),1))]),_:2},1024))),256)),d("     "),i("a",{href:"",onClick:g(E,["prevent"]),style:{"font-size":"0.9em"}},"[修改]")])):v("",!0)],512),[[w,!u(_)]]),S(i("div",null,[u(s).length>0?(o(),n("div",Q,[(o(!0),n(A,null,N(u(s),(e,a)=>(o(),$(C,{outlined:""},{default:D(()=>[d(c(e.protocol)+"://",1),e.host.length>0?(o(),n("span",W,c(e.host.quoteIP()),1)):v("",!0),e.host.length==0?(o(),n("span",X,"*")):v("",!0),d(":"),e.portRange.indexOf("-")<0?(o(),n("span",Y,c(e.portRange),1)):(o(),n("span",Z,c(e.portRange),1)),d("  "),i("a",{href:"",onClick:g(p=>O(a,e),["prevent"]),title:"修改"},oe,8,ee),d("  "),i("a",{href:"",onClick:g(p=>I(a),["prevent"]),title:"删除"},re,8,se)]),_:2},1024))),256)),F(J)])):v("",!0),i("div",null,[i("a",{href:"",onClick:l[0]||(l[0]=g(e=>U(),["prevent"]))},"[添加端口绑定]")])],512),[[w,u(_)||u(s).length==0]])]))}};export{pe as _};
