import{d as j,b as l,a7 as P,af as G,aB as D,a8 as C,M,P as R,r as W,at as Y,w as h,x as O,bB as Q,_ as Z}from"./app-QjDgb7aF.js";import{b as $,a as d,w as ee,j as v,p as g,q as f,k as V,i as s,J as o,D as n,u as t,I as m,g as S,F as N,G as E,H as T}from"./vue-Cm77DuTi.js";const ae={class:"shaynizk"},te={class:"form"},ne={value:"all"},le={value:"users"},se={value:"instances"},oe=["value"],ue=["value"],ie={class:"actions"},de=$({__name:"editor",props:{antenna:{}},emits:["created","updated","deleted"],setup(L,{emit:X}){const u=L,K=X;let k=d(u.antenna.name),r=d(u.antenna.src),w=d(u.antenna.userListId),y=d(u.antenna.userGroupId),p=d(u.antenna.users.join(`
`)),c=d(u.antenna.instances.join(`
`)),_=d(u.antenna.keywords.map(i=>i.join(" ")).join(`
`)),B=d(u.antenna.excludeKeywords.map(i=>i.join(" ")).join(`
`)),b=d(u.antenna.caseSensitive),x=d(u.antenna.withReplies),U=d(u.antenna.withFile),I=d(u.antenna.notify),A=d(null),F=d(null);ee(()=>r.value,async()=>{if(r.value==="list"&&A.value===null&&(A.value=await j("users/lists/list")),r.value==="group"&&F.value===null){const i=await j("users/groups/owned"),a=await j("users/groups/joined");F.value=[...i,...a]}});async function q(){const i={name:k.value,src:r.value,userListId:w.value,userGroupId:y.value,withReplies:x.value,withFile:U.value,notify:I.value,caseSensitive:b.value,users:p.value.trim().split(`
`).map(a=>a.trim()),instances:c.value.trim().split(`
`).map(a=>a.trim()),keywords:_.value.trim().split(`
`).map(a=>a.trim().split(" ")),excludeKeywords:B.value.trim().split(`
`).map(a=>a.trim().split(" "))};u.antenna.id==null?(await R("antennas/create",i),K("created")):(i.antennaId=u.antenna.id,await R("antennas/update",i),K("updated"))}async function z(){const{canceled:i}=await W({type:"warning",text:l.t("removeAreYouSure",{x:u.antenna.name})});i||(await j("antennas/delete",{antennaId:u.antenna.id}),Y(),K("deleted"))}function H(){h().then(i=>{p.value=p.value.trim(),p.value+=`
@${O.toString(i)}`,p.value=p.value.trim()})}function J(){Q().then(i=>{c.value=c.value.trim(),c.value+=`
`+i.host,c.value=c.value.trim()})}return(i,a)=>(v(),g("div",ae,[f("div",te,[V(P,{modelValue:t(k),"onUpdate:modelValue":a[0]||(a[0]=e=>m(k)?k.value=e:k=e),class:"_formBlock"},{label:s(()=>[o(n(t(l).ts.name),1)]),_:1},8,["modelValue"]),V(G,{modelValue:t(r),"onUpdate:modelValue":a[1]||(a[1]=e=>m(r)?r.value=e:r=e),class:"_formBlock"},{label:s(()=>[o(n(t(l).ts.antennaSource),1)]),default:s(()=>[f("option",ne,n(t(l).ts._antennaSources.all),1),f("option",le,n(t(l).ts._antennaSources.users),1),f("option",se,n(t(l).ts._antennaSources.instances),1)]),_:1},8,["modelValue"]),t(r)==="list"?(v(),S(G,{key:0,modelValue:t(w),"onUpdate:modelValue":a[2]||(a[2]=e=>m(w)?w.value=e:w=e),class:"_formBlock"},{label:s(()=>[o(n(t(l).ts.userList),1)]),default:s(()=>[(v(!0),g(N,null,E(t(A),e=>(v(),g("option",{key:e.id,value:e.id},n(e.name),9,oe))),128))]),_:1},8,["modelValue"])):t(r)==="group"?(v(),S(G,{key:1,modelValue:t(y),"onUpdate:modelValue":a[3]||(a[3]=e=>m(y)?y.value=e:y=e),class:"_formBlock"},{label:s(()=>[o(n(t(l).ts.userGroup),1)]),default:s(()=>[(v(!0),g(N,null,E(t(F),e=>(v(),g("option",{key:e.id,value:e.id},n(e.name),9,ue))),128))]),_:1},8,["modelValue"])):t(r)==="users"?(v(),S(D,{key:2,modelValue:t(p),"onUpdate:modelValue":a[4]||(a[4]=e=>m(p)?p.value=e:p=e),class:"_formBlock"},{label:s(()=>[o(n(t(l).ts.users),1)]),caption:s(()=>[o(n(t(l).ts.antennaUsersDescription)+" ",1),f("button",{class:"_textButton",onClick:H},n(t(l).ts.addUser),1)]),_:1},8,["modelValue"])):t(r)==="instances"?(v(),S(D,{key:3,modelValue:t(c),"onUpdate:modelValue":a[5]||(a[5]=e=>m(c)?c.value=e:c=e),class:"_formBlock"},{label:s(()=>[o(n(t(l).ts.instances),1)]),caption:s(()=>[o(n(t(l).ts.antennaInstancesDescription)+" ",1),f("button",{class:"_textButton",onClick:J},n(t(l).ts.addInstance),1)]),_:1},8,["modelValue"])):T("",!0),V(C,{modelValue:t(x),"onUpdate:modelValue":a[6]||(a[6]=e=>m(x)?x.value=e:x=e),class:"_formBlock"},{default:s(()=>[o(n(t(l).ts.withReplies),1)]),_:1},8,["modelValue"]),V(D,{modelValue:t(_),"onUpdate:modelValue":a[7]||(a[7]=e=>m(_)?_.value=e:_=e),class:"_formBlock"},{label:s(()=>[o(n(t(l).ts.antennaKeywords),1)]),caption:s(()=>[o(n(t(l).ts.antennaKeywordsDescription),1)]),_:1},8,["modelValue"]),V(D,{modelValue:t(B),"onUpdate:modelValue":a[8]||(a[8]=e=>m(B)?B.value=e:B=e),class:"_formBlock"},{label:s(()=>[o(n(t(l).ts.antennaExcludeKeywords),1)]),caption:s(()=>[o(n(t(l).ts.antennaKeywordsDescription),1)]),_:1},8,["modelValue"]),V(C,{modelValue:t(b),"onUpdate:modelValue":a[9]||(a[9]=e=>m(b)?b.value=e:b=e),class:"_formBlock"},{default:s(()=>[o(n(t(l).ts.caseSensitive),1)]),_:1},8,["modelValue"]),V(C,{modelValue:t(U),"onUpdate:modelValue":a[10]||(a[10]=e=>m(U)?U.value=e:U=e),class:"_formBlock"},{default:s(()=>[o(n(t(l).ts.withFileAntenna),1)]),_:1},8,["modelValue"]),V(C,{modelValue:t(I),"onUpdate:modelValue":a[11]||(a[11]=e=>m(I)?I.value=e:I=e),class:"_formBlock"},{default:s(()=>[o(n(t(l).ts.notifyAntenna),1)]),_:1},8,["modelValue"])]),f("div",ie,[V(M,{inline:"",primary:"",onClick:a[12]||(a[12]=e=>q())},{default:s(()=>[a[14]||(a[14]=f("i",{class:"ph-floppy-disk-back ph-bold ph-lg"},null,-1)),o(" "+n(t(l).ts.save),1)]),_:1}),L.antenna.id!=null?(v(),S(M,{key:0,inline:"",danger:"",onClick:a[13]||(a[13]=e=>z())},{default:s(()=>[a[15]||(a[15]=f("i",{class:"ph-trash ph-bold ph-lg"},null,-1)),o(" "+n(t(l).ts.delete),1)]),_:1})):T("",!0)])]))}}),pe=Z(de,[["__scopeId","data-v-0cb2d796"]]);export{pe as X};
//# sourceMappingURL=editor-yG_HD3t2.js.map
