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,P as c,Q as l,R as u,T as d,Tt as f,Ut as p,bt as m,j as h,nt as g,ot as _,qt as v,w as y,y as b}from"./vue-3bs2-dMU.js";import{C as x,K as S,U as C}from"./stores-DmetsdTd.js";import{C as w,D as T,G as E,K as D,S as O,T as k,ht as A,w as j,y as M}from"./vuetify-gGrfRH2I.js";i(),f(),p(),b();var N=t({__name:`RenameTorrentDialog`,props:{guid:{},hash:{}},setup(t){let i=t,{isOpened:f}=C(i.guid),{t:p}=S(),b=x(),N=o(),P=o(),F=o(!1),I=e({newName:``}),L=[e=>!!e||p(`dialogs.renameTorrent.required`),e=>e!==z.value||p(`dialogs.renameTorrent.sameName`)],R=h(()=>b.getTorrentByHash(i.hash)),z=h(()=>R.value?.name);async function B(){await P.value?.validate(),F.value&&(await b.renameTorrent(i.hash,I.newName),V())}function V(){f.value=!1}return l(()=>{I.newName=R.value?.name||``}),g(()=>{N.value?.select()}),(e,t)=>(_(),s(O,{modelValue:n(f),"onUpdate:modelValue":t[3]||=e=>r(f)?f.value=e:null},{default:m(()=>[u(w,null,{default:m(()=>[u(k,null,{default:m(()=>[a(v(e.$t(`dialogs.renameTorrent.title`)),1)]),_:1}),u(j,null,{default:m(()=>[u(n(M),{ref_key:`form`,ref:P,modelValue:F.value,"onUpdate:modelValue":t[1]||=e=>F.value=e,onSubmit:t[2]||=d(()=>{},[`prevent`])},{default:m(()=>[z.value?(_(),s(E,{key:0,"model-value":z.value,disabled:``,label:e.$t(`dialogs.renameTorrent.oldName`)},null,8,[`model-value`,`label`])):c(``,!0),u(E,{ref_key:`field`,ref:N,modelValue:I.newName,"onUpdate:modelValue":t[0]||=e=>I.newName=e,rules:L,autofocus:``,label:e.$t(`dialogs.renameTorrent.newName`),onKeydown:y(B,[`enter`])},null,8,[`modelValue`,`label`])]),_:1},8,[`modelValue`])]),_:1}),u(T,null,{default:m(()=>[u(A),u(D,{color:`error`,onClick:V},{default:m(()=>[a(v(e.$t(`common.cancel`)),1)]),_:1}),u(D,{color:`accent`,disabled:!F.value,onClick:B},{default:m(()=>[a(v(e.$t(`common.save`)),1)]),_:1},8,[`disabled`])]),_:1})]),_:1})]),_:1},8,[`modelValue`]))}});export{N as default};