import{_ as e}from"./index.vue_vue_type_script_setup_true_lang.js?v=1764233927359";import{k as a,P as l,r,e as t,R as o,V as s,W as i,a3 as u,l as p,a2 as n,an as c,S as d,U as f,v as m}from"./vue.js?v=1764233927359";import{gX as y,x as v,k as _,gY as b,gZ as w,b6 as h}from"./page_layout.js?v=1764233927359";import{dR as g,dV as x,df as S,_ as A}from"./naive.js?v=1764233927359";import"./__commonjsHelpers__.js?v=1764233927359";import"./common.js?v=1764233927359";import"./public.js?v=1764233927359";const F={class:"px-20px pt-24px pb-8px"},j={class:"w-240px"},U={class:"w-240px"},k={class:"w-240px"},E={class:"w-240px"},$=a({__name:"form",props:{row:{},isEdit:{type:Boolean,default:!1}},emits:["refresh"],setup(a,{expose:$,emit:C}){const H=a,P=C,{t:R}=l(),{isEdit:V,row:B}=H,I=r(null),W=t({types:"drop",choose:"all",ports:null,country:["United States"],is_update:!1}),X={country:{trigger:"change",validator:()=>0!==W.country.length||new Error(R("Security.Firewall.Area.form_8"))},ports:{trigger:["blur","input"],validator:()=>{if("point"===W.choose){if(!W.ports)return new Error(R("Security.Firewall.Area.form_9"));if(!h("".concat(W.ports)))return new Error(R("Security.Firewall.Area.form_10"))}return!0}}},Y=[{label:R("Security.Firewall.Area.form_11"),value:"all"},{label:R("Security.Firewall.Area.form_3"),value:"point"}],Z=[{label:R("Security.Firewall.Area.form_12"),value:"drop"}],q=r(!1),z=r([]);return(async()=>{try{q.value=!0;const{message:e}=await y();v(e)&&(z.value=e.map(e=>({label:e.CH,value:e.CH,brief:e.brief})))}finally{q.value=!1}})(),V&&B&&(W.types=B.types,W.choose=B.ports?"point":"all",W.ports=B.ports?_(B.ports):null,W.country=B.country),$({onConfirm:async()=>{var e,a;await(null==(e=I.value)?void 0:e.validate());const l={types:W.types,choose:W.choose,ports:"point"===W.choose?"".concat(W.ports||""):"",country:W.country,brief:"",is_update:W.is_update};V&&B?(l.brief="".concat((null==(a=z.value.find(e=>e.label===B.country))?void 0:a.brief)||""),await b({...l,id:B.id})):await w(l),P("refresh")}}),(a,l)=>{const r=x,t=g,y=S,v=A,_=e;return s(),o("div",F,[i(_,{ref_key:"formRef",ref:I,model:f(W),rules:X},{default:u(()=>[i(t,{label:a.$t("Security.Firewall.Area.form_1"),path:"types"},{default:u(()=>[d("div",j,[i(r,{value:f(W).types,"onUpdate:value":l[0]||(l[0]=e=>f(W).types=e),options:Z},null,8,["value"])])]),_:1},8,["label"]),i(t,{label:a.$t("Security.Firewall.Area.form_2"),path:"choose"},{default:u(()=>[d("div",U,[i(r,{value:f(W).choose,"onUpdate:value":l[1]||(l[1]=e=>f(W).choose=e),options:Y},null,8,["value"])])]),_:1},8,["label"]),p(i(t,{label:a.$t("Security.Firewall.Area.form_3"),path:"ports"},{default:u(()=>[d("div",k,[i(y,{value:f(W).ports,"onUpdate:value":l[2]||(l[2]=e=>f(W).ports=e),min:1,max:65535,"show-button":!1,placeholder:a.$t("Security.Firewall.Area.form_4")},null,8,["value","placeholder"])])]),_:1},8,["label"]),[[m,"point"===f(W).choose]]),i(t,{label:a.$t("Security.Firewall.Area.form_5"),path:"country"},{default:u(()=>[d("div",E,[i(r,{value:f(W).country,"onUpdate:value":l[3]||(l[3]=e=>f(W).country=e),filterable:"","max-tag-count":"responsive",multiple:!f(V),loading:f(q),options:f(z)},null,8,["value","multiple","loading","options"])])]),_:1},8,["label"]),f(V)?c("",!0):(s(),n(t,{key:0,label:" "},{default:u(()=>[i(v,{checked:f(W).is_update,"onUpdate:checked":l[4]||(l[4]=e=>f(W).is_update=e),label:"Update IP Pool"},null,8,["checked"])]),_:1}))]),_:1},8,["model"])])}}});export{$ as default};
