import{b as a,h as l,d as e,f as s,_ as t}from"./public.js?v=1753954525509";import{w as i,m as n}from"./page_layout.js?v=1753954525509";import{f as u,m as r,h as o,i as c,j as p}from"./setting.js?v=1753954525509";import{aq as d,c5 as m,ay as f}from"./naive.js?v=1753954525509";import{k as g,t as v,P as V,e as _,r as y,Q as x,F as h,n as b,U as w,V as S,W,X as k,a2 as j,j as E,a3 as C,N as P}from"./vue.js?v=1753954525509";import"./common.js?v=1753954525509";import"./__commonjsHelpers__.js?v=1753954525509";const B={class:"p-20px"},N={class:"flex mb-12px"},U={class:"flex-1 mr-12px"},$={class:"w-150px mr-12px"},z={class:"text-error"},D=g({__name:"index",props:{type:{}},setup(g,{expose:D}){const R=v(g,"type"),{t:q}=V(),A=_({ruleValue:"",ps:""}),F=async()=>{""!==A.ruleValue.trim()?(await p({...P(A),ruleName:R.value}),O(),A.ruleValue="",A.ps=""):n.error(q("Waf.Setting.config_194"))},H=y(null),L=y(null),{table:Q,columns:X,setLoading:G}=a([{key:"rule",title:q("Waf.Setting.config_82"),render:a=>x(h,null,[a.isEdit?x(d,{ref:H,value:a.ruleVal,size:"small",type:"textarea",autosize:{minRows:2,maxRows:2},placeholder:"",onUpdateValue:l=>{a.ruleVal=l}},null):a.rule])},{key:"ps",title:q("Waf.Setting.config_190"),width:150,render:a=>x(h,null,[a.isEdit?x(d,{ref:L,value:a.psVal,size:"small",placeholder:"",onUpdateValue:l=>{a.psVal=l}},null):a.ps])},{key:"status",title:q("Waf.Setting.config_82"),width:60,render:(a,l)=>x(m,{value:a.status,size:"small",checkedValue:1,uncheckedValue:0,onUpdateValue:async e=>{await u({index:l,ruleName:R.value}),a.status=e}},null)},l({width:100,options:(a,l)=>a.isEdit?[{label:q("Public.Btn.Save"),onClick:()=>{J(a,l)}},{label:q("Public.Btn.Cancel"),onClick:()=>{K(a)}}]:[{label:q("Public.Btn.Edit"),onClick:()=>{I(a)}},{label:q("Public.Btn.Del"),show:a.isDel,onClick:()=>{M(a,l)}}]})]),I=a=>{a.isEdit=!0,b((()=>{var a;null==(a=H.value)||a.focus()}))},J=async(a,l)=>{a.isEdit=!1,await r({index:l,ruleBody:a.ruleVal,rulePs:a.psVal,ruleName:R.value}),a.rule=a.ruleVal,a.ps=a.psVal},K=a=>{a.isEdit=!1,a.ruleVal=a.rule,a.psVal=a.ps},M=async(a,l)=>{e({title:q("Waf.Setting.config_195",[a.rule]),content:q("Waf.Setting.config_196"),onConfirm:async()=>{await o({index:l,ruleName:R.value}),O()}})},O=async()=>{try{G(!0);const{message:a}=await c({ruleName:R.value});i(a)&&(Q.data=a.map((a=>({rule:a[1],ruleVal:a[1],ps:a[2],psVal:a[2],status:a[0],isEdit:!1,isDel:1===a[3]}))))}finally{G(!1)}};return O(),D({init:O}),(a,l)=>{const e=f,i=s,n=t;return w(),S("div",B,[W("div",N,[W("div",U,[x(k(d),{value:k(A).ruleValue,"onUpdate:value":l[0]||(l[0]=a=>k(A).ruleValue=a),placeholder:a.$t("Waf.Setting.config_189")},null,8,["value","placeholder"])]),W("div",$,[x(k(d),{value:k(A).ps,"onUpdate:value":l[1]||(l[1]=a=>k(A).ps=a),placeholder:a.$t("Waf.Setting.config_190")},null,8,["value","placeholder"])]),x(e,{type:"primary",onClick:F},{default:j((()=>[E(C(a.$t("Public.Btn.Add")),1)])),_:1})]),x(i,{"max-height":340,loading:k(Q).loading,data:k(Q).data,columns:k(X)},null,8,["loading","data","columns"]),x(n,{class:"mt-16px"},{default:j((()=>[W("li",z,C(a.$t("Waf.Setting.config_191")),1),W("li",null,C(a.$t("Waf.Setting.config_192")),1),W("li",null,C(a.$t("Waf.Setting.config_193")),1)])),_:1})])}}});export{D as default};
