import{B as e,Bt as t,D as n,Dt as r,F as i,G as a,L as o,Mt as s,N as c,P as l,Q as u,R as d,Tt as f,Ut as p,Wt as ee,bt as m,ct as h,h as te,j as g,ot as _,p as v,qt as y}from"./vue-3bs2-dMU.js";import{C as b,D as x,E as S,K as ne,U as re,h as C}from"./stores-DmetsdTd.js";import{t as w}from"./HistoryKey-C5zPCBlq.js";import{C as T,D as E,G as ie,I as D,K as O,S as ae,T as oe,U as k,W as A,X as j,_t as M,b as N,gt as P,ht as F,mt as I,pt as L,w as R,x as z}from"./vuetify-gGrfRH2I.js";import{t as B}from"./AddTorrentParamsForm-Co-lsHHL.js";import{t as V}from"./HistoryField-BFlc9nis.js";a(),f(),p();var H={key:0,class:`text-label-medium text-grey-darken-2 ml-2`},U=2,W=e({__name:`AddTorrentDialog`,props:{guid:{},openSuddenly:{type:Boolean,default:!1}},setup(e){let{isOpened:a}=re(e.guid),{t:f}=ne(),p=x(),{urls:W,files:G,form:K,addTorrentParams:q}=v(p),se=S(),ce=b(),le=C(),J=g(()=>W.value.length>0||G.value.length>0),Y=s(),X=s(),Z=g({get:()=>K.value.cookie,set:e=>K.value.cookie=e||void 0}),Q=g({get:()=>K.value.rename,set:e=>K.value.rename=e||void 0});function ue(){if(!J.value)return;let e={addToTopOfQueue:q.value.add_to_top_of_queue,autoTMM:q.value.use_auto_tmm,category:q.value.category,contentLayout:q.value.content_layout,cookie:K.value.cookie,dlLimit:q.value.download_limit,downloadPath:q.value.download_path,firstLastPiecePrio:K.value.firstLastPiecePrio,forced:q.value.forced,inactiveSeedingTimeLimit:q.value.inactive_seeding_time_limit,paused:q.value.stopped,stopped:q.value.stopped,ratioLimit:q.value.ratio_limit,rename:K.value.rename,savepath:q.value.save_path,seedingTimeLimit:q.value.seeding_time_limit,sequentialDownload:K.value.sequentialDownload,skip_checking:q.value.skip_checking,stopCondition:q.value.stop_condition,tags:q.value.tags?.join(`,`),upLimit:q.value.upload_limit,useDownloadPath:q.value.use_download_path},t=G.value.length+W.value.split(`
`).filter(e=>e.trim().length).length;te.promise(ce.addTorrents(G.value,W.value,e),{pending:f(`toast.add.pending`),error:f(`toast.add.error`,t),success:f(`toast.add.success`,t)},{autoClose:1500}).then(()=>{Y.value?.saveValueToHistory(),X.value?.saveFields(),p.resetForm(),$()})}function $(){a.value=!1}return u(()=>{p.initForm()}),(s,u)=>(_(),c(ae,{modelValue:t(a),"onUpdate:modelValue":u[8]||=e=>r(a)?a.value=e:null,class:ee(s.$vuetify.display.mobile?``:`w-75`),fullscreen:s.$vuetify.display.mobile,scrollable:``,transition:e.openSuddenly?`none`:`dialog-bottom-transition`},{default:m(()=>[d(T,null,{default:m(()=>[d(oe,{class:`ios-margin`},{default:m(()=>[d(k,{color:`transparent`},{default:m(()=>[d(A,null,{default:m(()=>[o(y(t(f)(`dialogs.add.title`)),1)]),_:1}),d(O,{icon:`mdi-close`,onClick:$})]),_:1})]),_:1}),d(R,null,{default:m(()=>[d(P,null,{default:m(()=>[d(M,{cols:`12`},{default:m(()=>[d(z,{modelValue:t(G),"onUpdate:modelValue":u[0]||=e=>r(G)?G.value=e:null,label:t(f)(`dialogs.add.files`),"show-size":t(le).useBinarySize?1024:1e3,accept:`.torrent`,counter:``,multiple:``,"persistent-clear":``,"persistent-hint":``,"prepend-icon":``,variant:`outlined`},{prepend:m(()=>[d(I,{color:`accent`},{default:m(()=>[...u[9]||=[o(` mdi-paperclip `,-1)]]),_:1})]),selection:m(({fileNames:e})=>[(_(!0),i(n,null,h(e,(e,t)=>(_(),i(n,null,[t<U?(_(),c(j,{key:e,class:`mr-2`,color:`accent`,label:``,size:`small`},{default:m(()=>[o(y(e),1)]),_:2},1024)):l(``,!0)],64))),256)),e.length>U?(_(),i(`span`,H,y(t(f)(`dialogs.add.file_overflow`,e.length-U)),1)):l(``,!0)]),_:1},8,[`modelValue`,`label`,`show-size`]),d(N,{modelValue:t(W),"onUpdate:modelValue":u[1]||=e=>r(W)?W.value=e:null,label:t(f)(`dialogs.add.links`),clearable:``},{prepend:m(()=>[d(I,{color:`accent`},{default:m(()=>[...u[10]||=[o(` mdi-link `,-1)]]),_:1})]),_:1},8,[`modelValue`,`label`]),d(L,null,{default:m(()=>[t(W)&&!t(se).isFeatureAvailable(`5.1.0`)?(_(),c(V,{key:0,ref_key:`cookieField`,ref:Y,modelValue:Z.value,"onUpdate:modelValue":u[2]||=e=>Z.value=e,"history-key":t(w).COOKIE,clearable:``,label:s.$t(`dialogs.add.cookie`),placeholder:s.$t(`dialogs.add.cookie_placeholder`)},{prepend:m(()=>[d(I,{color:`accent`},{default:m(()=>[...u[11]||=[o(` mdi-cookie `,-1)]]),_:1})]),_:1},8,[`modelValue`,`history-key`,`label`,`placeholder`])):l(``,!0)]),_:1}),d(ie,{modelValue:Q.value,"onUpdate:modelValue":u[3]||=e=>Q.value=e,clearable:``,"hide-details":``,label:s.$t(`dialogs.add.rename`)},{prepend:m(()=>[d(I,{color:`accent`},{default:m(()=>[...u[12]||=[o(` mdi-rename `,-1)]]),_:1})]),_:1},8,[`modelValue`,`label`])]),_:1})]),_:1}),d(P,null,{default:m(()=>[d(M,{cols:`12`,md:`6`},{default:m(()=>[d(D,{modelValue:t(K).sequentialDownload,"onUpdate:modelValue":u[4]||=e=>t(K).sequentialDownload=e,label:t(f)(`dialogs.add.sequential_download`),color:`accent`,density:`compact`,"hide-details":``},null,8,[`modelValue`,`label`])]),_:1}),d(M,{cols:`12`,md:`6`},{default:m(()=>[d(D,{modelValue:t(K).firstLastPiecePrio,"onUpdate:modelValue":u[5]||=e=>t(K).firstLastPiecePrio=e,label:t(f)(`dialogs.add.first_last_piece_prio`),color:`accent`,density:`compact`,"hide-details":``},null,8,[`modelValue`,`label`])]),_:1})]),_:1}),d(B,{ref_key:`addTorrentParamsForm`,ref:X,modelValue:t(q),"onUpdate:modelValue":u[6]||=e=>r(q)?q.value=e:null},null,8,[`modelValue`])]),_:1}),d(E,{class:`mb-2`},{default:m(()=>[d(O,{text:s.$t(`dialogs.add.reset_form`),color:`error`,variant:`flat`,onClick:u[7]||=e=>t(p).resetForm()},null,8,[`text`]),d(F),d(O,{disabled:!J.value,text:s.$t(`dialogs.add.submit`),color:`accent`,type:`submit`,variant:`elevated`,onClick:ue},null,8,[`disabled`,`text`]),d(O,{text:s.$t(`common.close`),color:``,variant:`flat`,onClick:$},null,8,[`text`])]),_:1})]),_:1})]),_:1},8,[`modelValue`,`class`,`fullscreen`,`transition`]))}});export{W as default};