import{At as e,B as t,Bt as n,Dt as r,G as i,L as a,Mt as o,N as s,Q as c,R as l,T as u,Tt as d,Ut as f,bt as p,ot as m,qt as h,w as g,y as _}from"./vue-3bs2-dMU.js";import{K as v,U as y,i as b}from"./stores-DmetsdTd.js";import{C as x,D as S,G as C,K as w,S as T,T as E,ht as D,w as O,y as k}from"./vuetify-gGrfRH2I.js";i(),d(),f(),_();var A=t({__name:`RssFeedDialog`,props:{guid:{},initialFeed:{}},setup(t){let i=t,{t:d}=v(),{isOpened:f}=y(i.guid),_=b(),A=o(),j=o(!1),M=e({name:``,url:``}),N=[e=>!!e||d(`dialogs.rss.feed.rules.name_required`)],P=[e=>!!e||d(`dialogs.rss.feed.rules.url_required`)];async function F(){await A.value?.validate(),j.value&&(i.initialFeed?(M.url!==i.initialFeed.url&&await _.setFeedUrl(i.initialFeed.name,M.url),M.name!==i.initialFeed.name&&await _.renameFeed(i.initialFeed.name,M.name)):await _.createFeed(M.name,M.url),await _.fetchFeeds(),I())}function I(){f.value=!1}return c(()=>{i.initialFeed&&(M.name=i.initialFeed.name,M.url=i.initialFeed.url)}),(e,i)=>(m(),s(T,{modelValue:n(f),"onUpdate:modelValue":i[4]||=e=>r(f)?f.value=e:null},{default:p(()=>[l(x,null,{default:p(()=>[l(E,null,{default:p(()=>[a(h(e.$t(`dialogs.rss.feed.title.${t.initialFeed?`edit`:`create`}`)),1)]),_:1}),l(O,null,{default:p(()=>[l(n(k),{ref_key:`form`,ref:A,modelValue:j.value,"onUpdate:modelValue":i[2]||=e=>j.value=e,onSubmit:i[3]||=u(()=>{},[`prevent`])},{default:p(()=>[l(C,{modelValue:M.name,"onUpdate:modelValue":i[0]||=e=>M.name=e,rules:N,label:e.$t(`dialogs.rss.feed.name`),onKeydown:g(F,[`enter`])},null,8,[`modelValue`,`label`]),l(C,{modelValue:M.url,"onUpdate:modelValue":i[1]||=e=>M.url=e,rules:P,label:e.$t(`dialogs.rss.feed.url`),onKeydown:g(F,[`enter`])},null,8,[`modelValue`,`label`])]),_:1},8,[`modelValue`])]),_:1}),l(S,null,{default:p(()=>[l(D),l(w,{color:`error`,onClick:I},{default:p(()=>[a(h(e.$t(`common.cancel`)),1)]),_:1}),l(w,{color:`accent`,disabled:!j.value,onClick:F},{default:p(()=>[a(h(e.$t(`common.save`)),1)]),_:1},8,[`disabled`])]),_:1})]),_:1})]),_:1},8,[`modelValue`]))}});export{A as default};