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