import{a as i,F as x,j as t}from"./index-b983ad9b.js";import{r as c}from"./react-b0e0d18a.js";/* empty css                *//* empty css              *//* empty css              *//* empty css              *//* empty css              *//* empty css              *//* empty css              */import{E as m}from"./index-6d3c1eaa.js";import{c as d,B as p,r as v,M as G,b as T,s as N,E as h}from"./antd-8ca2e36c.js";/* empty css              *//* empty css              */function _({type:o,targetId:r=0,refreshSeed:u,onChange:s}){const[n,f]=c.useState(),[l,g]=c.useState(!0);c.useEffect(()=>{let e=!0;return(async()=>{const a={targetId:r,type:o};l&&(a.global=1);const E=await m.getTriggers(a);e&&f(E)})(),()=>{e=!1}},[r,o,u,l]);const b=()=>{s&&s(0)},y=e=>async a=>{await m.updateTrigger(e.id,{enabled:a})};return i(x,{children:[i("div",{className:"section-title",children:[t("span",{className:"title",children:"事件规则"}),i(d,{children:[t(p,{size:"small",shape:"circle",type:l?"primary":"default",title:"全局",disabled:!r,onClick:()=>{g(!l)},children:"G"}),t(p,{size:"small",shape:"circle",icon:t(v,{}),onClick:b})]})]}),t("div",{className:"section-content",children:n&&n.length?t(G,{mode:"vertical",onClick:({key:e})=>{s&&s(Number(e))},items:n.map(e=>({key:e.id,label:i("div",{style:{display:"flex",flexDirection:"row",alignItems:"center"},children:[t("div",{style:{flex:1},children:i(d,{children:[t("span",{className:"name",children:e.name}),e.type==="global"&&t(T,{children:"G"})]})}),t(N,{size:"small",defaultChecked:e.enabled,onChange:y(e)})]})}))}):t("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:t(h,{image:h.PRESENTED_IMAGE_SIMPLE,description:""})})})]})}export{_ as default};
