const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./TorrentCreatorFormDialog-CVJNMn6L.js","./vue-3bs2-dMU.js","./rolldown-runtime-B0Z9INg1.js","./vue-BKb5tX_4.css","./stores-DmetsdTd.js","./preload-helper-HclGiUj8.js","./vuetify-gGrfRH2I.js","./vuetify-Pk2Sm9cw.css","./ServerPathField-DLutqYNk.js","./HistoryKey-C5zPCBlq.js"])))=>i.map(i=>d[i]);
import{$ as e,B as t,Bt as n,D as r,F as i,G as a,L as o,M as s,N as c,P as l,Q as ee,R as u,T as d,Tt as f,Ut as p,Wt as te,Y as m,bt as h,c as ne,ct as g,j as _,ot as v,p as re,qt as y,y as b,z as ie}from"./vue-3bs2-dMU.js";import{B as ae,E as oe,Ht as se,K as ce,Lt as x,Qt as S,Tt as le,W as ue,Zt as C,h as de,kt as w,t as T,zt as E}from"./stores-DmetsdTd.js";import{t as D}from"./preload-helper-HclGiUj8.js";import{C as O,Ft as fe,K as k,S as A,T as j,U as M,W as N,et as P,h as pe,ht as F,mt as I,o as L,q as R,rt as z,tt as B,w as V}from"./vuetify-gGrfRH2I.js";import{t as H}from"./purify.es-CYRiAeUx.js";a(),f(),p(),b();var me={class:`pa-3`},he={class:`d-flex align-center`},ge={class:`text-headline-medium ml-2`},_e={class:`d-flex justify-end`},ve={class:`d-flex align-center flex-gap`},ye={class:`text-no-wrap`},be={class:`text-no-wrap`},xe={class:`text-no-wrap`},Se={class:`text-no-wrap`},Ce={key:1},we={class:`text-no-wrap`},Te={key:1},Ee=[`innerHTML`],De=[`innerHTML`],U=t({__name:`TorrentCreator`,setup(t){let{height:a}=fe(),f=ne(),{t:p}=ce(),b=oe(),U=ue(),W=T(),{tasks:G}=re(W),K=de(),{isActive:q,pause:Oe,resume:J}=ae(W.fetchTasks,1e3,{immediate:!0,immediateCallback:!0}),ke=J,Ae=_(()=>a.value-64-24-48),je=_(()=>[{key:`actions`,sortable:!1},{title:p(`torrentCreator.table.sourcePath`),key:`sourcePath`},{title:p(`torrentCreator.table.status`),key:`status`},{title:p(`torrentCreator.table.progress`),key:`progress`},b.usesLibtorrent2?{title:p(`torrentCreator.table.format`),key:`format`}:{title:p(`torrentCreator.table.optimizeAlignment`),key:`optimizeAlignment`},{title:p(`torrentCreator.table.pieceSize`),key:`pieceSize`},{title:p(`torrentCreator.table.private`),key:`private`},{title:p(`torrentCreator.table.timeAdded`),key:`timeAdded`},{title:p(`torrentCreator.table.timeStarted`),key:`timeStarted`},{title:p(`torrentCreator.table.timeFinished`),key:`timeFinished`},{title:p(`torrentCreator.table.trackers.header`),key:`trackers`,sortable:!1},{title:p(`torrentCreator.table.urlSeeds.header`),key:`urlSeeds`,sortable:!1},{title:p(`torrentCreator.table.source`),key:`source`},{title:p(`torrentCreator.table.comment`),key:`comment`},{title:p(`torrentCreator.table.errorMessage`),key:`errorMessage`}]),Y={[S.FAILED]:`error`,[S.RUNNING]:`torrent-ul_stalled`,[S.QUEUED]:`warning`,[S.FINISHED]:`success`},Me={[C.V1]:`V1`,[C.V2]:`V2`,[C.HYBRID]:`Hybrid`};function X(){U.createDialog(ie(()=>D(()=>import(`./TorrentCreatorFormDialog-CVJNMn6L.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]),import.meta.url)),{},()=>void W.fetchTasks())}async function Ne(e){let t=await W.downloadTorrent(e.taskID),n=w(e.torrentFilePath),r;r=n&&n.endsWith(`.torrent`)?n.slice(0,-8):n||e.taskID,le(`${r}.torrent`,t)}async function Pe(e){await W.deleteTask(e.taskID),ke()}function Z(e){return e?.length?H.sanitize(e,{USE_PROFILES:{html:!0}}).replaceAll(`
`,`<br>`):``}function Q(){f.push({name:`dashboard`})}function $(e){if(U.hasActiveDialog)return!1;e.key===`Escape`&&(e.preventDefault(),Q())}return ee(()=>{document.addEventListener(`keydown`,$)}),e(()=>{document.removeEventListener(`keydown`,$)}),(e,t)=>(v(),i(`div`,me,[s(`div`,he,[s(`div`,ge,y(n(p)(`torrentCreator.title`)),1),u(F),s(`div`,_e,[u(k,{icon:`mdi-close`,variant:`plain`,onClick:Q})])]),n(G).length?(v(),c(P,{key:1},{default:h(()=>[u(z,null,{default:h(()=>[s(`div`,ve,[u(F),u(k,{color:`accent`,"prepend-icon":n(q)?`mdi-timer-pause`:`mdi-timer-play`,text:n(q)?n(p)(`common.pause`):n(p)(`common.resume`),onClick:t[1]||=e=>n(q)?n(Oe)():n(J)()},null,8,[`prepend-icon`,`text`]),u(k,{color:`accent`,"prepend-icon":`mdi-plus`,text:n(p)(`torrentCreator.table.create`),onClick:X},null,8,[`text`])])]),_:1}),u(B,{class:`my-3`}),u(z,{class:`text-select`},{default:h(()=>[u(pe,{"header-props":{class:`text-no-wrap`},mobile:null,headers:je.value,items:n(G),"multi-sort":``,"footer-props":{itemsPerPageOptions:[10,25,50,100,-1]}},{"item.status":h(({item:e,value:t})=>[s(`span`,{class:te(`text-${Y[e.status]}`)},y(n(p)(`constants.torrentCreatorTaskStatus.${t.toLowerCase()}`)),3)]),"item.progress":h(({item:e,value:t})=>[e.status===n(S).RUNNING?(v(),c(R,{key:0,"model-value":t,color:Y[e.status],height:20,rounded:`sm`,style:{width:`10em`}},{default:h(()=>[o(y(t)+` % `,1)]),_:2},1032,[`model-value`,`color`])):(v(),c(R,{key:1,"model-value":100,color:Y[e.status],height:20,rounded:`sm`,style:{width:`10em`}},{default:h(()=>[o(y(n(se)(1)),1)]),_:1},8,[`color`]))]),"item.format":h(({value:e})=>[o(y(Me[e]),1)]),"item.pieceSize":h(({value:e})=>[o(y(n(E)(e,n(K).useBinarySize,0)),1)]),"item.private":h(({value:e})=>[e?(v(),c(I,{key:0,color:`accent`},{default:h(()=>[...t[2]||=[o(` mdi-check-bold `,-1)]]),_:1})):(v(),c(I,{key:1,color:`error`},{default:h(()=>[...t[3]||=[o(` mdi-close-thick `,-1)]]),_:1}))]),"item.optimizeAlignment":h(({value:e})=>[e?(v(),c(I,{key:0,color:`accent`},{default:h(()=>[...t[4]||=[o(` mdi-check-bold `,-1)]]),_:1})):(v(),c(I,{key:1,color:`error`},{default:h(()=>[...t[5]||=[o(` mdi-close-thick `,-1)]]),_:1}))]),"item.timeAdded":h(({value:e})=>[s(`div`,ye,y(n(x)(e).format(n(K).dateFormat)),1)]),"item.timeFinished":h(({value:e})=>[s(`div`,be,y(n(x)(e).format(n(K).dateFormat)),1)]),"item.timeStarted":h(({value:e})=>[s(`div`,xe,y(n(x)(e).format(n(K).dateFormat)),1)]),"item.trackers":h(({value:e})=>[e&&e.length&&!e.every(e=>!e.length)?(v(),c(A,{key:0},{activator:h(({props:r})=>[s(`div`,Se,[s(`span`,null,y(n(p)(`torrentCreator.table.trackers.activator`,e.filter(e=>e.length).length)),1),u(I,m({class:`ml-1`},r),{default:h(()=>[...t[6]||=[o(` mdi-information `,-1)]]),_:1},16)])]),default:h(()=>[u(O,null,{default:h(()=>[u(j,{class:`ios-margin`},{default:h(()=>[u(M,{color:`transparent`},{default:h(()=>[u(N,null,{default:h(()=>[o(y(n(p)(`torrentCreator.table.trackers.title`)),1)]),_:1}),u(F),u(k,{icon:`mdi-close`})]),_:1})]),_:1}),u(V,null,{default:h(()=>[u(P,null,{default:h(()=>[(v(!0),i(r,null,g(e,(e,t)=>(v(),i(r,{key:t},[e?(v(),c(z,{key:0},{default:h(()=>[o(y(e),1)]),_:2},1024)):(v(),c(B,{key:1}))],64))),128))]),_:2},1024)]),_:2},1024)]),_:2},1024)]),_:2},1024)):(v(),i(`span`,Ce,y(n(p)(`common.none`)),1))]),"item.urlSeeds":h(({value:e})=>[e&&e.length&&!e.every(e=>!e.length)?(v(),c(A,{key:0},{activator:h(({props:r})=>[s(`div`,we,[s(`span`,null,y(n(p)(`torrentCreator.table.urlSeeds.activator`,e.filter(e=>e.length).length)),1),u(I,m({class:`ml-1`},r),{default:h(()=>[...t[7]||=[o(` mdi-information `,-1)]]),_:1},16)])]),default:h(()=>[u(O,null,{default:h(()=>[u(j,{class:`ios-margin`},{default:h(()=>[u(M,{color:`transparent`},{default:h(()=>[u(N,null,{default:h(()=>[o(y(n(p)(`torrentCreator.table.urlSeeds.title`)),1)]),_:1}),u(F),u(k,{icon:`mdi-close`})]),_:1})]),_:1}),u(V,null,{default:h(()=>[u(P,null,{default:h(()=>[(v(!0),i(r,null,g(e.filter(e=>e.length),(e,t)=>(v(),i(r,null,[e?(v(),c(z,{key:t},{default:h(()=>[o(y(e),1)]),_:2},1024)):l(``,!0)],64))),256))]),_:2},1024)]),_:2},1024)]),_:2},1024)]),_:2},1024)):(v(),i(`span`,Te,y(n(p)(`common.none`)),1))]),"item.comment":h(({value:e})=>[s(`div`,{class:`text-no-wrap`,innerHTML:Z(e)},null,8,Ee)]),"item.errorMessage":h(({value:e})=>[s(`div`,{class:`text-no-wrap`,innerHTML:Z(e)},null,8,De)]),"item.actions":h(({item:e})=>[u(k,{disabled:e.status!==n(S).FINISHED,color:`accent`,icon:`mdi-download`,variant:`text`,density:`compact`,onClick:d(t=>Ne(e),[`stop`])},null,8,[`disabled`,`onClick`]),u(k,{color:`red`,icon:`mdi-delete`,variant:`text`,density:`compact`,onClick:d(t=>Pe(e),[`stop`])},null,8,[`onClick`])]),_:2},1032,[`headers`,`items`])]),_:1})]),_:1})):(v(),c(O,{key:0,height:Ae.value},{default:h(()=>[u(L,{title:n(p)(`torrentCreator.empty.value`),color:`accent`,icon:`mdi-cog-off`},{actions:h(()=>[u(k,{text:n(p)(`torrentCreator.empty.action`),color:`accent`,onClick:t[0]||=e=>X()},null,8,[`text`])]),_:1},8,[`title`])]),_:1},8,[`height`]))]))}});export{U as default};