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