import{_ as e}from"./index.vue_vue_type_script_setup_true_lang.js?v=1764830988434";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=1764830988434";import{gP as y,x as v,k as _,gQ as b,gR as w,bf as h}from"./page_layout.js?v=1764830988434";import{dR as g,dV as x,df as S,_ as A}from"./naive.js?v=1764830988434";import"./__commonjsHelpers__.js?v=1764830988434";import"./common.js?v=1764830988434";import"./public.js?v=1764830988434";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:P}){const R=a,C=P,{t:H}=l(),{isEdit:V,row:B}=R,I=r(null),Q=t({types:"drop",choose:"all",ports:null,country:["United States"],is_update:!1}),W={country:{trigger:"change",validator:()=>0!==Q.country.length||new Error(H("Security.Firewall.Area.form_8"))},ports:{trigger:["blur","input"],validator:()=>{if("point"===Q.choose){if(!Q.ports)return new Error(H("Security.Firewall.Area.form_9"));if(!h("".concat(Q.ports)))return new Error(H("Security.Firewall.Area.form_10"))}return!0}}},q=[{label:H("Security.Firewall.Area.form_11"),value:"all"},{label:H("Security.Firewall.Area.form_3"),value:"point"}],z=[{label:H("Security.Firewall.Area.form_12"),value:"drop"}],D=r(!1),G=r([]);return(async()=>{try{D.value=!0;const{message:e}=await y();v(e)&&(G.value=e.map(e=>({label:e.CH,value:e.CH,brief:e.brief})))}finally{D.value=!1}})(),V&&B&&(Q.types=B.types,Q.choose=B.ports?"point":"all",Q.ports=B.ports?_(B.ports):null,Q.country=B.country),$({onConfirm:async()=>{var e,a;await(null==(e=I.value)?void 0:e.validate());const l={types:Q.types,choose:Q.choose,ports:"point"===Q.choose?"".concat(Q.ports||""):"",country:Q.country,brief:"",is_update:Q.is_update};V&&B?(l.brief="".concat((null==(a=G.value.find(e=>e.label===B.country))?void 0:a.brief)||""),await b({...l,id:B.id})):await w(l),C("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(Q),rules:W},{default:u(()=>[i(t,{label:a.$t("Security.Firewall.Area.form_1"),path:"types"},{default:u(()=>[d("div",j,[i(r,{value:f(Q).types,"onUpdate:value":l[0]||(l[0]=e=>f(Q).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(Q).choose,"onUpdate:value":l[1]||(l[1]=e=>f(Q).choose=e),options:q},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(Q).ports,"onUpdate:value":l[2]||(l[2]=e=>f(Q).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(Q).choose]]),i(t,{label:a.$t("Security.Firewall.Area.form_5"),path:"country"},{default:u(()=>[d("div",E,[i(r,{value:f(Q).country,"onUpdate:value":l[3]||(l[3]=e=>f(Q).country=e),filterable:"","max-tag-count":"responsive",multiple:!f(V),loading:f(D),options:f(G)},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(Q).is_update,"onUpdate:checked":l[4]||(l[4]=e=>f(Q).is_update=e),label:"Update IP Pool"},null,8,["checked"])]),_:1}))]),_:1},8,["model"])])}}});export{$ as default};
