import{g as I,G as S,d as u,r as h,H as B,A as g,I as F,J as T,K as n,m as l,L as m,M as f,u as V,N as D,O as x,P as M,Q as O}from"./vue-BSryv7ps.js";import{a as $,b as K,V as U,c as A,d as P,e as R,f as b,g as _,h as j,i as C,j as q,__tla as __tla_0}from"./index-bUuJUL5l.js";let J;let __tla=Promise.all([(()=>{try{return __tla_0}catch{}})()]).then(async()=>{J=I({__name:"MoveTorrentFileDialog",props:{guid:{},hash:{},isFolder:{type:Boolean},oldName:{}},setup(k){const o=k,{isOpened:r}=$(o.guid),{t:c}=S(),N=K(),p=u(),i=u(),d=u(!1),t=h({newName:""}),y=[e=>!!e||c("dialogs.moveTorrent.required")];async function v(){await p.value?.validate(),d.value&&(o.isFolder?await N.renameTorrentFolder(o.hash,o.oldName,t.newName):await N.renameTorrentFile(o.hash,o.oldName,t.newName),w())}const w=()=>{r.value=!1};return B(()=>{if(t.newName=o.oldName,o.isFolder)g(()=>i.value?.select());else{const e=t.newName.lastIndexOf("/"),a=t.newName.lastIndexOf(".");g(()=>{i.value?.setSelectionRange(e+1,a==-1?t.newName.length:a)})}}),(e,a)=>(F(),T(q,{modelValue:V(r),"onUpdate:modelValue":a[3]||(a[3]=s=>O(r)?r.value=s:null)},{default:n(()=>[l(U,null,{default:n(()=>[l(A,null,{default:n(()=>[m(f(V(c)("dialogs.moveTorrentFile.title",1+Number(e.isFolder))),1)]),_:1}),l(P,null,{default:n(()=>[l(V(R),{modelValue:d.value,"onUpdate:modelValue":a[1]||(a[1]=s=>d.value=s),ref_key:"form",ref:p,onSubmit:a[2]||(a[2]=D(()=>{},["prevent"]))},{default:n(()=>[e.oldName?(F(),T(b,{key:0,"model-value":e.oldName,disabled:"",label:e.$t("dialogs.moveTorrentFile.oldName")},null,8,["model-value","label"])):x("",!0),l(b,{modelValue:t.newName,"onUpdate:modelValue":a[0]||(a[0]=s=>t.newName=s),ref_key:"input",ref:i,rules:y,autofocus:"",label:e.$t("dialogs.moveTorrent.newPath"),onKeydown:M(v,["enter"])},null,8,["modelValue","label"])]),_:1},8,["modelValue"])]),_:1}),l(_,null,{default:n(()=>[l(j),l(C,{color:"error",onClick:w},{default:n(()=>[m(f(e.$t("common.cancel")),1)]),_:1}),l(C,{color:"accent",disabled:!d.value,onClick:v},{default:n(()=>[m(f(e.$t("common.save")),1)]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"]))}})});export{J as _,__tla};