import{r as d,J as T,o as i,g as u,a,u as n,F as j,D as q,c as G,w as m,h as r,f as e,t as H,i as x,n as Q,b as c,bb as B,d as W,e as L,a_ as R,L as X}from"./app-SC54XQDl.js";import{u as Y}from"./app-Ba7ZqSpq.js";import{_ as Z}from"./app-CVQkwzlf.js";import{C as D}from"./app-Ciy_QwIW.js";import{T as ee}from"./app-CNHjdV6U.js";import{_ as le}from"./app-T1ysvErZ.js";import{a as K,_ as te}from"./app-PrSv7rSt.js";import{T as se}from"./app-DoVkxbmA.js";import{P as ne}from"./app-BxWqoSpr.js";const ae=["name","value"],oe={key:0,class:"label-group"},ie={key:0,class:"grey",style:{"font-style":"normal"}},ue={key:1,class:"grey",style:{"font-style":"normal"}},ce={key:2,class:"grey",style:{"font-style":"normal"}},re={key:3},fe=["onClick"],de=a("i",{class:"icon pencil small"},null,-1),me=[de],pe=["onClick"],ve=a("i",{class:"icon remove small"},null,-1),_e=[ve],he={key:4},ge=a("a",{class:"disabled"},[a("i",{class:"icon pencil small"})],-1),ye=a("a",{class:"disabled"},[a("i",{class:"icon remove small"})],-1),we={key:1},ke={class:"ui fields inline mt-2"},be={key:0,class:"ui field"},xe={class:"ui field"},De={class:"ui field mt-2"},Ve=a("i",{class:"icon remove small"},null,-1),Ce=[Ve],$e={key:0,class:"comment"},Ee={key:0},Ne={key:1,class:"comment"},Be={key:2,style:{"margin-top":"0.5em"}},Pe={__name:"DomainsBox",props:["v-domains","name","v-support-wildcard"],emits:["change"],setup(z,{emit:U}){const y=Y(),h=z,v=d(),w=d(),J=U,{domains:p,mode:_,batchDomains:V,isAdding:g,addingDomain:o,isEditing:k,editingIndex:C,realName:P,supportWildcard:b}=function(){let s=h.vDomains;s==null&&(s=[]);let t="domainsJSON";h.name!=null&&typeof h.name=="string"&&(t=h.name);let l=!0;return typeof h.vSupportWildcard=="boolean"&&(l=h.vSupportWildcard),{domains:d(s),mode:d("single"),batchDomains:d(""),isAdding:d(!1),addingDomain:d(""),isEditing:d(!1),editingIndex:d(-1),realName:d(t),supportWildcard:d(l)}}(),A=function(){g.value=!0,setTimeout(function(){v.value.focus()},100)},S=function(){if(_.value=="batch"){F();return}if(o.value=o.value.replace(/\s/g,""),o.value.length==0){y.warn("请输入要添加的域名",function(){v.value.focus()});return}if(b.value){if(o.value[0]=="~"){let s=o.value.substring(1);try{new RegExp(s)}catch(t){y.warn("正则表达式错误："+t.message,function(){v.value.focus()});return}}}else if(/[*~^]/.test(o.value)){y.warn("当前只支持添加普通域名，域名中不能含有特殊符号",function(){v.value.focus()});return}k.value&&C.value>=0?p.value[C.value]=o.value:o.value.match("[，、,;]")?o.value.split(new RegExp("[，、,;]")).forEach(function(t){t.length>0&&p.value.push(t)}):p.value.push(o.value),$(),E()},F=function(){let s=V.value.split(`
`),t=[],l=!1;if(s.forEach(function(f){if(!l&&f.length!=0){if(b.value){if(f=="~"){let N=f.substring(1);try{new RegExp(N)}catch(M){l=!0,y.warn("正则表达式错误："+M.message,function(){w.value.focus()});return}}}else if(/[*~^]/.test(f)){l=!0,y.warn("当前只支持添加普通域名，域名中不能含有特殊符号",function(){w.value.focus()});return}t.push(f)}}),!l){if(t.length==0){y.warn("请输入要添加的域名",function(){w.value.focus()});return}t.forEach(function(f){p.value.push(f)}),$(),E()}},I=function(s){o.value=p.value[s],k.value=!0,C.value=s,setTimeout(function(){v.value.focus()},50)},O=function(s){p.value.$remove(s),E()},$=function(){g.value=!1,_.value="single",V.value="",k.value=!1,C.value=-1,o.value=""},E=function(){J("change",p.value)};return T(()=>h.vSupportWildcard,function(s){typeof s=="boolean"&&(b.value=s)}),T(_,function(s){setTimeout(function(){s=="single"?v.value!=null&&v.value.focus():s=="batch"&&w.value!=null&&w.value.focus()},100)}),(s,t)=>(i(),u("div",null,[a("input",{type:"hidden",name:n(P),value:JSON.stringify(n(p))},null,8,ae),n(p).length>0?(i(),u("div",oe,[(i(!0),u(j,null,q(n(p),(l,f)=>(i(),G(se,{outlined:"",class:Q({blue:f==n(C)})},{default:m(()=>[l.length>0&&l[0]=="~"?(i(),u("span",ie,"[正则]")):r("",!0),l.length>0&&l[0]=="."?(i(),u("span",ue,"[后缀]")):r("",!0),l.length>0&&l[0]=="*"?(i(),u("span",ce,"[泛域名]")):r("",!0),e(" "+H(l)+" ",1),!n(g)&&!n(k)?(i(),u("span",re,[e("   "),a("a",{href:"",title:"修改",onClick:x(N=>I(f),["prevent"])},me,8,fe),e("   "),a("a",{href:"",title:"删除",onClick:x(N=>O(f),["prevent"])},_e,8,pe)])):r("",!0),n(g)||n(k)?(i(),u("span",he,[e("   "),ge,e("   "),ye])):r("",!0)]),_:2},1032,["class"]))),256))])):r("",!0),n(g)||n(k)?(i(),u("div",we,[a("div",ke,[n(g)?(i(),u("div",be,[c(te,{modelValue:n(_),"onUpdate:modelValue":t[0]||(t[0]=l=>B(_)?_.value=l:null)},{default:m(()=>[c(K,{value:"single"},{default:m(()=>[e("单个")]),_:1}),c(K,{value:"batch"},{default:m(()=>[e("批量")]),_:1})]),_:1},8,["modelValue"])])):r("",!0),a("div",xe,[W(a("div",null,[c(Z,{type:"text",modelValue:n(o),"onUpdate:modelValue":t[1]||(t[1]=l=>B(o)?o.value=l:null),onKeyup:t[2]||(t[2]=R(l=>S(),["enter"])),onKeypress:R(x(l=>1,["prevent"]),["enter"]),onKeydown:t[3]||(t[3]=R(l=>$(),["esc"])),ref_key:"addingDomainRef",ref:v,placeholder:n(b)?"example.com、*.example.com":"example.com、www.example.com",size:"30",maxlength:"100",class:"w-full"},null,8,["modelValue","onKeypress","placeholder"])],512),[[L,n(_)=="single"]]),W(a("div",null,[c(le,{cols:"30",modelValue:n(V),"onUpdate:modelValue":t[4]||(t[4]=l=>B(V)?V.value=l:null),placeholder:`example1.com
example2.com
每行一个域名`,ref_key:"batchDomainsRef",ref:w,class:"w-full",rows:"5"},null,8,["modelValue"])],512),[[L,n(_)=="batch"]])]),a("div",De,[c(ee,{secondary:"",size:"small",type:"button",onClick:x(S,["prevent"])},{default:m(()=>[e("确定")]),_:1}),e("   "),a("a",{href:"",title:"取消",onClick:x($,["prevent"])},Ce)])]),n(b)?(i(),u("p",$e,[e("支持普通域名（ "),c(D,null,{default:m(()=>[e("example.com")]),_:1}),e(" ）、泛域名（ "),c(D,null,{default:m(()=>[e("*.example.com")]),_:1}),e(" ）"),s.vSupportWildcard==null?(i(),u("span",Ee,[e("、域名后缀（以点号开头，如"),c(D,null,{default:m(()=>[e(".example.com")]),_:1}),e("）和正则表达式（以波浪号开头，如"),c(D,null,{default:m(()=>[e("~.*.example.com")]),_:1}),e("）")])):r("",!0),e("；如果域名后有端口，请加上端口号。 ")])):r("",!0),n(b)?r("",!0):(i(),u("p",Ne,[e("只支持普通域名（ "),c(D,null,{default:m(()=>[e("example.com")]),_:1}),e(" 、 "),c(D,null,{default:m(()=>[e("www.example.com")]),_:1}),e(" ）。 ")])),c(X)])):r("",!0),n(g)?r("",!0):(i(),u("div",Be,[c(ne,{size:"small",onClick:x(A,["prevent"])})]))]))}};export{Pe as _};
