import{B as e,Bt as t,Dt as n,G as r,L as i,Mt as a,N as o,Q as s,R as c,T as l,Tt as u,Ut as d,bt as f,ot as p,qt as m,w as h,y as g}from"./vue-3bs2-dMU.js";import{C as _,U as v,c as y}from"./stores-DmetsdTd.js";import{C as b,D as x,G as S,K as C,S as w,ht as T,w as E,y as D}from"./vuetify-gGrfRH2I.js";r(),u(),g(),d();var O=e({__name:`SpeedLimitDialog`,props:{guid:{},hashes:{},mode:{}},setup(e){let r=e,{isOpened:u}=v(r.guid),d=y(),g=_(),O=a(!1),k=a(0);function A(){u.value=!1}async function j(){let e=Math.max(0,k.value)*1e3;switch(r.mode){case`download`:await d.setDownloadLimit(e,r.hashes);break;case`upload`:await d.setUploadLimit(e,r.hashes)}A()}return s(()=>{let e=g.getTorrentByHash(r.hashes[0]);if(!e)return A();switch(r.mode){case`download`:k.value=Math.max(0,Math.round(e.dl_limit/1e3));break;case`upload`:k.value=Math.max(0,Math.round(e.up_limit/1e3))}}),(r,a)=>(p(),o(w,{modelValue:t(u),"onUpdate:modelValue":a[3]||=e=>n(u)?u.value=e:null},{default:f(()=>[c(b,{title:r.$t(`dialogs.speed_limit.${e.mode}`)},{default:f(()=>[c(E,null,{default:f(()=>[c(D,{modelValue:O.value,"onUpdate:modelValue":a[1]||=e=>O.value=e,onSubmit:a[2]||=l(()=>{},[`prevent`]),onKeydown:h(l(j,[`prevent`]),[`enter`])},{default:f(()=>[c(S,{modelValue:k.value,"onUpdate:modelValue":a[0]||=e=>k.value=e,modelModifiers:{number:!0},type:`number`,autofocus:``,clearable:``,label:r.$t(`dialogs.speed_limit.label`),"prepend-inner-icon":`mdi-speedometer`,suffix:`kB/s`,onKeydown:h(l(j,[`prevent`]),[`enter`])},null,8,[`modelValue`,`label`,`onKeydown`])]),_:1},8,[`modelValue`,`onKeydown`])]),_:1}),c(x,null,{default:f(()=>[c(T),c(C,{color:`error`,onClick:A},{default:f(()=>[i(m(r.$t(`common.cancel`)),1)]),_:1}),c(C,{color:`accent`,disabled:!O.value,onClick:j},{default:f(()=>[i(m(r.$t(`common.save`)),1)]),_:1},8,[`disabled`])]),_:1})]),_:1},8,[`title`])]),_:1},8,[`modelValue`]))}});export{O as default};