import{At as e,B as t,Bt as n,Dt as r,G as i,Gt as a,L as o,M as s,N as c,R as l,Tt as u,Ut as d,Y as f,bt as p,j as m,ot as h,qt as g}from"./vue-3bs2-dMU.js";import{At as _,I as v,K as y,Mt as b,Nt as x,U as S,Wt as C,h as w,m as T,tn as E,zt as D}from"./stores-DmetsdTd.js";import{C as ee,D as O,G as k,K as A,N as j,S as M,T as N,U as P,W as F,_t as I,gt as L,mt as R,nt as z,p as B,rt as V,tt as H,w as U}from"./vuetify-gGrfRH2I.js";i(),u(),d();var W={style:{"white-space":`nowrap`}},G=t({__name:`ContentFilterDialog`,props:{guid:{}},setup(t){let i=t,{t:u}=y(),{isOpened:d}=S(i.guid),G=T(),K=w(),q=m(()=>G.cachedFiles.map(e=>e.size).reduce((e,t)=>[e[0]===-1||t<e[0]?t:e[0],e[1]===-1||t>e[1]?t:e[1]],[-1,-1])),J=m(()=>new Set(G.cachedFiles.map(e=>x(e.name)[1])).values().reduce((e,t)=>{let n=_(t);return Object.keys(e).includes(n)?e[n].push(t):e[n]=[t],e},{})),Y=m(()=>Object.entries(J.value).sort(([e,t],[n,r])=>e===v.UNKNOWN?1:n===v.UNKNOWN?-1:C.text.asc(e,n)).flatMap(([e,t])=>[{props:{header:u(`constants.file_type.${e}`),icon:b(e)}},...t.map(e=>({title:e?`.${e}`:u(`constants.file_type.no_ext`),value:e})),{props:{divider:!0}}])),X=[{title:u(`constants.file_priority.unwanted`),value:E.DO_NOT_DOWNLOAD},{title:u(`constants.file_priority.normal`),value:E.NORMAL},{title:u(`constants.file_priority.high`),value:E.HIGH},{title:u(`constants.file_priority.max`),value:E.MAXIMAL}],Z=e({extensions:[],priority:[],size:q.value}),Q=m(()=>G.cachedFiles.filter(e=>(!Z.extensions.length||Z.extensions.includes(x(e.name)[1]))&&(!Z.priority.length||Z.priority.includes(e.priority))&&e.size>=Z.size[0]&&e.size<=Z.size[1])),te=m(()=>Q.value.reduce((e,t)=>e+t.size,0));function ne(){G.setFilePriority(Q.value.map(e=>e.index),E.DO_NOT_DOWNLOAD).then($)}function re(){let e=Q.value.filter(e=>e.priority===E.DO_NOT_DOWNLOAD).map(e=>e.index);G.setFilePriority(e,E.NORMAL).then($)}function $(){d.value=!1}return(e,t)=>(h(),c(M,{modelValue:n(d),"onUpdate:modelValue":t[5]||=e=>r(d)?d.value=e:null,fullscreen:e.$vuetify.display.mobile},{default:p(()=>[l(ee,null,{default:p(()=>[l(N,{class:`ios-margin`},{default:p(()=>[l(P,{color:`transparent`},{default:p(()=>[l(F,null,{default:p(()=>[o(g(n(u)(`torrentDetail.content.filter.title`)),1)]),_:1}),l(A,{icon:`mdi-close`,onClick:$})]),_:1})]),_:1}),l(U,null,{default:p(()=>[l(L,null,{default:p(()=>[l(I,{cols:`4`,class:`d-flex align-center`},{default:p(()=>[o(g(n(u)(`torrentDetail.content.filter.extensions`)),1)]),_:1}),l(I,{cols:`8`},{default:p(()=>[l(j,{modelValue:Z.extensions,"onUpdate:modelValue":t[0]||=e=>Z.extensions=e,items:Y.value,placeholder:n(u)(`common.disabled`),"persistent-placeholder":``,multiple:``,"hide-details":``},{item:p(({props:e})=>[e.header?(h(),c(z,{key:0},{default:p(()=>[l(R,null,{default:p(()=>[o(g(e.icon),1)]),_:2},1024),o(` `+g(e.header),1)]),_:2},1024)):e.divider?(h(),c(H,{key:1})):(h(),c(V,a(f({key:2},e)),null,16))]),_:1},8,[`modelValue`,`items`,`placeholder`])]),_:1})]),_:1}),l(L,null,{default:p(()=>[l(I,{cols:`4`,class:`d-flex align-center`},{default:p(()=>[o(g(n(u)(`torrentDetail.content.filter.priority`)),1)]),_:1}),l(I,{cols:`8`},{default:p(()=>[l(j,{modelValue:Z.priority,"onUpdate:modelValue":t[1]||=e=>Z.priority=e,items:X,placeholder:n(u)(`common.disabled`),"persistent-placeholder":``,multiple:``,"hide-details":``},null,8,[`modelValue`,`placeholder`])]),_:1})]),_:1}),l(L,null,{default:p(()=>[l(I,{cols:`4`,class:`d-flex align-center`},{default:p(()=>[o(g(n(u)(`torrentDetail.content.filter.size`)),1)]),_:1}),l(I,{cols:`8`},{default:p(()=>[l(B,{modelValue:Z.size,"onUpdate:modelValue":t[4]||=e=>Z.size=e,direction:e.$vuetify.display.mobile?`vertical`:`horizontal`,color:`primary`,disabled:q.value[0]===q.value[1],min:q.value[0],max:q.value[1],step:1,density:`compact`,"thumb-label":`always`,"hide-details":``},{"thumb-label":p(({modelValue:e})=>[s(`div`,W,g(n(D)(e,n(K).useBinarySize)),1)]),prepend:p(()=>[l(k,{modelValue:Z.size[0],"onUpdate:modelValue":t[2]||=e=>Z.size[0]=e,"hide-spin-buttons":``,density:`compact`,style:{width:`130px`},type:`number`,variant:`outlined`,"hide-details":``,"single-line":``},null,8,[`modelValue`])]),append:p(()=>[l(k,{modelValue:Z.size[1],"onUpdate:modelValue":t[3]||=e=>Z.size[1]=e,"hide-spin-buttons":``,density:`compact`,style:{width:`130px`},type:`number`,variant:`outlined`,"hide-details":``,"single-line":``},null,8,[`modelValue`])]),_:1},8,[`modelValue`,`direction`,`disabled`,`min`,`max`])]),_:1})]),_:1}),l(L,null,{default:p(()=>[l(I,{cols:`12`},{default:p(()=>[o(g(n(u)(`torrentDetail.content.filter.preview`,{count:Q.value.length,total:n(G).cachedFiles.length,size:n(D)(te.value,n(K).useBinarySize)})),1)]),_:1})]),_:1})]),_:1}),l(O,null,{default:p(()=>[l(A,{color:`error`,onClick:ne},{default:p(()=>[o(g(n(u)(`torrentDetail.content.filter.exclude`)),1)]),_:1}),l(A,{color:`success`,onClick:re},{default:p(()=>[o(g(n(u)(`torrentDetail.content.filter.include`)),1)]),_:1})]),_:1})]),_:1})]),_:1},8,[`modelValue`,`fullscreen`]))}});export{G as default};